summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/sebastien/java/embed/BUILDING44
-rw-r--r--sandbox/sebastien/java/embed/CHANGES100
-rw-r--r--sandbox/sebastien/java/embed/LICENSE485
-rw-r--r--sandbox/sebastien/java/embed/NOTICE5
-rw-r--r--sandbox/sebastien/java/embed/README21
-rw-r--r--sandbox/sebastien/java/embed/RELEASE_NOTES84
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml36
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml30
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml110
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip-discriptor/pom.xml33
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml40
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml36
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml30
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml153
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java25
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite29
-rw-r--r--sandbox/sebastien/java/embed/archetypes/pom.xml51
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml43
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml33
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml182
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel66
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl82
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite37
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp36
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml44
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml38
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml154
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java64
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml53
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite35
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml230
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp37
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp22
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp35
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml42
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml31
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml154
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java27
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite32
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml43
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp36
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml44
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml38
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml124
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java31
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/BaseActionBean.java36
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/HomeActionBean.java48
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties77
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties51
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/home.jsp29
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/layout.jsp42
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/taglibs.jsp32
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml68
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html27
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml42
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml31
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml143
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java27
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml43
-rw-r--r--sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp36
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/assembly/pom.xml140
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java236
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/resources/oasis-sca-tests.properties30
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/resources/tuscany-oasis-sca-tests-errors.properties94
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-jms/pom.xml132
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java220
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/resources/oasis-sca-tests.properties30
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/resources/tuscany-oasis-sca-tests-errors.properties43
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-ws/pom.xml119
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-ws/sca_variables.dtd28
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java238
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/resources/oasis-sca-tests.properties30
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/resources/tuscany-oasis-sca-tests-errors.properties33
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/java-caa/pom.xml127
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java238
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/resources/oasis-sca-tests.properties30
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/resources/tuscany-oasis-sca-tests-errors.properties57
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/java-ci/pom.xml122
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java238
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/resources/oasis-sca-tests.properties30
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/resources/tuscany-oasis-sca-tests-errors.properties33
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/policy/pom.xml127
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/policy/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java226
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/policy/src/test/resources/oasis-sca-tests.properties30
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/policy/src/test/resources/tuscany-oasis-sca-tests-errors.properties57
-rw-r--r--sandbox/sebastien/java/embed/compliance-tests/pom.xml48
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/pom.xml64
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/InputStream2Protobuf.java65
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/Protobuf2OutputStream.java60
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufDatabinding.java107
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding20
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer20
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer17
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/java/com/example/tutorial/AddressBookProtos.java1375
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufTransformationTestCase.java63
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/resources/addressbook.proto48
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/META-INF/MANIFEST.MF33
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java58
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java114
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java701
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost18
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java372
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/resources/content/test.html21
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/resources/tuscany.keyStorebin0 -> 1265 bytes
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/META-INF/MANIFEST.MF63
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/pom.xml81
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAGenericApplicationContext.java145
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAParentApplicationContext.java213
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java41
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringContextWrapper.java130
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java53
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java38
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java44
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java49
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java48
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java151
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java112
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java75
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java164
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java168
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java78
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/ComponentWrapper.java38
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/PropertyValueWrapper.java50
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java81
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java78
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java158
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvocationException.java40
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvoker.java126
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader17
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers1
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas1
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd84
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/META-INF/MANIFEST.MF25
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/README9
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/stub/SpringXMLBeanDefinitionLoaderStub.java92
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/ComponentTie.java41
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/PropertyValueTie.java53
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringApplicationContextAccessor.java39
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringContextStub.java142
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProvider.java80
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProviderFactory.java75
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationTie.java156
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvocationException.java40
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvoker.java125
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader17
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/META-INF/MANIFEST.MF25
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/README9
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAGenericApplicationContext.java176
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAParentApplicationContext.java212
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringContextTie.java130
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringImplementationStub.java146
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java129
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java77
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java70
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java68
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java59
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java73
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java73
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java53
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java38
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java44
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java49
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java48
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentNameAnnotationProcessor.java151
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentStub.java54
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ConstructorAnnotationProcessor.java112
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/InitDestroyAnnotationProcessor.java75
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyAnnotationProcessor.java163
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyValueStub.java55
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ReferenceAnnotationProcessor.java167
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/SpringXMLLoaderTie.java57
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/META-INF/spring.handlers1
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/META-INF/spring.schemas1
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/org/springframework/sca/xml/spring-sca.xsd84
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/META-INF/MANIFEST.MF50
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/pom.xml59
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java132
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java90
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java259
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java41
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java73
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java71
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java63
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java92
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java92
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java95
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java917
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java244
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringXMLBeanDefinitionLoader.java50
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder18
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties28
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml30
-rw-r--r--sandbox/sebastien/java/embed/contrib/modules/pom.xml91
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml76
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/calculator/CalculatorService.java31
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/RuntimeIntegration.java43
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleJSELauncher.java45
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/test/java/launcher/LauncherTestCase.java33
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/pom.xml44
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java48
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncHandler.java36
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java48
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java30
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java33
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceProxyImpl.java89
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java31
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite43
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite30
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/README20
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/build.xml118
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/JSELauncherBindingWSCalculator.java75
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/test/java/launcher/LauncherTestCase.java33
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/manifests/axiom-api-1.2.7.MF47
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/manifests/axiom-api-1.2.8.MF49
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/manifests/axis2-kernel-1.5.1.MF39
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/manifests/axis2-transport-http-1.5.1.MF12
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/manifests/woden-impl-dom-1.0M8.MF229
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/pom.xml301
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/assembly/bin-default.xml37
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/assembly/bin-distribution.xml37
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/assembly/src.xml46
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-common.xml43
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-launcher.xml40
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-lib.xml55
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-modules.xml35
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-samples.xml68
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-tracing.xml39
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/INSTALL29
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/LICENSE2300
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/NOTICE5
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/README42
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/default.config22
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/osgi.config21
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/tuscany.bat83
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/tuscany.sh54
-rw-r--r--sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/unmanaged.config21
-rw-r--r--sandbox/sebastien/java/embed/distribution/pom.xml38
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/README.txt8
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/pom.xml40
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/download-tomcat/pom.xml82
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/pom.xml47
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java30
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite30
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml31
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp36
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/pom.xml45
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/java/testing/HelloworldRefImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/java/testing/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/resources/helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/pom.xml48
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/java/testing/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/META-INF/sca-contribution.xml28
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/WEB-INF/web.xml31
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/hello.jsp41
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/java/testing/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/java/testing/HelloworldServlet.java64
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/META-INF/sca-contribution.xml28
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/hello.html52
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/pom.xml45
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite28
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/legal-checks/pom.xml42
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java147
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/testing/pom.xml42
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF24
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/NOTICE7
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java85
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyContextConfig.java183
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyHostConfig.java167
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java161
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java196
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/pom.xml63
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java374
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java70
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/pom.xml106
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/assembly/war.xml98
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE442
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE79
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml40
-rw-r--r--sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp106
-rw-r--r--sandbox/sebastien/java/embed/features/all/pom.xml112
-rw-r--r--sandbox/sebastien/java/embed/features/api/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/features/binding-ws/pom.xml107
-rw-r--r--sandbox/sebastien/java/embed/features/core/pom.xml242
-rw-r--r--sandbox/sebastien/java/embed/features/ejava/pom.xml177
-rw-r--r--sandbox/sebastien/java/embed/features/osgi/pom.xml109
-rw-r--r--sandbox/sebastien/java/embed/features/pom.xml51
-rw-r--r--sandbox/sebastien/java/embed/features/process/pom.xml57
-rw-r--r--sandbox/sebastien/java/embed/features/sdo/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/features/web20/pom.xml145
-rw-r--r--sandbox/sebastien/java/embed/features/webapp/pom.xml96
-rw-r--r--sandbox/sebastien/java/embed/features/webservice/pom.xml107
-rw-r--r--sandbox/sebastien/java/embed/itest/T3558/pom.xml45
-rw-r--r--sandbox/sebastien/java/embed/itest/T3558/src/test/java/org/apache/tuscany/sca/itest/t3558/T3558TestCase.java72
-rw-r--r--sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store-all.jarbin0 -> 15723 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store-client.jarbin0 -> 4829 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store.jarbin0 -> 13510 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/base/dependencies/pom.xml59
-rw-r--r--sandbox/sebastien/java/embed/itest/base/dependencies/src/test/java/org/apache/tuscany/sca/itest/base/dependencies/ValidateDependenciesTestCase.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/base/pom.xml36
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/pom.xml286
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java65
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite32
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl87
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel84
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl94
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/log4j.properties36
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/pom.xml175
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java71
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel66
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite32
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl82
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/log4j.properties36
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld/pom.xml270
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java75
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel78
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl94
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/log4j.properties36
-rw-r--r--sandbox/sebastien/java/embed/itest/bpel/pom.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/pom.xml112
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java48
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/scenario1.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/scenario1a.composite47
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/scenario10.composite62
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/scenario10a.composite61
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/service3.wsdl63
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/scenario11.composite59
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/scenario11a.composite64
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/service3.wsdl63
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/scenario12.composite58
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/scenario12a.composite64
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/scenario13.composite58
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/scenario13a.composite64
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/scenario2.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/scenario2a.composite47
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/scenario3.composite44
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/scenario3a.composite48
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/scenario4.composite44
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/scenario4a.composite48
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenario5.composite46
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenario5a.composite47
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenarios.wsdl63
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenario6.composite47
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenario6a.composite47
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenarios.wsdl63
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenario7.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenario7a.composite49
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenarios.wsdl63
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenario8.composite44
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenario8a.composite50
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenarios.wsdl63
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/scenario9.composite60
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/scenario9a.composite61
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java814
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java99
-rw-r--r--sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java319
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java201
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java113
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/src/main/resources/CallBackApiTest.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java70
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java129
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/src/main/resources/CallBackBasicTest.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java138
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType28
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClient.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl1.java49
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl2.java49
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyService.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceCallback.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/test/java/org/apache/tuscany/sca/test/callback/CallbackMultiWireTestCase.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-separatethread/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java186
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java195
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java73
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/pom.xml79
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java129
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/CallBackReference.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/CallBackService.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-composites/src/test/java/org/apache/tuscany/sca/test/CallBackTwoCompositesTestCase.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/pom.xml86
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java129
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/CallBackReference.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/CallBackService.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/callback-two-nodes/src/test/java/org/apache/tuscany/sca/test/CallBackTwoNodesTestCase.java78
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/AddService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/AddServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorClient.java49
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java63
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/DivideServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/resources/Calculator.composite49
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType27
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType43
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType27
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType27
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType27
-rw-r--r--sandbox/sebastien/java/embed/itest/component-type/src/test/java/calculator/CalculatorTestCase.java60
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-folder/pom.xml46
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-folder/src/test/java/calculator/CalculatorService.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite49
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jarbin0 -> 2380 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jarbin0 -> 4655 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository3/contribution.zipbin0 -> 5478 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/pom.xml67
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/resources/hello.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java91
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/pom.xml67
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType30
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/pom.xml31
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html27
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/pom.xml31
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl76
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd35
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/pom.xml73
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml27
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl76
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd35
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite39
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java126
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/pom.xml73
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java127
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/pom.xml102
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/main/resources/store.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/test/java/org/apache/tuscany/sca/test/contribution/StoreTestCase.java129
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/pom.xml73
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java137
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-import-export/pom.xml56
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-zip/pom.xml45
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-zip/src/test/java/calculator/CalculatorService.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/contribution-zip/src/test/resources/repository/contribution.zipbin0 -> 7287 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/pom.xml144
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java153
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioOneTestCase.java373
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioSixTestCase.java230
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioThreeTestCase.java132
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioTwoTestCase.java141
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHost.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHostModuleActivator.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStruct.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHelper.java97
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/Color.java61
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ColorHelper.java72
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ColorHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStruct.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStructHelper.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStructHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnion.java130
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java124
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/LongSequenceHelper.java79
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/LongSequenceHolder.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStruct.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStructHelper.java110
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStructHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnion.java195
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java175
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOne.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneHelper.java104
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneOperations.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSix.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixHelper.java104
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwo.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHelper.java106
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHolder.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoOperations.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringArrayHelper.java95
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringArrayHolder.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringSequenceHelper.java81
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringSequenceHolder.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHelper.java83
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHolder.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedException.java52
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHelper.java98
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColor.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColorHelper.java105
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColorHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioOneImplBase.java91
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioOneStub.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java105
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java119
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoImplBase.java93
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoStub.java99
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFive.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveComponent.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveImpl.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourException.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioOneComponent.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioOneServant.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioSixServant.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioTwoServant.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TAnnotatedStruct.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TColor.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerStruct.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerUnion.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichStruct.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichUnion.java95
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOne.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOneComponent.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOneServant.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSix.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixComponent.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixServant.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThree.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThreeComponent.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThreeServant.java52
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwo.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwoComponent.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwoServant.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator18
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioFive.composite41
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioFour.composite56
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioOne.composite111
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioSix.composite41
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioThree.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioTwo.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/itest_scenario.idl110
-rw-r--r--sandbox/sebastien/java/embed/itest/corba/src/test/resources/scenariofour.xsd31
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/pom.xml188
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/AClientService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/AService.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean1.java66
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean10.java25
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean11.java25
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean2.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean3.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean31.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsLocalService.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsServiceClient.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloLocalServiceSimple.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceSimple.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceSimpleClient.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesLocalService.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesServiceClient.java48
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesLocalService.java78
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesServiceClient.java79
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/AClientServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/AServiceImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsLocalServiceClientImpl.java77
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsServiceClientImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsServiceImpl.java69
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsTransformer.java125
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloLocalServiceSimpleClientImpl.java73
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceSimpleClientImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceSimpleImpl.java86
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesLocalServiceClientImpl.java138
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceClientImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceImpl.java151
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesLocalServiceClientImpl.java157
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceClientImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.java208
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesTransformer.java144
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/aservice.wsdl127
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/doclitbarewsdl.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/generics-service.composite69
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/helloservice.composite65
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/primitivesservice.composite66
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/standard-types-service.composite66
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/DatabindingTestCase.java345
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/DocLitBareWsdlTestCase.java75
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsDatabindingTestCase.java493
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesDatabindingTestCase.java784
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesDatabindingTestCase.java1439
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/pom.xml189
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloService.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceClient.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesService.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesServiceClient.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesService.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesServiceClient.java81
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceClientImpl.java73
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceImpl.java86
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceClientImpl.java139
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceImpl.java151
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceClientImpl.java159
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.java207
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesTransformer.java142
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/hello-service.wsdl372
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/helloservice.composite80
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/primitives-service.wsdl927
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/primitivesservice.composite80
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/standard-types-service.composite80
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/standard-types-service.wsdl1155
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/DatabindingTestCase.java346
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/PrimitivesDatabindingTestCase.java849
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/StandardTypesDatabindingTestCase.java1438
-rw-r--r--sandbox/sebastien/java/embed/itest/databindings/pom.xml41
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/bin-distro-unzip/build.xml27
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/bin-distro-unzip/pom.xml128
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/contribution-binding-rmi-calculator/build.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/contribution-binding-rmi-calculator/pom.xml68
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/contribution-binding-sca-calculator/build.xml40
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/contribution-binding-sca-calculator/pom.xml87
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/contribution-binding-ws-calculator/build.xml40
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/contribution-binding-ws-calculator/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/contribution-implementation-java-calculator/build.xml40
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/contribution-implementation-java-calculator/pom.xml87
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-jse/build.xml41
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-jse/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-osgi/build.xml45
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-osgi/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/legal-checks/pom.xml71
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java162
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/pom.xml85
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/src-distro-rat/pom.xml82
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/src-distro-unzip/build.xml27
-rw-r--r--sandbox/sebastien/java/embed/itest/distribution/src-distro-unzip/pom.xml128
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/distributed/pom.xml51
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/distributed/src/test/java/itest/Helloworld.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/distributed/src/test/java/itest/StandaloneTestCase.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/helloworld/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/java/itest/HelloworldImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/resources/helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/interfaces/pom.xml51
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/interfaces/src/main/java/itest/Helloworld.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/pom.xml38
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/standalone/pom.xml57
-rw-r--r--sandbox/sebastien/java/embed/itest/domains/standalone/src/test/java/itest/StandaloneTestCase.java66
-rw-r--r--sandbox/sebastien/java/embed/itest/endpoints/pom.xml68
-rw-r--r--sandbox/sebastien/java/embed/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/endpoints/src/test/java/helloworld/HelloWorldService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/EndpointsTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/Utils.java70
-rw-r--r--sandbox/sebastien/java/embed/itest/endpoints/src/test/resources/helloworld.composite116
-rw-r--r--sandbox/sebastien/java/embed/itest/endpoints/src/test/resources/nested.composite30
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java115
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java116
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/main/resources/ExceptionTest.composite41
-rw-r--r--sandbox/sebastien/java/embed/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java85
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/pom.xml92
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/AddService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/CalculatorService.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java79
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java178
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java66
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestBean.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestReference.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java131
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml45
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite49
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite49
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml29
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite30
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF3
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml31
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml36
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml34
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config3
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties18
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite58
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/definitions.xml54
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite40
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF3
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml34
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite40
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/jar/spring-context.jarbin0 -> 1454 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml31
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml33
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml34
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite40
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml41
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml31
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite34
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite60
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml41
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java77
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java48
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/exports/pom.xml40
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/exports/src/main/java/org/apache/tuscany/sca/itest/exports/Helloworld.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/exports/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/imports/pom.xml46
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/imports/src/main/java/org/apache/tuscany/sca/itest/imports/HelloworldImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/imports/src/main/resources/Helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/imports/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/pom.xml38
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/tests/pom.xml40
-rw-r--r--sandbox/sebastien/java/embed/itest/import-export/tests/src/test/java/org/apache/tuscany/sca/itests/TestTestCase.java60
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java83
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java49
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java48
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java81
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/invalid/InvalidRemoteAttribute.composite28
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/valid/InterfacesTest.composite40
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java137
-rw-r--r--sandbox/sebastien/java/embed/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java52
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws-asyncclient/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java69
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java67
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/StockQuote.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/StockQuoteImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/jaxws/src/test/resources/StockQuote.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/args/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/selectors/selectors.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/pom.xml73
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/jndi.properties40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/simple/client.composite44
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/simple/tempq.composite50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java61
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/defaults/client.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/defaults/service.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/pom.xml73
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/definitions.xml28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/definitions/definitions.composite39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/pom.xml90
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/exceptions/service.composite44
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/jndi.properties40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java212
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/exceptions/client.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/exceptions/service.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/external/client.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/external/service.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java71
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java69
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java85
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite94
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl139
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java68
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README3
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite46
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl129
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java63
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite61
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java73
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java60
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite80
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl161
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java85
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README3
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java63
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite52
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl139
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite54
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java144
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/noreplyto/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/service.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java100
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/nulls/pom.xml71
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/nulls.composite57
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java60
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java60
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/META-INF/definitions.xml65
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/policy-headers/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java94
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/pom.xml68
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/properties/properties.composite53
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java93
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/cf/client.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/cf/service.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/jndi.properties39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/simple/client.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/simple/service.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite69
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite65
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/selectors/selectors.composite68
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java76
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/pom.xml71
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/topics/TopicsClient.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/topics/TopicsService.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/ttl/pom.xml71
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java904
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/ttl.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/jndi.properties38
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/simple/service.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/node-launcher-equinox/pom.xml76
-rw-r--r--sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorld.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java100
-rw-r--r--sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java67
-rw-r--r--sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/resources/HelloWorld.composite34
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/pom.xml94
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java70
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java66
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java79
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java83
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java74
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/AsynchTestCase.java79
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/CallbackTestCase.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/PromotionTestCase.java76
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/SimpleTestCase.java116
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldCallbackRemote.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldClient.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackOnewayRemote.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackRemote.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceLocal.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote2.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientLocalImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemote2Impl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemoteImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceLocalImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceRemoteImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java170
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java63
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ServiceNode.java48
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/TestCaseRunner.java329
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchReference/HelloWorld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchService/HelloWorld.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackReference/HelloWorld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackService/HelloWorld.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/HelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/HelloWorldComponent.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/HelloWorld.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/HelloWorldComponent.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleReference/HelloWorld.composite67
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleService/HelloWorld.composite85
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchReference/HelloWorld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchService/HelloWorld.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackReference/HelloWorld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackService/HelloWorld.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/HelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/HelloWorldComponent.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/HelloWorld.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/HelloWorldComponent.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleReference/HelloWorld.composite67
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleService/HelloWorld.composite84
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java70
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java66
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java79
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java83
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java74
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/AsynchTestCase.java79
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/CallbackTestCase.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/PromotionTestCase.java76
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/SimpleTestCase.java116
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldCallbackRemote.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldClient.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackOnewayRemote.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackRemote.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceLocal.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote2.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientLocalImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemote2Impl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemoteImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceLocalImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceRemoteImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java170
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java63
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ServiceNode.java48
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/TestCaseRunner.java329
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchReference/HelloWorld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchService/HelloWorld.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackReference/HelloWorld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackService/HelloWorld.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/HelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/HelloWorldComponent.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/HelloWorld.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/HelloWorldComponent.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleReference/HelloWorld.composite67
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleService/HelloWorld.composite85
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchReference/HelloWorld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchService/HelloWorld.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackReference/HelloWorld.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackService/HelloWorld.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/HelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/HelloWorldComponent.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/HelloWorld.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/HelloWorldComponent.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleReference/HelloWorld.composite67
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleReference/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleService/HelloWorld.composite84
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleService/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-client/pom.xml44
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-iface/pom.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/pom.xml44
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/java/itest/nodes/HelloworldImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/resources/service-a.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/pom.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/Helloworld.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/HelloworldClientImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/HelloworldServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/resources/helloworld-service.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/pom.xml49
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/java/itest/nodes/HelloworldImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/resources/service-b.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/pom.xml49
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/java/itest/nodes/HelloworldImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/resources/service-c.composite28
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service/pom.xml43
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite28
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast-client/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/pom.xml68
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/OneNodeOneContributionTestCase.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/OneNodeTestCase.java76
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/TwoNodeTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/TwoRemoteNodesTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/pom.xml82
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/OneNodeTestCase.java76
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/TwoNodeTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/TwoRemoteNodesTestCase.java83
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm/src/test/java/itest/OneNodeTestCase.java76
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-jvm/src/test/java/itest/TwoNodeTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-node-test/pom.xml48
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java87
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/pom.xml63
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/build.xml38
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/client.xml31
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/pom.xml104
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/server.xml30
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-a-config.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-b-config.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-c-config.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceA.java65
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceB.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceC.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/pom.xml59
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java93
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java103
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java292
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java106
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/build.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/client-config.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/client.xml55
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/pom.xml114
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/scaclient.xml54
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/server-config.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/server.xml42
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/Client.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/SCAClient.java66
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/Service.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/build.xml38
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/client-config.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/client.xml31
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/pom.xml104
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/server-config.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/server.xml33
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/Client.java69
-rw-r--r--sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/Service.java61
-rw-r--r--sandbox/sebastien/java/embed/itest/oneway/build.xml127
-rw-r--r--sandbox/sebastien/java/embed/itest/oneway/pom.xml64
-rw-r--r--sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java47
-rw-r--r--sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java68
-rw-r--r--sandbox/sebastien/java/embed/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite57
-rw-r--r--sandbox/sebastien/java/embed/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java235
-rw-r--r--sandbox/sebastien/java/embed/itest/operation-overloading/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java61
-rw-r--r--sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadASource.java113
-rw-r--r--sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATarget.java99
-rw-r--r--sandbox/sebastien/java/embed/itest/operation-overloading/src/main/resources/OperationOverload.composite34
-rw-r--r--sandbox/sebastien/java/embed/itest/operation-overloading/src/test/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATestCase.java98
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/pom.xml59
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java65
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java78
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/resources/Customer.composite34
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/resources/LoggingMessages.properties16
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/resources/META-INF/definitions.xml82
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/main/resources/Payment.composite57
-rw-r--r--sandbox/sebastien/java/embed/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java69
-rw-r--r--sandbox/sebastien/java/embed/itest/policy-transaction/pom.xml72
-rw-r--r--sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/Customer.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/CustomerRegistry.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/impl/CustomerRegistryImpl.java63
-rw-r--r--sandbox/sebastien/java/embed/itest/policy-transaction/src/main/resources/Customer.composite30
-rw-r--r--sandbox/sebastien/java/embed/itest/policy-transaction/src/test/java/org/apache/tuscany/sca/itest/policy/transaction/CustomerTestCase.java69
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorldClient.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml67
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite86
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.wsdl90
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java135
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/pom.xml37
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorldClient.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/LoggingMessages.properties16
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/definitions.xml42
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/helloworld.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/helloworld.wsdl90
-rw-r--r--sandbox/sebastien/java/embed/itest/policy/wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyTestCase.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/pom.xml110
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/pom.xml74
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java88
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java50
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java73
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java75
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java131
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java71
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java143
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java151
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java114
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java144
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java23
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java75
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java103
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/package-info.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/ConstructorPropertyInjection.composite39
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/Outer.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/OuterPropertyTest.composite42
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/PropertyTest.composite260
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/customer.xsd30
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/fileProperty.txt21
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/foo.xsd40
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/manyValuesFileProperty.txt25
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/mySimpleService.composite40
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/rcProps.txt22
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/main/resources/rcprops.xsd55
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java104
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java169
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java422
-rw-r--r--sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java72
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/pom.xml61
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite53
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite49
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite52
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java92
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/pom.xml92
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/Target.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/TargetClientImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/TargetServiceImpl.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/Composer.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerClient.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerClientImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerServer.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Client.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Inner.composite27
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Outer.composite32
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/bindingoverride/InnerComposite.composite36
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/bindingoverride/OuterComposite.composite38
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/PolicyInnerComposite.composite37
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/PolicyOuterComposite.composite39
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/definitions.xml39
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/bindingoverride/BindingOverrideTestCase.java65
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/policy/PolicyTestCase.java81
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/recursive/ComposerClientTestCase.java76
-rw-r--r--sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/recursive/ComposerTestServer.java61
-rw-r--r--sandbox/sebastien/java/embed/itest/references/pom.xml52
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java125
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java24
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java26
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/resources/AutoWiredReferencesTest.composite61
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/resources/InnerReferencesTest.composite51
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/main/resources/ManualWiredReferencesTest.composite59
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java114
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java99
-rw-r--r--sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java97
-rw-r--r--sandbox/sebastien/java/embed/itest/samples/helloworld/pom.xml38
-rw-r--r--sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/Helloworld.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/HelloworldDomainNodeTestCase.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/HelloworldNodeTestCase.java49
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/pom.xml57
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/java/itest/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/java/itest/HelloworldServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/resources/Helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/test/java/test/scaclient/SCAClientTestCase.java63
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-osgi/META-INF/MANIFEST.MF20
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-osgi/pom.xml109
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/java/itest/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/java/itest/HelloworldServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/resources/Helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/test/java/test/scaclient/SCAClientTestCase.java65
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-remote/pom.xml64
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/java/itest/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/java/itest/HelloworldServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/resources/Helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/test/java/test/scaclient/SCAClientTestCase.java115
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api/pom.xml46
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/RemoteHelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api/src/main/resources/Helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java129
-rw-r--r--sandbox/sebastien/java/embed/itest/scdl/pom.xml79
-rw-r--r--sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java80
-rw-r--r--sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java109
-rw-r--r--sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/scdl/src/test/resources/test.composite51
-rw-r--r--sandbox/sebastien/java/embed/itest/scopes/pom.xml54
-rw-r--r--sandbox/sebastien/java/embed/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java25
-rw-r--r--sandbox/sebastien/java/embed/itest/scopes/src/main/resources/scopes.composite29
-rw-r--r--sandbox/sebastien/java/embed/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java89
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/pom.xml66
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java297
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/nodeA/CompositeA.composite44
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/nodeB/CompositeB.composite46
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite48
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java139
-rw-r--r--sandbox/sebastien/java/embed/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java88
-rw-r--r--sandbox/sebastien/java/embed/itest/services/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java25
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java27
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java24
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java24
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/main/resources/ServicesTest.composite70
-rw-r--r--sandbox/sebastien/java/embed/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java108
-rw-r--r--sandbox/sebastien/java/embed/itest/wires/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/itest/wires/src/main/resources/WireTest.composite39
-rw-r--r--sandbox/sebastien/java/embed/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java78
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/README83
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/Bar.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/Foo.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/HelloWorldServiceService_schema1.xsd38
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/helloworld-external-service.wsdl57
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/helloworld.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/pom.xml125
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/impl/HelloWorldImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld-external.wsdl84
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld-sca.wsdl84
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/pom.xml122
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java73
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl104
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd93
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/pom.xml104
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java57
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java49
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/pom.xml114
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java119
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/WSDLFirstTestCaseOFF.java143
-rw-r--r--sandbox/sebastien/java/embed/itest/ws-jaxws/pom.xml41
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/README135
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/pom.xml47
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java45
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/definitions.xml46
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl90
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloworldTestCase.java52
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/HelloWorldServiceService_schema1.xsd70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/helloworld-external-service.wsdl75
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/helloworld.composite45
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/HelloWorldServiceService_schema1.xsd70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/helloworld-external-service.wsdl75
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/helloworld.composite51
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/HelloWorldServiceService_schema1.xsd70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworld-external-service.wsdl75
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworld.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworldcallbackservice-bottom.composite34
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworldservice-bottom.composite40
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java31
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java53
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java84
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/HelloWorldServiceService_schema1.xsd70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/helloworld-external-service.wsdl75
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/helloworld.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit.wsdl109
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit1.xsd83
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit2.xsd40
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldServiceService_schema1.xsd70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/helloworld-external-service.wsdl75
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/helloworld.composite44
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java56
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldBare.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit.wsdl113
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit1.xsd49
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit2.xsd40
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldServiceService_schema1.xsd70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/helloworld-external-service.wsdl75
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/helloworld.composite44
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-java-first/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/HelloWorldServiceService_schema1.xsd70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/helloworld-external-service.wsdl75
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/helloworld.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/README254
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/pom.xml123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java32
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java54
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java55
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit.wsdl110
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit1.xsd83
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit2.xsd40
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldServiceService_schema1.xsd70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/helloworld-external-service.wsdl75
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/helloworld.composite64
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/pom.xml125
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java37
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java60
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService.wsdl128
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService_schema1.xsd99
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService_schema2.xsd40
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldServiceService_schema1.xsd86
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/helloworld-external-service.wsdl99
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/helloworld.composite35
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/pom.xml47
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Bar.java58
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Foo.java36
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldClient.java40
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java42
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.composite41
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl90
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/defaults/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultsTestCase.java74
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoint-references/pom.xml47
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldComponent.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.composite48
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl86
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java52
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/pom.xml47
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldMultiService.java51
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM2.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMComponent.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMService.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/DefaultMultiService.composite53
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/DefaultSingleService.composite51
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLExplicitURI.composite50
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite51
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl78
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-uri.wsdl78
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om.wsdl78
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java68
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultMultiServiceTestCase.java24
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultSingleServiceTestCase.java24
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLExplicitURITestCase.java24
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURITestCase.java24
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-client/pom.xml112
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java91
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-client/src/main/resources/HelloWorldImplService.wsdl128
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd111
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-service/pom.xml104
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/Bar.java152
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/Foo.java88
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java64
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java49
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/README68
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/pom.xml52
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java35
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/definitions.xml35
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite59
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl90
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/tuscany.jksbin0 -> 1378 bytes
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/http-ssl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HTTPSTestCase.java59
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/pom.xml67
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackForwardSpecTestCase.java114
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackFullSpecTestCase.java111
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackPromotionTestCase.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackTestCase.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/DocLitTestCase.java124
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/DocLitWrappedTestCase.java122
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/JavaFirstTestCase.java123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/RpcLitTestCase.java122
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/WSDLFirstTestCase.java130
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-base/pom.xml59
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackForwardSpecTestCase.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackFullSpecTestCase.java111
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackPromotionTestCase.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackTestCase.java112
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/DocLitWrappedTestCase.java122
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/JavaFirstTestCase.java123
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/WSDLFirstTestCase.java125
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/pom.xml61
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/pom.xml47
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Account.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AccountService.java33
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/CustomerProfileData.java113
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM.java30
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMComponent.java34
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMService.java41
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java28
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/package-info.java21
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerdata.xsd36
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerdefs.xsd27
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerinfo.xsd31
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.composite43
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.wsdl59
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl86
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import-nested.wsdl70
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import.wsdl49
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-include.wsdl90
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-import.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-include.composite31
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl.composite33
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldWSDLMergedTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLImportTestCase.java99
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLIncludeTestCase.java98
-rw-r--r--sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java126
-rw-r--r--sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/README21
-rw-r--r--sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/pom.xml60
-rw-r--r--sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyLaunchMojo.java108
-rw-r--r--sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java188
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/META-INF/MANIFEST.MF71
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/pom.xml94
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java713
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java471
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java185
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java1259
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java181
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java257
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java132
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java242
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java132
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java128
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java171
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java299
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java250
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExternalAttachmentProcessor.java296
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java446
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java572
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java295
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml242
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor29
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor22
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver21
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint17
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties32
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties24
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties50
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java192
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java130
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java143
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java162
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java109
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java136
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java99
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java230
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java161
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java307
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite59
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType31
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorURISpaces.composite59
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite32
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite29
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite44
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite127
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite56
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite125
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml96
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite27
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml206
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml207
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite49
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml206
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/LICENSE338
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/META-INF/MANIFEST.MF13
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/NOTICE38
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/pom.xml31
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java140
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema19
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd402
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd204
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd195
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd108
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd137
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd141
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd35
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd117
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd318
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-1.1-cd05-rev1.xsd38
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-1.1-cd05.xsd38
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd02-rev1.xsd33
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04-rev1.xsd169
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04-rev1.xsd186
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd05-rev1.xsd20
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04-rev1.xsd34
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd20
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd05-rev1.xsd89
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd05-rev1.xsd35
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd05-rev1.xsd35
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02-rev1.xsd34
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd05-rev1.xsd468
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd05-rev1.xsd31
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd32
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd05-rev1.xsd55
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd05-rev1.xsd26
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd05-rev1.xsd63
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd02-rev1.xsd26
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd21
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd05-rev1.xsd51
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd51
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd05-rev1.xsd51
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04-rev1.xsd28
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd05-rev1.xsd28
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd52
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd03-rev1.xsd131
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd03.xml249
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-atom.xsd43
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd41
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd41
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jms.xsd128
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd41
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rest.xsd105
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd40
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rss.xsd43
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd53
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-script.xsd38
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-widget.xsd42
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd40
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/META-INF/MANIFEST.MF60
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/pom.xml45
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java167
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java114
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java113
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java132
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java111
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java139
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java165
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java107
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java149
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ContractBuilder.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java479
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/WireBuilder.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java112
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java138
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java122
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java186
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java119
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java176
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java185
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java283
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java233
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java135
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java148
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java105
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java92
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java307
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java110
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Compatibility.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java120
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java116
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java232
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java204
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java220
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java574
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java329
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java282
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/Audit.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java144
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java101
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java204
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java153
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java161
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java159
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java168
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java87
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java154
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java130
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint18
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper19
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties327
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties85
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties30
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties25
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java170
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java396
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/META-INF/MANIFEST.MF24
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/src/main/java/org/apache/tuscany/sca/binding/atom/js/dojo/AtomBindingJavascriptProxyFactoryImpl.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/META-INF/MANIFEST.MF47
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/pom.xml227
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/Collection.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/MediaCollection.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/NotFoundException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java510
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java895
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java165
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java178
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java105
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java118
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java219
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java121
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java159
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java258
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClient.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClientImpl.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java153
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerNonCollectionImpl.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionImpl.java213
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java294
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java432
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java386
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTestCase.java204
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Aggregator.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorImpl.java135
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Sort.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/SortImpl.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/Headline.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsService.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceImpl.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/util/AtomTestCaseUtils.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gifbin0 -> 14205 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpgbin0 -> 21373 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite38
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/META-INF/MANIFEST.MF19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/pom.xml54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.java110
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/META-INF/MANIFEST.MF35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/pom.xml130
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaBindingProviderFactory.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaInvoker.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaReferenceBindingProvider.java101
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaServiceBindingProvider.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/CorbaException.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/RequestConfigurationException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaArray.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElement.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElementType.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaRequest.java253
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaResponse.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceInstanceCreator.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceMethodInterceptor.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/ComponentInvocationProxy.java122
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/DynaCorbaServant.java137
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationProxy.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/OperationTypes.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/AnnotationAttributes.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/NodeType.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTree.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeCreator.java497
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeNode.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/UnionAttributes.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ArrayTypeHelper.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/BooleanTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ByteTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/CharTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/DoubleTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/EnumTypeHelper.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/FloatTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/IntTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/LongTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ReferenceTypeHelper.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/SequenceTypeHelper.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ShortTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StringTypeHelper.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StructTypeHelper.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelper.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelpersProxy.java119
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/UnionTypeHelper.java92
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/Utils.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/MethodFinder.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/OperationMapper.java578
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java565
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java841
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MappingTestInterface.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MethodFinderTestCase.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/OperationMappingTestCase.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/TestConstants.java87
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java194
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java174
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java166
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java104
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java117
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java146
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java99
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java232
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java343
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java230
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java341
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java149
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java182
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/ArraysTestStruct.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/Calc.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/DummyObject.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InnerUnion.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidCorbaArray.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion1.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion2.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion3.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion4.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion5.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/NonCorbaException.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/RichUnion.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SimpleStruct.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SomeStruct.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java92
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysSetterServant.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsServant.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsTuscanyServant.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/CalcServant.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/DummyObjectServant.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTestObjectServant.java24
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTypesServant.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/NonCorbaServant.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ObjectManagerServant.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/PrimitivesSetterServant.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/TestObjectServant.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java194
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java177
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java226
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java311
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/arrays_unions.idl69
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/enums.idl44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/exceptions.idl58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/general_tests.idl124
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/references.idl50
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/META-INF/MANIFEST.MF29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java137
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.corba.CorbaBindingFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/META-INF/MANIFEST.MF39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/pom.xml169
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ClassLoadingUtil.java365
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/DynamicStubClassLoader.java150
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/Java2IDLUtil.java811
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ObjectInputStreamExt.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/StubMethodInterceptor.java154
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/UtilInitializer.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java338
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java483
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java209
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java117
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java157
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java189
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java124
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/Customer.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java138
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/resources/account/account.composite37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/META-INF/MANIFEST.MF26
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/pom.xml60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java203
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java168
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/META-INF/MANIFEST.MF31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java127
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor21
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java114
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/client.composite29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/client2.composite29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/service.composite28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/META-INF/MANIFEST.MF26
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/pom.xml94
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java462
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPGetListenerServlet.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java208
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceListenerServlet.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java903
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java163
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/NotModifiedException.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/PreconditionFailedException.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java243
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestGetImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceImpl.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/content/test.html21
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/test.composite47
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/testCache.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/META-INF/MANIFEST.MF23
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/pom.xml54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/META-INF/MANIFEST.MF40
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/pom.xml117
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java141
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java174
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderServiceInterceptor.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java253
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java192
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java107
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyInterceptor.java104
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyInterceptor.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderPolicyProviderFactory.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderReferencePolicyInterceptor.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderReferencePolicyProvider.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java136
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java120
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java302
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java169
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java246
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java109
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java282
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java231
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java262
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java136
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java132
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java157
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java210
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java92
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java109
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java175
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java204
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java187
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java198
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java113
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java139
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java119
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java124
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java101
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java113
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java116
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory21
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory25
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java229
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/resources/simple/client.composite38
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/resources/simple/service.composite35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/META-INF/MANIFEST.MF62
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/pom.xml51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java982
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java1671
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefaultProcessor.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserProp.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserPropProcessor.java87
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicy.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java111
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java130
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java206
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytes.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesProcessor.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXML.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXMLProcessor.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefaultProcessor.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObject.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObjectProcessor.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSText.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextProcessor.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXML.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXMLProcessor.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java773
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java438
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/pom.xml104
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java174
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java223
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/BeanA.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/resources/jquery.html51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/META-INF/MANIFEST.MF17
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/pom.xml41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/META-INF/MANIFEST.MF22
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/pom.xml52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/js/dojo/JSONRPCBindingJavascriptProxyFactoryImpl.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/NOTICE11
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/pom.xml154
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java155
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java111
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java394
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JavaToSmd.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/resources/org/apache/tuscany/sca/binding/jsonrpc/provider/jsonrpc.js493
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java202
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java101
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite38
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/META-INF/MANIFEST.MF16
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/pom.xml46
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingFactoryImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/META-INF/MANIFEST.MF51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/pom.xml175
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java256
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFactory.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorReferenceProvider.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorServiceProvider.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorInterceptor.java203
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorProviderFactory.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorReferenceProvider.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorServiceProvider.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java203
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/JAXRSHelper.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java298
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java582
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java371
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java118
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java127
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java159
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFactory.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatReferenceProvider.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java136
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatInterceptor.java143
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFactory.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatReferenceProvider.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java137
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/NotModifiedException.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/PreconditionFailedException.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/RESTBindingCacheTestCase.java903
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/RESTBindingTestCase.java163
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestBindingCacheImpl.java199
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestGetImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestServiceImpl.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java145
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java150
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/CustomerServiceTestCase.java119
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/binary/BinaryService.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/binary/BinaryServiceImpl.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/Customer.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/CustomerService.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/CustomerServiceImpl.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverter.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverterImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Item.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Items.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/binary.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/content/test.html21
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/customer.composite39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/echo.composite44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/store.composite41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/test.composite40
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/testCache.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/META-INF/MANIFEST.MF27
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/pom.xml60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java111
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelector.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelectorFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorImpl.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelector.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelectorFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorImpl.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormat.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormatFactory.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormat.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormatFactory.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatFactoryImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java232
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor27
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorProcessorTestCase.java107
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatProcessorTestCase.java133
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/META-INF/MANIFEST.MF28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/pom.xml79
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java168
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RemoteInterfaceGenerator.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType23
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType28
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/META-INF/MANIFEST.MF17
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/pom.xml41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/pom.xml170
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java397
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java25
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java114
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/META-INF/MANIFEST.MF20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/pom.xml78
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBinding.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBindingFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingImpl.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/META-INF/MANIFEST.MF43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/pom.xml72
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java220
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAServiceBindingProvider.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java215
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java101
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java104
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingMapper.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper17
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml27
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/resources/Calculator.composite59
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF151
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/pom.xml436
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java156
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BaseBindingProvider.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BindingProviderFactory.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java540
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java380
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java382
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java304
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInMessageReceiver.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInOutSyncMessageReceiver.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceServlet.java300
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyDispatcher.java104
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyListingAgent.java232
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java296
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/transport/TransportReferenceInterceptor.java137
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory21
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml44
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml507
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/modules.list1
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/rampart-1.4.marbin0 -> 2796 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/services/services.list0
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingTestCase.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingURITestCase.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingWSATestCase.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl86
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.composite42
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/META-INF/MANIFEST.MF54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/pom.xml151
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSBindingProviderFactory.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSReferenceBindingProvider.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java140
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml41
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLPortTestCase.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.composite39
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.wsdl80
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/META-INF/MANIFEST.MF55
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/pom.xml235
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java580
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingProvider.java314
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/pom.xml79
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java359
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java897
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLContractBuilder.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java305
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java527
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder18
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ContractBuilder18
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java21
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/META-INF/MANIFEST.MF45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/pom.xml74
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java279
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java460
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java223
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java526
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties38
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite59
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite63
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite60
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl26
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd136
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl58
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl45
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd33
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl63
-rw-r--r--sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl76
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/META-INF/MANIFEST.MF43
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/pom.xml65
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java355
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java1695
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java582
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java696
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java126
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java477
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeWireApplierImpl.java212
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java137
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java883
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/IntentValidator.java139
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java188
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java175
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java389
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java191
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/WireBuilderImpl.java1028
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/WireMatcherImpl.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder18
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties39
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java132
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java139
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite49
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite34
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite29
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite32
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml38
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odgbin0 -> 15518 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.pngbin0 -> 4041817 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml207
-rw-r--r--sandbox/sebastien/java/embed/modules/common-http/META-INF/MANIFEST.MF14
-rw-r--r--sandbox/sebastien/java/embed/modules/common-http/pom.xml47
-rw-r--r--sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java261
-rw-r--r--sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContext.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPHeader.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/META-INF/MANIFEST.MF22
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/pom.xml55
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundEnumeration.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundIterator.java113
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java167
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java586
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/SubTestImpl.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test1.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test2.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/TestImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/META-INF/MANIFEST.MF57
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/pom.xml98
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java153
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java231
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/impl/SAX2DOMAdapter.java244
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/sax/SAXHelper.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java573
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/StAX2SAXAdapter.java256
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java368
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXMLStreamReader.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXmlNodeImpl.java150
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DelegatingNamespaceContext.java310
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValueArrayStreamReader.java404
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValuePairStreamReader.java348
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamedProperty.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamespaceContextImpl.java124
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NilElementStreamReader.java279
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/SimpleXmlNodeImpl.java112
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/WrappingXMLStreamReader.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLDocumentStreamReader.java482
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReader.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReaderImpl.java858
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLStreamable.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNode.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNodeIterator.java258
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderImpl.java531
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XMLCharHelper.java613
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java169
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/dom/DOMHelperTestCase.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/StAXHelperTestCase.java112
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderTestCase.java207
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java147
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.wsdl60
-rw-r--r--sandbox/sebastien/java/embed/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.xsd30
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/META-INF/MANIFEST.MF24
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/pom.xml72
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/BundleReference.java136
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleActivator.java152
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java222
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java117
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner22
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/META-INF/MANIFEST.MF59
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java126
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java158
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultJavaImportExportFactory.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaExport.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImport.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImportExportFactory.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java182
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoader.java386
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportModelResolver.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java147
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportExportFactoryImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java111
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportModelResolver.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java153
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/DefaultNamespaceImportExportFactory.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceExport.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImportExportFactory.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java172
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java178
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java532
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java325
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java292
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java320
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java435
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java283
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java259
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java145
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java127
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java409
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java329
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java131
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java179
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java131
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java159
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.java143
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionGeneratedMetadataDocumentProcessor.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java127
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java270
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionModelResolver.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor25
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor22
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver20
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-java-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-namespace-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-validation-messages.properties34
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties25
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java262
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessorTestCase.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessorTestCase.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java116
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java137
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java156
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/resources/deployables/sample-calculator.jarbin0 -> 26901 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/resources/repository/sample-calculator.jarbin0 -> 29164 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/contribution/src/test/resources/test.composite22
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/META-INF/MANIFEST.MF30
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/pom.xml91
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java131
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java126
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Array2ArrayTransformer.java104
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Collection2CollectionTransformer.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Exception2ExceptionTransformer.java112
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java270
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Map2MapTransformer.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java251
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java184
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer30
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor19
-rw-r--r--sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor17
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/META-INF/MANIFEST.MF48
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/pom.xml118
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/doc/Context Model.emx673
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java152
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java26
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java186
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java500
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/RuntimeProvider.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistryFactory.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseEndpointRegistry.java141
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java159
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultDomainRegistryFactoryExtensionPoint.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java127
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactoryExtensionPoint.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java168
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java133
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java137
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint17
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/org/apache/tuscany/sca/runtime/revision.properties30
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java207
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java107
-rw-r--r--sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/core/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/core/META-INF/MANIFEST.MF66
-rw-r--r--sandbox/sebastien/java/embed/modules/core/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/core/pom.xml89
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java607
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java119
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/LocalDomainRegistryFactory.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java121
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java111
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java835
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java619
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java124
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java546
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java424
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncFaultWrapper.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseException.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseHandler.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java152
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java125
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java185
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java239
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java571
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponseHandlerImpl.java197
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java208
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java311
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java206
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java114
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java313
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java236
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java875
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java196
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java160
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java87
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java204
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java228
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java167
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry19
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator19
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder18
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer17
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeProperties18
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler17
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/main/resources/endpoint-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java154
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java240
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java153
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java227
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest24
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/META-INF/MANIFEST.MF14
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/pom.xml38
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java159
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/META-INF/MANIFEST.MF29
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/pom.xml112
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomHelper.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Object.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2String.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java251
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Object2OMElement.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/String2OMElement.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/XMLStreamReader2OMElement.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding21
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer31
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementTestCase.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/ipo.xml51
-rwxr-xr-xsandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/ipo.xsd137
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/order.wsdl76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF38
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/pom.xml175
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/AxiomHelper.java140
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java128
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBCustomBuilder.java114
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java191
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDataSourceExt.java144
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStreamWriterWithOS.java246
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer27
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java113
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/resources/ipo.xsd136
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/META-INF/MANIFEST.MF53
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/pom.xml175
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DataConverter.java378
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DefaultXMLAdapterExtensionPoint.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java561
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java492
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java148
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBPropertyDescriptor.java302
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java244
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperException.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHelper.java166
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLAdapterExtensionPoint.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLRootElementUtil.java299
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/package.html29
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding20
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer33
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint17
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/com/example/stock/StockQuoteOffer.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java122
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBindingTestCase.java131
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBReflectionTestCase.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java148
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyBean.java162
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterface.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterfaceImpl.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyJaxbBean.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MySubBean.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java238
-rwxr-xr-xsandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/resources/ipo.xsd144
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/LICENSE202
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/META-INF/MANIFEST.MF37
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/pom.xml140
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2JavaBean.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2String.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2XMLStreamReader.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSON.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONObject.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/String2JSON.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/XMLStreamReader2JSON.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSON2OMElement.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONBadgerfishDataSource.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONDataSource.java176
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/InputStream2JSON.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2Object.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2OutputStream.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonHelper.java128
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding20
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer34
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer17
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.java140
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.java170
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyBean.java158
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterface.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java92
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonTestCase.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSONTestCase.java169
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-json/src/test/resources/ipo.xsd136
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/pom.xml148
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/AxiomHelper.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/DataObject2OMElement.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/SDODataSource.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/XMLDocument2OMElement.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer20
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/DataObject2OMElementTestCase.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/SDOTransformerTestCaseBase.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/XMLDocument2OMElementTestCase.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/resources/ipo.xsd136
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/resources/stock.xsd33
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/META-INF/MANIFEST.MF37
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/pom.xml157
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2Node.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2String.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReader.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDO.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java215
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/Node2DataObject.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelper.java258
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java150
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOSimpleTypeMapper.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java253
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java107
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java192
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/String2DataObject.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2String.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2XMLStreamReader.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLStreamReader2DataObject.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLStreamReader2XMLDocument.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java234
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java109
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver17
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding19
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer27
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/databinding-sdo-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2NodeTestCase.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2StringTestCase.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReaderTestCase.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelperTestCase.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDODataBindingTestCase.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOTransformerTestCaseBase.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/TestModelResolver.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2XMLStreamReaderTestCase.java64
-rwxr-xr-xsandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/ipo.xsd136
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/stock.xsd33
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/wrapper.xml27
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/wrapper.xsd38
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/LICENSE244
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/META-INF/MANIFEST.MF71
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/pom.xml97
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/BaseDataBinding.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/BaseTransformer.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingContext.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipe.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipeTransformer.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java261
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java321
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.java204
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PushTransformer.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Transformer.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformerExtensionPoint.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataBinding.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataType.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/externalizable/ExternalizableDataBinding.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java469
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.java104
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java629
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/PipedTransformer.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.java402
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java951
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/DOMNode2JavaBeanTransformer.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/Java2XMLMapperException.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2DOMNodeTransformer.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLStreamReaderTransformer.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLTransformer.java262
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.java166
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaExceptionDataBinding.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaBeanTransformer.java329
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaMapperException.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java165
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java300
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.java131
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java138
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2SAX.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2SAX.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SimpleJavaType.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SourceTransformer.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2XMLStreamReader.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2SAX.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SAX2DOMPipe.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SimpleJavaType2Node.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2NodeTransformer.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StAXDataBinding.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StreamDataPipe.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2Node.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SAX.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SourceTransformer.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2XMLStreamReader.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Writer2ReaderDataPipe.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLGroupDataBinding.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2Node.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2SAX.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2String.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding26
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.Mediator17
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer41
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer27
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.SimpleTypeMapper17
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/SimpleTypeMapperExtensionTestCase.java.fixme124
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/TransformerExtensionTestCase.java.fixme77
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/XSDDataTypeConverterTestCase.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DataBindingTestCase.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.java127
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java125
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/XMLDocumentStreamReaderTestCase.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java188
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java116
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java137
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/ipo.xsd136
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/order.wsdl76
-rw-r--r--sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/xml/foo.xml22
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/META-INF/MANIFEST.MF51
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/pom.xml83
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/DefaultDeployer.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java207
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java160
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java721
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer18
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties22
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/test/java/hello/deployer/HelloWorld.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java135
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/test/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite29
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/pom.xml75
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java179
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java263
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java154
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java140
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/InstalledContribution.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java358
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/java/itest/nodes/Helloworld.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java87
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java105
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java141
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/java/sample/Helloworld.java24
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/helloworld2.composite29
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jarbin0 -> 4708 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jarbin0 -> 4515 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jarbin0 -> 4761 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sample-helloworld.jarbin0 -> 4753 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sca-contribution-generated.xml23
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/META-INF/MANIFEST.MF18
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/pom.xml45
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientDomainRegistryFactory.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java120
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast/META-INF/MANIFEST.MF19
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast/pom.xml63
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java370
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java179
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java163
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/META-INF/MANIFEST.MF28
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/pom.xml65
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/AbstractReplicatedMap.java1564
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/MapStore.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java420
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.java163
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/TribesDomainRegistryFactory.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java168
-rw-r--r--sandbox/sebastien/java/embed/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/META-INF/MANIFEST.MF30
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/NOTICE5
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/pom.xml66
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java326
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxHostTestCase.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java132
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/TestEquinoxHost.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/resources/test-bundle-v1.jarbin0 -> 2801 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/resources/test-bundle-v2.jarbin0 -> 2805 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/META-INF/MANIFEST.MF18
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/NOTICE10
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/pom.xml31
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java193
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java162
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java154
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java219
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivatorExtensionPoint.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderContext.java213
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java179
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.java375
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java288
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java226
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/ClassLoaderDelegate.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java1373
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.FactoryExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.UtilityExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java118
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java101
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface19
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/META-INF/MANIFEST.MF23
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/pom.xml44
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java164
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost17
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java208
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java174
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java99
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/resources/general.idl45
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse-tns/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse-tns/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse-tns/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse-tns/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java120
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost17
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java99
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/META-INF/MANIFEST.MF32
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/pom.xml38
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java185
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java863
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java134
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java200
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java440
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost17
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java253
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/resources/general.idl43
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/META-INF/MANIFEST.MF17
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/pom.xml38
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java202
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java62
-rwxr-xr-xsandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java226
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint18
-rw-r--r--sandbox/sebastien/java/embed/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java145
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/META-INF/MANIFEST.MF19
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/pom.xml46
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultResourceServlet.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java200
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java140
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java143
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletMappingException.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/host-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/META-INF/MANIFEST.MF27
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyDefaultServlet.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java107
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java596
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost18
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java358
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/src/test/resources/content/test.html21
-rw-r--r--sandbox/sebastien/java/embed/modules/host-jetty/src/test/resources/tuscany.keyStorebin0 -> 1265 bytes
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/META-INF/MANIFEST.MF15
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/pom.xml39
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java177
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostExtensionPoint.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostRuntimeException.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMISocketFactoryImpl.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint19
-rw-r--r--sandbox/sebastien/java/embed/modules/host-rmi/src/test/java/org/apache/tuscany/sca/host/rmi/RMIHostImplTestCase.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/META-INF/MANIFEST.MF23
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/NOTICE7
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/pom.xml73
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java109
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java247
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java117
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java342
-rw-r--r--sandbox/sebastien/java/embed/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost18
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/LICENSE251
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF52
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/NOTICE17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/pom.xml495
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java233
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/DeploymentWorkspace.java233
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java563
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/GeronimoTxFactory.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeployment.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeploymentException.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEndpointReference.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEprContext.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java370
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEInitializationException.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEShutdownException.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyEPR.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyPRC.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java823
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java187
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProviderFactory.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java286
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/ODEInvocationException.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServerTestCase.java124
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/deploy.xml30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/greetings.wsdl87
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.bpel81
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.wsdl82
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/log4j.properties36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/LICENSE251
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/META-INF/MANIFEST.MF32
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/NOTICE17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/pom.xml64
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELFactory.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java109
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java152
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java128
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentModelResolver.java401
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java355
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java452
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java132
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java118
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELProcessorConstants.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.bpel.BPELFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/impl-bpel-validation-messages.properties34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELDocumentProcessorTestCase.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementationProcessorTestCase.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/resources/helloworld/helloworld.bpel66
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/resources/helloworld/helloworld.wsdl82
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/META-INF/MANIFEST.MF60
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/pom.xml57
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/databinding/PropertyDataTypeProcessor.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java346
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaAsyncImplementationInvoker.java131
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java125
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java399
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java192
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java169
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java204
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/ResponseDispatchImpl.java224
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.PropertyValueFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/definitions/definitions.xml30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java.fixme84
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java.fixme54
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactoryTestCase.java.fixme449
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java.fixme89
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactory.java120
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Entry.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java189
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/META-INF/MANIFEST.MF49
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/pom.xml124
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/IntrospectionException.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaConstructorImpl.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java222
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java164
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationFactory.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaParameterImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaResourceImpl.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java125
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java135
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java144
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaClassVisitor.java126
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java622
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java257
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java87
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java110
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java758
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java42
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java309
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java303
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java274
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java153
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java247
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/package.html29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationConstants.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java395
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/AddService.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/AddServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/CalculatorService.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/CalculatorServiceImpl.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/DivideService.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/DivideServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/MultiplyService.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/SubtractService.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/SubtractServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java206
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java174
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java188
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java164
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java216
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java150
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java330
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java581
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java157
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java153
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessorTestCase.java127
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ModelHelper.java99
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java428
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java304
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java310
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java128
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java197
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java219
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java180
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java242
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/TestModelResolver.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/WriteTestCase.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/Calculator.composite66
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml100
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml113
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/LICENSE241
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/META-INF/MANIFEST.MF32
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/pom.xml154
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProvider.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProviderFactory.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory21
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/HelloWorld.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/HelloWorldApp.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/test/HelloWorldTestCase.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/resources/helloworld/jaxrs/HelloWorld.composite29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/META-INF/MANIFEST.MF31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/pom.xml91
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/JAXRSImplementation.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/JAXRSImplementationFactory.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationFactoryImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationImpl.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/xml/JAXRSImplementationProcessor.java162
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema18
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementationFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/org/apache/tuscany/sca/implementation/jaxrs/tuscany-sca-1.1-implementation-jaxrs.xsd38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/java/org/apache/tuscany/sca/implementation/jaxrs/xml/ReadTestCase.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/java/org/apache/tuscany/sca/implementation/jaxrs/xml/WriteTestCase.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/resources/org/apache/tuscany/sca/implementation/jaxrs/xml/TestJAXRS.composite30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/LICENSE203
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/pom.xml78
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java336
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java210
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties25
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/LICENSE203
-rwxr-xr-xsandbox/sebastien/java/embed/modules/implementation-osgi/META-INF/MANIFEST.MF37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/pom.xml72
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java242
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java125
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java124
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java144
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java174
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java342
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java115
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java194
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java99
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java255
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor22
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver18
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties26
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java173
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java110
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java105
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType63
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/osgitest.composite35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/LICENSE246
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/NOTICE13
-rwxr-xr-xsandbox/sebastien/java/embed/modules/implementation-python-runtime/jython-install27
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/pom.xml100
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProvider.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProviderFactory.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonInvoker.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/atomutil.py120
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/__init__.py0
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/__init__.py0
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/__init__.py252
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/decoder.py273
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/encoder.py331
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/scanner.py63
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/elemutil.py168
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/invoker.py108
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/jsonutil.py142
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/rssutil.py119
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/util.py145
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/xmlutil.py114
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/ClientTest.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/EchoTest.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/InvokeTestCase.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/ServerTest.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/client_test.py35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/domain-test.composite64
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/server_test.py42
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/META-INF/MANIFEST.MF11
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/pom.xml84
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonEval.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonImplementation.java104
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonImplementationProcessor.java107
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonProperty.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema18
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/org/apache/tuscany/sca/implementation/python/tuscany-sca-1.1-implementation-python.xsd38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/test/java/org/apache/tuscany/sca/implementation/python/ReadWriteTestCase.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-python/src/test/resources/domain-test.composite39
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/LICENSE251
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/META-INF/MANIFEST.MF58
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/pom.xml189
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java174
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptInvoker.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptPropertyFactory.java225
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorld.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorldProxy.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/AbstractHelloWorldTestCase.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorldTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorld.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorldProxy.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorldTestCase.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorldTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReferenceTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/HelloWorldTarget.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReferenceTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReferenceTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JythonReferenceTestCase.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.componentType30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy22
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js23
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb21
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorld.composite33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.componentType32
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy22
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js23
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb21
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReference.composite38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReference.composite38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReference.composite38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JythonReference.composite38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.componentType31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy22
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.js22
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.py20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.rb21
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/LICENSE251
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/META-INF/MANIFEST.MF29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/pom.xml48
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationFactory.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/impl/ScriptImplementationFactoryImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/impl/ScriptImplementationImpl.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java167
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.script.ScriptImplementationFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/META-INF/MANIFEST.MF63
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/pom.xml81
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAGenericApplicationContext.java145
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAParentApplicationContext.java213
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringContextWrapper.java130
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java112
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java164
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java168
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/ComponentWrapper.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/PropertyValueWrapper.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java78
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java158
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvocationException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvoker.java126
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers2
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas1
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd84
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/META-INF/MANIFEST.MF26
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/README9
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/pom.xml56
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/stub/SpringXMLBeanDefinitionLoaderStub.java92
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/ComponentTie.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/PropertyValueTie.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringApplicationContextAccessor.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringContextStub.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProvider.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProviderFactory.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationTie.java156
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvocationException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvoker.java125
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/META-INF/MANIFEST.MF25
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/README9
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAGenericApplicationContext.java176
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAParentApplicationContext.java212
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringContextTie.java130
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringImplementationStub.java146
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java93
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentNameAnnotationProcessor.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentStub.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ConstructorAnnotationProcessor.java112
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/InitDestroyAnnotationProcessor.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyAnnotationProcessor.java163
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyValueStub.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ReferenceAnnotationProcessor.java167
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/SpringXMLLoaderTie.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/META-INF/spring.handlers1
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/META-INF/spring.schemas1
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/org/springframework/sca/xml/spring-sca.xsd84
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/META-INF/MANIFEST.MF29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/pom.xml60
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorBean.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/test/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorTestCase.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/META-INF/MANIFEST.MF50
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/pom.xml59
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java132
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java259
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java105
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java985
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java244
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringXMLBeanDefinitionLoader.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder18
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties28
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-client/LICENSE241
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-client/META-INF/MANIFEST.MF31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-client/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-client/pom.xml68
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java259
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.runtime.ClientExtensionPoint22
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/LICENSE241
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/META-INF/MANIFEST.MF28
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/pom.xml89
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTEI.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/utils/ContextHelper.java133
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld49
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory21
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/META-INF/MANIFEST.MF28
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/pom.xml73
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementationFactory.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationFactoryImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java156
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.java126
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder18
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.WebImplementationFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/ReadTestCase.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/WriteTestCase.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-web/src/test/resources/org/apache/tuscany/sca/implementation/web/xml/TestWeb.composite29
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/META-INF/MANIFEST.MF15
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/pom.xml52
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java267
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/META-INF/MANIFEST.MF33
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/pom.xml71
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java101
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java157
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/atomModel.js1590
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/binding-http.js105
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/META-INF/MANIFEST.MF31
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/pom.xml64
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java59
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java150
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java188
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java134
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/javascript/WidgetImplementationJavascriptProvider.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.WidgetImplementationFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/impl-widget-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/META-INF/MANIFEST.MF18
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/pom.xml64
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java280
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/GeneratedClassLoader.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java116
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGenerator.java210
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor17
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/Bean.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSInterfaceProcessorTestCase.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/MockedResource.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/Resource.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/ResourceWrapper.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGeneratorTestCase.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/META-INF/MANIFEST.MF49
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/pom.xml281
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java542
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java280
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java147
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedClassLoader.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedDataTypeImpl.java143
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java276
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java403
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java388
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSUtils.java310
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WebServiceInterfaceProcessor.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java238
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.FaultExceptionMapper17
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor19
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean1.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean2.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java28
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessorTestCase.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java121
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JavaReflectionHelperTestCase.java47
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyException.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyServiceImpl.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/StockQuote.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestGenericClass.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/resources/wsdl/Stock.wsdl142
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/resources/wsdl/StockExceptionTest.wsdl171
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/META-INF/MANIFEST.MF45
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/pom.xml64
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.java134
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.java33
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java360
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java309
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java223
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.java100
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java278
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/introspect/JavaInterfaceVisitor.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/package.html30
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java445
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor18
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties28
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilDuplicateRemotableTestCase.java317
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilTestCase.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java.fixme107
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/PolicyProcessorTestCase.java119
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/ReadTestCase.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/WriteTestCase.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite53
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/CalculatorImpl.componentType31
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/META-INF/MANIFEST.MF47
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/pom.xml86
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/BPELPartnerLinkTypeExt.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/DefaultWSDLFactory.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java190
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLFactory.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLObject.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/InvalidWSDLException.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java321
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLFactoryImpl.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java124
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.java135
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLObjectImpl.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java605
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/package.html31
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java235
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java494
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java675
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver19
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties27
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java125
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/AbstractWSDLTestCase.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java126
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java82
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite55
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType33
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl26
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl58
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd136
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl58
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl45
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd33
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl63
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl76
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/policy/stockquote_policy.wsdl62
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/wsdl/helloworld-interface.wsdl67
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/wsdl/helloworld-service.wsdl49
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/greeting.xsd29
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/helloworld.xsd22
-rw-r--r--sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/name.xsd29
-rw-r--r--sandbox/sebastien/java/embed/modules/launcher/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/launcher/META-INF/MANIFEST.MF14
-rw-r--r--sandbox/sebastien/java/embed/modules/launcher/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/launcher/pom.xml35
-rw-r--r--sandbox/sebastien/java/embed/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java346
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/META-INF/MANIFEST.MF14
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/pom.xml33
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java364
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java144
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/ProblemImpl.java181
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java98
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages.properties24
-rw-r--r--sandbox/sebastien/java/embed/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages_it.properties24
-rw-r--r--sandbox/sebastien/java/embed/modules/myfaces/LICENSE241
-rw-r--r--sandbox/sebastien/java/embed/modules/myfaces/META-INF/MANIFEST.MF18
-rw-r--r--sandbox/sebastien/java/embed/modules/myfaces/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/modules/myfaces/pom.xml76
-rw-r--r--sandbox/sebastien/java/embed/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationLifecycleProvider.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationProcessor.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/META-INF/MANIFEST.MF18
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/pom.xml41
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java160
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java623
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java108
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java54
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java155
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java63
-rw-r--r--sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java176
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/META-INF/MANIFEST.MF53
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/NOTICE9
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/pom.xml121
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java129
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java143
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java142
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java109
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java550
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointMatcher.java273
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportReferenceImpl.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportReferenceImpl.java72
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java70
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java234
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java163
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java114
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java346
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java400
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.java265
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/Discovery.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DiscoveryActivator.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java140
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java262
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java682
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointListener.java126
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java693
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ExportReference.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ExportRegistration.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ImportReference.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ImportRegistration.java67
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteConstants.java216
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdmin.java124
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminEvent.java178
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminListener.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema18
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory17
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/org/osgi/service/remoteserviceadmin/osgi-remoteserviceadmin.xsd92
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorService.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorActivator.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java114
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceImpl.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/AddServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/DivideServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/OperationsActivator.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java156
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java99
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java362
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF20
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/blueprint/calculator-module.xml43
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/calculator-component.xml36
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml55
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/bundle.componentType63
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite53
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF22
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/add-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/blueprint/operations-module.xml40
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/divide-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/multiply-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/subtract-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType54
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/operations.composite43
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF12
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite70
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/META-INF/MANIFEST.MF40
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/pom.xml115
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java160
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java237
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java524
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java382
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java43
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor18
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties22
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/java/hello/HelloWorld.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/java/hello/HelloWorldImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java86
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java218
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/HelloWorld.composite30
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml58
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/test-node-factory.config19
-rw-r--r--sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/test.properties22
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/pom.xml126
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java173
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java658
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/FrameworkLauncher.java254
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java160
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java375
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher2.java217
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherCommand.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java1362
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/J2SE-1.5.profile150
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/JavaSE-1.6.profile185
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF47
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.8.MF49
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF2
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.5.1.MF39
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-transport-http-1.5.1.MF12
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-agents-1.3.2.MF7
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-api-1.3.2.MF58
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-compiler-1.3.2.MF170
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-dao-1.3.2.MF23
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-epr-1.3.2.MF79
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-obj-1.3.2.MF40
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-runtime-1.3.2.MF256
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-schemas-1.3.2.MF40
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-store-1.3.2.MF97
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-dao-hibernate-1.3.2.MF83
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-dao-jpa-1.3.2.MF44
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-jacob-1.3.2.MF46
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-jacob-ap-1.3.2.MF19
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-scheduler-simple-1.3.2.MF24
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-utils-1.3.2.MF134
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF226
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/xercesImpl-2.9.0.MF421
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/META-INF/MANIFEST.MF15
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/pom.xml64
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java180
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/LauncherException.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeDaemonLauncher.java169
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java364
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java567
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeMain.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeServletFilter.java130
-rw-r--r--sandbox/sebastien/java/embed/modules/node-launcher/src/test/java/org/apache/tuscany/sca/node/launcher/ServiceInvocationTestCase.java77
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/META-INF/MANIFEST.MF28
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/pom.xml53
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java48
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java97
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java84
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java171
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java135
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java68
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder17
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml38
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java94
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml23
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/META-INF/MANIFEST.MF88
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/pom.xml52
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java123
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicyProcessor.java150
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java83
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java75
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java131
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.java65
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/http/ssl/HTTPSPolicy.java130
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/http/ssl/HTTPSPolicyProcessor.java156
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java91
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationInterceptor.java81
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java148
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProviderFactory.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor29
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions18
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory21
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml35
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml30
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/policy-security-validation-messages.properties28
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/test/java/org/apache/tuscany/sca/policy/security/PolicyProcessorTestCase.java88
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml80
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/META-INF/MANIFEST.MF35
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/GeronimoTransactionManagerHelper.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionManagerWrapper.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionModuleActivator.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator18
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.runtime.TransactionManagerHelper17
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/test/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionManagerHelperTestCaseOFF.java196
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/META-INF/MANIFEST.MF33
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/pom.xml63
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/IncompatibleIntentException.java44
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionIntent.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionInterceptor.java151
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionManagerHelper.java252
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionPolicyProviderFactory.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionalAction.java31
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/META-INF/MANIFEST.MF31
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/pom.xml51
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicy.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyFactory.java34
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java103
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyImpl.java61
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory19
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/log4j.properties29
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/org/apache/tuscany/sca/policy/transaction/definitions.xml57
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/META-INF/MANIFEST.MF39
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/pom.xml136
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicy.java74
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyBuilder.java173
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessor.java180
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder17
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TestModelResolver.java64
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TuscanyWSPolicyAssertion.java40
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TuscanyWSPolicyAssertionProcessor.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyTestCase.java199
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessorTestCase.java140
-rw-r--r--sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/resources/org/apache/tuscany/sca/policy/wspolicy/test_definitions.xml192
-rw-r--r--sandbox/sebastien/java/embed/modules/pom.xml207
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/LICENSE261
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/META-INF/MANIFEST.MF16
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/NOTICE9
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/pom.xml35
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java194
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java90
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java71
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java46
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java55
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java62
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java39
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java27
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java29
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java21
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java22
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java26
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java22
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java22
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java22
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java51
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java50
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java23
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java58
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java24
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java56
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java23
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java32
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html3
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java152
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java289
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/package.html3
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/META-INF/MANIFEST.MF24
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/pom.xml47
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java202
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java89
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java210
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientModuleActivator.java37
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.java76
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator18
-rw-r--r--sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/shell/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/embed/modules/shell/pom.xml50
-rw-r--r--sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java686
-rw-r--r--sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/CompositeURICompletor.java69
-rw-r--r--sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ICURICompletor.java49
-rw-r--r--sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/JLine.java80
-rw-r--r--sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/TShellCompletor.java165
-rw-r--r--sandbox/sebastien/java/embed/modules/stripes/LICENSE241
-rw-r--r--sandbox/sebastien/java/embed/modules/stripes/META-INF/MANIFEST.MF29
-rw-r--r--sandbox/sebastien/java/embed/modules/stripes/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/modules/stripes/pom.xml60
-rw-r--r--sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyHelper.java298
-rw-r--r--sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptor.java73
-rw-r--r--sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptorSupport.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/META-INF/MANIFEST.MF13
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/maven-eclipse.xml8
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/pom.xml75
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/LoggingAspect.java102
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/SimpleTracingAspect.java85
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/TimingAspect.java53
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/TracingAspect.java92
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/UserTimingAspect.java45
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/resources/META-INF/aop.xml42
-rw-r--r--sandbox/sebastien/java/embed/modules/tracing-aspectj/src/test/java/org/apache/tuscany/sca/aspectj/TracingTestCase.java41
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/LICENSE238
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/META-INF/MANIFEST.MF26
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/NOTICE11
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/build-dojo.xml64
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/pom.xml120
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoResourceServlet.java95
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoWidgetJavascriptProvider.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider19
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/resources/tuscany/AtomService.js141
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/META-INF/MANIFEST.MF19
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/pom.xml46
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/ComponentJavaScriptGenerator.java60
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/ComponentJavaScriptGeneratorExtensionPoint.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/DefaultComponentJavaScriptGeneratorExtensionPoint.java158
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/DefaultJavascriptProxyFactoryExtensionPoint.java231
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/JavascriptProxyFactory.java79
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/JavascriptProxyFactoryExtensionPoint.java57
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGeneratorExtensionPoint18
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactoryExtensionPoint18
-rw-r--r--sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/web-javascript-validation-messages.properties21
-rw-r--r--sandbox/sebastien/java/embed/modules/wink/LICENSE241
-rw-r--r--sandbox/sebastien/java/embed/modules/wink/META-INF/MANIFEST.MF18
-rw-r--r--sandbox/sebastien/java/embed/modules/wink/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/modules/wink/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java66
-rw-r--r--sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.java38
-rw-r--r--sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.java52
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/META-INF/MANIFEST.MF46
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/pom.xml65
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/DefaultXSDFactory.java30
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.java36
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.java118
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDFactoryImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDefinitionImpl.java232
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessor.java106
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java391
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver19
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.xsd.XSDFactory18
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/main/resources/xsd-xml-validation-messages.properties23
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/test/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessorTestCase.java96
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/test/resources/xsd/greeting.xsd29
-rw-r--r--sandbox/sebastien/java/embed/modules/xsd/src/test/resources/xsd/name.xsd29
-rw-r--r--sandbox/sebastien/java/embed/pom.xml1039
-rw-r--r--sandbox/sebastien/java/embed/samples/README269
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/README1
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/build-dojo.xml64
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/pom.xml126
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddBean.java90
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddService.java32
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddServiceImpl.java44
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/CalculatorService.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java86
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/DivideServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/WEB-INF/web.composite53
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/calculate.html62
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/test/java/calculator/CalculatorTestCase.java50
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/README26
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/build.xml57
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddBean.java88
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddService.java32
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddServiceImpl.java43
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorClient.java52
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorService.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java86
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/Calculator.composite53
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/CalculatorClient.composite30
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java50
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-jsonrpc/pom.xml43
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/README1
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/README34
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/build.xml59
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/pom.xml74
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/AddService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/CalculatorService.java39
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/CalculatorServiceImpl.java68
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/resources/CalculatorRMIReference.composite42
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java70
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java52
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/README28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/build.xml59
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/pom.xml74
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/AddService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/AddServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorClient.java40
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorService.java36
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorServiceImpl.java68
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/DivideServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/MultiplyServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/SubtractServiceImpl.java30
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/resources/CalculatorRMIServer.composite53
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/test/java/calculator/CalculatorRMIServerTestCase.java63
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-rmi/pom.xml44
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/README1
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/README26
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/build.xml57
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/AddService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/AddServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorClient.java52
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorService.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java72
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/Calculator.composite49
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/CalculatorClient.composite30
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java50
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-sca/pom.xml43
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/README1
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/README25
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/build.xml55
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/calculator.odgbin0 -> 12477 bytes
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/calculator.pngbin0 -> 41196 bytes
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/pom.xml54
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/AddService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/CalculatorService.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java70
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/resources/Calculator.composite54
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java50
-rw-r--r--sandbox/sebastien/java/embed/samples/binding-ws/pom.xml43
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/META-INF/MANIFEST.MF19
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/README99
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/build.xml78
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/pom.xml116
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/AddService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java54
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java52
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java34
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java69
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/resources/Calculator.composite54
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java54
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-scaclient/README13
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-scaclient/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-scaclient/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/calculator-scaclient/src/main/java/sample/CalculatorSCAClient.java53
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/META-INF/MANIFEST.MF22
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/add-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/blueprint/operations-module.xml40
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/divide-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/multiply-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType54
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.composite43
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/subtract-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/README185
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/pom.xml148
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java88
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java105
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java43
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java104
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/META-INF/MANIFEST.MF20
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/blueprint/calculator-module.xml43
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/calculator-component.xml36
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/sca/bundle.componentType64
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/sca/bundle.composite45
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/README143
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/dosgi-calculator.pngbin0 -> 85103 bytes
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/pom.xml153
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/CalculatorService.java36
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java76
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java114
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java105
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java93
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java132
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRemote.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java43
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java152
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java105
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/META-INF/MANIFEST.MF23
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/add-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/blueprint/operations-module.xml40
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/divide-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/multiply-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/sca-config/operations-config.xml29
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/subtract-component.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/README196
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/pom.xml148
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java94
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java105
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java43
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java104
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/LICENSE205
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/META-INF/MANIFEST.MF23
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/NOTICE6
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/blueprint/calculator-module.xml43
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/calculator-component.xml36
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml61
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/sca-config/calculator-config.xml32
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/README145
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/dosgi-calculator.pngbin0 -> 85103 bytes
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/pom.xml153
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/CalculatorService.java36
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java78
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java114
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java99
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java93
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java132
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRemote.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java43
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java144
-rw-r--r--sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java105
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/README153
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/build.xml95
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/helloworld-bpel.pngbin0 -> 8897 bytes
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/helloworld-bpel.svg179
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/pom.xml76
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/java/helloworld/Hello.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.bpel80
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.wsdl94
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/log4j.properties35
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-scaclient/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/main/java/sample/Helloworld.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/main/java/sample/HelloworldSCAClient.java51
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/test/java/sample/HelloworldTestCase.java33
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/pom.xml67
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/DateService.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/DateServiceImpl.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/Helloworld.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/HelloworldClientImpl.java48
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.java34
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld-client-context.xml37
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld-context.xml30
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld.composite36
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-spring/src/test/java/sample/HelloworldTestCase.java33
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/README214
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/build.xml101
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/helloworld-ws-sdo.pngbin0 -> 7549 bytes
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/maven-eclipse.xml8
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/pom.xml180
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java51
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java51
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java34
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java42
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BioTestCase.java59
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircle.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircleImpl.java40
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/META-INF/sca-contribution.xml28
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite31
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite34
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/logging.properties30
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/resources/clinicalLaboratory.composite34
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/test.xsd35
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl88
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java85
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java67
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/TestCaseRunner.java329
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld/README7
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld/src/main/java/sample/Helloworld.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld/src/main/java/sample/HelloworldImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld/src/main/resources/helloworld.composite29
-rw-r--r--sandbox/sebastien/java/embed/samples/helloworld/src/test/java/sample/HelloworldTestCase.java33
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/README8
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/build.xml51
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/pom.xml79
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/Java.java34
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/WSDL.java34
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/WSDLReference.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleImplementation.java41
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleImplementationProcessor.java162
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleJavaInvoker.java52
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleProvider.java91
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleProviderFactory.java48
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleUtil.java148
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleWSDLInvoker.java56
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleWSDLProxy.java57
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema18
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/sample/impl/sample.xsd38
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Client.java30
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/ClientTest.java65
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Hello.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/JelloTest.java40
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Upper.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/UpperTest.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/WelloTest.java59
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Xutil.java244
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/ReadWriteTestCase.java83
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/RunTestCase.java70
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/Hello.wsdl62
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/Upper.wsdl62
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/test.composite45
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/README1
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/README25
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/build.xml56
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/AddService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorClient.java62
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorService.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java70
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/Calculator.composite49
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/CalculatorClient.composite30
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java49
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-java/pom.xml43
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/README1
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/README26
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/build.xml57
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/pom.xml58
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/AddService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorClient.java52
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorService.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java72
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/Calculator.composite50
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/CalculatorClient.composite30
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.componentType30
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.js22
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.componentType30
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.groovy22
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.componentType30
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.py20
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.componentType30
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.rb21
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-script/pom.xml43
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-command-line/README13
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/README20
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/build.xml110
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/pom.xml94
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java59
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java61
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java59
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java59
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java46
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java59
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java43
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java48
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/README24
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/build.xml94
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/pom.xml71
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java61
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java89
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java39
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/README20
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/build.xml94
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/pom.xml76
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java61
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java89
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java39
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-maven/README18
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/README34
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/pom.xml79
-rwxr-xr-xsandbox/sebastien/java/embed/samples/launcher-shell/sca19
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-remote.txt36
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-start.txt18
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-status.txt17
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-stop.txt17
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test.txt36
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/src/main/java/sample/Shell.java197
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/src/main/java/sample/ShellServlet.java48
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/src/main/webapp/WEB-INF/web.xml48
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-shell/src/main/webapp/index.html40
-rw-r--r--sandbox/sebastien/java/embed/samples/launcher-webapp/README29
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/README51
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/pom.xml96
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/com/facebook/fb303/FacebookService.java6823
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/com/facebook/fb303/fb_status.java68
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/LogEntry.java411
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/ResultCode.java61
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/scribe.java772
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/HelloWorld.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/HelloWorldImpl.java33
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/Logger.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/ScribeLoggerImpl.java76
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/fb303.thrift112
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/scribe.composite36
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/scribe.thrift38
-rw-r--r--sandbox/sebastien/java/embed/samples/logging-scribe/src/test/java/sample/LoggingTest.java39
-rw-r--r--sandbox/sebastien/java/embed/samples/logging.properties25
-rw-r--r--sandbox/sebastien/java/embed/samples/pom.xml107
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/README28
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/pom.xml84
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Cart.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Catalog.java27
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/CurrencyConverter.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/CurrencyConverterImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/FruitsCatalogImpl.java52
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Item.java51
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/ShoppingCartImpl.java112
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Total.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/resources/store.composite55
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml50
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/WEB-INF/web.xml36
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/store.html163
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/store.pngbin0 -> 15670 bytes
-rw-r--r--sandbox/sebastien/java/embed/samples/store-webapp/store.svg304
-rw-r--r--sandbox/sebastien/java/embed/samples/store/README28
-rw-r--r--sandbox/sebastien/java/embed/samples/store/build.xml79
-rw-r--r--sandbox/sebastien/java/embed/samples/store/pom.xml70
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/launch/Launch.java39
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/services/Cart.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/services/Catalog.java27
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/services/CurrencyConverter.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/services/CurrencyConverterImpl.java38
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/services/FruitsCatalogImpl.java52
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/services/Item.java50
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/services/ShoppingCartImpl.java112
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/java/services/Total.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/resources/store.composite58
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/main/resources/uiservices/store.html162
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/test/java/client/Shopper.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/test/java/client/ShopperImpl.java64
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/test/java/store/StoreTestCase.java117
-rw-r--r--sandbox/sebastien/java/embed/samples/store/src/test/resources/store-client.composite38
-rw-r--r--sandbox/sebastien/java/embed/samples/store/store.pngbin0 -> 15670 bytes
-rw-r--r--sandbox/sebastien/java/embed/samples/store/store.svg304
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/README7
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/pom.xml160
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/java/sample/HelloworldService.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/resources/helloworld.bpel66
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/resources/helloworld.wsdl82
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.composite37
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/hello.jsp36
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/README7
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/pom.xml116
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java68
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloworldServiceImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/application14
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/web.xml49
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java43
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/README131
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/pom.xml96
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldClient.java37
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldService.java29
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldServiceImpl.java31
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/META-INF/context.xml34
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/jetty-env.xml48
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.composite44
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.xml66
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/hello.jsp41
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/README7
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/pom.xml104
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldServiceImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.composite36
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/hello.html51
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/test/java/itest/HelloworldTestCase.java75
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/pom.xml99
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java56
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java27
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml51
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml191
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp40
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp23
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp38
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/README7
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/pom.xml98
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp37
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/test/java/itest/HelloworldTestCase.java53
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/README7
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/pom.xml105
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java27
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java64
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml44
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/hello.html46
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/test/java/itest/HelloworldTestCase.java55
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/pom.xml186
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/main/webapp/WEB-INF/web.xml51
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/test/java/sample/HelloworldClientTestCase.java58
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/test/resources/test-web.xml25
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/pom.xml112
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java33
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java45
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java25
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java28
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties73
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties48
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp26
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp39
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp29
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml61
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/index.html24
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/test/java/README7
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/test/java/itest/HelloworldTestCase.java53
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld/README7
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld/pom.xml118
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml47
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/java/itest/Helloworld.java27
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/java/itest/HelloworldTestCaseFIXME.java44
-rw-r--r--sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/resources/test-web.xml30
-rw-r--r--sandbox/sebastien/java/embed/shades/base-nodep/pom.xml121
-rw-r--r--sandbox/sebastien/java/embed/shades/base-nodep/src/main/java/org/apache/tuscany/sca/base/AggregatedBundleActivator.java56
-rw-r--r--sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/LICENSE234
-rw-r--r--sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/META-INF/MANIFEST.MF479
-rw-r--r--sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/README.txt33
-rw-r--r--sandbox/sebastien/java/embed/shades/base/pom.xml330
-rw-r--r--sandbox/sebastien/java/embed/shades/base/src/main/resources/LICENSE234
-rw-r--r--sandbox/sebastien/java/embed/shades/base/src/main/resources/NOTICE12
-rw-r--r--sandbox/sebastien/java/embed/shades/base/src/main/resources/README.txt31
-rw-r--r--sandbox/sebastien/java/embed/shades/bpel-nodep/pom.xml75
-rw-r--r--sandbox/sebastien/java/embed/shades/bpel/pom.xml132
-rw-r--r--sandbox/sebastien/java/embed/shades/jms-nodep/pom.xml107
-rw-r--r--sandbox/sebastien/java/embed/shades/jms/pom.xml124
-rw-r--r--sandbox/sebastien/java/embed/shades/json-nodep/pom.xml73
-rw-r--r--sandbox/sebastien/java/embed/shades/json/pom.xml167
-rw-r--r--sandbox/sebastien/java/embed/shades/pom.xml45
-rw-r--r--sandbox/sebastien/java/embed/shades/spring-nodep/pom.xml72
-rw-r--r--sandbox/sebastien/java/embed/shades/spring/pom.xml111
-rw-r--r--sandbox/sebastien/java/embed/shades/webservices-nodep/pom.xml69
-rw-r--r--sandbox/sebastien/java/embed/shades/webservices/pom.xml208
5918 files changed, 509213 insertions, 0 deletions
diff --git a/sandbox/sebastien/java/embed/BUILDING b/sandbox/sebastien/java/embed/BUILDING
new file mode 100644
index 0000000000..1f7d52f93f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/BUILDING
@@ -0,0 +1,44 @@
+Building the Apache Tuscany SCA source distribution
+===================================================
+
+Initial Setup
+-------------
+
+1) Install J2SE 6.x JDK, which can be downloaded from
+ http://java.sun.com/javase/downloads/index.jsp.
+
+2) Make sure that your JAVA_HOME environment variable is set to the newly installed
+ JDK location, and that your PATH includes %JAVA_HOME%\bin (windows) or
+ $JAVA_HOME/bin (unix).
+
+3) Install Maven 2.0.7 or higher (2.2.1 recommended), which can be downloaded from
+ http://maven.apache.org/download.html. Make sure that your PATH includes
+ the MVN_HOME/bin directory.
+
+4) Make sure that your MAVEN_OPTS environment variable has -Xmx128M (or more),
+ you can manually do this by executing the following in your prompt :
+ Windows users:
+ set MAVEN_OPTS=-Xmx128M
+ Unix users:
+ export MAVEN_OPTS=-Xmx128M
+
+
+Building
+--------
+
+1) Change to the top level directory of Apache Tuscany source distribution.
+2) Run
+
+ $> mvn
+
+ This will compile Apache Tuscany and run all of the tests in the source
+ distribution.
+
+ Depending on the load of remote Maven 2.0 repositories, you may have
+ to run "mvn" several times utill the required dependencies are
+ all located in your local maven repository. It usually takes some time for
+ maven to download required dependencies in the first build. Once all the
+ dependencies have been downloaded you may use the -o option to run maven
+ in offline mode, for example, 'mvn clean install -o'.
+
+
diff --git a/sandbox/sebastien/java/embed/CHANGES b/sandbox/sebastien/java/embed/CHANGES
new file mode 100644
index 0000000000..db34bff2e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/CHANGES
@@ -0,0 +1,100 @@
+Changes With Apache Tuscany SCA 2.0-Beta1 June 2010
+====================================================
+
+Lots of updates to keep up with recent changes in the OASIS Specifications
+
+
+Changes With Apache Tuscany SCA 2.0-M5 June 2010
+====================================================
+
+Highlights include:
+- Passes the OASIS conformance test suite for the SCA Assembly, SCA-J CAA and SCA-J CI Specifications!
+- Passes OSGI remote service SCA config type conformance test suite
+- New Tuscany specific support for REST/JAXRS
+- Started improving the layout of the samples to separate contributions from launchers
+- Further improvements to the distributed SCA domain support
+- Improved support for the SCAClient in distributed scenarios
+- Dropped support for JDK 5
+- Numerous other bug fixes and improvements
+
+Changes With Apache Tuscany SCA 2.0-M4 November 2009
+====================================================
+
+Highlights include:
+- Passes the OASIS conformance test suite for the SCA-J CAA Specification!
+- Almost passes the OASIS conformance test suite for the SCA Assembly Specification with
+ a small number of test failures that will be fixed in the next release
+- Support for <binding.jms> and the OASIS SCA JMS specification
+- Support for <binding.ejb> on references and partial support of the OASIS SCA EJB specification
+- A new Tuscany specific binding for JSONP support
+- Several Tuscany specific extensions ported up from the 1.x runtime including bindings for ATOM,
+ HTTP, JSON-RPC, and implementation web clients, plus new support for JSON-RPC references
+- Improved distributed SCA domain support
+- Improve the implementation of OSGi remote services with SCA configuration type that supports dynamic
+ OSGi remote service admin, including import, export and discovery
+- Add extension points for builders that can build implementation, binding and policy types
+- Add a Deployer utility to facilitate deployment-related functions
+- Improve the monitor usage so that monitors are isolated between requests
+- Numerous other bug fixes and improvements
+
+
+Changes With Apache Tuscany SCA 2.0-M3 June 2009
+================================================
+
+Highlights include:
+- Support for <implementation.bpel> and the OASIS BPEL specification
+- Support for <implementation.spring> and the draft OASIS Spring specification
+- Support for the new SCACleint API as defined in the OASIS spec drafts
+- Runtime support for SCA contributions in ZIP archives from the OASIS Assembly spec
+- New Maven archetype to simplify create ZIP contributions
+- New tuscany:run maven plugin for easy running SCA contributions
+- Clean up and simplify the Tuscany module structure
+- Various fixes for Assembly spec compliance and improved error reporting
+- New deep integration into Apache Tomcat
+
+
+Changes With Apache Tuscany SCA 2.0-M2 April 2009
+=================================================
+
+Highlights include:
+- OSGi Enhancements including support for <implementation.osgi> and a new OSGi RFC119 prototype
+- Many updates towards support for OASIS OpenCSA specification and the use OASIS namespaces and schemas
+- Start to implement the SCA policy framework 1.1 spec draft from OASIS OpenCSA
+- New Endpoint and EndpoitReference structures
+- Webapps integration support including <implementation.web> and the web application composite along
+- with support for various web technologies and frameworks including JSP support, JSF support with
+- Apache MyFaces, and integration with the Stripes Web Framework
+- New Maven Archetypes to make developing SCA applications easier,
+ see http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Tuscany+Maven+Archetypes
+
+Changes With Apache Tuscany SCA 2.0-M1 February 2009
+====================================================
+
+ The first milestone release for the 2.0 codebase
+
+ Features and/or Enhancements
+
+ * SCA Specification support
+ - The change over from OSOA SCA specification support to OASIS SCA
+ specification support is now in progress. As such we don't claim to
+ support either the OSOA or OASIS SCA specifications in the
+ 2.0 codebase yet.
+
+ * Core
+ - Enable Tuscany to run inside an OSGi runtime
+ - Updated SCA API package names.
+
+ * Other Extensions
+ - Binding RMI
+ - RMI Binding
+ - Binding WS
+ - WebServices Binding
+
+ * Samples/Tutorial/Demos
+ - binding-ws-calculator/
+ - calculator/
+ - calculator-equinox/
+ - calculator-osgi/
+ - calculator-rmi-reference/
+ - calculator-rmi-service/
+ - implementation-java-calculator
diff --git a/sandbox/sebastien/java/embed/LICENSE b/sandbox/sebastien/java/embed/LICENSE
new file mode 100644
index 0000000000..ddd30126af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/LICENSE
@@ -0,0 +1,485 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+===============================================================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================================================
+
+The module itest/databindings/common includes the test schema; datagraph.xsd, sdoJava.xsd, and sdoModel.xsd
+under the following license:
+
+License for the Service Data Objects JavaDoc, Interface Definition files
+and XSD files.
+
+The Service Data Objects JavaDoc, Interface Definition files and XSD files
+are being provided by the copyright holders under the following license.
+By using and/or copying this work, you agree that you have read,
+understood and will comply with the following terms and conditions:
+
+Permission to copy, display, make derivative works of and distribute
+the Service Data Objects JavaDoc, Interface Definition files and XSD files
+(the "Artifacts") in any medium without fee or royalty is hereby granted,
+provided that you include the following on ALL copies of the Artifacts,
+or portions thereof, that you make:
+
+1. A link or URL to the Artifacts at this location:
+http://www.osoa.org/display/Main/Service+Data+Objects+Specifications
+
+2. The full text of this copyright notice as shown in the Artifacts.
+
+
+
+THE ARTIFACTS ARE PROVIDED "AS IS" AND THE AUTHORS MAKE NO
+REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THE
+ARTIFACTS AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY
+USE OR DISTRIBUTION OF THE ARTIFACTS.
+
+The name and trademarks of the Authors may NOT be used in any manner,
+including advertising or publicity pertaining to the Service Data
+Objects Specification or its contents without specific, written prior
+permission. Title to copyright in the Service Data Objects
+Specification will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+Revision level 1.11, last updated on 2007/12/21
+
+=================================================================================================================
+
+The module implementation-script temporarily includes one file under the following BSD license:
+
+ Copyright (c) 2006, Sun Microsystems, Inc.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither the name of the Sun Microsystems, Inc. nor the names of
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+=================================================================================================================
+
+The module assembly-xsd includes XSD files under the following license:
+
+License for the Service Component Architecture JavaDoc, Interface
+Definition files and XSD files.
+
+The Service Component Architecture JavaDoc, Interface Definition files,
+and XSD files are being provided by the copyright holders under the
+following license. By using and/or copying this work, you agree that
+you have read, understood and will comply with the following terms and
+conditions:
+
+Permission to copy, display, make derivative works of, and distribute
+the Service Component Architecture JavaDoc, Interface Definition Files
+and XSD files (the "Artifacts") in any medium without fee or royalty is
+hereby granted, provided that you include the following on ALL copies
+of the Artifacts, or portions thereof, that you make:
+
+1. A link or URL to the Artifacts at this location:
+http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of this copyright notice as shown in the Artifacts.
+
+THE ARTIFACTS ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO
+REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THE
+ARTIFACTS AND THE IMPLEMENTATION OF THEIR CONTENTS, INCLUDING, BUT NOT
+LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE, NON-INFRINGEMENT OR TITLE.
+
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY
+USE OR DISTRIBUTION OF THE ARTIFACTS.
+
+The name and trademarks of the Authors may NOT be used in any manner,
+including advertising or publicity pertaining to the Service Component
+Architecture Specification or its contents without specific, written
+prior permission. Title to copyright in the Service Component
+Architecture Specification and the JavaDoc, Interface Definition Files
+and XSD Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+Revision level 1.1, last updated on 2007/11/19
+
+=================================================================================================================
+
+The modules assembly-xsd and definitions-xml includes XSD and XML files under the following license:
+
+Copyright OASIS 2005, 2009. All Rights Reserved.
+All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual
+Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
+This document and translations of it may be copied and furnished to others, and derivative works that
+comment on or otherwise explain it or assist in its implementation may be prepared, copied, published,
+and distributed, in whole or in part, without restriction of any kind, provided that the above copyright
+notice and this section are included on all such copies and derivative works. However, this document
+itself may not be modified in any way, including by removing the copyright notice or references to OASIS,
+except as needed for the purpose of developing any document or deliverable produced by an OASIS
+Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR
+Policy, must be followed) or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors
+or assigns.
+This document and the information contained herein is provided on an "AS IS" basis and OASIS
+DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
+WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP
+RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.
+OASIS requests that any OASIS Party or any other party that believes it has patent claims that would
+necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard,
+to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to
+such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that
+produced this specification.
+OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of
+any patent claims that would necessarily be infringed by implementations of this specification by a patent
+holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR
+Mode of the OASIS Technical Committee that produced this specification. OASIS may include such
+claims on its website, but disclaims any obligation to do so.
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that
+might be claimed to pertain to the implementation or use of the technology described in this document or
+the extent to which any license under such rights might or might not be available; neither does it represent
+that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to
+rights in any document or deliverable produced by an OASIS Technical Committee can be found on the
+OASIS website. Copies of claims of rights made available for publication and any assurances of licenses
+to be made available, or the result of an attempt made to obtain a general license or permission for the use
+of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS
+Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any
+information or list of intellectual property rights will at any time be complete, or that any claims in such list
+are, in fact, Essential Claims.
+The names "OASIS", are trademarks of OASIS, the owner and developer of this specification, and should
+be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and
+implementation and use of, specifications, while reserving the right to enforce its marks against misleading
+uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance.
+
+=================================================================================================================
+
+The module assembly-xsd includes XSD files under the following license:
+
+http://www.w3.org/Consortium/Legal/copyright-software-19980720
+
+W3C® SOFTWARE NOTICE AND LICENSE
+Copyright (c) 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche
+en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
+
+This W3C work (including software, documents, or other related items) is being provided by the copyright holders under
+the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood,
+and will comply with the following terms and conditions:
+
+Permission to use, copy, modify, and distribute this software and its documentation, with or without modification,
+for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies
+of the software and documentation or portions thereof, including modifications, that you make:
+
+ 1. The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+ 2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, a short
+notice of the following form (hypertext is preferred, text is permitted) should be used within the body of any redistributed
+or derivative code: "Copyright (c) [$date-of-software] World Wide Web Consortium, (Massachusetts Institute of Technology,
+Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/"
+ 3. Notice of any changes or modifications to the W3C files, including the date changes were made. (We recommend you provide URIs
+to the location from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE
+OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE
+OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software
+without specific, written prior permission. Title to copyright in this software and any associated documentation will
+at all times remain with copyright holders.
+
+=================================================================================================================
+
+The module assembly-xsd includes XSD files under the following license:
+
+The modules
+
+binding-ws-xml
+databinding
+databinding-axiom
+databinding-jaxb
+databinding-json
+databinding-sdo
+databinding-sdo-axiom
+databinding-xmlbeans
+interface-wsdl-xml
+
+Include the ipo.xsd and address.xsd information from the XML Schema Primer
+(http://www.w3.org/TR/2004/PER-xmlschema-0-20040318/) combined into the
+file ipo.xsd and extended with UK postcode structures.
+
+The ipo.xsd file is also included under the following license:
+
+W3C(c) SOFTWARE NOTICE AND LICENSE
+http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+This work (and included software, documentation such as READMEs, or other
+related items) is being provided by the copyright holders under the following
+license. By obtaining, using and/or copying this work, you (the licensee) agree
+that you have read, understood, and will comply with the following terms and conditions.
+
+Permission to copy, modify, and distribute this software and its documentation,
+with or without modification, for any purpose and without fee or royalty is
+hereby granted, provided that you include the following on ALL copies of the
+software and documentation or portions thereof, including modifications:
+
+ 1. The full text of this NOTICE in a location viewable to users of the
+ redistributed or derivative work.
+ 2. Any pre-existing intellectual property disclaimers, notices, or terms
+ and conditions. If none exist, the W3C Software Short Notice should be
+ included (hypertext is preferred, text is permitted) within the body of
+ any redistributed or derivative code.
+ 3. Notice of any changes or modifications to the files, including the date
+ changes were made. (We recommend you provide URIs to the location from which
+ the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
+NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,
+WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
+USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
+COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or
+publicity pertaining to the software without specific, written prior permission.
+Title to copyright in this software and any associated documentation will at all
+times remain with copyright holders.
diff --git a/sandbox/sebastien/java/embed/NOTICE b/sandbox/sebastien/java/embed/NOTICE
new file mode 100644
index 0000000000..65bf34a9ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/NOTICE
@@ -0,0 +1,5 @@
+Apache Tuscany
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/sandbox/sebastien/java/embed/README b/sandbox/sebastien/java/embed/README
new file mode 100644
index 0000000000..1d1c52763b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/README
@@ -0,0 +1,21 @@
+Apache Tuscany SCA README
+=========================
+
+Welcome to this Tuscany SCA release.
+
+See the RELEASE_NOTES file for information specific to this release.
+
+In the binary release see the INSTALL file for information on how to
+install the release.
+
+In the source distribution see the BUILDING file for information on
+building the source code.
+
+Please note that milestone releases may support experimental
+features and APIs that may not exist in future releases.
+
+
+
+
+
+
diff --git a/sandbox/sebastien/java/embed/RELEASE_NOTES b/sandbox/sebastien/java/embed/RELEASE_NOTES
new file mode 100644
index 0000000000..f1604b1889
--- /dev/null
+++ b/sandbox/sebastien/java/embed/RELEASE_NOTES
@@ -0,0 +1,84 @@
+Apache Tuscany SCA 2.0-Beta1 June 2010 Release Notes
+=====================================================
+
+Apache Tuscany provides a runtime based on the Service Component
+Architecture. SCA is a set of specifications aimed at simplifying SOA
+Application Development which are being standardized at OASIS as part
+of Open Composite Services Architecture (Open CSA) - http://www.oasis-opencsa.org/.
+
+Overview
+--------
+
+ The Apache Tuscany SCA 2.0-Beta1 release includes implementations of the
+ main SCA specifications and recent updates from Open CSA drafts including:
+
+ SCA Assembly Model V1.1
+ SCA Policy Framework V1.1
+ SCA Java Common Annotations and APIs V1.1
+ SCA Java Component Implementation V1.1
+ SCA Client & Implementation: Spring V1.1
+ SCA Web Services Binding V1.1
+ SCA WS-BPEL Client and Implementation V1.1
+ (portions of) SCA JEE Integration V1.1
+
+ It also includes implementations of many features not yet defined
+ by SCA specifications, including:
+
+ - SCA bindings for RMI, HTTP, JSON-RPC, ATOM.
+ - Databindings for JAXB, Axis2's AXIOM, DOM, SAX and StAX
+ - Integration with various web frameworks
+
+ The Tuscany SCA Runtime can be configured as a single node SCA domain or
+ as an SCA domain distributed across multiple nodes.
+ In addition Tuscany SCA supports the following host-deployment options: -
+ - running standalone
+ - running in a OSGi enabled runtime Environment (Equinox)
+ - running with distributed nodes across multiple JVMs
+
+See the CHANGES file for a detailed list of the features in this release.
+
+Known Issues
+------------
+
+If when building using the source distribution of tuscany you see build errors
+relating to use of hazelcast, this is a known issue which occurs in some
+environments where our use of hazelcast doesn't match up with your network
+configuration. If you see these errors please contact us on the mailing list
+as described below. You may wish to build using the
+"mvn -fae"
+command, so that the rest of the build completes before it reports the issue.
+
+Support
+-------
+
+For more information on Apache Tuscany visit the website at:
+
+ http://tuscany.apache.org/tuscany/
+
+Any issues with this release can be reported to Apache Tuscany
+using the mailing lists or in the JIRA issue tracker.
+
+ Mailing list archives:
+
+ http://mail-archives.apache.org/mod_mbox/tuscany-user/
+ http://mail-archives.apache.org/mod_mbox/tuscany-dev/
+
+ Jira:
+
+ http://issues.apache.org/jira/browse/TUSCANY
+
+To join the project's mailing lists follow the instructions at:
+
+ http://incubator.apache.org/tuscany/mailing-lists.html
+
+To find out more about OASIS Open CSA go to:
+
+ http://www.oasis-opencsa.org.
+
+Apache Tuscany welcomes your help. Any contribution, including code,
+testing, improving the documentation, or bug reporting is always
+appreciated.
+
+Thank you for using Apache Tuscany!
+
+- The Tuscany Team.
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/archetypes/contribution-jar/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1e2a0fbb4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Contribution JAR
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Quickstart Archetype
+Bundle-SymbolicName: org.apache.tuscany.sca.archetype.contribution.jar
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/pom.xml b/sandbox/sebastien/java/embed/archetypes/contribution-jar/pom.xml
new file mode 100644
index 0000000000..3473186421
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-contribution-jar</artifactId>
+ <packaging>maven-archetype</packaging>
+ <name>Create an SCA JAR contribution project</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-3</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-3</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..46c5cd6dca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<archetype-descriptor name="myproject">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.composite</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..69c3fb5ac9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+<archetype>
+ <id>tuscany-contribution-jar</id>
+ <sources>
+ <source>src/main/java/HelloworldImpl.java</source>
+ <source>src/main/java/HelloworldService.java</source>
+ </sources>
+ <resources>
+ <resource>src/main/hello.composite</resource>
+ <resource>src/main/webapp/META-INF/sca-contribution.xml</resource>
+ </resources>
+</archetype> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..99eb8fe62b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,110 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>jar</packaging>
+ <version>${version}</version>
+ #literal()<!-- TODO project name -->
+ <name>quickstart</name>
+ <description></description>
+
+ <dependencies>
+ <!-- TUSCANY DEPENDENCIES -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- JUNIT DEPENDENCY FOR TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ </properties>
+ #end
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java
new file mode 100644
index 0000000000..26237c105c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.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 ${package};
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.EagerInit;
+
+@Scope("COMPOSITE") @EagerInit
+public class HelloworldImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ @Init
+ public void init() {
+ System.out.println(sayHello("world"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java
new file mode 100644
index 0000000000..d705564334
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.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 ${package};
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..960d6a90ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://${package}">
+ <deployable composite="sample:${artifactId}"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..35970f63ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://${package}"
+ name="${artifactId}">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="${package}.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip-discriptor/pom.xml b/sandbox/sebastien/java/embed/archetypes/contribution-zip-discriptor/pom.xml
new file mode 100644
index 0000000000..c3a1f9bb5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip-discriptor/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-zip-contribution-descriptor</artifactId>
+ <name>Tuscany SCA ZIP contribution Shared Assembly Descriptor</name>
+
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml b/sandbox/sebastien/java/embed/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml
new file mode 100644
index 0000000000..a672d2920d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml
@@ -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.
+-->
+<assembly>
+ <id>zip-contribution</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <dependencySets>
+ <dependencySet>
+ <unpack>false</unpack>
+ <scope>runtime</scope>
+ <outputDirectory>lib</outputDirectory>
+ <useProjectArtifact>false</useProjectArtifact>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>${project.build.outputDirectory}</directory>
+ <outputDirectory>/</outputDirectory>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/archetypes/contribution-zip/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b5be2573dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Contribution ZIP
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA ZIP Contribution Archetype
+Bundle-SymbolicName: org.apache.tuscany.sca.archetype.contribution.zip
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/pom.xml b/sandbox/sebastien/java/embed/archetypes/contribution-zip/pom.xml
new file mode 100644
index 0000000000..e98f2ff845
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-contribution-zip</artifactId>
+ <packaging>maven-archetype</packaging>
+ <name>Create an SCA ZIP contribution project</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-3</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-3</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..46c5cd6dca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<archetype-descriptor name="myproject">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.composite</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..c17535e802
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+<archetype>
+ <id>tuscany-contribution-zip</id>
+ <sources>
+ <source>src/main/java/AddImpl.java</source>
+ <source>src/main/java/AddService.java</source>
+ </sources>
+ <resources>
+ <resource>src/main/resources/add.composite</resource>
+ <resource>src/main/resources/META-INF/sca-contribution.xml</resource>
+ </resources>
+</archetype> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..873b45ee39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,153 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>jar</packaging>
+ <version>${version}</version>
+ #literal() <!-- TODO project name -->
+ <name>quickstart</name>
+ <description></description>
+
+ <dependencies>
+ <!-- TUSCANY DEPENDENCIES -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!--
+ AN EXAMPLE APPLICATION DEPENDENCY TO BE INCLUDED IN ZIP
+ -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <!-- AN EXAMPLE APPLICATION DEPENDENCY TO BE INCLUDED IN ZIP -->
+ <dependency>
+ <groupId>commons-math</groupId>
+ <artifactId>commons-math</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <!-- JUNIT DEPENDENCY FOR TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-3</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-zip-contribution-descriptor</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <!-- This is where we use our shared assembly descriptor -->
+ <descriptors>
+ <descriptor>tuscany-zip-contribution.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ </properties>
+ #end
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java
new file mode 100644
index 0000000000..48b62dbb6f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.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 ${package};
+
+import org.apache.commons.math.util.MathUtils;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.EagerInit;
+
+@Scope("COMPOSITE") @EagerInit
+public class AddImpl implements AddService {
+
+ public int add(int x, int y) {
+ return MathUtils.addAndCheck(x, y);
+ }
+
+ @Init
+ public void init() {
+ System.out.println("1 + 2 = " + add(1, 2));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java
new file mode 100644
index 0000000000..4b25553893
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.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 ${package};
+
+public interface AddService {
+
+ int add(int x, int y);
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..960d6a90ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://${package}">
+ <deployable composite="sample:${artifactId}"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite
new file mode 100644
index 0000000000..3dc8175bd7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://${package}"
+ name="${artifactId}">
+
+ <component name="AddComponent">
+ <implementation.java class="${package}.AddImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/archetypes/pom.xml b/sandbox/sebastien/java/embed/archetypes/pom.xml
new file mode 100644
index 0000000000..9f3e35e2a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/pom.xml
@@ -0,0 +1,51 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-archetype</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Maven Archetypes</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+
+ <modules>
+ <module>contribution-jar</module>
+ <module>contribution-zip</module>
+ <module>contribution-zip-discriptor</module>
+ <module>quickstart</module>
+ <module>quickstart-jsf</module>
+ <module>quickstart-stripes</module>
+ <module>quickstart-bpel</module>
+ </modules>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..29e03eb396
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Quickstart Archetype
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Quickstart Archetype
+Bundle-SymbolicName: org.apache.tuscany.sca.archetype.quickstart
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/pom.xml
new file mode 100644
index 0000000000..c1248a0a9d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-quickstart-bpel</artifactId>
+ <packaging>maven-archetype</packaging>
+ <name>Create an SCA Webapp project using BPEL</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-3</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-3</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..47c2f5dc10
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.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.
+-->
+<archetype-descriptor name="myproject">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.jsp</include>
+ <include>**/*.xml</include>
+ <include>**/*.composite</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..c466a1b3f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml
@@ -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.
+-->
+<archetype>
+ <id>tuscany-quickstart</id>
+ <sources>
+ <source>src/main/java/HelloworldImpl.java</source>
+ <source>src/main/java/HelloworldService.java</source>
+ </sources>
+ <resources>
+ <source>src/main/resources/helloworld.bpel</source>
+ <source>src/main/resources/helloworld.wsdl</source>
+ <resource>src/main/webapp/hello.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/web.composite</resource>
+ <resource>src/main/webapp/WEB-INF/web.xml</resource>
+ </resources>
+</archetype> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..30be6b66e3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,182 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>war</packaging>
+ <version>${version}</version>
+ #literal()<!-- TODO project name -->
+ <name>quickstart</name>
+ <description></description>
+
+ <dependencies>
+ <!-- TUSCANY DEPENDENCIES -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- JUNIT DEPENDENCY FOR TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- JETTY DEPENDENCIES FOR TESTING -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-management</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby</artifactId>
+ <version>1.1.1</version>
+ <type>zip</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}/classes</outputDirectory>
+ <includes>**/*</includes>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>${jetty.version}</version>
+ <configuration>
+ <systemProperties>
+ <systemProperty>
+ <!-- this property is needed to avoid a problem in openjpa -->
+ <name>openjpa.QueryCompilationCache</name>
+ <value>false</value>
+ </systemProperty>
+ </systemProperties>
+ <!-- need to override the src dir so src/main/resources are also included -->
+ <webAppSourceDirectory>${basedir}/src/main</webAppSourceDirectory>
+ <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ <jetty.version>6.1.18</jetty.version>
+ </properties>
+ #end
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java
new file mode 100644
index 0000000000..a99cc7b032
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.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 ${package};
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String hello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel
new file mode 100644
index 0000000000..53e77c5be0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel
@@ -0,0 +1,66 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="helloworld.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"/>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink" partnerLinkType="test:HelloPartnerLinkType" myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="myVar" messageType="test:HelloMessage"/>
+ <variable name="tmpVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="myVar"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from variable="myVar" part="TestPart"/>
+ <to variable="tmpVar"/>
+ </copy>
+ <copy>
+ <from>concat($tmpVar,' World')</from>
+ <to variable="myVar" part="TestPart"/>
+ </copy>
+ </assign>
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="myVar"/>
+ </sequence>
+</process>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..46cf381577
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl
@@ -0,0 +1,82 @@
+<?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://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="message" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part element="tns:hello" name="TestPart"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="TestIn">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="TestOut">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8085/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..4d3d532184
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ targetNamespace="http://${package}"
+ name="${artifactId}">
+
+ <component name="WebComponent">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent">
+ <interface.java interface="${package}.HelloworldService"/>
+ </reference>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.bpel process="hns:HelloWorld"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..922d275b17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+<web-app 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>${artifactId}</display-name>
+
+ <filter>
+ <filter-name>tuscany.${artifactId}</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany.${artifactId}</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..7aeaf81b33
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
@@ -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.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="${package}.HelloworldService" />
+
+<html>
+ <body >
+
+ <h2>${artifactId}</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.hello("world") %>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/pom.xml
new file mode 100644
index 0000000000..ec26342ff9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-quickstart-jsf</artifactId>
+ <packaging>maven-archetype</packaging>
+ <name>Create a Tuscany SCA and JSF project</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-4</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-4</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..f15a12fb88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -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.
+-->
+<archetype-descriptor name="myproject">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.jsp</include>
+ <include>**/*.xml</include>
+ <include>**/*.html</include>
+ <include>**/*.composite</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..b5295d8a73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml
@@ -0,0 +1,38 @@
+<?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.
+-->
+<archetype>
+ <id>quickstart-stripes</id>
+ <sources>
+ <source>src/main/java/sample/stripes/action/BaseActionBean.java</source>
+ <source>src/main/java/sample/stripes/action/HomeActionBean.java</source>
+ <source>src/main/java/sample/sca/HelloworldService.java</source>
+ <source>src/main/java/sample/sca/HelloworldServiceImpl.java</source>
+ </sources>
+ <resources>
+ <resource>src/main/resources/log4j.properties</resource>
+ <resource>src/main/resources/StripesResources.properties</resource>
+ <resource>src/main/webapp/index.html</resource>
+ <resource>src/main/webapp/WEB-INF/jsp/home.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/jsp/layout.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/jsp/taglibs.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/web.composite</resource>
+ <resource>src/main/webapp/WEB-INF/web.xml</resource>
+ </resources>
+</archetype> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..f252e602ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,154 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>war</packaging>
+ <version>${version}</version>
+ #literal()<!-- TODO project name -->
+ <name>quickstart-jsf</name>
+ <description></description>
+
+ <dependencies>
+
+ <!-- Tuscany dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-myfaces</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+
+ <!-- MyFaces JSF dependencies -->
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>1.2.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>1.2.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.tomahawk</groupId>
+ <artifactId>tomahawk</artifactId>
+ <version>1.1.6</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>jstl</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>${jetty.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ <myfaces.version>1.5</myfaces.version>
+ <jetty.version>6.1.4</jetty.version>
+ </properties>
+ #end
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java
new file mode 100644
index 0000000000..e38c84feda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java
@@ -0,0 +1,64 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 ${package}.myfaces;
+
+import org.oasisopen.sca.annotation.Reference;
+
+import ${package}.sca.HelloworldService;
+
+/**
+ * A typical simple backing bean, that is backed to <code>helloworld.jsp</code>
+ *
+ */
+public class HelloWorldController {
+
+ //properties
+ private String name;
+
+ @Reference
+ private HelloworldService service;
+
+ /**
+ * default empty constructor
+ */
+ public HelloWorldController(){
+ }
+
+ //-------------------getter & setter
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Method that is backed to a submit button of a form.
+ */
+ public String send(){
+
+ // invoke the SCA reference
+ name = service.sayHello(name);
+
+ return "success";
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java
new file mode 100644
index 0000000000..d6cb7bbcf2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java
@@ -0,0 +1,28 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 ${package}.sca;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..ec9bfd7221
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java
@@ -0,0 +1,30 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 ${package}.sca;
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000000..3b732de8af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,53 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?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.
+-->
+<faces-config version="1.2"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+
+ <!-- managed beans of the simple hello world app -->
+ <managed-bean>
+ <managed-bean-name>helloWorld</managed-bean-name>
+ <managed-bean-class>${package}.myfaces.HelloWorldController</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <!-- navigation rules for helloWorld.jsp -->
+ <navigation-rule>
+ <from-view-id>/helloWorld.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/page2.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <!-- navigation rules for page2.jsp -->
+ <navigation-rule>
+ <from-view-id>/page2.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/helloWorld.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+</faces-config> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..7e18dc9308
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://${package}"
+ name="${artifactId}">
+
+ <component name="${artifactId}WebComponent">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="${package}.sca.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
+
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..48b73fe68a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,230 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?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.
+-->
+<web-app 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"
+ version="2.4">
+
+ <display-name>${artifactId}</display-name>
+
+ <!-- The only web.xml change to the MyFaces Helloworld sample is to add
+ the Tuscany listener and annotation processor context parameter -->
+ <listener>
+ <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>
+ </listener>
+ <context-param>
+ <param-name>org.apache.myfaces.config.annotation.LifecycleProvider</param-name>
+ <param-value>org.apache.tuscany.sca.myfaces.TuscanyAnnotationLifecycleProvider</param-value>
+ </context-param>
+
+ <!--optional: context-param>
+ <description>Comma separated list of URIs of (additional) faces config files.
+ (e.g. /WEB-INF/my-config.xml)
+ See JSF 1.0 PRD2, 10.3.2
+ Attention: You do not need to put /WEB-INF/faces-config.xml in here.
+ </description>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/examples-config.xml</param-value>
+ </context-param-->
+ <context-param>
+ <description>State saving method: "client" or "server" (= default)
+ See JSF Specification 2.5.3</description>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>client</param-value>
+ </context-param>
+ <context-param>
+ <description>Only applicable if state saving method is "server" (= default).
+ Defines the amount (default = 20) of the latest views are stored in session.</description>
+ <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
+ <param-value>20</param-value>
+ </context-param>
+ <context-param>
+ <description>Only applicable if state saving method is "server" (= default).
+ If true (default) the state will be serialized to a byte stream before it
+ is written to the session.
+ If false the state will not be serialized to a byte stream.</description>
+ <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Only applicable if state saving method is "server" (= default) and if
+ org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default)
+ If true (default) the serialized state will be compressed before it
+ is written to the session. If false the state will not be compressed.</description>
+ <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>This parameter tells MyFaces if javascript code should be allowed in the
+ rendered HTML output.
+ If javascript is allowed, command_link anchors will have javascript code
+ that submits the corresponding form.
+ If javascript is not allowed, the state saving info and nested parameters
+ will be added as url parameters.
+ Default: "true"</description>
+ <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <description>If true, rendered HTML code will be formatted, so that it is "human readable".
+ i.e. additional line separators and whitespace will be written, that do not
+ influence the HTML code.
+ Default: "true"</description>
+ <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>If true, a javascript function will be rendered that is able to restore the
+ former vertical scroll on every request. Convenient feature if you have pages
+ with long lists and you do not want the browser page to always jump to the top
+ if you trigger a link or button action that stays on the same page.
+ Default: "false"</description>
+ <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <description>Used for encrypting view state. Only relevant for client side
+ state saving. See MyFaces wiki/web site documentation for instructions
+ on how to configure an application for diffenent encryption strengths.
+ </description>
+ <param-name>org.apache.myfaces.SECRET</param-name>
+ <param-value>NzY1NDMyMTA=</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Validate managed beans, navigation rules and ensure that forms are not nested.
+ </description>
+ <param-name>org.apache.myfaces.VALIDATE</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Treat readonly same as if disabled attribute was set for select elements.
+ </description>
+ <param-name>org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Use the defined class as the class which will be called when a resource is added to the
+ ExtensionFilter handling. Using StreamingAddResource here helps with performance. If you want to add
+ custom components and want to use the ExtensionFilter, you need to provide your custom implementation here.
+ </description>
+ <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
+ <param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Virtual path in the URL which triggers loading of resources for the MyFaces extended components
+ in the ExtensionFilter.
+ </description>
+ <param-name>org.apache.myfaces.RESOURCE_VIRTUAL_PATH</param-name>
+ <param-value>/faces/myFacesExtensionResource</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Check if the extensions-filter has been properly configured.
+ </description>
+ <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Define partial state saving as true/false.
+ </description>
+ <param-name>javax.faces.PARTIAL_STATE_SAVING_METHOD</param-name>
+ <param-value>false</param-value>
+ </context-param>
+
+ <!-- Extensions Filter -->
+ <filter>
+ <filter-name>extensionsFilter</filter-name>
+ <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
+ <init-param>
+ <description>Set the size limit for uploaded files.
+ Format: 10 - 10 bytes
+ 10k - 10 KB
+ 10m - 10 MB
+ 1g - 1 GB</description>
+ <param-name>uploadMaxFileSize</param-name>
+ <param-value>100m</param-value>
+ </init-param>
+ <init-param>
+ <description>Set the threshold size - files
+ below this limit are stored in memory, files above
+ this limit are stored on disk.
+
+ Format: 10 - 10 bytes
+ 10k - 10 KB
+ 10m - 10 MB
+ 1g - 1 GB</description>
+ <param-name>uploadThresholdSize</param-name>
+ <param-value>100k</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>extensionsFilter</filter-name>
+ <url-pattern>*.jsf</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>extensionsFilter</filter-name>
+ <url-pattern>/faces/*</url-pattern>
+ </filter-mapping>
+
+ <!-- Listener, to allow Jetty serving MyFaces apps -->
+ <listener>
+ <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
+ </listener>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp
new file mode 100644
index 0000000000..4a3197ec4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp
@@ -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.
+-->
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<html>
+ <head>
+ <title>Hello World</title>
+ </head>
+ <body>
+ <f:view>
+ <h:form id="mainForm">
+ <h:panelGrid columns="2">
+ <h:outputLabel for="name" value="Please enter your name" />
+ <h:inputText id="name" value="#{helloWorld.name}" required="true"/>
+ <h:commandButton value="Press me" action="#{helloWorld.send}"/>
+ <h:messages showDetail="true" showSummary="false"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp
new file mode 100644
index 0000000000..768aa2408b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp
@@ -0,0 +1,22 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<%@ page session="false"%>
+<%
+response.sendRedirect("helloWorld.jsf");
+%> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp
new file mode 100644
index 0000000000..1c096f66c6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp
@@ -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.
+-->
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<html>
+ <head>
+ <title>Hello World</title>
+ </head>
+ <body>
+ <f:view>
+ <h:form id="mainForm">
+ <h2><h:outputText value="#{helloWorld.name}. We hope you enjoy SCA and JSF with Apache Tuscany and MyFaces"/></h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+ </f:view>
+ </body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..29e03eb396
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Quickstart Archetype
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Quickstart Archetype
+Bundle-SymbolicName: org.apache.tuscany.sca.archetype.quickstart
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/pom.xml
new file mode 100644
index 0000000000..67a90e2a7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-quickstart-jsonp</artifactId>
+ <packaging>maven-archetype</packaging>
+ <name>Create a Tuscany SCA webapp project using the JSONP binding</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-4</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-4</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..450e33afd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<archetype-descriptor name="myproject">
+ <requiredProperties>
+ <requiredProperty key="includeTuscanyRuntime">
+ <defaultValue>Y</defaultValue>
+ </requiredProperty>
+ </requiredProperties>
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.jsp</include>
+ <include>**/*.xml</include>
+ <include>**/*.composite</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..1bf4353502
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml
@@ -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.
+-->
+<archetype>
+ <id>tuscany-quickstart</id>
+ <sources>
+ <source>src/main/java/HelloworldImpl.java</source>
+ <source>src/main/java/HelloworldService.java</source>
+ </sources>
+ <resources>
+ <resource>src/main/webapp/hello.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/web.composite</resource>
+ <resource>src/main/webapp/WEB-INF/web.xml</resource>
+ </resources>
+</archetype> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..8fc4bde625
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,154 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>war</packaging>
+ <version>${version}</version>
+ <name>quickstart-jsonp</name>
+
+ <dependencies>
+ <!-- TUSCANY DEPENDENCIES -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+#if(${includeTuscanyRuntime} == "Y")
+ <scope>compile</scope>
+#else
+ <scope>provided</scope>
+#end
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>${tuscany.version}</version>
+#if( $includeTuscanyRuntime == "Y")
+ <scope>runtime</scope>
+#else
+ <scope>provided</scope>
+#end
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>${tuscany.version}</version>
+#if( $includeTuscanyRuntime == "Y")
+ <scope>runtime</scope>
+#else
+ <scope>provided</scope>
+#end
+ </dependency>
+
+ <!-- JUNIT DEPENDENCY FOR TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- JETTY DEPENDENCIES FOR TESTING -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-management</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>${jetty.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ <jetty.version>6.1.18</jetty.version>
+ </properties>
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java
new file mode 100644
index 0000000000..2491816adc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package ${package};
+
+public class HelloworldImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java
new file mode 100644
index 0000000000..3527edcd6f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.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 ${package};
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..fa37fec88c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://${package}"
+ name="${artifactId}">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="${package}.HelloworldImpl"/>
+ <service name="HelloworldService">
+ <tuscany:binding.jsonp/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..25d8d8184d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.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.
+-->
+<web-app 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>${artifactId}</display-name>
+
+#if($includeTuscanyRuntime == "Y")
+ <filter>
+ <filter-name>tuscany.${artifactId}</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany.${artifactId}</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+#end
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..9729ca6823
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
@@ -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.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="${package}.HelloworldService" />
+
+<html>
+ <body >
+
+ <h2>${artifactId}</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.sayHello("world") %>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ae84237c4a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Quickstart Stripes Archetype
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Quickstart Stripes Archetype
+Bundle-SymbolicName: org.apache.tuscany.sca.archetype.quickstart.stripes
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/pom.xml
new file mode 100644
index 0000000000..af6ae0be3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-quickstart-stripes</artifactId>
+ <packaging>maven-archetype</packaging>
+ <name>Create a simple Apache Tuscany SCA webapp project using the Stripes Web Framework</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-4</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-4</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..f15a12fb88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -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.
+-->
+<archetype-descriptor name="myproject">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.jsp</include>
+ <include>**/*.xml</include>
+ <include>**/*.html</include>
+ <include>**/*.composite</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..b5295d8a73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml
@@ -0,0 +1,38 @@
+<?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.
+-->
+<archetype>
+ <id>quickstart-stripes</id>
+ <sources>
+ <source>src/main/java/sample/stripes/action/BaseActionBean.java</source>
+ <source>src/main/java/sample/stripes/action/HomeActionBean.java</source>
+ <source>src/main/java/sample/sca/HelloworldService.java</source>
+ <source>src/main/java/sample/sca/HelloworldServiceImpl.java</source>
+ </sources>
+ <resources>
+ <resource>src/main/resources/log4j.properties</resource>
+ <resource>src/main/resources/StripesResources.properties</resource>
+ <resource>src/main/webapp/index.html</resource>
+ <resource>src/main/webapp/WEB-INF/jsp/home.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/jsp/layout.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/jsp/taglibs.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/web.composite</resource>
+ <resource>src/main/webapp/WEB-INF/web.xml</resource>
+ </resources>
+</archetype> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..312affaba9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,124 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>war</packaging>
+ <version>${version}</version>
+ #literal()<!-- TODO project name -->
+ <name>quickstart-stripes</name>
+ <description></description>
+
+ <dependencies>
+
+ <!-- Tuscany dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-stripes</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+
+ <!-- Stripes Framework dependencies -->
+ <dependency>
+ <groupId>net.sourceforge.stripes</groupId>
+ <artifactId>stripes</artifactId>
+ <version>${stripes.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>${jetty.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ <stripes.version>1.5.2</stripes.version>
+ <jetty.version>6.1.4</jetty.version>
+ </properties>
+ #end
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java
new file mode 100644
index 0000000000..d6cb7bbcf2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java
@@ -0,0 +1,28 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 ${package}.sca;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..390b424d24
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java
@@ -0,0 +1,31 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 ${package}.sca;
+
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/BaseActionBean.java b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/BaseActionBean.java
new file mode 100644
index 0000000000..5bfa1c5d32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/BaseActionBean.java
@@ -0,0 +1,36 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 ${package}.stripes.action;
+
+import net.sourceforge.stripes.action.ActionBean;
+import net.sourceforge.stripes.action.ActionBeanContext;
+
+public class BaseActionBean implements ActionBean {
+ private ActionBeanContext context;
+
+ public ActionBeanContext getContext() {
+ return context;
+ }
+ public void setContext(ActionBeanContext context) {
+ this.context = context;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/HomeActionBean.java b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/HomeActionBean.java
new file mode 100644
index 0000000000..05fd743841
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/HomeActionBean.java
@@ -0,0 +1,48 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 ${package}.stripes.action;
+
+import net.sourceforge.stripes.action.DefaultHandler;
+import net.sourceforge.stripes.action.ForwardResolution;
+import net.sourceforge.stripes.action.Resolution;
+import net.sourceforge.stripes.action.UrlBinding;
+
+import org.oasisopen.sca.annotation.Reference;
+
+import ${package}.sca.HelloworldService;
+
+@UrlBinding("/Home.htm")
+public class HomeActionBean extends BaseActionBean {
+
+ @Reference
+ HelloworldService service;
+
+ @DefaultHandler
+ public Resolution view() {
+ return new ForwardResolution("/WEB-INF/jsp/home.jsp");
+ }
+
+ public String getHello() {
+ return service.sayHello("world");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties
new file mode 100644
index 0000000000..6567f21ce1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties
@@ -0,0 +1,77 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+
+${symbol_pound} Resource strings used by the <stripes:errors> tag when there are no nested tags
+stripes.errors.header=<div style="color:${symbol_pound}b72222; font-weight: bold">Please fix the following errors:</div><ol>
+stripes.errors.beforeError=<li style="color: ${symbol_pound}b72222;">
+stripes.errors.afterError=</li>
+stripes.errors.footer=</ol>
+
+${symbol_pound} Resource strings used by the <stripes:errors> tag when displaying errors for a
+${symbol_pound} specific field (e.g. <stripes:errors field="password"/>). If not supplied the
+${symbol_pound} values above will be used instead.
+stripes.fieldErrors.header=
+stripes.fieldErrors.beforeError=<span style="color: ${symbol_pound}b72222;">
+stripes.fieldErrors.afterError=</span><br />
+stripes.fieldErrors.footer=
+
+${symbol_pound} Resource strings used by the stripes:messages tag
+stripes.messages.header=<ul class="messages">
+stripes.messages.beforeMessage=<li>
+stripes.messages.afterMessage=</li>
+stripes.messages.footer=</ul>
+
+${symbol_pound} Validation error messages produced by Stripes' built-in converter classes. These
+${symbol_pound} are default error messages and can be overridden on per-field and per-form levels.
+${symbol_pound} Using the 'invalidNumber' error for a field 'age' of a form posting to
+${symbol_pound} '/user/Profile.action', the keys looked for (in order) would be:
+${symbol_pound} 1: /user/Profile.action.age.invalidNumber
+${symbol_pound} 2: /user/Profile.action.age.errorMessage
+${symbol_pound} 3: age.errorMessage
+${symbol_pound} 4: /user/Profile.action.invalidNumber
+${symbol_pound} 5: converter.number.invalidNumber
+converter.number.invalidNumber=The value ({1}) entered in field {0} must be a valid number
+converter.byte.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.short.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.integer.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.float.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.enum.notAnEnumeratedValue=The value "{1}" is not a valid value for field {0}
+converter.date.invalidDate=The value ({1}) entered in field {0} must be a valid date
+converter.email.invalidEmail=The value ({1}) entered is not a valid email address
+converter.creditCard.invalidCreditCard=The value ({1}) entered is not a valid credit card number
+
+${symbol_pound} Validation error messages produced by Stripes' annotation based validations. These
+${symbol_pound} are default error messages and can be overridden on per-field and per-form levels.
+${symbol_pound} Using the 'valueNotPresent' required field error for a field 'username' of a form
+${symbol_pound} posting to '/user/Register.action', the keys looked for (in order) would be:
+${symbol_pound} 1: /user/Register.action.username.valueNotPresent
+${symbol_pound} 2: /user/Register.action.username.errorMessage
+${symbol_pound} 3: username.errorMessage
+${symbol_pound} 4: /user/Register.action.valueNotPresent
+${symbol_pound} 5: validation.required.valueNotPresent
+validation.required.valueNotPresent={0} is a required field
+validation.minlength.valueTooShort={0} must be at least {2} characters long
+validation.maxlength.valueTooLong={0} must be no more than {2} characters long
+validation.minvalue.valueBelowMinimum=The minimum allowed value for {0} is {2}
+validation.maxvalue.valueAboveMaximum=The maximum allowed value for {0} is {2}
+validation.mask.valueDoesNotMatch=<em>{1}</em> is not a valid {0}
+validation.expression.valueFailedExpression=The value supplied ({1}) for field {0} is invalid
+validation.file.postBodyTooBig=Total upload size of {3} KB exceeds the maximum size of {2} KB
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties
new file mode 100644
index 0000000000..e2fd1997c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties
@@ -0,0 +1,51 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+${symbol_pound} log4j.properties
+
+${symbol_pound} Set up a logger to the console
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p %c %x - %m%n
+
+${symbol_pound} Use this to only see log messages beyond a certain threshold in the console
+${symbol_pound}log4j.appender.stdout.Threshold=WARN
+
+${symbol_pound} Set up a logger to a log file
+log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
+log4j.appender.logfile.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p %c %x - %m%n
+log4j.appender.logfile.File=${symbol_dollar}{user.home}/stripesquick.log
+log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
+
+${symbol_pound} Use this to only see log messages beyond a certain threshold in the log file
+${symbol_pound}log4j.appender.logfile.Threshold=WARN
+
+${symbol_pound} Logger settings
+log4j.rootLogger=INFO, stdout, logfile
+
+${symbol_pound} Valid levels are TRACE, DEBUG, INFO, WARN, ERROR, FATAL
+${symbol_pound} Change to TRACE or DEBUG to see more log messages
+log4j.logger.net.sourceforge.stripes=WARN
+log4j.logger.org.stripesbook.quickstart=INFO
+log4j.logger.org.mortbay.log=INFO
+log4j.logger.org=WARN
+log4j.logger.com=WARN
+log4j.logger.net=WARN
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/home.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/home.jsp
new file mode 100644
index 0000000000..59cdacfe23
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/home.jsp
@@ -0,0 +1,29 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<%--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+--%>
+<%@ include file="/WEB-INF/jsp/taglibs.jsp" %>
+
+<s:layout-render name="/WEB-INF/jsp/layout.jsp" title="Welcome">
+ <s:layout-component name="body">
+ <p>sayHello returns: ${symbol_dollar}{actionBean.hello}</p>
+ <p>Congratulations, you've set up a Stripes SCA project!</p>
+ </s:layout-component>
+</s:layout-render>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/layout.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/layout.jsp
new file mode 100644
index 0000000000..0964d2fb7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/layout.jsp
@@ -0,0 +1,42 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<%--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+--%>
+<%@ include file="/WEB-INF/jsp/taglibs.jsp" %>
+
+<s:layout-definition>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+ <title>${symbol_dollar}{title}</title>
+ <link rel="stylesheet" type="text/css" href="${symbol_dollar}{contextPath}/css/style.css">
+ <s:layout-component name="head">
+ </s:layout-component>
+ </head>
+ <body>
+ <div id="main">
+ <s:layout-component name="body">
+ </s:layout-component>
+ </div>
+ </body>
+</html>
+
+</s:layout-definition> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/taglibs.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/taglibs.jsp
new file mode 100644
index 0000000000..6452b1bd9c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/taglibs.jsp
@@ -0,0 +1,32 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<%--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+--%>
+<%-- Stripes TLD --%>
+<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
+<%@ taglib prefix="sdyn" uri="http://stripes.sourceforge.net/stripes-dynattr.tld" %>
+
+<%-- JSTL TLDs --%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
+
+<%-- This is so that you can conveniently refer to the context path with ${symbol_dollar}{contextPath} --%>
+<c:set var="contextPath" value="${symbol_dollar}{pageContext.request.contextPath}"/>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..f98b7f2721
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://${package}"
+ name="${artifactId}">
+
+ <component name="${artifactId}WebComponent">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="${package}.sca.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..d73e7311d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,68 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?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.
+-->
+<web-app 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>${artifactId}</display-name>
+
+ <listener>
+ <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <filter>
+ <filter-name>StripesFilter</filter-name>
+ <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
+ <init-param>
+ <param-name>ActionResolver.Packages</param-name>
+ <param-value>${package}.stripes.action</param-value>
+ </init-param>
+ <init-param>
+ <param-name>Extension.Packages</param-name>
+ <param-value>org.apache.tuscany.sca.stripes</param-value>
+ </init-param>
+ </filter>
+
+ <servlet>
+ <servlet-name>DispatcherServlet</servlet-name>
+ <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <filter-mapping>
+ <filter-name>StripesFilter</filter-name>
+ <servlet-name>DispatcherServlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ </filter-mapping>
+
+ <servlet-mapping>
+ <servlet-name>DispatcherServlet</servlet-name>
+ <url-pattern>*.htm</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html
new file mode 100644
index 0000000000..a350f1e68a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html
@@ -0,0 +1,27 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+ <meta http-equiv="refresh" content="0;url=Home.htm">
+ </head>
+</html>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/archetypes/quickstart/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..29e03eb396
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Quickstart Archetype
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Quickstart Archetype
+Bundle-SymbolicName: org.apache.tuscany.sca.archetype.quickstart
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart/pom.xml
new file mode 100644
index 0000000000..583acbb297
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-quickstart</artifactId>
+ <packaging>maven-archetype</packaging>
+ <name>Create a simple Apache Tuscany SCA webapp project</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-4</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-4</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..c132fa0364
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<archetype-descriptor name="myproject">
+ <requiredProperties>
+ <requiredProperty key="includeTuscanyRuntime">
+ <defaultValue>Y</defaultValue>
+ </requiredProperty>
+ </requiredProperties>
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.jsp</include>
+ <include>**/*.xml</include>
+ <include>**/*.composite</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..7794570626
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml
@@ -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.
+-->
+<archetype>
+ <id>tuscany-quickstart</id>
+ <sources>
+ <source>src/main/java/HelloworldImpl.java</source>
+ <source>src/main/java/HelloworldService.java</source>
+ </sources>
+ <resources>
+ <resource>src/main/webapp/hello.jsp</resource>
+ <resource>src/main/webapp/WEB-INF/web.composite</resource>
+ <resource>src/main/webapp/WEB-INF/web.xml</resource>
+ </resources>
+</archetype> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..bad07a995e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,143 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>war</packaging>
+ <version>${version}</version>
+ <name>quickstart</name>
+
+ <dependencies>
+ <!-- TUSCANY DEPENDENCIES -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+#if(${includeTuscanyRuntime} == "Y")
+ <scope>compile</scope>
+#else
+ <scope>provided</scope>
+#end
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>${tuscany.version}</version>
+#if( $includeTuscanyRuntime == "Y")
+ <scope>runtime</scope>
+#else
+ <scope>provided</scope>
+#end
+ </dependency>
+
+ <!-- JUNIT DEPENDENCY FOR TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- JETTY DEPENDENCIES FOR TESTING -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-management</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>${jetty.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ <jetty.version>6.1.18</jetty.version>
+ </properties>
+</project>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java
new file mode 100644
index 0000000000..df80303778
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package ${package};
+
+public class HelloworldImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java
new file mode 100644
index 0000000000..47501efb9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/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 ${package};
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..8d840b7867
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://${package}"
+ name="${artifactId}">
+
+ <component name="${artifactId}WebComponent">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="${package}.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..a7c7d2251e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.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.
+-->
+<web-app 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>${artifactId}</display-name>
+
+#if($includeTuscanyRuntime == "Y")
+ <filter>
+ <filter-name>tuscany.${artifactId}</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany.${artifactId}</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+#end
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..9729ca6823
--- /dev/null
+++ b/sandbox/sebastien/java/embed/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
@@ -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.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="${package}.HelloworldService" />
+
+<html>
+ <body >
+
+ <h2>${artifactId}</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.sayHello("world") %>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/compliance-tests/assembly/pom.xml b/sandbox/sebastien/java/embed/compliance-tests/assembly/pom.xml
new file mode 100644
index 0000000000..45cb276cb4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/assembly/pom.xml
@@ -0,0 +1,140 @@
+<?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-compliance-tests</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-compliance-test-assembly</artifactId>
+ <name>Apache Tuscany SCA Specification Compliance Tests Assembly</name>
+
+ <dependencies>
+
+ <dependency>
+ <!-- This is only needed to get the module working in Eclipse which doesn't pick it up from the dependency plugin unpack -->
+ <!-- The dependency plugin unpack is needed as presently the surefire plugin wont run tests in a dependency jar -->
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-assembly-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- This is need when running with Sun JDK which gets an unsupported operation exception creating an XMLStreamReader from a DOMSource
+ when Tuscany is writing a property value -->
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- Real otest/Tuscany problems -->
+ <exclude>**/ASM_10002_TestCase.java</exclude><!-- see TUSCANY-3503 -->
+
+ <exclude>**/ASM_12006_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_12007_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_5016_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_6004_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_6007_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_12008_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_6014_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_8014_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_6008_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_6034_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_8017_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_8018_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/ASM_10003_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+
+ <!-- actually is working but the err msgs come out in a different order so the msg text test fails -->
+ <exclude>**/ASM_13004_TestCase.java</exclude>
+
+
+ </excludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-assembly-contributions</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>zip</type>
+ <outputDirectory>${project.build.directory}/oasis-contributions</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-assembly-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ <excludes>commons-logging.properties,oasis-sca-tests.properties</excludes>
+ <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
new file mode 100644
index 0000000000..5aca4756bc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.otest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.node2.Node;
+import org.apache.tuscany.sca.node2.NodeFactory;
+
+import client.RuntimeBridge;
+import client.TestConfiguration;
+
+/**
+ * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x)
+ *
+ */
+public class TuscanyRuntimeBridge implements RuntimeBridge {
+
+ static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION";
+
+ protected NodeFactory launcher;
+ protected Node node;
+ protected Properties expectedErrorMessages;
+
+ TestConfiguration testConfiguration = null;
+
+ public TuscanyRuntimeBridge() {
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
+ }
+
+ public TestConfiguration getTestConfiguration() {
+ return testConfiguration;
+ }
+
+ public void setTestConfiguration(TestConfiguration testConfiguration) {
+ this.testConfiguration = testConfiguration;
+ }
+
+ public boolean startContribution(String contributionLocation, String[] contributionNames) throws Exception {
+ try {
+ // Tuscany specific code which starts the contribution(s) holding the test
+ Properties ps = new Properties();
+ ps.setProperty("defaultScheme", "vm");
+ ps.setProperty("org.apache.tuscany.sca.binding.ws.jaxws.ri.JAXWSBindingProviderFactory.defaultPort", "8080");
+ launcher = NodeFactory.newInstance(ps);
+ node = launcher.createNode("default");
+
+// Contribution[] contributions = new Contribution[contributionNames.length];
+ String[] contributionURIs = getContributionURIs(contributionLocation);
+// for (int i = 0; i < contributions.length; i++) {
+// contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
+// } // end for
+
+ for (int i=contributionURIs.length-1; i > -1; i--) {
+ node.installContribution(contributionNames[i], contributionURIs[i], null, null, false);
+ }
+
+ node.addToDomainLevelComposite(contributionNames[0], testConfiguration.getComposite());
+
+// node = NodeFactory.createNode(testConfiguration.getComposite(), contributionURIs);
+ // Start the node
+// node.start();
+
+ // For debugging
+ // print out the composites that have been read in success cases
+ // System.out.println(((NodeImpl)node).dumpDomainComposite());
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ throw e;
+ } // end try
+
+ return true;
+ } // end method startContribution
+
+ /**
+ * Gets the location of the Contributions as URIs
+ * @param contributionLocation - a location pattern URI, which contains one or more "%1"
+ * substrings, which are substituted with the name of the contribution to get the URI of
+ * the contribution
+ * @return the contribution locations as an array of Strings
+ */
+ protected String[] getContributionURIs(String contributionLocation) throws Exception {
+ String[] locations;
+ locations = testConfiguration.getContributionNames();
+
+ if (locations != null && contributionLocation != null) {
+
+ for (int i = 0; i < locations.length; i++) {
+ String aLocation = contributionLocation.replaceAll("%1", locations[i]);
+ // Looks like bugs in the oasis code that sometimes still uses jars for some
+ if (aLocation.endsWith("_Java-1.0.zip") && !aLocation.endsWith("ASM_8005_Java-1.0.zip")) {
+ aLocation = aLocation.substring(0, aLocation.length()-3) + "jar";
+ }
+ if (!(new File(aLocation)).exists()) {
+ aLocation = aLocation.replace(".zip", ".jar");
+ }
+ locations[i] = aLocation;
+ } // end for
+ } else {
+ if (locations == null) {
+ // No contribution specified - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution supplied - error");
+ } else {
+ // No contribution location supplied - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution location supplied - error");
+ } // end if
+ } // end if
+
+ return locations;
+ } // end getContributionURI
+
+ public void stopContribution() {
+ if (node != null) {
+ node.stop();
+ } // end if
+ if (launcher != null) {
+ launcher.stop();
+ } // end if
+ } // end method stopContribution
+
+ public void checkError(String testName, Throwable ex) throws Throwable {
+
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = ex.getMessage();
+ if (ex instanceof ValidationException && ex.getCause() == null) {
+ receivedMessage = "org.apache.tuscany.sca.monitor.ValidationException: " + receivedMessage;
+ }
+
+ if (expectedMessage == null){
+ writeMissingMessage(testName, ex);
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ } // end if
+
+ if (receivedMessage == null){
+ ex.printStackTrace();
+ fail("Null received error message for test " + testName);
+ } // end if
+
+ if (expectedMessage.startsWith("*")) {
+ // allow using * to ignore a message comparison
+ return;
+ }
+
+ // Deal with the case where the message has variable parts within it
+ // marked with the characters ***. Here we tokenize the epected string
+ // and make sure all the individual parts are present in the results string
+ String expectedMessageParts[] = expectedMessage.split("\\*\\*\\*");
+
+ if (expectedMessageParts.length > 1){
+ int foundParts = 0;
+ for(int i = 0; i < expectedMessageParts.length; i++){
+ if (receivedMessage.indexOf(expectedMessageParts[i]) > -1 ){
+ foundParts++;
+ }
+ }
+
+ if (foundParts == expectedMessageParts.length){
+ return;
+ }
+ }
+
+
+ // Deal with the case where the end of the message is variable (eg contains absolute filenames)
+ // and where the only relevant part is the start of the message - in this case the expected
+ // message only contains the stem section which is unchanging...
+ if( receivedMessage.length() > expectedMessage.length() ) {
+ // Truncate the received message to the length of the expected message
+ receivedMessage = receivedMessage.substring(0, expectedMessage.length() );
+ } // end if
+
+ if (!expectedMessage.equals(receivedMessage)) {
+ writeIncorrectMessage(testName, expectedMessage, receivedMessage);
+ }
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+
+ }
+
+ protected void writeMissingMessage(String testName, Throwable ex) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestMissingMsgs.txt", true));
+ out.write(testName + "=*");
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected void writeIncorrectMessage(String testName, String expected, String received) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestIncorrectMsgs.txt", true));
+ out.write(testName); out.newLine();
+ out.write(" " + expected); out.newLine();
+ out.write(" " + received); out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+} // end class TuscanyRuntimeBridge
diff --git a/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/resources/oasis-sca-tests.properties b/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/resources/oasis-sca-tests.properties
new file mode 100644
index 0000000000..0d8cc27a45
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/resources/oasis-sca-tests.properties
@@ -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.
+
+# OASIS SCA Assembly test properties
+# The implementation type to use for Assembly test suite
+# org.oasis.sca.tests.assembly.lang=BPEL
+org.oasis.sca.tests.assembly.lang=Java
+
+# The class to use as the Runtime Bridge for the SCA runtime under test
+#org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyOSGiRuntimeBridge
+org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyRuntimeBridge
+
+# The location of the contributions for the test suite
+# %1 represents the placement of the name of each contribution into the location URI
+org.oasis.sca.tests.assembly.contribution.location=target/oasis-contributions/%1.zip
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/resources/tuscany-oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..68d87f2902
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/assembly/src/test/resources/tuscany-oasis-sca-tests-errors.properties
@@ -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.
+
+ASM_4002=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM40003,ASM60003,JCA90045] Duplicate implementation service name: Component = TestComponent1 Service = Service1
+ASM_4003=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM40004,ASM50007,ASM60006] Duplicate implementation reference name: Component = TestComponent1 Reference = Reference1
+ASM_4004=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM40005,ASM60014] Duplicate implementation property name: Component = TestComponent1 Property = propertyName
+ASM_4007=org.apache.tuscany.sca.contribution.processor.ContributionReadException: [ASM40010,ASM60040] Error: property has both @type and @element attribute values - propertyName
+ASM_4008=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM40011,ASM60034] No value configured on a mustSupply property: Component = TestComponent1 Property = propertyName
+ASM_5004=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient] - [ASM50022] Too many targets on reference: reference1
+ASM_5005=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: Test_ASM_5005Component1] - [ASM40003,ASM60003,JCA90045] Duplicate implementation service name: Component = Test_ASM_5005Component1 Service = Service1
+ASM_5006=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - Component type service not found for component service (missing @Remotable annotation?): Component = TestComponent1 Service = InvalidName
+ASM_5007=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: Test_ASM_5007Component1] - [ASM40004,ASM50007,ASM60006] Duplicate implementation reference name: Component = Test_ASM_5007Component1 Reference = Reference1
+ASM_5008=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM50008] Component type reference not found for component reference: Component = TestComponent1 Reference = InvalidName
+ASM_5009=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}] - [ASM50001] Duplicate component name: Composite = {http://docs.oasis-open.org/ns/opencsa/sca/200912} Component = TestComponent1
+ASM_5010=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = TestComponent1 Service = Service1
+ASM_5014=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM50009] Component reference multiplicity incompatible with reference multiplicity: Component = TestComponent1 Reference = Reference1
+ASM_5023=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite11, Component: Composite11Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite4, Component: Composite4Component1] - [ASM50022] Too many targets on reference: reference1
+ASM_5024=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Reference: Reference1] - [ASM50026] Composite {http://docs.oasis-open.org/ns/opencsa/sca/200912} Component TestComponent1 Reference Reference1 must not specify endpoints using both target attribute and with a binding child element
+ASM_5027=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - Duplicate component property name: Component = TestComponent1 Property = serviceName
+ASM_5028=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM50031] Property not found for component property: Component = TestComponent1 Property = randomName
+ASM_5029=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM50032] The property component TestComponent1 property complexType has many values but its "many" attribute is set to false
+ASM_5030=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_5030, Artifact: Test_ASM_5030.composite] - ASM50033: value attribute exists for the property element
+ASM_5035=org.apache.tuscany.sca.contribution.processor.ContributionReadException: [ASM40010,ASM60040] Error: property has both @type and @element attribute values - complexType
+ASM_5036=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_5036Component1] - [ASM_5036] The property component TEST_ASM_5036Component1 property complexType has XSD type {http://docs.oasis-open.org/ns/opencsa/scatests/200903}ComplexType2 while its component type property has the XSD type {http://docs.oasis-open.org/ns/opencsa/scatests/200903}ComplexType1
+ASM_5037=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_5037Component1] - [ASM50031] Property not found for component property: Component = TEST_ASM_5037Component1 Property = bogusName
+ASM_5038=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_5038Component1] - [ASM50027] The property serviceData1 on component TEST_ASM_5038Component1 has a value which does not match the simple type {http://www.w3.org/2001/XMLSchema}float with which it is associated
+ASM_5039=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_5039Component1] - [ASM50038] The property complexType on component TEST_ASM_5039Component1 has a value which does not match the complex type {http://docs.oasis-open.org/ns/opencsa/scatests/200903}ComplexType1 with which it is associated. Validation reported cvc-complex-type.2.4.d: Invalid content was found starting with element 'test:thirdData'. No child element is expected at this point.
+ASM_5040=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_5040Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite74] - [ASM50042] Composite reference promotes component reference with 1..1 multiplicity and nonOverridable flag set true: Composite = TestComposite74.composite Composite reference = Reference1 Component reference = Reference1
+ASM_6001=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_6001, Artifact: TestDuplicate1.composite] - [ASM_6001] More than one composite with the same name {http://docs.oasis-open.org/ns/opencsa/scatests/200903}DuplicateComposite found in contribution
+ASM_6002=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM40003,ASM60003,JCA90045] Duplicate implementation service name: Component = TestComponent1 Service = Service1
+ASM_6003=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite17] - [ASM60004,ASM60032] Promoted component service not found: Composite = {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite17 Service = SpuriousComponent/SpuriousService
+ASM_6005=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM40004,ASM50007,ASM60006] Duplicate implementation reference name: Component = TestComponent1 Reference = Reference1
+ASM_6006=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite20] - [ASM60007] Promoted component reference not found: Composite = {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite20 Reference = Composite20Componentz/Reference1
+ASM_6008=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_6008Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite22] - [ASM60008,ASM60013] Interface of composite reference Reference1 must be compatible with the interface declared by promoted component reference. Operation operation2 not found on target
+ASM_6012=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_6012TestComponent1] - [ASM40005,ASM60014] Duplicate implementation property name: Component = TEST_ASM_6012TestComponent1 Property = propertyName
+ASM_6016=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite30, Component: TestComponent1, Reference: Reference1] - [ASM60028] No target services found for the component reference to be autowired: Reference1
+ASM_6020=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Reference: Reference1] - [ASM60028] No target services found for the component reference to be autowired: Reference1
+ASM_6021=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_6021TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite31] - [ASM60004,ASM60032] Promoted component service not found: Composite = {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite31 Service = Not_A_URI_of_a_Component
+ASM_6022=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite32, Component: TestComponent1] - [ASM60033] No targets for reference: Composite = {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite32 Reference = Reference1
+ASM_6023=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM40011,ASM60034] No value configured on a mustSupply property: Component = TestComponent1 Property = simpleType
+ASM_6024=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM60030,JCI50004,JCI80001] Component implementation not resolved: Component = TestComponent1 Uri = TestComponent1
+ASM_6025=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}] - [ASM50001] Duplicate component name: Composite = {http://docs.oasis-open.org/ns/opencsa/sca/200912} Component = TestComponent1
+ASM_6028=org.apache.tuscany.sca.contribution.processor.ContributionReadException: [ASM40010,ASM60040] Error: property has both @type and @element attribute values - InvalidProperty
+ASM_6029=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: [ASM60041] Error: Composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_ASM_6029 can only include another composite with the identical @local attribute value
+ASM_6030=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: [ASM60042] Error: Composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}Invalid_composite_name is not a valid composite within the domain
+ASM_6031=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite39] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200912}suspendsTransaction and {http://docs.oasis-open.org/ns/opencsa/sca/200912}propagatesTransaction are mutually exclusive
+ASM_6032=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite40] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200912}suspendsTransaction and {http://docs.oasis-open.org/ns/opencsa/sca/200912}propagatesTransaction are mutually exclusive
+ASM_6033=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite41] - [ASM60011] Composite reference multiplicity incompatible with component reference multiplicity: Composite = TestComposite41.composite Composite reference = Reference1 Component reference = Reference1
+ASM_6036=Test service got an exception during execution: org.oasisopen.sca.ServiceRuntimeException Unable to bind [] - No endpoints found in the domain that match the reference (@***)EndpointReference: URI = TestClient#reference(reference1) WIRED_TARGET_NOT_FOUND Target = (@***)Endpoint: URI = TEST_ASM_6036Component1#service(ServiceZ) [Unresolved]
+ASM_6039=Test service got an exception during execution: org.oasisopen.sca.ServiceRuntimeException Unable to bind [] - No endpoints found in the domain that match the reference (@***)EndpointReference: URI = TestClient#reference(reference1) WIRED_TARGET_NOT_FOUND Target = (@***)Endpoint: URI = TEST_ASM_6039Component1#service-binding(Service1/harry) [Unresolved]
+ASM_8001=org.apache.tuscany.sca.interfacedef.OverloadedOperationException: [JCA20001] Cannot overload operation operation1 on org.oasisopen.sca.test.Service3 as it is a @Remotable interface
+ASM_8004=org.apache.tuscany.sca.interfacedef.InvalidCallbackException: Callback org.oasisopen.sca.test.Service6Callback must be remotable on remotable interface org.oasisopen.sca.test.Service6
+ASM_8005=org.apache.tuscany.sca.interfacedef.InvalidCallbackException: Callbackorg.oasisopen.sca.test.Service7Callback must not be remotable on local interface org.oasisopen.sca.test.Service7
+ASM_8006=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_8006, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_ASM_8006] - The interface.wsdl element has a forward interface with a callback declared in the WSDL {http://test.sca.oasisopen.org/}Service9Callback and a callback interface also declared using the callbackInterface attribute {http://test.sca.oasisopen.org/}Service8Callback but the callback interfaces are not equal.
+ASM_8007=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent2] - [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = TestComponent2 Service = Service1
+ASM_8008=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [JCA30001,JCA30002,JCA30003,JCA90046] Component reference interface incompatible with implementation reference interface: Component = TestComponent1 Reference = Reference1
+ASM_8009=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_8009Component1] - [JCA30001,JCA30002,JCA30003,JCA90046] Component reference interface incompatible with implementation reference interface: Component = TEST_ASM_8009Component1 Reference = Reference1
+ASM_8010=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_8010Component2, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite63] - Interface of composite service Service1 must be subset of the interface declared by promoted component service. Callback operation not found on target
+ASM_8011=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite62] - [ASM60008,ASM60013] Interface of composite reference Reference1 must be compatible with the interface declared by promoted component reference. Callback operation not found on target
+ASM_8012=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_8012Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite64] - [ASM60008,ASM60013] Interface of composite reference Reference1 must be compatible with the interface declared by promoted component reference.
+ASM_8017=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_8017Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite72] - Interface of composite service Service1a must be subset of the interface declared by promoted component service. Callback interface doesn't match
+ASM_8018=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient] - [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = TestClient Service = TestInvocation
+ASM_8019=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_8019, Artifact: Test_ASM_8019.composite] - The interface.wsdl interface {http://test.sca.oasisopen.org/}Service1 element can only have a remotable attribute with the value "true" as WSDL interface are assumed to be remotable by default. The value that was found is: false.
+ASM_9002=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - Multiple bindings with the same name for a service: Service = Service1 Binding name = Fred
+ASM_9005=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_9005Component1] - [ASM90005] The SCA binding Service1 on component TEST_ASM_9005Component1 service Service1 should not have a URI and the URI is currently set to http://example/bar
+ASM_10001=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_10001, Artifact: META-INF/definitions.xml, Definitions: jar:file:***ASM_10001***.zip!/META-INF/definitions.xml] - [ASM10001,POL30002] Duplicate intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}Fred found in domain
+ASM_10003=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_10003, Artifact: META-INF/definitions.xml, Definitions: jar:file:***ASM_10003***.zip!/META-INF/definitions.xml] - XMLSchema validation error occured in: Test_ASM_10003.composite ,line = ***, column = ***, Message = cvc-complex-type.2.4.a: Invalid content was found starting with element 'component'. One of '{"http://docs.oasis-open.org/ns/opencsa/sca/200912":documentation, "http://docs.oasis-open.org/ns/opencsa/sca/200912":intent, "http://docs.oasis-open.org/ns/opencsa/sca/200912":policySet, "http://docs.oasis-open.org/ns/opencsa/sca/200912":bindingType, "http://docs.oasis-open.org/ns/opencsa/sca/200912":implementationType, "http://docs.oasis-open.org/ns/opencsa/sca/200912":externalAttachment, WC[##other:"http://docs.oasis-open.org/ns/opencsa/sca/200912"]}' is expected.
+ASM_12003=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Invalid interface when resolving
+ASM_12007=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/2009032}TestComposite5, Component: TestComposite5TestComponent1] - [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = TestComposite5TestComponent1 Service = Service1 Operations called operation2 are not compatible Operation argument types source = {http://www.w3.org/2001/XMLSchema}int target = {http://www.w3.org/2001/XMLSchema}string don't match for output types
+ASM_12008=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_ASM_12008TestComponent1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/2009032}TestComposite5, Component: TestComposite5TestComponent1] - [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = TestComposite5TestComponent1 Service = Service1 Operations called operation2 are not compatible Operation argument types source = {http://www.w3.org/2001/XMLSchema}int target = {http://www.w3.org/2001/XMLSchema}string don't match for output types
+ASM_12011=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestComponent1] - [ASM60030,JCI50004,JCI80001] Component implementation not resolved: Component = TestComponent1 Uri = TestComponent1
+ASM_12012=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_12012, Artifact: META-INF/sca-contribution.xml] - XMLSchema validation error occured in: jar:file:***ASM_12012***.zip!/META-INF/sca-contribution.xml ,line = ***, column = ***, Message = cvc-complex-type.2.4.a: Invalid content was found starting with element 'component'. One of '{"http://docs.oasis-open.org/ns/opencsa/sca/200912":documentation, "http://docs.oasis-open.org/ns/opencsa/sca/200912":deployable, "http://docs.oasis-open.org/ns/opencsa/sca/200912":importBase, "http://docs.oasis-open.org/ns/opencsa/sca/200912":exportBase, "http://docs.oasis-open.org/ns/opencsa/sca/200912":extensions}' is expected.
+ASM_13001=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_13001, Artifact: Test_ASM_13001.composite] - XMLSchema validation error occured in: Test_ASM_13001.composite ,line = ***, column = ***, Message = cvc-complex-type.2.4.a: Invalid content was found starting with element 'sevrice'. One of '{"http://docs.oasis-open.org/ns/opencsa/sca/200912":service, "http://docs.oasis-open.org/ns/opencsa/sca/200912":reference, "http://docs.oasis-open.org/ns/opencsa/sca/200912":property, "http://docs.oasis-open.org/ns/opencsa/sca/200912":requires, "http://docs.oasis-open.org/ns/opencsa/sca/200912":policySetAttachment, "http://docs.oasis-open.org/ns/opencsa/sca/200912":extensions}' is expected.
+ASM_13002=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_13002, Artifact: Test_ASM_13002.composite] - XMLSchema validation error occured in: Test_ASM_13002.composite ,line = ***, column = ***, Message = cvc-complex-type.2.4.a: Invalid content was found starting with element 'operation'. One of '{"http://docs.oasis-open.org/ns/opencsa/sca/200912":binding, "http://docs.oasis-open.org/ns/opencsa/sca/200912":callback, "http://docs.oasis-open.org/ns/opencsa/sca/200912":requires, "http://docs.oasis-open.org/ns/opencsa/sca/200912":policySetAttachment, "http://docs.oasis-open.org/ns/opencsa/sca/200912":extensions}' is expected.
+ASM_13003=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_13003, Artifact: Test_ASM_13003.composite] - XMLSchema validation error occured in: Test_ASM_13003.composite ,line = ***, column = ***, Message = cvc-complex-type.2.4.a: Invalid content was found starting with element 'binding.ws'. One of '{"http://docs.oasis-open.org/ns/opencsa/sca/200912":documentation, "http://docs.oasis-open.org/ns/opencsa/sca/200912":include, "http://docs.oasis-open.org/ns/opencsa/sca/200912":requires, "http://docs.oasis-open.org/ns/opencsa/sca/200912":policySetAttachment, "http://docs.oasis-open.org/ns/opencsa/sca/200912":service, "http://docs.oasis-open.org/ns/opencsa/sca/200912":property, "http://docs.oasis-open.org/ns/opencsa/sca/200912":component, "http://docs.oasis-open.org/ns/opencsa/sca/200912":reference, "http://docs.oasis-open.org/ns/opencsa/sca/200912":wire, WC[##other:"http://docs.oasis-open.org/ns/opencsa/sca/200912"]}' is expected.
+ASM_13004=org.apache.tuscany.sca.monitor.ValidationException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestClient_0002, Component: TestClient_0002TestClient] - [ASM40011,ASM60034] No value configured on a mustSupply property
+ASM_13005=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_13005, Artifact: Test_ASM_13005.composite] - XMLSchema validation error occured in: Test_ASM_13005.composite ,line = ***, column = ***, Message = cvc-elt.2: The value of {abstract} in the element declaration for 'implementation' must be false.
+ASM_13006=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_13006, Artifact: Test_ASM_13006.composite] - XMLSchema validation error occured in: Test_ASM_13006.composite ,line = ***, column = ***, Message = cvc-complex-type.3.2.2: Attribute 'callback' is not allowed to appear in element 'interface.java'.
+ASM_13007=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_13007, Artifact: Test_ASM_13007.composite] - XMLSchema validation error occured in: Test_ASM_13007.composite ,line = ***, column = ***, Message = cvc-complex-type.3.2.2: Attribute 'mulplicity' is not allowed to appear in element 'reference'.
+ASM_13008=org.apache.tuscany.sca.monitor.ValidationException: [Contribution: ASM_13008, Artifact: Test_ASM_13008.composite] - XMLSchema validation error occured in: Test_ASM_13008.composite ,line = ***, column = ***, Message = cvc-complex-type.2.4.a: Invalid content was found starting with element 'operation'. One of '{"http://docs.oasis-open.org/ns/opencsa/sca/200912":documentation, "http://docs.oasis-open.org/ns/opencsa/sca/200912":wireFormat, "http://docs.oasis-open.org/ns/opencsa/sca/200912":operationSelector, "http://docs.oasis-open.org/ns/opencsa/sca/200912":requires, "http://docs.oasis-open.org/ns/opencsa/sca/200912":policySetAttachment}' is expected.
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-jms/pom.xml b/sandbox/sebastien/java/embed/compliance-tests/binding-jms/pom.xml
new file mode 100644
index 0000000000..cf604a3d92
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-jms/pom.xml
@@ -0,0 +1,132 @@
+<?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-compliance-tests</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-compliance-test-binding-jms</artifactId>
+ <name>Apache Tuscany SCA Specification Compliance Tests Binding JMS</name>
+
+ <dependencies>
+
+ <dependency>
+ <!-- This is only needed to get the module working in Eclipse which doesn't pick it up from the dependency plugin unpack -->
+ <!-- The dependency plugin unpack is needed as presently the surefire plugin wont run tests in a dependency jar -->
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-binding-jms-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-jms</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ </dependency>
+
+ <!-- This is need when running with Sun JDK which gets an unsupported operation exception creating an XMLStreamReader from a DOMSource
+ when Tuscany is writing a property value -->
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- exclude>**/POJO_8011_TestCase.java</exclude -->
+ </excludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-binding-jms-contributions</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>zip</type>
+ <outputDirectory>${project.build.directory}/oasis-contributions</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-binding-jms-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ <excludes>commons-logging.properties,oasis-sca-tests.properties,tuscany-oasis-sca-tests-errors.properties</excludes>
+ <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
new file mode 100644
index 0000000000..d9490c641e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.otest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import testClient.TestException_Exception;
+import client.RuntimeBridge;
+
+/**
+ * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x)
+ *
+ */
+public class TuscanyRuntimeBridge implements RuntimeBridge {
+
+ static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION";
+
+ protected NodeFactory launcher;
+ protected Node node;
+ protected Properties expectedErrorMessages;
+
+ public TuscanyRuntimeBridge() {
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
+ }
+
+ public boolean startContribution(String compositeName, String contributionLocation, String[] contributionNames) throws Exception {
+ try {
+ // Tuscany specific code which starts the contribution(s) holding the test
+ Properties ps = new Properties();
+ ps.setProperty("defaultScheme", "vm");
+ ps.setProperty("org.apache.tuscany.sca.binding.ws.jaxws.ri.JAXWSBindingProviderFactory.defaultPort", "8080");
+ launcher = NodeFactory.newInstance(ps);
+
+ Contribution[] contributions = new Contribution[contributionNames.length];
+ String[] contributionURIs = getContributionURIs(contributionLocation, contributionNames);
+ for (int i = 0; i < contributions.length; i++) {
+ contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
+ } // end for
+
+ node = launcher.createNode(compositeName, contributions);
+ // Start the node
+ node.start();
+
+ // For debugging
+ // print out the composites that have been read in success cases
+ // System.out.println(((NodeImpl)node).dumpDomainComposite());
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ throw e;
+ } // end try
+
+ return true;
+ } // end method startContribution
+
+ /**
+ * Gets the location of the Contributions as URIs
+ * @param contributionLocation - a location pattern URI, which contains one or more "%1"
+ * substrings, which are substituted with the name of the contribution to get the URI of
+ * the contribution
+ * @return the contribution locations as an array of Strings
+ */
+ protected String[] getContributionURIs(String contributionLocation, String[] contributionNames) throws Exception {
+ String[] locations = new String[contributionNames.length];
+
+ if (locations != null && contributionLocation != null) {
+
+ for (int i = 0; i < locations.length; i++) {
+ String aLocation = contributionLocation.replaceAll("%1", contributionNames[i]);
+
+ locations[i] = aLocation;
+ } // end for
+ } else {
+ if (locations == null) {
+ // No contribution specified - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution supplied - error");
+ } else {
+ // No contribution location supplied - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution location supplied - error");
+ } // end if
+ } // end if
+
+ return locations;
+ } // end getContributionURI
+
+ public void stopContribution() {
+ if (node != null) {
+ node.stop();
+ } // end if
+ if (launcher != null) {
+ launcher.destroy();
+ } // end if
+ } // end method stopContribution
+
+ public void checkError(String testName, Throwable ex) throws Throwable {
+
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = getErrorMessage(ex);//ex.getMessage();
+
+ if (expectedMessage == null){
+ writeMissingMessage(testName, ex);
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ } // end if
+
+ if (receivedMessage == null){
+ ex.printStackTrace();
+ fail("Null received error message for test " + testName);
+ } // end if
+
+ if (expectedMessage.startsWith("*")) {
+ // allow using * to ignore a message comparison
+ return;
+ }
+
+ // Deal with the case where the message has variable parts within it
+ // marked with the characters ***. Here we tokenize the expected string
+ // and make sure all the individual parts are present in the results string
+ String expectedMessageParts[] = expectedMessage.split("\\*\\*\\*");
+
+ if (expectedMessageParts.length > 1){
+ int foundParts = 0;
+ for(int i = 0; i < expectedMessageParts.length; i++){
+ if (receivedMessage.indexOf(expectedMessageParts[i]) > -1 ){
+ foundParts++;
+ }
+ }
+
+ if (foundParts == expectedMessageParts.length){
+ return;
+ }
+ }
+
+
+ // Deal with the case where the end of the message is variable (eg contains absolute filenames)
+ // and where the only relevant part is the start of the message - in this case the expected
+ // message only contains the stem section which is unchanging...
+ if( receivedMessage.length() > expectedMessage.length() ) {
+ // Truncate the received message to the length of the expected message
+ receivedMessage = receivedMessage.substring(0, expectedMessage.length() );
+ } // end if
+
+ if (!expectedMessage.equals(receivedMessage)) {
+ writeIncorrectMessage(testName, expectedMessage, receivedMessage);
+ }
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+
+ }
+
+ protected void writeMissingMessage(String testName, Throwable ex) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestMissingMsgs.txt", true));
+ out.write(testName + "=*");
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected void writeIncorrectMessage(String testName, String expected, String received) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestIncorrectMsgs.txt", true));
+ out.write(testName); out.newLine();
+ out.write(" " + expected); out.newLine();
+ out.write(" " + received); out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected String getErrorMessage(Throwable ex) {
+ String errorMessage = null;
+
+ if (ex instanceof TestException_Exception) {
+ TestException_Exception te = (TestException_Exception) ex;
+ errorMessage = te.getFaultInfo().getMessage();
+ } else {
+ errorMessage = ex.getMessage();
+ }
+
+ return errorMessage;
+ }
+} // end class TuscanyRuntimeBridge
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/resources/oasis-sca-tests.properties b/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/resources/oasis-sca-tests.properties
new file mode 100644
index 0000000000..33192c49e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/resources/oasis-sca-tests.properties
@@ -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.
+
+# OASIS SCA Assembly test properties
+# The implementation type to use for Assembly test suite
+# org.oasis.sca.tests.assembly.lang=BPEL
+org.oasis.sca.tests.assembly.lang=Java
+
+# The class to use as the Runtime Bridge for the SCA runtime under test
+#org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyOSGiRuntimeBridge
+org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyRuntimeBridge
+
+# The location of the contributions for the test suite
+# %1 represents the placement of the name of each contribution into the location URI
+org.oasis.sca.tests.assembly.contribution.location=target/oasis-contributions/%1.zip
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/resources/tuscany-oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..1788c1f2b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-jms/src/test/resources/tuscany-oasis-sca-tests-errors.properties
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+BJM_3001=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BJM_3001, Artifact: Test_BJM_3001.composite] - URI must start with the scheme jms: for uri: http://test.sca.oasisopen.org/
+BJM_3002=Test service got an exception during execution: org.apache.tuscany.sca.binding.jms.JMSBindingException JMS Destination jndi:BJM_3002_Queue not found with create mode of "ifnotexist" while registering binding Reference1 invoker
+BJM_3003=No error expected
+BJM_3004=No error expected
+BJM_3005=No error expected
+BJM_3010=**testcase incomplete**
+BJM_3011=org.apache.tuscany.sca.binding.jms.JMSBindingException: Error starting JMSServiceBinding
+BJM_3012=**testcase incomplete**
+BJM_3013=org.apache.tuscany.sca.binding.jms.JMSBindingException: Error starting JMSServiceBinding
+BJM_3014=**testcase incomplete**
+BJM_3015=**testcase incomplete**
+BJM_3017=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BJM_3017, Artifact: Test_BJM_3017.composite] - XMLSchema validation error occured in: Test_BJM_3017.composite ,line = 36, column = 17, Message = cvc-complex-type.2.4.a: Invalid content was found starting with element 'activationSpec'. One of '{"http://docs.oasis-open.org/ns/opencsa/sca/200912":response, "http://docs.oasis-open.org/ns/opencsa/sca/200912":headers, "http://docs.oasis-open.org/ns/opencsa/sca/200912":messageSelection, "http://docs.oasis-open.org/ns/opencsa/sca/200912":resourceAdapter, "http://docs.oasis-open.org/ns/opencsa/sca/200912":operationProperties}' is expected.
+BJM_3018=**testcase incomplete**
+BJM_3019=**testcase incomplete**
+BJM_3020=**testcase incomplete**
+BJM_3021=**testcase incomplete**
+BJM_3022=**testcase incomplete**
+BJM_3023=**testcase incomplete**
+BJM_3024=**testcase incomplete**
+BJM_3025=**testcase incomplete**
+BJM_3026=**testcase incomplete**
+BJM_3029=**testcase incomplete**
+BJM_3034=**testcase incomplete**
+BJM_3037=**testcase incomplete**
+BJM_4011=*
+
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-ws/pom.xml b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/pom.xml
new file mode 100644
index 0000000000..a85570c720
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/pom.xml
@@ -0,0 +1,119 @@
+<?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-compliance-tests</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-compliance-test-binding-ws</artifactId>
+ <name>Apache Tuscany SCA Specification Compliance Tests Binding WS</name>
+
+ <dependencies>
+
+ <dependency>
+ <!-- This is only needed to get the module working in Eclipse which doesn't pick it up from the dependency plugin unpack -->
+ <!-- The dependency plugin unpack is needed as presently the surefire plugin wont run tests in a dependency jar -->
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-binding-ws-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- This is need when running with Sun JDK which gets an unsupported operation exception creating an XMLStreamReader from a DOMSource
+ when Tuscany is writing a property value -->
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-binding-ws-contributions</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>zip</type>
+ <outputDirectory>${project.build.directory}/oasis-contributions</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-binding-ws-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ <excludes>commons-logging.properties,oasis-sca-tests.properties</excludes>
+ <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-ws/sca_variables.dtd b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/sca_variables.dtd
new file mode 100644
index 0000000000..f29713a20d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/sca_variables.dtd
@@ -0,0 +1,28 @@
+<!--
+ *
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ *
+-->
+<!--
+ * This DTD forms part of the SCA Web Service Binding Test Suite.
+ * It declares a number of XML Entities which are used in Entity References in some of the
+ * composites that are artifacts used in the testcases.
+ *
+ * The values declared in the Entity References are intended to reflect SCA runtime specific
+ * values for certain aspects of the composites at runtime - in particular addresses of some
+ * services.
+ *
+ * It is permitted - indeed it is expected - that an SCA runtime provider will MODIFY the values
+ * declared for the Entity References to match the values which would be expected when running the
+ * SCA Web Service Binding test suite against a given SCA runtime. The values held in the this file are
+ * examples, derived from running the test suite against the Apache Tuscany SCA runtime.
+-->
+<!-- Address of the Web service provided by component "BWS_2004Component2" in Test_BWS_2004 composite -->
+<!ENTITY ws_addr_2004 "http://localhost:8080/TEST_BWS_2004Component2/Service1">
+<!-- Address of the Web service provided by component "BWS_2006Component2" in Test_BWS_2006 composite -->
+<!ENTITY ws_addr_2006_A "http://localhost:8080/TEST_BWS_2006Component2/Service1">
+<!-- Address of the Web service provided by component "BWS_2006Component3" in Test_BWS_2006 composite -->
+<!ENTITY ws_addr_2006_B "http://localhost:8080/TEST_BWS_2006Component3/Service1">
+<!-- Address of the Web service provided by the client for a range of BWS testcases -->
+<!ENTITY ws_addr_client_1 "http://localhost:9081/JAXWS/Service1"> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
new file mode 100644
index 0000000000..6f4aa8e86a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.otest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import client.RuntimeBridge;
+import client.TestConfiguration;
+
+/**
+ * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x)
+ *
+ */
+public class TuscanyRuntimeBridge implements RuntimeBridge {
+
+ static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION";
+
+ protected NodeFactory launcher;
+ protected Node node;
+ protected Properties expectedErrorMessages;
+
+ TestConfiguration testConfiguration = null;
+
+ public TuscanyRuntimeBridge() {
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
+ }
+
+ public TestConfiguration getTestConfiguration() {
+ return testConfiguration;
+ }
+
+ public void setTestConfiguration(TestConfiguration testConfiguration) {
+ this.testConfiguration = testConfiguration;
+ }
+
+ public boolean startContribution(String compositeName,
+ String contributionLocation, String[] contributionNames)
+ throws Exception {
+ //TODO:
+ return startContribution(contributionLocation, contributionNames);
+ }
+
+ public boolean startContribution(String contributionLocation, String[] contributionNames) throws Exception {
+ try {
+ // Tuscany specific code which starts the contribution(s) holding the test
+ Properties ps = new Properties();
+ ps.setProperty("defaultScheme", "vm");
+ ps.setProperty("org.apache.tuscany.sca.binding.ws.jaxws.ri.JAXWSBindingProviderFactory.defaultPort", "8080");
+ launcher = NodeFactory.newInstance(ps);
+
+ Contribution[] contributions = new Contribution[contributionNames.length];
+ String[] contributionURIs = getContributionURIs(contributionLocation);
+ for (int i = 0; i < contributions.length; i++) {
+ contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
+ } // end for
+
+ node = launcher.createNode(testConfiguration.getComposite(), contributions);
+ // Start the node
+ node.start();
+
+ // For debugging
+ // print out the composites that have been read in success cases
+ // System.out.println(((NodeImpl)node).dumpDomainComposite());
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ throw e;
+ } // end try
+
+ return true;
+ } // end method startContribution
+
+ /**
+ * Gets the location of the Contributions as URIs
+ * @param contributionLocation - a location pattern URI, which contains one or more "%1"
+ * substrings, which are substituted with the name of the contribution to get the URI of
+ * the contribution
+ * @return the contribution locations as an array of Strings
+ */
+ protected String[] getContributionURIs(String contributionLocation) throws Exception {
+ String[] locations;
+ locations = testConfiguration.getContributionNames();
+
+ if (locations != null && contributionLocation != null) {
+
+ for (int i = 0; i < locations.length; i++) {
+ String aLocation = contributionLocation.replaceAll("%1", locations[i]);
+ // Looks like bugs in the oasis code that sometimes still uses jars for some
+ if (aLocation.endsWith("_POJO.zip") && !aLocation.endsWith("ASM_8005_Java-1.0.zip")) {
+ aLocation = aLocation.substring(0, aLocation.length()-3) + "jar";
+ }
+ if (!(new File(aLocation)).exists()) {
+ aLocation = aLocation.replace(".zip", ".jar");
+ }
+ locations[i] = aLocation;
+ } // end for
+ } else {
+ if (locations == null) {
+ // No contribution specified - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution supplied - error");
+ } else {
+ // No contribution location supplied - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution location supplied - error");
+ } // end if
+ } // end if
+
+ return locations;
+ } // end getContributionURI
+
+ public void stopContribution() {
+ if (node != null) {
+ node.stop();
+ } // end if
+ if (launcher != null) {
+ launcher.destroy();
+ } // end if
+ } // end method stopContribution
+
+ public String getContributionLocation(Class<?> testClass) {
+ return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
+ } // end method getContributionLocation
+
+ public void checkError(String testName, Throwable ex) throws Throwable {
+
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = ex.getMessage();
+
+ if (expectedMessage == null){
+ writeMissingMessage(testName, ex);
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ } // end if
+
+ if (receivedMessage == null){
+ ex.printStackTrace();
+ fail("Null received error message for test " + testName);
+ } // end if
+
+ if (expectedMessage.startsWith("*")) {
+ // allow using * to ignore a message comparison
+ return;
+ }
+
+ // Deal with the case where the message has variable parts within it
+ // marked with the characters ***. Here we tokenize the epected string
+ // and make sure all the individual parts are present in the results string
+ String expectedMessageParts[] = expectedMessage.split("\\*\\*\\*");
+
+ if (expectedMessageParts.length > 1){
+ int foundParts = 0;
+ for(int i = 0; i < expectedMessageParts.length; i++){
+ if (receivedMessage.indexOf(expectedMessageParts[i]) > -1 ){
+ foundParts++;
+ }
+ }
+
+ if (foundParts == expectedMessageParts.length){
+ return;
+ }
+ }
+
+
+ // Deal with the case where the end of the message is variable (eg contains absolute filenames)
+ // and where the only relevant part is the start of the message - in this case the expected
+ // message only contains the stem section which is unchanging...
+ if( receivedMessage.length() > expectedMessage.length() ) {
+ // Truncate the received message to the length of the expected message
+ receivedMessage = receivedMessage.substring(0, expectedMessage.length() );
+ } // end if
+
+ if (!expectedMessage.equals(receivedMessage)) {
+ writeIncorrectMessage(testName, expectedMessage, receivedMessage);
+ }
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+
+ }
+
+ protected void writeMissingMessage(String testName, Throwable ex) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestMissingMsgs.txt", true));
+ out.write(testName + "=*");
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected void writeIncorrectMessage(String testName, String expected, String received) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestIncorrectMsgs.txt", true));
+ out.write(testName); out.newLine();
+ out.write(" " + expected); out.newLine();
+ out.write(" " + received); out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+} // end class TuscanyRuntimeBridge
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/resources/oasis-sca-tests.properties b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/resources/oasis-sca-tests.properties
new file mode 100644
index 0000000000..33192c49e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/resources/oasis-sca-tests.properties
@@ -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.
+
+# OASIS SCA Assembly test properties
+# The implementation type to use for Assembly test suite
+# org.oasis.sca.tests.assembly.lang=BPEL
+org.oasis.sca.tests.assembly.lang=Java
+
+# The class to use as the Runtime Bridge for the SCA runtime under test
+#org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyOSGiRuntimeBridge
+org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyRuntimeBridge
+
+# The location of the contributions for the test suite
+# %1 represents the placement of the name of each contribution into the location URI
+org.oasis.sca.tests.assembly.contribution.location=target/oasis-contributions/%1.zip
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/resources/tuscany-oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..292486c446
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/binding-ws/src/test/resources/tuscany-oasis-sca-tests-errors.properties
@@ -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.
+BWS_2001=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2001, Artifact: Test_BWS_2001.composite] - [BWS20001] The URI value for binding.ws on an SCA reference must be absolute. Non-absolute value found /TEST_BWS_2001Component2/Service1
+BWS_2002=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2002, Artifact: Test_BWS_2002.composite] - Invalid WebService binding wsdlElement attribute: http://test.sca.oasisopen.org/#wsdl.port(NonExistentPortName)
+BWS_2003=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2003, Artifact: Test_BWS_2003.composite] - [BWS20003] The wsdlElement attribute of a binding.ws on an SCA service must not specify the wsdl.service form of URI. The following URI was found http://test.sca.oasisopen.org/#wsdl.service(Service1Service)
+BWS_2005=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2005, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_BWS_2005] - [BWS20005][BWS20010] The WSDL binding transport http://example.com/foo/bar is not supported by Tuscany
+BWS_2007=org.apache.tuscany.sca.runtime.ActivationException: org.apache.tuscany.sca.runtime.ActivationException: org.oasisopen.sca.ServiceRuntimeException: Component TEST_BWS_2007Component2 Service Service1 interface is incompatible with the interface of the reference binding - Service1 - Operations called operation1 are not compatible Operation argument types source = {http://www.w3.org/2001/XMLSchema}float target = {http://www.w3.org/2001/XMLSchema}string don't match for output types||| - [(***)Endpoint: URI = TEST_BWS_2007Component2#service-binding(Service1/Service1)]
+BWS_2011=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2011, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_BWS_2011] - [BWS20005][BWS20010] The WSDL binding transport http://example.com/foo/bar is not supported by Tuscany
+BWS_2013=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2013, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_BWS_2013] - [BWS20005][BWS20010] The WSDL binding transport http://example.com/foo/bar is not supported by Tuscany
+BWS_2015=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2015, Artifact: Test_BWS_2015.composite] - [BWS20017] binding.ws has a @wsdli:wsdlLocation attribute but no @wsdlElement attribute
+BWS_2016=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2016, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_BWS_2016] - Exception locating wsdli:location resource: org.apache.tuscany.sca.contribution.processor.ContributionReadException: java.io.FileNotFoundException: http://example.org/Service1.wsdl
+BWS_2017=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2017, Artifact: Test_BWS_2017.composite] - [BWS20019] with binding.ws you can only specify one of url, wsa:EndpointReference, #wsdl.service or #wsdl.port. The following were found [uri, wsa:EndpointReference]
+BWS_2018=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2018, Artifact: Test_BWS_2018.composite] - [BWS20020] For the callback element of an SCA service, the binding must not specify an endpoint address URI or a WS-Addressing wsa:EndpointReference
+BWS_2019=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2019, Artifact: Test_BWS_2019.composite] - XMLSchema validation error occured in: Test_BWS_2019.composite ,line = 36, column = 10, Message = cvc-complex-type.3.2.2: Attribute 'invalidAttribute' is not allowed to appear in element 'binding.ws'.
+BWS_2020=org.oasisopen.sca.ServiceRuntimeException [BWS20025] Unable to determine destination endpoint for endpoint reference (***)EndpointReference: URI = TEST_BWS_2020Component1#reference-binding(reference1/Reference1) RESOLVED_BINDING Target = (***)Endpoint:
+BWS_2022=org.apache.tuscany.sca.runtime.ActivationException: org.apache.tuscany.sca.runtime.ActivationException: org.apache.tuscany.sca.runtime.ActivationException: org.apache.tuscany.sca.runtime.ActivationException: org.oasisopen.sca.ServiceRuntimeException: Component TEST_BWS_2022Component1 Reference reference1 interface is incompatible with the interface of the reference binding Reference1 - Callback interface doesn't match as one of the callback interfaces is null - [(***)EndpointReference: URI = TEST_BWS_2022Component1#reference-binding(reference1/Reference1) RESOLVED_BINDING Target = (***)Endpoint: ]
+BWS_4008=org.apache.tuscany.sca.runtime.ActivationException: org.apache.tuscany.sca.runtime.ActivationException: org.apache.tuscany.sca.runtime.ActivationException: org.apache.tuscany.sca.runtime.ActivationException: org.oasisopen.sca.ServiceRuntimeException: rpc/encoded WSDL style not supported. Component TEST_BWS_4008Component1 Reference reference1 Binding Reference1
+BWS_5003=A header representing a Message Addressing Property is not valid and the message cannot be processed
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/java-caa/pom.xml b/sandbox/sebastien/java/embed/compliance-tests/java-caa/pom.xml
new file mode 100644
index 0000000000..46606dea22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/java-caa/pom.xml
@@ -0,0 +1,127 @@
+<?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-compliance-tests</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-compliance-test-java-caa</artifactId>
+ <name>Apache Tuscany SCA Specification Compliance Tests Java CAA</name>
+
+ <dependencies>
+
+ <dependency>
+ <!-- This is only needed to get the module working in Eclipse which doesn't pick it up from the dependency plugin unpack -->
+ <!-- The dependency plugin unpack is needed as presently the surefire plugin wont run tests in a dependency jar -->
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-javacaa-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- This is need when running with Sun JDK which gets an unsupported operation exception creating an XMLStreamReader from a DOMSource
+ when Tuscany is writing a property value -->
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/JCA_11008_TestCase.java</exclude><!-- could be due to out of date compliance artifacts -->
+ <exclude>**/JCA_10013_TestCase.java</exclude>
+ <exclude>**/JCA_8001_TestCase.java</exclude>
+ <exclude>**/JCA_8006_TestCase.java</exclude>
+ <exclude>**/JCA_8007_TestCase.java</exclude>
+ <exclude>**/JCA_8011_TestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-javacaa-contributions</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>zip</type>
+ <outputDirectory>${project.build.directory}/oasis-contributions</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-javacaa-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ <excludes>commons-logging.properties,oasis-sca-tests.properties,tuscany-oasis-sca-tests-errors.properties</excludes>
+ <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
new file mode 100644
index 0000000000..136e5668c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.otest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import client.RuntimeBridge;
+import client.TestConfiguration;
+
+/**
+ * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x)
+ *
+ */
+public class TuscanyRuntimeBridge implements RuntimeBridge {
+
+ static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION";
+
+ protected NodeFactory launcher;
+ protected Node node;
+ protected Properties expectedErrorMessages;
+
+ TestConfiguration testConfiguration = null;
+
+ public TuscanyRuntimeBridge() {
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
+ }
+
+ public TestConfiguration getTestConfiguration() {
+ return testConfiguration;
+ }
+
+ public void setTestConfiguration(TestConfiguration testConfiguration) {
+ this.testConfiguration = testConfiguration;
+ }
+
+ public boolean startContribution(String compositeName,
+ String contributionLocation, String[] contributionNames)
+ throws Exception {
+ //TODO:
+ return startContribution(contributionLocation, contributionNames);
+ }
+
+ public boolean startContribution(String contributionLocation, String[] contributionNames) throws Exception {
+ try {
+ // Tuscany specific code which starts the contribution(s) holding the test
+ Properties ps = new Properties();
+ ps.setProperty("defaultScheme", "vm");
+ ps.setProperty("org.apache.tuscany.sca.binding.ws.jaxws.ri.JAXWSBindingProviderFactory.defaultPort", "8080");
+ launcher = NodeFactory.newInstance(ps);
+
+ Contribution[] contributions = new Contribution[contributionNames.length];
+ String[] contributionURIs = getContributionURIs(contributionLocation);
+ for (int i = 0; i < contributions.length; i++) {
+ contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
+ } // end for
+
+ node = launcher.createNode(testConfiguration.getComposite(), contributions);
+ // Start the node
+ node.start();
+
+ // For debugging
+ // print out the composites that have been read in success cases
+ // System.out.println(((NodeImpl)node).dumpDomainComposite());
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ throw e;
+ } // end try
+
+ return true;
+ } // end method startContribution
+
+ /**
+ * Gets the location of the Contributions as URIs
+ * @param contributionLocation - a location pattern URI, which contains one or more "%1"
+ * substrings, which are substituted with the name of the contribution to get the URI of
+ * the contribution
+ * @return the contribution locations as an array of Strings
+ */
+ protected String[] getContributionURIs(String contributionLocation) throws Exception {
+ String[] locations;
+ locations = testConfiguration.getContributionNames();
+
+ if (locations != null && contributionLocation != null) {
+
+ for (int i = 0; i < locations.length; i++) {
+ String aLocation = contributionLocation.replaceAll("%1", locations[i]);
+ // Looks like bugs in the oasis code that sometimes still uses jars for some
+ if (aLocation.endsWith("_POJO.zip") && !aLocation.endsWith("ASM_8005_Java-1.0.zip")) {
+ aLocation = aLocation.substring(0, aLocation.length()-3) + "jar";
+ }
+ if (!(new File(aLocation)).exists()) {
+ aLocation = aLocation.replace(".zip", ".jar");
+ }
+ locations[i] = aLocation;
+ } // end for
+ } else {
+ if (locations == null) {
+ // No contribution specified - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution supplied - error");
+ } else {
+ // No contribution location supplied - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution location supplied - error");
+ } // end if
+ } // end if
+
+ return locations;
+ } // end getContributionURI
+
+ public void stopContribution() {
+ if (node != null) {
+ node.stop();
+ } // end if
+ if (launcher != null) {
+ launcher.destroy();
+ } // end if
+ } // end method stopContribution
+
+ public String getContributionLocation(Class<?> testClass) {
+ return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
+ } // end method getContributionLocation
+
+ public void checkError(String testName, Throwable ex) throws Throwable {
+
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = ex.getMessage();
+
+ if (expectedMessage == null){
+ writeMissingMessage(testName, ex);
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ } // end if
+
+ if (receivedMessage == null){
+ ex.printStackTrace();
+ fail("Null received error message for test " + testName);
+ } // end if
+
+ if (expectedMessage.startsWith("*")) {
+ // allow using * to ignore a message comparison
+ return;
+ }
+
+ // Deal with the case where the message has variable parts within it
+ // marked with the characters ***. Here we tokenize the epected string
+ // and make sure all the individual parts are present in the results string
+ String expectedMessageParts[] = expectedMessage.split("\\*\\*\\*");
+
+ if (expectedMessageParts.length > 1){
+ int foundParts = 0;
+ for(int i = 0; i < expectedMessageParts.length; i++){
+ if (receivedMessage.indexOf(expectedMessageParts[i]) > -1 ){
+ foundParts++;
+ }
+ }
+
+ if (foundParts == expectedMessageParts.length){
+ return;
+ }
+ }
+
+
+ // Deal with the case where the end of the message is variable (eg contains absolute filenames)
+ // and where the only relevant part is the start of the message - in this case the expected
+ // message only contains the stem section which is unchanging...
+ if( receivedMessage.length() > expectedMessage.length() ) {
+ // Truncate the received message to the length of the expected message
+ receivedMessage = receivedMessage.substring(0, expectedMessage.length() );
+ } // end if
+
+ if (!expectedMessage.equals(receivedMessage)) {
+ writeIncorrectMessage(testName, expectedMessage, receivedMessage);
+ }
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+
+ }
+
+ protected void writeMissingMessage(String testName, Throwable ex) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestMissingMsgs.txt", true));
+ out.write(testName + "=*");
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected void writeIncorrectMessage(String testName, String expected, String received) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestIncorrectMsgs.txt", true));
+ out.write(testName); out.newLine();
+ out.write(" " + expected); out.newLine();
+ out.write(" " + received); out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+} // end class TuscanyRuntimeBridge
diff --git a/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/resources/oasis-sca-tests.properties b/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/resources/oasis-sca-tests.properties
new file mode 100644
index 0000000000..38e1e013dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/resources/oasis-sca-tests.properties
@@ -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.
+
+# OASIS SCA Assembly test properties
+# The implementation type to use for Assembly test suite
+# org.oasis.sca.tests.assembly.lang=BPEL
+org.oasis.sca.tests.assembly.lang=POJO
+
+# The class to use as the Runtime Bridge for the SCA runtime under test
+#org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyOSGiRuntimeBridge
+org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyRuntimeBridge
+
+# The location of the contributions for the test suite
+# %1 represents the placement of the name of each contribution into the location URI
+org.oasis.sca.tests.assembly.contribution.location=target/oasis-contributions/%1.zip
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/resources/tuscany-oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..2e0017225b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/java-caa/src/test/resources/tuscany-oasis-sca-tests-errors.properties
@@ -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.
+JCA_2001=org.apache.tuscany.sca.interfacedef.OverloadedOperationException: [JCA20001] Cannot overload operation operation1 on org.oasisopen.sca.test.Service1Overload as it is a @Remotable interface
+JCA_3001=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_3001, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_3001] - Class Not Found Exception: Service1
+JCA_3002=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_3002, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_3002] - Class Not Found Exception: Service1
+JCA_3003=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_3003, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_3003] - Class Not Found Exception: Service3Callback
+JCA_3004=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_3004, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_3004] - Class Not Found Exception: Service3Callback
+JCA_3006=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_JCA_3006Component2] - [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = TEST_JCA_3006Component2 Service = Service3WithCallback Callback operation not found on target
+JCA_3007=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_JCA_3007Component1] - [JCA30001,JCA30002,JCA30003,JCA90046] Component reference interface incompatible with implementation reference interface: Component = TEST_JCA_3007Component1 Reference = reference1
+JCA_3008=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_3008, Artifact: Test_JCA_3008.composite] - XMLSchema validation error occured in: Test_JCA_3008.composite ,line = ***, column = ***, Message = cvc-complex-type.3.2.2: Attribute 'oops' is not allowed to appear in element 'interface.java'.
+JCA_3009=org.apache.tuscany.sca.interfacedef.InvalidAnnotationException: [JCA30005] @Remotable annotation present in a interface marked as not remotable in the SCDL
+JCA_3011=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_3011, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_3011] - [JCA30006] Forbidden annotation interface org.oasisopen.sca.annotation.Property found on service interface in class org.oasisopen.sca.test.JCA3011Service
+JCA_3012=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_3012, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_3012] - [JCA30007] Forbidden annotation interface org.oasisopen.sca.annotation.Property found on callback interface in class org.oasisopen.sca.test.JCA3012Service3Callback
+JCA_10001=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.IllegalPropertyException: [JCA90001] Argument 1 of method operation1 in class class org.oasisopen.sca.test.service1BadAnnotation can not be a Property
+JCA_10002=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_10002, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_10002] - [JCA9002] SCA annotations are not permitted on static members: org.oasisopen.sca.test.service1Sta
+JCA_10003=org.oasisopen.sca.ServiceRuntimeException: [Contribution: JCA_10003, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_10003] - [JCA9002] SCA annotations are not permitted on static members: org.oasisopen.sca.test.service1Sta
+JCA_10004=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.IllegalCallbackReferenceException: [JCA90046] @Callback on field of method must not have any parameters
+JCA_10006=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.InvalidConstructorException: JCA90003 constructor parameters for class *** must have @Property or @Reference annotation
+JCA_10007=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.IllegalDestructorException: [JCA90004] Destructor must not have arguments
+JCA_10008=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.IllegalInitException: [JCA90008] Initializer must not have argments
+JCA_10009=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.IllegalPropertyException: [JCA90011] Final field serviceName in class org.oasisopen.sca.test.service1BadPropImpl can not be annotated as a Property
+JCA_10010=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.InvalidPropertyException: [JCA90013] Missing property name: public org.oasisopen.sca.test.service1ConstrBadPropImpl(java.lang.String)[0]
+JCA_10011=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.InvalidPropertyException: [JCA90014] Constructor property must not have required=false: org.oasisopen.sca.test.service1ConstrBadPropImpl
+JCA_10014=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.InvalidReferenceException: [JCA90018] @Reference in a Constructor must have a name attributeorg.oasisopen.sca.test.service1ConstrBad
+JCA_10015=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.InvalidReference
+JCA_10046=org.oasisopen.sca.ServiceRuntimeException: [] - [JCA90040] Exception while generating WSDL for TEST_JCA_10046Component1/Unmappable exception was:
+JCA_10047=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.IntrospectionException: [JCA90041] @Scope annotation not allowed on service interface
+JCA_10048=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.IntrospectionException: [JCA90042,JCI20002] Implementation missing service method operation2 service interface org.oasisopen.sca.test.Service1Superset
+JCA_10049=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.IntrospectionException: [JCA90050] The number of Strings in the names attribute array of the @Service annotation MUST match the number of elements in the value attribute array
+JCA_10050=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_JCA_10050Component1] - [ASM40003,ASM60003,JCA90045] Duplicate implementation service name: Component = TEST_JCA_10050Component1 Service = Service1
+JCA_10051=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.IntrospectionException: [JCA90059] The array of interfaces or classes specified by the value attribute of the @Service annotation
+JCA_10052=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.IntrospectionException: [JCA90060] The value of each element in the @Service names array MUST be unique amongst all the other element values in the array
+JCA_11005=org.oasisopen.sca.ServiceRuntimeException: [Component: TEST_JCA_11005Component1, Service: Service1] - [JCA100006] JAX-WS client-side asynchronous polling and callback methods are not allowed in service interfaces
+# Intent and PolicySet related tests
+JCA_8001=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_JCA_8001Component1, Service: Service1] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testIntent2 and {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testIntent1 are mutually exclusive
+JCA_8002=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Processing composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_8002: Resolving Java implementation: org.oasisopen.sca.test.service1BadIntent, [JCA70002,JCA70005] Method that is not an SCA reference cannot have policySet/intent annotations: public java.lang.String org.oasisopen.sca.test.service1BadIntent.operation1(java.lang.String)
+JCA_8003=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Processing composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_8003: Resolving Java implementation: org.oasisopen.sca.test.service1BadIntent, [JCA70002,JCA70005] Field that is not an SCA reference cannot have policySet/intent annotations: public java.lang.String org.oasisopen.sca.test.service1BadIntent.someField
+JCA_8004=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Processing composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_8004: Resolving Java implementation: org.oasisopen.sca.test.service1BadIntent, [JCA70002,JCA70005] Constructor parameter that is not an SCA reference cannot have policySet/intent annotations: public org.oasisopen.sca.test.service1BadIntent(java.lang.String)[0]
+JCA_8006=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_JCA_8006Component1, Service: Service1] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testIntent2 and {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testIntent1 are mutually exclusive
+JCA_8008=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Processing composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_8008: Resolving Java implementation: org.oasisopen.sca.test.service1BadPolicySet, [JCA70002,JCA70005] Method that is not an SCA reference cannot have policySet/intent annotations: public java.lang.String org.oasisopen.sca.test.service1BadPolicySet.operation1(java.lang.String)
+JCA_8009=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Processing composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_8009: Resolving Java implementation: org.oasisopen.sca.test.service1BadPolicySet, [JCA70002,JCA70005] Field that is not an SCA reference cannot have policySet/intent annotations: public java.lang.String org.oasisopen.sca.test.service1BadPolicySet.someField
+JCA_8010=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.contribution.processor.ContributionResolveException: Processing composite {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TEST_JCA_8010: Resolving Java implementation: org.oasisopen.sca.test.service1BadPolicySet, [JCA70002,JCA70005] Constructor parameter that is not an SCA reference cannot have policySet/intent annotations: public org.oasisopen.sca.test.service1BadPolicySet(java.lang.String)[0]
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/java-ci/pom.xml b/sandbox/sebastien/java/embed/compliance-tests/java-ci/pom.xml
new file mode 100644
index 0000000000..34161f0cf3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/java-ci/pom.xml
@@ -0,0 +1,122 @@
+<?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-compliance-tests</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-compliance-test-java-ci</artifactId>
+ <name>Apache Tuscany SCA Specification Compliance Tests Java CI</name>
+
+ <dependencies>
+
+ <dependency>
+ <!-- This is only needed to get the module working in Eclipse which doesn't pick it up from the dependency plugin unpack -->
+ <!-- The dependency plugin unpack is needed as presently the surefire plugin wont run tests in a dependency jar -->
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-javaci-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- This is need when running with Sun JDK which gets an unsupported operation exception creating an XMLStreamReader from a DOMSource
+ when Tuscany is writing a property value -->
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/POJO_8003_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/POJO_8008_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ <exclude>**/POJO_8012_TestCase.java</exclude><!-- see TUSCANY-xxx -->
+ </excludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-javaci-contributions</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>zip</type>
+ <outputDirectory>${project.build.directory}/oasis-contributions</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-javaci-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ <excludes>commons-logging.properties,oasis-sca-tests.properties,tuscany-oasis-sca-tests-errors.properties</excludes>
+ <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
new file mode 100644
index 0000000000..136e5668c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.otest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import client.RuntimeBridge;
+import client.TestConfiguration;
+
+/**
+ * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x)
+ *
+ */
+public class TuscanyRuntimeBridge implements RuntimeBridge {
+
+ static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION";
+
+ protected NodeFactory launcher;
+ protected Node node;
+ protected Properties expectedErrorMessages;
+
+ TestConfiguration testConfiguration = null;
+
+ public TuscanyRuntimeBridge() {
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
+ }
+
+ public TestConfiguration getTestConfiguration() {
+ return testConfiguration;
+ }
+
+ public void setTestConfiguration(TestConfiguration testConfiguration) {
+ this.testConfiguration = testConfiguration;
+ }
+
+ public boolean startContribution(String compositeName,
+ String contributionLocation, String[] contributionNames)
+ throws Exception {
+ //TODO:
+ return startContribution(contributionLocation, contributionNames);
+ }
+
+ public boolean startContribution(String contributionLocation, String[] contributionNames) throws Exception {
+ try {
+ // Tuscany specific code which starts the contribution(s) holding the test
+ Properties ps = new Properties();
+ ps.setProperty("defaultScheme", "vm");
+ ps.setProperty("org.apache.tuscany.sca.binding.ws.jaxws.ri.JAXWSBindingProviderFactory.defaultPort", "8080");
+ launcher = NodeFactory.newInstance(ps);
+
+ Contribution[] contributions = new Contribution[contributionNames.length];
+ String[] contributionURIs = getContributionURIs(contributionLocation);
+ for (int i = 0; i < contributions.length; i++) {
+ contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
+ } // end for
+
+ node = launcher.createNode(testConfiguration.getComposite(), contributions);
+ // Start the node
+ node.start();
+
+ // For debugging
+ // print out the composites that have been read in success cases
+ // System.out.println(((NodeImpl)node).dumpDomainComposite());
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ throw e;
+ } // end try
+
+ return true;
+ } // end method startContribution
+
+ /**
+ * Gets the location of the Contributions as URIs
+ * @param contributionLocation - a location pattern URI, which contains one or more "%1"
+ * substrings, which are substituted with the name of the contribution to get the URI of
+ * the contribution
+ * @return the contribution locations as an array of Strings
+ */
+ protected String[] getContributionURIs(String contributionLocation) throws Exception {
+ String[] locations;
+ locations = testConfiguration.getContributionNames();
+
+ if (locations != null && contributionLocation != null) {
+
+ for (int i = 0; i < locations.length; i++) {
+ String aLocation = contributionLocation.replaceAll("%1", locations[i]);
+ // Looks like bugs in the oasis code that sometimes still uses jars for some
+ if (aLocation.endsWith("_POJO.zip") && !aLocation.endsWith("ASM_8005_Java-1.0.zip")) {
+ aLocation = aLocation.substring(0, aLocation.length()-3) + "jar";
+ }
+ if (!(new File(aLocation)).exists()) {
+ aLocation = aLocation.replace(".zip", ".jar");
+ }
+ locations[i] = aLocation;
+ } // end for
+ } else {
+ if (locations == null) {
+ // No contribution specified - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution supplied - error");
+ } else {
+ // No contribution location supplied - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution location supplied - error");
+ } // end if
+ } // end if
+
+ return locations;
+ } // end getContributionURI
+
+ public void stopContribution() {
+ if (node != null) {
+ node.stop();
+ } // end if
+ if (launcher != null) {
+ launcher.destroy();
+ } // end if
+ } // end method stopContribution
+
+ public String getContributionLocation(Class<?> testClass) {
+ return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
+ } // end method getContributionLocation
+
+ public void checkError(String testName, Throwable ex) throws Throwable {
+
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = ex.getMessage();
+
+ if (expectedMessage == null){
+ writeMissingMessage(testName, ex);
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ } // end if
+
+ if (receivedMessage == null){
+ ex.printStackTrace();
+ fail("Null received error message for test " + testName);
+ } // end if
+
+ if (expectedMessage.startsWith("*")) {
+ // allow using * to ignore a message comparison
+ return;
+ }
+
+ // Deal with the case where the message has variable parts within it
+ // marked with the characters ***. Here we tokenize the epected string
+ // and make sure all the individual parts are present in the results string
+ String expectedMessageParts[] = expectedMessage.split("\\*\\*\\*");
+
+ if (expectedMessageParts.length > 1){
+ int foundParts = 0;
+ for(int i = 0; i < expectedMessageParts.length; i++){
+ if (receivedMessage.indexOf(expectedMessageParts[i]) > -1 ){
+ foundParts++;
+ }
+ }
+
+ if (foundParts == expectedMessageParts.length){
+ return;
+ }
+ }
+
+
+ // Deal with the case where the end of the message is variable (eg contains absolute filenames)
+ // and where the only relevant part is the start of the message - in this case the expected
+ // message only contains the stem section which is unchanging...
+ if( receivedMessage.length() > expectedMessage.length() ) {
+ // Truncate the received message to the length of the expected message
+ receivedMessage = receivedMessage.substring(0, expectedMessage.length() );
+ } // end if
+
+ if (!expectedMessage.equals(receivedMessage)) {
+ writeIncorrectMessage(testName, expectedMessage, receivedMessage);
+ }
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+
+ }
+
+ protected void writeMissingMessage(String testName, Throwable ex) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestMissingMsgs.txt", true));
+ out.write(testName + "=*");
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected void writeIncorrectMessage(String testName, String expected, String received) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestIncorrectMsgs.txt", true));
+ out.write(testName); out.newLine();
+ out.write(" " + expected); out.newLine();
+ out.write(" " + received); out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+} // end class TuscanyRuntimeBridge
diff --git a/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/resources/oasis-sca-tests.properties b/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/resources/oasis-sca-tests.properties
new file mode 100644
index 0000000000..38e1e013dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/resources/oasis-sca-tests.properties
@@ -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.
+
+# OASIS SCA Assembly test properties
+# The implementation type to use for Assembly test suite
+# org.oasis.sca.tests.assembly.lang=BPEL
+org.oasis.sca.tests.assembly.lang=POJO
+
+# The class to use as the Runtime Bridge for the SCA runtime under test
+#org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyOSGiRuntimeBridge
+org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyRuntimeBridge
+
+# The location of the contributions for the test suite
+# %1 represents the placement of the name of each contribution into the location URI
+org.oasis.sca.tests.assembly.contribution.location=target/oasis-contributions/%1.zip
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/resources/tuscany-oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..4de2d6e98b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/java-ci/src/test/resources/tuscany-oasis-sca-tests-errors.properties
@@ -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.
+POJO_2003=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.IntrospectionException: [JCA90042,JCI20002] Implementation missing service method operation2 service interface org.oasisopen.sca.test.Service1Superset
+POJO_5001=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.NoConstructorException: [JCI50001] No public constructor for class
+POJO_5005=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.AmbiguousConstructorException:
+POJO_5006=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.DuplicateConstructorException: [JCI50002] Multiple constructors marked with @Constructor
+POJO_5007=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.InvalidConstructorException: [JCI50005] Multiple annotated constructors
+POJO_8002=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POJO_8002Component1] - [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = TEST_POJO_8002Component1 Service = Service1Superset Operation operationb not found on target
+POJO_8003=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POJO_8003Component1, Service: Service1] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200912}suspendsTransaction and {http://docs.oasis-open.org/ns/opencsa/sca/200912}propagatesTransaction are mutually exclusive
+POJO_8008=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POJO_8008Component1, Service: Service1] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200912}suspendsTransaction and {http://docs.oasis-open.org/ns/opencsa/sca/200912}propagatesTransaction are mutually exclusive
+POJO_8012=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POJO_8012Component1, Service: Service1] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200912}noManagedTransaction and {http://docs.oasis-open.org/ns/opencsa/sca/200912}managedTransaction are mutually exclusive
+POJO_8013=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.DuplicatePropertyException: duplicateProperty
+POJO_8014=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: org.apache.tuscany.sca.implementation.java.introspect.impl.DuplicateReferenceException: duplicateReference
+POJO_9001=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POJO_9001, Artifact: Test_POJO_9001.composite] - XMLSchema validation error occured in: Test_POJO_9001.composite ,line = ***, column = ***, Message = cvc-complex-type.3.2.2: Attribute 'interface' is not allowed to appear in element 'implementation.java'.
+POJO_10001=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POJO_10001, Artifact: META-INF/sca-contribution.xml] - [JCI10001] The value of the @package attribute on the <import.java/> element is not unique across all other <import.java/> elements within the contribution.
+POJO_10004=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: [JCI100007] A Java package org.oasisopen.sca.test;version=1.0.0 that is specified on an export element MUST be contained within the contribution containing the export element.
+POJO_10005=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POJO_10005, Artifact: META-INF/sca-contribution.xml] - [JCI10004] The value of the @package attribute on the <export.java/> element is not unique across all other <export.java/> elements within the contribution.
+POJO_10006=org.apache.tuscany.sca.contribution.processor.ContributionResolveException: [JCI100007] A Java package org.oasisopen.sca.test.y that is specified on an export element MUST be contained within the contribution containing the export element.
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/policy/pom.xml b/sandbox/sebastien/java/embed/compliance-tests/policy/pom.xml
new file mode 100644
index 0000000000..548716f02f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/policy/pom.xml
@@ -0,0 +1,127 @@
+<?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-compliance-tests</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-compliance-test-policy</artifactId>
+ <name>Apache Tuscany SCA Specification Compliance Tests Policy</name>
+
+ <dependencies>
+
+ <dependency>
+ <!-- This is only needed to get the module working in Eclipse which doesn't pick it up from the dependency plugin unpack -->
+ <!-- The dependency plugin unpack is needed as presently the surefire plugin wont run tests in a dependency jar -->
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-policy-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <!-- This is need for POL_4013 and POL_4028 when running with Sun JDK which
+ gets an unsupported operation exception creating an XMLStreamReader from a DOMSource
+ when Tuscany is writing a property value -->
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- 3002 is no longer part of the suite and 4015/4016 are tests for no optional support -->
+ <exclude>**/POL_3002_TestCase.java</exclude>
+ <exclude>**/POL_4015_TestCase.java</exclude>
+ <exclude>**/POL_4016_TestCase.java</exclude>
+
+ <!-- 3001 fails due to a Tuscany bug in the RI based WS binding -->
+ <exclude>**/POL_3001_TestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-policy-contributions</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>zip</type>
+ <outputDirectory>${project.build.directory}/oasis-contributions</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>oasis-policy-test-runner</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ <excludes>commons-logging.properties,oasis-sca-tests.properties,tuscany-oasis-sca-tests-errors.properties</excludes>
+ <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
new file mode 100644
index 0000000000..ac2759114f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/java/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.otest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import testClient.TestException_Exception;
+import client.RuntimeBridge;
+
+/**
+ * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x)
+ *
+ */
+public class TuscanyRuntimeBridge implements RuntimeBridge {
+
+ static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION";
+
+ protected NodeFactory launcher;
+ protected Node node;
+ protected Properties expectedErrorMessages;
+
+ public TuscanyRuntimeBridge() {
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
+ }
+
+ public boolean startContribution(String compositeName, String contributionLocation, String[] contributionNames) throws Exception {
+ try {
+ // Tuscany specific code which starts the contribution(s) holding the test
+ Properties ps = new Properties();
+ ps.setProperty("defaultScheme", "vm");
+ ps.setProperty("org.apache.tuscany.sca.binding.ws.jaxws.ri.JAXWSBindingProviderFactory.defaultPort", "8080");
+ launcher = NodeFactory.newInstance(ps);
+
+ Contribution[] contributions = new Contribution[contributionNames.length];
+ String[] contributionURIs = getContributionURIs(contributionLocation, contributionNames);
+ for (int i = 0; i < contributions.length; i++) {
+ contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
+ } // end for
+
+ node = launcher.createNode(compositeName, contributions);
+ // Start the node
+ node.start();
+
+ // For debugging
+ // print out the composites that have been read in success cases
+ // System.out.println(((NodeImpl)node).dumpDomainComposite());
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ throw e;
+ } // end try
+
+ return true;
+ } // end method startContribution
+
+ /**
+ * Gets the location of the Contributions as URIs
+ * @param contributionLocation - a location pattern URI, which contains one or more "%1"
+ * substrings, which are substituted with the name of the contribution to get the URI of
+ * the contribution
+ * @return the contribution locations as an array of Strings
+ */
+ protected String[] getContributionURIs(String contributionLocation, String[] contributionNames) throws Exception {
+ String[] locations = new String[contributionNames.length];
+
+ if (locations != null && contributionLocation != null) {
+
+ for (int i = 0; i < locations.length; i++) {
+ String aLocation = contributionLocation.replaceAll("%1", contributionNames[i]);
+
+ if (!(new File(aLocation)).exists()) {
+ aLocation = aLocation.replace(".zip", ".jar");
+ }
+
+ locations[i] = aLocation;
+ } // end for
+ } else {
+ if (locations == null) {
+ // No contribution specified - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution supplied - error");
+ } else {
+ // No contribution location supplied - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution location supplied - error");
+ } // end if
+ } // end if
+
+ return locations;
+ } // end getContributionURI
+
+ public void stopContribution() {
+ if (node != null) {
+ node.stop();
+ } // end if
+ if (launcher != null) {
+ launcher.destroy();
+ } // end if
+ } // end method stopContribution
+
+ public void checkError(String testName, Throwable ex) throws Throwable {
+
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = getErrorMessage(ex);//ex.getMessage();
+
+ if (expectedMessage == null){
+ writeMissingMessage(testName, ex);
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ } // end if
+
+ if (receivedMessage == null){
+ ex.printStackTrace();
+ fail("Null received error message for test " + testName);
+ } // end if
+
+ if (expectedMessage.startsWith("*")) {
+ // allow using * to ignore a message comparison
+ return;
+ }
+
+ // Deal with the case where the message has variable parts within it
+ // marked with the characters ***. Here we tokenize the expected string
+ // and make sure all the individual parts are present in the results string
+ String expectedMessageParts[] = expectedMessage.split("\\*\\*\\*");
+
+ if (expectedMessageParts.length > 1){
+ int foundParts = 0;
+ for(int i = 0; i < expectedMessageParts.length; i++){
+ if (receivedMessage.indexOf(expectedMessageParts[i]) > -1 ){
+ foundParts++;
+ }
+ }
+
+ if (foundParts == expectedMessageParts.length){
+ return;
+ }
+ }
+
+
+ // Deal with the case where the end of the message is variable (eg contains absolute filenames)
+ // and where the only relevant part is the start of the message - in this case the expected
+ // message only contains the stem section which is unchanging...
+ if( receivedMessage.length() > expectedMessage.length() ) {
+ // Truncate the received message to the length of the expected message
+ receivedMessage = receivedMessage.substring(0, expectedMessage.length() );
+ } // end if
+
+ if (!expectedMessage.equals(receivedMessage)) {
+ writeIncorrectMessage(testName, expectedMessage, receivedMessage);
+ }
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+
+ }
+
+ protected void writeMissingMessage(String testName, Throwable ex) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestMissingMsgs.txt", true));
+ out.write(testName + "=*");
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected void writeIncorrectMessage(String testName, String expected, String received) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestIncorrectMsgs.txt", true));
+ out.write(testName); out.newLine();
+ out.write(" " + expected); out.newLine();
+ out.write(" " + received); out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected String getErrorMessage(Throwable ex) {
+ String errorMessage = null;
+
+ if (ex instanceof TestException_Exception) {
+ TestException_Exception te = (TestException_Exception) ex;
+ errorMessage = te.getFaultInfo().getMessage();
+ } else {
+ errorMessage = ex.getMessage();
+ }
+
+ return errorMessage;
+ }
+
+} // end class TuscanyRuntimeBridge
diff --git a/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/resources/oasis-sca-tests.properties b/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/resources/oasis-sca-tests.properties
new file mode 100644
index 0000000000..0d8cc27a45
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/resources/oasis-sca-tests.properties
@@ -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.
+
+# OASIS SCA Assembly test properties
+# The implementation type to use for Assembly test suite
+# org.oasis.sca.tests.assembly.lang=BPEL
+org.oasis.sca.tests.assembly.lang=Java
+
+# The class to use as the Runtime Bridge for the SCA runtime under test
+#org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyOSGiRuntimeBridge
+org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyRuntimeBridge
+
+# The location of the contributions for the test suite
+# %1 represents the placement of the name of each contribution into the location URI
+org.oasis.sca.tests.assembly.contribution.location=target/oasis-contributions/%1.zip
+
diff --git a/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/resources/tuscany-oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..3a6e06654c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/policy/src/test/resources/tuscany-oasis-sca-tests-errors.properties
@@ -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.
+
+POL_3001=Test service got an exception during execution: org.oasisopen.sca.ServiceRuntimeException WSDL document is using SOAP v1.2 but SOAP v1.1 is required by the specified policy intents
+POL_3002=TUSCANY-3370
+POL_3003=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_3003, Artifact: META-INF/definitions.xml, Definitions: jar:file:***/POL_3003.zip!/META-INF/definitions.xml] - [ASM10001,POL30002] Duplicate intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}dupIntent found in domain
+POL_3004=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_3004, Artifact: META-INF/definitions.xml, Definitions: jar:file:***/POL_3004.zip!/META-INF/definitions.xml] - [POL30004] Intent twoDefaults has more than one qualifier marked as the default qualifier
+POL_3005=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_3005, Artifact: META-INF/definitions.xml, Definitions: jar:file:***/POL_3005.zip!/META-INF/definitions.xml] - [POL30005] The intent dupQualifiers has more than one qualifier with the name qual1
+POL_3006=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_3006, Artifact: META-INF/definitions.xml, Definitions: jar:file:***/POL_3006.zip!/META-INF/definitions.xml] - [POL30006] The profile intent name bad.ProfileIntent must not have the character "." in it
+POL_3009=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_3009, Artifact: META-INF/definitions.xml, Definitions: jar:file:***/POL_3009.zip!/META-INF/definitions.xml] - [POL30010] The policy set TwoIntentMapPolicySet has more than one intent map with the name testIntent6
+POL_3012=org.oasisopen.sca.ServiceRuntimeException: [Contribution: http://tuscany.apache.org/SystemContribution] - [POL30015] Required Intent - {http://docs.oasis-open.org/ns/opencsa/scatests/200903}undefinedIntent2 not found for ProfileIntent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}badProfileIntent
+POL_3013=org.oasisopen.sca.ServiceRuntimeException: [Contribution: http://tuscany.apache.org/SystemContribution] - [POL30016] Excluded Intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}undefinedIntent not found for intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}noMuxIntent
+POL_3014=org.oasisopen.sca.ServiceRuntimeException: [Contribution: Policy_General, Definitions: jar:file:***/Policy_General.zip!/META-INF/definitions.xml] - DuplicatePolicySet
+POL_3015=org.apache.tuscany.sca.contribution.processor.ContributionReadException: javax.xml.xpath.XPathExpressionException
+POL_3016=org.apache.tuscany.sca.contribution.processor.ContributionReadException: javax.xml.xpath.XPathExpressionException
+POL_3017=org.oasisopen.sca.ServiceRuntimeException: [Contribution: http://tuscany.apache.org/SystemContribution] - [POL30020] The policy set {http://docs.oasis-open.org/ns/opencsa/scatests/200903}BadIntentMapPolicySet intent map testIntent6 has missing qualifiers: testIntent6.qual2 The intent map qualifiers must match the provided intent qualifiers.
+POL_3018=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_3018, Artifact: META-INF/definitions.xml, Definitions: jar:file:***/POL_3018.zip!/META-INF/definitions.xml] - [POL30021] Intent Map provides for Intent not specified as provided by parent PolicySet - BadIntentMapPolicySet
+POL_3020=TUSCANY-3371
+POL_4001=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient, Service: TestInvocation] - The intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testIntentExt2 associated with policy subject ***Endpoint: URI = TestClient#service-binding(TestInvocation/TestInvocation) has no matching policy set
+POL_4004=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POL_4004Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestCompositeImplIntent, Component: TestComposite0Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite0, Component: TestComposite0Component1] - The intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testImplIntent.qual2 associated with policy subject {http://docs.oasis-open.org/ns/opencsa/sca/200912}implementation.java (class=org.oasisopen.sca.test.service1Impl) has no matching policy set
+POL_4005=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POL_4005Component1, Service: Service1] - The intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testImplIntent.qual2 associated with policy subject ***Endpoint: URI = TEST_POL_4005Component1#service-binding(Service1/Service1) has no matching policy set
+POL_4006=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient, Service: TestInvocation] - The intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}HighIntent associated with policy subject ***Endpoint: URI = TestClient#service-binding(TestInvocation/TestInvocation) has no matching policy set
+POL_4009=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POL_4009Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestCompositeImplPolicySet, Component: TestComposite0Component1, Composite: {http://docs.oasis-open.org/ns/opencsa/scatests/200903}TestComposite0, Component: TestComposite0Component1] - The intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testImplIntent2 associated with policy subject {http://docs.oasis-open.org/ns/opencsa/sca/200912}implementation.java (class=org.oasisopen.sca.test.service1Impl) has no matching policy set
+POL_4010=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient, Service: TestInvocation] - The intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}DirectIntent associated with policy subject ***Endpoint: URI = TestClient#service-binding(TestInvocation/TestInvocation) has no matching policy set
+POL_4012=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient, Service: TestInvocation] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testIntent*** and {http://docs.oasis-open.org/ns/opencsa/scatests/200903}testIntent*** are mutually exclusive
+POL_4018=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient, Service: TestInvocation] - The intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}DirectIntent associated with policy subject ***Endpoint: URI = TestClient#service-binding(TestInvocation/TestInvocation) has no matching policy set
+POL_4027=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_4027, Artifact: META-INF/definitions.xml, Definitions:*** - [POL40020] Duplicate binding type {http://docs.oasis-open.org/ns/opencsa/sca/200912}dupBinding.type found in domain
+POL_4028=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}] - [POL40002] The policy {http://docs.oasis-open.org/ns/opencsa/scatests/200903}PolicySetExtAttachProp has been attached to a property or one of its children. This is not allowed.
+POL_4033=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_4033, Artifact: META-INF/definitions.xml, Definitions:*** - ContributionReadException occurred due to: org.apache.tuscany.sca.contribution.processor.ContributionReadException: javax.xml.xpath.XPathExpressionException
+POL_5001=org.oasisopen.sca.ServiceRuntimeException: [Contribution: http://tuscany.apache.org/SystemContribution] - [POL50001] An extension to support the implementation type {http://docs.oasis-open.org/ns/opencsa/sca/200912}unknown.type cant be found in the domain
+POL_9006=org.oasisopen.sca.ServiceRuntimeException: [] - The Component reference reference1 can not require transactedOneWay because the implementation for Component TEST_POL_9006Component1 requires managedTransaction.local
+POL_9009=org.oasisopen.sca.ServiceRuntimeException: [] - The Component service Service1 can not require transactedOneWay because the implementation for Component TEST_POL_9009Component2 requires managedTransaction.local
+POL_9015=org.oasisopen.sca.ServiceRuntimeException: [] - The component service Service1 can not require propagatesTransaction because the implementation for component TEST_POL_9015Component1 requires managedTransaction.local
+POL_9016=org.oasisopen.sca.ServiceRuntimeException: [] - The component service Service1 can not require propagatesTransaction because the implementation for component TEST_POL_9016Component1 requires noManagedTransaction
+POL_9017=org.oasisopen.sca.ServiceRuntimeException: [] - The component reference reference1 can not require propagatesTransaction because the implementation for component TEST_POL_9017Component1 requires managedTransaction.local
+POL_9018=org.oasisopen.sca.ServiceRuntimeException: [] - The component reference reference1 can not require propagatesTransaction because the implementation for component TEST_POL_9018Component1 requires noManagedTransaction
+POL_9019=org.oasisopen.sca.ServiceRuntimeException: [***] - The Component reference reference1 can not require transactedOneWay because the implementation for Component TEST_POL_9019Component1 requires managedTransaction.local
+POL_9020=org.oasisopen.sca.ServiceRuntimeException: [] - The component reference reference1 can not require transactedOneWay because the operation operation1 is a two way operation
+POL_9021=org.oasisopen.sca.ServiceRuntimeException: [] - The component reference reference1 can not require immediateOneWay because the operation operation1 is a two way operation
+POL_9022=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POL_9022Component1, Reference: reference1] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200912}*** and {http://docs.oasis-open.org/ns/opencsa/sca/200912}*** are mutually exclusive
+POL_9023=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TEST_POL_9023Component2, Service: Service1] - [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {http://docs.oasis-open.org/ns/opencsa/sca/200912}*** and {http://docs.oasis-open.org/ns/opencsa/sca/200912}*** are mutually exclusive
+POL_10001=org.oasisopen.sca.ServiceRuntimeException: [Composite: {http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component: TestClient, Service: TestInvocation] - The noListener intent may only be specified on a reference.
+POL_11001=org.oasisopen.sca.ServiceRuntimeException: [Contribution: POL_11001, Artifact: Test_POL_11001.composite] - XMLSchema validation error occured in: Test_POL_11001.composite ,line = 21, column = 4, Message = cvc-complex-type.3.2.2: Attribute 'badAttribute' is not allowed to appear in element 'policySetAttachment'. \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/compliance-tests/pom.xml b/sandbox/sebastien/java/embed/compliance-tests/pom.xml
new file mode 100644
index 0000000000..56b1da7637
--- /dev/null
+++ b/sandbox/sebastien/java/embed/compliance-tests/pom.xml
@@ -0,0 +1,48 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <packaging>pom</packaging>
+ <artifactId>tuscany-compliance-tests</artifactId>
+ <name>Apache Tuscany SCA Compliance Tests</name>
+
+ <repositories>
+ <repository>
+ <!-- OASIS will eventually publish these themselves but for now they're at my people place -->
+ <id>oasis.contributions</id>
+ <url>http://people.apache.org/~antelder/tuscany/otests/maven</url>
+ </repository>
+ </repositories>
+
+ <modules>
+ <module>assembly</module>
+ <!-- module>policy</module -->
+ <module>java-caa</module>
+ <module>java-ci</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2789db18ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data Binding for Google ProtocolBuffers
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data Binding for JSON
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding.protobuf
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/pom.xml b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/pom.xml
new file mode 100644
index 0000000000..90b5ba1c68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/pom.xml
@@ -0,0 +1,64 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding-protobuf</artifactId>
+ <name>Apache Tuscany SCA Data Binding for Google ProtocolBuffers</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/InputStream2Protobuf.java b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/InputStream2Protobuf.java
new file mode 100644
index 0000000000..7953e4e5b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/InputStream2Protobuf.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.sca.databinding.protobuf;
+
+import java.io.InputStream;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+import com.google.protobuf.Message;
+
+/**
+ *
+ */
+public class InputStream2Protobuf implements PullTransformer<InputStream, Message> {
+
+ @Override
+ public String getSourceDataBinding() {
+ return "application/x-protobuf" + "#" + InputStream.class.getName();
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ // TODO Auto-generated method stub
+ return ProtobufDatabinding.NAME;
+ }
+
+ @Override
+ public int getWeight() {
+ // TODO Auto-generated method stub
+ return 10;
+ }
+
+ @Override
+ public Message transform(InputStream source, TransformationContext context) {
+ try {
+ Class<?> type = context.getTargetDataType().getPhysical();
+ Method method = type.getMethod("parseFrom", InputStream.class);
+ Object result = method.invoke(null, source);
+ return (Message)result;
+ } catch (Throwable e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/Protobuf2OutputStream.java b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/Protobuf2OutputStream.java
new file mode 100644
index 0000000000..6892287f67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/Protobuf2OutputStream.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.databinding.protobuf;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+import com.google.protobuf.Message;
+
+/**
+ *
+ */
+public class Protobuf2OutputStream implements PushTransformer<Message, OutputStream> {
+ @Override
+ public String getSourceDataBinding() {
+ return ProtobufDatabinding.NAME;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return "application/x-protobuf" + "#" + OutputStream.class.getName();
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ @Override
+ public void transform(Message source, OutputStream sink, TransformationContext context) {
+ try {
+ if (source != null) {
+ source.writeTo(sink);
+ }
+ } catch (IOException e) {
+ throw new TransformationException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufDatabinding.java b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufDatabinding.java
new file mode 100644
index 0000000000..ad148c7499
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufDatabinding.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.protobuf;
+
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+
+import com.google.protobuf.Message;
+
+/**
+ * Google ProtocolBuffers databinding
+ */
+public class ProtobufDatabinding implements DataBinding {
+
+ public static final String NAME = "ProtocolBuffers";
+
+ /**
+ *
+ */
+ public ProtobufDatabinding() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#getName()
+ */
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#introspect(org.apache.tuscany.sca.interfacedef.DataType, org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ @Override
+ public boolean introspect(DataType dataType, Operation operation) {
+ if (Message.class.isAssignableFrom(dataType.getPhysical())) {
+ dataType.setDataBinding(NAME);
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#introspect(java.lang.Object, org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ @Override
+ public DataType introspect(Object value, Operation operation) {
+ if (value instanceof Message) {
+ DataType dt = new DataTypeImpl(value.getClass(), null);
+ dt.setDataBinding(NAME);
+ return dt;
+ } else {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#getWrapperHandler()
+ */
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#copy(java.lang.Object, org.apache.tuscany.sca.interfacedef.DataType, org.apache.tuscany.sca.interfacedef.DataType, org.apache.tuscany.sca.interfacedef.Operation, org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ @Override
+ public Object copy(Object object,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ Message msg = (Message)object;
+ return ((Message.Builder)msg.toBuilder().clone()).build();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#getXMLTypeHelper()
+ */
+ @Override
+ public XMLTypeHelper getXMLTypeHelper() {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
new file mode 100644
index 0000000000..35f7932ff9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
@@ -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 classes for the databindings
+org.apache.tuscany.sca.databinding.protobuf.ProtobufDatabinding;name=ProtocolBuffers
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..0f60373c30
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -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 classes for the transformers
+org.apache.tuscany.sca.databinding.protobuf.InputStream2Protobuf;source=application/x-protobuf#java.io.InputStream;target=ProtocolBuffers,weight=10,public=true
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
new file mode 100644
index 0000000000..cc1989eb7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.databinding.protobuf.Protobuf2OutputStream;source=ProtocolBuffers;target=application/x-protobuf#java.io.OutputStream,weight=10,public=true
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/java/com/example/tutorial/AddressBookProtos.java b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/java/com/example/tutorial/AddressBookProtos.java
new file mode 100644
index 0000000000..8219fe1099
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/java/com/example/tutorial/AddressBookProtos.java
@@ -0,0 +1,1375 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: addressbook.proto
+
+package com.example.tutorial;
+
+public final class AddressBookProtos {
+ private AddressBookProtos() {
+ }
+
+ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) {
+ }
+
+ public static final class Person extends com.google.protobuf.GeneratedMessage {
+ // Use Person.newBuilder() to construct.
+ private Person() {
+ initFields();
+ }
+
+ private Person(boolean noInit) {
+ }
+
+ private static final Person defaultInstance;
+
+ public static Person getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public Person getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_fieldAccessorTable;
+ }
+
+ public enum PhoneType implements com.google.protobuf.ProtocolMessageEnum {
+ MOBILE(0, 0), HOME(1, 1), WORK(2, 2), ;
+
+ public final int getNumber() {
+ return value;
+ }
+
+ public static PhoneType valueOf(int value) {
+ switch (value) {
+ case 0:
+ return MOBILE;
+ case 1:
+ return HOME;
+ case 2:
+ return WORK;
+ default:
+ return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap<PhoneType> internalGetValueMap() {
+ return internalValueMap;
+ }
+
+ private static com.google.protobuf.Internal.EnumLiteMap<PhoneType> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap<PhoneType>() {
+ public PhoneType findValueByNumber(int number) {
+ return PhoneType.valueOf(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() {
+ return getDescriptor().getValues().get(index);
+ }
+
+ public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() {
+ return getDescriptor();
+ }
+
+ public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() {
+ return com.example.tutorial.AddressBookProtos.Person.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final PhoneType[] VALUES = {MOBILE, HOME, WORK,};
+
+ public static PhoneType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int index;
+ private final int value;
+
+ private PhoneType(int index, int value) {
+ this.index = index;
+ this.value = value;
+ }
+
+ static {
+ com.example.tutorial.AddressBookProtos.getDescriptor();
+ }
+
+ // @@protoc_insertion_point(enum_scope:tutorial.Person.PhoneType)
+ }
+
+ public static final class PhoneNumber extends com.google.protobuf.GeneratedMessage {
+ // Use PhoneNumber.newBuilder() to construct.
+ private PhoneNumber() {
+ initFields();
+ }
+
+ private PhoneNumber(boolean noInit) {
+ }
+
+ private static final PhoneNumber defaultInstance;
+
+ public static PhoneNumber getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public PhoneNumber getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_PhoneNumber_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable;
+ }
+
+ // required string number = 1;
+ public static final int NUMBER_FIELD_NUMBER = 1;
+ private boolean hasNumber;
+ private java.lang.String number_ = "";
+
+ public boolean hasNumber() {
+ return hasNumber;
+ }
+
+ public java.lang.String getNumber() {
+ return number_;
+ }
+
+ // optional .tutorial.Person.PhoneType type = 2 [default = HOME];
+ public static final int TYPE_FIELD_NUMBER = 2;
+ private boolean hasType;
+ private com.example.tutorial.AddressBookProtos.Person.PhoneType type_;
+
+ public boolean hasType() {
+ return hasType;
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneType getType() {
+ return type_;
+ }
+
+ private void initFields() {
+ type_ = com.example.tutorial.AddressBookProtos.Person.PhoneType.HOME;
+ }
+
+ public final boolean isInitialized() {
+ if (!hasNumber)
+ return false;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
+ getSerializedSize();
+ if (hasNumber()) {
+ output.writeString(1, getNumber());
+ }
+ if (hasType()) {
+ output.writeEnum(2, getType().getNumber());
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1)
+ return size;
+
+ size = 0;
+ if (hasNumber()) {
+ size += com.google.protobuf.CodedOutputStream.computeStringSize(1, getNumber());
+ }
+ if (hasType()) {
+ size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, getType().getNumber());
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseDelimitedFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static Builder newBuilder() {
+ return Builder.create();
+ }
+
+ public Builder newBuilderForType() {
+ return newBuilder();
+ }
+
+ public static Builder newBuilder(com.example.tutorial.AddressBookProtos.Person.PhoneNumber prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+
+ public Builder toBuilder() {
+ return newBuilder(this);
+ }
+
+ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> {
+ private com.example.tutorial.AddressBookProtos.Person.PhoneNumber result;
+
+ // Construct using com.example.tutorial.AddressBookProtos.Person.PhoneNumber.newBuilder()
+ private Builder() {
+ }
+
+ private static Builder create() {
+ Builder builder = new Builder();
+ builder.result = new com.example.tutorial.AddressBookProtos.Person.PhoneNumber();
+ return builder;
+ }
+
+ protected com.example.tutorial.AddressBookProtos.Person.PhoneNumber internalGetResult() {
+ return result;
+ }
+
+ public Builder clear() {
+ if (result == null) {
+ throw new IllegalStateException("Cannot call clear() after build().");
+ }
+ result = new com.example.tutorial.AddressBookProtos.Person.PhoneNumber();
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(result);
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
+ return com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDescriptor();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getDefaultInstanceForType() {
+ return com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDefaultInstance();
+ }
+
+ public boolean isInitialized() {
+ return result.isInitialized();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber build() {
+ if (result != null && !isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return buildPartial();
+ }
+
+ private com.example.tutorial.AddressBookProtos.Person.PhoneNumber buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ if (!isInitialized()) {
+ throw newUninitializedMessageException(result).asInvalidProtocolBufferException();
+ }
+ return buildPartial();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber buildPartial() {
+ if (result == null) {
+ throw new IllegalStateException("build() has already been called on this Builder.");
+ }
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber returnMe = result;
+ result = null;
+ return returnMe;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.example.tutorial.AddressBookProtos.Person.PhoneNumber) {
+ return mergeFrom((com.example.tutorial.AddressBookProtos.Person.PhoneNumber)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.example.tutorial.AddressBookProtos.Person.PhoneNumber other) {
+ if (other == com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDefaultInstance())
+ return this;
+ if (other.hasNumber()) {
+ setNumber(other.getNumber());
+ }
+ if (other.hasType()) {
+ setType(other.getType());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ setNumber(input.readString());
+ break;
+ }
+ case 16: {
+ int rawValue = input.readEnum();
+ com.example.tutorial.AddressBookProtos.Person.PhoneType value =
+ com.example.tutorial.AddressBookProtos.Person.PhoneType.valueOf(rawValue);
+ if (value == null) {
+ unknownFields.mergeVarintField(2, rawValue);
+ } else {
+ setType(value);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // required string number = 1;
+ public boolean hasNumber() {
+ return result.hasNumber();
+ }
+
+ public java.lang.String getNumber() {
+ return result.getNumber();
+ }
+
+ public Builder setNumber(java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasNumber = true;
+ result.number_ = value;
+ return this;
+ }
+
+ public Builder clearNumber() {
+ result.hasNumber = false;
+ result.number_ = getDefaultInstance().getNumber();
+ return this;
+ }
+
+ // optional .tutorial.Person.PhoneType type = 2 [default = HOME];
+ public boolean hasType() {
+ return result.hasType();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneType getType() {
+ return result.getType();
+ }
+
+ public Builder setType(com.example.tutorial.AddressBookProtos.Person.PhoneType value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasType = true;
+ result.type_ = value;
+ return this;
+ }
+
+ public Builder clearType() {
+ result.hasType = false;
+ result.type_ = com.example.tutorial.AddressBookProtos.Person.PhoneType.HOME;
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:tutorial.Person.PhoneNumber)
+ }
+
+ static {
+ defaultInstance = new PhoneNumber(true);
+ com.example.tutorial.AddressBookProtos.internalForceInit();
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:tutorial.Person.PhoneNumber)
+ }
+
+ // required string name = 1;
+ public static final int NAME_FIELD_NUMBER = 1;
+ private boolean hasName;
+ private java.lang.String name_ = "";
+
+ public boolean hasName() {
+ return hasName;
+ }
+
+ public java.lang.String getName() {
+ return name_;
+ }
+
+ // required int32 id = 2;
+ public static final int ID_FIELD_NUMBER = 2;
+ private boolean hasId;
+ private int id_ = 0;
+
+ public boolean hasId() {
+ return hasId;
+ }
+
+ public int getId() {
+ return id_;
+ }
+
+ // optional string email = 3;
+ public static final int EMAIL_FIELD_NUMBER = 3;
+ private boolean hasEmail;
+ private java.lang.String email_ = "";
+
+ public boolean hasEmail() {
+ return hasEmail;
+ }
+
+ public java.lang.String getEmail() {
+ return email_;
+ }
+
+ // repeated .tutorial.Person.PhoneNumber phone = 4;
+ public static final int PHONE_FIELD_NUMBER = 4;
+ private java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> phone_ =
+ java.util.Collections.emptyList();
+
+ public java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> getPhoneList() {
+ return phone_;
+ }
+
+ public int getPhoneCount() {
+ return phone_.size();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getPhone(int index) {
+ return phone_.get(index);
+ }
+
+ private void initFields() {
+ }
+
+ public final boolean isInitialized() {
+ if (!hasName)
+ return false;
+ if (!hasId)
+ return false;
+ for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
+ if (!element.isInitialized())
+ return false;
+ }
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
+ getSerializedSize();
+ if (hasName()) {
+ output.writeString(1, getName());
+ }
+ if (hasId()) {
+ output.writeInt32(2, getId());
+ }
+ if (hasEmail()) {
+ output.writeString(3, getEmail());
+ }
+ for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
+ output.writeMessage(4, element);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1)
+ return size;
+
+ size = 0;
+ if (hasName()) {
+ size += com.google.protobuf.CodedOutputStream.computeStringSize(1, getName());
+ }
+ if (hasId()) {
+ size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, getId());
+ }
+ if (hasEmail()) {
+ size += com.google.protobuf.CodedOutputStream.computeStringSize(3, getEmail());
+ }
+ for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
+ size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, element);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseDelimitedFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static Builder newBuilder() {
+ return Builder.create();
+ }
+
+ public Builder newBuilderForType() {
+ return newBuilder();
+ }
+
+ public static Builder newBuilder(com.example.tutorial.AddressBookProtos.Person prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+
+ public Builder toBuilder() {
+ return newBuilder(this);
+ }
+
+ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> {
+ private com.example.tutorial.AddressBookProtos.Person result;
+
+ // Construct using com.example.tutorial.AddressBookProtos.Person.newBuilder()
+ private Builder() {
+ }
+
+ private static Builder create() {
+ Builder builder = new Builder();
+ builder.result = new com.example.tutorial.AddressBookProtos.Person();
+ return builder;
+ }
+
+ protected com.example.tutorial.AddressBookProtos.Person internalGetResult() {
+ return result;
+ }
+
+ public Builder clear() {
+ if (result == null) {
+ throw new IllegalStateException("Cannot call clear() after build().");
+ }
+ result = new com.example.tutorial.AddressBookProtos.Person();
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(result);
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
+ return com.example.tutorial.AddressBookProtos.Person.getDescriptor();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person getDefaultInstanceForType() {
+ return com.example.tutorial.AddressBookProtos.Person.getDefaultInstance();
+ }
+
+ public boolean isInitialized() {
+ return result.isInitialized();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person build() {
+ if (result != null && !isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return buildPartial();
+ }
+
+ private com.example.tutorial.AddressBookProtos.Person buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ if (!isInitialized()) {
+ throw newUninitializedMessageException(result).asInvalidProtocolBufferException();
+ }
+ return buildPartial();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person buildPartial() {
+ if (result == null) {
+ throw new IllegalStateException("build() has already been called on this Builder.");
+ }
+ if (result.phone_ != java.util.Collections.EMPTY_LIST) {
+ result.phone_ = java.util.Collections.unmodifiableList(result.phone_);
+ }
+ com.example.tutorial.AddressBookProtos.Person returnMe = result;
+ result = null;
+ return returnMe;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.example.tutorial.AddressBookProtos.Person) {
+ return mergeFrom((com.example.tutorial.AddressBookProtos.Person)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.example.tutorial.AddressBookProtos.Person other) {
+ if (other == com.example.tutorial.AddressBookProtos.Person.getDefaultInstance())
+ return this;
+ if (other.hasName()) {
+ setName(other.getName());
+ }
+ if (other.hasId()) {
+ setId(other.getId());
+ }
+ if (other.hasEmail()) {
+ setEmail(other.getEmail());
+ }
+ if (!other.phone_.isEmpty()) {
+ if (result.phone_.isEmpty()) {
+ result.phone_ =
+ new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
+ }
+ result.phone_.addAll(other.phone_);
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ setName(input.readString());
+ break;
+ }
+ case 16: {
+ setId(input.readInt32());
+ break;
+ }
+ case 26: {
+ setEmail(input.readString());
+ break;
+ }
+ case 34: {
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder subBuilder =
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.newBuilder();
+ input.readMessage(subBuilder, extensionRegistry);
+ addPhone(subBuilder.buildPartial());
+ break;
+ }
+ }
+ }
+ }
+
+ // required string name = 1;
+ public boolean hasName() {
+ return result.hasName();
+ }
+
+ public java.lang.String getName() {
+ return result.getName();
+ }
+
+ public Builder setName(java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasName = true;
+ result.name_ = value;
+ return this;
+ }
+
+ public Builder clearName() {
+ result.hasName = false;
+ result.name_ = getDefaultInstance().getName();
+ return this;
+ }
+
+ // required int32 id = 2;
+ public boolean hasId() {
+ return result.hasId();
+ }
+
+ public int getId() {
+ return result.getId();
+ }
+
+ public Builder setId(int value) {
+ result.hasId = true;
+ result.id_ = value;
+ return this;
+ }
+
+ public Builder clearId() {
+ result.hasId = false;
+ result.id_ = 0;
+ return this;
+ }
+
+ // optional string email = 3;
+ public boolean hasEmail() {
+ return result.hasEmail();
+ }
+
+ public java.lang.String getEmail() {
+ return result.getEmail();
+ }
+
+ public Builder setEmail(java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasEmail = true;
+ result.email_ = value;
+ return this;
+ }
+
+ public Builder clearEmail() {
+ result.hasEmail = false;
+ result.email_ = getDefaultInstance().getEmail();
+ return this;
+ }
+
+ // repeated .tutorial.Person.PhoneNumber phone = 4;
+ public java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> getPhoneList() {
+ return java.util.Collections.unmodifiableList(result.phone_);
+ }
+
+ public int getPhoneCount() {
+ return result.getPhoneCount();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getPhone(int index) {
+ return result.getPhone(index);
+ }
+
+ public Builder setPhone(int index, com.example.tutorial.AddressBookProtos.Person.PhoneNumber value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.phone_.set(index, value);
+ return this;
+ }
+
+ public Builder setPhone(int index,
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
+ result.phone_.set(index, builderForValue.build());
+ return this;
+ }
+
+ public Builder addPhone(com.example.tutorial.AddressBookProtos.Person.PhoneNumber value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ if (result.phone_.isEmpty()) {
+ result.phone_ =
+ new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
+ }
+ result.phone_.add(value);
+ return this;
+ }
+
+ public Builder addPhone(com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
+ if (result.phone_.isEmpty()) {
+ result.phone_ =
+ new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
+ }
+ result.phone_.add(builderForValue.build());
+ return this;
+ }
+
+ public Builder addAllPhone(java.lang.Iterable<? extends com.example.tutorial.AddressBookProtos.Person.PhoneNumber> values) {
+ if (result.phone_.isEmpty()) {
+ result.phone_ =
+ new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
+ }
+ super.addAll(values, result.phone_);
+ return this;
+ }
+
+ public Builder clearPhone() {
+ result.phone_ = java.util.Collections.emptyList();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:tutorial.Person)
+ }
+
+ static {
+ defaultInstance = new Person(true);
+ com.example.tutorial.AddressBookProtos.internalForceInit();
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:tutorial.Person)
+ }
+
+ public static final class AddressBook extends com.google.protobuf.GeneratedMessage {
+ // Use AddressBook.newBuilder() to construct.
+ private AddressBook() {
+ initFields();
+ }
+
+ private AddressBook(boolean noInit) {
+ }
+
+ private static final AddressBook defaultInstance;
+
+ public static AddressBook getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public AddressBook getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_AddressBook_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_AddressBook_fieldAccessorTable;
+ }
+
+ // repeated .tutorial.Person person = 1;
+ public static final int PERSON_FIELD_NUMBER = 1;
+ private java.util.List<com.example.tutorial.AddressBookProtos.Person> person_ = java.util.Collections
+ .emptyList();
+
+ public java.util.List<com.example.tutorial.AddressBookProtos.Person> getPersonList() {
+ return person_;
+ }
+
+ public int getPersonCount() {
+ return person_.size();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person getPerson(int index) {
+ return person_.get(index);
+ }
+
+ private void initFields() {
+ }
+
+ public final boolean isInitialized() {
+ for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
+ if (!element.isInitialized())
+ return false;
+ }
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
+ getSerializedSize();
+ for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
+ output.writeMessage(1, element);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1)
+ return size;
+
+ size = 0;
+ for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
+ size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, element);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseDelimitedFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static Builder newBuilder() {
+ return Builder.create();
+ }
+
+ public Builder newBuilderForType() {
+ return newBuilder();
+ }
+
+ public static Builder newBuilder(com.example.tutorial.AddressBookProtos.AddressBook prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+
+ public Builder toBuilder() {
+ return newBuilder(this);
+ }
+
+ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> {
+ private com.example.tutorial.AddressBookProtos.AddressBook result;
+
+ // Construct using com.example.tutorial.AddressBookProtos.AddressBook.newBuilder()
+ private Builder() {
+ }
+
+ private static Builder create() {
+ Builder builder = new Builder();
+ builder.result = new com.example.tutorial.AddressBookProtos.AddressBook();
+ return builder;
+ }
+
+ protected com.example.tutorial.AddressBookProtos.AddressBook internalGetResult() {
+ return result;
+ }
+
+ public Builder clear() {
+ if (result == null) {
+ throw new IllegalStateException("Cannot call clear() after build().");
+ }
+ result = new com.example.tutorial.AddressBookProtos.AddressBook();
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(result);
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
+ return com.example.tutorial.AddressBookProtos.AddressBook.getDescriptor();
+ }
+
+ public com.example.tutorial.AddressBookProtos.AddressBook getDefaultInstanceForType() {
+ return com.example.tutorial.AddressBookProtos.AddressBook.getDefaultInstance();
+ }
+
+ public boolean isInitialized() {
+ return result.isInitialized();
+ }
+
+ public com.example.tutorial.AddressBookProtos.AddressBook build() {
+ if (result != null && !isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return buildPartial();
+ }
+
+ private com.example.tutorial.AddressBookProtos.AddressBook buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ if (!isInitialized()) {
+ throw newUninitializedMessageException(result).asInvalidProtocolBufferException();
+ }
+ return buildPartial();
+ }
+
+ public com.example.tutorial.AddressBookProtos.AddressBook buildPartial() {
+ if (result == null) {
+ throw new IllegalStateException("build() has already been called on this Builder.");
+ }
+ if (result.person_ != java.util.Collections.EMPTY_LIST) {
+ result.person_ = java.util.Collections.unmodifiableList(result.person_);
+ }
+ com.example.tutorial.AddressBookProtos.AddressBook returnMe = result;
+ result = null;
+ return returnMe;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.example.tutorial.AddressBookProtos.AddressBook) {
+ return mergeFrom((com.example.tutorial.AddressBookProtos.AddressBook)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.example.tutorial.AddressBookProtos.AddressBook other) {
+ if (other == com.example.tutorial.AddressBookProtos.AddressBook.getDefaultInstance())
+ return this;
+ if (!other.person_.isEmpty()) {
+ if (result.person_.isEmpty()) {
+ result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
+ }
+ result.person_.addAll(other.person_);
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ com.example.tutorial.AddressBookProtos.Person.Builder subBuilder =
+ com.example.tutorial.AddressBookProtos.Person.newBuilder();
+ input.readMessage(subBuilder, extensionRegistry);
+ addPerson(subBuilder.buildPartial());
+ break;
+ }
+ }
+ }
+ }
+
+ // repeated .tutorial.Person person = 1;
+ public java.util.List<com.example.tutorial.AddressBookProtos.Person> getPersonList() {
+ return java.util.Collections.unmodifiableList(result.person_);
+ }
+
+ public int getPersonCount() {
+ return result.getPersonCount();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person getPerson(int index) {
+ return result.getPerson(index);
+ }
+
+ public Builder setPerson(int index, com.example.tutorial.AddressBookProtos.Person value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.person_.set(index, value);
+ return this;
+ }
+
+ public Builder setPerson(int index, com.example.tutorial.AddressBookProtos.Person.Builder builderForValue) {
+ result.person_.set(index, builderForValue.build());
+ return this;
+ }
+
+ public Builder addPerson(com.example.tutorial.AddressBookProtos.Person value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ if (result.person_.isEmpty()) {
+ result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
+ }
+ result.person_.add(value);
+ return this;
+ }
+
+ public Builder addPerson(com.example.tutorial.AddressBookProtos.Person.Builder builderForValue) {
+ if (result.person_.isEmpty()) {
+ result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
+ }
+ result.person_.add(builderForValue.build());
+ return this;
+ }
+
+ public Builder addAllPerson(java.lang.Iterable<? extends com.example.tutorial.AddressBookProtos.Person> values) {
+ if (result.person_.isEmpty()) {
+ result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
+ }
+ super.addAll(values, result.person_);
+ return this;
+ }
+
+ public Builder clearPerson() {
+ result.person_ = java.util.Collections.emptyList();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:tutorial.AddressBook)
+ }
+
+ static {
+ defaultInstance = new AddressBook(true);
+ com.example.tutorial.AddressBookProtos.internalForceInit();
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:tutorial.AddressBook)
+ }
+
+ private static com.google.protobuf.Descriptors.Descriptor internal_static_tutorial_Person_descriptor;
+ private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_tutorial_Person_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor internal_static_tutorial_Person_PhoneNumber_descriptor;
+ private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor internal_static_tutorial_AddressBook_descriptor;
+ private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_tutorial_AddressBook_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
+ return descriptor;
+ }
+
+ private static com.google.protobuf.Descriptors.FileDescriptor descriptor;
+ static {
+ java.lang.String[] descriptorData =
+ {"\n\021addressbook.proto\022\010tutorial\"\332\001\n\006Person" + "\022\014\n\004name\030\001 \002(\t\022\n\n\002id\030\002 \002(\005\022\r\n\005email\030\003 \001("
+ + "\t\022+\n\005phone\030\004 \003(\0132\034.tutorial.Person.Phone"
+ + "Number\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n"
+ + "\004type\030\002 \001(\0162\032.tutorial.Person.PhoneType:"
+ + "\004HOME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001"
+ + "\022\010\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003("
+ + "\0132\020.tutorial.PersonB)\n\024com.example.tutor"
+ + "ialB\021AddressBookProtos"};
+ com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+ new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+ public com.google.protobuf.ExtensionRegistry assignDescriptors(com.google.protobuf.Descriptors.FileDescriptor root) {
+ descriptor = root;
+ internal_static_tutorial_Person_descriptor = getDescriptor().getMessageTypes().get(0);
+ internal_static_tutorial_Person_fieldAccessorTable =
+ new com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_tutorial_Person_descriptor,
+ new java.lang.String[] {"Name",
+ "Id",
+ "Email",
+ "Phone",},
+ com.example.tutorial.AddressBookProtos.Person.class,
+ com.example.tutorial.AddressBookProtos.Person.Builder.class);
+ internal_static_tutorial_Person_PhoneNumber_descriptor =
+ internal_static_tutorial_Person_descriptor.getNestedTypes().get(0);
+ internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable =
+ new com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_tutorial_Person_PhoneNumber_descriptor,
+ new java.lang.String[] {"Number",
+ "Type",},
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.class,
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder.class);
+ internal_static_tutorial_AddressBook_descriptor = getDescriptor().getMessageTypes().get(1);
+ internal_static_tutorial_AddressBook_fieldAccessorTable =
+ new com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_tutorial_AddressBook_descriptor,
+ new java.lang.String[] {"Person",},
+ com.example.tutorial.AddressBookProtos.AddressBook.class,
+ com.example.tutorial.AddressBookProtos.AddressBook.Builder.class);
+ return null;
+ }
+ };
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {},
+ assigner);
+ }
+
+ public static void internalForceInit() {
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufTransformationTestCase.java b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufTransformationTestCase.java
new file mode 100644
index 0000000000..9fc6f30794
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufTransformationTestCase.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.sca.databinding.protobuf;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.junit.Test;
+
+import com.example.tutorial.AddressBookProtos.AddressBook;
+import com.example.tutorial.AddressBookProtos.Person;
+
+/**
+ *
+ */
+public class ProtobufTransformationTestCase {
+ @Test
+ public void testTransform() throws Exception {
+ Protobuf2OutputStream t1 = new Protobuf2OutputStream();
+ TransformationContext context = new TransformationContextImpl();
+ DataType dt1 = new DataTypeImpl(AddressBook.class, null);
+ context.setSourceDataType(dt1);
+
+ AddressBook addressBook =
+ AddressBook.newBuilder()
+ .addPerson(Person.newBuilder().setId(1).setEmail("abc@example.com").setName("John Smith").build())
+ .build();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ t1.transform(addressBook, bos, context);
+
+ InputStream2Protobuf t2 = new InputStream2Protobuf();
+ context.setSourceDataType(null);
+ context.setTargetDataType(dt1);
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ AddressBook addressBook2 = (AddressBook)t2.transform(bis, context);
+ Assert.assertEquals(addressBook, addressBook2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/resources/addressbook.proto b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/resources/addressbook.proto
new file mode 100644
index 0000000000..395320fb22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/databinding-protobuf/src/test/resources/addressbook.proto
@@ -0,0 +1,48 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// See README.txt for information and build instructions.
+
+package tutorial;
+
+option java_package = "com.example.tutorial";
+option java_outer_classname = "AddressBookProtos";
+
+message Person {
+ required string name = 1;
+ required int32 id = 2; // Unique ID number for this person.
+ optional string email = 3;
+
+ enum PhoneType {
+ MOBILE = 0;
+ HOME = 1;
+ WORK = 2;
+ }
+
+ message PhoneNumber {
+ required string number = 1;
+ optional PhoneType type = 2 [default = HOME];
+ }
+
+ repeated PhoneNumber phone = 4;
+}
+
+// Our address book file is just one of these.
+message AddressBook {
+ repeated Person person = 1;
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/LICENSE b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/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/sebastien/java/embed/contrib/modules/host-tomcat/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cab6b5057e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/META-INF/MANIFEST.MF
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.http.tomcat;version="2.0.0",org.
+ apache.tuscany.sca.http.tomcat.module;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Tomcat Servlet Host Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1222833663765
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Tomcat Servlet Host Extension
+Import-Package: javax.naming,
+ javax.naming.directory,
+ javax.servlet,
+ javax.servlet.http,
+ org.apache.catalina,
+ org.apache.catalina.connector,
+ org.apache.catalina.core,
+ org.apache.catalina.servlets,
+ org.apache.catalina.startup,
+ org.apache.coyote,
+ org.apache.coyote.http11,
+ org.apache.naming.resources,
+ org.apache.tomcat.util.buf,
+ org.apache.tomcat.util.http.mapper,
+ org.apache.tomcat.util.net,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.host.tomcat
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/NOTICE b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/pom.xml b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/pom.xml
new file mode 100644
index 0000000000..6f49551591
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/pom.xml
@@ -0,0 +1,69 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ <name>Apache Tuscany SCA Tomcat Servlet Host Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>6.0.26</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>coyote</artifactId>
+ <version>6.0.26</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java
new file mode 100644
index 0000000000..a0b384d554
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.tomcat;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+
+import org.apache.catalina.core.StandardWrapper;
+
+/**
+ * A Servlet wrapper.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServletWrapper extends StandardWrapper {
+ private static final long serialVersionUID = 1L;
+
+ private final Servlet servlet;
+
+ public ServletWrapper(Servlet servlet) {
+ this.servlet = servlet;
+ }
+
+ @Override
+ public synchronized Servlet loadServlet() {
+ return servlet;
+ }
+
+ @Override
+ public Servlet getServlet() {
+ return servlet;
+ }
+
+ public void initServlet() throws ServletException {
+ servlet.init(facade);
+ }
+
+ public void destroyServlet() {
+ servlet.destroy();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java
new file mode 100644
index 0000000000..5d9b65503a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.tomcat;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.catalina.servlets.DefaultServlet;
+import org.apache.naming.resources.FileDirContext;
+import org.apache.naming.resources.ProxyDirContext;
+import org.apache.naming.resources.Resource;
+
+/**
+ * DefaultServlet implementation for Tomcat.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TomcatDefaultServlet extends DefaultServlet {
+ private static final long serialVersionUID = -7503581551326796573L;
+
+ private String documentRoot;
+ private ProxyDirContext proxyDirContext;
+
+ public TomcatDefaultServlet(String servletPath, String documentRoot) {
+ this.documentRoot = documentRoot;
+
+ DirContext dirContext;
+ URI uri = URI.create(documentRoot);
+ if (!"file".equals(uri.getScheme())) {
+
+ dirContext = new FileDirContext() {
+ @Override
+ public Attributes getAttributes(String name) throws NamingException {
+ return new BasicAttributes();
+ }
+
+ @Override
+ public Object lookup(String name) throws NamingException {
+
+ try {
+ final URL url = new URL(TomcatDefaultServlet.this.documentRoot + name);
+ return new Resource() {
+ @Override
+ public InputStream streamContent() throws IOException {
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ return connection.getInputStream();
+ }
+ };
+ } catch (MalformedURLException e) {
+ throw new NamingException(e.toString());
+ }
+ }
+ };
+
+ } else {
+ dirContext = new FileDirContext();
+ ((FileDirContext)dirContext).setDocBase(uri.getPath());
+ }
+ proxyDirContext = new ProxyDirContext(new Hashtable(), dirContext);
+ resources = proxyDirContext;
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ resources = proxyDirContext;
+ }
+
+ @Override
+ public void init(ServletConfig servletConfig) throws ServletException {
+ super.init(servletConfig);
+ resources = proxyDirContext;
+ }
+
+ @Override
+ protected String getRelativePath(HttpServletRequest request) {
+ String path = request.getPathInfo();
+ if (path == null || path.length() == 0) {
+ path = "/";
+ }
+ return path;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
new file mode 100644
index 0000000000..d1a2e5d283
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
@@ -0,0 +1,701 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.tomcat;
+
+import java.beans.PropertyChangeListener;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.KeyStore;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Loader;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardEngine;
+import org.apache.catalina.startup.ContextConfig;
+import org.apache.catalina.startup.Embedded;
+import org.apache.coyote.http11.Http11Protocol;
+import org.apache.tomcat.util.buf.MessageBytes;
+import org.apache.tomcat.util.http.mapper.MappingData;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
+import org.apache.tuscany.sca.host.http.SecurityContext;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+/**
+ * A Tomcat based implementation of ServletHost.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TomcatServer implements ServletHost, LifeCycleListener {
+ private static final Logger logger = Logger.getLogger(TomcatServer.class.getName());
+
+ private WorkScheduler workScheduler;
+ private Embedded embedded;
+ private Map<Integer, Port> ports = new HashMap<Integer, Port>();
+ private String contextPath = "/";
+ private int defaultPort = 8080;
+ private int defaultSSLPort = 8443;
+
+ private final class TuscanyLoader implements Loader {
+ private final ClassLoader tccl;
+ private boolean delegate;
+ private boolean reloadable;
+ private Container container;
+ private List<String> repos = new ArrayList<String>();
+ private List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
+
+ private TuscanyLoader(ClassLoader tccl) {
+ this.tccl = tccl;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ listeners.add(listener);
+ }
+
+ public void addRepository(String repository) {
+ repos.add(repository);
+ }
+
+ public void backgroundProcess() {
+ }
+
+ public String[] findRepositories() {
+ return repos.toArray(new String[repos.size()]);
+ }
+
+ public Container getContainer() {
+ return container;
+ }
+
+ public boolean getDelegate() {
+ return delegate;
+ }
+
+ public String getInfo() {
+ return "Tuscany Loader for Embedded Tomcat";
+ }
+
+ public boolean getReloadable() {
+ return reloadable;
+ }
+
+ public boolean modified() {
+ return false;
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void setContainer(Container container) {
+ this.container = container;
+ }
+
+ public void setDelegate(boolean delegate) {
+ this.delegate = delegate;
+ }
+
+ public void setReloadable(boolean reloadable) {
+ this.reloadable = reloadable;
+ }
+
+ public ClassLoader getClassLoader() {
+ return tccl;
+ }
+ }
+
+ /**
+ * Represents a port and the server that serves it.
+ */
+ private class Port {
+ private Engine engine;
+ private Host host;
+ private Connector connector;
+
+ private Port(Engine engine, Host host, Connector connector) {
+ this.engine = engine;
+ this.host = host;
+ this.connector = connector;
+ }
+
+ public Engine getEngine() {
+ return engine;
+ }
+
+ public Host getHost() {
+ return host;
+ }
+
+ public Connector getConnector() {
+ return connector;
+ }
+ }
+
+ /**
+ * Constructs a new embedded Tomcat server.
+ *
+ */
+ public TomcatServer(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.workScheduler = utilities.getUtility(WorkScheduler.class);
+ String port = attributes.get("defaultPort");
+ if (port != null) {
+ defaultPort = Integer.parseInt(port);
+ }
+ String sslPort = attributes.get("defaultSSLPort");
+ if (sslPort != null) {
+ defaultPort = Integer.parseInt(sslPort);
+ }
+ if (attributes.containsKey("contextPath")) {
+ contextPath = attributes.get("contextPath");
+ }
+ }
+
+ protected TomcatServer(WorkScheduler workScheduler) {
+ this.workScheduler = workScheduler;
+ }
+
+ public void setDefaultPort(int port) {
+ defaultPort = port;
+ }
+
+ public int getDefaultPort() {
+ return defaultPort;
+ }
+
+ /**
+ * Stop all the started servers.
+ */
+ public void stop() {
+ if (embedded != null) {
+ try {
+ // embedded.stop();
+ embedded.destroy();
+ for (Port port : ports.values()) {
+ port.connector.stop();
+ }
+ } catch (LifecycleException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ public synchronized String addServletMapping(String suri, Servlet servlet) {
+ init();
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ final int portNumber = (uri.getPort() == -1 ? defaultPort : uri.getPort());
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+
+ port = createInstance(scheme, portNumber);
+ ports.put(portNumber, port);
+ }
+
+ // Register the Servlet mapping
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ ServletWrapper wrapper;
+ if (servlet instanceof DefaultResourceServlet) {
+ String defaultServletPath = path;
+
+ // Optimize the handling of resource requests, use the Tomcat default Servlet
+ // instead of our default resource Servlet
+ if (defaultServletPath.endsWith("*")) {
+ defaultServletPath = defaultServletPath.substring(0, defaultServletPath.length() - 1);
+ }
+ if (defaultServletPath.endsWith("/")) {
+ defaultServletPath = defaultServletPath.substring(0, defaultServletPath.length() - 1);
+ }
+ DefaultResourceServlet resourceServlet = (DefaultResourceServlet)servlet;
+ TomcatDefaultServlet defaultServlet =
+ new TomcatDefaultServlet(defaultServletPath, resourceServlet.getDocumentRoot());
+ wrapper = new ServletWrapper(defaultServlet);
+
+ } else {
+ wrapper = new ServletWrapper(servlet);
+ }
+ Context context = port.getHost().map(path);
+ wrapper.setName(path);
+ wrapper.addMapping(path);
+ context.addChild(wrapper);
+ context.addServletMapping(path, path);
+ port.getConnector().getMapper().addWrapper("localhost", "", path, wrapper);
+
+ // Initialize the Servlet
+ try {
+ wrapper.initServlet();
+ } catch (ServletException e) {
+ throw new ServletMappingException(e);
+ }
+
+ // Compute the complete URL
+ String host;
+ try {
+ host = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+ URL addedURL;
+ try {
+ addedURL = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ logger.info("Added Servlet mapping: " + addedURL);
+ return addedURL.toString();
+ }
+
+ private Port createInstance(String scheme, final int portNumber) {
+ Port port;
+ // Create an engine
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ final Engine engine = AccessController.doPrivileged(new PrivilegedAction<Engine>() {
+ public Engine run() {
+ return embedded.createEngine();
+ }
+ });
+
+ ((StandardEngine)engine).setBaseDir("");
+ engine.setDefaultHost("localhost");
+ engine.setName("engine/" + portNumber);
+
+ // Create a host
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ final Host host = AccessController.doPrivileged(new PrivilegedAction<Host>() {
+ public Host run() {
+ Host host = embedded.createHost("localhost", "");
+ engine.addChild(host);
+ return host;
+ }
+ });
+
+ // Create the root context
+ Context context = embedded.createContext("", "");
+ final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ context.setLoader(new TuscanyLoader(tccl));
+ // context.setParentClassLoader(tccl.getParent());
+ ContextConfig config = new ContextConfig();
+ ((Lifecycle)context).addLifecycleListener(config);
+ host.addChild(context);
+
+ embedded.addEngine(engine);
+
+ // Install an HTTP connector
+
+ Connector connector;
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ try {
+ final String protocol = scheme;
+ connector = AccessController.doPrivileged(new PrivilegedExceptionAction<Connector>() {
+ public Connector run() throws Exception {
+ Connector customConnector = new Connector();
+ customConnector.setPort(portNumber);
+
+ if ("https".equalsIgnoreCase(protocol)) {
+ configureSSL(customConnector);
+ ((Http11Protocol)customConnector.getProtocolHandler()).setSSLEnabled(true);
+ }
+ return customConnector;
+ }
+
+ private void configureSSL(Connector customConnector) {
+ String trustStore = System.getProperty("javax.net.ssl.trustStore");
+ String trustStorePass = System.getProperty("javax.net.ssl.trustStorePassword");
+ String keyStore = System.getProperty("javax.net.ssl.keyStore");
+ String keyStorePass = System.getProperty("javax.net.ssl.keyStorePassword");
+
+ customConnector.setProperty("protocol", "TLS");
+
+ customConnector.setProperty("keystore", keyStore);
+ customConnector.setProperty("keypass", keyStorePass);
+ String keyStoreType = System.getProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType());
+ String trustStoreType =
+ System.getProperty("javax.net.ssl.trustStoreType", KeyStore.getDefaultType());
+ customConnector.setProperty("keytype", keyStoreType);
+ customConnector.setProperty("trusttype", trustStoreType);
+ customConnector.setProperty("truststore", trustStore);
+ customConnector.setProperty("trustpass", trustStorePass);
+
+ customConnector.setProperty("clientauth", "false");
+ customConnector.setProtocol("HTTP/1.1");
+ customConnector.setScheme(protocol);
+ customConnector.setProperty("backlog", "10");
+ customConnector.setSecure(true);
+ }
+ });
+ } catch (Exception e) {
+ throw new ServletMappingException(e);
+ }
+
+ embedded.addConnector(connector);
+ try {
+ connector.start();
+ } catch (LifecycleException e) {
+ throw new ServletMappingException(e);
+ }
+
+ // Keep track of the running server
+ port = new Port(engine, host, connector);
+ return port;
+ }
+
+ private synchronized void init() {
+ if (embedded != null) {
+ return;
+ }
+ embedded = new Embedded();
+ embedded.setAwait(true);
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws LifecycleException {
+ embedded.start();
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ // throw (LifecycleException)e.getException();
+ throw new ServletMappingException(e);
+ }
+ }
+
+ public URL getURLMapping(String suri) throws ServletMappingException {
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPort;
+ }
+
+ // Get the host
+ String host;
+ try {
+ host = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+
+ // Construct the URL
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+ URL url;
+ try {
+ url = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ return url;
+ }
+
+ public Servlet getServletMapping(String suri) throws ServletMappingException {
+
+ if (suri == null) {
+ return null;
+ }
+
+ URI uri = URI.create(suri);
+
+ // Get the URI port
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPort;
+ }
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+ return null;
+ }
+
+ String mapping = uri.getPath();
+
+ if (!mapping.startsWith("/")) {
+ mapping = '/' + mapping;
+ }
+
+ if (!mapping.startsWith(contextPath)) {
+ mapping = contextPath + mapping;
+ }
+
+ final Context context = port.getHost().map(mapping);
+ final MappingData md = new MappingData();
+ final MessageBytes mb = MessageBytes.newInstance();
+ mb.setString(mapping);
+ try {
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ context.getMapper().map(mb, md);
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ return null;
+ }
+ if (md.wrapper instanceof ServletWrapper) {
+ ServletWrapper servletWrapper = (ServletWrapper)md.wrapper;
+ return servletWrapper.getServlet();
+ } else {
+ return null;
+ }
+ }
+
+ public synchronized Servlet removeServletMapping(String suri) {
+ URI uri = URI.create(suri);
+
+ // Get the URI port
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPort;
+ }
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+ throw new IllegalStateException("No servlet registered at this URI: " + suri);
+ }
+
+ String mapping = uri.getPath();
+
+ if (!mapping.startsWith("/")) {
+ mapping = '/' + mapping;
+ }
+
+ if (!mapping.startsWith(contextPath)) {
+ mapping = contextPath + mapping;
+ }
+
+ final Context context = port.getHost().map(mapping);
+ final MappingData md = new MappingData();
+ final MessageBytes mb = MessageBytes.newInstance();
+ mb.setString(mapping);
+ try {
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ context.getMapper().map(mb, md);
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ return null;
+ }
+ if (md.wrapper instanceof ServletWrapper) {
+ ServletWrapper servletWrapper = (ServletWrapper)md.wrapper;
+
+ port.getConnector().getMapper().removeWrapper("localhost", "", mapping);
+
+ try {
+ context.removeServletMapping(mapping);
+ } catch (NegativeArraySizeException e) {
+ // JIRA TUSCANY-1599
+ // FIXME Looks like a bug in Tomcat when removing the last
+ // Servlet in the list, catch the exception for now as it doesn't
+ // seem harmful, will find a better solution for the next release
+ }
+ context.removeChild(servletWrapper);
+ try {
+ servletWrapper.destroyServlet();
+ } catch (Exception ex) {
+ // Hack to handle destruction of Servlets without Servlet context
+ }
+
+ logger.info("Removed Servlet mapping: " + suri);
+
+ // Stop the port if there's no servlets on it anymore
+ String[] contextNames = port.getConnector().getMapper().getContextNames();
+ if (contextNames == null || contextNames.length == 0) {
+ try {
+ port.getConnector().stop();
+ ((StandardEngine)port.getEngine()).stop();
+ embedded.removeEngine(port.getEngine());
+ embedded.removeConnector(port.getConnector());
+ ports.remove(portNumber);
+ } catch (LifecycleException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ return servletWrapper.getServlet();
+ } else {
+ logger.warning("Trying to Remove servlet mapping: " + mapping + " where mapping is not registered");
+ return null;
+ }
+ }
+
+ public RequestDispatcher getRequestDispatcher(String suri) throws ServletMappingException {
+ //FIXME implement this later
+ return null;
+ }
+
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ public void setContextPath(String path) {
+ this.contextPath = path;
+ }
+
+ public void start() {
+
+ }
+
+ public String addServletMapping(String uri, Servlet servlet, SecurityContext securityContext)
+ throws ServletMappingException {
+ return addServletMapping(uri, servlet);
+ }
+
+ public String getName() {
+ return "tomcat";
+ }
+
+ public URL getURLMapping(String arg0, SecurityContext arg1) {
+ return null;
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ }
+
+ private URL map(String suri, SecurityContext securityContext, boolean resolve) throws ServletMappingException {
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = null;
+ if (securityContext != null && securityContext.isSSLEnabled()) {
+ scheme = "https";
+ } else {
+ scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ }
+
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ if ("http".equals(scheme)) {
+ portNumber = defaultPort;
+ } else {
+ portNumber = defaultSSLPort;
+ }
+ }
+
+ // Get the host
+ String host = uri.getHost();
+ if (host == null) {
+ host = "0.0.0.0";
+ if (resolve) {
+ try {
+ host = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+ }
+ }
+
+ // Construct the URL
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ URL url;
+ try {
+ url = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ return url;
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ if (ports.isEmpty()) {
+ return null;
+ } else {
+ Port port = ports.values().iterator().next();
+ return port.getHost().map(getContextPath()).getServletContext();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
new file mode 100644
index 0000000000..00350bbf6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
@@ -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 ServletHost
+org.apache.tuscany.sca.http.tomcat.TomcatServer;name=tomcat,ranking=50,defaultPort=8085
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java
new file mode 100644
index 0000000000..4bcf0623e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java
@@ -0,0 +1,372 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.tomcat;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
+import org.apache.tuscany.sca.host.http.ExtensibleServletHost;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.work.NotificationListener;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TomcatServerTestCase extends TestCase {
+
+ private static final String REQUEST1_HEADER =
+ "GET /foo HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST1_CONTENT = "";
+ private static final String REQUEST1 =
+ REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT;
+
+ private static final String REQUEST2_HEADER =
+ "GET /webcontent/test.html HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST2_CONTENT = "";
+ private static final String REQUEST2 =
+ REQUEST2_HEADER + REQUEST2_CONTENT.getBytes().length + "\n\n" + REQUEST2_CONTENT;
+
+ private static final int HTTP_PORT = 8085;
+
+ private WorkScheduler workScheduler = new WorkScheduler() {
+
+ public <T extends Runnable> void scheduleWork(T work) {
+ Thread thread = new Thread(work);
+ thread.start();
+ }
+
+ public <T extends Runnable> void scheduleWork(T work, NotificationListener<T> listener) {
+ scheduleWork(work);
+ }
+
+ public void destroy() {
+ }
+ };
+
+ /**
+ * Verifies requests are properly routed according to the Servlet mapping
+ */
+ public void testRegisterServletMapping() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ ServletContext servletContext = service.getServletContext();
+ Assert.assertNotNull(servletContext);
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.stop();
+ assertTrue(servlet.invoked);
+ }
+
+ /**
+ * Verifies requests are properly routed according to the Servlet mapping
+ */
+ public void testRegisterServletMappingSSL() throws Exception {
+ System.setProperty("javax.net.ssl.keyStore", "target/test-classes/tuscany.keyStore");
+ System.setProperty("javax.net.ssl.keyStorePassword", "apache");
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ try {
+ service.addServletMapping("https://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ } finally {
+ System.clearProperty("javax.net.ssl.keyStore");
+ System.clearProperty("javax.net.ssl.keyStorePassword");
+ }
+ System.setProperty("javax.net.ssl.trustStore", "target/test-classes/tuscany.keyStore");
+ System.setProperty("javax.net.ssl.trustStorePassword", "apache");
+ URL url = new URL("https://127.0.0.1:8085/foo");
+ HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
+ conn.setHostnameVerifier(new HostnameVerifier() {
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }}
+ );
+
+ conn.connect();
+ read(conn.getInputStream());
+
+ service.stop();
+ assertTrue(servlet.invoked);
+
+ }
+ /**
+ * Verifies that Servlets can be registered with multiple ports
+ */
+ public void testRegisterMultiplePorts() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/", servlet);
+ TestServlet servlet2 = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + (HTTP_PORT + 1) + "/", servlet2);
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT + 1);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+
+ service.stop();
+ assertTrue(servlet.invoked);
+ assertTrue(servlet2.invoked);
+ }
+
+ public void testUnregisterMapping() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ service.removeServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo");
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.stop();
+ assertFalse(servlet.invoked);
+
+ }
+
+ public void testRegisterUnregisterMapping() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ assertTrue(servlet.invoked);
+ service.removeServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo");
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ assertTrue(servlet.invoked);
+ service.stop();
+ }
+
+ public void testRequestSession() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.stop();
+ assertTrue(servlet.invoked);
+ assertNotNull(servlet.sessionId);
+ }
+
+ public void testRestart() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ service.stop();
+ service.stop();
+ }
+
+ public void testNoMappings() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ Exception ex = null;
+ try {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ } catch (Exception e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ service.stop();
+ }
+
+ public void testResourceServlet() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+
+ String documentRoot = getClass().getClassLoader().getResource("content/test.html").toString();
+ documentRoot = documentRoot.substring(0, documentRoot.lastIndexOf('/'));
+ DefaultResourceServlet resourceServlet = new DefaultResourceServlet(documentRoot);
+ TestResourceServlet servlet = new TestResourceServlet(resourceServlet);
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/webcontent/*", servlet);
+
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST2.getBytes());
+ os.flush();
+
+ String document = read(client);
+ assertTrue(document.indexOf("<body><p>hello</body>") != -1);
+
+ service.stop();
+ }
+
+ public void testDefaultServlet() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+
+ String documentRoot = getClass().getClassLoader().getResource("content/test.html").toString();
+ documentRoot = documentRoot.substring(0, documentRoot.lastIndexOf('/'));
+ DefaultResourceServlet resourceServlet = new DefaultResourceServlet(documentRoot);
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/webcontent/*", resourceServlet);
+
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST2.getBytes());
+ os.flush();
+
+ String document = read(client);
+ assertTrue(document.indexOf("<body><p>hello</body>") != -1);
+
+ service.stop();
+ }
+
+ private static String read(Socket socket) throws IOException {
+ InputStream is = socket.getInputStream();
+ return read(is);
+ }
+
+ private static String read(InputStream is) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+ private class TestServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ boolean invoked;
+ String sessionId;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ invoked = true;
+ sessionId = req.getSession().getId();
+ OutputStream writer = resp.getOutputStream();
+ try {
+ writer.write("result".getBytes());
+ } finally {
+ writer.close();
+ }
+ }
+
+ }
+
+ private class TestResourceServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ private HttpServlet delegate;
+
+ public TestResourceServlet(HttpServlet delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ delegate.init();
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init();
+ delegate.init(config);
+ }
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ delegate.service(req, resp);
+ }
+
+ @Override
+ public void destroy() {
+ super.destroy();
+ delegate.destroy();
+ }
+ }
+
+ @Test
+ public void testDiscovery() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ExtensibleServletHost host = ExtensibleServletHost.getInstance(registry);
+ ServletHost me = host.getDefaultServletHost();
+ Assert.assertEquals("tomcat", me.getName());
+ Assert.assertEquals(8085, me.getDefaultPort());
+ registry.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/resources/content/test.html b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/resources/content/test.html
new file mode 100644
index 0000000000..f4b79d7f01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/resources/content/test.html
@@ -0,0 +1,21 @@
+<html>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<body><p>hello</body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/resources/tuscany.keyStore b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/resources/tuscany.keyStore
new file mode 100644
index 0000000000..7ea23f7ff4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/host-tomcat/src/test/resources/tuscany.keyStore
Binary files differ
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/LICENSE b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/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/sebastien/java/embed/contrib/modules/implementation-spring-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b598607625
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,63 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring.xml;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.injection;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.springframework.beans;version="3.0.2.RELEASE",
+ org.springframework.beans.factory;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.annotation;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.config;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.support;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.xml;version="3.0.2.RELEASE",
+ org.springframework.context;version="3.0.2.RELEASE",
+ org.springframework.context.support;version="3.0.2.RELEASE",
+ org.springframework.core;version="3.0.2.RELEASE",
+ org.springframework.core.io;version="3.0.2.RELEASE",
+ org.springframework.util;version="3.0.2.RELEASE"
+Export-Package: org.apache.tuscany.sca.implementation.spring.context;version="2.0.0";
+ uses:="org.springframework.beans.factory.support,
+ org.springframework.context.support,
+ org.springframework.core.io,
+ org.apache.tuscany.sca.implementation.spring,
+ org.springframework.context,
+ org.apache.tuscany.sca.implementation.spring.provider,
+ org.springframework.beans.factory.config,
+ org.springframework.beans.factory"
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/NOTICE b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/pom.xml b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/pom.xml
new file mode 100644
index 0000000000..b08e1c8930
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/pom.xml
@@ -0,0 +1,81 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Runtime Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Spring dependencies... -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAGenericApplicationContext.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAGenericApplicationContext.java
new file mode 100644
index 0000000000..44a3ee2b88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAGenericApplicationContext.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.sca.implementation.spring.context;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement;
+import org.apache.tuscany.sca.implementation.spring.SpringPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.ConstructorArgumentValues;
+import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
+import org.springframework.beans.factory.config.TypedStringValue;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SCAGenericApplicationContext extends GenericApplicationContext {
+
+ private ClassLoader classloader = null;
+ private List<SpringSCAPropertyElement> propertyElements = new ArrayList<SpringSCAPropertyElement>();
+ private List<SpringSCAServiceElement> serviceElements = new ArrayList<SpringSCAServiceElement>();
+ private List<SpringSCAReferenceElement> referenceElements = new ArrayList<SpringSCAReferenceElement>();
+ private List<SpringBeanElement> beanElements;
+
+ public SCAGenericApplicationContext(DefaultListableBeanFactory beanFactory,
+ ApplicationContext parent,
+ ClassLoader classloader) {
+ super(beanFactory, parent);
+ this.classloader = classloader;
+ }
+
+ public SCAGenericApplicationContext(ApplicationContext parent, ClassLoader classloader) {
+ super(parent);
+ this.classloader = classloader;
+ }
+
+ @Override
+ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
+ beanFactory.setBeanClassLoader(classloader);
+ }
+
+ public void addSCAPropertyElement(SpringSCAPropertyElement propertyElement) {
+ propertyElements.add(propertyElement);
+ }
+
+ public void addSCAServiceElement(SpringSCAServiceElement serviceElement) {
+ serviceElements.add(serviceElement);
+ }
+
+ public void addSCAReferenceElement(SpringSCAReferenceElement referenceElement) {
+ referenceElements.add(referenceElement);
+ }
+
+ public synchronized List<SpringBeanElement> getBeanElements() {
+ if (beanElements == null) {
+ beanElements = new ArrayList<SpringBeanElement>();
+ for (String name : getBeanDefinitionNames()) {
+ BeanDefinition def = getBeanDefinition(name);
+ SpringBeanElement beanElement = new SpringBeanElement(name, def.getBeanClassName());
+ beanElements.add(beanElement);
+ beanElement.setAbstractBean(def.isAbstract());
+ beanElement.setFactoryBeanAttribute(def.getFactoryBeanName() != null);
+ beanElement.setFactoryMethodAttribute(def.getFactoryMethodName() != null);
+ beanElement.setParentAttribute(def.getParentName() != null);
+ beanElement.setInnerBean(beanElement.getId() == null);
+
+ ConstructorArgumentValues args = def.getConstructorArgumentValues();
+ for (Map.Entry<Integer, ValueHolder> e: args.getIndexedArgumentValues().entrySet()) {
+ ValueHolder holder = e.getValue();
+ SpringConstructorArgElement arg = new SpringConstructorArgElement(holder.getType());
+ arg.setIndex(e.getKey());
+ beanElement.addCustructorArgs(arg);
+ }
+
+ MutablePropertyValues values = def.getPropertyValues();
+ for (PropertyValue p : values.getPropertyValueList()) {
+ SpringPropertyElement propertyElement = new SpringPropertyElement(p.getName());
+ Object value = p.getValue();
+ configurePropertyElement(propertyElement, value);
+ beanElement.getProperties().add(propertyElement);
+ }
+ }
+ }
+ return beanElements;
+ }
+
+ public void configurePropertyElement(SpringPropertyElement propertyElement, Object value) {
+ if (value instanceof BeanReference) {
+ BeanReference beanRef = (BeanReference)value;
+ propertyElement.addRef(beanRef.getBeanName());
+ } else if (value instanceof Collection) {
+ Collection collection = (Collection)value;
+ for (Object item : collection) {
+ configurePropertyElement(propertyElement, item);
+ }
+ } else if (value instanceof TypedStringValue) {
+ TypedStringValue stringValue = (TypedStringValue)value;
+ propertyElement.addValue(stringValue.getValue());
+ } else {
+ if (value != null) {
+ propertyElement.addValue(value.toString());
+ }
+ }
+ }
+
+ public List<SpringSCAPropertyElement> getPropertyElements() {
+ return propertyElements;
+ }
+
+ public List<SpringSCAServiceElement> getServiceElements() {
+ return serviceElements;
+ }
+
+ public List<SpringSCAReferenceElement> getReferenceElements() {
+ return referenceElements;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAParentApplicationContext.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAParentApplicationContext.java
new file mode 100644
index 0000000000..cd81facc3d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAParentApplicationContext.java
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.spring.provider.SpringImplementationWrapper;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.MessageSourceResolvable;
+import org.springframework.context.NoSuchMessageException;
+import org.springframework.core.io.Resource;
+
+/**
+ * A Spring ParentApplicationContext for a given Spring Implementation
+ *
+ * The Parent application context is responsible for handling those entities within a Spring
+ * application context that actually belong to SCA rather than to Spring. The principal things
+ * are Properties and References. These may be present either through explicit <sca:property/>
+ * and <sca:reference/> elements in the application context or they may be implicit through
+ * unresolved Spring bean <property.../> elements. In either case, it is the Parent application
+ * context that must provide Spring beans that correspond to the property or reference, as derived
+ * from the SCA composite in which the Spring application context is an implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAParentApplicationContext implements ApplicationContext {
+
+ // The Spring implementation for which this is the parent application context
+ private SpringImplementationWrapper implementation;
+
+ private static final String[] EMPTY_ARRAY = new String[0];
+
+ public SCAParentApplicationContext(SpringImplementationWrapper implementation) {
+ this.implementation = implementation;
+ } // end constructor
+
+ public Object getBean(String name) throws BeansException {
+ return getBean(name, (Class)null);
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class requiredType) throws BeansException {
+ Object bean = implementation.getBean(name, requiredType);
+ if (bean == null && getParent() != null) {
+ bean = getParent().getBean(name, requiredType);
+ }
+ if (bean == null) {
+ throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name);
+ } else {
+ return bean;
+ }
+ } // end method getBean( String, Class )
+
+ public Object getBean(String name, Object[] args) throws BeansException {
+ return getBean(name, ((Class)null));
+ }
+
+ public <T> T getBean(Class<T> clazz) throws BeansException {
+ return clazz.cast(getBean(clazz.getName(), clazz));
+ }
+
+ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> clazz) throws BeansException {
+ return null;
+ }
+
+ public <A extends Annotation> A findAnnotationOnBean(String arg0, Class<A> clazz) {
+ return null;
+ }
+
+ public boolean containsBean(String name) {
+ // TODO
+ return false;
+ }
+
+ public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+ // TODO
+ return false;
+ }
+
+ public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class getType(String name) throws NoSuchBeanDefinitionException {
+ return null;
+ }
+
+ public String[] getAliases(String name) throws NoSuchBeanDefinitionException {
+ return EMPTY_ARRAY;
+ }
+
+ public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
+ return null;
+ }
+
+ public String getId() {
+ return this.toString();
+ }
+
+ public String getDisplayName() {
+ return implementation.getURI();
+ }
+
+ public long getStartupDate() {
+ return 0;
+ }
+
+ public boolean containsBeanDefinition(String beanName) {
+ return false;
+ }
+
+ public int getBeanDefinitionCount() {
+ return 0;
+ }
+
+ public String[] getBeanDefinitionNames() {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type) {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean includeFactoryBeans) {
+ return new String[0];
+ }
+
+ public Map getBeansOfType(Class type) throws BeansException {
+ return null;
+ }
+
+ public Map getBeansOfType(Class type, boolean includePrototypes, boolean includeFactoryBeans) throws BeansException {
+ return null;
+ }
+
+ public boolean isPrototype(String theString) {
+ return false;
+ }
+
+ public BeanFactory getParentBeanFactory() {
+ return null;
+ }
+
+ public boolean containsLocalBean(String name) {
+ return false;
+ }
+
+ public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
+ return null;
+ }
+
+ public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public void publishEvent(ApplicationEvent event) {
+
+ }
+
+ public Resource[] getResources(String locationPattern) throws IOException {
+ return new Resource[0];
+ }
+
+ public Resource getResource(String location) {
+ return null;
+ }
+
+ public ClassLoader getClassLoader() {
+ // REVIEW: this is almost certainly flawed, but it's not clear how the SCA runtime's
+ // resource loading mechanism is exposed right now.
+ return this.getClass().getClassLoader();
+ }
+
+ @Override
+ public ApplicationContext getParent() {
+ return implementation.getParentApplicationContext();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java
new file mode 100644
index 0000000000..2d18b5aa6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.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.implementation.spring.context;
+
+import org.springframework.context.ApplicationContext;
+
+/**
+ * A utility to receive the parent Spring application context
+ */
+public interface SpringApplicationContextAccessor {
+ /**
+ * Get the parent Spring application context for the hosting environment. This will be used as the parent
+ * application context for implementation.spring components
+ * @return The parent application context
+ */
+ ApplicationContext getParentApplicationContext();
+
+ /**
+ * Set the root Spring application context. This is particually useful for Spring web integration where Spring
+ * creates WebApplicationContext and keeps it in the ServletContext
+ * @param parentApplicationContext The parent application context
+ */
+ void setParentApplicationContext(ApplicationContext parentApplicationContext);
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringContextWrapper.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringContextWrapper.java
new file mode 100644
index 0000000000..4b0ad72972
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringContextWrapper.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.spring.processor.ComponentNameAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.ConstructorAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.InitDestroyAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.PropertyAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.ReferenceAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.provider.ComponentWrapper;
+import org.apache.tuscany.sca.implementation.spring.provider.PropertyValueWrapper;
+import org.apache.tuscany.sca.implementation.spring.provider.SpringImplementationWrapper;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * This is the runtime side tie for the corresponding tuscany side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextStub class
+ * in the implementation-spring module for what the stub does.
+ */
+public class SpringContextWrapper {
+
+ private GenericApplicationContext springContext;
+ private SpringImplementationWrapper implementation;
+
+ public SpringContextWrapper(SpringImplementationWrapper implementation, List<URL> resource) {
+ this.implementation = implementation;
+ SCAParentApplicationContext scaParentContext = new SCAParentApplicationContext(implementation);
+ springContext = createApplicationContext(scaParentContext, resource);
+ }
+
+ public ApplicationContext getApplicationContext() {
+ return springContext;
+ }
+
+ public void start() {
+ // Do refresh here to ensure that Spring Beans are not touched before the SCA config process is complete...
+ springContext.refresh();
+ springContext.start();
+ }
+
+ public void close() {
+ springContext.close();
+ if (springContext instanceof GenericApplicationContext) {
+ springContext.stop();
+ }
+ }
+
+ /**
+ * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ */
+ private GenericApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext,
+ List<URL> resources) {
+
+ GenericApplicationContext appCtx =
+ new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader());
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+ xmlReader.setBeanClassLoader(implementation.getClassLoader());
+ includeAnnotationProcessors(appCtx.getBeanFactory());
+ return appCtx;
+
+ }
+
+ public Object getBean(String id) throws BeansException {
+ return springContext.getBean(id);
+ }
+
+ /**
+ * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ */
+ private void includeAnnotationProcessors(ConfigurableListableBeanFactory beanFactory) {
+
+ // Processor to deal with @Init and @Destroy SCA Annotations
+ BeanPostProcessor initDestroyProcessor = new InitDestroyAnnotationProcessor();
+ beanFactory.addBeanPostProcessor(initDestroyProcessor);
+
+ // Processor to deal with @Reference SCA Annotations
+ ComponentWrapper component = implementation.getComponentWrapper();
+ BeanPostProcessor referenceProcessor = new ReferenceAnnotationProcessor(component);
+ beanFactory.addBeanPostProcessor(referenceProcessor);
+
+ // Processor to deal with @Property SCA Annotations
+ PropertyValueWrapper pvs = implementation.getPropertyValueWrapper();
+ BeanPostProcessor propertyProcessor = new PropertyAnnotationProcessor(pvs);
+ beanFactory.addBeanPostProcessor(propertyProcessor);
+
+ // Processor to deal with @ComponentName SCA Annotations
+ BeanPostProcessor componentNameProcessor =
+ new ComponentNameAnnotationProcessor(implementation.getComponentName());
+ beanFactory.addBeanPostProcessor(componentNameProcessor);
+
+ // Processor to deal with @Constructor SCA Annotations
+ BeanPostProcessor constructorProcessor = new ConstructorAnnotationProcessor();
+ beanFactory.addBeanPostProcessor(constructorProcessor);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
new file mode 100644
index 0000000000..75e00007f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.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.sca.implementation.spring.namespace;
+
+import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.NamespaceHandler;
+
+/**
+ * Overrides the default Spring namespace resolver to automatically register
+ * {@link ScaNamespaceHandler} instead of requiring a value to be supplied in a
+ * Spring configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCANamespaceHandlerResolver extends DefaultNamespaceHandlerResolver {
+ private static final String SCA_NAMESPACE = "http://www.springframework.org/schema/sca";
+
+ private ScaNamespaceHandler handler;
+
+ public SCANamespaceHandlerResolver(ClassLoader classLoader) {
+ super(classLoader);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ public SCANamespaceHandlerResolver(String handlerMappingsLocation, ClassLoader classLoader) {
+ super(classLoader, handlerMappingsLocation);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ @Override
+ public NamespaceHandler resolve(String namespaceUri) {
+ if (SCA_NAMESPACE.equals(namespaceUri)) {
+ return handler;
+ }
+ return super.resolve(namespaceUri);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
new file mode 100644
index 0000000000..89c87ad1d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ * Handler for the &lt;sca:&gt; namespace in an application context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaNamespaceHandler extends NamespaceHandlerSupport {
+
+ public ScaNamespaceHandler() {
+ }
+
+ @Override
+ public void init() {
+ registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+ registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+ registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
new file mode 100644
index 0000000000..bff0aa84e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ * @version $Rev$ $Date$
+ */
+public class ScaPropertyBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAPropertyElement propertyElement =
+ new SpringSCAPropertyElement(element.getAttributeNS(null, "name"), element.getAttributeNS(null, "type"));
+ context.addSCAPropertyElement(propertyElement);
+ }
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
new file mode 100644
index 0000000000..6cb4978a47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaReferenceBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAReferenceElement referenceElement =
+ new SpringSCAReferenceElement(element.getAttributeNS(null, "name"),
+ element.getAttributeNS(null, "type"));
+ referenceElement.setDefaultBean(element.getAttributeNS(null, "default"));
+ context.addSCAReferenceElement(referenceElement);
+ }
+
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
new file mode 100644
index 0000000000..e5eabd2a4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:service/&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaServiceBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAServiceElement serviceElement =
+ new SpringSCAServiceElement(element.getAttributeNS(null, "name"),
+ element.getAttributeNS(null, "target"));
+ serviceElement.setType(element.getAttributeNS(null, "type"));
+ context.addSCAServiceElement(serviceElement);
+ }
+ // do nothing, handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
new file mode 100644
index 0000000000..68d49bbc24
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.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.implementation.spring.processor;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.ref.Reference;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.ComponentName;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
+
+ private String componentName;
+
+ public ComponentNameAnnotationProcessor(String componentName) {
+ this.componentName = componentName;
+ }
+
+ /**
+ * Gets componentName annotation type.
+ */
+ protected Class<? extends Annotation> getComponentNameAnnotationType() {
+ return this.componentNameAnnotationType;
+ }
+
+ /**
+ * Sets componentName annotation type.
+ */
+ public void setComponentNameAnnotationType(Class<? extends Annotation> componentNameAnnotationType) {
+ Assert.notNull(componentNameAnnotationType, "'componentNameAnnotationType' type must not be null.");
+ this.componentNameAnnotationType = componentNameAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+ Annotation annotation = field.getAnnotation(getComponentNameAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on static fields");
+ }
+
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on private fields");
+ }
+
+ ReflectionUtils.makeAccessible(field);
+
+ if (field.getType().getName().equals("java.lang.String")) {
+ Object nameObj = componentName;
+ if (nameObj != null)
+ ReflectionUtils.setField(field, bean, nameObj);
+ } else {
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+ Annotation annotation = method.getAnnotation(getComponentNameAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on static methods");
+ }
+
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on private methods");
+ }
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException(
+ "ComponentName annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+
+ if (pd.getPropertyType().getName().equals("java.lang.String")) {
+ Object nameObj = componentName;
+ if (nameObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {nameObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
+ }
+ }
+ } else {
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
new file mode 100644
index 0000000000..a52a85ff3a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
+import org.springframework.util.Assert;
+
+public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostProcessorAdapter {
+
+ private Class<? extends Annotation> constructorAnnotationType = org.oasisopen.sca.annotation.Constructor.class;
+
+ private Class<? extends Annotation> autowiredAnnotationType = Autowired.class;
+
+ public ConstructorAnnotationProcessor() {
+ // Default constructor.
+ }
+
+ /**
+ * Set the 'autowired' annotation type, to be used on constructors, fields,
+ * setter methods and arbitrary config methods.
+ */
+ public void setAutowiredAnnotationType(Class<? extends Annotation> autowiredAnnotationType) {
+ Assert.notNull(autowiredAnnotationType, "'autowiredAnnotationType' must not be null");
+ this.autowiredAnnotationType = autowiredAnnotationType;
+ }
+
+ /**
+ * Return the 'autowired' annotation type.
+ */
+ protected Class<? extends Annotation> getAutowiredAnnotationType() {
+ return this.autowiredAnnotationType;
+ }
+
+ /**
+ * Return the 'constructor' annotation type.
+ */
+ protected Class<? extends Annotation> getConstructorAnnotationType() {
+ return this.constructorAnnotationType;
+ }
+
+ /**
+ * Sets the 'constructor' annotation type.
+ */
+ public void setConstructorAnnotationType(Class<? extends Annotation> constructorAnnotationType) {
+ Assert.notNull(constructorAnnotationType, "'constructorAnnotationType' type must not be null.");
+ this.constructorAnnotationType = constructorAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
+ /*Constructor[] declaredConstructors = beanClass.getDeclaredConstructors();
+ Method[] declaredMethods = beanClass.getDeclaredMethods();
+ List candidates = new ArrayList(declaredConstructors.length);
+
+ for (int i = 0; i < declaredMethods.length; i++) {
+ Method method = declaredMethods[i];
+ Annotation annotation = method.getAnnotation(getConstructorAnnotationType());
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Constructor annotation is not supported on static methods");
+ }
+
+ if (candidates.size() == 1) {
+ throw new IllegalStateException("Only one method is allowed to have constructor annotation in a bean: " + method);
+ }
+
+ candidates.add(method);
+ }
+ }
+
+ return (Constructor[]) candidates.toArray(new Constructor[candidates.size()]);*/
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
new file mode 100644
index 0000000000..477582b1d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.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.sca.implementation.spring.processor;
+
+import java.lang.annotation.Annotation;
+
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
+
+public class InitDestroyAnnotationProcessor extends InitDestroyAnnotationBeanPostProcessor {
+
+ private static final long serialVersionUID = 0;
+
+ private Class<? extends Annotation> initAnnotationType = Init.class;
+ private Class<? extends Annotation> destroyAnnotationType = Destroy.class;
+
+ /**
+ * Gets init annotation type.
+ */
+ protected Class<? extends Annotation> getInitAnnotationType() {
+ return this.initAnnotationType;
+ }
+
+ /**
+ * Sets init annotation type.
+ */
+ /*
+ * public void setInitAnnotationType(Class<? extends Annotation>
+ * initAnnotationType) { Assert.notNull(initAnnotationType,
+ * "Init annotation type must not be null."); this.initAnnotationType =
+ * initAnnotationType; }
+ */
+
+ /**
+ * Gets destroy annotation type.
+ */
+ protected Class<? extends Annotation> getDestroyAnnotationType() {
+ return this.destroyAnnotationType;
+ }
+
+ /**
+ * Sets destroy annotation type.
+ */
+ /*
+ * public void setDestroyAnnotationType(Class<? extends Annotation>
+ * destroyAnnotationType) { Assert.notNull(destroyAnnotationType,
+ * "Destroy annotation type must not be null."); this.destroyAnnotationType
+ * = destroyAnnotationType; }
+ */
+
+ public InitDestroyAnnotationProcessor() {
+ // Set the @Init annotation type
+ setInitAnnotationType(initAnnotationType);
+
+ // Set the @Destroy annotation type
+ setDestroyAnnotationType(destroyAnnotationType);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
new file mode 100644
index 0000000000..4763714a38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.sca.implementation.spring.provider.PropertyValueWrapper;
+import org.oasisopen.sca.annotation.Property;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class PropertyAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> propertyAnnotationType = Property.class;
+
+ private PropertyValueWrapper propertyValue;
+
+ public PropertyAnnotationProcessor(PropertyValueWrapper propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+ /**
+ * Gets property annotation type.
+ */
+ protected Class<? extends Annotation> getPropertyAnnotationType() {
+ return this.propertyAnnotationType;
+ }
+
+ /**
+ * Sets property annotation type.
+ */
+ public void setPropertyAnnotationType(Class<? extends Annotation> propertyAnnotationType) {
+ Assert.notNull(propertyAnnotationType, "'propertyAnnotationType' type must not be null.");
+ this.propertyAnnotationType = propertyAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Property} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+
+ Property annotation = (Property)method.getAnnotation(getPropertyAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on static methods");
+ }
+
+ /*
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on private methods");
+ }
+ */
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException("Property annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+ if (pd != null) {
+ String propName = annotation.name();
+ if ("".equals(propName)) {
+ injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), pd.getName()));
+ } else {
+ injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), propName));
+ }
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+
+ Property annotation = (Property)field.getAnnotation(getPropertyAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on static fields");
+ }
+
+ /*
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on private fields");
+ }
+ */
+
+ ReflectionUtils.makeAccessible(field);
+
+ Object propertyObj = null;
+ String propName = annotation.name();
+ if ("".equals(propName)) {
+ propertyObj = propertyValue.getPropertyObj(field.getType(), field.getName());
+ } else {
+ propertyObj = propertyValue.getPropertyObj(field.getType(), propName);
+ }
+
+ if (propertyObj != null)
+ ReflectionUtils.setField(field, bean, propertyObj);
+ }
+ }
+ });
+ }
+
+ public void injectProperty(Object bean, PropertyDescriptor pd, Object propertyObj) {
+
+ if (propertyObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {propertyObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting property: " + e.getMessage(), e);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
new file mode 100644
index 0000000000..ad79db840e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.sca.implementation.spring.provider.ComponentWrapper;
+import org.oasisopen.sca.annotation.Reference;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ReferenceAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> referenceAnnotationType = Reference.class;
+ private ComponentWrapper component;
+
+ public ReferenceAnnotationProcessor(ComponentWrapper component) {
+ this.component = component;
+ }
+
+ /**
+ * Gets referece annotation type.
+ */
+ protected Class<? extends Annotation> getReferenceAnnotationType() {
+ return this.referenceAnnotationType;
+ }
+
+ /**
+ * Sets referece annotation type.
+ */
+ public void setReferenceAnnotationType(Class<? extends Annotation> referenceAnnotationType) {
+ Assert.notNull(referenceAnnotationType, "'referenceAnnotationType' type must not be null.");
+ this.referenceAnnotationType = referenceAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+
+ Reference annotation = (Reference)method.getAnnotation(getReferenceAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on static methods");
+ }
+
+ /*
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on private methods");
+ }
+ */
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException(
+ "Reference annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+ if (pd != null) {
+ String refName = annotation.name();
+ if ("".equals(refName)) {
+ injectReference(bean, pd, pd.getName());
+ } else {
+ injectReference(bean, pd, refName);
+ }
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+
+ Reference annotation = (Reference)field.getAnnotation(getReferenceAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on static fields");
+ }
+
+ /*
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on private fields");
+ }
+ */
+
+ ReflectionUtils.makeAccessible(field);
+
+ Object referenceObj = null;
+ String refName = annotation.name();
+ if ("".equals(refName)) {
+ referenceObj = component.getService(field.getType(), field.getName());
+ } else {
+ referenceObj = component.getService(field.getType(), refName);
+ }
+
+ if (referenceObj != null)
+ ReflectionUtils.setField(field, bean, referenceObj);
+ }
+ }
+ });
+ }
+
+ /**
+ * Processes a property descriptor to inject a service.
+ */
+ public void injectReference(Object bean, PropertyDescriptor pd, String name) {
+
+ Object referenceObj = component.getService(pd.getPropertyType(), name);
+
+ if (referenceObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {referenceObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java
new file mode 100644
index 0000000000..71feddb9f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.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.implementation.spring.processor;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * A tie that allows Tuscany to call Spring library to load the application context for the purpose of introspection
+ */
+public class SpringXMLBeanDefinitionLoaderImpl implements SpringXMLBeanDefinitionLoader {
+
+ private static SCAGenericApplicationContext createApplicationContext(Object scaParentContext,
+ ClassLoader classLoader,
+ List<URL> resources) {
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+
+ SCAGenericApplicationContext appCtx =
+ new SCAGenericApplicationContext((ApplicationContext)scaParentContext, classLoader);
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+
+ return appCtx;
+
+ }
+
+ @Override
+ public Object load(List<URL> resources,
+ List<SpringSCAServiceElement> serviceElements,
+ List<SpringSCAReferenceElement> referenceElements,
+ List<SpringSCAPropertyElement> propertyElements,
+ List<SpringBeanElement> beanElements,
+ ProcessorContext context) {
+ SCAGenericApplicationContext applicationContext = createApplicationContext(null, null, resources);
+ serviceElements.addAll(applicationContext.getServiceElements());
+ referenceElements.addAll(applicationContext.getReferenceElements());
+ propertyElements.addAll(applicationContext.getPropertyElements());
+ beanElements.addAll(applicationContext.getBeanElements());
+ return applicationContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/ComponentWrapper.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/ComponentWrapper.java
new file mode 100644
index 0000000000..5bddd8a006
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/ComponentWrapper.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 org.apache.tuscany.sca.implementation.spring.provider;
+
+/**
+ * Wrapper for the Component
+ */
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class ComponentWrapper {
+
+ private RuntimeComponent component;
+
+ public ComponentWrapper(RuntimeComponent component) {
+ this.component = component;
+ }
+
+ public Object getService(Class<?> type, String name) {
+ return component.getComponentContext().getService(type, name);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/PropertyValueWrapper.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/PropertyValueWrapper.java
new file mode 100644
index 0000000000..eca1492081
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/PropertyValueWrapper.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.spring.provider;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Wrapper for PropertyValue
+ */
+public class PropertyValueWrapper {
+
+ private RuntimeComponent component;
+ private PropertyValueFactory propertyFactory;
+
+ public PropertyValueWrapper(RuntimeComponent component, PropertyValueFactory propertyFactory) {
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ }
+
+ public Object getPropertyObj(Class<?> type, String name) {
+ List<ComponentProperty> props = component.getProperties();
+ for (ComponentProperty prop : props) {
+ if (prop.getName().equals(name)) {
+ return propertyFactory.createPropertyValue(prop, type);
+ }
+ }
+ return null; // property name not found
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java
new file mode 100644
index 0000000000..db7831322a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.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.sca.implementation.spring.provider;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.context.SpringContextWrapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * A provider class for runtime Spring implementation instances
+ * @version $Rev$ $Date$
+ */
+public class SpringImplementationProvider implements ImplementationProvider {
+ private RuntimeComponent component;
+
+ // A Spring application context object
+ private SpringContextWrapper springContext;
+
+ /**
+ * Constructor for the provider - takes a component definition and a Spring implementation
+ * description
+ * @param component - the component in the assembly
+ * @param implementation - the implementation
+ */
+ public SpringImplementationProvider(RuntimeComponent component,
+ SpringImplementationWrapper implementation,
+ ApplicationContext parentApplicationContext,
+ ProxyFactory proxyService,
+ PropertyValueFactory propertyValueObjectFactory) {
+ super();
+ this.component = component;
+
+ springContext = new SpringContextWrapper(implementation, implementation.getResource());
+
+ } // end constructor
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ return new SpringInvoker(component, springContext, service, operation);
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ /**
+ * Start this Spring implementation instance
+ */
+ public void start() {
+ springContext.start();
+ }
+
+ /**
+ * Stop this implementation instance
+ */
+ public void stop() {
+ springContext.close();
+ }
+
+} // end class SpringImplementationProvider
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java
new file mode 100644
index 0000000000..be16fb3251
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.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.implementation.spring.provider;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * ImplementationProviderFactory for Spring implementation type
+ * @version $Rev$ $Date$
+ *
+ */
+public class SpringImplementationProviderFactory implements ImplementationProviderFactory<SpringImplementation> {
+ private ProxyFactory proxyFactory;
+ private PropertyValueFactory propertyFactory;
+ private SpringApplicationContextAccessor contextAccessor;
+
+ /**
+ * Simple constructor
+ *
+ */
+ public SpringImplementationProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ contextAccessor = utilities.getUtility(SpringApplicationContextAccessor.class);
+ proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ propertyFactory = utilities.getUtility(PropertyValueFactory.class);
+ }
+
+ /**
+ * Returns a SpringImplementationProvider for a given component and Spring implementation
+ * @param component the component for which implementation instances are required
+ * @param implementation the Spring implementation with details of the component
+ * implementation
+ * @return the SpringImplementationProvider for the specified component
+ */
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ SpringImplementation implementation) {
+ ApplicationContext parentApplicationContext =
+ (contextAccessor != null) ? contextAccessor.getParentApplicationContext() : null;
+ SpringImplementationWrapper tie =
+ new SpringImplementationWrapper(implementation, parentApplicationContext, component, propertyFactory);
+ return new SpringImplementationProvider(component, tie, parentApplicationContext, proxyFactory, propertyFactory);
+ }
+
+ /**
+ * Returns the class of the Spring implementation
+ */
+ public Class<SpringImplementation> getModelType() {
+ return SpringImplementation.class;
+ }
+
+} // end class SpringImplementationProviderFactory
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java
new file mode 100644
index 0000000000..e5593f5eaa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Wrapper for SpringImplementation
+ */
+public class SpringImplementationWrapper {
+
+ private SpringImplementation implementation;
+ private ApplicationContext parentApplicationContext;
+ private RuntimeComponent component;
+ private PropertyValueFactory propertyFactory;
+
+ public SpringImplementationWrapper(SpringImplementation implementation,
+ ApplicationContext parentApplicationContext,
+ RuntimeComponent component,
+ PropertyValueFactory propertyFactory) {
+ this.implementation = implementation;
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ this.parentApplicationContext = parentApplicationContext;
+ }
+
+ public String getURI() {
+ return implementation.getURI();
+ }
+
+ public List<URL> getResource() {
+ return implementation.getResource();
+ }
+
+ public String getComponentName() {
+ return component.getName();
+ }
+
+ /**
+ * Method to create a Java Bean for a Property value
+ * @param <B> the class type of the Bean
+ * @param requiredType - a Class object for the required type
+ * @param name - the Property name
+ * @return - a Bean of the specified property, with value set
+ */
+ private <B> B getPropertyBean(Class<?> requiredType, String name) {
+ B propertyObject = null;
+ // Get the component's list of properties
+ List<ComponentProperty> props = component.getProperties();
+ for (ComponentProperty prop : props) {
+ if (prop.getName().equals(name)) {
+ // On finding the property, create a factory for it and create a Bean using
+ // the factory
+ propertyObject = (B)propertyFactory.createPropertyValue(prop, requiredType);
+ } // end if
+ } // end for
+
+ return propertyObject;
+ }
+
+ /**
+ * Creates a proxy Bean for a reference
+ * @param <B> the Business interface type for the reference
+ * @param businessInterface - the business interface as a Class
+ * @param referenceName - the name of the Reference
+ * @return an Bean of the type defined by <B>
+ */
+ private <B> B getService(Class<B> businessInterface, String referenceName) {
+ return component.getComponentContext().getService(businessInterface, referenceName);
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class<?> requiredType) {
+ // The expectation is that the requested Bean is either a reference or a property
+ // from the Spring context
+ for (Reference reference : implementation.getReferences()) {
+ if (reference.getName().equals(name)) {
+ // Extract the Java interface for the reference (it can't be any other interface type
+ // for a Spring application context)
+ if (requiredType == null) {
+ JavaInterface javaInterface = (JavaInterface)reference.getInterfaceContract().getInterface();
+ requiredType = javaInterface.getJavaClass();
+ }
+ // Create and return the proxy for the reference
+ return getService(requiredType, reference.getName());
+ } // end if
+ } // end for
+
+ // For a property, get the name and the required Java type and create a Bean
+ // of that type with the value inserted.
+ for (Property property : implementation.getProperties()) {
+ if (property.getName().equals(name)) {
+ if (requiredType == null) {
+ // The following code only deals with a subset of types and was superceded
+ // by the information from the implementation (which uses Classes as found
+ // in the Spring implementation itself.
+ //requiredType = JavaXMLMapper.getJavaType( property.getXSDType() );
+ requiredType = implementation.getPropertyClass(name);
+ }
+ return getPropertyBean(requiredType, property.getName());
+ } // end if
+ } // end for
+ // TODO: NoSuchBeanException
+ // throw new RuntimeException("Unable to find Bean with name " + name);
+ return null;
+
+ } // end method getBean( String, Class )
+
+ public ComponentWrapper getComponentWrapper() {
+ return new ComponentWrapper(component);
+ }
+
+ public PropertyValueWrapper getPropertyValueWrapper() {
+ return new PropertyValueWrapper(component, propertyFactory);
+ }
+
+ public ClassLoader getClassLoader() {
+ return implementation.getClassLoader();
+ }
+
+ public ApplicationContext getParentApplicationContext() {
+ return parentApplicationContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvocationException.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvocationException.java
new file mode 100644
index 0000000000..0e1d3f5b5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvocationException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.provider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SpringInvocationException extends Exception {
+
+ private static final long serialVersionUID = -1157790036638157513L;
+
+ public SpringInvocationException(String msg) {
+ super(msg);
+ }
+
+ public SpringInvocationException(Throwable e) {
+ super(e);
+ }
+
+ public SpringInvocationException(String msg, Throwable e) {
+ super(msg, e);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvoker.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvoker.java
new file mode 100644
index 0000000000..ea1d6e6755
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvoker.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.context.SpringContextWrapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Initial implementation of a Spring bean invoker
+ * @version $Rev$ $Date$
+ */
+public class SpringInvoker implements Invoker {
+
+ private Method theMethod = null;
+ private Object bean;
+ private SpringBeanElement beanElement;
+ private boolean badInvoker = false;
+
+ private SpringContextWrapper springContext;
+ private Operation operation;
+
+ /**
+ * SpringInvoker constructor
+ * @param component - the Spring component to invoke
+ * @param service - the service to invoke
+ * @param operation - the operation to invoke
+ */
+ public SpringInvoker(RuntimeComponent component,
+ SpringContextWrapper springContext,
+ RuntimeComponentService service,
+ Operation operation) {
+
+ this.springContext = springContext;
+ this.operation = operation;
+
+ // From the component and the service, identify the Spring Bean which is the target
+ SpringImplementation theImplementation = (SpringImplementation)component.getImplementation();
+ beanElement = theImplementation.getBeanFromService(service.getService());
+
+ if (beanElement == null) {
+ badInvoker = true;
+ return;
+ }
+
+ } // end constructor SpringInvoker
+
+ // Lazy-load the method to avoid timing problems with the Spring Context
+ private void setupMethod() throws SpringInvocationException {
+ try {
+ bean = springContext.getBean(beanElement.getId());
+ Class<?> beanClass = bean.getClass();
+ theMethod = JavaInterfaceUtil.findMethod(beanClass, operation);
+ //System.out.println("SpringInvoker - found method " + theMethod.getName() );
+ } catch (NoSuchMethodException e) {
+ throw new SpringInvocationException(e);
+ }
+ }
+
+ private Object doInvoke(Object payload) throws SpringInvocationException {
+ if (theMethod == null)
+ setupMethod();
+
+ if (badInvoker)
+ throw new SpringInvocationException("Spring invoker incorrectly configured");
+ // Invoke the method on the Spring bean using the payload, returning the results
+ try {
+ Object ret;
+
+ if (payload != null && !payload.getClass().isArray()) {
+ ret = theMethod.invoke(bean, payload);
+ } else {
+ ret = theMethod.invoke(bean, (Object[])payload);
+ }
+ return ret;
+ } catch (InvocationTargetException e) {
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.",
+ e.getCause());
+ } catch (Exception e) {
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.", e);
+ }
+
+ } // end method doInvoke
+
+ /**
+ * @param msg the message to invoke on the target bean
+ */
+ public Message invoke(Message msg) {
+ try {
+ Object resp = doInvoke(msg.getBody());
+ msg.setBody(resp);
+ } catch (SpringInvocationException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+ //System.out.println("Spring Invoker - invoke called");
+ return msg;
+ } // end method invoke
+
+} // end class SpringInvoker
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
new file mode 100644
index 0000000000..4c8fa09951
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.implementation.spring.processor.SpringXMLBeanDefinitionLoaderImpl;ranking=100 \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..e6c8d70fe1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.spring.provider.SpringImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.spring.SpringImplementation;ranking=100
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000000..6d29e21024
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+http\://www.springframework.org/schema/sca=org.apache.tuscany.sca.implementation.spring.namespace.ScaNamespaceHandler
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000000..249cc21c13
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd=org/springframework/sca/xml/spring-sca.xsd
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
new file mode 100644
index 0000000000..dfa0b931f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
@@ -0,0 +1,84 @@
+<?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.
+-->
+<xsd:schema xmlns="http://www.springframework.org/schema/sca" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ attributeFormDefault="unqualified" elementFormDefault="qualified"
+ targetNamespace="http://www.springframework.org/schema/sca">
+
+ <xsd:element name="reference">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="default" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="service">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="target" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/LICENSE b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/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/sebastien/java/embed/contrib/modules/implementation-spring-stub/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a41644caa8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Model
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.stub
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/NOTICE b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/README b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/README
new file mode 100644
index 0000000000..e1b1f98fe0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/README
@@ -0,0 +1,9 @@
+Note that the implementation spring modules have a different structure from other extensions.
+
+The aim is to have the Tuscany runtime embedded in a container with the Tuscany classes hidden
+from user applications and the Spring jar's packaged with the application. That means that the
+Tuscany code has no visibilty of the Spring classes and visa-versa. To implement that the
+implementation-spring module has no dependencies on Spring and the implementation-spring-runtime
+module has no dependencies on Tuscany (other than the sca-api), and reflection is used to call
+methods between the modules.
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/pom.xml b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/pom.xml
new file mode 100644
index 0000000000..f459f1755c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring-stub</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Runtime Stub</name>
+
+ <dependencies>
+
+ <!-- **************************************** -->
+ <!-- * * -->
+ <!-- * DONT ADD ANY SPRING DEPENDENCIES!!! * -->
+ <!-- * * -->
+ <!-- * See the README for details why not * -->
+ <!-- * * -->
+ <!-- * * -->
+ <!-- **************************************** -->
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/stub/SpringXMLBeanDefinitionLoaderStub.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/stub/SpringXMLBeanDefinitionLoaderStub.java
new file mode 100644
index 0000000000..f34dfb8ceb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/stub/SpringXMLBeanDefinitionLoaderStub.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.spring.processor.stub;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * This is the Tuscany side stub for the corresponding runtime tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextTie class
+ * in the implementation-spring-runtime module for what the tie does.
+ */
+public class SpringXMLBeanDefinitionLoaderStub implements SpringXMLBeanDefinitionLoader {
+ private final static String TIE = "org.apache.tuscany.sca.implementation.spring.processor.tie.SpringXMLLoaderTie";
+
+ private static Method createApplicationContext;
+
+ public SpringXMLBeanDefinitionLoaderStub() throws Exception {
+ synchronized (SpringXMLBeanDefinitionLoaderStub.class) {
+ if (createApplicationContext == null) {
+ Class<?> tieClass = Class.forName(TIE, false, Thread.currentThread().getContextClassLoader());
+ createApplicationContext =
+ tieClass.getMethod("createApplicationContext", Object.class, ClassLoader.class, List.class);
+ }
+ }
+ }
+
+ public Object createApplicationContext(Object scaParentContext, ClassLoader classLoader, List<URL> resources)
+ throws Exception {
+ return createApplicationContext.invoke(null, scaParentContext, classLoader, resources);
+ }
+
+ public Object load(List<URL> resources,
+ List<SpringSCAServiceElement> serviceElements,
+ List<SpringSCAReferenceElement> referenceElements,
+ List<SpringSCAPropertyElement> propertyElements,
+ List<SpringBeanElement> beanElements,
+ ProcessorContext context) {
+ try {
+ Object appContext =
+ createApplicationContext(null, Thread.currentThread().getContextClassLoader(), resources);
+ Class<?> cls = appContext.getClass();
+ Method method = cls.getMethod("getElements", Class.class);
+ SpringSCAServiceElement[] serviceArray =
+ (SpringSCAServiceElement[])method.invoke(appContext, SpringSCAServiceElement.class);
+ serviceElements.addAll(Arrays.asList(serviceArray));
+
+ SpringSCAReferenceElement[] referenceArray =
+ (SpringSCAReferenceElement[])method.invoke(appContext, SpringSCAReferenceElement.class);
+ referenceElements.addAll(Arrays.asList(referenceArray));
+
+ SpringSCAPropertyElement[] propertyArray =
+ (SpringSCAPropertyElement[])method.invoke(appContext, SpringSCAPropertyElement.class);
+ propertyElements.addAll(Arrays.asList(propertyArray));
+
+ SpringBeanElement[] beanArray = (SpringBeanElement[])method.invoke(appContext, SpringBeanElement.class);
+ beanElements.addAll(Arrays.asList(beanArray));
+
+ return appContext;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/ComponentTie.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/ComponentTie.java
new file mode 100644
index 0000000000..882aa587e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/ComponentTie.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.implementation.spring.provider.stub;
+
+/**
+ * This is the Tuscany side tie for the corresponding Spring runtime side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the ComponentStub class
+ * in the implementation-spring-runtime module for what the stub does.
+ */
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class ComponentTie {
+
+ private RuntimeComponent component;
+
+ public ComponentTie(RuntimeComponent component) {
+ this.component = component;
+ }
+
+ public Object getService(Class<?> type, String name) {
+ return component.getComponentContext().getService(type, name);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/PropertyValueTie.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/PropertyValueTie.java
new file mode 100644
index 0000000000..5e0c5263c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/PropertyValueTie.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.sca.implementation.spring.provider.stub;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * This is the Tuscany side tie for the corresponding Spring runtime side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the PropertyValueStub class
+ * in the implementation-spring-runtime module for what the stub does.
+ */
+public class PropertyValueTie {
+
+ private RuntimeComponent component;
+ private PropertyValueFactory propertyFactory;
+
+ public PropertyValueTie(RuntimeComponent component, PropertyValueFactory propertyFactory) {
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ }
+
+ public Object getPropertyObj(Class<?> type, String name) {
+ List<ComponentProperty> props = component.getProperties();
+ for (ComponentProperty prop : props) {
+ if (prop.getName().equals(name)) {
+ return propertyFactory.createPropertyValue(prop, type);
+ }
+ }
+ return null; // property name not found
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringApplicationContextAccessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringApplicationContextAccessor.java
new file mode 100644
index 0000000000..84a65bcf17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringApplicationContextAccessor.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.sca.implementation.spring.provider.stub;
+
+/**
+ * A utility to receive the parent Spring application context
+ */
+public interface SpringApplicationContextAccessor {
+ /**
+ * Get the parent Spring application context for the hosting environment. This will be used as the parent
+ * application context for implementation.spring components
+ * @return The parent application context
+ */
+ Object getParentApplicationContext();
+
+ /**
+ * Set the root Spring application context. This is particually useful for Spring web integration where Spring
+ * creates WebApplicationContext and keeps it in the ServletContext
+ * @param parentApplicationContext The parent application context
+ */
+ void setParentApplicationContext(Object parentApplicationContext);
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringContextStub.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringContextStub.java
new file mode 100644
index 0000000000..062da4b2d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringContextStub.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider.stub;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * This is the Tuscany side stub for the corresponding runtime tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextTie class
+ * in the implementation-spring-runtime module for what the tie does.
+ */
+public class SpringContextStub {
+
+ private static final String SPRING_IMPLEMENTATION_STUB =
+ "org.apache.tuscany.sca.implementation.spring.context.tie.SpringImplementationStub";
+ private static final String SPRING_CONTEXT_TIE =
+ "org.apache.tuscany.sca.implementation.spring.context.tie.SpringContextTie";
+ private Object tie;
+ private Method startMethod;
+ private Method closeMethod;
+ private Method getBeanMethod;
+
+ public SpringContextStub(RuntimeComponent component,
+ SpringImplementation implementation,
+ Object parentApplicationContext,
+ ProxyFactory proxyService,
+ PropertyValueFactory propertyValueObjectFactory) {
+
+ initTie(component, implementation, parentApplicationContext, propertyValueObjectFactory);
+
+ }
+
+ private void initTie(RuntimeComponent component,
+ SpringImplementation implementation,
+ Object parentApplicationContext,
+ PropertyValueFactory propertyValueObjectFactory) {
+
+ // TODO: what class loader to use?
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ try {
+
+ Class<?> stubClass = Class.forName(SPRING_IMPLEMENTATION_STUB, true, cl);
+ Constructor<?> stubConstructor = stubClass.getConstructor(new Class<?>[] {Object.class});
+ Object stub =
+ stubConstructor.newInstance(new SpringImplementationTie(implementation, parentApplicationContext,
+ component, propertyValueObjectFactory));
+
+ Class<?> tieClass = Class.forName(SPRING_CONTEXT_TIE, true, cl);
+ Constructor<?> tieConstructor = tieClass.getConstructor(new Class<?>[] {stubClass, List.class});
+ this.tie = tieConstructor.newInstance(stub, implementation.getResource());
+
+ this.startMethod = tieClass.getMethod("start");
+ this.closeMethod = tieClass.getMethod("close");
+ this.getBeanMethod = tieClass.getMethod("getBean", String.class);
+
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void start() {
+ try {
+ startMethod.invoke(tie);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void close() {
+ try {
+ closeMethod.invoke(tie);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getBean(String id) throws SpringInvocationException {
+ try {
+
+ return getBeanMethod.invoke(tie, id);
+
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProvider.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProvider.java
new file mode 100644
index 0000000000..e0207b9f12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProvider.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider.stub;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * A provider class for runtime Spring implementation instances
+ * @version $Rev$ $Date$
+ */
+public class SpringImplementationProvider implements ImplementationProvider {
+ private RuntimeComponent component;
+
+ // A Spring application context object
+ private SpringContextStub springContext;
+
+ /**
+ * Constructor for the provider - takes a component definition and a Spring implementation
+ * description
+ * @param component - the component in the assembly
+ * @param implementation - the implementation
+ */
+ public SpringImplementationProvider(RuntimeComponent component,
+ SpringImplementation implementation,
+ Object parentApplicationContext,
+ ProxyFactory proxyService,
+ PropertyValueFactory propertyValueObjectFactory) {
+ super();
+ this.component = component;
+
+ springContext = new SpringContextStub(component, implementation, parentApplicationContext, proxyService, propertyValueObjectFactory);
+
+ } // end constructor
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ return new SpringInvoker(component, springContext, service, operation);
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ /**
+ * Start this Spring implementation instance
+ */
+ public void start() {
+ springContext.start();
+ }
+
+ /**
+ * Stop this implementation instance
+ */
+ public void stop() {
+ springContext.close();
+ }
+
+} // end class SpringImplementationProvider
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProviderFactory.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProviderFactory.java
new file mode 100644
index 0000000000..d402ff2eb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProviderFactory.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.sca.implementation.spring.provider.stub;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * ImplementationProviderFactory for Spring implementation type
+ * @version $Rev$ $Date$
+ *
+ */
+public class SpringImplementationProviderFactory implements ImplementationProviderFactory<SpringImplementation> {
+ private ProxyFactory proxyFactory;
+ private PropertyValueFactory propertyFactory;
+ private SpringApplicationContextAccessor contextAccessor;
+
+ /**
+ * Simple constructor
+ *
+ */
+ public SpringImplementationProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ contextAccessor = utilities.getUtility(SpringApplicationContextAccessor.class);
+ proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ propertyFactory = utilities.getUtility(PropertyValueFactory.class);
+ }
+
+ /**
+ * Returns a SpringImplementationProvider for a given component and Spring implementation
+ * @param component the component for which implementation instances are required
+ * @param implementation the Spring implementation with details of the component
+ * implementation
+ * @return the SpringImplementationProvider for the specified component
+ */
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ SpringImplementation implementation) {
+ Object parentApplicationContext =
+ (contextAccessor != null) ? contextAccessor.getParentApplicationContext() : null;
+ return new SpringImplementationProvider(component, implementation, parentApplicationContext, proxyFactory,
+ propertyFactory);
+ }
+
+ /**
+ * Returns the class of the Spring implementation
+ */
+ public Class<SpringImplementation> getModelType() {
+ return SpringImplementation.class;
+ }
+
+} // end class SpringImplementationProviderFactory
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationTie.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationTie.java
new file mode 100644
index 0000000000..fc75faed21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationTie.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider.stub;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * This is the Tuscany side tie for the corresponding runtime stub class.
+ * It enables the Sping code in the runtime module to invoke methods on a
+ * Tuscany SpringImplementation without the Spring runtime module
+ * needing to know about any Tuscany classes. See the SpringImplementationStub class
+ * in the implementation-spring-runtime module for what the stub does.
+ */
+public class SpringImplementationTie {
+
+ private SpringImplementation implementation;
+ private Object parentApplicationContext;
+ private RuntimeComponent component;
+ private PropertyValueFactory propertyFactory;
+
+ public SpringImplementationTie(SpringImplementation implementation,
+ Object parentApplicationContext,
+ RuntimeComponent component,
+ PropertyValueFactory propertyFactory) {
+ this.implementation = implementation;
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ this.parentApplicationContext = parentApplicationContext;
+ }
+
+ public String getURI() {
+ return implementation.getURI();
+ }
+
+ public String getComponentName() {
+ return component.getName();
+ }
+
+ /**
+ * Method to create a Java Bean for a Property value
+ * @param <B> the class type of the Bean
+ * @param requiredType - a Class object for the required type
+ * @param name - the Property name
+ * @return - a Bean of the specified property, with value set
+ */
+ private <B> B getPropertyBean(Class<?> requiredType, String name) {
+ B propertyObject = null;
+ // Get the component's list of properties
+ List<ComponentProperty> props = component.getProperties();
+ for (ComponentProperty prop : props) {
+ if (prop.getName().equals(name)) {
+ // On finding the property, create a factory for it and create a Bean using
+ // the factory
+ propertyObject = (B) propertyFactory.createPropertyValue(prop, requiredType);
+ } // end if
+ } // end for
+
+ return propertyObject;
+ }
+
+ /**
+ * Creates a proxy Bean for a reference
+ * @param <B> the Business interface type for the reference
+ * @param businessInterface - the business interface as a Class
+ * @param referenceName - the name of the Reference
+ * @return an Bean of the type defined by <B>
+ */
+ private <B> B getService(Class<B> businessInterface, String referenceName) {
+ return component.getComponentContext().getService(businessInterface, referenceName);
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class<?> requiredType) {
+ // The expectation is that the requested Bean is either a reference or a property
+ // from the Spring context
+ for (Reference reference : implementation.getReferences()) {
+ if (reference.getName().equals(name)) {
+ // Extract the Java interface for the reference (it can't be any other interface type
+ // for a Spring application context)
+ if (requiredType == null) {
+ JavaInterface javaInterface = (JavaInterface)reference.getInterfaceContract().getInterface();
+ requiredType = javaInterface.getJavaClass();
+ }
+ // Create and return the proxy for the reference
+ return getService(requiredType, reference.getName());
+ } // end if
+ } // end for
+
+ // For a property, get the name and the required Java type and create a Bean
+ // of that type with the value inserted.
+ for (Property property : implementation.getProperties()) {
+ if (property.getName().equals(name)) {
+ if (requiredType == null) {
+ // The following code only deals with a subset of types and was superceded
+ // by the information from the implementation (which uses Classes as found
+ // in the Spring implementation itself.
+ //requiredType = JavaXMLMapper.getJavaType( property.getXSDType() );
+ requiredType = implementation.getPropertyClass(name);
+ }
+ return getPropertyBean(requiredType, property.getName());
+ } // end if
+ } // end for
+ // TODO: NoSuchBeanException
+ // throw new RuntimeException("Unable to find Bean with name " + name);
+ return null;
+
+ } // end method getBean( String, Class )
+
+ public Object getComponentTie() {
+ return new ComponentTie(component);
+ }
+
+ public Object getPropertyValueTie() {
+ return new PropertyValueTie(component, propertyFactory);
+ }
+
+ public ClassLoader getClassLoader() {
+ return implementation.getClassLoader();
+ }
+
+ public Object getParentApplicationContext() {
+ return parentApplicationContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvocationException.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvocationException.java
new file mode 100644
index 0000000000..909a640563
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvocationException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.provider.stub;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SpringInvocationException extends Exception {
+
+ private static final long serialVersionUID = -1157790036638157513L;
+
+ public SpringInvocationException(String msg) {
+ super(msg);
+ }
+
+ public SpringInvocationException(Throwable e) {
+ super(e);
+ }
+
+ public SpringInvocationException(String msg, Throwable e) {
+ super(msg, e);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvoker.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvoker.java
new file mode 100644
index 0000000000..7d73eb5e6a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvoker.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider.stub;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Initial implementation of a Spring bean invoker
+ * @version $Rev$ $Date$
+ */
+public class SpringInvoker implements Invoker {
+
+ private Method theMethod = null;
+ private Object bean;
+ private SpringBeanElement beanElement;
+ private boolean badInvoker = false;
+
+ private SpringContextStub springContext;
+ private Operation operation;
+
+ /**
+ * SpringInvoker constructor
+ * @param component - the Spring component to invoke
+ * @param service - the service to invoke
+ * @param operation - the operation to invoke
+ */
+ public SpringInvoker(RuntimeComponent component,
+ SpringContextStub springContext,
+ RuntimeComponentService service,
+ Operation operation) {
+
+ this.springContext = springContext;
+ this.operation = operation;
+
+ // From the component and the service, identify the Spring Bean which is the target
+ SpringImplementation theImplementation = (SpringImplementation)component.getImplementation();
+ beanElement = theImplementation.getBeanFromService(service.getService());
+
+ if (beanElement == null) {
+ badInvoker = true;
+ return;
+ }
+
+ } // end constructor SpringInvoker
+
+ // Lazy-load the method to avoid timing problems with the Spring Context
+ private void setupMethod() throws SpringInvocationException {
+ try {
+ bean = springContext.getBean(beanElement.getId());
+ Class<?> beanClass = bean.getClass();
+ theMethod = JavaInterfaceUtil.findMethod(beanClass, operation);
+ //System.out.println("SpringInvoker - found method " + theMethod.getName() );
+ } catch (NoSuchMethodException e) {
+ throw new SpringInvocationException(e);
+ }
+ }
+
+ private Object doInvoke(Object payload) throws SpringInvocationException {
+ if (theMethod == null)
+ setupMethod();
+
+ if (badInvoker)
+ throw new SpringInvocationException("Spring invoker incorrectly configured");
+ // Invoke the method on the Spring bean using the payload, returning the results
+ try {
+ Object ret;
+
+ if (payload != null && !payload.getClass().isArray()) {
+ ret = theMethod.invoke(bean, payload);
+ } else {
+ ret = theMethod.invoke(bean, (Object[])payload);
+ }
+ return ret;
+ } catch (InvocationTargetException e) {
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.",
+ e.getCause());
+ } catch (Exception e) {
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.", e);
+ }
+
+ } // end method doInvoke
+
+ /**
+ * @param msg the message to invoke on the target bean
+ */
+ public Message invoke(Message msg) {
+ try {
+ Object resp = doInvoke(msg.getBody());
+ msg.setBody(resp);
+ } catch (SpringInvocationException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+ //System.out.println("Spring Invoker - invoke called");
+ return msg;
+ } // end method invoke
+
+} // end class SpringInvoker
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
new file mode 100644
index 0000000000..0a46baa13b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.implementation.spring.processor.stub.SpringXMLBeanDefinitionLoaderStub;ranking=50 \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..e037ea60f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.spring.provider.stub.SpringImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.spring.SpringImplementation;ranking=50
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/LICENSE b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/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/sebastien/java/embed/contrib/modules/implementation-spring-tie/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5d452244d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.tie
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.springframework.beans;version="3.0.2.RELEASE",
+ org.springframework.beans.factory;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.annotation;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.config;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.support;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.xml;version="3.0.2.RELEASE",
+ org.springframework.context;version="3.0.2.RELEASE",
+ org.springframework.context.support;version="3.0.2.RELEASE",
+ org.springframework.core;version="3.0.2.RELEASE",
+ org.springframework.core.io;version="3.0.2.RELEASE",
+ org.springframework.util;version="3.0.2.RELEASE"
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/NOTICE b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/README b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/README
new file mode 100644
index 0000000000..e1b1f98fe0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/README
@@ -0,0 +1,9 @@
+Note that the implementation spring modules have a different structure from other extensions.
+
+The aim is to have the Tuscany runtime embedded in a container with the Tuscany classes hidden
+from user applications and the Spring jar's packaged with the application. That means that the
+Tuscany code has no visibilty of the Spring classes and visa-versa. To implement that the
+implementation-spring module has no dependencies on Spring and the implementation-spring-runtime
+module has no dependencies on Tuscany (other than the sca-api), and reflection is used to call
+methods between the modules.
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/pom.xml b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/pom.xml
new file mode 100644
index 0000000000..a30109d442
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring-tie</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Runtime Tie</name>
+
+ <dependencies>
+
+ <!-- **************************************** -->
+ <!-- * * -->
+ <!-- * DONT ADD ANY TUSCANY DEPENDENCIES!!! * -->
+ <!-- * * -->
+ <!-- * See the README for details why not * -->
+ <!-- * * -->
+ <!-- * * -->
+ <!-- **************************************** -->
+
+ <!-- SCA API dependency -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Spring dependencies... -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAGenericApplicationContext.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAGenericApplicationContext.java
new file mode 100644
index 0000000000..69e2ee2865
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAGenericApplicationContext.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context.tie;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringConstructorArgElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringElementTie;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAServiceElement;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.ConstructorArgumentValues;
+import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
+import org.springframework.beans.factory.config.TypedStringValue;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SCAGenericApplicationContext extends GenericApplicationContext {
+
+ private ClassLoader classloader = null;
+ private List<SpringSCAPropertyElement> propertyElements = new ArrayList<SpringSCAPropertyElement>();
+ private List<SpringSCAServiceElement> serviceElements = new ArrayList<SpringSCAServiceElement>();
+ private List<SpringSCAReferenceElement> referenceElements = new ArrayList<SpringSCAReferenceElement>();
+ private List<SpringBeanElement> beanElements;
+
+ public SCAGenericApplicationContext(DefaultListableBeanFactory beanFactory,
+ ApplicationContext parent,
+ ClassLoader classloader) {
+ super(beanFactory, parent);
+ this.classloader = classloader;
+ }
+
+ public SCAGenericApplicationContext(ApplicationContext parent, ClassLoader classloader) {
+ super(parent);
+ this.classloader = classloader;
+ }
+
+ @Override
+ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
+ beanFactory.setBeanClassLoader(classloader);
+ }
+
+ public void addSCAPropertyElement(SpringSCAPropertyElement propertyElement) {
+ propertyElements.add(propertyElement);
+ }
+
+ public void addSCAServiceElement(SpringSCAServiceElement serviceElement) {
+ serviceElements.add(serviceElement);
+ }
+
+ public void addSCAReferenceElement(SpringSCAReferenceElement referenceElement) {
+ referenceElements.add(referenceElement);
+ }
+
+ public synchronized List<SpringBeanElement> getBeanElements() {
+ if (beanElements == null) {
+ beanElements = new ArrayList<SpringBeanElement>();
+ for (String name : getBeanDefinitionNames()) {
+ BeanDefinition def = getBeanDefinition(name);
+ SpringBeanElement beanElement = new SpringBeanElement(name, def.getBeanClassName());
+ beanElements.add(beanElement);
+ beanElement.setAbstractBean(def.isAbstract());
+ beanElement.setFactoryBeanAttribute(def.getFactoryBeanName() != null);
+ beanElement.setFactoryMethodAttribute(def.getFactoryMethodName() != null);
+ beanElement.setParentAttribute(def.getParentName() != null);
+ beanElement.setInnerBean(beanElement.getId() == null);
+
+ ConstructorArgumentValues args = def.getConstructorArgumentValues();
+ for (Map.Entry<Integer, ValueHolder> e: args.getIndexedArgumentValues().entrySet()) {
+ ValueHolder holder = e.getValue();
+ SpringConstructorArgElement arg = new SpringConstructorArgElement(holder.getType());
+ arg.setIndex(e.getKey());
+ beanElement.addCustructorArgs(arg);
+ }
+
+ MutablePropertyValues values = def.getPropertyValues();
+ for (PropertyValue p : values.getPropertyValueList()) {
+ SpringPropertyElement propertyElement = new SpringPropertyElement(p.getName());
+ Object value = p.getValue();
+ configurePropertyElement(propertyElement, value);
+ beanElement.getProperties().add(propertyElement);
+ }
+ }
+ }
+ return beanElements;
+ }
+
+ public void configurePropertyElement(SpringPropertyElement propertyElement, Object value) {
+ if (value instanceof BeanReference) {
+ BeanReference beanRef = (BeanReference)value;
+ propertyElement.addRef(beanRef.getBeanName());
+ } else if (value instanceof Collection) {
+ Collection collection = (Collection)value;
+ for (Object item : collection) {
+ configurePropertyElement(propertyElement, item);
+ }
+ } else if (value instanceof TypedStringValue) {
+ TypedStringValue stringValue = (TypedStringValue)value;
+ propertyElement.addValue(stringValue.getValue());
+ } else {
+ if (value != null) {
+ propertyElement.addValue(value.toString());
+ }
+ }
+ }
+
+ public List<SpringSCAPropertyElement> getPropertyElements() {
+ return propertyElements;
+ }
+
+ public List<SpringSCAServiceElement> getServiceElements() {
+ return serviceElements;
+ }
+
+ public List<SpringSCAReferenceElement> getReferenceElements() {
+ return referenceElements;
+ }
+
+ public <T> T[] getElements(Class<T> type) {
+ if (type.getSimpleName().equals(SpringSCAPropertyElement.class.getSimpleName())) {
+ T[] elements = (T[])Array.newInstance(type, getPropertyElements().size());
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = SpringElementTie.copy(getPropertyElements().get(i), type, type);
+ }
+ return elements;
+ } else if (type.getSimpleName().equals(SpringSCAReferenceElement.class.getSimpleName())) {
+ T[] elements = (T[])Array.newInstance(type, getReferenceElements().size());
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = SpringElementTie.copy(getReferenceElements().get(i), type, type);
+ }
+ return elements;
+ } else if (type.getSimpleName().equals(SpringSCAServiceElement.class.getSimpleName())) {
+ T[] elements = (T[])Array.newInstance(type, getServiceElements().size());
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = SpringElementTie.copy(getServiceElements().get(i), type, type);
+ }
+ return elements;
+ } else if (type.getSimpleName().equals(SpringBeanElement.class.getSimpleName())) {
+ T[] elements = (T[])Array.newInstance(type, getBeanElements().size());
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = SpringElementTie.copy(getBeanElements().get(i), type, type);
+ }
+ return elements;
+ } else {
+ throw new IllegalArgumentException(type + " is not supported");
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAParentApplicationContext.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAParentApplicationContext.java
new file mode 100644
index 0000000000..d2b35ce74e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAParentApplicationContext.java
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context.tie;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.Locale;
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.MessageSourceResolvable;
+import org.springframework.context.NoSuchMessageException;
+import org.springframework.core.io.Resource;
+
+/**
+ * A Spring ParentApplicationContext for a given Spring Implementation
+ *
+ * The Parent application context is responsible for handling those entities within a Spring
+ * application context that actually belong to SCA rather than to Spring. The principal things
+ * are Properties and References. These may be present either through explicit <sca:property/>
+ * and <sca:reference/> elements in the application context or they may be implicit through
+ * unresolved Spring bean <property.../> elements. In either case, it is the Parent application
+ * context that must provide Spring beans that correspond to the property or reference, as derived
+ * from the SCA composite in which the Spring application context is an implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAParentApplicationContext implements ApplicationContext {
+
+ // The Spring implementation for which this is the parent application context
+ private SpringImplementationStub implementation;
+
+ private static final String[] EMPTY_ARRAY = new String[0];
+
+ public SCAParentApplicationContext(SpringImplementationStub implementation) {
+ this.implementation = implementation;
+ } // end constructor
+
+ public Object getBean(String name) throws BeansException {
+ return getBean(name, (Class)null);
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class requiredType) throws BeansException {
+ Object bean = implementation.getBean(name, requiredType);
+ if (bean == null && getParent() != null) {
+ bean = getParent().getBean(name, requiredType);
+ }
+ if (bean == null) {
+ throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name);
+ } else {
+ return bean;
+ }
+ } // end method getBean( String, Class )
+
+ public Object getBean(String name, Object[] args) throws BeansException {
+ return getBean(name, ((Class)null));
+ }
+
+ public <T> T getBean(Class<T> clazz) throws BeansException {
+ return clazz.cast(getBean(clazz.getName(), clazz));
+ }
+
+ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> clazz) throws BeansException {
+ return null;
+ }
+
+ public <A extends Annotation> A findAnnotationOnBean(String arg0, Class<A> clazz) {
+ return null;
+ }
+
+ public boolean containsBean(String name) {
+ // TODO
+ return false;
+ }
+
+ public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+ // TODO
+ return false;
+ }
+
+ public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class getType(String name) throws NoSuchBeanDefinitionException {
+ return null;
+ }
+
+ public String[] getAliases(String name) throws NoSuchBeanDefinitionException {
+ return EMPTY_ARRAY;
+ }
+
+ public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
+ return null;
+ }
+
+ public String getId() {
+ return this.toString();
+ }
+
+ public String getDisplayName() {
+ return implementation.getURI();
+ }
+
+ public long getStartupDate() {
+ return 0;
+ }
+
+ public boolean containsBeanDefinition(String beanName) {
+ return false;
+ }
+
+ public int getBeanDefinitionCount() {
+ return 0;
+ }
+
+ public String[] getBeanDefinitionNames() {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type) {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean includeFactoryBeans) {
+ return new String[0];
+ }
+
+ public Map getBeansOfType(Class type) throws BeansException {
+ return null;
+ }
+
+ public Map getBeansOfType(Class type, boolean includePrototypes, boolean includeFactoryBeans) throws BeansException {
+ return null;
+ }
+
+ public boolean isPrototype(String theString) {
+ return false;
+ }
+
+ public BeanFactory getParentBeanFactory() {
+ return null;
+ }
+
+ public boolean containsLocalBean(String name) {
+ return false;
+ }
+
+ public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
+ return null;
+ }
+
+ public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public void publishEvent(ApplicationEvent event) {
+
+ }
+
+ public Resource[] getResources(String locationPattern) throws IOException {
+ return new Resource[0];
+ }
+
+ public Resource getResource(String location) {
+ return null;
+ }
+
+ public ClassLoader getClassLoader() {
+ // REVIEW: this is almost certainly flawed, but it's not clear how the SCA runtime's
+ // resource loading mechanism is exposed right now.
+ return this.getClass().getClassLoader();
+ }
+
+ @Override
+ public ApplicationContext getParent() {
+ return implementation.getParentApplicationContext();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringContextTie.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringContextTie.java
new file mode 100644
index 0000000000..8bcdc8108d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringContextTie.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context.tie;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.spring.processor.tie.ComponentNameAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.ComponentStub;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.ConstructorAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.InitDestroyAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.PropertyAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.PropertyValueStub;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.ReferenceAnnotationProcessor;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * This is the runtime side tie for the corresponding tuscany side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextStub class
+ * in the implementation-spring module for what the stub does.
+ */
+public class SpringContextTie {
+
+ private AbstractApplicationContext springContext;
+ private SpringImplementationStub implementation;
+
+ public SpringContextTie(SpringImplementationStub implementation, List<URL> resource) {
+ this.implementation = implementation;
+ SCAParentApplicationContext scaParentContext = new SCAParentApplicationContext(implementation);
+ springContext = createApplicationContext(scaParentContext, resource);
+ }
+
+ public ApplicationContext getApplicationContext() {
+ return springContext;
+ }
+
+ public void start() {
+ // Do refresh here to ensure that Spring Beans are not touched before the SCA config process is complete...
+ springContext.refresh();
+ springContext.start();
+ }
+
+ public void close() {
+ springContext.close();
+ if (springContext instanceof GenericApplicationContext) {
+ springContext.stop();
+ }
+ }
+
+ /**
+ * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ */
+ private AbstractApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext,
+ List<URL> resources) {
+
+ GenericApplicationContext appCtx =
+ new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader());
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+ xmlReader.setBeanClassLoader(implementation.getClassLoader());
+ includeAnnotationProcessors(appCtx.getBeanFactory());
+ return appCtx;
+
+ }
+
+ public Object getBean(String id) throws BeansException {
+ return springContext.getBean(id);
+ }
+
+ /**
+ * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ */
+ private void includeAnnotationProcessors(ConfigurableListableBeanFactory beanFactory) {
+
+ // Processor to deal with @Init and @Destroy SCA Annotations
+ BeanPostProcessor initDestroyProcessor = new InitDestroyAnnotationProcessor();
+ beanFactory.addBeanPostProcessor(initDestroyProcessor);
+
+ // Processor to deal with @Reference SCA Annotations
+ ComponentStub component = new ComponentStub(implementation.getComponentTie());
+ BeanPostProcessor referenceProcessor = new ReferenceAnnotationProcessor(component);
+ beanFactory.addBeanPostProcessor(referenceProcessor);
+
+ // Processor to deal with @Property SCA Annotations
+ PropertyValueStub pvs = new PropertyValueStub(implementation.getPropertyValueTie());
+ BeanPostProcessor propertyProcessor = new PropertyAnnotationProcessor(pvs);
+ beanFactory.addBeanPostProcessor(propertyProcessor);
+
+ // Processor to deal with @ComponentName SCA Annotations
+ BeanPostProcessor componentNameProcessor =
+ new ComponentNameAnnotationProcessor(implementation.getComponentName());
+ beanFactory.addBeanPostProcessor(componentNameProcessor);
+
+ // Processor to deal with @Constructor SCA Annotations
+ BeanPostProcessor constructorProcessor = new ConstructorAnnotationProcessor();
+ beanFactory.addBeanPostProcessor(constructorProcessor);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringImplementationStub.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringImplementationStub.java
new file mode 100644
index 0000000000..5ce52e668c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringImplementationStub.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context.tie;
+
+import java.lang.reflect.Method;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * This is the runtime side stub for the corresponding Tuscany-side stub class.
+ * It enables the Spring code in the runtime module to invoke methods on a
+ * Tuscany SpringImplementation without the Spring runtime module
+ * needing to know about any Tuscany classes. See the SpringImplementationTie class
+ * in the implementation-spring module for what the tie does.
+ */
+public class SpringImplementationStub {
+
+ Object tie;
+ Method getURI;
+ Method getBean;
+ Method getComponentName;
+ Method getComponentTie;
+ Method getPropertyValueTie;
+ Method getClassLoader;
+ Method getParentApplicationContext;
+
+ public SpringImplementationStub(Object tie) {
+ this.tie = tie;
+ Class<?> tieClass = tie.getClass();
+ try {
+ getURI = tieClass.getMethod("getURI", new Class<?>[] {});
+ getBean = tieClass.getMethod("getBean", new Class<?>[] {String.class, Class.class});
+ getComponentName = tieClass.getMethod("getComponentName");
+ getComponentTie = tieClass.getMethod("getComponentTie");
+ getPropertyValueTie = tieClass.getMethod("getPropertyValueTie");
+ getClassLoader = tieClass.getMethod("getClassLoader");
+ getParentApplicationContext = tieClass.getMethod("getParentApplicationContext");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getURI() {
+ try {
+
+ return (String)getURI.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class<?> requiredType) throws BeansException {
+ try {
+
+ Object bean = getBean.invoke(tie, new Object[] {name, requiredType});
+// if (bean == null) {
+// throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name);
+// }
+ return bean;
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getComponentName() {
+ try {
+
+ return (String)getComponentName.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getComponentTie() {
+ try {
+
+ return getComponentTie.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getPropertyValueTie() {
+ try {
+
+ return getPropertyValueTie.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public ClassLoader getClassLoader() {
+ try {
+
+ return (ClassLoader)getClassLoader.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Get the parent Spring application context set by the Tuscany runtime
+ * @return
+ */
+ public ApplicationContext getParentApplicationContext() {
+ try {
+
+ return (ApplicationContext)getParentApplicationContext.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java
new file mode 100644
index 0000000000..020e001a59
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <bean> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringBeanElement {
+
+ private String id;
+ private String className = null;
+ private boolean innerBean = false;
+ private boolean abstractBean = false;
+ private boolean parentAttribute = false;
+ private boolean factoryBeanAttribute = false;
+ private boolean factoryMethodAttribute = false;
+
+ private List<SpringPropertyElement> properties = new ArrayList<SpringPropertyElement>();
+ private List<SpringConstructorArgElement> constructorargs = new ArrayList<SpringConstructorArgElement>();
+
+ public SpringBeanElement(String id, String className) {
+ this.id = id;
+ this.className = className;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<SpringPropertyElement> getProperties() {
+ return properties;
+ }
+
+ public void addProperty(SpringPropertyElement property) {
+ properties.add(property);
+ }
+
+ public List<SpringConstructorArgElement> getCustructorArgs() {
+ return constructorargs;
+ }
+
+ public void addCustructorArgs(SpringConstructorArgElement args) {
+ constructorargs.add(args);
+ }
+
+ public boolean isInnerBean() {
+ return innerBean;
+ }
+
+ public void setInnerBean(boolean innerBean) {
+ this.innerBean = innerBean;
+ }
+
+ public boolean isAbstractBean() {
+ return abstractBean;
+ }
+
+ public void setAbstractBean(boolean abstractBean) {
+ this.abstractBean = abstractBean;
+ }
+
+ public boolean hasParentAttribute() {
+ return parentAttribute;
+ }
+
+ public void setParentAttribute(boolean parentAttribute) {
+ this.parentAttribute = parentAttribute;
+ }
+
+ public boolean hasFactoryBeanAttribute() {
+ return factoryBeanAttribute;
+ }
+
+ public void setFactoryBeanAttribute(boolean factoryBeanAttribute) {
+ this.factoryBeanAttribute = factoryBeanAttribute;
+ }
+
+ public boolean hasFactoryMethodAttribute() {
+ return factoryMethodAttribute;
+ }
+
+ public void setFactoryMethodAttribute(boolean factoryMethodAttribute) {
+ this.factoryMethodAttribute = factoryMethodAttribute;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringBeanElement [id=").append(id).append(", className=").append(className)
+ .append(", innerBean=").append(innerBean).append(", abstractBean=").append(abstractBean)
+ .append(", parentAttribute=").append(parentAttribute).append(", factoryBeanAttribute=")
+ .append(factoryBeanAttribute).append(", factoryMethodAttribute=").append(factoryMethodAttribute)
+ .append(", properties=").append(properties).append(", constructorargs=").append(constructorargs)
+ .append("]");
+ return builder.toString();
+ }
+
+} // end class SpringBeanElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java
new file mode 100644
index 0000000000..53a972b7d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <constructor-arg> element in a Spring application-context
+ * - this has ref attribute
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringConstructorArgElement {
+
+ private String type;
+ private int autoIndex = -1;
+ private int index = -1;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringConstructorArgElement(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getAutoIndex() {
+ return this.autoIndex;
+ }
+
+ public void setAutoIndex(int index) {
+ this.autoIndex = index;
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java
new file mode 100644
index 0000000000..c088e5d0f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.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.spring.elements.tie;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A hacking utility to copy beans field by field between two class loaders
+ */
+public class SpringElementTie {
+ public static <T> T copy(Object source, Class<T> cls, Type genericType) {
+ if (source == null) {
+ return null;
+ }
+ if (cls.isPrimitive()) {
+ return (T)source;
+ }
+ if (Collection.class.isAssignableFrom(cls)) {
+ ParameterizedType pType = (ParameterizedType)genericType;
+ Type itemType = pType.getActualTypeArguments()[0];
+ Collection col = (Collection)source;
+ List target = new ArrayList();
+ for (Object item : col) {
+ target.add(copy(item, (Class<?>)itemType, itemType));
+ }
+ return (T)target;
+ }
+ if (cls.isInstance(source)) {
+ return cls.cast(source);
+ }
+ try {
+ Class<?> sourceClass = source.getClass();
+ T target = cls.newInstance();
+ for (Field sourceField : sourceClass.getDeclaredFields()) {
+ sourceField.setAccessible(true);
+ Field targetField = cls.getDeclaredField(sourceField.getName());
+ targetField.setAccessible(true);
+ Object sourceFieldValue = sourceField.get(source);
+ Object targetFieldValue = copy(sourceFieldValue, targetField.getType(), targetField.getGenericType());
+ targetField.set(target, targetFieldValue);
+ }
+ return target;
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java
new file mode 100644
index 0000000000..c0a1f2129b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <property> element in a Spring application-context
+ * - this has name and ref attributes
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringPropertyElement {
+
+ private String name;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringPropertyElement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringPropertyElement [name=").append(name).append(", refs=").append(refs).append(", values=")
+ .append(values).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java
new file mode 100644
index 0000000000..3f9901abea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.elements.tie;
+
+/**
+ * Represents an <sca:property> element in a Spring application-context
+ * - this has name and type attributes
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAPropertyElement {
+
+ private String name;
+ private String type;
+
+ public SpringSCAPropertyElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAPropertyElement [name=").append(name).append(", type=").append(type).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java
new file mode 100644
index 0000000000..7569d2996f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.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.implementation.spring.elements.tie;
+
+
+/**
+ * Represents a <sca:reference> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAReferenceElement {
+
+ private String name;
+ private String type;
+ private String defaultBean;
+
+ public SpringSCAReferenceElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setDefaultBean(String defaultBean) {
+ this.defaultBean = defaultBean;
+ }
+
+ public String getDefaultBean() {
+ return defaultBean;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAReferenceElement [name=").append(name).append(", type=").append(type)
+ .append(", defaultBean=").append(defaultBean).append("]");
+ return builder.toString();
+ }
+
+
+} // end class SpringSCAReferenceElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java
new file mode 100644
index 0000000000..737abe7c04
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.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.implementation.spring.elements.tie;
+
+
+/**
+ * Represents a <sca:service> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAServiceElement {
+
+ private String name;
+ private String type;
+ private String target;
+
+
+ public SpringSCAServiceElement(String name, String target) {
+ this.name = name;
+ this.target = target;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAServiceElement [name=").append(name).append(", type=").append(type)
+ .append(", target=").append(target).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringSCAServiceElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java
new file mode 100644
index 0000000000..07c7c6a454
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.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.sca.implementation.spring.namespace.tie;
+
+import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.NamespaceHandler;
+
+/**
+ * Overrides the default Spring namespace resolver to automatically register
+ * {@link ScaNamespaceHandler} instead of requiring a value to be supplied in a
+ * Spring configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCANamespaceHandlerResolver extends DefaultNamespaceHandlerResolver {
+ private static final String SCA_NAMESPACE = "http://www.springframework.org/schema/sca";
+
+ private ScaNamespaceHandler handler;
+
+ public SCANamespaceHandlerResolver(ClassLoader classLoader) {
+ super(classLoader);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ public SCANamespaceHandlerResolver(String handlerMappingsLocation, ClassLoader classLoader) {
+ super(classLoader, handlerMappingsLocation);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ @Override
+ public NamespaceHandler resolve(String namespaceUri) {
+ if (SCA_NAMESPACE.equals(namespaceUri)) {
+ return handler;
+ }
+ return super.resolve(namespaceUri);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java
new file mode 100644
index 0000000000..6ed49abb6f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace.tie;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ * Handler for the &lt;sca:&gt; namespace in an application context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaNamespaceHandler extends NamespaceHandlerSupport {
+
+ public ScaNamespaceHandler() {
+ }
+
+ @Override
+ public void init() {
+ registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+ registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+ registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java
new file mode 100644
index 0000000000..ad11a300ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace.tie;
+
+import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAPropertyElement;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ * @version $Rev$ $Date$
+ */
+public class ScaPropertyBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAPropertyElement propertyElement =
+ new SpringSCAPropertyElement(element.getAttributeNS(null, "name"), element.getAttributeNS(null, "type"));
+ context.addSCAPropertyElement(propertyElement);
+ }
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java
new file mode 100644
index 0000000000..a4fefa70f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace.tie;
+
+import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAReferenceElement;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaReferenceBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAReferenceElement referenceElement =
+ new SpringSCAReferenceElement(element.getAttributeNS(null, "name"),
+ element.getAttributeNS(null, "type"));
+ referenceElement.setDefaultBean(element.getAttributeNS(null, "default"));
+ context.addSCAReferenceElement(referenceElement);
+ }
+
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java
new file mode 100644
index 0000000000..64f4ce20dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace.tie;
+
+import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAServiceElement;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:service/&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaServiceBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAServiceElement serviceElement =
+ new SpringSCAServiceElement(element.getAttributeNS(null, "name"),
+ element.getAttributeNS(null, "target"));
+ serviceElement.setType(element.getAttributeNS(null, "type"));
+ context.addSCAServiceElement(serviceElement);
+ }
+ // do nothing, handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentNameAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentNameAnnotationProcessor.java
new file mode 100644
index 0000000000..77f9f30bfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentNameAnnotationProcessor.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.implementation.spring.processor.tie;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.ref.Reference;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.ComponentName;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
+
+ private String componentName;
+
+ public ComponentNameAnnotationProcessor(String componentName) {
+ this.componentName = componentName;
+ }
+
+ /**
+ * Gets componentName annotation type.
+ */
+ protected Class<? extends Annotation> getComponentNameAnnotationType() {
+ return this.componentNameAnnotationType;
+ }
+
+ /**
+ * Sets componentName annotation type.
+ */
+ public void setComponentNameAnnotationType(Class<? extends Annotation> componentNameAnnotationType) {
+ Assert.notNull(componentNameAnnotationType, "'componentNameAnnotationType' type must not be null.");
+ this.componentNameAnnotationType = componentNameAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+ Annotation annotation = field.getAnnotation(getComponentNameAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on static fields");
+ }
+
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on private fields");
+ }
+
+ ReflectionUtils.makeAccessible(field);
+
+ if (field.getType().getName().equals("java.lang.String")) {
+ Object nameObj = componentName;
+ if (nameObj != null)
+ ReflectionUtils.setField(field, bean, nameObj);
+ } else {
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+ Annotation annotation = method.getAnnotation(getComponentNameAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on static methods");
+ }
+
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on private methods");
+ }
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException(
+ "ComponentName annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+
+ if (pd.getPropertyType().getName().equals("java.lang.String")) {
+ Object nameObj = componentName;
+ if (nameObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {nameObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
+ }
+ }
+ } else {
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentStub.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentStub.java
new file mode 100644
index 0000000000..7511ac4bd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentStub.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.sca.implementation.spring.processor.tie;
+
+import java.lang.reflect.Method;
+
+/**
+ * This is the Spring runtime side stub for the corresponding Tuscany tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the ComponentTie class
+ * in the implementation-spring module for what the tie does.
+ */
+public class ComponentStub {
+
+ private Object tie;
+ private Method getService;
+
+ public ComponentStub(Object tie) {
+ this.tie = tie;
+ Class<?> tieClass = tie.getClass();
+ try {
+ getService = tieClass.getMethod("getService", new Class<?>[] {Class.class, String.class});
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getService(Class<?> type, String name) {
+ try {
+
+ return getService.invoke(tie, type, name);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ConstructorAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ConstructorAnnotationProcessor.java
new file mode 100644
index 0000000000..503307cfd9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ConstructorAnnotationProcessor.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor.tie;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
+import org.springframework.util.Assert;
+
+public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostProcessorAdapter {
+
+ private Class<? extends Annotation> constructorAnnotationType = org.oasisopen.sca.annotation.Constructor.class;
+
+ private Class<? extends Annotation> autowiredAnnotationType = Autowired.class;
+
+ public ConstructorAnnotationProcessor() {
+ // Default constructor.
+ }
+
+ /**
+ * Set the 'autowired' annotation type, to be used on constructors, fields,
+ * setter methods and arbitrary config methods.
+ */
+ public void setAutowiredAnnotationType(Class<? extends Annotation> autowiredAnnotationType) {
+ Assert.notNull(autowiredAnnotationType, "'autowiredAnnotationType' must not be null");
+ this.autowiredAnnotationType = autowiredAnnotationType;
+ }
+
+ /**
+ * Return the 'autowired' annotation type.
+ */
+ protected Class<? extends Annotation> getAutowiredAnnotationType() {
+ return this.autowiredAnnotationType;
+ }
+
+ /**
+ * Return the 'constructor' annotation type.
+ */
+ protected Class<? extends Annotation> getConstructorAnnotationType() {
+ return this.constructorAnnotationType;
+ }
+
+ /**
+ * Sets the 'constructor' annotation type.
+ */
+ public void setConstructorAnnotationType(Class<? extends Annotation> constructorAnnotationType) {
+ Assert.notNull(constructorAnnotationType, "'constructorAnnotationType' type must not be null.");
+ this.constructorAnnotationType = constructorAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
+ /*Constructor[] declaredConstructors = beanClass.getDeclaredConstructors();
+ Method[] declaredMethods = beanClass.getDeclaredMethods();
+ List candidates = new ArrayList(declaredConstructors.length);
+
+ for (int i = 0; i < declaredMethods.length; i++) {
+ Method method = declaredMethods[i];
+ Annotation annotation = method.getAnnotation(getConstructorAnnotationType());
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Constructor annotation is not supported on static methods");
+ }
+
+ if (candidates.size() == 1) {
+ throw new IllegalStateException("Only one method is allowed to have constructor annotation in a bean: " + method);
+ }
+
+ candidates.add(method);
+ }
+ }
+
+ return (Constructor[]) candidates.toArray(new Constructor[candidates.size()]);*/
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/InitDestroyAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/InitDestroyAnnotationProcessor.java
new file mode 100644
index 0000000000..390ee040f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/InitDestroyAnnotationProcessor.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.sca.implementation.spring.processor.tie;
+
+import java.lang.annotation.Annotation;
+
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
+
+public class InitDestroyAnnotationProcessor extends InitDestroyAnnotationBeanPostProcessor {
+
+ private static final long serialVersionUID = 0;
+
+ private Class<? extends Annotation> initAnnotationType = Init.class;
+ private Class<? extends Annotation> destroyAnnotationType = Destroy.class;
+
+ /**
+ * Gets init annotation type.
+ */
+ protected Class<? extends Annotation> getInitAnnotationType() {
+ return this.initAnnotationType;
+ }
+
+ /**
+ * Sets init annotation type.
+ */
+ /*
+ * public void setInitAnnotationType(Class<? extends Annotation>
+ * initAnnotationType) { Assert.notNull(initAnnotationType,
+ * "Init annotation type must not be null."); this.initAnnotationType =
+ * initAnnotationType; }
+ */
+
+ /**
+ * Gets destroy annotation type.
+ */
+ protected Class<? extends Annotation> getDestroyAnnotationType() {
+ return this.destroyAnnotationType;
+ }
+
+ /**
+ * Sets destroy annotation type.
+ */
+ /*
+ * public void setDestroyAnnotationType(Class<? extends Annotation>
+ * destroyAnnotationType) { Assert.notNull(destroyAnnotationType,
+ * "Destroy annotation type must not be null."); this.destroyAnnotationType
+ * = destroyAnnotationType; }
+ */
+
+ public InitDestroyAnnotationProcessor() {
+ // Set the @Init annotation type
+ setInitAnnotationType(initAnnotationType);
+
+ // Set the @Destroy annotation type
+ setDestroyAnnotationType(destroyAnnotationType);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyAnnotationProcessor.java
new file mode 100644
index 0000000000..ce3aafd3ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyAnnotationProcessor.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor.tie;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.Property;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class PropertyAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> propertyAnnotationType = Property.class;
+
+ private PropertyValueStub propertyValue;
+
+ public PropertyAnnotationProcessor(PropertyValueStub propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+ /**
+ * Gets property annotation type.
+ */
+ protected Class<? extends Annotation> getPropertyAnnotationType() {
+ return this.propertyAnnotationType;
+ }
+
+ /**
+ * Sets property annotation type.
+ */
+ public void setPropertyAnnotationType(Class<? extends Annotation> propertyAnnotationType) {
+ Assert.notNull(propertyAnnotationType, "'propertyAnnotationType' type must not be null.");
+ this.propertyAnnotationType = propertyAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Property} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+
+ Property annotation = (Property)method.getAnnotation(getPropertyAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on static methods");
+ }
+
+ /*
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on private methods");
+ }
+ */
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException("Property annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+ if (pd != null) {
+ String propName = annotation.name();
+ if ("".equals(propName)) {
+ injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), pd.getName()));
+ } else {
+ injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), propName));
+ }
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+
+ Property annotation = (Property)field.getAnnotation(getPropertyAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on static fields");
+ }
+
+ /*
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on private fields");
+ }
+ */
+
+ ReflectionUtils.makeAccessible(field);
+
+ Object propertyObj = null;
+ String propName = annotation.name();
+ if ("".equals(propName)) {
+ propertyObj = propertyValue.getPropertyObj(field.getType(), field.getName());
+ } else {
+ propertyObj = propertyValue.getPropertyObj(field.getType(), propName);
+ }
+
+ if (propertyObj != null)
+ ReflectionUtils.setField(field, bean, propertyObj);
+ }
+ }
+ });
+ }
+
+ public void injectProperty(Object bean, PropertyDescriptor pd, Object propertyObj) {
+
+ if (propertyObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {propertyObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting property: " + e.getMessage(), e);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyValueStub.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyValueStub.java
new file mode 100644
index 0000000000..5a4b57ce81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyValueStub.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.spring.processor.tie;
+
+import java.lang.reflect.Method;
+
+/**
+ * This is the Spring runtime side stub for the corresponding Tuscany tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the PropertyValueTie class
+ * in the implementation-spring module for what the tie does.
+ */
+public class PropertyValueStub {
+
+ private Object tie;
+ private Method getPropertyObj;
+
+ public PropertyValueStub(Object tie) {
+ this.tie = tie;
+ Class<?> tieClass = tie.getClass();
+ try {
+ getPropertyObj = tieClass.getMethod("getPropertyObj", new Class<?>[] {Class.class, String.class});
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getPropertyObj(Class<?> propertyType, String name) {
+ try {
+
+ return getPropertyObj.invoke(tie, propertyType, name);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ReferenceAnnotationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ReferenceAnnotationProcessor.java
new file mode 100644
index 0000000000..24761d2cfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ReferenceAnnotationProcessor.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor.tie;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ReferenceAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> referenceAnnotationType = Reference.class;
+ private ComponentStub component;
+
+ public ReferenceAnnotationProcessor(ComponentStub component) {
+ this.component = component;
+ }
+
+ /**
+ * Gets referece annotation type.
+ */
+ protected Class<? extends Annotation> getReferenceAnnotationType() {
+ return this.referenceAnnotationType;
+ }
+
+ /**
+ * Sets referece annotation type.
+ */
+ public void setReferenceAnnotationType(Class<? extends Annotation> referenceAnnotationType) {
+ Assert.notNull(referenceAnnotationType, "'referenceAnnotationType' type must not be null.");
+ this.referenceAnnotationType = referenceAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+
+ Reference annotation = (Reference)method.getAnnotation(getReferenceAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on static methods");
+ }
+
+ /*
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on private methods");
+ }
+ */
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException(
+ "Reference annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+ if (pd != null) {
+ String refName = annotation.name();
+ if ("".equals(refName)) {
+ injectReference(bean, pd, pd.getName());
+ } else {
+ injectReference(bean, pd, refName);
+ }
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+
+ Reference annotation = (Reference)field.getAnnotation(getReferenceAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on static fields");
+ }
+
+ /*
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on private fields");
+ }
+ */
+
+ ReflectionUtils.makeAccessible(field);
+
+ Object referenceObj = null;
+ String refName = annotation.name();
+ if ("".equals(refName)) {
+ referenceObj = component.getService(field.getType(), field.getName());
+ } else {
+ referenceObj = component.getService(field.getType(), refName);
+ }
+
+ if (referenceObj != null)
+ ReflectionUtils.setField(field, bean, referenceObj);
+ }
+ }
+ });
+ }
+
+ /**
+ * Processes a property descriptor to inject a service.
+ */
+ public void injectReference(Object bean, PropertyDescriptor pd, String name) {
+
+ Object referenceObj = component.getService(pd.getPropertyType(), name);
+
+ if (referenceObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {referenceObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/SpringXMLLoaderTie.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/SpringXMLLoaderTie.java
new file mode 100644
index 0000000000..82aa176219
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/SpringXMLLoaderTie.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.spring.processor.tie;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * A tie that allows Tuscany to call Spring library to load the application context for the purpose of introspection
+ */
+public class SpringXMLLoaderTie {
+
+ public static ApplicationContext createApplicationContext(Object scaParentContext,
+ ClassLoader classLoader,
+ List<URL> resources) {
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+
+ SCAGenericApplicationContext appCtx =
+ new SCAGenericApplicationContext((ApplicationContext)scaParentContext, classLoader);
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+
+ return appCtx;
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/META-INF/spring.handlers b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000000..e7b61bfe48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+http\://www.springframework.org/schema/sca=org.apache.tuscany.sca.implementation.spring.namespace.tie.ScaNamespaceHandler
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/META-INF/spring.schemas b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000000..249cc21c13
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd=org/springframework/sca/xml/spring-sca.xsd
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/org/springframework/sca/xml/spring-sca.xsd b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
new file mode 100644
index 0000000000..dfa0b931f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring-tie/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
@@ -0,0 +1,84 @@
+<?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.
+-->
+<xsd:schema xmlns="http://www.springframework.org/schema/sca" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ attributeFormDefault="unqualified" elementFormDefault="qualified"
+ targetNamespace="http://www.springframework.org/schema/sca">
+
+ <xsd:element name="reference">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="default" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="service">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="target" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/LICENSE b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/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/sebastien/java/embed/contrib/modules/implementation-spring/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9226b047d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/META-INF/MANIFEST.MF
@@ -0,0 +1,50 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Model
+Import-Package: javax.jws,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.injection;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.implementation.spring;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring.xml;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.implementation.spring,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ javax.xml.namespace"
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/NOTICE b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/pom.xml b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/pom.xml
new file mode 100644
index 0000000000..371bde71b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/pom.xml
@@ -0,0 +1,59 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java
new file mode 100644
index 0000000000..64b36a0a44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.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.sca.implementation.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <bean> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringBeanElement {
+
+ private String id;
+ private String className = null;
+ private boolean innerBean = false;
+ private boolean abstractBean = false;
+ private boolean parentAttribute = false;
+ private boolean factoryBeanAttribute = false;
+ private boolean factoryMethodAttribute = false;
+
+ private List<SpringPropertyElement> properties = new ArrayList<SpringPropertyElement>();
+ private List<SpringConstructorArgElement> constructorargs = new ArrayList<SpringConstructorArgElement>();
+
+ public SpringBeanElement() {
+ }
+
+ public SpringBeanElement(String id, String className) {
+ this.id = id;
+ this.className = className;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<SpringPropertyElement> getProperties() {
+ return properties;
+ }
+
+ public void addProperty(SpringPropertyElement property) {
+ properties.add(property);
+ }
+
+ public List<SpringConstructorArgElement> getCustructorArgs() {
+ return constructorargs;
+ }
+
+ public void addCustructorArgs(SpringConstructorArgElement args) {
+ constructorargs.add(args);
+ }
+
+ public boolean isInnerBean() {
+ return innerBean;
+ }
+
+ public void setInnerBean(boolean innerBean) {
+ this.innerBean = innerBean;
+ }
+
+ public boolean isAbstractBean() {
+ return abstractBean;
+ }
+
+ public void setAbstractBean(boolean abstractBean) {
+ this.abstractBean = abstractBean;
+ }
+
+ public boolean hasParentAttribute() {
+ return parentAttribute;
+ }
+
+ public void setParentAttribute(boolean parentAttribute) {
+ this.parentAttribute = parentAttribute;
+ }
+
+ public boolean hasFactoryBeanAttribute() {
+ return factoryBeanAttribute;
+ }
+
+ public void setFactoryBeanAttribute(boolean factoryBeanAttribute) {
+ this.factoryBeanAttribute = factoryBeanAttribute;
+ }
+
+ public boolean hasFactoryMethodAttribute() {
+ return factoryMethodAttribute;
+ }
+
+ public void setFactoryMethodAttribute(boolean factoryMethodAttribute) {
+ this.factoryMethodAttribute = factoryMethodAttribute;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringBeanElement [id=").append(id).append(", className=").append(className)
+ .append(", innerBean=").append(innerBean).append(", abstractBean=").append(abstractBean)
+ .append(", parentAttribute=").append(parentAttribute).append(", factoryBeanAttribute=")
+ .append(factoryBeanAttribute).append(", factoryMethodAttribute=").append(factoryMethodAttribute)
+ .append(", properties=").append(properties).append(", constructorargs=").append(constructorargs)
+ .append("]");
+ return builder.toString();
+ }
+
+} // end class SpringBeanElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java
new file mode 100644
index 0000000000..1de0595d60
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.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.implementation.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <constructor-arg> element in a Spring application-context
+ * - this has ref attribute
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringConstructorArgElement {
+
+ private String type;
+ private int autoIndex = -1;
+ private int index = -1;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringConstructorArgElement() {
+
+ }
+
+ public SpringConstructorArgElement(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getAutoIndex() {
+ return this.autoIndex;
+ }
+
+ public void setAutoIndex(int index) {
+ this.autoIndex = index;
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringConstructorArgElement [type=").append(type).append(", autoIndex=").append(autoIndex)
+ .append(", index=").append(index).append(", refs=").append(refs).append(", values=").append(values)
+ .append("]");
+ return builder.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
new file mode 100644
index 0000000000..a5d4adb1bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a Spring implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringImplementation extends ImplementationImpl implements Implementation, Extensible {
+ public final static QName TYPE = new QName(SCA11_NS, "implementation.spring");
+ // The location attribute which points to the Spring application-context XML file
+ private String location;
+ // The application-context file as a Spring Resource
+ private List<URL> resource;
+ private ComponentType componentType;
+ // Mapping of Services to Beans
+ private Map<String, SpringBeanElement> serviceMap;
+ // Mapping of property names to Java class
+ private Map<String, Class<?>> propertyMap;
+ // List of unresolved bean property references
+ private Map<String, Reference> unresolvedBeanRef;
+ private ClassLoader classLoader;
+
+ public SpringImplementation() {
+ super(TYPE);
+ this.location = null;
+ this.resource = null;
+ setUnresolved(true);
+ serviceMap = new HashMap<String, SpringBeanElement>();
+ propertyMap = new HashMap<String, Class<?>>();
+ unresolvedBeanRef = new HashMap<String, Reference>();
+ } // end method SpringImplementation
+
+ /* Returns the location attribute for this Spring implementation */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * Sets the location attribute for this Spring implementation
+ * location - a URI to the Spring application-context file
+ */
+ public void setLocation(String location) {
+ this.location = location;
+ return;
+ }
+
+ public void setResource(List<URL> resource) {
+ this.resource = resource;
+ }
+
+ public List<URL> getResource() {
+ return resource;
+ }
+
+ /*
+ * Returns the componentType for this Spring implementation
+ */
+ public ComponentType getComponentType() {
+ return componentType;
+ }
+
+ /*
+ * Sets the componentType for this Spring implementation
+ */
+ public void setComponentType(ComponentType componentType) {
+ this.componentType = componentType;
+ }
+
+ @Override
+ public List<Service> getServices() {
+ return componentType.getServices();
+ }
+
+ @Override
+ public List<Reference> getReferences() {
+ return componentType.getReferences();
+ }
+
+ @Override
+ public List<Property> getProperties() {
+ return componentType.getProperties();
+ }
+
+ /**
+ * Returns the Spring Bean which implements a particular service
+ * @param service the service
+ * @return the bean which implements the service, as a SpringBeanElement
+ */
+ public SpringBeanElement getBeanFromService(Service service) {
+ SpringBeanElement theBean = serviceMap.get(service.getName());
+ return theBean;
+ }
+
+ /**
+ * Sets the mapping from a service to the Spring Bean that implements the service
+ * @param service the service
+ * @param theBean a SpringBeanElement for the Bean implementing the service
+ */
+ public void setBeanForService(Service service, SpringBeanElement theBean) {
+ serviceMap.put(service.getName(), theBean);
+ }
+
+ /**
+ * Add a mapping from a SCA property name to a Java class for the property
+ * @param propertyName
+ * @param propertyClass
+ */
+ public void setPropertyClass(String propertyName, Class<?> propertyClass) {
+ if (propertyName == null || propertyClass == null)
+ return;
+ propertyMap.put(propertyName, propertyClass);
+ return;
+ } // end method setPropertyClass
+
+ /**
+ * Gets the Java Class for an SCA property
+ * @param propertyName - the property name
+ * @return - a Class object for the type of the property
+ */
+ public Class<?> getPropertyClass(String propertyName) {
+ return propertyMap.get(propertyName);
+ } // end method getPropertyClass
+
+ public void setUnresolvedBeanRef(String refName, Reference reference) {
+ if (refName == null || reference == null)
+ return;
+ unresolvedBeanRef.put(refName, reference);
+ return;
+ } // end method setUnresolvedBeanRef
+
+ public Reference getUnresolvedBeanRef(String refName) {
+ return unresolvedBeanRef.get(refName);
+ } // end method getUnresolvedBeanRef
+
+ /**
+ * Use preProcess to validate and map the references and properties dynamically
+ */
+ public void build(Component component) {
+
+ for (Reference reference : component.getReferences()) {
+ if (unresolvedBeanRef.containsKey(reference.getName())) {
+ Reference ref = unresolvedBeanRef.get(reference.getName());
+ componentType.getReferences().add(createReference(reference, ref.getInterfaceContract()));
+ unresolvedBeanRef.remove(reference.getName());
+ }
+ }
+
+ for (Property property : component.getProperties()) {
+ if (unresolvedBeanRef.containsKey(property.getName())) {
+ componentType.getProperties().add(createProperty(property));
+ this.setPropertyClass(property.getName(), property.getClass());
+ unresolvedBeanRef.remove(property.getName());
+ }
+ }
+ }
+
+ protected Reference createReference(Reference reference, InterfaceContract interfaze) {
+ Reference newReference;
+ try {
+ newReference = (Reference)reference.clone();
+ if (newReference.getInterfaceContract() == null)
+ newReference.setInterfaceContract(interfaze);
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e); // should not ever happen
+ }
+ return newReference;
+ }
+
+ protected Property createProperty(Property property) {
+ Property newProperty;
+ try {
+ newProperty = (Property)property.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e); // should not ever happen
+ }
+ return newProperty;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (!(obj instanceof SpringImplementation)) {
+ return false;
+ }
+ SpringImplementation other = (SpringImplementation)obj;
+ if (location == null) {
+ if (other.location != null) {
+ return false;
+ }
+ } else if (!location.equals(other.location)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringImplementation [location=").append(location).append(", resource=").append(resource)
+ .append("]");
+ return builder.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java
new file mode 100644
index 0000000000..1a246fa03a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.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.implementation.spring;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder;
+
+/**
+ *
+ */
+public class SpringImplementationBuilder implements ImplementationBuilder<SpringImplementation> {
+
+ public void build(Component component, SpringImplementation implmentation, BuilderContext context) {
+ implmentation.build(component);
+ }
+
+ public QName getImplementationType() {
+ return SpringImplementation.TYPE;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java
new file mode 100644
index 0000000000..27c09c1f18
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.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.implementation.spring;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants used in Spring Application Context XML files.
+ */
+public interface SpringImplementationConstants {
+
+ String SCA_NS = "http://www.springframework.org/schema/sca";
+ String SPRING_NS = "http://www.springframework.org/schema/beans";
+
+ String PROPERTY = "property";
+ QName SCA_PROPERTY_ELEMENT = new QName(SCA_NS, PROPERTY);
+ QName PROPERTY_ELEMENT = new QName(SPRING_NS, PROPERTY);
+
+ String SCASERVICE = "service";
+ QName SCA_SERVICE_ELEMENT = new QName(SCA_NS, SCASERVICE);
+
+ String SCAREFERENCE = "reference";
+ QName SCA_REFERENCE_ELEMENT = new QName(SCA_NS, SCAREFERENCE);
+
+ String BEANS = "beans";
+ QName BEANS_ELEMENT = new QName(SPRING_NS, BEANS);
+
+ String IMPORT = "import";
+ QName IMPORT_ELEMENT = new QName(SPRING_NS, IMPORT);
+
+ String BEAN = "bean";
+ QName BEAN_ELEMENT = new QName(SPRING_NS, BEAN);
+
+ String CONSTRUCTORARG = "constructor-arg";
+ QName CONSTRUCTORARG_ELEMENT = new QName(SPRING_NS, CONSTRUCTORARG);
+
+ String LIST = "list";
+ QName LIST_ELEMENT = new QName(SPRING_NS, LIST);
+
+ String SET = "set";
+ QName SET_ELEMENT = new QName(SPRING_NS, SET);
+
+ String MAP = "map";
+ QName MAP_ELEMENT = new QName(SPRING_NS, MAP);
+
+ String VALUE = "value";
+ QName VALUE_ELEMENT = new QName(SPRING_NS, VALUE);
+
+ String REF = "ref";
+ QName REF_ELEMENT = new QName(SPRING_NS, REF);
+
+ String ENTRY = "entry";
+ QName ENTRY_ELEMENT = new QName(SPRING_NS, ENTRY);
+
+ String APPLICATION_CONTEXT = "application-context.xml";
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java
new file mode 100644
index 0000000000..8de3a4cbe1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.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.implementation.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <property> element in a Spring application-context
+ * - this has name and ref attributes
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringPropertyElement {
+
+ private String name;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringPropertyElement() {
+ }
+
+ public SpringPropertyElement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringPropertyElement [name=").append(name).append(", refs=").append(refs).append(", values=")
+ .append(values).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java
new file mode 100644
index 0000000000..f27506f28b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.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.sca.implementation.spring;
+
+/**
+ * Represents an <sca:property> element in a Spring application-context
+ * - this has name and type attributes
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAPropertyElement {
+
+ private String name;
+ private String type;
+
+ public SpringSCAPropertyElement() {
+ super();
+ }
+
+ public SpringSCAPropertyElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAPropertyElement [name=").append(name).append(", type=").append(type).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
new file mode 100644
index 0000000000..74cd3f4290
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a <sca:reference> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAReferenceElement {
+
+ private String name;
+ private String type;
+ private String defaultBean;
+ private List<Intent> intents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ public SpringSCAReferenceElement() {
+
+ }
+
+ public SpringSCAReferenceElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setDefaultBean(String defaultBean) {
+ this.defaultBean = defaultBean;
+ }
+
+ public String getDefaultBean() {
+ return defaultBean;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return intents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAReferenceElement [name=").append(name).append(", type=").append(type)
+ .append(", defaultBean=").append(defaultBean).append(", intents=").append(intents).append(", policySets=")
+ .append(policySets).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringSCAReferenceElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
new file mode 100644
index 0000000000..181bd7a787
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a <sca:service> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAServiceElement {
+
+ private String name;
+ private String type;
+ private String target;
+ private List<Intent> intents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ public SpringSCAServiceElement() {
+
+ }
+
+ public SpringSCAServiceElement(String name, String target) {
+ this.name = name;
+ this.target = target;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return intents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAServiceElement [name=").append(name).append(", type=").append(type)
+ .append(", target=").append(target).append(", intents=").append(intents).append(", policySets=")
+ .append(policySets).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringSCAServiceElement
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
new file mode 100644
index 0000000000..5eaf27ab81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.introspect;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+
+/**
+ * Provides introspection functions for Spring beans
+ * This version leans heavily on the implementation-java classes
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringBeanIntrospector {
+
+ private JavaImplementationFactory javaImplementationFactory;
+
+ /**
+ * The constructor sets up the various visitor elements that will be used to introspect
+ * the Spring bean and extract SCA information.
+ *
+ * @param assemblyFactory The Assembly Factory to use
+ * @param javaFactory The Java Interface Factory to use
+ * @param policyFactory The Policy Factory to use.
+ */
+ public SpringBeanIntrospector(ExtensionPointRegistry registry, List<SpringConstructorArgElement> conArgs) {
+
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ javaImplementationFactory = factories.getFactory(JavaImplementationFactory.class);
+ } // end constructor
+
+ /**
+ * Introspect a Spring Bean and extract the features important to SCA
+ * @param beanClass the Spring Bean class to introspect
+ * @param componentType the componentType that is filled in through the introspection
+ * process (assumed empty on invocation, filled on return
+ * @return a Map of property names to JavaElementImpl
+ * @throws ContributionResolveException - if there was a problem resolving the
+ * Spring Bean or its componentType
+ *
+ */
+ public JavaImplementation introspectBean(Class<?> beanClass, ComponentType componentType)
+ throws ContributionResolveException {
+ if (componentType == null)
+ throw new ContributionResolveException("Introspect Spring bean: supplied componentType is null");
+
+ // Create a Java implementation ready for the introspection
+ JavaImplementation javaImplementation = javaImplementationFactory.createJavaImplementation();
+ // Set the type to be implementation.spring to avoid heuristic introspection
+ javaImplementation.setType(SpringImplementation.TYPE);
+
+ try {
+ // Introspect the bean...the results of the introspection are placed into the Java implementation
+ javaImplementationFactory.createJavaImplementation(javaImplementation, beanClass);
+
+ // Extract the services, references & properties found through introspection
+ // put the services, references and properties into the component type
+ componentType.getServices().addAll(javaImplementation.getServices());
+ componentType.getReferences().addAll(javaImplementation.getReferences());
+ componentType.getProperties().addAll(javaImplementation.getProperties());
+
+ } catch (IntrospectionException e) {
+ throw new ContributionResolveException(e);
+ } // end try
+
+ return javaImplementation;
+
+ } // end method introspectBean
+
+} // end class SpringBeanIntrospector
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
new file mode 100644
index 0000000000..2730ee3146
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
@@ -0,0 +1,917 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.introspect;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.SpringPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Introspects a Spring XML application-context configuration file to create <implementation-spring../>
+ * component type information.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringXMLComponentTypeLoader {
+ private final static Logger log = Logger.getLogger(SpringXMLComponentTypeLoader.class.getName());
+
+ private ExtensionPointRegistry registry;
+ private ContributionFactory contributionFactory;
+ private AssemblyFactory assemblyFactory;
+ private JavaInterfaceFactory javaFactory;
+ private SpringBeanIntrospector beanIntrospector;
+
+ private SpringXMLBeanDefinitionLoader xmlBeanDefinitionLoader;
+
+ public SpringXMLComponentTypeLoader(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.javaFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.contributionFactory = factories.getFactory(ContributionFactory.class);
+ this.xmlBeanDefinitionLoader =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(SpringXMLBeanDefinitionLoader.class);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ protected Class<SpringImplementation> getImplementationClass() {
+ return SpringImplementation.class;
+ }
+
+ /**
+ * Base method which loads the component type from the application-context attached to the
+ * Spring implementation
+ *
+ */
+ public void load(SpringImplementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionReadException {
+ //System.out.println("Spring TypeLoader - load method start");
+ ComponentType componentType = implementation.getComponentType();
+ /* Check that there is a component type object already set */
+ if (componentType == null) {
+ throw new ContributionReadException("SpringXMLLoader load: implementation has no ComponentType object");
+ }
+ if (componentType.isUnresolved()) {
+ /* Fetch the location of the application-context file from the implementation */
+ loadFromXML(implementation, resolver, context);
+ if (!componentType.isUnresolved())
+ implementation.setUnresolved(false);
+ } // end if
+ //System.out.println("Spring TypeLoader - load method complete");
+ } // end method load
+
+ private Class<?> resolveClass(ModelResolver resolver, String className, ProcessorContext context)
+ throws ClassNotFoundException {
+ ClassReference classReference = new ClassReference(className);
+ classReference = resolver.resolveModel(ClassReference.class, classReference, context);
+ if (classReference.isUnresolved()) {
+ throw new ClassNotFoundException(className);
+ }
+ Class<?> javaClass = classReference.getJavaClass();
+ return javaClass;
+ }
+
+ /**
+ * Method which fills out the component type for a Spring implementation by reading the
+ * Spring application-context.xml file.
+ *
+ * @param implementation SpringImplementation into which to load the component type information
+ * @throws ContributionReadException Failed to read the contribution
+ */
+ private void loadFromXML(SpringImplementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionReadException {
+ List<SpringBeanElement> beans = new ArrayList<SpringBeanElement>();
+ List<SpringSCAServiceElement> services = new ArrayList<SpringSCAServiceElement>();
+ List<SpringSCAReferenceElement> references = new ArrayList<SpringSCAReferenceElement>();
+ List<SpringSCAPropertyElement> scaproperties = new ArrayList<SpringSCAPropertyElement>();
+
+ URL resource;
+ List<URL> contextResources = new ArrayList<URL>();
+ String contextPath = implementation.getLocation();
+
+ try {
+ resource = resolveLocation(resolver, contextPath, context);
+ contextResources = getApplicationContextResource(resource);
+
+ implementation.setClassLoader(new ContextClassLoader(resolver, context));
+ implementation.setResource(contextResources);
+ // The URI is used to uniquely identify the Implementation
+ implementation.setURI(resource.toString());
+
+ List<SpringBeanElement> appCxtBeans = new ArrayList<SpringBeanElement>();
+ List<SpringSCAServiceElement> appCxtServices = new ArrayList<SpringSCAServiceElement>();
+ List<SpringSCAReferenceElement> appCxtReferences = new ArrayList<SpringSCAReferenceElement>();
+ List<SpringSCAPropertyElement> appCxtProperties = new ArrayList<SpringSCAPropertyElement>();
+
+ if (xmlBeanDefinitionLoader != null) {
+ xmlBeanDefinitionLoader.load(contextResources,
+ appCxtServices,
+ appCxtReferences,
+ appCxtProperties,
+ appCxtBeans,
+ context);
+ }
+ // Validate the beans from individual application context for uniqueness
+ validateBeans(appCxtBeans, appCxtServices, appCxtReferences, appCxtProperties, context.getMonitor());
+ // Add all the validated beans to the generic list
+ beans.addAll(appCxtBeans);
+ services.addAll(appCxtServices);
+ references.addAll(appCxtReferences);
+ scaproperties.addAll(appCxtProperties);
+ } catch (Throwable e) {
+ throw new ContributionReadException(e);
+ }
+
+ /* At this point, the complete application-context.xml file has been read and its contents */
+ /* stored in the lists of beans, services, references. These are now used to generate */
+ /* the implied componentType for the application context */
+ generateComponentType(implementation, resolver, beans, services, references, scaproperties, context);
+
+ return;
+ } // end method loadFromXML
+
+ private URL resolveLocation(ModelResolver resolver, String contextPath, ProcessorContext context)
+ throws MalformedURLException, ContributionReadException {
+ URL resource = null;
+ URI uri = URI.create(contextPath);
+ if (!uri.isAbsolute()) {
+ Artifact parent = context.getArtifact();
+ if (parent != null && parent.getURI() != null) {
+ URI base = URI.create("/" + parent.getURI());
+ uri = base.resolve(uri);
+ // Remove the leading / to make artifact resolver happy
+ if (uri.toString().startsWith("/")) {
+ uri = URI.create(uri.toString().substring(1));
+ }
+ }
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setUnresolved(true);
+ artifact.setURI(uri.toString());
+ artifact = resolver.resolveModel(Artifact.class, artifact, context);
+ if (!artifact.isUnresolved()) {
+ resource = new URL(artifact.getLocation());
+ } else {
+ throw new ContributionReadException("Location cannot be resloved: " + contextPath);
+ }
+ } else {
+ resource = new URL(contextPath);
+ }
+ return resource;
+ }
+
+ /**
+ * Generates the Spring implementation component type from the configuration contained in the
+ * lists of beans, services, references and scaproperties derived from the application context
+ */
+ private void generateComponentType(SpringImplementation implementation,
+ ModelResolver resolver,
+ List<SpringBeanElement> beans,
+ List<SpringSCAServiceElement> services,
+ List<SpringSCAReferenceElement> references,
+ List<SpringSCAPropertyElement> scaproperties,
+ ProcessorContext context) throws ContributionReadException {
+ /*
+ * 1. Each sca:service becomes a service in the component type
+ * 2. Each sca:reference becomes a reference in the component type
+ * 3. Each sca:property becomes a property in the component type
+ * 4. IF there are no explicit service elements, each bean becomes a service
+ * 5. Each bean property which is a reference not pointing at another bean in the
+ * application context becomes a reference unless it is pointing at one of the references
+ * 6. Each bean property which is not a reference and which is not pointing
+ * at another bean in the application context becomes a property in the component type
+ */
+
+ JavaImplementation javaImplementation = null;
+ ComponentType componentType = implementation.getComponentType();
+
+ try {
+ // Deal with the services first....
+ Iterator<SpringSCAServiceElement> its = services.iterator();
+ while (its.hasNext()) {
+ SpringSCAServiceElement serviceElement = its.next();
+ Class<?> interfaze = resolveClass(resolver, serviceElement.getType(), context);
+ Service theService = createService(interfaze, serviceElement.getName());
+ // Spring allows duplication of bean definitions in multiple context scenario,
+ // in such cases, the latest bean definition overrides the older ones, hence
+ // we will remove any older definition and use the latest.
+ Service duplicate = null;
+ for (Service service : componentType.getServices()) {
+ if (service.getName().equals(theService.getName()))
+ duplicate = service;
+ }
+ if (duplicate != null)
+ componentType.getServices().remove(duplicate);
+
+ componentType.getServices().add(theService);
+ // Add this service to the Service / Bean map
+ String beanName = serviceElement.getTarget();
+ for (SpringBeanElement beanElement : beans) {
+ if (beanName.equals(beanElement.getId())) {
+ if (isValidBeanForService(beanElement)) {
+ // add the required intents and policySets for the service
+ theService.getRequiredIntents().addAll(serviceElement.getRequiredIntents());
+ theService.getPolicySets().addAll(serviceElement.getPolicySets());
+ implementation.setBeanForService(theService, beanElement);
+ }
+ }
+ } // end for
+ } // end while
+
+ // Next handle the references
+ Iterator<SpringSCAReferenceElement> itr = references.iterator();
+ while (itr.hasNext()) {
+ SpringSCAReferenceElement referenceElement = itr.next();
+ Class<?> interfaze = resolveClass(resolver, referenceElement.getType(), context);
+ Reference theReference = createReference(interfaze, referenceElement.getName());
+ // Override the older bean definition with the latest ones
+ // for the duplicate definitions found.
+ Reference duplicate = null;
+ for (Reference reference : componentType.getReferences()) {
+ if (reference.getName().equals(theReference.getName()))
+ duplicate = reference;
+ }
+ if (duplicate != null)
+ componentType.getReferences().remove(duplicate);
+
+ // add the required intents and policySets for this reference
+ theReference.getRequiredIntents().addAll(referenceElement.getRequiredIntents());
+ theReference.getPolicySets().addAll(referenceElement.getPolicySets());
+ componentType.getReferences().add(theReference);
+ } // end while
+
+ // Next handle the properties
+ Iterator<SpringSCAPropertyElement> itsp = scaproperties.iterator();
+ while (itsp.hasNext()) {
+ SpringSCAPropertyElement scaproperty = itsp.next();
+ // Create a component type property if the SCA property element has a name
+ // and a type declared...
+ if (scaproperty.getType() != null && scaproperty.getName() != null) {
+ Property theProperty = assemblyFactory.createProperty();
+ theProperty.setName(scaproperty.getName());
+ // Get the Java class and then an XSD element type for the property
+ Class<?> propType = Class.forName(scaproperty.getType());
+ theProperty.setXSDType(JavaXMLMapper.getXMLType(propType));
+ // Override the older bean definition with the latest ones
+ // for the duplicate definitions found.
+ Property duplicate = null;
+ for (Property property : componentType.getProperties()) {
+ if (property.getName().equals(theProperty.getName()))
+ duplicate = property;
+ }
+ if (duplicate != null)
+ componentType.getProperties().remove(duplicate);
+
+ componentType.getProperties().add(theProperty);
+ // Remember the Java Class (ie the type) for this property
+ implementation.setPropertyClass(theProperty.getName(), propType);
+ } // end if
+ } // end while
+
+ // Finally deal with the beans
+ Iterator<SpringBeanElement> itb;
+ // If there are no explicit service elements, then expose all the beans
+ if (services.isEmpty()) {
+ itb = beans.iterator();
+ // Loop through all the beans found
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+
+ // If its not a valid bean for service, ignore it
+ if (!isValidBeanForService(beanElement)) {
+ continue;
+ }
+ try {
+ // Load the Spring bean class
+ Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
+ // Introspect the bean
+ beanIntrospector = new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
+ ComponentType beanComponentType = assemblyFactory.createComponentType();
+ javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
+ // Set the service name as bean name
+ for (Service componentService : beanComponentType.getServices()) {
+ componentService.setName(beanElement.getId());
+ }
+ // Get the service interface defined by this Spring Bean and add to
+ // the component type of the Spring Assembly
+ List<Service> beanServices = beanComponentType.getServices();
+ componentType.getServices().addAll(beanServices);
+ // Add these services to the Service / Bean map
+ for (Service beanService : beanServices) {
+ implementation.setBeanForService(beanService, beanElement);
+ }
+ } catch (Throwable e) {
+ // [rfeng] FIXME: Some Spring beans have constructors that take pararemters injected by Spring and
+ // Tuscany is not happy with that during the introspection
+ log.log(Level.SEVERE, e.getMessage(), e);
+ }
+ } // end while
+ } // end if
+
+ itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+
+ // If its not a valid bean for service, ignore it
+ if (!isValidBeanForService(beanElement)) {
+ continue;
+ }
+ // Ignore if the bean has no properties and constructor arguments
+ if (beanElement.getProperties().isEmpty() && beanElement.getCustructorArgs().isEmpty())
+ continue;
+
+ ComponentType beanComponentType = assemblyFactory.createComponentType();
+
+ try {
+ Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
+ // Introspect the bean
+ beanIntrospector = new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
+ javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
+ } catch (Exception e) {
+ // [rfeng] FIXME: Some Spring beans have constructors that take pararemters injected by Spring and
+ // Tuscany is not happy with that during the introspection
+ log.log(Level.SEVERE, e.getMessage(), e);
+ continue;
+ }
+ Map<String, JavaElementImpl> propertyMap = javaImplementation.getPropertyMembers();
+ JavaConstructorImpl constructor = javaImplementation.getConstructor();
+ // Get the references by this Spring Bean and add the unresolved ones to
+ // the component type of the Spring Assembly
+ List<Reference> beanReferences = beanComponentType.getReferences();
+ List<Property> beanProperties = beanComponentType.getProperties();
+
+ Set<String> excludedNames = new HashSet<String>();
+ Iterator<SpringPropertyElement> itp = beanElement.getProperties().iterator();
+ while (itp.hasNext()) {
+ SpringPropertyElement propertyElement = itp.next();
+ // Exclude the reference that is also known as a spring property
+ excludedNames.add(propertyElement.getName());
+ for (String propertyRef : propertyElement.getRefs()) {
+ if (propertyRefUnresolved(propertyRef, beans, references, scaproperties)) {
+ // This means an unresolved reference from the spring bean...
+ for (Reference reference : beanReferences) {
+ if (propertyElement.getName().equals(reference.getName())) {
+ // The name of the reference in this case is the string in
+ // the @ref attribute of the Spring property element, NOT the
+ // name of the field in the Spring bean....
+ reference.setName(propertyRef);
+ componentType.getReferences().add(reference);
+ break;
+ } // end if
+ } // end for
+
+ // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
+ for (Property scaproperty : beanProperties) {
+ if (propertyElement.getName().equals(scaproperty.getName())) {
+ // The name of the reference in this case is the string in
+ // the @ref attribute of the Spring property element, NOT the
+ // name of the field in the Spring bean....
+ Class<?> interfaze =
+ resolveClass(resolver,
+ (propertyMap.get(propertyElement.getName()).getType()).getName(),
+ context);
+ Reference theReference = createReference(interfaze, propertyRef);
+ implementation.setUnresolvedBeanRef(propertyRef, theReference);
+ break;
+ } // end if
+ } // end for
+ } // end if
+ } // end for
+ } // end while
+
+ Iterator<SpringConstructorArgElement> itcr = beanElement.getCustructorArgs().iterator();
+ while (itcr.hasNext()) {
+ SpringConstructorArgElement conArgElement = itcr.next();
+ for (String constructorArgRef : conArgElement.getRefs()) {
+ if (propertyRefUnresolved(constructorArgRef, beans, references, scaproperties)) {
+ for (JavaParameterImpl parameter : constructor.getParameters()) {
+ String paramType = parameter.getType().getName();
+ Class<?> interfaze = resolveClass(resolver, paramType, context);
+ // Create a component type reference/property if the constructor-arg element has a
+ // type attribute OR index attribute declared...
+ if ((conArgElement.getType() != null && paramType.equals(conArgElement.getType())) || (conArgElement
+ .getIndex() != -1 && (conArgElement.getIndex() == parameter.getIndex()))) {
+ // [rfeng] Commenting out the following code as the constructor parameter based SCA
+ // references are added already
+ /*
+ if (parameter.getClassifer() == org.oasisopen.sca.annotation.Reference.class) {
+ Reference theReference = createReference(interfaze, constructorArgRef);
+ componentType.getReferences().add(theReference);
+ }
+ */
+ if (parameter.getClassifer() == org.oasisopen.sca.annotation.Property.class) {
+ // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
+ // we might need to verify with the component definition later.
+ Reference theReference = createReference(interfaze, constructorArgRef);
+ implementation.setUnresolvedBeanRef(constructorArgRef, theReference);
+ }
+ }
+ } // end for
+ } // end if
+ } // end for
+ } // end while
+
+ // [rfeng] Add the remaining introspected references (w/ @Reference but without Spring property ref)
+ for (Reference ref : beanReferences) {
+ if (!excludedNames.contains(ref.getName()) && componentType.getReference(ref.getName()) == null) {
+ // Only add the ones that not listed by sca:reference
+ componentType.getReferences().add(ref);
+ }
+ }
+
+ } // end while
+
+ } catch (ClassNotFoundException e) {
+ // Means that either an interface class, property class or a bean was not found
+ throw new ContributionReadException(e);
+ } catch (InvalidInterfaceException e) {
+ throw new ContributionReadException(e);
+ } // end try
+
+ // If we get here, the Spring assembly component type is resolved
+ componentType.setUnresolved(false);
+ implementation.setComponentType(componentType);
+ return;
+ } // end method generateComponentType
+
+ /*
+ * Determines whether a reference attribute of a Spring property element is resolved either
+ * by a bean in the application context or by an SCA reference element or by an SCA property
+ * element
+ * @param ref - a String containing the name of the reference - may be null
+ * @param beans - a List of SpringBean elements
+ * @param references - a List of SCA reference elements
+ * @return true if the property is not resolved, false if it is resolved
+ */
+ private boolean propertyRefUnresolved(String ref,
+ List<SpringBeanElement> beans,
+ List<SpringSCAReferenceElement> references,
+ List<SpringSCAPropertyElement> scaproperties) {
+ boolean unresolved = true;
+
+ if (ref != null) {
+ // Scan over the beans looking for a match
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ // Does the bean name match the ref?
+ if (ref.equals(beanElement.getId())) {
+ unresolved = false;
+ break;
+ } // end if
+ } // end while
+ // Scan over the SCA reference elements looking for a match
+ if (unresolved) {
+ Iterator<SpringSCAReferenceElement> itr = references.iterator();
+ while (itr.hasNext()) {
+ SpringSCAReferenceElement referenceElement = itr.next();
+ if (ref.equals(referenceElement.getName())) {
+ unresolved = false;
+ break;
+ } // end if
+ } // end while
+ } // end if
+ // Scan over the SCA property elements looking for a match
+ if (unresolved) {
+ Iterator<SpringSCAPropertyElement> itsp = scaproperties.iterator();
+ while (itsp.hasNext()) {
+ SpringSCAPropertyElement propertyElement = itsp.next();
+ if (ref.equals(propertyElement.getName())) {
+ unresolved = false;
+ break;
+ } // end if
+ } // end while
+ } // end if
+ } else {
+ // In the case where ref = null, the property is not going to be a reference of any
+ // kind and can be ignored
+ unresolved = false;
+ } // end if
+
+ return unresolved;
+
+ } // end method propertyRefUnresolved
+
+ /**
+ * Validates whether the <sca:service>, <sca:reference> and <sca:property> elements
+ * has unique names within the application context.
+ */
+ private void validateBeans(List<SpringBeanElement> beans,
+ List<SpringSCAServiceElement> services,
+ List<SpringSCAReferenceElement> references,
+ List<SpringSCAPropertyElement> scaproperties,
+ Monitor monitor) throws ContributionReadException {
+
+ // The @target attribute of a <service/> subelement of a <beans/> element
+ // MUST have the value of the @name attribute of one of the <bean/>
+ // subelements of the <beans/> element.
+ Iterator<SpringSCAServiceElement> its = services.iterator();
+ while (its.hasNext()) {
+ SpringSCAServiceElement serviceElement = its.next();
+ boolean targetBeanExists = false;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (serviceElement.getTarget().equals(beanElement.getId()))
+ targetBeanExists = true;
+ }
+ if (!targetBeanExists)
+ error(monitor, "TargetBeanDoesNotExist", beans);
+ } // end while
+
+ // The value of the @name attribute of an <sca:reference/> subelement of a <beans/>
+ // element MUST be unique amongst the @name attributes of the <sca:property/>
+ // subelements and the <bean/> subelements of the <beans/> element.
+ // AND
+ // The @default attribute of a <sca:reference/> subelement of a <beans/>
+ // element MUST have the value of the @name attribute of one of the <bean/>
+ // subelements of the <beans/> element.
+ Iterator<SpringSCAReferenceElement> itr = references.iterator();
+ while (itr.hasNext()) {
+ SpringSCAReferenceElement referenceElement = itr.next();
+ boolean defaultBeanExists = true;
+ boolean isUniqueReferenceName = true;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (referenceElement.getDefaultBean() != null)
+ if (referenceElement.getDefaultBean().equals(beanElement.getId()))
+ defaultBeanExists = false;
+ if (referenceElement.getName().equals(beanElement.getId()))
+ isUniqueReferenceName = false;
+ }
+ Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
+ while (itp.hasNext()) {
+ SpringSCAPropertyElement propertyElement = itp.next();
+ if (referenceElement.getName().equals(propertyElement.getName()))
+ isUniqueReferenceName = false;
+ }
+ if (!defaultBeanExists)
+ error(monitor, "DefaultBeanDoesNotExist", beans);
+ if (!isUniqueReferenceName)
+ error(monitor, "ScaReferenceNameNotUnique", beans);
+ } // end while
+
+ // The value of the @name attribute of an <sca:property/> subelement of a <beans/>
+ // element MUST be unique amongst the @name attributes of the <sca:reference/>
+ // subelements and the <bean/> subelements of the <beans/> element.
+ Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
+ while (itp.hasNext()) {
+ SpringSCAPropertyElement propertyElement = itp.next();
+ boolean isUniquePropertyName = true;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (propertyElement.getName().equals(beanElement.getId()))
+ isUniquePropertyName = false;
+ }
+ Iterator<SpringSCAReferenceElement> itrp = references.iterator();
+ while (itrp.hasNext()) {
+ SpringSCAReferenceElement referenceElement = itrp.next();
+ if (propertyElement.getName().equals(referenceElement.getName()))
+ isUniquePropertyName = false;
+ }
+ if (!isUniquePropertyName)
+ error(monitor, "ScaPropertyNameNotUnique", beans);
+ } // end while
+ }
+
+ /**
+ * Validates whether a bean definition is valid for exposing as service.
+ */
+ private boolean isValidBeanForService(SpringBeanElement beanElement) {
+
+ if (beanElement.isInnerBean())
+ return false;
+ if (beanElement.hasParentAttribute())
+ return false;
+ if (beanElement.hasFactoryMethodAttribute())
+ return false;
+ if (beanElement.hasFactoryBeanAttribute())
+ return false;
+ if (beanElement.getClassName() == null)
+ return false;
+ if (beanElement.getClassName().startsWith("org.springframework"))
+ return false;
+ // return true otherwise
+ return true;
+ }
+
+ /**
+ * Gets hold of the application-context.xml file as a Spring resource
+ * @param locationAttr - the location attribute from the <implementation.spring../> element
+ * @param cl - the ClassLoader for the Spring implementation
+ */
+ protected List<URL> getApplicationContextResource(URL url) throws ContributionReadException {
+ File manifestFile = null;
+ File appXmlFile;
+ File appXmlFolder;
+ File locationFile = null;
+ List<URL> appCtxResources = new ArrayList<URL>();
+
+ if (url != null) {
+ String path = url.getPath();
+ locationFile = new File(path);
+ } else {
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + "unable to find resource file "
+ + url);
+ }
+
+ if (locationFile.isDirectory()) {
+ try {
+ manifestFile = new File(locationFile, "META-INF" + File.separator + "MANIFEST.MF");
+ if (manifestFile.exists()) {
+ Manifest mf = new Manifest(new FileInputStream(manifestFile));
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ appXmlFile = new File(locationFile, path.trim());
+ if (appXmlFile.exists()) {
+ appCtxResources.add(appXmlFile.toURI().toURL());
+ }
+ }
+ return appCtxResources;
+ }
+ }
+ // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
+ // xml files available in the META-INF/spring folder.
+ appXmlFolder = new File(locationFile, "META-INF" + File.separator + "spring");
+ if (appXmlFolder.exists()) {
+ File[] files = appXmlFolder.listFiles();
+ for (File appFile : files) {
+ if (appFile.getName().endsWith(".xml")) {
+ appCtxResources.add(appFile.toURI().toURL());
+ }
+ }
+ return appCtxResources;
+ }
+ } catch (IOException e) {
+ throw new ContributionReadException("Error reading manifest " + manifestFile);
+ }
+ } else {
+ if (locationFile.isFile() && locationFile.getName().endsWith(".jar")) {
+ try {
+ JarFile jf = new JarFile(locationFile);
+ JarEntry je;
+ Manifest mf = jf.getManifest();
+ if (mf != null) {
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ je = jf.getJarEntry(path.trim());
+ if (je != null)
+ appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL()
+ + "!/"
+ + appCtxPath));
+ }
+ return appCtxResources;
+ }
+ }
+ // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
+ // .xml files available in the META-INF/spring folder.
+ Enumeration<JarEntry> entries = jf.entries();
+ while (entries.hasMoreElements()) {
+ je = entries.nextElement();
+ if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
+ appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL() + "!/" + je.getName()));
+ }
+ }
+ return appCtxResources;
+ } catch (IOException e) {
+ // TODO: create a more appropriate exception type
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + " IO exception reading context file.",
+ e);
+ }
+ } else {
+ if (locationFile.getName().endsWith(".xml")) {
+ appCtxResources.add(url);
+ return appCtxResources;
+ } else {
+ // Deal with the directory inside a jar file, in case the contribution itself is a JAR file.
+ try {
+ if (locationFile.getPath().indexOf(".jar") > 0) {
+ String jarPath = url.getPath().substring(5, url.getPath().indexOf("!"));
+ JarFile jf = new JarFile(jarPath);
+ JarEntry je =
+ jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/") + 2) + "/"
+ + "META-INF"
+ + "/"
+ + "MANIFEST.MF");
+ if (je != null) {
+ Manifest mf = new Manifest(jf.getInputStream(je));
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ je =
+ jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/") + 2) + "/"
+ + path.trim());
+ if (je != null) {
+ appCtxResources.add(new URL("jar:" + url.getPath() + "/" + path.trim()));
+ }
+ }
+ return appCtxResources;
+ }
+ }
+ // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
+ // .xml files available in the META-INF/spring folder.
+ Enumeration<JarEntry> entries = jf.entries();
+ while (entries.hasMoreElements()) {
+ je = entries.nextElement();
+ if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
+ appCtxResources.add(new URL("jar:" + url.getPath() + "/" + je.getName()));
+ }
+ }
+ return appCtxResources;
+ }
+ } catch (IOException e) {
+ throw new ContributionReadException("Error reading manifest " + manifestFile);
+ }
+ }
+ }
+ }
+
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + "unable to read resource file "
+ + url);
+ } // end method getApplicationContextResource
+
+ /**
+ * Creates a Service for the component type based on its name and Java interface
+ */
+ public Service createService(Class<?> interfaze, String name) throws InvalidInterfaceException {
+ Service service = assemblyFactory.createService();
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ service.setInterfaceContract(interfaceContract);
+
+ // Set the name for the service
+ service.setName(name);
+
+ // Set the call interface and, if present, the callback interface
+ JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
+ service.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ service.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+ return service;
+ } // end method createService
+
+ /**
+ * Creates a Reference for the component type based on its name and Java interface
+ */
+ private org.apache.tuscany.sca.assembly.Reference createReference(Class<?> interfaze, String name)
+ throws InvalidInterfaceException {
+ org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ reference.setInterfaceContract(interfaceContract);
+
+ // Set the name of the reference to the supplied name and the multiplicity of the reference
+ // to 1..1 - for Spring implementations, this is the only multiplicity supported
+ reference.setName(name);
+ reference.setMultiplicity(Multiplicity.ONE_ONE);
+
+ // Set the call interface and, if present, the callback interface
+ JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
+ reference.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+
+ return reference;
+ }
+
+ private class ContextClassLoader extends ClassLoader {
+ public ContextClassLoader(ModelResolver resolver, ProcessorContext context) {
+ super();
+ this.resolver = resolver;
+ this.context = context;
+ }
+
+ private ModelResolver resolver;
+ private ProcessorContext context;
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ return SpringXMLComponentTypeLoader.this.resolveClass(resolver, name, context);
+ }
+
+ @Override
+ protected URL findResource(String name) {
+ try {
+ return resolveLocation(resolver, name, context);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(String name) throws IOException {
+ URL url = findResource(name);
+ if (url != null) {
+ return Collections.enumeration(Arrays.asList(url));
+ } else {
+ Collection<URL> urls = Collections.emptyList();
+ return Collections.enumeration(urls);
+ }
+ }
+ }
+} // end class SpringXMLComponentTypeLoader
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
new file mode 100644
index 0000000000..4b4144f0c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.xml;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.introspect.SpringXMLComponentTypeLoader;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * SpringArtifactProcessor is responsible for processing the XML of an <implementation.spring.../>
+ * element in an SCA SCDL file.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringImplementationProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<SpringImplementation> {
+
+ private static final String LOCATION = "location";
+ private static final String IMPLEMENTATION_SPRING = "implementation.spring";
+ private static final QName IMPLEMENTATION_SPRING_QNAME = new QName(Constants.SCA11_NS, IMPLEMENTATION_SPRING);
+ private static final String MSG_LOCATION_MISSING = "Reading implementation.spring - location attribute missing";
+
+ private ExtensionPointRegistry registry;
+ private AssemblyFactory assemblyFactory;
+ private PolicySubjectProcessor policyProcessor;
+
+ private FactoryExtensionPoint factories;
+
+ public SpringImplementationProcessor(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ this.factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(registry);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /*
+ * Read the XML and parse out the attributes.
+ *
+ * <implementation.spring.../> has a single required attribute:
+ * "location" - which is the target URI of of an archive file or a directory that contains the Spring
+ * application context files.
+ * If the resource identified by the location attribute is an archive file, then the file
+ * META-INF/MANIFEST.MF is read from the archive.
+ * If the location URI identifies a directory, then META-INF/MANIFEST.MF must exist
+ * underneath that directory.
+ * If the manifest file contains a header "Spring-Context" of the format:
+ * Spring-Context ::= path ( ';' path )*
+ *
+ * Where path is a relative path with respect to the location URI, then the set of paths
+ * specified in the header identify the context configuration files.
+ * If there is no MANIFEST.MF file or no Spring-Context header within that file,
+ * then the default behaviour is to build an application context using all the *.xml files
+ * in the META-INF/spring directory.
+ */
+ public SpringImplementation read(XMLStreamReader reader, ProcessorContext context)
+ throws ContributionReadException, XMLStreamException {
+
+ // Create the Spring implementation
+ SpringImplementation springImplementation = null;
+
+ // Read the location attribute for the spring implementation
+ String springLocation = getURIString(reader, LOCATION);
+ if (springLocation != null) {
+ springImplementation = new SpringImplementation();
+ springImplementation.setLocation(springLocation);
+ springImplementation.setUnresolved(true);
+ processComponentType(springImplementation);
+ } else {
+ error(context.getMonitor(), "LocationAttributeMissing", reader);
+ //throw new ContributionReadException(MSG_LOCATION_MISSING);
+ }
+
+ // Read policies
+ policyProcessor.readPolicies(springImplementation, reader);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_SPRING_QNAME.equals(reader.getName())) {
+ break;
+ }
+ } // end while
+
+ return springImplementation;
+ } // end read
+
+ /*
+ * Handles the component type for the Spring implementation
+ * @param springImplementation - a Spring implementation. The component type information
+ * is created for this implementation
+ *
+ */
+ private void processComponentType(SpringImplementation springImplementation) {
+
+ // Create a ComponentType and mark it unresolved
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setUnresolved(true);
+ springImplementation.setComponentType(componentType);
+ } // end processComponentType
+
+ /*
+ * Write out the XML representation of the Spring implementation
+ * <implementation.spring location="..." />
+ */
+ public void write(SpringImplementation springImplementation, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ // Write <implementation.spring>
+ writer.writeStartElement(Constants.SCA11_NS, IMPLEMENTATION_SPRING);
+ policyProcessor.writePolicyAttributes(springImplementation, writer);
+
+ if (springImplementation.getLocation() != null) {
+ writer.writeAttribute(LOCATION, springImplementation.getLocation());
+ }
+
+ writer.writeEndElement();
+
+ } // end write
+
+ /**
+ * Resolves the Spring implementation - loads the Spring application-context XML and
+ * derives the spring implementation componentType from it
+ */
+ public void resolve(SpringImplementation springImplementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+
+ if (springImplementation == null)
+ return;
+
+ Monitor monitor = context.getMonitor();
+ /* Load the Spring component type by reading the Spring application context */
+ SpringXMLComponentTypeLoader springLoader = new SpringXMLComponentTypeLoader(registry);
+ try {
+ // Load the Spring Implementation information from its application context file...
+ springLoader.load(springImplementation, resolver, context);
+ } catch (ContributionReadException e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(monitor, "ContributionResolveException", resolver, ce);
+ throw ce;
+ }
+
+ ComponentType ct = springImplementation.getComponentType();
+ if (ct.isUnresolved()) {
+ // If the introspection fails to resolve, try to find a side file...
+ ComponentType componentType = resolver.resolveModel(ComponentType.class, ct, context);
+ if (componentType.isUnresolved()) {
+ error(monitor, "UnableToResolveComponentType", resolver);
+ //throw new ContributionResolveException("SpringArtifactProcessor: unable to resolve componentType for Spring component");
+ } else {
+ springImplementation.setComponentType(componentType);
+ springImplementation.setUnresolved(false);
+ }
+
+ } // end if
+
+ } // end method resolve
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_SPRING_QNAME;
+ }
+
+ public Class<SpringImplementation> getModelType() {
+ return SpringImplementation.class;
+ }
+
+} // end class SpringArtifactProcessor
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringXMLBeanDefinitionLoader.java b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringXMLBeanDefinitionLoader.java
new file mode 100644
index 0000000000..a3dc353ffc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringXMLBeanDefinitionLoader.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.spring.xml;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+
+/**
+ * The utility interface to load Spring XML bean definitions into an application context
+ */
+public interface SpringXMLBeanDefinitionLoader {
+ /**
+ * @param resources
+ * @param serviceElements
+ * @param referenceElements
+ * @param propertyElements
+ * @param beanElements
+ * @param context
+ * @return
+ */
+ Object load(List<URL> resources,
+ List<SpringSCAServiceElement> serviceElements,
+ List<SpringSCAReferenceElement> referenceElements,
+ List<SpringSCAPropertyElement> propertyElements,
+ List<SpringBeanElement> beanElements,
+ ProcessorContext context);
+}
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
new file mode 100644
index 0000000000..7ea615051e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
@@ -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.implementation.spring.SpringImplementationBuilder;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.spring
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..880d6fade0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.implementation.spring.xml.SpringImplementationProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.spring,model=org.apache.tuscany.sca.implementation.spring.SpringImplementation
+
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..4a9270d094
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/implementation/spring/definitions.xml
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties
new file mode 100644
index 0000000000..28bd31ca11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties
@@ -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.
+#
+#
+LocationAttributeMissing = Reading implementation.spring - location attribute missing
+ContributionResolveException = ContributionResolveException occured due to:
+UnableToResolveComponentType = SpringArtifactProcessor: unable to resolve componentType for Spring component
+ScaServiceNameNotUnique = The value of the @name attribute of an <sca:service/> element MUST be unique amongst the <sca:service/> subelements of the <beans/> element
+ScaReferenceNameNotUnique = The value of the @name attribute of an <sca:reference/> element MUST be unique amongst the <sca:reference/> subelements of the <beans/> element
+ScaPropertyNameNotUnique = The value of the @name attribute of an <sca:property/> element MUST be unique amongst the <sca:property/> subelements of the <beans/> element
+DefaultBeanDoesNotExist = The @default attribute of a <sca:reference/> element MUST have the value of the @name attribute of one of the <bean/> subelements of the <beans/> element.
+TargetBeanDoesNotExist = The @target attribute of a <sca:service/> element MUST have the value of the @name attribute of one of the <bean/> subelements of the <beans/> element.
diff --git a/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml
new file mode 100644
index 0000000000..18e7b1e60a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:implementationType type="sca:implementation.spring" mayProvide="" alwaysProvides=""/>
+
+ </sca:definitions>
diff --git a/sandbox/sebastien/java/embed/contrib/modules/pom.xml b/sandbox/sebastien/java/embed/contrib/modules/pom.xml
new file mode 100644
index 0000000000..238ee4dd06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/modules/pom.xml
@@ -0,0 +1,91 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-contrib-modules</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Contributed Modules</name>
+
+ <modules>
+ <module>databinding-protobuf</module>
+ <module>host-tomcat</module>
+ </modules>
+
+ <profiles>
+ <profile>
+ <id>eclipse</id>
+ <build>
+ <defaultGoal>org.apache.tuscany.maven.plugins:maven-bundle-plugin:eclipse</defaultGoal>
+ <!--
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.6</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-pde</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>eclipse</goal>
+ </goals>
+ <configuration>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ -->
+ </build>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml
new file mode 100644
index 0000000000..cdf1c59f2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/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-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>embedded-jse-async-sample-launcher</artifactId>
+ <name>Embedded JSE Launcher for async samples</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..9937323993
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/calculator/CalculatorService.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 calculator;
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+
+@Remotable
+public interface CalculatorService {
+ String calculate(Integer n1);
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/RuntimeIntegration.java b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..aa36b6009b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/RuntimeIntegration.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+
+/**
+ * Base JSE launcher function
+ */
+public class RuntimeIntegration {
+
+
+ public Node startNode(Contribution... contributions){
+ Node node = NodeFactory.newInstance().createNode(contributions);
+ node.start();
+ return node;
+ }
+
+ public void stopNode(Node node){
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleJSELauncher.java b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleJSELauncher.java
new file mode 100644
index 0000000000..a5e6d75d24
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleJSELauncher.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+
+import calculator.CalculatorService;
+
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and, in some cases, locate and invoke an SCA component
+ */
+public class SampleJSELauncher extends RuntimeIntegration {
+
+ protected boolean waitBeforeStopping = false;
+
+ public static void main(String[] args) throws Exception {
+ SampleJSELauncher launcher = new SampleJSELauncher();
+ launcher.launchImplementationJavaCalculatorAsync();
+ }
+
+ public void launchImplementationJavaCalculatorAsync(){
+ Node node = startNode(new Contribution("c1", "../sample-contribution-implementation-java-calculator-async/target/sample-contribution-implementation-java-calculator-async.jar"));
+ stopNode(node);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleLauncherException.java b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..1eacb94b19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/main/java/launcher/SampleLauncherException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/test/java/launcher/LauncherTestCase.java b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..538b693e3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/embedded-jse-async-sample-launcher/src/test/java/launcher/LauncherTestCase.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 launcher;
+
+import org.junit.Test;
+
+/**
+ * Test sample contributions.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionImplementationJavaCalculatorAsync() throws Exception {
+ SampleJSELauncher.main(null);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/pom.xml b/sandbox/sebastien/java/embed/contrib/samples/async/pom.xml
new file mode 100644
index 0000000000..f44ae33067
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-async</artifactId>
+ <packaging>pom</packaging>
+ <name>MYYYYYYYYYYYYYYYYYYY Apache Tuscany SCA Samples for Synchronous/Asynchronous invocation</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>sample-contribution-implementation-java-calculator-async</module>
+ <module>embedded-jse-async-sample-launcher</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml
new file mode 100644
index 0000000000..a0f60bcf6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml
@@ -0,0 +1,58 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-implementation-java-calculator-async</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution Implementation Java Calculator for Async Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java
new file mode 100644
index 0000000000..6ae8fd13f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package calculator;
+
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Async client version of the CalculatorService interface
+ *
+ */
+
+@Remotable
+public interface CalculateViaAsyncRef {
+
+ //public Response<String> calculate( Integer i1);
+
+ // Sync
+ public String calculate(Integer i1);
+
+ // Aysnc Poll
+ public Future<String> calculateAsync(Integer i1);
+
+ // Async Callback
+ public Future<String> calculateAsync(Integer i1, AsyncHandler<String> handler);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncHandler.java b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncHandler.java
new file mode 100644
index 0000000000..abaeef8062
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncHandler.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 calculator;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+/**
+ * Handles callbacks to the async client
+ */
+
+public class CalculatorAsyncHandler implements AsyncHandler<String> {
+ public void handleResponse(Response<String> res) {
+ try {
+ System.out.println("Async client callback patern: result in handler = " + res.get());
+ } catch(Exception ex){
+ System.out.println("Async client callback patern: exception in handler = " + ex.getMessage());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..cc1d1d8d46
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE") @EagerInit
+public class CalculatorClient {
+
+ private CalculatorService calculatorService;
+
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ @Init
+ public void calculate() {
+ System.out.println("calculation=" + calculatorService.calculate(20));
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..45bdd265d4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The sync Calculator service interface.
+ */
+
+@Remotable
+public interface CalculatorService {
+ String calculate(Integer n1);
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java
new file mode 100644
index 0000000000..3979529595
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.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 calculator;
+
+import org.oasisopen.sca.ResponseDispatch;
+import org.oasisopen.sca.annotation.AsyncInvocation;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The async Calculator service interface.
+ */
+
+@Remotable
+@AsyncInvocation
+public interface CalculatorServiceAsync {
+ void calculateAsync(Integer n1, ResponseDispatch<String> response);
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java
new file mode 100644
index 0000000000..1906f46f5b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.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 calculator;
+
+import org.oasisopen.sca.ResponseDispatch;
+
+public class CalculatorServiceAsyncImpl implements CalculatorServiceAsync {
+
+ @Override
+ public void calculateAsync(Integer n1, ResponseDispatch<String> response) {
+ int result = n1 + n1;
+ String retval = "async service invoked: " + n1 + " + " + n1 + " = " + result;
+
+ response.sendResponse(retval);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceProxyImpl.java b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceProxyImpl.java
new file mode 100644
index 0000000000..69c96fe892
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceProxyImpl.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 calculator;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * An implementation of the Calculator service which just proxies
+ * to sync and asyn versions of the calculator service. This proxy
+ * exercises the various async interface alternatives
+ */
+public class CalculatorServiceProxyImpl implements CalculatorService {
+
+ @Reference
+ protected CalculateViaAsyncRef calculatorServiceRefSync;
+
+ @Reference
+ protected CalculateViaAsyncRef calculatorServiceRefAsync;
+
+ @Override
+ public String calculate(Integer n1) {
+ String result = null;
+
+ // calculate using a sync service
+ System.out.println("Calling sync service");
+ result = calculate(calculatorServiceRefSync, n1);
+
+ // calculate using an aycn service
+ System.out.println("Calling async service");
+ result += calculate(calculatorServiceRefAsync, n1);
+
+ return result;
+ }
+
+ // exercise sync and async versions of a service interface method
+ private String calculate(CalculateViaAsyncRef calculatorRef, Integer n1) {
+
+ // sync
+ String result = calculatorRef.calculate(1);
+ System.out.println("Sync client patern: result = " + result);
+
+ // async poll
+ Future<String> future = calculatorRef.calculateAsync(20);
+
+ while (!future.isDone()){
+ System.out.println("Waiting for poll");
+ }
+
+ try {
+ result = future.get();
+ System.out.println("Async client poll patern: result = " + result);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // async callback
+ CalculatorAsyncHandler handler = new CalculatorAsyncHandler();
+ future = calculatorRef.calculateAsync(3, handler);
+
+ while (!future.isDone()){
+ System.out.println("Waiting for callback");
+ }
+
+ return result;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java
new file mode 100644
index 0000000000..615a4f4f11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.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 calculator;
+
+public class CalculatorServiceSyncImpl implements CalculatorService {
+
+ @Override
+ public String calculate(Integer n1) {
+ int result = n1 + n1;
+ String retval = "sync service invoked: " + n1 + " + " + n1 + " = " + result;
+ return retval;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..6117d436db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceProxyImpl"/>
+ <reference name="calculatorServiceRefSync" target="CalculatorSync"/>
+ <reference name="calculatorServiceRefAsync" target="CalculatorAsync"/>
+ </component>
+
+ <component name="CalculatorSync">
+ <implementation.java class="calculator.CalculatorServiceSyncImpl"/>
+ </component>
+
+ <component name="CalculatorAsync">
+ <implementation.java class="calculator.CalculatorServiceAsyncImpl"/>
+ <service name="CalculatorServiceAsync">
+ <binding.ws uri="http://localhost:8085/CalculatorAsync"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite
new file mode 100644
index 0000000000..374ef27e2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="CalculatorClient">
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3e64787ce4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+ <deployable composite="sample:CalculatorClient"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/README b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/README
new file mode 100644
index 0000000000..7108333efa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/README
@@ -0,0 +1,20 @@
+JSE Sample Launcher
+===================
+
+This directory contains a sample java launcher for the
+tuscany sample contributions.
+
+The README file in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running sample contributions using the
+tuscany sample launchers ( where distribution-unpack-dir is the directory in which you
+unpacked the tuscany binary distribution archive)
+
+To use this sample JSE launcher with ant excute the command
+
+ant run-<contributionname>
+
+where run-<contributionname> is one of the targets in the build.xml file
+
+To use this sample launcher to run all of the contributions as junit test cases,
+execute the command "mvn" in the launcher directory.
+
diff --git a/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/build.xml b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/build.xml
new file mode 100644
index 0000000000..64bad00b76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/build.xml
@@ -0,0 +1,118 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 name="launcher-embedded-jse" default="run">
+ <property name="tuscany.home" value="../.."/>
+ <property name="jar.name" value="sample-launcher-embedded-jse.jar" />
+ <property name="main.class" value="launcher.SampleJSELauncher" />
+ <property name="wait.before.stopping" value="dontWaitBeforeStopping" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-base-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <echo>Please use 'ant run-name-of-sample-contribution-to-run' for example, try one of</echo>
+ <echo> 'ant run-contribution-binding-sca-calculator' </echo>
+ <echo> 'ant run-contribution-binding-ws-calculator' </echo>
+ <echo> 'ant run-contribution-binding-rmi-calculator' </echo>
+ <echo> 'ant run-contribution-implementation-java-calculator' </echo>
+ </target>
+
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-sca-calculator"/>
+ <arg value="${wait.before.stopping}"/>
+ </java>
+ </target>
+
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="launcher.JSELauncherBindingWSCalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-contribution-binding-rmi-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-rmi-calculator"/>
+ </java>
+ </target>
+
+ <target name="run-contribution-implementation-java-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-implementaton-java-calculator"/>
+ </java>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/pom.xml b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/pom.xml
new file mode 100644
index 0000000000..b1f8e5c15c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-embedded-jse-spec</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Embedded JSE Spec</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/JSELauncherBindingWSCalculator.java b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/JSELauncherBindingWSCalculator.java
new file mode 100644
index 0000000000..2f48e273bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/JSELauncherBindingWSCalculator.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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node2.Node;
+import org.apache.tuscany.sca.node2.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingWSCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingWSCalculator launcher = new JSELauncherBindingWSCalculator();
+ launcher.launchBindingWSCalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchBindingWSCalculator(){
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ Node node = nodeFactory.createNode("MyDomain");
+
+ try {
+ node.installContribution("../../../samples/contribution-binding-ws-calculator/target/sample-contribution-binding-ws-calculator.jar");
+ } catch(Exception ex){
+ System.out.println("Exception on installContribution");
+ ex.printStackTrace();
+ }
+
+ //node.start();
+
+ CalculatorService calculator = null;
+
+ try {
+ calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+ } catch(Exception ex){
+ System.out.println("Exception on getService");
+ ex.printStackTrace();
+ }
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/SampleLauncherException.java b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..f2ed3d421d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/main/java/launcher/SampleLauncherException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/test/java/launcher/LauncherTestCase.java b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..04521d326b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/contrib/samples/launcher-embedded-jse-spec/src/test/java/launcher/LauncherTestCase.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 launcher;
+
+import org.junit.Test;
+
+/**
+ * Test sample contributions.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionBindingWSCalculator() throws Exception {
+ JSELauncherBindingWSCalculator.main(null);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/all/manifests/axiom-api-1.2.7.MF b/sandbox/sebastien/java/embed/distribution/all/manifests/axiom-api-1.2.7.MF
new file mode 100644
index 0000000000..3a692b6c06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/manifests/axiom-api-1.2.7.MF
@@ -0,0 +1,47 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Axiom API
+Bundle-SymbolicName: org.apache.ws.commons.axiom.axiom-api
+Bundle-Version: 1.2.7
+Bundle-Vendor: Apache Software Foundation
+Export-Package: org.apache.axiom.attachments,
+ org.apache.axiom.attachments.impl,
+ org.apache.axiom.attachments.lifecycle,
+ org.apache.axiom.attachments.lifecycle.impl,
+ org.apache.axiom.attachments.utils,
+ org.apache.axiom.om,
+ org.apache.axiom.om.ds,
+ org.apache.axiom.om.ds.custombuilder,
+ org.apache.axiom.om.impl,
+ org.apache.axiom.om.impl.builder,
+ org.apache.axiom.om.impl.exception,
+ org.apache.axiom.om.impl.serialize,
+ org.apache.axiom.om.impl.traverse,
+ org.apache.axiom.om.impl.util,
+ org.apache.axiom.om.util,
+ org.apache.axiom.om.xpath,
+ org.apache.axiom.soap,
+ org.apache.axiom.soap.impl.builder
+Archiver-Version: Plexus Archiver
+Build-Jdk: 1.5.0_15
+Created-By: Apache Maven
+Bundle-DocURL: http://www.apache.org/
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Built-By: dims
+Import-Package: javax.activation,
+ javax.mail,
+ javax.mail.internet,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.om.impl.llom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap11;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap12;resolution:=optional,
+ org.apache.commons.logging,
+ org.jaxen;resolution:=optional,
+ org.jaxen.saxpath;resolution:=optional,
+ org.jaxen.util;resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.helpers
diff --git a/sandbox/sebastien/java/embed/distribution/all/manifests/axiom-api-1.2.8.MF b/sandbox/sebastien/java/embed/distribution/all/manifests/axiom-api-1.2.8.MF
new file mode 100644
index 0000000000..671a7bff34
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/manifests/axiom-api-1.2.8.MF
@@ -0,0 +1,49 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Axiom API
+Bundle-SymbolicName: org.apache.ws.commons.axiom.axiom-api
+Bundle-Version: 1.2.8
+Bundle-Vendor: Apache Software Foundation
+Bundle-DocURL: http://www.apache.org/
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-ClassPath: axiom-api-1.2.8.jar
+Export-Package: org.apache.axiom.attachments,
+ org.apache.axiom.attachments.impl,
+ org.apache.axiom.attachments.lifecycle,
+ org.apache.axiom.attachments.lifecycle.impl,
+ org.apache.axiom.attachments.utils,
+ org.apache.axiom.om,
+ org.apache.axiom.om.ds,
+ org.apache.axiom.om.ds.custombuilder,
+ org.apache.axiom.om.impl,
+ org.apache.axiom.om.impl.builder,
+ org.apache.axiom.om.impl.exception,
+ org.apache.axiom.om.impl.serialize,
+ org.apache.axiom.om.impl.traverse,
+ org.apache.axiom.om.impl.util,
+ org.apache.axiom.om.util,
+ org.apache.axiom.om.xpath,
+ org.apache.axiom.soap,
+ org.apache.axiom.soap.impl.builder
+Archiver-Version: Plexus Archiver
+Build-Jdk: 1.5.0_15
+Created-By: Apache Maven
+Built-By: dims
+Import-Package: javax.activation,
+ javax.mail,
+ javax.mail.internet,
+ javax.xml.namespace,
+ javax.xml.stream,
+ javax.xml.stream.util,
+ org.apache.axiom.om.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.om.impl.llom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap11;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap12;resolution:=optional,
+ org.apache.commons.logging,
+ org.jaxen;resolution:=optional,
+ org.jaxen.saxpath;resolution:=optional,
+ org.jaxen.util;resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.helpers
diff --git a/sandbox/sebastien/java/embed/distribution/all/manifests/axis2-kernel-1.5.1.MF b/sandbox/sebastien/java/embed/distribution/all/manifests/axis2-kernel-1.5.1.MF
new file mode 100644
index 0000000000..686e53ae0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/manifests/axis2-kernel-1.5.1.MF
@@ -0,0 +1,39 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.axis2.kernel
+Bundle-Name: org.apache.axis2.kernel
+Bundle-Version: 1.5.1
+DynamicImport-Package: javax.transaction;version="1.1",javax.transacti
+ on.xa;version="1.1",javax.xml.ws,*
+Bundle-ClassPath: axis2-kernel-1.5.1.jar
+Export-Package: org.apache.axis2.dataretrieval;version=1.5.1,org.apach
+ e.axis2;version=1.5.1,org.apache.axis2.builder;version=1.5.1,org.apac
+ he.axis2.phaseresolver;version=1.5.1,org.apache.axis2.deployment.repo
+ sitory.util;version=1.5.1,org.apache.axis2.deployment;version=1.5.1,o
+ rg.apache.axis2.java.security;version=1.5.1,org.apache.axis2.engine;v
+ ersion=1.5.1,org.apache.axis2.context;version=1.5.1,org.apache.axis2.
+ addressing.i18n;version=1.5.1,org.apache.axis2.modules;version=1.5.1,
+ org.apache.axis2.addressing.metadata;version=1.5.1,org.apache.axis2.d
+ ataretrieval.client;version=1.5.1,org.apache.axis2.service;version=1.
+ 5.1,org.apache.axis2.description.java2wsdl.bytecode;version=1.5.1,org
+ .apache.axis2.i18n;version=1.5.1,org.apache.axis2.deployment.schedule
+ r;version=1.5.1,org.apache.axis2.description.java2wsdl;version=1.5.1,
+ org.apache.axis2.transport;version=1.5.1,org.apache.axis2.transport.h
+ ttp;version=1.5.1,org.apache.axis2.client;version=1.5.1,org.apache.ax
+ is2.wsdl;version=1.5.1,org.apache.axis2.util.threadpool;version=1.5.1
+ ,org.apache.axis2.client.async;version=1.5.1,org.apache.axis2.receive
+ rs;version=1.5.1,org.apache.axis2.util;version=1.5.1,org.apache.axis2
+ .namespace;version=1.5.1,org.apache.axis2.transport.http.util;version
+ =1.5.1,org.apache.axis2.context.externalize;version=1.5.1,org.apache.
+ axis2.addressing;version=1.5.1,org.apache.axis2.deployment.util;versi
+ on=1.5.1,org.apache.axis2.dispatchers;version=1.5.1,org.apache.axis2.
+ deployment.resolver;version=1.5.1,org.apache.axis2.clustering.configu
+ ration;version=1.5.1,org.apache.axis2.transaction;version=1.5.1,org.a
+ pache.axis2.clustering;version=1.5.1,org.apache.axis2.wsdl.util;versi
+ on=1.5.1,org.apache.axis2.clustering.context;version=1.5.1,org.apache
+ .axis2.builder.unknowncontent;version=1.5.1,org.apache.axis2.handlers
+ ;version=1.5.1,org.apache.axis2.addressing.wsdl;version=1.5.1,org.apa
+ che.axis2.classloader;version=1.5.1,org.apache.axis2.description;vers
+ ion=1.5.1
+Import-Package: javax.xml.ws
+Eclipse-ExtensibleAPI: true
diff --git a/sandbox/sebastien/java/embed/distribution/all/manifests/axis2-transport-http-1.5.1.MF b/sandbox/sebastien/java/embed/distribution/all/manifests/axis2-transport-http-1.5.1.MF
new file mode 100644
index 0000000000..ae6448acf5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/manifests/axis2-transport-http-1.5.1.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.axis2.transport.http
+Bundle-Name: org.apache.axis2.transport.http
+Bundle-Version: 1.5.1
+DynamicImport-Package: javax.transaction;version="1.1",javax.transacti
+ on.xa;version="1.1",*
+Bundle-ClassPath: axis2-transport-http-1.5.1.jar
+Export-Package: org.apache.axis2.transport.http.server;version=1.5.1,o
+ rg.apache.axis2.transport.http;version=1.5.1,org.apache.axis2.transpo
+ rt.http.util;version=1.5.1
+Fragment-Host: org.apache.axis2.kernel;bundle-version=1.5.1
diff --git a/sandbox/sebastien/java/embed/distribution/all/manifests/woden-impl-dom-1.0M8.MF b/sandbox/sebastien/java/embed/distribution/all/manifests/woden-impl-dom-1.0M8.MF
new file mode 100644
index 0000000000..b3e9d79d28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/manifests/woden-impl-dom-1.0M8.MF
@@ -0,0 +1,229 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Created-By: 1.4.2_17 (Sun Microsystems Inc.)
+Built-By: dims
+Build-Jdk: 1.4.2_17
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Import-Package: com.ibm.wsdl.util,
+ com.ibm.wsdl.util.xml,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ org.apache.woden;version="1.0",
+ org.apache.woden.internal;version="1.0.0",
+ org.apache.woden.internal.resolver;version="1.0.0",
+ org.apache.woden.internal.schema;version="1.0.0",
+ org.apache.woden.internal.util;version="1.0.0",
+ org.apache.woden.internal.util.dom;version="1.0.0",
+ org.apache.woden.internal.wsdl20;version="1.0.0",
+ org.apache.woden.internal.wsdl20.assertions;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.http;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.rpc;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.soap;version="1.0.0",
+ org.apache.woden.internal.wsdl20.validation;version="1.0.0",
+ org.apache.woden.internal.xml;version="1.0.0",
+ org.apache.woden.internal.xpointer;version="1.0.0",
+ org.apache.woden.resolver;version="1.0",
+ org.apache.woden.schema;version="1.0",
+ org.apache.woden.tool.converter;version="1.0.0",
+ org.apache.woden.types;version="1.0",
+ org.apache.woden.wsdl20;version="1.0",
+ org.apache.woden.wsdl20.enumeration;version="1.0",
+ org.apache.woden.wsdl20.extensions;version="1.0",
+ org.apache.woden.wsdl20.extensions.http;version="1.0",
+ org.apache.woden.wsdl20.extensions.rpc;version="1.0",
+ org.apache.woden.wsdl20.extensions.soap;version="1.0",
+ org.apache.woden.wsdl20.fragids;version="1.0",
+ org.apache.woden.wsdl20.validation;version="1.0",
+ org.apache.woden.wsdl20.xml;version="1.0",
+ org.apache.woden.xml;version="1.0",
+ org.apache.woden.xpointer;version="1.0",
+ org.apache.ws.commons.schema,
+ org.apache.ws.commons.schema.resolver,
+ org.apache.ws.commons.schema.utils,
+ org.apache.xerces.parsers,
+ org.apache.xml.serialize,
+ org.w3c.dom,
+ org.xml.sax
+Bnd-LastModified: 1208980539265
+Export-Package: javax.xml.namespace,
+ org.apache.woden.internal;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.schema,
+ org.apache.xerces.parsers,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.resolver,
+ org.apache.woden.internal.schema,
+ javax.xml.parsers,
+ org.apache.woden.wsdl20.xml,
+ org.xml.sax,
+ org.apache.ws.commons.schema,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden.internal.xpointer,
+ org.apache.woden.internal.util.dom,
+ org.apache.ws.commons.schema.resolver,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.xpointer,
+ org.apache.woden.internal.wsdl20.validation,
+ org.apache.woden.wsdl20.enumeration,
+ org.apache.woden.types,
+ org.apache.woden.internal.resolver,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.resolver;version="1.0.0";
+ uses:="org.apache.ws.commons.schema.resolver,
+ org.xml.sax,
+ org.apache.xml.serialize,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.resolver,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.schema;version="1.0.0";
+ uses:="org.apache.woden.schema,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden",
+ org.apache.woden.internal.util;version="1.0.0",
+ org.apache.woden.internal.util.dom;version="1.0.0";
+ uses:="javax.xml.namespace,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.wsdl20;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.schema,
+ org.apache.woden.wsdl20.extensions.rpc,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.wsdl20.fragids,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.ws.commons.schema.utils,
+ org.apache.woden.internal.schema,
+ org.apache.woden.wsdl20.enumeration,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.types",
+ org.apache.woden.internal.wsdl20.assertions;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.validation,
+ javax.xml.namespace,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden,
+ org.apache.woden.resolver,
+ org.apache.woden.internal",
+ org.apache.woden.internal.wsdl20.extensions;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.woden.internal.wsdl20.extensions.soap,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal.wsdl20.extensions.rpc,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.wsdl20.extensions.soap,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.wsdl20.extensions.http;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.wsdl20.xml",
+ org.apache.woden.internal.wsdl20.extensions.rpc;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions",
+ org.apache.woden.internal.wsdl20.extensions.soap;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.wsdl20.extensions.soap",
+ org.apache.woden.internal.wsdl20.validation;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.validation,
+ org.apache.woden.schema,
+ org.apache.woden.internal.wsdl20.assertions,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.resolver,
+ org.apache.woden.internal,
+ org.apache.woden.types,
+ org.apache.woden.wsdl20.xml",
+ org.apache.woden.internal.xml;version="1.0.0";
+ uses:="org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.internal.util,
+ org.apache.woden.internal",
+ org.apache.woden.internal.xpointer;version="1.0.0";
+ uses:="org.apache.woden.xpointer,
+ org.apache.woden.types,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal",
+ org.apache.woden.tool.converter;version="1.0.0";
+ uses:="javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.xml,
+ javax.wsdl.factory,
+ javax.xml.namespace,
+ com.ibm.wsdl.util,
+ com.ibm.wsdl.util.xml"
+Bundle-Version: 1.0.0
+Bundle-Description: The Woden project is a subproject of the Apache We
+ b Services Project to develop a Java class library for reading, ma
+ nipulating, creating and writing WSDL documents, initially to supp
+ ort WSDL 2.0 but with the longer term aim of supporting past, present
+ and future versions of WSDL. There are two main deliverables:
+ an API and an implementation. The Woden API consists of a set of J
+ ava interfaces. The WSDL 2.0-specific portion of the Woden API confor
+ ms to the W3C WSDL 2.0 specification. The implementation will be a
+ high performance implementation directly usable in other Apache p
+ rojects such as Axis2.
+Bundle-Name: Woden - DOM
+Bundle-DocURL: http://www.apache.org/
+Bundle-ManifestVersion: 2
+Bundle-Vendor: Apache Software Foundation
+Bundle-SymbolicName: org.apache.woden.woden-impl-dom
+Tool: Bnd-0.0.238
+
+
diff --git a/sandbox/sebastien/java/embed/distribution/all/pom.xml b/sandbox/sebastien/java/embed/distribution/all/pom.xml
new file mode 100644
index 0000000000..ef94bfbd08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/pom.xml
@@ -0,0 +1,301 @@
+<?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-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-distribution-all</artifactId>
+ <name>Apache Tuscany SCA All-in-one Distribution</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-all</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ejb-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-tracing-aspectj</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ <version>1.6.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <useDistributionName>false</useDistributionName>
+ <generateAggregatedBundle>false</generateAggregatedBundle>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-3</version>
+ <executions>
+ <execution>
+ <id>distribution-package</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/bin-default.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ <finalName>apache-tuscany-sca-all-${version}</finalName>
+ <appendAssemblyId>true</appendAssemblyId>
+ <ignoreDirFormatExtensions>false</ignoreDirFormatExtensions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>release</id>
+ <activation>
+ <property>
+ <name>buildZips</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <properties>
+ <useDistributionName>false</useDistributionName>
+ <generateAggregatedBundle>false</generateAggregatedBundle>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-5</version>
+ <executions>
+ <execution>
+ <id>distribution-package</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/bin-distribution.xml</descriptor>
+ <descriptor>src/main/assembly/src.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ <finalName>apache-tuscany-sca-all-${version}</finalName>
+ <appendAssemblyId>true</appendAssemblyId>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <attach>true</attach>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>singlebundle</id>
+ <properties>
+ <useDistributionName>true</useDistributionName>
+ <generateAggregatedBundle>true</generateAggregatedBundle>
+ </properties>
+ </profile>
+
+
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.6</version>
+ <executions>
+ <execution>
+ <id>distribution-modules</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>generate-modules</goal>
+ </goals>
+ <configuration>
+ <targetDirectory>target/modules</targetDirectory>
+ <useDistributionName>${useDistributionName}</useDistributionName>
+ <generateAggregatedBundle>${generateAggregatedBundle}</generateAggregatedBundle>
+ <generateManifestJar>true</generateManifestJar>
+ <excludeGroupIds>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ </excludeGroupIds>
+ <artifactManifests>
+ <artifactManifest>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.8</version>
+ <manifestFile>${basedir}/manifests/axiom-api-1.2.8.MF</manifestFile>
+ </artifactManifest>
+ <artifactManifest>
+ <groupId>org.apache.woden</groupId>
+ <artifactId>woden-impl-dom</artifactId>
+ <version>1.0M8</version>
+ <manifestFile>${basedir}/manifests/woden-impl-dom-1.0M8.MF</manifestFile>
+ </artifactManifest>
+ <!-- artifactAggregations (below) is the right approach to solving the split
+ package between axis-kernel and axis2-transport-http however the Tuscany
+ runtime doesn't take any notice of it so using a fragment at the moment -->
+ <artifactManifest>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>1.5.1</version>
+ <manifestFile>${basedir}/manifests/axis2-kernel-1.5.1.MF</manifestFile>
+ </artifactManifest>
+ <artifactManifest>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-http</artifactId>
+ <version>1.5.1</version>
+ <manifestFile>${basedir}/manifests/axis2-transport-http-1.5.1.MF</manifestFile>
+ </artifactManifest>
+ <artifactManifest>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>*</artifactId>
+ <version>*</version>
+ </artifactManifest>
+ </artifactManifests>
+ <!--artifactAggregations>
+ <artifactAggregation>
+ <symbolicName>org.apache.tuscany.sca.axis2-kernel</symbolicName>
+ <version>1.5.1</version>
+ <artifactMembers>
+ <artifactMember>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>1.5.1</version>
+ </artifactMember>
+ <artifactMember>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-http</artifactId>
+ <version>1.5.1</version>
+ </artifactMember>
+ </artifactMembers>
+ </artifactAggregation>
+ </artifactAggregations-->
+ </configuration>
+ </execution>
+<!--
+ <execution>
+ <id>distribution-singlebundle</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>aggregate-modules</goal>
+ </goals>
+ </execution>
+-->
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.3.0-v20070530</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <!--plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>distribution-package</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/bin.xml</descriptor>
+ <descriptor>src/main/assembly/src.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ <finalName>apache-tuscany-sca-all-${version}</finalName>
+ <appendAssemblyId>true</appendAssemblyId>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin-->
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/bin-default.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/bin-default.xml
new file mode 100644
index 0000000000..c946a0925a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/bin-default.xml
@@ -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.
+-->
+<assembly>
+ <!-- id typically identifies the "type" (src vs bin etc) of the assembly -->
+ <id></id>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>tuscany-sca-${version}</baseDirectory>
+ <formats>
+ <format>dir</format>
+ </formats>
+
+ <componentDescriptors>
+ <componentDescriptor>src/main/components/bin-common.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-lib.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-modules.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-samples.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-launcher.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-tracing.xml</componentDescriptor>
+ </componentDescriptors>
+</assembly>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/bin-distribution.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/bin-distribution.xml
new file mode 100644
index 0000000000..59b7c14719
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/bin-distribution.xml
@@ -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.
+-->
+<assembly>
+ <!-- id typically identifies the "type" (src vs bin etc) of the assembly -->
+ <id></id>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>tuscany-sca-${version}</baseDirectory>
+ <formats>
+ <format>tar.gz</format>
+ <format>zip</format>
+ </formats>
+
+ <componentDescriptors>
+ <componentDescriptor>src/main/components/bin-common.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-lib.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-modules.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-samples.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-launcher.xml</componentDescriptor>
+ </componentDescriptors>
+</assembly>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/src.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/src.xml
new file mode 100644
index 0000000000..89d50a7e7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/assembly/src.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+<assembly>
+ <!-- id typically identifies the "type" (src vs bin etc) of the assembly -->
+ <id>src</id>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>tuscany-sca-${version}-src</baseDirectory>
+ <formats>
+ <format>tar.gz</format>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <directory>../..</directory>
+ <outputDirectory></outputDirectory>
+ <excludes>
+ <exclude>**/.*</exclude>
+ <exclude>**/.*/**</exclude>
+ <exclude>**/*.log</exclude>
+ <exclude>**/target</exclude>
+ <exclude>**/target/**/*</exclude>
+ <exclude>**/maven-eclipse.xml</exclude>
+ <exclude>modules/web-javascript-dojo/src/main/resources/dojo/**</exclude>
+ <exclude>shades/**/dependency-reduced-pom.xml</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-common.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-common.xml
new file mode 100644
index 0000000000..b5b7111096
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-common.xml
@@ -0,0 +1,43 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<component>
+ <fileSets>
+
+ <!-- Add the text files to the top-level directroy -->
+ <fileSet>
+ <directory>../..</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>CHANGES</include>
+ <include>README</include>
+ <include>RELEASE_NOTES</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/release/bin</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>INSTALL</include>
+ <include>LICENSE</include>
+ <include>NOTICE</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+
+</component>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-launcher.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-launcher.xml
new file mode 100644
index 0000000000..4afd92b098
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-launcher.xml
@@ -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.
+-->
+<component>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/release/launcher</directory>
+ <outputDirectory>bin</outputDirectory>
+ <includes>
+ </includes>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>bin</outputDirectory>
+ <unpack>false</unpack>
+ <includes>
+ <include>org.apache.tuscany.sca:tuscany-launcher</include>
+ </includes>
+ <outputFileNameMapping>launcher.jar</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+
+</component>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-lib.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-lib.xml
new file mode 100644
index 0000000000..1da6bebbe6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-lib.xml
@@ -0,0 +1,55 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<component>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ <useTransitiveDependencies>true</useTransitiveDependencies>
+ <unpack>false</unpack>
+ <includes>
+ <include>org.apache.tuscany.sca.shades:tuscany-base</include>
+ <include>org.apache.ws.commons.schema:XmlSchema</include>
+ <include>cglib:cglib</include>
+ <include>com.hazelcast:*</include>
+ <include>wsdl4j:wsdl4j</include>
+ <include>org.apache.tuscany.sca:tuscany-sca-api</include>
+ </includes>
+ </dependencySet>
+
+ <dependencySet>
+ <outputDirectory>lib/spring</outputDirectory>
+ <useTransitiveDependencies>true</useTransitiveDependencies>
+ <unpack>false</unpack>
+ <includes>
+ <include>org.apache.tuscany.sca.shades:tuscany-spring</include>
+ <include>org.springframework:*</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/release/bin/</directory>
+ <outputDirectory>lib</outputDirectory>
+ <includes>
+ <include>README</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</component>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-modules.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-modules.xml
new file mode 100644
index 0000000000..15233db587
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-modules.xml
@@ -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.
+-->
+<component>
+ <fileSets>
+
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>modules/**/*</include>
+ <include>features/**/*</include>
+ </includes>
+ <excludes>
+ <exclude>org.aspectj:aspectjweaver</exclude>
+ <exclude>org.apache.tuscany.sca.shades:*</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</component>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-samples.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-samples.xml
new file mode 100644
index 0000000000..ed29ad2265
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-samples.xml
@@ -0,0 +1,68 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<component>
+ <fileSets>
+ <!-- Add top level samples files -->
+ <fileSet>
+ <directory>../../samples</directory>
+ <outputDirectory>samples</outputDirectory>
+ <excludes>
+ <!-- General file/folders to exclude -->
+ <exclude>**/.*</exclude>
+ <exclude>**/.*/**</exclude>
+ <exclude>**/*.log</exclude>
+ <exclude>**/*.svg</exclude>
+ <exclude>**/maven-eclipse.xml</exclude>
+ <exclude>**/target/mvn-eclipse-cache.properties</exclude>
+ <exclude>**/target/pom-transformed.xml</exclude>
+ <exclude>**/target/classes</exclude>
+ <exclude>**/target/classes/**/*</exclude>
+ <exclude>**/target/dependency-maven-plugin-markers</exclude>
+ <exclude>**/target/equinox/**/*</exclude>
+ <exclude>**/target/equinox</exclude>
+ <exclude>**/target/dependency-maven-plugin-markers/**/*</exclude>
+ <exclude>**/target/.felix</exclude>
+ <exclude>**/target/.felix/**/*</exclude>
+ <exclude>**/target/generated-sources</exclude>
+ <exclude>**/target/generated-sources/**/*</exclude>
+ <exclude>**/target/maven-archiver</exclude>
+ <exclude>**/target/maven-archiver/**/*</exclude>
+ <exclude>**/target/maven-shared-archive-resources</exclude>
+ <exclude>**/target/maven-shared-archive-resources/**/*</exclude>
+ <exclude>**/target/test-classes</exclude>
+ <exclude>**/target/test-classes/**/*</exclude>
+ <exclude>**/target/sdo-source</exclude>
+ <exclude>**/target/sdo-source/**/*</exclude>
+ <exclude>**/target/surefire-reports</exclude>
+ <exclude>**/target/surefire-reports/**/*</exclude>
+ <exclude>**/target/surefire-osgi-reports</exclude>
+ <exclude>**/target/surefire-osgi-reports/**/*</exclude>
+ <exclude>**/target/war</exclude>
+ <exclude>**/target/war/**/*</exclude>
+ <exclude>webapps/*/target</exclude>
+ <exclude>webapps/*/target/**/*</exclude>
+ <exclude>helloworld-bpel/target/sample-helloworld-bpel</exclude>
+ <exclude>helloworld-bpel/target/sample-helloworld-bpel/**/*</exclude>
+ <exclude>binding-jsonrpc/contribution-calculator-webapp/target/**/*</exclude>
+ <exclude>binding-jsonrpc/contribution-calculator-webapp/target</exclude>
+ <exclude>binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/dojo/**/*</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</component>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-tracing.xml b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-tracing.xml
new file mode 100644
index 0000000000..d80fdf42f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/components/bin-tracing.xml
@@ -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.
+-->
+<component>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/release/tracing</directory>
+ <outputDirectory>bin</outputDirectory>
+ <includes/>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>bin</outputDirectory>
+ <unpack>false</unpack>
+ <includes>
+ <include>org.aspectj:aspectjweaver</include>
+ </includes>
+ <outputFileNameMapping>aspectjweaver.jar</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+
+</component>
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/INSTALL b/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/INSTALL
new file mode 100644
index 0000000000..00ddf4df6f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/INSTALL
@@ -0,0 +1,29 @@
+Installing the Apache Tuscany SCA binary distribution
+=====================================================
+
+Unzip Tuscany binary distribution archive and you get the following:
+
+tuscany-sca-<version>
+ CHANGES - A note of the major changes in this release
+ INSTALL - this help file
+ LICENSE - the Apache License and any dependecy licenses
+ NOTICE - attribution notices associated with the licenses
+ README - readme for the release
+ RELEASE_NOTES - description of this release
+
+ /bin - Tuscany launcher (for use when running tuscany from the command line)
+
+ /features - OSGi runtime configuration, Tuscany manifest and PDE target
+
+ /lib - a new feature of this release looking at how to aggregate the
+ information in modules into more coarse grained jars to ease
+ classpath creation without having to rely on the Tuscany distribution
+ structure.
+
+ /modules - all of the individual Tuscany jars and their dependencies
+
+ /samples - all the Tuscany samples, see the README in that directory
+
+
+
+
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/LICENSE b/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/LICENSE
new file mode 100644
index 0000000000..941dc0474b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/LICENSE
@@ -0,0 +1,2300 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+===============================================================================
+
+APACHE TUSCANY SUBCOMPONENTS:
+
+The Apache Tuscany binary distribution includes a number of subcomponents
+with separate copyright notices and license terms. Your use of the
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+The following components come under Apache Software License 2.0
+
+ abdera-client-1.0.jar
+ abdera-core-1.0.jar
+ abdera-extensions-html-1.0.jar
+ abdera-extensions-json-1.0.jar
+ abdera-extensions-main-1.0.jar
+ abdera-i18n-1.0.jar
+ abdera-parser-1.0.jar
+ abdera-server-1.0.jar
+ addressing-1.3.mar
+ aopalliance-1.0.jar
+ annogen-0.1.0.jar
+ aspectjrt-1.6.8.jar
+ aspectjweaver-1.6.8.jar
+ axiom-api-1.2.8.jar
+ axiom-dom-1.2.8.jar
+ axiom-impl-1.2.8.jar
+ axis2-codegen-1.5.1.jar
+ axis2-kernel-1.5.1.jar
+ axis2-java2wsdl-1.5.1.jar
+ axis2-mtompolicy-1.5.1.jar
+ axis2-transport-base-1.0.0.jar
+ axis2-transport-jms-1.0.0.jar
+ axis2-transport-local-1.5.1.jar
+ axis2-transport-http-1.5.1.jar
+ axis-ant-1.4.jar
+ bsf-all-3.0.jar
+ cglib-2.2.jar
+ commons-beanutils-1.7.0.jar
+ commons-cli-1.2.jar
+ commons-collections-3.2.jar
+ commons-codec-1.3.jar
+ commons-digester-1.8.jar
+ commons-discovery-0.4.jar
+ commons-fileupload-1.2.jar
+ commons-httpclient-3.1.jar
+ commons-io-1.4.jar
+ commons-lang-2.3.jar
+ commons-logging-1.1.1.jar
+ commons-pool-1.3.jar
+ derby-10.4.1.3.jar
+ dwr-2.0.3.jar
+ geronimo-activation_1.1_spec-1.0.1.jar
+ geronimo-connector-2.1.3.jar
+ geronimo-ejb_3.0_spec-1.0.1.jar
+ geronimo-el_1.0_spec-1.0.1.jar
+ geronimo-javamail_1.4_spec-1.6.jar
+ geronimo-jms_1.1_spec-1.1.1.jar
+ geronimo-jpa_3.0_spec-1.1.1.jar
+ geronimo-jsp_2.1_spec-1.0.1.jar
+ geronimo-jta_1.0.1B_spec-1.0.jar
+ geronimo-jta_1.1_spec-1.1.1.jar
+ geronimo-j2ee-connector_1.5_spec-2.0.0.jar
+ geronimo-kernel-2.0.1.jar
+ geronimo-stax-api_1.0_spec-1.0.1.jar
+ geronimo-transaction-2.1.3.jar
+ geronimo-ws-metadata_2.0_spec-1.1.2.jar
+ groovy-all-1.7.1.jar
+ hazelcast-1.8.3.jar
+ hazelcast-client-1.8.3.jar
+ httpclient-4.0.jar
+ httpcore-4.0.1.jar
+ httpcore-nio-4.0.1.jar
+ jabsorb-1.3.1.jar
+ jackson-core-asl-1.5.4.jar
+ jackson-mapper-asl-1.5.4.jar
+ jackson-xc-1.5.4.jar
+ jettison-1.2.jar
+ jetty-6.1.19.jar
+ jetty-util-6.1.19.jar
+ juli-6.0.26.jar
+ log4j-1.2.15.jar
+ mex-1.5.1-impl.jar
+ myfaces-api-1.2.2.jar
+ myfaces-impl-1.2.2.jar
+ neethi-2.0.4.jar
+ ode-agents-1.3.2.jar
+ ode-bpel-api-1.3.2.jar
+ ode-bpel-compiler-1.3.2.jar
+ ode-bpel-dao-1.3.2.jar
+ ode-bpel-epr-1.3.2.jar
+ ode-bpel-obj-1.3.2.jar
+ ode-bpel-runtime-1.3.2.jar
+ ode-bpel-schemas-1.3.2.jar
+ ode-bpel-store-1.3.2.jar
+ ode-dao-hibernate-1.3.2.jar
+ ode-dao-jpa-1.3.2.jar
+ ode-jacob-1.3.2.jar
+ ode-jacob-ap-1.3.2.jar
+ ode-scheduler-simple-1.3.2.jar
+ ode-utils-1.3.2.jar
+ openjpa-1.2.1.jar
+ rampart-core-1.4.jar
+ rampart-policy-1.4.jar
+ rampart-trust-1.4.jar
+ regexp-1.3.jar
+ rome-1.0.jar
+ spring-aop-3.0.2.RELEASE.jar
+ spring-asm-3.0.2.RELEASE.jar
+ spring-beans-3.0.2.RELEASE.jar
+ spring-context-3.0.2.RELEASE.jar
+ spring-core-3.0.2.RELEASE.jar
+ spring-expression-3.0.2.RELEASE.jar
+ stripes-1.5.2.jar
+ tranql-connector-1.1.jar
+ tribes-6.0.26.jar
+ wink-common-1.1.1-incubating.jar
+ wink-client-1.1.1-incubating.jar
+ wink-server-1.1.1-incubating.jar
+ woden-api-1.0M8.jar
+ woden-impl-dom-1.0M8.jar
+ wss4j-1.5.4.jar
+ wstx-asl-3.2.4.jar
+ wstx-asl-3.2.6.jar
+ xalan-2.7.0.jar
+ xercesImpl-2.8.1.jar
+ xml-apis-1.3.04.jar
+ xmlbeans-2.3.0.jar
+ xmlsec-1.4.3.jar
+ XmlSchema-1.4.3.jar
+
+===============================================================================
+The serp-1.13.1.jar is distributed under the BSD license with the following copyright:
+
+ Copyright (c) 2002, A. Abram White
+ All rights reserved.
+
+BSD license:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither the name of the Sun Microsystems, Inc. nor the names of
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+================================================================================
+
+dom4j-1.6.1.jar
+
+Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
+
+Redistribution and use of this software and associated documentation
+("Software"), with or without modification, are permitted provided
+that the following conditions are met:
+
+1. Redistributions of source code must retain copyright
+ statements and notices. Redistributions must also contain a
+ copy of this document.
+
+2. Redistributions in binary form must reproduce the
+ above copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+3. The name "DOM4J" must not be used to endorse or promote
+ products derived from this Software without prior written
+ permission of MetaStuff, Ltd. For written permission,
+ please contact dom4j-info@metastuff.com.
+
+4. Products derived from this Software may not be called "DOM4J"
+ nor may "DOM4J" appear in their names without prior written
+ permission of MetaStuff, Ltd. DOM4J is a registered
+ trademark of MetaStuff, Ltd.
+
+5. Due credit should be given to the DOM4J Project -
+ http://www.dom4j.org
+
+THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+===============================================================================
+The Equinox OSGi Runtime jars:
+ osgi-3.5.0-v20090520.jar
+ common-3.5.0-v20090520-1800.jar
+ services-3.2.0-v20090520-1800.jar
+
+Tuscany SDO dependencies on Eclipse:
+ ecore-2.2.3.jar
+ ecore-change-2.2.3.jar
+ ecore-xmi-2.2.3.jar
+ common-2.2.3.jar
+ xsd-2.2.3.jar
+ runtime-3.4.0-v20080512.jar,
+ app-1.2.0-v20090520-1800.jar
+ contenttype-3.3.0-v20080604-1400.jar
+ jobs-3.4.0-v20080512.jar
+ preferences-3.2.300-v20090520-1800.jar
+ registry-3.4.100-v20090520-1800.jar
+
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and
+are distributed by that particular Contributor. A Contribution
+'originates' from a Contributor if it was added to the Program by such
+Contributor itself or anyone acting on such Contributor's behalf.
+Contributions do not include additions to the Program which: (i) are
+separate modules of software distributed in conjunction with the
+Program under their own license agreement, and (ii) are not derivative
+works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this
+Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free copyright
+license to reproduce, prepare derivative works of, publicly display,
+publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and
+object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free patent
+license under Licensed Patents to make, use, sell, offer to sell,
+import and otherwise transfer the Contribution of such Contributor, if
+any, in source code and object code form. This patent license shall
+apply to the combination of the Contribution and the Program if, at
+the time the Contribution is added by the Contributor, such addition
+of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the
+licenses to its Contributions set forth herein, no assurances are
+provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow
+Recipient to distribute the Program, it is Recipient's responsibility
+to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright
+license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form
+under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties
+and conditions, express and implied, including warranties or
+conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability
+for damages, including direct, indirect, special, incidental and
+consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are
+offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable
+manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the
+Program.
+
+Contributors may not remove or alter any copyright notices contained
+within the Program.
+
+Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a
+commercial product offering should do so in a manner which does not
+create potential liability for other Contributors. Therefore, if a
+Contributor includes the Program in a commercial product offering,
+such Contributor ("Commercial Contributor") hereby agrees to defend
+and indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses") arising
+from claims, lawsuits and other legal actions brought by a third party
+against the Indemnified Contributor to the extent caused by the acts
+or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement.
+In order to qualify, an Indemnified Contributor must: a) promptly
+notify the Commercial Contributor in writing of such claim, and b)
+allow the Commercial Contributor to control, and cooperate with the
+Commercial Contributor in, the defense and any related settlement
+negotiations. The Indemnified Contributor may participate in any such
+claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED 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. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable
+laws, damage to or loss of data, programs or equipment, and
+unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further
+action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+the Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of
+the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of
+time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use
+and distribution of the Program as soon as reasonably practicable.
+However, Recipient's obligations under this Agreement and any licenses
+granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted and
+may only be modified in the following manner. The Agreement Steward
+reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation
+is the initial Agreement Steward. The Eclipse Foundation may assign
+the responsibility to serve as the Agreement Steward to a suitable
+separate entity. Each new version of the Agreement will be given a
+distinguishing version number. The Program (including Contributions)
+may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the
+Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives
+no rights or licenses to the intellectual property of any Contributor
+under this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No
+party to this Agreement will bring a legal action under this Agreement
+more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
+
+===============================================================================
+
+The howl-1.0.1-1.jar is distributed under the BSD license:
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+================================================================================
+
+The jars;
+activation-1.1.jar,
+jaxb-api-2.1.jar,
+jaxb-impl-2.1.12.jar,
+jaxws-api-2.1.jar,
+jsr181-api-1.0-MR1.jar,
+jsr250-api-1.0.jar,
+jstl-1.1.2.jar,
+mail-1.4.jar,
+servlet-api-2.5.jar,
+jsr311-api-1.1.jar
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+
+ 1. Definitions.
+
+ 1.1. "Contributor" means each individual or entity that
+ creates or contributes to the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the
+ Original Software, prior Modifications used by a
+ Contributor (if any), and the Modifications made by that
+ particular Contributor.
+
+ 1.3. "Covered Software" means (a) the Original Software, or
+ (b) Modifications, or (c) the combination of files
+ containing Original Software with files containing
+ Modifications, in each case including portions thereof.
+
+ 1.4. "Executable" means the Covered Software in any form
+ other than Source Code.
+
+ 1.5. "Initial Developer" means the individual or entity
+ that first makes Original Software available under this
+ License.
+
+ 1.6. "Larger Work" means a work which combines Covered
+ Software or portions thereof with code not governed by the
+ terms of this License.
+
+ 1.7. "License" means this document.
+
+ 1.8. "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 the Source Code and Executable
+ form of any of the following:
+
+ A. Any file that results from an addition to,
+ deletion from or modification of the contents of a
+ file containing Original Software or previous
+ Modifications;
+
+ B. Any new file that contains any part of the
+ Original Software or previous Modification; or
+
+ C. Any new file that is contributed or otherwise made
+ available under the terms of this License.
+
+ 1.10. "Original Software" means the Source Code and
+ Executable form of computer software code that is
+ originally released under this License.
+
+ 1.11. "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.12. "Source Code" means (a) the common form of computer
+ software code in which modifications are made and (b)
+ associated documentation included in or with such code.
+
+ 1.13. "You" (or "Your") means an individual or a legal
+ entity exercising rights under, and complying with all of
+ the terms of, this License. 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. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the
+ Initial Developer hereby grants You a world-wide,
+ royalty-free, non-exclusive license:
+
+ (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 Software (or
+ portions thereof), with or without Modifications,
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making,
+ using or selling of Original Software, to make, have
+ made, use, practice, sell, and offer for sale, and/or
+ otherwise dispose of the Original Software (or
+ portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b)
+ are effective on the date Initial Developer first
+ distributes or otherwise makes the Original Software
+ available to a third party 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 Software, or (2) for infringements
+ caused by: (i) the modification of the Original
+ Software, or (ii) the combination of the Original
+ Software with other software or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ 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 Software 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
+ distributes or otherwise makes the Modifications
+ available to a third party.
+
+ (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) 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 (3) under
+ Patent Claims infringed by Covered Software in the
+ absence of Modifications made by that Contributor.
+
+ 3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in
+ Source Code form and that Source Code form must be
+ distributed only under the terms of this License. You must
+ include a copy of this License with every copy of the
+ Source Code form of the Covered Software You distribute or
+ otherwise make available. You must inform recipients of any
+ such Covered Software in Executable form as to how they can
+ obtain such Covered Software in Source Code form in a
+ reasonable manner on or through a medium customarily used
+ for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You
+ contribute are governed by the terms of this License. You
+ represent that You believe Your Modifications are Your
+ original creation(s) and/or You have sufficient rights to
+ grant the rights conveyed by this License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications
+ that identifies You as the Contributor of the Modification.
+ You may not remove or alter any copyright, patent or
+ trademark notices contained within the Covered Software, or
+ any notices of licensing or any descriptive text giving
+ attribution to any Contributor or the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered
+ Software in Source Code form that alters or restricts the
+ applicable version of this License or the recipients'
+ rights hereunder. You may choose to offer, and to charge a
+ fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Software.
+ 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 that 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.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered
+ Software under the terms of this License or under the terms
+ of 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 form does not attempt to limit
+ or alter the recipient's rights in the Source Code form
+ from the rights set forth in this License. If You
+ distribute the Covered Software in Executable form 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 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.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software
+ 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 Software.
+
+ 4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Sun Microsystems, Inc. is the initial license steward and
+ may publish revised and/or new versions of this License
+ from time to time. Each version will be given a
+ distinguishing version number. Except as provided in
+ Section 4.3, no one other than the license steward has the
+ right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. If the Initial Developer includes a
+ notice in the Original Software prohibiting it from being
+ distributed or otherwise made available under any
+ subsequent version of the License, You must distribute and
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. Otherwise, You may also choose to
+ use, distribute or otherwise make the Covered Software
+ available under the terms of any subsequent version of the
+ License published by the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a
+ new license for Your Original Software, You may create and
+ use a modified version of this License if You: (a) rename
+ the license and remove any references to the name of the
+ license steward (except to note that the license differs
+ from this License); and (b) otherwise make it clear that
+ the license contains terms which differ from this License.
+
+
+ 5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE 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
+ SOFTWARE 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 SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE 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 SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+ 6. TERMINATION.
+
+ 6.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. Provisions which, by their
+ nature, must remain in effect beyond the termination of
+ this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or
+ a Contributor (the Initial Developer or Contributor against
+ whom You assert such claim is referred to as "Participant")
+ alleging that the Participant Software (meaning the
+ Contributor Version where the Participant is a Contributor
+ or the Original Software where the Participant is the
+ Initial Developer) directly or indirectly infringes any
+ patent, then any and all rights granted directly or
+ indirectly to You by such Participant, the Initial
+ Developer (if the Initial Developer is not the Participant)
+ and all Contributors under Sections 2.1 and/or 2.2 of this
+ License shall, upon 60 days notice from Participant
+ terminate prospectively and automatically at the expiration
+ of such 60 day notice period, unless if within such 60 day
+ period You withdraw Your claim with respect to the
+ Participant Software against such Participant either
+ unilaterally or pursuant to a written agreement with
+ Participant.
+
+ 6.3. In the event of termination under Sections 6.1 or 6.2
+ above, all end user licenses that have been validly granted
+ by You or any distributor hereunder prior to termination
+ (excluding licenses granted to You by any distributor)
+ shall survive termination.
+
+ 7. 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 SOFTWARE, 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 LOST PROFITS, 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.
+
+ 8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a "commercial item," as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+ computer software" (as that term is defined at 48 C.F.R.
+ 252.227-7014(a)(1)) 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 Software with only those rights set forth herein.
+ This U.S. Government Rights clause is in lieu of, and supersedes,
+ any other FAR, DFAR, or other clause or provision that addresses
+ Government rights in computer software under this License.
+
+ 9. 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 the law of the jurisdiction specified in a notice
+ contained within the Original Software (except to the extent
+ applicable law, if any, provides otherwise), excluding such
+ jurisdiction's conflict-of-law provisions. Any litigation
+ relating to this License shall be subject to the jurisdiction of
+ the courts located in the jurisdiction and venue specified in a
+ notice contained within the Original Software, 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.
+ You agree that You alone are responsible for compliance with the
+ United States export administration regulations (and the export
+ control laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+ 10. 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.
+
+===============================================================================
+
+WSDL4j (wsdl4j-1.6.2.jar):
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===============================================================================
+
+backport-util-concurrent-3.1.jar :
+
+The software comprising backport-util-concurrent is based in large
+part on the code from JSR166, and the package dl.util.concurrent.
+The software has been released to the public domain, as explained at:
+http://creativecommons.org/licenses/publicdomain, excepting portions
+of the class
+edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList,
+which were adapted from class java.util.ArrayList, written by Sun
+Microsystems, Inc, which are used with kind permission, and subject
+to the following:
+
+Copyright 2002-2004 Sun Microsystems, Inc. All rights reserved. Use is
+subject to the following license terms.
+
+ "Sun hereby grants you a non-exclusive, worldwide, non-transferrable
+ license to use and distribute the Java Software technologies as part
+ of a larger work in source and binary forms, with or without
+ modification, provided that the following conditions are met:
+
+ -Neither the name of or trademarks of Sun may be used to endorse or
+ promote products derived from the Java Software technology without
+ specific prior written permission.
+
+ -Redistributions of source or binary code must be accompanied by the
+ following notice and disclaimers:
+
+ Portions copyright Sun Microsystems, Inc. Used with kind permission.
+
+ This software is provided AS IS, without a warranty of any kind. ALL
+ EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PUPOSE OR
+ NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ MICROSYSTEMS, INC. AND ITS LICENSORS SHALL NOT BE LIABLE
+ FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS
+ DERIVATIVES. IN NO EVENT WILL SUN MICROSYSTEMS, INC. OR
+ ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR
+ DATA, OR FOR DIRECT, INDIRECT,CONSQUENTIAL, INCIDENTAL
+ OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF
+ THE THEORY OR LIABILITY, ARISING OUT OF THE USE OF OR
+ INABILITY TO USE SOFTWARE, EVEN IF SUN MICROSYSTEMS, INC.
+ HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ You acknowledge that Software is not designed, licensed or intended for
+ use in the design, construction, operation or maintenance of any nuclear
+ facility."
+
+===============================================================================
+
+jdom-1.0.jar :
+
+$Id: LICENSE.txt,v 1.11 2004/02/06 09:32:57 jhunter Exp $
+
+ Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions, and the disclaimer that follows
+ these conditions in the documentation and/or other materials
+ provided with the distribution.
+
+ 3. The name "JDOM" must not be used to endorse or promote products
+ derived from this software without prior written permission. For
+ written permission, please contact <request_AT_jdom_DOT_org>.
+
+ 4. Products derived from this software may not be called "JDOM", nor
+ may "JDOM" appear in their name, without prior written permission
+ from the JDOM Project Management <request_AT_jdom_DOT_org>.
+
+ In addition, we request (but do not require) that you include in the
+ end-user documentation provided with the redistribution and/or in the
+ software itself an acknowledgement equivalent to the following:
+ "This product includes software developed by the
+ JDOM Project (http://www.jdom.org/)."
+ Alternatively, the acknowledgment may be graphical using the logos
+ available at http://www.jdom.org/images/logos.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many
+ individuals on behalf of the JDOM Project and was originally
+ created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
+ Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
+ on the JDOM Project, please see <http://www.jdom.org/>.
+
+================================================================================
+
+For Saxon including
+ saxon-9.x.jar
+ saxon-dom-9.x.jar
+ saxon-xpath-9.x.jar
+ saxon-xqj-9.x.jar
+
+ MOZILLA PUBLIC LICENSE
+Version 1.0
+
+1. Definitions.
+
+ 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.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.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 a list of 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'' 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 fifty percent (50%) or more 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) to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, or as part of a Larger Work; and
+
+ (b) under patents now or hereafter owned or controlled by Initial Developer, to make, have made, use and sell (``Utilize'') the Original Code (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Original Code (or portions thereof) and not to any greater extent that may be necessary to Utilize further Modifications or combinations.
+
+ 2.2. Contributor Grant.
+ Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims:
+
+ (a) 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 or as part of a Larger Work; and
+
+ (b) under patents now or hereafter owned or controlled by Contributor, to Utilize the Contributor Version (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Contributor Version (or portions thereof), and not to any greater extent that may be necessary to Utilize further Modifications or combinations.
+
+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 You have knowledge that a party claims an intellectual property right in particular functionality or code (or its utilization under this License), you 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 you obtain such knowledge after You make Your Modification available as described in Section 3.2, You shall promptly modify the LEGAL file in all copies You make 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 Your Modification is an application programming interface and You own or control patents which are reasonably necessary to implement that API, you must also include this information in the LEGAL file.
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source Code, and this License in any documentation for the Source Code, where You describe recipients' rights relating to Covered Code. If You created one or more Modification(s), You may add your name as a Contributor to the notice described in Exhibit A. 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 file) where a user would be likely to look for such a notice. 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 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 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'', ``NPL'' or any confusingly similar phrase do not appear anywhere in your 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.
+
+ 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.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER 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 THAT 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: (a) unless otherwise agreed in writing, all disputes relating to this License (excepting any dispute relating to intellectual property rights) shall be subject to final and binding arbitration, with the losing party paying all costs of arbitration; (b) any arbitration relating to this Agreement shall be held in Santa Clara County, California, under the auspices of JAMS/EndDispute; and (c) any litigation relating to this Agreement 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.
+
+ Except in cases where another Contributor has failed to comply with Section 3.4, You are responsible for damages arising, directly or indirectly, out of Your utilization of rights under this License, based on the number of copies of Covered Code you made available, the revenues you received from utilizing such rights, and other relevant factors. You agree to work with affected parties to distribute responsibility on an equitable basis.
+
+EXHIBIT A.
+
+ ``The contents of this file are subject to the Mozilla Public License Version 1.0 (the "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): ______________________________________.''
+
+===============================================================================
+
+The jaxen-1.1.1.jar:
+
+ $Id: LICENSE.txt,v 1.5 2006/02/05 21:49:04 elharo Exp $
+
+ Copyright 2003-2006 The Werken Company. All Rights Reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of the Jaxen Project nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+================================================================================
+The asm-3.1.jar are distributed under the license:
+
+Copyright (c) 2000-2005 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
+================================================================================
+
+The slf4j-api-1.5.11.jar and slf4j-jdk14-1.5.11.jar are distributed under the license:
+
+Copyright (c) 2004-2008 QOS.ch
+ All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+==========================================================================================
+
+The htmlparser-1.0.5.jar includes files under the following licenses:
+
+This is for the HTML parser as a whole except the rewindable input stream,
+and the Live DOM Viewer.
+For the copyright notices for individual files, please see individual files.
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Henri Sivonen
+ * Copyright (c) 2007-2008 Mozilla Foundation
+ * Portions of comments Copyright 2004-2007 Apple Computer, Inc., Mozilla
+ * Foundation, and Opera Software ASA.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+The following license is for the rewindable input stream.
+
+/*
+ * Copyright (c) 2001-2003 Thai Open Source Software Center Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Thai Open Source Software Center Ltd nor
+ * the names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+The following license applies to the Live DOM Viewer:
+
+Copyright (c) 2000, 2006, 2008 Ian Hickson and various contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+==========================================================================================
+
+
+The tuscany-assembly-xsd-osoa jar includes XSD files under the following SCA Collaboration license:
+
+License for the Service Component Architecture JavaDoc, Interface
+Definition files and XSD files.
+
+The Service Component Architecture JavaDoc, Interface Definition files,
+and XSD files are being provided by the copyright holders under the
+following license. By using and/or copying this work, you agree that
+you have read, understood and will comply with the following terms and
+conditions:
+
+Permission to copy, display, make derivative works of, and distribute
+the Service Component Architecture JavaDoc, Interface Definition Files
+and XSD files (the "Artifacts") in any medium without fee or royalty is
+hereby granted, provided that you include the following on ALL copies
+of the Artifacts, or portions thereof, that you make:
+
+1. A link or URL to the Artifacts at this location:
+http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of this copyright notice as shown in the Artifacts.
+
+THE ARTIFACTS ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO
+REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THE
+ARTIFACTS AND THE IMPLEMENTATION OF THEIR CONTENTS, INCLUDING, BUT NOT
+LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE, NON-INFRINGEMENT OR TITLE.
+
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY
+USE OR DISTRIBUTION OF THE ARTIFACTS.
+
+The name and trademarks of the Authors may NOT be used in any manner,
+including advertising or publicity pertaining to the Service Component
+Architecture Specification or its contents without specific, written
+prior permission. Title to copyright in the Service Component
+Architecture Specification and the JavaDoc, Interface Definition Files
+and XSD Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+Revision level 1.1, last updated on 2007/11/19
+
+
+================================================================================
+
+The tuscany-assembly-xsd.jar and tuscany-sca-api.jar include files under the following OASIS license:
+
+Copyright (C) OASIS(R) 2005, 2009. All Rights Reserved.
+All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual
+Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
+This document and translations of it may be copied and furnished to others, and derivative works that
+comment on or otherwise explain it or assist in its implementation may be prepared, copied, published,
+and distributed, in whole or in part, without restriction of any kind, provided that the above copyright
+notice and this section are included on all such copies and derivative works. However, this document
+itself may not be modified in any way, including by removing the copyright notice or references to OASIS,
+except as needed for the purpose of developing any document or deliverable produced by an OASIS
+Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR
+Policy, must be followed) or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors
+or assigns.
+This document and the information contained herein is provided on an "AS IS" basis and OASIS
+DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
+WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP
+RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.
+OASIS requests that any OASIS Party or any other party that believes it has patent claims that would
+necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard,
+to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to
+such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that
+produced this specification.
+OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of
+any patent claims that would necessarily be infringed by implementations of this specification by a patent
+holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR
+Mode of the OASIS Technical Committee that produced this specification. OASIS may include such
+claims on its website, but disclaims any obligation to do so.
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that
+might be claimed to pertain to the implementation or use of the technology described in this document or
+the extent to which any license under such rights might or might not be available; neither does it represent
+that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to
+rights in any document or deliverable produced by an OASIS Technical Committee can be found on the
+OASIS website. Copies of claims of rights made available for publication and any assurances of licenses
+to be made available, or the result of an attempt made to obtain a general license or permission for the use
+of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS
+Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any
+information or list of intellectual property rights will at any time be complete, or that any claims in such list
+are, in fact, Essential Claims.
+The names "OASIS", are trademarks of OASIS, the owner and developer of this specification, and should
+be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and
+implementation and use of, specifications, while reserving the right to enforce its marks against misleading
+uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance.
+
+
+================================================================================
+
+The jruby-complete-1.4.0.jar includes files under the following licenses:
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===============================================================================
+
+The js-1.7R2.jar includes files under the following licenses:
+
+ 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.]
+========================================================================================================
+
+The jython-2.2.1.jar includes files under the following licenses:
+
+The Jython License
+A. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING JYTHON
+PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
+
+1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and the Individual or Organization ("Licensee") accessing and otherwise using this software ("Jython") in source or binary form and its associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Jython alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2007 Python Software Foundation; All Rights Reserved" are retained in Jython alone or in any derivative version prepared by Licensee.
+
+3. In the event Licensee prepares a derivative work that is based on or incorporates Jython or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to Jython.
+
+4. PSF is making Jython available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF JYTHON WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF JYTHON FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING JYTHON, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material breach of its terms and conditions.
+
+7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party.
+
+8. By copying, installing or otherwise using Jython, Licensee agrees to be bound by the terms and conditions of this License Agreement.
+========================================================================================================
+
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/NOTICE b/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/NOTICE
new file mode 100644
index 0000000000..65bf34a9ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/bin/NOTICE
@@ -0,0 +1,5 @@
+Apache Tuscany
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/README b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/README
new file mode 100644
index 0000000000..d651dfdeb7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/README
@@ -0,0 +1,42 @@
+The bin folder contains bat and shell scripts to help with using Tuscany.
+You can use the "tuscany.bat" script to start a standalone runtime and
+deploy your SCA contributions.
+
+For example, change to the implementation-java-calculator sample included
+in the Tuscany distribution and enter the following command:
+
+..\..\bin\tuscany.bat target\implementation-java-calculator.jar
+
+The script also supports things such as using a Java remote debugger,
+for help enter use the "/?" parameter, eg:
+
+..\..\bin\tuscany.bat /?
+
+To simplify the use of the script add the absolute file path of the bin
+folder to your environment path:
+
+set PATH=%PATH%;\Tuscany\tuscany-sca-2.0-M4\bin
+
+and that enables running the script by just "tuscany", for example, in the
+implementation-java-calculator sample again you can enter:
+
+tuscany target\implementation-java-calculator.jar
+
+Tuscany developers may find it useful to add the script from their SVN checkout
+development build to their environment so as to start runtimes using their local
+trunk build, for example:
+
+set PATH=%PATH%;\Tuscany\SVN\trunk\distribution\all\target\apache-tuscany-sca-all-2.0-SNAPSHOT-dir\tuscany-sca-2.0-SNAPSHOT\bin
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/default.config b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/default.config
new file mode 100644
index 0000000000..d0f68de133
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/default.config
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+classpath=modules/**
+mainClass=[firstArgJarManifestMainClass]|org.apache.tuscany.sca.domain.node.DomainNodeMain
+-Djava.util.logging.config.file={TUSCANY_HOME}/samples/logging.properties
+
+
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/osgi.config b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/osgi.config
new file mode 100644
index 0000000000..9516b9db34
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/osgi.config
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+classpath=modules/**
+-Djava.util.logging.config.file={TUSCANY_HOME}/samples/logging.properties
+mainClass=org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher2
+
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/tuscany.bat b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/tuscany.bat
new file mode 100644
index 0000000000..cbf6962218
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/tuscany.bat
@@ -0,0 +1,83 @@
+@echo off
+
+REM # Licensed to the Apache Software Foundation (ASF) under one
+REM # or more contributor license agreements. See the NOTICE file
+REM # distributed with this work for additional information
+REM # regarding copyright ownership. The ASF licenses this file
+REM # to you under the Apache License, Version 2.0 (the
+REM # "License"); you may not use this file except in compliance
+REM # with the License. You may obtain a copy of the License at
+REM #
+REM # http://www.apache.org/licenses/LICENSE-2.0
+REM #
+REM # Unless required by applicable law or agreed to in writing,
+REM # software distributed under the License is distributed on an
+REM # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+REM # KIND, either express or implied. See the License for the
+REM # specific language governing permissions and limitations
+REM # under the License.
+
+REM TODO: can't get these to work yet when using the tribes domaim URI in quotes
+REM if "%1".=="/?". goto help
+REM if "%1".=="-help". goto help
+
+if not "%TUSCANY_HOME%"=="" goto gotHome
+SET TUSCANY_HOME=%~dp0\..
+if not "%TUSCANY_HOME%"=="" goto gotHome
+echo.
+echo cannot find TUSCANY_HOME please set TUSCANY_HOME variable to the Tuscany installation dir
+echo.
+goto error
+:gotHome
+
+
+set _XDEBUG=
+if not %1==debug goto skipDebug
+set _XDEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
+shift
+:skipDebug
+
+set _FORK=
+if not %1==fork goto skipFork
+set _FORK=start
+shift
+:skipFORK
+
+set _CMD_LINE_ARGS=
+:argsLoop
+if %1a==a goto doneInit
+set _CMD_LINE_ARGS=%_CMD_LINE_ARGS% %1
+shift
+goto argsLoop
+
+
+:doneInit
+
+%_FORK% java %_XDEBUG% -jar %TUSCANY_HOME%/bin/launcher.jar %_CMD_LINE_ARGS%
+
+goto end
+
+:help
+
+echo Apache Tuscany SCA runtime launcher
+echo TUSCANY [debug] [fork] [domainURI] contributions
+echo debug enable Java remote debugging
+echo fork start a new command prompt window to run the contributions
+echo domainURI config URI for the domain, the format is:
+echo vm:domainName
+echo or
+echo "tribes:domainName?routes=ip1,ip2,..."
+echo NOTE that the tribes URI needs to be in quotes
+echo contributions list of SCA contribution file names seperated by spaces. All
+echo deployable composites found in the contributions will be run.
+
+goto end
+
+:error
+set ERROR_CODE=1
+
+
+:end
+@endlocal
+exit /B %ERROR_CODE%
+
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/tuscany.sh b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/tuscany.sh
new file mode 100644
index 0000000000..b053afe4e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/tuscany.sh
@@ -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
+
+#!/bin/bash
+
+# copied from tomcat catalina.sh
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ]; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+# Get standard environment variables
+PRGDIR=`dirname "$PRG"`
+
+# Only set CATALINA_HOME if not already set
+[ -z "$TUSCANY_HOME" ] && TUSCANY_HOME=`cd "$PRGDIR/.." ; pwd`
+
+if [ "$1" = "/?" ] ; then
+ echo "Apache Tuscany SCA runtime launcher"
+ echo "TUSCANY [debug] contributions"
+ echo " debug enable Java remote debugging"
+ echo " contributions list of SCA contribution file names seperated by spaces. All"
+ echo " deployable composites found in the contributions will be run."
+ exit 1
+fi
+
+_XDEBUG=""
+if [ "$1" = "debug" ] ; then
+ _XDEBUG="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
+ shift
+fi
+
+java $_XDEBUG -jar $TUSCANY_HOME/bin/launcher.jar "$@"
diff --git a/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/unmanaged.config b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/unmanaged.config
new file mode 100644
index 0000000000..ac99590ce9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/all/src/main/release/launcher/unmanaged.config
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+classpath=modules/**
+-Djava.util.logging.config.file={TUSCANY_HOME}/samples/logging.properties
+mainClass=[firstArgJarManifestMainClass]
+
diff --git a/sandbox/sebastien/java/embed/distribution/pom.xml b/sandbox/sebastien/java/embed/distribution/pom.xml
new file mode 100644
index 0000000000..0058a99177
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/pom.xml
@@ -0,0 +1,38 @@
+<?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>
+ <relativePath>../pom.xml</relativePath>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distribution</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Distributions</name>
+
+ <modules>
+ <module>all</module>
+ <module>tomcat</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/README.txt b/sandbox/sebastien/java/embed/distribution/tomcat/README.txt
new file mode 100644
index 0000000000..b6158e3667
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/README.txt
@@ -0,0 +1,8 @@
+This builds the Tuscany Tomcat Distribution.
+
+After building the distribution .war file will be
+found in the tomcat-war/target directory.
+
+
+
+
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/pom.xml
new file mode 100644
index 0000000000..7164f45ac7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <relativePath>../pom.xml</relativePath>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distribution-tomcat</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Distribution Tomcat</name>
+
+ <modules>
+ <module>tomcat-hook</module>
+ <module>tomcat-servlet</module>
+ <module>tomcat-war</module>
+ <module>testing</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/download-tomcat/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/download-tomcat/pom.xml
new file mode 100644
index 0000000000..68bb686ae3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/download-tomcat/pom.xml
@@ -0,0 +1,82 @@
+<?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-distribution-tomcat-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>download-tomcat</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Tomcat Integration Testing Download Tomcat</name>
+
+ <properties>
+ <tomcat.version>6.0.18</tomcat.version>
+ </properties>
+
+ <build>
+
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>wagon-maven-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ <executions>
+ <execution>
+ <id>download-tomcat</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>download-single</goal>
+ </goals>
+ <configuration>
+ <url>http://archive.apache.org</url>
+ <fromFile>dist/tomcat/tomcat-6/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip</fromFile>
+ <toDir>download</toDir>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+<profiles>
+ <profile>
+ <activation>
+ <file>
+ <exists>download/apache-tomcat-6.0.18.zip</exists>
+ </file>
+ </activation>
+ </profile>
+</profiles>
+
+
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/pom.xml
new file mode 100644
index 0000000000..27816ddb00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/pom.xml
@@ -0,0 +1,47 @@
+<?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-distribution-tomcat-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-client-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Tomcat Integration Testing Helloworld Client Webapp</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
+
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java
new file mode 100644
index 0000000000..0be22979c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/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 testing;
+
+// TODO: should the webapp need to include the service interface?
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..d6db86cf64
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://testing"
+ name="jsp-client-webapp">
+
+ <!-- TODO: should the component name be unique in the domain? i guess so -->
+ <component name="WebComponent">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..411d8a3146
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml
@@ -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.
+-->
+<web-app 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>jsp-client-webapp</display-name>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..d520375993
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp
@@ -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.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="testing.HelloworldService" />
+
+<html>
+ <body >
+
+ <h2>jsp-client-webapp</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.sayHello("world") %>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/pom.xml
new file mode 100644
index 0000000000..d1ea28fc54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/pom.xml
@@ -0,0 +1,45 @@
+<?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-distribution-tomcat-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-reference-contribution</artifactId>
+ <name>Apache Tuscany SCA Tomcat Integration Testing Helloworld Reference Contribution</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/java/testing/HelloworldRefImpl.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/java/testing/HelloworldRefImpl.java
new file mode 100644
index 0000000000..c2d0bcb4dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/java/testing/HelloworldRefImpl.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 testing;
+
+import org.oasisopen.sca.annotation.Service;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.EagerInit;
+
+@Service(HelloworldService.class)
+public class HelloworldRefImpl implements HelloworldService {
+
+ @Reference
+ public HelloworldService service;
+
+ public String sayHello(String name) {
+ if (service == null) {
+ return "ERROR, @Reference is null!";
+ } else {
+ return "Hello ref says: " + service.sayHello(name);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/java/testing/HelloworldService.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/java/testing/HelloworldService.java
new file mode 100644
index 0000000000..b035a772be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/java/testing/HelloworldService.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 testing;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..693325c13d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:testing="http://org.apache.tuscany.tomcat.testing">
+ <deployable composite="testing:helloworld-reference-contribution"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..b07cf6078c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-reference-contribution/src/main/resources/helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://org.apache.tuscany.tomcat.testing"
+ name="helloworld-reference-contribution">
+
+ <component name="HelloworldRefComponent">
+ <implementation.java class="testing.HelloworldRefImpl"/>
+ <reference name="service" target="HelloworldComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/pom.xml
new file mode 100644
index 0000000000..b11a6bb687
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/pom.xml
@@ -0,0 +1,48 @@
+<?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-distribution-tomcat-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-scaclient-jsp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Tomcat Integration Testing Helloworld Webapp Using SCAClient in a JSP</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
+
+
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/java/testing/HelloworldService.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/java/testing/HelloworldService.java
new file mode 100644
index 0000000000..b035a772be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/java/testing/HelloworldService.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 testing;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7839933b3a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/META-INF/sca-contribution.xml
@@ -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.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:testing="http://org.apache.tuscany.tomcat.testing">
+
+ <!-- TODO: There's nothing in here as this file is only present so that the
+ Tuscany Tomcat integration code gets triggered when this webapp
+ ias deployed and adds Tuscany to the Webapp classpath so that the
+ SCAClient implementation is available -->
+
+</contribution>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..f2e3441d5e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/WEB-INF/web.xml
@@ -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.
+-->
+<web-app 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>jsp-client-webapp</display-name>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/hello.jsp b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..45ae96cb82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-jsp/src/main/webapp/hello.jsp
@@ -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.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+<%@ page import="org.oasisopen.sca.client.SCAClientFactory"%>
+<%@ page import="testing.HelloworldService" %>
+<%@ page import="java.net.URI" %>
+
+<%
+ HelloworldService service = SCAClientFactory.newInstance(URI.create("default")).getService(HelloworldService.class, "HelloworldComponent");
+%>
+
+<html>
+ <body >
+
+ <h2>helloworld-scaclient-jsp</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.sayHello("world") %>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/pom.xml
new file mode 100644
index 0000000000..d8a4831e82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/pom.xml
@@ -0,0 +1,53 @@
+<?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-distribution-tomcat-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-scaclient-servlet</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Tomcat Integration Testing Helloworld Webapp Using SCAClient in a Servlet</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
+
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/java/testing/HelloworldService.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/java/testing/HelloworldService.java
new file mode 100644
index 0000000000..b035a772be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/java/testing/HelloworldService.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 testing;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/java/testing/HelloworldServlet.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/java/testing/HelloworldServlet.java
new file mode 100644
index 0000000000..5be51fab61
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/java/testing/HelloworldServlet.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 testing;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.net.URI;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ */
+public class HelloworldServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ try {
+
+ String component = request.getParameter("component");
+ HelloworldService service = SCAClientFactory.newInstance(URI.create("default")).getService(HelloworldService.class, component);
+
+ String name = request.getParameter("name");
+ String greeting = service.sayHello(name);
+
+ Writer out = response.getWriter();
+ out.write("<html><head><title>Apache Tuscany Helloworld Servlet Sample</title></head><body>");
+ out.write("<h2>Apache Tuscany Helloworld Servlet Sample</h2>");
+ out.write("<br><strong>Component " + component + " says: </strong>" + greeting);
+ out.write("</body></html>");
+ out.flush();
+ out.close();
+
+ } catch (NoSuchDomainException e) {
+ e.printStackTrace();
+ } catch (NoSuchServiceException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7839933b3a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/META-INF/sca-contribution.xml
@@ -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.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:testing="http://org.apache.tuscany.tomcat.testing">
+
+ <!-- TODO: There's nothing in here as this file is only present so that the
+ Tuscany Tomcat integration code gets triggered when this webapp
+ ias deployed and adds Tuscany to the Webapp classpath so that the
+ SCAClient implementation is available -->
+
+</contribution>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..d424d4b71b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+<web-app 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>helloworld-scaclient2-webapp</display-name>
+
+ <servlet>
+ <servlet-name>HelloworldServlet</servlet-name>
+ <servlet-class>testing.HelloworldServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>HelloworldServlet</servlet-name>
+ <url-pattern>/HelloworldServlet</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/hello.html b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/hello.html
new file mode 100644
index 0000000000..5398cb5274
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-scaclient-servlet/src/main/webapp/hello.html
@@ -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.
+-->
+<html>
+
+<head>
+<title>helloworld-scaclient2-webapp</title>
+</head>
+
+<body>
+
+<h2>helloworld-scaclient-servlet</h2>
+
+<form action="HelloworldServlet" method="post">
+ <table>
+ <tr>
+
+ <td><select name="component" size="1">
+ <option>HelloworldComponent</option>
+ <option>HelloworldRefComponent</option>
+ </select></td>
+
+ <td>Enter your name:</td>
+ <td>
+ <input type="text" name="name" width="10">
+ </td>
+ </tr>
+ <tr>
+ <td align="left" colspan="2">
+ <button name="submit" type="submit">Say hello</button>
+ </td>
+ </tr>
+ </table>
+</form>
+
+</body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/pom.xml
new file mode 100644
index 0000000000..3b43a4fa59
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/pom.xml
@@ -0,0 +1,45 @@
+<?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-distribution-tomcat-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-service-contribution</artifactId>
+ <name>Apache Tuscany SCA Tomcat Integration Testing Helloworld Service Contribution</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java
new file mode 100644
index 0000000000..564b2e332f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.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 testing;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+import org.oasisopen.sca.annotation.EagerInit;
+
+@Service(HelloworldService.class)
+@Scope("COMPOSITE") @EagerInit
+public class HelloworldImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ @Init
+ public void init() {
+ System.out.println("HelloworldImpl eager init: " + sayHello("world"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java
new file mode 100644
index 0000000000..eec9d63da8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.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 testing;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..4e0eca6068
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:testing="http://org.apache.tuscany.tomcat.testing">
+ <deployable composite="testing:helloworld-service-contribution"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..82b2cc7ce7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://org.apache.tuscany.tomcat.testing"
+ name="helloworld-service-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="testing.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/legal-checks/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/legal-checks/pom.xml
new file mode 100644
index 0000000000..96209a1b57
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/legal-checks/pom.xml
@@ -0,0 +1,42 @@
+<?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-distribution-tomcat-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>war-legal-checks</artifactId>
+ <name>Apache Tuscany SCA WAR Distribution Legal Checks</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java b/sandbox/sebastien/java/embed/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java
new file mode 100644
index 0000000000..04e6a0bc5c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.junit.Test;
+
+/**
+ * Checks that all jar files included in the distribution are mentioned in the LICENSE file
+ * and that all jars mentioned in the LICENSE are in the distribution.
+ */
+public class JarsInLICENSETestCase {
+
+ @Test
+ public void testJars() throws Exception {
+ File distroRoot = getUnzipedDistroRoot();
+
+ File licenseFile = new File(distroRoot, "LICENSE");
+ if (!licenseFile.exists()) {
+ throw new IllegalStateException("can't find LICENSE file at: " + licenseFile.getAbsoluteFile().toString());
+ }
+
+ File libDirectory = distroRoot;
+ if (!libDirectory.exists()) {
+ throw new IllegalStateException("can't find modules folder at: " + libDirectory.getAbsoluteFile().toString());
+ }
+
+ List<String> jars = getJarsInDistro(libDirectory);
+
+ List<String> bad2 = getLICENSEJarsNotInDistro(licenseFile, jars);
+ if (bad2.size() > 0) {
+ System.err.println("Jars in LICENSE but not in Distribution: " + bad2);
+ }
+
+ List<String> bad1 = getJarsNotInLICENSE(jars, licenseFile);
+ if (bad1.size() > 0) {
+ System.err.println("Jars in distribution but not in LICENSE: " + bad1);
+ }
+
+ if (bad1.size() > 0 || bad2.size() > 0) {
+ throw new IllegalStateException("LICENSE problems, check log");
+ }
+ }
+
+ private List<String> getLICENSEJarsNotInDistro(File licenseFile, List<String> jars) throws IOException {
+ List<String> badJars = new ArrayList<String>();
+ BufferedReader reader = new BufferedReader(new FileReader(licenseFile));
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ if (line.contains(".jar")) {
+ StringTokenizer st = new StringTokenizer(line);
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken();
+ if (s.contains(".jar")) {
+ if (s.startsWith("(")) {
+ s = s.substring(1);
+ }
+ if (s.endsWith(",") || s.endsWith(":")) {
+ s = s.substring(0, s.length()-1);
+ }
+ if (s.endsWith(")")) {
+ s = s.substring(0, s.length()-1);
+ }
+ if (!jars.contains(s) && !s.startsWith("tuscany-")) {
+ badJars.add(s);
+ }
+ }
+ }
+ }
+ }
+ return badJars;
+ }
+
+ private List<String> getJarsNotInLICENSE(List<String> jars, File licenseFile) throws IOException {
+ List<String> badJars = new ArrayList<String>();
+ String licenseText = readLICENSE(licenseFile);
+ for (String jar : jars) {
+ if (!licenseText.contains(jar)) {
+ if (jar.startsWith("tuscany-")) {
+ // ignore tuscany jars as they're not mentioned in the LICENSE file
+ } else {
+ badJars.add(jar);
+ }
+ }
+ }
+ return badJars;
+ }
+
+ private List<String> getJarsInDistro(File directory) {
+ List<String> jars = new ArrayList<String>();
+ for (String fn : directory.list()){
+ if (fn.endsWith(".jar")) {
+ jars.add(fn);
+ } else {
+ File f = new File(directory, fn);
+ if (f.isDirectory()) {
+ jars.addAll(getJarsInDistro(f));
+ }
+ }
+ }
+ return jars;
+ }
+
+ private File getUnzipedDistroRoot() {
+ return new File("../../tomcat-war/target/tuscany");
+ }
+
+ private static String readLICENSE(File licenseFile) throws java.io.IOException {
+ StringBuffer fileData = new StringBuffer();
+ BufferedReader reader = new BufferedReader(new FileReader(licenseFile));
+ char[] buf = new char[1024];
+ int numRead = 0;
+ while ((numRead = reader.read(buf)) != -1) {
+ String readData = String.valueOf(buf, 0, numRead);
+ fileData.append(readData);
+ buf = new char[1024];
+ }
+ reader.close();
+ return fileData.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/testing/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/testing/pom.xml
new file mode 100644
index 0000000000..d77f0e8b3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/testing/pom.xml
@@ -0,0 +1,42 @@
+<?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-distribution-tomcat</artifactId>
+ <relativePath>../pom.xml</relativePath>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distribution-tomcat-testing</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Distribution Tomcat Testing</name>
+
+ <modules>
+ <module>helloworld-service-contribution</module>
+ <module>helloworld-reference-contribution</module>
+ <module>helloworld-scaclient-jsp</module>
+ <module>helloworld-scaclient-servlet</module>
+ <module>helloworld-client-webapp</module>
+ <module>legal-checks</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/LICENSE b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/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/sebastien/java/embed/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..70e18a0c9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.tomcat;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Tomcat Hook
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1222833658000
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Webapp Host
+Import-Package: javax.naming,
+ javax.servlet,
+ javax.servlet.http,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.host.webapp;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.tomcat
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/NOTICE b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/NOTICE
new file mode 100644
index 0000000000..0d2bd8fb3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/NOTICE
@@ -0,0 +1,7 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/pom.xml
new file mode 100644
index 0000000000..8b792960ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-tomcat-hook</artifactId>
+ <name>Apache Tuscany SCA Tomcat Hook</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>6.0.18</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>coyote</artifactId>
+ <version>6.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.swizzle</groupId>
+ <artifactId>swizzle-stream</artifactId>
+ <version>1.0.2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java
new file mode 100644
index 0000000000..54947d6492
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.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.sca.tomcat;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.naming.NamingException;
+import javax.servlet.ServletContext;
+
+import org.apache.AnnotationProcessor;
+import org.apache.catalina.util.DefaultAnnotationProcessor;
+
+public class TuscanyAnnotationsProcessor implements AnnotationProcessor {
+
+ private TuscanyStandardContext tuscanyStandardContext;
+ private AnnotationProcessor tomcatAnnotationProcessor;
+ private Method tuscanyInjectMethod;
+
+ public TuscanyAnnotationsProcessor(TuscanyStandardContext tuscanyStandardContext, javax.naming.Context context) {
+ this.tuscanyStandardContext = tuscanyStandardContext;
+ this.tomcatAnnotationProcessor = new DefaultAnnotationProcessor(context);
+ initInjectMethod(tuscanyStandardContext);
+ }
+
+ private void initInjectMethod(TuscanyStandardContext tuscanyStandardContext) {
+
+ // this needs to use reflection as the tuscany-hook module can't have any
+ // dependencies on the tuscany runtime modules as they're not
+ // in the server classpath
+ // TODO: is there a nicer way ?
+
+ ClassLoader cl = tuscanyStandardContext.getParentClassLoader();
+ try {
+ Class<?> c = Class.forName("org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper", true, cl);
+ if (c != null) {
+ this.tuscanyInjectMethod = c.getMethod("inject", new Class[]{Object.class, ServletContext.class});
+ }
+ } catch (Exception e){
+ // ignore
+ }
+ }
+
+ public void postConstruct(Object instance) throws IllegalAccessException, InvocationTargetException {
+ tomcatAnnotationProcessor.postConstruct(instance);
+ }
+
+ public void preDestroy(Object instance) throws IllegalAccessException, InvocationTargetException {
+ tomcatAnnotationProcessor.preDestroy(instance);
+ }
+
+ public void processAnnotations(Object instance) throws IllegalAccessException, InvocationTargetException, NamingException {
+ if (tuscanyInjectMethod != null) {
+ ServletContext sc = tuscanyStandardContext.getServletContext();
+ if (sc != null) {
+ Object rc = sc.getAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent");
+ if (rc != null) {
+ try {
+ tuscanyInjectMethod.invoke(null, instance, sc);
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ }
+ }
+ tomcatAnnotationProcessor.processAnnotations(instance);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyContextConfig.java b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyContextConfig.java
new file mode 100644
index 0000000000..5e7905d246
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyContextConfig.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.tomcat;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.catalina.Host;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.startup.ContextConfig;
+import org.apache.catalina.startup.ExpandWar;
+
+public class TuscanyContextConfig extends ContextConfig{
+
+ /**
+ * Return the location of the default deployment descriptor
+ *
+ * Override the super class method to use the Tuscany specific
+ * default web.xml which has the Tuscany listener and filer config
+ */
+ @Override
+ public String getDefaultWebXml() {
+ if( defaultWebXml == null ) {
+ defaultWebXml="conf/tuscany-web.xml";
+ }
+ return (this.defaultWebXml);
+ }
+
+ /**
+ * Adjust docBase.
+ *
+ * This is cutNpaste of the Tomcat method but changed on the lines marked with // TUSCANY:
+ * to override the default that only works for file names ending with .war
+ *
+ */
+ @Override
+ protected void fixDocBase()
+ throws IOException {
+
+ Host host = (Host) context.getParent();
+ String appBase = host.getAppBase();
+
+ boolean unpackWARs = true;
+ if (host instanceof StandardHost) {
+ unpackWARs = ((StandardHost) host).isUnpackWARs()
+ && ((StandardContext) context).getUnpackWAR();
+ }
+
+ File canonicalAppBase = new File(appBase);
+ if (canonicalAppBase.isAbsolute()) {
+ canonicalAppBase = canonicalAppBase.getCanonicalFile();
+ } else {
+ canonicalAppBase =
+ new File(System.getProperty("catalina.base"), appBase)
+ .getCanonicalFile();
+ }
+
+ String docBase = context.getDocBase();
+ if (docBase == null) {
+ // Trying to guess the docBase according to the path
+ String path = context.getPath();
+ if (path == null) {
+ return;
+ }
+ if (path.equals("")) {
+ docBase = "ROOT";
+ } else {
+ if (path.startsWith("/")) {
+ docBase = path.substring(1);
+ } else {
+ docBase = path;
+ }
+ }
+ }
+
+ File file = new File(docBase);
+ if (!file.isAbsolute()) {
+ docBase = (new File(canonicalAppBase, docBase)).getPath();
+ } else {
+ docBase = file.getCanonicalPath();
+ }
+ file = new File(docBase);
+ String origDocBase = docBase;
+
+ String contextPath = context.getPath();
+ if (contextPath.equals("")) {
+ contextPath = "ROOT";
+ } else {
+ if (contextPath.lastIndexOf('/') > 0) {
+ contextPath = "/" + contextPath.substring(1).replace('/','#');
+ }
+ }
+ // TUSCANY: update from .war to also support .jar and .zip SCA contributions
+ if ((docBase.toLowerCase().endsWith(".war") || docBase.toLowerCase().endsWith(".jar")||docBase.toLowerCase().endsWith(".zip")) && !file.isDirectory() && unpackWARs) {
+ URL war = new URL("jar:" + (new File(docBase)).toURI().toURL() + "!/");
+ docBase = ExpandWar.expand(host, war, contextPath);
+ file = new File(docBase);
+ docBase = file.getCanonicalPath();
+ if (context instanceof StandardContext) {
+ ((StandardContext) context).setOriginalDocBase(origDocBase);
+ }
+ } else {
+ File docDir = new File(docBase);
+ if (!docDir.exists()) {
+ // TUSCANY: update from .war to also support .jar and .zip SCA contributions
+ File warFile = new File(docBase + ".war");
+ if (warFile.exists()) {
+ if (unpackWARs) {
+ URL war =
+ new URL("jar:" + warFile.toURI().toURL() + "!/");
+ docBase = ExpandWar.expand(host, war, contextPath);
+ file = new File(docBase);
+ docBase = file.getCanonicalPath();
+ } else {
+ docBase = warFile.getCanonicalPath();
+ }
+ } else {
+ warFile = new File(docBase + ".jar");
+ if (warFile.exists()) {
+ if (unpackWARs) {
+ URL war =
+ new URL("jar:" + warFile.toURI().toURL() + "!/");
+ docBase = ExpandWar.expand(host, war, contextPath);
+ file = new File(docBase);
+ docBase = file.getCanonicalPath();
+ } else {
+ docBase = warFile.getCanonicalPath();
+ }
+ } else {
+ warFile = new File(docBase + ".zip");
+ if (warFile.exists()) {
+ if (unpackWARs) {
+ URL war =
+ new URL("jar:" + warFile.toURI().toURL() + "!/");
+ docBase = ExpandWar.expand(host, war, contextPath);
+ file = new File(docBase);
+ docBase = file.getCanonicalPath();
+ } else {
+ docBase = warFile.getCanonicalPath();
+ }
+ }
+ }
+ }
+ if (context instanceof StandardContext) {
+ ((StandardContext) context).setOriginalDocBase(origDocBase);
+ }
+ }
+ }
+
+ if (docBase.startsWith(canonicalAppBase.getPath())) {
+ docBase = docBase.substring(canonicalAppBase.getPath().length());
+ docBase = docBase.replace(File.separatorChar, '/');
+ if (docBase.startsWith("/")) {
+ docBase = docBase.substring(1);
+ }
+ } else {
+ docBase = docBase.replace(File.separatorChar, '/');
+ }
+
+ context.setDocBase(docBase);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyHostConfig.java b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyHostConfig.java
new file mode 100644
index 0000000000..e92d7a0bf6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyHostConfig.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.tomcat;
+
+import java.io.File;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.startup.HostConfig;
+
+/**
+ * A Tuscany customized HostConfig that adds support for SCA contributions
+ * to be deployed along with the usual .war files.
+ */
+public class TuscanyHostConfig extends HostConfig {
+
+ protected File scaBase = null;
+
+ @Override
+ protected void deployApps() {
+
+ File appBase = appBase();
+ File configBase = configBase();
+ // Deploy XML descriptors from configBase
+ deployDescriptors(configBase, configBase.list());
+ // Deploy WARs, and loop if additional descriptors are found
+ deployWARs(appBase, appBase.list());
+ // TUSCANY: Deploy any SCA contibutions
+ deploySCAContributions(appBase, appBase.list());
+ // Deploy expanded folders
+ deployDirectories(appBase, appBase.list());
+ }
+
+ protected void deploySCAContributions(File appBase, String[] files) {
+ if (files == null)
+ return;
+
+ for (int i = 0; i < files.length; i++) {
+
+ File scafile = new File(appBase, files[i]);
+
+ if (scafile.isFile() && isSCAContribution(scafile)) {
+
+ // Calculate the context path and make sure it is unique
+ String contextPath = "/" + files[i].replace('#','/');
+ int period = contextPath.lastIndexOf(".");
+ if (period >= 0)
+ contextPath = contextPath.substring(0, period);
+
+ if (isServiced(contextPath))
+ continue;
+
+ String file = files[i];
+
+ deploySCAContribution(contextPath, scafile, file);
+
+ }
+
+ }
+
+ }
+
+ protected String tuscanyContextClass = "org.apache.tuscany.sca.tomcat.TuscanyContextConfig";
+
+ protected void deploySCAContribution(String contextPath, File dir, String file) {
+ if (deploymentExists(contextPath))
+ return;
+
+ DeployedApplication deployedApp = new DeployedApplication(contextPath);
+
+ // Deploy the application in this WAR file
+ if(log.isInfoEnabled())
+ log.info("Deploying SCA contibution: " + file);
+
+ // Populate redeploy resources with the WAR file
+ deployedApp.redeployResources.put(dir.getAbsolutePath(), new Long(dir.lastModified()));
+
+ try {
+ Context context = (Context) Class.forName(contextClass).newInstance();
+ if (context instanceof Lifecycle) {
+
+ // Tuscany: change to use the Tuscany ContextConfig class
+ Class clazz = Class.forName(tuscanyContextClass);
+
+ LifecycleListener listener =
+ (LifecycleListener) clazz.newInstance();
+ ((Lifecycle) context).addLifecycleListener(listener);
+ }
+ context.setPath(contextPath);
+ context.setDocBase(file);
+
+ host.addChild(context);
+ // If we're unpacking WARs, the docBase will be mutated after
+ // starting the context
+ if (unpackWARs && (context.getDocBase() != null)) {
+ String name = null;
+ String path = context.getPath();
+ if (path.equals("")) {
+ name = "ROOT";
+ } else {
+ if (path.startsWith("/")) {
+ name = path.substring(1);
+ } else {
+ name = path;
+ }
+ }
+ name = name.replace('/', '#');
+ File docBase = new File(name);
+ if (!docBase.isAbsolute()) {
+ docBase = new File(appBase(), name);
+ }
+ deployedApp.redeployResources.put(docBase.getAbsolutePath(),
+ new Long(docBase.lastModified()));
+ addWatchedResources(deployedApp, docBase.getAbsolutePath(), context);
+ } else {
+ addWatchedResources(deployedApp, null, context);
+ }
+ } catch (Throwable t) {
+ log.error(sm.getString("hostConfig.deployJar.error", file), t);
+ }
+
+ deployed.put(contextPath, deployedApp);
+ }
+
+ protected boolean isSCAContribution(File file) {
+ ZipFile zip = null;
+ ZipEntry entry = null;
+ try {
+ try {
+ zip = new ZipFile(file);
+ entry = zip.getEntry("META-INF/sca-contribution.xml");
+ } catch (Exception e) {
+ }
+
+ return (entry != null);
+
+ } finally {
+ if (zip != null) {
+ try {
+ zip.close();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java
new file mode 100644
index 0000000000..a9eee9687e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.tomcat;
+
+import java.io.File;
+import java.util.logging.Logger;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.ServerFactory;
+import org.apache.catalina.Service;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardEngine;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.core.StandardServer;
+import org.apache.catalina.core.StandardService;
+import org.apache.catalina.startup.HostConfig;
+
+/**
+ * A Tomcat LifecycleListener that initilizes the Tuscany Tomcat integration.
+ * It sets a System property with the location of the Tuscany runtime .war
+ * and configures each Tomcat Connector to use the TuscanyStandardContext.
+ *
+ * To configure Tomcat to use this add the following to the Tomcat conf/server.xml
+ * <Listener className="org.apache.tuscany.sca.tomcat.TuscanyLifecycleListener"/>
+ */
+public class TuscanyLifecycleListener implements LifecycleListener {
+ private static final Logger log = Logger.getLogger(TuscanyLifecycleListener.class.getName());
+
+ public static final String TUSCANY_WAR_PROP = "org.apache.tuscany.sca.tomcat.war";
+
+ private static boolean running;
+
+ public static boolean isRunning() {
+ return running;
+ }
+
+ static final String TUSCANY_SHARED_PROP = "org.apache.tuscany.sca.tomcat.shared";
+
+ private static String domainURI = "tuscany:default";
+
+ public TuscanyLifecycleListener() {
+ running = true;
+ log.info("Apache Tuscany initilizing");
+ }
+
+ public void lifecycleEvent(LifecycleEvent event) {
+ if ("init".equals(event.getType()) && (event.getSource() instanceof StandardServer)) {
+ File webappDir = findTuscanyWar();
+ if (webappDir == null) {
+ log.severe("Tuscany disabled as Tuscany webapp not found");
+ } else {
+ System.setProperty(TUSCANY_WAR_PROP, webappDir.getAbsolutePath());
+ log.info("Using Tuscany webapp: " + webappDir.getAbsolutePath());
+ StandardServer server = (StandardServer)event.getSource();
+ StandardService catalina = (StandardService)server.findService("Catalina");
+ for (Connector connector : catalina.findConnectors()) {
+ for (Container container : connector.getContainer().findChildren()) {
+ if (container instanceof StandardHost) {
+ for (LifecycleListener listener : ((StandardHost)container).findLifecycleListeners()) {
+ if (listener instanceof HostConfig) {
+ ((HostConfig)listener).setContextClass("org.apache.tuscany.sca.tomcat.TuscanyStandardContext");
+ log.info("Tuscany enabled on connector: " + container.getName() + ":" + connector.getPort());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private static File findTuscanyWar() {
+
+ // in Tomcat 5.5 the Tuscany war is in the server/webapps director
+ String catalinaBase = System.getProperty("catalina.base");
+ File serverWebapps = new File(catalinaBase, "server/webapps");
+ File tuscanyWar = findTuscanyWar(serverWebapps);
+ if (tuscanyWar != null) {
+ return tuscanyWar;
+ }
+
+ // in Tomcat 6 the Tuscany war is normally in webapps, but we just scan all hosts directories
+ for (Service service : ServerFactory.getServer().findServices()) {
+ Container container = service.getContainer();
+ if (container instanceof StandardEngine) {
+ StandardEngine engine = (StandardEngine)container;
+ for (Container child : engine.findChildren()) {
+ if (child instanceof StandardHost) {
+ StandardHost host = (StandardHost)child;
+ String appBase = host.getAppBase();
+
+ // determine the host dir (normally webapps)
+ File hostDir = new File(appBase);
+ if (!hostDir.isAbsolute()) {
+ hostDir = new File(catalinaBase, appBase);
+ }
+
+ tuscanyWar = findTuscanyWar(hostDir);
+ if (tuscanyWar != null) {
+ return tuscanyWar;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private static File findTuscanyWar(File hostDir) {
+ if (!hostDir.isDirectory()) {
+ return null;
+ }
+
+ // iterate over the contexts
+ for (File contextDir : hostDir.listFiles()) {
+ // does this war have a web-inf lib dir
+ File hookLib = new File(contextDir, "tomcat-lib");
+ if (!hookLib.isDirectory()) {
+ continue;
+ }
+ // iterate over the libs looking for the tuscany-tomcat-*.jar
+ for (File file : hookLib.listFiles()) {
+ if (file.getName().startsWith("tuscany-tomcat-hook-") && file.getName().endsWith(".jar")) {
+ // this should be in the Tuscany war...
+ // make sure it has a runtime directory
+ if (new File(contextDir, "tuscany-lib").isDirectory()) {
+ return contextDir;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setDomainURI(String domainURI) {
+ TuscanyLifecycleListener.domainURI = domainURI;
+ }
+
+ public static String getDomainURI() {
+ return domainURI;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
new file mode 100644
index 0000000000..ca9c81f1c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.tomcat;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.logging.Logger;
+
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Loader;
+import org.apache.catalina.core.StandardContext;
+
+/**
+ * A Tuscany StandardContext to initilize SCA applications.
+ * There is a StandardContext instance for each webapp and its
+ * called to handle all start/stop/etc requests. This intercepts
+ * the start and inserts any required Tuscany configuration.
+ */
+public class TuscanyStandardContext extends StandardContext {
+ private static final long serialVersionUID = 1L;
+ private static final Logger log = Logger.getLogger(TuscanyStandardContext.class.getName());
+
+ private boolean isSCAApp;
+
+ // TODO: this gives an instance per webapp, work out how to have only one per server
+ // ?? is that comment still true?
+ private static URLClassLoader tuscanyClassLoader;
+ private static Object node;
+ private static Class<?> nodeClass;
+ private static Method nodeStopMethod;
+
+ public TuscanyStandardContext() {
+ }
+
+ /**
+ * Overrides the getLoader method in the Tomcat StandardContext as its a convenient
+ * point to insert the Tuscany initilization. This gets called the first time during
+ * StandardContext.start after the webapp resources have been created so this can
+ * use getResources() to look for the SCA web.composite or sca-contribution.xml files,
+ * but its still early enough in start to insert the required Tuscany config.
+ */
+ @Override
+ public Loader getLoader() {
+ if (loader != null) {
+ return loader;
+ }
+
+ ClassLoader parent = getParentClassLoader();
+ if (isSCAApp = isSCAApplication()) {
+ if (tuscanyClassLoader == null) {
+ initTuscany();
+ }
+ setParentClassLoader(getTuscanyClassloader(parent));
+ setDefaultWebXml("conf/tuscany-web.xml");
+ }
+
+ return super.getLoader();
+ }
+
+ @Override
+ public boolean listenerStart() {
+ if (isSCAApp) {
+ enableTuscany();
+ }
+ return super.listenerStart();
+ }
+
+ private void enableTuscany() {
+
+ if (isUseNaming() && getNamingContextListener() != null) {
+ setAnnotationProcessor(new TuscanyAnnotationsProcessor(this, getNamingContextListener().getEnvContext()));
+ } else {
+ setAnnotationProcessor(new TuscanyAnnotationsProcessor(this, null));
+ }
+
+ log.info("Tuscany SCA is enabled for: " + this.getName());
+ }
+
+ private boolean isSCAApplication() {
+ Object o = null;
+ try {
+ o = getResources().lookup("WEB-INF/web.composite");
+ } catch (NamingException e) {
+ }
+ if (o == null) {
+ try {
+ o = getResources().lookup("META-INF/sca-contribution.xml");
+ } catch (NamingException e) {
+ }
+ }
+ if (o == null) {
+ return false;
+ }
+
+ // Try to see if the Tuscany jars are packaged in the webapp
+ NamingEnumeration<NameClassPair> enumeration;
+ try {
+ enumeration = getResources().list("WEB-INF/lib");
+ while (enumeration.hasMoreElements()) {
+ String jar = enumeration.nextElement().getName();
+ if (jar.startsWith("tuscany-")) {
+ // Do not alter is
+ log.info("Tuscany SCA ignoring webapp with embedded Tuscany runtime: " + this.getName());
+ return false;
+ }
+ }
+ } catch (NamingException e) {
+ }
+ return true;
+ }
+
+ private URLClassLoader getTuscanyClassloader(ClassLoader parent) {
+ return tuscanyClassLoader;
+ }
+
+ private void initTuscany() {
+ initTuscanyClassloader(getParentClassLoader());
+ initDomain();
+ }
+
+ private void initTuscanyClassloader(ClassLoader parent) {
+ if (tuscanyClassLoader == null) {
+ File tuscanyWar = new File(System.getProperty(TuscanyLifecycleListener.TUSCANY_WAR_PROP));
+ File[] runtimeJars = new File(tuscanyWar, "tuscany-lib").listFiles();
+ try {
+ URL[] jarURLs = new URL[runtimeJars.length];
+ for (int i = 0; i < jarURLs.length; i++) {
+ jarURLs[i] = runtimeJars[i].toURI().toURL();
+ }
+ tuscanyClassLoader = new URLClassLoader(jarURLs, parent);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void initDomain() {
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(tuscanyClassLoader);
+ Class<?> nodeFactoryClass = Class.forName("org.apache.tuscany.sca.node.NodeFactory", true, tuscanyClassLoader);
+ Method getInstanceMethod = nodeFactoryClass.getMethod("getInstance", new Class[0]);
+ Object instance = getInstanceMethod.invoke(null);
+ Method createNodeMethod = nodeFactoryClass.getMethod("createNode", new Class[]{URI.class, new String[0].getClass()});
+ URI domainURI = URI.create(TuscanyLifecycleListener.getDomainURI());
+ this.node = createNodeMethod.invoke(instance, new Object[]{domainURI, new String[0]});
+ this.nodeClass = Class.forName("org.apache.tuscany.sca.node.Node", true, tuscanyClassLoader);
+ Method nodeStartMethod = nodeClass.getMethod("start", new Class[0]);
+ this.nodeStopMethod = nodeClass.getMethod("stop", new Class[0]);
+ nodeStartMethod.invoke(node);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
+ }
+
+ @Override
+ public synchronized void stop() throws LifecycleException {
+ super.stop();
+
+ if (node != null && nodeStopMethod != null) {
+ try {
+ nodeStopMethod.invoke(node);
+ node = null;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..0b0e3e7d0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Tomcat Servlet
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1222833658000
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Tomcat Servlet
+Bundle-SymbolicName: org.apache.tuscany.sca.tomcat.servlet
+Import-Package: org.apache.tuscany.sca.tomcat;version="2.0.0"
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/pom.xml
new file mode 100644
index 0000000000..83b68dad0c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/pom.xml
@@ -0,0 +1,63 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-tomcat-servlet</artifactId>
+ <name>Apache Tuscany SCA Tomcat Integration Servlet</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-tomcat-hook</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.swizzle</groupId>
+ <artifactId>swizzle-stream</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java
new file mode 100644
index 0000000000..59fecbf8f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java
@@ -0,0 +1,374 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.war;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import org.apache.tuscany.sca.tomcat.TuscanyLifecycleListener;
+import org.codehaus.swizzle.stream.DelimitedTokenReplacementInputStream;
+import org.codehaus.swizzle.stream.StringTokenHandler;
+
+public class Installer {
+
+ private static boolean restartRequired;
+ private static boolean tuscanyHookRunning;
+ static {
+ try {
+ tuscanyHookRunning = TuscanyLifecycleListener.isRunning();
+ } catch (Throwable e) {
+ tuscanyHookRunning = false;
+ }
+ }
+
+ public static boolean isTuscanyHookRunning() {
+ return tuscanyHookRunning;
+ }
+
+ public static boolean isRestartRequired() {
+ return restartRequired;
+ }
+
+ private File tuscanyWAR;
+ private File catalinaBase;
+ private String status = "";
+
+ public Installer(File tuscanyWAR, File catalinaBase) {
+ this.tuscanyWAR = tuscanyWAR;
+ this.catalinaBase = catalinaBase;
+ }
+
+ public static boolean isInstalled() {
+ return false;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public boolean install() {
+ try {
+
+ doInstall();
+ status = "Install successful, Tomcat restart required.";
+ restartRequired = true;
+ return true;
+
+ } catch (Throwable e) {
+ status = "Exception during install\n";
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(os);
+ e.printStackTrace(pw);
+ pw.close();
+ status += new String(os.toByteArray());
+ return false;
+ }
+ }
+
+ public boolean uninstall() {
+ try {
+
+ doUnintsall();
+ status = "Tuscany removed from server.xml, please restart Tomcat and manually remove Tuscany jars from Tomcat lib";
+ restartRequired = true;
+ return true;
+
+ } catch (Throwable e) {
+ status = "Exception during install";
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(os);
+ e.printStackTrace(pw);
+ status += "/n" + new String(os.toByteArray());
+ return false;
+ }
+ }
+
+ private void doUnintsall() {
+ File serverXml = new File(catalinaBase, "/conf/server.xml");
+ if (!(serverXml.exists())) {
+ throw new IllegalStateException("conf/server.xml not found: " + serverXml.getAbsolutePath());
+ }
+ removeServerXml(serverXml);
+ removeHostConfigXml(serverXml);
+ removeContextXml();
+ }
+
+ private boolean doInstall() {
+ // First verify all the file locations are as expected
+ if (!tuscanyWAR.exists()) {
+ throw new IllegalStateException("Tuscany war missing: " + tuscanyWAR.getAbsolutePath());
+ }
+ if (!catalinaBase.exists()) {
+ throw new IllegalStateException("Catalina base does not exist: " + catalinaBase.getAbsolutePath());
+ }
+ File serverLib = new File(catalinaBase, "/lib");
+ if (!(serverLib.exists())) {
+ // try Tomcat 5 server/lib
+ if (new File(catalinaBase, "/server").exists()) {
+ serverLib = new File(new File(catalinaBase, "/server"), "/lib");
+ }
+ }
+ if (!(serverLib.exists())) {
+ throw new IllegalStateException("Tomcat lib not found: " + serverLib.getAbsolutePath());
+ }
+ File serverXml = new File(catalinaBase, "/conf/server.xml");
+ if (!(serverXml.exists())) {
+ throw new IllegalStateException("conf/server.xml not found: " + serverXml.getAbsolutePath());
+ }
+
+ File tuscanyTomcatJar = findTuscanyTomcatJar(tuscanyWAR);
+ if (tuscanyTomcatJar == null || !tuscanyTomcatJar.exists()) {
+ throw new IllegalStateException("Can't find tuscany-tomcat-*.jar in: " + tuscanyWAR.getAbsolutePath());
+ }
+
+ // Copy tuscany-tomcat jar from the tuscany webapp web-inf/lib to Tomcat server/lib
+ copyFile(tuscanyTomcatJar, new File(serverLib, tuscanyTomcatJar.getName()));
+
+ // Add Tuscany LifecycleListener to Tomcat server.xml
+ updateServerXml(serverXml);
+
+ // Add Tuscany HostConfig to Hosts definitions in server.xml
+ updateHostConfigXml(serverXml);
+
+ // Add Tuscany specific default web.xml and context.xml definitions
+ addTuscanyWebXml();
+ addTuscanyContextXml();
+
+ return true;
+ }
+
+ private static final String tuscanyWebXML =
+ "\r\n\r\n" + " <!-- Tuscany Listener and Filter definitions -->\r\n" +
+ " <listener>\r\n" +
+ " <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>\r\n" +
+ " </listener>\r\n" +
+ "\r\n" +
+ " <filter>\r\n" +
+ " <filter-name>tuscany</filter-name>\r\n" +
+ " <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>\r\n" +
+ " </filter>\r\n" +
+ "\r\n" +
+ " <filter-mapping>\r\n" +
+ " <filter-name>tuscany</filter-name>\r\n" +
+ " <url-pattern>/*</url-pattern>\r\n" +
+ " </filter-mapping>";
+
+ private void addTuscanyWebXml() {
+ File tuscanyWebXmlFile = new File(catalinaBase, "/conf/tuscany-web.xml");
+ if (!(tuscanyWebXmlFile.exists())) {
+ File webXmlFile = new File(catalinaBase, "/conf/web.xml");
+ if (!(webXmlFile.exists())) {
+ throw new IllegalStateException("conf/web.xml not found: " + webXmlFile.getAbsolutePath());
+ }
+ String webXML = readAll(webXmlFile);
+ String newWebXml = replace(webXML, "<web-app", "<web-app", ">", ">" + tuscanyWebXML);
+ writeAll(tuscanyWebXmlFile, newWebXml);
+ }
+ }
+
+ private static final String tuscanyContextXML =
+ "\r\n\r\n <!-- The Tuscany SCA default domain URI.\r\n" +
+ " Individual contributions may used different domains by having their \r\n" +
+ " context.xml files overriding this parameter. -->\r\n" +
+ " <Parameter name=\"org.apache.tuscany.sca.defaultDomainURI\" value=\"default\"/>";
+
+ private void addTuscanyContextXml() {
+ File contextXmlFile = new File(catalinaBase, "/conf/context.xml");
+ if ((contextXmlFile.exists())) {
+ String contextXML = readAll(contextXmlFile);
+ String newcontextXml = replace(contextXML, "<Context>", "<Context>" + tuscanyContextXML, "<", "<");
+ backup(contextXmlFile);
+ writeAll(contextXmlFile, newcontextXml);
+ }
+ }
+ private void removeContextXml() {
+ File contextXmlFile = new File(catalinaBase, "/conf/context.xml");
+ if ((contextXmlFile.exists())) {
+ String contextXML = readAll(contextXmlFile);
+ String oldContextXml = replace(contextXML, "<Context>" + tuscanyContextXML, "<Context>", "<", "<");
+ writeAll(contextXmlFile, oldContextXml);
+ }
+ }
+
+ private File findTuscanyTomcatJar(File tuscanyWAR) {
+ File lib = new File(tuscanyWAR, "/tomcat-lib");
+ for (File f : lib.listFiles()) {
+ if (f.getName().startsWith("tuscany-tomcat-hook-") && f.getName().endsWith(".jar")) {
+ return f;
+ }
+ }
+ return null;
+ }
+
+ private static final String tuscanyListener =
+ "\r\n" + " <!-- Tuscany plugin for Tomcat -->\r\n"
+ + " <Listener className=\"org.apache.tuscany.sca.tomcat.TuscanyLifecycleListener\" />";
+
+ private void updateServerXml(File serverXmlFile) {
+ String serverXML = readAll(serverXmlFile);
+ if (!serverXML.contains(tuscanyListener)) {
+ String newServerXml = replace(serverXML, "<Server", "<Server", ">", ">" + tuscanyListener);
+ backup(serverXmlFile);
+ writeAll(serverXmlFile, newServerXml);
+ }
+ }
+
+ private void removeServerXml(File serverXmlFile) {
+ String serverXML = readAll(serverXmlFile);
+ if (serverXML.contains(tuscanyListener)) {
+ String newServerXml = replace(serverXML, "<Server", "<Server", ">" + tuscanyListener, ">");
+ writeAll(serverXmlFile, newServerXml);
+ }
+ }
+
+ static final String tuscanyHostConfig = " hostConfigClass=\"org.apache.tuscany.sca.tomcat.TuscanyHostConfig\" >";
+
+ private void updateHostConfigXml(File serverXmlFile) {
+ String serverXML = readAll(serverXmlFile);
+ String newServerXml = replace(serverXML, "<Host", "<Host", ">", tuscanyHostConfig);
+ backup(serverXmlFile);
+ writeAll(serverXmlFile, newServerXml);
+ }
+
+ private void removeHostConfigXml(File serverXmlFile) {
+ String serverXML = readAll(serverXmlFile);
+ if (serverXML.contains(tuscanyHostConfig)) {
+ String newServerXml = replace(serverXML, "<Host", "<Host", tuscanyHostConfig, ">");
+ writeAll(serverXmlFile, newServerXml);
+ }
+ }
+
+ private String replace(String inputText, String begin, String newBegin, String end, String newEnd) {
+ BeginEndTokenHandler tokenHandler = new BeginEndTokenHandler(newBegin, newEnd);
+
+ ByteArrayInputStream in = new ByteArrayInputStream(inputText.getBytes());
+
+ InputStream replacementStream = new DelimitedTokenReplacementInputStream(in, begin, end, tokenHandler, true);
+ String newServerXml = readAll(replacementStream);
+ close(replacementStream);
+ return newServerXml;
+ }
+
+ private boolean backup(File source) {
+ File backupFile = new File(source.getParent(), source.getName() + ".b4Tuscany");
+ if (!backupFile.exists()) {
+ copyFile(source, backupFile);
+ }
+ return true;
+ }
+
+ private String readAll(File file) {
+ FileInputStream in = null;
+ try {
+ in = new FileInputStream(file);
+ String text = readAll(in);
+ return text;
+ } catch (Exception e) {
+ return null;
+ } finally {
+ close(in);
+ }
+ }
+
+ private String readAll(InputStream in) {
+ try {
+ // SwizzleStream block read methods are broken so read byte at a time
+ StringBuilder sb = new StringBuilder();
+ int i = in.read();
+ while (i != -1) {
+ sb.append((char)i);
+ i = in.read();
+ }
+ return sb.toString();
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void copyFile(File source, File destination) {
+ InputStream in = null;
+ OutputStream out = null;
+ try {
+ in = new FileInputStream(source);
+ out = new FileOutputStream(destination);
+ writeAll(in, out);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ } finally {
+ close(in);
+ close(out);
+ }
+ }
+
+ private boolean writeAll(File file, String text) {
+ FileOutputStream fileOutputStream = null;
+ try {
+ fileOutputStream = new FileOutputStream(file);
+ writeAll(new ByteArrayInputStream(text.getBytes()), fileOutputStream);
+ return true;
+ } catch (Exception e) {
+ return false;
+ } finally {
+ close(fileOutputStream);
+ }
+ }
+
+ private void writeAll(InputStream in, OutputStream out) throws IOException {
+ byte[] buffer = new byte[4096];
+ int count;
+ while ((count = in.read(buffer)) > 0) {
+ out.write(buffer, 0, count);
+ }
+ out.flush();
+ }
+
+ private void close(Closeable thing) {
+ if (thing != null) {
+ try {
+ thing.close();
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ private class BeginEndTokenHandler extends StringTokenHandler {
+ private final String begin;
+ private final String end;
+
+ public BeginEndTokenHandler(String begin, String end) {
+ this.begin = begin;
+ this.end = end;
+ }
+
+ public String handleToken(String token) throws IOException {
+ String result = begin + token + end;
+ return result;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java
new file mode 100644
index 0000000000..efcc2711f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.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.war;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class InstallerServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ private transient ServletConfig servletConfig;
+ private transient Installer installer;
+
+ public void init(ServletConfig servletConfig) throws ServletException {
+ this.servletConfig = servletConfig;
+ String path = servletConfig.getServletContext().getRealPath("/");
+ File tuscanyWarDir = null;
+ if (path != null) {
+ tuscanyWarDir = new File(path);
+ }
+ File tomcatBase = new File(System.getProperty("catalina.base"));
+ installer = new Installer(tuscanyWarDir, tomcatBase);
+ }
+
+ protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
+ doIt(httpServletRequest, httpServletResponse);
+ }
+
+ protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
+ doIt(httpServletRequest, httpServletResponse);
+ }
+
+ protected void doIt(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
+
+ if ("Install".equalsIgnoreCase(req.getParameter("action"))) {
+ installer.install();
+ } else if ("Uninstall".equalsIgnoreCase(req.getParameter("action"))) {
+ installer.uninstall();
+ }
+
+ req.setAttribute("installer", installer);
+ RequestDispatcher rd = servletConfig.getServletContext().getRequestDispatcher("/installer.jsp");
+ rd.forward(req,res);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/pom.xml b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/pom.xml
new file mode 100644
index 0000000000..e0bc900c6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/pom.xml
@@ -0,0 +1,106 @@
+<?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-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-war</artifactId>
+ <name>Apache Tuscany SCA Tomcat Deep Integration WAR</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.swizzle</groupId>
+ <artifactId>swizzle-stream</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-tomcat-servlet</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-tomcat-hook</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-webservices</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ </dependency>
+-->
+
+ </dependencies>
+
+ <build>
+ <finalName>tuscany</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-5</version>
+ <executions>
+ <execution>
+ <id>war</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>true</attach>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/assembly/war.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/assembly/war.xml b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/assembly/war.xml
new file mode 100644
index 0000000000..5c6dff5915
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/assembly/war.xml
@@ -0,0 +1,98 @@
+<?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.
+-->
+<assembly>
+ <id>war</id>
+ <formats>
+ <format>war</format>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>${basedir}</directory>
+ <includes>
+ <include>README.txt</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${basedir}/target/classes</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>README.txt</include>
+ <include>NOTICE.txt</include>
+ <include>LICENSE.txt</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${basedir}/src/main/webapp</directory>
+ <outputDirectory>/</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>${basedir}/target/classes</directory>
+ <outputDirectory>/</outputDirectory>
+ <excludes>
+ <exclude>org/**</exclude>
+ <exclude>META-INF/LICENSE</exclude>
+ <exclude>META-INF/NOTICE</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>${basedir}/target/classes</directory>
+ <outputDirectory>WEB-INF/classes</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>${basedir}/target</directory>
+ <outputDirectory>lib</outputDirectory>
+ <includes>
+ <include>tuscany-host*.jar</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>tuscany-lib</outputDirectory>
+ <scope>runtime</scope>
+ <excludes>
+ <exclude>org.apache.tomcat:catalina</exclude>
+ <exclude>org.apache.tomcat:annotations-api</exclude>
+ <exclude>org.apache.tomcat:juli</exclude>
+ <exclude>org.apache.tomcat:servlet-api</exclude>
+ <exclude>org.apache.tuscany.sca:tuscany-tomcat-hook</exclude>
+ <exclude>org.apache.tuscany.sca:tuscany-tomcat-servlet</exclude>
+ <exclude>org.codehaus.swizzle:swizzle-stream</exclude>
+ </excludes>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>tomcat-lib</outputDirectory>
+ <scope>runtime</scope>
+ <includes>
+ <include>org.apache.tuscany.sca:tuscany-tomcat-hook</include>
+ </includes>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>WEB-INF/lib</outputDirectory>
+ <scope>runtime</scope>
+ <includes>
+ <include>org.apache.tuscany.sca:tuscany-tomcat-servlet</include>
+ <include>org.codehaus.swizzle:swizzle-stream</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+</assembly>
+
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE
new file mode 100644
index 0000000000..f4f88da9ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE
@@ -0,0 +1,442 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+===============================================================================
+
+APACHE TUSCANY SUBCOMPONENTS:
+
+The Apache Tuscany binary distribution includes a number of subcomponents
+with separate copyright notices and license terms. Your use of the
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+The following components come under Apache Software License 2.0
+
+ cglib-2.2.jar
+ hazelcast-1.8.3.jar
+ hazelcast-client-1.8.3.jar
+ swizzle-stream-1.0.2.jar
+ XmlSchema-1.4.3.jar
+
+===============================================================================
+
+WSDL4j (wsdl4j-1.6.2.jar):
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+===============================================================================
+
+The asm-3.1.jar are distributed under the license:
+
+Copyright (c) 2000-2005 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
+================================================================================
+
+The tuscany-base jar includes XSD files under the following SCA Collaboration license:
+
+License for the Service Component Architecture JavaDoc, Interface
+Definition files and XSD files.
+
+The Service Component Architecture JavaDoc, Interface Definition files,
+and XSD files are being provided by the copyright holders under the
+following license. By using and/or copying this work, you agree that
+you have read, understood and will comply with the following terms and
+conditions:
+
+Permission to copy, display, make derivative works of, and distribute
+the Service Component Architecture JavaDoc, Interface Definition Files
+and XSD files (the "Artifacts") in any medium without fee or royalty is
+hereby granted, provided that you include the following on ALL copies
+of the Artifacts, or portions thereof, that you make:
+
+1. A link or URL to the Artifacts at this location:
+http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of this copyright notice as shown in the Artifacts.
+
+THE ARTIFACTS ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO
+REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THE
+ARTIFACTS AND THE IMPLEMENTATION OF THEIR CONTENTS, INCLUDING, BUT NOT
+LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE, NON-INFRINGEMENT OR TITLE.
+
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY
+USE OR DISTRIBUTION OF THE ARTIFACTS.
+
+The name and trademarks of the Authors may NOT be used in any manner,
+including advertising or publicity pertaining to the Service Component
+Architecture Specification or its contents without specific, written
+prior permission. Title to copyright in the Service Component
+Architecture Specification and the JavaDoc, Interface Definition Files
+and XSD Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+Revision level 1.1, last updated on 2007/11/19
+
+
+================================================================================
+
+The tuscany-base jar includes XSD files under the following OASIS license:
+
+All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual
+Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
+This document and translations of it may be copied and furnished to others, and derivative works that
+comment on or otherwise explain it or assist in its implementation may be prepared, copied, published,
+and distributed, in whole or in part, without restriction of any kind, provided that the above copyright
+notice and this section are included on all such copies and derivative works. However, this document
+itself may not be modified in any way, including by removing the copyright notice or references to OASIS,
+except as needed for the purpose of developing any document or deliverable produced by an OASIS
+Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR
+Policy, must be followed) or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors
+or assigns.
+This document and the information contained herein is provided on an "AS IS" basis and OASIS
+DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
+WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP
+RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.
+OASIS requests that any OASIS Party or any other party that believes it has patent claims that would
+necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard,
+to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to
+such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that
+produced this specification.
+OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of
+any patent claims that would necessarily be infringed by implementations of this specification by a patent
+holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR
+Mode of the OASIS Technical Committee that produced this specification. OASIS may include such
+claims on its website, but disclaims any obligation to do so.
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that
+might be claimed to pertain to the implementation or use of the technology described in this document or
+the extent to which any license under such rights might or might not be available; neither does it represent
+that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to
+rights in any document or deliverable produced by an OASIS Technical Committee can be found on the
+OASIS website. Copies of claims of rights made available for publication and any assurances of licenses
+to be made available, or the result of an attempt made to obtain a general license or permission for the use
+of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS
+Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any
+information or list of intellectual property rights will at any time be complete, or that any claims in such list
+are, in fact, Essential Claims.
+The names "OASIS", are trademarks of OASIS, the owner and developer of this specification, and should
+be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and
+implementation and use of, specifications, while reserving the right to enforce its marks against misleading
+uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance.
+
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE
new file mode 100644
index 0000000000..cdc221ee60
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE
@@ -0,0 +1,79 @@
+Apache Tuscany
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes/uses the Axion : the Open Source Java Database (http://axion.tigris.org/)
+ Copyright (c) 2002-2003 Axion Development Team. All rights reserved.
+
+This product includes/uses XmlSchema developed at
+The Apache Software Foundation (http://ws.apache.org/commons/XmlSchema)
+ Portions Copyright 2006 International Business Machines Corp.
+
+This product includes/uses the Jetty Servlet Engine (http://jetty.mortbay.org),
+developed by Mort Bay Consulting (http://www.mortbay.com)
+
+This product includes/uses DOM4J : the flexible XML framework for java (http://www.dom4j.org/)
+ Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
+
+This product includes/uses software, AOP alliance (http://aopalliance.sourceforge.net)
+License: Public Domain
+
+This product includes/uses javacc (https://javacc.dev.java.net/)
+ Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+
+This product includes software from the GlassFish project (https://glassfish.dev.java.net/)
+ Copyright (c) 2006, Sun Microsystems, Inc.
+
+This product includes/uses the Sourceforge wsdl4j project (http://sourceforge.net/projects/wsdl4j/)
+
+This product includes/uses JDOM (http://www.jdom.org/)
+ Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. All rights reserved.
+
+This product includes/uses javacc (https://javacc.dev.java.net/)
+ Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+
+This product includes/uses ASM (http://asm.objectweb.org)
+ Copyright (c) 2000-2005 INRIA, France Telecom. All rights reserved.
+
+This product includes/uses Jaxen (http://jaxen.codehaus.org/)
+ Copyright 2003-2006 The Werken Company. All Rights Reserved.
+
+This product includes/uses Serp (http://serp.sourceforge.net/) under the BSD license:
+ Copyright (c) 2002, A. Abram White. All rights reserved.
+
+This product also includes software under the BSD license
+with the following copyright:
+ Copyright (c) 2006, Sun Microsystems, Inc. All rights reserved.
+
+The Program includes all or portions of the following software: "The
+Saxon XSLT and XQuery Processor from Saxonica Limited" distributed under
+an MPL v1.0 license. Please refer to the homepage URL at
+http://www.saxonica.com/.
+
+This product includes/uses Serp (http://serp.sourceforge.net/) under the BSD license:
+ Copyright (c) 2002, A. Abram White. All rights reserved.
+
+This product also includes "OSGi Materials."
+ Copyright (c) 2000, 2006
+ OSGi Alliance Bishop Ranch 6
+ 2400 Camino Ramon, Suite 375
+ San Ramon, CA 94583 USA
+ All Rights Reserved.
+
+This product includes software under the Service Component Architecture JavaDoc,
+Interface Definition files and XSD files license.
+ (c) Copyright SCA Collaboration 2006, 2007
+
+This product includes software under the Service Data Objects JavaDoc and
+Interface Definition file license
+
+(c) Copyright BEA Systems, Inc., International Business Machines Corporation,
+Oracle Corporation, Primeton Technologies Ltd., Rogue Wave Software, SAP AG.,
+Software AG., Sun Microsystems, Sybase Inc., Xcalia, Zend Technologies,
+2005, 2006. All rights reserved.
+
+This product includes software under the OASIS license
+Copyright (C) OASIS(R) 2005, 2009. All Rights Reserved.
+
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..e6c3d23e9e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT 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 Installer Application</display-name>
+
+ <servlet>
+ <servlet-name>InstallerServlet</servlet-name>
+ <servlet-class>org.apache.tuscany.sca.war.InstallerServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>InstallerServlet</servlet-name>
+ <url-pattern>/installer</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>installer.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp
new file mode 100644
index 0000000000..68fd5101b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp
@@ -0,0 +1,106 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ page import="org.apache.tuscany.sca.war.Installer" %>
+
+<%
+ Installer installer = (Installer) request.getAttribute("installer");
+%>
+
+<html>
+ <body >
+
+ <h2>Apache Tuscany Tomcat Integration</h2>
+
+ The Tuscany Tomcat integration turns Tomcat into an SCA enabled runtime so it can run SCA contributions and SCA-enabled Web Applications.
+ <p>
+
+ Status: Tuscany is <B>
+ <% if (Installer.isTuscanyHookRunning()) { %>
+ installed and active
+ <% } else if (Installer.isRestartRequired()) {%>
+ installed but Tomcat needs to be restarted
+ <% } else {%>
+ not installed
+ <% }%>
+ </B>
+ in Tomcat.
+ <p>
+
+ <% if (!Installer.isTuscanyHookRunning() && !Installer.isRestartRequired()) { %>
+ <B>Install Tuscany</B><BR>
+ To install Tuscany into Tomcat, click:
+ <form action='installer' method='post'>
+ <input type='submit' name='action' value='Install'>
+ </form>
+ <BR>
+ <% } else {%>
+ <B>Uninstall Tuscany</B><BR>
+ If remove Tuscany from Tomcat, click:
+ <form action='installer' method='post'>
+ <input type='submit' name='action' value='Uninstall'>
+ </form>
+ <BR>
+ <% }%>
+
+ <p>
+ <BR>
+
+ <B>
+ <% if (installer != null) { %>
+ <%= installer.getStatus() %>
+ <% }%>
+ </B>
+
+
+ <p>
+ <h2>What does this do?</h2>
+
+ This Tuscany install makes two updates to Tomcat:
+ <UL>
+ <LI>copies the jars from the tomcat-lib directory in this webapp into the Tomcat lib directory
+ <LI>updates the Tomcat conf/server.xml to include a &lt;Listener&gt; definition for Tuscany
+ </UL>
+ Those changes cause the Tuscany listener to be called at Tomcat startup and that locates all the Host
+ defiinitions and patches them to use the TuscanyStandardContext. This enables support for deploying
+ SCA enabled webapps and plain SCA jar, zip, or folder contributions to the Host in the same way
+ that .war files are deployed.
+ <p>
+ The SCA domain used for running the contributions defaults to "vm:default". This can be configured
+ by using an initilization parameter, most easiliy by defining that parameter in a context.xml file.
+ The Tomcat file conf/context.xml file defines the global defaults so that can be used for setting the
+ deafult domain for all SCA contributions. Individual contributions can also use their own context.xml
+ files to override that default.
+ See the <a href="http://tomcat.apache.org/tomcat-6.0-doc/config/context.html">Tomcat doc</a> for more information on using context.xml files.
+ <p>
+ An example of setting the domain as a context.xml parameter:
+ <br>&lt;Context&gt;
+ <br>. . .
+ <br>&lt;Parameter name="org.apache.tuscany.sca.defaultDomainURI" value="tribes:myDomain"/&gt;
+ <br>. . .
+ <br>&lt;/Context&gt;
+ <p>
+ For more information visit the Tuscany website page on <a href="http://tuscany.apache.org/tuscany-tomcat-distribution.html">Tomcat Integration</a>.
+ <p>
+ Note also that this is work in progress so is liable to change as Tuscany 2.0 is developed. Feedback is welcome and appreciated so if you've any comments or requests on this Tomcat integration please email <href="mailto:dev@tuscany.apache.org">dev@tuscany.apache.org</a>.
+ <p>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/features/all/pom.xml b/sandbox/sebastien/java/embed/features/all/pom.xml
new file mode 100644
index 0000000000..994023c63a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/all/pom.xml
@@ -0,0 +1,112 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-all</artifactId>
+ <name>Apache Tuscany SCA All-in-one Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-osgi</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-sdo</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webapp</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-process</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-launcher</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-tracing-aspectj</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/api/pom.xml b/sandbox/sebastien/java/embed/features/api/pom.xml
new file mode 100644
index 0000000000..465829ca75
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/api/pom.xml
@@ -0,0 +1,58 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-api</artifactId>
+ <name>Apache Tuscany SCA API Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <!-- SCA API -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Data Collection API -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Node API -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/binding-ws/pom.xml b/sandbox/sebastien/java/embed/features/binding-ws/pom.xml
new file mode 100644
index 0000000000..1510dc454b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/binding-ws/pom.xml
@@ -0,0 +1,107 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-binding-ws</artifactId>
+ <name>Apache Tuscany SCA binding.ws Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>addressing</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-xmlbeans</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb-codegen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>bouncycastle</groupId>
+ <artifactId>bcprov-jdk15</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>opensaml</groupId>
+ <artifactId>opensaml</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/core/pom.xml b/sandbox/sebastien/java/embed/features/core/pom.xml
new file mode 100644
index 0000000000..79285e4805
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/core/pom.xml
@@ -0,0 +1,242 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-core</artifactId>
+ <name>Apache Tuscany SCA Core Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- SCA API -->
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+-->
+
+ <!-- Assembly model -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-corba-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency-->
+
+ <!-- Contribution model -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Core runtime -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Data API -->
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency-->
+
+ <!-- Core Extensibility -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency-->
+ <!-- host-http is required by tuscany-implementation-node-runtime -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Implementation types -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Interface models -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Node runtime -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>war</type>
+ </dependency>
+ -->
+
+ <!-- Monitoring -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Policy models -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security-jsr250</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency-->
+
+ <!-- XMLSchema support -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-shell</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/ejava/pom.xml b/sandbox/sebastien/java/embed/features/ejava/pom.xml
new file mode 100644
index 0000000000..970d2e759c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/ejava/pom.xml
@@ -0,0 +1,177 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <name>Apache Tuscany SCA Enterprise Java Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ejb-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+-->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-corba-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jee</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse-tns</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+
+ <!-- Implementations -->
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-ejb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+-->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- OSGi Remote Services SCA Configuration Type -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-jaxrs-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Policies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-transaction</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-transaction-runtime-geronimo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Hazelcast registry -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/osgi/pom.xml b/sandbox/sebastien/java/embed/features/osgi/pom.xml
new file mode 100644
index 0000000000..429b8c626d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/osgi/pom.xml
@@ -0,0 +1,109 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-osgi</artifactId>
+ <name>Apache Tuscany SCA OSGi Remote Services Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- WebService -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Implementations -->
+
+ <!-- OSGi Remote Services -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Policies -->
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-transaction</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+-->
+ </dependencies>
+
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/pom.xml b/sandbox/sebastien/java/embed/features/pom.xml
new file mode 100644
index 0000000000..f1dca26a14
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/pom.xml
@@ -0,0 +1,51 @@
+<?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>
+ <relativePath>../pom.xml</relativePath>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Features</name>
+
+ <modules>
+ <module>all</module>
+ <module>api</module>
+ <module>core</module>
+ <module>ejava</module>
+ <module>osgi</module>
+ <module>process</module>
+ <module>webservice</module>
+ <module>web20</module>
+ <module>webapp</module>
+ <module>sdo</module>
+<!--
+ <module>manager</module>
+ <module>repository</module>
+-->
+ <module>binding-ws</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/process/pom.xml b/sandbox/sebastien/java/embed/features/process/pom.xml
new file mode 100644
index 0000000000..644f55de85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/process/pom.xml
@@ -0,0 +1,57 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-process</artifactId>
+ <name>Apache Tuscany SCA Process Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- ODE BPEL -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/sdo/pom.xml b/sandbox/sebastien/java/embed/features/sdo/pom.xml
new file mode 100644
index 0000000000..843608e508
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/sdo/pom.xml
@@ -0,0 +1,58 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-sdo</artifactId>
+ <name>Apache Tuscany SCA SDO Databinding Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+
+ <!-- Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/web20/pom.xml b/sandbox/sebastien/java/embed/features/web20/pom.xml
new file mode 100644
index 0000000000..d1be8d99ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/web20/pom.xml
@@ -0,0 +1,145 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-web20</artifactId>
+ <name>Apache Tuscany SCA Web 2.0 Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Common -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Interface models -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxrs</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Implementation Types -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-widget-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-widget-runtime-dojo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-atom-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-atom-js-dojo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rest-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-js-dojo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rss-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Dojo and Dojo Extensions -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-web-javascript-dojo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!--Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/features/webapp/pom.xml b/sandbox/sebastien/java/embed/features/webapp/pom.xml
new file mode 100644
index 0000000000..bc87efd412
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/webapp/pom.xml
@@ -0,0 +1,96 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-webapp</artifactId>
+ <name>Apache Tuscany SCA WebApp Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Explicitly list the servlet/jsp apis as "provided" dependencies are not transitive -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jsp_2.1_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-el_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-stripes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-myfaces</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- JSONP Binding material -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <!-- end of JSONP Binding -->
+
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/features/webservice/pom.xml b/sandbox/sebastien/java/embed/features/webservice/pom.xml
new file mode 100644
index 0000000000..0a169ac8a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/features/webservice/pom.xml
@@ -0,0 +1,107 @@
+<?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-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <name>Apache Tuscany SCA Web Service Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>addressing</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-xmlbeans</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb-codegen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>bouncycastle</groupId>
+ <artifactId>bcprov-jdk15</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>opensaml</groupId>
+ <artifactId>opensaml</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/T3558/pom.xml b/sandbox/sebastien/java/embed/itest/T3558/pom.xml
new file mode 100644
index 0000000000..5940901bf7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/T3558/pom.xml
@@ -0,0 +1,45 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-t3558</artifactId>
+ <name>Apache Tuscany SCA iTest T3558</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/T3558/src/test/java/org/apache/tuscany/sca/itest/t3558/T3558TestCase.java b/sandbox/sebastien/java/embed/itest/T3558/src/test/java/org/apache/tuscany/sca/itest/t3558/T3558TestCase.java
new file mode 100644
index 0000000000..5bb860ef89
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/T3558/src/test/java/org/apache/tuscany/sca/itest/t3558/T3558TestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.t3558;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Test;
+
+public class T3558TestCase {
+
+ @Test
+ public void testAllJar() throws Exception {
+ Node node = NodeFactory.newInstance().createNode((String)null, new String[]{"src/test/resources/sample-store-all.jar"});
+ node.start();
+ }
+
+ @Test
+ public void testOneNode() throws Exception {
+ Node node = NodeFactory.newInstance().createNode((String)null, new String[]{"src/test/resources/sample-store.jar","src/test/resources/sample-store-client.jar"});
+ node.start();
+ }
+
+ @Test
+ public void testTwoNodes() throws Exception {
+ Node node2 = NodeFactory.newInstance().createNode((String)null, new String[]{"src/test/resources/sample-store.jar"});
+ node2.start();
+ Node node1 = NodeFactory.newInstance().createNode((String)null, new String[]{"src/test/resources/sample-store-client.jar"});
+ node1.start();
+ }
+
+ @Test
+ public void testTwoNodesJIRACode1() throws Exception {
+ String storeLocation = "src/test/resources/sample-store.jar";
+ String storeClientLocation = "src/test/resources/sample-store-client.jar";
+
+ Node node1 = NodeFactory.newInstance().createNode(new Contribution("store",storeLocation));
+ node1.start();
+ // The dependent contributions need to be added in the Node and need to be following the main contribution
+ Node node2 = NodeFactory.newInstance().createNode("store-client.composite",new Contribution("storeClient", storeClientLocation),new Contribution("store", storeLocation));
+ node2.start();
+ }
+
+ @Test
+ public void testTwoNodesJIRACode2() throws Exception {
+ String storeLocation = "src/test/resources/sample-store.jar";
+ String storeClientLocation = "src/test/resources/sample-store-client.jar";
+
+ Node node1 = NodeFactory.newInstance().createNode(new Contribution("store",storeLocation));
+ node1.start();
+
+ Node node2 = NodeFactory.newInstance().createNode("store-client.composite",new Contribution("storeClient", storeClientLocation));
+ node2.start();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store-all.jar b/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store-all.jar
new file mode 100644
index 0000000000..6f3649ff23
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store-all.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store-client.jar b/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store-client.jar
new file mode 100644
index 0000000000..5dfecda310
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store-client.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store.jar b/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store.jar
new file mode 100644
index 0000000000..98e1f6ebb4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/T3558/src/test/resources/sample-store.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/base/dependencies/pom.xml b/sandbox/sebastien/java/embed/itest/base/dependencies/pom.xml
new file mode 100644
index 0000000000..ad407a10f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/base/dependencies/pom.xml
@@ -0,0 +1,59 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-base-dependencies</artifactId>
+ <name>Apache Tuscany SCA iTest Base Dependencies</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Copy all the dependencies so the test can verify only the expected ones get dragged in -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/base/dependencies/src/test/java/org/apache/tuscany/sca/itest/base/dependencies/ValidateDependenciesTestCase.java b/sandbox/sebastien/java/embed/itest/base/dependencies/src/test/java/org/apache/tuscany/sca/itest/base/dependencies/ValidateDependenciesTestCase.java
new file mode 100644
index 0000000000..e9691cb3fe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/base/dependencies/src/test/java/org/apache/tuscany/sca/itest/base/dependencies/ValidateDependenciesTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.base.dependencies;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+/**
+ * Test case for verifying the expected dependencies of the base jar
+ * (Uses maven-dependency-plugin config in the pom.xml to generate the dependency list)
+ *
+ * *** NOTE: this is an API! If the dependencies change the API is changed and users will be broken.
+ * Don't just change the list without thinking about the consequencies
+ *
+ * Current required jars are:
+ * asm-3.1.jar
+ * cglib-2.2.jar
+ * hazelcast-1.8.3.jar
+ * hazelcast-client-1.8.3.jar
+ * tuscany-base-2.0-SNAPSHOT.jar
+ * wsdl4j-1.6.2.jar
+ * XmlSchema-1.4.3.jar
+ *
+ * junit-4.8.1.jar (only from this testcase)
+ *
+ */
+public class ValidateDependenciesTestCase {
+
+ @Test
+ public void countDependencies() {
+
+ File dependenciesDir = new File("target/dependency");
+ Assert.assertTrue(dependenciesDir.exists());
+
+ File[] dependencyFiles = dependenciesDir.listFiles();
+ Assert.assertEquals(8, dependencyFiles.length);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/base/pom.xml b/sandbox/sebastien/java/embed/itest/base/pom.xml
new file mode 100644
index 0000000000..930f119cd9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/base/pom.xml
@@ -0,0 +1,36 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-base</artifactId>
+ <name>Apache Tuscany SCA iTest Base</name>
+
+ <modules>
+ <module>dependencies</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/pom.xml b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/pom.xml
new file mode 100644
index 0000000000..75856a4c74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/pom.xml
@@ -0,0 +1,286 @@
+<?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>itest-bpel</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bpel-helloworld-reference</artifactId>
+ <name>Apache Tuscany SCA iTest BPEL HelloWorld Reference</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-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby</artifactId>
+ <version>1.1</version>
+ <type>zip</type>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!-- http://jira.codehaus.org/browse/SUREFIRE-322 -->
+ <version>2.3.1</version>
+ <configuration>
+ <useFile>false</useFile>
+ <trimStackTrace>false</trimStackTrace>
+ <useSystemClassLoader>true</useSystemClassLoader>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby</artifactId>
+ <version>1.1</version>
+ <type>zip</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/test-classes/</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!--
+ Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsimport</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.implementation.bpel.example.helloworld</packageName>
+ <wsdlDirectory>${basedir}/src/test/resources/helloworld/</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld.wsdl</wsdlFile>
+ </wsdlFiles>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <verbose>false</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </execution>
+
+ <!--
+ <execution>
+ <id>wsgen</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>wsgen-test</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.interfacedef.java.jaxws.MyServiceImpl</sei>
+ <genWsdl>true</genWsdl>
+ <keep>true</keep>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ </configuration>
+ </execution>
+ -->
+ </executions>
+
+ </plugin>
+
+ <!--
+ wsimport cannot handle WSDL files without a service/binding element.
+ CXF wsdl2java plugin does support that. I had to override the default
+ value of wsdlRoot/testWsdlRoot to a non-existent file to avoid NPE -->
+ <!--
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+
+ <configuration>
+ <sourceRoot>${basedir}/target/jaxws-source</sourceRoot>
+ <wsdlRoot>NONE</wsdlRoot>
+ <testWsdlRoot>NONE</testWsdlRoot>
+ <wsdlOptions>
+ <wsdlOption>
+ <wsdl>${basedir}/src/test/resources/wsdl/Stock.wsdl</wsdl>
+ <outputDir>${basedir}/target/jaxws-source</outputDir>
+ <packagenames>
+ <packagename>com.example.stock.cxf</packagename>
+ </packagenames>
+ </wsdlOption>
+ </wsdlOptions>
+ </configuration>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java
new file mode 100644
index 0000000000..d7dff093f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.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 greetings;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface GreetingsService {
+
+ public String getGreetings(String name);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java
new file mode 100644
index 0000000000..5ecf5494be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.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 greetings;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(GreetingsService.class)
+public class GreetingsServiceImpl implements GreetingsService {
+
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java
new file mode 100644
index 0000000000..24ab0a4181
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.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 greetings;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests the Greetings service
+ *
+ * @version $Rev$ $Date$
+ */
+public class GreetingsTestCase {
+
+ private static Node node;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("greetings/greetings.composite");
+ node = NodeFactory.newInstance().createNode("greetings/greetings.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testInvoke() {
+ GreetingsService greetingsService = node.getService(GreetingsService.class, "GreetingsServiceComponent");
+ String response = greetingsService.getGreetings("Luciano");
+ Assert.assertEquals("Hello Luciano", response);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..f46893481b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the helloworld service
+ */
+@Remotable
+public interface HelloWorldService {
+ public String hello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..a687534bb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.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 helloworld;
+
+import greetings.GreetingsService;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * The HelloWorld service implementation
+ */
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ protected GreetingsService greetingsService;
+
+ public GreetingsService getGreetingsService() {
+ System.out.println("Got Injected greetingsService");
+ return greetingsService;
+ }
+
+ @Reference
+ public void setGreetingsService(GreetingsService greetingsService) {
+ System.out.println("Injected greetingsService");
+ this.greetingsService = greetingsService;
+ }
+
+ public String hello(String name) {
+ System.out.println("Calling greeting services getGreetings");
+ return greetingsService.getGreetings(name);
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..a9268ac1b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests the BPEL Helloworld Service
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldTestCase {
+ private static Node node;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("helloworld/helloworld.composite");
+ node = NodeFactory.newInstance().createNode("helloworld/helloworld.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testServiceInvocation() {
+ HelloWorldService bpelService = node.getService(HelloWorldService.class, "HelloWorldService");
+ String response = bpelService.hello("Luciano");
+ Assert.assertEquals("Hello Luciano", response);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite
new file mode 100644
index 0000000000..d3cfb80547
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://greetings"
+ xmlns:hw="http://greetings"
+ name="greetings">
+
+ <component name="GreetingsServiceComponent">
+ <implementation.java class="greetings.GreetingsServiceImpl" />
+ <service name="GreetingsService">
+ <interface.wsdl interface="http://greetings#wsdl.interface(Greetings)" />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl
new file mode 100644
index 0000000000..b976a53970
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl
@@ -0,0 +1,87 @@
+<?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 name="greetings"
+ targetNamespace="http://greetings"
+ xmlns:tns="http://greetings"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://greetings" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="greetings">
+ <complexType>
+ <sequence>
+ <element name="greetings" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="greetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="greetingsResponse" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="GreetingsRequest">
+ <wsdl:part element="tns:greetings" name="request"/>
+ </wsdl:message>
+
+ <wsdl:message name="GreetingsResponse">
+ <wsdl:part element="tns:greetingsResponse" name="response"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greetings">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:GreetingsRequest" name="GreetingsRequest"/>
+ <wsdl:output message="tns:GreetingsResponse" name="GreetingsResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="GreetingsSoapBinding" type="tns:Greetings">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="GreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="GreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="GreetingsService">
+ <wsdl:port name="GreetingsSoapPort" binding="tns:GreetingsSoapBinding">
+ <wsdlsoap:address location="http://localhost:8085/ode/processes/greetings"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="GreetingsPartnerLinkType">
+ <plnk:role name="Provider" portType="tns:Greetings"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..c0317687df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel
@@ -0,0 +1,84 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://helloworld"
+ xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:tns="http://helloworld"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:helloworld="http://helloworld"
+ xmlns:greetings="http://greetings"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0" xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+
+ <import location="helloworld.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://helloworld"/>
+
+ <import location="../greetings/greetings.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://greetings"/>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink" partnerLinkType="helloworld:HelloPartnerLinkType" myRole="me" />
+ <partnerLink name="greetingsPartnerLink" partnerLinkType="greetings:GreetingsPartnerLinkType" partnerRole="Provider" initializePartnerRole="yes" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="helloMessage" messageType="helloworld:HelloMessage"/>
+ <variable name="helloMessageResponse" messageType="helloworld:HelloMessageResponse"/>
+ <variable name="greetingsRequest" messageType="greetings:GreetingsRequest"/>
+ <variable name="greetingsResponse" messageType="greetings:GreetingsResponse"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ createInstance="yes"
+ operation="hello"
+ variable="helloMessage"
+ partnerLink="helloPartnerLink"
+ portType="helloworld:HelloWorld" />
+
+ <assign name="assignToGreetingsRequest">
+ <copy>
+ <from>$helloMessage.TestPart</from>
+ <to>$greetingsRequest.request</to>
+ </copy>
+ </assign>
+
+ <invoke name="invokeGreetings"
+ operation="getGreetings"
+ inputVariable="greetingsRequest"
+ outputVariable="greetingsResponse"
+ partnerLink="greetingsPartnerLink"
+ portType="greetings:Greetings" />
+
+ <assign name="assignToHelloResponse">
+ <copy>
+ <from>$greetingsResponse.parameters/greetings:GreetingsResponse</from>
+ <to>$helloMessageResponse.TestPart</to>
+ </copy>
+ </assign>
+
+ <reply name="end"
+ operation="hello"
+ partnerLink="helloPartnerLink"
+ portType="helloworld:HelloWorld"
+ variable="helloMessageResponse"/>
+ </sequence>
+</process>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite
new file mode 100644
index 0000000000..ef66d28bb9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://bpel"
+ xmlns:hns="http://helloworld"
+ name="helloworld">
+
+ <component name="HelloWorldService">
+ <implementation.bpel process="hns:HelloWorld"/>
+ <reference name="greetingsPartnerLink" target="GreetingsServiceComponent"/>
+ </component>
+
+ <component name="GreetingsServiceComponent">
+ <implementation.java class="greetings.GreetingsServiceImpl" />
+ <service name="GreetingsService">
+ <interface.wsdl interface="http://greetings#wsdl.interface(Greetings)" />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..541a713112
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl
@@ -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.
+ -->
+
+<wsdl:definitions name="helloworld"
+ targetNamespace="http://helloworld"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ 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"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://helloworld"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="message" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="helloResponse">
+ <complexType>
+ <sequence>
+ <element name="messageResponse" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part element="tns:hello" name="TestPart"/>
+ </wsdl:message>
+
+ <wsdl:message name="HelloMessageResponse">
+ <wsdl:part element="tns:helloResponse" name="TestResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessageResponse" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="TestIn">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="TestOut">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port name="HelloSoapPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8085/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloWorld"/>
+ <plnk:role name="you" portType="tns:HelloWorld"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/log4j.properties b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..4e13380e0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-reference/src/test/resources/log4j.properties
@@ -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.
+#
+
+# Set root logger level to WARN and its only appender to CONSOLE
+log4j.rootLogger=OFF, CONSOLE
+
+# log4j properties to work with commandline tools.
+log4j.category.org.mortbay=OFF
+log4j.category.org.hibernate.type=OFF
+log4j.category.org.objectweb=OFF
+log4j.category.org.apache.ode.axis2=OFF
+log4j.category.org.apache.ode.bpel.engine=OFF
+log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF
+log4j.category.org.apache.ode.bpel.epr=OFF
+log4j.category.org.apache.tuscany.sca.implementation.bpel=DEBUG
+log4j.category.org.apache.tuscany.sca.implementation.bpel.ode=DEBUG
+log4j.category.org.apache.tuscany.sca.implementation.bpel.provider=DEBUG
+
+# Console appender
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=[%p] - %C{1}.%M(%L) | %m%n
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/pom.xml b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/pom.xml
new file mode 100644
index 0000000000..dffbb4f9a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/pom.xml
@@ -0,0 +1,175 @@
+<?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>itest-bpel</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bpel-helloworld-ws
+ </artifactId>
+ <name>Apache Tuscany SCA iTest BPEL HelloWorld Over Web Services</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-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!-- http://jira.codehaus.org/browse/SUREFIRE-322 -->
+ <version>2.3.1</version>
+ <configuration>
+ <useFile>false</useFile>
+ <trimStackTrace>false</trimStackTrace>
+ <useSystemClassLoader>true</useSystemClassLoader>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin
+ </artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby
+ </artifactId>
+ <version>1.1</version>
+ <type>zip</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/test-classes/
+ </outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <id>generate-bpel-helloworld</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <schemaFile>
+ ${basedir}/src/test/resources/helloworld/helloworld.wsdl
+ </schemaFile>
+ <targetDirectory>${basedir}/target/wsdl2java-source
+ </targetDirectory>
+ <prefix>HelloWorld</prefix>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-maven-wsdl2java
+ </artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <configuration>
+ <wsdlFiles>
+ <wsdlFile>
+ <fileName>
+ ${basedir}/src/test/resources/helloworld/helloworld.wsdl
+ </fileName>
+ </wsdlFile>
+ </wsdlFiles>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..0999e97065
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package helloworld;
+
+import org.apache.tuscany.implementation.bpel.example.helloworld.HelloPortType;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorld {
+ private HelloPortType helloService;
+
+ public HelloWorld() {
+ super();
+ }
+
+ @Reference
+ public void setHelloService(HelloPortType helloService){
+ this.helloService = helloService;
+ }
+
+ public String hello(String hello) throws java.rmi.RemoteException {
+ System.out.println(">>> Invoking helloService.hello with : " + hello);
+ return this.helloService.hello(hello);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..315591fb98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.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 helloworld;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.implementation.bpel.example.helloworld.HelloPortType;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Tests the BPEL Helloworld Service
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldTestCase {
+
+ private Node node;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ protected void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("helloworld/helloworld.composite");
+ node = NodeFactory.newInstance().createNode("CallBackApiTest.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+ public void testPing() throws IOException {
+ new Socket("127.0.0.1", 8085);
+ }
+
+ public void testServiceInvocation() throws Exception {
+ HelloPortType bpelService = node.getService(HelloPortType.class, "BPELHelloWorldServiceComponent");
+ String response = bpelService.hello("Hello");
+ Assert.assertEquals("Hello World", response);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..8cf91adc2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel
@@ -0,0 +1,66 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="helloworld.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"/>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink" partnerLinkType="test:HelloPartnerLinkType" myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="helloMessage" messageType="test:HelloMessage"/>
+ <variable name="tmpVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessage"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from variable="helloMessage" part="TestPart"/>
+ <to variable="tmpVar"/>
+ </copy>
+ <copy>
+ <from>concat($tmpVar,' World')</from>
+ <to variable="helloMessage" part="TestPart"/>
+ </copy>
+ </assign>
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessage"/>
+ </sequence>
+</process>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite
new file mode 100644
index 0000000000..e606e6dd52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://bpel"
+ xmlns:hns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ name="helloworld">
+
+ <component name="BPELHelloWorldServiceComponent">
+ <implementation.bpel process="hns:HelloWorld"/>
+ <service name="helloPartnerLink">
+ <interface.wsdl interface="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl#wsdl.interface(HelloPortType)" />
+ <binding.ws uri="http://localhost:8085/HelloPartnerLink" wsdlElement="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl#wsdl.service(HelloService)"/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..610bda3cc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl
@@ -0,0 +1,82 @@
+<?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 name="helloworld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="message" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part element="tns:hello" name="TestPart"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="TestIn">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="TestOut">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8085/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/log4j.properties b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..37f66e4189
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld-ws/src/test/resources/log4j.properties
@@ -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.
+#
+
+# Set root logger level to WARN and its only appender to CONSOLE
+log4j.rootLogger=OFF, CONSOLE
+
+# log4j properties to work with commandline tools.
+log4j.category.org.mortbay=OFF
+log4j.category.org.hibernate.type=OFF
+log4j.category.org.objectweb=OFF
+log4j.category.org.apache.ode.axis2=OFF
+log4j.category.org.apache.ode.bpel.engine=OFF
+log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF
+log4j.category.org.apache.ode.bpel.epr=OFF
+log4j.category.org.apache.tuscany.sca.implementation.bpel=DEBUG
+log4j.category.org.apache.tuscany.sca.implementation.bpel.ode=DEBUG
+log4j.category.org.apache.tuscany.sca.implementation.bpel.provider=DEBUG
+
+# Console appender
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=[%p] - %C{1}.%M(%L) | %m%n
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld/pom.xml b/sandbox/sebastien/java/embed/itest/bpel/helloworld/pom.xml
new file mode 100644
index 0000000000..2e01bee7c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld/pom.xml
@@ -0,0 +1,270 @@
+<?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>itest-bpel</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bpel-helloworld</artifactId>
+ <name>Apache Tuscany SCA iTest BPEL HelloWorld</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-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!-- http://jira.codehaus.org/browse/SUREFIRE-322 -->
+ <version>2.3.1</version>
+ <configuration>
+ <useFile>false</useFile>
+ <trimStackTrace>false</trimStackTrace>
+ <useSystemClassLoader>true</useSystemClassLoader>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby</artifactId>
+ <version>1.1</version>
+ <type>zip</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/test-classes/</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!--
+ Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsimport</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.implementation.bpel.example.helloworld</packageName>
+ <wsdlDirectory>${basedir}/src/test/resources/helloworld/</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld.wsdl</wsdlFile>
+ </wsdlFiles>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <verbose>false</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </execution>
+
+ <!--
+ <execution>
+ <id>wsgen</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>wsgen-test</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.interfacedef.java.jaxws.MyServiceImpl</sei>
+ <genWsdl>true</genWsdl>
+ <keep>true</keep>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ </configuration>
+ </execution>
+ -->
+ </executions>
+
+ </plugin>
+
+ <!--
+ wsimport cannot handle WSDL files without a service/binding element.
+ CXF wsdl2java plugin does support that. I had to override the default
+ value of wsdlRoot/testWsdlRoot to a non-existent file to avoid NPE -->
+ <!--
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+
+ <configuration>
+ <sourceRoot>${basedir}/target/jaxws-source</sourceRoot>
+ <wsdlRoot>NONE</wsdlRoot>
+ <testWsdlRoot>NONE</testWsdlRoot>
+ <wsdlOptions>
+ <wsdlOption>
+ <wsdl>${basedir}/src/test/resources/wsdl/Stock.wsdl</wsdl>
+ <outputDir>${basedir}/target/jaxws-source</outputDir>
+ <packagenames>
+ <packagename>com.example.stock.cxf</packagename>
+ </packagenames>
+ </wsdlOption>
+ </wsdlOptions>
+ </configuration>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..0999e97065
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package helloworld;
+
+import org.apache.tuscany.implementation.bpel.example.helloworld.HelloPortType;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorld {
+ private HelloPortType helloService;
+
+ public HelloWorld() {
+ super();
+ }
+
+ @Reference
+ public void setHelloService(HelloPortType helloService){
+ this.helloService = helloService;
+ }
+
+ public String hello(String hello) throws java.rmi.RemoteException {
+ System.out.println(">>> Invoking helloService.hello with : " + hello);
+ return this.helloService.hello(hello);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..cbed39c295
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.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 helloworld;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.implementation.bpel.example.helloworld.HelloPortType;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Tests the BPEL Helloworld Service
+ *
+ * @version $Rev$ $Date$
+ */
+@Ignore
+public class HelloWorldTestCase {
+
+ private static Node node;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("helloworld/helloworld.composite");
+ node = NodeFactory.newInstance().createNode("helloworld/helloworld.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testServiceInvocation() throws Exception {
+ HelloPortType bpelService = node.getService(HelloPortType.class, "BPELHelloWorldService");
+ String response = bpelService.hello("Hello");
+ Assert.assertEquals("Hello World", response);
+ }
+
+ @Test
+ public void testReferenceInvocation() throws Exception {
+ HelloWorld bpelService = node.getService(HelloWorld.class, "BPELHelloWorld");
+ String response = bpelService.hello("Hello");
+ Assert.assertEquals("Hello World", response);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..156e32e9ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel
@@ -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.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0" xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+
+ <import location="helloworld.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"/>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink" partnerLinkType="test:HelloPartnerLinkType" myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="helloMessage" messageType="test:HelloMessage"/>
+ <variable name="helloMessageResponse" messageType="test:HelloMessageResponse"/>
+ <variable name="tmpVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessage"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from>concat($helloMessage.TestPart/test:message/text(), ' World')</from>
+ <to variable="tmpVar"/>
+ </copy>
+ <!-- Initialize the response -->
+ <copy>
+ <from>
+ <literal>
+ <test:helloResponse>
+ <test:messageResponse>Dummy</test:messageResponse>
+ </test:helloResponse>
+ </literal>
+ </from>
+ <to variable="helloMessageResponse" part="TestResponse"/>
+ </copy>
+ <copy>
+ <from variable="tmpVar"/>
+ <to>$helloMessageResponse.TestResponse/test:messageResponse</to>
+ </copy>
+ </assign>
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessageResponse"/>
+ </sequence>
+</process>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite
new file mode 100644
index 0000000000..96ec8b24b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://bpel"
+ xmlns:hns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ name="helloworld">
+
+ <component name="BPELHelloWorld">
+ <implementation.java class="helloworld.HelloWorld"/>
+ <reference name="helloService" target="BPELHelloWorldService">
+ <!-- Workaround for databinding issue -->
+ <!-- interface.wsdl interface="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl#wsdl.interface(HelloPortType)" / -->
+ </reference>
+ </component>
+
+ <component name="BPELHelloWorldService">
+ <implementation.bpel process="hns:HelloWorld"/>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..c77318e8fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl
@@ -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.
+ -->
+
+<wsdl:definitions name="helloworld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="message" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="helloResponse">
+ <complexType>
+ <sequence>
+ <element name="messageResponse" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part element="tns:hello" name="TestPart"/>
+ </wsdl:message>
+
+ <wsdl:message name="HelloMessageResponse">
+ <wsdl:part element="tns:helloResponse" name="TestResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessageResponse" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="TestIn">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="TestOut">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8085/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/log4j.properties b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..37f66e4189
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/helloworld/src/test/resources/log4j.properties
@@ -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.
+#
+
+# Set root logger level to WARN and its only appender to CONSOLE
+log4j.rootLogger=OFF, CONSOLE
+
+# log4j properties to work with commandline tools.
+log4j.category.org.mortbay=OFF
+log4j.category.org.hibernate.type=OFF
+log4j.category.org.objectweb=OFF
+log4j.category.org.apache.ode.axis2=OFF
+log4j.category.org.apache.ode.bpel.engine=OFF
+log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF
+log4j.category.org.apache.ode.bpel.epr=OFF
+log4j.category.org.apache.tuscany.sca.implementation.bpel=DEBUG
+log4j.category.org.apache.tuscany.sca.implementation.bpel.ode=DEBUG
+log4j.category.org.apache.tuscany.sca.implementation.bpel.provider=DEBUG
+
+# Console appender
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=[%p] - %C{1}.%M(%L) | %m%n
diff --git a/sandbox/sebastien/java/embed/itest/bpel/pom.xml b/sandbox/sebastien/java/embed/itest/bpel/pom.xml
new file mode 100644
index 0000000000..10cc5e27fe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/bpel/pom.xml
@@ -0,0 +1,39 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bpel</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA iTest BPEL Integration Tests</name>
+
+ <modules>
+ <module>helloworld</module>
+ <!--
+ <module>helloworld-reference</module>
+ <module>helloworld-ws</module>
+ -->
+ </modules>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/builder/pom.xml b/sandbox/sebastien/java/embed/itest/builder/pom.xml
new file mode 100644
index 0000000000..390716452d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/pom.xml
@@ -0,0 +1,112 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-builder</artifactId>
+ <name>Apache Tuscany SCA iTest Builder</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java
new file mode 100644
index 0000000000..b0dc7a6389
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.builder;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Implementation class for ComponentD.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service({Service3.class, Service3a.class})
+public class ComponentDImpl implements Service3, Service3a {
+
+ @Reference
+ protected Service3a reference3;
+
+ public String getGreetings(String name) {
+ return "Hello, " + name + "!";
+ }
+
+ public String getGreetings2(String name) {
+ return "Goodbye, " + name + "!";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java
new file mode 100644
index 0000000000..bf73a64027
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.builder;
+
+import java.util.List;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Implementation class for ComponentD.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service({Service3.class, Service3a.class})
+public class ComponentDReferenceMultiplicityImpl implements Service3, Service3a {
+
+ @Reference
+ protected Service3a reference3;
+
+ @Reference
+ protected List<Service3> reference3a;
+
+ public String getGreetings(String name) {
+ return "Hello, " + name + "!";
+ }
+
+ public String getGreetings2(String name) {
+ return "Goodbye, " + name + "!";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java
new file mode 100644
index 0000000000..6f36b1c55a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.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 org.apache.tuscany.sca.itest.builder;
+
+import org.oasisopen.sca.annotation.Service;
+
+
+/**
+ * Implementation class for ComponentD.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service({Service3.class})
+public class ComponentEImpl implements Service3 {
+
+
+ public String getGreetings(String name) {
+ return "Hello, " + name + " from ComponentE";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java
new file mode 100644
index 0000000000..8c5c5de208
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.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 org.apache.tuscany.sca.itest.builder;
+
+import org.oasisopen.sca.annotation.Service;
+
+
+/**
+ * Implementation class for ComponentD.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service({Service3.class})
+public class ComponentFImpl implements Service3 {
+
+
+ public String getGreetings(String name) {
+ return "Hello, " + name + " from ComponentF";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java
new file mode 100644
index 0000000000..f4b8d2cf39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.builder;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * Interface for Service3 in ComponentD.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Service3 {
+
+ String getGreetings(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java
new file mode 100644
index 0000000000..299f7606e3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.builder;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * Interface for Service3a in ComponentD.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Service3a {
+
+ String getGreetings2(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7fabed9436
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:ns1="http://scenario1">
+ <deployable composite="ns1:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/scenario1.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/scenario1.composite
new file mode 100644
index 0000000000..286e53539f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/scenario1.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://scenario1"
+ xmlns:tns="http://scenario1"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/scenario1a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/scenario1a.composite
new file mode 100644
index 0000000000..2bdfc19c3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario1/scenario1a.composite
@@ -0,0 +1,47 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://scenario1"
+ xmlns:tns="http://scenario1"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ac01b3c687
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario10"
+ xmlns:ns10="http://scenario10">
+ <deployable composite="ns10:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/scenario10.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/scenario10.composite
new file mode 100644
index 0000000000..2d127a7bec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/scenario10.composite
@@ -0,0 +1,62 @@
+<?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://scenario10"
+ xmlns:tns="http://scenario10"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference2" target="ComponentB/Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ <reference name="reference2a" target="ComponentF">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3)" />
+ <binding.ws />
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/scenario10a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/scenario10a.composite
new file mode 100644
index 0000000000..0fda11482b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/scenario10a.composite
@@ -0,0 +1,61 @@
+<?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://scenario10"
+ xmlns:tns="http://scenario10"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/service3.wsdl b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/service3.wsdl
new file mode 100644
index 0000000000..2477e23dc6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario10/service3.wsdl
@@ -0,0 +1,63 @@
+<?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 name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings">
+ <wsdl:part name="getGreetings" element="tns:getGreetings" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part name="getGreetingsResponse" element="tns:getGreetingsResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetings" />
+ <wsdl:output message="tns:getGreetingsResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8b82b43c68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario11"
+ xmlns:ns11="http://scenario11">
+ <deployable composite="ns11:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/scenario11.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/scenario11.composite
new file mode 100644
index 0000000000..2f5ca96d07
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/scenario11.composite
@@ -0,0 +1,59 @@
+<?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://scenario11"
+ xmlns:tns="http://scenario11"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" target="ComponentF">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/scenario11a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/scenario11a.composite
new file mode 100644
index 0000000000..1831d97ea7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/scenario11a.composite
@@ -0,0 +1,64 @@
+<?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://scenario11"
+ xmlns:tns="http://scenario11"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" target="ComponentB/Service2a" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3)" />
+ <binding.ws />
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/service3.wsdl b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/service3.wsdl
new file mode 100644
index 0000000000..2477e23dc6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario11/service3.wsdl
@@ -0,0 +1,63 @@
+<?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 name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings">
+ <wsdl:part name="getGreetings" element="tns:getGreetings" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part name="getGreetingsResponse" element="tns:getGreetingsResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetings" />
+ <wsdl:output message="tns:getGreetingsResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..4028098023
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario12"
+ xmlns:ns12="http://scenario12">
+ <deployable composite="ns12:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/scenario12.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/scenario12.composite
new file mode 100644
index 0000000000..23799f8487
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/scenario12.composite
@@ -0,0 +1,58 @@
+<?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://scenario12"
+ xmlns:tns="http://scenario12"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" target="ComponentF">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/scenario12a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/scenario12a.composite
new file mode 100644
index 0000000000..7982a9b2d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario12/scenario12a.composite
@@ -0,0 +1,64 @@
+<?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://scenario12"
+ xmlns:tns="http://scenario12"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws/>
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..1da59d5f04
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario13"
+ xmlns:ns13="http://scenario13">
+ <deployable composite="ns13:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/scenario13.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/scenario13.composite
new file mode 100644
index 0000000000..631e38855f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/scenario13.composite
@@ -0,0 +1,58 @@
+<?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://scenario13"
+ xmlns:tns="http://scenario13"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/scenario13a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/scenario13a.composite
new file mode 100644
index 0000000000..a6e31ea5e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario13/scenario13a.composite
@@ -0,0 +1,64 @@
+<?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://scenario13"
+ xmlns:tns="http://scenario13"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws/>
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b51ef11b05
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:ns2="http://scenario2">
+ <deployable composite="ns2:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/scenario2.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/scenario2.composite
new file mode 100644
index 0000000000..2fa559e1ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/scenario2.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://scenario2"
+ xmlns:tns="http://scenario2"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/scenario2a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/scenario2a.composite
new file mode 100644
index 0000000000..9fd3df07e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario2/scenario2a.composite
@@ -0,0 +1,47 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://scenario2"
+ xmlns:tns="http://scenario2"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3" >
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..22950dfe03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario3"
+ xmlns:ns3="http://scenario3">
+ <deployable composite="ns3:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/scenario3.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/scenario3.composite
new file mode 100644
index 0000000000..84f42c60fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/scenario3.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"
+ targetNamespace="http://scenario3"
+ xmlns:tns="http://scenario3"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/scenario3a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/scenario3a.composite
new file mode 100644
index 0000000000..89fa0619e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario3/scenario3a.composite
@@ -0,0 +1,48 @@
+<?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://scenario3"
+ xmlns:tns="http://scenario3"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a17e27c9d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario4"
+ xmlns:ns4="http://scenario4">
+ <deployable composite="ns4:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/scenario4.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/scenario4.composite
new file mode 100644
index 0000000000..a0bdb0197d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/scenario4.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"
+ targetNamespace="http://scenario4"
+ xmlns:tns="http://scenario4"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/scenario4a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/scenario4a.composite
new file mode 100644
index 0000000000..fbf1b1a893
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario4/scenario4a.composite
@@ -0,0 +1,48 @@
+<?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://scenario4"
+ xmlns:tns="http://scenario4"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..83a232db6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario5"
+ xmlns:ns5="http://scenario5">
+ <deployable composite="ns5:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenario5.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenario5.composite
new file mode 100644
index 0000000000..2326afd2f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenario5.composite
@@ -0,0 +1,46 @@
+<?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://scenario5"
+ xmlns:tns="http://scenario5"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3a)" />
+ <binding.ws uri="http://foo.com/bar" />
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenario5a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenario5a.composite
new file mode 100644
index 0000000000..802d82b0f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenario5a.composite
@@ -0,0 +1,47 @@
+<?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://scenario5"
+ xmlns:tns="http://scenario5"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenarios.wsdl b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenarios.wsdl
new file mode 100644
index 0000000000..5cda7327dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario5/scenarios.wsdl
@@ -0,0 +1,63 @@
+<?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 name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetings2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings2">
+ <wsdl:part name="getGreetings2" element="tns:getGreetings2" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings2Response">
+ <wsdl:part name="getGreetings2Response" element="tns:getGreetings2Response" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3a">
+ <wsdl:operation name="getGreetings2">
+ <wsdl:input message="tns:getGreetings2" />
+ <wsdl:output message="tns:getGreetings2Response" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..fb477d3e62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://scenario6"
+ xmlns:ns6="http://scenario6">
+ <deployable composite="ns6:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenario6.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenario6.composite
new file mode 100644
index 0000000000..dadfc7eb82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenario6.composite
@@ -0,0 +1,47 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://scenario6"
+ xmlns:tns="http://scenario6"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference2" target="ComponentB/Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3a)" />
+ <binding.ws />
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenario6a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenario6a.composite
new file mode 100644
index 0000000000..0c94b2bf06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenario6a.composite
@@ -0,0 +1,47 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://scenario6"
+ xmlns:tns="http://scenario6"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenarios.wsdl b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenarios.wsdl
new file mode 100644
index 0000000000..5cda7327dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario6/scenarios.wsdl
@@ -0,0 +1,63 @@
+<?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 name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetings2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings2">
+ <wsdl:part name="getGreetings2" element="tns:getGreetings2" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings2Response">
+ <wsdl:part name="getGreetings2Response" element="tns:getGreetings2Response" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3a">
+ <wsdl:operation name="getGreetings2">
+ <wsdl:input message="tns:getGreetings2" />
+ <wsdl:output message="tns:getGreetings2Response" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ede31d6bee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario7"
+ xmlns:ns7="http://scenario7">
+ <deployable composite="ns7:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenario7.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenario7.composite
new file mode 100644
index 0000000000..e1d2e0cefe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenario7.composite
@@ -0,0 +1,45 @@
+<?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://scenario7"
+ xmlns:tns="http://scenario7"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenario7a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenario7a.composite
new file mode 100644
index 0000000000..76892f1515
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenario7a.composite
@@ -0,0 +1,49 @@
+<?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://scenario7"
+ xmlns:tns="http://scenario7"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" target="ComponentB/Service2a" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3a)" />
+ <binding.ws />
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenarios.wsdl b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenarios.wsdl
new file mode 100644
index 0000000000..5cda7327dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario7/scenarios.wsdl
@@ -0,0 +1,63 @@
+<?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 name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetings2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings2">
+ <wsdl:part name="getGreetings2" element="tns:getGreetings2" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings2Response">
+ <wsdl:part name="getGreetings2Response" element="tns:getGreetings2Response" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3a">
+ <wsdl:operation name="getGreetings2">
+ <wsdl:input message="tns:getGreetings2" />
+ <wsdl:output message="tns:getGreetings2Response" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7bb9e694a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario8"
+ xmlns:ns8="http://scenario8">
+ <deployable composite="ns8:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenario8.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenario8.composite
new file mode 100644
index 0000000000..467b7f57fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenario8.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"
+ targetNamespace="http://scenario8"
+ xmlns:tns="http://scenario8"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenario8a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenario8a.composite
new file mode 100644
index 0000000000..86cf093f94
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenario8a.composite
@@ -0,0 +1,50 @@
+<?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://scenario8"
+ xmlns:tns="http://scenario8"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar" />
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <interface.wsdl interface="http://scenarios#wsdl.interface(Service3a)" />
+ <binding.ws />
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenarios.wsdl b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenarios.wsdl
new file mode 100644
index 0000000000..5cda7327dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario8/scenarios.wsdl
@@ -0,0 +1,63 @@
+<?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 name="Service3Service"
+ targetNamespace="http://scenarios"
+ xmlns:tns="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://scenarios"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetings2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetings2">
+ <wsdl:part name="getGreetings2" element="tns:getGreetings2" />
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings2Response">
+ <wsdl:part name="getGreetings2Response" element="tns:getGreetings2Response" />
+ </wsdl:message>
+
+ <wsdl:portType name="Service3a">
+ <wsdl:operation name="getGreetings2">
+ <wsdl:input message="tns:getGreetings2" />
+ <wsdl:output message="tns:getGreetings2Response" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b6ec160506
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://scenario9"
+ xmlns:ns9="http://scenario9">
+ <deployable composite="ns9:CompositeA" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/scenario9.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/scenario9.composite
new file mode 100644
index 0000000000..83584ed482
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/scenario9.composite
@@ -0,0 +1,60 @@
+<?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://scenario9"
+ xmlns:tns="http://scenario9"
+ name="CompositeA">
+
+ <service name="Service1" promote="ComponentB/Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference1" promote="ComponentB/reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar"/>
+ </reference>
+ <reference name="reference1a" promote="ComponentB/reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws uri="http://foo.com/bar"/>
+ </reference>
+
+ <component name="ComponentB">
+ <implementation.composite name="tns:CompositeC" />
+ <service name="Service2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentF">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/scenario9a.composite b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/scenario9a.composite
new file mode 100644
index 0000000000..2861974c98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/main/resources/scenario9/scenario9a.composite
@@ -0,0 +1,61 @@
+<?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://scenario9"
+ xmlns:tns="http://scenario9"
+ name="CompositeC">
+
+ <service name="Service2" promote="ComponentD/Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service2a" promote="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference2" promote="ComponentD/reference3" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a" multiplicity="1..1">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+
+ <component name="ComponentD">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentDReferenceMultiplicityImpl"/>
+ <service name="Service3">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <service name="Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </service>
+ <reference name="reference3" target="ComponentD/Service3a">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference3a" target="ComponentE">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ </component>
+
+ <component name="ComponentE">
+ <implementation.java class="org.apache.tuscany.sca.itest.builder.ComponentEImpl"/>
+ <service name="Service3">
+ <binding.sca />
+ <binding.ws />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java b/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
new file mode 100644
index 0000000000..e2fda0e0ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
@@ -0,0 +1,814 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.builder;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Load and build some composites and inspect the results.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuilderTestCase {
+ private CustomCompositeBuilder customBuilder;
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /* OASIS doesn't take notice of top level composite services
+ *
+ // Scenario 1: <binding.ws> on outer composite service CompositeA/Service1
+ @Ignore
+ @Test
+ public void testScenario1() throws Exception {
+ System.out.println("====>Running testScenario1");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario1.composite", "TestContribution", "src/main/resources/scenario1/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario1Results(false);
+ }
+
+ @Ignore
+ @Test
+ public void testScenario1NonWiring() throws Exception {
+ System.out.println("====>Running testScenario1NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario1.composite", "TestContribution", "src/main/resources/scenario1/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario1Results(true);
+ }
+
+ private void checkScenario1Results(boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ if (!nonWiring) {
+ // Should create component service $promoted$Service1 on innermost component
+ // ComponentD, with <binding.ws> and uri="/Service1"
+ // No other services on ComponentD should have <binding.ws>
+ WebServiceBinding wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
+ if ("$promoted$Service1".equals(service.getName())) {
+ wsBinding = wsb;
+ } else {
+ assert wsb == null;
+ }
+ }
+ assert "/Service1".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/$promoted$Service1 with endpoint uri="/Service1"
+ Definition def = wsBinding.getWSDLDocument();
+ javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ Port port = svc.getPort("Service3Port");
+ assert "/Service1".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not create component service $promoted$Service1 on innermost component ComponentD
+ // No component services on ComponentD should have <binding.ws>
+ for (ComponentService service : componentD.getServices()) {
+ assert !"$promoted$Service1".equals(service.getName());
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+
+ // No services on ComponentB should have <binding.ws>
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ for (ComponentService service : componentB.getServices()) {
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+
+ // No services on CompositeC should have <binding.ws>
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario1", "CompositeC"));
+ for (Service service : compositeC.getServices()) {
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+
+ if (nonWiring) {
+ // Should not add a WSDL document to domain composite service Service1
+ WebServiceBinding wsBinding = null;
+ for (Service service : domainComposite.getServices()) {
+ if ("Service1".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert wsBinding.getWSDLDocument() == null;
+ }
+
+ String expectedEndpoints = "Component - ComponentB\n" +
+ "Service - Service2\n" +
+ "Endpoint - Service2\n" +
+ "Service - Service2a\n" +
+ "Endpoint - Service2a\n" +
+ "Reference - reference2\n" +
+ "Component - ComponentB has composite impl\n" +
+ " Component - ComponentD\n" +
+ " Service - Service3\n" +
+ " Endpoint - Service3\n" +
+ " Service - Service3a\n" +
+ " Endpoint - Service3a\n" +
+ " Reference - reference3";
+
+ String actualEndpoints = TestUtils.printEndpoints(domainComposite);
+ System.out.println(actualEndpoints);
+
+ Assert.assertEquals(expectedEndpoints, actualEndpoints);
+ }
+*/
+
+ // Scenario 2: <binding.ws> on outer component service ComponentB/Service2
+ @Test
+ public void testScenario2() throws Exception {
+ System.out.println("====>Running testScenario2");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario2.composite", "TestContribution", "src/main/resources/scenario2/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario2and3Results("http://scenario2", false);
+ }
+
+ public void testScenario2NonWiring() throws Exception {
+ System.out.println("====>Running testScenario2NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario2.composite", "TestContribution", "src/main/resources/scenario2/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario2and3Results("http://scenario2", true);
+ }
+
+ private void checkScenario2and3Results(String namespace, boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Test that endpoint structure matches expected
+ String structure = TestUtils.printStructure(domainComposite, "");
+ System.out.println(structure);
+
+ String expectedStructure = "Component URI - ComponentB\n" +
+ " Component URI - ComponentB/ComponentD\n" +
+ " Endpoint: URI = ComponentB/ComponentD#service-binding(Service3/Service3) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n" +
+ " Endpoint: URI = ComponentB/ComponentD#service-binding(Service3a/Service3a) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n" +
+ "Endpoint: URI = ComponentB#service-binding(Service2/Service2) org.apache.tuscany.sca.binding.ws.impl.WebServiceBindingImpl\n" +
+ "Endpoint: URI = ComponentB#service-binding(Service2a/Service3a) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n";
+
+ Assert.assertEquals(expectedStructure, structure);
+
+ // Test that generated WSDL matches expected
+ // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
+ // No other services on ComponentB should have <binding.ws>
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ WebServiceBinding wsBinding = null;
+
+ for (ComponentService service : componentB.getServices()) {
+ WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
+ if ("Service2".equals(service.getName())) {
+ wsBinding = wsb;
+ } else {
+ assert wsb == null;
+ }
+ }
+
+ Definition def = wsBinding.getGeneratedWSDLDocument();
+ TestUtils.writeWSDL(def);
+
+ javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ Port port = svc.getPort("Service3Port");
+ Assert.assertEquals("/ComponentB/Service2",TestUtils.getPortAddress(port));
+
+ }
+/*
+ // Scenario 3: <binding.ws> on inner composite service CompositeC/Service2
+ public void testScenario3() throws Exception {
+ System.out.println("====>Running testScenario3");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario3.composite", "TestContribution", "src/main/resources/scenario3/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario2and3Results("http://scenario3", false);
+ }
+
+ public void testScenario3NonWiring() throws Exception {
+ System.out.println("====>Running testScenario3NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario3.composite", "TestContribution", "src/main/resources/scenario3/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario2and3Results("http://scenario3", true);
+ }
+
+ // Scenario 4: <binding.ws> on inner component service ComponentD/Service3
+ public void testScenario4() throws Exception {
+ System.out.println("====>Running testScenario4");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario4.composite", "TestContribution", "src/main/resources/scenario4/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario4Results(false);
+ }
+
+ public void testScenario4NonWiring() throws Exception {
+ System.out.println("====>Running testScenario4NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario4.composite", "TestContribution", "src/main/resources/scenario4/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario4Results(true);
+ }
+
+ private void checkScenario4Results(boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Should create WSDL document for ComponentD/Service3 with endpoint uri="/ComponentD/Service3"
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ WebServiceBinding wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ if ("Service3".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ Definition def = wsBinding.getWSDLDocument();
+ javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ Port port = svc.getPort("Service3Port");
+ assert "/ComponentB/ComponentD/Service3".equals(TestUtils.getPortAddress(port));
+
+ // Should add <binding.ws> to inner composite service CompositeC/Service2
+ // No other services on CompositeC should have <binding.ws>
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario4", "CompositeC"));
+ wsBinding = null;
+ for (Service service : compositeC.getServices()) {
+ WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
+ if ("Service2".equals(service.getName())) {
+ wsBinding = wsb;
+ } else {
+ assert wsb == null;
+ }
+ }
+ assert "/ComponentB/Service2".equals(wsBinding.getURI());
+
+ // Should add <binding.ws> to outer component service ComponentB/Service2
+ // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
+ // No other services on ComponentB should have <binding.ws>
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ wsBinding = null;
+ for (ComponentService service : componentB.getServices()) {
+ WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
+ if ("Service2".equals(service.getName())) {
+ wsBinding = wsb;
+ } else {
+ assert wsb == null;
+ }
+ }
+ assert "/ComponentB/Service2".equals(wsBinding.getURI());
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ port = svc.getPort("Service3Port");
+ assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
+
+ if (!nonWiring) {
+ // Should create component service $promoted$ComponentB$slash$Service2 on innermost component
+ // ComponentD, with <binding.ws> and uri="/ComponentB/Service2"
+ wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ if ("$promoted$ComponentB$slash$Service2".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert "/ComponentB/Service2".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/$promoted$ComponentB$slash$Service2 with endpoint uri="/ComponentB/Service2"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ port = svc.getPort("Service3Port");
+ assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not create component service $promoted$ComponentB$slash$Service2 on innermost component ComponentD
+ for (ComponentService service : componentD.getServices()) {
+ assert !"$promoted$ComponentB$slash$Service2".equals(service.getName());
+ }
+ }
+
+ // Should add <binding.ws> to outer composite service CompositeA/Service1
+ wsBinding = null;
+ for (Service service : domainComposite.getServices()) {
+ if ("Service1".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert wsBinding != null;
+ if (nonWiring) {
+ // Should not add a WSDL document to domain composite service Service1
+ assert wsBinding.getWSDLDocument() == null;
+ }
+
+ if (!nonWiring) {
+ // Should create component service $promoted$Service1 on innermost component
+ // ComponentD, with <binding.ws> and uri="/Service1"
+ wsBinding = null;
+ for (ComponentService service : componentD.getServices()) {
+ if ("$promoted$Service1".equals(service.getName())) {
+ wsBinding = service.getBinding(WebServiceBinding.class);
+ }
+ }
+ assert "/Service1".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/$promoted$Service1 with endpoint uri="/Service1"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
+ port = svc.getPort("Service3Port");
+ assert "/Service1".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not create component service $promoted$.Service1 on innermost component ComponentD
+ for (ComponentService service : componentD.getServices()) {
+ assert !"$promoted$Service1".equals(service.getName());
+ }
+ }
+
+ // No services on ComponentD should have <binding.ws>, except for Service3,
+ // $promoted$.Service1 and $promoted$.ComponentB.Service2
+ for (ComponentService service : componentD.getServices()) {
+ if (!"Service3".equals(service.getName()) &&
+ !"$promoted$Service1".equals(service.getName()) &&
+ !"$promoted$ComponentB$slash$Service2".equals(service.getName())) {
+ assert service.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+ }
+
+ // Scenario 5: <binding.ws> and <interface.wsdl> on outer composite reference CompositeA/reference1
+ @Test
+ public void testScenario5() throws Exception {
+ System.out.println("====>Running testScenario5");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario5.composite", "TestContribution", "src/main/resources/scenario5/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario5Results(false);
+ }
+
+ @Test
+ public void testScenario5NonWiring() throws Exception {
+ System.out.println("====>Running testScenario5NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario5.composite", "TestContribution", "src/main/resources/scenario5/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario5Results(true);
+ }
+
+ private void checkScenario5Results(boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Should not add <binding.ws> to any outer component references
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ for (ComponentReference reference : componentB.getReferences()) {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ }
+
+ Definition def;
+ javax.wsdl.Service svc;
+ Port port;
+ WebServiceBinding wsBinding;
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ if (!nonWiring) {
+ // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
+ // Should set <interface.wsdl> on inner component reference ComponentD/reference3
+ wsBinding = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
+ }
+ }
+ assert "http://foo.com/bar".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
+ port = svc.getPort("Service3aPort");
+ assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not add <binding.ws> to any inner component references
+ for (ComponentReference reference : componentD.getReferences()) {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+
+ // Should not add <binding.ws> or <interface.wsdl> to inner composite reference CompositeC/reference2
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario5", "CompositeC"));
+ for (Reference reference : compositeC.getReferences()) {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ assert reference.getInterfaceContract() instanceof JavaInterfaceContract;
+ }
+
+ String expectedEndpoints = "Component - ComponentB\n" +
+ "Service - Service2\n" +
+ "Endpoint - Service2\n" +
+ "Service - Service2a\n" +
+ "Endpoint - Service2a\n" +
+ "Reference - reference2\n" +
+ "Component - ComponentB has composite impl\n" +
+ " Component - ComponentD\n" +
+ " Service - Service3\n" +
+ " Endpoint - Service3\n" +
+ " Service - Service3a\n" +
+ " Endpoint - Service3a\n" +
+ " Reference - reference3";
+
+ String actualEndpoints = TestUtils.printEndpoints(domainComposite);
+ System.out.println(actualEndpoints);
+
+ Assert.assertEquals(expectedEndpoints, actualEndpoints);
+ }
+
+
+ // Scenario 6: <binding.ws> and <interface.wsdl> on outer component reference ComponentB/reference2
+ @Ignore
+ @Test
+ public void testScenario6() throws Exception {
+ System.out.println("====>Running testScenario6");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario6.composite", "TestContribution", "src/main/resources/scenario6/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario6and7Results("http://scenario6", false);
+ }
+
+ @Ignore
+ @Test
+ public void testScenario6NonWiring() throws Exception {
+ System.out.println("====>Running testScenario6NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario6.composite", "TestContribution", "src/main/resources/scenario6/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario6and7Results("http://scenario6", true);
+ }
+
+ private void checkScenario6and7Results(String namespace, boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Should remove target= on ComponentB/reference2 (for Scenario 6) or
+ // CompositeC/reference2 (for Scenario 7), and add uri="http://foo.com/bar"
+ // to the <binding.ws> element on ComponentB/reference2
+ // For nonWiring, ComponentB/reference2 should have target=
+ // and no uri= should be added
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ WebServiceBinding wsBinding = null;
+ for (ComponentReference reference : componentB.getReferences()) {
+ if ("reference2".equals(reference.getName())) {
+ if (!nonWiring) {
+ assert reference.getTargets().size() == 0;
+ } else {
+ assert reference.getTargets().size() == 1;
+ }
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ }
+ }
+ if (!nonWiring) {
+ assert "http://foo.com/bar".equals(wsBinding.getURI());
+ } else {
+ assert wsBinding.getURI() == null;
+ }
+
+ Definition def;
+ javax.wsdl.Service svc;
+ Port port;
+ if (!nonWiring) {
+ // Should create WSDL document for ComponentB/reference2 with endpoint uri="http://foo.com/bar"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
+ port = svc.getPort("Service3aPort");
+ assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
+ }
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ if (!nonWiring) {
+ // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
+ // Should set <interface.wsdl> on inner component reference ComponentD/reference3
+ wsBinding = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getBindings().size() == 1;
+ assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
+ }
+ }
+ assert "http://foo.com/bar".equals(wsBinding.getURI());
+
+ // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
+ port = svc.getPort("Service3aPort");
+ assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
+ } else {
+ // Should not add <binding.ws> to any inner component references
+ for (ComponentReference reference : componentD.getReferences()) {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ }
+ }
+
+ // No references on CompositeC should have <binding.ws> or <interface.wsdl>, except for
+ // reference2 in Scenario 7
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName(namespace, "CompositeC"));
+ for (Reference reference : compositeC.getReferences()) {
+ if ("http://scenario7".equals(namespace) && "reference2".equals(reference.getName())) {
+ assert reference.getBinding(WebServiceBinding.class)!= null;
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ } else {
+ assert reference.getBinding(WebServiceBinding.class) == null;
+ assert reference.getInterfaceContract() instanceof JavaInterfaceContract;
+ }
+ }
+
+ // Should add <binding.ws> and <interface.wsdl> to outer composite reference CompositeA/reference1
+ wsBinding = null;
+ for (Reference reference : domainComposite.getReferences()) {
+ if ("reference1".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ }
+ }
+ assert wsBinding.getURI() == null;
+
+ // Should not add a WSDL document to domain composite reference reference1
+ assert wsBinding.getWSDLDocument() == null;
+
+ String expectedEndpoints = "Component - ComponentB\n" +
+ "Service - Service2\n" +
+ "Endpoint - Service2\n" +
+ "Service - Service2a\n" +
+ "Endpoint - Service2a\n" +
+ "Reference - reference2\n" +
+ "Component - ComponentB has composite impl\n" +
+ " Component - ComponentD\n" +
+ " Service - Service3\n" +
+ " Endpoint - Service3\n" +
+ " Service - Service3a\n" +
+ " Endpoint - Service3a\n" +
+ " Reference - reference3";
+
+ String actualEndpoints = TestUtils.printEndpoints(domainComposite);
+ System.out.println(actualEndpoints);
+
+ Assert.assertEquals(expectedEndpoints, actualEndpoints);
+ }
+
+ // Scenario 7: <binding.ws> and <interface.wsdl> on inner composite reference CompositeC/reference2
+ public void testScenario7() throws Exception {
+ System.out.println("====>Running testScenario7");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario7.composite", "TestContribution", "src/main/resources/scenario7/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario6and7Results("http://scenario7", false);
+ }
+
+ public void testScenario7NonWiring() throws Exception {
+ System.out.println("====>Running testScenario7NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario7.composite", "TestContribution", "src/main/resources/scenario7/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario6and7Results("http://scenario7", true);
+ }
+
+ // Scenario 8: <binding.ws> and <interface.wsdl> on inner component reference ComponentD/reference3
+ public void testScenario8() throws Exception {
+ System.out.println("====>Running testScenario8");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario8.composite", "TestContribution", "src/main/resources/scenario8/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario8Results(false);
+ }
+
+ public void testScenario8NonWiring() throws Exception {
+ System.out.println("====>Running testScenario8NonWiring");
+ customBuilder = new CustomCompositeBuilder(true);
+ customBuilder.loadContribution("scenario8.composite", "TestContribution", "src/main/resources/scenario8/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario8Results(true);
+ }
+
+ private void checkScenario8Results(boolean nonWiring) {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ // Should replace target= on ComponentD/reference3 by uri="http://foo.com/bar" on <binding.ws>
+ // For nonWiring, the original target= is preserved and there is no uri=
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ WebServiceBinding wsBinding = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3".equals(reference.getName())) {
+ if (!nonWiring) {
+ assert reference.getTargets().size() == 0;
+ } else {
+ assert reference.getTargets().size() == 1;
+ }
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ }
+ }
+ if (!nonWiring) {
+ assert "http://foo.com/bar".equals(wsBinding.getURI());
+ } else {
+ assert wsBinding.getURI() == null;
+ }
+
+ Definition def;
+ javax.wsdl.Service svc;
+ Port port;
+ if (!nonWiring) {
+ // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
+ def = wsBinding.getWSDLDocument();
+ svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
+ port = svc.getPort("Service3aPort");
+ assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
+ }
+
+ // Should add <binding.ws> and <interface.wsdl> to inner composite reference CompositeC/reference2
+ Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario8", "CompositeC"));
+ wsBinding = null;
+ for (Reference reference : compositeC.getReferences()) {
+ if ("reference2".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ }
+ }
+ assert wsBinding.getURI() == null;
+
+ // Should add <binding.ws> and <interface.wsdl> to outer component reference ComponentB/reference2
+ Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
+ wsBinding = null;
+ for (ComponentReference reference : componentB.getReferences()) {
+ if ("reference2".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ }
+ }
+ assert wsBinding.getURI() == null;
+
+ // Should add <binding.ws> and <interface.wsdl> to outer composite reference CompositeA/reference1
+ wsBinding = null;
+ for (Reference reference : domainComposite.getReferences()) {
+ if ("reference1".equals(reference.getName())) {
+ wsBinding = reference.getBinding(WebServiceBinding.class);
+ assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
+ }
+ }
+ assert wsBinding.getURI() == null;
+
+ // Should not add a WSDL document to domain composite reference reference1
+ assert wsBinding.getWSDLDocument() == null;
+ }
+
+ // Scenario 9: target in reference CDR3A and binding.ws uri= at CAR1A
+ public void testScenario9() throws Exception {
+ System.out.println("====>Running testScenario9");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario9.composite", "TestContribution", "src/main/resources/scenario9/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario9Results();
+ }
+
+ private void checkScenario9Results() {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ ComponentReference componentRef = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3a".equals(reference.getName())) {
+ componentRef = reference;
+ assertTrue(reference.getBindings().size() == 2);
+ assertTrue(reference.getBindings().get(0) instanceof SCABinding);
+ assertTrue(reference.getBindings().get(1) instanceof WebServiceBinding);
+ }
+ }
+ assertTrue(componentRef != null);
+ }
+
+ // Scenario 10: targets in references CBR2A and CDR3A and binding.ws at CBR2A
+ public void testScenario10() throws Exception {
+ System.out.println("====>Running testScenario10");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario10.composite", "TestContribution", "src/main/resources/scenario10/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario10And11Results();
+ }
+
+ // Scenario 11: targets in references CBR2A and CDR3A and binding.ws at CCR2A
+ public void testScenario11() throws Exception {
+ System.out.println("====>Running testScenario11");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario11.composite", "TestContribution", "src/main/resources/scenario11/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario10And11Results();
+ }
+
+ private void checkScenario10And11Results() {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ ComponentReference componentRef = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3a".equals(reference.getName())) {
+ componentRef = reference;
+ assertTrue(reference.getBindings().size() == 2);
+ Binding binding1 = reference.getBindings().get(0);
+ assertTrue(binding1 instanceof SCABinding);
+ assertTrue(reference.getInterfaceContract(binding1) instanceof JavaInterfaceContract);
+ Binding binding2 = reference.getBindings().get(1);
+ assertTrue(binding2 instanceof WebServiceBinding);
+ assertTrue(reference.getInterfaceContract(binding2) instanceof WSDLInterfaceContract);
+ }
+ }
+ assertTrue(componentRef != null);
+ }
+
+ // Scenario 12: targets in references CBR2A and CDR3A and binding.ws at CDR3A
+ public void testScenario12() throws Exception {
+ System.out.println("====>Running testScenario12");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario12.composite", "TestContribution", "src/main/resources/scenario12/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario12Results();
+ }
+
+ private void checkScenario12Results() {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ ComponentReference componentRef = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3a".equals(reference.getName())) {
+ componentRef = reference;
+ assertTrue(reference.getBindings().size() == 2);
+ assertTrue(reference.getBindings().get(0) instanceof WebServiceBinding);
+ assertTrue(reference.getBindings().get(1) instanceof WebServiceBinding);
+ }
+ }
+ assertTrue(componentRef != null);
+ }
+
+ // Scenario 13: target in reference CDR3A
+ public void testScenario13() throws Exception {
+ System.out.println("====>Running testScenario13");
+ customBuilder = new CustomCompositeBuilder(false);
+ customBuilder.loadContribution("scenario13.composite", "TestContribution", "src/main/resources/scenario13/");
+ //TestUtils.printResults(customBuilder);
+ TestUtils.checkProblems(customBuilder);
+ checkScenario13Results();
+ }
+
+ private void checkScenario13Results() {
+ Composite domainComposite = customBuilder.getDomainComposite();
+
+ Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
+ ComponentReference componentRef = null;
+ for (ComponentReference reference : componentD.getReferences()) {
+ if ("reference3a".equals(reference.getName())) {
+ componentRef = reference;
+ assertTrue(reference.getBindings().size() == 1);
+ assertTrue(reference.getBindings().get(0) instanceof WebServiceBinding);
+ }
+ }
+ assertTrue(componentRef != null);
+ }
+*/
+}
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java b/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
new file mode 100644
index 0000000000..897cd21e8a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.builder;
+
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Composite;
+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.UtilityExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+
+
+public class CustomCompositeBuilder {
+
+ private boolean nonWiring;
+ private Node node;
+ private ExtensionPointRegistry extensionPoints;
+ private Monitor monitor;
+ private StAXArtifactProcessor<Composite> compositeProcessor;
+
+ public CustomCompositeBuilder(boolean nonWiring) {
+ this.nonWiring = nonWiring;
+ }
+
+ public void loadContribution(String compositeURL, String sourceURI, String sourceURL) throws Exception {
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ node = nodeFactory.createNode(compositeURL, new Contribution(sourceURI, sourceURL));
+ node.start();
+
+ // get some things out of the extension registry
+ extensionPoints = ((NodeImpl)node).getExtensionPointRegistry();
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ monitor = monitorFactory.createMonitor();
+
+ StAXArtifactProcessorExtensionPoint xmlProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ compositeProcessor = xmlProcessors.getProcessor(Composite.class);
+
+ CompositeActivator compositeActivator = utilities.getUtility(CompositeActivator.class);
+ }
+
+ /**
+ * Returns the delegating model processor.
+ * @return the delegating model processor
+ */
+ public StAXArtifactProcessor<Object> getModelProcessor() {
+ return null;//compositeProcessor;
+ }
+
+ /**
+ * Returns the XML output factory.
+ * @return the XML output factory
+ */
+ public XMLOutputFactory getOutputFactory() {
+ return null; //outputFactory;
+ }
+
+ /**
+ * Returns the domain composite.
+ * @return the domain composite model object
+ */
+ public Composite getDomainComposite() {
+ return (Composite) ((NodeImpl)node).getDomainComposite();
+ }
+
+ /**
+ * Returns the monitor.
+ * @return the monitor instance
+ */
+ public Monitor getMonitor() {
+ return monitor;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java b/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
new file mode 100644
index 0000000000..9a5aa5582d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
@@ -0,0 +1,319 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.builder;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.EndpointImpl;
+import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+
+/**
+ * Static utility methods for use by test cases.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestUtils {
+
+ protected static void checkProblems(CustomCompositeBuilder customBuilder) throws Exception {
+ boolean problems = false;
+ for (Problem problem : customBuilder.getMonitor().getProblems()) {
+ if (problem.getCause() != null) {
+ problem.getCause().printStackTrace();
+ }
+ if (problem.getSeverity() == Problem.Severity.ERROR){
+ problems = true;
+ }
+ }
+ assert !problems;
+ }
+
+ protected static String getPortAddress(Port port) {
+ Object ext = port.getExtensibilityElements().get(0);
+ String returnAddress = null;
+ if (ext instanceof SOAPAddress) {
+ returnAddress = ((SOAPAddress)ext).getLocationURI();
+ }
+ if (ext instanceof SOAP12Address) {
+ returnAddress = ((SOAP12Address)ext).getLocationURI();
+ }
+
+ returnAddress = returnAddress.substring(returnAddress.indexOf("//") + 2);
+ returnAddress = returnAddress.substring(returnAddress.indexOf("/"));
+
+ return returnAddress;
+ }
+
+ protected static Component getComponent(Composite composite, String name) {
+ for (Component component : composite.getComponents()) {
+ if (name.equals(component.getName())) {
+ return component;
+ }
+ // process implementation composites recursively
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ Component comp = getComponent((Composite)impl, name);
+ if (comp != null) {
+ return comp;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected static Composite getComposite(Composite composite, QName name) {
+ if (name.equals(composite.getName())) {
+ return composite;
+ }
+ for (Component component : composite.getComponents()) {
+ // process implementation composites recursively
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ Composite comp = getComposite((Composite)impl, name);
+ if (comp != null) {
+ return comp;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected static void printResults(CustomCompositeBuilder customBuilder) throws Exception {
+ for (Problem problem : customBuilder.getMonitor().getProblems()) {
+ if (problem.getCause() != null) {
+ problem.getCause().printStackTrace();
+ }
+ }
+ Composite domainComposite = customBuilder.getDomainComposite();
+ printComposite(domainComposite, customBuilder);
+ }
+
+ private static void printComposite(Composite composite, CustomCompositeBuilder customBuilder) throws Exception {
+ // process implementation composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ printComposite((Composite)implementation, customBuilder);
+ }
+ }
+
+ // write out the SCDL
+ writeSCDL(composite, customBuilder);
+
+ // find all the component service and reference bindings
+ for (Component component : composite.getComponents()) {
+ for (ComponentService componentService : component.getServices()) {
+ for (Binding binding : componentService.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(component, componentService, ((WebServiceBinding)binding).getGeneratedWSDLDocument());
+ }
+ }
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (Binding binding : componentReference.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(component, componentReference, ((WebServiceBinding)binding).getGeneratedWSDLDocument());
+ }
+ }
+ }
+ }
+
+ // find all the composite service and reference bindings
+ for (Service service : composite.getServices()) {
+ for (Binding binding : service.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(null, service, ((WebServiceBinding)binding).getGeneratedWSDLDocument());
+ }
+ }
+ }
+ for (Reference reference : composite.getReferences()) {
+ for (Binding binding : reference.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(null, reference, ((WebServiceBinding)binding).getGeneratedWSDLDocument());
+ }
+ }
+ }
+ }
+
+ private static void writeSCDL(Composite composite, CustomCompositeBuilder customBuilder) throws Exception {
+ // Print out a composite
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLStreamWriter writer = customBuilder.getOutputFactory().createXMLStreamWriter(bos);
+ customBuilder.getModelProcessor().write(composite, writer, new ProcessorContext());
+
+ // Parse and write again to pretty format it
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = documentBuilder.parse(new ByteArrayInputStream(bos.toByteArray()));
+ OutputFormat format = new OutputFormat();
+ format.setIndenting(true);
+ format.setIndent(2);
+ XMLSerializer serializer = new XMLSerializer(System.out, format);
+ System.out.println("-->Runtime SCDL model for composite " + composite.getName());
+ serializer.serialize(document);
+ }
+
+ private static void writeWSDL(Component component, Contract contract, Definition definition) {
+ if (definition == null) {
+ System.out.println("-->No generated WSDL for " + (component != null ? component.getName() : "") + "/" + contract.getName());
+ } else {
+ try {
+ System.out.println("-->Generated WSDL for " + (component != null ? component.getName() : "") + "/" + contract.getName());
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(definition, System.out);
+ } catch (WSDLException e) {
+ // ignore
+ }
+ }
+ }
+
+ protected static void writeWSDL(Definition definition) {
+ try {
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(definition, System.out);
+ } catch (WSDLException e) {
+ // ignore
+ }
+ }
+
+ protected static String printStructure(Composite composite, String indent){
+ String structure = "";
+ for (Component component : composite.getComponents()){
+ structure += indent + "Component URI - " + component.getURI() + "\n";
+
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ structure += printStructure((Composite)implementation, indent + " ");
+ }
+
+ for (Service service : component.getServices()){
+ for (Endpoint endpoint : service.getEndpoints()){
+ structure += indent + ((EndpointImpl)endpoint).toStringWithoutHash() + " " + endpoint.getBinding().getClass().getName() + "\n";
+ }
+ }
+ for (Reference reference : component.getReferences()){
+ for (EndpointReference endpointReference : reference.getEndpointReferences()){
+ structure += indent + ((EndpointReferenceImpl)endpointReference).toStringWithoutHash() + " " + endpointReference.getBinding().getClass().getName() + "\n";
+ }
+ }
+ }
+ return structure;
+ }
+/*
+ protected static String printEndpoints(Composite composite){
+ return printEndpoints(composite, "");
+ }
+
+ protected static String printEndpoints(Composite composite, String indent){
+
+ String buffer = "";
+
+ for (Component component : composite.getComponents()) {
+ buffer += indent + "Component - " + component.getName() + "\n";
+
+ // print component service endpoints
+ for (ComponentService componentService : component.getServices()) {
+ buffer += indent + "Service - " + componentService.getName() + "\n";
+ for (Endpoint endpoint : componentService.getEndpoints()) {
+ if (endpoint.getBinding() != null){
+ buffer += printEndpoint(endpoint, indent);
+ }
+ }
+ }
+
+ for (ComponentReference componentReference : component.getReferences()) {
+ buffer += indent + "Reference - " + componentReference.getName() + "\n";
+ for (EndpointReference endpointReference : componentReference.getEndpointReferences()) {
+ buffer += printEndpointReference(endpointReference, indent);
+ }
+ }
+
+ // process implementation composites recursively
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buffer += indent + "Component - " + component.getName() + " has composite impl" + "\n";
+ buffer += printEndpoints((Composite)implementation, indent + " ");
+ }
+ }
+
+ return buffer;
+ }
+
+ protected static String printEndpoint(Endpoint endpoint, String indent){
+ String buffer = "";
+
+ buffer += indent + " Endpoint - Component: " + endpoint.getComponent().getName() +"\n";
+ buffer += indent + " Service: " + endpoint.getService().getName() +"\n";
+ buffer += indent + " Binding: " + endpoint.getBinding().getName() +"\n";
+
+ return buffer;
+ }
+
+ protected static String printEndpointReference(EndpointReference endpointReference, String indent){
+ String buffer = "";
+
+ buffer += indent + " EndpointReference - Component: " + endpointReference.getComponent().getName() +"\n";
+ buffer += indent + " Reference: " + endpointReference.getReference().getName() +"\n";
+ if (endpointReference.getTargetEndpoint() != null){
+ buffer += indent + " Wired: " +"\n";
+ buffer += indent + " Target: " + endpointReference.getTargetEndpoint().getComponent().getName()+"\n";
+ if (endpointReference.getTargetEndpoint() != null &&
+ endpointReference.getTargetEndpoint().isUnresolved() == false){
+ buffer += indent + " Binding: " + endpointReference.getBinding().getName() +"\n";
+ buffer += indent + " TargetEndpoint: " + endpointReference.getTargetEndpoint().getBinding().getName()+"\n";
+ } else {
+ buffer += indent + " Unresolved: " +"\n";
+ }
+ } else {
+ buffer += indent + " NonWired: " +"\n";
+ }
+
+ return buffer;
+ }
+*/
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/pom.xml b/sandbox/sebastien/java/embed/itest/callback-api/pom.xml
new file mode 100644
index 0000000000..87ca4b67a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/pom.xml
@@ -0,0 +1,58 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-callback-api</artifactId>
+ <name>Apache Tuscany SCA iTest Callback API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <properties>
+ <was.ant.script>${basedir}/../build-was-integration.xml</was.ant.script>
+ <was.python.script>${basedir}/../wasAdmin.py</was.python.script>
+ </properties>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java
new file mode 100644
index 0000000000..b013462f9f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+/**
+ *
+ */
+public interface CallBackApiCallBack {
+ /**
+ * This function is defined in CallBackApiClientImpl
+ */
+ void callBackMessage(String aString);
+
+ /**
+ * This function is defined in CallBackApiClientImpl
+ */
+ void callBackIncrement(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java
new file mode 100644
index 0000000000..252e4dc45f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.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.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CallBackApiClient {
+ /**
+ * This function is defined in CallBackApiClientImpl
+ */
+ void run();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java
new file mode 100644
index 0000000000..d883dc2d6f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test;
+
+import org.junit.Assert;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackApiClient.class)
+public class CallBackApiClientImpl implements CallBackApiClient, CallBackApiCallBack {
+
+ @Reference
+ protected CallBackApiService aCallBackService;
+
+ private static String returnMessage = null;
+ private static int callBackCount = 0;
+ private static Object monitor = new Object();
+
+ /**
+ * This test calls function test 3a,3a1,3b,3c
+ */
+ public void run() {
+
+ // This tests basic callback patterns.
+
+ // Test3a is the basic callback where the target calls back prior to
+ // returning to the client.
+ test3a();
+
+ test3a1();
+
+ // Test3b is where the target does not call back to the client.
+ test3b();
+
+ // Test3c is where the target calls back multiple times to the client.
+ test3c();
+ }
+
+ /**
+ * This test is the basic callback where the target calls back prior to returning to the client.
+ */
+
+ private void test3a() {
+ aCallBackService.knockKnock("Knock Knock");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackApiITest - test3a", "Who's There", this.getReturnMessage());
+
+ }
+
+ /**
+ * This test is the basic callback where the target calls back prior to returning to the client.
+ */
+ private void test3a1() {
+ aCallBackService.knockKnockByRef("Knock Knock");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackApiITest - test3a", "Who's There", this.getReturnMessage());
+
+ }
+
+ /**
+ * This test is the basic callback where the target does not call back to the client
+ */
+ private void test3b() {
+ aCallBackService.noCallBack("No Reply Desired");
+ Assert.assertEquals("CallBackApiITest - test3b", 1, 1);
+ }
+
+ /**
+ * This test is the basic callback where the target calls back multiple times to the client
+ */
+
+ private void test3c() {
+ aCallBackService.multiCallBack("Call me back 3 times");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (this.getCallBackCount() < 3 && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackApiITest - test3c", 3, this.getCallBackCount());
+ }
+
+ /**
+ * This function returns a string
+ *
+ * @param void
+ * @return String result string
+ */
+
+ public String getReturnMessage() {
+ return returnMessage;
+ }
+
+ /**
+ * This function set the returnMessage string
+ *
+ * @param String
+ */
+ public void setReturnMessage(String aReturnMessage) {
+ returnMessage = aReturnMessage;
+ }
+
+ /**
+ * This function returns the callBackCount variable
+ *
+ * @return Integer callBackCount variable
+ */
+ public int getCallBackCount() {
+ return callBackCount;
+ }
+
+ /**
+ * This function increments callBackCount variable by 1
+ */
+ public void incrementCallBackCount() {
+ callBackCount++;
+ }
+
+ /**
+ * This function prints a message synched with setReturnMessage function
+ *
+ * @param String
+ */
+ public void callBackMessage(String aString) {
+ System.out.println("Entering callback callBackMessage: " + aString);
+ synchronized (monitor) {
+ this.setReturnMessage(aString);
+ monitor.notify();
+ }
+ }
+
+ /**
+ * This function prints a message synched with incrementCallBackCount function
+ *
+ * @param String
+ */
+ public void callBackIncrement(String aString) {
+ System.out.println("Entering callback increment: " + aString);
+ synchronized (monitor) {
+ this.incrementCallBackCount();
+ monitor.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java
new file mode 100644
index 0000000000..afb7c45e2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.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.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(CallBackApiCallBack.class)
+/**
+ *
+ */
+public interface CallBackApiService {
+ /**
+ * This function is defined in CallBackApiServiceImpl
+ */
+ void knockKnock(String aString);
+
+ /**
+ * This function is defined in CallBackApiServiceImpl
+ */
+ void knockKnockByRef(String aString);
+
+ /**
+ * This function is defined in CallBackApiServiceImpl
+ */
+ void noCallBack(String aString);
+
+ /**
+ * This function is defined in CallBackApiServiceImpl
+ */
+ void multiCallBack(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java
new file mode 100644
index 0000000000..44f57b4316
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.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.sca.test;
+
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackApiService.class)
+public class CallBackApiServiceImpl implements CallBackApiService {
+
+ @Context
+ protected ComponentContext componentContext;
+ /**
+ * Object of CallBackApiCallBack class
+ */
+ private CallBackApiCallBack callback;
+
+ @Callback
+ protected ServiceReference<CallBackApiCallBack> callbackRef;
+
+ /**
+ * This function get an object of CallBackApiServiceImpl by calling getCallBackInterface function and calls the
+ * callBackMessage function.
+ *
+ * @param aString String passed by a function call
+ */
+
+ public void knockKnock(String aString) {
+
+ System.out.println("CallBackApiServiceImpl message received: " + aString);
+ callback = this.getCallBackInterface();
+ callback.callBackMessage("Who's There");
+ System.out.println("CallBackApiServiceImpl response sent");
+ }
+
+ /**
+ * This function calls the callBackMessage function. <br>
+ * The reference to this function is received from Call back reference to the class CallBackApiService.
+ *
+ * @param aString String passed by a function call
+ */
+ public void knockKnockByRef(String aString) {
+
+ System.out.println("CallBackApiServiceImpl message received: " + aString);
+ callbackRef.getService().callBackMessage("Who's There");
+ System.out.println("CallBackApiServiceImpl response sent");
+ }
+
+ /**
+ * This function get an object of CallBackApiServiceImpl by calling getCallBackInterface function. <br>
+ * This function then places multiple callBack using the callbackIncrement function defined in
+ * callBack.ApiServiceImpl
+ *
+ * @param aString String passed by a function call
+ */
+ public void multiCallBack(String aString) {
+
+ callback = this.getCallBackInterface();
+
+ System.out.println("CallBackApiServiceImpl message received: " + aString);
+ callback.callBackIncrement("Who's There 1");
+ System.out.println("CallBackApiServiceImpl response sent");
+ callback.callBackIncrement("Who's There 2");
+ System.out.println("CallBackApiServiceImpl response sent");
+ callback.callBackIncrement("Who's There 3");
+ System.out.println("CallBackApiServiceImpl response sent");
+ }
+
+ /**
+ * This function does not callBack any function.
+ *
+ * @param aString String passed by a function call
+ */
+ public void noCallBack(String aString) {
+ System.out.println("CallBackApiServiceImpl message received: " + aString);
+ }
+
+ /**
+ * This function get an object of CallBackApiServiceImpl from the present componentContext
+ *
+ * @param void
+ */
+ private CallBackApiCallBack getCallBackInterface() {
+ System.out.println("CallBackApiServiceImpl getting request context");
+ RequestContext rc = componentContext.getRequestContext();
+ System.out.println("CallBackApiServiceImpl getting callback from request context");
+ callback = rc.getCallback();
+ System.out.println("CallBackApiServiceImpl returning callback");
+ return callback;
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/src/main/resources/CallBackApiTest.composite b/sandbox/sebastien/java/embed/itest/callback-api/src/main/resources/CallBackApiTest.composite
new file mode 100644
index 0000000000..a67233665c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/src/main/resources/CallBackApiTest.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://callback"
+ name="CallBackApiTest">
+
+ <component name="CallBackApiClient">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackApiClientImpl"/>
+ <reference name="aCallBackService" target="CallBackApiService"/>
+ </component>
+
+ <component name="CallBackApiService">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackApiServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b1a01e9f7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://callback">
+ <deployable composite="t:CallBackApiTest" />
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java b/sandbox/sebastien/java/embed/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java
new file mode 100644
index 0000000000..75fab95efb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.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.test;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CallBackApiTestCase {
+
+ private static Node node;
+ private CallBackApiClient aCallBackClient;
+
+ /**
+ * This function uses the Instance of CallBackApiClient.class <br>
+ * This function calls the run function defined in the CallBackApiClinet Interface <br>
+ * which in turn executes the following test cases. <br>
+ * 1. Basic callback patterns <br>
+ * 2. Test in which the target does not call back to the client <br>
+ * 3. Test in which the target calls back multiple times to the client.
+ */
+ @Test
+ public void testCallBackBasic() {
+ aCallBackClient = node.getService(CallBackApiClient.class, "CallBackApiClient");
+ aCallBackClient.run();
+ }
+
+ /**
+ * This function creates the Node instance and gets an Instance of CallBackApiClient.class
+ */
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ if (node == null) {
+ String location = ContributionLocationHelper.getContributionLocation("CallBackApiTest.composite");
+ node = NodeFactory.newInstance().createNode("CallBackApiTest.composite", new Contribution("c1", location));
+ node.start();
+ }
+ }
+
+ /**
+ * This function destroys the Node instance that was created in setUp()
+ */
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/pom.xml b/sandbox/sebastien/java/embed/itest/callback-basic/pom.xml
new file mode 100644
index 0000000000..029bb56247
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/pom.xml
@@ -0,0 +1,58 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-callback-basic</artifactId>
+ <name>Apache Tuscany SCA iTest Callback Basic</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <properties>
+ <was.ant.script>${basedir}/../build-was-integration.xml</was.ant.script>
+ <was.python.script>${basedir}/../wasAdmin.py</was.python.script>
+ </properties>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java
new file mode 100644
index 0000000000..291a72b9d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+/**
+ *
+ */
+public interface CallBackBasicCallBack {
+
+ void callBackMessage(String aString);
+
+ void callBackIncrement(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java
new file mode 100644
index 0000000000..19f366c423
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CallBackBasicClient {
+
+ void run();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java
new file mode 100644
index 0000000000..4bb6b29a8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test;
+
+import org.junit.Assert;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackBasicClient.class)
+public class CallBackBasicClientImpl implements CallBackBasicClient, CallBackBasicCallBack {
+
+ @Reference
+ protected CallBackBasicService aCallBackService;
+ private static String returnMessage = null;
+ private static int callBackCount = 0;
+ private static Object monitor = new Object();
+
+ public void run() {
+
+ // This tests basic callback patterns.
+
+ // Test1 is the basic callback where the target calls back prior to
+ // returning to the client.
+ test1a();
+
+ // Test2 is where the target does not call back to the client.
+ test1b();
+
+ // Test3 is where the target calls back multiple times to the client.
+ test1c();
+ }
+
+ private void test1a() {
+ aCallBackService.knockKnock("Knock Knock");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackBasicITest - test1a", "Who's There", this.getReturnMessage());
+
+ }
+
+ private void test1b() {
+ aCallBackService.noCallBack("No Reply Desired");
+ Assert.assertEquals("CallBackBasicITest - test1b", 1, 1);
+ }
+
+ private void test1c() {
+ aCallBackService.multiCallBack("Call me back 3 times");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (this.getCallBackCount() < 3 && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackBasicITest - test1c", 3, this.getCallBackCount());
+ }
+
+ public String getReturnMessage() {
+ return returnMessage;
+ }
+
+ public void setReturnMessage(String aReturnMessage) {
+ returnMessage = aReturnMessage;
+ }
+
+ public int getCallBackCount() {
+ return callBackCount;
+ }
+
+ public void incrementCallBackCount() {
+ callBackCount++;
+ }
+
+ public void callBackMessage(String aString) {
+ System.out.println("Entering callback callBackMessage: " + aString);
+ synchronized (monitor) {
+ this.setReturnMessage(aString);
+ monitor.notify();
+ }
+ }
+
+ public void callBackIncrement(String aString) {
+ System.out.println("Entering callback increment: " + aString);
+ synchronized (monitor) {
+ this.incrementCallBackCount();
+ monitor.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java
new file mode 100644
index 0000000000..5396879e83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.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.sca.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(CallBackBasicCallBack.class)
+/**
+ *
+ */
+public interface CallBackBasicService {
+
+ void knockKnock(String aString);
+
+ void noCallBack(String aString);
+
+ void multiCallBack(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java
new file mode 100644
index 0000000000..07010f61e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackBasicService.class)
+public class CallBackBasicServiceImpl implements CallBackBasicService {
+
+ @Callback
+ protected CallBackBasicCallBack callback;
+
+ public void knockKnock(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ callback.callBackMessage("Who's There");
+ System.out.println("CallBackBasicServiceImpl response sent");
+
+ }
+
+ public void multiCallBack(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ callback.callBackIncrement("Who's There 1");
+ System.out.println("CallBackBasicServiceImpl response sent");
+ callback.callBackIncrement("Who's There 2");
+ System.out.println("CallBackBasicServiceImpl response sent");
+ callback.callBackIncrement("Who's There 3");
+ System.out.println("CallBackBasicServiceImpl response sent");
+
+ }
+
+ public void noCallBack(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ // System.out.println("CallBackBasicServiceImpl No response desired");
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/src/main/resources/CallBackBasicTest.composite b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/resources/CallBackBasicTest.composite
new file mode 100644
index 0000000000..5339e9952e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/resources/CallBackBasicTest.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://callback"
+ name="CallBackBasicTest">
+
+ <component name="CallBackBasicClient">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackBasicClientImpl"/>
+ <reference name="aCallBackService" target="CallBackBasicService"/>
+ </component>
+
+ <component name="CallBackBasicService">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackBasicServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..d36d7478e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://callback">
+ <deployable composite="t:CallBackBasicTest" />
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java b/sandbox/sebastien/java/embed/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java
new file mode 100644
index 0000000000..43b812faed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.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 org.apache.tuscany.sca.test;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CallBackBasicTestCase {
+
+ private static Node node;
+ private CallBackBasicClient aCallBackClient;
+
+ @Test
+ public void testCallBackBasic() {
+ aCallBackClient.run();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ if (node == null) {
+ String location = ContributionLocationHelper.getContributionLocation("CallBackBasicTest.composite");
+ node = NodeFactory.newInstance().createNode("CallBackBasicTest.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ aCallBackClient = node.getService(CallBackBasicClient.class, "CallBackBasicClient");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/pom.xml b/sandbox/sebastien/java/embed/itest/callback-complex-type/pom.xml
new file mode 100644
index 0000000000..726465f2b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-callback-complex-type</artifactId>
+ <name>Apache Tuscany SCA iTest Callback Complex Type</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java
new file mode 100644
index 0000000000..627d37e27d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+/**
+ *
+ */
+public interface CallBackCTypeCallBack {
+
+ void callBackMessage(String aString);
+
+ void callBackIncrement(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java
new file mode 100644
index 0000000000..966ad17b9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CallBackCTypeClient {
+
+ void run();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java
new file mode 100644
index 0000000000..d2dc0add75
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test;
+
+import org.junit.Assert;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackCTypeClient.class)
+public class CallBackCTypeClientImpl implements CallBackCTypeClient, CallBackCTypeCallBack {
+
+ @Reference
+ protected CallBackCTypeService aCallBackService;
+ private static String returnMessage = null;
+ private static int callBackCount = 0;
+ private static Object monitor = new Object();
+
+ public CallBackCTypeClientImpl() {
+ }
+
+ public void run() {
+
+ // This test is the same as the Basic Callback except it uses a
+ // componentType side file.
+ // This test currently fails because the integration test environment
+ // does not properly copy
+ // the componentType files to the target folder. This is documented in
+ // Tuscany-967.
+
+ // Test12a is the basic callback where the target calls back prior to
+ // returning to the client.
+ test12a();
+
+ // Test12b is where the target does not call back to the client.
+ test12b();
+
+ // Test12c is where the target calls back multiple times to the client.
+ test12c();
+
+ }
+
+ private void test12a() {
+ aCallBackService.knockKnock("Knock Knock");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackBasicITest - test12a -", "Who's There", this.getReturnMessage());
+
+ }
+
+ private void test12b() {
+ aCallBackService.noCallBack("No Reply Desired");
+ Assert.assertEquals("CallBackBasicITest - test12b -", 1, 1);
+ }
+
+ private void test12c() {
+ aCallBackService.multiCallBack("Call me back 3 times");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (this.getCallBackCount() < 3 && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackBasicITest - test12c -", 3, this.getCallBackCount());
+ }
+
+ public String getReturnMessage() {
+ return returnMessage;
+ }
+
+ public void setReturnMessage(String aReturnMessage) {
+ returnMessage = aReturnMessage;
+ }
+
+ public int getCallBackCount() {
+ return callBackCount;
+ }
+
+ public void incrementCallBackCount() {
+ callBackCount++;
+ }
+
+ public void callBackMessage(String aString) {
+ System.out.println("Entering callback callBackMessage: " + aString);
+ synchronized (monitor) {
+ this.setReturnMessage(aString);
+ monitor.notify();
+ }
+ }
+
+ public void callBackIncrement(String aString) {
+ System.out.println("Entering callback increment: " + aString);
+ synchronized (monitor) {
+ this.incrementCallBackCount();
+ monitor.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java
new file mode 100644
index 0000000000..32ab1bdd3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.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.sca.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(CallBackCTypeCallBack.class)
+/**
+ *
+ */
+public interface CallBackCTypeService {
+
+ void knockKnock(String aString);
+
+ void noCallBack(String aString);
+
+ void multiCallBack(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java
new file mode 100644
index 0000000000..f7a1a195ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackCTypeService.class)
+public class CallBackCTypeServiceImpl implements CallBackCTypeService {
+
+ @Callback
+ protected CallBackCTypeCallBack callback;
+
+ public CallBackCTypeServiceImpl() {
+ }
+
+ public void knockKnock(String aString) {
+
+ System.out.println("CallBackCTypeServiceImpl message received: " + aString);
+ callback.callBackMessage("Who's There");
+ System.out.println("CallBackCTypeServiceImpl response sent");
+
+ }
+
+ public void multiCallBack(String aString) {
+
+ System.out.println("CallBackCTypeServiceImpl message received: " + aString);
+ callback.callBackIncrement("Who's There 1");
+ System.out.println("CallBackCTypeServiceImpl response sent");
+ callback.callBackIncrement("Who's There 2");
+ System.out.println("CallBackCTypeServiceImpl response sent");
+ callback.callBackIncrement("Who's There 3");
+ System.out.println("CallBackCTypeServiceImpl response sent");
+
+ }
+
+ public void noCallBack(String aString) {
+
+ System.out.println("CallBackCTypeServiceImpl message received: " + aString);
+ System.out.println("CallBackCTypeServiceImpl No response desired");
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite
new file mode 100644
index 0000000000..9730c294d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://callback"
+ name="CallBackCTypeTest">
+
+ <component name="CallBackCTypeClient">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackCTypeClientImpl"/>
+ <reference name="aCallBackService" target="CallBackCTypeService"/>
+ </component>
+
+ <component name="CallBackCTypeService">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackCTypeServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType
new file mode 100644
index 0000000000..11e748675d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" >
+
+ <service name="CallBackCTypeService">
+ <interface.java interface="org.apache.tuscany.sca.test.CallBackCTypeService"
+ callbackInterface="org.apache.tuscany.sca.test.CallBackCTypeCallBack"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java
new file mode 100644
index 0000000000..dde489d766
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.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.sca.test;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CallBackCTypeTestCase {
+
+ private Node node;
+ private CallBackCTypeClient aCallBackClient;
+
+ @Test
+ public void testCallBackBasic() {
+ aCallBackClient.run();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("CallBackCTypeClient.composite");
+ node =
+ NodeFactory.newInstance().createNode("CallBackCTypeClient.composite", new Contribution("c1", location))
+ .start();
+
+ aCallBackClient = node.getService(CallBackCTypeClient.class, "CallBackCTypeClient");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/pom.xml b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/pom.xml
new file mode 100644
index 0000000000..b29900c6ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-callback-multiple-wires</artifactId>
+ <name>Apache Tuscany SCA iTest Callback With Mutiple Wires</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClient.java b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClient.java
new file mode 100644
index 0000000000..7c80d222fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClient.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.test.callback;
+
+/**
+ * The client interface
+ */
+public interface MyClient {
+
+ void aClientMethod();
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl1.java b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl1.java
new file mode 100644
index 0000000000..c3ea6c3032
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl1.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.callback;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Demonstrates a component-to-component callback invocation
+ */
+@Service(MyClient.class)
+@Scope("COMPOSITE")
+public class MyClientImpl1 implements MyClient, MyServiceCallback {
+
+ private MyService myService;
+ static String result;
+
+ @Reference
+ public void setMyService(MyService myService) {
+ this.myService = myService;
+ }
+
+ public void aClientMethod() {
+ myService.someMethod("-> someMethod1");
+ }
+
+ public void receiveResult(String result) {
+ System.out.println("Work thread " + Thread.currentThread());
+ System.out.println("Result in client1: " + result);
+ MyClientImpl1.result = result;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl2.java b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl2.java
new file mode 100644
index 0000000000..84ca158c97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl2.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.callback;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Demonstrates a component-to-component callback invocation
+ */
+@Service(MyClient.class)
+@Scope("COMPOSITE")
+public class MyClientImpl2 implements MyClient, MyServiceCallback {
+
+ private MyService myService;
+ static String result;
+
+ @Reference
+ public void setMyService(MyService myService) {
+ this.myService = myService;
+ }
+
+ public void aClientMethod() {
+ myService.someMethod("-> someMethod2");
+ }
+
+ public void receiveResult(String result) {
+ System.out.println("Work thread " + Thread.currentThread());
+ System.out.println("Result in client2: " + result);
+ MyClientImpl2.result = result;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyService.java b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyService.java
new file mode 100644
index 0000000000..66758a1e73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyService.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.test.callback;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.OneWay;
+
+/**
+ * This service that will be invoked in a non-blocking fashion
+ */
+@Callback(MyServiceCallback.class)
+public interface MyService {
+
+ @OneWay
+ void someMethod(String arg);
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceCallback.java b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceCallback.java
new file mode 100644
index 0000000000..f198efae51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceCallback.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.test.callback;
+
+/**
+ * The callback interface for {@link MyService}.
+ */
+public interface MyServiceCallback {
+
+ void receiveResult(String result);
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.java b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.java
new file mode 100644
index 0000000000..2b484293c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.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.test.callback;
+
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements MyService and uses a callback.
+ *
+ * In this scenario, we exlore using the RequestContext to retrieve the callBack reference
+ * as @Callback injection is not performed for composite-scoped implementations (see JavaCAA Section 7.2.5)
+ *
+ * Changing the service implementation to be @Scope("STATELESS") would make plain @Callback injection work
+ */
+@Service(MyService.class)
+@Scope("COMPOSITE")
+public class MyServiceImpl implements MyService {
+
+ @Context
+ protected RequestContext requestContext;
+
+ public void someMethod(String arg) {
+ // invoke the callback
+ try {
+ MyServiceCallback myServiceCallback = requestContext.getCallback();
+ myServiceCallback.receiveResult(arg + " -> receiveResult");
+ } catch (RuntimeException e) {
+ System.out.println("RuntimeException invoking receiveResult: " + e.toString());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite
new file mode 100644
index 0000000000..9fe62ac671
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://callback"
+ name="CallbackMultiWireTest">
+
+ <component name="MyClientComponent1">
+ <implementation.java class="org.apache.tuscany.sca.test.callback.MyClientImpl1"/>
+ <reference name="myService" target="MyServiceComponent"/>
+ </component>
+
+ <component name="MyClientComponent2">
+ <implementation.java class="org.apache.tuscany.sca.test.callback.MyClientImpl2"/>
+ <reference name="myService" target="MyServiceComponent"/>
+ </component>
+
+ <component name="MyServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.test.callback.MyServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/test/java/org/apache/tuscany/sca/test/callback/CallbackMultiWireTestCase.java b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/test/java/org/apache/tuscany/sca/test/callback/CallbackMultiWireTestCase.java
new file mode 100644
index 0000000000..bd3cce74b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-multiple-wires/src/test/java/org/apache/tuscany/sca/test/callback/CallbackMultiWireTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.callback;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * A TestCase that demonstrates resolving the client service and initiating the callback sequence
+ */
+public class CallbackMultiWireTestCase {
+
+ private Node node;
+ private MyClient myClient1;
+ private MyClient myClient2;
+
+ @Before
+ public void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("CallbackMultiWireTest.composite");
+ node = NodeFactory.newInstance().createNode("CallbackMultiWireTest.composite", new Contribution("c1", location));
+ node.start();
+ myClient1 = node.getService(MyClient.class, "MyClientComponent1");
+ myClient2 = node.getService(MyClient.class, "MyClientComponent2");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void test() throws Exception {
+ System.out.println("Main thread " + Thread.currentThread());
+ myClient1.aClientMethod();
+ myClient2.aClientMethod();
+ System.out.println("Sleeping ...");
+ Thread.sleep(300);
+ assertEquals("-> someMethod1 -> receiveResult", MyClientImpl1.result);
+ assertEquals("-> someMethod2 -> receiveResult", MyClientImpl2.result);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-separatethread/pom.xml b/sandbox/sebastien/java/embed/itest/callback-separatethread/pom.xml
new file mode 100644
index 0000000000..99ecf2e312
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-separatethread/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-callback-separatethread</artifactId>
+ <name>Apache Tuscany SCA iTest Callback Using Separate Thread</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java
new file mode 100644
index 0000000000..dc66003604
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the client interface for the call backs in a separate thread tests
+ */
+@Remotable
+public interface CallBackSeparateThreadClient {
+
+ /**
+ * This tests call back patterns using separate threads.
+ */
+ void runTests();
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java
new file mode 100644
index 0000000000..f03144db8a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.junit.Assert;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This is the client implementation for the call backs in a separate thread tests
+ */
+@Service(CallBackSeparateThreadClient.class)
+public class CallBackSeparateThreadClientImpl implements CallBackSeparateThreadClient, EventProcessorCallBack {
+ /**
+ * Max time to wait to receive events. If not all the events are received then timeout.
+ */
+ private static final int TIMEOUT = 30 * 1000;
+
+ /**
+ * Counts the number of fast call backs.
+ */
+ private static final AtomicInteger FAST_CALLBACK_COUNT = new AtomicInteger();
+
+ /**
+ * Counts the number of slow call backs.
+ */
+ private static final AtomicInteger SLOW_CALLBACK_COUNT = new AtomicInteger();
+
+ /**
+ * This is our injected reference to the EventProcessorService
+ */
+ @Reference
+ protected EventProcessorService aCallBackService;
+
+ /**
+ * This tests call back patterns using separate threads.
+ */
+ public void runTests() {
+ try {
+ // Register for fast call back
+ registerForFastCallback();
+
+ // Wait for a few fast call backs
+ System.out.println("Waiting for some fast call backs");
+ waitForSomeFastCallbacks();
+
+ try {
+ // Register for slow call back
+ registerForSlowCallback();
+
+ // Wait for a few fast call backs
+ System.out.println("Waiting for some fast calls");
+ waitForSomeFastCallbacks();
+
+ // Wait for a few slow call backs
+ System.out.println("Waiting for some slow calls");
+ waitForSomeSlowCallbacks();
+ } finally {
+ unregisterForSlowCallback();
+ }
+
+ System.out.println("Done");
+ } finally {
+ unregisterForFastCallback();
+ }
+ }
+
+ /**
+ * Waits for some fast call backs to be fired
+ */
+ private void waitForSomeFastCallbacks() {
+ // Reset the fast call back count
+ FAST_CALLBACK_COUNT.set(0);
+
+ // Wait until we have 10 fast call backs or timeout occurs
+ final long start = System.currentTimeMillis();
+ do {
+ if (FAST_CALLBACK_COUNT.get() >= 10) {
+ System.out.println("Received enough fast notifications");
+ return;
+ }
+
+ try {
+ Thread.sleep(5);
+ } catch (InterruptedException e) {
+ Assert.fail("Unexpeceted exception " + e);
+ }
+ } while (System.currentTimeMillis() - start < TIMEOUT);
+
+ // If we get to here then we did not receive enough events
+ Assert.fail("Did not receive enough fast events");
+ }
+
+ /**
+ * Waits for some slow call backs to be fired
+ */
+ private void waitForSomeSlowCallbacks() {
+ // Reset the slow call back count
+ SLOW_CALLBACK_COUNT.set(0);
+
+ // Wait until we have 4 slow call backs or timeout
+ final long start = System.currentTimeMillis();
+ do {
+ if (SLOW_CALLBACK_COUNT.get() >= 4) {
+ System.out.println("Received enough slow notifications");
+ return;
+ }
+
+ try {
+ Thread.sleep(5);
+ } catch (InterruptedException e) {
+ Assert.fail("Unexpeceted exception " + e);
+ }
+ } while (System.currentTimeMillis() - start < TIMEOUT);
+
+ // If we get to here then we did not receive enough events
+ Assert.fail("Did not receive enough slow events");
+ }
+
+ /**
+ * Register to receive fast call backs
+ */
+ private void registerForFastCallback() {
+ aCallBackService.registerForEvent("FAST");
+ }
+
+ /**
+ * Register to receive slow call backs
+ */
+ private void registerForSlowCallback() {
+ aCallBackService.registerForEvent("SLOW");
+ }
+
+ /**
+ * Unregister to receive fast call backs
+ */
+ private void unregisterForFastCallback() {
+ aCallBackService.unregisterForEvent("FAST");
+ }
+
+ /**
+ * Unregister to receive slow call backs
+ */
+ private void unregisterForSlowCallback() {
+ aCallBackService.unregisterForEvent("SLOW");
+ }
+
+ /**
+ * Method that is called when an Event is delivered.
+ *
+ * @param aEventName The name of the Event
+ * @param aEventData The Event data
+ */
+ public void eventNotification(String aEventName, Object aEventData) {
+ // System.out.println("Received Event : " + aEventName + " " + aEventData);
+
+ if (aEventName.equals("FAST")) {
+ final int newValue = FAST_CALLBACK_COUNT.incrementAndGet();
+ //System.out.println("Received total of " + newValue + " fast call backs");
+ } else if (aEventName.equals("SLOW")) {
+ final int newValue = SLOW_CALLBACK_COUNT.incrementAndGet();
+ //System.out.println("Received total of " + newValue + " slow call backs");
+ } else {
+ System.out.println("Unknown event type of " + aEventName);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java
new file mode 100644
index 0000000000..137ea6a658
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.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.sca.itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The call back interface for the EventProcessorService that is implemented
+ * by the client to receive event notifications
+ */
+@Remotable
+public interface EventProcessorCallBack {
+ /**
+ * Call back notifying client of an Event
+ *
+ * @param aEventName The name of the Event
+ * @param aEventData The data for the Event
+ */
+ void eventNotification(String aEventName, Object aEventData);
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java
new file mode 100644
index 0000000000..4bf05fc925
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Sample Event Processor Service
+ */
+@Callback(EventProcessorCallBack.class)
+@Remotable
+public interface EventProcessorService {
+
+ /**
+ * Registers the client to receive notifications for the specified event
+ *
+ * @param aEventName The name of the Event to register
+ */
+ void registerForEvent(String aEventName);
+
+ /**
+ * Unregisters the client so it no longer receives notifications for the specified event
+ *
+ * @param aEventName The name of the Event to unregister
+ */
+ void unregisterForEvent(String aEventName);
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java
new file mode 100644
index 0000000000..bec98a49c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Sample Event Processor Service Implementation
+ */
+@Service(EventProcessorService.class)
+@Scope("COMPOSITE")
+public class EventProcessorServiceImpl implements EventProcessorService {
+
+ /**
+ * Reference to the call back
+ */
+ @Callback
+ protected ServiceReference<EventProcessorCallBack> clientCallback;
+
+ /**
+ * This map contains the call backs for each of the registered Event names
+ */
+ private final Map<String, ServiceReference<EventProcessorCallBack>> eventListeners;
+
+ /**
+ * The list of all Event Generators we create
+ */
+ private final EventGenerator[] allEventGenerators;
+
+ /**
+ * Constructor. Starts the Event Generators
+ */
+ public EventProcessorServiceImpl() {
+ eventListeners = new ConcurrentHashMap<String, ServiceReference<EventProcessorCallBack>>();
+
+ // We will simulate an Event generator
+ allEventGenerators = new EventGenerator[2];
+ allEventGenerators[0] = new EventGenerator("FAST", 10); // Generate the FAST event every 10ms
+ allEventGenerators[1] = new EventGenerator("SLOW", 50); // Generate the SLOW event every 50ms
+ }
+
+ /**
+ * Registers the client to receive notifications for the specified event
+ *
+ * @param aEventName The name of the Event to register
+ */
+ public void registerForEvent(String aEventName) {
+ // Register for the Event
+ eventListeners.put(aEventName, clientCallback);
+
+ // Send the "register" started event to the client
+ receiveEvent(aEventName, "SameThread: Registered to receive notifications for " + aEventName);
+ }
+
+ /**
+ * Unregisters the client so it no longer receives notifications for the specified event
+ *
+ * @param aEventName The name of the Event to unregister
+ */
+ public void unregisterForEvent(String aEventName) {
+ // Send the "register" started event to the client
+ receiveEvent(aEventName, "SameThread: Unregister from receiving notifications for " + aEventName);
+
+ eventListeners.remove(aEventName);
+ }
+
+ /**
+ * This method is called whenever the EventProcessorService receives an Event
+ *
+ * @param aEventName The name of the Event received
+ * @param aEventData The Event data
+ */
+ private void receiveEvent(String aEventName, Object aEventData) {
+ // Get the listener for the Event
+ final ServiceReference<EventProcessorCallBack> callback = eventListeners.get(aEventName);
+ if (callback == null) {
+ //System.out.println("No registered listeners for " + aEventName);
+ return;
+ }
+
+ // Trigger the call back
+ // System.out.println("Notifying " + callback + " of event " + aEventName);
+ callback.getService().eventNotification(aEventName, aEventData);
+ // System.out.println("Done notify " + callback + " of event " + aEventName);
+ }
+
+ /**
+ * Shuts down the Event Processor
+ */
+ @Destroy
+ public void shutdown() {
+ System.out.println("Shutting down the EventProcessor");
+
+ // Clear list of call back locations as we don't want to send any more notifications
+ eventListeners.clear();
+
+ // Stop the Event Generators
+ for (EventGenerator generator : allEventGenerators) {
+ generator.stop();
+ }
+ }
+
+ /**
+ * Utility class for generating Events
+ */
+ private final class EventGenerator {
+ /**
+ * The Timer we are using to generate the events
+ */
+ private final Timer timer = new Timer();
+
+ /**
+ * Lock object to ensure that we can cancel the timer cleanly.
+ */
+ private final Object lock = new Object();
+
+ /**
+ * Constructor
+ *
+ * @param aEventName The name of the Event to generate
+ * @param frequencyInMilliseconds How frequently we should generate the Events
+ */
+ private EventGenerator(String aEventName, int frequencyInMilliseconds) {
+ timer.schedule(new EventGeneratorTimerTask(aEventName),
+ frequencyInMilliseconds,
+ frequencyInMilliseconds);
+ }
+
+ /**
+ * Stop this Event Generator
+ */
+ private void stop() {
+ synchronized (lock) {
+ timer.cancel();
+ }
+ }
+
+ /**
+ * The TimerTask that is invoked by the Timer for the EventGenerator
+ */
+ private final class EventGeneratorTimerTask extends TimerTask {
+ /**
+ * The name of the Event we should generate
+ */
+ private final String eventName;
+
+ /**
+ * Constructor
+ *
+ * @param aEventName The name of the Event we should generate
+ */
+ private EventGeneratorTimerTask(String aEventName) {
+ eventName = aEventName;
+ }
+
+ /**
+ * Timer calls this method and it will generate an Event
+ */
+
+ public void run() {
+ synchronized(lock) {
+ // System.out.println("Generating new event " + eventName);
+ receiveEvent(eventName, "Separate Thread Notification: " + UUID.randomUUID().toString());
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite
new file mode 100644
index 0000000000..b10f3bc771
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.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://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://callback" name="CallBackSeparateThreadTest">
+
+ <component name="CallBackSeparateThreadClient">
+ <implementation.java class="org.apache.tuscany.sca.itest.CallBackSeparateThreadClientImpl"/>
+ <reference name="aCallBackService" target="EventProcessorService"/>
+ </component>
+
+ <component name="EventProcessorService">
+ <implementation.java class="org.apache.tuscany.sca.itest.EventProcessorServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java
new file mode 100644
index 0000000000..c216cab1be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.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.itest;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This test case will attempt to trigger a call back using a separate thread
+ */
+public class CallBackSeparateThreadTestCase {
+
+ /**
+ * The Node we are using
+ */
+ private Node node;
+
+ /**
+ * The client the tests should use
+ */
+ private CallBackSeparateThreadClient aCallBackClient;
+
+ /**
+ * Run the call back in separate thread tests
+ */
+ @Test
+ public void testCallBackSeparateThread() {
+ aCallBackClient.runTests();
+ }
+
+ /**
+ * Load the Call back in separate thread composite and look up the client.
+ */
+
+ @Before
+ public void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("CallBackSeparateThreadTest.composite");
+ node = NodeFactory.newInstance().createNode("CallBackSeparateThreadTest.composite", new Contribution("c1", location));
+ node.start();
+ aCallBackClient = node.getService(CallBackSeparateThreadClient.class, "CallBackSeparateThreadClient");
+ }
+
+ /**
+ * Shutdown the SCA node
+ */
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/pom.xml b/sandbox/sebastien/java/embed/itest/callback-two-composites/pom.xml
new file mode 100644
index 0000000000..339b2179a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-callback-two-composites</artifactId>
+ <name>Apache Tuscany SCA iTest Callback Two Composites</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <properties>
+ <was.ant.script>${basedir}/../build-was-integration.xml</was.ant.script>
+ <was.python.script>${basedir}/../wasAdmin.py</was.python.script>
+ </properties>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java
new file mode 100644
index 0000000000..291a72b9d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+/**
+ *
+ */
+public interface CallBackBasicCallBack {
+
+ void callBackMessage(String aString);
+
+ void callBackIncrement(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java
new file mode 100644
index 0000000000..19f366c423
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CallBackBasicClient {
+
+ void run();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java
new file mode 100644
index 0000000000..4bb6b29a8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test;
+
+import org.junit.Assert;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackBasicClient.class)
+public class CallBackBasicClientImpl implements CallBackBasicClient, CallBackBasicCallBack {
+
+ @Reference
+ protected CallBackBasicService aCallBackService;
+ private static String returnMessage = null;
+ private static int callBackCount = 0;
+ private static Object monitor = new Object();
+
+ public void run() {
+
+ // This tests basic callback patterns.
+
+ // Test1 is the basic callback where the target calls back prior to
+ // returning to the client.
+ test1a();
+
+ // Test2 is where the target does not call back to the client.
+ test1b();
+
+ // Test3 is where the target calls back multiple times to the client.
+ test1c();
+ }
+
+ private void test1a() {
+ aCallBackService.knockKnock("Knock Knock");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackBasicITest - test1a", "Who's There", this.getReturnMessage());
+
+ }
+
+ private void test1b() {
+ aCallBackService.noCallBack("No Reply Desired");
+ Assert.assertEquals("CallBackBasicITest - test1b", 1, 1);
+ }
+
+ private void test1c() {
+ aCallBackService.multiCallBack("Call me back 3 times");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (this.getCallBackCount() < 3 && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackBasicITest - test1c", 3, this.getCallBackCount());
+ }
+
+ public String getReturnMessage() {
+ return returnMessage;
+ }
+
+ public void setReturnMessage(String aReturnMessage) {
+ returnMessage = aReturnMessage;
+ }
+
+ public int getCallBackCount() {
+ return callBackCount;
+ }
+
+ public void incrementCallBackCount() {
+ callBackCount++;
+ }
+
+ public void callBackMessage(String aString) {
+ System.out.println("Entering callback callBackMessage: " + aString);
+ synchronized (monitor) {
+ this.setReturnMessage(aString);
+ monitor.notify();
+ }
+ }
+
+ public void callBackIncrement(String aString) {
+ System.out.println("Entering callback increment: " + aString);
+ synchronized (monitor) {
+ this.incrementCallBackCount();
+ monitor.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java
new file mode 100644
index 0000000000..5396879e83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.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.sca.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(CallBackBasicCallBack.class)
+/**
+ *
+ */
+public interface CallBackBasicService {
+
+ void knockKnock(String aString);
+
+ void noCallBack(String aString);
+
+ void multiCallBack(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java
new file mode 100644
index 0000000000..07010f61e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackBasicService.class)
+public class CallBackBasicServiceImpl implements CallBackBasicService {
+
+ @Callback
+ protected CallBackBasicCallBack callback;
+
+ public void knockKnock(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ callback.callBackMessage("Who's There");
+ System.out.println("CallBackBasicServiceImpl response sent");
+
+ }
+
+ public void multiCallBack(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ callback.callBackIncrement("Who's There 1");
+ System.out.println("CallBackBasicServiceImpl response sent");
+ callback.callBackIncrement("Who's There 2");
+ System.out.println("CallBackBasicServiceImpl response sent");
+ callback.callBackIncrement("Who's There 3");
+ System.out.println("CallBackBasicServiceImpl response sent");
+
+ }
+
+ public void noCallBack(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ // System.out.println("CallBackBasicServiceImpl No response desired");
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/CallBackReference.composite b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/CallBackReference.composite
new file mode 100644
index 0000000000..477ef7391f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/CallBackReference.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://callback"
+ name="CallBackReferenceTest">
+
+ <component name="CallBackBasicClient">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackBasicClientImpl"/>
+ <reference name="aCallBackService" target="CallBackBasicService">
+ <callback>
+ <binding.ws uri="http://localhost:8084/aCallBackService"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/CallBackService.composite b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/CallBackService.composite
new file mode 100644
index 0000000000..c3f0f5bc81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/CallBackService.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://callback"
+ name="CallBackServiceTest">
+
+ <component name="CallBackBasicService">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackBasicServiceImpl"/>
+ <service name="CallBackBasicService">
+ <binding.ws uri="http://localhost:8085/CallBackBasicService"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..11d737e701
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://callback">
+ <deployable composite="t:CallBackReferenceTest" />
+ <deployable composite="t:CallBackServiceTest" />
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-composites/src/test/java/org/apache/tuscany/sca/test/CallBackTwoCompositesTestCase.java b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/test/java/org/apache/tuscany/sca/test/CallBackTwoCompositesTestCase.java
new file mode 100644
index 0000000000..92fc8f4bef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-composites/src/test/java/org/apache/tuscany/sca/test/CallBackTwoCompositesTestCase.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 org.apache.tuscany.sca.test;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CallBackTwoCompositesTestCase {
+
+ private static Node node;
+ private CallBackBasicClient aCallBackClient;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ node = NodeFactory.newInstance().createNode(new Contribution("c1", "./target/classes"));
+ node.start();
+
+ aCallBackClient = node.getService(CallBackBasicClient.class, "CallBackBasicClient");
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCallBackBasic() {
+ aCallBackClient.run();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/pom.xml b/sandbox/sebastien/java/embed/itest/callback-two-nodes/pom.xml
new file mode 100644
index 0000000000..bacd95d894
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/pom.xml
@@ -0,0 +1,86 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-callback-two-nodes</artifactId>
+ <name>Apache Tuscany SCA iTest Callback Two Nodes</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <properties>
+ <was.ant.script>${basedir}/../build-was-integration.xml</was.ant.script>
+ <was.python.script>${basedir}/../wasAdmin.py</was.python.script>
+ </properties>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java
new file mode 100644
index 0000000000..291a72b9d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+/**
+ *
+ */
+public interface CallBackBasicCallBack {
+
+ void callBackMessage(String aString);
+
+ void callBackIncrement(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java
new file mode 100644
index 0000000000..19f366c423
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CallBackBasicClient {
+
+ void run();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java
new file mode 100644
index 0000000000..4bb6b29a8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test;
+
+import org.junit.Assert;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackBasicClient.class)
+public class CallBackBasicClientImpl implements CallBackBasicClient, CallBackBasicCallBack {
+
+ @Reference
+ protected CallBackBasicService aCallBackService;
+ private static String returnMessage = null;
+ private static int callBackCount = 0;
+ private static Object monitor = new Object();
+
+ public void run() {
+
+ // This tests basic callback patterns.
+
+ // Test1 is the basic callback where the target calls back prior to
+ // returning to the client.
+ test1a();
+
+ // Test2 is where the target does not call back to the client.
+ test1b();
+
+ // Test3 is where the target calls back multiple times to the client.
+ test1c();
+ }
+
+ private void test1a() {
+ aCallBackService.knockKnock("Knock Knock");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackBasicITest - test1a", "Who's There", this.getReturnMessage());
+
+ }
+
+ private void test1b() {
+ aCallBackService.noCallBack("No Reply Desired");
+ Assert.assertEquals("CallBackBasicITest - test1b", 1, 1);
+ }
+
+ private void test1c() {
+ aCallBackService.multiCallBack("Call me back 3 times");
+ int count = 0;
+
+ //
+ // If we can't get a response in 30 seconds consider this a failure
+ //
+
+ synchronized (monitor) {
+ while (this.getCallBackCount() < 3 && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ Assert.assertEquals("CallBackBasicITest - test1c", 3, this.getCallBackCount());
+ }
+
+ public String getReturnMessage() {
+ return returnMessage;
+ }
+
+ public void setReturnMessage(String aReturnMessage) {
+ returnMessage = aReturnMessage;
+ }
+
+ public int getCallBackCount() {
+ return callBackCount;
+ }
+
+ public void incrementCallBackCount() {
+ callBackCount++;
+ }
+
+ public void callBackMessage(String aString) {
+ System.out.println("Entering callback callBackMessage: " + aString);
+ synchronized (monitor) {
+ this.setReturnMessage(aString);
+ monitor.notify();
+ }
+ }
+
+ public void callBackIncrement(String aString) {
+ System.out.println("Entering callback increment: " + aString);
+ synchronized (monitor) {
+ this.incrementCallBackCount();
+ monitor.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java
new file mode 100644
index 0000000000..5396879e83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.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.sca.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(CallBackBasicCallBack.class)
+/**
+ *
+ */
+public interface CallBackBasicService {
+
+ void knockKnock(String aString);
+
+ void noCallBack(String aString);
+
+ void multiCallBack(String aString);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java
new file mode 100644
index 0000000000..07010f61e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.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 org.apache.tuscany.sca.test;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CallBackBasicService.class)
+public class CallBackBasicServiceImpl implements CallBackBasicService {
+
+ @Callback
+ protected CallBackBasicCallBack callback;
+
+ public void knockKnock(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ callback.callBackMessage("Who's There");
+ System.out.println("CallBackBasicServiceImpl response sent");
+
+ }
+
+ public void multiCallBack(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ callback.callBackIncrement("Who's There 1");
+ System.out.println("CallBackBasicServiceImpl response sent");
+ callback.callBackIncrement("Who's There 2");
+ System.out.println("CallBackBasicServiceImpl response sent");
+ callback.callBackIncrement("Who's There 3");
+ System.out.println("CallBackBasicServiceImpl response sent");
+
+ }
+
+ public void noCallBack(String aString) {
+
+ System.out.println("CallBackBasicServiceImpl message received: " + aString);
+ // System.out.println("CallBackBasicServiceImpl No response desired");
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/CallBackReference.composite b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/CallBackReference.composite
new file mode 100644
index 0000000000..477ef7391f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/CallBackReference.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://callback"
+ name="CallBackReferenceTest">
+
+ <component name="CallBackBasicClient">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackBasicClientImpl"/>
+ <reference name="aCallBackService" target="CallBackBasicService">
+ <callback>
+ <binding.ws uri="http://localhost:8084/aCallBackService"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/CallBackService.composite b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/CallBackService.composite
new file mode 100644
index 0000000000..c3f0f5bc81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/CallBackService.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://callback"
+ name="CallBackServiceTest">
+
+ <component name="CallBackBasicService">
+ <implementation.java class="org.apache.tuscany.sca.test.CallBackBasicServiceImpl"/>
+ <service name="CallBackBasicService">
+ <binding.ws uri="http://localhost:8085/CallBackBasicService"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..efef032b8f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://callback">
+ <deployable composite="t:CallBackTwoNodesReferenceTest" />
+ <deployable composite="t:CallBackTwoNodesServiceTest" />
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/test/java/org/apache/tuscany/sca/test/CallBackTwoNodesTestCase.java b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/test/java/org/apache/tuscany/sca/test/CallBackTwoNodesTestCase.java
new file mode 100644
index 0000000000..19e818b68f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/callback-two-nodes/src/test/java/org/apache/tuscany/sca/test/CallBackTwoNodesTestCase.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.test;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CallBackTwoNodesTestCase {
+
+ private static Node node1;
+ private static Node node2;
+ private CallBackBasicClient aCallBackClient;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.getInstance();
+
+ NodeConfiguration configuration = factory.createNodeConfiguration();
+ configuration.setDomainURI("tuscany:default");
+ configuration.setURI("node1");
+ configuration.addContribution("c1", "./target/classes");
+ configuration.addDeploymentComposite("c1","CallBackService.composite");
+
+ //node1 = factory.createNode("CallBackService.composite", new Contribution("c1", "./target/classes"));
+ node1 = factory.createNode(configuration);
+ node1.start();
+
+ configuration = factory.createNodeConfiguration();
+ configuration.setDomainURI("tuscany:default");
+ configuration.setURI("node2");
+ configuration.addContribution("c1", "./target/classes");
+ configuration.addDeploymentComposite("c1","CallBackReference.composite");
+
+ //node2 = factory.newInstance().createNode("CallBackReference.composite", new Contribution("c1", "./target/classes"));
+ node2 = factory.createNode(configuration);
+ node2.start();
+
+ aCallBackClient = node2.getService(CallBackBasicClient.class, "CallBackBasicClient");
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCallBackTwoNodes() {
+ aCallBackClient.run();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node2.stop();
+ node1.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/pom.xml b/sandbox/sebastien/java/embed/itest/component-type/pom.xml
new file mode 100644
index 0000000000..4dc05305af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-component-type</artifactId>
+ <name>Apache Tuscany SCA iTest Component Type</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/AddService.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 calculator;
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..8b6fe066a6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/AddServiceImpl.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 calculator;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..6f978bd9be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorClient.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+ String location = ContributionLocationHelper.getContributionLocation("Calculator.composite");
+ Node node = NodeFactory.newInstance().createNode("Calculator.composite", new Contribution("c1", location));
+ node.start();
+
+ CalculatorService calculatorService =
+ node.getService(CalculatorService.class, "CalculatorServiceComponent/CalculatorService");
+
+ // Calculate
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..c89043276e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorService.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 calculator;
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..1209ac128a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.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 calculator;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..f7ac0b7287
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..b7dca792b2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..77b128ab8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/Calculator.composite b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..fc08333544
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/Calculator.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent/AddService"/>
+ <reference name="subtractService" target="SubtractServiceComponent/SubtractService"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent/MultiplyService"/>
+ <reference name="divideService" target="DivideServiceComponent/DivideService"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType
new file mode 100644
index 0000000000..a6babbfc2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="AddService">
+ <interface.java interface="calculator.AddService"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType
new file mode 100644
index 0000000000..b3a4ac83e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <reference name="addService">
+ <interface.java interface="calculator.AddService"/>
+ </reference>
+
+ <reference name="subtractService">
+ <interface.java interface="calculator.SubtractService"/>
+ </reference>
+
+ <reference name="multiplyService">
+ <interface.java interface="calculator.MultiplyService"/>
+ </reference>
+
+ <reference name="divideService">
+ <interface.java interface="calculator.DivideService"/>
+ </reference>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType
new file mode 100644
index 0000000000..9238359f76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="DivideService">
+ <interface.java interface="calculator.DivideService"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType
new file mode 100644
index 0000000000..2fadb54bf1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="MultiplyService">
+ <interface.java interface="calculator.MultiplyService"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType
new file mode 100644
index 0000000000..6ca2df2928
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="SubtractService">
+ <interface.java interface="calculator.SubtractService"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/component-type/src/test/java/calculator/CalculatorTestCase.java b/sandbox/sebastien/java/embed/itest/component-type/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..ac3ccc3d08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/component-type/src/test/java/calculator/CalculatorTestCase.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 calculator;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorTestCase {
+
+ private CalculatorService calculatorService;
+ private Node node;
+
+ @Before
+ public void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("Calculator.composite");
+ node = NodeFactory.newInstance().createNode("Calculator.composite", new Contribution("c1", location));
+ node.start();
+ calculatorService = node.getService(CalculatorService.class, "CalculatorServiceComponent/CalculatorService");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ // Calculate
+ /*
+ assertEquals(calculatorService.add(3, 2), 5.0, 0.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0, 0.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0, 0.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5, 0.0);
+ */
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-folder/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-folder/pom.xml
new file mode 100644
index 0000000000..35e7bb03ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-folder/pom.xml
@@ -0,0 +1,46 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-folder</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution Folder</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..b4c677b371
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/java/calculator/CalculatorService.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 calculator;
+
+public interface CalculatorService {
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java
new file mode 100644
index 0000000000..ef2a43c766
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package test;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * Test SCADomain.newInstance and invocation of a service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionFolderTestCase extends TestCase {
+
+ private Node node;
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode(new Contribution("foo", "src/test/resources/repository"));
+ node.start();
+ }
+
+ public void testInvoke() throws Exception {
+ CalculatorService service = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+ assertEquals(3.0, service.add(1, 2));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite
new file mode 100644
index 0000000000..05bea57944
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8d6012e5c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar
new file mode 100644
index 0000000000..fe264693fe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar
new file mode 100644
index 0000000000..d5dfb647d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository3/contribution.zip b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository3/contribution.zip
new file mode 100644
index 0000000000..b293aa4bcc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-folder/src/test/resources/repository3/contribution.zip
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/pom.xml
new file mode 100644
index 0000000000..842a7ca47a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/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-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-export-composite</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution Export</name>
+
+<dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java
new file mode 100644
index 0000000000..669821261c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.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 hello;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * This is the business interface of the Hello service.
+ */
+@Remotable
+public interface Hello {
+
+ public String getGreetings(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java
new file mode 100644
index 0000000000..ff9f6e75f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.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 hello;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(Hello.class)
+public class HelloImpl implements Hello {
+
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..bea6f39932
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,25 @@
+<?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"
+ targetNamespace="http://hello"
+ xmlns:hello="http://hello">
+ <deployable composite="hello:hello"/>
+ <export namespace="http://hello"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/resources/hello.composite b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/resources/hello.composite
new file mode 100644
index 0000000000..aeeab337fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/main/resources/hello.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://hello"
+ xmlns:hello="http://hello"
+ name="hello">
+
+ <service name="HelloService" promote="HelloServiceComponent"/>
+
+ <component name="HelloServiceComponent">
+ <implementation.java class="hello.HelloImpl" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java
new file mode 100644
index 0000000000..44614f243a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.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.sca.test.contribution;
+
+import hello.Hello;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+
+/**
+ * Tests that the helloworld server is available
+ */
+public class HelloTestCase extends TestCase {
+ private ClassLoader cl;
+ private EmbeddedSCADomain domain;
+
+ @Override
+ protected void setUp() throws Exception {
+ // Create a test embedded SCA domain
+ cl = getClass().getClassLoader();
+ domain = new EmbeddedSCADomain(cl, "http://localhost");
+
+ // Start the domain
+ domain.start();
+
+ // Contribute the SCA contribution
+ ContributionService contributionService = domain.getContributionService();
+
+ URL helloURL = getContributionURL(Hello.class);
+
+ // File helloContrib = new File("./target/classes/");
+ // URL helloURL = helloContrib.toURL();
+ Contribution consumerContribution =
+ contributionService.contribute("http://import-export/hello", helloURL, false);
+ Composite consumerComposite = consumerContribution.getDeployables().get(0);
+ domain.getDomainComposite().getIncludes().add(consumerComposite);
+ domain.buildComposite(consumerComposite);
+
+ // Start Components from my composite
+ domain.getCompositeActivator().activate(consumerComposite);
+ domain.getCompositeActivator().start(consumerComposite);
+ }
+
+ private URL getContributionURL(Class<?> cls) throws MalformedURLException {
+ String flag = "/" + cls.getName().replace('.', '/') + ".class";
+ URL url = cls.getResource(flag);
+ String root = url.toExternalForm();
+ root = root.substring(0, root.length() - flag.length() + 1);
+ if (root.startsWith("jar:") && root.endsWith("!/")) {
+ root = root.substring(4, root.length() - 2);
+ }
+ url = new URL(root);
+ return url;
+ }
+
+ public void testHello() throws IOException {
+ Hello hello = domain.getService(Hello.class, "HelloServiceComponent");
+ assertNotNull(hello);
+ assertEquals(hello.getGreetings("lresende"), "Hello lresende");
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/pom.xml
new file mode 100644
index 0000000000..a863a7843f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/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-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-export-java</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution Java Export</name>
+
+<dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..268d90e910
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-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/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e11adcec7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://helloworld"
+ xmlns:helloworld="http://helloworld">
+ <export.java package="helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..5a14b41650
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/pom.xml
new file mode 100644
index 0000000000..d8133c4acc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-export-resource</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution Resource Export</name>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..f11eacb416
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://store"
+ xmlns:helloworld="http://store">
+ <export.resource uri="ufservices/store.html"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html
new file mode 100644
index 0000000000..1ff281373a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html
@@ -0,0 +1,27 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+<title>Store</TITLE>
+</head>
+
+<body>
+<h1>Sample Store Page</h1>
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/pom.xml
new file mode 100644
index 0000000000..7c504aee50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-export-wsdl</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution WSDL Export</name>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8254b667f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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"
+ targetNamespace="http://helloworld"
+ xmlns:helloworld="http://helloworld">
+ <export namespace="http://helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..0172fb2c7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl
@@ -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.
+-->
+
+<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 xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns2="http://helloworld2"
+ targetNamespace="http://helloworld"
+ elementFormDefault="qualified">
+
+ <xsd:import namespace="http://helloworld2" schemaLocation="helloworld.xsd" />
+
+ <element name="getGreetings" type="tns2:getGreetingsType"/>
+ <element name="getGreetingsResponse" type="tns2:getGreetingsResponseType"/>
+
+ </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:8085/HelloWorldServiceComponent"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd
new file mode 100644
index 0000000000..d49e2ead99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd
@@ -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.
+-->
+<schema targetNamespace="http://helloworld2"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://helloworld2">
+
+ <complexType name="getGreetingsType">
+ <sequence>
+ <element name="name" type="string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="getGreetingsResponseType">
+ <sequence>
+ <element name="getGreetingsReturn" type="string"/>
+ </sequence>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/pom.xml
new file mode 100644
index 0000000000..7fdc6b68e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/pom.xml
@@ -0,0 +1,73 @@
+<?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-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-import-composite</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution Import</name>
+
+<dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-contribution-export-composite</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..c062afaed0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.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 helloworld;
+
+import hello.Hello;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+ @Reference
+ protected Hello helloServiceRef;
+
+ public String getGreetings(String name) {
+ return helloServiceRef.getGreetings(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java
new file mode 100644
index 0000000000..e03ed4dc25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.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 java.io.IOException;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * This server program shows how to create an SCA runtime, and start it which
+ * activates the helloworld Web service endpoint.
+ */
+public class HelloWorldServer {
+
+ public static void main(String[] args) {
+
+ SCADomain scaDomain = SCADomain.newInstance("helloworldws.composite");
+
+ try {
+ System.out.println("HelloWorld server started (press enter to shutdown)");
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ scaDomain.close();
+ System.out.println("HelloWorld server stopped");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..268d90e910
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/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/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..130aa91093
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml
@@ -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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://helloworld"
+ xmlns:helloworld="http://helloworld"
+ xmlns:hello="http://hello">
+ <deployable composite="helloworld:helloworldws"/>
+ <import namespace="http://hello"/>
+ <!-- import namespace="http://hello" location="http://import-export/contrib-composite"/ -->
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..0172fb2c7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl
@@ -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.
+-->
+
+<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 xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns2="http://helloworld2"
+ targetNamespace="http://helloworld"
+ elementFormDefault="qualified">
+
+ <xsd:import namespace="http://helloworld2" schemaLocation="helloworld.xsd" />
+
+ <element name="getGreetings" type="tns2:getGreetingsType"/>
+ <element name="getGreetingsResponse" type="tns2:getGreetingsResponseType"/>
+
+ </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:8085/HelloWorldServiceComponent"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd
new file mode 100644
index 0000000000..d49e2ead99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd
@@ -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.
+-->
+<schema targetNamespace="http://helloworld2"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://helloworld2">
+
+ <complexType name="getGreetingsType">
+ <sequence>
+ <element name="name" type="string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="getGreetingsResponseType">
+ <sequence>
+ <element name="getGreetingsReturn" type="string"/>
+ </sequence>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite
new file mode 100644
index 0000000000..44ceba1240
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite
@@ -0,0 +1,39 @@
+<?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://helloworld"
+ xmlns:helloworld="http://helloworld"
+ xmlns:hello="http://hello"
+ name="helloworldws">
+
+ <component name="SourceHelloServiceComponent">
+ <implementation.composite name="hello:hello"/>
+ </component>
+
+ <component name="HelloWorldServiceComponent">
+ <service name="HelloWorldService">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService"/>
+ </service>
+ <implementation.java class="helloworld.HelloWorldImpl" />
+ <reference name="helloServiceRef" target="SourceHelloServiceComponent/HelloService"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java
new file mode 100644
index 0000000000..3cc6784eca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.contribution;
+
+import hello.Hello;
+import helloworld.HelloWorldService;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+
+/**
+ * Tests that the helloworld server is available
+ */
+public class HelloWorldServerTestCase extends TestCase {
+ private ClassLoader cl;
+ private EmbeddedSCADomain domain;
+ private Contribution helloWorldContribution;
+ private Contribution compositeContribution;
+
+ @Override
+ protected void setUp() throws Exception {
+ //Create a test embedded SCA domain
+ cl = getClass().getClassLoader();
+ domain = new EmbeddedSCADomain(cl, "http://localhost");
+
+ //Start the domain
+ domain.start();
+
+ // Contribute the SCA contribution
+ ContributionService contributionService = domain.getContributionService();
+
+ // File compositeContribLocation = new File("../export-composite/target/classes");
+ // URL compositeContribURL = compositeContribLocation.toURL();
+ URL compositeContribURL = getContributionURL(Hello.class);
+ compositeContribution =
+ contributionService.contribute("http://import-export/export-composite", compositeContribURL, false);
+ for (Composite deployable : compositeContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+// File helloWorldContribLocation = new File("./target/classes/");
+// URL helloWorldContribURL = helloWorldContribLocation.toURL();
+ URL helloWorldContribURL = getContributionURL(HelloWorldService.class);
+ helloWorldContribution =
+ contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
+ for (Composite deployable : helloWorldContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+ // Start Components from my composite
+ for (Composite deployable : helloWorldContribution.getDeployables()) {
+ domain.getCompositeActivator().activate(deployable);
+ domain.getCompositeActivator().start(deployable);
+ }
+ }
+
+ private URL getContributionURL(Class<?> cls) throws MalformedURLException {
+ String flag = "/" + cls.getName().replace('.', '/') + ".class";
+ URL url = cls.getResource(flag);
+ String root = url.toExternalForm();
+ root = root.substring(0, root.length() - flag.length() + 1);
+ if (root.startsWith("jar:") && root.endsWith("!/")) {
+ root = root.substring(4, root.length() - 2);
+ }
+ url = new URL(root);
+ return url;
+ }
+
+ public void testPing() throws IOException {
+ new Socket("127.0.0.1", 8085);
+ }
+
+ public void testServiceCall() throws IOException {
+ HelloWorldService helloWorldService =
+ domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
+ assertNotNull(helloWorldService);
+
+ assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ ContributionService contributionService = domain.getContributionService();
+
+ // Remove the contribution from the in-memory repository
+ contributionService.remove("http://import-export/helloworld");
+ contributionService.remove("http://import-export/export-composite");
+
+ //Stop Components from my composite
+ for (Composite deployable : helloWorldContribution.getDeployables()) {
+ domain.getCompositeActivator().stop(deployable);
+ domain.getCompositeActivator().deactivate(deployable);
+ }
+
+ domain.stop();
+ domain.close();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/pom.xml
new file mode 100644
index 0000000000..a0fac8b806
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/pom.xml
@@ -0,0 +1,73 @@
+<?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-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-import-java</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution Java Import</name>
+
+<dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-contribution-export-java</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..0de3c70303
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-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/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..224e2c4d79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,25 @@
+<?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"
+ targetNamespace="http://helloworld"
+ xmlns:helloworld="http://helloworld">
+ <deployable composite="helloworld:helloworldws"/>
+ <import.java package="helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite
new file mode 100644
index 0000000000..a53117e72f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite
@@ -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"
+ targetNamespace="http://helloworld"
+ xmlns:helloworld="http://helloworld"
+ name="helloworldws">
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java
new file mode 100644
index 0000000000..9bc94525e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.contribution;
+
+import helloworld.HelloWorldImpl;
+import helloworld.HelloWorldService;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+
+/**
+ * Tests that the helloworld server is available
+ */
+public class HelloWorldServerTestCase extends TestCase {
+ private ClassLoader cl;
+ private EmbeddedSCADomain domain;
+ private Contribution helloWorldContribution;
+ private Contribution javaContribution;
+
+ @Override
+ protected void setUp() throws Exception {
+ //Create a test embedded SCA domain
+ cl = getClass().getClassLoader();
+ domain = new EmbeddedSCADomain(cl, "http://localhost");
+
+ //Start the domain
+ domain.start();
+
+ // Contribute the SCA contribution
+ ContributionService contributionService = domain.getContributionService();
+
+ //File javaContribLocation = new File("../export-java/target/classes");
+ //URL javaContribURL = javaContribLocation.toURL();
+ URL javaContribURL = getContributionURL(HelloWorldService.class);
+ javaContribution = contributionService.contribute("http://import-export/export-java", javaContribURL, false);
+ for (Composite deployable : javaContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+ //File helloWorldContribLocation = new File("./target/classes/");
+ //URL helloWorldContribURL = helloWorldContribLocation.toURL();
+ URL helloWorldContribURL = getContributionURL(HelloWorldImpl.class);
+ helloWorldContribution = contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
+ for (Composite deployable : helloWorldContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+ // Start Components from my composite
+ for (Composite deployable : helloWorldContribution.getDeployables()) {
+ domain.getCompositeActivator().activate(deployable);
+ domain.getCompositeActivator().start(deployable);
+ }
+ }
+
+ private URL getContributionURL(Class<?> cls) throws MalformedURLException {
+ String flag = "/" + cls.getName().replace('.', '/') + ".class";
+ URL url = cls.getResource(flag);
+ String root = url.toExternalForm();
+ root = root.substring(0, root.length() - flag.length() + 1);
+ if (root.startsWith("jar:") && root.endsWith("!/")) {
+ root = root.substring(4, root.length() - 2);
+ }
+ url = new URL(root);
+ return url;
+ }
+
+ public void testPing() throws IOException {
+ HelloWorldService helloWorldService =
+ domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
+ assertNotNull(helloWorldService);
+ assertEquals("Hello test", helloWorldService.getGreetings("test"));
+ }
+
+ public void testServiceCall() throws IOException {
+ HelloWorldService helloWorldService =
+ domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
+ assertNotNull(helloWorldService);
+
+ assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ ContributionService contributionService = domain.getContributionService();
+
+ // Remove the contribution from the in-memory repository
+ contributionService.remove("http://import-export/helloworld");
+ contributionService.remove("http://import-export/export-java");
+
+ // Stop Components from my composite
+ for (Composite deployable : helloWorldContribution.getDeployables()) {
+ domain.getCompositeActivator().stop(deployable);
+ domain.getCompositeActivator().deactivate(deployable);
+ }
+
+ domain.stop();
+
+ domain.close();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/pom.xml
new file mode 100644
index 0000000000..2cf8245ccb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/pom.xml
@@ -0,0 +1,102 @@
+<?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-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-import-resource</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution Resource Import</name>
+
+<dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-contribution-export-resource</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-resource-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-resource</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ac6d7becb3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,25 @@
+<?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"
+ targetNamespace="http://store"
+ xmlns:store="http://store">
+ <deployable composite="store:store"/>
+ <import.resource uri="ufservices/store.html"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/main/resources/store.composite b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/main/resources/store.composite
new file mode 100644
index 0000000000..bb5a7b764f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/main/resources/store.composite
@@ -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"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://store"
+ xmlns:helloworld="http://store"
+ name="store">
+
+ <component name="store">
+ <tuscany:implementation.resource location="ufservices/store.html"/>
+ <service name="Resource">
+ <tuscany:binding.http uri="http://127.0.0.1:8085"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/test/java/org/apache/tuscany/sca/test/contribution/StoreTestCase.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/test/java/org/apache/tuscany/sca/test/contribution/StoreTestCase.java
new file mode 100644
index 0000000000..1b7542b7d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-resource/src/test/java/org/apache/tuscany/sca/test/contribution/StoreTestCase.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.contribution;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+
+/**
+ * Tests that the helloworld server is available
+ */
+public class StoreTestCase extends TestCase {
+ private ClassLoader cl;
+ private EmbeddedSCADomain domain;
+ private Contribution storeContribution;
+ private Contribution resourceContribution;
+
+ @Override
+ protected void setUp() throws Exception {
+ //Create a test embedded SCA domain
+ cl = getClass().getClassLoader();
+ domain = new EmbeddedSCADomain(cl, "http://localhost");
+
+ //Start the domain
+ domain.start();
+
+ // Contribute the SCA contribution
+ ContributionService contributionService = domain.getContributionService();
+
+ URL javaContribURL = getContributionURL(cl, "ufservices/store.html");
+ resourceContribution = contributionService.contribute("http://import-export/export-resource", javaContribURL, false);
+ for (Composite deployable : resourceContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+ URL storeContributionURL = getContributionURL(cl, "store.composite");
+
+ storeContribution =
+ contributionService.contribute("http://import-export/store", storeContributionURL, false);
+ for (Composite deployable : storeContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+ // Start Components from my composite
+ for (Composite deployable : storeContribution.getDeployables()) {
+ domain.getCompositeActivator().activate(deployable);
+ domain.getCompositeActivator().start(deployable);
+ }
+ }
+
+ public void testPing() throws IOException {
+ new Socket("127.0.0.1", 8085);
+ }
+
+
+ @Override
+ public void tearDown() throws Exception {
+ ContributionService contributionService = domain.getContributionService();
+
+ // Remove the contribution from the in-memory repository
+ contributionService.remove("http://import-export/store");
+ contributionService.remove("http://import-export/export-resource");
+
+ // Stop Components from my composite
+ for (Composite deployable : storeContribution.getDeployables()) {
+ domain.getCompositeActivator().stop(deployable);
+ domain.getCompositeActivator().deactivate(deployable);
+ }
+
+ domain.stop();
+
+ domain.close();
+ }
+
+
+ /**
+ * Utility methods
+ */
+
+
+ private URL getContributionURL(ClassLoader cl, Class<?> cls) throws MalformedURLException {
+ String flag = "/" + cls.getName().replace('.', '/') + ".class";
+ URL url = cl.getResource(flag);
+ String root = url.toExternalForm();
+ root = root.substring(0, root.length() - flag.length() + 1);
+ if (root.startsWith("jar:") && root.endsWith("!/")) {
+ root = root.substring(4, root.length() - 2);
+ }
+ url = new URL(root);
+ return url;
+ }
+
+ private URL getContributionURL(ClassLoader cl, String uri) throws MalformedURLException {
+ URL url = cl.getResource(uri);
+ String root = url.toExternalForm();
+ root = root.substring(0, root.length() - uri.length());
+ if (root.startsWith("jar:") && root.endsWith("!/")) {
+ root = root.substring(4, root.length() - 2);
+ }
+ url = new URL(root);
+ return url;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/pom.xml
new file mode 100644
index 0000000000..a0d1b7d215
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/pom.xml
@@ -0,0 +1,73 @@
+<?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-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-import-wsdl</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution WSDL Import</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-contribution-export-wsdl</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..0de3c70303
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/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/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java
new file mode 100644
index 0000000000..e03ed4dc25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.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 java.io.IOException;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * This server program shows how to create an SCA runtime, and start it which
+ * activates the helloworld Web service endpoint.
+ */
+public class HelloWorldServer {
+
+ public static void main(String[] args) {
+
+ SCADomain scaDomain = SCADomain.newInstance("helloworldws.composite");
+
+ try {
+ System.out.println("HelloWorld server started (press enter to shutdown)");
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ scaDomain.close();
+ System.out.println("HelloWorld server stopped");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..268d90e910
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/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/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a47b9a71e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,25 @@
+<?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"
+ targetNamespace="http://helloworld"
+ xmlns:helloworld="http://helloworld">
+ <deployable composite="helloworld:helloworldws"/>
+ <import namespace="http://helloworld" location="http://import-export/export-wsdl"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite
new file mode 100644
index 0000000000..76ccf71fb8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite
@@ -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"
+ targetNamespace="http://helloworld"
+ xmlns:hw="http://helloworld"
+ name="helloworldws">
+
+ <component name="HelloWorldServiceComponent">
+ <service name="HelloWorldService">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService"/>
+ </service>
+ <implementation.java class="helloworld.HelloWorldImpl" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java
new file mode 100644
index 0000000000..66227eacaa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.contribution;
+
+import helloworld.HelloWorldService;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+
+/**
+ * Tests that the helloworld server is available
+ */
+public class HelloWorldServerTestCase extends TestCase {
+ private ClassLoader cl;
+ private EmbeddedSCADomain domain;
+ private Contribution wsdlContribution;
+ private Contribution consumerContribution;
+
+ @Override
+ protected void setUp() throws Exception {
+ // Create a test embedded SCA domain
+ cl = getClass().getClassLoader();
+ domain = new EmbeddedSCADomain(cl, "http://localhost");
+
+ //Start the domain
+ domain.start();
+
+ // Contribute the SCA contribution
+ ContributionService contributionService = domain.getContributionService();
+
+ // File wsdlContribLocation = new File("../export-wsdl/target/classes");
+ // URL wsdlContribURL = wsdlContribLocation.toURL();
+ URL wsdlContribURL = getContributionURL(getClass().getClassLoader(), "helloworld.wsdl");
+ wsdlContribution = contributionService.contribute("http://import-export/export-wsdl", wsdlContribURL, false);
+ for (Composite deployable : wsdlContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+ // File helloWorldContribLocation = new File("./target/classes/");
+ // URL helloWorldContribURL = helloWorldContribLocation.toURL();
+ URL helloWorldContribURL = getContributionURL(HelloWorldService.class);
+ consumerContribution =
+ contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
+ for (Composite deployable : consumerContribution.getDeployables()) {
+ domain.getDomainComposite().getIncludes().add(deployable);
+ domain.buildComposite(deployable);
+ }
+
+ // Start Components from my composite
+ for (Composite deployable : consumerContribution.getDeployables()) {
+ domain.getCompositeActivator().activate(deployable);
+ domain.getCompositeActivator().start(deployable);
+ }
+ }
+
+ public void testPing() throws IOException {
+ new Socket("127.0.0.1", 8085);
+ }
+
+ private URL getContributionURL(Class<?> cls) throws MalformedURLException {
+ String flag = "/" + cls.getName().replace('.', '/') + ".class";
+ URL url = cls.getResource(flag);
+ String root = url.toExternalForm();
+ root = root.substring(0, root.length() - flag.length() + 1);
+ if (root.startsWith("jar:") && root.endsWith("!/")) {
+ root = root.substring(4, root.length() - 2);
+ }
+ url = new URL(root);
+ return url;
+ }
+
+ private URL getContributionURL(ClassLoader cl, String flag) throws MalformedURLException {
+ URL url = cl.getResource(flag);
+ String root = url.toExternalForm();
+ root = root.substring(0, root.length() - flag.length());
+ if (root.startsWith("jar:") && root.endsWith("!/")) {
+ root = root.substring(4, root.length() - 2);
+ }
+ url = new URL(root);
+ // System.out.println(url);
+ return url;
+ }
+
+ public void testServiceCall() throws IOException {
+ HelloWorldService helloWorldService =
+ domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
+ assertNotNull(helloWorldService);
+
+ assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ ContributionService contributionService = domain.getContributionService();
+
+ // Remove the contribution from the in-memory repository
+ contributionService.remove("http://import-export/helloworld");
+ contributionService.remove("http://import-export/export-wsdl");
+
+ // Stop Components from my composite
+ for (Composite deployable : consumerContribution.getDeployables()) {
+ domain.getCompositeActivator().stop(deployable);
+ domain.getCompositeActivator().deactivate(deployable);
+ }
+
+ domain.stop();
+
+ domain.close();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-import-export/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-import-export/pom.xml
new file mode 100644
index 0000000000..e64ff002e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-import-export/pom.xml
@@ -0,0 +1,56 @@
+<?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-itest</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-import-export</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Contribution Import/Export Integration Tests</name>
+
+ <modules>
+ <module>export-composite</module>
+ <module>export-java</module>
+ <module>export-resource</module>
+ <module>export-wsdl</module>
+ <module>import-composite</module>
+ <module>import-java</module>
+ <module>import-resource</module>
+ <module>import-wsdl</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-zip/pom.xml b/sandbox/sebastien/java/embed/itest/contribution-zip/pom.xml
new file mode 100644
index 0000000000..ecffbc155a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-zip/pom.xml
@@ -0,0 +1,45 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-contribution-zip</artifactId>
+ <name>Apache Tuscany SCA iTest Contribution ZIP</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..b4c677b371
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/java/calculator/CalculatorService.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 calculator;
+
+public interface CalculatorService {
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java b/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java
new file mode 100644
index 0000000000..303e2a6d9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.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 org.apache.tuscany.sca.contribution.zip;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * Test SCADomain.newInstance and invocation of a service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionZIPTestCase extends TestCase {
+
+ private Node node;
+
+ @Override
+ protected void setUp() throws Exception {
+ node =
+ NodeFactory.newInstance().createNode(new Contribution("foo",
+ "src/test/resources/repository/contribution.zip"));
+ node.start();
+ }
+
+ public void testInvoke() throws Exception {
+ CalculatorService service = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+ assertEquals(3.0, service.add(1, 2));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/resources/repository/contribution.zip b/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/resources/repository/contribution.zip
new file mode 100644
index 0000000000..25476c2206
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/contribution-zip/src/test/resources/repository/contribution.zip
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/corba/pom.xml b/sandbox/sebastien/java/embed/itest/corba/pom.xml
new file mode 100644
index 0000000000..b6f8655924
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/pom.xml
@@ -0,0 +1,144 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-corba-binding</artifactId>
+ <name>Apache Tuscany SCA CORBA Binding Integration Tests</name>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-corba-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse-tns</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/sdo-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <id>generate-scenariofour-sdo</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <schemaFile>
+ ${basedir}/src/test/resources/scenariofour.xsd
+ </schemaFile>
+ <javaPackage>
+ org.apache.tuscany.sca.test.corba.scenariofour
+ </javaPackage>
+ <prefix>ScenarioFour</prefix>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java
new file mode 100644
index 0000000000..6c362b0062
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.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.sca.test.corba;
+
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.host.corba.jse.tns.TnsDefaultCorbaHost;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFive;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFiveComponent;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ * Tests usage of TNS JSE Corba host
+ */
+public class ScenarioFiveTestCase {
+
+ @Test
+ public void test_providedNameServer() {
+ TestCorbaHost.setCorbaHost(new TnsDefaultCorbaHost());
+ try {
+ // just make sure we can obtain and use the reference with success
+ Node node = NodeFactory.getInstance().createNode("ScenarioFive.composite", getClass().getClassLoader()).start();
+ ScenarioFive scenarioFive =
+ node.getService(ScenarioFiveComponent.class, "ScenarioFive").getScenarioFive();
+ scenarioFive.doNothing();
+ node.stop();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java
new file mode 100644
index 0000000000..da4644057e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourFactory;
+import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourSdo;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFour;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFourComponent;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFourException;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFourStruct;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ * Tests SCA default binding over CORBA binding
+ */
+public class ScenarioFourTestCase {
+
+ // note that those values are also used in resources/*.composite file
+ private static Node node;
+ private static ScenarioFourComponent scenarioFourComponent;
+ private static ScenarioFour scenarioFour;
+ private static TransientNameServer server;
+ private static final int ORB_INITIAL_PORT = 5080;
+
+ /**
+ * Initial configuration
+ */
+ @BeforeClass
+ public static void setUp() {
+ System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding", "{http://tuscany.apache.org/xmlns/sca/1.1}binding.corba");
+ TestCorbaHost.setCorbaHost(new DefaultCorbaHost());
+ try {
+ server = new TransientNameServer("localhost", ORB_INITIAL_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ Assert.fail("The naming server cannot be started");
+ }
+ // obtain node
+ node = NodeFactory.getInstance().createNode("ScenarioFour.composite", TestCorbaHost.class.getClassLoader()).start();
+ scenarioFourComponent = node.getService(ScenarioFourComponent.class, "ScenarioFour");
+ scenarioFour = scenarioFourComponent.getScenarioFour();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Test cleanup
+ */
+ @AfterClass
+ public static void tearDown() {
+ server.stop();
+ node.stop();
+ System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+ }
+
+ /**
+ * General tests for passing JAXB objects
+ */
+ @Test
+ public void test_generalJAXB() {
+ try {
+ ScenarioFourStruct input = new ScenarioFourStruct();
+ input.field1 = "Test";
+ input.field2 = 1;
+ input.field3 = new double[1];
+ ScenarioFourStruct output = scenarioFour.setStruct(input);
+ assertTrue(input.equals(output));
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Test for JAXB exceptions
+ */
+ @Test
+ public void test_exceptionsJAXB() {
+ try {
+ scenarioFour.exceptionTest();
+ fail();
+ } catch (ScenarioFourException e) {
+ assertTrue(ScenarioFourException.DEFAULT_CONTENT.equals(e.getContent()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * General test for passing SDO objects
+ */
+ @Test
+ public void test_generalSDO() {
+ try {
+ ScenarioFourSdo scenarioFourSdo = ScenarioFourFactory.INSTANCE.createScenarioFourSdo();
+ scenarioFourSdo.setMessage("Test1");
+ scenarioFourSdo.setSymbol("Test2");
+ ScenarioFourSdo result = scenarioFour.passScenarioFourStruct(scenarioFourSdo);
+ assertTrue(scenarioFourSdo.getMessage().equals(result.getMessage()) && scenarioFourSdo.getSymbol()
+ .equals(result.getSymbol()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests reusing local name server with multiple bindings
+ */
+ @Test
+ public void test_nameServerReuse() {
+ try {
+ ScenarioFour scenarioFour =
+ node.getService(ScenarioFourComponent.class, "ScenarioFourReuse").getScenarioFour();
+ ScenarioFourStruct struct = new ScenarioFourStruct();
+ scenarioFour.setStruct(struct);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioOneTestCase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioOneTestCase.java
new file mode 100644
index 0000000000..4b58fab1f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioOneTestCase.java
@@ -0,0 +1,373 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.test.corba.generated.Color;
+import org.apache.tuscany.sca.test.corba.generated.InnerStruct;
+import org.apache.tuscany.sca.test.corba.generated.RichStruct;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioOne;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioOneHelper;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioOneOperations;
+import org.apache.tuscany.sca.test.corba.generated.UnexpectedException;
+import org.apache.tuscany.sca.test.corba.generated.WrongColor;
+import org.apache.tuscany.sca.test.corba.types.ScenarioOneServant;
+import org.apache.tuscany.sca.test.corba.types.TColor;
+import org.apache.tuscany.sca.test.corba.types.TInnerStruct;
+import org.apache.tuscany.sca.test.corba.types.TRichStruct;
+import org.apache.tuscany.sca.test.corba.types.TScenarioOne;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextHelper;
+
+/**
+ * @version $Rev$ $Date$
+ * This test class contains three main tests:<br>
+ * 1. Tuscany is being used as a consumer of some non-Tuscany CORBA service<br>
+ * 2. Tuscany is being used as a service provider, which will be consumed by
+ * non-Tuscany CORBA client<br>
+ * 3. Tuscany is being used as a service provider, which will be consumed by
+ * Tuscany client<br>
+ * But that's not all, there are some other variations. Tuscany CORBA binding
+ * supports using Java interface generated by IDLJ, also it supports interfaces
+ * provided by user - I combined those cases in each test.<br>
+ */
+public class ScenarioOneTestCase {
+
+ // note that those values are also used in resources/*.composite file
+ private static int ORB_INITIAL_PORT = 5060;
+ private static String SERVICE_NAME = "ScenarioOne";
+
+ private static Node node;
+
+ private static TransientNameServer server;
+ private static ORB orb;
+
+ /**
+ * Sets up name service, creates and registers traditional CORBA service,
+ * obtains SCADomain
+ */
+ @BeforeClass
+ public static void setUp() {
+ TestCorbaHost.setCorbaHost(new DefaultCorbaHost());
+ try {
+ try {
+ server =
+ new TransientNameServer("localhost", ORB_INITIAL_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ Assert.fail("The naming server cannot be started");
+ }
+ orb = server.getORB();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+ NamingContext ncRef = NamingContextHelper.narrow(objRef);
+ NameComponent nc = new NameComponent(SERVICE_NAME, "");
+ NameComponent path[] = {nc};
+ ScenarioOne scenarioOne = new ScenarioOneServant();
+ ncRef.rebind(path, scenarioOne);
+ // obtain node
+ node = NodeFactory.getInstance().createNode("ScenarioOne.composite", TestCorbaHost.class.getClassLoader()).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Kills previously spawned name service.
+ */
+ @AfterClass
+ public static void tearDown() {
+ server.stop();
+ node.stop();
+ }
+
+ /**
+ * Creates nicely filled structure for user provided interface.
+ *
+ * @return
+ */
+ private static TRichStruct getTRichStruct() {
+ int[][] intArr = new int[][] { {1, 2}, {3, 4}};
+ TInnerStruct innerStruct = new TInnerStruct(intArr, "Test", TColor.green);
+ String[] strSeq = {"i", "Test"};
+ return new TRichStruct(innerStruct, strSeq, 1);
+
+ }
+
+ /**
+ * Creates nicely filled structure for generated interface.
+ *
+ * @return
+ */
+ private static RichStruct getRichStruct() {
+ int[][] intArr = new int[][] { {1, 2}, {3, 4}};
+ InnerStruct innerStruct2 = new InnerStruct(intArr, "Test", Color.green);
+ String[] strSeq = {"i", "Test"};
+ return new RichStruct(innerStruct2, strSeq, 1);
+ }
+
+ /**
+ * Compares String arrays
+ *
+ * @param arg1
+ * @param arg2
+ * @return
+ */
+ private boolean areSrringArraysEqual(String[] arg1, String[] arg2) {
+ try {
+ for (int i = 0; i < arg1.length; i++) {
+ if (!arg1[i].equals(arg2[i])) {
+ return false;
+ }
+ }
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Compares two dimensional int arrays
+ *
+ * @param arg1
+ * @param arg2
+ * @return
+ */
+ private boolean areTwoDimIntArraysEqual(int[][] arg1, int[][] arg2) {
+ try {
+ for (int i = 0; i < arg1.length; i++) {
+ for (int j = 0; j < arg1[i].length; j++) {
+ if (arg1[i][j] != arg2[i][j]) {
+ return false;
+ }
+ }
+ }
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean equalTo(TInnerStruct arg1, TInnerStruct arg2) {
+ return (arg1.color.value() == arg2.color.value() && arg1.stringField.equals(arg2.stringField) && areTwoDimIntArraysEqual(arg1.twoDimLongSequence,
+ arg2.twoDimLongSequence));
+ }
+
+ private boolean equalTo(InnerStruct arg1, InnerStruct arg2) {
+ return (arg1.color.value() == arg2.color.value() && arg1.stringField.equals(arg2.stringField) && areTwoDimIntArraysEqual(arg1.twoDimLongSequence,
+ arg2.twoDimLongSequence));
+ }
+
+ private boolean equalTo(TRichStruct arg1, TRichStruct arg2) {
+ return (equalTo(arg1.innerStruct, arg2.innerStruct) && arg2.longField == arg1.longField && areSrringArraysEqual(arg1.stringSequence,
+ arg2.stringSequence));
+ }
+
+ private boolean equalTo(RichStruct arg1, RichStruct arg2) {
+ return (equalTo(arg1.innerStruct, arg2.innerStruct) && arg2.longField == arg1.longField && areSrringArraysEqual(arg1.stringSequence,
+ arg2.stringSequence));
+ }
+
+ /**
+ * Helper method used several times for various components. Executes several
+ * tests using Tuscany reference binding. This helper uses generated Java
+ * interface.
+ *
+ * @param componentName
+ */
+ private void testClientUsingGeneratedInterface(String componentName) {
+ ScenarioOneOperations component = node.getService(ScenarioOneOperations.class, componentName);
+ RichStruct richStruct = getRichStruct();
+
+ try {
+ RichStruct result = component.setRichStruct(richStruct);
+ assertTrue(equalTo(result, richStruct));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ try {
+ richStruct.longField = 0;
+ component.setRichStruct(richStruct);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof UnexpectedException);
+ }
+
+ try {
+ richStruct.longField = 1;
+ richStruct.innerStruct.color = Color.red;
+ component.setRichStruct(richStruct);
+ } catch (Exception e) {
+ assertTrue(e instanceof WrongColor);
+ }
+ }
+
+ /**
+ * Helper method used several times for various components. Executes several
+ * tests using Tuscany reference binding. This helper uses user provided
+ * Java interface.
+ *
+ * @param componentName
+ */
+ private void testClientUsingUserProvidedInterface(String componentName) {
+ TScenarioOne component = node.getService(TScenarioOne.class, componentName);
+ TRichStruct tRichStruct = getTRichStruct();
+
+ try {
+ TRichStruct result = component.setRichStruct(tRichStruct);
+ assertTrue(equalTo(result, tRichStruct));
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ tRichStruct.longField = 0;
+ component.setRichStruct(tRichStruct);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof UnexpectedException);
+ }
+
+ try {
+ tRichStruct.longField = 1;
+ tRichStruct.innerStruct.color = TColor.red;
+ component.setRichStruct(tRichStruct);
+ } catch (Exception e) {
+ assertTrue(e instanceof WrongColor);
+ }
+ }
+
+ public void testServiceUsingGeneratedClient(String serviceName) {
+ try {
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+ NamingContext ncRef = NamingContextHelper.narrow(objRef);
+ NameComponent nc = new NameComponent(serviceName, "");
+ NameComponent path[] = {nc};
+ ScenarioOne so = ScenarioOneHelper.narrow(ncRef.resolve(path));
+
+ RichStruct richStruct = getRichStruct();
+ RichStruct result = so.setRichStruct(richStruct);
+ assertTrue(equalTo(result, richStruct));
+
+ try {
+ richStruct.innerStruct.color = Color.red;
+ result = so.setRichStruct(richStruct);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof WrongColor);
+ }
+
+ try {
+ richStruct.innerStruct.color = Color.green;
+ richStruct.longField = 0;
+ result = so.setRichStruct(richStruct);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof UnexpectedException);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Service is exposed in traditional way (using CORBA API from JDK).
+ * Reference is obtained from Tuscany.
+ */
+ @Test
+ public void test_TraditionalService_TuscanyClient() {
+
+ // Client is using user provided interface
+ testClientUsingUserProvidedInterface("ScenarioOne");
+
+ // Client is using generated interface
+ testClientUsingGeneratedInterface("ScenarioOneGenerated");
+ }
+
+ /**
+ * Service is exposed by Tuscany. Reference is obtained in traditional way.
+ * (using CORBA API from JDK)
+ *
+ * @throws Exception
+ */
+ @Test
+ public void test_TuscanyService_TraditionalClient() throws Exception {
+
+ // tests service which uses user provided interface
+ testServiceUsingGeneratedClient("ScenarioOneTuscany");
+
+ // tests service which uses generated interface
+ testServiceUsingGeneratedClient("ScenarioOneTuscanyGenerated");
+ }
+
+ /**
+ * Service is exposed by Tuscany. Reference is obtained from Tuscany. There
+ * are 4 combinations (basing on if we are using generated or user provided
+ * interfaces, both on service and reference side).
+ */
+ @Test
+ public void test_TuscanyService_TuscanyClient() {
+
+ // Client is using user provided interface, service is using user
+ // provided interface.
+ testClientUsingUserProvidedInterface("TU2TS1");
+
+ // Client is using user provided interface, service is using generated
+ // interface.
+ testClientUsingUserProvidedInterface("TU2TS2");
+
+ // Client is using generated interface, service is using user provided
+ // interface.
+ testClientUsingGeneratedInterface("TG2TS1");
+
+ // Client is using generated interface, service is using generated
+ // interface.
+ testClientUsingGeneratedInterface("TG2TS2");
+ }
+
+ /**
+ * Tests using reference obtained by corbaname URI
+ */
+ @Test
+ public void test_serviceAndReferenceByURI() {
+ testClientUsingUserProvidedInterface("UriBinding");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioSixTestCase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioSixTestCase.java
new file mode 100644
index 0000000000..3d3efb9c29
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioSixTestCase.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct;
+import org.apache.tuscany.sca.test.corba.generated.InnerUnion;
+import org.apache.tuscany.sca.test.corba.generated.RichUnion;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioSix;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioSixHelper;
+import org.apache.tuscany.sca.test.corba.types.ScenarioSixServant;
+import org.apache.tuscany.sca.test.corba.types.TAnnotatedStruct;
+import org.apache.tuscany.sca.test.corba.types.TInnerUnion;
+import org.apache.tuscany.sca.test.corba.types.TRichUnion;
+import org.apache.tuscany.sca.test.corba.types.TScenarioSix;
+import org.apache.tuscany.sca.test.corba.types.TScenarioSixComponent;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextHelper;
+
+/**
+ * Tests using enhanced Java interfaces (annotations)
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScenarioSixTestCase {
+
+ // note that those values are also used in resources/*.composite file
+ private static int ORB_INITIAL_PORT = 5050;
+ private static String SERVICE_NAME = "ScenarioSix";
+ private static String TUSCANY_SERVICE_NAME = "ScenarioSixTuscany";
+
+ private static Node node;
+
+ private static TransientNameServer server;
+ private static ORB orb;
+
+ /**
+ * Sets up name service, creates and registers traditional CORBA service,
+ * obtains SCADomain
+ */
+ @BeforeClass
+ public static void setUp() {
+ TestCorbaHost.setCorbaHost(new DefaultCorbaHost());
+ try {
+ try {
+ server =
+ new TransientNameServer("localhost", ORB_INITIAL_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ Assert.fail("The naming server cannot be started");
+ }
+ orb = server.getORB();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+ NamingContext ncRef = NamingContextHelper.narrow(objRef);
+ NameComponent nc = new NameComponent(SERVICE_NAME, "");
+ NameComponent path[] = {nc};
+ ScenarioSix scenarioSix = new ScenarioSixServant();
+ ncRef.rebind(path, scenarioSix);
+ // obtain node
+ node = NodeFactory.getInstance().createNode("ScenarioSix.composite", TestCorbaHost.class.getClassLoader()).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Kills previously spawned name service.
+ */
+ @AfterClass
+ public static void tearDown() {
+ server.stop();
+ node.stop();
+ }
+
+ private boolean areArraysEqual(String[][] arr1, String[][] arr2) {
+ for (int i = 0; i < arr1.length; i++) {
+ for (int j = 0; j < arr1[i].length; j++) {
+ if (!arr1[i][j].equals(arr2[i][j])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private String[][] getStringArray() {
+ String[][] result = { {"Hello", "World"}, {"Hi", "Again"}};
+ return result;
+ }
+
+ /**
+ * Tests passing arrays. Tuscany acts as a client, servant object is served
+ * in a traditional way
+ */
+ @Test
+ public void test_arraysPassing_tuscanyAsClient() {
+ try {
+ TScenarioSix ref = node.getService(TScenarioSixComponent.class, "ScenarioSix").getScenarioSix();
+ String[][] arrayArg = getStringArray();
+ String[][] arrayRes = ref.passStringArray(arrayArg);
+ assertTrue(areArraysEqual(arrayArg, arrayRes));
+ TAnnotatedStruct structArg = new TAnnotatedStruct();
+ structArg.stringArray = getStringArray();
+ TAnnotatedStruct structRes = ref.passAnnotatedStruct(structArg);
+ assertTrue(areArraysEqual(structArg.stringArray, structRes.stringArray));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests passing arrays. Servant object is served by Tuscany and it is
+ * accessed by traditional Corba client
+ */
+ @Test
+ public void test_arraysPassing_tuscanyAsService() {
+ try {
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+ NamingContext ncRef = NamingContextHelper.narrow(objRef);
+ NameComponent nc = new NameComponent(TUSCANY_SERVICE_NAME, "");
+ NameComponent path[] = {nc};
+ ScenarioSix ref = ScenarioSixHelper.narrow(ncRef.resolve(path));
+ String[][] stringArg = getStringArray();
+ String[][] stringRes = ref.passStringArray(stringArg);
+ assertTrue(areArraysEqual(stringArg, stringRes));
+ AnnotatedStruct structArg = new AnnotatedStruct();
+ structArg.stringArray = getStringArray();
+ AnnotatedStruct structRes = ref.passAnnotatedStruct(structArg);
+ assertTrue(areArraysEqual(structArg.stringArray, structRes.stringArray));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests passing unions. Tuscany acts as a client, servant object is served
+ * in a traditional way
+ */
+ @Test
+ public void test_unionsPassing_tuscanyAsClient() {
+ try {
+ TScenarioSix ref = node.getService(TScenarioSixComponent.class, "ScenarioSix").getScenarioSix();
+ TRichUnion arg = new TRichUnion();
+ TInnerUnion inner = new TInnerUnion();
+ inner.setY(10f);
+ arg.setIu(inner);
+ TRichUnion result = ref.passRichUnion(arg);
+ assertEquals(arg.getIu().getY(), result.getIu().getY(), 0.0f);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ try {
+ TScenarioSix ref = node.getService(TScenarioSixComponent.class, "ScenarioSix").getScenarioSix();
+ TRichUnion arg = new TRichUnion();
+ arg.setY(15f);
+ TRichUnion result = ref.passRichUnion(arg);
+ assertEquals(arg.getY(), result.getY(), 0.0f);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests passing unions. Servant object is served by Tuscany and it is
+ * accessed by traditional Corba client
+ */
+ @Test
+ public void test_unionsPassing_tuscanyAsService() {
+ try {
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+ NamingContext ncRef = NamingContextHelper.narrow(objRef);
+ NameComponent nc = new NameComponent(TUSCANY_SERVICE_NAME, "");
+ NameComponent path[] = {nc};
+ ScenarioSix ref = ScenarioSixHelper.narrow(ncRef.resolve(path));
+ RichUnion arg = new RichUnion();
+ InnerUnion inner = new InnerUnion();
+ inner.y(20f);
+ arg.iu(inner);
+ RichUnion result = ref.passRichUnion(arg);
+ assertEquals(arg.iu().y(), result.iu().y(), 0.0f);
+ arg = new RichUnion();
+ arg.y(15f);
+ result = ref.passRichUnion(arg);
+ assertEquals(arg.y(), result.y(), 0.0f);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioThreeTestCase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioThreeTestCase.java
new file mode 100644
index 0000000000..0190df2d1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioThreeTestCase.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.sca.test.corba;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.test.corba.types.TScenarioThree;
+import org.apache.tuscany.sca.test.corba.types.TScenarioThreeComponent;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ * Tests various mapping scenarios.
+ */
+public class ScenarioThreeTestCase {
+
+ // note that those values are also used in resources/*.composite file
+ private static int ORB_INITIAL_PORT = 5060;
+ private static Node node;
+ private static TransientNameServer server;
+
+ /**
+ * Sets up name service, creates and registers traditional CORBA service,
+ * obtains SCADomain
+ */
+ @BeforeClass
+ public static void setUp() {
+ TestCorbaHost.setCorbaHost(new DefaultCorbaHost());
+ try {
+ try {
+ server =
+ new TransientNameServer("localhost", ORB_INITIAL_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ Assert.fail("The naming server cannot be started");
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ // obtain node
+ node = NodeFactory.getInstance().createNode("ScenarioThree.composite", TestCorbaHost.class.getClassLoader()).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Kills previously spawned name service.
+ */
+ @AfterClass
+ public static void tearDown() {
+ server.stop();
+ node.stop();
+ }
+
+ /**
+ * Tests mapping for getters and setters
+ */
+ @Test
+ public void test_getterSetter() {
+ try {
+ TScenarioThree ref =
+ node.getService(TScenarioThreeComponent.class, "ScenarioThreeReference").getScenarioThree();
+ ref.getIntField();
+ ref.setIntField(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests mapping the same operation names but with different cases
+ */
+ @Test
+ public void test_nameCase() {
+ try {
+ TScenarioThree ref =
+ node.getService(TScenarioThreeComponent.class, "ScenarioThreeReference").getScenarioThree();
+ assertEquals(0, ref.caseDifferent());
+ assertEquals(1, ref.CaseDifferent());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests mappings for operations with overloaded names
+ */
+ @Test
+ public void test_overloadedNames() {
+ try {
+ TScenarioThree ref =
+ node.getService(TScenarioThreeComponent.class, "ScenarioThreeReference").getScenarioThree();
+ ref.overloadedName();
+ ref.overloadedName("");
+ ref.overloadedName("", 0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioTwoTestCase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioTwoTestCase.java
new file mode 100644
index 0000000000..af2c9ea711
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioTwoTestCase.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.sca.test.corba;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioTwo;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioTwoHelper;
+import org.apache.tuscany.sca.test.corba.types.ScenarioTwoServant;
+import org.apache.tuscany.sca.test.corba.types.TScenarioTwo;
+import org.apache.tuscany.sca.test.corba.types.TScenarioTwoComponent;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextHelper;
+
+/**
+ * @version $Rev$ $Date$
+ * Tests attribute get/set mapping using cooperation between traditional CORBA
+ * and Tuscany CORBA
+ */
+public class ScenarioTwoTestCase {
+
+ // note that those values are also used in resources/*.composite file
+ private static int ORB_INITIAL_PORT = 5060;
+
+ private static Node node;
+
+ private static TransientNameServer server;
+ private static ORB orb;
+ private static String TUSCANY_SERVICE_NAME = "ScenarioTwo";
+ private static String GENERATED_SERVICE_NAME = "ScenarioTwoGenerated";
+
+ /**
+ * Sets up name service, creates and registers traditional CORBA service,
+ * obtains SCADomain
+ */
+ @BeforeClass
+ public static void setUp() {
+ TestCorbaHost.setCorbaHost(new DefaultCorbaHost());
+ try {
+ try {
+ server =
+ new TransientNameServer("localhost", ORB_INITIAL_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ Assert.fail("The naming server cannot be started");
+ }
+ orb = server.getORB();
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+ NamingContext ncRef = NamingContextHelper.narrow(objRef);
+ NameComponent nc = new NameComponent(GENERATED_SERVICE_NAME, "");
+ NameComponent path[] = {nc};
+ ScenarioTwo scenarioTwo = new ScenarioTwoServant();
+ ncRef.rebind(path, scenarioTwo);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ // obtain node
+ node = NodeFactory.getInstance().createNode("ScenarioTwo.composite", TestCorbaHost.class.getClassLoader()).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Kills previously spawned name service.
+ */
+ @AfterClass
+ public static void tearDown() {
+ server.stop();
+ node.stop();
+ }
+
+ /**
+ * Tests using objects attribute (which is server in traditional way) by
+ * Tuscany CORBA binding
+ */
+ @Test
+ public void test_tuscanyGetSetAttribute() {
+ try {
+ TScenarioTwo ref = node.getService(TScenarioTwoComponent.class, "ScenarioTwo").getScenarioTwo();
+ String strVal = "Whatever";
+ ref.setStringField(strVal);
+ assertEquals(strVal, ref.getStringField());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests using objects attribute (which is served by Tuscany) in traditional
+ * way (by idlj generated code)
+ */
+ @Test
+ public void test_getneratedGetSetAttribute() {
+ try {
+ orb = server.getORB();
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+ NamingContext ncRef = NamingContextHelper.narrow(objRef);
+ NameComponent nc = new NameComponent(TUSCANY_SERVICE_NAME, "");
+ NameComponent path[] = {nc};
+ ScenarioTwo st = ScenarioTwoHelper.narrow(ncRef.resolve(path));
+ st.stringField("");
+ assertEquals("", st.stringField());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHost.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHost.java
new file mode 100644
index 0000000000..bd1ce8cb49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHost.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 org.apache.tuscany.sca.test.corba;
+
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.host.corba.CorbaHostException;
+import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost;
+import org.omg.CORBA.Object;
+
+/**
+ * @version $Rev$ $Date$
+ * Mock Corba host which proxies to configured Corba host
+ */
+public class TestCorbaHost implements CorbaHost {
+
+ private static CorbaHost corbaHost = new DefaultCorbaHost();
+
+ /**
+ * Configures environment to use given Corba host
+ *
+ * @param corbaHost Corba host to use
+ */
+ public static void setCorbaHost(CorbaHost corbaHost) {
+ TestCorbaHost.corbaHost = corbaHost;
+ }
+
+ public Object lookup(String arg0) throws CorbaHostException {
+ return TestCorbaHost.corbaHost.lookup(arg0);
+ }
+
+ public void registerServant(String arg0, Object arg1) throws CorbaHostException {
+ TestCorbaHost.corbaHost.registerServant(arg0, arg1);
+ }
+
+ public void unregisterServant(String arg0) throws CorbaHostException {
+ TestCorbaHost.corbaHost.unregisterServant(arg0);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHostModuleActivator.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHostModuleActivator.java
new file mode 100644
index 0000000000..3639ba812d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHostModuleActivator.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.test.corba;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint;
+
+/**
+ * @version $Rev$ $Date$
+ * Registers TestCorbaHost as a Corba host extension.
+ */
+public class TestCorbaHostModuleActivator implements ModuleActivator {
+ private ExtensionPointRegistry registry;
+
+ /**
+ *
+ */
+ public TestCorbaHostModuleActivator(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public void start() {
+ CorbaHostExtensionPoint chep = registry.getExtensionPoint(CorbaHostExtensionPoint.class);
+ chep.getCorbaHosts().add(0, new TestCorbaHost());
+ }
+
+ public void stop() {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStruct.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStruct.java
new file mode 100644
index 0000000000..abcec43d0e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStruct.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/AnnotatedStruct.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* sobota, 16 sierpieñ 2008 15:31:35 CEST
+*/
+
+public final class AnnotatedStruct implements org.omg.CORBA.portable.IDLEntity
+{
+ public String stringArray[][] = null;
+
+ public AnnotatedStruct ()
+ {
+ } // ctor
+
+ public AnnotatedStruct (String[][] _stringArray)
+ {
+ stringArray = _stringArray;
+ } // ctor
+
+} // class AnnotatedStruct
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHelper.java
new file mode 100644
index 0000000000..171a7919a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHelper.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* sobota, 16 sierpieñ 2008 15:31:35 CEST
+*/
+
+abstract public class AnnotatedStructHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/AnnotatedStruct/AnnotatedStruct:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ synchronized (org.omg.CORBA.TypeCode.class)
+ {
+ if (__typeCode == null)
+ {
+ if (__active)
+ {
+ return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [1];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.id (), "StringArray", _tcOf_members0);
+ _members0[0] = new org.omg.CORBA.StructMember (
+ "stringArray",
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_struct_tc (org.apache.tuscany.sca.test.corba.generated.AnnotatedStructHelper.id (), "AnnotatedStruct", _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct value = new org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct ();
+ value.stringArray = org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.read (istream);
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct value)
+ {
+ org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.write (ostream, value.stringArray);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHolder.java
new file mode 100644
index 0000000000..5f2dc56033
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHolder.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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/AnnotatedStructHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* sobota, 16 sierpieñ 2008 15:31:35 CEST
+*/
+
+public final class AnnotatedStructHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct value = null;
+
+ public AnnotatedStructHolder ()
+ {
+ }
+
+ public AnnotatedStructHolder (org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.AnnotatedStructHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.AnnotatedStructHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.AnnotatedStructHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/Color.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/Color.java
new file mode 100644
index 0000000000..24a628d406
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/Color.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.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/Color.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public class Color implements org.omg.CORBA.portable.IDLEntity
+{
+ private int __value;
+ private static int __size = 3;
+ private static org.apache.tuscany.sca.test.corba.generated.Color[] __array = new org.apache.tuscany.sca.test.corba.generated.Color [__size];
+
+ public static final int _red = 0;
+ public static final org.apache.tuscany.sca.test.corba.generated.Color red = new org.apache.tuscany.sca.test.corba.generated.Color(_red);
+ public static final int _yellow = 1;
+ public static final org.apache.tuscany.sca.test.corba.generated.Color yellow = new org.apache.tuscany.sca.test.corba.generated.Color(_yellow);
+ public static final int _green = 2;
+ public static final org.apache.tuscany.sca.test.corba.generated.Color green = new org.apache.tuscany.sca.test.corba.generated.Color(_green);
+
+ public int value ()
+ {
+ return __value;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.Color from_int (int value)
+ {
+ if (value >= 0 && value < __size)
+ return __array[value];
+ else
+ throw new org.omg.CORBA.BAD_PARAM ();
+ }
+
+ protected Color (int value)
+ {
+ __value = value;
+ __array[__value] = this;
+ }
+} // class Color
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ColorHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ColorHelper.java
new file mode 100644
index 0000000000..da37f28e39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ColorHelper.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ColorHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class ColorHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/Color:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.Color that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.Color extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_enum_tc (org.apache.tuscany.sca.test.corba.generated.ColorHelper.id (), "Color", new String[] { "red", "yellow", "green"} );
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.Color read (org.omg.CORBA.portable.InputStream istream)
+ {
+ return org.apache.tuscany.sca.test.corba.generated.Color.from_int (istream.read_long ());
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.Color value)
+ {
+ ostream.write_long (value.value ());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ColorHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ColorHolder.java
new file mode 100644
index 0000000000..7b2466f791
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ColorHolder.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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ColorHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class ColorHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.Color value = null;
+
+ public ColorHolder ()
+ {
+ }
+
+ public ColorHolder (org.apache.tuscany.sca.test.corba.generated.Color initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.ColorHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.ColorHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.ColorHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStruct.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStruct.java
new file mode 100644
index 0000000000..27052a1549
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStruct.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.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/InnerStruct.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class InnerStruct implements org.omg.CORBA.portable.IDLEntity
+{
+ public int twoDimLongSequence[][] = null;
+ public String stringField = null;
+ public org.apache.tuscany.sca.test.corba.generated.Color color = null;
+
+ public InnerStruct ()
+ {
+ } // ctor
+
+ public InnerStruct (int[][] _twoDimLongSequence, String _stringField, org.apache.tuscany.sca.test.corba.generated.Color _color)
+ {
+ twoDimLongSequence = _twoDimLongSequence;
+ stringField = _stringField;
+ color = _color;
+ } // ctor
+
+} // class InnerStruct
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStructHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStructHelper.java
new file mode 100644
index 0000000000..57daa51f42
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStructHelper.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/InnerStructHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class InnerStructHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/InnerStruct/InnerStruct:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.InnerStruct that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.InnerStruct extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ synchronized (org.omg.CORBA.TypeCode.class)
+ {
+ if (__typeCode == null)
+ {
+ if (__active)
+ {
+ return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [3];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_sequence_tc (0, _tcOf_members0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.LongSequenceHelper.id (), "LongSequence", _tcOf_members0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_sequence_tc (0, _tcOf_members0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.TwoDimLongSequenceHelper.id (), "TwoDimLongSequence", _tcOf_members0);
+ _members0[0] = new org.omg.CORBA.StructMember (
+ "twoDimLongSequence",
+ _tcOf_members0,
+ null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ _members0[1] = new org.omg.CORBA.StructMember (
+ "stringField",
+ _tcOf_members0,
+ null);
+ _tcOf_members0 = org.apache.tuscany.sca.test.corba.generated.ColorHelper.type ();
+ _members0[2] = new org.omg.CORBA.StructMember (
+ "color",
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_struct_tc (org.apache.tuscany.sca.test.corba.generated.InnerStructHelper.id (), "InnerStruct", _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.InnerStruct read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.test.corba.generated.InnerStruct value = new org.apache.tuscany.sca.test.corba.generated.InnerStruct ();
+ value.twoDimLongSequence = org.apache.tuscany.sca.test.corba.generated.TwoDimLongSequenceHelper.read (istream);
+ value.stringField = istream.read_string ();
+ value.color = org.apache.tuscany.sca.test.corba.generated.ColorHelper.read (istream);
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.InnerStruct value)
+ {
+ org.apache.tuscany.sca.test.corba.generated.TwoDimLongSequenceHelper.write (ostream, value.twoDimLongSequence);
+ ostream.write_string (value.stringField);
+ org.apache.tuscany.sca.test.corba.generated.ColorHelper.write (ostream, value.color);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStructHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStructHolder.java
new file mode 100644
index 0000000000..88fef0b4fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerStructHolder.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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/InnerStructHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class InnerStructHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.InnerStruct value = null;
+
+ public InnerStructHolder ()
+ {
+ }
+
+ public InnerStructHolder (org.apache.tuscany.sca.test.corba.generated.InnerStruct initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.InnerStructHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.InnerStructHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.InnerStructHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnion.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnion.java
new file mode 100644
index 0000000000..c5d2aab203
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnion.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/InnerUnion.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 19:07:14 CEST
+*/
+
+public final class InnerUnion implements org.omg.CORBA.portable.IDLEntity
+{
+ private int ___x;
+ private float ___y;
+ private int __discriminator;
+ private boolean __uninitialized = true;
+
+ public InnerUnion ()
+ {
+ }
+
+ public int discriminator ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ return __discriminator;
+ }
+
+ public int x ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyx (__discriminator);
+ return ___x;
+ }
+
+ public void x (int value)
+ {
+ __discriminator = 1;
+ ___x = value;
+ __uninitialized = false;
+ }
+
+ public void x (int discriminator, int value)
+ {
+ verifyx (discriminator);
+ __discriminator = discriminator;
+ ___x = value;
+ __uninitialized = false;
+ }
+
+ private void verifyx (int discriminator)
+ {
+ if (discriminator != 1)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public float y ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyy (__discriminator);
+ return ___y;
+ }
+
+ public void y (float value)
+ {
+ __discriminator = 2;
+ ___y = value;
+ __uninitialized = false;
+ }
+
+ public void y (int discriminator, float value)
+ {
+ verifyy (discriminator);
+ __discriminator = discriminator;
+ ___y = value;
+ __uninitialized = false;
+ }
+
+ private void verifyy (int discriminator)
+ {
+ if (discriminator != 2)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public void _default ()
+ {
+ __discriminator = -2147483648;
+ __uninitialized = false;
+ }
+
+ public void _default (int discriminator)
+ {
+ verifyDefault( discriminator ) ;
+ __discriminator = discriminator ;
+ __uninitialized = false;
+ }
+
+ private void verifyDefault( int value )
+ {
+ switch (value) {
+ case 1:
+ case 2:
+ throw new org.omg.CORBA.BAD_OPERATION() ;
+
+ default:
+ return;
+ }
+ }
+
+} // class InnerUnion
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java
new file mode 100644
index 0000000000..db57fc5cba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 19:07:14 CEST
+*/
+
+abstract public class InnerUnionHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/InnerUnion/InnerUnion:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.InnerUnion that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.InnerUnion extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ org.omg.CORBA.TypeCode _disTypeCode0;
+ _disTypeCode0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [2];
+ org.omg.CORBA.TypeCode _tcOf_members0;
+ org.omg.CORBA.Any _anyOf_members0;
+
+ // Branch for x (case label 1)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)1);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ _members0[0] = new org.omg.CORBA.UnionMember (
+ "x",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for y (case label 2)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)2);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float);
+ _members0[1] = new org.omg.CORBA.UnionMember (
+ "y",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.id (), "InnerUnion", _disTypeCode0, _members0);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.InnerUnion read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.test.corba.generated.InnerUnion value = new org.apache.tuscany.sca.test.corba.generated.InnerUnion ();
+ int _dis0 = (int)0;
+ _dis0 = istream.read_long ();
+ switch (_dis0)
+ {
+ case 1:
+ int _x = (int)0;
+ _x = istream.read_long ();
+ value.x (_x);
+ break;
+ case 2:
+ float _y = (float)0;
+ _y = istream.read_float ();
+ value.y (_y);
+ break;
+ default:
+ value._default( _dis0 ) ;
+ break;
+ }
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.InnerUnion value)
+ {
+ ostream.write_long (value.discriminator ());
+ switch (value.discriminator ())
+ {
+ case 1:
+ ostream.write_long (value.x ());
+ break;
+ case 2:
+ ostream.write_float (value.y ());
+ break;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.java
new file mode 100644
index 0000000000..ec25e703c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.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 org.apache.tuscany.sca.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 19:07:14 CEST
+*/
+
+public final class InnerUnionHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.InnerUnion value = null;
+
+ public InnerUnionHolder ()
+ {
+ }
+
+ public InnerUnionHolder (org.apache.tuscany.sca.test.corba.generated.InnerUnion initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/LongSequenceHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/LongSequenceHelper.java
new file mode 100644
index 0000000000..940b391499
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/LongSequenceHelper.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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/LongSequenceHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class LongSequenceHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/LongSequence:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, int[] that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static int[] extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ __typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
+ __typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.LongSequenceHelper.id (), "LongSequence", __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static int[] read (org.omg.CORBA.portable.InputStream istream)
+ {
+ int value[] = null;
+ int _len0 = istream.read_long ();
+ value = new int[_len0];
+ istream.read_long_array (value, 0, _len0);
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, int[] value)
+ {
+ ostream.write_long (value.length);
+ ostream.write_long_array (value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/LongSequenceHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/LongSequenceHolder.java
new file mode 100644
index 0000000000..63a11dc56a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/LongSequenceHolder.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/LongSequenceHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class LongSequenceHolder implements org.omg.CORBA.portable.Streamable
+{
+ public int value[] = null;
+
+ public LongSequenceHolder ()
+ {
+ }
+
+ public LongSequenceHolder (int[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.LongSequenceHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.LongSequenceHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.LongSequenceHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStruct.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStruct.java
new file mode 100644
index 0000000000..8c0bfc9e39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStruct.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.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/RichStruct.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class RichStruct implements org.omg.CORBA.portable.IDLEntity
+{
+ public org.apache.tuscany.sca.test.corba.generated.InnerStruct innerStruct = null;
+ public String stringSequence[] = null;
+ public int longField = (int)0;
+
+ public RichStruct ()
+ {
+ } // ctor
+
+ public RichStruct (org.apache.tuscany.sca.test.corba.generated.InnerStruct _innerStruct, String[] _stringSequence, int _longField)
+ {
+ innerStruct = _innerStruct;
+ stringSequence = _stringSequence;
+ longField = _longField;
+ } // ctor
+
+} // class RichStruct
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStructHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStructHelper.java
new file mode 100644
index 0000000000..72ff55a711
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStructHelper.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.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/RichStructHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class RichStructHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/RichStruct/RichStruct:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.RichStruct that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.RichStruct extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ synchronized (org.omg.CORBA.TypeCode.class)
+ {
+ if (__typeCode == null)
+ {
+ if (__active)
+ {
+ return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [3];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.apache.tuscany.sca.test.corba.generated.InnerStructHelper.type ();
+ _members0[0] = new org.omg.CORBA.StructMember (
+ "innerStruct",
+ _tcOf_members0,
+ null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_sequence_tc (0, _tcOf_members0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.StringSequenceHelper.id (), "StringSequence", _tcOf_members0);
+ _members0[1] = new org.omg.CORBA.StructMember (
+ "stringSequence",
+ _tcOf_members0,
+ null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ _members0[2] = new org.omg.CORBA.StructMember (
+ "longField",
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_struct_tc (org.apache.tuscany.sca.test.corba.generated.RichStructHelper.id (), "RichStruct", _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.RichStruct read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.test.corba.generated.RichStruct value = new org.apache.tuscany.sca.test.corba.generated.RichStruct ();
+ value.innerStruct = org.apache.tuscany.sca.test.corba.generated.InnerStructHelper.read (istream);
+ value.stringSequence = org.apache.tuscany.sca.test.corba.generated.StringSequenceHelper.read (istream);
+ value.longField = istream.read_long ();
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.RichStruct value)
+ {
+ org.apache.tuscany.sca.test.corba.generated.InnerStructHelper.write (ostream, value.innerStruct);
+ org.apache.tuscany.sca.test.corba.generated.StringSequenceHelper.write (ostream, value.stringSequence);
+ ostream.write_long (value.longField);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStructHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStructHolder.java
new file mode 100644
index 0000000000..8a063b8b9d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichStructHolder.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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/RichStructHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class RichStructHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.RichStruct value = null;
+
+ public RichStructHolder ()
+ {
+ }
+
+ public RichStructHolder (org.apache.tuscany.sca.test.corba.generated.RichStruct initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.RichStructHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.RichStructHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.RichStructHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnion.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnion.java
new file mode 100644
index 0000000000..bc42d57ac3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnion.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/RichUnion.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 19:07:14 CEST
+*/
+
+public final class RichUnion implements org.omg.CORBA.portable.IDLEntity
+{
+ private int ___x;
+ private float ___y;
+ private String ___z;
+ private org.apache.tuscany.sca.test.corba.generated.InnerUnion ___iu;
+ private boolean ___a;
+ private int __discriminator;
+ private boolean __uninitialized = true;
+
+ public RichUnion ()
+ {
+ }
+
+ public int discriminator ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ return __discriminator;
+ }
+
+ public int x ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyx (__discriminator);
+ return ___x;
+ }
+
+ public void x (int value)
+ {
+ __discriminator = 1;
+ ___x = value;
+ __uninitialized = false;
+ }
+
+ public void x (int discriminator, int value)
+ {
+ verifyx (discriminator);
+ __discriminator = discriminator;
+ ___x = value;
+ __uninitialized = false;
+ }
+
+ private void verifyx (int discriminator)
+ {
+ if (discriminator != 1)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public float y ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyy (__discriminator);
+ return ___y;
+ }
+
+ public void y (float value)
+ {
+ __discriminator = 2;
+ ___y = value;
+ __uninitialized = false;
+ }
+
+ public void y (int discriminator, float value)
+ {
+ verifyy (discriminator);
+ __discriminator = discriminator;
+ ___y = value;
+ __uninitialized = false;
+ }
+
+ private void verifyy (int discriminator)
+ {
+ if (discriminator != 2)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public String z ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyz (__discriminator);
+ return ___z;
+ }
+
+ public void z (String value)
+ {
+ __discriminator = 3;
+ ___z = value;
+ __uninitialized = false;
+ }
+
+ public void z (int discriminator, String value)
+ {
+ verifyz (discriminator);
+ __discriminator = discriminator;
+ ___z = value;
+ __uninitialized = false;
+ }
+
+ private void verifyz (int discriminator)
+ {
+ if (discriminator != 3)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public org.apache.tuscany.sca.test.corba.generated.InnerUnion iu ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyiu (__discriminator);
+ return ___iu;
+ }
+
+ public void iu (org.apache.tuscany.sca.test.corba.generated.InnerUnion value)
+ {
+ __discriminator = 4;
+ ___iu = value;
+ __uninitialized = false;
+ }
+
+ public void iu (int discriminator, org.apache.tuscany.sca.test.corba.generated.InnerUnion value)
+ {
+ verifyiu (discriminator);
+ __discriminator = discriminator;
+ ___iu = value;
+ __uninitialized = false;
+ }
+
+ private void verifyiu (int discriminator)
+ {
+ if (discriminator != 4)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public boolean a ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifya (__discriminator);
+ return ___a;
+ }
+
+ public void a (boolean value)
+ {
+ __discriminator = -2147483648;
+ ___a = value;
+ __uninitialized = false;
+ }
+
+ public void a (int discriminator, boolean value)
+ {
+ verifya (discriminator);
+ __discriminator = discriminator;
+ ___a = value;
+ __uninitialized = false;
+ }
+
+ private void verifya (int discriminator)
+ {
+ if (discriminator == 1 || discriminator == 2 || discriminator == 3 || discriminator == 4)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+} // class RichUnion
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java
new file mode 100644
index 0000000000..1cb1ed295e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 19:07:14 CEST
+*/
+
+abstract public class RichUnionHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/RichUnion/RichUnion:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.RichUnion that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.RichUnion extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ org.omg.CORBA.TypeCode _disTypeCode0;
+ _disTypeCode0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [5];
+ org.omg.CORBA.TypeCode _tcOf_members0;
+ org.omg.CORBA.Any _anyOf_members0;
+
+ // Branch for x (case label 1)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)1);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ _members0[0] = new org.omg.CORBA.UnionMember (
+ "x",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for y (case label 2)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)2);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float);
+ _members0[1] = new org.omg.CORBA.UnionMember (
+ "y",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for z (case label 3)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)3);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ _members0[2] = new org.omg.CORBA.UnionMember (
+ "z",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for iu (case label 4)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)4);
+ _tcOf_members0 = org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.type ();
+ _members0[3] = new org.omg.CORBA.UnionMember (
+ "iu",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for a (Default case)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_octet ((byte)0); // default member label
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_boolean);
+ _members0[4] = new org.omg.CORBA.UnionMember (
+ "a",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.id (), "RichUnion", _disTypeCode0, _members0);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.RichUnion read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.test.corba.generated.RichUnion value = new org.apache.tuscany.sca.test.corba.generated.RichUnion ();
+ int _dis0 = (int)0;
+ _dis0 = istream.read_long ();
+ switch (_dis0)
+ {
+ case 1:
+ int _x = (int)0;
+ _x = istream.read_long ();
+ value.x (_x);
+ break;
+ case 2:
+ float _y = (float)0;
+ _y = istream.read_float ();
+ value.y (_y);
+ break;
+ case 3:
+ String _z = null;
+ _z = istream.read_string ();
+ value.z (_z);
+ break;
+ case 4:
+ org.apache.tuscany.sca.test.corba.generated.InnerUnion _iu = null;
+ _iu = org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.read (istream);
+ value.iu (_iu);
+ break;
+ default:
+ boolean _a = false;
+ _a = istream.read_boolean ();
+ value.a (_dis0, _a);
+ break;
+ }
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.RichUnion value)
+ {
+ ostream.write_long (value.discriminator ());
+ switch (value.discriminator ())
+ {
+ case 1:
+ ostream.write_long (value.x ());
+ break;
+ case 2:
+ ostream.write_float (value.y ());
+ break;
+ case 3:
+ ostream.write_string (value.z ());
+ break;
+ case 4:
+ org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.write (ostream, value.iu ());
+ break;
+ default:
+ ostream.write_boolean (value.a ());
+ break;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.java
new file mode 100644
index 0000000000..e2221541c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.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 org.apache.tuscany.sca.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 19:07:14 CEST
+*/
+
+public final class RichUnionHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.RichUnion value = null;
+
+ public RichUnionHolder ()
+ {
+ }
+
+ public RichUnionHolder (org.apache.tuscany.sca.test.corba.generated.RichUnion initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOne.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOne.java
new file mode 100644
index 0000000000..13f294b871
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOne.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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioOne.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public interface ScenarioOne extends ScenarioOneOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
+{
+} // interface ScenarioOne
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneHelper.java
new file mode 100644
index 0000000000..66cc1d1e82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneHelper.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioOneHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class ScenarioOneHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioOne:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.ScenarioOne that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioOne extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.apache.tuscany.sca.test.corba.generated.ScenarioOneHelper.id (), "ScenarioOne");
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioOne read (org.omg.CORBA.portable.InputStream istream)
+ {
+ return narrow (istream.read_Object (_ScenarioOneStub.class));
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.ScenarioOne value)
+ {
+ ostream.write_Object ((org.omg.CORBA.Object) value);
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioOne narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.test.corba.generated.ScenarioOne)
+ return (org.apache.tuscany.sca.test.corba.generated.ScenarioOne)obj;
+ else if (!obj._is_a (id ()))
+ throw new org.omg.CORBA.BAD_PARAM ();
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ org.apache.tuscany.sca.test.corba.generated._ScenarioOneStub stub = new org.apache.tuscany.sca.test.corba.generated._ScenarioOneStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioOne unchecked_narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.test.corba.generated.ScenarioOne)
+ return (org.apache.tuscany.sca.test.corba.generated.ScenarioOne)obj;
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ org.apache.tuscany.sca.test.corba.generated._ScenarioOneStub stub = new org.apache.tuscany.sca.test.corba.generated._ScenarioOneStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneHolder.java
new file mode 100644
index 0000000000..f14394b400
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneHolder.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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioOneHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class ScenarioOneHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.ScenarioOne value = null;
+
+ public ScenarioOneHolder ()
+ {
+ }
+
+ public ScenarioOneHolder (org.apache.tuscany.sca.test.corba.generated.ScenarioOne initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.ScenarioOneHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.ScenarioOneHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.ScenarioOneHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneOperations.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneOperations.java
new file mode 100644
index 0000000000..56388624d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioOneOperations.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioOneOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public interface ScenarioOneOperations
+{
+ org.apache.tuscany.sca.test.corba.generated.RichStruct setRichStruct (org.apache.tuscany.sca.test.corba.generated.RichStruct richStruct) throws org.apache.tuscany.sca.test.corba.generated.WrongColor, org.apache.tuscany.sca.test.corba.generated.UnexpectedException;
+} // interface ScenarioOneOperations
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSix.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSix.java
new file mode 100644
index 0000000000..1897d0682c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSix.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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioSix.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* sobota, 16 sierpieñ 2008 15:31:35 CEST
+*/
+
+public interface ScenarioSix extends ScenarioSixOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
+{
+} // interface ScenarioSix
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixHelper.java
new file mode 100644
index 0000000000..c8c88ef91d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixHelper.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioSixHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* sobota, 16 sierpieñ 2008 15:31:35 CEST
+*/
+
+abstract public class ScenarioSixHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioSix:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.ScenarioSix that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioSix extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.apache.tuscany.sca.test.corba.generated.ScenarioSixHelper.id (), "ScenarioSix");
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioSix read (org.omg.CORBA.portable.InputStream istream)
+ {
+ return narrow (istream.read_Object (_ScenarioSixStub.class));
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.ScenarioSix value)
+ {
+ ostream.write_Object ((org.omg.CORBA.Object) value);
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioSix narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.test.corba.generated.ScenarioSix)
+ return (org.apache.tuscany.sca.test.corba.generated.ScenarioSix)obj;
+ else if (!obj._is_a (id ()))
+ throw new org.omg.CORBA.BAD_PARAM ();
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ org.apache.tuscany.sca.test.corba.generated._ScenarioSixStub stub = new org.apache.tuscany.sca.test.corba.generated._ScenarioSixStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioSix unchecked_narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.test.corba.generated.ScenarioSix)
+ return (org.apache.tuscany.sca.test.corba.generated.ScenarioSix)obj;
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ org.apache.tuscany.sca.test.corba.generated._ScenarioSixStub stub = new org.apache.tuscany.sca.test.corba.generated._ScenarioSixStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixHolder.java
new file mode 100644
index 0000000000..5540b98c21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixHolder.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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioSixHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* sobota, 16 sierpieñ 2008 15:31:35 CEST
+*/
+
+public final class ScenarioSixHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.ScenarioSix value = null;
+
+ public ScenarioSixHolder ()
+ {
+ }
+
+ public ScenarioSixHolder (org.apache.tuscany.sca.test.corba.generated.ScenarioSix initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.ScenarioSixHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.ScenarioSixHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.ScenarioSixHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java
new file mode 100644
index 0000000000..648144299c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.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 org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 19:07:14 CEST
+*/
+
+public interface ScenarioSixOperations
+{
+ String[][] passStringArray (String[][] arg);
+ org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct passAnnotatedStruct (org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct arg);
+ org.apache.tuscany.sca.test.corba.generated.RichUnion passRichUnion (org.apache.tuscany.sca.test.corba.generated.RichUnion arg);
+} // interface ScenarioSixOperations
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwo.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwo.java
new file mode 100644
index 0000000000..b57e098a56
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwo.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioTwo.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* wtorek, 15 lipiec 2008 13:36:31 CEST
+*/
+
+
+// objects for ScenarioTwo
+public interface ScenarioTwo extends ScenarioTwoOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
+{
+} // interface ScenarioTwo
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHelper.java
new file mode 100644
index 0000000000..8ddfa10575
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHelper.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* wtorek, 15 lipiec 2008 13:36:31 CEST
+*/
+
+
+// objects for ScenarioTwo
+abstract public class ScenarioTwoHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioTwo:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.ScenarioTwo that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioTwo extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.apache.tuscany.sca.test.corba.generated.ScenarioTwoHelper.id (), "ScenarioTwo");
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioTwo read (org.omg.CORBA.portable.InputStream istream)
+ {
+ return narrow (istream.read_Object (_ScenarioTwoStub.class));
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.ScenarioTwo value)
+ {
+ ostream.write_Object ((org.omg.CORBA.Object) value);
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioTwo narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.test.corba.generated.ScenarioTwo)
+ return (org.apache.tuscany.sca.test.corba.generated.ScenarioTwo)obj;
+ else if (!obj._is_a (id ()))
+ throw new org.omg.CORBA.BAD_PARAM ();
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ org.apache.tuscany.sca.test.corba.generated._ScenarioTwoStub stub = new org.apache.tuscany.sca.test.corba.generated._ScenarioTwoStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.ScenarioTwo unchecked_narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.test.corba.generated.ScenarioTwo)
+ return (org.apache.tuscany.sca.test.corba.generated.ScenarioTwo)obj;
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ org.apache.tuscany.sca.test.corba.generated._ScenarioTwoStub stub = new org.apache.tuscany.sca.test.corba.generated._ScenarioTwoStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHolder.java
new file mode 100644
index 0000000000..9717629711
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHolder.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioTwoHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* wtorek, 15 lipiec 2008 13:36:31 CEST
+*/
+
+
+// objects for ScenarioTwo
+public final class ScenarioTwoHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.ScenarioTwo value = null;
+
+ public ScenarioTwoHolder ()
+ {
+ }
+
+ public ScenarioTwoHolder (org.apache.tuscany.sca.test.corba.generated.ScenarioTwo initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.ScenarioTwoHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.ScenarioTwoHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.ScenarioTwoHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoOperations.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoOperations.java
new file mode 100644
index 0000000000..1247b4618d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioTwoOperations.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 org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/ScenarioTwoOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* wtorek, 15 lipiec 2008 13:36:31 CEST
+*/
+
+
+// objects for ScenarioTwo
+public interface ScenarioTwoOperations
+{
+ String stringField ();
+ void stringField (String newStringField);
+} // interface ScenarioTwoOperations
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringArrayHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringArrayHelper.java
new file mode 100644
index 0000000000..f2cc3adad5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringArrayHelper.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/StringArrayHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* sobota, 16 sierpieñ 2008 15:31:35 CEST
+*/
+
+abstract public class StringArrayHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/StringArray:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, String[][] that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static String[][] extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ __typeCode = org.omg.CORBA.ORB.init ().create_array_tc (2, __typeCode );
+ __typeCode = org.omg.CORBA.ORB.init ().create_array_tc (2, __typeCode );
+ __typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.id (), "StringArray", __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static String[][] read (org.omg.CORBA.portable.InputStream istream)
+ {
+ String value[][] = null;
+ value = new String[2][];
+ for (int _o0 = 0;_o0 < (2); ++_o0)
+ {
+ value[_o0] = new String[2];
+ for (int _o1 = 0;_o1 < (2); ++_o1)
+ {
+ value[_o0][_o1] = istream.read_string ();
+ }
+ }
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, String[][] value)
+ {
+ if (value.length != (2))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i0 = 0;_i0 < (2); ++_i0)
+ {
+ if (value[_i0].length != (2))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i1 = 0;_i1 < (2); ++_i1)
+ {
+ ostream.write_string (value[_i0][_i1]);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringArrayHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringArrayHolder.java
new file mode 100644
index 0000000000..dbad550222
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringArrayHolder.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/StringArrayHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* sobota, 16 sierpieñ 2008 15:31:35 CEST
+*/
+
+public final class StringArrayHolder implements org.omg.CORBA.portable.Streamable
+{
+ public String value[][] = null;
+
+ public StringArrayHolder ()
+ {
+ }
+
+ public StringArrayHolder (String[][] initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringSequenceHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringSequenceHelper.java
new file mode 100644
index 0000000000..d29129236c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringSequenceHelper.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.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/StringSequenceHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class StringSequenceHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/StringSequence:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, String[] that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static String[] extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ __typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
+ __typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.StringSequenceHelper.id (), "StringSequence", __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static String[] read (org.omg.CORBA.portable.InputStream istream)
+ {
+ String value[] = null;
+ int _len0 = istream.read_long ();
+ value = new String[_len0];
+ for (int _o1 = 0;_o1 < value.length; ++_o1)
+ value[_o1] = istream.read_string ();
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, String[] value)
+ {
+ ostream.write_long (value.length);
+ for (int _i0 = 0;_i0 < value.length; ++_i0)
+ ostream.write_string (value[_i0]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringSequenceHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringSequenceHolder.java
new file mode 100644
index 0000000000..837ba04cea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/StringSequenceHolder.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/StringSequenceHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class StringSequenceHolder implements org.omg.CORBA.portable.Streamable
+{
+ public String value[] = null;
+
+ public StringSequenceHolder ()
+ {
+ }
+
+ public StringSequenceHolder (String[] initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.StringSequenceHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.StringSequenceHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.StringSequenceHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHelper.java
new file mode 100644
index 0000000000..0b24056642
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHelper.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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class TwoDimLongSequenceHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequence:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, int[][] that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static int[][] extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ __typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
+ __typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.LongSequenceHelper.id (), "LongSequence", __typeCode);
+ __typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
+ __typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.test.corba.generated.TwoDimLongSequenceHelper.id (), "TwoDimLongSequence", __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static int[][] read (org.omg.CORBA.portable.InputStream istream)
+ {
+ int value[][] = null;
+ int _len0 = istream.read_long ();
+ value = new int[_len0][];
+ for (int _o1 = 0;_o1 < value.length; ++_o1)
+ value[_o1] = org.apache.tuscany.sca.test.corba.generated.LongSequenceHelper.read (istream);
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, int[][] value)
+ {
+ ostream.write_long (value.length);
+ for (int _i0 = 0;_i0 < value.length; ++_i0)
+ org.apache.tuscany.sca.test.corba.generated.LongSequenceHelper.write (ostream, value[_i0]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHolder.java
new file mode 100644
index 0000000000..e2ed1ab037
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHolder.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/TwoDimLongSequenceHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class TwoDimLongSequenceHolder implements org.omg.CORBA.portable.Streamable
+{
+ public int value[][] = null;
+
+ public TwoDimLongSequenceHolder ()
+ {
+ }
+
+ public TwoDimLongSequenceHolder (int[][] initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.TwoDimLongSequenceHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.TwoDimLongSequenceHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.TwoDimLongSequenceHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedException.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedException.java
new file mode 100644
index 0000000000..46888399ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedException.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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/UnexpectedException.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class UnexpectedException extends org.omg.CORBA.UserException
+{
+ public String info = null;
+
+ public UnexpectedException ()
+ {
+ super(UnexpectedExceptionHelper.id());
+ } // ctor
+
+ public UnexpectedException (String _info)
+ {
+ super(UnexpectedExceptionHelper.id());
+ info = _info;
+ } // ctor
+
+
+ public UnexpectedException (String $reason, String _info)
+ {
+ super(UnexpectedExceptionHelper.id() + " " + $reason);
+ info = _info;
+ } // ctor
+
+} // class UnexpectedException
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHelper.java
new file mode 100644
index 0000000000..c276038050
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHelper.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class UnexpectedExceptionHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/UnexpectedException:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.UnexpectedException that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.UnexpectedException extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ synchronized (org.omg.CORBA.TypeCode.class)
+ {
+ if (__typeCode == null)
+ {
+ if (__active)
+ {
+ return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [1];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ _members0[0] = new org.omg.CORBA.StructMember (
+ "info",
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_exception_tc (org.apache.tuscany.sca.test.corba.generated.UnexpectedExceptionHelper.id (), "UnexpectedException", _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.UnexpectedException read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.test.corba.generated.UnexpectedException value = new org.apache.tuscany.sca.test.corba.generated.UnexpectedException ();
+ // read and discard the repository ID
+ istream.read_string ();
+ value.info = istream.read_string ();
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.UnexpectedException value)
+ {
+ // write the repository ID
+ ostream.write_string (id ());
+ ostream.write_string (value.info);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHolder.java
new file mode 100644
index 0000000000..079a56b446
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHolder.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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/UnexpectedExceptionHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class UnexpectedExceptionHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.UnexpectedException value = null;
+
+ public UnexpectedExceptionHolder ()
+ {
+ }
+
+ public UnexpectedExceptionHolder (org.apache.tuscany.sca.test.corba.generated.UnexpectedException initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.UnexpectedExceptionHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.UnexpectedExceptionHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.UnexpectedExceptionHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColor.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColor.java
new file mode 100644
index 0000000000..0407184598
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColor.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/WrongColor.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class WrongColor extends org.omg.CORBA.UserException
+{
+ public org.apache.tuscany.sca.test.corba.generated.Color givenColor = null;
+ public org.apache.tuscany.sca.test.corba.generated.Color correctColor = null;
+
+ public WrongColor ()
+ {
+ super(WrongColorHelper.id());
+ } // ctor
+
+ public WrongColor (org.apache.tuscany.sca.test.corba.generated.Color _givenColor, org.apache.tuscany.sca.test.corba.generated.Color _correctColor)
+ {
+ super(WrongColorHelper.id());
+ givenColor = _givenColor;
+ correctColor = _correctColor;
+ } // ctor
+
+
+ public WrongColor (String $reason, org.apache.tuscany.sca.test.corba.generated.Color _givenColor, org.apache.tuscany.sca.test.corba.generated.Color _correctColor)
+ {
+ super(WrongColorHelper.id() + " " + $reason);
+ givenColor = _givenColor;
+ correctColor = _correctColor;
+ } // ctor
+
+} // class WrongColor
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColorHelper.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColorHelper.java
new file mode 100644
index 0000000000..16e099cfa3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColorHelper.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/WrongColorHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+abstract public class WrongColorHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/WrongColor:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.WrongColor that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.WrongColor extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ synchronized (org.omg.CORBA.TypeCode.class)
+ {
+ if (__typeCode == null)
+ {
+ if (__active)
+ {
+ return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [2];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.apache.tuscany.sca.test.corba.generated.ColorHelper.type ();
+ _members0[0] = new org.omg.CORBA.StructMember (
+ "givenColor",
+ _tcOf_members0,
+ null);
+ _tcOf_members0 = org.apache.tuscany.sca.test.corba.generated.ColorHelper.type ();
+ _members0[1] = new org.omg.CORBA.StructMember (
+ "correctColor",
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_exception_tc (org.apache.tuscany.sca.test.corba.generated.WrongColorHelper.id (), "WrongColor", _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.test.corba.generated.WrongColor read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.test.corba.generated.WrongColor value = new org.apache.tuscany.sca.test.corba.generated.WrongColor ();
+ // read and discard the repository ID
+ istream.read_string ();
+ value.givenColor = org.apache.tuscany.sca.test.corba.generated.ColorHelper.read (istream);
+ value.correctColor = org.apache.tuscany.sca.test.corba.generated.ColorHelper.read (istream);
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.WrongColor value)
+ {
+ // write the repository ID
+ ostream.write_string (id ());
+ org.apache.tuscany.sca.test.corba.generated.ColorHelper.write (ostream, value.givenColor);
+ org.apache.tuscany.sca.test.corba.generated.ColorHelper.write (ostream, value.correctColor);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColorHolder.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColorHolder.java
new file mode 100644
index 0000000000..b4883cb35c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/WrongColorHolder.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.test.corba.generated;
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/WrongColorHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public final class WrongColorHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.test.corba.generated.WrongColor value = null;
+
+ public WrongColorHolder ()
+ {
+ }
+
+ public WrongColorHolder (org.apache.tuscany.sca.test.corba.generated.WrongColor initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.test.corba.generated.WrongColorHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.test.corba.generated.WrongColorHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.test.corba.generated.WrongColorHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioOneImplBase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioOneImplBase.java
new file mode 100644
index 0000000000..c96fb61204
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioOneImplBase.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.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/_ScenarioOneImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public abstract class _ScenarioOneImplBase extends org.omg.CORBA.portable.ObjectImpl
+ implements org.apache.tuscany.sca.test.corba.generated.ScenarioOne, org.omg.CORBA.portable.InvokeHandler
+{
+
+ // Constructors
+ public _ScenarioOneImplBase ()
+ {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable ();
+ static
+ {
+ _methods.put ("setRichStruct", new java.lang.Integer (0));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke (String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh)
+ {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get ($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue ())
+ {
+ case 0: // org/apache/tuscany/sca/test/corba/generated/ScenarioOne/setRichStruct
+ {
+ try {
+ org.apache.tuscany.sca.test.corba.generated.RichStruct richStruct = org.apache.tuscany.sca.test.corba.generated.RichStructHelper.read (in);
+ org.apache.tuscany.sca.test.corba.generated.RichStruct $result = null;
+ $result = this.setRichStruct (richStruct);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.test.corba.generated.RichStructHelper.write (out, $result);
+ } catch (org.apache.tuscany.sca.test.corba.generated.WrongColor $ex) {
+ out = $rh.createExceptionReply ();
+ org.apache.tuscany.sca.test.corba.generated.WrongColorHelper.write (out, $ex);
+ } catch (org.apache.tuscany.sca.test.corba.generated.UnexpectedException $ex) {
+ out = $rh.createExceptionReply ();
+ org.apache.tuscany.sca.test.corba.generated.UnexpectedExceptionHelper.write (out, $ex);
+ }
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioOne:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+
+} // class _ScenarioOneImplBase
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioOneStub.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioOneStub.java
new file mode 100644
index 0000000000..3427c127ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioOneStub.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/_ScenarioOneStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* pi±tek, 27 czerwiec 2008 20:40:03 CEST
+*/
+
+public class _ScenarioOneStub extends org.omg.CORBA.portable.ObjectImpl implements org.apache.tuscany.sca.test.corba.generated.ScenarioOne
+{
+
+ public org.apache.tuscany.sca.test.corba.generated.RichStruct setRichStruct (org.apache.tuscany.sca.test.corba.generated.RichStruct richStruct) throws org.apache.tuscany.sca.test.corba.generated.WrongColor, org.apache.tuscany.sca.test.corba.generated.UnexpectedException
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("setRichStruct", true);
+ org.apache.tuscany.sca.test.corba.generated.RichStructHelper.write ($out, richStruct);
+ $in = _invoke ($out);
+ org.apache.tuscany.sca.test.corba.generated.RichStruct $result = org.apache.tuscany.sca.test.corba.generated.RichStructHelper.read ($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ if (_id.equals ("IDL:org/apache/tuscany/sca/test/corba/generated/WrongColor:1.0"))
+ throw org.apache.tuscany.sca.test.corba.generated.WrongColorHelper.read ($in);
+ else if (_id.equals ("IDL:org/apache/tuscany/sca/test/corba/generated/UnexpectedException:1.0"))
+ throw org.apache.tuscany.sca.test.corba.generated.UnexpectedExceptionHelper.read ($in);
+ else
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setRichStruct (richStruct );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // setRichStruct
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioOne:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+ private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
+ {
+ String str = s.readUTF ();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
+ _set_delegate (delegate);
+ }
+
+ private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
+ {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
+ s.writeUTF (str);
+ }
+} // class _ScenarioOneStub
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java
new file mode 100644
index 0000000000..78464fe40d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 23:35:36 CEST
+*/
+
+public abstract class _ScenarioSixImplBase extends org.omg.CORBA.portable.ObjectImpl
+ implements org.apache.tuscany.sca.test.corba.generated.ScenarioSix, org.omg.CORBA.portable.InvokeHandler
+{
+
+ // Constructors
+ public _ScenarioSixImplBase ()
+ {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable ();
+ static
+ {
+ _methods.put ("passStringArray", new java.lang.Integer (0));
+ _methods.put ("passAnnotatedStruct", new java.lang.Integer (1));
+ _methods.put ("passRichUnion", new java.lang.Integer (2));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke (String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh)
+ {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get ($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue ())
+ {
+ case 0: // org/apache/tuscany/sca/test/corba/generated/ScenarioSix/passStringArray
+ {
+ String arg[][] = org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.read (in);
+ String $result[][] = null;
+ $result = this.passStringArray (arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.write (out, $result);
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/test/corba/generated/ScenarioSix/passAnnotatedStruct
+ {
+ org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct arg = org.apache.tuscany.sca.test.corba.generated.AnnotatedStructHelper.read (in);
+ org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct $result = null;
+ $result = this.passAnnotatedStruct (arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.test.corba.generated.AnnotatedStructHelper.write (out, $result);
+ break;
+ }
+
+ case 2: // org/apache/tuscany/sca/test/corba/generated/ScenarioSix/passRichUnion
+ {
+ org.apache.tuscany.sca.test.corba.generated.RichUnion arg = org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.read (in);
+ org.apache.tuscany.sca.test.corba.generated.RichUnion $result = null;
+ $result = this.passRichUnion (arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.write (out, $result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioSix:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+
+} // class _ScenarioSixImplBase
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java
new file mode 100644
index 0000000000..faff36c2a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* niedziela, 17 sierpieñ 2008 19:07:14 CEST
+*/
+
+public class _ScenarioSixStub extends org.omg.CORBA.portable.ObjectImpl implements org.apache.tuscany.sca.test.corba.generated.ScenarioSix
+{
+
+ public String[][] passStringArray (String[][] arg)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("passStringArray", true);
+ org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.write ($out, arg);
+ $in = _invoke ($out);
+ String $result[][] = org.apache.tuscany.sca.test.corba.generated.StringArrayHelper.read ($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return passStringArray (arg );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // passStringArray
+
+ public org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct passAnnotatedStruct (org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct arg)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("passAnnotatedStruct", true);
+ org.apache.tuscany.sca.test.corba.generated.AnnotatedStructHelper.write ($out, arg);
+ $in = _invoke ($out);
+ org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct $result = org.apache.tuscany.sca.test.corba.generated.AnnotatedStructHelper.read ($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return passAnnotatedStruct (arg );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // passAnnotatedStruct
+
+ public org.apache.tuscany.sca.test.corba.generated.RichUnion passRichUnion (org.apache.tuscany.sca.test.corba.generated.RichUnion arg)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("passRichUnion", true);
+ org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.write ($out, arg);
+ $in = _invoke ($out);
+ org.apache.tuscany.sca.test.corba.generated.RichUnion $result = org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.read ($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return passRichUnion (arg );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // passRichUnion
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioSix:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+ private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
+ {
+ String str = s.readUTF ();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
+ _set_delegate (delegate);
+ }
+
+ private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
+ {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
+ s.writeUTF (str);
+ }
+} // class _ScenarioSixStub
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoImplBase.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoImplBase.java
new file mode 100644
index 0000000000..750006cec6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoImplBase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* wtorek, 15 lipiec 2008 13:36:31 CEST
+*/
+
+
+// objects for ScenarioTwo
+public abstract class _ScenarioTwoImplBase extends org.omg.CORBA.portable.ObjectImpl
+ implements org.apache.tuscany.sca.test.corba.generated.ScenarioTwo, org.omg.CORBA.portable.InvokeHandler
+{
+
+ // Constructors
+ public _ScenarioTwoImplBase ()
+ {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable ();
+ static
+ {
+ _methods.put ("_get_stringField", new java.lang.Integer (0));
+ _methods.put ("_set_stringField", new java.lang.Integer (1));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke (String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh)
+ {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get ($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue ())
+ {
+ case 0: // org/apache/tuscany/sca/test/corba/generated/ScenarioTwo/_get_stringField
+ {
+ String $result = null;
+ $result = this.stringField ();
+ out = $rh.createReply();
+ out.write_string ($result);
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/test/corba/generated/ScenarioTwo/_set_stringField
+ {
+ String newStringField = in.read_string ();
+ this.stringField (newStringField);
+ out = $rh.createReply();
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioTwo:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+
+} // class _ScenarioTwoImplBase
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoStub.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoStub.java
new file mode 100644
index 0000000000..ef9f561d1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoStub.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.generated;
+
+
+/**
+* org/apache/tuscany/sca/test/corba/generated/_ScenarioTwoStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from itest_scenario.idl
+* wtorek, 15 lipiec 2008 13:36:31 CEST
+*/
+
+
+// objects for ScenarioTwo
+public class _ScenarioTwoStub extends org.omg.CORBA.portable.ObjectImpl implements org.apache.tuscany.sca.test.corba.generated.ScenarioTwo
+{
+
+ public String stringField ()
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("_get_stringField", true);
+ $in = _invoke ($out);
+ String $result = $in.read_string ();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return stringField ( );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // stringField
+
+ public void stringField (String newStringField)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("_set_stringField", true);
+ $out.write_string (newStringField);
+ $in = _invoke ($out);
+ return;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ stringField (newStringField );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // stringField
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioTwo:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+ private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
+ {
+ String str = s.readUTF ();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
+ _set_delegate (delegate);
+ }
+
+ private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
+ {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
+ s.writeUTF (str);
+ }
+} // class _ScenarioTwoStub
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFive.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFive.java
new file mode 100644
index 0000000000..1bc2156183
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFive.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * @version $Rev$ $Date$
+ * Operations for scenario five
+ */
+@Remotable
+public interface ScenarioFive {
+
+ void doNothing();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveComponent.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveComponent.java
new file mode 100644
index 0000000000..a198eaf646
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveComponent.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.test.corba.types;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ * Component for obtaining ScenarioFive reference
+ */
+public class ScenarioFiveComponent {
+
+ private ScenarioFive scenarioFive;
+
+ @Reference
+ public void setScenarioFive(ScenarioFive scenarioFive) {
+ this.scenarioFive = scenarioFive;
+ }
+
+ public ScenarioFive getScenarioFive() {
+ return scenarioFive;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveImpl.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveImpl.java
new file mode 100644
index 0000000000..dc752a2aea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFiveImpl.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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Implementation of ScenarioFive service
+ */
+public class ScenarioFiveImpl implements ScenarioFive {
+
+ public void doNothing() {
+ // does nothing
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java
new file mode 100644
index 0000000000..aa2f06909b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.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 org.apache.tuscany.sca.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourSdo;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * @version $Rev$ $Date$
+ * Operations for ScenarioFour
+ */
+@Remotable
+public interface ScenarioFour {
+
+ ScenarioFourStruct setStruct(ScenarioFourStruct struct);
+
+ void exceptionTest() throws ScenarioFourException;
+
+ ScenarioFourSdo passScenarioFourStruct(ScenarioFourSdo scenarioFourSdo);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.java
new file mode 100644
index 0000000000..c7569720f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.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.test.corba.types;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ * Component for obtaining ScenarioFour reference
+ */
+public class ScenarioFourComponent {
+
+ private ScenarioFour scenarioFour;
+
+ @Reference
+ public void setScenarioFour(ScenarioFour scenarioFour) {
+ this.scenarioFour = scenarioFour;
+ }
+
+ public ScenarioFour getScenarioFour() {
+ return scenarioFour;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourException.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourException.java
new file mode 100644
index 0000000000..bc76373633
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourException.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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Exception for ScenarioFour tests
+ */
+public class ScenarioFourException extends Exception {
+
+ public static final String DEFAULT_CONTENT = "Test";
+
+ private static final long serialVersionUID = 1L;
+ private String content;
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java
new file mode 100644
index 0000000000..2f10177bd0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.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.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourSdo;
+
+/**
+ * @version $Rev$ $Date$
+ * Implementation of ScenarioFour service
+ */
+public class ScenarioFourImpl implements ScenarioFour {
+
+ public ScenarioFourStruct setStruct(ScenarioFourStruct struct) {
+ return struct;
+ }
+
+ public void exceptionTest() throws ScenarioFourException {
+ ScenarioFourException exception = new ScenarioFourException();
+ exception.setContent(ScenarioFourException.DEFAULT_CONTENT);
+ throw exception;
+ }
+
+ public ScenarioFourSdo passScenarioFourStruct(ScenarioFourSdo scenarioFourSdo) {
+ return scenarioFourSdo;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java
new file mode 100644
index 0000000000..de8624455f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Type for ScenarioFour test
+ */
+public class ScenarioFourStruct {
+
+ public String field1;
+ public int field2;
+ public double[] field3;
+
+ public boolean equals(ScenarioFourStruct arg) {
+ return (field1 != null && arg.field1 != null
+ && field1.equals(arg.field1)
+ && field2 == arg.field2
+ && field3 != null
+ && arg.field3 != null && field3.length == arg.field3.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioOneComponent.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioOneComponent.java
new file mode 100644
index 0000000000..1813de4e67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioOneComponent.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.sca.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.generated.RichStruct;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioOne;
+import org.apache.tuscany.sca.test.corba.generated.ScenarioOneOperations;
+import org.apache.tuscany.sca.test.corba.generated.UnexpectedException;
+import org.apache.tuscany.sca.test.corba.generated.WrongColor;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ * Component for reference using generated interface.
+ */
+public class ScenarioOneComponent implements ScenarioOneOperations {
+
+ private ScenarioOne scenarionOne;
+
+ @Reference
+ public void setScenarioOne(ScenarioOne scenarioOne) {
+ this.scenarionOne = scenarioOne;
+ }
+
+ public RichStruct setRichStruct(RichStruct richStruct) throws WrongColor, UnexpectedException {
+ return scenarionOne.setRichStruct(richStruct);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioOneServant.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioOneServant.java
new file mode 100644
index 0000000000..9b49adbfbb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioOneServant.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.generated.Color;
+import org.apache.tuscany.sca.test.corba.generated.RichStruct;
+import org.apache.tuscany.sca.test.corba.generated.UnexpectedException;
+import org.apache.tuscany.sca.test.corba.generated.WrongColor;
+import org.apache.tuscany.sca.test.corba.generated._ScenarioOneImplBase;
+
+/**
+ * @version $Rev$ $Date$
+ * Servant for generated interface. Uses generated classes.
+ */
+public class ScenarioOneServant extends _ScenarioOneImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public RichStruct setRichStruct(RichStruct richStruct) throws WrongColor, UnexpectedException {
+ if (richStruct.innerStruct.color.value() == Color.red.value()) {
+ throw new WrongColor(richStruct.innerStruct.color, Color.green);
+ } else if (richStruct.longField == 0) {
+ throw new UnexpectedException("Expected richStruct.longField != 0");
+ }
+ return richStruct;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioSixServant.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioSixServant.java
new file mode 100644
index 0000000000..7889a80bf1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioSixServant.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.sca.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct;
+import org.apache.tuscany.sca.test.corba.generated.RichUnion;
+import org.apache.tuscany.sca.test.corba.generated._ScenarioSixImplBase;
+
+/**
+ * @version $Rev$ $Date$
+ * Scenario six servant for generated interface.
+ */
+public class ScenarioSixServant extends _ScenarioSixImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public String[][] passStringArray(String[][] arg) {
+ return arg;
+ }
+
+ public AnnotatedStruct passAnnotatedStruct(AnnotatedStruct arg) {
+ return arg;
+ }
+
+ public RichUnion passRichUnion(RichUnion arg) {
+ return arg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioTwoServant.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioTwoServant.java
new file mode 100644
index 0000000000..cdd49904d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioTwoServant.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.generated._ScenarioTwoImplBase;
+
+/**
+ * @version $Rev$ $Date$
+ * Servant for generated interface.
+ */
+public class ScenarioTwoServant extends _ScenarioTwoImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ private String stringField = "";
+
+ public String stringField() {
+ return stringField;
+ }
+
+ public void stringField(String newStringField) {
+ this.stringField = newStringField;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TAnnotatedStruct.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TAnnotatedStruct.java
new file mode 100644
index 0000000000..6f0ef584da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TAnnotatedStruct.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray;
+
+/**
+ * @version $Rev$ $Date$ Scenario six structure used by Tuscany.
+ */
+public final class TAnnotatedStruct {
+
+ @CorbaArray( {2, 2})
+ public String[][] stringArray;
+
+ public TAnnotatedStruct() {
+
+ }
+
+ public TAnnotatedStruct(String[][] stringArray) {
+ this.stringArray = stringArray;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TColor.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TColor.java
new file mode 100644
index 0000000000..71003d008f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TColor.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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * User provided enum representation for Color type.
+ */
+public class TColor {
+
+ private int value;
+
+ public static final int _red = 0;
+ public static final int _yellow = 1;
+ public static final int _green = 2;
+
+ public static final TColor red = new TColor(_red);
+ public static final TColor yellow = new TColor(_yellow);
+ public static final TColor green = new TColor(_green);
+
+ public int value() {
+ return value;
+ }
+
+ public static TColor from_int(int value) {
+ switch (value) {
+ case 0:
+ return red;
+ case 1:
+ return yellow;
+ case 2:
+ return green;
+ }
+ return green;
+ }
+
+ protected TColor(int value) {
+ this.value = value;
+ }
+
+ public TColor() {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerStruct.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerStruct.java
new file mode 100644
index 0000000000..271f1e669b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerStruct.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * User provided interface representation for InnerStruct type.
+ */
+public final class TInnerStruct {
+
+ public int[][] twoDimLongSequence;
+ public String stringField;
+ public TColor color;
+
+ public TInnerStruct() {
+
+ }
+
+ public TInnerStruct(int[][] a1, String a2, TColor a3) {
+ twoDimLongSequence = a1;
+ stringField = a2;
+ color = a3;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerUnion.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerUnion.java
new file mode 100644
index 0000000000..f2baffce9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerUnion.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.types;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+/**
+ * @version $Rev$ $Date$
+ * User provided interface representation for CORBA InnerUnion type.
+ */
+public final class TInnerUnion {
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1)
+ private int x;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 2)
+ private float y;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private int discriminator;
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ discriminator = 1;
+ this.x = x;
+ }
+
+ public float getY() {
+ return y;
+ }
+
+ public void setY(float y) {
+ discriminator = 2;
+ this.y = y;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichStruct.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichStruct.java
new file mode 100644
index 0000000000..1b44da9752
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichStruct.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * User provided interface representation for RichStruct type.
+ */
+public final class TRichStruct {
+
+ public TInnerStruct innerStruct;
+ public String[] stringSequence;
+ public int longField;
+
+ public TRichStruct() {
+
+ }
+
+ public TRichStruct(TInnerStruct a1, String[] a2, int a3) {
+ innerStruct = a1;
+ stringSequence = a2;
+ longField = a3;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichUnion.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichUnion.java
new file mode 100644
index 0000000000..8270ba1a8c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichUnion.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+/**
+ * @version $Rev$ $Date$
+ * User provided interface representation for CORBA RichUnion type.
+ */
+public final class TRichUnion {
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1)
+ private int x;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 2)
+ private float y;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 3)
+ private String z;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 4)
+ private TInnerUnion iu;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.defaultOption)
+ private boolean def;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private int discriminator = -1;
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ this.discriminator = 1;
+ this.x = x;
+ }
+
+ public float getY() {
+ return y;
+ }
+
+ public void setY(float y) {
+ this.discriminator = 2;
+ this.y = y;
+ }
+
+ public String getZ() {
+ return z;
+ }
+
+ public void setZ(String z) {
+ this.discriminator = 3;
+ this.z = z;
+ }
+
+ public boolean isDef() {
+ return def;
+ }
+
+ public void setDef(boolean def) {
+ this.discriminator = -1;
+ this.def = def;
+ }
+
+ public TInnerUnion getIu() {
+ return iu;
+ }
+
+ public void setIu(TInnerUnion iu) {
+ this.discriminator = 4;
+ this.iu = iu;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOne.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOne.java
new file mode 100644
index 0000000000..922759cd8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOne.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.generated.UnexpectedException;
+import org.apache.tuscany.sca.test.corba.generated.WrongColor;
+
+/**
+ * @version $Rev$ $Date$
+ * User provided CORBA service interface.
+ */
+public interface TScenarioOne {
+
+ TRichStruct setRichStruct(TRichStruct richStruct) throws WrongColor, UnexpectedException;
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOneComponent.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOneComponent.java
new file mode 100644
index 0000000000..ac7b0af175
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOneComponent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.generated.UnexpectedException;
+import org.apache.tuscany.sca.test.corba.generated.WrongColor;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ * Component for reference using user provided interface.
+ */
+public class TScenarioOneComponent implements TScenarioOne {
+
+ private TScenarioOne scenarionOne;
+
+ @Reference
+ public void setScenarioOne(TScenarioOne scenarioOne) {
+ this.scenarionOne = scenarioOne;
+ }
+
+ public TRichStruct setRichStruct(TRichStruct richStruct) throws WrongColor, UnexpectedException {
+ return scenarionOne.setRichStruct(richStruct);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOneServant.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOneServant.java
new file mode 100644
index 0000000000..47f0775c16
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioOneServant.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.test.corba.types;
+
+import org.apache.tuscany.sca.test.corba.generated.Color;
+import org.apache.tuscany.sca.test.corba.generated.UnexpectedException;
+import org.apache.tuscany.sca.test.corba.generated.WrongColor;
+
+/**
+ * @version $Rev$ $Date$
+ * Servant for user provided interface. Uses T* classes.
+ */
+public class TScenarioOneServant implements TScenarioOne {
+
+ private static final long serialVersionUID = 1L;
+
+ public TRichStruct setRichStruct(TRichStruct richStruct) throws WrongColor, UnexpectedException {
+ if (richStruct.innerStruct.color.value() == Color.red.value()) {
+ Color translatedColor = Color.from_int(richStruct.innerStruct.color.value());
+ throw new WrongColor(translatedColor, Color.green);
+ } else if (richStruct.longField == 0) {
+ throw new UnexpectedException("Expected richStruct.longField != 0");
+ }
+ return richStruct;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSix.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSix.java
new file mode 100644
index 0000000000..0e894cb7ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSix.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.sca.test.corba.types;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray;
+
+/**
+ * @version $Rev$ $Date$
+ * Operations for scenario six.
+ */
+public interface TScenarioSix {
+
+ @CorbaArray( {2, 2})
+ public String[][] passStringArray(@CorbaArray( {2, 2})String[][] arg);
+
+ public TAnnotatedStruct passAnnotatedStruct(TAnnotatedStruct arg);
+
+ public TRichUnion passRichUnion(TRichUnion arg);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixComponent.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixComponent.java
new file mode 100644
index 0000000000..13bc1d499e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixComponent.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.test.corba.types;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ * Component for obtaining ScenartioSix reference.
+ */
+public class TScenarioSixComponent {
+
+ private TScenarioSix scenarioSix;
+
+ @Reference
+ public void setScenarioSix(TScenarioSix scenarioSix) {
+ this.scenarioSix = scenarioSix;
+ }
+
+ public TScenarioSix getScenarioSix() {
+ return scenarioSix;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixServant.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixServant.java
new file mode 100644
index 0000000000..8e76958e31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixServant.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Tuscany scenario six servant.
+ */
+public class TScenarioSixServant implements TScenarioSix {
+
+ private static final long serialVersionUID = 1L;
+
+ public String[][] passStringArray(String[][] arg) {
+ return arg;
+ }
+
+ public TAnnotatedStruct passAnnotatedStruct(TAnnotatedStruct arg) {
+ return arg;
+ }
+
+ public TRichUnion passRichUnion(TRichUnion arg) {
+ return arg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThree.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThree.java
new file mode 100644
index 0000000000..1e4264256b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThree.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Operations for ScenarioThree.
+ */
+public interface TScenarioThree {
+
+ int getIntField();
+
+ void setIntField(int intField);
+
+ void overloadedName();
+
+ void overloadedName(String arg1);
+
+ void overloadedName(String arg1, int arg2);
+
+ int caseDifferent();
+
+ int CaseDifferent();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThreeComponent.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThreeComponent.java
new file mode 100644
index 0000000000..12b0f404ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThreeComponent.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.test.corba.types;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ * Component for obtaining ScenartioThree reference.
+ */
+public class TScenarioThreeComponent {
+
+ private TScenarioThree scenarionThree;
+
+ @Reference
+ public void setScenarioThree(TScenarioThree scenarioThree) {
+ this.scenarionThree = scenarioThree;
+ }
+
+ public TScenarioThree getScenarioThree() {
+ return scenarionThree;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThreeServant.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThreeServant.java
new file mode 100644
index 0000000000..b679214c6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioThreeServant.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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Servant for user provided interface.
+ */
+public class TScenarioThreeServant implements TScenarioThree {
+
+ public int getIntField() {
+ return 0;
+ }
+
+ public void overloadedName() {
+ }
+
+ public void overloadedName(String arg1) {
+ }
+
+ public void overloadedName(String arg1, int arg2) {
+ }
+
+ public void setIntField(int intField) {
+ }
+
+ public int CaseDifferent() {
+ return 1;
+ }
+
+ public int caseDifferent() {
+ return 0;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwo.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwo.java
new file mode 100644
index 0000000000..415634c80f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwo.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.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Operations for ScenarioTwo.
+ */
+public interface TScenarioTwo {
+
+ String getStringField();
+
+ void setStringField(String stringField);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwoComponent.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwoComponent.java
new file mode 100644
index 0000000000..937d82b33e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwoComponent.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.test.corba.types;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ * Component for obtaining ScenartioTwo reference.
+ */
+public class TScenarioTwoComponent {
+
+ private TScenarioTwo scenarioTwo;
+
+ @Reference
+ public void setScenarioTwo(TScenarioTwo scenarioTwo) {
+ this.scenarioTwo = scenarioTwo;
+ }
+
+ public TScenarioTwo getScenarioTwo() {
+ return scenarioTwo;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwoServant.java b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwoServant.java
new file mode 100644
index 0000000000..cb868d18a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioTwoServant.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 org.apache.tuscany.sca.test.corba.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Servant for user provided interface.
+ */
+public class TScenarioTwoServant implements TScenarioTwo {
+
+ private static String stringField = "";
+
+ public String getStringField() {
+ return stringField;
+ }
+
+ public void setStringField(String stringField) {
+ TScenarioTwoServant.stringField = stringField;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
new file mode 100644
index 0000000000..3e77527d73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/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.
+
+org.apache.tuscany.sca.test.corba.TestCorbaHostModuleActivator
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioFive.composite b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioFive.composite
new file mode 100644
index 0000000000..b3675a0194
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioFive.composite
@@ -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.
+-->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Corba5">
+
+ <component name="ScenarioFiveService">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFiveImpl" />
+ </component>
+ <service name="ScenarioFive" promote="ScenarioFiveService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.ScenarioFive"/>
+ <binding.sca uri="corbaname::localhost:5090#ScenarioFive"/>
+ </service>
+
+ <component name="ScenarioFive">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFiveComponent" />
+ <reference name="scenarioFive">
+ <binding.sca uri="corbaname::localhost:5090#ScenarioFive"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioFour.composite b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioFour.composite
new file mode 100644
index 0000000000..50bfc02803
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioFour.composite
@@ -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.
+-->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Corba4">
+
+ <!-- note that some binding configuration (like port or host name) is also used in JUnit test class -->
+
+ <component name="ScenarioFourService">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFourImpl" />
+ </component>
+ <service name="ScenarioFour" promote="ScenarioFourService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.ScenarioFour"/>
+ <binding.sca uri="corbaname::localhost:5080#ScenarioFour"/>
+ </service>
+
+ <component name="ScenarioFour">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFourComponent" />
+ <reference name="scenarioFour">
+ <binding.sca uri="corbaname::localhost:5080#ScenarioFour"/>
+ </reference>
+ </component>
+
+ <!-- doubled service and reference to test reuse of name server -->
+ <service name="ScenarioFourDoubled" promote="ScenarioFourService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.ScenarioFour"/>
+ <binding.sca uri="corbaname::localhost:5080#ScenarioFourReuse"/>
+ </service>
+
+ <component name="ScenarioFourReuse">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFourComponent" />
+ <reference name="scenarioFour">
+ <binding.sca uri="corbaname::localhost:5080#ScenarioFourReuse"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioOne.composite b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioOne.composite
new file mode 100644
index 0000000000..495ca2a41f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioOne.composite
@@ -0,0 +1,111 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Corba1">
+
+ <!-- note that some binding configuration (like port or host name) is also used in JUnit test class -->
+
+ <!-- reference 1 - consuming traditional CORBA service using USER PROVIDED Java interface -->
+ <component name="ScenarioOne">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioOneComponent" />
+ <reference name="scenarioOne">
+ <tuscany:binding.corba host="localhost" port="5060" name="ScenarioOne"/>
+ </reference>
+ </component>
+
+ <!-- reference 2 - consuming traditional CORBA service using GENERATED Java interface -->
+ <component name="ScenarioOneGenerated">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioOneComponent" />
+ <reference name="scenarioOne">
+ <tuscany:binding.corba host="localhost" port="5060" name="ScenarioOne"/>
+ </reference>
+ </component>
+
+ <!-- TUSCANY CORBA SERVICE 1 (TS1) - CORBA service using USER PROVIDED Java interface -->
+ <component name="ScenarionOneService">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioOneServant" />
+ </component>
+ <service name="ScenarionOneService" promote="ScenarionOneService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.TScenarioOne"/>
+ <tuscany:binding.corba host="localhost" port="5060" name="ScenarioOneTuscany" id="IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioOne:1.0"/>
+ </service>
+
+ <!-- TUSCANY CORBA SERVICE 2 (TS2) - CORBA service using GENERATED provided Java interface -->
+ <component name="ScenarionOneServiceGenerated">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioOneServant" />
+ </component>
+ <service name="ScenarionOneServiceGenerated" promote="ScenarionOneServiceGenerated">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.generated.ScenarioOneOperations"/>
+ <tuscany:binding.corba host="localhost" port="5060" name="ScenarioOneTuscanyGenerated" id="IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioOne:1.0"/>
+ </service>
+
+ <!-- reference 3 - user provided interface combined with TUSCANY SERVICE 1 (TS1) -->
+ <component name="TU2TS1">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioOneComponent" />
+ <reference name="scenarioOne">
+ <tuscany:binding.corba host="localhost" port="5060" name="ScenarioOneTuscany"/>
+ </reference>
+ </component>
+
+ <!-- reference 4 - generated interface combined with TUSCANY SERVICE 1 (TS1) -->
+ <component name="TG2TS1">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioOneComponent" />
+ <reference name="scenarioOne">
+ <tuscany:binding.corba host="localhost" port="5060" name="ScenarioOneTuscany"/>
+ </reference>
+ </component>
+
+ <!-- reference 5 - user provided interface combined with TUSCANY SERVICE 2 (TS2) -->
+ <component name="TU2TS2">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioOneComponent" />
+ <reference name="scenarioOne">
+ <tuscany:binding.corba host="localhost" port="5060" name="ScenarioOneTuscanyGenerated"/>
+ </reference>
+ </component>
+
+ <!-- reference 6 - generated interface combined with TUSCANY SERVICE 2 (TS2) -->
+ <component name="TG2TS2">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioOneComponent" />
+ <reference name="scenarioOne">
+ <tuscany:binding.corba host="localhost" port="5060" name="ScenarioOneTuscanyGenerated"/>
+ </reference>
+ </component>
+
+ <!-- TUSCANY CORBA SERVICE 3 (TS3) - CORBA service using registered using URI -->
+ <component name="ScenarionOneServiceURI">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioOneServant" />
+ </component>
+ <service name="ScenarionOneServiceGenerated" promote="ScenarionOneServiceGenerated">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.generated.ScenarioOneOperations"/>
+ <tuscany:binding.corba uri="corbaname::localhost:5060#NamedWithURI"/>
+ </service>
+
+ <!-- reference 7 - ... -->
+ <component name="UriBinding">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioOneComponent" />
+ <reference name="scenarioOne">
+ <tuscany:binding.corba uri="corbaname::localhost:5060#NamedWithURI"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioSix.composite b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioSix.composite
new file mode 100644
index 0000000000..840cd076b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioSix.composite
@@ -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.
+-->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Corba6">
+
+ <component name="ScenarioSix">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioSixComponent" />
+ <reference name="scenarioSix">
+ <tuscany:binding.corba host="localhost" port="5050" name="ScenarioSix"/>
+ </reference>
+ </component>
+
+ <component name="ScenarionSixService">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioSixServant" />
+ </component>
+ <service name="ScenarionSixService" promote="ScenarionSixService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.TScenarioSix"/>
+ <tuscany:binding.corba host="localhost" port="5050" name="ScenarioSixTuscany" id="IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioSix:1.0"/>
+ </service>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioThree.composite b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioThree.composite
new file mode 100644
index 0000000000..f02ba89496
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioThree.composite
@@ -0,0 +1,43 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Corba3">
+
+ <!-- note that some binding configuration (like port or host name) is also used in JUnit test class -->
+
+ <component name="ScenarioThreeService">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioThreeServant" />
+ </component>
+ <service name="ScenarioThreeServiceTuscany" promote="ScenarioThreeService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.TScenarioThree"/>
+ <tuscany:binding.corba uri="corbaname::localhost:5060#ScenarioThree"/>
+ </service>
+
+ <component name="ScenarioThreeReference">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioThreeComponent" />
+ <reference name="scenarioThree">
+ <tuscany:binding.corba uri="corbaname::localhost:5060#ScenarioThree"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioTwo.composite b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioTwo.composite
new file mode 100644
index 0000000000..ed3f545f72
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/ScenarioTwo.composite
@@ -0,0 +1,43 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Corba2">
+
+ <!-- note that some binding configuration (like port or host name) is also used in JUnit test class -->
+
+ <component name="ScenarioTwoService">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioTwoServant" />
+ </component>
+ <service name="ScenarioTwoServiceTuscany" promote="ScenarioTwoService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.TScenarioTwo"/>
+ <tuscany:binding.corba uri="corbaname::localhost:5060#ScenarioTwo" id="IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioTwo:1.0"/>
+ </service>
+
+ <component name="ScenarioTwo">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.TScenarioTwoComponent" />
+ <reference name="scenarioTwo">
+ <tuscany:binding.corba uri="corbaname::localhost:5060#ScenarioTwoGenerated"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/itest_scenario.idl b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/itest_scenario.idl
new file mode 100644
index 0000000000..41489a4565
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/itest_scenario.idl
@@ -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.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase itest_scenario.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module test {
+ module corba {
+ module generated {
+
+ // objects for ScenarioOne
+
+ enum Color {red, yellow, green};
+
+ typedef sequence<string> StringSequence;
+ typedef sequence<long> LongSequence;
+ typedef sequence<LongSequence> TwoDimLongSequence;
+
+ struct InnerStruct {
+ TwoDimLongSequence twoDimLongSequence;
+ string stringField;
+ Color color;
+ };
+
+ struct RichStruct {
+ InnerStruct innerStruct;
+ StringSequence stringSequence;
+ long longField;
+ };
+
+ exception WrongColor {
+ Color givenColor;
+ Color correctColor;
+ };
+
+ exception UnexpectedException {
+ string info;
+ };
+
+ interface ScenarioOne {
+
+ RichStruct setRichStruct(in RichStruct richStruct) raises (WrongColor, UnexpectedException);
+
+ };
+
+ // objects for ScenarioTwo
+
+ interface ScenarioTwo {
+
+ attribute string stringField;
+
+ };
+
+ typedef string StringArray[2][2];
+
+ struct AnnotatedStruct {
+ StringArray stringArray;
+ };
+
+ union InnerUnion switch (long) {
+ case 1: long x;
+ case 2: float y;
+ };
+
+ union RichUnion switch (long) {
+ case 1: long x;
+ case 2: float y;
+ case 3: string z;
+ case 4: InnerUnion iu;
+ default: boolean a;
+ };
+
+ interface ScenarioSix {
+
+ StringArray passStringArray(in StringArray arg);
+
+ AnnotatedStruct passAnnotatedStruct(in AnnotatedStruct arg);
+
+ RichUnion passRichUnion(in RichUnion arg);
+
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sandbox/sebastien/java/embed/itest/corba/src/test/resources/scenariofour.xsd b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/scenariofour.xsd
new file mode 100644
index 0000000000..2669b54be3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/corba/src/test/resources/scenariofour.xsd
@@ -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.
+-->
+<schema targetNamespace="http://example.com/scenariofour" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="ScenarioFourSdo">
+ <complexType>
+ <sequence>
+ <element name="message" minOccurs="1" type="string" />
+ <element name="symbol" minOccurs="1" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/pom.xml b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/pom.xml
new file mode 100644
index 0000000000..669c85ca19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/pom.xml
@@ -0,0 +1,188 @@
+<?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</groupId>
+ <artifactId>itest-databindings</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>itest-databindings-jaxb-bottom-up</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <name>Apache Tuscany SCA iTest Databinding - JAXB Bottom Up</name>
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>${pom.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>${pom.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency-->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-databindings-common</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency-->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>${pom.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-rt</artifactId>
+ <version>2.1.3</version>
+ </dependency>
+ <!-- Added by Simon Nash -->
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- End of addition -->
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/AClientService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/AClientService.java
new file mode 100644
index 0000000000..5d389643cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/AClientService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for AClientService.
+ */
+@Remotable
+public interface AClientService {
+ public String getGreetingsForward(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/AService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/AService.java
new file mode 100644
index 0000000000..52f1c01fd8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/AService.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.itest.databindings.jaxb;
+
+import javax.jws.soap.SOAPBinding;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for AService.
+ */
+@Remotable
+@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public interface AService {
+ public String getGreetings(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean1.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean1.java
new file mode 100644
index 0000000000..f1c948dc1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean1.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@XmlSeeAlso({Bean10.class, Bean11.class, Bean10[].class, Bean11[].class})
+public class Bean1<T> {
+ private T item;
+
+ public Bean1() {
+ }
+
+ public Bean1(T item) {
+ this.item = item;
+ }
+
+ public void setItem(T item) {
+ this.item = item;
+ }
+
+ public T getItem() {
+ return item;
+ }
+
+ public boolean equals(Object that) {
+ if(that == null) {
+ return false;
+ }
+ if(that.getClass() != this.getClass()) {
+ return false;
+ }
+
+ Bean1<?> that1 = (Bean1<?>)that;
+ if(this == that1) {
+ return true;
+ } else if(this.item != null) {
+ return this.item.equals(that1.item);
+ } else {
+ return that1.item == null;
+ }
+ }
+
+ public String toString() {
+ return this.getClass().getSimpleName()+"[item = "+item+"]";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean10.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean10.java
new file mode 100644
index 0000000000..4a4419a42b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean10.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.databindings.jaxb;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Bean10 extends Bean1<String> {
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean11.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean11.java
new file mode 100644
index 0000000000..65f019ec48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean11.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.databindings.jaxb;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Bean11 extends Bean1<String> {
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean2.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean2.java
new file mode 100644
index 0000000000..45c01dc054
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean2.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@XmlSeeAlso({Bean3.class, Bean3[].class, Bean31.class, Bean31[].class})
+public class Bean2 {
+ private String name;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean equals(Object that) {
+ if(that == null) {
+ return false;
+ }
+
+ if(this.getClass() != that.getClass()) {
+ return false;
+ }
+
+ if(this == that) {
+ return true;
+ } else if(this.name != null) {
+ return this.name.equals(((Bean2)that).name);
+ } else {
+ return ((Bean2)that).name == null;
+ }
+ }
+
+ public String toString() {
+ return this.getClass().getSimpleName()+"[name = "+name+"]";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean3.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean3.java
new file mode 100644
index 0000000000..4e0bd38b2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean3.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 org.apache.tuscany.sca.itest.databindings.jaxb;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Bean3 extends Bean2 {
+ private String address;
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public boolean equals(Object that) {
+ if(that == null) {
+ return false;
+ }
+
+ if(this.getClass() != that.getClass()) {
+ return false;
+ }
+
+ if(this == that) {
+ return true;
+ } else if(this.address != null) {
+ return this.address.equals(((Bean3)that).address) && super.equals(that);
+ } else {
+ return ((Bean3)that).address == null && super.equals(that);
+ }
+ }
+
+ public String toString() {
+ return this.getClass().getSimpleName()+"[name = "+super.getName()+", address = "+address+"]";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean31.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean31.java
new file mode 100644
index 0000000000..40aff31297
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/Bean31.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 org.apache.tuscany.sca.itest.databindings.jaxb;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Bean31 extends Bean2 {
+ private String address;
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public boolean equals(Object that) {
+ if(that == null) {
+ return false;
+ }
+
+ if(this.getClass() != that.getClass()) {
+ return false;
+ }
+
+ if(this == that) {
+ return true;
+ } else if(this.address != null) {
+ return this.address.equals(((Bean31)that).address) && super.equals(that);
+ } else {
+ return ((Bean31)that).address == null && super.equals(that);
+ }
+ }
+
+ public String toString() {
+ return this.getClass().getSimpleName()+"[name = "+super.getName()+", address = "+address+"]";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsLocalService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsLocalService.java
new file mode 100644
index 0000000000..ca012b967d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsLocalService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+/**
+ * The interface for GenericsLocalService.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GenericsLocalService {
+ Bean1<String> getTypeExplicit(Bean1<String> arg);
+
+ <T> Bean1<T> getTypeUnbound(T[] anArray);
+
+ <T extends Bean2> Bean1<T> getTypeExtends(T[] anArray);
+
+ <T extends Bean1<String>> Bean1<T> getRecursiveTypeBound(T[] anArray);
+
+ Bean1<?> getWildcardUnbound(Bean1<?> arg);
+
+ Bean1<? super Bean3> getWildcardSuper(Bean1<? super Bean3> arg);
+
+ Bean1<? extends Bean2> getWildcardExtends(Bean1<? extends Bean2> arg);
+
+ Bean2 getPolymorphic(Bean2 arg);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsService.java
new file mode 100644
index 0000000000..be446c9759
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsService.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.itest.databindings.jaxb;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for GenericsService.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface GenericsService extends GenericsLocalService{
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsServiceClient.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsServiceClient.java
new file mode 100644
index 0000000000..3bae554dc7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsServiceClient.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.databindings.jaxb;
+
+/**
+ * The interface for GenericsServiceClient.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GenericsServiceClient {
+ Bean1<String> getTypeExplicitForward(Bean1<String> arg);
+
+ <T> Bean1<T> getTypeUnboundForward(T[] anArray);
+
+ <T extends Bean2> Bean1<T> getTypeExtendsForward(T[] anArray);
+
+ <T extends Bean1<String>> Bean1<T> getRecursiveTypeBoundForward(T[] anArray);
+
+ Bean1<?> getWildcardUnboundForward(Bean1<?> arg);
+
+ Bean1<? super Bean3> getWildcardSuperForward(Bean1<? super Bean3> arg);
+
+ Bean1<? extends Bean2> getWildcardExtendsForward(Bean1<? extends Bean2> arg);
+
+ Bean2 getPolymorphicForward(Bean2 arg);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloLocalServiceSimple.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloLocalServiceSimple.java
new file mode 100644
index 0000000000..a31cc3d45a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloLocalServiceSimple.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.sca.itest.databindings.jaxb;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The interface for HelloLocalServiceSimple.
+ */
+public interface HelloLocalServiceSimple {
+ String getGreetings(String name);
+ String[] getGreetingsArray(String[] names);
+ List<String> getGreetingsList(List<String> names);
+ ArrayList<String> getGreetingsArrayList(ArrayList<String> names);
+ Map<String, String> getGreetingsMap(Map<String, String> namesMap);
+ HashMap<String, String> getGreetingsHashMap(HashMap<String, String> namesMap);
+ String getGreetingsVarArgs(String... names);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceSimple.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceSimple.java
new file mode 100644
index 0000000000..df9e6e53ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceSimple.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for HelloServiceSimple.
+ */
+@Remotable
+public interface HelloServiceSimple extends HelloLocalServiceSimple {
+ // Add any methods to the local interface.
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceSimpleClient.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceSimpleClient.java
new file mode 100644
index 0000000000..779943739e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceSimpleClient.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 org.apache.tuscany.sca.itest.databindings.jaxb;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The interface for HelloServiceSimpleClient.
+ */
+public interface HelloServiceSimpleClient {
+ String getGreetingsForward(String name);
+ String[] getGreetingsArrayForward(String[] names);
+ List<String> getGreetingsListForward(List<String> names);
+ ArrayList<String> getGreetingsArrayListForward(ArrayList<String> names);
+ Map<String, String> getGreetingsMapForward(Map<String, String> namesMap);
+ HashMap<String, String> getGreetingsHashMapForward(HashMap<String, String> namesMap);
+ String getGreetingsVarArgsForward(String... names);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesLocalService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesLocalService.java
new file mode 100644
index 0000000000..6239c0f5f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesLocalService.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.sca.itest.databindings.jaxb;
+
+
+/**
+ * The interface for PrimitivesLocalService.
+ */
+public interface PrimitivesLocalService {
+ boolean negateBoolean(boolean flag);
+ boolean[] negateBooleanArray(boolean[] flags);
+ boolean[] identityBooleanArray(boolean[] flags);
+ byte negateByte(byte b);
+ byte[] negateByteArray(byte[] ba);
+ byte[] identityByteArray(byte[] ba);
+ short negateShort(short s);
+ short[] negateShortArray(short[] s);
+ short[] identityShortArray(short[] sa);
+ int negateInt(int s);
+ int[] negateIntArray(int[] s);
+ int[] identityIntArray(int[] ia);
+ long negateLong(long l);
+ long[] negateLongArray(long[] la);
+ long[] identityLongArray(long[] la);
+ float negateFloat(float f);
+ float[] negateFloatArray(float[] fa);
+ float[] identityFloatArray(float[] fa);
+ double negateDouble(double d);
+ double[] negateDoubleArray(double[] da);
+ double[] identityDoubleArray(double[] da);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesService.java
new file mode 100644
index 0000000000..690a2adb3d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for PrimitivesService.
+ */
+@Remotable
+public interface PrimitivesService extends PrimitivesLocalService {
+ // Add any methods to the local interface.
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesServiceClient.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesServiceClient.java
new file mode 100644
index 0000000000..3bdf886dfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesServiceClient.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.databindings.jaxb;
+
+
+/**
+ * The interface for PrimitivesServiceClient.
+ */
+public interface PrimitivesServiceClient {
+ boolean negateBooleanForward(boolean flag);
+ boolean[] negateBooleanArrayForward(boolean[] flags);
+ boolean passByValueBooleanArray();
+ byte negateByteForward(byte b);
+ byte[] negateByteArrayForward(byte[] ba);
+ boolean passByValueByteArray();
+ short negateShortForward(short s);
+ short[] negateShortArrayForward(short[] sa);
+ boolean passByValueShortArray();
+ int negateIntForward(int i);
+ int[] negateIntArrayForward(int[] ia);
+ boolean passByValueIntArray();
+ long negateLongForward(long l);
+ long[] negateLongArrayForward(long[] la);
+ boolean passByValueLongArray();
+ float negateFloatForward(float f);
+ float[] negateFloatArrayForward(float[] fa);
+ boolean passByValueFloatArray();
+ double negateDoubleForward(double d);
+ double[] negateDoubleArrayForward(double[] da);
+ boolean passByValueDoubleArray();
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesLocalService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesLocalService.java
new file mode 100644
index 0000000000..0fdf69459f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesLocalService.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.itest.databindings.jaxb;
+
+import java.awt.Image;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+
+/**
+ * The interface for StandardTypesLocalService.
+ */
+public interface StandardTypesLocalService {
+ BigInteger getNewBigInteger(BigInteger bi);
+ BigInteger[] getNewBigIntegerArray(BigInteger[] bia);
+
+ BigDecimal getNewBigDecimal(BigDecimal bd);
+ BigDecimal[] getNewBigDecimalArray(BigDecimal[] bda);
+
+ Calendar getNewCalendar(Calendar c);
+ Calendar[] getNewCalendarArray(Calendar[] ca);
+
+ Date getNewDate(Date d);
+ Date[] getNewDateArray(Date[] da);
+
+ QName getNewQName(QName qname);
+ QName[] getNewQNameArray(QName[] qnames);
+
+ URI getNewURI(URI uri);
+ URI[] getNewURIArray(URI[] uris);
+
+ XMLGregorianCalendar getNewXMLGregorianCalendar(XMLGregorianCalendar xgcal);
+ XMLGregorianCalendar[] getNewXMLGregorianCalendarArray(XMLGregorianCalendar[] xgcal);
+
+ Duration getNewDuration(Duration d);
+ Duration[] getNewDurationArray(Duration[] da);
+
+ Object getNewObject(Object obj);
+ Object[] getNewObjectArray(Object[] objs);
+
+ Image getNewImage(Image img);
+ Image[] getNewImageArray(Image[] imgs);
+
+ DataHandler getNewDataHandler(DataHandler dh);
+ DataHandler[] getNewDataHandlerArray(DataHandler[] dha);
+
+ Source getNewSource(Source src);
+ Source[] getNewSourceArray(Source[] srcs);
+
+ UUID getNewUUID(UUID uuid);
+ UUID[] getNewUUIDArray(UUID[] uuids);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesService.java
new file mode 100644
index 0000000000..3b9690b7d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesService.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.itest.databindings.jaxb;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+
+/**
+ * The interface for StandardTypesService.
+ */
+@Remotable
+public interface StandardTypesService extends StandardTypesLocalService{
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesServiceClient.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesServiceClient.java
new file mode 100644
index 0000000000..351d9df0cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesServiceClient.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.itest.databindings.jaxb;
+
+import java.awt.Image;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+
+/**
+ * The interface for StandardTypesServiceClient.
+ */
+public interface StandardTypesServiceClient {
+ BigInteger getNewBigIntegerForward(BigInteger bi);
+ BigInteger[] getNewBigIntegerArrayForward(BigInteger[] bia);
+
+ BigDecimal getNewBigDecimalForward(BigDecimal bd);
+ BigDecimal[] getNewBigDecimalArrayForward(BigDecimal[] bda);
+
+ Calendar getNewCalendarForward(Calendar c);
+ Calendar[] getNewCalendarArrayForward(Calendar[] ca);
+
+ Date getNewDateForward(Date d);
+ Date[] getNewDateArrayForward(Date[] da);
+
+ QName getNewQNameForward(QName qname);
+ QName[] getNewQNameArrayForward(QName[] qnames);
+
+ URI getNewURIForward(URI uri);
+ URI[] getNewURIArrayForward(URI[] uris);
+
+ XMLGregorianCalendar getNewXMLGregorianCalendarForward(XMLGregorianCalendar xgcal);
+ XMLGregorianCalendar[] getNewXMLGregorianCalendarArrayForward(XMLGregorianCalendar[] xgcals);
+
+ Duration getNewDurationForward(Duration d);
+ Duration[] getNewDurationArrayForward(Duration[] da);
+
+ Object getNewObjectForward(Object obj);
+ Object[] getNewObjectArrayForward(Object[] objs);
+
+ Image getNewImageForward(Image img);
+ Image[] getNewImageArrayForward(Image[] imgs);
+
+ DataHandler getNewDataHandlerForward(DataHandler dh);
+ DataHandler[] getNewDataHandlerArrayForward(DataHandler[] dha);
+
+ Source getNewSourceForward(Source src);
+ Source[] getNewSourceArrayForward(Source[] srcs);
+
+ UUID getNewUUIDForward(UUID uuid);
+ UUID[] getNewUUIDArrayForward(UUID[] uuids);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/AClientServiceImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/AClientServiceImpl.java
new file mode 100644
index 0000000000..2f3bd3f2cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/AClientServiceImpl.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 org.apache.tuscany.sca.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.AClientService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.AService;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements AService.
+ */
+@Service(AClientService.class)
+public class AClientServiceImpl implements AClientService {
+
+ @Reference
+ protected AService aService;
+
+ public String getGreetingsForward(String name) {
+ return aService.getGreetings(name);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/AServiceImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/AServiceImpl.java
new file mode 100644
index 0000000000..078be8896e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/AServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.AService;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements AService.
+ */
+@Service(AService.class)
+public class AServiceImpl implements AService {
+
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsLocalServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsLocalServiceClientImpl.java
new file mode 100644
index 0000000000..4d451e6d32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsLocalServiceClientImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean1;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean2;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean3;
+import org.apache.tuscany.sca.itest.databindings.jaxb.GenericsLocalService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.GenericsServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of GenericsLocalServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(GenericsServiceClient.class)
+public class GenericsLocalServiceClientImpl implements GenericsServiceClient {
+
+ private GenericsLocalService service;
+
+ @Reference(required=false)
+ protected void setGenericsLocalService(GenericsLocalService service) {
+ this.service = service;
+ }
+
+ public Bean1<String> getTypeExplicitForward(Bean1<String> arg) {
+ return service.getTypeExplicit(arg);
+ }
+
+ public <T> Bean1<T> getTypeUnboundForward(T[] anArray) {
+ return service.getTypeUnbound(anArray);
+ }
+
+ public <T extends Bean2> Bean1<T> getTypeExtendsForward(T[] anArray) {
+ return service.getTypeExtends(anArray);
+ }
+
+ public <T extends Bean1<String>> Bean1<T> getRecursiveTypeBoundForward(T[] anArray) {
+ return service.getRecursiveTypeBound(anArray);
+ }
+
+ public Bean1<?> getWildcardUnboundForward(Bean1<?> arg) {
+ return service.getWildcardUnbound(arg);
+ }
+
+ public Bean1<? super Bean3> getWildcardSuperForward(Bean1<? super Bean3> arg) {
+ return service.getWildcardSuper(arg);
+ }
+
+ public Bean1<? extends Bean2> getWildcardExtendsForward(Bean1<? extends Bean2> arg) {
+ return service.getWildcardExtends(arg);
+ }
+
+ public Bean2 getPolymorphicForward(Bean2 arg) {
+ return service.getPolymorphic(arg);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsServiceClientImpl.java
new file mode 100644
index 0000000000..d520e64881
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsServiceClientImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.GenericsService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.GenericsServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of GenericsServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(GenericsServiceClient.class)
+public class GenericsServiceClientImpl extends GenericsLocalServiceClientImpl {
+
+ @Reference
+ public void setGenericsService(GenericsService service) {
+ super.setGenericsLocalService(service);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsServiceImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsServiceImpl.java
new file mode 100644
index 0000000000..460f6dd1a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsServiceImpl.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean1;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean2;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean3;
+import org.apache.tuscany.sca.itest.databindings.jaxb.GenericsLocalService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.GenericsService;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of GenericsService.
+ * This implementation provides both a local and a remotable service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(value={GenericsService.class, GenericsLocalService.class})
+public class GenericsServiceImpl implements GenericsService, GenericsLocalService {
+
+ public Bean1<String> getTypeExplicit(Bean1<String> arg) {
+ return GenericsTransformer.getTypeExplicit(arg);
+ }
+
+ public <T> Bean1<T> getTypeUnbound(T[] anArray) {
+ return GenericsTransformer.getTypeUnbound(anArray);
+ }
+
+ public <T extends Bean2> Bean1<T> getTypeExtends(T[] anArray) {
+ return GenericsTransformer.getTypeExtends(anArray);
+ }
+
+ public <T extends Bean1<String>> Bean1<T> getRecursiveTypeBound(T[] anArray) {
+ return GenericsTransformer.getRecursiveTypeBound(anArray);
+ }
+
+ public Bean1<?> getWildcardUnbound(Bean1<?> arg) {
+ return GenericsTransformer.getWildcardUnbound(arg);
+ }
+
+ public Bean1<? super Bean3> getWildcardSuper(Bean1<? super Bean3> arg) {
+ return GenericsTransformer.getWildcardSuper(arg);
+ }
+
+ public Bean1<? extends Bean2> getWildcardExtends(Bean1<? extends Bean2> arg) {
+ return GenericsTransformer.getWildcardExtends(arg);
+ }
+
+ public Bean2 getPolymorphic(Bean2 arg) {
+ return GenericsTransformer.getPolymorphic(arg);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsTransformer.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsTransformer.java
new file mode 100644
index 0000000000..858b8da59a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/GenericsTransformer.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean1;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean10;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean11;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean2;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean3;
+import org.apache.tuscany.sca.itest.databindings.jaxb.Bean31;
+
+
+/**
+ * GenericsTransformer class that provide for transforming input provided to GenericsService methods.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GenericsTransformer {
+
+ public static Bean1<String> getTypeExplicit(Bean1<String> arg) {
+ return new Bean1<String>(arg.getItem() == null ? null : arg.getItem()+" AA");
+ }
+
+ public static <T> Bean1<T> getTypeUnbound(T[] arg) {
+ if(arg instanceof String[]) {
+ return new Bean1<T>(arg[0]);
+ } else if(arg instanceof Integer[]){
+ return new Bean1<T>(arg[1]);
+ } else {
+ return new Bean1<T>(arg[2]);
+ }
+ }
+
+ public static <T extends Bean2> Bean1<T> getTypeExtends(T[] arg) {
+ if(arg instanceof Bean3[]) {
+ return new Bean1<T>(arg[0]);
+ } else if(arg instanceof Bean31[]) {
+ return new Bean1<T>(arg[1]);
+ } else {
+ return new Bean1<T>(arg[2]);
+ }
+ }
+
+ public static <T extends Bean1<String>> Bean1<T> getRecursiveTypeBound(T[] arg) {
+ if(arg instanceof Bean10[]) {
+ return new Bean1<T>(arg[0]);
+ } else if(arg instanceof Bean11[]) {
+ return new Bean1<T>(arg[1]);
+ } else {
+ return new Bean1<T>(arg[2]);
+ }
+ }
+
+ public static Bean1<?> getWildcardUnbound(Bean1<?> arg) {
+ if(arg.getItem() instanceof String) {
+ Bean1<String> temp = new Bean1<String>();
+ temp.setItem("Hello "+arg.getItem());
+ return temp;
+ } else if(arg.getItem() instanceof Integer) {
+ Bean1<Integer> temp = new Bean1<Integer>();
+ temp.setItem(10+(Integer)arg.getItem());
+ return temp;
+ } else {
+ return new Bean1<String>(arg.toString());
+ }
+ }
+
+ public static Bean1<? super Bean3> getWildcardSuper(Bean1<? super Bean3> arg) {
+ Object item = arg.getItem();
+ if(item instanceof Bean3) {
+ Bean3 temp = new Bean3();
+ temp.setName("Hello " + ((Bean3)item).getName());
+ temp.setAddress("New "+((Bean3)item).getAddress());
+ return new Bean1<Bean3>(temp);
+ } else if(item instanceof Bean2) {
+ Bean2 temp = new Bean2();
+ temp.setName("Hello " + ((Bean3)item).getName());
+ return new Bean1<Bean2>(temp);
+ } else {
+ Bean2 temp = new Bean2();
+ temp.setName(item.toString());
+ return new Bean1<Bean2>(temp);
+ }
+ }
+
+ public static Bean1<? extends Bean2> getWildcardExtends(Bean1<? extends Bean2> arg) {
+ Bean2 item = arg.getItem();
+ if(item instanceof Bean3) {
+ Bean3 temp = new Bean3();
+ temp.setName("Hello "+item.getName());
+ temp.setAddress("New "+((Bean3)item).getAddress());
+ return new Bean1<Bean3>(temp);
+ } else if(item instanceof Bean31) {
+ Bean31 temp = new Bean31();
+ temp.setName("Hello "+item.getName());
+ temp.setAddress("New "+((Bean31)item).getAddress());
+ return new Bean1<Bean31>(temp);
+ } else {
+ Bean2 temp = new Bean2();
+ temp.setName("Hello "+item.getName());
+ return new Bean1<Bean2>(temp);
+ }
+ }
+
+ public static Bean2 getPolymorphic(Bean2 arg) {
+ return arg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloLocalServiceSimpleClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloLocalServiceSimpleClientImpl.java
new file mode 100644
index 0000000000..6c7c82a4ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloLocalServiceSimpleClientImpl.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.itest.databindings.jaxb.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloLocalServiceSimple;
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceSimpleClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of HelloServiceSimpleClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ */
+@Service(HelloServiceSimpleClient.class)
+public class HelloLocalServiceSimpleClientImpl implements HelloServiceSimpleClient {
+
+ private HelloLocalServiceSimple service;
+
+ @Reference(required=false)
+ protected void setHelloLocalServiceSimple(HelloLocalServiceSimple service) {
+ this.service = service;
+ }
+
+ public String getGreetingsForward(String name) {
+ return service.getGreetings(name);
+ }
+
+ public String[] getGreetingsArrayForward(String[] names) {
+ return service.getGreetingsArray(names);
+ }
+
+ public List<String> getGreetingsListForward(List<String> names) {
+ return service.getGreetingsList(names);
+ }
+
+ public Map<String, String> getGreetingsMapForward(Map<String, String> namesMap) {
+ return service.getGreetingsMap(namesMap);
+ }
+
+ public ArrayList<String> getGreetingsArrayListForward(ArrayList<String> names) {
+ return service.getGreetingsArrayList(names);
+ }
+
+ public HashMap<String, String> getGreetingsHashMapForward(HashMap<String, String> namesMap) {
+ return service.getGreetingsHashMap(namesMap);
+ }
+
+ public String getGreetingsVarArgsForward(String... names) {
+ return service.getGreetingsVarArgs(names[0], names[1], names[2]);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceSimpleClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceSimpleClientImpl.java
new file mode 100644
index 0000000000..44b6e9d906
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceSimpleClientImpl.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 org.apache.tuscany.sca.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceSimple;
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceSimpleClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of HelloServiceSimpleClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ */
+@Service(HelloServiceSimpleClient.class)
+public class HelloServiceSimpleClientImpl extends HelloLocalServiceSimpleClientImpl {
+
+ @Reference
+ public void setHelloServiceSimple(HelloServiceSimple service) {
+ super.setHelloLocalServiceSimple(service);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceSimpleImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceSimpleImpl.java
new file mode 100644
index 0000000000..e0b81152ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceSimpleImpl.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloLocalServiceSimple;
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceSimple;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of HelloServiceSimple.
+ * The implementation provides both a local and a remotable service.
+ */
+@Service(value={HelloServiceSimple.class, HelloLocalServiceSimple.class})
+public class HelloServiceSimpleImpl implements HelloServiceSimple {
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+
+ public String[] getGreetingsArray(String[] names) {
+ String[] resps = new String[names.length];
+ for (int i = 0; i < names.length; ++i) {
+ resps[i] = "Hello " + names[i];
+ }
+ return resps;
+ }
+
+ public List<String> getGreetingsList(List<String> names) {
+ List<String> resps = new ArrayList<String>();
+ for (int i = 0; i < names.size(); ++i) {
+ resps.add("Hello " + names.get(i));
+ }
+ return resps;
+ }
+
+ public ArrayList<String> getGreetingsArrayList(ArrayList<String> names) {
+ ArrayList<String> resps = new ArrayList<String>();
+ for (int i = 0; i < names.size(); ++i) {
+ resps.add("Hello " + names.get(i));
+ }
+ return resps;
+ }
+
+ public Map<String, String> getGreetingsMap(Map<String, String> namesMap) {
+ for (Map.Entry<String, String> entry : namesMap.entrySet()) {
+ entry.setValue("Hello " + entry.getKey());
+ }
+ return namesMap;
+ }
+
+ public HashMap<String, String> getGreetingsHashMap(HashMap<String, String> namesMap) {
+ for (Map.Entry<String, String> entry : namesMap.entrySet()) {
+ entry.setValue("Hello " + entry.getKey());
+ }
+ return namesMap;
+ }
+
+ public String getGreetingsVarArgs(String... names) {
+ String resp = "Hello";
+ for(int i = 0; i < names.length; ++i) {
+ resp += (" "+names[i]);
+ }
+ return resp;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesLocalServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesLocalServiceClientImpl.java
new file mode 100644
index 0000000000..eea19521c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesLocalServiceClientImpl.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesLocalService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of PrimitivesLocalServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ */
+@Service(PrimitivesServiceClient.class)
+public class PrimitivesLocalServiceClientImpl implements PrimitivesServiceClient {
+
+ private PrimitivesLocalService service;
+
+ @Reference(required=false)
+ protected void setPrimitivesLocalService(PrimitivesLocalService service) {
+ this.service = service;
+ }
+
+ public boolean negateBooleanForward(boolean flag) {
+ return service.negateBoolean(flag);
+ }
+
+ public boolean[] negateBooleanArrayForward(boolean[] flags) {
+ return service.negateBooleanArray(flags);
+ }
+
+ public boolean passByValueBooleanArray() {
+ boolean[] req = new boolean[2];
+ boolean[] resp = service.identityBooleanArray(req);
+ return req != resp;
+ }
+
+ public byte negateByteForward(byte b) {
+ return service.negateByte(b);
+ }
+
+ public byte[] negateByteArrayForward(byte[] ba) {
+ return service.negateByteArray(ba);
+ }
+
+ public boolean passByValueByteArray() {
+ byte[] req = new byte[2];
+ byte[] resp = service.identityByteArray(req);
+ return req != resp;
+ }
+
+ public short negateShortForward(short s) {
+ return service.negateShort(s);
+ }
+
+ public short[] negateShortArrayForward(short[] s) {
+ return service.negateShortArray(s);
+ }
+
+ public boolean passByValueShortArray() {
+ short[] req = new short[2];
+ short[] resp = service.identityShortArray(req);
+ return req != resp;
+ }
+
+ public int negateIntForward(int i) {
+ return service.negateInt(i);
+ }
+
+ public int[] negateIntArrayForward(int[] ia) {
+ return service.negateIntArray(ia);
+ }
+
+ public boolean passByValueIntArray() {
+ int[] req = new int[2];
+ int[] resp = service.identityIntArray(req);
+ return req != resp;
+ }
+
+ public long negateLongForward(long l) {
+ return service.negateLong(l);
+ }
+
+ public long[] negateLongArrayForward(long[] la) {
+ return service.negateLongArray(la);
+ }
+
+ public boolean passByValueLongArray() {
+ long[] req = new long[2];
+ long[] resp = service.identityLongArray(req);
+ return req != resp;
+ }
+
+ public float negateFloatForward(float f) {
+ return service.negateFloat(f);
+ }
+
+ public float[] negateFloatArrayForward(float[] fa) {
+ return service.negateFloatArray(fa);
+ }
+
+ public boolean passByValueFloatArray() {
+ float[] req = new float[2];
+ float[] resp = service.identityFloatArray(req);
+ return req != resp;
+ }
+
+ public double negateDoubleForward(double d) {
+ return service.negateDouble(d);
+ }
+
+ public double[] negateDoubleArrayForward(double[] da) {
+ return service.negateDoubleArray(da);
+ }
+
+ public boolean passByValueDoubleArray() {
+ double[] req = new double[2];
+ double[] resp = service.identityDoubleArray(req);
+ return req != resp;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceClientImpl.java
new file mode 100644
index 0000000000..263d1212ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceClientImpl.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 org.apache.tuscany.sca.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of PrimitivesServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ */
+@Service(PrimitivesServiceClient.class)
+public class PrimitivesServiceClientImpl extends PrimitivesLocalServiceClientImpl {
+
+ @Reference
+ public void setPrimitivesService(PrimitivesService service) {
+ super.setPrimitivesLocalService(service);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceImpl.java
new file mode 100644
index 0000000000..182ccf0f83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceImpl.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.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesLocalService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of PrimitivesService.
+ * This implementation provides both a local and a remotable service.
+ */
+@Service(value={PrimitivesService.class, PrimitivesLocalService.class})
+public class PrimitivesServiceImpl implements PrimitivesService, PrimitivesLocalService {
+
+ public boolean negateBoolean(boolean flag) {
+ return !flag;
+ }
+
+ public boolean[] negateBooleanArray(boolean[] flags) {
+ boolean[] resp = new boolean[flags.length];
+
+ for(int i = 0; i < flags.length; ++i) {
+ resp[i] = !flags[i];
+ }
+ return resp;
+ }
+
+ public boolean[] identityBooleanArray(boolean[] flags) {
+ return flags;
+ }
+
+ public byte negateByte(byte b) {
+ return (byte)-b;
+ }
+
+ public byte[] negateByteArray(byte[] ba) {
+ byte[] resp = new byte[ba.length];
+
+ for(int i = 0; i < ba.length; ++i) {
+ resp[i] = (byte)-ba[i];
+ }
+ return resp;
+ }
+
+ public byte[] identityByteArray(byte[] ba) {
+ return ba;
+ }
+
+ public short negateShort(short s) {
+ return (short)-s;
+ }
+
+ public short[] negateShortArray(short[] s) {
+ short[] resp = new short[s.length];
+
+ for(int i = 0; i < s.length; ++i) {
+ resp[i] = (short)-s[i];
+ }
+ return resp;
+ }
+
+ public short[] identityShortArray(short[] sa) {
+ return sa;
+ }
+
+ public int negateInt(int i) {
+ return -i;
+ }
+
+ public int[] negateIntArray(int[] ia) {
+ int[] resp = new int[ia.length];
+
+ for(int i = 0; i < ia.length; ++i) {
+ resp[i] = -ia[i];
+ }
+ return resp;
+ }
+
+ public int[] identityIntArray(int[] ia) {
+ return ia;
+ }
+
+ public long negateLong(long l) {
+ return -l;
+ }
+
+ public long[] negateLongArray(long[] la) {
+ long[] resp = new long[la.length];
+
+ for(int i = 0; i < la.length; ++i) {
+ resp[i] = -la[i];
+ }
+ return resp;
+ }
+
+ public long[] identityLongArray(long[] la) {
+ return la;
+ }
+
+ public float negateFloat(float f) {
+ return -f;
+ }
+
+ public float[] negateFloatArray(float[] fa) {
+ float[] resp = new float[fa.length];
+
+ for(int i = 0; i < fa.length; ++i) {
+ resp[i] = -fa[i];
+ }
+ return resp;
+ }
+
+ public float[] identityFloatArray(float[] fa) {
+ return fa;
+ }
+
+ public double negateDouble(double d) {
+ return -d;
+ }
+
+ public double[] negateDoubleArray(double[] da) {
+ double[] resp = new double[da.length];
+
+ for(int i = 0; i < da.length; ++i) {
+ resp[i] = -da[i];
+ }
+ return resp;
+ }
+
+ public double[] identityDoubleArray(double[] da) {
+ return da;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesLocalServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesLocalServiceClientImpl.java
new file mode 100644
index 0000000000..3ceee3c4b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesLocalServiceClientImpl.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import java.awt.Image;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesLocalService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of StandardTypesLocalServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ */
+@Service(StandardTypesServiceClient.class)
+public class StandardTypesLocalServiceClientImpl implements StandardTypesServiceClient {
+
+ private StandardTypesLocalService service;
+
+ @Reference(required=false)
+ protected void setStandardTypesLocalService(StandardTypesLocalService service) {
+ this.service = service;
+ }
+
+ public BigInteger getNewBigIntegerForward(BigInteger bi) {
+ return service.getNewBigInteger(bi);
+ }
+
+ public BigInteger[] getNewBigIntegerArrayForward(BigInteger[] bia) {
+ return service.getNewBigIntegerArray(bia);
+ }
+
+ public BigDecimal getNewBigDecimalForward(BigDecimal bd) {
+ return service.getNewBigDecimal(bd);
+ }
+
+ public BigDecimal[] getNewBigDecimalArrayForward(BigDecimal[] bda) {
+ return service.getNewBigDecimalArray(bda);
+ }
+ public Calendar getNewCalendarForward(Calendar c) {
+ return service.getNewCalendar(c);
+ }
+ public Calendar[] getNewCalendarArrayForward(Calendar[] ca) {
+ return service.getNewCalendarArray(ca);
+ }
+
+ public Date getNewDateForward(Date d) {
+ return service.getNewDate(d);
+ }
+
+ public Date[] getNewDateArrayForward(Date[] da) {
+ return service.getNewDateArray(da);
+ }
+
+ public QName getNewQNameForward(QName qname) {
+ return service.getNewQName(qname);
+ }
+
+ public QName[] getNewQNameArrayForward(QName[] qnames) {
+ return service.getNewQNameArray(qnames);
+ }
+
+ public URI getNewURIForward(URI uri) {
+ return service.getNewURI(uri);
+ }
+
+ public URI[] getNewURIArrayForward(URI[] uris) {
+ return service.getNewURIArray(uris);
+ }
+
+ public XMLGregorianCalendar getNewXMLGregorianCalendarForward(XMLGregorianCalendar xgcal) {
+ return service.getNewXMLGregorianCalendar(xgcal);
+ }
+
+ public XMLGregorianCalendar[] getNewXMLGregorianCalendarArrayForward(XMLGregorianCalendar[] xgcals) {
+ return service.getNewXMLGregorianCalendarArray(xgcals);
+ }
+
+ public Duration getNewDurationForward(Duration d) {
+ return service.getNewDuration(d);
+ }
+
+ public Duration[] getNewDurationArrayForward(Duration[] da) {
+ return service.getNewDurationArray(da);
+ }
+
+ public Object getNewObjectForward(Object obj) {
+ return service.getNewObject(obj);
+ }
+
+ public Object[] getNewObjectArrayForward(Object[] objs) {
+ return service.getNewObjectArray(objs);
+ }
+
+ public Image getNewImageForward(Image img) {
+ return service.getNewImage(img);
+ }
+
+ public Image[] getNewImageArrayForward(Image[] imgs) {
+ return service.getNewImageArray(imgs);
+ }
+
+ public DataHandler getNewDataHandlerForward(DataHandler dh) {
+ return service.getNewDataHandler(dh);
+ }
+
+ public DataHandler[] getNewDataHandlerArrayForward(DataHandler[] dha) {
+ return service.getNewDataHandlerArray(dha);
+ }
+
+
+ public Source getNewSourceForward(Source src) {
+ return service.getNewSource(src);
+ }
+
+ public Source[] getNewSourceArrayForward(Source[] srcs) {
+ return service.getNewSourceArray(srcs);
+ }
+
+ public UUID getNewUUIDForward(UUID uuid) {
+ return service.getNewUUID(uuid);
+ }
+
+ public UUID[] getNewUUIDArrayForward(UUID[] uuids) {
+ return service.getNewUUIDArray(uuids);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceClientImpl.java
new file mode 100644
index 0000000000..6aefb05c83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceClientImpl.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 org.apache.tuscany.sca.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of StandardTypesServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ */
+@Service(StandardTypesServiceClient.class)
+public class StandardTypesServiceClientImpl extends StandardTypesLocalServiceClientImpl {
+
+ @Reference
+ public void setStandardTypesService(StandardTypesService service) {
+ super.setStandardTypesLocalService(service);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.java
new file mode 100644
index 0000000000..4e40f006d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import java.awt.Image;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesLocalService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of StandardTypesService.
+ * This implementation provides both a local and a remotable service.
+ */
+@Service(value={StandardTypesService.class, StandardTypesLocalService.class})
+public class StandardTypesServiceImpl implements StandardTypesService, StandardTypesLocalService {
+
+ public BigInteger getNewBigInteger(BigInteger bi) {
+ return bi.negate();
+ }
+
+ public BigInteger[] getNewBigIntegerArray(BigInteger[] bia) {
+ BigInteger[] resp = new BigInteger[bia.length];
+ for(int i = 0; i < bia.length; ++i) {
+ resp[i] = bia[i].negate();
+ }
+ return resp;
+ }
+
+ public BigDecimal getNewBigDecimal(BigDecimal bd) {
+ return bd.negate();
+ }
+
+ public BigDecimal[] getNewBigDecimalArray(BigDecimal[] bda) {
+ BigDecimal[] resp = new BigDecimal[bda.length];
+ for(int i = 0; i < bda.length; ++i) {
+ resp[i] = bda[i].negate();
+ }
+ return resp;
+ }
+
+ public Calendar getNewCalendar(Calendar c) {
+ Calendar resp = (Calendar)c.clone();
+ resp.add(Calendar.DAY_OF_MONTH, 5);
+ return resp;
+ }
+
+ public Calendar[] getNewCalendarArray(Calendar[] ca) {
+ Calendar[] resp = new Calendar[ca.length];
+ for(int i = 0; i < ca.length; ++i) {
+ resp[i] = getNewCalendar(ca[i]);
+ }
+ return resp;
+ }
+
+ public Date getNewDate(Date d) {
+ return new Date(d.getTime() + 5*24*60*60*1000);
+ }
+
+ public Date[] getNewDateArray(Date[] da) {
+ Date[] resp = new Date[da.length];
+ for(int i = 0; i < da.length; ++i) {
+ resp[i] = getNewDate(da[i]);
+ }
+ return resp;
+ }
+
+ public QName getNewQName(QName qname) {
+ return new QName(qname.getNamespaceURI()+"q", qname.getLocalPart()+"q", qname.getPrefix()+"q");
+
+ }
+
+ public QName[] getNewQNameArray(QName[] qnames) {
+ QName[] resp = new QName[qnames.length];
+ for(int i = 0; i < qnames.length; ++i) {
+ resp[i] = getNewQName(qnames[i]);
+ }
+ return resp;
+ }
+
+ public URI getNewURI(URI uri) {
+ return uri.resolve("uri");
+ }
+
+ public URI[] getNewURIArray(URI[] uris) {
+ URI[] resp = new URI[uris.length];
+ for(int i = 0; i < uris.length; ++i) {
+ resp[i] = getNewURI(uris[i]);
+ }
+ return resp;
+ }
+
+ public XMLGregorianCalendar getNewXMLGregorianCalendar(XMLGregorianCalendar xgcal) {
+ xgcal = (XMLGregorianCalendar)xgcal.clone();
+ xgcal.setDay(xgcal.getDay()+5);
+ return xgcal;
+ }
+
+ public XMLGregorianCalendar[] getNewXMLGregorianCalendarArray(XMLGregorianCalendar[] xgcals) {
+ XMLGregorianCalendar[] resp = new XMLGregorianCalendar[xgcals.length];
+ for(int i = 0; i < xgcals.length; ++i) {
+ resp[i] = getNewXMLGregorianCalendar(xgcals[i]);
+ }
+ return resp;
+ }
+
+ public Duration getNewDuration(Duration d) {
+ return d.negate();
+ }
+
+ public Duration[] getNewDurationArray(Duration[] da) {
+ Duration[] resp = new Duration[da.length];
+ for(int i = 0; i < da.length; ++i) {
+ resp[i] = da[i].negate();
+ }
+ return resp;
+ }
+
+ public Object getNewObject(Object obj) {
+ return StandardTypesTransformer.getNewObject(obj);
+ }
+
+ public Object[] getNewObjectArray(Object[] objs) {
+ Object[] resp = new Object[objs.length];
+ for(int i = 0; i < objs.length; ++i) {
+ resp[i] = getNewObject(objs[i]);
+ }
+ return resp;
+ }
+
+ public Image getNewImage(Image img) {
+ return StandardTypesTransformer.getNewImage(img);
+ }
+
+ public Image[] getNewImageArray(Image[] imgs) {
+ Image[] resp = new Image[imgs.length];
+ for(int i = 0; i < imgs.length; ++i) {
+ resp[i] = getNewImage(imgs[i]);
+ }
+ return resp;
+ }
+
+ public DataHandler getNewDataHandler(DataHandler dh) {
+ // FIXME: transform the input
+ return dh;
+ }
+
+ public DataHandler[] getNewDataHandlerArray(DataHandler[] dha) {
+ DataHandler[] resp = new DataHandler[dha.length];
+ for(int i = 0; i < dha.length; ++i) {
+ resp[i] = dha[i];
+ }
+ return resp;
+ }
+
+ public Source getNewSource(Source src) {
+ return StandardTypesTransformer.getNewSource(src);
+ }
+
+ public Source[] getNewSourceArray(Source[] srcs) {
+ Source[] resp = new Source[srcs.length];
+ for(int i = 0; i < srcs.length; ++i) {
+ resp[i] = getNewSource(srcs[i]);
+ }
+ return resp;
+ }
+
+ public UUID getNewUUID(UUID uuid) {
+ return UUID.fromString(uuid.toString()+"AAA");
+ }
+
+ public UUID[] getNewUUIDArray(UUID[] uuids) {
+ UUID[] resp = new UUID[uuids.length];
+ for(int i = 0; i < uuids.length; ++i) {
+ resp[i] = getNewUUID(uuids[i]);
+ }
+ return resp;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesTransformer.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesTransformer.java
new file mode 100644
index 0000000000..68510b4b03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesTransformer.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.sca.itest.databindings.jaxb.impl;
+
+import java.awt.Image;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+
+import org.xml.sax.InputSource;
+
+
+
+/**
+ * StandardTypesTransformer class that provide for transforming input provided to StandardTypesService methods.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StandardTypesTransformer {
+
+ public static Object getNewObject(Object obj) {
+ if(obj instanceof String) {
+ return "Hello "+obj;
+ } else if(obj instanceof Integer) {
+ return new Integer(-((Integer)obj).intValue());
+ } else if(obj instanceof Double) {
+ return new Double(-((Double)obj).doubleValue());
+ }
+
+ return obj;
+ }
+
+ /**
+ * Returns a copy of the source object if the input is DOMSource, SAXSource or StreamSource.
+ * Returns the input object as is for other types.
+ */
+ public static Source getNewSource(Source src) {
+ Source ret = null;
+ if(src instanceof DOMSource) {
+ DOMSource dsrc = (DOMSource)src;
+ ret = new DOMSource(dsrc.getNode() != null ? dsrc.getNode().cloneNode(true) : null);
+ } else if(src instanceof SAXSource) {
+ SAXSource ssrc = (SAXSource)src;
+ if(ssrc.getInputSource().getByteStream() != null) {
+ InputStream inp = ssrc.getInputSource().getByteStream();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ int b;
+ try {
+ while((b = inp.read()) != -1) {
+ bout.write(b);
+ }
+ } catch (IOException ignored) {
+ }
+ try { bout.close();} catch (IOException ignored) {}
+ try { inp.reset();} catch (IOException ignored) {}
+ ret = new SAXSource(new InputSource(new ByteArrayInputStream(bout.toByteArray())));
+ } else if(ssrc.getInputSource().getCharacterStream() != null) {
+ Reader rdr = ssrc.getInputSource().getCharacterStream();
+ CharArrayWriter caw = new CharArrayWriter();
+ try {
+ int c;
+ while((c = rdr.read()) != -1) {
+ caw.append((char)c);
+ }
+ } catch (IOException ignored) {
+ }
+ caw.close();
+ try{ rdr.reset();} catch(IOException ignored) {}
+ ret = new SAXSource(new InputSource(new CharArrayReader(caw.toCharArray())));
+ } else {
+ ret = new SAXSource();
+ }
+ } else if(src instanceof StreamSource) {
+ StreamSource ssrc = (StreamSource)src;
+ if(ssrc.getInputStream() != null) {
+ InputStream inp = ssrc.getInputStream();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ int b;
+ try {
+ while((b = inp.read()) != -1) {
+ bout.write(b);
+ }
+ } catch (IOException ignored) {
+ }
+ try { bout.close();} catch (IOException ignored) {}
+ try { inp.reset();} catch (IOException ignored) {}
+ ret = new StreamSource(new ByteArrayInputStream(bout.toByteArray()));
+ } else if(ssrc.getReader() != null) {
+ Reader rdr = ssrc.getReader();
+ CharArrayWriter caw = new CharArrayWriter();
+ try {
+ int c;
+ while((c = rdr.read()) != -1) {
+ caw.append((char)c);
+ }
+ } catch (IOException ignored) {
+ }
+ caw.close();
+ try{ rdr.reset();} catch(IOException ignored) {}
+ ret = new StreamSource(new CharArrayReader(caw.toCharArray()));
+ } else {
+ ret = new StreamSource();
+ }
+ }
+
+ if(ret != null) {
+ ret.setSystemId(src.getSystemId());
+ } else {
+ ret = src;
+ }
+ return ret;
+ }
+
+ public static Image getNewImage(Image arg) {
+ arg.getGraphics().drawOval(2, 2, 7, 7);
+ return arg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/aservice.wsdl b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/aservice.wsdl
new file mode 100644
index 0000000000..10a242be4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/aservice.wsdl
@@ -0,0 +1,127 @@
+<?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://jaxb.databindings.itest.sca.tuscany.apache.org"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:ns0="http://jaxb.databindings.itest.sca.tuscany.apache.org"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:ns1="http://org.apache.axis2/xsd"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org" xmlns:ns="http://jaxb.databindings.itest.sca.tuscany.apache.org">
+ <xs:element name="getGreetings" nillable="true" type="xs:string"/>
+ <xs:element name="getGreetingsResponse" nillable="true" type="xs:string"/>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part name="parameters" element="ns0:getGreetings"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part name="parameters" element="ns0:getGreetingsResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="AServicePortType">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="ns0:getGreetingsRequest" wsaw:Action="urn:getGreetings"/>
+ <wsdl:output message="ns0:getGreetingsResponse" wsaw:Action="urn:getGreetingsResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="AServiceSOAP12Binding" type="ns0:AServicePortType">
+ <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <soap12:operation soapAction="urn:getGreetings" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:binding name="AServicePortTypeBinding" type="ns0:AServicePortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:binding name="AServiceHttpBinding" type="ns0:AServicePortType">
+ <http:binding verb="POST"/>
+ <wsdl:operation name="getGreetings">
+ <http:operation location="AService/getGreetings"/>
+ <wsdl:input>
+ <mime:content part="getGreetings" type="text/xml"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content part="getGreetings" type="text/xml"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:binding name="AServiceSOAP11Binding" type="ns0:AServicePortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <soap:operation soapAction="urn:getGreetings" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="AServicePortTypeService">
+ <wsdl:port name="AServicePortTypePort" binding="ns0:AServicePortTypeBinding">
+ <soap:address location="http://localhost:8080/AService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <wsdl:service name="AService">
+ <wsdl:port name="AServiceHttpport" binding="ns0:AServiceHttpBinding">
+ <http:address location="http://localhost:8080/AService/httpport"/>
+ </wsdl:port>
+ <wsdl:port name="AServiceSOAP12port_http" binding="ns0:AServiceSOAP12Binding">
+ <soap12:address location="http://localhost:8080/AService/soap12port"/>
+ </wsdl:port>
+ <wsdl:port name="AServiceSOAP11port_http" binding="ns0:AServiceSOAP11Binding">
+ <soap:address location="http://localhost:8080/AService/soap11port"/>
+ </wsdl:port>
+ <wsdl:port name="AServiceSOAP12port_http_null" binding="ns0:AServiceSOAP12Binding">
+ <soap12:address location=""/>
+ </wsdl:port>
+ <wsdl:port name="AServiceSOAP12port_http_wsdl" binding="ns0:AServiceSOAP12Binding">
+ <soap12:address location="inWsdl"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/doclitbarewsdl.composite b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/doclitbarewsdl.composite
new file mode 100644
index 0000000000..0b5dacda35
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/doclitbarewsdl.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://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://itest" name="doclitbarewsdltest">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.AServiceImpl"/>
+ <service name="AService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org#wsdl.interface(AServicePortType)"/>
+ <binding.ws uri="http://localhost:8085/AService/endpointref"/>
+ </service>
+ </component>
+ <component name="AClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.AClientServiceImpl"/>
+ <reference name="aService">
+ <!--interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org#wsdl.interface(AServicePortType)"/-->
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.AService"/>
+ <binding.ws uri="http://localhost:8085/AService/endpointref"/>
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/generics-service.composite b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/generics-service.composite
new file mode 100644
index 0000000000..c38ee6ee78
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/generics-service.composite
@@ -0,0 +1,69 @@
+<?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.
+-->
+
+<!-- $Rev: 741544 $ $Date: 2009-02-06 17:16:22 +0530 (Fri, 06 Feb 2009) $ -->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ name="GenericsService">
+
+ <!-- Clients to test the service -->
+ <!-- A GenericsServiceClient component that uses WS binding to invoke GenericsService -->
+ <component name="GenericsServiceClientWSComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.GenericsServiceClientImpl" />
+ <reference name="genericsService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.GenericsService"/>
+ <binding.ws uri="http://localhost:8085/gs-ep"/>
+ </reference>
+ </component>
+
+ <!-- A GenericsServiceClient component that uses SCA binding to invoke GenericsService service -->
+ <component name="GenericsServiceClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.GenericsServiceClientImpl" />
+ <reference name="genericsService" target="GenericsServiceComponent/GenericsService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.GenericsService"/>
+ <binding.sca/>
+ </reference>
+ </component>
+
+ <!-- A GenericsLocalServiceClient component that uses SCA binding to invoke GenericsLocalService service -->
+ <component name="GenericsLocalServiceClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.GenericsLocalServiceClientImpl" />
+ <reference name="genericsLocalService" target="GenericsServiceComponent/GenericsLocalService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.GenericsLocalService"/>
+ <binding.sca/>
+ </reference>
+ </component>
+
+ <!-- Components used to implement the services -->
+ <!-- A GenericsService component. -->
+ <component name="GenericsServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.GenericsServiceImpl"/>
+ <service name="GenericsService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.GenericsService"/>
+ <binding.ws uri="http://localhost:8085/gs-ep"/>
+ </service>
+ <service name="GenericsLocalService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.GenericsLocalService"/>
+ <binding.sca/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/helloservice.composite b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/helloservice.composite
new file mode 100644
index 0000000000..db01ba12ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/helloservice.composite
@@ -0,0 +1,65 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ name="HelloService">
+
+ <!-- Clients to test the service -->
+ <!-- A HelloServiceSimpleClient component that uses WS binding to invoke HelloServiceSimple service -->
+ <component name="HelloServiceSimpleClientWSComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloServiceSimpleClientImpl" />
+ <reference name="helloServiceSimple">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceSimple"/>
+ <binding.ws uri="http://localhost:8085/hs-ep0"/>
+ </reference>
+ </component>
+
+ <!-- A HelloServiceSimpleClient component that uses SCA binding to invoke HelloServiceSimple service -->
+ <component name="HelloServiceSimpleClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloServiceSimpleClientImpl" />
+ <reference name="helloServiceSimple" target="HelloServiceSimpleComponent/HelloServiceSimple">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceSimple"/>
+ <binding.sca/>
+ </reference>
+ </component>
+
+ <!-- A HelloLocalServiceSimpleClient component that uses SCA binding to invoke HelloLocalServiceSimple service -->
+ <component name="HelloLocalServiceSimpleClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloLocalServiceSimpleClientImpl" />
+ <reference name="helloLocalServiceSimple" target="HelloServiceSimpleComponent/HelloLocalServiceSimple">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.HelloLocalServiceSimple"/>
+ <binding.sca/>
+ </reference>
+ </component>
+
+ <!-- Components used to implement the services -->
+ <!-- A HelloServiceSimple component. -->
+ <component name="HelloServiceSimpleComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloServiceSimpleImpl"/>
+ <service name="HelloServiceSimple">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceSimple"/>
+ <binding.ws uri="http://localhost:8085/hs-ep0"/>
+ </service>
+ <service name="HelloLocalServiceSimple">
+ <binding.sca/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/primitivesservice.composite b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/primitivesservice.composite
new file mode 100644
index 0000000000..09d42b2bdf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/primitivesservice.composite
@@ -0,0 +1,66 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ name="PrimitivesService">
+
+ <!-- Clients to test the service -->
+ <!-- A PrimitivesServiceClient component that uses WS binding to invoke PrimitivesService -->
+ <component name="PrimitivesServiceClientWSComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesServiceClientImpl" />
+ <reference name="primitivesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService"/>
+ <binding.ws uri="http://localhost:8085/ps-ep"/>
+ </reference>
+ </component>
+
+ <!-- A PrimitivesServiceClient component that uses SCA binding to invoke PrimitivesService service -->
+ <component name="PrimitivesServiceClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesServiceClientImpl" />
+ <reference name="primitivesService" target="PrimitivesServiceComponent/PrimitivesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService"/>
+ <binding.sca/>
+ </reference>
+ </component>
+
+ <!-- A PrimitivesLocalServiceClient component that uses SCA binding to invoke PrimitivesLocalService service -->
+ <component name="PrimitivesLocalServiceClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesLocalServiceClientImpl" />
+ <reference name="primitivesLocalService" target="PrimitivesServiceComponent/PrimitivesLocalService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesLocalService"/>
+ <binding.sca/>
+ </reference>
+ </component>
+
+ <!-- Components used to implement the services -->
+ <!-- A PrimitivesService component. -->
+ <component name="PrimitivesServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesServiceImpl"/>
+ <service name="PrimitivesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService"/>
+ <binding.ws uri="http://localhost:8085/ps-ep"/>
+ </service>
+ <service name="PrimitivesLocalService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesLocalService"/>
+ <binding.sca/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/standard-types-service.composite b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/standard-types-service.composite
new file mode 100644
index 0000000000..5aefe799a6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/main/resources/standard-types-service.composite
@@ -0,0 +1,66 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ name="StandardTypesService">
+
+ <!-- Clients to test the service -->
+ <!-- A StandardTypesServiceClient component that uses WS binding to invoke StandardTypesService -->
+ <component name="StandardTypesServiceClientWSComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesServiceClientImpl" />
+ <reference name="standardTypesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService"/>
+ <binding.ws uri="http://localhost:8085/sts-ep"/>
+ </reference>
+ </component>
+
+ <!-- A StandardTypesServiceClient component that uses SCA binding to invoke StandardTypesService service -->
+ <component name="StandardTypesServiceClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesServiceClientImpl" />
+ <reference name="standardTypesService" target="StandardTypesServiceComponent/StandardTypesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService"/>
+ <binding.sca/>
+ </reference>
+ </component>
+
+ <!-- A StandardTypesLocalServiceClient component that uses SCA binding to invoke StandardTypesLocalService service -->
+ <component name="StandardTypesLocalServiceClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesLocalServiceClientImpl" />
+ <reference name="standardTypesLocalService" target="StandardTypesServiceComponent/StandardTypesLocalService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesLocalService"/>
+ <binding.sca/>
+ </reference>
+ </component>
+
+ <!-- Components used to implement the services -->
+ <!-- A StandardTypesService component. -->
+ <component name="StandardTypesServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesServiceImpl"/>
+ <service name="StandardTypesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService"/>
+ <binding.ws uri="http://localhost:8085/sts-ep"/>
+ </service>
+ <service name="StandardTypesLocalService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesLocalService"/>
+ <binding.sca/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/DatabindingTestCase.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/DatabindingTestCase.java
new file mode 100644
index 0000000000..8bacf13063
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/DatabindingTestCase.java
@@ -0,0 +1,345 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DatabindingTestCase {
+
+ private static Node node;
+
+ /**
+ * Runs once before running the tests
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/helloservice.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ } catch(Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Runs once after running the tests
+ */
+ @AfterClass
+ public static void tearDown() {
+ node.stop();
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using SCA binding.
+ * Service method invoked is getGreetings.
+ */
+ @Test
+ public void testSCA() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientSCAComponent");
+ performTest(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsArray.
+ */
+ @Test
+ public void testSCAArray() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientSCAComponent");
+ performTestArray(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsList.
+ */
+ @Test
+ public void testSCAList() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientSCAComponent");
+ performTestList(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsArrayList.
+ */
+ @Test
+ public void testSCAArrayList() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientSCAComponent");
+ performTestArrayList(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsMap.
+ */
+ @Test
+ public void testSCAMap() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientSCAComponent");
+ performTestMap(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsHashMap.
+ */
+ @Test
+ public void testSCAHashMap() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientSCAComponent");
+ performTestHashMap(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsVarArgs.
+ */
+ @Test
+ public void testSCAVarArgs() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientSCAComponent");
+ performTestVarArgs(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using WS binding.
+ * Service method invoked is getGreetings.
+ */
+ @Test
+ public void testWS() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientWSComponent");
+ performTest(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using WS binding.
+ * Service method invoked is getGreetingsArray.
+ */
+ @Test
+ public void testWSArray() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientWSComponent");
+ performTestArray(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using WS binding.
+ * Service method invoked is getGreetingsList.
+ */
+ @Test
+ public void testWSList() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientWSComponent");
+ performTestList(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using WS binding.
+ * Service method invoked is getGreetingsArrayList.
+ */
+ @Test
+ public void testWSArrayList() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientWSComponent");
+ performTestArrayList(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using WS binding.
+ * Service method invoked is getGreetingsMap.
+ */
+ @Test
+ public void testWSMap() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientWSComponent");
+ performTestMap(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using WS binding.
+ * Service method invoked is getGreetingsHashMap.
+ */
+ @Test
+ public void testWSHashMap() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientWSComponent");
+ performTestHashMap(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloServiceSimple service using WS binding.
+ * Service method invoked is getGreetingsVarArgs.
+ */
+ @Test
+ public void testWSVarArgs() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloServiceSimpleClientWSComponent");
+ performTestVarArgs(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloLocalServiceSimple service using SCA binding.
+ * Service method invoked is getGreetings.
+ */
+ @Test
+ public void testSCALocal() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloLocalServiceSimpleClientSCAComponent");
+ performTest(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloLocalServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsArray.
+ */
+ @Test
+ public void testSCALocalArray() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloLocalServiceSimpleClientSCAComponent");
+ performTestArray(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloLocalServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsList.
+ */
+ @Test
+ public void testSCALocalList() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloLocalServiceSimpleClientSCAComponent");
+ performTestList(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloLocalServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsArrayList.
+ */
+ @Test
+ public void testSCALocalArrayList() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloLocalServiceSimpleClientSCAComponent");
+ performTestArrayList(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloLocalServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsMap.
+ */
+ @Test
+ public void testSCALocalMap() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloLocalServiceSimpleClientSCAComponent");
+ performTestMap(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloLocalServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsHashMap.
+ */
+ @Test
+ public void testSCALocalHashMap() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloLocalServiceSimpleClientSCAComponent");
+ performTestHashMap(helloServiceSimpleClient);
+ }
+
+ /**
+ * Invokes the HelloLocalServiceSimple service using SCA binding.
+ * Service method invoked is getGreetingsVarArgs.
+ */
+ @Test
+ public void testSCALocalVarArgs() throws Exception {
+ HelloServiceSimpleClient helloServiceSimpleClient = node.getService(HelloServiceSimpleClient.class, "HelloLocalServiceSimpleClientSCAComponent");
+ performTestVarArgs(helloServiceSimpleClient);
+ }
+
+ private void performTest(HelloServiceSimpleClient helloServiceSimpleClient) {
+ String name = "Pandu";
+ String resp = helloServiceSimpleClient.getGreetingsForward(name);
+ Assert.assertEquals("Hello "+name, resp);
+ }
+
+ private void performTestArray(HelloServiceSimpleClient helloServiceSimpleClient) {
+ String[] names = {"Me", "Pandu"};
+ String[] resps = helloServiceSimpleClient.getGreetingsArrayForward(names);
+ for(int i = 0; i < names.length; ++i) {
+ Assert.assertEquals("Hello "+names[i], resps[i]);
+ }
+ }
+
+ private void performTestList(HelloServiceSimpleClient helloServiceSimpleClient) {
+ List<String> namesList = new ArrayList<String>();
+ namesList.add("Me");
+ namesList.add("Pandu");
+ namesList.add("Chinnipandu");
+ List<String> respList = helloServiceSimpleClient.getGreetingsListForward(namesList);
+ Assert.assertEquals(namesList.size(), respList.size());
+ for(int i = 0; i < namesList.size(); ++i) {
+ Assert.assertEquals("Hello "+namesList.get(i), respList.get(i));
+ }
+ }
+
+ private void performTestArrayList(HelloServiceSimpleClient helloServiceSimpleClient) {
+ ArrayList<String> namesList = new ArrayList<String>();
+ namesList.add("Me");
+ namesList.add("Pandu");
+ namesList.add("Chinnipandu");
+ ArrayList<String> respList = helloServiceSimpleClient.getGreetingsArrayListForward(namesList);
+ Assert.assertEquals(namesList.size(), respList.size());
+ for(int i = 0; i < namesList.size(); ++i) {
+ Assert.assertEquals("Hello "+namesList.get(i), respList.get(i));
+ }
+ }
+
+ private void performTestMap(HelloServiceSimpleClient helloServiceSimpleClient) {
+ Map<String, String> namesMap = new HashMap<String, String>();
+ namesMap.put("Me", null);
+ namesMap.put("Pandu", null);
+ namesMap.put("Chinnipandu", null);
+ Map<String, String> respMap = helloServiceSimpleClient.getGreetingsMapForward(namesMap);
+ Assert.assertEquals(namesMap.keySet().size(), respMap.keySet().size());
+ for(Map.Entry<String, String> entry: namesMap.entrySet()) {
+ Assert.assertEquals("Hello "+entry.getKey(), respMap.get(entry.getKey()));
+ }
+ }
+
+ private void performTestHashMap(HelloServiceSimpleClient helloServiceSimpleClient) {
+ HashMap<String, String> namesMap = new HashMap<String, String>();
+ namesMap.put("Me", null);
+ namesMap.put("Pandu", null);
+ namesMap.put("Chinnipandu", null);
+ Map<String, String> respMap = helloServiceSimpleClient.getGreetingsHashMapForward(namesMap);
+ Assert.assertEquals(namesMap.keySet().size(), respMap.keySet().size());
+ for(Map.Entry<String, String> entry: namesMap.entrySet()) {
+ Assert.assertEquals("Hello "+entry.getKey(), respMap.get(entry.getKey()));
+ }
+ }
+
+ private void performTestVarArgs(HelloServiceSimpleClient helloServiceSimpleClient) {
+ String[] names = { "Me", "You", "Pandu" }; // Do not change the array size from 3.
+ String expected = "Hello Me You Pandu";
+ String actual = helloServiceSimpleClient.getGreetingsVarArgsForward(names[0], names[1], names[2]);
+ Assert.assertEquals(expected, actual);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/DocLitBareWsdlTestCase.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/DocLitBareWsdlTestCase.java
new file mode 100644
index 0000000000..6aac75ae08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/DocLitBareWsdlTestCase.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.sca.itest.databindings.jaxb;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DocLitBareWsdlTestCase {
+
+ private static Node node;
+
+ /**
+ * Runs once before running the tests
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/doclitbarewsdl.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ } catch (Throwable e) {
+ // @Ignore("TUSCANY-2398")
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Runs once after running the tests
+ */
+ @AfterClass
+ public static void tearDown() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+ // @Ignore("TUSCANY-2398")
+ @Test
+ public void testDocLitBareWsdl() throws Exception {
+ AClientService client = node.getService(AClientService.class, "AClientComponent");
+ String name = "Pandu";
+ String resp = client.getGreetingsForward(name);
+ Assert.assertEquals("Hello " + name, resp);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsDatabindingTestCase.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsDatabindingTestCase.java
new file mode 100644
index 0000000000..755619908d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/GenericsDatabindingTestCase.java
@@ -0,0 +1,493 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.impl.GenericsTransformer;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Databinding tests for generics, parameterized and polymorphic types.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GenericsDatabindingTestCase {
+
+ private static Node node;
+
+ /**
+ * Runs before each test method
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/generics-service.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ } catch(Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Runs after each test method
+ */
+ @AfterClass
+ public static void tearDown() {
+ node.stop();
+ }
+
+ /**
+ * Invokes the GenericsService service using SCA binding.
+ * Service method invoked is getTypeExplicit.
+ */
+ @Test
+ public void testSCATypeExplicit() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientSCAComponent");
+ performTestTypeExplicit(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using SCA binding.
+ * Service method invoked is getTypeUnbound.
+ */
+ @Test
+ public void testSCATypeUnbound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientSCAComponent");
+ performTestTypeUnbound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using SCA binding.
+ * Service method invoked is getTypeExtends.
+ */
+ @Test
+ public void testSCATypeExtends() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientSCAComponent");
+ performTestTypeExtends(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using SCA binding.
+ * Service method invoked is getRecursiveTypeBound.
+ */
+ @Test
+ public void testSCARecursiveTypeBound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientSCAComponent");
+ performTestRecursiveTypeBound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using SCA binding.
+ * Service method invoked is getWildcardUnbound.
+ */
+ @Test
+ public void testSCAWildcardUnbound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientSCAComponent");
+ performTestWildcardUnbound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using SCA binding.
+ * Service method invoked is getWildcardSuper.
+ */
+ @Test
+ public void testSCAWildcardSuper() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientSCAComponent");
+ performTestWildcardSuper(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using SCA binding.
+ * Service method invoked is getWildcardExtends.
+ */
+ @Test
+ public void testSCAWildcardExtends() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientSCAComponent");
+ performTestWildcardExtends(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using SCA binding.
+ * Service method invoked is getPolymorphic.
+ */
+ @Test
+ public void testSCAPolymorphic() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientSCAComponent");
+ performTestPolymorphic(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using WS binding.
+ * Service method invoked is getTypeExplicit.
+ */
+ @Test
+ public void testWSTypeExplicit() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientWSComponent");
+ performTestTypeExplicit(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using WS binding.
+ * Service method invoked is getTypeUnbound.
+ */
+ @Test
+ public void testWSTypeUnbound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientWSComponent");
+ performTestTypeUnbound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using WS binding.
+ * Service method invoked is getTypeExtends.
+ */
+ @Test
+ public void testWSTypeExtends() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientWSComponent");
+ performTestTypeExtends(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using WS binding.
+ * Service method invoked is getRecursiveTypeBound.
+ */
+ @Test
+ public void testWSRecursiveTypeBound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientWSComponent");
+ performTestRecursiveTypeBound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using WS binding.
+ * Service method invoked is getWildcardUnbound.
+ */
+ @Test
+ public void testWSWildcardUnbound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientWSComponent");
+ performTestWildcardUnbound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using WS binding.
+ * Service method invoked is getWildcardSuper.
+ */
+ @Test
+ public void testWSWildcardSuper() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientWSComponent");
+ performTestWildcardSuper(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using WS binding.
+ * Service method invoked is getWildcardExtends.
+ */
+ @Test
+ public void testWSWildcardExtends() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientWSComponent");
+ performTestWildcardExtends(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsService service using WS binding.
+ * Service method invoked is getPolymorphic.
+ */
+ @Test
+ public void testWSPolymorphic() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsServiceClientWSComponent");
+ performTestPolymorphic(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsLocalService service using SCA binding.
+ * Service method invoked is getTypeExplicit.
+ */
+ @Test
+ public void testSCALocalTypeExplicit() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsLocalServiceClientSCAComponent");
+ performTestTypeExplicit(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsLocalService service using SCA binding.
+ * Service method invoked is getTypeUnbound.
+ */
+ @Test
+ public void testSCALocalTypeUnbound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsLocalServiceClientSCAComponent");
+ performTestTypeUnbound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsLocalService service using SCA binding.
+ * Service method invoked is getTypeExtends.
+ */
+ @Test
+ public void testSCALocalTypeExtends() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsLocalServiceClientSCAComponent");
+ performTestTypeExtends(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsLocalService service using SCA binding.
+ * Service method invoked is getRecursiveTypeBound.
+ */
+ @Test
+ public void testSCALocalRecursiveTypeBound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsLocalServiceClientSCAComponent");
+ performTestRecursiveTypeBound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsLocalService service using SCA binding.
+ * Service method invoked is getWildcardUnbound.
+ */
+ @Test
+ public void testSCALocalWildcardUnbound() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsLocalServiceClientSCAComponent");
+ performTestWildcardUnbound(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsLocalService service using SCA binding.
+ * Service method invoked is getWildcardSuper.
+ */
+ @Test
+ public void testSCALocalWildcardSuper() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsLocalServiceClientSCAComponent");
+ performTestWildcardSuper(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsLocalService service using SCA binding.
+ * Service method invoked is getWildcardExtends.
+ */
+ @Test
+ public void testSCALocalWildcardExtends() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsLocalServiceClientSCAComponent");
+ performTestWildcardExtends(serviceClient);
+ }
+
+ /**
+ * Invokes the GenericsLocalService service using SCA binding.
+ * Service method invoked is getPolymorphic.
+ */
+ @Test
+ public void testSCALocalPolymorphic() throws Exception {
+ GenericsServiceClient serviceClient = node.getService(GenericsServiceClient.class, "GenericsLocalServiceClientSCAComponent");
+ performTestPolymorphic(serviceClient);
+ }
+
+ private void performTestTypeExplicit(GenericsServiceClient serviceClient) {
+ Bean1<String> args[] = new Bean1[2];
+ args[0] = new Bean1<String>("Me");
+ args[1] = new Bean1<String>();
+ for(int i = 0; i < args.length; ++i) {
+ Bean1<String> arg = args[i];
+ Bean1<String> expected = GenericsTransformer.getTypeExplicit(arg);
+ Bean1<String> actual = serviceClient.getTypeExplicitForward(arg);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestTypeUnbound(GenericsServiceClient serviceClient) {
+ { // String
+ String[] args = { "Me", "You", "Him" };
+ Bean1<String> expected = GenericsTransformer.getTypeUnbound(args);
+ Bean1<String> actual = serviceClient.getTypeUnboundForward(args);
+ // Assert.assertEquals(expected, actual);
+ }
+ { // Integer
+ Integer[] args = new Integer[3];
+ args[0] = -10;
+ args[1] = 0;
+ args[2] = 10;
+ Bean1<Integer> expected = GenericsTransformer.getTypeUnbound(args);
+ Bean1<Integer> actual = serviceClient.getTypeUnboundForward(args);
+ // Assert.assertEquals(expected, actual);
+ }
+ { // Object
+ Object[] args = new Object[3];
+ args[0] = "Me";
+ args[1] = 10;
+ args[2] = "Him";
+ Bean1<Object> expected = GenericsTransformer.getTypeUnbound(args);
+ Bean1<Object> actual = serviceClient.getTypeUnboundForward(args);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestTypeExtends(GenericsServiceClient serviceClient) {
+ { // Bean2
+ Bean2[] args = new Bean2[3];
+ for(int i = 0; i < args.length; ++i) {
+ args[i] = new Bean2();
+ args[i].setName("Name"+i);
+ }
+
+ Bean1<Bean2> expected = GenericsTransformer.getTypeExtends(args);
+ Bean1<Bean2> actual = serviceClient.getTypeExtendsForward(args);
+ Assert.assertEquals(expected, actual);
+ }
+ { // Bean3 extends Bean2
+ Bean3[] args = new Bean3[3];
+ for(int i = 0; i < args.length; ++i) {
+ args[i] = new Bean3();
+ args[i].setName("Name"+i);
+ args[i].setAddress("Address"+i);
+ }
+
+ Bean1<Bean3> expected = GenericsTransformer.getTypeExtends(args);
+ Bean1<Bean3> actual = serviceClient.getTypeExtendsForward(args);
+ // Assert.assertEquals(expected, actual);
+ }
+ { //Bean31 extends Bean2
+ Bean31[] args = new Bean31[3];
+ for(int i = 0; i < args.length; ++i) {
+ args[i] = new Bean31();
+ args[i].setName("Name"+i);
+ args[i].setAddress("Address"+i);
+ }
+
+ Bean1<Bean31> expected = GenericsTransformer.getTypeExtends(args);
+ Bean1<Bean31> actual = serviceClient.getTypeExtendsForward(args);
+ // Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestRecursiveTypeBound(GenericsServiceClient serviceClient) {
+ { // Bean1<String>
+ Bean1<String>[] args = new Bean1[3];
+ for(int i = 0; i < args.length; ++i) {
+ args[i] = new Bean1<String>();
+ args[i].setItem("Bean."+i);
+ }
+ Bean1<Bean1<String>> expected = GenericsTransformer.getRecursiveTypeBound(args);
+ Bean1<Bean1<String>> actual = serviceClient.getRecursiveTypeBoundForward(args);
+ Assert.assertEquals(expected, actual);
+ }
+ { // Bean10 extends Bean1<String>
+ Bean10[] args = new Bean10[3];
+ for(int i = 0; i < args.length; ++i) {
+ args[i] = new Bean10();
+ args[i].setItem("Bean10."+i);
+ }
+ Bean1<Bean10> expected = GenericsTransformer.getRecursiveTypeBound(args);
+ Bean1<Bean10> actual = serviceClient.getRecursiveTypeBoundForward(args);
+ // Assert.assertEquals(expected, actual);
+ }
+ { // Bean11 extends Bean1<String>
+ Bean11[] args = new Bean11[3];
+ for(int i = 0; i < args.length; ++i) {
+ args[i] = new Bean11();
+ args[i].setItem("Bean11."+i);
+ }
+ Bean1<Bean11> expected = GenericsTransformer.getRecursiveTypeBound(args);
+ Bean1<Bean11> actual = serviceClient.getRecursiveTypeBoundForward(args);
+ // Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestWildcardUnbound(GenericsServiceClient serviceClient) {
+ {
+ Bean1<?> arg = new Bean1<String>("Me");
+ Bean1<?> expected = GenericsTransformer.getWildcardUnbound(arg);
+ Bean1<?> actual = serviceClient.getWildcardUnboundForward(arg);
+ Assert.assertEquals(expected, actual);
+ }
+ {
+ Bean1<?> arg = new Bean1<Integer>(1);
+ Bean1<?> expected = GenericsTransformer.getWildcardUnbound(arg);
+ Bean1<?> actual = serviceClient.getWildcardUnboundForward(arg);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestWildcardSuper(GenericsServiceClient serviceClient) {
+ Bean1<? super Bean3> arg = new Bean1<Bean2>();
+ Bean3 item = new Bean3();
+ item.setName("Name");
+ item.setAddress("Address");
+ arg.setItem(item);
+ Bean1<? super Bean3> expected = GenericsTransformer.getWildcardSuper(arg);
+ Bean1<? super Bean3> actual = serviceClient.getWildcardSuperForward(arg);
+ Assert.assertEquals(expected, actual);
+ }
+
+ private void performTestWildcardExtends(GenericsServiceClient serviceClient) {
+ { // Bean2
+ Bean2 temp = new Bean2();
+ temp.setName("Me");
+ Bean1<? extends Bean2> arg = new Bean1<Bean2>(temp);
+ Bean1<? extends Bean2> expected = GenericsTransformer.getWildcardExtends(arg);
+ Bean1<? extends Bean2> actual = serviceClient.getWildcardExtendsForward(arg);
+ Assert.assertEquals(expected, actual);
+ }
+ { // Bean3 extends Bean2
+ Bean3 temp = new Bean3();
+ temp.setName("Me");
+ temp.setAddress("My address");
+ Bean1<? extends Bean2> arg = new Bean1<Bean3>(temp);
+ Bean1<? extends Bean2> expected = GenericsTransformer.getWildcardExtends(arg);
+ Bean1<? extends Bean2> actual = serviceClient.getWildcardExtendsForward(arg);
+ // The Bean3 will be unmarshalled into Bean2
+ // Assert.assertEquals(expected, actual);
+ Assert.assertTrue(actual.getItem() instanceof Bean2);
+ }
+ { // Bean31 extends Bean2
+ Bean31 temp = new Bean31();
+ temp.setName("Me1");
+ temp.setAddress("My address1");
+ Bean1<? extends Bean2> arg = new Bean1<Bean31>(temp);
+ Bean1<? extends Bean2> expected = GenericsTransformer.getWildcardExtends(arg);
+ Bean1<? extends Bean2> actual = serviceClient.getWildcardExtendsForward(arg);
+ // The Bean31 will be unmarshalled into Bean2
+ // Assert.assertEquals(expected, actual);
+ Assert.assertTrue(actual.getItem() instanceof Bean2);
+ }
+ }
+
+ private void performTestPolymorphic(GenericsServiceClient serviceClient) {
+ { // Bean2
+ Bean2 arg = new Bean2();
+ arg.setName("Me");
+ Bean2 expected = GenericsTransformer.getPolymorphic(arg);
+ Bean2 actual = serviceClient.getPolymorphicForward(arg);
+ Assert.assertEquals(expected, actual);
+ }
+ { // Bean3 extends Bean2
+ Bean3 arg = new Bean3();
+ arg.setName("Me");
+ arg.setAddress("My address");
+ Bean2 expected = GenericsTransformer.getPolymorphic(arg);
+ Bean2 actual = serviceClient.getPolymorphicForward(arg);
+ Assert.assertEquals(expected.getName(), actual.getName());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesDatabindingTestCase.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesDatabindingTestCase.java
new file mode 100644
index 0000000000..8ece2c3293
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesDatabindingTestCase.java
@@ -0,0 +1,784 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PrimitivesDatabindingTestCase {
+
+ private static Node node;
+
+ /**
+ * Runs before each test method
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/primitivesservice.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ } catch(Throwable e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+ }
+
+ /**
+ * Runs after each test method
+ */
+ @AfterClass
+ public static void tearDown() {
+ node.stop();
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateBoolean.
+ */
+ @Test
+ public void testSCANegateBoolean() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateBoolean(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateBooleanArray.
+ */
+ @Test
+ public void testSCANegateBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateBooleanArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with SCA binding.
+ * Test for boolean array.
+ */
+ @Test
+ public void testSCAPassByValueBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueBooleanArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateByte.
+ */
+ @Test
+ public void testSCANegateByte() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateByte(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateByteArray.
+ */
+ @Test
+ public void testSCANegateByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateByteArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with SCA binding.
+ * Test for byte array.
+ */
+ @Test
+ public void testSCAPassByValueByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueByteArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateShort.
+ */
+ @Test
+ public void testSCANegateShort() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateShort(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateShortArray.
+ */
+ @Test
+ public void testSCANegateShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateShortArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with SCA binding.
+ * Test for short array.
+ */
+ @Test
+ public void testSCAPassByValueShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueShortArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateInt.
+ */
+ @Test
+ public void testSCANegateInt() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateInt(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateIntArray.
+ */
+ @Test
+ public void testSCANegateIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateIntArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with SCA binding.
+ * Test for int array.
+ */
+ @Test
+ public void testSCAPassByValueIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueIntArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateLong.
+ */
+ @Test
+ public void testSCANegateLong() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateLong(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateLongArray.
+ */
+ @Test
+ public void testSCANegateLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateLongArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with SCA binding.
+ * Test for long array.
+ */
+ @Test
+ public void testSCAPassByValueLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueLongArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateFloat.
+ */
+ @Test
+ public void testSCANegateFloat() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateFloat(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateFloatArray.
+ */
+ @Test
+ public void testSCANegateFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateFloatArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with SCA binding.
+ * Test for float array.
+ */
+ @Test
+ public void testSCAPassByValueFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueFloatArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateDouble.
+ */
+ @Test
+ public void testSCANegateDouble() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateDouble(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateDoubleArray.
+ */
+ @Test
+ public void testSCANegateDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ performTestNegateDoubleArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with SCA binding.
+ * Test for double array.
+ */
+ @Test
+ public void testSCAPassByValueDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientSCAComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueDoubleArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateBoolean.
+ */
+ @Test
+ public void testWSNegateBoolean() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateBoolean(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateBooleanArray.
+ */
+ @Test
+ public void testWSNegateBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateBooleanArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for boolean array.
+ */
+ @Test
+ public void testWSPassByValueBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueBooleanArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateByte.
+ */
+ @Test
+ public void testWSNegateByte() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateByte(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateByteArray.
+ */
+ @Test
+ public void testWSNegateByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateByteArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for byte array.
+ */
+ @Test
+ public void testWSPassByValueByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueByteArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateShort.
+ */
+ @Test
+ public void testWSNegateShort() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateShort(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateShortArray.
+ */
+ @Test
+ public void testWSNegateShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateShortArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for short array.
+ */
+ @Test
+ public void testWSPassByValueShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueShortArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateInt.
+ */
+ @Test
+ public void testWSNegateInt() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateInt(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateIntArray.
+ */
+ @Test
+ public void testWSNegateIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateIntArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for int array.
+ */
+ @Test
+ public void testWSPassByValueIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueIntArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateLong.
+ */
+ @Test
+ public void testWSNegateLong() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateLong(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateLongArray.
+ */
+ @Test
+ public void testWSNegateLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateLongArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for long array.
+ */
+ @Test
+ public void testWSPassByValueLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueLongArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateFloat.
+ */
+ @Test
+ public void testWSNegateFloat() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateFloat(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateFloatArray.
+ */
+ @Test
+ public void testWSNegateFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateFloatArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for float array.
+ */
+ @Test
+ public void testWSPassByValueFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueFloatArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateDouble.
+ */
+ @Test
+ public void testWSNegateDouble() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateDouble(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateDoubleArray.
+ */
+ @Test
+ public void testWSNegateDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ performTestNegateDoubleArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for double array.
+ */
+ @Test
+ public void testWSPassByValueDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientWSComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueDoubleArray());
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateBoolean.
+ */
+ @Test
+ public void testSCALocalNegateBoolean() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateBoolean(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateBooleanArray.
+ */
+ @Test
+ public void testSCALocalNegateBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateBooleanArray(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateByte.
+ */
+ @Test
+ public void testSCALocalNegateByte() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateByte(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateByteArray.
+ */
+ @Test
+ public void testSCALocalNegateByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateByteArray(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateShort.
+ */
+ @Test
+ public void testSCALocalNegateShort() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateShort(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateShortArray.
+ */
+ @Test
+ public void testSCALocalNegateShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateShortArray(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateInt.
+ */
+ @Test
+ public void testSCALocalNegateInt() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateInt(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateIntArray.
+ */
+ @Test
+ public void testSCALocalNegateIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateIntArray(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateLong.
+ */
+ @Test
+ public void testSCALocalNegateLong() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateLong(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateLongArray.
+ */
+ @Test
+ public void testSCALocalNegateLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateLongArray(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateFloat.
+ */
+ @Test
+ public void testSCALocalNegateFloat() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateFloat(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using SCA binding.
+ * Service method invoked is negateFloatArray.
+ */
+ @Test
+ public void testSCALocalNegateFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateFloatArray(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateDouble.
+ */
+ @Test
+ public void testSCALocalNegateDouble() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateDouble(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesLocalService service using SCA binding.
+ * Service method invoked is negateDoubleArray.
+ */
+ @Test
+ public void testSCALocalNegateDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesLocalServiceClientSCAComponent");
+ performTestNegateDoubleArray(primitivesServiceClient);
+ }
+
+ private void performTestNegateBoolean(PrimitivesServiceClient primitivesServiceClient) {
+ Assert.assertTrue(primitivesServiceClient.negateBooleanForward(false));
+ Assert.assertFalse(primitivesServiceClient.negateBooleanForward(true));
+ }
+
+ private void performTestNegateBooleanArray(PrimitivesServiceClient primitivesServiceClient) {
+ boolean flags[] = new boolean[2];
+ flags[0] = false;
+ flags[1] = true;
+ boolean[] respFlags = primitivesServiceClient.negateBooleanArrayForward(flags);
+ Assert.assertEquals(flags.length, respFlags.length);
+ for(int i = 0; i < flags.length; ++i) {
+ Assert.assertEquals(!flags[i], respFlags[i]);
+ }
+ }
+
+ private void performTestNegateByte(PrimitivesServiceClient primitivesServiceClient) {
+ byte[] ba = new byte[3];
+ ba[0] = -1;
+ ba[1] = 0;
+ ba[2] = 1;
+
+ for(int i = 0; i < ba.length; ++i) {
+ Assert.assertEquals((byte)-ba[i], primitivesServiceClient.negateByteForward(ba[i]));
+ }
+ }
+
+ private void performTestNegateByteArray(PrimitivesServiceClient primitivesServiceClient) {
+ byte[] ba = new byte[3];
+ ba[0] = -1;
+ ba[1] = 0;
+ ba[2] = 1;
+
+ byte[] r = primitivesServiceClient.negateByteArrayForward(ba);
+ Assert.assertEquals(ba.length, r.length);
+ for(int i = 0; i < ba.length; ++i) {
+ Assert.assertEquals((byte)-ba[i], r[i]);
+ }
+ }
+
+ private void performTestNegateShort(PrimitivesServiceClient primitivesServiceClient) {
+ short[] s = new short[3];
+ s[0] = -1;
+ s[1] = 0;
+ s[2] = 1;
+
+ for(int i = 0; i < s.length; ++i) {
+ Assert.assertEquals((short)-s[i], primitivesServiceClient.negateShortForward(s[i]));
+ }
+ }
+
+ private void performTestNegateShortArray(PrimitivesServiceClient primitivesServiceClient) {
+ short[] s = new short[3];
+ s[0] = -1;
+ s[1] = 0;
+ s[2] = 1;
+
+ short[] r = primitivesServiceClient.negateShortArrayForward(s);
+ Assert.assertEquals(s.length, r.length);
+ for(int i = 0; i < s.length; ++i) {
+ Assert.assertEquals((short)-s[i], r[i]);
+ }
+ }
+
+ private void performTestNegateInt(PrimitivesServiceClient primitivesServiceClient) {
+ int[] ia = new int[3];
+ ia[0] = -1;
+ ia[1] = 0;
+ ia[2] = 1;
+
+ for(int i = 0; i < ia.length; ++i) {
+ Assert.assertEquals(-ia[i], primitivesServiceClient.negateIntForward(ia[i]));
+ }
+ }
+
+ private void performTestNegateIntArray(PrimitivesServiceClient primitivesServiceClient) {
+ int[] ia = new int[3];
+ ia[0] = -1;
+ ia[1] = 0;
+ ia[2] = 1;
+
+ int[] r = primitivesServiceClient.negateIntArrayForward(ia);
+ Assert.assertEquals(ia.length, r.length);
+ for(int i = 0; i < ia.length; ++i) {
+ Assert.assertEquals(-ia[i], r[i]);
+ }
+ }
+
+ private void performTestNegateLong(PrimitivesServiceClient primitivesServiceClient) {
+ long[] la = new long[3];
+ la[0] = -1;
+ la[1] = 0;
+ la[2] = 1;
+
+ for(int i = 0; i < la.length; ++i) {
+ Assert.assertEquals(-la[i], primitivesServiceClient.negateLongForward(la[i]));
+ }
+ }
+
+ private void performTestNegateLongArray(PrimitivesServiceClient primitivesServiceClient) {
+ long[] la = new long[3];
+ la[0] = -1;
+ la[1] = 0;
+ la[2] = 1;
+
+ long[] r = primitivesServiceClient.negateLongArrayForward(la);
+ Assert.assertEquals(la.length, r.length);
+ for(int i = 0; i < la.length; ++i) {
+ Assert.assertEquals(-la[i], r[i]);
+ }
+ }
+
+ private void performTestNegateFloat(PrimitivesServiceClient primitivesServiceClient) {
+ float[] fa = new float[3];
+ fa[0] = -1;
+ fa[1] = 0;
+ fa[2] = 1;
+
+ for(int i = 0; i < fa.length; ++i) {
+ Assert.assertEquals(-fa[i], primitivesServiceClient.negateFloatForward(fa[i]));
+ }
+ }
+
+ private void performTestNegateFloatArray(PrimitivesServiceClient primitivesServiceClient) {
+ float[] ia = new float[3];
+ ia[0] = -1;
+ ia[1] = 0;
+ ia[2] = 1;
+
+ float[] r = primitivesServiceClient.negateFloatArrayForward(ia);
+ Assert.assertEquals(ia.length, r.length);
+ for(int i = 0; i < ia.length; ++i) {
+ Assert.assertEquals(-ia[i], r[i]);
+ }
+ }
+
+ private void performTestNegateDouble(PrimitivesServiceClient primitivesServiceClient) {
+ double[] da = new double[3];
+ da[0] = -1;
+ da[1] = 0;
+ da[2] = 1;
+
+ for(int i = 0; i < da.length; ++i) {
+ Assert.assertEquals(-da[i], primitivesServiceClient.negateDoubleForward(da[i]));
+ }
+ }
+
+ private void performTestNegateDoubleArray(PrimitivesServiceClient primitivesServiceClient) {
+ double[] da = new double[3];
+ da[0] = -1;
+ da[1] = 0;
+ da[2] = 1;
+
+ double[] r = primitivesServiceClient.negateDoubleArrayForward(da);
+ Assert.assertEquals(da.length, r.length);
+ for(int i = 0; i < da.length; ++i) {
+ Assert.assertEquals(-da[i], r[i]);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesDatabindingTestCase.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesDatabindingTestCase.java
new file mode 100644
index 0000000000..dd9a689353
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-bottom-up/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesDatabindingTestCase.java
@@ -0,0 +1,1439 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.attachments.ByteArrayDataSource;
+import org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesTransformer;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StandardTypesDatabindingTestCase {
+
+ private static Node node;
+
+ /**
+ * Runs before each test method
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/standard-types-service.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Runs after each test method
+ */
+ @AfterClass
+ public static void tearDown() {
+ node.stop();
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewBigInteger.
+ */
+ @Test
+ public void testSCANewBigInteger() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewBigInteger(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewBigIntegerArray.
+ */
+ @Test
+ public void testSCANewBigIntegerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewBigIntegerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewBigDecimal.
+ */
+ @Test
+ public void testSCANewBigDecimal() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewBigDecimal(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewBigDecimalArray.
+ */
+ @Test
+ public void testSCANewBigDecimalArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewBigDecimalArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewCalendar.
+ */
+ @Test
+ public void testSCANewCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewCalendarArray.
+ */
+ @Test
+ public void testSCANewCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewDate.
+ */
+ @Test
+ public void testSCANewDate() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewDate(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewDateArray.
+ */
+ @Test
+ public void testSCANewDateArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewDateArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewQName.
+ */
+ @Test
+ public void testSCANewQName() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewQName(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewQNameArray.
+ */
+ @Test
+ public void testSCANewQNameArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewQNameArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewURI.
+ */
+ @Test
+ public void testSCANewURI() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewURI(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewURIArray.
+ */
+ @Test
+ public void testSCANewURIArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewURIArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewXMLGregorianCalendar.
+ */
+ @Test
+ public void testSCANewXMLGregorianCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewXMLGregorianCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewXMLGregorianCalendarArray.
+ */
+ @Test
+ public void testSCANewXMLGregorianCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewXMLGregorianCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewDuration.
+ */
+ @Test
+ public void testSCANewDuration() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewDuration(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewDurationArray.
+ */
+ @Test
+ public void testSCANewDurationArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewDurationArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewObject.
+ */
+ @Test
+ public void testSCANewObject() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewObject(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewObjectArray.
+ */
+ @Test
+ public void testSCANewObjectArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewObjectArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewImage.
+ */
+ @Test
+ public void testSCANewImage() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewImage(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewImageArray.
+ */
+ @Test
+ public void testSCANewImageArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewImageArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewDataHandler.
+ */
+ @Test
+ public void testSCANewDataHandler() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewDataHandler(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewDataHandlerArray.
+ */
+ @Test
+ public void testSCANewDataHandlerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewDataHandlerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewSource.
+ */
+ /*@Test
+ public void testSCANewSource() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewSource(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewSourceArray.
+ */
+ /*@Test
+ @Ignore("TUSCANY-2387")
+ public void testSCANewSourceArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewSourceArray(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewUUID.
+ */
+ @Test
+ public void testSCANewUUID() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewUUID(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using SCA binding.
+ * Service method invoked is getNewUUIDArray.
+ */
+ @Test
+ public void testSCANewUUIDArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientSCAComponent");
+ performTestNewUUIDArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigInteger.
+ */
+ @Test
+ public void testWSNewBigInteger() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewBigInteger(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigIntegerArray.
+ */
+ @Test
+ public void testWSNewBigIntegerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewBigIntegerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigDecimal.
+ */
+ @Test
+ public void testWSNewBigDecimal() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewBigDecimal(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigDecimalArray.
+ */
+ @Test
+ public void testWSNewBigDecimalArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewBigDecimalArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewCalendar.
+ */
+ @Test
+ public void testWSNewCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewCalendarArray.
+ */
+ @Test
+ public void testWSNewCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDate.
+ */
+ @Test
+ public void testWSNewDate() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewDate(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDateArray.
+ */
+ @Test
+ public void testWSNewDateArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewDateArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewQName.
+ */
+ @Test
+ public void testWSNewQName() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewQName(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewQNameArray.
+ */
+ @Test
+ public void testWSNewQNameArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewQNameArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewURI.
+ */
+ @Test
+ public void testWSNewURI() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewURI(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewURIArray.
+ */
+ @Test
+ public void testWSNewURIArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewURIArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewXMLGregorianCalendar.
+ */
+ @Test
+ public void testWSNewXMLGregorianCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewXMLGregorianCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewXMLGregorianCalendarArray.
+ */
+ @Test
+ public void testWSNewXMLGregorianCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewXMLGregorianCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDuration.
+ */
+ @Test
+ public void testWSNewDuration() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewDuration(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDurationArray.
+ */
+ @Test
+ public void testWSNewDurationArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewDurationArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewObject.
+ */
+ @Test
+ public void testWSNewObject() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewObject(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewObjectArray.
+ */
+ @Test
+ public void testWSNewObjectArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewObjectArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewImage.
+ */
+ @Test
+ public void testWSNewImage() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewImage(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewImageArray.
+ */
+ @Test
+ public void testWSNewImageArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewImageArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDataHandler.
+ */
+ @Test
+ public void testWSNewDataHandler() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewDataHandler(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDataHandlerArray.
+ */
+ @Test
+ public void testWSNewDataHandlerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewDataHandlerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewSource.
+ */
+ /*@Test
+ // @Ignore("junit.framework.ComparisonFailure: null expected:<... encoding=\"UTF-8\"?><[a>A</a]>> but was:<... encoding=\"UTF-8\"?><[return xmlns=\"http://jaxb.databindings.itest.sca.tuscany.apache.org/\">A</return]>>")
+ public void testWSNewSource() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewSource(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewSourceArray.
+ */
+ /*@Test
+ @Ignore("TUSCANY-2386")
+ public void testWSNewSourceArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewSourceArray(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewUUID.
+ */
+ @Test
+ public void testWSNewUUID() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewUUID(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewUUIDArray.
+ */
+ @Test
+ public void testWSNewUUIDArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientWSComponent");
+ performTestNewUUIDArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewBigInteger.
+ */
+ @Test
+ public void testSCALocalNewBigInteger() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewBigInteger(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewBigIntegerArray.
+ */
+ @Test
+ public void testSCALocalNewBigIntegerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewBigIntegerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewBigDecimal.
+ */
+ @Test
+ public void testSCALocalNewBigDecimal() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewBigDecimal(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewBigDecimalArray.
+ */
+ @Test
+ public void testSCALocalNewBigDecimalArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewBigDecimalArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewCalendar.
+ */
+ @Test
+ public void testSCALocalNewCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewCalendarArray.
+ */
+ @Test
+ public void testSCALocalNewCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewDate.
+ */
+ @Test
+ public void testSCALocalNewDate() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewDate(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewDateArray.
+ */
+ @Test
+ public void testSCALocalNewDateArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewDateArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewQName.
+ */
+ @Test
+ public void testSCALocalNewQName() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewQName(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewQNameArray.
+ */
+ @Test
+ public void testSCALocalNewQNameArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewQNameArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewURI.
+ */
+ @Test
+ public void testSCALocalNewURI() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewURI(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewURIArray.
+ */
+ @Test
+ public void testSCALocalNewURIArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewURIArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewXMLGregorianCalendar.
+ */
+ @Test
+ public void testSCALocalNewXMLGregorianCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewXMLGregorianCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewXMLGregorianCalendarArray.
+ */
+ @Test
+ public void testSCALocalNewXMLGregorianCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewXMLGregorianCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewDuration.
+ */
+ @Test
+ public void testSCALocalNewDuration() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewDuration(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewDurationArray.
+ */
+ @Test
+ public void testSCALocalNewDurationArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewDurationArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewObject.
+ */
+ @Test
+ public void testSCALocalNewObject() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewObject(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewObjectArray.
+ */
+ @Test
+ public void testSCALocalNewObjectArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewObjectArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewImage.
+ */
+ @Test
+ public void testSCALocalNewImage() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewImage(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewImageArray.
+ */
+ @Test
+ public void testSCALocalNewImageArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewImageArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalLocalService service using SCA binding.
+ * Service method invoked is getNewDataHandler.
+ */
+ @Test
+ public void testSCALocalNewDataHandler() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewDataHandler(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewDataHandlerArray.
+ */
+ @Test
+ public void testSCALocalNewDataHandlerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewDataHandlerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewSource.
+ */
+ /*@Test
+ public void testSCALocalNewSource() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewSource(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewSourceArray.
+ */
+ /*@Test
+ public void testSCALocalNewSourceArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewSourceArray(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewUUID.
+ */
+ @Test
+ public void testSCALocalNewUUID() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewUUID(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesLocalService service using SCA binding.
+ * Service method invoked is getNewUUIDArray.
+ */
+ @Test
+ public void testSCALocalNewUUIDArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesLocalServiceClientSCAComponent");
+ performTestNewUUIDArray(serviceClient);
+ }
+
+ private void performTestNewBigInteger(StandardTypesServiceClient serviceClient) {
+ BigInteger bi = new BigInteger("1234567890123456789012345678901234");
+ BigInteger expected = bi.negate();
+ BigInteger actual = serviceClient.getNewBigIntegerForward(bi);
+ Assert.assertEquals(expected, actual);
+ }
+
+ private void performTestNewBigIntegerArray(StandardTypesServiceClient serviceClient) {
+ BigInteger[] bia = new BigInteger[2];
+ bia[0] = new BigInteger("1234567890123456789012345678901234");
+ bia[1] = new BigInteger("-98765432109876543210987654321");
+ BigInteger[] actual = serviceClient.getNewBigIntegerArrayForward(bia);
+ Assert.assertEquals(bia.length, actual.length);
+ for (int i = 0; i < bia.length; ++i) {
+ Assert.assertEquals(bia[i].negate(), actual[i]);
+ }
+ }
+
+ private void performTestNewBigDecimal(StandardTypesServiceClient serviceClient) {
+ BigDecimal bd = new BigDecimal("12345678901234567890.12345678901234");
+ BigDecimal expected = bd.negate();
+ BigDecimal actual = serviceClient.getNewBigDecimalForward(bd);
+ Assert.assertEquals(expected, actual);
+ }
+
+ private void performTestNewBigDecimalArray(StandardTypesServiceClient serviceClient) {
+ BigDecimal[] bda = new BigDecimal[2];
+ bda[0] = new BigDecimal("1234567890123456.789012345678901234");
+ bda[1] = new BigDecimal("-987654321098765.43210987654321");
+ BigDecimal[] actual = serviceClient.getNewBigDecimalArrayForward(bda);
+ Assert.assertEquals(bda.length, actual.length);
+ for (int i = 0; i < bda.length; ++i) {
+ Assert.assertEquals(bda[i].negate(), actual[i]);
+ }
+ }
+
+ private void performTestNewCalendar(StandardTypesServiceClient serviceClient) {
+ Calendar[] ca = new Calendar[3];
+ String[] tz = {"GMT+05:30", "GMT+00:00", "GMT-05:00"};
+ for (int i = 0; i < ca.length; ++i) {
+ ca[i] = Calendar.getInstance(TimeZone.getTimeZone(tz[i]));
+ ca[i].set(Calendar.DAY_OF_MONTH, i + 1);
+ }
+ for (int i = 0; i < ca.length; ++i) {
+ Calendar actual = serviceClient.getNewCalendarForward(ca[i]);
+ ca[i].add(Calendar.DAY_OF_MONTH, 5);
+ if (actual instanceof GregorianCalendar && ca[i] instanceof GregorianCalendar) {
+ // FIXME: Is this a problem?
+ // The instance returned by service method invoked over binding.ws seems to have a gregorianCutover
+ // different from the instance passed. Adjust the gregorianCutover as per the input instance.
+ ((GregorianCalendar)actual).setGregorianChange(((GregorianCalendar)ca[i]).getGregorianChange());
+ }
+ Assert.assertEquals(ca[i], actual);
+ }
+ }
+
+ private void performTestNewCalendarArray(StandardTypesServiceClient serviceClient) {
+ Calendar[] ca = new Calendar[3];
+ String[] tz = {"GMT+05:30", "GMT+00:00", "GMT-05:00"};
+ for (int i = 0; i < ca.length; ++i) {
+ ca[i] = Calendar.getInstance(TimeZone.getTimeZone(tz[i]));
+ ca[i].set(Calendar.DAY_OF_MONTH, i + 1);
+ }
+ Calendar[] actual = serviceClient.getNewCalendarArrayForward(ca);
+ Assert.assertEquals(ca.length, actual.length);
+ for (int i = 0; i < ca.length; ++i) {
+ ca[i].add(Calendar.DAY_OF_MONTH, 5);
+ if (actual[i] instanceof GregorianCalendar && ca[i] instanceof GregorianCalendar) {
+ // FIXME: Is this a problem?
+ // The instance returned by service method invoked over binding.ws seems to have a gregorianCutover
+ // different from the instance passed. Adjust the gregorianCutover as per the input instance.
+ ((GregorianCalendar)actual[i]).setGregorianChange(((GregorianCalendar)ca[i]).getGregorianChange());
+ }
+ Assert.assertEquals(ca[i], actual[i]);
+ }
+ }
+
+ private void performTestNewDate(StandardTypesServiceClient serviceClient) {
+ Date d = new Date();
+ Date expected = new Date(d.getTime() + 5 * 24 * 60 * 60 * 1000);
+ Date actual = serviceClient.getNewDateForward(d);
+ Assert.assertEquals(expected, actual);
+ }
+
+ private void performTestNewDateArray(StandardTypesServiceClient serviceClient) {
+ Date[] d = new Date[2];
+ Date[] expected = new Date[d.length];
+ for (int i = 0; i < d.length; ++i) {
+ d[i] = new Date();
+ d[i].setTime(d[i].getTime() + i * 24 * 60 * 60 * 1000);
+ expected[i] = new Date(d[i].getTime() + 5 * 24 * 60 * 60 * 1000);
+ }
+ Date[] actual = serviceClient.getNewDateArrayForward(d);
+ Assert.assertEquals(expected.length, actual.length);
+ for (int i = 0; i < expected.length; ++i) {
+ Assert.assertEquals(expected[i], actual[i]);
+ }
+ }
+
+ private void performTestNewQName(StandardTypesServiceClient serviceClient) {
+ QName[] qnames = new QName[3];
+ qnames[0] = new QName("localPart");
+ qnames[1] = new QName("namespaceUri", "localPart");
+ qnames[2] = new QName("namespaceUri", "localPart", "prefix");
+ QName[] expected = new QName[qnames.length];
+ for (int i = 0; i < qnames.length; ++i) {
+ expected[i] =
+ new QName(qnames[i].getNamespaceURI() + "q", qnames[i].getLocalPart() + "q",
+ qnames[i].getPrefix() + "q");
+ }
+ for (int i = 0; i < qnames.length; ++i) {
+ QName actual = serviceClient.getNewQNameForward(qnames[i]);
+ Assert.assertEquals(expected[i], actual);
+ }
+ }
+
+ private void performTestNewQNameArray(StandardTypesServiceClient serviceClient) {
+ QName[] qnames = new QName[4];
+ qnames[0] = new QName("localPart");
+ qnames[1] = new QName("namespaceUri", "localPart");
+ qnames[2] = new QName("namespaceUri", "localPart", "prefix");
+ qnames[3] = new QName("localPart2");
+ QName[] expected = new QName[qnames.length];
+ for (int i = 0; i < qnames.length; ++i) {
+ expected[i] =
+ new QName(qnames[i].getNamespaceURI() + "q", qnames[i].getLocalPart() + "q",
+ qnames[i].getPrefix() + "q");
+ }
+ QName[] actual = serviceClient.getNewQNameArrayForward(qnames);
+ Assert.assertEquals(expected.length, actual.length);
+ for (int i = 0; i < qnames.length; ++i) {
+ Assert.assertEquals(expected[i], actual[i]);
+ }
+ }
+
+ private void performTestNewURI(StandardTypesServiceClient serviceClient) {
+ URI[] uris = new URI[4];
+ uris[0] = URI.create("a/b/c");
+ uris[1] = URI.create("http://abc/");
+ uris[2] = URI.create("ftp://a/b");
+ uris[3] = URI.create("http://abc/").resolve("xyz");
+
+ for (int i = 0; i < uris.length; ++i) {
+ URI expected = uris[i].resolve("uri");
+ URI actual = serviceClient.getNewURIForward(uris[i]);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestNewURIArray(StandardTypesServiceClient serviceClient) {
+ URI[] uris = new URI[4];
+ uris[0] = URI.create("a/b/c");
+ // [rfeng] We need to have a trialign / to avoid the resolving problem
+ // FIXME: [vamsi] This is actually a data transformation problem. The array being returned from the service method is
+ // not making to the caller intact.
+ uris[1] = URI.create("http://abc/");
+ uris[2] = URI.create("ftp://a/b");
+ uris[3] = URI.create("http://abc/").resolve("xyz");
+
+ URI[] expected = new URI[uris.length];
+ for (int i = 0; i < uris.length; ++i) {
+ expected[i] = uris[i].resolve("uri");
+ }
+
+ URI[] actual = serviceClient.getNewURIArrayForward(uris);
+ Assert.assertEquals(expected.length, actual.length);
+ for (int i = 0; i < uris.length; ++i) {
+ Assert.assertEquals(expected[i], actual[i]);
+ }
+ }
+
+ private void performTestNewXMLGregorianCalendar(StandardTypesServiceClient serviceClient)
+ throws DatatypeConfigurationException {
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ XMLGregorianCalendar[] xgcals = new XMLGregorianCalendar[3];
+ xgcals[0] = df.newXMLGregorianCalendar(new GregorianCalendar(1974, GregorianCalendar.APRIL, 19));
+ xgcals[1] = df.newXMLGregorianCalendar(new GregorianCalendar(1978, GregorianCalendar.OCTOBER, 13));
+ xgcals[2] = df.newXMLGregorianCalendar(new GregorianCalendar(2006, GregorianCalendar.JUNE, 16));
+
+ for (int i = 0; i < xgcals.length; ++i) {
+ XMLGregorianCalendar actual = serviceClient.getNewXMLGregorianCalendarForward(xgcals[i]);
+ xgcals[i].setDay(xgcals[i].getDay() + 5);
+ Assert.assertEquals(xgcals[i], actual);
+ }
+ }
+
+ private void performTestNewXMLGregorianCalendarArray(StandardTypesServiceClient serviceClient)
+ throws DatatypeConfigurationException {
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ XMLGregorianCalendar[] xgcals = new XMLGregorianCalendar[3];
+ xgcals[0] = df.newXMLGregorianCalendar(new GregorianCalendar(1974, GregorianCalendar.APRIL, 19));
+ xgcals[1] = df.newXMLGregorianCalendar(new GregorianCalendar(1978, GregorianCalendar.OCTOBER, 13));
+ xgcals[2] = df.newXMLGregorianCalendar(new GregorianCalendar(2006, GregorianCalendar.JUNE, 16));
+
+ XMLGregorianCalendar[] actual = serviceClient.getNewXMLGregorianCalendarArrayForward(xgcals);
+ Assert.assertEquals(xgcals.length, actual.length);
+ for (int i = 0; i < xgcals.length; ++i) {
+ xgcals[i].setDay(xgcals[i].getDay() + 5);
+ Assert.assertEquals(xgcals[i], actual[i]);
+ }
+ }
+
+ private void performTestNewDuration(StandardTypesServiceClient serviceClient) throws DatatypeConfigurationException {
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ Duration[] da = new Duration[3];
+ da[0] = df.newDuration(1000000000000L);
+ da[1] = df.newDurationDayTime(1000000000000L);
+ da[2] = df.newDurationYearMonth(true, 1, 3);
+
+ for (int i = 0; i < da.length; ++i) {
+ Assert.assertEquals(da[i].negate(), serviceClient.getNewDurationForward(da[i]));
+ }
+ }
+
+ private void performTestNewObject(StandardTypesServiceClient serviceClient) {
+ Object[] objs = new Object[5];
+ objs[0] = "Hello";
+ objs[1] = 10;
+ objs[2] = null;
+ objs[3] = -1.0;
+ objs[4] = null;
+
+ for (int i = 0; i < objs.length; ++i) {
+ Object expected = StandardTypesTransformer.getNewObject(objs[i]);
+ Object actual = serviceClient.getNewObjectForward(objs[i]);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestNewObjectArray(StandardTypesServiceClient serviceClient) {
+ Object[] objs = new Object[5];
+ objs[0] = "Hello";
+ objs[1] = 10;
+ objs[2] = null;
+ objs[3] = -1.0;
+ objs[4] = null;
+
+ Object[] actual = serviceClient.getNewObjectArrayForward(objs);
+ Assert.assertEquals(objs.length, actual.length);
+ for (int i = 0; i < objs.length; ++i) {
+ Object expected = StandardTypesTransformer.getNewObject(objs[i]);
+ Assert.assertEquals(expected, actual[i]);
+ }
+ }
+
+ private void performTestNewImage(StandardTypesServiceClient serviceClient) throws InterruptedException {
+ // Create some images to test with.
+ Image[] imgs = new Image[3];
+ imgs[0] = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
+ imgs[1] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ imgs[2] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ imgs[0].getGraphics().drawLine(1, 1, 8, 8);
+ imgs[1].getGraphics().drawLine(8, 1, 1, 8);
+ imgs[2].getGraphics().drawLine(1, 8, 8, 1);
+
+ Image[] copy = imgs;
+ // Create the same images once again as the StandardTypesTransformer may manipulate the image passed.
+ imgs = new Image[3];
+ imgs[0] = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
+ imgs[1] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ imgs[2] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ imgs[0].getGraphics().drawLine(1, 1, 8, 8);
+ imgs[1].getGraphics().drawLine(8, 1, 1, 8);
+ imgs[2].getGraphics().drawLine(1, 8, 8, 1);
+
+ // Make sure the images and copies are equal using ImageInfo
+ for(int i = 0; i < imgs.length; ++i) {
+ Assert.assertEquals(new ImageInfo(imgs[i]), new ImageInfo(copy[i]));
+ }
+
+ for (int i = 0; i < imgs.length; ++i) {
+ Image actual = serviceClient.getNewImageForward(imgs[i]);
+ Image expected = StandardTypesTransformer.getNewImage(copy[i]);
+ // Compare using ImageInfo
+ Assert.assertEquals(new ImageInfo(expected), new ImageInfo(actual));
+ }
+ }
+
+ private void performTestNewImageArray(StandardTypesServiceClient serviceClient) throws InterruptedException {
+ // Create some images to test with.
+ Image[] imgs = new Image[3];
+ imgs[0] = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
+ imgs[1] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ imgs[2] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ imgs[0].getGraphics().drawLine(1, 1, 8, 8);
+ imgs[1].getGraphics().drawLine(8, 1, 1, 8);
+ imgs[2].getGraphics().drawLine(1, 8, 8, 1);
+
+ Image[] copy = imgs;
+ // Create the same images once again as the StandardTypesTransformer may manipulate the image passed.
+ imgs = new Image[3];
+ imgs[0] = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
+ imgs[1] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ imgs[2] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ imgs[0].getGraphics().drawLine(1, 1, 8, 8);
+ imgs[1].getGraphics().drawLine(8, 1, 1, 8);
+ imgs[2].getGraphics().drawLine(1, 8, 8, 1);
+
+ // Make sure the images and copies are equal using ImageInfo
+ for(int i = 0; i < imgs.length; ++i) {
+ Assert.assertEquals(new ImageInfo(imgs[i]), new ImageInfo(copy[i]));
+ }
+
+ Image[] actual = serviceClient.getNewImageArrayForward(imgs);
+ Assert.assertEquals(imgs.length, actual.length);
+ for (int i = 0; i < imgs.length; ++i) {
+ Image expected = StandardTypesTransformer.getNewImage(copy[i]);
+ // Compare using ImageInfo
+ Assert.assertEquals(new ImageInfo(expected), new ImageInfo(actual[i]));
+ }
+ }
+
+ private void performTestNewDurationArray(StandardTypesServiceClient serviceClient)
+ throws DatatypeConfigurationException {
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ Duration[] da = new Duration[3];
+ da[0] = df.newDuration(1000000000000L);
+ da[1] = df.newDurationDayTime(1000000000000L);
+ da[2] = df.newDurationYearMonth(true, 1, 3);
+
+ Duration[] actual = serviceClient.getNewDurationArrayForward(da);
+ Assert.assertEquals(da.length, actual.length);
+ for (int i = 0; i < da.length; ++i) {
+ Assert.assertEquals(da[i].negate(), actual[i]);
+ }
+ }
+
+ private void performTestNewDataHandler(StandardTypesServiceClient serviceClient) throws IOException {
+ DataHandler[] dha = new DataHandler[3];
+ dha[0] = new DataHandler("Some data", "text/plain");
+ dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
+ dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));
+
+ for (int i = 0; i < dha.length; ++i) {
+ DataHandler actual = serviceClient.getNewDataHandlerForward(dha[i]);
+ // Note: The DataHandler returned may use a different type of DataSource.
+ // Compare the data content instead of using equals().
+ Assert.assertTrue(compare(dha[i], actual));
+ }
+ }
+
+ private void performTestNewDataHandlerArray(StandardTypesServiceClient serviceClient) throws IOException {
+ DataHandler[] dha = new DataHandler[3];
+ dha[0] = new DataHandler("Some data", "text/plain");
+ dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
+ dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));
+
+ DataHandler[] actual = serviceClient.getNewDataHandlerArrayForward(dha);
+ Assert.assertEquals(dha.length, actual.length);
+ for (int i = 0; i < dha.length; ++i) {
+ // Note: The DataHandler returned may use a different type of DataSource.
+ // Compare the data content instead of using equals().
+ Assert.assertTrue(compare(dha[i], actual[i]));
+ }
+ }
+
+ /*private void performTestNewSource(StandardTypesServiceClient serviceClient) throws Exception {
+ String xml = "<a>A<b>B</b><c>C</c></a>";
+ Source[] srcs = new Source[3];
+ srcs[0] = new DOMSource(new String2Node(null).transform(xml, null));
+ srcs[1] = new SAXSource(new InputSource(new StringReader(xml)));
+ srcs[2] = new StreamSource(new StringReader(xml));
+
+ for (int i = 0; i < srcs.length; ++i) {
+ Source expected = StandardTypesTransformer.getNewSource(srcs[i]);
+ Source actual = serviceClient.getNewSourceForward(srcs[i]);
+ // [rfeng] The data may come back as a different source
+ Assert.assertEquals(sourceToString(expected), sourceToString(actual));
+ }
+ }
+
+ private void performTestNewSourceArray(StandardTypesServiceClient serviceClient) throws Exception {
+ String xml = "<a>A<b>B</b><c>C</c></a>";
+ Source[] srcs = new Source[3];
+ srcs[0] = new DOMSource(new String2Node(null).transform(xml, null));
+ srcs[1] = new SAXSource(new InputSource(new StringReader(xml)));
+ srcs[2] = new StreamSource(new StringReader(xml));
+
+ Source[] actual = serviceClient.getNewSourceArrayForward(srcs);
+ Source[] expected = new Source[srcs.length];
+ for(int i = 0; i < srcs.length; ++i) {
+ expected[i] = StandardTypesTransformer.getNewSource(srcs[i]);
+ }
+ Assert.assertEquals(srcs.length, actual.length);
+ for (int i = 0; i < srcs.length; ++i) {
+ // [rfeng] The data may come back as a different source
+ Assert.assertEquals(sourceToString(expected[i]), sourceToString(actual[i]));
+ }
+
+ }*/
+
+ private void performTestNewUUID(StandardTypesServiceClient serviceClient) {
+ UUID[] uuids = new UUID[3];
+ uuids[0] = UUID.nameUUIDFromBytes("ABCDEFGHJKLMNOPQRSTUVWXYZ".getBytes());
+ uuids[1] = UUID.nameUUIDFromBytes("abcdefghjklmnopqrstuvwxyz".getBytes());
+ uuids[2] = UUID.randomUUID();
+
+ for (int i = 0; i < uuids.length; ++i) {
+ UUID expected = UUID.fromString(uuids[i].toString() + "AAA");
+ UUID actual = serviceClient.getNewUUIDForward(uuids[i]);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestNewUUIDArray(StandardTypesServiceClient serviceClient) {
+ UUID[] uuids = new UUID[3];
+ uuids[0] = UUID.nameUUIDFromBytes("ABCDEFGHJKLMNOPQRSTUVWXYZ".getBytes());
+ uuids[1] = UUID.nameUUIDFromBytes("abcdefghjklmnopqrstuvwxyz".getBytes());
+ uuids[2] = UUID.randomUUID();
+
+ UUID[] actual = serviceClient.getNewUUIDArrayForward(uuids);
+ for (int i = 0; i < uuids.length; ++i) {
+ UUID expected = UUID.fromString(uuids[i].toString() + "AAA");
+ Assert.assertEquals(expected, actual[i]);
+ }
+ }
+
+ /**
+ * This method compares two DataHandlers.
+ * @return true if the data in the two handlers is the same.
+ */
+ private boolean compare(DataHandler dh1, DataHandler dh2) throws IOException {
+ InputStream inp1 = dh1.getInputStream();
+ InputStream inp2 = dh2.getInputStream();
+ for(;;) {
+ int i1 = inp1.read();
+ int i2 = inp2.read();
+ if(i1 == -1 && i2 == -1) {
+ return true;
+ } else if(i1 != -1 && i2 != -1) {
+ if(i1 != i2) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * This method returns the content of a source object as String.
+ */
+ private String sourceToString(Source s) throws Exception {
+ StringWriter sw = new StringWriter();
+ Result r = new StreamResult(sw);
+ TransformerFactory.newInstance().newTransformer().transform(s, r);
+ sw.close();
+ return sw.toString();
+ }
+
+ /**
+ * This class initializes with the width, height and pixel data of a java.awt.Image object.
+ */
+ private static class ImageInfo {
+ private int h, w, pixels[];
+ public ImageInfo(Image img) throws InterruptedException {
+ w = img.getWidth(null);
+ h = img.getHeight(null);
+ pixels = new int[w*h];
+ PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w);
+ pg.grabPixels();
+ }
+
+ public boolean equals(Object that) {
+ if(that == null) {
+ return false;
+ } else if(!(that instanceof ImageInfo)) {
+ return false;
+ }
+
+ ImageInfo that1 = (ImageInfo)that;
+ if(w != that1.w || h != that1.h || pixels == null || that1.pixels == null || pixels.length != that1.pixels.length) {
+ return false;
+ }
+ for(int i = 0; i < pixels.length; ++i) {
+ if(pixels[i] != that1.pixels[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public String toString() {
+ return this.getClass().getSimpleName()+"[w = "+w+", h = "+h+", pixels = "+pixels+"]";
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/pom.xml b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/pom.xml
new file mode 100644
index 0000000000..be9d12f1e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/pom.xml
@@ -0,0 +1,189 @@
+<?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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-databindings</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>itest-databindings-jaxb-top-down</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <name>Apache Tuscany SCA iTest Databinding - JAXB Top Down</name>
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency-->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-databindings-common</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-rt</artifactId>
+ <version>2.1.3</version>
+ </dependency>
+ <!-- Added by Simon Nash -->
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- End of addition -->
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloService.java
new file mode 100644
index 0000000000..ab2d9630eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for HelloService.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface HelloService {
+ String getGreetings(String name);
+ String[] getGreetingsArray(String[] names);
+ List<String> getGreetingsList(List<String> names);
+ ArrayList<String> getGreetingsArrayList(ArrayList<String> names);
+ Map<String, String> getGreetingsMap(Map<String, String> namesMap);
+ HashMap<String, String> getGreetingsHashMap(HashMap<String, String> namesMap);
+ String getGreetingsVarArgs(String... names);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceClient.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceClient.java
new file mode 100644
index 0000000000..7bd95cec95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/HelloServiceClient.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.itest.databindings.jaxb;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * The interface for HelloServiceClient.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HelloServiceClient {
+ String getGreetingsForward(String name);
+ String[] getGreetingsArrayForward(String[] names);
+ List<String> getGreetingsListForward(List<String> names);
+ ArrayList<String> getGreetingsArrayListForward(ArrayList<String> names);
+ Map<String, String> getGreetingsMapForward(Map<String, String> namesMap);
+ HashMap<String, String> getGreetingsHashMapForward(HashMap<String, String> namesMap);
+ String getGreetingsVarArgsForward(String... names);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesService.java
new file mode 100644
index 0000000000..ac6c8d5a60
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesService.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for PrimitivesService.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface PrimitivesService {
+ boolean negateBoolean(boolean flag);
+ boolean[] negateBooleanArray(boolean[] flags);
+ boolean[] identityBooleanArray(boolean[] flags);
+ byte negateByte(byte b);
+ byte[] negateByteArray(byte[] ba);
+ byte[] identityByteArray(byte[] ba);
+ short negateShort(short s);
+ short[] negateShortArray(short[] s);
+ short[] identityShortArray(short[] sa);
+ int negateInt(int s);
+ int[] negateIntArray(int[] s);
+ int[] identityIntArray(int[] ia);
+ long negateLong(long l);
+ long[] negateLongArray(long[] la);
+ long[] identityLongArray(long[] la);
+ float negateFloat(float f);
+ float[] negateFloatArray(float[] fa);
+ float[] identityFloatArray(float[] fa);
+ double negateDouble(double d);
+ double[] negateDoubleArray(double[] da);
+ double[] identityDoubleArray(double[] da);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesServiceClient.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesServiceClient.java
new file mode 100644
index 0000000000..3a5a81bae4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/PrimitivesServiceClient.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.itest.databindings.jaxb;
+
+
+/**
+ * The interface for PrimitivesServiceClient.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PrimitivesServiceClient {
+ boolean negateBooleanForward(boolean flag);
+ boolean[] negateBooleanArrayForward(boolean[] flags);
+ boolean passByValueBooleanArray();
+ byte negateByteForward(byte b);
+ byte[] negateByteArrayForward(byte[] ba);
+ boolean passByValueByteArray();
+ short negateShortForward(short s);
+ short[] negateShortArrayForward(short[] sa);
+ boolean passByValueShortArray();
+ int negateIntForward(int i);
+ int[] negateIntArrayForward(int[] ia);
+ boolean passByValueIntArray();
+ long negateLongForward(long l);
+ long[] negateLongArrayForward(long[] la);
+ boolean passByValueLongArray();
+ float negateFloatForward(float f);
+ float[] negateFloatArrayForward(float[] fa);
+ boolean passByValueFloatArray();
+ double negateDoubleForward(double d);
+ double[] negateDoubleArrayForward(double[] da);
+ boolean passByValueDoubleArray();
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesService.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesService.java
new file mode 100644
index 0000000000..1f3b7ec633
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesService.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb;
+
+import java.awt.Image;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+
+/**
+ * The interface for StandardTypesService.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface StandardTypesService {
+ BigInteger getNewBigInteger(BigInteger bi);
+ BigInteger[] getNewBigIntegerArray(BigInteger[] bia);
+
+ BigDecimal getNewBigDecimal(BigDecimal bd);
+ BigDecimal[] getNewBigDecimalArray(BigDecimal[] bda);
+
+ Calendar getNewCalendar(Calendar c);
+ Calendar[] getNewCalendarArray(Calendar[] ca);
+
+ Date getNewDate(Date d);
+ Date[] getNewDateArray(Date[] da);
+
+ QName getNewQName(QName qname);
+ QName[] getNewQNameArray(QName[] qnames);
+
+ URI getNewURI(URI uri);
+ URI[] getNewURIArray(URI[] uris);
+
+ XMLGregorianCalendar getNewXMLGregorianCalendar(XMLGregorianCalendar xgcal);
+ XMLGregorianCalendar[] getNewXMLGregorianCalendarArray(XMLGregorianCalendar[] xgcal);
+
+ Duration getNewDuration(Duration d);
+ Duration[] getNewDurationArray(Duration[] da);
+
+ Object getNewObject(Object obj);
+ Object[] getNewObjectArray(Object[] objs);
+
+ Image getNewImage(Image img);
+ Image[] getNewImageArray(Image[] imgs);
+
+ DataHandler getNewDataHandler(DataHandler dh);
+ DataHandler[] getNewDataHandlerArray(DataHandler[] dha);
+
+ Source getNewSource(Source src);
+ Source[] getNewSourceArray(Source[] srcs);
+
+ UUID getNewUUID(UUID uuid);
+ UUID[] getNewUUIDArray(UUID[] uuids);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesServiceClient.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesServiceClient.java
new file mode 100644
index 0000000000..0c073cd054
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/StandardTypesServiceClient.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.sca.itest.databindings.jaxb;
+
+import java.awt.Image;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+
+/**
+ * The interface for StandardTypesServiceClient.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface StandardTypesServiceClient {
+ BigInteger getNewBigIntegerForward(BigInteger bi);
+ BigInteger[] getNewBigIntegerArrayForward(BigInteger[] bia);
+
+ BigDecimal getNewBigDecimalForward(BigDecimal bd);
+ BigDecimal[] getNewBigDecimalArrayForward(BigDecimal[] bda);
+
+ Calendar getNewCalendarForward(Calendar c);
+ Calendar[] getNewCalendarArrayForward(Calendar[] ca);
+
+ Date getNewDateForward(Date d);
+ Date[] getNewDateArrayForward(Date[] da);
+
+ QName getNewQNameForward(QName qname);
+ QName[] getNewQNameArrayForward(QName[] qnames);
+
+ URI getNewURIForward(URI uri);
+ URI[] getNewURIArrayForward(URI[] uris);
+
+ XMLGregorianCalendar getNewXMLGregorianCalendarForward(XMLGregorianCalendar xgcal);
+ XMLGregorianCalendar[] getNewXMLGregorianCalendarArrayForward(XMLGregorianCalendar[] xgcals);
+
+ Duration getNewDurationForward(Duration d);
+ Duration[] getNewDurationArrayForward(Duration[] da);
+
+ Object getNewObjectForward(Object obj);
+ Object[] getNewObjectArrayForward(Object[] objs);
+
+ Image getNewImageForward(Image img);
+ Image[] getNewImageArrayForward(Image[] imgs);
+
+ DataHandler getNewDataHandlerForward(DataHandler dh);
+ DataHandler[] getNewDataHandlerArrayForward(DataHandler[] dha);
+
+ Source getNewSourceForward(Source src);
+ Source[] getNewSourceArrayForward(Source[] srcs);
+
+ UUID getNewUUIDForward(UUID uuid);
+ UUID[] getNewUUIDArrayForward(UUID[] uuids);
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceClientImpl.java
new file mode 100644
index 0000000000..61449c8981
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceClientImpl.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.itest.databindings.jaxb.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of HelloServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ */
+@Service(HelloServiceClient.class)
+public class HelloServiceClientImpl {
+
+ private HelloService service;
+
+ @Reference
+ public void setHelloService(HelloService service) {
+ this.service = service;
+ }
+
+ public String getGreetingsForward(String name) {
+ return service.getGreetings(name);
+ }
+
+ public String[] getGreetingsArrayForward(String[] names) {
+ return service.getGreetingsArray(names);
+ }
+
+ public List<String> getGreetingsListForward(List<String> names) {
+ return service.getGreetingsList(names);
+ }
+
+ public Map<String, String> getGreetingsMapForward(Map<String, String> namesMap) {
+ return service.getGreetingsMap(namesMap);
+ }
+
+ public ArrayList<String> getGreetingsArrayListForward(ArrayList<String> names) {
+ return service.getGreetingsArrayList(names);
+ }
+
+ public HashMap<String, String> getGreetingsHashMapForward(HashMap<String, String> namesMap) {
+ return service.getGreetingsHashMap(namesMap);
+ }
+
+ public String getGreetingsVarArgsForward(String... names) {
+ return service.getGreetingsVarArgs(names[0], names[1], names[2]);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceImpl.java
new file mode 100644
index 0000000000..690001bfe1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/HelloServiceImpl.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloService;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of HelloService.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(HelloService.class)
+public class HelloServiceImpl implements HelloService {
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+
+ public String[] getGreetingsArray(String[] names) {
+ String[] resps = new String[names.length];
+ for (int i = 0; i < names.length; ++i) {
+ resps[i] = "Hello " + names[i];
+ }
+ return resps;
+ }
+
+ public List<String> getGreetingsList(List<String> names) {
+ List<String> resps = new ArrayList<String>();
+ for (int i = 0; i < names.size(); ++i) {
+ resps.add("Hello " + names.get(i));
+ }
+ return resps;
+ }
+
+ public ArrayList<String> getGreetingsArrayList(ArrayList<String> names) {
+ ArrayList<String> resps = new ArrayList<String>();
+ for (int i = 0; i < names.size(); ++i) {
+ resps.add("Hello " + names.get(i));
+ }
+ return resps;
+ }
+
+ public Map<String, String> getGreetingsMap(Map<String, String> namesMap) {
+ for (Map.Entry<String, String> entry : namesMap.entrySet()) {
+ entry.setValue("Hello " + entry.getKey());
+ }
+ return namesMap;
+ }
+
+ public HashMap<String, String> getGreetingsHashMap(HashMap<String, String> namesMap) {
+ for (Map.Entry<String, String> entry : namesMap.entrySet()) {
+ entry.setValue("Hello " + entry.getKey());
+ }
+ return namesMap;
+ }
+
+ public String getGreetingsVarArgs(String... names) {
+ String resp = "Hello";
+ for(int i = 0; i < names.length; ++i) {
+ resp += (" "+names[i]);
+ }
+ return resp;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceClientImpl.java
new file mode 100644
index 0000000000..e55d2527f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceClientImpl.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of PrimitivesServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(PrimitivesServiceClient.class)
+public class PrimitivesServiceClientImpl {
+
+ private PrimitivesService service;
+
+ @Reference
+ public void setPrimitivesService(PrimitivesService service) {
+ this.service = service;
+ }
+ public boolean negateBooleanForward(boolean flag) {
+ return service.negateBoolean(flag);
+ }
+
+ public boolean[] negateBooleanArrayForward(boolean[] flags) {
+ return service.negateBooleanArray(flags);
+ }
+
+ public boolean passByValueBooleanArray() {
+ boolean[] req = new boolean[2];
+ boolean[] resp = service.identityBooleanArray(req);
+ return req != resp;
+ }
+
+ public byte negateByteForward(byte b) {
+ return service.negateByte(b);
+ }
+
+ public byte[] negateByteArrayForward(byte[] ba) {
+ return service.negateByteArray(ba);
+ }
+
+ public boolean passByValueByteArray() {
+ byte[] req = new byte[2];
+ byte[] resp = service.identityByteArray(req);
+ return req != resp;
+ }
+
+ public short negateShortForward(short s) {
+ return service.negateShort(s);
+ }
+
+ public short[] negateShortArrayForward(short[] s) {
+ return service.negateShortArray(s);
+ }
+
+ public boolean passByValueShortArray() {
+ short[] req = new short[2];
+ short[] resp = service.identityShortArray(req);
+ return req != resp;
+ }
+
+ public int negateIntForward(int i) {
+ return service.negateInt(i);
+ }
+
+ public int[] negateIntArrayForward(int[] ia) {
+ return service.negateIntArray(ia);
+ }
+
+ public boolean passByValueIntArray() {
+ int[] req = new int[2];
+ int[] resp = service.identityIntArray(req);
+ return req != resp;
+ }
+
+ public long negateLongForward(long l) {
+ return service.negateLong(l);
+ }
+
+ public long[] negateLongArrayForward(long[] la) {
+ return service.negateLongArray(la);
+ }
+
+ public boolean passByValueLongArray() {
+ long[] req = new long[2];
+ long[] resp = service.identityLongArray(req);
+ return req != resp;
+ }
+
+ public float negateFloatForward(float f) {
+ return service.negateFloat(f);
+ }
+
+ public float[] negateFloatArrayForward(float[] fa) {
+ return service.negateFloatArray(fa);
+ }
+
+ public boolean passByValueFloatArray() {
+ float[] req = new float[2];
+ float[] resp = service.identityFloatArray(req);
+ return req != resp;
+ }
+
+ public double negateDoubleForward(double d) {
+ return service.negateDouble(d);
+ }
+
+ public double[] negateDoubleArrayForward(double[] da) {
+ return service.negateDoubleArray(da);
+ }
+
+ public boolean passByValueDoubleArray() {
+ double[] req = new double[2];
+ double[] resp = service.identityDoubleArray(req);
+ return req != resp;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceImpl.java
new file mode 100644
index 0000000000..60ff4163d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/PrimitivesServiceImpl.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.itest.databindings.jaxb.impl;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of PrimitivesService.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(PrimitivesService.class)
+public class PrimitivesServiceImpl implements PrimitivesService {
+
+ public boolean negateBoolean(boolean flag) {
+ return !flag;
+ }
+
+ public boolean[] negateBooleanArray(boolean[] flags) {
+ boolean[] resp = new boolean[flags.length];
+
+ for(int i = 0; i < flags.length; ++i) {
+ resp[i] = !flags[i];
+ }
+ return resp;
+ }
+
+ public boolean[] identityBooleanArray(boolean[] flags) {
+ return flags;
+ }
+
+ public byte negateByte(byte b) {
+ return (byte)-b;
+ }
+
+ public byte[] negateByteArray(byte[] ba) {
+ byte[] resp = new byte[ba.length];
+
+ for(int i = 0; i < ba.length; ++i) {
+ resp[i] = (byte)-ba[i];
+ }
+ return resp;
+ }
+
+ public byte[] identityByteArray(byte[] ba) {
+ return ba;
+ }
+
+ public short negateShort(short s) {
+ return (short)-s;
+ }
+
+ public short[] negateShortArray(short[] s) {
+ short[] resp = new short[s.length];
+
+ for(int i = 0; i < s.length; ++i) {
+ resp[i] = (short)-s[i];
+ }
+ return resp;
+ }
+
+ public short[] identityShortArray(short[] sa) {
+ return sa;
+ }
+
+ public int negateInt(int i) {
+ return -i;
+ }
+
+ public int[] negateIntArray(int[] ia) {
+ int[] resp = new int[ia.length];
+
+ for(int i = 0; i < ia.length; ++i) {
+ resp[i] = -ia[i];
+ }
+ return resp;
+ }
+
+ public int[] identityIntArray(int[] ia) {
+ return ia;
+ }
+
+ public long negateLong(long l) {
+ return -l;
+ }
+
+ public long[] negateLongArray(long[] la) {
+ long[] resp = new long[la.length];
+
+ for(int i = 0; i < la.length; ++i) {
+ resp[i] = -la[i];
+ }
+ return resp;
+ }
+
+ public long[] identityLongArray(long[] la) {
+ return la;
+ }
+
+ public float negateFloat(float f) {
+ return -f;
+ }
+
+ public float[] negateFloatArray(float[] fa) {
+ float[] resp = new float[fa.length];
+
+ for(int i = 0; i < fa.length; ++i) {
+ resp[i] = -fa[i];
+ }
+ return resp;
+ }
+
+ public float[] identityFloatArray(float[] fa) {
+ return fa;
+ }
+
+ public double negateDouble(double d) {
+ return -d;
+ }
+
+ public double[] negateDoubleArray(double[] da) {
+ double[] resp = new double[da.length];
+
+ for(int i = 0; i < da.length; ++i) {
+ resp[i] = -da[i];
+ }
+ return resp;
+ }
+
+ public double[] identityDoubleArray(double[] da) {
+ return da;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceClientImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceClientImpl.java
new file mode 100644
index 0000000000..b3d3c3eb3a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceClientImpl.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import java.awt.Image;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService;
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesServiceClient;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of StandardTypesServiceClient.
+ * The client forwards the request to the service component and returns the response from the service component.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(StandardTypesServiceClient.class)
+public class StandardTypesServiceClientImpl implements StandardTypesServiceClient{
+
+ private StandardTypesService service;
+
+ @Reference
+ public void setStandardTypesService(StandardTypesService service) {
+ this.service = service;
+ }
+
+ public BigInteger getNewBigIntegerForward(BigInteger bi) {
+ return service.getNewBigInteger(bi);
+ }
+
+ public BigInteger[] getNewBigIntegerArrayForward(BigInteger[] bia) {
+ return service.getNewBigIntegerArray(bia);
+ }
+
+ public BigDecimal getNewBigDecimalForward(BigDecimal bd) {
+ return service.getNewBigDecimal(bd);
+ }
+
+ public BigDecimal[] getNewBigDecimalArrayForward(BigDecimal[] bda) {
+ return service.getNewBigDecimalArray(bda);
+ }
+ public Calendar getNewCalendarForward(Calendar c) {
+ return service.getNewCalendar(c);
+ }
+ public Calendar[] getNewCalendarArrayForward(Calendar[] ca) {
+ return service.getNewCalendarArray(ca);
+ }
+
+ public Date getNewDateForward(Date d) {
+ return service.getNewDate(d);
+ }
+
+ public Date[] getNewDateArrayForward(Date[] da) {
+ return service.getNewDateArray(da);
+ }
+
+ public QName getNewQNameForward(QName qname) {
+ return service.getNewQName(qname);
+ }
+
+ public QName[] getNewQNameArrayForward(QName[] qnames) {
+ return service.getNewQNameArray(qnames);
+ }
+
+ public URI getNewURIForward(URI uri) {
+ return service.getNewURI(uri);
+ }
+
+ public URI[] getNewURIArrayForward(URI[] uris) {
+ return service.getNewURIArray(uris);
+ }
+
+ public XMLGregorianCalendar getNewXMLGregorianCalendarForward(XMLGregorianCalendar xgcal) {
+ return service.getNewXMLGregorianCalendar(xgcal);
+ }
+
+ public XMLGregorianCalendar[] getNewXMLGregorianCalendarArrayForward(XMLGregorianCalendar[] xgcals) {
+ return service.getNewXMLGregorianCalendarArray(xgcals);
+ }
+
+ public Duration getNewDurationForward(Duration d) {
+ return service.getNewDuration(d);
+ }
+
+ public Duration[] getNewDurationArrayForward(Duration[] da) {
+ return service.getNewDurationArray(da);
+ }
+
+ public Object getNewObjectForward(Object obj) {
+ return service.getNewObject(obj);
+ }
+
+ public Object[] getNewObjectArrayForward(Object[] objs) {
+ return service.getNewObjectArray(objs);
+ }
+
+ public Image getNewImageForward(Image img) {
+ return service.getNewImage(img);
+ }
+
+ public Image[] getNewImageArrayForward(Image[] imgs) {
+ return service.getNewImageArray(imgs);
+ }
+
+ public DataHandler getNewDataHandlerForward(DataHandler dh) {
+ return service.getNewDataHandler(dh);
+ }
+
+ public DataHandler[] getNewDataHandlerArrayForward(DataHandler[] dha) {
+ return service.getNewDataHandlerArray(dha);
+ }
+
+
+ public Source getNewSourceForward(Source src) {
+ return service.getNewSource(src);
+ }
+
+ public Source[] getNewSourceArrayForward(Source[] srcs) {
+ return service.getNewSourceArray(srcs);
+ }
+
+ public UUID getNewUUIDForward(UUID uuid) {
+ return service.getNewUUID(uuid);
+ }
+
+ public UUID[] getNewUUIDArrayForward(UUID[] uuids) {
+ return service.getNewUUIDArray(uuids);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.java
new file mode 100644
index 0000000000..1fa525a0ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.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.sca.itest.databindings.jaxb.impl;
+
+import java.awt.Image;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of StandardTypesService.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(StandardTypesService.class)
+public class StandardTypesServiceImpl implements StandardTypesService {
+ public BigInteger getNewBigInteger(BigInteger bi) {
+ return bi.negate();
+ }
+
+ public BigInteger[] getNewBigIntegerArray(BigInteger[] bia) {
+ BigInteger[] resp = new BigInteger[bia.length];
+ for(int i = 0; i < bia.length; ++i) {
+ resp[i] = bia[i].negate();
+ }
+ return resp;
+ }
+
+ public BigDecimal getNewBigDecimal(BigDecimal bd) {
+ return bd.negate();
+ }
+
+ public BigDecimal[] getNewBigDecimalArray(BigDecimal[] bda) {
+ BigDecimal[] resp = new BigDecimal[bda.length];
+ for(int i = 0; i < bda.length; ++i) {
+ resp[i] = bda[i].negate();
+ }
+ return resp;
+ }
+
+ public Calendar getNewCalendar(Calendar c) {
+ Calendar resp = (Calendar)c.clone();
+ resp.add(Calendar.DAY_OF_MONTH, 5);
+ return resp;
+ }
+
+ public Calendar[] getNewCalendarArray(Calendar[] ca) {
+ Calendar[] resp = new Calendar[ca.length];
+ for(int i = 0; i < ca.length; ++i) {
+ resp[i] = getNewCalendar(ca[i]);
+ }
+ return resp;
+ }
+
+ public Date getNewDate(Date d) {
+ return new Date(d.getTime() + 5*24*60*60*1000);
+ }
+
+ public Date[] getNewDateArray(Date[] da) {
+ Date[] resp = new Date[da.length];
+ for(int i = 0; i < da.length; ++i) {
+ resp[i] = getNewDate(da[i]);
+ }
+ return resp;
+ }
+
+ public QName getNewQName(QName qname) {
+ return new QName(qname.getNamespaceURI()+"q", qname.getLocalPart()+"q", qname.getPrefix()+"q");
+
+ }
+
+ public QName[] getNewQNameArray(QName[] qnames) {
+ QName[] resp = new QName[qnames.length];
+ for(int i = 0; i < qnames.length; ++i) {
+ resp[i] = getNewQName(qnames[i]);
+ }
+ return resp;
+ }
+
+ public URI getNewURI(URI uri) {
+ return uri.resolve("uri");
+ }
+
+ public URI[] getNewURIArray(URI[] uris) {
+ URI[] resp = new URI[uris.length];
+ for(int i = 0; i < uris.length; ++i) {
+ resp[i] = getNewURI(uris[i]);
+ }
+ return resp;
+ }
+
+ public XMLGregorianCalendar getNewXMLGregorianCalendar(XMLGregorianCalendar xgcal) {
+ xgcal = (XMLGregorianCalendar)xgcal.clone();
+ xgcal.setDay(xgcal.getDay()+5);
+ return xgcal;
+ }
+
+ public XMLGregorianCalendar[] getNewXMLGregorianCalendarArray(XMLGregorianCalendar[] xgcals) {
+ XMLGregorianCalendar[] resp = new XMLGregorianCalendar[xgcals.length];
+ for(int i = 0; i < xgcals.length; ++i) {
+ resp[i] = getNewXMLGregorianCalendar(xgcals[i]);
+ }
+ return resp;
+ }
+
+ public Duration getNewDuration(Duration d) {
+ return d.negate();
+ }
+
+ public Duration[] getNewDurationArray(Duration[] da) {
+ Duration[] resp = new Duration[da.length];
+ for(int i = 0; i < da.length; ++i) {
+ resp[i] = da[i].negate();
+ }
+ return resp;
+ }
+
+ public Object getNewObject(Object obj) {
+ return StandardTypesTransformer.getNewObject(obj);
+ }
+
+ public Object[] getNewObjectArray(Object[] objs) {
+ Object[] resp = new Object[objs.length];
+ for(int i = 0; i < objs.length; ++i) {
+ resp[i] = getNewObject(objs[i]);
+ }
+ return resp;
+ }
+
+ public Image getNewImage(Image img) {
+ return StandardTypesTransformer.getNewImage(img);
+ }
+
+ public Image[] getNewImageArray(Image[] imgs) {
+ Image[] resp = new Image[imgs.length];
+ for(int i = 0; i < imgs.length; ++i) {
+ resp[i] = getNewImage(imgs[i]);
+ }
+ return resp;
+ }
+
+ public DataHandler getNewDataHandler(DataHandler dh) {
+ // FIXME: transform the input
+ return dh;
+ }
+
+ public DataHandler[] getNewDataHandlerArray(DataHandler[] dha) {
+ DataHandler[] resp = new DataHandler[dha.length];
+ for(int i = 0; i < dha.length; ++i) {
+ resp[i] = dha[i];
+ }
+ return resp;
+ }
+
+ public Source getNewSource(Source src) {
+ return StandardTypesTransformer.getNewSource(src);
+ }
+
+ public Source[] getNewSourceArray(Source[] srcs) {
+ Source[] resp = new Source[srcs.length];
+ for(int i = 0; i < srcs.length; ++i) {
+ resp[i] = getNewSource(srcs[i]);
+ }
+ return resp;
+ }
+
+ public UUID getNewUUID(UUID uuid) {
+ return UUID.fromString(uuid.toString()+"AAA");
+ }
+
+ public UUID[] getNewUUIDArray(UUID[] uuids) {
+ UUID[] resp = new UUID[uuids.length];
+ for(int i = 0; i < uuids.length; ++i) {
+ resp[i] = getNewUUID(uuids[i]);
+ }
+ return resp;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesTransformer.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesTransformer.java
new file mode 100644
index 0000000000..9d851455da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesTransformer.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.impl;
+
+import java.awt.Image;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+
+import org.xml.sax.InputSource;
+
+/**
+ * StandardTypesTransformer class that provide for transforming input provided to StandardTypesService methods.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StandardTypesTransformer {
+
+ public static Object getNewObject(Object obj) {
+ if(obj instanceof String) {
+ return "Hello "+obj;
+ } else if(obj instanceof Integer) {
+ return new Integer(-((Integer)obj).intValue());
+ } else if(obj instanceof Double) {
+ return new Double(-((Double)obj).doubleValue());
+ }
+
+ return obj;
+ }
+
+ /**
+ * Returns a copy of the source object if the input is DOMSource, SAXSource or StreamSource.
+ * Returns the input object as is for other types.
+ */
+ public static Source getNewSource(Source src) {
+ Source ret = null;
+ if(src instanceof DOMSource) {
+ DOMSource dsrc = (DOMSource)src;
+ ret = new DOMSource(dsrc.getNode() != null ? dsrc.getNode().cloneNode(true) : null);
+ } else if(src instanceof SAXSource) {
+ SAXSource ssrc = (SAXSource)src;
+ if(ssrc.getInputSource().getByteStream() != null) {
+ InputStream inp = ssrc.getInputSource().getByteStream();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ int b;
+ try {
+ while((b = inp.read()) != -1) {
+ bout.write(b);
+ }
+ } catch (IOException ignored) {
+ }
+ try { bout.close();} catch (IOException ignored) {}
+ try { inp.reset();} catch (IOException ignored) {}
+ ret = new SAXSource(new InputSource(new ByteArrayInputStream(bout.toByteArray())));
+ } else if(ssrc.getInputSource().getCharacterStream() != null) {
+ Reader rdr = ssrc.getInputSource().getCharacterStream();
+ CharArrayWriter caw = new CharArrayWriter();
+ try {
+ int c;
+ while((c = rdr.read()) != -1) {
+ caw.append((char)c);
+ }
+ } catch (IOException ignored) {
+ }
+ caw.close();
+ try{ rdr.reset();} catch(IOException ignored) {}
+ ret = new SAXSource(new InputSource(new CharArrayReader(caw.toCharArray())));
+ } else {
+ ret = new SAXSource();
+ }
+ } else if(src instanceof StreamSource) {
+ StreamSource ssrc = (StreamSource)src;
+ if(ssrc.getInputStream() != null) {
+ InputStream inp = ssrc.getInputStream();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ int b;
+ try {
+ while((b = inp.read()) != -1) {
+ bout.write(b);
+ }
+ } catch (IOException ignored) {
+ }
+ try { bout.close();} catch (IOException ignored) {}
+ try { inp.reset();} catch (IOException ignored) {}
+ ret = new StreamSource(new ByteArrayInputStream(bout.toByteArray()));
+ } else if(ssrc.getReader() != null) {
+ Reader rdr = ssrc.getReader();
+ CharArrayWriter caw = new CharArrayWriter();
+ try {
+ int c;
+ while((c = rdr.read()) != -1) {
+ caw.append((char)c);
+ }
+ } catch (IOException ignored) {
+ }
+ caw.close();
+ try{ rdr.reset();} catch(IOException ignored) {}
+ ret = new StreamSource(new CharArrayReader(caw.toCharArray()));
+ } else {
+ ret = new StreamSource();
+ }
+ }
+
+ if(ret != null) {
+ ret.setSystemId(src.getSystemId());
+ } else {
+ ret = src;
+ }
+ return ret;
+ }
+
+ public static Image getNewImage(Image arg) {
+ arg.getGraphics().drawOval(2, 2, 7, 7);
+ return arg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/hello-service.wsdl b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/hello-service.wsdl
new file mode 100644
index 0000000000..a76e5c5802
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/hello-service.wsdl
@@ -0,0 +1,372 @@
+<?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.
+-->
+
+<!-- $Rev: 678733 $ $Date: 2008-07-22 17:48:58 +0530 (Tue, 22 Jul 2008) $ -->
+
+<wsdl:definitions name="HelloService"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:tns="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <!-- <xs:schema targetNamespace="http://util.java/" -->
+ <xs:schema targetNamespace=""
+ version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="arrayList">
+ <xs:complexContent>
+ <xs:extension base="abstractList">
+ <xs:sequence />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType abstract="true" name="abstractList">
+ <xs:complexContent>
+ <xs:extension base="abstractCollection">
+ <xs:sequence />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType abstract="true" name="abstractCollection">
+ <xs:sequence />
+ </xs:complexType>
+ <xs:complexType name="hashMap">
+ <xs:complexContent>
+ <xs:extension base="abstractMap">
+ <xs:sequence />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:complexType abstract="true" name="abstractMap">
+ <xs:sequence />
+ </xs:complexType>
+ </xs:schema>
+ <xs:schema targetNamespace="http://jaxb.dev.java.net/array"
+ version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType final="#all" name="stringArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:ns0="http://util.java/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsList">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsListResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsArrayList">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="ns0:arrayList" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsArrayListResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="ns0:arrayList" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsMap">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsMapResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsHashMap">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="ns0:hashMap" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsHashMapResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="ns0:hashMap" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsVarArgs">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getGreetingsVarArgsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="getGreetings">
+ <wsdl:part name="getGreetings" element="tns:getGreetings">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part name="getGreetingsResponse"
+ element="tns:getGreetingsResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsArray">
+ <wsdl:part name="getGreetingsArray"
+ element="tns:getGreetingsArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsArrayResponse">
+ <wsdl:part name="getGreetingsArrayResponse"
+ element="tns:getGreetingsArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsList">
+ <wsdl:part name="getGreetingsList"
+ element="tns:getGreetingsList">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsListResponse">
+ <wsdl:part name="getGreetingsListResponse"
+ element="tns:getGreetingsListResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsArrayList">
+ <wsdl:part name="getGreetingsArrayList"
+ element="tns:getGreetingsArrayList">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsArrayListResponse">
+ <wsdl:part name="getGreetingsArrayListResponse"
+ element="tns:getGreetingsArrayListResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsMap">
+ <wsdl:part name="getGreetingsMap"
+ element="tns:getGreetingsMap">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsMapResponse">
+ <wsdl:part name="getGreetingsMapResponse"
+ element="tns:getGreetingsMapResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsHashMap">
+ <wsdl:part name="getGreetingsHashMap"
+ element="tns:getGreetingsHashMap">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsHashMapResponse">
+ <wsdl:part name="getGreetingsHashMapResponse"
+ element="tns:getGreetingsHashMapResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsVarArgs">
+ <wsdl:part name="getGreetingsVarArgs"
+ element="tns:getGreetingsVarArgs">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getGreetingsVarArgsResponse">
+ <wsdl:part name="getGreetingsVarArgsResponse"
+ element="tns:getGreetingsVarArgsResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="HelloService">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetings"></wsdl:input>
+ <wsdl:output message="tns:getGreetingsResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsArray">
+ <wsdl:input message="tns:getGreetingsArray"></wsdl:input>
+ <wsdl:output message="tns:getGreetingsArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsList">
+ <wsdl:input message="tns:getGreetingsList"></wsdl:input>
+ <wsdl:output message="tns:getGreetingsListResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsArrayList">
+ <wsdl:input message="tns:getGreetingsArrayList">
+ </wsdl:input>
+ <wsdl:output message="tns:getGreetingsArrayListResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsMap">
+ <wsdl:input message="tns:getGreetingsMap">
+ </wsdl:input>
+ <wsdl:output message="tns:getGreetingsMapResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsHashMap">
+ <wsdl:input message="tns:getGreetingsHashMap"></wsdl:input>
+ <wsdl:output message="tns:getGreetingsHashMapResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsVarArgs">
+ <wsdl:input message="tns:getGreetingsVarArgs">
+ </wsdl:input>
+ <wsdl:output message="tns:getGreetingsVarArgsResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="HelloServiceBinding" type="tns:HelloService">
+ <soap11:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getGreetings">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsList">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsArrayList">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsMap">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsHashMap">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsVarArgs">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="HelloServiceService">
+ <wsdl:port name="HelloServicePort"
+ binding="tns:HelloServiceBinding">
+ <soap11:address location="http://localhost:8085/hs-ep" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/helloservice.composite b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/helloservice.composite
new file mode 100644
index 0000000000..f62689c8b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/helloservice.composite
@@ -0,0 +1,80 @@
+<?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.
+-->
+
+<!-- $Rev: 741544 $ $Date: 2009-02-06 17:16:22 +0530 (Fri, 06 Feb 2009) $ -->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ name="HelloService">
+
+ <!-- Clients to test the service -->
+ <!-- A HelloServiceClient component that uses WS binding to invoke HelloService service.
+ The service component uses interface.wsdl on the service element.
+ This client component uses interface.wsdl on the reference element. -->
+ <component name="HelloServiceClientW2WComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloServiceClientImpl" />
+ <reference name="helloService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(HelloService)"/>
+ <binding.ws uri="http://localhost:8085/hs-ep-w"/>
+ </reference>
+ </component>
+
+ <!-- A HelloServiceClient component that uses WS binding to invoke HelloService service.
+ The service component uses interface.wsdl on the service element.
+ This client component uses interface.java on the reference element. -->
+ <component name="HelloServiceClientJ2WComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloServiceClientImpl" />
+ <reference name="helloService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.HelloService"/>
+ <binding.ws uri="http://localhost:8085/hs-ep-w"/>
+ </reference>
+ </component>
+
+ <!-- A HelloServiceClient component that uses WS binding to invoke HelloService service.
+ The service component uses interface.wsdl on the service element.
+ This client component uses interface.java on the reference element. -->
+ <component name="HelloServiceClientW2JComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloServiceClientImpl" />
+ <reference name="helloService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(HelloService)"/>
+ <binding.ws uri="http://localhost:8085/hs-ep-j"/>
+ </reference>
+ </component>
+
+ <!-- Components used to implement the services -->
+ <!-- A HelloService component that uses interface.wsdl -->
+ <component name="HelloServiceWSDLComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloServiceImpl"/>
+ <service name="HelloService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(HelloService)"/>
+ <binding.ws uri="http://localhost:8085/hs-ep-w"/>
+ </service>
+ </component>
+
+ <!-- A HelloService component that uses interface.java -->
+ <component name="HelloServiceJavaComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.HelloServiceImpl"/>
+ <service name="HelloService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.HelloService"/>
+ <binding.ws uri="http://localhost:8085/hs-ep-j"/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/primitives-service.wsdl b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/primitives-service.wsdl
new file mode 100644
index 0000000000..432c3115bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/primitives-service.wsdl
@@ -0,0 +1,927 @@
+<?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.
+-->
+
+<!-- $Rev: 673594 $ $Date: 2008-07-03 11:20:39 +0530 (Thu, 03 Jul 2008) $ -->
+
+<wsdl:definitions name="PrimitivesService"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:tns="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <xs:schema targetNamespace="http://jaxb.dev.java.net/array"
+ version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType final="#all" name="shortArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:short" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="intArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="floatArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:float" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="doubleArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="longArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:long" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="booleanArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="negateLongArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:long" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityByteArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateDoubleArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityFloatArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:float" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateLong">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ type="xs:long" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityIntArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateIntResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateLongArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:long" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateInt">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateFloatArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:float" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityDoubleArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateDouble">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityByteArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateByte">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ type="xs:byte" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityLongArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:long" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateDoubleResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityFloatArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:float" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateFloat">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ type="xs:float" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateShortArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:short" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateByteArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateLongResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ type="xs:long" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateShortArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:short" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateFloatArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:float" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateBoolean">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateShort">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ type="xs:short" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateByteArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityBooleanArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityShortArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:short" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateBooleanResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateFloatResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ type="xs:float" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityBooleanArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateBooleanArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateDoubleArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityDoubleArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateIntArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityIntArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateByteResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ type="xs:byte" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateBooleanArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:boolean" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateShortResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ type="xs:short" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="negateIntArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:int" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityShortArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:short" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="identityLongArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:long" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="negateLongArrayResponse">
+ <wsdl:part name="negateLongArrayResponse"
+ element="tns:negateLongArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityByteArrayResponse">
+ <wsdl:part name="identityByteArrayResponse"
+ element="tns:identityByteArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateDoubleArray">
+ <wsdl:part name="negateDoubleArray"
+ element="tns:negateDoubleArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityFloatArray">
+ <wsdl:part name="identityFloatArray"
+ element="tns:identityFloatArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateLong">
+ <wsdl:part name="negateLong" element="tns:negateLong">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityIntArray">
+ <wsdl:part name="identityIntArray"
+ element="tns:identityIntArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateIntResponse">
+ <wsdl:part name="negateIntResponse"
+ element="tns:negateIntResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateLongArray">
+ <wsdl:part name="negateLongArray"
+ element="tns:negateLongArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateInt">
+ <wsdl:part name="negateInt" element="tns:negateInt"></wsdl:part>
+ </wsdl:message>
+
+ <wsdl:message name="negateFloatArrayResponse">
+ <wsdl:part name="negateFloatArrayResponse"
+ element="tns:negateFloatArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityDoubleArrayResponse">
+ <wsdl:part name="identityDoubleArrayResponse"
+ element="tns:identityDoubleArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateDouble">
+ <wsdl:part name="negateDouble" element="tns:negateDouble">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityByteArray">
+ <wsdl:part name="identityByteArray"
+ element="tns:identityByteArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateByte">
+ <wsdl:part name="negateByte" element="tns:negateByte">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityLongArrayResponse">
+ <wsdl:part name="identityLongArrayResponse"
+ element="tns:identityLongArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateDoubleResponse">
+ <wsdl:part name="negateDoubleResponse"
+ element="tns:negateDoubleResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityFloatArrayResponse">
+ <wsdl:part name="identityFloatArrayResponse"
+ element="tns:identityFloatArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateFloat">
+ <wsdl:part name="negateFloat" element="tns:negateFloat">
+ </wsdl:part>
+ </wsdl:message>
+
+ <wsdl:message name="negateShortArrayResponse">
+ <wsdl:part name="negateShortArrayResponse"
+ element="tns:negateShortArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateByteArrayResponse">
+ <wsdl:part name="negateByteArrayResponse"
+ element="tns:negateByteArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateLongResponse">
+ <wsdl:part name="negateLongResponse"
+ element="tns:negateLongResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateShortArray">
+ <wsdl:part name="negateShortArray"
+ element="tns:negateShortArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateFloatArray">
+ <wsdl:part name="negateFloatArray"
+ element="tns:negateFloatArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateBoolean">
+ <wsdl:part name="negateBoolean" element="tns:negateBoolean">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateShort">
+ <wsdl:part name="negateShort" element="tns:negateShort">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateByteArray">
+ <wsdl:part name="negateByteArray"
+ element="tns:negateByteArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityBooleanArray">
+ <wsdl:part name="identityBooleanArray"
+ element="tns:identityBooleanArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityShortArrayResponse">
+ <wsdl:part name="identityShortArrayResponse"
+ element="tns:identityShortArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateBooleanResponse">
+ <wsdl:part name="negateBooleanResponse"
+ element="tns:negateBooleanResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateFloatResponse">
+ <wsdl:part name="negateFloatResponse"
+ element="tns:negateFloatResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityBooleanArrayResponse">
+ <wsdl:part name="identityBooleanArrayResponse"
+ element="tns:identityBooleanArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateBooleanArray">
+ <wsdl:part name="negateBooleanArray"
+ element="tns:negateBooleanArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateDoubleArrayResponse">
+ <wsdl:part name="negateDoubleArrayResponse"
+ element="tns:negateDoubleArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityDoubleArray">
+ <wsdl:part name="identityDoubleArray"
+ element="tns:identityDoubleArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateIntArrayResponse">
+ <wsdl:part name="negateIntArrayResponse"
+ element="tns:negateIntArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityIntArrayResponse">
+ <wsdl:part name="identityIntArrayResponse"
+ element="tns:identityIntArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateByteResponse">
+ <wsdl:part name="negateByteResponse"
+ element="tns:negateByteResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateBooleanArrayResponse">
+ <wsdl:part name="negateBooleanArrayResponse"
+ element="tns:negateBooleanArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateShortResponse">
+ <wsdl:part name="negateShortResponse"
+ element="tns:negateShortResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="negateIntArray">
+ <wsdl:part name="negateIntArray" element="tns:negateIntArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityShortArray">
+ <wsdl:part name="identityShortArray"
+ element="tns:identityShortArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="identityLongArray">
+ <wsdl:part name="identityLongArray"
+ element="tns:identityLongArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="PrimitivesService">
+ <wsdl:operation name="negateBoolean">
+ <wsdl:input message="tns:negateBoolean">
+ </wsdl:input>
+ <wsdl:output message="tns:negateBooleanResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateBooleanArray">
+ <wsdl:input message="tns:negateBooleanArray"></wsdl:input>
+ <wsdl:output message="tns:negateBooleanArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityBooleanArray">
+ <wsdl:input message="tns:identityBooleanArray"></wsdl:input>
+ <wsdl:output message="tns:identityBooleanArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateByte">
+ <wsdl:input message="tns:negateByte">
+ </wsdl:input>
+ <wsdl:output message="tns:negateByteResponse"></wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateByteArray">
+ <wsdl:input message="tns:negateByteArray"></wsdl:input>
+ <wsdl:output message="tns:negateByteArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityByteArray">
+ <wsdl:input message="tns:identityByteArray"></wsdl:input>
+ <wsdl:output message="tns:identityByteArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateShort">
+ <wsdl:input message="tns:negateShort">
+ </wsdl:input>
+ <wsdl:output message="tns:negateShortResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateShortArray">
+ <wsdl:input message="tns:negateShortArray"></wsdl:input>
+ <wsdl:output message="tns:negateShortArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityShortArray">
+ <wsdl:input message="tns:identityShortArray"></wsdl:input>
+ <wsdl:output message="tns:identityShortArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateInt">
+ <wsdl:input message="tns:negateInt">
+ </wsdl:input>
+ <wsdl:output message="tns:negateIntResponse"></wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateIntArray">
+ <wsdl:input message="tns:negateIntArray"></wsdl:input>
+ <wsdl:output message="tns:negateIntArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityIntArray">
+ <wsdl:input message="tns:identityIntArray"></wsdl:input>
+ <wsdl:output message="tns:identityIntArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateLong">
+ <wsdl:input message="tns:negateLong">
+ </wsdl:input>
+ <wsdl:output message="tns:negateLongResponse"></wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateLongArray">
+ <wsdl:input message="tns:negateLongArray"></wsdl:input>
+ <wsdl:output message="tns:negateLongArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityLongArray">
+ <wsdl:input message="tns:identityLongArray"></wsdl:input>
+ <wsdl:output message="tns:identityLongArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateFloat">
+ <wsdl:input message="tns:negateFloat">
+ </wsdl:input>
+ <wsdl:output message="tns:negateFloatResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateFloatArray">
+ <wsdl:input message="tns:negateFloatArray"></wsdl:input>
+ <wsdl:output message="tns:negateFloatArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityFloatArray">
+ <wsdl:input message="tns:identityFloatArray"></wsdl:input>
+ <wsdl:output message="tns:identityFloatArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateDouble">
+ <wsdl:input message="tns:negateDouble">
+ </wsdl:input>
+ <wsdl:output message="tns:negateDoubleResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateDoubleArray">
+ <wsdl:input message="tns:negateDoubleArray"></wsdl:input>
+ <wsdl:output message="tns:negateDoubleArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityDoubleArray">
+ <wsdl:input message="tns:identityDoubleArray"></wsdl:input>
+ <wsdl:output message="tns:identityDoubleArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="PrimitivesServiceBinding"
+ type="tns:PrimitivesService">
+ <soap11:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="negateBoolean">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateBooleanArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityBooleanArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateByte">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateByteArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityByteArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateShort">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateShortArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityShortArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateInt">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateIntArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityIntArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateLong">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateLongArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityLongArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateFloat">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateFloatArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityFloatArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateDouble">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="negateDoubleArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="identityDoubleArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="PrimitivesServiceService">
+ <wsdl:port name="PrimitivesServicePort"
+ binding="tns:PrimitivesServiceBinding">
+ <soap11:address location="http://localhost:8085/ps-ep" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/primitivesservice.composite b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/primitivesservice.composite
new file mode 100644
index 0000000000..9b08c334cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/primitivesservice.composite
@@ -0,0 +1,80 @@
+<?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.
+-->
+
+<!-- $Rev: 741544 $ $Date: 2009-02-06 17:16:22 +0530 (Fri, 06 Feb 2009) $ -->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="PrimitivesService">
+
+ <!-- Clients to test the service -->
+ <!-- A PrimitivesServiceClient component that uses WS binding to invoke PrimitivesService.
+ The service component uses interface.wsdl on the service element.
+ This client component uses interface.wsdl on the reference element. -->
+ <component name="PrimitivesServiceClientW2WComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesServiceClientImpl" />
+ <reference name="primitivesService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(PrimitivesService)"/>
+ <binding.ws uri="http://localhost:8085/ps-ep-w"/>
+ </reference>
+ </component>
+
+ <!-- A PrimitivesServiceClient component that uses WS binding to invoke PrimitivesService.
+ The service component uses interface.wsdl on the service element.
+ This client component uses interface.java on the reference element. -->
+ <component name="PrimitivesServiceClientJ2WComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesServiceClientImpl" />
+ <reference name="primitivesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService"/>
+ <binding.ws uri="http://localhost:8085/ps-ep-w"/>
+ </reference>
+ </component>
+
+ <!-- A PrimitivesServiceClient component that uses WS binding to invoke PrimitivesService.
+ The service component uses interface.java on the service element.
+ This client component uses interface.wsdl on the reference element. -->
+ <component name="PrimitivesServiceClientW2JComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesServiceClientImpl" />
+ <reference name="primitivesService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(PrimitivesService)"/>
+ <binding.ws uri="http://localhost:8085/ps-ep-j"/>
+ </reference>
+ </component>
+
+ <!-- Components used to implement the services -->
+ <!-- A PrimitivesService component that uses interface.java -->
+ <component name="PrimitivesServiceJavaComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesServiceImpl"/>
+ <service name="PrimitivesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesService"/>
+ <binding.ws uri="http://localhost:8085/ps-ep-j"/>
+ </service>
+ </component>
+
+ <!-- A PrimitivesService component that uses interface.wsdl -->
+ <component name="PrimitivesServiceWSDLComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.PrimitivesServiceImpl"/>
+ <service name="PrimitivesService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(PrimitivesService)"/>
+ <binding.ws uri="http://localhost:8085/ps-ep-w"/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/standard-types-service.composite b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/standard-types-service.composite
new file mode 100644
index 0000000000..f9ac98d5bc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/standard-types-service.composite
@@ -0,0 +1,80 @@
+<?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.
+-->
+
+<!-- $Rev: 741544 $ $Date: 2009-02-06 17:16:22 +0530 (Fri, 06 Feb 2009) $ -->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="StandardTypesService">
+
+ <!-- Clients to test the service -->
+ <!-- A StandardTypesServiceClient component that uses WS binding to invoke StandardTypesService.
+ The service component uses interface.wsdl on the service element.
+ This client component uses interface.wsdl on the reference element. -->
+ <component name="StandardTypesServiceClientW2WComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesServiceClientImpl" />
+ <reference name="standardTypesService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(StandardTypesService)"/>
+ <binding.ws uri="http://localhost:8085/sts-ep-w"/>
+ </reference>
+ </component>
+
+ <!-- A StandardTypesServiceClient component that uses WS binding to invoke StandardTypesService.
+ The service component uses interface.wsdl on the service element.
+ This client component uses interface.java on the reference element. -->
+ <component name="StandardTypesServiceClientJ2WComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesServiceClientImpl" />
+ <reference name="standardTypesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService"/>
+ <binding.ws uri="http://localhost:8085/sts-ep-w"/>
+ </reference>
+ </component>
+
+ <!-- A StandardTypesServiceClient component that uses WS binding to invoke StandardTypesService.
+ The service component uses interface.java on the service element.
+ This client component uses interface.wsdl on the reference element. -->
+ <component name="StandardTypesServiceClientW2JComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesServiceClientImpl" />
+ <reference name="standardTypesService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(StandardTypesService)"/>
+ <binding.ws uri="http://localhost:8085/sts-ep-j"/>
+ </reference>
+ </component>
+
+ <!-- Components used to implement the services -->
+ <!-- A StandardTypesService component. -->
+ <component name="StandardTypesServiceJavaComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesServiceImpl"/>
+ <service name="StandardTypesService">
+ <interface.java interface="org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService"/>
+ <binding.ws uri="http://localhost:8085/sts-ep-j"/>
+ </service>
+ </component>
+
+ <!-- A StandardTypesService component. -->
+ <component name="StandardTypesServiceWSDLComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesServiceImpl"/>
+ <service name="StandardTypesService">
+ <interface.wsdl interface="http://jaxb.databindings.itest.sca.tuscany.apache.org/#wsdl.interface(StandardTypesService)"/>
+ <binding.ws uri="http://localhost:8085/sts-ep-w"/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/standard-types-service.wsdl b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/standard-types-service.wsdl
new file mode 100644
index 0000000000..219497e2c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/main/resources/wsdl/wrapped/standard-types-service.wsdl
@@ -0,0 +1,1155 @@
+<?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.
+-->
+
+<!-- $Rev: 673585 $ $Date: 2008-07-03 10:42:18 +0530 (Thu, 03 Jul 2008) $ -->
+
+<wsdl:definitions name="StandardTypesService"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:tns="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <xs:schema targetNamespace="http://jaxb.dev.java.net/array"
+ version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType final="#all" name="anyTypeArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="base64BinaryArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ <xs:schema targetNamespace="http://jaxb.dev.java.net/array"
+ version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType final="#all" name="dateTimeArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="durationArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:duration" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="integerArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:integer" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="anySimpleTypeArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:anySimpleType" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="QNameArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:QName" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="decimalArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:decimal" />
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType final="#all" name="base64BinaryArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType final="#all" name="stringArray">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="item" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
+ xmlns:ns0="http://activation.javax/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="getNewBigDecimalArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:decimal" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewImageArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewBigDecimal">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:decimal" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewURIArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewObjectArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDataHandler">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDateResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewBigInteger">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:integer" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDateArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewBigIntegerArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:integer" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewQNameArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:QName" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewURIResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewUUIDArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewCalendarArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewXMLGregorianCalendarArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:anySimpleType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewCalendarResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewCalendar">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewCalendarArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewImageArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewObjectResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDurationArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:duration" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element
+ name="getNewXMLGregorianCalendarArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:anySimpleType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewSource">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewObjectArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewUUIDResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewBigIntegerResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:integer" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewQNameArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:QName" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewUUIDArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewBigDecimalResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:decimal" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDateArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewURIArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDurationArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:duration" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewObject">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDataHandlerResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewQName">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:QName" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDate">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:dateTime" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewUUID">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewXMLGregorianCalendarResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:anySimpleType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewBigIntegerArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:integer" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewSourceArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewImage">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewSourceArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewXMLGregorianCalendar">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:anySimpleType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewQNameResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:QName" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDataHandlerArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewBigDecimalArrayResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="return" nillable="true" type="xs:decimal" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDuration">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:duration" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDataHandlerArray">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0"
+ name="arg0" nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewImageResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewSourceResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:base64Binary" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewDurationResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:duration" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNewURI">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="getNewBigDecimalArray">
+ <wsdl:part name="getNewBigDecimalArray"
+ element="tns:getNewBigDecimalArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewImageArrayResponse">
+
+ <wsdl:part name="getNewImageArrayResponse"
+ element="tns:getNewImageArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewBigDecimal">
+ <wsdl:part name="getNewBigDecimal"
+ element="tns:getNewBigDecimal">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewURIArray">
+ <wsdl:part name="getNewURIArray" element="tns:getNewURIArray">
+
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewObjectArray">
+ <wsdl:part name="getNewObjectArray"
+ element="tns:getNewObjectArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDataHandler">
+ <wsdl:part name="getNewDataHandler"
+ element="tns:getNewDataHandler">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDateResponse">
+ <wsdl:part name="getNewDateResponse"
+ element="tns:getNewDateResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewBigInteger">
+ <wsdl:part name="getNewBigInteger"
+ element="tns:getNewBigInteger">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDateArrayResponse">
+ <wsdl:part name="getNewDateArrayResponse"
+ element="tns:getNewDateArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewBigIntegerArray">
+ <wsdl:part name="getNewBigIntegerArray"
+ element="tns:getNewBigIntegerArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewQNameArrayResponse">
+ <wsdl:part name="getNewQNameArrayResponse"
+ element="tns:getNewQNameArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewURIResponse">
+ <wsdl:part name="getNewURIResponse"
+ element="tns:getNewURIResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewUUIDArrayResponse">
+ <wsdl:part name="getNewUUIDArrayResponse"
+ element="tns:getNewUUIDArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewCalendarArrayResponse">
+ <wsdl:part name="getNewCalendarArrayResponse"
+ element="tns:getNewCalendarArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewXMLGregorianCalendarArray">
+ <wsdl:part name="getNewXMLGregorianCalendarArray"
+ element="tns:getNewXMLGregorianCalendarArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewCalendarResponse">
+ <wsdl:part name="getNewCalendarResponse"
+ element="tns:getNewCalendarResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewCalendar">
+ <wsdl:part name="getNewCalendar" element="tns:getNewCalendar">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewCalendarArray">
+ <wsdl:part name="getNewCalendarArray"
+ element="tns:getNewCalendarArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewImageArray">
+ <wsdl:part name="getNewImageArray"
+ element="tns:getNewImageArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewObjectResponse">
+ <wsdl:part name="getNewObjectResponse"
+ element="tns:getNewObjectResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDurationArray">
+ <wsdl:part name="getNewDurationArray"
+ element="tns:getNewDurationArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewXMLGregorianCalendarArrayResponse">
+ <wsdl:part name="getNewXMLGregorianCalendarArrayResponse"
+ element="tns:getNewXMLGregorianCalendarArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewSource">
+ <wsdl:part name="getNewSource" element="tns:getNewSource">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewObjectArrayResponse">
+ <wsdl:part name="getNewObjectArrayResponse"
+ element="tns:getNewObjectArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewUUIDResponse">
+ <wsdl:part name="getNewUUIDResponse"
+ element="tns:getNewUUIDResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewBigIntegerResponse">
+ <wsdl:part name="getNewBigIntegerResponse"
+ element="tns:getNewBigIntegerResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewQNameArray">
+ <wsdl:part name="getNewQNameArray"
+ element="tns:getNewQNameArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewUUIDArray">
+ <wsdl:part name="getNewUUIDArray"
+ element="tns:getNewUUIDArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewBigDecimalResponse">
+ <wsdl:part name="getNewBigDecimalResponse"
+ element="tns:getNewBigDecimalResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDateArray">
+ <wsdl:part name="getNewDateArray"
+ element="tns:getNewDateArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewURIArrayResponse">
+ <wsdl:part name="getNewURIArrayResponse"
+ element="tns:getNewURIArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDurationArrayResponse">
+ <wsdl:part name="getNewDurationArrayResponse"
+ element="tns:getNewDurationArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewObject">
+ <wsdl:part name="getNewObject" element="tns:getNewObject">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDataHandlerResponse">
+ <wsdl:part name="getNewDataHandlerResponse"
+ element="tns:getNewDataHandlerResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewQName">
+ <wsdl:part name="getNewQName" element="tns:getNewQName">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDate">
+ <wsdl:part name="getNewDate" element="tns:getNewDate">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewUUID">
+ <wsdl:part name="getNewUUID" element="tns:getNewUUID">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewXMLGregorianCalendarResponse">
+ <wsdl:part name="getNewXMLGregorianCalendarResponse"
+ element="tns:getNewXMLGregorianCalendarResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewBigIntegerArrayResponse">
+ <wsdl:part name="getNewBigIntegerArrayResponse"
+ element="tns:getNewBigIntegerArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewSourceArray">
+ <wsdl:part name="getNewSourceArray"
+ element="tns:getNewSourceArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewImage">
+ <wsdl:part name="getNewImage" element="tns:getNewImage">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewSourceArrayResponse">
+ <wsdl:part name="getNewSourceArrayResponse"
+ element="tns:getNewSourceArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewXMLGregorianCalendar">
+ <wsdl:part name="getNewXMLGregorianCalendar"
+ element="tns:getNewXMLGregorianCalendar">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewQNameResponse">
+ <wsdl:part name="getNewQNameResponse"
+ element="tns:getNewQNameResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDataHandlerArrayResponse">
+ <wsdl:part name="getNewDataHandlerArrayResponse"
+ element="tns:getNewDataHandlerArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewBigDecimalArrayResponse">
+ <wsdl:part name="getNewBigDecimalArrayResponse"
+ element="tns:getNewBigDecimalArrayResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDuration">
+ <wsdl:part name="getNewDuration" element="tns:getNewDuration">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDataHandlerArray">
+ <wsdl:part name="getNewDataHandlerArray"
+ element="tns:getNewDataHandlerArray">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewImageResponse">
+ <wsdl:part name="getNewImageResponse"
+ element="tns:getNewImageResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewSourceResponse">
+ <wsdl:part name="getNewSourceResponse"
+ element="tns:getNewSourceResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewDurationResponse">
+ <wsdl:part name="getNewDurationResponse"
+ element="tns:getNewDurationResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNewURI">
+ <wsdl:part name="getNewURI" element="tns:getNewURI"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="StandardTypesService">
+ <wsdl:operation name="getNewObject">
+ <wsdl:input message="tns:getNewObject"></wsdl:input>
+ <wsdl:output message="tns:getNewObjectResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewImage">
+ <wsdl:input message="tns:getNewImage"></wsdl:input>
+ <wsdl:output message="tns:getNewImageResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewSource">
+ <wsdl:input message="tns:getNewSource"></wsdl:input>
+ <wsdl:output message="tns:getNewSourceResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewBigInteger">
+ <wsdl:input message="tns:getNewBigInteger"></wsdl:input>
+ <wsdl:output message="tns:getNewBigIntegerResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewBigIntegerArray">
+ <wsdl:input message="tns:getNewBigIntegerArray">
+ </wsdl:input>
+ <wsdl:output message="tns:getNewBigIntegerArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewBigDecimal">
+ <wsdl:input message="tns:getNewBigDecimal"></wsdl:input>
+ <wsdl:output message="tns:getNewBigDecimalResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewBigDecimalArray">
+ <wsdl:input message="tns:getNewBigDecimalArray">
+ </wsdl:input>
+ <wsdl:output message="tns:getNewBigDecimalArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewCalendar">
+ <wsdl:input message="tns:getNewCalendar"></wsdl:input>
+ <wsdl:output message="tns:getNewCalendarResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewCalendarArray">
+ <wsdl:input message="tns:getNewCalendarArray"></wsdl:input>
+ <wsdl:output message="tns:getNewCalendarArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDate">
+ <wsdl:input message="tns:getNewDate"></wsdl:input>
+ <wsdl:output message="tns:getNewDateResponse"></wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDateArray">
+ <wsdl:input message="tns:getNewDateArray"></wsdl:input>
+ <wsdl:output message="tns:getNewDateArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewQName">
+ <wsdl:input message="tns:getNewQName"></wsdl:input>
+ <wsdl:output message="tns:getNewQNameResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewQNameArray">
+ <wsdl:input message="tns:getNewQNameArray"></wsdl:input>
+ <wsdl:output message="tns:getNewQNameArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewURI">
+ <wsdl:input message="tns:getNewURI"></wsdl:input>
+ <wsdl:output message="tns:getNewURIResponse"></wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewURIArray">
+ <wsdl:input message="tns:getNewURIArray"></wsdl:input>
+ <wsdl:output message="tns:getNewURIArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewXMLGregorianCalendar">
+ <wsdl:input message="tns:getNewXMLGregorianCalendar">
+ </wsdl:input>
+ <wsdl:output
+ message="tns:getNewXMLGregorianCalendarResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewXMLGregorianCalendarArray">
+ <wsdl:input message="tns:getNewXMLGregorianCalendarArray">
+ </wsdl:input>
+ <wsdl:output
+ message="tns:getNewXMLGregorianCalendarArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDuration">
+ <wsdl:input message="tns:getNewDuration"></wsdl:input>
+ <wsdl:output message="tns:getNewDurationResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDurationArray">
+ <wsdl:input message="tns:getNewDurationArray"></wsdl:input>
+ <wsdl:output message="tns:getNewDurationArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewObjectArray">
+ <wsdl:input message="tns:getNewObjectArray"></wsdl:input>
+ <wsdl:output message="tns:getNewObjectArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewImageArray">
+ <wsdl:input message="tns:getNewImageArray"></wsdl:input>
+ <wsdl:output message="tns:getNewImageArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDataHandler">
+ <wsdl:input message="tns:getNewDataHandler"></wsdl:input>
+ <wsdl:output message="tns:getNewDataHandlerResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDataHandlerArray">
+ <wsdl:input message="tns:getNewDataHandlerArray">
+ </wsdl:input>
+ <wsdl:output message="tns:getNewDataHandlerArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewSourceArray">
+ <wsdl:input message="tns:getNewSourceArray"></wsdl:input>
+ <wsdl:output message="tns:getNewSourceArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewUUID">
+ <wsdl:input message="tns:getNewUUID"></wsdl:input>
+ <wsdl:output message="tns:getNewUUIDResponse"></wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewUUIDArray">
+ <wsdl:input message="tns:getNewUUIDArray"></wsdl:input>
+ <wsdl:output message="tns:getNewUUIDArrayResponse">
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:portType>
+ <wsdl:binding name="StandardTypesServiceBinding"
+ type="tns:StandardTypesService">
+ <soap11:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getNewObject">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewImage">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewSource">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewBigInteger">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewBigIntegerArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewBigDecimal">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewBigDecimalArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewCalendar">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewCalendarArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDate">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDateArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewQName">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewQNameArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewURI">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewURIArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewXMLGregorianCalendar">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewXMLGregorianCalendarArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDuration">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDurationArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewObjectArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewImageArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDataHandler">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewDataHandlerArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewSourceArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewUUID">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNewUUIDArray">
+ <soap11:operation />
+ <wsdl:input>
+ <soap11:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap11:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="StandardTypesServiceService">
+ <wsdl:port name="StandardTypesServicePort"
+ binding="tns:StandardTypesServiceBinding">
+ <soap11:address location="http://localhost:8085/sts-ep"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/DatabindingTestCase.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/DatabindingTestCase.java
new file mode 100644
index 0000000000..3351e9c441
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/DatabindingTestCase.java
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.topdown;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DatabindingTestCase {
+
+ private static Node node;
+
+ /**
+ * Runs once before running the tests
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/wsdl/wrapped/helloservice.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/wsdl/wrapped/").toURI().toURL().toString()));
+ node.start();
+ }catch(Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Runs once after running the tests
+ */
+ @AfterClass
+ public static void tearDown() {
+ node.stop();
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetings.
+ */
+ @Test
+ public void testW2W() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2WComponent");
+ performTest(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsArray.
+ */
+ @Test
+ public void testW2WArray() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2WComponent");
+ performTestArray(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsList.
+ */
+ @Test
+ public void testW2WList() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2WComponent");
+ performTestList(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsArrayList.
+ */
+ @Test
+ public void testW2WArrayList() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2WComponent");
+ performTestArrayList(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsMap.
+ */
+ @Test
+ public void testW2WMap() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2WComponent");
+ performTestMap(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsHashMap.
+ */
+ @Test
+ public void testW2WHashMap() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2WComponent");
+ performTestHashMap(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsVarArgs.
+ */
+ @Test
+ public void testW2WVarArgs() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2WComponent");
+ performTestVarArgs(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetings.
+ */
+ @Test
+ public void testJ2W() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientJ2WComponent");
+ performTest(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsArray.
+ */
+ @Test
+ public void testJ2WArray() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientJ2WComponent");
+ performTestArray(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsList.
+ */
+ @Test
+ public void testJ2WList() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientJ2WComponent");
+ performTestList(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsArrayList.
+ */
+ @Test
+ public void testJ2WArrayList() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientJ2WComponent");
+ performTestArrayList(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsMap.
+ */
+ @Test
+ public void testJ2WMap() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientJ2WComponent");
+ performTestMap(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsHashMap.
+ */
+ @Test
+ public void testJ2WHashMap() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientJ2WComponent");
+ performTestHashMap(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsVarArgs.
+ */
+ @Test
+ public void testJ2WVarArgs() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientJ2WComponent");
+ performTestVarArgs(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetings.
+ */
+ @Test
+ public void testW2J() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2JComponent");
+ performTest(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsArray.
+ */
+ @Test
+ public void testW2JArray() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2JComponent");
+ performTestArray(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsList.
+ */
+ @Test
+ public void testW2JList() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2JComponent");
+ performTestList(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsArrayList.
+ */
+ @Test
+ public void testW2JArrayList() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2JComponent");
+ performTestArrayList(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsMap.
+ */
+ @Test
+ public void testW2JMap() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2JComponent");
+ performTestMap(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsHashMap.
+ */
+ @Test
+ public void testW2JHashMap() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2JComponent");
+ performTestHashMap(helloServiceClient);
+ }
+
+ /**
+ * Invokes the HelloService service using WS binding.
+ * Service method invoked is getGreetingsVarArgs.
+ */
+ @Test
+ public void testW2JVarArgs() throws Exception {
+ HelloServiceClient helloServiceClient = node.getService(HelloServiceClient.class, "HelloServiceClientW2JComponent");
+ performTestVarArgs(helloServiceClient);
+ }
+
+ private void performTest(HelloServiceClient helloServiceClient) {
+ String name = "Pandu";
+ String resp = helloServiceClient.getGreetingsForward(name);
+ Assert.assertEquals("Hello "+name, resp);
+ }
+
+ private void performTestArray(HelloServiceClient helloServiceClient) {
+ String[] names = {"Me", "Pandu"};
+ String[] resps = helloServiceClient.getGreetingsArrayForward(names);
+ for(int i = 0; i < names.length; ++i) {
+ Assert.assertEquals("Hello "+names[i], resps[i]);
+ }
+ }
+
+ private void performTestList(HelloServiceClient helloServiceClient) {
+ List<String> namesList = new ArrayList<String>();
+ namesList.add("Me");
+ namesList.add("Pandu");
+ namesList.add("Chinnipandu");
+ List<String> respList = helloServiceClient.getGreetingsListForward(namesList);
+ Assert.assertEquals(namesList.size(), respList.size());
+ for(int i = 0; i < namesList.size(); ++i) {
+ Assert.assertEquals("Hello "+namesList.get(i), respList.get(i));
+ }
+ }
+
+ private void performTestArrayList(HelloServiceClient helloServiceClient) {
+ ArrayList<String> namesList = new ArrayList<String>();
+ namesList.add("Me");
+ namesList.add("Pandu");
+ namesList.add("Chinnipandu");
+ ArrayList<String> respList = helloServiceClient.getGreetingsArrayListForward(namesList);
+ Assert.assertEquals(namesList.size(), respList.size());
+ for(int i = 0; i < namesList.size(); ++i) {
+ Assert.assertEquals("Hello "+namesList.get(i), respList.get(i));
+ }
+ }
+
+ private void performTestMap(HelloServiceClient helloServiceClient) {
+ Map<String, String> namesMap = new HashMap<String, String>();
+ namesMap.put("Me", null);
+ namesMap.put("Pandu", null);
+ namesMap.put("Chinnipandu", null);
+ Map<String, String> respMap = helloServiceClient.getGreetingsMapForward(namesMap);
+ Assert.assertEquals(namesMap.keySet().size(), respMap.keySet().size());
+ for(Map.Entry<String, String> entry: namesMap.entrySet()) {
+ Assert.assertEquals("Hello "+entry.getKey(), respMap.get(entry.getKey()));
+ }
+ }
+
+ private void performTestHashMap(HelloServiceClient helloServiceClient) {
+ HashMap<String, String> namesMap = new HashMap<String, String>();
+ namesMap.put("Me", null);
+ namesMap.put("Pandu", null);
+ namesMap.put("Chinnipandu", null);
+ Map<String, String> respMap = helloServiceClient.getGreetingsHashMapForward(namesMap);
+ Assert.assertEquals(namesMap.keySet().size(), respMap.keySet().size());
+ for(Map.Entry<String, String> entry: namesMap.entrySet()) {
+ Assert.assertEquals("Hello "+entry.getKey(), respMap.get(entry.getKey()));
+ }
+ }
+
+ private void performTestVarArgs(HelloServiceClient helloServiceClient) {
+ String[] names = { "Me", "You", "Pandu" }; // Do not change the array size from 3.
+ String expected = "Hello Me You Pandu";
+ String actual = helloServiceClient.getGreetingsVarArgsForward(names[0], names[1], names[2]);
+ Assert.assertEquals(expected, actual);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/PrimitivesDatabindingTestCase.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/PrimitivesDatabindingTestCase.java
new file mode 100644
index 0000000000..8430d5e978
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/PrimitivesDatabindingTestCase.java
@@ -0,0 +1,849 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.topdown;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesServiceClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PrimitivesDatabindingTestCase {
+
+ private static Node node;
+
+ /**
+ * Runs before each test method
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/wsdl/wrapped/primitivesservice.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/wsdl/wrapped/").toURI().toURL().toString()));
+ node.start();
+ }
+
+ /**
+ * Runs after each test method
+ */
+ @AfterClass
+ public static void tearDown() {
+ node.stop();
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateBoolean.
+ */
+ @Test
+ public void testW2WNegateBoolean() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateBoolean(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateBooleanArray.
+ */
+ @Test
+ public void testW2WNegateBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateBooleanArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for boolean array.
+ */
+ @Test
+ public void testW2WPassByValueBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueBooleanArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateByte.
+ */
+ @Test
+ public void testW2WNegateByte() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateByte(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateByteArray.
+ */
+ @Test
+ public void testW2WNegateByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateByteArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for byte array.
+ */
+ @Test
+ public void testW2WPassByValueByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueByteArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateShort.
+ */
+ @Test
+ public void testW2WNegateShort() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateShort(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateShortArray.
+ */
+ @Test
+ public void testW2WNegateShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateShortArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for short array.
+ */
+ @Test
+ public void testW2WPassByValueShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueShortArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateInt.
+ */
+ @Test
+ public void testW2WNegateInt() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateInt(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateIntArray.
+ */
+ @Test
+ public void testW2WNegateIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateIntArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for int array.
+ */
+ @Test
+ public void testW2WPassByValueIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueIntArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateLong.
+ */
+ @Test
+ public void testW2WNegateLong() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateLong(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateLongArray.
+ */
+ @Test
+ public void testW2WNegateLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateLongArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for long array.
+ */
+ @Test
+ public void testW2WPassByValueLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueLongArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateFloat.
+ */
+ @Test
+ public void testW2WNegateFloat() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateFloat(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateFloatArray.
+ */
+ @Test
+ public void testW2WNegateFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateFloatArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for float array.
+ */
+ @Test
+ public void testW2WPassByValueFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueFloatArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateDouble.
+ */
+ @Test
+ public void testW2WNegateDouble() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateDouble(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateDoubleArray.
+ */
+ @Test
+ public void testW2WNegateDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ performTestNegateDoubleArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for double array.
+ */
+ @Test
+ public void testW2WPassByValueDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueDoubleArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateBoolean.
+ */
+ @Test
+ public void testJ2WNegateBoolean() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateBoolean(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateBooleanArray.
+ */
+ @Test
+ public void testJ2WNegateBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateBooleanArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for boolean array.
+ */
+ @Test
+ public void testJ2WPassByValueBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueBooleanArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateByte.
+ */
+ @Test
+ public void testJ2WNegateByte() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateByte(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateByteArray.
+ */
+ @Test
+ public void testJ2WNegateByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateByteArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for byte array.
+ */
+ @Test
+ public void testJ2WPassByValueByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueByteArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateShort.
+ */
+ @Test
+ public void testJ2WNegateShort() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateShort(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateShortArray.
+ */
+ @Test
+ public void testJ2WNegateShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateShortArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for short array.
+ */
+ @Test
+ public void testJ2WPassByValueShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueShortArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateInt.
+ */
+ @Test
+ public void testJ2WNegateInt() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateInt(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateIntArray.
+ */
+ @Test
+ public void testJ2WNegateIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateIntArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for int array.
+ */
+ @Test
+ public void testJ2WPassByValueIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueIntArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateLong.
+ */
+ @Test
+ public void testJ2WNegateLong() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateLong(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateLongArray.
+ */
+ @Test
+ public void testJ2WNegateLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateLongArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for long array.
+ */
+ @Test
+ public void testJ2WPassByValueLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueLongArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateFloat.
+ */
+ @Test
+ public void testJ2WNegateFloat() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateFloat(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateFloatArray.
+ */
+ @Test
+ public void testJ2WNegateFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateFloatArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for float array.
+ */
+ @Test
+ public void testJ2WPassByValueFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueFloatArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateDouble.
+ */
+ @Test
+ public void testJ2WNegateDouble() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateDouble(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateDoubleArray.
+ */
+ @Test
+ public void testJ2WNegateDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ performTestNegateDoubleArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for double array.
+ */
+ @Test
+ public void testJ2WPassByValueDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientJ2WComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueDoubleArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateBoolean.
+ */
+ @Test
+ public void testW2JNegateBoolean() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateBoolean(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateBooleanArray.
+ */
+ @Test
+ public void testW2JNegateBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateBooleanArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for boolean array.
+ */
+ @Test
+ public void testW2JPassByValueBooleanArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueBooleanArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateByte.
+ */
+ @Test
+ public void testW2JNegateByte() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateByte(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateByteArray.
+ */
+ @Test
+ public void testW2JNegateByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateByteArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for byte array.
+ */
+ @Test
+ public void testW2JPassByValueByteArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueByteArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateShort.
+ */
+ @Test
+ public void testW2JNegateShort() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateShort(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateShortArray.
+ */
+ @Test
+ public void testW2JNegateShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateShortArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for short array.
+ */
+ @Test
+ public void testW2JPassByValueShortArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueShortArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateInt.
+ */
+ @Test
+ public void testW2JNegateInt() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateInt(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateIntArray.
+ */
+ @Test
+ public void testW2JNegateIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateIntArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for int array.
+ */
+ @Test
+ public void testW2JPassByValueIntArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueIntArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateLong.
+ */
+ @Test
+ public void testW2JNegateLong() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateLong(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateLongArray.
+ */
+ @Test
+ public void testW2JNegateLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateLongArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for long array.
+ */
+ @Test
+ public void testW2JPassByValueLongArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueLongArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateFloat.
+ */
+ @Test
+ public void testW2JNegateFloat() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateFloat(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateFloatArray.
+ */
+ @Test
+ public void testW2JNegateFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateFloatArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for float array.
+ */
+ @Test
+ public void testW2JPassByValueFloatArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueFloatArray());
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateDouble.
+ */
+ @Test
+ public void testW2JNegateDouble() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateDouble(primitivesServiceClient);
+ }
+
+ /**
+ * Invokes the PrimitivesService service using WS binding.
+ * Service method invoked is negateDoubleArray.
+ */
+ @Test
+ public void testW2JNegateDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ performTestNegateDoubleArray(primitivesServiceClient);
+ }
+
+ /**
+ * Test the pass-by-value semantics of a remotable service with WS binding.
+ * Test for double array.
+ */
+ @Test
+ public void testW2JPassByValueDoubleArray() throws Exception {
+ PrimitivesServiceClient primitivesServiceClient = node.getService(PrimitivesServiceClient.class, "PrimitivesServiceClientW2JComponent");
+ Assert.assertTrue(primitivesServiceClient.passByValueDoubleArray());
+ }
+
+ private void performTestNegateBoolean(PrimitivesServiceClient primitivesServiceClient) {
+ Assert.assertTrue(primitivesServiceClient.negateBooleanForward(false));
+ Assert.assertFalse(primitivesServiceClient.negateBooleanForward(true));
+ }
+
+ private void performTestNegateBooleanArray(PrimitivesServiceClient primitivesServiceClient) {
+ boolean flags[] = new boolean[2];
+ flags[0] = false;
+ flags[1] = true;
+ boolean[] respFlags = primitivesServiceClient.negateBooleanArrayForward(flags);
+ Assert.assertEquals(flags.length, respFlags.length);
+ for(int i = 0; i < flags.length; ++i) {
+ Assert.assertEquals(!flags[i], respFlags[i]);
+ }
+ }
+
+ private void performTestNegateByte(PrimitivesServiceClient primitivesServiceClient) {
+ byte[] ba = new byte[3];
+ ba[0] = -1;
+ ba[1] = 0;
+ ba[2] = 1;
+
+ for(int i = 0; i < ba.length; ++i) {
+ Assert.assertEquals((byte)-ba[i], primitivesServiceClient.negateByteForward(ba[i]));
+ }
+ }
+
+ private void performTestNegateByteArray(PrimitivesServiceClient primitivesServiceClient) {
+ byte[] ba = new byte[3];
+ ba[0] = -1;
+ ba[1] = 0;
+ ba[2] = 1;
+
+ byte[] r = primitivesServiceClient.negateByteArrayForward(ba);
+ Assert.assertEquals(ba.length, r.length);
+ for(int i = 0; i < ba.length; ++i) {
+ Assert.assertEquals((byte)-ba[i], r[i]);
+ }
+ }
+
+ private void performTestNegateShort(PrimitivesServiceClient primitivesServiceClient) {
+ short[] s = new short[3];
+ s[0] = -1;
+ s[1] = 0;
+ s[2] = 1;
+
+ for(int i = 0; i < s.length; ++i) {
+ Assert.assertEquals((short)-s[i], primitivesServiceClient.negateShortForward(s[i]));
+ }
+ }
+
+ private void performTestNegateShortArray(PrimitivesServiceClient primitivesServiceClient) {
+ short[] s = new short[3];
+ s[0] = -1;
+ s[1] = 0;
+ s[2] = 1;
+
+ short[] r = primitivesServiceClient.negateShortArrayForward(s);
+ Assert.assertEquals(s.length, r.length);
+ for(int i = 0; i < s.length; ++i) {
+ Assert.assertEquals((short)-s[i], r[i]);
+ }
+ }
+
+ private void performTestNegateInt(PrimitivesServiceClient primitivesServiceClient) {
+ int[] ia = new int[3];
+ ia[0] = -1;
+ ia[1] = 0;
+ ia[2] = 1;
+
+ for(int i = 0; i < ia.length; ++i) {
+ Assert.assertEquals(-ia[i], primitivesServiceClient.negateIntForward(ia[i]));
+ }
+ }
+
+ private void performTestNegateIntArray(PrimitivesServiceClient primitivesServiceClient) {
+ int[] ia = new int[3];
+ ia[0] = -1;
+ ia[1] = 0;
+ ia[2] = 1;
+
+ int[] r = primitivesServiceClient.negateIntArrayForward(ia);
+ Assert.assertEquals(ia.length, r.length);
+ for(int i = 0; i < ia.length; ++i) {
+ Assert.assertEquals(-ia[i], r[i]);
+ }
+ }
+
+ private void performTestNegateLong(PrimitivesServiceClient primitivesServiceClient) {
+ long[] la = new long[3];
+ la[0] = -1;
+ la[1] = 0;
+ la[2] = 1;
+
+ for(int i = 0; i < la.length; ++i) {
+ Assert.assertEquals(-la[i], primitivesServiceClient.negateLongForward(la[i]));
+ }
+ }
+
+ private void performTestNegateLongArray(PrimitivesServiceClient primitivesServiceClient) {
+ long[] la = new long[3];
+ la[0] = -1;
+ la[1] = 0;
+ la[2] = 1;
+
+ long[] r = primitivesServiceClient.negateLongArrayForward(la);
+ Assert.assertEquals(la.length, r.length);
+ for(int i = 0; i < la.length; ++i) {
+ Assert.assertEquals(-la[i], r[i]);
+ }
+ }
+
+ private void performTestNegateFloat(PrimitivesServiceClient primitivesServiceClient) {
+ float[] fa = new float[3];
+ fa[0] = -1;
+ fa[1] = 0;
+ fa[2] = 1;
+
+ for(int i = 0; i < fa.length; ++i) {
+ Assert.assertEquals(-fa[i], primitivesServiceClient.negateFloatForward(fa[i]));
+ }
+ }
+
+ private void performTestNegateFloatArray(PrimitivesServiceClient primitivesServiceClient) {
+ float[] ia = new float[3];
+ ia[0] = -1;
+ ia[1] = 0;
+ ia[2] = 1;
+
+ float[] r = primitivesServiceClient.negateFloatArrayForward(ia);
+ Assert.assertEquals(ia.length, r.length);
+ for(int i = 0; i < ia.length; ++i) {
+ Assert.assertEquals(-ia[i], r[i]);
+ }
+ }
+
+ private void performTestNegateDouble(PrimitivesServiceClient primitivesServiceClient) {
+ double[] da = new double[3];
+ da[0] = -1;
+ da[1] = 0;
+ da[2] = 1;
+
+ for(int i = 0; i < da.length; ++i) {
+ Assert.assertEquals(-da[i], primitivesServiceClient.negateDoubleForward(da[i]));
+ }
+ }
+
+ private void performTestNegateDoubleArray(PrimitivesServiceClient primitivesServiceClient) {
+ double[] da = new double[3];
+ da[0] = -1;
+ da[1] = 0;
+ da[2] = 1;
+
+ double[] r = primitivesServiceClient.negateDoubleArrayForward(da);
+ Assert.assertEquals(da.length, r.length);
+ for(int i = 0; i < da.length; ++i) {
+ Assert.assertEquals(-da[i], r[i]);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/StandardTypesDatabindingTestCase.java b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/StandardTypesDatabindingTestCase.java
new file mode 100644
index 0000000000..7499978c0e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/StandardTypesDatabindingTestCase.java
@@ -0,0 +1,1438 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.databindings.jaxb.topdown;
+
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.attachments.ByteArrayDataSource;
+import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesServiceClient;
+import org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesTransformer;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StandardTypesDatabindingTestCase {
+
+ private static Node node;
+
+ /**
+ * Runs once before the tests
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/wsdl/wrapped/standard-types-service.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/wsdl/wrapped/").toURI().toURL().toString()));
+ node.start();
+ }
+
+ /**
+ * Runs once after the tests
+ */
+ @AfterClass
+ public static void tearDown() {
+ node.stop();
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigInteger.
+ */
+ @Test
+ public void testW2WNewBigInteger() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewBigInteger(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigIntegerArray.
+ */
+ @Test
+ public void testW2WNewBigIntegerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewBigIntegerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigDecimal.
+ */
+ @Test
+ public void testW2WNewBigDecimal() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewBigDecimal(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigDecimalArray.
+ */
+ @Test
+ public void testW2WNewBigDecimalArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewBigDecimalArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewCalendar.
+ */
+ @Test
+ public void testW2WNewCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewCalendarArray.
+ */
+ @Test
+ public void testW2WNewCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDate.
+ */
+ @Test
+ public void testW2WNewDate() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewDate(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDateArray.
+ */
+ @Test
+ public void testW2WNewDateArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewDateArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewQName.
+ */
+ @Test
+ public void testW2WNewQName() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewQName(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewQNameArray.
+ */
+ @Test
+ public void testW2WNewQNameArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewQNameArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewURI.
+ */
+ @Test
+ public void testW2WNewURI() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewURI(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewURIArray.
+ */
+ @Test
+ public void testW2WNewURIArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewURIArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewXMLGregorianCalendar.
+ */
+ @Test
+ public void testW2WNewXMLGregorianCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewXMLGregorianCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewXMLGregorianCalendarArray.
+ */
+ @Test
+ public void testW2WNewXMLGregorianCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewXMLGregorianCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDuration.
+ */
+ @Test
+ public void testW2WNewDuration() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewDuration(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDurationArray.
+ */
+ @Test
+ public void testW2WNewDurationArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewDurationArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewObject.
+ */
+ @Test
+ public void testW2WNewObject() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewObject(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewObjectArray.
+ */
+ @Test
+ public void testW2WNewObjectArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewObjectArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewImage.
+ */
+ @Test
+ public void testW2WNewImage() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewImage(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewImageArray.
+ */
+ @Test
+ public void testW2WNewImageArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewImageArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDataHandler.
+ */
+ @Test
+ public void testW2WNewDataHandler() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewDataHandler(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDataHandlerArray.
+ */
+ @Test
+ public void testW2WNewDataHandlerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewDataHandlerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewSource.
+ */
+ /*@Test
+ //@Ignore("junit.framework.ComparisonFailure: null expected:<... encoding=\"UTF-8\"?><[a>A</a]>> but was:<... encoding=\"UTF-8\"?><[return xmlns=\"http://jaxb.databindings.itest.sca.tuscany.apache.org/\">A</return]>>")
+ public void testW2WNewSource() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewSource(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewSourceArray.
+ */
+ /*@Test
+ @Ignore("TUSCANY-2452")
+ public void testW2WNewSourceArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewSourceArray(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewUUID.
+ */
+ @Test
+ public void testW2WNewUUID() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewUUID(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewUUIDArray.
+ */
+ @Test
+ public void testW2WNewUUIDArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2WComponent");
+ performTestNewUUIDArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigInteger.
+ */
+ @Test
+ public void testJ2WNewBigInteger() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewBigInteger(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigIntegerArray.
+ */
+ @Test
+ public void testJ2WNewBigIntegerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewBigIntegerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigDecimal.
+ */
+ @Test
+ public void testJ2WNewBigDecimal() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewBigDecimal(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigDecimalArray.
+ */
+ @Test
+ public void testJ2WNewBigDecimalArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewBigDecimalArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewCalendar.
+ */
+ @Test
+ public void testJ2WNewCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewCalendarArray.
+ */
+ @Test
+ public void testJ2WNewCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDate.
+ */
+ @Test
+ public void testJ2WNewDate() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewDate(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDateArray.
+ */
+ @Test
+ public void testJ2WNewDateArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewDateArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewQName.
+ */
+ @Test
+ public void testJ2WNewQName() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewQName(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewQNameArray.
+ */
+ @Test
+ public void testJ2WNewQNameArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewQNameArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewURI.
+ */
+ @Test
+ public void testJ2WNewURI() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewURI(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewURIArray.
+ */
+ @Test
+ public void testJ2WNewURIArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewURIArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewXMLGregorianCalendar.
+ */
+ @Test
+ public void testJ2WNewXMLGregorianCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewXMLGregorianCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewXMLGregorianCalendarArray.
+ */
+ @Test
+ public void testJ2WNewXMLGregorianCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewXMLGregorianCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDuration.
+ */
+ @Test
+ public void testJ2WNewDuration() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewDuration(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDurationArray.
+ */
+ @Test
+ public void testJ2WNewDurationArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewDurationArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewObject.
+ */
+ @Test
+ public void testJ2WNewObject() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewObject(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewObjectArray.
+ */
+ @Test
+ public void testJ2WNewObjectArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewObjectArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewImage.
+ */
+ @Test
+ public void testJ2WNewImage() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewImage(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewImageArray.
+ */
+ @Test
+ public void testJ2WNewImageArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewImageArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDataHandler.
+ */
+ @Test
+ public void testJ2WNewDataHandler() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewDataHandler(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDataHandlerArray.
+ */
+ @Test
+ public void testJ2WNewDataHandlerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewDataHandlerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewSource.
+ */
+ /*@Test
+ //@Ignore("junit.framework.ComparisonFailure: null expected:<... encoding=\"UTF-8\"?><[a>A</a]>> but was:<... encoding=\"UTF-8\"?><[return xmlns=\"http://jaxb.databindings.itest.sca.tuscany.apache.org/\">A</return]>>")
+ public void testJ2WNewSource() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewSource(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewSourceArray.
+ */
+ /*@Test
+ @Ignore("TUSCANY-2452")
+ public void testJ2WNewSourceArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewSourceArray(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewUUID.
+ */
+ @Test
+ public void testJ2WNewUUID() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewUUID(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewUUIDArray.
+ */
+ @Test
+ public void testJ2WNewUUIDArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientJ2WComponent");
+ performTestNewUUIDArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigInteger.
+ */
+ @Test
+ public void testW2JNewBigInteger() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewBigInteger(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigIntegerArray.
+ */
+ @Test
+ public void testW2JNewBigIntegerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewBigIntegerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigDecimal.
+ */
+ @Test
+ public void testW2JNewBigDecimal() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewBigDecimal(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewBigDecimalArray.
+ */
+ @Test
+ public void testW2JNewBigDecimalArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewBigDecimalArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewCalendar.
+ */
+ @Test
+ public void testW2JNewCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewCalendarArray.
+ */
+ @Test
+ public void testW2JNewCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDate.
+ */
+ @Test
+ public void testW2JNewDate() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewDate(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDateArray.
+ */
+ @Test
+ public void testW2JNewDateArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewDateArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewQName.
+ */
+ @Test
+ public void testW2JNewQName() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewQName(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewQNameArray.
+ */
+ @Test
+ public void testW2JNewQNameArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewQNameArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewURI.
+ */
+ @Test
+ public void testW2JNewURI() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewURI(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewURIArray.
+ */
+ @Test
+ public void testW2JNewURIArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewURIArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewXMLGregorianCalendar.
+ */
+ @Test
+ public void testW2JNewXMLGregorianCalendar() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewXMLGregorianCalendar(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewXMLGregorianCalendarArray.
+ */
+ @Test
+ public void testW2JNewXMLGregorianCalendarArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewXMLGregorianCalendarArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDuration.
+ */
+ @Test
+ public void testW2JNewDuration() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewDuration(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDurationArray.
+ */
+ @Test
+ public void testW2JNewDurationArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewDurationArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewObject.
+ */
+ @Test
+ public void testW2JNewObject() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewObject(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewObjectArray.
+ */
+ @Test
+ public void testW2JNewObjectArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewObjectArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewImage.
+ */
+ @Test
+ public void testW2JNewImage() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewImage(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewImageArray.
+ */
+ @Test
+ public void testW2JNewImageArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewImageArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDataHandler.
+ */
+ @Test
+ public void testW2JNewDataHandler() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewDataHandler(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewDataHandlerArray.
+ */
+ @Test
+ public void testW2JNewDataHandlerArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewDataHandlerArray(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewSource.
+ */
+ /*@Test
+ //@Ignore("junit.framework.ComparisonFailure: null expected:<... encoding=\"UTF-8\"?><[a>A</a]>> but was:<... encoding=\"UTF-8\"?><[return xmlns=\"http://jaxb.databindings.itest.sca.tuscany.apache.org/\">A</return]>>")
+ public void testW2JNewSource() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewSource(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewSourceArray.
+ */
+ /*@Test
+ @Ignore("TUSCANY-2452")
+ public void testW2JNewSourceArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewSourceArray(serviceClient);
+ }*/
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewUUID.
+ */
+ @Test
+ public void testW2JNewUUID() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewUUID(serviceClient);
+ }
+
+ /**
+ * Invokes the StandardTypesService service using WS binding.
+ * Service method invoked is getNewUUIDArray.
+ */
+ @Test
+ public void testW2JNewUUIDArray() throws Exception {
+ StandardTypesServiceClient serviceClient =
+ node.getService(StandardTypesServiceClient.class, "StandardTypesServiceClientW2JComponent");
+ performTestNewUUIDArray(serviceClient);
+ }
+
+ private void performTestNewBigInteger(StandardTypesServiceClient serviceClient) {
+ BigInteger bi = new BigInteger("1234567890123456789012345678901234");
+ BigInteger expected = bi.negate();
+ BigInteger actual = serviceClient.getNewBigIntegerForward(bi);
+ Assert.assertEquals(expected, actual);
+ }
+
+ private void performTestNewBigIntegerArray(StandardTypesServiceClient serviceClient) {
+ BigInteger[] bia = new BigInteger[2];
+ bia[0] = new BigInteger("1234567890123456789012345678901234");
+ bia[1] = new BigInteger("-98765432109876543210987654321");
+ BigInteger[] actual = serviceClient.getNewBigIntegerArrayForward(bia);
+ Assert.assertEquals(bia.length, actual.length);
+ for (int i = 0; i < bia.length; ++i) {
+ Assert.assertEquals(bia[i].negate(), actual[i]);
+ }
+ }
+
+ private void performTestNewBigDecimal(StandardTypesServiceClient serviceClient) {
+ BigDecimal bd = new BigDecimal("12345678901234567890.12345678901234");
+ BigDecimal expected = bd.negate();
+ BigDecimal actual = serviceClient.getNewBigDecimalForward(bd);
+ Assert.assertEquals(expected, actual);
+ }
+
+ private void performTestNewBigDecimalArray(StandardTypesServiceClient serviceClient) {
+ BigDecimal[] bda = new BigDecimal[2];
+ bda[0] = new BigDecimal("1234567890123456.789012345678901234");
+ bda[1] = new BigDecimal("-987654321098765.43210987654321");
+ BigDecimal[] actual = serviceClient.getNewBigDecimalArrayForward(bda);
+ Assert.assertEquals(bda.length, actual.length);
+ for (int i = 0; i < bda.length; ++i) {
+ Assert.assertEquals(bda[i].negate(), actual[i]);
+ }
+ }
+
+ private void performTestNewCalendar(StandardTypesServiceClient serviceClient) {
+ Calendar[] ca = new Calendar[3];
+ String[] tz = {"GMT+05:30", "GMT+00:00", "GMT-05:00"};
+ for (int i = 0; i < ca.length; ++i) {
+ ca[i] = Calendar.getInstance(TimeZone.getTimeZone(tz[i]));
+ ca[i].set(Calendar.DAY_OF_MONTH, i + 1);
+ }
+ for (int i = 0; i < ca.length; ++i) {
+ Calendar actual = serviceClient.getNewCalendarForward(ca[i]);
+ ca[i].add(Calendar.DAY_OF_MONTH, 5);
+ if (actual instanceof GregorianCalendar && ca[i] instanceof GregorianCalendar) {
+ // FIXME: Is this a problem?
+ // The instance returned by service method invoked over binding.ws seems to have a gregorianCutover
+ // different from the instance passed. Adjust the gregorianCutover as per the input instance.
+ ((GregorianCalendar)actual).setGregorianChange(((GregorianCalendar)ca[i]).getGregorianChange());
+ }
+ Assert.assertEquals(ca[i], actual);
+ }
+ }
+
+ private void performTestNewCalendarArray(StandardTypesServiceClient serviceClient) {
+ Calendar[] ca = new Calendar[3];
+ String[] tz = {"GMT+05:30", "GMT+00:00", "GMT-05:00"};
+ for (int i = 0; i < ca.length; ++i) {
+ ca[i] = Calendar.getInstance(TimeZone.getTimeZone(tz[i]));
+ ca[i].set(Calendar.DAY_OF_MONTH, i + 1);
+ }
+ Calendar[] actual = serviceClient.getNewCalendarArrayForward(ca);
+ Assert.assertEquals(ca.length, actual.length);
+ for (int i = 0; i < ca.length; ++i) {
+ ca[i].add(Calendar.DAY_OF_MONTH, 5);
+ if (actual[i] instanceof GregorianCalendar && ca[i] instanceof GregorianCalendar) {
+ // FIXME: Is this a problem?
+ // The instance returned by service method invoked over binding.ws seems to have a gregorianCutover
+ // different from the instance passed. Adjust the gregorianCutover as per the input instance.
+ ((GregorianCalendar)actual[i]).setGregorianChange(((GregorianCalendar)ca[i]).getGregorianChange());
+ }
+ Assert.assertEquals(ca[i], actual[i]);
+ }
+ }
+
+ private void performTestNewDate(StandardTypesServiceClient serviceClient) {
+ Date d = new Date();
+ Date expected = new Date(d.getTime() + 5 * 24 * 60 * 60 * 1000);
+ Date actual = serviceClient.getNewDateForward(d);
+ Assert.assertEquals(expected, actual);
+ }
+
+ private void performTestNewDateArray(StandardTypesServiceClient serviceClient) {
+ Date[] d = new Date[2];
+ Date[] expected = new Date[d.length];
+ for (int i = 0; i < d.length; ++i) {
+ d[i] = new Date();
+ d[i].setTime(d[i].getTime() + i * 24 * 60 * 60 * 1000);
+ expected[i] = new Date(d[i].getTime() + 5 * 24 * 60 * 60 * 1000);
+ }
+ Date[] actual = serviceClient.getNewDateArrayForward(d);
+ Assert.assertEquals(expected.length, actual.length);
+ for (int i = 0; i < expected.length; ++i) {
+ Assert.assertEquals(expected[i], actual[i]);
+ }
+ }
+
+ private void performTestNewQName(StandardTypesServiceClient serviceClient) {
+ QName[] qnames = new QName[3];
+ qnames[0] = new QName("localPart");
+ qnames[1] = new QName("namespaceUri", "localPart");
+ qnames[2] = new QName("namespaceUri", "localPart", "prefix");
+ QName[] expected = new QName[qnames.length];
+ for (int i = 0; i < qnames.length; ++i) {
+ expected[i] =
+ new QName(qnames[i].getNamespaceURI() + "q", qnames[i].getLocalPart() + "q",
+ qnames[i].getPrefix() + "q");
+ }
+ for (int i = 0; i < qnames.length; ++i) {
+ QName actual = serviceClient.getNewQNameForward(qnames[i]);
+ Assert.assertEquals(expected[i], actual);
+ }
+ }
+
+ private void performTestNewQNameArray(StandardTypesServiceClient serviceClient) {
+ QName[] qnames = new QName[4];
+ qnames[0] = new QName("localPart");
+ qnames[1] = new QName("namespaceUri", "localPart");
+ qnames[2] = new QName("namespaceUri", "localPart", "prefix");
+ qnames[3] = new QName("localPart2");
+ QName[] expected = new QName[qnames.length];
+ for (int i = 0; i < qnames.length; ++i) {
+ expected[i] =
+ new QName(qnames[i].getNamespaceURI() + "q", qnames[i].getLocalPart() + "q",
+ qnames[i].getPrefix() + "q");
+ }
+ QName[] actual = serviceClient.getNewQNameArrayForward(qnames);
+ Assert.assertEquals(expected.length, actual.length);
+ for (int i = 0; i < qnames.length; ++i) {
+ Assert.assertEquals(expected[i], actual[i]);
+ }
+ }
+
+ private void performTestNewURI(StandardTypesServiceClient serviceClient) {
+ URI[] uris = new URI[4];
+ uris[0] = URI.create("a/b/c");
+ uris[1] = URI.create("http://abc/");
+ uris[2] = URI.create("ftp://a/b");
+ uris[3] = URI.create("http://abc/").resolve("xyz");
+
+ for (int i = 0; i < uris.length; ++i) {
+ URI expected = uris[i].resolve("uri");
+ URI actual = serviceClient.getNewURIForward(uris[i]);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestNewURIArray(StandardTypesServiceClient serviceClient) {
+ URI[] uris = new URI[4];
+ uris[0] = URI.create("a/b/c");
+ // [rfeng] We need to have a trialign / to avoid the resolving problem
+ // FIXME: [vamsi] This is actually a data transformation problem. The array being returned from the service method is
+ // not making to the caller intact.
+ uris[1] = URI.create("http://abc/");
+ uris[2] = URI.create("ftp://a/b");
+ uris[3] = URI.create("http://abc/").resolve("xyz");
+
+ URI[] expected = new URI[uris.length];
+ for (int i = 0; i < uris.length; ++i) {
+ expected[i] = uris[i].resolve("uri");
+ }
+
+ URI[] actual = serviceClient.getNewURIArrayForward(uris);
+ Assert.assertEquals(expected.length, actual.length);
+ for (int i = 0; i < uris.length; ++i) {
+ Assert.assertEquals(expected[i], actual[i]);
+ }
+ }
+
+ private void performTestNewXMLGregorianCalendar(StandardTypesServiceClient serviceClient)
+ throws DatatypeConfigurationException {
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ XMLGregorianCalendar[] xgcals = new XMLGregorianCalendar[3];
+ xgcals[0] = df.newXMLGregorianCalendar(new GregorianCalendar(1974, GregorianCalendar.APRIL, 19));
+ xgcals[1] = df.newXMLGregorianCalendar(new GregorianCalendar(1978, GregorianCalendar.OCTOBER, 13));
+ xgcals[2] = df.newXMLGregorianCalendar(new GregorianCalendar(2006, GregorianCalendar.JUNE, 16));
+
+ for (int i = 0; i < xgcals.length; ++i) {
+ XMLGregorianCalendar actual = serviceClient.getNewXMLGregorianCalendarForward(xgcals[i]);
+ xgcals[i].setDay(xgcals[i].getDay() + 5);
+ Assert.assertEquals(xgcals[i], actual);
+ }
+ }
+
+ private void performTestNewXMLGregorianCalendarArray(StandardTypesServiceClient serviceClient)
+ throws DatatypeConfigurationException {
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ XMLGregorianCalendar[] xgcals = new XMLGregorianCalendar[3];
+ xgcals[0] = df.newXMLGregorianCalendar(new GregorianCalendar(1974, GregorianCalendar.APRIL, 19));
+ xgcals[1] = df.newXMLGregorianCalendar(new GregorianCalendar(1978, GregorianCalendar.OCTOBER, 13));
+ xgcals[2] = df.newXMLGregorianCalendar(new GregorianCalendar(2006, GregorianCalendar.JUNE, 16));
+
+ XMLGregorianCalendar[] actual = serviceClient.getNewXMLGregorianCalendarArrayForward(xgcals);
+ Assert.assertEquals(xgcals.length, actual.length);
+ for (int i = 0; i < xgcals.length; ++i) {
+ xgcals[i].setDay(xgcals[i].getDay() + 5);
+ Assert.assertEquals(xgcals[i], actual[i]);
+ }
+ }
+
+ private void performTestNewDuration(StandardTypesServiceClient serviceClient) throws DatatypeConfigurationException {
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ Duration[] da = new Duration[3];
+ da[0] = df.newDuration(1000000000000L);
+ da[1] = df.newDurationDayTime(1000000000000L);
+ da[2] = df.newDurationYearMonth(true, 1, 3);
+
+ for (int i = 0; i < da.length; ++i) {
+ Assert.assertEquals(da[i].negate(), serviceClient.getNewDurationForward(da[i]));
+ }
+ }
+
+ private void performTestNewObject(StandardTypesServiceClient serviceClient) {
+ Object[] objs = new Object[5];
+ objs[0] = "Hello";
+ objs[1] = 10;
+ objs[2] = null;
+ objs[3] = -1.0;
+ objs[4] = null;
+
+ for (int i = 0; i < objs.length; ++i) {
+ Object expected = StandardTypesTransformer.getNewObject(objs[i]);
+ Object actual = serviceClient.getNewObjectForward(objs[i]);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestNewObjectArray(StandardTypesServiceClient serviceClient) {
+ Object[] objs = new Object[5];
+ objs[0] = "Hello";
+ objs[1] = 10;
+ objs[2] = null;
+ objs[3] = -1.0;
+ objs[4] = null;
+
+ Object[] actual = serviceClient.getNewObjectArrayForward(objs);
+ Assert.assertEquals(objs.length, actual.length);
+ for (int i = 0; i < objs.length; ++i) {
+ Object expected = StandardTypesTransformer.getNewObject(objs[i]);
+ Assert.assertEquals(expected, actual[i]);
+ }
+ }
+
+ private void performTestNewImage(StandardTypesServiceClient serviceClient) throws InterruptedException {
+ // Create some images to test with.
+ Image[] imgs = new Image[3];
+ imgs[0] = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
+ imgs[1] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ imgs[2] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ imgs[0].getGraphics().drawLine(1, 1, 8, 8);
+ imgs[1].getGraphics().drawLine(8, 1, 1, 8);
+ imgs[2].getGraphics().drawLine(1, 8, 8, 1);
+
+ Image[] copy = imgs;
+ // Create the same images once again as the StandardTypesTransformer may manipulate the image passed.
+ imgs = new Image[3];
+ imgs[0] = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
+ imgs[1] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ imgs[2] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ imgs[0].getGraphics().drawLine(1, 1, 8, 8);
+ imgs[1].getGraphics().drawLine(8, 1, 1, 8);
+ imgs[2].getGraphics().drawLine(1, 8, 8, 1);
+
+ // Make sure the images and copies are equal using ImageInfo
+ for(int i = 0; i < imgs.length; ++i) {
+ Assert.assertEquals(new ImageInfo(imgs[i]), new ImageInfo(copy[i]));
+ }
+
+ for (int i = 0; i < imgs.length; ++i) {
+ Image actual = serviceClient.getNewImageForward(imgs[i]);
+ Image expected = StandardTypesTransformer.getNewImage(copy[i]);
+ // Compare using ImageInfo
+ Assert.assertEquals(new ImageInfo(expected), new ImageInfo(actual));
+ }
+ }
+
+ private void performTestNewImageArray(StandardTypesServiceClient serviceClient) throws InterruptedException {
+ // Create some images to test with.
+ Image[] imgs = new Image[3];
+ imgs[0] = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
+ imgs[1] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ imgs[2] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ imgs[0].getGraphics().drawLine(1, 1, 8, 8);
+ imgs[1].getGraphics().drawLine(8, 1, 1, 8);
+ imgs[2].getGraphics().drawLine(1, 8, 8, 1);
+
+ Image[] copy = imgs;
+ // Create the same images once again as the StandardTypesTransformer may manipulate the image passed.
+ imgs = new Image[3];
+ imgs[0] = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
+ imgs[1] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ imgs[2] = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ imgs[0].getGraphics().drawLine(1, 1, 8, 8);
+ imgs[1].getGraphics().drawLine(8, 1, 1, 8);
+ imgs[2].getGraphics().drawLine(1, 8, 8, 1);
+
+ // Make sure the images and copies are equal using ImageInfo
+ for(int i = 0; i < imgs.length; ++i) {
+ Assert.assertEquals(new ImageInfo(imgs[i]), new ImageInfo(copy[i]));
+ }
+
+ Image[] actual = serviceClient.getNewImageArrayForward(imgs);
+ Assert.assertEquals(imgs.length, actual.length);
+ for (int i = 0; i < imgs.length; ++i) {
+ Image expected = StandardTypesTransformer.getNewImage(copy[i]);
+ // Compare using ImageInfo
+ Assert.assertEquals(new ImageInfo(expected), new ImageInfo(actual[i]));
+ }
+ }
+
+ private void performTestNewDurationArray(StandardTypesServiceClient serviceClient)
+ throws DatatypeConfigurationException {
+ DatatypeFactory df = DatatypeFactory.newInstance();
+ Duration[] da = new Duration[3];
+ da[0] = df.newDuration(1000000000000L);
+ da[1] = df.newDurationDayTime(1000000000000L);
+ da[2] = df.newDurationYearMonth(true, 1, 3);
+
+ Duration[] actual = serviceClient.getNewDurationArrayForward(da);
+ Assert.assertEquals(da.length, actual.length);
+ for (int i = 0; i < da.length; ++i) {
+ Assert.assertEquals(da[i].negate(), actual[i]);
+ }
+ }
+
+ private void performTestNewDataHandler(StandardTypesServiceClient serviceClient) throws IOException {
+ DataHandler[] dha = new DataHandler[3];
+ dha[0] = new DataHandler("Some data", "text/plain");
+ dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
+ dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));
+
+ for (int i = 0; i < dha.length; ++i) {
+ DataHandler actual = serviceClient.getNewDataHandlerForward(dha[i]);
+ // Note: The DataHandler returned may use a different type of DataSource.
+ // Compare the data content instead of using equals().
+ Assert.assertTrue(compare(dha[i], actual));
+ }
+ }
+
+ private void performTestNewDataHandlerArray(StandardTypesServiceClient serviceClient) throws IOException {
+ DataHandler[] dha = new DataHandler[3];
+ dha[0] = new DataHandler("Some data", "text/plain");
+ dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
+ dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));
+
+ DataHandler[] actual = serviceClient.getNewDataHandlerArrayForward(dha);
+ Assert.assertEquals(dha.length, actual.length);
+ for (int i = 0; i < dha.length; ++i) {
+ // Note: The DataHandler returned may use a different type of DataSource.
+ // Compare the data content instead of using equals().
+ Assert.assertTrue(compare(dha[i], actual[i]));
+ }
+ }
+
+ /*private void performTestNewSource(StandardTypesServiceClient serviceClient) throws Exception {
+ String xml = "<a>A<b>B</b><c>C</c></a>";
+ Source[] srcs = new Source[3];
+ srcs[0] = new DOMSource(new String2Node(null).transform(xml, null));
+ srcs[1] = new SAXSource(new InputSource(new StringReader(xml)));
+ srcs[2] = new StreamSource(new StringReader(xml));
+
+ for (int i = 0; i < srcs.length; ++i) {
+ Source expected = StandardTypesTransformer.getNewSource(srcs[i]);
+ Source actual = serviceClient.getNewSourceForward(srcs[i]);
+ // [rfeng] The data may come back as a different source
+ Assert.assertEquals(sourceToString(expected), sourceToString(actual));
+ }
+ }
+
+ private void performTestNewSourceArray(StandardTypesServiceClient serviceClient) throws Exception {
+ String xml = "<a>A<b>B</b><c>C</c></a>";
+ Source[] srcs = new Source[3];
+ srcs[0] = new DOMSource(new String2Node(null).transform(xml, null));
+ srcs[1] = new SAXSource(new InputSource(new StringReader(xml)));
+ srcs[2] = new StreamSource(new StringReader(xml));
+
+ Source[] actual = serviceClient.getNewSourceArrayForward(srcs);
+ Source[] expected = new Source[srcs.length];
+ for(int i = 0; i < srcs.length; ++i) {
+ expected[i] = StandardTypesTransformer.getNewSource(srcs[i]);
+ }
+ Assert.assertEquals(srcs.length, actual.length);
+ for (int i = 0; i < srcs.length; ++i) {
+ // [rfeng] The data may come back as a different source
+ Assert.assertEquals(sourceToString(expected[i]), sourceToString(actual[i]));
+ }
+
+ }*/
+
+ private void performTestNewUUID(StandardTypesServiceClient serviceClient) {
+ UUID[] uuids = new UUID[3];
+ uuids[0] = UUID.nameUUIDFromBytes("ABCDEFGHJKLMNOPQRSTUVWXYZ".getBytes());
+ uuids[1] = UUID.nameUUIDFromBytes("abcdefghjklmnopqrstuvwxyz".getBytes());
+ uuids[2] = UUID.randomUUID();
+
+ for (int i = 0; i < uuids.length; ++i) {
+ UUID expected = UUID.fromString(uuids[i].toString() + "AAA");
+ UUID actual = serviceClient.getNewUUIDForward(uuids[i]);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ private void performTestNewUUIDArray(StandardTypesServiceClient serviceClient) {
+ UUID[] uuids = new UUID[3];
+ uuids[0] = UUID.nameUUIDFromBytes("ABCDEFGHJKLMNOPQRSTUVWXYZ".getBytes());
+ uuids[1] = UUID.nameUUIDFromBytes("abcdefghjklmnopqrstuvwxyz".getBytes());
+ uuids[2] = UUID.randomUUID();
+
+ UUID[] actual = serviceClient.getNewUUIDArrayForward(uuids);
+ for (int i = 0; i < uuids.length; ++i) {
+ UUID expected = UUID.fromString(uuids[i].toString() + "AAA");
+ Assert.assertEquals(expected, actual[i]);
+ }
+ }
+
+ /**
+ * This method compares two DataHandlers.
+ * @return true if the data in the two handlers is the same.
+ */
+ private boolean compare(DataHandler dh1, DataHandler dh2) throws IOException {
+ InputStream inp1 = dh1.getInputStream();
+ InputStream inp2 = dh2.getInputStream();
+ for(;;) {
+ int i1 = inp1.read();
+ int i2 = inp2.read();
+ if(i1 == -1 && i2 == -1) {
+ return true;
+ } else if(i1 != -1 && i2 != -1) {
+ if(i1 != i2) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * This method returns the content of a source object as String.
+ */
+ private String sourceToString(Source s) throws Exception {
+ StringWriter sw = new StringWriter();
+ Result r = new StreamResult(sw);
+ TransformerFactory.newInstance().newTransformer().transform(s, r);
+ sw.close();
+ return sw.toString();
+ }
+
+ /**
+ * This class initializes with the width, height and pixel data of a java.awt.Image object.
+ */
+ private static class ImageInfo {
+ private int h, w, pixels[];
+ public ImageInfo(Image img) throws InterruptedException {
+ w = img.getWidth(null);
+ h = img.getHeight(null);
+ pixels = new int[w*h];
+ PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w);
+ pg.grabPixels();
+ }
+
+ public boolean equals(Object that) {
+ if(that == null) {
+ return false;
+ } else if(!(that instanceof ImageInfo)) {
+ return false;
+ }
+
+ ImageInfo that1 = (ImageInfo)that;
+ if(w != that1.w || h != that1.h || pixels == null || that1.pixels == null || pixels.length != that1.pixels.length) {
+ return false;
+ }
+ for(int i = 0; i < pixels.length; ++i) {
+ if(pixels[i] != that1.pixels[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public String toString() {
+ return this.getClass().getSimpleName()+"[w = "+w+", h = "+h+", pixels = "+pixels+"]";
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/databindings/pom.xml b/sandbox/sebastien/java/embed/itest/databindings/pom.xml
new file mode 100644
index 0000000000..8615b6c370
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/databindings/pom.xml
@@ -0,0 +1,41 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-databindings</artifactId>
+ <name>Apache Tuscany SCA Databindings Integration Tests</name>
+ <version>2.0-SNAPSHOT</version>
+
+ <packaging>pom</packaging>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ </build>
+ <modules>
+ <module>jaxb-bottom-up</module>
+ <module>jaxb-top-down</module>
+ </modules>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/bin-distro-unzip/build.xml b/sandbox/sebastien/java/embed/itest/distribution/bin-distro-unzip/build.xml
new file mode 100644
index 0000000000..6c4b1fdf3f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/bin-distro-unzip/build.xml
@@ -0,0 +1,27 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="itest-unzip" default="unzip">
+
+ <target name="unzip">
+ <delete dir="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.dir"/>
+ <unzip src="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.zip"
+ dest="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.dir"/>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/bin-distro-unzip/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/bin-distro-unzip/pom.xml
new file mode 100644
index 0000000000..d9793d810d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/bin-distro-unzip/pom.xml
@@ -0,0 +1,128 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Bin Distro Unzip</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distribution-all</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <!-- HACK: use profile to control if we need to add tools.jar -->
+ <!-- Mac OS doesn't have tools.jar -->
+ <profiles>
+ <profile>
+ <id>not-sun-jdk</id>
+ <activation>
+ <file>
+ <missing>${java.home}/../lib/tools.jar</missing>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="java.home" value="${java.home}"/>
+ <property name="tuscany.version" value="${version}" />
+ <ant antfile="./build.xml" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>sun-jdk</id>
+ <activation>
+ <file>
+ <exists>${java.home}/../lib/tools.jar</exists>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-trax</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <!-- this JDk dependency is a workaround for Maven bug - http://jira.codehaus.org/browse/MNG-1323 -->
+ <dependency>
+ <groupId>sun.jdk</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.6</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="java.home" value="${java.home}"/>
+ <property name="tuscany.version" value="${version}" />
+ <ant antfile="./build.xml" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-rmi-calculator/build.xml b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-rmi-calculator/build.xml
new file mode 100644
index 0000000000..86afb7a952
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-rmi-calculator/build.xml
@@ -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.
+-->
+<project name="itest-samples" default="run">
+
+ <!--
+ compile and run each sample as though the user were running
+ samples from the binary distribution. Here we use ant targets
+ in the first instance but for some tests we may want to run
+ jars directly or fire up webapp containers and deploy wars. In other cases
+ we may need to run two samples together to provide reference and
+ service sides of the sample.
+ -->
+
+ <property name="distro.root" value="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.dir/tuscany-sca-${tuscany.version}" />
+
+ <target name="run">
+ <ant antfile="build.xml"
+ dir="${distro.root}/samples/binding-rmi/contribution-calculator-reference"/>
+ <ant antfile="build.xml"
+ dir="${distro.root}/samples/binding-rmi/contribution-calculator-service"/>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-rmi-calculator/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-rmi-calculator/pom.xml
new file mode 100644
index 0000000000..35058e8300
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-rmi-calculator/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-contribution-binding-rmi-calculator</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Contribution binding-rmi Calculator</name>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="tuscany.version" value="${version}" />
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-sca-calculator/build.xml b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-sca-calculator/build.xml
new file mode 100644
index 0000000000..bd5f247a19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-sca-calculator/build.xml
@@ -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.
+-->
+<project name="itest-samples" default="run">
+
+ <echo>${java.home}</echo>
+ <!--
+ compile and run each sample as though the user were running
+ samples from the binary distribution. Here we use ant targets
+ in the first instance but for some tests we may want to run
+ jars directly or fire up webapp containers and deploy wars. In other cases
+ we may need to run two samples together to provide reference and
+ service sides of the sample.
+ -->
+
+ <property name="distro.root" value="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.dir/tuscany-sca-${tuscany.version}" />
+
+ <target name="run">
+
+ <ant antfile="build.xml"
+ dir="${distro.root}/samples/binding-sca/contribution-calculator"/>
+
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-sca-calculator/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-sca-calculator/pom.xml
new file mode 100644
index 0000000000..5ea30a20f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-sca-calculator/pom.xml
@@ -0,0 +1,87 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-contribution-binding-sca-calculator</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Contribution binding-sca Calculator</name>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-trax</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <!-- this JDk dependency is a workaround for Maven bug - http://jira.codehaus.org/browse/MNG-1323 -->
+ <dependency>
+ <groupId>sun.jdk</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.6</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="tuscany.version" value="${version}" />
+ <property name="java.home" value="${java.home}"/>
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-ws-calculator/build.xml b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-ws-calculator/build.xml
new file mode 100644
index 0000000000..a12aebb4a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-ws-calculator/build.xml
@@ -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.
+-->
+<project name="itest-samples" default="run">
+
+ <echo>${java.home}</echo>
+ <!--
+ compile and run each sample as though the user were running
+ samples from the binary distribution. Here we use ant targets
+ in the first instance but for some tests we may want to run
+ jars directly or fire up webapp containers and deploy wars. In other cases
+ we may need to run two samples together to provide reference and
+ service sides of the sample.
+ -->
+
+ <property name="distro.root" value="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.dir/tuscany-sca-${tuscany.version}" />
+
+ <target name="run">
+
+ <ant antfile="build.xml"
+ dir="${distro.root}/samples/binding-ws/contribution-calculator"/>
+
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-ws-calculator/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-ws-calculator/pom.xml
new file mode 100644
index 0000000000..c598f122e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/contribution-binding-ws-calculator/pom.xml
@@ -0,0 +1,69 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-contribution-binding-ws-calculator</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Contribution binding-ws Calculator</name>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="java.home" value="${java.home}"/>
+ <property name="tuscany.version" value="${version}" />
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/contribution-implementation-java-calculator/build.xml b/sandbox/sebastien/java/embed/itest/distribution/contribution-implementation-java-calculator/build.xml
new file mode 100644
index 0000000000..8da281f984
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/contribution-implementation-java-calculator/build.xml
@@ -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.
+-->
+<project name="itest-samples" default="run">
+
+ <echo>${java.home}</echo>
+ <!--
+ compile and run each sample as though the user were running
+ samples from the binary distribution. Here we use ant targets
+ in the first instance but for some tests we may want to run
+ jars directly or fire up webapp containers and deploy wars. In other cases
+ we may need to run two samples together to provide reference and
+ service sides of the sample.
+ -->
+
+ <property name="distro.root" value="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.dir/tuscany-sca-${tuscany.version}" />
+
+ <target name="run">
+
+ <ant antfile="build.xml"
+ dir="${distro.root}/samples/implementation-java/contribution-calculator"/>
+
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/contribution-implementation-java-calculator/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/contribution-implementation-java-calculator/pom.xml
new file mode 100644
index 0000000000..a0a1790c00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/contribution-implementation-java-calculator/pom.xml
@@ -0,0 +1,87 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-contribution-implementation-java-calculator</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution contribution implementation-java Calculator</name>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-trax</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <!-- this JDk dependency is a workaround for Maven bug - http://jira.codehaus.org/browse/MNG-1323 -->
+ <dependency>
+ <groupId>sun.jdk</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.6</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="tuscany.version" value="${version}" />
+ <property name="java.home" value="${java.home}"/>
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-jse/build.xml b/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-jse/build.xml
new file mode 100644
index 0000000000..cd569b380a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-jse/build.xml
@@ -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.
+-->
+<project name="itest-samples" default="run">
+
+ <echo>${java.home}</echo>
+ <!--
+ compile and run each sample as though the user were running
+ samples from the binary distribution. Here we use ant targets
+ in the first instance but for some tests we may want to run
+ jars directly or fire up webapp containers and deploy wars. In other cases
+ we may need to run two samples together to provide reference and
+ service sides of the sample.
+ -->
+
+ <property name="distro.root" value="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.dir/tuscany-sca-${tuscany.version}" />
+
+ <target name="run">
+
+ <ant dir="${distro.root}/samples/launcher-embedded-jse"
+ target="run-contribution-binding-sca-calculator">
+ </ant>
+
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-jse/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-jse/pom.xml
new file mode 100644
index 0000000000..93bd2e3327
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-jse/pom.xml
@@ -0,0 +1,69 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-launcher-embedded-jse</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Launcher Embedded JSE</name>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="java.home" value="${java.home}"/>
+ <property name="tuscany.version" value="${version}" />
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-osgi/build.xml b/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-osgi/build.xml
new file mode 100644
index 0000000000..c6874ed86e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-osgi/build.xml
@@ -0,0 +1,45 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="itest-samples" default="run">
+
+ <echo>${java.home}</echo>
+ <!--
+ compile and run each sample as though the user were running
+ samples from the binary distribution. Here we use ant targets
+ in the first instance but for some tests we may want to run
+ jars directly or fire up webapp containers and deploy wars. In other cases
+ we may need to run two samples together to provide reference and
+ service sides of the sample.
+ -->
+
+ <property name="distro.root" value="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}.dir/tuscany-sca-${tuscany.version}" />
+
+ <target name="run">
+
+<!-- Seems to be hanging in the console at the end of the OSGi run
+ configure it to run no tests for now
+ <ant dir="${distro.root}/samples/launcher-embedded-osgi"
+ target="run-contribution-binding-sca-calculator"/>
+-->
+
+ <ant dir="${distro.root}/samples/launcher-embedded-osgi"/>
+
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-osgi/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-osgi/pom.xml
new file mode 100644
index 0000000000..0e4a97a07f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/launcher-embedded-osgi/pom.xml
@@ -0,0 +1,69 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-launcher-embedded-osgi</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Launcher Embedded OSGi</name>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="java.home" value="${java.home}"/>
+ <property name="tuscany.version" value="${version}" />
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/legal-checks/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/legal-checks/pom.xml
new file mode 100644
index 0000000000..fec631b113
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/legal-checks/pom.xml
@@ -0,0 +1,71 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-legal-checks</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Legal Checks</name>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <version>0.6</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <basedir>../../../distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT.dir</basedir>
+ <excludeSubProjects>false</excludeSubProjects>
+ <excludes>
+ <exclude>tuscany-sca-2.0-SNAPSHOT/CHANGES</exclude>
+ <exclude>**/MANIFEST.MF</exclude>
+ <exclude>**/target/**/*.log</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT/features/configuration/config.ini</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java b/sandbox/sebastien/java/embed/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java
new file mode 100644
index 0000000000..2fdbf62353
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.junit.Test;
+
+/**
+ * Checks that all jar files included in the distribution are mentioned in the LICENSE file
+ * and that all jars mentioned in the LICENSE are in the distribution.
+ */
+public class JarsInLICENSETestCase {
+
+ @Test
+ public void testJars() throws Exception {
+ File distroRoot = getUnzipedDistroRoot();
+
+ File licenseFile = new File(distroRoot, "LICENSE");
+ if (!licenseFile.exists()) {
+ throw new IllegalStateException("can't find LICENSE file at: " + licenseFile.getAbsoluteFile().toString());
+ }
+
+ File libDirectory = new File(distroRoot, "modules");
+ if (!libDirectory.exists()) {
+ throw new IllegalStateException("can't find modules folder at: " + libDirectory.getAbsoluteFile().toString());
+ }
+
+ List<String> jars = getJarsInDistro(libDirectory);
+
+ List<String> bad2 = getLICENSEJarsNotInDistro(licenseFile, jars);
+ if (bad2.size() > 0) {
+ System.err.println("Jars in LICENSE but not in Distribution: " + bad2);
+ }
+
+ List<String> bad1 = getJarsNotInLICENSE(jars, licenseFile);
+ if (bad1.size() > 0) {
+ System.err.println("Jars in distribution but not in LICENSE: " + bad1);
+ }
+
+ if (bad1.size() > 0 || bad2.size() > 0) {
+ throw new IllegalStateException("LICENSE problems, check log");
+ }
+ }
+
+ private List<String> getLICENSEJarsNotInDistro(File licenseFile, List<String> jars) throws IOException {
+ List<String> badJars = new ArrayList<String>();
+ BufferedReader reader = new BufferedReader(new FileReader(licenseFile));
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ if (line.contains(".jar")) {
+ StringTokenizer st = new StringTokenizer(line);
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken();
+ if (s.contains(".jar")) {
+ if (s.startsWith("(")) {
+ s = s.substring(1);
+ }
+ if (s.endsWith(",") || s.endsWith(":")) {
+ s = s.substring(0, s.length()-1);
+ }
+ if (s.endsWith(")")) {
+ s = s.substring(0, s.length()-1);
+ }
+ if (!jars.contains(s) && !s.startsWith("tuscany-")) {
+ badJars.add(s);
+ }
+ }
+ }
+ }
+ }
+ return badJars;
+ }
+
+ private List<String> getJarsNotInLICENSE(List<String> jars, File licenseFile) throws IOException {
+ List<String> badJars = new ArrayList<String>();
+ String licenseText = readLICENSE(licenseFile);
+ for (String jar : jars) {
+ if (!licenseText.contains(jar)) {
+ if (jar.startsWith("tuscany-") || jar.startsWith("sample-") || jar.startsWith("test-") || jar.startsWith("itest-")) {
+ // ignore tuscany jars as they're not mentioned in the LICENSE file
+ } else {
+ badJars.add(jar);
+ }
+ }
+ }
+ return badJars;
+ }
+
+ private List<String> getJarsInDistro(File directory) {
+ List<String> jars = new ArrayList<String>();
+ for (String fn : directory.list()){
+ if (fn.endsWith(".jar")) {
+ jars.add(fn);
+ } else {
+ File f = new File(directory, fn);
+ if (f.isDirectory()) {
+ jars.addAll(getJarsInDistro(f));
+ }
+ }
+ }
+ return jars;
+ }
+
+ private File getUnzipedDistroRoot() {
+ File distroTarget = new File("../../../distribution/all/target");
+ File root = null;
+ for (String f : distroTarget.list()) {
+ if (f.endsWith(".dir")) {
+ root = new File(distroTarget, f);
+ break;
+ }
+ }
+ if (root == null) {
+ throw new IllegalStateException("can't find distro root");
+ }
+ if (root.list().length != 1) {
+ throw new IllegalStateException("expecting one directory in distro root");
+ }
+ root = new File(root, root.list()[0]);
+ return root;
+ }
+
+ private static String readLICENSE(File licenseFile) throws java.io.IOException {
+ StringBuffer fileData = new StringBuffer();
+ BufferedReader reader = new BufferedReader(new FileReader(licenseFile));
+ char[] buf = new char[1024];
+ int numRead = 0;
+ while ((numRead = reader.read(buf)) != -1) {
+ String readData = String.valueOf(buf, 0, numRead);
+ fileData.append(readData);
+ buf = new char[1024];
+ }
+ reader.close();
+ return fileData.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/distribution/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/pom.xml
new file mode 100644
index 0000000000..8c6d99c480
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-distribution</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distribution-all</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>legal-checks</module>
+ <module>contribution-binding-sca-calculator</module>
+ <module>contribution-binding-ws-calculator</module>
+ <module>contribution-binding-rmi-calculator</module>
+ <module>contribution-implementation-java-calculator</module>
+ <module>launcher-embedded-jse</module>
+ <module>launcher-embedded-osgi</module>
+ </modules>
+ </profile>
+
+ <profile>
+ <id>distribution</id>
+ <activation>
+ <property>
+ <name>buildZips</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <modules>
+ <module>src-distro-unzip</module>
+ <module>src-distro-rat</module>
+ <module>bin-distro-unzip</module>
+ <module>legal-checks</module>
+ <module>contribution-binding-sca-calculator</module>
+ <module>contribution-binding-ws-calculator</module>
+ <module>contribution-binding-rmi-calculator</module>
+ <module>contribution-implementation-java-calculator</module>
+ <module>launcher-embedded-jse</module>
+ <module>launcher-embedded-osgi</module>
+ </modules>
+ </profile>
+ </profiles>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/src-distro-rat/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/src-distro-rat/pom.xml
new file mode 100644
index 0000000000..541b1c9830
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/src-distro-rat/pom.xml
@@ -0,0 +1,82 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-src-dsitro-rat</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Src Distro RAT</name>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-src-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <version>0.6</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <basedir>../../../distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT-src.dir</basedir>
+ <excludeSubProjects>false</excludeSubProjects>
+ <excludes>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/CHANGES</exclude>
+ <exclude>**/*.MF</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/compliance-tests/binding-ws/sca_variables.dtd</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/modules.list</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/services/services.list</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas</exclude>
+
+ <!-- these ones we need to implement RAT license processors to handle the non-AL headers, just exclude for now -->
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/assembly-xsd/**/*.*</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/sca-api/**/*.*</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml</exclude>
+ <exclude>tuscany-sca-2.0-SNAPSHOT-src/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/src-distro-unzip/build.xml b/sandbox/sebastien/java/embed/itest/distribution/src-distro-unzip/build.xml
new file mode 100644
index 0000000000..c98e19b6a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/src-distro-unzip/build.xml
@@ -0,0 +1,27 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="itest-unzip" default="unzip">
+
+ <target name="unzip">
+ <delete dir="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}-src.dir"/>
+ <unzip src="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}-src.zip"
+ dest="../../../distribution/all/target/apache-tuscany-sca-all-${tuscany.version}-src.dir"/>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/distribution/src-distro-unzip/pom.xml b/sandbox/sebastien/java/embed/itest/distribution/src-distro-unzip/pom.xml
new file mode 100644
index 0000000000..c4b6e5eb5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/distribution/src-distro-unzip/pom.xml
@@ -0,0 +1,128 @@
+<?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>itest-distribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-src-distro-unzip</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Src Distro Unzip</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distribution-all</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <!-- HACK: use profile to control if we need to add tools.jar -->
+ <!-- Mac OS doesn't have tools.jar -->
+ <profiles>
+ <profile>
+ <id>not-sun-jdk</id>
+ <activation>
+ <file>
+ <missing>${java.home}/../lib/tools.jar</missing>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="java.home" value="${java.home}"/>
+ <property name="tuscany.version" value="${version}" />
+ <ant antfile="./build.xml" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>sun-jdk</id>
+ <activation>
+ <file>
+ <exists>${java.home}/../lib/tools.jar</exists>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-trax</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <!-- this JDk dependency is a workaround for Maven bug - http://jira.codehaus.org/browse/MNG-1323 -->
+ <dependency>
+ <groupId>sun.jdk</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.6</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="java.home" value="${java.home}"/>
+ <property name="tuscany.version" value="${version}" />
+ <ant antfile="./build.xml" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/domains/distributed/pom.xml b/sandbox/sebastien/java/embed/itest/domains/distributed/pom.xml
new file mode 100644
index 0000000000..b568e5ba53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/distributed/pom.xml
@@ -0,0 +1,51 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-domains-distributed</artifactId>
+ <name>Apache Tuscany SCA itest domain distributed</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base-nodep</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/domains/distributed/src/test/java/itest/Helloworld.java b/sandbox/sebastien/java/embed/itest/domains/distributed/src/test/java/itest/Helloworld.java
new file mode 100644
index 0000000000..f764bc8358
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/distributed/src/test/java/itest/Helloworld.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 itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/domains/distributed/src/test/java/itest/StandaloneTestCase.java b/sandbox/sebastien/java/embed/itest/domains/distributed/src/test/java/itest/StandaloneTestCase.java
new file mode 100644
index 0000000000..222b3e8c3a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/distributed/src/test/java/itest/StandaloneTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class StandaloneTestCase{
+
+ @Test
+ public void test1() throws Exception {
+ Node node = NodeFactory.newInstance().createNode(URI.create("tuscany:foo"),"../helloworld/target/itest-domains-helloworld.zip");
+ node.start();
+ assertEquals(1, node.getServiceNames().size());
+ assertEquals("HelloworldComponent/Helloworld", node.getServiceNames().get(0));
+ Helloworld helloworld = SCAClientFactory.newInstance(URI.create("tuscany:foo")).getService(Helloworld.class, "HelloworldComponent");
+ assertEquals("Hello petra", helloworld.sayHello("petra"));
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/domains/helloworld/pom.xml b/sandbox/sebastien/java/embed/itest/domains/helloworld/pom.xml
new file mode 100644
index 0000000000..ab3e8ecd8f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/helloworld/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-domains-helloworld</artifactId>
+ <name>Apache Tuscany SCA itest domain helloworld</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-domains-interfaces</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-3</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-zip-contribution-descriptor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>tuscany-zip-contribution.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
diff --git a/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/java/itest/HelloworldImpl.java b/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/java/itest/HelloworldImpl.java
new file mode 100644
index 0000000000..2a10b3fb77
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/java/itest/HelloworldImpl.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 itest;
+
+import itest.Helloworld;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE") @EagerInit
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ @Init
+ public void init() {
+ System.out.println(sayHello("world"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8939a73d01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://org.apache.tuscany.sca.itest">
+ <deployable composite="itest:helloworld"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..18d064c588
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/helloworld/src/main/resources/helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://org.apache.tuscany.sca.itest"
+ name="helloworld">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="itest.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/domains/interfaces/pom.xml b/sandbox/sebastien/java/embed/itest/domains/interfaces/pom.xml
new file mode 100644
index 0000000000..73ee94fef1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/interfaces/pom.xml
@@ -0,0 +1,51 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-domains-interfaces</artifactId>
+ <name>Apache Tuscany SCA itest domain interfaces</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/domains/interfaces/src/main/java/itest/Helloworld.java b/sandbox/sebastien/java/embed/itest/domains/interfaces/src/main/java/itest/Helloworld.java
new file mode 100644
index 0000000000..f764bc8358
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/interfaces/src/main/java/itest/Helloworld.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 itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/domains/pom.xml b/sandbox/sebastien/java/embed/itest/domains/pom.xml
new file mode 100644
index 0000000000..76286b77bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/pom.xml
@@ -0,0 +1,38 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-domains</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Domians Integration Tests</name>
+
+ <modules>
+ <module>interfaces</module>
+ <module>helloworld</module>
+ <module>standalone</module>
+ <module>distributed</module>
+ </modules>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/domains/standalone/pom.xml b/sandbox/sebastien/java/embed/itest/domains/standalone/pom.xml
new file mode 100644
index 0000000000..d434ce9816
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/standalone/pom.xml
@@ -0,0 +1,57 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-domains-standalone</artifactId>
+ <name>Apache Tuscany SCA itest domain standalone</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- TODO: shouldnt need to have this dependency, should be in DomainNode -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/domains/standalone/src/test/java/itest/StandaloneTestCase.java b/sandbox/sebastien/java/embed/itest/domains/standalone/src/test/java/itest/StandaloneTestCase.java
new file mode 100644
index 0000000000..0fbcc98a96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/domains/standalone/src/test/java/itest/StandaloneTestCase.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.domain.node.DomainNode;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class StandaloneTestCase{
+
+ private static DomainNode node;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ node = new DomainNode();
+ node.addContribution("../helloworld/target/itest-domains-helloworld.zip");
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testServices() throws Exception {
+ assertEquals(1, node.getServiceNames().size());
+ assertEquals("HelloworldComponent/Helloworld", node.getServiceNames().get(0));
+ }
+
+ @Test
+ public void testDuplicateComponents() throws Exception {
+ try {
+ node.addContribution("../helloworld/target/itest-domains-helloworld.zip", "dup");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // verify the old one is still there
+ // TODO: doesn't work correctly yet
+// assertEquals(1, node.getServiceNames().size());
+// assertEquals("HelloworldComponent/Helloworld", node.getServiceNames().get(0));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/endpoints/pom.xml b/sandbox/sebastien/java/embed/itest/endpoints/pom.xml
new file mode 100644
index 0000000000..4a962cfdf2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/endpoints/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-endpoints</artifactId>
+ <name>Apache Tuscany SCA iTest Endpoints</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..c307547f56
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.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 helloworld;
+
+
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..064d615c45
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/helloworld/HelloWorldService.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 helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/EndpointsTestCase.java b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/EndpointsTestCase.java
new file mode 100644
index 0000000000..7802848c3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/EndpointsTestCase.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 test;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.apache.tuscany.sca.http.jetty.JettyServer;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class EndpointsTestCase {
+
+ private static Node node;
+
+ @Test
+ public void testJSONP1() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp />
+ Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent1/HelloWorldService/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP2() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp2"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent2/HelloWorldService/jsonp2/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP3() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp uri="jsonp3"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent3/HelloWorldService/jsonp3/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP4() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp uri="/jsonp4"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp4/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP5() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp5a" uri="/jsonp5b"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp5b/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP6() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp6a" uri="jsonp6b"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent6/HelloWorldService/jsonp6a/jsonp6b/sayHello?name=petra&callback=foo");
+ }
+
+ @Test
+ public void testWS1() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS />
+ Utils.invokeWSEndpoint("http://localhost:8085/WSComponent1/HelloWorldService");
+ }
+ @Test
+ public void testWS2() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS2"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/WSComponent2/HelloWorldService/ws2");
+ }
+ @Test
+ public void testWS3() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="WS3"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/WSComponent3/HelloWorldService/ws3");
+ }
+ @Test
+ public void testWS4() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="/WS4"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/ws4");
+ }
+ @Test
+ public void testWS5() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS5a" uri="/WS5b"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/ws5b");
+ }
+ @Test
+ public void testWS6() throws Exception {
+ // <tuscany:binding.ws name="ws6a" uri="ws6b"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/WSComponent6/HelloWorldService/ws6a/ws6b");
+ }
+
+ @BeforeClass
+ public static void init() throws Exception {
+ JettyServer.portDefault = 8085;
+ node = NodeFactory.newInstance().createNode("helloworld.composite").start();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java
new file mode 100644
index 0000000000..f3b6c15bf1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.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 test;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.apache.tuscany.sca.http.jetty.JettyServer;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class NestedEndpointsTestCase {
+
+ private static Node node;
+
+ @Test
+ public void testJSONP1() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp />
+ Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent1/HelloWorldService/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP2() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp2"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent2/HelloWorldService/jsonp2/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP3() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp uri="jsonp3"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent3/HelloWorldService/jsonp3/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP4() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp uri="/jsonp4"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp4/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP5() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp5a" uri="/jsonp5b"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp5b/sayHello?name=petra&callback=foo");
+ }
+ @Test
+ public void testJSONP6() throws MalformedURLException, IOException {
+ // <tuscany:binding.jsonp name="jsonp6a" uri="jsonp6b"/>
+ Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent6/HelloWorldService/jsonp6a/jsonp6b/sayHello?name=petra&callback=foo");
+ }
+
+ @Test
+ public void testWS1() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS />
+ Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent1/HelloWorldService");
+ }
+ @Test
+ public void testWS2() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS2"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent2/HelloWorldService/ws2");
+ }
+ @Test
+ public void testWS3() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="WS3"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent3/HelloWorldService/ws3");
+ }
+ @Test
+ public void testWS4() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS uri="/WS4"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/ws4");
+ }
+ @Test
+ public void testWS5() throws MalformedURLException, Exception {
+ // <tuscany:binding.WS name="WS5a" uri="/WS5b"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/ws5b");
+ }
+ @Test
+ public void testWS6() throws Exception {
+ // <tuscany:binding.ws name="ws6a" uri="ws6b"/>
+ Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent6/HelloWorldService/ws6a/ws6b");
+ }
+
+ @BeforeClass
+ public static void init() throws Exception {
+ JettyServer.portDefault = 8085;
+ node = NodeFactory.newInstance().createNode("nested.composite").start();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/Utils.java b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/Utils.java
new file mode 100644
index 0000000000..5107d8f660
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/endpoints/src/test/java/test/Utils.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 test;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+
+import junit.framework.Assert;
+
+public class Utils {
+
+ public static void invokeJSONPEndpoint(String s) throws MalformedURLException, IOException {
+ URL url = new URL(s);
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ String response = br.readLine();
+ Assert.assertEquals("foo(\"Hello petra\");", response);
+ }
+
+ public static void invokeWSEndpoint(String endpoint) throws Exception {
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL(endpoint + "?wsdl");
+ Assert.assertNotNull(definition);
+ Service service = (Service)definition.getServices().values().iterator().next();
+ Port port = (Port)service.getPorts().values().iterator().next();
+
+ Assert.assertEquals(new URL(endpoint).getPath(), new URL(getEndpoint(port)).getPath());
+ }
+
+ private static String getEndpoint(Port port) {
+ List<?> wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/endpoints/src/test/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/endpoints/src/test/resources/helloworld.composite
new file mode 100644
index 0000000000..1f56c3d73b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/endpoints/src/test/resources/helloworld.composite
@@ -0,0 +1,116 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="HelloWorldComposite">
+
+ <component name="JSONPComponent1">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp />
+ </service>
+ </component>
+
+ <component name="JSONPComponent2">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp name="jsonp2"/>
+ </service>
+ </component>
+
+ <component name="JSONPComponent3">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp uri="jsonp3"/>
+ </service>
+ </component>
+
+ <component name="JSONPComponent4">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp uri="/jsonp4"/>
+ </service>
+ </component>
+
+ <component name="JSONPComponent5">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp name="jsonp5a" uri="/jsonp5b"/>
+ </service>
+ </component>
+
+ <component name="JSONPComponent6">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp name="jsonp6a" uri="jsonp6b"/>
+ </service>
+ </component>
+
+ <component name="RMIComponent6">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.rmi name="rmi6a" uri="rmi6b"/>
+ </service>
+ </component>
+
+ <component name="WSComponent1">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws />
+ </service>
+ </component>
+
+ <component name="WSComponent2">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws name="ws2"/>
+ </service>
+ </component>
+
+ <component name="WSComponent3">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws uri="ws3"/>
+ </service>
+ </component>
+
+ <component name="WSComponent4">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws uri="/ws4"/>
+ </service>
+ </component>
+
+ <component name="WSComponent5">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws name="ws5a" uri="/ws5b"/>
+ </service>
+ </component>
+
+ <component name="WSComponent6">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <binding.ws name="ws6a" uri="ws6b"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/endpoints/src/test/resources/nested.composite b/sandbox/sebastien/java/embed/itest/endpoints/src/test/resources/nested.composite
new file mode 100644
index 0000000000..138020eab0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/endpoints/src/test/resources/nested.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:itest="http://itest"
+ targetNamespace="http://itest"
+ name="NestedComposite">
+
+ <component name="NestedComponent1">
+ <implementation.composite name="itest:HelloWorldComposite"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/pom.xml b/sandbox/sebastien/java/embed/itest/exceptions/pom.xml
new file mode 100644
index 0000000000..41dd198009
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-exceptions</artifactId>
+ <name>Apache Tuscany SCA iTest Exceptions</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java
new file mode 100644
index 0000000000..1f57116bac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.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.test.exceptions;
+
+public class Checked extends Exception {
+ private static final long serialVersionUID = -129752837478357452L;
+
+ /**
+ *
+ */
+ public Checked() {
+
+ }
+
+ /**
+ * @param message
+ */
+ public Checked(String message) {
+ super(message);
+
+ }
+
+ /**
+ * @param cause
+ */
+ public Checked(Throwable cause) {
+ super(cause);
+
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public Checked(String message, Throwable cause) {
+ super(message, cause);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java
new file mode 100644
index 0000000000..112aefc747
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.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.test.exceptions;
+
+public interface ExceptionHandler {
+
+ void testing();
+
+ Checked getTheBad();
+
+ String getTheGood();
+
+ UnChecked getTheUgly();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java
new file mode 100644
index 0000000000..53a6c70b57
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.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.test.exceptions;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Remote exception thrower
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface ExceptionRemoteThrower extends ExceptionThrower {
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java
new file mode 100644
index 0000000000..ace219991b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.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.sca.test.exceptions;
+
+/**
+ * Local exception thrower
+ * @version $Rev$ $Date$
+ */
+public interface ExceptionThrower {
+ Checked BAD = new Checked("theBad");
+ UnChecked UGLY = new UnChecked("theUgly");
+ String SO_THEY_SAY = "All is good that ends good.";
+
+ String theGood() throws Checked;
+
+ String theBad() throws Checked;
+
+ String theUgly() throws Checked;
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java
new file mode 100644
index 0000000000..453528444d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.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.test.exceptions;
+
+public class UnChecked extends RuntimeException {
+ private static final long serialVersionUID = -1318118082838092244L;
+
+ /**
+ *
+ */
+ public UnChecked() {
+
+ }
+
+ /**
+ * @param message
+ */
+ public UnChecked(String message) {
+ super(message);
+
+ }
+
+ /**
+ * @param cause
+ */
+ public UnChecked(Throwable cause) {
+ super(cause);
+
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public UnChecked(String message, Throwable cause) {
+ super(message, cause);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java
new file mode 100644
index 0000000000..26b9f0a383
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.exceptions.impl;
+
+import org.apache.tuscany.sca.test.exceptions.Checked;
+import org.apache.tuscany.sca.test.exceptions.ExceptionHandler;
+import org.apache.tuscany.sca.test.exceptions.ExceptionThrower;
+import org.apache.tuscany.sca.test.exceptions.UnChecked;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class ExceptionHandlerImpl implements ExceptionHandler {
+ static final String INIT = "INIT";
+
+ private ExceptionThrower exceptionThrower;
+
+ private String theGood;
+
+ private Checked theBad;
+
+ private UnChecked theUgly;
+
+ public void testing() {
+
+ assert exceptionThrower != null : "'exceptionThrower' never wired";
+ String result = INIT;
+ try {
+ theGood = result = exceptionThrower.theGood();
+ assert result == ExceptionThrower.SO_THEY_SAY;
+ } catch (Throwable e) {
+ assert result == INIT;
+ assert false;
+ e.printStackTrace();
+ }
+
+ result = INIT;
+ try {
+ result = exceptionThrower.theBad();
+ // incredible
+ assert false : "Expected 'Check' Exception";
+
+ } catch (Checked e) {
+ // This is good...
+ assert result == INIT;
+ theBad = e;
+ } catch (Throwable t) {
+ // This is not so good.
+ t.printStackTrace();
+ assert result == INIT;
+ assert false : "Got wrong exception '" + t.getClass().getName();
+ }
+
+ result = INIT;
+ try {
+ result = exceptionThrower.theUgly();
+ // incredible
+ assert false : "Expected 'UnCheck' Exception";
+
+ } catch (Checked e) {
+ // This is not so good...
+ assert false : "Got wrong exception '" + e.getClass().getName();
+ assert result == INIT;
+ } catch (UnChecked e) {
+ theUgly = e;
+
+ } catch (Throwable t) {
+ // This is not good.
+ assert false;
+ assert result == INIT;
+
+ System.out.println(ExceptionThrower.SO_THEY_SAY + " " + INIT);
+ }
+
+ }
+
+ @Reference
+ public void setExceptionThrower(ExceptionThrower exceptionThrower) {
+ this.exceptionThrower = exceptionThrower;
+ }
+
+ public String getTheGood() {
+ return theGood;
+ }
+
+ public Checked getTheBad() {
+ return theBad;
+ }
+
+ public UnChecked getTheUgly() {
+ return theUgly;
+ }
+
+ public ExceptionThrower getExceptionThrower() {
+ return exceptionThrower;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java
new file mode 100644
index 0000000000..cd62338841
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.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.test.exceptions.impl;
+
+import org.apache.tuscany.sca.test.exceptions.Checked;
+import org.apache.tuscany.sca.test.exceptions.ExceptionRemoteThrower;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(ExceptionRemoteThrower.class)
+public class ExceptionRemoteThrowerImpl implements ExceptionRemoteThrower {
+ public String theBad() throws Checked {
+ throw BAD;
+ }
+
+ public String theGood() throws Checked {
+ return SO_THEY_SAY;
+ }
+
+ public String theUgly() throws Checked {
+ throw UGLY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java
new file mode 100644
index 0000000000..56b9fc6f5b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.exceptions.impl;
+
+import org.apache.tuscany.sca.test.exceptions.Checked;
+import org.apache.tuscany.sca.test.exceptions.ExceptionThrower;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(ExceptionThrower.class)
+public class ExceptionThrowerImpl implements ExceptionThrower {
+
+ public String theBad() throws Checked {
+ throw BAD;
+ }
+
+ public String theGood() throws Checked {
+ return SO_THEY_SAY;
+ }
+
+ public String theUgly() throws Checked {
+ throw UGLY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java
new file mode 100644
index 0000000000..c5b54ff902
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.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.sca.test.exceptions.impl;
+
+import org.apache.tuscany.sca.test.exceptions.Checked;
+import org.apache.tuscany.sca.test.exceptions.ExceptionHandler;
+import org.apache.tuscany.sca.test.exceptions.ExceptionRemoteThrower;
+import org.apache.tuscany.sca.test.exceptions.ExceptionThrower;
+import org.apache.tuscany.sca.test.exceptions.UnChecked;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class RemoteExceptionHandlerImpl implements ExceptionHandler {
+ static final String INIT = "INIT";
+
+ private ExceptionRemoteThrower exceptionThrower;
+
+ private String theGood;
+
+ private Checked theBad;
+
+ private UnChecked theUgly;
+
+ public void testing() {
+
+ assert exceptionThrower != null : "'exceptionThrower' never wired";
+ String result = INIT;
+ try {
+ theGood = result = exceptionThrower.theGood();
+ assert result == ExceptionThrower.SO_THEY_SAY;
+ } catch (Throwable e) {
+ assert result == INIT;
+ assert false;
+ e.printStackTrace();
+ }
+
+ result = INIT;
+ try {
+ result = exceptionThrower.theBad();
+ // incredible
+ assert false : "Expected 'Check' Exception";
+
+ } catch (Checked e) {
+ // This is good...
+ assert result == INIT;
+ theBad = e;
+ } catch (Throwable t) {
+ // This is not so good.
+ t.printStackTrace();
+ assert result == INIT;
+ assert false : "Got wrong exception '" + t.getClass().getName();
+ }
+
+ result = INIT;
+ try {
+ result = exceptionThrower.theUgly();
+ // incredible
+ assert false : "Expected 'UnCheck' Exception";
+
+ } catch (Checked e) {
+ // This is not so good...
+ assert false : "Got wrong exception '" + e.getClass().getName();
+ assert result == INIT;
+ } catch (UnChecked e) {
+ theUgly = e;
+
+ } catch (Throwable t) {
+ // This is not good.
+ assert false;
+ assert result == INIT;
+
+ System.out.println(ExceptionThrower.SO_THEY_SAY + " " + INIT);
+ }
+
+ }
+
+ @Reference
+ public void setExceptionThrower(ExceptionRemoteThrower exceptionThrower) {
+ this.exceptionThrower = exceptionThrower;
+ }
+
+ public String getTheGood() {
+ return theGood;
+ }
+
+ public Checked getTheBad() {
+ return theBad;
+ }
+
+ public UnChecked getTheUgly() {
+ return theUgly;
+ }
+
+ public ExceptionRemoteThrower getExceptionThrower() {
+ return exceptionThrower;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/main/resources/ExceptionTest.composite b/sandbox/sebastien/java/embed/itest/exceptions/src/main/resources/ExceptionTest.composite
new file mode 100644
index 0000000000..b8a8b01e8b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/main/resources/ExceptionTest.composite
@@ -0,0 +1,41 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="ExceptionTest">
+ <component name="main">
+ <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.ExceptionHandlerImpl" />
+ <reference name="exceptionThrower" target="exceptionThrower" />
+ </component>
+
+ <component name="exceptionThrower">
+ <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.ExceptionThrowerImpl" />
+ </component>
+
+ <component name="mainRemote">
+ <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.RemoteExceptionHandlerImpl" />
+ <reference name="exceptionThrower" target="exceptionThrowerRemote" />
+ </component>
+
+ <component name="exceptionThrowerRemote">
+ <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.ExceptionRemoteThrowerImpl" />
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java b/sandbox/sebastien/java/embed/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java
new file mode 100644
index 0000000000..7794348476
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.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.sca.test.exceptions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ExceptionsTestCase {
+
+ private static Node node;
+
+ /**
+ * Test exception handling over a local interface
+ */
+ @Test
+ public void testLocal() {
+ ExceptionHandler exceptionHandler = node.getService(ExceptionHandler.class, "main");
+ exceptionHandler.testing();
+ assertEquals(ExceptionThrower.SO_THEY_SAY, exceptionHandler.getTheGood());
+ assertNotNull(exceptionHandler.getTheBad());
+ assertEquals(Checked.class, exceptionHandler.getTheBad().getClass());
+ assertSame(ExceptionThrower.BAD, exceptionHandler.getTheBad());
+ assertNotNull(exceptionHandler.getTheUgly());
+ assertEquals(UnChecked.class, exceptionHandler.getTheUgly().getClass());
+ assertSame(ExceptionThrower.UGLY, exceptionHandler.getTheUgly());
+ }
+
+ /**
+ * Test exception handling over a remotable interface
+ */
+ @Test
+ public void testRemote() {
+ ExceptionHandler exceptionHandler = node.getService(ExceptionHandler.class, "mainRemote");
+ exceptionHandler.testing();
+ assertEquals(ExceptionThrower.SO_THEY_SAY, exceptionHandler.getTheGood());
+ assertNotNull(exceptionHandler.getTheBad());
+ assertEquals(Checked.class, exceptionHandler.getTheBad().getClass());
+ assertNotSame(ExceptionThrower.BAD, exceptionHandler.getTheBad());
+ assertNotNull(exceptionHandler.getTheUgly());
+ assertEquals(UnChecked.class, exceptionHandler.getTheUgly().getClass());
+
+ // [rfeng] We're not in a position to copy non business exceptions
+ // assertNotSame(ExceptionThrower.UGLY, exceptionHandler.getTheUgly());
+
+ }
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("ExceptionTest.composite");
+ node = NodeFactory.newInstance().createNode("ExceptionTest.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/pom.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/pom.xml
new file mode 100644
index 0000000000..ac5265d026
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/pom.xml
@@ -0,0 +1,92 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-implementation-spring</artifactId>
+ <name>Apache Tuscany SCA iTest Spring Implementation</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Spring dependencies... -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java
new file mode 100644
index 0000000000..bd7770ca7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.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 bigbank.stockquote;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the StockQuote service.
+ */
+@Service(StockQuoteService.class)
+public class StockQuoteImpl implements StockQuoteService {
+
+ public double getQuote(String symbol) {
+ double price = 104.0 + Math.random();
+ price = ((int)(price * 100)) / 100.0;
+
+ System.out.println("Getting stock quote for: " + symbol + ", value: "+ price);
+
+ return price;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..747433a9e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.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 bigbank.stockquote;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the StockQuote service.
+ */
+@Remotable
+public interface StockQuoteService {
+
+ public double getQuote(String symbol);
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/AddService.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 calculator;
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..eae607a7ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..ce1cdaae5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..b033516c1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.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 calculator;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ public AddService getAddService() {
+ return addService;
+ }
+
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ public SubtractService getSubtractService() {
+ return subtractService;
+ }
+
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ public DivideService getDivideService() {
+ return divideService;
+ }
+
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public MultiplyService getMultiplyService() {
+ return multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..1323edf55a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..91b803bc9e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..58cc4a3547
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java
new file mode 100644
index 0000000000..4f063993a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.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 calculator.security;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CalculatorCallbackHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] instanceof NameCallback) {
+ NameCallback nc = (NameCallback)callbacks[i];
+ nc.setName("CalculatorUser");
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ PasswordCallback pc = (PasswordCallback)callbacks[i];
+ pc.setPassword("CalculatorUserPasswd".toCharArray());
+ } else {
+ throw new UnsupportedCallbackException
+ (callbacks[i], "Unsupported Callback!");
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java
new file mode 100644
index 0000000000..b3ef6e7312
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.security;
+
+import java.security.Principal;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JaasLoginModule implements LoginModule {
+
+ private CallbackHandler callbackHandler;
+ private Subject subject;
+ private Principal userPrincipal;
+ private String userId;
+ private String password;
+ private boolean succeeded;
+ private boolean commitSucceeded;
+
+ public void initialize(Subject subject,
+ CallbackHandler callbackHandler,
+ Map<String, ?> sharedState,
+ Map<String, ?> options) {
+ this.callbackHandler = callbackHandler;
+ this.subject = subject;
+ }
+
+ public boolean login() throws LoginException {
+ Callback[] callbacks = new Callback[2];
+ callbacks[0] = new NameCallback("UserId:");
+ callbacks[1] = new PasswordCallback("Password:", false);
+
+ try {
+ callbackHandler.handle(callbacks);
+ userId = ((NameCallback)callbacks[0]).getName();
+ password = new String(((PasswordCallback)callbacks[1]).getPassword());
+
+ if (userId.equals("CalculatorUser") && password.equals("CalculatorUserPasswd")) {
+ System.out.println("Successfully AUTHENTICATED!!");
+ succeeded = true;
+ return true;
+ } else {
+ System.out.println("Incorrect userId / password! AUTHENTICATION FAILED!!");
+ return false;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * <p> This method is called if the LoginContext's
+ * overall authentication succeeded
+ * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules
+ * succeeded).
+ *
+ * <p> If this LoginModule's own authentication attempt
+ * succeeded (checked by retrieving the private state saved by the
+ * <code>login</code> method), then this method associates a
+ * <code>UserPrincipal</code>
+ * with the <code>Subject</code> located in the
+ * <code>LoginModule</code>. If this LoginModule's own
+ * authentication attempted failed, then this method removes
+ * any state that was originally saved.
+ *
+ * <p>
+ *
+ * @exception LoginException if the commit fails.
+ *
+ * @return true if this LoginModule's own login and commit
+ * attempts succeeded, or false otherwise.
+ */
+ public boolean commit() throws LoginException {
+ if (succeeded == false) {
+ return false;
+ } else {
+ // add a Principal (authenticated identity) to the Subject
+
+ // assume the user we authenticated is the UserPrincipal
+ userPrincipal = new UserPrincipal(userId);
+ if (!subject.getPrincipals().contains(userPrincipal))
+ subject.getPrincipals().add(userPrincipal);
+
+ // in any case, clean out state
+ userId = null;
+ password = null;
+ commitSucceeded = true;
+ return true;
+ }
+ }
+
+ /**
+ * <p> This method is called if the LoginContext's
+ * overall authentication failed.
+ * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules
+ * did not succeed).
+ *
+ * <p> If this LoginModule's own authentication attempt
+ * succeeded (checked by retrieving the private state saved by the
+ * <code>login</code> and <code>commit</code> methods),
+ * then this method cleans up any state that was originally saved.
+ *
+ * <p>
+ *
+ * @exception LoginException if the abort fails.
+ *
+ * @return false if this LoginModule's own login and/or commit attempts
+ * failed, and true otherwise.
+ */
+ public boolean abort() throws LoginException {
+ if (succeeded == false) {
+ return false;
+ } else if (succeeded == true && commitSucceeded == false) {
+ // login succeeded but overall authentication failed
+ succeeded = false;
+ userId = null;
+ password = null;
+ userPrincipal = null;
+ } else {
+ // overall authentication succeeded and commit succeeded,
+ // but someone else's commit failed
+ logout();
+ }
+ return true;
+ }
+
+ /**
+ * Logout the user.
+ *
+ * <p> This method removes the <code>SimplePrincipal</code>
+ * that was added by the <code>commit</code> method.
+ *
+ * <p>
+ *
+ * @exception LoginException if the logout fails.
+ *
+ * @return true in all cases since this <code>LoginModule</code>
+ * should not be ignored.
+ */
+ public boolean logout() throws LoginException {
+ subject.getPrincipals().remove(userPrincipal);
+ succeeded = false;
+ succeeded = commitSucceeded;
+ userId = null;
+ if (password != null)
+ password = null;
+ userPrincipal = null;
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java
new file mode 100644
index 0000000000..595626e672
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 calculator.security;
+
+import java.security.Principal;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UserPrincipal implements Principal {
+
+ private final String name;
+
+ public UserPrincipal(String name) {
+ if (name == null)
+ throw new IllegalArgumentException("name cannot be null");
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final UserPrincipal other = (UserPrincipal)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java
new file mode 100644
index 0000000000..968d420fc8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.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 context.access;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class SCAApplicationContextProvider implements ApplicationContextAware {
+
+ private static ApplicationContext ctx;
+
+ public void setApplicationContext(ApplicationContext appContext) throws BeansException {
+ // Wiring the ApplicationContext into a static method
+ ctx = appContext;
+ }
+
+ public static ApplicationContext getApplicationContext() {
+ return ctx;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..8bb3006d12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorld.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.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Interface for the "hello world" service - predictably simple with a single operation
+ * "sayHello"
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface HelloWorld {
+
+ String sayHello(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..f68134702b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.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 helloworld;
+
+/**
+ * A simple proxy Java class which implements the HelloWorld interface but which uses
+ * a reference "delegate" to actually provide the HelloWorld service
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldImpl implements HelloWorld {
+
+ static String hello = "Hello ";
+
+ public String sayHello(String s) {
+ // Simply call the reference to satisfy the service request...
+ System.out.println("HelloWorldImpl - sayHello called");
+ return (hello + s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java
new file mode 100644
index 0000000000..78b3649b5b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.oasisopen.sca.annotation.Reference;
+
+/**
+ * A simple proxy Java class which implements the HelloWorld interface but which uses
+ * a reference "delegate" to actually provide the HelloWorld service
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldProxy implements HelloWorld {
+
+ // Here is the reference "delegate" - it implements the HelloWorld interface...
+ @Reference
+ public HelloWorld delegate;
+
+ public String sayHello(String s) {
+ // Simply call the reference to satisfy the service request...
+ System.out.println("HelloWorldProxy - calling sayHello");
+ return delegate.sayHello(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestBean.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestBean.java
new file mode 100644
index 0000000000..1a0abd7f8f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestBean.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 mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TestBean {
+ String echo(String msg);
+
+ TestBean getBean();
+
+ void setBean(TestBean bean);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java
new file mode 100644
index 0000000000..e3d9a36bb8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestBeanImpl implements TestBean {
+
+ private TestBean bean;
+
+ public TestBeanImpl() {
+ }
+
+ public String echo(String msg) {
+ return msg;
+ }
+
+ public TestBean getBean() {
+ return bean;
+ }
+
+ public void setBean(TestBean bean) {
+ this.bean = bean;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java
new file mode 100644
index 0000000000..47342fded8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.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 mock;
+
+/**
+ * A simple test Spring bean which provides the HelloWorld service
+ *
+ * @version $Rev$ $Date$
+ */
+
+import helloworld.HelloWorld;
+
+public class TestHelloWorldBean implements HelloWorld {
+
+ static String hello = "Hello ";
+
+ // Classic "Hello xxx" response to any input message
+ public String sayHello(String message) {
+ System.out.println("TestHelloWorldBean - sayHello called");
+ return (hello + message);
+ }
+
+} // end class TestHelloWorldBean
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestReference.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestReference.java
new file mode 100644
index 0000000000..6f5b280f31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestReference.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TestReference {
+ String echo(String msg);
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java
new file mode 100644
index 0000000000..dea7933e1a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestReferenceBean.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 mock;
+
+/**
+ * A test Spring bean which provides the HelloWorld service by calling a reference
+ * to provide the content of the response
+ *
+ * @version $Rev$ $Date$
+ */
+
+import helloworld.HelloWorld;
+
+public class TestReferenceBean implements HelloWorld {
+
+ // The reference
+ private HelloWorld bean;
+
+ // Classic "Hello xxx" response to any input message
+ public String sayHello(String message) {
+ System.out.println("TestReferenceBean - sayHello called");
+ return (bean.sayHello(message));
+ }
+
+ /**
+ * Setter for the bean reference
+ * @param theBean
+ */
+ public void setBean(HelloWorld theBean) {
+ this.bean = theBean;
+ }
+
+ /**
+ * Getter for the reference
+ * @return
+ */
+ public HelloWorld getBean() {
+ return this.bean;
+ }
+
+} // end class TestReferenceBean
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java
new file mode 100644
index 0000000000..b80b05dc08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package mock;
+
+/**
+ * A test Spring bean which provides the HelloWorld service.
+ * This bean has a single String property called "hello" which must be set through
+ * external configuration to give the correct response message, otherwise an (incorrect)
+ * default message is generated
+ *
+ * @version $Rev$ $Date$
+ */
+
+import helloworld.HelloWorld;
+
+public class TestSCAPropertyBean implements HelloWorld {
+
+ private String hello = "Go away";
+
+ /**
+ * Provides the operation of the "HelloWorld" interface - a simple string response
+ * to a string input message, where the response is a greeting followed by the original
+ * input message.
+ */
+ public String sayHello(String message) {
+ System.out.println("TestHelloWorldBean - sayHello called");
+ return (hello + " " + message);
+ }
+
+ /**
+ * Public setter for the (unannotated) field "hello" which constitutes an SCA
+ * property
+ * @param message - the message to use for the response to "sayHello"
+ */
+ public void setHello(String message) {
+ hello = message;
+ }
+
+} // end class TestSCAPropertyBean
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..544b39ad58
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 spring.annotations;
+
+import org.oasisopen.sca.annotation.ComponentName;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+import calculator.AddService;
+import calculator.CalculatorService;
+import calculator.DivideService;
+import calculator.MultiplyService;
+import calculator.SubtractService;
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Service(CalculatorService.class)
+public class CalculatorServiceImpl implements AddService, SubtractService, MultiplyService, DivideService {
+
+ public AddService addService; // setter injection
+
+ @Reference
+ public SubtractService subtractService; // field injection
+
+ @Reference(name="multiplyService", required=false)
+ public MultiplyService multiply; // field injection (different reference and field name)
+
+ public DivideService divide; // setter injection (different reference and field name)
+
+ public String message; // setter injection
+
+ @Property(name="message", required=false)
+ public String message2; // field injection
+
+ public String componentName;
+
+ @Init
+ public void initMethod () {
+ System.out.println("Init method is sucessfully called.....");
+ // Property value should be null here.
+ System.out.println("Property Value message is...." + message);
+ }
+
+ @Destroy
+ public void destroyMethod () {
+ System.out.println("Component Name is...." + componentName);
+ System.out.println("Property Value message is...." + message);
+ System.out.println("Property Value message2 is...." + message2);
+ System.out.println("Destroy method is sucessfully called.....");
+ }
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ public AddService getAddService() {
+ return addService;
+ }
+
+ /*public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ public SubtractService getSubtractService() {
+ return subtractService;
+ }*/
+
+ @Reference(name="divideService", required=false)
+ public void setDivideService(DivideService divide) {
+ this.divide = divide;
+ }
+
+ public DivideService getDivideService() {
+ return divide;
+ }
+
+ /*public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public MultiplyService getMultiplyService() {
+ return multiplyService;
+ }*/
+
+ @ComponentName
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ @Property
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiply.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divide.divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml
new file mode 100644
index 0000000000..81d59432b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <sca:service name="CalculatorService"
+ type="calculator.CalculatorService" target="CalculatorServiceBean"/>
+
+ <bean id="CalculatorServiceBean" class="calculator.CalculatorServiceImpl">
+ <property name="addService" ref="addService"/>
+ <property name="subtractService" ref="subtractService"/>
+ <property name="multiplyService" ref="multiplyService"/>
+ <property name="divideService" ref="divideService"/>
+ </bean>
+
+ <bean id="contextAccess" class="context.access.SCAApplicationContextProvider">
+ </bean>
+
+ <sca:reference name="addService" type="calculator.AddService"/>
+ <sca:reference name="subtractService" type="calculator.SubtractService"/>
+ <sca:reference name="multiplyService" type="calculator.MultiplyService"/>
+ <sca:reference name="divideService" type="calculator.DivideService"/>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite
new file mode 100644
index 0000000000..f5514bad0a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://contextaccess"
+ xmlns:sample="http://contextaccess"
+ name="ContextAccess"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.spring location="CalculatorService-context.xml"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite
new file mode 100644
index 0000000000..27df510da8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://contextimports"
+ xmlns:sample="http://contextimports"
+ name="ContextImports"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.spring location="META-INF/spring/SpringImport-context.xml"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml
new file mode 100644
index 0000000000..c50f0ef4d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="CalculatorServiceBean" class="calculator.CalculatorServiceImpl">
+ <property name="addService" ref="addService"/>
+ <property name="subtractService" ref="subtractService"/>
+ <property name="multiplyService" ref="multiplyService"/>
+ <property name="divideService" ref="divideService"/>
+ </bean>
+
+ <sca:reference name="addService" type="calculator.AddService"/>
+ <sca:reference name="subtractService" type="calculator.SubtractService"/>
+ <sca:reference name="multiplyService" type="calculator.MultiplyService"/>
+ <sca:reference name="divideService" type="calculator.DivideService"/>
+
+</beans>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml
new file mode 100644
index 0000000000..a0bb10e8dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml
@@ -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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <import resource="CalculatorService-context.xml"/>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite
new file mode 100644
index 0000000000..5973484f6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://stockquote"
+ xmlns:hw="http://stockquote"
+ name="MultipleContext">
+
+ <component name="StockQuoteServiceComponent">
+ <implementation.spring location="springapp"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9267f28e83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Spring-Context: META-INF/spring/beanRefContext.xml; META-INF/spring/StockQuoteService-context.xml
+
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml
new file mode 100644
index 0000000000..62e4e077b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml
@@ -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.
+-->
+<!-- Application context for the SpringHelloWorld testcase -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="testBean" class="org.apache.tuscany.sca.itest.spring.TestHelloWorldBean" lazy-init="true">
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml
new file mode 100644
index 0000000000..5b1885d6b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <sca:service name="StockQuoteService"
+ type="bigbank.stockquote.StockQuoteService" target="StockQuoteServiceBean"/>
+
+ <bean id="StockQuoteServiceBean" class="bigbank.stockquote.StockQuoteImpl">
+ </bean>
+
+ <bean id="applicationContextProvider" class="context.access.SCAApplicationContextProvider">
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml
new file mode 100644
index 0000000000..dcc88f6770
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="beanRefFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
+ <constructor-arg>
+ <list>
+ <value>context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml</value>
+ </list>
+ </constructor-arg>
+ </bean>
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config
new file mode 100644
index 0000000000..0e7cb86633
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config
@@ -0,0 +1,3 @@
+Calculator {
+ calculator.security.JaasLoginModule required debug=true;
+};
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties
new file mode 100644
index 0000000000..0238f0b013
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties
@@ -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.
+CALLING_OPERATION=Inovoking operation {0} with arguments {1}
+OPERATION_RETURNED=Returning from operation {0} with return value {1} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite
new file mode 100644
index 0000000000..5ffeda11df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite
@@ -0,0 +1,58 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.spring location="META-INF/spring/CalculatorService-context.xml"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" policySets="tuscany:JaasPolicy"/>
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent" policySets="tuscany:JaasPolicy">
+ <implementation.java class="calculator.MultiplyServiceImpl" />
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <component name="AnotherCalculatorServiceComponent">
+ <implementation.spring location="META-INF/spring/CalculatorService-context.xml" requires="tuscany:logging"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" policySets="tuscany:JaasPolicy"/>
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/definitions.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/definitions.xml
new file mode 100644
index 0000000000..efc2464425
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/definitions.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:calc="http://calculator">
+
+ <intent name="logging" constrains="sca:implementation" intentType="implementation"/>
+
+ <!-- PolicySets -->
+ <policySet name="JaasPolicy" provides="tuscany:jaasAuthentication" appliesTo="//sca:binding">
+<!-- empty policy set so that intents are resolved and match works but without including
+ any actual policy runtime artifacts
+ <tuscany:jaasAuthentication>
+ <tuscany:configurationName>Calculator</tuscany:configurationName>
+ <tuscany:callbackHandler>calculator.security.CalculatorCallbackHandler</tuscany:callbackHandler>
+ </tuscany:jaasAuthentication>
+-->
+ </policySet>
+
+
+ <!-- PolicySets -->
+
+ <policySet name="JDKLoggingPolicy"
+ provides="tuscany:logging"
+ appliesTo="//sca:implementation.spring"
+ attachTo="//sca:implementation.spring">
+<!-- empty policy set so that intents are resolved and match works but without including
+ any actual policy runtime artifacts
+ <tuscany:jdkLogger name="calculator">
+ <logLevel>FINER</logLevel>
+ </tuscany:jdkLogger>
+-->
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml
new file mode 100644
index 0000000000..c50f0ef4d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="CalculatorServiceBean" class="calculator.CalculatorServiceImpl">
+ <property name="addService" ref="addService"/>
+ <property name="subtractService" ref="subtractService"/>
+ <property name="multiplyService" ref="multiplyService"/>
+ <property name="divideService" ref="divideService"/>
+ </bean>
+
+ <sca:reference name="addService" type="calculator.AddService"/>
+ <sca:reference name="subtractService" type="calculator.SubtractService"/>
+ <sca:reference name="multiplyService" type="calculator.MultiplyService"/>
+ <sca:reference name="divideService" type="calculator.DivideService"/>
+
+</beans>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite
new file mode 100644
index 0000000000..e889d84544
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite
@@ -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.
+-->
+<!-- Composite for the SpringSCAPropertyTestCase
+ * This composite has the HelloWorldComponent implemented with a Spring implementation where
+ * the Spring application context uses an explicit SCA property. The value of the property
+ * is set in this composite and is used to compute the response to a service invocation from
+ * the ClientComponent.
+ -->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://SpringFolderLocation"
+ name="SpringFolderLocation">
+
+ <component name="ClientComponent">
+ <implementation.java class="helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.spring location="springapp"/>
+ <property name="TestProperty">Hello</property>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..950dbeba4c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Spring-Context: META-INF/spring/SpringSCAProperty-context.xml
+
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml
new file mode 100644
index 0000000000..8613e6c82a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+<!-- Application context for the SpringHelloWorld testcase -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="testBean" class="mock.TestSCAPropertyBean" lazy-init="true">
+ <property name="hello" ref="TestProperty"/>
+ </bean>
+
+ <sca:property id="foo" name="TestProperty" type="java.lang.String"/>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite
new file mode 100644
index 0000000000..b7281272da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite
@@ -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.
+-->
+<!-- Composite for the SpringSCAPropertyTestCase
+ * This composite has the HelloWorldComponent implemented with a Spring implementation where
+ * the Spring application context uses an explicit SCA property. The value of the property
+ * is set in this composite and is used to compute the response to a service invocation from
+ * the ClientComponent.
+ -->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://SpringJarLocation"
+ name="SpringJarLocation">
+
+ <component name="ClientComponent">
+ <implementation.java class="helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.spring location="spring-context.jar"/>
+ <property name="TestProperty">Hello</property>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar
new file mode 100644
index 0000000000..504d59e5ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml
new file mode 100644
index 0000000000..9912624870
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<!-- Application context for the SpringHelloWorld testcase -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <sca:service name="HelloWorld" type="helloworld.HelloWorld" target="testBean"/>
+
+ <bean id="delegateBean"
+ class="org.apache.tuscany.sca.itest.spring.TestHelloWorldBean" lazy-init="true">
+ </bean>
+
+ <bean id="testBean"
+ class="org.apache.tuscany.sca.itest.spring.TestHelloWorldDelegatorBean" lazy-init="true">
+ <property name="delegate"><ref bean="delegateBean"/></property>
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml
new file mode 100644
index 0000000000..62e4e077b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml
@@ -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.
+-->
+<!-- Application context for the SpringHelloWorld testcase -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="testBean" class="org.apache.tuscany.sca.itest.spring.TestHelloWorldBean" lazy-init="true">
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite
new file mode 100644
index 0000000000..e9f8bb888b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://SpringDelegationHelloWorld"
+ name="SpringDelegationHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.spring.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.spring location="META-INF/spring/SpringDelegationHelloWorld-context.xml"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite
new file mode 100644
index 0000000000..30719684a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="SpringHelloWorld"
+ name="SpringHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.spring.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.spring location="META-INF/spring/SpringHelloWorld-context.xml"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml
new file mode 100644
index 0000000000..1705164104
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml
@@ -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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="testBean" class="mock.TestReferenceBean">
+ <property name="bean" ref="testReference"/>
+ </bean>
+
+ <sca:reference name="testReference" type="helloworld.HelloWorld"/>
+
+</beans>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml
new file mode 100644
index 0000000000..539dfa6e32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="testBean" class="mock.TestReferenceBean">
+ <!-- Here is the implicit reference - a property with a ref not satisifed within the
+ * Spring application context.
+ -->
+ <property name="bean" ref="testReference"/>
+ </bean>
+
+</beans>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite
new file mode 100644
index 0000000000..fcbafad27d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://SpringExplicitReference"
+ name="SpringExplicitReference">
+
+ <component name="ClientComponent">
+ <implementation.spring location="META-INF/spring/SpringExplicitReference-context.xml"/>
+ <reference name="testReference" target="ExplicitReferenceComponent"/>
+ </component>
+
+ <component name="ExplicitReferenceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite
new file mode 100644
index 0000000000..4204b75b48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite
@@ -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.
+-->
+<!-- Composite for the SpringImplicitReferenceTestCase
+ * This composite has a ClientComponent implemented with a Spring implementation where
+ * Spring application context uses an implicit reference definition through a Bean with
+ * a property with an unsatisfied ref attribute, which forms the reference.
+ * The reference is satisified by a wire to a ReferenceComponent which is implemented
+ * by a plain Java POJO.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://SpringImplicitReference"
+ name="SpringImplicitReference">
+
+ <component name="ClientComponent">
+ <implementation.spring location="META-INF/spring/SpringImplicitReference-context.xml"/>
+ <reference name="testReference" target="ImplicitReferenceComponent"/>
+ </component>
+
+ <component name="ImplicitReferenceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml
new file mode 100644
index 0000000000..5fe57ed733
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+<!-- Application context for the SpringExplicitHelloWorld testcase
+In this case, the service offered by the Spring application is specified
+explicitly using an sca:service element -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xmlns:spec="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <sca:service name="fooService"
+ type="helloworld.HelloWorld"
+ target="testBean"/>
+ <!-- requires="spec:serverAuthentication" -->
+
+ <bean id="testBean"
+ class="mock.TestHelloWorldBean"
+ lazy-init="true">
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml
new file mode 100644
index 0000000000..83558e8abc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml
@@ -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.
+-->
+<!-- Application context for the SpringHelloWorld testcase -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="testBean" class="mock.TestHelloWorldBean" lazy-init="true">
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite
new file mode 100644
index 0000000000..c9bb5b9e3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://SpringExplicitService"
+ name="SpringExplicitService">
+
+ <component name="ClientComponent">
+ <implementation.java class="helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="ExplicitServiceComponent"/>
+ </component>
+
+ <component name="ExplicitServiceComponent">
+ <implementation.spring location="META-INF/spring/SpringExplicitService-context.xml"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite
new file mode 100644
index 0000000000..856b41f897
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://SpringImplicitService"
+ name="SpringImplicitService">
+
+ <component name="ClientComponent">
+ <implementation.java class="helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="ImplicitServiceComponent"/>
+ </component>
+
+ <component name="ImplicitServiceComponent">
+ <implementation.spring location="META-INF/spring/SpringImplicitService-context.xml"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite
new file mode 100644
index 0000000000..b59114bd31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite
@@ -0,0 +1,60 @@
+<?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 targetNamespace="http://sample"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample"
+ name="Calculator"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.spring location="CalculatorService-context.xml"/>
+ <property name="message">HelloWorld</property>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <!--<component name="AnotherCalculatorServiceComponent">
+ <implementation.spring location="CalculatorService-context.xml"/>
+ <property name="message">HelloWorld</property>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+--></composite>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml
new file mode 100644
index 0000000000..4a873f2424
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="CalculatorServiceBean" class="spring.annotations.CalculatorServiceImpl">
+ <property name="addService" ref="addService"/>
+ <!-- <property name="subtractService" ref="subtractService"/>
+ <property name="multiplyService" ref="multiplyService"/> -->
+ <property name="divideService" ref="divideService"/>
+ </bean>
+
+ <sca:reference name="addService" type="calculator.AddService"/>
+ <sca:reference name="subtractService" type="calculator.SubtractService"/>
+ <sca:reference name="multiplyService" type="calculator.MultiplyService"/>
+ <sca:reference name="divideService" type="calculator.DivideService"/>
+
+ <sca:property id="msg" name="message" type="java.lang.String"/>
+
+</beans>
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java
new file mode 100644
index 0000000000..a346e290b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 context.access;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.springframework.context.ApplicationContext;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ Node node = factory.createNode(new File("src/main/resources/context/access/ContextAccess.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/context/access/").toURI().toURL().toString()));
+ node.start();
+
+ // Code: To access the Spring Application Context instance
+ ApplicationContext ctx = SCAApplicationContextProvider.getApplicationContext();
+ if (ctx.containsBean("CalculatorServiceBean"))
+ System.out.println("CalculatorServiceBean is now available for use...");
+
+ CalculatorService calculatorService =
+ node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java
new file mode 100644
index 0000000000..2602839d1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.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 context.access;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests out the big bank service
+ *
+ */
+public class ContextAccessTestCase extends TestCase {
+
+ public void testServer() throws Exception {
+ CalculatorClient.main(new String[] {""});
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java
new file mode 100644
index 0000000000..c029b06a8c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.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 context.imports;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ Node node = factory.createNode(new File("src/main/resources/context/imports/ContextImports.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/context/imports/").toURI().toURL().toString()));
+ node.start();
+
+ CalculatorService calculatorService =
+ node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java
new file mode 100644
index 0000000000..8df60c5bab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.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 context.imports;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests out the big bank service
+ *
+ */
+public class ContextImportsTestCase extends TestCase {
+
+ public void testServer() throws Exception {
+ CalculatorClient.main(new String[] {""});
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java
new file mode 100644
index 0000000000..f5261c85bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.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 context.multiple;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests out the big bank service
+ *
+ */
+public class MultipleContextTestCase extends TestCase {
+
+ public void testServer() throws Exception {
+ StockQuoteServer.main(new String[] {"1000"});
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java
new file mode 100644
index 0000000000..83875e0b0a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.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 context.multiple;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.springframework.context.ApplicationContext;
+
+import context.access.SCAApplicationContextProvider;
+
+/**
+ * This server program shows how to bootstrap SCA from a simple J2SE program
+ * and start it which activates the StockQuote Web service endpoint.
+ */
+public class StockQuoteServer {
+
+ public static void main(String[] args) throws Exception {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ Node node = factory.createNode(new File("src/main/resources/context/multiple/MultipleContext.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/context/multiple/").toURI().toURL().toString()));
+ node.start();
+
+ // Method 1: To access the Spring Application Context instance
+ ApplicationContext ctx = SCAApplicationContextProvider.getApplicationContext();
+ if (ctx.containsBean("StockQuoteServiceBean"))
+ System.out.println("StockQuoteServiceBean is now available for use...");
+
+ System.out.println("Press Enter to Exit...");
+ Thread.sleep(1000);
+
+ node.stop();
+ System.out.println("Bye");
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java
new file mode 100644
index 0000000000..19892597c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package implementation.policies;
+
+import java.io.File;
+
+import javax.security.auth.login.Configuration;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+ try {
+ Configuration secConf = Configuration.getConfiguration();
+ } catch (java.lang.SecurityException e) {
+ System.setProperty("java.security.auth.login.config", CalculatorClient.class.getClassLoader()
+ .getResource("implementation/policies/CalculatorJass.config").toString());
+ }
+
+ NodeFactory factory = NodeFactory.newInstance();
+ Node node = factory.createNode(new File("src/main/resources/implementation/policies/ImplementationPolicies.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/implementation/policies/").toURI().toURL().toString()));
+ node.start();
+
+ CalculatorService calculatorService =
+ node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // Calculate
+ System.out.println("Calling CalculatorServiceComponent configured with 'logging' " +
+ "policy for subtract and divide operations...");
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ calculatorService =
+ node.getService(CalculatorService.class, "AnotherCalculatorServiceComponent");
+
+ // Calculate
+ System.out.println("Calling CalculatorServiceComponent configured with 'logging' " +
+ "for all operations in the implementation...");
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ node.stop();
+ System.out.println("Bye");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java
new file mode 100644
index 0000000000..a44ae38d24
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.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 implementation.policies;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests out the big bank service
+ *
+ */
+public class ImplementationPoliciesTestCase extends TestCase {
+
+ public void testServer() throws Exception {
+ CalculatorClient.main(new String[] {""});
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java
new file mode 100644
index 0000000000..d54f0544d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package location.folder;
+
+import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase;
+
+/**
+ * A test case designed to test the implementation of Properties from a Spring application
+ * context, where the properties are explicit, through the presence of an sca:property
+ * element within the Spring application context
+ *
+ * The artifacts involved in this test are:
+ *
+ * 1) A composite containing a component with a Spring implementation
+ * 2) The <implementation.spring.../> element references an application context that
+ * uses an explicit sca:property element which is used to compute the response to an invocation
+ * of the service of the implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringFolderLocationTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+
+ public SpringFolderLocationTestCase() {
+ super("SpringFolderLocation.composite", "location/folder/");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java
new file mode 100644
index 0000000000..71768f5a7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package location.jar;
+
+import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase;
+
+/**
+ * A test case designed to test the implementation of Properties from a Spring application
+ * context, where the properties are explicit, through the presence of an sca:property
+ * element within the Spring application context
+ *
+ * The artifacts involved in this test are:
+ *
+ * 1) A composite containing a component with a Spring implementation
+ * 2) The <implementation.spring.../> element references an application context that
+ * uses an explicit sca:property element which is used to compute the response to an invocation
+ * of the service of the implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringJarLocationTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+
+ public SpringJarLocationTestCase() {
+ super("SpringJarLocation.composite", "location/jar/");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java
new file mode 100644
index 0000000000..0c6f8d2e84
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.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.itest.spring;
+
+
+/**
+ * Basic "hello world" style test case for testing Spring component implementation
+ *
+ */
+public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase<HelloWorld> {
+
+ /**
+ * Calls the hello world service and checks that it gives the right response...
+ */
+ public AbstractHelloWorldTestCase(String compositeName, String contributionLocation) {
+ super(compositeName, contributionLocation);
+ }
+
+ public void testHello() throws Exception {
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @Override
+ protected Class<HelloWorld> getServiceClass() {
+ return HelloWorld.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java
new file mode 100644
index 0000000000..53cc094aca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.spring;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public abstract class AbstractSCATestCase<T> extends TestCase {
+
+ protected Node node;
+ protected T service;
+ protected String compositeName;
+ protected String contributionLocation;
+
+ public AbstractSCATestCase(String compositeName, String contributionLocation) {
+ super();
+ this.compositeName = compositeName;
+ this.contributionLocation = contributionLocation;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/" + contributionLocation + compositeName).toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/" + contributionLocation).toURI().toURL().toString()));
+ node.start();
+ service = node.getService(getServiceClass(), "ClientComponent");
+ }
+
+ abstract protected Class<T> getServiceClass();
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java
new file mode 100644
index 0000000000..5869d344f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.spring;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Interface for the "hello world" service - predictably simple with a single operation
+ * "sayHello"
+ *
+ */
+@Remotable
+public interface HelloWorld {
+
+ public String sayHello(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java
new file mode 100644
index 0000000000..90d26dd89f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.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.itest.spring;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * A simple proxy Java class which implements the HelloWorld interface but which uses
+ * a reference "delegate" to actually provide the HelloWorld service
+ *
+ */
+public class HelloWorldProxy implements HelloWorld {
+
+ // Here is the reference "delegate" - it implements the HelloWorld interface...
+ @Reference
+ public HelloWorld delegate;
+
+ public String sayHello(String s) {
+ // Simply call the reference to satisfy the service request...
+ System.out.println("HelloWorldProxy - calling sayHello");
+ return delegate.sayHello(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java
new file mode 100644
index 0000000000..f28dace31a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.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 org.apache.tuscany.sca.itest.spring;
+
+/**
+ * A basic test case of:
+ * 1) A composite containing a component with a Spring implementation
+ * 2) The composite has a component with a Java POJO implementation which uses the
+ * Spring implementation to satisfy a reference
+ *
+ */
+public class SpringDelegationHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+
+ public SpringDelegationHelloWorldTestCase() {
+ super("SpringDelegationHelloWorld.composite", "org/apache/tuscany/sca/itest/spring/");
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java
new file mode 100644
index 0000000000..def30b3ea0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.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 org.apache.tuscany.sca.itest.spring;
+
+/**
+ * A basic test case of:
+ * 1) A composite containing a component with a Spring implementation
+ * 2) The composite has a component with a Java POJO implementation which uses the
+ * Spring implementation to satisfy a reference
+ * 3) The Spring component delegates function to a second spring bean
+ *
+ */
+public class SpringHelloWorldTestCase extends AbstractHelloWorldTestCase {
+
+ // super class does it all getting composite based on this class name
+ public SpringHelloWorldTestCase() {
+ super("SpringHelloWorld.composite", "org/apache/tuscany/sca/itest/spring/");
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java
new file mode 100644
index 0000000000..fa7967c964
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.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 org.apache.tuscany.sca.itest.spring;
+
+/**
+ * A simple test Spring bean which provides the HelloWorld service
+ *
+ */
+
+public class TestHelloWorldBean implements HelloWorld {
+
+ static String hello = "Hello ";
+
+ // Classic "Hello xxx" response to any input message
+ public String sayHello(String message) {
+ System.out.println("TestHelloWorldBean - sayHello called");
+ return (hello + message);
+ }
+
+} // end class TestHelloWorldBean
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java
new file mode 100644
index 0000000000..b57cc7f366
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.spring;
+
+/**
+ * A simple test Spring bean which delgates to another bean
+ *
+ */
+
+public class TestHelloWorldDelegatorBean implements HelloWorld {
+
+ HelloWorld delegate;
+
+ public void setDelegate(HelloWorld delegate) {
+ this.delegate = delegate;
+ }
+
+ // Classic "Hello xxx" response to any input message
+ public String sayHello(String message) {
+ System.out.println("TestHelloWorldDelegatorBean - sayHello called");
+ return delegate.sayHello(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java
new file mode 100644
index 0000000000..0c2e1daa81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sca.references;
+
+import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase;
+
+/**
+ * A test case designed to test the implementation of References from a Spring application
+ * context, where the references are explicit, through the presence of an sca:reference
+ * element within the Spring application context
+ *
+ * The artifacts involved in this test are:
+ *
+ * 1) A composite containing a component with a Spring implementation which makes
+ * a reference to a second component
+ * 2) The composite has a component with a Java POJO implementation which satisfies the reference
+ * 3) The <implementation.spring.../> element references an application context that
+ * uses an explicit sca:reference element to identify the reference made by the Spring application
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringExplicitReferenceTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+
+ public SpringExplicitReferenceTestCase() {
+ super("SpringExplicitReference.composite", "sca/references/");
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java
new file mode 100644
index 0000000000..8d0c548899
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sca.references;
+
+import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase;
+
+/**
+ * A test case designed to test the implementation of References from a Spring application
+ * context, where the references are implicit, through the presence of Bean properties with a
+ * ref attribute which is not satisfied by a Bean within the application context.
+ *
+ * The artifacts involved in this test are:
+ *
+ * 1) A composite containing a component with a Spring implementation which makes
+ * a reference to a second component
+ * 2) The composite has a component with a Java POJO implementation which satisfies the reference
+ * 3) The <implementation.spring.../> element references an application context that
+ * does not use an explicit sca:reference element to identify the reference made by the
+ * Spring application, but relies on an unsatisfied Bean property with a ref attribute.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringImplicitReferenceTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+
+ public SpringImplicitReferenceTestCase() {
+ super("SpringImplicitReference.composite", "sca/references/");
+ }
+}
+
+
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java
new file mode 100644
index 0000000000..f4bd53876c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.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 sca.services;
+
+import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase;
+
+/**
+ * A basic test case of:
+ * 1) A composite containing a component with a Spring implementation
+ * 2) The composite has a component with a Java POJO implementation which uses the
+ * Spring implementation to satisfy a reference
+ * 3) The <implementation.spring.../> element references an application context that
+ * uses an explicit sca: element to identify the service offered by the Spring application
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringExplicitServiceTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+
+ public SpringExplicitServiceTestCase() {
+ super("SpringExplicitService.composite", "sca/services/");
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java
new file mode 100644
index 0000000000..0907985d7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.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 sca.services;
+
+import org.apache.tuscany.sca.itest.spring.AbstractHelloWorldTestCase;
+
+/**
+ * A basic test case of:
+ * 1) A composite containing a component with a Spring implementation
+ * 2) The composite has a component with a Java POJO implementation which uses the
+ * Spring implementation to satisfy a reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringImplicitServiceTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+
+ public SpringImplicitServiceTestCase() {
+ super("SpringImplicitService.composite", "sca/services/");
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java
new file mode 100644
index 0000000000..c2dfbf247f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package spring.annotations;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ Node node = factory.createNode(new File("src/main/resources/spring/annotations/Calculator.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/spring/annotations/").toURI().toURL().toString()));
+ node.start();
+
+ CalculatorService calculatorService =
+ node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ node.stop();
+ System.out.println("Bye");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java
new file mode 100644
index 0000000000..5db9c84c00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.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 spring.annotations;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests out the big bank service
+ *
+ */
+public class SpringAnnotationsTestCase extends TestCase {
+
+ public void testServer() throws Exception {
+ CalculatorClient.main(new String[] {""});
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/import-export/exports/pom.xml b/sandbox/sebastien/java/embed/itest/import-export/exports/pom.xml
new file mode 100644
index 0000000000..e83be7145f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/exports/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-import-export-export</artifactId>
+ <name>Apache Tuscany SCA iTest Import Export Exports</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/import-export/exports/src/main/java/org/apache/tuscany/sca/itest/exports/Helloworld.java b/sandbox/sebastien/java/embed/itest/import-export/exports/src/main/java/org/apache/tuscany/sca/itest/exports/Helloworld.java
new file mode 100644
index 0000000000..186e42da39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/exports/src/main/java/org/apache/tuscany/sca/itest/exports/Helloworld.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.exports;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+ String sayHello(String s);
+}
diff --git a/sandbox/sebastien/java/embed/itest/import-export/exports/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/import-export/exports/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..9a0edcba68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/exports/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <export.java package="org.apache.tuscany.sca.itest.exports"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/import-export/imports/pom.xml b/sandbox/sebastien/java/embed/itest/import-export/imports/pom.xml
new file mode 100644
index 0000000000..73da8052b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/imports/pom.xml
@@ -0,0 +1,46 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-import-export-imports</artifactId>
+ <name>Apache Tuscany SCA iTest Import Export Imports</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-import-export-export</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/java/org/apache/tuscany/sca/itest/imports/HelloworldImpl.java b/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/java/org/apache/tuscany/sca/itest/imports/HelloworldImpl.java
new file mode 100644
index 0000000000..4c7bc92b4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/java/org/apache/tuscany/sca/itest/imports/HelloworldImpl.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.itest.imports;
+
+import org.apache.tuscany.sca.itest.exports.Helloworld;
+
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/resources/Helloworld.composite b/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/resources/Helloworld.composite
new file mode 100644
index 0000000000..b4e2ff8868
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/resources/Helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="HelloworldImpl">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.imports.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c136923ab4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/imports/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:Helloworld"/>
+ <import.java package="org.apache.tuscany.sca.itest.exports"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/import-export/pom.xml b/sandbox/sebastien/java/embed/itest/import-export/pom.xml
new file mode 100644
index 0000000000..182203291b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/pom.xml
@@ -0,0 +1,38 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-import-export</artifactId>
+ <name>Apache Tuscany SCA iTest Import Export</name>
+
+ <modules>
+ <module>imports</module>
+ <module>exports</module>
+ <module>tests</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/import-export/tests/pom.xml b/sandbox/sebastien/java/embed/itest/import-export/tests/pom.xml
new file mode 100644
index 0000000000..2e95f157b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/tests/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-import-export-tests</artifactId>
+ <name>Apache Tuscany SCA iTest Import Export Tests</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/import-export/tests/src/test/java/org/apache/tuscany/sca/itests/TestTestCase.java b/sandbox/sebastien/java/embed/itest/import-export/tests/src/test/java/org/apache/tuscany/sca/itests/TestTestCase.java
new file mode 100644
index 0000000000..ea76a23c03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/import-export/tests/src/test/java/org/apache/tuscany/sca/itests/TestTestCase.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.itests;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Test;
+
+public class TestTestCase {
+
+ private Node node;
+ private Node node2;
+
+ @Test
+ public void testOneNode() throws Exception {
+
+ node = NodeFactory.newInstance().createNode((String)null, new String[] {"../exports/target/classes", "../imports/target/classes"});
+ node.start();
+
+ }
+
+ @Test
+ public void testSeparateNodes() throws Exception {
+
+ node = NodeFactory.newInstance().createNode((String)null, new String[] {"../exports/target/classes"});
+ node.start();
+
+ node2 = NodeFactory.newInstance().createNode((String)null, new String[] {"../imports/target/classes"});
+ node2.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ if (node2 != null) {
+ node2.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/pom.xml b/sandbox/sebastien/java/embed/itest/interfaces/pom.xml
new file mode 100644
index 0000000000..09a969d146
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-interfaces</artifactId>
+ <name>Apache Tuscany SCA iTest Interface</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java
new file mode 100644
index 0000000000..f4131593d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.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.itest.interfaces;
+
+/**
+ * only for callBack
+ */
+public interface LocalCallbackInterface {
+
+ void callbackMethod(String str);
+
+ void modifyParameter(ParameterObject po);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java
new file mode 100644
index 0000000000..3c7a398abd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.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.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.OneWay;
+
+/*
+ * itest for interface: local,method-overloading
+ */
+public interface LocalClientComponent {
+
+ String foo1(ParameterObject po);
+
+ String foo2(String str) throws Exception;
+
+ String foo3(String str, int i);
+
+ String foo4(int i, String str) throws Exception;
+
+ void callback(String str);
+
+ void callModifyParameter();
+
+ @OneWay
+ void onewayMethod(String str);
+
+ String getCallbackValue();
+
+ String getOnewayValue();
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java
new file mode 100644
index 0000000000..fc88c4f119
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.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.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(LocalClientComponent.class)
+public class LocalClientComponentImpl implements LocalClientComponent, LocalCallbackInterface {
+
+ @Reference
+ protected LocalServiceComponent aCallBackService;
+ private static String callbackValue;
+ private static String onewayValue;
+
+ public String foo1(ParameterObject po) {
+ po.field1 = "AComponent";
+ return "AComponent";
+ }
+
+ public String foo2(String str) throws Exception {
+ return str + "AComponent";
+ }
+
+ public String foo3(String str, int i) {
+ return str + "AComponent" + i;
+ }
+
+ public String foo4(int i, String str) throws Exception {
+ return str + "AComponent" + i;
+ }
+
+ public void callback(String str) {
+ aCallBackService.callback(str);
+ }
+
+ public void callbackMethod(String str) {
+ callbackValue = str;
+ }
+
+ public void callModifyParameter() {
+ this.aCallBackService.modifyParameter();
+ }
+
+ public String getCallbackValue() {
+ return callbackValue;
+ }
+
+ public void onewayMethod(String str) {
+ onewayValue = str;
+ try {
+ Thread.sleep(200);
+ } catch (Exception e) {
+ //do nothing
+ }
+ }
+
+ public String getOnewayValue() {
+ return onewayValue;
+ }
+
+ public void modifyParameter(ParameterObject po) {
+ po.field1 = "AComponent";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java
new file mode 100644
index 0000000000..05a9d09bdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.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.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Callback;
+
+/**
+ * Local be-directional callBackService
+ */
+@Callback(LocalCallbackInterface.class)
+public interface LocalServiceComponent {
+
+ String foo(String str);
+
+ void callback(String str);
+
+ void modifyParameter();
+
+ ParameterObject getPO();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java
new file mode 100644
index 0000000000..ab0b18191c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(LocalServiceComponent.class)
+public class LocalServiceComponentImpl implements LocalServiceComponent {
+
+ @Callback
+ protected LocalCallbackInterface callback;
+
+ private static ParameterObject po;
+
+ public void callback(String str) {
+ callback.callbackMethod(str);
+ }
+
+ public void modifyParameter() {
+ po = new ParameterObject("CallBack");
+ callback.modifyParameter(po);
+ }
+
+ public String foo(String str) {
+ return str;
+ }
+
+ public ParameterObject getPO() {
+ return po;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java
new file mode 100644
index 0000000000..724d94dffb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.interfaces;
+
+import java.io.Serializable;
+
+public class ParameterObject implements Serializable {
+ private static final long serialVersionUID = 1L;
+ public String field1;
+
+ public ParameterObject() {
+ this.field1 = null;
+ }
+
+ public ParameterObject(String field1) {
+ this.field1 = field1;
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof ParameterObject) {
+ ParameterObject other = (ParameterObject)o;
+ if (field1 != null) {
+ return field1.equals(other.field1);
+ }
+ }
+ return false;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java
new file mode 100644
index 0000000000..be3fa4c15a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * only for callBack
+ */
+@Remotable
+public interface RemoteCallbackInterface {
+
+ void callbackMethod(String str);
+
+ void modifyParameter(ParameterObject po);
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
new file mode 100644
index 0000000000..9f34dfd274
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/*
+ * different signatures
+ */
+
+@Remotable
+public interface RemoteClientComponent {
+
+ String foo1(ParameterObject po);
+
+ String foo3(ParameterObject po);
+
+ String foo2(int i, String str1) throws Exception;
+
+ void callback(String str);
+
+ void callModifyParameter();
+
+ String getCallbackValue();
+
+ void onewayMethod(String str);
+
+ String getOnewayValue();
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
new file mode 100644
index 0000000000..541b1f1508
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.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.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(RemoteClientComponent.class)
+public class RemoteClientComponentImpl implements RemoteClientComponent, RemoteCallbackInterface {
+
+ @Reference
+ protected RemoteServiceComponent aCallBackService;
+ private static String callbackValue;
+ private static String onewayValue;
+
+ public String foo1(ParameterObject po) {
+ po.field1 = "BComponent";
+ return "BComponent";
+ }
+
+ @AllowsPassByReference
+ public String foo3(ParameterObject po) {
+ po.field1 = "BComponent";
+ return "BComponent";
+ }
+
+ public String foo2(int i, String str) throws Exception {
+ return str + "BComponent" + i;
+ }
+
+ public void callback(String str) {
+ aCallBackService.callback(str);
+ }
+
+ public void callModifyParameter() {
+ this.aCallBackService.modifyParameter();
+ }
+
+ public void callbackMethod(String str) {
+ callbackValue = str;
+ }
+
+ public String getCallbackValue() {
+ return callbackValue;
+ }
+
+ public void onewayMethod(String str) {
+ onewayValue = str;
+ try {
+ Thread.sleep(200);
+ } catch (Exception e) {
+ //do nothing
+ }
+ }
+
+ public String getOnewayValue() {
+ return onewayValue;
+ }
+
+ public void modifyParameter(ParameterObject po) {
+ po.field1 = "BComponent";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java
new file mode 100644
index 0000000000..b29b298ab6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(RemoteCallbackInterface.class)
+public interface RemoteServiceComponent {
+
+ String foo(String str);
+
+ void callback(String str);
+
+ void modifyParameter();
+
+ ParameterObject getPO();
+
+ String[] bar(int[][] intArray);
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java
new file mode 100644
index 0000000000..00a0f5645b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.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.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(RemoteServiceComponent.class)
+public class RemoteServiceComponentImpl implements RemoteServiceComponent {
+
+ @Callback
+ protected RemoteCallbackInterface callback;
+
+ private static ParameterObject po;
+
+ public void callback(String str) {
+ callback.callbackMethod(str);
+ }
+
+ public void modifyParameter() {
+ po = new ParameterObject("CallBack");
+ callback.modifyParameter(po);
+ }
+
+ public String foo(String str) {
+ return str;
+ }
+
+ public ParameterObject getPO() {
+ return po;
+ }
+
+ public String[] bar(int[][] intArray) {
+ return new String[] {"int"};
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/invalid/InvalidRemoteAttribute.composite b/sandbox/sebastien/java/embed/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/invalid/InvalidRemoteAttribute.composite
new file mode 100644
index 0000000000..da5700aa35
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/invalid/InvalidRemoteAttribute.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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="InvalidRemoteAttribute" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <component name="RemoteServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.RemoteServiceComponentImpl" />
+ <service name="RemoteServiceComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.interfaces.RemoteServiceComponent" remotable="false"/>
+ </service>
+ </component>
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/valid/InterfacesTest.composite b/sandbox/sebastien/java/embed/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/valid/InterfacesTest.composite
new file mode 100644
index 0000000000..e9267b75d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/valid/InterfacesTest.composite
@@ -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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="InterfacesTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <component name="LocalClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.LocalClientComponentImpl" />
+ <reference name="aCallBackService" target="LocalServiceComponent" />
+ </component>
+
+ <component name="RemoteClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.RemoteClientComponentImpl" />
+ <reference name="aCallBackService" target="RemoteServiceComponent" />
+ </component>
+
+ <component name="LocalServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.LocalServiceComponentImpl" />
+ </component>
+
+ <component name="RemoteServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.RemoteServiceComponentImpl" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java b/sandbox/sebastien/java/embed/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
new file mode 100644
index 0000000000..d04351f51e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.interfaces;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+// @Ignore("TUSCANY-3138")
+public class InterfacesTestCase {
+ private static final String PKG = "org/apache/tuscany/sca/itest/interfaces/valid";
+ private static String ROOT = new File("target/classes/" + PKG).toURI().toString();
+
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ String location = ROOT;
+ node = NodeFactory.newInstance().createNode("InterfacesTest.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testLocalClient() {
+ LocalServiceComponent service = node.getService(LocalServiceComponent.class, "LocalServiceComponent");
+ LocalClientComponent local = node.getService(LocalClientComponent.class, "LocalClientComponent");
+
+ try {
+ ParameterObject po = new ParameterObject();
+ assertEquals("AComponent", local.foo1(po));
+ assertEquals("AComponent", po.field1);
+
+ assertEquals("AAComponent", local.foo2("A"));
+
+ assertEquals("AAComponent1", local.foo3("A", 1));
+ assertEquals("AAComponent1", local.foo4(1, "A"));
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ // test local callback
+ local.callback("CallBack");
+ Thread.sleep(100);
+ assertEquals("CallBack", local.getCallbackValue());
+
+ local.callModifyParameter();
+ Thread.sleep(100);
+ assertEquals("AComponent", service.getPO().field1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("CallBack failed");
+ }
+
+ try {
+ local.onewayMethod("OneWay");
+ Thread.sleep(100);
+ assertEquals("OneWay", local.getOnewayValue());
+ } catch (Exception e) {
+ fail("OneWay failed");
+ }
+ }
+
+ @Test
+ public void testRemoteClient() {
+ RemoteServiceComponent service = node.getService(RemoteServiceComponent.class, "RemoteServiceComponent");
+ RemoteClientComponent remote = node.getService(RemoteClientComponent.class, "RemoteClientComponent");
+
+ try {
+ // Test Pass By Value
+ ParameterObject po = new ParameterObject("NotBComponent");
+ assertEquals("BComponent", remote.foo1(po));
+ assertEquals("NotBComponent", po.field1);
+
+ assertEquals("BBComponent1", remote.foo2(1, "B"));
+
+// TODO: TUSCANY-3479, investigate Node/SCAClient pass by reference
+// // Test allowsPassByReference
+// assertEquals("BComponent", remote.foo3(po));
+// assertEquals("BComponent", po.field1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ try {
+ remote.callback("CallBack");
+ Thread.sleep(100);
+ assertEquals("CallBack", remote.getCallbackValue());
+
+ remote.callModifyParameter();
+ Thread.sleep(100);
+ assertEquals("CallBack", service.getPO().field1);
+ } catch (Exception e) {
+ fail("CallBack failed");
+ }
+
+ try {
+ remote.onewayMethod("OneWay");
+ Thread.sleep(100);
+ assertEquals("OneWay", remote.getOnewayValue());
+ } catch (Exception e) {
+ fail("OneWay failed");
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java b/sandbox/sebastien/java/embed/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java
new file mode 100644
index 0000000000..5aa8be2f04
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.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.itest.interfaces;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.interfacedef.InvalidAnnotationException;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Test;
+
+public class InvalidRemoteAttributeTestCase {
+ private static final String PKG = "org/apache/tuscany/sca/itest/interfaces/invalid";
+ private static String ROOT = new File("target/classes/" + PKG).toURI().toString();
+
+ @Test
+ public void testInvalidRemoteAttribute() throws Exception {
+ Node node = null;
+
+ try {
+ String location = ROOT;
+ node = NodeFactory.newInstance().createNode("InvalidRemoteAttribute.composite", new Contribution("c1", location));
+ node.start();
+ } catch (Exception e) {
+ if (! e.getCause().getClass().equals(InvalidAnnotationException.class)) {
+ throw e;
+ }
+ } finally {
+ if (node != null) {
+ node.stop();
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/pom.xml b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/pom.xml
new file mode 100644
index 0000000000..1f9b339386
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jaxws-asyncclient</artifactId>
+ <name>Apache Tuscany JAX-WS Integration Tests</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java
new file mode 100644
index 0000000000..4e55bae98d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java
@@ -0,0 +1,36 @@
+package stock;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import javax.jws.WebService;
+
+/**
+ * JAX-WS Async style Stock quote interface
+ *
+ * @version $Rev: 828277 $ $Date: 2009-10-22 02:40:52 +0100 (Thu, 22 Oct 2009) $
+ */
+
+@WebService
+public interface StockQuote {
+
+ float getPrice(String ticker);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java
new file mode 100644
index 0000000000..0bf3328c31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 stock;
+
+import java.util.concurrent.ExecutionException;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class StockQuoteClient {
+
+ @Reference public StockQuoteRef stockQuote;
+
+ public float getPrice(String ticker) {
+ return stockQuote.getPrice(ticker);
+ }
+
+ public float getPriceAsyncPoll(String ticker) throws InterruptedException, ExecutionException {
+ Response<Float> response = stockQuote.getPriceAsync("foo");
+ return response.get();
+ }
+
+ float price = 0f;
+ Object mutex = new Object();
+ Exception exception;
+
+ public float getPriceAsyncCallback(String ticker) throws Exception {
+ AsyncHandler<Float> callback = new AsyncHandler<Float>() {
+ public void handleResponse(Response<Float> arg) {
+ synchronized (mutex) {
+ try {
+ price = arg.get();
+ } catch (Exception e) {
+ exception = e;
+ }
+ mutex.notify();
+ }
+ }
+ };
+ stockQuote.getPriceAsync("foo", callback);
+ synchronized (mutex) {
+ if (price == 0f)
+ mutex.wait(5000); // wait for up to 5 seconds
+ }
+
+ if (exception != null) throw exception;
+ return price;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java
new file mode 100644
index 0000000000..a43b85361b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.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 stock;
+
+
+/**
+ * Stock quote impl
+ *
+ * @version $Rev: 828277 $ $Date: 2009-10-22 02:40:52 +0100 (Thu, 22 Oct 2009) $
+ */
+public class StockQuoteImpl implements StockQuote {
+
+ public float getPrice(String ticker) {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java
new file mode 100644
index 0000000000..b15ab6be08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java
@@ -0,0 +1,39 @@
+package stock;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * JAX-WS Async style Stock quote interface
+ */
+@Remotable
+public interface StockQuoteRef extends StockQuote {
+
+ Response<Float> getPriceAsync(String ticker);
+
+ Future<?> getPriceAsync(String ticker, AsyncHandler<Float> callback);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b30367319d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest/jaxws">
+ <deployable composite="itest:jaxwsAsync"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite
new file mode 100644
index 0000000000..548b7a9da5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite
@@ -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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://itest/jaxws"
+ targetNamespace="http://itest/jaxws"
+ name="jaxwsAsync">
+
+ <component name="StockQuote">
+ <implementation.java class="stock.StockQuoteImpl" />
+ </component>
+
+ <component name="StockQuoteClient">
+ <implementation.java class="stock.StockQuoteClient" />
+ <reference name="stockQuote" target="StockQuote" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java
new file mode 100644
index 0000000000..eb72924093
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java
@@ -0,0 +1,67 @@
+package itest;
+import java.util.concurrent.ExecutionException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import stock.StockQuoteClient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public class AsyncServiceTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void invokeRPC() {
+ StockQuoteClient sc = node.getService(StockQuoteClient.class, "StockQuoteClient");
+ Assert.assertEquals(10.0f, sc.getPrice("foo"));
+ }
+
+ @Test
+ public void invokeAsyncPoll() throws InterruptedException, ExecutionException {
+ StockQuoteClient sc = node.getService(StockQuoteClient.class, "StockQuoteClient");
+ Assert.assertEquals(10.0f, sc.getPriceAsyncPoll("foo"));
+ }
+
+ @Test
+ public void invokeAsyncCallback() throws Exception {
+ StockQuoteClient sc = node.getService(StockQuoteClient.class, "StockQuoteClient");
+ Assert.assertEquals(10.0f, sc.getPriceAsyncCallback("foo"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws/pom.xml b/sandbox/sebastien/java/embed/itest/jaxws/pom.xml
new file mode 100644
index 0000000000..3566980756
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jaxws</artifactId>
+ <name>Apache Tuscany SCA iTest JAX-WS Integration Tests</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java b/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java
new file mode 100644
index 0000000000..e1c2bedea3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java
@@ -0,0 +1,42 @@
+package stock;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public class AsyncServiceTestCase {
+
+ @Test
+ public void init() throws Exception {
+ try{
+ String location = ContributionLocationHelper.getContributionLocation("StockQuote.composite");
+ Node node = NodeFactory.newInstance().createNode("StockQuote.composite", new Contribution("c1", location));
+ node.start();
+ node.stop();
+ } catch (Exception e) {
+ Assert.assertTrue(e.getMessage().contains("[JCA100006]"));
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/StockQuote.java b/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/StockQuote.java
new file mode 100644
index 0000000000..74e25bb3bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/StockQuote.java
@@ -0,0 +1,45 @@
+package stock;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import java.util.concurrent.Future;
+
+import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+/**
+ * JAX-WS Async style Stock quote interface
+ *
+ * @version $Rev$ $Date$
+ */
+
+@WebService
+public interface StockQuote {
+
+ float getPrice(String ticker);
+
+ Response<Float> getPriceAsync(String ticker);
+
+ Future<?> getPriceAsync(String ticker, AsyncHandler<Float> callback);
+
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/StockQuoteImpl.java b/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/StockQuoteImpl.java
new file mode 100644
index 0000000000..516c63d864
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws/src/test/java/stock/StockQuoteImpl.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 stock;
+
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+/**
+ * Stock quote impl
+ *
+ * @version $Rev$ $Date$
+ */
+public class StockQuoteImpl implements StockQuote {
+
+ public float getPrice(String ticker) {
+ return 10;
+ }
+
+ public Response<Float> getPriceAsync(String ticker) {
+ return null;
+ }
+
+ public Future<?> getPriceAsync(String ticker, AsyncHandler<Float> callback) {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jaxws/src/test/resources/StockQuote.composite b/sandbox/sebastien/java/embed/itest/jaxws/src/test/resources/StockQuote.composite
new file mode 100644
index 0000000000..c8c7719dfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jaxws/src/test/resources/StockQuote.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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://itest/jaxws"
+ targetNamespace="http://itest/jaxws"
+ name="jaxwsAsync">
+
+ <component name="StockQuote">
+ <implementation.java class="stock.StockQuoteImpl" />
+ <service name="StockQuote">
+ <interface.java interface="stock.StockQuote"/>
+ </service>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/pom.xml b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/pom.xml
new file mode 100644
index 0000000000..4a28617959
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-dynamic-replyq</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with dynamic replyq</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldClientImpl implements HelloWorldService {
+
+ private HelloWorldService serviceA;
+
+ @Reference
+ public void setServiceA(HelloWorldService service) {
+ this.serviceA = service;
+ }
+
+ public String sayHello(String name) {
+ return serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.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.jms;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ if ("bang".equals(name)) {
+ throw new RuntimeException("blem wit");
+ }
+ return "jmsHello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ce6a9514af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+ <deployable composite="itest:DynamicComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite
new file mode 100644
index 0000000000..7f9ed9612f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="DynamicComposite">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms>
+ <destination jndiName="DestQueueA"/>
+ <!-- No response destination defined means a temporary queue will be used -->
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite
new file mode 100644
index 0000000000..33364f61c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/main/resources/simple/service.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="SimpleServiceComposite">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
+ <service name="HelloWorldService">
+ <binding.jms>
+ <destination jndiName="DestQueueA" create="always">
+ </destination>
+ <response>
+ <destination jndiName="RespQueueA" create="always"/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java
new file mode 100644
index 0000000000..3bf4e0bc30
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class DynamicReplyQTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldService helloWorldService = node.getService(HelloWorldService.class, "HelloWorldClient");
+ assertEquals("jmsHello Beate", helloWorldService.sayHello("Beate"));
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/args/pom.xml b/sandbox/sebastien/java/embed/itest/jms/args/pom.xml
new file mode 100644
index 0000000000..405017ef33
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/args/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-args</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Args</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- uses ActiveMQ 5.1 as 4.1 Session.createQueue does not work using
+ a temporary queue name -->
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java
new file mode 100644
index 0000000000..68506b857b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the OneWay service.
+ */
+@Service(MyService.class)
+public class ClientImpl implements MyService {
+
+ private MyService serviceA;
+
+ @Reference
+ public void setServiceA(MyService service) {
+ this.serviceA = service;
+ }
+
+ public void sayHello(String name, String n2) {
+ serviceA.sayHello(name, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java b/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java
new file mode 100644
index 0000000000..5f19aa1fa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface MyService {
+
+ @OneWay
+ void sayHello(String name, String n2);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java
new file mode 100644
index 0000000000..18324d5d1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.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 org.apache.tuscany.sca.binding.jms;
+
+
+public class ServiceImpl implements MyService {
+
+ public static Object lock = new Object();
+ public static String name;
+ public static String n2;
+
+ public void sayHello(String name, String n2) {
+ System.out.println("SelectorServiceImpl1 " + name + n2);
+ ServiceImpl.name = name;
+ ServiceImpl.n2 = n2;
+ synchronized (ServiceImpl.lock) {
+ ServiceImpl.lock.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ac6e94ca21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:DefinitionsTests"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..7f82eb48d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false&broker.useShutdownHook=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory, ConnectionFactory2
+
+# register some queues in JNDI using the form
+queue.MyService = MyService
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+topic.ServiceTopic = ServiceTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/selectors/selectors.composite b/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/selectors/selectors.composite
new file mode 100644
index 0000000000..fcda648f1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/args/src/main/resources/selectors/selectors.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="DefinitionsTests">
+
+ <component name="Client1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms uri="jms:jndi:MyService" />
+ </reference>
+ </component>
+
+ <component name="Service1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ServiceImpl"/>
+ <service name="MyService">
+ <binding.jms />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java b/sandbox/sebastien/java/embed/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java
new file mode 100644
index 0000000000..28e0b530c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ */
+public class ArgsTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testSayHello() throws Exception {
+ MyService client1 = node.getService(MyService.class, "Client1");
+
+ client1.sayHello("petra", "beate");
+
+ synchronized(ServiceImpl.lock) {
+ if (ServiceImpl.name == null) {
+ ServiceImpl.lock.wait(5000);
+ }
+ }
+
+ assertEquals("petra", ServiceImpl.name);
+ assertEquals("beate", ServiceImpl.n2);
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/pom.xml b/sandbox/sebastien/java/embed/itest/jms/callbacks/pom.xml
new file mode 100644
index 0000000000..780724ce5e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/pom.xml
@@ -0,0 +1,73 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-jms-callbacks</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Tests For Callbacks</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- uses ActiveMQ 5.1 as 4.1 Session.createQueue does not work using
+ a temporary queue name -->
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
new file mode 100644
index 0000000000..d4cd5df431
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.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 org.apache.tuscany.sca.binding.jms;
+
+
+/**
+ * The client interface
+ */
+public interface JMSClient {
+
+ void aClientMethod();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java
new file mode 100644
index 0000000000..f90db55dda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Remote Web service client with callback interface
+ */
+@Service(JMSClient.class)
+public class JMSClientImpl implements JMSClient, JMSServiceCallback {
+
+ @Reference protected JMSService myService;
+
+ public static String result;
+ public static Object lock = new Object();
+
+ public void aClientMethod() {
+ System.out.println("aClientMethod " + this + " on thread " + Thread.currentThread());
+ myService.someMethod("-> someMethod"); // calls the server
+ System.out.println("aClientMethod return from someMethod on thread " + Thread.currentThread());
+ }
+
+ public void receiveResult(String result) {
+ System.out.println("receiveResult " + this + " '" + result + "' on thread " + Thread.currentThread());
+ JMSClientImpl.result = result;
+
+ // wakeup the waiting testcase
+ synchronized (lock) {
+ lock.notifyAll();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java
new file mode 100644
index 0000000000..b78feab413
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The remote service that will be invoked by the client
+ */
+@Remotable
+@Callback(JMSServiceCallback.class)
+public interface JMSService {
+
+ @OneWay
+ void someMethod(String arg);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java
new file mode 100644
index 0000000000..20b74ccc1a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.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.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The callback interface for {@link JMSService}.
+ */
+@Remotable
+public interface JMSServiceCallback {
+
+ @OneWay
+ void receiveResult(String result);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java
new file mode 100644
index 0000000000..cec4e6fa6d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.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.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements MyService and uses a callback.
+ */
+@Service(JMSService.class)
+public class JMSServiceImpl implements JMSService {
+
+ private JMSServiceCallback myServiceCallback;
+
+ @Callback
+ public void setMyServiceCallback(JMSServiceCallback myServiceCallback) {
+ System.out.println("setMyServiceCallback on thread " + Thread.currentThread() + " cb: " + myServiceCallback);
+ this.myServiceCallback = myServiceCallback;
+ }
+
+ public void someMethod(String arg) {
+ System.out.println("someMethod '" + arg + "' on thread " + Thread.currentThread());
+ try {
+ myServiceCallback.receiveResult(arg + "-> receiveResult");
+ } catch(Exception e) {
+ System.out.println("RuntimeException invoking receiveResult: " + e.toString());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..68c3bfa4e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:CallbackClientComposite"/>
+ <deployable composite="itest:CallbackTempQComposite"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..b8c4b1c6aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false&broker.useShutdownHook=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.ServiceQueue = ServiceQueue
+queue.TQServiceQueue = TQServiceQueue
+queue.CallbackQueue = CallbackQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/simple/client.composite b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/simple/client.composite
new file mode 100644
index 0000000000..64d45f1816
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/simple/client.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="CallbackClientComposite">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.JMSClientImpl" />
+ <reference name="myService">
+ <binding.jms uri="jms:jndi:ServiceQueue"/>
+ <callback>
+ <binding.jms uri="jms:jndi:CallbackQueue"/>
+ </callback>
+ </reference>
+ </component>
+
+ <component name="ServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.JMSServiceImpl" />
+ <service name="JMSService">
+ <binding.jms uri="jms:jndi:ServiceQueue"/>
+ <callback>
+ <binding.jms uri="jms:jndi:CallbackQueue"/>
+ </callback>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/simple/tempq.composite b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/simple/tempq.composite
new file mode 100644
index 0000000000..f9bccedfe9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/main/resources/simple/tempq.composite
@@ -0,0 +1,50 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="CallbackTempQComposite">
+
+<!--
+
+The client component does not define the callback destination so a temporary queue should be used
+
+-->
+
+ <component name="TQClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.JMSClientImpl" />
+ <reference name="myService">
+ <binding.jms uri="jms:jndi:TQServiceQueue"/>
+ <callback>
+ <binding.jms />
+ </callback>
+ </reference>
+ </component>
+
+ <component name="TQServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.JMSServiceImpl" />
+ <service name="JMSService">
+ <binding.jms uri="jms:jndi:TQServiceQueue"/>
+ <callback>
+ <binding.jms />
+ </callback>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java
new file mode 100644
index 0000000000..1661a4614c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class CallbackTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ JMSClient client = node.getService(JMSClient.class, "ClientComponent");
+
+ client.aClientMethod();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(JMSClientImpl.lock) {
+ JMSClientImpl.lock.wait(5000);
+ }
+
+ assertEquals("-> someMethod-> receiveResult", JMSClientImpl.result);
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java
new file mode 100644
index 0000000000..5897df6784
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.MalformedURLException;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class TempCallbackQTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() throws MalformedURLException {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ JMSClient client = node.getService(JMSClient.class, "ClientComponent");
+
+ client.aClientMethod();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized (JMSClientImpl.lock) {
+ JMSClientImpl.lock.wait(5000);
+ }
+
+ assertEquals("-> someMethod-> receiveResult", JMSClientImpl.result);
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/pom.xml b/sandbox/sebastien/java/embed/itest/jms/defaults/pom.xml
new file mode 100644
index 0000000000..df8dc88819
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-defaults</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with Defaults</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldClientImpl implements HelloWorldService {
+
+ private HelloWorldService serviceA;
+
+ @Reference
+ public void setServiceA(HelloWorldService service) {
+ this.serviceA = service;
+ }
+
+ public String sayHello(String name) {
+ return serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.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.jms;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ if ("bang".equals(name)) {
+ throw new RuntimeException("blem wit");
+ }
+ return "jmsHello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..f4da034c55
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:DefaultServiceComposite"/>
+ <deployable composite="itest:DefaultClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/defaults/client.composite b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/defaults/client.composite
new file mode 100644
index 0000000000..ebafbb6bcd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/defaults/client.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="DefaultClientComposite">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms uri="jms:jndi:HelloWorldService" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/defaults/service.composite b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/defaults/service.composite
new file mode 100644
index 0000000000..5354afb130
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/defaults/service.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="DefaultServiceComposite">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
+ <service name="HelloWorldService">
+ <binding.jms />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..c8b186a83c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.HelloWorldService = HelloWorldService
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java b/sandbox/sebastien/java/embed/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java
new file mode 100644
index 0000000000..d2b1a5fe59
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class DefaultsTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldService helloWorldService = node.getService(HelloWorldService.class, "HelloWorldClient");
+ assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra"));
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/pom.xml b/sandbox/sebastien/java/embed/itest/jms/definitions/pom.xml
new file mode 100644
index 0000000000..28e9dd74c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/pom.xml
@@ -0,0 +1,73 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-definitions</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Tests For Properties</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- uses ActiveMQ 5.1 as 4.1 Session.createQueue does not work using
+ a temporary queue name -->
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java
new file mode 100644
index 0000000000..b572b1012a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the OneWay service.
+ */
+@Service(OneWayService.class)
+public class OneWayClientImpl implements OneWayService {
+
+ private OneWayService serviceA;
+
+ @Reference
+ public void setServiceA(OneWayService service) {
+ this.serviceA = service;
+ }
+
+ public void sayHello(String name) {
+ serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
new file mode 100644
index 0000000000..9cec2d9b3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface OneWayService {
+
+ @OneWay
+ void sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
new file mode 100644
index 0000000000..6b763874df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+public class OneWayServiceImpl implements OneWayService {
+
+ public static Object lock = new Object();
+ public static String name;
+
+ public void sayHello(String name) {
+ OneWayServiceImpl.name = name;
+ synchronized (OneWayServiceImpl.lock) {
+ OneWayServiceImpl.lock.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a57e5befe2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:DefinitionsTests"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/definitions.xml b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/definitions.xml
new file mode 100644
index 0000000000..07b9f4aaa8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/definitions.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://jms" >
+
+ <binding.jms name="TestService" >
+ <destination name="MyServiceQueue" create="never"/>
+ <connectionFactory name="MyConnectionFactory"/>
+ </binding.jms>
+
+ </definitions>
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/definitions/definitions.composite b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/definitions/definitions.composite
new file mode 100644
index 0000000000..6e478e067d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/definitions/definitions.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest"
+ targetNamespace="http://itest"
+ name="DefinitionsTests">
+
+ <component name="OneWayClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms requestConnection="itest:TestService" />
+ </reference>
+ </component>
+
+ <component name="OneWayService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <binding.jms requestConnection="itest:TestService" />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..d7f64fda62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false&broker.useShutdownHook=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = MyConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.MyServiceQueue= MyServiceQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java b/sandbox/sebastien/java/embed/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java
new file mode 100644
index 0000000000..729ad072b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ */
+public class DefinitionsTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testSayHello() throws Exception {
+ OneWayService client = node.getService(OneWayService.class, "OneWayClient");
+
+ client.sayHello("petra");
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(OneWayServiceImpl.lock) {
+ if (OneWayServiceImpl.name == null) {
+ OneWayServiceImpl.lock.wait(5000);
+ }
+ }
+
+ assertEquals("petra", OneWayServiceImpl.name);
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/pom.xml b/sandbox/sebastien/java/embed/itest/jms/exceptions/pom.xml
new file mode 100644
index 0000000000..4189bb096e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/pom.xml
@@ -0,0 +1,90 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-nonscaclient-exceptions</artifactId>
+ <name>Apache Tuscany SCA iTest JMS NonSCA Client Exceptions</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java
new file mode 100644
index 0000000000..469882f3b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.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 org.apache.tuscany.sca.binding.jms;
+
+public class CheckedExcpetion extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetion(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java
new file mode 100644
index 0000000000..19b584950a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.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 org.apache.tuscany.sca.binding.jms;
+
+public class CheckedExcpetion2Args extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetion2Args(String s, Throwable e) {
+ super(s, e);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java
new file mode 100644
index 0000000000..b12e3a562e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.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 org.apache.tuscany.sca.binding.jms;
+
+public class CheckedExcpetionChained extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetionChained(Throwable e) {
+ super(e);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java
new file mode 100644
index 0000000000..b23db73c01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.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 org.apache.tuscany.sca.binding.jms;
+
+public class CheckedExcpetionNoArgs extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetionNoArgs() {
+ super();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java
new file mode 100644
index 0000000000..9e4c4c46d4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface ExceptionService {
+
+ public void throwChecked() throws CheckedExcpetion;
+ public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs;
+ public void throwChecked2Args() throws CheckedExcpetion2Args;
+ public void throwCheckedChained() throws CheckedExcpetionChained;
+
+ public void throwUnChecked();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java
new file mode 100644
index 0000000000..866acf1ce1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.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.binding.jms;
+
+public class ExceptionServiceImpl implements ExceptionService {
+
+ public void throwChecked() throws CheckedExcpetion {
+ throw new CheckedExcpetion("foo");
+ }
+
+ public void throwChecked2Args() throws CheckedExcpetion2Args {
+ throw new CheckedExcpetion2Args("foo", new Exception("bla"));
+ }
+
+ public void throwCheckedChained() throws CheckedExcpetionChained {
+ throw new CheckedExcpetionChained(new Exception("bla"));
+ }
+
+ public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs {
+ throw new CheckedExcpetionNoArgs();
+ }
+
+ public void throwUnChecked() {
+ throw new RuntimeException("bla");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..865bb39b4c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ExceptionServiceComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/exceptions/service.composite b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/exceptions/service.composite
new file mode 100644
index 0000000000..42e33330d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/exceptions/service.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="ExceptionServiceComposite">
+
+ <component name="TextExceptionService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ExceptionServiceImpl"/>
+ <service name="ExceptionService">
+ <binding.jms>
+ <destination jndiName="TextExceptionService"/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="ObjectExceptionService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ExceptionServiceImpl"/>
+ <service name="ExceptionService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsObject/>
+ <destination jndiName="ObjectExceptionService"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..72d5457faf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.TextExceptionService = TextRequestQueue
+queue.ObjectExceptionService = ObjectRequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
new file mode 100644
index 0000000000..2aeadc6faf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class ExceptionsTestCase {
+
+ private Node node;
+ private Session session;
+ private InitialContext context;
+ private Connection connection;
+
+ private static final String CHECKED_XML =
+ "<ns2:CheckedExcpetion xmlns:ns2=\"http://jms.binding.sca.tuscany.apache.org/\"><message>foo</message></ns2:CheckedExcpetion>";
+ private static final String CHECKED_NOARGS_XML = "<ns2:CheckedExcpetionNoArgs xmlns:ns2=\"http://jms.binding.sca.tuscany.apache.org/\" />";
+ private static final String CHECKED_2ARGS_XML =
+ "<ns2:CheckedExcpetion2Args xmlns:ns2=\"http://jms.binding.sca.tuscany.apache.org/\"><message>foo</message></ns2:CheckedExcpetion2Args>";
+ private static final String CHECKED_CHAINED_XML =
+ "<ns2:CheckedExcpetionChained xmlns:ns2=\"http://jms.binding.sca.tuscany.apache.org/\"><message>java.lang.Exception: bla</message></ns2:CheckedExcpetionChained>";
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testTextChecked() throws NamingException, JMSException, SAXException, IOException {
+ sendJMSTextRequest("throwChecked");
+ Message m = receiveJMSResponse();
+ assertXMLEqual(CHECKED_XML, ((TextMessage)m).getText());
+ }
+
+ @Test
+ public void testTextCheckedNoArgs() throws NamingException, JMSException, SAXException, IOException {
+ sendJMSTextRequest("throwCheckedNoArgs");
+ Message m = receiveJMSResponse();
+ assertXMLEqual(CHECKED_NOARGS_XML, ((TextMessage)m).getText());
+ }
+
+ @Test
+ public void testTextChecked2Args() throws NamingException, JMSException, SAXException, IOException {
+ sendJMSTextRequest("throwChecked2Args");
+ Message m = receiveJMSResponse();
+ assertXMLEqual(CHECKED_2ARGS_XML, ((TextMessage)m).getText());
+ }
+
+ @Test
+ public void testTextCheckedChained() throws NamingException, JMSException, SAXException, IOException {
+ sendJMSTextRequest("throwCheckedChained");
+ Message m = receiveJMSResponse();
+ assertXMLEqual(CHECKED_CHAINED_XML, ((TextMessage)m).getText());
+ }
+
+ @Test
+ public void testTextUnChecked() throws NamingException, JMSException, SAXException, IOException {
+ sendJMSTextRequest("throwUnChecked");
+ Message m = receiveJMSResponse();
+
+ // FIXME: what should the response message be for unchecked exceptions with wireFormat.textXML???
+ Object o = ((ObjectMessage)m).getObject();
+ assertTrue(o instanceof RuntimeException);
+ assertTrue("org.oasisopen.sca.ServiceRuntimeException".equals(o.getClass().getName()));
+ assertEquals("bla", ((RuntimeException)o).getMessage());
+ }
+
+ @Test
+ public void testObjectChecked() throws NamingException, JMSException {
+ sendJMSObjectRequest("throwChecked");
+ Message m = receiveJMSResponse();
+ Object o = ((ObjectMessage)m).getObject();
+ assertTrue(o instanceof CheckedExcpetion);
+ assertEquals("foo", ((CheckedExcpetion)o).getMessage());
+ }
+
+ @Test
+ public void testObjectCheckedNoArgs() throws NamingException, JMSException {
+ sendJMSObjectRequest("throwCheckedNoArgs");
+ Message m = receiveJMSResponse();
+ Object o = ((ObjectMessage)m).getObject();
+ assertTrue(o instanceof CheckedExcpetionNoArgs);
+ }
+
+ @Test
+ public void testObjectChecked2Args() throws NamingException, JMSException {
+ sendJMSObjectRequest("throwChecked2Args");
+ Message m = receiveJMSResponse();
+ Object o = ((ObjectMessage)m).getObject();
+ assertTrue(o instanceof CheckedExcpetion2Args);
+ assertEquals("foo", ((CheckedExcpetion2Args)o).getMessage());
+ assertEquals("bla", ((CheckedExcpetion2Args)o).getCause().getMessage());
+ }
+
+ @Test
+ public void testObjectCheckedChained() throws NamingException, JMSException {
+ sendJMSObjectRequest("throwCheckedChained");
+ Message m = receiveJMSResponse();
+ Object o = ((ObjectMessage)m).getObject();
+ assertTrue(o instanceof CheckedExcpetionChained);
+ assertEquals("bla", ((CheckedExcpetionChained)o).getCause().getMessage());
+ }
+
+ @Test
+ public void testObjectUnChecked() throws NamingException, JMSException {
+ sendJMSObjectRequest("throwUnChecked");
+ Message m = receiveJMSResponse();
+ Object o = ((ObjectMessage)m).getObject();
+ assertTrue(o instanceof RuntimeException);
+ assertTrue("org.oasisopen.sca.ServiceRuntimeException".equals(o.getClass().getName()));
+ assertEquals("bla", ((RuntimeException)o).getMessage());
+ }
+
+ @After
+ public void end() throws JMSException {
+ if (node != null) {
+ node.stop();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ }
+
+ private void sendJMSTextRequest(String operationName) throws NamingException, JMSException {
+ context = new InitialContext(new Properties());
+ ConnectionFactory cf = (ConnectionFactory)context.lookup("ConnectionFactory");
+ connection = cf.createConnection();
+ connection.start();
+
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Destination toDest = (Destination)context.lookup("TextExceptionService");
+
+ TextMessage m = session.createTextMessage();
+ m.setStringProperty("scaOperationName", operationName);
+ m.setJMSReplyTo((Destination)context.lookup("ResponseQueue"));
+ m.setText("<_ns_:" + operationName + " xmlns:_ns_=\"http://jms.binding.sca.tuscany.apache.org/\" />");
+
+ MessageProducer producer = session.createProducer(toDest);
+ producer.send(m);
+ }
+
+ private void sendJMSObjectRequest(String operationName) throws NamingException, JMSException {
+ context = new InitialContext(new Properties());
+ ConnectionFactory cf = (ConnectionFactory)context.lookup("ConnectionFactory");
+ connection = cf.createConnection();
+ connection.start();
+
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Destination toDest = (Destination)context.lookup("ObjectExceptionService");
+
+ ObjectMessage m = session.createObjectMessage();
+ m.setStringProperty("scaOperationName", operationName);
+ m.setJMSReplyTo((Destination)context.lookup("ResponseQueue"));
+ m.setObject(new Object[0]);
+
+ MessageProducer producer = session.createProducer(toDest);
+ producer.send(m);
+ }
+
+ private Message receiveJMSResponse() throws NamingException, JMSException {
+ Destination replyDest = (Destination)context.lookup("ResponseQueue");
+ MessageConsumer consumer = session.createConsumer(replyDest);
+ Message m = consumer.receive(5000);
+ if (m == null) {
+ throw new RuntimeException("No reply message received");
+ }
+ return m;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/pom.xml b/sandbox/sebastien/java/embed/itest/jms/exceptions1/pom.xml
new file mode 100644
index 0000000000..5c6dbaaaa2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-exceptions1</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with Exceptions1</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java
new file mode 100644
index 0000000000..469882f3b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.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 org.apache.tuscany.sca.binding.jms;
+
+public class CheckedExcpetion extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetion(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java
new file mode 100644
index 0000000000..19b584950a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.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 org.apache.tuscany.sca.binding.jms;
+
+public class CheckedExcpetion2Args extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetion2Args(String s, Throwable e) {
+ super(s, e);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java
new file mode 100644
index 0000000000..b12e3a562e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.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 org.apache.tuscany.sca.binding.jms;
+
+public class CheckedExcpetionChained extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetionChained(Throwable e) {
+ super(e);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java
new file mode 100644
index 0000000000..b23db73c01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.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 org.apache.tuscany.sca.binding.jms;
+
+public class CheckedExcpetionNoArgs extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetionNoArgs() {
+ super();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java
new file mode 100644
index 0000000000..9e4c4c46d4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface ExceptionService {
+
+ public void throwChecked() throws CheckedExcpetion;
+ public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs;
+ public void throwChecked2Args() throws CheckedExcpetion2Args;
+ public void throwCheckedChained() throws CheckedExcpetionChained;
+
+ public void throwUnChecked();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java
new file mode 100644
index 0000000000..02426936d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(ExceptionService.class)
+public class ExceptionServiceClient implements ExceptionService {
+
+ private ExceptionService service;
+
+ @Reference
+ public void setService(ExceptionService service) {
+ this.service = service;
+ }
+
+ public void throwChecked() throws CheckedExcpetion {
+ service.throwChecked();
+ }
+
+ public void throwChecked2Args() throws CheckedExcpetion2Args {
+ service.throwChecked2Args();
+ }
+
+ public void throwCheckedChained() throws CheckedExcpetionChained {
+ service.throwCheckedChained();
+ }
+
+ public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs {
+ service.throwCheckedNoArgs();
+ }
+
+ public void throwUnChecked() {
+ service.throwUnChecked();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java
new file mode 100644
index 0000000000..866acf1ce1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.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.binding.jms;
+
+public class ExceptionServiceImpl implements ExceptionService {
+
+ public void throwChecked() throws CheckedExcpetion {
+ throw new CheckedExcpetion("foo");
+ }
+
+ public void throwChecked2Args() throws CheckedExcpetion2Args {
+ throw new CheckedExcpetion2Args("foo", new Exception("bla"));
+ }
+
+ public void throwCheckedChained() throws CheckedExcpetionChained {
+ throw new CheckedExcpetionChained(new Exception("bla"));
+ }
+
+ public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs {
+ throw new CheckedExcpetionNoArgs();
+ }
+
+ public void throwUnChecked() {
+ throw new RuntimeException("bla");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..53504398bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ExceptionServiceComposite"/>
+ <deployable composite="itest:ExceptionClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/exceptions/client.composite b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/exceptions/client.composite
new file mode 100644
index 0000000000..86451dcf02
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/exceptions/client.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="ExceptionClientComposite">
+
+ <component name="ExceptionServiceClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ExceptionServiceClient"/>
+ <reference name="service">
+ <binding.jms uri="jms:jndi:ExceptionService" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/exceptions/service.composite b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/exceptions/service.composite
new file mode 100644
index 0000000000..dce41b86ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/exceptions/service.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="ExceptionServiceComposite">
+
+ <component name="ExceptionService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ExceptionServiceImpl"/>
+ <service name="ExceptionService">
+ <binding.jms />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..f7875b52a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.ExceptionService = ExceptionService
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
new file mode 100644
index 0000000000..0d897d8703
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class ExceptionsTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testChecked() {
+ ExceptionService service = node.getService(ExceptionService.class, "ExceptionServiceClient");
+ try {
+ service.throwChecked();
+ fail();
+ } catch (CheckedExcpetion e) {
+ assertEquals("foo", e.getMessage());
+ } catch (Throwable e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void testCheckedNoArgs() {
+ ExceptionService service = node.getService(ExceptionService.class, "ExceptionServiceClient");
+ try {
+ service.throwCheckedNoArgs();
+ fail();
+ } catch (CheckedExcpetionNoArgs e) {
+ // ok
+ }
+ }
+
+ @Test
+ public void testChecked2Args() {
+ ExceptionService service = node.getService(ExceptionService.class, "ExceptionServiceClient");
+ try {
+ service.throwChecked2Args();
+ fail();
+ } catch (CheckedExcpetion2Args e) {
+ assertEquals("foo", e.getMessage());
+// FIXME: TUSCANY-2848: lost the cause!
+// assertNotNull(e.getCause());
+// assertEquals("bla", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void testCheckedChained() {
+ ExceptionService service = node.getService(ExceptionService.class, "ExceptionServiceClient");
+ try {
+ service.throwCheckedChained();
+ fail();
+ } catch (CheckedExcpetionChained e) {
+ // FIXME: TUSCANY-2848: lost the cause!
+// assertNotNull(e.getCause());
+// assertEquals("bla", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void testUnChecked() {
+ ExceptionService service = node.getService(ExceptionService.class, "ExceptionServiceClient");
+ try {
+ service.throwUnChecked();
+ fail();
+ } catch (Exception e) {
+ assertEquals("bla", e.getCause().getMessage());
+ }
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/pom.xml b/sandbox/sebastien/java/embed/itest/jms/externalBroker/pom.xml
new file mode 100644
index 0000000000..ac890aa687
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-external-broker</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with External JMS Broker</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldClientImpl implements HelloWorldService {
+
+ private HelloWorldService serviceA;
+
+ @Reference
+ public void setServiceA(HelloWorldService service) {
+ this.serviceA = service;
+ }
+
+ public String sayHello(String name) {
+ return serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.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.jms;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ if ("bang".equals(name)) {
+ throw new RuntimeException("blem wit");
+ }
+ return "jmsHello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..5883e9a2d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ExternalServiceComposite"/>
+ <deployable composite="itest:ExternalClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/external/client.composite b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/external/client.composite
new file mode 100644
index 0000000000..e27e3818f8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/external/client.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="ExternalClientComposite">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61606">
+ <destination jndiName="DestQueueA"/>
+ <response>
+ <destination jndiName="RespQueueA"/>
+ </response>
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/external/service.composite b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/external/service.composite
new file mode 100644
index 0000000000..d5ab03e688
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/external/service.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="ExternalServiceComposite">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
+ <service name="HelloWorldService">
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61606">
+ <destination jndiName="DestQueueA" create="always"/>
+ <response>
+ <destination jndiName="RespQueueA" create="always"/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java
new file mode 100644
index 0000000000..53acb22e64
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.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.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests using the JMS binding with an external JMS broker
+ */
+public class ExternalBrokerTestCase {
+
+ private static Node node;
+ private BrokerService broker;
+
+ @Before
+ public void init() throws Exception {
+ startBroker();
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldService helloWorldService = node.getService(HelloWorldService.class, "HelloWorldClient");
+ assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra"));
+ }
+
+ @After
+ public void end() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ stopBroker();
+ }
+
+ protected void startBroker() throws Exception {
+ broker = new BrokerService();
+ broker.setPersistent(false);
+ broker.setUseJmx(false);
+ broker.addConnector("tcp://localhost:61606");
+ broker.start();
+ }
+ protected void stopBroker() throws Exception {
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/pom.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/pom.xml
new file mode 100644
index 0000000000..fac0721715
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-format-jmsbytes</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Message Format jmsbytes</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1acbfbd5ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..2d19d4bd82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3ccd54e9bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReference helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (Exception e) {
+ // Test to see what happens if we talk to a service
+ // that declares a checked exception through an
+ // interface that doesn't
+ stringValue += " " + e.getCause().getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b9a1ffd5ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b92959cfd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..ff5cf617f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) ;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ced023ecdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite
new file mode 100644
index 0000000000..cdd079810e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hw="http://helloworld"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsBytes/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsBytes/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java
new file mode 100644
index 0000000000..49cb0a69ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytes/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.HelloWorldReference;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class FormatJMSBytesTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldService = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent");
+
+ System.out.println(helloWorldService.getGreetings("Fred Bloggs"));
+/* TUSCANY-2967 - disable this change while we decide what to do and
+ * return faults as JMSObject messages to be consistent
+ * again with other wire formats
+ assertEquals("Hello Fred Bloggs " +
+ "org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.CheckedException: foo " +
+ "org.osoa.sca.ServiceRuntimeException: java.lang.RuntimeException: bla",
+ helloWorldService.getGreetings("Fred Bloggs"));
+*/
+ assertEquals("Hello Fred Bloggs " +
+ "foo " +
+ "remote service exception, see nested exception" ,
+ helloWorldService.getGreetings("Fred Bloggs"));
+
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/pom.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/pom.xml
new file mode 100644
index 0000000000..7705c82c55
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-format-jmsbytesxml</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Message Format jmsbytesxml</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1684c19c50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytesxml.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..cc7b7b11e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytesxml.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3742bd6ac6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.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.sca.binding.jms.format.jmsbytesxml.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (CheckedException e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..eae95b4201
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytesxml.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..a37a03d994
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.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.sca.binding.jms.format.jmsbytesxml.helloworld;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ced023ecdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite
new file mode 100644
index 0000000000..f74ab86a14
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hw="http://helloworld"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsbytesxml.helloworld.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsBytesXML/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsbytesxml.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsBytesXML/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java
new file mode 100644
index 0000000000..53498ce44d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.HelloWorldReference;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class FormatJMSBytesXMLTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldService = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent");
+
+ System.out.println(helloWorldService.getGreetings("Fred Bloggs"));
+ assertEquals("Hello Fred Bloggs foo remote service exception, see nested exception", helloWorldService.getGreetings("Fred Bloggs"));
+
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1acbfbd5ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..2d19d4bd82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3ccd54e9bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReference helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (Exception e) {
+ // Test to see what happens if we talk to a service
+ // that declares a checked exception through an
+ // interface that doesn't
+ stringValue += " " + e.getCause().getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b9a1ffd5ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b92959cfd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..ff5cf617f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) ;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/pom.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/pom.xml
new file mode 100644
index 0000000000..85cd35ec82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-format-jmsdefault</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Message Format jmsdefault</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1acbfbd5ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..2d19d4bd82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3ccd54e9bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReference helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (Exception e) {
+ // Test to see what happens if we talk to a service
+ // that declares a checked exception through an
+ // interface that doesn't
+ stringValue += " " + e.getCause().getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b9a1ffd5ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b92959cfd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..ff5cf617f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) ;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java
new file mode 100644
index 0000000000..530eac3d00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..1768816247
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.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 org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String name);
+
+ public String getPersonGreetings(Person person);
+
+ public void nullInVoidOut();
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..d0a5faaef7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.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.sca.binding.jms.format.jmsdefault.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ @Reference
+ protected HelloWorldService helloWorldService2;
+
+ @Reference
+ protected HelloWorldService helloWorldService3;
+
+ @Reference
+ protected HelloWorldService helloWorldService4;
+
+ public String getGreetings(String name){
+ String stringValue = helloWorldService1.getGreetings(name) + " " +
+ helloWorldService2.getGreetings(name) + " " +
+ helloWorldService3.getGreetings(name) + " " +
+ helloWorldService4.getGreetings(name);
+
+ try {
+ helloWorldService3.throwChecked(name);
+ } catch (CheckedException e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService3.throwUnChecked(name);
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService4.throwChecked(name);
+ } catch (CheckedException e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService4.throwUnChecked(name);
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ return stringValue;
+ }
+
+ public String getPersonGreetings(Person person){
+ return helloWorldService1.getPersonGreetings(person) + " " +
+ helloWorldService2.getPersonGreetings(person) + " " +
+ helloWorldService3.getPersonGreetings(person) + " " +
+ helloWorldService4.getPersonGreetings(person);
+ }
+
+ public void nullInVoidOut() {
+ helloWorldService1.nullInVoidOut();
+ helloWorldService2.nullInVoidOut();
+ helloWorldService3.nullInVoidOut();
+ helloWorldService4.nullInVoidOut();
+
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..204863423d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+
+ public String getPersonGreetings(Person person);
+
+ public void nullInVoidOut();
+
+ public void throwChecked(String msg) throws CheckedException;
+ public void throwUnChecked(String msg);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b143079fe3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public static int nullInVoidOutCalled = 0;
+
+ public String getGreetings(String name){
+ String response = "Hello " + name;
+ System.out.println("getGreetings: " + response);
+ return response;
+ }
+
+ public String getPersonGreetings(Person person){
+ String response = "Hello " + person.getFirstName() + " " + person.getLastName();
+ System.out.println("getPersonGreetings: " + response);
+ return response;
+ }
+
+ public void nullInVoidOut() {
+ System.out.println("nullInVoidOut");
+ nullInVoidOutCalled++;
+ }
+
+ public void throwChecked(String msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(String msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java
new file mode 100644
index 0000000000..b62d1b1f1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+public class Person {
+ String firstName;
+ String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ced023ecdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite
new file mode 100644
index 0000000000..56285ad234
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hw="http://helloworld"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService2" >
+ <binding.jms>
+ <wireFormat.jmsDefault/>
+ <destination jndiName="HelloWorldService2"/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService3" >
+ <binding.jms>
+ <wireFormat.jmsDefault/>
+ <destination jndiName="HelloWorldService3"/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService4" >
+ <binding.jms>
+ <wireFormat.jmsDefault/>
+ <destination jndiName="HelloWorldService4"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="HelloWorldServiceComponent2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldService" />
+ <binding.jms>
+ <destination jndiName="HelloWorldService2"/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="HelloWorldServiceComponent3">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <!--interface.wsdl interface="http://helloworld/textxml#wsdl.interface(HelloWorld)" /-->
+ <binding.jms>
+ <wireFormat.jmsDefault />
+ <destination jndiName="HelloWorldService3"/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="HelloWorldServiceComponent4">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <!--interface.wsdl interface="http://helloworld/textxml#wsdl.interface(HelloWorld)" /-->
+ <binding.jms>
+ <wireFormat.jmsDefault />
+ <destination jndiName="HelloWorldService4"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl
new file mode 100644
index 0000000000..935a2e73c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl
@@ -0,0 +1,139 @@
+<?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/textxml" xmlns:tns="http://helloworld/textxml" 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/textxml" 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>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld/textxml" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="PersonType">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string"/>
+ <xsd:element name="lastName" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <element name="getPersonGreetings">
+ <complexType>
+ <sequence>
+ <element name="person" type="PersonType"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getPersonGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getPersonGreetingsReturn" 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:message name="getPersonGreetingsRequest">
+ <wsdl:part element="tns:getPersonGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getPersonGreetingsResponse">
+ <wsdl:part element="tns:getPersonGreetingsResponse" 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:operation name="getPersonGreetings">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ <wsdl:output message="tns:getPersonGreetingsResponse" name="getPersonGreetingsResponse"/>
+ </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:operation name="getPersonGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getPersonGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getPersonGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <!-- wsdl:binding name="HelloWorldSoapJmsBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/jms"/>
+ <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:8085/HelloWorldService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java
new file mode 100644
index 0000000000..78c0239f0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsdefault/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldReference;
+import org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldServiceImpl;
+import org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.Person;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class FormatJMSDefaultTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldService = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent");
+
+ assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs foo remote service exception, see nested exception foo remote service exception, see nested exception", helloWorldService.getGreetings("Fred Bloggs"));
+
+ Person person = new Person();
+ person.setFirstName("Fred");
+ person.setLastName("Bloggs");
+ assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs", helloWorldService.getPersonGreetings(person));
+
+ // this just makes sure that there are no exceptions thrown for this case
+ helloWorldService.nullInVoidOut();
+ Assert.assertEquals(4, HelloWorldServiceImpl.nullInVoidOutCalled);
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/pom.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/pom.xml
new file mode 100644
index 0000000000..312dea14fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-format-jmsmessage</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Message Format jmsmessage</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1acbfbd5ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..2d19d4bd82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3ccd54e9bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReference helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (Exception e) {
+ // Test to see what happens if we talk to a service
+ // that declares a checked exception through an
+ // interface that doesn't
+ stringValue += " " + e.getCause().getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b9a1ffd5ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b92959cfd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..ff5cf617f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) ;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..490bd5d4a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.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.binding.jms.format.jmsmessage.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..5aed6b12d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsmessage.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReferenceSide helloWorldService1;
+
+ public String getGreetings(String name){
+ helloWorldService1.getGreetings(name);
+
+ try {
+ Thread.sleep(2000);
+ } catch (Exception ex) {
+ // do nothing
+ }
+
+ return HelloWorldServiceImpl.getGreetings();
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..efe2f1a4dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ @OneWay
+ public void onMessage(javax.jms.Message message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..c1011ce6fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld;
+
+import javax.jms.TextMessage;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ private static String greetings = "not set";
+
+ public void onMessage(javax.jms.Message message){
+
+ String name = null;
+
+ try {
+ name = ((TextMessage)message).getText();
+ } catch (Exception ex) {
+ name = "EXCEPTION";
+ }
+ greetings = "Hello " + name;
+ }
+
+ public static String getGreetings(){
+ return greetings;
+ }
+
+ // javax.jms.BytesMessage
+ // javax.jms.MapMessage
+ // javax.jms.ObjectMessage
+ // javax.jms.StreamMessage
+ // javax.jms.TextMessage
+
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java
new file mode 100644
index 0000000000..d863b3a0a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.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.sca.binding.jms.format.jmsmessage.helloworld;
+
+import javax.jws.soap.SOAPBinding;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReferenceSide {
+
+ @OneWay
+ @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
+ public void getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README
new file mode 100644
index 0000000000..0f7a730b91
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README
@@ -0,0 +1,3 @@
+This test uses an SCA composite to fake a scenario where the reference is an SCA reference but the
+service is a non-SCA JMS endpoint. This gives us the opportunity to play about with the interface
+configuration at the reference to see how the contents of the JMS message can be controlled. \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ced023ecdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite
new file mode 100644
index 0000000000..48608ba9b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite
@@ -0,0 +1,46 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:hw="http://helloworld"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <!--interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)"/-->
+ <interface.java interface="org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld.HelloWorldServiceReferenceSide"/>
+ <binding.jms>
+ <tuscany:wireFormat.jmsText/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl
new file mode 100644
index 0000000000..f72ce434fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl
@@ -0,0 +1,129 @@
+<?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">
+
+ <xsd:complexType name="PersonType">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string"/>
+ <xsd:element name="lastName" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <element name="getPersonGreetings">
+ <complexType>
+ <sequence>
+ <element name="person" type="PersonType"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getPersonGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getPersonGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <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:part type="xsd:string" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <!-- wsdl:part element="tns:getGreetingsResponse" name="parameters"/-->
+ <wsdl:part type="xsd:string" name="parameters"/>
+ </wsdl:message>
+
+ <!-- wsdl:message name="getPersonGreetingsRequest">
+ <wsdl:part element="tns:getPersonGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getPersonGreetingsResponse">
+ <wsdl:part element="tns:getPersonGreetingsResponse" 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:operation name="getPersonGreetings">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ <wsdl:output message="tns:getPersonGreetingsResponse" name="getPersonGreetingsResponse"/>
+ </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:binding name="HelloWorldSoapJmsBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/jms"/>
+ <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:8085/HelloWorldService"/>
+ </wsdl:port>
+ </wsdl:service-->
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java
new file mode 100644
index 0000000000..f47031da10
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsmessage/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld.HelloWorldReference;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class FormatJMSMessageTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldService = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent");
+
+ System.out.println(helloWorldService.getGreetings("Fred Bloggs"));
+ assertEquals("Hello Fred Bloggs", helloWorldService.getGreetings("Fred Bloggs"));
+
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/pom.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/pom.xml
new file mode 100644
index 0000000000..9e784d5f4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-format-jmsobject</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Message Format jmsobject</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1acbfbd5ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..2d19d4bd82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3ccd54e9bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReference helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (Exception e) {
+ // Test to see what happens if we talk to a service
+ // that declares a checked exception through an
+ // interface that doesn't
+ stringValue += " " + e.getCause().getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b9a1ffd5ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b92959cfd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..ff5cf617f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) ;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java
new file mode 100644
index 0000000000..a1c38f7295
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..3b34dbae85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.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.binding.jms.format.jmsobject.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetingsWrapSingle(String firstName, String lastName);
+ public String getGreetingsDontWrapSingle(String firstName, String lastName);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..443d2aa746
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldServiceWrapSingle;
+
+ @Reference
+ protected HelloWorldService helloWorldServiceDontWrapSingle;
+
+ public String getGreetingsWrapSingle(String firstName, String lastName){
+ Person person = new Person();
+ person.setFirstName(firstName);
+ person.setLastName(lastName);
+
+ String returnString = "";
+
+ Person returnPerson = helloWorldServiceWrapSingle.getPersonGreetings(person);
+ returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName();
+
+ Person returnNullPerson = helloWorldServiceWrapSingle.getNullReturnGreetings(person);
+
+ if (returnNullPerson == null){
+ returnString += " Hello2 null";
+ }
+
+ String returnGreeting = helloWorldServiceWrapSingle.getArrayGreeting(new String[]{firstName, lastName});
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceWrapSingle.getMultiArrayGreetings(new String[]{firstName, firstName},new String[]{lastName, lastName});
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceWrapSingle.getMultiGreetings(firstName, lastName);
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceWrapSingle.getObjectGreeting(person);
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceWrapSingle.getObjectArrayGreeting(new Object[]{person});
+ returnString += " " + returnGreeting;
+
+ return returnString;
+ }
+
+ public String getGreetingsDontWrapSingle(String firstName, String lastName){
+ Person person = new Person();
+ person.setFirstName(firstName);
+ person.setLastName(lastName);
+
+ String returnString = "";
+
+ Person returnPerson = helloWorldServiceDontWrapSingle.getPersonGreetings(person);
+ returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName();
+
+ Person returnNullPerson = helloWorldServiceDontWrapSingle.getNullReturnGreetings(person);
+
+ if (returnNullPerson == null){
+ returnString += " Hello2 null";
+ }
+
+ String returnGreeting = helloWorldServiceDontWrapSingle.getArrayGreeting(new String[]{firstName, lastName});
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceDontWrapSingle.getMultiArrayGreetings(new String[]{firstName, firstName},new String[]{lastName, lastName});
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceDontWrapSingle.getMultiGreetings(firstName, lastName);
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceDontWrapSingle.getObjectGreeting(person);
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceDontWrapSingle.getObjectArrayGreeting(new Object[]{person});
+ returnString += " " + returnGreeting;
+
+ try {
+ helloWorldServiceDontWrapSingle.throwChecked(person);
+ } catch (CheckedException e) {
+ returnString += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldServiceDontWrapSingle.throwUnChecked(person);
+ } catch (Exception e) {
+ returnString += " " + e.getCause().getMessage();
+ }
+
+ return returnString;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b179a86f52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.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.binding.jms.format.jmsobject.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public Person getPersonGreetings(Person person);
+ public Person getNullReturnGreetings(Person person);
+ public String getArrayGreeting(String[] names);
+ public String getMultiArrayGreetings(String[] firstName, String[] lastName);
+ public String getMultiGreetings(String firstName, String lastName);
+ public String getObjectGreeting(Object person);
+ public String getObjectArrayGreeting(Object[] pearson);
+
+ public void throwChecked(Person person) throws CheckedException;
+ public void throwUnChecked(Person person);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..fa9e9eb1cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.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.sca.binding.jms.format.jmsobject.helloworld;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public Person getPersonGreetings(Person person){
+
+ person.setFirstName("Hello1 " + person.getFirstName());
+ person.setLastName("Hello1 " + person.getLastName());
+
+ return person;
+ }
+
+ public Person getNullReturnGreetings(Person person){
+ return null;
+ }
+
+ public String getArrayGreeting(String[] names) {
+ return "Hello3 " + names[0];
+ }
+
+ public String getMultiArrayGreetings(String[] firstName, String[] lastName) {
+ return "Hello4 " + firstName[0] + " " + lastName[0];
+ }
+
+ public String getMultiGreetings(String firstName, String lastName) {
+ return "Hello5 " + firstName + " " + lastName;
+ }
+
+ public String getObjectGreeting(Object person) {
+ return "Hello6 " + ((Person)person).getFirstName() + " " + ((Person)person).getLastName();
+ }
+
+ public String getObjectArrayGreeting(Object[] person) {
+ return "Hello7 " + ((Person)person[0]).getFirstName() + " " + ((Person)person[0]).getLastName();
+ }
+
+ public void throwChecked(Person person) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(Person person) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java
new file mode 100644
index 0000000000..29233d74a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.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.sca.binding.jms.format.jmsobject.helloworld;
+
+import java.io.Serializable;
+
+public class Person implements Serializable {
+
+ private static final long serialVersionUID = -6842761353978551779L;
+
+ String firstName;
+ String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ced023ecdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite
new file mode 100644
index 0000000000..7950309b07
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite
@@ -0,0 +1,61 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:hw="http://helloworld"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld.HelloWorldReferenceImpl" />
+ <reference name="helloWorldServiceWrapSingle" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsObject wrapSingle="true"/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldServiceDontWrapSingle" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsObject wrapSingle="false" />
+ <destination jndiName="HelloWorldService2"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsObject wrapSingle="true"/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="HelloWorldServiceComponent2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsObject /> <!-- test that wrapSingle default works -->
+ <destination jndiName="HelloWorldService2"/>
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java
new file mode 100644
index 0000000000..a2bfc0ca8a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.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.jms.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld.HelloWorldReference;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class FormatJMSObjectTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldService = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent");
+
+ assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs",
+ helloWorldService.getGreetingsWrapSingle("Fred", "Bloggs"));
+
+ assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs foo bla",
+ helloWorldService.getGreetingsDontWrapSingle("Fred", "Bloggs"));
+
+ }
+
+ @Ignore
+ @Test
+ public void testWaitForInput() {
+ System.out.println("Press a key to end");
+ try {
+ System.in.read();
+ } catch (Exception ex) {
+ }
+ System.out.println("Shutting down");
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/pom.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/pom.xml
new file mode 100644
index 0000000000..a416b7ae72
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-format-jmstext</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Message Format jmstext</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1acbfbd5ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..2d19d4bd82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3ccd54e9bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReference helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (Exception e) {
+ // Test to see what happens if we talk to a service
+ // that declares a checked exception through an
+ // interface that doesn't
+ stringValue += " " + e.getCause().getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b9a1ffd5ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b92959cfd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..ff5cf617f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) ;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java
new file mode 100644
index 0000000000..57ad23e064
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..ea8d5ffd28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.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.binding.jms.format.jmstext.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..afcd391009
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.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.sca.binding.jms.format.jmstext.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ public String getGreetings(String name){
+ String stringValue = helloWorldService1.getStringGreetings(name);
+
+ try {
+ helloWorldService1.throwChecked(name);
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name);
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..8af585c13c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getStringGreetings(String msg);
+
+ public void throwChecked(String msg) throws CheckedException;
+ public void throwUnChecked(String msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..4f0a6fe4c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String getStringGreetings(String msg){
+
+ msg = "Hello " + msg;
+ return msg;
+ }
+
+ public void throwChecked(String msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(String msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..a8dd686725
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public String getStringGreetings(String msg);
+
+ public void throwChecked(String msg) ;
+ public void throwUnChecked(String msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ced023ecdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite
new file mode 100644
index 0000000000..a9e8782f94
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hw="http://helloworld"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsText/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsText/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java
new file mode 100644
index 0000000000..b887aa18fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstext/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.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.binding.jms.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.HelloWorldReference;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class FormatJMSTextTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldService = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent");
+
+ System.out.println(helloWorldService.getGreetings("Fred Bloggs"));
+ assertEquals("Hello Fred Bloggs " +
+ "foo remote service exception, see nested exception",
+ helloWorldService.getGreetings("Fred Bloggs"));
+
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/pom.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/pom.xml
new file mode 100644
index 0000000000..9235ad3f93
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-format-jmstextxml</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Message Format jmstextxml</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java
new file mode 100644
index 0000000000..5e9a7a316e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..768b293380
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String name);
+ public String getPersonGreetings(Person person);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..2bac5db5ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ @Reference
+ protected HelloWorldService helloWorldService2;
+
+ @Reference
+ protected HelloWorldService helloWorldService3;
+
+ public String getGreetings(String name){
+ String stringValue = helloWorldService1.getGreetings(name) + " " +
+ helloWorldService2.getGreetings(name) + " " +
+ helloWorldService3.getGreetings(name);
+
+ return stringValue;
+ }
+
+ public String getPersonGreetings(Person person){
+ String stringValue = helloWorldService1.getPersonGreetings(person) + " " +
+ helloWorldService2.getPersonGreetings(person) + " " +
+ helloWorldService3.getPersonGreetings(person);
+
+ try {
+ helloWorldService1.throwChecked(person.getLastName());
+ } catch (CheckedException e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(person.getLastName());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..fe200e3cbe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+ public String getPersonGreetings(Person person);
+
+ public String throwChecked(String msg) throws CheckedException;
+ public String throwUnChecked(String msg);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..80624ee770
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.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.binding.jms.format.jmstextxml.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String getGreetings(String name){
+ String response = "Hello " + name;
+ System.out.println("getGreetings: " + response);
+ return response;
+ }
+
+ public String getPersonGreetings(Person person){
+ String response = "Hello " + person.getFirstName() + " " + person.getLastName();
+ System.out.println("getPersonGreetings: " + response);
+ return response;
+ }
+
+ public String throwChecked(String msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public String throwUnChecked(String msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java
new file mode 100644
index 0000000000..175b482c81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+public class Person {
+ String firstName;
+ String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ced023ecdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite
new file mode 100644
index 0000000000..c15d99550e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite
@@ -0,0 +1,80 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hw="http://helloworld"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsTextXML/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService2" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsTextXML/>
+ <destination jndiName="HelloWorldService2"/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService3" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsTextXML/>
+ <destination jndiName="HelloWorldService3"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsTextXML/>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="HelloWorldServiceComponent2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.HelloWorldService" />
+ <binding.jms>
+ <tuscany:wireFormat.jmsTextXML/>
+ <destination jndiName="HelloWorldService2"/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="HelloWorldServiceComponent3">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <interface.wsdl interface="http://helloworld/textxml#wsdl.interface(HelloWorld)" />
+ <binding.jms>
+ <tuscany:wireFormat.jmsTextXML/>
+ <destination jndiName="HelloWorldService3"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl
new file mode 100644
index 0000000000..ac68c85fd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl
@@ -0,0 +1,161 @@
+<?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/textxml" xmlns:tns="http://helloworld/textxml" 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/textxml" 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>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld/textxml" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="PersonType">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string"/>
+ <xsd:element name="lastName" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <element name="getPersonGreetings">
+ <complexType>
+ <sequence>
+ <element name="person" type="PersonType"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getPersonGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getPersonGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="CheckedException" type="CheckedException" />
+
+ <complexType name="CheckedException">
+ <sequence>
+ <element minOccurs="0" name="message" type="xsd:string" />
+ </sequence>
+ </complexType>
+
+ </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:message name="getPersonGreetingsRequest">
+ <wsdl:part element="tns:getPersonGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getPersonGreetingsResponse">
+ <wsdl:part element="tns:getPersonGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="CheckedException">
+ <wsdl:part element="tns:CheckedException" name="fault" />
+ </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:operation name="getPersonGreetings">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ <wsdl:output message="tns:getPersonGreetingsResponse" name="getPersonGreetingsResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="throwChecked">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ <wsdl:output message="tns:getPersonGreetingsResponse" name="getPersonGreetingsResponse"/>
+ <wsdl:fault message="tns:CheckedException" name="CheckedException"/>
+ </wsdl:operation>
+ <wsdl:operation name="throwUnChecked">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ <wsdl:output message="tns:getPersonGreetingsResponse" name="getPersonGreetingsResponse"/>
+ </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:operation name="getPersonGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getPersonGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getPersonGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <!-- wsdl:binding name="HelloWorldSoapJmsBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/jms"/>
+ <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:8085/HelloWorldService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java
new file mode 100644
index 0000000000..6054050a5d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.HelloWorldReference;
+import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.Person;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class FormatJMSTextXMLTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldService = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent");
+
+ assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs", helloWorldService.getGreetings("Fred Bloggs"));
+
+ Person person = new Person();
+ person.setFirstName("Fred");
+ person.setLastName("Bloggs");
+ assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs foo remote service exception, see nested exception", helloWorldService.getPersonGreetings(person));
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml
new file mode 100644
index 0000000000..28da31fbde
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-format-jmstextxmlinjmsobjectout</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Message Format jmstextxmlinjmsobjectout</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1acbfbd5ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..2d19d4bd82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3ccd54e9bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReference helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (Exception e) {
+ // Test to see what happens if we talk to a service
+ // that declares a checked exception through an
+ // interface that doesn't
+ stringValue += " " + e.getCause().getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b9a1ffd5ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b92959cfd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..ff5cf617f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) ;
+ public void throwUnChecked(byte[] msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1684c19c50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsbytesxml.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..cc7b7b11e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.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.binding.jms.format.jmsbytesxml.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3742bd6ac6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.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.sca.binding.jms.format.jmsbytesxml.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ public String getGreetings(String name){
+ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes());
+ String stringValue = new String(bytesValue);
+
+ try {
+ helloWorldService1.throwChecked(name.getBytes());
+ } catch (CheckedException e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name.getBytes());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..eae95b4201
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsbytesxml.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg);
+
+ public void throwChecked(byte[] msg) throws CheckedException;
+ public void throwUnChecked(byte[] msg);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..a37a03d994
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.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.sca.binding.jms.format.jmsbytesxml.helloworld;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public byte[] getByteArrayGreetings(byte[] msg){
+
+ String name = new String(msg);
+ name = "Hello " + name;
+
+ return name.getBytes();
+ }
+
+ public void throwChecked(byte[] msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(byte[] msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java
new file mode 100644
index 0000000000..530eac3d00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..1768816247
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.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 org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String name);
+
+ public String getPersonGreetings(Person person);
+
+ public void nullInVoidOut();
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..d0a5faaef7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.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.sca.binding.jms.format.jmsdefault.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ @Reference
+ protected HelloWorldService helloWorldService2;
+
+ @Reference
+ protected HelloWorldService helloWorldService3;
+
+ @Reference
+ protected HelloWorldService helloWorldService4;
+
+ public String getGreetings(String name){
+ String stringValue = helloWorldService1.getGreetings(name) + " " +
+ helloWorldService2.getGreetings(name) + " " +
+ helloWorldService3.getGreetings(name) + " " +
+ helloWorldService4.getGreetings(name);
+
+ try {
+ helloWorldService3.throwChecked(name);
+ } catch (CheckedException e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService3.throwUnChecked(name);
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService4.throwChecked(name);
+ } catch (CheckedException e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService4.throwUnChecked(name);
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ return stringValue;
+ }
+
+ public String getPersonGreetings(Person person){
+ return helloWorldService1.getPersonGreetings(person) + " " +
+ helloWorldService2.getPersonGreetings(person) + " " +
+ helloWorldService3.getPersonGreetings(person) + " " +
+ helloWorldService4.getPersonGreetings(person);
+ }
+
+ public void nullInVoidOut() {
+ helloWorldService1.nullInVoidOut();
+ helloWorldService2.nullInVoidOut();
+ helloWorldService3.nullInVoidOut();
+ helloWorldService4.nullInVoidOut();
+
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..204863423d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+
+ public String getPersonGreetings(Person person);
+
+ public void nullInVoidOut();
+
+ public void throwChecked(String msg) throws CheckedException;
+ public void throwUnChecked(String msg);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b143079fe3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public static int nullInVoidOutCalled = 0;
+
+ public String getGreetings(String name){
+ String response = "Hello " + name;
+ System.out.println("getGreetings: " + response);
+ return response;
+ }
+
+ public String getPersonGreetings(Person person){
+ String response = "Hello " + person.getFirstName() + " " + person.getLastName();
+ System.out.println("getPersonGreetings: " + response);
+ return response;
+ }
+
+ public void nullInVoidOut() {
+ System.out.println("nullInVoidOut");
+ nullInVoidOutCalled++;
+ }
+
+ public void throwChecked(String msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(String msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java
new file mode 100644
index 0000000000..b62d1b1f1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld;
+
+public class Person {
+ String firstName;
+ String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..490bd5d4a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.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.binding.jms.format.jmsmessage.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..5aed6b12d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.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.binding.jms.format.jmsmessage.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldServiceReferenceSide helloWorldService1;
+
+ public String getGreetings(String name){
+ helloWorldService1.getGreetings(name);
+
+ try {
+ Thread.sleep(2000);
+ } catch (Exception ex) {
+ // do nothing
+ }
+
+ return HelloWorldServiceImpl.getGreetings();
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..efe2f1a4dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ @OneWay
+ public void onMessage(javax.jms.Message message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..c1011ce6fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld;
+
+import javax.jms.TextMessage;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ private static String greetings = "not set";
+
+ public void onMessage(javax.jms.Message message){
+
+ String name = null;
+
+ try {
+ name = ((TextMessage)message).getText();
+ } catch (Exception ex) {
+ name = "EXCEPTION";
+ }
+ greetings = "Hello " + name;
+ }
+
+ public static String getGreetings(){
+ return greetings;
+ }
+
+ // javax.jms.BytesMessage
+ // javax.jms.MapMessage
+ // javax.jms.ObjectMessage
+ // javax.jms.StreamMessage
+ // javax.jms.TextMessage
+
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java
new file mode 100644
index 0000000000..d863b3a0a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.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.sca.binding.jms.format.jmsmessage.helloworld;
+
+import javax.jws.soap.SOAPBinding;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReferenceSide {
+
+ @OneWay
+ @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
+ public void getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README
new file mode 100644
index 0000000000..0f7a730b91
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README
@@ -0,0 +1,3 @@
+This test uses an SCA composite to fake a scenario where the reference is an SCA reference but the
+service is a non-SCA JMS endpoint. This gives us the opportunity to play about with the interface
+configuration at the reference to see how the contents of the JMS message can be controlled. \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java
new file mode 100644
index 0000000000..a1c38f7295
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..3b34dbae85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.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.binding.jms.format.jmsobject.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetingsWrapSingle(String firstName, String lastName);
+ public String getGreetingsDontWrapSingle(String firstName, String lastName);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..443d2aa746
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldServiceWrapSingle;
+
+ @Reference
+ protected HelloWorldService helloWorldServiceDontWrapSingle;
+
+ public String getGreetingsWrapSingle(String firstName, String lastName){
+ Person person = new Person();
+ person.setFirstName(firstName);
+ person.setLastName(lastName);
+
+ String returnString = "";
+
+ Person returnPerson = helloWorldServiceWrapSingle.getPersonGreetings(person);
+ returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName();
+
+ Person returnNullPerson = helloWorldServiceWrapSingle.getNullReturnGreetings(person);
+
+ if (returnNullPerson == null){
+ returnString += " Hello2 null";
+ }
+
+ String returnGreeting = helloWorldServiceWrapSingle.getArrayGreeting(new String[]{firstName, lastName});
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceWrapSingle.getMultiArrayGreetings(new String[]{firstName, firstName},new String[]{lastName, lastName});
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceWrapSingle.getMultiGreetings(firstName, lastName);
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceWrapSingle.getObjectGreeting(person);
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceWrapSingle.getObjectArrayGreeting(new Object[]{person});
+ returnString += " " + returnGreeting;
+
+ return returnString;
+ }
+
+ public String getGreetingsDontWrapSingle(String firstName, String lastName){
+ Person person = new Person();
+ person.setFirstName(firstName);
+ person.setLastName(lastName);
+
+ String returnString = "";
+
+ Person returnPerson = helloWorldServiceDontWrapSingle.getPersonGreetings(person);
+ returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName();
+
+ Person returnNullPerson = helloWorldServiceDontWrapSingle.getNullReturnGreetings(person);
+
+ if (returnNullPerson == null){
+ returnString += " Hello2 null";
+ }
+
+ String returnGreeting = helloWorldServiceDontWrapSingle.getArrayGreeting(new String[]{firstName, lastName});
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceDontWrapSingle.getMultiArrayGreetings(new String[]{firstName, firstName},new String[]{lastName, lastName});
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceDontWrapSingle.getMultiGreetings(firstName, lastName);
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceDontWrapSingle.getObjectGreeting(person);
+ returnString += " " + returnGreeting;
+
+ returnGreeting = helloWorldServiceDontWrapSingle.getObjectArrayGreeting(new Object[]{person});
+ returnString += " " + returnGreeting;
+
+ try {
+ helloWorldServiceDontWrapSingle.throwChecked(person);
+ } catch (CheckedException e) {
+ returnString += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldServiceDontWrapSingle.throwUnChecked(person);
+ } catch (Exception e) {
+ returnString += " " + e.getCause().getMessage();
+ }
+
+ return returnString;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b179a86f52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.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.binding.jms.format.jmsobject.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public Person getPersonGreetings(Person person);
+ public Person getNullReturnGreetings(Person person);
+ public String getArrayGreeting(String[] names);
+ public String getMultiArrayGreetings(String[] firstName, String[] lastName);
+ public String getMultiGreetings(String firstName, String lastName);
+ public String getObjectGreeting(Object person);
+ public String getObjectArrayGreeting(Object[] pearson);
+
+ public void throwChecked(Person person) throws CheckedException;
+ public void throwUnChecked(Person person);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..fa9e9eb1cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.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.sca.binding.jms.format.jmsobject.helloworld;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public Person getPersonGreetings(Person person){
+
+ person.setFirstName("Hello1 " + person.getFirstName());
+ person.setLastName("Hello1 " + person.getLastName());
+
+ return person;
+ }
+
+ public Person getNullReturnGreetings(Person person){
+ return null;
+ }
+
+ public String getArrayGreeting(String[] names) {
+ return "Hello3 " + names[0];
+ }
+
+ public String getMultiArrayGreetings(String[] firstName, String[] lastName) {
+ return "Hello4 " + firstName[0] + " " + lastName[0];
+ }
+
+ public String getMultiGreetings(String firstName, String lastName) {
+ return "Hello5 " + firstName + " " + lastName;
+ }
+
+ public String getObjectGreeting(Object person) {
+ return "Hello6 " + ((Person)person).getFirstName() + " " + ((Person)person).getLastName();
+ }
+
+ public String getObjectArrayGreeting(Object[] person) {
+ return "Hello7 " + ((Person)person[0]).getFirstName() + " " + ((Person)person[0]).getLastName();
+ }
+
+ public void throwChecked(Person person) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(Person person) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java
new file mode 100644
index 0000000000..29233d74a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.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.sca.binding.jms.format.jmsobject.helloworld;
+
+import java.io.Serializable;
+
+public class Person implements Serializable {
+
+ private static final long serialVersionUID = -6842761353978551779L;
+
+ String firstName;
+ String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java
new file mode 100644
index 0000000000..57ad23e064
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..ea8d5ffd28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.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.binding.jms.format.jmstext.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String message);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..afcd391009
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.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.sca.binding.jms.format.jmstext.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ public String getGreetings(String name){
+ String stringValue = helloWorldService1.getStringGreetings(name);
+
+ try {
+ helloWorldService1.throwChecked(name);
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(name);
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..8af585c13c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getStringGreetings(String msg);
+
+ public void throwChecked(String msg) throws CheckedException;
+ public void throwUnChecked(String msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..4f0a6fe4c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String getStringGreetings(String msg){
+
+ msg = "Hello " + msg;
+ return msg;
+ }
+
+ public void throwChecked(String msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(String msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..a8dd686725
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldServiceReference {
+
+ public String getStringGreetings(String msg);
+
+ public void throwChecked(String msg) ;
+ public void throwUnChecked(String msg);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java
new file mode 100644
index 0000000000..5e9a7a316e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.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 org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+public class CheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedException(String s) {
+ super(s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..768b293380
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String name);
+ public String getPersonGreetings(Person person);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..2bac5db5ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ @Reference
+ protected HelloWorldService helloWorldService2;
+
+ @Reference
+ protected HelloWorldService helloWorldService3;
+
+ public String getGreetings(String name){
+ String stringValue = helloWorldService1.getGreetings(name) + " " +
+ helloWorldService2.getGreetings(name) + " " +
+ helloWorldService3.getGreetings(name);
+
+ return stringValue;
+ }
+
+ public String getPersonGreetings(Person person){
+ String stringValue = helloWorldService1.getPersonGreetings(person) + " " +
+ helloWorldService2.getPersonGreetings(person) + " " +
+ helloWorldService3.getPersonGreetings(person);
+
+ try {
+ helloWorldService1.throwChecked(person.getLastName());
+ } catch (CheckedException e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ try {
+ helloWorldService1.throwUnChecked(person.getLastName());
+ } catch (Exception e) {
+ stringValue += " " + e.getMessage();
+ }
+
+ return stringValue;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..be2af78958
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+ public String getPersonGreetings(Person person);
+
+ public void throwChecked(String msg) throws CheckedException;
+ public void throwUnChecked(String msg);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..e85d4ca5a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.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.binding.jms.format.jmstextxml.helloworld;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String getGreetings(String name){
+ String response = "Hello " + name;
+ System.out.println("getGreetings: " + response);
+ return response;
+ }
+
+ public String getPersonGreetings(Person person){
+ String response = "Hello " + person.getFirstName() + " " + person.getLastName();
+ System.out.println("getPersonGreetings: " + response);
+ return response;
+ }
+
+ public void throwChecked(String msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(String msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java
new file mode 100644
index 0000000000..175b482c81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld;
+
+public class Person {
+ String firstName;
+ String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..7bb33ae270
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.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 org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldService {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ public String getGreetings(String name){
+ return helloWorldService1.getGreetings(name).toString();
+ }
+
+ public String getPersonGreetings(Person person){
+ return helloWorldService1.getPersonGreetings(person).toString();
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..9f955c278a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+
+ public String getPersonGreetings(Person person);
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..7c1cce6087
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.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 org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String getGreetings(String name){
+ String response = "Hello " + name;
+ System.out.println("getGreetings: " + response);
+ return response;
+ }
+
+ public String getPersonGreetings(Person person){
+ String response = "Hello " + person.getFirstName() + " " + person.getLastName();
+ System.out.println("getPersonGreetings: " + response);
+ return response;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java
new file mode 100644
index 0000000000..3d41f656f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld;
+
+public class Person {
+ String firstName;
+ String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ced023ecdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite
new file mode 100644
index 0000000000..79dd18b027
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hw="http://helloworld"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <binding.jms>
+ <tuscany:wireFormat.jmsTextXML/>
+ <destination jndiName="HelloWorldService1"/>
+ <response>
+ <tuscany:wireFormat.jmsObject/>
+ </response>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsTextXML/>
+ <destination jndiName="HelloWorldService1"/>
+ <response>
+ <tuscany:wireFormat.jmsObject/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl
new file mode 100644
index 0000000000..935a2e73c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl
@@ -0,0 +1,139 @@
+<?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/textxml" xmlns:tns="http://helloworld/textxml" 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/textxml" 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>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld/textxml" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="PersonType">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string"/>
+ <xsd:element name="lastName" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <element name="getPersonGreetings">
+ <complexType>
+ <sequence>
+ <element name="person" type="PersonType"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getPersonGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getPersonGreetingsReturn" 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:message name="getPersonGreetingsRequest">
+ <wsdl:part element="tns:getPersonGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getPersonGreetingsResponse">
+ <wsdl:part element="tns:getPersonGreetingsResponse" 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:operation name="getPersonGreetings">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ <wsdl:output message="tns:getPersonGreetingsResponse" name="getPersonGreetingsResponse"/>
+ </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:operation name="getPersonGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getPersonGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getPersonGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <!-- wsdl:binding name="HelloWorldSoapJmsBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/jms"/>
+ <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:8085/HelloWorldService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java
new file mode 100644
index 0000000000..5c4d3cba9e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld.HelloWorldService;
+import org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld.Person;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class FormatJMSTextXMLInJMSObjectOutTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ @Ignore("TUSCANY-3654")
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldService helloWorldService = node.getService(HelloWorldService.class, "HelloWorldReferenceComponent");
+
+ assertEquals("Hello Fred Bloggs", helloWorldService.getGreetings("Fred Bloggs"));
+
+ Person person = new Person();
+ person.setFirstName("Fred");
+ person.setLastName("Bloggs");
+ assertEquals("Hello Fred Bloggs", helloWorldService.getPersonGreetings(person));
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/pom.xml b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/pom.xml
new file mode 100644
index 0000000000..84331d04cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-non-sca-client-broker</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with Non SCA Client</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java
new file mode 100644
index 0000000000..9083ba1d9c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface OneWayObjectService {
+
+ @OneWay
+ void sayHello(Object name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java
new file mode 100644
index 0000000000..3149f99a25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+public class OneWayObjectServiceImpl implements OneWayObjectService {
+
+ public static Object mutex = new Object();
+ public static Object name;
+
+ public void sayHello(Object name) {
+ OneWayObjectServiceImpl.name = name;
+ synchronized (OneWayObjectServiceImpl.mutex) {
+ OneWayObjectServiceImpl.mutex.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
new file mode 100644
index 0000000000..9cec2d9b3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface OneWayService {
+
+ @OneWay
+ void sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
new file mode 100644
index 0000000000..0036391696
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+public class OneWayServiceImpl implements OneWayService {
+
+ public static Object mutex = new Object();
+ public static String name;
+
+ public void sayHello(String name) {
+ OneWayServiceImpl.name = name;
+ synchronized (OneWayServiceImpl.mutex) {
+ OneWayServiceImpl.mutex.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..decff8708f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ServiceComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..03690b1169
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.TextDest = TextDest
+queue.ObjectDest = ObjectDest
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite
new file mode 100644
index 0000000000..67d5038a51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite
@@ -0,0 +1,54 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="ServiceComposite">
+
+ <component name="DefaultService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61623">
+ <tuscany:wireFormat.jmsTextXML/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="TextService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61623"
+ uri="jms:jndi:TextDest">
+ <tuscany:wireFormat.jmsText/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="ObjectService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayObjectServiceImpl"/>
+ <service name="OneWayObjectService">
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61623"
+ uri="jms:jndi:ObjectDest">
+ <tuscany:wireFormat.jmsObject /> <!-- test that wrapSingle default works -->
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java
new file mode 100644
index 0000000000..54cfdeb273
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/non-sca-client/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryImpl;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class NonSCAClientTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() throws Exception {
+ startBroker();
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @After
+ public void end() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ stopBroker();
+ }
+
+
+ @Test
+ public void testXMLText() throws Exception {
+
+ synchronized (OneWayServiceImpl.mutex) {
+
+ sendTextMessage("dynamicQueues/OneWayService", "<ns2:sayHello xmlns:ns2=\"http://jms.binding.sca.tuscany.apache.org/\"><arg0>Petra</arg0></ns2:sayHello>");
+
+ // wait up to 10 seconds but it will likely be a lot less
+ // as the service invocation will wake this up earlier
+ if (OneWayServiceImpl.name == null) {
+ OneWayServiceImpl.mutex.wait(10000);
+ }
+ }
+ assertEquals("Petra", OneWayServiceImpl.name);
+ }
+
+ @Test
+ public void testText() throws Exception {
+
+ synchronized (OneWayServiceImpl.mutex) {
+
+ sendTextMessage("dynamicQueues/TextDest", "Petra");
+
+ // wait up to 10 seconds but it will likely be a lot less
+ // as the service invocation will wake this up earlier
+ OneWayServiceImpl.mutex.wait(10000);
+ }
+ assertEquals("Petra", OneWayServiceImpl.name);
+ }
+
+ @Test
+ public void testObject() throws Exception {
+
+ Set<Integer> arg = new HashSet<Integer>();
+ arg.add(new Integer(3));
+
+ synchronized (OneWayObjectServiceImpl.mutex) {
+
+ sendObjectMessage("dynamicQueues/ObjectDest", arg);
+
+ // wait up to 10 seconds but it will likely be a lot less
+ // as the service invocation will wake this up earlier
+ OneWayObjectServiceImpl.mutex.wait(10000);
+ }
+ assertEquals(arg, OneWayObjectServiceImpl.name);
+ }
+
+ private static BrokerService broker;
+ protected static void startBroker() throws Exception {
+ broker = new BrokerService();
+ broker.setPersistent(false);
+ broker.setUseJmx(false);
+ broker.addConnector("tcp://localhost:61623");
+ broker.start();
+ }
+
+ protected static void stopBroker() throws Exception {
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+
+ protected static void sendTextMessage(String destName, String payload) throws JMSException, NamingException {
+ JMSResourceFactory rf = new JMSResourceFactoryImpl(null, null, null, "tcp://localhost:61623");
+ Session session = rf.getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer p = session.createProducer(rf.lookupDestination(destName));
+ rf.getConnection().start();
+ session.run();
+ p.send(session.createTextMessage(payload));
+ rf.closeConnection();
+ }
+
+ protected static void sendObjectMessage(String destName, Object payload) throws JMSException, NamingException {
+ JMSResourceFactory rf = new JMSResourceFactoryImpl(null, null, null, "tcp://localhost:61623");
+ Session session = rf.getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer p = session.createProducer(rf.lookupDestination(destName));
+ rf.getConnection().start();
+ session.run();
+ p.send(session.createObjectMessage((Serializable)payload));
+ rf.closeConnection();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/noreplyto/pom.xml b/sandbox/sebastien/java/embed/itest/jms/noreplyto/pom.xml
new file mode 100644
index 0000000000..79cbc59ed5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/noreplyto/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-noreplyto</artifactId>
+ <name>Apache Tuscany SCA iTest JMS No replyTo</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.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.jms;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ if ("bang".equals(name)) {
+ throw new RuntimeException("blem wit");
+ }
+ return "jmsHello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..16825fe48f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/service.composite b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/service.composite
new file mode 100644
index 0000000000..a712990a9b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/main/resources/service.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="SimpleServiceComposite">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:wireFormat.jmsObject/>
+ <destination jndiName="RequestQueue"/>
+ <response>
+ <destination jndiName="ResponseQueue"/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java
new file mode 100644
index 0000000000..848e340181
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Uses a non-Tuscany JMS client to send/receive a JMS request to a Tuscany/SCA JMS service
+ */
+public class NoReplyToTestCase {
+
+ private Node node;
+ private Session session;
+ private InitialContext context;
+ private Connection connection;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ sendJMSRequest();
+ String response = receiveJMSResponse();
+ assertEquals("jmsHello Petra", response);
+ }
+
+ private void sendJMSRequest() throws NamingException, JMSException {
+ context = new InitialContext(new Properties());
+ ConnectionFactory cf = (ConnectionFactory)context.lookup("ConnectionFactory");
+ connection = cf.createConnection();
+ connection.start();
+
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Destination toDest = (Destination)context.lookup("RequestQueue");
+
+ ObjectMessage m = session.createObjectMessage();
+ m.setObject("Petra");
+
+ MessageProducer producer = session.createProducer(toDest);
+ producer.send(m);
+ }
+
+ private String receiveJMSResponse() throws NamingException, JMSException {
+ Destination replyDest = (Destination)context.lookup("ResponseQueue");
+ MessageConsumer consumer = session.createConsumer(replyDest);
+ Message m = consumer.receive(5000);
+ if (m == null) {
+ throw new RuntimeException("No reply message received");
+ }
+ return ((ObjectMessage)m).getObject().toString();
+ }
+
+ @After
+ public void end() throws JMSException {
+ if (node != null) {
+ node.stop();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/nulls/pom.xml b/sandbox/sebastien/java/embed/itest/jms/nulls/pom.xml
new file mode 100644
index 0000000000..cdf628fe76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/nulls/pom.xml
@@ -0,0 +1,71 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-nulls</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Nulls</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java
new file mode 100644
index 0000000000..7fed36fa77
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the OneWay service.
+ */
+@Service(MyService.class)
+public class ClientImpl implements MyService {
+
+ private MyService serviceA;
+
+ @Reference
+ public void setServiceA(MyService service) {
+ this.serviceA = service;
+ }
+
+ public void sayHello() {
+ serviceA.sayHello();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java
new file mode 100644
index 0000000000..7ab6019fd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.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 org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface MyService {
+
+ void sayHello();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java
new file mode 100644
index 0000000000..89758becff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.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 org.apache.tuscany.sca.binding.jms;
+
+
+public class ServiceImpl implements MyService {
+
+ public void sayHello() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ccb52c8702
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:Nulls"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4bada514fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false&broker.useShutdownHook=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory, ConnectionFactory2
+
+# register some queues in JNDI using the form
+queue.MyService = MyService
+queue.MyService2 = MyService2
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+topic.ServiceTopic = ServiceTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/nulls.composite b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/nulls.composite
new file mode 100644
index 0000000000..1aa17808bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/nulls/src/main/resources/nulls.composite
@@ -0,0 +1,57 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="Nulls">
+
+ <component name="Client1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms uri="jms:jndi:MyService" />
+ </reference>
+ </component>
+
+ <component name="Service1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ServiceImpl"/>
+ <service name="MyService">
+ <binding.jms />
+ </service>
+ </component>
+
+ <component name="Client2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms uri="jms:jndi:MyService2">
+ <tuscany:wireFormat.jmsObject/>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="Service2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ServiceImpl"/>
+ <service name="MyService">
+ <binding.jms uri="jms:jndi:MyService2">
+ <tuscany:wireFormat.jmsObject/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java b/sandbox/sebastien/java/embed/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java
new file mode 100644
index 0000000000..ac872f46a6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.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.binding.jms;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ */
+public class NullsTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testSayHello() throws Exception {
+ MyService client1 = node.getService(MyService.class, "Client1");
+
+ client1.sayHello();
+
+ }
+
+ @Test
+ public void testSayHelloObjectFormat() throws Exception {
+ MyService client1 = node.getService(MyService.class, "Client2");
+
+ client1.sayHello();
+
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/pom.xml b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/pom.xml
new file mode 100644
index 0000000000..97365205e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-jms-oneway-nocf</artifactId>
+ <name>Apache Tuscany SCA iTest JMS for a oneway service</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java
new file mode 100644
index 0000000000..b572b1012a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the OneWay service.
+ */
+@Service(OneWayService.class)
+public class OneWayClientImpl implements OneWayService {
+
+ private OneWayService serviceA;
+
+ @Reference
+ public void setServiceA(OneWayService service) {
+ this.serviceA = service;
+ }
+
+ public void sayHello(String name) {
+ serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
new file mode 100644
index 0000000000..9cec2d9b3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface OneWayService {
+
+ @OneWay
+ void sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
new file mode 100644
index 0000000000..0036391696
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+public class OneWayServiceImpl implements OneWayService {
+
+ public static Object mutex = new Object();
+ public static String name;
+
+ public void sayHello(String name) {
+ OneWayServiceImpl.name = name;
+ synchronized (OneWayServiceImpl.mutex) {
+ OneWayServiceImpl.mutex.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..edd6d508f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:OneWayServiceComposite"/>
+ <deployable composite="itest:OneWayClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..8934614a8a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = SomeConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.SomeQueue = RequestQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite
new file mode 100644
index 0000000000..bf709776df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="OneWayClientComposite">
+
+ <component name="OneWayClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayClientImpl"/>
+ <reference name="serviceA">
+ <interface.java interface="org.apache.tuscany.sca.binding.jms.OneWayService" />
+ <binding.jms>
+ <destination jndiName="SomeQueue"/>
+ <connectionFactory jndiName="SomeConnectionFactory"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite
new file mode 100644
index 0000000000..da2e6a2264
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="OneWayServiceComposite">
+
+ <component name="OneWayService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <binding.jms>
+ <destination jndiName="SomeQueue"/>
+ <connectionFactory jndiName="SomeConnectionFactory"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java
new file mode 100644
index 0000000000..5d1f764382
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class OneWayTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testOneWayInvoked() throws Exception {
+ OneWayService oneWayService = node.getService(OneWayService.class, "OneWayClient");
+ oneWayService.sayHello("Petra");
+ synchronized (OneWayServiceImpl.mutex) {
+ // wait up to 10 seconds but it will likely be a lot less
+ // as the service invocation will wake this up earlier
+ OneWayServiceImpl.mutex.wait(10000);
+ }
+ assertEquals("Petra", OneWayServiceImpl.name);
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/pom.xml b/sandbox/sebastien/java/embed/itest/jms/oneway/pom.xml
new file mode 100644
index 0000000000..f201e5e0d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-oneway</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with Oneway</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java
new file mode 100644
index 0000000000..b572b1012a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the OneWay service.
+ */
+@Service(OneWayService.class)
+public class OneWayClientImpl implements OneWayService {
+
+ private OneWayService serviceA;
+
+ @Reference
+ public void setServiceA(OneWayService service) {
+ this.serviceA = service;
+ }
+
+ public void sayHello(String name) {
+ serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java
new file mode 100644
index 0000000000..9083ba1d9c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface OneWayObjectService {
+
+ @OneWay
+ void sayHello(Object name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java
new file mode 100644
index 0000000000..3149f99a25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+public class OneWayObjectServiceImpl implements OneWayObjectService {
+
+ public static Object mutex = new Object();
+ public static Object name;
+
+ public void sayHello(Object name) {
+ OneWayObjectServiceImpl.name = name;
+ synchronized (OneWayObjectServiceImpl.mutex) {
+ OneWayObjectServiceImpl.mutex.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
new file mode 100644
index 0000000000..9cec2d9b3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface OneWayService {
+
+ @OneWay
+ void sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
new file mode 100644
index 0000000000..0036391696
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+public class OneWayServiceImpl implements OneWayService {
+
+ public static Object mutex = new Object();
+ public static String name;
+
+ public void sayHello(String name) {
+ OneWayServiceImpl.name = name;
+ synchronized (OneWayServiceImpl.mutex) {
+ OneWayServiceImpl.mutex.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..edd6d508f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:OneWayServiceComposite"/>
+ <deployable composite="itest:OneWayClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite
new file mode 100644
index 0000000000..8bccf22bea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="OneWayClientComposite">
+
+ <component name="OneWayClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms>
+ <destination jndiName="DestQueueA"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite
new file mode 100644
index 0000000000..0014b88050
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="OneWayServiceComposite">
+
+ <component name="OneWayService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <binding.jms>
+ <destination jndiName="DestQueueA" create="always"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java b/sandbox/sebastien/java/embed/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java
new file mode 100644
index 0000000000..14bbf238e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.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.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class OneWayTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testOneWayInvoked() throws Exception {
+ OneWayService oneWayService = node.getService(OneWayService.class, "OneWayClient");
+ oneWayService.sayHello("Petra");
+ synchronized (OneWayServiceImpl.mutex) {
+ // wait up to 10 seconds but it will likely be a lot less
+ // as the service invocation will wake this up earlier
+ OneWayServiceImpl.mutex.wait(10000);
+ }
+ assertEquals("Petra", OneWayServiceImpl.name);
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/pom.xml b/sandbox/sebastien/java/embed/itest/jms/policy-headers/pom.xml
new file mode 100644
index 0000000000..42596b8d0e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-policy-headers</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with Policy Headers</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
new file mode 100644
index 0000000000..d4cd5df431
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.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 org.apache.tuscany.sca.binding.jms;
+
+
+/**
+ * The client interface
+ */
+public interface JMSClient {
+
+ void aClientMethod();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
new file mode 100644
index 0000000000..464072b42d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+
+/**
+ * The client interface
+ */
+public interface MsgClient {
+
+ void aClientMethod();
+ void op2();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java
new file mode 100644
index 0000000000..4140fa0b89
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.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 org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(MsgClient.class)
+public class MsgClientImpl implements MsgClient {
+
+ @Reference protected MsgClientService myService;
+
+ public void aClientMethod() {
+ myService.aClientMethod();
+ }
+
+ public void op2() {
+ myService.op2();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
new file mode 100644
index 0000000000..2be4f2ad3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The client interface
+ */
+@Remotable
+public interface MsgClientService {
+
+ void aClientMethod();
+
+ void op2();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java
new file mode 100644
index 0000000000..d5684ca56c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.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.binding.jms;
+
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+@AllowsPassByReference
+public interface MsgService {
+
+ void onMessage(javax.jms.Message msg);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java
new file mode 100644
index 0000000000..e18de0456c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.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.sca.binding.jms;
+
+import javax.jms.Message;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service(MsgService.class)
+public class MsgServiceImpl implements MsgService {
+
+ public static Object lock = new Object();
+ public static Message msg;
+
+ public void onMessage(Message msg) {
+ MsgServiceImpl.msg = msg;
+ synchronized(lock) {
+ lock.notifyAll();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/META-INF/definitions.xml b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/META-INF/definitions.xml
new file mode 100644
index 0000000000..7e417723f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/META-INF/definitions.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <policySet name="JMSPolicySet1"
+ provides="priority"
+ appliesTo="sca:binding.jms">
+ <intentMap provides="priority">
+ <qualifier name="high">
+ <tuscany:jmsHeader JMSPriority="9"/>
+ </qualifier>
+ <qualifier name="medium">
+ <tuscany:jmsHeader JMSPriority="4"/>
+ </qualifier>
+ <qualifier name="low">
+ <tuscany:jmsHeader JMSPriority="0"/>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="JMSPolicySet2"
+ provides="deliveryMode"
+ appliesTo="sca:binding.jms">
+ <intentMap provides="deliveryMode">
+ <qualifier name="persistent">
+ <tuscany:jmsHeader JMSDeliveryMode="PERSISTENT"/>
+ </qualifier>
+ <qualifier name="nonPersistent">
+ <tuscany:jmsHeader JMSDeliveryMode="NON_PERSISTENT"/>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <intent name="priority" constrains="sca:binding" intentType="interaction">
+ <qualifier name="high" default="true"/>
+ <qualifier name="medium"/>
+ <qualifier name="low"/>
+ </intent>
+
+ <intent name="deliveryMode" constrains="sca:binding" intentType="interaction">
+ <qualifier name="nonPersistent" default="true"/>
+ <qualifier name="persistent"/>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..12c7313bb4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:PropertiesClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..f0b9fbd734
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.ServiceQueue = ServiceQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite
new file mode 100644
index 0000000000..68f93669ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="PropertiesClientComposite">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.MsgClientImpl" />
+ <reference name="myService" requires="priority.medium">
+ <binding.jms uri="jms:jndi:ServiceQueue">
+ <headers type="myType"
+ deliveryMode="persistent"
+ timeToLive="4321"
+ priority="7">
+ <property name="headP1">myHeadP1</property>
+ </headers>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="ServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.MsgServiceImpl" />
+ <service name="MsgService">
+ <binding.jms uri="jms:jndi:ServiceQueue"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
new file mode 100644
index 0000000000..ebffbc4bc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/policy-headers/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import javax.jms.DeliveryMode;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ */
+public class PolicyHeadersTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testProps1() throws Exception {
+ JMSClient client = node.getService(JMSClient.class, "ClientComponent");
+
+ client.aClientMethod();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(MsgServiceImpl.lock) {
+ if (MsgServiceImpl.msg == null) {
+ MsgServiceImpl.lock.wait(5000); // For debugging set higher.
+ }
+ }
+ assertNotNull(MsgServiceImpl.msg);
+
+ assertEquals("myType", MsgServiceImpl.msg.getJMSType());
+ assertEquals(DeliveryMode.PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode());
+ assertEquals(7, MsgServiceImpl.msg.getJMSPriority());
+ assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
+ }
+
+ @Test
+ @Ignore
+ public void testOp2() throws Exception {
+ MsgClient client = node.getService(MsgClient.class, "ClientComponent");
+
+ client.op2();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(MsgServiceImpl.lock) {
+ if (MsgServiceImpl.msg == null) {
+ MsgServiceImpl.lock.wait(5000);
+ }
+ }
+ assertNotNull(MsgServiceImpl.msg);
+
+ assertEquals("op2Type", MsgServiceImpl.msg.getJMSType());
+ assertEquals(DeliveryMode.NON_PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode());
+ assertEquals(3, MsgServiceImpl.msg.getJMSPriority());
+ assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
+ assertEquals("foo", MsgServiceImpl.msg.getStringProperty("op2P2"));
+ assertEquals("nativeOp2", MsgServiceImpl.msg.getStringProperty("scaOperationName"));
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/pom.xml b/sandbox/sebastien/java/embed/itest/jms/pom.xml
new file mode 100644
index 0000000000..cccfe5c657
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-jms</artifactId>
+ <name>Apache Tuscany SCA iTest JMS</name>
+
+ <modules>
+ <module>args</module>
+ <module>callbacks</module>
+ <module>defaults</module>
+ <module>DynamicReplyQ</module>
+ <module>exceptions</module>
+ <module>exceptions1</module>
+ <module>externalBroker</module>
+ <module>format-jmsbytes</module>
+ <module>format-jmsbytesxml</module>
+ <module>format-jmsdefault</module>
+ <module>format-jmsmessage</module>
+ <module>format-jmsobject</module>
+ <module>format-jmstext</module>
+ <module>format-jmstextxml</module>
+ <module>format-jmstextxmlinjmsobjectout</module>
+ <module>non-sca-client</module>
+ <module>noreplyto</module>
+ <module>nulls</module>
+ <module>oneway</module>
+ <module>oneway-nocf</module>
+ <module>policy-headers</module>
+ <module>properties</module>
+ <module>responsecf</module>
+ <module>rpc</module>
+ <module>selectors</module>
+ <module>topics</module>
+ <module>ttl</module>
+ <module>uri-rpc</module>
+
+<!-- still to bring up in 2.x
+ <module>definitions</module>
+-->
+
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/pom.xml b/sandbox/sebastien/java/embed/itest/jms/properties/pom.xml
new file mode 100644
index 0000000000..72d1041f44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-properties</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with Properties</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
new file mode 100644
index 0000000000..d4cd5df431
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.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 org.apache.tuscany.sca.binding.jms;
+
+
+/**
+ * The client interface
+ */
+public interface JMSClient {
+
+ void aClientMethod();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
new file mode 100644
index 0000000000..464072b42d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+
+/**
+ * The client interface
+ */
+public interface MsgClient {
+
+ void aClientMethod();
+ void op2();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java
new file mode 100644
index 0000000000..4140fa0b89
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.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 org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(MsgClient.class)
+public class MsgClientImpl implements MsgClient {
+
+ @Reference protected MsgClientService myService;
+
+ public void aClientMethod() {
+ myService.aClientMethod();
+ }
+
+ public void op2() {
+ myService.op2();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
new file mode 100644
index 0000000000..2be4f2ad3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The client interface
+ */
+@Remotable
+public interface MsgClientService {
+
+ void aClientMethod();
+
+ void op2();
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java
new file mode 100644
index 0000000000..d5684ca56c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.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.binding.jms;
+
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+@AllowsPassByReference
+public interface MsgService {
+
+ void onMessage(javax.jms.Message msg);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java
new file mode 100644
index 0000000000..e18de0456c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.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.sca.binding.jms;
+
+import javax.jms.Message;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service(MsgService.class)
+public class MsgServiceImpl implements MsgService {
+
+ public static Object lock = new Object();
+ public static Message msg;
+
+ public void onMessage(Message msg) {
+ MsgServiceImpl.msg = msg;
+ synchronized(lock) {
+ lock.notifyAll();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..12c7313bb4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:PropertiesClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..c44da27df1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.ServiceQueue = RequestQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/properties/properties.composite b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/properties/properties.composite
new file mode 100644
index 0000000000..234bfa7fcf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/main/resources/properties/properties.composite
@@ -0,0 +1,53 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="PropertiesClientComposite">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.MsgClientImpl" />
+ <reference name="myService">
+ <binding.jms uri="jms:jndi:ServiceQueue">
+ <headers type="myType"
+ deliveryMode="persistent"
+ timeToLive="4321"
+ priority="7">
+ <property name="headP1">myHeadP1</property>
+ </headers>
+ <operationProperties name="op2" nativeOperation="nativeOp2">
+ <headers type="op2Type"
+ deliveryMode="nonpersistent"
+ timeToLive="6000"
+ priority="8">
+ <property name="op2P2">foo</property>
+ </headers>
+ </operationProperties>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="ServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.MsgServiceImpl" />
+ <service name="MsgService">
+ <binding.jms uri="jms:jndi:ServiceQueue"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java b/sandbox/sebastien/java/embed/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java
new file mode 100644
index 0000000000..e8d748bb19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import javax.jms.DeliveryMode;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ */
+public class PropertiesTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testProps1() throws Exception {
+ JMSClient client = node.getService(JMSClient.class, "ClientComponent");
+
+ client.aClientMethod();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(MsgServiceImpl.lock) {
+ if (MsgServiceImpl.msg == null) {
+ MsgServiceImpl.lock.wait(5000);
+ }
+ }
+ assertNotNull(MsgServiceImpl.msg);
+
+ assertEquals("myType", MsgServiceImpl.msg.getJMSType());
+ assertEquals(DeliveryMode.PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode());
+ // assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work with ActiveMQ
+ assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
+ }
+
+ @Test
+ public void testOp2() throws Exception {
+ MsgClient client = node.getService(MsgClient.class, "ClientComponent");
+
+ client.op2();
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(MsgServiceImpl.lock) {
+ if (MsgServiceImpl.msg == null) {
+ MsgServiceImpl.lock.wait(15000);
+ }
+ }
+ assertNotNull(MsgServiceImpl.msg);
+
+ assertEquals("op2Type", MsgServiceImpl.msg.getJMSType());
+ // assertEquals(DeliveryMode.NON_PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode()); // Doesn't seem to work with ActiveMQ
+ // assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work with ActiveMQ
+ assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
+ assertEquals("foo", MsgServiceImpl.msg.getStringProperty("op2P2"));
+ //operation properties are a service side thing
+ //assertEquals("nativeOp2", MsgServiceImpl.msg.getStringProperty("scaOperationName"));
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/pom.xml b/sandbox/sebastien/java/embed/itest/jms/responsecf/pom.xml
new file mode 100644
index 0000000000..fb7edf2918
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-responsecf</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Response ConnectionFactory</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldClientImpl implements HelloWorldService {
+
+ private HelloWorldService serviceA;
+
+ @Reference
+ public void setServiceA(HelloWorldService service) {
+ this.serviceA = service;
+ }
+
+ public String sayHello(String name) {
+ return serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.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.jms;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ if ("bang".equals(name)) {
+ throw new RuntimeException("blem wit");
+ }
+ return "jmsHello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..23c5979291
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+ <deployable composite="itest:SimpleClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/cf/client.composite b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/cf/client.composite
new file mode 100644
index 0000000000..a3e5403432
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/cf/client.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="SimpleClientComposite">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms>
+ <destination jndiName="DestQueueA"/>
+ <response>
+ <destination jndiName="RespQueueA"/>
+ </response>
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/cf/service.composite b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/cf/service.composite
new file mode 100644
index 0000000000..cd04ae7836
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/cf/service.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="SimpleServiceComposite">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
+ <service name="HelloWorldService">
+ <binding.jms>
+ <destination jndiName="DestQueueA"/>
+ <response>
+ <connectionFactory jndiName="ResponseCF"/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..a41e42950e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory, ResponseCF
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.DestQueueA = RequestQueue
+queue.RespQueueA = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java
new file mode 100644
index 0000000000..03b834ce7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a response ConnectionFactory
+ */
+public class ResponseCFTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldService helloWorldService = node.getService(HelloWorldService.class, "HelloWorldClient");
+ assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra"));
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/pom.xml b/sandbox/sebastien/java/embed/itest/jms/rpc/pom.xml
new file mode 100644
index 0000000000..b436479c3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-rpc</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with RPC</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldClientImpl implements HelloWorldService {
+
+ private HelloWorldService serviceA;
+
+ @Reference
+ public void setServiceA(HelloWorldService service) {
+ this.serviceA = service;
+ }
+
+ public String sayHello(String name) {
+ return serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.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.jms;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ if ("bang".equals(name)) {
+ throw new RuntimeException("blem wit");
+ }
+ return "jmsHello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..23c5979291
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+ <deployable composite="itest:SimpleClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.RequestQueue = RequestQueue
+queue.ResponseQueue = ResponseQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/simple/client.composite b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/simple/client.composite
new file mode 100644
index 0000000000..a758389e89
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/simple/client.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="SimpleClientComposite">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms>
+ <destination jndiName="DestQueueA">
+ </destination>
+ <response>
+ <destination jndiName="RespQueueA"/>
+ </response>
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/simple/service.composite b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/simple/service.composite
new file mode 100644
index 0000000000..33364f61c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/src/main/resources/simple/service.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="SimpleServiceComposite">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
+ <service name="HelloWorldService">
+ <binding.jms>
+ <destination jndiName="DestQueueA" create="always">
+ </destination>
+ <response>
+ <destination jndiName="RespQueueA" create="always"/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java b/sandbox/sebastien/java/embed/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java
new file mode 100644
index 0000000000..3c0eb0791b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class RPCTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldService helloWorldService = node.getService(HelloWorldService.class, "HelloWorldClient");
+ assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra"));
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/pom.xml b/sandbox/sebastien/java/embed/itest/jms/selectors/pom.xml
new file mode 100644
index 0000000000..c3dd5edee8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-selectors</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Tests For Selectors</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java
new file mode 100644
index 0000000000..b589d5e8bc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the OneWay service.
+ */
+@Service(SelectorService.class)
+public class ClientImpl implements SelectorService {
+
+ private SelectorService serviceA;
+
+ @Reference
+ public void setServiceA(SelectorService service) {
+ this.serviceA = service;
+ }
+
+ public void sayHello(String name) {
+ serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java
new file mode 100644
index 0000000000..1aff0d454e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface SelectorService {
+
+ @OneWay
+ void sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java
new file mode 100644
index 0000000000..fb53c877e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SelectorServiceImpl1 implements SelectorService {
+
+ public static Object lock = new Object();
+ public static List<String> names = new ArrayList<String>();
+
+ public void sayHello(String name) {
+ System.out.println("SelectorServiceImpl1 " + name);
+ SelectorServiceImpl1.names.add(name);
+ if (names.size() == 2) {
+ synchronized (SelectorServiceImpl1.lock) {
+ SelectorServiceImpl1.lock.notify();
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java
new file mode 100644
index 0000000000..1bbaf5d6f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.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 org.apache.tuscany.sca.binding.jms;
+
+public class SelectorServiceImpl2 implements SelectorService {
+
+ public static Object lock = new Object();
+ public static String name;
+
+ public void sayHello(String name) {
+ if (SelectorServiceImpl2.name != null) {
+ throw new IllegalStateException("name already set");
+ }
+ System.out.println("SelectorServiceImpl2 " + name);
+ SelectorServiceImpl2.name = name;
+ synchronized (SelectorServiceImpl2.lock) {
+ SelectorServiceImpl2.lock.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java
new file mode 100644
index 0000000000..4bdc4edcb5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.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 org.apache.tuscany.sca.binding.jms;
+
+public class SelectorServiceImpl3 implements SelectorService {
+
+ public static Object lock = new Object();
+ public static String name;
+
+ public void sayHello(String name) {
+ if (SelectorServiceImpl3.name != null) {
+ throw new IllegalStateException("name already set");
+ }
+ System.out.println("SelectorServiceImpl3 " + name);
+ SelectorServiceImpl3.name = name;
+ synchronized (SelectorServiceImpl3.lock) {
+ SelectorServiceImpl3.lock.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java
new file mode 100644
index 0000000000..0592194b21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.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.binding.jms.operationselector.jmsdefault;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String name);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..2d4ff0192b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.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.sca.binding.jms.operationselector.jmsdefault;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+ @Reference
+ protected HelloWorldService helloWorldService2;
+
+ public String getGreetings(String name){
+ return helloWorldService1.getGreetingsOne(name) + " " +
+ helloWorldService1.getGreetingsTwo(name) + " " +
+ helloWorldService2.getGreetingsOne(name) + " " +
+ helloWorldService1.getGreetingsThree(name);
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java
new file mode 100644
index 0000000000..b632b3f60f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetingsOne(String name);
+
+ public String getGreetingsTwo(String name);
+
+ public String getGreetingsThree(String name);
+
+ public String getGreetingsFour(String name);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b2df9137c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.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.sca.binding.jms.operationselector.jmsdefault;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String getGreetingsOne(String name){
+ String response = "Hello One " + name;
+ System.out.println("getGreetingsOne: " + response);
+ return response;
+ }
+
+ public String getGreetingsTwo(String name){
+ String response = "Hello Two " + name;
+ System.out.println("getGreetingsTwo: " + response);
+ return response;
+ }
+
+ public String getGreetingsThree(String name){
+ String response = "Hello Three " + name;
+ System.out.println("getGreetingsThree: " + response);
+ return response;
+ }
+
+ public String getGreetingsFour(String name){
+ String response = "Hello Four " + name;
+ System.out.println("getGreetingsFour: " + response);
+ return response;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java
new file mode 100644
index 0000000000..0b24678543
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.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.binding.jms.operationselector.jmsuserprop;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldReference {
+
+ public String getGreetings(String name);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..0ce66005fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.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 org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+public class HelloWorldReferenceImpl implements HelloWorldReference {
+
+ @Reference
+ protected HelloWorldService helloWorldService1;
+
+
+ public String getGreetings(String name){
+ return helloWorldService1.getGreetingsOne(name) + " " +
+ helloWorldService1.getGreetingsTwo(name) + " " +
+ helloWorldService1.getGreetingsThree(name);
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java
new file mode 100644
index 0000000000..7e42113da4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.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 org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetingsOne(String name);
+
+ public String getGreetingsTwo(String name);
+
+ public String getGreetingsThree(String name);
+
+ public String getGreetingsFour(String name);
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..724de6ff7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.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.sca.binding.jms.operationselector.jmsuserprop;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String getGreetingsOne(String name){
+ String response = "Hello One " + name;
+ System.out.println("getGreetingsOne: " + response);
+ return response;
+ }
+
+ public String getGreetingsTwo(String name){
+ String response = "Hello Two " + name;
+ System.out.println("getGreetingsTwo: " + response);
+ return response;
+ }
+
+ public String getGreetingsThree(String name){
+ String response = "Hello Three " + name;
+ System.out.println("getGreetingsThree: " + response);
+ return response;
+ }
+
+ public String getGreetingsFour(String name){
+ String response = "Hello Four " + name;
+ System.out.println("getGreetingsFour: " + response);
+ return response;
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3527e98032
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,25 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld"/>
+ <deployable composite="itest:helloworldUP"/>
+ <deployable composite="itest:Selectors"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite
new file mode 100644
index 0000000000..41ee0e10d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite
@@ -0,0 +1,69 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hw="http://helloworld"
+ name="helloworld">
+
+ <component name="HelloWorldReferenceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService1"/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService2" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService2"/>
+ <operationProperties name="getGreetingsOne" >
+ <headers>
+ <property name="scaOperationName">getGreetingsThree</property>
+ </headers>
+ </operationProperties>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <destination jndiName="HelloWorldService1"/>
+ <operationProperties name="getGreetingsThree" nativeOperation="getGreetingsFour">
+ <headers>
+ <property name="blaNotUsed">getGreetingsThree</property>
+ </headers>
+ </operationProperties>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="HelloWorldServiceComponent2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <operationSelector.jmsDefault/>
+ <destination jndiName="HelloWorldService2"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite
new file mode 100644
index 0000000000..6b86764820
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite
@@ -0,0 +1,65 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hw="http://helloworld"
+ name="helloworldUP">
+
+ <component name="HelloWorldReferenceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop.HelloWorldReferenceImpl" />
+ <reference name="helloWorldService1" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService4"/>
+ <operationProperties name="getGreetingsOne" >
+ <headers>
+ <property name="myProperty">getGreetingsOne</property>
+ </headers>
+ </operationProperties>
+ <operationProperties name="getGreetingsTwo" >
+ <headers>
+ <property name="myProperty">getGreetingsThree</property>
+ </headers>
+ </operationProperties>
+ <operationProperties name="getGreetingsThree" >
+ <headers>
+ <property name="myProperty">getGreetingsTwo</property>
+ </headers>
+ </operationProperties>
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent3">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms>
+ <tuscany:operationSelector.jmsUserProp propertyName="myProperty"/>
+ <destination jndiName="HelloWorldService4"/>
+ <operationProperties name="getGreetingsThree" nativeOperation="getGreetingsFour">
+ <headers>
+ <property name="blaNotUsed2">getGreetingsThree</property>
+ </headers>
+ </operationProperties>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..7ce468aa0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false&broker.useShutdownHook=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory, ConnectionFactory2
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+topic.ServiceTopic = ServiceTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/selectors/selectors.composite b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/selectors/selectors.composite
new file mode 100644
index 0000000000..1a408dfb9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/main/resources/selectors/selectors.composite
@@ -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.
+ -->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:itest="http://jms"
+ name="Selectors">
+
+ <component name="Client1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms uri="jms:jndi:ServiceTopic" >
+ <headers type="type1" />
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="Client2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms uri="jms:jndi:ServiceTopic" >
+ <headers type="type2" />
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="Service1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.SelectorServiceImpl1"/>
+ <service name="SelectorService">
+ <binding.jms uri="jms:jndi:ServiceTopic" />
+ </service>
+ </component>
+
+ <component name="Service2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.SelectorServiceImpl2"/>
+ <service name="SelectorService">
+ <binding.jms uri="jms:jndi:ServiceTopic" >
+ <messageSelection selector="JMSType = 'type1'"/>
+ </binding.jms>
+ </service>
+ </component>
+
+ <component name="Service3">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.SelectorServiceImpl3"/>
+ <service name="SelectorService">
+ <binding.jms uri="jms:jndi:ServiceTopic" >
+ <messageSelection selector="JMSType = 'type2'"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java
new file mode 100644
index 0000000000..bee0c549bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.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.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.HelloWorldReference;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class OperationselectorJMSDefaultTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldReference = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent");
+
+ assertEquals("Hello One Fred Bloggs Hello Two Fred Bloggs Hello Three Fred Bloggs Hello Four Fred Bloggs", helloWorldReference.getGreetings("Fred Bloggs"));
+
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java
new file mode 100644
index 0000000000..33e047ae18
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.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.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.HelloWorldReference;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class OperationselectorJMSUserPropTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldReference helloWorldReference = node.getService(HelloWorldReference.class, "HelloWorldReferenceComponent1");
+
+ assertEquals("Hello One Fred Bloggs Hello Four Fred Bloggs Hello Two Fred Bloggs", helloWorldReference.getGreetings("Fred Bloggs"));
+
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java b/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java
new file mode 100644
index 0000000000..e7254005be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ */
+public class SelectorsTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testSayHello() throws Exception {
+ SelectorService client1 = node.getService(SelectorService.class, "Client1");
+ SelectorService client2 = node.getService(SelectorService.class, "Client2");
+
+ client1.sayHello("petra");
+ client2.sayHello("beate");
+
+ // wait for up to 5 seconds but should wake up as soon as done
+ synchronized(SelectorServiceImpl2.lock) {
+ if (SelectorServiceImpl2.name == null) {
+ SelectorServiceImpl2.lock.wait(5000);
+ }
+ }
+ synchronized(SelectorServiceImpl3.lock) {
+ if (SelectorServiceImpl3.name == null) {
+ SelectorServiceImpl3.lock.wait(5000);
+ }
+ }
+ synchronized(SelectorServiceImpl1.lock) {
+ if (SelectorServiceImpl1.names.size() != 2) {
+ SelectorServiceImpl1.lock.wait(5000);
+ }
+ }
+
+ assertEquals("petra", SelectorServiceImpl2.name);
+ assertEquals("beate", SelectorServiceImpl3.name);
+ assertEquals(2, SelectorServiceImpl1.names.size());
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/pom.xml b/sandbox/sebastien/java/embed/itest/jms/topics/pom.xml
new file mode 100644
index 0000000000..0be4f6e4b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/pom.xml
@@ -0,0 +1,71 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-topics</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Tests for topics</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java
new file mode 100644
index 0000000000..b572b1012a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the OneWay service.
+ */
+@Service(OneWayService.class)
+public class OneWayClientImpl implements OneWayService {
+
+ private OneWayService serviceA;
+
+ @Reference
+ public void setServiceA(OneWayService service) {
+ this.serviceA = service;
+ }
+
+ public void sayHello(String name) {
+ serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
new file mode 100644
index 0000000000..9cec2d9b3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface OneWayService {
+
+ @OneWay
+ void sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
new file mode 100644
index 0000000000..0036391696
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+public class OneWayServiceImpl implements OneWayService {
+
+ public static Object mutex = new Object();
+ public static String name;
+
+ public void sayHello(String name) {
+ OneWayServiceImpl.name = name;
+ synchronized (OneWayServiceImpl.mutex) {
+ OneWayServiceImpl.mutex.notify();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c1156b35e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:TopicsClientComposite"/>
+ <deployable composite="itest:OneWayServiceComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..d7988ee60d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false&broker.useShutdownHook=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/topics/TopicsClient.composite b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/topics/TopicsClient.composite
new file mode 100644
index 0000000000..d4027ff60d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/topics/TopicsClient.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="TopicsClientComposite">
+
+ <component name="OneWayClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms>
+ <destination jndiName="MyTopic" type="topic" create="never"/>
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/topics/TopicsService.composite b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/topics/TopicsService.composite
new file mode 100644
index 0000000000..8726543253
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/src/main/resources/topics/TopicsService.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="OneWayServiceComposite">
+
+ <component name="OneWayService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <binding.jms>
+ <destination jndiName="MyTopic" type="topic" create="never"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java b/sandbox/sebastien/java/embed/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java
new file mode 100644
index 0000000000..35fe96b81a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class TopicsTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testOneWayInvoked() throws Exception {
+ OneWayService oneWayService = node.getService(OneWayService.class, "OneWayClient");
+ oneWayService.sayHello("Petra");
+ synchronized (OneWayServiceImpl.mutex) {
+ // wait up to 10 seconds but it will likely be a lot less
+ // as the service invocation will wake this up earlier
+ OneWayServiceImpl.mutex.wait(10000);
+ }
+ assertEquals("Petra", OneWayServiceImpl.name);
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/ttl/pom.xml b/sandbox/sebastien/java/embed/itest/jms/ttl/pom.xml
new file mode 100644
index 0000000000..c7462bc039
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/ttl/pom.xml
@@ -0,0 +1,71 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-ttl</artifactId>
+ <name>Apache Tuscany SCA iTest JMS Time To Live</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java
new file mode 100644
index 0000000000..336fecf67b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java
@@ -0,0 +1,904 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionConsumer;
+import javax.jms.ConnectionFactory;
+import javax.jms.ConnectionMetaData;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.ServerSessionPool;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.TopicSubscriber;
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+/**
+ * Some classes that mock up various JMS interfaces with the end result
+ * of having the Time-To-Live value set on the static timeToLive
+ *
+ * This class is referenced from the AMQ jndi.properties file
+ */
+public class MockInitialContextFactory extends org.apache.activemq.jndi.ActiveMQInitialContextFactory{
+
+ public static Object lock = new Object();
+ public static Long timeToLive;
+
+ public Context getInitialContext(Hashtable environment) throws NamingException {
+ return new Context() {
+
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void bind(Name name, Object obj) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void bind(String name, Object obj) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void close() throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String composeName(String name, String prefix) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Context createSubcontext(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Context createSubcontext(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void destroySubcontext(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void destroySubcontext(String name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Hashtable<?, ?> getEnvironment() throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getNameInNamespace() throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NameParser getNameParser(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookup(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookup(String name) throws NamingException {
+ if (name.endsWith("ConnectionFactory")) {
+ return new ConnectionFactory() {
+ public Connection createConnection() throws JMSException {
+ return new Connection(){
+
+ public void close() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ConnectionConsumer createConnectionConsumer(Destination arg0,
+ String arg1,
+ ServerSessionPool arg2,
+ int arg3) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ConnectionConsumer createDurableConnectionConsumer(Topic arg0,
+ String arg1,
+ String arg2,
+ ServerSessionPool arg3,
+ int arg4) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Session createSession(boolean arg0, int arg1) throws JMSException {
+ // TODO Auto-generated method stub
+ return new Session() {
+
+ public void close() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void commit() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public QueueBrowser createBrowser(Queue arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public QueueBrowser createBrowser(Queue arg0, String arg1) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public BytesMessage createBytesMessage() throws JMSException {
+ // TODO Auto-generated method stub
+ return new BytesMessage() {
+
+ public long getBodyLength() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public boolean readBoolean() throws JMSException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public byte readByte() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int readBytes(byte[] arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int readBytes(byte[] arg0, int arg1) throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public char readChar() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public double readDouble() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public float readFloat() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int readInt() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long readLong() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public short readShort() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String readUTF() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int readUnsignedByte() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int readUnsignedShort() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void reset() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeBoolean(boolean arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeByte(byte arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeBytes(byte[] arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeBytes(byte[] arg0, int arg1, int arg2)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeChar(char arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeDouble(double arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeFloat(float arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeInt(int arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeLong(long arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeObject(Object arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeShort(short arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeUTF(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acknowledge() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void clearBody() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void clearProperties() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean getBooleanProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public byte getByteProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public double getDoubleProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public float getFloatProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getIntProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getJMSCorrelationID() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getJMSDeliveryMode() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Destination getJMSDestination() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getJMSExpiration() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getJMSMessageID() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getJMSPriority() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public boolean getJMSRedelivered() throws JMSException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Destination getJMSReplyTo() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getJMSTimestamp() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getJMSType() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getLongProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Object getObjectProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Enumeration getPropertyNames() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public short getShortProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getStringProperty(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean propertyExists(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setBooleanProperty(String arg0, boolean arg1)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setByteProperty(String arg0, byte arg1) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDoubleProperty(String arg0, double arg1)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setFloatProperty(String arg0, float arg1)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setIntProperty(String arg0, int arg1) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSCorrelationID(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSCorrelationIDAsBytes(byte[] arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSDeliveryMode(int arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSDestination(Destination arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSExpiration(long arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSMessageID(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSPriority(int arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSRedelivered(boolean arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSReplyTo(Destination arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSTimestamp(long arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setJMSType(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLongProperty(String arg0, long arg1) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setObjectProperty(String arg0, Object arg1)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setShortProperty(String arg0, short arg1)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setStringProperty(String arg0, String arg1)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }};
+ }
+
+ public MessageConsumer createConsumer(Destination arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MessageConsumer createConsumer(Destination arg0, String arg1)
+ throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MessageConsumer createConsumer(Destination arg0,
+ String arg1,
+ boolean arg2) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1)
+ throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TopicSubscriber createDurableSubscriber(Topic arg0,
+ String arg1,
+ String arg2,
+ boolean arg3)
+ throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MapMessage createMapMessage() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Message createMessage() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ObjectMessage createObjectMessage() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ObjectMessage createObjectMessage(Serializable arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MessageProducer createProducer(Destination arg0) throws JMSException {
+ return new MessageProducer() {
+
+ public void close() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public int getDeliveryMode() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Destination getDestination() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean getDisableMessageID() throws JMSException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean getDisableMessageTimestamp() throws JMSException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public int getPriority() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long getTimeToLive() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void send(Message arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void send(Destination arg0, Message arg1) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void send(Message arg0, int arg1, int arg2, long arg3)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void send(Destination arg0,
+ Message arg1,
+ int arg2,
+ int arg3,
+ long arg4) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDeliveryMode(int arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDisableMessageID(boolean arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDisableMessageTimestamp(boolean arg0)
+ throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setPriority(int arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setTimeToLive(long arg0) throws JMSException {
+ MockInitialContextFactory.timeToLive = Long.valueOf(arg0);
+ synchronized(MockInitialContextFactory.lock) {
+ MockInitialContextFactory.lock.notifyAll();
+ }
+ }};
+ }
+
+ public Queue createQueue(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public StreamMessage createStreamMessage() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TemporaryQueue createTemporaryQueue() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TemporaryTopic createTemporaryTopic() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TextMessage createTextMessage() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TextMessage createTextMessage(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Topic createTopic(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getAcknowledgeMode() throws JMSException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public MessageListener getMessageListener() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean getTransacted() throws JMSException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void recover() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void rollback() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void run() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMessageListener(MessageListener arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unsubscribe(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }};
+ }
+
+ public String getClientID() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ExceptionListener getExceptionListener() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ConnectionMetaData getMetaData() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setClientID(String arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setExceptionListener(ExceptionListener arg0) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void start() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void stop() throws JMSException {
+ // TODO Auto-generated method stub
+
+ }};
+ }
+ public Connection createConnection(String arg0, String arg1) throws JMSException {
+ return null;
+ }};
+ } else {
+ return new Queue(){
+ public String getQueueName() throws JMSException {
+ return null;
+ }};
+ }
+ }
+
+ public Object lookupLink(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookupLink(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void rebind(String name, Object obj) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object removeFromEnvironment(String propName) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void rename(String oldName, String newName) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unbind(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unbind(String name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }};
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java
new file mode 100644
index 0000000000..dc6577b7e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.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.jms;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface ClientIface {
+
+ @OneWay
+ void sayHello(String s);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java
new file mode 100644
index 0000000000..4f9908f062
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.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.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * This class implements the OneWay service.
+ */
+public class ClientImpl implements ClientIface {
+
+ private ClientIface serviceA;
+
+ @Reference
+ public void setServiceA(ClientIface service) {
+ this.serviceA = service;
+ }
+
+ public void sayHello(String name) {
+ serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ff50ad2daa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:TTLTests"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..7ac9aa559c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = itest.MockInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false&broker.useShutdownHook=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory, ConnectionFactory2
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+topic.ServiceTopic = ServiceTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/ttl.composite b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/ttl.composite
new file mode 100644
index 0000000000..8b06a9fc7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/ttl/src/main/resources/ttl.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="TTLTests">
+
+ <component name="Client1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.ClientImpl"/>
+ <reference name="serviceA">
+ <interface.java interface="org.apache.tuscany.sca.binding.jms.ClientIface" />
+ <binding.jms >
+ <destination jndiName="dynamic/MyService"/>
+ <headers timeToLive="123" />
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java b/sandbox/sebastien/java/embed/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java
new file mode 100644
index 0000000000..b5839f4c4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.MockInitialContextFactory;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ */
+public class TTLTestCase {
+
+ private Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @Test
+ public void testSayHello() throws Exception {
+ ClientIface client1 = node.getService(ClientIface.class, "Client1");
+
+ client1.sayHello("petra");
+
+ synchronized(MockInitialContextFactory.lock) {
+ if (MockInitialContextFactory.timeToLive == null) {
+ MockInitialContextFactory.lock.wait(10000);
+ }
+ }
+
+ assertNotNull(MockInitialContextFactory.timeToLive);
+ assertEquals(123, MockInitialContextFactory.timeToLive.longValue());
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/pom.xml b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/pom.xml
new file mode 100644
index 0000000000..61c0602f03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-uri-rpc</artifactId>
+ <name>Apache Tuscany SCA iTest JMS with URI RPC</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.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.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldClientImpl implements HelloWorldService {
+
+ private HelloWorldService serviceA;
+
+ @Reference
+ public void setServiceA(HelloWorldService service) {
+ this.serviceA = service;
+ }
+
+ public String sayHello(String name) {
+ return serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.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.jms;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ if ("bang".equals(name)) {
+ throw new RuntimeException("blem wit");
+ }
+ return "jmsHello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..655372580c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+ <deployable composite="itest:URIClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/jndi.properties b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..f6dfc8e9d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/jndi.properties
@@ -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.
+## ---------------------------------------------------------------------------
+
+# START SNIPPET: jndi
+
+java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
+
+# use the following property to configure the default connector
+java.naming.provider.url = vm://localhost?broker.persistent=false
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
+connectionFactoryNames = ConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.DestQueueA = DestQueueA
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.MyTopic = example.MyTopic
+
+# END SNIPPET: jndi
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/simple/service.composite b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/simple/service.composite
new file mode 100644
index 0000000000..99ed243196
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/simple/service.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="SimpleServiceComposite">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
+ <service name="HelloWorldService">
+ <binding.jms>
+ <destination jndiName="DestQueueA" >
+ </destination>
+ <response>
+ <destination jndiName="RespQueueA"/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite
new file mode 100644
index 0000000000..8295fb10c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/main/resources/simple/uriclient.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="URIClientComposite">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>
+ <reference name="serviceA">
+ <binding.jms uri="jms:jndi:DestQueueA" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java
new file mode 100644
index 0000000000..60b0f0a1a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/jms/uri-rpc/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.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.sca.binding.jms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This shows how to test the JMS binding using a simple HelloWorld application.
+ */
+public class URIRPCTestCase {
+
+ private static Node node;
+
+ @Before
+ public void init() {
+ node = NodeFactory.newInstance().createNode().start();
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testHelloWorldCreate() throws Exception {
+ HelloWorldService helloWorldService = node.getService(HelloWorldService.class, "HelloWorldClient");
+ assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/node-launcher-equinox/pom.xml b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/pom.xml
new file mode 100644
index 0000000000..8e80bd658c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-node-launcher-equinox</artifactId>
+ <name>Apache Tuscany SCA iTest Node Launcher Exuinox</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorld.java b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorld.java
new file mode 100644
index 0000000000..e3fcdfd25f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorld.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 hello;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * HelloWorld interface
+ */
+@Remotable
+public interface HelloWorld {
+ String hello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java
new file mode 100644
index 0000000000..8232acb658
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorldClient.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 hello;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class HelloWorldClient {
+
+ private HelloWorld hw;
+
+ @Reference
+ public void setHelloWorld(HelloWorld hw) {
+ this.hw = hw;
+ }
+
+ @Init
+ public void hello() {
+ // Say hello
+ System.out.println("Contribution ClassLoader: " + getClass().getClassLoader());
+ System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader());
+ System.out.println(hw.hello("Equinox"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java
new file mode 100644
index 0000000000..e51d3c79d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.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 hello;
+
+/**
+ * HelloWorldImpl
+ */
+public class HelloWorldImpl implements HelloWorld {
+ public String hello(String name) {
+ System.out.println("Name: " + name);
+ return "Hello, " + name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java
new file mode 100644
index 0000000000..5728ad2e07
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.equinox.launcher;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * Test case for equinox host
+ */
+public class EquinoxOSGiHostTestCase {
+
+ @Test
+ public void testStartThenStop() {
+ EquinoxHost host = new EquinoxHost();
+ BundleContext context = host.start();
+ Assert.assertNotNull(context);
+ for (Bundle b : context.getBundles()) {
+ System.out.println(toString(b, false));
+ }
+ host.stop();
+ }
+
+ @Test
+ public void testStartThenStopTwice() {
+ EquinoxHost host = new EquinoxHost();
+ BundleContext context = host.start();
+ Assert.assertNotNull(context);
+ for (Bundle b : context.getBundles()) {
+ System.out.println(toString(b, false));
+ }
+ host.stop();
+
+ host = new EquinoxHost();
+ context = host.start();
+ Assert.assertNotNull(context);
+ for (Bundle b : context.getBundles()) {
+ System.out.println(toString(b, false));
+ }
+ host.stop();
+ }
+
+ public static String toString(Bundle b, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(b.getBundleId()).append(" ").append(b.getSymbolicName());
+ int s = b.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ sb.append(" ").append(b.getLocation());
+ if (verbose) {
+ Dictionary<Object, Object> dict = b.getHeaders();
+ Enumeration<Object> keys = dict.keys();
+ while (keys.hasMoreElements()) {
+ Object key = keys.nextElement();
+ sb.append(" ").append(key).append("=").append(dict.get(key));
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java
new file mode 100644
index 0000000000..5cc40ca77f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.equinox.launcher;
+
+import org.apache.tuscany.sca.node.Node;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class NodeLauncherTestCase {
+ private static NodeLauncher launcher;
+
+ @BeforeClass
+ public static void setUp() {
+ System.setProperty("osgi.configuration.area", "target/equinox/configuration");
+ try {
+ launcher = NodeLauncher.newInstance();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ System.clearProperty("osgi.configuration.area");
+ if (launcher != null) {
+ launcher.destroy();
+ }
+
+ }
+
+ @Test
+ public void testLaunch() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation(getClass());
+ Node node = launcher.createNode("HelloWorld.composite", new Contribution("test", location));
+ node.start();
+ node.stop();
+ }
+
+ @Test
+ @Ignore("contribution-osgi issue")
+ public void testLaunchDomain() throws Exception {
+ DomainManagerLauncher.main(new String[] {});
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/resources/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/resources/HelloWorld.composite
new file mode 100644
index 0000000000..32ec5f0e2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/node-launcher-equinox/src/test/resources/HelloWorld.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample/composite"
+ xmlns:sc="http://sample/composite"
+ name="HelloWorld">
+
+ <component name="HelloWorld">
+ <implementation.java class="hello.HelloWorldImpl" />
+ </component>
+ <component name="HelloWorldClient">
+ <implementation.java class="hello.HelloWorldClient" />
+ <reference name="helloWorld" target="HelloWorld"></reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/pom.xml
new file mode 100644
index 0000000000..aa08bfde8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-binding-sca-hazelcast</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes binding.sca Using Hazelcast Registry</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <reportFormat>brief</reportFormat>
+ <useFile>true</useFile>
+ <forkMode>once</forkMode>
+ <argLine>-ea -Xmx256m</argLine>
+ <parallel>off</parallel>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java
new file mode 100644
index 0000000000..ef2565b750
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+/**
+ *
+ */
+public interface Client {
+ String getName(String id);
+
+ String create(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java
new file mode 100644
index 0000000000..96a0f2dadd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.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.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Client.class)
+public class ClientImpl implements Client {
+ @Reference
+ protected Local local;
+
+ @Reference
+ protected Remote remote;
+
+ public String getName(String id) {
+ Customer customer = null;
+ try {
+ customer = remote.getCustomer(id);
+ } catch (CustomerNotFoundException e) {
+ return null;
+ }
+ customer.dump("Client.getName()");
+ return local.getName(customer);
+ }
+
+ public String create(String name) {
+ String id = remote.generateId();
+ Customer customer = remote.createCustomer(id, name);
+ customer.dump("Client.create()");
+ return remote.getId(customer);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java
new file mode 100644
index 0000000000..f2b7b1e41d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.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.itest.bindingsca;
+
+/**
+ *
+ */
+public class Customer {
+ private String id;
+ private String name;
+
+ public Customer() {
+ }
+
+ /**
+ * @param id
+ * @param name
+ */
+ public Customer(String id, String name) {
+ super();
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "Customer [id=" + id + ", name=" + name + "]";
+ }
+
+ public void dump(String prefix) {
+ System.out.print(prefix);
+ System.out.print(": ");
+ System.out.print(toString());
+ System.out.println(" @" + System.identityHashCode(this));
+ System.out.println(getClass().getClassLoader());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java
new file mode 100644
index 0000000000..a6e80c9eca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+/**
+ *
+ */
+public class CustomerNotFoundException extends Exception {
+ private String customerId;
+
+ /**
+ *
+ */
+ public CustomerNotFoundException() {
+ }
+
+ /**
+ * @param message
+ */
+ public CustomerNotFoundException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public CustomerNotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public CustomerNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public String getCustomerId() {
+ return customerId;
+ }
+
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java
new file mode 100644
index 0000000000..0fe30c9d53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.bindingsca;
+
+/**
+ *
+ */
+public interface Local {
+ String getName(Customer customer);
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java
new file mode 100644
index 0000000000..8783808334
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.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 org.apache.tuscany.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Local.class)
+public class LocalServiceImpl implements Local {
+
+ public String getName(Customer customer) {
+ if (customer == null) {
+ return null;
+ }
+ customer.dump("Local.getName()");
+ return customer.getName();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java
new file mode 100644
index 0000000000..050d35007b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.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 org.apache.tuscany.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface Remote {
+ String generateId();
+
+ String getId(Customer customer);
+
+ Customer getCustomer(String id) throws CustomerNotFoundException;
+
+ Customer createCustomer(String id, String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java
new file mode 100644
index 0000000000..6c432a500a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Remote.class)
+@Scope("COMPOSITE")
+public class RemoteServiceImpl implements Remote {
+ private Map<String, Customer> customers = new HashMap<String, Customer>();
+
+ public String generateId() {
+ return UUID.randomUUID().toString();
+ }
+
+ @AllowsPassByReference
+ public String getId(Customer customer) {
+ customer.dump("Remote.getId()");
+ return customer.getId();
+ }
+
+ public Customer getCustomer(String id) throws CustomerNotFoundException {
+ Customer customer = customers.get(id);
+ if (customer == null) {
+ CustomerNotFoundException ex = new CustomerNotFoundException("Customer not found");
+ ex.setCustomerId(id);
+ throw ex;
+ }
+ customer.dump("Remote.getCustomer()");
+ return customer;
+ }
+
+ public Customer createCustomer(String id, String name) {
+ Customer customer = new Customer(id, name);
+ customer.dump("Remote.createCustomer()");
+ customers.put(id, customer);
+ return customer;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java
new file mode 100644
index 0000000000..3573eea978
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.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.itest.bindingsca;
+
+import java.net.URI;
+
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ *
+ */
+public class SCAClientImpl implements Client {
+ private Local local;
+ private Remote remote;
+
+ public SCAClientImpl(String domainURI) throws Exception {
+ SCAClientFactory factory = SCAClientFactory.newInstance(URI.create(domainURI));
+ local = factory.getService(Local.class, "LocalComponent/Local");
+ remote = factory.getService(Remote.class, "RemoteComponent/Remote");
+ }
+
+ public String getName(String id) {
+ Customer customer = null;
+ try {
+ customer = remote.getCustomer(id);
+ } catch (CustomerNotFoundException e) {
+ return null;
+ }
+ customer.dump("Client.getName()");
+ return local.getName(customer);
+ }
+
+ public String create(String name) {
+ String id = remote.generateId();
+ Customer customer = remote.createCustomer(id, name);
+ customer.dump("Client.create()");
+ return remote.getId(customer);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite
new file mode 100644
index 0000000000..b04cc33023
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite
@@ -0,0 +1,30 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://client"
+ name="Client">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.ClientImpl" />
+ <reference name="local" target="LocalComponent" />
+ <reference name="remote" target="RemoteComponent" />
+ </component>
+
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite
new file mode 100644
index 0000000000..fe282d291c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://service"
+ name="Service">
+
+ <component name="LocalComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.LocalServiceImpl" />
+ </component>
+
+ <component name="RemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.RemoteServiceImpl" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java
new file mode 100644
index 0000000000..9efa1a99ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.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.sca.axis2;
+
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientCallbackOnewayRemoteImpl;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+// @Ignore("TUSCANY-3138")
+public class AsynchTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("asynch", "./target/test-classes/ws/asynchReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("asynch", "./target/test-classes/ws/asynchService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ @Test
+ public void testHelloWorldAsynch() throws Exception {
+ HelloWorldClient helloWorldClientB;
+ helloWorldClientB = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ helloWorldClientB.getGreetings("fred");
+ System.out.println("Sleeping ...");
+ Thread.sleep(2000);
+ System.out.println("... Done");
+ Assert.assertEquals("callback fred", HelloWorldClientCallbackOnewayRemoteImpl.result );
+
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java
new file mode 100644
index 0000000000..efa84e92a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.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.binding.sca.axis2;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+// @Ignore("TUSCANY-3138")
+public class CallbackTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/ws/callbackReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/ws/callbackService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ //@Test
+ public void testKeepServerRunning() throws Exception {
+ System.out.println("press enter to continue");
+ System.in.read();
+ }
+
+ @Test
+ public void testHelloWorldCallbackLocal() throws Exception {
+ HelloWorldClient helloWorldClientB;
+ helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientCallbackLocal");
+ Assert.assertEquals("Hello callback fred", helloWorldClientB.getGreetings("fred"));
+ }
+
+ @Test
+ public void testHelloWorldCallbackRemote() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ Assert.assertEquals("Hello callback fred", helloWorldClientA.getGreetings("fred"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java
new file mode 100644
index 0000000000..45d28140b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.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.sca.binding.sca.axis2;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class PromotionTestCase {
+
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/ws/promotionReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/ws/promotionService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ @Test
+ @Ignore
+ public void testHelloWorldPromotion() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemotePromotion");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java
new file mode 100644
index 0000000000..a5d6529895
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.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.sca.binding.sca.axis2;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+public class SimpleTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/ws/simpleReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/ws/simpleService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ @Test
+ public void testHelloWorldLocal() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocal");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+ @Test
+ public void testHelloWorldRemote() throws Exception {
+
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemote");
+
+ try {
+ helloWorldClientA.getGreetings("fred");
+ } catch (ServiceUnavailableException ex){
+ Assert.fail();
+ }
+ }
+
+ @Test
+ public void testHelloWorldLocalAndRemote() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocalAndRemote");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientLocalAndRemote");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
+ }
+
+ @Test
+ public void testHelloWorldMultipleServices() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices");
+ HelloWorldClient helloWorldClientA2 = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices2");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientMultipleServices");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientA2.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
+ }
+
+ @Test
+ public void testHelloWorldMultipleBindings() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleBindings");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java
new file mode 100644
index 0000000000..f7ab3dfe98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.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.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+public interface HelloWorldCallbackRemote {
+
+ String getGreetingsCallbackRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..3d25d37708
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2.helloworld;
+
+
+public interface HelloWorldClient {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java
new file mode 100644
index 0000000000..a469d197d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallbackRemote.class)
+public interface HelloWorldServiceCallbackOnewayRemote {
+
+ @OneWay
+ void getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java
new file mode 100644
index 0000000000..3f5a21fddd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.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.sca.binding.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallbackRemote.class)
+public interface HelloWorldServiceCallbackRemote {
+
+ String getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java
new file mode 100644
index 0000000000..49e5232b31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2.helloworld;
+
+
+public interface HelloWorldServiceLocal {
+
+ String getGreetingsLocal(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java
new file mode 100644
index 0000000000..ccc77c142b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldServiceRemote {
+
+ String getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java
new file mode 100644
index 0000000000..c2be798d1a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldServiceRemote2 {
+
+ String getGreetingsRemote2(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..9355aece1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceCallbackOnewayRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientCallbackOnewayRemoteImpl implements HelloWorldClient {
+
+ public static String result;
+
+ @Reference
+ public HelloWorldServiceCallbackOnewayRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ helloWorldService.getGreetingsRemote(s);
+ return null;
+ }
+
+ public String getGreetingsCallbackRemote(String s) {
+ result = "callback " + s;
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
new file mode 100644
index 0000000000..efc47aa94d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceCallbackRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientCallbackRemoteImpl implements HelloWorldClient {
+
+ public static String result;
+
+ @Reference
+ public HelloWorldServiceCallbackRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote(s);
+ }
+
+ public String getGreetingsCallbackRemote(String s) {
+ result = "callback " + s;
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java
new file mode 100644
index 0000000000..6ed813ff0a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.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 org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceLocal;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientLocalImpl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceLocal helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsLocal(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java
new file mode 100644
index 0000000000..ba70573efb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.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 org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote2;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientRemote2Impl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceRemote2 helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote2(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java
new file mode 100644
index 0000000000..a87d6eb49a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.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 org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientRemoteImpl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..3dc0b12b82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.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 org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldCallbackRemote;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceCallbackOnewayRemote;
+import org.oasisopen.sca.annotation.Callback;
+
+public class HelloWorldServiceCallbackOnewayRemoteImpl implements HelloWorldServiceCallbackOnewayRemote {
+
+ @Callback
+ protected HelloWorldCallbackRemote theCallback;
+
+ public void getGreetingsRemote(String s) {
+ theCallback.getGreetingsCallbackRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java
new file mode 100644
index 0000000000..b15d6dea80
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.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.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldCallbackRemote;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceCallbackRemote;
+import org.oasisopen.sca.annotation.Callback;
+
+public class HelloWorldServiceCallbackRemoteImpl implements HelloWorldServiceCallbackRemote {
+
+ @Callback
+ protected HelloWorldCallbackRemote theCallback;
+
+ public HelloWorldServiceCallbackRemoteImpl() {
+ System.out.println("Constructor");
+ }
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + theCallback.getGreetingsCallbackRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java
new file mode 100644
index 0000000000..c4347b084a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.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.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceLocal;
+
+public class HelloWorldServiceLocalImpl implements HelloWorldServiceLocal {
+
+ public String getGreetingsLocal(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java
new file mode 100644
index 0000000000..846bff02e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.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.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceLocal;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote2;
+import org.oasisopen.sca.annotation.Service;
+
+@Service({HelloWorldServiceRemote.class, HelloWorldServiceRemote2.class, HelloWorldServiceLocal.class} )
+public class HelloWorldServiceMultipleServicesImpl implements HelloWorldServiceLocal, HelloWorldServiceRemote, HelloWorldServiceRemote2 {
+
+ public String getGreetingsLocal(String s) {
+ return "Hello " + s;
+ }
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + s;
+ }
+
+ public String getGreetingsRemote2(String s) {
+ return "Hello " + s;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java
new file mode 100644
index 0000000000..d69f442879
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.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.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote;
+
+public class HelloWorldServiceRemoteImpl implements HelloWorldServiceRemote {
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/AsynchTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/AsynchTestCase.java
new file mode 100644
index 0000000000..cbcc06056a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/AsynchTestCase.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.sca.rmi;
+
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientCallbackOnewayRemoteImpl;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class AsynchTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+ // System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding", RMIBinding.TYPE.toString());
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("asynch", "./target/test-classes/rmi/asynchReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("asynch", "./target/test-classes/rmi/asynchService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ // System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+ }
+
+ @Test
+ public void testHelloWorldAsynch() throws Exception {
+ HelloWorldClient helloWorldClientB;
+ helloWorldClientB = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ helloWorldClientB.getGreetings("fred");
+ System.out.println("Sleeping ...");
+ Thread.sleep(2000);
+ System.out.println("... Done");
+ Assert.assertEquals("callback fred", HelloWorldClientCallbackOnewayRemoteImpl.result );
+
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/CallbackTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/CallbackTestCase.java
new file mode 100644
index 0000000000..dccd2dace8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/CallbackTestCase.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.rmi;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CallbackTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+ // System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding", RMIBinding.TYPE.toString());
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/rmi/callbackReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/rmi/callbackService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ // System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+ }
+
+ //@Test
+ public void testKeepServerRunning() throws Exception {
+ System.out.println("press enter to continue");
+ System.in.read();
+ }
+
+ @Test
+ public void testHelloWorldCallbackLocal() throws Exception {
+ HelloWorldClient helloWorldClientB;
+ helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientCallbackLocal");
+ Assert.assertEquals("Hello callback fred", helloWorldClientB.getGreetings("fred"));
+ }
+
+ @Test
+ public void testHelloWorldCallbackRemote() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ Assert.assertEquals("Hello callback fred", helloWorldClientA.getGreetings("fred"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/PromotionTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/PromotionTestCase.java
new file mode 100644
index 0000000000..7aac95a8ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/PromotionTestCase.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.sca.binding.sca.rmi;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class PromotionTestCase {
+
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+ System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding",
+ "{http://tuscany.apache.org/xmlns/sca/1.1}binding.rmi");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/rmi/promotionReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/rmi/promotionService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+
+ }
+
+ @Test
+ public void testHelloWorldPromotion() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemotePromotion");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/SimpleTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/SimpleTestCase.java
new file mode 100644
index 0000000000..f748beb6cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/SimpleTestCase.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.sca.binding.sca.rmi;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+public class SimpleTestCase {
+
+ private static NodeFactory factory;
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+ System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding",
+ "{http://tuscany.apache.org/xmlns/sca/1.1}binding.rmi");
+
+ try {
+ factory = NodeFactory.getInstance();
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/rmi/simpleReference");
+ nodeA = factory.createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/rmi/simpleService");
+ nodeB = factory.createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ factory.destroy();
+ System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+ }
+
+ @Test
+ public void testHelloWorldLocal() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocal");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+ @Test
+ public void testHelloWorldRemote() throws Exception {
+
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemote");
+
+ try {
+ helloWorldClientA.getGreetings("fred");
+ } catch (ServiceUnavailableException ex){
+ Assert.fail();
+ }
+ }
+
+ @Test
+ public void testHelloWorldLocalAndRemote() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocalAndRemote");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientLocalAndRemote");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
+ }
+
+ @Test
+ public void testHelloWorldMultipleServices() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices");
+ HelloWorldClient helloWorldClientA2 = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices2");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientMultipleServices");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientA2.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
+ }
+
+ @Test
+ public void testHelloWorldMultipleBindings() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleBindings");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldCallbackRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldCallbackRemote.java
new file mode 100644
index 0000000000..7c4cf4b0b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldCallbackRemote.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.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+public interface HelloWorldCallbackRemote {
+
+ String getGreetingsCallbackRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..017acee582
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldClient.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.rmi.helloworld;
+
+
+public interface HelloWorldClient {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackOnewayRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackOnewayRemote.java
new file mode 100644
index 0000000000..86f984e61a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackOnewayRemote.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallbackRemote.class)
+public interface HelloWorldServiceCallbackOnewayRemote {
+
+ @OneWay
+ void getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackRemote.java
new file mode 100644
index 0000000000..8e19fd7382
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackRemote.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.sca.binding.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallbackRemote.class)
+public interface HelloWorldServiceCallbackRemote {
+
+ String getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceLocal.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceLocal.java
new file mode 100644
index 0000000000..b0d623e2e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceLocal.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.rmi.helloworld;
+
+
+public interface HelloWorldServiceLocal {
+
+ String getGreetingsLocal(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote.java
new file mode 100644
index 0000000000..ccb44694d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldServiceRemote {
+
+ String getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote2.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote2.java
new file mode 100644
index 0000000000..5c8bb13f43
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote2.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldServiceRemote2 {
+
+ String getGreetingsRemote2(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..1ff1792bb7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceCallbackOnewayRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientCallbackOnewayRemoteImpl implements HelloWorldClient {
+
+ public static String result;
+
+ @Reference
+ public HelloWorldServiceCallbackOnewayRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ helloWorldService.getGreetingsRemote(s);
+ return null;
+ }
+
+ public String getGreetingsCallbackRemote(String s) {
+ result = "callback " + s;
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
new file mode 100644
index 0000000000..b17d8e2016
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceCallbackRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientCallbackRemoteImpl implements HelloWorldClient {
+
+ public static String result;
+
+ @Reference
+ public HelloWorldServiceCallbackRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote(s);
+ }
+
+ public String getGreetingsCallbackRemote(String s) {
+ result = "callback " + s;
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientLocalImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientLocalImpl.java
new file mode 100644
index 0000000000..e230326f5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientLocalImpl.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 org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceLocal;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientLocalImpl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceLocal helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsLocal(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemote2Impl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemote2Impl.java
new file mode 100644
index 0000000000..77df8c2c39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemote2Impl.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 org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote2;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientRemote2Impl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceRemote2 helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote2(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemoteImpl.java
new file mode 100644
index 0000000000..8effa3ac36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemoteImpl.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 org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientRemoteImpl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..2467ddab88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.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 org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldCallbackRemote;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceCallbackOnewayRemote;
+import org.oasisopen.sca.annotation.Callback;
+
+public class HelloWorldServiceCallbackOnewayRemoteImpl implements HelloWorldServiceCallbackOnewayRemote {
+
+ @Callback
+ protected HelloWorldCallbackRemote theCallback;
+
+ public void getGreetingsRemote(String s) {
+ theCallback.getGreetingsCallbackRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java
new file mode 100644
index 0000000000..d1b75d0a2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.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.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldCallbackRemote;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceCallbackRemote;
+import org.oasisopen.sca.annotation.Callback;
+
+public class HelloWorldServiceCallbackRemoteImpl implements HelloWorldServiceCallbackRemote {
+
+ @Callback
+ protected HelloWorldCallbackRemote theCallback;
+
+ public HelloWorldServiceCallbackRemoteImpl() {
+ System.out.println("Constructor");
+ }
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + theCallback.getGreetingsCallbackRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceLocalImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceLocalImpl.java
new file mode 100644
index 0000000000..44e7efc668
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceLocalImpl.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.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceLocal;
+
+public class HelloWorldServiceLocalImpl implements HelloWorldServiceLocal {
+
+ public String getGreetingsLocal(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java
new file mode 100644
index 0000000000..88440de023
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceMultipleServicesImpl.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.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceLocal;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote2;
+import org.oasisopen.sca.annotation.Service;
+
+@Service({HelloWorldServiceRemote.class, HelloWorldServiceRemote2.class, HelloWorldServiceLocal.class} )
+public class HelloWorldServiceMultipleServicesImpl implements HelloWorldServiceLocal, HelloWorldServiceRemote, HelloWorldServiceRemote2 {
+
+ public String getGreetingsLocal(String s) {
+ return "Hello " + s;
+ }
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + s;
+ }
+
+ public String getGreetingsRemote2(String s) {
+ return "Hello " + s;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceRemoteImpl.java
new file mode 100644
index 0000000000..06dc2c3f79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceRemoteImpl.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.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote;
+
+public class HelloWorldServiceRemoteImpl implements HelloWorldServiceRemote {
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
new file mode 100644
index 0000000000..fcd0d39162
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Test binding.sca in the same classloader
+ */
+public class BindingSCATestCase {
+ static final String DOMAIN_URI = "my-domain";
+ private static final String REGISTRY_URI = "tuscany:bindingScaTestDomain";
+ private static final String PKG = "org/apache/tuscany/sca/itest/bindingsca/";
+ private static final String CLIENT = "Client.composite";
+ private static final String SERVICE = "Service.composite";
+ private static final String ROOT = new File("target/classes/" + PKG).toURI().toString();
+
+ /**
+ * One NodeFactory and two nodes
+ */
+ @Test
+ public void testOneFactoryTwoNodes() {
+ NodeFactory factory1 = NodeFactory.getInstance();
+ Node node1 = createClientNode(factory1);
+ Node node2 = createServiceNode(factory1);
+ node1.start();
+ node2.start();
+ try {
+ runClient(node1);
+ } finally {
+ node2.stop();
+ node1.stop();
+ factory1.destroy();
+ }
+ }
+
+ /**
+ * Create the service node
+ * @param factory
+ * @return
+ */
+ static Node createServiceNode(NodeFactory factory) {
+ NodeConfiguration config2 =
+ factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node2").addContribution("c2", ROOT)
+ .addDeploymentComposite("c2", SERVICE).setDomainRegistryURI(REGISTRY_URI)
+ .addBinding(WebServiceBinding.TYPE, "http://localhost:8085/").addBinding(SCABinding.TYPE,
+ "http://localhost:8085/");
+
+ Node node2 = factory.createNode(config2);
+ return node2;
+ }
+
+ /**
+ * Create the client node
+ * @param factory
+ * @return
+ */
+ static Node createClientNode(NodeFactory factory) {
+ NodeConfiguration config1 =
+ factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node1").addContribution("c1", ROOT)
+ .addDeploymentComposite("c1", CLIENT).setDomainRegistryURI(REGISTRY_URI)
+ .addBinding(WebServiceBinding.TYPE, "http://localhost:8085/").addBinding(SCABinding.TYPE,
+ "http://localhost:8085/");
+ Node node1 = factory.createNode(config1);
+ return node1;
+ }
+
+ /**
+ * Two node factories and two nodes
+ */
+ @Test
+ public void testTwoFactoriesTwoNodes() throws Exception {
+ NodeFactory factory1 = NodeFactory.newInstance();
+ Node node1 = createClientNode(factory1);
+ NodeFactory factory2 = NodeFactory.newInstance();
+ Node node2 = createServiceNode(factory2);
+ node1.start();
+ node2.start();
+ Thread.sleep(1000);
+ try {
+ // This call doesn't require the Local service, it should be successful
+ createCustomer(node1);
+ try {
+ runClient(node1);
+ // We cannot make local call to remote endpoints
+ Assert.fail("ServiceRuntimeException should have been thrown.");
+ } catch (ServiceRuntimeException e) {
+ // ignore
+ }
+ } finally {
+ node2.stop();
+ node1.stop();
+ factory2.destroy();
+ factory1.destroy();
+ }
+ }
+
+ /**
+ * Run the client
+ * @param node
+ */
+ static void runClient(Node node) {
+ Client client = node.getService(Client.class, "ClientComponent/Client");
+ runClient(client);
+ }
+
+ static void runClient(Client client) {
+ String id = client.create("Ray");
+ Assert.assertEquals("Ray", client.getName(id));
+ }
+
+ static void runClientNotFound(Client client) {
+ String id = "not-there";
+ Assert.assertNull(client.getName(id));
+ }
+
+ static String createCustomer(Node node) {
+ Client client = node.getService(Client.class, "ClientComponent/Client");
+ String id = client.create("John");
+ Assert.assertNotNull(id);
+ return id;
+ }
+
+ /**
+ * One node factory and one node for both composites
+ */
+ @Test
+ public void testOneFactoryOneNode() {
+ NodeFactory factory = NodeFactory.getInstance();
+ NodeConfiguration config1 =
+ factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node1").addContribution("c1", ROOT)
+ .addDeploymentComposite("c1", CLIENT).addDeploymentComposite("c1", SERVICE);
+
+ Node node1 = factory.createNode(config1);
+ node1.start();
+ try {
+ runClient(node1);
+ } finally {
+ node1.stop();
+ factory.destroy();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
new file mode 100644
index 0000000000..7255697d4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.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.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client node and service node with two different classloaders that share the Customer class
+ */
+public class ClientNodeSharedCustomerTestCase {
+ private static Node clientNode;
+ private static TestCaseRunner runner;
+ private static NodeFactory factory;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner = new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName());
+ runner.beforeClass();
+ factory = NodeFactory.getInstance();
+ clientNode = BindingSCATestCase.createClientNode(factory).start();
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(clientNode);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (runner != null) {
+ runner.afterClass();
+ }
+ if (factory != null) {
+ factory.destroy();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
new file mode 100644
index 0000000000..51fafae32c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.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.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client node and service node with two different classloaders that share the Local class
+ * (but not Customer)
+ */
+public class ClientNodeSharedLocalTestCase {
+ private static Node clientNode;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner =
+ new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName(),
+ Customer.class.getName());
+ runner.beforeClass();
+ NodeFactory factory = NodeFactory.getInstance();
+ clientNode = BindingSCATestCase.createClientNode(factory).start();
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(clientNode);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (runner != null) {
+ runner.afterClass();
+ }
+ NodeFactory.getInstance().destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
new file mode 100644
index 0000000000..b8ff0c58ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.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.sca.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client api and service node with two different classloaders that share the Customer class
+ */
+public class ClientSharedCustomerTestCase {
+ private static Client client;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner = new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName());
+ runner.beforeClass();
+ client = new SCAClientImpl(BindingSCATestCase.DOMAIN_URI);
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(client);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (runner != null) {
+ runner.afterClass();
+ }
+ NodeFactory.getInstance().destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
new file mode 100644
index 0000000000..633e1a767c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.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.sca.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client api and service node with two different classloaders that share the Local class
+ * (but not Customer)
+ */
+public class ClientSharedLocalTestCase {
+ private static Client client;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner =
+ new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName(),
+ Customer.class.getName(), CustomerNotFoundException.class.getName());
+ runner.beforeClass();
+ client = new SCAClientImpl(BindingSCATestCase.DOMAIN_URI);
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(client);
+ }
+
+ @Test
+ public void testClientNotFound() throws Exception {
+ BindingSCATestCase.runClientNotFound(client);
+ }
+
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (runner != null) {
+ runner.afterClass();
+ }
+ NodeFactory.getInstance().destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ServiceNode.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ServiceNode.java
new file mode 100644
index 0000000000..1cba2b57c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ServiceNode.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class ServiceNode {
+ private static Node serviceNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ /* System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled",
+ "false");
+ */
+ NodeFactory factory = NodeFactory.getInstance();
+ serviceNode = BindingSCATestCase.createServiceNode(factory).start();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/TestCaseRunner.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/TestCaseRunner.java
new file mode 100644
index 0000000000..c0960ffe95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/java/org/apache/tuscany/sca/itest/bindingsca/TestCaseRunner.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A helper class that can be used to run an SCA JUnit test case. The test case will run in an isolated class loader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestCaseRunner {
+
+ private ClassLoader classLoader;
+ private Class<?> testSuiteClass;
+ private Object testSuite;
+ private Class<?> testResultClass;
+ private Class<?> testCaseClass;
+ private Object testCase;
+
+ private Class<?> beforeAnnotation;
+ private Class<?> beforeClassAnnotation;
+ private Class<?> afterAnnotation;
+ private Class<?> afterClassAnnotation;
+ private Class<?> junit4AdapterClass;
+ private Class<?> junit3TestCaseClass;
+
+ /**
+ * Constructs a new TestCase runner.
+ *
+ * @param testClass
+ */
+ public TestCaseRunner(Class<?> testClass, String... isolatedClasses) {
+ try {
+ ClassLoader tccl = setupClassLoader(testClass, isolatedClasses);
+
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ testCaseClass = Class.forName(testClass.getName(), true, classLoader);
+ testCase = testCaseClass.newInstance();
+ ClassLoader testClassLoader = testCaseClass.getClassLoader();
+
+ junit3TestCaseClass = Class.forName("junit.framework.TestCase", true, testClassLoader);
+
+ testSuiteClass = Class.forName("junit.framework.TestSuite", true, testClassLoader);
+ Constructor<?> testSuiteConstructor = testSuiteClass.getConstructor(Class.class);
+ testSuite = testSuiteConstructor.newInstance(testCaseClass);
+
+ testResultClass = Class.forName("junit.framework.TestResult", true, testClassLoader);
+
+ try {
+ beforeAnnotation = Class.forName("org.junit.Before", true, testClassLoader);
+ afterAnnotation = Class.forName("org.junit.After", true, testClassLoader);
+ beforeClassAnnotation = Class.forName("org.junit.BeforeClass", true, testClassLoader);
+ afterClassAnnotation = Class.forName("org.junit.AfterClass", true, testClassLoader);
+ junit4AdapterClass = Class.forName("junit.framework.JUnit4TestAdapter", true, testClassLoader);
+ } catch (Exception e) {
+ // Unexpected
+ throw new AssertionError(e);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ClassLoader setupClassLoader(Class<?> testClass, String... isolatedClasses) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ classLoader = testClass.getClassLoader();
+ if (classLoader instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader)classLoader).getURLs();
+ classLoader = new ClassLoaderImpl(urls, classLoader, isolatedClasses);
+ } else if (classLoader == tccl || classLoader.getParent() == tccl) {
+ classLoader = new URLClassLoader(new URL[0], classLoader);
+ } else {
+ classLoader = tccl;
+ }
+ return tccl;
+ }
+
+ /**
+ * Run the test case
+ */
+ public void run() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ if (junit3TestCaseClass.isAssignableFrom(testCaseClass)) {
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = testSuiteClass.getMethod("run", testResultClass);
+ runMethod.invoke(testSuite, testResult);
+ } else {
+ Object junit4Adapter = junit4AdapterClass.getConstructor(Class.class).newInstance(testCaseClass);
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = junit4AdapterClass.getMethod("run", testResultClass);
+ runMethod.invoke(junit4Adapter, testResult);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Invoke the setUp method
+ */
+ public void setUp() {
+ execute("setUp");
+ }
+
+ /**
+ * Invoke the before methods
+ */
+ public void before() {
+ execute(beforeAnnotation);
+ }
+
+ /**
+ * Invoke the beforeClass methods
+ */
+ public void beforeClass() {
+ execute(beforeClassAnnotation);
+ }
+
+ /**
+ * Invoke the tearDown method
+ */
+ public void tearDown() {
+ execute("tearDown");
+ }
+
+ /**
+ * Invoke the after methods
+ */
+ public void after() {
+ execute(afterAnnotation);
+ }
+
+ /**
+ * Invoke the afterClass methods
+ */
+ public void afterClass() {
+ execute(afterClassAnnotation);
+ }
+
+ /**
+ * Invoke the specified test method.
+ */
+ public void run(String methodName) {
+ execute(methodName);
+ }
+
+ /**
+ * Invoke the methods annotated with the specified annotation.
+ */
+ private void execute(Class<?> annotationClass) {
+ if (annotationClass == null) {
+ throw new RuntimeException(new NoSuchMethodException());
+ }
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ for (Method method : testCaseClass.getDeclaredMethods()) {
+ for (Annotation annotation : method.getAnnotations()) {
+ if (annotation.annotationType() == annotationClass) {
+ method.invoke(testCase);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Invoke the specified method
+ */
+ private void execute(String methodName) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+ Method setUpMethod = testCaseClass.getDeclaredMethod(methodName);
+ setUpMethod.setAccessible(true);
+ setUpMethod.invoke(testCase);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ public static class ClassLoaderImpl extends URLClassLoader {
+ private Set<String> isolatedClasses = new HashSet<String>();
+
+ /**
+ * @param urls
+ * @param parent
+ */
+ public ClassLoaderImpl(URL[] urls, ClassLoader parent, String... sharedClasses) {
+ super(urls, parent);
+ this.isolatedClasses.addAll(Arrays.asList(sharedClasses));
+ }
+
+ @Override
+ protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ if (!isolatedClasses.contains(name)) {
+ return super.loadClass(name, resolve);
+ } else {
+ Class<?> cls = findLoadedClass(name);
+ if (cls == null) {
+ cls = findClass(name);
+ }
+ if (resolve) {
+ resolveClass(cls);
+ }
+ return cls;
+ }
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchReference/HelloWorld.composite
new file mode 100644
index 0000000000..8c825ca805
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchReference/HelloWorld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+ <!-- callback remote wire -->
+ <component name="AHelloWorldClientCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientCallbackOnewayRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote">
+ <binding.sca/>
+ <callback>
+ <binding.sca uri="http://localhost:8084/AHelloWorldClientCallbackRemote"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchService/HelloWorld.composite
new file mode 100644
index 0000000000..79b1a5d794
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchService/HelloWorld.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- callback remote wire -->
+ <component name="BHelloWorldServiceCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceCallbackOnewayRemoteImpl" />
+ <service name="HelloWorldServiceCallbackOnewayRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceCallbackRemote"/>
+ <callback>
+ <binding.sca/>
+ </callback>
+ </service>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/asynchService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackReference/HelloWorld.composite
new file mode 100644
index 0000000000..e8924d2728
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackReference/HelloWorld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+ <!-- callback remote wire -->
+ <component name="AHelloWorldClientCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientCallbackRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote">
+ <binding.sca/>
+ <callback>
+ <binding.sca uri="http://localhost:8084/AHelloWorldClientCallbackRemote"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackService/HelloWorld.composite
new file mode 100644
index 0000000000..4edc8df5cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackService/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- callback remote wire -->
+ <component name="BHelloWorldServiceCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceCallbackRemoteImpl" />
+ <service name="HelloWorldServiceCallbackRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceCallbackRemote"/>
+ <callback>
+ <binding.sca/>
+ </callback>
+ </service>
+ </component>
+
+ <!-- callback local wire -->
+ <component name="BHelloWorldClientCallbackLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientCallbackRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/callbackService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/HelloWorld.composite
new file mode 100644
index 0000000000..823cab4f56
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/HelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- composite hierarchy -->
+ <component name="AHelloWorldClientRemotePromotion">
+ <implementation.composite name="sample:HelloWorldComponent" />
+ <reference name="AHelloWorldClientRemoteReference" target="BHelloWorldServiceRemotePromotion"/>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/HelloWorldComponent.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/HelloWorldComponent.composite
new file mode 100644
index 0000000000..088fd616f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/HelloWorldComponent.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorldComponent">
+
+ <service name="AHelloWorldClientRemoteService" promote="AHelloWorldClientRemoteComponent">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient"/>
+ </service>
+
+ <reference name="AHelloWorldClientRemoteReference" promote="AHelloWorldClientRemoteComponent/helloWorldService" multiplicity="1..1">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote"/>
+ </reference>
+
+ <component name="AHelloWorldClientRemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/HelloWorld.composite
new file mode 100644
index 0000000000..454e9c55cf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/HelloWorld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- composite hierarchy -->
+ <component name="BHelloWorldServiceRemotePromotion">
+ <implementation.composite name="sample:HelloWorldComponent" />
+ <service name="BHelloWorldServiceRemoteService">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceRemotePromotion"/>
+ </service>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/HelloWorldComponent.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/HelloWorldComponent.composite
new file mode 100644
index 0000000000..a313fb8f68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/HelloWorldComponent.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorldComponent">
+
+ <service name="BHelloWorldServiceRemoteService"
+ promote="BHelloWorldServiceRemoteComponent/HelloWorldServiceRemote"/>
+
+ <component name="BHelloWorldServiceRemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl"/>
+ </component>
+
+ <component name="BHelloWorldServiceLocalAndRemoteNested">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/promotionService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleReference/HelloWorld.composite
new file mode 100644
index 0000000000..4151749523
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleReference/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- local only wire -->
+ <component name="AHelloWorldClientLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientLocalImpl"/>
+ <reference name="helloWorldService" target="AHelloWorldServiceLocal" />
+ </component>
+
+ <component name="AHelloWorldServiceLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceLocalImpl" />
+ </component>
+
+ <!-- unresolved remote wire -->
+ <component name="AHelloWorldClientRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceRemote" />
+ </component>
+
+ <!-- local and remote wires -->
+ <component name="AHelloWorldClientLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceLocalAndRemote"/>
+ </component>
+
+ <!-- multiple services -->
+ <component name="AHelloWorldClientMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceRemote"/>
+ </component>
+
+ <component name="AHelloWorldClientMultipleServices2">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemote2Impl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceRemote2"/>
+ </component>
+
+ <!-- multiple bindings -->
+ <component name="AHelloWorldClientMultipleBindings">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldMultipleBindings/HelloWorldServiceRemote/scaBinding">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleService/HelloWorld.composite
new file mode 100644
index 0000000000..37af7625ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleService/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- local only wire -->
+
+
+ <!-- unresolved remote wire -->
+ <component name="BHelloWorldServiceRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceRemote"/>
+ </service>
+ </component>
+
+ <!-- local and remote wires -->
+ <component name="BHelloWorldServiceLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceLocalAndRemote"/>
+ </service>
+ </component>
+
+ <component name="BHelloWorldClientLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceLocalAndRemote" />
+ </component>
+
+ <!-- multiple services -->
+ <component name="BHelloWorldServiceMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceMultipleServicesImpl" />
+ <service name="HelloWorldServiceLocal">
+ </service>
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceMultipleServices/HelloWorldServiceRemote"/>
+ </service>
+ <service name="HelloWorldServiceRemote2">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceMultipleServices/HelloWorldServiceRemote2"/>
+ </service>
+ </component>
+
+ <component name="BHelloWorldClientMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientLocalImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceLocal" />
+ </component>
+
+ <!-- multiple bindings -->
+ <component name="BHelloWorldMultipleBindings">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote" />
+ <!-- tuscany:binding.rmi name="rmiBinding" uri="http://localhost:8085/BHelloWorldMultipleBindings/HelloWorldServiceRemote-wsbinding"/ -->
+ <binding.sca name="scaBinding" uri="http://localhost:8085/BHelloWorldMultipleBindings/HelloWorldServiceRemote-scabinding"/>
+ </service>
+ </component>
+
+
+ <!-- Dynamic interfaces -->
+ <!--component name="BHelloWorldServiceScript">
+ <implementation.script script="calculator/AddServiceImpl.js"/>
+ </component-->
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/rmi/simpleService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchReference/HelloWorld.composite
new file mode 100644
index 0000000000..e797a0aa9c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchReference/HelloWorld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+ <!-- callback remote wire -->
+ <component name="AHelloWorldClientCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientCallbackOnewayRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote">
+ <binding.sca/>
+ <callback>
+ <binding.sca uri="http://localhost:8084/AHelloWorldClientCallbackRemote"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchService/HelloWorld.composite
new file mode 100644
index 0000000000..079ee49380
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchService/HelloWorld.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- callback remote wire -->
+ <component name="BHelloWorldServiceCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceCallbackOnewayRemoteImpl" />
+ <service name="HelloWorldServiceCallbackOnewayRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceCallbackRemote"/>
+ <callback>
+ <binding.sca/>
+ </callback>
+ </service>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/asynchService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackReference/HelloWorld.composite
new file mode 100644
index 0000000000..1d5630f3d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackReference/HelloWorld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+ <!-- callback remote wire -->
+ <component name="AHelloWorldClientCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientCallbackRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote">
+ <binding.sca/>
+ <callback>
+ <binding.sca uri="http://localhost:8084/AHelloWorldClientCallbackRemote"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackService/HelloWorld.composite
new file mode 100644
index 0000000000..ded3766d49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackService/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- callback remote wire -->
+ <component name="BHelloWorldServiceCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceCallbackRemoteImpl" />
+ <service name="HelloWorldServiceCallbackRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceCallbackRemote"/>
+ <callback>
+ <binding.sca/>
+ </callback>
+ </service>
+ </component>
+
+ <!-- callback local wire -->
+ <component name="BHelloWorldClientCallbackLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientCallbackRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/callbackService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/HelloWorld.composite
new file mode 100644
index 0000000000..4513f21acf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/HelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- composite hierarchy -->
+ <component name="AHelloWorldClientRemotePromotion">
+ <implementation.composite name="sample:HelloWorldComponent" />
+ <reference name="AHelloWorldClientRemoteReference" target="BHelloWorldServiceRemotePromotion"/>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/HelloWorldComponent.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/HelloWorldComponent.composite
new file mode 100644
index 0000000000..22c20ff94a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/HelloWorldComponent.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorldComponent">
+
+ <service name="AHelloWorldClientRemoteService" promote="AHelloWorldClientRemoteComponent">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient"/>
+ </service>
+
+ <reference name="AHelloWorldClientRemoteReference" promote="AHelloWorldClientRemoteComponent/helloWorldService" multiplicity="1..1">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote"/>
+ </reference>
+
+ <component name="AHelloWorldClientRemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/HelloWorld.composite
new file mode 100644
index 0000000000..e6a7d776c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/HelloWorld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- composite hierarchy -->
+ <component name="BHelloWorldServiceRemotePromotion">
+ <implementation.composite name="sample:HelloWorldComponent" />
+ <service name="BHelloWorldServiceRemoteService">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceRemotePromotion"/>
+ </service>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/HelloWorldComponent.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/HelloWorldComponent.composite
new file mode 100644
index 0000000000..0393280625
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/HelloWorldComponent.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorldComponent">
+
+ <service name="BHelloWorldServiceRemoteService"
+ promote="BHelloWorldServiceRemoteComponent/HelloWorldServiceRemote"/>
+
+ <component name="BHelloWorldServiceRemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl"/>
+ </component>
+
+ <component name="BHelloWorldServiceLocalAndRemoteNested">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/promotionService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleReference/HelloWorld.composite
new file mode 100644
index 0000000000..f4d2789ff7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleReference/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- local only wire -->
+ <component name="AHelloWorldClientLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientLocalImpl"/>
+ <reference name="helloWorldService" target="AHelloWorldServiceLocal" />
+ </component>
+
+ <component name="AHelloWorldServiceLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceLocalImpl" />
+ </component>
+
+ <!-- unresolved remote wire -->
+ <component name="AHelloWorldClientRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceRemote" />
+ </component>
+
+ <!-- local and remote wires -->
+ <component name="AHelloWorldClientLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceLocalAndRemote"/>
+ </component>
+
+ <!-- multiple services -->
+ <component name="AHelloWorldClientMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceRemote"/>
+ </component>
+
+ <component name="AHelloWorldClientMultipleServices2">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemote2Impl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceRemote2"/>
+ </component>
+
+ <!-- multiple bindings -->
+ <component name="AHelloWorldClientMultipleBindings">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldMultipleBindings/HelloWorldServiceRemote/scaBinding">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleService/HelloWorld.composite
new file mode 100644
index 0000000000..7e6311a22d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleService/HelloWorld.composite
@@ -0,0 +1,84 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- local only wire -->
+
+
+ <!-- unresolved remote wire -->
+ <component name="BHelloWorldServiceRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceRemote"/>
+ </service>
+ </component>
+
+ <!-- local and remote wires -->
+ <component name="BHelloWorldServiceLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceLocalAndRemote"/>
+ </service>
+ </component>
+
+ <component name="BHelloWorldClientLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceLocalAndRemote" />
+ </component>
+
+ <!-- multiple services -->
+ <component name="BHelloWorldServiceMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceMultipleServicesImpl" />
+ <service name="HelloWorldServiceLocal">
+ </service>
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceMultipleServices/HelloWorldServiceRemote"/>
+ </service>
+ <service name="HelloWorldServiceRemote2">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceMultipleServices/HelloWorldServiceRemote2"/>
+ </service>
+ </component>
+
+ <component name="BHelloWorldClientMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientLocalImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceLocal" />
+ </component>
+
+ <!-- multiple bindings -->
+ <component name="BHelloWorldMultipleBindings">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote" />
+ <binding.ws name="wsBinding" uri="http://localhost:8085/BHelloWorldMultipleBindings/HelloWorldServiceRemote-wsbinding"/>
+ <binding.sca name="scaBinding" uri="http://localhost:8085/BHelloWorldMultipleBindings/HelloWorldServiceRemote-scabinding"/>
+ </service>
+ </component>
+
+
+ <!-- Dynamic interfaces -->
+ <!--component name="BHelloWorldServiceScript">
+ <implementation.script script="calculator/AddServiceImpl.js"/>
+ </component-->
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-hazelcast/src/test/resources/ws/simpleService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/pom.xml
new file mode 100644
index 0000000000..0cfb13dd46
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-binding-sca-tribes</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes binding.sca Using Tribes Registry</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java
new file mode 100644
index 0000000000..ef2565b750
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+/**
+ *
+ */
+public interface Client {
+ String getName(String id);
+
+ String create(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java
new file mode 100644
index 0000000000..96a0f2dadd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.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.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Client.class)
+public class ClientImpl implements Client {
+ @Reference
+ protected Local local;
+
+ @Reference
+ protected Remote remote;
+
+ public String getName(String id) {
+ Customer customer = null;
+ try {
+ customer = remote.getCustomer(id);
+ } catch (CustomerNotFoundException e) {
+ return null;
+ }
+ customer.dump("Client.getName()");
+ return local.getName(customer);
+ }
+
+ public String create(String name) {
+ String id = remote.generateId();
+ Customer customer = remote.createCustomer(id, name);
+ customer.dump("Client.create()");
+ return remote.getId(customer);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java
new file mode 100644
index 0000000000..f2b7b1e41d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.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.itest.bindingsca;
+
+/**
+ *
+ */
+public class Customer {
+ private String id;
+ private String name;
+
+ public Customer() {
+ }
+
+ /**
+ * @param id
+ * @param name
+ */
+ public Customer(String id, String name) {
+ super();
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "Customer [id=" + id + ", name=" + name + "]";
+ }
+
+ public void dump(String prefix) {
+ System.out.print(prefix);
+ System.out.print(": ");
+ System.out.print(toString());
+ System.out.println(" @" + System.identityHashCode(this));
+ System.out.println(getClass().getClassLoader());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java
new file mode 100644
index 0000000000..a6e80c9eca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/CustomerNotFoundException.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+/**
+ *
+ */
+public class CustomerNotFoundException extends Exception {
+ private String customerId;
+
+ /**
+ *
+ */
+ public CustomerNotFoundException() {
+ }
+
+ /**
+ * @param message
+ */
+ public CustomerNotFoundException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public CustomerNotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public CustomerNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public String getCustomerId() {
+ return customerId;
+ }
+
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java
new file mode 100644
index 0000000000..0fe30c9d53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.bindingsca;
+
+/**
+ *
+ */
+public interface Local {
+ String getName(Customer customer);
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java
new file mode 100644
index 0000000000..8783808334
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.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 org.apache.tuscany.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Local.class)
+public class LocalServiceImpl implements Local {
+
+ public String getName(Customer customer) {
+ if (customer == null) {
+ return null;
+ }
+ customer.dump("Local.getName()");
+ return customer.getName();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java
new file mode 100644
index 0000000000..050d35007b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.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 org.apache.tuscany.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface Remote {
+ String generateId();
+
+ String getId(Customer customer);
+
+ Customer getCustomer(String id) throws CustomerNotFoundException;
+
+ Customer createCustomer(String id, String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java
new file mode 100644
index 0000000000..6c432a500a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Remote.class)
+@Scope("COMPOSITE")
+public class RemoteServiceImpl implements Remote {
+ private Map<String, Customer> customers = new HashMap<String, Customer>();
+
+ public String generateId() {
+ return UUID.randomUUID().toString();
+ }
+
+ @AllowsPassByReference
+ public String getId(Customer customer) {
+ customer.dump("Remote.getId()");
+ return customer.getId();
+ }
+
+ public Customer getCustomer(String id) throws CustomerNotFoundException {
+ Customer customer = customers.get(id);
+ if (customer == null) {
+ CustomerNotFoundException ex = new CustomerNotFoundException("Customer not found");
+ ex.setCustomerId(id);
+ throw ex;
+ }
+ customer.dump("Remote.getCustomer()");
+ return customer;
+ }
+
+ public Customer createCustomer(String id, String name) {
+ Customer customer = new Customer(id, name);
+ customer.dump("Remote.createCustomer()");
+ customers.put(id, customer);
+ return customer;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java
new file mode 100644
index 0000000000..3573eea978
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.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.itest.bindingsca;
+
+import java.net.URI;
+
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ *
+ */
+public class SCAClientImpl implements Client {
+ private Local local;
+ private Remote remote;
+
+ public SCAClientImpl(String domainURI) throws Exception {
+ SCAClientFactory factory = SCAClientFactory.newInstance(URI.create(domainURI));
+ local = factory.getService(Local.class, "LocalComponent/Local");
+ remote = factory.getService(Remote.class, "RemoteComponent/Remote");
+ }
+
+ public String getName(String id) {
+ Customer customer = null;
+ try {
+ customer = remote.getCustomer(id);
+ } catch (CustomerNotFoundException e) {
+ return null;
+ }
+ customer.dump("Client.getName()");
+ return local.getName(customer);
+ }
+
+ public String create(String name) {
+ String id = remote.generateId();
+ Customer customer = remote.createCustomer(id, name);
+ customer.dump("Client.create()");
+ return remote.getId(customer);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite
new file mode 100644
index 0000000000..b04cc33023
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite
@@ -0,0 +1,30 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://client"
+ name="Client">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.ClientImpl" />
+ <reference name="local" target="LocalComponent" />
+ <reference name="remote" target="RemoteComponent" />
+ </component>
+
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite
new file mode 100644
index 0000000000..fe282d291c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://service"
+ name="Service">
+
+ <component name="LocalComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.LocalServiceImpl" />
+ </component>
+
+ <component name="RemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.RemoteServiceImpl" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java
new file mode 100644
index 0000000000..9efa1a99ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.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.sca.axis2;
+
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientCallbackOnewayRemoteImpl;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+// @Ignore("TUSCANY-3138")
+public class AsynchTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("asynch", "./target/test-classes/ws/asynchReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("asynch", "./target/test-classes/ws/asynchService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ @Test
+ public void testHelloWorldAsynch() throws Exception {
+ HelloWorldClient helloWorldClientB;
+ helloWorldClientB = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ helloWorldClientB.getGreetings("fred");
+ System.out.println("Sleeping ...");
+ Thread.sleep(2000);
+ System.out.println("... Done");
+ Assert.assertEquals("callback fred", HelloWorldClientCallbackOnewayRemoteImpl.result );
+
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java
new file mode 100644
index 0000000000..efa84e92a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.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.binding.sca.axis2;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+// @Ignore("TUSCANY-3138")
+public class CallbackTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/ws/callbackReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/ws/callbackService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ //@Test
+ public void testKeepServerRunning() throws Exception {
+ System.out.println("press enter to continue");
+ System.in.read();
+ }
+
+ @Test
+ public void testHelloWorldCallbackLocal() throws Exception {
+ HelloWorldClient helloWorldClientB;
+ helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientCallbackLocal");
+ Assert.assertEquals("Hello callback fred", helloWorldClientB.getGreetings("fred"));
+ }
+
+ @Test
+ public void testHelloWorldCallbackRemote() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ Assert.assertEquals("Hello callback fred", helloWorldClientA.getGreetings("fred"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java
new file mode 100644
index 0000000000..45d28140b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.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.sca.binding.sca.axis2;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class PromotionTestCase {
+
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/ws/promotionReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/ws/promotionService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ @Test
+ @Ignore
+ public void testHelloWorldPromotion() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemotePromotion");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java
new file mode 100644
index 0000000000..a5d6529895
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.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.sca.binding.sca.axis2;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+public class SimpleTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/ws/simpleReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/ws/simpleService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ @Test
+ public void testHelloWorldLocal() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocal");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+ @Test
+ public void testHelloWorldRemote() throws Exception {
+
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemote");
+
+ try {
+ helloWorldClientA.getGreetings("fred");
+ } catch (ServiceUnavailableException ex){
+ Assert.fail();
+ }
+ }
+
+ @Test
+ public void testHelloWorldLocalAndRemote() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocalAndRemote");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientLocalAndRemote");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
+ }
+
+ @Test
+ public void testHelloWorldMultipleServices() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices");
+ HelloWorldClient helloWorldClientA2 = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices2");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientMultipleServices");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientA2.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
+ }
+
+ @Test
+ public void testHelloWorldMultipleBindings() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleBindings");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java
new file mode 100644
index 0000000000..f7ab3dfe98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.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.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+public interface HelloWorldCallbackRemote {
+
+ String getGreetingsCallbackRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..3d25d37708
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2.helloworld;
+
+
+public interface HelloWorldClient {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java
new file mode 100644
index 0000000000..a469d197d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallbackRemote.class)
+public interface HelloWorldServiceCallbackOnewayRemote {
+
+ @OneWay
+ void getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java
new file mode 100644
index 0000000000..3f5a21fddd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.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.sca.binding.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallbackRemote.class)
+public interface HelloWorldServiceCallbackRemote {
+
+ String getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java
new file mode 100644
index 0000000000..49e5232b31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2.helloworld;
+
+
+public interface HelloWorldServiceLocal {
+
+ String getGreetingsLocal(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java
new file mode 100644
index 0000000000..ccc77c142b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldServiceRemote {
+
+ String getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java
new file mode 100644
index 0000000000..c2be798d1a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldServiceRemote2 {
+
+ String getGreetingsRemote2(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..9355aece1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceCallbackOnewayRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientCallbackOnewayRemoteImpl implements HelloWorldClient {
+
+ public static String result;
+
+ @Reference
+ public HelloWorldServiceCallbackOnewayRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ helloWorldService.getGreetingsRemote(s);
+ return null;
+ }
+
+ public String getGreetingsCallbackRemote(String s) {
+ result = "callback " + s;
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
new file mode 100644
index 0000000000..efc47aa94d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceCallbackRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientCallbackRemoteImpl implements HelloWorldClient {
+
+ public static String result;
+
+ @Reference
+ public HelloWorldServiceCallbackRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote(s);
+ }
+
+ public String getGreetingsCallbackRemote(String s) {
+ result = "callback " + s;
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java
new file mode 100644
index 0000000000..6ed813ff0a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.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 org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceLocal;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientLocalImpl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceLocal helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsLocal(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java
new file mode 100644
index 0000000000..ba70573efb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.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 org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote2;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientRemote2Impl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceRemote2 helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote2(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java
new file mode 100644
index 0000000000..a87d6eb49a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.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 org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientRemoteImpl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..3dc0b12b82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.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 org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldCallbackRemote;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceCallbackOnewayRemote;
+import org.oasisopen.sca.annotation.Callback;
+
+public class HelloWorldServiceCallbackOnewayRemoteImpl implements HelloWorldServiceCallbackOnewayRemote {
+
+ @Callback
+ protected HelloWorldCallbackRemote theCallback;
+
+ public void getGreetingsRemote(String s) {
+ theCallback.getGreetingsCallbackRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java
new file mode 100644
index 0000000000..b15d6dea80
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.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.sca.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldCallbackRemote;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceCallbackRemote;
+import org.oasisopen.sca.annotation.Callback;
+
+public class HelloWorldServiceCallbackRemoteImpl implements HelloWorldServiceCallbackRemote {
+
+ @Callback
+ protected HelloWorldCallbackRemote theCallback;
+
+ public HelloWorldServiceCallbackRemoteImpl() {
+ System.out.println("Constructor");
+ }
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + theCallback.getGreetingsCallbackRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java
new file mode 100644
index 0000000000..c4347b084a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.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.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceLocal;
+
+public class HelloWorldServiceLocalImpl implements HelloWorldServiceLocal {
+
+ public String getGreetingsLocal(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java
new file mode 100644
index 0000000000..846bff02e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.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.binding.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceLocal;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote;
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote2;
+import org.oasisopen.sca.annotation.Service;
+
+@Service({HelloWorldServiceRemote.class, HelloWorldServiceRemote2.class, HelloWorldServiceLocal.class} )
+public class HelloWorldServiceMultipleServicesImpl implements HelloWorldServiceLocal, HelloWorldServiceRemote, HelloWorldServiceRemote2 {
+
+ public String getGreetingsLocal(String s) {
+ return "Hello " + s;
+ }
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + s;
+ }
+
+ public String getGreetingsRemote2(String s) {
+ return "Hello " + s;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java
new file mode 100644
index 0000000000..d69f442879
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.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.sca.axis2.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote;
+
+public class HelloWorldServiceRemoteImpl implements HelloWorldServiceRemote {
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/AsynchTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/AsynchTestCase.java
new file mode 100644
index 0000000000..cbcc06056a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/AsynchTestCase.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.sca.rmi;
+
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientCallbackOnewayRemoteImpl;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class AsynchTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+ // System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding", RMIBinding.TYPE.toString());
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("asynch", "./target/test-classes/rmi/asynchReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("asynch", "./target/test-classes/rmi/asynchService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ // System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+ }
+
+ @Test
+ public void testHelloWorldAsynch() throws Exception {
+ HelloWorldClient helloWorldClientB;
+ helloWorldClientB = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ helloWorldClientB.getGreetings("fred");
+ System.out.println("Sleeping ...");
+ Thread.sleep(2000);
+ System.out.println("... Done");
+ Assert.assertEquals("callback fred", HelloWorldClientCallbackOnewayRemoteImpl.result );
+
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/CallbackTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/CallbackTestCase.java
new file mode 100644
index 0000000000..dccd2dace8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/CallbackTestCase.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.rmi;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CallbackTestCase {
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+ // System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding", RMIBinding.TYPE.toString());
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/rmi/callbackReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/rmi/callbackService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ // System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+ }
+
+ //@Test
+ public void testKeepServerRunning() throws Exception {
+ System.out.println("press enter to continue");
+ System.in.read();
+ }
+
+ @Test
+ public void testHelloWorldCallbackLocal() throws Exception {
+ HelloWorldClient helloWorldClientB;
+ helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientCallbackLocal");
+ Assert.assertEquals("Hello callback fred", helloWorldClientB.getGreetings("fred"));
+ }
+
+ @Test
+ public void testHelloWorldCallbackRemote() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ Assert.assertEquals("Hello callback fred", helloWorldClientA.getGreetings("fred"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/PromotionTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/PromotionTestCase.java
new file mode 100644
index 0000000000..7aac95a8ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/PromotionTestCase.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.sca.binding.sca.rmi;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class PromotionTestCase {
+
+
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+ System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding",
+ "{http://tuscany.apache.org/xmlns/sca/1.1}binding.rmi");
+
+ try {
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/rmi/promotionReference");
+ nodeA = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/rmi/promotionService");
+ nodeB = NodeFactory.getInstance().createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+
+ }
+
+ @Test
+ public void testHelloWorldPromotion() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemotePromotion");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/SimpleTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/SimpleTestCase.java
new file mode 100644
index 0000000000..f748beb6cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/SimpleTestCase.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.sca.binding.sca.rmi;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+public class SimpleTestCase {
+
+ private static NodeFactory factory;
+ public static Node nodeA;
+ public static Node nodeB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up nodes");
+ System.setProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding",
+ "{http://tuscany.apache.org/xmlns/sca/1.1}binding.rmi");
+
+ try {
+ factory = NodeFactory.getInstance();
+ // create and start nodes
+ Contribution contrib = new Contribution("reference", "./target/test-classes/rmi/simpleReference");
+ nodeA = factory.createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/rmi/simpleService");
+ nodeB = factory.createNode("HelloWorld.composite", contrib);
+ nodeB.start();
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ nodeA.stop();
+ nodeB.stop();
+ factory.destroy();
+ System.clearProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+ }
+
+ @Test
+ public void testHelloWorldLocal() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocal");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+ @Test
+ public void testHelloWorldRemote() throws Exception {
+
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemote");
+
+ try {
+ helloWorldClientA.getGreetings("fred");
+ } catch (ServiceUnavailableException ex){
+ Assert.fail();
+ }
+ }
+
+ @Test
+ public void testHelloWorldLocalAndRemote() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocalAndRemote");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientLocalAndRemote");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
+ }
+
+ @Test
+ public void testHelloWorldMultipleServices() throws Exception {
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices");
+ HelloWorldClient helloWorldClientA2 = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices2");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientMultipleServices");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientA2.getGreetings("fred"), "Hello fred");
+ Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
+ }
+
+ @Test
+ public void testHelloWorldMultipleBindings() throws Exception {
+ HelloWorldClient helloWorldClientA;
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleBindings");
+ Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldCallbackRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldCallbackRemote.java
new file mode 100644
index 0000000000..7c4cf4b0b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldCallbackRemote.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.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+public interface HelloWorldCallbackRemote {
+
+ String getGreetingsCallbackRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..017acee582
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldClient.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.rmi.helloworld;
+
+
+public interface HelloWorldClient {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackOnewayRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackOnewayRemote.java
new file mode 100644
index 0000000000..86f984e61a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackOnewayRemote.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallbackRemote.class)
+public interface HelloWorldServiceCallbackOnewayRemote {
+
+ @OneWay
+ void getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackRemote.java
new file mode 100644
index 0000000000..8e19fd7382
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceCallbackRemote.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.sca.binding.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallbackRemote.class)
+public interface HelloWorldServiceCallbackRemote {
+
+ String getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceLocal.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceLocal.java
new file mode 100644
index 0000000000..b0d623e2e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceLocal.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.rmi.helloworld;
+
+
+public interface HelloWorldServiceLocal {
+
+ String getGreetingsLocal(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote.java
new file mode 100644
index 0000000000..ccb44694d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldServiceRemote {
+
+ String getGreetingsRemote(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote2.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote2.java
new file mode 100644
index 0000000000..5c8bb13f43
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/HelloWorldServiceRemote2.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.rmi.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldServiceRemote2 {
+
+ String getGreetingsRemote2(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..1ff1792bb7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceCallbackOnewayRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientCallbackOnewayRemoteImpl implements HelloWorldClient {
+
+ public static String result;
+
+ @Reference
+ public HelloWorldServiceCallbackOnewayRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ helloWorldService.getGreetingsRemote(s);
+ return null;
+ }
+
+ public String getGreetingsCallbackRemote(String s) {
+ result = "callback " + s;
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
new file mode 100644
index 0000000000..b17d8e2016
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceCallbackRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientCallbackRemoteImpl implements HelloWorldClient {
+
+ public static String result;
+
+ @Reference
+ public HelloWorldServiceCallbackRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote(s);
+ }
+
+ public String getGreetingsCallbackRemote(String s) {
+ result = "callback " + s;
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientLocalImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientLocalImpl.java
new file mode 100644
index 0000000000..e230326f5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientLocalImpl.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 org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceLocal;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientLocalImpl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceLocal helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsLocal(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemote2Impl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemote2Impl.java
new file mode 100644
index 0000000000..77df8c2c39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemote2Impl.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 org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote2;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientRemote2Impl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceRemote2 helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote2(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemoteImpl.java
new file mode 100644
index 0000000000..8effa3ac36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldClientRemoteImpl.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 org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClientRemoteImpl implements HelloWorldClient {
+
+ @Reference
+ public HelloWorldServiceRemote helloWorldService;
+
+ public String getGreetings(String s) {
+ return helloWorldService.getGreetingsRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..2467ddab88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.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 org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldCallbackRemote;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceCallbackOnewayRemote;
+import org.oasisopen.sca.annotation.Callback;
+
+public class HelloWorldServiceCallbackOnewayRemoteImpl implements HelloWorldServiceCallbackOnewayRemote {
+
+ @Callback
+ protected HelloWorldCallbackRemote theCallback;
+
+ public void getGreetingsRemote(String s) {
+ theCallback.getGreetingsCallbackRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java
new file mode 100644
index 0000000000..d1b75d0a2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.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.sca.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldCallbackRemote;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceCallbackRemote;
+import org.oasisopen.sca.annotation.Callback;
+
+public class HelloWorldServiceCallbackRemoteImpl implements HelloWorldServiceCallbackRemote {
+
+ @Callback
+ protected HelloWorldCallbackRemote theCallback;
+
+ public HelloWorldServiceCallbackRemoteImpl() {
+ System.out.println("Constructor");
+ }
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + theCallback.getGreetingsCallbackRemote(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceLocalImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceLocalImpl.java
new file mode 100644
index 0000000000..44e7efc668
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceLocalImpl.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.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceLocal;
+
+public class HelloWorldServiceLocalImpl implements HelloWorldServiceLocal {
+
+ public String getGreetingsLocal(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java
new file mode 100644
index 0000000000..88440de023
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceMultipleServicesImpl.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.binding.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceLocal;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote;
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote2;
+import org.oasisopen.sca.annotation.Service;
+
+@Service({HelloWorldServiceRemote.class, HelloWorldServiceRemote2.class, HelloWorldServiceLocal.class} )
+public class HelloWorldServiceMultipleServicesImpl implements HelloWorldServiceLocal, HelloWorldServiceRemote, HelloWorldServiceRemote2 {
+
+ public String getGreetingsLocal(String s) {
+ return "Hello " + s;
+ }
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + s;
+ }
+
+ public String getGreetingsRemote2(String s) {
+ return "Hello " + s;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceRemoteImpl.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceRemoteImpl.java
new file mode 100644
index 0000000000..06dc2c3f79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/binding/sca/rmi/helloworld/impl/HelloWorldServiceRemoteImpl.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.sca.rmi.helloworld.impl;
+
+import org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote;
+
+public class HelloWorldServiceRemoteImpl implements HelloWorldServiceRemote {
+
+ public String getGreetingsRemote(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
new file mode 100644
index 0000000000..05a8c3455c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Test binding.sca in the same classloader
+ */
+public class BindingSCATestCase {
+ static final String DOMAIN_URI = "my-domain";
+ private static final String REGISTRY_URI = "tribes://228.0.0.100:50000";
+ private static final String PKG = "org/apache/tuscany/sca/itest/bindingsca/";
+ private static final String CLIENT = "Client.composite";
+ private static final String SERVICE = "Service.composite";
+ private static final String ROOT = new File("target/classes/" + PKG).toURI().toString();
+
+ /**
+ * One NodeFactory and two nodes
+ */
+ @Test
+ public void testOneFactoryTwoNodes() {
+ NodeFactory factory1 = NodeFactory.getInstance();
+ Node node1 = createClientNode(factory1);
+ Node node2 = createServiceNode(factory1);
+ node1.start();
+ node2.start();
+ try {
+ runClient(node1);
+ } finally {
+ node2.stop();
+ node1.stop();
+ factory1.destroy();
+ }
+ }
+
+ /**
+ * Create the service node
+ * @param factory
+ * @return
+ */
+ static Node createServiceNode(NodeFactory factory) {
+ NodeConfiguration config2 =
+ factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node2").addContribution("c2", ROOT)
+ .addDeploymentComposite("c2", SERVICE).setDomainRegistryURI(REGISTRY_URI)
+ .addBinding(WebServiceBinding.TYPE, "http://localhost:8085/").addBinding(SCABinding.TYPE,
+ "http://localhost:8085/");
+
+ Node node2 = factory.createNode(config2);
+ return node2;
+ }
+
+ /**
+ * Create the client node
+ * @param factory
+ * @return
+ */
+ static Node createClientNode(NodeFactory factory) {
+ NodeConfiguration config1 =
+ factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node1").addContribution("c1", ROOT)
+ .addDeploymentComposite("c1", CLIENT).setDomainRegistryURI(REGISTRY_URI)
+ .addBinding(WebServiceBinding.TYPE, "http://localhost:8085/").addBinding(SCABinding.TYPE,
+ "http://localhost:8085/");
+ Node node1 = factory.createNode(config1);
+ return node1;
+ }
+
+ /**
+ * Two node factories and two nodes
+ */
+ @Test
+ public void testTwoFactoriesTwoNodes() throws Exception {
+ NodeFactory factory1 = NodeFactory.newInstance();
+ Node node1 = createClientNode(factory1);
+ NodeFactory factory2 = NodeFactory.newInstance();
+ Node node2 = createServiceNode(factory2);
+ node1.start();
+ node2.start();
+ Thread.sleep(1000);
+ try {
+ // This call doesn't require the Local service, it should be successful
+ createCustomer(node1);
+ try {
+ runClient(node1);
+ // We cannot make local call to remote endpoints
+ Assert.fail("ServiceRuntimeException should have been thrown.");
+ } catch (ServiceRuntimeException e) {
+ // ignore
+ }
+ } finally {
+ node2.stop();
+ node1.stop();
+ factory2.destroy();
+ factory1.destroy();
+ }
+ }
+
+ /**
+ * Run the client
+ * @param node
+ */
+ static void runClient(Node node) {
+ Client client = node.getService(Client.class, "ClientComponent/Client");
+ runClient(client);
+ }
+
+ static void runClient(Client client) {
+ String id = client.create("Ray");
+ Assert.assertEquals("Ray", client.getName(id));
+ }
+
+ static void runClientNotFound(Client client) {
+ String id = "not-there";
+ Assert.assertNull(client.getName(id));
+ }
+
+ static String createCustomer(Node node) {
+ Client client = node.getService(Client.class, "ClientComponent/Client");
+ String id = client.create("John");
+ Assert.assertNotNull(id);
+ return id;
+ }
+
+ /**
+ * One node factory and one node for both composites
+ */
+ @Test
+ public void testOneFactoryOneNode() {
+ NodeFactory factory = NodeFactory.getInstance();
+ NodeConfiguration config1 =
+ factory.createNodeConfiguration().setDomainURI(DOMAIN_URI).setURI("node1").addContribution("c1", ROOT)
+ .addDeploymentComposite("c1", CLIENT).addDeploymentComposite("c1", SERVICE);
+
+ Node node1 = factory.createNode(config1);
+ node1.start();
+ try {
+ runClient(node1);
+ } finally {
+ node1.stop();
+ factory.destroy();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
new file mode 100644
index 0000000000..7255697d4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.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.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client node and service node with two different classloaders that share the Customer class
+ */
+public class ClientNodeSharedCustomerTestCase {
+ private static Node clientNode;
+ private static TestCaseRunner runner;
+ private static NodeFactory factory;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner = new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName());
+ runner.beforeClass();
+ factory = NodeFactory.getInstance();
+ clientNode = BindingSCATestCase.createClientNode(factory).start();
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(clientNode);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (runner != null) {
+ runner.afterClass();
+ }
+ if (factory != null) {
+ factory.destroy();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
new file mode 100644
index 0000000000..51fafae32c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.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.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client node and service node with two different classloaders that share the Local class
+ * (but not Customer)
+ */
+public class ClientNodeSharedLocalTestCase {
+ private static Node clientNode;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner =
+ new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName(),
+ Customer.class.getName());
+ runner.beforeClass();
+ NodeFactory factory = NodeFactory.getInstance();
+ clientNode = BindingSCATestCase.createClientNode(factory).start();
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(clientNode);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (runner != null) {
+ runner.afterClass();
+ }
+ NodeFactory.getInstance().destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
new file mode 100644
index 0000000000..b8ff0c58ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.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.sca.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client api and service node with two different classloaders that share the Customer class
+ */
+public class ClientSharedCustomerTestCase {
+ private static Client client;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner = new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName());
+ runner.beforeClass();
+ client = new SCAClientImpl(BindingSCATestCase.DOMAIN_URI);
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(client);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (runner != null) {
+ runner.afterClass();
+ }
+ NodeFactory.getInstance().destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
new file mode 100644
index 0000000000..633e1a767c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.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.sca.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Running the client api and service node with two different classloaders that share the Local class
+ * (but not Customer)
+ */
+public class ClientSharedLocalTestCase {
+ private static Client client;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner =
+ new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName(),
+ Customer.class.getName(), CustomerNotFoundException.class.getName());
+ runner.beforeClass();
+ client = new SCAClientImpl(BindingSCATestCase.DOMAIN_URI);
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ BindingSCATestCase.runClient(client);
+ }
+
+ @Test
+ public void testClientNotFound() throws Exception {
+ BindingSCATestCase.runClientNotFound(client);
+ }
+
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (runner != null) {
+ runner.afterClass();
+ }
+ NodeFactory.getInstance().destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ServiceNode.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ServiceNode.java
new file mode 100644
index 0000000000..1cba2b57c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ServiceNode.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.bindingsca;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class ServiceNode {
+ private static Node serviceNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ /* System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled",
+ "false");
+ */
+ NodeFactory factory = NodeFactory.getInstance();
+ serviceNode = BindingSCATestCase.createServiceNode(factory).start();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/TestCaseRunner.java b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/TestCaseRunner.java
new file mode 100644
index 0000000000..c0960ffe95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/TestCaseRunner.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.bindingsca;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A helper class that can be used to run an SCA JUnit test case. The test case will run in an isolated class loader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestCaseRunner {
+
+ private ClassLoader classLoader;
+ private Class<?> testSuiteClass;
+ private Object testSuite;
+ private Class<?> testResultClass;
+ private Class<?> testCaseClass;
+ private Object testCase;
+
+ private Class<?> beforeAnnotation;
+ private Class<?> beforeClassAnnotation;
+ private Class<?> afterAnnotation;
+ private Class<?> afterClassAnnotation;
+ private Class<?> junit4AdapterClass;
+ private Class<?> junit3TestCaseClass;
+
+ /**
+ * Constructs a new TestCase runner.
+ *
+ * @param testClass
+ */
+ public TestCaseRunner(Class<?> testClass, String... isolatedClasses) {
+ try {
+ ClassLoader tccl = setupClassLoader(testClass, isolatedClasses);
+
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ testCaseClass = Class.forName(testClass.getName(), true, classLoader);
+ testCase = testCaseClass.newInstance();
+ ClassLoader testClassLoader = testCaseClass.getClassLoader();
+
+ junit3TestCaseClass = Class.forName("junit.framework.TestCase", true, testClassLoader);
+
+ testSuiteClass = Class.forName("junit.framework.TestSuite", true, testClassLoader);
+ Constructor<?> testSuiteConstructor = testSuiteClass.getConstructor(Class.class);
+ testSuite = testSuiteConstructor.newInstance(testCaseClass);
+
+ testResultClass = Class.forName("junit.framework.TestResult", true, testClassLoader);
+
+ try {
+ beforeAnnotation = Class.forName("org.junit.Before", true, testClassLoader);
+ afterAnnotation = Class.forName("org.junit.After", true, testClassLoader);
+ beforeClassAnnotation = Class.forName("org.junit.BeforeClass", true, testClassLoader);
+ afterClassAnnotation = Class.forName("org.junit.AfterClass", true, testClassLoader);
+ junit4AdapterClass = Class.forName("junit.framework.JUnit4TestAdapter", true, testClassLoader);
+ } catch (Exception e) {
+ // Unexpected
+ throw new AssertionError(e);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ClassLoader setupClassLoader(Class<?> testClass, String... isolatedClasses) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ classLoader = testClass.getClassLoader();
+ if (classLoader instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader)classLoader).getURLs();
+ classLoader = new ClassLoaderImpl(urls, classLoader, isolatedClasses);
+ } else if (classLoader == tccl || classLoader.getParent() == tccl) {
+ classLoader = new URLClassLoader(new URL[0], classLoader);
+ } else {
+ classLoader = tccl;
+ }
+ return tccl;
+ }
+
+ /**
+ * Run the test case
+ */
+ public void run() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ if (junit3TestCaseClass.isAssignableFrom(testCaseClass)) {
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = testSuiteClass.getMethod("run", testResultClass);
+ runMethod.invoke(testSuite, testResult);
+ } else {
+ Object junit4Adapter = junit4AdapterClass.getConstructor(Class.class).newInstance(testCaseClass);
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = junit4AdapterClass.getMethod("run", testResultClass);
+ runMethod.invoke(junit4Adapter, testResult);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Invoke the setUp method
+ */
+ public void setUp() {
+ execute("setUp");
+ }
+
+ /**
+ * Invoke the before methods
+ */
+ public void before() {
+ execute(beforeAnnotation);
+ }
+
+ /**
+ * Invoke the beforeClass methods
+ */
+ public void beforeClass() {
+ execute(beforeClassAnnotation);
+ }
+
+ /**
+ * Invoke the tearDown method
+ */
+ public void tearDown() {
+ execute("tearDown");
+ }
+
+ /**
+ * Invoke the after methods
+ */
+ public void after() {
+ execute(afterAnnotation);
+ }
+
+ /**
+ * Invoke the afterClass methods
+ */
+ public void afterClass() {
+ execute(afterClassAnnotation);
+ }
+
+ /**
+ * Invoke the specified test method.
+ */
+ public void run(String methodName) {
+ execute(methodName);
+ }
+
+ /**
+ * Invoke the methods annotated with the specified annotation.
+ */
+ private void execute(Class<?> annotationClass) {
+ if (annotationClass == null) {
+ throw new RuntimeException(new NoSuchMethodException());
+ }
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ for (Method method : testCaseClass.getDeclaredMethods()) {
+ for (Annotation annotation : method.getAnnotations()) {
+ if (annotation.annotationType() == annotationClass) {
+ method.invoke(testCase);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Invoke the specified method
+ */
+ private void execute(String methodName) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+ Method setUpMethod = testCaseClass.getDeclaredMethod(methodName);
+ setUpMethod.setAccessible(true);
+ setUpMethod.invoke(testCase);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ public static class ClassLoaderImpl extends URLClassLoader {
+ private Set<String> isolatedClasses = new HashSet<String>();
+
+ /**
+ * @param urls
+ * @param parent
+ */
+ public ClassLoaderImpl(URL[] urls, ClassLoader parent, String... sharedClasses) {
+ super(urls, parent);
+ this.isolatedClasses.addAll(Arrays.asList(sharedClasses));
+ }
+
+ @Override
+ protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ if (!isolatedClasses.contains(name)) {
+ return super.loadClass(name, resolve);
+ } else {
+ Class<?> cls = findLoadedClass(name);
+ if (cls == null) {
+ cls = findClass(name);
+ }
+ if (resolve) {
+ resolveClass(cls);
+ }
+ return cls;
+ }
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchReference/HelloWorld.composite
new file mode 100644
index 0000000000..8c825ca805
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchReference/HelloWorld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+ <!-- callback remote wire -->
+ <component name="AHelloWorldClientCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientCallbackOnewayRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote">
+ <binding.sca/>
+ <callback>
+ <binding.sca uri="http://localhost:8084/AHelloWorldClientCallbackRemote"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchService/HelloWorld.composite
new file mode 100644
index 0000000000..79b1a5d794
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchService/HelloWorld.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- callback remote wire -->
+ <component name="BHelloWorldServiceCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceCallbackOnewayRemoteImpl" />
+ <service name="HelloWorldServiceCallbackOnewayRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceCallbackRemote"/>
+ <callback>
+ <binding.sca/>
+ </callback>
+ </service>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/asynchService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackReference/HelloWorld.composite
new file mode 100644
index 0000000000..e8924d2728
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackReference/HelloWorld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+ <!-- callback remote wire -->
+ <component name="AHelloWorldClientCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientCallbackRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote">
+ <binding.sca/>
+ <callback>
+ <binding.sca uri="http://localhost:8084/AHelloWorldClientCallbackRemote"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackService/HelloWorld.composite
new file mode 100644
index 0000000000..4edc8df5cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackService/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- callback remote wire -->
+ <component name="BHelloWorldServiceCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceCallbackRemoteImpl" />
+ <service name="HelloWorldServiceCallbackRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceCallbackRemote"/>
+ <callback>
+ <binding.sca/>
+ </callback>
+ </service>
+ </component>
+
+ <!-- callback local wire -->
+ <component name="BHelloWorldClientCallbackLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientCallbackRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/callbackService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/HelloWorld.composite
new file mode 100644
index 0000000000..823cab4f56
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/HelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- composite hierarchy -->
+ <component name="AHelloWorldClientRemotePromotion">
+ <implementation.composite name="sample:HelloWorldComponent" />
+ <reference name="AHelloWorldClientRemoteReference" target="BHelloWorldServiceRemotePromotion"/>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/HelloWorldComponent.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/HelloWorldComponent.composite
new file mode 100644
index 0000000000..54fb359ba0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/HelloWorldComponent.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorldComponent">
+
+ <service name="AHelloWorldClientRemoteService" promote="AHelloWorldClientRemoteComponent">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldClient"/>
+ </service>
+
+ <reference name="AHelloWorldClientRemoteReference" promote="AHelloWorldClientRemoteComponent/helloWorldService" multiplicity="1..1">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote"/>
+ </reference>
+
+ <component name="AHelloWorldClientRemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/HelloWorld.composite
new file mode 100644
index 0000000000..454e9c55cf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/HelloWorld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- composite hierarchy -->
+ <component name="BHelloWorldServiceRemotePromotion">
+ <implementation.composite name="sample:HelloWorldComponent" />
+ <service name="BHelloWorldServiceRemoteService">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceRemotePromotion"/>
+ </service>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/HelloWorldComponent.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/HelloWorldComponent.composite
new file mode 100644
index 0000000000..a313fb8f68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/HelloWorldComponent.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorldComponent">
+
+ <service name="BHelloWorldServiceRemoteService"
+ promote="BHelloWorldServiceRemoteComponent/HelloWorldServiceRemote"/>
+
+ <component name="BHelloWorldServiceRemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl"/>
+ </component>
+
+ <component name="BHelloWorldServiceLocalAndRemoteNested">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/promotionService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleReference/HelloWorld.composite
new file mode 100644
index 0000000000..4151749523
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleReference/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- local only wire -->
+ <component name="AHelloWorldClientLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientLocalImpl"/>
+ <reference name="helloWorldService" target="AHelloWorldServiceLocal" />
+ </component>
+
+ <component name="AHelloWorldServiceLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceLocalImpl" />
+ </component>
+
+ <!-- unresolved remote wire -->
+ <component name="AHelloWorldClientRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceRemote" />
+ </component>
+
+ <!-- local and remote wires -->
+ <component name="AHelloWorldClientLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceLocalAndRemote"/>
+ </component>
+
+ <!-- multiple services -->
+ <component name="AHelloWorldClientMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceRemote"/>
+ </component>
+
+ <component name="AHelloWorldClientMultipleServices2">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemote2Impl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceRemote2"/>
+ </component>
+
+ <!-- multiple bindings -->
+ <component name="AHelloWorldClientMultipleBindings">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldMultipleBindings/HelloWorldServiceRemote/scaBinding">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleService/HelloWorld.composite
new file mode 100644
index 0000000000..37af7625ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleService/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- local only wire -->
+
+
+ <!-- unresolved remote wire -->
+ <component name="BHelloWorldServiceRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceRemote"/>
+ </service>
+ </component>
+
+ <!-- local and remote wires -->
+ <component name="BHelloWorldServiceLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceLocalAndRemote"/>
+ </service>
+ </component>
+
+ <component name="BHelloWorldClientLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceLocalAndRemote" />
+ </component>
+
+ <!-- multiple services -->
+ <component name="BHelloWorldServiceMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceMultipleServicesImpl" />
+ <service name="HelloWorldServiceLocal">
+ </service>
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceMultipleServices/HelloWorldServiceRemote"/>
+ </service>
+ <service name="HelloWorldServiceRemote2">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceMultipleServices/HelloWorldServiceRemote2"/>
+ </service>
+ </component>
+
+ <component name="BHelloWorldClientMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldClientLocalImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceLocal" />
+ </component>
+
+ <!-- multiple bindings -->
+ <component name="BHelloWorldMultipleBindings">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.rmi.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.rmi.helloworld.HelloWorldServiceRemote" />
+ <!-- tuscany:binding.rmi name="rmiBinding" uri="http://localhost:8085/BHelloWorldMultipleBindings/HelloWorldServiceRemote-wsbinding"/ -->
+ <binding.sca name="scaBinding" uri="http://localhost:8085/BHelloWorldMultipleBindings/HelloWorldServiceRemote-scabinding"/>
+ </service>
+ </component>
+
+
+ <!-- Dynamic interfaces -->
+ <!--component name="BHelloWorldServiceScript">
+ <implementation.script script="calculator/AddServiceImpl.js"/>
+ </component-->
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ab75f7d225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/rmi/simpleService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchReference/HelloWorld.composite
new file mode 100644
index 0000000000..e797a0aa9c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchReference/HelloWorld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+ <!-- callback remote wire -->
+ <component name="AHelloWorldClientCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientCallbackOnewayRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote">
+ <binding.sca/>
+ <callback>
+ <binding.sca uri="http://localhost:8084/AHelloWorldClientCallbackRemote"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchService/HelloWorld.composite
new file mode 100644
index 0000000000..079ee49380
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchService/HelloWorld.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- callback remote wire -->
+ <component name="BHelloWorldServiceCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceCallbackOnewayRemoteImpl" />
+ <service name="HelloWorldServiceCallbackOnewayRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceCallbackRemote"/>
+ <callback>
+ <binding.sca/>
+ </callback>
+ </service>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/asynchService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackReference/HelloWorld.composite
new file mode 100644
index 0000000000..1d5630f3d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackReference/HelloWorld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+ <!-- callback remote wire -->
+ <component name="AHelloWorldClientCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientCallbackRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote">
+ <binding.sca/>
+ <callback>
+ <binding.sca uri="http://localhost:8084/AHelloWorldClientCallbackRemote"/>
+ </callback>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackService/HelloWorld.composite
new file mode 100644
index 0000000000..ded3766d49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackService/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- callback remote wire -->
+ <component name="BHelloWorldServiceCallbackRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceCallbackRemoteImpl" />
+ <service name="HelloWorldServiceCallbackRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceCallbackRemote"/>
+ <callback>
+ <binding.sca/>
+ </callback>
+ </service>
+ </component>
+
+ <!-- callback local wire -->
+ <component name="BHelloWorldClientCallbackLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientCallbackRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceCallbackRemote" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/callbackService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/HelloWorld.composite
new file mode 100644
index 0000000000..4513f21acf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/HelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- composite hierarchy -->
+ <component name="AHelloWorldClientRemotePromotion">
+ <implementation.composite name="sample:HelloWorldComponent" />
+ <reference name="AHelloWorldClientRemoteReference" target="BHelloWorldServiceRemotePromotion"/>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/HelloWorldComponent.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/HelloWorldComponent.composite
new file mode 100644
index 0000000000..22c20ff94a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/HelloWorldComponent.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorldComponent">
+
+ <service name="AHelloWorldClientRemoteService" promote="AHelloWorldClientRemoteComponent">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldClient"/>
+ </service>
+
+ <reference name="AHelloWorldClientRemoteReference" promote="AHelloWorldClientRemoteComponent/helloWorldService" multiplicity="1..1">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote"/>
+ </reference>
+
+ <component name="AHelloWorldClientRemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/HelloWorld.composite
new file mode 100644
index 0000000000..e6a7d776c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/HelloWorld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- composite hierarchy -->
+ <component name="BHelloWorldServiceRemotePromotion">
+ <implementation.composite name="sample:HelloWorldComponent" />
+ <service name="BHelloWorldServiceRemoteService">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceRemotePromotion"/>
+ </service>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/HelloWorldComponent.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/HelloWorldComponent.composite
new file mode 100644
index 0000000000..0393280625
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/HelloWorldComponent.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorldComponent">
+
+ <service name="BHelloWorldServiceRemoteService"
+ promote="BHelloWorldServiceRemoteComponent/HelloWorldServiceRemote"/>
+
+ <component name="BHelloWorldServiceRemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl"/>
+ </component>
+
+ <component name="BHelloWorldServiceLocalAndRemoteNested">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/promotionService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleReference/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleReference/HelloWorld.composite
new file mode 100644
index 0000000000..f4d2789ff7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleReference/HelloWorld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- local only wire -->
+ <component name="AHelloWorldClientLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientLocalImpl"/>
+ <reference name="helloWorldService" target="AHelloWorldServiceLocal" />
+ </component>
+
+ <component name="AHelloWorldServiceLocal">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceLocalImpl" />
+ </component>
+
+ <!-- unresolved remote wire -->
+ <component name="AHelloWorldClientRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceRemote" />
+ </component>
+
+ <!-- local and remote wires -->
+ <component name="AHelloWorldClientLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceLocalAndRemote"/>
+ </component>
+
+ <!-- multiple services -->
+ <component name="AHelloWorldClientMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceRemote"/>
+ </component>
+
+ <component name="AHelloWorldClientMultipleServices2">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemote2Impl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceRemote2"/>
+ </component>
+
+ <!-- multiple bindings -->
+ <component name="AHelloWorldClientMultipleBindings">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldMultipleBindings/HelloWorldServiceRemote/scaBinding">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleReference/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleReference/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleService/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleService/HelloWorld.composite
new file mode 100644
index 0000000000..7e6311a22d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleService/HelloWorld.composite
@@ -0,0 +1,84 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="HelloWorld">
+
+
+ <!-- local only wire -->
+
+
+ <!-- unresolved remote wire -->
+ <component name="BHelloWorldServiceRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceRemote"/>
+ </service>
+ </component>
+
+ <!-- local and remote wires -->
+ <component name="BHelloWorldServiceLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceLocalAndRemote"/>
+ </service>
+ </component>
+
+ <component name="BHelloWorldClientLocalAndRemote">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientRemoteImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceLocalAndRemote" />
+ </component>
+
+ <!-- multiple services -->
+ <component name="BHelloWorldServiceMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceMultipleServicesImpl" />
+ <service name="HelloWorldServiceLocal">
+ </service>
+ <service name="HelloWorldServiceRemote">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceMultipleServices/HelloWorldServiceRemote"/>
+ </service>
+ <service name="HelloWorldServiceRemote2">
+ <binding.sca uri="http://localhost:8085/BHelloWorldServiceMultipleServices/HelloWorldServiceRemote2"/>
+ </service>
+ </component>
+
+ <component name="BHelloWorldClientMultipleServices">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldClientLocalImpl" />
+ <reference name="helloWorldService" target="BHelloWorldServiceMultipleServices/HelloWorldServiceLocal" />
+ </component>
+
+ <!-- multiple bindings -->
+ <component name="BHelloWorldMultipleBindings">
+ <implementation.java class="org.apache.tuscany.sca.binding.sca.axis2.helloworld.impl.HelloWorldServiceRemoteImpl" />
+ <service name="HelloWorldServiceRemote">
+ <interface.java interface="org.apache.tuscany.sca.binding.sca.axis2.helloworld.HelloWorldServiceRemote" />
+ <binding.ws name="wsBinding" uri="http://localhost:8085/BHelloWorldMultipleBindings/HelloWorldServiceRemote-wsbinding"/>
+ <binding.sca name="scaBinding" uri="http://localhost:8085/BHelloWorldMultipleBindings/HelloWorldServiceRemote-scabinding"/>
+ </service>
+ </component>
+
+
+ <!-- Dynamic interfaces -->
+ <!--component name="BHelloWorldServiceScript">
+ <implementation.script script="calculator/AddServiceImpl.js"/>
+ </component-->
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleService/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e6ccae5c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/binding-sca-tribes/src/test/resources/ws/simpleService/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/pom.xml
new file mode 100644
index 0000000000..8367550f5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-helloworld-client</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Helloworld Client</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java
new file mode 100644
index 0000000000..2619dc269b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest.nodes;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+@EagerInit
+@Scope("COMPOSITE")
+public class HelloworldImpl implements Helloworld {
+
+ @Reference
+ public Helloworld service;
+
+ @Init
+ public void initialize() throws Exception{
+ System.out.println(">>>>>> " + sayHello("init"));
+ }
+
+ public String sayHello(String name) throws Exception {
+ return "Hi " + service.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e062cc14e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:HelloworldClient"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite b/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite
new file mode 100644
index 0000000000..3c4ed03448
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="HelloworldClient">
+
+ <component name="HelloworldClient">
+ <implementation.java class="itest.nodes.HelloworldImpl"/>
+ <reference name="service" target="HelloworldService"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-iface/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-iface/pom.xml
new file mode 100644
index 0000000000..87b6a4fc51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-iface/pom.xml
@@ -0,0 +1,39 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Helloworld IFaces</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java
new file mode 100644
index 0000000000..a0710281c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest.nodes;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name) throws Exception;
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/pom.xml
new file mode 100644
index 0000000000..e981d2dc4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-helloworld-service-a</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Helloworld Service A</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/java/itest/nodes/HelloworldImpl.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/java/itest/nodes/HelloworldImpl.java
new file mode 100644
index 0000000000..2619dc269b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/java/itest/nodes/HelloworldImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest.nodes;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+@EagerInit
+@Scope("COMPOSITE")
+public class HelloworldImpl implements Helloworld {
+
+ @Reference
+ public Helloworld service;
+
+ @Init
+ public void initialize() throws Exception{
+ System.out.println(">>>>>> " + sayHello("init"));
+ }
+
+ public String sayHello(String name) throws Exception {
+ return "Hi " + service.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..bba92e6ca3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ServiceA"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/resources/service-a.composite b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/resources/service-a.composite
new file mode 100644
index 0000000000..55122d2d6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-a/src/main/resources/service-a.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://itest"
+ name="ServiceA">
+
+ <component name="ServiceA">
+ <implementation.java class="itest.nodes.HelloworldImpl"/>
+ <reference name="service" target="ServiceA"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/pom.xml
new file mode 100644
index 0000000000..862475b534
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/pom.xml
@@ -0,0 +1,39 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-helloworld-service-and-client</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Helloworld Service and Client</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/Helloworld.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/Helloworld.java
new file mode 100644
index 0000000000..1cb9b813f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/Helloworld.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest.nodes.sac;
+
+public interface Helloworld {
+
+ String sayHello(String name) throws Exception;
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/HelloworldClientImpl.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/HelloworldClientImpl.java
new file mode 100644
index 0000000000..d64536a998
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/HelloworldClientImpl.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 itest.nodes.sac;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloworldClientImpl implements Helloworld {
+
+ @Reference
+ public Helloworld service;
+
+
+ public String sayHello(String name) throws Exception {
+ return "Hi " + service.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..728804b08c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/java/itest/nodes/sac/HelloworldServiceImpl.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 itest.nodes.sac;
+
+public class HelloworldServiceImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ String response = "Hello " + name;
+ System.out.println("At service - " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..555824a94e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:HelloworldServiceAndClient"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/resources/helloworld-service.composite b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/resources/helloworld-service.composite
new file mode 100644
index 0000000000..38ac479275
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-and-client/src/main/resources/helloworld-service.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="HelloworldServiceAndClient">
+
+ <component name="HelloworldClient">
+ <implementation.java class="itest.nodes.sac.HelloworldClientImpl"/>
+ <reference name="service" target="HelloworldService"/>
+ </component>
+
+ <component name="HelloworldService">
+ <implementation.java class="itest.nodes.sac.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/pom.xml
new file mode 100644
index 0000000000..49fdb9b562
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/pom.xml
@@ -0,0 +1,49 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-helloworld-service-b</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Helloworld Service B</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/java/itest/nodes/HelloworldImpl.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/java/itest/nodes/HelloworldImpl.java
new file mode 100644
index 0000000000..b1d5a8235a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/java/itest/nodes/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 itest.nodes;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloworldImpl implements Helloworld {
+
+ @Reference
+ protected Helloworld service;
+
+ public String sayHello(String name) throws Exception {
+ return service.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..4405cca18e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ServiceB"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/resources/service-b.composite b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/resources/service-b.composite
new file mode 100644
index 0000000000..02cff882a7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-b/src/main/resources/service-b.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://itest"
+ name="ServiceB">
+
+ <component name="ServiceB">
+ <implementation.java class="itest.nodes.HelloworldImpl"/>
+ <reference name="service" target="ServiceC"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/pom.xml
new file mode 100644
index 0000000000..ef7068e0e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/pom.xml
@@ -0,0 +1,49 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-helloworld-Serivce-c</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Helloworld Service C</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/java/itest/nodes/HelloworldImpl.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/java/itest/nodes/HelloworldImpl.java
new file mode 100644
index 0000000000..81f7e1747d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/java/itest/nodes/HelloworldImpl.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 itest.nodes;
+
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3ff86f946b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ServiceC"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/resources/service-c.composite b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/resources/service-c.composite
new file mode 100644
index 0000000000..d88db09b43
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service-c/src/main/resources/service-c.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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://itest"
+ name="ServiceC">
+
+ <component name="ServiceC">
+ <implementation.java class="itest.nodes.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/pom.xml
new file mode 100644
index 0000000000..e5e84571cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-helloworld-service</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Helloworld Service</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java
new file mode 100644
index 0000000000..a27e752fd7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.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 itest.nodes;
+
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ String response = "Hello " + name;
+ System.out.println("At service - " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..829ece9f7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:HelloworldService"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite
new file mode 100644
index 0000000000..5334caeb55
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/helloworld-service/src/main/resources/helloworld-service.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="HelloworldService">
+
+ <component name="HelloworldService">
+ <implementation.java class="itest.nodes.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast-client/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast-client/pom.xml
new file mode 100644
index 0000000000..30d509ecc6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast-client/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-one-jvm-hazelcast-client</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes One JVM Using Hazelcast and client</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast-client</artifactId>
+ <version>1.8.3</version>
+ </dependency>
+ </dependencies>
+ <build>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.java
new file mode 100644
index 0000000000..cf99c970db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.hazelcast.client.HazelcastClient;
+import com.hazelcast.core.IMap;
+
+/**
+ */
+public class ClientTestCase{
+
+ private static String domainURI = "uri:OneNodeTestCase?bind=127.0.0.1:14829";
+ private static Node node;
+ private static HazelcastClient client;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ node = NodeFactory.newInstance(domainURI).createNode((String)null, new String[]{"../helloworld-service/target/classes", "../helloworld-client/target/classes"});
+ node.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ client = HazelcastClient.newHazelcastClient("OneNodeTestCase", "tuscany", "127.0.0.1:14829");
+ IMap<Object, Object> map = client.getMap("OneNodeTestCase/Endpoints");
+
+ assertNotNull(map);
+ assertEquals(2, map.size());
+ Object ep1 = map.get("HelloworldService#service-binding(Helloworld/Helloworld)");
+// System.out.println((RuntimeEndpointImpl)ep1);
+ assertNotNull(ep1);
+ assertTrue(ep1 instanceof RuntimeEndpointImpl);
+ Object ep2 = map.get("HelloworldClient#service-binding(Helloworld/Helloworld)");
+ assertNotNull(ep2);
+ }
+
+ //@Test
+ public void testTime() throws Exception {
+ long start = System.currentTimeMillis();
+ long count = 100;
+ for (int i=0; i<count; i++) {
+ testNode();
+ client.shutdown();
+ }
+ long avg = (System.currentTimeMillis() - start) / count;
+ System.out.println("Average for " + count + " client connects " + avg);
+ }
+
+ @Test
+ public void testBadPassword() throws Exception {
+ try {
+ client = HazelcastClient.newHazelcastClient("OneNodeTestCase", "IncorrectPassword", "127.0.0.1:14829");
+ fail();
+ } catch (Exception e) {
+ //expected
+ }
+ }
+
+ @Test
+ public void testBadIP() throws Exception {
+ try {
+ client = HazelcastClient.newHazelcastClient("OneNodeTestCase", "IncorrectPassword", "127.0.0.99:9999");
+ fail();
+ } catch (Exception e) {
+ //expected
+ }
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (client != null) {
+ client.shutdown();
+ }
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/pom.xml
new file mode 100644
index 0000000000..4d5fb61d2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-one-jvm-hazelcast</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes One JVM Using Hazelcast Registry</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-service-and-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/OneNodeOneContributionTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/OneNodeOneContributionTestCase.java
new file mode 100644
index 0000000000..3755d0b365
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/OneNodeOneContributionTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.sac.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class OneNodeOneContributionTestCase{
+
+ private static URI domainURI = URI.create("tuscany:OneNodeTestCase");
+ private static Node node;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ node = NodeFactory.getInstance().createNode(domainURI, "../helloworld-service-and-client/target/classes");
+ node.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld client = node.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/OneNodeTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/OneNodeTestCase.java
new file mode 100644
index 0000000000..1c6b2ce754
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/OneNodeTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class OneNodeTestCase{
+
+ private static URI domainURI = URI.create("OneNodeTestCase");
+ private static Node node;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ node = NodeFactory.getInstance().createNode(domainURI, "../helloworld-service/target/classes", "../helloworld-client/target/classes");
+ node.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld service = node.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = node.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ Helloworld scaClientService = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(scaClientService);
+ assertEquals("Hello Petra", scaClientService.sayHello("Petra"));
+
+ Helloworld scaClientClient = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(scaClientClient);
+ assertEquals("Hi Hello Petra", scaClientClient.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/TwoNodeTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/TwoNodeTestCase.java
new file mode 100644
index 0000000000..558afda077
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/TwoNodeTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class TwoNodeTestCase{
+
+ private static URI domainURI = URI.create("TwoNodeTestCase");
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ serviceNode = NodeFactory.getInstance().createNode(domainURI, "../helloworld-service/target/classes");
+ serviceNode.start();
+ clientNode = NodeFactory.getInstance().createNode(domainURI, "../helloworld-client/target/classes");
+ clientNode.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ Helloworld scaClientService = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(scaClientService);
+ assertEquals("Hello Petra", scaClientService.sayHello("Petra"));
+
+ Helloworld scaClientClient = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(scaClientClient);
+ assertEquals("Hi Hello Petra", scaClientClient.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/TwoRemoteNodesTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/TwoRemoteNodesTestCase.java
new file mode 100644
index 0000000000..841621964f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-hazelcast/src/test/java/itest/TwoRemoteNodesTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class TwoRemoteNodesTestCase{
+
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ serviceNode = NodeFactory.newInstance().createNode(URI.create("tuscany:TwoRemoteNodesTestCase"), "../helloworld-service/target/classes");
+ serviceNode.start();
+
+ clientNode = NodeFactory.getInstance().createNode(URI.create("tuscany:TwoRemoteNodesTestCase"), "../helloworld-client/target/classes");
+ clientNode.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ Helloworld scaClientService = SCAClientFactory.newInstance(URI.create("TwoRemoteNodesTestCase")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(scaClientService);
+ assertEquals("Hello Petra", scaClientService.sayHello("Petra"));
+
+ Helloworld scaClientClient = SCAClientFactory.newInstance(URI.create("TwoRemoteNodesTestCase")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(scaClientClient);
+ assertEquals("Hi Hello Petra", scaClientClient.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/pom.xml
new file mode 100644
index 0000000000..ff52b60103
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/pom.xml
@@ -0,0 +1,82 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-one-jvm-tribes</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes One JVM Using Tribes Registry</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <reportFormat>brief</reportFormat>
+ <useFile>false</useFile>
+ <forkMode>once</forkMode>
+ <argLine>-ea -Xmx256m</argLine>
+ <parallel>off</parallel>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/OneNodeTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/OneNodeTestCase.java
new file mode 100644
index 0000000000..e55e8f63e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/OneNodeTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class OneNodeTestCase{
+
+ private static URI domainURI = URI.create("OneNodeTestCase");
+ private static Node node;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ node = NodeFactory.getInstance().createNode(domainURI, "../helloworld-service/target/classes", "../helloworld-client/target/classes");
+ node.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld service = node.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = node.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ Helloworld scaClientService = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(scaClientService);
+ assertEquals("Hello Petra", scaClientService.sayHello("Petra"));
+
+ Helloworld scaClientClient = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(scaClientClient);
+ assertEquals("Hi Hello Petra", scaClientClient.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/TwoNodeTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/TwoNodeTestCase.java
new file mode 100644
index 0000000000..2d920c340a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/TwoNodeTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class TwoNodeTestCase{
+
+ private static URI domainURI = URI.create("TwoNodeTestCase");
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ serviceNode = NodeFactory.getInstance().createNode(domainURI, "../helloworld-service/target/classes");
+ serviceNode.start();
+ clientNode = NodeFactory.getInstance().createNode(domainURI, "../helloworld-client/target/classes");
+ clientNode.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ Helloworld scaClientService = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(scaClientService);
+ assertEquals("Hello Petra", scaClientService.sayHello("Petra"));
+
+ Helloworld scaClientClient = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(scaClientClient);
+ assertEquals("Hi Hello Petra", scaClientClient.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/TwoRemoteNodesTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/TwoRemoteNodesTestCase.java
new file mode 100644
index 0000000000..888b4df156
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm-tribes/src/test/java/itest/TwoRemoteNodesTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class TwoRemoteNodesTestCase{
+
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ serviceNode = NodeFactory.newInstance().createNode(URI.create("tuscany:TwoRemoteNodesTestCase"), "../helloworld-service/target/classes");
+ serviceNode.start();
+
+ clientNode = NodeFactory.getInstance().createNode(URI.create("tuscany:TwoRemoteNodesTestCase"), "../helloworld-client/target/classes");
+ clientNode.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+// Helloworld scaClientService = SCAClientFactory.newInstance(URI.create("TwoRemoteNodesTestCase")).getService(Helloworld.class, "HelloworldService");
+// assertNotNull(scaClientService);
+// assertEquals("Hello Petra", scaClientService.sayHello("Petra"));
+
+ Helloworld scaClientClient = SCAClientFactory.newInstance(URI.create("TwoRemoteNodesTestCase")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(scaClientClient);
+ assertEquals("Hi Hello Petra", scaClientClient.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/one-jvm/pom.xml
new file mode 100644
index 0000000000..1edbfc3b99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-one-jvm</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes One JVM</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm/src/test/java/itest/OneNodeTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm/src/test/java/itest/OneNodeTestCase.java
new file mode 100644
index 0000000000..1c6b2ce754
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm/src/test/java/itest/OneNodeTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class OneNodeTestCase{
+
+ private static URI domainURI = URI.create("OneNodeTestCase");
+ private static Node node;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ node = NodeFactory.getInstance().createNode(domainURI, "../helloworld-service/target/classes", "../helloworld-client/target/classes");
+ node.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld service = node.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = node.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ Helloworld scaClientService = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(scaClientService);
+ assertEquals("Hello Petra", scaClientService.sayHello("Petra"));
+
+ Helloworld scaClientClient = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(scaClientClient);
+ assertEquals("Hi Hello Petra", scaClientClient.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-jvm/src/test/java/itest/TwoNodeTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-jvm/src/test/java/itest/TwoNodeTestCase.java
new file mode 100644
index 0000000000..558afda077
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-jvm/src/test/java/itest/TwoNodeTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class TwoNodeTestCase{
+
+ private static URI domainURI = URI.create("TwoNodeTestCase");
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ serviceNode = NodeFactory.getInstance().createNode(domainURI, "../helloworld-service/target/classes");
+ serviceNode.start();
+ clientNode = NodeFactory.getInstance().createNode(domainURI, "../helloworld-client/target/classes");
+ clientNode.start();
+ }
+
+ @Test
+ public void testNode() throws Exception {
+
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ Helloworld scaClientService = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(scaClientService);
+ assertEquals("Hello Petra", scaClientService.sayHello("Petra"));
+
+ Helloworld scaClientClient = SCAClientFactory.newInstance(domainURI).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(scaClientClient);
+ assertEquals("Hi Hello Petra", scaClientClient.sayHello("Petra"));
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-node-test/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/one-node-test/pom.xml
new file mode 100644
index 0000000000..d35761bc88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-node-test/pom.xml
@@ -0,0 +1,48 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-one-node-test</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes One Node Test</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java
new file mode 100644
index 0000000000..6d49b718ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+
+import itest.nodes.Helloworld;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class OneNodeTestCase{
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled", "false");
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(
+ new Contribution("service", getJar("../helloworld-service/target")),
+ new Contribution("client", getJar("../helloworld-client/target")));
+ node.start();
+ }
+
+ /**
+ * Get the jar in the target folder without being dependent on the version name to
+ * make tuscany releases easier
+ */
+ private static String getJar(String targetDirectory) {
+ File f = new File(targetDirectory);
+ for (File file : f.listFiles()) {
+ if (file.getName().endsWith(".jar")) {
+ return file.toURI().toString();
+ }
+ }
+ throw new IllegalStateException("Can't find jar in: " + targetDirectory);
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+
+ // Ideally this would use the SCAClient API but leaving that tillwe have the basics working
+
+ Helloworld service = node.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = node.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/pom.xml
new file mode 100644
index 0000000000..6a60de05da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/pom.xml
@@ -0,0 +1,63 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-nodes</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes</name>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ </build>
+
+ <modules>
+ <module>helloworld-iface</module>
+ <module>helloworld-service</module>
+ <module>helloworld-client</module>
+ <module>helloworld-service-and-client</module>
+<!--
+ <module>helloworld-service-a</module>
+ <module>helloworld-service-b</module>
+ <module>helloworld-service-c</module>
+-->
+ <module>one-jvm</module>
+ <module>one-jvm-hazelcast</module>
+ <module>one-jvm-hazelcast-client</module>
+ <module>one-jvm-tribes</module>
+ <module>binding-sca-hazelcast</module>
+ <!-- module>binding-sca-tribes</module -->
+ <module>one-node-test</module>
+<!-- failing now and then with RMI already bound problem
+ <module>two-nodes-two-vms-hazelcast</module>
+ <module>two-nodes-test</module>
+-->
+
+<!--
+ <module>three-nodes-three-vms-test</module>
+-->
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/build.xml b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/build.xml
new file mode 100644
index 0000000000..3d77230541
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/build.xml
@@ -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.
+-->
+<project name="itest-samples" default="run">
+
+ <target name="run">
+
+ <parallel failonany="true">
+
+ <daemons>
+ <ant antfile="server.xml"/>
+ </daemons>
+
+ <sequential>
+ <sleep seconds="4"/>
+ <ant antfile="client.xml"/>
+ </sequential>
+
+ </parallel>
+
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/client.xml b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/client.xml
new file mode 100644
index 0000000000..8e7c744940
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/client.xml
@@ -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.
+-->
+<project name="server" default="run">
+
+ <!--echo>${runtime_classpath}</echo-->
+
+ <target name="run">
+ <java classpath="${runtime_classpath};./target/test-classes"
+ classname="itest.Client"
+ fork="true"
+ failonerror="true">
+ </java>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/pom.xml
new file mode 100644
index 0000000000..337a4ba5c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/pom.xml
@@ -0,0 +1,104 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-three-nodes-three-vms-test</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Three Nodes Three VMs Test</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks unless="maven.test.skip">
+ <property name="tuscany.version" value="${version}" />
+ <property name="runtime_classpath" refid="maven.runtime.classpath"/>
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/server.xml b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/server.xml
new file mode 100644
index 0000000000..dc18cc8ce0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/server.xml
@@ -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.
+-->
+<project name="server" default="run">
+
+ <!--echo>${runtime_classpath}</echo-->
+
+ <target name="run">
+ <java classpath="${runtime_classpath}" classname="org.apache.tuscany.sca.node.launcher.NodeMain" fork="true">
+ <arg value="-node"/>
+ <arg value="./server-config.xml"/>
+ </java>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-a-config.xml b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-a-config.xml
new file mode 100644
index 0000000000..1f87322e80
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-a-config.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ uri="http://sample/nodes/TestNode1"
+ domain="http://domain1"
+ domainRegistry="tribes:default">
+
+ <!-- Configure the base URIs for a given binding -->
+ <!-- Each base URI is for a protocol supported by the binding -->
+ <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/>
+ <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/>
+
+ <!-- Configure a list of contributions -->
+ <contribution uri="iface" location="../helloworld-iface/target/itest-nodes-helloworld-iface-2.0-SNAPSHOT.jar"/>
+ <contribution uri="client" location="../helloworld-service-a/target/itest-nodes-helloworld-service-a-2.0-SNAPSHOT.jar">
+ <!-- doesn't pick up the deployable composite properly without this?-->
+ <deploymentComposite location="service-a.composite"/>
+ </contribution>
+
+</node> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-b-config.xml b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-b-config.xml
new file mode 100644
index 0000000000..d557a31b64
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-b-config.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ uri="http://sample/nodes/TestNode1"
+ domain="http://domain1"
+ domainRegistry="tribes:default">
+
+ <!-- Configure the base URIs for a given binding -->
+ <!-- Each base URI is for a protocol supported by the binding -->
+ <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/>
+ <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/>
+
+ <!-- Configure a list of contributions -->
+ <contribution uri="iface" location="../helloworld-iface/target/classes"/>
+ <contribution uri="service" location="../helloworld-service-b/target/classes">
+ <!-- doesn't pick up the deployable composite properly without this?-->
+ <deploymentComposite location="service-b.composite"/>
+ </contribution>
+
+</node> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-c-config.xml b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-c-config.xml
new file mode 100644
index 0000000000..ba642c5ed0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/service-c-config.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ uri="http://sample/nodes/TestNode1"
+ domain="http://domain1"
+ domainRegistry="tribes:default">
+
+ <!-- Configure the base URIs for a given binding -->
+ <!-- Each base URI is for a protocol supported by the binding -->
+ <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/>
+ <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/>
+
+ <!-- Configure a list of contributions -->
+ <contribution uri="iface" location="../helloworld-iface/target/classes"/>
+ <contribution uri="service" location="../helloworld-service-c/target/classes">
+ <!-- doesn't pick up the deployable composite properly without this?-->
+ <deploymentComposite location="service-c.composite"/>
+ </contribution>
+
+</node> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceA.java b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceA.java
new file mode 100644
index 0000000000..6ef30fe43f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceA.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 itest;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class ServiceA {
+
+ private static Node sericeNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+
+ sericeNode = factory.createNode(new File("service-a-config.xml").toURI().toURL());
+
+ try {
+ sericeNode.start();
+ } catch (Exception ex){
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ @Test
+ public void testNothing() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (sericeNode != null) {
+ sericeNode.stop();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ ServiceA.setUpBeforeClass();
+ ServiceA.tearDownAfterClass();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceB.java b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceB.java
new file mode 100644
index 0000000000..67a8e5d92e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceB.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ServiceB {
+
+ private static Node serviceNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+
+ serviceNode = factory.createNode(new File("service-b-config.xml").toURI().toURL());
+ serviceNode.start();
+ }
+
+ @Test
+ public void testNothing() throws Exception {
+ synchronized (this) {
+ this.wait();
+ }
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceC.java b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceC.java
new file mode 100644
index 0000000000..d716b5cd98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/three-nodes-three-vms-test/src/test/java/itest/ServiceC.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ServiceC {
+
+ private static Node serviceNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+
+ serviceNode = factory.createNode(new File("service-c-config.xml").toURI().toURL());
+ serviceNode.start();
+ }
+
+ @Test
+ public void testNothing() throws Exception {
+ synchronized (this) {
+ this.wait();
+ }
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/pom.xml
new file mode 100644
index 0000000000..091f5cbb9e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/pom.xml
@@ -0,0 +1,59 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-two-nodes-test</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Two Nodes Test</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java
new file mode 100644
index 0000000000..6da4c1f7e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.io.File;
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class ClientNode {
+ private final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static Node clientNode;
+ private static TestCaseRunner runner;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ runner = new TestCaseRunner(ServiceNode.class);
+ runner.beforeClass();
+ System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled",
+ "false");
+ NodeFactory factory = NodeFactory.newInstance();
+ NodeConfiguration conf =
+ factory.createNodeConfiguration().setURI("clientNode").
+ addBinding(new QName(SCA11_NS, "binding.sca"), "http://localhost:8085/sca https://localhost:9085/sca")
+ .addBinding(new QName(SCA11_NS, "binding.ws"), "http://localhost:8086/ws")
+ .addContribution("client", new File("../helloworld-client/target/classes").toURI().toString());
+ clientNode = factory.createNode(conf).start();
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ @Ignore("SCAClient needs to leverage the EndpointRegistry to invoke services that are not hosted on the local node")
+ public void testCalculatorClientAPI() throws Exception {
+ Helloworld service = SCAClientFactory.newInstance(URI.create("default")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClientFactory.newInstance(URI.create("default")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (runner != null) {
+ runner.afterClass();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java
new file mode 100644
index 0000000000..4b034d89e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class ServiceNode {
+ private final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static Node serviceNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled",
+ "false");
+ NodeFactory factory = NodeFactory.newInstance();
+ NodeConfiguration conf =
+ factory.createNodeConfiguration().setURI("serviceNode")
+ .addBinding(new QName(SCA11_NS, "binding.sca"), "http://localhost:8087/sca")
+ .addBinding(new QName(SCA11_NS, "binding.ws"), "http://localhost:8088/ws")
+ .addContribution("service", new File("../helloworld-service/target/classes").toURI().toString());
+ serviceNode = factory.createNode(conf).start();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java
new file mode 100644
index 0000000000..998492734b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+/**
+ * Tests using two nodes and stopping and restarting a service node.
+ */
+public class StopStartNodesTestCase {
+
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @Test
+ public void testCalculator() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+ serviceNode = factory.createNode(new Contribution("service", getJar("../helloworld-service/target")));
+ serviceNode.start();
+ clientNode = factory.createNode(new Contribution("client", getJar("../helloworld-client/target")));
+ clientNode.start();
+
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ serviceNode.stop();
+
+ client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+
+ try {
+ client.sayHello("Petra");
+ fail();
+ } catch (Exception e) {
+ // expected
+ // TODO: better exception than NPE
+ }
+
+ serviceNode = factory.createNode(new Contribution("service", getJar("../helloworld-service/target")));
+ serviceNode.start();
+
+ client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ /**
+ * Get the jar in the target folder without being dependent on the version name to
+ * make tuscany releases easier
+ */
+ private static String getJar(String targetDirectory) {
+ File f = new File(targetDirectory);
+ for (File file : f.listFiles()) {
+ if (file.getName().endsWith(".jar")) {
+ return file.toURI().toString();
+ }
+ }
+ throw new IllegalStateException("Can't find jar in: " + targetDirectory);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java
new file mode 100644
index 0000000000..7dfa6e66cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java
@@ -0,0 +1,292 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * A helper class that can be used to run an SCA JUnit test case. The test case will run in an isolated class loader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestCaseRunner {
+
+ private ClassLoader classLoader;
+ private Class<?> testSuiteClass;
+ private Object testSuite;
+ private Class<?> testResultClass;
+ private Class<?> testCaseClass;
+ private Object testCase;
+
+ private Class<?> beforeAnnotation;
+ private Class<?> beforeClassAnnotation;
+ private Class<?> afterAnnotation;
+ private Class<?> afterClassAnnotation;
+ private Class<?> junit4AdapterClass;
+ private Class<?> junit3TestCaseClass;
+
+ /**
+ * Constructs a new TestCase runner.
+ *
+ * @param testClass
+ */
+ public TestCaseRunner(Class<?> testClass) {
+ try {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ classLoader = testClass.getClassLoader();
+ if (classLoader instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader)classLoader).getURLs();
+ classLoader = new URLClassLoader(urls, classLoader.getParent());
+ } else if (classLoader == tccl || classLoader.getParent() == tccl) {
+ classLoader = new URLClassLoader(new URL[0], classLoader);
+ } else {
+ classLoader = tccl;
+ }
+
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ testCaseClass = Class.forName(testClass.getName(), true, classLoader);
+ testCase = testCaseClass.newInstance();
+ ClassLoader testClassLoader = testCaseClass.getClassLoader();
+
+ junit3TestCaseClass = Class.forName("junit.framework.TestCase", true, testClassLoader);
+
+ testSuiteClass = Class.forName("junit.framework.TestSuite", true, testClassLoader);
+ Constructor<?> testSuiteConstructor = testSuiteClass.getConstructor(Class.class);
+ testSuite = testSuiteConstructor.newInstance(testCaseClass);
+
+ testResultClass = Class.forName("junit.framework.TestResult", true, testClassLoader);
+
+ try {
+ beforeAnnotation = Class.forName("org.junit.Before", true, testClassLoader);
+ afterAnnotation = Class.forName("org.junit.After", true, testClassLoader);
+ beforeClassAnnotation = Class.forName("org.junit.BeforeClass", true, testClassLoader);
+ afterClassAnnotation = Class.forName("org.junit.AfterClass", true, testClassLoader);
+ junit4AdapterClass = Class.forName("junit.framework.JUnit4TestAdapter", true, testClassLoader);
+ } catch (Exception e) {
+ // Unexpected
+ throw new AssertionError(e);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Run the test case
+ */
+ public void run() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ if (junit3TestCaseClass.isAssignableFrom(testCaseClass)) {
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = testSuiteClass.getMethod("run", testResultClass);
+ runMethod.invoke(testSuite, testResult);
+ } else {
+ Object junit4Adapter = junit4AdapterClass.getConstructor(Class.class).newInstance(testCaseClass);
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = junit4AdapterClass.getMethod("run", testResultClass);
+ runMethod.invoke(junit4Adapter, testResult);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Invoke the setUp method
+ */
+ public void setUp() {
+ execute("setUp");
+ }
+
+ /**
+ * Invoke the before methods
+ */
+ public void before() {
+ execute(beforeAnnotation);
+ }
+
+ /**
+ * Invoke the beforeClass methods
+ */
+ public void beforeClass() {
+ execute(beforeClassAnnotation);
+ }
+
+ /**
+ * Invoke the tearDown method
+ */
+ public void tearDown() {
+ execute("tearDown");
+ }
+
+ /**
+ * Invoke the after methods
+ */
+ public void after() {
+ execute(afterAnnotation);
+ }
+
+ /**
+ * Invoke the afterClass methods
+ */
+ public void afterClass() {
+ execute(afterClassAnnotation);
+ }
+
+ /**
+ * Invoke the specified test method.
+ */
+ public void run(String methodName) {
+ execute(methodName);
+ }
+
+ /**
+ * Invoke the methods annotated with the specified annotation.
+ */
+ private void execute(Class<?> annotationClass) {
+ if (annotationClass == null) {
+ throw new RuntimeException(new NoSuchMethodException());
+ }
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ for (Method method : testCaseClass.getDeclaredMethods()) {
+ for (Annotation annotation : method.getAnnotations()) {
+ if (annotation.annotationType() == annotationClass) {
+ method.invoke(testCase);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Invoke the specified method
+ */
+ private void execute(String methodName) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+ Method setUpMethod = testCaseClass.getDeclaredMethod(methodName);
+ setUpMethod.setAccessible(true);
+ setUpMethod.invoke(testCase);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java
new file mode 100644
index 0000000000..80c36e5ee9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.io.File;
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class TwoNodesTestCase {
+
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled",
+ "false");
+ NodeFactory factory = NodeFactory.getInstance();
+ NodeConfiguration configuration1 =
+ factory.createNodeConfiguration().setURI("serviceNode")
+ .addContribution("service", getJar("../helloworld-service/target"));
+ serviceNode = factory.createNode(configuration1).start();
+
+ NodeConfiguration configuration2 =
+ factory.createNodeConfiguration().setURI("clientNode")
+ .addContribution("client", getJar("../helloworld-client/target"));
+ clientNode = factory.createNode(configuration2).start();
+ }
+
+ /**
+ * Get the jar in the target folder without being dependent on the version name to
+ * make tuscany releases easier
+ */
+ private static String getJar(String targetDirectory) {
+ File f = new File(targetDirectory);
+ for (File file : f.listFiles()) {
+ if (file.getName().endsWith(".jar")) {
+ return file.toURI().toString();
+ }
+ }
+ throw new IllegalStateException("Can't find jar in: " + targetDirectory);
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testCalculatorClientAPI() throws Exception {
+ Helloworld service = SCAClientFactory.newInstance(URI.create("default")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClientFactory.newInstance(URI.create("default")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/build.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/build.xml
new file mode 100644
index 0000000000..ad0476c6d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/build.xml
@@ -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.
+-->
+<project name="itest-samples" default="run">
+
+ <target name="run">
+
+ <parallel failonany="true">
+
+ <daemons>
+ <ant antfile="server.xml"/>
+ </daemons>
+
+ <sequential>
+ <sleep seconds="5"/>
+ <ant antfile="client.xml"/>
+ <ant antfile="scaclient.xml"/>
+ </sequential>
+
+ </parallel>
+
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/client-config.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/client-config.xml
new file mode 100644
index 0000000000..a5e4a0b7c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/client-config.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ uri="http://sample/nodes/TestNode1"
+ domain="default"
+ domainRegistry="tuscany:default">
+
+ <!-- Configure the base URIs for a given binding -->
+ <!-- Each base URI is for a protocol supported by the binding -->
+ <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/>
+ <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/>
+
+ <!-- Configure a list of contributions -->
+ <contribution uri="iface" location="../helloworld-iface/target/itest-nodes-helloworld-iface-2.0-SNAPSHOT.jar"/>
+ <contribution uri="client" location="../helloworld-client/target/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar">
+ <!-- doesn't pick up the deployable composite properly without this?-->
+ <deploymentComposite location="helloworld-client.composite"/>
+ </contribution>
+
+</node> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/client.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/client.xml
new file mode 100644
index 0000000000..b7a0e63a48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/client.xml
@@ -0,0 +1,55 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="client" default="run">
+
+ <!--echo>${runtime_classpath}</echo-->
+
+ <target name="run">
+ <java classpath="${runtime_classpath};./target/test-classes"
+ classname="itest.Client"
+ fork="true"
+ failonerror="true">
+ </java>
+ </target>
+
+
+ <target name="run-cmdline">
+ <java classpath="../../../distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT.dir/tuscany-sca-2.0-SNAPSHOT/features/tuscany-sca-manifest.jar:./target/test-classes:../helloworld-iface/target/classes"
+ classname="itest.Client"
+ fork="true"
+ failonerror="true">
+ </java>
+ </target>
+
+ <target name="run-cmdline-seq">
+ <sequential>
+ <antcall target="run-cmdline"/>
+ <antcall target="run-cmdline"/>
+ <antcall target="run-cmdline"/>
+ </sequential>
+ </target>
+
+ <target name="run-cmdline-par">
+ <parallel>
+ <antcall target="run-cmdline"/>
+ <antcall target="run-cmdline"/>
+ <antcall target="run-cmdline"/>
+ </parallel>
+ </target>
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/pom.xml
new file mode 100644
index 0000000000..05fec4cb54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/pom.xml
@@ -0,0 +1,114 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-two-nodes-two-vms-hazelcast</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Two Nodes Two VMs Test using Hazelcast registry</name>
+
+ <dependencies>
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency-->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks unless="maven.test.skip">
+ <property name="tuscany.version" value="${version}" />
+ <property name="runtime_classpath" refid="maven.runtime.classpath"/>
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/scaclient.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/scaclient.xml
new file mode 100644
index 0000000000..b85d1a7915
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/scaclient.xml
@@ -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.
+-->
+<project name="scaclient" default="run">
+
+ <!--echo>${runtime_classpath}</echo-->
+
+ <target name="run">
+ <java classpath="${runtime_classpath};./target/test-classes"
+ classname="itest.SCAClient"
+ fork="true"
+ failonerror="true">
+ </java>
+ </target>
+
+ <target name="run-cmdline">
+ <java classpath="../../../distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT.dir/tuscany-sca-2.0-SNAPSHOT/features/tuscany-sca-manifest.jar:./target/test-classes:../helloworld-iface/target/classes"
+ classname="itest.SCAClient"
+ fork="true"
+ failonerror="true">
+ </java>
+ </target>
+
+ <target name="run-cmdline-seq">
+ <sequential>
+ <antcall target="run-cmdline"/>
+ <antcall target="run-cmdline"/>
+ <antcall target="run-cmdline"/>
+ </sequential>
+ </target>
+
+ <target name="run-cmdline-par">
+ <parallel>
+ <antcall target="run-cmdline"/>
+ <antcall target="run-cmdline"/>
+ <antcall target="run-cmdline"/>
+ </parallel>
+ </target>
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/server-config.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/server-config.xml
new file mode 100644
index 0000000000..841471f95f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/server-config.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ uri="http://sample/nodes/TestNode2"
+ domain="default"
+ domainRegistry="tuscany:default?listen=127.0.0.1:14820">
+
+ <!-- Configure the base URIs for a given binding -->
+ <!-- Each base URI is for a protocol supported by the binding -->
+ <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/>
+ <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/>
+
+ <!-- Configure a list of contributions -->
+ <contribution uri="iface" location="../helloworld-iface/target/classes"/>
+ <contribution uri="service" location="../helloworld-service/target/classes">
+ <!-- doesn't pick up the deployable composite properly without this?-->
+ <deploymentComposite location="helloworld-service.composite"/>
+ </contribution>
+
+</node> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/server.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/server.xml
new file mode 100644
index 0000000000..98474d2cf4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/server.xml
@@ -0,0 +1,42 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 name="server" default="run">
+
+ <!--echo>${runtime_classpath}</echo-->
+
+ <target name="run">
+ <java classpath="${runtime_classpath}" classname="org.apache.tuscany.sca.node.launcher.NodeMain" fork="true">
+ <sysproperty key="org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding" value="{http://tuscany.apache.org/xmlns/sca/1.1}binding.rmi"/>
+ <arg value="-node"/>
+ <arg value="./server-config.xml"/>
+ <!-- Give the server 60 seconds to stay -->
+ <arg value="-ttl"/>
+ <arg value="60000"/>
+ </java>
+ </target>
+
+ <target name="run-cmdline">
+ <java classpath="../../../distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT.dir/tuscany-sca-2.0-SNAPSHOT/features/tuscany-sca-manifest.jar:./target/test-classes:../helloworld-iface/target/classes"
+ classname="itest.Service"
+ fork="true"
+ failonerror="true">
+ </java>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/Client.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/Client.java
new file mode 100644
index 0000000000..5d884921fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/Client.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 itest;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class Client {
+
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ clientNode = NodeFactory.newInstance().createNode(URI.create("tuscany:default?listen=127.0.0.1:14821"), "../helloworld-client/target//classes");
+ clientNode.start();
+ }
+
+ @Test
+ public void testNothing() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Client.setUpBeforeClass();
+ Client.tearDownAfterClass();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/SCAClient.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/SCAClient.java
new file mode 100644
index 0000000000..81af1c6b5b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/SCAClient.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+public class SCAClient {
+
+ public void testSCAClient() throws Exception {
+ // The configuration required when running with sca-client-rmi and endpoint-hazelcast-rmi
+ SCAClientFactory factory = SCAClientFactory.newInstance(URI.create("tuscanyclient:default?remotes=127.0.0.1:14820"));
+
+ // The configuration required when running with sca-client-impl and endpoint-hazelcast
+ //SCAClientFactory factory = SCAClientFactory.newInstance(URI.create("tuscany:default"));
+
+ // Sleep 3 seconds so that the endpoint is populated into the EndpointRegistry
+ //Thread.sleep(3000);
+
+ Helloworld service = factory.getService(Helloworld.class, "HelloworldService");
+
+ String response = service.sayHello("test");
+ if (response == null || !response.equals("Hello test")){
+ throw new Exception("Test failed - expecting 'Hello test' got " + response);
+ } else {
+ System.out.println("Test success - " + response);
+ }
+
+ //TODO - When using the hazelcast registry (or client) it causes the
+ // JVM to hang on shutdown as it created non-daemon threads
+ // So destroy the node factory here which should bring down
+ // the runtime and hence hazelcast.
+ // There's currently no interface on the client factory
+ // for doing this so we may need to talk to OASIS about adding one
+ // or just rely on the runtime hosting the classes using the SCAClient
+ // when it's on its way down
+ //NodeFactory.getInstance().destroy();
+ }
+
+ public static void main(String[] args) throws Exception {
+ SCAClient client = new SCAClient();
+ client.testSCAClient();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/Service.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/Service.java
new file mode 100644
index 0000000000..0c9659b0ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-hazelcast/src/test/java/itest/Service.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class Service {
+
+ private static Node serviceNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ serviceNode = NodeFactory.newInstance().createNode(URI.create("tuscany:default"), "../helloworld-service/target/classes");
+ serviceNode.start();
+ }
+
+ @Test
+ public void testNothing() throws Exception {
+ // Stay for 1 min
+ Thread.sleep(60000);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Service.setUpBeforeClass();
+ new Service().testNothing();
+ Service.tearDownAfterClass();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/build.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/build.xml
new file mode 100644
index 0000000000..fa7e963e87
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/build.xml
@@ -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.
+-->
+<project name="itest-samples" default="run">
+
+ <target name="run">
+
+ <parallel failonany="true">
+
+ <daemons>
+ <ant antfile="server.xml"/>
+ </daemons>
+
+ <sequential>
+ <sleep seconds="10"/>
+ <ant antfile="client.xml"/>
+ </sequential>
+
+ </parallel>
+
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/client-config.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/client-config.xml
new file mode 100644
index 0000000000..5afc1eddfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/client-config.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ uri="http://sample/nodes/TestNode1"
+ domainRegistry = "tribes://228.0.0.100:50000"
+ domain="http://domain1">
+
+ <!-- Configure the base URIs for a given binding -->
+ <!-- Each base URI is for a protocol supported by the binding -->
+ <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/>
+ <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/>
+
+ <!-- Configure a list of contributions -->
+ <contribution uri="iface" location="../helloworld-iface/target/itest-nodes-helloworld-iface-2.0-SNAPSHOT.jar"/>
+ <contribution uri="client" location="../helloworld-client/target/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar">
+ <!-- doesn't pick up the deployable composite properly without this?-->
+ <deploymentComposite location="helloworld-client.composite"/>
+ </contribution>
+
+</node> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/client.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/client.xml
new file mode 100644
index 0000000000..8e7c744940
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/client.xml
@@ -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.
+-->
+<project name="server" default="run">
+
+ <!--echo>${runtime_classpath}</echo-->
+
+ <target name="run">
+ <java classpath="${runtime_classpath};./target/test-classes"
+ classname="itest.Client"
+ fork="true"
+ failonerror="true">
+ </java>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/pom.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/pom.xml
new file mode 100644
index 0000000000..2f80274c47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/pom.xml
@@ -0,0 +1,104 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-two-nodes-two-vms-test</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Two Nodes Two VMs Test</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run-samples</id>
+ <phase>test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks unless="maven.test.skip">
+ <property name="tuscany.version" value="${version}" />
+ <property name="runtime_classpath" refid="maven.runtime.classpath"/>
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/server-config.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/server-config.xml
new file mode 100644
index 0000000000..590cf3bddb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/server-config.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ uri="http://sample/nodes/TestNode2"
+ domainRegistry = "tribes://228.0.0.100:50000"
+ domain="http://domain1">
+
+ <!-- Configure the base URIs for a given binding -->
+ <!-- Each base URI is for a protocol supported by the binding -->
+ <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/>
+ <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/>
+
+ <!-- Configure a list of contributions -->
+ <contribution uri="iface" location="../helloworld-iface/target/classes"/>
+ <contribution uri="service" location="../helloworld-service/target/classes">
+ <!-- doesn't pick up the deployable composite properly without this?-->
+ <deploymentComposite location="helloworld-service.composite"/>
+ </contribution>
+
+</node> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/server.xml b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/server.xml
new file mode 100644
index 0000000000..05a5aa16e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/server.xml
@@ -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.
+-->
+<project name="server" default="run">
+
+ <!--echo>${runtime_classpath}</echo-->
+
+ <target name="run">
+ <java classpath="${runtime_classpath}" classname="org.apache.tuscany.sca.node.launcher.NodeMain" fork="true">
+ <sysproperty key="org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding" value="{http://tuscany.apache.org/xmlns/sca/1.1}binding.rmi"/>
+ <arg value="-node"/>
+ <arg value="./server-config.xml"/>
+ <arg value="-ttl"/>
+ <arg value="15000"/>
+ </java>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/Client.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/Client.java
new file mode 100644
index 0000000000..eef3362c10
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/Client.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.domain.node.DomainNode;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class Client {
+
+ private static Node clientNode;
+// private static DomainNode clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+
+ clientNode = factory.createNode(new File("client-config.xml").toURI().toURL());
+
+ try {
+ clientNode.start();
+ } catch (Exception ex){
+ ex.printStackTrace();
+ throw ex;
+ }
+
+// clientNode = new DomainNode("tribes:default", new String []{"../helloworld-client/target/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
+ }
+
+ @Test
+ public void testNothing() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Client.setUpBeforeClass();
+ Client.tearDownAfterClass();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/Service.java b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/Service.java
new file mode 100644
index 0000000000..7323c2c122
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/Service.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 itest;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.domain.node.DomainNode;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class Service {
+
+ private static Node serviceNode;
+// private static DomainNode serviceNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+
+ serviceNode = factory.createNode(new File("server-config.xml").toURI().toURL());
+ serviceNode.start();
+
+// serviceNode = new DomainNode("tribes:default", new String[]{"../helloworld-service/target/classes"});
+
+ }
+
+ @Test
+ public void testNothing() throws Exception {
+ synchronized (this) {
+ this.wait();
+ }
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/oneway/build.xml b/sandbox/sebastien/java/embed/itest/oneway/build.xml
new file mode 100644
index 0000000000..79222717b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/oneway/build.xml
@@ -0,0 +1,127 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 name="oneway" default="runServer">
+
+ <property name="m2.repo" value="${user.home}\.m2\repository" />
+
+ <path id="repo.classpath">
+ <pathelement location="target/classes"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-core-spi\2.0-SNAPSHOT\tuscany-core-spi-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-host-http\2.0-SNAPSHOT\tuscany-host-http-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-ws-axis2\2.0-SNAPSHOT\tuscany-binding-ws-axis2-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-policy\2.0-SNAPSHOT\tuscany-policy-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\xerces\xercesImpl\2.8.1\xercesImpl-2.8.1.jar"/>
+ <pathelement location="${m2.repo}\org\mortbay\jetty\jetty-util\6.1.3\jetty-util-6.1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-jms_1.1_spec\1.1\geronimo-jms_1.1_spec-1.1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-implementation-java-runtime\2.0-SNAPSHOT\tuscany-implementation-java-runtime-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\wsdl4j\wsdl4j\1.6.2\wsdl4j-1.6.2.jar"/>
+ <pathelement location="${m2.repo}\commons-codec\commons-codec\1.3\commons-codec-1.3.jar"/>
+ <pathelement location="${m2.repo}\xml-apis\xml-apis\1.3.03\xml-apis-1.3.03.jar"/>
+ <pathelement location="${m2.repo}\org\apache\ws\security\wss4j\1.5.3\wss4j-1.5.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-contribution-namespace\2.0-SNAPSHOT\tuscany-contribution-namespace-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\jdom\jdom\1.0\jdom-1.0.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-assembly-xsd\2.0-SNAPSHOT\tuscany-assembly-xsd-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-assembly\2.0-SNAPSHOT\tuscany-assembly-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\rampart\rampart-trust\1.3\rampart-trust-1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-core-databinding\2.0-SNAPSHOT\tuscany-core-databinding-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\ws\commons\axiom\axiom-api\1.2.5\axiom-api-1.2.5.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-policy-xml\2.0-SNAPSHOT\tuscany-policy-xml-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\axis2\axis2-kernel\1.3\axis2-kernel-1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-sca-api\2.0-SNAPSHOT\tuscany-sca-api-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\cglib\cglib-nodep\2.1_3\cglib-nodep-2.1_3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\httpcomponents\httpcore\4.0-alpha5\httpcore-4.0-alpha5.jar"/>
+ <pathelement location="${m2.repo}\backport-util-concurrent\backport-util-concurrent\2.2\backport-util-concurrent-2.2.jar"/>
+ <pathelement location="${m2.repo}\commons-logging\commons-logging\1.1\commons-logging-1.1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-contribution-java\2.0-SNAPSHOT\tuscany-contribution-java-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-activation_1.1_spec\1.0-M1\geronimo-activation_1.1_spec-1.0-M1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-databinding\2.0-SNAPSHOT\tuscany-databinding-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\logkit\logkit\1.0.1\logkit-1.0.1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-ws-xml\2.0-SNAPSHOT\tuscany-binding-ws-xml-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\commons-fileupload\commons-fileupload\1.1.1\commons-fileupload-1.1.1.jar"/>
+ <pathelement location="${m2.repo}\annogen\annogen\0.1.0\annogen-0.1.0.jar"/>
+ <pathelement location="${m2.repo}\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar"/>
+ <pathelement location="${m2.repo}\org\apache\axis2\axis2-adb\1.3\axis2-adb-1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-policy-security\2.0-SNAPSHOT\tuscany-policy-security-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-assembly-xml\2.0-SNAPSHOT\tuscany-assembly-xml-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\axis2\axis2-mtompolicy\1.3\axis2-mtompolicy-1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-domain\2.0-SNAPSHOT\tuscany-domain-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\commons-httpclient\commons-httpclient\3.0.1\commons-httpclient-3.0.1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface-java\2.0-SNAPSHOT\tuscany-interface-java-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\axis2\axis2-java2wsdl\1.3\axis2-java2wsdl-1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\httpcomponents\httpcore-nio\4.0-alpha5\httpcore-nio-4.0-alpha5.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-contribution\2.0-SNAPSHOT\tuscany-contribution-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-implementation-java\2.0-SNAPSHOT\tuscany-implementation-java-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\xalan\xalan\2.7.0\xalan-2.7.0.jar"/>
+ <pathelement location="${m2.repo}\com\ibm\icu\icu4j\2.6.1\icu4j-2.6.1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\rampart\rampart-core\1.3\rampart-core-1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-commonj_1.1_spec\1.0\geronimo-commonj_1.1_spec-1.0.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-domain-api\2.0-SNAPSHOT\tuscany-domain-api-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-sca\2.0-SNAPSHOT\tuscany-binding-sca-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\xom\xom\1.0\xom-1.0.jar"/>
+ <pathelement location="${m2.repo}\org\apache\ant\ant-launcher\1.7.0\ant-launcher-1.7.0.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-host-jetty\2.0-SNAPSHOT\tuscany-host-jetty-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\rampart\rampart-policy\1.3\rampart-policy-1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\httpcomponents\httpcore-niossl\4.0-alpha5\httpcore-niossl-4.0-alpha5.jar"/>
+ <pathelement location="${m2.repo}\junit\junit\4.2\junit-4.2.jar"/>
+ <pathelement location="${m2.repo}\org\apache\ws\commons\axiom\axiom-impl\1.2.5\axiom-impl-1.2.5.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-implementation-java-xml\2.0-SNAPSHOT\tuscany-implementation-java-xml-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-sca-xml\2.0-SNAPSHOT\tuscany-binding-sca-xml-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\neethi\neethi\2.0.2\neethi-2.0.2.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface-wsdl\2.0-SNAPSHOT\tuscany-interface-wsdl-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-ws\2.0-SNAPSHOT\tuscany-binding-ws-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\javax\activation\activation\1.1\activation-1.1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\ant\ant\1.7.0\ant-1.7.0.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-databinding-axiom\2.0-SNAPSHOT\tuscany-databinding-axiom-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\mortbay\jetty\jetty\6.1.3\jetty-6.1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-javamail_1.4_spec\1.0-M1\geronimo-javamail_1.4_spec-1.0-M1.jar"/>
+ <pathelement location="${m2.repo}\avalon-framework\avalon-framework\4.1.3\avalon-framework-4.1.3.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-core\2.0-SNAPSHOT\tuscany-core-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface-wsdl-xml\2.0-SNAPSHOT\tuscany-interface-wsdl-xml-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-contribution-impl\2.0-SNAPSHOT\tuscany-contribution-impl-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-node\2.0-SNAPSHOT\tuscany-node-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-definitions\2.0-SNAPSHOT\tuscany-definitions-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\santuario\xmlsec\1.4.0\xmlsec-1.4.0.jar"/>
+ <pathelement location="${m2.repo}\jaxen\jaxen\1.1.1\jaxen-1.1.1.jar"/>
+ <pathelement location="${m2.repo}\commons-io\commons-io\1.2\commons-io-1.2.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-host-embedded\2.0-SNAPSHOT\tuscany-host-embedded-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\ws\commons\axiom\axiom-dom\1.2.5\axiom-dom-1.2.5.jar"/>
+ <pathelement location="${m2.repo}\log4j\log4j\1.2.12\log4j-1.2.12.jar"/>
+ <pathelement location="${m2.repo}\javax\mail\mail\1.4\mail-1.4.jar"/>
+ <pathelement location="${m2.repo}\org\apache\axis2\axis2-codegen\1.3\axis2-codegen-1.3.jar"/>
+ <pathelement location="${m2.repo}\org\codehaus\woodstox\wstx-asl\3.2.1\wstx-asl-3.2.1.jar"/>
+ <pathelement location="${m2.repo}\stax\stax-api\1.0.1\stax-api-1.0.1.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface-java-xml\2.0-SNAPSHOT\tuscany-interface-java-xml-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\ws\commons\schema\XmlSchema\1.3.2\XmlSchema-1.3.2.jar"/>
+ <pathelement location="${m2.repo}\xerces\xmlParserAPIs\2.6.2\xmlParserAPIs-2.6.2.jar"/>
+ <pathelement location="${m2.repo}\org\apache\woden\woden\1.0-incubating-M7b\woden-1.0-incubating-M7b.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface\2.0-SNAPSHOT\tuscany-interface-2.0-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\easymock\easymock\2.2\easymock-2.2.jar"/>
+ </path>
+
+ <target name="runServer">
+ <java classname="org.apache.tuscany.sca.itest.oneway.impl.OneWayServer"
+ fork="true">
+ <classpath>
+ <path refid="repo.classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/oneway/pom.xml b/sandbox/sebastien/java/embed/itest/oneway/pom.xml
new file mode 100644
index 0000000000..b0ef9774e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/oneway/pom.xml
@@ -0,0 +1,64 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-oneway</artifactId>
+ <name>Apache Tuscany SCA iTest OneWay</name>
+ <version>2.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>${pom.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java b/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java
new file mode 100644
index 0000000000..ecd239d5fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.oneway;
+
+/**
+ * The client for the oneway itest.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface OneWayClient {
+
+ /**
+ * This method will invoke the doSomething() @OneWay method on the OneWayService
+ * the specified number of times.
+ *
+ * @param count The number of times to invoke doSomething() on the OneWayService
+ */
+ void doSomething(int count);
+
+ /**
+ * This method will invoke a @OneWay method that throws an exception.
+ */
+ void doSomethingWhichThrowsException();
+}
diff --git a/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java b/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java
new file mode 100644
index 0000000000..ba74b67d31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.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.sca.itest.oneway;
+
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The service interface used when testing @OneWay interactions.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface OneWayService {
+
+ /**
+ * This OneWay method will increment the callCount by 1.
+ *
+ * @param count Not used
+ */
+ @OneWay
+ void doSomething(int count);
+
+ /**
+ * This one way method will throw a NullPointerException.
+ */
+ @OneWay
+ void doSomethingWhichThrowsException();
+}
diff --git a/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java b/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java
new file mode 100644
index 0000000000..8ed3c3d638
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.oneway.impl;
+
+import org.apache.tuscany.sca.itest.oneway.OneWayClient;
+import org.apache.tuscany.sca.itest.oneway.OneWayService;
+import org.junit.Assert;
+import org.oasisopen.sca.annotation.Reference;
+
+
+/**
+ * The client for the oneway itest.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OneWayClientImpl implements OneWayClient {
+ /**
+ * Injected reference to the OneWayService.
+ */
+ @Reference
+ protected OneWayService oneWayService;
+
+ /**
+ * Tracks the number of calls of the doSomething() method on the OneWayService.
+ */
+ public static int callCount = 0;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doSomething(int count) {
+ callCount = callCount + count;
+
+ for (int loopCount = 0; loopCount < count; loopCount++) {
+ //System.out.println("Client: doSomething " + loopCount);
+ //System.out.flush();
+ oneWayService.doSomething(loopCount);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doSomethingWhichThrowsException() {
+ Assert.assertNotNull(oneWayService);
+ oneWayService.doSomethingWhichThrowsException();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java b/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java
new file mode 100644
index 0000000000..ef88c22baa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.oneway.impl;
+
+import org.apache.tuscany.sca.itest.oneway.OneWayService;
+
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * The service for the oneway itest.
+ *
+ * @version $Rev$ $Date$
+ */
+
+
+public class OneWayServiceImpl implements OneWayService {
+
+ /**
+ * This is the error message that will be in the Exception thrown by
+ * the doSomethingWhichThrowsException() method.
+ */
+ public static final String EXCEPTION_MESSAGE = "Sample RuntimeException from a @OneWay method";
+
+ /**
+ * Counts the number of invocations to doSomething().
+ */
+ public static final AtomicInteger CALL_COUNT = new AtomicInteger();
+
+ /**
+ * Counts the number of invocations of the doSomethingWhichThrowsException() method.
+ */
+ public static final AtomicInteger CALL_COUNT_FOR_THROWS_EXCEPTION_METHOD = new AtomicInteger();
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doSomething(int count) {
+ CALL_COUNT.incrementAndGet();
+
+ // System.out.println("Service: doSomething " + count + " callCount = " + callCount);
+ // System.out.flush();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doSomethingWhichThrowsException() {
+ System.out.println("OneWay invoked. About to throw an Exception");
+ CALL_COUNT_FOR_THROWS_EXCEPTION_METHOD.incrementAndGet();
+ throw new NullPointerException(EXCEPTION_MESSAGE);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite b/sandbox/sebastien/java/embed/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite
new file mode 100644
index 0000000000..b375944bbd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite
@@ -0,0 +1,57 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://oneway"
+ name="OneWayITest">
+
+ <component name="OneWayClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.oneway.impl.OneWayClientImpl"/>
+ <reference name="oneWayService" target="OneWayServiceComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.oneway.OneWayService" />
+ </reference>
+ </component>
+
+ <component name="OneWayServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.oneway.impl.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <interface.java interface="org.apache.tuscany.sca.itest.oneway.OneWayService" />
+ <binding.ws uri="http://localhost:8085/OneWayServiceComponent"/>
+ </service>
+ </component>
+
+
+ <!-- OneWay Client and Server Components that use the standard SCA Binding so we can validate -->
+ <!-- that the NonBlockingInterceptor logs an message when an Exception is thrown by the code -->
+ <!-- that is called. See TUSCANY-2225 -->
+ <component name="OneWayClientComponentSCABinding">
+ <implementation.java class="org.apache.tuscany.sca.itest.oneway.impl.OneWayClientImpl"/>
+ <reference name="oneWayService" target="OneWayServiceComponentSCABinding">
+ <interface.java interface="org.apache.tuscany.sca.itest.oneway.OneWayService" />
+ </reference>
+ </component>
+
+ <component name="OneWayServiceComponentSCABinding">
+ <implementation.java class="org.apache.tuscany.sca.itest.oneway.impl.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <interface.java interface="org.apache.tuscany.sca.itest.oneway.OneWayService" />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java b/sandbox/sebastien/java/embed/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java
new file mode 100644
index 0000000000..1f771ea4ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.oneway;
+
+import java.io.File;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
+import org.apache.tuscany.sca.itest.oneway.impl.OneWayClientImpl;
+import org.apache.tuscany.sca.itest.oneway.impl.OneWayServiceImpl;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This test case will test invoking @OneWay operations.
+ *
+ * @version $Date$ $Revision$
+ */
+public class OneWayTestCase {
+ /**
+ * Maximum period of time that we are prepared to wait for all the @OneWay
+ * method calls to complete in milliseconds.
+ */
+ private static final int MAX_SLEEP_TIME = 10000;
+
+ private Node node;
+
+ /**
+ * Initialise the SCADomain.
+ *
+ * @throws Exception Failed to initialise the SCADomain
+ */
+ @Before
+ public void setUp() throws Exception {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/OneWayContribution/META-INF/sca-deployables/").toURI().toURL().toString()));
+ node.start();
+
+ }
+
+ /**
+ * This method will ensure that the SCADomain is shutdown.
+ *
+ * @throws Exception Failed to shutdown the SCADomain
+ */
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+ /**
+ * This test will test repeatedly calling a @OneWay operation and ensure that the correct
+ * number of @OneWay operations are run.
+ *
+ * @throws Exception Test failed
+ */
+ @Test
+ public void testOneWay() throws Exception {
+ OneWayClient client =
+ node.getService(OneWayClient.class, "OneWayClientComponent");
+
+ int count = 100;
+
+ for (int i = 0; i < 10; i++) {
+ // System.out.println("Test: doSomething " + count);
+ // System.out.flush();
+ client.doSomething(count);
+
+ // TUSCANY-2192 - We need to sleep to allow the @OneWay method calls to complete.
+ // Note: This can take different periods depending on the speed and load
+ // on the computer where the test is being run.
+ // This loop will wait for the required number of @OneWay method calls to
+ // have taken place or MAX_SLEEP_TIME to have passed.
+ long startSleep = System.currentTimeMillis();
+ while (OneWayClientImpl.callCount != OneWayServiceImpl.CALL_COUNT.get()
+ && System.currentTimeMillis() - startSleep < MAX_SLEEP_TIME) {
+ Thread.sleep(100);
+ // System.out.println("" + OneWayClientImpl.callCount + "," + OneWayServiceImpl.callCount);
+ }
+
+ System.out.println("Finished callCount = " + OneWayServiceImpl.CALL_COUNT);
+
+ Assert.assertEquals(OneWayClientImpl.callCount, OneWayServiceImpl.CALL_COUNT.get());
+ }
+ }
+
+ /**
+ * This method will invoke a @OneWay method that throws an exception
+ * when invoked over a SCA Binding which uses the NonBlockingInterceptor and
+ * ensure that the Exception is logged.
+ * See TUSCANY-2225
+ */
+ @Test
+ public void testOneWayUsingNonBlockingInterceptorThrowsAnException() {
+ OneWayClient client =
+ node.getService(OneWayClient.class, "OneWayClientComponentSCABinding");
+
+ // We need to modify the JDK Logger for the NonBlockingInterceptor so we
+ // can check that it logs a message for the @OneWay invocation that throws
+ // an Exception
+ Logger nbiLogger = Logger.getLogger(NonBlockingInterceptor.class.getName());
+ DummyJDKHandler handler = new DummyJDKHandler();
+ nbiLogger.addHandler(handler);
+
+ // Add a message on the console to explain the stack dump that is going to be
+ // displayed and state that this is not a problem but expected behaviour
+ System.out.println();
+ System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
+ System.out.println("IMPORTANT: The error message that appears on the console");
+ System.out.println("below is an expected error if it is a NullPointerException");
+ System.out.println(" with the message of:");
+ System.out.println(" \"" + OneWayServiceImpl.EXCEPTION_MESSAGE + "\"");
+ System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
+ System.out.println();
+ System.out.flush();
+
+ // Invoke the @OneWay method that throws an exception
+ client.doSomethingWhichThrowsException();
+
+ // The logging is done asynchronously so we will need to wait a bit before
+ // the log message appears.
+ long start = System.currentTimeMillis();
+ boolean logged = false;
+ while (System.currentTimeMillis() - start < MAX_SLEEP_TIME && !logged) {
+ // Has the log message been logged?
+ if (handler.exceptionLogged.get()) {
+ logged = true;
+ } else {
+ try {
+ Thread.sleep(25);
+ } catch (InterruptedException ex) {
+ Assert.fail("Unexpected exception " + ex);
+ }
+ }
+ }
+
+ // Add a message explaining that errors beyond this point should be reported
+ System.out.println();
+ System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
+ System.out.println("End of expected exceptions. Any errors beyond this point are errors!");
+ System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
+ System.out.println();
+ System.out.flush();
+
+ // Remove the handler
+ nbiLogger.removeHandler(handler);
+
+ // Make sure that the exception was logged
+ Assert.assertTrue(handler.exceptionLogged.get());
+ }
+
+ /**
+ * A handler that is added to the JDK Logging system to examine the log messages
+ * generated to ensure that a @OneWay method that throws an Exception will
+ * generate a log message.
+ */
+ private class DummyJDKHandler extends Handler {
+
+ /**
+ * Used to track whether the exception has been logged.
+ */
+ private AtomicBoolean exceptionLogged = new AtomicBoolean(false);
+
+ /**
+ * Constructor.
+ */
+ private DummyJDKHandler() {
+ super.setLevel(Level.ALL);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void close() throws SecurityException {
+ // Nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void flush() {
+ // Nothing to do
+ }
+
+ /**
+ * Examines the LogRecord and checks whether it matches the one we are looking for.
+ * If it matches, it will set exceptionLogged to True.
+ *
+ * @param record The Log Record that is being published
+ */
+ @Override
+ public void publish(LogRecord record) {
+ // The log message we are looking for is Severe
+ if (record.getLevel() == Level.SEVERE) {
+ if (record.getThrown() != null
+ && record.getThrown().toString().indexOf(
+ OneWayServiceImpl.EXCEPTION_MESSAGE) != -1) {
+ // We have found our Exception.
+ exceptionLogged.set(true);
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/operation-overloading/pom.xml b/sandbox/sebastien/java/embed/itest/operation-overloading/pom.xml
new file mode 100644
index 0000000000..48410a4b47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/operation-overloading/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-operation-overloading</artifactId>
+ <name>Apache Tuscany SCA iTest Operation Overloading</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java b/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java
new file mode 100644
index 0000000000..1f589b44f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.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.sca.test.opoverload;
+
+/**
+ * This is an Interface which has methods declared but not implemented, These methods will be implemented in
+ * OverloadATarget Class and OverloadASource This class has methods with overloaded parameters.
+ */
+
+//@AllowsPassByReference
+public interface OverloadASourceTarget {
+ String opName = "operationA:";
+
+ /**
+ * Method with no parameters
+ */
+ String operationA();
+
+ /**
+ * Method with one integer parameter
+ */
+ String operationA(int parm1);
+
+ /**
+ * Method with one integer parameter and one string parameter
+ */
+ String operationA(int parm1, String parm2);
+
+ /**
+ * Method with one one string parameter and one integer parameter
+ */
+ String operationA(String parm1, int parm2);
+
+ /**
+ * Method with one string parameter
+ */
+ String operationA(String string);
+
+ /**
+ * Method which throws an illegal argument exception in case of any exceptions.
+ */
+ String[] operationAall();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadASource.java b/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadASource.java
new file mode 100644
index 0000000000..a30d3611fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadASource.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.sca.test.opoverload.impl;
+
+import java.util.ArrayList;
+
+import org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class Implements the interface OverloadASourceTarget, and gives implementation for all methods which are
+ * declared in the OverloadASourceTarget interface.
+ */
+@Service(OverloadASourceTarget.class)
+public class OverloadASource implements OverloadASourceTarget {
+ public OverloadASourceTarget overloadASourceTarget;
+
+ /**
+ * This is a default constructor
+ */
+ public OverloadASource() {
+
+ }
+
+ /**
+ * @return
+ * @see org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget#operationA()
+ */
+ public String[] operationAall() {
+ assert overloadASourceTarget != null : "reference overloadASourceTarget is null";
+ ArrayList<String> ret = new ArrayList<String>();
+ ret.add(overloadASourceTarget.operationA());
+ ret.add(overloadASourceTarget.operationA(11));
+ ret.add(overloadASourceTarget.operationA("eleven"));
+ ret.add(overloadASourceTarget.operationA(3, "three"));
+ ret.add(overloadASourceTarget.operationA("four", 4));
+ return (String[])ret.toArray(new String[ret.size()]);
+ }
+
+ /**
+ * @return
+ * @see org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget#operationA()
+ */
+ public String operationA() {
+ assert overloadASourceTarget != null : "reference overloadASourceTarget is null";
+ return overloadASourceTarget.operationA();
+ }
+
+ /**
+ * @param parm1
+ * @return
+ * @see org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget#operationA(int)
+ */
+ public String operationA(int parm1) {
+ assert overloadASourceTarget != null : "reference overloadASourceTarget is null";
+ return overloadASourceTarget.operationA(parm1);
+ }
+
+ /**
+ * @param parm1
+ * @param parm2
+ * @return
+ * @see org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget#operationA(int, java.lang.String)
+ */
+ public String operationA(int parm1, String parm2) {
+ assert overloadASourceTarget != null : "reference overloadASourceTarget is null";
+ return overloadASourceTarget.operationA(parm1, parm2);
+ }
+
+ public String operationA(String string) {
+ assert overloadASourceTarget != null : "reference overloadASourceTarget is null";
+ return overloadASourceTarget.operationA(string);
+ }
+
+ /**
+ * @param parm1
+ * @param parm2
+ * @return
+ * @see org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget#operationA(java.lang.String, int)
+ */
+ public String operationA(String parm1, int parm2) {
+ assert overloadASourceTarget != null : "reference overloadASourceTarget is null";
+ return overloadASourceTarget.operationA(parm1, parm2);
+ }
+
+ /**
+ * This method which is used by all the overloaded functions to set the source target
+ */
+ @Reference
+ public void setOverloadASourceTarget(OverloadASourceTarget overloadASourceTarget) {
+ assert overloadASourceTarget != null : "reference overloadASourceTarget is set tonull";
+ this.overloadASourceTarget = overloadASourceTarget;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATarget.java b/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATarget.java
new file mode 100644
index 0000000000..9ec60eb78f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATarget.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.opoverload.impl;
+
+import org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class Implements the interface OverloadASourceTarget, and gives implementation for all methods which are
+ * declared in the OverloadASourceTarget interface.
+ */
+@Service(OverloadASourceTarget.class)
+public class OverloadATarget implements OverloadASourceTarget {
+
+ /**
+ * This is a default Constructor
+ */
+ public OverloadATarget() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget#operationA(int)
+ */
+ public String operationA(int parm1) {
+ final String ret = opName + parm1;
+ out(ret);
+ return ret;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget#operationA(int, java.lang.String)
+ */
+ public String operationA(int parm1, String parm2) {
+ final String ret = opName + parm1 + parm2;
+ out(ret);
+ return ret;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget#operationA()
+ */
+ public String operationA() {
+ out(opName);
+ return opName;
+
+ }
+
+ public String operationA(String parm1, int parm2) {
+ final String ret = opName + parm1 + parm2;
+ out(ret);
+ return ret;
+ }
+
+ public String operationA(String parm1) {
+ final String ret = opName + parm1;
+ out(ret);
+ return ret;
+ }
+
+ /**
+ * This method is used to print the message returned by all the overloaded functions
+ */
+ private void out(String msg) {
+
+ java.lang.System.out.println(msg);
+ }
+
+ public String[] operationAall() {
+ throw new IllegalArgumentException("not supported");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/resources/OperationOverload.composite b/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/resources/OperationOverload.composite
new file mode 100644
index 0000000000..cbf5aa2078
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/operation-overloading/src/main/resources/OperationOverload.composite
@@ -0,0 +1,34 @@
+<?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://foo"
+ xmlns:foo="http://foo"
+ name="OperationOverload">
+
+ <component name="OverloadASourceComponent">
+ <implementation.java class="org.apache.tuscany.sca.test.opoverload.impl.OverloadASource" />
+ <reference name="overloadASourceTarget" target="OverloadATargetComponent"/>
+ </component>
+
+ <component name="OverloadATargetComponent">
+ <implementation.java class="org.apache.tuscany.sca.test.opoverload.impl.OverloadATarget" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/operation-overloading/src/test/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATestCase.java b/sandbox/sebastien/java/embed/itest/operation-overloading/src/test/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATestCase.java
new file mode 100644
index 0000000000..62e5c14ce2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/operation-overloading/src/test/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATestCase.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.test.opoverload.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.test.opoverload.OverloadASourceTarget;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+public class OverloadATestCase {
+
+ private static Node node;
+ private static OverloadASourceTarget overloadA;
+
+ /**
+ * Method prefixed with 'test' is a test method where testing logic is written using various assert methods. This
+ * test verifies the values compared are same as the values retrieved from the SCA runtime.
+ */
+ @Test
+ public void testOperationAall() {
+ String[] result = overloadA.operationAall();
+ assertEquals(5, result.length);
+ assertEquals(OverloadASourceTarget.opName, result[0]);
+ assertEquals(OverloadASourceTarget.opName + 11, result[1]);
+ assertEquals(OverloadASourceTarget.opName + "eleven", result[2]);
+ assertEquals(OverloadASourceTarget.opName + 3 + "three", result[3]);
+ assertEquals(OverloadASourceTarget.opName + "four" + 4, result[4]);
+ }
+
+ @Test
+ public void testOperationAInt() {
+ String result = overloadA.operationA(29);
+ assertEquals(OverloadASourceTarget.opName + 29, result);
+ }
+
+ @Test
+ public void testOperationAString() {
+ String result = overloadA.operationA("rick:-)");
+ assertEquals(OverloadASourceTarget.opName + "rick:-)", result);
+ }
+
+ @Test
+ public void testOperationAIntString() {
+ String result = overloadA.operationA(123, "Tuscany");
+ assertEquals(OverloadASourceTarget.opName + 123 + "Tuscany", result);
+ }
+
+ @Test
+ public void testOperationStringInt() {
+ String result = overloadA.operationA("StringInt", 77);
+ assertEquals(OverloadASourceTarget.opName + "StringInt" + 77, result);
+ }
+
+ /**
+ * setUp() is a method in JUnit Frame Work which is executed before all others methods in the class extending
+ * unit.framework.TestCase. So this method is used to create a test Embedded SCA node, to start the SCA node and
+ * to get a reference to the contribution service
+ */
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("OperationOverload.composite");
+ node = NodeFactory.newInstance().createNode("OperationOverload.composite", new Contribution("c1", location));
+ node.start();
+ overloadA = node.getService(OverloadASourceTarget.class, "OverloadASourceComponent");
+ }
+
+ /**
+ * tearDown() is a method in JUnit Frame Work which is executed after all other methods in the class extending
+ * unit.framework.TestCase. So this method is used to close the SCA node.
+ */
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/pom.xml b/sandbox/sebastien/java/embed/itest/policies/pom.xml
new file mode 100644
index 0000000000..daa3e395f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/pom.xml
@@ -0,0 +1,59 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-policies</artifactId>
+ <name>Apache Tuscany SCA iTest Policies</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-logging</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java
new file mode 100644
index 0000000000..fd33be01d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.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.sca.itest.policies;
+
+import java.io.Serializable;
+
+/**
+ * Credit Card
+ */
+public class CreditCard implements Serializable {
+ private static final long serialVersionUID = -6107293191546007197L;
+ private String type;
+ private String number;
+ private String owner;
+ private int expMonth;
+ private int expYear;
+
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getNumber() {
+ return number;
+ }
+ public void setNumber(String number) {
+ this.number = number;
+ }
+ public String getOwner() {
+ return owner;
+ }
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+ public int getExpMonth() {
+ return expMonth;
+ }
+ public void setExpMonth(int expMonth) {
+ this.expMonth = expMonth;
+ }
+ public int getExpYear() {
+ return expYear;
+ }
+ public void setExpYear(int expYear) {
+ this.expYear = expYear;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java
new file mode 100644
index 0000000000..368179dc29
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.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.sca.itest.policies;
+
+import org.oasisopen.sca.annotation.Authentication;
+import org.oasisopen.sca.annotation.Confidentiality;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ */
+@Remotable
+@Authentication
+public interface CreditCardPayment {
+ String COMPLETED = "Completed";
+ String REJECTED = "Rejected";
+
+ @Confidentiality
+ String authorize(CreditCard creditCard, float amount);
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java
new file mode 100644
index 0000000000..05ea341466
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.policies;
+
+import java.io.Serializable;
+
+/**
+ * Customer
+ */
+public class Customer implements Serializable {
+ private static final long serialVersionUID = 680227659536711695L;
+ private String id;
+ private String name;
+ private CreditCard creditCard;
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public CreditCard getCreditCard() {
+ return creditCard;
+ }
+ public void setCreditCard(CreditCard creditCard) {
+ this.creditCard = creditCard;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java
new file mode 100644
index 0000000000..c9f50d08ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.policies;
+
+/**
+ *
+ */
+public interface CustomerRegistry {
+ Customer find(String id);
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java
new file mode 100644
index 0000000000..cc7c555aff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.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.itest.policies;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface Payment {
+ String charge(String customerID, float amount);
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java
new file mode 100644
index 0000000000..01cc8ac636
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.policies.impl;
+
+import org.apache.tuscany.sca.itest.policies.CreditCard;
+import org.apache.tuscany.sca.itest.policies.CreditCardPayment;
+
+/**
+ *
+ */
+public class CreditCardPaymentImpl implements CreditCardPayment {
+
+ public String authorize(CreditCard creditCard, float amount) {
+ System.out.println(creditCard.getType() + " " + creditCard.getNumber());
+ System.out.println(amount);
+ if (amount < 200f) {
+ return COMPLETED;
+ } else {
+ return REJECTED;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java
new file mode 100644
index 0000000000..943720451f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.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.itest.policies.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.itest.policies.CreditCard;
+import org.apache.tuscany.sca.itest.policies.Customer;
+import org.apache.tuscany.sca.itest.policies.CustomerRegistry;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(CustomerRegistry.class)
+@Scope("COMPOSITE")
+public class CustomerRegistryImpl implements CustomerRegistry {
+ private Map<String, Customer> customers = new HashMap<String, Customer>();
+
+
+ @Init
+ public void init() {
+ Customer c1 = new Customer();
+ c1.setId("001");
+ c1.setName("John Smith");
+ CreditCard creditCard = new CreditCard();
+ creditCard.setNumber("1234-5678-1234");
+ creditCard.setType("Visa");
+ creditCard.setOwner("John Smith");
+ creditCard.setExpMonth(6);
+ creditCard.setExpYear(2015);
+ c1.setCreditCard(creditCard);
+ customers.put(c1.getId(), c1);
+
+ Customer c2 = new Customer();
+ c2.setId("002");
+ c2.setName("Jane Smith");
+ creditCard = new CreditCard();
+ creditCard.setNumber("1234-5678-5678");
+ creditCard.setType("MasterCard");
+ creditCard.setOwner("Jane Smith");
+ creditCard.setExpMonth(9);
+ creditCard.setExpYear(2012);
+ c2.setCreditCard(creditCard);
+ customers.put(c2.getId(), c2);
+ }
+
+ public Customer find(String id) {
+ return customers.get(id);
+ }
+
+ @Destroy
+ public void destroy() {
+ customers.clear();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java
new file mode 100644
index 0000000000..b712b99388
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.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.sca.itest.policies.impl;
+
+import org.apache.tuscany.sca.itest.policies.CreditCard;
+import org.apache.tuscany.sca.itest.policies.CreditCardPayment;
+import org.apache.tuscany.sca.itest.policies.Customer;
+import org.apache.tuscany.sca.itest.policies.CustomerRegistry;
+import org.apache.tuscany.sca.itest.policies.Payment;
+import org.apache.tuscany.sca.policy.logging.Logging;
+import org.oasisopen.sca.annotation.Authentication;
+import org.oasisopen.sca.annotation.Confidentiality;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Requires;
+
+/**
+ *
+ */
+@Logging
+public class PaymentImpl implements Payment {
+
+ @Reference
+ protected CustomerRegistry customerRegistry;
+
+ @Reference
+ @Authentication
+ @Requires({Confidentiality.CONFIDENTIALITY_MESSAGE, Confidentiality.CONFIDENTIALITY_TRANSPORT})
+ protected CreditCardPayment creditCardPayment;
+
+ public String charge(String customerID, float amount) {
+ Customer customer = customerRegistry.find(customerID);
+ CreditCard creditCard = customer.getCreditCard();
+ String status = creditCardPayment.authorize(creditCard, amount);
+ return status;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/resources/Customer.composite b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/Customer.composite
new file mode 100644
index 0000000000..7c66c741f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/Customer.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:c="http://customer"
+ targetNamespace="http://customer"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="Customer">
+
+ <service name="Registry" promote="CustomerRegistry" requires="tuscany:logging">
+ <binding.sca/>
+ </service>
+
+ <component name="CustomerRegistry">
+ <implementation.java class="org.apache.tuscany.sca.itest.policies.impl.CustomerRegistryImpl" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/resources/LoggingMessages.properties b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/LoggingMessages.properties
new file mode 100644
index 0000000000..ada808be0e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/LoggingMessages.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/sebastien/java/embed/itest/policies/src/main/resources/META-INF/definitions.xml b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/META-INF/definitions.xml
new file mode 100644
index 0000000000..d607832554
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/META-INF/definitions.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <policySet name="JDKLoggingPolicy"
+ provides="tuscany:logging"
+ appliesTo="//binding | //implementation">
+ <tuscany:jdkLogger name="test.logger">
+ <tuscany:logLevel>FINE</tuscany:logLevel>
+ <tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+ </tuscany:jdkLogger>
+
+ </policySet>
+
+ <policySet name="JDKLoggingImplPolicy"
+ provides="tuscany:logging"
+ appliesTo="//implementation.java"
+ attachTo="//sca:component[@name='CreditCardPayment']">
+ <tuscany:jdkLogger name="test.logger">
+ <tuscany:logLevel>INFO</tuscany:logLevel>
+ <tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+ </tuscany:jdkLogger>
+
+ </policySet>
+
+ <!-- A set of policy sets introduced just to ensure that intents are resolved -->
+
+ <policySet name="SuspendsTransactionPolicy"
+ provides="sca:suspendsTransaction"
+ appliesTo="//binding.sca | //implementation.java"
+ attachTo="IntentRefs('sca:suspendsTransaction')"/>
+
+ <policySet name="AuthorizationFineGrainPolicy"
+ provides="sca:authorization.fineGrain"
+ appliesTo="//binding.sca | //implementation.java"
+ attachTo="IntentRefs('sca:authorization') | IntentRefs('sca:authorization.fineGrain')"/>
+
+ <policySet name="ConfidentialityTransportPolicy"
+ provides="sca:confidentiality.transport"
+ appliesTo="//binding.sca | //implementation.java"
+ attachTo="IntentRefs('sca:confidentiality.transport')"/>
+
+ <policySet name="ConfidentialityMessagePolicy"
+ provides="sca:confidentiality.message"
+ appliesTo="//binding.sca | //implementation.java"
+ attachTo="IntentRefs('sca:confidentiality.message')"/>
+
+ <policySet name="ClientAuthenticationTransportPolicy"
+ provides="sca:clientAuthentication.transport"
+ appliesTo="//binding.sca | //implementation.java"
+ attachTo="IntentRefs('sca:clientAuthentication.transport') | //sca:service[@name='CreditCardPayment']"/>
+
+ <policySet name="IntegrityTransportPolicy"
+ provides="sca:integrity.transport"
+ appliesTo="//binding.sca | //implementation.java"
+ attachTo="IntentRefs('sca:integrity.transport')"/>
+
+ <policySet name="ManagedTransactionGlobalPolicy"
+ provides="sca:managedTransaction.global"
+ appliesTo="//implementation.composite | //implementation.java"
+ attachTo="IntentRefs('sca:managedTransaction.global')"/>
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..d5d1840754
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:p="http://payment">
+ <deployable composite="p:Payment" />
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/main/resources/Payment.composite b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/Payment.composite
new file mode 100644
index 0000000000..20124467b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/main/resources/Payment.composite
@@ -0,0 +1,57 @@
+<?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.
+-->
+
+<!--
+ NOTE - policy sets all defined at top level as external attach functions
+ not working yet so it's difficult to know precisely where to
+ attach policy to
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:p="http://payment"
+ xmlns:c="http://customer"
+ xmlns:sca = "http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ requires = "sca:authorization"
+ targetNamespace="http://payment"
+ name="Payment"
+ policySets="tuscany:JDKLoggingPolicy tuscany:JDKLoggingImplPolicy tuscany:SuspendsTransactionPolicy tuscany:AuthorizationFineGrainPolicy tuscany:ConfidentialityTransportPolicy tuscany:ConfidentialityMessagePolicy tuscany:ClientAuthenticationTransportPolicy tuscany:IntegrityTransportPolicy">
+
+ <component name="Payment">
+ <implementation.java class="org.apache.tuscany.sca.itest.policies.impl.PaymentImpl" />
+ <reference name="creditCardPayment" target="CreditCardPayment">
+ <binding.sca requires="sca:integrity tuscany:logging">
+ </binding.sca>
+ </reference>
+ <reference name="customerRegistry" target="Customer/Registry" requires="sca:suspendsTransaction tuscany:logging"/>
+ </component>
+
+ <component name="CreditCardPayment">
+ <implementation.java class="org.apache.tuscany.sca.itest.policies.impl.CreditCardPaymentImpl" />
+ <service name="CreditCardPayment" requires="tuscany:logging sca:confidentiality.message sca:confidentiality.transport"/>
+ </component>
+
+ <component name="Customer" requires="tuscany:logging">
+ <implementation.composite name="c:Customer" requires="sca:managedTransaction.global"/>
+ <service name="Registry" requires="sca:suspendsTransaction">
+ <binding.sca/>
+ </service>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java b/sandbox/sebastien/java/embed/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java
new file mode 100644
index 0000000000..3385ee9071
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.policies;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class PaymentTestCase {
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String location = ContributionLocationHelper.getContributionLocation("Payment.composite");
+ node = NodeFactory.newInstance().createNode(new Contribution("c1", location));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testPayment() {
+ Payment payment = node.getService(Payment.class, "Payment");
+ String status = payment.charge("001", 100f);
+ Assert.assertEquals(CreditCardPayment.COMPLETED, status);
+
+ status = payment.charge("002", 300f);
+ Assert.assertEquals(CreditCardPayment.REJECTED, status);
+ }
+
+ public static void main(String[] args) throws Exception {
+ PaymentTestCase.init();
+ PaymentTestCase tester = new PaymentTestCase();
+ tester.testPayment();
+ PaymentTestCase.destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy-transaction/pom.xml b/sandbox/sebastien/java/embed/itest/policy-transaction/pom.xml
new file mode 100644
index 0000000000..d18e19e957
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy-transaction/pom.xml
@@ -0,0 +1,72 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-policy-transaction</artifactId>
+ <name>Apache Tuscany SCA iTest Policy Transaction</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-transaction-runtime-geronimo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.3</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.5.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/Customer.java b/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/Customer.java
new file mode 100644
index 0000000000..b58547bf47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/Customer.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 customer;
+
+import java.io.Serializable;
+
+/**
+ * Customer
+ */
+public class Customer implements Serializable {
+ private static final long serialVersionUID = 680227659536711695L;
+ private String id;
+ private String name;
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/CustomerRegistry.java b/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/CustomerRegistry.java
new file mode 100644
index 0000000000..4a05f0d0a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/CustomerRegistry.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 customer;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface CustomerRegistry {
+ Customer find(String id);
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/impl/CustomerRegistryImpl.java b/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/impl/CustomerRegistryImpl.java
new file mode 100644
index 0000000000..d2d6aa1f44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/java/customer/impl/CustomerRegistryImpl.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 customer.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+import customer.Customer;
+import customer.CustomerRegistry;
+
+/**
+ *
+ */
+@Scope("COMPOSITE")
+@Service(CustomerRegistry.class)
+public class CustomerRegistryImpl implements CustomerRegistry {
+ private Map<String, Customer> customers = new HashMap<String, Customer>();
+
+ @Init
+ public void init() {
+ Customer c1 = new Customer();
+ c1.setId("001");
+ c1.setName("John Smith");
+ customers.put(c1.getId(), c1);
+
+ Customer c2 = new Customer();
+ c2.setId("002");
+ c2.setName("Jane Smith");
+ customers.put(c2.getId(), c2);
+ }
+
+ public Customer find(String id) {
+ return customers.get(id);
+ }
+
+ @Destroy
+ public void destroy() {
+ customers.clear();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/resources/Customer.composite b/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/resources/Customer.composite
new file mode 100644
index 0000000000..7047de3663
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy-transaction/src/main/resources/Customer.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:c="http://customer"
+ targetNamespace="http://customer"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="CustomerTransaction">
+
+ <component name="CustomerRegistryComponent">
+ <implementation.java class="customer.impl.CustomerRegistryImpl" requires="managedTransaction.local"/>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policy-transaction/src/test/java/org/apache/tuscany/sca/itest/policy/transaction/CustomerTestCase.java b/sandbox/sebastien/java/embed/itest/policy-transaction/src/test/java/org/apache/tuscany/sca/itest/policy/transaction/CustomerTestCase.java
new file mode 100644
index 0000000000..2d83cd0ee5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy-transaction/src/test/java/org/apache/tuscany/sca/itest/policy/transaction/CustomerTestCase.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.policy.transaction;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import customer.Customer;
+import customer.CustomerRegistry;
+
+public class CustomerTestCase {
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String location = ContributionLocationHelper.getContributionLocation("Customer.composite");
+ node = NodeFactory.newInstance().createNode("Customer.composite",new Contribution("c1", location));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testCustomer() {
+ CustomerRegistry customerRegistry = node.getService(CustomerRegistry.class, "CustomerRegistryComponent");
+ Customer customer = customerRegistry.find("001");
+ Assert.assertEquals(customer.getName(), "John Smith");
+ }
+
+ public static void main(String[] args) throws Exception {
+ CustomerTestCase.init();
+ CustomerTestCase tester = new CustomerTestCase();
+ tester.testCustomer();
+ CustomerTestCase.destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/pom.xml b/sandbox/sebastien/java/embed/itest/policy/matching/pom.xml
new file mode 100644
index 0000000000..d3dca04a64
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/pom.xml
@@ -0,0 +1,58 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-policy-matching</artifactId>
+ <name>Apache Tuscany SCA iTest Policy Matching</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-wspolicy</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-logging</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..16db3fd9fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.matching.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..d34591713b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/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 org.apache.tuscany.sca.policy.matching.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorld;
+
+ public String getGreetings(String s) {
+ String response = helloWorld.getGreetings(s);
+ System.out.println("At client: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..31a2d2cb89
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/java/org/apache/tuscany/sca/policy/matching/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 org.apache.tuscany.sca.policy.matching.helloworld;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ String response = "Hello " + s;
+ System.out.println("At service: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..6ae1c88c42
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/policy">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..45b6be47b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/policy/matching/helloworld/definitions.xml \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
new file mode 100644
index 0000000000..f37b1ee739
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <intent name="testIntent1" constrains="sca:binding" intentType="interaction"/>
+
+ <intent name="testIntent2" constrains="sca:binding" intentType="interaction"/>
+
+ <intent name="testIntent3" constrains="sca:binding" intentType="interaction" excludes="tuscany:testIntent1" />
+
+ <intent name="testIntent4" constrains="sca:binding" intentType="interaction"/>
+
+ <intent name="testIntent5" constrains="sca:binding" intentType="interaction"/>
+
+ <intent name="testIntent6" constrains="sca:binding" intentType="interaction"/>
+
+ <policySet name="testPolicy1"
+ provides="tuscany:testIntent1"
+ appliesTo="//binding | //implementation">
+ </policySet>
+
+ <policySet name="testPolicy2"
+ provides="tuscany:testIntent4 tuscany:testIntent5"
+ appliesTo="//binding | //implementation">
+ <tuscany:jdkLogger name="test.logger">
+ <tuscany:logLevel>FINE</tuscany:logLevel>
+ <tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+ </tuscany:jdkLogger>
+ </policySet>
+
+ <policySet name="testPolicy3"
+ provides="tuscany:testIntent6"
+ appliesTo="//binding | //implementation">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <tuscany:jdkLogger name="test.logger">
+ <tuscany:logLevel>FINE</tuscany:logLevel>
+ <tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+ </tuscany:jdkLogger>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
new file mode 100644
index 0000000000..7dfe083bae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
@@ -0,0 +1,86 @@
+<?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.
+-->
+
+<!--
+ NOTE - not using external attachment yet in this test because the
+ policy xpath functions are not working yet
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/policy"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="HelloWorld">
+
+ <component name="HelloWorldClientMutuallyExclusiveIntents">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+ <reference name="helloWorld" target="HelloWorldService2" requires="tuscany:testIntent3"/>
+ </component>
+
+ <component name="HelloWorldClientNoIntentsOrPolicies">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+ <reference name="helloWorld" target="HelloWorldService1" />
+ </component>
+
+ <component name="HelloUnresolvedIntentsOnReference">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+ <reference name="helloWorld" target="HelloWorldService2" requires="tuscany:testIntent1 tuscany:testIntent2" policySets="tuscany:testPolicy1"/>
+ </component>
+
+ <component name="HelloWorldClientIntentsButNoPolicies1">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+ <reference name="helloWorld" target="HelloWorldService2" />
+ </component>
+
+ <component name="HelloWorldClientIntentsButNoPolicies2">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+ <reference name="helloWorld" target="HelloWorldService2" requires="tuscany:testIntent1" policySets="tuscany:testPolicy1"/>
+ </component>
+
+ <component name="HelloWorldClientSomePoliciesOnOneSideButNoneOnTheOther">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+ <reference name="helloWorld" target="HelloWorldService3" />
+ </component>
+
+ <component name="HelloWorldClientPolicySetQNameMatch">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+ <reference name="helloWorld" target="HelloWorldService3" requires="tuscany:testIntent5" policySets="tuscany:testPolicy2"/>
+ </component>
+
+ <component name="HelloWorldClientDifferentPolicyLanguage">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+ <reference name="helloWorld" target="HelloWorldService3" requires="tuscany:testIntent6" policySets="tuscany:testPolicy3"/>
+ </component>
+
+ <component name="HelloWorldService1">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldService"/>
+ <service name="HelloWorld"/>
+ </component>
+
+ <component name="HelloWorldService2">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldService"/>
+ <service name="HelloWorld" requires="tuscany:testIntent1" policySets="tuscany:testPolicy1"/>
+ </component>
+
+ <component name="HelloWorldService3">
+ <implementation.java class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldService"/>
+ <service name="HelloWorld" requires="tuscany:testIntent4" policySets="tuscany:testPolicy2"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..a352696b8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.wsdl
@@ -0,0 +1,90 @@
+<?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="HelloWorldSoapPort1">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService1"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java b/sandbox/sebastien/java/embed/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java
new file mode 100644
index 0000000000..d5112e5312
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.matching;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.policy.matching.helloworld.HelloWorld;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/*
+ * Test the various conditions in the matching algorithm
+ * 1 - FAIL if there are intents that are mutually exclusive between reference and service
+ * 2 - PASS if there are no intents or policies present at reference and service
+ * 3 - FAIL if there are unresolved intents (intents with no policy set) at the reference (service should have been checked previously)
+ * 4 - PASS if there are no policies at reference and service (now we know all intents are resolved)
+ * 5 - FAIL if there are some policies on one side but not on the other
+ * 6 - PASS if the QName of the policy sets on each side match
+ * 7 - FAIL if the policy languages on both sides are different
+ * 8 - Perform policy specific match
+ */
+public class MatchingTestCase {
+
+ private static Node node;
+
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ node = NodeFactory.newInstance().createNode(new Contribution("test", "target/classes"));
+ node.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testMutuallyExclusiveIntents() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientMutuallyExclusiveIntents");
+ try {
+ helloWorld.getGreetings("petra");
+ fail("Exception expected");
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().indexOf("No match because the following intents are mutually exclusive {http://tuscany.apache.org/xmlns/sca/1.1}testIntent3 {http://tuscany.apache.org/xmlns/sca/1.1}testIntent1") > -1);
+ }
+ }
+
+ @Test
+ public void testNoIntentsOrPolicies() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientNoIntentsOrPolicies");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Test
+ public void testUnresolvedIntentsOnReference() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloUnresolvedIntentsOnReference");
+ try {
+ helloWorld.getGreetings("petra");
+ fail("Exception expected");
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().indexOf("No match because there are unresolved intents [{http://tuscany.apache.org/xmlns/sca/1.1}testIntent2]") > -1);
+ }
+ }
+
+ @Test
+ public void testIntentsButNoPolicies() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientIntentsButNoPolicies1");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClientIntentsButNoPolicies2");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Test
+ public void testSomePoliciesOnOneSideButNoneOnTheOther() throws Exception {
+ try {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientSomePoliciesOnOneSideButNoneOnTheOther");
+ helloWorld.getGreetings("petra");
+ fail("Exception expected");
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().indexOf("No match because there are policy sets at the endpoint but not at the endpoint reference") > -1);
+ }
+ }
+
+ @Test
+ public void testPolicySetQNameMatch() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientPolicySetQNameMatch");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Test
+ public void testDifferentPolicyLanguage() throws Exception {
+ try {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientDifferentPolicyLanguage");
+ helloWorld.getGreetings("petra");
+ fail("Exception expected");
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().indexOf("No match because the policy sets on either side have policies in differnt languages {http://schemas.xmlsoap.org/ws/2004/09/policy}Policy and {http://tuscany.apache.org/xmlns/sca/1.1}jdkLogger") > -1);
+ }
+ }
+
+ @Test
+ public void testPolicySpecificMatch() throws Exception {
+ // TODO
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy/pom.xml b/sandbox/sebastien/java/embed/itest/policy/pom.xml
new file mode 100644
index 0000000000..14335b254a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-policy</artifactId>
+ <name>Apache Tuscany SCA iTest Policy</name>
+
+ <modules>
+ <module>matching</module>
+ <module>wspolicy</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/pom.xml b/sandbox/sebastien/java/embed/itest/policy/wspolicy/pom.xml
new file mode 100644
index 0000000000..a0bf3de1a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/pom.xml
@@ -0,0 +1,58 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-policy-wspolicy</artifactId>
+ <name>Apache Tuscany SCA iTest Policy WS-Policy</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-wspolicy</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-logging</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..a9835199d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.wspolicy.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..620adad638
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/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 org.apache.tuscany.sca.policy.wspolicy.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorldWS;
+
+ public String getGreetings(String s) {
+ String response = helloWorldWS.getGreetings(s);
+ System.out.println("At client: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b7955522f8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/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 org.apache.tuscany.sca.policy.wspolicy.helloworld;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ String response = "Hello " + s;
+ System.out.println("At service: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/LoggingMessages.properties b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/LoggingMessages.properties
new file mode 100644
index 0000000000..ada808be0e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/LoggingMessages.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e71dd465f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..961fdeb602
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/policy/wspolicy/helloworld/definitions.xml \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/definitions.xml b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/definitions.xml
new file mode 100644
index 0000000000..425f511273
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/definitions.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <policySet name="JDKLoggingPolicy"
+ provides="tuscany:logging"
+ appliesTo="//binding | //implementation"
+ attachTo="//sca:service | //sca:reference">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <tuscany:jdkLogger name="test.logger">
+ <tuscany:logLevel>FINE</tuscany:logLevel>
+ <tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+ </tuscany:jdkLogger>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/helloworld.composite b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/helloworld.composite
new file mode 100644
index 0000000000..5a3a8f09a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/helloworld.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="HelloWorld">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.policy.wspolicy.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS" target="HelloWorldService" requires="tuscany:logging"/>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.policy.wspolicy.helloworld.HelloWorldService"/>
+ <service name="HelloWorld" requires="tuscany:logging">
+ <binding.ws/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..a352696b8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/main/resources/org/apache/tuscany/sca/policy/wspolicy/helloworld/helloworld.wsdl
@@ -0,0 +1,90 @@
+<?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="HelloWorldSoapPort1">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService1"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyTestCase.java b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyTestCase.java
new file mode 100644
index 0000000000..4d6921f8a1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/policy/wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyTestCase.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.policy.wspolicy;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.policy.wspolicy.helloworld.HelloWorld;
+
+public class WSPolicyTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode(new Contribution("test", "target/classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/pom.xml b/sandbox/sebastien/java/embed/itest/pom.xml
new file mode 100644
index 0000000000..cc9d227767
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/pom.xml
@@ -0,0 +1,110 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-itest</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Integration Tests</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <modules>
+ <module>base</module>
+ <module>builder</module>
+ <module>bpel</module>
+ <module>callback-api</module>
+ <module>callback-basic</module>
+ <module>callback-complex-type</module>
+ <module>callback-multiple-wires</module>
+ <module>callback-separatethread</module>
+ <module>callback-two-composites</module>
+ <module>callback-two-nodes</module>
+ <module>component-type</module>
+ <module>contribution-folder</module>
+ <module>contribution-zip</module>
+<!-- why commented out?
+ <module>definitions-multiple</module>
+-->
+ <module>databindings</module>
+ <module>distribution</module>
+ <module>exceptions</module>
+ <module>implementation-spring</module>
+ <module>import-export</module>
+ <module>interfaces</module>
+ <module>jms</module>
+ <module>nodes</module>
+ <module>node-launcher-equinox</module>
+ <module>oneway</module>
+<!-- why commented out?
+ <module>operation-overloading</module>
+-->
+ <module>policy</module>
+ <module>policies</module>
+ <module>policy-transaction</module>
+<!-- wait until databinding-sdo is in
+ <module>properties</module>
+-->
+ <module>recursive-multi-level</module>
+ <module>references</module>
+ <module>scaclient-api</module>
+<!-- TUSCANY-3424 - SCAClient in JSE with OSGi runtime not yet supported
+ <module>scaclient-api-jse-osgi</module>
+-->
+ <module>scaclient-api-osgi</module>
+ <module>scaclient-api-remote</module>
+ <module>scopes</module>
+ <module>scdl</module>
+ <module>services</module>
+ <module>service-reference</module>
+ <module>wires</module>
+ <module>ws</module>
+ <module>ws-jaxws</module>
+ </modules>
+
+ <!-- We don't want to deploy any of the test modules -->
+ <properties>
+ <maven.deploy.skip>true</maven.deploy.skip>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/properties/pom.xml b/sandbox/sebastien/java/embed/itest/properties/pom.xml
new file mode 100644
index 0000000000..ec04cdba99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-properties</artifactId>
+ <name>Apache Tuscany SCA iTest Properties</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- XPathFactory -->
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java
new file mode 100644
index 0000000000..b0fd64c9da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.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 mysca.test.myservice.impl;
+
+public interface MyService {
+ /**
+ * This is a method to get the location property value from the sca runtime environment. It is implemented in the
+ * class MyServiceImpl
+ */
+ String getLocation();
+
+ /**
+ * This is a method to get the year property value from the sca runtime environment. It is implemented in the class
+ * MyServiceImpl
+ */
+ String getYear();
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java
new file mode 100644
index 0000000000..7b44ef02e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.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 mysca.test.myservice.impl;
+
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.ComponentName;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class Implements the interface MyService and gives implementation for all methods which are declared in that
+ * interface. scope is specified as Composite using
+ *
+ * @scope annotation.
+ */
+
+@Service(MyService.class)
+public class MyServiceImpl implements MyService {
+
+ @Property(name = "location")
+ protected String location = "RTP";
+
+ @Property(name = "year")
+ protected String year = "2006";
+
+ @ComponentName
+ protected String componentName;
+
+ private Logger logger;
+
+ /**
+ * @ to print the message in the log
+ */
+ public MyServiceImpl() {
+ logger = Logger.getAnonymousLogger();
+ logger.info("creating service instance...");
+ }
+
+ /**
+ * @Init annotation to Start the service. Which is executed all the time
+ */
+ @Init
+ public void start() {
+ logger.info("Start service..");
+ }
+
+ /**
+ * @Destroy annotation to stop the service. Which is executed in the end
+ */
+ @Destroy
+ public void stop() {
+ logger.info("Stop service..");
+
+ }
+
+ public String getComponentName() {
+ return componentName;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public String getYear() {
+ return year;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java
new file mode 100644
index 0000000000..e8c4341cf2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.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 mysca.test.myservice.impl;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class Implements the interface MyService and gives implementation for all methods which are declared in that
+ * interface. scope is specified as Composite using
+ *
+ * @scope annotation.
+ */
+
+@Service(MyService.class)
+public class MyTotalServiceImpl implements MyService {
+
+ // default required==true so it is 1:1
+ @Reference
+ public MyService myService;
+
+ public String getLocation() {
+ return myService.getLocation();
+ }
+
+ public String getYear() {
+ return myService.getYear();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java
new file mode 100644
index 0000000000..68ce5a3cb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.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.itest;
+
+/**
+ * It is an Interface which has method declarations. Methods which are to be accessed as a service are declared in this
+ * interface. Implementation for these methods is provided in ABCDComponentImpl Class
+ */
+public interface ABCDComponent {
+
+ /**
+ * This is a method to get a string property value from the SCA runtime environment. It is implemented in the class
+ * ABCDComponentImpl
+ */
+ String getA();
+
+ /**
+ * This is a method to get a string property value from the SCA runtime environment. It is implemented in the class
+ * ABCDComponentImpl
+ */
+ String getB();
+
+ /**
+ * This is a method to get a string property value from the SCA runtime environment. It is implemented in the class
+ * ABCDComponentImpl
+ */
+ String getC();
+
+ /**
+ * This is a method to get a string property value from the SCA runtime environment. It is implemented in the class
+ * ABCDComponentImpl
+ */
+ String getD();
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java
new file mode 100644
index 0000000000..c8d0d4cae4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.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.itest;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This class Implements the interface ABCDComponent and gives implementation for all methods which are declared in that
+ * interface. scope is specified as Composite using
+ *
+ * @scope annotation.
+ */
+@Scope("COMPOSITE")
+public class ABCDComponentImpl implements ABCDComponent {
+ private ABComponent abComponent;
+ private CDComponent cdComponent;
+
+ /**
+ * It is a method which injects the property value to the variable 'abComponent' from the SCA runtime environment
+ * using
+ *
+ * @Property Annotations.
+ */
+ @Reference
+ public void setAb(ABComponent component) {
+ this.abComponent = component;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'cdComponent' from the SCA runtime environment
+ * using
+ *
+ * @Property Annotations.
+ */
+ @Reference
+ public void setCd(CDComponent component) {
+ this.cdComponent = component;
+ }
+
+ public String getA() {
+ return this.abComponent.getA();
+ }
+
+ public String getB() {
+ return this.abComponent.getB();
+ }
+
+ public String getC() {
+ return this.cdComponent.getC();
+ }
+
+ public String getD() {
+ return this.cdComponent.getD();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java
new file mode 100644
index 0000000000..b727935bc1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.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.sca.itest;
+
+import java.util.Collection;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * It is an Interface which has method declarations. Methods which are to be accessed as a service are declared in this
+ * interface. Implementation for these methods is provided in ABComponentImpl Class
+ */
+@Remotable
+public interface ABComponent {
+
+ /**
+ * This is a method to get a string property value from the SCA runtime environment. It is implemented in the class
+ * ABComponentImpl
+ */
+
+ String getA();
+
+ /**
+ * This is a method to get a string property value from the SCA runtime environment. It is implemented in the class
+ * ABComponentImpl
+ */
+ String getB();
+
+ /**
+ * This is a method to get a string property value from the SCA runtime environment. It is implemented in the class
+ * ABComponentImpl
+ */
+ String getZ();
+
+ /**
+ * This is a method to get an integer property value from the SCA runtime environment. It is implemented in the
+ * class ABComponentImpl
+ */
+ int getIntValue();
+
+ /**
+ * This is a method to get a string property value from the SCA runtime environment. It is implemented in the class
+ * ABComponentImpl
+ */
+ String getF();
+
+ /**
+ * This is a method to get collection of property values from the SCA runtime environment. It is implemented in the
+ * class ABComponentImpl
+ */
+ Collection<String> getManyStringValues();
+
+ /**
+ * This is a method to get collection of property value from the SCA runtime environment. It is implemented in the
+ * class ABComponentImpl
+ */
+ Collection<Integer> getManyIntegers();
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java
new file mode 100644
index 0000000000..e402131ce2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import java.util.Collection;
+
+import org.oasisopen.sca.annotation.Property;
+
+/**
+ * This class Implements the interface ABComponent and gives implementation for all methods which are declared in that
+ * interface.
+ */
+
+public class ABComponentImpl implements ABComponent {
+
+ private String aProperty;
+ private String bProperty;
+ private int intValue;
+ private Collection<String> manyStringValues;
+ private Collection<Integer> manyIntegerValues;
+ private String zProperty;
+ private String fProperty;
+
+ /**
+ * It is a method which injects the property value to the variable 'zProperty' from the SCA runtime environment
+ * using Annotations.
+ */
+ @Property(name = "xpath")
+ public void setZProperty(final String value) {
+ this.zProperty = value;
+ }
+
+ /**
+ * It is a method which injects collection of property values to the variable 'manyStringValues' from the SCA
+ * runtime environment using Annotations.
+ */
+ @Property(name = "foobar")
+ public void setManyStringValues(final Collection<String> value) {
+ this.manyStringValues = value;
+ }
+
+ /**
+ * It is a method which injects collection of integer property values to the variable 'manyIntegerValues' from the
+ * SCA runtime environment using Annotations.
+ */
+ @Property(name = "fooInts")
+ public void setManyIntegers(final Collection<Integer> value) {
+ this.manyIntegerValues = value;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'aProperty' from the SCA runtime environment
+ * using Annotations.
+ */
+ @Property
+ public void setA(final String A) {
+ this.aProperty = A;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'bProperty' from the SCA runtime environment
+ * using Annotations.
+ */
+ @Property
+ public void setB(final String B) {
+ this.bProperty = B;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'fProperty' from the SCA runtime environment
+ * using Annotations.
+ */
+ @Property
+ public void setF(final String F) {
+ this.fProperty = F;
+ }
+
+ /**
+ * It is a method which injects integer property value to the variable 'intValue' from the SCA runtime environment
+ * using Annotations.
+ */
+ @Property
+ public void setOne(final int value) {
+ this.intValue = value;
+ }
+
+ public String getA() {
+ return this.aProperty;
+ }
+
+ public String getB() {
+ return this.bProperty;
+ }
+
+ public int getIntValue() {
+ return this.intValue;
+ }
+
+ public String getZ() {
+ return this.zProperty;
+ }
+
+ public String getF() {
+ return this.fProperty;
+ }
+
+ public Collection<String> getManyStringValues() {
+ return manyStringValues;
+ }
+
+ public Collection<Integer> getManyIntegers() {
+ return manyIntegerValues;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java
new file mode 100644
index 0000000000..52f9871d1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.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.itest;
+
+import java.util.Collection;
+
+/**
+ * It is an Interface which has method declarations. Methods which are to be accessed as a service are declared in this
+ * interface. Implementation for these methods is provided in CDComponentImpl Class
+ */
+public interface CDComponent {
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * CDComponentImpl Class
+ */
+ String getC();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * CDComponentImpl Class
+ */
+ String getC2();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * CDComponentImpl Class
+ */
+ String getD();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * CDComponentImpl Class
+ */
+ String getNoSource();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * CDComponentImpl Class
+ */
+ String getFileProperty();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * CDComponentImpl Class
+ */
+ Collection<String> getManyValuesFileProperty();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * CDComponentImpl Class
+ */
+ int getOverrideValue();
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java
new file mode 100644
index 0000000000..fceda9d9ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import java.util.Collection;
+
+import org.oasisopen.sca.annotation.Property;
+
+/**
+ * This class Implements the interface CDComponent and gives implementation for all methods which are declared in that
+ * interface.
+ */
+public class CDComponentImpl implements CDComponent {
+
+ private String cProperty;
+ private String dProperty;
+ private String nosource;
+ private String fileProperty;
+ private Collection<String> manyValuesFileProperty;
+ private int overrideNumber;
+ private String cProperty2;
+
+ /**
+ * It is a method which injects the property value to the variable 'cProperty2' from the SCA runtime environment
+ * using
+ *
+ * @Property Annotations.
+ */
+ @Property(name = "nonFileProperty")
+ public void setC2(final String value) {
+ this.cProperty2 = value;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'overrideNumber' from the SCA runtime environment
+ * using
+ *
+ * @Property Annotations.
+ */
+ @Property(name = "two")
+ public void setOverrideNumber(final int value) {
+ this.overrideNumber = value;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'fileProperty' from the SCA runtime environment
+ * using
+ *
+ * @Property Annotations.
+ */
+ @Property(name = "fileProperty")
+ public void setFileProp(final String value) {
+ this.fileProperty = value;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'manyValuesFileProperty' from the SCA runtime
+ * environment using
+ *
+ * @Property Annotations.
+ */
+ @Property(name = "manyValuesFileProperty")
+ public void setFileManyValueProp(final Collection<String> values) {
+ this.manyValuesFileProperty = values;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'cProperty' from the SCA runtime environment
+ * using
+ *
+ * @Property Annotations.
+ */
+ @Property
+ public void setC(final String C) {
+ this.cProperty = C;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'dProperty' from the SCA runtime environment
+ * using
+ *
+ * @Property Annotations.
+ */
+ @Property
+ public void setD(final String D) {
+ this.dProperty = D;
+ }
+
+ /**
+ * It is a method which injects the property value to the variable 'nosource' from the SCA runtime environment using
+ *
+ * @Property Annotations.
+ */
+ @Property
+ public void setNosource(final String value) {
+ this.nosource = value;
+ }
+
+ public String getFileProperty() {
+ return this.fileProperty;
+ }
+
+ public String getC() {
+ return this.cProperty;
+ }
+
+ public String getC2() {
+ return this.cProperty2;
+ }
+
+ public String getD() {
+ return this.dProperty;
+ }
+
+ public String getNoSource() {
+ return this.nosource;
+ }
+
+ public int getOverrideValue() {
+ return this.overrideNumber;
+ }
+
+ public Collection<String> getManyValuesFileProperty() {
+ return this.manyValuesFileProperty;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java
new file mode 100644
index 0000000000..1642ab55f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.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.itest;
+
+/**
+ * This is a Java Bean which has setter and getter methods for for the variables used in the property tests.
+ */
+public class ComplexPropertyBean {
+
+ /**
+ * Variable declarations
+ */
+ protected int integerNumber = 25;
+ protected float floatNumber = 50;
+ protected double doubleNumber = 75;
+ protected int[] intArray = null;
+ protected double[] doubleArray = null;
+ protected String[] stringArray = null;
+
+ ComplexPropertyBean numberSet;
+ protected ComplexPropertyBean[] numberSetArray = null;
+
+ public ComplexPropertyBean() {
+
+ }
+
+ public double getDoubleNumber() {
+ return doubleNumber;
+ }
+
+ /**
+ * It is a setter method to set a value for the variable doubleNumber
+ */
+ public void setDoubleNumber(double doubleNumber) {
+ this.doubleNumber = doubleNumber;
+ }
+
+ /**
+ * It is a getter method to get a value for the variable floatNumber
+ */
+ public float getFloatNumber() {
+ return floatNumber;
+ }
+
+ /**
+ * It is a setter method to set a value for the variable floatNumber
+ */
+ public void setFloatNumber(float floatNumber) {
+ this.floatNumber = floatNumber;
+ }
+
+ /**
+ * It is a getter method to get a value for the variable floatNumber
+ */
+ public int getIntegerNumber() {
+ return integerNumber;
+ }
+
+ /**
+ * It is a getter method to get a value for the variable integerNumber
+ */
+ public void setIntegerNumber(int integerNumber) {
+ this.integerNumber = integerNumber;
+ }
+
+ /**
+ * It is a getter method to set a value for the variable numberSet
+ */
+ public ComplexPropertyBean getNumberSet() {
+ return numberSet;
+ }
+
+ /**
+ * It is a setter method to set a value for the variable numberSet
+ */
+ public void setNumberSet(ComplexPropertyBean numberSet) {
+ this.numberSet = numberSet;
+ }
+
+ /**
+ * It is a method which implements toString() function
+ */
+
+ public String toString() {
+ return Double.toString(integerNumber) + " - "
+ + Double.toString(floatNumber)
+ + " - "
+ + Double.toString(doubleNumber)
+ + " \n"
+ + ((intArray == null) ? "" : intArray[0] + " - " + intArray[1] + " \n ")
+ + ((doubleArray == null) ? "" : doubleArray[0] + " - " + doubleArray[1] + " \n ")
+ + ((stringArray == null) ? "" : stringArray[0] + " - " + stringArray[1] + " \n ")
+ + ((numberSetArray == null) ? "" : numberSetArray[0] + " - " + numberSetArray[1] + " \n ")
+ + ((numberSet == null) ? "" : numberSet.toString());
+ }
+
+ /**
+ * It is a setter method to set values for the variable stringArray
+ */
+ public String[] getStringArray() {
+ return stringArray;
+ }
+
+ /**
+ * It is a setter method to set values for the variable stringArray
+ */
+ public void setStringArray(String[] stringArray) {
+ this.stringArray = stringArray;
+ }
+
+ public int[] getIntArray() {
+ return intArray;
+ }
+
+ public void setIntArray(int[] intArray) {
+ this.intArray = intArray;
+ }
+
+ public double[] getDoubleArray() {
+ return doubleArray;
+ }
+
+ public void setDoubleArray(double[] doubleArray) {
+ this.doubleArray = doubleArray;
+ }
+
+ public ComplexPropertyBean[] getNumberSetArray() {
+ return numberSetArray;
+ }
+
+ public void setNumberSetArray(ComplexPropertyBean[] numberSetArray) {
+ this.numberSetArray = numberSetArray;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java
new file mode 100644
index 0000000000..acd1f26670
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest;
+
+/**
+ * This is an Interface for the services
+ */
+public interface OverrideService {
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java
new file mode 100644
index 0000000000..71dce41efc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.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 org.apache.tuscany.sca.itest;
+
+/**
+ * An implementation for the interface OverrideService.
+ */
+
+public class OverrideServiceImpl implements OverrideService {
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java
new file mode 100644
index 0000000000..9c7e8c3447
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import java.util.Collection;
+
+import test.jaxb.props.ReturnCodeProperties;
+
+/**
+ * It is an Interface which has method declarations. Methods which are to be accessed as a service are declared in this
+ * interface. Implementation for these methods is provided in PropertyComponentImpl Class
+ */
+public interface PropertyComponent {
+
+ /**
+ * This is a method to get a value for a property name 'location' from the SCA runtime environment. It is
+ * implemented in the class PropertyComponentImpl
+ */
+ public String getLocation();
+
+ /**
+ * This is a method to get a value for a property name 'year' from the SCA runtime environment. It is implemented in
+ * the class PropertyComponentImpl
+ */
+ public String getYear();
+
+ /**
+ * This method is used to test injecting a primitive String Array
+ *
+ * @return The injected array
+ */
+ public String[] getDaysOfTheWeek();
+
+ /**
+ * This method is used to test injecting an Object Integer Array
+ *
+ * @return The injected array
+ */
+ public Integer[] getIntegerNumbers();
+
+ /**
+ * This method is used to test injecting an int Array
+ *
+ * @return The injected array
+ */
+ public int[] getIntNumbers();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * PropertyComponentImpl
+ */
+
+ public ComplexPropertyBean getComplexPropertyOne();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * PropertyComponentImpl
+ */
+ public ComplexPropertyBean getComplexPropertyTwo();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * PropertyComponentImpl
+ */
+ public ComplexPropertyBean getComplexPropertyThree();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * PropertyComponentImpl
+ */
+ public Collection<ComplexPropertyBean> getComplexPropertyFour();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * PropertyComponentImpl
+ */
+
+ public ComplexPropertyBean getComplexPropertyFive();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * PropertyComponentImpl
+ */
+ public ReturnCodeProperties getComplexJAXBPropertyOne();
+
+ /**
+ * This is a method to get a property value from the SCA runtime environment. It is implemented in the class
+ * PropertyComponentImpl
+ */
+ public ReturnCodeProperties getComplexJAXBPropertyTwo();
+
+ /**
+ * @return
+ */
+ public String getLocationFromComponentContext();
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java
new file mode 100644
index 0000000000..64ca749e9f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.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.sca.itest;
+
+import java.util.Collection;
+
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Property;
+
+import test.jaxb.props.ReturnCodeProperties;
+
+/**
+ * This class Implements the interface PropertyComponent and gives implementation for all methods which are declared in
+ * that interface.
+ */
+public class PropertyComponentImpl implements PropertyComponent {
+ @Context
+ protected ComponentContext context;
+
+ @Property
+ protected ComplexPropertyBean complexPropertyOne;
+
+ @Property
+ protected ComplexPropertyBean complexPropertyTwo;
+
+ @Property
+ protected ComplexPropertyBean complexPropertyThree;
+
+ @Property
+ protected Collection<ComplexPropertyBean> complexPropertyFour;
+
+ @Property
+ protected ComplexPropertyBean complexPropertyFive;
+
+ @Property(name = "location")
+ protected String location;
+
+ @Property(name = "year")
+ protected String year;
+
+ @Property(name = "daysOfTheWeek")
+ protected String[] daysOfTheWeek;
+
+ @Property(name = "integerNumbers")
+ protected Integer[] integerNumbers;
+
+ @Property(name = "intNumbers")
+ protected int[] intNumbers;
+
+ @Property
+ protected ReturnCodeProperties complexJAXBPropertyOne;
+
+ @Property
+ protected ReturnCodeProperties complexJAXBPropertyTwo;
+
+ public String getLocation() {
+ return location;
+ }
+
+ public String getYear() {
+ return year;
+ }
+
+ public ComplexPropertyBean getComplexPropertyOne() {
+ //System.out.println(complexPropertyOne);
+ return complexPropertyOne;
+ }
+
+ public ComplexPropertyBean getComplexPropertyTwo() {
+ //System.out.println(complexPropertyTwo);
+ return complexPropertyTwo;
+ }
+
+ public ComplexPropertyBean getComplexPropertyThree() {
+ //System.out.println(complexPropertyThree);
+ return complexPropertyThree;
+ }
+
+ public Collection<ComplexPropertyBean> getComplexPropertyFour() {
+ //System.out.println(complexPropertyThree);
+ return complexPropertyFour;
+ }
+
+ public ComplexPropertyBean getComplexPropertyFive() {
+ return complexPropertyFive;
+ }
+
+ /**
+ * This method is used to test injecting an Array
+ *
+ * @return The injected array
+ */
+ public String[] getDaysOfTheWeek() {
+ return daysOfTheWeek;
+ }
+
+ /**
+ * This method is used to test injecting an Object Integer Array
+ *
+ * @return The injected array
+ */
+ public Integer[] getIntegerNumbers() {
+ return integerNumbers;
+ }
+
+ /**
+ * This method is used to test injecting an int Array
+ *
+ * @return The injected array
+ */
+ public int[] getIntNumbers() {
+ return intNumbers;
+ }
+
+ public String getLocationFromComponentContext() {
+ return context.getProperty(String.class, "location");
+ }
+
+ public ReturnCodeProperties getComplexJAXBPropertyOne() {
+ return complexJAXBPropertyOne;
+ }
+
+ public ReturnCodeProperties getComplexJAXBPropertyTwo() {
+ return complexJAXBPropertyTwo;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java
new file mode 100644
index 0000000000..a57ccd90c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest;
+
+/**
+ * This is an Interface for the services.
+ */
+public interface PropertyService {
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java
new file mode 100644
index 0000000000..c147a2affe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.cdi;
+
+public interface Bar {
+ public String getBar();
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java
new file mode 100644
index 0000000000..f44fed7389
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.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 org.apache.tuscany.sca.itest.cdi;
+
+import org.oasisopen.sca.annotation.Constructor;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(Bar.class)
+public class Foo1 implements Bar {
+
+ protected String bar;
+
+ @Constructor
+ public Foo1(@Property(name="bar") String b) {
+ this.bar = b;
+ }
+
+ public String getBar() {
+ return this.bar;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java
new file mode 100644
index 0000000000..1d2e563095
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.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.sca.itest.cdi;
+
+import org.oasisopen.sca.annotation.Constructor;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(Bar.class)
+public class Foo2 implements Bar {
+
+ protected String bar;
+
+ @Constructor
+ public Foo2(@Property(name = "bar") String b) {
+ this.bar = b;
+ }
+
+ public String getBar() {
+ return this.bar;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java
new file mode 100644
index 0000000000..54082e297a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.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.itest.cdi;
+
+import org.oasisopen.sca.annotation.Constructor;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(Bar.class)
+public class Foo3 implements Bar {
+
+ protected String bar;
+
+ @Constructor
+ public Foo3() {
+ this.bar = "bar";
+ }
+
+ public String getBar() {
+ return this.bar;
+ }
+
+ @Property(name = "bar")
+ public void setBar(String b) {
+ this.bar = b;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java
new file mode 100644
index 0000000000..15fb49ea4e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.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.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 1.6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.06.07 at 03:30:47 PM EDT
+//
+package test.jaxb.props;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the test.jaxb.props package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _MyRCProps_QNAME = new QName("http://test.sca.jaxb/rcprops", "MyRCProps");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: test.jaxb.props
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link ReturnCodeProperties }
+ *
+ */
+ public ReturnCodeProperties createReturnCodeProperties() {
+ return new ReturnCodeProperties();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ReturnCodeProperties }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://test.sca.jaxb/rcprops", name = "MyRCProps")
+ public JAXBElement<ReturnCodeProperties> createMyRCProps(ReturnCodeProperties value) {
+ return new JAXBElement<ReturnCodeProperties>(_MyRCProps_QNAME, ReturnCodeProperties.class, null, value);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java
new file mode 100644
index 0000000000..0a1d4a34a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.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.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 1.6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.06.07 at 03:30:47 PM EDT
+//
+package test.jaxb.props;
+
+import java.math.BigInteger;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p>Java class for ReturnCodeProperties complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="ReturnCodeProperties">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="AInt" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;element name="BInteger" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ReturnCodeProperties", namespace = "http://test.sca.jaxb/rcprops", propOrder = {"a", "b"})
+public class ReturnCodeProperties {
+
+ @XmlElement(name = "AInt")
+ protected int a;
+ @XmlElement(name = "BInteger", required = true)
+ protected BigInteger b;
+
+ /**
+ * Gets the value of the a property.
+ *
+ */
+ public int getA() {
+ return a;
+ }
+
+ /**
+ * Sets the value of the a property.
+ *
+ */
+ public void setA(int value) {
+ this.a = value;
+ }
+
+ /**
+ * Gets the value of the b property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getB() {
+ return b;
+ }
+
+ /**
+ * Sets the value of the b property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setB(BigInteger value) {
+ this.b = value;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/package-info.java b/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/package-info.java
new file mode 100644
index 0000000000..6a6fdd00cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/java/test/jaxb/props/package-info.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 1.6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2008.06.07 at 03:30:47 PM EDT
+//
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://test.sca.jaxb/rcprops", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package test.jaxb.props;
+
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/ConstructorPropertyInjection.composite b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/ConstructorPropertyInjection.composite
new file mode 100644
index 0000000000..e697cedd62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/ConstructorPropertyInjection.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://foo" name="ConstructorPropertyInjection">
+
+ <component name="Foo1Component">
+ <implementation.java class="org.apache.tuscany.sca.itest.cdi.Foo1" />
+ <property name="bar" value="foobar" />
+ </component>
+
+ <component name="Foo2Component">
+ <implementation.java class="org.apache.tuscany.sca.itest.cdi.Foo2" />
+ <property name="bar">fubar</property>
+ </component>
+
+ <component name="Foo3Component">
+ <implementation.java class="org.apache.tuscany.sca.itest.cdi.Foo3" />
+ <property name="bar">
+ <value>fubar</value>
+ </property>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/Outer.composite b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/Outer.composite
new file mode 100644
index 0000000000..93f164a1e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/Outer.composite
@@ -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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912" name="Iteration3Composite"
+ targetNamespace="http://foo" local="true" autowire="false">
+
+ <property name="newLocation" type="xsd:anyURI">Raleigh</property>
+ <property name="newYear" type="xsd:anyURI">2008</property>
+ <component name="MyServiceComponent">
+ <implementation.java class="mysca.test.myservice.impl.MyServiceImpl" />
+ </component>
+ <component name="MyServiceComponentNew">
+ <implementation.java class="mysca.test.myservice.impl.MyServiceImpl" />
+ <property name="location" source="$newLocation" />
+ <property name="year" source="$newYear" />
+ </component>
+ <component name="MyTotalServiceNewComponent">
+ <implementation.java class="mysca.test.myservice.impl.MyTotalServiceImpl" />
+ <reference name="myService" target="MyServiceComponentNew/MyService" />
+ </component>
+ <component name="MySimpleServiceInRecursiveAnother">
+ <implementation.composite name="foo:MySimpleService" />
+ <property name="newLocation">Durham</property>
+ <property name="newYear">2009</property>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/OuterPropertyTest.composite b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/OuterPropertyTest.composite
new file mode 100644
index 0000000000..0c8714cbe1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/OuterPropertyTest.composite
@@ -0,0 +1,42 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo"
+ targetNamespace="http://foo"
+ name="OuterPropertyTest"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <component name="OuterComponent">
+ <implementation.composite name="foo:PropertyTest" />
+ <property name="number">125</property>
+ <property name="complex" type="foo:MyComplexType">
+ <value>
+ <foo:a>Overriden A</foo:a>
+ <foo:b>Overriden B</foo:b>
+ <foo:c>Overriden C</foo:c>
+ <foo:d>Overriden D</foo:d>
+ <foo:x>
+ <foo:y>Overriden Y</foo:y>
+ <foo:z>Overriden Z</foo:z>
+ </foo:x>
+ </value>
+ </property>
+ </component>
+</composite>
+
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/PropertyTest.composite b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/PropertyTest.composite
new file mode 100644
index 0000000000..7c834d5e0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/PropertyTest.composite
@@ -0,0 +1,260 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo"
+ xmlns:cust="http://www.example.com/Customer"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:rcp="http://test.sca.jaxb/rcprops"
+ targetNamespace="http://foo"
+ name="PropertyTest"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <service name="ProperterTestService" promote="ABComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.ABComponent"/>
+ </service>
+
+ <property name="number" type="xsd:int">1</property>
+ <property name="complex" type="foo:MyComplexType" >
+ <value>
+ <foo:a>a</foo:a>
+ <foo:b>b</foo:b>
+ <foo:c>c</foo:c>
+ <foo:d>d</foo:d>
+ <foo:x>
+ <foo:y>y</foo:y>
+ <foo:z>z</foo:z>
+ </foo:x>
+ </value>
+ </property>
+
+ <property name="moreComplex" type="foo:MyMoreComplexType">
+ <value>
+ <numberSetArray>
+ <integerNumber>1</integerNumber>
+ <floatNumber>11</floatNumber>
+ <doubleNumber>111</doubleNumber>
+ </numberSetArray>
+ <numberSetArray>
+ <integerNumber>2</integerNumber>
+ <floatNumber>22</floatNumber>
+ <doubleNumber>222</doubleNumber>
+ </numberSetArray>
+ <stringArray>TestString_1</stringArray>
+ <stringArray>TestString_2</stringArray>
+ <intArray>10</intArray>
+ <intArray>20</intArray>
+ <integerNumber>27</integerNumber>
+ <floatNumber>79.34</floatNumber>
+ <doubleNumber>184.52</doubleNumber>
+ <doubleArray>50.05</doubleArray>
+ <doubleArray>25.52</doubleArray>
+ <numberSet>
+ <integerNumber>54</integerNumber>
+ <floatNumber>158.68</floatNumber>
+ <doubleNumber>369.04</doubleNumber>
+ </numberSet>
+ </value>
+ </property>
+
+ <property name="complexFoo" type="foo:MyMoreComplexType">
+ <value>
+ <stringArray>TestString_3</stringArray>
+ <stringArray>TestString_4</stringArray>
+ <intArray>100</intArray>
+ <intArray>200</intArray>
+ </value>
+ </property>
+
+ <component name="ABCDComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.ABCDComponentImpl"/>
+ <reference name="ab" target="ABComponent"/>
+ <reference name="cd" target="CDComponent"/>
+ </component>
+
+ <component name="ABComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.ABComponentImpl"/>
+ <property name="a" source="$complex/foo:a"/>
+ <property name="b" source="$complex/foo:b"/>
+ <property name="f" source="$complex/foo:a">f</property>
+ <property name="xpath" source="$complex/foo:x/*[local-name()='z']"/>
+ <property name="one" source="$number"/>
+ <property name="foobar" many="true">
+ <value>Apache</value>
+ <value>Tuscany</value>
+ <value>Java SCA</value>
+ </property>
+ <property name="fooInts" many="true">
+ <value>123</value>
+ <value>456</value>
+ <value>789</value>
+ </property>
+ </component>
+
+
+ <component name="CDComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.CDComponentImpl"/>
+ <property name="c" source="$complex/foo:c"/>
+ <property name="d" source="$complex/foo:d"/>
+ <property name="nosource">aValue</property>
+ <property name="fileProperty" file="fileProperty.txt"/>
+ <property name="manyValuesFileProperty" many="true" file="manyValuesFileProperty.txt"/>
+ <property name="nonFileProperty" file="fileProperty.txt" source="$complex/foo:c"/>
+ <property name="two" source="$number">25</property>
+ </component>
+
+ <component name="PropertyComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.PropertyComponentImpl"/>
+ <property name="complexPropertyOne" source="$moreComplex"></property>
+ <property name="complexPropertyTwo" type="foo:MyMoreComplexType">
+ <value>
+ <stringArray>TestString_1</stringArray>
+ <stringArray>TestString_2</stringArray>
+ <intArray>10</intArray>
+ <integerNumber>27</integerNumber>
+ <floatNumber>79.34</floatNumber>
+ <doubleArray>25.52</doubleArray>
+ <doubleNumber>184.52</doubleNumber>
+ <doubleArray>50.05</doubleArray>
+ <intArray>20</intArray>
+ <numberSetArray>
+ <integerNumber>1</integerNumber>
+ <floatNumber>11</floatNumber>
+ <doubleNumber>111</doubleNumber>
+ </numberSetArray>
+ <numberSetArray>
+ <integerNumber>2</integerNumber>
+ <floatNumber>22</floatNumber>
+ <doubleNumber>222</doubleNumber>
+ </numberSetArray>
+ <numberSet>
+ <integerNumber>54</integerNumber>
+ <floatNumber>158.68</floatNumber>
+ <doubleNumber>369.04</doubleNumber>
+ </numberSet>
+ </value>
+ </property>
+ <property name="complexPropertyThree" element="foo:PropertyThreeElement">
+ <PropertyThreeElement xmlns="http://foo">
+ <stringArray>TestElementString_1</stringArray>
+ <stringArray>TestElementString_2</stringArray>
+ <intArray>10</intArray>
+ <integerNumber>27</integerNumber>
+ <floatNumber>79.34</floatNumber>
+ <doubleArray>25.52</doubleArray>
+ <doubleNumber>184.52</doubleNumber>
+ <doubleArray>50.05</doubleArray>
+ <intArray>20</intArray>
+ <numberSetArray>
+ <integerNumber>1</integerNumber>
+ <floatNumber>11</floatNumber>
+ <doubleNumber>111</doubleNumber>
+ </numberSetArray>
+ <numberSetArray>
+ <integerNumber>2</integerNumber>
+ <floatNumber>22</floatNumber>
+ <doubleNumber>222</doubleNumber>
+ </numberSetArray>
+ <numberSet>
+ <integerNumber>54</integerNumber>
+ <floatNumber>158.68</floatNumber>
+ <doubleNumber>369.04</doubleNumber>
+ </numberSet>
+ </PropertyThreeElement>
+ </property>
+ <property name="complexPropertyFour" element="foo:PropertyFourElement" many="true">
+ <PropertyFourElement xmlns="http://foo">
+ <integerNumber>1</integerNumber>
+ <floatNumber>11.11</floatNumber>
+ <doubleNumber>111.111</doubleNumber>
+ <numberSet>
+ <integerNumber>11</integerNumber>
+ <floatNumber>1111.1111</floatNumber>
+ <doubleNumber>11111.11111</doubleNumber>
+ </numberSet>
+ </PropertyFourElement>
+ <PropertyFourElement xmlns="http://foo">
+ <integerNumber>2</integerNumber>
+ <floatNumber>22.22</floatNumber>
+ <doubleNumber>222.222</doubleNumber>
+ <numberSet>
+ <integerNumber>22</integerNumber>
+ <floatNumber>2222.2222</floatNumber>
+ <doubleNumber>22222.22222</doubleNumber>
+ </numberSet>
+ </PropertyFourElement>
+ <PropertyFourElement xmlns="http://foo">
+ <integerNumber>3</integerNumber>
+ <floatNumber>33.33</floatNumber>
+ <doubleNumber>333.333</doubleNumber>
+ <numberSet>
+ <integerNumber>33</integerNumber>
+ <floatNumber>3333.3333</floatNumber>
+ <doubleNumber>33333.33333</doubleNumber>
+ </numberSet>
+ </PropertyFourElement>
+ </property>
+ <property name="complexPropertyFive" source="$complexFoo"/>
+ <property name="location" type="xsd:string">RTP</property>
+ <property name="year" type="xsd:string">2006</property>
+ <property name="daysOfTheWeek" many="true" type="xsd:string">
+ <value>Monday</value>
+ <value>Tuesday</value>
+ <value>Wednesday</value>
+ <value>Thursday</value>
+ <value>Friday</value>
+ <value>Saturday</value>
+ <value>Sunday</value>
+ </property>
+ <property name="integerNumbers" many="true" type="xsd:int">
+ <value>1</value>
+ <value>2</value>
+ <value>3</value>
+ <value>4</value>
+ <value>5</value>
+ <value>6</value>
+ <value>7</value>
+ <value>8</value>
+ <value>9</value>
+ <value>10</value>
+ </property>
+ <property name="intNumbers" many="true" type="xsd:int">
+ <value>10</value>
+ <value>9</value>
+ <value>8</value>
+ <value>7</value>
+ <value>6</value>
+ <value>5</value>
+ <value>4</value>
+ <value>3</value>
+ <value>2</value>
+ <value>1</value>
+ <value>0</value>
+ </property>
+
+ <property name="complexJAXBPropertyOne" type="rcp:ReturnCodeProperties">
+ <MyRCProps xmlns="http://test.sca.jaxb/rcprops">
+ <AInt>10</AInt>
+ <BInteger>10</BInteger>
+ </MyRCProps>
+ </property>
+ <property name="complexJAXBPropertyTwo" type="rcp:ReturnCodeProperties" file="rcProps.txt"/>
+ </component>
+</composite>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/customer.xsd b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/customer.xsd
new file mode 100644
index 0000000000..7421750f1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/customer.xsd
@@ -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.
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://www.example.com/Customer" targetNamespace="http://www.example.com/Customer">
+
+ <xsd:element name="customer" type="Customer"/>
+ <xsd:complexType name="Customer">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string"/>
+ <xsd:element name="middleName" type="xsd:string"/>
+ <xsd:element name="lastName" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/fileProperty.txt b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/fileProperty.txt
new file mode 100644
index 0000000000..7e932622ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/fileProperty.txt
@@ -0,0 +1,21 @@
+<?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.
+-->
+
+<filePropertyTest>fileValue</filePropertyTest> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/foo.xsd b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/foo.xsd
new file mode 100644
index 0000000000..6831f66cec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/foo.xsd
@@ -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.
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://foo"
+ targetNamespace="http://foo"
+ elementFormDefault="qualified">
+
+ <xsd:complexType name="MyComplexType">
+ <xsd:sequence>
+ <xsd:element name="a" type="xsd:string"/>
+ <xsd:element name="b" type="xsd:string"/>
+ <xsd:element name="c" type="xsd:string"/>
+ <xsd:element name="d" type="xsd:string"/>
+ <xsd:element name="x">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="y" type="xsd:string"/>
+ <xsd:element name="z" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/manyValuesFileProperty.txt b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/manyValuesFileProperty.txt
new file mode 100644
index 0000000000..e037537d7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/manyValuesFileProperty.txt
@@ -0,0 +1,25 @@
+<?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.
+-->
+<value>
+ <manyFilePropertyValues>fileValueOne</manyFilePropertyValues>
+ <manyFilePropertyValues>fileValueTwo</manyFilePropertyValues>
+ <manyFilePropertyValues>fileValueThree</manyFilePropertyValues>
+ <manyFilePropertyValues>fileValueFour</manyFilePropertyValues>
+</value> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/mySimpleService.composite b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/mySimpleService.composite
new file mode 100644
index 0000000000..347990cca8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/mySimpleService.composite
@@ -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.
+-->
+<composite autowire="false" local="true" name="MySimpleService"
+ targetNamespace="http://foo" xmlns:foo="http://foo" xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912 ">
+
+
+ <service name="MyServiceNew1" promote="MyServiceComponentNew/MyService">
+ <interface.java interface="mysca.test.myservice.impl.MyService" />
+ </service>
+
+ <property name="newLocation" type="xsd:anyURI">Raleigh</property>
+ <property name="newYear" type="xsd:anyURI">2008</property>
+
+
+ <component name="MyServiceComponentNew">
+ <implementation.java class="mysca.test.myservice.impl.MyServiceImpl" />
+ <property name="location" source="$newLocation" />
+ <property name="year" source="$newYear" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/rcProps.txt b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/rcProps.txt
new file mode 100644
index 0000000000..052c291fd0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/rcProps.txt
@@ -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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<MyRCProps xmlns="http://test.sca.jaxb/rcprops">
+ <AInt>20</AInt>
+ <BInteger>20</BInteger>
+</MyRCProps>
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/main/resources/rcprops.xsd b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/rcprops.xsd
new file mode 100644
index 0000000000..21289fa7b2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/main/resources/rcprops.xsd
@@ -0,0 +1,55 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema elementFormDefault="qualified" targetNamespace="http://test.sca.jaxb/rcprops"
+ xmlns:tns="http://test.sca.jaxb/rcprops" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
+ xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+
+ <!-- Use some JAXB customizations -->
+
+ <annotation>
+ <appinfo>
+ <jaxb:schemaBindings>
+ <jaxb:package name="test.jaxb.props" />
+ </jaxb:schemaBindings>
+ </appinfo>
+ </annotation>
+
+ <element name="MyRCProps" type="tns:ReturnCodeProperties" />
+
+ <complexType name="ReturnCodeProperties">
+ <sequence>
+ <element name="AInt" type="xsd:int">
+ <annotation>
+ <appinfo>
+ <jaxb:property name="a" />
+ </appinfo>
+ </annotation>
+ </element>
+ <element name="BInteger" type="xsd:integer">
+ <annotation>
+ <appinfo>
+ <jaxb:property name="b" />
+ </appinfo>
+ </annotation>
+ </element>
+ </sequence>
+ </complexType>
+</schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java b/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
new file mode 100644
index 0000000000..efc635c72b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import static org.junit.Assert.assertEquals;
+import mysca.test.myservice.impl.MyService;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MyTotalServiceTestCase {
+ private static MyService service1;
+ private static MyService service2;
+ private static MyService service3;
+
+ private static Node node;
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the local
+ * property variables defined in the implementation file with the expected values 'RTP' and '2006'
+ */
+ @Test
+ public void testPropertyDefault() {
+ assertEquals("RTP", service1.getLocation());
+ assertEquals("2006", service1.getYear());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using service2 from the SCA runtime environment with the expected values 'Raleigh'
+ * and '2008'. This overrides the local property values
+ */
+ @Test
+ public void testPropertyOverride() {
+ assertEquals("Raleigh", service2.getLocation());
+ assertEquals("2008", service2.getYear());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using service3 from the SCA runtime environment with the expected values 'Durham'
+ * and '2009'
+ */
+ @Test
+ public void testPropertyNestedOverride() {
+ assertEquals("Durham", service3.getLocation());
+ assertEquals("2009", service3.getYear());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @BeforeClass is used for one time set Up, it executes before every tests. This method is used to create a test
+ * Embedded SCA node, to start the SCA node and to get a reference to the 'outerABService' service
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+
+ String location = ContributionLocationHelper.getContributionLocation("Outer.composite");
+ node = NodeFactory.newInstance().createNode("Outer.composite", new Contribution("c1", location));
+ node.start();
+ service1 = node.getService(MyService.class, "MyServiceComponent/MyService");
+ service2 = node.getService(MyService.class, "MyServiceComponentNew/MyService");
+ service3 = node.getService(MyService.class, "MySimpleServiceInRecursiveAnother");
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @AfterClass is used for one time Tear Down, it executes after every tests. This method is used to close the
+ * node, close any previously opened connections etc
+ */
+ @AfterClass
+ public static void tearDown() {
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java b/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java
new file mode 100644
index 0000000000..0906a45ab3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Iterator;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This is a class which makes user of JUnit Framework, all tests are written using JUnit notation. These tests are used
+ * to test different property values returned from the SCA Runtime Environment which is initialized with the composite
+ * 'OuterPropertyTest.composite'. It basically tests the Simple type of property and Complex type of property from the
+ * SCA Runtime Environment.
+ */
+public class OuterPropertyTestCase {
+
+ private static Node node;
+ private static ABComponent outerABService;
+
+ /**
+ * Method annotated with
+ *
+ * @BeforeClass is used for one time set Up, it executes before every tests. This method is used to create a test
+ * Embedded SCA node, to start the SCA node and to get a reference to the 'outerABService' service
+ */
+ @BeforeClass
+ public static void init() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("OuterPropertyTest.composite");
+ node = NodeFactory.newInstance().createNode("OuterPropertyTest.composite", new Contribution("c1", location));
+ node.start();
+ outerABService = node.getService(ABComponent.class, "OuterComponent");
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @AfterClass is used for one time Tear Down, it executes after every tests. This method is used to close the
+ * node, close any previously opened connections etc
+ */
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'Overriden
+ * A'
+ */
+ @Test
+ public void testOverridenA() {
+ assertEquals("Overriden A", outerABService.getA());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'Overriden
+ * B'
+ */
+ @Test
+ public void testOverridenB() {
+ assertEquals("Overriden B", outerABService.getB());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'Overriden
+ * A'
+ */
+ @Test
+ public void testOverridenF() {
+ assertEquals("Overriden A", outerABService.getF());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'Overriden
+ * Z'
+ */
+ @Test
+ public void testOverridenZ() {
+ assertEquals("Overriden Z", outerABService.getZ());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 125
+ */
+ @Test
+ public void testOverridenIntValue() {
+ assertEquals(125, outerABService.getIntValue());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 125
+ */
+ @Test
+ public void testDefaultValue() {
+ assertEquals(125, outerABService.getIntValue());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values 'Apache' ,
+ * 'Tuscany' and 'Java SCA' respectively .
+ */
+ @Test
+ public void testManySimpleStringValues() {
+ Iterator<String> iterator = outerABService.getManyStringValues().iterator();
+ assertEquals("Apache", iterator.next());
+ assertEquals("Tuscany", iterator.next());
+ assertEquals("Java SCA", iterator.next());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values 123, 456
+ * and 789
+ */
+ @Test
+ public void testManySimpleIntegerValues() {
+ Iterator<Integer> iterator = outerABService.getManyIntegers().iterator();
+ assertEquals(123, iterator.next().intValue());
+ assertEquals(456, iterator.next().intValue());
+ assertEquals(789, iterator.next().intValue());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java b/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java
new file mode 100644
index 0000000000..eb217600db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java
@@ -0,0 +1,422 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import test.jaxb.props.ReturnCodeProperties;
+
+/**
+ * This is a class which makes user of JUnit Framework, all tests are written using JUnit notation. These tests are used
+ * to test different property values returned from the SCA Runtime Environment which is initialized with the composite
+ * 'PropertyTest.composite'. It basically tests all types of property values returned from SCA runtime environment.
+ */
+public class PropertyTestCase {
+ private static Node node;
+ private static ABComponent abService;
+ private static CDComponent cdService;
+ private static ABCDComponent abcdService;
+ private static PropertyComponent propertyService;
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'a'
+ */
+ @Test
+ public void testA() {
+ assertEquals("a", abService.getA());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'b'
+ */
+ @Test
+ public void testB() {
+ assertEquals("b", abService.getB());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'c'
+ */
+ @Test
+ public void testC() {
+ assertEquals("c", cdService.getC());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'c'
+ */
+ @Test
+ public void testC2() {
+ assertEquals("c", cdService.getC2());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'd'
+ */
+ @Test
+ public void testD() {
+ assertEquals("d", cdService.getD());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'a'
+ */
+ @Test
+ public void testF() {
+ assertEquals("a", abService.getF());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'z'
+ */
+ @Test
+ public void testZ() {
+ assertEquals("z", abService.getZ());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 1.
+ */
+ @Test
+ public void testIntValue() {
+ assertEquals(1, abService.getIntValue());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 1.
+ */
+ @Test
+ public void testDefaultValue() {
+ assertEquals(1, abService.getIntValue());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 1.
+ */
+ @Test
+ public void testDefaultValueOverride() {
+ assertEquals(1, cdService.getOverrideValue());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value 'aValue'
+ */
+ @Test
+ public void testNoSource() {
+ assertEquals("aValue", cdService.getNoSource());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property value obtained using a service from the SCA runtime environment with the expected value
+ * 'fileValue'
+ */
+ @Test
+ public void testFileProperty() {
+ assertEquals("fileValue", cdService.getFileProperty());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values 4 and
+ * 'fileValueTwo' respectively.
+ */
+ @Test
+ public void testManyValuesFileProperty() {
+ Iterator<String> iterator = cdService.getManyValuesFileProperty().iterator();
+ iterator.next();
+ String secondValue = iterator.next();
+ assertEquals(4, cdService.getManyValuesFileProperty().size());
+ assertEquals("fileValueTwo", secondValue);
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values 'a' ,
+ * 'b', 'c' and 'd' respectively.
+ */
+ @Test
+ public void testABCD() {
+ assertEquals("a", abcdService.getA());
+ assertEquals("b", abcdService.getB());
+ assertEquals("c", abcdService.getC());
+ assertEquals("d", abcdService.getD());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values 'RTP'
+ * and '2006' respectively
+ */
+ @Test
+ public void testDefaultProperty() {
+ assertEquals("RTP", propertyService.getLocation());
+ assertEquals("2006", propertyService.getYear());
+
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values 'Apache' ,
+ * 'Tuscany' and 'Java SCA' respectively .
+ */
+ @Test
+ public void testManySimpleStringValues() {
+ Iterator<String> iterator = abService.getManyStringValues().iterator();
+ assertEquals("Apache", iterator.next());
+ assertEquals("Tuscany", iterator.next());
+ assertEquals("Java SCA", iterator.next());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values 123, 456
+ * and 789 respectively.
+ */
+ @Test
+ public void testManySimpleIntegerValues() {
+ Iterator<Integer> iterator = abService.getManyIntegers().iterator();
+ assertEquals(123, iterator.next().intValue());
+ assertEquals(456, iterator.next().intValue());
+ assertEquals(789, iterator.next().intValue());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values
+ * 'TestString_1' and 2 respectively.
+ */
+ @Test
+ public void testComplexPropertyOne() {
+ ComplexPropertyBean propBean = propertyService.getComplexPropertyOne();
+ assertNotNull(propBean);
+ assertEquals("TestString_1", propBean.getStringArray()[0]);
+ assertEquals(2, propBean.numberSetArray[1].integerNumber);
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected integer number
+ * and a float number
+ */
+ @Test
+ public void testComplexPropertyTwo() {
+ ComplexPropertyBean propBean = propertyService.getComplexPropertyTwo();
+ assertNotNull(propBean);
+ assertEquals(10, propBean.intArray[0]);
+ assertEquals((float)22, propBean.numberSetArray[1].floatNumber);
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected value first
+ * element in the string array and the float number
+ */
+ @Test
+ public void testComplexPropertyThree() {
+ ComplexPropertyBean propBean = propertyService.getComplexPropertyThree();
+ assertNotNull(propBean);
+ assertEquals("TestElementString_1", propBean.stringArray[0]);
+ assertEquals((float)22, propBean.numberSetArray[1].floatNumber);
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * complex property value obtained using a service from the SCA runtime environment with the expected values
+ * 1, 222.222 and 33 respectively.
+ */
+ @Test
+ public void testComplexPropertyFour() {
+ Object[] propBeanCollection = propertyService.getComplexPropertyFour().toArray();
+ assertNotNull(propBeanCollection);
+ assertEquals(1, ((ComplexPropertyBean)propBeanCollection[0]).getIntegerNumber());
+ assertEquals(222.222, ((ComplexPropertyBean)propBeanCollection[1]).getDoubleNumber());
+ assertEquals(33, ((ComplexPropertyBean)propBeanCollection[2]).getNumberSet().getIntegerNumber());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @Test is a test method where testing logic is written using various assert methods. This test verifies the
+ * property values obtained using a service from the SCA runtime environment with the expected values
+ * 'TestString_3', 'TestString_4', 100 and 200.
+ */
+ @Test
+ public void testComplexPropertyFive() {
+ ComplexPropertyBean propBean = propertyService.getComplexPropertyFive();
+ assertNotNull(propBean);
+ assertEquals("TestString_3", propBean.getStringArray()[0]);
+ assertEquals("TestString_4", propBean.getStringArray()[1]);
+ assertEquals(100, propBean.getIntArray()[0]);
+ assertEquals(200, propBean.getIntArray()[1]);
+ }
+
+ @Test
+ public void testGetLocationFromComponentContext() {
+ String location = propertyService.getLocation();
+ assertNotNull(location);
+ String locationFromCC = propertyService.getLocationFromComponentContext();
+ assertNotNull(locationFromCC);
+ assertEquals(location, locationFromCC);
+ }
+
+ @Test
+ public void testGetInjectedStringArrayProperty() {
+ String[] daysOfWeek = propertyService.getDaysOfTheWeek();
+ assertNotNull(daysOfWeek);
+
+ String[] expected = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
+ Assert.assertTrue(Arrays.equals(expected, daysOfWeek));
+ }
+
+ @Test
+ public void testGetInjectedIntegerArrayProperty() {
+ Integer[] numbers = propertyService.getIntegerNumbers();
+ assertNotNull(numbers);
+
+ Integer[] expected = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ Assert.assertTrue(Arrays.equals(expected, numbers));
+ }
+
+ @Test
+ public void testGetInjectedIntArrayProperty() {
+ int[] numbers = propertyService.getIntNumbers();
+ assertNotNull(numbers);
+
+ int[] expected = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ Assert.assertTrue(Arrays.equals(expected, numbers));
+ }
+
+ @Test
+ public void testComplexJAXBProperty() {
+ ReturnCodeProperties rc = propertyService.getComplexJAXBPropertyOne();
+ assertEquals(10, rc.getA());
+ assertEquals(new BigInteger("10"), rc.getB());
+ }
+
+ @Test
+ public void testComplexJAXBPropertyFromFile() {
+ ReturnCodeProperties rc = propertyService.getComplexJAXBPropertyTwo();
+ System.out.println("SKSK: a =" + rc.getA());
+ System.out.println("SKSK: b =" + rc.getB());
+ assertEquals(20, rc.getA());
+ assertEquals(new BigInteger("20"), rc.getB());
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @BeforeClass is used for one time set Up, it executes before every tests. This method is used to create a test
+ * Embedded SCA node, to start the SCA node and to get a reference to 4 services namely 'abService'
+ * service, 'cdService' service, 'abcdService' service and 'propertyService' service
+ */
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String location = ContributionLocationHelper.getContributionLocation("PropertyTest.composite");
+ node = NodeFactory.newInstance().createNode("PropertyTest.composite", new Contribution("c1", location));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ abService = node.getService(ABComponent.class, "ABComponent");
+ cdService = node.getService(CDComponent.class, "CDComponent");
+ abcdService = node.getService(ABCDComponent.class, "ABCDComponent");
+ propertyService = node.getService(PropertyComponent.class, "PropertyComponent");
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @AfterClass is used for one time Tear Down, it executes after every tests. This method is used to close the
+ * node, close any previously opened connections etc
+ */
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java b/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java
new file mode 100644
index 0000000000..a0213ced46
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.cdi;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ConstructorPropertyInjectionTestCase {
+ private static org.apache.tuscany.sca.node.Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String location = ContributionLocationHelper.getContributionLocation("ConstructorPropertyInjection.composite");
+ node = NodeFactory.newInstance().createNode("ConstructorPropertyInjection.composite", new Contribution("c1", location));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @AfterClass is used for one time Tear Down, it executes after every tests. This method is used to close the
+ * node, close any previously opened connections etc
+ */
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testFoo1() throws Exception {
+ Bar foo = node.getService(Bar.class, "Foo1Component");
+ assertEquals("fubar", foo.getBar());
+ }
+
+ @Test
+ public void testFoo2() throws Exception {
+ Bar foo = node.getService(Bar.class, "Foo2Component");
+ assertEquals("fubar", foo.getBar());
+ }
+
+ @Test
+ public void testFoo3() throws Exception {
+ Bar foo = node.getService(Bar.class, "Foo3Component");
+ assertEquals("fubar", foo.getBar());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/pom.xml b/sandbox/sebastien/java/embed/itest/recursive-multi-level/pom.xml
new file mode 100644
index 0000000000..3130da271c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/pom.xml
@@ -0,0 +1,61 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <!--relativePath>../pom.xml</relativePath-->
+ </parent>
+ <artifactId>itest-recursive-multi-level</artifactId>
+ <name>Apache Tuscany SCA iTest Builder Recusive Multi-Level</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- XPathFactory -->
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java
new file mode 100644
index 0000000000..986c8305dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.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 mysca.test.myservice;
+
+public interface MyService {
+ String getLocation();
+
+ String getYear();
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java
new file mode 100644
index 0000000000..6cad998042
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 mysca.test.myservice;
+
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(MyService.class)
+public class MyServiceImpl implements MyService {
+
+ @Property(name = "location")
+ protected String location = "ABC";
+
+ @Property(name = "year")
+ protected String year = "2006";
+
+ public String getLocation() {
+ return location;
+ }
+
+ public String getYear() {
+ return year;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java
new file mode 100644
index 0000000000..a10a430473
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.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 mysca.test.myservice;
+
+public interface MySimpleTotalService {
+ String getLocation();
+
+ String getYear();
+
+ String getYear2();
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java
new file mode 100644
index 0000000000..d00b016e34
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.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 mysca.test.myservice;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(MySimpleTotalService.class)
+public class MySimpleTotalServiceImpl implements MySimpleTotalService {
+ // default required==true so it is 1:1
+ @Reference
+ public MyService myService;
+
+ @Reference
+ private MyService myService2;
+
+ public String getLocation() {
+ return myService.getLocation();
+ }
+
+ public String getYear() {
+ return myService.getYear();
+ }
+
+ public String getYear2() {
+ return myService2.getYear();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite
new file mode 100644
index 0000000000..9ff53cca08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite
@@ -0,0 +1,53 @@
+<?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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ name="TotalComposite1Auto"
+ targetNamespace="http://foo"
+ local="true"
+ autowire="false">
+
+ <property name="newLocation" type="xsd:anyURI">Level 1</property>
+ <property name="newYear" type="xsd:anyURI">2001</property>
+
+ <component name="ServiceComponentLevel1Auto">
+ <implementation.java class="mysca.test.myservice.MyServiceImpl"/>
+ <property name="location" source="$newLocation"/>
+ <property name="year" source="$newYear"/>
+ </component>
+
+ <service name="MyServiceLevel1Auto" promote="TotalServiceComponentLevel1Auto/MySimpleTotalService">
+ <interface.java interface="mysca.test.myservice.MySimpleTotalService"/>
+ </service>
+
+ <component name="TotalServiceComponentLevel1Auto">
+ <implementation.java class="mysca.test.myservice.MySimpleTotalServiceImpl"/>
+ <reference name="myService" autowire="true"/>
+ <reference name="myService2" target="ServiceComponentLevel1Auto"/>
+ </component>
+
+ <reference name="myServiceReference1Auto" promote="TotalServiceComponentLevel1Auto/myService" multiplicity="1..1">
+ <interface.java interface="mysca.test.myservice.MyService"/>
+ </reference>
+</composite>
+
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite
new file mode 100644
index 0000000000..cf8506b4e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite
@@ -0,0 +1,49 @@
+<?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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ name="TotalComposite2Auto"
+ targetNamespace="http://foo"
+ local="true"
+ autowire="false">
+
+ <property name="newLocation" type="xsd:anyURI">Level 2</property>
+ <property name="newYear" type="xsd:anyURI">2002</property>
+
+ <component name="ServiceComponentLevel2Auto">
+ <implementation.java class="mysca.test.myservice.MyServiceImpl"/>
+ <property name="location">Default 2</property>
+ <property name="year">1992</property>
+ </component>
+
+ <service name="MyServiceLevel2Auto" promote="TotalServiceInRecursive2Auto/MyServiceLevel1Auto"/>
+
+ <component name="TotalServiceInRecursive2Auto">
+ <implementation.composite name="foo:TotalComposite1Auto"/>
+ <reference name="myServiceReference1Auto" autowire="true"/>
+ <property name="newLocation" source="$newLocation"/>
+ <property name="newYear" source="$newYear"/>
+ </component>
+
+ <reference name="myServiceReference2Auto" promote="TotalServiceInRecursive2Auto/myServiceReference1Auto" multiplicity="1..1"/>
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite
new file mode 100644
index 0000000000..7386404e71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite
@@ -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.
+ -->
+<composite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ name="TotalComposite3Auto"
+ targetNamespace="http://foo"
+ local="true"
+ autowire="false">
+
+ <property name="newLocation" type="xsd:anyURI">Level 3</property>
+ <property name="newYear" type="xsd:anyURI">2003</property>
+
+ <component name="ServiceComponentLevel3Auto">
+ <implementation.java class="mysca.test.myservice.MyServiceImpl"/>
+ <property name="location">Default 3</property>
+ <property name="year">1993</property>
+ </component>
+
+ <service name="MyServiceLevel3Auto" promote="TotalServiceInRecursive3Auto/MyServiceLevel2Auto">
+ </service>
+
+ <component name="TotalServiceInRecursive3Auto" autowire="true">
+ <implementation.composite name="foo:TotalComposite2Auto"/>
+ <reference name="myServiceReference2Auto"/>
+ <property name="newLocation" source="$newLocation"/>
+ <property name="newYear" source="$newYear"/>
+ </component>
+
+ <reference name="myServiceReference3Auto" promote="TotalServiceInRecursive3Auto/myServiceReference2Auto" multiplicity="1..1">
+ </reference>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java
new file mode 100644
index 0000000000..2dc13c4f42
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package test.sca.tests;
+
+import static org.junit.Assert.assertEquals;
+import mysca.test.myservice.MySimpleTotalService;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests to make sure that autowiring and recusive composite work together
+ *
+ */
+public class MultiLevelTestCase {
+ private static Node node1;
+ private static Node node2;
+ private static Node node3;
+ private static MySimpleTotalService myService1;
+ private static MySimpleTotalService myService2;
+ private static MySimpleTotalService myService3;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("TotalService1Auto.composite");
+ Contribution contribution = new Contribution("c1", location);
+ try {
+ node1 = NodeFactory.newInstance().createNode("TotalService1Auto.composite", contribution);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ node2 = NodeFactory.newInstance().createNode("TotalService2Auto.composite", contribution);
+ node3 = NodeFactory.newInstance().createNode("TotalService3Auto.composite", contribution);
+
+ node1.start();
+ node2.start();
+ node3.start();
+
+ myService1 = node1.getService(MySimpleTotalService.class, "TotalServiceComponentLevel1Auto");
+ myService2 = node2.getService(MySimpleTotalService.class, "TotalServiceInRecursive2Auto/MyServiceLevel1Auto");
+ myService3 = node3.getService(MySimpleTotalService.class, "TotalServiceInRecursive3Auto/MyServiceLevel2Auto");
+ }
+
+ @Test
+ public void testLevel1() {
+ assertEquals("Level 1", myService1.getLocation());
+ assertEquals("2001", myService1.getYear());
+ assertEquals("2001", myService1.getYear2());
+ }
+
+ @Test
+ public void testLevel2() {
+ assertEquals("Default 2", myService2.getLocation());
+ assertEquals("1992", myService2.getYear());
+ assertEquals("2002", myService2.getYear2());
+ }
+
+ @Test
+ public void testLevel3() {
+ assertEquals("Default 3", myService3.getLocation());
+ assertEquals("1993", myService3.getYear());
+ assertEquals("2003", myService3.getYear2());
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ node1.stop();
+ node2.stop();
+ node3.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/pom.xml b/sandbox/sebastien/java/embed/itest/recursive-ws/pom.xml
new file mode 100644
index 0000000000..46eeeafb18
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/pom.xml
@@ -0,0 +1,92 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-recursive-ws</artifactId>
+ <name>Apache Tuscany SCA iTest Recursive WS</name>
+ <version>2.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>${pom.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>${pom.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>${pom.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>${pom.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- Declare tuscany-host-jetty dependency in the default profile so that it can be replaced -->
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/Target.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/Target.java
new file mode 100644
index 0000000000..2366f6542a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/Target.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 policy;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Target {
+ String hello(String arg);
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/TargetClientImpl.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/TargetClientImpl.java
new file mode 100644
index 0000000000..b2d59e925c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/TargetClientImpl.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 policy;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(Target.class)
+public class TargetClientImpl implements Target {
+
+ @Reference
+ protected Target targetService;
+
+ public String hello(String arg) {
+ return "Target: Hello " + targetService.hello(arg) + "!";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/TargetServiceImpl.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/TargetServiceImpl.java
new file mode 100644
index 0000000000..6f52dfb26e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/policy/TargetServiceImpl.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 policy;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service(Target.class)
+public class TargetServiceImpl implements Target {
+
+ public String hello(String arg) {
+ return "Target: Hello " + arg + "!";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/Composer.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/Composer.java
new file mode 100644
index 0000000000..18486115ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/Composer.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 recursive;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Composer {
+ public String Compose(String s);
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerClient.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerClient.java
new file mode 100644
index 0000000000..13c306d9b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerClient.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package recursive;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.Contribution;
+
+/**
+ * For testing purpose
+ */
+public class ComposerClient {
+
+ public final static void main(String[] args) throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+ Node node = factory.createNode(new File("src/main/resources/Client.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ Composer composer = ((Client)node).getService(Composer.class, "ClientComponent/Composer");
+ System.out.println(composer.Compose("ABC"));
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerClientImpl.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerClientImpl.java
new file mode 100644
index 0000000000..3c432bc26a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerClientImpl.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 recursive;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ComposerClientImpl implements Composer {
+ @Reference
+ protected Composer composerWS;
+
+ /**
+ * @see recursive.Composer#Compose(java.lang.String)
+ */
+ public String Compose(String s) {
+ return composerWS.Compose(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerImpl.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerImpl.java
new file mode 100644
index 0000000000..8b77484922
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerImpl.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 recursive;
+
+/**
+ * Composer Component Implementation
+ *
+ */
+
+public class ComposerImpl implements Composer {
+
+ public String Compose(String s) {
+ System.out.println("Composing " + s + "...");
+ return "Composed: " + s;
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerServer.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerServer.java
new file mode 100644
index 0000000000..a123160d85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/java/recursive/ComposerServer.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 recursive;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.Contribution;
+
+/**
+ * For testing purpose
+ */
+public class ComposerServer {
+
+ public final static void main(String[] args) throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+ Node node = factory.createNode(new File("src/main/resources/Outer.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ System.out.println("Press Enter to exit...");
+ System.in.read();
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Client.composite b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Client.composite
new file mode 100644
index 0000000000..50cbaa5086
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Client.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://client" name="Client">
+ <component name="ClientComponent">
+ <implementation.java class="recursive.ComposerClientImpl" />
+ <reference name="composerWS">
+ <binding.ws uri="http://localhost:8085/OuterService"/>
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Inner.composite b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Inner.composite
new file mode 100644
index 0000000000..df7130ba99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Inner.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://inner" name="Inner">
+ <component name="InnerComponent">
+ <implementation.java class="recursive.ComposerImpl" />
+ </component>
+ <service name="OuterService" promote="InnerComponent"/>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Outer.composite b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Outer.composite
new file mode 100644
index 0000000000..1c7d49f1c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/Outer.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://outer" xmlns:inner="http://inner"
+ name="Outer">
+ <component name="OuterComponent">
+ <implementation.composite name="inner:Inner" />
+ <service name="OuterService">
+ <interface.java interface="recursive.Composer" />
+ <binding.ws uri="http://localhost:8085/OuterService" />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/bindingoverride/InnerComposite.composite b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/bindingoverride/InnerComposite.composite
new file mode 100644
index 0000000000..cb6e0cc358
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/bindingoverride/InnerComposite.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://bindingoverride"
+ xmlns:bindingoverride="http://bindingoverride"
+ name="BindingOverrideInnerComposite">
+
+ <service name="InnerService" promote="InnerServiceComponent">
+ <interface.java interface="policy.Target"/>
+ </service>
+
+ <component name="InnerServiceComponent">
+ <implementation.java class="policy.TargetServiceImpl"/>
+ <service name="Target">
+ <interface.java interface="policy.Target"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/bindingoverride/OuterComposite.composite b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/bindingoverride/OuterComposite.composite
new file mode 100644
index 0000000000..3f76efb11b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/bindingoverride/OuterComposite.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://bindingoverride"
+ xmlns:bindingoverride="http://bindingoverride"
+ name="BindingOverrideOuterComposite">
+
+ <component name="OuterClientComponent">
+ <implementation.java class="policy.TargetClientImpl"/>
+ <reference name="targetService" target="OuterServiceComponent"/>
+ </component>
+
+ <component name="OuterServiceComponent">
+ <implementation.composite name="bindingoverride:BindingOverrideInnerComposite"/>
+ <service name="InnerService">
+ <interface.java interface="policy.Target"/>
+ <binding.ws uri="http://localhost:8085/OuterTargetServiceComponent"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/PolicyInnerComposite.composite b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/PolicyInnerComposite.composite
new file mode 100644
index 0000000000..3e78eb4533
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/PolicyInnerComposite.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://policy"
+ xmlns:policy="http://policy"
+ name="PolicyInnerComposite">
+
+ <service name="TargetService" promote="TargetServiceComponent">
+ <interface.java interface="policy.Target"/>
+ </service>
+
+ <component name="TargetServiceComponent">
+ <implementation.java class="policy.TargetServiceImpl"/>
+ <service name="Target">
+ <interface.java interface="policy.Target"/>
+ <binding.ws uri="http://localhost:8085/TargetServiceComponent"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/PolicyOuterComposite.composite b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/PolicyOuterComposite.composite
new file mode 100644
index 0000000000..6e686a579f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/PolicyOuterComposite.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://policy"
+ xmlns:policy="http://policy"
+ name="PolicyOuterComposite"
+ requires="policy:TestIntent_1">
+
+ <component name="TargetClientComponent">
+ <implementation.java class="policy.TargetClientImpl"/>
+ <reference name="targetService" target="OuterTargetServiceComponent"/>
+ </component>
+
+ <component name="OuterTargetServiceComponent">
+ <implementation.composite name="policy:PolicyInnerComposite"/>
+ <service name="TargetService">
+ <interface.java interface="policy.Target"/>
+ <binding.ws uri="http://localhost:8085/OuterTargetServiceComponent"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/definitions.xml b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/definitions.xml
new file mode 100644
index 0000000000..923e1ad5f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/main/resources/policy/definitions.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://policy"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:ip="http://policy" >
+
+ <!-- Policy Intents -->
+ <sca:intent name="TestIntent_1" constrains="sca:binding.ws">
+ <description>Test Intent One</description>
+ </sca:intent>
+
+ <!-- Policy Sets -->
+ <sca:policySet name="TestPolicySet_1_binding"
+ provides="ip:TestIntent_1"
+ appliesTo="sca:binding.ws"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy />
+ </sca:policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/bindingoverride/BindingOverrideTestCase.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/bindingoverride/BindingOverrideTestCase.java
new file mode 100644
index 0000000000..a1b3eb3afa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/bindingoverride/BindingOverrideTestCase.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 bindingoverride;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.Contribution;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import policy.Target;
+
+public class BindingOverrideTestCase{
+
+ private Node node;
+ private Target targetClient;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/bindingoverride/OuterComposite.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/bindingoverride/").toURI().toURL().toString()));
+ node.start();
+ targetClient = ((Client)node).getService(Target.class, "OuterClientComponent");
+ } catch(Exception ex) {
+ System.out.println(ex.toString());
+ }
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ //@Ignore("TUSCANY-2352")
+ public void test() throws Exception {
+ Assert.assertEquals("Target: Hello Target: Hello Fred!!", targetClient.hello("Fred"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/policy/PolicyTestCase.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/policy/PolicyTestCase.java
new file mode 100644
index 0000000000..821a437d12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/policy/PolicyTestCase.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 policy;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.impl.CompositeImpl;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PolicyTestCase{
+
+ private Node node;
+ private Target targetClient;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/policy/PolicyOuterComposite.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/policy/").toURI().toURL().toString()));
+ node.start();
+ targetClient = ((Client)node).getService(Target.class, "TargetClientComponent");
+ } catch(Exception ex) {
+ System.out.println(ex.toString());
+ }
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void test() throws Exception {
+ //Check that the binding policy sets do flow down to the component but not down to the
+ //component inside implementation.composite
+ Component outerComponent = ((NodeImpl)node).getDomainComposite().getComponent("OuterTargetServiceComponent");
+
+ // The outer component service bindings should have policy sets attached
+ Assert.assertEquals(1, outerComponent.getServices().get(0).getPolicySets().size());
+
+ Component component = ((CompositeImpl)outerComponent.getImplementation()).getComponents().get(0);
+
+ // The original inner component service binding should not have policy sets attached
+ Assert.assertEquals(0, ((PolicySet)component.getServices().get(0).getBindings().get(0)).getReferencedPolicySets().size());
+
+ // The promoted inner component service binding should have policy sets attached
+ Assert.assertEquals(1, ((PolicySet)component.getServices().get(1).getBindings().get(0)).getReferencedPolicySets().size());
+
+ String result = targetClient.hello("Fred");
+
+ System.out.println(result);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/recursive/ComposerClientTestCase.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/recursive/ComposerClientTestCase.java
new file mode 100644
index 0000000000..3852947223
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/recursive/ComposerClientTestCase.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 recursive;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.Contribution;
+//import org.apache.tuscany.sca.host.embedded.SCATestCaseRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import recursive.Composer;
+
+/**
+ * Test case for helloworld web service client
+ */
+public class ComposerClientTestCase {
+
+ private Composer composer;
+ private Node node;
+
+ //private SCATestCaseRunner server;
+
+ @Before
+ public void startClient() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/Client.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ composer = ((Client)node).getService(Composer.class, "ClientComponent/Composer");
+
+ //server = new SCATestCaseRunner(ComposerTestServer.class);
+ //server.before();
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testWSClient() throws Exception {
+ String msg = composer.Compose("ABC");
+ Assert.assertEquals("Composed: ABC", msg);
+ }
+
+ @After
+ public void stopClient() throws Exception {
+ //server.after();
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/recursive/ComposerTestServer.java b/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/recursive/ComposerTestServer.java
new file mode 100644
index 0000000000..6ceeb3e3eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/recursive-ws/src/test/java/recursive/ComposerTestServer.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 recursive;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.Contribution;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Starts up the SCA runtime which starts listening for service requests
+ */
+public class ComposerTestServer {
+
+ private Node node;
+
+ @Before
+ public void startServer() throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode(new File("src/main/resources/Outer.composite").toURI().toURL().toString(),
+ new Contribution("TestContribution", new File("src/main/resources/").toURI().toURL().toString()));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testPing() throws IOException {
+ new Socket("127.0.0.1", 8085);
+ }
+
+ @After
+ public void stopServer() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/pom.xml b/sandbox/sebastien/java/embed/itest/references/pom.xml
new file mode 100644
index 0000000000..9da71f2ee8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/pom.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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-references</artifactId>
+ <name>Apache Tuscany SCA iTest References</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java
new file mode 100644
index 0000000000..f8c0850118
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.references;
+
+public interface AComponent {
+
+ String fooB();
+
+ String fooC();
+
+ String fooBC();
+
+ String fooD1();
+
+ String fooD2();
+
+ String fooMultipleD();
+
+ String fooMultipleDArray();
+
+ String fooMultipleDServiceRef();
+
+ DComponent getDReference();
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java
new file mode 100644
index 0000000000..cd0aad3eea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.references;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Reference;
+
+public class AComponentImpl implements AComponent {
+
+ @Reference(name = "bReference")
+ protected BComponent b;
+
+ @Reference
+ private CComponent cReference;
+
+ @Reference(required = false)
+ protected DComponent dReference;
+
+ @Reference(name = "dReferences")
+ public Collection<DComponent> dReferences;
+
+ @Reference(name = "dReferenceArray")
+ public DComponent[] dReferenceArray;
+
+ @Reference(name = "dServiceReferences")
+ public List<ServiceReference<DComponent>> dServiceReferences;
+
+ private DComponent dReference1;
+
+ private DComponent dReference2;
+
+ @Reference(name = "dReference1", required = false)
+ public void setDReference(DComponent dReference) {
+ this.dReference1 = dReference;
+ }
+
+ @Reference
+ public void setDReference2(DComponent dReference2) {
+ this.dReference2 = dReference2;
+ }
+
+ public String fooB() {
+ return b.bFoo();
+ }
+
+ public String fooC() {
+ return cReference.cFoo();
+ }
+
+ public String fooBC() {
+ return b.fooC();
+ }
+
+ public String fooD() {
+ return dReference1.dFoo();
+ }
+
+ public String fooD1() {
+ return dReference1.dFoo();
+ }
+
+ public String fooD2() {
+ return dReference2.dFoo();
+ }
+
+ public String fooMultipleDArray() {
+ StringBuffer str = new StringBuffer();
+ for (DComponent d : dReferenceArray) {
+ str.append(d.getComponentName());
+ str.append(',');
+ }
+ if (str.length() > 0) {
+ str.deleteCharAt(str.length() - 1);
+ }
+ return str.toString();
+ }
+
+ public String fooMultipleD() {
+ StringBuffer str = new StringBuffer();
+ for (DComponent d : dReferences) {
+ str.append(d.getComponentName());
+ str.append(',');
+ }
+ if (str.length() > 0) {
+ str.deleteCharAt(str.length() - 1);
+ }
+ return str.toString();
+ }
+
+ public String fooMultipleDServiceRef() {
+ StringBuffer str = new StringBuffer();
+ for (ServiceReference<DComponent> d : dServiceReferences) {
+ str.append(d.getService().getComponentName());
+ str.append(',');
+ }
+ if (str.length() > 0) {
+ str.deleteCharAt(str.length() - 1);
+ }
+ return str.toString();
+ }
+
+ public DComponent getDReference() {
+ return dReference;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java
new file mode 100644
index 0000000000..785920bb2d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.references;
+
+public interface BComponent {
+
+ String bFoo();
+
+ String fooC();
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java
new file mode 100644
index 0000000000..211e6160f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.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.sca.itest.references;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class BComponentImpl implements BComponent {
+
+ protected CComponent cReference;
+
+ public BComponentImpl(@Reference(name = "cReference") CComponent cReference) {
+ this.cReference = cReference;
+ }
+
+ public String bFoo() {
+ return "BComponent";
+ }
+
+ public String fooC() {
+ return "B" + cReference.cFoo();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java
new file mode 100644
index 0000000000..47a1f9bde8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.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.sca.itest.references;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class BComponentWrongTargetImpl implements BComponent {
+
+ protected CComponent cReference;
+
+ public BComponentWrongTargetImpl(@Reference(name = "cReference") CComponent cReference) {
+ this.cReference = cReference;
+ }
+
+ public String bFoo() {
+ return "BComponentWrongTarget";
+ }
+
+ public String fooC() {
+ return "B" + cReference.cFoo();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java
new file mode 100644
index 0000000000..d436c28adc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.references;
+
+public interface CComponent {
+
+ String cFoo();
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java
new file mode 100644
index 0000000000..a1823e1cdc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.references;
+
+public class CComponentImpl implements CComponent {
+
+ public String cFoo() {
+ return "CComponent";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java
new file mode 100644
index 0000000000..80617bdec2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.references;
+
+public interface DComponent {
+
+ String dFoo();
+
+ String getComponentName();
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java
new file mode 100644
index 0000000000..d181ac96ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.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 org.apache.tuscany.sca.itest.references;
+
+import org.oasisopen.sca.annotation.ComponentName;
+
+public class DComponentImpl implements DComponent {
+ @ComponentName
+ public String name;
+
+ public String dFoo() {
+ return "DComponent";
+ }
+
+ public String getComponentName() {
+ return name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/resources/AutoWiredReferencesTest.composite b/sandbox/sebastien/java/embed/itest/references/src/main/resources/AutoWiredReferencesTest.composite
new file mode 100644
index 0000000000..14899fce62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/resources/AutoWiredReferencesTest.composite
@@ -0,0 +1,61 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="AutowireReferencesTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autowire="true">
+
+ <component name="AComponent" autowire="false">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.AComponentImpl" />
+ <reference name="bReference" target="BComponent" />
+ <reference name="cReference" autowire="true" />
+ <reference name="dReference1" multiplicity="0..1"/>
+ <!--
+ <reference name="dReference1" target="DComponent" />
+ -->
+ <reference name="DReference2" target="DComponent" />
+ <reference name="dReferences" autowire="true" />
+ <reference name="dReferenceArray" autowire="true" />
+ <reference name="dServiceReferences" target="DComponent DComponent1" />
+
+ </component>
+
+ <component name="AComponentAutowire" autowire="true">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.AComponentImpl" />
+ <reference name="bReference" target="BComponent" />
+ </component>
+
+ <component name="BComponentWrongTarget">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.BComponentWrongTargetImpl" />
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.BComponentImpl" />
+ </component>
+
+ <component name="CComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.CComponentImpl" />
+ </component>
+
+ <component name="DComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
+ </component>
+
+ <component name="DComponent1">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
+ </component>
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/resources/InnerReferencesTest.composite b/sandbox/sebastien/java/embed/itest/references/src/main/resources/InnerReferencesTest.composite
new file mode 100644
index 0000000000..7048eaf371
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/resources/InnerReferencesTest.composite
@@ -0,0 +1,51 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="InnerReferencesTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.AComponentImpl" />
+ <reference name="bReference" target="BComponent" />
+ <reference name="cReference" target="CComponent" />
+ <reference name="dReference1" target="DComponent" />
+ <reference name="DReference2" target="DComponent" />
+ <reference name="dReferences" target="DComponent DComponent1" />
+ <reference name="dReferenceArray" target="DComponent1" />
+ <reference name="dServiceReferences" target="DComponent DComponent1" />
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.BComponentImpl" />
+ <reference name="cReference" target="CComponent" />
+ </component>
+
+ <component name="CComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.CComponentImpl" />
+ </component>
+
+ <component name="DComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
+ </component>
+
+ <component name="DComponent1">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/references/src/main/resources/ManualWiredReferencesTest.composite b/sandbox/sebastien/java/embed/itest/references/src/main/resources/ManualWiredReferencesTest.composite
new file mode 100644
index 0000000000..dbf72f67b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/main/resources/ManualWiredReferencesTest.composite
@@ -0,0 +1,59 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="ManualWiredReferencesTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autowire="true">
+
+ <component name="AComponent" >
+ <implementation.java class="org.apache.tuscany.sca.itest.references.AComponentImpl" />
+ <reference name="bReference" target="BComponent" />
+ <reference name="cReference" target="CComponent/CComponentImpl">
+ <!-- reference name="cReference" target="CComponent"-->
+ </reference>
+ <reference name="dReference1" >
+ <binding.sca uri="DComponent"/>
+ </reference>
+ <reference name="DReference2" target="DComponent" >
+ <!-- binding.ws uri="DComponent"/-->
+ </reference>
+ <reference name="dReferences" target="DComponent DComponent1" />
+ <reference name="dReferenceArray" target="DComponent DComponent1" />
+ <reference name="dServiceReferences" target="DComponent DComponent1" />
+
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.BComponentImpl" />
+ </component>
+
+ <component name="CComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.CComponentImpl" />
+ </component>
+
+ <component name="DComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
+ <service name="DComponentImpl">
+ <binding.sca/>
+ <!-- binding.ws/-->
+ </service>
+ </component>
+
+ <component name="DComponent1">
+ <implementation.java class="org.apache.tuscany.sca.itest.references.DComponentImpl" />
+ </component>
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java b/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java
new file mode 100644
index 0000000000..76264d308f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.references;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+public class AutoWiredReferenceTestCase {
+ private static Node node;
+ private static AComponent acomponent;
+ private static AComponent acomponentAutowire;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String location = ContributionLocationHelper.getContributionLocation("AutoWiredReferencesTest.composite");
+ node =
+ NodeFactory.newInstance().createNode("AutoWiredReferencesTest.composite",
+ new Contribution("c1", location));
+ node.start();
+ acomponent = node.getService(AComponent.class, "AComponent");
+ acomponentAutowire = node.getService(AComponent.class, "AComponentAutowire");
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testBReference() {
+ assertEquals("BComponent", acomponent.fooB());
+ }
+
+ @Test
+ public void testCReference() {
+ assertEquals("CComponent", acomponent.fooC());
+ }
+
+ @Test
+ public void testBCReference() {
+ assertEquals("BCComponent", acomponent.fooBC());
+ }
+
+ @Test(expected = Exception.class)
+ public void testD1Reference() {
+ acomponent.fooD1();
+ }
+
+ @Test
+ public void testD2Reference() {
+ assertEquals("DComponent", acomponent.fooD2());
+ }
+
+ @Test
+ public void testMultiDReferenceArray() {
+ String components = acomponent.fooMultipleDArray();
+ Assert.assertTrue(components.contains("DComponent1"));
+ }
+
+ @Test
+ public void testMultiDServiceReference() {
+ String components = acomponent.fooMultipleDServiceRef();
+ Assert.assertTrue(components.contains("DComponent"));
+ Assert.assertTrue(components.contains("DComponent1"));
+ }
+
+ @Test
+ public void testRequiredFalseReference() {
+ try {
+ acomponent.getDReference().dFoo();
+ } catch (Exception e) {
+ Assert.assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testTargetPrecendence() {
+ try {
+ assertEquals("BComponent", acomponentAutowire.fooB());
+ } catch (Exception e) {
+ Assert.assertTrue(true);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java b/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java
new file mode 100644
index 0000000000..6e4212fd9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.references;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class InnerReferenceTestCase {
+ private static Node node;
+ private static AComponent acomponent;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("InnerReferencesTest.composite");
+ node = NodeFactory.newInstance().createNode("InnerReferencesTest.composite", new Contribution("c1", location));
+ node.start();
+ acomponent = node.getService(AComponent.class, "AComponent");
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testBReference() {
+ assertEquals("BComponent", acomponent.fooB());
+ }
+
+ @Test
+ public void testCReference() {
+ assertEquals("CComponent", acomponent.fooC());
+ }
+
+ @Test
+ public void testBCReference() {
+ assertEquals("BCComponent", acomponent.fooBC());
+ }
+
+ @Test
+ public void testD1Reference() {
+ assertEquals("DComponent", acomponent.fooD1());
+ }
+
+ @Test
+ public void testD2Reference() {
+ assertEquals("DComponent", acomponent.fooD2());
+ }
+
+ @Test
+ public void testMultiDReference() {
+ String components = acomponent.fooMultipleD();
+ Assert.assertTrue(components.contains("DComponent"));
+ Assert.assertTrue(components.contains("DComponent1"));
+ }
+
+ @Test
+ public void testMultiDReferenceArray() {
+ String components = acomponent.fooMultipleDArray();
+ Assert.assertTrue(components.equals("DComponent1"));
+ }
+
+ @Test
+ public void testMultiDServiceReference() {
+ String components = acomponent.fooMultipleDServiceRef();
+ Assert.assertTrue(components.contains("DComponent"));
+ Assert.assertTrue(components.contains("DComponent1"));
+ }
+
+ @Test(expected = Exception.class)
+ public void testRequiredFalseReference() {
+ acomponent.getDReference().dFoo();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java b/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java
new file mode 100644
index 0000000000..2fce95401e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.references;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class ManualWiredReferenceTestCase {
+ private static Node node;
+ private static AComponent acomponent;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("ManualWiredReferencesTest.composite");
+ node = NodeFactory.newInstance().createNode("ManualWiredReferencesTest.composite", new Contribution("c1", location));
+ node.start();
+ acomponent = node.getService(AComponent.class, "AComponent");
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testBReference() {
+ assertEquals("BComponent", acomponent.fooB());
+ }
+
+ @Test
+ public void testCReference() {
+ assertEquals("CComponent", acomponent.fooC());
+ }
+
+ @Test
+ public void testBCReference() {
+ assertEquals("BCComponent", acomponent.fooBC());
+ }
+
+ @Test
+ public void testD1Reference() {
+ acomponent.fooD1();
+ }
+
+ @Test
+ public void testD2Reference() {
+ assertEquals("DComponent", acomponent.fooD2());
+ }
+
+ @Test
+ public void testMultiDReferenceArray() {
+ String components = acomponent.fooMultipleDArray();
+ Assert.assertTrue(components.contains("DComponent1"));
+ }
+
+ @Test
+ public void testMultiDServiceReference() {
+ String components = acomponent.fooMultipleDServiceRef();
+ Assert.assertTrue(components.contains("DComponent"));
+ Assert.assertTrue(components.contains("DComponent1"));
+ }
+
+ @Test
+ public void testRequiredFalseReference() {
+ try {
+ acomponent.getDReference().dFoo();
+ } catch (Exception e) {
+ Assert.assertTrue(true);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/samples/helloworld/pom.xml b/sandbox/sebastien/java/embed/itest/samples/helloworld/pom.xml
new file mode 100644
index 0000000000..c8817be0f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/samples/helloworld/pom.xml
@@ -0,0 +1,38 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-samples-helloworld</artifactId>
+ <name>Apache Tuscany SCA iTest Samples Helloworld</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/Helloworld.java b/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/Helloworld.java
new file mode 100644
index 0000000000..38dc80bed3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/Helloworld.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/HelloworldDomainNodeTestCase.java b/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/HelloworldDomainNodeTestCase.java
new file mode 100644
index 0000000000..dd46d68547
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/HelloworldDomainNodeTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest.helloworld;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.domain.node.DomainNode;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class HelloworldDomainNodeTestCase {
+
+ DomainNode node;
+
+ @Before
+ public void setUp() throws Exception {
+ node = new DomainNode("../../../samples/helloworld/target/sample-helloworld.zip");
+ }
+
+ @Test
+ public void testHelloworld() throws NoSuchServiceException {
+ assertEquals(1, node.getServiceNames().size());
+ assertEquals("HelloworldComponent/Helloworld", node.getServiceNames().get(0));
+ Helloworld service = node.getService(Helloworld.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @After
+ public void stop() {
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/HelloworldNodeTestCase.java b/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/HelloworldNodeTestCase.java
new file mode 100644
index 0000000000..37950f1276
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/samples/helloworld/src/test/java/itest/helloworld/HelloworldNodeTestCase.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest.helloworld;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class HelloworldNodeTestCase {
+
+ Node node;
+
+ @Before
+ public void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode(null, new String[]{"../../../samples/helloworld/target/sample-helloworld.zip"}).start();
+ }
+
+ @Test
+ public void testHelloworld() {
+ Helloworld service = node.getService(Helloworld.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @After
+ public void stop() {
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/pom.xml b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/pom.xml
new file mode 100644
index 0000000000..2e0ff027b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/pom.xml
@@ -0,0 +1,57 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-scaclient-api-jse-osgi</artifactId>
+ <name>Apache Tuscany SCA iTest SCAClient API JSE and OSGI</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/java/itest/HelloworldService.java b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/java/itest/HelloworldService.java
new file mode 100644
index 0000000000..1c7edaefb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/java/itest/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 itest;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/java/itest/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/java/itest/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..7793bdd544
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/java/itest/HelloworldServiceImpl.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 itest;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@EagerInit
+@Scope("COMPOSITE")
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ @Init
+ public void init() {
+ System.out.println("Init - " + sayHello("world"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/resources/Helloworld.composite b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/resources/Helloworld.composite
new file mode 100644
index 0000000000..2d5ae6a57c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/resources/Helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="Helloworld">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="itest.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..56e127b539
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:Helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/test/java/test/scaclient/SCAClientTestCase.java b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/test/java/test/scaclient/SCAClientTestCase.java
new file mode 100644
index 0000000000..8bf162dfd9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-jse-osgi/src/test/java/test/scaclient/SCAClientTestCase.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 test.scaclient;
+
+import java.net.URI;
+
+import itest.HelloworldService;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * Test SCADomain.newInstance and invocation of a service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAClientTestCase extends TestCase {
+
+ private static NodeLauncher launcher;
+ private static Node node;
+
+ @Override
+ protected void setUp() throws Exception {
+ launcher = NodeLauncher.newInstance();
+ node = launcher.createNode(null, new Contribution("test", "./target/classes"));
+ System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader());
+ node.start();
+ }
+
+ public void testInvoke() throws Exception {
+ // At the moment the SCAClientFactory assumes that only one domain is active
+ // in a JVM. So we pass in null for the domain name and get what we're given
+ HelloworldService service =
+ SCAClientFactory.newInstance(URI.create("default")).getService(HelloworldService.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ae6704f97d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Private-Package: helloworld;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA SCAClient API OSGi itest
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: false
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1223949424781
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA SCAClient API OSGi itest
+Import-Package: org.apache.tuscany.sca.node;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.oasisopen.sca.client;version="2.0.0",
+ org.osgi.framework;version="1.4"
+Bundle-SymbolicName: itest-scaclient-apo-osgi
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/pom.xml b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/pom.xml
new file mode 100644
index 0000000000..b75879bcad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/pom.xml
@@ -0,0 +1,109 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-scaclient-api-osgi</artifactId>
+ <name>Apache Tuscany SCA iTest SCAClient API OSGi</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <buildcommands>
+ <buildcommand>org.eclipse.pde.ManifestBuilder</buildcommand>
+ <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+ </buildcommands>
+ <projectnatures>
+ <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+ <projectnature>org.eclipse.pde.PluginNature</projectnature>
+ </projectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+ </classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-osgi-junit-plugin</artifactId>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>osgi-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration></configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/java/itest/HelloworldService.java b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/java/itest/HelloworldService.java
new file mode 100644
index 0000000000..1c7edaefb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/java/itest/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 itest;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/java/itest/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/java/itest/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..3eecc59439
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/java/itest/HelloworldServiceImpl.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 itest;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@EagerInit
+@Scope("COMPOSITE")
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ @Init
+ public void init() {
+ System.out.println("Result from Init = " + sayHello("world"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/resources/Helloworld.composite b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/resources/Helloworld.composite
new file mode 100644
index 0000000000..2d5ae6a57c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/resources/Helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="Helloworld">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="itest.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..56e127b539
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:Helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/test/java/test/scaclient/SCAClientTestCase.java b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/test/java/test/scaclient/SCAClientTestCase.java
new file mode 100644
index 0000000000..431b2995aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-osgi/src/test/java/test/scaclient/SCAClientTestCase.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 test.scaclient;
+
+import java.net.URI;
+
+import itest.HelloworldService;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * Test SCADomain.newInstance and invocation of a service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAClientTestCase extends TestCase {
+
+ private static Node node;
+
+ @Override
+ protected void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation(HelloworldService.class);
+ node = NodeFactory.getInstance().createNode("Helloworld.composite", new Contribution("test", "./target/classes"));
+ System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader());
+ node.start();
+ }
+
+ public void testInvoke() throws NoSuchServiceException, NoSuchDomainException {
+ HelloworldService service =
+ SCAClientFactory.newInstance(URI.create("default")).getService(HelloworldService.class, "HelloworldComponent");
+ String result = service.sayHello("petra");
+ assertEquals("Hello petra", result);
+ System.out.println("Result from SCAClient call = " + result);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-remote/pom.xml b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/pom.xml
new file mode 100644
index 0000000000..f807c9883f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/pom.xml
@@ -0,0 +1,64 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-scaclient-api-remote</artifactId>
+ <name>Apache Tuscany SCA iTest SCAClient API with Hazelcast client</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/java/itest/HelloworldService.java b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/java/itest/HelloworldService.java
new file mode 100644
index 0000000000..f97d2c3a83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/java/itest/HelloworldService.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 itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/java/itest/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/java/itest/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..a04b40279f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/java/itest/HelloworldServiceImpl.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 itest;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@EagerInit
+@Scope("COMPOSITE")
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ @Init
+ public void init() {
+ System.out.println(sayHello("world"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/resources/Helloworld.composite b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/resources/Helloworld.composite
new file mode 100644
index 0000000000..d37c93857d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/resources/Helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="Helloworld">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="itest.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e178823296
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:Helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/test/java/test/scaclient/SCAClientTestCase.java b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/test/java/test/scaclient/SCAClientTestCase.java
new file mode 100644
index 0000000000..0ae70d6c3f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api-remote/src/test/java/test/scaclient/SCAClientTestCase.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 test.scaclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import itest.HelloworldService;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * Test SCADomain.newInstance and invocation of a service.
+ *
+ * @version $Rev: 904064 $ $Date: 2010-01-28 12:31:36 +0000 (Thu, 28 Jan 2010) $
+ */
+public class SCAClientTestCase {
+
+ private Node node;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ @Test
+ public void testDefault() throws Exception {
+
+ node = NodeFactory.newInstance().createNode((String)null, new String[] {"target/classes"});
+ node.start();
+
+ HelloworldService service = SCAClientFactory.newInstance(URI.create("default")).getService(HelloworldService.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @Test
+ public void testURIconfig() throws Exception {
+
+ node = NodeFactory.newInstance("uri:somedomain").createNode((String)null, new String[] {"target/classes"});
+ node.start();
+
+ HelloworldService service = SCAClientFactory.newInstance(URI.create("somedomain")).getService(HelloworldService.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ try {
+ service = SCAClientFactory.newInstance(URI.create("nosuchdomain")).getService(HelloworldService.class, "HelloworldComponent");
+ service.sayHello("petra");
+ fail();
+ } catch (Exception e) {
+ if (!(e.getCause() instanceof NoSuchDomainException)) {
+ throw e;
+ }
+ }
+ }
+
+ @Test
+ public void testExplicit() throws Exception {
+ node = NodeFactory.newInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"});
+ node.start();
+
+ HelloworldService service = SCAClientFactory.newInstance(URI.create("myFooDomain")).getService(HelloworldService.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @Test
+ public void testExplicitRemote() throws Exception {
+ node = NodeFactory.newInstance("uri:myFooDomain?bind=127.0.0.1:14821").createNode((String)null, new String[] {"target/classes"});
+ node.start();
+
+ HelloworldService service = SCAClientFactory.newInstance(URI.create("uri:myFooDomain?wka=127.0.0.1:14821")).getService(HelloworldService.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @Test
+ public void testExplicitRemote2() throws Exception {
+ node = NodeFactory.newInstance("uri:myFooDomain?bind=127.0.0.1:14821").createNode((String)null, new String[] {"target/classes"});
+ node.start();
+
+ HelloworldService service = SCAClientFactory.newInstance(URI.create("uri:myFooDomain?wka=127.0.0.1:14821")).getService(HelloworldService.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api/pom.xml b/sandbox/sebastien/java/embed/itest/scaclient-api/pom.xml
new file mode 100644
index 0000000000..795221292c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api/pom.xml
@@ -0,0 +1,46 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-scaclient-api</artifactId>
+ <name>Apache Tuscany SCA iTest SCAClient API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/HelloworldService.java b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/HelloworldService.java
new file mode 100644
index 0000000000..1c7edaefb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/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 itest;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..5af221313e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.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 itest;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@EagerInit
+@Scope("COMPOSITE")
+@Service({HelloworldService.class, RemoteHelloworldService.class})
+public class HelloworldServiceImpl implements HelloworldService, RemoteHelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ public String sayHelloRemote(String name) {
+ return "Hello " + name;
+ }
+
+ @Init
+ public void init() {
+ System.out.println(sayHello("world"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/RemoteHelloworldService.java b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/RemoteHelloworldService.java
new file mode 100644
index 0000000000..a8640bf484
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/java/itest/RemoteHelloworldService.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 itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface RemoteHelloworldService {
+
+ String sayHelloRemote(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/resources/Helloworld.composite b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/resources/Helloworld.composite
new file mode 100644
index 0000000000..2d5ae6a57c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/resources/Helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="Helloworld">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="itest.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..56e127b539
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:Helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java b/sandbox/sebastien/java/embed/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java
new file mode 100644
index 0000000000..6a639661cf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 test.scaclient;
+
+import itest.HelloworldService;
+import itest.RemoteHelloworldService;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * Test SCADomain.newInstance and invocation of a service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAClientTestCase extends TestCase {
+
+ private Node node;
+
+ @Test
+ public void testDefault() throws Exception {
+
+ node = NodeFactory.getInstance().createNode((String)null, new String[] {"target/classes"});
+ node.start();
+
+ SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("default"));
+ HelloworldService service = clientFactory.getService(HelloworldService.class, "HelloworldComponent/HelloworldService");
+ assertEquals("Hello petra", service.sayHello("petra"));
+
+ RemoteHelloworldService remoteService = clientFactory.getService(RemoteHelloworldService.class, "HelloworldComponent/RemoteHelloworldService");
+ assertEquals("Hello petra", remoteService.sayHelloRemote("petra"));
+
+ }
+
+ @Test
+ public void testExplicit() throws Exception {
+ node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"});
+ node.start();
+
+ SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain"));
+ HelloworldService service = clientFactory.getService(HelloworldService.class, "HelloworldComponent/HelloworldService");
+ assertEquals("Hello petra", service.sayHello("petra"));
+
+ RemoteHelloworldService remoteService = clientFactory.getService(RemoteHelloworldService.class, "HelloworldComponent/RemoteHelloworldService");
+ assertEquals("Hello petra", remoteService.sayHelloRemote("petra"));
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+// @Test
+// public void testWithoutServiceName() throws Exception {
+// node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"});
+// node.start();
+//
+// SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain"));
+// HelloworldService service = clientFactory.getService(HelloworldService.class, "HelloworldComponent");
+// assertEquals("Hello petra", service.sayHello("petra"));
+// }
+
+ @Test
+ public void testWithBadServiceName() throws Exception {
+ node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"});
+ node.start();
+
+ SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain"));
+ try {
+ clientFactory.getService(HelloworldService.class, "HelloworldComponent/foo");
+ fail();
+ } catch (NoSuchServiceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testWithBadDomainName() throws Exception {
+ node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"});
+ node.start();
+
+ SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("someBadDomainName"));
+ try {
+ HelloworldService service = clientFactory.getService(HelloworldService.class, "HelloworldComponent/foo");
+ service.sayHello("petra");
+ fail();
+ } catch (Exception e) {
+ if (!(e.getCause() instanceof NoSuchDomainException)) {
+ throw e;
+ }
+ }
+ }
+
+ // @Test @Ignore
+// public void testHTTPURI() throws Exception {
+// node = NodeFactory.getInstance().createNode(URI.create("http://defaultDomain"), new String[] {"target/classes"});
+// node.start();
+//
+// HelloworldService service = SCAClientFactory.newInstance(URI.create("http://defaultDomain")).getService(HelloworldService.class, "HelloworldComponent");
+// assertEquals("Hello petra", service.sayHello("petra"));
+// }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scdl/pom.xml b/sandbox/sebastien/java/embed/itest/scdl/pom.xml
new file mode 100644
index 0000000000..54e1c132ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scdl/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-scdl</artifactId>
+ <name>Apache Tuscany SCA iTest SCDL</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-deployment</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Copy all the dependencies so the test can verify only the expected ones get dragged in -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java b/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java
new file mode 100644
index 0000000000..97fdb53d6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.scdl;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.deployment.DefaultDeployer;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test case for reading and writing SCDL
+ */
+public class ContributionTestCase {
+
+ @Test
+ public void testRead() throws Exception {
+ Deployer deployer = new DefaultDeployer();
+ File file = new File("../../samples/binding-sca/contribution-calculator/target/sample-contribution-binding-sca-calculator.jar");
+ URL url = file.toURI().toURL();
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(url.toURI(), url, monitor);
+ deployer.build(Arrays.asList(contribution), Arrays.asList(contribution), null, monitor);
+
+ // Ferkle around in the contribution verifying it looks as expected
+ Assert.assertNotNull(contribution);
+ List<Composite> deployables = contribution.getDeployables();
+ Assert.assertEquals(2, deployables.size());
+ Composite calculatorComposte = deployables.get(0);
+ Assert.assertEquals("Calculator", calculatorComposte.getName().getLocalPart());
+ Assert.assertEquals(5, calculatorComposte.getComponents().size());
+ Component calcComp = calculatorComposte.getComponent("CalculatorServiceComponent");
+ Assert.assertNotNull(calcComp);
+ Assert.assertEquals(4, calcComp.getReferences().size());
+ Reference ref = calcComp.getReference("addService");
+ Assert.assertEquals("AddServiceComponent", ref.getTargets().get(0).getName());
+ Implementation impl = calcComp.getImplementation();
+ Assert.assertTrue(impl instanceof JavaImplementation);
+ Assert.assertEquals("calculator.CalculatorServiceImpl", ((JavaImplementation)impl).getJavaClass().getName());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java b/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java
new file mode 100644
index 0000000000..7dd52c5942
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.scdl;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jsonp.JSONPBinding;
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.junit.Test;
+
+/**
+ * Test case for reading and writing a composite
+ */
+public class SCDLTestCase {
+
+ @Test
+ public void testRead() throws ContributionReadException, XMLStreamException {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ Deployer deployer = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Deployer.class);
+
+ URL r = getClass().getResource("/test.composite");
+ Composite composite = deployer.loadXMLDocument(r, null);
+ Assert.assertNotNull(composite);
+
+ Component JavaComp = composite.getComponent("JavaComponent");
+ Assert.assertNotNull(JavaComp);
+
+ Component bpelComp = composite.getComponent("BPELComponent");
+ Assert.assertNotNull(bpelComp);
+
+ Service jsonpService = composite.getService("JSONPService");
+ Assert.assertNotNull(jsonpService);
+ Assert.assertEquals(1, jsonpService.getBindings().size());
+ JSONPBinding jsonpBinding = jsonpService.getBinding(JSONPBinding.class);
+ Assert.assertNotNull(jsonpBinding);
+
+ Service jmsService = composite.getService("JMSService");
+ Assert.assertNotNull(jmsService);
+ Assert.assertEquals(1, jmsService.getBindings().size());
+ JMSBinding jmsBinding = jmsService.getBinding(JMSBinding.class);
+ Assert.assertNotNull(jmsBinding);
+
+ Service rmiService = composite.getService("RMIService");
+ Assert.assertNotNull(rmiService);
+ Assert.assertEquals(1, rmiService.getBindings().size());
+ RMIBinding rmiBinding = rmiService.getBinding(RMIBinding.class);
+ Assert.assertNotNull(rmiBinding);
+
+// TODO: WS binding drags in entire runtime
+// Service wsService = composite.getService("WSService");
+// Assert.assertNotNull(wsService);
+// Assert.assertEquals(1, wsService.getBindings().size());
+// WSBinding wsBinding = wsService.getBinding(WSBinding.class);
+// Assert.assertNotNull(wsBinding);
+ }
+
+ @Test
+ public void testBuild() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ Deployer deployer = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Deployer.class);
+ URL r = getClass().getResource("/test.composite");
+ r = new URL(r, "../");
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(URI.create("c1"), r, monitor);
+ deployer.build(Arrays.asList(contribution), Arrays.asList(contribution), null, monitor);
+ int i = 0;
+ for (Problem p : monitor.getProblems()) {
+ System.err.println(i + ": " + p);
+ i++;
+ }
+ Assert.assertTrue(i > 0);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java b/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
new file mode 100644
index 0000000000..9cb6374b7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.scdl;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+/**
+ * Test case for verifying only SCDL jars are needed
+ *
+ * Uses maven-dependency-plugin config in the pom.xml
+ *
+ * Current required jars are:
+ *
+ * activation-1.1.jar
+ * asm-3.1.jar
+ * geronimo-stax-api_1.0_spec-1.0.1.jar
+ * jaxb-api-2.1.jar
+ * jaxb-impl-2.1.12.jar
+ * jaxws-api-2.1.jar
+ * jsr181-api-1.0-MR1.jar
+ * jsr250-api-1.0.jar
+ * junit-4.8.1.jar
+ * tuscany-assembly-2.0-SNAPSHOT.jar
+ * tuscany-assembly-xml-2.0-SNAPSHOT.jar
+ * tuscany-assembly-xsd-2.0-SNAPSHOT.jar
+ * tuscany-binding-jms-2.0-SNAPSHOT.jar
+ * tuscany-binding-jsonp-2.0-SNAPSHOT.jar
+ * tuscany-binding-rmi-2.0-SNAPSHOT.jar
+ * tuscany-binding-ws-2.0-SNAPSHOT.jar
+ * tuscany-builder-2.0-SNAPSHOT.jar
+ * tuscany-common-java-2.0-SNAPSHOT.jar
+ * tuscany-common-xml-2.0-SNAPSHOT.jar
+ * tuscany-contribution-2.0-SNAPSHOT.jar
+ * tuscany-core-spi-2.0-SNAPSHOT.jar
+ * tuscany-databinding-2.0-SNAPSHOT.jar
+ * tuscany-databinding-jaxb-2.0-SNAPSHOT.jar
+ * tuscany-deployment-2.0-SNAPSHOT.jar
+ * tuscany-extensibility-2.0-SNAPSHOT.jar
+ * tuscany-implementation-java-2.0-SNAPSHOT.jar
+ * tuscany-interface-java-2.0-SNAPSHOT.jar
+ * tuscany-interface-java-jaxws-2.0-SNAPSHOT.jar
+ * tuscany-interface-wsdl-2.0-SNAPSHOT.jar
+ * tuscany-monitor-2.0-SNAPSHOT.jar
+ * tuscany-sca-api-2.0-SNAPSHOT.jar
+ * tuscany-xsd-2.0-SNAPSHOT.jar
+ * wsdl4j-1.6.2.jar
+ * wstx-asl-3.2.4.jar
+ * XmlSchema-1.4.3.jar
+ *
+ * TODO: WS binding drags in all runtime
+ */
+public class ValidateDependenciesTestCase {
+
+ @Test
+ public void countDependencies() {
+
+ File dependenciesDir = new File("target/dependency");
+ Assert.assertTrue(dependenciesDir.exists());
+
+ File[] dependencyFiles = dependenciesDir.listFiles();
+ Assert.assertEquals(35, dependencyFiles.length);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/scdl/src/test/resources/test.composite b/sandbox/sebastien/java/embed/itest/scdl/src/test/resources/test.composite
new file mode 100644
index 0000000000..c0bb2bbc40
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scdl/src/test/resources/test.composite
@@ -0,0 +1,51 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ xmlns:hns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="SCDLTest">
+
+ <component name="JavaComponent">
+ <implementation.java class="itest.FooImpl"/>
+ </component>
+
+ <component name="BPELComponent">
+ <implementation.bpel process="hns:HelloWorld"/>
+ </component>
+
+ <service name="JSONPService" promote="JavaComponent">
+ <tuscany:binding.jsonp/>
+ </service>
+
+ <service name="JMSService" promote="JavaComponent">
+ <binding.jms/>
+ </service>
+
+ <service name="RMIService" promote="JavaComponent">
+ <tuscany:binding.rmi/>
+ </service>
+
+<!-- TODO: leave out WS binding for now as it drags in entire runtime
+ <service name="WSService" promote="JavaComponent">
+ <binding.ws/>
+ </service>
+-->
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/scopes/pom.xml b/sandbox/sebastien/java/embed/itest/scopes/pom.xml
new file mode 100644
index 0000000000..4ba97f3062
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scopes/pom.xml
@@ -0,0 +1,54 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <name>Apache Tuscany SCA iTest Scopes</name>
+ <artifactId>itest-scopes</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java b/sandbox/sebastien/java/embed/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java
new file mode 100644
index 0000000000..208ac3ba44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.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.sca.itest.scopes;
+
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * Test Composite scope
+ */
+@Scope("COMPOSITE")
+public class CompositeScopeStateVerifierImpl implements StateVerifier {
+
+ // State data for this module (composite).
+ // In order to support thread-based state verification,
+ // the module state needs to be a ThreadLocal.
+ ThreadLocal<Integer> moduleState;
+
+ public CompositeScopeStateVerifierImpl() {
+ moduleState = new ThreadLocal<Integer>();
+ }
+
+ public void setState(int i) {
+ moduleState.set(i);
+ }
+
+ public boolean checkState(int i) {
+ return (moduleState.get() == i);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java b/sandbox/sebastien/java/embed/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java
new file mode 100644
index 0000000000..e6bf08ccf2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.scopes;
+
+public interface StateVerifier {
+ void setState(int i);
+
+ boolean checkState(int i);
+}
diff --git a/sandbox/sebastien/java/embed/itest/scopes/src/main/resources/scopes.composite b/sandbox/sebastien/java/embed/itest/scopes/src/main/resources/scopes.composite
new file mode 100644
index 0000000000..ed67bf5953
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scopes/src/main/resources/scopes.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://Scopes"
+ name="Scopes">
+
+ <!-- Components used to test scopes. -->
+ <component name="ModuleScopeComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.scopes.CompositeScopeStateVerifierImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java b/sandbox/sebastien/java/embed/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java
new file mode 100644
index 0000000000..594bdd5038
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.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.sca.test;
+
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.itest.scopes.StateVerifier;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ScopeTestCase {
+
+ /**
+ * Number of threads to drive each scope container.
+ */
+ private static final int NUM_THREADS = 4;
+
+ /**
+ * Number of iterations per thread.
+ */
+ private static final int ITERATIONS = 200;
+
+ private Node node;
+
+ @Before
+ public void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("scopes.composite");
+ node = NodeFactory.newInstance().createNode("scopes.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testScopes() throws InterruptedException {
+
+ Thread[] moduleScopeThreadTable = new Thread[NUM_THREADS];
+
+ for (int i = 0; i < NUM_THREADS; i++) {
+ moduleScopeThreadTable[i] = new ModuleScopeTestThread();
+ }
+ for (int j = 0; j < NUM_THREADS; j++) {
+ moduleScopeThreadTable[j].start();
+ }
+ for (int k = 0; k < NUM_THREADS; k++) {
+ moduleScopeThreadTable[k].join();
+ }
+ }
+
+ private class ModuleScopeTestThread extends Thread {
+
+ public void run() {
+ StateVerifier moduleScopeService = node.getService(StateVerifier.class, "ModuleScopeComponent");
+ for (int i = 1; i <= ITERATIONS; i++) {
+ moduleScopeService.setState(i);
+ if (!moduleScopeService.checkState(i)) {
+ fail("The module scope service lost its state on iteration " + i);
+ }
+ }
+ }
+ }
+
+
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/pom.xml b/sandbox/sebastien/java/embed/itest/service-reference/pom.xml
new file mode 100644
index 0000000000..ffd8d14fe6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/pom.xml
@@ -0,0 +1,66 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-service-reference</artifactId>
+ <name>Apache Tuscany SCA iTest ServiceReference</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java
new file mode 100644
index 0000000000..8b5cf4d29a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.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.sca.itest.serviceref;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface AComponent {
+ String foo();
+
+ String fooB();
+ String fooB1();
+
+ String fooC();
+ String fooC1();
+
+ String fooStringD();
+ String fooD();
+
+ String fooBC();
+
+ String invokeDReference();
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java
new file mode 100644
index 0000000000..3f68ac828a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.serviceref;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(AComponent.class)
+public class AComponentImpl implements AComponent {
+
+ @Context
+ protected ComponentContext componentContext;
+
+ @Reference(name = "bReference")
+ protected BComponent b;
+
+ @Reference
+ protected CComponent cReference;
+
+ @Reference
+ protected ServiceReference<CComponent> cServiceReference;
+
+ @Reference(required=false)
+ protected DComponent dReference;
+
+ protected DComponent dReference1;
+
+ @Reference(name = "dReference1")
+ public void setDReference(DComponent dReference) {
+ this.dReference1 = dReference;
+ }
+
+ public String foo() {
+ return "AComponent";
+ }
+
+ public String fooB() {
+ return b.foo();
+ }
+
+ public String fooB1() {
+ ServiceReference<BComponent> bRef = componentContext.cast(b);
+ return bRef.getService().foo();
+ }
+
+ public String fooC() {
+ return cReference.foo();
+ }
+
+ public String fooC1() {
+ return cServiceReference.getService().foo();
+ }
+
+ public String fooBC() {
+ ServiceReference<CComponent> cReference = componentContext.getServiceReference(CComponent.class, "cReference");
+ return b.fooC(cReference);
+ }
+
+ public String fooD() {
+ ServiceReference<AComponent> aReference = componentContext.createSelfReference(AComponent.class);
+ return dReference1.foo(aReference);
+ }
+
+ /**
+ * A test case to work out what needs to be done in a transformer to get the
+ * CallableReference across the wire. Left here for interest in case anyone
+ * is looking for how to get at the innards of CallableReferences
+ */
+ public String fooStringD() {
+ ServiceReference<AComponent> aReference = componentContext.createSelfReference(AComponent.class);
+ ByteArrayOutputStream bos = null;
+
+ try {
+ bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeObject(aReference);
+ } catch (Exception ex) {
+ System.out.println(ex.toString());
+ return null;
+ }
+
+ String aReferenceString = Base64Binary.encode(bos.toByteArray());
+ return dReference1.fooString(aReferenceString);
+ }
+
+ public String invokeDReference() {
+ return dReference.foo(null);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java
new file mode 100644
index 0000000000..18242cd594
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.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.sca.itest.serviceref;
+
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+public interface BComponent {
+
+ String foo();
+
+ String fooC(ServiceReference<CComponent> cComponent);
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java
new file mode 100644
index 0000000000..dd143df036
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.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 org.apache.tuscany.sca.itest.serviceref;
+
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(BComponent.class)
+public class BComponentImpl implements BComponent {
+
+ public BComponentImpl() {
+ }
+
+ public String foo() {
+ return "BComponent";
+ }
+
+ public String fooC(ServiceReference<CComponent> cReference) {
+ return "B" + cReference.getService().foo();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java
new file mode 100644
index 0000000000..fb436ae10c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java
@@ -0,0 +1,297 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.serviceref;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+
+/**
+ *
+ */
+
+public final class Base64Binary {
+ private static final char[] S_BASE64CHAR =
+ {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
+ 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
+ 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
+
+ private static final char S_BASE64PAD = '=';
+
+ private static final byte[] S_DECODETABLE = new byte[128];
+
+ static {
+ for (int i = 0; i < S_DECODETABLE.length; i++) {
+ S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
+ }
+ for (int i = 0; i < S_BASE64CHAR.length; i++) {
+ // 0 to 63
+ S_DECODETABLE[S_BASE64CHAR[i]] = (byte)i;
+ }
+ }
+
+ private Base64Binary() {
+ }
+
+ /**
+ *
+ */
+ public static byte[] decode(char[] data, int off, int len) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[len / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public static byte[] decode(String data) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[data.length() / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public static void decode(String data, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
+ }
+
+ private static int decode0(char[] ibuf, byte[] obuf, int index) {
+ int wp = index;
+ int outlen = 3;
+ if (ibuf[3] == S_BASE64PAD) {
+ outlen = 2;
+ }
+ if (ibuf[2] == S_BASE64PAD) {
+ outlen = 1;
+ }
+ int b0 = S_DECODETABLE[ibuf[0]];
+ int b1 = S_DECODETABLE[ibuf[1]];
+ int b2 = S_DECODETABLE[ibuf[2]];
+ int b3 = S_DECODETABLE[ibuf[3]];
+ switch (outlen) {
+ case 1:
+ obuf[wp] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ return 1;
+ case 2:
+ obuf[wp++] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp] = (byte)(b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ return 2;
+ case 3:
+ obuf[wp++] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp++] = (byte)(b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ obuf[wp] = (byte)(b2 << 6 & 0xc0 | b3 & 0x3f);
+ return 3;
+ default:
+ throw new IllegalArgumentException("The character sequence is not base64 encoded.");
+ }
+ }
+
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data) {
+ return encode(data, 0, data.length);
+ }
+
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data, int off, int len) {
+ if (len <= 0) {
+ return "";
+ }
+ char[] out = new char[len / 3 * 4 + 4];
+ int rindex = off;
+ int windex = 0;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 18];
+ out[windex++] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[windex++] = S_BASE64CHAR[i & 0x3f];
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[windex++] = S_BASE64CHAR[i >> 2];
+ out[windex++] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ out[windex++] = S_BASE64PAD;
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 10];
+ out[windex++] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ }
+ return new String(out, 0, windex);
+ }
+
+ /**
+ * Outputs base64 representation of the specified byte array to a byte stream.
+ */
+ public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ byte[] out = new byte[4];
+ int rindex = off;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
+ out[0] = (byte)S_BASE64CHAR[i >> 18];
+ out[1] = (byte)S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = (byte)S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = (byte)S_BASE64CHAR[i & 0x3f];
+ ostream.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = (byte)S_BASE64CHAR[i >> 2];
+ out[1] = (byte)S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = (byte)S_BASE64PAD;
+ out[3] = (byte)S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = (byte)S_BASE64CHAR[i >> 10];
+ out[1] = (byte)S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = (byte)S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = (byte)S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ }
+ }
+
+ /**
+ * Outputs base64 representation of the specified byte array to a character stream.
+ */
+ public static void encode(byte[] data, int off, int len, Writer writer) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ char[] out = new char[4];
+ int rindex = off;
+ int rest = len - off;
+ int output = 0;
+ while (rest >= 3) {
+ int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 18];
+ out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = S_BASE64CHAR[i & 0x3f];
+ writer.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ output += 4;
+ if (output % 76 == 0) {
+ writer.write("\n");
+ }
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = S_BASE64CHAR[i >> 2];
+ out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = S_BASE64PAD;
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 10];
+ out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java
new file mode 100644
index 0000000000..fc15b632d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.itest.serviceref;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CComponent {
+
+ String foo();
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java
new file mode 100644
index 0000000000..276093b69f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.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.itest.serviceref;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CComponent.class)
+public class CComponentImpl implements CComponent {
+
+ public String foo() {
+ return "CComponent";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java
new file mode 100644
index 0000000000..84e15b5eb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.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.itest.serviceref;
+
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface DComponent {
+
+ String foo(ServiceReference<AComponent> aReference);
+
+ String fooString(String aReferenceString);
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java
new file mode 100644
index 0000000000..db99472385
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.serviceref;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(DComponent.class)
+public class DComponentImpl implements DComponent {
+
+ @Context
+ protected RequestContext requestContext;
+
+ public String foo(ServiceReference<AComponent> aReference) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeObject(aReference);
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
+ Object obj = ois.readObject();
+ aReference = (ServiceReference<AComponent>) obj;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println("Invoking service: " + requestContext.getServiceName());
+ return "D" + aReference.getService().foo();
+ }
+
+ public String fooString(String aReferenceString) {
+ ServiceReference<AComponent> aReference = null;
+ try {
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64Binary.decode(aReferenceString)));
+ Object obj = ois.readObject();
+ aReference = (ServiceReference<AComponent>) obj;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println("Invoking service: " + requestContext.getServiceName());
+ return "D" + aReference.getService().foo();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/nodeA/CompositeA.composite b/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/nodeA/CompositeA.composite
new file mode 100644
index 0000000000..9a1fa0a7f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/nodeA/CompositeA.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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo"
+ targetNamespace="http://foo"
+ name="CompositeA"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.serviceref.AComponentImpl" />
+ <service name="AComponent">
+ <binding.ws uri="http://localhost:8084/AComponent"/>
+ </service>
+ <reference name="bReference">
+ <binding.ws uri="http://localhost:8085/BComponent" />
+ </reference>
+ <reference name="cReference">
+ <binding.ws uri="http://localhost:8085/CComponent" />
+ </reference>
+ <reference name="cServiceReference">
+ <binding.ws uri="http://localhost:8085/CComponent" />
+ </reference>
+ <reference name="dReference1">
+ <binding.ws uri="http://localhost:8085/DComponent" />
+ </reference>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/nodeB/CompositeB.composite b/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/nodeB/CompositeB.composite
new file mode 100644
index 0000000000..a72f5949ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/nodeB/CompositeB.composite
@@ -0,0 +1,46 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo"
+ targetNamespace="http://foo"
+ name="CompositeB"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.serviceref.BComponentImpl" />
+ <service name="BComponent">
+ <binding.ws uri="http://localhost:8085/BComponent"/>
+ </service>
+ </component>
+
+ <component name="CComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.serviceref.CComponentImpl" />
+ <service name="CComponent">
+ <binding.ws uri="http://localhost:8085/CComponent"/>
+ </service>
+ </component>
+
+ <component name="DComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.serviceref.DComponentImpl" />
+ <service name="DComponent">
+ <binding.ws uri="http://localhost:8085/DComponent"/>
+ </service>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite b/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite
new file mode 100644
index 0000000000..bc5ede7605
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite
@@ -0,0 +1,48 @@
+<?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
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo"
+ targetNamespace="http://foo"
+ name="InnerReferencesTest"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <service name="AComponent" promote="AComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.serviceref.AComponent" />
+ </service>
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.serviceref.AComponentImpl" />
+ <reference name="bReference" target="BComponent" />
+ <reference name="cReference" target="CComponent" />
+ <reference name="cServiceReference" target="CComponent" />
+ <reference name="dReference1" target="DComponent" />
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.serviceref.BComponentImpl" />
+ </component>
+
+ <component name="CComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.serviceref.CComponentImpl" />
+ </component>
+
+ <component name="DComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.serviceref.DComponentImpl" />
+ </component>
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java b/sandbox/sebastien/java/embed/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java
new file mode 100644
index 0000000000..843afe207c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.serviceref;
+
+import static junit.framework.Assert.assertEquals;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.itest.serviceref.AComponent;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Runs a distributed domain in a single VM by using and in memory
+ * implementation of the distributed domain
+ */
+public class CallableReferenceRemoteTestCase {
+
+ private static Node nodeA;
+ private static Node nodeB;
+
+ private static AComponent acomponent;
+
+ @BeforeClass
+ public static void init() throws Exception {
+
+ try {
+
+ System.out.println("Setting up nodes");
+
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+
+ nodeA = nodeFactory.createNode("nodeA/CompositeA.composite", new Contribution("contrib","target/classes"));
+ nodeA.start();
+
+ nodeB = nodeFactory.createNode("nodeB/CompositeB.composite", new Contribution("contrib","target/classes"));
+ nodeB.start();
+
+ acomponent = nodeA.getService(AComponent.class, "AComponent/AComponent");
+
+ } catch (Throwable ex) {
+ System.out.println(ex.toString());
+ // Print detailed cause information.
+ ex.printStackTrace();
+ StringBuffer sb = new StringBuffer();
+ Throwable cause = ex.getCause();
+ while ( cause != null ) {
+ sb.append( " " );
+ System.out.println( sb.toString() + "Cause: " + cause );
+ if (cause instanceof java.lang.reflect.InvocationTargetException)
+ System.out.println( sb.toString() + "Target Exception: " + ((java.lang.reflect.InvocationTargetException)cause).getTargetException() );
+ cause = cause.getCause();
+ }
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // stop the nodes and hence the domains they contain
+ nodeA.stop();
+ nodeB.stop();
+ }
+
+ //@Test
+ public void testKeepServerRunning1() throws Exception {
+ System.out.println("press enter to continue");
+ System.in.read();
+ }
+
+ @Test
+ public void testBReference() {
+ assertEquals("BComponent", acomponent.fooB());
+ }
+
+ @Test
+ public void testBCast() {
+ assertEquals("BComponent", acomponent.fooB1());
+ }
+
+ @Test
+ public void testCReference() {
+ assertEquals("CComponent", acomponent.fooC());
+ }
+
+ @Test
+ public void testCServiceReference() {
+ assertEquals("CComponent", acomponent.fooC1());
+ }
+
+ @Test
+ public void testDReferenceString() {
+ assertEquals("DAComponent", acomponent.fooStringD());
+ }
+
+ @Test
+ @Ignore
+ public void testDReference() {
+ assertEquals("DAComponent", acomponent.fooD());
+ }
+
+
+ @Test
+ @Ignore
+ public void testBCReference() {
+ assertEquals("BCComponent", acomponent.fooBC());
+ }
+
+ @Test
+ public void testRequiredFalseReference() {
+ try {
+ acomponent.invokeDReference();
+ } catch (Exception e) {
+ Assert.assertTrue(true);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java b/sandbox/sebastien/java/embed/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java
new file mode 100644
index 0000000000..1a454c939a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.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.itest.serviceref;
+
+import static junit.framework.Assert.assertEquals;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.itest.serviceref.AComponent;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ServiceReferenceTestCase {
+ private static Node node;
+ private static AComponent acomponent;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ node = NodeFactory.newInstance().createNode("ServiceReferenceTest.composite",
+ new Contribution("contrib","src/main/resources/servicereference"));
+ node.start();
+ acomponent = node.getService(AComponent.class, "AComponent");
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testBReference() {
+ assertEquals("BComponent", acomponent.fooB());
+ }
+
+ @Test
+ public void testBCast() {
+ assertEquals("BComponent", acomponent.fooB1());
+ }
+
+ @Test
+ public void testCReference() {
+ assertEquals("CComponent", acomponent.fooC());
+ }
+
+ @Test
+ public void testCServiceReference() {
+ assertEquals("CComponent", acomponent.fooC1());
+ }
+
+ @Test
+ public void testDReference() {
+ assertEquals("DAComponent", acomponent.fooD());
+ }
+
+ @Test
+ public void testBCReference() {
+ assertEquals("BCComponent", acomponent.fooBC());
+ }
+
+ @Test
+ public void testRequiredFalseReference() {
+ try {
+ acomponent.invokeDReference();
+ } catch (Exception e) {
+ Assert.assertTrue(true);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/pom.xml b/sandbox/sebastien/java/embed/itest/services/pom.xml
new file mode 100644
index 0000000000..7564ee1c9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-services</artifactId>
+ <name>Apache Tuscany SCA iTest Services</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java
new file mode 100644
index 0000000000..26e58dc530
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface AComponent {
+ String foo();
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java
new file mode 100644
index 0000000000..627ff4976f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.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 org.apache.tuscany.sca.itest.services;
+
+public class AComponentImpl implements AComponent {
+
+ public String foo() {
+ return "AComponent";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java
new file mode 100644
index 0000000000..d04bd1b985
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.services;
+
+public interface BComponent {
+
+ String foo();
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java
new file mode 100644
index 0000000000..01df89a8fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.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.sca.itest.services;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service(BComponent.class)
+public class BComponentImpl implements BComponent {
+
+ public String foo() {
+ return "BComponent";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java
new file mode 100644
index 0000000000..07397e4502
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CComponent {
+ String foo();
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java
new file mode 100644
index 0000000000..8713e5ab22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.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 org.apache.tuscany.sca.itest.services;
+
+public class CComponentImpl implements CComponent {
+
+ public String foo() {
+ return "CComponent";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java
new file mode 100644
index 0000000000..842a85e000
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.services;
+
+public interface D1Component {
+ String foo1();
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java
new file mode 100644
index 0000000000..8a3923b351
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.services;
+
+public interface DComponent {
+ String foo();
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java
new file mode 100644
index 0000000000..e52692fbf4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest.services;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service({DComponent.class, D1Component.class})
+public class DComponentImpl implements DComponent, D1Component {
+
+ public String foo() {
+ return "DComponent";
+ }
+
+ public String foo1() {
+ return "DComponent";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/services/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a687b3481a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foo="http://foo">
+ <deployable composite="foo:InnerServicesTest" />
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/services/src/main/resources/ServicesTest.composite b/sandbox/sebastien/java/embed/itest/services/src/main/resources/ServicesTest.composite
new file mode 100644
index 0000000000..49fdf02f4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/main/resources/ServicesTest.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="InnerServicesTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <component name="AComponent1">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.AComponentImpl" />
+ </component>
+
+ <component name="AComponent2">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.AComponentImpl" />
+ <service name="AComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.services.AComponent" />
+ </service>
+ </component>
+
+ <component name="BComponent1">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.BComponentImpl" />
+ </component>
+
+ <component name="BComponent2">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.BComponentImpl" />
+ <service name="BComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.services.BComponent" />
+ </service>
+ </component>
+
+ <component name="CComponent1">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.CComponentImpl" />
+ </component>
+
+ <component name="CComponent2">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.CComponentImpl" />
+ <service name="CComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.services.CComponent" />
+ </service>
+ </component>
+
+ <component name="DComponent1">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.DComponentImpl" />
+ </component>
+
+ <component name="DComponent2">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.DComponentImpl" />
+ <service name="DComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.services.DComponent" />
+ </service>
+ <service name="D1Component">
+ <interface.java interface="org.apache.tuscany.sca.itest.services.D1Component" />
+ </service>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java b/sandbox/sebastien/java/embed/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java
new file mode 100644
index 0000000000..da779b2c54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest.services;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class ServicesTestCase {
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("ServicesTest.composite");
+ node = NodeFactory.newInstance().createNode("ServicesTest.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testAService() {
+ AComponent a1 = node.getService(AComponent.class, "AComponent1");
+ assertEquals("AComponent", a1.foo());
+
+ AComponent a2 = node.getService(AComponent.class, "AComponent2/AComponent");
+ assertEquals("AComponent", a2.foo());
+ }
+
+ @Test
+ public void testBService() {
+ BComponent a1 = node.getService(BComponent.class, "BComponent1");
+ assertEquals("BComponent", a1.foo());
+
+ BComponent a2 = node.getService(BComponent.class, "BComponent2/BComponent");
+ assertEquals("BComponent", a2.foo());
+ }
+
+ @Test
+ public void testCService() {
+ CComponent a1 = node.getService(CComponent.class, "CComponent1");
+ assertEquals("CComponent", a1.foo());
+
+ CComponent a2 = node.getService(CComponent.class, "CComponent2/CComponent");
+ assertEquals("CComponent", a2.foo());
+ }
+
+ @Test
+ public void testDService() {
+ DComponent a1 = node.getService(DComponent.class, "DComponent1/DComponent");
+ assertEquals("DComponent", a1.foo());
+
+ D1Component a2 = node.getService(D1Component.class, "DComponent1/D1Component");
+ assertEquals("DComponent", a2.foo1());
+
+ try {
+ node.getService(DComponent.class, "DComponent1");
+ Assert.fail("The service name is required");
+ } catch (ServiceRuntimeException e) {
+ Assert.assertTrue("The service name is required", true);
+ }
+
+ DComponent a3 = node.getService(DComponent.class, "DComponent2/DComponent");
+ assertEquals("DComponent", a3.foo());
+
+ D1Component a4 = node.getService(D1Component.class, "DComponent2/D1Component");
+ assertEquals("DComponent", a4.foo1());
+
+ }
+
+ public static void main(String[] args) throws Exception {
+ ServicesTestCase.init();
+ ServicesTestCase tester = new ServicesTestCase();
+ tester.testAService();
+ tester.testBService();
+ tester.testCService();
+ tester.testDService();
+ ServicesTestCase.destroy();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/wires/pom.xml b/sandbox/sebastien/java/embed/itest/wires/pom.xml
new file mode 100644
index 0000000000..73868c649e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/wires/pom.xml
@@ -0,0 +1,53 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-wires</artifactId>
+ <name>Apache Tuscany SCA iTest Wires Basic</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java b/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java
new file mode 100644
index 0000000000..f5a4337254
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the client interface for the wires tests
+ */
+@Remotable
+public interface WireClient {
+
+ /**
+ * This tests the wires.
+ */
+ void runTests();
+}
diff --git a/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java b/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java
new file mode 100644
index 0000000000..82f0e26d58
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.itest;
+
+import org.junit.Assert;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This is the client implementation for the wires tests
+ */
+@Service(WireClient.class)
+public class WireClientImpl implements WireClient {
+ /**
+ * This is our injected reference to the WireService
+ */
+ @Reference
+ protected WireService aWireService;
+
+ /**
+ * This tests the wire reference
+ */
+ public void runTests() {
+ // Make sure the wire has injected a reference
+ Assert.assertNotNull(aWireService);
+
+ // Test the injected reference
+ String msg = aWireService.sayHello("MCC");
+
+ // Validate the response
+ Assert.assertNotNull(msg);
+ Assert.assertEquals("Hello MCC", msg);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java b/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java
new file mode 100644
index 0000000000..67df1e3a52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.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 org.apache.tuscany.sca.itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Sample Wire Service
+ */
+@Remotable
+public interface WireService {
+ /**
+ * Returns "Hello " + aName
+ *
+ * @param aName The name to say hello
+ * @return "Hello " + aName
+ */
+ String sayHello(String aName);
+}
diff --git a/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java b/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java
new file mode 100644
index 0000000000..f0308252ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.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.sca.itest;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Sample WireService Implementation
+ */
+@Service(WireService.class)
+public class WireServiceImpl implements WireService {
+
+ /**
+ * Returns "Hello " + aName
+ *
+ * @param aName The name to say hello
+ * @return "Hello " + aName
+ */
+ public String sayHello(String aName) {
+ return "Hello " + aName;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/wires/src/main/resources/WireTest.composite b/sandbox/sebastien/java/embed/itest/wires/src/main/resources/WireTest.composite
new file mode 100644
index 0000000000..e697726a73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/wires/src/main/resources/WireTest.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://wires" name="WireTest">
+
+ <component name="WireClient">
+ <implementation.java class="org.apache.tuscany.sca.itest.WireClientImpl"/>
+<!-- We are not using a reference - we are using a wire - see below -->
+<!-- The equivalent reference for the wire would be as follows -->
+<!-- <reference name="aWireService" target="WireService"/>-->
+ </component>
+
+ <component name="AnotherWireClient">
+ <implementation.java class="org.apache.tuscany.sca.itest.WireClientImpl"/>
+ </component>
+
+ <component name="WireServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.WireServiceImpl"/>
+ </component>
+
+ <wire source="WireClient/aWireService" target="WireServiceComponent"/>
+ <wire source="AnotherWireClient/aWireService" target="WireServiceComponent/WireService"/>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java b/sandbox/sebastien/java/embed/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java
new file mode 100644
index 0000000000..2a0095cabc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.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.itest;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This test case will attempt to use a wire
+ */
+public class WireTestCase {
+
+ /**
+ * The Node we are using
+ */
+ private Node node;
+
+ /**
+ * The client the tests should use
+ */
+ private WireClient aWireClient;
+
+ /**
+ * Run the wire tests
+ */
+ @Test
+ public void testWire() {
+ aWireClient.runTests();
+ }
+
+ /**
+ * Load the Wire composite and look up the client.
+ */
+
+ @Before
+ public void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("WireTest.composite");
+ node = NodeFactory.newInstance().createNode("WireTest.composite", new Contribution("c1", location));
+ node.start();
+ aWireClient = node.getService(WireClient.class, "WireClient");
+ Assert.assertNotNull(aWireClient);
+
+ aWireClient = node.getService(WireClient.class, "AnotherWireClient");
+ Assert.assertNotNull(aWireClient);
+ }
+
+ /**
+ * Shutdown the SCA node
+ */
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/README b/sandbox/sebastien/java/embed/itest/ws-jaxws/README
new file mode 100644
index 0000000000..cf635e78d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/README
@@ -0,0 +1,83 @@
+
+Scenarios
+=========
+
+General Patterns
+----------------
+
+For simple synchronous tests:
+
+Jaxws client -> (b.ws service) SCA Component (b.ws reference) -> Jaxws Service
+
+For callback or asynchronous tests
+
+JUnit client -> SCA Component (b.ws reference) -> (b.ws service) SCA component
+
+Java First
+----------
+scratch java component impl
+interface jaave (simple + JAXB + SDO )
+?wsdl - gens wsdl
+
+Java First with JAX-WS annotations
+----------------------------------
+WSDL -> wsimport -> Java component impl
+interface java
+?wsdl - re-gens wsdl
+
+WSDL first
+----------
+Java component impl -> wsgen -> wsdl
+interface wsdl
+?wsld - provided wsdl
+
+Policy
+------
+ws-policy (aac)
+
+Java First
+ WSpolicy from Policy set in definitions.xml
+ ?wsdl - gens wsdl + policy
+WSDL first
+ WSpolicy from WSDL
+ ?wsld - uses wsdl + policy
+ Policy signing
+
+alternative bindings
+--------------------
+SOAP/HTTP
+SOAP/HTTPS
+SOAP/JMS
+ How to retrieve WSDL for non-http bindings (a SHOULD in the spec)
+
+asynchInvocation Intent
+-----------------------
+ Service
+ Client
+
+noListener Intent
+-----------------
+ ws-makeconnetion?
+
+
+SOAP1.1 intent
+--------------
+
+
+SOAP1.2 intent
+--------------
+
+MTOM intent
+--------------
+
+callback
+--------
+new OASIS protocol
+WSCallback ws policy
+
+JAXWS Asynch APIs
+-----------------
+
+Streaming
+---------
+Do we need to support?
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/pom.xml b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/pom.xml
new file mode 100644
index 0000000000..afdfac7a95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-jaxws-contribution-java-first</artifactId>
+ <name>Apache Tuscany SCA iTest WS JAXWS Contribution Java First </name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.jaxws.HelloWorldImpl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.jaxws</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/Bar.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/Bar.java
new file mode 100644
index 0000000000..e712ec8b53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/Bar.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws;
+
+import java.io.Serializable;
+
+public class Bar implements Serializable {
+ private static final long serialVersionUID = 1249963611910502668L;
+
+ private String s;
+ private int x;
+ private Integer y;
+
+ private Boolean b;
+
+ public Boolean getB() {
+ return b;
+ }
+ public void setB(Boolean b) {
+ this.b = b;
+ }
+ public String getS() {
+ return s;
+ }
+ public void setS(String s) {
+ this.s = s;
+ }
+ public int getX() {
+ return x;
+ }
+ public void setX(int x) {
+ this.x = x;
+ }
+ public Integer getY() {
+ return y;
+ }
+ public void setY(Integer y) {
+ this.y = y;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/Foo.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/Foo.java
new file mode 100644
index 0000000000..d09b2af230
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/Foo.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 org.apache.tuscany.sca.binding.ws.jaxws;
+
+import java.io.Serializable;
+
+public class Foo implements Serializable {
+ private static final long serialVersionUID = 4879476066850018458L;
+
+ private Bar[] bars;
+
+ public Bar[] getBars() {
+ return bars;
+ }
+
+ public void setBars(Bar[] bars) {
+ this.bars = bars;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.java
new file mode 100644
index 0000000000..652f7b53c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.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.sca.binding.ws.jaxws;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.java
new file mode 100644
index 0000000000..85e55888c6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.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.sca.binding.ws.jaxws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.jaxws.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorldImpl implements HelloWorld {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetings: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ Foo response = null;//helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("At client: " + response.getBars()[0].getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..51f6dd4d51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e71dd465f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..67236a5f98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="http://localhost:8086/External/HelloWorld"/>
+ </port>
+ </service>
+</definitions>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..0188dc0d41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-java-first/src/main/resources/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.jaxws.HelloWorldImpl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/pom.xml b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/pom.xml
new file mode 100644
index 0000000000..0bab07d102
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/pom.xml
@@ -0,0 +1,125 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-jaxws-contribution-wsdl-first</artifactId>
+ <name>Apache Tuscany SCA iTest WS JAXWS Contribution WSDL First</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-sca.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport2</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport2StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/impl/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/impl/HelloWorldImpl.java
new file mode 100644
index 0000000000..7c63fd5ba9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/impl/HelloWorldImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.jaxws.impl;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.HelloWorld;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldImpl implements HelloWorld {
+
+ @Reference
+ public org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorld helloWorldExternal;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetings: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ return response;
+ }
+/*
+ public Foo getGreetingsComplex(Foo foo){
+ Foo response = null;//helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("At client: " + response.getBars()[0].getS());
+ return response;
+ }
+*/
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e71dd465f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld-external.wsdl b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld-external.wsdl
new file mode 100644
index 0000000000..78d8077bcd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld-external.wsdl
@@ -0,0 +1,84 @@
+<?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/external"
+ xmlns:tns="http://helloworld/external"
+ 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/external" 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:8086/External/HelloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld-sca.wsdl b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld-sca.wsdl
new file mode 100644
index 0000000000..0e6a10cc62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld-sca.wsdl
@@ -0,0 +1,84 @@
+<?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:8085/HelloWorldService/HelloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..0cd2b4419d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/contribution-wsdl-first/src/main/resources/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.jaxws.impl.HelloWorldImpl"/>
+ <service name="HelloWorld">
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws wsdlElement="http://helloworld/external#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/pom.xml b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/pom.xml
new file mode 100644
index 0000000000..b613a4ad3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/pom.xml
@@ -0,0 +1,122 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-jaxws-external-client</artifactId>
+ <name>Apache Tuscany SCA iTest WS JAXWS External Client</name>
+
+ <dependencies>
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-jaxws-ri</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.sca</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>HelloWorldImplService.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java
new file mode 100644
index 0000000000..da40a7f442
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.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.ws.jaxws.external.client;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Exception_Exception;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.HelloWorldImpl;
+
+public class HelloWorldClientLauncher {
+
+ public HelloWorldImpl wsProxy;
+
+ public HelloWorldClientLauncher(){
+ }
+
+ public void createClient() throws Exception{
+ System.out.println(">>> Starting external JAXWS client ");
+
+ // default JVM JAXWS support
+ QName serviceName = new QName("http://jaxws.ws.binding.sca.tuscany.apache.org/", "HelloWorldImplService");
+ QName portName = new QName("http://jaxws.ws.binding.sca.tuscany.apache.org/", "HelloWorldImplPort");
+ //URL wsdlLocation = new File("../external-client/target/classes/helloworld-sca.wsdl").toURL();
+ URL wsdlLocation = new File("../external-client/target/classes/HelloWorldImplService.wsdl").toURL();
+ javax.xml.ws.Service webService = Service.create(wsdlLocation, serviceName);
+ wsProxy = (HelloWorldImpl) webService.getPort(portName, HelloWorldImpl.class);
+ }
+
+ public void destroyClient(){
+ System.out.println(">>> Stopping external JAXWS client: ");
+ // TODO
+ }
+
+ public String getGreetings(String name){
+ System.out.println("Entering External Client HelloWorld.getGreetings: " + name);
+ String response = wsProxy.getGreetings(name);
+ System.out.println("Leaving External Client HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String name) throws Exception_Exception {
+ return wsProxy.getGreetingsException(name);
+ }
+
+ public static void main(String[] args) throws Exception {
+ HelloWorldClientLauncher launcher = new HelloWorldClientLauncher();
+ launcher.createClient();
+ launcher.getGreetings("Fred");
+ launcher.destroyClient();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl
new file mode 100644
index 0000000000..11ed0a3353
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://jaxws.ws.binding.sca.tuscany.apache.org/" name="HelloWorldImplService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://jaxws.ws.binding.sca.tuscany.apache.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://jaxws.ws.binding.sca.tuscany.apache.org/" schemaLocation="HelloWorldImplService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsException">
+ <part name="parameters" element="tns:getGreetingsException"/>
+ </message>
+ <message name="getGreetingsExceptionResponse">
+ <part name="parameters" element="tns:getGreetingsExceptionResponse"/>
+ </message>
+ <message name="Exception">
+ <part name="fault" element="tns:Exception"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldImpl">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsException">
+ <input message="tns:getGreetingsException"/>
+ <output message="tns:getGreetingsExceptionResponse"/>
+ <fault message="tns:Exception" name="Exception"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldImplPortBinding" type="tns:HelloWorldImpl">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsException">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="Exception">
+ <soap:fault name="Exception" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldImplService">
+ <port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
+ <soap:address location="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </port>
+ </service>
+</definitions>
+
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd
new file mode 100644
index 0000000000..3c347570a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://jaxws.ws.binding.sca.tuscany.apache.org/" xmlns:tns="http://jaxws.ws.binding.sca.tuscany.apache.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="Exception" type="tns:Exception"/>
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsException" type="tns:getGreetingsException"/>
+
+ <xs:element name="getGreetingsExceptionResponse" type="tns:getGreetingsExceptionResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetingsException">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsExceptionResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Exception">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/pom.xml b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/pom.xml
new file mode 100644
index 0000000000..e64f40273f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/pom.xml
@@ -0,0 +1,104 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-jaxws-external-service</artifactId>
+ <name>Apache Tuscany SCA iTest WS JAXWS External Service</name>
+
+ <dependencies>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldService</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java
new file mode 100644
index 0000000000..796ef82792
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.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.binding.ws.jaxws.external.service;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+@WebService(name = "HelloWorldService", targetNamespace = "http://helloworld/external")
+public class HelloWorldService {
+
+ @WebMethod
+ @WebResult(name = "getGreetingsReturn", targetNamespace = "http://helloworld/external")
+ @RequestWrapper(localName = "getGreetings", targetNamespace = "http://helloworld/external", className = "org.apache.tuscany.sca.binding.ws.jaxws.external.service.GetGreetings")
+ @ResponseWrapper(localName = "getGreetingsResponse", targetNamespace = "http://helloworld/external", className = "org.apache.tuscany.sca.binding.ws.jaxws.external.service.GetGreetingsResponse")
+ public String getGreetings( @WebParam(name = "name", targetNamespace = "http://helloworld/external")
+ String name) {
+ System.out.println("Entering External Service HelloWorld.getGreetings: " + name);
+ String response = "Hello " + name;
+ System.out.println("Leaving External Service HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+/*
+ public Foo getGreetingsComplex(Foo foo){
+ Foo response = foo;
+ Bar b3 = new Bar();
+ b3.setS("simon");
+ b3.setX(4);
+ b3.setY(new Integer(5));
+ b3.setB(Boolean.TRUE);
+ response.getBars()[1] = b3;
+ System.out.println("At sevice: " + response.getBars()[0].getS());
+ return response;
+ }
+*/
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java
new file mode 100644
index 0000000000..ba7e033f63
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws.external.service;
+
+import javax.xml.ws.Endpoint;
+
+public class HelloWorldServiceLauncher {
+
+ public Endpoint endpoint;
+
+ public HelloWorldServiceLauncher(){
+
+ }
+
+ public void createService(){
+ System.out.println(">>> Starting external JAXWS service at http://localhost:8086/External/HelloWorld");
+
+ // default JVM JAXWS support.
+ endpoint= Endpoint.publish("http://localhost:8086/External/HelloWorld",
+ new HelloWorldService());
+ }
+
+ public void destoryService(){
+ System.out.println(">>> Stopping external JAXWS service at http://localhost:8086/External/HelloWorld");
+ endpoint.stop();
+ }
+
+ public static void main(String[] args) throws Exception {
+ HelloWorldServiceLauncher launcher = new HelloWorldServiceLauncher();
+ launcher.createService();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/pom.xml b/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/pom.xml
new file mode 100644
index 0000000000..b78095f01a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/pom.xml
@@ -0,0 +1,114 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-jaxws-launcher-ri</artifactId>
+ <name>Apache Tuscany SCA iTest WS JAXWS Launcher RI</name>
+
+ <dependencies>
+<!-- ws feature dependencies copied below so that we can use the
+ binding-ws-runtime-jaxws implementation while it's under development
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+-->
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-jaxws-ri</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ -->
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Test resources -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-ws-jaxws-external-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-ws-jaxws-external-service</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java
new file mode 100644
index 0000000000..3c14218118
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.jaxws.launcher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JavaFirstTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-java-first/target/classes"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ public void testGetGreetingsComplex() throws Exception {
+
+/*
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.setBars(new Bar[] { b1, b2} );
+
+ Foo f2 = helloWorld.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars()[0].getS());
+ assertEquals(1, f2.getBars()[0].getX());
+ assertEquals(2, f2.getBars()[0].getY().intValue());
+ assertTrue(f2.getBars()[0].getB().booleanValue());
+ assertEquals("simon", f2.getBars()[1].getS());
+ assertEquals(4, f2.getBars()[1].getX());
+ assertEquals(5, f2.getBars()[1].getY().intValue());
+ assertTrue(f2.getBars()[1].getB().booleanValue());
+*/
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/WSDLFirstTestCaseOFF.java b/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/WSDLFirstTestCaseOFF.java
new file mode 100644
index 0000000000..a69fe483bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/WSDLFirstTestCaseOFF.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws.launcher;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class WSDLFirstTestCaseOFF extends TestCase {
+
+ private Node node;
+
+ @Override
+ protected void setUp() throws Exception {
+ // Start the external service
+ HelloWorldServiceLauncher.main(null);
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("common", "../common-contribution/target/classes"),
+ new Contribution("wsdl-first", "../wsdl-first-contribution/target/classes"));
+ node.start();
+ }
+
+ public void testCalculator() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+/*
+ public void testWait1() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+
+ public void testCalculator1() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator2() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator3() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator4() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator5() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator6() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator7() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator8() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator9() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator10() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator11() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator12() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator13() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator14() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator15() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator16() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator17() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator18() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator19() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+
+ public void testCalculator20() throws Exception {
+ HelloWorldClientLauncher.main(null);
+ }
+*/
+
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node = null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws-jaxws/pom.xml b/sandbox/sebastien/java/embed/itest/ws-jaxws/pom.xml
new file mode 100644
index 0000000000..f8c19205e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws-jaxws/pom.xml
@@ -0,0 +1,41 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-ws-jaxws</artifactId>
+ <name>Apache Tuscany SCA iTest WS JAXWS</name>
+
+ <modules>
+ <module>contribution-java-first</module>
+ <module>contribution-wsdl-first</module>
+ <module>external-client</module>
+ <module>external-service</module>
+ <module>launcher-ri</module>
+ <!--module>launcher-axis2</module-->
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/README b/sandbox/sebastien/java/embed/itest/ws/README
new file mode 100644
index 0000000000..0efac242c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/README
@@ -0,0 +1,135 @@
+
+Features/Tests
+==============
+
+General Patterns
+----------------
+For simple synchronous tests:
+
+Jaxws client -> (b.ws service) SCA Component (b.ws reference) -> Jaxws Service
+ /\ /\ |
+ | use | use | gen
+ | | \/
+Java Interface<------------------Java Interface<---------gen----------WSDL
+
+
+For message format the external service don't get involved in the varying message formats,
+They are still doing doc/lit/wrapped:
+
+TODO - we could extend testing to include JAXWS edpoints thatunderstand the different formats
+
+JUnit client -> SCA Component (b.ws reference) -> (b.ws service) SCA component -> Jaxws Service
+ /\ /\ /\ /\ |
+ | | config | config | |
+ | use | | | use | gen
+ | -----------WSDL------- | |
+ | | \/
+Java Interface<-------------------------------------------------Java Interface<----gen---WSDL
+
+For SCA callback or asynchronous tests the external services don't get involved in the
+callback or aysnc request:
+
+JUnit client -> SCA Component (b.ws reference) -> (b.ws service) SCA component -> Jaxws Service
+
+
+Java First
+----------
+implemenation.java
+interface.java
+ simple
+ JAXB
+ SDO - TODO
+?wsdl - gens wsdl
+
+Java First with JAX-WS annotations
+----------------------------------
+WSDL -> wsimport -> implemenation.java
+interface.java
+?wsdl - re-gens wsdl
+
+WSDL first
+----------
+implemenation.java -> wsgen -> wsdl
+interface.wsdl
+?wsld - provided wsdl
+
+Callback
+--------
+Various combinations of specified callback and default configuration
+WSCallback ws policy - TODO
+
+WSDL Styles
+-----------
+
+rpc-lit - supported
+ WSDL configuration where
+ message parts use types - <part name="s" type="xsd:string"/>
+ binding style set to rpc - <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ body uses literal - <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsNamespace" />
+ Note the use of a namespace on the body element to set the namespace of the wrapper child of the body element
+doc-lit(or bare) - supported (however see note below)
+ WS-I BP1.1 4.7.6 states that an operation signature is a
+ "fully qualified name of the child element of SOAP body of the SOAP input message"
+ to make this true for doc-lit encoding you have to design the WSDL to wrap the parameters
+ in an appropriate type. Hence doc-literal-wrapped is supported which encompasses this wrapping style.
+ For bare style interfaces you have to mark the Java service interface as follows
+ SOAP binding is set to - @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+ WSDL configuration where
+ message parts use elements - <part name="parameters" element="tns:getGreetings"/>
+ the elements are directly implemented by the operation parameter type
+ binding style set to document - <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ body uses literal - <soap:body use="literal"/>
+doc-lit-wrapped - supported
+ WSDL configuration where
+ message parts use elements - <part name="parameters" element="tns:getGreetings"/>
+ the elements are implemented by wrapper types following the name of the operation
+ binding style set to document - <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ body uses literal - <soap:body use="literal"/>
+rpc-encoded - not supported
+ not WS-I compliant
+doc-encoded - not supported
+ not WS-I compliant
+
+================================== TODO below =========================
+
+Policy
+------
+ws-policy (aac)
+
+Java First
+ WSpolicy from Policy set in definitions.xml
+ ?wsdl - gens wsdl + policy
+WSDL first
+ WSpolicy from WSDL
+ ?wsld - uses wsdl + policy
+ Policy signing
+
+alternative bindings
+--------------------
+SOAP/HTTP
+SOAP/HTTPS
+SOAP/JMS
+ How to retrieve WSDL for non-http bindings (a SHOULD in the spec)
+
+asynchInvocation Intent
+-----------------------
+ Service
+ Client
+
+noListener Intent
+-----------------
+ ws-makeconnetion?
+
+
+SOAP1.1 intent
+--------------
+
+SOAP1.2 intent
+--------------
+
+MTOM intent
+--------------
+
+Streaming
+---------
+Do we need to support?
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/pom.xml b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/pom.xml
new file mode 100644
index 0000000000..211cf97ceb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/pom.xml
@@ -0,0 +1,47 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-authentication-basic</artifactId>
+ <name>Apache Tuscany SCA iTest WS with Authentication Basic</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..98eb6e361b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..2c6c4fc92c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/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 org.apache.tuscany.sca.binding.ws.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorldWS;
+
+ public String getGreetings(String s) {
+ String response = helloWorldWS.getGreetings(s);
+ System.out.println("At client: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..885844260a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2.helloworld;
+
+import javax.security.auth.Subject;
+
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.annotation.Context;
+
+public class HelloWorldService implements HelloWorld {
+
+ @Context
+ protected RequestContext requestContext;
+
+ public String getGreetings(String name) {
+ Subject subject = requestContext.getSecuritySubject();
+ String response = "Hello " + name + " ";
+
+ if (subject == null){
+ response += "null subject";
+ } else {
+ response += subject.getPrincipals().iterator().next().getName();
+ }
+
+ System.out.println("At service: " + response);
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e71dd465f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..04fe620be4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/binding/ws/axis2/helloworld/definitions.xml \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/definitions.xml b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/definitions.xml
new file mode 100644
index 0000000000..d4e651b271
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/definitions.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2" >
+
+
+ <sca:policySet name="BasicAuthenticationPolicySet"
+ attachTo="//sca:binding.ws"
+ provides="clientAuthentication.transport"
+ appliesTo="//sca:binding.ws">
+ <tuscany:basicAuthentication>
+ <tuscany:userName>myname</tuscany:userName>
+ <tuscany:password>mypassword</tuscany:password>
+ </tuscany:basicAuthentication>
+ </sca:policySet>
+
+ <sca:policySet name="ImplementationIdentityPolicySet"
+ attachTo="//sca:implementation.java"
+ provides="tuscany:identity"
+ appliesTo="//sca:implementation.java">
+ <tuscany:securityIdentity>
+ <tuscany:useCallerIdentity/>
+ </tuscany:securityIdentity>
+ </sca:policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite
new file mode 100644
index 0000000000..166565baa0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS" requires="authentication">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort1)"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService" requires="authentication">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/>
+ <service name="HelloWorld">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)">
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/services/HelloWorldWebService1</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..a352696b8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl
@@ -0,0 +1,90 @@
+<?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="HelloWorldSoapPort1">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService1"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloworldTestCase.java b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloworldTestCase.java
new file mode 100644
index 0000000000..04db2e1834
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/authentication-basic/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloworldTestCase.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.binding.ws.axis2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Ignore;
+
+@Ignore("TUSCANY-3631")
+public class HelloworldTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello fred myname", helloWorld.getGreetings("fred"));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode(new Contribution("test", "target/classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/pom.xml
new file mode 100644
index 0000000000..ff868b9bd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-callback-forwardspec</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution Callback Forward Bindings Specified</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.HelloWorldImpl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..6bc67db5fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java
new file mode 100644
index 0000000000..ba117c8cfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.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.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldCallback {
+
+ String getGreetingsCallback(String s);
+ Foo getGreetingsComplexCallback(Foo foo);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java
new file mode 100644
index 0000000000..3521fa5624
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallback.class)
+public interface HelloWorldCallbackService {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java
new file mode 100644
index 0000000000..057b884bc9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.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.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(HelloWorldCallbackService.class)
+public class HelloWorldCallbackServiceImpl implements HelloWorldCallbackService {
+
+ @Callback
+ protected HelloWorldCallback helloWorldCallback;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetings: " + s);
+ String response = helloWorldCallback.getGreetingsCallback(s);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetingsException: " + s);
+ String response = helloWorldCallback.getGreetingsCallback(s);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldCallback.getGreetingsComplexCallback(foo);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
new file mode 100644
index 0000000000..1ff58a29b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorldImpl implements HelloWorld, HelloWorldCallback {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ @Reference
+ public HelloWorldCallbackService helloWorldCallbackService;
+
+ // HelloWorld operations
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetings: " + s);
+ String response = helloWorldCallbackService.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s);
+ String response = helloWorldCallbackService.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldCallbackService.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+ // HelloWorldCallback operations
+
+ public String getGreetingsCallback(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetingsCallback: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCallback: " + response);
+ return response;
+ }
+
+ public String getGreetingsExceptionCallback(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsExceptionCallback: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCallback: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplexCallback(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplexCallback: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplexCallback: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..acdfcaaaa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..837bcb059e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..2be7fd7315
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-forwardspec/src/main/resources/helloworld.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldImpl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ <reference name="helloWorldCallbackService">
+ <binding.ws uri="http://localhost:8085/HelloWorldCallbackService"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldCallbackService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldCallbackServiceImpl"/>
+ <service name="HelloWorldCallbackService">
+ <binding.ws uri="http://localhost:8085/HelloWorldCallbackService"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/pom.xml
new file mode 100644
index 0000000000..68273c819b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-callback-fullspec</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution Callback Fully Specified</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.HelloWorldImpl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..6bc67db5fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java
new file mode 100644
index 0000000000..ba117c8cfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.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.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldCallback {
+
+ String getGreetingsCallback(String s);
+ Foo getGreetingsComplexCallback(Foo foo);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java
new file mode 100644
index 0000000000..3521fa5624
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallback.class)
+public interface HelloWorldCallbackService {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java
new file mode 100644
index 0000000000..057b884bc9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.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.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(HelloWorldCallbackService.class)
+public class HelloWorldCallbackServiceImpl implements HelloWorldCallbackService {
+
+ @Callback
+ protected HelloWorldCallback helloWorldCallback;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetings: " + s);
+ String response = helloWorldCallback.getGreetingsCallback(s);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetingsException: " + s);
+ String response = helloWorldCallback.getGreetingsCallback(s);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldCallback.getGreetingsComplexCallback(foo);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
new file mode 100644
index 0000000000..1ff58a29b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorldImpl implements HelloWorld, HelloWorldCallback {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ @Reference
+ public HelloWorldCallbackService helloWorldCallbackService;
+
+ // HelloWorld operations
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetings: " + s);
+ String response = helloWorldCallbackService.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s);
+ String response = helloWorldCallbackService.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldCallbackService.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+ // HelloWorldCallback operations
+
+ public String getGreetingsCallback(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetingsCallback: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCallback: " + response);
+ return response;
+ }
+
+ public String getGreetingsExceptionCallback(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsExceptionCallback: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCallback: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplexCallback(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplexCallback: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplexCallback: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..acdfcaaaa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..837bcb059e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..31414beb47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-fullspec/src/main/resources/helloworld.composite
@@ -0,0 +1,51 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldImpl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ <reference name="helloWorldCallbackService">
+ <binding.ws uri="http://localhost:8084/HelloWorldCallbackService"/>
+ <callback>
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorldCallback"/>
+ </callback>
+ </reference>
+ </component>
+
+ <component name="HelloWorldCallbackService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldCallbackServiceImpl"/>
+ <service name="HelloWorldCallbackService">
+ <binding.ws uri="http://localhost:8084/HelloWorldCallbackService"/>
+ <callback>
+ <binding.ws/>
+ </callback>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/pom.xml
new file mode 100644
index 0000000000..dcada2d5ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-callback-promotion</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution Callback Promotion</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.HelloWorldImpl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..6bc67db5fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java
new file mode 100644
index 0000000000..ba117c8cfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.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.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldCallback {
+
+ String getGreetingsCallback(String s);
+ Foo getGreetingsComplexCallback(Foo foo);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java
new file mode 100644
index 0000000000..3521fa5624
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallback.class)
+public interface HelloWorldCallbackService {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java
new file mode 100644
index 0000000000..057b884bc9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.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.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(HelloWorldCallbackService.class)
+public class HelloWorldCallbackServiceImpl implements HelloWorldCallbackService {
+
+ @Callback
+ protected HelloWorldCallback helloWorldCallback;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetings: " + s);
+ String response = helloWorldCallback.getGreetingsCallback(s);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetingsException: " + s);
+ String response = helloWorldCallback.getGreetingsCallback(s);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldCallback.getGreetingsComplexCallback(foo);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
new file mode 100644
index 0000000000..1ff58a29b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorldImpl implements HelloWorld, HelloWorldCallback {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ @Reference
+ public HelloWorldCallbackService helloWorldCallbackService;
+
+ // HelloWorld operations
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetings: " + s);
+ String response = helloWorldCallbackService.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s);
+ String response = helloWorldCallbackService.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldCallbackService.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+ // HelloWorldCallback operations
+
+ public String getGreetingsCallback(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetingsCallback: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCallback: " + response);
+ return response;
+ }
+
+ public String getGreetingsExceptionCallback(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsExceptionCallback: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCallback: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplexCallback(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplexCallback: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplexCallback: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..acdfcaaaa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..837bcb059e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..0d66bb105f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ xmlns:tns="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.composite name="tns:HelloWorldService"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="HelloWorldCallbackService">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorldCallbackService"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldCallbackService">
+ <implementation.composite name="tns:HelloWorldCallbackService"/>
+ <service name="HelloWorldCallbackService">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorldCallbackService"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworldcallbackservice-bottom.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworldcallbackservice-bottom.composite
new file mode 100644
index 0000000000..e522c6c151
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworldcallbackservice-bottom.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorldCallbackService">
+
+ <service name="HelloWorldCallbackService" promote="HelloWorldCallbackService/HelloWorldCallbackService"/>
+
+ <component name="HelloWorldCallbackService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldCallbackServiceImpl"/>
+ <service name="HelloWorldCallbackService">
+ <!-- configured at the top level -->
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworldservice-bottom.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworldservice-bottom.composite
new file mode 100644
index 0000000000..aea84ad56e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback-promotion/src/main/resources/helloworldservice-bottom.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorldService">
+
+ <service name="HelloWorld" promote="HelloWorldService/HelloWorld"/>
+ <reference name="HelloWorldCallbackService" multiplicity="1..1" promote="HelloWorldService/helloWorldCallbackService"/>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldImpl"/>
+ <service name="HelloWorld">
+ <!-- configured at the top level -->
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ <reference name="helloWorldCallbackService">
+ <!-- configured at the top level -->
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/pom.xml
new file mode 100644
index 0000000000..efdd580b18
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-callback</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution Callback </name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.HelloWorldImpl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..6bc67db5fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.java
new file mode 100644
index 0000000000..ba117c8cfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallback.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.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldCallback {
+
+ String getGreetingsCallback(String s);
+ Foo getGreetingsComplexCallback(Foo foo);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java
new file mode 100644
index 0000000000..3521fa5624
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(HelloWorldCallback.class)
+public interface HelloWorldCallbackService {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.java
new file mode 100644
index 0000000000..057b884bc9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldCallbackServiceImpl.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.sca.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(HelloWorldCallbackService.class)
+public class HelloWorldCallbackServiceImpl implements HelloWorldCallbackService {
+
+ @Callback
+ protected HelloWorldCallback helloWorldCallback;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetings: " + s);
+ String response = helloWorldCallback.getGreetingsCallback(s);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetingsException: " + s);
+ String response = helloWorldCallback.getGreetingsCallback(s);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorldCallbackService.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldCallback.getGreetingsComplexCallback(foo);
+ System.out.println("Leaving SCA HelloWorldCallbackService.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
new file mode 100644
index 0000000000..1ff58a29b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorldImpl implements HelloWorld, HelloWorldCallback {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ @Reference
+ public HelloWorldCallbackService helloWorldCallbackService;
+
+ // HelloWorld operations
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetings: " + s);
+ String response = helloWorldCallbackService.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s);
+ String response = helloWorldCallbackService.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldCallbackService.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+ // HelloWorldCallback operations
+
+ public String getGreetingsCallback(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetingsCallback: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCallback: " + response);
+ return response;
+ }
+
+ public String getGreetingsExceptionCallback(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsExceptionCallback: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCallback: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplexCallback(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplexCallback: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplexCallback: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..acdfcaaaa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..837bcb059e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..cb257d22dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-callback/src/main/resources/helloworld.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldImpl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ <reference name="helloWorldCallbackService" target="HelloWorldCallbackService"/>
+ </component>
+
+ <component name="HelloWorldCallbackService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldCallbackServiceImpl"/>
+ <service name="HelloWorldCallbackService">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorldCallbackService"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/pom.xml
new file mode 100644
index 0000000000..c14b5cda66
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-doc-lit-wrapped</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution Doc Lit Wrapped </name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.HelloWorld1Impl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..6bc67db5fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java
new file mode 100644
index 0000000000..27471f87c6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.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.sca.binding.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorld1Impl implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorld2;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld1.getGreetings: " + s);
+ String response = helloWorld2.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld1.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld1.getGreetingsException: " + s);
+ String response = helloWorld2.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld1.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld1.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorld2.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld1.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java
new file mode 100644
index 0000000000..6f3b430d6d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorld2Impl implements HelloWorld {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld2.getGreetings: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld2.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld2.getGreetingsException: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld2.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld2.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld2.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit.wsdl
new file mode 100644
index 0000000000..f5a25b39f8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit.wsdl
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions targetNamespace="http://ws.binding.sca.tuscany.apache.org/doclit"
+ name="HelloWorldImplService"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/doclit"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ws.binding.sca.tuscany.apache.org/doclit"
+ schemaLocation="HelloWorldImplService_doclit1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsException">
+ <part name="parameters" element="tns:getGreetingsException"/>
+ </message>
+ <message name="getGreetingsExceptionResponse">
+ <part name="parameters" element="tns:getGreetingsExceptionResponse"/>
+ </message>
+ <message name="Exception">
+ <part name="fault" element="tns:Exception"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldImpl">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsException">
+ <input message="tns:getGreetingsException"/>
+ <output message="tns:getGreetingsExceptionResponse"/>
+ <fault message="tns:Exception" name="Exception"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldImplPortBinding" type="tns:HelloWorldImpl">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsException">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="Exception">
+ <soap:fault name="Exception" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldImplService">
+ <port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
+ <soap:address location="http://localhost:8085/HelloWorldService/HelloWorld-doclit"/>
+ </port>
+ </service>
+</definitions>
+
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit1.xsd
new file mode 100644
index 0000000000..545820a07d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit1.xsd
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://ws.binding.sca.tuscany.apache.org/doclit"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/doclit"
+ xmlns:tns2="http://helloworld/external"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:import namespace="http://helloworld/external" schemaLocation="./HelloWorldImplService-doclit2.xsd"/>
+
+ <xs:element name="Exception" type="tns:Exception"/>
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsException" type="tns:getGreetingsException"/>
+
+ <xs:element name="getGreetingsExceptionResponse" type="tns:getGreetingsExceptionResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetingsException">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsExceptionResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Exception">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns2:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns2:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit2.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit2.xsd
new file mode 100644
index 0000000000..d955cc2af4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldImplService-doclit2.xsd
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external"
+ xmlns:tns="http://helloworld/external"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..acdfcaaaa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..837bcb059e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..e00e130c32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit-wrapped/src/main/resources/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService1">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorld1Impl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="helloWorld2">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld-doclit" wsdlElement="http://ws.binding.sca.tuscany.apache.org/doclit#wsdl.binding(HelloWorldImplPortBinding)"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService2">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorld2Impl"/>
+ <service name="HelloWorld">
+ <binding.ws wsdlElement="http://ws.binding.sca.tuscany.apache.org/doclit#wsdl.port(HelloWorldImplService/HelloWorldImplPort)"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/pom.xml
new file mode 100644
index 0000000000..562fd47ab6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-doc-lit</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution Doc Lit(sometimes called Bare) </name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.HelloWorld1Impl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..9196530db7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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 org.apache.tuscany.sca.binding.ws;
+
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+/* TUSCANY-3621
+ Foo getGreetingsComplex(Foo foo);
+*/
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java
new file mode 100644
index 0000000000..c8bad91339
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorld1Impl implements HelloWorld {
+
+ @Reference
+ public HelloWorldBare helloWorld2;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld1.getGreetings: " + s);
+ String response = helloWorld2.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld1.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld1.getGreetingsException: " + s);
+ String response = helloWorld2.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld1.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+/* TUSCANY-3621
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld1.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorld2.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld1.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+*/
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java
new file mode 100644
index 0000000000..deb4dfc09d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.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 org.apache.tuscany.sca.binding.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorld2Impl implements HelloWorldBare {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld2.getGreetings: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld2.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld2.getGreetingsException: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld2.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+/* TUSCANY-3621
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld2.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld2.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+*/
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldBare.java b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldBare.java
new file mode 100644
index 0000000000..e37ff1aef3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldBare.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.sca.binding.ws;
+
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public interface HelloWorldBare {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+/* TUSCANY-3621
+ Foo getGreetingsComplex(Foo foo);
+*/
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit.wsdl
new file mode 100644
index 0000000000..03e0a8c93c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit.wsdl
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions targetNamespace="http://ws.binding.sca.tuscany.apache.org/doclit"
+ name="HelloWorldImplService"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/doclit"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ws.binding.sca.tuscany.apache.org/doclit"
+ schemaLocation="HelloWorldImplService_doclit1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsException">
+ <part name="parameters" element="tns:getGreetingsException"/>
+ </message>
+ <message name="getGreetingsExceptionResponse">
+ <part name="parameters" element="tns:getGreetingsExceptionResponse"/>
+ </message>
+ <message name="Exception">
+ <part name="fault" element="tns:Exception"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldImpl">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsException">
+ <input message="tns:getGreetingsException"/>
+ <output message="tns:getGreetingsExceptionResponse"/>
+ <fault message="tns:Exception" name="Exception"/>
+ </operation>
+<!-- TUSCANY-3621
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+-->
+ </portType>
+ <binding name="HelloWorldImplPortBinding" type="tns:HelloWorldImpl">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsException">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="Exception">
+ <soap:fault name="Exception" use="literal"/>
+ </fault>
+ </operation>
+<!-- TUSCANY-3621
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+-->
+ </binding>
+ <service name="HelloWorldImplService">
+ <port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
+ <soap:address location="http://localhost:8085/HelloWorldService/HelloWorld-doclit"/>
+ </port>
+ </service>
+</definitions>
+
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit1.xsd
new file mode 100644
index 0000000000..6238bf2f45
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit1.xsd
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://ws.binding.sca.tuscany.apache.org/doclit"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/doclit"
+ xmlns:tns2="http://helloworld/external"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:import namespace="http://helloworld/external" schemaLocation="./HelloWorldImplService-doclit2.xsd"/>
+
+ <xs:element name="Exception" type="tns:Exception"/>
+
+ <xs:element name="getGreetings" type="xs:string"/>
+
+ <xs:element name="getGreetingsResponse" type="xs:string"/>
+
+ <xs:element name="getGreetingsComplex" type="tns2:foo"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns2:foo"/>
+
+ <xs:element name="getGreetingsException" type="xs:string"/>
+
+ <xs:element name="getGreetingsExceptionResponse" type="xs:string"/>
+
+ <xs:complexType name="Exception">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit2.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit2.xsd
new file mode 100644
index 0000000000..d955cc2af4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldImplService-doclit2.xsd
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external"
+ xmlns:tns="http://helloworld/external"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..acdfcaaaa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..837bcb059e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..5ae9e78823
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-doc-lit/src/main/resources/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService1">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorld1Impl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="helloWorld2">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld-doclit" wsdlElement="http://ws.binding.sca.tuscany.apache.org/doclit#wsdl.binding(HelloWorldImplPortBinding)"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService2">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorld2Impl"/>
+ <service name="HelloWorldBare">
+ <binding.ws wsdlElement="http://ws.binding.sca.tuscany.apache.org/doclit#wsdl.port(HelloWorldImplService/HelloWorldImplPort)"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/pom.xml
new file mode 100644
index 0000000000..de8041888b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-java-first</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution Java First </name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.HelloWorldImpl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..6bc67db5fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
new file mode 100644
index 0000000000..8f57680d47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorldImpl implements HelloWorld {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetings: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..acdfcaaaa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..837bcb059e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..e6cdb94dfb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-java-first/src/main/resources/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldImpl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/README b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/README
new file mode 100644
index 0000000000..fe73646e78
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/README
@@ -0,0 +1,254 @@
+RPC Literal WSDL Style
+======================
+
+Interface
+---------
+
+@Remotable
+public interface HelloWorld {
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
+
+WSDL
+----
+
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ws.binding.sca.tuscany.apache.org/rpclit"
+ schemaLocation="HelloWorldImplService-rpclit.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="s" type="xsd:string"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="s" type="xsd:string"/>
+ </message>
+ <message name="getGreetingsException">
+ <part name="s" type="xsd:string"/>
+ </message>
+ <message name="getGreetingsExceptionResponse">
+ <part name="s" type="xsd:string"/>
+ </message>
+ <message name="Exception">
+ <part name="fault" element="tns:Exception"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="foo" type="tns:foo"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="foo" type="tns:foo"/>
+ </message>
+ <portType name="HelloWorldImpl">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsException">
+ <input message="tns:getGreetingsException"/>
+ <output message="tns:getGreetingsExceptionResponse"/>
+ <fault message="tns:Exception" name="Exception"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldImplPortBinding" type="tns:HelloWorldImpl">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsNamespace"/>
+ </input>
+ <output>
+ <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsNamespace"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsException">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsExceptionNamespace"/>
+ </input>
+ <output>
+ <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsExceptionNamespace"/>
+ </output>
+ <fault name="Exception">
+ <soap:fault name="Exception" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+
+getGreetings SOAP Request/Response
+----------------------------------
+
+POST /HelloWorldService/HelloWorld-rpclit-porttype HTTP/1.1
+Content-Type: text/xml; charset=UTF-8
+SOAPAction: ""
+User-Agent: Axis2
+Host: localhost:8088
+Content-Length: 480
+
+<?xml version='1.0' encoding='UTF-8'?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soape nv:Body>
+ <axis2ns1:getGreetings
+ xmlns:axis2ns1="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsNamespace">
+ <s xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ns2="http://ws.binding.sca.tuscany.apache.org/"
+ xsi:type="xs:string">Fred
+ </s>
+ </axis2ns1:getGreetings>
+ </soapenv:Body>
+</soapenv:Envelope>
+
+HTTP/1.1 200 OK
+Content-Type: text/xml; charset=utf-8
+Transfer-Encoding: chunked
+
+1FE
+<?xml version='1.0' encoding='UTF-8'?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soape nv:Body>
+ <axis2ns4:getGreetingsResponse
+ xmlns:axis2ns4="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsResponseNamespace">
+ <s xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ns2="http://ws.binding.sca.tuscany.apache.org/"
+ xsi:type="xs:string">Hello Fred</s>
+ </axis2ns4:getGreetingsResponse>
+ </soapenv:Body>
+</soapenv:Envelope>
+
+
+getGreetingsException SOAP Request/Response
+-------------------------------------------
+
+POST /HelloWorldService/HelloWorld-rpclit-porttype HTTP/1.1
+Content-Type: text/xml; charset=UTF-8
+SOAPAction: ""
+User-Agent: Axis2
+Host: localhost:8088
+Content-Length: 507
+
+<?xml version='1.0' encoding='UTF-8'?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soape nv:Body>
+ <axis2ns5:getGreetingsException
+ xmlns:axis2ns5="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsExceptionNamespace">
+ <s xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ns2="http://ws.binding.sca.tuscany.apache.org/"
+ xsi:type="xs:string">Fred
+ </s>
+ </axis2ns5:getGreetingsException>
+ </soapenv:Body>
+</soapenv:Envelope>
+
+HTTP/1.1 500 Internal Server Error
+Content-Type: text/xml; charset=utf-8
+Transfer-Encoding: chunked
+
+133C
+<?xml version='1.0' encoding='UTF-8'?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soape nv:Body>
+ <soapenv:Fault>
+ <faultcode>soapenv:Server</faultcode>
+ <faultstring>org.apache.tuscany.sca.interfacedef.util.FaultE
+ xception cannot be cast to org.apache.axiom.om.OMElement</faultstring>
+ <detail>
+ ...
+ </Exception>
+ </detail>
+ </soapenv:Fault>
+ </soapenv:Body>
+</soapenv:Envelope>
+
+TODO - exception is wrong
+
+getGreetingsComplex SOAP Request/Response
+-----------------------------------------
+
+POST /HelloWorldService/HelloWorld-rpclit-porttype HTTP/1.1
+Content-Type: text/xml; charset=UTF-8
+SOAPAction: ""
+User-Agent: Axis2
+Host: localhost:8088
+Content-Length: 570
+
+<?xml version='1.0' encoding='UTF-8'?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soape nv:Body>
+ <axis2ns7:getGreetingsComplex
+ xmlns:axis2ns7="http://ws.binding.sca.tuscany.apache.org/rpclit">
+ <foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ns3="http://ws.binding.sca.tuscany.apache.org/"
+ xmlns:ns2="http://helloworld/external"
+ xsi:type="ns2:foo">
+ <bars>
+ <b>true</b>
+ <s>petra</s>
+ <x>1</x>
+ <y>2</y>
+ </bars>
+ <bars>
+ <b>false</b>
+ <s>beate</s>
+ <x>3</x>
+ <y>4</y>
+ </bars>
+ </foo>
+ </axis2ns7:getGreetingsComplex>
+ </soapenv:Body>
+</soapenv:Envelope>
+
+HTTP/1.1 200 OK
+Content-Type: text/xml; charset=utf-8
+Transfer-Encoding: chunked
+
+281
+<?xml version='1.0' encoding='UTF-8'?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soape nv:Body>
+ <axis2ns10:getGreetingsComplexResponse
+ xmlns:axis2ns10="http://ws.binding.sca.tuscany.apache.org/rpclit">
+ <foo xm lns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ns3="http://ws.binding.sca.tuscany.apache.org/"
+ xmlns:ns2="http://helloworld/external"
+ xsi:type="ns2:foo">
+ <bars>
+ <b>true</b>
+ <s>petra</s>
+ <x>1</x>
+ <y>2</y>
+ </bars>
+ <bars>
+ <b>false</b>
+ <s>bea
+ te</s>
+ <x>3</x>
+ <y>4</y>
+ </bars>
+ <bars>
+ <b>true</b>
+ <s>simon</s>
+ <x>7</x>
+ <y>8</y>
+ </bars>
+ </foo>
+ </axis2ns10:getGreetingsComplexResponse>
+ </soapenv:Body>
+</soapenv:Envelope> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/pom.xml
new file mode 100644
index 0000000000..400b89ad7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/pom.xml
@@ -0,0 +1,123 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-rpc-lit</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution RPC Lit</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.HelloWorld1Impl</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..6bc67db5fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.java
new file mode 100644
index 0000000000..9ee8373468
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld1Impl.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.sca.binding.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorld1Impl implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorld2;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld1.getGreetings: " + s);
+ String response = helloWorld2.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld1.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld1.getGreetingsException: " + s);
+ String response = helloWorld2.getGreetingsException(s);
+ System.out.println("Leaving SCA HelloWorld1.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld1.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorld2.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld1.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java
new file mode 100644
index 0000000000..6f3b430d6d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld2Impl.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+@WebService
+public class HelloWorld2Impl implements HelloWorld {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld2.getGreetings: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld2.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld2.getGreetingsException: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld2.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld2.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld2.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit.wsdl
new file mode 100644
index 0000000000..0c11e6a8f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit.wsdl
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions targetNamespace="http://ws.binding.sca.tuscany.apache.org/rpclit"
+ name="HelloWorldImplService"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/rpclit"
+ xmlns:tns2="http://helloworld/external"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ws.binding.sca.tuscany.apache.org/rpclit"
+ schemaLocation="HelloWorldImplService-rpclit1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="s" type="xsd:string"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="s" type="xsd:string"/>
+ </message>
+ <message name="getGreetingsException">
+ <part name="s" type="xsd:string"/>
+ </message>
+ <message name="getGreetingsExceptionResponse">
+ <part name="s" type="xsd:string"/>
+ </message>
+ <message name="Exception">
+ <part name="fault" element="tns:Exception"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="foo" type="tns2:foo"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="foo" type="tns2:foo"/>
+ </message>
+ <portType name="HelloWorldImpl">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsException">
+ <input message="tns:getGreetingsException"/>
+ <output message="tns:getGreetingsExceptionResponse"/>
+ <fault message="tns:Exception" name="Exception"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldImplPortBinding" type="tns:HelloWorldImpl">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsNamespace" />
+ </input>
+ <output>
+ <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsResponseNamespace"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsException">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsExceptionNamespace"/>
+ </input>
+ <output>
+ <soap:body use="literal" namespace="http://ws.binding.sca.tuscany.apache.org/rpclit/getGreetingsExceptionResponseNamespace"/>
+ </output>
+ <fault name="Exception">
+ <soap:fault name="Exception" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldImplService">
+ <port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
+ <soap:address location="http://localhost:8087/HelloWorldService/HelloWorld-rpclit"/>
+ </port>
+ </service>
+</definitions>
+
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit1.xsd
new file mode 100644
index 0000000000..8841f0dcf2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit1.xsd
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://ws.binding.sca.tuscany.apache.org/rpclit"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/rpclit"
+ xmlns:tns2="http://helloworld/external"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:import namespace="http://helloworld/external" schemaLocation="./HelloWorldImplService-rpclit2.xsd"/>
+
+ <xs:element name="Exception" type="tns:Exception"/>
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsException" type="tns:getGreetingsException"/>
+
+ <xs:element name="getGreetingsExceptionResponse" type="tns:getGreetingsExceptionResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetingsException">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsExceptionResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Exception">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns2:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns2:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit2.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit2.xsd
new file mode 100644
index 0000000000..d955cc2af4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldImplService-rpclit2.xsd
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external"
+ xmlns:tns="http://helloworld/external"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..acdfcaaaa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..837bcb059e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..28dedef44c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-rpc-lit/src/main/resources/helloworld.composite
@@ -0,0 +1,64 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService1">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorld1Impl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </service>
+ <reference name="helloWorld2">
+ <interface.wsdl interface="http://ws.binding.sca.tuscany.apache.org/rpclit#wsdl.porttype(HelloWorldImpl)"/>
+ <binding.ws uri="http://localhost:8087/HelloWorldService/HelloWorld-rpclit-porttype"
+ wsdlElement="http://ws.binding.sca.tuscany.apache.org/rpclit#wsdl.binding(HelloWorldImplPortBinding)"/>
+ <!--
+ note that it's not necessary to have interface.wsdl here but I left it in after
+ I added the wsdlElement on the binding in order to configure the binding with the
+ wrapper element namespace that appears in the binding configuration
+ -->
+ </reference>
+ </component>
+
+ <component name="HelloWorldService1a">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorld1Impl"/>
+ <service name="HelloWorld">
+ <binding.ws uri="http://localhost:8087/HelloWorldService/HelloWorld-rpclit-porttype"
+ wsdlElement="http://ws.binding.sca.tuscany.apache.org/rpclit#wsdl.binding(HelloWorldImplPortBinding)"/>
+ </service>
+ <reference name="helloWorld2">
+ <binding.ws uri="http://localhost:8087/HelloWorldService/HelloWorld-rpclit"
+ wsdlElement="http://ws.binding.sca.tuscany.apache.org/rpclit#wsdl.binding(HelloWorldImplPortBinding)"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService2">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorld2Impl"/>
+ <service name="HelloWorld">
+ <binding.ws wsdlElement="http://ws.binding.sca.tuscany.apache.org/rpclit#wsdl.port(HelloWorldImplService/HelloWorldImplPort)"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws uri="http://localhost:8086/External/HelloWorld"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/pom.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/pom.xml
new file mode 100644
index 0000000000..52945adcf8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/pom.xml
@@ -0,0 +1,125 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-contribution-wsdl-first</artifactId>
+ <name>Apache Tuscany SCA iTest WS Contribution WSDL First</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <!-- execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.sca</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>HelloWorldImplService.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution-->
+ <execution>
+ <id>wsimport2</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>helloworld-external-service.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport2StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.java
new file mode 100644
index 0000000000..c9c1038ea3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorld.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.sca.binding.ws;
+
+import javax.jws.WebMethod;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
+ Foo getGreetingsComplex(Foo foo);
+
+ @WebMethod(operationName = "GetGreetingsCaps")
+ String getGreetingsCaps(String s);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.java
new file mode 100644
index 0000000000..d88a765682
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/java/org/apache/tuscany/sca/binding/ws/HelloWorldImpl.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.binding.ws;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.iface.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldImpl implements HelloWorld {
+
+ @Reference
+ public HelloWorldService helloWorldExternal;
+
+ public String getGreetings(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetings: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = helloWorldExternal.getGreetingsComplex(foo);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+ public String getGreetingsCaps(String s) {
+ System.out.println("Entering SCA HelloWorld.getGreetingsCaps: " + s);
+ String response = helloWorldExternal.getGreetingsCaps(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetingsCaps: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService.wsdl
new file mode 100644
index 0000000000..59fce9d849
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService.wsdl
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions targetNamespace="http://ws.binding.sca.tuscany.apache.org/"
+ name="HelloWorldImplService"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ws.binding.sca.tuscany.apache.org/"
+ schemaLocation="HelloWorldImplService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsException">
+ <part name="parameters" element="tns:getGreetingsException"/>
+ </message>
+ <message name="getGreetingsExceptionResponse">
+ <part name="parameters" element="tns:getGreetingsExceptionResponse"/>
+ </message>
+ <message name="Exception">
+ <part name="fault" element="tns:Exception"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <message name="GetGreetingsCaps">
+ <part name="parameters" element="tns:GetGreetingsCaps"/>
+ </message>
+ <message name="GetGreetingsCapsResponse">
+ <part name="parameters" element="tns:GetGreetingsCapsResponse"/>
+ </message>
+ <portType name="HelloWorldImpl">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsException">
+ <input message="tns:getGreetingsException"/>
+ <output message="tns:getGreetingsExceptionResponse"/>
+ <fault message="tns:Exception" name="Exception"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ <operation name="GetGreetingsCaps">
+ <input message="tns:GetGreetingsCaps"/>
+ <output message="tns:GetGreetingsCapsResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldImplPortBinding" type="tns:HelloWorldImpl">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsException">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="Exception">
+ <soap:fault name="Exception" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="GetGreetingsCaps">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldImplService">
+ <port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
+ <soap:address location="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </port>
+ </service>
+</definitions>
+
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService_schema1.xsd
new file mode 100644
index 0000000000..2d8adf3d73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService_schema1.xsd
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://ws.binding.sca.tuscany.apache.org/"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/"
+ xmlns:tns2="http://helloworld/external"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:import namespace="http://helloworld/external" schemaLocation="./HelloWorldImplService_schema2.xsd"/>
+
+ <xs:element name="Exception" type="tns:Exception"/>
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsException" type="tns:getGreetingsException"/>
+
+ <xs:element name="getGreetingsExceptionResponse" type="tns:getGreetingsExceptionResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:element name="GetGreetingsCaps" type="tns:GetGreetingsCaps"/>
+
+ <xs:element name="GetGreetingsCapsResponse" type="tns:GetGreetingsCapsResponse"/>
+
+ <xs:complexType name="getGreetingsException">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsExceptionResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Exception">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns2:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns2:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="GetGreetingsCaps">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="GetGreetingsCapsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService_schema2.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService_schema2.xsd
new file mode 100644
index 0000000000..d955cc2af4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldImplService_schema2.xsd
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external"
+ xmlns:tns="http://helloworld/external"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldServiceService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldServiceService_schema1.xsd
new file mode 100644
index 0000000000..467eeb90c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/HelloWorldServiceService_schema1.xsd
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://helloworld/external" xmlns:tns="http://helloworld/external" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="GetGreetingsCaps" type="tns:GetGreetingsCaps"/>
+
+ <xs:element name="GetGreetingsCapsResponse" type="tns:GetGreetingsCapsResponse"/>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="getGreetingsReturn" type="xs:string" form="qualified" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="GetGreetingsCaps">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="GetGreetingsCapsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..350ad6be96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/helloworld-external-service.wsdl b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/helloworld-external-service.wsdl
new file mode 100644
index 0000000000..c38f629e4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/helloworld-external-service.wsdl
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. -->
+<definitions targetNamespace="http://helloworld/external" name="HelloWorldServiceService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://helloworld/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://helloworld/external" schemaLocation="HelloWorldServiceService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <message name="GetGreetingsCaps">
+ <part name="parameters" element="tns:GetGreetingsCaps"/>
+ </message>
+ <message name="GetGreetingsCapsResponse">
+ <part name="parameters" element="tns:GetGreetingsCapsResponse"/>
+ </message>
+ <portType name="HelloWorldService">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ <operation name="GetGreetingsCaps">
+ <input message="tns:GetGreetingsCaps"/>
+ <output message="tns:GetGreetingsCapsResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldServicePortBinding" type="tns:HelloWorldService">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="GetGreetingsCaps">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldServiceService">
+ <port name="HelloWorldServicePort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="http://localhost:8086/External/HelloWorld"/>
+ </port>
+ </service>
+ <service name="HelloWorldImplService">
+ <port name="HelloWorldImplPort" binding="tns:HelloWorldServicePortBinding">
+ <soap:address location="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </port>
+ </service>
+</definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..8d0c7bf9ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/contribution-wsdl-first/src/main/resources/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.HelloWorldImpl"/>
+ <service name="HelloWorld">
+ <binding.ws wsdlElement="http://ws.binding.sca.tuscany.apache.org/#wsdl.port(HelloWorldImplService/HelloWorldImplPort)"/>
+ </service>
+ <reference name="helloWorldExternal">
+ <binding.ws wsdlElement="http://helloworld/external#wsdl.port(HelloWorldServiceService/HelloWorldServicePort)"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/pom.xml b/sandbox/sebastien/java/embed/itest/ws/defaults/pom.xml
new file mode 100644
index 0000000000..2107b1fc3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/pom.xml
@@ -0,0 +1,47 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-defaults</artifactId>
+ <name>Apache Tuscany SCA iTest WS with Defaults</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Bar.java b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Bar.java
new file mode 100644
index 0000000000..a1233f6d25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Bar.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import java.io.Serializable;
+
+public class Bar implements Serializable {
+ private static final long serialVersionUID = 1249963611910502668L;
+
+ private String s;
+ private int x;
+ private Integer y;
+
+ private Boolean b;
+
+ public Boolean getB() {
+ return b;
+ }
+ public void setB(Boolean b) {
+ this.b = b;
+ }
+ public String getS() {
+ return s;
+ }
+ public void setS(String s) {
+ this.s = s;
+ }
+ public int getX() {
+ return x;
+ }
+ public void setX(int x) {
+ this.x = x;
+ }
+ public Integer getY() {
+ return y;
+ }
+ public void setY(Integer y) {
+ this.y = y;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Foo.java b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Foo.java
new file mode 100644
index 0000000000..0695ace7f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Foo.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 org.apache.tuscany.sca.binding.ws.axis2;
+
+import java.io.Serializable;
+
+public class Foo implements Serializable {
+ private static final long serialVersionUID = 4879476066850018458L;
+
+ private Bar[] bars;
+
+ public Bar[] getBars() {
+ return bars;
+ }
+
+ public void setBars(Bar[] bars) {
+ this.bars = bars;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java
new file mode 100644
index 0000000000..f39566ccbf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+ Foo getGreetingsComplex(Foo foo);
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldClient.java
new file mode 100644
index 0000000000..332f825a51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldClient.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorldWS;
+
+ public String getGreetings(String s) {
+ String response = helloWorldWS.getGreetings(s);
+ System.out.println("At client: " + response);
+ return response;
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ Foo response = helloWorldWS.getGreetingsComplex(foo);
+ System.out.println("At client: " + response.getBars()[0].getS());
+ return response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java
new file mode 100644
index 0000000000..3bbf50a728
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ String response = "Hello " + s;
+ System.out.println("At service: " + response);
+ return response;
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ Foo response = foo;
+ Bar b3 = new Bar();
+ b3.setS("simon");
+ b3.setX(4);
+ b3.setY(new Integer(5));
+ b3.setB(Boolean.TRUE);
+ response.getBars()[1] = b3;
+ System.out.println("At sevice: " + response.getBars()[0].getS());
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e71dd465f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.composite
new file mode 100644
index 0000000000..cae74697f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.composite
@@ -0,0 +1,41 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <!--
+ Test the ws binding with default settings for simple and complex parameters
+ -->
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldClient"/>
+ <reference name="helloWorldWS" target="HelloWorldService"/>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldService"/>
+ <service name="HelloWorld">
+ <binding.ws/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl
new file mode 100644
index 0000000000..a352696b8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl
@@ -0,0 +1,90 @@
+<?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="HelloWorldSoapPort1">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService1"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/defaults/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultsTestCase.java b/sandbox/sebastien/java/embed/itest/ws/defaults/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultsTestCase.java
new file mode 100644
index 0000000000..1e4c1fcbff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/defaults/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultsTestCase.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.sca.binding.ws.axis2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class DefaultsTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode(new Contribution("test", "target/classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ }
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.setBars(new Bar[] { b1, b2} );
+
+ Foo f2 = helloWorld.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars()[0].getS());
+ assertEquals(1, f2.getBars()[0].getX());
+ assertEquals(2, f2.getBars()[0].getY().intValue());
+ assertTrue(f2.getBars()[0].getB().booleanValue());
+ assertEquals("simon", f2.getBars()[1].getS());
+ assertEquals(4, f2.getBars()[1].getX());
+ assertEquals(5, f2.getBars()[1].getY().intValue());
+ assertTrue(f2.getBars()[1].getB().booleanValue());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoint-references/pom.xml b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/pom.xml
new file mode 100644
index 0000000000..99aabcbec0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/pom.xml
@@ -0,0 +1,47 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-endpoint-references</artifactId>
+ <name>Apache Tuscany SCA iTest WS Endpoint References</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java
new file mode 100644
index 0000000000..d6db1c2d0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldComponent.java b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldComponent.java
new file mode 100644
index 0000000000..4ba7e67de2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldComponent.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldComponent implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorldWS;
+
+ public String getGreetings(String s) {
+ return helloWorldWS.getGreetings(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java
new file mode 100644
index 0000000000..052b49ff55
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.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 org.apache.tuscany.sca.binding.ws.axis2;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.composite b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.composite
new file mode 100644
index 0000000000..1b0af55874
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.composite
@@ -0,0 +1,48 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="HelloWorld2">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldService"/>
+ <service name="HelloWorld">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws>
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/myService</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldComponent"/>
+ <reference name="helloWorldWS">
+ <binding.ws>
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/myService</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl
new file mode 100644
index 0000000000..1a2272d7ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl
@@ -0,0 +1,86 @@
+<?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:8085/services/HelloWorldWebService"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java
new file mode 100644
index 0000000000..f1cfe30475
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoint-references/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.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.binding.ws.axis2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class HelloWorldTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = "target/classes";
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.composite", new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/pom.xml b/sandbox/sebastien/java/embed/itest/ws/endpoints/pom.xml
new file mode 100644
index 0000000000..84da8f9ab6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/pom.xml
@@ -0,0 +1,47 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-endpoints</artifactId>
+ <name>Apache Tuscany SCA iTest WS Endpoints</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldMultiService.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldMultiService.java
new file mode 100644
index 0000000000..8f77c63213
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldMultiService.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+
+public class HelloWorldMultiService implements HelloWorldOM, HelloWorldOM2 {
+
+ public OMElement getGreetings(OMElement requestOM) {
+ String name = requestOM.getFirstElement().getText();
+
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld");
+ OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld");
+ responseOM.addChild(param);
+ param.addChild(omFactory.createOMText("Hello " + name));
+
+ return responseOM;
+ }
+
+ public OMElement getGreetings2(OMElement requestOM) {
+ String name = requestOM.getFirstElement().getText();
+
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld");
+ OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld");
+ responseOM.addChild(param);
+ param.addChild(omFactory.createOMText("Hello2 " + name));
+
+ return responseOM;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM.java
new file mode 100644
index 0000000000..e248815805
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM.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.ws.axis2;
+
+import org.apache.axiom.om.OMElement;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldOM {
+
+ OMElement getGreetings(OMElement parmE);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM2.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM2.java
new file mode 100644
index 0000000000..9d0a4ce5b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM2.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.ws.axis2;
+
+import org.apache.axiom.om.OMElement;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldOM2 {
+
+ OMElement getGreetings2(OMElement parmE);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMComponent.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMComponent.java
new file mode 100644
index 0000000000..8439696fa8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMComponent.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+import org.apache.axiom.om.OMElement;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldOMComponent implements HelloWorldOM {
+
+ @Reference
+ public HelloWorldOM helloWorldWS;
+
+ public OMElement getGreetings(OMElement om) {
+ return helloWorldWS.getGreetings(om);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMService.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMService.java
new file mode 100644
index 0000000000..5b8578c816
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMService.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.binding.ws.axis2;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+
+public class HelloWorldOMService implements HelloWorldOM {
+
+ public OMElement getGreetings(OMElement requestOM) {
+ System.out.println(" **** getGreetings **** ");
+ String name = requestOM.getFirstElement().getText();
+
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld");
+ OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld");
+ responseOM.addChild(param);
+ param.addChild(omFactory.createOMText("Hello " + name));
+
+ return responseOM;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/DefaultMultiService.composite b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/DefaultMultiService.composite
new file mode 100644
index 0000000000..c7863a5ff8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/DefaultMultiService.composite
@@ -0,0 +1,53 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="DefaultMultiService">
+
+ <!--
+ exposing a component which has multiple services with a WS binding,
+ endpoint should be <componentURI>/<serviceName> so for this composite:
+ http://localhost:8085/HelloWorldService/service1
+ -->
+
+
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldMultiService"/>
+ <service name="HelloWorldOM">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"
+ wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"/>
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </reference>
+ </component>
+
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/DefaultSingleService.composite b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/DefaultSingleService.composite
new file mode 100644
index 0000000000..63c6a89cfb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/DefaultSingleService.composite
@@ -0,0 +1,51 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="DefaultSingleService">
+
+ <!--
+ exposing a component with a WS binding, endpoint should be <componentURI>/<serviceName>
+ unless the component has just a single service in which case its just <componentURI>
+ so for this composite: http://localhost:8085/HelloWorldService
+ -->
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMService"/>
+ <service name="HelloWorldOM">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"
+ wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"/>
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </reference>
+ </component>
+
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLExplicitURI.composite b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLExplicitURI.composite
new file mode 100644
index 0000000000..9991a415f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLExplicitURI.composite
@@ -0,0 +1,50 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="endpoint3">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with an explicit URL
+ so for this composite the service is: http://localhost:8085/myExplicitURI
+ -->
+
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMService"/>
+ <service name="HelloWorldOM">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/myExplicitURI"/>
+ </reference>
+ </component>
+
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
new file mode 100644
index 0000000000..1ea7ab5a36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURI.composite
@@ -0,0 +1,51 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="endpoint4">
+
+ <!--
+ exposing a component with a WS binding using a WSDL port with a relative URL
+ so for this composite the service is: http://localhost:8085/HelloWorldService/myRelativeURI
+ -->
+
+
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMService"/>
+ <service name="HelloWorldOM">
+ <interface.wsdl interface="http://helloworld-om-relative-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-relative-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om-relative-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-relative-uri#wsdl.binding(HelloWorldSoapBinding)"
+ uri="http://localhost:8085/HelloWorldService/helloWorld/myRelativeURI"/>
+ </reference>
+ </component>
+
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
new file mode 100644
index 0000000000..fe68755c47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-relative-uri.wsdl
@@ -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.
+-->
+<wsdl:definitions targetNamespace="http://helloworld-om-relative-uri" xmlns:tns="http://helloworld-om-relative-uri" 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-om">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om-relative-uri" 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:8085/HelloWorldService/helloWorld/myRelativeURI"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-uri.wsdl b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-uri.wsdl
new file mode 100644
index 0000000000..baa223f41c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-uri.wsdl
@@ -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.
+-->
+<wsdl:definitions targetNamespace="http://helloworld-om-uri" xmlns:tns="http://helloworld-om-uri" 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-om">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om-uri" 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:8085/myExplicitURI"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om.wsdl b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om.wsdl
new file mode 100644
index 0000000000..73ca02246d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om.wsdl
@@ -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.
+-->
+<wsdl:definitions targetNamespace="http://helloworld-om" xmlns:tns="http://helloworld-om" 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-om">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om" 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://endpoint.not.used"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java
new file mode 100644
index 0000000000..bad94bbbc3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/AbstractHelloWorldOMTestCase.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOM;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public abstract class AbstractHelloWorldOMTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorldOM helloWorld;
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = "target/classes";
+ node = NodeFactory.newInstance().createNode(getCompositeName(), new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ public void testCalculator() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld");
+ OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");
+ requestOM.addChild(parmE);
+ parmE.addChild(fac.createOMText("petra"));
+ OMElement responseOM = helloWorld.getGreetings(requestOM);
+ OMElement child = (OMElement)responseOM.getFirstElement();
+ Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+ protected String getCompositeName() {
+ String className = this.getClass().getName();
+ return className.substring(0, className.length() - 8).replace('.', '/') + ".composite";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultMultiServiceTestCase.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultMultiServiceTestCase.java
new file mode 100644
index 0000000000..4ecf016e5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultMultiServiceTestCase.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+public class DefaultMultiServiceTestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultSingleServiceTestCase.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultSingleServiceTestCase.java
new file mode 100644
index 0000000000..13163d62ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/DefaultSingleServiceTestCase.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+public class DefaultSingleServiceTestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLExplicitURITestCase.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLExplicitURITestCase.java
new file mode 100644
index 0000000000..bb492557d4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLExplicitURITestCase.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+public class WSDLExplicitURITestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURITestCase.java b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURITestCase.java
new file mode 100644
index 0000000000..e038cc3116
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/endpoints/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLRelativeURITestCase.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+public class WSDLRelativeURITestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-client/pom.xml b/sandbox/sebastien/java/embed/itest/ws/external-client/pom.xml
new file mode 100644
index 0000000000..1a75336754
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-client/pom.xml
@@ -0,0 +1,112 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-external-client</artifactId>
+ <name>Apache Tuscany SCA iTest WS External Client</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-rt</artifactId>
+ <version>2.1.7</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsimport1</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>org.apache.tuscany.sca.binding.ws.jaxws.sca</packageName>
+ <wsdlDirectory>${basedir}/target/classes</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>HelloWorldImplService.wsdl</wsdlFile>
+ </wsdlFiles>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsimport1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java b/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java
new file mode 100644
index 0000000000..ccecf5695f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.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.sca.binding.ws.jaxws.external.client;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Exception_Exception;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.HelloWorldImpl;
+
+public class HelloWorldClientLauncher {
+
+ public HelloWorldImpl wsProxy;
+
+ public HelloWorldClientLauncher(){
+ }
+
+ public void createClient() throws Exception{
+ System.out.println(">>> Starting external JAXWS client ");
+
+ // default JVM JAXWS support
+ QName serviceName = new QName("http://ws.binding.sca.tuscany.apache.org/", "HelloWorldImplService");
+ QName portName = new QName("http://ws.binding.sca.tuscany.apache.org/", "HelloWorldImplPort");
+ //URL wsdlLocation = new File("../external-client/target/classes/helloworld-sca.wsdl").toURL();
+ URL wsdlLocation = new File("../external-client/target/classes/HelloWorldImplService.wsdl").toURL();
+ javax.xml.ws.Service webService = Service.create(wsdlLocation, serviceName);
+ wsProxy = (HelloWorldImpl) webService.getPort(portName, HelloWorldImpl.class);
+ }
+
+ public void destroyClient(){
+ System.out.println(">>> Stopping external JAXWS client: ");
+ // TODO
+ }
+
+ public String getGreetings(String name){
+ System.out.println("Entering External Client HelloWorld.getGreetings: " + name);
+ String response = wsProxy.getGreetings(name);
+ System.out.println("Leaving External Client HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String name) throws Exception_Exception {
+ System.out.println("Entering External Client HelloWorld.getGreetingsException: " + name);
+ String response = wsProxy.getGreetingsException(name);
+ System.out.println("Leaving External Client HelloWorld.getGreetingsException: " + response);
+ return response;
+ }
+
+ public Foo getGreetingsComplex(Foo f) throws Exception_Exception {
+ System.out.println("Entering External Client HelloWorld.getGreetingsComplex: " + f.getBars().get(0).getS());
+ Foo response = wsProxy.getGreetingsComplex(f);
+ System.out.println("Leaving External Client HelloWorld.getGreetingsComplex: " + response.getBars().get(0).getS());
+ return response;
+ }
+
+ public String getGreetingsCaps(String s) throws Exception_Exception {
+ System.out.println("Entering External Client HelloWorld.getGreetingsCaps: " + s);
+ String response = wsProxy.getGreetingsCaps(s);
+ System.out.println("Leaving External Client HelloWorld.getGreetingsCaps: " + response);
+ return response;
+ }
+
+ public static void main(String[] args) throws Exception {
+ HelloWorldClientLauncher launcher = new HelloWorldClientLauncher();
+ launcher.createClient();
+ launcher.getGreetings("Fred");
+ launcher.destroyClient();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/resources/HelloWorldImplService.wsdl b/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/resources/HelloWorldImplService.wsdl
new file mode 100644
index 0000000000..d175589d7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/resources/HelloWorldImplService.wsdl
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions targetNamespace="http://ws.binding.sca.tuscany.apache.org/"
+ name="HelloWorldImplService"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ws.binding.sca.tuscany.apache.org/"
+ schemaLocation="HelloWorldImplService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="getGreetings">
+ <part name="parameters" element="tns:getGreetings"/>
+ </message>
+ <message name="getGreetingsResponse">
+ <part name="parameters" element="tns:getGreetingsResponse"/>
+ </message>
+ <message name="getGreetingsException">
+ <part name="parameters" element="tns:getGreetingsException"/>
+ </message>
+ <message name="getGreetingsExceptionResponse">
+ <part name="parameters" element="tns:getGreetingsExceptionResponse"/>
+ </message>
+ <message name="Exception">
+ <part name="fault" element="tns:Exception"/>
+ </message>
+ <message name="getGreetingsComplex">
+ <part name="parameters" element="tns:getGreetingsComplex"/>
+ </message>
+ <message name="getGreetingsComplexResponse">
+ <part name="parameters" element="tns:getGreetingsComplexResponse"/>
+ </message>
+ <message name="GetGreetingsCaps">
+ <part name="parameters" element="tns:GetGreetingsCaps"/>
+ </message>
+ <message name="GetGreetingsCapsResponse">
+ <part name="parameters" element="tns:GetGreetingsCapsResponse"/>
+ </message>
+ <portType name="HelloWorldImpl">
+ <operation name="getGreetings">
+ <input message="tns:getGreetings"/>
+ <output message="tns:getGreetingsResponse"/>
+ </operation>
+ <operation name="getGreetingsException">
+ <input message="tns:getGreetingsException"/>
+ <output message="tns:getGreetingsExceptionResponse"/>
+ <fault message="tns:Exception" name="Exception"/>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <input message="tns:getGreetingsComplex"/>
+ <output message="tns:getGreetingsComplexResponse"/>
+ </operation>
+ <operation name="GetGreetingsCaps">
+ <input message="tns:GetGreetingsCaps"/>
+ <output message="tns:GetGreetingsCapsResponse"/>
+ </operation>
+ </portType>
+ <binding name="HelloWorldImplPortBinding" type="tns:HelloWorldImpl">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="getGreetings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getGreetingsException">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="Exception">
+ <soap:fault name="Exception" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getGreetingsComplex">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="GetGreetingsCaps">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="HelloWorldImplService">
+ <port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
+ <soap:address location="http://localhost:8085/HelloWorldService/HelloWorld"/>
+ </port>
+ </service>
+</definitions>
+
+
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd b/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd
new file mode 100644
index 0000000000..c9c0acb038
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xs:schema version="1.0" targetNamespace="http://ws.binding.sca.tuscany.apache.org/"
+ xmlns:tns="http://ws.binding.sca.tuscany.apache.org/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="Exception" type="tns:Exception"/>
+
+ <xs:element name="getGreetings" type="tns:getGreetings"/>
+
+ <xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
+
+ <xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+
+ <xs:element name="getGreetingsException" type="tns:getGreetingsException"/>
+
+ <xs:element name="getGreetingsExceptionResponse" type="tns:getGreetingsExceptionResponse"/>
+
+ <xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+
+ <xs:element name="GetGreetingsCaps" type="tns:GetGreetingsCaps"/>
+
+ <xs:element name="GetGreetingsCapsResponse" type="tns:GetGreetingsCapsResponse"/>
+
+ <xs:complexType name="getGreetingsException">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsExceptionResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Exception">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetings">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplex">
+ <xs:sequence>
+ <xs:element name="arg0" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bars" type="tns:bar" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="bar">
+ <xs:sequence>
+ <xs:element name="b" type="xs:boolean" minOccurs="0"/>
+ <xs:element name="s" type="xs:string" minOccurs="0"/>
+ <xs:element name="x" type="xs:int"/>
+ <xs:element name="y" type="xs:int" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsComplexResponse">
+ <xs:sequence>
+ <xs:element name="return" type="tns:foo" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="GetGreetingsCaps">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="GetGreetingsCapsResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-service/pom.xml b/sandbox/sebastien/java/embed/itest/ws/external-service/pom.xml
new file mode 100644
index 0000000000..f789844419
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-service/pom.xml
@@ -0,0 +1,104 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-external-service</artifactId>
+ <name>Apache Tuscany SCA iTest WS External Service</name>
+
+ <dependencies>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsgen1</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldService</sei>
+ <genWsdl>true</genWsdl>
+ <staleFile>${project.build.directory}/jaxws/stale/.wsgen1StaleFlag</staleFile>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <verbose>true</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/Bar.java b/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/Bar.java
new file mode 100644
index 0000000000..1f330aa441
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/Bar.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws.external.service;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for bar complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="bar">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="b" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ * &lt;element name="s" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="x" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;element name="y" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "bar", propOrder = {
+ "b",
+ "s",
+ "x",
+ "y"
+})
+public class Bar {
+
+ protected Boolean b;
+ protected String s;
+ protected int x;
+ protected Integer y;
+
+ /**
+ * Gets the value of the b property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public Boolean isB() {
+ return b;
+ }
+
+ /**
+ * Sets the value of the b property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setB(Boolean value) {
+ this.b = value;
+ }
+
+ /**
+ * Gets the value of the s property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getS() {
+ return s;
+ }
+
+ /**
+ * Sets the value of the s property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setS(String value) {
+ this.s = value;
+ }
+
+ /**
+ * Gets the value of the x property.
+ *
+ */
+ public int getX() {
+ return x;
+ }
+
+ /**
+ * Sets the value of the x property.
+ *
+ */
+ public void setX(int value) {
+ this.x = value;
+ }
+
+ /**
+ * Gets the value of the y property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public Integer getY() {
+ return y;
+ }
+
+ /**
+ * Sets the value of the y property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setY(Integer value) {
+ this.y = value;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/Foo.java b/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/Foo.java
new file mode 100644
index 0000000000..1b22153169
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/Foo.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.ws.jaxws.external.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for foo complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="foo">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="bars" type="{http://ws.binding.sca.tuscany.apache.org/}bar" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "foo", propOrder = {
+ "bars"
+})
+public class Foo {
+
+ @XmlElement(nillable = true)
+ protected List<Bar> bars;
+
+ /**
+ * Gets the value of the bars property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the bars property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getBars().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Bar }
+ *
+ *
+ */
+ public List<Bar> getBars() {
+ if (bars == null) {
+ bars = new ArrayList<Bar>();
+ }
+ return this.bars;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java
new file mode 100644
index 0000000000..129365b5e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws.external.service;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+@WebService(name = "HelloWorldService", targetNamespace = "http://helloworld/external")
+public class HelloWorldService {
+
+ @WebMethod
+ @WebResult(name = "getGreetingsReturn", targetNamespace = "http://helloworld/external")
+ @RequestWrapper(localName = "getGreetings", targetNamespace = "http://helloworld/external", className = "org.apache.tuscany.sca.binding.ws.jaxws.external.service.GetGreetings")
+ @ResponseWrapper(localName = "getGreetingsResponse", targetNamespace = "http://helloworld/external", className = "org.apache.tuscany.sca.binding.ws.jaxws.external.service.GetGreetingsResponse")
+ public String getGreetings( @WebParam(name = "name", targetNamespace = "http://helloworld/external")
+ String name) {
+ System.out.println("Entering External Service HelloWorld.getGreetings: " + name);
+ String response = "Hello " + name;
+ System.out.println("Leaving External Service HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public Foo getGreetingsComplex(Foo foo){
+ System.out.println("Entering External Service HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ Foo response = foo;
+ Bar b3 = new Bar();
+ b3.setS("simon");
+ b3.setX(7);
+ b3.setY(new Integer(8));
+ b3.setB(Boolean.TRUE);
+ response.getBars().add(b3);
+ System.out.println("Leaving External Service HelloWorld.getGreetingsComplex: " + foo.getBars().get(0).getS());
+ return response;
+ }
+
+ public String GetGreetingsCaps(String name) {
+ System.out.println("Entering External Service HelloWorld.GetGreetingsCaps: " + name);
+ String response = "Hello " + name;
+ System.out.println("Leaving External Service HelloWorld.GetGreetingsCaps: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java b/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java
new file mode 100644
index 0000000000..3a6266f1ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws.external.service;
+
+import javax.xml.ws.Endpoint;
+
+public class HelloWorldServiceLauncher {
+
+ public Endpoint endpoint;
+
+ public HelloWorldServiceLauncher(){
+
+ }
+
+ public void createService(){
+ System.out.println(">>> Starting external JAXWS service at http://localhost:8086/External/HelloWorld");
+
+ // default JVM JAXWS support.
+ endpoint= Endpoint.publish("http://localhost:8086/External/HelloWorld",
+ new HelloWorldService());
+ }
+
+ public void destoryService(){
+ System.out.println(">>> Stopping external JAXWS service at http://localhost:8086/External/HelloWorld");
+ endpoint.stop();
+ }
+
+ public static void main(String[] args) throws Exception {
+ HelloWorldServiceLauncher launcher = new HelloWorldServiceLauncher();
+ launcher.createService();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/README b/sandbox/sebastien/java/embed/itest/ws/http-ssl/README
new file mode 100644
index 0000000000..41dcb8680b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/README
@@ -0,0 +1,68 @@
+The module tests web service communications running over HTTPS. HTTPS is configured
+in this embedded test environment by adding the confidentiality intent to both
+reference and service and by configuring reference and service side policy sets
+to configure the web service binding appropriately to enable SSL.
+
+When running the web service binding in a container that itself is configured
+to provide SSL support these policy sets are not required. TODO can they themselves
+detect that they are not required.
+
+The SSL configuration depends on public/private key pairs and a keystore. This is how
+they are organized and generated
+
+
+Generate Private/Public keys into a keystore for use at the server
+------------------------------------------------------------------
+
+keytool -genkey -keyalg RSA -sigalg MD5withRSA -keysize 1024 -alias TuscanyUser -dname "CN=Tuscany Service, OU=Tuscany, O=Apache, L=Hursley, S=Hampshire, C=UK" -storetype JKS -keystore tuscany.jks -validity 9999 -keypass tuscany -storepass tuscany
+
+View the contents of the key store that result
+----------------------------------------------
+
+keytool -list -v -keystore tuscany.jks -storepass tuscany
+
+Keystore type: JKS
+Keystore provider: SUN
+
+Your keystore contains 1 entry
+
+Alias name: tuscanyuser
+Creation date: 26-Feb-2010
+Entry type: PrivateKeyEntry
+Certificate chain length: 1
+Certificate[1]:
+Owner: CN=Tuscany Service, OU=Tuscany, O=Apache, L=Hursley, ST=Hampshire, C=UK
+Issuer: CN=Tuscany Service, OU=Tuscany, O=Apache, L=Hursley, ST=Hampshire, C=UK
+Serial number: 4b87b4d7
+Valid from: Fri Feb 26 11:47:35 GMT 2010 until: Mon Jul 13 12:47:35 BST 2037
+Certificate fingerprints:
+ MD5: C3:0C:D6:DF:F6:27:26:47:AD:41:44:CA:D7:98:FA:41
+ SHA1: 2E:82:AD:F6:54:E0:C6:A5:47:5C:8C:9F:3B:5A:65:8E:F9:5A:40:07
+ Signature algorithm name: MD5withRSA
+ Version: 3
+
+
+IN THIS EMBEDDED TEST THE FOLLOWING ARE NOT REQUIRED AS BOTH REFERENCE AND SERVICES
+ARE RUNNING IN THE SAME JVM AND HAVE ACCESS TO THE SERVICE SIDE KEY STORE
+
+Generate the client side certificate
+------------------------------------
+
+keytool -export -alias TuscanyUser -file tuscany.cer -keystore tuscany.jks -storepass tuscany
+
+Print the contents of the generated certificate file
+----------------------------------------------------
+
+keytool -printcert -v -file tuscany.cer
+
+Owner: CN=Tuscany Service, OU=Tuscany, O=Apache, L=Hursley, ST=Hampshire, C=UK
+Issuer: CN=Tuscany Service, OU=Tuscany, O=Apache, L=Hursley, ST=Hampshire, C=UK
+Serial number: 4b87b4d7
+Valid from: Fri Feb 26 11:47:35 GMT 2010 until: Mon Jul 13 12:47:35 BST 2037
+Certificate fingerprints:
+ MD5: C3:0C:D6:DF:F6:27:26:47:AD:41:44:CA:D7:98:FA:41
+ SHA1: 2E:82:AD:F6:54:E0:C6:A5:47:5C:8C:9F:3B:5A:65:8E:F9:5A:40:07
+ Signature algorithm name: MD5withRSA
+ Version: 3
+
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/pom.xml b/sandbox/sebastien/java/embed/itest/ws/http-ssl/pom.xml
new file mode 100644
index 0000000000..05f96f4a25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/pom.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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-http-ssl</artifactId>
+ <name>Apache Tuscany SCA iTest WS HTTP SSL</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..98eb6e361b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..2c6c4fc92c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/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 org.apache.tuscany.sca.binding.ws.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorldWS;
+
+ public String getGreetings(String s) {
+ String response = helloWorldWS.getGreetings(s);
+ System.out.println("At client: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..3662007984
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/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 org.apache.tuscany.sca.binding.ws.axis2.helloworld;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ String response = "Hello " + s;
+ System.out.println("At service: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e71dd465f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2">
+ <deployable composite="itest:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..04fe620be4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/binding/ws/axis2/helloworld/definitions.xml \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/definitions.xml b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/definitions.xml
new file mode 100644
index 0000000000..d7251590ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/definitions.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2" >
+
+ <sca:policySet name="HTTPSPolicySet"
+ provides="confidentiality.transport"
+ appliesTo="//sca:reference | //sca:binding.ws">
+ <tuscany:https>
+ <tuscany:keyStore type="JKS" file="target/classes/org/apache/tuscany/sca/binding/ws/axis2/helloworld/tuscany.jks" password="tuscany"/>
+ <tuscany:trustStore type="JKS" file="target/classes/org/apache/tuscany/sca/binding/ws/axis2/helloworld/tuscany.jks" password="tuscany"/>
+ </tuscany:https>
+ </sca:policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite
new file mode 100644
index 0000000000..aa21221b30
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite
@@ -0,0 +1,59 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ targetNamespace="http://www.tuscany.apache.org/itests/binding/ws/axis2"
+ name="HelloWorld"
+ policySets="itest:HTTPSPolicySet">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS" requires="confidentiality">
+ <binding.ws uri="https://localhost:8443/HelloWorldService/HelloWorld" />
+ </reference>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/>
+ <service name="HelloWorld" requires="confidentiality">
+ <binding.ws uri="https://0.0.0.0:8443/HelloWorldService/HelloWorld" />
+ </service>
+ </component>
+
+ <component name="HelloWorldClient2">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS" requires="confidentiality">
+ <binding.ws uri="https://localhost:8443/HelloWorldService2/HelloWorld" />
+ </reference>
+ </component>
+
+ <component name="HelloWorldService2">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/>
+ <service name="HelloWorld" requires="confidentiality">
+ <binding.ws/>
+ </service>
+ </component>
+
+ <component name="HelloWorldClient3">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS" target="HelloWorldService2"/>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..a352696b8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl
@@ -0,0 +1,90 @@
+<?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="HelloWorldSoapPort1">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService1"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/tuscany.jks b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/tuscany.jks
new file mode 100644
index 0000000000..d67bccdf8b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/tuscany.jks
Binary files differ
diff --git a/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HTTPSTestCase.java b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HTTPSTestCase.java
new file mode 100644
index 0000000000..d58f761b79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/http-ssl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HTTPSTestCase.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Ignore;
+
+@Ignore("TUSCANY-3632")
+public class HTTPSTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+ private HelloWorld helloWorld2;
+ private HelloWorld helloWorld3;
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode(new Contribution("test", "target/classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ helloWorld2 = node.getService(HelloWorld.class, "HelloWorldClient2");
+ helloWorld3 = node.getService(HelloWorld.class, "HelloWorldClient3");
+ }
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ assertEquals("Hello petra", helloWorld2.getGreetings("petra"));
+ // TODO - check policy matching for unconfigure reference
+ //assertEquals("Hello petra", helloWorld3.getGreetings("petra"));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/pom.xml b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/pom.xml
new file mode 100644
index 0000000000..cb917ea9d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-launcher-axis2</artifactId>
+ <name>Apache Tuscany SCA iTest WS Launcher Axis2</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Test resources -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-ws-external-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-ws-external-service</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackForwardSpecTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackForwardSpecTestCase.java
new file mode 100644
index 0000000000..aaf9504116
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackForwardSpecTestCase.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CallbackForwardSpecTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-callback-forwardspec/target/itest-ws-contribution-callback-forwardspec.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ @Test
+ @Ignore
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+
+ // Test may be causing build hang problems: temporarily ignore
+ // see dev list 16th July '10
+ @Test
+ @Ignore
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackFullSpecTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackFullSpecTestCase.java
new file mode 100644
index 0000000000..a8980c8031
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackFullSpecTestCase.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CallbackFullSpecTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-callback-fullspec/target/itest-ws-contribution-callback-fullspec.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ @Test
+ @Ignore
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackPromotionTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackPromotionTestCase.java
new file mode 100644
index 0000000000..8c26e5c54a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackPromotionTestCase.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CallbackPromotionTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-callback-promotion/target/itest-ws-contribution-callback-promotion.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ @Test
+ @Ignore
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackTestCase.java
new file mode 100644
index 0000000000..3bd65d549a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/CallbackTestCase.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CallbackTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-callback/target/itest-ws-contribution-callback.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/DocLitTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/DocLitTestCase.java
new file mode 100644
index 0000000000..a7fb6d6125
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/DocLitTestCase.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class DocLitTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("doc-lit", "../contribution-doc-lit/target/itest-ws-contribution-doc-lit.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ @Test
+ @Ignore("TUSCANY-3621")
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/DocLitWrappedTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/DocLitWrappedTestCase.java
new file mode 100644
index 0000000000..95e61ccc1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/DocLitWrappedTestCase.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DocLitWrappedTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("doc-lit-wrapped", "../contribution-doc-lit-wrapped/target/itest-ws-contribution-doc-lit-wrapped.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/JavaFirstTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/JavaFirstTestCase.java
new file mode 100644
index 0000000000..77418f331f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/JavaFirstTestCase.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.sca.binding.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JavaFirstTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-java-first/target/itest-ws-contribution-java-first.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/RpcLitTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/RpcLitTestCase.java
new file mode 100644
index 0000000000..9f74dd47b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/RpcLitTestCase.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RpcLitTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("rpc-lit", "../contribution-rpc-lit/target/itest-ws-contribution-rpc-lit.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/WSDLFirstTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/WSDLFirstTestCase.java
new file mode 100644
index 0000000000..7ed4829d85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/axis2/WSDLFirstTestCase.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.axis2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class WSDLFirstTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("wsdl-first", "../contribution-wsdl-first/target/itest-ws-contribution-wsdl-first.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ @Ignore
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @Test
+ public void testGetGreetingsCaps() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetingsCaps("Fred"));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-base/pom.xml b/sandbox/sebastien/java/embed/itest/ws/launcher-base/pom.xml
new file mode 100644
index 0000000000..bc78b9a0b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-base/pom.xml
@@ -0,0 +1,59 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-launcher-base</artifactId>
+ <name>Apache Tuscany SCA iTest WS Launcher Base</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Test resources -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-ws-external-client</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-ws-external-service</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackForwardSpecTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackForwardSpecTestCase.java
new file mode 100644
index 0000000000..d349e450c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackForwardSpecTestCase.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CallbackForwardSpecTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-callback-forwardspec/target/itest-ws-contribution-callback-forwardspec.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ @Test
+ @Ignore
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackFullSpecTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackFullSpecTestCase.java
new file mode 100644
index 0000000000..0e0e6e93ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackFullSpecTestCase.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CallbackFullSpecTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-callback-fullspec/target/itest-ws-contribution-callback-fullspec.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ @Test
+ @Ignore
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackPromotionTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackPromotionTestCase.java
new file mode 100644
index 0000000000..09697f82ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackPromotionTestCase.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CallbackPromotionTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-callback-promotion/target/itest-ws-contribution-callback-promotion.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ @Test
+ @Ignore
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackTestCase.java
new file mode 100644
index 0000000000..49ba20c20b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/CallbackTestCase.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CallbackTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-callback/target/itest-ws-contribution-callback.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/DocLitWrappedTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/DocLitWrappedTestCase.java
new file mode 100644
index 0000000000..a85007e019
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/DocLitWrappedTestCase.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DocLitWrappedTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("doc-lit-wrapped", "../contribution-doc-lit-wrapped/target/itest-ws-contribution-doc-lit-wrapped.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/JavaFirstTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/JavaFirstTestCase.java
new file mode 100644
index 0000000000..0aa6a71db4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/JavaFirstTestCase.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.sca.binding.ws.launcher.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JavaFirstTestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-java-first/target/itest-ws-contribution-java-first.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/WSDLFirstTestCase.java b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/WSDLFirstTestCase.java
new file mode 100644
index 0000000000..c8566bfa3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/launcher-base/src/test/java/org/apache/tuscany/sca/binding/ws/launcher/base/WSDLFirstTestCase.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.launcher.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Bar;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Foo;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class WSDLFirstTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
+
+ @Before
+ public void setUp() throws Exception {
+ // Start the external service
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
+
+ // Start the SCA contribution
+ node = NodeFactory.newInstance().createNode(new Contribution("wsdl-first", "../contribution-wsdl-first/target/itest-ws-contribution-wsdl-first.jar"));
+ node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+/*
+ @Test
+ public void testWait() throws Exception {
+ System.out.println("Press a key");
+ System.in.read();
+ }
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
+
+ @Test
+ @Ignore
+ public void testGetGreetingsException() throws Exception {
+ try {
+ externalClient.getGreetingsException("Fred");
+ } catch (Exception ex) {
+ return;
+ }
+
+ fail("expecting exception");
+ }
+
+ @Test
+ public void testGetGreetingsComplex() throws Exception {
+ Foo f = new Foo();
+ Bar b1 = new Bar();
+ b1.setS("petra");
+ b1.setX(1);
+ b1.setY(new Integer(2));
+ b1.setB(Boolean.TRUE);
+ Bar b2 = new Bar();
+ b2.setS("beate");
+ b2.setX(3);
+ b2.setY(new Integer(4));
+ b2.setB(Boolean.FALSE);
+ f.getBars().add(b1);
+ f.getBars().add(b2);
+
+ Foo f2 = externalClient.getGreetingsComplex(f);
+
+ assertEquals("petra", f2.getBars().get(0).getS());
+ assertEquals(1, f2.getBars().get(0).getX());
+ assertEquals(2, f2.getBars().get(0).getY().intValue());
+ assertTrue(f2.getBars().get(0).isB());
+ assertEquals("simon", f2.getBars().get(2).getS());
+ assertEquals(7, f2.getBars().get(2).getX());
+ assertEquals(8, f2.getBars().get(2).getY().intValue());
+ assertTrue(f2.getBars().get(2).isB().booleanValue());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/pom.xml b/sandbox/sebastien/java/embed/itest/ws/pom.xml
new file mode 100644
index 0000000000..526bbe76ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/pom.xml
@@ -0,0 +1,61 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-ws</artifactId>
+ <name>Apache Tuscany SCA iTest WS</name>
+
+ <modules>
+ <module>defaults</module>
+ <module>authentication-basic</module>
+ <module>http-ssl</module>
+ <module>wsdl</module>
+ <module>endpoints</module>
+ <module>endpoint-references</module>
+<!--
+ <module>jms</module>
+ <module>mtom</module>
+ <module>authentication-wssecurity</module>
+ <module>autherization-wssecurity</module>
+ <module>confidentiality-wssecurity</module>
+-->
+ <!-- separate test contributions from launcher -->
+ <module>contribution-java-first</module>
+ <module>contribution-wsdl-first</module>
+ <module>contribution-callback</module>
+ <module>contribution-callback-forwardspec</module>
+ <module>contribution-callback-fullspec</module>
+ <module>contribution-callback-promotion</module>
+ <module>contribution-doc-lit</module>
+ <module>contribution-doc-lit-wrapped</module>
+ <module>contribution-rpc-lit</module>
+ <module>external-client</module>
+ <module>external-service</module>
+ <module>launcher-axis2</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/pom.xml b/sandbox/sebastien/java/embed/itest/ws/wsdl/pom.xml
new file mode 100644
index 0000000000..cac59f85b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/pom.xml
@@ -0,0 +1,47 @@
+<?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-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-ws-wsdl</artifactId>
+ <name>Apache Tuscany SCA iTest WS WSDL</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Account.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Account.java
new file mode 100644
index 0000000000..963712c0c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Account.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Account {
+
+ CustomerProfileData getCustomerProfile(String loginID);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AccountService.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AccountService.java
new file mode 100644
index 0000000000..ab5fc0f873
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AccountService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class AccountService implements Account {
+
+ public CustomerProfileData getCustomerProfile(String loginID) {
+ return new CustomerProfileData(loginID);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/CustomerProfileData.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/CustomerProfileData.java
new file mode 100644
index 0000000000..6f6a374450
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/CustomerProfileData.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.sca.binding.ws.axis2;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class CustomerProfileData {
+
+ private String firstName;
+ private String lastName;
+ private String address;
+ private String email;
+ private String loginID;
+ private String password;
+ private int id;
+
+ public CustomerProfileData() {
+ firstName = "John";
+ lastName = "Doe";
+ address = "345 Main Street";
+ email = "john@doe.org";
+ this.loginID = "DefaultloginID";
+ password = "hello";
+ id = 1234;
+ }
+
+ public CustomerProfileData(String loginID) {
+ firstName = "John";
+ lastName = "Doe";
+ address = "345 Main Street";
+ email = "john@doe.org";
+ this.loginID = loginID;
+ password = "hello";
+ id = 1234;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getLoginID() {
+ return loginID;
+ }
+
+ public void setLoginID(String loginID) {
+ this.loginID = loginID;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java
new file mode 100644
index 0000000000..d6db1c2d0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM.java
new file mode 100644
index 0000000000..e248815805
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOM.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.ws.axis2;
+
+import org.apache.axiom.om.OMElement;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldOM {
+
+ OMElement getGreetings(OMElement parmE);
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMComponent.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMComponent.java
new file mode 100644
index 0000000000..8439696fa8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMComponent.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+import org.apache.axiom.om.OMElement;
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldOMComponent implements HelloWorldOM {
+
+ @Reference
+ public HelloWorldOM helloWorldWS;
+
+ public OMElement getGreetings(OMElement om) {
+ return helloWorldWS.getGreetings(om);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMService.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMService.java
new file mode 100644
index 0000000000..5b8578c816
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldOMService.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.binding.ws.axis2;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+
+public class HelloWorldOMService implements HelloWorldOM {
+
+ public OMElement getGreetings(OMElement requestOM) {
+ System.out.println(" **** getGreetings **** ");
+ String name = requestOM.getFirstElement().getText();
+
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ OMElement responseOM = omFactory.createOMElement("getGreetingsResponse", "http://helloworld-om", "helloworld");
+ OMElement param = omFactory.createOMElement("getGreetingsReturn", "http://helloworld-om", "helloworld");
+ responseOM.addChild(param);
+ param.addChild(omFactory.createOMText("Hello " + name));
+
+ return responseOM;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.java
new file mode 100644
index 0000000000..052b49ff55
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldService.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 org.apache.tuscany.sca.binding.ws.axis2;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/package-info.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/package-info.java
new file mode 100644
index 0000000000..805a515382
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://accounts")
+package org.apache.tuscany.sca.binding.ws.axis2;
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerdata.xsd b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerdata.xsd
new file mode 100644
index 0000000000..2479f3dbe5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerdata.xsd
@@ -0,0 +1,36 @@
+<?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.
+-->
+<xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <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:schema>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerdefs.xsd b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerdefs.xsd
new file mode 100644
index 0000000000..24cf3eebad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerdefs.xsd
@@ -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.
+-->
+<xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:include schemaLocation="customerdata.xsd" />
+ <xsd:include schemaLocation="/org/apache/tuscany/sca/binding/ws/axis2/customerinfo.xsd" />
+
+</xsd:schema>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerinfo.xsd b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerinfo.xsd
new file mode 100644
index 0000000000..b78909142f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/customerinfo.xsd
@@ -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.
+-->
+<xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="CustomerProfileInfo">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string" />
+ <xsd:element name="lastName" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.composite b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.composite
new file mode 100644
index 0000000000..c520d2e3b2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="HelloWorldOM-Merged">
+
+
+ <component name="HelloWorldMergedService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMService"/>
+ <service name="HelloWorldOM">
+ <interface.wsdl interface="http://helloworld-om-merged#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </service>
+ </component>
+
+ <component name="HelloWorldWSDLMergedComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om-merged#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld" />
+ </reference>
+ </component>
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.wsdl b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.wsdl
new file mode 100644
index 0000000000..29be66fb71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.wsdl
@@ -0,0 +1,59 @@
+<?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-om-merged" xmlns:tns="http://helloworld-om-merged" 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-om-porttype">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld-om-merged" 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:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl
new file mode 100644
index 0000000000..1a2272d7ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld.wsdl
@@ -0,0 +1,86 @@
+<?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:8085/services/HelloWorldWebService"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import-nested.wsdl b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import-nested.wsdl
new file mode 100644
index 0000000000..686b08a1d4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import-nested.wsdl
@@ -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.
+-->
+<wsdl:definitions targetNamespace="http://account3"
+ xmlns:tns="http://account3"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="questionmark-import-nested">
+
+ <wsdl:types>
+ <xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://account3"
+ xmlns:account="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:import namespace="http://accounts" schemaLocation="customerdefs.xsd" />
+
+ <xsd:element name="getCustomerProfile">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="loginID" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getCustomerProfileResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getCustomerProfileRequest">
+ <wsdl:part element="tns:getCustomerProfile" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="getCustomerProfileResponse">
+ <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Account">
+ <wsdl:operation name="getCustomerProfile">
+ <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" />
+ <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import.wsdl b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import.wsdl
new file mode 100644
index 0000000000..105c82a411
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import.wsdl
@@ -0,0 +1,49 @@
+<?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://account2"
+ xmlns:tns="http://account2"
+ xmlns:account3="http://account3"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="questionmark-import">
+
+ <wsdl:import namespace="http://account3" location="/org/apache/tuscany/sca/binding/ws/axis2/questionmark-import-nested.wsdl" />
+
+ <wsdl:binding name="AccountSoapBinding" type="account3:Account">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getCustomerProfile">
+ <wsdlsoap:operation soapAction="" />
+ <wsdl:input name="getCustomerProfileRequest">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output name="getCustomerProfileResponse">
+ <wsdlsoap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort">
+ <wsdlsoap:address location="http://localhost:8086/AccountService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-include.wsdl b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-include.wsdl
new file mode 100644
index 0000000000..7a7a4033ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-include.wsdl
@@ -0,0 +1,90 @@
+<?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://accounts"
+ xmlns:tns="http://accounts"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="questionmark-include">
+
+ <wsdl:types>
+ <xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:account="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:include schemaLocation="/org/apache/tuscany/sca/binding/ws/axis2/customerdata.xsd" />
+
+ <xsd:element name="getCustomerProfile">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="loginID" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getCustomerProfileResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:customerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getCustomerProfileRequest">
+ <wsdl:part element="tns:getCustomerProfile" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="getCustomerProfileResponse">
+ <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Account">
+ <wsdl:operation name="getCustomerProfile">
+ <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" />
+ <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="AccountSoapBinding" type="tns:Account">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getCustomerProfile">
+ <wsdlsoap:operation soapAction="" />
+ <wsdl:input name="getCustomerProfileRequest">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output name="getCustomerProfileResponse">
+ <wsdlsoap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort">
+ <wsdlsoap:address location="http://localhost:8085/AccountService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-import.composite b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-import.composite
new file mode 100644
index 0000000000..65270b8d6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-import.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="QuestionMarkWSDLImport">
+
+ <component name="AccountService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.AccountService" />
+ <service name="Account">
+ <binding.ws uri="http://localhost:8086/AccountService" wsdlElement="http://account2#wsdl.binding(AccountSoapBinding)" />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-include.composite b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-include.composite
new file mode 100644
index 0000000000..02395c4615
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-include.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="QuestionMarkWSDLInclude">
+
+ <component name="AccountService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.AccountService" />
+ <service name="Account">
+ <binding.ws uri="http://localhost:8085/AccountService" wsdlElement="http://accounts#wsdl.binding(AccountSoapBinding)" />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl.composite b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl.composite
new file mode 100644
index 0000000000..6b06cec722
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="QuestionMarkWSDLTests">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.HelloWorldService"/>
+ <service name="HelloWorld">
+ <binding.ws name="ep1" uri="http://localhost:8085/foo/bar" />
+ <binding.ws name="ep2" uri="http://localhost:8085/services/HelloWorldWebService2" wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldWSDLMergedTestCase.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldWSDLMergedTestCase.java
new file mode 100644
index 0000000000..b79ee7d254
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldWSDLMergedTestCase.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class HelloWorldWSDLMergedTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorldOM helloWorld;
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = "target/classes";
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/helloworld-om-merged.composite", new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldWSDLMergedComponent");
+ }
+
+ public void testHelloWorld() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-om", "helloworld");
+ OMElement parmE = fac.createOMElement("name", "http://helloworld-om", "helloworld");
+ requestOM.addChild(parmE);
+ parmE.addChild(fac.createOMText("petra"));
+ OMElement responseOM = helloWorld.getGreetings(requestOM);
+ OMElement child = (OMElement)responseOM.getFirstElement();
+ Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLImportTestCase.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLImportTestCase.java
new file mode 100644
index 0000000000..76ea53681f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLImportTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class QuestionMarkWSDLImportTestCase extends TestCase {
+
+ private Node node;
+
+ /**
+ * Tests ?wsdl works and returns the correct port endpoint from the WSDL
+ */
+ public void testWSDLImportPortEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8086/AccountService?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose", false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments", true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8086/AccountService?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName("http://account2/AccountService/Account", "AccountService"));
+ Port port = service.getPort("AccountPort");
+
+ String endpoint = getEndpoint(port);
+ // String ip = HttpUtils.getIpAddress();
+ assertEquals("http://localhost:8086/AccountService", endpoint);
+ }
+
+ private String getEndpoint(Port port) {
+ List wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = "target/classes";
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-import.composite", new Contribution("test", contribution));
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLIncludeTestCase.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLIncludeTestCase.java
new file mode 100644
index 0000000000..54a40afc63
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLIncludeTestCase.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class QuestionMarkWSDLIncludeTestCase extends TestCase {
+
+ private Node node;
+
+ /**
+ * Tests ?wsdl works and returns the correct port endpoint from the WSDL
+ */
+ public void testWSDLIncludePortEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/AccountService?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose", false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments", true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/AccountService?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName("http://accounts/AccountService/Account", "AccountService"));
+ Port port = service.getPort("AccountPort");
+
+ String endpoint = getEndpoint(port);
+ assertEquals("http://localhost:8085/AccountService", endpoint);
+ }
+
+ private String getEndpoint(Port port) {
+ List wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = "target/classes";
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl-include.composite", new Contribution("test", contribution));
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java
new file mode 100644
index 0000000000..0148460b5c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/itest/ws/wsdl/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/QuestionMarkWSDLTestCase.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class QuestionMarkWSDLTestCase extends TestCase {
+
+ private Node node;
+
+ /**
+ * Tests ?wsdl works and returns the correct port endpoint from the WSDL
+ */
+ public void testWSDLPortEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/services/HelloWorldWebService2?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/services/HelloWorldWebService2?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName("http://helloworld/HelloWorldService/HelloWorld",
+ "HelloWorldService"));
+ Port port = service.getPort("HelloWorldPort");
+
+ String endpoint = getEndpoint(port);
+ assertEquals("http://localhost:8085/services/HelloWorldWebService2", endpoint);
+ }
+
+ /**
+ * Tests ?wsdl works and returns the correct port endpoint from binding.ws with a custom URI
+ */
+ public void testCustomEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/foo/bar?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/foo/bar?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName("http://axis2.ws.binding.sca.tuscany.apache.org/",
+ "HelloWorldService"));
+ Port port = service.getPort("HelloWorldPort");
+
+ String endpoint = getEndpoint(port);
+ // TODO - used to get the real host here but WSDL seems to have localhost in it atm?
+ assertEquals("http://localhost:8085/foo/bar", endpoint);
+ }
+
+ protected String getEndpoint(Port port) {
+ List wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = "target/classes";
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/questionmark-wsdl.composite", new Contribution("test", contribution));
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/LICENSE b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/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/sebastien/java/embed/maven/maven-tuscany-plugin/NOTICE b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/README b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/README
new file mode 100644
index 0000000000..8754eeae6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/README
@@ -0,0 +1,21 @@
+This module is a Maven plugin for starting a Tuscany runtime which runs the project as an SCA contribution.
+
+To configure the project add the following to the SCA contribution's pom.xml:
+
+ <build>
+ ...
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ </plugin>
+ ...
+ </plugins>
+ </build>
+
+To run the contribution in Tuscany use "mvn tuscany:run"
+
+Optional parameters are:
+ config - uri string to configure the Tuscany runtime
+ contributions - additional SCA contributions to install along with the project contribution
+
diff --git a/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/pom.xml b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/pom.xml
new file mode 100644
index 0000000000..7096a30aa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/pom.xml
@@ -0,0 +1,60 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <relativePath>../../pom.xml</relativePath>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Apache Tuscany Maven Tuscany Plugin</name>
+ <version>2.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyLaunchMojo.java b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyLaunchMojo.java
new file mode 100644
index 0000000000..55b0a51b7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyLaunchMojo.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.maven.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.tuscany.sca.domain.node.DomainNode;
+
+/**
+ * Maven Mojo to launch a Tuscany runtime
+ * Invoked with mvn org.apache.tuscany.maven.plugin:maven-tuscany-plugin:launch [-Ddomain=tribes:myDomain] -Dcontributions=path\to\scacontribution
+ *
+ * @goal launch
+ * @requiresProject false
+ * @requiresDependencyResolution runtime
+ */
+public class TuscanyLaunchMojo extends AbstractMojo {
+
+ /**
+ * @parameter expression="${domain}" default-value="vm:default"
+ */
+ private String domain;
+
+ /**
+ * @parameter expression="${contributions}"
+ */
+ private String contributions;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ if (contributions == null) {
+ getLog().info("Missing contributions parameter");
+ getLog().info(" use -Dcontributions=<pathToSCAContribution,pathToAnotherContribution...>");
+ return;
+ }
+
+ getLog().info("Launching Tuscany Runtime...");
+
+ List<String> cs = new ArrayList<String>();
+ StringTokenizer st = new StringTokenizer(contributions, ",");
+ while (st.hasMoreTokens()) {
+ cs.add(st.nextToken());
+ }
+
+ DomainNode domainNode = new DomainNode(domain, cs.toArray(new String[cs.size()]));
+
+ waitForShutdown(domainNode, getLog());
+
+ }
+
+ protected void waitForShutdown(DomainNode domainNode, Log log) {
+ Runtime.getRuntime().addShutdownHook(new ShutdownThread(domainNode, log));
+ synchronized (this) {
+ try {
+ log.info("Ctrl-C to end...");
+ this.wait();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ }
+ }
+
+ protected static class ShutdownThread extends Thread {
+
+ private DomainNode domainNode;
+ private Log log;
+
+ public ShutdownThread(DomainNode domainNode, Log log) {
+ super();
+ this.domainNode = domainNode;
+ this.log = log;
+ }
+
+ @Override
+ public void run() {
+ try {
+
+ log.info("Stopping Tuscany Runtime...");
+ domainNode.stop();
+
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java
new file mode 100644
index 0000000000..edb7e0f0de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.maven.plugin;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * Maven Mojo to run the SCA contribution project in Tuscany.
+ * Invoked with "mvn tuscany:run"
+ *
+ * @goal run
+ * @requiresDependencyResolution runtime
+ * @execute phase="package"
+ * @description Runs Tuscany directly from a SCA conribution maven project
+ */
+public class TuscanyRunMojo extends AbstractMojo {
+
+ /**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+ /**
+ * The project artifactId.
+ *
+ * @parameter expression="${project.artifactId}"
+ * @required
+ */
+ protected String artifactId;
+
+ /**
+ * The project packaging.
+ *
+ * @parameter expression=".${project.packaging}"
+ * @required
+ */
+ protected String packaging;
+
+ /**
+ * The project build output directory
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ */
+ protected File buildDirectory;
+
+ /**
+ * The project build output directory
+ *
+ * @parameter expression="${project.build.finalName}"
+ * @required
+ */
+ protected File finalName;
+
+ /**
+ * @parameter expression="${config}" default-value="uri:default"
+ */
+ private String config;
+ /**
+ * @parameter expression="${contributions}"
+ */
+ private String[] contributions;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().info("Starting Tuscany Runtime...");
+
+ List<String> contributionList = new ArrayList<String>();
+
+ addProjectContribution(contributionList);
+
+ addAdditionalContributions(contributionList);
+
+ Node node = NodeFactory.newInstance(config).createNode((String)null, contributionList.toArray(new String[contributionList.size()])).start();
+
+ waitForShutdown(node, getLog());
+ }
+
+ private void addAdditionalContributions(List<String> contributionList) throws MojoExecutionException {
+ if (contributions != null) {
+ for (String s : contributions) {
+ if (new File(s).exists()) {
+ contributionList.add(s);
+ } else {
+ boolean found = false;
+ for (Object o : project.getDependencyArtifacts()) {
+ Artifact a = (Artifact) o;
+ if (a.getId().startsWith(s)) {
+ try {
+ contributionList.add(a.getFile().toURI().toURL().toString());
+ } catch (MalformedURLException e) {
+ throw new MojoExecutionException("", e);
+ }
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw new IllegalArgumentException("Contribution not found as file or dependency: " + s);
+ }
+ }
+ }
+ }
+ }
+
+ protected void addProjectContribution(List<String> cs) throws MojoExecutionException {
+ try {
+
+ File contributionFile = new File(buildDirectory.getParent(), finalName.getName());
+ if (!contributionFile.exists()) {
+ contributionFile = new File(buildDirectory.getParent(), finalName.getName() + packaging);
+ }
+ String contribution = contributionFile.toURI().toURL().toString();
+ getLog().info("Project contribution: " + contribution);
+ cs.add(contribution);
+
+ } catch (MalformedURLException e) {
+ throw new MojoExecutionException("", e);
+ }
+ }
+
+ protected void waitForShutdown(Node node, Log log) {
+ Runtime.getRuntime().addShutdownHook(new ShutdownThread(node, log));
+ synchronized (this) {
+ try {
+ log.info("Ctrl-C to end...");
+ this.wait();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ }
+ }
+
+ protected static class ShutdownThread extends Thread {
+
+ private Node node;
+ private Log log;
+
+ public ShutdownThread(Node node, Log log) {
+ super();
+ this.node = node;
+ this.log = log;
+ }
+
+ @Override
+ public void run() {
+ try {
+
+ log.info("Stopping Tuscany Runtime...");
+ node.stop();
+
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/LICENSE b/sandbox/sebastien/java/embed/modules/assembly-xml/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/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/sebastien/java/embed/modules/assembly-xml/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/assembly-xml/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..d1ff0fb160
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/META-INF/MANIFEST.MF
@@ -0,0 +1,71 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.assembly.xml;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ javax.xml.parsers,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.contribution,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef,
+ org.w3c.dom,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.definitions,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.policy.xml;version="2.0.0";
+ uses:="javax.xml.xpath,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA XML Assembly Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA XML Assembly Model
+Import-Package: javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream;version="1.0.0",
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
+ javax.xml.validation;resolution:=optional,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.xpath;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.java;version="2.0.0",
+ org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.w3c.dom,
+ org.xml.sax;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly.xml
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/NOTICE b/sandbox/sebastien/java/embed/modules/assembly-xml/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/pom.xml b/sandbox/sebastien/java/embed/modules/assembly-xml/pom.xml
new file mode 100644
index 0000000000..5df6a570ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <name>Apache Tuscany SCA Assembly XML Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ </dependency>
+ -->
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
new file mode 100644
index 0000000000..091b3c01d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
@@ -0,0 +1,713 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+import static javax.xml.stream.XMLStreamConstants.CDATA;
+import static javax.xml.stream.XMLStreamConstants.CHARACTERS;
+import static javax.xml.stream.XMLStreamConstants.COMMENT;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MULTIPLICITY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ONE_N;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ONE_ONE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SCA11_NS;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TARGET;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.VALUE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.VALUE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ZERO_N;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ZERO_ONE;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A base class with utility methods for the other artifact processors in this module.
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
+
+ protected AssemblyFactory assemblyFactory;
+ protected PolicyFactory policyFactory;
+ protected StAXArtifactProcessor<Object> extensionProcessor;
+ protected PolicySubjectProcessor policyProcessor;
+ private DocumentBuilderFactory documentBuilderFactory;
+
+
+ /**
+ * Constructs a new BaseArtifactProcessor.
+ * @param assemblyFactory
+ * @param policyFactory
+ */
+ @SuppressWarnings("unchecked")
+ protected BaseAssemblyProcessor(AssemblyFactory assemblyFactory,
+ PolicyFactory policyFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ StAXArtifactProcessor extensionProcessor) {
+ this.assemblyFactory = assemblyFactory;
+ this.policyFactory = policyFactory;
+ this.documentBuilderFactory = documentBuilderFactory;
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ /**
+ * @param modelFactories
+ * @param staxProcessor
+ * @param monitor
+ */
+ protected BaseAssemblyProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ /**
+ * Marshals warnings into the monitor
+ *
+ * @param message
+ * @param model
+ * @param messageParameters
+ */
+ protected void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals errors into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals exceptions into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Start an element.
+ * @param writer
+ * @param name
+ * @param attrs
+ * @throws XMLStreamException
+ */
+ protected void writeStart(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
+ super.writeStart(writer, SCA11_NS, name, attrs);
+ }
+
+ /**
+ * Start a document.
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
+ super.writeStartDocument(writer, SCA11_NS, name, attrs);
+ }
+
+ /**
+ * Read list of reference targets
+ * @param reference
+ * @param reader
+ */
+ protected void readTargets(Reference reference, XMLStreamReader reader) {
+ String value = getString(reader, TARGET);
+ ComponentService target = null;
+ if (value != null) {
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ target = assemblyFactory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(tokens.nextToken());
+ reference.getTargets().add(target);
+ }
+ }
+ }
+
+ /**
+ * Write a list of targets into an attribute
+ * @param reference
+ * @return
+ */
+ protected XAttr writeTargets(Reference reference) {
+ List<String> targets = new ArrayList<String>();
+ for (Service target : reference.getTargets()) {
+ targets.add(target.getName());
+ }
+ return new XAttr(TARGET, targets);
+ }
+
+ /**
+ * Read a multiplicity attribute.
+ * @param reference
+ * @param reader
+ */
+ protected void readMultiplicity(AbstractReference reference, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, MULTIPLICITY);
+ if (ZERO_ONE.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ZERO_ONE);
+ } else if (ONE_N.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ONE_N);
+ } else if (ZERO_N.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ZERO_N);
+ } else if (ONE_ONE.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ONE_ONE);
+ }
+ }
+
+ protected XAttr writeMultiplicity(AbstractReference reference) {
+ Multiplicity multiplicity = reference.getMultiplicity();
+ if (multiplicity != null) {
+ String value = null;
+ if (Multiplicity.ZERO_ONE.equals(multiplicity)) {
+ value = ZERO_ONE;
+ } else if (Multiplicity.ONE_N.equals(multiplicity)) {
+ value = ONE_N;
+ } else if (Multiplicity.ZERO_N.equals(multiplicity)) {
+ value = ZERO_N;
+ } else if (Multiplicity.ONE_ONE.equals(multiplicity)) {
+ value = ONE_ONE;
+ return null;
+ }
+ return new XAttr(MULTIPLICITY, value);
+ }
+ return null;
+ }
+
+
+ /**
+ * Reads an abstract property element.
+ * @param property
+ * @param reader
+ * @param context TODO
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ */
+ protected void readAbstractProperty(AbstractProperty property, XMLStreamReader reader, ProcessorContext context) throws XMLStreamException,
+ ContributionReadException {
+
+ property.setName(getString(reader, NAME));
+ property.setMany(getBoolean(reader, MANY));
+ property.setMustSupply(getBoolean(reader, MUST_SUPPLY));
+ property.setXSDElement(getQName(reader, ELEMENT));
+ property.setXSDType(getQName(reader, TYPE));
+ // MJE added 14/05/2009 - check for both @element and @type being present - disallowed by OASIS Assembly spec
+ if( property.getXSDElement() != null && property.getXSDType() != null ) {
+ ContributionReadException ce = new ContributionReadException("[ASM40010,ASM60040] Error: property has both @type and @element attribute values - " +
+ property.getName());
+ error(context.getMonitor(), "ContributionReadException", property, ce);
+ } // end if
+
+ }
+
+ /**
+ * Resolve an implementation.
+ * @param implementation
+ * @param resolver
+ * @param context
+ * @return
+ * @throws ContributionResolveException
+ */
+ protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (implementation != null) {
+ if (implementation.isUnresolved()) {
+ implementation = resolver.resolveModel(Implementation.class, implementation, context);
+
+ // Lazily resolve implementations
+ if (implementation.isUnresolved()) {
+ extensionProcessor.resolve(implementation, resolver, context);
+ if (!implementation.isUnresolved()) {
+ resolver.addModel(implementation, context);
+ }
+ }
+ }
+ }
+ return implementation;
+ }
+
+ /**
+ * Resolve interface, callback interface and bindings on a list of contracts.
+ * @param contracts the list of contracts
+ * @param resolver the resolver to use to resolve models
+ * @param context TODO
+ */
+ protected <C extends Contract> void resolveContracts(List<C> contracts, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ resolveContracts(null, contracts, resolver, context);
+ }
+
+ /**
+ * Resolve interface, callback interface and bindings on a list of contracts.
+ * @param parent element for the contracts
+ * @param contracts the list of contracts
+ * @param resolver the resolver to use to resolve models
+ * @param context TODO
+ */
+ protected <C extends Contract> void resolveContracts(Base parent, List<C> contracts, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+
+ String parentName =
+ (parent instanceof Composite) ? ((Composite)parent).getName().toString() : (parent instanceof Component)
+ ? ((Component)parent).getName() : "UNKNOWN";
+
+ for (Contract contract : contracts) {
+ // Resolve the interface contract
+ InterfaceContract interfaceContract = contract.getInterfaceContract();
+ if (interfaceContract != null) {
+ extensionProcessor.resolve(interfaceContract, resolver, context);
+ }
+
+ // Resolve bindings
+ for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
+ Binding binding = contract.getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver, context);
+
+ }
+
+ // Resolve callback bindings
+ if (contract.getCallback() != null) {
+
+ for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
+ Binding binding = contract.getCallback().getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver, context);
+ }
+ }
+ }
+ }
+
+ /**
+ * Resolve interface and callback interface on a list of abstract contracts.
+ * @param contracts the list of contracts
+ * @param resolver the resolver to use to resolve models
+ * @param context TODO
+ */
+ protected <C extends AbstractContract> void resolveAbstractContracts(List<C> contracts, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ for (AbstractContract contract : contracts) {
+
+ // Resolve the interface contract
+ InterfaceContract interfaceContract = contract.getInterfaceContract();
+ if (interfaceContract != null) {
+ extensionProcessor.resolve(interfaceContract, resolver, context);
+ }
+ }
+ }
+
+ /**
+ * Read a property value into a DOM document.
+ * @param element
+ * @param type
+ * @param reader
+ * @param context
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ParserConfigurationException
+ */
+ protected Document readPropertyValue(QName element, QName type, boolean isMany, XMLStreamReader reader, ProcessorContext context) throws XMLStreamException,
+ ContributionReadException {
+ Document document;
+ try {
+ if (documentBuilderFactory == null) {
+ documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ }
+ document = documentBuilderFactory.newDocumentBuilder().newDocument();
+ } catch (ParserConfigurationException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(context.getMonitor(), "ContributionReadException", documentBuilderFactory, ce);
+ throw ce;
+ }
+
+ // Collect the property values as <value> elements under the <property>
+ Element root = document.createElementNS(SCA11_NS, "sca:" + PROPERTY);
+ String nameAttr = getString(reader, NAME);
+ if (nameAttr != null) {
+ root.setAttributeNS(SCA11_NS, "sca:" + NAME, nameAttr);
+ }
+ declareNamespace(root, "sca", SCA11_NS);
+ if (type != null) {
+ org.w3c.dom.Attr xsi = document.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
+ xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ root.setAttributeNodeNS(xsi);
+
+ String prefix = type.getPrefix();
+ if (prefix == null || prefix.length() == 0) {
+ prefix = "ns";
+ }
+
+ declareNamespace(root, prefix, type.getNamespaceURI());
+
+ org.w3c.dom.Attr xsiType = document.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
+ xsiType.setValue(prefix + ":" + type.getLocalPart());
+ root.setAttributeNodeNS(xsiType);
+ }
+ document.appendChild(root);
+
+ // Start to parse the property
+ QName name = reader.getName(); // Should be sca:property
+
+ // SCA 1.1 supports the @value for simple types
+ String valueAttr = getString(reader, VALUE);
+ if (valueAttr != null) {
+ Element valueElement = document.createElementNS(SCA11_NS, VALUE);
+ root.appendChild(valueElement);
+ valueElement.setTextContent(valueAttr);
+ }
+
+ boolean gotOneValue = false;
+ boolean isTextForProperty = true;
+ StringBuffer text = new StringBuffer();
+
+ int event = reader.getEventType();
+ while (true) {
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+ if (PROPERTY_QNAME.equals(name)) {
+ isTextForProperty = true;
+ break;
+ }
+ isTextForProperty = false;
+
+ // CONFORMANCE: ASM50033
+ // A property <value/> subelement MUST NOT be used when the @value attribute is used
+ // to specify the value for that property.
+ if (valueAttr != null) {
+ error(context.getMonitor(), "ASM50033: value attribute exists for the property element", name, name);
+ }
+ // Read <value>
+ if (VALUE_QNAME.equals(name)) {
+ if (gotOneValue && !isMany) {
+ // TODO: TUSCANY-3231 this should be error not warning but that breaks OASIS tests
+ // [rfeng] We should not issue warning here as the component property many inherit @many from the componentType property
+ // warning(context.getMonitor(), "ASM50032: multiple value elements for single-valued property", name, name);
+ }
+ loadElement(reader, root);
+ gotOneValue = true;
+ } else {
+ // Global elements
+ loadElement(reader, root);
+ }
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ case XMLStreamConstants.CDATA:
+ if (isTextForProperty) {
+ text.append(reader.getText());
+ }
+ break;
+ case END_ELEMENT:
+ name = reader.getName();
+ if (PROPERTY_QNAME.equals(name)) {
+
+ if (root.getChildNodes().getLength() == 0) {
+ // Add an text as an <value>
+ if (isTextForProperty){
+ if (text.length() > 0) {
+ Element valueElement = document.createElementNS(SCA11_NS, VALUE);
+ root.appendChild(valueElement);
+ valueElement.setTextContent(text.toString());
+ }
+ }
+ }
+ return document;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ break;
+ }
+ }
+ return document;
+ }
+
+ /**
+ * Create a DOM element
+ * @param document
+ * @param name
+ * @return
+ */
+ private Element createElement(Document document, QName name) {
+ String prefix = name.getPrefix();
+ String qname =
+ (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name.getLocalPart();
+ return document.createElementNS(name.getNamespaceURI(), qname);
+ }
+
+ /**
+ * Declare a namespace.
+ * @param element
+ * @param prefix
+ * @param ns
+ */
+ private void declareNamespace(Element element, String prefix, String ns) {
+ if (ns == null) {
+ ns = "";
+ }
+ if (prefix == null) {
+ prefix = "";
+ }
+ String qname = null;
+ if ("".equals(prefix)) {
+ qname = "xmlns";
+ } else {
+ qname = "xmlns:" + prefix;
+ }
+ Node node = element;
+ boolean declared = false;
+ while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+ NamedNodeMap attrs = node.getAttributes();
+ if (attrs == null) {
+ break;
+ }
+ Node attr = attrs.getNamedItem(qname);
+ if (attr != null) {
+ declared = ns.equals(attr.getNodeValue());
+ break;
+ }
+ node = node.getParentNode();
+ }
+ if (!declared) {
+ org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname);
+ attr.setValue(ns);
+ element.setAttributeNodeNS(attr);
+ }
+ }
+
+ /**
+ * Load a property value specification from an StAX stream into a DOM
+ * Document. Only elements, text and attributes are processed; all comments
+ * and other whitespace are ignored.
+ *
+ * @param reader the stream to read from
+ * @param root the DOM node to load
+ * @throws javax.xml.stream.XMLStreamException
+ */
+ private void loadElement(XMLStreamReader reader, Element root) throws XMLStreamException {
+ Document document = root.getOwnerDocument();
+ Node current = root;
+ while (true) {
+ switch (reader.getEventType()) {
+ case START_ELEMENT:
+ QName name = reader.getName();
+ Element child = createElement(document, name);
+
+ // push the new element and make it the current one
+ current.appendChild(child);
+ current = child;
+
+ int count = reader.getNamespaceCount();
+ for (int i = 0; i < count; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ declareNamespace(child, prefix, ns);
+ }
+
+ if (!"".equals(name.getNamespaceURI())) {
+ declareNamespace(child, name.getPrefix(), name.getNamespaceURI());
+ }
+
+ // add the attributes for this element
+ count = reader.getAttributeCount();
+ for (int i = 0; i < count; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+ if (prefix != null && prefix.length() != 0) {
+ qname = prefix + ":" + qname;
+ }
+ child.setAttributeNS(ns, qname, value);
+ if (ns != null) {
+ declareNamespace(child, prefix, ns);
+ }
+ }
+
+ break;
+ case CDATA:
+ current.appendChild(document.createCDATASection(reader.getText()));
+ break;
+ case CHARACTERS:
+ current.appendChild(document.createTextNode(reader.getText()));
+ break;
+ case COMMENT:
+ current.appendChild(document.createComment(reader.getText()));
+ break;
+ case END_ELEMENT:
+ // pop the element off the stack
+ current = current.getParentNode();
+ // if we are back at the root then we are done
+ if (current == root) {
+ return;
+ }
+
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ return;
+ }
+ }
+ }
+
+ /**
+ *
+ * @param reader
+ * @param elementName
+ * @param extensionAttributeProcessor
+ * @param context TODO
+ * @param estensibleElement
+ * @throws ContributionReadException
+ * @throws XMLStreamException
+ */
+ protected void readExtendedAttributes(XMLStreamReader reader,
+ QName elementName,
+ Extensible extensible,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ ProcessorContext context) throws ContributionReadException,
+ XMLStreamException {
+ super.readExtendedAttributes(reader, extensible, extensionAttributeProcessor, assemblyFactory, context);
+ }
+
+
+ /*protected void validatePolicySets(PolicySubject policySetAttachPoint)
+ throws ContributionResolveException {
+ validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets());
+ }
+
+
+ protected void validatePolicySets(PolicySubject policySetAttachPoint,
+ List<PolicySet> applicablePolicySets) throws ContributionResolveException {
+ //Since the applicablePolicySets in a policySetAttachPoint will already have the
+ //list of policysets that might ever be applicable to this attachPoint, just check
+ //if the defined policysets feature in the list of applicable policysets
+ ExtensionType attachPointType = policySetAttachPoint.getType();
+ for ( PolicySet definedPolicySet : policySetAttachPoint.getPolicySets() ) {
+ if ( !definedPolicySet.isUnresolved() ) {
+ if ( !applicablePolicySets.contains(definedPolicySet)) {
+ throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+ + "' does not apply to binding type "
+ + attachPointType.getName());
+ }
+ } else {
+ throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+ + "' is not defined in this domain ");
+
+
+ }
+ }
+ }*/
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
new file mode 100644
index 0000000000..b5fe005812
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A componentType processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<ComponentType> {
+ private ValidatingXMLInputFactory inputFactory;
+
+ /**
+ * Constructs a new componentType processor.
+ * @param modelFactories
+ * @param staxProcessor
+ */
+ public ComponentTypeDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor) {
+ super(modelFactories, staxProcessor);
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ }
+
+ public ComponentType read(URL contributionURL, URI uri, URL url, ProcessorContext context) throws ContributionReadException {
+ InputStream urlStream = null;
+ Monitor monitor = context.getMonitor();
+ try {
+
+ // Create a stream reader
+ urlStream = IOHelper.openStream(url);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
+ ValidatingXMLInputFactory.setMonitor(reader, monitor);
+ reader.nextTag();
+
+ // Reader the componentType model
+ ComponentType componentType = (ComponentType)extensionProcessor.read(reader, context);
+ if (componentType != null) {
+ componentType.setURI(uri.toString());
+ }
+
+ // For debugging purposes, write it back to XML
+// if (componentType != null) {
+// try {
+// ByteArrayOutputStream bos = new ByteArrayOutputStream();
+// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+// extensionProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos));
+// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
+// OutputFormat format = new OutputFormat();
+// format.setIndenting(true);
+// format.setIndent(2);
+// XMLSerializer serializer = new XMLSerializer(System.out, format);
+// serializer.serialize(document);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+
+ return componentType;
+
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } finally {
+ try {
+ if (urlStream != null) {
+ urlStream.close();
+ urlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+
+ public void resolve(ComponentType componentType, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ extensionProcessor.resolve(componentType, resolver, context);
+ }
+
+ public String getArtifactType() {
+ return ".componentType";
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java
new file mode 100644
index 0000000000..9a4a0dc035
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A Model Resolver for ComponentType models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeModelResolver implements ModelResolver {
+ private Contribution contribution;
+ private Map<String, ComponentType> map = new HashMap<String, ComponentType>();
+
+ public ComponentTypeModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ ComponentType componentType = (ComponentType)resolved;
+ map.put(componentType.getURI(), componentType);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(((ComponentType)resolved).getURI());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ //get componentType artifact URI
+ String uri = ((ComponentType)unresolved).getURI();
+ if (uri == null) {
+ return (T)unresolved;
+ }
+
+ //lookup the componentType
+ ComponentType resolved = (ComponentType) map.get(uri);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ //If not found, delegate the resolution to the imports (in this case based on the java imports)
+ //compute the package name from the componentType URI
+ if (unresolved instanceof ComponentType) {
+ //FIXME The core assembly model now depends on java imports to
+ // resolve componentTypes of all kinds, this is not right at all!!!
+ int s = uri.lastIndexOf('/');
+ if (s != -1) {
+ String packageName = uri.substring(0, uri.lastIndexOf("/"));
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof JavaImport) {
+ JavaImport javaImport = (JavaImport)import_;
+ //check the import location against the computed package name from the componentType URI
+ if (javaImport.getPackage().equals(packageName)) {
+ // Delegate the resolution to the import resolver
+ resolved = javaImport.getModelResolver().resolveModel(ComponentType.class, (ComponentType)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return (T)unresolved;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
new file mode 100644
index 0000000000..8f24cc41b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
@@ -0,0 +1,471 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CALLBACK;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CALLBACK_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPONENT_TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPONENT_TYPE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.IMPLEMENTATION;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.OPERATION_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.EXTENSION;
+import static org.apache.tuscany.sca.assembly.xml.Constants.EXTENSION_QNAME;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A componentType processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<ComponentType> {
+
+ private StAXHelper staxHelper;
+
+ /**
+ * Constructs a new componentType processor.
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ * @param extensionAttributeProcessor
+ * @param monitor
+ */
+ public ComponentTypeProcessor(ExtensionPointRegistry extensionPoints,
+ //public ComponentTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+ super(modelFactories(extensionPoints), extensionProcessor);
+
+ //
+ staxHelper = StAXHelper.getInstance(extensionPoints);
+ }
+
+ public ComponentType read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ ComponentType componentType = null;
+ Service service = null;
+ Reference reference = null;
+ Contract contract = null;
+ Property property = null;
+ Callback callback = null;
+ QName name = null;
+
+ try {
+ // Read the componentType document
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+
+ if (Constants.COMPONENT_TYPE_QNAME.equals(name)) {
+
+ // Read a <componentType>
+ componentType = assemblyFactory.createComponentType();
+
+ } else if (Constants.SERVICE_QNAME.equals(name)) {
+
+ // Read a <service>
+ service = assemblyFactory.createService();
+ contract = service;
+ service.setName(getString(reader, Constants.NAME));
+ componentType.getServices().add(service);
+ policyProcessor.readPolicies(service, reader);
+
+ } else if (Constants.REFERENCE_QNAME.equals(name)) {
+
+ // Read a <reference>
+ reference = assemblyFactory.createReference();
+ contract = reference;
+ reference.setName(getString(reader, Constants.NAME));
+ reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL));
+ readMultiplicity(reference, reader);
+ readTargets(reference, reader);
+ componentType.getReferences().add(reference);
+ policyProcessor.readPolicies(reference, reader);
+
+ } else if (Constants.PROPERTY_QNAME.equals(name)) {
+
+ // Read a <property>
+ property = assemblyFactory.createProperty();
+ readAbstractProperty(property, reader, context);
+ policyProcessor.readPolicies(property, reader);
+
+ // Read the property value
+ Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), property.isMany(), reader, context);
+ property.setValue(value);
+
+ componentType.getProperties().add(property);
+
+ } else if (Constants.IMPLEMENTATION_QNAME.equals(name)) {
+
+ // Read an <implementation> element
+ policyProcessor.readPolicies(componentType, reader);
+
+ } else if (Constants.CALLBACK_QNAME.equals(name)) {
+
+ // Read a <callback>
+ callback = assemblyFactory.createCallback();
+ contract.setCallback(callback);
+ policyProcessor.readPolicies(callback, reader);
+
+ } else if (OPERATION_QNAME.equals(name)) {
+
+ // Read an <operation>
+ Operation operation = new OperationImpl();
+ operation.setName(getString(reader, NAME));
+ operation.setUnresolved(true);
+ if (callback != null) {
+ policyProcessor.readPolicies(callback, operation, reader);
+ } else {
+ policyProcessor.readPolicies(contract, operation, reader);
+ }
+ } else if(EXTENSION_QNAME.equals(name)) {
+ // Handle <extension>
+ //ignore element as this is a wrapper for extensibility
+ break;
+ } else {
+
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof InterfaceContract) {
+
+ // <service><interface> and <reference><interface>
+ contract.setInterfaceContract((InterfaceContract)extension);
+
+ } else if (extension instanceof Binding) {
+
+ // <service><binding> and <reference><binding>
+ if (callback != null) {
+ callback.getBindings().add((Binding)extension);
+ } else {
+ contract.getBindings().add((Binding)extension);
+ }
+ } else {
+
+ // Add the extension element to the current element
+ if (callback != null) {
+ callback.getExtensions().add(extension);
+ } else if (contract != null) {
+ contract.getExtensions().add(extension);
+ } else if (property != null) {
+ property.getExtensions().add(extension);
+ } else {
+ if (componentType instanceof Extensible) {
+ ((Extensible)componentType).getExtensions().add(extension);
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+
+ // Clear current state when reading reaching end element
+ if (SERVICE_QNAME.equals(name)) {
+ service = null;
+ contract = null;
+ } else if (REFERENCE_QNAME.equals(name)) {
+ reference = null;
+ contract = null;
+ } else if (PROPERTY_QNAME.equals(name)) {
+ property = null;
+ } else if (CALLBACK_QNAME.equals(name)) {
+ callback = null;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "XMLStreamException", reader, ex);
+ }
+
+ return componentType;
+ }
+
+ public void write(ComponentType componentType, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <componentType> element
+ writeStartDocument(writer, COMPONENT_TYPE);
+
+ // Write <service> elements
+ for (Service service : componentType.getServices()) {
+ writeStart(writer, SERVICE, new XAttr(NAME, service.getName()),
+ policyProcessor.writePolicies(service));
+
+ if (service.getInterfaceContract() != null) {
+ extensionProcessor.write(service.getInterfaceContract(), writer, context);
+ }
+
+ for (Binding binding: service.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ if (service.getCallback() != null) {
+ Callback callback = service.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ for (Binding binding: callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+ for (Object extension: callback.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ this.writeExtendedElements(writer, service, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (Reference reference : componentType.getReferences()) {
+
+ writeStart(writer, REFERENCE,
+ new XAttr(NAME, reference.getName()),
+ writeMultiplicity(reference),
+ writeTargets(reference),
+ policyProcessor.writePolicies(reference));
+
+ extensionProcessor.write(reference.getInterfaceContract(), writer, context);
+
+ for (Binding binding: reference.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK,
+ policyProcessor.writePolicies(callback));
+
+ for (Binding binding: callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+ for (Object extension: callback.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ this.writeExtendedElements(writer, reference, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <property> elements
+ for (Property property : componentType.getProperties()) {
+ writeStart(writer,
+ PROPERTY,
+ new XAttr(NAME, property.getName()),
+ new XAttr(MUST_SUPPLY, property.isMustSupply()),
+ new XAttr(MANY, property.isMany()),
+ new XAttr(TYPE, property.getXSDType()),
+ new XAttr(ELEMENT, property.getXSDElement()),
+ policyProcessor.writePolicies(property));
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extension elements
+ if (componentType instanceof Extensible) {
+ for (Object extension: ((Extensible)componentType).getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+ }
+
+ // Write <implementation> elements if the componentType has
+ // any intents or policySets
+ boolean writeImplementation = false;
+ if (componentType instanceof PolicySubject) {
+ if (!((PolicySubject)componentType).getRequiredIntents().isEmpty()) {
+ writeImplementation = true;
+ }
+ }
+ if (componentType instanceof PolicySubject) {
+ if (!((PolicySubject)componentType).getPolicySets().isEmpty()) {
+ writeImplementation = true;
+ }
+ }
+ if (writeImplementation) {
+ writeStart(writer, IMPLEMENTATION,
+ policyProcessor.writePolicies(componentType));
+ }
+
+ writeEndDocument(writer);
+ }
+
+ /**
+ * Write the value of a property - override to use correct method of creating an XMLStreamReader
+ * @param document
+ * @param element
+ * @param type
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writePropertyValue(Object propertyValue, QName element, QName type, XMLStreamWriter writer)
+ throws XMLStreamException {
+
+ if (propertyValue instanceof Document) {
+ Document document = (Document)propertyValue;
+ NodeList nodeList = document.getDocumentElement().getChildNodes();
+
+ for (int item = 0; item < nodeList.getLength(); ++item) {
+ Node node = nodeList.item(item);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ // Correct way to create a reader for a node object...
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(node);
+
+ while (reader.hasNext()) {
+ switch (reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ writer.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
+
+ int namespaces = reader.getNamespaceCount();
+ for (int i = 0; i < namespaces; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ writer.writeNamespace(prefix, ns);
+ }
+
+ if (!"".equals(name.getNamespaceURI())) {
+ writer.writeNamespace(name.getPrefix(), name.getNamespaceURI());
+ }
+
+ // add the attributes for this element
+ namespaces = reader.getAttributeCount();
+ for (int i = 0; i < namespaces; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+
+ writer.writeAttribute(prefix, ns, qname, value);
+ }
+
+ break;
+ case XMLStreamConstants.CDATA:
+ writer.writeCData(reader.getText());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ writer.writeCharacters(reader.getText());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ writer.writeEndElement();
+ break;
+ }
+ }
+ } else {
+ writer.writeCharacters(node.getTextContent());
+ }
+ }
+ }
+ } // end method writePropertyValue
+
+ public void resolve(ComponentType componentType, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Resolve component type services and references
+ resolveContracts(componentType.getServices(), resolver, context);
+ resolveContracts(componentType.getReferences(), resolver, context);
+ }
+
+ public QName getArtifactType() {
+ return COMPONENT_TYPE_QNAME;
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+
+ /**
+ * Returns the model factory extension point to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) {
+ return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
new file mode 100644
index 0000000000..5ba42a0dec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.xml.sax.SAXException;
+
+/**
+ * A composite processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<Composite>,
+ XMLStreamConstants {
+ private ValidatingXMLInputFactory inputFactory;
+
+
+ /**
+ * Constructs a composite document processor
+ * @param modelFactories
+ * @param staxProcessor
+ * @param monitor
+ */
+ public CompositeDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<?> staxProcessor) {
+ super(modelFactories, staxProcessor);
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ }
+
+ /**
+ * Reads the contents of a Composite document and returns a Composite object
+ * @param contributionURL - the URL of the contribution containing the Composite - can be null
+ * @param uri - the URI of the composite document
+ * @param url - the URL of the composite document
+ * @return a Composite object built from the supplied Composite document
+ */
+ public Composite read(URL contributionURL, URI uri, URL url, ProcessorContext context) throws ContributionReadException {
+ if( uri == null || url == null ) {
+ throw new ContributionReadException("Request to read composite with uri or url NULL");
+ } // end if
+ InputStream scdlStream = null;
+
+ try {
+ scdlStream = IOHelper.openStream(url);
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException("Exception reading " + uri, e);
+ error(context.getMonitor(), "ContributionReadException", url, ce);
+ throw ce;
+ }
+ return read(uri, url, scdlStream, context);
+ }
+
+ public Composite read(URI uri, URL url, InputStream scdlStream, ProcessorContext context) throws ContributionReadException {
+ try {
+
+ Composite composite = null;
+ Monitor monitor = context.getMonitor();
+ // Tag the monitor with the name of the composite artifact
+ if( monitor != null ) {
+ monitor.setArtifactName(uri.toString());
+ } //end if
+
+ // Set up a StreamSource for the composite file, since this has an associated URL that
+ // can be used by the parser to find references to other files such as DTDs
+ StreamSource scdlSource = new StreamSource( scdlStream, url.toString() );
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlSource);
+
+ // set the monitor on the input factory as the standard XMLInputFactory
+ // methods used for creating readers don't allow for the context to
+ // be passed in
+ ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
+
+ // Read the header (i.e. text before the <composite> element, if any
+ readCompositeFileHeader( reader );
+
+ // Read the composite model
+ composite = (Composite)extensionProcessor.read(reader, context);
+ if (composite != null) {
+ composite.setURI(uri.toString());
+ }
+
+ return composite;
+
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException("Exception reading " + uri, e);
+ error(context.getMonitor(), "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } finally {
+ try {
+ if (scdlStream != null) {
+ scdlStream.close();
+ scdlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+
+ /**
+ * Reads the header portion of a composite file - i.e. the section of the file before the
+ * <composite> start tag
+ * In particular handle any DTD declarations
+ * @param reader - an XMLStreamReader which is reading the composite file
+ * @throws XMLStreamException
+ */
+ private void readCompositeFileHeader( XMLStreamReader reader ) throws XMLStreamException {
+
+ while (true) {
+ int event = reader.next();
+
+ if ( event == CHARACTERS
+ || event == CDATA
+ || event == SPACE
+ || event == PROCESSING_INSTRUCTION
+ || event == COMMENT
+ || event == DTD
+ || event == ENTITY_DECLARATION ) {
+ continue;
+ } // end if
+
+ // The first start (or end) element terminates the header scan
+ if (event == START_ELEMENT || event == END_ELEMENT) {
+ return;
+ } // end if
+ } // end while
+ } // end method readCompositeFileHeader
+
+ public void resolve(Composite composite, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ try {
+ if (composite != null)
+ extensionProcessor.resolve(composite, resolver, context);
+ } catch (Throwable e ) {
+ // Add information about which composite was being processed when the exception occurred
+ String newMessage = "Processing composite " + composite.getName() + ": " + e.getMessage();
+ throw new ContributionResolveException( newMessage, e );
+ } // end try
+ }
+
+ public String getArtifactType() {
+ return ".composite";
+ }
+
+ public Class<Composite> getModelType() {
+ return Composite.class;
+ }
+
+} // end class
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
new file mode 100644
index 0000000000..7a396fe100
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A Model Resolver for Composite models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeModelResolver implements ModelResolver {
+
+ private Contribution contribution;
+ private Map<QName, Composite> map = new HashMap<QName, Composite>();
+
+ public CompositeModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ Composite composite = (Composite)resolved;
+ Composite old = map.put(composite.getName(), composite);
+ if (old != null) {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "DuplicateCompositeName",
+ composite.getName().toString(),
+ contribution.getLocation());
+ }
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(((Composite)resolved).getName());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ // Lookup a definition for the given namespace
+ QName qname = ((Composite)unresolved).getName();
+ Composite resolved = null;
+
+ // Delegate the resolution to the imports
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof NamespaceImport) {
+ NamespaceImport namespaceImport = (NamespaceImport)import_;
+ if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
+
+ // Delegate the resolution to the import resolver
+ resolved = namespaceImport.getModelResolver().resolveModel(Composite.class, (Composite)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+
+ // No definition found, search within the current contribution
+ resolved = (Composite) map.get(qname);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ return (T)unresolved;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
new file mode 100644
index 0000000000..eecb07e6cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
@@ -0,0 +1,1259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.AUTOWIRE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CALLBACK;
+import static org.apache.tuscany.sca.assembly.xml.Constants.CALLBACK_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPONENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPONENT_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPOSITE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.COMPOSITE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.ELEMENT;
+import static org.apache.tuscany.sca.assembly.xml.Constants.EXTENSION_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.FILE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.IMPLEMENTATION_COMPOSITE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.IMPLEMENTATION_COMPOSITE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.INCLUDE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.INCLUDE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.INTENTS;
+import static org.apache.tuscany.sca.assembly.xml.Constants.LOCAL;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MANY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.NONOVERRIDABLE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.POLICY_SET_ATTACHMENT_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROMOTE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REFERENCE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REPLACE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REQUIRES_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SCA11_NS;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE_QNAME;
+import static org.apache.tuscany.sca.assembly.xml.Constants.SOURCE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TARGET;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TARGET_NAMESPACE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.TYPE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.URI;
+import static org.apache.tuscany.sca.assembly.xml.Constants.WIRE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.WIRED_BY_IMPL;
+import static org.apache.tuscany.sca.assembly.xml.Constants.WIRE_QNAME;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.common.xml.xpath.XPathHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ResolverExtension;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A composite processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<Composite> {
+ private XPathHelper xpathHelper;
+ private PolicyFactory intentAttachPointTypeFactory;
+ private StAXAttributeProcessor<Object> extensionAttributeProcessor;
+ private ContributionFactory contributionFactory;
+ private XSDFactory xsdFactory;
+
+ private StAXHelper staxHelper;
+
+ /**
+ * Construct a new composite processor
+ *
+ * @param extensionPoints
+ * @param extensionProcessor
+ */
+ public CompositeProcessor(ExtensionPointRegistry extensionPoints,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+
+ this(modelFactories(extensionPoints), extensionProcessor, extensionAttributeProcessor);
+
+ this.xpathHelper = XPathHelper.getInstance(extensionPoints);
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+
+ this.xsdFactory = extensionPoints.getExtensionPoint(XSDFactory.class);
+
+ //
+ staxHelper = StAXHelper.getInstance(extensionPoints);
+ }
+
+ /**
+ * Constructs a new composite processor
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ * @param monitor
+ */
+ private CompositeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+
+ super(modelFactories, extensionProcessor);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+
+ this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ }
+
+ public Composite read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ Composite composite = null;
+ Composite include = null;
+ Component component = null;
+ Property property = null;
+ ComponentService componentService = null;
+ ComponentReference componentReference = null;
+ ComponentProperty componentProperty = null;
+ CompositeService compositeService = null;
+ CompositeReference compositeReference = null;
+ Contract contract = null;
+ Wire wire = null;
+ Callback callback = null;
+ QName name = null;
+ Monitor monitor = context.getMonitor();
+ try {
+ // Read the composite document
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+
+ if (COMPOSITE_QNAME.equals(name)) {
+
+ // Read a <composite>
+ composite = assemblyFactory.createComposite();
+ composite.setSpecVersion(Constants.SCA11_NS);
+
+ composite.setName(new QName(getURIString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
+
+ if (!isSet(reader, TARGET_NAMESPACE)) {
+ // spec says that a composite must have a namespace
+ warning(monitor, "NoCompositeNamespace", composite, composite.getName().toString());
+ }
+
+ if (isSet(reader, AUTOWIRE)) {
+ composite.setAutowire(getBoolean(reader, AUTOWIRE));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, composite, extensionAttributeProcessor, context);
+
+ composite.setLocal(getBoolean(reader, LOCAL));
+ policyProcessor.readPolicies(composite, reader);
+
+ } else if (INCLUDE_QNAME.equals(name)) {
+
+ // Read an <include>
+ include = assemblyFactory.createComposite();
+ include.setName(getQName(reader, NAME));
+ include.setURI(getURIString(reader, URI));
+ include.setUnresolved(true);
+ composite.getIncludes().add(include);
+
+ } else if (SERVICE_QNAME.equals(name)) {
+ if (component != null) {
+
+ // Read a <component><service>
+ componentService = assemblyFactory.createComponentService();
+ contract = componentService;
+ componentService.setName(getString(reader, NAME));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, componentService, extensionAttributeProcessor, context);
+
+ component.getServices().add(componentService);
+ policyProcessor.readPolicies(contract, reader);
+ } else {
+
+ // Read a <composite><service>
+ compositeService = assemblyFactory.createCompositeService();
+ contract = compositeService;
+ compositeService.setName(getString(reader, NAME));
+
+ String promoted = getURIString(reader, PROMOTE);
+ if (promoted != null) {
+ String promotedComponentName;
+ String promotedServiceName;
+ int s = promoted.indexOf('/');
+ if (s == -1) {
+ promotedComponentName = promoted;
+ promotedServiceName = null;
+ } else {
+ promotedComponentName = promoted.substring(0, s);
+ promotedServiceName = promoted.substring(s + 1);
+ }
+
+ Component promotedComponent = assemblyFactory.createComponent();
+ promotedComponent.setUnresolved(true);
+ promotedComponent.setName(promotedComponentName);
+ compositeService.setPromotedComponent(promotedComponent);
+
+ ComponentService promotedService = assemblyFactory.createComponentService();
+ promotedService.setUnresolved(true);
+ promotedService.setName(promotedServiceName);
+ compositeService.setPromotedService(promotedService);
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, compositeService, extensionAttributeProcessor, context);
+
+ composite.getServices().add(compositeService);
+ policyProcessor.readPolicies(contract, reader);
+ }
+
+ // set the parent model so that binding processing can
+ // detect it they're being read as part of a reference
+ // or a service
+ context.setParentModel(contract);
+
+ } else if (REFERENCE_QNAME.equals(name)) {
+ if (component != null) {
+ // Read a <component><reference>
+ componentReference = assemblyFactory.createComponentReference();
+ contract = componentReference;
+ componentReference.setName(getString(reader, NAME));
+ readMultiplicity(componentReference, reader);
+ if (isSet(reader, AUTOWIRE)) {
+ componentReference.setAutowire(getBoolean(reader, AUTOWIRE));
+ }
+ // Read @nonOverridable
+ String nonOverridable = reader.getAttributeValue(null, NONOVERRIDABLE);
+ if (nonOverridable != null) {
+ componentReference.setNonOverridable(Boolean.parseBoolean(nonOverridable));
+ }
+ readTargets(componentReference, reader);
+ componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader,
+ name,
+ componentReference,
+ extensionAttributeProcessor, context);
+
+ component.getReferences().add(componentReference);
+ policyProcessor.readPolicies(contract, reader);
+ } else {
+ // Read a <composite><reference>
+ compositeReference = assemblyFactory.createCompositeReference();
+ contract = compositeReference;
+ compositeReference.setName(getString(reader, NAME));
+ readMultiplicity(compositeReference, reader);
+ readTargets(compositeReference, reader);
+ String promote = getString(reader, Constants.PROMOTE);
+ if (promote != null) {
+ for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) {
+ String refName = tokens.nextToken();
+ Component promotedComponent = assemblyFactory.createComponent();
+ int index = refName.indexOf('/');
+ if (index == -1) {
+ error(monitor, "Invalid reference name", compositeReference, refName);
+ }
+ String promotedComponentName = refName.substring(0, index);
+ promotedComponent.setName(promotedComponentName);
+ promotedComponent.setUnresolved(true);
+ compositeReference.getPromotedComponents().add(promotedComponent);
+ ComponentReference promotedReference =
+ assemblyFactory.createComponentReference();
+ promotedReference.setUnresolved(true);
+ promotedReference.setName(refName);
+ compositeReference.getPromotedReferences().add(promotedReference);
+ }
+ }
+ compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader,
+ name,
+ compositeReference,
+ extensionAttributeProcessor, context);
+
+ composite.getReferences().add(compositeReference);
+ policyProcessor.readPolicies(contract, reader);
+ }
+
+ // set the parent model so that binding processing can
+ // detect it they're being read as part of a reference
+ // or a service
+ context.setParentModel(contract);
+
+ } else if (PROPERTY_QNAME.equals(name)) {
+ if (component != null) {
+
+ // Read a <component><property>
+ componentProperty = assemblyFactory.createComponentProperty();
+ property = componentProperty;
+ String source = getURIString(reader, SOURCE);
+ if (source != null) {
+ source = source.trim();
+ }
+ componentProperty.setSource(source);
+ if (source != null) {
+ String xPath = prepareSourceXPathString( source );
+
+ try {
+ componentProperty.setSourceXPathExpression(xpathHelper.compile(reader
+ .getNamespaceContext(), xPath));
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", source, ce);
+ //throw ce;
+ }
+ }
+ componentProperty.setFile(getURIString(reader, FILE));
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader,
+ name,
+ componentProperty,
+ extensionAttributeProcessor, context);
+
+ policyProcessor.readPolicies(property, reader);
+ readAbstractProperty(componentProperty, reader, context);
+
+ // Read the property value
+ Document value =
+ readPropertyValue(property.getXSDElement(), property.getXSDType(), property
+ .isMany(), reader, context);
+ property.setValue(value);
+
+ component.getProperties().add(componentProperty);
+ } else {
+
+ // Read a <composite><property>
+ property = assemblyFactory.createProperty();
+ policyProcessor.readPolicies(property, reader);
+ readAbstractProperty(property, reader, context);
+
+ // Read the property value
+ Document value =
+ readPropertyValue(property.getXSDElement(), property.getXSDType(), property
+ .isMany(), reader, context);
+ property.setValue(value);
+
+ composite.getProperties().add(property);
+ }
+
+ // TUSCANY-1949
+ // If the property doesn't have a value, the END_ELEMENT event is read by the readPropertyValue
+ if (reader.getEventType() == END_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) {
+ property = null;
+ componentProperty = null;
+ }
+
+ } else if (COMPONENT_QNAME.equals(name)) {
+
+ // Read a <component>
+ component = assemblyFactory.createComponent();
+ component.setName(getString(reader, NAME));
+ if (isSet(reader, AUTOWIRE)) {
+ component.setAutowire(getBoolean(reader, AUTOWIRE));
+ }
+ if (isSet(reader, URI)) {
+ component.setURI(getURIString(reader, URI));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, component, extensionAttributeProcessor, context);
+
+ composite.getComponents().add(component);
+ policyProcessor.readPolicies(component, reader);
+
+ } else if (WIRE_QNAME.equals(name)) {
+
+ // Read a <wire>
+ wire = assemblyFactory.createWire();
+ ComponentReference source = assemblyFactory.createComponentReference();
+ source.setUnresolved(true);
+ source.setName(getURIString(reader, SOURCE));
+ wire.setSource(source);
+
+ ComponentService target = assemblyFactory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getURIString(reader, TARGET));
+ wire.setTarget(target);
+
+ // Read @replace
+ String replace = reader.getAttributeValue(null, REPLACE);
+ if (replace != null) {
+ wire.setReplace(Boolean.parseBoolean(replace));
+ }
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, wire, extensionAttributeProcessor, context);
+
+ composite.getWires().add(wire);
+ policyProcessor.readPolicies(wire, reader);
+
+ } else if (CALLBACK_QNAME.equals(name)) {
+
+ // Read a <callback>
+ callback = assemblyFactory.createCallback();
+ contract.setCallback(callback);
+ callback.setParentContract(contract);
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor, context);
+
+ policyProcessor.readPolicies(callback, reader);
+
+ // set the parent model so that binding processing can
+ // detect it they're being read as part of a callback
+ context.setParentModel(callback);
+
+ } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {
+
+ // Read an implementation.composite
+ Composite implementation = assemblyFactory.createComposite();
+ implementation.setName(getQName(reader, NAME));
+ implementation.setUnresolved(true);
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, implementation, extensionAttributeProcessor, context);
+
+ component.setImplementation(implementation);
+ policyProcessor.readPolicies(implementation, reader);
+ } else if (REQUIRES_QNAME.equals(name)) {
+ List<QName> intents = getQNames(reader, INTENTS);
+ for (QName i : intents) {
+ Intent intent = policyFactory.createIntent();
+ intent.setName(i);
+ if (composite != null) {
+ composite.getRequiredIntents().add(intent);
+ } else if (component != null) {
+ component.getRequiredIntents().add(intent);
+ } else if (contract != null) {
+ contract.getRequiredIntents().add(intent);
+ } else if (callback != null) {
+ callback.getRequiredIntents().add(intent);
+ }
+ }
+ } else if (POLICY_SET_ATTACHMENT_QNAME.equals(name)) {
+ QName ps = getQName(reader, NAME);
+ if (ps != null) {
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(ps);
+ if (composite != null) {
+ composite.getPolicySets().add(policySet);
+ } else if (component != null) {
+ component.getPolicySets().add(policySet);
+ } else if (contract != null) {
+ contract.getPolicySets().add(policySet);
+ } else if (callback != null) {
+ callback.getPolicySets().add(policySet);
+ }
+ }
+ } else if(EXTENSION_QNAME.equals(name)) {
+ // Handle <extension>
+ //ignore element as this is a wrapper for extensibility
+ break;
+ } else {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof InterfaceContract) {
+
+ // <service><interface> and
+ // <reference><interface>
+ if (contract != null) {
+ contract.setInterfaceContract((InterfaceContract)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA11_NS)) {
+ error(monitor, "UnexpectedInterfaceElement", extension);
+ //throw new ContributionReadException("Unexpected <interface> element found. It should appear inside a <service> or <reference> element");
+ } else {
+ composite.getExtensions().add(extension);
+ }
+ }
+ } else if (extension instanceof Binding) {
+ if (extension instanceof PolicySubject) {
+ ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
+ bindingType.setType(name);
+ bindingType.setUnresolved(true);
+ ((PolicySubject)extension).setExtensionType(bindingType);
+ }
+ // <service><binding> and
+ // <reference><binding>
+ if (callback != null) {
+ callback.getBindings().add((Binding)extension);
+ } else {
+ if (contract != null) {
+ contract.getBindings().add((Binding)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA11_NS)) {
+ error(monitor, "UnexpectedBindingElement", extension);
+ //throw new ContributionReadException("Unexpected <binding> element found. It should appear inside a <service> or <reference> element");
+ } else {
+ composite.getExtensions().add(extension);
+ }
+ }
+ }
+
+ } else if (extension instanceof Implementation) {
+ if (extension instanceof PolicySubject) {
+ ExtensionType implType =
+ intentAttachPointTypeFactory.createImplementationType();
+ implType.setType(name);
+ implType.setUnresolved(true);
+ ((PolicySubject)extension).setExtensionType(implType);
+ }
+ // <component><implementation>
+ if (component != null) {
+ component.setImplementation((Implementation)extension);
+ } else {
+ if (name.getNamespaceURI().equals(SCA11_NS)) {
+ error(monitor, "UnexpectedImplementationElement", extension);
+ //throw new ContributionReadException("Unexpected <implementation> element found. It should appear inside a <component> element");
+ } else {
+ composite.getExtensions().add(extension);
+ }
+ }
+ } else {
+
+ // Add the extension element to the current
+ // element
+ if (callback != null) {
+ callback.getExtensions().add(extension);
+ } else if (contract != null) {
+ contract.getExtensions().add(extension);
+ } else if (property != null) {
+ property.getExtensions().add(extension);
+ } else if (component != null) {
+ component.getExtensions().add(extension);
+ } else {
+ composite.getExtensions().add(extension);
+ }
+ }
+ }
+ }
+ break;
+
+ case XMLStreamConstants.CHARACTERS:
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+
+ // Clear current state when reading reaching end element
+ if (SERVICE_QNAME.equals(name)) {
+ componentService = null;
+ compositeService = null;
+ contract = null;
+ } else if (INCLUDE_QNAME.equals(name)) {
+ include = null;
+ } else if (REFERENCE_QNAME.equals(name)) {
+ componentReference = null;
+ compositeReference = null;
+ contract = null;
+ } else if (PROPERTY_QNAME.equals(name)) {
+ componentProperty = null;
+ property = null;
+ } else if (COMPONENT_QNAME.equals(name)) {
+ component = null;
+ } else if (WIRE_QNAME.equals(name)) {
+ wire = null;
+ } else if (CALLBACK_QNAME.equals(name)) {
+ callback = null;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ } catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(monitor, "XMLStreamException", reader, ex);
+ }
+
+ return composite;
+ }
+
+ /**
+ * Prepares the property @source XPath expression
+ *
+ * The form of the @source attribute in the composite file must take one of the forms
+ * $propertyName
+ * $propertyName/expression
+ * $propertyName[n]
+ * $propertyName[n]/expression
+ * Property values are stored as <sca:property> elements with one or more <sca:value> subelements or one or more
+ * global element subelements. The XPath constructed is designed to work against this XML structure and aims to
+ * retrieve one or more of the subelements or subportions of those subelements (eg some text content).
+ * Thus the XPath:
+ * - starts with "*", which means "all the child elements of the root" where root = the <property/> element
+ * - may then be followed by [xxx] (typically [n] to select one of the child elements) if the source string has [xxx]
+ * following the propertyName
+ * - may then be followed by /expression, if the source contains an expression, which will typically select some subportion
+ * of the child element(s)
+ *
+ * @param source - the @source attribute string from a <sca:property> element
+ * @return the XPath string to use for the source property
+ */
+ private String prepareSourceXPathString( String source ) {
+ String output = null;
+ // Expression must begin with '$'
+ if( source.charAt(0) != '$' ) return output;
+
+ int slash = source.indexOf('/');
+ int bracket = source.indexOf('[');
+ if (slash == -1) {
+ // Form is $propertyName or $propertyName[n]
+ output = "*";
+ if( bracket != -1 ) {
+ output = "*" + source.substring(bracket);
+ }
+ } else {
+ // Form is $propertyName/exp or $propertyName[n]/exp
+ output = "*/" + source.substring(slash + 1);
+ if( bracket != -1 && bracket < slash ) {
+ output = "*" + source.substring(bracket);
+ }
+ } // end if
+
+ return output;
+ } // end method prepareSourceXPathString( source )
+
+ public void write(Composite composite, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write <composite> element
+ writeStartDocument(writer,
+ COMPOSITE,
+ new XAttr(TARGET_NAMESPACE, composite.getName().getNamespaceURI()),
+ new XAttr(NAME, composite.getName().getLocalPart()),
+ new XAttr(LOCAL, composite.isLocal() ? Boolean.TRUE : null),
+ new XAttr(AUTOWIRE, composite.getAutowire()),
+ policyProcessor.writePolicies(composite));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, composite, extensionAttributeProcessor, context);
+
+ // Write <include> elements
+ for (Composite include : composite.getIncludes()) {
+ String uri = include.isUnresolved() ? include.getURI() : null;
+ writeStart(writer, INCLUDE, new XAttr(NAME, include.getName()), new XAttr(URI, uri));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, include, extensionAttributeProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <service> elements
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ Component promotedComponent = compositeService.getPromotedComponent();
+ ComponentService promotedService = compositeService.getPromotedService();
+ String promote;
+ if (promotedService != null) {
+ if (promotedService.getName() != null) {
+ promote = promotedComponent.getName() + '/' + promotedService.getName();
+ } else {
+ promote = promotedComponent.getName();
+ }
+ } else {
+ promote = null;
+ }
+ writeStart(writer,
+ SERVICE,
+ new XAttr(NAME, service.getName()),
+ new XAttr(PROMOTE, promote),
+ policyProcessor.writePolicies(service));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, service, extensionAttributeProcessor, context);
+
+ // Write service interface
+ extensionProcessor.write(service.getInterfaceContract(), writer, context);
+
+ // Write bindings
+ for (Binding binding : service.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write <callback> element
+ if (service.getCallback() != null) {
+ Callback callback = service.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor, context);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, service, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, service, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <component> elements
+ for (Component component : composite.getComponents()) {
+ writeStart(writer,
+ COMPONENT,
+ new XAttr(NAME, component.getName()),
+ new XAttr(URI, component.getURI()),
+ new XAttr(AUTOWIRE, component.getAutowire()),
+ policyProcessor.writePolicies(component));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, component, extensionAttributeProcessor, context);
+
+ // Write the component implementation
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, ((Composite)implementation).getName()), policyProcessor.writePolicies(implementation));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, (Composite)implementation, extensionAttributeProcessor, context);
+
+ writeEnd(writer);
+ } else {
+ extensionProcessor.write(component.getImplementation(), writer, context);
+ }
+
+ for (Object extension : component.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ // Write <service> elements
+ for (ComponentService service : component.getServices()) {
+ writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), policyProcessor.writePolicies(service));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, service, extensionAttributeProcessor, context);
+
+ // Write service interface
+ extensionProcessor.write(service.getInterfaceContract(), writer, context);
+
+ // Write bindings
+ for (Binding binding : service.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write <callback> element
+ if (service.getCallback() != null) {
+ Callback callback = service.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor, context);
+
+ // Write bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, callback, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, service, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (ComponentReference reference : component.getReferences()) {
+ writeStart(writer,
+ REFERENCE,
+ new XAttr(NAME, reference.getName()),
+ new XAttr(AUTOWIRE, reference.getAutowire()),
+ (reference.isNonOverridable() ? new XAttr(NONOVERRIDABLE, true) : null),
+ writeMultiplicity(reference),
+ writeTargets(reference),
+ policyProcessor.writePolicies(reference));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, reference, extensionAttributeProcessor, context);
+
+ // Write reference interface
+ extensionProcessor.write(reference.getInterfaceContract(), writer, context);
+
+ // Write bindings
+ for (Binding binding : reference.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write callback
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor, context);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, callback, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, reference, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <property> elements
+ for (ComponentProperty property : component.getProperties()) {
+ writeStart(writer,
+ PROPERTY,
+ new XAttr(NAME, property.getName()),
+ new XAttr(MUST_SUPPLY, property.isMustSupply()),
+ new XAttr(MANY, property.isMany()),
+ new XAttr(TYPE, property.getXSDType()),
+ new XAttr(ELEMENT, property.getXSDElement()),
+ new XAttr(SOURCE, property.getSource()),
+ new XAttr(FILE, property.getFile()),
+ policyProcessor.writePolicies(property));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, property, extensionAttributeProcessor, context);
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <reference> elements
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+
+ // Write list of promoted references
+ List<String> promote = new ArrayList<String>();
+ for (ComponentReference promoted : compositeReference.getPromotedReferences()) {
+ promote.add(promoted.getName());
+ }
+
+ // Write <reference> element
+ writeStart(writer,
+ REFERENCE,
+ new XAttr(NAME, reference.getName()),
+ new XAttr(PROMOTE, promote),
+ writeMultiplicity(reference),
+ policyProcessor.writePolicies(reference));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, reference, extensionAttributeProcessor, context);
+
+ // Write reference interface
+ extensionProcessor.write(reference.getInterfaceContract(), writer, context);
+
+ // Write bindings
+ for (Binding binding : reference.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write <callback> element
+ if (reference.getCallback() != null) {
+ Callback callback = reference.getCallback();
+ writeStart(writer, CALLBACK);
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor, context);
+
+ // Write callback bindings
+ for (Binding binding : callback.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, callback, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ this.writeExtendedElements(writer, reference, extensionProcessor, context);
+
+ writeEnd(writer);
+ }
+
+ // Write <property> elements
+ for (Property property : composite.getProperties()) {
+ writeStart(writer,
+ PROPERTY,
+ new XAttr(NAME, property.getName()),
+ new XAttr(MUST_SUPPLY, property.isMustSupply()),
+ new XAttr(MANY, property.isMany()),
+ new XAttr(TYPE, property.getXSDType()),
+ new XAttr(ELEMENT, property.getXSDElement()),
+ policyProcessor.writePolicies(property));
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, property, extensionAttributeProcessor, context);
+
+ // Write property value
+ writePropertyValue(property.getValue(), property.getXSDElement(), property.getXSDType(), writer);
+
+ // Write extensions
+ for (Object extension : property.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write <wire> elements
+ for (Wire wire : composite.getWires()) {
+ writeStart(writer, WIRE, new XAttr(SOURCE, wire.getSource().getName()), new XAttr(TARGET, wire.getTarget()
+ .getName()), wire.isReplace() ? new XAttr(Constants.REPLACE, true) : null);
+
+ //write extended attributes
+ this.writeExtendedAttributes(writer, wire, extensionAttributeProcessor, context);
+
+ // Write extensions
+ for (Object extension : wire.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+ writeEnd(writer);
+ }
+
+ for (Object extension : composite.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(Composite composite, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ Monitor monitor = context.getMonitor();
+ try {
+ monitor.pushContext("Composite: " + composite.getName());
+
+ // Resolve includes in the composite
+ for (int i = 0, n = composite.getIncludes().size(); i < n; i++) {
+ Composite include = composite.getIncludes().get(i);
+ if (include != null) {
+ Composite resolved = resolver.resolveModel(Composite.class, include, context);
+ if (!resolved.isUnresolved()) {
+ if ((composite.isLocal() && resolved.isLocal()) || (!composite.isLocal() && !resolved.isLocal())) {
+ composite.getIncludes().set(i, resolved);
+ } else {
+ ContributionResolveException ce =
+ new ContributionResolveException("[ASM60041] Error: Composite " + composite.getName()
+ + " can only include another composite with the identical @local attribute value");
+ error(monitor, "ContributionResolveException", include, ce);
+ }
+ } else {
+ ContributionResolveException ce =
+ new ContributionResolveException("[ASM60042] Error: Composite " + include.getName()
+ + " is not a valid composite within the domain");
+ error(monitor, "ContributionResolveException", include, ce);
+ }
+ }
+ }
+
+ // Resolve extensions
+ for (Object extension : composite.getExtensions()) {
+ if (extension != null) {
+ extensionProcessor.resolve(extension, resolver, context);
+ }
+ }
+
+ //Resolve composite services and references
+ resolveContracts(composite, composite.getServices(), resolver, context);
+ resolveContracts(composite, composite.getReferences(), resolver, context);
+
+ for (Property property : composite.getProperties()){
+ resolvePropertyType("composite " + composite.getName().toString(),
+ property,
+ context.getContribution(), context);
+ }
+
+ // Resolve component implementations, services and references
+ for (Component component : composite.getComponents()) {
+
+ //resolve component services and references
+ resolveContracts(component, component.getServices(), resolver, context);
+ resolveContracts(component, component.getReferences(), resolver, context);
+
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ // resolve a reference to a property file
+ if (componentProperty.getFile() != null) {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(componentProperty.getFile());
+ artifact = resolver.resolveModel(Artifact.class, artifact, context);
+ if (artifact.getLocation() != null) {
+ componentProperty.setFile(artifact.getLocation());
+ }
+ }
+
+ // resolve the reference to a complex property
+ resolvePropertyType("component " + component.getName(),
+ componentProperty,
+ context.getContribution(), context);
+ }
+
+ //resolve component implementation
+ Implementation implementation = component.getImplementation();
+ if (implementation != null) {
+ //now resolve the implementation so that even if there is a shared instance
+ //for this that is resolved, the specified intents and policysets are safe in the
+ //component and not lost
+
+ List<PolicySet> policySets = new ArrayList<PolicySet>(implementation.getPolicySets());
+ List<Intent> intents = new ArrayList<Intent>(implementation.getRequiredIntents());
+ implementation = resolveImplementation(implementation, resolver, context);
+
+ // If there are any policy sets on the implementation or component we have to
+ // ignore policy sets from the component type (policy spec 4.9)
+ if ( !policySets.isEmpty() || !component.getPolicySets().isEmpty() ) {
+ implementation.getPolicySets().clear();
+ implementation.getPolicySets().addAll(policySets);
+ }
+
+ implementation.getRequiredIntents().addAll(intents);
+
+ component.setImplementation(implementation);
+ }
+
+ //add model resolver to component
+ if (component instanceof ResolverExtension) {
+ ((ResolverExtension)component).setModelResolver(resolver);
+ }
+ }
+
+ // Add model resolver to promoted components
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ Component promotedComponent = compositeService.getPromotedComponent();
+ if (promotedComponent instanceof ResolverExtension) {
+ ((ResolverExtension)promotedComponent).setModelResolver(resolver);
+ }
+ } // end for
+
+ } finally {
+ // Pop context
+ monitor.popContext();
+ } // end try
+ }
+
+ public QName getArtifactType() {
+ return COMPOSITE_QNAME;
+ }
+
+ public Class<Composite> getModelType() {
+ return Composite.class;
+ }
+
+ /**
+ * Write the value of a property - override to use correct method of creating an XMLStreamReader
+ * @param document
+ * @param element
+ * @param type
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writePropertyValue(Object propertyValue, QName element, QName type, XMLStreamWriter writer)
+ throws XMLStreamException {
+
+ if (propertyValue instanceof Document) {
+ Document document = (Document)propertyValue;
+ NodeList nodeList = document.getDocumentElement().getChildNodes();
+
+ for (int item = 0; item < nodeList.getLength(); ++item) {
+ Node node = nodeList.item(item);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ // Correct way to create a reader for a node object...
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(node);
+
+ while (reader.hasNext()) {
+ switch (reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ writer.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
+
+ int namespaces = reader.getNamespaceCount();
+ for (int i = 0; i < namespaces; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ writer.writeNamespace(prefix, ns);
+ }
+
+ if (!"".equals(name.getNamespaceURI())) {
+ writer.writeNamespace(name.getPrefix(), name.getNamespaceURI());
+ }
+
+ // add the attributes for this element
+ namespaces = reader.getAttributeCount();
+ for (int i = 0; i < namespaces; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+
+ writer.writeAttribute(prefix, ns, qname, value);
+ }
+
+ break;
+ case XMLStreamConstants.CDATA:
+ writer.writeCData(reader.getText());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ writer.writeCharacters(reader.getText());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ writer.writeEndElement();
+ break;
+ }
+ }
+ } else {
+ writer.writeCharacters(node.getTextContent());
+ }
+ }
+ }
+ } // end method writePropertyValue
+
+
+ /**
+ * Returns the model factory extension point to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) {
+ return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ }
+
+ /**
+ * Property elements can have XSD types attributes so, in the case of a complex type, we need to find
+ * the XSD definition that defines that type in the contribution while we still have access to the
+ * contribution. Later, in the builder, we use this XSD definition to ensure that the property value
+ * is of the correct type
+ *
+ * @param property
+ * @param contribution
+ */
+ private void resolvePropertyType(String parentName, Property property, Contribution contribution, ProcessorContext context){
+ // resolve the reference to a complex property
+ // we ignore any types in the schema namespace
+ if (property.getXSDType() != null &&
+ property.getXSDType().getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema") != true){
+ XSDefinition xsdDefinition = xsdFactory.createXSDefinition();
+ xsdDefinition.setUnresolved(true);
+ xsdDefinition.setNamespace(property.getXSDType().getNamespaceURI());
+ // some unit tests don't set up contribution and model resolvers properly
+ if (contribution != null && contribution.getModelResolver() != null) {
+ XSDefinition resolved = contribution.getModelResolver().resolveModel(XSDefinition.class, xsdDefinition, context);
+ if (resolved == null || resolved.isUnresolved()){
+ // raise an error
+ // [rfeng] The XSD might be not available if we use JAXB annotated classes, report it as a warning for now
+ warning(context.getMonitor(), "PropertyTypeNotFound", property, property.getXSDType().toString(), property.getName(), parentName);
+ } else {
+ // store the schema in the property
+ property.setXSDDefinition(resolved);
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java
new file mode 100644
index 0000000000..9930096a26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for dealing with 'operation' elements from composite definitions
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ConfiguredOperationProcessor implements StAXArtifactProcessor<ConfiguredOperation>, Constants{
+
+ private AssemblyFactory assemblyFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private PolicyFactory policyFactory;
+
+
+ public ConfiguredOperationProcessor(FactoryExtensionPoint modelFactories) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ public ConfiguredOperation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ ConfiguredOperation configuredOp = assemblyFactory.createConfiguredOperation();
+
+ //Read an <operation>
+ configuredOp.setName(reader.getAttributeValue(null, NAME));
+ configuredOp.setContractName(reader.getAttributeValue(null, SERVICE));
+ configuredOp.setUnresolved(true);
+
+ // Read policies
+ policyProcessor.readPolicies(configuredOp, reader);
+
+ //Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && OPERATION_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return configuredOp;
+ }
+
+ public void write(ConfiguredOperation configuredOperation, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ // Write an <operation>
+ writer.writeStartElement(Constants.SCA11_NS, OPERATION);
+ policyProcessor.writePolicyAttributes(configuredOperation, writer);
+
+ writer.writeAttribute(NAME, configuredOperation.getName());
+ if ( configuredOperation.getContractName() != null ) {
+ writer.writeAttribute(SERVICE, configuredOperation.getContractName());
+ }
+ writer.writeEndElement();
+ }
+
+ public void resolve(ConfiguredOperation configuredOperation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ }
+
+ public QName getArtifactType() {
+ return OPERATION_QNAME;
+ }
+
+ public Class<ConfiguredOperation> getModelType() {
+ return ConfiguredOperation.class;
+ }
+
+}
+
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java
new file mode 100644
index 0000000000..0c88a01b19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants used in SCA assembly XML files.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension
+ */
+public interface Constants {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ String COMPONENT_TYPE = "componentType";
+ QName COMPONENT_TYPE_QNAME = new QName(SCA11_NS, COMPONENT_TYPE);
+
+ String SERVICE = "service";
+ QName SERVICE_QNAME = new QName(SCA11_NS, SERVICE);
+
+ String REFERENCE = "reference";
+ QName REFERENCE_QNAME = new QName(SCA11_NS, REFERENCE);
+
+ String PROPERTY = "property";
+ QName PROPERTY_QNAME = new QName(SCA11_NS, PROPERTY);
+
+ String COMPOSITE = "composite";
+ QName COMPOSITE_QNAME = new QName(SCA11_NS, COMPOSITE);
+
+ String INCLUDE = "include";
+ QName INCLUDE_QNAME = new QName(SCA11_NS, INCLUDE);
+
+ String COMPONENT = "component";
+ QName COMPONENT_QNAME = new QName(SCA11_NS, COMPONENT);
+
+ String WIRE = "wire";
+ QName WIRE_QNAME = new QName(SCA11_NS, WIRE);
+
+ String OPERATION = "operation";
+ QName OPERATION_QNAME = new QName(SCA11_NS, OPERATION);
+
+ String CALLBACK = "callback";
+ QName CALLBACK_QNAME = new QName(SCA11_NS, CALLBACK);
+
+ String IMPLEMENTATION_COMPOSITE = "implementation.composite";
+ QName IMPLEMENTATION_COMPOSITE_QNAME = new QName(SCA11_NS, IMPLEMENTATION_COMPOSITE);
+
+ String IMPLEMENTATION = "implementation";
+ QName IMPLEMENTATION_QNAME = new QName(SCA11_NS, IMPLEMENTATION);
+
+ String BINDING_SCA = "binding.sca";
+ QName BINDING_SCA_QNAME = new QName(Constants.SCA11_NS, BINDING_SCA);
+
+ String EXTENSION = "extensions";
+ QName EXTENSION_QNAME = new QName(Constants.SCA11_NS, EXTENSION);
+
+ String NAME = "name";
+ String VALUE = "value";
+ QName VALUE_QNAME = new QName(SCA11_NS, VALUE);
+
+ String POLICY_SET_ATTACHMENT = "policySetAttachment";
+ QName POLICY_SET_ATTACHMENT_QNAME = new QName(SCA11_NS, POLICY_SET_ATTACHMENT);
+
+ String TARGET_NAMESPACE = "targetNamespace";
+ String LOCAL = "local";
+ String AUTOWIRE = "autowire";
+ String NONOVERRIDABLE = "nonOverridable";
+ String REPLACE = "replace";
+ String REQUIRES = "requires";
+ QName REQUIRES_QNAME = new QName(SCA11_NS, REQUIRES);
+ String INTENTS = "intents";
+
+ String POLICY_SETS = "policySets";
+ String PROMOTE = "promote";
+ String TARGET = "target";
+ String WIRED_BY_IMPL = "wiredByImpl";
+ String MULTIPLICITY = "multiplicity";
+ String TYPE = "type";
+ String ELEMENT = "element";
+ String MANY = "many";
+ String MUST_SUPPLY = "mustSupply";
+ String SOURCE = "source";
+ String FILE = "file";
+ String URI = "uri";
+ String ZERO_ONE = "0..1";
+ String ZERO_N = "0..n";
+ String ONE_ONE = "1..1";
+ String ONE_N = "1..n";
+
+ String SERVER_AUTHENTICATION = "serverAuthentication";
+ QName SERVER_AUTHENTICATION_INTENT = new QName(SCA11_NS, SERVER_AUTHENTICATION);
+ String SERVER_AUTHENTICATION_TRANSPORT = "serverAuthentication.transport";
+ QName SERVER_AUTHENTICATION_TRANSPORT_INTENT = new QName(SCA11_NS, SERVER_AUTHENTICATION_TRANSPORT);
+ String SERVER_AUTHENTICATION_MESSAGE = "serverAuthentication.message";
+ QName SERVER_AUTHENTICATION_MESSAGE_INTENT = new QName(SCA11_NS, SERVER_AUTHENTICATION_MESSAGE);
+
+ String CLIENT_AUTHENTICATION = "clientAuthentication";
+ QName CLIENT_AUTHENTICATION_INTENT = new QName(SCA11_NS, CLIENT_AUTHENTICATION);
+ String CLIENT_AUTHENTICATION_TRANSPORT = "clientAuthentication.transport";
+ QName CLIENT_AUTHENTICATION_TRANSPORT_INTENT = new QName(SCA11_NS, CLIENT_AUTHENTICATION_TRANSPORT);
+ String CLIENT_AUTHENTICATION_MESSAGE = "clientAuthentication.message";
+ QName CLIENT_AUTHENTICATION_MESSAGE_INTENT = new QName(SCA11_NS, CLIENT_AUTHENTICATION_MESSAGE);
+
+ String AUTHENTICATION = "authentication";
+ QName AUTHENTICATION_INTENT = new QName(SCA11_NS, AUTHENTICATION);
+
+ String MUTUAL_AUTHENTICATION = "mutualAuthentication";
+ QName MUTUAL_AUTHENTICATION_INTENT = new QName(SCA11_NS, MUTUAL_AUTHENTICATION);
+
+ String CONFIDENTIALITY = "confidentiality";
+ QName CONFIDENTIALITY_INTENT = new QName(SCA11_NS, CONFIDENTIALITY);
+ String CONFIDENTIALITY_TRANSPORT = "confidentiality.transport";
+ QName CONFIDENTIALITY_TRANSPORT_INTENT = new QName(SCA11_NS, CONFIDENTIALITY_TRANSPORT);
+ String CONFIDENTIALITY_MESSAGE = "confidentiality.message";
+ QName CONFIDENTIALITY_MESSAGE_INTENT = new QName(SCA11_NS, CONFIDENTIALITY_MESSAGE);
+
+ String INTEGRITY = "integrity";
+ QName INTEGRITY_INTENT = new QName(SCA11_NS, "INTEGRITY");
+ String INTEGRITY_TRANSPORT = "integrity.transport";
+ QName INTEGRITY_TRANSPORT_INTENT = new QName(SCA11_NS, INTEGRITY_TRANSPORT);
+ String INTEGRITY_MESSAGE = "integrity.message";
+ QName INTEGRITY_MESSAGE_INTENT = new QName(SCA11_NS, INTEGRITY_MESSAGE);
+
+ String AUTHORIZATION = "authorization";
+ QName AUTHORIZATION_INTENT = new QName(SCA11_NS, "INTEGRITY");
+ String AUTHORIZATION_FINE_GRAIN = "authorization.fineGrain";
+ QName AUTHORIZATION_FINE_GRAIN_INTENT = new QName(SCA11_NS, AUTHORIZATION_FINE_GRAIN);
+
+ String MANAGED_TRANSACTION = "managedTransaction";
+ QName MANAGED_TRANSACTION_INTENT = new QName(SCA11_NS, MANAGED_TRANSACTION);
+
+ String NO_MANAGED_TRANSACTION = "noManagedTransaction";
+ QName NO_MANAGED_TRANSACTION_INTENT = new QName(SCA11_NS, NO_MANAGED_TRANSACTION);
+
+ String MANAGED_TRANSACTION_LOCAL = "managedTransaction.local";
+ QName MANAGED_TRANSACTION_LOCAL_INTENT = new QName(SCA11_NS, MANAGED_TRANSACTION_LOCAL);
+
+ String MANAGED_TRANSACTION_GLOBAL = "managedTransaction.global";
+ QName MANAGED_TRANSACTION_GLOBAL_INTENT = new QName(SCA11_NS, MANAGED_TRANSACTION_GLOBAL);
+
+ String PROPAGATES_TRANSACTION = "propagatesTransaction";
+ QName PROPAGATES_TRANSACTION_INTENT = new QName(SCA11_NS, PROPAGATES_TRANSACTION);
+
+ String SUSPENDS_TRANSACTION = "suspendsTransaction";
+ QName SUSPENDS_TRANSACTION_INTENT = new QName(SCA11_NS, SUSPENDS_TRANSACTION);
+
+ String TRANSACTED_ONE_WAY = "transactedOneWay";
+ QName TRANSACTED_ONE_WAY_INTENT = new QName(SCA11_NS, TRANSACTED_ONE_WAY);
+
+ String IMMEDIATE_ONE_WAY = "immediateOneWay";
+ QName IMMEDIATE_ONE_WAY_INTENT = new QName(SCA11_NS, IMMEDIATE_ONE_WAY);
+
+ String NOLISTENER = "noListener";
+ QName NOLISTENER_INTENT = new QName(SCA11_NS, NOLISTENER);
+
+ String SOAP = "SOAP";
+ QName SOAP_INTENT = new QName(SCA11_NS, SOAP);
+ String SOAP11 = "SOAP.v1_1";
+ QName SOAP11_INTENT = new QName(SCA11_NS, SOAP11);
+ String SOAP12 = "SOAP.v1_2";
+ QName SOAP12_INTENT = new QName(SCA11_NS, SOAP12);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
new file mode 100644
index 0000000000..e6e172a44b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.Base;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Default Model Processor for beans.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultBeanModelProcessor<T> extends BaseAssemblyProcessor implements StAXArtifactProcessor<T> {
+
+ private QName artifactType;
+ private Class<T> modelClass;
+ private Object modelFactory;
+ private Method factoryMethod;
+ private Map<String, Method> setterMethods = new HashMap<String, Method>();
+ private Map<String, Method> getterMethods = new HashMap<String, Method>();
+
+ public DefaultBeanModelProcessor(FactoryExtensionPoint modeFactories,
+ QName artifactType,
+ Class<T> modelClass,
+ Object modelFactory) {
+ super(modeFactories, null);
+ this.artifactType = artifactType;
+ this.modelClass = modelClass;
+ this.modelFactory = modelFactory;
+
+ // Introspect the factory class and bean model class
+ if (modelFactory != null) {
+
+ // Find the model create method
+ for (Method method: modelFactory.getClass().getMethods()) {
+ if (method.getName().startsWith("create") && method.getReturnType() == modelClass) {
+ factoryMethod = method;
+ break;
+ }
+ }
+ }
+
+ // Index the bean's setter methods
+ for (Method method: modelClass.getMethods()) {
+ Method getter;
+ String name = method.getName();
+ if (name.startsWith("set") && name.length() > 3) {
+
+ // Get the corresponding getter method
+ try {
+ getter = modelClass.getMethod("get" + name.substring(3));
+ } catch (Exception e) {
+ getter = null;
+ continue;
+ }
+
+ // Get the property name
+ name = name.substring(3);
+ if (name.length() > 1) {
+ if (!name.toUpperCase().equals(name)) {
+ name = name.substring(0, 1).toLowerCase() + name.substring(1);
+ }
+ }
+ } else {
+ continue;
+ }
+
+ // Map an uppercase property name to a lowercase attribute name
+ if (name.toUpperCase().equals(name)) {
+ name = name.toLowerCase();
+ }
+
+ // Trim trailing _ from property names
+ if (name.endsWith("_")) {
+ name = name.substring(0, name.length()-1);
+ }
+ setterMethods.put(name, method);
+ getterMethods.put(name, getter);
+ }
+ }
+
+ public T read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ // Read an element
+ try {
+
+ // Create a new instance of the model
+ Object model;
+ if (modelFactory != null) {
+ // Invoke the factory create method
+ model = factoryMethod.invoke(modelFactory);
+ } else {
+ // Invoke the model bean class default constructor
+ model = modelClass.newInstance();
+ }
+
+ // Initialize the bean properties with the attributes found in the
+ // XML element
+ for (int i = 0, n = reader.getAttributeCount(); i < n; i++) {
+ String attributeName = reader.getAttributeLocalName(i);
+ Method setter = setterMethods.get(attributeName);
+ if (setter != null) {
+ String value = null;
+ if (attributeName.equals("uri")){
+ value = getURIString(reader, "uri");
+ } else {
+ value = reader.getAttributeValue(i);
+ }
+ setter.invoke(model, value);
+ }
+ }
+
+ // Read policies
+ policyProcessor.readPolicies(model, reader);
+
+ // FIXME read extension elements
+
+ // By default mark the model object unresolved
+ if (model instanceof Base) {
+ ((Base)model).setUnresolved(true);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && artifactType.equals(reader.getName())) {
+ break;
+ }
+ }
+ return (T) model;
+
+ } catch (Exception e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(context.getMonitor(), "ContributionReadException", reader, ce);
+ throw ce;
+ }
+ }
+
+ public void write(T bean, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ try {
+ // Write the bean properties as attributes
+ List<XAttr> attrs = new ArrayList<XAttr>();
+ for (Map.Entry<String, Method> entry: getterMethods.entrySet()) {
+ if (entry.getValue().getReturnType() == String.class) {
+ String value = (String)entry.getValue().invoke(bean);
+ attrs.add(new XAttr(entry.getKey(), value));
+ }
+ }
+
+ // Write element
+ writeStart(writer, artifactType.getNamespaceURI(), artifactType.getLocalPart(),
+ policyProcessor.writePolicies(bean), new XAttr(null, attrs));
+
+ writeEnd(writer);
+
+ } catch (Exception e) {
+ ContributionWriteException ce = new ContributionWriteException(e);
+ error(context.getMonitor(), "ContributionWriteException", writer, ce);
+ throw ce;
+ }
+ }
+
+ public void resolve(T bean, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Resolve and merge the component type associated with an
+ // implementation model
+ if (bean instanceof Implementation) {
+ Implementation implementation = (Implementation)bean;
+ String uri = implementation.getURI();
+ if (uri != null) {
+ int d = uri.lastIndexOf('.');
+ if (d != -1) {
+ uri = uri.substring(0, d) + ".componentType";
+
+ // Resolve the component type
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setURI(uri);
+ componentType.setUnresolved(true);
+
+ componentType = resolver.resolveModel(ComponentType.class, componentType, context);
+ if (componentType != null && !componentType.isUnresolved()) {
+
+ // We found a component type, merge it into the implementation model
+ implementation.getServices().addAll(componentType.getServices());
+ implementation.getReferences().addAll(componentType.getReferences());
+ implementation.getProperties().addAll(componentType.getProperties());
+
+ if (implementation instanceof PolicySubject &&
+ componentType instanceof PolicySubject ) {
+ PolicySubject policiedImpl = (PolicySubject)implementation;
+ PolicySubject policiedCompType = (PolicySubject)componentType;
+
+ if ( policiedImpl.getPolicySets() != null) {
+ policiedImpl.getPolicySets().addAll(policiedCompType.getPolicySets());
+ }
+ if (policiedImpl.getRequiredIntents() != null) {
+ policiedImpl.getRequiredIntents().addAll(policiedCompType.getRequiredIntents());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Mark the model resolved
+ if (bean instanceof Base) {
+ ((Base)bean).setUnresolved(false);
+ }
+ }
+
+ public QName getArtifactType() {
+ return artifactType;
+ }
+
+ public Class<T> getModelType() {
+ return modelClass;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java
new file mode 100644
index 0000000000..d128897df0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.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.sca.assembly.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ */
+public class EndpointProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<Endpoint> {
+ private final static String ENDPOINT = "endpoint";
+ private final static QName ENDPOINT_QNAME = new QName(Constants.SCA11_TUSCANY_NS, ENDPOINT);
+
+ private ExtensionPointRegistry registry;
+
+ public EndpointProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+
+ super(modelFactories(registry), extensionProcessor);
+ this.registry = registry;
+ }
+
+ /**
+ * Returns the model factory extension point to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) {
+ return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ }
+
+ public QName getArtifactType() {
+ return ENDPOINT_QNAME;
+ }
+
+ public Endpoint read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
+ reader.nextTag();
+ }
+ Object model = extensionProcessor.read(reader, context);
+ if (model instanceof Composite) {
+ Composite composite = (Composite)model;
+ Component component = composite.getComponents().get(0);
+ ComponentService service = component.getServices().get(0);
+ Binding binding = service.getBindings().get(0);
+ endpoint.setComponent(component);
+ endpoint.setService(service);
+ endpoint.setBinding(binding);
+ }
+ return endpoint;
+ }
+
+ public void write(Endpoint model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // writeStart(writer, ENDPOINT_QNAME);
+ extensionProcessor.write(wrap(model), writer, context);
+ // writeEnd(writer);
+ }
+
+ private Composite wrap(Endpoint endpoint) {
+ try {
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(ENDPOINT_QNAME);
+ composite.setLocal(false);
+ if (endpoint.getComponent() != null) {
+ Component component = (Component)endpoint.getComponent().clone();
+ component.setImplementation(null);
+ composite.getComponents().add(component);
+ component.getReferences().clear();
+ component.getServices().clear();
+ if (endpoint.getService() != null) {
+ ComponentService service = (ComponentService)endpoint.getService().clone();
+ component.getServices().add(service);
+ service.getBindings().clear();
+ service.setInterfaceContract(endpoint.getComponentServiceInterfaceContract());
+ if (endpoint.getBinding() != null) {
+ Binding binding = (Binding)endpoint.getBinding().clone();
+ service.getBindings().add(binding);
+ }
+ }
+ }
+ return composite;
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+ public Class<Endpoint> getModelType() {
+ return Endpoint.class;
+ }
+
+ public void resolve(Endpoint model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java
new file mode 100644
index 0000000000..eda90c9d44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.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.assembly.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ */
+public class EndpointReferenceProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<EndpointReference> {
+ private final static String ENDPOINT_REFERENCE = "endpointReference";
+ private final static QName ENDPOINT_REFERENCE_QNAME = new QName(Constants.SCA11_TUSCANY_NS, ENDPOINT_REFERENCE);
+
+ private ExtensionPointRegistry registry;
+
+ public EndpointReferenceProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+
+ super(modelFactories(registry), extensionProcessor);
+ this.registry = registry;
+ }
+
+ /**
+ * Returns the model factory extension point to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) {
+ return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ }
+
+ public QName getArtifactType() {
+ return ENDPOINT_REFERENCE_QNAME;
+ }
+
+ public EndpointReference read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
+ reader.nextTag();
+ }
+ Object model = extensionProcessor.read(reader, context);
+ if (model instanceof Composite) {
+ Composite composite = (Composite)model;
+ Component component = composite.getComponents().get(0);
+ ComponentReference reference = component.getReferences().get(0);
+ Binding binding = reference.getBindings().get(0);
+ endpointReference.setComponent(component);
+ endpointReference.setReference(reference);
+ reference.getEndpointReferences().add(endpointReference);
+ endpointReference.setBinding(binding);
+
+ // set up the EPR so that resolution will happen
+ // at wire creation time if needs be
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ endpointReference.setTargetEndpoint(endpoint);
+
+ if (reference.getTargets().size() > 0){
+ // create a dummy endpoint with the URI set so that
+ // the endpoint registry will be consulted
+ endpoint.setUnresolved(true);
+ endpoint.setURI(reference.getTargets().get(0).getName());
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
+ endpointReference.setUnresolved(true);
+ } else {
+ endpoint.setUnresolved(false);
+ endpoint.setBinding(reference.getBindings().get(0));
+ endpointReference.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ endpointReference.setUnresolved(false);
+ }
+ }
+ return endpointReference;
+ }
+
+ public void write(EndpointReference model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ extensionProcessor.write(wrap(model), writer, context);
+ }
+
+ private Composite wrap(EndpointReference endpointReference) {
+ try {
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(ENDPOINT_REFERENCE_QNAME);
+ composite.setLocal(false);
+ Component component = (Component)endpointReference.getComponent().clone();
+ composite.getComponents().add(component);
+ component.getReferences().clear();
+ component.getServices().clear();
+ ComponentReference reference = (ComponentReference)endpointReference.getReference().clone();
+ component.getReferences().add(reference);
+ reference.getBindings().clear();
+ Binding binding = (Binding)endpointReference.getBinding().clone();
+ reference.getBindings().add(binding);
+ //reference.setInterfaceContract(endpointReference.getInterfaceContract());
+ if (endpointReference.getStatus() != EndpointReference.Status.RESOLVED_BINDING){
+ ComponentService service = assemblyFactory.createComponentService();
+ service.setName(endpointReference.getTargetEndpoint().getURI());
+ reference.getTargets().clear();
+ reference.getTargets().add(service);
+ }
+ return composite;
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+ public Class<EndpointReference> getModelType() {
+ return EndpointReference.class;
+ }
+
+ public void resolve(EndpointReference model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java
new file mode 100644
index 0000000000..0391acc676
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.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 org.apache.tuscany.sca.assembly.xml;
+
+/**
+ * Constants for resource bundle names
+ * @tuscany.spi.extension
+ */
+public interface Messages {
+ String RESOURCE_BUNDLE = "org.apache.tuscany.sca.assembly.xml.assembly-xml-validation-messages";
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
new file mode 100644
index 0000000000..286f109f44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static org.apache.tuscany.sca.assembly.xml.Constants.POLICY_SETS;
+import static org.apache.tuscany.sca.assembly.xml.Constants.REQUIRES;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+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.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A Policy Attach Point processor.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class PolicySubjectProcessor extends BaseStAXArtifactProcessor {
+
+ private PolicyFactory policyFactory;
+
+ public PolicySubjectProcessor(PolicyFactory policyFactory) {
+ this.policyFactory = policyFactory;
+ }
+
+ public PolicySubjectProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ }
+
+ /**
+ * Read policy intents associated with an operation.
+ * @param subject
+ * @param operation
+ * @param reader
+ */
+ private void readIntents(Object subject, Operation operation, XMLStreamReader reader) {
+ if (!(subject instanceof PolicySubject))
+ return;
+ PolicySubject intentAttachPoint = (PolicySubject)subject;
+ String value = reader.getAttributeValue(null, REQUIRES);
+ if (value != null) {
+ List<Intent> requiredIntents = intentAttachPoint.getRequiredIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ if (operation != null) {
+ //FIXME Don't we need to handle intent specification
+ // on an operation basis?
+ //intent.getOperations().add(operation);
+ }
+ requiredIntents.add(intent);
+ }
+ }
+ }
+
+ /**
+ * Reads policy intents and policy sets associated with an operation.
+ * @param subject
+ * @param operation
+ * @param reader
+ */
+ public void readPolicies(Object subject, Operation operation, XMLStreamReader reader) {
+ readIntents(subject, operation, reader);
+ readPolicySets(subject, operation, reader);
+ }
+
+ /**
+ * Reads policy intents and policy sets.
+ * @param subject
+ * @param reader
+ */
+ public void readPolicies(Object subject, XMLStreamReader reader) {
+ readPolicies(subject, null, reader);
+ }
+
+ /**
+ * Reads policy sets associated with an operation.
+ * @param subject
+ * @param operation
+ * @param reader
+ */
+ private void readPolicySets(Object subject, Operation operation, XMLStreamReader reader) {
+ if (!(subject instanceof PolicySubject)) {
+ return;
+ }
+ PolicySubject policySubject = (PolicySubject)subject;
+ String value = reader.getAttributeValue(null, POLICY_SETS);
+ if (value != null) {
+ List<PolicySet> policySets = policySubject.getPolicySets();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(qname);
+ if (operation != null) {
+ //FIXME Don't we need to handle policySet specification
+ // on an operation basis?
+ //policySet.getOperations().add(operation);
+ }
+ policySets.add(policySet);
+ }
+ }
+ }
+
+ /**
+ * Write policies
+ * @param subject
+ * @return
+ */
+ XAttr writePolicies(Object subject) throws XMLStreamException {
+ return writePolicies(subject, (Operation)null);
+ }
+
+ /**
+ * Write policies
+ * @param subject
+ * @return
+ */
+ public void writePolicyAttributes(Object subject, XMLStreamWriter writer) throws XMLStreamException {
+ writePolicyAttributes(subject, (Operation)null, writer);
+ }
+
+ /**
+ * Write policies associated with an operation
+ * @param subject
+ * @param operation
+ * @return
+ */
+ XAttr writePolicies(Object subject, Operation operation) {
+ List<XAttr> attrs =new ArrayList<XAttr>();
+ attrs.add(writeIntents(subject, operation));
+ attrs.add(writePolicySets(subject, operation));
+ return new XAttr(null, attrs);
+ }
+
+ /**
+ * Write policies
+ * @param subject
+ * @return
+ */
+ public void writePolicyAttributes(Object subject, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
+ XAttr attr = writePolicies(subject, operation);
+ attr.write(writer);
+ }
+
+ /**
+ * Write policy intents associated with an operation.
+ * @param subject
+ * @param operation
+ */
+ private XAttr writeIntents(Object subject, Operation operation) {
+ if (!(subject instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject intentAttachPoint = (PolicySubject)subject;
+ List<QName> qnames = new ArrayList<QName>();
+ for (Intent intent: intentAttachPoint.getRequiredIntents()) {
+ qnames.add(intent.getName());
+ }
+ return new XAttr(Constants.REQUIRES, qnames);
+ }
+
+ /**
+ * Write policy sets associated with an operation.
+ * @param subject
+ * @param operation
+ */
+ private XAttr writePolicySets(Object subject, Operation operation) {
+ if (!(subject instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject policySetAttachPoint = (PolicySubject)subject;
+ List<QName> qnames = new ArrayList<QName>();
+ for (PolicySet policySet: policySetAttachPoint.getPolicySets()) {
+ qnames.add(policySet.getName());
+ }
+ return new XAttr(Constants.POLICY_SETS, qnames);
+ }
+
+ public void resolvePolicies(Object subject, ModelResolver resolver, ProcessorContext context) {
+ if ( subject instanceof PolicySubject ) {
+ PolicySubject policySetAttachPoint = (PolicySubject)subject;
+
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ Intent resolvedIntent = null;
+
+ if ( policySetAttachPoint.getRequiredIntents() != null && policySetAttachPoint.getRequiredIntents().size() > 0 ) {
+ for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) {
+ resolvedIntent = resolver.resolveModel(Intent.class, intent, context);
+ requiredIntents.add(resolvedIntent);
+ }
+ policySetAttachPoint.getRequiredIntents().clear();
+ policySetAttachPoint.getRequiredIntents().addAll(requiredIntents);
+ }
+
+ if ( policySetAttachPoint.getPolicySets() != null && policySetAttachPoint.getPolicySets().size() > 0 ) {
+ List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
+ PolicySet resolvedPolicySet = null;
+ for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
+ resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet, context);
+ resolvedPolicySets.add(resolvedPolicySet);
+ }
+ policySetAttachPoint.getPolicySets().clear();
+ policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java
new file mode 100644
index 0000000000..28f4f9fb25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.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.sca.assembly.xml;
+
+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.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A processor to read the XML that describes the SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class SCABindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SCABinding> {
+ private static final String NAME = "name";
+ private static final String URI = "uri";
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static final String BINDING_SCA = "binding.sca";
+ private static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA);
+
+ private PolicyFactory policyFactory;
+ private SCABindingFactory scaBindingFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private PolicyFactory intentAttachPointTypeFactory;
+
+
+ public SCABindingProcessor(FactoryExtensionPoint modelFactories) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
+ policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
+ }
+
+ public QName getArtifactType() {
+ return BINDING_SCA_QNAME;
+ }
+
+ public Class<SCABinding> getModelType() {
+ return SCABinding.class;
+ }
+
+ public SCABinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ SCABinding scaBinding = scaBindingFactory.createSCABinding();
+ ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
+ bindingType.setType(getArtifactType());
+ bindingType.setUnresolved(true);
+ ((PolicySubject)scaBinding).setExtensionType(bindingType);
+
+ // Read policies
+ policyProcessor.readPolicies(scaBinding, reader);
+
+ // Read binding name
+ String name = reader.getAttributeValue(null, NAME);
+ if (name != null) {
+ scaBinding.setName(name);
+ }
+
+ // Read binding URI
+ String uri = getURIString(reader, URI);
+ if (uri != null) {
+ scaBinding.setURI(uri);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && BINDING_SCA_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+ return scaBinding;
+ }
+
+ public void resolve(SCABinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ policyProcessor.resolvePolicies(model, resolver, context);
+ }
+
+ public void write(SCABinding scaBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <binding.sca>
+ writer.writeStartElement(SCA11_NS, BINDING_SCA);
+ policyProcessor.writePolicyAttributes(scaBinding, writer);
+
+ // Write binding name
+ if (scaBinding.getName() != null) {
+ writer.writeAttribute(NAME, scaBinding.getName());
+ }
+
+ // Write binding URI
+ if (scaBinding.getURI() != null) {
+ writer.writeAttribute(URI, scaBinding.getURI());
+ }
+
+ writer.writeEndElement();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
new file mode 100644
index 0000000000..af59324c7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.definitions.xml;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+
+/**
+ * Default implementation of an extension point for XML definitionss.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultDefinitionsExtensionPoint implements DefinitionsExtensionPoint {
+ private static final Logger logger = Logger.getLogger(DefaultDefinitionsExtensionPoint.class.getName());
+ private static final URI DEFINITIONS_URI = URI.create("META-INF/definitions.xml");
+ private ExtensionPointRegistry registry;
+ private MonitorFactory monitorFactory;
+ private Set<URL> documents = new HashSet<URL>();
+ private List<Definitions> definitions = new ArrayList<Definitions>();
+ private boolean documentsLoaded;
+ private boolean loaded;
+
+ public DefaultDefinitionsExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ this.monitorFactory = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
+ }
+
+ public void addDefinitionsDocument(URL url) {
+ documents.add(url);
+ }
+
+ public void removeDefinitionsDocument(URL url) {
+ documents.remove(url);
+ }
+
+ /**
+ * Load definitions declarations from META-INF/services/
+ * org.apache.tuscany.sca.contribution.processor.Definitions files
+ */
+ private synchronized void loadDefinitionsDocuments() {
+ if (documentsLoaded)
+ return;
+
+ // Get the definitions declarations
+ Collection<ServiceDeclaration> definitionsDeclarations;
+ try {
+ definitionsDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DEFINITIONS_FILE);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Find each definitions
+ for (ServiceDeclaration definitionsDeclaration : definitionsDeclarations) {
+ URL url = definitionsDeclaration.getResource(definitionsDeclaration.getClassName());
+ if (url == null) {
+ throw new IllegalArgumentException(definitionsDeclaration.getClassName() + " cannot be found");
+ }
+ documents.add(url);
+ }
+
+ documentsLoaded = true;
+ }
+
+ public synchronized List<Definitions> getDefinitions() {
+ if (!loaded) {
+ loadDefinitionsDocuments();
+ URLArtifactProcessorExtensionPoint processors =
+ registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ URLArtifactProcessor<Definitions> processor = processors.getProcessor(Definitions.class);
+ ProcessorContext context = new ProcessorContext(monitorFactory.createMonitor());
+ for (URL url : documents) {
+ Definitions def;
+ try {
+ def = processor.read(null, DEFINITIONS_URI, url, context);
+ definitions.add(def);
+ } catch (ContributionReadException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ loaded = true;
+ }
+ return definitions;
+ }
+
+ public void addDefinitions(Definitions def) {
+ this.definitions.add(def);
+ }
+
+ public void removeDefinitions(Definitions def) {
+ this.definitions.remove(def);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
new file mode 100644
index 0000000000..d0a42be34e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.definitions.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.definitions.DefinitionsFactory;
+import org.apache.tuscany.sca.definitions.util.DefinitionsUtil;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * A SCA Definitions Document processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsDocumentProcessor implements URLArtifactProcessor<Definitions> {
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private XMLInputFactory inputFactory;
+ private DefinitionsFactory definitionsFactory;
+
+
+
+ /**
+ * Constructs a new SCADefinitions processor.
+ *
+ * @param modelFactories
+ * @param staxProcessor
+ */
+ public DefinitionsDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> staxProcessor) {
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ this.definitionsFactory = modelFactories.getFactory(DefinitionsFactory.class);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public Definitions read(URL contributionURL, final URI uri, final URL url, ProcessorContext context) throws ContributionReadException {
+ InputStream urlStream = null;
+ Monitor monitor = context.getMonitor();
+ monitor.pushContext("Definitions: " + url);
+ try {
+ // Allow privileged access to open URL stream. Add FilePermission to added to security
+ // policy file.
+ try {
+ urlStream = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() {
+ public InputStream run() throws IOException {
+ return IOHelper.openStream(url);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ error(monitor, "PrivilegedActionException", url, (IOException)e.getException());
+ throw (IOException)e.getException();
+ }
+
+ //urlStream = createInputStream(url);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
+ ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
+ Definitions definitions = definitionsFactory.createDefinitions();
+ int event = reader.getEventType();
+ while (reader.hasNext()) {
+ event = reader.next();
+
+ // We only deal with the root element
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ // QName name = reader.getName();
+ Object model = extensionProcessor.read(reader, context);
+ if (model instanceof Definitions) {
+ DefinitionsUtil.aggregate((Definitions)model, definitions, monitor);
+ return definitions;
+ } else {
+ error(monitor, "ContributionReadException", model, null);
+ }
+ }
+ }
+
+ return definitions;
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ } finally {
+
+ try {
+ if (urlStream != null) {
+ urlStream.close();
+ urlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+
+ monitor.popContext();
+ }
+ }
+
+ public void resolve(Definitions scaDefinitions, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ extensionProcessor.resolve(scaDefinitions, resolver, context);
+ }
+
+ public String getArtifactType() {
+ return "/META-INF/definitions.xml";
+ }
+
+ public Class<Definitions> getModelType() {
+ return Definitions.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java
new file mode 100644
index 0000000000..3058b1f5b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.definitions.xml;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.definitions.Definitions;
+
+/**
+ * An extension point for built-in SCA intent/policySet definition files
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DefinitionsExtensionPoint {
+ String DEFINITIONS_FILE = "org.apache.tuscany.sca.definitions.xml.Definitions";
+
+ /**
+ * Add a definitions document
+ *
+ * @param url the URL of the definitions
+ */
+ void addDefinitionsDocument(URL url);
+
+ /**
+ * Remove a definitions document
+ *
+ * @param url the URL of the definitions
+ */
+ void removeDefinitionsDocument(URL url);
+
+ /**
+ * @param definitions
+ */
+ void addDefinitions(Definitions definitions);
+ /**
+ * @param definitions
+ */
+ void removeDefinitions(Definitions definitions);
+
+ /**
+ * Get the list of definitions
+ * @return A list of definitions
+ */
+ List<Definitions> getDefinitions();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
new file mode 100644
index 0000000000..0213713ced
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.definitions.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.definitions.DefinitionsFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Processor for SCA Definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Definitions> {
+ private ExtensionPointRegistry registry;
+ private StAXArtifactProcessorExtensionPoint processors;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private DefinitionsFactory definitionsFactory;
+ private PolicyFactory policyFactory;
+
+ public static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ public static final String BINDING = "binding";
+ public static final String IMPLEMENTATION = "implementation";
+ public static final String DEFINITIONS = "definitions";
+ public static final QName DEFINITIONS_QNAME = new QName(SCA11_NS, DEFINITIONS);
+ public static final String TARGET_NAMESPACE = "targetNamespace";
+ public static final String NAME = "name";
+
+ public DefinitionsProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ this.registry = registry;
+ this.extensionProcessor = extensionProcessor;
+ this.processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.definitionsFactory = factoryExtensionPoint.getFactory(DefinitionsFactory.class);
+ this.policyFactory = factoryExtensionPoint.getFactory(PolicyFactory.class);
+ }
+
+ public Definitions read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ QName name = null;
+ Definitions definitions = null;
+ String targetNamespace = null;
+
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (DEFINITIONS_QNAME.equals(name)) {
+ definitions = definitionsFactory.createDefinitions();
+ targetNamespace = getURIString(reader, TARGET_NAMESPACE);
+ definitions.setTargetNamespace(targetNamespace);
+ } else {
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof Intent) {
+ Intent intent = (Intent)extension;
+ intent.setName(new QName(targetNamespace, intent.getName().getLocalPart()));
+ definitions.getIntents().add(intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(targetNamespace, i.getName().getLocalPart()));
+ }
+ } else if (extension instanceof PolicySet) {
+ PolicySet policySet = (PolicySet)extension;
+ policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart()));
+ definitions.getPolicySets().add(policySet);
+ } else if (extension instanceof Binding) {
+ Binding binding = (Binding)extension;
+ definitions.getBindings().add(binding);
+ } else if (extension instanceof BindingType) {
+ definitions.getBindingTypes().add((BindingType)extension);
+ } else if (extension instanceof ImplementationType) {
+ definitions.getImplementationTypes().add((ImplementationType)extension);
+ } else if (extension instanceof ExternalAttachment) {
+ definitions.getExternalAttachments().add((ExternalAttachment)extension);
+ }
+ }
+ break;
+ }
+ }
+
+ case XMLStreamConstants.CHARACTERS:
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+ if (DEFINITIONS_QNAME.equals(name)) {
+ return definitions;
+ }
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return definitions;
+ }
+
+ public void write(Definitions definitions, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ writeStartDocument(writer, SCA11_NS, DEFINITIONS, new XAttr(TARGET_NAMESPACE, definitions.getTargetNamespace()));
+
+ for (Intent policyIntent : definitions.getIntents()) {
+ extensionProcessor.write(policyIntent, writer, context);
+ }
+
+ for (PolicySet policySet : definitions.getPolicySets()) {
+ extensionProcessor.write(policySet, writer, context);
+ }
+
+ for (Binding binding : definitions.getBindings()) {
+ extensionProcessor.write(binding, writer, context);
+ }
+
+ for (BindingType bindingType : definitions.getBindingTypes()) {
+ extensionProcessor.write(bindingType, writer, context);
+ }
+
+ for (ImplementationType implType : definitions.getImplementationTypes()) {
+ extensionProcessor.write(implType, writer, context);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(Definitions scaDefns, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // start by adding all of the top level artifacts into the resolver as there
+ // are many cross artifact references in a definitions file and we don't want
+ // to be dependent on the order things appear
+
+ List<Intent> intents = new ArrayList<Intent>();
+ List<PolicySet> policySets = new ArrayList<PolicySet>();
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+
+ for (Intent intent : scaDefns.getIntents()) {
+ intents.add(intent);
+ resolver.addModel(intent, context);
+ for (Intent i : intent.getQualifiedIntents()) {
+ intents.add(i);
+ resolver.addModel(i, context);
+ }
+ }
+
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ if (policySet.getReferencedPolicySets().isEmpty()) {
+ policySets.add(policySet);
+ } else {
+ referredPolicySets.add(policySet);
+ }
+
+ resolver.addModel(policySet, context);
+ }
+
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ resolver.addModel(bindingType, context);
+ }
+
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ resolver.addModel(implType, context);
+ }
+
+ // now resolve everything to ensure that any references between
+ // artifacts are satisfied
+
+ for (Intent policyIntent : intents)
+ extensionProcessor.resolve(policyIntent, resolver, context);
+
+ for (PolicySet policySet : policySets)
+ extensionProcessor.resolve(policySet, resolver, context);
+
+ for (PolicySet policySet : referredPolicySets)
+ extensionProcessor.resolve(policySet, resolver, context);
+
+ for (Binding binding : scaDefns.getBindings()) {
+ extensionProcessor.resolve(binding, resolver, context);
+ }
+
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ extensionProcessor.resolve(bindingType, resolver, context);
+ if (processors.getProcessor(bindingType.getType()) == null){
+ Monitor.error(context.getMonitor(),
+ this,
+ "org.apache.tuscany.sca.definitions.xml.definitions-xml-validation-messages",
+ "BindingTypeNotFound",
+ bindingType.getType().toString());
+ }
+ }
+
+ for (ImplementationType implementationType : scaDefns.getImplementationTypes()) {
+ extensionProcessor.resolve(implementationType, resolver, context);
+ if (processors.getProcessor(implementationType.getType()) == null){
+ Monitor.error(context.getMonitor(),
+ this,
+ "org.apache.tuscany.sca.definitions.xml.definitions-xml-validation-messages",
+ "ImplementationTypeNotFound",
+ implementationType.getType().toString());
+ }
+ }
+
+
+ // Flat intentMap structure by creating a policySet for each one
+ List<PolicySet> copy = new ArrayList<PolicySet>(scaDefns.getPolicySets());
+ for (PolicySet policySet : copy) {
+ // Add PolicySets to model based on qualified intents. The policy builder will be responsible for assigning
+ // the correct policy set.
+ // For example, ManagedTransactionPolicySet will result in:
+ // ManagedTransactionPolicySet (original PolicySet, must exist for matching at build time)
+ // ManagedTransactionPolicySet.managedTransaction.global
+ // ManagedTransactionPolicySet.managedTransaction.local
+
+ //process intent maps
+ for(IntentMap intentMap : policySet.getIntentMaps()) {
+ for(Qualifier qualifier : intentMap.getQualifiers()) {
+ // remove = true;
+
+ PolicySet qualifiedPolicySet = policyFactory.createPolicySet();
+ qualifiedPolicySet.setAppliesTo(policySet.getAppliesTo());
+ qualifiedPolicySet.setAppliesToXPathExpression(policySet.getAttachToXPathExpression());
+ qualifiedPolicySet.setAttachTo(policySet.getAttachTo());
+ qualifiedPolicySet.setAttachToXPathExpression(policySet.getAttachToXPathExpression());
+
+ String qualifiedLocalName = policySet.getName().getLocalPart() + "." + qualifier.getIntent().getName().getLocalPart();
+ qualifiedPolicySet.setName(new QName(policySet.getName().getNamespaceURI(), qualifiedLocalName));
+ qualifiedPolicySet.getProvidedIntents().clear();
+ qualifiedPolicySet.getProvidedIntents().add(qualifier.getIntent());
+ qualifiedPolicySet.getPolicies().clear();
+ qualifiedPolicySet.getPolicies().addAll(qualifier.getPolicies());
+
+ scaDefns.getPolicySets().add(qualifiedPolicySet);
+ }
+ }
+
+// if(remove) {
+// scaDefns.getPolicySets().remove(policySet);
+// }
+ }
+ }
+
+ public QName getArtifactType() {
+ return DEFINITIONS_QNAME;
+ }
+
+ public Class<Definitions> getModelType() {
+ return Definitions.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java
new file mode 100644
index 0000000000..38cc4a9de2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.definitions.xml;
+
+/**
+ * Constants for resource bundle names
+ */
+public interface Messages {
+ String RESOURCE_BUNDLE = "org.apache.tuscany.sca.definitions.xml.definitions-xml-validation-messages";
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
new file mode 100644
index 0000000000..70c71c5f1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.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.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of BindingType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindingTypeProcessor extends ExtensionTypeProcessor {
+
+ public BindingTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ super(policyFactory, extensionProcessor);
+ }
+
+ public BindingTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ super(modelFactories.getFactory(PolicyFactory.class), extensionProcessor);
+ }
+
+ public QName getArtifactType() {
+ return BINDING_TYPE_QNAME;
+ }
+
+ @Override
+ protected ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (extnType instanceof BindingType) {
+ BindingType bindingType = (BindingType)extnType;
+ return resolver.resolveModel(BindingType.class, bindingType, context);
+ } else {
+ return extnType;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
new file mode 100644
index 0000000000..95d8e67bf7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+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.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of ExtensionType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class ExtensionTypeProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<ExtensionType>, PolicyConstants {
+
+ private PolicyFactory policyFactory;
+
+
+ protected abstract ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException;
+
+ public ExtensionTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ this.policyFactory = policyFactory;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public ExtensionType read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ QName extType = getArtifactType();
+ QName type = getQName(reader, "type");
+
+ if (type != null) {
+ ExtensionType extensionType = null;
+ if (BINDING_TYPE_QNAME.equals(extType)) {
+ extensionType = policyFactory.createBindingType();
+ } else if (IMPLEMENTATION_TYPE_QNAME.equals(extType)) {
+ extensionType = policyFactory.createImplementationType();
+ } else {
+ error(context.getMonitor(), "UnrecognizedExtensionType", reader, type);
+ return null;
+ //throw new ContributionReadException("Unrecognized ExtensionType - " + type);
+ }
+ extensionType.setType(type);
+ extensionType.setUnresolved(true);
+
+ readAlwaysProvidedIntents(extensionType, reader);
+ readMayProvideIntents(extensionType, reader);
+ return extensionType;
+
+ } else {
+ error(context.getMonitor(), "RequiredAttributeMissing", reader, extType);
+ //throw new ContributionReadException("Required attribute '" + TYPE +
+ //"' missing from BindingType Definition");
+ }
+ return null;
+ }
+
+ private void readAlwaysProvidedIntents(ExtensionType extnType, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, ALWAYS_PROVIDES);
+ if (value != null) {
+ List<Intent> alwaysProvided = extnType.getAlwaysProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ alwaysProvided.add(intent);
+ }
+ }
+ }
+
+ private void readMayProvideIntents(ExtensionType extnType, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, MAY_PROVIDE);
+ if (value != null) {
+ List<Intent> mayProvide = extnType.getMayProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ mayProvide.add(intent);
+ }
+ }
+ }
+
+ public void write(ExtensionType extnType, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write an <sca:bindingType or sca:implementationType>
+ if (extnType instanceof BindingType) {
+ writer.writeStartElement(SCA11_NS, BINDING_TYPE);
+ } else if (extnType instanceof ImplementationType) {
+ writer.writeStartElement(SCA11_NS, IMPLEMENTATION_TYPE);
+ }
+
+ writeAlwaysProvidesIntentsAttribute(extnType, writer);
+ writeMayProvideIntentsAttribute(extnType, writer);
+
+ writer.writeEndElement();
+ }
+
+ private void writeMayProvideIntentsAttribute(ExtensionType extnType, XMLStreamWriter writer)
+ throws XMLStreamException {
+ StringBuffer sb = new StringBuffer();
+ for (Intent intent : extnType.getMayProvidedIntents()) {
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ sb.append(intent.getName().getPrefix() + COLON + intent.getName().getLocalPart());
+ sb.append(WHITE_SPACE);
+ }
+
+ if (sb.length() > 0) {
+ writer.writeAttribute(MAY_PROVIDE, sb.toString());
+ }
+ }
+
+ private void writeAlwaysProvidesIntentsAttribute(ExtensionType extnType, XMLStreamWriter writer)
+ throws XMLStreamException {
+ StringBuffer sb = new StringBuffer();
+ for (Intent intent : extnType.getAlwaysProvidedIntents()) {
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ sb.append(intent.getName().getPrefix() + COLON + intent.getName().getLocalPart());
+ sb.append(WHITE_SPACE);
+ }
+
+ if (sb.length() > 0) {
+ writer.writeAttribute(ALWAYS_PROVIDES, sb.toString());
+
+ }
+ }
+
+ public void resolve(ExtensionType extnType, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (extnType != null && extnType.isUnresolved()) {
+ resolveAlwaysProvidedIntents(extnType, resolver, context);
+ resolveMayProvideIntents(extnType, resolver, context);
+ extnType.setUnresolved(false);
+ //resolveExtensionType(extnType, resolver);
+ }
+ }
+
+ private void resolveAlwaysProvidedIntents(ExtensionType extensionType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> alwaysProvided = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getAlwaysProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ providedIntent = resolver.resolveModel(Intent.class, providedIntent, context);
+ if (!providedIntent.isUnresolved()) {
+ alwaysProvided.add(providedIntent);
+ } else {
+ error(context.getMonitor(), "AlwaysProvidedIntentNotFound", resolver, providedIntent, extensionType);
+ //throw new ContributionResolveException("Always Provided Intent - " + providedIntent
+ //+ " not found for ExtensionType "
+ //+ extensionType);
+ }
+ } else {
+ alwaysProvided.add(providedIntent);
+ }
+ }
+ extensionType.getAlwaysProvidedIntents().clear();
+ extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
+ }
+ }
+
+ private void resolveMayProvideIntents(ExtensionType extensionType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> mayProvide = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getMayProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ providedIntent = resolver.resolveModel(Intent.class, providedIntent, context);
+ if (!providedIntent.isUnresolved()) {
+ mayProvide.add(providedIntent);
+ } else {
+ error(context.getMonitor(), "MayProvideIntentNotFound", resolver, providedIntent, extensionType);
+ //throw new ContributionResolveException("May Provide Intent - " + providedIntent
+ //+ " not found for ExtensionType "
+ //+ extensionType);
+ }
+ } else {
+ mayProvide.add(providedIntent);
+ }
+ }
+ extensionType.getMayProvidedIntents().clear();
+ extensionType.getMayProvidedIntents().addAll(mayProvide);
+ }
+ }
+
+ public Class<ExtensionType> getModelType() {
+ return ExtensionType.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExternalAttachmentProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExternalAttachmentProcessor.java
new file mode 100644
index 0000000000..2cf9d02ee4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExternalAttachmentProcessor.java
@@ -0,0 +1,296 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.xml;
+
+import static org.apache.tuscany.sca.policy.xml.PolicyConstants.SCA11_NS;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.tuscany.sca.common.xml.xpath.XPathHelper;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Processor for handling XML models of ExternalAttachment definitions
+ *
+ * @version $Rev: 961010 $ $Date: 2010-07-06 13:34:54 -0700 (Tue, 06 Jul 2010) $
+ */
+public class ExternalAttachmentProcessor extends BaseStAXArtifactProcessor
+ implements StAXArtifactProcessor<ExternalAttachment>, PolicyConstants {
+
+
+ private PolicyFactory policyFactory;
+ private XPathHelper xpathHelper;
+
+ public ExternalAttachmentProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ this.xpathHelper = XPathHelper.getInstance(registry);
+ }
+
+ public Class<ExternalAttachment> getModelType() {
+ return ExternalAttachment.class;
+ }
+
+ public void resolve(ExternalAttachment attachment, ModelResolver resolver,
+ ProcessorContext context) throws ContributionResolveException {
+ if (attachment != null && attachment.isUnresolved()) {
+ resolveIntents(attachment, resolver, context);
+ resolvePolicySets(attachment, resolver, context);
+
+ attachment.setUnresolved(false);
+ }
+
+ }
+
+ private void resolvePolicySets(ExternalAttachment attachment,
+ ModelResolver resolver, ProcessorContext context) {
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+ for (PolicySet referredPolicySet : attachment.getPolicySets()) {
+ if (referredPolicySet.isUnresolved()) {
+ PolicySet resolved = resolver.resolveModel(PolicySet.class, referredPolicySet, context);
+ if (!resolved.isUnresolved() || resolved != referredPolicySet) {
+ referredPolicySets.add(resolved);
+ } else {
+ error(context.getMonitor(), "ReferredPolicySetNotFound", attachment, referredPolicySet, attachment);
+ return;
+ }
+ } else {
+ referredPolicySets.add(referredPolicySet);
+ }
+ }
+ attachment.getPolicySets().clear();
+ attachment.getPolicySets().addAll(referredPolicySets);
+
+ }
+
+ private void resolveIntents(ExternalAttachment attachment,
+ ModelResolver resolver, ProcessorContext context) {
+ if (attachment != null) {
+ //resolve all provided intents
+ List<Intent> providedIntents = new ArrayList<Intent>();
+ for (Intent providedIntent : attachment.getIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, providedIntent, context);
+ if (!resolved.isUnresolved() || resolved != providedIntent) {
+ providedIntents.add(resolved);
+ } else {
+ error(context.getMonitor(), "ProvidedIntentNotFound", attachment, providedIntent, attachment);
+ return;
+ }
+ } else {
+ providedIntents.add(providedIntent);
+ }
+ }
+ attachment.getIntents().clear();
+ attachment.getIntents().addAll(providedIntents);
+ }
+
+ }
+
+ public QName getArtifactType() {
+ return EXTERNAL_ATTACHMENT_QNAME;
+ }
+
+ public ExternalAttachment read(XMLStreamReader reader, ProcessorContext context)
+ throws ContributionReadException, XMLStreamException {
+ ExternalAttachment attachment = policyFactory.createExternalAttachment();
+
+ readPolicySets(attachment, reader);
+ readIntents(attachment, reader, context);
+ readAttachTo(attachment, reader, context);
+
+ return attachment;
+ }
+
+ private void readIntents(ExternalAttachment attachment,
+ XMLStreamReader reader, ProcessorContext context) {
+ String value = reader.getAttributeValue(null, INTENTS);
+ if (value != null) {
+ List<Intent> intents = attachment.getIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ intents.add(intent);
+ }
+ }
+
+ }
+
+ private void readAttachTo(ExternalAttachment attachment,
+ XMLStreamReader reader, ProcessorContext context) {
+ Monitor monitor = context.getMonitor();
+
+ String attachTo = reader.getAttributeValue(null, ATTACH_TO);
+ if ( attachTo != null ) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext nsContext = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
+ path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(nsContext));
+
+ attachTo = PolicyXPathFunction.normalize(attachTo,getSCAPrefix(nsContext));
+ XPathExpression expression = xpathHelper.compile(path, nsContext, attachTo);
+ attachment.setAttachTo(attachTo);
+ attachment.setAttachToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", attachment, ce);
+ }
+ }
+
+ }
+
+ private String getSCAPrefix(NamespaceContext nsContext) {
+
+ Iterator<String> iter = nsContext.getPrefixes(SCA11_NS);
+ while (iter.hasNext()) {
+ String prefix = iter.next();
+ if (!prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
+ return prefix;
+ }
+ }
+
+ return "__sca";
+ }
+ /**
+ * Reads policy sets associated with an external attachment element.
+ * @param subject
+ * @param operation
+ * @param reader
+ */
+ private void readPolicySets(ExternalAttachment attachment, XMLStreamReader reader) {
+
+
+ String value = reader.getAttributeValue(null, POLICY_SETS);
+ if (value != null) {
+ List<PolicySet> policySets = attachment.getPolicySets();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(qname);
+ policySets.add(policySet);
+ }
+ }
+ }
+ public void write(ExternalAttachment attachment, XMLStreamWriter writer,
+ ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ writePolicySets(attachment, writer, context);
+ writeIntents(attachment, writer, context);
+ writeAttachTo(attachment, writer, context);
+
+ }
+
+ private void writeAttachTo(ExternalAttachment attachment,
+ XMLStreamWriter writer, ProcessorContext context) throws XMLStreamException {
+ if ( attachment.getAttachTo() != null ) {
+ writer.writeAttribute(PolicyConstants.ATTACH_TO, attachment.getAttachTo());
+ }
+
+ }
+
+ private void writeIntents(ExternalAttachment attachment,
+ XMLStreamWriter writer, ProcessorContext context) throws XMLStreamException {
+ if (!attachment.getIntents().isEmpty()) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent intent : attachment.getIntents()) {
+ sb.append(getQualifiedName(intent.getName(), writer));
+ sb.append(" ");
+ }
+ // Remove the last space
+ sb.deleteCharAt(sb.length() - 1);
+ writer.writeAttribute(PolicyConstants.INTENTS, sb.toString());
+ }
+
+ }
+
+ private void writePolicySets(ExternalAttachment attachment,
+ XMLStreamWriter writer, ProcessorContext context) throws XMLStreamException {
+ if ( !attachment.getPolicySets().isEmpty()) {
+ StringBuffer sb = new StringBuffer();
+ for (PolicySet ps : attachment.getPolicySets()) {
+ sb.append(getQualifiedName(ps.getName(), writer));
+ sb.append(" ");
+ }
+ // Remove the last space
+ sb.deleteCharAt(sb.length() - 1);
+ writer.writeAttribute(PolicyConstants.POLICY_SETS, sb.toString());
+ }
+
+ }
+
+ private String getQualifiedName(QName name, XMLStreamWriter writer) throws XMLStreamException {
+ String local = name.getLocalPart();
+ String prefix = writer.getPrefix(name.getNamespaceURI());
+ if (prefix != null && prefix.length() > 0) {
+ return prefix + ':' + local;
+ } else {
+ return local;
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
new file mode 100644
index 0000000000..ec4e17385f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.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.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Processor for handling XML models of ImplementationType meta data definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationTypeProcessor extends ExtensionTypeProcessor {
+
+ public ImplementationTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ super(policyFactory, extensionProcessor);
+ }
+
+ public ImplementationTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ super(modelFactories.getFactory(PolicyFactory.class), extensionProcessor);
+ }
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_TYPE_QNAME;
+ }
+
+ @Override
+ protected ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (extnType instanceof ImplementationType) {
+ ImplementationType implType = (ImplementationType)extnType;
+ return resolver.resolveModel(ImplementationType.class, implType, context);
+ } else {
+ return extnType;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
new file mode 100644
index 0000000000..c7eb7f49d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
@@ -0,0 +1,446 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.StringTokenizer;
+
+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.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.Intent.Type;
+
+/**
+ * Processor for handling XML models of PolicyIntent definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntentProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Intent>,
+ PolicyConstants {
+
+ private PolicyFactory policyFactory;
+
+
+ public IntentProcessor(FactoryExtensionPoint modelFactories) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ }
+
+ public IntentProcessor(PolicyFactory policyFactory) {
+ this.policyFactory = policyFactory;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ private void warn(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.WARNING,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public Intent read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Intent intent = null;
+ String intentLocalName = reader.getAttributeValue(null, NAME);
+ if (intentLocalName == null) {
+ error(context.getMonitor(), "IntentNameMissing", reader);
+ return null;
+ }
+
+ String intentType = reader.getAttributeValue(null, INTENT_TYPE);
+ if (intentType == null) {
+ intentType = Intent.Type.interaction.name();
+ }
+
+ intent = policyFactory.createIntent();
+
+ // [rfeng] the target namespace is not available, set the local part for now
+ // This will be changed in the definitions processor
+ intent.setName(new QName(intentLocalName));
+ intent.setType(Type.valueOf(intentType));
+
+ readRequiredIntents(intent, reader, context);
+ readExcludedIntents(intent, reader);
+
+ readConstrainedTypes(intent, reader);
+
+ String mutuallyExclusiveString = reader.getAttributeValue(null, MUTUALLY_EXCLUSIVE);
+ if (mutuallyExclusiveString != null &&
+ mutuallyExclusiveString.equals("true")){
+ intent.setMutuallyExclusive(true);
+ } else {
+ intent.setMutuallyExclusive(false);
+ }
+
+ Intent current = intent;
+ int event = reader.getEventType();
+ QName name = null;
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (DESCRIPTION_QNAME.equals(name)) {
+ String text = reader.getElementText();
+ if (text != null) {
+ text = text.trim();
+ }
+ current.setDescription(text);
+ } else if (INTENT_QUALIFIER_QNAME.equals(name)) {
+ String qualifierName = reader.getAttributeValue(null, NAME);
+ String defaultQ = reader.getAttributeValue(null, DEFAULT);
+ boolean isDefault = defaultQ == null ? false : Boolean.parseBoolean(defaultQ);
+ String qualifiedIntentName = intentLocalName + QUALIFIER + qualifierName;
+ Intent qualified = policyFactory.createIntent();
+ qualified.setUnresolved(false);
+ qualified.setType(intent.getType());
+ qualified.setName(new QName(qualifiedIntentName));
+ if (isDefault) {
+ if (intent.getDefaultQualifiedIntent() == null){
+ intent.setDefaultQualifiedIntent(qualified);
+ } else {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "MultipleDefaultQualifiers",
+ intent.getName().toString());
+ }
+ }
+
+ // check that the qualifier is unique
+ if ( !intent.getQualifiedIntents().contains(qualified)){
+ intent.getQualifiedIntents().add(qualified);
+ } else {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "QualifierIsNotUnique",
+ intent.getName().toString(),
+ qualifierName);
+ }
+
+ qualified.setQualifiableIntent(intent);
+ current = qualified;
+ }
+ break;
+ }
+ case END_ELEMENT: {
+ name = reader.getName();
+ if (INTENT_QUALIFIER_QNAME.equals(name)) {
+ current = intent;
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ // REVIEW: [rfeng] What's going to happen if there is only one qualified intent
+ if (intent.getQualifiedIntents().size() == 1) {
+ intent.setDefaultQualifiedIntent(intent.getQualifiedIntents().get(0));
+ }
+
+ // set all qualified intents as excluding one another if the qualifiable
+ // intent is set to be mutually exclusive
+ if (intent.isMutuallyExclusive()){
+ for (Intent qualifiedIntent : intent.getQualifiedIntents()){
+ for (Intent excludedIntent : intent.getQualifiedIntents()){
+ if (qualifiedIntent != excludedIntent){
+ qualifiedIntent.getExcludedIntents().add(excludedIntent);
+ }
+ }
+ }
+ }
+
+ return intent;
+ }
+
+ public void write(Intent intent, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // Write an <sca:intent>
+ writer.writeStartElement(PolicyConstants.SCA11_NS, INTENT);
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ writer.writeAttribute(PolicyConstants.NAME, intent.getName().getPrefix() + COLON
+ + intent.getName().getLocalPart());
+ if (intent.getRequiredIntents() != null && intent.getRequiredIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent requiredIntents : intent.getRequiredIntents()) {
+ sb.append(requiredIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(PolicyConstants.REQUIRES, sb.toString());
+ }
+
+ if (intent.getExcludedIntents() != null && intent.getExcludedIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent excludedIntents : intent.getExcludedIntents()) {
+ sb.append(excludedIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(PolicyConstants.EXCLUDES, sb.toString());
+ }
+
+ if (intent.getConstrainedTypes() != null && intent.getConstrainedTypes().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (ExtensionType contrainedArtifact : intent.getConstrainedTypes()) {
+ sb.append(contrainedArtifact.getType().getPrefix());
+ sb.append(':').append(contrainedArtifact.getType().getLocalPart());
+ sb.append(" ");
+ }
+ writer.writeAttribute(CONSTRAINS, sb.toString());
+ }
+
+ if (intent.getDescription() != null && intent.getDescription().length() > 0) {
+ writer.writeStartElement(PolicyConstants.SCA11_NS, DESCRIPTION);
+ writer.writeCData(intent.getDescription());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ private void resolveContrainedTypes(Intent intent, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ Collection<ExtensionType> resolvedTypes = new HashSet<ExtensionType>();
+ for (ExtensionType extensionType : intent.getConstrainedTypes()) {
+ if (ExtensionType.BINDING_BASE.equals(extensionType.getType()) || ExtensionType.IMPLEMENTATION_BASE
+ .equals(extensionType.getType())) {
+ // HACK: Mark sca:binding and sca:implementation as resolved
+ extensionType.setUnresolved(false);
+ resolvedTypes.add(extensionType);
+ } else {
+ ExtensionType resolved = resolver.resolveModel(ExtensionType.class, extensionType, context);
+ if (!resolved.isUnresolved() || resolved != extensionType) {
+ resolvedTypes.add(resolved);
+ } else {
+ warn(context.getMonitor(), "ConstrainedTypeNotFound", intent, extensionType, intent);
+ }
+ }
+ }
+ intent.getConstrainedTypes().clear();
+ intent.getConstrainedTypes().addAll(resolvedTypes);
+ }
+
+ private void resolveProfileIntent(Intent intent, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ Monitor monitor = context.getMonitor();
+ // FIXME: Need to check for cyclic references first i.e an A requiring B
+ // and then B requiring A...
+ if (intent != null && !intent.getRequiredIntents().isEmpty()) {
+ // resolve all required intents
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ for (Intent required : intent.getRequiredIntents()) {
+ if (required.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, required, context);
+ // At this point, when the required intent is not resolved, it does not mean
+ // its undeclared, chances are that their dependency are not resolved yet.
+ // Lets try to resolve them first.
+ if (resolved.isUnresolved()) {
+ if (((resolved).getRequiredIntents()).contains(intent)) {
+ error(monitor, "CyclicReferenceFound", resolver, required, intent);
+ return;
+ }
+ }
+
+ if (!resolved.isUnresolved() || resolved != required) {
+ requiredIntents.add(resolved);
+ } else {
+ error(monitor, "RequiredIntentNotFound", resolver, required, intent);
+ return;
+ //throw new ContributionResolveException("Required Intent - " + requiredIntent
+ //+ " not found for Intent " + policyIntent);
+ }
+ } else {
+ requiredIntents.add(required);
+ }
+ }
+ intent.getRequiredIntents().clear();
+ intent.getRequiredIntents().addAll(requiredIntents);
+ }
+ }
+
+ private void resolveQualifiedIntent(Intent qualifed, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ if (qualifed != null) {
+ //resolve the qualifiable intent
+ Intent parent = qualifed.getQualifiableIntent();
+ if (parent == null) {
+ return;
+ }
+ if (parent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, parent, context);
+ // At this point, when the qualifiable intent is not resolved, it does not mean
+ // its undeclared, chances are that their dependency are not resolved yet.
+ // Lets try to resolve them first.
+
+ if (!resolved.isUnresolved() || resolved != qualifed) {
+ qualifed.setQualifiableIntent(resolved);
+ } else {
+ error(context.getMonitor(), "QualifiableIntentNotFound", resolver, parent, qualifed);
+ //throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
+ //+ " not found for Intent " + policyIntent);
+ }
+ }
+ }
+ }
+
+ public void resolve(Intent intent, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ if (intent != null && intent.isUnresolved()) {
+ resolveProfileIntent(intent, resolver, context);
+ resolveExcludedIntents(intent, resolver, context);
+ resolveQualifiedIntent(intent, resolver, context);
+ resolveContrainedTypes(intent, resolver, context);
+ intent.setUnresolved(false);
+ }
+ }
+
+ public QName getArtifactType() {
+ return POLICY_INTENT_QNAME;
+ }
+
+ private void readConstrainedTypes(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
+ String value = reader.getAttributeValue(null, CONSTRAINS);
+ if (value != null) {
+ List<ExtensionType> constrainedTypes = policyIntent.getConstrainedTypes();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ ExtensionType extensionType = policyFactory.createExtensionType();
+ extensionType.setType(qname);
+ constrainedTypes.add(extensionType);
+ }
+ }
+ }
+
+ private void readRequiredIntents(Intent intent, XMLStreamReader reader, ProcessorContext context) {
+ String value = reader.getAttributeValue(null, REQUIRES);
+ if (value != null) {
+ List<Intent> requiredIntents = intent.getRequiredIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent required = policyFactory.createIntent();
+ required.setName(qname);
+ required.setUnresolved(true);
+ requiredIntents.add(required);
+ }
+
+ // Check that a profile intent does not have "." in its name
+ if (requiredIntents.size() > 0) {
+ if (intent.getName().getLocalPart().contains(".")){
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "ProfileIntentNameWithPeriod",
+ intent.getName().toString());
+ }
+ }
+ }
+ }
+
+ private void readExcludedIntents(Intent intent, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, EXCLUDES);
+ if (value != null) {
+ List<Intent> excludedIntents = intent.getExcludedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent excluded = policyFactory.createIntent();
+ excluded.setName(qname);
+ excluded.setUnresolved(true);
+ excludedIntents.add(excluded);
+ }
+ }
+ }
+
+ private void resolveExcludedIntents(Intent policyIntent, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (policyIntent != null) {
+ // resolve all excluded intents
+ List<Intent> excludedIntents = new ArrayList<Intent>();
+ for (Intent excludedIntent : policyIntent.getExcludedIntents()) {
+ if (excludedIntent.isUnresolved()) {
+ Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent, context);
+ if (!resolvedExcludedIntent.isUnresolved() || resolvedExcludedIntent != excludedIntent) {
+ excludedIntents.add(resolvedExcludedIntent);
+ } else {
+ error(context.getMonitor(), "ExcludedIntentNotFound", resolver, excludedIntent, policyIntent);
+ return;
+ //throw new ContributionResolveException("Excluded Intent " + excludedIntent
+ //+ " not found for intent " + policyIntent);
+ }
+ } else {
+ excludedIntents.add(excludedIntent);
+ }
+ }
+ policyIntent.getExcludedIntents().clear();
+ policyIntent.getExcludedIntents().addAll(excludedIntents);
+ }
+ }
+
+ public Class<Intent> getModelType() {
+ return Intent.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java
new file mode 100644
index 0000000000..ee8b5274cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+/**
+ * Constants for resource bundle names
+ */
+public interface Messages {
+ String RESOURCE_BUNDLE = "org.apache.tuscany.sca.policy.xml.policy-xml-validation-messages";
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
new file mode 100644
index 0000000000..2498f3df67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.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.policy.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * constants related to policy framework
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PolicyConstants {
+ String WHITE_SPACE = " ";
+ String COLON = ":";
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ String INTENT = "intent";
+ String POLICY_SET = "policySet";
+ String POLICY_SET_REFERENCE = "policySetReference";
+ String INTENT_MAP = "intentMap";
+ String NAME = "name";
+ String TARGET_NAMESPACE = "targetNamespace";
+ String SCA_DEFINITIONS = "definitions";
+ String CONSTRAINS = "constrains";
+ String DESCRIPTION = "description";
+ String PROVIDES = "provides";
+ String APPLIES_TO = "appliesTo";
+ String ATTACH_TO = "attachTo";
+ String ALWAYS_APPLIES_TO = "alwaysAppliesTo";
+ String QUALIFIER = ".";
+ String INTENT_QUALIFIER = "qualifier";
+ String INTENT_MAP_QUALIFIER = "qualifier";
+ String REQUIRES = "requires";
+ String EXCLUDES = "excludes";
+ String DEFAULT = "default";
+ String EXTERNAL_ATTACHMENT = "externalAttachment";
+ String INTENTS = "intents";
+ String POLICY_SETS = "policySets";
+ String MUTUALLY_EXCLUSIVE = "mutuallyExclusive";
+
+ String ALWAYS_PROVIDES = "alwaysProvides";
+ String MAY_PROVIDE = "mayProvide";
+ String INTENT_TYPE = "intentType";
+ String IMPLEMENTATION_TYPE = "implementationType";
+ String BINDING_TYPE = "bindingType";
+ QName IMPLEMENTATION_TYPE_QNAME = new QName(SCA11_NS, IMPLEMENTATION_TYPE);
+ QName BINDING_TYPE_QNAME = new QName(SCA11_NS, BINDING_TYPE);
+ String BINDING = "binding";
+ String IMPLEMENTATION = "implementation";
+
+ QName POLICY_INTENT_QNAME = new QName(SCA11_NS, INTENT);
+ QName POLICY_SET_QNAME = new QName(SCA11_NS, POLICY_SET);
+ QName POLICY_INTENT_MAP_QNAME = new QName(SCA11_NS, INTENT_MAP);
+ QName SCA_DEFINITIONS_QNAME = new QName(SCA11_NS, SCA_DEFINITIONS);
+ QName DESCRIPTION_QNAME = new QName(SCA11_NS, DESCRIPTION);
+ QName POLICY_INTENT_MAP_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_MAP_QUALIFIER);
+ QName POLICY_SET_REFERENCE_QNAME = new QName(SCA11_NS, POLICY_SET_REFERENCE);
+ QName INTENT_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_QUALIFIER);
+ QName EXTERNAL_ATTACHMENT_QNAME = new QName(SCA11_NS, EXTERNAL_ATTACHMENT);
+ String QUALIFIED_INTENT_CONSTRAINS_ERROR = " - Qualified Intents must not specify 'constrains' attribute";
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
new file mode 100644
index 0000000000..68475a208b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
@@ -0,0 +1,572 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.policy.xml.PolicyConstants.SCA11_NS;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.tuscany.sca.common.xml.xpath.XPathHelper;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Processor for handling XML models of PolicySet definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<PolicySet>,
+ PolicyConstants {
+
+ private PolicyFactory policyFactory;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private XPathHelper xpathHelper;
+
+ // private XPathFactory xpathFactory;
+
+ public PolicySetProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor<Object> extensionProcessor) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.xpathHelper = XPathHelper.getInstance(registry);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public PolicySet read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException,
+ XMLStreamException {
+ PolicySet policySet = null;
+ Monitor monitor = context.getMonitor();
+ String policySetName = reader.getAttributeValue(null, NAME);
+ String appliesTo = reader.getAttributeValue(null, APPLIES_TO);
+ if (policySetName == null || appliesTo == null) {
+ if (policySetName == null)
+ error(monitor, "PolicySetNameMissing", reader);
+ if (appliesTo == null)
+ error(monitor, "PolicySetAppliesToMissing", reader);
+ return policySet;
+ }
+
+ policySet = policyFactory.createPolicySet();
+ policySet.setName(new QName(policySetName));
+
+ //TODO: with 1.0 version of specs the applies to xpath is given related to the immediate
+ //parent whereas the runtime evaluates the xpath aginst the composite element. What the runtime
+ //is doing is what the future version of the specs could be tending towards. When that happens
+ //this 'if' must be deleted
+ if (appliesTo != null && !appliesTo.startsWith("/")) {
+ appliesTo = "//" + appliesTo;
+ }
+
+ policySet.setAppliesTo(appliesTo);
+
+ if (appliesTo != null) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext nsContext = xpathHelper.getNamespaceContext(appliesTo, reader.getNamespaceContext());
+ // path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(context));
+ XPathExpression expression = xpathHelper.compile(path, nsContext, appliesTo);
+ policySet.setAppliesToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", policySet, ce);
+ //throw ce;
+ }
+ }
+
+ String attachTo = reader.getAttributeValue(null, ATTACH_TO);
+ if (attachTo != null) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext nsContext = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
+ path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(nsContext));
+
+ attachTo = PolicyXPathFunction.normalize(attachTo,getSCAPrefix(nsContext));
+ XPathExpression expression = xpathHelper.compile(path, nsContext, attachTo);
+ policySet.setAttachTo(attachTo);
+ policySet.setAttachToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", policySet, ce);
+ //throw ce;
+ }
+
+ }
+
+ readProvidedIntents(policySet, reader);
+
+ int event = reader.getEventType();
+ QName name = null;
+ reader.next();
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+ Intent mappedIntent = policyFactory.createIntent();
+ String provides = reader.getAttributeValue(null, PROVIDES);
+ if (provides != null) {
+ mappedIntent.setName(getQName(reader, PROVIDES));
+ if (policySet.getProvidedIntents().contains(mappedIntent)) {
+ readIntentMap(reader, policySet, mappedIntent, context);
+ } else {
+ error(monitor, "IntentNotSpecified", policySet, policySetName);
+ }
+ } else {
+ error(monitor, "IntentMapProvidesMissing", reader, policySetName);
+ }
+ } else if (POLICY_SET_REFERENCE_QNAME.equals(name)) {
+ PolicySet referredPolicySet = policyFactory.createPolicySet();
+ String referencename = reader.getAttributeValue(null, NAME);
+ if (referencename != null) {
+ referredPolicySet.setName(getQName(reader, NAME));
+ policySet.getReferencedPolicySets().add(referredPolicySet);
+ } else {
+ error(monitor, "PolicySetReferenceNameMissing", reader, policySetName);
+ }
+ } /*else if ( WS_POLICY_QNAME.equals(name) ) {
+ OMElement policyElement = loadElement(reader);
+ org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
+ policySet.getPolicies().add(wsPolicy);
+ } */else {
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ PolicyExpression exp = policyFactory.createPolicyExpression();
+ exp.setName(name);
+ exp.setPolicy(extension);
+ // check that all the policies in the policy set are
+ // expressed in the same language. Compare against the
+ // first expression we added
+ if ((policySet.getPolicies().size() > 0) && (!policySet.getPolicies().get(0).getName()
+ .equals(name))) {
+ error(monitor, "PolicyLanguageMissmatch", reader, policySet.getName(), policySet
+ .getPolicies().get(0).getName(), name);
+ } else {
+ policySet.getPolicies().add(exp);
+ }
+ }
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT) {
+ if (POLICY_SET_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return policySet;
+ }
+
+ private String getSCAPrefix(NamespaceContext nsContext) {
+
+ Iterator<String> iter = nsContext.getPrefixes(SCA11_NS);
+ while (iter.hasNext()) {
+ String prefix = iter.next();
+ if (!prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
+ return prefix;
+ }
+ }
+
+ return "__sca";
+ }
+
+ public void readIntentMap(XMLStreamReader reader, PolicySet policySet, Intent mappedIntent, ProcessorContext context)
+ throws ContributionReadException {
+ Monitor monitor = context.getMonitor();
+ QName name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+
+ IntentMap intentMap = policyFactory.createIntentMap();
+ QName intentName = getQName(reader, INTENT_MAP);
+ intentMap.setProvidedIntent(mappedIntent);
+
+ if (!policySet.getIntentMaps().contains(intentMap)) {
+ policySet.getIntentMaps().add(intentMap);
+ } else {
+ Monitor.error(context.getMonitor(), this, Messages.RESOURCE_BUNDLE, "IntentMapIsNotUnique", policySet
+ .getName().toString(), mappedIntent.getName().getLocalPart());
+ }
+
+ String qualifierName = null;
+ String qualfiedIntentName = null;
+ Intent qualifiedIntent = null;
+
+ Qualifier qualifier = null;
+
+ int event = reader.getEventType();
+ try {
+ reader.next();
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QUALIFIER_QNAME.equals(name)) {
+ qualifierName = getString(reader, NAME);
+ if (qualifierName != null) {
+ qualfiedIntentName =
+ mappedIntent.getName().getLocalPart() + QUALIFIER + qualifierName;
+ qualifiedIntent = policyFactory.createIntent();
+ qualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(),
+ qualfiedIntentName));
+ qualifier = policyFactory.createQualifier();
+ qualifier.setIntent(qualifiedIntent);
+ intentMap.getQualifiers().add(qualifier);
+
+ } else {
+ error(monitor, "QualifierNameMissing", reader, policySet.getName());
+ }
+ } else if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+ QName providedIntent = getQName(reader, PROVIDES);
+ if (qualifierName.equals(providedIntent.getLocalPart())) {
+ readIntentMap(reader, policySet, qualifiedIntent, context);
+ } else {
+ error(monitor,
+ "IntentMapDoesNotMatch",
+ providedIntent,
+ providedIntent,
+ qualifierName,
+ policySet);
+ //throw new ContributionReadException("Intent provided by IntentMap " +
+ //providedIntent + " does not match parent qualifier " + qualifierName +
+ //" in policyset - " + policySet);
+ }
+ } else {
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null && qualifier != null) {
+ PolicyExpression exp = policyFactory.createPolicyExpression();
+ exp.setName(name);
+ exp.setPolicy(extension);
+ qualifier.getPolicies().add(exp);
+ }
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT && POLICY_INTENT_MAP_QNAME.equals(reader.getName())) {
+ break;
+ }
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", reader, ce);
+ throw ce;
+ }
+ }
+ }
+
+ public void write(PolicySet policySet, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ // Write an <sca:policySet>
+ writer.writeStartElement(SCA11_NS, POLICY_SET);
+ writer.writeNamespace(policySet.getName().getPrefix(), policySet.getName().getNamespaceURI());
+ writer.writeAttribute(NAME, policySet.getName().getPrefix() + COLON + policySet.getName().getLocalPart());
+ writer.writeAttribute(APPLIES_TO, policySet.getAppliesTo());
+ writer.writeAttribute(ATTACH_TO, policySet.getAttachTo());
+
+ writeProvidedIntents(policySet, writer);
+
+ writer.writeEndElement();
+ }
+
+ private void readProvidedIntents(PolicySet policySet, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, PROVIDES);
+ if (value != null) {
+ List<Intent> providedIntents = policySet.getProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ providedIntents.add(intent);
+ }
+ }
+ }
+
+ private void writeProvidedIntents(PolicySet policySet, XMLStreamWriter writer) throws XMLStreamException {
+ if (!policySet.getProvidedIntents().isEmpty()) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent providedIntents : policySet.getProvidedIntents()) {
+ sb.append(getQualifiedName(providedIntents.getName(), writer));
+ sb.append(" ");
+ }
+ // Remove the last space
+ sb.deleteCharAt(sb.length() - 1);
+ writer.writeAttribute(PolicyConstants.PROVIDES, sb.toString());
+ }
+ }
+
+ private String getQualifiedName(QName name, XMLStreamWriter writer) throws XMLStreamException {
+ String local = name.getLocalPart();
+ String prefix = writer.getPrefix(name.getNamespaceURI());
+ if (prefix != null && prefix.length() > 0) {
+ return prefix + ':' + local;
+ } else {
+ return local;
+ }
+ }
+
+ private void resolvePolicies(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ boolean unresolved = false;
+ if (policySet != null) {
+ for (Object o : policySet.getPolicies()) {
+ extensionProcessor.resolve(o, resolver, context);
+ /*if ( o instanceof Policy && ((Policy)o).isUnresolved() ) {
+ unresolved = true;
+ }*/
+ }
+ policySet.setUnresolved(unresolved);
+ }
+ }
+
+ public QName getArtifactType() {
+ return POLICY_SET_QNAME;
+ }
+
+ public Class<PolicySet> getModelType() {
+ return PolicySet.class;
+ }
+
+ private void resolveProvidedIntents(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (policySet != null) {
+ //resolve all provided intents
+ List<Intent> providedIntents = new ArrayList<Intent>();
+ for (Intent providedIntent : policySet.getProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, providedIntent, context);
+ if (!resolved.isUnresolved() || resolved != providedIntent) {
+ providedIntents.add(resolved);
+ } else {
+ error(context.getMonitor(), "ProvidedIntentNotFound", policySet, providedIntent, policySet);
+ return;
+ //throw new ContributionResolveException("Provided Intent - " + providedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ } else {
+ providedIntents.add(providedIntent);
+ }
+ }
+ policySet.getProvidedIntents().clear();
+ policySet.getProvidedIntents().addAll(providedIntents);
+ }
+ }
+
+ private void resolveIntentsInMappedPolicies(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ Monitor monitor = context.getMonitor();
+ for (IntentMap intentMap : policySet.getIntentMaps()) {
+ Intent intent = intentMap.getProvidedIntent();
+ if (intent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, intent, context);
+ if (!resolved.isUnresolved() || resolved != intent) {
+ intentMap.setProvidedIntent(resolved);
+ } else {
+ error(monitor, "MappedIntentNotFound", policySet, intent, policySet);
+ return;
+ //throw new ContributionResolveException("Mapped Intent - " + mappedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ }
+ for (Qualifier qualifier : intentMap.getQualifiers()) {
+ intent = qualifier.getIntent();
+ if (intent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, intent, context);
+ if (!resolved.isUnresolved() || resolved != intent) {
+ qualifier.setIntent(resolved);
+ } else {
+ error(monitor, "MappedIntentNotFound", policySet, intent, policySet);
+ return;
+ //throw new ContributionResolveException("Mapped Intent - " + mappedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ }
+ for (PolicyExpression exp : qualifier.getPolicies()) {
+ // FIXME: How to resolve the policies?
+ }
+ }
+ // validate that the intent map has a qualifier for each
+ // intent qualifier. The above code has already checked that the
+ // qualifiers that are there are resolved
+ Intent providedIntent = intentMap.getProvidedIntent();
+ if (intentMap.getQualifiers().size() != providedIntent.getQualifiedIntents().size()) {
+ String missingQualifiers = "";
+ for (Intent loopQualifiedIntent : providedIntent.getQualifiedIntents()) {
+ boolean found = false;
+ for (Qualifier loopQualifier : intentMap.getQualifiers()) {
+ if (loopQualifier.getIntent().getName().equals(loopQualifiedIntent.getName())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ missingQualifiers += loopQualifiedIntent.getName().getLocalPart() + " ";
+ }
+ }
+ if (missingQualifiers.length() > 0) {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "IntentMapMissingQualifiers",
+ policySet.getName().toString(),
+ providedIntent.getName().getLocalPart(),
+ missingQualifiers);
+ }
+ }
+ }
+
+ }
+
+ private void resolveReferredPolicySets(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ if (referredPolicySet.isUnresolved()) {
+ PolicySet resolved = resolver.resolveModel(PolicySet.class, referredPolicySet, context);
+ if (!resolved.isUnresolved() || resolved != referredPolicySet) {
+ referredPolicySets.add(resolved);
+ } else {
+ error(context.getMonitor(), "ReferredPolicySetNotFound", policySet, referredPolicySet, policySet);
+ return;
+ //throw new ContributionResolveException("Referred PolicySet - " + referredPolicySet
+ //+ "not found for PolicySet - " + policySet);
+ }
+ } else {
+ referredPolicySets.add(referredPolicySet);
+ }
+ }
+ policySet.getReferencedPolicySets().clear();
+ policySet.getReferencedPolicySets().addAll(referredPolicySets);
+ }
+
+ private void includeReferredPolicySets(PolicySet policySet, PolicySet referredPolicySet) {
+ for (PolicySet furtherReferredPolicySet : referredPolicySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
+ }
+ policySet.getPolicies().addAll(referredPolicySet.getPolicies());
+ policySet.getIntentMaps().addAll(referredPolicySet.getIntentMaps());
+ }
+
+ public void resolve(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ if (policySet != null && policySet.isUnresolved()) {
+ resolveProvidedIntents(policySet, resolver, context);
+ resolveIntentsInMappedPolicies(policySet, resolver, context);
+ resolveReferredPolicySets(policySet, resolver, context);
+
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(policySet, referredPolicySet);
+ }
+
+ if (policySet.isUnresolved()) {
+ //resolve the policy attachments
+ resolvePolicies(policySet, resolver, context);
+
+ /*if ( !policySet.isUnresolved() ) {
+ resolver.addModel(policySet);
+ }*/
+ }
+
+ policySet.setUnresolved(false);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java
new file mode 100644
index 0000000000..8e2d7f9e60
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.xml;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The SCA-defined XPath function
+ */
+public class PolicyXPathFunction implements XPathFunction {
+ private static Logger logger = Logger.getLogger(PolicyXPathFunction.class.getName());
+
+ static final QName InterfaceRef = new QName(PolicyConstants.SCA11_NS, "InterfaceRef");
+ static final QName OperationRef = new QName(PolicyConstants.SCA11_NS, "OperationRef");
+ static final QName MessageRef = new QName(PolicyConstants.SCA11_NS, "MessageRef");
+ static final QName IntentRefs = new QName(PolicyConstants.SCA11_NS, "IntentRefs");
+ static final QName URIRef = new QName(PolicyConstants.SCA11_NS, "URIRef");
+
+ static final Set<QName> functions =
+ new HashSet<QName>(Arrays.asList(InterfaceRef, OperationRef, MessageRef, IntentRefs, URIRef));
+
+ private NamespaceContext namespaceContext;
+ private final QName functionName;
+
+ public PolicyXPathFunction(NamespaceContext namespaceContext, QName functionName) {
+ super();
+ this.namespaceContext = namespaceContext;
+ this.functionName = functionName;
+ }
+
+ private Node getContextNode(List args) {
+ if (args.size() >= 2) {
+ NodeList nodeList = (NodeList)args.get(1);
+ if (nodeList.getLength() > 0) {
+ return nodeList.item(0);
+ }
+ }
+ return null;
+ }
+
+ public Object evaluate(List args) throws XPathFunctionException {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(functionName + "(" + args + ")");
+ }
+
+ String arg = (String)args.get(0);
+ Node node = getContextNode(args);
+ /**
+ * If the xpath expression that contains the function does not select any nodes
+ * (eg IntentRefs('someIntent')), the context node passed in will be a Document.
+ * In this case we need to iterate over every Node in the Document and evaluate it.
+ *
+ * If the xpath expression does select nodes (eg //sca:component[IntentRefs('someIntent')])
+ * then xpath will call evaluate for each node and we only need to return the result for that
+ * node.
+ */
+ if ( node instanceof Document )
+ return evaluateDocument(arg, (Document)node);
+ else
+ return evaluateNode(arg, node);
+ }
+
+ public Object evaluateNode(String arg, Node node) {
+ if (InterfaceRef.equals(functionName)) {
+ return evaluateInterface(arg, node);
+ } else if (OperationRef.equals(functionName)) {
+ String[] params = arg.split("/");
+ if (params.length != 2) {
+ throw new IllegalArgumentException("Invalid argument: " + arg);
+ }
+ String interfaceName = params[0];
+ String operationName = params[1];
+ return evaluateOperation(interfaceName, operationName, node);
+ } else if (MessageRef.equals(functionName)) {
+ String[] params = arg.split("/");
+ if (params.length != 3) {
+ throw new IllegalArgumentException("Invalid argument: " + arg);
+ }
+ String interfaceName = params[0];
+ String operationName = params[1];
+ String messageName = params[2];
+ return evaluateMessage(interfaceName, operationName, messageName, node);
+ } else if (URIRef.equals(functionName)) {
+ return evaluateURI(arg, node);
+ } else if (IntentRefs.equals(functionName)) {
+ String[] intents = arg.split("(\\s)+");
+ return evaluateIntents(intents, node);
+ } else {
+ return Boolean.FALSE;
+ }
+ }
+
+ private class NodeListImpl implements NodeList {
+
+ private ArrayList<Node> list;
+
+ public NodeListImpl() {
+ this.list = new ArrayList<Node>();
+ }
+ public int getLength() {
+ return this.list.size();
+ }
+
+ public Node item(int index) {
+ return this.list.get(index);
+ }
+ public boolean add(Node node) {
+ return this.list.add(node);
+
+ }
+
+ }
+ private Object evaluateDocument(String arg, Document doc) {
+ NodeListImpl retList = new NodeListImpl();
+ NodeList elements = doc.getElementsByTagName("*");
+ for ( int i=0; i < elements.getLength(); i++) {
+ Object node = evaluateNode(arg, elements.item(i));
+ if ( node != null )
+ retList.add((Node)node);
+ }
+ return retList;
+ }
+
+ private Boolean evaluateInterface(String interfaceName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateOperation(String interfaceName, String operationName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateMessage(String interfaceName, String operationName, String messageName, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private Boolean evaluateURI(String uri, Node node) {
+ return Boolean.FALSE;
+ }
+
+ /**
+ * Evaluates a single node for the given intents.
+ * @param intents
+ * @param node
+ * @return
+ */
+ private Object evaluateIntents(String[] intents, Node node) {
+ if ( node == null )
+ return false;
+
+ if ( node.getAttributes() != null ) {
+ for ( int i=0; i < node.getAttributes().getLength(); i++) {
+ Node attr = node.getAttributes().item(i);
+
+ if ( "requires".equalsIgnoreCase(attr.getNodeName())) {
+
+ for ( int j = 0; j < intents.length; j++ ) {
+ // Check negative intents
+ if ( intents[j].startsWith("!")) {
+ if ( matchIntent(intents[j].substring(1), attr, node.getNamespaceURI()))
+ return null;
+ } else if ( !matchIntent(intents[j], attr, node.getNamespaceURI())){
+ return null;
+ }
+ }
+ return node;
+ }
+
+ }
+ }
+
+ return null;
+ }
+
+
+
+ /**
+ * Determine whether the given intent is present in the "requires" attribute
+ * @param intent
+ * @param node
+ * @param namespaceURI
+ * @return
+ */
+ private boolean matchIntent(String intent, Node node, String namespaceURI) {
+ String[] requires = node.getNodeValue().split("(\\s)+");
+ QName intentName = getStringAsQName(intent);
+
+
+ for ( int i=0; i < requires.length; i++ ) {
+ QName nodeName = null;
+ int idx = requires[i].indexOf(':');
+
+ // No prefix specified
+ if ( idx == -1 ) {
+ nodeName = new QName(namespaceURI, requires[i]);
+ } else {
+ String prefix = requires[i].substring(0, idx);
+ String name = requires[i].substring(idx + 1);
+ String ns = node.lookupNamespaceURI(prefix);
+ nodeName = new QName(ns, name, prefix);
+ }
+ if ( intentName.equals(nodeName))
+ return true;
+ }
+ return false;
+ }
+
+
+ private QName getStringAsQName(String intent) {
+ int idx = intent.indexOf(':');
+ if (idx == -1)
+ return new QName(namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX), intent);
+
+ String prefix = intent.substring(0, idx);
+ intent = intent.substring(idx + 1);
+
+ return new QName(namespaceContext.getNamespaceURI(prefix), intent, prefix);
+
+ }
+
+
+ private static Pattern FUNCTION;
+ static {
+ String functionPattern = "(URIRef|InterfaceRef|OperationRef|MessageRef|IntentRefs)\\s*\\(([^\\)]*)\\)";
+ FUNCTION = Pattern.compile(functionPattern);
+ }
+
+ /** Adds the node as an argument to the XPath function.
+ * Required in order to have access to the NodeList within the function
+ */
+ public static String normalize(String attachTo, String scaPrefix) {
+ // Get rid of any whitespace
+ attachTo = attachTo.trim();
+
+ Matcher matcher = FUNCTION.matcher(attachTo);
+ boolean result = matcher.find();
+ if (result) {
+ StringBuffer sb = new StringBuffer();
+ do {
+ String function = matcher.group(1);
+ String args = matcher.group(2);
+ if ( (matcher.start() == 0) || (attachTo.charAt( matcher.start() -1) != ':' )) {
+ function = scaPrefix + ":" + function;
+ }
+ String replacement = null;
+ if (args.trim().length() > 0) {
+ replacement = function + "(" + args + "," + "self::node())";
+ } else {
+ replacement = function + "(self::node())";
+ }
+ matcher.appendReplacement(sb, replacement);
+ result = matcher.find();
+ } while (result);
+
+ matcher.appendTail(sb);
+ return sb.toString();
+ }
+ return attachTo;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java
new file mode 100644
index 0000000000..ca44667903
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionResolver;
+
+/**
+ * A resolver that handles SCA-defined XPath functions
+ *
+ * Interface Related Functions
+ * <ul>
+ * <li>InterfaceRef( InterfaceName )
+ * <li>OperationRef( InterfaceName/OperationName )
+ * <li>MessageRef( InterfaceName/OperationName/MessageName )
+ * </ul>
+ *
+ * Intent Related Functions
+ * <ul>
+ * <li>IntentRefs( IntentList )
+ * </ul>
+ *
+ * URI Based Function
+ * <ul>
+ * <li>URIRef( URI )
+ * </ul>
+ */
+public class PolicyXPathFunctionResolver implements XPathFunctionResolver {
+ private NamespaceContext namespaceContext;
+
+ public PolicyXPathFunctionResolver(NamespaceContext namespaceContext) {
+ super();
+ this.namespaceContext = namespaceContext;
+ }
+
+ public XPathFunction resolveFunction(QName functionName, int arity) {
+ if (functionName == null) {
+ throw new NullPointerException("Function name is null");
+ }
+ if (PolicyXPathFunction.functions.contains(functionName)) {
+ if (arity >= 1) {
+ // We are relaxing the arity here so that we can pass in the context node
+ // by modifying the original xpath so that sca functions take self::node()
+ // as the 2nd argument
+ return new PolicyXPathFunction(namespaceContext, functionName);
+ } else {
+ throw new IllegalArgumentException("Invalid number of arguments: " + arity);
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml
new file mode 100644
index 0000000000..58770f71a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Security related intents -->
+ <sca:intent name="serverAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding requires that the
+ server is authenticated by the client
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="clientAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding requires that the
+ client is authenticated by the server
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="authentication" requires="sca:clientAuthentication">
+ <sca:description>
+ A convenience intent to help migration
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="mutualAuthentication"
+ requires="sca:clientAuthentication sca:serverAuthentication">
+ <sca:description>
+ Communication through the binding requires that the
+ client and server to authenticate each other
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="confidentiality" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding prevents unauthorized
+ users from reading the messages
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="integrity" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding prevents tampering
+ with the messages sent between the client and the service.
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="authorization" constrains="sca:implementation"
+ intentType="implementation">
+ <sca:description>
+ Ensures clients are authorized to use services.
+ </sca:description>
+ <sca:qualifier name="fineGrain" default="true"/>
+ </sca:intent>
+
+
+ <!-- Reliable messaging related intents -->
+ <sca:intent name="atLeastOnce" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that a message sent
+ by a client is always delivered to the component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="atMostOnce" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that a message that was
+ successfully sent by a client is not delivered more than
+ once to the component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="exactlyOnce" requires="sca:atLeastOnce sca:atMostOnce"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ This profile intent is used to indicate that a message sent
+ by a client is always delivered to the component. It also
+ indicates that duplicate messages are not delivered to the
+ component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="ordered" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that all the messages are
+ delivered to the component in the order they were sent by
+ the client.
+ </sca:description>
+ </sca:intent>
+
+ <!-- Transaction related intents -->
+ <sca:intent name="managedTransaction" excludes="sca:noManagedTransaction"
+ mutuallyExclusive="true" constrains="sca:implementation"
+ intentType="implementation">
+ <sca:description>
+ A managed transaction environment is necessary in order to
+ run the component. The specific type of managed transaction
+ needed is not constrained.
+ </sca:description>
+ <sca:qualifier name="global" default="true">
+ <sca:description>
+ For a component marked with managedTransaction.global
+ a global transaction needs to be present before dispatching
+ any method on the component - using any transaction
+ propagated from the client or else beginning and completing
+ a new transaction.
+ </sca:description>
+ </sca:qualifier>
+ <sca:qualifier name="local">
+ <sca:description>
+ A component marked with managedTransaction.local needs to
+ run within a local transaction containment (LTC) that
+ is started and ended by the SCA runtime.
+ </sca:description>
+ </sca:qualifier>
+ </sca:intent>
+
+ <sca:intent name="noManagedTransaction" excludes="sca:managedTransaction"
+ constrains="sca:implementation" intentType="implementation">
+ <sca:description>
+ A component marked with noManagedTransaction needs to run without
+ a managed transaction, under neither a global transaction nor
+ an LTC. A transaction propagated to the hosting SCA runtime
+ is not joined by the hosting runtime on behalf of a
+ component marked with noManagedtransaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="transactedOneWay" excludes="sca:immediateOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <sca:description>
+ For a reference marked as transactedOneWay any OneWay invocation
+ messages are transacted as part of a client global
+ transaction.
+ For a service marked as transactedOneWay any OneWay invocation
+ message are received from the transport binding in a
+ transacted fashion, under the service’s global transaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="immediateOneWay" excludes="sca:transactedOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <sca:description>
+ For a reference indicates that any OneWay invocation messages
+ are sent immediately regardless of any client transaction.
+ For a service indicates that any OneWay invocation is
+ received immediately regardless of any target service
+ transaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="propagatesTransaction" excludes="sca:suspendsTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ A service marked with propagatesTransaction is dispatched
+ under any propagated (client) transaction and the service binding
+ needs to be capable of receiving a transaction context.
+ A reference marked with propagatesTransaction propagates any
+ transaction context under which the client runs when the
+ reference is used for a request-response interaction and the
+ binding of a reference marked with propagatesTransaction needs to
+ be capable of propagating a transaction context.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="suspendsTransaction" excludes="sca:propagatesTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ A service marked with suspendsTransaction is not dispatched
+ under any propagated (client) transaction.
+ A reference marked with suspendsTransaction does not propagate
+ any transaction context under which the client runs when the
+ reference is used.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="managedSharedTransaction"
+ requires="sca:managedTransaction.global sca:propagatesTransaction">
+ <sca:description>
+ Used to indicate that the component requires both the
+ managedTransaction.global and the propagatesTransactions
+ intents
+ </sca:description>
+ </sca:intent>
+
+ <!-- Miscellaneous intents -->
+ <sca:intent name="asyncInvocation" excludes="sca:propagatesTransaction" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Indicates that request/response operations for the
+ interface of this wire are "long running" and must be
+ treated as two separate message transmissions
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="SOAP" constrains="sca:binding" intentType="interaction" mutuallyExclusive="true">
+ <sca:description>
+ Specifies that the SOAP messaging model is used for delivering
+ messages.
+ </sca:description>
+ <sca:qualifier name="v1_1" default="true"/>
+ <sca:qualifier name="v1_2"/>
+ </sca:intent>
+
+ <sca:intent name="JMS" constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ Requires that the messages are delivered and received via the
+ JMS API.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="noListener" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent can only be used on a reference. Indicates that the
+ client is not able to handle new inbound connections. The binding
+ and callback binding are configured so that any
+ response or callback comes either through a back channel of the
+ connection from the client to the server or by having the client
+ poll the server for messages.
+ </sca:description>
+ </sca:intent>
+
+</sca:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..250cc1d568
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.assembly.xml.ComponentTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#componentType,model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.assembly.xml.CompositeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#composite,model=org.apache.tuscany.sca.assembly.Composite
+org.apache.tuscany.sca.assembly.xml.SCABindingProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#binding.sca,model=org.apache.tuscany.sca.assembly.SCABinding
+org.apache.tuscany.sca.assembly.xml.EndpointProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#endpoint,model=org.apache.tuscany.sca.assembly.Endpoint
+org.apache.tuscany.sca.assembly.xml.EndpointReferenceProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#endpointReference,model=org.apache.tuscany.sca.assembly.EndpointReference
+org.apache.tuscany.sca.definitions.xml.DefinitionsProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#definitions,model=org.apache.tuscany.sca.definitions.Definitions
+org.apache.tuscany.sca.policy.xml.BindingTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#bindingType,model=org.apache.tuscany.sca.policy.BindingType
+org.apache.tuscany.sca.policy.xml.ImplementationTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementationType,model=org.apache.tuscany.sca.policy.ImplementationType
+org.apache.tuscany.sca.policy.xml.IntentProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#intent,model=org.apache.tuscany.sca.policy.Intent
+org.apache.tuscany.sca.policy.xml.PolicySetProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#policySet,model=org.apache.tuscany.sca.policy.PolicySet
+org.apache.tuscany.sca.policy.xml.ExternalAttachmentProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#externalAttachment,model=org.apache.tuscany.sca.policy.ExternalAttachment
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..f8d1e11ef3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.ComponentTypeDocumentProcessor;type=.componentType,model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;type=.composite,model=org.apache.tuscany.sca.assembly.Composite
+org.apache.tuscany.sca.definitions.xml.DefinitionsDocumentProcessor;type=/META-INF/definitions.xml,model=org.apache.tuscany.sca.definitions.Definitions
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..f8e4d5bbd4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.assembly.xml.CompositeModelResolver;model=org.apache.tuscany.sca.assembly.Composite
+org.apache.tuscany.sca.assembly.xml.ComponentTypeModelResolver;model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;model=org.apache.tuscany.sca.policy.Intent
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..381c0ba23b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+META-INF/sca-policy-1.1-intents-definitions-cd03.xml
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint
new file mode 100644
index 0000000000..45b3512614
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.definitions.xml.DefaultDefinitionsExtensionPoint
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
new file mode 100644
index 0000000000..8ad5f88892
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
@@ -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.
+#
+#
+NoCompositeNamespace = No namespace found: Composite = {0}
+UnexpectedInterfaceElement = Unexpected <interface> element found. It should appear inside a <service> or <reference> element.
+UnexpectedBindingElement = Unexpected <binding> element found. It should appear inside a <service> or <reference> element.
+UnexpectedImplementationElement = Unexpected <implementation> element found. It should appear inside a <component> element.
+PolicyImplValidationException = PolicyValidation exception when processing implementation of component {0} due to {1}.
+PolicyServiceValidationException = PolicyValidation exceptions when processing service/reference {0} in {1}. Error is {2}
+ContributionReadException = ContributionReadException occured due to : {0}
+ContributionResolveException = ContributionResolveException occured due to : {0}
+ContributionWriteException = ContributionWriteException occured due to : {0}
+XMLStreamException = XMLStreamException occured due to : {0}
+DuplicateCompositeName = [ASM_6001] More than one composite with the same name {0} found in contribution {1}
+PropertyTypeNotFound = The type {0} specified on property {1} of {2} can't be found in any loaded contribution (makes sure the .xsd file is in a contribution, that the contribution is being loaded and that contribution imports and exports are correct)
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties
new file mode 100644
index 0000000000..de27c0bd31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties
@@ -0,0 +1,24 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+ContributionReadException = ContributionReadException occured due to :
+PrivilegedActionException = Privileged Action Exception occured due to FilePermission in security policy file:
+ImplementationTypeNotFound = [POL50001] An extension to support the implementation type {0} can't be found in the domain
+BindingTypeNotFound = An extension to support the binding type {0} can't be found in the domain \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties
new file mode 100644
index 0000000000..08ef6bb5e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties
@@ -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.
+#
+#
+ReferredPolicySetNotFound = Referred PolicySet - {0} not found for PolicySet - {1}
+MappedIntentNotFound = Mapped Intent - {0} not found for PolicySet {1}
+ProvidedIntentNotFound = Provided Intent - {0} not found for PolicySet {1}
+UnableToMapPolicies = Unable to map policies for default qualifier in IntentMap for - {0} in policy set - {1}
+IntentMapDoesNotMatch = Intent provided by IntentMap {0} does not match parent qualifier {1} in policyset - {2}
+IntentNotSpecified = [POL30021] Intent Map provides for Intent not specified as provided by parent PolicySet - {0}
+ContrainsAttributeMissing = Constrains attribute missing from Policy Intent Definition {0}
+RequiredIntentNotFound = [POL30015] Required Intent - {0} not found for ProfileIntent {1}
+QualifiableIntentNotFound = Qualifiable Intent - {0} not found for QualifiedIntent {1}
+ErrorInPolicyIntentDefinition = Error in PolicyIntent Definition - {0} {1}
+ExcludedIntentNotFound = [POL30016] Excluded Intent {0} not found for intent {1}
+UnrecognizedIntentAttachPointType = Unrecognized IntentAttachPointType - {0}
+RequiredAttributeMissing = Required attribute {0} missing from extension type definition
+AlwaysProvidedIntentNotFound = Always Provided Intent - {0} not found for ExtensionType {1}
+MayProvideIntentNotFound = May Provide Intent - {0} not found for ExtensionType {1}
+ContributionReadException = ContributionReadException occurred due to: {0}
+CyclicReferenceFound = Cyclic reference detected in required attributes of ProfileIntents {0} and {1}
+IntentNameMissing = Required attribute "name" missing for Intent Definition
+PolicySetReferenceNameMissing = Required attribute "name" missing for PolicySetReference in PolicySet : {0}
+PolicySetNameMissing = Required attribute "name" missing for PolicySet Definition
+PolicySetAppliesToMissing = Required attribute "appliesTo" missing for PolicySet Definition
+IntentMapProvidesMissing = Required attribute "provides" missing for IntentMap in PolicySet : {0}
+QualifierNameMissing = Required attribute "name" missing for qualifier definition in PolicySet : {0}
+ConstrainedTypeNotFound = Unable to find the extension type {0} constrained by intent: {1}
+MultipleDefaultQualifiers = [POL30004] Intent {0} has more than one qualifier marked as the default qualifier
+QualifierIsNotUnique = [POL30005] The intent {0} has more than one qualifier with the name {1}
+ProfileIntentNameWithPeriod = [POL30006] The profile intent name {0} must not have the character "." in it
+IntentMapIsNotUnique = [POL30010] The policy set {0} has more than one intent map with the name {1}
+IntentMapMissingQualifiers = [POL30020] The policy set {0} intent map {1} has missing qualifiers: {2} The intent map qualifiers must match the provided intent qualifiers.
+PolicyLanguageMissmatch = Policy set {0} contains policy expressions from more than on language, languages {1} and {2} found
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java
new file mode 100644
index 0000000000..3f4a74ba03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessorTestCase.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CompositeProcessorTestCase {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private static final String OASIS_COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?> "
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" "
+ + "xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" "
+ + "targetNamespace=\"http://store\" "
+ + "name=\"store\">"
+ + "<component name=\"Catalog\">"
+ + " <implementation.java class=\"services.FruitsCatalogImpl\"/>"
+ + "</component>"
+ + "</composite>";
+
+ private static final String OSOA_COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" "
+ + "xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" "
+ + "targetNamespace=\"http://store\" "
+ + "name=\"store\">"
+ + "<component name=\"Catalog\">"
+ + " <implementation.java class=\"services.FruitsCatalogImpl\"/>"
+ + "</component>"
+ + "</composite>";
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ monitor = context.getMonitor();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ public void testReadOASISSpecVersion() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OASIS_COMPOSITE));
+ Object result = staxProcessor.read(reader, context);
+ assertNotNull(result);
+ if( result instanceof Composite) {
+ Composite composite = (Composite) result;
+ assertEquals(SCA11_NS, composite.getSpecVersion());
+ }
+ reader.close();
+ }
+
+ @Test
+ public void testReadOSOASpecVersion() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OSOA_COMPOSITE));
+ Object result = staxProcessor.read(reader, context);
+ assertNotNull(result);
+ if( result instanceof Composite) {
+ throw new Exception("Error, unsupported OSOA namespace being parsed as valid !");
+ }
+ reader.close();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
new file mode 100644
index 0000000000..0d5e69bd61
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * TUSCANY-2662
+ *
+ * @version $Rev$ $Date$
+ */
+public class MultiplicityReadWriteTestCase {
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+ private ProcessorContext context;
+
+ @Before
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Multiplicity.composite");
+ Composite composite = staxProcessor.read(is, Composite.class, context);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class, context);
+
+ verifyComposite(composite);
+
+ }
+
+
+ private void verifyComposite(Composite composite) {
+ assertEquals(composite.getComponents().get(0).getReferences().get(0).getMultiplicity(), Multiplicity.ZERO_N);
+ assertEquals(composite.getReferences().get(0).getMultiplicity(), Multiplicity.ONE_N);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
new file mode 100644
index 0000000000..155c0c5a47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadAllTestCase {
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static XMLInputFactory inputFactory;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(composite);
+ assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator"));
+ assertTrue(composite.isLocal());
+ assertFalse(composite.getAutowire() == Boolean.TRUE);
+ assertEquals(((PolicySubject)composite).getRequiredIntents().get(0).getName(), new QName("http://test",
+ "confidentiality"));
+ assertEquals(((PolicySubject)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+
+ Composite include = composite.getIncludes().get(0);
+ assertEquals(include.getName(), new QName("http://calc", "TestAllDivide"));
+
+ CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0);
+ assertEquals(calcCompositeService.getName(), "CalculatorService");
+ assertTrue(calcCompositeService.getPromotedService().isUnresolved());
+ assertEquals(calcCompositeService.getPromotedService().getName(),
+ "CalculatorService");
+ assertEquals(calcCompositeService.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+ Callback calcServiceCallback = calcCompositeService.getCallback();
+ assertNotNull(calcServiceCallback);
+ assertEquals(calcServiceCallback.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcServiceCallback.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ Component calcComponent = composite.getComponents().get(0);
+ assertEquals(calcComponent.getName(), "CalculatorServiceComponent");
+ assertEquals(calcComponent.getAutowire(), Boolean.FALSE);
+ assertEquals(calcComponent.getRequiredIntents().get(0).getName(), new QName("http://test",
+ "confidentiality"));
+ assertEquals(calcComponent.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+
+ ComponentService calcComponentService = calcComponent.getServices().get(0);
+ assertEquals(calcComponentService.getName(), "CalculatorService");
+ assertEquals(calcComponentService.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcComponentService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ ComponentReference calcComponentReference = calcComponent.getReferences().get(0);
+ assertEquals(calcComponentReference.getName(), "addService");
+ assertEquals(calcComponentReference.getAutowire(), Boolean.FALSE);
+ assertEquals(calcComponentReference.isWiredByImpl(), false);
+ assertEquals(calcComponentReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcComponentReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+
+ Property property = calcComponent.getProperties().get(0);
+ assertEquals(property.getName(), "round");
+ Document doc = (Document) property.getValue();
+ Element element = doc.getDocumentElement();
+ String value = element.getTextContent();
+ assertEquals(value, "true");
+ assertEquals(property.getXSDType(), new QName("http://www.w3.org/2001/XMLSchema", "boolean"));
+ assertEquals(property.isMany(), false);
+
+ CompositeReference calcCompositeReference = (CompositeReference)composite.getReferences().get(0);
+ assertEquals(calcCompositeReference.getName(), "MultiplyService");
+ assertTrue(calcCompositeReference.getPromotedReferences().get(0).isUnresolved());
+ assertEquals(calcCompositeReference.getPromotedReferences().get(0).getName(),
+ "CalculatorServiceComponent/multiplyService");
+ assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ // TODO test operations
+ Callback calcCallback = calcCompositeReference.getCallback();
+ assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
+ new QName("http://test", "confidentiality"));
+ assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ assertNotNull(calcCallback);
+ // TODO test operations
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..473e483d31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.HashMap;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.ValidatorHandler;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+ private static final String TUSCANY_11_XSD = "tuscany-sca-1.1.xsd";
+
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ValidatorHandler handler;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ URLArtifactProcessorExtensionPoint documentProcessors =
+ extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+
+ resolver = new DefaultModelResolver();
+ handler = getValidationHandler();
+
+ }
+
+ @Test
+ public void testValidateAssembly() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("Calculator.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+
+ }
+
+ private static ValidatorHandler getValidationHandler() throws SAXException {
+ SchemaFactory schemaFactory;
+ try {
+ schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ schemaFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ } catch (Error e) {
+ // Some old JDKs don't support XMLSchema validation
+ return null;
+ } catch (Exception e) {
+ // Some old JDKs don't support XMLSchema validation
+ return null;
+ }
+ Schema schema = schemaFactory.newSchema(ReadDocumentTestCase.class.getClassLoader().getResource(TUSCANY_11_XSD));
+ ValidatorHandler handler = schema.newValidatorHandler();
+ return handler;
+ }
+
+ @Test
+ public void testValidateImplementation() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("Calculator.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+ }
+
+ @Test
+ public void testReadImplementation() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(registry, new HashMap<String, String>());
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry);
+ factories.addFactory(validatingInputFactory);
+
+ CompositeDocumentProcessor compositeDocumentProcessor =
+ new CompositeDocumentProcessor(factories, staxProcessor);
+
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url, context);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testValidateBinding() throws Exception {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ URL url = getClass().getResource("RMIBindingTest.composite");
+ XMLReader reader = parserFactory.newSAXParser().getXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(url.openStream()));
+ }
+
+ @Test
+ public void testReadBinding() throws Exception {
+
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(registry, new HashMap<String, String>());
+ schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString());
+ XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas);
+ DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry);
+ factories.addFactory(validatingInputFactory);
+ CompositeDocumentProcessor compositeDocumentProcessor =
+ new CompositeDocumentProcessor(factories, staxProcessor);
+
+ URL url = getClass().getResource("RMIBindingTest.composite");
+ URI uri = URI.create("RMIBindingTest.composite");
+ Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url, context);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url, context);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite, context);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url, context);
+
+ documentProcessor.resolve(composite, resolver, context);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
new file mode 100644
index 0000000000..05d320b211
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.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.sca.assembly.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ }
+
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader, context));
+ is.close();
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader, context));
+ is.close();
+
+ }
+
+ @Test
+ public void testReadCompositeAndWireIt() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ assertNotNull(staxProcessor.read(reader, context));
+ is.close();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java
new file mode 100644
index 0000000000..28a2bb6851
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteAnyAttributeTestCase {
+
+ private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
+ "targetNamespace=\"http://calc\" " +
+ "name=\"Calculator\">"+
+ "<component name=\"AddServiceComponent\" xmlns:test=\"http://test\" test:customAttribute=\"customValue\">"+
+ "<implementation.java class=\"calculator.AddServiceImpl\" />"+
+ "</component>"+
+ "</composite>";
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+ private ProcessorContext context;
+
+ /**
+ * Initialize the test environment
+ * This takes care to register attribute processors when provided
+ *
+ * @param attributeProcessor
+ * @throws Exception
+ */
+ private void init(StAXAttributeProcessor<?> attributeProcessor) throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+ if(attributeProcessor != null) {
+ StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ staxAttributeProcessors.addArtifactProcessor(attributeProcessor);
+ }
+
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ }
+
+ /**
+ * Read and Write a composite that has a extended attribute
+ * and a particular attribute processor
+ * @throws Exception
+ */
+ @Test
+ public void testReadWriteCompositeWithAttributeProcessor() throws Exception {
+ init(new TestAttributeProcessor());
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML, bos.toString());
+ }
+
+ /**
+ * Read and Write a composite that has a extended attribute
+ * but no particular processor for it
+ * @throws Exception
+ */
+ @Test
+ public void testDefaultReadWriteComposite() throws Exception {
+ init(null);
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML));
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML, bos.toString());
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java
new file mode 100644
index 0000000000..7a36c1d97d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class ReadWriteAnyElementTestCase {
+ private static final String XML_RECURSIVE_EXTENDED_ELEMENT =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://temp\" name=\"RecursiveExtendedElement\">" +
+ "<unknownElement>" +
+ "<subUnknownElement1 attribute=\"anyAttribute\" />" +
+ "<subUnknownElement2 />" +
+ "</unknownElement>" +
+ "</composite>";
+
+ private static final String XML_UNKNOWN_IMPL =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://temp\" name=\"aaaa\" autowire=\"false\">" +
+ "<component name=\"unknownImpl\">" +
+ "<implementation.unknown class=\"raymond\" />" +
+ "<service name=\"service\">" +
+ "<binding.ws />" +
+ "</service>" +
+ "</component>" +
+ "</composite>";
+
+ private static final String XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://temp\" name=\"aaaa\" autowire=\"false\">" +
+ "<component name=\"unknownImpl\">" +
+ "<implementation.unknown class=\"raymond\" />" +
+ "<service name=\"service\" requires=\"\">" +
+ "<binding.ws />" +
+ "</service>" +
+ "</component>" +
+ "</composite>";
+
+
+ private ValidatingXMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+ private ProcessorContext context;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, XMLOutputFactory.newInstance());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testReadWriteExtendedRecursiveElement() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_RECURSIVE_EXTENDED_ELEMENT));
+ ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML_RECURSIVE_EXTENDED_ELEMENT);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_RECURSIVE_EXTENDED_ELEMENT, bos.toString());
+ bos.close();
+ }
+
+ @Test
+ public void testReadWriteUnknwonImpl() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML_UNKNOWN_IMPL);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_UNKNOWN_IMPL, bos.toString());
+ bos.close();
+ }
+
+ // @Test
+ @Ignore()
+ public void testReadWriteInvalidAttribute() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+
+ // used for debug comparison
+ // System.out.println(XML_UNKNOWN_IMPL);
+ // System.out.println(bos.toString());
+
+ assertEquals(XML_UNKNOWN_IMPL, bos.toString());
+ bos.close();
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
new file mode 100644
index 0000000000..fc675dcdce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.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.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteLocalCompositeTestCase {
+
+ private XMLInputFactory inputFactory;
+ private ExtensibleStAXArtifactProcessor staxProcessor;
+ private ProcessorContext context;
+
+ private static final String LOCAL_COMPOSITE_XML = "<?xml version='1.0' encoding='UTF-8'?>"+
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://localcalc\" name=\"LocalCalculator\" local=\"true\">"+
+ "</composite>";
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+ StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ staxAttributeProcessors.addArtifactProcessor(new TestAttributeProcessor());
+
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("local.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+ }
+
+ @Test
+ public void testWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("local.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ assertTrue(composite.isLocal());
+ is.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+ System.out.println(bos.toString());
+
+ assertEquals(LOCAL_COMPOSITE_XML, bos.toString());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
new file mode 100644
index 0000000000..df588e3504
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResolvePolicyTestCase {
+
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ resolver = new DefaultModelResolver();
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ // Create StAX processors
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+ }
+
+ private void preResolvePolicyTests(Composite composite) {
+ assertNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
+ assertTrue(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+
+ assertNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertTrue(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ }
+
+ private void postResolvePolicyTests(Composite composite) {
+ assertNotNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
+ assertFalse(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+ assertNotNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
+ assertFalse(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+
+
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ URL url = getClass().getResource("Calculator.composite");
+ URI uri = URI.create("Calculator.composite");
+ Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url, context);
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite, context);
+
+ url = getClass().getResource("TestAllCalculator.composite");
+ uri = URI.create("TestAllCalculator.composite");
+ Composite composite = (Composite)documentProcessor.read(null, uri, url, context);
+
+ documentProcessor.resolve(composite, resolver, context);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
new file mode 100644
index 0000000000..28e679da4a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.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.sca.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test resolving SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResolveTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessorExtensionPoint staxProcessors;
+ private static ModelResolver resolver;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ resolver = new DefaultModelResolver();
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Composite.class);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite nestedComposite = compositeReader.read(reader, context);
+ is.close();
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite, context);
+
+ is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.read(reader, context);
+ is.close();
+
+ compositeReader.resolve(composite, resolver, context);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.java
new file mode 100644
index 0000000000..8d9bc72389
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/StripURISpacesTestCase.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.assembly.xml;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StripURISpacesTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance());
+ }
+
+
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorURISpaces.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ is.close();
+
+ CompositeService compositeService = (CompositeService)composite.getServices().get(0);
+ assertNotNull(compositeService);
+
+ // Promoted component name with leading and training spaces removed
+ assertEquals("CalculatorServiceComponent", compositeService.getPromotedComponent().getName());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java
new file mode 100644
index 0000000000..b6f4c11ac2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.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.assembly.xml;
+
+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.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A Policy Processor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor<String> {
+ private static final QName ATTRIBUTE = new QName("http://test", "customAttribute");
+
+ public QName getArtifactType() {
+ return ATTRIBUTE;
+ }
+
+ public String read(QName attributeName, XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart());
+ }
+
+ public void write(String value, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ writer.setPrefix(ATTRIBUTE.getPrefix(), ATTRIBUTE.getNamespaceURI());
+ writer.writeAttribute(ATTRIBUTE.getLocalPart(), value);
+ }
+
+ public Class<String> getModelType() {
+ return String.class;
+ }
+
+ public void resolve(String arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..cfec8dee7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.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.assembly.xml;
+
+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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+/**
+ * A PolicyExpression Processor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<PolicyExpression> {
+
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public PolicyExpression read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new MockPolicyImplOne();
+ }
+
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<PolicyExpression> getModelType() {
+ return PolicyExpression.class;
+ }
+
+ public void resolve(PolicyExpression arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+ }
+
+ public class MockPolicyImplOne implements PolicyExpression {
+ public <T> T getPolicy() {
+ return null;
+ }
+
+ public void setName(QName name) {
+ }
+
+ public <T> void setPolicy(T policy) {
+ }
+
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java
new file mode 100644
index 0000000000..5e3fa15b69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.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 org.apache.tuscany.sca.assembly.xml;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+
+/**
+ * A factory for the SCA binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestSCABindingFactoryImpl implements SCABindingFactory {
+ public SCABinding createSCABinding() {
+ return new TestSCABindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
new file mode 100644
index 0000000000..f83a2ebd14
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A test cheel for the SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestSCABindingImpl implements SCABinding, PolicySubject {
+ private String name;
+ private String uri;
+ private List<Object> extensions = new ArrayList<Object>();
+
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private ExtensionType bindingType = new TestSCABindingType();
+
+ /**
+ * Constructs a new SCA binding.
+ */
+ protected TestSCABindingImpl() {
+ }
+
+ 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 false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public List<PolicySet> getPolicySets() {
+ // TODO Auto-generated method stub
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ // TODO Auto-generated method stub
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ // TODO Auto-generated method stub
+ return bindingType;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.bindingType = type;
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ private class TestSCABindingType implements ExtensionType {
+ private QName name = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912","binding");
+ public QName getBaseType() {
+ return BINDING_BASE;
+ }
+
+ public QName getType() {
+ return name;
+ }
+
+ public void setType(QName type) {
+ }
+
+ public List<Intent> getAlwaysProvidedIntents() {
+ return Collections.emptyList();
+ }
+
+ public List<Intent> getMayProvidedIntents() {
+ return Collections.emptyList();
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
new file mode 100644
index 0000000000..543aaf9893
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test the wiring of SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ resolver = new DefaultModelResolver();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+ }
+
+ @Test
+ public void testResolveComposite() throws Exception {
+ Composite nestedComposite = readComposite("Calculator.composite");
+ assertNotNull(nestedComposite);
+ resolver.addModel(nestedComposite, context);
+
+ Composite composite = readComposite("TestAllCalculator.composite");
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
+ assertNotNull(scaDefns);
+
+ policyDefinitionsProcessor.resolve(scaDefns, resolver, context);
+
+ staxProcessor.resolve(composite, resolver, context);
+
+ assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
+ }
+
+ private Composite readComposite(String resource) throws XMLStreamException, ContributionReadException, IOException {
+ InputStream is = getClass().getResourceAsStream(resource);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ is.close();
+ return composite;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
new file mode 100644
index 0000000000..a19ce79490
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteAllTestCase {
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ resolver = new DefaultModelResolver();
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
+ modelFactories.addFactory(scaBindingFactory);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = staxProcessor.read(is, Composite.class, context);
+
+ verifyComposite(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+ bos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ composite = staxProcessor.read(bis, Composite.class, context);
+
+ verifyComposite(composite);
+
+ }
+
+ @Test
+ public void testReadWireWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
+ Composite composite = staxProcessor.read(is, Composite.class, context);
+
+ URL url = getClass().getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
+ assertNotNull(scaDefns);
+ policyDefinitionsProcessor.resolve(scaDefns, resolver, context);
+
+ staxProcessor.resolve(composite, resolver, context);
+ // compositeBuilder.build(composite, null, monitor);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos, context);
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentType componentType = staxProcessor.read(is, ComponentType.class, context);
+ staxProcessor.resolve(componentType, resolver, context);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, bos, context);
+ }
+
+
+ private void verifyComposite(Composite composite) {
+ assertEquals(composite.getProperties().get(0).getName(),"prop1");
+ assertEquals(composite.getProperties().get(0).isMany(), true);
+ assertEquals(composite.getProperties().get(1).getName(),"prop2");
+ assertEquals(composite.getProperties().get(1).isMustSupply(), true);
+ assertEquals(composite.getProperties().get(0).getXSDType(), new QName("http://foo", "MyComplexType"));
+ assertEquals(composite.getProperties().get(1).getXSDElement(), new QName("http://foo", "MyComplexPropertyValue1"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
new file mode 100644
index 0000000000..f50cd5811f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test writing SCA XML assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteNamespacesTestCase {
+ private static StAXArtifactProcessor<Composite> compositeProcessor;
+ private static XMLOutputFactory outputFactory;
+ private static XMLInputFactory inputFactory;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ //outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ compositeProcessor = artifactProcessors.getProcessor(Composite.class);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+
+ // Read
+ InputStream is = getClass().getResourceAsStream("NestedCalculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeProcessor.read(reader, context);
+ Component component = composite.getComponents().get(0);
+ Composite implementation = (Composite)component.getImplementation();
+ QName qname = implementation.getName();
+
+ // Write
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
+ compositeProcessor.write(composite, writer, context);
+ System.out.println(bos);
+
+ // Read again
+ is = new ByteArrayInputStream(bos.toByteArray());
+ reader = inputFactory.createXMLStreamReader(is);
+ composite = compositeProcessor.read(reader, context);
+
+ // Compare
+ component = composite.getComponents().get(0);
+ implementation = (Composite)component.getImplementation();
+
+ assertEquals(qname, implementation.getName());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
new file mode 100644
index 0000000000..58e6e534b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.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.sca.definitions.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Mocked Policy
+ */
+public class MockPolicy {
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..f99b81f73f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.definitions.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor = null;
+ private static Definitions definitions;
+ private static Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
+ private static Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
+ private static Map<QName, BindingType> bindingTypesTable = new Hashtable<QName, BindingType>();
+ private static Map<QName, ImplementationType> implTypesTable = new Hashtable<QName, ImplementationType>();
+ public static final String scaNamespace = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ public static final String namespace = "http://test";
+
+ private static final QName secureWsPolicy = new QName(namespace, "SecureWSPolicy");
+ private static final QName confidentiality = new QName(namespace, "confidentiality");
+ private static final QName integrity = new QName(namespace, "integrity");
+ private static final QName messageProtection = new QName(namespace, "messageProtection");
+ private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ private static final QName confidentiality_message = new QName(namespace, "confidentiality.message");
+ private static final QName secureReliablePolicy = new QName(namespace, "SecureReliablePolicy");
+ private static final QName secureMessagingPolicies = new QName(namespace, "SecureMessagingPolicies");
+ private static final QName securityPolicy = new QName(namespace, "SecurityPolicy");
+ private static final QName basicAuthMsgProtSecurity = new QName(namespace, "BasicAuthMsgProtSecurity");
+ private static final QName wsBinding = new QName(scaNamespace, "binding.ws");
+ private static final QName javaImpl = new QName(scaNamespace, "implementation.java");
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ // Create StAX processors
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URLArtifactProcessorExtensionPoint documentProcessors =
+ extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ URL url = ReadDocumentTestCase.class.getResource("test_definitions.xml");
+ URI uri = URI.create("test_definitions.xml");
+ definitions = policyDefinitionsProcessor.read(null, uri, url, context);
+
+ for (Intent intent : definitions.getIntents()) {
+ intentTable.put(intent.getName(), intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ intentTable.put(i.getName(), i);
+ }
+ }
+
+ for (PolicySet policySet : definitions.getPolicySets()) {
+ policySetTable.put(policySet.getName(), policySet);
+ }
+
+ for (BindingType bindingType : definitions.getBindingTypes()) {
+ bindingTypesTable.put(bindingType.getType(), bindingType);
+ }
+
+ for (ImplementationType implType : definitions.getImplementationTypes()) {
+ implTypesTable.put(implType.getType(), implType);
+ }
+ }
+
+ @Test
+ public void testReadSCADefinitions() throws Exception {
+ assertNotNull(definitions);
+
+ assertNotNull(intentTable.get(confidentiality));
+ assertNotNull(intentTable.get(messageProtection));
+ assertNotNull(intentTable.get(confidentiality_transport));
+ assertTrue(intentTable.get(confidentiality).getDescription().length() > 0);
+
+ assertNotNull(policySetTable.get(secureReliablePolicy));
+ assertTrue(policySetTable.get(secureReliablePolicy).getProvidedIntents().size() == 2);
+ assertTrue(policySetTable.get(secureReliablePolicy).getPolicies().size() == 2);
+
+ assertNotNull(policySetTable.get(secureMessagingPolicies));
+ assertEquals(2, policySetTable.get(secureMessagingPolicies).getIntentMaps().get(0).getQualifiers().size());
+ //assertTrue(policySetTable.get(secureWsPolicy).getPolicies().get(0) instanceof org.apache.neethi.Policy);
+
+ assertEquals(bindingTypesTable.size(), 1);
+ assertNotNull(bindingTypesTable.get(wsBinding));
+ assertEquals(implTypesTable.size(), 1);
+ assertNotNull(implTypesTable.get(javaImpl));
+ }
+
+ private boolean isRealizedBy(PolicySet policySet, Intent intent) {
+ if (intent.getName().getLocalPart().indexOf('.') == -1) {
+ return policySet.getProvidedIntents().contains(intent);
+ }
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (q.getIntent().equals(intent)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private int getNumberOfQualifiedPolicies(PolicySet policySet) {
+ int count = 0;
+ for(IntentMap intentMap: policySet.getIntentMaps()) {
+ for(Qualifier q: intentMap.getQualifiers()) {
+ count += q.getPolicies().size();
+ }
+ }
+ return count;
+ }
+
+ @Test
+ public void testResolveSCADefinitions() throws Exception {
+ Intent i1 = intentTable.get(messageProtection);
+ assertTrue(!i1.getRequiredIntents().isEmpty());
+ assertNull(i1.getRequiredIntents().get(0).getDescription());
+
+ QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ Intent i2 = intentTable.get(confidentiality_transport);
+ assertNotNull(i2.getQualifiableIntent());
+
+ PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
+ PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
+ PolicySet securityPolicySet = policySetTable.get(securityPolicy);
+
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+ assertTrue(secureMessagingPolicySet.isUnresolved());
+ assertEquals(3, getNumberOfQualifiedPolicies(securityPolicySet));
+
+ //testing to ensure that inclusion of referred policy sets has not happened
+ PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+
+ BindingType wsBindingType = bindingTypesTable.get(wsBinding);
+ assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ ImplementationType javaImplType = implTypesTable.get(javaImpl);
+ assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+
+ ModelResolver resolver = new DefaultModelResolver();
+ policyDefinitionsProcessor.resolve(definitions, resolver, context);
+ //builder.build(scaDefinitions);
+
+ //testing if policy intents have been linked have property been linked up
+ assertNotNull(i1.getRequiredIntents().get(0).getDescription());
+ // assertNotNull(i2.getQualifiableIntent().getDescription());
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+
+ //testing if policysets have been properly linked up with intents
+ assertFalse(secureMessagingPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality_transport)));
+
+ //testing if intent maps have been properly mapped to policies
+ assertFalse(securityPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality_message)));
+
+ //testing for inclusion of referred policysets
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getIntentMaps().get(0).getQualifiers().isEmpty());
+ assertTrue(isRealizedBy(basicAuthMsgProtSecurityPolicySet, intentTable.get(confidentiality_transport)));
+
+ assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..a148e33029
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.definitions.xml;
+
+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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A PolicyProcessor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<MockPolicy> {
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public MockPolicy read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new MockPolicy();
+ }
+
+ public void write(MockPolicy arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ }
+
+ public Class<MockPolicy> getModelType() {
+ return MockPolicy.class;
+ }
+
+ public void resolve(MockPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
new file mode 100644
index 0000000000..d2b0775361
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.xml;
+
+import static org.apache.tuscany.sca.policy.xml.PolicyXPathFunction.normalize;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ *
+ */
+public class PolicyXPathFunctionResolverTestCase {
+ private static XPath xpath;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ XPathFactory factory = XPathFactory.newInstance();
+ xpath = factory.newXPath();
+ xpath.setNamespaceContext(new NamespaceContextImpl());
+ xpath.setXPathFunctionResolver(new PolicyXPathFunctionResolver(xpath.getNamespaceContext()));
+ }
+
+ @Test
+ public void testIntentsRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = "//sca:composite/sca:component[IntentRefs('sca:confidentiality')]";
+ str = normalize(str, "sca");
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testIntentsRef2() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = " //sca:composite/sca:component[sca:IntentRefs('sca:confidentiality')]";
+ str = normalize(str, "sca");
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testIntentsRef3() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = " IntentRefs('sca:confidentiality') ";
+ str = normalize(str, "sca");
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ Assert.assertEquals(1, nodes.getLength());
+ }
+ @Test
+ public void testURIRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("sca:composite/sca:component[sca:URIRef('AddServiceComponent')]","sca"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testInterfaceRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:service[sca:InterfaceRef('AddService')]","sca"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testOperationRef() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:reference[sca:OperationRef('AddService/add')]","sca"));
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ // Assert.assertEquals(1, nodes.getLength());
+ }
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ private static class NamespaceContextImpl implements NamespaceContext {
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ public String getNamespaceURI(String prefix) {
+ if ("sca".equals(prefix)) {
+ return SCA11_NS;
+ } else {
+ return null;
+ }
+ }
+
+ public String getPrefix(String namespaceURI) {
+ if (SCA11_NS.equals(namespaceURI)) {
+ return "sca";
+ }
+ return null;
+ }
+
+ public Iterator getPrefixes(String namespaceURI) {
+ if (SCA11_NS.equals(namespaceURI)) {
+ return Collections.singleton("sca").iterator();
+ }
+ return null;
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..b91308cfb0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadDocumentTestCase {
+
+ private ModelResolver resolver;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ private static final QName elementToProcess =
+ new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "implementationType");
+
+ private Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
+ private Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
+ private Map<QName, BindingType> bindingTypesTable = new Hashtable<QName, BindingType>();
+ private Map<QName, ImplementationType> implTypesTable = new Hashtable<QName, ImplementationType>();
+ private Map<QName, ExternalAttachment> attachmentsTable = new Hashtable<QName, ExternalAttachment>();
+
+ private static final String scaNamespace = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static final String namespace = "http://test";
+
+ private static final QName confidentiality = new QName(namespace, "confidentiality");
+ private static final QName integrity = new QName(namespace, "integrity");
+ private static final QName messageProtection = new QName(namespace, "messageProtection");
+ private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ private static final QName confidentiality_message = new QName(namespace, "confidentiality.message");
+ private static final QName secureReliablePolicy = new QName(namespace, "SecureReliablePolicy");
+ private static final QName secureMessagingPolicies = new QName(namespace, "SecureMessagingPolicies");
+ private static final QName securityPolicy = new QName(namespace, "SecurityPolicy");
+ private static final QName basicAuthMsgProtSecurity = new QName(namespace, "BasicAuthMsgProtSecurity");
+ private static final QName wsBinding = new QName(scaNamespace, "binding.ws");
+ private static final QName javaImpl = new QName(scaNamespace, "implementation.java");
+ private static final QName testPolicySetOne = new QName(namespace, "TestPolicySetOne");
+
+ @Before
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ resolver = new DefaultModelResolver();
+ context = new ProcessorContext(extensionPoints);
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URL url = getClass().getResource("test_definitions.xml");
+ InputStream urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+ reader.next();
+
+ //position on the right element qname to get processed
+ while (reader.hasNext()) {
+ reader.next();
+ int event = reader.getEventType();
+ if (event == START_ELEMENT && reader.getName().equals(elementToProcess)) {
+ break;
+ }
+ }
+ while (true) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ Object artifact = staxProcessor.read(reader, context);
+ if (artifact instanceof PolicySet) {
+ PolicySet policySet = (PolicySet)artifact;
+ policySet.setName(new QName(namespace, policySet.getName().getLocalPart()));
+ policySetTable.put(policySet.getName(), policySet);
+ } else if (artifact instanceof Intent) {
+ Intent intent = (Intent)artifact;
+ intent.setName(new QName(namespace, intent.getName().getLocalPart()));
+ intentTable.put(intent.getName(), intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(namespace, i.getName().getLocalPart()));
+ intentTable.put(i.getName(), i);
+ resolver.addModel(i, context);
+ }
+ } else if (artifact instanceof BindingType) {
+ BindingType bindingType = (BindingType)artifact;
+ bindingTypesTable.put(bindingType.getType(), bindingType);
+ } else if (artifact instanceof ImplementationType) {
+ ImplementationType implType = (ImplementationType)artifact;
+ implTypesTable.put(implType.getType(), implType);
+ } else if ( artifact instanceof ExternalAttachment) {
+ ExternalAttachment attachment = (ExternalAttachment)artifact;
+ attachmentsTable.put(attachment.getPolicySets().get(0).getName(), attachment);
+ }
+
+ if (artifact != null) {
+ resolver.addModel(artifact, context);
+ }
+
+ break;
+ }
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ urlStream.close();
+ }
+
+ @Test
+ public void testReadSCADefinitions() throws Exception {
+ assertNotNull(intentTable.get(confidentiality));
+ assertNotNull(intentTable.get(messageProtection));
+ assertNotNull(intentTable.get(confidentiality_transport));
+ assertTrue(intentTable.get(confidentiality).getDescription().length() > 0);
+
+ assertNotNull(policySetTable.get(secureReliablePolicy));
+ assertTrue(policySetTable.get(secureReliablePolicy).getProvidedIntents().size() == 2);
+ assertTrue(policySetTable.get(secureReliablePolicy).getPolicies().size() == 2);
+
+ assertNotNull(policySetTable.get(secureMessagingPolicies));
+ assertEquals(2, policySetTable.get(secureMessagingPolicies).getIntentMaps().get(0).getQualifiers().get(0).getPolicies().size());
+
+ assertEquals(bindingTypesTable.size(), 1);
+ assertNotNull(bindingTypesTable.get(wsBinding));
+ assertEquals(implTypesTable.size(), 1);
+ assertNotNull(implTypesTable.get(javaImpl));
+
+ // Test external attachments
+ assertEquals(1, attachmentsTable.size());
+ assertNotNull(attachmentsTable.get(policySetTable.get(testPolicySetOne).getName()));
+ }
+
+ private int getNumberOfQualifiedPolicies(PolicySet policySet) {
+ int count = 0;
+ for(IntentMap intentMap: policySet.getIntentMaps()) {
+ for(Qualifier q: intentMap.getQualifiers()) {
+ count += q.getPolicies().size();
+ }
+ }
+ return count;
+ }
+
+ @Test
+ public void testResolution() throws Exception {
+ assertTrue(!intentTable.get(messageProtection).getRequiredIntents().isEmpty());
+ Intent profileIntent = intentTable.get(new QName(namespace, "messageProtection"));
+ assertNull(profileIntent.getRequiredIntents().get(0).getDescription());
+
+ QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ assertTrue(intentTable.get(confidentiality_transport) instanceof Intent);
+ Intent qualifiedIntent = (Intent)intentTable.get(new QName(namespace, "confidentiality.transport"));
+ assertNull(qualifiedIntent.getDescription());
+ assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
+
+ PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
+ PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
+ PolicySet securityPolicySet = policySetTable.get(securityPolicy);
+
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+ assertTrue(secureMessagingPolicySet.isUnresolved());
+ assertEquals(2, getNumberOfQualifiedPolicies(securityPolicySet));
+
+ //testing to ensure that inclusion of referred policy sets has not happened
+ PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+
+ ExtensionType wsBindingType = bindingTypesTable.get(wsBinding);
+ assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ ExtensionType javaImplType = implTypesTable.get(javaImpl);
+ assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+
+ ExternalAttachment attachment = attachmentsTable.values().iterator().next();
+ PolicySet psOne = policySetTable.get(testPolicySetOne);
+ assertEquals(psOne, attachment.getPolicySets().get(0));
+
+ List<Intent> intents = new ArrayList<Intent>(intentTable.values());
+
+ for (Intent intent : intents) {
+ staxProcessor.resolve(intent, resolver, context);
+ }
+
+ for (PolicySet policySet : policySetTable.values()) {
+ if (policySet.getReferencedPolicySets().isEmpty())
+ staxProcessor.resolve(policySet, resolver, context);
+ }
+
+ for (PolicySet policySet : policySetTable.values()) {
+ if (!policySet.getReferencedPolicySets().isEmpty())
+ staxProcessor.resolve(policySet, resolver, context);
+ }
+
+ for (ExtensionType bindingType : bindingTypesTable.values()) {
+ staxProcessor.resolve(bindingType, resolver, context);
+ }
+
+ for (ExtensionType implType : implTypesTable.values()) {
+ staxProcessor.resolve(implType, resolver, context);
+ }
+
+ for ( ExternalAttachment ea : attachmentsTable.values()) {
+ staxProcessor.resolve(ea, resolver, context);
+ }
+
+ //testing if policy intents have been linked have property been linked up
+ assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
+ assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
+ assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
+ assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
+
+ //testing if policysets have been properly linked up with intents
+ assertFalse(secureMessagingPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality_transport)));
+
+ //testing if intent maps have been properly mapped to policies
+ assertFalse(securityPolicySet.isUnresolved());
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality_message)));
+
+ //testing for inclusion of referred policysets
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+ assertTrue(isRealizedBy(basicAuthMsgProtSecurityPolicySet, intentTable.get(confidentiality_transport)));
+
+ assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+ assertNotNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+
+
+ }
+
+ private boolean isRealizedBy(PolicySet policySet, Intent intent) {
+ if (intent.getName().getLocalPart().indexOf('.') == -1) {
+ return policySet.getProvidedIntents().contains(intent);
+ }
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (q.getIntent().equals(intent)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..aea2c3adb8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.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.policy.xml;
+
+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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<PolicyExpression> {
+
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public PolicyExpression read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new MockPolicyImplOne();
+ }
+
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ }
+
+ public Class<PolicyExpression> getModelType() {
+ // TODO Auto-generated method stub
+ return PolicyExpression.class;
+ }
+
+ public void resolve(PolicyExpression arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+ public class MockPolicyImplOne implements PolicyExpression {
+ public <T> T getPolicy() {
+ return null;
+ }
+
+ public void setName(QName name) {
+ }
+
+ public <T> void setPolicy(T policy) {
+ }
+
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
new file mode 100644
index 0000000000..be0c1eb737
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
@@ -0,0 +1,59 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:x="http://x"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" multiplicity="0..1" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <x:unknownElement uknAttr="attribute1">
+ <y:subUnknownElement1 xmlns:y="http://y" uknAttr1="attribute2"/>
+ <x:subUnknownElement2 />
+ </x:unknownElement>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..83fa64cef4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java interface="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorURISpaces.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorURISpaces.composite
new file mode 100644
index 0000000000..287810b156
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorURISpaces.composite
@@ -0,0 +1,59 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:x="http://x"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <service name="CalculatorService" promote=" CalculatorServiceComponent ">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" multiplicity="0..1" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <x:unknownElement uknAttr="attribute1">
+ <y:subUnknownElement1 xmlns:y="http://y" uknAttr1="attribute2"/>
+ <x:subUnknownElement2 />
+ </x:unknownElement>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
new file mode 100644
index 0000000000..0d344ac937
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://temp"
+ name="composite1">
+ <component name="data7">
+ <implementation.java class="temp.EchoImpl"/>
+ <service name="Echo">
+ <interface.wsdl interface="http://echo.webservice#wsdl.interface(Echo)"/>
+ </service>
+ <reference multiplicity="0..n" name="reference" requires=""/>
+ </component>
+
+ <reference multiplicity="1..n" name="reference" promote="" requires=""/>
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite
new file mode 100644
index 0000000000..5606e653bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.composite xmlns:n="http://inner" name="n:InnerCalculator"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite
new file mode 100644
index 0000000000..9140403fc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://helloWorldRMI"
+ name="HelloWorldRmiComposite">
+
+ <service name="HelloWorldRmiService" promote="HelloWorldServiceComponent">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" />
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ </component>
+
+ <component name="HelloWorldRmiServiceComponent">
+ <implementation.java class="helloworld.HelloWorldRmiImpl"/>
+ <reference name="extService"></reference>
+ </component>
+
+ <reference name="HelloWorldRmiReference" promote="HelloWorldRmiServiceComponent/extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" />
+ </reference>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
new file mode 100644
index 0000000000..195dfcf106
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
@@ -0,0 +1,127 @@
+<?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 autowire="false" local="true" name="TestAllCalculator" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912 "
+ xmlns:ext="http://extension"
+ xmlns:cns="http://test" xmlns:sns="http://test">
+
+ <include name="tns:TestAllDivide"/>
+ <ext:testExtension/>
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService" requires="cns:confidentiality"
+ policySets="sns:SecureReliablePolicy">
+ <ext:testExtension/>
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <operation name="add" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
+
+ <binding.ws name="CalculatorWS" policySets="sns:SecureReliablePolicy" port="" requires="cns:confidentiality" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <ext:testExtension/>
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorServiceComponent" autowire="false"
+ policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <ext:testExtension/>
+ <service name="CalculatorService" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ </service>
+
+ <reference name="addService" target="AddServiceComponent/AddService" autowire="false" multiplicity="1..1"
+ policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" wiredByImpl="false">
+ <ext:testExtension/>
+ <interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" />
+ <reference name="divideService" target="DivideServiceComponent" />
+
+ <property name="round" type="xsd:boolean" many="false">true</property>
+
+ <implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires="" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <service name="AddService">
+ <interface.java interface="calculator.AddService" />
+ </service>
+ <implementation.java class="calculator.AddServiceImpl" />
+ </component>
+
+ <component name="NestedCompositeComponent">
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+ <implementation.composite name="tns:Calculator" />
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl" />
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl" />
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl" />
+ </component>
+
+ <reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality">
+ <interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
+
+ <binding.ws name="MultiplyWS" port="" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
+ <binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws" policySets="sns:SecureReliablePolicy"
+ requires="cns:confidentiality">
+ </binding.ws>
+ </callback>
+ </reference>
+
+ <property name="prop1" xmlns:foo="http://foo" many="true" type="foo:MyComplexType">
+ <value xsi:type="foo:MyComplexType" attr="bar">
+ <foo:a>AValue</foo:a>
+ <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+ </value>
+ <value xsi:type="foo:MyComplexType" attr="zing">
+ <foo:a>BValue</foo:a>
+ <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+ </value>
+ </property>
+
+ <property name="prop2" xmlns:foo="http://foo" mustSupply="true" element="foo:MyComplexPropertyValue1">
+ <foo:MyComplexPropertyValue1>123</foo:MyComplexPropertyValue1>
+ </property>
+ <property name="prop3" xmlns:foo="http://foo" mustSupply="true" value="123"/>
+ <property name="prop4">123</property>
+ <property name="prop5"><value>123</value></property>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite
new file mode 100644
index 0000000000..42e6c1c3ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite
@@ -0,0 +1,56 @@
+<?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 autowire="false"
+ local="true"
+ name="TestAllDivide"
+ policySets="" requires=""
+ targetNamespace="http://calc"
+ xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912 ">
+
+ <!--
+ <include name="tns:CompleteDivide"/>
+ -->
+ <service name="DivideService" policySets="" promote="CalculatorDivideComponent/DivideService" requires="">
+ <interface.java interface="calculator.DivideService" callbackInterface="calculator.DivideCallback"/>
+ <operation name="divide" policySets="" requires=""/>
+
+ <binding.ws name="CalculatorWS" policySets="" port="" requires="" uri="http://calc/ws">
+ <operation name="divide" policySets="" requires=""/>
+ </binding.ws>
+
+ <callback policySets="" requires="">
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
+ <operation name="divideCallback" policySets="" requires=""/>
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorDivideComponent" autowire="false" policySets="" requires="">
+ <service name="DivideService" policySets="" requires="">
+ <interface.java interface="calculator.DivideService" callbackInterface="calculator.DivideCallback"/>
+ </service>
+ <implementation.java class="calculator.DivideImpl" policySets="" requires=""/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
new file mode 100644
index 0000000000..424cec3e8a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
@@ -0,0 +1,125 @@
+<?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 autowire="false" local="true" name="TestAllCalculator"
+ requires="cns:tuscanyIntent_1" targetNamespace="http://calc" xmlns:tns="http://calc"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200912 http://docs.oasis-open.org/ns/opencsa/sca/200912 "
+ xmlns:ext="http://extension"
+ xmlns:cns="http://test" xmlns:sns="http://test">
+
+ <include name="tns:TestAllDivide"/>
+ <ext:testExtension/>
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService" requires="cns:tuscanyIntent_2 cns:tuscanyIntent_1">
+ <ext:testExtension/>
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <operation name="add" requires="cns:tuscanyIntent_6"/>
+
+ <binding.ws name="CalculatorWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback requires="cns:tuscanyIntent_4">
+ <ext:testExtension/>
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_5" uri="http://calc/callback/ws">
+ </binding.ws>
+ </callback>
+ </service>
+
+ <component name="CalculatorServiceComponent" autowire="false"
+ requires="cns:tuscanyIntent_2 cns:tuscanyIntent_3">
+ <ext:testExtension/>
+ <service name="CalculatorService" requires="cns:tuscanyIntent_3">
+ <interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
+ <binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
+ </binding.ws>
+ <callback>
+ </callback>
+ </service>
+
+ <reference name="addService" target="AddServiceComponent/AddService" autowire="false" multiplicity="1..1"
+ requires="cns:tuscanyIntent_3 cns:tuscanyIntent_2.qualified" wiredByImpl="false">
+ <ext:testExtension/>
+ <interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
+ <binding.ws name="addServiceWSRef" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
+ </binding.ws>
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" />
+ <reference name="divideService" target="DivideServiceComponent" />
+
+ <property name="round" type="xsd:boolean" many="false">true</property>
+
+ <implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires="cns:tuscanyIntent_4" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <service name="AddService">
+ <interface.java interface="calculator.AddService" />
+ </service>
+ <implementation.java class="calculator.AddServiceImpl" />
+ </component>
+
+ <component name="NestedCompositeComponent">
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+ <implementation.composite name="tns:Calculator" />
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl" />
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl" />
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl" />
+ </component>
+
+ <reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService"
+ requires="cns:tuscanyIntent_2">
+ <interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
+
+ <binding.ws name="MultiplyWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
+ </binding.ws>
+
+ <callback policySets="sns:SecureReliablePolicy" requires="cns:tuscanyIntent_3">
+ <binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws"
+ requires="cns:tuscanyIntent_4">
+ </binding.ws>
+ </callback>
+ </reference>
+
+ <property name="prop1" xmlns:foo="http://foo">
+ <value xsi:type="foo:MyComplexType" attr="bar">
+ <foo:a>AValue</foo:a>
+ <bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
+ </value>
+ <value xsi:type="foo:MyComplexType" attr="zing">
+ <foo:a>BValue</foo:a>
+ <bar:b xmlns:bar="http://bar">BoringURI</bar:b>
+ </value>
+ </property>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
new file mode 100644
index 0000000000..489d6abed1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<sca:definitions xmlns="http://test"
+ targetNamespace="http://test"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+<!-- simple intent -->
+ <sca:intent name="tuscanyIntent_1"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_2"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_3"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_4"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+<sca:intent name="tuscanyIntent_5"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_6"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_7"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_8"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_9"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_10"
+ constrains="sca:binding">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+</sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
new file mode 100644
index 0000000000..279f7d534e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://localcalc"
+ xmlns:test="http://testlocal"
+ targetNamespace="http://localcalc"
+ name="LocalCalculator"
+ local="true">
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
new file mode 100644
index 0000000000..2cfbd6bcff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
new file mode 100644
index 0000000000..dc7f5c422c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
new file mode 100644
index 0000000000..0e7aad877e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent" requires="confidentiality">
+ <implementation.java class="calculator.CalculatorServiceImpl" xmlns:test="http://test" requiers="test:TestIntentOne"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
new file mode 100644
index 0000000000..aea941a78f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+ <externalAttachment policySets="test:TestPolicySetOne" attachTo="IntentRefs('test:testIntentOne')"/>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/LICENSE b/sandbox/sebastien/java/embed/modules/assembly-xsd/LICENSE
new file mode 100644
index 0000000000..0bea130c88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/LICENSE
@@ -0,0 +1,338 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+This module includes XSD files under the following OASIS license:
+
+Copyright (C) OASIS(R) 2005, 2009. All Rights Reserved.
+All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual
+Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
+This document and translations of it may be copied and furnished to others, and derivative works that
+comment on or otherwise explain it or assist in its implementation may be prepared, copied, published,
+and distributed, in whole or in part, without restriction of any kind, provided that the above copyright
+notice and this section are included on all such copies and derivative works. However, this document
+itself may not be modified in any way, including by removing the copyright notice or references to OASIS,
+except as needed for the purpose of developing any document or deliverable produced by an OASIS
+Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR
+Policy, must be followed) or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors
+or assigns.
+This document and the information contained herein is provided on an "AS IS" basis and OASIS
+DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
+WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP
+RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.
+OASIS requests that any OASIS Party or any other party that believes it has patent claims that would
+necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard,
+to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to
+such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that
+produced this specification.
+OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of
+any patent claims that would necessarily be infringed by implementations of this specification by a patent
+holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR
+Mode of the OASIS Technical Committee that produced this specification. OASIS may include such
+claims on its website, but disclaims any obligation to do so.
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that
+might be claimed to pertain to the implementation or use of the technology described in this document or
+the extent to which any license under such rights might or might not be available; neither does it represent
+that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to
+rights in any document or deliverable produced by an OASIS Technical Committee can be found on the
+OASIS website. Copies of claims of rights made available for publication and any assurances of licenses
+to be made available, or the result of an attempt made to obtain a general license or permission for the use
+of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS
+Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any
+information or list of intellectual property rights will at any time be complete, or that any claims in such list
+are, in fact, Essential Claims.
+The names "OASIS", are trademarks of OASIS, the owner and developer of this specification, and should
+be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and
+implementation and use of, specifications, while reserving the right to enforce its marks against misleading
+uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance.
+
+===============================================================================
+
+This module includes XSD files under the following W3C(r) Software License:
+
+W3C(r) SOFTWARE NOTICE AND LICENSE
+http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+This work (and included software, documentation such as READMEs, or other related items)
+is being provided by the copyright holders under the following license. By obtaining,
+using and/or copying this work, you (the licensee) agree that you have read, understood,
+and will comply with the following terms and conditions.
+
+Permission to copy, modify, and distribute this software and its documentation, with or
+without modification, for any purpose and without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the software and documentation or portions
+thereof, including modifications:
+
+ 1. The full text of this NOTICE in a location viewable to users of the redistributed or
+ derivative work.
+ 2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions.
+ If none exist, the W3C Software Short Notice should be included (hypertext is preferred,
+ text is permitted) within the body of any redistributed or derivative code.
+ 3. Notice of any changes or modifications to the files, including the date changes were
+ made. (We recommend you provide URIs to the location from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
+REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES
+OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
+DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER
+RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL
+DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or publicity
+pertaining to the software without specific, written prior permission. Title to copyright
+in this software and any associated documentation will at all times remain with copyright
+holders.
+
+===============================================================================
+
+This module includes XSD files under the following license:
+
+http://www.w3.org/Consortium/Legal/copyright-software-19980720
+
+W3C® SOFTWARE NOTICE AND LICENSE
+Copyright (c) 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche
+en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
+
+This W3C work (including software, documents, or other related items) is being provided by the copyright holders under
+the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood,
+and will comply with the following terms and conditions:
+
+Permission to use, copy, modify, and distribute this software and its documentation, with or without modification,
+for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies
+of the software and documentation or portions thereof, including modifications, that you make:
+
+ 1. The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+ 2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, a short
+notice of the following form (hypertext is preferred, text is permitted) should be used within the body of any redistributed
+or derivative code: "Copyright (c) [$date-of-software] World Wide Web Consortium, (Massachusetts Institute of Technology,
+Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/"
+ 3. Notice of any changes or modifications to the W3C files, including the date changes were made. (We recommend you provide URIs
+to the location from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE
+OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE
+OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software
+without specific, written prior permission. Title to copyright in this software and any associated documentation will
+at all times remain with copyright holders.
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/assembly-xsd/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ff93db6b14
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Assembly Model XML Schemas
+Bundle-ManifestVersion: 2
+Bundle-Description: Apache Tuscany SCA Assembly Model XML Schemas
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly.xsd
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.assembly.xsd;version="2.0.0"
+Import-Package: javax.xml.namespace
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/NOTICE b/sandbox/sebastien/java/embed/modules/assembly-xsd/NOTICE
new file mode 100644
index 0000000000..c5118ba0fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/NOTICE
@@ -0,0 +1,38 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the OASIS license
+(see the LICENSE file contained in this distribution), with the following
+copyright:
+
+Copyright (C) OASIS(R) 2005, 2009. All Rights Reserved.
+OASIS trademark, IPR and other policies apply.
+
+This product also includes software under the W3C(r) Software License
+(see the LICENSE file contained in this distribution), with the following
+copyright:
+
+Copyright (c) 2004 World Wide Web Consortium (Massachusetts Institute of Technology,
+European Research Consortium for Informatics and Mathematics, Keio University).
+All Rights Reserved. This work is distributed under the W3C(r) Software License [1]
+in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+This product also includes software under the W3C(c) Software License
+with the following copyright:
+
+Copyright 2001 The Internet Society and W3C (Massachusetts Institute
+of Technology, Institut National de Recherche en Informatique et en
+Automatique, Keio University). All Rights Reserved.
+http://www.w3.org/Consortium/Legal/
+
+This document is governed by the W3C Software License [1] as described
+in the FAQ [2].
+
+[1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
+[2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/pom.xml b/sandbox/sebastien/java/embed/modules/assembly-xsd/pom.xml
new file mode 100644
index 0000000000..8193461b62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <name>Apache Tuscany SCA Assembly Model XSD Files</name>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java
new file mode 100644
index 0000000000..d782b20a4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.xsd;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants used in SCA assembly XML files.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Constants {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ String COMPONENT_TYPE = "componentType";
+ QName COMPONENT_TYPE_QNAME = new QName(SCA11_NS, COMPONENT_TYPE);
+
+ String SERVICE = "service";
+ QName SERVICE_QNAME = new QName(SCA11_NS, SERVICE);
+
+ String REFERENCE = "reference";
+ QName REFERENCE_QNAME = new QName(SCA11_NS, REFERENCE);
+
+ String PROPERTY = "property";
+ QName PROPERTY_QNAME = new QName(SCA11_NS, PROPERTY);
+
+ String COMPOSITE = "composite";
+ QName COMPOSITE_QNAME = new QName(SCA11_NS, COMPOSITE);
+
+ String INCLUDE = "include";
+ QName INCLUDE_QNAME = new QName(SCA11_NS, INCLUDE);
+
+ String COMPONENT = "component";
+ QName COMPONENT_QNAME = new QName(SCA11_NS, COMPONENT);
+
+ String WIRE = "wire";
+ QName WIRE_QNAME = new QName(SCA11_NS, WIRE);
+
+ String OPERATION = "operation";
+ QName OPERATION_QNAME = new QName(SCA11_NS, OPERATION);
+
+ String CALLBACK = "callback";
+ QName CALLBACK_QNAME = new QName(SCA11_NS, CALLBACK);
+
+ String IMPLEMENTATION_COMPOSITE = "implementation.composite";
+ QName IMPLEMENTATION_COMPOSITE_QNAME = new QName(SCA11_NS, IMPLEMENTATION_COMPOSITE);
+
+ String IMPLEMENTATION = "implementation";
+ QName IMPLEMENTATION_QNAME = new QName(SCA11_NS, IMPLEMENTATION);
+
+ String BINDING_SCA = "binding.sca";
+ QName BINDING_SCA_QNAME = new QName(Constants.SCA11_NS, BINDING_SCA);
+
+ String NAME = "name";
+ String VALUE = "value";
+ QName VALUE_QNAME = new QName(SCA11_NS, VALUE);
+ String TARGET_NAMESPACE = "targetNamespace";
+ String LOCAL = "local";
+ String AUTOWIRE = "autowire";
+ String NONOVERRIDABLE = "nonOverridable";
+ String REPLACE = "replace";
+ String REQUIRES = "requires";
+ String POLICY_SETS = "policySets";
+ String APPLICABLE_POLICY_SETS = "applicablePolicySets";
+ String PROMOTE = "promote";
+ String TARGET = "target";
+ String WIRED_BY_IMPL = "wiredByImpl";
+ String MULTIPLICITY = "multiplicity";
+ String TYPE = "type";
+ String ELEMENT = "element";
+ String MANY = "many";
+ String MUST_SUPPLY = "mustSupply";
+ String SOURCE = "source";
+ String FILE = "file";
+ String URI = "uri";
+ String ZERO_ONE = "0..1";
+ String ZERO_N = "0..n";
+ String ONE_ONE = "1..1";
+ String ONE_N = "1..n";
+
+ /**
+ * Cache for public XSDs and DTDs
+ */
+ Map<String, URL> CACHED_XSDS = XSDCache.cache();
+
+ static class XSDCache {
+ static Map<String, URL> cache() {
+ Map<String, URL> cachedXSDs = new HashMap<String, URL>();
+ cachedXSDs.put(Constants.SCA11_NS, Constants.class.getResource("/sca-1.1-cd05.xsd"));
+ cachedXSDs
+ .put("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
+ Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd"));
+ cachedXSDs
+ .put("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd",
+ Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd"));
+ cachedXSDs.put("http://www.w3.org/2005/08/addressing", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd"));
+ cachedXSDs.put("http://www.w3.org/ns/ws-policy", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd"));
+ cachedXSDs.put("http://www.w3.org/ns/wsdl-instance", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd"));
+ cachedXSDs.put("http://www.w3.org/XML/1998/namespace", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/xml.xsd"));
+ cachedXSDs.put("http://www.w3.org/2000/09/xmldsig#", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd"));
+
+ cachedXSDs.put("-//W3C//DTD XMLSchema 200102//EN", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd"));
+ cachedXSDs.put("-//W3C//DTD XMLSCHEMA 200102//EN", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd"));
+ cachedXSDs.put("datatypes", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd"));
+ return cachedXSDs;
+ }
+ };
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..ba25c9908a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+tuscany-sca-1.1.xsd
+sca-1.1-cd05-rev1.xsd
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd
new file mode 100644
index 0000000000..e8e8f7625a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd
@@ -0,0 +1,402 @@
+<!-- DTD for XML Schemas: Part 1: Structures
+ Public Identifier: "-//W3C//DTD XMLSCHEMA 200102//EN"
+ Official Location: http://www.w3.org/2001/XMLSchema.dtd -->
+<!-- $Id: XMLSchema.dtd,v 1.31 2001/10/24 15:50:16 ht Exp $ -->
+<!-- Note this DTD is NOT normative, or even definitive. --> <!--d-->
+<!-- prose copy in the structures REC is the definitive version --> <!--d-->
+<!-- (which shouldn't differ from this one except for this --> <!--d-->
+<!-- comment and entity expansions, but just in case) --> <!--d-->
+<!-- With the exception of cases with multiple namespace
+ prefixes for the XML Schema namespace, any XML document which is
+ not valid per this DTD given redefinitions in its internal subset of the
+ 'p' and 's' parameter entities below appropriate to its namespace
+ declaration of the XML Schema namespace is almost certainly not
+ a valid schema. -->
+
+<!-- The simpleType element and its constituent parts
+ are defined in XML Schema: Part 2: Datatypes -->
+<!ENTITY % xs-datatypes PUBLIC 'datatypes' 'datatypes.dtd' >
+
+<!ENTITY % p 'xs:'> <!-- can be overriden in the internal subset of a
+ schema document to establish a different
+ namespace prefix -->
+<!ENTITY % s ':xs'> <!-- if %p is defined (e.g. as foo:) then you must
+ also define %s as the suffix for the appropriate
+ namespace declaration (e.g. :foo) -->
+<!ENTITY % nds 'xmlns%s;'>
+
+<!-- Define all the element names, with optional prefix -->
+<!ENTITY % schema "%p;schema">
+<!ENTITY % complexType "%p;complexType">
+<!ENTITY % complexContent "%p;complexContent">
+<!ENTITY % simpleContent "%p;simpleContent">
+<!ENTITY % extension "%p;extension">
+<!ENTITY % element "%p;element">
+<!ENTITY % unique "%p;unique">
+<!ENTITY % key "%p;key">
+<!ENTITY % keyref "%p;keyref">
+<!ENTITY % selector "%p;selector">
+<!ENTITY % field "%p;field">
+<!ENTITY % group "%p;group">
+<!ENTITY % all "%p;all">
+<!ENTITY % choice "%p;choice">
+<!ENTITY % sequence "%p;sequence">
+<!ENTITY % any "%p;any">
+<!ENTITY % anyAttribute "%p;anyAttribute">
+<!ENTITY % attribute "%p;attribute">
+<!ENTITY % attributeGroup "%p;attributeGroup">
+<!ENTITY % include "%p;include">
+<!ENTITY % import "%p;import">
+<!ENTITY % redefine "%p;redefine">
+<!ENTITY % notation "%p;notation">
+
+<!-- annotation elements -->
+<!ENTITY % annotation "%p;annotation">
+<!ENTITY % appinfo "%p;appinfo">
+<!ENTITY % documentation "%p;documentation">
+
+<!-- Customisation entities for the ATTLIST of each element type.
+ Define one of these if your schema takes advantage of the
+ anyAttribute='##other' in the schema for schemas -->
+
+<!ENTITY % schemaAttrs ''>
+<!ENTITY % complexTypeAttrs ''>
+<!ENTITY % complexContentAttrs ''>
+<!ENTITY % simpleContentAttrs ''>
+<!ENTITY % extensionAttrs ''>
+<!ENTITY % elementAttrs ''>
+<!ENTITY % groupAttrs ''>
+<!ENTITY % allAttrs ''>
+<!ENTITY % choiceAttrs ''>
+<!ENTITY % sequenceAttrs ''>
+<!ENTITY % anyAttrs ''>
+<!ENTITY % anyAttributeAttrs ''>
+<!ENTITY % attributeAttrs ''>
+<!ENTITY % attributeGroupAttrs ''>
+<!ENTITY % uniqueAttrs ''>
+<!ENTITY % keyAttrs ''>
+<!ENTITY % keyrefAttrs ''>
+<!ENTITY % selectorAttrs ''>
+<!ENTITY % fieldAttrs ''>
+<!ENTITY % includeAttrs ''>
+<!ENTITY % importAttrs ''>
+<!ENTITY % redefineAttrs ''>
+<!ENTITY % notationAttrs ''>
+<!ENTITY % annotationAttrs ''>
+<!ENTITY % appinfoAttrs ''>
+<!ENTITY % documentationAttrs ''>
+
+<!ENTITY % complexDerivationSet "CDATA">
+ <!-- #all or space-separated list drawn from derivationChoice -->
+<!ENTITY % blockSet "CDATA">
+ <!-- #all or space-separated list drawn from
+ derivationChoice + 'substitution' -->
+
+<!ENTITY % mgs '%all; | %choice; | %sequence;'>
+<!ENTITY % cs '%choice; | %sequence;'>
+<!ENTITY % formValues '(qualified|unqualified)'>
+
+
+<!ENTITY % attrDecls '((%attribute;| %attributeGroup;)*,(%anyAttribute;)?)'>
+
+<!ENTITY % particleAndAttrs '((%mgs; | %group;)?, %attrDecls;)'>
+
+<!-- This is used in part2 -->
+<!ENTITY % restriction1 '((%mgs; | %group;)?)'>
+
+%xs-datatypes;
+
+<!-- the duplication below is to produce an unambiguous content model
+ which allows annotation everywhere -->
+<!ELEMENT %schema; ((%include; | %import; | %redefine; | %annotation;)*,
+ ((%simpleType; | %complexType;
+ | %element; | %attribute;
+ | %attributeGroup; | %group;
+ | %notation; ),
+ (%annotation;)*)* )>
+<!ATTLIST %schema;
+ targetNamespace %URIref; #IMPLIED
+ version CDATA #IMPLIED
+ %nds; %URIref; #FIXED 'http://www.w3.org/2001/XMLSchema'
+ xmlns CDATA #IMPLIED
+ finalDefault %complexDerivationSet; ''
+ blockDefault %blockSet; ''
+ id ID #IMPLIED
+ elementFormDefault %formValues; 'unqualified'
+ attributeFormDefault %formValues; 'unqualified'
+ xml:lang CDATA #IMPLIED
+ %schemaAttrs;>
+<!-- Note the xmlns declaration is NOT in the Schema for Schemas,
+ because at the Infoset level where schemas operate,
+ xmlns(:prefix) is NOT an attribute! -->
+<!-- The declaration of xmlns is a convenience for schema authors -->
+
+<!-- The id attribute here and below is for use in external references
+ from non-schemas using simple fragment identifiers.
+ It is NOT used for schema-to-schema reference, internal or
+ external. -->
+
+<!-- a type is a named content type specification which allows attribute
+ declarations-->
+<!-- -->
+
+<!ELEMENT %complexType; ((%annotation;)?,
+ (%simpleContent;|%complexContent;|
+ %particleAndAttrs;))>
+
+<!ATTLIST %complexType;
+ name %NCName; #IMPLIED
+ id ID #IMPLIED
+ abstract %boolean; #IMPLIED
+ final %complexDerivationSet; #IMPLIED
+ block %complexDerivationSet; #IMPLIED
+ mixed (true|false) 'false'
+ %complexTypeAttrs;>
+
+<!-- particleAndAttrs is shorthand for a root type -->
+<!-- mixed is disallowed if simpleContent, overriden if complexContent
+ has one too. -->
+
+<!-- If anyAttribute appears in one or more referenced attributeGroups
+ and/or explicitly, the intersection of the permissions is used -->
+
+<!ELEMENT %complexContent; ((%annotation;)?, (%restriction;|%extension;))>
+<!ATTLIST %complexContent;
+ mixed (true|false) #IMPLIED
+ id ID #IMPLIED
+ %complexContentAttrs;>
+
+<!-- restriction should use the branch defined above, not the simple
+ one from part2; extension should use the full model -->
+
+<!ELEMENT %simpleContent; ((%annotation;)?, (%restriction;|%extension;))>
+<!ATTLIST %simpleContent;
+ id ID #IMPLIED
+ %simpleContentAttrs;>
+
+<!-- restriction should use the simple branch from part2, not the
+ one defined above; extension should have no particle -->
+
+<!ELEMENT %extension; ((%annotation;)?, (%particleAndAttrs;))>
+<!ATTLIST %extension;
+ base %QName; #REQUIRED
+ id ID #IMPLIED
+ %extensionAttrs;>
+
+<!-- an element is declared by either:
+ a name and a type (either nested or referenced via the type attribute)
+ or a ref to an existing element declaration -->
+
+<!ELEMENT %element; ((%annotation;)?, (%complexType;| %simpleType;)?,
+ (%unique; | %key; | %keyref;)*)>
+<!-- simpleType or complexType only if no type|ref attribute -->
+<!-- ref not allowed at top level -->
+<!ATTLIST %element;
+ name %NCName; #IMPLIED
+ id ID #IMPLIED
+ ref %QName; #IMPLIED
+ type %QName; #IMPLIED
+ minOccurs %nonNegativeInteger; #IMPLIED
+ maxOccurs CDATA #IMPLIED
+ nillable %boolean; #IMPLIED
+ substitutionGroup %QName; #IMPLIED
+ abstract %boolean; #IMPLIED
+ final %complexDerivationSet; #IMPLIED
+ block %blockSet; #IMPLIED
+ default CDATA #IMPLIED
+ fixed CDATA #IMPLIED
+ form %formValues; #IMPLIED
+ %elementAttrs;>
+<!-- type and ref are mutually exclusive.
+ name and ref are mutually exclusive, one is required -->
+<!-- In the absence of type AND ref, type defaults to type of
+ substitutionGroup, if any, else the ur-type, i.e. unconstrained -->
+<!-- default and fixed are mutually exclusive -->
+
+<!ELEMENT %group; ((%annotation;)?,(%mgs;)?)>
+<!ATTLIST %group;
+ name %NCName; #IMPLIED
+ ref %QName; #IMPLIED
+ minOccurs %nonNegativeInteger; #IMPLIED
+ maxOccurs CDATA #IMPLIED
+ id ID #IMPLIED
+ %groupAttrs;>
+
+<!ELEMENT %all; ((%annotation;)?, (%element;)*)>
+<!ATTLIST %all;
+ minOccurs (1) #IMPLIED
+ maxOccurs (1) #IMPLIED
+ id ID #IMPLIED
+ %allAttrs;>
+
+<!ELEMENT %choice; ((%annotation;)?, (%element;| %group;| %cs; | %any;)*)>
+<!ATTLIST %choice;
+ minOccurs %nonNegativeInteger; #IMPLIED
+ maxOccurs CDATA #IMPLIED
+ id ID #IMPLIED
+ %choiceAttrs;>
+
+<!ELEMENT %sequence; ((%annotation;)?, (%element;| %group;| %cs; | %any;)*)>
+<!ATTLIST %sequence;
+ minOccurs %nonNegativeInteger; #IMPLIED
+ maxOccurs CDATA #IMPLIED
+ id ID #IMPLIED
+ %sequenceAttrs;>
+
+<!-- an anonymous grouping in a model, or
+ a top-level named group definition, or a reference to same -->
+
+<!-- Note that if order is 'all', group is not allowed inside.
+ If order is 'all' THIS group must be alone (or referenced alone) at
+ the top level of a content model -->
+<!-- If order is 'all', minOccurs==maxOccurs==1 on element/any inside -->
+<!-- Should allow minOccurs=0 inside order='all' . . . -->
+
+<!ELEMENT %any; (%annotation;)?>
+<!ATTLIST %any;
+ namespace CDATA '##any'
+ processContents (skip|lax|strict) 'strict'
+ minOccurs %nonNegativeInteger; '1'
+ maxOccurs CDATA '1'
+ id ID #IMPLIED
+ %anyAttrs;>
+
+<!-- namespace is interpreted as follows:
+ ##any - - any non-conflicting WFXML at all
+
+ ##other - - any non-conflicting WFXML from namespace other
+ than targetNamespace
+
+ ##local - - any unqualified non-conflicting WFXML/attribute
+ one or - - any non-conflicting WFXML from
+ more URI the listed namespaces
+ references
+
+ ##targetNamespace ##local may appear in the above list,
+ with the obvious meaning -->
+
+<!ELEMENT %anyAttribute; (%annotation;)?>
+<!ATTLIST %anyAttribute;
+ namespace CDATA '##any'
+ processContents (skip|lax|strict) 'strict'
+ id ID #IMPLIED
+ %anyAttributeAttrs;>
+<!-- namespace is interpreted as for 'any' above -->
+
+<!-- simpleType only if no type|ref attribute -->
+<!-- ref not allowed at top level, name iff at top level -->
+<!ELEMENT %attribute; ((%annotation;)?, (%simpleType;)?)>
+<!ATTLIST %attribute;
+ name %NCName; #IMPLIED
+ id ID #IMPLIED
+ ref %QName; #IMPLIED
+ type %QName; #IMPLIED
+ use (prohibited|optional|required) #IMPLIED
+ default CDATA #IMPLIED
+ fixed CDATA #IMPLIED
+ form %formValues; #IMPLIED
+ %attributeAttrs;>
+<!-- type and ref are mutually exclusive.
+ name and ref are mutually exclusive, one is required -->
+<!-- default for use is optional when nested, none otherwise -->
+<!-- default and fixed are mutually exclusive -->
+<!-- type attr and simpleType content are mutually exclusive -->
+
+<!-- an attributeGroup is a named collection of attribute decls, or a
+ reference thereto -->
+<!ELEMENT %attributeGroup; ((%annotation;)?,
+ (%attribute; | %attributeGroup;)*,
+ (%anyAttribute;)?) >
+<!ATTLIST %attributeGroup;
+ name %NCName; #IMPLIED
+ id ID #IMPLIED
+ ref %QName; #IMPLIED
+ %attributeGroupAttrs;>
+
+<!-- ref iff no content, no name. ref iff not top level -->
+
+<!-- better reference mechanisms -->
+<!ELEMENT %unique; ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %unique;
+ name %NCName; #REQUIRED
+ id ID #IMPLIED
+ %uniqueAttrs;>
+
+<!ELEMENT %key; ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %key;
+ name %NCName; #REQUIRED
+ id ID #IMPLIED
+ %keyAttrs;>
+
+<!ELEMENT %keyref; ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %keyref;
+ name %NCName; #REQUIRED
+ refer %QName; #REQUIRED
+ id ID #IMPLIED
+ %keyrefAttrs;>
+
+<!ELEMENT %selector; ((%annotation;)?)>
+<!ATTLIST %selector;
+ xpath %XPathExpr; #REQUIRED
+ id ID #IMPLIED
+ %selectorAttrs;>
+<!ELEMENT %field; ((%annotation;)?)>
+<!ATTLIST %field;
+ xpath %XPathExpr; #REQUIRED
+ id ID #IMPLIED
+ %fieldAttrs;>
+
+<!-- Schema combination mechanisms -->
+<!ELEMENT %include; (%annotation;)?>
+<!ATTLIST %include;
+ schemaLocation %URIref; #REQUIRED
+ id ID #IMPLIED
+ %includeAttrs;>
+
+<!ELEMENT %import; (%annotation;)?>
+<!ATTLIST %import;
+ namespace %URIref; #IMPLIED
+ schemaLocation %URIref; #IMPLIED
+ id ID #IMPLIED
+ %importAttrs;>
+
+<!ELEMENT %redefine; (%annotation; | %simpleType; | %complexType; |
+ %attributeGroup; | %group;)*>
+<!ATTLIST %redefine;
+ schemaLocation %URIref; #REQUIRED
+ id ID #IMPLIED
+ %redefineAttrs;>
+
+<!ELEMENT %notation; (%annotation;)?>
+<!ATTLIST %notation;
+ name %NCName; #REQUIRED
+ id ID #IMPLIED
+ public CDATA #REQUIRED
+ system %URIref; #IMPLIED
+ %notationAttrs;>
+
+<!-- Annotation is either application information or documentation -->
+<!-- By having these here they are available for datatypes as well
+ as all the structures elements -->
+
+<!ELEMENT %annotation; (%appinfo; | %documentation;)*>
+<!ATTLIST %annotation; %annotationAttrs;>
+
+<!-- User must define annotation elements in internal subset for this
+ to work -->
+<!ELEMENT %appinfo; ANY> <!-- too restrictive -->
+<!ATTLIST %appinfo;
+ source %URIref; #IMPLIED
+ id ID #IMPLIED
+ %appinfoAttrs;>
+<!ELEMENT %documentation; ANY> <!-- too restrictive -->
+<!ATTLIST %documentation;
+ source %URIref; #IMPLIED
+ id ID #IMPLIED
+ xml:lang CDATA #IMPLIED
+ %documentationAttrs;>
+
+<!NOTATION XMLSchemaStructures PUBLIC
+ 'structures' 'http://www.w3.org/2001/XMLSchema.xsd' >
+<!NOTATION XML PUBLIC
+ 'REC-xml-1998-0210' 'http://www.w3.org/TR/1998/REC-xml-19980210' >
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd
new file mode 100644
index 0000000000..685e89a57e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd
@@ -0,0 +1,204 @@
+<!--
+ DTD for XML Schemas: Part 2: Datatypes
+ $Id: datatypes.dtd,v 1.23 2001/03/16 17:36:30 ht Exp $
+ Note this DTD is NOT normative, or even definitive. - - the
+ prose copy in the datatypes REC is the definitive version
+ (which shouldn't differ from this one except for this comment
+ and entity expansions, but just in case)
+ -->
+
+<!--
+ This DTD cannot be used on its own, it is intended
+ only for incorporation in XMLSchema.dtd, q.v.
+ -->
+
+<!-- Define all the element names, with optional prefix -->
+<!ENTITY % simpleType "%p;simpleType">
+<!ENTITY % restriction "%p;restriction">
+<!ENTITY % list "%p;list">
+<!ENTITY % union "%p;union">
+<!ENTITY % maxExclusive "%p;maxExclusive">
+<!ENTITY % minExclusive "%p;minExclusive">
+<!ENTITY % maxInclusive "%p;maxInclusive">
+<!ENTITY % minInclusive "%p;minInclusive">
+<!ENTITY % totalDigits "%p;totalDigits">
+<!ENTITY % fractionDigits "%p;fractionDigits">
+<!ENTITY % length "%p;length">
+<!ENTITY % minLength "%p;minLength">
+<!ENTITY % maxLength "%p;maxLength">
+<!ENTITY % enumeration "%p;enumeration">
+<!ENTITY % whiteSpace "%p;whiteSpace">
+<!ENTITY % pattern "%p;pattern">
+
+<!--
+ Customisation entities for the ATTLIST of each element
+ type. Define one of these if your schema takes advantage
+ of the anyAttribute='##other' in the schema for schemas
+ -->
+
+<!ENTITY % simpleTypeAttrs "">
+<!ENTITY % restrictionAttrs "">
+<!ENTITY % listAttrs "">
+<!ENTITY % unionAttrs "">
+<!ENTITY % maxExclusiveAttrs "">
+<!ENTITY % minExclusiveAttrs "">
+<!ENTITY % maxInclusiveAttrs "">
+<!ENTITY % minInclusiveAttrs "">
+<!ENTITY % totalDigitsAttrs "">
+<!ENTITY % fractionDigitsAttrs "">
+<!ENTITY % lengthAttrs "">
+<!ENTITY % minLengthAttrs "">
+<!ENTITY % maxLengthAttrs "">
+<!ENTITY % enumerationAttrs "">
+<!ENTITY % whiteSpaceAttrs "">
+<!ENTITY % patternAttrs "">
+
+<!-- Define some entities for informative use as attribute
+ types -->
+<!ENTITY % URIref "CDATA">
+<!ENTITY % XPathExpr "CDATA">
+<!ENTITY % QName "NMTOKEN">
+<!ENTITY % QNames "NMTOKENS">
+<!ENTITY % NCName "NMTOKEN">
+<!ENTITY % nonNegativeInteger "NMTOKEN">
+<!ENTITY % boolean "(true|false)">
+<!ENTITY % simpleDerivationSet "CDATA">
+<!--
+ #all or space-separated list drawn from derivationChoice
+ -->
+
+<!--
+ Note that the use of 'facet' below is less restrictive
+ than is really intended: There should in fact be no
+ more than one of each of minInclusive, minExclusive,
+ maxInclusive, maxExclusive, totalDigits, fractionDigits,
+ length, maxLength, minLength within datatype,
+ and the min- and max- variants of Inclusive and Exclusive
+ are mutually exclusive. On the other hand, pattern and
+ enumeration may repeat.
+ -->
+<!ENTITY % minBound "(%minInclusive; | %minExclusive;)">
+<!ENTITY % maxBound "(%maxInclusive; | %maxExclusive;)">
+<!ENTITY % bounds "%minBound; | %maxBound;">
+<!ENTITY % numeric "%totalDigits; | %fractionDigits;">
+<!ENTITY % ordered "%bounds; | %numeric;">
+<!ENTITY % unordered
+ "%pattern; | %enumeration; | %whiteSpace; | %length; |
+ %maxLength; | %minLength;">
+<!ENTITY % facet "%ordered; | %unordered;">
+<!ENTITY % facetAttr
+ "value CDATA #REQUIRED
+ id ID #IMPLIED">
+<!ENTITY % fixedAttr "fixed %boolean; #IMPLIED">
+<!ENTITY % facetModel "(%annotation;)?">
+<!ELEMENT %simpleType;
+ ((%annotation;)?, (%restriction; | %list; | %union;))>
+<!ATTLIST %simpleType;
+ name %NCName; #IMPLIED
+ final %simpleDerivationSet; #IMPLIED
+ id ID #IMPLIED
+ %simpleTypeAttrs;>
+<!-- name is required at top level -->
+<!ELEMENT %restriction; ((%annotation;)?,
+ (%restriction1; |
+ ((%simpleType;)?,(%facet;)*)),
+ (%attrDecls;))>
+<!ATTLIST %restriction;
+ base %QName; #IMPLIED
+ id ID #IMPLIED
+ %restrictionAttrs;>
+<!--
+ base and simpleType child are mutually exclusive,
+ one is required.
+
+ restriction is shared between simpleType and
+ simpleContent and complexContent (in XMLSchema.xsd).
+ restriction1 is for the latter cases, when this
+ is restricting a complex type, as is attrDecls.
+ -->
+<!ELEMENT %list; ((%annotation;)?,(%simpleType;)?)>
+<!ATTLIST %list;
+ itemType %QName; #IMPLIED
+ id ID #IMPLIED
+ %listAttrs;>
+<!--
+ itemType and simpleType child are mutually exclusive,
+ one is required
+ -->
+<!ELEMENT %union; ((%annotation;)?,(%simpleType;)*)>
+<!ATTLIST %union;
+ id ID #IMPLIED
+ memberTypes %QNames; #IMPLIED
+ %unionAttrs;>
+<!--
+ At least one item in memberTypes or one simpleType
+ child is required
+ -->
+
+<!ELEMENT %maxExclusive; %facetModel;>
+<!ATTLIST %maxExclusive;
+ %facetAttr;
+ %fixedAttr;
+ %maxExclusiveAttrs;>
+<!ELEMENT %minExclusive; %facetModel;>
+<!ATTLIST %minExclusive;
+ %facetAttr;
+ %fixedAttr;
+ %minExclusiveAttrs;>
+
+<!ELEMENT %maxInclusive; %facetModel;>
+<!ATTLIST %maxInclusive;
+ %facetAttr;
+ %fixedAttr;
+ %maxInclusiveAttrs;>
+<!ELEMENT %minInclusive; %facetModel;>
+<!ATTLIST %minInclusive;
+ %facetAttr;
+ %fixedAttr;
+ %minInclusiveAttrs;>
+
+<!ELEMENT %totalDigits; %facetModel;>
+<!ATTLIST %totalDigits;
+ %facetAttr;
+ %fixedAttr;
+ %totalDigitsAttrs;>
+<!ELEMENT %fractionDigits; %facetModel;>
+<!ATTLIST %fractionDigits;
+ %facetAttr;
+ %fixedAttr;
+ %fractionDigitsAttrs;>
+
+<!ELEMENT %length; %facetModel;>
+<!ATTLIST %length;
+ %facetAttr;
+ %fixedAttr;
+ %lengthAttrs;>
+<!ELEMENT %minLength; %facetModel;>
+<!ATTLIST %minLength;
+ %facetAttr;
+ %fixedAttr;
+ %minLengthAttrs;>
+<!ELEMENT %maxLength; %facetModel;>
+<!ATTLIST %maxLength;
+ %facetAttr;
+ %fixedAttr;
+ %maxLengthAttrs;>
+
+<!-- This one can be repeated -->
+<!ELEMENT %enumeration; %facetModel;>
+<!ATTLIST %enumeration;
+ %facetAttr;
+ %enumerationAttrs;>
+
+<!ELEMENT %whiteSpace; %facetModel;>
+<!ATTLIST %whiteSpace;
+ %facetAttr;
+ %fixedAttr;
+ %whiteSpaceAttrs;>
+
+<!-- This one can be repeated -->
+<!ELEMENT %pattern; %facetModel;>
+<!ATTLIST %pattern;
+ %facetAttr;
+ %patternAttrs;>
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd
new file mode 100644
index 0000000000..641798b17f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS's procedures with respect to rights in OASIS specifications can be found at the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementors or users of this specification, can be obtained from the OASIS Executive Director.
+OASIS invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to implement this specification. Please address the information to the OASIS Executive Director.
+Copyright © OASIS Open 2002-2004. All Rights Reserved.
+This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself does not be modified in any way, such as by removing the copyright notice or references to OASIS, except as needed for the purpose of developing OASIS specifications, in which case the procedures for copyrights defined in the OASIS Intellectual Property Rights document must be followed, or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.
+This document and the information contained herein is provided on an “AS IS†basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+-->
+<xsd:schema targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified" attributeFormDefault="unqualified" blockDefault="#all" version="0.2">
+ <xsd:import namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" schemaLocation="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+ <xsd:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"/>
+ <xsd:complexType name="AttributedString">
+ <xsd:annotation>
+ <xsd:documentation>This type represents an element with arbitrary attributes.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute ref="wsu:Id"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="PasswordString">
+ <xsd:annotation>
+ <xsd:documentation>This type is used for password elements per Section 4.1.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="wsse:AttributedString">
+ <xsd:attribute name="Type" type="xsd:anyURI"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="EncodedString">
+ <xsd:annotation>
+ <xsd:documentation>This type is used for elements containing stringified binary data.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="wsse:AttributedString">
+ <xsd:attribute name="EncodingType" type="xsd:anyURI"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="UsernameTokenType">
+ <xsd:annotation>
+ <xsd:documentation>This type represents a username token per Section 4.1</xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="Username" type="wsse:AttributedString"/>
+ <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute ref="wsu:Id"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="BinarySecurityTokenType">
+ <xsd:annotation>
+ <xsd:documentation>A security token that is encoded in binary</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="wsse:EncodedString">
+ <xsd:attribute name="ValueType" type="xsd:anyURI"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="KeyIdentifierType">
+ <xsd:annotation>
+ <xsd:documentation>A security token key identifier</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="wsse:EncodedString">
+ <xsd:attribute name="ValueType" type="xsd:anyURI"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:simpleType name="tUsage">
+ <xsd:annotation>
+ <xsd:documentation>Typedef to allow a list of usages (as URIs).</xsd:documentation>
+ </xsd:annotation>
+ <xsd:list itemType="xsd:anyURI"/>
+ </xsd:simpleType>
+ <xsd:attribute name="Usage" type="tUsage">
+ <xsd:annotation>
+ <xsd:documentation>This global attribute is used to indicate the usage of a referenced or indicated token within the containing context</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:complexType name="ReferenceType">
+ <xsd:annotation>
+ <xsd:documentation>This type represents a reference to an external security token.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="URI" type="xsd:anyURI"/>
+ <xsd:attribute name="ValueType" type="xsd:anyURI"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="EmbeddedType">
+ <xsd:annotation>
+ <xsd:documentation>This type represents a reference to an embedded security token.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:any processContents="lax"/>
+ </xsd:choice>
+ <xsd:attribute name="ValueType" type="xsd:anyURI"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="SecurityTokenReferenceType">
+ <xsd:annotation>
+ <xsd:documentation>This type is used reference a security token.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:any processContents="lax"/>
+ </xsd:choice>
+ <xsd:attribute ref="wsu:Id"/>
+ <xsd:attribute ref="wsse:Usage"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="SecurityHeaderType">
+ <xsd:annotation>
+ <xsd:documentation>This complexType defines header block to use for security-relevant data directed at a specific SOAP actor.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>The use of "any" is to allow extensibility and different forms of security data.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:any>
+ </xsd:sequence>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:complexType name="TransformationParametersType">
+ <xsd:annotation>
+ <xsd:documentation>This complexType defines a container for elements to be specified from any namespace as properties/parameters of a DSIG transformation.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>The use of "any" is to allow extensibility from any namespace.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:any>
+ </xsd:sequence>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:complexType>
+ <xsd:element name="UsernameToken" type="wsse:UsernameTokenType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines the wsse:UsernameToken element per Section 4.1.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="BinarySecurityToken" type="wsse:BinarySecurityTokenType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines the wsse:BinarySecurityToken element per Section 4.2.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Reference" type="wsse:ReferenceType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines a security token reference</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Embedded" type="wsse:EmbeddedType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines a security token embedded reference</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="KeyIdentifier" type="wsse:KeyIdentifierType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines a key identifier reference</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="SecurityTokenReference" type="wsse:SecurityTokenReferenceType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines the wsse:SecurityTokenReference per Section 4.3.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Security" type="wsse:SecurityHeaderType">
+ <xsd:annotation>
+ <xsd:documentation>This element defines the wsse:Security SOAP header element per Section 4.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="TransformationParameters" type="wsse:TransformationParametersType">
+ <xsd:annotation>
+ <xsd:documentation>This element contains properties for transformations from any namespace, including DSIG.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Password" type="wsse:PasswordString"/>
+ <xsd:element name="Nonce" type="wsse:EncodedString"/>
+ <xsd:simpleType name="FaultcodeEnum">
+ <xsd:restriction base="xsd:QName">
+ <xsd:enumeration value="wsse:UnsupportedSecurityToken"/>
+ <xsd:enumeration value="wsse:UnsupportedAlgorithm"/>
+ <xsd:enumeration value="wsse:InvalidSecurity"/>
+ <xsd:enumeration value="wsse:InvalidSecurityToken"/>
+ <xsd:enumeration value="wsse:FailedAuthentication"/>
+ <xsd:enumeration value="wsse:FailedCheck"/>
+ <xsd:enumeration value="wsse:SecurityTokenUnavailable"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+</xsd:schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd
new file mode 100644
index 0000000000..f8d74e9c6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS's procedures with respect to rights in OASIS specifications can be found at the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementors or users of this specification, can be obtained from the OASIS Executive Director.
+OASIS invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to implement this specification. Please address the information to the OASIS Executive Director.
+Copyright © OASIS Open 2002-2004. All Rights Reserved.
+This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself does not be modified in any way, such as by removing the copyright notice or references to OASIS, except as needed for the purpose of developing OASIS specifications, in which case the procedures for copyrights defined in the OASIS Intellectual Property Rights document must be followed, or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.
+This document and the information contained herein is provided on an “AS IS†basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+-->
+<xsd:schema targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
+
+
+xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.1">
+ <!-- // Fault Codes /////////////////////////////////////////// -->
+ <xsd:simpleType name="tTimestampFault">
+ <xsd:annotation>
+ <xsd:documentation>
+This type defines the fault code value for Timestamp message expiration.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:QName">
+ <xsd:enumeration value="wsu:MessageExpired"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- // Global attributes //////////////////////////////////// -->
+ <xsd:attribute name="Id" type="xsd:ID">
+ <xsd:annotation>
+ <xsd:documentation>
+This global attribute supports annotating arbitrary elements with an ID.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attributeGroup name="commonAtts">
+ <xsd:annotation>
+ <xsd:documentation>
+Convenience attribute group used to simplify this schema.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute ref="wsu:Id" use="optional"/>
+ <xsd:anyAttribute namespace="##other" processContents="lax"/>
+ </xsd:attributeGroup>
+ <!-- // Utility types //////////////////////////////////////// -->
+ <xsd:complexType name="AttributedDateTime">
+ <xsd:annotation>
+ <xsd:documentation>
+This type is for elements whose [children] is a psuedo-dateTime and can have arbitrary attributes.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attributeGroup ref="wsu:commonAtts"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="AttributedURI">
+ <xsd:annotation>
+ <xsd:documentation>
+This type is for elements whose [children] is an anyURI and can have arbitrary attributes.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:anyURI">
+ <xsd:attributeGroup ref="wsu:commonAtts"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <!-- // Timestamp header components /////////////////////////// -->
+ <xsd:complexType name="TimestampType">
+ <xsd:annotation>
+ <xsd:documentation>
+This complex type ties together the timestamp related elements into a composite type.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="wsu:Created" minOccurs="0"/>
+ <xsd:element ref="wsu:Expires" minOccurs="0"/>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:any namespace="##other" processContents="lax"/>
+ </xsd:choice>
+ </xsd:sequence>
+ <xsd:attributeGroup ref="wsu:commonAtts"/>
+ </xsd:complexType>
+ <xsd:element name="Timestamp" type="wsu:TimestampType">
+ <xsd:annotation>
+ <xsd:documentation>
+This element allows Timestamps to be applied anywhere element wildcards are present,
+including as a SOAP header.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- global element decls to allow individual elements to appear anywhere -->
+ <xsd:element name="Expires" type="wsu:AttributedDateTime">
+ <xsd:annotation>
+ <xsd:documentation>
+This element allows an expiration time to be applied anywhere element wildcards are present.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="Created" type="wsu:AttributedDateTime">
+ <xsd:annotation>
+ <xsd:documentation>
+This element allows a creation time to be applied anywhere element wildcards are present.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+</xsd:schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd
new file mode 100644
index 0000000000..f6fc9c53b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ W3C XML Schema defined in the Web Services Addressing 1.0 specification
+ http://www.w3.org/TR/ws-addr-core
+
+ Copyright © 2005 World Wide Web Consortium,
+
+ (Massachusetts Institute of Technology, European Research Consortium for
+ Informatics and Mathematics, Keio University). All Rights Reserved. This
+ work is distributed under the W3C® Software License [1] in the hope that
+ it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+ $Id: ws-addr.xsd,v 1.2 2008/07/23 13:38:16 plehegar Exp $
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2005/08/addressing" targetNamespace="http://www.w3.org/2005/08/addressing" blockDefault="#all" elementFormDefault="qualified" finalDefault="" attributeFormDefault="unqualified">
+
+ <!-- Constructs from the WS-Addressing Core -->
+
+ <xs:element name="EndpointReference" type="tns:EndpointReferenceType"/>
+ <xs:complexType name="EndpointReferenceType" mixed="false">
+ <xs:sequence>
+ <xs:element name="Address" type="tns:AttributedURIType"/>
+ <xs:element ref="tns:ReferenceParameters" minOccurs="0"/>
+ <xs:element ref="tns:Metadata" minOccurs="0"/>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="ReferenceParameters" type="tns:ReferenceParametersType"/>
+ <xs:complexType name="ReferenceParametersType" mixed="false">
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="Metadata" type="tns:MetadataType"/>
+ <xs:complexType name="MetadataType" mixed="false">
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="MessageID" type="tns:AttributedURIType"/>
+ <xs:element name="RelatesTo" type="tns:RelatesToType"/>
+ <xs:complexType name="RelatesToType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:attribute name="RelationshipType" type="tns:RelationshipTypeOpenEnum" use="optional" default="http://www.w3.org/2005/08/addressing/reply"/>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:simpleType name="RelationshipTypeOpenEnum">
+ <xs:union memberTypes="tns:RelationshipType xs:anyURI"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="RelationshipType">
+ <xs:restriction base="xs:anyURI">
+ <xs:enumeration value="http://www.w3.org/2005/08/addressing/reply"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="ReplyTo" type="tns:EndpointReferenceType"/>
+ <xs:element name="From" type="tns:EndpointReferenceType"/>
+ <xs:element name="FaultTo" type="tns:EndpointReferenceType"/>
+ <xs:element name="To" type="tns:AttributedURIType"/>
+ <xs:element name="Action" type="tns:AttributedURIType"/>
+
+ <xs:complexType name="AttributedURIType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <!-- Constructs from the WS-Addressing SOAP binding -->
+
+ <xs:attribute name="IsReferenceParameter" type="xs:boolean"/>
+
+ <xs:simpleType name="FaultCodesOpenEnumType">
+ <xs:union memberTypes="tns:FaultCodesType xs:QName"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="FaultCodesType">
+ <xs:restriction base="xs:QName">
+ <xs:enumeration value="tns:InvalidAddressingHeader"/>
+ <xs:enumeration value="tns:InvalidAddress"/>
+ <xs:enumeration value="tns:InvalidEPR"/>
+ <xs:enumeration value="tns:InvalidCardinality"/>
+ <xs:enumeration value="tns:MissingAddressInEPR"/>
+ <xs:enumeration value="tns:DuplicateMessageID"/>
+ <xs:enumeration value="tns:ActionMismatch"/>
+ <xs:enumeration value="tns:MessageAddressingHeaderRequired"/>
+ <xs:enumeration value="tns:DestinationUnreachable"/>
+ <xs:enumeration value="tns:ActionNotSupported"/>
+ <xs:enumeration value="tns:EndpointUnavailable"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="RetryAfter" type="tns:AttributedUnsignedLongType"/>
+ <xs:complexType name="AttributedUnsignedLongType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:unsignedLong">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:element name="ProblemHeaderQName" type="tns:AttributedQNameType"/>
+ <xs:complexType name="AttributedQNameType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:QName">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:element name="ProblemIRI" type="tns:AttributedURIType"/>
+
+ <xs:element name="ProblemAction" type="tns:ProblemActionType"/>
+ <xs:complexType name="ProblemActionType" mixed="false">
+ <xs:sequence>
+ <xs:element ref="tns:Action" minOccurs="0"/>
+ <xs:element name="SoapAction" minOccurs="0" type="xs:anyURI"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+</xs:schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd
new file mode 100644
index 0000000000..c43e5814ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd
@@ -0,0 +1,141 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!--
+
+ W3C XML Schema defined in the Web Services Policy 1.5
+ Framework specification
+
+ http://www.w3.org/TR/ws-policy-framework
+
+ Copyright © 2006 World Wide Web Consortium,
+
+ (Massachusetts Institute of Technology, European Research Consortium for
+ Informatics and Mathematics, Keio University). All Rights Reserved. This
+ work is distributed under the W3C® Software License [1] in the hope that
+ it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+ $Id: ws-policy.xsd,v 1.2 2007/02/14 16:38:37 fsasaki Exp $
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://www.w3.org/ns/ws-policy"
+ xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ targetNamespace="http://www.w3.org/ns/ws-policy" blockDefault="#all"
+ elementFormDefault="qualified">
+
+ <xs:import
+ namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
+ schemaLocation="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" />
+
+ <xs:import
+ namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ schemaLocation="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" />
+
+ <xs:import
+ namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/xml.xsd" />
+
+ <!-- Constructs from the Web Services Policy 1.5 Framework -->
+
+ <xs:element name="Policy" >
+ <xs:complexType>
+
+ <xs:complexContent>
+ <xs:extension base="tns:OperatorContentType" >
+ <xs:attribute name="Name" type="xs:anyURI" />
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="All" type="tns:OperatorContentType" />
+ <xs:element name="ExactlyOne" type="tns:OperatorContentType" />
+
+ <xs:complexType name="OperatorContentType" >
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded" >
+ <xs:element ref="tns:Policy" />
+ <xs:element ref="tns:All" />
+ <xs:element ref="tns:ExactlyOne" />
+
+ <xs:element ref="tns:PolicyReference" />
+ <xs:any namespace="##other" processContents="lax" />
+ </xs:choice>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="PolicyReference" >
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="URI" type="xs:anyURI" use="required" />
+
+ <xs:attribute name="Digest" type="xs:base64Binary" />
+ <xs:attribute name="DigestAlgorithm"
+ type="xs:anyURI"
+ default="http://www.w3.org/ns/ws-policy/Sha1Exc"
+ />
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:attribute name="Optional" type="xs:boolean" default="false" />
+ <xs:attribute name="Ignorable" type="xs:boolean" default="false" />
+
+ <!-- Constructs from the Web Services Policy 1.5 Attachment -->
+
+ <xs:attribute name="PolicyURIs" >
+ <xs:simpleType>
+ <xs:list itemType="xs:anyURI" />
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:element name="PolicyAttachment" >
+ <xs:complexType>
+ <xs:sequence>
+
+ <xs:element ref="tns:AppliesTo" />
+ <xs:choice maxOccurs="unbounded" >
+ <xs:element ref="tns:Policy" />
+ <xs:element ref="tns:PolicyReference" />
+ </xs:choice>
+ <!-- omitted only because it causes the content model to be non-determistic
+ <xs:element ref="wsse:Security" minOccurs="0" />
+-->
+ <xs:any namespace="##other"
+ processContents="lax"
+ minOccurs="0"
+ maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="AppliesTo" >
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##any"
+ processContents="lax"
+ maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="URI">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:anyAttribute namespace="##any" processContents="lax" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd
new file mode 100644
index 0000000000..7fb8c1beed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd">
+<!--
+ W3C XML Schema defined in the Web Services Description (WSDL)
+ Version 2.0 specification
+ http://www.w3.org/TR/wsdl20
+
+ Copyright © 2007 World Wide Web Consortium,
+
+ (Massachusetts Institute of Technology, European Research Consortium for
+ Informatics and Mathematics, Keio University). All Rights Reserved. This
+ work is distributed under the W3C® Software License [1] in the hope that
+ it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+ $Id: wsdl20-instance.xsd,v 1.1 2007/06/19 15:59:38 plehegar Exp $
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdli="http://www.w3.org/ns/wsdl-instance" targetNamespace="http://www.w3.org/ns/wsdl-instance" elementFormDefault="qualified" finalDefault="" blockDefault="" attributeFormDefault="unqualified">
+
+ <xs:attribute name="wsdlLocation">
+ <xs:annotation>
+ <xs:documentation>
+ This attribute can be used to provide some hints on where
+ additional WSDL information for a given namespace can be
+ found in order to help with QName resolution
+ </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:list itemType="xs:anyURI"/>
+ </xs:simpleType>
+ </xs:attribute>
+
+</xs:schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd
new file mode 100644
index 0000000000..ac4b0ec8e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd
@@ -0,0 +1,117 @@
+<?xml version='1.0'?>
+<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" >
+<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en">
+
+ <xs:annotation>
+ <xs:documentation>
+ See http://www.w3.org/XML/1998/namespace.html and
+ http://www.w3.org/TR/REC-xml for information about this namespace.
+
+ This schema document describes the XML namespace, in a form
+ suitable for import by other schema documents.
+
+ Note that local names in this namespace are intended to be defined
+ only by the World Wide Web Consortium or its subgroups. The
+ following names are currently defined in this namespace and should
+ not be used with conflicting semantics by any Working Group,
+ specification, or document instance:
+
+ base (as an attribute name): denotes an attribute whose value
+ provides a URI to be used as the base for interpreting any
+ relative URIs in the scope of the element on which it
+ appears; its value is inherited. This name is reserved
+ by virtue of its definition in the XML Base specification.
+
+ lang (as an attribute name): denotes an attribute whose value
+ is a language code for the natural language of the content of
+ any element; its value is inherited. This name is reserved
+ by virtue of its definition in the XML specification.
+
+ space (as an attribute name): denotes an attribute whose
+ value is a keyword indicating what whitespace processing
+ discipline is intended for the content of the element; its
+ value is inherited. This name is reserved by virtue of its
+ definition in the XML specification.
+
+ Father (in any context at all): denotes Jon Bosak, the chair of
+ the original XML Working Group. This name is reserved by
+ the following decision of the W3C XML Plenary and
+ XML Coordination groups:
+
+ In appreciation for his vision, leadership and dedication
+ the W3C XML Plenary on this 10th day of February, 2000
+ reserves for Jon Bosak in perpetuity the XML name
+ xml:Father
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+ <xs:documentation>This schema defines attributes and an attribute group
+ suitable for use by
+ schemas wishing to allow xml:base, xml:lang or xml:space attributes
+ on elements they define.
+
+ To enable this, such a schema must import this schema
+ for the XML namespace, e.g. as follows:
+ &lt;schema . . .>
+ . . .
+ &lt;import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
+
+ Subsequently, qualified reference to any of the attributes
+ or the group defined below will have the desired effect, e.g.
+
+ &lt;type . . .>
+ . . .
+ &lt;attributeGroup ref="xml:specialAttrs"/>
+
+ will define a type which will schema-validate an instance
+ element with any of those attributes</xs:documentation>
+ </xs:annotation>
+
+ <xs:annotation>
+ <xs:documentation>In keeping with the XML Schema WG's standard versioning
+ policy, this schema document will persist at
+ http://www.w3.org/2001/03/xml.xsd.
+ At the date of issue it can also be found at
+ http://www.w3.org/2001/xml.xsd.
+ The schema document at that URI may however change in the future,
+ in order to remain compatible with the latest version of XML Schema
+ itself. In other words, if the XML Schema namespace changes, the version
+ of this document at
+ http://www.w3.org/2001/xml.xsd will change
+ accordingly; the version at
+ http://www.w3.org/2001/03/xml.xsd will not change.
+ </xs:documentation>
+ </xs:annotation>
+
+ <xs:attribute name="lang" type="xs:language">
+ <xs:annotation>
+ <xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter
+ codes as the enumerated possible values . . .</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="space" default="preserve">
+ <xs:simpleType>
+ <xs:restriction base="xs:NCName">
+ <xs:enumeration value="default"/>
+ <xs:enumeration value="preserve"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="base" type="xs:anyURI">
+ <xs:annotation>
+ <xs:documentation>See http://www.w3.org/TR/xmlbase/ for
+ information about this attribute.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attributeGroup name="specialAttrs">
+ <xs:attribute ref="xml:base"/>
+ <xs:attribute ref="xml:lang"/>
+ <xs:attribute ref="xml:space"/>
+ </xs:attributeGroup>
+
+</xs:schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd
new file mode 100644
index 0000000000..c4e9808cfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd
@@ -0,0 +1,318 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE schema
+ PUBLIC "-//W3C//DTD XMLSchema 200102//EN" "XMLSchema.dtd"
+ [
+ <!ATTLIST schema
+ xmlns:ds CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#">
+ <!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
+ <!ENTITY % p ''>
+ <!ENTITY % s ''>
+ ]>
+
+<!-- Schema for XML Signatures
+ http://www.w3.org/2000/09/xmldsig#
+ $Revision$ on $Date$ by $Author: reagle $
+
+ Copyright 2001 The Internet Society and W3C (Massachusetts Institute
+ of Technology, Institut National de Recherche en Informatique et en
+ Automatique, Keio University). All Rights Reserved.
+ http://www.w3.org/Consortium/Legal/
+
+ This document is governed by the W3C Software License [1] as described
+ in the FAQ [2].
+
+ [1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
+ [2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
+-->
+
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+ targetNamespace="http://www.w3.org/2000/09/xmldsig#"
+ version="0.1" elementFormDefault="qualified">
+
+<!-- Basic Types Defined for Signatures -->
+
+<simpleType name="CryptoBinary">
+ <restriction base="base64Binary">
+ </restriction>
+</simpleType>
+
+<!-- Start Signature -->
+
+<element name="Signature" type="ds:SignatureType"/>
+<complexType name="SignatureType">
+ <sequence>
+ <element ref="ds:SignedInfo"/>
+ <element ref="ds:SignatureValue"/>
+ <element ref="ds:KeyInfo" minOccurs="0"/>
+ <element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+ <element name="SignatureValue" type="ds:SignatureValueType"/>
+ <complexType name="SignatureValueType">
+ <simpleContent>
+ <extension base="base64Binary">
+ <attribute name="Id" type="ID" use="optional"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+<!-- Start SignedInfo -->
+
+<element name="SignedInfo" type="ds:SignedInfoType"/>
+<complexType name="SignedInfoType">
+ <sequence>
+ <element ref="ds:CanonicalizationMethod"/>
+ <element ref="ds:SignatureMethod"/>
+ <element ref="ds:Reference" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+ <element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/>
+ <complexType name="CanonicalizationMethodType" mixed="true">
+ <sequence>
+ <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
+ <!-- (0,unbounded) elements from (1,1) namespace -->
+ </sequence>
+ <attribute name="Algorithm" type="anyURI" use="required"/>
+ </complexType>
+
+ <element name="SignatureMethod" type="ds:SignatureMethodType"/>
+ <complexType name="SignatureMethodType" mixed="true">
+ <sequence>
+ <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
+ <any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
+ <!-- (0,unbounded) elements from (1,1) external namespace -->
+ </sequence>
+ <attribute name="Algorithm" type="anyURI" use="required"/>
+ </complexType>
+
+<!-- Start Reference -->
+
+<element name="Reference" type="ds:ReferenceType"/>
+<complexType name="ReferenceType">
+ <sequence>
+ <element ref="ds:Transforms" minOccurs="0"/>
+ <element ref="ds:DigestMethod"/>
+ <element ref="ds:DigestValue"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+ <attribute name="URI" type="anyURI" use="optional"/>
+ <attribute name="Type" type="anyURI" use="optional"/>
+</complexType>
+
+ <element name="Transforms" type="ds:TransformsType"/>
+ <complexType name="TransformsType">
+ <sequence>
+ <element ref="ds:Transform" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="Transform" type="ds:TransformType"/>
+ <complexType name="TransformType" mixed="true">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ <!-- (1,1) elements from (0,unbounded) namespaces -->
+ <element name="XPath" type="string"/>
+ </choice>
+ <attribute name="Algorithm" type="anyURI" use="required"/>
+ </complexType>
+
+<!-- End Reference -->
+
+<element name="DigestMethod" type="ds:DigestMethodType"/>
+<complexType name="DigestMethodType" mixed="true">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Algorithm" type="anyURI" use="required"/>
+</complexType>
+
+<element name="DigestValue" type="ds:DigestValueType"/>
+<simpleType name="DigestValueType">
+ <restriction base="base64Binary"/>
+</simpleType>
+
+<!-- End SignedInfo -->
+
+<!-- Start KeyInfo -->
+
+<element name="KeyInfo" type="ds:KeyInfoType"/>
+<complexType name="KeyInfoType" mixed="true">
+ <choice maxOccurs="unbounded">
+ <element ref="ds:KeyName"/>
+ <element ref="ds:KeyValue"/>
+ <element ref="ds:RetrievalMethod"/>
+ <element ref="ds:X509Data"/>
+ <element ref="ds:PGPData"/>
+ <element ref="ds:SPKIData"/>
+ <element ref="ds:MgmtData"/>
+ <any processContents="lax" namespace="##other"/>
+ <!-- (1,1) elements from (0,unbounded) namespaces -->
+ </choice>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+ <element name="KeyName" type="string"/>
+ <element name="MgmtData" type="string"/>
+
+ <element name="KeyValue" type="ds:KeyValueType"/>
+ <complexType name="KeyValueType" mixed="true">
+ <choice>
+ <element ref="ds:DSAKeyValue"/>
+ <element ref="ds:RSAKeyValue"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ </complexType>
+
+ <element name="RetrievalMethod" type="ds:RetrievalMethodType"/>
+ <complexType name="RetrievalMethodType">
+ <sequence>
+ <element ref="ds:Transforms" minOccurs="0"/>
+ </sequence>
+ <attribute name="URI" type="anyURI"/>
+ <attribute name="Type" type="anyURI" use="optional"/>
+ </complexType>
+
+<!-- Start X509Data -->
+
+<element name="X509Data" type="ds:X509DataType"/>
+<complexType name="X509DataType">
+ <sequence maxOccurs="unbounded">
+ <choice>
+ <element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
+ <element name="X509SKI" type="base64Binary"/>
+ <element name="X509SubjectName" type="string"/>
+ <element name="X509Certificate" type="base64Binary"/>
+ <element name="X509CRL" type="base64Binary"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ </sequence>
+</complexType>
+
+<complexType name="X509IssuerSerialType">
+ <sequence>
+ <element name="X509IssuerName" type="string"/>
+ <element name="X509SerialNumber" type="integer"/>
+ </sequence>
+</complexType>
+
+<!-- End X509Data -->
+
+<!-- Begin PGPData -->
+
+<element name="PGPData" type="ds:PGPDataType"/>
+<complexType name="PGPDataType">
+ <choice>
+ <sequence>
+ <element name="PGPKeyID" type="base64Binary"/>
+ <element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <sequence>
+ <element name="PGPKeyPacket" type="base64Binary"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ </choice>
+</complexType>
+
+<!-- End PGPData -->
+
+<!-- Begin SPKIData -->
+
+<element name="SPKIData" type="ds:SPKIDataType"/>
+<complexType name="SPKIDataType">
+ <sequence maxOccurs="unbounded">
+ <element name="SPKISexp" type="base64Binary"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"/>
+ </sequence>
+</complexType>
+
+<!-- End SPKIData -->
+
+<!-- End KeyInfo -->
+
+<!-- Start Object (Manifest, SignatureProperty) -->
+
+<element name="Object" type="ds:ObjectType"/>
+<complexType name="ObjectType" mixed="true">
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##any" processContents="lax"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+ <attribute name="MimeType" type="string" use="optional"/> <!-- add a grep facet -->
+ <attribute name="Encoding" type="anyURI" use="optional"/>
+</complexType>
+
+<element name="Manifest" type="ds:ManifestType"/>
+<complexType name="ManifestType">
+ <sequence>
+ <element ref="ds:Reference" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+<element name="SignatureProperties" type="ds:SignaturePropertiesType"/>
+<complexType name="SignaturePropertiesType">
+ <sequence>
+ <element ref="ds:SignatureProperty" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="Id" type="ID" use="optional"/>
+</complexType>
+
+ <element name="SignatureProperty" type="ds:SignaturePropertyType"/>
+ <complexType name="SignaturePropertyType" mixed="true">
+ <choice maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ <!-- (1,1) elements from (1,unbounded) namespaces -->
+ </choice>
+ <attribute name="Target" type="anyURI" use="required"/>
+ <attribute name="Id" type="ID" use="optional"/>
+ </complexType>
+
+<!-- End Object (Manifest, SignatureProperty) -->
+
+<!-- Start Algorithm Parameters -->
+
+<simpleType name="HMACOutputLengthType">
+ <restriction base="integer"/>
+</simpleType>
+
+<!-- Start KeyValue Element-types -->
+
+<element name="DSAKeyValue" type="ds:DSAKeyValueType"/>
+<complexType name="DSAKeyValueType">
+ <sequence>
+ <sequence minOccurs="0">
+ <element name="P" type="ds:CryptoBinary"/>
+ <element name="Q" type="ds:CryptoBinary"/>
+ </sequence>
+ <element name="G" type="ds:CryptoBinary" minOccurs="0"/>
+ <element name="Y" type="ds:CryptoBinary"/>
+ <element name="J" type="ds:CryptoBinary" minOccurs="0"/>
+ <sequence minOccurs="0">
+ <element name="Seed" type="ds:CryptoBinary"/>
+ <element name="PgenCounter" type="ds:CryptoBinary"/>
+ </sequence>
+ </sequence>
+</complexType>
+
+<element name="RSAKeyValue" type="ds:RSAKeyValueType"/>
+<complexType name="RSAKeyValueType">
+ <sequence>
+ <element name="Modulus" type="ds:CryptoBinary"/>
+ <element name="Exponent" type="ds:CryptoBinary"/>
+ </sequence>
+</complexType>
+
+<!-- End KeyValue Element-types -->
+
+<!-- End Signature -->
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..1e38d384ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-1.1-cd05-rev1.xsd
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <include schemaLocation="sca-interface-java-1.1-cd04-rev1.xsd"/>
+ <include schemaLocation="sca-interface-wsdl-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-interface-cpp-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-interface-c-1.1-cd05-rev1.xsd"/>
+
+ <include schemaLocation="sca-implementation-java-1.1-cd02-rev1.xsd"/>
+ <include schemaLocation="sca-implementation-composite-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-implementation-cpp-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-implementation-c-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-implementation-bpel-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-implementation-spring-1.1-cd01.xsd"/>
+
+ <include schemaLocation="sca-binding-ws-1.1-cd04-rev1.xsd"/>
+ <include schemaLocation="sca-binding-ws-callback-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-jms-1.1-cd04-rev1.xsd"/>
+ <include schemaLocation="sca-binding-jca-1.1-cd04-rev1.xsd"/>
+ <include schemaLocation="sca-binding-sca-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-binding-ejb-1.1-cd02-rev1.xsd"/>
+
+ <include schemaLocation="sca-definitions-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd03-rev1.xsd"/>
+
+ <include schemaLocation="sca-contribution-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-contribution-cpp-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-contribution-c-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-contribution-java-1.1-cd02-rev1.xsd"/>
+
+ <include schemaLocation="sca-jee-1.1-wd03.xsd"/>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-1.1-cd05.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-1.1-cd05.xsd
new file mode 100644
index 0000000000..5f3c796810
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-1.1-cd05.xsd
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <include schemaLocation="sca-interface-java-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-interface-wsdl-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-interface-cpp-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-interface-c-1.1-cd04.xsd"/>
+
+ <include schemaLocation="sca-implementation-java-1.1-cd02.xsd"/>
+ <include schemaLocation="sca-implementation-composite-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-implementation-cpp-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-implementation-c-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-implementation-bpel-1.1-cd03.xsd"/>
+ <include schemaLocation="sca-implementation-spring-1.1-cd01.xsd"/>
+
+ <include schemaLocation="sca-binding-ws-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-ws-callback-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-jms-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-jca-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-binding-sca-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-binding-ejb-1.1-cd01.xsd"/>
+
+ <include schemaLocation="sca-definitions-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd03.xsd"/>
+
+ <include schemaLocation="sca-contribution-1.1-cd05.xsd"/>
+ <include schemaLocation="sca-contribution-cpp-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-contribution-c-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-contribution-java-1.1-cd02.xsd"/>
+
+ <include schemaLocation="sca-jee-1.1-wd03.xsd"/>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd02-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd02-rev1.xsd
new file mode 100644
index 0000000000..0ac63d4a86
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd02-rev1.xsd
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <element name="binding.ejb" type="sca:EJBSessionBeanBinding"
+ substitutionGroup="sca:binding" />
+
+ <simpleType name="VersionValue">
+ <restriction base="string">
+ <enumeration value="EJB2"/>
+ <enumeration value="EJB3"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="EJBSessionBeanBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ <attribute name="homeInterface" type="NCName" use="optional"/>
+ <attribute name="ejb-link-name" type="string" use="optional"/>
+ <attribute name="ejb-version" type="sca:VersionValue" use="optional" default="EJB3"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04-rev1.xsd
new file mode 100644
index 0000000000..789918f41e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04-rev1.xsd
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd" />
+
+ <complexType name="JCABinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="outboundConnection"
+ type="sca:JCAOutboundConnection" minOccurs="0" />
+ <element name="inboundConnection"
+ type="sca:JCAInboundConnection" minOccurs="0" />
+ <element name="outboundInteraction"
+ type="sca:JCAOutboundInteraction" minOccurs="0" />
+ <element name="inboundInteraction"
+ type="sca:JCAInboundInteraction" minOccurs="0" />
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="initialContextFactory" type="anyURI"
+ use="optional"/>
+ <attribute name="jndiURL" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="JCACreateResource">
+ <restriction base="string">
+ <enumeration value="always" />
+ <enumeration value="never" />
+ <enumeration value="ifNotExist" />
+ </restriction>
+ </simpleType>
+ <simpleType name="ResAuth">
+ <restriction base="string">
+ <enumeration value="container" />
+ <enumeration value="application" />
+ </restriction>
+ </simpleType>
+ <complexType name="JCAOutboundConnection">
+ <sequence>
+ <element name="resourceAdapter" type="sca:ResourceAdapter"
+ minOccurs="0" />
+ <element name="connection" type="sca:Connection" />
+ <element name="resAuth" type="sca:ResAuth" minOccurs="0" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="managed" type="boolean" use="optional"
+ default="true" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="JCAInboundConnection">
+ <sequence>
+ <element name="resourceAdapter" type="sca:ResourceAdapter" />
+ <element name="activationSpec" type="sca:ActivationSpec" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="JCAOutboundInteraction">
+ <sequence>
+ <element name="connectionSpec" type="sca:ConnectionSpec"
+ minOccurs="0" />
+ <element name="interactionSpec" type="sca:InteractionSpec"
+ minOccurs="0" />
+ <element name="operation" type="sca:Operation" minOccurs="0" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="JCAInboundInteraction">
+ <sequence>
+ <element name="listener" type="string" minOccurs="0" />
+ <element name="inboundOperation" type="sca:InboundOperation"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="ResourceAdapter">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NMTOKEN" use="optional" />
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="Connection">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="jndiName" type="anyURI" use="optional" />
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <attribute name="create" type="sca:JCACreateResource" use="optional"
+ default="ifNotExist" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="ActivationSpec">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="jndiName" type="anyURI" use="optional" />
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <attribute name="create" type="sca:JCACreateResource" use="optional"
+ default="ifNotExist"/>
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="Operation">
+ <sequence>
+ <element name="interactionSpec" type="sca:InteractionSpec"
+ minOccurs="0" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NMTOKEN" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="InboundOperation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NMTOKEN" use="required" />
+ <attribute name="selectedOperation" type="string" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="ConnectionSpec">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+ <complexType name="InteractionSpec">
+ <sequence>
+ <element name="property" type="sca:Property" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="type" type="NMTOKEN" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+ <element name="binding.jca" type="sca:JCABinding"
+ substitutionGroup="sca:binding" />
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04-rev1.xsd
new file mode 100644
index 0000000000..1cb011f7b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04-rev1.xsd
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <complexType name="JMSBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="destination" type="sca:JMSDestination"
+ minOccurs="0"/>
+ <choice minOccurs="0" maxOccurs="1">
+ <element name="connectionFactory"
+ type="sca:JMSConnectionFactory"/>
+ <element name="activationSpec" type="sca:JMSActivationSpec"/>
+ </choice>
+ <element name="response" type="sca:JMSResponse" minOccurs="0"/>
+ <element name="headers" type="sca:JMSHeaders" minOccurs="0"/>
+ <element name="messageSelection" type="sca:JMSMessageSelection"
+ minOccurs="0"/>
+ <element name="resourceAdapter" type="sca:JMSResourceAdapter"
+ minOccurs="0"/>
+ <element name="operationProperties"
+ type="sca:JMSOperationProperties"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="correlationScheme" type="QName"
+ default="sca:messageID"/>
+ <attribute name="initialContextFactory" type="anyURI"/>
+ <attribute name="jndiURL" type="anyURI"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="JMSCreateResource">
+ <restriction base="string">
+ <enumeration value="always"/>
+ <enumeration value="never"/>
+ <enumeration value="ifNotExist"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="JMSDestination">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="jndiName" type="anyURI"/>
+ <attribute name="type" use="optional" default="queue">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="queue"/>
+ <enumeration value="topic"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="create" type="sca:JMSCreateResource"
+ use="optional" default="ifNotExist"/>
+ </complexType>
+
+ <complexType name="JMSConnectionFactory">
+ <sequence> <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="jndiName" type="anyURI"/>
+ <attribute name="create" type="sca:JMSCreateResource"
+ use="optional" default="ifNotExist"/>
+ </complexType>
+
+ <complexType name="JMSActivationSpec">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="jndiName" type="anyURI"/>
+ <attribute name="create" type="sca:JMSCreateResource"
+ use="optional" default="ifNotExist"/>
+ </complexType>
+
+ <complexType name="JMSResponse">
+ <sequence>
+ <element ref="sca:wireFormat" minOccurs="0" maxOccurs="1"/>
+ <element name="destination" type="sca:JMSDestination" minOccurs="0"/>
+ <choice minOccurs="0">
+ <element name="connectionFactory" type="sca:JMSConnectionFactory"/>
+ <element name="activationSpec" type="sca:JMSActivationSpec"/>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <complexType name="JMSHeaders">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="type" type="string"/>
+ <attribute name="deliveryMode" default="persistent">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="persistent"/>
+ <enumeration value="nonpersistent"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="timeToLive" type="long" default="0"/>
+ <attribute name="priority" default="4">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="0"/>
+ <enumeration value="1"/>
+ <enumeration value="2"/>
+ <enumeration value="3"/>
+ <enumeration value="4"/>
+ <enumeration value="5"/>
+ <enumeration value="6"/>
+ <enumeration value="7"/>
+ <enumeration value="8"/>
+ <enumeration value="9"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+
+ <complexType name="JMSMessageSelection">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="selector" type="string"/>
+ </complexType>
+
+ <complexType name="JMSResourceAdapter">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="string" use="required"/>
+ </complexType>
+
+ <complexType name="JMSOperationProperties">
+ <sequence>
+ <element name="property" type="sca:BindingProperty"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <element name="headers" type="sca:JMSHeaders"/>
+ </sequence>
+ <attribute name="name" type="string" use="required"/>
+ <attribute name="nativeOperation" type="string"/>
+ </complexType>
+
+ <complexType name="BindingProperty">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="name" type="NMTOKEN" use="required"/>
+ <attribute name="type" type="string" use="optional"
+ default="xs:string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <element name="binding.jms" type="sca:JMSBinding"
+ substitutionGroup="sca:binding"/>
+
+ <complexType name="JMSDefaultWireFormatType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+
+ <complexType name="JMSDefaultOperationSelectorType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType"/>
+ </complexContent>
+ </complexType>
+
+ <element name="wireFormat.jmsDefault" type="sca:JMSDefaultWireFormatType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <element name="operationSelector.jmsDefault" type="sca:JMSDefaultOperationSelectorType"
+ substitutionGroup="sca:operationSelector"/>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..6cdbf1656e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd05-rev1.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <!-- SCA Binding -->
+ <element name="binding.sca" type="sca:SCABinding"
+ substitutionGroup="sca:binding"/>
+ <complexType name="SCABinding">
+ <complexContent>
+ <extension base="sca:Binding"/>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04-rev1.xsd
new file mode 100644
index 0000000000..9d6d97e32c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04-rev1.xsd
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/ns/wsdl-instance"
+ xmlns:wsa="http://www.w3.org/2005/08/addressing"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.w3.org/ns/wsdl-instance"
+ schemaLocation="http://www.w3.org/2007/05/wsdl/wsdl20-instance.xsd"/>
+ <import namespace="http://www.w3.org/2005/08/addressing"
+ schemaLocation="http://www.w3.org/2006/03/addressing/ws-addr.xsd"/>
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <element name="binding.ws" type="sca:WebServiceBinding"
+ substitutionGroup="sca:binding"/>
+
+ <complexType name="WebServiceBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element ref="wsa:EndpointReference"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ <attribute name="wsdlElement" type="anyURI" use="optional"/>
+ <attribute ref="wsdli:wsdlLocation" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd
new file mode 100644
index 0000000000..72d84b31ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright OASIS 2005, 2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <element name="WSCallback">
+ <complexType>
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+
+ </complexType>
+ </element>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..346bfe485e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd05-rev1.xsd
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <!-- Contribution -->
+ <element name="contribution" type="sca:ContributionType"/>
+ <complexType name="ContributionType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element name="deployable" type="sca:DeployableType"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="sca:importBase" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:exportBase" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Deployable -->
+ <complexType name="DeployableType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="composite" type="QName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Import -->
+ <element name="importBase" type="sca:Import" abstract="true" />
+ <complexType name="Import" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="import" type="sca:ImportType"
+ substitutionGroup="sca:importBase"/>
+ <complexType name="ImportType">
+ <complexContent>
+ <extension base="sca:Import">
+ <attribute name="namespace" type="string" use="required"/>
+ <attribute name="location" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Export -->
+ <element name="exportBase" type="sca:Export" abstract="true" />
+ <complexType name="Export" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="export" type="sca:ExportType"
+ substitutionGroup="sca:exportBase"/>
+ <complexType name="ExportType">
+ <complexContent>
+ <extension base="sca:Export">
+ <attribute name="namespace" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..9e29607c5d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd05-rev1.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2007,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd05-rev1.xsd" />
+
+ <element name="export.c" type="sca:CExport"
+ substitutionGroup="sca:exportBase" />
+
+ <complexType name="CExport">
+ <complexContent>
+ <extension base="sca:Export">
+ <attribute name="name" type="QName" use="required" />
+ <attribute name="path" type="string" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="import.c" type="sca:CImport"
+ substitutionGroup="sca:importBase" />
+
+ <complexType name="CImport">
+ <complexContent>
+ <extension base="sca:Import">
+ <attribute name="name" type="QName" use="required" />
+ <attribute name="location" type="string" use="required" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..94813bf6ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd05-rev1.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2006,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd05-rev1.xsd" />
+
+ <element name="export.cpp" type="sca:CPPExport"
+ substitutionGroup="sca:exportBase" />
+
+ <complexType name="CPPExport">
+ <complexContent>
+ <extension base="sca:Export">
+ <attribute name="name" type="QName" use="required" />
+ <attribute name="path" type="string" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="import.cpp" type="sca:CPPImport"
+ substitutionGroup="sca:importBase" />
+
+ <complexType name="CPPImport">
+ <complexContent>
+ <extension base="sca:Import">
+ <attribute name="name" type="QName" use="required" />
+ <attribute name="location" type="string" use="required" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02-rev1.xsd
new file mode 100644
index 0000000000..92642591cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02-rev1.xsd
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd05-rev1.xsd"/>
+
+ <!-- Import.java -->
+ <element name="import.java" type="sca:JavaImportType"
+ substitutionGroup="sca:importBase" />
+ <complexType name="JavaImportType">
+ <complexContent>
+ <extension base="sca:Import">
+ <attribute name="package" type="string" use="required"/>
+ <attribute name="location" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Export.java -->
+ <element name="export.java" type="sca:JavaExportType"
+ substitutionGroup="sca:exportBase" />
+ <complexType name="JavaExportType">
+ <complexContent>
+ <extension base="sca:Export">
+ <attribute name="package" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..541a5c324c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd05-rev1.xsd
@@ -0,0 +1,468 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-policy-1.1-cd03-rev1.xsd"/>
+ <import namespace="http://www.w3.org/XML/1998/namespace"
+ schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+
+ <!-- Common extension base for SCA definitions -->
+ <complexType name="CommonExtensionBase">
+ <sequence>
+ <element ref="sca:documentation" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <element name="documentation" type="sca:Documentation"/>
+ <complexType name="Documentation" mixed="true">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute ref="xml:lang"/>
+ </complexType>
+
+ <!-- Component Type -->
+ <element name="componentType" type="sca:ComponentType"/>
+ <complexType name="ComponentType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:implementation" minOccurs="0"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService"/>
+ <element name="reference"
+ type="sca:ComponentTypeReference"/>
+ <element name="property" type="sca:Property"/>
+ </choice>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Composite -->
+ <element name="composite" type="sca:Composite"/>
+ <complexType name="Composite">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:include" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ <element name="service" type="sca:Service"/>
+ <element name="property" type="sca:Property"/>
+ <element name="component" type="sca:Component"/>
+ <element name="reference" type="sca:Reference"/>
+ <element name="wire" type="sca:Wire"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="targetNamespace" type="anyURI" use="required"/>
+ <attribute name="local" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="autowire" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Contract base type for Service, Reference -->
+ <complexType name="Contract" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:binding" minOccurs="0"
+ maxOccurs="unbounded" />
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:requires" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:policySetAttachment" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Service -->
+ <complexType name="Service">
+ <complexContent>
+ <extension base="sca:Contract">
+ <attribute name="promote" type="anyURI" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Interface -->
+ <element name="interface" type="sca:Interface" abstract="true"/>
+ <complexType name="Interface" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <attribute name="remotable" type="boolean" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Reference -->
+ <complexType name="Reference">
+ <complexContent>
+ <extension base="sca:Contract">
+ <attribute name="target" type="sca:listOfAnyURIs"
+ use="optional"/>
+ <attribute name="wiredByImpl" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="multiplicity" type="sca:Multiplicity"
+ use="required"/>
+ <attribute name="promote" type="sca:listOfAnyURIs"
+ use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Property -->
+ <complexType name="SCAPropertyBase" mixed="true">
+ <sequence>
+ <any namespace="##any" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <!-- NOT an extension point; This any exists to accept
+ the element-based or complex type property
+ i.e. no element-based extension point under "sca:property" -->
+ </sequence>
+ <!-- mixed="true" to handle simple type -->
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="type" type="QName" use="optional"/>
+ <attribute name="element" type="QName" use="optional"/>
+ <attribute name="many" type="boolean" use="optional" default="false"/>
+ <attribute name="value" type="anySimpleType" use="optional"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Property" mixed="true">
+ <complexContent mixed="true">
+ <extension base="sca:SCAPropertyBase">
+ <attribute name="mustSupply" type="boolean" use="optional"
+ default="false"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="PropertyValue" mixed="true">
+ <complexContent mixed="true">
+ <extension base="sca:SCAPropertyBase">
+ <attribute name="source" type="string" use="optional"/>
+ <attribute name="file" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Binding -->
+ <element name="binding" type="sca:Binding" abstract="true"/>
+ <complexType name="Binding" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:wireFormat" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:operationSelector" minOccurs="0"
+ maxOccurs="1" />
+ <element ref="sca:requires" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:policySetAttachment" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="uri" type="anyURI" use="optional"/>
+ <attribute name="name" type="NCName" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Binding Type -->
+ <element name="bindingType" type="sca:BindingType"/>
+ <complexType name="BindingType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="type" type="QName" use="required"/>
+ <attribute name="alwaysProvides" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="mayProvide" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- WireFormat Type -->
+ <element name="wireFormat" type="sca:WireFormatType" abstract="true"/>
+ <complexType name="WireFormatType" abstract="true">
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <!-- OperationSelector Type -->
+ <element name="operationSelector" type="sca:OperationSelectorType"
+ abstract="true"/>
+ <complexType name="OperationSelectorType" abstract="true">
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <!-- Callback -->
+ <element name="callback" type="sca:Callback"/>
+ <complexType name="Callback">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:binding"/>
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </choice>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Component -->
+ <complexType name="Component">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <element ref="sca:implementation" minOccurs="1"
+ maxOccurs="1"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService"/>
+ <element name="reference" type="sca:ComponentReference"/>
+ <element name="property" type="sca:PropertyValue"/>
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="autowire" type="boolean" use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Component Service -->
+ <complexType name="ComponentService">
+ <complexContent>
+ <extension base="sca:Contract">
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Component Reference -->
+ <complexType name="ComponentReference">
+ <complexContent>
+ <extension base="sca:Contract">
+ <attribute name="autowire" type="boolean" use="optional"/>
+ <attribute name="target" type="sca:listOfAnyURIs"
+ use="optional"/>
+ <attribute name="wiredByImpl" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="multiplicity" type="sca:Multiplicity"
+ use="optional" default="1..1"/>
+ <attribute name="nonOverridable" type="boolean" use="optional"
+ default="false"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Component Type Reference -->
+ <complexType name="ComponentTypeReference">
+ <complexContent>
+ <restriction base="sca:ComponentReference">
+ <sequence>
+ <element ref="sca:documentation" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:interface" minOccurs="0"/>
+ <element ref="sca:binding" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:callback" minOccurs="0"/>
+ <element ref="sca:requires" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:policySetAttachment" minOccurs="0"
+ maxOccurs="unbounded"/>
+ <element ref="sca:extensions" minOccurs="0" maxOccurs="1" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="autowire" type="boolean" use="optional"/>
+ <attribute name="wiredByImpl" type="boolean" use="optional"
+ default="false"/>
+ <attribute name="multiplicity" type="sca:Multiplicity"
+ use="optional" default="1..1"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+
+ <!-- Implementation -->
+ <element name="implementation" type="sca:Implementation" abstract="true"/>
+ <complexType name="Implementation" abstract="true">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Implementation Type -->
+ <element name="implementationType" type="sca:ImplementationType"/>
+ <complexType name="ImplementationType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="type" type="QName" use="required"/>
+ <attribute name="alwaysProvides" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="mayProvide" type="sca:listOfQNames"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Wire -->
+ <complexType name="Wire">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="source" type="anyURI" use="required"/>
+ <attribute name="target" type="anyURI" use="required"/>
+ <attribute name="replace" type="boolean" use="optional"
+ default="false"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Include -->
+ <element name="include" type="sca:Include"/>
+ <complexType name="Include">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <attribute name="name" type="QName"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Extensions element -->
+ <element name="extensions">
+ <complexType>
+ <sequence>
+ <any namespace="##other" processContents="lax"
+ minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Intents within WSDL documents -->
+ <attribute name="requires" type="sca:listOfQNames"/>
+
+ <!-- Global attribute definition for @callback to mark a WSDL port type
+ as having a callback interface defined in terms of a second port
+ type. -->
+ <attribute name="callback" type="anyURI"/>
+
+ <!-- Value type definition for property values -->
+ <element name="value" type="sca:ValueType"/>
+ <complexType name="ValueType" mixed="true">
+ <sequence>
+ <any namespace="##any" processContents="lax" minOccurs="0"
+ maxOccurs='unbounded'/>
+ </sequence>
+ <!-- mixed="true" to handle simple type -->
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <!-- Miscellaneous simple type definitions -->
+ <simpleType name="Multiplicity">
+ <restriction base="string">
+ <enumeration value="0..1"/>
+ <enumeration value="1..1"/>
+ <enumeration value="0..n"/>
+ <enumeration value="1..n"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="OverrideOptions">
+ <restriction base="string">
+ <enumeration value="no"/>
+ <enumeration value="may"/>
+ <enumeration value="must"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="listOfQNames">
+ <list itemType="QName"/>
+ </simpleType>
+
+ <simpleType name="listOfAnyURIs">
+ <list itemType="anyURI"/>
+ </simpleType>
+
+ <simpleType name="CreateResource">
+ <restriction base="string">
+ <enumeration value="always" />
+ <enumeration value="never" />
+ <enumeration value="ifnotexist" />
+ </restriction>
+ </simpleType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..fcd3cc0f8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd05-rev1.xsd
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,20010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd03-rev1.xsd"/>
+
+ <!-- Definitions -->
+ <element name="definitions" type="sca:tDefinitions"/>
+ <complexType name="tDefinitions">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:intent"/>
+ <element ref="sca:policySet"/>
+ <element ref="sca:bindingType"/>
+ <element ref="sca:implementationType"/>
+ <element ref="sca:externalAttachment"/>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </choice>
+ <attribute name="targetNamespace" type="anyURI" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd
new file mode 100644
index 0000000000..967dadf395
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified">
+
+ <!-- SCA-Assembly XML Schema -->
+ <include schemaLocation="sca-core-1.1-cd05.xsd" />
+
+ <!-- SCA-BPEL Component Implementation Type -->
+ <element name="implementation.bpel"
+ type="sca:BPELImplementation" substitutionGroup="sca:implementation" />
+
+ <complexType name="BPELImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="process" type="QName" use="required" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..2f394bc260
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd05-rev1.xsd
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Copyright(C) OASIS(R) 2007,2010. All Rights Reserved. OASIS trademark,
+ IPR and other policies apply.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd" />
+
+ <element name="implementation.c" type="sca:CImplementation"
+ substitutionGroup="sca:implementation" />
+
+ <complexType name="CImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <element name="operation" type="sca:CImplementationFunction"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="module" type="NCName" use="required" />
+ <attribute name="path" type="string" use="optional" />
+ <attribute name="library" type="boolean" use="optional" />
+ <attribute name="componentType" type="string" use="required" />
+ <attribute name="eagerInit" type="boolean" use="optional" />
+ <attribute name="init" type="boolean" use="optional" />
+ <attribute name="destoy" type="boolean" use="optional" />
+ <attribute name="allowsPassByReference" type="boolean"
+ use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CImplementationFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="allowsPassByReference" type="boolean" use="optional" />
+ <attribute name="init" type="boolean" use="optional" />
+ <attribute name="destoy" type="boolean" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..5ca0e598de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd05-rev1.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <!-- Composite Implementation -->
+ <element name="implementation.composite" type="sca:SCAImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="SCAImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="QName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..93f3c85884
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd05-rev1.xsd
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2006,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd" />
+
+ <element name="implementation.cpp" type="sca:CPPImplementation"
+ substitutionGroup="sca:implementation" />
+ <complexType name="CPPImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <element name="function"
+ type="sca:CPPImplementationFunction" minOccurs="0"
+ maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="library" type="NCName" use="required" />
+ <attribute name="header" type="NCName" use="required" />
+ <attribute name="path" type="string" use="optional" />
+ <attribute name="class" type="Name" use="optional" />
+ <attribute name="componentType" type="string"
+ use="optional" />
+ <attribute name="scope"
+ type="sca:CPPImplementationScope" use="optional" />
+ <attribute name="eagerInit" type="boolean"
+ use="optional" />
+ <attribute name="allowsPassByReference" type="boolean"
+ use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="CPPImplementationScope">
+ <restriction base="string">
+ <enumeration value="stateless" />
+ <enumeration value="composite" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="CPPImplementationFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="allowsPassByReference" type="boolean"
+ use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd02-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd02-rev1.xsd
new file mode 100644
index 0000000000..90fe13c015
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd02-rev1.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <!-- Java Implementation -->
+ <element name="implementation.java" type="sca:JavaImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="JavaImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="class" type="NCName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd
new file mode 100644
index 0000000000..5ef3e86c92
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+ <element name="implementation.spring" type="sca:SpringImplementation" substitutionGroup="sca:implementation"/>
+ <complexType name="SpringImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="location" type="anyURI" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..0dca94a6d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd05-rev1.xsd
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Copyright(C) OASIS(R) 2007,2010. All Rights Reserved. OASIS trademark,
+ IPR and other policies apply.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd" />
+
+ <element name="interface.c" type="sca:CInterface"
+ substitutionGroup="sca:interface" />
+
+ <complexType name="CInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <element name="function" type="sca:CFunction" minOccurs="0"
+ maxOccurs="unbounded" />
+ <element name="callbackFunction" type="sca:CFunction"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="header" type="string" use="required" />
+ <attribute name="callbackHeader" type="string" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="oneWay" type="boolean" use="optional" />
+ <attribute name="exclude" type="boolean" use="optional" />
+ <attribute name="input" type="NCName" use="optional" />
+ <attribute name="output" type="NCName" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd
new file mode 100644
index 0000000000..b07bf01f1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Copyright(C) OASIS(R) 2006,2010. All Rights Reserved. OASIS trademark,
+ IPR and other policies apply.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd" />
+
+ <element name="interface.cpp" type="sca:CPPInterface"
+ substitutionGroup="sca:interface" />
+
+ <complexType name="CPPInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <element name="function" type="sca:CPPFunction" minOccurs="0"
+ maxOccurs="unbounded" />
+ <element name="callbackFunction" type="sca:CPPFunction"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="header" type="string" use="required" />
+ <attribute name="class" type="Name" use="required" />
+ <attribute name="callbackHeader" type="string" use="optional" />
+ <attribute name="callbackClass" type="Name" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CPPFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="oneWay" type="boolean" use="optional" />
+ <attribute name="exclude" type="boolean" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..0dee25b649
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd05-rev1.xsd
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Copyright(C) OASIS(R) 2006,2010. All Rights Reserved. OASIS trademark,
+ IPR and other policies apply.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd" />
+
+ <element name="interface.cpp" type="sca:CPPInterface"
+ substitutionGroup="sca:interface" />
+
+ <complexType name="CPPInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <element name="function" type="sca:CPPFunction" minOccurs="0"
+ maxOccurs="unbounded" />
+ <element name="callbackFunction" type="sca:CPPFunction"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="header" type="string" use="required" />
+ <attribute name="class" type="Name" use="required" />
+ <attribute name="callbackHeader" type="string" use="optional" />
+ <attribute name="callbackClass" type="Name" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CPPFunction">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="sca:requires"/>
+ <element ref="sca:policySetAttachment"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames" use="optional" />
+ <attribute name="policySets" type="sca:listOfQNames" use="optional" />
+ <attribute name="oneWay" type="boolean" use="optional" />
+ <attribute name="exclude" type="boolean" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04-rev1.xsd
new file mode 100644
index 0000000000..7dcf79a797
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04-rev1.xsd
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <!-- Java Interface -->
+ <element name="interface.java" type="sca:JavaInterface"
+ substitutionGroup="sca:interface"/>
+ <complexType name="JavaInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="interface" type="NCName" use="required"/>
+ <attribute name="callbackInterface" type="NCName"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd05-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd05-rev1.xsd
new file mode 100644
index 0000000000..532c0a6bd0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd05-rev1.xsd
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05-rev1.xsd"/>
+
+ <!-- WSDL Interface -->
+ <element name="interface.wsdl" type="sca:WSDLPortType"
+ substitutionGroup="sca:interface"/>
+ <complexType name="WSDLPortType">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="interface" type="anyURI" use="required"/>
+ <attribute name="callbackInterface" type="anyURI"
+ use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd
new file mode 100644
index 0000000000..97b44f8da5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2009. All Rights Reserved. OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd05.xsd"/>
+
+ <element name="implementation.ejb" type="sca:EJBImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="EJBImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="ejb-link" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="implementation.web" type="sca:WebImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="WebImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="web-uri" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="implementation.jee" type="sca:JEEImplementation"
+ substitutionGroup="sca:implementation"/>
+ <complexType name="JEEImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="archive" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd03-rev1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd03-rev1.xsd
new file mode 100644
index 0000000000..8de738cf73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd03-rev1.xsd
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd06.xsd"/>
+ <import namespace="http://www.w3.org/ns/ws-policy"
+ schemaLocation="http://www.w3.org/2007/02/ws-policy.xsd"/>
+
+ <element name="intent" type="sca:Intent"/>
+ <complexType name="Intent">
+ <sequence>
+ <element name="description" type="string" minOccurs="0"
+ maxOccurs="1" />
+ <element name="qualifier" type="sca:IntentQualifier"
+ minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="constrains" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="excludes" type="sca:listOfQNames"
+ use="optional"/>
+ <attribute name="mutuallyExclusive" type="boolean"
+ use="optional" default="false"/>
+ <attribute name="intentType"
+ type="sca:InteractionOrImplementation"
+ use="optional" default="interaction"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="IntentQualifier">
+ <sequence>
+ <element name="description" type="string" minOccurs="0"
+ maxOccurs="1" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="default" type="boolean" use="optional"
+ default="false"/>
+ </complexType>
+
+ <element name="requires">
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ </sequence>
+ <attribute name="intents" type="sca:listOfQNames" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+ </element>
+
+ <element name="externalAttachment">
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ </sequence>
+ <attribute name="intents" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ <attribute name="attachTo" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+ </element>
+
+ <element name="policySet" type="sca:PolicySet"/>
+ <complexType name="PolicySet">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="policySetReference"
+ type="sca:PolicySetReference"/>
+ <element name="intentMap" type="sca:IntentMap"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="provides" type="sca:listOfQNames"/>
+ <attribute name="appliesTo" type="string" use="optional"/>
+ <attribute name="attachTo" type="string" use="optional"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <element name="policySetAttachment">
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ </sequence>
+ <attribute name="name" type="QName" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+ </element>
+
+ <complexType name="PolicySetReference">
+ <attribute name="name" type="QName" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="IntentMap">
+ <choice minOccurs="1" maxOccurs="unbounded">
+ <element name="qualifier" type="sca:Qualifier"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ <attribute name="provides" type="QName" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Qualifier">
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <any namespace="##other" processContents="lax"/>
+ </sequence>
+ <attribute name="name" type="string" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <simpleType name="listOfNCNames">
+ <list itemType="NCName"/>
+ </simpleType>
+
+ <simpleType name="InteractionOrImplementation">
+ <restriction base="string">
+ <enumeration value="interaction"/>
+ <enumeration value="implementation"/>
+ </restriction>
+ </simpleType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd03.xml b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd03.xml
new file mode 100644
index 0000000000..4505850072
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/sca-policy-1.1-intents-definitions-cd03.xml
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ OASIS trademark, IPR and other policies apply. -->
+<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Security related intents -->
+ <sca:intent name="serverAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding requires that the
+ server is authenticated by the client
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="clientAuthentication" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding requires that the
+ client is authenticated by the server
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="authentication" requires="sca:clientAuthentication">
+ <sca:description>
+ A convenience intent to help migration
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="mutualAuthentication"
+ requires="sca:clientAuthentication sca:serverAuthentication">
+ <sca:description>
+ Communication through the binding requires that the
+ client and server to authenticate each other
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="confidentiality" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding prevents unauthorized
+ users from reading the messages
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="integrity" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Communication through the binding prevents tampering
+ with the messages sent between the client and the service.
+ </sca:description>
+ <sca:qualifier name="transport" default="true"/>
+ <sca:qualifier name="message"/>
+ </sca:intent>
+
+ <sca:intent name="authorization" constrains="sca:implementation"
+ intentType="implementation">
+ <sca:description>
+ Ensures clients are authorized to use services.
+ </sca:description>
+ </sca:intent>
+
+
+ <!-- Reliable messaging related intents -->
+ <sca:intent name="atLeastOnce" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that a message sent
+ by a client is always delivered to the component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="atMostOnce" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that a message that was
+ successfully sent by a client is not delivered more than
+ once to the component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="exactlyOnce" requires="sca:atLeastOnce sca:atMostOnce"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ This profile intent is used to indicate that a message sent
+ by a client is always delivered to the component. It also
+ indicates that duplicate messages are not delivered to the
+ component.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="ordered" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent is used to indicate that all the messages are
+ delivered to the component in the order they were sent by
+ the client.
+ </sca:description>
+ </sca:intent>
+
+ <!-- Transaction related intents -->
+ <sca:intent name="managedTransaction" excludes="sca:noManagedTransaction"
+ mutuallyExclusive="true" constrains="sca:implementation"
+ intentType="implementation">
+ <sca:description>
+ A managed transaction environment is necessary in order to
+ run the component. The specific type of managed transaction
+ needed is not constrained.
+ </sca:description>
+ <sca:qualifier name="global" default="true">
+ <sca:description>
+ For a component marked with managedTransaction.global
+ a global transaction needs to be present before dispatching
+ any method on the component - using any transaction
+ propagated from the client or else beginning and completing
+ a new transaction.
+ </sca:description>
+ </sca:qualifier>
+ <sca:qualifier name="local">
+ <sca:description>
+ A component marked with managedTransaction.local needs to
+ run within a local transaction containment (LTC) that
+ is started and ended by the SCA runtime.
+ </sca:description>
+ </sca:qualifier>
+ </sca:intent>
+
+ <sca:intent name="noManagedTransaction" excludes="sca:managedTransaction"
+ constrains="sca:implementation" intentType="implementation">
+ <sca:description>
+ A component marked with noManagedTransaction needs to run without
+ a managed transaction, under neither a global transaction nor
+ an LTC. A transaction propagated to the hosting SCA runtime
+ is not joined by the hosting runtime on behalf of a
+ component marked with noManagedtransaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="transactedOneWay" excludes="sca:immediateOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <sca:description>
+ For a reference marked as transactedOneWay any OneWay invocation
+ messages are transacted as part of a client global
+ transaction.
+ For a service marked as transactedOneWay any OneWay invocation
+ message are received from the transport binding in a
+ transacted fashion, under the service’s global transaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="immediateOneWay" excludes="sca:transactedOneWay"
+ constrains="sca:binding" intentType="implementation">
+ <sca:description>
+ For a reference indicates that any OneWay invocation messages
+ are sent immediately regardless of any client transaction.
+ For a service indicates that any OneWay invocation is
+ received immediately regardless of any target service
+ transaction.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="propagatesTransaction" excludes="sca:suspendsTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ A service marked with propagatesTransaction is dispatched
+ under any propagated (client) transaction and the service binding
+ needs to be capable of receiving a transaction context.
+ A reference marked with propagatesTransaction propagates any
+ transaction context under which the client runs when the
+ reference is used for a request-response interaction and the
+ binding of a reference marked with propagatesTransaction needs to
+ be capable of propagating a transaction context.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="suspendsTransaction" excludes="sca:propagatesTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ A service marked with suspendsTransaction is not dispatched
+ under any propagated (client) transaction.
+ A reference marked with suspendsTransaction does not propagate
+ any transaction context under which the client runs when the
+ reference is used.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="managedSharedTransaction"
+ requires="sca:managedTransaction.global sca:propagatesTransaction">
+ <sca:description>
+ Used to indicate that the component requires both the
+ managedTransaction.global and the propagatesTransactions
+ intents
+ </sca:description>
+ </sca:intent>
+
+ <!-- Miscellaneous intents -->
+ <sca:intent name="asyncInvocation" excludes="sca:propagatesTransaction"
+ constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ Indicates that request/response operations for the
+ interface of this wire are "long running" and must be
+ treated as two separate message transmissions
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="EJB" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ Specifies that the EJB API is needed to communicate with
+ the service or reference.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="SOAP" constrains="sca:binding" intentType="interaction" mutuallyExclusive="true">
+ <sca:description>
+ Specifies that the SOAP messaging model is used for delivering
+ messages.
+ </sca:description>
+ <sca:qualifier name="v1_1" default="true"/>
+ <sca:qualifier name="v1_2"/>
+ </sca:intent>
+
+ <sca:intent name="JMS" constrains="sca:binding" intentType="interaction">
+ <sca:description>
+ Requires that the messages are delivered and received via the
+ JMS API.
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="noListener" constrains="sca:binding"
+ intentType="interaction">
+ <sca:description>
+ This intent can only be used on a reference. Indicates that the
+ client is not able to handle new inbound connections. The binding
+ and callback binding are configured so that any
+ response or callback comes either through a back channel of the
+ connection from the client to the server or by having the client
+ poll the server for messages.
+ </sca:description>
+ </sca:intent>
+
+</sca:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-atom.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-atom.xsd
new file mode 100644
index 0000000000..603455a1f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-atom.xsd
@@ -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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.atom" type="t:AtomBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="AtomBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <!-- sequence>
+ <any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence -->
+ <attribute name="title" type="string" use="optional"/>
+ <attribute name="description" type="string" use="optional"/>
+ <!-- anyAttribute namespace="##any" processContents="lax"/ -->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd
new file mode 100644
index 0000000000..52445c14c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd
@@ -0,0 +1,41 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.dwr" type="t:DWRBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="DWRBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ <!-- anyAttribute namespace="##any" processContents="lax"/ -->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd
new file mode 100644
index 0000000000..67feb54963
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd
@@ -0,0 +1,41 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.http" type="t:HTTPBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="HTTPBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ <!-- anyAttribute namespace="##any" processContents="lax"/-->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jms.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jms.xsd
new file mode 100644
index 0000000000..e99c0860e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jms.xsd
@@ -0,0 +1,128 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-binding-jms-1.1-cd04-rev1.xsd"/>
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05-rev1.xsd"/>
+
+ <!-- wire formats -->
+ <!-- -->
+ <complexType name="WireFormatJMSDefaultType">
+ <complexContent>
+ <extension base="sca:WireFormatType">
+ <attribute name="sendFormat" default="bytes">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="text"/>
+ <enumeration value="bytes"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsdefault"
+ type="t:WireFormatJMSDefaultType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSTextType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsText"
+ type="t:WireFormatJMSTextType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSTextXMLType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsTextXML"
+ type="t:WireFormatJMSTextXMLType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSBytesType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsBytes"
+ type="t:WireFormatJMSBytesType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSBytesXMLType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsBytesXML"
+ type="t:WireFormatJMSBytesXMLType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatJMSObjectType">
+ <complexContent>
+ <extension base="sca:WireFormatType">
+ <attribute name="wrapSingle" default="false">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="true"/>
+ <enumeration value="false"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="wireFormat.jmsObject"
+ type="t:WireFormatJMSObjectType"
+ substitutionGroup="sca:wireFormat"/>
+ <!-- -->
+
+ <!-- operation selectors -->
+ <!-- -->
+ <complexType name="OperationSelectorJMSDefaultType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType"/>
+ </complexContent>
+ </complexType>
+ <element name="operationSelector.jmsdefault"
+ type="t:OperationSelectorJMSDefaultType"
+ substitutionGroup="sca:operationSelector"/>
+
+ <complexType name="OperationSelectorJMSUserPropType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType">
+ <attribute name="propertyName" type="string"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="operationSelector.jmsUserProp"
+ type="t:OperationSelectorJMSUserPropType"
+ substitutionGroup="sca:operationSelector"/>
+
+ <!-- -->
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd
new file mode 100644
index 0000000000..d1bdcbdfae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd
@@ -0,0 +1,41 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.jsonrpc" type="t:JSONRPCBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="JSONRPCBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ <!-- anyAttribute namespace="##any" processContents="lax"/ -->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rest.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rest.xsd
new file mode 100644
index 0000000000..05adf814c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rest.xsd
@@ -0,0 +1,105 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.rest" type="t:RESTBinding" substitutionGroup="sca:binding"/>
+
+
+ <complexType name="RESTBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="response" type="t:RESTResponse" minOccurs="0"/>
+ <element ref="t:http-headers" minOccurs="0" maxOccurs="1"/>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ <!-- anyAttribute namespace="##any" processContents="lax"/-->
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+ <complexType name="RESTResponse">
+ <sequence>
+ <element ref="sca:wireFormat" minOccurs="0" />
+ </sequence>
+ </complexType>
+
+ <complexType name="HTTPHeadersType">
+ <sequence>
+ <element ref="t:header" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="http-headers" type="t:HTTPHeadersType"/>
+
+ <complexType name="HTTPHeaderType">
+ <attribute name="name" type="string" use="required" />
+ <attribute name="value" type="string" use="required" />
+ </complexType>
+
+ <element name="header" type="t:HTTPHeaderType" />
+
+ <!-- wire formats -->
+ <complexType name="WireFormatJSONType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+
+ <element name="wireFormat.json" type="t:WireFormatJSONType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <complexType name="WireFormatXMLType">
+ <complexContent>
+ <extension base="sca:WireFormatType"/>
+ </complexContent>
+ </complexType>
+
+ <element name="wireFormat.xml" type="t:WireFormatXMLType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <!-- operation selectors -->
+ <complexType name="OperationSelectorJAXRSType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType"/>
+ </complexContent>
+ </complexType>
+ <element name="operationSelector.jaxrs"
+ type="t:OperationSelectorJAXRSType"
+ substitutionGroup="sca:operationSelector"/>
+
+ <complexType name="OperationSelectorRPCType">
+ <complexContent>
+ <extension base="sca:OperationSelectorType"/>
+ </complexContent>
+ </complexType>
+ <element name="operationSelector.rpc"
+ type="t:OperationSelectorRPCType"
+ substitutionGroup="sca:operationSelector"/>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd
new file mode 100644
index 0000000000..ea39a773e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd
@@ -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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.rmi" type="t:RMIBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="RMIBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <!-- any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/ -->
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rss.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rss.xsd
new file mode 100644
index 0000000000..9857ec62b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rss.xsd
@@ -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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="binding.rss" type="t:RSSBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="RSSBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <!--sequence>
+ <any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence -->
+ <attribute name="title" type="string" use="optional"/>
+ <attribute name="description" type="string" use="optional"/>
+ <!--anyAttribute namespace="##any" processContents="lax"/-->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd
new file mode 100644
index 0000000000..c97b91251b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd
@@ -0,0 +1,53 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="implementation.osgi" type="t:OSGiImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="OSGiImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##targetNamespace" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="bundleSymbolicName" type="string" use="required"/>
+ <attribute name="bundleVersion" type="string" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+ <element name="osgi.property" type="t:OSGiProperty"/>
+ <complexType name="OSGiProperty">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="value" type="string" use="optional"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-script.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-script.xsd
new file mode 100644
index 0000000000..fab809c7e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-script.xsd
@@ -0,0 +1,38 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="implementation.script" type="t:ScriptImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="ScriptImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <attribute name="script" type="anyURI" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-widget.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-widget.xsd
new file mode 100644
index 0000000000..491cb2abce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-widget.xsd
@@ -0,0 +1,42 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05.xsd"/>
+
+ <element name="implementation.widget" type="t:WidgetImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="WidgetImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##targetNamespace" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="location" type="anyURI" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd
new file mode 100644
index 0000000000..08c6f57eb4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd
@@ -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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1">
+
+<!--
+ <import namespace="http://www.w3.org/ns/wsdl-instance" schemaLocation="wsdli.xsd"/>
+-->
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" schemaLocation="sca-1.1-cd05-rev1.xsd"/>
+
+
+ <include schemaLocation="tuscany-sca-1.1-binding-atom.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-jms.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-http.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-jsonrpc.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-rest.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-rmi.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-binding-rss.xsd"/>
+
+ <include schemaLocation="tuscany-sca-1.1-implementation-osgi.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-implementation-widget.xsd"/>
+ <include schemaLocation="tuscany-sca-1.1-implementation-script.xsd"/>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly/LICENSE b/sandbox/sebastien/java/embed/modules/assembly/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/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/sebastien/java/embed/modules/assembly/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/assembly/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..61b8b3ffea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/META-INF/MANIFEST.MF
@@ -0,0 +1,60 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.assembly;version="2.0.0";
+ uses:="javax.xml.xpath,
+ org.apache.tuscany.sca.assembly.impl,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.definitions,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0";
+ uses:="javax.xml.xpath,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0";uses:="org.apache.tuscany.sca.definitions,org.apache.tuscany.sca.monitor",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0";uses:="org.apache.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.policy",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";uses:="org.apache.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.policy,org.apache.tuscany.sca.interfacedef",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0";uses:="org.apache.tuscany.sca.interfacedef,javax.xml.namespace",
+ org.apache.tuscany.sca.policy;version="2.0.0";uses:="javax.xml.xpath,org.apache.tuscany.sca.policy.impl,javax.xml.namespace",
+ org.apache.tuscany.sca.policy.impl;version="2.0.0";uses:="javax.xml.xpath,org.apache.tuscany.sca.policy,javax.xml.namespace",
+ org.apache.tuscany.sca.policy.util;version="2.0.0";uses:="javax.xml.parsers,org.apache.tuscany.sca.policy"
+Private-Package: org.apache.tuscany.sca.assembly.builder.impl;version=
+ "2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Assembly Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Assembly Model
+Import-Package: javax.xml.datatype,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.impl;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/assembly/NOTICE b/sandbox/sebastien/java/embed/modules/assembly/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly/pom.xml b/sandbox/sebastien/java/embed/modules/assembly/pom.xml
new file mode 100644
index 0000000000..11fa07c1e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/pom.xml
@@ -0,0 +1,45 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-assembly</artifactId>
+ <name>Apache Tuscany SCA Assembly Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
new file mode 100644
index 0000000000..dca1decb76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.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.assembly;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Interface contracts define one or more business functions. These business
+ * functions are provided by services and are used by references.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface AbstractContract extends Base, Extensible, PolicySubject {
+
+ /**
+ * Returns the name of the contract.
+ *
+ * @return the name of the contract
+ */
+ String getName();
+
+ /**
+ * Sets the name of the contract.
+ *
+ * @param name the name of the contract
+ */
+ void setName(String name);
+
+ /**
+ * Returns the interface contract defining the interface and callback
+ * interface for the contract.
+ *
+ * @return the interface contract
+ */
+ InterfaceContract getInterfaceContract();
+
+ /**
+ * Sets the interface contract defining the interface and callback
+ * interface for the contract.
+ *
+ * @param interfaceContract the interface contract
+ */
+ void setInterfaceContract(InterfaceContract interfaceContract);
+
+ /**
+ * Returns true if this contract is a reference or service created internally
+ * to handle a callback interface of another contract, false otherwise.
+ *
+ * @return true for a callback contract, false otherwise
+ */
+ boolean isForCallback();
+
+ /**
+ * Sets a flag indicating whether this is a callback contract.
+ *
+ * @param isCallback true for a callback contract, false otherwise
+ */
+ void setForCallback(boolean isCallback);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
new file mode 100644
index 0000000000..45fa05d66c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.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.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * A property allows for the configuration of an implementation with externally
+ * set data values. An implementation can have zero or more properties. Each
+ * property has a data type, which may be either simple or complex. An
+ * implementation may also define a default value for a property.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AbstractProperty extends Base, Extensible {
+
+ /**
+ * Returns the property name.
+ *
+ * @return the property name
+ */
+ String getName();
+
+ /**
+ * Sets the property name.
+ *
+ * @param name the property name
+ */
+ void setName(String name);
+
+ /**
+ * Returns the default value of the property.
+ *
+ * @return the default value of this property
+ */
+ Object getValue();
+
+ /**
+ * Sets the default value of the property.
+ *
+ * @param defaultValue the default value of this property
+ */
+ void setValue(Object defaultValue);
+
+ /**
+ * Returns true if the property allows multiple values.
+ *
+ * @return true if the property allows multiple values
+ */
+ boolean isMany();
+
+ /**
+ * Sets whether or not the property allows multiple values.
+ *
+ * @param many true if the property should allow multiple values
+ */
+ void setMany(boolean many);
+
+ /**
+ * Returns true if a value must be supplied for the property.
+ *
+ * @return true is a value must be supplied for the property
+ */
+ boolean isMustSupply();
+
+ /**
+ * Sets whether a value must be supplied for the property.
+ *
+ * @param mustSupply set to true to require that a value be supplied for
+ * uses of this property
+ */
+ void setMustSupply(boolean mustSupply);
+
+ /**
+ * Returns the data type of this property. This is the qualified name of an
+ * XML schema type.
+ *
+ * @return the type of this property
+ */
+ QName getXSDType();
+
+ /**
+ * Sets the data type of this property. This is the qualified name of an XML
+ * schema type.
+ *
+ * @param type the type of this property
+ */
+ void setXSDType(QName type);
+
+ /**
+ * Returns the element defining the data type of this property. This is the
+ * qualified name of an XML schema element.
+ *
+ * @return the element defining the type of this property
+ */
+ QName getXSDElement();
+
+ /**
+ * Sets the element defining the data type of this property. This is the
+ * qualified name of an XML schema element.
+ *
+ * @param element the element defining the type of this property
+ */
+ void setXSDElement(QName element);
+
+ /**
+ * Get the data type for this property
+ * @return The data type
+ */
+ DataType getDataType();
+
+ /**
+ * Set the data type
+ * @param dataType The data type
+ */
+ void setDataType(DataType dataType);
+
+ /**
+ * Get the XML schema that represents the type if this property.
+ * Used during property value validation
+ *
+ * @return
+ */
+ Object getXSDDefinition();
+
+ /**
+ * Set the XML schema that represents the type if this property.
+ * Used during property value validation
+ *
+ * @param xsdDefintion
+ */
+ void setXSDDefinition(Object xsdDefintion);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java
new file mode 100644
index 0000000000..a9ef26bbb9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * Represents a reference contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AbstractReference extends AbstractContract {
+
+ /**
+ * Returns the multiplicity allowed for wires connected to this reference.
+ *
+ * @return the multiplicity allowed for wires connected to this reference
+ */
+ Multiplicity getMultiplicity();
+
+ /**
+ * Sets the multiplicity allowed for wires connected to this reference.
+ *
+ * @param multiplicity the multiplicity allowed for wires connected to this
+ * reference
+ */
+ void setMultiplicity(Multiplicity multiplicity);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java
new file mode 100644
index 0000000000..9ae511c07b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.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 org.apache.tuscany.sca.assembly;
+
+/**
+ * Represents a service contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AbstractService extends AbstractContract {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
new file mode 100644
index 0000000000..5d82b9b727
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+/**
+ * A factory for the assembly model
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface AssemblyFactory {
+
+ /**
+ * Create a new abstract property.
+ *
+ * @return a new abstract property
+ */
+ AbstractProperty createAbstractProperty();
+
+ /**
+ * Create a new abstract reference.
+ *
+ * @return a new abstract reference
+ */
+ AbstractReference createAbstractReference();
+
+ /**
+ * Create a new abstract service.
+ *
+ * @return a new abstract service
+ */
+ AbstractService createAbstractService();
+
+ /**
+ * Create a new callback.
+ *
+ * @return
+ */
+ Callback createCallback();
+
+ /**
+ * Create a new component.
+ *
+ * @return a new component
+ */
+ Component createComponent();
+
+ /**
+ * Create a new component property.
+ *
+ * @return a new component property
+ */
+ ComponentProperty createComponentProperty();
+
+ /**
+ * Create a new component reference.
+ *
+ * @return a new component reference
+ */
+ ComponentReference createComponentReference();
+
+ /**
+ * Create a new component service.
+ *
+ * @return a new component service
+ */
+ ComponentService createComponentService();
+
+ /**
+ * Create a new component type
+ *
+ * @return a new component type
+ */
+ ComponentType createComponentType();
+
+ /**
+ * Create a new composite.
+ *
+ * @return a new composite
+ */
+ Composite createComposite();
+
+ /**
+ * Create a new composite reference.
+ *
+ * @return a new composite reference
+ */
+ CompositeReference createCompositeReference();
+
+ /**
+ * Create a new composite service.
+ *
+ * @return a new composite service
+ */
+ CompositeService createCompositeService();
+
+ /**
+ * Create a new property.
+ *
+ * @return a new property
+ */
+ Property createProperty();
+
+ /**
+ * Create a new reference.
+ *
+ * @return a new reference
+ */
+ Reference createReference();
+
+ /**
+ * Create a new service.
+ *
+ * @return a new service
+ */
+ Service createService();
+
+ /**
+ * Create a new wire.
+ *
+ * @return a new wire
+ */
+ Wire createWire();
+
+ /**
+ * Create an Extension
+ * @return
+ */
+ Extension createExtension();
+
+ /**
+ * Create a new endpoint
+ *
+ * @return a new endpoint
+ */
+ Endpoint createEndpoint();
+
+ /**
+ * Create a new endpoint reference
+ *
+ * @return a new endpoint reference
+ */
+ EndpointReference createEndpointReference();
+
+ /**
+ * Create a new configured operation.
+ *
+ * @return a new ConfiguredOperation
+ */
+ ConfiguredOperation createConfiguredOperation();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java
new file mode 100644
index 0000000000..b9abb90b03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * Base interface for all assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Base {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
new file mode 100644
index 0000000000..9b96556173
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a binding.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Binding extends Base, Cloneable {
+
+ /**
+ * Returns the binding URI.
+ *
+ * @return the binding URI
+ */
+ String getURI();
+
+ /**
+ * Sets the binding URI.
+ *
+ * @param uri the binding URI
+ */
+ void setURI(String uri);
+
+ /**
+ * Returns the binding name.
+ *
+ * @return the binding name
+ */
+ String getName();
+
+ /**
+ * Sets the binding name.
+ *
+ * @param name the binding name
+ */
+ void setName(String name);
+
+ /**
+ * Clone the binding
+ *
+ * @return the clone
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Returns the QName type for the binding
+ *
+ * @return the binding type QName
+ */
+ QName getType();
+
+ /**
+ * Returns the request wire format
+ *
+ * @return the request wire format or null is none is specified
+ */
+ WireFormat getRequestWireFormat();
+
+ /**
+ * Sets the request wire format
+ *
+ * @param wireFormat the request wire format
+ */
+ void setRequestWireFormat(WireFormat wireFormat);
+
+ /**
+ * Returns the response wire format
+ *
+ * @return the response wire format or null is none is specified
+ */
+ WireFormat getResponseWireFormat();
+
+ /**
+ * Sets the response wire format
+ *
+ * @param wireFormat the response wire format
+ */
+ void setResponseWireFormat(WireFormat wireFormat);
+
+ /**
+ * Returns the operation selector
+ *
+ * @return the operation selector or null is none is specified
+ */
+ OperationSelector getOperationSelector();
+
+ /**
+ * Sets the operation selector
+ *
+ * @param operationSelector the operation selector
+ */
+ void setOperationSelector(OperationSelector operationSelector);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
new file mode 100644
index 0000000000..a220f14159
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.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.sca.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a callback object describing the bindings to use for callbacks.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Callback extends Base, Extensible, PolicySubject {
+
+ /**
+ * Returns the bindings supported for callbacks.
+ *
+ * @return the bindings supported for callbacks
+ */
+ List<Binding> getBindings();
+
+ /**
+ * Returns the contract that holds this callback
+ *
+ * @return the contract that holds this callback
+ */
+ Contract getParentContract();
+
+ /**
+ * Sets the contract that holds this callback
+ *
+ * @param contract the contract that holds this callback
+ */
+ void setParentContract(Contract contract);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
new file mode 100644
index 0000000000..efd8557e07
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a component. A component is a configured instance of an
+ * implementation.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Component extends Base, Extensible, PolicySubject, Cloneable {
+
+ /**
+ * Returns the URI of the component.
+ *
+ * @return the URI of the component
+ */
+ String getURI();
+
+ /**
+ * Sets the URI of the component.
+ *
+ * @param uri the URI of the component
+ */
+ void setURI(String uri);
+
+ /**
+ * Returns the name of the component.
+ *
+ * @return the name of the component
+ */
+ String getName();
+
+ /**
+ * Sets the name of the component.
+ *
+ * @param name the name of the component
+ */
+ void setName(String name);
+
+ /**
+ * Returns the component implementation.
+ *
+ * @return the component implementation
+ */
+ Implementation getImplementation();
+
+ /**
+ * Sets the component implementation
+ *
+ * @param implementation the component implementation
+ */
+ void setImplementation(Implementation implementation);
+
+ /**
+ * Returns a list of references used by the component.
+ *
+ * @return a list of references used by the component
+ */
+ List<ComponentReference> getReferences();
+
+ /**
+ * Return a reference by name
+ *
+ * @param name the reference name
+ * @return reference the reference
+ */
+ ComponentReference getReference(String name);
+
+ /**
+ * Returns a list of services exposed by the component.
+ *
+ * @return a list of services exposed by the component
+ */
+ List<ComponentService> getServices();
+
+ /**
+ * Return a service by name
+ *
+ * @param name the service name
+ * @return service the service
+ */
+ ComponentService getService(String name);
+
+ /**
+ * Returns a list of properties for the component.
+ *
+ * @return a list of properties
+ */
+ List<ComponentProperty> getProperties();
+
+ /**
+ * Return a property by name
+ *
+ * @param name the property name
+ * @return property the property
+ */
+ ComponentProperty getProperty(String name);
+
+ /**
+ * Return the Boolean value of autowire
+ * @return null/TRUE/FALSE
+ */
+ Boolean getAutowire();
+
+ /**
+ * Sets whether component references should be autowired.
+ *
+ * @param autowire whether component references should be autowired
+ */
+ void setAutowire(Boolean autowire);
+
+ /**
+ * Returns a clone of the component.
+ *
+ * @return a clone of the component
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java
new file mode 100644
index 0000000000..1202b4d83a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.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.sca.assembly;
+
+import javax.xml.xpath.XPathExpression;
+
+/**
+ * Represents a configured property of a component.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentProperty extends Property {
+
+ /**
+ * Returns the property defined by the component implementation.
+ *
+ * @return the property defined by the component implementation
+ */
+ Property getProperty();
+
+ /**
+ * Sets the property defined by this component implementation.
+ *
+ * @param property the property defined by this component implementation
+ */
+ void setProperty(Property property);
+
+ /**
+ * Returns an XPath expression referencing a property of the enclosing
+ * composite.
+ *
+ * @return an XPath expression referencing a property of the enclosing
+ * composite
+ */
+ String getSource();
+
+ /**
+ * Sets an XPath expression referencing a property of the enclosing
+ * composite.
+ *
+ * @param source an XPath expression referencing a property of the enclosing
+ * composite
+ */
+ void setSource(String source);
+
+ /**
+ * Get the XPath expression for the source attribute
+ * @return the XPath expression for the source attribute
+ */
+ XPathExpression getSourceXPathExpression();
+
+ /**
+ * Set the XPath expression for the source attribute
+ * @param sourceXPathExpression the XPath expression for the source attribute
+ */
+ void setSourceXPathExpression(XPathExpression sourceXPathExpression);
+
+ /**
+ * Returns a URI to a file containing the property value.
+ *
+ * @return a URI to a file containing the property value
+ */
+ String getFile();
+
+ /**
+ * Sets a URI to a file containing the property value.
+ *
+ * @param file a URI to a file containing the property value
+ */
+ void setFile(String file);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java
new file mode 100644
index 0000000000..ad72780de8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.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.sca.assembly;
+
+/**
+ * An instance of a reference associated with a particular component.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentReference extends Reference {
+
+ /**
+ * Returns the reference defined by the implementation for this reference.
+ *
+ * @return the implementation reference
+ */
+ Reference getReference();
+
+ /**
+ * Sets the reference defined by the implementation for this reference.
+ *
+ * @param reference the implementation reference
+ */
+ void setReference(Reference reference);
+
+ /**
+ * Return the Boolean value of autowire
+ * @return null/TRUE/FALSE
+ */
+ Boolean getAutowire();
+
+ /**
+ * Sets whether component references should be autowired.
+ *
+ * @param autowire whether component references should be autowired
+ */
+ void setAutowire(Boolean autowire);
+
+ /**
+ * Returns the callback service created internally as a target endpoint
+ * for callbacks to this reference.
+ *
+ * @return the callback service
+ */
+ ComponentService getCallbackService();
+
+ /**
+ * Sets the callback service created internally as a target endpoint
+ * for callbacks to this reference.
+ *
+ * @param callbackService the callback service
+ */
+ void setCallbackService(ComponentService callbackService);
+
+ /**
+ * A boolean value, "false" by default, which indicates whether this component reference
+ * can have its targets overridden by a composite reference which promotes the
+ * component reference.
+ *
+ * If @nonOverridable==false, the target(s) of the promoting composite reference
+ * replace all the targets explicitly declared on the component reference for any
+ * value of @multiplicity on the component reference.
+ *
+ * If the component reference has @nonOverridable==false and @multiplicity 1..1
+ * and the reference has a target, then any composite reference which promotes
+ * the component reference has @multiplicity 0..1.by default and MAY have an explicit @multiplicity of either
+ * 0..1 or 1..1.
+ *
+ * If @nonOverridable==true, and the component reference has @multiplicity 0..1 or
+ * 1..1 and the component reference also declares a target, promotion implies
+ * that the promoting composite reference has @wiredbyImpl==true and the composite
+ * reference cannot supply a target, but can influence the policy attached to the
+ * component reference.
+ *
+ * If @nonOverridable==true, and the component reference @multiplicity is 0..n
+ * or 1..n, promotion targeting is additive
+ *
+ * @return
+ */
+ boolean isNonOverridable();
+
+ /**
+ * Set the nonOverridable flag
+ * @param nonOverridable
+ */
+ void setNonOverridable(boolean nonOverridable);
+
+ /**
+ * Sets whether this Component Reference is promoted
+ * @param isPromoted - true if the component reference is promoted
+ */
+ void setPromoted(boolean isPromoted);
+
+ boolean isPromoted();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java
new file mode 100644
index 0000000000..e1e3eab90c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+/**
+ * An addressable instance of a service associated with a particular component.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentService extends Service {
+
+ /**
+ * Returns the service defined by the implementation for this service.
+ *
+ * @return
+ */
+ Service getService();
+
+ /**
+ * Sets the service defined by the implementation for this service.
+ *
+ * @param service
+ */
+ void setService(Service service);
+
+ /**
+ * Returns the callback reference created internally as a source endpoint
+ * for callbacks from this service.
+ *
+ * @return the callback reference
+ */
+ ComponentReference getCallbackReference();
+
+ /**
+ * Sets the callback reference created internally as a source endpoint
+ * for callbacks from this service.
+ *
+ * @param callbackReference the callback reference
+ */
+ void setCallbackReference(ComponentReference callbackReference);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
new file mode 100644
index 0000000000..f748828999
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.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.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Describes an implementation and represents its configurable aspects.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentType extends Base, PolicySubject {
+
+ /**
+ * Returns the URI of this component type.
+ * @return the URI of the component type
+ */
+ String getURI();
+
+ /**
+ * Sets the URI of this component type.
+ * @param uri the URI of the component type
+ */
+ void setURI(String uri);
+
+ /**
+ * Returns a list of services that are offered.
+ *
+ * @return a list of services that are offered
+ */
+ List<Service> getServices();
+
+ /**
+ * Return a service by name
+ *
+ * @param name the service name
+ * @return service the service
+ */
+ Service getService(String name);
+
+ /**
+ * Returns the list of reference types that are used.
+ *
+ * @return the list of reference types that are used
+ */
+ List<Reference> getReferences();
+
+ /**
+ * Return a reference by name
+ *
+ * @param name the reference name
+ * @return reference the reference
+ */
+ Reference getReference(String name);
+
+ /**
+ * Returns the list of properties that can be set.
+ *
+ * @return the list of properties that can be set
+ */
+ List<Property> getProperties();
+
+ /**
+ * Return a property by name
+ *
+ * @param name the property name
+ * @return property the property
+ */
+ Property getProperty(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
new file mode 100644
index 0000000000..64a55f1b44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.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.sca.assembly;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Composite extends Implementation, Extensible, Cloneable, PolicySubject {
+ /**
+ * Special name for the domain composite
+ */
+ QName DOMAIN_COMPOSITE = new QName(SCA11_NS, "");
+ QName TYPE = new QName(SCA11_NS, "implementation.composite");
+
+ /**
+ * Returns the spec version of the composite used to build this model
+ *
+ * @return the spec version used to build this model
+ */
+ String getSpecVersion();
+
+ /**
+ * Sets the spec version of the composite used to build this model
+ *
+ * @param specVersion the spec version used to build this model
+ */
+ void setSpecVersion(String specVersion);
+
+ /**
+ * Returns the name of the composite.
+ *
+ * @return the name of the composite
+ */
+ QName getName();
+
+ /**
+ * Sets the name of the composite.
+ *
+ * @param name the name of the composite
+ */
+ void setName(QName name);
+
+ /**
+ * Returns a list of composites included in this composite.
+ *
+ * @return a list of composites included in this composite.
+ */
+ List<Composite> getIncludes();
+
+ /**
+ * Returns a list of components contained in this composite.
+ *
+ * @return a list of components contained in this composite
+ */
+ List<Component> getComponents();
+
+ /**
+ * Returns a component by name
+ */
+ Component getComponent(String name);
+
+ /**
+ * Returns a list of wires contained in this composite.
+ *
+ * @return a list of wires contained in this composite
+ */
+ List<Wire> getWires();
+
+ /**
+ * Returns true if all the components within the composite must run in the
+ * same process.
+ *
+ * @return true if all the components within the composite must run in the
+ * same process
+ */
+ boolean isLocal();
+
+ /**
+ * Sets whether all the components within the composite must run in the same
+ * process.
+ *
+ * @param local whether all the components within the composite must run in
+ * the same process
+ */
+ void setLocal(boolean local);
+
+ /**
+ * Return the Boolean value of autowire
+ * @return null/TRUE/FALSE
+ */
+ Boolean getAutowire();
+
+ /**
+ * Sets whether component references should be autowired.
+ *
+ * @param autowire whether component references should be autowired
+ */
+ void setAutowire(Boolean autowire);
+
+ /**
+ * Returns a clone of the component type.
+ *
+ * @return a clone of the component type
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
new file mode 100644
index 0000000000..88cb2f9a2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.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.assembly;
+
+import java.util.List;
+
+/**
+ * Represents composite reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompositeReference extends Reference {
+ /**
+ * Returns the promoted components. For each promoted component/reference,
+ * they have the same index in the component and reference list.
+ *
+ * @return the promoted components
+ */
+ List<Component> getPromotedComponents();
+
+ /**
+ * Returns the promoted component references.
+ *
+ * @return the promoted component references
+ */
+ List<ComponentReference> getPromotedReferences();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java
new file mode 100644
index 0000000000..575d0784ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.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.assembly;
+
+/**
+ * Represents a composite service.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface CompositeService extends Service {
+
+ /**
+ * Returns the promoted component.
+ *
+ * @return the promoted component.
+ */
+ Component getPromotedComponent();
+
+ /**
+ * Sets the promoted component
+ *
+ * @param promotedComponent the promoted component.
+ */
+ void setPromotedComponent(Component promotedComponent);
+
+ /**
+ * Returns the promoted component service .
+ *
+ * @return the promoted component service.
+ */
+ ComponentService getPromotedService();
+
+ /**
+ * Sets the promoted component service
+ *
+ * @param promotedService the promoted component service.
+ */
+ void setPromotedService(ComponentService promotedService);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
new file mode 100644
index 0000000000..25ae82aa8f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.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.assembly;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents an Operation. Typically Operation elements are used when there is a
+ * need to apply certain facets such as intents and policysets only to a specific
+ * operation provided by a service or reference.
+ *
+ * @tuscany.spi.extension.asclient
+ * @version $Rev$ $Date$
+ */
+public interface ConfiguredOperation extends Base, PolicySubject {
+ /**
+ * Returns the name of the operation.
+ *
+ * @return the name of the operation
+ */
+ String getName();
+
+ /**
+ * Sets the name of the operation.
+ *
+ * @param name the name of the operation
+ */
+ void setName(String name);
+
+ /**
+ * Returns the name of the service or reference to which this operation belongs.
+ * This method is particularly useful when operation elements are specified under implementation
+ * elements and it is necessary to identify which of the various services provided by the
+ * implementation is referred to by the operation element in question
+ *
+ * @return the name of the contract to which this operation belongs
+ */
+ String getContractName();
+
+ /**
+ * Sets the name of the service or reference to which this operation belongs.
+ *
+ * @param contractName the name of the contract to which this operation belongs
+ */
+ void setContractName(String contractName);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
new file mode 100644
index 0000000000..0c57c74ec0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a contract. A contract can be either a service or a reference.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Contract extends AbstractContract, PolicySubject, Cloneable {
+
+ /**
+ * Returns the bindings supported by this contract.
+ *
+ * @return the bindings supported by this contract
+ */
+ List<Binding> getBindings();
+
+ /**
+ * Returns a binding of the specified type or null if there is no such
+ * binding configured on this contract.
+ *
+ * @param <B> the binding type
+ * @param bindingClass the binding type class
+ * @return the binding or null if there is no binding of the specified type
+ */
+ <B> B getBinding(Class<B> bindingClass);
+
+ /**
+ * Returns a callback binding of the specified type or null if there is no such
+ * callback binding configured on this contract.
+ *
+ * @param <B> the callback binding type
+ * @param bindingClass the callback binding type class
+ * @return the callback binding or null if there is no callback binding of the specified type
+ */
+ <B> B getCallbackBinding(Class<B> bindingClass);
+
+ /**
+ * Returns a callback definition of the bindings to use for callbacks.
+ *
+ * @return a definition of the bindings to use for callbacks
+ */
+ Callback getCallback();
+
+ /**
+ * Sets a callback definition of the bindings to use for callbacks
+ *
+ * @param callback a definition of the bindings to use for callbacks
+ */
+ void setCallback(Callback callback);
+
+ /**
+ * Returns a clone of the contract.
+ *
+ * @return a clone of the reference
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Returns the interface contract given a binding. Important in the case where
+ * a reference with multiplicity > 1 has been promoted and has it's list of
+ * resolved bindings extended by a promoting reference. Here the binding
+ * from the promoting reference may need the interface contract from the
+ * promoting reference and not the promoted reference.
+ * TODO - remove this wrinkle with better endpoint support.
+ *
+ * @param binding the binding for which the interface contract is required
+ * @return the interface contract
+ */
+ InterfaceContract getInterfaceContract(Binding binding);
+
+ /**
+ * A flag to tell if there are any binding elements specified for this service or reference.
+ * If true, they override the the bindings in the corresponding reference/service in the
+ * component type or promoted reference/service.
+ * @return
+ */
+ boolean isOverridingBindings();
+
+ /**
+ * Set the flag depending on if there are any binding elements specified for this service or
+ * reference.
+ * @param overridingBindings true if there are binding elements specified
+ */
+ void setOverridingBindings(boolean overridingBindings);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java
new file mode 100644
index 0000000000..6d8350fc66
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.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.assembly;
+
+import org.apache.tuscany.sca.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * A factory for the assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultAssemblyFactory extends AssemblyFactoryImpl implements AssemblyFactory {
+
+ public DefaultAssemblyFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public DefaultAssemblyFactory() {
+ super(new DefaultExtensionPointRegistry());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
new file mode 100644
index 0000000000..43bf17d66a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a service endpoint which is what results from having a configured
+ * binding applied to a component service. In a deployed application an endpoint
+ * will relate directly to a physical endpoint, for example, a HTTP URL or a
+ * JMS destination.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Endpoint extends Base, PolicySubject, Cloneable, Serializable {
+ /**
+ * Get the structural URI of the service binding
+ * @return structural URI of the service/binding
+ */
+ String getURI();
+
+ /**
+ * Set the structural URI of the service binding
+ * @param uri &lt;componentURI&gt;#service-binding(serviceName/bindingName)
+ * or &lt;componentURI&gt;#service(serviceName)
+ */
+ void setURI(String uri);
+
+ /**
+ * Get the component model object
+ *
+ * @return component
+ */
+ Component getComponent();
+
+ /**
+ * Set the component model object
+ *
+ * @param component
+ */
+ void setComponent(Component component);
+
+ /**
+ * Get the service model object
+ *
+ * @return service
+ */
+ ComponentService getService();
+
+ /**
+ * Set the service model object
+ *
+ * @param service
+ */
+ void setService(ComponentService service);
+
+ /**
+ * Get the resolved target binding
+ *
+ * @return target binding
+ */
+ Binding getBinding();
+
+ /**
+ * Set the binding
+ *
+ * @param binding
+ */
+ void setBinding(Binding binding);
+
+ /**
+ * Returns the interface contract defining the interface
+ *
+ * @return the interface contract
+ */
+ InterfaceContract getComponentServiceInterfaceContract();
+
+ /**
+ * Get the service's callback endpoint references that
+ * represent endpoint references from which callbacks
+ * originate
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ List<EndpointReference> getCallbackEndpointReferences();
+
+ /**
+ * Returns true if this endpoint represents a serivce that is not
+ * running in this JVM
+ *
+ * @return true if the endpoint is remote
+ */
+ boolean isRemote();
+
+ /**
+ * Set true if this endpoint represents a serivce that is not
+ * running in this JVM
+ *
+ * @param remote set to true if the endpoint is remote
+ */
+ void setRemote(boolean remote);
+
+ /**
+ * Supports endpoint cloning
+ *
+ * @return endpoint
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Tests if the URI of this endpoint matches the service URI
+ * @param serviceName the service URI to test
+ * @return true if the endpoint URI matches the service URI
+ */
+ boolean matches(String serviceURI);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java
new file mode 100644
index 0000000000..f9edbe6e87
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import java.io.Serializable;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents an endpoint reference. An SCA reference can reference service endpoints in a
+ * number of ways. Target names, autowire, configured bindings. The endpoint reference
+ * captures the result of specifying one of these things.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface EndpointReference extends Base, PolicySubject, Cloneable, Serializable {
+
+ /**
+ * Status of the endpoint reference resolution
+ */
+ enum Status {
+ NOT_CONFIGURED, // Not configured
+ RESOLVED_BINDING, // The endpoint reference is configured with a binding
+ AUTOWIRE_PLACEHOLDER, // Autowire to be performed
+ WIRED_TARGET_NOT_FOUND, // Wire target not found
+ WIRED_TARGET_FOUND_READY_FOR_MATCHING, // Wire target found and ready to be resolved to an endpoint
+ WIRED_TARGET_FOUND_AND_MATCHED, // Wire target found and resolved to an endpoint
+ WIRED_TARGET_IN_BINDING_URI // SCA target specified by the binding uri
+ };
+
+ /**
+ * Get the structural URI of the reference binding
+ * @return The structural URI of the reference/binding
+ */
+ String getURI();
+
+ /**
+ * Set the structural URI of the reference binding
+ * @param uri &lt;componentURI&gt;#reference-binding(referenceName/bindingName)
+ * or &lt;componentURI&gt;#reference(referenceName) if binding is not present
+ *
+ */
+ void setURI(String uri);
+
+ /**
+ * Supports endpoint reference cloning
+ *
+ * @return endpointReference
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Get the component model object
+ *
+ * @return component
+ */
+ Component getComponent();
+
+ /**
+ * Set the component model object
+ *
+ * @param component the component for the endpoint
+ */
+ void setComponent(Component component);
+
+ /**
+ * Get the source component reference model object
+ *
+ * @return reference the source component reference for the endpoint
+ */
+ ComponentReference getReference();
+
+ /**
+ * Set the source component reference model object
+ *
+ * @param reference
+ */
+ void setReference(ComponentReference reference);
+
+ /**
+ * Get the resolved reference binding
+ *
+ * @return binding the resolved reference binding
+ */
+ Binding getBinding();
+
+ /**
+ * Set the resolved reference binding
+ *
+ * @param binding the resolved reference binding
+ */
+ void setBinding(Binding binding);
+
+ /**
+ * Get the target endpoint
+ *
+ * @return endpoint the target endpoint
+ */
+ Endpoint getTargetEndpoint();
+
+ /**
+ * Set the target endpoint model object
+ *
+ * @param endpoint the target endpoint
+ */
+ void setTargetEndpoint(Endpoint targetEndpoint);
+
+ /**
+ * Returns the interface contract defining the interface
+ *
+ * @return the interface contract
+ */
+ InterfaceContract getComponentReferenceInterfaceContract();
+
+ /**
+ * Get the reference callback endpoint that
+ * represents that target endpoint to which callback
+ * messages will be directed
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ Endpoint getCallbackEndpoint();
+
+ /**
+ * Set the reference callback endpoint
+ *
+ * @param callbackEndpoint the reference callback endpoint
+ */
+ void setCallbackEndpoint(Endpoint callbackEndpoint);
+
+ /**
+ * Rather than relying on combinations of unresolved flags and
+ * other data we maintain a status enumeration
+ *
+ * @return status
+ */
+ Status getStatus();
+
+ /**
+ * Rather than relying on combinations of unresolved flags and
+ * other data we maintain a status enumeration
+ *
+ * @param status the new status
+ */
+ void setStatus(Status status);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
new file mode 100644
index 0000000000..da8d054140
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+/**
+ * Base interface for extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Extensible extends Base {
+
+ /**
+ * Returns a list of extension objects contained in this model object.
+ *
+ * @return a list of extension objects container in this model object
+ */
+ List<Object> getExtensions();
+
+ /**
+ * Returns a list of attribute extensions contained in this model object
+ *
+ * @return a list of attribute extensions contained in this model object
+ */
+ List<Extension> getAttributeExtensions();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
new file mode 100644
index 0000000000..d179ce7b3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Base interface for storing contents of extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Extension {
+
+ /**
+ * Return QName for the extension
+ * @return the extension QName
+ */
+ QName getQName();
+
+ /**
+ * Set QName for the extension
+ * @param qName the extension QName
+ */
+ void setQName(QName qName);
+
+ /**
+ * Return the original extension value
+ * @return the extension value
+ */
+ <T> T getValue();
+
+ /**
+ * Set the original extension value
+ * @param value the extension value
+ */
+ <T> void setValue(T value);
+
+ /**
+ * Return whether or not the extension is an attribute
+ * @return
+ */
+ boolean isAttribute();
+
+ /**
+ * Set whether or not the extension is an attribute
+ * @param value
+ */
+ void setAttribute(boolean isAttribute);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
new file mode 100644
index 0000000000..3912896f0c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.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 org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * Represents a component implementation.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Implementation extends ComponentType {
+ QName getType();
+ List<Operation> getOperations();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java
new file mode 100644
index 0000000000..5b719e50bc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.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.assembly;
+
+/**
+ * Enumeration for multiplicity. Defines the number of wires that can connect a
+ * reference to target services.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension
+ */
+public enum Multiplicity {
+
+ /**
+ * Zero or one wire can have the reference as a source.
+ */
+ ZERO_ONE,
+
+ /**
+ * The default setting, one wire can have the reference as a source.
+ */
+ ONE_ONE,
+
+ /**
+ * Zero or more wires can have the reference as a source.
+ */
+ ZERO_N,
+
+ /**
+ * One or more wires can have the reference as a source.
+ */
+ ONE_N
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java
new file mode 100644
index 0000000000..9df72e358d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+/**
+ * Represents an operationSelector
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface OperationSelector extends Base, Cloneable {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
new file mode 100644
index 0000000000..9563d2e1cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly;
+
+import java.util.List;
+
+/**
+ * Interface to be implemented by SCA artifacts that support configuration of 'operation' child
+ * elements for policies etc.
+ * @tuscany.spi.extension.inheritfrom
+ * @version $Rev$ $Date$
+ */
+
+public interface OperationsConfigurator {
+ List<ConfiguredOperation> getConfiguredOperations();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
new file mode 100644
index 0000000000..c65b6213b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly;
+
+/**
+ * A property allows for the configuration of an implementation with externally
+ * set data values. An implementation can have zero or more properties. Each
+ * property has a data type, which may be either simple or complex. An
+ * implementation may also define a default value for a property.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Property extends AbstractProperty, Cloneable {
+
+ /**
+ * Returns a clone of the property.
+ *
+ * @return a clone of the property
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
new file mode 100644
index 0000000000..2ee3e774e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.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.assembly;
+
+import java.util.List;
+
+/**
+ * Represents a reference. References within an implementation represent links
+ * to services that the implementation uses that must be provided by other
+ * components.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Reference extends AbstractReference, Contract {
+
+ /**
+ * Returns a boolean value, "false" by default, which indicates that the
+ * implementation wires this reference dynamically.
+ *
+ * @return true if the implementation wires this reference dynamically
+ */
+ boolean isWiredByImpl();
+
+ /**
+ * Sets a boolean value, "false" by default, which indicates that the
+ * implementation wires this reference dynamically.
+ *
+ * @param wiredByImpl whether the implementation wires this reference
+ * dynamically
+ */
+ void setWiredByImpl(boolean wiredByImpl);
+
+
+ /**
+ * Returns the targets of this reference.
+ *
+ * @return the targets of this reference.
+ */
+ List<ComponentService> getTargets();
+
+ /**
+ * Returns the endpoint references implied by this reference.
+ *
+ * Endpoint references are used to represent:
+ *
+ * - manually specified reference targets
+ * - reference targets determined by autowire
+ * - manually configured remote bindings
+ *
+ * @return the endpoint references implied by this reference
+ */
+ List<EndpointReference> getEndpointReferences();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java
new file mode 100644
index 0000000000..aa356e3857
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.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.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents an SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCABinding extends Binding {
+ QName TYPE = new QName(SCA11_NS, "binding.sca");
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java
new file mode 100644
index 0000000000..feae980326
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.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 org.apache.tuscany.sca.assembly;
+
+/**
+ * A factory for the SCA binding model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCABindingFactory {
+
+ /**
+ * Create a new SCA binding.
+ *
+ * @return a new SCA binding
+ */
+ SCABinding createSCABinding();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java
new file mode 100644
index 0000000000..9caa7563c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import java.util.List;
+
+/**
+ * Represents a service. Services are used to publish services provided by
+ * implementations, so that they are addressable by other components.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Service extends AbstractService, Contract {
+ /**
+ * Returns the endpoints implied by this service.
+ *
+ * Endpoints represent configured bindings for a service. Hence a service
+ * with two bindings will expose two Endpoints. Where a promoted service has
+ * new binding configuration applied by a promoting component Endpoints are
+ * introduced to represent these new bindings.
+ *
+ * @return the endpoints implied by this service
+ */
+ List<Endpoint> getEndpoints();
+
+
+ /**
+ * Returns true if this service was defined based on JAXWS annotations
+ * in a Java implementation
+ *
+ * @return
+ */
+ boolean isJAXWSService();
+
+ /**
+ * Allows the JAXWSService flag to be set. It should be set true if the service
+ * configuration has been affected by JAXWS annotations.
+ *
+ * @param isJAXWSService
+ */
+ void setJAXWSService(boolean isJAXWSService);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
new file mode 100644
index 0000000000..075b50eec1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.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.sca.assembly;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a wire.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Wire extends Base, Extensible, PolicySubject, Cloneable {
+
+ /**
+ * Returns the source of the wire.
+ *
+ * @return the source of the wire
+ */
+ ComponentReference getSource();
+
+ /**
+ * Sets the source of the wire.
+ *
+ * @param source the source of the wire
+ */
+ void setSource(ComponentReference source);
+
+ /**
+ * Returns the target of the wire.
+ *
+ * @return the target of the wire
+ */
+ ComponentService getTarget();
+
+ /**
+ * Sets the target of the wire.
+ *
+ * @param target the target of the wire
+ */
+ void setTarget(ComponentService target);
+
+ /**
+ * A boolean value, with the default of "false". When a wire element has
+ * @replace="false", the wire is added to the set of wires which apply to
+ * the reference identified by the @source attribute. When a wire element
+ * has @replace="true", the wire is added to the set of wires which apply to
+ * the reference identified by the @source attribute - but any wires for that
+ * reference specified by means of the @target attribute of the reference
+ * are removed from the set of wires which apply to the reference.
+ *
+ * @return
+ */
+ boolean isReplace();
+
+ /**
+ * Set the replace flag for the wire
+ * @param replace
+ */
+ void setReplace(boolean replace);
+
+ /**
+ * Returns a clone of the wire.
+ *
+ * @return a clone of the wire
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java
new file mode 100644
index 0000000000..c622737454
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.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.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a wireFormat.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface WireFormat extends Base, Cloneable {
+ QName getSchemaName();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java
new file mode 100644
index 0000000000..8c56385c9e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.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.sca.assembly.builder;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
+
+/**
+ * A builder that handles any build-time configuration needed by bindings.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface BindingBuilder<B extends Binding> {
+
+ /**
+ * Configure a binding.
+ *
+ * @param component The component for the binding's service or reference
+ * @param contract The binding's service or reference
+ * @param context The context for the builder
+ * @param rebuild Set true to have derived data in the binding rebuilt
+ * caching can cause problems in the late binding case so we
+ * need to be able to remove cached data
+ */
+ void build(Component component, Contract contract, B binding, BuilderContext context, boolean rebuild);
+
+ /**
+ * Get QName of the binding type
+ * @return The binding type
+ */
+ QName getBindingType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java
new file mode 100644
index 0000000000..374c36c1f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.builder;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+
+/**
+ * Context for builders
+ * @tuscany.spi.extension.asclient
+ */
+public class BuilderContext {
+ protected Definitions definitions;
+ protected Map<QName, List<String>> bindingBaseURIs = Collections.emptyMap();
+ protected Monitor monitor;
+
+ /**
+ * @param definitions
+ * @param bindingBaseURIs
+ * @param monitor
+ */
+ public BuilderContext(Definitions definitions, Map<QName, List<String>> bindingBaseURIs, Monitor monitor) {
+ super();
+ this.definitions = definitions;
+ if (bindingBaseURIs != null) {
+ this.bindingBaseURIs = bindingBaseURIs;
+ }
+ this.monitor = monitor;
+ }
+
+ /**
+ * Create a builder context with the monitor
+ * @param monitor
+ */
+ public BuilderContext(Monitor monitor) {
+ super();
+ this.monitor = monitor;
+ }
+
+ /**
+ * Create a builder context with the extension point registry
+ * @param registry
+ */
+ public BuilderContext(ExtensionPointRegistry registry) {
+ super();
+ MonitorFactory monitorFactory =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
+ this.monitor = monitorFactory.createMonitor();
+ }
+
+ /**
+ * Create a builder context with a default monitor
+ */
+ public BuilderContext() {
+ super();
+ this.monitor = new DefaultMonitorFactory().createMonitor();
+ }
+
+ public Monitor getMonitor() {
+ return monitor;
+ }
+
+ public Monitor setMonitor(Monitor monitor) {
+ Monitor old = this.monitor;
+ this.monitor = monitor;
+ return old;
+ }
+
+ public Definitions getDefinitions() {
+ return definitions;
+ }
+
+ public Map<QName, List<String>> getBindingBaseURIs() {
+ return bindingBaseURIs;
+ }
+
+ public void setDefinitions(Definitions definitions) {
+ this.definitions = definitions;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java
new file mode 100644
index 0000000000..14ae2042d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.builder;
+
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * An extension point for Composite builders.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface BuilderExtensionPoint {
+
+ /**
+ * Adds a contract builder.
+ *
+ * @param compositeBuilder
+ */
+ void addContractBuilder(ContractBuilder contractBuilder);
+
+ /**
+ * Removes a contract builder.
+ *
+ * @param compositeBuilder
+ */
+ void removeContractBuilder(ContractBuilder contractBuilder);
+
+ /**
+ * Returns the contract builder
+ *
+ * @param id
+ * @return
+ */
+ ContractBuilder getContractBuilder();
+
+ /**
+ * Adds a composite builder.
+ *
+ * @param compositeBuilder
+ */
+ void addCompositeBuilder(CompositeBuilder compositeBuilder);
+
+ /**
+ * Removes a composite builder.
+ *
+ * @param compositeBuilder
+ */
+ void removeCompositeBuilder(CompositeBuilder compositeBuilder);
+
+ /**
+ * Returns the composite builder with the given id.
+ *
+ * @param id
+ * @return
+ */
+ CompositeBuilder getCompositeBuilder(String id);
+
+ /**
+ * Add a binding builder
+ * @param bindingBuilder
+ */
+ void addBindingBuilder(BindingBuilder<?> bindingBuilder);
+
+ /**
+ * Look up a binding builder by the binding type
+ * @param <B>
+ * @param bindingType
+ * @return
+ */
+ <B extends Binding> BindingBuilder<B> getBindingBuilder(QName bindingType);
+
+ /**
+ * Remove a binding builder
+ * @param <B>
+ * @param builder
+ */
+ <B extends Binding> void removeBindingBuilder(BindingBuilder<B> builder);
+
+ /**
+ * Add an implementation builder
+ * @param implementationBuilder
+ */
+ void addImplementationBuilder(ImplementationBuilder<?> implementationBuilder);
+
+ /**
+ * Look up an implementation builder by implementation type
+ * @param <I>
+ * @param implementationType
+ * @return
+ */
+ <I extends Implementation> ImplementationBuilder<I> getImplementationBuilder(QName implementationType);
+
+ /**
+ * Remove an implementation builder
+ * @param <I>
+ * @param builder
+ */
+ <I extends Implementation> void removeImplementationBuilder(ImplementationBuilder<I> builder);
+
+ /**
+ * Add a policy builder
+ * @param policyBuilder
+ */
+ void addPolicyBuilder(PolicyBuilder<?> policyBuilder);
+
+ /**
+ * Look up a Policy builder by the Policy type
+ * @param <P>
+ * @param policyType
+ * @return
+ */
+ <P> PolicyBuilder<P> getPolicyBuilder(QName policyType);
+
+ /**
+ * Remove a Policy builder
+ * @param <P>
+ * @param builder
+ */
+ <P> void removePolicyBuilder(PolicyBuilder<P> builder);
+
+ /**
+ * Get a collection of policy builders
+ * @return
+ */
+ public Collection<PolicyBuilder> getPolicyBuilders();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java
new file mode 100644
index 0000000000..50bf10f54a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.builder;
+
+import org.apache.tuscany.sca.assembly.Composite;
+
+/**
+ * A builder that handles the configuration of the components inside a
+ * composite and the wiring of component references to component services.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompositeBuilder {
+
+ /**
+ * Returns the ID of the builder.
+ *
+ * @return An ID that identifies the builder
+ */
+ String getID();
+
+ /**
+ * Build a composite.
+ *
+ * @param composite The composite
+ * @param context The builder context
+ * @return The composite built from the original one. In most cases, it is the same as the orginal one as
+ * most builders only change the content of the composite.
+ *
+ * @throws CompositeBuilderException
+ */
+ Composite build(Composite composite, BuilderContext context) throws CompositeBuilderException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java
new file mode 100644
index 0000000000..5a2015f55e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.builder;
+
+/**
+ * Reports a composite builder exception.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeBuilderException extends Exception {
+ private static final long serialVersionUID = -8916323176803443856L;
+
+ public CompositeBuilderException() {
+ }
+
+ public CompositeBuilderException(String message) {
+ super(message);
+ }
+
+ public CompositeBuilderException(Throwable cause) {
+ super(cause);
+ }
+
+ public CompositeBuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ContractBuilder.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ContractBuilder.java
new file mode 100644
index 0000000000..99a58dc1c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ContractBuilder.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.sca.assembly.builder;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * A builder that builds WSDL versions of component contracts so that the
+ * component contracts can be compared with binding contracts in a generic way.
+ * The generic interface format defined by the Assembly spec is WSDL 1.1
+ */
+public interface ContractBuilder {
+
+ /**
+ * Build the WSDL version of the Interface Contract
+ */
+ boolean build(InterfaceContract interfaceContract, BuilderContext context);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java
new file mode 100644
index 0000000000..8b037a7534
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java
@@ -0,0 +1,479 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.builder;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDeclarationParser;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+
+/**
+ * Default implementation of a provider factory extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultBuilderExtensionPoint implements BuilderExtensionPoint, LifeCycleListener {
+
+ private ExtensionPointRegistry registry;
+ private final Map<String, CompositeBuilder> builders = new HashMap<String, CompositeBuilder>();
+ private final Map<QName, BindingBuilder> bindingBuilders = new HashMap<QName, BindingBuilder>();
+ private final Map<QName, ImplementationBuilder> implementationBuilders =
+ new HashMap<QName, ImplementationBuilder>();
+ private final Map<QName, PolicyBuilder> policyBuilders = new HashMap<QName, PolicyBuilder>();
+ private ContractBuilder contractBuilder = null;
+
+ private boolean loaded;
+
+ public DefaultBuilderExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ builders.clear();
+ bindingBuilders.clear();
+ implementationBuilders.clear();
+ loaded = false;
+ }
+
+ public void addCompositeBuilder(CompositeBuilder builder) {
+ builders.put(builder.getID(), builder);
+ }
+
+ public void removeCompositeBuilder(CompositeBuilder builder) {
+ builders.remove(builder.getID());
+ }
+
+ public CompositeBuilder getCompositeBuilder(String id) {
+ loadBuilders();
+ return builders.get(id);
+ }
+
+ public void addContractBuilder(ContractBuilder contractBuilder){
+ this.contractBuilder = contractBuilder;
+ }
+
+ public void removeContractBuilder(ContractBuilder contractBuilder){
+ this.contractBuilder = null;
+ }
+
+ public ContractBuilder getContractBuilder(){
+ loadBuilders();
+ return contractBuilder;
+ }
+
+ /**
+ * Load builders declared under META-INF/services.
+ */
+ private synchronized void loadBuilders() {
+ if (loaded)
+ return;
+
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+
+ UtilityExtensionPoint utils = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utils.getUtility(InterfaceContractMapper.class);
+
+ // Get the provider factory service declarations
+ Collection<ServiceDeclaration> builderDeclarations;
+ ServiceDiscovery serviceDiscovery = registry.getServiceDiscovery();
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(CompositeBuilder.class.getName());
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ Map<String, String> attributes = builderDeclaration.getAttributes();
+ String id = attributes.get("id");
+
+ CompositeBuilder builder = new LazyCompositeBuilder(id, builderDeclaration, this, factories, mapper);
+ builders.put(id, builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(BindingBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ BindingBuilder<?> builder = new LazyBindingBuilder(builderDeclaration);
+ bindingBuilders.put(builder.getBindingType(), builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(ImplementationBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ ImplementationBuilder<?> builder = new LazyImplementationBuilder(builderDeclaration);
+ implementationBuilders.put(builder.getImplementationType(), builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(PolicyBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ PolicyBuilder<?> builder = new LazyPolicyBuilder(builderDeclaration);
+ policyBuilders.put(builder.getPolicyType(), builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(ContractBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ contractBuilder = new LazyContractBuilder(builderDeclaration);
+ }
+
+
+ loaded = true;
+
+ }
+
+ public void addBindingBuilder(BindingBuilder<?> bindingBuilder) {
+ bindingBuilders.put(bindingBuilder.getBindingType(), bindingBuilder);
+ }
+
+ public <B extends Binding> BindingBuilder<B> getBindingBuilder(QName bindingType) {
+ loadBuilders();
+ return (BindingBuilder<B>)bindingBuilders.get(bindingType);
+ }
+
+ public <B extends Binding> void removeBindingBuilder(BindingBuilder<B> builder) {
+ bindingBuilders.remove(builder.getBindingType());
+ }
+
+ public void addImplementationBuilder(ImplementationBuilder<?> implementationBuilder) {
+ implementationBuilders.put(implementationBuilder.getImplementationType(), implementationBuilder);
+ }
+
+ public <I extends Implementation> ImplementationBuilder<I> getImplementationBuilder(QName implementationType) {
+ loadBuilders();
+ return (ImplementationBuilder<I>)implementationBuilders.get(implementationType);
+ }
+
+ public <I extends Implementation> void removeImplementationBuilder(ImplementationBuilder<I> builder) {
+ implementationBuilders.remove(builder.getImplementationType());
+ }
+
+ public void addPolicyBuilder(PolicyBuilder<?> policyBuilder) {
+ policyBuilders.put(policyBuilder.getPolicyType(), policyBuilder);
+ }
+
+ public <B> PolicyBuilder<B> getPolicyBuilder(QName policyType) {
+ loadBuilders();
+ return (PolicyBuilder<B>)policyBuilders.get(policyType);
+ }
+
+ public Collection<PolicyBuilder> getPolicyBuilders() {
+ loadBuilders();
+ return policyBuilders.values();
+ }
+
+ public <B> void removePolicyBuilder(PolicyBuilder<B> builder) {
+ policyBuilders.remove(builder.getPolicyType());
+ }
+
+ /**
+ * A wrapper around a composite builder allowing lazy
+ * loading and initialization of implementation providers.
+ */
+ private class LazyCompositeBuilder implements CompositeBuilder {
+
+ private FactoryExtensionPoint factories;
+ private InterfaceContractMapper mapper;
+ private String id;
+ private ServiceDeclaration builderDeclaration;
+ private CompositeBuilder builder;
+ private BuilderExtensionPoint builders;
+
+ private LazyCompositeBuilder(String id,
+ ServiceDeclaration factoryDeclaration,
+ BuilderExtensionPoint builders,
+ FactoryExtensionPoint factories,
+ InterfaceContractMapper mapper) {
+ this.id = id;
+ this.builderDeclaration = factoryDeclaration;
+ this.builders = builders;
+ this.factories = factories;
+ this.mapper = mapper;
+ }
+
+ public String getID() {
+ return id;
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ return getBuilder().build(composite, context);
+ }
+
+ private CompositeBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<CompositeBuilder> builderClass = (Class<CompositeBuilder>)builderDeclaration.loadClass();
+ try {
+ Constructor<CompositeBuilder> constructor =
+ builderClass.getConstructor(FactoryExtensionPoint.class, InterfaceContractMapper.class);
+ builder = constructor.newInstance(factories, mapper);
+ } catch (NoSuchMethodException e) {
+ try {
+ Constructor<CompositeBuilder> constructor =
+ builderClass.getConstructor(BuilderExtensionPoint.class,
+ FactoryExtensionPoint.class,
+ InterfaceContractMapper.class);
+ builder = constructor.newInstance(builders, factories, mapper);
+ } catch (NoSuchMethodException ex) {
+ Constructor<CompositeBuilder> constructor =
+ builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = constructor.newInstance(registry);
+ }
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
+ private class LazyBindingBuilder implements BindingBuilder {
+ private ServiceDeclaration sd;
+ private BindingBuilder<?> builder;
+ private QName qname;;
+
+ /**
+ * @param sd
+ */
+ public LazyBindingBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname"));
+ }
+
+ public void build(Component component, Contract contract, Binding binding, BuilderContext context, boolean rebuild) {
+ getBuilder().build(component, contract, binding, context, rebuild);
+ }
+
+ public QName getBindingType() {
+ return qname;
+ }
+
+
+ private synchronized BindingBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (BindingBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (BindingBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
+ private class LazyImplementationBuilder implements ImplementationBuilder {
+ private ServiceDeclaration sd;
+ private ImplementationBuilder<?> builder;
+ private QName qname;;
+
+ /**
+ * @param sd
+ */
+ public LazyImplementationBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname"));
+ }
+
+ public void build(Component component, Implementation implementation, BuilderContext context) {
+ getBuilder().build(component, implementation, context);
+ }
+
+ public QName getImplementationType() {
+ return qname;
+ }
+
+ private synchronized ImplementationBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (ImplementationBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (ImplementationBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
+ private class LazyPolicyBuilder implements PolicyBuilder {
+ private ServiceDeclaration sd;
+ private PolicyBuilder<?> builder;
+ private QName qname;;
+
+ /**
+ * @param sd
+ */
+ public LazyPolicyBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname"));
+ }
+
+ public boolean build(Component component, Implementation implementation, BuilderContext context) {
+ return getBuilder().build(component, implementation, context);
+ }
+
+ public QName getPolicyType() {
+ return qname;
+ }
+
+ public List<QName> getSupportedBindings() {
+ return getBuilder().getSupportedBindings();
+ }
+
+ private synchronized PolicyBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (PolicyBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (PolicyBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ public boolean build(Endpoint endpoint, BuilderContext context) {
+ return getBuilder().build(endpoint, context);
+ }
+
+ public boolean build(org.apache.tuscany.sca.assembly.EndpointReference endpointReference, BuilderContext context) {
+ return getBuilder().build(endpointReference, context);
+ }
+
+ public boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context) {
+ return getBuilder().build(endpointReference, endpoint, context);
+ }
+ }
+
+ private class LazyContractBuilder implements ContractBuilder {
+ private ServiceDeclaration sd;
+ private ContractBuilder builder;
+
+ /**
+ * @param sd
+ */
+ public LazyContractBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ }
+
+/*
+ public boolean build(EndpointReference endpointReference, BuilderContext context){
+ return getBuilder().build(endpointReference, context);
+ }
+
+ public boolean build(Endpoint endpoint, BuilderContext context){
+ return getBuilder().build(endpoint, context);
+ }
+*/
+
+ public boolean build(InterfaceContract interfaceContract, BuilderContext context){
+ return getBuilder().build(interfaceContract, context);
+ }
+
+ private synchronized ContractBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (ContractBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (ContractBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java
new file mode 100644
index 0000000000..d47c3d9032
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.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.assembly.builder;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * A builder that handles any build-time configuration needed by implementations.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ImplementationBuilder<I extends Implementation> {
+
+ /**
+ * Configure a component implementation.
+ *
+ * @param component The component
+ * @param context TODO
+ * @param contract The implementation
+ */
+ void build(Component component, I implmentation, BuilderContext context);
+
+ /**
+ * Get the QName of the implementation type
+ * @return
+ */
+ QName getImplementationType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java
new file mode 100644
index 0000000000..4f2842c61a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.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.sca.assembly.builder;
+
+/**
+ * Constants for resource bundle names
+ */
+public interface Messages {
+ String RESOURCE_PACKAGE = "org.apache.tuscany.sca.assembly.builder.";
+ String ASSEMBLY_VALIDATION = RESOURCE_PACKAGE + "assembly-validation-messages";
+ String ASSEMBLY_CONFORMANCE = RESOURCE_PACKAGE + "assembly-conformance-messages";
+ String DEFINITIONS_VALIDATION = RESOURCE_PACKAGE + "definitions-validation-messages";
+ String BUILDER_VALIDATION_BUNDLE = "org.apache.tuscany.sca.builder.builder-validation-messages";
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java
new file mode 100644
index 0000000000..423c856973
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.builder;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * A builder that is contributed by a specific policy language to validate the configurations
+ * for SCA endpoints, endpoint references and component implementations
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PolicyBuilder<T> {
+ /**
+ * Get the policy type
+ * @return
+ */
+ QName getPolicyType();
+
+ /**
+ * Return the list of binding type QNames at which this policy implementation
+ * is targeted. Or null if the policy is not binding specific
+ * @return list of binding type QNames at which this policy implementation or null if it's not binding specific
+ */
+ List<QName> getSupportedBindings();
+
+ /**
+ * Build (and validate) the policy settings on the endpoint
+ * @param endpoint
+ * @param monitor
+ * @return true if the policy setting is compatible
+ */
+ boolean build(Endpoint endpoint, BuilderContext context);
+
+ /**
+ * Build (and validate) the policy settings on the endpoint reference
+ * @param endpointReference
+ * @param monitor
+ * @return true if the policy setting is compatible
+ */
+ boolean build(EndpointReference endpointReference, BuilderContext context);
+
+ /**
+ * Build (and validate) the policy settings on the component implementation
+ * @param component
+ * @param implementation
+ * @param monitor
+ * @return true if the policy setting is compatible
+ */
+ boolean build(Component component, Implementation implementation, BuilderContext context);
+
+ /**
+ * Build (and validate) the policy settings on the endpoint reference is compatible with the endpoint
+ * @param endpointReference
+ * @param endpoint
+ * @param context
+ * @return if the policy setting is compatible
+ */
+ boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/WireBuilder.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/WireBuilder.java
new file mode 100644
index 0000000000..2bfbe85664
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/WireBuilder.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.sca.assembly.builder;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+
+/**
+ * A builder that connects an endpoint reference to an endpoint
+ */
+public interface WireBuilder {
+ /**
+ * Build the endpoint reference against the endpoint. If the endpoint is a valid target for the
+ * endpoint reference, the wire buidler can populate some information from the endpoint into the
+ * endpoint reference (such as targetEndpoint, policySets or requiredIntents)
+ * @param endpointReference
+ * @param endpoint
+ * @param context
+ * @return true if the endpoint is a valid target for the endpoint reference
+ */
+ boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
new file mode 100644
index 0000000000..24dc20f815
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * Represents an abstract property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProperty {
+ protected Object value;
+ protected String name;
+ protected QName xsdType;
+ protected QName xsdElement;
+ protected boolean many;
+ protected boolean mustSupply;
+ protected DataType dataType;
+ protected Object xsdDefinition;
+
+ /**
+ * Constructs a new abstract property.
+ */
+ protected AbstractPropertyImpl() {
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public QName getXSDElement() {
+ return xsdElement;
+ }
+
+ public QName getXSDType() {
+ return xsdType;
+ }
+
+ public boolean isMany() {
+ return many;
+ }
+
+ public boolean isMustSupply() {
+ return mustSupply;
+ }
+
+ public void setValue(Object defaultValue) {
+ this.value = defaultValue;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+ public void setMustSupply(boolean mustSupply) {
+ this.mustSupply = mustSupply;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setXSDElement(QName element) {
+ this.xsdElement = element;
+ }
+
+ public void setXSDType(QName type) {
+ this.xsdType = type;
+ }
+
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(DataType dataType) {
+ this.dataType = dataType;
+ }
+
+ public Object getXSDDefinition() {
+ return xsdDefinition;
+ }
+
+ public void setXSDDefinition(Object xsdDefinition) {
+ this.xsdDefinition = xsdDefinition;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java
new file mode 100644
index 0000000000..3e44f5f7ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.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.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+
+/**
+ * Represents an abstract reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractReferenceImpl extends ContractImpl implements AbstractReference {
+ private Multiplicity multiplicity = Multiplicity.ONE_ONE;
+
+ /**
+ * Constructs a new abstract reference.
+ */
+ protected AbstractReferenceImpl() {
+ }
+
+ public Multiplicity getMultiplicity() {
+ return multiplicity;
+ }
+
+ public void setMultiplicity(Multiplicity multiplicity) {
+ this.multiplicity = multiplicity;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java
new file mode 100644
index 0000000000..24b1a0e03e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.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 org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractService;
+
+/**
+ * Represents an abstract service
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractServiceImpl extends ContractImpl implements AbstractService {
+
+ /**
+ * Constructs a new abstract service.
+ */
+ protected AbstractServiceImpl() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
new file mode 100644
index 0000000000..0759ff1361
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.AbstractService;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * A factory for the assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AssemblyFactoryImpl implements AssemblyFactory {
+
+ protected ExtensionPointRegistry registry;
+
+ protected AssemblyFactoryImpl(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public AbstractProperty createAbstractProperty() {
+ return new AbstractPropertyImpl();
+ }
+
+ public AbstractReference createAbstractReference() {
+ return new AbstractReferenceImpl();
+ }
+
+ public AbstractService createAbstractService() {
+ return new AbstractServiceImpl();
+ }
+
+ public Callback createCallback() {
+ return new CallbackImpl();
+ }
+
+ public Component createComponent() {
+ return new ComponentImpl();
+ }
+
+ public ComponentProperty createComponentProperty() {
+ return new ComponentPropertyImpl();
+ }
+
+ public ComponentReference createComponentReference() {
+ return new ComponentReferenceImpl();
+ }
+
+ public ComponentService createComponentService() {
+ return new ComponentServiceImpl();
+ }
+
+ public ComponentType createComponentType() {
+ return new ComponentTypeImpl();
+ }
+
+ public Composite createComposite() {
+ return new CompositeImpl();
+ }
+
+ public CompositeReference createCompositeReference() {
+ return new CompositeReferenceImpl();
+ }
+
+ public CompositeService createCompositeService() {
+ return new CompositeServiceImpl();
+ }
+
+ public Property createProperty() {
+ return new PropertyImpl();
+ }
+
+ public Reference createReference() {
+ return new ReferenceImpl();
+ }
+
+ public Service createService() {
+ return new ServiceImpl();
+ }
+
+ public Wire createWire() {
+ return new WireImpl();
+ }
+
+ public Extension createExtension() {
+ return new ExtensionImpl();
+ }
+
+ public Endpoint createEndpoint() {
+ return new EndpointImpl(registry);
+ }
+
+ public EndpointReference createEndpointReference() {
+ return new EndpointReferenceImpl(registry);
+ }
+
+ public ConfiguredOperation createConfiguredOperation() {
+ return new ConfiguredOperationImpl();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
new file mode 100644
index 0000000000..516b11724f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+/**
+ * Convenience base class for assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseImpl implements Base {
+ private boolean unresolved;
+
+ /**
+ * Constructs a new base model object.
+ */
+ protected BaseImpl() {
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java
new file mode 100644
index 0000000000..d912606f1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Base Binding implementation class
+ */
+public abstract class BindingImpl extends ExtensibleImpl implements Binding {
+ private String name;
+ private ExtensionType extensionType;
+ private String uri;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ protected QName type;
+
+ protected BindingImpl(QName type) {
+ super();
+ this.type = type;
+ }
+
+ public QName getType() {
+ return type;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ExtensionType getExtensionType() {
+ return extensionType;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.extensionType = type;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(getType()).append(" (");
+ buf.append("uri=").append(getURI());
+ buf.append(",name=").append(getName());
+ buf.append(")");
+ return buf.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
new file mode 100644
index 0000000000..dec68d1413
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallbackImpl extends ExtensibleImpl implements Callback {
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private Contract parentContract;
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ protected CallbackImpl() {
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public Contract getParentContract() {
+ return parentContract;
+ }
+
+ public void setParentContract(Contract contract) {
+ this.parentContract = contract;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
new file mode 100644
index 0000000000..8a03df339c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentImpl extends ExtensibleImpl implements Component, Cloneable {
+ private Implementation implementation;
+ private String name;
+ private String uri;
+ private List<ComponentProperty> properties = new ArrayList<ComponentProperty>();
+ private List<ComponentReference> references = new ArrayList<ComponentReference>();
+ private List<ComponentService> services = new ArrayList<ComponentService>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private Boolean autowire;
+ private ExtensionType type;
+
+ /**
+ * Constructs a new component.
+ */
+ protected ComponentImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ComponentImpl clone = (ComponentImpl)super.clone();
+
+ clone.properties = new ArrayList<ComponentProperty>();
+ for (ComponentProperty property : getProperties()) {
+ clone.properties.add((ComponentProperty)property.clone());
+ }
+ clone.references = new ArrayList<ComponentReference>();
+ for (ComponentReference reference : getReferences()) {
+ clone.references.add((ComponentReference)reference.clone());
+ }
+ clone.services = new ArrayList<ComponentService>();
+ for (ComponentService service : getServices()) {
+ clone.services.add((ComponentService)service.clone());
+ }
+
+ // Clone the implementation.composite
+ if(implementation instanceof Composite) {
+ clone.implementation = (Composite) ((Composite) implementation).clone();
+ }
+
+ // Clone the Lists for intents and policySets
+ clone.requiredIntents = new ArrayList<Intent>(getRequiredIntents());
+ clone.policySets = new ArrayList<PolicySet>(getPolicySets());
+
+ return clone;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public Implementation getImplementation() {
+ return implementation;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<ComponentProperty> getProperties() {
+ return properties;
+ }
+
+ public ComponentProperty getProperty(String name) {
+ for (ComponentProperty property : getProperties()) {
+ if (property.getName().equals(name)) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ public List<ComponentReference> getReferences() {
+ return references;
+ }
+
+ public ComponentReference getReference(String name){
+ for (ComponentReference ref : getReferences()){
+ if (ref.getName().equals(name)){
+ return ref;
+ }
+ }
+ return null;
+ }
+
+ public List<ComponentService> getServices() {
+ return services;
+ }
+
+ public ComponentService getService(String name) {
+ for (ComponentService service : getServices()) {
+ if (service.getName().equals(name)) {
+ return service;
+ }
+ }
+ return null;
+ }
+
+ public void setImplementation(Implementation implementation) {
+ this.implementation = implementation;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public boolean isAutowire() {
+ return (autowire == null) ? false : autowire.booleanValue();
+ }
+
+ public void setAutowire(Boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public Boolean getAutowire() {
+ return autowire;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("Component (");
+ buf.append("uri=").append(uri);
+ buf.append(",name=").append(name);
+ buf.append(",implementation=").append(implementation);
+ buf.append(")");
+ return buf.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
new file mode 100644
index 0000000000..9db522930f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+
+/**
+ * Represents a component property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentPropertyImpl extends PropertyImpl implements ComponentProperty, Cloneable {
+ private String file;
+ private Property property;
+ private String source;
+ private XPathExpression sourceXPathExpression;
+
+ /**
+ * Constructs a new component property.
+ */
+ protected ComponentPropertyImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ // FIXME getValue should not delegate to property.getValue()
+ // Doing this violates the setValue/getValue semantics, as you
+ // can call setValue() then get a different value from getValue()
+ @Override
+ public Object getValue() {
+ if (super.getValue() == null && property != null) {
+ return property.getValue();
+ } else {
+ return super.getValue();
+ }
+ }
+
+ public String getFile() {
+ return file;
+ }
+
+ public Property getProperty() {
+ return property;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ public void setProperty(Property property) {
+ this.property = property;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public XPathExpression getSourceXPathExpression() {
+ return sourceXPathExpression;
+ }
+
+ public void setSourceXPathExpression(XPathExpression sourceXPathExpression) {
+ this.sourceXPathExpression = sourceXPathExpression;
+ }
+
+ public String toString() {
+ return "Property: " + getName() + " Value: " + getValue();
+ } // end method toString
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
new file mode 100644
index 0000000000..78b54668b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a component reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferenceImpl extends ReferenceImpl implements ComponentReference, Cloneable {
+ private Reference reference;
+ private Boolean autowire;
+ private boolean nonOverridable;
+ private List<CompositeReference> promotedAs = new ArrayList<CompositeReference>();
+ private ComponentService callbackService;
+ private boolean isPromoted = false;
+
+ /**
+ * Constructs a new component reference.
+ */
+ protected ComponentReferenceImpl() {
+ // Set multiplicity to null so that by default it'll inherit from the Reference
+ setMultiplicity(null);
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public Reference getReference() {
+ return reference;
+ }
+
+ public void setReference(Reference reference) {
+ this.reference = reference;
+ }
+
+ public boolean isAutowire() {
+ return (autowire == null) ? false : autowire.booleanValue();
+ }
+
+ public void setAutowire(Boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public Boolean getAutowire() {
+ return autowire;
+ }
+
+ public List<CompositeReference> promotedAs() {
+ return promotedAs;
+ }
+
+ public ComponentService getCallbackService() {
+ return callbackService;
+ }
+
+ public void setCallbackService(ComponentService callbackService) {
+ this.callbackService = callbackService;
+ }
+
+ /**
+ * Use endpoint information to work out what the interface contract for the
+ * binding is.
+ */
+ @Override
+ public InterfaceContract getInterfaceContract(Binding binding) {
+ InterfaceContract interfaceContract = null;
+
+ if (interfaceContract == null) {
+ interfaceContract = getInterfaceContract();
+ }
+ return interfaceContract;
+ }
+
+ public boolean isNonOverridable() {
+ return nonOverridable;
+ }
+
+ public void setNonOverridable(boolean nonOverridable) {
+ this.nonOverridable = nonOverridable;
+ }
+
+ public void setPromoted(boolean isPromoted) {
+ this.isPromoted = isPromoted;
+ } // end method setPromoted
+
+ public boolean isPromoted() {
+ return isPromoted;
+ }
+} // end class ComponentReferenceImpl
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java
new file mode 100644
index 0000000000..f8c9f53413
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+
+/**
+ * Represents a component service
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentServiceImpl extends ServiceImpl implements ComponentService, Cloneable {
+ private Service service;
+ private List<CompositeService> promotedAs = new ArrayList<CompositeService>();
+ private ComponentReference callbackReference;
+
+ /**
+ * Constructs a new component service.
+ */
+ protected ComponentServiceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public Service getService() {
+ return service;
+ }
+
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ public List<CompositeService> promotedAs() {
+ return promotedAs;
+ }
+
+ public ComponentReference getCallbackReference() {
+ return callbackReference;
+ }
+
+ public void setCallbackReference(ComponentReference callbackReference) {
+ this.callbackReference = callbackReference;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
new file mode 100644
index 0000000000..b52c65ef8b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a component type.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, Cloneable {
+ private String uri;
+ private List<Property> properties = new ArrayList<Property>();
+ private List<Reference> references = new ArrayList<Reference>();
+ private List<Service> services = new ArrayList<Service>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ /**
+ * Constructs a new component type.
+ */
+ protected ComponentTypeImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ComponentTypeImpl clone = (ComponentTypeImpl)super.clone();
+
+ clone.services = new ArrayList<Service>();
+ for (Service service : getServices()) {
+ clone.services.add((Service)service.clone());
+ }
+ clone.references = new ArrayList<Reference>();
+ for (Reference reference : getReferences()) {
+ clone.references.add((Reference)reference.clone());
+ }
+ clone.properties = new ArrayList<Property>();
+ for (Property property : getProperties()) {
+ clone.properties.add((Property)property.clone());
+ }
+ clone.requiredIntents = new ArrayList<Intent>(requiredIntents);
+ clone.policySets = new ArrayList<PolicySet>(policySets);
+ return clone;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ public Property getProperty(String name){
+ Property property = null;
+
+ for (Property tmp : getProperties()){
+ if (tmp.getName().equals(name)){
+ property = tmp;
+ break;
+ }
+ }
+
+ return property;
+ }
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public Reference getReference(String name){
+ Reference reference = null;
+
+ for (Reference tmp : getReferences()){
+ if (tmp.getName().equals(name)){
+ reference = tmp;
+ break;
+ }
+ }
+
+ return reference;
+ }
+
+ public List<Service> getServices() {
+ return services;
+ }
+
+ public Service getService(String name){
+ Service service = null;
+
+ for (Service tmp : getServices()){
+ if (tmp.getName().equals(name)){
+ service = tmp;
+ break;
+ }
+ }
+
+ return service;
+ }
+
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ComponentTypeImpl other = (ComponentTypeImpl)obj;
+ if (uri == null) {
+ if (other.uri != null) {
+ return false;
+ }
+ } else if (!uri.equals(other.uri)) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java
new file mode 100644
index 0000000000..fba6af7e7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+
+/**
+ * Implementation of a Composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeImpl extends ImplementationImpl implements Composite, Cloneable {
+ private String specVersion = "undefined";
+ private List<Component> components = new ArrayList<Component>();
+ private List<Composite> includes = new ArrayList<Composite>();
+ private QName name;
+ private List<Wire> wires = new ArrayList<Wire>();
+ private Boolean autowire;
+ private boolean local = true;
+
+ /**
+ * Constructs a new composite.
+ */
+ protected CompositeImpl() {
+ super(TYPE);
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ CompositeImpl clone = (CompositeImpl)super.clone();
+
+ // clone the child components
+ clone.components = new ArrayList<Component>();
+ for (Component component : getComponents()) {
+ Component clonedComponent = (Component)component.clone();
+ clone.components.add(clonedComponent);
+ }
+
+ // reset the references and services so the get re-resolved
+ for (Service service : clone.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ // Force the promoted component/service to be rebuilt against the clone
+ if (compositeService.getPromotedComponent() != null) {
+ compositeService.getPromotedComponent().setUnresolved(true);
+ }
+ if (compositeService.getPromotedService() != null) {
+ compositeService.getPromotedService().setUnresolved(true);
+ }
+ }
+ for (Reference reference : clone.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ for (ComponentReference ref : compositeReference.getPromotedReferences()) {
+ // Force the promoted reference to be rebuilt against the clone
+ ref.setUnresolved(true);
+ }
+ }
+
+ // clone the wires
+ clone.wires = new ArrayList<Wire>();
+ for (Wire wire : getWires()) {
+ clone.wires.add((Wire)wire.clone());
+ }
+
+ // Clone the includes
+ clone.includes = new ArrayList<Composite>();
+ for (Composite included : getIncludes()) {
+ clone.includes.add((Composite)included.clone());
+ }
+ return clone;
+ }
+
+ public String getSpecVersion() {
+ return specVersion;
+ }
+
+ public void setSpecVersion(String specVersion) {
+ this.specVersion = specVersion;
+ }
+
+ public List<Component> getComponents() {
+ return components;
+ }
+
+ public Component getComponent(String name) {
+ Component component = null;
+
+ for (Component tmp : getComponents()){
+ if (tmp.getName().equals(name)){
+ component = tmp;
+ break;
+ }
+ }
+ return component;
+ }
+
+ public List<Composite> getIncludes() {
+ return includes;
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ public List<Wire> getWires() {
+ return wires;
+ }
+
+ public boolean isLocal() {
+ return local;
+ }
+
+ public void setLocal(boolean local) {
+ this.local = local;
+ }
+
+ public boolean isAutowire() {
+ return (autowire == null) ? false : autowire.booleanValue();
+ }
+
+ public void setAutowire(Boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public Boolean getAutowire() {
+ return autowire;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getName()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof Composite) {
+ if (getName() != null) {
+ return getName().equals(((Composite)obj).getName());
+ } else {
+ return ((Composite)obj).getName() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Composite (name=" + getName() + ")";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
new file mode 100644
index 0000000000..ae5fad461b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.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.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+
+/**
+ * Represents a composite reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceImpl extends ReferenceImpl implements CompositeReference, Cloneable {
+ private List<Component> promotedComponents = new ArrayList<Component>();
+ private List<ComponentReference> promotedReferences = new ArrayList<ComponentReference>();
+
+ /**
+ * Constructs a new composite reference.
+ */
+ protected CompositeReferenceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ CompositeReferenceImpl copy = (CompositeReferenceImpl)super.clone();
+ copy.promotedComponents = new ArrayList<Component>(promotedComponents);
+ copy.promotedReferences = new ArrayList<ComponentReference>(promotedReferences);
+ return copy;
+ }
+
+ public List<ComponentReference> getPromotedReferences() {
+ return promotedReferences;
+ }
+
+ public List<Component> getPromotedComponents() {
+ return promotedComponents;
+ }
+
+ public String toString() {
+ return getName();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java
new file mode 100644
index 0000000000..55b48ec578
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.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.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+
+/**
+ * Represents a composite service
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeServiceImpl extends ServiceImpl implements CompositeService, Cloneable {
+ private ComponentService promotedService;
+ private Component promotedComponent;
+
+ /**
+ * Constructs a new composite service.
+ */
+ protected CompositeServiceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public ComponentService getPromotedService() {
+ return promotedService;
+ }
+
+ public void setPromotedService(ComponentService promotedService) {
+ this.promotedService = promotedService;
+ }
+
+ public Component getPromotedComponent() {
+ return promotedComponent;
+ }
+
+ public void setPromotedComponent(Component promotedComponent) {
+ this.promotedComponent = promotedComponent;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
new file mode 100644
index 0000000000..80c1c7cd21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents an Operation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfiguredOperationImpl extends BaseImpl implements ConfiguredOperation {
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ private String name;
+ private String contractName;
+ private ExtensionType type;
+
+ /**
+ * Constructs a new Operation.
+ */
+ protected ConfiguredOperationImpl() {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public String getContractName() {
+ return contractName;
+ }
+
+ public void setContractName(String contractName) {
+ this.contractName = contractName;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
new file mode 100644
index 0000000000..2b72f1f047
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Implementation of a Contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContractImpl extends ExtensibleImpl implements AbstractContract {
+ private InterfaceContract interfaceContract;
+ private String name;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ private boolean isCallback = false;
+
+ /**
+ * Constructs a new contract.
+ */
+ protected ContractImpl() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public InterfaceContract getInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public boolean isForCallback() {
+ return isCallback;
+ }
+
+ public void setForCallback(boolean isCallback) {
+ this.isCallback = isCallback;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
new file mode 100644
index 0000000000..e25bd4206b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
@@ -0,0 +1,283 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * The assembly model object for an endpoint.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EndpointImpl implements Endpoint {
+ private static final long serialVersionUID = 7344399683703812593L;
+
+ protected transient ExtensionPointRegistry registry;
+ protected transient BuilderExtensionPoint builders;
+ protected transient ContractBuilder contractBuilder;
+ protected boolean unresolved;
+ protected String uri;
+ protected Component component;
+ protected ComponentService service;
+ protected Binding binding;
+ protected InterfaceContract interfaceContract;
+ protected List<EndpointReference> callbackEndpointReferences = new ArrayList<EndpointReference>();
+ protected List<PolicySet> policySets = new ArrayList<PolicySet>();
+ protected List<Intent> requiredIntents = new ArrayList<Intent>();
+ protected boolean remote = false;
+
+ protected EndpointImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Component getComponent() {
+ resolve();
+ return component;
+ }
+
+ public void setComponent(Component component) {
+ this.component = component;
+ reset();
+ }
+
+ public ComponentService getService() {
+ resolve();
+ return service;
+ }
+
+ public void setService(ComponentService service) {
+ this.service = service;
+ reset();
+ }
+
+ public Binding getBinding() {
+ resolve();
+ return binding;
+ }
+
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ reset();
+ }
+
+ public InterfaceContract getComponentServiceInterfaceContract() {
+ resolve();
+ if (interfaceContract == null && service != null) {
+ interfaceContract = service.getInterfaceContract();
+ }
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ }
+
+ /**
+ * Get the services callbacl enpoint references that
+ * represent endpoint references from which callbacks
+ * originate
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ public List<EndpointReference> getCallbackEndpointReferences() {
+ resolve();
+ return callbackEndpointReferences;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ resolve();
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ resolve();
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ getBinding();
+ if (binding instanceof PolicySubject) {
+ return ((PolicySubject)binding).getExtensionType();
+ }
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String toStringWithoutHash() {
+ String output = "Endpoint: ";
+
+ if (getURI() != null) {
+ output += " URI = " + getURI();
+ }
+
+ if (unresolved) {
+ output += " [Unresolved]";
+ }
+
+ return output;
+ }
+
+ public String toString() {
+ return "(@" + this.hashCode() + ")" + toStringWithoutHash();
+ }
+
+ public String getURI() {
+ if (uri == null) {
+ if (component != null && service != null && binding != null) {
+ String bindingName = binding.getName();
+ if (bindingName == null) {
+ bindingName = service.getName();
+ }
+ uri = component.getURI() + "#service-binding(" + service.getName() + "/" + bindingName + ")";
+ } else if (component != null && service != null) {
+ uri = component.getURI() + "#service(" + service.getName() + ")";
+ } else if (component != null) {
+ uri = component.getURI();
+ }
+ }
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ protected void resolve() {
+ }
+
+ protected void reset() {
+ this.uri = null;
+ }
+
+ protected void setExtensionPointRegistry(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public boolean isRemote() {
+ return remote;
+ }
+
+ public void setRemote(boolean remote) {
+ this.remote = remote;
+ }
+
+ public boolean matches(String serviceURI) {
+ String[] parts1 = parseServiceURI(serviceURI);
+ String[] parts2 = parseStructuralURI(getURI());
+ for (int i = 0; i < parts1.length; i++) {
+ if (parts1[i] == null || parts1[i].equals(parts2[i])) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Parse the service URI into an array of names. The service URI is in one of the following formats:
+ * <ul>
+ * <li>componentName
+ * <li>componentName/serviceName
+ * <li>componentName/serviceName/bindingName
+ * </ul>
+ * @param serviceURI
+ * @return
+ */
+ private static String[] parseServiceURI(String serviceURI) {
+ if (serviceURI.startsWith("/")) {
+ serviceURI = serviceURI.substring(1);
+ }
+ if (serviceURI.contains("#")) {
+ return parseStructuralURI(serviceURI);
+ }
+ String[] names = new String[3];
+ String[] segments = serviceURI.split("/");
+ for (int i = 0; i < names.length && i < segments.length; i++) {
+ names[i] = segments[i];
+ }
+ return names;
+ }
+
+ /**
+ * Parse the structural URI into an array of parts (componentURI, serviceName, bindingName)
+ * @param structuralURI
+ * @return [0]: componentURI [1]: serviceName [2]: bindingName
+ */
+ private static String[] parseStructuralURI(String structuralURI) {
+ String[] names = new String[3];
+ int index = structuralURI.lastIndexOf('#');
+ if (index == -1) {
+ names[0] = structuralURI;
+ } else {
+ names[0] = structuralURI.substring(0, index);
+ String str = structuralURI.substring(index + 1);
+ if (str.startsWith("service-binding(") && str.endsWith(")")) {
+ str = str.substring("service-binding(".length(), str.length() - 1);
+ String[] parts = str.split("/");
+ if (parts.length != 2) {
+ throw new IllegalArgumentException("Invalid service-binding URI: " + structuralURI);
+ }
+ names[1] = parts[0];
+ names[2] = parts[1];
+ } else if (str.startsWith("service(") && str.endsWith(")")) {
+ str = str.substring("service(".length(), str.length() - 1);
+ // [rfeng] Deal with empty service name
+ if (!"".equals(str)) {
+ names[1] = str;
+ }
+ } else {
+ throw new IllegalArgumentException("Invalid structural URI: " + structuralURI);
+ }
+ }
+ return names;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java
new file mode 100644
index 0000000000..ac35b45678
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * The assembly model object for an endpoint.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EndpointReferenceImpl implements EndpointReference {
+ private static final long serialVersionUID = 8838066441709300972L;
+
+ protected transient ExtensionPointRegistry registry;
+ protected transient BuilderExtensionPoint builders;
+ protected transient ContractBuilder contractBuilder;
+ protected boolean unresolved = true;
+ protected String uri;
+ protected Component component;
+ protected ComponentReference reference;
+ protected Binding binding;
+ protected List<PolicySet> policySets = new ArrayList<PolicySet>();
+ protected List<Intent> requiredIntents = new ArrayList<Intent>();
+ protected InterfaceContract interfaceContract;
+ protected Status status = Status.NOT_CONFIGURED;
+
+ // the target of the endpoint reference
+ protected Endpoint targetEndpoint;
+
+ // callback endpoint that messages across this reference
+ // will be directed toward
+ protected Endpoint callbackEndpoint;
+
+ protected EndpointReferenceImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ EndpointReference cloned = (EndpointReference)super.clone();
+
+ if (targetEndpoint != null) {
+ cloned.setTargetEndpoint((Endpoint)targetEndpoint.clone());
+ }
+
+ return cloned;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Component getComponent() {
+ resolve();
+ return component;
+ }
+
+ public void setComponent(Component component) {
+ this.component = component;
+ reset();
+ }
+
+ public ComponentReference getReference() {
+ resolve();
+ return reference;
+ }
+
+ public void setReference(ComponentReference reference) {
+ this.reference = reference;
+ reset();
+ }
+
+ public Binding getBinding() {
+ resolve();
+ return binding;
+ }
+
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ reset();
+ }
+
+ public Endpoint getTargetEndpoint() {
+ resolve();
+ return targetEndpoint;
+ }
+
+ public void setTargetEndpoint(Endpoint targetEndpoint) {
+ this.targetEndpoint = targetEndpoint;
+ reset();
+ }
+
+ public InterfaceContract getComponentReferenceInterfaceContract() {
+ resolve();
+ if (interfaceContract == null && reference != null) {
+ interfaceContract = reference.getInterfaceContract();
+ }
+ return interfaceContract;
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ this.interfaceContract = interfaceContract;
+ reset();
+ }
+
+ public List<PolicySet> getPolicySets() {
+ resolve();
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ resolve();
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ getBinding();
+ if (binding instanceof PolicySubject) {
+ return ((PolicySubject)binding).getExtensionType();
+ }
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Endpoint getCallbackEndpoint() {
+ resolve();
+ return callbackEndpoint;
+ }
+
+ public void setCallbackEndpoint(Endpoint callbackEndpoint) {
+ this.callbackEndpoint = callbackEndpoint;
+ reset();
+ }
+
+ public String toStringWithoutHash() {
+ StringBuffer output = new StringBuffer("EndpointReference: ");
+
+ if (getURI() != null) {
+ output.append(" URI = ").append(getURI());
+ }
+
+ output.append(" ").append(status);
+
+ if (targetEndpoint != null) {
+ output.append(" Target = ").append(targetEndpoint);
+ }
+
+ return output.toString();
+ }
+
+ public String toString() {
+ return "(@" + this.hashCode() + ")" + toStringWithoutHash();
+ }
+
+ public String getURI() {
+ if (uri == null) {
+ if (component != null && reference != null && binding != null) {
+ String bindingName = binding.getName();
+ if (bindingName == null) {
+ bindingName = reference.getName();
+ }
+ uri = component.getURI() + "#reference-binding(" + reference.getName() + "/" + bindingName + ")";
+ } else if (component != null && reference != null) {
+ uri = component.getURI() + "#reference(" + reference.getName() + ")";
+ } else if (component != null) {
+ uri = component.getURI();
+ }
+ }
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ protected void resolve() {
+ }
+
+ protected void reset() {
+ this.uri = null;
+ }
+
+ public void setExtensionPointRegistry(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java
new file mode 100644
index 0000000000..340fa2854c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+
+/**
+ * Convenience base class for extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ExtensibleImpl extends BaseImpl implements Extensible {
+ private List<Object> extensions = new ArrayList<Object>();
+ private List<Extension> attributeExtensions = new ArrayList<Extension>();
+
+ /**
+ * Constructs a new base model object.
+ */
+ protected ExtensibleImpl() {
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public List<Extension> getAttributeExtensions() {
+ return attributeExtensions;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java
new file mode 100644
index 0000000000..e69eb4a771
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.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.assembly.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Extension;
+
+public class ExtensionImpl implements Extension {
+ private QName qName;
+ private Object value;
+ private boolean isAttribute = false;
+
+ public ExtensionImpl() {
+ }
+
+ public ExtensionImpl(QName qName, Object value, boolean isAttribute) {
+ this.qName = qName;
+ this.value = value;
+ this.isAttribute = isAttribute;
+ }
+
+ public QName getQName() {
+ return qName;
+ }
+
+ public void setQName(QName qName) {
+ this.qName = qName;
+ }
+
+ public <T> T getValue() {
+ return (T)value;
+ }
+
+ public <T> void setValue(T value) {
+ this.value = value;
+ }
+
+ public boolean isAttribute() {
+ return isAttribute;
+ }
+
+ public void setAttribute(boolean isAttribute) {
+ this.isAttribute = isAttribute;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
new file mode 100644
index 0000000000..f943438a9f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.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.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Base implementation class of Implementation model interface
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySubject {
+ protected QName type;
+ protected ExtensionType extensionType;
+ protected List<Operation> operations = new ArrayList<Operation>();
+
+ protected ImplementationImpl(QName type) {
+ super();
+ this.type = type;
+ }
+
+ public ExtensionType getExtensionType() {
+ return extensionType;
+ }
+
+ public void setExtensionType(ExtensionType extensionType) {
+ this.extensionType = extensionType;
+ }
+
+ public QName getType() {
+ return type;
+ }
+
+ public String toString() {
+ return String.valueOf(getType());
+ }
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ImplementationImpl impl = (ImplementationImpl)super.clone();
+ impl.operations = new ArrayList<Operation>();
+ for (Operation operation : operations) {
+ impl.operations.add((Operation)operation.clone());
+ }
+ return impl;
+ }
+
+ // Override the ComponentTypeImpl.hashCode()
+ @Override
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ // Override the ComponentTypeImpl.equals()
+ @Override
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java
new file mode 100644
index 0000000000..263af296b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PropertyImpl extends AbstractPropertyImpl implements Property, Cloneable {
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ /**
+ * Constructs a new property.
+ */
+ protected PropertyImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
new file mode 100644
index 0000000000..69d76f238d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceImpl extends AbstractReferenceImpl implements Reference, Cloneable {
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private boolean wiredByImpl;
+ private List<ComponentService> targets = new ArrayList<ComponentService>();
+ private Callback callback;
+ private boolean overridingBindings;
+ private List<EndpointReference> endpointReferences = new ArrayList<EndpointReference>();
+
+ /**
+ * Constructs a new reference.
+ */
+ protected ReferenceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ReferenceImpl clone = (ReferenceImpl)super.clone();
+ clone.bindings = new ArrayList<Binding>(bindings);
+ clone.targets = new ArrayList<ComponentService>(targets);
+ // clone the endpoint references themselves and set the reference pointer back to
+ // this new refrence
+ clone.endpointReferences = new ArrayList<EndpointReference>();
+
+ for (EndpointReference epr : endpointReferences) {
+ EndpointReference eprClone = (EndpointReference)epr.clone();
+ eprClone.setReference((ComponentReference)clone);
+ clone.endpointReferences.add(eprClone);
+ }
+ return clone;
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public <B> B getBinding(Class<B> bindingClass) {
+ for (Binding binding : bindings) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ return null;
+ }
+
+ public <B> B getCallbackBinding(Class<B> bindingClass) {
+ if (callback != null) {
+ for (Binding binding : callback.getBindings()) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isWiredByImpl() {
+ return wiredByImpl;
+ }
+
+ public void setWiredByImpl(boolean wiredByImpl) {
+ this.wiredByImpl = wiredByImpl;
+ }
+
+ public List<ComponentService> getTargets() {
+ return targets;
+ }
+
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+
+ /**
+ * By default return the interface contract for the reference
+ */
+ public InterfaceContract getInterfaceContract(Binding binding) {
+ return getInterfaceContract();
+ }
+
+ public List<EndpointReference> getEndpointReferences() {
+ return endpointReferences;
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public boolean isOverridingBindings() {
+ return overridingBindings;
+ }
+
+ public void setOverridingBindings(boolean overridingBindings) {
+ this.overridingBindings = overridingBindings;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java
new file mode 100644
index 0000000000..84e5825b50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+
+/**
+ * A factory for the SCA binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCABindingFactoryImpl implements SCABindingFactory {
+
+ public SCABindingFactoryImpl() {
+
+ }
+
+ public SCABinding createSCABinding() {
+ return new SCABindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java
new file mode 100644
index 0000000000..b42f3f929f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * The assembly mode object for an SCA binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCABindingImpl implements SCABinding, Extensible, PolicySubject {
+ private String name;
+ private String uri;
+ private List<Object> extensions = new ArrayList<Object>();
+ private List<Extension> attributeExtensions = new ArrayList<Extension>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private ExtensionType extensionType;
+
+ /**
+ * Constructs a new SCA binding.
+ */
+ protected SCABindingImpl() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Getters for the binding URI. The computed URI for the
+ * service that the reference is targeting or which the service represents
+ * depending on whether the biding is associated with a reference or
+ * service
+ *
+ * @return the binding URI
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public List<Extension> getAttributeExtensions() {
+ return attributeExtensions;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return extensionType;
+ }
+
+ public void setExtensionType(ExtensionType intentAttachPointType) {
+ this.extensionType = intentAttachPointType;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
new file mode 100644
index 0000000000..f8eb0fa6ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneable {
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private boolean overridingBindings;
+ private Callback callback;
+ private List<Endpoint> endpoints = new ArrayList<Endpoint>();
+ private boolean isJAXWSService = false;
+
+ /**
+ * Constructs a new service.
+ */
+ protected ServiceImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ServiceImpl clone = (ServiceImpl)super.clone();
+ clone.bindings = new ArrayList<Binding>();
+ clone.bindings.addAll(getBindings());
+ return clone;
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public <B> B getBinding(Class<B> bindingClass) {
+ for (Binding binding : bindings) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ return null;
+ }
+
+ public <B> B getCallbackBinding(Class<B> bindingClass) {
+ if (callback != null) {
+ for (Binding binding : callback.getBindings()) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ }
+ return null;
+ }
+
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+
+ /**
+ * By default return the interface contract for the service
+ */
+ public InterfaceContract getInterfaceContract(Binding binding) {
+ return getInterfaceContract();
+ }
+
+ public List<Endpoint> getEndpoints() {
+ return endpoints;
+ }
+
+ public boolean isOverridingBindings() {
+ return overridingBindings;
+ }
+
+ public void setOverridingBindings(boolean overridingBindings) {
+ this.overridingBindings = overridingBindings;
+ }
+
+ public boolean isJAXWSService() {
+ return isJAXWSService;
+ }
+
+ public void setJAXWSService(boolean isJAXWSService) {
+ this.isJAXWSService = isJAXWSService;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
new file mode 100644
index 0000000000..a4990f6a98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireImpl extends ExtensibleImpl implements Wire, Cloneable {
+ private ComponentReference source;
+ private ComponentService target;
+ private boolean replace;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ /**
+ * Constructs a new wire.
+ */
+ protected WireImpl() {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public ComponentReference getSource() {
+ return source;
+ }
+
+ public ComponentService getTarget() {
+ return target;
+ }
+
+ public void setSource(ComponentReference source) {
+ this.source = source;
+ }
+
+ public void setTarget(ComponentService target) {
+ this.target = target;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public boolean isReplace() {
+ return replace;
+ }
+
+ public void setReplace(boolean replace) {
+ this.replace = replace;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java
new file mode 100644
index 0000000000..156fd0af75
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.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.definitions;
+
+import org.apache.tuscany.sca.definitions.impl.DefinitionsImpl;
+
+/**
+ * Default Implementation of DefinitionsFactory
+ */
+public class DefaultDefinitionsFactory implements DefinitionsFactory {
+
+ public Definitions createDefinitions() {
+ return new DefinitionsImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
new file mode 100644
index 0000000000..9ae5e6f26f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
@@ -0,0 +1,92 @@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+
+
+/**
+ * Represents SCA Definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Definitions {
+ /**
+ * Returns the target namespace for this SCA Definition
+ * @return the target namespace
+ */
+ String getTargetNamespace();
+
+ /**
+ * Sets the target names for this SCA Definition.
+ *
+ * @param ns the target namespace for this SCA Definition
+ */
+ void setTargetNamespace(String ns);
+
+ /**
+ * Returns a list of domain wide Policy Intents
+ *
+ * @return a list of domain wide Policy Intents
+ */
+ List<Intent> getIntents();
+
+ /**
+ * Returns a list of domain wide PolicySets
+ *
+ * @return a list of domain wide PolicySets
+ */
+ List<PolicySet> getPolicySets();
+
+ /**
+ * Returns a list of domain wide Binding Types
+ *
+ * @return a list of domain wide Binding Types
+ */
+ List<BindingType> getBindingTypes();
+
+
+ /**
+ * Returns a list of domain wide Implementation Types
+ *
+ * @return a list of domain wide Implementation Types
+ */
+ List<ImplementationType> getImplementationTypes();
+
+ /**
+ * Returns a list of domain wide binding definition objects
+ *
+ * @return a list of domain wide binding definition objects
+ */
+ List<Binding> getBindings();
+
+ /**
+ * Returns a list of external attachments
+ * @return
+ */
+ List<ExternalAttachment> getExternalAttachments();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java
new file mode 100644
index 0000000000..5c68c6cbff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions;
+
+
+/**
+ * Interface to abstract building of SCA Definitions for a Domain
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DefinitionsBuilder {
+ /**
+ * Builds the SCA definitions
+ *
+ * @param scaDefns
+ */
+ void build(Definitions scaDefns) throws DefinitionsBuilderException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java
new file mode 100644
index 0000000000..f45be80888
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.definitions;
+
+/**
+ * Builder Exception
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsBuilderException extends Exception {
+ private static final long serialVersionUID = 2513219325230252783L;
+
+ public DefinitionsBuilderException() {
+ }
+
+ public DefinitionsBuilderException(String message) {
+ super(message);
+ }
+
+ public DefinitionsBuilderException(Throwable cause) {
+ super(cause);
+ }
+
+ public DefinitionsBuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java
new file mode 100644
index 0000000000..616616ae7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.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.sca.definitions;
+
+/**
+ * Factory interface to create SCA definitions model
+ *
+ */
+public interface DefinitionsFactory {
+ /**
+ * Create an instance of SCA definitions
+ * @return a new instance of SCA definitions
+ */
+ Definitions createDefinitions();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java
new file mode 100644
index 0000000000..d87d45b27a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.definitions.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.definitions.DefinitionsBuilder;
+import org.apache.tuscany.sca.definitions.DefinitionsBuilderException;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Provides a concrete implementation for a SCADefinitionsBuilder
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsBuilderImpl implements DefinitionsBuilder {
+
+ public void build(Definitions scaDefns) throws DefinitionsBuilderException {
+ Map<QName, Intent> definedIntents = new HashMap<QName, Intent>();
+ for (Intent intent : scaDefns.getIntents()) {
+ definedIntents.put(intent.getName(), intent);
+ }
+
+ Map<QName, PolicySet> definedPolicySets = new HashMap<QName, PolicySet>();
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ definedPolicySets.put(policySet.getName(), policySet);
+ }
+
+ Map<QName, BindingType> definedBindingTypes = new HashMap<QName, BindingType>();
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ definedBindingTypes.put(bindingType.getType(), bindingType);
+ }
+
+ Map<QName, ImplementationType> definedImplTypes = new HashMap<QName, ImplementationType>();
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ definedImplTypes.put(implType.getType(), implType);
+ }
+
+ //filling up the maps removes all duplicate entries... so fill this unique lists
+ //into the scaDefns.
+ scaDefns.getIntents().clear();
+ scaDefns.getPolicySets().clear();
+ scaDefns.getBindingTypes().clear();
+ scaDefns.getImplementationTypes().clear();
+
+ scaDefns.getIntents().addAll(definedIntents.values());
+ scaDefns.getPolicySets().addAll(definedPolicySets.values());
+ scaDefns.getBindingTypes().addAll(definedBindingTypes.values());
+ scaDefns.getImplementationTypes().addAll(definedImplTypes.values());
+
+ buildPolicyIntents(scaDefns, definedIntents);
+ buildPolicySets(scaDefns, definedPolicySets, definedIntents);
+ buildBindingTypes(scaDefns, definedBindingTypes, definedIntents);
+ buildImplementationTypes(scaDefns, definedImplTypes, definedIntents);
+ }
+
+ private void buildBindingTypes(Definitions scaDefns,
+ Map<QName, BindingType> definedBindingTypes,
+ Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ buildAlwaysProvidedIntents(bindingType, definedIntents);
+ buildMayProvideIntents(bindingType, definedIntents);
+ }
+
+ }
+
+ private void buildImplementationTypes(Definitions scaDefns,
+ Map<QName, ImplementationType> definedImplTypes,
+ Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ buildAlwaysProvidedIntents(implType, definedIntents);
+ buildMayProvideIntents(implType, definedIntents);
+ }
+ }
+
+ private void buildPolicyIntents(Definitions scaDefns, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ for (Intent policyIntent : scaDefns.getIntents()) {
+ if (!policyIntent.getRequiredIntents().isEmpty()) {
+ buildProfileIntent(policyIntent, definedIntents);
+ }
+
+ if (!policyIntent.getQualifiedIntents().isEmpty()) {
+ buildQualifiedIntent(policyIntent, definedIntents);
+ }
+ }
+ }
+
+ private void buildPolicySets(Definitions scaDefns,
+ Map<QName, PolicySet> definedPolicySets,
+ Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ buildProvidedIntents(policySet, definedIntents);
+ buildIntentsInMappedPolicies(policySet, definedIntents);
+ buildReferredPolicySets(policySet, definedPolicySets);
+ }
+
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(policySet, referredPolicySet);
+ }
+ }
+ }
+
+ private void buildProfileIntent(Intent policyIntent, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ //FIXME: Need to check for cyclic references first i.e an A requiring B and then B requiring A...
+ if (policyIntent != null) {
+ //resolve all required intents
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
+ if (requiredIntent.isUnresolved()) {
+ Intent resolvedRequiredIntent = definedIntents.get(requiredIntent.getName());
+ if (resolvedRequiredIntent != null) {
+ requiredIntents.add(resolvedRequiredIntent);
+ } else {
+ throw new DefinitionsBuilderException("Required Intent - " + requiredIntent
+ + " not found for ProfileIntent "
+ + policyIntent);
+
+ }
+ } else {
+ requiredIntents.add(requiredIntent);
+ }
+ }
+ policyIntent.getRequiredIntents().clear();
+ policyIntent.getRequiredIntents().addAll(requiredIntents);
+ }
+ }
+
+ private void buildQualifiedIntent(Intent policyIntent, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ /*
+ if (policyIntent != null) {
+ //resolve the qualifiable intent
+ Intent qualifiableIntent = policyIntent.getQualifiableIntent();
+ if (qualifiableIntent.isUnresolved()) {
+ Intent resolvedQualifiableIntent = definedIntents.get(qualifiableIntent.getName());
+
+ if (resolvedQualifiableIntent != null) {
+ policyIntent.setQualifiableIntent(resolvedQualifiableIntent);
+ } else {
+ throw new DefinitionsBuilderException("Qualifiable Intent - " + qualifiableIntent
+ + " not found for QualifiedIntent "
+ + policyIntent);
+ }
+
+ }
+ }
+ */
+ }
+
+ private void buildAlwaysProvidedIntents(ExtensionType extensionType, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> alwaysProvided = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getAlwaysProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName());
+ if (resolvedProvidedIntent != null) {
+ alwaysProvided.add(resolvedProvidedIntent);
+ } else {
+ throw new DefinitionsBuilderException("Always Provided Intent - " + providedIntent
+ + " not found for ExtensionType "
+ + extensionType);
+
+ }
+ } else {
+ alwaysProvided.add(providedIntent);
+ }
+ }
+ extensionType.getAlwaysProvidedIntents().clear();
+ extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
+ }
+ }
+
+ private void buildMayProvideIntents(ExtensionType extensionType, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> mayProvide = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getMayProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName());
+ if (resolvedProvidedIntent != null) {
+ mayProvide.add(resolvedProvidedIntent);
+ } else {
+ throw new DefinitionsBuilderException("May Provide Intent - " + providedIntent
+ + " not found for ExtensionType "
+ + extensionType);
+
+ }
+ } else {
+ mayProvide.add(providedIntent);
+ }
+ }
+ extensionType.getMayProvidedIntents().clear();
+ extensionType.getMayProvidedIntents().addAll(mayProvide);
+ }
+ }
+
+ private void buildProvidedIntents(PolicySet policySet, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ if (policySet != null) {
+ //resolve all provided intents
+ List<Intent> providedIntents = new ArrayList<Intent>();
+ for (Intent providedIntent : policySet.getProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName());
+ if (resolvedProvidedIntent != null) {
+ providedIntents.add(resolvedProvidedIntent);
+ } else {
+ throw new DefinitionsBuilderException("Provided Intent - " + providedIntent
+ + " not found for PolicySet "
+ + policySet);
+
+ }
+ } else {
+ providedIntents.add(providedIntent);
+ }
+ }
+ policySet.getProvidedIntents().clear();
+ policySet.getProvidedIntents().addAll(providedIntents);
+ }
+ }
+
+ private void buildIntentsInMappedPolicies(PolicySet policySet, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
+ for (IntentMap intentMap : policySet.getIntentMaps()) {
+ for (Qualifier qualifier : intentMap.getQualifiers()) {
+ Intent mappedIntent = qualifier.getIntent();
+ if (mappedIntent.isUnresolved()) {
+ Intent resolvedMappedIntent = definedIntents.get(mappedIntent.getName());
+
+ if (resolvedMappedIntent != null) {
+ qualifier.setIntent(resolvedMappedIntent);
+ } else {
+ throw new DefinitionsBuilderException("Mapped Intent - " + mappedIntent
+ + " not found for PolicySet "
+ + policySet);
+
+ }
+ }
+ }
+ }
+ }
+
+ private void buildReferredPolicySets(PolicySet policySet, Map<QName, PolicySet> definedPolicySets)
+ throws DefinitionsBuilderException {
+
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+ for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
+ if (referredPolicySet.isUnresolved()) {
+ PolicySet resolvedReferredPolicySet = definedPolicySets.get(referredPolicySet.getName());
+ if (resolvedReferredPolicySet != null) {
+ referredPolicySets.add(resolvedReferredPolicySet);
+ } else {
+ throw new DefinitionsBuilderException("Referred PolicySet - " + referredPolicySet
+ + "not found for PolicySet - "
+ + policySet);
+ }
+ } else {
+ referredPolicySets.add(referredPolicySet);
+ }
+ }
+ policySet.getReferencedPolicySets().clear();
+ policySet.getReferencedPolicySets().addAll(referredPolicySets);
+ }
+
+ private void includeReferredPolicySets(PolicySet policySet, PolicySet referredPolicySet) {
+ for (PolicySet furtherReferredPolicySet : referredPolicySet.getReferencedPolicySets()) {
+ includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
+ }
+ policySet.getPolicies().addAll(referredPolicySet.getPolicies());
+ policySet.getIntentMaps().addAll(referredPolicySet.getIntentMaps());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
new file mode 100644
index 0000000000..e58261cda2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.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.definitions.impl;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Provides a concrete implementation for SCADefinitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsImpl implements Definitions {
+ private String targetNamespace = null;
+ private List<Intent> intents = new CopyOnWriteArrayList<Intent>();
+ private List<PolicySet> policySets = new CopyOnWriteArrayList<PolicySet>();
+ private List<BindingType> bindingTypes = new CopyOnWriteArrayList<BindingType>();
+ private List<ImplementationType> implementationTypes = new CopyOnWriteArrayList<ImplementationType>();
+ private List<Binding> bindings = new CopyOnWriteArrayList<Binding>();
+ private List<ExternalAttachment> externalAttachments = new CopyOnWriteArrayList<ExternalAttachment>();
+
+
+ public List<BindingType> getBindingTypes() {
+ return bindingTypes;
+ }
+
+ public List<ImplementationType> getImplementationTypes() {
+ return implementationTypes;
+ }
+
+ public List<Intent> getIntents() {
+ return intents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String ns) {
+ this.targetNamespace = ns;
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public List<ExternalAttachment> getExternalAttachments() {
+ return externalAttachments ;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
new file mode 100644
index 0000000000..452c3bf883
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.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.sca.definitions.util;
+
+import static org.apache.tuscany.sca.assembly.builder.Messages.DEFINITIONS_VALIDATION;
+
+import java.util.HashSet;
+
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Some utility functions to deal with SCADefinitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsUtil {
+
+ /**
+ * Add the source set of definitions into the target set of definitions checking that
+ * definitions artifacts are unique in the process
+ *
+ * @param source the input definitions collection
+ * @param target the definition collection into which source will aggregated
+ */
+ public static void aggregate(Definitions source, Definitions target, Monitor monitor) {
+
+ HashSet<Intent> intents = new HashSet<Intent>(target.getIntents());
+ for(Intent intent : source.getIntents()){
+ if (intents.contains(intent)){
+ Monitor.error(monitor,
+ target,
+ DEFINITIONS_VALIDATION,
+ "DuplicateIntent",
+ intent.getName().toString());
+ } else {
+ target.getIntents().add(intent);
+ intents.add(intent);
+ }
+ }
+
+ HashSet<PolicySet> policySets = new HashSet<PolicySet>(target.getPolicySets());
+ for(PolicySet policySet : source.getPolicySets()){
+ if (policySets.contains(policySet)){
+ Monitor.error(monitor,
+ target,
+ DEFINITIONS_VALIDATION,
+ "DuplicatePolicySet",
+ policySet.getName().toString());
+ } else {
+ target.getPolicySets().add(policySet);
+ policySets.add(policySet);
+ }
+ }
+
+ HashSet<BindingType> bindingTypes = new HashSet<BindingType>(target.getBindingTypes());
+ for(BindingType bindingType : source.getBindingTypes()){
+ if (bindingTypes.contains(bindingType)){
+ Monitor.error(monitor,
+ target,
+ DEFINITIONS_VALIDATION,
+ "DuplicateBindingType",
+ bindingType.getType().toString());
+ } else {
+ target.getBindingTypes().add(bindingType);
+ bindingTypes.add(bindingType);
+ }
+ }
+
+ HashSet<ImplementationType> implementationTypes = new HashSet<ImplementationType>(target.getImplementationTypes());
+ for(ImplementationType implementationType : source.getImplementationTypes()){
+ if (implementationTypes.contains(implementationType)){
+ Monitor.error(monitor,
+ target,
+ DEFINITIONS_VALIDATION,
+ "DuplicateImplementationType",
+ implementationType.getType().toString());
+ } else {
+ target.getImplementationTypes().add(implementationType);
+ implementationTypes.add(implementationType);
+ }
+ }
+
+ target.getBindings().addAll(source.getBindings());
+
+ target.getExternalAttachments().addAll(source.getExternalAttachments());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Compatibility.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Compatibility.java
new file mode 100644
index 0000000000..e05a05476a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Compatibility.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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;
+
+/**
+ * Types of compatibility
+ */
+public enum Compatibility {
+ SUPERSET, // The source is a superset of the target
+ SUBSET, // The source is a subset of the target
+ MUTUAL, // The source is the same set as the target
+ INCOMPATIBLE // The source is not compatible with the target
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java
new file mode 100644
index 0000000000..386275b41b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+import java.lang.reflect.Type;
+
+/**
+ * Representation of the type of data associated with an operation. Data is
+ * represented in two forms: the physical form used by the runtime and a logical
+ * form used by the assembly. The physical form is a Java Type because the
+ * runtime is written in Java. This may be the same form used by the application
+ * but it may not; for example, an application that is performing stream
+ * processing may want a physical form such as an
+ * {@link java.io.InputStream InputStream} to semantically operate on application
+ * data such as a purchase order. The logical description is that used by the
+ * assembly model and is an identifier into some well-known type space; examples
+ * may be a Java type represented by its Class or an XML type represented by its
+ * QName. Every data type may also contain metadata describing the expected
+ * data; for example, it could specify a preferred data binding technology or
+ * the size of a typical instance.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface DataType<L> extends Cloneable {
+ /**
+ * Set the java type for the data
+ * @param cls
+ */
+ void setPhysical(Class<?> cls);
+
+ /**
+ * Returns the physical type used by the runtime.
+ *
+ * @return the physical type used by the runtime
+ */
+ Class<?> getPhysical();
+
+ /**
+ * Get the java generic type
+ * @return The java generic type
+ */
+ Type getGenericType();
+
+ /**
+ * Set the java generic type
+ * @param genericType
+ */
+ void setGenericType(Type genericType);
+
+ /**
+ * Returns the logical identifier used by the assembly. The type of this
+ * value identifies the logical type system in use. Known values are:
+ * <ul>
+ * <li>a Class identifies a Java type by name and
+ * ClassLoader; this includes Java Classes as they are specializations of
+ * Type</li>
+ * <li>a XMLType identifies an XML type by local name and
+ * namespace</li>
+ * </ul>
+ *
+ * @return the logical type name
+ */
+ L getLogical();
+
+ /**
+ * Get the databinding for the given data type
+ * @return the databinding
+ */
+ String getDataBinding();
+
+ /**
+ * Set the databinding for the given data type
+ * @param dataBinding the dataBinding to set
+ */
+ void setDataBinding(String dataBinding);
+
+ /**
+ * Clone a data type
+ * @return The cloned data type
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Set the logical type of the data type
+ * @param logical the logical to set
+ */
+ void setLogical(L logical);
+
+ /**
+ * Get the databinding-specific metadata
+ * @param type The java type of the metadata
+ * @return the databinding-specific metadata
+ */
+ <T> T getMetaData(Class<T> type);
+ /**
+ * Set the databinding-specific metadata
+ * @param type The java type of the metadata
+ * @param metaData the databinding-specific metadata, such as SDO's commonj.sdo.Type or
+ * JAXB's javax.xml.bind.JAXBContext
+ */
+ <T> void setMetaData(Class<T> type, T metaData);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java
new file mode 100644
index 0000000000..4aa5f2780a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.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.sca.interfacedef;
+
+/**
+ * This interface represents the mapping between WSDL faults and Java exceptions
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+@SuppressWarnings("unchecked")
+public interface FaultExceptionMapper {
+ /**
+ * Introspect an exception class to find out the fault data type following the WSDL2Java
+ * mapping rules. The result will be populated into the logical type of the exception data
+ * type
+ *
+ * @param exceptionDataType The data type representing a java exception class
+ * @param operation TODO
+ * @param generatingFaultBean If JAXWS Section 3.7 Fault Bean will be generated
+ * @return true if the introspection can recognize the exception data type
+ */
+ boolean introspectFaultDataType(DataType<DataType> exceptionDataType, Operation operation, boolean generatingFaultBean);
+
+ /**
+ * Create a java exception to wrap the fault data
+ *
+ * @param exceptionType The DataType for the exception
+ * @param message message for the exception
+ * @param faultInfo The fault data
+ * @param cause of the exception
+ * @param operation TODO
+ * @return An instance of java exception to represent the fault
+ */
+ Throwable wrapFaultInfo(DataType<DataType> exceptionType, String message, Object faultInfo, Throwable cause, Operation operation);
+
+ /**
+ * Retrieve the fault info from a java exception
+ *
+ * @param exception The java exception that represents the fault data
+ * @param faultBeanClass
+ * @param operation TODO
+ * @return The fault data
+ */
+ Object getFaultInfo(Throwable exception, Class<?> faultBeanClass, Operation operation);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java
new file mode 100644
index 0000000000..179dc1755e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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;
+
+/**
+ * Denotes incompatible service contracts for a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class IncompatibleInterfaceContractException extends Exception {
+ private static final long serialVersionUID = 5127478601823295587L;
+ private final InterfaceContract source;
+ private final InterfaceContract target;
+ private final Operation sourceOperation;
+ private final Operation targetOperation;
+
+ public IncompatibleInterfaceContractException(String message, InterfaceContract source, InterfaceContract target) {
+ super(message);
+ this.source = source;
+ this.target = target;
+ this.sourceOperation = null;
+ this.targetOperation = null;
+ }
+
+ public IncompatibleInterfaceContractException(String message,
+ InterfaceContract source,
+ InterfaceContract target,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ super(message);
+ this.source = source;
+ this.target = target;
+ this.sourceOperation = sourceOperation;
+ this.targetOperation = targetOperation;
+ }
+
+ public InterfaceContract getTarget() {
+ return target;
+ }
+
+ public InterfaceContract getSource() {
+ return source;
+ }
+
+ public Operation getSourceOperation() {
+ return sourceOperation;
+ }
+
+ public Operation getTargetOperation() {
+ return targetOperation;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
new file mode 100644
index 0000000000..e3103b768a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.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.sca.interfacedef;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents a service interface. This interface will typically be extended to
+ * support concrete interface type systems, such as Java interfaces, WSDL 1.1
+ * portTypes and WSDL 2.0 interfaces.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Interface extends Cloneable, PolicySubject {
+
+ /**
+ * Returns true if the interface is a remotable interface..
+ *
+ * @return true if the interface is a remotable interface
+ */
+ boolean isRemotable();
+
+ /**
+ * Sets whether the interface is a remotable or local interface.
+ *
+ * @param remotable indicates whether the interface is remotable or local
+ */
+ void setRemotable(boolean remotable);
+
+ /**
+ * Returns true if the interface remotable property is set..
+ *
+ * This is used to verify if a @remotable attribute is used in the
+ * <interface.java> SCDL element. If true, use isRemotable to verify the
+ * current value
+ *
+ * @return
+ */
+ boolean isRemotableSet();
+
+ /**
+ * Returns the operations defined on this interface.
+ *
+ * @return the operations defined on this interface
+ */
+ List<Operation> getOperations();
+
+ /**
+ * Set the databinding for the interface
+ * @param dataBinding
+ * @deprecated Please use resetDataBinding
+ */
+ @Deprecated
+ void setDefaultDataBinding(String dataBinding);
+
+ /**
+ * Reset the databinding for the interface
+ * @param dataBinding
+ */
+ void resetDataBinding(String dataBinding);
+
+ /**
+ * Set the interface input types by copying those from the
+ * interface provided
+ *
+ * @param newInterface
+ */
+ public void resetInterfaceInputTypes(Interface newInterface);
+
+ /**
+ * Set the interface output types by copying those from the
+ * interface provided
+ *
+ * @param newInterface
+ */
+ public void resetInterfaceOutputTypes(Interface newInterface);
+
+ /**
+ * Returns true if the Interface is dynamic.
+ *
+ * @return true if the Interface is dynamic.
+ */
+ boolean isDynamic();
+
+ /**
+ * Get a map of attributes associated with the interface
+ * @return A map of attributes
+ */
+ Map<Object, Object> getAttributes();
+
+ /**
+ * Implementations must support cloning.
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
new file mode 100644
index 0000000000..3eda9f37e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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;
+
+
+/**
+ * Interface contracts define one or more business functions. These business
+ * functions are provided by services and are used by references.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface InterfaceContract extends Cloneable {
+
+ /**
+ * Returns the interface definition representing the interface for
+ * invocations from the requestor to the provider.
+ *
+ * @return the interface definition representing the interface for
+ * invocations from the requestor to the provider
+ */
+ Interface getInterface();
+
+ /**
+ * Sets the interface definition representing the interface for invocations
+ * from the requestor to the provider.
+ *
+ * @param callInterface the interface definition representing the interface
+ * for invocations from the requestor to the provider
+ */
+ void setInterface(Interface callInterface);
+
+ /**
+ * Returns the interface definition representing the interface for
+ * invocations from the provider to the requestor.
+ *
+ * @return the interface definition representing the interface for
+ * invocations from the provider to the requestor.
+ */
+ Interface getCallbackInterface();
+
+ /**
+ * Sets the interface definition representing the interface for invocations
+ * from the provider to the requestor.
+ *
+ * @param callbackInterface the interface definition representing the
+ * interface for invocations from the provider to the requestor.
+ */
+ void setCallbackInterface(Interface callbackInterface);
+
+ // FIXME: We need a better way to do this
+ /**
+ * Convert an interface contract to a unidirectional interface contract
+ *
+ * @param isCallback true for a callback interface contract, false for
+ * a forward interface contract
+ * @return A unidirectional interface contract, cloned if necessary
+ */
+ InterfaceContract makeUnidirectional(boolean isCallback);
+
+ /**
+ * Implementations must support cloning.
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ /**
+ * For matching purposes the Java interface contract is
+ * turned into a WSDL contract in the cases where it needs to be matched
+ * against another WSDL contract
+ *
+ * @return WSDL interface contract
+ */
+ InterfaceContract getNormalizedWSDLContract();
+
+ /**
+ * For matching purposes the Java interface contract is
+ * turned into a WSDL contract in the cases where it needs to be matched
+ * against another WSDL contract
+ *
+ * @param wsdlInterfaceContract
+ */
+ void setNormailizedWSDLContract(InterfaceContract wsdlInterfaceContract);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
new file mode 100644
index 0000000000..94bce6d6b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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;
+
+import org.apache.tuscany.sca.interfacedef.util.Audit;
+
+/**
+ * The InterfaceContractMapper is responsible to match interfaces
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface InterfaceContractMapper {
+ /**
+ * @param source The source interface contract
+ * @param target The target interface contract
+ * @param compatibility The compatibility style
+ * @param ignoreCallback
+ * @param silent
+ * @return
+ * @throws IncompatibleInterfaceContractException
+ */
+ boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent) throws IncompatibleInterfaceContractException;
+
+ /**
+ * @param source The source interface contract
+ * @param target The target interface contract
+ * @param compatibility The compatibility style
+ * @param ignoreCallback
+ * @param silent
+ * @return
+ * @throws IncompatibleInterfaceContractException
+ * this interface is intended to incrementally replace the variant without the audit trail
+ * the presence of both interfaces implies a state of partial development
+ */
+ boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent,
+ Audit audit) throws IncompatibleInterfaceContractException;
+
+ /**
+ * Test if the source data type is compatible with the target data type. The
+ * compatibility is defined as follows.
+ * <ul>
+ * <li>source's logical type is either the same or subtype of the target's
+ * logical type
+ * </ul>
+ * For example, if the source type is a SDO Customer and the target type is
+ * a JAXB Customer and both Customer are generated from the same XSD type.
+ *
+ * @param source The source data type
+ * @param target The target data type
+ * @param passByValue A flag to indicate how the compatibility is checked
+ * <ul>
+ * <li>true: Check the two types as compatible "by-value" (can be copied)
+ * <li>false: Check the two types as compatible "by-reference" (can be assigned)
+ * </ul>
+ * @return true if the source data type is the same or subtype of the target data type
+ */
+ boolean isCompatible(DataType<?> source, DataType<?> target, boolean passByValue);
+
+ /**
+ * Check if source operation is compatible with the target operation. A source operation is
+ * compatible with the target operation means the following:
+ *
+ * <ol>
+ * <li>compatibility for the two operations is defined as compatibility
+ * of the signature, i.e., the operation name, the input types, and the output types are the same
+ *
+ * <li>the order of the input and output types of the source operation is the same as the order of
+ * the input and output types for the corresponding target operation
+ * <li>the set of Faults and Exceptions expected by the source operation is the same as or is
+ * a SUPERSET of the set of Faults and Exceptions specified by the corresponding target operation
+ * </ol>
+ *
+ * Simply speaking, any request from the source operation can be processed by the target operation and
+ * the normal response or fault/exception from the target operation can be handled by the source operation.
+ *
+ * Please note this compatibility check is NOT symmetric. But the following should be guaranteed:
+ * <ul>
+ * <li>(source, target, SUB) == (target, source, SUPER)
+ * <li>(source, target, MUTUAL) == (source, target, SUB) && (target, source, SUB) == (source, target, SUPER) && (source, target, SUPER)
+ *
+ * @param source The source operation
+ * @param target The target operation
+ * @param compatibilityType The type of compatibility
+ * @return true if the source operation is compatible with the target
+ * operation
+ */
+ boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType);
+
+ boolean isCompatibleByReference(Operation source, Operation target, Compatibility compatibilityType);
+ boolean isCompatibleByValue(Operation source, Operation target, Compatibility compatibilityType);
+
+ /**
+ * An interface A is a Compatible Subset of a second interface B if and only if all of points 1 through 6
+ * in the following list apply:
+ * <ol>
+ * <li>interfaces A and B are either both remotable or else both local
+ * <li>the set of operations in interface A is the same as or is a subset of the set of operations in
+ * interface B
+ * <li>compatibility for individual operations of the interfaces A and B is defined as compatibility
+ * of the signature, i.e., the operation name, the input types, and the output types are the same
+ * <li>the order of the input and output types for each operation in interface A is the same as the
+ * order of the input and output types for the corresponding operation in interface B
+ * <li>the set of Faults and Exceptions expected by each operation in interface A is the same as or is
+ * a superset of the set of Faults and Exceptions specified by the corresponding operation in interface B
+ * <li>for checking the compatibility of 2 remotable interfaces which are in different interface
+ * languages, both are mapped to WSDL 1.1 (if not already WSDL 1.1) and compatibility checking is done
+ * between the WSDL 1.1 mapped interfaces.<br>
+ * For checking the compatibility of 2 local interfaces which are in different interface languages, the
+ * method of checking compatibility is defined by the specifications which define those interface types,
+ * which must define mapping rules for the 2 interface types concerned.
+ *
+ * </ol>
+ *
+ * <b>The callback interfaces are not considered her.</b>
+ *
+ * @param source The source interface
+ * @param target The target interface
+ * @return true if the source interface is a compatible subset of the target interface
+ */
+ boolean isCompatibleSubset(Interface source, Interface target);
+
+ /**
+ * An interface A is a Compatible Subset of a second interface B if and only if all of points 1 through 7
+ * in the following list apply:
+ * <ol>
+ * <li>interfaces A and B are either both remotable or else both local
+ * <li>the set of operations in interface A is the same as or is a subset of the set of operations in
+ * interface B
+ * <li>compatibility for individual operations of the interfaces A and B is defined as compatibility
+ * of the signature, i.e., the operation name, the input types, and the output types are the same
+ * <li>the order of the input and output types for each operation in interface A is the same as the
+ * order of the input and output types for the corresponding operation in interface B
+ * <li>the set of Faults and Exceptions expected by each operation in interface A is the same as or is
+ * a superset of the set of Faults and Exceptions specified by the corresponding operation in interface B
+ * <li>for checking the compatibility of 2 remotable interfaces which are in different interface
+ * languages, both are mapped to WSDL 1.1 (if not already WSDL 1.1) and compatibility checking is done
+ * between the WSDL 1.1 mapped interfaces.<br>
+ * For checking the compatibility of 2 local interfaces which are in different interface languages, the
+ * method of checking compatibility is defined by the specifications which define those interface types,
+ * which must define mapping rules for the 2 interface types concerned.
+ * <li>if either interface A or interface B declares a callback interface then both interface
+ * A and interface B declare callback interfaces and the callback interface declared on interface B is a
+ * compatible subset of the callback interface declared on interface A, according to points 1 through 6
+ * above
+ * </ol>
+ *
+ * @param source The source interface contract
+ * @param target The target interface contract
+ * @return true if the source interface contract is a compatible subset of the target interface contract
+ */
+ boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target);
+ /*
+ * the variant of isCompatibleSubset with the audit parameter is intended to supersed the other
+ * -- the presence of both indicates a partial development state
+ */
+ boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target, Audit audit);
+
+ /**
+ * Check that two interfaces are mutually compatible. The interfaces are mutually compatible if the two
+ * interfaces have the same set of operations, with each operation having the same signature (name, input
+ * types, output types and fault/exception types).
+ *
+ * @param source an interface
+ * @param target a second interface
+ * @return true if the two interfaces are mutually compatible, otherwise return false
+ */
+ public boolean isMutuallyCompatible(Interface source, Interface target);
+
+ /**
+ * An interface A is Compatible with a second interface B if and only if all of points 1 through 7 in the
+ * following list apply:<p>
+ * <ol>
+ * <li>interfaces A and B are either both remotable or else both local
+ * <li>the set of operations in interface A is the same as the set of operations in interface B
+ * <li>compatibility for individual operations of the interfaces A and B is defined as compatibility
+ * of the signature, i.e., the operation name, the input types, and the output types are the same
+ * <li>the order of the input and output types for each operation in interface A is the same as the
+ * order of the input and output types for the corresponding operation in interface B
+ * <li>the set of Faults and Exceptions expected by each operation in interface A is the
+ * same as the set of Faults and Exceptions specified by the corresponding operation in interface B
+ * <li>for checking the compatibility of 2 remotable interfaces which are in different interface
+ * languages, both are mapped to WSDL 1.1 (if not already WSDL 1.1) and compatibility checking is done
+ * between the WSDL 1.1 mapped interfaces.
+ * <br>For checking the compatibility of 2 local interfaces which are in different interface languages,
+ * the method of checking compatibility is defined by the specifications which define those interface types,
+ * which must define mapping rules for the 2 interface types concerned.
+ * <li>if either interface A or interface B declares a callback interface then both interface
+ * A and interface B declare callback interfaces and the callback interface declared on interface A is
+ * compatible with the callback interface declared on interface B, according to points 1 through 6 above
+ *
+ * @param source - the source interface contract
+ * @param target - the target interface contract
+ * @return true if the source and target interface contracts are mutually compatible
+ */
+ boolean isMutuallyCompatible(InterfaceContract source, InterfaceContract target);
+
+ /**
+ * Map the source operation to a compatible operation in the target interface
+ *
+ * @param target The target interface
+ * @param source The source operation
+ * @return A compatible operation if the target interface is compatible superset of the source interface
+ */
+ Operation map(Interface target, Operation source);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java
new file mode 100644
index 0000000000..db1d5f7fd7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public class InvalidAnnotationException extends InvalidInterfaceException {
+
+ private static final long serialVersionUID = 4923028138353415223L;
+ private final Class<?> clazz;
+
+ public InvalidAnnotationException(String message, Class<?> clazz) {
+ super(message);
+ this.clazz = clazz;
+ }
+
+ public Class<?> getAnnotation() {
+ return clazz;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java
new file mode 100644
index 0000000000..392e81a8fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.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 org.apache.tuscany.sca.interfacedef;
+
+
+/**
+ * Denotes an illegal callback interface
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+
+public class InvalidCallbackException extends InvalidInterfaceException {
+ private static final long serialVersionUID = 2727755895702116397L;
+
+ public InvalidCallbackException(String message) {
+ super(message);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java
new file mode 100644
index 0000000000..0cac606e1a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class InvalidInterfaceException extends Exception {
+ private static final long serialVersionUID = -3850574026273544538L;
+
+ public InvalidInterfaceException() {
+ super();
+ }
+
+ public InvalidInterfaceException(String message) {
+ super(message);
+ }
+
+ public InvalidInterfaceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidInterfaceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java
new file mode 100644
index 0000000000..2e82c201d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+import java.lang.reflect.Method;
+
+/**
+ * Denotes an invalid conversational interface definition
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class InvalidOperationException extends InvalidInterfaceException {
+
+ private static final long serialVersionUID = -1797615361821517091L;
+ private final Method operation;
+
+ public InvalidOperationException(String message, Method operation) {
+ super(message);
+ this.operation = operation;
+ }
+
+ public Method getOperation() {
+ return operation;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
new file mode 100644
index 0000000000..c71225c9e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Represents an operation on a service interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Operation extends Cloneable, PolicySubject {
+ /**
+ * Returns the name of the operation.
+ *
+ * @return the name of the operation
+ */
+ String getName();
+
+ /**
+ * Sets the name of the operation.
+ *
+ * @param name the name of the operation
+ */
+ void setName(String name);
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ /**
+ * Get the data type that represents the input of this operation. The logic
+ * type is a list of data types and each element represents a parameter
+ *
+ * @return the inputType
+ */
+ DataType<List<DataType>> getInputType();
+
+ /**
+ * @param inputType
+ */
+ void setInputType(DataType<List<DataType>> inputType);
+
+ /**
+ * Get the data type for the output
+ *
+ * @return the outputType
+ */
+ DataType getOutputType();
+
+ /**
+ * @param outputType
+ */
+ void setOutputType(DataType outputType);
+
+ /**
+ * Get a list of data types to represent the faults/exceptions
+ *
+ * @return the faultTypes
+ */
+ List<DataType> getFaultTypes();
+
+ /**
+ * @param faultTypes
+ */
+ void setFaultTypes(List<DataType> faultTypes);
+
+ /**
+ * Get the owning interface
+ * @return
+ */
+ Interface getInterface();
+
+ /**
+ * Set the owning interface
+ * @param interfaze
+ */
+ void setInterface(Interface interfaze);
+
+ /**
+ * Indicate if the operation is non-blocking
+ * @return
+ */
+ boolean isNonBlocking();
+
+ /**
+ * Indicate if the operation is an async server operation
+ * @return - true if the operation is an async server operation
+ */
+ boolean isAsyncServer();
+
+ /**
+ * Set the operation to be non-blocking
+ */
+ void setNonBlocking(boolean nonBlocking);
+
+ /**
+ * @return the wrapperInfo
+ */
+ WrapperInfo getWrapper();
+
+ /**
+ * @param wrapperInfo the wrapperInfo to set
+ */
+ void setWrapper(WrapperInfo wrapperInfo);
+
+ /**
+ * @return the wrapperStyle
+ */
+ boolean isWrapperStyle();
+
+ /**
+ * @param wrapperStyle the wrapperStyle to set
+ */
+ void setWrapperStyle(boolean wrapperStyle);
+
+ /**
+ * @deprecated This should be the WrapperInfo.getDataBinding()
+ * Get the databinding for the operation
+ * @return
+ */
+ @Deprecated
+ String getDataBinding();
+
+ /**
+ * @deprecated This should be the WrapperInfo.setDataBinding()
+ * Set the databinding for the operation
+ * @param dataBinding
+ */
+ @Deprecated
+ void setDataBinding(String dataBinding);
+
+ /**
+ * Returns true if the operation is dynamic.
+ *
+ * @return true if the operation is dynamic otherwise false
+ */
+ boolean isDynamic();
+
+ /**
+ * Set if the operation is dynamic
+ * @param b
+ */
+ void setDynamic(boolean b);
+
+ /**
+ * Get the synthesized fault beans for this operation
+ *
+ * @return the fault beans
+ */
+ Map<QName, List<DataType<XMLType>>> getFaultBeans();
+
+ /**
+ * Set the synthesized fault beans for this operation
+ * @param faultBeans
+ */
+ void setFaultBeans(Map<QName, List<DataType<XMLType>>> faultBeans);
+
+ /**
+ * Get a map of attributes assoicated with the operation
+ * @return A map of attributes
+ */
+ Map<Object, Object> getAttributes();
+
+ /**
+ * Implementations must support cloning.
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java
new file mode 100644
index 0000000000..92ac0850e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.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.sca.interfacedef;
+
+import java.lang.reflect.Method;
+
+/**
+ * Exception thrown to indicate that a service contract specification contains
+ * an overloaded method.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class OverloadedOperationException extends InvalidInterfaceException {
+ private static final long serialVersionUID = -4658711318608885638L;
+ private final Method operation;
+
+ public OverloadedOperationException(Method operation) {
+ super(operation == null ?
+ null : "[JCA20001] Cannot overload operation " + operation.getName()
+ + " on " + operation.getDeclaringClass().getName()
+ + " as it is a @Remotable interface");
+ this.operation = operation;
+ }
+
+ public Method getOperation() {
+ return operation;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java
new file mode 100644
index 0000000000..12ea22938c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.impl;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * Representation of the type of data associated with an operation. Data is
+ * represented in two forms: the physical form used by the runtime and a logical
+ * form used by the assembly. The physical form is a Java Type because the
+ * runtime is written in Java. This may be the same form used by the application
+ * but it may not; for example, an application that is performing stream
+ * processing may want a physical form such as an
+ * {@link java.io.InputStream InputStream} to semantically operate on application
+ * data such as a purchase order. The logical description is that used by the
+ * assembly model and is an identifier into some well-known type space; examples
+ * may be a Java type represented by its Class or an XML type represented by its
+ * QName. Every data type may also contain metadata describing the expected
+ * data; for example, it could specify a preferred data binding technology or
+ * the size of a typical instance.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class DataTypeImpl<L> implements DataType<L> {
+ private String dataBinding;
+ private Class<?> physical;
+ private Type genericType;
+ private L logical;
+ private Map<Class<?>, Object> metaDataMap;
+
+ /**
+ * Construct a data type specifying the physical and logical types.
+ *
+ * @param physical the physical class used by the runtime
+ * @param logical the logical type
+ * @see #getLogical()
+ */
+ public DataTypeImpl(Class<?> physical, L logical) {
+ this(null, physical, physical, logical);
+ }
+
+ /**
+ * @param dataBinding
+ * @param physical
+ * @param logical
+ */
+ public DataTypeImpl(String dataBinding, Class<?> physical, L logical) {
+ this(dataBinding, physical, physical, logical);
+ }
+
+ /**
+ * @param dataBinding
+ * @param physical
+ * @param genericType
+ * @param logical
+ */
+ public DataTypeImpl(String dataBinding, Class<?> physical, Type genericType, L logical) {
+ super();
+ this.dataBinding = dataBinding;
+ this.physical = physical;
+ this.genericType = genericType;
+ this.logical = logical;
+ }
+
+ /**
+ * Returns the physical type used by the runtime.
+ *
+ * @return the physical type used by the runtime
+ */
+ public Class<?> getPhysical() {
+ return physical;
+ }
+
+ /**
+ * @param physical the physical to set
+ */
+ public void setPhysical(Class<?> physical) {
+ this.physical = physical;
+ }
+
+ /**
+ * Get the java generic type
+ * @return The java generic type
+ */
+ public Type getGenericType() {
+ return genericType;
+ }
+
+ /**
+ * Set the java generic type
+ * @param genericType
+ */
+ public void setGenericType(Type genericType) {
+ this.genericType = genericType;
+ }
+
+ /**
+ * Returns the logical identifier used by the assembly. The type of this
+ * value identifies the logical type system in use. Known values are:
+ * <ul>
+ * <li>a java.lang.reflect.Type identifies a Java type by name and
+ * ClassLoader; this includes Java Classes as they are specializations of
+ * Type</li>
+ * <li>a javax.xml.namespace.QName identifies an XML type by local name and
+ * namespace</li>
+ * </ul>
+ *
+ * @return the logical type name
+ */
+ public L getLogical() {
+ return logical;
+ }
+
+ /**
+ * @param logical the logical to set
+ */
+ public void setLogical(L logical) {
+ this.logical = logical;
+ }
+
+ public String getDataBinding() {
+ return dataBinding;
+ }
+
+ /**
+ * @param dataBinding the dataBinding to set
+ */
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(physical).append(" ").append(dataBinding).append(" ").append(logical);
+ return sb.toString();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ DataTypeImpl copy = (DataTypeImpl)super.clone();
+ return copy;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((dataBinding == null) ? 0 : dataBinding.hashCode());
+ result = prime * result + ((genericType == null) ? 0 : genericType.hashCode());
+ result = prime * result + ((logical == null) ? 0 : logical.hashCode());
+ result = prime * result + ((physical == null) ? 0 : physical.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final DataTypeImpl other = (DataTypeImpl)obj;
+ if (dataBinding == null) {
+ if (other.dataBinding != null)
+ return false;
+ } else if (!dataBinding.equals(other.dataBinding))
+ return false;
+ if (genericType == null) {
+ if (other.genericType != null)
+ return false;
+ } else if (!genericType.equals(other.genericType))
+ return false;
+ if (logical == null) {
+ if (other.logical != null)
+ return false;
+ } else if (!logical.equals(other.logical))
+ return false;
+ if (physical == null) {
+ if (other.physical != null)
+ return false;
+ } else if (!physical.equals(other.physical))
+ return false;
+ return true;
+ }
+
+ public <T> T getMetaData(Class<T> type) {
+ return metaDataMap == null ? null : type.cast(metaDataMap.get(type));
+ }
+
+ public <T> void setMetaData(Class<T> type, T metaData) {
+ if (metaDataMap == null) {
+ metaDataMap = new ConcurrentHashMap<Class<?>, Object>();
+ }
+ metaDataMap.put(type, metaData);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
new file mode 100644
index 0000000000..4fad64ac89
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.impl;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents an interface contract. InterfaceContractImpl
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class InterfaceContractImpl implements InterfaceContract {
+ private Interface callInterface;
+ private Interface callbackInterface;
+
+ public Interface getCallbackInterface() {
+ return callbackInterface;
+ }
+
+ public Interface getInterface() {
+ return callInterface;
+ }
+
+ public void setCallbackInterface(Interface callbackInterface) {
+ this.callbackInterface = callbackInterface;
+ }
+
+ public void setInterface(Interface callInterface) {
+ this.callInterface = callInterface;
+ }
+
+ public InterfaceContract makeUnidirectional(boolean isCallback) {
+ if (!isCallback && callbackInterface == null)
+ return this; // already a unidirectional forward interface contract
+
+ if (isCallback && callInterface == null)
+ return this; // already a unidirectional callback interface contract
+
+ // contract is bidirectional, so create a new unidirectional contract
+ try {
+ InterfaceContract newContract = clone();
+ if (!isCallback) {
+ newContract.setCallbackInterface(null); // create unidirectional forward interface contract
+ } else {
+ newContract.setInterface(null); // create unidirectional callback interface contract
+ }
+ return newContract;
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+ @Override
+ public InterfaceContractImpl clone() throws CloneNotSupportedException {
+ InterfaceContractImpl copy = (InterfaceContractImpl)super.clone();
+ if (this.callbackInterface != null) {
+ copy.callbackInterface = (Interface)this.callbackInterface.clone();
+ }
+ if (this.callInterface != null) {
+ copy.callInterface = (Interface)this.callInterface.clone();
+ }
+ return copy;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((callInterface == null) ? 0 : callInterface.hashCode());
+ result = prime * result + ((callbackInterface == null) ? 0 : callbackInterface.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final InterfaceContractImpl other = (InterfaceContractImpl)obj;
+ if (callInterface == null) {
+ if (other.callInterface != null) {
+ return false;
+ }
+ } else if (!callInterface.equals(other.callInterface)) {
+ return false;
+ }
+ if (callbackInterface == null) {
+ if (other.callbackInterface != null) {
+ return false;
+ }
+ } else if (!callbackInterface.equals(other.callbackInterface)) {
+ return false;
+ }
+ return true;
+ }
+
+ // By default there is no normailized contract
+ // as only Java needs it
+ public InterfaceContract getNormalizedWSDLContract() {
+ return null;
+ }
+
+ // By default there is no normailized contract
+ // as only Java needs it
+ public void setNormailizedWSDLContract(
+ InterfaceContract wsdlInterfaceContract) {
+ // do nothing
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
new file mode 100644
index 0000000000..3dedb5e62c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.Audit;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterfaceContractMapperImpl implements InterfaceContractMapper {
+
+ protected ExtensionPointRegistry registry;
+ protected BuilderExtensionPoint builders;
+ protected ContractBuilder contractBuilder;
+
+ public InterfaceContractMapperImpl(ExtensionPointRegistry registry){
+ this.registry = registry;
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ public boolean isCompatible(DataType source, DataType target, boolean passByValue) {
+ return isCompatible(source, target, passByValue, null);
+ }
+
+ public boolean isCompatible(DataType source, DataType target, boolean passByValue, Audit audit) {
+ if (source == target) {
+ return true;
+ }
+ if (!passByValue) {
+ if (source == null || target == null) {
+ if (audit != null){
+ audit.append("One of either the source or target data types is null for");
+ }
+ return false;
+ }
+ // For local case
+ return target.getPhysical().isAssignableFrom(source.getPhysical());
+ } else {
+ // For remote interfaces where the target is represented with WSDL
+ // the source will have been converted to WSDL so we rely on JAXB mappings
+ // being the same in both cases and just compare the type names directly.
+ // TODO - is this right?
+ XMLType sourceLogicalType = null;
+
+ // There is some nesting of data types (when GeneratedDataType is used) so
+ // dig a bit deeper to find the real data type
+ if (source.getLogical() instanceof DataType<?>){
+ sourceLogicalType = (XMLType)((DataType<?>)source.getLogical()).getLogical();
+ } else {
+ sourceLogicalType = (XMLType)source.getLogical();
+ }
+
+ XMLType targetLogicalType = null;
+
+ if (target.getLogical() instanceof DataType<?>){
+ targetLogicalType = (XMLType)((DataType<?>)target.getLogical()).getLogical();
+ } else {
+ targetLogicalType = (XMLType)target.getLogical();
+ }
+
+ // The logical type seems to be null in some cases, e.g. when the
+ // argument or return type is something like a Map.
+ // TODO - check when some type give rise to a null logical type
+ if (sourceLogicalType.getTypeName() == null ||
+ targetLogicalType.getTypeName() == null) {
+ return true;
+ }
+
+ boolean match = sourceLogicalType.getTypeName().equals(targetLogicalType.getTypeName());
+
+ if (!match){
+
+ QName anyType = new QName("http://www.w3.org/2001/XMLSchema", "anyType");
+ if (sourceLogicalType.getTypeName().equals(anyType) ||
+ targetLogicalType.getTypeName().equals(anyType)){
+ // special case where a Java interface uses a generic type, e.g.
+ // public OMElement getGreetings(OMElement om)
+ // while the provided WSDL uses a specific type. So we assume
+ // that xsd:anyType matched anything
+ match = true;
+ } else {
+ if (audit != null){
+ audit.append("Operation argument types source = " +
+ sourceLogicalType.getTypeName() +
+ " target = " +
+ targetLogicalType.getTypeName() +
+ " don't match for");
+ }
+ }
+ }
+
+ return match;
+ }
+
+ }
+
+ /**
+ * Check that two interface contracts are equal. The contracts are equal if the two contracts have the
+ * same set of operations, with each operation having the same signature, both for forward and callback
+ * interfaces
+ * @param source
+ * @param target
+ * @return
+ */
+ public boolean isMutuallyCompatible(InterfaceContract source, InterfaceContract target) {
+ ExtensionType ext = source.getInterface().getExtensionType();
+ InterfaceContract sourceContract = null;
+
+ // Are the forward interfaces equal?
+ if (isMutuallyCompatible(source.getInterface(), target.getInterface())) {
+ // Is there a Callback interface?
+ if (source.getCallbackInterface() == null && target.getCallbackInterface() == null) {
+ return true;
+ } else {
+ if (isMutuallyCompatible(source.getCallbackInterface(), target.getCallbackInterface())) {
+ return true;
+ } // end if
+ } // end if
+ } // end if
+ return false;
+ } // end method isEqual
+
+ /**
+ * Check that two interfaces are equal. The interfaces are equal if the two interfaces have the
+ * same set of operations, with each operation having the same signature.
+ * @param source
+ * @param target
+ * @return
+ */
+ public boolean isMutuallyCompatible(Interface source, Interface target) {
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ } // end if
+ if (source == null || target == null) {
+ return false;
+ } // end if
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ if (source.isRemotable() != target.isRemotable()) {
+ return false;
+ }
+ if (source.getOperations().size() != target.getOperations().size()) {
+ return false;
+ }
+
+ for (Operation operation : source.getOperations()) {
+ Operation targetOperation = getOperation(target.getOperations(), operation.getName());
+ if (targetOperation == null) {
+ return false;
+ }
+ if (!isCompatible(operation, targetOperation, Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ return true;
+ } // end method isEqual
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, true);
+ }
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType, boolean byValue) {
+ return isCompatible(source, target, compatibilityType, true, null);
+ }
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType, boolean byValue, Audit audit) {
+ if (source == target) {
+ return true;
+ }
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ // Check name
+ if (!source.getName().equals(target.getName())) {
+ if (audit != null){
+ audit.append("operation names are not the same source = " +
+ source.getName() +
+ " target = " +
+ target.getName());
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) {
+ if (audit != null){
+ audit.append("Interfaces have different remote settings source = " +
+ source.getName() +
+ " target = " +
+ target.getName());
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ if (source.isNonBlocking() != target.isNonBlocking()) {
+ if (audit != null){
+ audit.append("operations one-way not the same, source = " +
+ source.isNonBlocking() +
+ " target = " +
+ target.isNonBlocking());
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ boolean passByValue = (source.getInterface().isRemotable()) && byValue;
+
+ // if (source.getInterface().isRemotable()) {
+ // return true;
+ // }
+
+ // FIXME: We need to deal with wrapped<-->unwrapped conversion
+
+ // Check output type
+ DataType<?> sourceOutputType = source.getOutputType();
+ DataType<?> targetOutputType = target.getOutputType();
+
+ boolean checkSourceWrapper = true;
+ List<DataType> sourceInputType = source.getInputType().getLogical();
+ if (source.isWrapperStyle() && source.getWrapper() != null) {
+ sourceInputType = source.getWrapper().getUnwrappedInputType().getLogical();
+ sourceOutputType = source.getWrapper().getUnwrappedOutputType();
+ checkSourceWrapper = false;
+ }
+ boolean checkTargetWrapper = true;
+ List<DataType> targetInputType = target.getInputType().getLogical();
+ if (target.isWrapperStyle() && target.getWrapper() != null) {
+ targetInputType = target.getWrapper().getUnwrappedInputType().getLogical();
+ targetOutputType = target.getWrapper().getUnwrappedOutputType();
+ checkTargetWrapper = false;
+ }
+
+/* TODO - Why are we assuming compatibility if one side is wrapped and the other is not?
+ if (checkSourceWrapper != checkTargetWrapper) {
+ return true;
+ }
+*/
+
+ if (!isCompatible(targetOutputType, sourceOutputType, passByValue, audit)) {
+ if (audit != null){
+ audit.append(" output types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ if (sourceInputType.size() != targetInputType.size()) {
+ if (audit != null){
+ audit.append("different number of input types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ int size = sourceInputType.size();
+ for (int i = 0; i < size; i++) {
+ if (!isCompatible(sourceInputType.get(i), targetInputType.get(i), passByValue, audit)) {
+ if (audit != null){
+ audit.append(" input types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+ }
+
+ // Check fault types
+ for (DataType targetFaultType : target.getFaultTypes()) {
+ // Source fault types must be the same or superset of target fault
+ // types
+ boolean found = true;
+ for (DataType sourceFaultType : source.getFaultTypes()) {
+ found = false;
+ if (isCompatible(targetFaultType, sourceFaultType, passByValue, audit)) {
+ // Target fault type can be covered by the source fault type
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ if (audit != null){
+ audit.append("Fault types incompatible");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
+ public boolean isCompatibleByReference(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, false);
+ }
+
+ public boolean isCompatibleByValue(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, true);
+ }
+
+ // FIXME: How to improve the performance for the lookup
+ private Operation getOperation(List<Operation> operations, String name) {
+ for (Operation op : operations) {
+ if (op.getName().equals(name)) {
+ return op;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * this variant of the checkCompatibility method is intended to supersede the one without an audit argument
+ * Presence of both method variants indicates a state of partial development
+ */
+ public boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent,
+ Audit audit)
+ throws IncompatibleInterfaceContractException {
+
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ }
+
+ if (source == null || target == null) {
+ return false;
+ }
+
+ if (source.getInterface() == target.getInterface()) {
+ return ignoreCallback
+ || isCallbackCompatible(source, target, silent);
+ }
+
+ if (source.getInterface() == null || target.getInterface() == null) {
+ return false;
+ }
+
+ if (source.getInterface().isDynamic()
+ || target.getInterface().isDynamic()) {
+ return ignoreCallback
+ || isCallbackCompatible(source, target, silent);
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface()
+ .isRemotable()) {
+ if (!silent) {
+ audit.append("Remotable settings do not match: "+ source + "," + target); // TODO see if serialization is sufficient
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException(
+ "Remotable settings do not match", source, target);
+
+ } else {
+ return false;
+ }
+ }
+
+ for (Operation operation : source.getInterface().getOperations()) {
+ Operation targetOperation = map(target.getInterface(), operation);
+ if (targetOperation == null) {
+ if (!silent) {
+ audit.append("Operation " + operation.getName()+ " not found on target");
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException(
+ "Operation " + operation.getName()
+ + " not found on target", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ if (!silent) {
+ if (audit == null)
+ audit = new Audit();
+ if (!isCompatible(operation, targetOperation,
+ Compatibility.SUBSET, true, audit)) {
+ audit.append("Operations called " + operation.getName()+ " are not compatible");
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException(
+ "Operations called " + operation.getName()
+ + " are not compatible " + audit, source,
+ target);
+ }
+ } else {
+ if (!isCompatible(operation, targetOperation,
+ Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ }
+
+ return ignoreCallback || isCallbackCompatible(source, target, silent);
+ }
+
+ /*
+ * The old checkCompatibility operation without auditing. This just delegates to the new one for the time
+ * being while there are still calls that don't provide and audit object. In the medium term when the calls have
+ * been converted to sue the new opetion directly this should be removed.
+ */
+ public boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent)
+ throws IncompatibleInterfaceContractException {
+
+ // create dummy audit object.
+ Audit audit = new Audit();
+
+ return checkCompatibility(source,
+ target,
+ compatibility,
+ ignoreCallback,
+ silent,
+ audit);
+ }
+
+
+
+ protected boolean isCallbackCompatible(InterfaceContract source, InterfaceContract target, boolean silent)
+ throws IncompatibleInterfaceContractException {
+ if (source.getCallbackInterface() == null && target.getCallbackInterface() == null) {
+ return true;
+ }
+ if (source.getCallbackInterface() == null || target.getCallbackInterface() == null) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Callback interface doesn't match as one of the callback interfaces is null", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ for (Operation operation : source.getCallbackInterface().getOperations()) {
+ Operation targetOperation =
+ getOperation(target.getCallbackInterface().getOperations(), operation.getName());
+ if (targetOperation == null) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Callback operation not found on target", source,
+ target, null, targetOperation);
+ } else {
+ return false;
+ }
+ }
+ if (!source.getCallbackInterface().isRemotable()) {
+ // FIXME: for remotable operation, only compare name for now
+ if (!operation.equals(targetOperation)) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Target callback operation is not compatible",
+ source, target, operation, targetOperation);
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public boolean isCompatibleSubset(Interface source, Interface target) {
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ }
+ if (source == null || target == null) {
+ return false;
+ }
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ if (source.isRemotable() != target.isRemotable()) {
+ return false;
+ }
+
+ for (Operation operation : source.getOperations()) {
+ Operation targetOperation = getOperation(target.getOperations(), operation.getName());
+ if (targetOperation == null) {
+ return false;
+ }
+ if (!isCompatible(operation, targetOperation, Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * the variant of isCompatibleSubset with the audit parameter is intended to supersede the other
+ * -- the presence of both indicates a partial development state
+ */
+ public boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target, Audit audit) {
+
+ try {
+ return checkCompatibility(source, target, Compatibility.SUBSET, false, false, audit);
+ } catch (IncompatibleInterfaceContractException e) {
+ return false;
+ }
+ }
+
+ public boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target) {
+
+ try {
+ return checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ } catch (IncompatibleInterfaceContractException e) {
+ return false;
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.InterfaceContractMapper#map(org.apache.tuscany.sca.interfacedef.Interface,
+ * org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public Operation map(Interface target, Operation source) {
+ // TODO: How to handle the case that source operation is dynamic?
+ if (target == null || target.isDynamic()) {
+ return source;
+ } else if (target.isRemotable()) {
+ for (Operation op : target.getOperations()) {
+ if (op.getName().equals(source.getName())) {
+ return op;
+ }
+ }
+ return null;
+ } else {
+ for (Operation op : target.getOperations()) {
+ if (isCompatible(source, op, Compatibility.SUBSET)) {
+ return op;
+ }
+ }
+ return null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
new file mode 100644
index 0000000000..c56b5545ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a service interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public class InterfaceImpl implements Interface {
+
+ private Boolean remotable;
+ private boolean conversational;
+ private OperationList operations = new OperationList();
+ private boolean unresolved;
+
+ private ExtensionType type;
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();
+
+ public boolean isRemotable() {
+ boolean value = false;
+ if (remotable != null && remotable.booleanValue()) {
+ value = true;
+ }
+ return value;
+ }
+
+ public void setRemotable(boolean remotable) {
+ this.remotable = Boolean.valueOf(remotable);
+ }
+
+ public boolean isRemotableSet() {
+ return remotable == null ? false : true;
+ }
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ /**
+ * @return the conversational
+ */
+ public boolean isConversational() {
+ return conversational;
+ }
+
+ /**
+ * @param conversational the conversational to set
+ */
+ public void setConversational(boolean conversational) {
+ this.conversational = conversational;
+ }
+
+ private class OperationList extends ArrayList<Operation> {
+ private static final long serialVersionUID = -903469106307606099L;
+
+ @Override
+ public Operation set(int index, Operation element) {
+ element.setInterface(InterfaceImpl.this);
+ return super.set(index, element);
+ }
+
+ @Override
+ public void add(int index, Operation element) {
+ element.setInterface(InterfaceImpl.this);
+ super.add(index, element);
+ }
+
+ @Override
+ public boolean add(Operation o) {
+ o.setInterface(InterfaceImpl.this);
+ return super.add(o);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Operation> c) {
+ for (Operation op : c) {
+ op.setInterface(InterfaceImpl.this);
+ }
+ return super.addAll(c);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends Operation> c) {
+ for (Operation op : c) {
+ op.setInterface(InterfaceImpl.this);
+ }
+ return super.addAll(index, c);
+ }
+
+ }
+
+ @Deprecated
+ public void setDefaultDataBinding(String dataBinding) {
+ for (Operation op : getOperations()) {
+ if (op.getDataBinding() == null) {
+ op.setDataBinding(dataBinding);
+ DataType<List<DataType>> inputType = op.getInputType();
+ if (inputType != null) {
+ for (DataType d : inputType.getLogical()) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ }
+ }
+ DataType outputType = op.getOutputType();
+ if (outputType != null && outputType.getDataBinding() == null) {
+ outputType.setDataBinding(dataBinding);
+ }
+ List<DataType> faultTypes = op.getFaultTypes();
+ if (faultTypes != null) {
+ for (DataType d : faultTypes) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ DataType ft = (DataType) d.getLogical();
+ if (ft.getDataBinding() == null) {
+ ft.setDataBinding(dataBinding);
+ }
+
+ }
+ }
+ if (op.isWrapperStyle()) {
+ WrapperInfo wrapper = op.getWrapper();
+ if (wrapper != null) {
+ DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType();
+ if (unwrappedInputType != null) {
+ for (DataType d : unwrappedInputType.getLogical()) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ }
+ }
+ DataType unwrappedOutputType = wrapper.getUnwrappedOutputType();
+ if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) {
+ unwrappedOutputType.setDataBinding(dataBinding);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void setDataBinding(DataType dataType, String dataBinding) {
+ if ("java:array".equals(dataType.getDataBinding())) {
+ setDataBinding((DataType)dataType.getLogical(), dataBinding);
+ } else {
+ dataType.setDataBinding(dataBinding);
+ }
+ }
+
+ public void resetDataBinding(String dataBinding) {
+ for (Operation op : getOperations()) {
+ op.setDataBinding(dataBinding);
+ DataType<List<DataType>> inputType = op.getInputType();
+ if (inputType != null) {
+ for (DataType d : inputType.getLogical()) {
+ setDataBinding(d, dataBinding);
+ }
+ }
+ DataType outputType = op.getOutputType();
+ if (outputType != null) {
+ setDataBinding(outputType, dataBinding);
+ }
+ List<DataType> faultTypes = op.getFaultTypes();
+ if (faultTypes != null) {
+ for (DataType d : faultTypes) {
+ setDataBinding(d, dataBinding);
+ setDataBinding((DataType) d.getLogical(), dataBinding);
+ }
+ }
+ if (op.isWrapperStyle()) {
+ WrapperInfo wrapper = op.getWrapper();
+ if (wrapper != null) {
+ DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType();
+ if (unwrappedInputType != null) {
+ for (DataType d : unwrappedInputType.getLogical()) {
+ setDataBinding(d, dataBinding);
+ }
+ }
+ DataType unwrappedOutputType = wrapper.getUnwrappedOutputType();
+ if (unwrappedOutputType != null) {
+ setDataBinding(unwrappedOutputType, dataBinding);
+ }
+ }
+ }
+ }
+ }
+
+ public void resetInterfaceInputTypes(Interface newInterface){
+ for (int i = 0; i < getOperations().size(); i++) {
+ // only remote interfaces only have a data type model defined
+ // and in this case operations cannot be overloaded so match
+ // operations by name
+ Operation oldOperation = getOperations().get(i);
+ Operation newOperation = null;
+
+ for (Operation tmpOperation : newInterface.getOperations()){
+ if (tmpOperation.getName().equals(oldOperation.getName())){
+ newOperation = tmpOperation;
+ }
+ }
+
+ if (newOperation == null){
+ break;
+ }
+
+ // set input types
+ oldOperation.setInputType(newOperation.getInputType());
+
+ // set wrapper
+ if (newOperation.isWrapperStyle()) {
+ oldOperation.setWrapperStyle(true);
+ oldOperation.setWrapper(newOperation.getWrapper());
+ }
+ }
+ }
+
+ public void resetInterfaceOutputTypes(Interface newInterface){
+ for (int i = 0; i < getOperations().size(); i++) {
+ // only remote interfaces only have a data type model defined
+ // and in this case operations cannot be overloaded so match
+ // operations by name
+ Operation oldOperation = getOperations().get(i);
+ Operation newOperation = null;
+
+ for (Operation tmpOperation : newInterface.getOperations()){
+ if (tmpOperation.getName().equals(oldOperation.getName())){
+ newOperation = tmpOperation;
+ }
+ }
+
+ if (newOperation == null){
+ break;
+ }
+
+ // set output types
+ oldOperation.setOutputType(newOperation.getOutputType());
+
+ // set fault types
+ oldOperation.setFaultTypes(newOperation.getFaultTypes());
+
+ // set wrapper
+ if (newOperation.isWrapperStyle()) {
+ oldOperation.setWrapperStyle(true);
+ oldOperation.setWrapper(newOperation.getWrapper());
+ }
+ }
+ }
+
+ public boolean isDynamic() {
+ return false;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ InterfaceImpl copy = (InterfaceImpl)super.clone();
+ copy.operations = new OperationList();
+ for (Operation operation : this.operations) {
+ Operation clonedOperation = (Operation)operation.clone();
+ copy.operations.add(clonedOperation);
+ }
+ copy.attributes = new ConcurrentHashMap<Object, Object>();
+ copy.attributes.putAll(attributes);
+ return copy;
+ }
+
+ public Map<Object, Object> getAttributes() {
+ return attributes;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
new file mode 100644
index 0000000000..606782466d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents an operation on a service interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public class OperationImpl implements Operation {
+
+ private String name;
+ private boolean unresolved;
+ private DataType outputType;
+ private DataType<List<DataType>> inputType;
+ private List<DataType> faultTypes;
+ private Interface interfaze;
+ private boolean nonBlocking;
+ private boolean wrapperStyle;
+ private WrapperInfo wrapper;
+ private boolean dynamic;
+
+ private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();
+
+ private Map<QName, List<DataType<XMLType>>> faultBeans;
+
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private ExtensionType type;
+
+ /**
+ * @param name
+ */
+ public OperationImpl() {
+ inputType = new DataTypeImpl<List<DataType>>("idl:input", Object[].class, new ArrayList<DataType>());
+ faultTypes = new ArrayList<DataType>();
+ faultBeans = new HashMap<QName, List<DataType<XMLType>>>();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ /**
+ * @return the faultTypes
+ */
+ public List<DataType> getFaultTypes() {
+ return faultTypes;
+ }
+
+ /**
+ * @param faultTypes the faultTypes to set
+ */
+ public void setFaultTypes(List<DataType> faultTypes) {
+ this.faultTypes = faultTypes;
+ }
+
+ /**
+ * @return the inputType
+ */
+ public DataType<List<DataType>> getInputType() {
+ return inputType;
+ }
+
+ /**
+ * @param inputType the inputType to set
+ */
+ public void setInputType(DataType<List<DataType>> inputType) {
+ this.inputType = inputType;
+ }
+
+ /**
+ * @return the outputType
+ */
+ public DataType getOutputType() {
+ return outputType;
+ }
+
+ /**
+ * @param outputType the outputType to set
+ */
+ public void setOutputType(DataType outputType) {
+ this.outputType = outputType;
+ }
+
+ /**
+ * @return the interface
+ */
+ public Interface getInterface() {
+ return interfaze;
+ }
+
+ /**
+ * @param interfaze the interface to set
+ */
+ public void setInterface(Interface interfaze) {
+ this.interfaze = interfaze;
+ }
+
+ /**
+ * @return the nonBlocking
+ */
+ public boolean isNonBlocking() {
+ return nonBlocking;
+ }
+
+ /**
+ * @param nonBlocking the nonBlocking to set
+ */
+ public void setNonBlocking(boolean nonBlocking) {
+ this.nonBlocking = nonBlocking;
+ }
+
+ /**
+ * @return the wrapperInfo
+ */
+ public WrapperInfo getWrapper() {
+ return wrapper;
+ }
+
+ /**
+ * @param wrapperInfo the wrapperInfo to set
+ */
+ public void setWrapper(WrapperInfo wrapperInfo) {
+ this.wrapper = wrapperInfo;
+ }
+
+ /**
+ * @return the wrapperStyle
+ */
+ public boolean isWrapperStyle() {
+ return wrapperStyle;
+ }
+
+ /**
+ * @param wrapperStyle the wrapperStyle to set
+ */
+ public void setWrapperStyle(boolean wrapperStyle) {
+ this.wrapperStyle = wrapperStyle;
+ }
+
+ public String getDataBinding() {
+ return wrapper != null ? wrapper.getDataBinding() : null;
+ }
+
+ public void setDataBinding(String dataBinding) {
+ if (wrapper != null) {
+ wrapper.setDataBinding(dataBinding);
+ }
+ }
+
+ public boolean isDynamic() {
+ return dynamic;
+ }
+
+ public void setDynamic(boolean b) {
+ this.dynamic = b;
+ }
+
+ public Map<QName, List<DataType<XMLType>>> getFaultBeans() {
+ return faultBeans;
+ }
+
+ public void setFaultBeans(Map<QName, List<DataType<XMLType>>> faultBeans) {
+ this.faultBeans = faultBeans;
+ }
+
+ @Override
+ public OperationImpl clone() throws CloneNotSupportedException {
+ OperationImpl copy = (OperationImpl) super.clone();
+
+ final List<DataType> clonedFaultTypes = new ArrayList<DataType>(this.faultTypes.size());
+ for (DataType t : this.faultTypes) {
+ clonedFaultTypes.add((DataType) t.clone());
+ }
+ copy.faultTypes = clonedFaultTypes;
+
+ List<DataType> clonedLogicalTypes = new ArrayList<DataType>();
+ for (DataType t : inputType.getLogical()) {
+ DataType type = (DataType) t.clone();
+ clonedLogicalTypes.add(type);
+ }
+ DataType<List<DataType>> clonedInputType =
+ new DataTypeImpl<List<DataType>>(inputType.getPhysical(), clonedLogicalTypes);
+ clonedInputType.setDataBinding(inputType.getDataBinding());
+ copy.inputType = clonedInputType;
+
+ if (this.outputType != null) {
+ copy.outputType = (DataType) this.outputType.clone();
+ }
+
+ copy.attributes = new ConcurrentHashMap<Object, Object>();
+ copy.attributes.putAll(attributes);
+
+ // [rfeng] We need to clone the wrapper as it holds the databinding information
+ if (wrapper != null) {
+ copy.wrapper = (WrapperInfo)wrapper.clone();
+ }
+
+ return copy;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+ public Map<Object, Object> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Indicates if this operation is an async server style of operation
+ * @return true if the operation is async server style
+ */
+ public boolean isAsyncServer() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/Audit.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/Audit.java
new file mode 100644
index 0000000000..343d369fdb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/Audit.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.util;
+
+
+/*
+ * utility to allow building up an audit trail in case reporting is necessary later
+ *
+ */
+public class Audit {
+
+ public static final String seperator = "|||";
+ private StringBuffer buf;
+
+ public Audit() {
+ this.buf = new StringBuffer();
+ }
+ public void append(String str) {
+ buf.append(str);
+ }
+
+ public void appendSeperator() {
+ buf.append(seperator);
+ }
+ public String toString() {
+ return buf.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java
new file mode 100644
index 0000000000..38e33e33d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema elements.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ElementInfo {
+ private final QName name;
+ private final TypeInfo type;
+ private boolean many = false;
+ private boolean nillable = false;
+
+ /**
+ * @param name
+ * @param type
+ */
+ public ElementInfo(QName name, TypeInfo type) {
+ super();
+ this.name = name;
+ this.type = type;
+ }
+
+ /**
+ * @return the name
+ */
+ public QName getQName() {
+ return name;
+ }
+
+ /**
+ * @return the type
+ */
+ public TypeInfo getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Element: ").append(name).append(" ").append(type);
+ return sb.toString();
+ }
+
+ public boolean isMany() {
+ return many;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+ public boolean isNillable() {
+ return nillable;
+ }
+
+ public void setNillable(boolean nillable) {
+ this.nillable = nillable;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ElementInfo other = (ElementInfo)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ /*
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ */
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java
new file mode 100644
index 0000000000..334c826f86
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.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.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The generic java exception to wrap service faults
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class FaultException extends Exception {
+ private static final long serialVersionUID = -8002583655240625792L;
+ private transient Object faultInfo; // FIXME: How to serialize it?
+ private QName faultName;
+
+ /**
+ * @param message
+ * @param faultInfo
+ */
+ public FaultException(String message, Object faultInfo) {
+ super(message);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @param message
+ * @param faultInfo
+ * @param cause
+ */
+ public FaultException(String message, Object faultInfo, Throwable cause) {
+ super(message, cause);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @return the faultInfo
+ */
+ public Object getFaultInfo() {
+ return faultInfo;
+ }
+
+ public QName getFaultName() {
+ return faultName;
+ }
+
+ public void setFaultName(QName logical) {
+ this.faultName = logical;
+ }
+
+ public boolean isMatchingType(Object type) {
+ if (faultName == null) {
+ return false;
+ }
+
+ if ((type instanceof QName) && faultName.equals(type)) {
+ return true;
+ }
+ if (type instanceof XMLType && faultName.equals(((XMLType)type).getElementName())) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
new file mode 100644
index 0000000000..849b922285
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.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.sca.interfacedef.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Utility class that can be used to map XSD types to Java classes and Java classes to XSD types.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public final class JavaXMLMapper {
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+ private static final Map<Class, QName> JAVA2XML = new HashMap<Class, QName>();
+ private static final Map<String, Class> XML2JAVA = new HashMap<String, Class>();
+
+ private JavaXMLMapper() {
+ }
+
+ static {
+ JAVA2XML.put(boolean.class, getTypeName("boolean"));
+ JAVA2XML.put(byte.class, getTypeName("byte"));
+ JAVA2XML.put(short.class, getTypeName("short"));
+ JAVA2XML.put(int.class, getTypeName("int"));
+ JAVA2XML.put(long.class, getTypeName("long"));
+ JAVA2XML.put(float.class, getTypeName("float"));
+ JAVA2XML.put(double.class, getTypeName("double"));
+ JAVA2XML.put(Boolean.class, getTypeName("boolean"));
+ JAVA2XML.put(Byte.class, getTypeName("byte"));
+ JAVA2XML.put(Short.class, getTypeName("short"));
+ JAVA2XML.put(Integer.class, getTypeName("int"));
+ JAVA2XML.put(Long.class, getTypeName("long"));
+ JAVA2XML.put(Float.class, getTypeName("float"));
+ JAVA2XML.put(Double.class, getTypeName("double"));
+ JAVA2XML.put(java.lang.String.class, getTypeName("string"));
+ JAVA2XML.put(java.math.BigInteger.class, getTypeName("integer"));
+ JAVA2XML.put(java.math.BigDecimal.class, getTypeName("decimal"));
+ JAVA2XML.put(java.util.Calendar.class, getTypeName("dateTime"));
+ JAVA2XML.put(java.util.Date.class, getTypeName("dateTime"));
+ JAVA2XML.put(javax.xml.namespace.QName.class, getTypeName("QName"));
+ JAVA2XML.put(java.net.URI.class, getTypeName("string"));
+ JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, getTypeName("anySimpleType"));
+ JAVA2XML.put(javax.xml.datatype.Duration.class, getTypeName("duration"));
+ JAVA2XML.put(java.lang.Object.class, getTypeName("anyType"));
+ JAVA2XML.put(java.awt.Image.class, getTypeName("base64Binary"));
+ JAVA2XML.put(byte[].class, getTypeName("base64Binary"));
+ // java2XSD.put(javax.activation.DataHandler.class, getTypeName("base64Binary"));
+ JAVA2XML.put(javax.xml.transform.Source.class, getTypeName("base64Binary"));
+ JAVA2XML.put(java.util.UUID.class, getTypeName("string"));
+ }
+
+ static {
+ XML2JAVA.put("string", java.lang.String.class);
+ XML2JAVA.put("integer", java.math.BigInteger.class);
+ XML2JAVA.put("int", int.class);
+ XML2JAVA.put("long", long.class);
+ XML2JAVA.put("short", short.class);
+ XML2JAVA.put("decimal", java.math.BigDecimal.class);
+ XML2JAVA.put("float", float.class);
+ XML2JAVA.put("double", double.class);
+ XML2JAVA.put("boolean", boolean.class);
+ XML2JAVA.put("byte", byte.class);
+ XML2JAVA.put("QName", javax.xml.namespace.QName.class);
+ XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("base64Binary", byte[].class);
+ XML2JAVA.put("hexBinary", byte[].class);
+ XML2JAVA.put("unsignedInt", long.class);
+ XML2JAVA.put("unsignedShort", int.class);
+ XML2JAVA.put("unsignedByte", short.class);
+ XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements
+ // XML2JAVA.put("anySimpleType", java.lang.String.class); // For
+ // attributes
+ XML2JAVA.put("duration", javax.xml.datatype.Duration.class);
+ XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class);
+ }
+
+ public static Class getJavaType(QName xmlType) {
+ if (URI_2001_SCHEMA_XSD.equals(xmlType.getNamespaceURI())) {
+ return XML2JAVA.get(xmlType.getLocalPart());
+ } else {
+ return null;
+ }
+ }
+
+ private static QName getTypeName(String name) {
+ return new QName(URI_2001_SCHEMA_XSD, name);
+ }
+
+ public static QName getXMLType(Class javaType) {
+ return JAVA2XML.get(javaType);
+ }
+
+ private static String getPackageName(Class<?> cls) {
+ String name = cls.getName();
+ int index = name.lastIndexOf('.');
+ return index == -1 ? "" : name.substring(0, index);
+ }
+
+ public static String getNamespace(Class<?> cls) {
+ String packageName = getPackageName(cls);
+ if ("".equals(packageName)) {
+ return "";
+ }
+ StringBuffer ns = new StringBuffer("http://");
+ String[] names = packageName.split("\\.");
+ for (int i = names.length - 1; i >= 0; i--) {
+ ns.append(names[i]);
+ if (i != 0) {
+ ns.append('.');
+ }
+ }
+ ns.append('/');
+ return ns.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java
new file mode 100644
index 0000000000..abae4e7e38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema types
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class TypeInfo {
+ private QName name;
+
+ private boolean isSimpleType;
+
+ private TypeInfo baseType;
+
+ /**
+ * @param name
+ * @param isSimpleType
+ */
+ public TypeInfo(QName name, boolean isSimpleType, TypeInfo baseType) {
+ super();
+ this.name = name;
+ this.isSimpleType = isSimpleType;
+ this.baseType = baseType;
+ }
+
+ /**
+ * @return the isSimpleType
+ */
+ public boolean isSimpleType() {
+ return isSimpleType;
+ }
+
+ /**
+ * @return the name
+ */
+ public QName getQName() {
+ return name;
+ }
+
+ /**
+ * @return the baseType
+ */
+ public TypeInfo getBaseType() {
+ return baseType;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Type: ").append(name);
+ return sb.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final TypeInfo other = (TypeInfo)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java
new file mode 100644
index 0000000000..2252434c39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+
+/**
+ * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based
+ * Web Services (JAX-WS) 2.0 specification, section 2.3.1.2 Wrapper Style. <p/>
+ * A WSDL operation qualifies for wrapper style mapping only if the following
+ * criteria are met:
+ * <ul>
+ * <li>(i) The operation�s input and output messages (if present) each contain
+ * only a single part
+ * <li>(ii) The input message part refers to a global element declaration whose
+ * localname is equal to the operation name
+ * <li>(iii) The output message part refers to a global element declaration
+ * <li>(iv) The elements referred to by the input and output message parts
+ * (henceforth referred to as wrapper elements) are both complex types defined
+ * using the xsd:sequence compositor
+ * <li>(v) The wrapper elements only contain child elements, they must not
+ * contain other structures such as wildcards (element or attribute),
+ * xsd:choice, substitution groups (element references are not permitted) or
+ * attributes; furthermore, they must not be nillable.
+ * </ul>
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class WrapperInfo implements Cloneable {
+ private ElementInfo inputWrapperElement;
+
+ private ElementInfo outputWrapperElement;
+
+ private List<ElementInfo> inputChildElements;
+
+ private List<ElementInfo> outputChildElements;
+
+ // The data type of the unwrapped input child elements
+ private DataType<List<DataType>> unwrappedInputType;
+
+ // The data type of the unwrapped output child element (we only supports one child)
+ private DataType<XMLType> unwrappedOutputType;
+
+ // The data for the input/output wrappers
+ private String dataBinding;
+
+ // The data type for the input (request) wrapper bean
+ private DataType<XMLType> inputWrapperType;
+ // The data type for the output (response) wrapper bean
+ private DataType<XMLType> outputWrapperType;
+
+ public WrapperInfo(String dataBinding,
+ ElementInfo inputWrapperElement,
+ ElementInfo outputWrapperElement,
+ List<ElementInfo> inputElements,
+ List<ElementInfo> outputElements) {
+ super();
+ this.dataBinding = dataBinding;
+ this.inputWrapperElement = inputWrapperElement;
+ this.outputWrapperElement = outputWrapperElement;
+ this.inputChildElements = inputElements;
+ this.outputChildElements = outputElements;
+ }
+
+ /**
+ * @return the inputElements
+ */
+ public List<ElementInfo> getInputChildElements() {
+ return inputChildElements;
+ }
+
+ /**
+ * @return the inputWrapperElement
+ */
+ public ElementInfo getInputWrapperElement() {
+ return inputWrapperElement;
+ }
+
+ /**
+ * @return the outputElements
+ */
+ public List<ElementInfo> getOutputChildElements() {
+ return outputChildElements;
+ }
+
+ /**
+ * @return the outputWrapperElement
+ */
+ public ElementInfo getOutputWrapperElement() {
+ return outputWrapperElement;
+ }
+
+ /**
+ * @return the unwrappedInputType
+ */
+ public DataType<List<DataType>> getUnwrappedInputType() {
+ if (unwrappedInputType == null) {
+ List<DataType> childTypes = new ArrayList<DataType>();
+ for (ElementInfo element : getInputChildElements()) {
+ DataType type = getDataType(element);
+ childTypes.add(type);
+ }
+ unwrappedInputType = new DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class, childTypes);
+ }
+ return unwrappedInputType;
+ }
+
+ private DataType getDataType(ElementInfo element) {
+ DataType type = null;
+ if (element.isMany()) {
+ DataType logical = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element));
+ type = new DataTypeImpl<DataType>("java:array", Object[].class, logical);
+ } else {
+ type = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element));
+ }
+ return type;
+ }
+
+ /**
+ * @return the unwrappedOutputType
+ */
+ public DataType getUnwrappedOutputType() {
+ if (unwrappedOutputType == null) {
+ List<ElementInfo> elements = getOutputChildElements();
+ if (elements != null && elements.size() > 0) {
+ if (elements.size() > 1) {
+ // We don't support output with multiple parts
+ // throw new IllegalArgumentException("Multi-part output is not supported");
+ }
+ ElementInfo element = elements.get(0);
+
+ unwrappedOutputType = getDataType(element);
+ }
+ }
+ return unwrappedOutputType;
+ }
+
+ public Class<?> getInputWrapperClass() {
+ return inputWrapperType == null ? null : inputWrapperType.getPhysical();
+ }
+
+ public Class<?> getOutputWrapperClass() {
+ return outputWrapperType == null ? null : outputWrapperType.getPhysical();
+ }
+
+ public String getDataBinding() {
+ return dataBinding;
+ }
+
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
+ }
+
+ public DataType<XMLType> getInputWrapperType() {
+ return inputWrapperType;
+ }
+
+ public void setInputWrapperType(DataType<XMLType> inputWrapperType) {
+ this.inputWrapperType = inputWrapperType;
+ }
+
+ public DataType<XMLType> getOutputWrapperType() {
+ return outputWrapperType;
+ }
+
+ public void setOutputWrapperType(DataType<XMLType> outputWrapperType) {
+ this.outputWrapperType = outputWrapperType;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ WrapperInfo copy = (WrapperInfo) super.clone();
+ if (inputWrapperType != null) {
+ copy.inputWrapperType = (DataType<XMLType>)inputWrapperType.clone();
+ }
+ if (outputWrapperType != null) {
+ copy.outputWrapperType = (DataType<XMLType>)outputWrapperType.clone();
+ }
+ return copy;
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java
new file mode 100644
index 0000000000..fd1b840b17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The metadata for an XML element or type.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class XMLType {
+ public static final XMLType UNKNOWN = new XMLType(null, null);
+ protected QName element;
+ protected QName type;
+ protected boolean nillable = true;
+ protected boolean many = false;
+
+ /**
+ * @param element
+ */
+ public XMLType(ElementInfo element) {
+ super();
+ this.element = element.getQName();
+ if (element.getType() != null) {
+ this.type = element.getType().getQName();
+ }
+ }
+
+ /**
+ * @param element
+ */
+ public XMLType(TypeInfo type) {
+ this.element = null;
+ this.type = type.getQName();
+ }
+
+ public XMLType(QName element, QName type) {
+ this.element = element;
+ this.type = type;
+ }
+
+ /**
+ * @return the type
+ */
+ public QName getTypeName() {
+ return type;
+ }
+
+ public boolean isElement() {
+ return element != null;
+ }
+
+ public QName getElementName() {
+ return element;
+ }
+
+ public void setElementName(QName element) {
+ this.element = element;
+ }
+
+ public void setTypeName(QName type) {
+ this.type = type;
+ }
+
+ public static XMLType getType(QName type) {
+ return new XMLType(null, type);
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((element == null) ? 0 : element.hashCode());
+ result = PRIME * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final XMLType other = (XMLType)obj;
+ if (element == null) {
+ if (other.element != null) {
+ return false;
+ }
+ } else if (!element.equals(other.element)) {
+ return false;
+ }
+ if (type == null) {
+ if (other.type != null) {
+ return false;
+ }
+ } else if (!type.equals(other.type)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Element: " + element + " Type: " + type;
+ }
+
+ public boolean isNillable() {
+ return nillable;
+ }
+
+ public void setNillable(boolean niable) {
+ this.nillable = niable;
+ }
+
+ public boolean isMany() {
+ return many;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
new file mode 100644
index 0000000000..f43c428563
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+
+/**
+ * Definition of binding type which extends from sca:binding
+ */
+public interface BindingType extends ExtensionType {
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java
new file mode 100644
index 0000000000..2da41675a1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.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.policy;
+
+import org.apache.tuscany.sca.policy.impl.PolicyFactoryImpl;
+
+/**
+ * A factory for the policy model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultPolicyFactory extends PolicyFactoryImpl implements PolicyFactory {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
new file mode 100644
index 0000000000..f8f8a48b06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.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.sca.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Definition of extension type: binding or implementation
+ * @tuscany.spi.extension.asclient
+ */
+public interface ExtensionType {
+ QName BINDING_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "binding");
+ QName IMPLEMENTATION_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "implementation");
+
+ /**
+ * The name of the extension type (binding or implementation). The extension type name
+ * attribute MUST be the QName of an XSD global element definition used for
+ * binding/implementation elements of that type
+ *
+ * @return The QName of this type
+ */
+ QName getType();
+
+ /**
+ * Set the QName for this type
+ * @param type The QName of this type
+ */
+ void setType(QName type);
+
+ QName getBaseType();
+
+ /**
+ * A set of intents. The intents in the alwaysProvides set are always
+ * provided by this extension type, whether the intents are attached
+ * to the using component or not.
+ *
+ * @return A list of intents that are always provided by this type
+ */
+ List<Intent> getAlwaysProvidedIntents();
+
+ /**
+ * a set of intents. The intents in the mayProvide set are provided by this
+ * extension type if the intent in question is attached to the using
+ * component.
+ *
+ * @return A list of intents that may be provided by this type
+ */
+ List<Intent> getMayProvidedIntents();
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.java
new file mode 100644
index 0000000000..5bccf51b91
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExternalAttachment.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.sca.policy;
+
+import java.util.List;
+
+import javax.xml.xpath.XPathExpression;
+
+/*
+ * Represents an external attachment element. See the Policy Framework specification for a
+ * description of this element.
+ *
+ * @version $Rev: 937291 $ $Date: 2010-04-23 06:41:24 -0700 (Fri, 23 Apr 2010) $
+ * @tuscany.spi.extension.asclient
+ */
+
+
+public interface ExternalAttachment {
+
+ /**
+ * Get the attachTo attribute
+ * @return
+ */
+ String getAttachTo();
+
+ /**
+ * Set the attachTo attribute
+ * @param name
+ */
+ void setAttachTo(String name);
+
+ /**
+ * Get the compiled XPath attachTo expression
+ * @return
+ */
+ XPathExpression getAttachToXPathExpression();
+
+ /**
+ * Set the compiled XPath attachTo expression
+ * @param expression
+ */
+ void setAttachToXPathExpression(XPathExpression expression);
+
+ /**
+ * Get the policy sets associated with this ExternalAttachment
+ * @return
+ */
+ List<PolicySet> getPolicySets();
+
+ /**
+ * Get the intents associated with this ExternalAttachment
+ * @return
+ */
+ List<Intent> getIntents();
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
new file mode 100644
index 0000000000..d142015f57
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+
+/**
+ * Definition of an implementation type which extends from sca:implementation
+ */
+public interface ImplementationType extends ExtensionType {
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java
new file mode 100644
index 0000000000..b2578fab49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a policy intent. See the Policy Framework specification for a
+ * description of this element.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Intent {
+ enum Type {
+ interaction, implementation
+ };
+
+ /**
+ * Returns the intent name.
+ *
+ * @return the intent name
+ */
+ QName getName();
+
+ /**
+ * Sets the intent name
+ *
+ * @param name the intent name
+ */
+ void setName(QName name);
+
+ /**
+ * Returns the list of SCA constructs that this intent is meant to
+ * configure.
+ *
+ * @return the list of SCA constructs that this intent is meant to configure
+ */
+ List<ExtensionType> getConstrainedTypes();
+
+ /**
+ * Return a list of required intents
+ * @return The list of required intents
+ */
+ List<Intent> getRequiredIntents();
+
+ /**
+ * Returns the list of intents which are mutually exclusive with this intent.
+ *
+ * @return the list of mutually exclusive intents.
+ */
+ List<Intent> getExcludedIntents();
+
+ /**
+ * Returns the list of qualified intents.
+ *
+ * @return the list of qualified intents.
+ */
+ List<Intent> getQualifiedIntents();
+
+ /**
+ * Get the default qualified intent
+ *
+ * @return
+ */
+ Intent getDefaultQualifiedIntent();
+
+ /**
+ * Set the default qualified intent
+ *
+ * @param qualifiedIntent
+ */
+ void setDefaultQualifiedIntent(Intent qualifiedIntent);
+
+ /**
+ * Get the intent type: Interaction or Implementation
+ * @return
+ */
+ Type getType();
+
+ /**
+ * Set the intent type
+ * @param type: Interaction or Implementation
+ */
+ void setType(Type type);
+
+ /**
+ * If this attribute is present and has a value of true it indicates that
+ * the qualified intents defined for this intent are mutually exclusive
+ *
+ * @return
+ */
+ boolean isMutuallyExclusive();
+
+ /**
+ * Set the value of mutuallyExclusive
+ * @param mutuallyExclusive
+ */
+ void setMutuallyExclusive(boolean mutuallyExclusive);
+
+ /**
+ * Returns the intent description.
+ *
+ * @return the intent description
+ */
+ String getDescription();
+
+ /**
+ * Sets the intent description.
+ *
+ * @param description the intent description
+ */
+ void setDescription(String description);
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+
+ /**
+ * Get the parent intent for a qualified intent. If an intent is not qualified,
+ * return null.
+ * @return The parent intent or null if this intent is not qualified
+ */
+ Intent getQualifiableIntent();
+
+ /**
+ * Set the parent intent for a qualified intent
+ * @param intent
+ */
+ void setQualifiableIntent(Intent intent);
+
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
new file mode 100644
index 0000000000..5b401baeb3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy;
+
+import java.util.List;
+
+
+/**
+ * Map policies to the qualified intents
+ */
+public interface IntentMap {
+ /**
+ * Returns the intent realized by this intent map.
+ *
+ * @return the intent realized by this intent map
+ */
+ Intent getProvidedIntent();
+
+ /**
+ * Sets the intent realized by this intent map.
+ *
+ * @param providedIntent the intent realized by this intent map
+ */
+ void setProvidedIntent(Intent providedIntent);
+
+ /**
+ * Get a list of qualifiers
+ *
+ * @return A list of qualifiers
+ */
+ List<Qualifier> getQualifiers();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java
new file mode 100644
index 0000000000..ee4f5b5236
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.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.sca.policy;
+
+import java.util.List;
+
+/**
+ * Attach a policySet to a collection of policy subjects
+ */
+public interface PolicyAttachment {
+ PolicySet getPolicySet();
+ void setPolicySet(PolicySet policySet);
+ List<PolicySubject> getPolicySubjects();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.java
new file mode 100644
index 0000000000..6bb7244e05
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyContainer.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.sca.policy;
+
+/**
+ * Base interface for policy models. Mainly allows policies to hold
+ * other policies
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PolicyContainer {
+ /**
+ * For complex policy models, such as ws-policy,
+ * a policy provider may only match against one of a
+ * number of child policy models
+ *
+ * @return the matching child policy object or null
+ */
+ <T> Object getChildPolicy(Class<T> policyType);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
new file mode 100644
index 0000000000..b7de263789
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Interface that will abstract various types of policy specifications
+ * and attachments for example WS-Policy
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface PolicyExpression {
+ /**
+ * Get the QName of the policy expression
+ * @return the QName of the policy expression
+ */
+ QName getName();
+
+ /**
+ * Set the QName of the policy expression
+ * @param name
+ */
+ void setName(QName name);
+
+ /**
+ * Get the policy definition in the type of the specific domain
+ * @return
+ */
+ <T> T getPolicy();
+
+ /**
+ * Set the policy definition
+ * @param expression
+ */
+ <T> void setPolicy(T policy);
+
+ /**
+ *
+ * @param unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ /**
+ *
+ * @return
+ */
+ boolean isUnresolved();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
new file mode 100644
index 0000000000..b23060dafb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+/**
+ * A factory for the policy model.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface PolicyFactory {
+
+ /**
+ * Create a new intent.
+ *
+ * @return a new intent
+ */
+ Intent createIntent();
+
+ /**
+ * Create a new policy set.
+ *
+ * @return a new policy set
+ */
+ PolicySet createPolicySet();
+
+ /**
+ * Create a new intent map.
+ *
+ * @return a new intent map
+ */
+ IntentMap createIntentMap();
+
+ /**
+ * create a new Qualifier
+ *
+ * @return a Qualifier
+ */
+ Qualifier createQualifier();
+
+ /**
+ * Create a new PolicyExpression
+ * @return
+ */
+ PolicyExpression createPolicyExpression();
+
+ ExtensionType createExtensionType();
+ BindingType createBindingType();
+ ImplementationType createImplementationType();
+
+ /**
+ * Create a new ExternalAttachment
+ * @return
+ */
+ ExternalAttachment createExternalAttachment();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
new file mode 100644
index 0000000000..230d635e76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathExpression;
+
+/**
+ * Represents a policy set. See the Policy Framework specification for a
+ * description of this element.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface PolicySet {
+
+ /**
+ * Returns the intent name.
+ *
+ * @return the intent name
+ */
+ QName getName();
+
+ /**
+ * Sets the intent name
+ *
+ * @param name the intent name
+ */
+ void setName(QName name);
+
+ /**
+ * Returns the list of
+ *
+ * @return
+ */
+ List<PolicySet> getReferencedPolicySets();
+
+ /**
+ * Returns the list of provided intents
+ *
+ * @return
+ */
+ List<Intent> getProvidedIntents();
+
+ /**
+ * Returns the list of concrete policies, either WS-Policy policy
+ * attachments, policy references, or policies expressed in another policy
+ * language.
+ *
+ * @return the list of concrete policies
+ */
+ List<PolicyExpression> getPolicies();
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ /**
+ * Returns the XPath expression that is to be used to evaluate
+ * if this PolicySet applies to specific policy subject
+ *
+ * @return the XPath expression
+ */
+ String getAppliesTo();
+
+ /**
+ * Sets the XPath expression that is to be used to evaluate
+ * if this PolicySet applies to specific policy subject
+ *
+ */
+ void setAppliesTo(String xpath);
+
+ /**
+ * A string which is an XPath 1.0 expression identifying one or more
+ * elements (policy subject) in the Domain. It is used to declare which
+ * set of elements the policySet is actually attached to.
+ *
+ * @return The attachTo XPath
+ */
+ String getAttachTo();
+
+ /**
+ * Set the attachTo XPath
+ * @param xpath
+ */
+ void setAttachTo(String xpath);
+
+ /**
+ * Get the resolved XPathExpression for attachTo
+ * @return
+ */
+ XPathExpression getAttachToXPathExpression();
+
+ /**
+ * Set the resolved XPathExpression for attachTo
+ * @param expression
+ */
+ void setAttachToXPathExpression(XPathExpression expression);
+
+ /**
+ * Returns the policies / policy attachments provided thro intent maps
+ *
+ * @return
+ */
+ List<IntentMap> getIntentMaps();
+
+ /**
+ * Get the XPath expression for the appliesTo attribute
+ * @return the XPath expression for the appliesTo attribute
+ */
+ XPathExpression getAppliesToXPathExpression();
+
+ /**
+ * Set the XPath expression for the appliesTo attribute
+ * @param xpathExpression the XPath expression for the appliesTo attribute
+ */
+ void setAppliesToXPathExpression(XPathExpression xpathExpression);
+
+ /**
+ * Returns true if this PolicySet was attached via external attachment
+ * For unattached and directly attached PolicySets, returns false
+ * @return
+ */
+ boolean isExternalAttachment();
+
+ /**
+ * Sets whether this PolicySet has been attached via external attachment or not
+ * @param value
+ */
+ void setIsExternalAttachment(boolean value);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java
new file mode 100644
index 0000000000..e585fcf384
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.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.policy;
+
+import java.util.List;
+
+/**
+ * A policy subject is an entity in the assembly with which a policy can be
+ * associated.
+ *
+ * For example, a policy subject can be one of the following:
+ * <ul>
+ * <li>composite
+ * <li>component
+ * <li>implementation
+ * <li>service
+ * <li>reference
+ * <li>binding
+ * <li>interface
+ * </ul>
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PolicySubject {
+ /**
+ * Get a list of required intents
+ *
+ * @return
+ */
+ List<Intent> getRequiredIntents();
+
+ /**
+ * Get a list of attached policySets
+ *
+ * @return A list of policySets
+ */
+ List<PolicySet> getPolicySets();
+
+ ExtensionType getExtensionType();
+ void setExtensionType(ExtensionType type);
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java
new file mode 100644
index 0000000000..c1862283c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.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.policy;
+
+import java.util.List;
+
+/**
+ * A qualifier provides a list of policies for a qualified intent within the IntentMap
+ */
+public interface Qualifier {
+ /**
+ * Get the qualified intent for this qualifier
+ * @return The intent
+ */
+ Intent getIntent();
+
+ /**
+ * Set the qualified intent for this qualifier
+ */
+ void setIntent(Intent intent);
+
+ /**
+ * Get the list of policies provided by this qualifier
+ * @return A list of policies
+ */
+ List<PolicyExpression> getPolicies();
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
new file mode 100644
index 0000000000..1a2a9c5bad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.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 org.apache.tuscany.sca.policy.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.BindingType;
+
+/**
+ * Concrete implementation for a BindingType
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindingTypeImpl extends ExtensionTypeImpl implements BindingType {
+ protected BindingTypeImpl() {
+ super();
+ }
+
+ public QName getBaseType() {
+ return BINDING_BASE;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
new file mode 100644
index 0000000000..97fbc19ced
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Concrete implementation for a BindingType
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensionTypeImpl implements ExtensionType {
+
+ private List<Intent> alwaysProvides = new ArrayList<Intent>();
+ private List<Intent> mayProvide = new ArrayList<Intent>();
+ private QName typeName;
+ private boolean unResolved = true;
+
+ protected ExtensionTypeImpl() {
+
+ }
+
+ public List<Intent> getAlwaysProvidedIntents() {
+ return alwaysProvides;
+ }
+
+ public List<Intent> getMayProvidedIntents() {
+ return mayProvide;
+ }
+
+ public QName getType() {
+ return typeName;
+ }
+
+ public void setType(QName type) {
+ this.typeName = type;
+ }
+
+ public boolean isUnresolved() {
+ return unResolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unResolved = unresolved;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getType()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof ExtensionTypeImpl) {
+ if (getType() != null) {
+ return getType().equals(((ExtensionTypeImpl)obj).getType());
+ } else {
+ return ((ExtensionTypeImpl)obj).getType() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return (this.typeName != null) ? getType().toString() : "null";
+ }
+
+ public QName getBaseType() {
+ return null;
+ }
+};
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.java
new file mode 100644
index 0000000000..1e90e26324
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExternalAttachmentImpl.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.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * An implementation of ExternalAttachment
+ *
+ */
+public class ExternalAttachmentImpl implements ExternalAttachment {
+
+ private String attachTo;
+ private List<Intent> intents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private XPathExpression xpath;
+ private boolean isUnresolved;
+
+
+ public String getAttachTo() {
+ return attachTo;
+ }
+
+ public void setAttachTo(String attachTo) {
+ this.attachTo = attachTo;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return this.policySets;
+ }
+
+ public List<Intent> getIntents() {
+ return this.intents;
+ }
+
+ public XPathExpression getAttachToXPathExpression() {
+ return this.xpath;
+ }
+
+ public void setAttachToXPathExpression(XPathExpression expression) {
+ this.xpath = expression;
+ }
+
+ public boolean isUnresolved() {
+ return this.isUnresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.isUnresolved = unresolved;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
new file mode 100644
index 0000000000..5c285e4d95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.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.sca.policy.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.ImplementationType;
+
+/**
+ * Concrete implementation for a Implementation Type
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationTypeImpl extends ExtensionTypeImpl implements ImplementationType {
+ protected ImplementationTypeImpl() {
+ super();
+ }
+
+ public QName getBaseType() {
+ return IMPLEMENTATION_BASE;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
new file mode 100644
index 0000000000..27a77f3ba8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Represents a policy intent.
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntentImpl implements Intent {
+
+ private QName name;
+ private Type type;
+ private List<ExtensionType> constrainedTypes = new ArrayList<ExtensionType>();
+ private String description;
+ private List<Intent> qualifiedIntents = new ArrayList<Intent>();
+ private Intent defaultQualifiedIntent;
+ private Intent parent;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<Intent> excludedIntents = new ArrayList<Intent>();
+ private boolean mutuallyExclusive;
+ private boolean unresolved = true;
+
+ protected IntentImpl() {
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public List<ExtensionType> getConstrainedTypes() {
+ return constrainedTypes;
+ }
+
+ public void setConstrainedTypes(List<ExtensionType> constrainedTypes) {
+ this.constrainedTypes = constrainedTypes;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Intent getQualifiableIntent() {
+ return parent;
+ }
+
+ public void setQualifiableIntent(Intent parent) {
+ this.parent = parent;
+ }
+
+ public List<Intent> getQualifiedIntents() {
+ return qualifiedIntents;
+ }
+
+ public void setQualifiedIntents(List<Intent> qualifiedIntents) {
+ this.qualifiedIntents = qualifiedIntents;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public void setRequiredIntents(List<Intent> requiredIntents) {
+ this.requiredIntents = requiredIntents;
+ }
+
+ public List<Intent> getExcludedIntents() {
+ return excludedIntents;
+ }
+
+ public void setExcludedIntents(List<Intent> excludedIntents) {
+ this.excludedIntents = excludedIntents;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public boolean isMutuallyExclusive() {
+ return mutuallyExclusive;
+ }
+
+ public void setMutuallyExclusive(boolean mutuallyExclusive) {
+ this.mutuallyExclusive = mutuallyExclusive;
+ }
+
+ public Intent getDefaultQualifiedIntent() {
+ return defaultQualifiedIntent;
+ }
+
+ public void setDefaultQualifiedIntent(Intent defaultQualifiedIntent) {
+ this.defaultQualifiedIntent = defaultQualifiedIntent;
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IntentImpl other = (IntentImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
new file mode 100644
index 0000000000..357b7afab4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.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.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * Represents an intent map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntentMapImpl implements IntentMap {
+
+ private boolean unresolved;
+ private Intent providedIntent;
+ private List<Qualifier> qualifiers = new ArrayList<Qualifier>();
+
+ protected IntentMapImpl() {
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public Intent getProvidedIntent() {
+ return providedIntent;
+ }
+
+ public void setProvidedIntent(Intent providedIntent) {
+ this.providedIntent = providedIntent;
+ }
+
+ public List<Qualifier> getQualifiers() {
+ return qualifiers;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IntentMapImpl other = (IntentMapImpl)obj;
+ if (providedIntent == null) {
+ if (other.providedIntent != null)
+ return false;
+ } else if (!providedIntent.equals(other.providedIntent))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
new file mode 100644
index 0000000000..b9f9fa5eb4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+public class PolicyExpressionImpl implements PolicyExpression {
+ private QName name;
+ private Object policy;
+ private boolean unresolved = true;
+
+ protected PolicyExpressionImpl() {
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getPolicy() {
+ return (T)policy;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public <T> void setPolicy(T policy) {
+ this.policy = policy;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PolicyExpressionImpl other = (PolicyExpressionImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
new file mode 100644
index 0000000000..f700f7c41a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.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.sca.policy.impl;
+
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+
+/**
+ * A factory for the policy model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class PolicyFactoryImpl implements PolicyFactory {
+
+ public Intent createIntent() {
+ return new IntentImpl();
+ }
+
+ public PolicySet createPolicySet() {
+ return new PolicySetImpl();
+ }
+
+ public IntentMap createIntentMap() {
+ return new IntentMapImpl();
+ }
+
+ public Qualifier createQualifier() {
+ return new QualifierImpl();
+ }
+
+ public PolicyExpression createPolicyExpression() {
+ return new PolicyExpressionImpl();
+ }
+
+ public BindingType createBindingType() {
+ return new BindingTypeImpl();
+ }
+
+ public ImplementationType createImplementationType() {
+ return new ImplementationTypeImpl();
+ }
+
+ public ExtensionType createExtensionType() {
+ return new ExtensionTypeImpl();
+ }
+
+ public ExternalAttachment createExternalAttachment() {
+ return new ExternalAttachmentImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
new file mode 100644
index 0000000000..22e6e4d4cf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a policy set.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicySetImpl implements PolicySet {
+
+ private QName name;
+ private String appliesTo;
+ private String attachTo;
+ private List<Intent> providedIntents = new ArrayList<Intent>();
+ private List<PolicySet> referencedPolicySets = new ArrayList<PolicySet>();
+ private boolean unresolved = true;
+
+ private XPathExpression appliesToXPathExpression;
+ private XPathExpression attachToXPathExpression;
+
+ private List<IntentMap> intentMaps = new ArrayList<IntentMap>();
+ private List<PolicyExpression> policies = new ArrayList<PolicyExpression>();
+ private boolean isExternalAttachment;
+
+ public QName getName() {
+ return name;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public String getAppliesTo() {
+ return appliesTo;
+ }
+
+ public void setAppliesTo(String appliesTo) {
+ this.appliesTo = appliesTo;
+ }
+
+ public String getAttachTo() {
+ return attachTo;
+ }
+
+ public void setAttachTo(String attachTo) {
+ this.attachTo = attachTo;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public XPathExpression getAppliesToXPathExpression() {
+ return appliesToXPathExpression;
+ }
+
+ public void setAppliesToXPathExpression(XPathExpression appliesToXPathExpression) {
+ this.appliesToXPathExpression = appliesToXPathExpression;
+ }
+
+ public XPathExpression getAttachToXPathExpression() {
+ return attachToXPathExpression;
+ }
+
+ public void setAttachToXPathExpression(XPathExpression attachToXPathExpression) {
+ this.attachToXPathExpression = attachToXPathExpression;
+ }
+
+ public List<IntentMap> getIntentMaps() {
+ return intentMaps;
+ }
+
+ public List<Intent> getProvidedIntents() {
+ return providedIntents;
+ }
+
+ public List<PolicySet> getReferencedPolicySets() {
+ return referencedPolicySets;
+ }
+
+ public List<PolicyExpression> getPolicies() {
+ return policies;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PolicySetImpl other = (PolicySetImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ public boolean isExternalAttachment() {
+ return this.isExternalAttachment;
+ }
+
+ public void setIsExternalAttachment(boolean value) {
+ this.isExternalAttachment = value;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
new file mode 100644
index 0000000000..102bea8d41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+public class QualifierImpl implements Qualifier {
+ private Intent intent;
+ private List<PolicyExpression> policies = new ArrayList<PolicyExpression>();
+
+ protected QualifierImpl() {
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+
+ public List<PolicyExpression> getPolicies() {
+ return policies;
+ }
+
+ public void setIntent(Intent intent) {
+ this.intent = intent;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java
new file mode 100644
index 0000000000..8a4adb3d7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * A utility that helps to navigate the policy model
+ * @tuscany.spi.extension.asclient
+ */
+public class PolicyHelper {
+ public PolicySet getPolicySet(PolicySubject subject, QName policySetName) {
+ for (PolicySet ps : subject.getPolicySets()) {
+ if (ps.getName().equals(policySetName)) {
+ return ps;
+ }
+ }
+ return null;
+ }
+
+ public Intent getIntent(Definitions subject, QName intentName) {
+ for (Intent i : subject.getIntents()) {
+ if (i.getName().equals(intentName)) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ public PolicySet getPolicySet(Definitions subject, QName policySetName) {
+ for (PolicySet ps : subject.getPolicySets()) {
+ if (ps.getName().equals(policySetName)) {
+ return ps;
+ }
+ }
+ return null;
+ }
+
+ public Intent getIntent(PolicySubject subject, QName intentName) {
+ for (Intent i : subject.getRequiredIntents()) {
+ if (i.getName().equals(intentName)) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ public Collection<PolicyExpression> getPolicyExpressions(PolicySubject subject, QName policyName) {
+ Collection<PolicyExpression> policies = new ArrayList<PolicyExpression>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ if (exp.getName().equals(policyName)) {
+ policies.add(exp);
+ }
+ }
+ }
+ return policies;
+ }
+
+ public Collection<Object> getPolicies(PolicySubject subject, QName policyName) {
+ Collection<Object> policies = new ArrayList<Object>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ if (exp.getName().equals(policyName)) {
+ policies.add(exp.getPolicy());
+ }
+ }
+ }
+ return policies;
+ }
+
+ public static PolicySet getPolicySet(Binding wsBinding, QName intentName) {
+ PolicySet returnPolicySet = null;
+
+ if (wsBinding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)wsBinding;
+ for (PolicySet policySet : policiedBinding.getPolicySets()) {
+ for (Intent intent : policySet.getProvidedIntents()) {
+ if (intent.getName().equals(intentName)) {
+ returnPolicySet = policySet;
+ break;
+ }
+ }
+ }
+ }
+
+ return returnPolicySet;
+ }
+
+ public static boolean isIntentRequired(Binding wsBinding, QName intent) {
+ if (wsBinding instanceof PolicySubject) {
+ List<Intent> intents = ((PolicySubject)wsBinding).getRequiredIntents();
+ for (Intent i : intents) {
+ if (intent.equals(i.getName())) {
+ return true;
+ }
+ }
+ }
+ return getPolicySet(wsBinding, intent) != null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
new file mode 100644
index 0000000000..20189eae98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
@@ -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.assembly.DefaultAssemblyFactory
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory
new file mode 100644
index 0000000000..6e24d0bcfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory
@@ -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.
+
+org.apache.tuscany.sca.assembly.impl.SCABindingFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint
new file mode 100644
index 0000000000..61171ac041
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint
@@ -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.assembly.builder.DefaultBuilderExtensionPoint
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory
new file mode 100644
index 0000000000..c1cb41d967
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.definitions.DefaultDefinitionsFactory
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper
new file mode 100644
index 0000000000..e2da378609
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper
@@ -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.
+
+org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory
new file mode 100644
index 0000000000..6ff07189e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory
@@ -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.policy.DefaultPolicyFactory
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties
new file mode 100644
index 0000000000..8ded10c9db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties
@@ -0,0 +1,327 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+# C.1 Mandatory Items
+ASM13001=\
+An SCA runtime MUST reject a composite file that does not conform to the sca-core.xsd, sca-interface-wsdl.xsd, sca-implementation-composite.xsd and sca-binding-sca.xsd schema.
+ASM13002=\
+An SCA runtime MUST reject a contribution file that does not conform to the sca-contribution.xsd schema.
+ASM13003=\
+An SCA runtime MUST reject a definitions file that does not conform to the sca-definitions.xsd schema.
+ASM40001=\
+The extension of a componentType side file name MUST be .componentType.
+ASM40002=\
+If present, the @constrainingType attribute of a <componentType/> element MUST reference a <constrainingType/> element in the Domain through its QName.
+ASM40003=\
+The @name attribute of a <service/> child element of a <componentType/> MUST be unique amongst the service elements of that <componentType/>.
+ASM40004=\
+The @name attribute of a <reference/> child element of a <componentType/> MUST be unique amongst the reference elements of that <componentType/>.
+ASM40005=\
+The @name attribute of a <property/> child element of a <componentType/> MUST be unique amongst the property elements of that <componentType/>.
+ASM40006=\
+If @wiredByImpl is set to "true", then any reference targets configured for this reference MUST be ignored by the runtime.
+ASM40007=\
+The value of the property @type attribute MUST be the QName of an XML schema type.
+ASM40008=\
+The value of the property @element attribute MUST be the QName of an XSD global element.
+ASM40009=\
+The SCA runtime MUST ensure that any implementation default property value is replaced by a value for that property explicitly set by a component using that implementation.
+ASM40010=\
+A single property element MUST NOT contain both a @type attribute and an @element attribute.
+ASM40011=\
+When the componentType has @mustSupply="true" for a property element, a component using the implementation MUST supply a value for the property since the implementation has no default value for the property.
+ASM50001=\
+The @name attribute of a <component/> child element of a <composite/> MUST be unique amongst the component elements of that <composite/>
+ASM50002=\
+The @name attribute of a service element of a <component/> MUST be unique amongst the service elements of that <component/>
+ASM50003=\
+The @name attribute of a service element of a <component/> MUST match the @name attribute of a service element of the componentType of the <implementation/> child element of the component.
+ ASM50004=\
+If an interface is declared for a component service, the interface MUST provide a compatible subset of the interface declared for the equivalent service in the componentType of the implementation
+ ASM50005=\
+If no binding elements are specified for the service, then the bindings specified for the equivalent service in the componentType of the implementation MUST be used, but if the componentType also has no bindings specified, then <binding.sca/> MUST be used as the binding. If binding elements are specified for the service, then those bindings MUST be used and they override any bindings specified for the equivalent service in the componentType of the implementation.
+ASM50006=\
+If the callback element is present and contains one or more binding child elements, then those bindings MUST be used for the callback.
+ASM50007=\
+The @name attribute of a reference element of a <component/> MUST be unique amongst the reference elements of that <component/>
+
+ASM50008=\
+The @name attribute of a reference element of a <component/> MUST match the @name attribute of a reference element of the componentType of the <implementation/> child element of the component.
+ASM50009=\
+The value of multiplicity for a component reference MUST only be equal or further restrict any value for the multiplicity of the reference with the same name in the componentType of the implementation, where further restriction means 0..n to 0..1 or 1..n to 1..1.
+ASM50010=\
+If @wiredByImpl="true" is set for a reference, then the reference MUST NOT be wired statically within a composite, but left unwired.
+ ASM50011=\
+If an interface is declared for a component reference, the interface MUST provide a compatible superset of the interface declared for the equivalent reference in the componentType of the implementation.
+ASM50012=\
+If no binding elements are specified for the reference, then the bindings specified for the equivalent reference in the componentType of the implementation MUST be used. If binding elements are specified for the reference, then those bindings MUST be used and they override any bindings specified for the equivalent reference in the componentType of the implementation.
+ASM50013=\
+If @wiredByImpl="true", other methods of specifying the target service MUST NOT be used.
+ASM50014=\
+If @autowire="true", the autowire procedure MUST only be used if no target is identified by any of the other ways listed above. It is not an error if @autowire="true" and a target is also defined through some other means, however in this case the autowire procedure MUST NOT be used.
+ASM50015=\
+If a binding element has a value specified for a target service using its @uri attribute, the binding element MUST NOT identify target services using binding specific attributes or elements.
+ASM50016=\
+It is possible that a particular binding type uses more than a simple URI for the address of a target service. In cases where a reference element has a binding subelement that uses more than simple URI, the @uri attribute of the binding element MUST NOT be used to identify the target service - in this case binding specific attributes and/or child elements MUST be used.
+ASM50018=\
+A reference with multiplicity 0..1 or 0..n MAY have no target service defined.
+ASM50019=\
+A reference with multiplicity 0..1 or 1..1 MUST NOT have more that one target service defined.
+ASM50020=\
+A reference with multiplicity 1..1 or 1..n MUST have at least one target service defined.
+ASM50021=\
+A reference with multiplicity 0..n or 1..n MAY have one or more target services defined.
+ASM50022=\
+Where it is detected that the rules for the number of target services for a reference have been violated, either at deployment or at execution time, an SCA Runtime MUST raise an error no later than when the reference is invoked by the component implementation.
+ASM50025=\
+Where a component reference is promoted by a composite reference, the promotion MUST be treated from a multiplicity perspective as providing 0 or more target services for the component reference, depending upon the further configuration of the composite reference. These target services are in addition to any target services identified on the component reference itself, subject to the rules relating to multiplicity.
+ASM50026=\
+If a reference has a value specified for one or more target services in its @target attribute, there MUST NOT be any child <binding/> elements declared for that reference.
+ASM50027=\
+If the @value attribute of a component property element is declared, the type of the property MUST be an XML Schema simple type and the @value attribute MUST contain a single value of that type.
+ASM50028=\
+If the value subelement of a component property is specified, the type of the property MUST be an XML Schema simple type or an XML schema complex type.
+ASM50029=\
+If a component property value is declared using a child element of the <property/> element, the type of the property MUST be an XML Schema global element and the declared child element MUST be an instance of that global element.
+ASM50030=\
+A <component/> element MUST NOT contain two <property/> subelements with the same value of the @name attribute.
+ASM50031=\
+The @name attribute of a property element of a <component/> MUST be unique amongst the property elements of that <component/>.
+ASM50032
+If a property is single-valued, the <value/> subelement MUST NOT occur more than once.
+ASM50033=\
+A property <value/> subelement MUST NOT be used when the @value attribute is used to specify the value for that property.
+ASM50034=\
+If any <wire/> element with its @replace attribute set to "true" has a particular reference specified in its @source attribute, the value of the @target attribute for that reference MUST be ignored and MUST NOT be used to define target services for that reference.
+ASM50035=\
+A single property element MUST NOT contain both a @type attribute and an @element attribute.
+ASM50036=\
+The property type specified for the property element of a component MUST be compatible with the type of the property with the same @name declared in the component type of the implementation used by the component. If no type is declared in the component property element, the type of the property declared in the componentType of the implementation MUST be used.
+ASM50037=\
+The @name attribute of a property element of a <component/> MUST match the @name attribute of a property element of the componentType of the <implementation/> child element of the component.
+ASM50038=\
+In these cases where the types of two property elements are matched, the types declared for the two <property/> elements MUST be compatible
+ASM50039=\
+A reference with multiplicity 0..1 MUST have no more than one target service defined.
+ASM50040=\
+A reference with multiplicity 1..1 MUST have exactly one target service defined.
+ASM50041=\
+A reference with multiplicity 1..n MUST have at least one target service defined.
+ASM50042=\
+If a component reference has @multiplicity 0..1 or 1..1 and @nonOverridable==true, then the component reference MUST NOT be promoted by any composite reference.
+ASM60001=\
+A composite @name attribute value MUST be unique within the namespace of the composite.
+ASM60002=\
+@local="true" for a composite means that all the components within the composite MUST run in the same operating system process.
+ASM60003=\
+The name of a composite <service/> element MUST be unique across all the composite services in the composite.
+ASM60004=\
+A composite <service/> element's @promote attribute MUST identify one of the component services within that composite.
+ASM60005=\
+If a composite service interface is specified it MUST be the same or a compatible subset of the interface provided by the promoted component service.
+ASM60006=\
+The name of a composite <reference/> element MUST be unique across all the composite references in the composite.
+ASM60007=\
+Each of the URIs declared by a composite reference's @promote attribute MUST identify a component reference within the composite.
+ASM60008=\
+the interfaces of the component references promoted by a composite reference MUST be the same, or if the composite reference itself declares an interface then each of the component reference interfaces MUST be a compatible subset of the composite reference interface..
+ASM60009=\
+the intents declared on a composite reference and on the component references which it promoites MUST NOT be mutually exclusive.
+ASM60010=\
+If any intents in the set which apply to a composite reference are mutually exclusive then the SCA runtime MUST raise an error.
+ASM60011=\
+The value specified for the @multiplicity attribute of a composite reference MUST be compatible with the multiplicity specified on each of the component references which it promotes, i.e. the multplicity of the composite reference MUST be equal to or further restrict the multiplicity of the component reference, except for the case where all the promoted component references have at least one target declared in which case a composite reference of 0..1 is compatble with component references of 1..1 and composite reference of 0..n is compatible with component references of 1..n.
+ASM60012=\
+If a composite reference has an interface specified, it MUST provide an interface which is the same or which is a compatible superset of the interface(s) declared by the promoted component reference(s).
+ASM60013=\
+If no interface is declared on a composite reference, the interface from one of its promoted component references MUST be used for the component type associated with the composite.
+ASM60014=\
+The @name attribute of a composite property MUST be unique amongst the properties of the same composite.
+ASM60022=\
+For each component reference for which autowire is enabled, the SCA runtime MUST search within the composite for target services which have an interface that is a compatible superset of the interface of the reference.
+ASM60024=\
+The intents, and policies applied to the service MUST be compatible with those on the reference when using autowire to wire a reference - so that wiring the reference to the service will not cause an error due to policy mismatch
+ASM60025=\
+for an autowire reference with multiplicity 0..1 or 1..1, the SCA runtime MUST wire the reference to one of the set of valid target services chosen from the set in a runtime-dependent fashion
+ASM60026=\
+for an autowire reference with multiplicity 0..n or 1..n, the reference MUST be wired to all of the set of valid target services
+ASM60027=\
+for an autowire reference with multiplicity 0..1 or 0..n, if the SCA runtime finds no valid target service, there is no problem - no services are wired and the SCA runtime MUST NOT raise an error
+ASM60028=\
+for an autowire reference with multiplicity 1..1 or 1..n, if the SCA runtime finds no valid target services an error MUST be raised by the SCA runtime since the reference is intended to be wired
+ASM60030=\
+The @name attribute of an <implementation.composite/> element MUST contain the QName of a composite in the SCA Domain.
+ASM60031=\
+The SCA runtime MUST raise an error if the composite resulting from the inclusion of one composite into another is invalid.
+ASM60032=\
+For a composite used as a component implementation, each composite service offered by the composite MUST promote a component service of a component that is within the composite.
+ASM60033=\
+For a composite used as a component implementation, every component reference of components within the composite with a multiplicity of 1..1 or 1..n MUST be wired or promoted.
+ASM60034=\
+For a composite used as a component implementation, all properties of components within the composite, where the underlying component implementation specifies "mustSupply=true" for the property, MUST either specify a value for the property or source the value from a composite property.
+ASM60035=\
+All the component references promoted by a single composite reference MUST have the same value for @wiredByImpl.
+ASM60036=\
+If the @wiredByImpl attribute is not specified on the composite reference, the default value is "true" if all of the promoted component references have a wiredByImpl value of "true", and the default value is "false" if all the promoted component references have a wiredByImpl value of "false". If the @wiredByImpl attribute is specified, its value MUST be "true" if all of the promoted component references have a wiredByImpl value of "true", and its value MUST be "false" if all the promoted component references have a wiredByImpl value of "false".
+ASM60037=\
+<include/> processing MUST take place before the processing of the @promote attribute of a composite reference is performed.
+ASM60038=\
+<include/> processing MUST take place before the processing of the @promote attribute of a composite service is performed.
+ASM60039=\
+<include/> processing MUST take place before the @source and @target attributes of a wire are resolved.
+ASM60040=\
+A single property element MUST NOT contain both a @type attribute and an @element attribute.
+ASM60041=\
+If the included composite has the value true for the attribute @local then the including composite MUST have the same value for the @local attribute, else it is an error.
+ASM60042=\
+The @name attribute of an include element MUST be the QName of a composite in the SCA Domain.
+ASM60043=\
+The interface declared by the target of a wire MUST be a compatible superset of the interface declared by the source of the wire.
+ASM60044=\
+If the composite reference promotes multiple component references with different multiplicities, there is no default value for the @multiplicity attribute of the composite reference and a value for @multiplicity MUST be specified.
+ASM70001=\
+The constrainingType specifies the services, references and properties that MUST be provided by the implementation of the component to which the constrainingType is attached.
+ASM70002=\
+If the configuration of the component or its implementation does not conform to the constrainingType specified on the component element, the SCA runtime MUST raise an error.
+ASM70003=\
+The @name attribute of the constraining type MUST be unique in the SCA Domain.
+ASM70004=\
+When an implementation is constrained by a constrainingType its component type MUST contain all the services, references and properties specified in the constrainingType.
+ASM70005=\
+An implementation that is constrained by a constrainingType MUST NOT contain additional references with @multiplicity=1..1 or @multiplicity=1..n or additional properties with @mustSupply=true
+ASM70006=\
+Additional services, references and properties provided by the implementation which are not declared in the constrainingType associated with a component MUST NOT be configured in any way by the containing composite.
+ASM70007=\
+When an implementation is constrained by a constrainingType and the constrainingType declares an interface for a service or for a reference, then the component type of the implementation MUST contain a declaration of a compatiible interface for that service or reference.
+ASM80001=\
+The interface.wsdl @interface attribute MUST reference a portType of a WSDL 1.1 document.
+ASM80002=\
+Remotable service Interfaces MUST NOT make use of method or operation overloading.
+ASM80003=\
+If a remotable service is called locally or remotely, the SCA container MUST ensure sure that no modification of input messages by the service or post-invocation modifications to return messages are seen by the caller.
+ASM80004=\
+If a reference is defined using a bidirectional interface element, the client component implementation using the reference calls the referenced service using the interface. The client MUST provide an implementation of the callback interface.
+ASM80005=\
+Either both interfaces of a bidirectional service MUST be remotable, or both MUST be local. A bidirectional service MUST NOT mix local and remote services.
+ASM80008=\
+Any service or reference that uses an interface marked with intents MUST implicitly add those intents to its own @requires list.
+ASM80009=\
+In a bidirectional interface, the service interface can have more than one operation defined, and the callback interface can also have more than one operation defined. SCA runtimes MUST allow an invocation of any operation on the service interface to be followed by zero, one or many invocations of any of the operations on the callback interface.
+ASM80010=\
+Whenever an interface document declaring a callback interface is used in the declaration of an <interface/> element in SCA, it MUST be treated as being bidirectional with the declared callback interface.
+ASM80011=\
+If an <interface/> element references an interface document which declares a callback interface and also itself contains a declaration of a callback interface, the two callback interfaces MUST be compatible.
+ASM80016=\
+The interface.wsdl @callbackInterface attribute, if present, MUST reference a portType of a WSDL 1.1 document.
+ASM80017=\
+WSDL interfaces are always remotable and therefore an <interface.wsdl/> element MUST NOT contain remotable="false".
+ASM90001=\
+For a binding of a reference the @uri attribute defines the target URI of the reference. This MUST be either the componentName/serviceName for a wire to an endpoint within the SCA Domain, or the accessible address of some service endpoint either inside or outside the SCA Domain (where the addressing scheme is defined by the type of the binding).
+ASM90002=\
+When a service or reference has multiple bindings, only one binding can have the default @name value; all others MUST have a @name value specified that is unique within the service or reference.
+ASM90003=\
+If a reference has any bindings, they MUST be resolved, which means that each binding MUST include a value for the @uri attribute or MUST otherwise specify an endpoint. The reference MUST NOT be wired using other SCA mechanisms.
+ ASM90004=\
+To wire to a specific binding of a target service the syntax "componentName/serviceName/bindingName" MUST be used.
+ASM10001=\
+all of the QNames for the definitions contained in definitions.xml files MUST be unique within the Domain.
+ASM10002=\
+An SCA runtime MUST make available to the Domain all the artifacts contained within the definitions.xml files in the Domain.
+ASM10003=\
+An SCA runtime MUST reject a definitions.xml file that does not conform to the sca-definitions.xsd schema.
+ASM12001=\
+For any contribution packaging it MUST be possible to present the artifacts of the packaging to SCA as a hierarchy of resources based off of a single root
+ASM12005=\
+Where present, artifact-related or packaging-related artifact resolution mechanisms MUST be used by the SCA runtime to resolve artifact dependencies.
+ASM12006=\
+SCA requires that all runtimes MUST support the ZIP packaging format for contributions.
+ASM12009=\
+if there is ever a conflict between two indirect dependent contributions, then the conflict MUST be resolved by an explicit entry in the dependent contribution list.
+ASM12010=\
+Where present, non-SCA artifact resolution mechanisms MUST be used by the SCA runtime in precendence to the SCA mechanisms.
+ ASM12011=\
+If one of the non-SCA artifact resolution mechanisms is present, but there is a failure to find the resource indicated when using the mechanism (e.g. the URI is incorrect or invalid, say) the SCA runtime MUST raise an error and MUST NOT attempt to use SCA resolution mechanisms as an alternative.
+ASM12012=\
+The value of @autowire for the logical Domain composite MUST be autowire="false".
+ASM12013=\
+For components at the Domain level, with references for which @autowire="true" applies, the behaviour of the SCA runtime for a given Domain MUST take ONE of the 3 following forms:\
+1) The SCA runtime disallows deployment of any components with autowire references. In this case, the SCA runtime MUST raise an exception at the point where the component is deployed.\
+2) The SCA runtime evaluates the target(s) for the reference at the time that the component is deployed and does not update those targets when later deployment actions occur. \
+3) The SCA runtime re-evaluates the target(s) for the reference dynamically as later deployment actions occur resulting in updated reference targets which match the new Domain configuration. How the reconfiguration of the reference takes place is described by the relevant client and implementation specifications.
+ASM12015=\
+Where components are updated by deployment actions (their configuration is changed in some way, which includes changing the wires of component references), the new configuration MUST apply to all new instances of those components once the update is complete.
+ASM12017=\
+Where a component that is the target of a wire is removed, without the wire being changed, then future invocations of the reference that use that wire SHOULD fail with a ServiceUnavailable fault. If the wire is the result of the autowire process, the SCA runtime MUST:\
+* either cause future invocation of the target component's services to fail with a ServiceUnavailable fault\
+* or alternatively, if an alternative target component is available that satisfies the autowire process, update the reference of the source component
+ASM12020=\
+Where a component is added to the Domain that is a potential target for a domain level component reference where that reference is marked as @autowire=true, the SCA runtime MUST:\
+- either update the references for the source component once the new component is running. \
+- or alternatively, defer the updating of the references of the source component until the source component is stopped and restarted.
+ASM12021=\
+The SCA runtime MUST raise an error if an artifact cannot be resolved using these mechanisms, if present.
+ASM12022=\
+There can be multiple import declarations for a given namespace. Where multiple import declarations are made for the same namespace, all the locations specified MUST be searched in lexical order.
+ASM12023=\
+When a contribution contains a reference to an artifact from a namespace that is declared in an import statement of the contribution, if the SCA artifact resolution mechanism is used to resolve the artifact, the SCA runtime MUST resolve artifacts in the following order:\
+1. from the locations identified by the import statement(s) for the namespace. Locations MUST NOT be searched recursively in order to locate artifacts (i.e. only a one-level search is performed).\
+2. from the contents of the contribution itself.
+ASM12024=\
+The SCA runtime MUST ignore local definitions of an artifact if the artifact is found through resolving an import statement.
+ASM12025=\
+The SCA runtime MUST raise an error if an artifact cannot be resolved by using artifact-related or packaging-related artifact resolution mechanisms, if present, by searching locations identified by the import statements of the contribution, if present, and by searching the contents of the contribution.
+ASM12026=\
+An SCA runtime MUST make the <import/> and <export/> elements found in the META-INF/sca-contribution.xml and META-INF/sca-contribution-generated.xml files available for the SCA artifact resolution process.
+ASM12027=\
+An SCA runtime MUST reject files that do not conform to the schema declared in sca-contribution.xsd.
+ASM12028=\
+An SCA runtime MUST merge the contents of sca-contribution-generated.xml into the contents of sca-contribution.xml, with the entries in sca-contribution.xml taking priority if there are any conflicting declarations.
+ASM12031=\
+When a contribution uses an artifact contained in another contribution through SCA artifact resolution, if that artifact itself has dependencies on other artifacts, the SCA runtime MUST resolve these dependencies in the context of the contribution containing the artifact, not in the context of the original contribution.
+ASM14003=\
+Where errors are only detected at runtime, when the error is detected an error MUST be raised to the component that is attempting the activity concerned with the error.
+
+# C.2 Non-mandatory Items
+ASM60021=\
+For the case of an un-wired reference with multiplicity 1..1 or 1..n the deployment process provided by an SCA runtime SHOULD issue a warning.
+ASM12002=\
+Within any contribution packaging A directory resource SHOULD exist at the root of the hierarchy named META-INF
+ASM12003=\
+Within any contribution packaging a document SHOULD exist directly under the META-INF directory named sca-contribution.xml which lists the SCA Composites within the contribution that are runnable.
+ASM12007=\
+Implementations of SCA MAY also raise an error if there are conflicting names exported from multiple contributions.
+ASM12008=\
+An SCA runtime MAY provide the contribution operation functions (install Contribution, update Contribution, add Deployment Composite, update Deployment Composite, remove Contribution).
+ASM12014=\
+Where <wire/> elements are added, removed or replaced by deployment actions, the components whose references are affected by those deployment actions MAY have their references updated by the SCA runtime dynamically without the need to stop and start those components.
+ASM12016=\
+An SCA runtime MAY choose to maintain existing instances with the old configuration of components updated by deployment actions, but an SCA runtime MAY choose to stop and discard existing instances of those components.
+ASM12018=\
+Where a component that is the target of a wire is updated, future invocations of that reference SHOULD use the updated component.
+ASM12029=\
+An SCA runtime MAY deploy the composites in <deployable/> elements found in the META-INF/sca-contribution.xml and META-INF/sca-contribution-generated.xml files.
+ASM12030=\
+For XML definitions, which are identified by QNames, the @namespace attribute of the export element SHOULD be the namespace URI for the exported definitions.
+ASM14001=\
+An SCA runtime SHOULD detect errors at deployment time where those errors can be found through static analysis.
+ASM14002=\
+The SCA runtime SHOULD prevent deployment of contributions that are in error, and raise the error to the process performing the deployment (e.g. write a message to an interactive console or write a message to a log file).
+ASM14004=\
+When an error that could have been detected through static analysis is detected and raised at runtime for a component, the component SHOULD NOT be run until the error is fixed.
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
new file mode 100644
index 0000000000..91b1721bf7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
@@ -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.
+#
+DuplicateComponentName = [ASM50001] Duplicate component name: Composite = {0} Component = {1}
+DuplicateComponentServiceName = Duplicate component service name: Component = {0} Service = {1}
+DuplicateComponentReferenceName = Duplicate component reference name: Component = {0} Reference = {1}
+DuplicateComponentPropertyName = Duplicate component property name: Component = {0} Property = {1}
+NoComponentImplementation = No implementation for component: Component = {0}
+ServiceNotFoundForComponentService = Component type service not found for component service (missing @Remotable annotation?): Component = {0} Service = {1}
+UnresolvedComponentImplementation = [ASM60030,JCI50004,JCI80001] Component implementation not resolved: Component = {0} Uri = {1}
+DuplicateImplementationPropertyName = [ASM40005,ASM60014] Duplicate implementation property name: Component = {0} Property = {1}
+DuplicateImplementationServiceName = [ASM40003,ASM60003,JCA90045] Duplicate implementation service name: Component = {0} Service = {1}
+DuplicateImplementationReferenceName = [ASM40004,ASM50007,ASM60006] Duplicate implementation reference name: Component = {0} Reference = {1}
+PropertyNotFound = [ASM50031] Property not found for component property: Component = {0} Property = {1}
+PropertyMustSupplyIncompatible = Component property mustSupply attribute incompatible with property: Component = {0} Property = {1}
+PropertyMustSupplyNull = [ASM40011,ASM60034] No value configured on a mustSupply property: Component = {0} Property = {1}
+PropertyOverrideManyAttribute = Component property many attribute incompatible with property: Component = {0} Property = {1}
+ReferenceNotFoundForComponentReference = [ASM50008] Component type reference not found for component reference: Component = {0} Reference = {1}
+CompositeReferenceIncompatibleMultiplicity = [ASM60011] Composite reference multiplicity incompatible with component reference multiplicity: Composite = {0} Composite reference = {1} Component reference = {2}
+ReferenceIncompatibleMultiplicity = [ASM50009] Component reference multiplicity incompatible with reference multiplicity: Component = {0} Reference = {1}
+ReferenceIncompatibleInterface = Incompatible interfaces on component reference and target: Composite = {0} Reference = {1} Service = {2}
+ReferencePromotionIncompatibleInterface = Promoted reference interface incompatible with promoting reference: Promoting interface = {0} Promoted = {1}
+ReferencePromotionInterfacesNotEqual = Peer promoted references not equal: First interface = {0} second interface = {1}
+ReferenceIncompatibleComponentInterface = [JCA30001,JCA30002,JCA30003,JCA90046] Component reference interface incompatible with implementation reference interface: Component = {0} Reference = {1} {2}
+ServiceIncompatibleComponentInterface = [ASM50004,JCA30002,JCI80001] Component service interface incompatible with implementation service interface: Component = {0} Service = {1} {2}
+MultipleBindingsForService = Multiple bindings with the same name for a service: Service = {0} Binding name = {1}
+MultipleBindingsForReference = Multiple bindings with the same name for a reference: Reference = {0} Binding name = {1}
+ReferenceWithoutTargets = [ASM60033] No targets for reference: Composite = {0} Reference = {1}
+PromotedReferenceNotFound = [ASM60007] Promoted component reference not found: Composite = {0} Reference = {1}
+PromotedServiceNotFound = [ASM60004,ASM60032] Promoted component service not found: Composite = {0} Service = {1}
+NoSCABindingAvailableForUnresolvedService = A local service cannot be found for reference {0} target {1} and there is no SCA binding available to represent the unresolved target
+NoMatchingBinding = Component reference {0} does not have a binding which matches the bindings of service {1}
+NoMatchingCallbackBinding = Component reference {0} does not have a callback binding which matches the callback bindings of service {1}
+ReferenceEndPointMixWithTarget = [ASM50026] Composite {0} Component {1} Reference {2} must not specify endpoints using both target attribute and with a binding child element
+CompositeAlreadyIncluded = Composite {0} has already been included.
+ComponentReferenceMoreWire = Component reference {0} has more than one wires
+WireTargetNotFound = Wire target not found : {0}
+WireSourceNotFound = Wire source not found : {0}
+WireIncompatibleInterface = Incompatible interfaces on wire source and target : source = {0} target = {1}
+ComponentIncompatibleInterface = Incompatible interfaces on component reference and target : reference = {0} target = {1}
+TooManyReferenceTargets = [ASM50022] Too many targets on reference: {0}
+ReferenceInterfaceNotSubSet = [ASM60008,ASM60013] Interface of composite reference {0} must be compatible with the interface declared by promoted component reference. {1}
+ServiceInterfaceNotSubSet = Interface of composite service {0} must be subset of the interface declared by promoted component service. {1}
+NoComponentReferenceTarget = [ASM60028] No target services found for the component reference to be autowired: {0}
+NoTypeForComponentProperty = No type specified on component property: Component = {0} Property = {1}
+URLSyntaxException = URLSyntaxException when creating binding URI at component = {0} service = {1} binding = {2}
+IllegalCompositeIncusion = Local Composite {0} cannot include a non-local composite {1}
+PropertySourceNotFound = The property source {0} for property {1} in component {2} cannot be resolved to a composite property
+PropertySourceValueInvalid = The property source {0} for property {1} in component {2} has an invalid value. It should start with $ followed by the name of a composite property
+PropertySourceXPathInvalid = The property source {0} for property {1} in component {2} has an invalid XPath expression. The following error was returned while processing the XPath expression: {3}
+PropertyFileValueInvalid = The property file {0} for property {1} in component {2} is an invalid value. The following error was returned while processing the file name: {3}
+PolicyRelatedException = Policy Related Exception occured due to : {0}
+IntentNotFound = Intent {0} is not defined in SCA definitions
+PolicySetNotFound = PolicySet {0} is not defined in SCA definitions
+MutuallyExclusiveIntents = [POL40009,ASM60009,ASM60010] Intent {0} and {1} are mutually exclusive
+PropertyXpathExpressionReturnedNull = The property XPath expression for component {0} property {1} expression {2} did not match anything in the source property
+PropertyHasManyValues = [ASM50032] The property component {0} property {1} has many values but its "many" attribute is set to false
+PropertXSDTypesDontMatch = [ASM_5036] The property component {0} property {1} has XSD type {2} while its component type property has the XSD type {3}
+PropertXSDElementsDontMatch = [ASM_5036] The property component {0} property {1} has XSD element {2} while its component type property has the XSD element {3}
+IntentNotSatisfied = The intent {0} associated with policy subject {1} has no matching policy set
+URIFoundOnServiceSCABinding = [ASM90005] The SCA binding {0} on component {1} service {2} should not have a URI and the URI is currently set to {3}
+CompositeReferencePromotesNonOverridableReference = [ASM50042] Composite reference promotes component reference with 1..1 multiplicity and nonOverridable flag set true: Composite = {0} Composite reference = {1} Component reference = {2}
+PropertyValueDoesNotMatchSimpleType = [ASM50027] The property {0} on component {1} has a value which does not match the simple type {2} with which it is associated
+PropertyValueDoesNotMatchComplexType = [ASM50038] The property {0} on component {1} has a value which does not match the complex type {2} with which it is associated. Validation reported {3}
+PropertyValueDoesNotMatchElement = [ASM50029] The property {0} on component {1} has a value which does not match the element {2} with which it is associated. Validation reported {3}
+EPRIncompatibleInterface = [BWS20007] The reference interface is incompatible with the interface of the reference binding {0}
+EPIncompatibleInterface = [BWS20007] The service interface is incompatible with the interface of the service binding {0}
+PromotedCallbackReferenceNotFound = For component {0} and service {1} the promoted component {2} does not have a callback reference called {3} which should have been created automatically by Tuscany
+PromotedCallbackServiceNotFound = For component {0} and reference {1} the promoted component {2} does not have a callback service called {3} which should have been created automatically by Tuscany
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties
new file mode 100644
index 0000000000..b94d37ba2d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties
@@ -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.
+#
+#
+DuplicateComponentName = Nome del componente duplicato: Composite = {0} Component = {1}
+DuplicateComponentServiceName = Nome del servizio del componente duplicato: Component = {0} Service = {1}
+DuplicateComponentReferenceName = Nome del reference del componente duplicato: Component = {0} Reference = {1}
+DuplicateComponentPropertyName = Nome della property del componente duplicato: Component = {0} Property = {1}
+NoComponentImplementation = Implementazione insistente per il componente: Component = {0}
+ServiceNotFoundForComponentService = Servizio non trovato per il componente: Component = {0} Service = {1}
+UnresolvedComponentImplementation = Implementazione del componente non trovata: Component = {0} Uri = {1}
+DuplicateImplementationPropertyName = Nome della property del componente duplicata: Component = {0} Property = {1}
+DuplicateImplementationReferenceName = Nome del riferimento duplicato: Component = {0} Reference = {1}
+PropertyNotFound = Property non trovata per il componente: Component = {0} Property = {1}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties
new file mode 100644
index 0000000000..d3905035b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties
@@ -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.
+#
+#
+
+DuplicateIntent = [ASM10001,POL30002] Duplicate intent {0} found in domain
+DuplicatePolicysSet = Duplicate policy set {0} found in domain
+DuplicateImplementationType = Duplicate implementation type {0} found in domain
+DuplicateBindingType = [POL40020] Duplicate binding type {0} found in domain
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
new file mode 100644
index 0000000000..20fd74d46e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test building of assembly model instances using the assembly factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AssemblyFactoryTestCase {
+
+ private static AssemblyFactory assemblyFactory;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ assemblyFactory = new DefaultAssemblyFactory();
+ }
+
+ @Test
+ public void testCreateComponent() {
+ createComponent("AccountServiceComponent1");
+ }
+
+ @Test
+ public void testCreateComponentType() {
+ createComponentType();
+ }
+
+ @Test
+ public void testCreateComposite() {
+ createComposite();
+ }
+
+ /**
+ * Create a composite
+ */
+ Composite createComposite() {
+ Composite c = assemblyFactory.createComposite();
+
+ Component c1 = createComponent("AccountServiceComponent1");
+ c.getComponents().add(c1);
+ Component c2 = createComponent("AccountServiceComponent2");
+ c.getComponents().add(c2);
+
+ Wire w = assemblyFactory.createWire();
+ w.setSource(c1.getReferences().get(0));
+ w.setTarget(c2.getServices().get(0));
+ c.getWires().add(w);
+
+ CompositeService cs = assemblyFactory.createCompositeService();
+ cs.setName("AccountService");
+ cs.setPromotedService(c1.getServices().get(0));
+ cs.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ c.getServices().add(cs);
+ cs.getBindings().add(new TestBinding(assemblyFactory));
+
+ CompositeReference cr = assemblyFactory.createCompositeReference();
+ cr.setName("StockQuoteService");
+ cr.getPromotedReferences().add(c2.getReferences().get(1));
+ cr.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ c.getReferences().add(cr);
+ cr.getBindings().add(new TestBinding(assemblyFactory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component
+ */
+ Component createComponent(String name) {
+ Component c = assemblyFactory.createComponent();
+ c.setName(name);
+
+ Implementation i = new TestImplementation(assemblyFactory);
+ c.setImplementation(i);
+
+ ComponentProperty p = assemblyFactory.createComponentProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ p.setProperty(i.getProperties().get(0));
+ c.getProperties().add(p);
+
+ ComponentReference ref1 = assemblyFactory.createComponentReference();
+ ref1.setName("accountDataService");
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ref1.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref1.setReference(i.getReferences().get(0));
+ c.getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(assemblyFactory));
+
+ ComponentReference ref2 = assemblyFactory.createComponentReference();
+ ref2.setName("stockQuoteService");
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ref2.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref2.setReference(i.getReferences().get(1));
+ c.getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(assemblyFactory));
+
+ ComponentService s = assemblyFactory.createComponentService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ s.setService(i.getServices().get(0));
+ c.getServices().add(s);
+ s.getBindings().add(new TestBinding(assemblyFactory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component type
+ *
+ * @return
+ */
+ ComponentType createComponentType() {
+ ComponentType ctype = assemblyFactory.createComponentType();
+
+ Property p = assemblyFactory.createProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ Reference ref1 = assemblyFactory.createReference();
+ ref1.setName("accountDataService");
+ ref1.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(assemblyFactory));
+
+ Reference ref2 = assemblyFactory.createReference();
+ ref2.setName("stockQuoteService");
+ ref2.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(assemblyFactory));
+
+ Service s = assemblyFactory.createService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(assemblyFactory));
+ ctype.getServices().add(s);
+ s.getBindings().add(new TestBinding(assemblyFactory));
+
+ return ctype;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
new file mode 100644
index 0000000000..a09f7af06c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.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.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.BindingImpl;
+
+/**
+ * A test interface model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestBinding extends BindingImpl implements Binding {
+ private final static QName TYPE = new QName("http://test", "binding.test");
+
+ public TestBinding(AssemblyFactory factory) {
+ super(TYPE);
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public String getURI() {
+ return "http://test";
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java
new file mode 100644
index 0000000000..6777c33ff1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.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.sca.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+
+/**
+ * A test component implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestImplementation extends ImplementationImpl implements Implementation {
+ public TestImplementation(AssemblyFactory factory) {
+ super(new QName("http://test", "implementation.test"));
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ getProperties().add(p);
+
+ Reference ref1 = factory.createReference();
+ ref1.setName("accountDataService");
+ ref1.setMultiplicity(Multiplicity.ONE_ONE);
+ getReferences().add(ref1);
+ ref1.getBindings().add(new TestBinding(factory));
+
+ Reference ref2 = factory.createReference();
+ ref2.setName("stockQuoteService");
+ ref2.setMultiplicity(Multiplicity.ONE_ONE);
+ ref2.setInterfaceContract(new TestInterfaceContract(factory));
+ getReferences().add(ref2);
+ ref2.getBindings().add(new TestBinding(factory));
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ s.setInterfaceContract(new TestInterfaceContract(factory));
+ getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java
new file mode 100644
index 0000000000..dbe0cb8225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.assembly;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
+
+/**
+ * A test interface model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestInterface extends InterfaceImpl implements Interface {
+
+ public TestInterface(AssemblyFactory factory) {
+
+ setRemotable(true);
+
+ Operation operation = new TestOperation();
+ operation.setName("test");
+ getOperations().add(operation);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java
new file mode 100644
index 0000000000..24be8a3e7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.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.assembly;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractImpl;
+
+/**
+ * A test interface contract model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestInterfaceContract extends InterfaceContractImpl implements InterfaceContract {
+
+ public TestInterfaceContract(AssemblyFactory factory) {
+
+ TestInterface testInterface = new TestInterface(factory);
+ setInterface(testInterface);
+
+ TestInterface testCallbackInterface = new TestInterface(factory);
+ setCallbackInterface(testCallbackInterface);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java
new file mode 100644
index 0000000000..d94a7e93a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.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.assembly;
+
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+
+/**
+ * A test operation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestOperation extends OperationImpl {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java
new file mode 100644
index 0000000000..603d393e5c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java
@@ -0,0 +1,396 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.impl;
+
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * TODO some tests commented out due to DataType.equals() needing to be strict
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContractCompatibilityTestCase {
+
+ private InterfaceContractMapper mapper;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ mapper = utilities.getUtility(InterfaceContractMapper.class);
+ }
+
+ @Test
+ public void testNoOperation() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ InterfaceContract target = new MockContract("FooContract");
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ @Test
+ public void testBasic() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ Operation opSource1 = newOperation("op1");
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+ InterfaceContract target = new MockContract("FooContract");
+ Operation opSource2 = newOperation("op1");
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opSource2);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ @Test
+ public void testBasicIncompatibleOperationNames() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ Operation opSource1 = newOperation("op1");
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+ InterfaceContract target = new MockContract("FooContract");
+ Operation opSource2 = newOperation("op2");
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op2", opSource2);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ try {
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ fail();
+ } catch (IncompatibleInterfaceContractException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testInputTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ List<DataType> sourceInputTypes = new ArrayList<DataType>();
+ sourceInputTypes.add(new DataTypeImpl<Type>(Object.class, Object.class));
+ DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>(String.class, sourceInputTypes);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setInputType(inputType);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ List<DataType> targetInputTypes = new ArrayList<DataType>();
+ targetInputTypes.add(new DataTypeImpl<Type>(Object.class, Object.class));
+ DataType<List<DataType>> targetInputType = new DataTypeImpl<List<DataType>>(String.class, targetInputTypes);
+
+ Operation opTarget = newOperation("op1");
+ opTarget.setInputType(targetInputType);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ @Test
+ public void testIncompatibleInputTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ List<DataType> sourceInputTypes = new ArrayList<DataType>();
+ sourceInputTypes.add(new DataTypeImpl<Type>(Integer.class, Integer.class));
+ DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>(String.class, sourceInputTypes);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setInputType(inputType);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ List<DataType> targetInputTypes = new ArrayList<DataType>();
+ targetInputTypes.add(new DataTypeImpl<Type>(String.class, String.class));
+ DataType<List<DataType>> targetInputType = new DataTypeImpl<List<DataType>>(String.class, targetInputTypes);
+
+ Operation opTarget = newOperation("op1");
+ opTarget.setInputType(targetInputType);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ try {
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ fail();
+ } catch (IncompatibleInterfaceContractException e) {
+ // expected
+ }
+ }
+
+ /**
+ * Verifies source input types can be super types of the target
+ */
+ @Test
+ public void testSourceSuperTypeInputCompatibility() throws Exception {
+ // InterfaceContract source = new MockContract("FooContract");
+ // List<DataType> sourceInputTypes = new ArrayList<DataType>();
+ // sourceInputTypes.add(new DataTypeImpl<Type>(Object.class,
+ // Object.class));
+ // DataType<List<DataType>> inputType = new
+ // DataTypeImpl<List<DataType>>(String.class, sourceInputTypes);
+ // Operation opSource1 = newOperationImpl("op1", inputType, null, null,
+ // false, null);
+ // Map<String, Operation> sourceOperations = new HashMap<String,
+ // Operation>();
+ // sourceOperations.put("op1", opSource1);
+ // source.getInterface().getOperations().addAll(sourceOperations.values());
+ //
+ // InterfaceContract target = new MockContract("FooContract");
+ // List<DataType> targetInputTypes = new ArrayList<DataType>();
+ // targetInputTypes.add(new DataTypeImpl<Type>(String.class,
+ // String.class));
+ // DataType<List<DataType>> targetInputType =
+ // new DataTypeImpl<List<DataType>>(String.class, targetInputTypes);
+ //
+ // Operation opTarget = newOperationImpl("op1", targetInputType, null,
+ // null, false, null);
+ // Map<String, Operation> targetOperations = new HashMap<String,
+ // Operation>();
+ // targetOperations.put("op1", opTarget);
+ // target.getInterface().getOperations().addAll(targetOperations.values());
+ // wireService.checkCompatibility(source, target, false);
+ }
+
+ @Test
+ public void testOutputTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ DataType sourceOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setOutputType(sourceOutputType);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ DataType targetOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ Operation opTarget = newOperation("op1");
+ opTarget.setOutputType(targetOutputType);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ /**
+ * Verifies a return type that is a supertype of of the target is compatible
+ */
+ @Test
+ public void testSupertypeOutputTypes() throws Exception {
+ // InterfaceContract source = new MockContract("FooContract");
+ // DataType sourceOutputType = new DataTypeImpl<Type>(Object.class,
+ // Object.class);
+ // Operation opSource1 = newOperationImpl("op1", null,
+ // sourceOutputType, null, false, null);
+ // Map<String, Operation> sourceOperations = new HashMap<String,
+ // Operation>();
+ // sourceOperations.put("op1", opSource1);
+ // source.getInterface().getOperations().addAll(sourceOperations.values());
+ //
+ // InterfaceContract target = new MockContract("FooContract");
+ // DataType targetOutputType = new DataTypeImpl<Type>(String.class,
+ // String.class);
+ // Operation opTarget = newOperationImpl("op1", null, targetOutputType,
+ // null, false, null);
+ // Map<String, Operation> targetOperations = new HashMap<String,
+ // Operation>();
+ // targetOperations.put("op1", opTarget);
+ // target.getInterface().getOperations().addAll(targetOperations.values());
+ // wireService.checkCompatibility(source, target, false);
+ }
+
+ @Test
+ public void testIncompatibleOutputTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ DataType sourceOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setOutputType(sourceOutputType);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ DataType targetOutputType = new DataTypeImpl<Type>(Integer.class, Integer.class);
+ Operation opTarget = newOperation("op1");
+ opTarget.setOutputType(targetOutputType);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ try {
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ fail();
+ } catch (IncompatibleInterfaceContractException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testFaultTypes() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ DataType sourceFaultType = new DataTypeImpl<Type>(String.class, String.class);
+ List<DataType> sourceFaultTypes = new ArrayList<DataType>();
+ sourceFaultTypes.add(0, sourceFaultType);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setFaultTypes(sourceFaultTypes);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ DataType targetFaultType = new DataTypeImpl<Type>(String.class, String.class);
+ List<DataType> targetFaultTypes = new ArrayList<DataType>();
+ targetFaultTypes.add(0, targetFaultType);
+
+ Operation opTarget = newOperation("op1");
+ opTarget.setFaultTypes(targetFaultTypes);
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ @Test
+ public void testSourceFaultTargetNoFaultCompatibility() throws Exception {
+ InterfaceContract source = new MockContract("FooContract");
+ DataType sourceFaultType = new DataTypeImpl<Type>(String.class, String.class);
+ List<DataType> sourceFaultTypes = new ArrayList<DataType>();
+ sourceFaultTypes.add(0, sourceFaultType);
+ Operation opSource1 = newOperation("op1");
+ opSource1.setFaultTypes(sourceFaultTypes);
+ Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
+ sourceOperations.put("op1", opSource1);
+ source.getInterface().getOperations().addAll(sourceOperations.values());
+
+ InterfaceContract target = new MockContract("FooContract");
+ Operation opTarget = newOperation("op1");
+ Map<String, Operation> targetOperations = new HashMap<String, Operation>();
+ targetOperations.put("op1", opTarget);
+ target.getInterface().getOperations().addAll(targetOperations.values());
+ mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ }
+
+ /**
+ * Verifies a source's fault which is a supertype of the target's fault are
+ * compatible
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testFaultSuperTypes() throws Exception {
+ // InterfaceContract source = new MockContract("FooContract");
+ // DataType sourceFaultType = new DataTypeImpl<Type>(Exception.class,
+ // Exception.class);
+ // List<DataType> sourceFaultTypes = new ArrayList<DataType>();
+ // sourceFaultTypes.add(0, sourceFaultType);
+ // Operation opSource1 = newOperationImpl("op1", null, null,
+ // sourceFaultTypes, false, null);
+ // Map<String, Operation> sourceOperations = new HashMap<String,
+ // Operation>();
+ // sourceOperations.put("op1", opSource1);
+ // source.getInterface().getOperations().addAll(sourceOperations.values());
+ //
+ // InterfaceContract target = new MockContract("FooContract");
+ // DataType targetFaultType = new
+ // DataTypeImpl<Type>(TuscanyException.class, TuscanyException.class);
+ // List<DataType> targetFaultTypes = new ArrayList<DataType>();
+ // targetFaultTypes.add(0, targetFaultType);
+ //
+ // Operation opTarget = newOperationImpl("op1", null, null,
+ // targetFaultTypes, false, null);
+ // Map<String, Operation> targetOperations = new HashMap<String,
+ // Operation>();
+ // targetOperations.put("op1", opTarget);
+ // target.getInterface().getOperations().addAll(targetOperations.values());
+ // wireService.checkCompatibility(source, target, false);
+ }
+
+ /**
+ * Verifies a source's faults which are supertypes and a superset of the
+ * target's faults are compatible
+ */
+ @Test
+ public void testFaultSuperTypesAndSuperset() throws Exception {
+ // InterfaceContract source = new MockContract("FooContract");
+ // DataType sourceFaultType = new DataTypeImpl<Type>(Exception.class,
+ // Exception.class);
+ // DataType sourceFaultType2 = new
+ // DataTypeImpl<Type>(RuntimeException.class, RuntimeException.class);
+ // List<DataType> sourceFaultTypes = new ArrayList<DataType>();
+ // sourceFaultTypes.add(0, sourceFaultType);
+ // sourceFaultTypes.add(1, sourceFaultType2);
+ // Operation opSource1 = newOperationImpl("op1", null, null,
+ // sourceFaultTypes, false, null);
+ // Map<String, Operation> sourceOperations = new HashMap<String,
+ // Operation>();
+ // sourceOperations.put("op1", opSource1);
+ // source.getInterface().getOperations().addAll(sourceOperations.values());
+ //
+ // InterfaceContract target = new MockContract("FooContract");
+ // DataType targetFaultType = new
+ // DataTypeImpl<Type>(TuscanyException.class, TuscanyException.class);
+ // List<DataType> targetFaultTypes = new ArrayList<DataType>();
+ // targetFaultTypes.add(0, targetFaultType);
+ //
+ // Operation opTarget = newOperationImpl("op1", null, null,
+ // targetFaultTypes, false, null);
+ // Map<String, Operation> targetOperations = new HashMap<String,
+ // Operation>();
+ // targetOperations.put("op1", opTarget);
+ // target.getInterface().getOperations().addAll(targetOperations.values());
+ // wireService.checkCompatibility(source, target, false);
+ }
+
+ private static class MockInterface extends InterfaceImpl {
+
+ }
+
+ private class MockContract<T> extends InterfaceContractImpl {
+ public MockContract() {
+ }
+
+ public MockContract(String interfaceClass) {
+ Interface jInterface = new MockInterface();
+ setInterface(jInterface);
+ }
+ }
+
+ private static Operation newOperation(String name) {
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+ return operation;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java
new file mode 100644
index 0000000000..d1faa5cf2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.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.interfacedef.impl;
+
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterfaceContractTestCase {
+ private InterfaceContract contract;
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ contract = new MockInterfaceContract();
+ Interface i1 = new MockInterface();
+ contract.setInterface(i1);
+ Operation op1 = newOperation("op1");
+ i1.getOperations().add(op1);
+ Interface i2 = new MockInterface();
+ contract.setCallbackInterface(i2);
+ Operation callbackOp1 = newOperation("callbackOp1");
+ i2.getOperations().add(callbackOp1);
+ }
+
+ @Test
+ public void testClone() throws Exception {
+ InterfaceContract copy = (InterfaceContract) contract.clone();
+ Assert.assertNotNull(copy);
+ Assert.assertNotSame(copy.getCallbackInterface(), contract.getCallbackInterface());
+ Assert.assertNotSame(copy.getInterface(), contract.getInterface());
+ }
+
+ private static class MockInterfaceContract extends InterfaceContractImpl implements InterfaceContract {
+ }
+
+ private static class MockInterface extends InterfaceImpl implements Interface {
+ }
+
+ private static Operation newOperation(String name) {
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+ return operation;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java
new file mode 100644
index 0000000000..569366ad1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.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.policy;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test building of policy model instances using the policy factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyFactoryTestCase {
+
+ PolicyFactory factory;
+
+ @Before
+ public void setUp() throws Exception {
+ factory = new DefaultPolicyFactory();
+ }
+
+ @Test
+ public void testCreateIntent() {
+ Intent intent = factory.createIntent();
+ intent.setName(new QName("http://test", "reliability"));
+ assertEquals(intent.getName(), new QName("http://test", "reliability"));
+ }
+
+ @Test
+ public void testCreatePolicySet() {
+ PolicySet policySet = factory.createPolicySet();
+ policySet.setName(new QName("http://test", "reliability"));
+ assertEquals(policySet.getName(), new QName("http://test", "reliability"));
+ }
+
+ @Test
+ public void testCreateExternalAttachment() {
+ ExternalAttachment attachment = factory.createExternalAttachment();
+ attachment.setAttachTo("sca:component");
+
+ Intent intent = factory.createIntent();
+ intent.setName(new QName("http://test", "reliability"));
+ attachment.getIntents().add(intent);
+
+ PolicySet policySet = factory.createPolicySet();
+ policySet.setName(new QName("http://test", "reliability"));
+ attachment.getPolicySets().add(policySet);
+
+ assertEquals("sca:component", attachment.getAttachTo());
+ assertEquals(intent, attachment.getIntents().get(0));
+ assertEquals(policySet, attachment.getPolicySets().get(0));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/LICENSE b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/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/sebastien/java/embed/modules/binding-atom-js-dojo/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ba2b954239
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.atom.js.dojo;uses:="org
+ .apache.tuscany.sca.assembly,org.apache.tuscany.sca.web.javascript,or
+ g.apache.tuscany.sca.binding.atom,javax.xml.namespace";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Atom Feed Binding JavaScript using Doj
+ o
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Atom Feed Binding JavaScript us
+ ing Dojo
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.atom;version="2.0.0",
+ org.apache.tuscany.sca.binding.atom.js.dojo;version="2.0.0",
+ org.apache.tuscany.sca.web.javascript;version="2.0.0",
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.atom-js-dojo
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/NOTICE b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/pom.xml b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/pom.xml
new file mode 100644
index 0000000000..8c40ca4059
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/pom.xml
@@ -0,0 +1,53 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-atom-js-dojo</artifactId>
+ <name>Apache Tuscany SCA Atom Feed Binding JavaScript using Dojo</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-atom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-web-javascript</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/src/main/java/org/apache/tuscany/sca/binding/atom/js/dojo/AtomBindingJavascriptProxyFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/src/main/java/org/apache/tuscany/sca/binding/atom/js/dojo/AtomBindingJavascriptProxyFactoryImpl.java
new file mode 100644
index 0000000000..abc3c0c342
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/src/main/java/org/apache/tuscany/sca/binding/atom/js/dojo/AtomBindingJavascriptProxyFactoryImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.atom.js.dojo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.atom.AtomBinding;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory;
+
+public class AtomBindingJavascriptProxyFactoryImpl implements JavascriptProxyFactory {
+ private static final QName NAME = new QName("http://tuscany.apache.org/xmlns/sca/1.1", "binding.atom");
+
+ public Class<?> getModelType() {
+ return AtomBinding.class;
+ }
+
+ public QName getQName() {
+ return NAME;
+ }
+
+ public String getJavascriptProxyFile() {
+ return null;
+ }
+
+ public InputStream getJavascriptProxyFileAsStream() throws IOException {
+ return null;
+ }
+
+ public String createJavascriptHeader(ComponentReference componentReference) throws IOException {
+ return "dojo.require('tuscany.AtomService');";
+ }
+
+ public String createJavascriptReference(ComponentReference componentReference) throws IOException {
+ EndpointReference epr = componentReference.getEndpointReferences().get(0);
+ Endpoint targetEndpoint = epr.getTargetEndpoint();
+ if (targetEndpoint.isUnresolved()) {
+ //force resolution and targetEndpoint binding calculations
+ //by calling the getInvocationChain
+ ((RuntimeEndpointReference) epr).getInvocationChains();
+ targetEndpoint = epr.getTargetEndpoint();
+ }
+
+ Binding binding = targetEndpoint.getBinding();
+
+ URI targetURI = URI.create(binding.getURI());
+ String targetPath = targetURI.getPath();
+
+ return "tuscany.AtomService(\"" + targetPath + "\")";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory
new file mode 100644
index 0000000000..c9ff2ef9d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-js-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory
@@ -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 Javascript Proxy Factory
+org.apache.tuscany.sca.binding.atom.js.dojo.AtomBindingJavascriptProxyFactoryImpl;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.atom,model=org.apache.tuscany.sca.binding.atom.AtomBinding \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/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/sebastien/java/embed/modules/binding-atom-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..4ae5784c2a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,47 @@
+Manifest-Version: 1.0
+Export-Package:
+ org.apache.tuscany.sca.binding.atom.collection
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Abdera Atom Feed Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Abdera Atom Feed Binding Extens
+ ion
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ org.apache.abdera,
+ org.apache.abdera.factory,
+ org.apache.abdera.i18n.iri,
+ org.apache.abdera.model,
+ org.apache.abdera.parser,
+ org.apache.abdera.protocol,
+ org.apache.abdera.protocol.client,
+ org.apache.abdera.protocol.client.util,
+ org.apache.abdera.writer,
+ org.apache.commons.codec.binary,
+ org.apache.commons.httpclient,
+ org.apache.commons.httpclient.auth,
+ org.apache.commons.httpclient.methods,
+ org.apache.commons.httpclient.params,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.atom;version="2.0.0",
+ org.apache.tuscany.sca.binding.http;version="2.0.0",
+ org.apache.tuscany.sca.common.http;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.data.collection;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util,
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.atom.abdera
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..1b9052299c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.atom.provider.AtomBindingProviderFactory;model=org.apache.tuscany.sca.binding.atom.AtomBinding
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/pom.xml
new file mode 100644
index 0000000000..ce7fb47ccc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/pom.xml
@@ -0,0 +1,227 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-atom-runtime</artifactId>
+ <name>Apache Tuscany SCA Abdera Atom Feed Binding Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-atom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-core</artifactId>
+ <version>1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.0.2_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-parser</artifactId>
+ <version>1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xom</groupId>
+ <artifactId>xom</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-client</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-extensions-main</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-extensions-json</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>runtime</scope>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin> <!-- TUSCANY-3383 avoid intermitent test fails-->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/Collection.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/Collection.java
new file mode 100644
index 0000000000..81ec1ddad3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/Collection.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.sca.binding.atom.collection;
+
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Provides access to a collection of resources using Atom.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Collection {
+
+ /**
+ * Get an Atom feed for a collection of resources.
+ *
+ * @return the Atom feed
+ */
+ Feed getFeed();
+
+ /**
+ * Get an Atom feed for a collection of resources resulting
+ * from a query.
+ *
+ * @param queryString a query string
+ * @return the Atom feed
+ */
+ Feed query(String queryString);
+
+ /**
+ * Creates a new entry.
+ *
+ * @param entry
+ * @return
+ */
+ Entry post(Entry entry);
+
+ /**
+ * Retrieves an entry.
+ *
+ * @param id
+ * @return
+ */
+ Entry get(String id) throws NotFoundException;
+
+ /**
+ * Update an entry.
+ *
+ * @param id
+ * @param entry
+ * @return
+ */
+ void put(String id, Entry entry) throws NotFoundException;
+
+ /**
+ * Delete an entry.
+ *
+ * @param id
+ */
+ void delete(String id) throws NotFoundException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/MediaCollection.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/MediaCollection.java
new file mode 100644
index 0000000000..d318e5b7e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/MediaCollection.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.sca.binding.atom.collection;
+
+import java.io.InputStream;
+
+import org.apache.abdera.model.Entry;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Provides access to a collection of resources using Atom.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface MediaCollection extends Collection {
+
+ /**
+ * Creates a new media entry
+ *
+ * @param title
+ * @param slug
+ * @param contentType
+ * @param media
+ */
+ Entry postMedia(String title, String slug, String contentType, InputStream media);
+
+ /**
+ * Update a media entry.
+ *
+ * @param id
+ * @param contentType
+ * @param media
+ * @return
+ */
+ void putMedia(String id, String contentType, InputStream media) throws NotFoundException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/NotFoundException.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/NotFoundException.java
new file mode 100644
index 0000000000..b457840922
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/NotFoundException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.atom.collection;
+
+/**
+ * Indicates that a resource could not be found.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NotFoundException extends Exception {
+ private static final long serialVersionUID = -5046027674128627383L;
+
+ public NotFoundException() {
+ }
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+ public NotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
new file mode 100644
index 0000000000..5fd380dab6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
@@ -0,0 +1,510 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom.provider;
+
+import static org.apache.tuscany.sca.binding.atom.provider.AtomBindingUtil.entry;
+import static org.apache.tuscany.sca.binding.atom.provider.AtomBindingUtil.feedEntry;
+
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.Parser;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Invoker for the Atom binding.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomBindingInvoker implements Invoker {
+
+ private static final Factory abderaFactory = Abdera.getNewFactory();
+ private static final Parser abderaParser = Abdera.getNewParser();
+
+ Operation operation;
+ String uri;
+ HttpClient httpClient;
+ String authorizationHeader;
+ AtomReferenceBindingProvider provider;
+
+ AtomBindingInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ this.operation = operation;
+ this.uri = uri;
+ this.httpClient = httpClient;
+ this.authorizationHeader = authorizationHeader;
+ this.provider = bindingProvider;
+ }
+
+ public Message invoke(Message msg) {
+ // Shouldn't get here, as the only supported methods are
+ // defined in the ResourceCollection interface, and implemented
+ // by specific invoker subclasses
+ throw new UnsupportedOperationException(operation.getName());
+ }
+
+ /**
+ * Get operation invoker
+ */
+ public static class GetInvoker extends AtomBindingInvoker {
+
+ public GetInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // Get an entry
+ String id = (String)((Object[])msg.getBody())[0];
+
+ // Send an HTTP GET
+ GetMethod getMethod = new GetMethod(uri + "/" + id);
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ boolean parsing = false;
+ try {
+ httpClient.executeMethod(getMethod);
+ int status = getMethod.getStatusCode();
+
+ // Read the Atom entry
+ if (status == 200) {
+ Document<org.apache.abdera.model.Entry> doc =
+ abderaParser.parse(new InputStreamReader(getMethod.getResponseBodyAsStream()));
+ parsing = true;
+ org.apache.abdera.model.Entry feedEntry = doc.getRoot();
+
+ if (provider.supportsFeedEntries()) {
+
+ // Return the Atom entry
+ msg.setBody(feedEntry);
+
+ } else {
+
+ // Convert the feed entry to a data entry and return the data item
+ Entry<Object, Object> entry = entry(feedEntry, provider.getItemClassType(),
+ provider.getItemXMLType(), provider.getMediator());
+ msg.setBody(entry.getData());
+ }
+
+ } else if (status == 404) {
+ if ( provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ if (!parsing) {
+ // Release the connection unless the Abdera parser is
+ // parsing the response, in this case it will release it
+ getMethod.releaseConnection();
+ }
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * Post operation invoker
+ */
+ public static class PostInvoker extends AtomBindingInvoker {
+
+ public PostInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // Post an entry
+ Object[] args = (Object[])msg.getBody();
+ org.apache.abdera.model.Entry feedEntry;
+ if (provider.supportsFeedEntries()) {
+
+ // Expect an Atom entry
+ feedEntry = (org.apache.abdera.model.Entry)args[0];
+ } else {
+
+ // Expect a key and data item
+ Entry<Object, Object> entry = new Entry<Object, Object>(args[0], args[1]);
+ feedEntry = feedEntry(entry, provider.getItemClassType(),
+ provider.getItemXMLType(), provider.getMediator(), abderaFactory);
+ }
+
+ // Send an HTTP POST
+ PostMethod postMethod = new PostMethod(uri);
+ postMethod.setRequestHeader("Authorization", authorizationHeader);
+ boolean parsing = false;
+ try {
+
+ // Write the Atom entry
+ StringWriter writer = new StringWriter();
+ feedEntry.writeTo(writer);
+ // postMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
+ postMethod.setRequestHeader("Content-type", "application/atom+xml;type=entry");
+ postMethod.setRequestEntity(new StringRequestEntity(writer.toString()));
+
+ httpClient.executeMethod(postMethod);
+ int status = postMethod.getStatusCode();
+
+ // Read the Atom entry
+ if (status == 200 || status == 201) {
+ Document<org.apache.abdera.model.Entry> doc = abderaParser.parse(new InputStreamReader(postMethod.getResponseBodyAsStream()));
+ parsing = true;
+ org.apache.abdera.model.Entry createdEntry = doc.getRoot();
+
+ // Returns the created Atom entry ID
+ if (provider.supportsFeedEntries()) {
+
+ // Returns the created entry
+ msg.setBody(createdEntry);
+
+ } else {
+
+ // Returns the id of the created entry
+ msg.setBody(createdEntry.getId().toString());
+ }
+
+ } else if (status == 404) {
+ if ( provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ if (!parsing) {
+ // Release the connection unless the Abdera parser is
+ // parsing the response, in this case it will release it
+ postMethod.releaseConnection();
+ }
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * Put operation invoker
+ */
+ public static class PutInvoker extends AtomBindingInvoker {
+
+ public PutInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // Put an entry
+ Object[] args = (Object[])msg.getBody();
+ String id;
+ org.apache.abdera.model.Entry feedEntry;
+ if (provider.supportsFeedEntries()) {
+
+ // Expect a key and Atom entry
+ id = (String)args[0];
+ feedEntry = (org.apache.abdera.model.Entry)args[1];
+ } else {
+
+ // Expect a key and data item
+ id = (String)args[0];
+ Entry<Object, Object> entry = new Entry<Object, Object>(id, args[1]);
+ feedEntry = feedEntry(entry, provider.getItemClassType(),
+ provider.getItemXMLType(), provider.getMediator(), abderaFactory);
+ }
+
+ // Send an HTTP PUT
+ PutMethod putMethod = new PutMethod(uri + "/" + id);
+ putMethod.setRequestHeader("Authorization", authorizationHeader);
+
+ try {
+
+ // Write the Atom entry
+ StringWriter writer = new StringWriter();
+ feedEntry.writeTo(writer);
+ putMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
+ putMethod.setRequestEntity(new StringRequestEntity(writer.toString()));
+
+ httpClient.executeMethod(putMethod);
+ int status = putMethod.getStatusCode();
+ if (status == 200 || status == 201 || status == 412) {
+
+ msg.setBody(null);
+
+ } else if (status == 404) {
+ if ( provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ putMethod.releaseConnection();
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * Delete operation invoker
+ */
+ public static class DeleteInvoker extends AtomBindingInvoker {
+
+ public DeleteInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // Delete an entry
+ String id = (String)((Object[])msg.getBody())[0];
+
+ // Send an HTTP DELETE
+ DeleteMethod deleteMethod = new DeleteMethod(uri + "/" + id);
+ deleteMethod.setRequestHeader("Authorization", authorizationHeader);
+ try {
+ httpClient.executeMethod(deleteMethod);
+ int status = deleteMethod.getStatusCode();
+ if (status == 200) {
+ msg.setBody(null);
+
+ } else if (status == 404) {
+ if ( provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ deleteMethod.releaseConnection();
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * GetAll operation invoker
+ */
+ public static class GetAllInvoker extends AtomBindingInvoker {
+
+ public GetAllInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // Get a feed
+
+ // Send an HTTP GET
+ GetMethod getMethod = new GetMethod(uri);
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ boolean parsing = false;
+ try {
+ httpClient.executeMethod(getMethod);
+ int status = getMethod.getStatusCode();
+ // AtomBindingInvoker.printResponseHeader( getMethod );
+
+ // Read the Atom feed
+ if (status == 200) {
+ Document<Feed> doc = abderaParser.parse(new InputStreamReader(getMethod.getResponseBodyAsStream()));
+ parsing = true;
+
+ Feed feed = null;
+ try {
+ feed = doc.getRoot();
+ } catch(Exception e) {
+ throw new IllegalArgumentException("Invalid feed format :" + uri);
+ }
+
+ if (provider.supportsFeedEntries()) {
+
+ // Returns the Atom feed
+ msg.setBody(feed);
+
+ } else {
+
+ // Returns an array of data entries
+ List<Entry<Object, Object>> entries = new ArrayList<Entry<Object,Object>>();
+ for (org.apache.abdera.model.Entry feedEntry: feed.getEntries()) {
+ Entry<Object, Object> entry = entry(feedEntry, provider.getItemClassType(),
+ provider.getItemXMLType(), provider.getMediator());
+ entries.add(entry);
+ }
+ msg.setBody(entries.toArray(new Entry[entries.size()]));
+ }
+
+ } else if (status == 404) {
+ if ( provider.supportsFeedEntries()) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ }
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ if (!parsing) {
+ // Release the connection unless the Abdera parser is
+ // parsing the response, in this case it will release it
+ getMethod.releaseConnection();
+ }
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * Query operation invoker
+ */
+ public static class QueryInvoker extends AtomBindingInvoker {
+
+ public QueryInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // Get a feed from a query
+ String queryString = (String)((Object[])msg.getBody())[0];
+
+ // Send an HTTP GET
+ GetMethod getMethod = new GetMethod(uri);
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ getMethod.setQueryString(queryString);
+ boolean parsing = false;
+ try {
+ httpClient.executeMethod(getMethod);
+ int status = getMethod.getStatusCode();
+
+ // Read the Atom feed
+ if (status == 200) {
+ Document<Feed> doc = abderaParser.parse(new InputStreamReader(getMethod.getResponseBodyAsStream()));
+ parsing = true;
+ Feed feed = doc.getRoot();
+
+ if (provider.supportsFeedEntries()) {
+
+ // Returns the Atom feed
+ msg.setBody(feed);
+
+ } else {
+
+ // Returns an array of data entries
+ List<Entry<Object, Object>> entries = new ArrayList<Entry<Object,Object>>();
+ for (org.apache.abdera.model.Entry feedEntry: feed.getEntries()) {
+ Entry<Object, Object> entry = entry(feedEntry, provider.getItemClassType(),
+ provider.getItemXMLType(), provider.getMediator());
+ entries.add(entry);
+ }
+ msg.setBody(entries.toArray(new Entry[entries.size()]));
+ }
+
+ } else if (status == 404) {
+ if ( provider.supportsFeedEntries())
+ msg.setFaultBody(new NotFoundException());
+ else
+ msg.setFaultBody(new org.apache.tuscany.sca.data.collection.NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ if (!parsing) {
+ // Release the connection unless the Abdera parser is
+ // parsing the response, in this case it will release it
+ getMethod.releaseConnection();
+ }
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * PostMedia operation invoker
+ */
+ public static class PostMediaInvoker extends AtomBindingInvoker {
+
+ public PostMediaInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // PostInvoker can detect media by content type (non-Feed, non-Entry)
+ return super.invoke(msg);
+ }
+ }
+
+ /**
+ * PutMedia operation invoker
+ */
+ public static class PutMediaInvoker extends AtomBindingInvoker {
+
+ public PutMediaInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader, AtomReferenceBindingProvider bindingProvider) {
+ super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // PutInvoker can detect media by content type (non-Feed, non-Entry)
+ return super.invoke(msg);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
new file mode 100644
index 0000000000..20fb9309d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
@@ -0,0 +1,895 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom.provider;
+
+import static org.apache.tuscany.sca.binding.atom.provider.AtomBindingUtil.entry;
+import static org.apache.tuscany.sca.binding.atom.provider.AtomBindingUtil.feedEntry;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.net.URLDecoder;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Category;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.writer.WriterFactory;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.tuscany.sca.common.http.HTTPCacheContext;
+import org.apache.tuscany.sca.common.http.HTTPUtil;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+
+/**
+ * A resource collection binding listener, implemented as a Servlet and
+ * registered in a Servlet host provided by the SCA hosting runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomBindingListenerServlet extends HttpServlet {
+ private static final Logger logger = Logger.getLogger(AtomBindingListenerServlet.class.getName());
+ private static final long serialVersionUID = 1L;
+
+ private static final Factory abderaFactory = Abdera.getNewFactory();
+ private static final Parser abderaParser = Abdera.getNewParser();
+ private static final String ETAG = "ETag";
+ private static final String LASTMODIFIED = "Last-Modified";
+ private static final String LOCATION = "Location";
+ private static final String CONTENTLOCATION = "Content-Location";
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
+
+ private Invocable wire;
+ private Invoker getFeedInvoker;
+ private Invoker getAllInvoker;
+ private Invoker queryInvoker;
+ private Invoker getInvoker;
+ private Invoker postInvoker;
+ private Invoker postMediaInvoker;
+ private Invoker putInvoker;
+ private Invoker putMediaInvoker;
+ private Invoker deleteInvoker;
+ private MessageFactory messageFactory;
+ private String title;
+ private String description;
+ private Mediator mediator;
+ private DataType<?> itemClassType;
+ private DataType<?> itemXMLType;
+ private boolean supportsFeedEntries;
+
+ /**
+ * Constructs a new binding listener.
+ *
+ * @param wire
+ * @param messageFactory
+ * @param feedType
+ */
+ AtomBindingListenerServlet(Invocable wire, MessageFactory messageFactory, Mediator mediator, String title, String description) {
+ this.wire = wire;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+ this.title = title;
+ this.description = description;
+
+ // Get the invokers for the supported operations
+ Operation getOperation = null;
+ for (InvocationChain invocationChain : this.wire.getInvocationChains()) {
+ invocationChain.setAllowsPassByReference(true);
+ Operation operation = invocationChain.getTargetOperation();
+ String operationName = operation.getName();
+ if (operationName.equals("getFeed")) {
+ getFeedInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("getAll")) {
+ getAllInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("query")) {
+ queryInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("get")) {
+ getInvoker = invocationChain.getHeadInvoker();
+ getOperation = operation;
+ } else if (operationName.equals("put")) {
+ putInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("putMedia")) {
+ putMediaInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("post")) {
+ postInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("postMedia")) {
+ postMediaInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("delete")) {
+ deleteInvoker = invocationChain.getHeadInvoker();
+ }
+ }
+
+ // Determine the collection item type
+ if (getOperation != null) {
+ itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
+ Class<?> itemClass = getOperation.getOutputType().getPhysical();
+ if (itemClass == org.apache.abdera.model.Entry.class) {
+ supportsFeedEntries = true;
+ }
+ //We assume that the item type is the same for both input and
+ //ouput for all operations on the interface
+ itemClassType = getOperation.getOutputType();
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // No authentication required for a get request
+
+ // Test for any cache info in the request
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest( request );
+ } catch ( java.text.ParseException e ) {
+ }
+ // System.out.println( "AtomBindingListener.doGet cache context=" + cacheContext );
+
+ // Get the request path
+ //int servletPathLength = request.getContextPath().length() + request.getServletPath().length();
+ //String path = URLDecoder.decode(request.getRequestURI().substring(servletPathLength), "UTF-8");
+
+ String path = URLDecoder.decode(HTTPUtil.getRequestPath(request), "UTF-8");
+
+ logger.fine("get " + request.getRequestURI());
+
+ // Handle an Atom request
+ if (path != null && path.equals("/atomsvc")) {
+ /*
+ <?xml version='1.0' encoding='UTF-8'?>
+ <service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom">
+ <workspace>
+ <atom:title type="text">resource</atom:title>
+ <collection href="http://luck.ibm.com:8084/customer">
+ <atom:title type="text">entries</atom:title>
+ <accept>application/atom+xml;type=entry</accept>
+ <categories />
+ </collection>
+ </workspace>
+ </service>
+ */
+
+ // Return the Atom service document
+ response.setContentType("application/atomsvc+xml; charset=utf-8");
+
+ String href = request.getRequestURL().toString();
+ href = href.substring(0, href.length() - "/atomsvc".length());
+
+ String workspaceURL = new String( href );
+ int pathIndex = workspaceURL.indexOf( request.getServletPath() );
+ if ( -1 != pathIndex ) {
+ workspaceURL = workspaceURL.substring( 0, pathIndex ) + "/";
+ }
+
+ Service service = abderaFactory.newService();
+ //service.setText("service");
+
+ Workspace workspace = abderaFactory.newWorkspace();
+ if ( title != null ) {
+ workspace.setTitle(title);
+ } else {
+ workspace.setTitle("workspace");
+ }
+ workspace.setBaseUri( new IRI( workspaceURL ));
+
+ Collection collection = workspace.addCollection("collection", href );
+ Feed feed = getFeed( request );
+ if ( feed != null ) {
+ String title = feed.getTitle();
+ if ( title != null ) {
+ collection.setTitle(title);
+ } else {
+ collection.setTitle("entries");
+ }
+ collection.addAccepts("application/atom+xml;type=feed");
+ collection.addAccepts("application/json;type=feed");
+ collection.addAccepts("application/atom+xml;type=entry");
+ collection.addAccepts("application/json;type=entry");
+ List<Category> categories = feed.getCategories();
+ if ( categories != null ) {
+ collection.addCategories(categories, false, null);
+ } else {
+ collection.addCategories().setFixed(false);
+ }
+
+ } else {
+ collection.setTitle("entries");
+ // collection.addAccepts("application/atom+xml;type=feed");
+ collection.addAccepts("application/atom+xml; type=entry");
+ collection.addAccepts("application/json;type=entry");
+ collection.addCategories().setFixed(false);
+ }
+ workspace.addCollection(collection);
+ service.addWorkspace(workspace);
+
+ //FIXME add prettyPrint support
+ try {
+ service.getDocument().writeTo(response.getOutputStream());
+ } catch (IOException ioe) {
+ throw new ServletException(ioe);
+ }
+
+ } else if (path == null || path.length() == 0 || path.equals("/")) {
+
+ // Return a feed containing the entries in the collection
+ Feed feed = getFeed( request );
+ if (feed != null) {
+ String feedETag = null;
+ if (feed.getId() != null)
+ feedETag = "\"" + feed.getId().toString() + "\"";
+ Date feedUpdated = feed.getUpdated();
+ // Test request for predicates.
+ String predicate = request.getHeader( "If-Match" );
+ if (( predicate != null ) && ( !predicate.equals(feedETag) )) {
+ // No match, should short circuit
+ response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
+ return;
+ }
+ predicate = request.getHeader( "If-None-Match" );
+ if (( predicate != null ) && ( predicate.equals(feedETag) )) {
+ // Match, should short circuit
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ if ( feedUpdated != null ) {
+ predicate = request.getHeader( "If-Unmodified-Since" );
+ if ( predicate != null ) {
+ try {
+ Date predicateDate = dateFormat.parse( predicate );
+ if ( predicateDate.compareTo( feedUpdated ) < 0 ) {
+ // Match, should short circuit
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ } catch ( java.text.ParseException e ) {
+ // Ignore and move on
+ }
+ }
+ predicate = request.getHeader( "If-Modified-Since" );
+ if ( predicate != null ) {
+ try {
+ Date predicateDate = dateFormat.parse( predicate );
+ if ( predicateDate.compareTo( feedUpdated ) > 0 ) {
+ // Match, should short circuit
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ } catch ( java.text.ParseException e ) {
+ // Ignore and move on
+ }
+ }
+ }
+ // Provide Etag based on Id and time if given.
+ // Ignore if not given. (Browser may cache if trivial ETag is given.)
+ if ( feedETag != null ) {
+ response.addHeader(ETAG, feedETag);
+ }
+ if ( feedUpdated != null ) {
+ response.addHeader(LASTMODIFIED, dateFormat.format( feedUpdated ));
+ }
+
+ // Content negotiation
+ String acceptType = request.getHeader( "Accept" );
+ String preferredType = getContentPreference( acceptType );
+ if (( preferredType != null ) && ((preferredType.indexOf( "json") > -1) || (preferredType.indexOf( "JSON") > -1 ))) {
+ // JSON response body
+ response.setContentType("application/json;type=feed");
+
+ try {
+ Abdera abdera = new Abdera();
+ WriterFactory wf = abdera.getWriterFactory();
+ org.apache.abdera.writer.Writer json = wf.getWriter("json");
+ feed.writeTo(json, response.getWriter());
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+
+ } else {
+ // Write the Atom feed
+ response.setContentType("application/atom+xml;type=feed");
+ try {
+ feed.getDocument().writeTo(response.getOutputStream());
+ } catch (IOException ioe) {
+ throw new ServletException(ioe);
+ }
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ } else if (path.startsWith("/")) {
+ // Return a specific entry in the collection
+ org.apache.abdera.model.Entry feedEntry;
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ String id = path.substring(1);
+ requestMessage.setBody(new Object[] {id});
+ Message responseMessage = getInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+ }
+ if (supportsFeedEntries) {
+ // The service implementation returns a feed entry
+ feedEntry = responseMessage.getBody();
+ } else {
+ // The service implementation only returns a data item, create an entry
+ // from it
+ Entry<Object, Object> entry = new Entry<Object, Object>(id, responseMessage.getBody());
+ feedEntry = feedEntry(entry, itemClassType, itemXMLType, mediator, abderaFactory);
+ }
+ // Write the Atom entry
+ if (feedEntry != null) {
+ String entryETag = null;
+ if (feedEntry.getId() != null)
+ entryETag = feedEntry.getId().toString();
+ Date entryUpdated = feedEntry.getUpdated();
+ if ( entryUpdated != null )
+ response.addHeader(LASTMODIFIED, dateFormat.format( entryUpdated ));
+ // TODO Check If-Modified-Since If-Unmodified-Since predicates against LASTMODIFIED.
+ // If true return 304 and null body.
+
+ Link link = feedEntry.getSelfLink();
+ if (link != null) {
+ response.addHeader(LOCATION, link.getHref().toString());
+ } else {
+ link = feedEntry.getLink( "Edit" );
+ if (link != null) {
+ response.addHeader(LOCATION, link.getHref().toString());
+ }
+ }
+
+ // Test request for predicates.
+ String predicate = request.getHeader( "If-Match" );
+ if (( predicate != null ) && ( !predicate.equals(entryETag) )) {
+ // No match, should short circuit
+ response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
+ return;
+ }
+ predicate = request.getHeader( "If-None-Match" );
+ if (( predicate != null ) && ( predicate.equals(entryETag) )) {
+ // Match, should short circuit
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ if ( entryUpdated != null ) {
+ predicate = request.getHeader( "If-Unmodified-Since" );
+ if ( predicate != null ) {
+ try {
+ Date predicateDate = dateFormat.parse( predicate );
+ if ( predicateDate.compareTo( entryUpdated ) < 0 ) {
+ // Match, should short circuit
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ } catch ( java.text.ParseException e ) {
+ // Ignore and move on
+ }
+ }
+ predicate = request.getHeader( "If-Modified-Since" );
+ if ( predicate != null ) {
+ try {
+ Date predicateDate = dateFormat.parse( predicate );
+ if ( predicateDate.compareTo( entryUpdated ) > 0 ) {
+ // Match, should short circuit
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ } catch ( java.text.ParseException e ) {
+ // Ignore and move on
+ }
+ }
+ }
+ // Provide Etag based on Id and time if given.
+ // Ignore if not given. (Browser may cache if trivial ETag is given.)
+ if (entryETag != null) {
+ response.addHeader(ETAG, entryETag );
+ }
+ if ( entryUpdated != null ) {
+ response.addHeader(LASTMODIFIED, dateFormat.format( entryUpdated ));
+ }
+
+ // Content negotiation
+ String acceptType = request.getHeader( "Accept" );
+ String preferredType = getContentPreference( acceptType );
+ if (( preferredType != null ) && ((preferredType.indexOf( "json") > -1) || (preferredType.indexOf( "JSON") > -1 ))) {
+ // JSON response body
+ response.setContentType("application/json;type=entry");
+ try {
+ Abdera abdera = new Abdera();
+ WriterFactory wf = abdera.getWriterFactory();
+ org.apache.abdera.writer.Writer json = wf.getWriter("json");
+ feedEntry.writeTo(json, response.getWriter());
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ } else {
+ // XML response body
+ response.setContentType("application/atom+xml;type=entry");
+ try {
+ feedEntry.writeTo(getWriter(response));
+ } catch (IOException ioe) {
+ throw new ServletException(ioe);
+ }
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ } else {
+ // Path doesn't match any known pattern
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ }
+
+ protected Feed getFeed( HttpServletRequest request ) throws ServletException {
+ if (supportsFeedEntries) {
+ // The service implementation supports feed entries, invoke its getFeed operation
+ Message requestMessage = messageFactory.createMessage();
+ Message responseMessage;
+ if (request.getQueryString() != null) {
+ requestMessage.setBody(new Object[] {request.getQueryString()});
+ responseMessage = queryInvoker.invoke(requestMessage);
+ } else {
+ responseMessage = getFeedInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ return (Feed)responseMessage.getBody();
+ } else {
+
+ // The service implementation does not support feed entries,
+ // invoke its getAll operation to get the data item collection, then create
+ // feed entries from the items
+ Message requestMessage = messageFactory.createMessage();
+ Message responseMessage;
+ if (request.getQueryString() != null) {
+ requestMessage.setBody(new Object[] {request.getQueryString()});
+ responseMessage = queryInvoker.invoke(requestMessage);
+ } else {
+ responseMessage = getAllInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ Entry<Object, Object>[] collection = (Entry<Object, Object>[])responseMessage.getBody();
+ if (collection != null) {
+
+ // Create the feed
+ Feed feed = abderaFactory.newFeed();
+
+ // Set the feed title
+ if (title != null) {
+ feed.setTitle(title);
+ } else {
+ feed.setTitle("Feed");
+ }
+ if (description != null) {
+ feed.setSubtitle(description);
+ }
+ // All feeds must provide Id and updated elements.
+ // However, some do not, so provide some program protection.
+ feed.setId( "Feed" + feed.hashCode());
+ Date responseLastModified = new Date( 0 );
+
+ // Add entries to the feed
+ for (Entry<Object, Object> entry: collection) {
+ org.apache.abdera.model.Entry feedEntry = feedEntry(entry, itemClassType, itemXMLType, mediator, abderaFactory);
+ // Use the most recent entry update as the feed update
+ Date entryUpdated = feedEntry.getUpdated();
+ if (( entryUpdated != null ) && (entryUpdated.compareTo( responseLastModified ) > 0 )) {
+ responseLastModified = entryUpdated;
+ }
+ feed.addEntry(feedEntry);
+ }
+ // If no entries were newly updated,
+ if ( responseLastModified.compareTo( new Date( 0 ) ) == 0 ) {
+ responseLastModified = new Date();
+ }
+ return feed;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
+ IOException {
+ // Authenticate the user
+ String user = processAuthorizationHeader(request);
+ if (user == null) {
+ unauthorized(response);
+ return;
+ }
+
+ // Get the request path
+ String path = URLDecoder.decode(HTTPUtil.getRequestPath(request), "UTF-8");
+
+ if (path == null || path.length() == 0 || path.equals("/")) {
+ org.apache.abdera.model.Entry createdFeedEntry = null;
+
+ // Create a new Atom entry
+ String contentType = request.getContentType();
+ if (contentType != null && contentType.startsWith("application/atom+xml")) {
+
+ // Read the entry from the request
+ org.apache.abdera.model.Entry feedEntry;
+ try {
+ Document<org.apache.abdera.model.Entry> doc = abderaParser.parse(request.getReader());
+ feedEntry = doc.getRoot();
+ } catch (ParseException pe) {
+ throw new ServletException(pe);
+ }
+
+ // Let the component implementation create it
+ if (supportsFeedEntries) {
+
+ // The service implementation supports feed entries, pass the entry to it
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {feedEntry});
+ Message responseMessage = postInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ createdFeedEntry = responseMessage.getBody();
+ } else {
+
+ // The service implementation does not support feed entries, pass the data item to it
+ Message requestMessage = messageFactory.createMessage();
+ Entry<Object, Object> entry = entry(feedEntry, itemClassType, itemXMLType, mediator);
+ requestMessage.setBody(new Object[] {entry.getKey(), entry.getData()});
+ Message responseMessage = postInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ entry.setKey(responseMessage.getBody());
+ createdFeedEntry = feedEntry(entry, itemClassType, itemXMLType, mediator, abderaFactory);
+ }
+
+ } else if (contentType != null) {
+ // Create a new media entry
+
+ // Get incoming headers
+ String title = request.getHeader("Title");
+ String slug = request.getHeader("Slug");
+
+ // Let the component implementation create the media entry
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {title, slug, contentType, request.getInputStream()});
+ Message responseMessage = postMediaInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ createdFeedEntry = responseMessage.getBody();
+
+ // Transfer media info to response header.
+ // Summary is a comma separated list of header properties.
+ String summary = createdFeedEntry.getSummary();
+ addPropertiesToHeader( response, summary );
+
+ } else {
+ response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+ }
+
+ // A new entry for non-media was created successfully.
+ if (createdFeedEntry != null) {
+ // Set location of the created entry in the Location header
+ IRI feedId = createdFeedEntry.getId();
+ if ( feedId != null ) {
+ response.addHeader(ETAG, "\"" + feedId.toString() + "\"" );
+ }
+ Date entryUpdated = createdFeedEntry.getUpdated();
+ if ( entryUpdated != null ) {
+ response.addHeader(LASTMODIFIED, dateFormat.format( entryUpdated ));
+ }
+ Link link = createdFeedEntry.getSelfLink();
+ if (link != null) {
+ response.addHeader(LOCATION, link.getHref().toString());
+ }
+ Link editLink = createdFeedEntry.getEditLink();
+ if (editLink != null) {
+ response.addHeader(LOCATION, editLink.getHref().toString());
+ }
+ Link editMediaLink = createdFeedEntry.getEditMediaLink();
+ if (editMediaLink != null) {
+ response.addHeader(CONTENTLOCATION, editMediaLink.getHref().toString());
+ }
+
+ // Write the created Atom entry
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ response.setContentType("application/atom+xml;type=entry");
+ try {
+ createdFeedEntry.writeTo(getWriter(response));
+ } catch (ParseException pe) {
+ throw new ServletException(pe);
+ }
+
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ }
+
+ private Writer getWriter(HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+ Writer writer = new OutputStreamWriter(response.getOutputStream(), "UTF-8");
+ return writer;
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Authenticate the user
+ String user = processAuthorizationHeader(request);
+ if (user == null) {
+ unauthorized(response);
+ return;
+ }
+
+ // Get the request path
+ String path = URLDecoder.decode(HTTPUtil.getRequestPath(request), "UTF-8");
+
+ if (path != null && path.startsWith("/")) {
+ String id = path.substring(1);
+
+ // Update an Atom entry
+ String contentType = request.getContentType();
+ if (contentType != null && contentType.startsWith("application/atom+xml")) {
+
+ // Read the entry from the request
+ org.apache.abdera.model.Entry feedEntry;
+ try {
+ Document<org.apache.abdera.model.Entry> doc = abderaParser.parse(request.getReader());
+ feedEntry = doc.getRoot();
+ } catch (ParseException pe) {
+ throw new ServletException(pe);
+ }
+
+ // Let the component implementation create it
+ if (supportsFeedEntries) {
+ // The service implementation supports feed entries, pass the entry to it
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {id, feedEntry});
+ Message responseMessage = putInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ }
+ } else {
+ // The service implementation does not support feed entries, pass the data item to it
+ Message requestMessage = messageFactory.createMessage();
+ Entry<Object, Object> entry = entry(feedEntry, itemClassType, itemXMLType, mediator);
+ requestMessage.setBody(new Object[] {entry.getKey(), entry.getData()});
+ Message responseMessage = putInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ }
+ }
+
+ } else if (contentType != null) {
+
+ // Update a media entry
+
+ // Let the component implementation create the media entry
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {id, contentType, request.getInputStream()});
+ Message responseMessage = putMediaInvoker.invoke(requestMessage);
+
+ Object body = responseMessage.getBody();
+ if (responseMessage.isFault()) {
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ }
+
+ // Transfer content to response header.
+
+ } else {
+ response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // Authenticate the user
+ String user = processAuthorizationHeader(request);
+ if (user == null) {
+ unauthorized(response);
+ return;
+ }
+
+ // Get the request path
+ String path = URLDecoder.decode(HTTPUtil.getRequestPath(request), "UTF-8");
+
+ String id;
+ if (path != null && path.startsWith("/")) {
+ id = path.substring(1);
+ } else {
+ id = "";
+ }
+
+ // Delete a specific entry from the collection
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {id});
+ Message responseMessage = deleteInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ }
+ }
+
+ /**
+ * Process the authorization header
+ *
+ * @param request
+ * @return
+ * @throws ServletException
+ */
+ private String processAuthorizationHeader(HttpServletRequest request) throws ServletException {
+
+ // FIXME temporarily disabling this as it doesn't work with all browsers
+ if (true)
+ return "admin";
+
+ try {
+ String authorization = request.getHeader("Authorization");
+ if (authorization != null) {
+ StringTokenizer tokens = new StringTokenizer(authorization);
+ if (tokens.hasMoreTokens()) {
+ String basic = tokens.nextToken();
+ if (basic.equalsIgnoreCase("Basic")) {
+ String credentials = tokens.nextToken();
+ String userAndPassword = new String(Base64.decodeBase64(credentials.getBytes()));
+ int colon = userAndPassword.indexOf(":");
+ if (colon != -1) {
+ String user = userAndPassword.substring(0, colon);
+ String password = userAndPassword.substring(colon + 1);
+
+ // Authenticate the User.
+ if (authenticate(user, password)) {
+ return user;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ return null;
+ }
+
+ /**
+ * Authenticate a user.
+ *
+ * @param user
+ * @param password
+ * @return
+ */
+ private boolean authenticate(String user, String password) {
+ // TODO Handle this using SCA security policies
+ return ("admin".equals(user) && "admin".equals(password));
+ }
+
+ /**
+ * Reject an unauthorized request.
+ *
+ * @param response
+ */
+ private void unauthorized(HttpServletResponse response) throws IOException {
+ response.setHeader("WWW-Authenticate", "BASIC realm=\"Tuscany\"");
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+
+ /**
+ * Get content-type preference using application/atom-xml as default
+ * @param acceptType content-type preference using application/atom-xml as default
+ * @return
+ */
+ private static String getContentPreference( String acceptType ) {
+ if (( acceptType == null ) || ( acceptType.length() < 1 )) {
+ return "application/atom+xml";
+ }
+ StringTokenizer st = new StringTokenizer( acceptType, "," );
+ if ( st.hasMoreTokens() ) {
+ return st.nextToken();
+ }
+ return "application/atom+xml";
+ }
+
+ /** Take a list of key values and add them to the header.
+ * For instance "Content-Type=image/gif,Content-Length=14201"
+ * @param response
+ * @param properties
+ */
+ private static void addPropertiesToHeader( HttpServletResponse response, String properties ) {
+ if ( properties == null ) return;
+ StringTokenizer props = new StringTokenizer( properties, ",");
+ while( props.hasMoreTokens()) {
+ String prop = props.nextToken();
+ StringTokenizer keyVal = new StringTokenizer( prop, "=");
+ String key = null;
+ String val = null;
+ if ( keyVal.hasMoreTokens() )
+ key = keyVal.nextToken();
+ if ( keyVal.hasMoreTokens() )
+ val = keyVal.nextToken();
+ if (( key != null ) && ( val != null )) {
+ response.addHeader(key, val);
+ }
+ }
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java
new file mode 100644
index 0000000000..a160925e4e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.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.sca.binding.atom.provider;
+
+import org.apache.tuscany.sca.binding.atom.AtomBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Implementation of a Binding provider factory for the Atom binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomBindingProviderFactory implements BindingProviderFactory<AtomBinding> {
+
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private ServletHost servletHost;
+
+ public AtomBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ this.mediator = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new AtomReferenceBindingProvider(endpointReference, mediator);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new AtomServiceBindingProvider(endpoint, messageFactory, mediator, servletHost);
+ }
+
+ public Class<AtomBinding> getModelType() {
+ return AtomBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java
new file mode 100644
index 0000000000..fad06a0c99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom.provider;
+
+import java.util.Date;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.model.Content.Type;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.Item;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * Utility methods used in this package.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomBindingUtil {
+
+ /**
+ * Create a data item from an Atom entry.
+ * @param feedEntry
+ * @param itemClassType
+ * @param itemXMLType
+ * @param mediator
+ * @return
+ */
+ static Entry<Object, Object> entry(org.apache.abdera.model.Entry feedEntry,
+ DataType<?> itemClassType, DataType<?> itemXMLType, Mediator mediator) {
+ if (feedEntry != null) {
+ if (itemClassType.getPhysical() == Item.class || feedEntry.getContentType() == Type.HTML ) {
+ String key = feedEntry.getId().toString();
+
+ Item item = new Item();
+ item.setTitle(feedEntry.getTitle());
+ item.setContents(feedEntry.getContent());
+
+ for (Link link : feedEntry.getLinks()) {
+ if (link.getRel() == null || "self".equals(link.getRel())) {
+ if (item.getLink() == null) {
+ item.setLink(link.getHref().toString());
+ }
+ } else if ("related".equals(link.getRel())) {
+ item.setRelated(link.getHref().toString());
+ } else if ("alternate".equals(link.getRel())) {
+ item.setAlternate(link.getHref().toString());
+ }
+ }
+
+ item.setDate(feedEntry.getUpdated());
+
+ return new Entry<Object, Object>(key, item);
+
+ } else {
+ String key = null;
+ if ( feedEntry.getId() != null) {
+ key = feedEntry.getId().toString();
+ }
+
+ // Create the item from XML
+ if (feedEntry.getContentElement().getElements().size() == 0) {
+ return null;
+ }
+
+ String value = feedEntry.getContent();
+ Object data = mediator.mediate(value, itemXMLType, itemClassType, null);
+
+ return new Entry<Object, Object>(key, data);
+ }
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create an Atom entry for a key and item from a collection.
+ * @param entry
+ * @param itemClassType
+ * @param itemXMLType
+ * @param mediator
+ * @param factory
+ * @return
+ */
+ static org.apache.abdera.model.Entry feedEntry(Entry<Object, Object> entry,
+ DataType<?> itemClassType, DataType<?> itemXMLType, Mediator mediator,
+ Factory factory) {
+ Object key = entry.getKey();
+ Object data = entry.getData();
+ if (data instanceof Item) {
+ Item item = (Item)data;
+
+ org.apache.abdera.model.Entry feedEntry = factory.newEntry();
+ if (key != null) {
+ feedEntry.setId(key.toString());
+ }
+ feedEntry.setTitle(item.getTitle());
+ feedEntry.setContentAsHtml(item.getContents());
+
+ String href = item.getLink();
+ if (href == null && key != null) {
+ href = key.toString();
+ }
+
+ if (href != null) {
+ feedEntry.addLink(href);
+ }
+ String related = item.getRelated();
+ if (related != null) {
+ feedEntry.addLink(related, "related");
+ }
+ String alternate = item.getAlternate();
+ if (alternate != null) {
+ feedEntry.addLink(alternate, "alternate");
+ }
+
+ Date date = item.getDate();
+ if (date != null) {
+ feedEntry.setUpdated(date);
+ }
+ return feedEntry;
+
+ } else if (data != null) {
+ org.apache.abdera.model.Entry feedEntry = factory.newEntry();
+ feedEntry.setId(key.toString());
+ feedEntry.setTitle("item");
+
+
+ // Convert the item to XML
+ String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString();
+
+ Content content = factory.newContent();
+ content.setContentType(Content.Type.XML);
+ content.setValue(value);
+
+ feedEntry.setContentElement(content);
+
+ feedEntry.addLink(key.toString());
+
+ return feedEntry;
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
new file mode 100644
index 0000000000..9291b8556b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom.provider;
+
+import java.net.URI;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.atom.AtomBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of the Atom binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomReferenceBindingProvider implements ReferenceBindingProvider {
+ private EndpointReference endpointReference;
+ private RuntimeComponentReference reference;
+ private AtomBinding binding;
+ private String authorizationHeader;
+ private HttpClient httpClient;
+ private Mediator mediator;
+ private DataType<?> itemClassType;
+ private DataType<?> itemXMLType;
+ private boolean supportsFeedEntries;
+
+ /**
+ * Constructs a new AtomReferenceBindingProvider
+ * @param component
+ * @param reference
+ * @param binding
+ * @param mediator
+ */
+ AtomReferenceBindingProvider(EndpointReference endpointReference,
+ Mediator mediator) {
+ this.endpointReference = endpointReference;
+ this.reference = (RuntimeComponentReference) endpointReference.getReference();
+ this.binding = (AtomBinding) endpointReference.getBinding();
+ this.mediator = mediator;
+
+ // Prepare authorization header
+ String authorization = "admin" + ":" + "admin";
+ authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes()));
+
+ // Create an HTTP client
+ HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+ connectionManager.getParams().setDefaultMaxConnectionsPerHost(10);
+ connectionManager.getParams().setConnectionTimeout(60000);
+ httpClient = new HttpClient(connectionManager);
+ }
+
+ public Invoker createInvoker(Operation operation) {
+
+ String operationName = operation.getName();
+ if (operationName.equals("get")) {
+
+ // Determine the collection item type
+ itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
+ Class<?> itemClass = operation.getOutputType().getPhysical();
+ DataType<XMLType> outputType = operation.getOutputType();
+ itemClassType = outputType;
+ if (itemClassType.getPhysical() == org.apache.abdera.model.Entry.class) {
+ supportsFeedEntries = true;
+ }
+
+ return new AtomBindingInvoker.GetInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+
+ } else if (operationName.equals("post")) {
+ return new AtomBindingInvoker.PostInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+ } else if (operationName.equals("put")) {
+ return new AtomBindingInvoker.PutInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+ } else if (operationName.equals("delete")) {
+ return new AtomBindingInvoker.DeleteInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+ } else if (operationName.equals("getFeed") || operationName.equals("getAll")) {
+ return new AtomBindingInvoker.GetAllInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+ } else if (operationName.equals("postMedia")) {
+ return new AtomBindingInvoker.PostMediaInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+ } else if (operationName.equals("putMedia")) {
+ return new AtomBindingInvoker.PutMediaInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+ } else if (operationName.equals("query")) {
+ return new AtomBindingInvoker.QueryInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+ }
+
+ return new AtomBindingInvoker(operation, binding.getURI(), httpClient, authorizationHeader, this);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ public void start() {
+
+ // Configure the HTTP client credentials
+ Credentials credentials = new UsernamePasswordCredentials("admin", "admin");
+ httpClient.getParams().setAuthenticationPreemptive(true);
+ URI uri = URI.create(binding.getURI());
+ httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), credentials);
+
+ // Find the get operation on the reference interface
+ if (true) {
+ return;
+ }
+ }
+
+ public void stop() {
+
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ /**
+ * Returns the mediator.
+ * @return
+ */
+ Mediator getMediator() {
+ return mediator;
+ }
+
+ /**
+ * Returns the item class type.
+ * @return
+ */
+ DataType<?> getItemClassType() {
+ return itemClassType;
+ }
+
+ /**
+ * Returns the item XML type.
+ * @return
+ */
+ DataType<?> getItemXMLType() {
+ return itemXMLType;
+ }
+
+ /**
+ * Returns true if the invoker should work with Atom
+ * feed entries.
+ * @return
+ */
+ boolean supportsFeedEntries() {
+ return supportsFeedEntries;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java
new file mode 100644
index 0000000000..155d07ae86
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom.provider;
+
+import org.apache.tuscany.sca.binding.atom.AtomBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Implementation of the Atom binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomServiceBindingProvider implements ServiceBindingProvider {
+ private MessageFactory messageFactory;
+
+ private RuntimeEndpoint endpoint;
+
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private InterfaceContract serviceContract;
+ private AtomBinding binding;
+ private ServletHost servletHost;
+ private Mediator mediator;
+
+ private String servletMapping;
+ private String bindingURI;
+
+ AtomServiceBindingProvider(RuntimeEndpoint endpoint,
+ MessageFactory messageFactory,
+ Mediator mediator,
+ ServletHost servletHost) {
+ this.endpoint = endpoint;
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (AtomBinding) endpoint.getBinding();
+
+ this.servletHost = servletHost;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+
+ // TUSCANY-3166
+ this.serviceContract = endpoint.getComponentTypeServiceInterfaceContract();
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return serviceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ Invocable wire = (RuntimeEndpoint) endpoint;
+
+ AtomBindingListenerServlet servlet =
+ new AtomBindingListenerServlet(wire, messageFactory, mediator, binding.getTitle(), binding.getDescription());
+
+ servletMapping = binding.getURI();
+ if (!servletMapping.endsWith("/")) {
+ servletMapping += "/";
+ }
+ if (!servletMapping.endsWith("*")) {
+ servletMapping += "*";
+ }
+ servletHost.addServletMapping(servletMapping, servlet);
+
+ bindingURI = binding.getURI();
+ if (!bindingURI.endsWith("/")) {
+ bindingURI += "/";
+ }
+
+ servletHost.addServletMapping(bindingURI, servlet);
+ }
+
+ public void stop() {
+ servletHost.removeServletMapping(servletMapping);
+ servletHost.removeServletMapping(bindingURI);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..1accd4cfb4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.atom.provider.AtomBindingProviderFactory;model=org.apache.tuscany.sca.binding.atom.AtomBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.java
new file mode 100644
index 0000000000..77c2562c0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.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.sca.binding.atom;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractProviderConsumerTestCase {
+ protected static Node scaProviderNode;
+ protected static Node scaConsumerNode;
+
+ protected static void initTestEnvironment(Class<?> testClazz) throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(testClazz);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ scaConsumerNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution));
+ scaConsumerNode.start();
+ }
+
+ protected static void destroyTestEnvironment() throws Exception {
+ if (scaConsumerNode != null) {
+ scaConsumerNode.stop();
+ }
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java
new file mode 100644
index 0000000000..da3c8b7594
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.util.UUID;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomDeleteTestCase extends AbstractProviderConsumerTestCase {
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ // System.out.println(">>>AtomDeleteTestCase.init entry");
+
+ initTestEnvironment(AtomDeleteTestCase.class);
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+ abdera = new Abdera();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // System.out.println(">>>AtomDeleteTestCase.destroy entry");
+
+ destroyTestEnvironment();
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(testService);
+ Assert.assertNotNull(abdera);
+ }
+
+ @Test
+ public void testAtomDelete() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry postEntry = postEntry("Sponge Bob");
+ // System.out.println(">>> post entry= " + postEntry.getTitle());
+
+ Entry newEntry = resourceCollection.post(postEntry);
+ // System.out.println("<<< Entry posted for " + newEntry.getTitle());
+
+ // System.out.println(">>> get id=" + newEntry.getId());
+
+ resourceCollection.delete(newEntry.getId().toString());
+
+ }
+
+ @Test
+ public void testAtomDeleteException() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ try {
+ // Generates custom ID
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+ resourceCollection.delete(id);
+ } catch (Exception e) {
+ // ID doesn't match with the existing IDs and NotFoundException is
+ // thrown
+ Assert.assertEquals("NotFoundException", e.getClass().getSimpleName());
+ }
+
+ }
+
+ private Entry postEntry(String value) {
+ Entry entry = abdera.newEntry();
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java
new file mode 100644
index 0000000000..9c0ad5a26a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.model.Link;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.Item;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test cases for using an Atom feed that does not implement
+ * the Collections interface but does have a getAll() method.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomFeedNonCollectionTest {
+ /**
+ * Used to generate unique IDs for the feed entries.
+ */
+ private static final AtomicInteger ID_GEN = new AtomicInteger();
+
+ /**
+ * Data used for creating test feed entries.
+ */
+ private static final String[] FEED_ENTRY_TITLES = {"Apache Tuscany", "Apache"};
+
+ /**
+ * Data used for creating test feed entries.
+ */
+ private static final String[] FEED_ENTRY_CONTENT = {"This is Apache Tuscany", "This is Apache"};
+
+ /**
+ * Data used for creating test feed entries.
+ */
+ private static final String[] FEED_ENTRY_LINK = {"http://tuscany.apache.org", "http://www.apache.org"};
+
+ /**
+ * The number of test feed entries.
+ */
+ private static final int FEED_ENTRY_COUNT = FEED_ENTRY_TITLES.length;
+
+ protected static Node scaProviderNode;
+ protected static Node scaConsumerNode;
+
+ private static CustomerClient testService;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ //System.out.println(">>>AtomFeedNonCollectionTest.init entry");
+
+ String contribution = ContributionLocationHelper.getContributionLocation(AtomFeedNonCollectionTest.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ scaConsumerNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution));
+ scaConsumerNode.start();
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (scaConsumerNode != null) {
+ scaConsumerNode.stop();
+ }
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ /**
+ * Make sure everything has been initialized correctly.
+ */
+ @SuppressWarnings("unchecked")
+ @Before
+ public void testPrelim() {
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(testService);
+
+ // Add some entries to the Atom feed
+ final Entry<Object, Object>[] testEntries = new Entry[FEED_ENTRY_COUNT];
+ for (int i = 0; i < FEED_ENTRY_COUNT; i++) {
+ testEntries[i] = createFeedEntry(FEED_ENTRY_TITLES[i], FEED_ENTRY_CONTENT[i], FEED_ENTRY_LINK[i]);
+ }
+ CustomerNonCollectionImpl.entries = testEntries;
+ }
+
+ /**
+ * Post test cleanup
+ */
+ @After
+ public void testPostCleanup()
+ {
+ // Clear any old feed entries that have been added by previous tests
+ CustomerNonCollectionImpl.entries = null;
+ }
+
+ /**
+ * Test that we can retrieve entries from a feed that does not implement
+ * the Collection interface.
+ */
+ @Test
+ public void testThatCanGetFeedEntriesFromNonCollectionImplementation() {
+ // Get the entries from the feed
+ final Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+ final List<org.apache.abdera.model.Entry> entries = resourceCollection.getFeed().getEntries();
+
+ // Validate the feed entries
+ Assert.assertNotNull(entries);
+ Assert.assertEquals(FEED_ENTRY_COUNT, entries.size());
+ for (int i = 0; i < FEED_ENTRY_COUNT; i++) {
+ final org.apache.abdera.model.Entry entry = entries.get(i);
+ Assert.assertEquals(FEED_ENTRY_TITLES[i], entry.getTitle());
+ Assert.assertEquals(FEED_ENTRY_CONTENT[i], entry.getContent());
+ final List<Link> links = entry.getLinks();
+ Assert.assertNotNull(links);
+ Assert.assertEquals(1, links.size());
+ final Link link = links.get(0);
+ final String linkStr = link.getHref().toString();
+ Assert.assertEquals(FEED_ENTRY_LINK[i], linkStr);
+ }
+ }
+
+ /**
+ * Tests that the title of the feed can be set by the title
+ * attribute on the binding.atom
+ */
+ @Test
+ public void testThatFeedTitleSet() {
+ final String expectedFeedTitle = "Atom binding Non Collection";
+
+ // Get the title of the feed
+ final Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+ final String feedTitle = resourceCollection.getFeed().getTitle();
+
+ // Validate the title
+ Assert.assertEquals(expectedFeedTitle, feedTitle);
+ }
+
+ /**
+ * Tests that the description of the feed can be set by the description
+ * attribute on the binding.atom
+ */
+ @Test
+ public void testThatFeedDescriptionSet() {
+ final String expectedFeedDescription = "Feed used for unit testing";
+
+ // Get the description of the feed
+ final Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+ final String feedDescription = resourceCollection.getFeed().getSubtitle();
+
+ // Validate the description
+ Assert.assertEquals(expectedFeedDescription, feedDescription);
+ }
+
+ /**
+ * Creates a feed entry.
+ *
+ * @param title Title for the feed entry
+ * @param content Contents of the feed entry
+ * @param link Link for the feed entry
+ * @return A new feed entry.
+ */
+ private Entry<Object, Object> createFeedEntry(String title, String content, String link) {
+ final Item item = new Item(title, content, link, null, new Date());
+ final Entry<Object, Object> entry = new Entry<Object, Object>(nextFeedID(), item);
+ return entry;
+ }
+
+ /**
+ * Generates the feed entry ID.
+ *
+ * @return Next feed entry ID
+ */
+ private String nextFeedID() {
+ return Integer.toString(ID_GEN.incrementAndGet());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java
new file mode 100644
index 0000000000..7f74ef019d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomGetTestCase extends AbstractProviderConsumerTestCase {
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ //System.out.println(">>>AtomGetTestCase.init entry");
+
+ initTestEnvironment(AtomFeedNonCollectionTest.class);
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+ abdera = new Abdera();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // System.out.println(">>>AtomGetTestCase.destroy entry");
+ destroyTestEnvironment();
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(testService);
+ Assert.assertNotNull(abdera);
+ }
+
+ @Test
+ public void testAtomGet() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry postEntry = postEntry("Sponge Bob");
+ //System.out.println(">>> post entry= " + postEntry.getTitle());
+
+ Entry newEntry = resourceCollection.post(postEntry);
+ //System.out.println("<<< Entry posted for " + newEntry.getTitle());
+
+ //System.out.println(">>> get id=" + newEntry.getId());
+
+ Entry getEntry = resourceCollection.get(newEntry.getId().toString());
+
+ Assert.assertEquals(newEntry.getTitle(), getEntry.getTitle());
+ //System.out.println("<<< get id=" + getEntry.getId() + " entry=" + getEntry.getTitle());
+ }
+
+ @Test
+ public void testAtomGetException() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry postEntry = postEntry("Sponge Bob");
+ //System.out.println(">>> post entry= " + postEntry.getTitle());
+
+ Entry newEntry = resourceCollection.post(postEntry);
+ //System.out.println("<<< Entry posted for " + newEntry.getTitle());
+ //System.out.println(newEntry.getId());
+
+ // Delete the entry to force the Collection to throw NotFoundException
+ resourceCollection.delete(newEntry.getId().toString());
+
+ try {
+ resourceCollection.get(newEntry.getId().toString());
+ } catch (Exception e) {
+ Assert.assertEquals("NotFoundException", e.getClass().getSimpleName());
+ }
+ }
+
+ private Entry postEntry(String value) {
+ Entry entry = abdera.newEntry();
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java
new file mode 100644
index 0000000000..50a684beba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.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.sca.binding.atom;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomPostTestCase extends AbstractProviderConsumerTestCase {
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ //System.out.println(">>>AtomPostTestCase.init entry");
+
+ initTestEnvironment(AtomPostTestCase.class);
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+ abdera = new Abdera();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ //System.out.println(">>>AtomPostTestCase.destroy entry");
+
+ destroyTestEnvironment();
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(testService);
+ Assert.assertNotNull(abdera);
+ }
+
+ @Test
+ public void testAtomPost() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry postEntry = postEntry("Sponge Bob");
+ //System.out.println(">>> post entry= " + postEntry.getTitle());
+
+ Entry newEntry = resourceCollection.post(postEntry);
+
+ Assert.assertEquals(postEntry.getTitle(), newEntry.getTitle());
+
+ //System.out.println("<<< new entry= " + newEntry.getTitle());
+
+ }
+
+ @Test
+ public void testAtomPostException() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry postEntry = postEntry("Exception_Test");
+
+ try {
+ resourceCollection.post(postEntry);
+ } catch (Exception e) {
+ Assert.assertEquals("HTTP status code: 500", e.getMessage());
+ }
+ }
+
+ private Entry postEntry(String value) {
+ Entry entry = abdera.newEntry();
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java
new file mode 100644
index 0000000000..4e09eea032
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.util.UUID;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomPutTestCase extends AbstractProviderConsumerTestCase {
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ //System.out.println(">>>AtomPutTestCase.init entry");
+
+ initTestEnvironment(AtomPutTestCase.class);
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+ abdera = new Abdera();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // System.out.println(">>>AtomPutTestCase.destroy entry");
+
+ destroyTestEnvironment();
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(testService);
+ Assert.assertNotNull(abdera);
+ }
+
+ @Test
+ public void testAtomPut() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry postEntry = postEntry("Sponge Bob");
+ //System.out.println(">>> post entry= " + postEntry.getTitle());
+
+ Entry newEntry = resourceCollection.post(postEntry);
+ //System.out.println("<<< Entry posted for " + newEntry.getTitle());
+ //System.out.println(newEntry.getId());
+
+ //System.out.println(">>> put id=" + newEntry.getId() + " entry=" + newEntry.getTitle());
+ resourceCollection.put(newEntry.getId().toString(), updateEntry(newEntry, "James Bond"));
+ //System.out.println("<<< put id=" + newEntry.getId() + " entry=" + newEntry.getTitle());
+ }
+
+ @Test
+ public void testAtomPutException() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry postEntry = postEntry("Sponge Bob");
+ //System.out.println(">>> post entry= " + postEntry.getTitle());
+
+ // Generate random ID to pass as parameter in PUT() --
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+ try {
+ // ID doesn't match with the existing IDs and NotFoundException is thrown
+ resourceCollection.put(id, updateEntry(postEntry, "James Bond"));
+ } catch (Exception e) {
+ Assert.assertEquals("NotFoundException", e.getClass().getSimpleName());
+ }
+ }
+
+ private Entry postEntry(String value) {
+ Entry entry = abdera.newEntry();
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+ private Entry updateEntry(Entry entry, String value) {
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java
new file mode 100644
index 0000000000..e6fa67883a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.atom;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Consumer {
+
+ public static void main(String[] args) throws Exception {
+
+ String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class);
+ Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Consumer.composite",new Contribution("c1", contribution));
+
+ CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient");
+ testService.testCustomerCollection();
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java
new file mode 100644
index 0000000000..07909388e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test case for the given package.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConsumerProviderAtomTestCase extends AbstractProviderConsumerTestCase {
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ //System.out.println(">>>AtomBindingIntegratedTestCase.init entry");
+
+ initTestEnvironment(ConsumerProviderAtomTestCase.class);
+
+ testService = scaConsumerNode.getService(CustomerClient.class,"CustomerClient");
+ abdera = new Abdera();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ //System.out.println(">>>AtomBindingIntegratedTestCase.destroy entry");
+
+ destroyTestEnvironment();
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(testService);
+ Assert.assertNotNull(abdera);
+ }
+
+ @Test
+ public void testEntry() throws Exception {
+ // System.out.println( getClass().getName() + ".testEntry entry" );
+ Entry entry = abdera.newEntry();
+ Assert.assertNotNull(entry);
+
+ String testTitle = "Sponge Bob";
+ entry.setTitle(testTitle);
+ Assert.assertEquals(testTitle, entry.getTitle());
+
+ String testContent = "This is the content";
+ entry.setContent(testContent);
+ Assert.assertEquals(testContent, entry.getContent());
+
+ Date now = new Date();
+ entry.setEdited(now);
+ Assert.assertEquals(now, entry.getEdited());
+
+ Date later = new Date();
+ entry.setPublished(later);
+ Assert.assertEquals(later, entry.getPublished());
+
+ String testSummary = "This is the summary";
+ entry.setSummary(testSummary);
+ Assert.assertEquals(testSummary, entry.getSummary());
+ }
+
+ @Test
+ public void testCustomerCollection() throws Exception {
+ System.out.println(getClass().getName() + ".testCustomerCollection entry");
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry newEntry = newEntry("Sponge Bob");
+ //System.out.println(">>> post entry=" + newEntry.getTitle());
+ newEntry = resourceCollection.post(newEntry);
+ //System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle());
+
+ newEntry = newEntry("Jane Bond");
+ //System.out.println(">>> post entry=" + newEntry.getTitle());
+ newEntry = resourceCollection.post(newEntry);
+ //System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle());
+
+ //System.out.println(">>> get id=" + newEntry.getId());
+ Entry entry = resourceCollection.get(newEntry.getId().toString());
+ //System.out.println("<<< get id=" + entry.getId() + " entry=" + entry.getTitle());
+
+ //System.out.println(">>> put id=" + newEntry.getId() + " entry=" + entry.getTitle());
+ resourceCollection.put(entry.getId().toString(), updateEntry(entry, "James Bond"));
+ //System.out.println("<<< put id=" + entry.getId() + " entry=" + entry.getTitle());
+
+ //System.out.println(">>> delete id=" + entry.getId());
+ resourceCollection.delete(entry.getId().toString());
+ //System.out.println("<<< delete id=" + entry.getId());
+
+ //System.out.println(">>> get collection");
+ Feed feed = resourceCollection.getFeed();
+ //System.out.println("<<< get collection");
+ for (Object o : feed.getEntries()) {
+ Entry e = (Entry)o;
+ //System.out.println("id = " + e.getId() + " entry = " + e.getTitle());
+ }
+ }
+
+ private Entry newEntry(String value) {
+ Entry entry = abdera.newEntry();
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+ private Entry updateEntry(Entry entry, String value) {
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java
new file mode 100644
index 0000000000..0b999ae1c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.protocol.Response.ResponseType;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.client.RequestOptions;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests use of content negotiation for Atom binding in Tuscany.
+ * Uses the SCA provided Provider composite to act as a server.
+ * Uses the Abdera provided Client to act as a client.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContentNegotiationTest {
+ public final static String providerURI = "http://localhost:8084/customer";
+
+ protected static Node scaProviderNode;
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+ protected static AbderaClient client;
+ protected static Parser abderaParser;
+ protected static String lastId;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ //System.out.println(">>>ContentNegotiationTest.init");
+ String contribution = ContributionLocationHelper.getContributionLocation(ContentNegotiationTest.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ abdera = new Abdera();
+ client = new AbderaClient(abdera);
+ abderaParser = Abdera.getNewParser();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.destroy");
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull( client );
+ }
+
+ @Test
+ public void testPost() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testPost");
+ // Testing of entry creation
+ Factory factory = abdera.getFactory();
+ String customerName = "Fred Farkle";
+ Entry entry = factory.newEntry();
+ entry.setTitle("customer " + customerName);
+ entry.setUpdated(new Date());
+ entry.addAuthor("Apache Tuscany");
+ // ID created by collection.
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(customerName);
+ entry.setContentElement(content);
+
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", opts );
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ ClientResponse res = client.post(colUri.toString(), entry, opts);
+
+ // Assert response status code is 201-OK.
+ // Assert response header Content-Type: application/atom+xml; charset=UTF-8
+ Assert.assertEquals(201, res.getStatus());
+ String returnedContentType = res.getContentType().toString().trim();
+ Assert.assertEquals(contentType, returnedContentType );
+
+ String eTag = res.getHeader( "ETag" );
+ if ( eTag != null)
+ lastId = eTag.substring( 1, eTag.length()-1);
+
+ // AtomTestCaseUtils.printResponseHeaders( "Entry post response headers:", " ", res );
+ // System.out.println("Entry post response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+ }
+
+ @Test
+ public void testXMLEntryGet() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testXMLEntryGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader( "Accept", "application/atom+xml" );
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
+ Assert.assertEquals(200, res.getStatus());
+ String returnedContentType = res.getContentType().toString().trim();
+ // Assert.assertEquals(contentType, returnedContentType );
+ res.release();
+ }
+
+ @Test
+ public void testJSONEntryGet() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testJSONEntryGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader( "Accept", "application/json" );
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
+ try {
+ Assert.assertEquals(200, res.getStatus());
+ // Abdera 0.4 throws exception on getContentType with application/json.
+ // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
+ String contentType = res.getHeader( "Content-Type");
+ Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
+ // Following is a poor man's JSONObject test to avoid dependency on JSON libs.
+ // JSONObject jsonResp = new JSONObject(res.);
+ // Assert.assertEquals(12345, jsonResp.getInt("result"));
+ String responseBody = readResponse( res.getReader() );
+ Assert.assertTrue( responseBody.startsWith( "{") );
+ Assert.assertTrue( responseBody.endsWith( "}") );
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
+ // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
+ // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testXMLFeedGet() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testXMLFeedGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader( "Accept", "application/atom+xml" );
+
+ // Atom feed request
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Asser feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+ // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res );
+ // System.out.println("Feed response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+
+ // Perform other tests on feed.
+ Document<Feed> doc = res.getDocument();
+ Assert.assertNotNull( doc );
+ Feed feed = doc.getRoot();
+ Assert.assertNotNull( feed );
+ // RFC 4287 requires non-null id, title, updated elements
+ Assert.assertNotNull( feed.getId() );
+ Assert.assertNotNull( feed.getTitle() );
+ Assert.assertNotNull( feed.getUpdated() );
+ // AtomTestCaseUtils.printFeed( "Feed values", " ", feed );
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testJSONFeedGet() throws Exception {
+ //System.out.println(">>>ContentNegotiationTest.testJSONFeedGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader( "Accept", "application/json" );
+
+ // JSON feed request
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Assert feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ // Abdera 0.4 throws exception on getContentType with application/json.
+ // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
+ String contentType = res.getHeader( "Content-Type");
+ Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
+ // Following is a poor man's JSONObject test to avoid dependency on JSON libs.
+ // JSONObject jsonResp = new JSONObject(res.);
+ // Assert.assertEquals(12345, jsonResp.getInt("result"));
+ String responseBody = readResponse( res.getReader() );
+ Assert.assertTrue( responseBody.startsWith( "{") );
+ Assert.assertTrue( responseBody.endsWith( "}") );
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
+ Assert.assertTrue( -1 < responseBody.indexOf( "\"entries\"" ));
+ // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
+ // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
+ } finally {
+ res.release();
+ }
+ }
+
+ protected String readResponse( Reader responseReader ) {
+ if ( responseReader == null ) return "";
+ StringBuffer sb = new StringBuffer(1024);
+ try {
+ int charValue = 0;
+ while ((charValue = responseReader.read()) != -1) {
+ //result = result + (char) charValue;
+ sb.append((char)charValue);
+ }
+ } catch ( IOException e ) {
+ }
+ return sb.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClient.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClient.java
new file mode 100644
index 0000000000..85c4d4f56a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClient.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.atom;
+
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CustomerClient {
+
+ void testCustomerCollection() throws Exception;
+
+ Collection getCustomerCollection();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClientImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClientImpl.java
new file mode 100644
index 0000000000..4e3b8241f8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClientImpl.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.sca.binding.atom;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class CustomerClientImpl implements CustomerClient {
+
+ protected final Abdera abdera = new Abdera();
+
+ @Reference
+ public Collection customerCollection;
+
+ public void testCustomerCollection() throws Exception {
+
+ Entry newEntry = newEntry("Sponge Bob");
+ //System.out.println(">>> post entry=" + newEntry.getTitle());
+ newEntry = customerCollection.post(newEntry);
+ //System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle());
+
+ newEntry = newEntry("Jane Bond");
+ //System.out.println(">>> post entry=" + newEntry.getTitle());
+ newEntry = customerCollection.post(newEntry);
+ //System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle());
+
+ //System.out.println(">>> get id=" + newEntry.getId());
+ Entry entry = customerCollection.get(newEntry.getId().toString());
+ //System.out.println("<<< get id=" + entry.getId() + " entry=" + entry.getTitle());
+
+ //System.out.println(">>> put id=" + newEntry.getId() + " entry=" + entry.getTitle());
+ customerCollection.put(entry.getId().toString(), updateEntry(entry, "James Bond"));
+ //System.out.println("<<< put id=" + entry.getId() + " entry=" + entry.getTitle());
+
+ //System.out.println(">>> delete id=" + entry.getId());
+ customerCollection.delete(entry.getId().toString());
+ //System.out.println("<<< delete id=" + entry.getId());
+
+ //System.out.println(">>> get collection");
+ Feed feed = customerCollection.getFeed();
+ //System.out.println("<<< get collection");
+ for (Object o : feed.getEntries()) {
+ Entry e = (Entry)o;
+ //System.out.println("id = " + e.getId() + " entry = " + e.getTitle());
+ }
+ }
+
+ public Collection getCustomerCollection() {
+ return customerCollection;
+ }
+
+ private Entry newEntry(String value) {
+
+ Entry entry = this.abdera.newEntry();
+ entry.setTitle("customer " + value);
+
+ Content content = this.abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+ private Entry updateEntry(Entry entry, String value) {
+
+ entry.setTitle("customer " + value);
+
+ Content content = this.abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+
+ entry.setContentElement(content);
+
+ return entry;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java
new file mode 100644
index 0000000000..9e50cbbae7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class CustomerCollectionImpl implements Collection {
+ private final Abdera abdera = new Abdera();
+ private Map<String, Entry> entries = new HashMap<String, Entry>();
+ public Date lastModified = new Date();
+
+ /**
+ * Default constructor
+ */
+ public CustomerCollectionImpl() {
+
+ }
+
+ public Entry post(Entry entry) {
+ //System.out.println(">>> CustomerCollectionImpl.post entry=" + entry.getTitle());
+
+ if(!("Exception_Test".equalsIgnoreCase(entry.getTitle())))
+ {
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+ entry.setId(id);
+
+ entry.addLink("" + id, "edit");
+ entry.addLink("" + id, "alternate");
+ Date now = new Date();
+ entry.setUpdated(now);
+ lastModified = now;
+ entries.put(id, entry);
+
+ //System.out.println(">>> CustomerCollectionImpl.post return id=" + id);
+
+ return entry;
+
+ }
+ else
+ {
+ throw new IllegalArgumentException("Exception in Post method");
+ }
+ }
+
+ public Entry get(String id) {
+ //System.out.println(">>> CustomerCollectionImpl.get id=" + id);
+ return entries.get(id);
+ }
+
+ public void put(String id, Entry entry) throws NotFoundException {
+ //System.out.println(">>> CustomerCollectionImpl.put id=" + id + " entry=" + entry.getTitle());
+ if(entries.containsKey(id)){
+ Date now = new Date();
+ entry.setUpdated(now);
+ lastModified = now;
+ entries.put(id, entry);
+ }
+ else {
+ throw new NotFoundException();
+ }
+ }
+
+ public void delete(String id) throws NotFoundException {
+ //System.out.println(">>> CustomerCollectionImpl.delete id=" + id);
+ if(entries.containsKey(id)){
+ entries.remove(id);
+ lastModified = new Date();
+ }
+ else {
+ throw new NotFoundException();
+ }
+ }
+
+ public Feed getFeed() {
+ //System.out.println(">>> CustomerCollectionImpl.getFeed");
+
+ Feed feed = this.abdera.getFactory().newFeed();
+ feed.setId("customers" + this.hashCode() ); // provide unique id for feed instance.
+ feed.setTitle("customers");
+ feed.setSubtitle("This is a sample feed");
+ feed.setUpdated(lastModified);
+ feed.addLink("");
+ feed.addLink("", "self");
+
+ for (Entry entry : entries.values()) {
+ feed.addEntry(entry);
+ }
+
+ return feed;
+ }
+
+ public Feed query(String queryString) {
+ //System.out.println(">>> CustomerCollectionImpl.query collection " + queryString);
+ return getFeed();
+ }
+
+ // This method used for testing.
+ protected void testPut(String value) {
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+
+ Entry entry = abdera.getFactory().newEntry();
+ entry.setId(id);
+ entry.setTitle("customer " + value);
+
+ Content content = this.abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+
+ entry.setContentElement(content);
+
+ entry.addLink("" + id, "edit");
+ entry.addLink("" + id, "alternate");
+
+ entry.setUpdated(new Date());
+
+ entries.put(id, entry);
+ System.out.println(">>> id=" + id);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerNonCollectionImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerNonCollectionImpl.java
new file mode 100644
index 0000000000..dbf6b5aed5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerNonCollectionImpl.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.atom;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * Implementation of an Atom feed that does not implement the Collections
+ * interface but does have a getAll() method that will be used by the Atom
+ * binding to get the feed entries.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class CustomerNonCollectionImpl {
+ /**
+ * All feed entries.
+ * This is set directly by the unit tests.
+ * @see AtomFeedNonCollectionTest
+ */
+ public static Entry<Object, Object>[] entries;
+
+ /**
+ * Default constructor
+ */
+ public CustomerNonCollectionImpl() {
+ }
+
+ /**
+ * Get all entries for this feed.
+ *
+ * @return All entries for this feed
+ */
+ public Entry<Object, Object>[] getAll() {
+ return entries;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionImpl.java
new file mode 100644
index 0000000000..8ff89030db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionImpl.java
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.tuscany.sca.binding.atom.collection.MediaCollection;
+import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class MediaCollectionImpl implements MediaCollection {
+ private final Abdera abdera = new Abdera();
+ private Map<String, Entry> entries = new HashMap<String, Entry>();
+ private Map<String, String> mediaFiles = new HashMap<String, String>();
+ public Date lastModified = new Date();
+
+ public Entry post(Entry entry) {
+ //System.out.println(">>> MediaCollectionImpl.post entry=" + entry.getTitle());
+
+ if(!("Exception_Test".equalsIgnoreCase(entry.getTitle())))
+ {
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+ entry.setId(id);
+
+ entry.addLink("" + id, "edit");
+ entry.addLink("" + id, "alternate");
+ Date now = new Date();
+ entry.setUpdated(now);
+ lastModified = now;
+ entries.put(id, entry);
+
+ //System.out.println(">>> MediaCollectionImpl.post return id=" + id);
+
+ return entry;
+
+ }
+ else
+ {
+ throw new IllegalArgumentException("Exception in Post method");
+ }
+ }
+
+ public Entry get(String id) {
+ //System.out.println(">>> MediaCollectionImpl.get id=" + id);
+ return entries.get(id);
+ }
+
+ public void put(String id, Entry entry) throws NotFoundException {
+ //System.out.println(">>> MediaCollectionImpl.put id=" + id + " entry=" + entry.getTitle());
+ if(entries.containsKey(id)){
+ Date now = new Date();
+ entry.setUpdated(now);
+ lastModified = now;
+ entries.put(id, entry);
+ }
+ else {
+ throw new NotFoundException();
+ }
+ }
+
+ public void delete(String id) throws NotFoundException {
+ //System.out.println(">>> MediaCollectionImpl.delete id=" + id);
+ if(entries.containsKey(id)){
+ entries.remove(id);
+ lastModified = new Date();
+ }
+ else {
+ throw new NotFoundException();
+ }
+ }
+
+ public Feed getFeed() {
+ //System.out.println(">>> MediaCollectionImpl.getFeed");
+
+ Feed feed = this.abdera.getFactory().newFeed();
+ feed.setId("customers" + this.hashCode() ); // provide unique id for feed instance.
+ feed.setTitle("customers");
+ feed.setSubtitle("This is a sample feed");
+ feed.setUpdated(lastModified);
+ feed.addLink("");
+ feed.addLink("", "self");
+
+ for (Entry entry : entries.values()) {
+ feed.addEntry(entry);
+ }
+
+ return feed;
+ }
+
+ public Feed query(String queryString) {
+ //System.out.println(">>> MediaCollectionImpl.query collection " + queryString);
+ return getFeed();
+ }
+
+ // This method used for testing.
+ protected void testPut(String value) {
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+
+ Entry entry = abdera.getFactory().newEntry();
+ entry.setId(id);
+ entry.setTitle("customer " + value);
+
+ Content content = this.abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+
+ entry.setContentElement(content);
+
+ entry.addLink("" + id, "edit");
+ entry.addLink("" + id, "alternate");
+
+ entry.setUpdated(new Date());
+
+ entries.put(id, entry);
+ System.out.println(">>> id=" + id);
+ }
+
+ // MediaCollection role
+ public Entry postMedia(String title, String slug, String contentType, InputStream media) {
+ //System.out.println(">>> MediaCollectionImpl.postMedia title=" + title + ", slug=" + slug + ", contentType=" + contentType );
+
+ Factory factory = abdera.getFactory();
+ Entry entry = factory.newEntry();
+ // Must provide entry to media as per Atom Pub spec (http://tools.ietf.org/html/rfc5023#section-9.6)
+ // <?xml version="1.0"?>
+ // <entry xmlns="http://www.w3.org/2005/Atom">
+ // <title>The Beach</title> (REQUIRED)
+ // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> (REQUIRED)
+ // <updated>2005-10-07T17:17:08Z</updated>
+ // <summary type="text" /> (REQUIRED, OPTIONAL to populate
+ // <content type="image/png" src="http://media.example.org/the_beach.png"/>
+ // <link rel="edit-media" href="http://media.example.org/edit/the_beach.png" />
+ // <link rel="edit" href="http://example.org/media/edit/the_beach.atom" />
+ // </entry>
+
+ // Normalize title
+ entry.setTitle( title );
+ String normalTitle = title.replace( " ", "_" );
+ String hostURL = "http://media.example.org/";
+ int lastDelimiterPos = contentType != null ? contentType.lastIndexOf( "/" ) : -1;
+ String extension = "";
+ if ( lastDelimiterPos != -1 ) {
+ extension = contentType.substring( lastDelimiterPos + 1 );
+ } else {
+ extension = contentType;
+ }
+ long mediaLength = -1;
+ try {
+ mediaLength = media.skip( Long.MAX_VALUE );
+ } catch ( IOException e ){}
+
+ // A true implementation would store the media to a repository, e.g. file system.
+ // This implementation record's the id and the location.
+ String id = "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a-" + mediaFiles.size();
+ String reposLocation = hostURL + "edit/" + normalTitle;
+ mediaFiles.put( id, reposLocation );
+
+ // Build entry for media link.
+ entry.setUpdated( new Date() );
+ entry.setId( id );
+ // Convention. Return header properties as key values.
+ entry.setSummary( "Content-Type=" + contentType + ",Content-Length=" + mediaLength );
+ entry.setContent( new IRI( hostURL + normalTitle + "." + extension ), contentType );
+ entry.addLink( reposLocation + ".atom", "edit" );
+ entry.addLink( reposLocation + "." + extension, "edit-media" );
+ return entry;
+ }
+
+ public void putMedia(String id, String contentType, InputStream media) throws NotFoundException {
+ //System.out.println(">>> MediaCollectionImpl.putMedia id=" + id + ", contentType=" + contentType );
+
+ // Must responsd with success or not found as per Atom Pub spec (http://tools.ietf.org/html/rfc5023#section-9.6)
+ // Body is null.
+ if ( !id.endsWith( "0" ) )
+ throw new NotFoundException( "Media at id=" + id + " not found." );
+
+ // A true implementation would update the media in the media repository.
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
new file mode 100644
index 0000000000..6d4a173d30
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
@@ -0,0 +1,294 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests use of server provided entry entity tags for Atom binding in Tuscany.
+ * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match)
+ * using entity tags or last modified header entries.
+ * Uses the SCA provided Provider composite to act as a server.
+ * Uses the Abdera provided Client to act as a client.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MediaCollectionTestCase {
+ public final static String providerURI = "http://localhost:8084/receipt";
+
+ protected static Node scaProviderNode;
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+ protected static AbderaClient client;
+ protected static Parser abderaParser;
+ protected static String eTag;
+ protected static Date lastModified;
+ protected static String mediaId;
+ protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ //System.out.println(">>>MediaCollectionTestCase.init");
+ String contribution = ContributionLocationHelper.getContributionLocation(MediaCollectionTestCase.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ abdera = new Abdera();
+ client = new AbderaClient(abdera);
+ abderaParser = Abdera.getNewParser();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ System.out.println(">>>MediaCollectionTestCase.destroy");
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull( client );
+ }
+
+ @Test
+ public void testMediaEntryPost() throws Exception {
+ // Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
+ // Post request
+ // POST /edit/ HTTP/1.1
+ // Host: media.example.org
+ // Content-Type: image/png
+ // Slug: The Beach
+ // Content-Length: nnn
+ // ...binary data...
+
+ // Testing of entry creation
+ String receiptName = "Auto Repair Bill";
+ String fileName = "target/test-classes/ReceiptToms.gif";
+ File input = new File( fileName );
+ boolean exists = input.exists();
+ Assert.assertTrue( exists );
+
+ // Prepare HTTP post
+ // PostMethod post = new PostMethod( colUri.toString() );
+ PostMethod post = new PostMethod( providerURI );
+ post.addRequestHeader( "Content-Type", "image/gif" );
+ post.addRequestHeader( "Title", "Title " + receiptName + "" );
+ post.addRequestHeader( "Slug", "Slug " + receiptName + "" );
+ post.setRequestEntity( new InputStreamRequestEntity( new FileInputStream( input ), "image/gif" ) );
+
+ // Get HTTP client
+ HttpClient httpclient = new HttpClient();
+ try {
+ // Execute request
+ int result = httpclient.executeMethod(post);
+ // Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
+ // Post response
+ // Tuscany responds with proper media links. Note that the media is
+ // stored in a different location than the media information which is
+ // stored in the Atom feed.
+ // HTTP/1.1 201 Created
+ // Display status code
+ // System.out.println("Response status code: " + result + ", status text=" + post.getStatusText() );
+ Assert.assertEquals(201, result );
+ // Display response
+ // System.out.println("Response body: ");
+ // System.out.println(post.getResponseBodyAsString()); // Warning: BodyAsString recommends BodyAsStream
+
+ // Location: http://example.org/media/edit/the_beach.atom (REQUIRED)
+ // System.out.println( "Response Location=" + post.getResponseHeader( "Location" ).getValue() + "." );
+ Header header = post.getResponseHeader( "Location" );
+ Assert.assertNotNull( header );
+ Assert.assertNotNull( header.getValue() );
+ // ContentLocation: http://example.org/media/edit/the_beach.jpg (REQUIRED)
+ // System.out.println( "Response Content-Location=" + post.getResponseHeader( "Content-Location" ).getValue() );
+ header = post.getResponseHeader( "Content-Location" );
+ Assert.assertNotNull( header );
+ Assert.assertNotNull( header.getValue() );
+ // Content-Type: application/atom+xml;type=entry;charset="utf-8"
+ // System.out.println( "Response Content-Type=" + post.getResponseHeader( "Content-Type" ).getValue());
+ header = post.getResponseHeader( "Content-Type" );
+ Assert.assertNotNull( header );
+ Assert.assertNotNull( header.getValue() );
+ // Content-Length: nnn (OPTIONAL)
+ // System.out.println( "Response Content-Length=" + post.getResponseHeader( "Content-Length" ).getValue() );
+ header = post.getResponseHeader( "Content-Length" );
+ Assert.assertNotNull( header );
+ Assert.assertNotNull( header.getValue() );
+ // <?xml version="1.0"?>
+ // <entry xmlns="http://www.w3.org/2005/Atom">
+ // <title>The Beach</title> (REQUIRED)
+ // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> (REQUIRED)
+ // <updated>2005-10-07T17:17:08Z</updated>
+ // <author><name>Daffy</name></author>
+ // <summary type="text" /> (REQUIRED, OPTIONAL to populate
+ // <content type="image/png" src="http://media.example.org/the_beach.png"/>
+ // <link rel="edit-media" href="http://media.example.org/edit/the_beach.png" />
+ // <link rel="edit" href="http://example.org/media/edit/the_beach.atom" />
+ // </entry>
+ Document<Entry> document = abderaParser.parse( post.getResponseBodyAsStream() );
+ Entry entry = document.getRoot();
+ String title = entry.getTitle();
+ // System.out.println( "mediaPost entry.title=" + title );
+ Assert.assertNotNull( title );
+ IRI id = entry.getId();
+ // System.out.println( "mediaPost entry.id=" + id );
+ Assert.assertNotNull( id );
+ mediaId = id.toString();
+ Assert.assertNotNull( mediaId ); // Save for put/update request
+ Date updated = entry.getUpdated();
+ // System.out.println( "mediaPost entry.updated=" + updated);
+ Assert.assertNotNull( updated );
+ String summary = entry.getSummary();
+ // System.out.println( "mediaPost entry.summary=" + summary);
+ Assert.assertNotNull( summary );
+ IRI contentSrc = entry.getContentSrc();
+ // System.out.println( "mediaPost entry.content.src=" + contentSrc + ", type=" + entry.getContentType());
+ Assert.assertNotNull( contentSrc );
+ Link editLink = entry.getEditLink();
+ // System.out.println( "mediaPost entry.editLink" + " rel=" + editLink.getRel() + ", href=" + editLink.getHref() );
+ Assert.assertNotNull( editLink );
+ Assert.assertNotNull( editLink.getRel() );
+ Assert.assertNotNull( editLink.getHref() );
+ Link editMediaLink = entry.getEditMediaLink();
+ // System.out.println( "mediaPost entry.editMediaLink" + " rel=" + editMediaLink.getRel() + ", href=" + editMediaLink.getHref() );
+ Assert.assertNotNull( editMediaLink );
+ Assert.assertNotNull( editMediaLink.getRel() );
+ Assert.assertNotNull( editMediaLink.getHref() );
+
+ } finally {
+ // Release current connection to the connection pool once you are done
+ post.releaseConnection();
+ }
+ }
+
+ @Test
+ public void testMediaEntryPutFound() throws Exception {
+ // Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
+ // Testing of entry update
+ String receiptName = "Value Autoglass Bill";
+ String fileName = "target/test-classes/ReceiptValue.jpg";
+ File input = new File( fileName );
+ boolean exists = input.exists();
+ Assert.assertTrue( exists );
+
+ // Prepare HTTP put request
+ // PUT /edit/the_beach.png HTTP/1.1
+ // Host: media.example.org
+ // Content-Type: image/png
+ // Content-Length: nnn
+ // ...binary data...
+ PutMethod put = new PutMethod( providerURI + "/" + mediaId );
+ put.addRequestHeader( "Content-Type", "image/jpg" );
+ put.addRequestHeader( "Title", "Title " + receiptName + "" );
+ put.addRequestHeader( "Slug", "Slug " + receiptName + "" );
+ put.setRequestEntity(
+ new InputStreamRequestEntity( new FileInputStream( input ), "image/jpg" ) );
+
+ // Get HTTP client
+ HttpClient httpclient = new HttpClient();
+ try {
+ // Execute request
+ int result = httpclient.executeMethod(put);
+ // Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
+ // Display status code
+ // System.out.println("Response status code: " + result + ", status text=" + put.getStatusText() );
+ Assert.assertEquals(200, result );
+ // Display response. Should be empty for put.
+ // System.out.println("Response body: ");
+ // System.out.println(put.getResponseBodyAsString()); // Warning: BodyAsString recommends BodyAsStream
+ } finally {
+ // Release current connection to the connection pool once you are done
+ put.releaseConnection();
+ }
+ }
+
+ @Test
+ public void testMediaEntryPutNotFound() throws Exception {
+ // Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
+ // Testing of entry update
+ String receiptName = "Value Autoglass Bill";
+ String fileName = "target/test-classes/ReceiptValue.jpg";
+ File input = new File( fileName );
+ boolean exists = input.exists();
+ Assert.assertTrue( exists );
+
+ // Prepare HTTP put request
+ // PUT /edit/the_beach.png HTTP/1.1
+ // Host: media.example.org
+ // Content-Type: image/png
+ // Content-Length: nnn
+ // ...binary data...
+ PutMethod put = new PutMethod( providerURI + "/" + mediaId + "-bogus" ); // Does not exist.
+ put.addRequestHeader( "Content-Type", "image/jpg" );
+ put.addRequestHeader( "Title", "Title " + receiptName + "" );
+ put.addRequestHeader( "Slug", "Slug " + receiptName + "" );
+ put.setRequestEntity(
+ new InputStreamRequestEntity( new FileInputStream( input ), "image/jpg" ) );
+
+ // Get HTTP client
+ HttpClient httpclient = new HttpClient();
+ try {
+ // Execute request
+ int result = httpclient.executeMethod(put);
+ // Pseudo Code (see APP (http://tools.ietf.org/html/rfc5023#section-9.6)
+ // Display status code
+ // System.out.println("Response status code: " + result + ", status text=" + put.getStatusText() );
+ Assert.assertEquals(404, result );
+ // Display response. Should be empty for put.
+ // System.out.println("Response body: ");
+ // System.out.println(put.getResponseBodyAsString()); // Warning: BodyAsString recommends BodyAsStream
+ } finally {
+ // Release current connection to the connection pool once you are done
+ put.releaseConnection();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java
new file mode 100644
index 0000000000..e2759235b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Provider {
+
+ public static void main(String[] args) {
+
+ String contribution = ContributionLocationHelper.getContributionLocation(Provider.class);
+ Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("c1", contribution));
+ System.out.println("Provider.composite ready...");
+
+ try {
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java
new file mode 100644
index 0000000000..6dbb15f6b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java
@@ -0,0 +1,432 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.client.RequestOptions;
+import org.apache.abdera.protocol.client.util.BaseRequestEntity;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests use of server provided entry entity tags for Atom binding in Tuscany.
+ * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match)
+ * using entity tags or last modified header entries.
+ * Uses the SCA provided Provider composite to act as a server.
+ * Uses the Abdera provided Client to act as a client.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProviderEntryEntityTagsTestCase {
+ public final static String providerURI = "http://localhost:8084/customer";
+
+ protected static Node scaProviderNode;
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+ protected static AbderaClient client;
+ protected static Parser abderaParser;
+ protected static String eTag;
+ protected static Date lastModified;
+ protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
+
+ @BeforeClass
+ public static void init() throws Exception {
+ //System.out.println(">>>ProviderEntryEntityTagsTestCase.init");
+ String contribution = ContributionLocationHelper.getContributionLocation(ProviderEntryEntityTagsTestCase.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ abdera = new Abdera();
+ client = new AbderaClient(abdera);
+ abderaParser = Abdera.getNewParser();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ //System.out.println(">>>ProviderEntryEntityTagsTestCase.destroy");
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull( client );
+ }
+
+ @Test
+ public void testEmptyCachePost() throws Exception {
+ // Pseudo-code
+ // 1) Example HTTP POST request (new entry put, new etag response)
+ // User client post request
+ // POST /myblog/entries HTTP/1.1
+ // Slug: First Post
+ //
+ // <?xml version="1.0" ?>
+ // <entry xmlns="http://www.w3.org/2005/Atom">
+ // <title>Atom-Powered Robots Run Amok</title>
+ // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+ // <updated>2007-02-123T17:09:02Z</updated>
+ // <author><name>Captain Lansing</name></author>
+ // <content>It's something moving... solid metal</content>
+ // </entry>
+
+ // Expected Atom server response (note unique ETag)
+ // HTTP/1.1 201 Created
+ // Date: Fri, 23 Feb 2007 21:17:11 GMT
+ // Content-Length: nnn
+ // Content-Type: application/atom+xml;type=entry
+ // Location: http://example.org/edit/first-post.atom
+ // Content-Location: http://example.org/edit/first-post.atom
+ // ETag: "e180ee84f0671b1"
+ // Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
+ //
+ // <?xml version="1.0" ?>
+ // <entry xmlns="http://www.w3.org/2005/Atom">
+ // <title>Atom-Powered Robots Run Amok</title>
+ // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+ // <updated>2007-02-123T17:09:02Z</updated>
+ // <author><name>Captain Lansing</name></author>
+ // <content>It's something moving... solid metal</content>
+ // </entry>
+
+ // Testing of entry creation
+ Factory factory = abdera.getFactory();
+ String customerName = "Fred Farkle";
+ Entry entry = factory.newEntry();
+ entry.setTitle("customer " + customerName);
+ entry.setUpdated(new Date());
+ entry.addAuthor("Apache Tuscany");
+ // ID created by collection.
+ // entry.setId(id); // auto-provided
+ // entry.addLink("" + id, "edit"); // auto-provided
+ // entry.addLink("" + id, "alternate"); // auto-provided
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(customerName);
+ entry.setContentElement(content);
+
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", opts );
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ ClientResponse res = client.post(colUri.toString(), entry, opts);
+
+ // Assert response status code is 201-OK.
+ // Assert response header Content-Type: application/atom+xml; charset=UTF-8
+ // Assert response header Location: http://example.org/edit/first-post.atom
+ // Assert response header Content-Location: http://example.org/edit/first-post.atom
+ // Assert response header ETag: "e180ee84f0671b1"
+ // Assert response header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
+ // Assert collection size is 1.
+ Assert.assertEquals(201, res.getStatus());
+ Assert.assertEquals(contentType, res.getContentType().toString().trim());
+ // Assert.assertNotNull( res.getLocation().toString() );
+ // Assert.assertEquals( "", res.getContentLocation().toString() );
+ // Save eTag for subsequent tests;
+ eTag = res.getHeader( "ETag" );
+ Assert.assertNotNull( eTag );
+ lastModified = res.getLastModified();
+ Assert.assertNotNull(lastModified);
+ }
+
+ @Test
+ public void testDirtyCachePut() throws Exception {
+ // 2) Conditional PUT request (post with etag. entry provided is stale)
+ // User client PUT request
+ // PUT /edit/first-post.atom HTTP/1.1
+ // > If-Match: "e180ee84f0671b1"
+ //
+ // <?xml version="1.0" ?>
+ // <entry xmlns="http://www.w3.org/2005/Atom">
+ // <title>Atom-Powered Robots Run Amok</title>
+ // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+ // <updated>2007-02-24T16:34:06Z</updated>
+ // <author><name>Captain Lansing</name></author>
+ // <content>Update: it's a hoax!</content>
+ // </entry>
+ // Testing of entry creation
+ Factory factory = abdera.getFactory();
+ String customerName = "Molly Ringwald";
+ Entry entry = factory.newEntry();
+ entry.setTitle("customer " + customerName);
+ entry.setUpdated( new Date());
+ entry.addAuthor("Apache Tuscany");
+ String id = eTag.substring( 1, eTag.length()-1);
+ entry.setId(id); // auto-provided
+ // entry.addLink("" + id, "edit"); // auto-provided
+ // entry.addLink("" + id, "alternate"); // auto-provided
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(customerName);
+ entry.setContentElement(content);
+
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-None-Match", eTag);
+
+ // AtomTestCaseUtils.printRequestHeaders( "Put request headers", " ", opts );
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ id = eTag.substring( 1, eTag.length()-1);
+ // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
+ // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+ ClientResponse res = client.put(colUri.toString() + "/" + id, new BaseRequestEntity( entry ), opts);
+ // Expected Atom server response (item was edited by another user)
+ // > HTTP/1.1 412 Precondition Failed
+ // Date: Sat, 24 Feb 2007 16:34:11 GMT
+
+ // If-Match Assert response status code is 412. Precondition failed.
+ // If-None-Match Assert response status code is 200. OK
+ Assert.assertEquals(200, res.getStatus());
+ // Put provides null body and no etags.
+ res.release();
+ }
+
+ @Test
+ public void testETagMissGet() throws Exception {
+ // 4) Conditional GET example (get with etag. etag not in cache)
+ // User client GET request
+ // GET /edit/first-post.atom HTTP/1.1
+ // > If-None-Match: "e180ee84f0671b1"
+
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-None-Match", "123456");
+ opts.setHeader( "Pragma", "no-cache"); // turn off client caching
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ String id = eTag.substring( 1, eTag.length()-1);
+ // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
+ // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+ ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+ // Expected Atom server response (item was edited by another user)
+ // > HTTP/1.1 412 Precondition Failed
+ // Date: Sat, 24 Feb 2007 16:34:11 GMT
+
+ // Atom server response (item was up to date)
+ // > HTTP/1.1 200 OK
+ // Date: Sat, 24 Feb 2007 13:17:11 GMT
+ // > ETag: "bb4f5e86e92ddb8549604a0df0763581"
+ // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
+
+ // Assert response status code is 200 OK.
+ // Assert header Content-Type: application/atom+xml;type=entry
+ // Assert header Location: http://example.org/edit/first-post.atom
+ // Assert header Content-Location: http://example.org/edit/first-post.atom
+ // Assert header ETag: "555555" (etag response != etag request)
+ // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(contentType, res.getContentType().toString().trim());
+ // Assert.assertNotNull( res.getLocation().toString() );
+ // Assert.assertEquals( "", res.getContentLocation().toString() );
+ Assert.assertNotNull( res.getHeader( "ETag" ) );
+ lastModified = res.getLastModified();
+ Assert.assertNotNull(lastModified);
+ res.release();
+ }
+
+ @Test
+ public void testETagHitGet() throws Exception {
+ // 3) Conditional GET example (get with etag. etag match)
+ // User client GET request
+ // GET /edit/first-post.atom HTTP/1.1
+ // > If-None-Match: "e180ee84f0671b1"
+
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-None-Match", eTag);
+ opts.setHeader( "Pragma", "no-cache"); // turn off client caching
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ String id = eTag.substring( 1, eTag.length()-1);
+ // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
+ // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+ ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+ // Atom server response (item was up to date)
+ // > HTTP/1.1 304 Not Modified
+ // Date: Sat, 24 Feb 2007 13:17:11 GMT
+
+ // Assert response status code is 304 Not Modified.
+ // Assert header ETag: "e180ee84f0671b1"
+ // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
+ // Assert.assertEquals(304, res.getStatus());
+ res.release();
+ }
+
+
+ @Test
+ public void testUpToDateGet() throws Exception {
+ // 3) Conditional GET example (get with If-Mod. entry is up to date)
+ // User client GET request
+ // GET /edit/first-post.atom HTTP/1.1
+ // > If-Modified-Since: Sat, 29 Oct 2025 19:43:31 GMT
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Modified-Since", "Sat, 29 Oct 2025 19:43:31 GMT"); // "EEE, dd MMM yyyy HH:mm:ss Z // RFC 822 Date
+ opts.setHeader( "Pragma", "no-cache"); // turn off client caching
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ String id = eTag.substring( 1, eTag.length()-1);
+ // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
+ // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+ // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
+ // ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+ ClientResponse res = client.execute( "GET", colUri.toString(), (BaseRequestEntity)null, opts);
+
+ // Atom server response (item was up to date)
+ // > HTTP/1.1 304 Not Modified
+ // Date: Sat, 24 Feb 2007 13:17:11 GMT
+
+ // Assert response status code is 304 Not Modified.
+ Assert.assertEquals(304, res.getStatus());
+ res.release();
+ }
+
+ @Test
+ public void testOutOfDateGet() throws Exception {
+ // 4) Conditional GET example (get with If-Mod. entry is not to date)
+ // User client GET request
+ // GET /edit/first-post.atom HTTP/1.1
+ // > If-Modified-Since: Sat, 29 Oct 1844 19:43:31 GMT
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Modified-Since", "Sat, 29 Oct 1844 19:43:31 GMT"); // "EEE, dd MMM yyyy HH:mm:ss Z // RFC 822 Date
+ opts.setHeader( "Pragma", "no-cache"); // turn off client caching
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ String id = eTag.substring( 1, eTag.length()-1);
+ // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
+ // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+ ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+
+ // Atom server response (item was up to date)
+ // > HTTP/1.1 200 OK
+ // Date: Sat, 24 Feb 2007 13:17:11 GMT
+ // > ETag: "bb4f5e86e92ddb8549604a0df0763581"
+ // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
+
+ // Assert response status code is 200 OK.
+ // Assert header ETag: "e180ee84f0671b1"
+ // Assert header Last-Modified: Greater than If-Mod
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(contentType, res.getContentType().toString().trim());
+ // Assert.assertNotNull( res.getLocation().toString() );
+ // Assert.assertEquals( "", res.getContentLocation().toString() );
+ Assert.assertNotNull( res.getHeader( "ETag" ) );
+ lastModified = res.getLastModified();
+ Assert.assertNotNull(lastModified);
+ res.release();
+ }
+
+ @Test
+ public void testUpToDateUnModGet() throws Exception {
+ // 3) Conditional GET example (get with If-Unmod. entry is not modified (< predicate date).
+ // User client GET request
+ // GET /edit/first-post.atom HTTP/1.1
+ // > If-Unmodified-Since: Sat, 29 Oct 2025 19:43:31 GMT
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Unmodified-Since", "Sat, 29 Oct 2050 19:43:31 GMT" );
+ opts.setHeader( "Pragma", "no-cache"); // turn off client caching
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ String id = eTag.substring( 1, eTag.length()-1);
+ // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
+ // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+ ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+
+ // Atom server response (item was up to date)
+ // > HTTP/1.1 200 OK
+ // Date: Sat, 24 Feb 2007 13:17:11 GMT
+ // > ETag: "bb4f5e86e92ddb8549604a0df0763581"
+ // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500
+
+ // Assert response status code is 200 OK.
+ // Assert header Content-Type: application/atom+xml;type=entry
+ // Assert header Location: http://example.org/edit/first-post.atom
+ // Assert header Content-Location: http://example.org/edit/first-post.atom
+ // Assert header ETag: "e180ee84f0671b1"
+ // Assert header Last-Modified: Less than If-Unmod
+ Assert.assertEquals(200, res.getStatus());
+ res.release();
+ }
+
+ @Test
+ public void testOutOfDateUnModGet() throws Exception {
+ // 4) Conditional GET example (get with If-Unmod. entry is modified (> predicate date)
+ // User client GET request
+ // GET /edit/first-post.atom HTTP/1.1
+ // Host: example.org
+ // > If-Unmodified-Since: Sat, 29 Oct 1844 19:43:31 GMT
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Unmodified-Since", "Sat, 29 Oct 1844 19:43:31 GMT" );
+ opts.setHeader( "Pragma", "no-cache"); // turn off client caching
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ String id = eTag.substring( 1, eTag.length()-1);
+ // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
+ // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
+ ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
+
+ // Atom server response (item was up to date)
+ // > HTTP/1.1 304 Not Modified
+ // Date: Sat, 24 Feb 2007 13:17:11 GMT
+
+ // Assert response status code is 304 Not Modified.
+ Assert.assertEquals(304, res.getStatus());
+ res.release();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java
new file mode 100644
index 0000000000..34131f6195
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java
@@ -0,0 +1,386 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.protocol.Response.ResponseType;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.client.RequestOptions;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests use of server provided feed entity tags for Atom binding in Tuscany.
+ * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match)
+ * using entity tags and last modified entries in headers.
+ * Uses the SCA provided Provider composite to act as a server.
+ * Uses the Abdera provided Client to act as a client.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProviderFeedEntityTagsTestCase {
+ public final static String providerURI = "http://localhost:8084/customer";
+
+ protected static Node scaProviderNode;
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+ protected static AbderaClient client;
+ protected static Parser abderaParser;
+ protected static String eTag;
+ protected static Date lastModified;
+ protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
+
+ @BeforeClass
+ public static void init() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.init");
+ String contribution = ContributionLocationHelper.getContributionLocation(ProviderEntryEntityTagsTestCase.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ abdera = new Abdera();
+ client = new AbderaClient(abdera);
+ abderaParser = Abdera.getNewParser();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.destroy");
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull( client );
+ }
+
+ @Test
+ public void testFeedBasics() throws Exception {
+ // System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedBasics");
+ // Normal feed request
+ ClientResponse res = client.get(providerURI);
+ Assert.assertNotNull(res);
+ try {
+ // Assert feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+ // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res );
+ // System.out.println("Feed response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+
+ // Perform other tests on feed.
+ // Warning. AbderaClient.getEntityTag is very particular on tag pattern.
+ // Document<Feed> doc = res.getDocument();
+ String body = read( res.getInputStream() );
+ // RFC 4287 requires non-null id, title, updated elements
+ Assert.assertTrue( -1 != body.indexOf( "</id>" ));
+ Assert.assertTrue( -1 != body.indexOf( "</title>" ));
+ Assert.assertTrue( -1 != body.indexOf( "</updated>" ));
+
+ eTag = res.getHeader("ETag");
+ Assert.assertNotNull( eTag );
+ lastModified = res.getLastModified();
+ Assert.assertNotNull( lastModified );
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testUnmodifiedGetIfMatch() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfMatch");
+ // Feed request with predicates
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Match", eTag);
+
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ String thisETag = res.getHeader("ETag");
+ Assert.assertNotNull( thisETag );
+ Date thisLastModified = res.getLastModified();
+ Assert.assertNotNull( thisLastModified );
+
+ // Should return 200 - Feed provided since it matches etag.
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+ // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res );
+ // System.out.println("Feed response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testUnmodifiedGetIfNoneMatch() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfNoneMatch");
+ // Feed request with predicates
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-None-Match", eTag);
+
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Should return 304 - Feed not provided since it matches ETag.
+ Assert.assertEquals(304, res.getStatus());
+ } finally {
+ res.release();
+ }
+ }
+
+ // @Test @Ignore Intermitently fails, see TUSCANY-3299
+ public void testUnmodifiedGetIfUnModified() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfUnModified");
+ // Feed request with predicates
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date() ));
+
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Should return 304 - Feed not provided since feed is modified since.
+ Assert.assertEquals(304, res.getStatus());
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testUnmodifiedGetIfModified() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfModified");
+ // Feed request with predicates
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Modified-Since", dateFormat.format( new Date( 0 ) ));
+
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Should return 200 - Feed provided since feed is changed.
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+
+ String thisETag = res.getHeader("ETag");
+ Assert.assertNotNull( thisETag );
+ Date thisLastModified = res.getLastModified();
+ Assert.assertNotNull( thisLastModified );
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testModifiedGetIfNoneMatch() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedModifiedGetIfNoneMatch");
+ // Post some new content to the feed.
+ Factory factory = abdera.getFactory();
+ String customerName = "Fred Farkle";
+ Entry entry = factory.newEntry();
+ entry.setTitle("customer " + customerName);
+ entry.setUpdated(new Date());
+ entry.addAuthor("Apache Tuscany");
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(customerName);
+ entry.setContentElement(content);
+
+ RequestOptions opts = new RequestOptions();
+ String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ ClientResponse res = client.post(colUri.toString(), entry, opts);
+
+ // Feed request with predicates
+ opts = new RequestOptions();
+ contentType = "application/atom+xml";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-None-Match", eTag);
+
+ res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Should return 304 - Feed not provided since it matches ETag.
+ Assert.assertEquals(304, res.getStatus());
+ // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res );
+ // System.out.println("Feed response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testModifiedGetIfMatch() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedModifiedGetIfMatch");
+ // Feed request with predicates
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Match", eTag);
+
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ String thisETag = res.getHeader("ETag");
+ Assert.assertNotNull( thisETag );
+ Date thisLastModified = res.getLastModified();
+ Assert.assertNotNull( thisLastModified );
+
+ // Should return 200 - value since feed is changed
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+
+ // AtomTestCaseUtils.printResponseHeaders( "Feed modified if-none-match response headers:", " ", res );
+ // System.out.println("Feed response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testModifiedGetIfUnModified() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfUnModified");
+ // Feed request with predicates
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date() ));
+
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Should return 304 - Feed not provided since feed is modified since.
+ Assert.assertEquals(304, res.getStatus());
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testModifiedGetIfModified() throws Exception {
+ //System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfModified");
+ // Feed request with predicates
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml";
+ opts.setContentType(contentType);
+ opts.setHeader( "If-Modified-Since", dateFormat.format( lastModified ));
+
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Should return 200 - Feed provided since feed is changed.
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+
+ String thisETag = res.getHeader("ETag");
+ Assert.assertNotNull( thisETag );
+ Date thisLastModified = res.getLastModified();
+ Assert.assertNotNull( thisLastModified );
+ } finally {
+ res.release();
+ }
+ }
+
+
+ public static void printFeed( String title, String indent, Feed feed ) {
+ if ( feed == null ) {
+ System.out.println( title + " feed is null");
+ return;
+ }
+
+ System.out.println( title );
+ System.out.println( indent + "id=" + feed.getId() );
+ System.out.println( indent + "title=" + feed.getTitle() );
+ System.out.println( indent + "updated=" + feed.getUpdated() );
+ System.out.println( indent + "author=" + feed.getAuthor() );
+ Collection collection = feed.getCollection();
+ if ( collection == null ) {
+ System.out.println( indent + "collection=null" );
+ } else {
+ System.out.println( indent + "collection=" + collection );
+ }
+ // System.out.println( indent + "collection size=" + feed.getCollection() );
+ // for (Collection collection : workspace.getCollections()) {
+ // if (collection.getTitle().equals("customers")) {
+ // String expected = uri + "customers";
+ // String actual = collection.getResolvedHref().toString();
+ // assertEquals(expected, actual);
+ // }
+ // }
+
+ }
+
+ /**
+ * Read response ream from the given socket.
+ * @param socket
+ * @return
+ * @throws IOException
+ */
+ private static String read(InputStream inputStream) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader( inputStream ));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTestCase.java
new file mode 100644
index 0000000000..f94df3cff8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTestCase.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.protocol.Response.ResponseType;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests use of service documents provided by atom binding based collections.
+ * Uses the SCA provided Provider composite to act as a server.
+ * Uses the Abdera provided Client to act as a client.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProviderServiceDocumentTestCase extends AbstractProviderConsumerTestCase {
+ public final static String providerURI = "http://localhost:8084/customer";
+
+ protected static CustomerClient testService;
+ protected static Abdera abdera;
+ protected static AbderaClient client;
+ protected static Parser abderaParser;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ initTestEnvironment(AtomPostTestCase.class);
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+
+ abdera = new Abdera();
+ client = new AbderaClient(abdera);
+ abderaParser = Abdera.getNewParser();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ destroyTestEnvironment();
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull( client );
+ }
+
+ @Test
+ public void testFeedBasics() throws Exception {
+ // Normal feed request
+ ClientResponse res = client.get(providerURI);
+ Assert.assertNotNull(res);
+ try {
+ // Assert feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+ // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res );
+ // System.out.println("Feed response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+
+ // Perform other tests on feed.
+ // Warning. AbderaClient.getEntityTag is very particular on tag pattern.
+ // Document<Feed> doc = res.getDocument();
+ String body = read( res.getInputStream() );
+ // RFC 4287 requires non-null id, title, updated elements
+ Assert.assertTrue( -1 != body.indexOf( "</id>" ));
+ Assert.assertTrue( -1 != body.indexOf( "</title>" ));
+ Assert.assertTrue( -1 != body.indexOf( "</updated>" ));
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testServiceDocumentGet() throws Exception {
+ Collection resourceCollection = testService.getCustomerCollection();
+ Assert.assertNotNull(resourceCollection);
+
+ Entry postEntry = postEntry("Sponge Bob");
+ Entry newEntry = resourceCollection.post(postEntry);
+ postEntry = postEntry("Austin Powers");
+ newEntry = resourceCollection.post(postEntry);
+ postEntry = postEntry("Count Dracula");
+ newEntry = resourceCollection.post(postEntry);
+
+ // Service document
+ ClientResponse res = client.get(providerURI + "/atomsvc");
+ Assert.assertNotNull(res);
+ try {
+ // Asser feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+
+ // Perform other tests on feed.
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+ Document<Service> serviceDoc = res.getDocument();
+ Service service = serviceDoc.getRoot();
+ Assert.assertNotNull( service );
+ org.apache.abdera.model.Collection collection = service.getCollection( "workspace", "customers" );
+ String title = collection.getTitle();
+ Assert.assertEquals("customers", title);
+ String href = collection.getHref().toString();
+ Assert.assertTrue( href.contains( "customer") );
+ } finally {
+ res.release();
+ }
+ }
+
+ public static void printFeed( String title, String indent, Feed feed ) {
+ if ( feed == null ) {
+ System.out.println( title + " feed is null");
+ return;
+ }
+
+ System.out.println( title );
+ System.out.println( indent + "id=" + feed.getId() );
+ System.out.println( indent + "title=" + feed.getTitle() );
+ System.out.println( indent + "updated=" + feed.getUpdated() );
+ System.out.println( indent + "author=" + feed.getAuthor() );
+ // Collection collection = feed.getCollection();
+ // if ( collection == null ) {
+ // System.out.println( indent + "collection=null" );
+ // } else {
+ // System.out.println( indent + "collection=" + collection );
+ // }
+ // System.out.println( indent + "collection size=" + feed.getCollection() );
+ // for (Collection collection : workspace.getCollections()) {
+ // if (collection.getTitle().equals("customers")) {
+ // String expected = uri + "customers";
+ // String actual = collection.getResolvedHref().toString();
+ // assertEquals(expected, actual);
+ // }
+ // }
+
+ }
+
+ private Entry postEntry(String value) {
+ Entry entry = abdera.newEntry();
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+ /**
+ * Read response ream from the given socket.
+ * @param socket
+ * @return
+ * @throws IOException
+ */
+ private static String read(InputStream inputStream) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader( inputStream ));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Aggregator.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Aggregator.java
new file mode 100644
index 0000000000..e10d442953
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Aggregator.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 org.apache.tuscany.sca.binding.atom.aggregator;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.apache.tuscany.sca.data.collection.Item;
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * Aggreator interface
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Aggregator extends Collection<String, Item>{
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorImpl.java
new file mode 100644
index 0000000000..781a670f57
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorImpl.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.atom.aggregator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.Item;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+
+/**
+ * Aggregator impl
+ *
+ * @version $Rev$ $Date$
+ */
+public class AggregatorImpl implements Aggregator {
+
+ @Reference(required = false)
+ public Collection<String, Item> atomFeed1;
+
+ @Reference(required = false)
+ public Collection<String, Item> atomFeed2;
+
+ @Reference(required = false)
+ public Sort sort;
+
+ @Property
+ public String feedTitle = "Aggregated Feed";
+ @Property
+ public String feedDescription = "Anonymous Aggregated Feed";
+ @Property
+ public String feedAuthor = "anonymous";
+
+ public Item get(String id) {
+
+ try {
+ if (atomFeed1.get(id) != null)
+ return atomFeed1.get(id);
+ } catch (NotFoundException ex) {
+ ex.printStackTrace();
+ }
+
+ try {
+ if (atomFeed2.get(id) != null)
+ return atomFeed2.get(id);
+ } catch (NotFoundException ex) {
+ ex.printStackTrace();
+ }
+
+ return null;
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public Entry<String, Item>[] getAll() {
+
+ // Aggregate entries from atomFeed1, atomFeed2, rssFeed1 and rssFeed2
+ List<Entry> entries = new ArrayList<Entry>();
+ if (atomFeed1 != null) {
+ try {
+ for (Entry entry : atomFeed1.getAll()) {
+ entries.add(entry);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ if (atomFeed2 != null) {
+ try {
+ for (Entry entry : atomFeed2.getAll()) {
+ entries.add(entry);
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ // Sort entries by published date
+ if (sort != null) {
+ entries = sort.sort(entries);
+ }
+
+ return entries.toArray(new Entry[entries.size()]);
+
+ }
+
+ public String post(String key, Item entry) {
+ return null;
+ }
+
+ public void put(String id, Item entry) {
+ }
+
+ @SuppressWarnings("unchecked")
+ public Entry<String, Item>[] query(String queryString) {
+ ArrayList<Entry> entries = new ArrayList<Entry>();
+
+ Entry<String, Item>[] allFeed = getAll();
+ if (queryString.startsWith("title=")) {
+ String title = queryString.substring(6);
+
+ for (Entry<String, Item> entry : allFeed) {
+ if (entry.getData().getTitle().contains(title)) {
+ entries.add(entry);
+ }
+ }
+ }
+ return entries.toArray(new Entry[entries.size()]);
+ }
+
+ public void delete(String id) {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java
new file mode 100644
index 0000000000..45d4c94768
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.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.sca.binding.atom.aggregator;
+
+import java.net.Socket;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.Item;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Agregattor test case
+ *
+ * @version $Rev$ $Date$
+ */
+public class AggregatorTestCase {
+ private static Node node;
+
+ private static Aggregator aggregatorService;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(AggregatorTestCase.class);
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite", new Contribution("test", contribution));
+ node.start();
+
+ aggregatorService = node.getService(Aggregator.class, "AtomAggregator/Aggregator");
+ Assert.assertNotNull(aggregatorService);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if(node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testPing() throws Exception {
+ new Socket("127.0.0.1", 8085);
+ }
+
+ @Test
+ public void testAggregator() throws Exception {
+ Entry<String, Item>[] entries = aggregatorService.getAll();
+
+ Assert.assertNotNull(entries);
+ Assert.assertTrue(entries.length > 0);
+
+ for(int pos = 0; pos < entries.length; pos++) {
+ System.out.println(">>> Entry[" + pos + "] - " + entries[pos].getData().getTitle());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Sort.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Sort.java
new file mode 100644
index 0000000000..28ea465968
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Sort.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.sca.binding.atom.aggregator;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+
+/**
+ * The Sort service business interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Sort {
+
+ /**
+ * Sort feed entries by published date.
+ * @param entries
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ List<Entry> sort(List<Entry> entries);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/SortImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/SortImpl.java
new file mode 100644
index 0000000000..022b1269fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/SortImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.atom.aggregator;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.Item;
+import org.oasisopen.sca.annotation.Property;
+
+/**
+ * Implementation of a Feed Sort service component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SortImpl implements Sort {
+
+ @Property
+ public boolean newFirst = true;
+
+ @SuppressWarnings("unchecked")
+ public List<Entry> sort(List<Entry> entries) {
+ Entry[] entriesArray = new Entry[entries.size()];
+ entriesArray = (Entry<String,Item>[])entries.toArray(entriesArray);
+ Arrays.sort(entriesArray, new Comparator() {
+ public int compare(final Object xObj, final Object yObj) {
+ Entry x = (Entry) xObj;
+ Entry y = (Entry) yObj;
+ Item xItem = (Item) x.getData();
+ Item yItem = (Item) y.getData();
+ Date xDate = xItem.getDate();
+ Date yDate = yItem.getDate();
+ if (xDate == null)
+ return -1;
+ if (newFirst)
+ return yDate.compareTo(xDate);
+ else
+ return xDate.compareTo(yDate);
+ }
+ });
+ return Arrays.asList(entriesArray);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/Headline.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/Headline.java
new file mode 100644
index 0000000000..95152af73d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/Headline.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.sca.binding.atom.news;
+
+import java.io.Serializable;
+
+public class Headline implements Serializable {
+ private static final long serialVersionUID = 2516853242307046775L;
+
+ private String text;
+ private String source;
+
+ public Headline() {
+
+ }
+
+ public Headline(String text, String source) {
+ this.text = text;
+ this.source = text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setSoure(String source) {
+ this.source = source;
+ }
+
+ public String getSource() {
+ return source;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsService.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsService.java
new file mode 100644
index 0000000000..ab97f4e340
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsService.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 org.apache.tuscany.sca.binding.atom.news;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface NewsService extends Collection<String, Headline>{
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceImpl.java
new file mode 100644
index 0000000000..7e40bb797d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceImpl.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.binding.atom.news;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(NewsService.class)
+public class NewsServiceImpl implements NewsService {
+ private Map<String, Headline> headlines = new HashMap<String,Headline>();
+
+ @Init
+ public void init() {
+ Headline headline;
+
+ headline = new Headline();
+ headline.setSoure("http://www.domain.com/source1");
+ headline.setText("headline text 1111");
+
+ headlines.put("h1", headline);
+
+
+ headline = new Headline();
+ headline.setSoure("http://www.domain.com/source2");
+ headline.setText("headline text 2222");
+
+ headlines.put("h2", headline);
+ }
+
+ public Entry<String, Headline>[] getAll() {
+ Entry<String, Headline>[] entries = new Entry[headlines.size()];
+ int i = 0;
+ for (Map.Entry<String, Headline> e: headlines.entrySet()) {
+ entries[i++] = new Entry<String, Headline>(e.getKey(), e.getValue());
+ }
+ return entries;
+ }
+
+ public Headline get(String key) throws NotFoundException {
+ Headline item = headlines.get(key);
+ if (item == null) {
+ throw new NotFoundException(key);
+ } else {
+ return item;
+ }
+ }
+
+ public String post(String key, Headline item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void put(String key, Headline item) throws NotFoundException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Entry<String, Headline>[] query(String queryString) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void delete(String key) throws NotFoundException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java
new file mode 100644
index 0000000000..b19f477912
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.atom.news;
+
+import java.net.Socket;
+
+import org.apache.tuscany.sca.binding.atom.aggregator.AggregatorTestCase;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class NewsServiceTestCase {
+ private static Node node;
+ private static NewsService newsService;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(AggregatorTestCase.class);
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/news/news.composite", new Contribution("test", contribution));
+ node.start();
+
+ newsService = node.getService(NewsService.class, "NewsService");
+ Assert.assertNotNull(newsService);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if(node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testPing() throws Exception {
+ new Socket("127.0.0.1", 8085);
+ // System.in.read();
+ }
+
+ @Test
+ public void testNewsService() throws Exception {
+ Entry<String, Headline>[] entries = newsService.getAll();
+
+ Assert.assertNotNull(entries);
+ Assert.assertTrue(entries.length > 0);
+
+ for(int pos = 0; pos < entries.length; pos++) {
+ System.out.println(">>> Entry[" + pos + "] - " + entries[pos].getData().getText());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/util/AtomTestCaseUtils.java b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/util/AtomTestCaseUtils.java
new file mode 100644
index 0000000000..1afad216e3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/util/AtomTestCaseUtils.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom.util;
+
+import java.io.IOException;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Base;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.client.RequestOptions;
+import org.apache.abdera.writer.Writer;
+import org.apache.abdera.writer.WriterFactory;
+
+/**
+ * Utilities to help print and test various aspects of entity tag support.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomTestCaseUtils {
+
+ public static void prettyPrint(Abdera abdera, Base doc) throws IOException {
+ WriterFactory factory = abdera.getWriterFactory();
+ Writer writer = factory.getWriter("prettyxml");
+ writer.writeTo(doc, System.out);
+ System.out.println();
+ }
+
+ public static void printRequestHeaders( String title, String indent, RequestOptions request ) {
+ System.out.println( title );
+ if ( request == null ) {
+ System.out.println( indent + " request is null");
+ return;
+ }
+ String [] headerNames = request.getHeaderNames();
+ for ( String headerName: headerNames) {
+ String header = request.getHeader(headerName);
+ System.out.println( indent + " header name,value=" + headerName + "," + header );
+ }
+ }
+
+ public static void printResponseHeaders( String title, String indent, ClientResponse response ) {
+ System.out.println( title );
+ if ( response == null ) {
+ System.out.println( indent + " response is null");
+ return;
+ }
+ String [] headerNames = response.getHeaderNames();
+ for ( String headerName: headerNames) {
+ String header = response.getHeader(headerName);
+ System.out.println( indent + " header name,value=" + headerName + "," + header );
+ }
+
+ }
+
+ public static Entry newEntry(String value) {
+ Abdera abdera = new Abdera();
+ Entry entry = abdera.newEntry();
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+ public static Entry updateEntry(Entry entry, String value) {
+ Abdera abdera = new Abdera();
+ entry.setTitle("customer " + value);
+
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(value);
+ entry.setContentElement(content);
+
+ return entry;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif
new file mode 100644
index 0000000000..bfeee9b2f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg
new file mode 100644
index 0000000000..584f39ea8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite
new file mode 100644
index 0000000000..43d8a7feda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://customer"
+ name="Consumer">
+
+ <component name="CustomerClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.atom.CustomerClientImpl"/>
+ <reference name="customerCollection">
+ <tuscany:binding.atom uri="http://localhost:8084/customer"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite
new file mode 100644
index 0000000000..819e19a801
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace = "http://customer"
+ name="Provider">
+
+ <!-- service name="customer" promote="CustomerCollection">
+ <tuscany:binding.atom uri = "http://localhost:8084/customer"/>
+ </service-->
+
+ <component name="CustomerCollection">
+ <implementation.java class="org.apache.tuscany.sca.binding.atom.CustomerCollectionImpl"/>
+ <service name="Collection">
+ <tuscany:binding.atom uri = "http://localhost:8084/customer"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite
new file mode 100644
index 0000000000..580e0ac324
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace = "http://customer"
+ name="ProviderNonCollection">
+
+ <!-- service name="customer" promote="CustomerCollection">
+ <tuscany:binding.atom uri = "http://localhost:8084/customer"
+ title="Atom binding Non Collection" description="Feed used for unit testing"/>
+ </service-->
+
+ <component name="CustomerCollection">
+ <implementation.java class="org.apache.tuscany.sca.binding.atom.CustomerNonCollectionImpl"/>
+ <service name="CustomerNonCollectionImpl">
+ <tuscany:binding.atom uri = "http://localhost:8084/customer"
+ title="Atom binding Non Collection" description="Feed used for unit testing"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite
new file mode 100644
index 0000000000..bac14b5b8b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace = "http://receipt"
+ name="ReceiptProvider">
+
+ <!-- service name="receipt" promote="MediaCollection">
+ <tuscany:binding.atom uri = "http://localhost:8084/receipt"/>
+ </service-->
+
+ <component name="MediaCollection">
+ <implementation.java class="org.apache.tuscany.sca.binding.atom.MediaCollectionImpl"/>
+ <service name="MediaCollection">
+ <tuscany:binding.atom uri = "http://localhost:8084/receipt"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite
new file mode 100644
index 0000000000..63085b3ea6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite
@@ -0,0 +1,51 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://aggregator"
+ name="FeedAggregator">
+
+ <!-- service name="atomSample" promote="AtomAggregator">
+ <tuscany:binding.atom uri="http://localhost:8085/atomAggregator"/>
+ </service-->
+
+ <component name="AtomAggregator">
+ <implementation.java class="org.apache.tuscany.sca.binding.atom.aggregator.AggregatorImpl"/>
+ <service name="Aggregator">
+ <tuscany:binding.atom uri="http://localhost:8085/atomAggregator"/>
+ </service>
+ <reference name="sort" target="Sort"/>
+ <reference name="atomFeed1">
+ <tuscany:binding.atom uri="http://www.ibm.com/developerworks/blogs/rss/lresende?flavor=atomdw"/>
+ </reference>
+ <reference name="atomFeed2">
+ <tuscany:binding.atom uri="https://blogs.apache.org/foundation/feed/entries/atom"/>
+ </reference>
+ <property name="feedTitle">Atom Aggregator Sample</property>
+ <property name="feedDescription">Anonymous Aggregated Feed</property>
+ <property name="feedAuthor">anonymous</property>
+ </component>
+
+ <component name="Sort">
+ <implementation.java class="org.apache.tuscany.sca.binding.atom.aggregator.SortImpl"/>
+ <property name="newFirst">true</property>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite
new file mode 100644
index 0000000000..bc74509dc5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://news"
+ name="newsService">
+
+ <component name="NewsService">
+ <implementation.java class="org.apache.tuscany.sca.binding.atom.news.NewsServiceImpl"/>
+ <service name="NewsService">
+ <tuscany:binding.atom uri="http://localhost:8085/news"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/LICENSE b/sandbox/sebastien/java/embed/modules/binding-atom/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/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/sebastien/java/embed/modules/binding-atom/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-atom/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..712a19bfa2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.atom;
+ uses:="org.apache.tuscany.sca.assembly";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Atom Feed Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Atom Feed Binding Extension
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.atom;version="2.0.0",
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.atom
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory b/sandbox/sebastien/java/embed/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory
new file mode 100644
index 0000000000..a8117db8f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.atom.impl.AtomBindingFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..00a4dfe0d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.atom,model=org.apache.tuscany.sca.binding.atom.AtomBinding,factory=org.apache.tuscany.sca.binding.atom.AtomBindingFactory \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/NOTICE b/sandbox/sebastien/java/embed/modules/binding-atom/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/pom.xml b/sandbox/sebastien/java/embed/modules/binding-atom/pom.xml
new file mode 100644
index 0000000000..84da39eca5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/pom.xml
@@ -0,0 +1,54 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-atom</artifactId>
+ <name>Apache Tuscany SCA Atom Feed Binding Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java
new file mode 100644
index 0000000000..7ac6e05bc9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.atom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * Atom binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AtomBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.atom");
+
+ /**
+ * Returns the title of the Atom collection.
+ * @return
+ */
+ String getTitle();
+
+ /**
+ * Sets the title of the Atom collection.
+ * @param title
+ */
+ void setTitle(String title);
+
+ /**
+ * Returns the description of the Atom collection.
+ *
+ * @return The description of the Atom collection
+ */
+ String getDescription();
+
+ /**
+ * Sets the description of the Atom collection.
+ *
+ * @param description The description of the Atom collection
+ */
+ void setDescription(String description);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java
new file mode 100644
index 0000000000..6e5623e1a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.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 org.apache.tuscany.sca.binding.atom;
+
+/**
+ * Factory for the Atom binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AtomBindingFactory {
+
+ /**
+ * Creates a new Atom binding.
+ * @return the new Atom binding
+ */
+ AtomBinding createAtomBinding();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingFactoryImpl.java
new file mode 100644
index 0000000000..ea06625d34
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingFactoryImpl.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 org.apache.tuscany.sca.binding.atom.impl;
+
+import org.apache.tuscany.sca.binding.atom.AtomBinding;
+import org.apache.tuscany.sca.binding.atom.AtomBindingFactory;
+
+/**
+ * Factory for the Atom binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomBindingFactoryImpl implements AtomBindingFactory {
+
+ public AtomBinding createAtomBinding() {
+ return new AtomBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.java
new file mode 100644
index 0000000000..c06a14726a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.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.sca.binding.atom.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.atom.AtomBinding;
+
+/**
+ * Implementation of the Atom Feed binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomBindingImpl implements AtomBinding {
+
+ private String name;
+ private String uri;
+ private String title;
+ private String description;
+
+ public QName getType() {
+ return AtomBinding.TYPE;
+ }
+
+ 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 String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isUnresolved() {
+ // The binding is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory
new file mode 100644
index 0000000000..9fc6a6bc22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.atom.impl.AtomBindingFactoryImpl
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..47798f1607
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.atom,model=org.apache.tuscany.sca.binding.atom.AtomBinding,factory=org.apache.tuscany.sca.binding.atom.AtomBindingFactory
diff --git a/sandbox/sebastien/java/embed/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java
new file mode 100644
index 0000000000..bfa922cbe4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.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.binding.atom;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AtomBindingProcessorTestCase {
+
+ private static final String COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" targetNamespace=\"http://binding-atom\" name=\"binding-atom\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <tuscany:binding.atom uri=\"http://localhost:8080/feed\" title=\"Feed Title\"/>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ /**
+ * Test parsing valid composite definition. Valid composite populated with correct values expected.
+ * @throws Exception
+ */
+ @Test
+ public void testLoadValidComposite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ AtomBinding binding = (AtomBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ Assert.assertNotNull(binding);
+ Assert.assertEquals("Feed Title", binding.getTitle());
+ Assert.assertEquals("http://localhost:8080/feed", binding.getURI());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/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/sebastien/java/embed/modules/binding-corba-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..395aa218a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,35 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.corba.provider.meta;ve
+ rsion="1.4",org.apache.tuscany.sca.binding.corba.provider.types.util;
+ version="2.0.0",org.apache.tuscany.sca.binding.corba.provider.util;vers
+ ion="1.4"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA CORBA Binding Runtime
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397143078
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA CORBA Binding Runtime
+Import-Package: javax.xml.namespace;resolution:=optional,
+ net.sf.cglib.proxy,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.corba;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.corba;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.omg.CORBA,
+ org.omg.CORBA.portable,
+ org.omg.CosNaming;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.corba.runtime
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/pom.xml
new file mode 100644
index 0000000000..516eea5f99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/pom.xml
@@ -0,0 +1,130 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-corba-runtime</artifactId>
+ <name>Apache Tuscany SCA CORBA Binding Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-corba</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Unfortunately the idlj maven plugin only works with SUN JDK -->
+ <!--
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/idl-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>idlj-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <debug>true</debug>
+ <compiler>idlj</compiler>
+ <sources>
+ <source>
+ <includes>
+ <include>tester.idl</include>
+ </includes>
+ <emitStubs>true</emitStubs>
+ <emitSkeletons>true</emitSkeletons>
+ </source>
+ </sources>
+ <sourceDirectory>${basedir}/src/test/resources</sourceDirectory>
+ <outputDirectory>${project.build.directory}/idl-source</outputDirectory>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.5.0</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ </dependencies>
+ </plugin>
+ -->
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaBindingProviderFactory.java
new file mode 100644
index 0000000000..bf0cc34195
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaBindingProviderFactory.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.sca.binding.corba.provider;
+
+import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.corba.ExtensibleCorbaHost;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CorbaBindingProviderFactory implements BindingProviderFactory<CorbaBinding> {
+ private ExtensibleCorbaHost host;
+
+ public CorbaBindingProviderFactory(ExtensionPointRegistry registry) {
+ host = ExtensibleCorbaHost.getInstance(registry);
+ }
+ /**
+ * @see org.apache.tuscany.sca.provider.BindingProviderFactory#createReferenceBindingProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference epr) {
+ return new CorbaReferenceBindingProvider(epr, host);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.BindingProviderFactory#createServiceBindingProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint ep) {
+ return new CorbaServiceBindingProvider(ep, host);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class<CorbaBinding> getModelType() {
+ return CorbaBinding.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaInvoker.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaInvoker.java
new file mode 100644
index 0000000000..0ad3b2240e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaInvoker.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.sca.binding.corba.provider;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException;
+import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaRequest;
+import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaResponse;
+import org.apache.tuscany.sca.binding.corba.provider.util.OperationMapper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.omg.CORBA.Object;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CorbaInvoker implements Invoker {
+
+ private Object remoteObject;
+ private Class<?> referenceClass;
+ private Map<Method, String> operationsMap;
+ private Map<Operation, Method> operationMethodMapping;
+
+ public CorbaInvoker(RuntimeComponentReference reference, Object remoteObject, Class<?> referenceClass, Map<Method, String> operationsMap) {
+ this.remoteObject = remoteObject;
+ this.referenceClass = referenceClass;
+ this.operationsMap = operationsMap;
+ this.operationMethodMapping = OperationMapper.mapOperationToMethod(reference.getInterfaceContract().getInterface().getOperations(), referenceClass);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message)
+ */
+ public Message invoke(Message msg) {
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, msg.getOperation().getName());
+ request.setReferenceClass(referenceClass);
+ request.setOperationsMap(operationsMap);
+ if (msg.getOperation().getOutputType() != null) {
+ Annotation[] notes = operationMethodMapping.get(msg.getOperation()).getAnnotations();
+ request.setOutputType(msg.getOperation().getOutputType().getPhysical(), notes);
+ }
+ java.lang.Object[] args = msg.getBody();
+ if (args != null) {
+ Annotation[][] notes = operationMethodMapping.get(msg.getOperation()).getParameterAnnotations();
+ for (int i = 0; i < args.length; i++) {
+ request.addArgument(args[i], notes[i]);
+ }
+ }
+ if (msg.getOperation().getFaultTypes() != null) {
+ for (DataType<?> type : msg.getOperation().getFaultTypes()) {
+ request.addExceptionType(type.getPhysical());
+ }
+ }
+ DynaCorbaResponse response = request.invoke();
+ msg.setBody(response.getContent());
+ } catch (RequestConfigurationException e) {
+ throw new ServiceRuntimeException(e);
+ } catch (Exception e) {
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaReferenceBindingProvider.java
new file mode 100644
index 0000000000..19ab58cc74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaReferenceBindingProvider.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.binding.corba.provider.util.OperationMapper;
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.omg.CORBA.Object;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CorbaReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private static final Logger logger = Logger.getLogger(CorbaReferenceBindingProvider.class.getName());
+ private CorbaBinding binding;
+ private CorbaHost host;
+ private RuntimeComponentReference reference;
+ private Object remoteObject;
+ private Class<?> referenceClass;
+ private Map<Method, String> operationsMap = null;
+
+ public CorbaReferenceBindingProvider(RuntimeEndpointReference epr, CorbaHost host) {
+ this.binding = (CorbaBinding) epr.getBinding();
+ this.host = host;
+ this.reference = (RuntimeComponentReference) epr.getReference();
+ this.referenceClass = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass();
+ operationsMap = OperationMapper.mapMethodToOperationName(referenceClass);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#createInvoker(org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public Invoker createInvoker(Operation operation) {
+ try {
+ if (remoteObject == null) {
+ remoteObject = host.lookup(binding.getCorbaname());
+ }
+ return new CorbaInvoker(reference, remoteObject, referenceClass, operationsMap);
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during creating CORBA invoker", e);
+ }
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#getBindingInterfaceContract()
+ */
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#start()
+ */
+ public void start() {
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#stop()
+ */
+ public void stop() {
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#supportsOneWayInvocation()
+ */
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaServiceBindingProvider.java
new file mode 100644
index 0000000000..0aa2e7394a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaServiceBindingProvider.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider;
+
+import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.binding.corba.provider.service.ComponentInvocationProxy;
+import org.apache.tuscany.sca.binding.corba.provider.service.DynaCorbaServant;
+import org.apache.tuscany.sca.binding.corba.provider.service.InvocationProxy;
+import org.apache.tuscany.sca.binding.corba.provider.types.util.Utils;
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+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.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CorbaServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+ private CorbaBinding binding;
+ private CorbaHost host;
+ // private RuntimeComponentService service;
+ private DynaCorbaServant servant;
+
+ public CorbaServiceBindingProvider(RuntimeEndpoint ep, CorbaHost host) {
+ this.endpoint = ep;
+ // this.service = (RuntimeComponentService) ep.getService();
+ this.binding = (CorbaBinding) ep.getBinding();
+ this.host = host;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#getBindingInterfaceContract()
+ */
+ public InterfaceContract getBindingInterfaceContract() {
+ return endpoint.getBindingInterfaceContract();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#start()
+ */
+ public void start() {
+ try {
+ Class<?> javaClass = ((JavaInterface)endpoint.getComponentTypeServiceInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy(endpoint, javaClass);
+ servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ servant.setIds(new String[] {binding.getId()});
+ host.registerServant(binding.getCorbaname(), servant);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#stop()
+ */
+ public void stop() {
+ try {
+ host.unregisterServant(binding.getCorbaname());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#supportsOneWayInvocation()
+ */
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/CorbaException.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/CorbaException.java
new file mode 100644
index 0000000000..b3569e43b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/CorbaException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider.exceptions;
+
+/**
+ * @version $Rev$ $Date$
+ * Represents CORBA SystemException
+ */
+public class CorbaException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public CorbaException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/RequestConfigurationException.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/RequestConfigurationException.java
new file mode 100644
index 0000000000..a554f56035
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/RequestConfigurationException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider.exceptions;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RequestConfigurationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+ private String objectId;
+
+ public RequestConfigurationException(String message, String objectId) {
+ super(message + ", object id was: " + objectId);
+ this.objectId = objectId;
+ }
+
+ public RequestConfigurationException(String message) {
+ super(message);
+ }
+
+ public String getType() {
+ return objectId;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaArray.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaArray.java
new file mode 100644
index 0000000000..823db1e748
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaArray.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider.meta;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @version $Rev$ $Date$
+ * Declares CORBA arrays lengths
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CorbaArray {
+
+ int[] value();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElement.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElement.java
new file mode 100644
index 0000000000..feb6627e25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElement.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.sca.binding.corba.provider.meta;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @version $Rev$ $Date$ Declares CORBA union object
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CorbaUnionElement {
+
+ // number of option in switch clause
+ int optionNumber() default -1;
+
+ // type of element
+ CorbaUnionElementType type();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElementType.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElementType.java
new file mode 100644
index 0000000000..1e7a0087e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElementType.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 org.apache.tuscany.sca.binding.corba.provider.meta;
+
+/**
+ * @version $Rev$ $Date$
+ * Types for union element
+ */
+public enum CorbaUnionElementType {
+ discriminator, defaultOption, option;
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaRequest.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaRequest.java
new file mode 100644
index 0000000000..e7d0b8b91b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaRequest.java
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.reference;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.CorbaException;
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException;
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTree;
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeCreator;
+import org.apache.tuscany.sca.binding.corba.provider.types.util.TypeHelpersProxy;
+import org.apache.tuscany.sca.binding.corba.provider.types.util.Utils;
+import org.apache.tuscany.sca.binding.corba.provider.util.MethodFinder;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$ Represents single CORBA request
+ */
+public class DynaCorbaRequest {
+
+ private TypeTree returnTree;
+ private Map<String, TypeTree> exceptions = new HashMap<String, TypeTree>();
+ private InputStream inputStream;
+ private ObjectImpl remoteObject;
+ private String operation;
+ private List<java.lang.Object> arguments = new ArrayList<java.lang.Object>();
+ private List<TypeTree> argumentsTypes = new ArrayList<TypeTree>();
+ private Class<?> referenceClass;
+ private Map<Method, String> operationsMap;
+
+ /**
+ * Creates request.
+ *
+ * @param ObjectremoteObject remote object reference
+ * @param operation operation to invoke
+ * @param scaBindingRules apply SCA default binding mapping rules
+ */
+ public DynaCorbaRequest(Object remoteObject, String operation) {
+ this.remoteObject = (ObjectImpl)remoteObject;
+ this.operation = operation;
+ }
+
+ /**
+ * Sets class which will be backed by this reference request
+ * @param referenceClass
+ */
+ public void setReferenceClass(Class<?> referenceClass) {
+ this.referenceClass = referenceClass;
+ }
+
+ /**
+ * Sets method to operation names mapping
+ * @param operationsMap
+ */
+ public void setOperationsMap(Map<Method, String> operationsMap) {
+ this.operationsMap = operationsMap;
+ }
+
+ /**
+ * Adds operation argument - stores arguments and caches its TypeTree. Annotations will be set to null by default.
+ *
+ * @param argument
+ */
+ public void addArgument(java.lang.Object argument) throws RequestConfigurationException {
+ addArgument(argument, null);
+ }
+
+ /**
+ * Adds operation argument - stores arguments and caches its TypeTree
+ *
+ * @param argument
+ */
+ public void addArgument(java.lang.Object argument, Annotation[] notes) throws RequestConfigurationException {
+ TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass(), notes);
+ argumentsTypes.add(tree);
+ arguments.add(argument);
+ }
+
+ /**
+ * Passing stored arguments to CORBA communication output stream
+ *
+ * @param outputStream
+ * @throws RequestConfigurationException
+ */
+ private void passArguments(OutputStream outputStream) throws RequestConfigurationException {
+ for (int i = 0; i < arguments.size(); i++) {
+ TypeTree tree = argumentsTypes.get(i);
+ TypeHelpersProxy.write(tree.getRootNode(), outputStream, arguments.get(i));
+ }
+ }
+
+ /**
+ * Sets return type for operation. Annotations will be set to null by default.
+ *
+ * @param forClass
+ */
+ public void setOutputType(Class<?> forClass) throws RequestConfigurationException {
+ setOutputType(forClass, null);
+ }
+
+ /**
+ * Sets return type for operation
+ *
+ * @param forClass
+ */
+ public void setOutputType(Class<?> forClass, Annotation[] notes) throws RequestConfigurationException {
+ returnTree = TypeTreeCreator.createTypeTree(forClass, notes);
+ }
+
+ /**
+ * Configures possible exceptions
+ *
+ * @param forClass
+ */
+ public void addExceptionType(Class<?> forClass) throws RequestConfigurationException {
+ TypeTree tree = TypeTreeCreator.createTypeTree(forClass, null);
+ String exceptionId = Utils.getTypeId(forClass);
+ exceptions.put(exceptionId, tree);
+ }
+
+ /**
+ * Handles application excpeition.
+ *
+ * @param ae occured exception
+ * @throws Exception
+ */
+ private void handleApplicationException(ApplicationException ae) throws Exception {
+ try {
+ if (exceptions.size() == 0) {
+ RequestConfigurationException exception =
+ new RequestConfigurationException(
+ "ApplicationException occured, but no exception type was specified.",
+ ae.getId());
+ throw exception;
+ }
+ InputStream is = ae.getInputStream();
+ String exceptionId = is.read_string();
+ TypeTree tree = exceptions.get(exceptionId);
+ if (tree == null) {
+ RequestConfigurationException exception =
+ new RequestConfigurationException(
+ "ApplicationException occured, but no such exception was defined",
+ ae.getId());
+ throw exception;
+ } else {
+ Exception ex = (Exception)TypeHelpersProxy.read(tree.getRootNode(), is);
+ throw ex;
+ }
+ } catch (Exception e) {
+ throw e;
+ }
+ }
+
+ /**
+ * Handles exceptions generated by CORBA API
+ *
+ * @param se
+ */
+ private void handleSystemException(SystemException se) throws Exception {
+ if (se instanceof BAD_OPERATION) {
+ throw new CorbaException("Bad operation name: " + operation, se);
+ } else if (se instanceof BAD_PARAM) {
+ throw new CorbaException("Bad parameter", se);
+ } else {
+ // TODO: handle more system exception types
+ throw new CorbaException(se.getMessage(), se);
+ }
+ }
+
+ /**
+ * Gets operation name which is includes mapping rules
+ * @return
+ */
+ private String getFinalOperationName() {
+ String result = operation;
+ if (referenceClass != null) {
+ Class<?>[] argumentTypes = new Class<?>[arguments.size()];
+ for (int i = 0; i < arguments.size(); i++) {
+ argumentTypes[i] = arguments.get(i).getClass();
+ }
+ Method method = MethodFinder.findMethod(referenceClass, operation, argumentTypes);
+ String newOperation = (String)operationsMap.get(method);
+ if (newOperation != null) {
+ result = newOperation;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Invokes previously configured request
+ *
+ * @return
+ */
+ public DynaCorbaResponse invoke() throws Exception {
+ DynaCorbaResponse response = new DynaCorbaResponse();
+ String finalOperationName = getFinalOperationName();
+ OutputStream outputStream = ((ObjectImpl)remoteObject)._request(finalOperationName, true);
+ passArguments(outputStream);
+ try {
+ inputStream = remoteObject._invoke(outputStream);
+ if (inputStream != null && returnTree != null) {
+ response.setContent(TypeHelpersProxy.read(returnTree.getRootNode(), inputStream));
+ }
+ } catch (ApplicationException ae) {
+ handleApplicationException(ae);
+ } catch (SystemException se) {
+ handleSystemException(se);
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ release();
+ }
+ return response;
+ }
+
+ /**
+ * Releases request resources
+ */
+ private void release() {
+ remoteObject._releaseReply(inputStream);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaResponse.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaResponse.java
new file mode 100644
index 0000000000..6a01c70a38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaResponse.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.sca.binding.corba.provider.reference;
+
+/**
+ * @version $Rev$ $Date$
+ * Holder for content returned from DynaCorbaRequest
+ *
+ */
+public class DynaCorbaResponse {
+
+ private Object content;
+
+ public Object getContent() {
+ return content;
+ }
+
+ public void setContent(Object content) {
+ this.content = content;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceInstanceCreator.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceInstanceCreator.java
new file mode 100644
index 0000000000..2828e09cc7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceInstanceCreator.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.binding.corba.provider.reference;
+
+import java.lang.reflect.Method;
+
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.CallbackFilter;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.NoOp;
+
+import org.omg.CORBA.Object;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterfaceInstanceCreator {
+
+ private static final CallbackFilter FILTER = new CallbackFilter() {
+ public int accept(Method method) {
+ return 1;
+ }
+ };
+
+ /**
+ * Dynamically creates instance of user defined interface. Instance is
+ * enhanced by RemoteMethodInterceptor
+ *
+ * @param reference
+ * CORBA reference
+ * @param forClass
+ * user defined interface
+ * @return dynamic implementation instance
+ */
+ public static java.lang.Object createInstance(Object reference, Class<?> forClass) {
+ java.lang.Object result = null;
+ try {
+ Enhancer enhancer = new Enhancer();
+ enhancer.setInterfaces(new Class[] {forClass});
+ enhancer.setCallbackFilter(FILTER);
+ enhancer.setCallbackTypes(new Class[] {NoOp.class, MethodInterceptor.class});
+ Class<?> newClass = enhancer.createClass();
+ Enhancer.registerStaticCallbacks(newClass, new Callback[] {NoOp.INSTANCE,
+ new InterfaceMethodInterceptor(reference, forClass)});
+ result = newClass.newInstance();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceMethodInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceMethodInterceptor.java
new file mode 100644
index 0000000000..c5c98ab27c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceMethodInterceptor.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.sca.binding.corba.provider.reference;
+
+import java.lang.reflect.Method;
+
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.omg.CORBA.Object;
+
+/**
+ * @version $Rev$ $Date$
+ * Interceptor for CORBA reference methods
+ */
+public class InterfaceMethodInterceptor implements MethodInterceptor {
+
+ private Object reference;
+ private Class<?> javaClass;
+
+ public InterfaceMethodInterceptor(Object reference, Class<?> javaClass) {
+ this.reference = reference;
+ this.javaClass = javaClass;
+ }
+
+ /**
+ * Create and execute DynaCorbaRequest instance, basing on intercepted
+ * method arguments, return types, exceptions
+ */
+ public java.lang.Object intercept(java.lang.Object object,
+ Method method,
+ java.lang.Object[] arguments,
+ MethodProxy arg3) throws Throwable {
+ DynaCorbaRequest request = new DynaCorbaRequest(reference, method.getName());
+ request.setReferenceClass(javaClass);
+ for (int i = 0; i < arguments.length; i++) {
+ request.addArgument(arguments[i]);
+ }
+ request.setOutputType(method.getReturnType());
+ Class<?>[] exceptions = method.getExceptionTypes();
+ for (int i = 0; i < exceptions.length; i++) {
+ request.addExceptionType(exceptions[i]);
+ }
+ DynaCorbaResponse response = request.invoke();
+ return response.getContent();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/ComponentInvocationProxy.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/ComponentInvocationProxy.java
new file mode 100644
index 0000000000..5babc25b07
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/ComponentInvocationProxy.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.service;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException;
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTree;
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeCreator;
+import org.apache.tuscany.sca.binding.corba.provider.util.OperationMapper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * @version $Rev$ $Date$
+ * Invocation proxy for SCA components
+ */
+public class ComponentInvocationProxy implements InvocationProxy {
+
+ private Invocable wire;
+ private Map<Method, Operation> methodOperationMapping;
+ private Map<Operation, Method> operationMethodMapping;
+ private Map<String, Method> operationsMap;
+ private Map<Operation, OperationTypes> operationsCache = new HashMap<Operation, OperationTypes>();
+
+ public ComponentInvocationProxy(RuntimeEndpoint wire, Class javaClass)
+ throws RequestConfigurationException {
+ this.wire = wire;
+ Interface interfaze = wire.getComponentTypeServiceInterfaceContract().getInterface();
+ operationsMap = OperationMapper.mapOperationNameToMethod(javaClass);
+ operationMethodMapping = OperationMapper.mapOperationToMethod(interfaze.getOperations(), javaClass);
+ methodOperationMapping = OperationMapper.mapMethodToOperation(interfaze.getOperations(), javaClass);
+ cacheOperationTypes(interfaze.getOperations());
+ }
+
+ /**
+ * Caches TypeTree for every operation in backed component
+ *
+ * @param operations
+ * @throws RequestConfigurationException
+ */
+ private void cacheOperationTypes(List<Operation> operations) throws RequestConfigurationException {
+ for (Operation operation : operations) {
+ try {
+ OperationTypes operationTypes = new OperationTypes();
+ List<TypeTree> inputInstances = new ArrayList<TypeTree>();
+ // cache output type tree
+ if (operation.getOutputType() != null && operation.getOutputType().getPhysical() != null
+ && !operation.getOutputType().getPhysical().equals(void.class)) {
+ Annotation[] notes = operationMethodMapping.get(operation).getAnnotations();
+ TypeTree outputType =
+ TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical(), notes);
+ operationTypes.setOutputType(outputType);
+ }
+ // cache input types trees
+ if (operation.getInputType() != null) {
+ Method method = operationMethodMapping.get(operation);
+ Annotation[][] notes = method.getParameterAnnotations();
+ int i = 0;
+ for (DataType<List<DataType<?>>> type : operation.getInputType().getLogical()) {
+ Class<?> forClass = type.getPhysical();
+ TypeTree inputType = TypeTreeCreator.createTypeTree(forClass, notes[i]);
+ inputInstances.add(inputType);
+ i++;
+ }
+
+ }
+ operationTypes.setInputType(inputInstances);
+ operationsCache.put(operation, operationTypes);
+ } catch (RequestConfigurationException e) {
+ throw e;
+ }
+ }
+ }
+
+ private Operation getOperation4Name(String operationName) {
+ Method method = operationsMap.get(operationName);
+ return methodOperationMapping.get(method);
+ }
+
+ public OperationTypes getOperationTypes(String operationName) {
+ return operationsCache.get(getOperation4Name(operationName));
+ }
+
+ public Object invoke(String operationName, List<Object> arguments) throws InvocationException {
+ Object result = null;
+ try {
+ result = wire.invoke(getOperation4Name(operationName), arguments.toArray());
+ } catch (InvocationTargetException e) {
+ InvocationException exception = new InvocationException(e.getCause());
+ throw exception;
+ }
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/DynaCorbaServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/DynaCorbaServant.java
new file mode 100644
index 0000000000..d8524eaee9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/DynaCorbaServant.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException;
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTree;
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeCreator;
+import org.apache.tuscany.sca.binding.corba.provider.types.util.TypeHelpersProxy;
+import org.apache.tuscany.sca.binding.corba.provider.types.util.Utils;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+
+/**
+ * @version $Rev$ $Date$
+ * General servant which provides target component implementation via CORBA
+ */
+public class DynaCorbaServant extends ObjectImpl implements InvokeHandler {
+
+ private static final Logger logger = Logger.getLogger(DynaCorbaServant.class.getName());
+
+ private String[] ids;
+ private InvocationProxy invocationProxy;
+ private String typeId;
+
+ /**
+ * Creates servant object
+ * @param invocationProxy
+ * @param typeId
+ * @throws RequestConfigurationException
+ */
+ public DynaCorbaServant(InvocationProxy invocationProxy, String typeId) throws RequestConfigurationException {
+ this.invocationProxy = invocationProxy;
+ this.typeId = typeId;
+ setDefaultIds();
+ }
+
+ /**
+ * Sets CORBA object ID
+ * @param ids
+ */
+ public void setIds(String[] ids) {
+ for (int i = 0; i < ids.length; i++) {
+ if (ids[i] == null || ids[i].length() == 0) {
+ // if invalid id was passed then set to default
+ setDefaultIds();
+ return;
+ }
+ }
+ this.ids = ids;
+ }
+
+ public OutputStream _invoke(String operationName, InputStream in, ResponseHandler rh) {
+ OperationTypes types = invocationProxy.getOperationTypes(operationName);
+ if (types == null) {
+ // operation wasn't found
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ } else {
+ List<Object> inputInstances = new ArrayList<Object>();
+ try {
+ // retrieving in arguments
+ for (TypeTree tree : types.getInputType()) {
+ Object o = TypeHelpersProxy.read(tree.getRootNode(), in);
+ inputInstances.add(o);
+ }
+ } catch (MARSHAL e) {
+ // parameter passed by user was not compatible with Java to
+ // Corba mapping
+ throw new org.omg.CORBA.BAD_PARAM(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+ try {
+ // invocation and sending result
+ Object result = invocationProxy.invoke(operationName, inputInstances);
+ OutputStream out = rh.createReply();
+ if (types.getOutputType() != null) {
+ TypeTree tree = types.getOutputType();
+ TypeHelpersProxy.write(tree.getRootNode(), out, result);
+ }
+ return out;
+ } catch (InvocationException ie) {
+ // handling user exception
+ try {
+ OutputStream out = rh.createExceptionReply();
+ Class<?> exceptionClass = ie.getTargetException().getClass();
+ TypeTree tree = TypeTreeCreator.createTypeTree(exceptionClass, null);
+ String exceptionId = Utils.getTypeId(exceptionClass);
+ out.write_string(exceptionId);
+ TypeHelpersProxy.write(tree.getRootNode(), out, ie.getTargetException());
+ return out;
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during handling invocation exception", e);
+ }
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Unexpected exception during sending CORBA result to client", e);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String[] _ids() {
+ return ids;
+ }
+
+ /**
+ * Sets servant ID to default, based on Java class name
+ */
+ private void setDefaultIds() {
+ this.ids = new String[] {typeId};
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationException.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationException.java
new file mode 100644
index 0000000000..57e2fae9f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider.service;
+
+/**
+ * @version $Rev$ $Date$
+ * Wrapper for exception thrown during target invocation
+ */
+public class InvocationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+ private Throwable targetException;
+
+ public InvocationException(Throwable targetException) {
+ this.targetException = targetException;
+ }
+
+ public Throwable getTargetException() {
+ return targetException;
+ }
+
+ public void setTargetException(Throwable target) {
+ this.targetException = target;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationProxy.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationProxy.java
new file mode 100644
index 0000000000..2e2066802a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationProxy.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.sca.binding.corba.provider.service;
+
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ * Target proxy interface for service bindings
+ */
+public interface InvocationProxy {
+
+ /**
+ * Gets operations types for target
+ * @param operationName
+ * @return
+ */
+ public OperationTypes getOperationTypes(String operationName);
+
+ /**
+ * Invokes target operation
+ * @param operationName
+ * @param arguments
+ * @return
+ * @throws InvocationException
+ */
+ public Object invoke(String operationName, List<Object> arguments) throws InvocationException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/OperationTypes.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/OperationTypes.java
new file mode 100644
index 0000000000..766048ac64
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/OperationTypes.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.service;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTree;
+
+/**
+ * @version $Rev$ $Date$
+ * Holder for Java type trees for one method
+ */
+public class OperationTypes {
+
+ private TypeTree outputType;
+ private List<TypeTree> inputType;
+
+ public TypeTree getOutputType() {
+ return outputType;
+ }
+
+ public void setOutputType(TypeTree outputType) {
+ this.outputType = outputType;
+ }
+
+ public List<TypeTree> getInputType() {
+ return inputType;
+ }
+
+ public void setInputType(List<TypeTree> inputType) {
+ this.inputType = inputType;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/AnnotationAttributes.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/AnnotationAttributes.java
new file mode 100644
index 0000000000..ab7371bbe8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/AnnotationAttributes.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.sca.binding.corba.provider.types;
+
+/**
+ * Holds information retrieved from objects annotations
+ */
+public class AnnotationAttributes {
+
+ private boolean corbaArray;
+ private int[] corbaArrayLength;
+
+ public boolean isCorbaArray() {
+ return corbaArray;
+ }
+
+ public void setCorbaArray(boolean isCorbaArray) {
+ this.corbaArray = isCorbaArray;
+ }
+
+ public int[] getCorbaArrayLength() {
+ return corbaArrayLength;
+ }
+
+ public void setCorbaArrayLength(int[] corbaArrayLength) {
+ this.corbaArrayLength = corbaArrayLength;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/NodeType.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/NodeType.java
new file mode 100644
index 0000000000..706a44406b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/NodeType.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 org.apache.tuscany.sca.binding.corba.provider.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Types of CORBA objects.
+ */
+public enum NodeType {
+ primitive, struct, union, array, sequence, reference, idl_enum, exception
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTree.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTree.java
new file mode 100644
index 0000000000..d4207ab735
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTree.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.binding.corba.provider.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Helper tree for Java object hierarchy. It's closer to CORBA types
+ * structure than plain Java hierarchy - it helps reading and writing
+ * complex structures.
+ */
+public class TypeTree {
+
+ private TypeTreeNode rootNode;
+
+ /**
+ * Returns root node.
+ *
+ * @return root of type tree
+ */
+ public TypeTreeNode getRootNode() {
+ return rootNode;
+ }
+
+ /**
+ * Sets root of the type tree.
+ *
+ * @param rootNode root node.
+ */
+ public void setRootNode(TypeTreeNode rootNode) {
+ this.rootNode = rootNode;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeCreator.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeCreator.java
new file mode 100644
index 0000000000..1ba4002303
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeCreator.java
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.types;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+/**
+ * @version $Rev$ $Date$
+ * Creator of types tree.
+ */
+public class TypeTreeCreator {
+
+ /**
+ * Helps to determine if type is a primitive.
+ */
+ private static List<Class<?>> primitives = new ArrayList<Class<?>>();
+
+ static {
+ primitives.add(boolean.class);
+ primitives.add(byte.class);
+ primitives.add(short.class);
+ primitives.add(int.class);
+ primitives.add(long.class);
+ primitives.add(double.class);
+ primitives.add(float.class);
+ primitives.add(char.class);
+ primitives.add(String.class);
+ primitives.add(Boolean.class);
+ primitives.add(Byte.class);
+ primitives.add(Short.class);
+ primitives.add(Integer.class);
+ primitives.add(Long.class);
+ primitives.add(Double.class);
+ primitives.add(Float.class);
+ primitives.add(Character.class);
+ }
+
+ /**
+ * Creates class for given string argument.
+ *
+ * @param name name of type
+ * @return type
+ */
+ private static Class<?> createClassFromString(String name) {
+ Class<?> result = null;
+ try {
+ if (name.length() == 1) {
+ // primitives
+ switch (name.charAt(0)) {
+ case 'Z':
+ result = boolean.class;
+ break;
+ case 'C':
+ result = char.class;
+ break;
+ case 'B':
+ result = byte.class;
+ break;
+ case 'S':
+ result = short.class;
+ break;
+ case 'I':
+ result = int.class;
+ break;
+ case 'J':
+ result = long.class;
+ break;
+ case 'F':
+ result = float.class;
+ break;
+ case 'D':
+ result = double.class;
+ break;
+ }
+ } else {
+ // class
+ name = name.substring(1, name.length() - 1);
+ result = Class.forName(name);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ /**
+ * Reduces dimension of array.
+ *
+ * @param forClass array class
+ * @return reduced array
+ */
+ private static Class<?> reduceArrayDimension(Class<?> forClass) {
+ String name = forClass.getName();
+ try {
+ String reduced = name.substring(1, name.length());
+ if (reduced.startsWith("[")) {
+ // reduced class is still an array
+ return Class.forName(reduced);
+ } else {
+ // reduced class may be primitive or class
+ return createClassFromString(reduced);
+ }
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Return given array without first element
+ *
+ * @param array
+ * @return
+ */
+ private static int[] removeFirstElement(int[] array) {
+ int[] result = new int[array.length - 1];
+ System.arraycopy(array, 1, result, 0, result.length);
+ return result;
+ }
+
+ /**
+ * Converts objects annotations to structure which will be used by this
+ * class
+ *
+ * @param notes
+ * @return
+ */
+ private static AnnotationAttributes createAnnotationAttributes(Annotation[] notes) {
+ AnnotationAttributes attrs = new AnnotationAttributes();
+ for (int i = 0; notes != null && i < notes.length; i++) {
+ if (notes[i].annotationType().equals(CorbaArray.class)) {
+ attrs.setCorbaArray(true);
+ attrs.setCorbaArrayLength(((CorbaArray)notes[i]).value());
+ }
+ }
+ return attrs;
+ }
+
+ /**
+ * Creates tree for given type.
+ *
+ * @param forClass
+ * @return type tree
+ */
+ public static TypeTree createTypeTree(Class<?> forClass, Annotation[] notes) throws RequestConfigurationException {
+ TypeTree tree = new TypeTree();
+ TypeTreeNode rootNode = null;
+ AnnotationAttributes attrs = createAnnotationAttributes(notes);
+ rootNode = inspectClassHierarchy(forClass, attrs, tree);
+ tree.setRootNode(rootNode);
+ return tree;
+
+ }
+
+ /**
+ * Recurrent method which builds type tree.
+ *
+ * @param forClass
+ * @param tree
+ * @return
+ */
+ private static TypeTreeNode inspectClassHierarchy(Class<?> forClass, AnnotationAttributes attributes, TypeTree tree)
+ throws RequestConfigurationException {
+
+ TypeTreeNode node = null;
+ node = createTypeNode(forClass, attributes);
+
+ NodeType nodeType = node.getNodeType();
+ TypeTreeNode[] children = null;
+
+ if (nodeType.equals(NodeType.primitive)) {
+ // stop condition for recurrent method
+ } else if (nodeType.equals(NodeType.array)) {
+ Class<?> reduced = reduceArrayDimension(node.getJavaClass());
+ children = new TypeTreeNode[1];
+ int[] newLengths = removeFirstElement(attributes.getCorbaArrayLength());
+ attributes.setCorbaArrayLength(newLengths);
+ children[0] = inspectClassHierarchy(reduced, attributes, tree);
+ } else if (nodeType.equals(NodeType.sequence)) {
+ // reducing sequence dimension
+ Class<?> reduced = reduceArrayDimension(node.getJavaClass());
+ children = new TypeTreeNode[1];
+ children[0] = inspectClassHierarchy(reduced, attributes, tree);
+ // System.arraycopy(src, srcPos, dest, destPos, length)
+ } else if (nodeType.equals(NodeType.struct) || nodeType.equals(NodeType.exception)) {
+ // inspect types for every structure member
+ Field[] fields = node.getJavaClass().getFields();
+ children = new TypeTreeNode[fields.length];
+ for (int i = 0; i < fields.length; i++) {
+ Class<?> field = fields[i].getType();
+ AnnotationAttributes fAttrs = createAnnotationAttributes(fields[i].getAnnotations());
+ TypeTreeNode child = inspectClassHierarchy(field, fAttrs, tree);
+ child.setName(fields[i].getName());
+ children[i] = child;
+ }
+ } else if (nodeType.equals(NodeType.idl_enum)) {
+
+ } else if (nodeType.equals(NodeType.union)) {
+ // inspect types for every structure member
+ Field[] fields = node.getJavaClass().getDeclaredFields();
+ children = new TypeTreeNode[fields.length];
+ for (int i = 0; i < fields.length; i++) {
+ Class<?> field = fields[i].getType();
+ AnnotationAttributes fAttrs = createAnnotationAttributes(fields[i].getAnnotations());
+ TypeTreeNode child = inspectClassHierarchy(field, fAttrs, tree);
+ child.setName(fields[i].getName());
+ children[i] = child;
+ }
+ } else if (nodeType.equals(NodeType.reference)) {
+ // TODO: CORBA references
+ }
+
+ node.setChildren(children);
+ return node;
+ }
+
+ /**
+ * Creating and configuring TypeTreeNode for given class.
+ *
+ * @param forClass class
+ * @return node
+ * @throws RequestConfigurationException
+ */
+ private static TypeTreeNode createTypeNode(Class<?> forClass, AnnotationAttributes attributes)
+ throws RequestConfigurationException {
+ TypeTreeNode node = new TypeTreeNode();
+ if (forClass.isArray() && !attributes.isCorbaArray()) {
+ node.setNodeType(NodeType.sequence);
+ node.setJavaClass(forClass);
+ } else if (forClass.isArray() && attributes.isCorbaArray()) {
+ node.setNodeType(NodeType.array);
+ node.setJavaClass(forClass);
+ try {
+ // set the actual array size for further use by ArrayTypeHelper
+ node.setAttributes(attributes.getCorbaArrayLength()[0]);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ RequestConfigurationException exc =
+ new RequestConfigurationException("Annotated array size doesn't match declared arrays size");
+ throw exc;
+ }
+ } else if (primitives.contains(forClass)) {
+ node.setNodeType(NodeType.primitive);
+ node.setJavaClass(forClass);
+ node.setChildren(null);
+ } else if (forClass.isInterface()) {
+ node.setNodeType(NodeType.reference);
+ node.setJavaClass(forClass);
+ node.setChildren(null);
+ } else if (isStructType(forClass)) {
+ node.setNodeType(NodeType.struct);
+ node.setJavaClass(forClass);
+ } else if (isEnumType(forClass)) {
+ node.setNodeType(NodeType.idl_enum);
+ node.setJavaClass(forClass);
+ } else if (isUserException(forClass)) {
+ node.setNodeType(NodeType.exception);
+ node.setJavaClass(forClass);
+ } else if (isUnionType(forClass)) {
+ node.setNodeType(NodeType.union);
+ node.setJavaClass(forClass);
+ node.setAttributes(getUnionAttributes(forClass));
+ } else {
+ RequestConfigurationException e =
+ new RequestConfigurationException("User defined type which cannot be handled: " + forClass
+ .getCanonicalName());
+ throw e;
+ }
+ return node;
+ }
+
+ /**
+ * Tells whether given class is structure
+ *
+ * @param forClass
+ * @return
+ */
+ private static boolean isStructType(Class<?> forClass) {
+ int classMods = forClass.getModifiers();
+ if (!Modifier.isFinal(classMods)) {
+ return false;
+ }
+ boolean areCtorsValid = false;
+ Class<?>[] fieldsTypes = null;
+ Constructor<?>[] ctors = forClass.getConstructors();
+ /*
+ * Do we have 2 ctors and one of them is null ctor?
+ */
+ if (ctors.length != 2) {
+ return false;
+ }
+ for (int i = 0; i < ctors.length; i++) {
+ Class<?>[] params = ctors[i].getParameterTypes();
+ if (params.length == 0) {
+ areCtorsValid = true;
+ } else {
+ fieldsTypes = params;
+ }
+ }
+ if (!areCtorsValid) {
+ return false;
+ }
+ /*
+ * Are constructor args declared as class fields?
+ */
+ Field[] fields = forClass.getFields();
+ Set<Class<?>> fieldsSet = new HashSet<Class<?>>(Arrays.asList(fieldsTypes));
+ for (int i = 0; i < fields.length && !fieldsSet.isEmpty(); i++) {
+ int mods = fields[i].getModifiers();
+ if (Modifier.isPublic(mods) && !Modifier.isStatic(mods) && !Modifier.isFinal(mods)) {
+ fieldsSet.remove(fields[i].getType());
+ }
+
+ }
+ return fieldsSet.isEmpty();
+ }
+
+ /**
+ * Tells whether given class is enum
+ *
+ * @param forClass
+ * @return
+ */
+ private static boolean isEnumType(Class<?> forClass) {
+ boolean isValueMethod = false;
+ boolean isFromIntMethod = false;
+ /*
+ * enum type should have value and from_int methods
+ */
+ try {
+ Method valueMet = forClass.getMethod("value", new Class[] {});
+ int modValueMet = valueMet.getModifiers();
+ if (valueMet.getReturnType().equals(int.class) && Modifier.isPublic(modValueMet)) {
+ isValueMethod = true;
+ }
+ Method fromIntMet = forClass.getMethod("from_int", new Class[] {int.class});
+ int modFromIntMet = fromIntMet.getModifiers();
+ if ((fromIntMet.getReturnType().equals(forClass) && Modifier.isPublic(modFromIntMet) && Modifier
+ .isStatic(modFromIntMet))) {
+ isFromIntMethod = true;
+ }
+ } catch (NoSuchMethodException e) {
+ }
+ if (!isFromIntMethod || !isValueMethod) {
+ return false;
+ }
+ /*
+ * enum type should also contain minimum one pair of fields: EnumType
+ * field and int _field
+ */
+ int enumCount = 0;
+ Field[] fields = forClass.getFields();
+ for (int i = 0; i < fields.length; i++) {
+ if (fields[i].getType().equals(forClass)) {
+ int modifiers = fields[i].getModifiers();
+ if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers) && Modifier.isFinal(modifiers)) {
+ try {
+ Field field = forClass.getField("_" + fields[i].getName());
+ if (field.getType().equals(int.class)) {
+ enumCount++;
+ }
+ } catch (NoSuchFieldException e) {
+ }
+
+ }
+ }
+ }
+ return enumCount > 0;
+ }
+
+ /**
+ * Tells whether given class is CORBA user exception
+ *
+ * @param forClass
+ * @return
+ */
+ private static boolean isUserException(Class<?> forClass) {
+ do {
+ if (forClass.equals(Exception.class)) {
+ return true;
+ } else {
+ forClass = forClass.getSuperclass();
+ }
+ } while (forClass != null && !forClass.equals(Object.class));
+ return false;
+ }
+
+ /**
+ * Tells whether given class is CORBA union. This method validates usage of
+ * unions annotations.
+ *
+ * @param forClass
+ * @return
+ * @throws RequestConfigurationException
+ */
+ private static boolean isUnionType(Class<?> forClass) throws RequestConfigurationException {
+ int classMods = forClass.getModifiers();
+ if (!Modifier.isFinal(classMods)) {
+ return false;
+ }
+ boolean atLeastOneOption = false;
+ boolean discriminatorPresent = false;
+ for (int i = 0; i < forClass.getDeclaredFields().length; i++) {
+ CorbaUnionElement note = forClass.getDeclaredFields()[i].getAnnotation(CorbaUnionElement.class);
+ if (note != null) {
+ int fieldMod = forClass.getDeclaredFields()[i].getModifiers();
+ if (Modifier.isPrivate(fieldMod) && !Modifier.isFinal(fieldMod) && !Modifier.isStatic(fieldMod)) {
+ if (note.type().equals(CorbaUnionElementType.discriminator)) {
+ if (discriminatorPresent) {
+ throw new RequestConfigurationException(
+ "More than one discriminators declared on: " + forClass);
+ }
+ discriminatorPresent = true;
+ } else {
+ atLeastOneOption = true;
+ }
+ } else {
+ throw new RequestConfigurationException(
+ "Annotated union field should be private, not final and no static on class: " + forClass);
+ }
+ }
+ }
+ if (atLeastOneOption && !discriminatorPresent) {
+ throw new RequestConfigurationException("No discriminator annotation found on: " + forClass);
+ } else if (!atLeastOneOption && discriminatorPresent) {
+ throw new RequestConfigurationException("No union option found on: " + forClass);
+ } else if (discriminatorPresent && atLeastOneOption) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Gets union attributes - discriminator field name, option fields etc. This
+ * method relies that previously scanned class is valid (method isUnionType)
+ *
+ * @param forClass
+ * @return
+ * @throws RequestConfigurationException
+ */
+ private static UnionAttributes getUnionAttributes(Class<?> forClass) throws RequestConfigurationException {
+ UnionAttributes attributes = new UnionAttributes();
+ for (int i = 0; i < forClass.getDeclaredFields().length; i++) {
+ CorbaUnionElement note = forClass.getDeclaredFields()[i].getAnnotation(CorbaUnionElement.class);
+ if (note != null) {
+ if (note.type().equals(CorbaUnionElementType.discriminator)) {
+ attributes.setDiscriminatorName(forClass.getDeclaredFields()[i].getName());
+ } else if (note.type().equals(CorbaUnionElementType.defaultOption)) {
+ attributes.setDefaultOptionName(forClass.getDeclaredFields()[i].getName());
+ } else if (note.type().equals(CorbaUnionElementType.option)) {
+ if (attributes.getOptionsMapping().containsKey(note.optionNumber())) {
+ throw new RequestConfigurationException("In " + forClass
+ + ": field \""
+ + forClass.getDeclaredFields()[i].getName()
+ + "\" uses already used option id: "
+ + note.optionNumber());
+ } else {
+ attributes.getOptionsMapping().put(note.optionNumber(),
+ forClass.getDeclaredFields()[i].getName());
+ }
+ }
+ }
+ }
+ return attributes;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeNode.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeNode.java
new file mode 100644
index 0000000000..009eac3377
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeNode.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.sca.binding.corba.provider.types;
+
+/**
+ * @version $Rev$ $Date$
+ * Represents single tree node.
+ *
+ */
+public class TypeTreeNode {
+
+ private NodeType nodeType;
+ private TypeTreeNode[] children;
+ private Class<?> javaClass;
+ private String name;
+ private Object attributes;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public NodeType getNodeType() {
+ return nodeType;
+ }
+
+ public void setNodeType(NodeType nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ public TypeTreeNode[] getChildren() {
+ return children;
+ }
+
+ public void setChildren(TypeTreeNode[] children) {
+ this.children = children;
+ }
+
+ public Class<?> getJavaClass() {
+ return javaClass;
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ this.javaClass = javaClass;
+ }
+
+ public Object getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Object attributes) {
+ this.attributes = attributes;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/UnionAttributes.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/UnionAttributes.java
new file mode 100644
index 0000000000..34bee2a0e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/UnionAttributes.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ * Stores attributes for previously scanned CORBA union type
+ */
+public class UnionAttributes {
+
+ public String discriminatorName;
+ public String defaultOptionName;
+ public Map<Integer, String> optionsMapping = new HashMap<Integer, String>();
+
+ public String getDiscriminatorName() {
+ return discriminatorName;
+ }
+
+ public void setDiscriminatorName(String discriminatorName) {
+ this.discriminatorName = discriminatorName;
+ }
+
+ public String getDefaultOptionName() {
+ return defaultOptionName;
+ }
+
+ public void setDefaultOptionName(String defaultOptionName) {
+ this.defaultOptionName = defaultOptionName;
+ }
+
+ public Map<Integer, String> getOptionsMapping() {
+ return optionsMapping;
+ }
+
+ public void setOptionsMapping(Map<Integer, String> optionsMapping) {
+ this.optionsMapping = optionsMapping;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ArrayTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ArrayTypeHelper.java
new file mode 100644
index 0000000000..35a1e539d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ArrayTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import java.lang.reflect.Array;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ArrayTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ Object array = null;
+ try {
+ int size = (Integer)node.getAttributes();
+ array = Array.newInstance(node.getChildren()[0].getJavaClass(), size);
+ for (int i = 0; i < size; i++) {
+ Array.set(array, i, TypeHelpersProxy.read(node.getChildren()[0], is));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return array;
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ for (int i = 0; i < (Integer)node.getAttributes(); i++) {
+ TypeHelpersProxy.write(node.getChildren()[0], os, Array.get(data, i));
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/BooleanTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/BooleanTypeHelper.java
new file mode 100644
index 0000000000..bbc2012a38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/BooleanTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BooleanTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_boolean();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_boolean((Boolean)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ByteTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ByteTypeHelper.java
new file mode 100644
index 0000000000..761cc5d62c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ByteTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ByteTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_octet();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_octet((Byte)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/CharTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/CharTypeHelper.java
new file mode 100644
index 0000000000..b2d2afd011
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/CharTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CharTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_char();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_char((Character)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/DoubleTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/DoubleTypeHelper.java
new file mode 100644
index 0000000000..f667123bb7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/DoubleTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DoubleTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_double();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_double((Double)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/EnumTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/EnumTypeHelper.java
new file mode 100644
index 0000000000..ae52bd6bbf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/EnumTypeHelper.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.types.util;
+
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EnumTypeHelper implements TypeHelper {
+
+ private static final Logger logger = Logger.getLogger(EnumTypeHelper.class.getName());
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ int value = is.read_long();
+ Object result = null;
+ try {
+ Method method = node.getJavaClass().getMethod("from_int", new Class[] {int.class});
+ result = method.invoke(null, new Object[] {value});
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during reading CORBA enum data", e);
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ int value = 0;
+ try {
+ Method method = data.getClass().getMethod("value", new Class[] {});
+ value = (Integer)method.invoke(data, new Object[] {});
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during writing CORBA enum data", e);
+ }
+ os.write_long(value);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/FloatTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/FloatTypeHelper.java
new file mode 100644
index 0000000000..7c39725012
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/FloatTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FloatTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_float();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_float((Float)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/IntTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/IntTypeHelper.java
new file mode 100644
index 0000000000..e903b59e50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/IntTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IntTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_long();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_long((Integer)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/LongTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/LongTypeHelper.java
new file mode 100644
index 0000000000..79d3c0cbc8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/LongTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LongTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_longlong();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_longlong((Long)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ReferenceTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ReferenceTypeHelper.java
new file mode 100644
index 0000000000..c89a25401d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ReferenceTypeHelper.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.reference.InterfaceInstanceCreator;
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTypeHelper implements TypeHelper {
+
+ public java.lang.Object read(TypeTreeNode node, InputStream is) {
+ Object reference = is.read_Object();
+ return (java.lang.Object)InterfaceInstanceCreator.createInstance(reference, node.getJavaClass());
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, java.lang.Object data) {
+ os.write_Object((Object)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/SequenceTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/SequenceTypeHelper.java
new file mode 100644
index 0000000000..911c787b11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/SequenceTypeHelper.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.binding.corba.provider.types.util;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SequenceTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ Object sequence = null;
+ try {
+ int size = is.read_long();
+ sequence = Array.newInstance(node.getChildren()[0].getJavaClass(), size);
+ for (int i = 0; i < size; i++) {
+ Array.set(sequence, i, TypeHelpersProxy.read(node.getChildren()[0], is));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return sequence;
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ int sum = 0;
+ // determine length of array
+ List<Object> array = new ArrayList<Object>();
+ while (true) {
+ try {
+ array.add(Array.get(data, sum));
+ sum++;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ break;
+ }
+ }
+ os.write_long(sum);
+ Iterator<Object> iter = array.iterator();
+ while (iter.hasNext()) {
+ Object elem = iter.next();
+ TypeHelpersProxy.write(node.getChildren()[0], os, elem);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ShortTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ShortTypeHelper.java
new file mode 100644
index 0000000000..f4cdabc8e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ShortTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ShortTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_short();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_short((Short)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StringTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StringTypeHelper.java
new file mode 100644
index 0000000000..5a4fcba221
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StringTypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StringTypeHelper implements TypeHelper {
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ return is.read_string();
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ os.write_string((String)data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StructTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StructTypeHelper.java
new file mode 100644
index 0000000000..1fc729b926
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StructTypeHelper.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.types.util;
+
+import java.lang.reflect.Field;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StructTypeHelper implements TypeHelper {
+
+ private static final Logger logger = Logger.getLogger(StructTypeHelper.class.getName());
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ TypeTreeNode[] children = node.getChildren();
+ Object result = null;
+ if (children != null) {
+ try {
+ result = node.getJavaClass().newInstance();
+ for (int i = 0; i < children.length; i++) {
+ Object childResult = TypeHelpersProxy.read(children[i], is);
+ Field childField = result.getClass().getField(children[i].getName());
+ childField.set(result, childResult);
+ }
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during reading CORBA struct data", e);
+ }
+ }
+ return result;
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ TypeTreeNode[] children = node.getChildren();
+ if (children != null) {
+ try {
+ for (int i = 0; i < children.length; i++) {
+ Field childField = node.getJavaClass().getField(children[i].getName());
+ TypeHelpersProxy.write(children[i], os, childField.get(data));
+ }
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during writing CORBA struct data", e);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelper.java
new file mode 100644
index 0000000000..0f1f973f49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelper.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.sca.binding.corba.provider.types.util;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TypeHelper {
+
+ /**
+ * Reads CORBA object
+ * @param node
+ * @param is
+ * @return
+ */
+ Object read(TypeTreeNode node, InputStream is);
+
+ /**
+ * Writes CORBA object
+ * @param node
+ * @param os
+ * @param data
+ */
+ void write(TypeTreeNode node, OutputStream os, Object data);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelpersProxy.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelpersProxy.java
new file mode 100644
index 0000000000..ded82bf12e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelpersProxy.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider.types.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.NodeType;
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ * Proxies getType(), write(), read() methods to appropriate TypeHelper implementation.
+ */
+public class TypeHelpersProxy {
+
+ /**
+ * Maps primitive types to its TypeHelper implementations
+ */
+ private static Map<Class<?>, TypeHelper> primitiveTypes = null;
+
+ /**
+ * Maps other types to its TypeHelper implementations
+ */
+ private static Map<NodeType, TypeHelper> complexTypes = null;
+
+ static {
+ // initiate type helpers
+ primitiveTypes = new HashMap<Class<?>, TypeHelper>();
+ complexTypes = new HashMap<NodeType, TypeHelper>();
+
+ primitiveTypes.put(boolean.class, new BooleanTypeHelper());
+ primitiveTypes.put(char.class, new CharTypeHelper());
+ primitiveTypes.put(byte.class, new ByteTypeHelper());
+ primitiveTypes.put(short.class, new ShortTypeHelper());
+ primitiveTypes.put(int.class, new IntTypeHelper());
+ primitiveTypes.put(long.class, new LongTypeHelper());
+ primitiveTypes.put(float.class, new FloatTypeHelper());
+ primitiveTypes.put(double.class, new DoubleTypeHelper());
+ primitiveTypes.put(String.class, new StringTypeHelper());
+ primitiveTypes.put(Boolean.class, primitiveTypes.get(boolean.class));
+ primitiveTypes.put(Character.class, primitiveTypes.get(char.class));
+ primitiveTypes.put(Byte.class, primitiveTypes.get(byte.class));
+ primitiveTypes.put(Short.class, primitiveTypes.get(short.class));
+ primitiveTypes.put(Integer.class, primitiveTypes.get(int.class));
+ primitiveTypes.put(Long.class, primitiveTypes.get(long.class));
+ primitiveTypes.put(Float.class, primitiveTypes.get(float.class));
+ primitiveTypes.put(Double.class, primitiveTypes.get(double.class));
+ primitiveTypes.put(String.class, primitiveTypes.get(String.class));
+ complexTypes.put(NodeType.array, new ArrayTypeHelper());
+ complexTypes.put(NodeType.struct, new StructTypeHelper());
+ complexTypes.put(NodeType.reference, new ReferenceTypeHelper());
+ complexTypes.put(NodeType.sequence, new SequenceTypeHelper());
+ complexTypes.put(NodeType.idl_enum, new EnumTypeHelper());
+ complexTypes.put(NodeType.exception, new StructTypeHelper());
+ complexTypes.put(NodeType.union, new UnionTypeHelper());
+ }
+
+ /**
+ * Gets type helper basing on given type
+ *
+ * @param node
+ * @return
+ */
+ private static TypeHelper getTypeHelper(TypeTreeNode node) {
+ TypeHelper typeHelper = null;
+ NodeType type = node.getNodeType();
+ if (type.equals(NodeType.primitive)) {
+ typeHelper = primitiveTypes.get(node.getJavaClass());
+ } else {
+ typeHelper = complexTypes.get(type);
+ }
+ return typeHelper;
+ }
+
+ /**
+ * Proxies read method invocation to appropriate TypeHelper implementation.
+ *
+ * @param node
+ * @param is
+ * @return
+ */
+ public static final Object read(TypeTreeNode node, InputStream is) {
+ TypeHelper helper = getTypeHelper(node);
+ return helper.read(node, is);
+ }
+
+ /**
+ * Proxies write method invocation to appropriate TypeHelper implementation.
+ *
+ * @param node
+ * @param os
+ * @param data
+ */
+ public static final void write(TypeTreeNode node, OutputStream os, Object data) {
+ TypeHelper helper = getTypeHelper(node);
+ helper.write(node, os, data);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/UnionTypeHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/UnionTypeHelper.java
new file mode 100644
index 0000000000..df2e833fcd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/UnionTypeHelper.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider.types.util;
+
+import java.lang.reflect.Field;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode;
+import org.apache.tuscany.sca.binding.corba.provider.types.UnionAttributes;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UnionTypeHelper implements TypeHelper {
+
+ private static final Logger logger = Logger.getLogger(UnionTypeHelper.class.getName());
+
+ public Object read(TypeTreeNode node, InputStream is) {
+ Object result = null;
+ try {
+ int discriminator = is.read_long();
+ UnionAttributes attrs = (UnionAttributes)node.getAttributes();
+ String childName = attrs.getOptionsMapping().get(discriminator);
+ if (childName == null) {
+ // get default if option numbers field not found
+ childName = attrs.getDefaultOptionName();
+ }
+ result = node.getJavaClass().newInstance();
+ Field discField = result.getClass().getDeclaredField(attrs.getDiscriminatorName());
+ discField.setAccessible(true);
+ discField.set(result, discriminator);
+ for (int i = 0; i < node.getChildren().length; i++) {
+ if (node.getChildren()[i].getName().equals(childName)) {
+ Object unionValue = TypeHelpersProxy.read(node.getChildren()[i], is);
+ Field childField = result.getClass().getDeclaredField(childName);
+ childField.setAccessible(true);
+ childField.set(result, unionValue);
+ break;
+ }
+ }
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during reading CORBA union data", e);
+ }
+ return result;
+ }
+
+ public void write(TypeTreeNode node, OutputStream os, Object data) {
+ try {
+ UnionAttributes attrs = (UnionAttributes)node.getAttributes();
+ Field discriminatorField = data.getClass().getDeclaredField(attrs.getDiscriminatorName());
+ discriminatorField.setAccessible(true);
+ int discriminator = discriminatorField.getInt(data);
+ os.write_long(discriminator);
+ String childName = attrs.getOptionsMapping().get(discriminator);
+ if (childName == null) {
+ // get default if option numbers field not found
+ childName = attrs.getDefaultOptionName();
+ }
+ for (int i = 0; i < node.getChildren().length; i++) {
+ if (node.getChildren()[i].getName().equals(childName)) {
+ Field childField = data.getClass().getDeclaredField(childName);
+ childField.setAccessible(true);
+ TypeHelpersProxy.write(node.getChildren()[i], os, childField.get(data));
+ break;
+ }
+ }
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception during writing CORBA union data", e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/Utils.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/Utils.java
new file mode 100644
index 0000000000..7ccd70f69e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/Utils.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.provider.types.util;
+
+/**
+ * @version $Rev$ $Date$
+ * Class for type utilities
+ */
+public class Utils {
+
+ /**
+ * Creates CORBA id for Java class
+ * @param forClass
+ * @return
+ */
+ public static String getTypeId(Class<?> forClass) {
+ String result = forClass.getName().replace('.', '/');
+ result = result.replaceAll("Package", "");
+ result = "IDL:" + result + ":1.0";
+ return result;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/MethodFinder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/MethodFinder.java
new file mode 100644
index 0000000000..f9facac0cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/MethodFinder.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.util;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ * Utility for finding method in given class.
+ */
+public class MethodFinder {
+
+ private static Map<Class<?>, Class<?>> boxingMapping;
+
+ static {
+ boxingMapping = new HashMap<Class<?>, Class<?>>();
+ boxingMapping.put(boolean.class, Boolean.class);
+ boxingMapping.put(byte.class, Byte.class);
+ boxingMapping.put(short.class, Short.class);
+ boxingMapping.put(char.class, Character.class);
+ boxingMapping.put(int.class, Integer.class);
+ boxingMapping.put(long.class, Long.class);
+ boxingMapping.put(float.class, Float.class);
+ boxingMapping.put(double.class, Double.class);
+ }
+
+ /**
+ * Converts primitive class to its object equivalent.
+ *
+ * @param parameter class to convert
+ * @return object equivalent for primitive type. If parameter wasn't
+ * primitive then returns parameter.
+ */
+ private static Class<?> normalizePrimitive(Class<?> parameter) {
+ Class<?> result = boxingMapping.get(parameter);
+ if (result != null) {
+ return result;
+ } else {
+ // not a primitive - no need to normalize
+ return parameter;
+ }
+ }
+
+ /**
+ * Finds appropriate method. This method ignores difference between
+ * primitive types and theirs object equivalents. Ie. if we want to find
+ * method "get" in java.util.List with only one parameter, which type is
+ * Integer then we'll obtain method get(int).
+ *
+ * @param forClass class which possibly contains desired method
+ * @param methodName desired methods name
+ * @param parameterTypes desired methods parameter types
+ * @return desired method, if no method was found then null will be returned
+ */
+ public static Method findMethod(Class<?> forClass, String methodName, Class<?>[] parameterTypes) {
+ Method[] methods = forClass.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(methodName)) {
+ Class<?>[] methodPTypes = methods[i].getParameterTypes();
+ if (methodPTypes.length == parameterTypes.length) {
+ boolean parameterMatch = true;
+ for (int j = 0; j < methodPTypes.length; j++) {
+ Class<?> nMethodPType = normalizePrimitive(methodPTypes[j]);
+ Class<?> nParameterType = normalizePrimitive(parameterTypes[j]);
+ if (!nMethodPType.equals(nParameterType)) {
+ parameterMatch = false;
+ break;
+ }
+ }
+ if (parameterMatch) {
+ return methods[i];
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/OperationMapper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/OperationMapper.java
new file mode 100644
index 0000000000..414e50abf4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/OperationMapper.java
@@ -0,0 +1,578 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.provider.util;
+
+import java.lang.reflect.Method;
+import java.rmi.RemoteException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class OperationMapper {
+
+ private static Set<Class<?>> getAllInterfaces(Class<?> intfClass) {
+ Set<Class<?>> allInterfaces = new LinkedHashSet<Class<?>>();
+
+ LinkedList<Class<?>> stack = new LinkedList<Class<?>>();
+ stack.addFirst(intfClass);
+
+ while (!stack.isEmpty()) {
+ Class<?> intf = stack.removeFirst();
+ allInterfaces.add(intf);
+ for (Class<?> i : intf.getInterfaces()) {
+ stack.add(0, i);
+ }
+ }
+
+ return allInterfaces;
+ }
+
+ /**
+ * Maps Java methods to operation names
+ * @param intfClass
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static Map<Method, String> mapMethodToOperationName(Class<?> intfClass) {
+ return iiopMap(intfClass, false);
+ }
+
+ /**
+ * Maps operation names to Java methods
+ * @param intfClass
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static Map<String, Method> mapOperationNameToMethod(Class<?> intfClass) {
+ return iiopMap(intfClass, true);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Map iiopMap(Class<?> intfClass, boolean operationToMethod) {
+ Method[] methods = getAllMethods(intfClass);
+
+ // find every valid getter
+ Map<Method, String> getterByMethod = new HashMap<Method, String>(methods.length);
+ Map<String, Method> getterByName = new HashMap<String, Method>(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String methodName = method.getName();
+
+ // no arguments allowed
+ if (method.getParameterTypes().length != 0) {
+ continue;
+ }
+
+ // must start with get or is
+ String verb;
+ if (methodName.startsWith("get") && methodName.length() > 3 && method.getReturnType() != void.class) {
+ verb = "get";
+ } else if (methodName.startsWith("is") && methodName.length() > 2 && method.getReturnType() == boolean.class) {
+ verb = "is";
+ } else {
+ continue;
+ }
+
+ // must only throw Remote or Runtime Exceptions
+ boolean exceptionsValid = true;
+ Class[] exceptionTypes = method.getExceptionTypes();
+ for (int j = 0; j < exceptionTypes.length; j++) {
+ Class<?> exceptionType = exceptionTypes[j];
+ if (!RemoteException.class.isAssignableFrom(exceptionType) &&
+ !RuntimeException.class.isAssignableFrom(exceptionType) &&
+ !Error.class.isAssignableFrom(exceptionType)) {
+ exceptionsValid = false;
+ break;
+ }
+ }
+ if (!exceptionsValid) {
+ continue;
+ }
+
+ String propertyName;
+ if (methodName.length() > verb.length() + 1 && Character.isUpperCase(methodName.charAt(verb.length() + 1))) {
+ propertyName = methodName.substring(verb.length());
+ } else {
+ propertyName = Character.toLowerCase(methodName.charAt(verb.length())) + methodName.substring(verb.length() + 1);
+ }
+ getterByMethod.put(method, propertyName);
+ getterByName.put(propertyName, method);
+ }
+
+ Map<Method, String> setterByMethod = new HashMap<Method, String>(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String methodName = method.getName();
+
+ // must have exactally one arg
+ if (method.getParameterTypes().length != 1) {
+ continue;
+ }
+
+ // must return non void
+ if (method.getReturnType() != void.class) {
+ continue;
+ }
+
+ // must start with set
+ if (!methodName.startsWith("set") || methodName.length() <= 3) {
+ continue;
+ }
+
+ // must only throw Remote or Runtime Exceptions
+ boolean exceptionsValid = true;
+ Class<?>[] exceptionTypes = method.getExceptionTypes();
+ for (int j = 0; j < exceptionTypes.length; j++) {
+ Class<?> exceptionType = exceptionTypes[j];
+ if (!RemoteException.class.isAssignableFrom(exceptionType) &&
+ !RuntimeException.class.isAssignableFrom(exceptionType) &&
+ !Error.class.isAssignableFrom(exceptionType)) {
+ exceptionsValid = false;
+ break;
+ }
+ }
+ if (!exceptionsValid) {
+ continue;
+ }
+
+ String propertyName;
+ if (methodName.length() > 4 && Character.isUpperCase(methodName.charAt(4))) {
+ propertyName = methodName.substring(3);
+ } else {
+ propertyName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
+ }
+
+ // must have a matching getter
+ Method getter = (Method) getterByName.get(propertyName);
+ if (getter == null) {
+ continue;
+ }
+
+ // setter property must match getter return value
+ if (!method.getParameterTypes()[0].equals(getter.getReturnType())) {
+ continue;
+ }
+ setterByMethod.put(method, propertyName);
+ }
+
+ // index the methods by name... used to determine which methods are overloaded
+ HashMap<String, List<Method>> overloadedMethods = new HashMap<String, List<Method>>(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (getterByMethod.containsKey(method) || setterByMethod.containsKey(method)) {
+ continue;
+ }
+ String methodName = method.getName();
+ List<Method> methodList = overloadedMethods.get(methodName);
+ if (methodList == null) {
+ methodList = new LinkedList<Method>();
+ overloadedMethods.put(methodName, methodList);
+ }
+ methodList.add(method);
+ }
+
+ // index the methods by lower case name... used to determine which methods differ only by case
+ Map<String, Set<String>> caseCollisionMethods = new HashMap<String, Set<String>>(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (getterByMethod.containsKey(method) || setterByMethod.containsKey(method)) {
+ continue;
+ }
+ String lowerCaseMethodName = method.getName().toLowerCase();
+ Set<String> methodSet = caseCollisionMethods.get(lowerCaseMethodName);
+ if (methodSet == null) {
+ methodSet = new HashSet<String>();
+ caseCollisionMethods.put(lowerCaseMethodName, methodSet);
+ }
+ methodSet.add(method.getName());
+ }
+
+ String className = getClassName(intfClass);
+ Map iiopMap = new HashMap(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+
+ String iiopName = (String) getterByMethod.get(method);
+ if (iiopName != null) {
+ // if we have a leading underscore prepend with J
+ if (iiopName.charAt(0) == '_') {
+ iiopName = "J_get_" + iiopName.substring(1);
+ } else {
+ iiopName = "_get_" + iiopName;
+ }
+ } else {
+ iiopName = (String) setterByMethod.get(method);
+ if (iiopName != null) {
+ // if we have a leading underscore prepend with J
+ if (iiopName.charAt(0) == '_') {
+ iiopName = "J_set_" + iiopName.substring(1);
+ } else {
+ iiopName = "_set_" + iiopName;
+ }
+ } else {
+ iiopName = method.getName();
+
+ // if we have a leading underscore prepend with J
+ if (iiopName.charAt(0) == '_') {
+ iiopName = "J" + iiopName;
+ }
+ }
+ }
+
+ // if this name only differs by case add the case index to the end
+ Set<String> caseCollisions = caseCollisionMethods.get(method.getName().toLowerCase());
+ if (caseCollisions != null && caseCollisions.size() > 1) {
+ iiopName += upperCaseIndexString(iiopName);
+ }
+
+ // if this is an overloaded method append the parameter string
+ List<Method> overloads = overloadedMethods.get(method.getName());
+ if (overloads != null && overloads.size() > 1) {
+ iiopName += buildOverloadParameterString(method.getParameterTypes());
+ }
+
+ // if we have a leading underscore prepend with J
+ iiopName = replace(iiopName, '$', "U0024");
+
+ // if we have matched a keyword prepend with an underscore
+ if (keywords.contains(iiopName.toLowerCase())) {
+ iiopName = "_" + iiopName;
+ }
+
+ // if the name is the same as the class name, append an underscore
+ if (iiopName.equalsIgnoreCase(className)) {
+ iiopName += "_";
+ }
+
+ if (operationToMethod) {
+ iiopMap.put(iiopName, method);
+ } else {
+ iiopMap.put(method, iiopName);
+ }
+ }
+
+ return iiopMap;
+ }
+
+ private static Method[] getAllMethods(Class<?> intfClass) {
+ List<Method> methods = new LinkedList<Method>();
+ for (Iterator<Class<?>> iterator = getAllInterfaces(intfClass).iterator(); iterator.hasNext();) {
+ Class<?> intf = iterator.next();
+ methods.addAll(Arrays.asList(intf.getDeclaredMethods()));
+ }
+
+ return (Method[]) methods.toArray(new Method[methods.size()]);
+ }
+
+ /**
+ * Return the a string containing an underscore '_' index of each uppercase
+ * character in the IIOP name. This is used for distinction of names that
+ * only differ by case, since CORBA does not support case sensitive names.
+ */
+ private static String upperCaseIndexString(String iiopName) {
+ StringBuffer stringBuffer = new StringBuffer();
+ for (int i = 0; i < iiopName.length(); i++) {
+ char c = iiopName.charAt(i);
+ if (Character.isUpperCase(c)) {
+ stringBuffer.append('_').append(i);
+ }
+ }
+ return stringBuffer.toString();
+ }
+
+ /**
+ * Replaces any occurances of the specified "oldChar" with the new string.
+ * This is used to replace occurances if '$' in CORBA names since '$' is a
+ * special character
+ */
+ private static String replace(String source, char oldChar, String newString) {
+ StringBuffer stringBuffer = new StringBuffer(source.length());
+ for (int i = 0; i < source.length(); i++) {
+ char c = source.charAt(i);
+ if (c == oldChar) {
+ stringBuffer.append(newString);
+ } else {
+ stringBuffer.append(c);
+ }
+ }
+ return stringBuffer.toString();
+ }
+
+ /**
+ * Return the a string containing a double underscore '__' list of parameter
+ * types encoded using the Java to IDL rules. This is used for distinction
+ * of methods that only differ by parameter lists.
+ */
+ private static String buildOverloadParameterString(Class<?>[] parameterTypes) {
+ String name = "";
+ if (parameterTypes.length == 0) {
+ name += "__";
+ } else {
+ for (int i = 0; i < parameterTypes.length; i++) {
+ Class<?> parameterType = parameterTypes[i];
+ name += buildOverloadParameterString(parameterType);
+ }
+ }
+ return name.replace('.', '_');
+ }
+
+ /**
+ * Returns a single parameter type encoded using the Java to IDL rules.
+ */
+ private static String buildOverloadParameterString(Class<?> parameterType) {
+ String name = "_";
+
+ int arrayDimensions = 0;
+ while (parameterType.isArray()) {
+ arrayDimensions++;
+ parameterType = parameterType.getComponentType();
+ }
+
+ // arrays start with org_omg_boxedRMI_
+ if (arrayDimensions > 0) {
+ name += "_org_omg_boxedRMI";
+ }
+
+ // IDLEntity types must be prefixed with org_omg_boxedIDL_
+ if (IDLEntity.class.isAssignableFrom(parameterType)) {
+ name += "_org_omg_boxedIDL";
+ }
+
+ // add package... some types have special mappings in corba
+ String packageName = (String)specialTypePackages.get(parameterType.getName());
+ if (packageName == null) {
+ packageName = getPackageName(parameterType.getName());
+ }
+ if (packageName.length() > 0) {
+ name += "_" + packageName;
+ }
+
+ // arrays now contain a dimension indicator
+ if (arrayDimensions > 0) {
+ name += "_" + "seq" + arrayDimensions;
+ }
+
+ // add the class name
+ String className = (String)specialTypeNames.get(parameterType.getName());
+ if (className == null) {
+ className = buildClassName(parameterType);
+ }
+ name += "_" + className;
+
+ return name;
+ }
+
+ /**
+ * Returns a string containing an encoded class name.
+ */
+ private static String buildClassName(Class<?> type) {
+ if (type.isArray()) {
+ throw new IllegalArgumentException("type is an array: " + type);
+ }
+
+ // get the classname
+ String typeName = type.getName();
+ int endIndex = typeName.lastIndexOf('.');
+ if (endIndex < 0) {
+ return typeName;
+ }
+ StringBuffer className = new StringBuffer(typeName.substring(endIndex + 1));
+
+ // for innerclasses replace the $ separator with two underscores
+ // we can't just blindly replace all $ characters since class names can
+ // contain the $ character
+ if (type.getDeclaringClass() != null) {
+ String declaringClassName = getClassName(type.getDeclaringClass());
+ assert className.toString().startsWith(declaringClassName + "$");
+ className.replace(declaringClassName.length(), declaringClassName.length() + 1, "__");
+ }
+
+ // if we have a leading underscore prepend with J
+ if (className.charAt(0) == '_') {
+ className.insert(0, "J");
+ }
+ return className.toString();
+ }
+
+ private static String getClassName(Class<?> type) {
+ if (type.isArray()) {
+ throw new IllegalArgumentException("type is an array: " + type);
+ }
+
+ // get the classname
+ String typeName = type.getName();
+ int endIndex = typeName.lastIndexOf('.');
+ if (endIndex < 0) {
+ return typeName;
+ }
+ return typeName.substring(endIndex + 1);
+ }
+
+ private static String getPackageName(String interfaceName) {
+ int endIndex = interfaceName.lastIndexOf('.');
+ if (endIndex < 0) {
+ return "";
+ }
+ return interfaceName.substring(0, endIndex);
+ }
+
+ private static final Map<String, String> specialTypeNames;
+ private static final Map<String, String> specialTypePackages;
+ private static final Set<String> keywords;
+
+ static {
+ specialTypeNames = new HashMap<String, String>();
+ specialTypeNames.put("boolean", "boolean");
+ specialTypeNames.put("char", "wchar");
+ specialTypeNames.put("byte", "octet");
+ specialTypeNames.put("short", "short");
+ specialTypeNames.put("int", "long");
+ specialTypeNames.put("long", "long_long");
+ specialTypeNames.put("float", "float");
+ specialTypeNames.put("double", "double");
+ specialTypeNames.put("java.lang.Class", "ClassDesc");
+ specialTypeNames.put("java.lang.String", "WStringValue");
+ specialTypeNames.put("org.omg.CORBA.Object", "Object");
+
+ specialTypePackages = new HashMap<String, String>();
+ specialTypePackages.put("boolean", "");
+ specialTypePackages.put("char", "");
+ specialTypePackages.put("byte", "");
+ specialTypePackages.put("short", "");
+ specialTypePackages.put("int", "");
+ specialTypePackages.put("long", "");
+ specialTypePackages.put("float", "");
+ specialTypePackages.put("double", "");
+ specialTypePackages.put("java.lang.Class", "javax.rmi.CORBA");
+ specialTypePackages.put("java.lang.String", "CORBA");
+ specialTypePackages.put("org.omg.CORBA.Object", "");
+
+ keywords = new HashSet<String>();
+ keywords.add("abstract");
+ keywords.add("any");
+ keywords.add("attribute");
+ keywords.add("boolean");
+ keywords.add("case");
+ keywords.add("char");
+ keywords.add("const");
+ keywords.add("context");
+ keywords.add("custom");
+ keywords.add("default");
+ keywords.add("double");
+ keywords.add("enum");
+ keywords.add("exception");
+ keywords.add("factory");
+ keywords.add("false");
+ keywords.add("fixed");
+ keywords.add("float");
+ keywords.add("in");
+ keywords.add("inout");
+ keywords.add("interface");
+ keywords.add("long");
+ keywords.add("module");
+ keywords.add("native");
+ keywords.add("object");
+ keywords.add("octet");
+ keywords.add("oneway");
+ keywords.add("out");
+ keywords.add("private");
+ keywords.add("public");
+ keywords.add("raises");
+ keywords.add("readonly");
+ keywords.add("sequence");
+ keywords.add("short");
+ keywords.add("string");
+ keywords.add("struct");
+ keywords.add("supports");
+ keywords.add("switch");
+ keywords.add("true");
+ keywords.add("truncatable");
+ keywords.add("typedef");
+ keywords.add("union");
+ keywords.add("unsigned");
+ keywords.add("valuebase");
+ keywords.add("valuetype");
+ keywords.add("void");
+ keywords.add("wchar");
+ keywords.add("wstring");
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<Operation, Method> mapOperationToMethod(List<Operation> operations, Class<?> forClass) {
+ return (Map<Operation, Method>)createMethod2OperationMapping(operations, forClass, false);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<Method, Operation> mapMethodToOperation(List<Operation> operations, Class<?> forClass) {
+ return (Map<Method, Operation>)createMethod2OperationMapping(operations, forClass, true);
+ }
+
+ /**
+ * Maps Java methods to Tuscany operations
+ */
+ @SuppressWarnings("unchecked")
+ private static Map createMethod2OperationMapping(List<Operation> operations, Class<?> forClass, boolean method2operation) {
+ // for every operation find all methods with the same name, then
+ // compare operations and methods parameters
+ Map mapping = new HashMap();
+ for (Operation operation : operations) {
+ List<DataType> inputTypes = operation.getInputType().getLogical();
+ Method[] methods = forClass.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(operation.getName()) && inputTypes.size() == methods[i]
+ .getParameterTypes().length) {
+ Class<?>[] parameterTypes = methods[i].getParameterTypes();
+ int j = 0;
+ boolean parameterMatch = true;
+ for (DataType dataType : inputTypes) {
+ if (!dataType.getPhysical().equals(parameterTypes[j])) {
+ parameterMatch = false;
+ break;
+ }
+ j++;
+ }
+ if (parameterMatch) {
+ // match found
+ if (method2operation) {
+ mapping.put(methods[i], operation);
+ } else {
+ mapping.put(operation, methods[i]);
+ }
+ break;
+ }
+ }
+ }
+ }
+ return mapping;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..9855dec8af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.corba.provider.CorbaBindingProviderFactory;model=org.apache.tuscany.sca.binding.corba.CorbaBinding
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java
new file mode 100644
index 0000000000..f1025e0693
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java
@@ -0,0 +1,565 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing;
+
+import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Array;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.CorbaException;
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException;
+import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaRequest;
+import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaResponse;
+import org.apache.tuscany.sca.binding.corba.provider.service.ComponentInvocationProxy;
+import org.apache.tuscany.sca.binding.corba.provider.service.DynaCorbaServant;
+import org.apache.tuscany.sca.binding.corba.provider.service.InvocationProxy;
+import org.apache.tuscany.sca.binding.corba.provider.types.util.Utils;
+import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests;
+import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper;
+import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct;
+import org.apache.tuscany.sca.binding.corba.testing.enums.Color;
+import org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager;
+import org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported;
+import org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter;
+import org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper;
+import org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter;
+import org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper;
+import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct;
+import org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct;
+import org.apache.tuscany.sca.binding.corba.testing.generated.TestObject;
+import org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.NonCorbaException;
+import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysSetterServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsTuscanyServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.CalcServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.EnumManagerServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.InvalidTestObjectServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.InvalidTypesServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.NonCorbaServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.PrimitivesSetterServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.TestObjectServant;
+import org.apache.tuscany.sca.binding.corba.testing.service.mocks.TestRuntimeComponentService;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextHelper;
+
+/**
+ * @version $Rev$ $Date$
+ * Tests API for dynamic CORBA servants
+ */
+public class CorbaServantTestCase {
+
+ private static ORB orb;
+ private static TransientNameServer server;
+
+ @BeforeClass
+ public static void start() {
+ try {
+ server =
+ new TransientNameServer(TestConstants.TEST2_HOST, TestConstants.TEST2_PORT,
+ TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ Assert.fail("The naming server cannot be started");
+ }
+ orb = server.getORB();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void stop() {
+ server.stop();
+ }
+
+ /**
+ * Binds servant implementation to name
+ */
+ private void bindServant(DynaCorbaServant servant, String name) {
+ try {
+ Object nameService = orb.resolve_initial_references("NameService");
+ NamingContext namingContext = NamingContextHelper.narrow(nameService);
+
+ NameComponent nc = new NameComponent(name, "");
+ NameComponent[] path = new NameComponent[] {nc};
+ namingContext.rebind(path, servant);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Returns object reference which is binded to given name
+ *
+ * @param name
+ * @return
+ */
+ private org.omg.CORBA.Object bindReference(String name) {
+ try {
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
+ NamingContext ncRef = NamingContextHelper.narrow(objRef);
+ NameComponent nc = new NameComponent(name, "");
+ NameComponent path[] = {nc};
+ return ncRef.resolve(path);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Tests primitives (arguments, return types)
+ */
+ @Test
+ public void test_primitivesSetter() {
+ try {
+ PrimitivesSetter primitivesSetter = new PrimitivesSetterServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(primitivesSetter);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids =
+ new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "PrimitivesSetter");
+ PrimitivesSetter psClient = PrimitivesSetterHelper.narrow(bindReference("PrimitivesSetter"));
+ assertTrue(psClient.setBoolean(true) == true);
+ assertTrue(psClient.setChar('A') == 'A');
+ assertTrue(psClient.setString("SomeTest").equals("SomeTest"));
+ assertTrue(psClient.setDouble(2d) == 2d);
+ assertTrue(psClient.setFloat(3f) == 3f);
+ assertTrue(psClient.setLong(1) == 1);
+ assertTrue(psClient.setLongLong(0L) == 0L);
+ assertTrue(psClient.setOctet((byte)8) == (byte)8);
+ assertTrue(psClient.setShort((short)6) == (short)6);
+ assertTrue(psClient.setUnsignedLong(9) == 9);
+ assertTrue(psClient.setUnsignedLongLong(11L) == 11L);
+ assertTrue(psClient.setUnsignedShort((short)15) == (short)15);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests if array values are equal
+ */
+ private boolean areArraysEqual(java.lang.Object arr1, java.lang.Object arr2, int arrLen) {
+ try {
+ for (int i = 0; i < arrLen; i++) {
+ if (!Array.get(arr1, i).equals(Array.get(arr2, i))) {
+ return false;
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * Tests arrays (arguments, return types)
+ */
+ @Test
+ public void test_arraysSetter() {
+ try {
+ ArraysSetter arraysSetter = new ArraysSetterServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(arraysSetter);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter:1.0"};
+ servant.setIds(ids);
+ java.lang.Object result = null;
+ bindServant(servant, "ArraysSetter");
+ ArraysSetter asClient = ArraysSetterHelper.narrow(bindReference("ArraysSetter"));
+
+ boolean[] bArr = new boolean[] {true, false};
+ result = (java.lang.Object)asClient.setBoolean(bArr);
+ assertTrue(areArraysEqual(bArr, result, bArr.length));
+
+ byte[] byArr = new byte[] {1, 2};
+ result = (java.lang.Object)asClient.setOctet(byArr);
+ assertTrue(areArraysEqual(byArr, result, byArr.length));
+
+ short[] shArr = new short[] {1, 2};
+ result = (java.lang.Object)asClient.setShort(shArr);
+ assertTrue(areArraysEqual(shArr, result, shArr.length));
+
+ int[] iArr = new int[] {1, 2};
+ result = (java.lang.Object)asClient.setLong(iArr);
+ assertTrue(areArraysEqual(iArr, result, iArr.length));
+
+ long[] lArr = new long[] {1, 2};
+ result = (java.lang.Object)asClient.setLongLong(lArr);
+ assertTrue(areArraysEqual(lArr, result, lArr.length));
+
+ String[] strArr = new String[] {"Some", "Test"};
+ result = (java.lang.Object)asClient.setString(strArr);
+ assertTrue(areArraysEqual(strArr, result, strArr.length));
+
+ char[] chArr = new char[] {'A', 'B'};
+ result = (java.lang.Object)asClient.setChar(chArr);
+ assertTrue(areArraysEqual(chArr, result, chArr.length));
+
+ float[] flArr = new float[] {1, 2};
+ result = (java.lang.Object)asClient.setFloat(flArr);
+ assertTrue(areArraysEqual(flArr, result, flArr.length));
+
+ double[] dbArr = new double[] {1, 2};
+ result = (java.lang.Object)asClient.setDouble(dbArr);
+ assertTrue(areArraysEqual(dbArr, result, dbArr.length));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests structures (arguments, return types)
+ */
+ @Test
+ public void test_TestObject_setStruct() {
+ try {
+ TestObject to = new TestObjectServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(to);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "TestObject");
+ TestObject testObject = TestObjectHelper.narrow(bindReference("TestObject"));
+ SomeStruct ss = new SomeStruct();
+ SimpleStruct inner = new SimpleStruct();
+ inner.field1 = TestConstants.STR_1;
+ inner.field2 = TestConstants.INT_1;
+ ss.innerStruct = inner;
+ ss.str = TestConstants.STR_2;
+ ss.str_list = TestConstants.STR_ARR_1;
+ ss.threeDimSeq = TestConstants.INT_ARRAY_3_DIM;
+ ss.twoDimSeq = TestConstants.INT_ARRAY_2_DIM;
+ SomeStruct result = testObject.setStruct(ss);
+ assertTrue(TestConstants.are2DimArraysEqual(result.twoDimSeq, TestConstants.INT_ARRAY_2_DIM));
+ assertTrue(TestConstants.are3DimArraysEqual(result.threeDimSeq, TestConstants.INT_ARRAY_3_DIM));
+ assertTrue(result.str.equals(ss.str));
+ assertTrue(result.innerStruct.field1.equals(ss.innerStruct.field1));
+ assertTrue(result.innerStruct.field2 == ss.innerStruct.field2);
+ assertTrue(areArraysEqual(result.str_list, ss.str_list, ss.str_list.length));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests handling BAD_OPERATION system exception
+ */
+ @Test
+ public void test_systemException_BAD_OPERATION() {
+ try {
+ TestObjectServant tos = new TestObjectServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(tos);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "TestObject");
+ DynaCorbaRequest request =
+ new DynaCorbaRequest(bindReference("TestObject"), "methodThatSurelyDoesNotExist");
+ request.invoke();
+ fail();
+ } catch (Exception e) {
+ if (e instanceof CorbaException) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ }
+ }
+
+ try {
+ InvalidTestObjectServant tos = new InvalidTestObjectServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(tos);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "InvalidTestObject");
+ TestObject to = TestObjectHelper.narrow(bindReference("InvalidTestObject"));
+ SomeStruct str = new SomeStruct();
+ str.innerStruct = new SimpleStruct();
+ str.innerStruct.field1 = "Whatever";
+ str.str = "Whatever";
+ str.str_list = new String[] {};
+ str.threeDimSeq = new int[][][] {};
+ str.twoDimSeq = new int[][] {};
+ to.setStruct(str);
+ } catch (Exception e) {
+ if (e instanceof BAD_OPERATION) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Tests handling user exceptions
+ */
+ @Test
+ public void test_userExceptions() {
+ try {
+ CalcServant calc = new CalcServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "Calc");
+ Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
+ calcClient.div(1, 0);
+ fail();
+ } catch (Exception e) {
+ if (e instanceof DivByZero) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ try {
+ CalcServant calc = new CalcServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "Calc");
+ Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
+ calcClient.divForSmallArgs(255, 255);
+ fail();
+ } catch (Exception e) {
+ if (e instanceof NotSupported) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ }
+
+ /**
+ * Tests enums (arguments, return types)
+ */
+ @Test
+ public void test_enums() {
+ try {
+ EnumManagerServant ems = new EnumManagerServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(ems);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "Enum");
+ EnumManager em = EnumManagerHelper.narrow(bindReference("Enum"));
+ Color color = Color.red;
+ assertTrue(em.getColor(color).value() == color.value());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ @Test
+ public void test_nonCorbaServants() {
+ try {
+ NonCorbaServant ncs = new NonCorbaServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(ncs);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ bindServant(servant, "NonCorbaServant");
+ // it's non corba servant so we don't have stubs to test them
+ DynaCorbaRequest request = new DynaCorbaRequest(bindReference("NonCorbaServant"), "setString");
+ request.addArgument(TestConstants.STR_1);
+ request.setOutputType(String.class);
+ DynaCorbaResponse response = request.invoke();
+ assertTrue(response.getContent().equals(TestConstants.STR_1));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ try {
+ NonCorbaServant ncs = new NonCorbaServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(ncs);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ bindServant(servant, "NonCorbaServant");
+ // it's non corba servant so we don't have stubs to test them
+ DynaCorbaRequest request = new DynaCorbaRequest(bindReference("NonCorbaServant"), "throwException");
+ request.addExceptionType(NonCorbaException.class);
+ request.invoke();
+ fail();
+ } catch (Exception e) {
+ if (e instanceof NonCorbaException) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ }
+
+ /**
+ * Tests handling BAD_PARAM system exception
+ */
+ @Test
+ public void test_systemException_BAD_PARAM() {
+ try {
+ CalcServant calc = new CalcServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "Calc");
+ DynaCorbaRequest request = new DynaCorbaRequest(bindReference("Calc"), "div");
+ request.addArgument(2d);
+ request.setOutputType(double.class);
+ request.invoke();
+ fail();
+ } catch (Exception e) {
+ if (e instanceof CorbaException) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ }
+
+ /**
+ * Tests handling BAD_PARAM system exception
+ */
+ @Test
+ public void test_invalidServantConfiguraion() {
+ try {
+ InvalidTypesServant its = new InvalidTypesServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(its);
+ //expecting exception...
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ fail();
+ } catch (Exception e) {
+ if (e instanceof RequestConfigurationException) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ }
+
+ /**
+ * Tests serving CORBA arrays by Tuscany CORBA servants
+ */
+ @Test
+ public void test_arraysPassing() {
+ try {
+ ArraysUnionsTuscanyServant arraysUnions = new ArraysUnionsTuscanyServant();
+ TestRuntimeComponentService service = new TestRuntimeComponentService(arraysUnions);
+ Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
+ InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
+ DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
+ String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0"};
+ servant.setIds(ids);
+ bindServant(servant, "ArraysUnions");
+ Object reference = bindReference("ArraysUnions");
+ ArraysUnionsTests objRef = ArraysUnionsTestsHelper.narrow(reference);
+ String[][] stringArray = {{"Hello", "World"}, {"Hi", "Again"}};
+ String[][] result = objRef.passStringArray(stringArray);
+ for (int i = 0; i < stringArray.length; i++) {
+ for (int j = 0; j < stringArray[i].length; j++) {
+ assertEquals(stringArray[i][j], result[i][j]);
+ }
+ }
+ TestStruct struct = new TestStruct();
+ String[] field1 = {"Hello", "World"};
+ int[][] field2 = { {4, 2, 2, 5}, {6, 12, 5, 8}};
+ float[][][] field3 = { { {2, 6}, {2, 7}, {9, 3}, {4, 6}}, { {3, 7}, {6, 6}, {3, 5}, {6, 2}}};
+ struct.oneDimArray = field1;
+ struct.twoDimArray = field2;
+ struct.threeDimArray = field3;
+
+ TestStruct structResult = objRef.passTestStruct(struct);
+ for (int i = 0; i < struct.oneDimArray.length; i++) {
+ assertEquals(struct.oneDimArray[i], structResult.oneDimArray[i]);
+ }
+ for (int i = 0; i < struct.twoDimArray.length; i++) {
+ for (int j = 0; j < struct.twoDimArray[i].length; j++) {
+ assertEquals(struct.twoDimArray[i][j], structResult.twoDimArray[i][j]);
+ }
+ }
+ for (int i = 0; i < struct.threeDimArray.length; i++) {
+ for (int j = 0; j < struct.threeDimArray[i].length; j++) {
+ for (int k = 0; k < struct.threeDimArray[i][j].length; k++) {
+ assertEquals(struct.threeDimArray[i][j][k], structResult.threeDimArray[i][j][k], 0.0);
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java
new file mode 100644
index 0000000000..1b1754f347
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java
@@ -0,0 +1,841 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.CorbaException;
+import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException;
+import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaRequest;
+import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaResponse;
+import org.apache.tuscany.sca.binding.corba.testing.enums.Color;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported;
+import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct;
+import org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.ArraysTestStruct;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.DummyObject;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InnerUnion;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidCorbaArray;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum1;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum2;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum3;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct1;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct2;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct3;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion1;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion2;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion3;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion4;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion5;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.RichUnion;
+import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysSetterServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsTuscanyServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.CalcServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.EnumManagerServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.ObjectManagerServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.PrimitivesSetterServant;
+import org.apache.tuscany.sca.binding.corba.testing.servants.TestObjectServant;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExt;
+import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CosNaming.NamingContextHelper;
+
+/**
+ * @version $Rev$ $Date$
+ * Tests API for dynamic CORBA requests. Tests handling various Java
+ * types.
+ */
+public class CorbaTypesTestCase {
+ private static TransientNameServer server;
+ private static ORB orb;
+
+ private static Object refPrimitivesSetter;
+ private static Object refArraysSetter;
+ private static Object refTestObject;
+ private static Object refCalcObject;
+ private static Object refObjectManager;
+ private static Object refEnumManager;
+ private static Object refArraysUnions;
+
+ /**
+ * Spawns tnameserv process (must be in PATH). Initializes test servants and
+ * stores it's references so tests can use it.
+ */
+ @BeforeClass
+ public static void setUp() {
+ try {
+ try {
+ server =
+ new TransientNameServer(TestConstants.TEST1_HOST, TestConstants.TEST1_PORT,
+ TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ Assert.fail("The naming server cannot be started");
+ }
+ orb = server.getORB();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+
+ Object nameService = orb.resolve_initial_references("NameService");
+ NamingContext namingContext = NamingContextHelper.narrow(nameService);
+
+ PrimitivesSetterServant singleSetter = new PrimitivesSetterServant();
+ ArraysSetterServant arraysSetter = new ArraysSetterServant();
+ TestObjectServant complexObject = new TestObjectServant();
+ CalcServant calcObject = new CalcServant();
+ ObjectManagerServant objectManager = new ObjectManagerServant();
+ EnumManagerServant enumManager = new EnumManagerServant();
+ ArraysUnionsServant arraysUnions = new ArraysUnionsServant();
+
+ orb.connect(singleSetter);
+ orb.connect(arraysSetter);
+
+ NameComponent nc;
+ NameComponent[] path;
+
+ nc = new NameComponent("PrimitivesSetter", "");
+ path = new NameComponent[] {nc};
+ namingContext.rebind(path, singleSetter);
+
+ nc = new NameComponent("ArraysSetter", "");
+ path = new NameComponent[] {nc};
+ namingContext.rebind(path, arraysSetter);
+
+ nc = new NameComponent("TestObject", "");
+ path = new NameComponent[] {nc};
+ namingContext.rebind(path, complexObject);
+
+ nc = new NameComponent("CalcObject", "");
+ path = new NameComponent[] {nc};
+ namingContext.rebind(path, calcObject);
+
+ nc = new NameComponent("ObjectManager", "");
+ path = new NameComponent[] {nc};
+ namingContext.rebind(path, objectManager);
+
+ nc = new NameComponent("EnumManager", "");
+ path = new NameComponent[] {nc};
+ namingContext.rebind(path, enumManager);
+
+ nc = new NameComponent("ArraysUnions", "");
+ path = new NameComponent[] {nc};
+ namingContext.rebind(path, arraysUnions);
+
+ NamingContextExt nce = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
+
+ refArraysSetter = nce.resolve(nce.to_name("ArraysSetter"));
+ refPrimitivesSetter = nce.resolve(nce.to_name("PrimitivesSetter"));
+ refTestObject = nce.resolve(nce.to_name("TestObject"));
+ refCalcObject = nce.resolve(nce.to_name("CalcObject"));
+ refObjectManager = nce.resolve(nce.to_name("ObjectManager"));
+ refEnumManager = nce.resolve(nce.to_name("EnumManager"));
+ refArraysUnions = nce.resolve(nce.to_name("ArraysUnions"));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void stop() {
+ server.stop();
+ }
+
+ /**
+ * Tests remote operation, basing on given reference, operation name,
+ * arguments, expected return type and content
+ *
+ * @param ref remote object
+ * @param operationName operation to invoke
+ * @param clazz expected return type
+ * @param arguments array of operation arguments
+ * @param equalTo expected return content
+ */
+ private void dynaTestInvoker(Object ref,
+ String operationName,
+ Class<?> clazz,
+ java.lang.Object[] arguments,
+ java.lang.Object equalTo) {
+
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(ref, operationName);
+ request.setOutputType(clazz);
+ for (int i = 0; arguments != null && i < arguments.length; i++) {
+ request.addArgument(arguments[i]);
+ }
+
+ DynaCorbaResponse response = request.invoke();
+ java.lang.Object content = (java.lang.Object)response.getContent();
+ assertTrue(content.getClass().equals(clazz));
+ if (equalTo != null && equalTo.getClass().isArray()) {
+ for (int i = 0; i < Array.getLength(equalTo); i++) {
+ assertTrue(Array.get(content, i).equals(Array.get(equalTo, i)));
+ }
+ } else {
+ assertTrue(content.equals(equalTo));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Error while invoking " + operationName);
+ }
+ }
+
+ /**
+ * Tests passing (and getting as result) varied primitives
+ */
+ @Test
+ public void test_setPrimitives() {
+
+ dynaTestInvoker(refPrimitivesSetter, "setBoolean", Boolean.class, new Boolean[] {true}, true);
+ dynaTestInvoker(refPrimitivesSetter, "setOctet", Byte.class, new Byte[] {1}, (byte)1);
+ dynaTestInvoker(refPrimitivesSetter, "setChar", Character.class, new Character[] {'A'}, 'A');
+ dynaTestInvoker(refPrimitivesSetter, "setShort", Short.class, new Short[] {1}, (short)1);
+ dynaTestInvoker(refPrimitivesSetter, "setLong", Integer.class, new Integer[] {1}, (int)1);
+ dynaTestInvoker(refPrimitivesSetter, "setLongLong", Long.class, new Long[] {(long)1}, (long)1);
+ dynaTestInvoker(refPrimitivesSetter, "setFloat", Float.class, new Float[] {(float)1}, (float)1);
+ dynaTestInvoker(refPrimitivesSetter, "setDouble", Double.class, new Double[] {(double)1}, (double)1);
+ dynaTestInvoker(refPrimitivesSetter, "setString", String.class, new String[] {"1"}, "1");
+
+ }
+
+ /**
+ * Tests passing (and getting as result) varied types sequences
+ */
+ @Test
+ public void test_setArrays() {
+
+ dynaTestInvoker(refArraysSetter,
+ "setBoolean",
+ Boolean[].class,
+ new Boolean[][] {new Boolean[] {false, true}},
+ new Boolean[] {false, true});
+
+ dynaTestInvoker(refArraysSetter,
+ "setChar",
+ Character[].class,
+ new Character[][] {new Character[] {'A', 'B'}},
+ new Character[] {'A', 'B'});
+
+ dynaTestInvoker(refArraysSetter, "setOctet", Byte[].class, new Byte[][] {new Byte[] {1, 2}}, new Byte[] {1, 2});
+
+ dynaTestInvoker(refArraysSetter, "setShort", Short[].class, new Short[][] {new Short[] {1, 2}}, new Short[] {1,
+ 2});
+
+ dynaTestInvoker(refArraysSetter,
+ "setLong",
+ Integer[].class,
+ new Integer[][] {new Integer[] {1, 2}},
+ new Integer[] {1, 2});
+
+ dynaTestInvoker(refArraysSetter,
+ "setLongLong",
+ Long[].class,
+ new Long[][] {new Long[] {new Long(1), new Long(2)}},
+ new Long[] {new Long(1), new Long(2)});
+
+ dynaTestInvoker(refArraysSetter,
+ "setFloat",
+ Float[].class,
+ new Float[][] {new Float[] {new Float(1.0), new Float(2.0)}},
+ new Float[] {new Float(1.0), new Float(2.0)});
+
+ dynaTestInvoker(refArraysSetter,
+ "setDouble",
+ Double[].class,
+ new Double[][] {new Double[] {new Double(1.0), new Double(2.0)}},
+ new Double[] {new Double(1.0), new Double(2.0)});
+
+ dynaTestInvoker(refArraysSetter,
+ "setString",
+ String[].class,
+ new String[][] {new String[] {"A", "B"}},
+ new String[] {"A", "B"});
+
+ }
+
+ /**
+ * Tests passing (and getting as result) complex structure
+ */
+ @Test
+ public void test_TestObject_setStruct() {
+ DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setStruct");
+
+ SomeStruct struct = new SomeStruct();
+ SimpleStruct inner = new SimpleStruct();
+ inner.field1 = TestConstants.STR_1;
+ inner.field2 = TestConstants.INT_1;
+ struct.innerStruct = inner;
+ struct.str_list = TestConstants.STR_ARR_2;
+ struct.twoDimSeq = TestConstants.INT_ARRAY_2_DIM;
+ struct.threeDimSeq = TestConstants.INT_ARRAY_3_DIM;
+ struct.str = TestConstants.STR_1;
+
+ try {
+ request.addArgument(struct);
+ request.setOutputType(SomeStruct.class);
+ DynaCorbaResponse response = request.invoke();
+ SomeStruct result = (SomeStruct)response.getContent();
+ assertTrue(TestConstants.are2DimArraysEqual(result.twoDimSeq, TestConstants.INT_ARRAY_2_DIM));
+ assertTrue(TestConstants.are3DimArraysEqual(result.threeDimSeq, TestConstants.INT_ARRAY_3_DIM));
+ assertEquals(TestConstants.STR_1, result.str);
+ assertEquals(TestConstants.STR_ARR_2[0], result.str_list[0]);
+ assertEquals(TestConstants.STR_ARR_2[1], result.str_list[1]);
+ assertEquals(TestConstants.STR_1, result.innerStruct.field1);
+ assertEquals(TestConstants.INT_1, result.innerStruct.field2);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception occured during tests: " + e);
+ }
+ }
+
+ /**
+ * Test passing (and getting as result) simple two-field structure
+ */
+ @Test
+ public void test_TestObject_setSimpleStruct() {
+ SimpleStruct struct = new SimpleStruct();
+ struct.field1 = TestConstants.STR_1;
+ struct.field2 = TestConstants.INT_1;
+ DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setSimpleStruct");
+ try {
+ request.setOutputType(SimpleStruct.class);
+ request.addArgument(struct);
+ DynaCorbaResponse response = request.invoke();
+ SimpleStruct retStruct = (SimpleStruct)response.getContent();
+ assertTrue(retStruct.field1.equals(struct.field1) && retStruct.field2 == struct.field2);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception occured during tests: " + e);
+ }
+ }
+
+ /**
+ * Tests passing (and getting as result) two dim. sequence of long.
+ */
+ @Test
+ public void test_TestObject_setLongSeq2() {
+ int[][] arr1 = new int[2][2];
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 2; j++) {
+ arr1[i][j] = (int)(Math.random() * 1000);
+ }
+ }
+ DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setLongSeq2");
+ try {
+ request.setOutputType(arr1.getClass());
+ request.addArgument(arr1);
+ DynaCorbaResponse response = request.invoke();
+ int[][] arr2 = (int[][])response.getContent();
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 2; j++) {
+ assertEquals(arr1[i][j], arr2[i][j]);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception occured during tests: " + e);
+ }
+ }
+
+ /**
+ * Tests passing multiple complex attributes.
+ */
+ @Test
+ public void test_TestObject_pickStructFromArgs() {
+ SomeStruct arg1 = new SomeStruct();
+ SomeStruct arg2 = new SomeStruct();
+ SomeStruct arg3 = new SomeStruct();
+
+ SimpleStruct inner = new SimpleStruct();
+ inner.field1 = TestConstants.STR_1;
+ inner.field2 = TestConstants.INT_1;
+
+ arg1.innerStruct = inner;
+ arg2.innerStruct = inner;
+ arg3.innerStruct = inner;
+
+ arg1.str = TestConstants.STR_1;
+ arg2.str = TestConstants.STR_2;
+ arg3.str = TestConstants.STR_3;
+
+ arg1.str_list = TestConstants.STR_ARR_1;
+ arg2.str_list = TestConstants.STR_ARR_2;
+ arg3.str_list = TestConstants.STR_ARR_2;
+
+ arg1.threeDimSeq = TestConstants.INT_ARRAY_3_DIM;
+ arg2.threeDimSeq = TestConstants.INT_ARRAY_3_DIM;
+ arg3.threeDimSeq = TestConstants.INT_ARRAY_3_DIM;
+
+ arg1.twoDimSeq = TestConstants.INT_ARRAY_2_DIM;
+ arg2.twoDimSeq = TestConstants.INT_ARRAY_2_DIM;
+ arg3.twoDimSeq = TestConstants.INT_ARRAY_2_DIM;
+
+ DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "pickStructFromArgs");
+ try {
+
+ request.setOutputType(SomeStruct.class);
+ request.addArgument(arg1);
+ request.addArgument(arg2);
+ request.addArgument(arg3);
+ request.addArgument(1);
+ DynaCorbaResponse response = request.invoke();
+ SomeStruct result = (SomeStruct)response.getContent();
+
+ // just make sure that servant returned right structure
+ assertTrue(result.str.equals(TestConstants.STR_1));
+ } catch (Exception e) {
+ fail("Exception occured during tests " + e);
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Tests handling user defined remote exception (single declared)
+ */
+ @Test
+ public void test_singleException() {
+ DynaCorbaRequest request1 = new DynaCorbaRequest(refCalcObject, "div");
+ try {
+ request1.addArgument(2d);
+ request1.addArgument(2d);
+ request1.setOutputType(Double.class);
+ request1.addExceptionType(DivByZero.class);
+ request1.invoke();
+ } catch (Exception e) {
+ fail();
+ }
+
+ DynaCorbaRequest request2 = new DynaCorbaRequest(refCalcObject, "div");
+ try {
+ request2.addArgument(2d);
+ request2.addArgument(0d);
+ request2.setOutputType(Double.class);
+ request2.addExceptionType(DivByZero.class);
+ request2.invoke();
+ } catch (DivByZero e) {
+ assertTrue(e.info != null && e.arguments != null && e.arguments.arg1 == 2 && e.arguments.arg2 == 0);
+ } catch (Exception exc) {
+ exc.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests handling user defined multiple exceptions
+ */
+ @Test
+ public void test_multipleExceptions() {
+ DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "divForSmallArgs");
+ try {
+ request.addArgument(101d);
+ request.addArgument(101d);
+ request.setOutputType(Double.class);
+ request.addExceptionType(DivByZero.class);
+ request.addExceptionType(NotSupported.class);
+ request.invoke();
+ } catch (Exception e) {
+ assertTrue(e instanceof NotSupported);
+ }
+ }
+
+ /**
+ * Tests handling exceptions while user defined no exceptions
+ */
+ @Test
+ public void test_noExceptionsDeclared() {
+ DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div");
+ try {
+ request.addArgument(1d);
+ request.addArgument(0d);
+ request.setOutputType(Double.class);
+ request.invoke();
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof RequestConfigurationException);
+ }
+ }
+
+ /**
+ * Tests handling exceptions while user defined no such exception
+ */
+ @Test
+ public void test_noSuchExceptionDeclared() {
+ DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div");
+ try {
+ request.addArgument(1d);
+ request.addArgument(0d);
+ request.addExceptionType(NotSupported.class);
+ request.setOutputType(Double.class);
+ request.invoke();
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof RequestConfigurationException);
+ }
+ }
+
+ /**
+ * Tests handling non existing operation situation
+ */
+ @Test
+ public void test_systemException_BAD_OPERATION() {
+ DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "thisOperationSurelyDoesNotExist");
+ try {
+ request.invoke();
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof CorbaException);
+ }
+ }
+
+ /**
+ * Tests obtaining references to other objects and using them with specified
+ * user interface
+ */
+ @Test
+ @Ignore("Cause of tnameservice hang on stop")
+ public void test_enchancedReferences() {
+ DynaCorbaRequest request = null;
+ try {
+ request = new DynaCorbaRequest(refObjectManager, "getDummyObject");
+ request.setOutputType(DummyObject.class);
+ DynaCorbaResponse response = request.invoke();
+ DummyObject dummy = (DummyObject)response.getContent();
+ DummyObject dummy2 = dummy.cloneObject();
+ dummy2.cloneObject();
+ assertNotSame(dummy.getLong(), dummy2.getLong());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Test passing enums as arguments and retrieving them as a result
+ */
+ @Test
+ public void test_enums() {
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refEnumManager, "getColor");
+ Color color = Color.green;
+ request.addArgument(color);
+ request.setOutputType(Color.class);
+ DynaCorbaResponse response = request.invoke();
+ Color result = (Color)response.getContent();
+ assertEquals(color.value(), result.value());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests recognizing structures
+ */
+ @Test
+ public void test_structValidation() {
+ DynaCorbaRequest request = null;
+ try {
+ request = new DynaCorbaRequest(refArraysSetter, "whatever");
+ request.setOutputType(InvalidStruct1.class);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof RequestConfigurationException);
+ }
+
+ try {
+ request = new DynaCorbaRequest(refArraysSetter, "whatever");
+ request.setOutputType(InvalidStruct2.class);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof RequestConfigurationException);
+ }
+
+ try {
+ request = new DynaCorbaRequest(refArraysSetter, "whatever");
+ request.setOutputType(InvalidStruct3.class);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof RequestConfigurationException);
+ }
+
+ try {
+ request = new DynaCorbaRequest(refArraysSetter, "whatever");
+ request.setOutputType(SomeStruct.class);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ /**
+ * Tests recognizing enums
+ */
+ @Test
+ public void test_enumValidation() {
+ DynaCorbaRequest request = null;
+ try {
+ request = new DynaCorbaRequest(refArraysSetter, "whatever");
+ request.setOutputType(InvalidEnum1.class);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof RequestConfigurationException);
+ }
+
+ try {
+ request = new DynaCorbaRequest(refArraysSetter, "whatever");
+ request.setOutputType(InvalidEnum2.class);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof RequestConfigurationException);
+ }
+
+ try {
+ request = new DynaCorbaRequest(refArraysSetter, "whatever");
+ request.setOutputType(InvalidEnum3.class);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof RequestConfigurationException);
+ }
+
+ try {
+ request = new DynaCorbaRequest(refArraysSetter, "whatever");
+ request.setOutputType(Color.class);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ /**
+ * Tests handling passing wrong params
+ */
+ @Test
+ public void test_systemException_BAD_PARAM() {
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div");
+ request.setOutputType(Double.class);
+ request.addArgument(3d);
+ request.invoke();
+ fail();
+ } catch (Exception e) {
+ if (e instanceof CorbaException) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ }
+
+ /**
+ * Tests passing CORBA arrays
+ */
+ @Test
+ public void test_arraysPassing() {
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray");
+ Annotation[] notes =
+ ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class})
+ .getAnnotations();
+ request.setOutputType(String[][].class, notes);
+ String[][] argument = { {"Hello", "World"}, {"Hi", "again"}};
+ request.addArgument(argument, notes);
+ DynaCorbaResponse response = request.invoke();
+ String[][] result = (String[][])response.getContent();
+ for (int i = 0; i < argument.length; i++) {
+ for (int j = 0; j < argument[i].length; j++) {
+ assertEquals(argument[i][j], result[i][j]);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passTestStruct");
+ ArraysTestStruct arg = new ArraysTestStruct();
+ String[] field1 = {"Hello", "World"};
+ arg.field1 = field1;
+ int[][] field2 = { {4, 2, 2, 5}, {6, 12, 5, 8}};
+ arg.field2 = field2;
+ float[][][] field3 = { { {2, 6}, {2, 7}, {9, 3}, {4, 6}}, { {3, 7}, {6, 6}, {3, 5}, {6, 2}}};
+ arg.field3 = field3;
+ request.addArgument(arg);
+ request.setOutputType(ArraysTestStruct.class);
+ DynaCorbaResponse response = request.invoke();
+ ArraysTestStruct result = (ArraysTestStruct)response.getContent();
+ for (int i = 0; i < arg.field1.length; i++) {
+ assertEquals(arg.field1[i], result.field1[i]);
+ }
+ for (int i = 0; i < arg.field2.length; i++) {
+ for (int j = 0; j < arg.field2[i].length; j++) {
+ assertEquals(arg.field2[i][j], result.field2[i][j]);
+ }
+ }
+ for (int i = 0; i < arg.field2.length; i++) {
+ for (int j = 0; j < arg.field2[i].length; j++) {
+ for (int k = 0; k < arg.field3[i][j].length; k++) {
+ assertEquals(arg.field3[i][j][k], result.field3[i][j][k], 0.0);
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests situation when CORBA array dimension size doesn't match
+ * CORBA array annotation arguments (which sets dimension lengths)
+ */
+ @Test
+ public void test_invalidArrayAnnotationSize() {
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray");
+ Annotation[] notes =
+ ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class})
+ .getAnnotations();
+ request.setOutputType(String[][][].class, notes);
+ fail();
+ } catch (RequestConfigurationException e) {
+ // expected
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray");
+ Annotation[] notes =
+ ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class})
+ .getAnnotations();
+ request.addArgument(new String[0][0][0], notes);
+ fail();
+ } catch (RequestConfigurationException e) {
+ // expected
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray");
+ request.addArgument(new InvalidCorbaArray(), null);
+ fail();
+ } catch (RequestConfigurationException e) {
+ // expected
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests passing CORBA unions
+ */
+ @Test
+ public void test_passingUnions() {
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passRichUnion");
+ request.setOutputType(RichUnion.class);
+ RichUnion arg = new RichUnion();
+ InnerUnion argIu = new InnerUnion();
+ argIu.setX(10);
+ arg.setIu(argIu);
+ request.addArgument(arg);
+ DynaCorbaResponse response = request.invoke();
+ RichUnion result = (RichUnion)response.getContent();
+ assertEquals(arg.getIu().getX(), result.getIu().getX());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passRichUnion");
+ request.setOutputType(RichUnion.class);
+ RichUnion arg = new RichUnion();
+ arg.setDef(true);
+ request.addArgument(arg);
+ DynaCorbaResponse response = request.invoke();
+ RichUnion result = (RichUnion)response.getContent();
+ assertEquals(arg.isDef(), result.isDef());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests handling invalid union declarations
+ */
+ @Test
+ public void test_testInvalidUnionClasses() {
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever");
+ request.setOutputType(InvalidUnion1.class);
+ } catch (Exception e) {
+ assertEquals(RequestConfigurationException.class, e.getClass());
+ }
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever");
+ request.setOutputType(InvalidUnion2.class);
+ } catch (Exception e) {
+ assertEquals(RequestConfigurationException.class, e.getClass());
+ }
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever");
+ request.setOutputType(InvalidUnion3.class);
+ } catch (Exception e) {
+ assertEquals(RequestConfigurationException.class, e.getClass());
+ }
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever");
+ request.setOutputType(InvalidUnion4.class);
+ } catch (Exception e) {
+ assertEquals(RequestConfigurationException.class, e.getClass());
+ }
+ try {
+ DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever");
+ request.setOutputType(InvalidUnion5.class);
+ } catch (Exception e) {
+ assertEquals(RequestConfigurationException.class, e.getClass());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MappingTestInterface.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MappingTestInterface.java
new file mode 100644
index 0000000000..f0dccd9e7e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MappingTestInterface.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.sca.binding.corba.testing;
+
+/**
+ * @version $Rev$ $Date$
+ * Interface that can be tested for operations mapping
+ */
+public interface MappingTestInterface {
+
+ int getIntField();
+
+ void setIntField(int intField);
+
+ boolean isBoolField();
+
+ void setBoolField(boolean boolField);
+
+ void overloadedName();
+
+ void overloadedName(String arg1);
+
+ void overloadedName(String arg1, int arg2);
+
+ void caseCollision();
+
+ void CaseCollision();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MethodFinderTestCase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MethodFinderTestCase.java
new file mode 100644
index 0000000000..6975c62ddb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MethodFinderTestCase.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.binding.corba.testing;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.binding.corba.provider.util.MethodFinder;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ * Various tests for MethodFinder
+ */
+public class MethodFinderTestCase {
+
+ /**
+ * Tests finding existing methods
+ */
+ @Test
+ public void test_findExistingMethod() {
+ try {
+ String methodName = "rotateLeft";
+ Method sample = Integer.class.getMethod(methodName, new Class<?>[] {int.class, int.class});
+ Method m1 = MethodFinder.findMethod(Integer.class, methodName, new Class<?>[] {int.class, int.class});
+ Method m2 =
+ MethodFinder.findMethod(Integer.class, methodName, new Class<?>[] {Integer.class, Integer.class});
+ assertEquals(sample, m1);
+ assertEquals(sample, m2);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests null result value for not existing method
+ */
+ @Test
+ public void test_findNotExistingMethod() {
+ try {
+ String methodName = "rotateLeft";
+ Method method = MethodFinder.findMethod(Integer.class, methodName, new Class<?>[] {});
+ assertEquals(null, method);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/OperationMappingTestCase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/OperationMappingTestCase.java
new file mode 100644
index 0000000000..4767728db7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/OperationMappingTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.sca.binding.corba.provider.util.OperationMapper;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ * Various tests for OperationsMapping
+ */
+public class OperationMappingTestCase {
+
+ /**
+ * Tests if Java2IDLUtil maps methods to operations correctly
+ */
+ @Test
+ public void test_mappingRules() {
+ Map<Method, String> met2op = OperationMapper.mapMethodToOperationName(MappingTestInterface.class);
+ for (Method method : met2op.keySet()) {
+ String name = method.getName();
+ String translatedName = met2op.get(method);
+ if (name.equals("getIntField")) {
+ assertEquals("_get_intField", translatedName);
+ } else if (name.equals("setIntField")) {
+ assertEquals("_set_intField", translatedName);
+ } else if (name.equals("isBoolField")) {
+ assertEquals("_get_boolField", translatedName);
+ } else if (name.equals("setBoolField")) {
+ assertEquals("_set_boolField", translatedName);
+ } else if (name.equals("overloadedName") && method.getParameterTypes().length == 0) {
+ assertEquals("overloadedName__", translatedName);
+ } else if (name.equals("overloadedName") && method.getParameterTypes().length == 1) {
+ assertEquals("overloadedName__CORBA_WStringValue", translatedName);
+ } else if (name.equals("overloadedName") && method.getParameterTypes().length == 2) {
+ assertEquals("overloadedName__CORBA_WStringValue__long", translatedName);
+ } else if (name.equals("caseCollision")) {
+ assertEquals("caseCollision_4", translatedName);
+ } else if (name.equals("CaseCollision")) {
+ assertEquals("CaseCollision_0_4", translatedName);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/TestConstants.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/TestConstants.java
new file mode 100644
index 0000000000..962a00d002
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/TestConstants.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing;
+
+/**
+ * Some constants and utilities for module tests
+ * @version $Rev$ $Date$
+ */
+public class TestConstants {
+
+ public static final String STR_1 = "Hello world!";
+ public static final String STR_2 = "2nd string";
+ public static final String STR_3 = "Other string";
+ public static final String[] STR_ARR_1 = {"Hello", "World"};
+ public static final String[] STR_ARR_2 = {"Another", "string", "array"};
+ public static final int INT_1 = 0;
+
+ public static final int TEST1_PORT = 11100;
+ public static final String TEST1_HOST = "localhost";
+
+ public static final int TEST2_PORT = 11101;
+ public static final String TEST2_HOST = "localhost";
+
+ public static final int[][] INT_ARRAY_2_DIM = { {1, 2}, {3, 4}};
+ public static final int[][][] INT_ARRAY_3_DIM = { { {1, 2}, {3, 4}}, { {5, 6}, {7, 8}}};
+
+ public static final long TNAMESERV_SPAWN_WAIT = 300;
+
+ /**
+ * Tests if given 2D arrays values are equal
+ * @param arr1
+ * @param arr2
+ * @return
+ */
+ public static boolean are2DimArraysEqual(int[][] arr1, int[][] arr2) {
+ int sum = 0;
+ int expSum = 0;
+ for (int i = 0; i < arr1.length; i++) {
+ for (int j = 0; j < arr1[i].length; j++) {
+ expSum++;
+ if (arr1[i][j] == arr2[i][j]) {
+ sum++;
+ }
+ }
+ }
+ return sum == expSum;
+ }
+
+ /**
+ * Tests if given 3D arrays values are equal
+ * @param arr1
+ * @param arr2
+ * @return
+ */
+ public static boolean are3DimArraysEqual(int[][][] arr1, int[][][] arr2) {
+ int sum = 0;
+ int expSum = 0;
+ for (int i = 0; i < arr1.length; i++) {
+ for (int j = 0; j < arr1[i].length; j++) {
+ for (int k = 0; k < arr1[i][j].length; k++) {
+ expSum++;
+ if (arr1[i][j][k] == arr2[i][j][k]) {
+ sum++;
+ }
+ }
+ }
+ }
+ return sum == expSum;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java
new file mode 100644
index 0000000000..895d2248fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.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.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public interface ArraysUnionsTests extends ArraysUnionsTestsOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
+{
+} // interface ArraysUnionsTests
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java
new file mode 100644
index 0000000000..bf6d6e322d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+abstract public class ArraysUnionsTestsHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.id (), "ArraysUnionsTests");
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests read (org.omg.CORBA.portable.InputStream istream)
+ {
+ return narrow (istream.read_Object (_ArraysUnionsTestsStub.class));
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests value)
+ {
+ ostream.write_Object ((org.omg.CORBA.Object) value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)
+ return (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)obj;
+ else if (!obj._is_a (id ()))
+ throw new org.omg.CORBA.BAD_PARAM ();
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub stub = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests unchecked_narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)
+ return (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)obj;
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub stub = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java
new file mode 100644
index 0000000000..aca8060d74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public final class ArraysUnionsTestsHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests value = null;
+
+ public ArraysUnionsTestsHolder ()
+ {
+ }
+
+ public ArraysUnionsTestsHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java
new file mode 100644
index 0000000000..01817e12a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public interface ArraysUnionsTestsOperations
+{
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct passTestStruct (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg);
+ String[][] passStringArray (String[][] arg);
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion passRichUnion (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion arg);
+} // interface ArraysUnionsTestsOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java
new file mode 100644
index 0000000000..9c00e20f7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public final class InnerUnion implements org.omg.CORBA.portable.IDLEntity
+{
+ private int ___x;
+ private float ___y;
+ private int __discriminator;
+ private boolean __uninitialized = true;
+
+ public InnerUnion ()
+ {
+ }
+
+ public int discriminator ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ return __discriminator;
+ }
+
+ public int x ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyx (__discriminator);
+ return ___x;
+ }
+
+ public void x (int value)
+ {
+ __discriminator = 1;
+ ___x = value;
+ __uninitialized = false;
+ }
+
+ public void x (int discriminator, int value)
+ {
+ verifyx (discriminator);
+ __discriminator = discriminator;
+ ___x = value;
+ __uninitialized = false;
+ }
+
+ private void verifyx (int discriminator)
+ {
+ if (discriminator != 1)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public float y ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyy (__discriminator);
+ return ___y;
+ }
+
+ public void y (float value)
+ {
+ __discriminator = 2;
+ ___y = value;
+ __uninitialized = false;
+ }
+
+ public void y (int discriminator, float value)
+ {
+ verifyy (discriminator);
+ __discriminator = discriminator;
+ ___y = value;
+ __uninitialized = false;
+ }
+
+ private void verifyy (int discriminator)
+ {
+ if (discriminator != 2)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public void _default ()
+ {
+ __discriminator = -2147483648;
+ __uninitialized = false;
+ }
+
+ public void _default (int discriminator)
+ {
+ verifyDefault( discriminator ) ;
+ __discriminator = discriminator ;
+ __uninitialized = false;
+ }
+
+ private void verifyDefault( int value )
+ {
+ switch (value) {
+ case 1:
+ case 2:
+ throw new org.omg.CORBA.BAD_OPERATION() ;
+
+ default:
+ return;
+ }
+ }
+
+} // class InnerUnion
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.java
new file mode 100644
index 0000000000..df692c3d27
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.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.sca.binding.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+abstract public class InnerUnionHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion/InnerUnion:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ org.omg.CORBA.TypeCode _disTypeCode0;
+ _disTypeCode0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [2];
+ org.omg.CORBA.TypeCode _tcOf_members0;
+ org.omg.CORBA.Any _anyOf_members0;
+
+ // Branch for x (case label 1)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)1);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ _members0[0] = new org.omg.CORBA.UnionMember (
+ "x",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for y (case label 2)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)2);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float);
+ _members0[1] = new org.omg.CORBA.UnionMember (
+ "y",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.id (), "InnerUnion", _disTypeCode0, _members0);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion ();
+ int _dis0 = (int)0;
+ _dis0 = istream.read_long ();
+ switch (_dis0)
+ {
+ case 1:
+ int _x = (int)0;
+ _x = istream.read_long ();
+ value.x (_x);
+ break;
+ case 2:
+ float _y = (float)0;
+ _y = istream.read_float ();
+ value.y (_y);
+ break;
+ default:
+ value._default( _dis0 ) ;
+ break;
+ }
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value)
+ {
+ ostream.write_long (value.discriminator ());
+ switch (value.discriminator ())
+ {
+ case 1:
+ ostream.write_long (value.x ());
+ break;
+ case 2:
+ ostream.write_float (value.y ());
+ break;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java
new file mode 100644
index 0000000000..9f3b7b5c34
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public final class InnerUnionHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value = null;
+
+ public InnerUnionHolder ()
+ {
+ }
+
+ public InnerUnionHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java
new file mode 100644
index 0000000000..4d2f7f7973
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public final class RichUnion implements org.omg.CORBA.portable.IDLEntity
+{
+ private int ___x;
+ private float ___y;
+ private String ___z;
+ private org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion ___iu;
+ private boolean ___a;
+ private int __discriminator;
+ private boolean __uninitialized = true;
+
+ public RichUnion ()
+ {
+ }
+
+ public int discriminator ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ return __discriminator;
+ }
+
+ public int x ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyx (__discriminator);
+ return ___x;
+ }
+
+ public void x (int value)
+ {
+ __discriminator = 1;
+ ___x = value;
+ __uninitialized = false;
+ }
+
+ public void x (int discriminator, int value)
+ {
+ verifyx (discriminator);
+ __discriminator = discriminator;
+ ___x = value;
+ __uninitialized = false;
+ }
+
+ private void verifyx (int discriminator)
+ {
+ if (discriminator != 1)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public float y ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyy (__discriminator);
+ return ___y;
+ }
+
+ public void y (float value)
+ {
+ __discriminator = 2;
+ ___y = value;
+ __uninitialized = false;
+ }
+
+ public void y (int discriminator, float value)
+ {
+ verifyy (discriminator);
+ __discriminator = discriminator;
+ ___y = value;
+ __uninitialized = false;
+ }
+
+ private void verifyy (int discriminator)
+ {
+ if (discriminator != 2)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public String z ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyz (__discriminator);
+ return ___z;
+ }
+
+ public void z (String value)
+ {
+ __discriminator = 3;
+ ___z = value;
+ __uninitialized = false;
+ }
+
+ public void z (int discriminator, String value)
+ {
+ verifyz (discriminator);
+ __discriminator = discriminator;
+ ___z = value;
+ __uninitialized = false;
+ }
+
+ private void verifyz (int discriminator)
+ {
+ if (discriminator != 3)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion iu ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifyiu (__discriminator);
+ return ___iu;
+ }
+
+ public void iu (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value)
+ {
+ __discriminator = 4;
+ ___iu = value;
+ __uninitialized = false;
+ }
+
+ public void iu (int discriminator, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value)
+ {
+ verifyiu (discriminator);
+ __discriminator = discriminator;
+ ___iu = value;
+ __uninitialized = false;
+ }
+
+ private void verifyiu (int discriminator)
+ {
+ if (discriminator != 4)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+ public boolean a ()
+ {
+ if (__uninitialized)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ verifya (__discriminator);
+ return ___a;
+ }
+
+ public void a (boolean value)
+ {
+ __discriminator = -2147483648;
+ ___a = value;
+ __uninitialized = false;
+ }
+
+ public void a (int discriminator, boolean value)
+ {
+ verifya (discriminator);
+ __discriminator = discriminator;
+ ___a = value;
+ __uninitialized = false;
+ }
+
+ private void verifya (int discriminator)
+ {
+ if (discriminator == 1 || discriminator == 2 || discriminator == 3 || discriminator == 4)
+ throw new org.omg.CORBA.BAD_OPERATION ();
+ }
+
+} // class RichUnion
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java
new file mode 100644
index 0000000000..17ab0d3e88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+abstract public class RichUnionHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion/RichUnion:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ org.omg.CORBA.TypeCode _disTypeCode0;
+ _disTypeCode0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [5];
+ org.omg.CORBA.TypeCode _tcOf_members0;
+ org.omg.CORBA.Any _anyOf_members0;
+
+ // Branch for x (case label 1)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)1);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ _members0[0] = new org.omg.CORBA.UnionMember (
+ "x",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for y (case label 2)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)2);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float);
+ _members0[1] = new org.omg.CORBA.UnionMember (
+ "y",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for z (case label 3)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)3);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ _members0[2] = new org.omg.CORBA.UnionMember (
+ "z",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for iu (case label 4)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_long ((int)4);
+ _tcOf_members0 = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.type ();
+ _members0[3] = new org.omg.CORBA.UnionMember (
+ "iu",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+
+ // Branch for a (Default case)
+ _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
+ _anyOf_members0.insert_octet ((byte)0); // default member label
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_boolean);
+ _members0[4] = new org.omg.CORBA.UnionMember (
+ "a",
+ _anyOf_members0,
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.id (), "RichUnion", _disTypeCode0, _members0);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion value = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion ();
+ int _dis0 = (int)0;
+ _dis0 = istream.read_long ();
+ switch (_dis0)
+ {
+ case 1:
+ int _x = (int)0;
+ _x = istream.read_long ();
+ value.x (_x);
+ break;
+ case 2:
+ float _y = (float)0;
+ _y = istream.read_float ();
+ value.y (_y);
+ break;
+ case 3:
+ String _z = null;
+ _z = istream.read_string ();
+ value.z (_z);
+ break;
+ case 4:
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion _iu = null;
+ _iu = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.read (istream);
+ value.iu (_iu);
+ break;
+ default:
+ boolean _a = false;
+ _a = istream.read_boolean ();
+ value.a (_dis0, _a);
+ break;
+ }
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion value)
+ {
+ ostream.write_long (value.discriminator ());
+ switch (value.discriminator ())
+ {
+ case 1:
+ ostream.write_long (value.x ());
+ break;
+ case 2:
+ ostream.write_float (value.y ());
+ break;
+ case 3:
+ ostream.write_string (value.z ());
+ break;
+ case 4:
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.write (ostream, value.iu ());
+ break;
+ default:
+ ostream.write_boolean (value.a ());
+ break;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.java
new file mode 100644
index 0000000000..af45c724d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.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 org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+
+*/
+
+public final class RichUnionHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion value = null;
+
+ public RichUnionHolder ()
+ {
+ }
+
+ public RichUnionHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java
new file mode 100644
index 0000000000..a8d0f101b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+
+*/
+
+abstract public class StringArrayHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArray:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, String[][] that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static String[][] extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ __typeCode = org.omg.CORBA.ORB.init ().create_array_tc (2, __typeCode );
+ __typeCode = org.omg.CORBA.ORB.init ().create_array_tc (2, __typeCode );
+ __typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.id (), "StringArray", __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static String[][] read (org.omg.CORBA.portable.InputStream istream)
+ {
+ String value[][] = null;
+ value = new String[2][];
+ for (int _o0 = 0;_o0 < (2); ++_o0)
+ {
+ value[_o0] = new String[2];
+ for (int _o1 = 0;_o1 < (2); ++_o1)
+ {
+ value[_o0][_o1] = istream.read_string ();
+ }
+ }
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, String[][] value)
+ {
+ if (value.length != (2))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i0 = 0;_i0 < (2); ++_i0)
+ {
+ if (value[_i0].length != (2))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i1 = 0;_i1 < (2); ++_i1)
+ {
+ ostream.write_string (value[_i0][_i1]);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java
new file mode 100644
index 0000000000..8b631fbfcf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.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.binding.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+
+*/
+
+public final class StringArrayHolder implements org.omg.CORBA.portable.Streamable
+{
+ public String value[][] = null;
+
+ public StringArrayHolder ()
+ {
+ }
+
+ public StringArrayHolder (String[][] initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java
new file mode 100644
index 0000000000..3c5487b207
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public final class TestStruct implements org.omg.CORBA.portable.IDLEntity
+{
+ public String oneDimArray[] = null;
+ public int twoDimArray[][] = null;
+ public float threeDimArray[][][] = null;
+
+ public TestStruct ()
+ {
+ } // ctor
+
+ public TestStruct (String[] _oneDimArray, int[][] _twoDimArray, float[][][] _threeDimArray)
+ {
+ oneDimArray = _oneDimArray;
+ twoDimArray = _twoDimArray;
+ threeDimArray = _threeDimArray;
+ } // ctor
+
+} // class TestStruct
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java
new file mode 100644
index 0000000000..060500bdce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+abstract public class TestStructHelper
+{
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct/TestStruct:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ synchronized (org.omg.CORBA.TypeCode.class)
+ {
+ if (__typeCode == null)
+ {
+ if (__active)
+ {
+ return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [3];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
+ _members0[0] = new org.omg.CORBA.StructMember (
+ "oneDimArray",
+ _tcOf_members0,
+ null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (4, _tcOf_members0 );
+ _members0[1] = new org.omg.CORBA.StructMember (
+ "twoDimArray",
+ _tcOf_members0,
+ null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float);
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (4, _tcOf_members0 );
+ _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 );
+ _members0[2] = new org.omg.CORBA.StructMember (
+ "threeDimArray",
+ _tcOf_members0,
+ null);
+ __typeCode = org.omg.CORBA.ORB.init ().create_struct_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.id (), "TestStruct", _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct read (org.omg.CORBA.portable.InputStream istream)
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct ();
+ value.oneDimArray = new String[2];
+ for (int _o0 = 0;_o0 < (2); ++_o0)
+ {
+ value.oneDimArray[_o0] = istream.read_string ();
+ }
+ value.twoDimArray = new int[2][];
+ for (int _o1 = 0;_o1 < (2); ++_o1)
+ {
+ value.twoDimArray[_o1] = new int[4];
+ for (int _o2 = 0;_o2 < (4); ++_o2)
+ {
+ value.twoDimArray[_o1][_o2] = istream.read_long ();
+ }
+ }
+ value.threeDimArray = new float[2][][];
+ for (int _o3 = 0;_o3 < (2); ++_o3)
+ {
+ value.threeDimArray[_o3] = new float[4][];
+ for (int _o4 = 0;_o4 < (4); ++_o4)
+ {
+ value.threeDimArray[_o3][_o4] = new float[2];
+ for (int _o5 = 0;_o5 < (2); ++_o5)
+ {
+ value.threeDimArray[_o3][_o4][_o5] = istream.read_float ();
+ }
+ }
+ }
+ return value;
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value)
+ {
+ if (value.oneDimArray.length != (2))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i0 = 0;_i0 < (2); ++_i0)
+ {
+ ostream.write_string (value.oneDimArray[_i0]);
+ }
+ if (value.twoDimArray.length != (2))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i1 = 0;_i1 < (2); ++_i1)
+ {
+ if (value.twoDimArray[_i1].length != (4))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i2 = 0;_i2 < (4); ++_i2)
+ {
+ ostream.write_long (value.twoDimArray[_i1][_i2]);
+ }
+ }
+ if (value.threeDimArray.length != (2))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i3 = 0;_i3 < (2); ++_i3)
+ {
+ if (value.threeDimArray[_i3].length != (4))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i4 = 0;_i4 < (4); ++_i4)
+ {
+ if (value.threeDimArray[_i3][_i4].length != (2))
+ throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ for (int _i5 = 0;_i5 < (2); ++_i5)
+ {
+ ostream.write_float (value.threeDimArray[_i3][_i4][_i5]);
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java
new file mode 100644
index 0000000000..45c1b99b49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.corba.testing.arrays_unions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public final class TestStructHolder implements org.omg.CORBA.portable.Streamable
+{
+ public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value = null;
+
+ public TestStructHolder ()
+ {
+ }
+
+ public TestStructHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.type ();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java
new file mode 100644
index 0000000000..df2ac4387b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+
+*/
+
+public abstract class _ArraysUnionsTestsImplBase extends org.omg.CORBA.portable.ObjectImpl
+ implements org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests, org.omg.CORBA.portable.InvokeHandler
+{
+
+ // Constructors
+ public _ArraysUnionsTestsImplBase ()
+ {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable ();
+ static
+ {
+ _methods.put ("passTestStruct", new java.lang.Integer (0));
+ _methods.put ("passStringArray", new java.lang.Integer (1));
+ _methods.put ("passRichUnion", new java.lang.Integer (2));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke (String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh)
+ {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get ($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue ())
+ {
+ case 0: // org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests/passTestStruct
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read (in);
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct $result = null;
+ $result = this.passTestStruct (arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write (out, $result);
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests/passStringArray
+ {
+ String arg[][] = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read (in);
+ String $result[][] = null;
+ $result = this.passStringArray (arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write (out, $result);
+ break;
+ }
+
+ case 2: // org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests/passRichUnion
+ {
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion arg = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.read (in);
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion $result = null;
+ $result = this.passRichUnion (arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.write (out, $result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+
+} // class _ArraysUnionsTestsImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java
new file mode 100644
index 0000000000..625d2e2a14
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.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.sca.binding.corba.testing.arrays_unions;
+
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from arrays_unions.idl
+*/
+
+public class _ArraysUnionsTestsStub extends org.omg.CORBA.portable.ObjectImpl implements org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests
+{
+
+ public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct passTestStruct (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("passTestStruct", true);
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write ($out, arg);
+ $in = _invoke ($out);
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct $result = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read ($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return passTestStruct (arg );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // passTestStruct
+
+ public String[][] passStringArray (String[][] arg)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("passStringArray", true);
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write ($out, arg);
+ $in = _invoke ($out);
+ String $result[][] = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read ($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return passStringArray (arg );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // passStringArray
+
+ public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion passRichUnion (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion arg)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("passRichUnion", true);
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.write ($out, arg);
+ $in = _invoke ($out);
+ org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion $result = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.read ($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return passRichUnion (arg );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // passRichUnion
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+ private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
+ {
+ String str = s.readUTF ();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
+ _set_delegate (delegate);
+ }
+
+ private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
+ {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
+ s.writeUTF (str);
+ }
+} // class _ArraysUnionsTestsStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java
new file mode 100644
index 0000000000..e3c28f8b91
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.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.binding.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/Color.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+public class Color implements org.omg.CORBA.portable.IDLEntity {
+ private int __value;
+ private static int __size = 3;
+ private static org.apache.tuscany.sca.binding.corba.testing.enums.Color[] __array =
+ new org.apache.tuscany.sca.binding.corba.testing.enums.Color[__size];
+
+ public static final int _red = 0;
+ public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color red =
+ new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_red);
+ public static final int _yellow = 1;
+ public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color yellow =
+ new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_yellow);
+ public static final int _green = 2;
+ public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color green =
+ new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_green);
+
+ public int value() {
+ return __value;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.enums.Color from_int(int value) {
+ if (value >= 0 && value < __size)
+ return __array[value];
+ else
+ throw new org.omg.CORBA.BAD_PARAM();
+ }
+
+ protected Color(int value) {
+ __value = value;
+ __array[__value] = this;
+ }
+} // class Color
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java
new file mode 100644
index 0000000000..775cac8e16
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+abstract public class ColorHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/enums/Color:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.enums.Color that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.enums.Color extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB.init().create_enum_tc(org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper
+ .id(),
+ "Color",
+ new String[] {"red", "yellow", "green"});
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.enums.Color read(org.omg.CORBA.portable.InputStream istream) {
+ return org.apache.tuscany.sca.binding.corba.testing.enums.Color.from_int(istream.read_long());
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.enums.Color value) {
+ ostream.write_long(value.value());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java
new file mode 100644
index 0000000000..32cd9c8df6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+public final class ColorHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.enums.Color value = null;
+
+ public ColorHolder() {
+ }
+
+ public ColorHolder(org.apache.tuscany.sca.binding.corba.testing.enums.Color initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java
new file mode 100644
index 0000000000..3f73557952
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.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.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+public interface EnumManager extends EnumManagerOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface EnumManager
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java
new file mode 100644
index 0000000000..a6160a7643
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+abstract public class EnumManagerHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_interface_tc(org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.id(),
+ "EnumManager");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_EnumManagerStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager)
+ return (org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager)
+ return (org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java
new file mode 100644
index 0000000000..6afa6bc806
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+public final class EnumManagerHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager value = null;
+
+ public EnumManagerHolder() {
+ }
+
+ public EnumManagerHolder(org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java
new file mode 100644
index 0000000000..bab0c27f77
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.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.binding.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+public interface EnumManagerOperations {
+
+ org.apache.tuscany.sca.binding.corba.testing.enums.Color getColor(org.apache.tuscany.sca.binding.corba.testing.enums.Color color);
+} // interface EnumManagerOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java
new file mode 100644
index 0000000000..514627ff4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.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.sca.binding.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+public abstract class _EnumManagerImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _EnumManagerImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("getColor", new java.lang.Integer(0));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager/getColor
+ {
+ org.apache.tuscany.sca.binding.corba.testing.enums.Color color =
+ org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read(in);
+ org.apache.tuscany.sca.binding.corba.testing.enums.Color $result = null;
+ $result = this.getColor(color);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write(out, $result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _EnumManagerImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java
new file mode 100644
index 0000000000..4629ca9cff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.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.sca.binding.corba.testing.enums;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from enums.idl
+* czwartek, 19 czerwiec 2008 15:46:10 CEST
+*/
+
+public class _EnumManagerStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager {
+
+ public org.apache.tuscany.sca.binding.corba.testing.enums.Color getColor(org.apache.tuscany.sca.binding.corba.testing.enums.Color color) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("getColor", true);
+ org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write($out, color);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.enums.Color $result =
+ org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return getColor(color);
+ } finally {
+ _releaseReply($in);
+ }
+ } // getColor
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _EnumManagerStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.java
new file mode 100644
index 0000000000..aa480f93ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.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.corba.testing.exceptions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public interface Calc extends CalcOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface Calc
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.java
new file mode 100644
index 0000000000..5ed36ca19b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.exceptions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+abstract public class CalcHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_interface_tc(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper.id(),
+ "Calc");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_CalcStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc)
+ return (org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc)
+ return (org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.java
new file mode 100644
index 0000000000..ec1cfadd1e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.exceptions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public final class CalcHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc value = null;
+
+ public CalcHolder() {
+ }
+
+ public CalcHolder(org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.java
new file mode 100644
index 0000000000..29865ace06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.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 org.apache.tuscany.sca.binding.corba.testing.exceptions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public interface CalcOperations {
+ double div(double arg1, double arg2)
+ throws org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero;
+
+ double divForSmallArgs(double arg1, double arg2)
+ throws org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported;
+} // interface CalcOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.java
new file mode 100644
index 0000000000..d7839ec4db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.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.binding.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public final class Arguments implements org.omg.CORBA.portable.IDLEntity {
+ public double arg1 = (double)0;
+ public double arg2 = (double)0;
+
+ public Arguments() {
+ } // ctor
+
+ public Arguments(double _arg1, double _arg2) {
+ arg1 = _arg1;
+ arg2 = _arg2;
+ } // ctor
+
+} // class Arguments
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java
new file mode 100644
index 0000000000..c47d63208f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+abstract public class ArgumentsHelper {
+ private static String _id =
+ "IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/Arguments/Arguments:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ synchronized (org.omg.CORBA.TypeCode.class) {
+ if (__typeCode == null) {
+ if (__active) {
+ return org.omg.CORBA.ORB.init().create_recursive_tc(_id);
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[2];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_double);
+ _members0[0] = new org.omg.CORBA.StructMember("arg1", _tcOf_members0, null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_double);
+ _members0[1] = new org.omg.CORBA.StructMember("arg2", _tcOf_members0, null);
+ __typeCode =
+ org.omg.CORBA.ORB
+ .init()
+ .create_struct_tc(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper
+ .id(),
+ "Arguments",
+ _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments read(org.omg.CORBA.portable.InputStream istream) {
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments value =
+ new org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments();
+ value.arg1 = istream.read_double();
+ value.arg2 = istream.read_double();
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments value) {
+ ostream.write_double(value.arg1);
+ ostream.write_double(value.arg2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.java
new file mode 100644
index 0000000000..f767e8c11a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public final class ArgumentsHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments value = null;
+
+ public ArgumentsHolder() {
+ }
+
+ public ArgumentsHolder(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.java
new file mode 100644
index 0000000000..e7cbb4b8ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.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.binding.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public final class DivByZero extends org.omg.CORBA.UserException {
+ public org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments arguments = null;
+ public String info = null;
+
+ public DivByZero() {
+ super(DivByZeroHelper.id());
+ } // ctor
+
+ public DivByZero(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments _arguments,
+ String _info) {
+ super(DivByZeroHelper.id());
+ arguments = _arguments;
+ info = _info;
+ } // ctor
+
+ public DivByZero(String $reason,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments _arguments,
+ String _info) {
+ super(DivByZeroHelper.id() + " " + $reason);
+ arguments = _arguments;
+ info = _info;
+ } // ctor
+
+} // class DivByZero
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java
new file mode 100644
index 0000000000..5d27f9969c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+abstract public class DivByZeroHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/DivByZero:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ synchronized (org.omg.CORBA.TypeCode.class) {
+ if (__typeCode == null) {
+ if (__active) {
+ return org.omg.CORBA.ORB.init().create_recursive_tc(_id);
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[2];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 =
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.type();
+ _members0[0] = new org.omg.CORBA.StructMember("arguments", _tcOf_members0, null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0);
+ _members0[1] = new org.omg.CORBA.StructMember("info", _tcOf_members0, null);
+ __typeCode =
+ org.omg.CORBA.ORB
+ .init()
+ .create_exception_tc(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper
+ .id(),
+ "DivByZero",
+ _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero read(org.omg.CORBA.portable.InputStream istream) {
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero value =
+ new org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero();
+ // read and discard the repository ID
+ istream.read_string();
+ value.arguments =
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.read(istream);
+ value.info = istream.read_string();
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero value) {
+ // write the repository ID
+ ostream.write_string(id());
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.write(ostream,
+ value.arguments);
+ ostream.write_string(value.info);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.java
new file mode 100644
index 0000000000..ab01c66675
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public final class DivByZeroHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero value = null;
+
+ public DivByZeroHolder() {
+ }
+
+ public DivByZeroHolder(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.java
new file mode 100644
index 0000000000..f4ea58e55e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.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.sca.binding.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public final class NotSupported extends org.omg.CORBA.UserException {
+ public String info = null;
+
+ public NotSupported() {
+ super(NotSupportedHelper.id());
+ } // ctor
+
+ public NotSupported(String _info) {
+ super(NotSupportedHelper.id());
+ info = _info;
+ } // ctor
+
+ public NotSupported(String $reason, String _info) {
+ super(NotSupportedHelper.id() + " " + $reason);
+ info = _info;
+ } // ctor
+
+} // class NotSupported
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java
new file mode 100644
index 0000000000..82609a36c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+abstract public class NotSupportedHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/NotSupported:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ synchronized (org.omg.CORBA.TypeCode.class) {
+ if (__typeCode == null) {
+ if (__active) {
+ return org.omg.CORBA.ORB.init().create_recursive_tc(_id);
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[1];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0);
+ _members0[0] = new org.omg.CORBA.StructMember("info", _tcOf_members0, null);
+ __typeCode =
+ org.omg.CORBA.ORB
+ .init()
+ .create_exception_tc(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper
+ .id(),
+ "NotSupported",
+ _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported read(org.omg.CORBA.portable.InputStream istream) {
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported value =
+ new org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported();
+ // read and discard the repository ID
+ istream.read_string();
+ value.info = istream.read_string();
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported value) {
+ // write the repository ID
+ ostream.write_string(id());
+ ostream.write_string(value.info);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.java
new file mode 100644
index 0000000000..1389bd33d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.exceptions.CalcPackage;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public final class NotSupportedHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported value = null;
+
+ public NotSupportedHolder() {
+ }
+
+ public NotSupportedHolder(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java
new file mode 100644
index 0000000000..a73e252129
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.exceptions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public abstract class _CalcImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _CalcImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("div", new java.lang.Integer(0));
+ _methods.put("divForSmallArgs", new java.lang.Integer(1));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/div
+ {
+ try {
+ double arg1 = in.read_double();
+ double arg2 = in.read_double();
+ double $result = (double)0;
+ $result = this.div(arg1, arg2);
+ out = $rh.createReply();
+ out.write_double($result);
+ } catch (org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero $ex) {
+ out = $rh.createExceptionReply();
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.write(out, $ex);
+ }
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/divForSmallArgs
+ {
+ try {
+ double arg1 = in.read_double();
+ double arg2 = in.read_double();
+ double $result = (double)0;
+ $result = this.divForSmallArgs(arg1, arg2);
+ out = $rh.createReply();
+ out.write_double($result);
+ } catch (org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero $ex) {
+ out = $rh.createExceptionReply();
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.write(out, $ex);
+ } catch (org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported $ex) {
+ out = $rh.createExceptionReply();
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.write(out,
+ $ex);
+ }
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _CalcImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java
new file mode 100644
index 0000000000..65ce051129
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.exceptions;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from exceptions.idl
+* sobota, 7 czerwiec 2008 16:12:31 CEST
+*/
+
+public class _CalcStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc {
+
+ public double div(double arg1, double arg2)
+ throws org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("div", true);
+ $out.write_double(arg1);
+ $out.write_double(arg2);
+ $in = _invoke($out);
+ double $result = $in.read_double();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ if (_id.equals("IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/DivByZero:1.0"))
+ throw org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.read($in);
+ else
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return div(arg1, arg2);
+ } finally {
+ _releaseReply($in);
+ }
+ } // div
+
+ public double divForSmallArgs(double arg1, double arg2)
+ throws org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero,
+ org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("divForSmallArgs", true);
+ $out.write_double(arg1);
+ $out.write_double(arg2);
+ $in = _invoke($out);
+ double $result = $in.read_double();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ if (_id.equals("IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/DivByZero:1.0"))
+ throw org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.read($in);
+ else if (_id.equals("IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/NotSupported:1.0"))
+ throw org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.read($in);
+ else
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return divForSmallArgs(arg1, arg2);
+ } finally {
+ _releaseReply($in);
+ }
+ } // divForSmallArgs
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _CalcStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.java
new file mode 100644
index 0000000000..fde204edf8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public interface ArraysSetter extends ArraysSetterOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface ArraysSetter
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java
new file mode 100644
index 0000000000..71b4fbbdb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+abstract public class ArraysSetterHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB
+ .init()
+ .create_interface_tc(org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper.id(),
+ "ArraysSetter");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_ArraysSetterStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter)
+ return (org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter)
+ return (org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.java
new file mode 100644
index 0000000000..d758a560a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public final class ArraysSetterHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter value = null;
+
+ public ArraysSetterHolder() {
+ }
+
+ public ArraysSetterHolder(org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.java
new file mode 100644
index 0000000000..464c2ccbc3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public interface ArraysSetterOperations {
+ boolean[] setBoolean(boolean[] arg);
+
+ char[] setChar(char[] arg);
+
+ char[] setWchar(char[] arg);
+
+ byte[] setOctet(byte[] arg);
+
+ short[] setShort(short[] arg);
+
+ short[] setUnsignedShort(short[] arg);
+
+ int[] setLong(int[] arg);
+
+ int[] setUnsignedLong(int[] arg);
+
+ long[] setLongLong(long[] arg);
+
+ long[] setUnsignedLongLong(long[] arg);
+
+ float[] setFloat(float[] arg);
+
+ double[] setDouble(double[] arg);
+
+ String[] setString(String[] arg);
+
+ String[] setWstring(String[] arg);
+
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] setRemoteObject(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] obj);
+} // interface ArraysSetterOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.java
new file mode 100644
index 0000000000..c053f12a02
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public interface PrimitivesSetter extends PrimitivesSetterOperations, org.omg.CORBA.Object,
+ org.omg.CORBA.portable.IDLEntity {
+} // interface PrimitivesSetter
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java
new file mode 100644
index 0000000000..566689960e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class PrimitivesSetterHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_interface_tc(org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper
+ .id(),
+ "PrimitivesSetter");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_PrimitivesSetterStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter)
+ return (org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter)
+ return (org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.java
new file mode 100644
index 0000000000..6564957081
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class PrimitivesSetterHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter value = null;
+
+ public PrimitivesSetterHolder() {
+ }
+
+ public PrimitivesSetterHolder(org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.java
new file mode 100644
index 0000000000..26669de95a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public interface PrimitivesSetterOperations {
+ boolean setBoolean(boolean arg);
+
+ char setChar(char arg);
+
+ char setWchar(char arg);
+
+ byte setOctet(byte arg);
+
+ short setShort(short arg);
+
+ short setUnsignedShort(short arg);
+
+ int setLong(int arg);
+
+ int setUnsignedLong(int arg);
+
+ long setLongLong(long arg);
+
+ long setUnsignedLongLong(long arg);
+
+ float setFloat(float arg);
+
+ double setDouble(double arg);
+
+ String setString(String arg);
+
+ String setWstring(String arg);
+
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject setRemoteObject(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject obj);
+} // interface PrimitivesSetterOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.java
new file mode 100644
index 0000000000..5a140f5ecc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public interface RemoteObject extends RemoteObjectOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface RemoteObject
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java
new file mode 100644
index 0000000000..2a8fe73417
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class RemoteObjectHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB
+ .init()
+ .create_interface_tc(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.id(),
+ "RemoteObject");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_RemoteObjectStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject)
+ return (org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.generated._RemoteObjectStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.generated._RemoteObjectStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject)
+ return (org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.generated._RemoteObjectStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.generated._RemoteObjectStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.java
new file mode 100644
index 0000000000..63e3926dd2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class RemoteObjectHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject value = null;
+
+ public RemoteObjectHolder() {
+ }
+
+ public RemoteObjectHolder(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.java
new file mode 100644
index 0000000000..a8231236eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public interface RemoteObjectOperations {
+} // interface RemoteObjectOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.java
new file mode 100644
index 0000000000..ca86420240
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.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.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class SimpleStruct implements org.omg.CORBA.portable.IDLEntity {
+ public String field1 = null;
+ public int field2 = (int)0;
+
+ public SimpleStruct() {
+ } // ctor
+
+ public SimpleStruct(String _field1, int _field2) {
+ field1 = _field1;
+ field2 = _field2;
+ } // ctor
+
+} // class SimpleStruct
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java
new file mode 100644
index 0000000000..2a8898d38f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class SimpleStructHelper {
+ private static String _id =
+ "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct/SimpleStruct:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ synchronized (org.omg.CORBA.TypeCode.class) {
+ if (__typeCode == null) {
+ if (__active) {
+ return org.omg.CORBA.ORB.init().create_recursive_tc(_id);
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[2];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0);
+ _members0[0] = new org.omg.CORBA.StructMember("field1", _tcOf_members0, null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
+ _members0[1] = new org.omg.CORBA.StructMember("field2", _tcOf_members0, null);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_struct_tc(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper
+ .id(),
+ "SimpleStruct",
+ _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct read(org.omg.CORBA.portable.InputStream istream) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct value =
+ new org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct();
+ value.field1 = istream.read_string();
+ value.field2 = istream.read_long();
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct value) {
+ ostream.write_string(value.field1);
+ ostream.write_long(value.field2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.java
new file mode 100644
index 0000000000..bed30e00ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class SimpleStructHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct value = null;
+
+ public SimpleStructHolder() {
+ }
+
+ public SimpleStructHolder(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.java
new file mode 100644
index 0000000000..73dbd6c198
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class SomeStruct implements org.omg.CORBA.portable.IDLEntity {
+ public org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct innerStruct = null;
+ public String str = null;
+ public String str_list[] = null;
+ public int twoDimSeq[][] = null;
+ public int threeDimSeq[][][] = null;
+
+ public SomeStruct() {
+ } // ctor
+
+ public SomeStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct _innerStruct,
+ String _str,
+ String[] _str_list,
+ int[][] _twoDimSeq,
+ int[][][] _threeDimSeq) {
+ innerStruct = _innerStruct;
+ str = _str;
+ str_list = _str_list;
+ twoDimSeq = _twoDimSeq;
+ threeDimSeq = _threeDimSeq;
+ } // ctor
+
+} // class SomeStruct
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java
new file mode 100644
index 0000000000..8f524ffeb1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class SomeStructHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct/SomeStruct:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ private static boolean __active = false;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ synchronized (org.omg.CORBA.TypeCode.class) {
+ if (__typeCode == null) {
+ if (__active) {
+ return org.omg.CORBA.ORB.init().create_recursive_tc(_id);
+ }
+ __active = true;
+ org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[5];
+ org.omg.CORBA.TypeCode _tcOf_members0 = null;
+ _tcOf_members0 = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.type();
+ _members0[0] = new org.omg.CORBA.StructMember("innerStruct", _tcOf_members0, null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0);
+ _members0[1] = new org.omg.CORBA.StructMember("str", _tcOf_members0, null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0);
+ _tcOf_members0 =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper
+ .id(),
+ "string_list",
+ _tcOf_members0);
+ _members0[2] = new org.omg.CORBA.StructMember("str_list", _tcOf_members0, null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0);
+ _tcOf_members0 =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper
+ .id(),
+ "long_seq1",
+ _tcOf_members0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0);
+ _tcOf_members0 =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper
+ .id(),
+ "long_seq2",
+ _tcOf_members0);
+ _members0[3] = new org.omg.CORBA.StructMember("twoDimSeq", _tcOf_members0, null);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0);
+ _tcOf_members0 =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper
+ .id(),
+ "long_seq1",
+ _tcOf_members0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0);
+ _tcOf_members0 =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper
+ .id(),
+ "long_seq2",
+ _tcOf_members0);
+ _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0);
+ _tcOf_members0 =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper
+ .id(),
+ "long_seq3",
+ _tcOf_members0);
+ _members0[4] = new org.omg.CORBA.StructMember("threeDimSeq", _tcOf_members0, null);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_struct_tc(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper
+ .id(),
+ "SomeStruct",
+ _members0);
+ __active = false;
+ }
+ }
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct read(org.omg.CORBA.portable.InputStream istream) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct value =
+ new org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct();
+ value.innerStruct = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read(istream);
+ value.str = istream.read_string();
+ value.str_list = org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.read(istream);
+ value.twoDimSeq = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read(istream);
+ value.threeDimSeq = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read(istream);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct value) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write(ostream, value.innerStruct);
+ ostream.write_string(value.str);
+ org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.write(ostream, value.str_list);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(ostream, value.twoDimSeq);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write(ostream, value.threeDimSeq);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.java
new file mode 100644
index 0000000000..3231a136dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class SomeStructHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct value = null;
+
+ public SomeStructHolder() {
+ }
+
+ public SomeStructHolder(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.java
new file mode 100644
index 0000000000..28d3ecdc91
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public interface TestObject extends TestObjectOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface TestObject
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java
new file mode 100644
index 0000000000..29ff2edfd2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class TestObjectHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.generated.TestObject that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.TestObject extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_interface_tc(org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper.id(),
+ "TestObject");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.TestObject read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_TestObjectStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.generated.TestObject value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.TestObject narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.TestObject)
+ return (org.apache.tuscany.sca.binding.corba.testing.generated.TestObject)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.TestObject unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.TestObject)
+ return (org.apache.tuscany.sca.binding.corba.testing.generated.TestObject)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.java
new file mode 100644
index 0000000000..b8aea13c8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class TestObjectHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.generated.TestObject value = null;
+
+ public TestObjectHolder() {
+ }
+
+ public TestObjectHolder(org.apache.tuscany.sca.binding.corba.testing.generated.TestObject initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.java
new file mode 100644
index 0000000000..0bacb6746a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.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.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public interface TestObjectOperations {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct pickStructFromArgs(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg1,
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg2,
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg3,
+ int structNumber);
+
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct setStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg);
+
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct setSimpleStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder arg);
+
+ int[] setLongSeq1(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder arg);
+
+ int[][] setLongSeq2(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder arg);
+
+ int[][][] setLongSeq3(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder arg);
+} // interface TestObjectOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java
new file mode 100644
index 0000000000..c6e8c2a4e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public abstract class _ArraysSetterImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _ArraysSetterImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("setBoolean", new java.lang.Integer(0));
+ _methods.put("setChar", new java.lang.Integer(1));
+ _methods.put("setWchar", new java.lang.Integer(2));
+ _methods.put("setOctet", new java.lang.Integer(3));
+ _methods.put("setShort", new java.lang.Integer(4));
+ _methods.put("setUnsignedShort", new java.lang.Integer(5));
+ _methods.put("setLong", new java.lang.Integer(6));
+ _methods.put("setUnsignedLong", new java.lang.Integer(7));
+ _methods.put("setLongLong", new java.lang.Integer(8));
+ _methods.put("setUnsignedLongLong", new java.lang.Integer(9));
+ _methods.put("setFloat", new java.lang.Integer(10));
+ _methods.put("setDouble", new java.lang.Integer(11));
+ _methods.put("setString", new java.lang.Integer(12));
+ _methods.put("setWstring", new java.lang.Integer(13));
+ _methods.put("setRemoteObject", new java.lang.Integer(14));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setBoolean
+ {
+ boolean arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.read(in);
+ boolean $result[] = null;
+ $result = this.setBoolean(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.write(out, $result);
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setChar
+ {
+ char arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.read(in);
+ char $result[] = null;
+ $result = this.setChar(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.write(out, $result);
+ break;
+ }
+
+ case 2: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setWchar
+ {
+ char arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.read(in);
+ char $result[] = null;
+ $result = this.setWchar(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.write(out, $result);
+ break;
+ }
+
+ case 3: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setOctet
+ {
+ byte arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.read(in);
+ byte $result[] = null;
+ $result = this.setOctet(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.write(out, $result);
+ break;
+ }
+
+ case 4: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setShort
+ {
+ short arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.read(in);
+ short $result[] = null;
+ $result = this.setShort(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.write(out, $result);
+ break;
+ }
+
+ case 5: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setUnsignedShort
+ {
+ short arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.read(in);
+ short $result[] = null;
+ $result = this.setUnsignedShort(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.write(out, $result);
+ break;
+ }
+
+ case 6: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setLong
+ {
+ int arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.read(in);
+ int $result[] = null;
+ $result = this.setLong(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.write(out, $result);
+ break;
+ }
+
+ case 7: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setUnsignedLong
+ {
+ int arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.read(in);
+ int $result[] = null;
+ $result = this.setUnsignedLong(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.write(out, $result);
+ break;
+ }
+
+ case 8: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setLongLong
+ {
+ long arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.read(in);
+ long $result[] = null;
+ $result = this.setLongLong(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.write(out, $result);
+ break;
+ }
+
+ case 9: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setUnsignedLongLong
+ {
+ long arg[] =
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.read(in);
+ long $result[] = null;
+ $result = this.setUnsignedLongLong(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper
+ .write(out, $result);
+ break;
+ }
+
+ case 10: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setFloat
+ {
+ float arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.read(in);
+ float $result[] = null;
+ $result = this.setFloat(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.write(out, $result);
+ break;
+ }
+
+ case 11: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setDouble
+ {
+ double arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.read(in);
+ double $result[] = null;
+ $result = this.setDouble(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.write(out, $result);
+ break;
+ }
+
+ case 12: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setString
+ {
+ String arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.read(in);
+ String $result[] = null;
+ $result = this.setString(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.write(out, $result);
+ break;
+ }
+
+ case 13: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setWstring
+ {
+ String arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.read(in);
+ String $result[] = null;
+ $result = this.setWstring(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.write(out, $result);
+ break;
+ }
+
+ case 14: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setRemoteObject
+ {
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject obj[] =
+ org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.read(in);
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject $result[] = null;
+ $result = this.setRemoteObject(obj);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.write(out, $result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _ArraysSetterImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java
new file mode 100644
index 0000000000..079cc6e899
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java
@@ -0,0 +1,343 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public class _ArraysSetterStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter {
+
+ public boolean[] setBoolean(boolean[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setBoolean", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.write($out, arg);
+ $in = _invoke($out);
+ boolean $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setBoolean(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setBoolean
+
+ public char[] setChar(char[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setChar", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.write($out, arg);
+ $in = _invoke($out);
+ char $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setChar(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setChar
+
+ public char[] setWchar(char[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setWchar", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.write($out, arg);
+ $in = _invoke($out);
+ char $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setWchar(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setWchar
+
+ public byte[] setOctet(byte[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setOctet", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.write($out, arg);
+ $in = _invoke($out);
+ byte $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setOctet(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setOctet
+
+ public short[] setShort(short[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setShort", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.write($out, arg);
+ $in = _invoke($out);
+ short $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setShort(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setShort
+
+ public short[] setUnsignedShort(short[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedShort", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.write($out, arg);
+ $in = _invoke($out);
+ short $result[] =
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setUnsignedShort(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setUnsignedShort
+
+ public int[] setLong(int[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setLong", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.write($out, arg);
+ $in = _invoke($out);
+ int $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setLong(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setLong
+
+ public int[] setUnsignedLong(int[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedLong", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.write($out, arg);
+ $in = _invoke($out);
+ int $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setUnsignedLong(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setUnsignedLong
+
+ public long[] setLongLong(long[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setLongLong", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.write($out, arg);
+ $in = _invoke($out);
+ long $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setLongLong(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setLongLong
+
+ public long[] setUnsignedLongLong(long[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedLongLong", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.write($out, arg);
+ $in = _invoke($out);
+ long $result[] =
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setUnsignedLongLong(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setUnsignedLongLong
+
+ public float[] setFloat(float[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setFloat", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.write($out, arg);
+ $in = _invoke($out);
+ float $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setFloat(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setFloat
+
+ public double[] setDouble(double[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setDouble", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.write($out, arg);
+ $in = _invoke($out);
+ double $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setDouble(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setDouble
+
+ public String[] setString(String[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setString", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.write($out, arg);
+ $in = _invoke($out);
+ String $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setString(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setString
+
+ public String[] setWstring(String[] arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setWstring", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.write($out, arg);
+ $in = _invoke($out);
+ String $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setWstring(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setWstring
+
+ public org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] setRemoteObject(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] obj) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setRemoteObject", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.write($out, obj);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject $result[] =
+ org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setRemoteObject(obj);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setRemoteObject
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _ArraysSetterStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java
new file mode 100644
index 0000000000..b444ce68d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public abstract class _PrimitivesSetterImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _PrimitivesSetterImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("setBoolean", new java.lang.Integer(0));
+ _methods.put("setChar", new java.lang.Integer(1));
+ _methods.put("setWchar", new java.lang.Integer(2));
+ _methods.put("setOctet", new java.lang.Integer(3));
+ _methods.put("setShort", new java.lang.Integer(4));
+ _methods.put("setUnsignedShort", new java.lang.Integer(5));
+ _methods.put("setLong", new java.lang.Integer(6));
+ _methods.put("setUnsignedLong", new java.lang.Integer(7));
+ _methods.put("setLongLong", new java.lang.Integer(8));
+ _methods.put("setUnsignedLongLong", new java.lang.Integer(9));
+ _methods.put("setFloat", new java.lang.Integer(10));
+ _methods.put("setDouble", new java.lang.Integer(11));
+ _methods.put("setString", new java.lang.Integer(12));
+ _methods.put("setWstring", new java.lang.Integer(13));
+ _methods.put("setRemoteObject", new java.lang.Integer(14));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setBoolean
+ {
+ boolean arg = in.read_boolean();
+ boolean $result = false;
+ $result = this.setBoolean(arg);
+ out = $rh.createReply();
+ out.write_boolean($result);
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setChar
+ {
+ char arg = in.read_char();
+ char $result = (char)0;
+ $result = this.setChar(arg);
+ out = $rh.createReply();
+ out.write_char($result);
+ break;
+ }
+
+ case 2: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setWchar
+ {
+ char arg = in.read_wchar();
+ char $result = (char)0;
+ $result = this.setWchar(arg);
+ out = $rh.createReply();
+ out.write_wchar($result);
+ break;
+ }
+
+ case 3: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setOctet
+ {
+ byte arg = in.read_octet();
+ byte $result = (byte)0;
+ $result = this.setOctet(arg);
+ out = $rh.createReply();
+ out.write_octet($result);
+ break;
+ }
+
+ case 4: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setShort
+ {
+ short arg = in.read_short();
+ short $result = (short)0;
+ $result = this.setShort(arg);
+ out = $rh.createReply();
+ out.write_short($result);
+ break;
+ }
+
+ case 5: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setUnsignedShort
+ {
+ short arg = in.read_ushort();
+ short $result = (short)0;
+ $result = this.setUnsignedShort(arg);
+ out = $rh.createReply();
+ out.write_ushort($result);
+ break;
+ }
+
+ case 6: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setLong
+ {
+ int arg = in.read_long();
+ int $result = (int)0;
+ $result = this.setLong(arg);
+ out = $rh.createReply();
+ out.write_long($result);
+ break;
+ }
+
+ case 7: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setUnsignedLong
+ {
+ int arg = in.read_ulong();
+ int $result = (int)0;
+ $result = this.setUnsignedLong(arg);
+ out = $rh.createReply();
+ out.write_ulong($result);
+ break;
+ }
+
+ case 8: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setLongLong
+ {
+ long arg = in.read_longlong();
+ long $result = (long)0;
+ $result = this.setLongLong(arg);
+ out = $rh.createReply();
+ out.write_longlong($result);
+ break;
+ }
+
+ case 9: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setUnsignedLongLong
+ {
+ long arg = in.read_ulonglong();
+ long $result = (long)0;
+ $result = this.setUnsignedLongLong(arg);
+ out = $rh.createReply();
+ out.write_ulonglong($result);
+ break;
+ }
+
+ case 10: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setFloat
+ {
+ float arg = in.read_float();
+ float $result = (float)0;
+ $result = this.setFloat(arg);
+ out = $rh.createReply();
+ out.write_float($result);
+ break;
+ }
+
+ case 11: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setDouble
+ {
+ double arg = in.read_double();
+ double $result = (double)0;
+ $result = this.setDouble(arg);
+ out = $rh.createReply();
+ out.write_double($result);
+ break;
+ }
+
+ case 12: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setString
+ {
+ String arg = in.read_string();
+ String $result = null;
+ $result = this.setString(arg);
+ out = $rh.createReply();
+ out.write_string($result);
+ break;
+ }
+
+ case 13: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setWstring
+ {
+ String arg = in.read_wstring();
+ String $result = null;
+ $result = this.setWstring(arg);
+ out = $rh.createReply();
+ out.write_wstring($result);
+ break;
+ }
+
+ case 14: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setRemoteObject
+ {
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject obj =
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.read(in);
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject $result = null;
+ $result = this.setRemoteObject(obj);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.write(out, $result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _PrimitivesSetterImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java
new file mode 100644
index 0000000000..0b08e1fb67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public class _PrimitivesSetterStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter {
+
+ public boolean setBoolean(boolean arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setBoolean", true);
+ $out.write_boolean(arg);
+ $in = _invoke($out);
+ boolean $result = $in.read_boolean();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setBoolean(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setBoolean
+
+ public char setChar(char arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setChar", true);
+ $out.write_char(arg);
+ $in = _invoke($out);
+ char $result = $in.read_char();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setChar(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setChar
+
+ public char setWchar(char arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setWchar", true);
+ $out.write_wchar(arg);
+ $in = _invoke($out);
+ char $result = $in.read_wchar();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setWchar(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setWchar
+
+ public byte setOctet(byte arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setOctet", true);
+ $out.write_octet(arg);
+ $in = _invoke($out);
+ byte $result = $in.read_octet();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setOctet(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setOctet
+
+ public short setShort(short arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setShort", true);
+ $out.write_short(arg);
+ $in = _invoke($out);
+ short $result = $in.read_short();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setShort(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setShort
+
+ public short setUnsignedShort(short arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedShort", true);
+ $out.write_ushort(arg);
+ $in = _invoke($out);
+ short $result = $in.read_ushort();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setUnsignedShort(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setUnsignedShort
+
+ public int setLong(int arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setLong", true);
+ $out.write_long(arg);
+ $in = _invoke($out);
+ int $result = $in.read_long();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setLong(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setLong
+
+ public int setUnsignedLong(int arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedLong", true);
+ $out.write_ulong(arg);
+ $in = _invoke($out);
+ int $result = $in.read_ulong();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setUnsignedLong(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setUnsignedLong
+
+ public long setLongLong(long arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setLongLong", true);
+ $out.write_longlong(arg);
+ $in = _invoke($out);
+ long $result = $in.read_longlong();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setLongLong(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setLongLong
+
+ public long setUnsignedLongLong(long arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedLongLong", true);
+ $out.write_ulonglong(arg);
+ $in = _invoke($out);
+ long $result = $in.read_ulonglong();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setUnsignedLongLong(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setUnsignedLongLong
+
+ public float setFloat(float arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setFloat", true);
+ $out.write_float(arg);
+ $in = _invoke($out);
+ float $result = $in.read_float();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setFloat(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setFloat
+
+ public double setDouble(double arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setDouble", true);
+ $out.write_double(arg);
+ $in = _invoke($out);
+ double $result = $in.read_double();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setDouble(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setDouble
+
+ public String setString(String arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setString", true);
+ $out.write_string(arg);
+ $in = _invoke($out);
+ String $result = $in.read_string();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setString(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setString
+
+ public String setWstring(String arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setWstring", true);
+ $out.write_wstring(arg);
+ $in = _invoke($out);
+ String $result = $in.read_wstring();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setWstring(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setWstring
+
+ public org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject setRemoteObject(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject obj) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setRemoteObject", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.write($out, obj);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject $result =
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setRemoteObject(obj);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setRemoteObject
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _PrimitivesSetterStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.java
new file mode 100644
index 0000000000..a87534f88b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public abstract class _RemoteObjectImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _RemoteObjectImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _RemoteObjectImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java
new file mode 100644
index 0000000000..e219dfa338
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public class _RemoteObjectStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject {
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _RemoteObjectStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java
new file mode 100644
index 0000000000..c0bc0d6ebd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public abstract class _TestObjectImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.generated.TestObject, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _TestObjectImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("pickStructFromArgs", new java.lang.Integer(0));
+ _methods.put("setStruct", new java.lang.Integer(1));
+ _methods.put("setSimpleStruct", new java.lang.Integer(2));
+ _methods.put("setLongSeq1", new java.lang.Integer(3));
+ _methods.put("setLongSeq2", new java.lang.Integer(4));
+ _methods.put("setLongSeq3", new java.lang.Integer(5));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/pickStructFromArgs
+ {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg1 =
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(in);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg2 =
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(in);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg3 =
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(in);
+ int structNumber = in.read_long();
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct $result = null;
+ $result = this.pickStructFromArgs(arg1, arg2, arg3, structNumber);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write(out, $result);
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setStruct
+ {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg =
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(in);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct $result = null;
+ $result = this.setStruct(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write(out, $result);
+ break;
+ }
+
+ case 2: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setSimpleStruct
+ {
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder arg =
+ new org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder();
+ arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read(in);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct $result = null;
+ $result = this.setSimpleStruct(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write(out, $result);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write(out, arg.value);
+ break;
+ }
+
+ case 3: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setLongSeq1
+ {
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder arg =
+ new org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder();
+ arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read(in);
+ int $result[] = null;
+ $result = this.setLongSeq1(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write(out, $result);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write(out, arg.value);
+ break;
+ }
+
+ case 4: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setLongSeq2
+ {
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder arg =
+ new org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder();
+ arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read(in);
+ int $result[][] = null;
+ $result = this.setLongSeq2(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(out, $result);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(out, arg.value);
+ break;
+ }
+
+ case 5: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setLongSeq3
+ {
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder arg =
+ new org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder();
+ arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read(in);
+ int $result[][][] = null;
+ $result = this.setLongSeq3(arg);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write(out, $result);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write(out, arg.value);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _TestObjectImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java
new file mode 100644
index 0000000000..ad47595ddf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public class _TestObjectStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.generated.TestObject {
+
+ public org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct pickStructFromArgs(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg1,
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg2,
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg3,
+ int structNumber) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("pickStructFromArgs", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write($out, arg1);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write($out, arg2);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write($out, arg3);
+ $out.write_long(structNumber);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct $result =
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return pickStructFromArgs(arg1, arg2, arg3, structNumber);
+ } finally {
+ _releaseReply($in);
+ }
+ } // pickStructFromArgs
+
+ public org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct setStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setStruct", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write($out, arg);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct $result =
+ org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setStruct(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setStruct
+
+ public org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct setSimpleStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setSimpleStruct", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write($out, arg.value);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct $result =
+ org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read($in);
+ arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setSimpleStruct(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setSimpleStruct
+
+ public int[] setLongSeq1(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setLongSeq1", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write($out, arg.value);
+ $in = _invoke($out);
+ int $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read($in);
+ arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setLongSeq1(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setLongSeq1
+
+ public int[][] setLongSeq2(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setLongSeq2", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write($out, arg.value);
+ $in = _invoke($out);
+ int $result[][] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read($in);
+ arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setLongSeq2(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setLongSeq2
+
+ public int[][][] setLongSeq3(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("setLongSeq3", true);
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write($out, arg.value);
+ $in = _invoke($out);
+ int $result[][][] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read($in);
+ arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return setLongSeq3(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // setLongSeq3
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _TestObjectStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.java
new file mode 100644
index 0000000000..f3d96e8fd7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+abstract public class boolean_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/boolean_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, boolean[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static boolean[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_boolean);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.id(),
+ "boolean_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static boolean[] read(org.omg.CORBA.portable.InputStream istream) {
+ boolean value[] = null;
+ int _len0 = istream.read_long();
+ value = new boolean[_len0];
+ istream.read_boolean_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, boolean[] value) {
+ ostream.write_long(value.length);
+ ostream.write_boolean_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.java
new file mode 100644
index 0000000000..cb0ab8bcfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public final class boolean_listHolder implements org.omg.CORBA.portable.Streamable {
+ public boolean value[] = null;
+
+ public boolean_listHolder() {
+ }
+
+ public boolean_listHolder(boolean[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.java
new file mode 100644
index 0000000000..0bde1e701c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+abstract public class char_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/char_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, char[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static char[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_char);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.id(),
+ "char_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static char[] read(org.omg.CORBA.portable.InputStream istream) {
+ char value[] = null;
+ int _len0 = istream.read_long();
+ value = new char[_len0];
+ istream.read_char_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, char[] value) {
+ ostream.write_long(value.length);
+ ostream.write_char_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.java
new file mode 100644
index 0000000000..19b2942cfe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public final class char_listHolder implements org.omg.CORBA.portable.Streamable {
+ public char value[] = null;
+
+ public char_listHolder() {
+ }
+
+ public char_listHolder(char[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.java
new file mode 100644
index 0000000000..8bb5a9c69d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+abstract public class double_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/double_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, double[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static double[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_double);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.id(),
+ "double_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static double[] read(org.omg.CORBA.portable.InputStream istream) {
+ double value[] = null;
+ int _len0 = istream.read_long();
+ value = new double[_len0];
+ istream.read_double_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, double[] value) {
+ ostream.write_long(value.length);
+ ostream.write_double_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.java
new file mode 100644
index 0000000000..dc89e71092
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public final class double_listHolder implements org.omg.CORBA.portable.Streamable {
+ public double value[] = null;
+
+ public double_listHolder() {
+ }
+
+ public double_listHolder(double[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.java
new file mode 100644
index 0000000000..7b71aa0a9f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+abstract public class float_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/float_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, float[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static float[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_float);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.id(),
+ "float_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static float[] read(org.omg.CORBA.portable.InputStream istream) {
+ float value[] = null;
+ int _len0 = istream.read_long();
+ value = new float[_len0];
+ istream.read_float_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, float[] value) {
+ ostream.write_long(value.length);
+ ostream.write_float_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.java
new file mode 100644
index 0000000000..513bab37cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public final class float_listHolder implements org.omg.CORBA.portable.Streamable {
+ public float value[] = null;
+
+ public float_listHolder() {
+ }
+
+ public float_listHolder(float[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.java
new file mode 100644
index 0000000000..c1d06e2ba9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+abstract public class long_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, int[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static int[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.id(),
+ "long_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static int[] read(org.omg.CORBA.portable.InputStream istream) {
+ int value[] = null;
+ int _len0 = istream.read_long();
+ value = new int[_len0];
+ istream.read_long_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, int[] value) {
+ ostream.write_long(value.length);
+ ostream.write_long_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.java
new file mode 100644
index 0000000000..f9ad7b77ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public final class long_listHolder implements org.omg.CORBA.portable.Streamable {
+ public int value[] = null;
+
+ public long_listHolder() {
+ }
+
+ public long_listHolder(int[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.java
new file mode 100644
index 0000000000..cfb292fc01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+abstract public class long_long_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_long_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, long[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static long[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_longlong);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.id(),
+ "long_long_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static long[] read(org.omg.CORBA.portable.InputStream istream) {
+ long value[] = null;
+ int _len0 = istream.read_long();
+ value = new long[_len0];
+ istream.read_longlong_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, long[] value) {
+ ostream.write_long(value.length);
+ ostream.write_longlong_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.java
new file mode 100644
index 0000000000..02f46a7d85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 14:12:28 CEST
+*/
+
+public final class long_long_listHolder implements org.omg.CORBA.portable.Streamable {
+ public long value[] = null;
+
+ public long_long_listHolder() {
+ }
+
+ public long_long_listHolder(long[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.java
new file mode 100644
index 0000000000..505aa3f026
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class long_seq1Helper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, int[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static int[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.id(),
+ "long_seq1",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static int[] read(org.omg.CORBA.portable.InputStream istream) {
+ int value[] = null;
+ int _len0 = istream.read_long();
+ value = new int[_len0];
+ istream.read_long_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, int[] value) {
+ ostream.write_long(value.length);
+ ostream.write_long_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.java
new file mode 100644
index 0000000000..5cbaa109ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class long_seq1Holder implements org.omg.CORBA.portable.Streamable {
+ public int value[] = null;
+
+ public long_seq1Holder() {
+ }
+
+ public long_seq1Holder(int[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.java
new file mode 100644
index 0000000000..2f792888fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.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.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class long_seq2Helper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, int[][] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static int[][] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.id(),
+ "long_seq1",
+ __typeCode);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.id(),
+ "long_seq2",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static int[][] read(org.omg.CORBA.portable.InputStream istream) {
+ int value[][] = null;
+ int _len0 = istream.read_long();
+ value = new int[_len0][];
+ for (int _o1 = 0; _o1 < value.length; ++_o1)
+ value[_o1] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read(istream);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, int[][] value) {
+ ostream.write_long(value.length);
+ for (int _i0 = 0; _i0 < value.length; ++_i0)
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write(ostream, value[_i0]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.java
new file mode 100644
index 0000000000..8b2ccc1f73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class long_seq2Holder implements org.omg.CORBA.portable.Streamable {
+ public int value[][] = null;
+
+ public long_seq2Holder() {
+ }
+
+ public long_seq2Holder(int[][] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.java
new file mode 100644
index 0000000000..67e224f0be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class long_seq3Helper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, int[][][] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static int[][][] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.id(),
+ "long_seq1",
+ __typeCode);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.id(),
+ "long_seq2",
+ __typeCode);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.id(),
+ "long_seq3",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static int[][][] read(org.omg.CORBA.portable.InputStream istream) {
+ int value[][][] = null;
+ int _len0 = istream.read_long();
+ value = new int[_len0][][];
+ for (int _o1 = 0; _o1 < value.length; ++_o1)
+ value[_o1] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read(istream);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, int[][][] value) {
+ ostream.write_long(value.length);
+ for (int _i0 = 0; _i0 < value.length; ++_i0)
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(ostream, value[_i0]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.java
new file mode 100644
index 0000000000..5d4adfba2d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class long_seq3Holder implements org.omg.CORBA.portable.Streamable {
+ public int value[][][] = null;
+
+ public long_seq3Holder() {
+ }
+
+ public long_seq3Holder(int[][][] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.java
new file mode 100644
index 0000000000..c7d86d9179
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class octet_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/octet_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, byte[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static byte[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_octet);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.id(),
+ "octet_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static byte[] read(org.omg.CORBA.portable.InputStream istream) {
+ byte value[] = null;
+ int _len0 = istream.read_long();
+ value = new byte[_len0];
+ istream.read_octet_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, byte[] value) {
+ ostream.write_long(value.length);
+ ostream.write_octet_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.java
new file mode 100644
index 0000000000..09b2b85c6a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class octet_listHolder implements org.omg.CORBA.portable.Streamable {
+ public byte value[] = null;
+
+ public octet_listHolder() {
+ }
+
+ public octet_listHolder(byte[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java
new file mode 100644
index 0000000000..e88b1e06c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class remote_object_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.type();
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper
+ .id(),
+ "remote_object_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] read(org.omg.CORBA.portable.InputStream istream) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject value[] = null;
+ int _len0 = istream.read_long();
+ value = new org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[_len0];
+ for (int _o1 = 0; _o1 < value.length; ++_o1)
+ value[_o1] = org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.read(istream);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] value) {
+ ostream.write_long(value.length);
+ for (int _i0 = 0; _i0 < value.length; ++_i0)
+ org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.write(ostream, value[_i0]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.java
new file mode 100644
index 0000000000..d3f996c5b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class remote_object_listHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject value[] = null;
+
+ public remote_object_listHolder() {
+ }
+
+ public remote_object_listHolder(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.java
new file mode 100644
index 0000000000..7c58d47f7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class short_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/short_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, short[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static short[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_short);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.id(),
+ "short_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static short[] read(org.omg.CORBA.portable.InputStream istream) {
+ short value[] = null;
+ int _len0 = istream.read_long();
+ value = new short[_len0];
+ istream.read_short_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, short[] value) {
+ ostream.write_long(value.length);
+ ostream.write_short_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.java
new file mode 100644
index 0000000000..5be5a65c43
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class short_listHolder implements org.omg.CORBA.portable.Streamable {
+ public short value[] = null;
+
+ public short_listHolder() {
+ }
+
+ public short_listHolder(short[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java
new file mode 100644
index 0000000000..a40d5fa8de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class string_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/string_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, String[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static String[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().create_string_tc(0);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.id(),
+ "string_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static String[] read(org.omg.CORBA.portable.InputStream istream) {
+ String value[] = null;
+ int _len0 = istream.read_long();
+ value = new String[_len0];
+ for (int _o1 = 0; _o1 < value.length; ++_o1)
+ value[_o1] = istream.read_string();
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, String[] value) {
+ ostream.write_long(value.length);
+ for (int _i0 = 0; _i0 < value.length; ++_i0)
+ ostream.write_string(value[_i0]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.java
new file mode 100644
index 0000000000..76f99408f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class string_listHolder implements org.omg.CORBA.portable.Streamable {
+ public String value[] = null;
+
+ public string_listHolder() {
+ }
+
+ public string_listHolder(String[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.java
new file mode 100644
index 0000000000..d7594b0815
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class unsigned_long_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, int[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static int[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper
+ .id(),
+ "unsigned_long_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static int[] read(org.omg.CORBA.portable.InputStream istream) {
+ int value[] = null;
+ int _len0 = istream.read_long();
+ value = new int[_len0];
+ istream.read_ulong_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, int[] value) {
+ ostream.write_long(value.length);
+ ostream.write_ulong_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.java
new file mode 100644
index 0000000000..e9fbcccc36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class unsigned_long_listHolder implements org.omg.CORBA.portable.Streamable {
+ public int value[] = null;
+
+ public unsigned_long_listHolder() {
+ }
+
+ public unsigned_long_listHolder(int[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.java
new file mode 100644
index 0000000000..6ef187c4e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class unsigned_long_long_listHelper {
+ private static String _id =
+ "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, long[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static long[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_ulonglong);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB
+ .init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper
+ .id(),
+ "unsigned_long_long_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static long[] read(org.omg.CORBA.portable.InputStream istream) {
+ long value[] = null;
+ int _len0 = istream.read_long();
+ value = new long[_len0];
+ istream.read_ulonglong_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, long[] value) {
+ ostream.write_long(value.length);
+ ostream.write_ulonglong_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.java
new file mode 100644
index 0000000000..59bc015c38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class unsigned_long_long_listHolder implements org.omg.CORBA.portable.Streamable {
+ public long value[] = null;
+
+ public unsigned_long_long_listHolder() {
+ }
+
+ public unsigned_long_long_listHolder(long[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.java
new file mode 100644
index 0000000000..ec4526cebf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class unsigned_short_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, short[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static short[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_ushort);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper
+ .id(),
+ "unsigned_short_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static short[] read(org.omg.CORBA.portable.InputStream istream) {
+ short value[] = null;
+ int _len0 = istream.read_long();
+ value = new short[_len0];
+ istream.read_ushort_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, short[] value) {
+ ostream.write_long(value.length);
+ ostream.write_ushort_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.java
new file mode 100644
index 0000000000..56ab28f0be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class unsigned_short_listHolder implements org.omg.CORBA.portable.Streamable {
+ public short value[] = null;
+
+ public unsigned_short_listHolder() {
+ }
+
+ public unsigned_short_listHolder(short[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.java
new file mode 100644
index 0000000000..73a10d3b7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.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.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class wchar_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/wchar_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, char[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static char[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_wchar);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.id(),
+ "wchar_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static char[] read(org.omg.CORBA.portable.InputStream istream) {
+ char value[] = null;
+ int _len0 = istream.read_long();
+ value = new char[_len0];
+ istream.read_wchar_array(value, 0, _len0);
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, char[] value) {
+ ostream.write_long(value.length);
+ ostream.write_wchar_array(value, 0, value.length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.java
new file mode 100644
index 0000000000..c5c1e87756
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class wchar_listHolder implements org.omg.CORBA.portable.Streamable {
+ public char value[] = null;
+
+ public wchar_listHolder() {
+ }
+
+ public wchar_listHolder(char[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java
new file mode 100644
index 0000000000..3e45568f01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+abstract public class wstring_listHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/wstring_list:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, String[] that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static String[] extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode = org.omg.CORBA.ORB.init().create_wstring_tc(0);
+ __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode);
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.id(),
+ "wstring_list",
+ __typeCode);
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static String[] read(org.omg.CORBA.portable.InputStream istream) {
+ String value[] = null;
+ int _len0 = istream.read_long();
+ value = new String[_len0];
+ for (int _o1 = 0; _o1 < value.length; ++_o1)
+ value[_o1] = istream.read_wstring();
+ return value;
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream, String[] value) {
+ ostream.write_long(value.length);
+ for (int _i0 = 0; _i0 < value.length; ++_i0)
+ ostream.write_wstring(value[_i0]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.java
new file mode 100644
index 0000000000..bdbf9d995b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.generated;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+* monday, 23 june 2008 2008 14:12:28 CEST
+*/
+
+public final class wstring_listHolder implements org.omg.CORBA.portable.Streamable {
+ public String value[] = null;
+
+ public wstring_listHolder() {
+ }
+
+ public wstring_listHolder(String[] initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/ArraysTestStruct.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/ArraysTestStruct.java
new file mode 100644
index 0000000000..ba1a5c0a51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/ArraysTestStruct.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray;
+
+public final class ArraysTestStruct {
+
+ public ArraysTestStruct() {
+
+ }
+
+ public ArraysTestStruct(String[] field1, int[][] field2, float[][][] field3) {
+ this.field1 = field1;
+ this.field2 = field2;
+ this.field3 = field3;
+ }
+
+ @CorbaArray( {2})
+ public String[] field1;
+
+ @CorbaArray( {2, 4})
+ public int[][] field2;
+
+ @CorbaArray( {2, 4, 2})
+ public float[][][] field3;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/Calc.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/Calc.java
new file mode 100644
index 0000000000..7c33b1d449
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/Calc.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.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero;
+
+public interface Calc {
+
+ public double div(double arg1, double arg2) throws DivByZero;
+
+ public double divForSmallArgs(double arg1, double arg2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/DummyObject.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/DummyObject.java
new file mode 100644
index 0000000000..d0ebff5fec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/DummyObject.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 org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+public interface DummyObject {
+
+ int getLong();
+
+ DummyObject cloneObject();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InnerUnion.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InnerUnion.java
new file mode 100644
index 0000000000..6e4204b9b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InnerUnion.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+public final class InnerUnion {
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1)
+ private int x;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 2)
+ private float y;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private int discriminator;
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ discriminator = 1;
+ this.x = x;
+ }
+
+ public float getY() {
+ return y;
+ }
+
+ public void setY(float y) {
+ discriminator = 2;
+ this.y = y;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidCorbaArray.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidCorbaArray.java
new file mode 100644
index 0000000000..cb3b6842c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidCorbaArray.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 org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray;
+
+public final class InvalidCorbaArray {
+
+ // annotation argument array is not equal to declared arrays dimension
+ @CorbaArray( {1})
+ public String[][] array;
+
+ public InvalidCorbaArray() {
+
+ }
+
+ public InvalidCorbaArray(String[][] arg) {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java
new file mode 100644
index 0000000000..0c9de5bb31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.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 org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+public class InvalidEnum1 {
+
+ public static final InvalidEnum1 red = new InvalidEnum1(0);
+
+ public int value() {
+ return 0;
+ }
+
+ public static InvalidEnum1 from_int(int value) {
+ return null;
+ }
+
+ protected InvalidEnum1(int value) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java
new file mode 100644
index 0000000000..8746eb7f9b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+public class InvalidEnum2 {
+
+ public static final int _red = 0;
+ public static final InvalidEnum2 red = new InvalidEnum2(_red);
+
+ public static InvalidEnum2 from_int(int value) {
+ return null;
+ }
+
+ protected InvalidEnum2(int value) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java
new file mode 100644
index 0000000000..6d124b0485
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+public class InvalidEnum3 {
+
+ public static final int _red = 0;
+ public static final InvalidEnum2 red = new InvalidEnum2(_red);
+
+ public int value() {
+ return 0;
+ }
+
+ protected InvalidEnum3(int value) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java
new file mode 100644
index 0000000000..8cf66e2fac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.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 org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+public final class InvalidStruct1 {
+
+ public InvalidStruct1() {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java
new file mode 100644
index 0000000000..5f361512f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.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.sca.binding.corba.testing.hierarchy;
+
+public final class InvalidStruct2 {
+
+ public int f1;
+ public String f2;
+
+ public InvalidStruct2(int f1, String f2) {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java
new file mode 100644
index 0000000000..adc81ea5a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.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 org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+public final class InvalidStruct3 {
+
+ public int f1;
+ public String f2;
+ public static byte f3;
+
+ public InvalidStruct3() {
+
+ }
+
+ public InvalidStruct3(int f1, String f2, byte f3) {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion1.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion1.java
new file mode 100644
index 0000000000..4f6d0085af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion1.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.sca.binding.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+/**
+ * More than one discriminators
+ */
+public final class InvalidUnion1 {
+
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private int a;
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private int b;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion2.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion2.java
new file mode 100644
index 0000000000..98462bbabe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion2.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+/**
+ * Discriminator is missing
+ */
+public final class InvalidUnion2 {
+
+ @CorbaUnionElement(type=CorbaUnionElementType.defaultOption)
+ @SuppressWarnings("unused")
+ private int a;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion3.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion3.java
new file mode 100644
index 0000000000..994ed6aea3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion3.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 org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+/**
+ * No option, only discriminator
+ */
+public final class InvalidUnion3{
+
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private int a;
+
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion4.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion4.java
new file mode 100644
index 0000000000..d68d903375
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion4.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.sca.binding.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+/**
+ * Invalid field modifiers
+ */
+public final class InvalidUnion4{
+
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private static int a;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.defaultOption)
+ @SuppressWarnings("unused")
+ private static int b;
+
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion5.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion5.java
new file mode 100644
index 0000000000..d4f8b0e6fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion5.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+/**
+ * Reused option id
+ */
+public final class InvalidUnion5 {
+
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private int a;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1)
+ @SuppressWarnings("unused")
+ private int b;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1)
+ @SuppressWarnings("unused")
+ private int c;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/NonCorbaException.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/NonCorbaException.java
new file mode 100644
index 0000000000..a514b5e222
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/NonCorbaException.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 org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+public class NonCorbaException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public String someField;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/RichUnion.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/RichUnion.java
new file mode 100644
index 0000000000..452dee8d95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/RichUnion.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.sca.binding.corba.testing.hierarchy;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement;
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType;
+
+public final class RichUnion {
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1)
+ private int x;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 2)
+ private float y;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 3)
+ private String z;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 4)
+ private InnerUnion iu;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.defaultOption)
+ private boolean def;
+
+ @CorbaUnionElement(type = CorbaUnionElementType.discriminator)
+ @SuppressWarnings("unused")
+ private int discriminator = -1;
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ this.discriminator = 1;
+ this.x = x;
+ }
+
+ public float getY() {
+ return y;
+ }
+
+ public void setY(float y) {
+ this.discriminator = 2;
+ this.y = y;
+ }
+
+ public String getZ() {
+ return z;
+ }
+
+ public void setZ(String z) {
+ this.discriminator = 3;
+ this.z = z;
+ }
+
+ public boolean isDef() {
+ return def;
+ }
+
+ public void setDef(boolean def) {
+ this.discriminator = -1;
+ this.def = def;
+ }
+
+ public InnerUnion getIu() {
+ return iu;
+ }
+
+ public void setIu(InnerUnion iu) {
+ this.discriminator = 4;
+ this.iu = iu;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SimpleStruct.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SimpleStruct.java
new file mode 100644
index 0000000000..85ca3798f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SimpleStruct.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.corba.testing.hierarchy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleStruct {
+
+ public String field1;
+ public int field2;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SomeStruct.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SomeStruct.java
new file mode 100644
index 0000000000..d8cdf1835a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SomeStruct.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.hierarchy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SomeStruct {
+
+ public SimpleStruct innerStruct;
+ public String str;
+ public String[] str_list;
+ public int[][] twoDimSeq;
+ public int[][][] threeDimSeq;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.java
new file mode 100644
index 0000000000..bb72fdbbf3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.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.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public interface DummyObject extends DummyObjectOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface DummyObject
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java
new file mode 100644
index 0000000000..606d333bb3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+abstract public class DummyObjectHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/references/DummyObject:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.references.DummyObject extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB
+ .init()
+ .create_interface_tc(org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.id(),
+ "DummyObject");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.references.DummyObject read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_DummyObjectStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.references.DummyObject narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.references.DummyObject)
+ return (org.apache.tuscany.sca.binding.corba.testing.references.DummyObject)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.references.DummyObject unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.references.DummyObject)
+ return (org.apache.tuscany.sca.binding.corba.testing.references.DummyObject)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.java
new file mode 100644
index 0000000000..0ff9540502
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public final class DummyObjectHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.references.DummyObject value = null;
+
+ public DummyObjectHolder() {
+ }
+
+ public DummyObjectHolder(org.apache.tuscany.sca.binding.corba.testing.references.DummyObject initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.java
new file mode 100644
index 0000000000..912bd16f9b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public interface DummyObjectOperations {
+ int getLong();
+
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject cloneObject();
+} // interface DummyObjectOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.java
new file mode 100644
index 0000000000..79f7959c72
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.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.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public interface ObjectManager extends ObjectManagerOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface ObjectManager
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java
new file mode 100644
index 0000000000..495a614d84
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+abstract public class ObjectManagerHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_interface_tc(org.apache.tuscany.sca.binding.corba.testing.references.ObjectManagerHelper
+ .id(),
+ "ObjectManager");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_ObjectManagerStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager)
+ return (org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager)
+ return (org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerStub stub =
+ new org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.java
new file mode 100644
index 0000000000..11cfc82ac2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public final class ObjectManagerHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager value = null;
+
+ public ObjectManagerHolder() {
+ }
+
+ public ObjectManagerHolder(org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.binding.corba.testing.references.ObjectManagerHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.binding.corba.testing.references.ObjectManagerHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.binding.corba.testing.references.ObjectManagerHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.java
new file mode 100644
index 0000000000..e0e56d1017
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public interface ObjectManagerOperations {
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject getDummyObject();
+
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject getObjectByArgument(org.apache.tuscany.sca.binding.corba.testing.references.DummyObject dummy);
+} // interface ObjectManagerOperations
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java
new file mode 100644
index 0000000000..c706661eaa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public abstract class _DummyObjectImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _DummyObjectImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("getLong", new java.lang.Integer(0));
+ _methods.put("cloneObject", new java.lang.Integer(1));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/binding/corba/testing/references/DummyObject/getLong
+ {
+ int $result = (int)0;
+ $result = this.getLong();
+ out = $rh.createReply();
+ out.write_long($result);
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/binding/corba/testing/references/DummyObject/cloneObject
+ {
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = null;
+ $result = this.cloneObject();
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write(out, $result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/references/DummyObject:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _DummyObjectImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java
new file mode 100644
index 0000000000..c9a31deb27
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public class _DummyObjectStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject {
+
+ public int getLong() {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("getLong", true);
+ $in = _invoke($out);
+ int $result = $in.read_long();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return getLong();
+ } finally {
+ _releaseReply($in);
+ }
+ } // getLong
+
+ public org.apache.tuscany.sca.binding.corba.testing.references.DummyObject cloneObject() {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("cloneObject", true);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result =
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return cloneObject();
+ } finally {
+ _releaseReply($in);
+ }
+ } // cloneObject
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/references/DummyObject:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _DummyObjectStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java
new file mode 100644
index 0000000000..a6b55b8bae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public abstract class _ObjectManagerImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _ObjectManagerImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("getDummyObject", new java.lang.Integer(0));
+ _methods.put("getObjectByArgument", new java.lang.Integer(1));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager/getDummyObject
+ {
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = null;
+ $result = this.getDummyObject();
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write(out, $result);
+ break;
+ }
+
+ case 1: // org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager/getObjectByArgument
+ {
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject dummy =
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read(in);
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = null;
+ $result = this.getObjectByArgument(dummy);
+ out = $rh.createReply();
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write(out, $result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _ObjectManagerImplBase
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java
new file mode 100644
index 0000000000..e06a078a93
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.references;
+
+/**
+* org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from remote_objects.idl
+* niedziela, 8 czerwiec 2008 16:43:12 CEST
+*/
+
+public class _ObjectManagerStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager {
+
+ public org.apache.tuscany.sca.binding.corba.testing.references.DummyObject getDummyObject() {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("getDummyObject", true);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result =
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return getDummyObject();
+ } finally {
+ _releaseReply($in);
+ }
+ } // getDummyObject
+
+ public org.apache.tuscany.sca.binding.corba.testing.references.DummyObject getObjectByArgument(org.apache.tuscany.sca.binding.corba.testing.references.DummyObject dummy) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("getObjectByArgument", true);
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write($out, dummy);
+ $in = _invoke($out);
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result =
+ org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read($in);
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return getObjectByArgument(dummy);
+ } finally {
+ _releaseReply($in);
+ }
+ } // getObjectByArgument
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager:1.0"};
+
+ @Override
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _ObjectManagerStub
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysSetterServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysSetterServant.java
new file mode 100644
index 0000000000..0aec4d278d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysSetterServant.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.sca.binding.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject;
+import org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterImplBase;
+
+public class ArraysSetterServant extends _ArraysSetterImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public boolean[] setBoolean(boolean[] arg) {
+ return arg;
+ }
+
+ public char[] setChar(char[] arg) {
+ return arg;
+ }
+
+ public double[] setDouble(double[] arg) {
+ return arg;
+ }
+
+ public float[] setFloat(float[] arg) {
+ return arg;
+ }
+
+ public int[] setLong(int[] arg) {
+ return arg;
+ }
+
+ public long[] setLongLong(long[] arg) {
+ return arg;
+ }
+
+ public byte[] setOctet(byte[] arg) {
+ return arg;
+ }
+
+ public RemoteObject[] setRemoteObject(RemoteObject[] obj) {
+ return obj;
+ }
+
+ public short[] setShort(short[] arg) {
+ return arg;
+ }
+
+ public String[] setString(String[] arg) {
+ return arg;
+ }
+
+ public int[] setUnsignedLong(int[] arg) {
+ return arg;
+ }
+
+ public long[] setUnsignedLongLong(long[] arg) {
+ return arg;
+ }
+
+ public short[] setUnsignedShort(short[] arg) {
+ return arg;
+ }
+
+ public char[] setWchar(char[] arg) {
+ return arg;
+ }
+
+ public String[] setWstring(String[] arg) {
+ return arg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsServant.java
new file mode 100644
index 0000000000..d9bde48a5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsServant.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion;
+import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct;
+import org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsImplBase;
+
+public class ArraysUnionsServant extends _ArraysUnionsTestsImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public TestStruct passTestStruct(TestStruct arg) {
+ return arg;
+ }
+
+ public String[][] passStringArray(String[][] arg) {
+ return arg;
+ }
+
+ public RichUnion passRichUnion(RichUnion arg) {
+ return arg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsTuscanyServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsTuscanyServant.java
new file mode 100644
index 0000000000..9ff94f8313
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsTuscanyServant.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.ArraysTestStruct;
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.RichUnion;
+
+public class ArraysUnionsTuscanyServant {
+
+ private static final long serialVersionUID = 1L;
+
+ public ArraysTestStruct passTestStruct(ArraysTestStruct arg) {
+ return arg;
+ }
+
+ @CorbaArray( {2, 2})
+ public String[][] passStringArray(@CorbaArray( {2, 2})String[][] arg) {
+ return arg;
+ }
+
+ public RichUnion passRichUnion(RichUnion arg) {
+ return arg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/CalcServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/CalcServant.java
new file mode 100644
index 0000000000..fd789e19cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/CalcServant.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.binding.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcImplBase;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero;
+import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported;
+
+public class CalcServant extends _CalcImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public double div(double arg1, double arg2) throws DivByZero {
+ if (arg2 == 0) {
+ DivByZero exception = new DivByZero();
+ exception.arguments = new Arguments(arg1, arg2);
+ exception.info = "Error occured during div: div by zero";
+ throw exception;
+ } else {
+ return arg1 / arg2;
+ }
+ }
+
+ public double divForSmallArgs(double arg1, double arg2) throws DivByZero, NotSupported {
+ if (arg1 > 100 || arg2 > 100) {
+ NotSupported exception = new NotSupported();
+ exception.info = "arg1: " + arg1 + ", arg2: " + arg2;
+ throw exception;
+ } else {
+ return div(arg1, arg2);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/DummyObjectServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/DummyObjectServant.java
new file mode 100644
index 0000000000..2e205f1d0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/DummyObjectServant.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.references.DummyObject;
+import org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectImplBase;
+
+public class DummyObjectServant extends _DummyObjectImplBase {
+
+ private static final long serialVersionUID = 1L;
+ private int retVal;
+
+ public DummyObjectServant() {
+ retVal = (int)System.currentTimeMillis();
+ }
+
+ public int getLong() {
+ return retVal;
+ }
+
+ public DummyObject cloneObject() {
+ return new DummyObjectServant();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java
new file mode 100644
index 0000000000..52386aeef7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.enums.Color;
+import org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerImplBase;
+
+public class EnumManagerServant extends _EnumManagerImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public Color getColor(Color color) {
+ return color;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTestObjectServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTestObjectServant.java
new file mode 100644
index 0000000000..b7fbb69627
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTestObjectServant.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.servants;
+
+public class InvalidTestObjectServant {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTypesServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTypesServant.java
new file mode 100644
index 0000000000..dda8203f79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTypesServant.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct1;
+
+public class InvalidTypesServant {
+
+ public InvalidStruct1 firstMethodWithInvalidArg() {
+ return null;
+ }
+
+ public void secondMethodWithInvalidArg(InvalidStruct1 arg) {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/NonCorbaServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/NonCorbaServant.java
new file mode 100644
index 0000000000..20700a0392
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/NonCorbaServant.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 org.apache.tuscany.sca.binding.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.hierarchy.NonCorbaException;
+
+public class NonCorbaServant {
+
+ public String setString(String arg) {
+ return arg;
+ }
+
+ public void throwException() throws NonCorbaException {
+ NonCorbaException e = new NonCorbaException();
+ e.someField = "test";
+ throw e;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ObjectManagerServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ObjectManagerServant.java
new file mode 100644
index 0000000000..213c7fbd7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ObjectManagerServant.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.sca.binding.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.references.DummyObject;
+import org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerImplBase;
+
+public class ObjectManagerServant extends _ObjectManagerImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public DummyObject getObjectByArgument(DummyObject arg) {
+ return arg;
+ }
+
+ public DummyObject getDummyObject() {
+ return new DummyObjectServant();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/PrimitivesSetterServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/PrimitivesSetterServant.java
new file mode 100644
index 0000000000..92e18741ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/PrimitivesSetterServant.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.sca.binding.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject;
+import org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterImplBase;
+
+public class PrimitivesSetterServant extends _PrimitivesSetterImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public boolean setBoolean(boolean arg) {
+ return arg;
+ }
+
+ public char setChar(char arg) {
+ return arg;
+ }
+
+ public double setDouble(double arg) {
+ return arg;
+ }
+
+ public float setFloat(float arg) {
+ return arg;
+ }
+
+ public int setLong(int arg) {
+ return arg;
+ }
+
+ public long setLongLong(long arg) {
+ return arg;
+ }
+
+ public byte setOctet(byte arg) {
+ return arg;
+ }
+
+ public RemoteObject setRemoteObject(RemoteObject obj) {
+ return obj;
+ }
+
+ public short setShort(short arg) {
+ return arg;
+ }
+
+ public String setString(String arg) {
+ return arg;
+ }
+
+ public int setUnsignedLong(int arg) {
+ return arg;
+ }
+
+ public long setUnsignedLongLong(long arg) {
+ return arg;
+ }
+
+ public short setUnsignedShort(short arg) {
+ return arg;
+ }
+
+ public char setWchar(char arg) {
+ return arg;
+ }
+
+ public String setWstring(String arg) {
+ return arg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/TestObjectServant.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/TestObjectServant.java
new file mode 100644
index 0000000000..153268983f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/TestObjectServant.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.corba.testing.servants;
+
+import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct;
+import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder;
+import org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct;
+import org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectImplBase;
+import org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder;
+import org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder;
+import org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestObjectServant extends _TestObjectImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public int[] setLongSeq1(long_seq1Holder arg) {
+ return arg.value;
+ }
+
+ public int[][] setLongSeq2(long_seq2Holder arg) {
+
+ return arg.value;
+ }
+
+ public int[][][] setLongSeq3(long_seq3Holder arg) {
+ return arg.value;
+ }
+
+ public SimpleStruct setSimpleStruct(SimpleStructHolder arg) {
+ return arg.value;
+ }
+
+ public SomeStruct setStruct(SomeStruct arg) {
+ return arg;
+ }
+
+ public SomeStruct pickStructFromArgs(SomeStruct arg1, SomeStruct arg2, SomeStruct arg3, int structNumber) {
+ switch (structNumber) {
+ case 1:
+ return arg1;
+ case 2:
+ return arg2;
+ case 3:
+ return arg3;
+ default:
+ return arg1;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java
new file mode 100644
index 0000000000..7ebc3fce85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.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.corba.testing.service.mocks;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * Mock DataType implementation. Only few methods needs to be implemented.
+ */
+public class TestDataType<L> implements DataType<L> {
+
+ public Class<?> typeClass;
+ public L logical;
+
+ public TestDataType(Class<?> typeClass) {
+ this.typeClass = typeClass;
+ }
+
+ public TestDataType(Class<?> typeClass, L logical) {
+ this.typeClass = typeClass;
+ this.logical = logical;
+ }
+
+ public String getDataBinding() {
+ return null;
+ }
+
+ public Type getGenericType() {
+ return null;
+ }
+
+ public L getLogical() {
+ return logical;
+ }
+
+ public <T> T getMetaData(Class<T> arg0) {
+ return null;
+ }
+
+ public Class<?> getPhysical() {
+ return typeClass;
+ }
+
+ public void setDataBinding(String arg0) {
+
+ }
+
+ public void setGenericType(Type arg0) {
+
+ }
+
+ public void setLogical(L arg0) {
+
+ }
+
+ public <T> void setMetaData(Class<T> arg0, T arg1) {
+
+ }
+
+ public void setPhysical(Class<?> arg0) {
+
+ }
+
+ @Override
+ public Object clone() {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java
new file mode 100644
index 0000000000..0668761e48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.service.mocks;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Mock TestInterface implementation. Only few methods needs to be implemented.
+ */
+public class TestInterface implements JavaInterface {
+
+ private List<Operation> operations;
+ private Class<?> javaClass;
+
+ public TestInterface(List<Operation> opearations, Class<?> javaClass) {
+ this.operations = opearations;
+ this.javaClass = javaClass;
+ }
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ public boolean isConversational() {
+ return false;
+ }
+
+ public boolean isDynamic() {
+ return false;
+ }
+
+ public boolean isRemotable() {
+ return false;
+ }
+
+ public void resetDataBinding(String dataBinding) {
+
+ }
+
+ public void setConversational(boolean conversational) {
+
+ }
+
+ public void setDefaultDataBinding(String dataBinding) {
+
+ }
+
+ public void setRemotable(boolean remotable) {
+
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return null;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return null;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return null;
+ }
+
+ @Override
+ public Object clone() {
+ return null;
+ }
+
+ public Class<?> getCallbackClass() {
+ return null;
+ }
+
+ public Class<?> getJavaClass() {
+ return javaClass;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public QName getQName() {
+ return null;
+ }
+
+ public void setCallbackClass(Class<?> arg0) {
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ this.javaClass = javaClass;
+ }
+
+ public void setName(String arg0) {
+ }
+
+ public void setQName(QName arg0) {
+
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean arg0) {
+ }
+
+ public Map<Object, Object> getAttributes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isRemotableSet() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void resetInterfaceInputTypes(Interface newInterface) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void resetInterfaceOutputTypes(Interface newInterface) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ExtensionType getExtensionType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String getJAXWSJavaInterfaceName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setJAXWSJavaInterfaceName(String javaInterfaceName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String getJAXWSWSDLLocation() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setJAXWSWSDLLocation(String wsdlLocation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Contribution getContributionContainingClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setContributionContainingClass(
+ Contribution contributionContainingClass) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java
new file mode 100644
index 0000000000..6ac4c1ff2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.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.corba.testing.service.mocks;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Mock InterfaceContract implementation. Only few methods needs to be
+ * implemented.
+ */
+public class TestInterfaceContract implements InterfaceContract {
+
+ private Interface iface;
+
+ public Interface getCallbackInterface() {
+ return null;
+ }
+
+ public Interface getInterface() {
+ return iface;
+ }
+
+ public InterfaceContract makeUnidirectional(boolean isCallback) {
+ return null;
+ }
+
+ public void setCallbackInterface(Interface callbackInterface) {
+
+ }
+
+ public void setInterface(Interface callInterface) {
+ this.iface = callInterface;
+ }
+
+ @Override
+ public Object clone() {
+ return null;
+ }
+
+ // By default there is no normailized contract
+ // as only Java needs it
+ public InterfaceContract getNormalizedWSDLContract() {
+ return null;
+ }
+
+ // By default there is no normailized contract
+ // as only Java needs it
+ public void setNormailizedWSDLContract(
+ InterfaceContract wsdlInterfaceContract) {
+ // do nothing
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java
new file mode 100644
index 0000000000..27278dd64e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.service.mocks;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Mock Operation implementation. Only few methods needs to be implemented.
+ */
+public class TestOperation implements Operation {
+
+ private DataType<List<DataType>> inputType;
+ private DataType outputType;
+ private String name;
+
+ public String getDataBinding() {
+ return null;
+ }
+
+ public Map<QName, List<DataType<XMLType>>> getFaultBeans() {
+ return null;
+ }
+
+ public List<DataType> getFaultTypes() {
+ return null;
+ }
+
+ public DataType<List<DataType>> getInputType() {
+ return inputType;
+ }
+
+ public Interface getInterface() {
+ return null;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public DataType getOutputType() {
+ return outputType;
+ }
+
+ public WrapperInfo getWrapper() {
+ return null;
+ }
+
+ public boolean isDynamic() {
+ return false;
+ }
+
+ public boolean isNonBlocking() {
+ return false;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public boolean isWrapperStyle() {
+ return false;
+ }
+
+ public void setDataBinding(String dataBinding) {
+
+ }
+
+ public void setDynamic(boolean b) {
+
+ }
+
+ public void setFaultBeans(Map<QName, List<DataType<XMLType>>> faultBeans) {
+
+ }
+
+ public void setFaultTypes(List<DataType> faultTypes) {
+
+ }
+
+ public void setInputType(DataType<List<DataType>> inputType) {
+ this.inputType = inputType;
+ }
+
+ public void setInterface(Interface interfaze) {
+
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setNonBlocking(boolean nonBlocking) {
+
+ }
+
+ public void setOutputType(DataType outputType) {
+ this.outputType = outputType;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+
+ }
+
+ public void setWrapper(WrapperInfo wrapperInfo) {
+
+ }
+
+ public void setWrapperStyle(boolean wrapperStyle) {
+
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return null;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return null;
+ }
+
+ @Override
+ public Object clone() {
+ return null;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return null;
+ }
+
+ public Map<Object, Object> getAttributes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ExtensionType getExtensionType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isAsyncServer() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java
new file mode 100644
index 0000000000..d31500c85a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.corba.testing.service.mocks;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Mock RuntimeComponentService implementation. Only few methods needs to be
+ * implemented.
+ */
+public class TestRuntimeComponentService implements RuntimeComponentService {
+
+ private InterfaceContract interfaceContract;
+ private RuntimeEndpoint runtimeWire;
+
+ public TestRuntimeComponentService(Object invocationTarget) {
+ List<Operation> operations = new ArrayList<Operation>();
+ Method[] methods = invocationTarget.getClass().getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ int mod = methods[i].getModifiers();
+ if (methods[i].getDeclaringClass().equals(invocationTarget.getClass()) && Modifier.isPublic(mod)
+ && !methods[i].getName().startsWith("_")) {
+ Operation operation = new TestOperation();
+ DataType returnType = new TestDataType(methods[i].getReturnType());
+ operation.setOutputType(returnType);
+ Class<?>[] argTypes = methods[i].getParameterTypes();
+ List<DataType> argDataTypes = new ArrayList<DataType>();
+ for (int j = 0; j < argTypes.length; j++) {
+ argDataTypes.add(new TestDataType(argTypes[j]));
+ }
+ TestDataType<List<DataType>> inputDataType = new TestDataType<List<DataType>>(null, argDataTypes);
+ operation.setInputType(inputDataType);
+ operations.add(operation);
+ operation.setName(methods[i].getName());
+ }
+ }
+ TestInterface iface = new TestInterface(operations, invocationTarget.getClass());
+ interfaceContract = new TestInterfaceContract();
+ interfaceContract.setInterface(iface);
+ runtimeWire = new TestRuntimeWire(interfaceContract, invocationTarget);
+ }
+
+ public ComponentReference getCallbackReference() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Service getService() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setCallbackReference(ComponentReference callbackReference) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setService(Service service) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List<Endpoint> getEndpoints() {
+ // TODO Auto-generated method stub
+ return Arrays.asList((Endpoint)runtimeWire);
+ }
+
+ public <B> B getBinding(Class<B> bindingClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Binding> getBindings() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Callback getCallback() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public <B> B getCallbackBinding(Class<B> bindingClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public InterfaceContract getInterfaceContract(Binding binding) {
+ // TODO Auto-generated method stub
+ return interfaceContract;
+ }
+
+ public boolean isOverridingBindings() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setCallback(Callback callback) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setOverridingBindings(boolean overridingBindings) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public InterfaceContract getInterfaceContract() {
+ // TODO Auto-generated method stub
+ return interfaceContract;
+ }
+
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isForCallback() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setForCallback(boolean isCallback) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setInterfaceContract(InterfaceContract interfaceContract) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setName(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List<Extension> getAttributeExtensions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Object> getExtensions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isUnresolved() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ // TODO Auto-generated method stub
+ return super.clone();
+ }
+
+ public ExtensionType getExtensionType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isJAXWSService() {
+ return false;
+ }
+
+ public void setJAXWSService(boolean isJAXWSService) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
new file mode 100644
index 0000000000..2896114775
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
@@ -0,0 +1,311 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.testing.service.mocks;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Mock RuntimeWire implementation. Only few methods needs to be implemented.
+ */
+public class TestRuntimeWire implements RuntimeEndpoint {
+ private Object invocationTarget;
+ private InterfaceContract interfaceContract;
+
+ public TestRuntimeWire(InterfaceContract interfaceContract, Object invocationTarget) {
+ this.interfaceContract = interfaceContract;
+ this.invocationTarget = invocationTarget;
+ }
+
+
+ public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
+ Class<?>[] types = new Class<?>[args.length];
+ for (int i = 0; i < args.length; i++) {
+ types[i] = args[i].getClass();
+ }
+ Object result = null;
+ try {
+ Method[] methods = invocationTarget.getClass().getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(operation.getName())) {
+ result = methods[i].invoke(invocationTarget, args);
+ break;
+ }
+ }
+ } catch (InvocationTargetException e) {
+ throw e;
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ // TODO Auto-generated method stub
+ return super.clone();
+ }
+
+
+ public InterfaceContract getBindingInterfaceContract() {
+ // TODO Auto-generated method stub
+ return interfaceContract;
+ }
+
+
+ public ServiceBindingProvider getBindingProvider() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public InterfaceContract getComponentTypeServiceInterfaceContract() {
+ // TODO Auto-generated method stub
+ return interfaceContract;
+ }
+
+
+ public void setBindingProvider(ServiceBindingProvider provider) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public boolean isUnresolved() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public void setUnresolved(boolean unresolved) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public ExtensionType getExtensionType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public List<PolicySet> getPolicySets() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public List<Intent> getRequiredIntents() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public void setExtensionType(ExtensionType type) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void bind(CompositeContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public InvocationChain getBindingInvocationChain() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public CompositeContext getCompositeContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public Contract getContract() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public InvocationChain getInvocationChain(Operation operation) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public List<InvocationChain> getInvocationChains() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public List<PolicyProvider> getPolicyProviders() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public Message invoke(Message msg) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public Message invoke(Operation operation, Message msg) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public void unbind() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public Binding getBinding() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public List<EndpointReference> getCallbackEndpointReferences() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public Component getComponent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public InterfaceContract getComponentServiceInterfaceContract() {
+ // TODO Auto-generated method stub
+ return interfaceContract;
+ }
+
+
+ public ComponentService getService() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public String getURI() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public boolean isRemote() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public boolean matches(String serviceURI) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public void setBinding(Binding binding) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void setComponent(Component component) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void setRemote(boolean remote) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void setService(ComponentService service) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void setURI(String uri) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setGeneratedWSDLContract(InterfaceContract wsdlContract){
+
+ }
+
+ public InterfaceContract getGeneratedWSDLContract(){
+ return null;
+ }
+
+ public void validateServiceInterfaceCompatibility() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public InterfaceContract getGeneratedWSDLContract(
+ InterfaceContract interfaceContract) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/arrays_unions.idl b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/arrays_unions.idl
new file mode 100644
index 0000000000..0f4ed03b4e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/arrays_unions.idl
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase arrays_unions.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module arrays_unions {
+
+ struct TestStruct {
+ string oneDimArray[2];
+ long twoDimArray[2][4];
+ float threeDimArray[2][4][2];
+ };
+
+ typedef string StringArray[2][2];
+
+ union InnerUnion switch (long) {
+ case 1: long x;
+ case 2: float y;
+ };
+
+ union RichUnion switch (long) {
+ case 1: long x;
+ case 2: float y;
+ case 3: string z;
+ case 4: InnerUnion iu;
+ default: boolean a;
+ };
+
+ interface ArraysUnionsTests {
+ TestStruct passTestStruct(in TestStruct arg);
+ StringArray passStringArray(in StringArray arg);
+ RichUnion passRichUnion(in RichUnion arg);
+ };
+
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/enums.idl b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/enums.idl
new file mode 100644
index 0000000000..2e4e829b0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/enums.idl
@@ -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.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase enums.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module enums {
+ enum Color {red, yellow, green};
+ interface EnumManager {
+ Color getColor(in Color color);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/exceptions.idl b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/exceptions.idl
new file mode 100644
index 0000000000..b34ec46458
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/exceptions.idl
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase exceptions.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module exceptions {
+ interface Calc {
+ struct Arguments {
+ double arg1;
+ double arg2;
+ };
+
+ exception DivByZero{
+ Arguments arguments;
+ string info;
+ };
+
+ exception NotSupported {
+ string info;
+ };
+
+ double div(in double arg1, in double arg2) raises(DivByZero);
+ double divForSmallArgs(in double arg1, in double arg2) raises(DivByZero, NotSupported);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/general_tests.idl b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/general_tests.idl
new file mode 100644
index 0000000000..db253338c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/general_tests.idl
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase general_tests.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module generated {
+
+ interface RemoteObject {
+
+ };
+
+ typedef sequence<RemoteObject> remote_object_list;
+ typedef sequence<boolean> boolean_list;
+ typedef sequence<char> char_list;
+ typedef sequence<wchar> wchar_list;
+ typedef sequence<octet> octet_list;
+ typedef sequence<short> short_list;
+ typedef sequence<unsigned short> unsigned_short_list;
+ typedef sequence<long> long_list;
+ typedef sequence<unsigned long> unsigned_long_list;
+ typedef sequence<long long> long_long_list;
+ typedef sequence<unsigned long long> unsigned_long_long_list;
+ typedef sequence<float> float_list;
+ typedef sequence<double> double_list;
+ typedef sequence<string> string_list;
+ typedef sequence<wstring> wstring_list;
+
+ interface PrimitivesSetter {
+ boolean setBoolean(in boolean arg);
+ char setChar(in char arg);
+ wchar setWchar(in wchar arg);
+ octet setOctet(in octet arg);
+ short setShort(in short arg);
+ unsigned short setUnsignedShort(in unsigned short arg);
+ long setLong(in long arg);
+ unsigned long setUnsignedLong(in unsigned long arg);
+ long long setLongLong(in long long arg);
+ unsigned long long setUnsignedLongLong(in unsigned long long arg);
+ float setFloat(in float arg);
+ double setDouble(in double arg);
+ string setString(in string arg);
+ wstring setWstring(in wstring arg);
+ RemoteObject setRemoteObject(in RemoteObject obj);
+ };
+
+ interface ArraysSetter {
+ boolean_list setBoolean(in boolean_list arg);
+ char_list setChar(in char_list arg);
+ wchar_list setWchar(in wchar_list arg);
+ octet_list setOctet(in octet_list arg);
+ short_list setShort(in short_list arg);
+ unsigned_short_list setUnsignedShort(in unsigned_short_list arg);
+ long_list setLong(in long_list arg);
+ unsigned_long_list setUnsignedLong(in unsigned_long_list arg);
+ long_long_list setLongLong(in long_long_list arg);
+ unsigned_long_long_list setUnsignedLongLong(in unsigned_long_long_list arg);
+ float_list setFloat(in float_list arg);
+ double_list setDouble(in double_list arg);
+ string_list setString(in string_list arg);
+ wstring_list setWstring(in wstring_list arg);
+ remote_object_list setRemoteObject(in remote_object_list obj);
+ };
+
+ typedef sequence<long> long_seq1;
+ typedef sequence<long_seq1> long_seq2;
+ typedef sequence<long_seq2> long_seq3;
+
+ struct SimpleStruct {
+ string field1;
+ long field2;
+ };
+
+
+ struct SomeStruct {
+ SimpleStruct innerStruct;
+ string str;
+ string_list str_list;
+ long_seq2 twoDimSeq;
+ long_seq3 threeDimSeq;
+ };
+
+ interface TestObject {
+ SomeStruct pickStructFromArgs(in SomeStruct arg1, in SomeStruct arg2, in SomeStruct arg3, in long structNumber);
+ SomeStruct setStruct(in SomeStruct arg);
+ SimpleStruct setSimpleStruct(inout SimpleStruct arg);
+ long_seq1 setLongSeq1(inout long_seq1 arg);
+ long_seq2 setLongSeq2(inout long_seq2 arg);
+ long_seq3 setLongSeq3(inout long_seq3 arg);
+ };
+
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/references.idl b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/references.idl
new file mode 100644
index 0000000000..72b58806e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba-runtime/src/test/resources/references.idl
@@ -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.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase remote_objects.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module references {
+
+ interface DummyObject {
+ long getLong();
+ DummyObject cloneObject();
+ };
+
+ interface ObjectManager {
+ DummyObject getDummyObject();
+ DummyObject getObjectByArgument(in DummyObject dummy);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/LICENSE b/sandbox/sebastien/java/embed/modules/binding-corba/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/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/sebastien/java/embed/modules/binding-corba/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-corba/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..6dfeae91cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.corba;uses:="org.apache
+ .tuscany.sca.assembly,javax.xml.namespace";version="2.0.0"
+Private-Package: org.apache.tuscany.sca.binding.corba.impl;version="1.
+ 4"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA CORBA Binding Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397128062
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA CORBA Binding Extension
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.corba;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.corba;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.corba
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/NOTICE b/sandbox/sebastien/java/embed/modules/binding-corba/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/pom.xml b/sandbox/sebastien/java/embed/modules/binding-corba/pom.xml
new file mode 100644
index 0000000000..fd6a3d12ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/pom.xml
@@ -0,0 +1,53 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-corba</artifactId>
+ <name>Apache Tuscany SCA CORBA Binding Extension</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java
new file mode 100644
index 0000000000..db8c32a400
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.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.sca.binding.corba;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface CorbaBinding extends Binding {
+ String BINDING_CORBA = "binding.corba";
+ QName BINDING_CORBA_QNAME = new QName(Base.SCA11_TUSCANY_NS, BINDING_CORBA);
+
+ String getHost();
+
+ void setHost(String host);
+
+ int getPort();
+
+ void setPort(int port);
+
+ String getId();
+
+ void setId(String id);
+
+ String getCorbaname();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java
new file mode 100644
index 0000000000..67e3bdcf74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.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.sca.binding.corba;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface CorbaBindingFactory {
+ /**
+ * Create a CorbaBinding model
+ * @return The CorbaBinding model
+ */
+ CorbaBinding createCorbaBinding();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java
new file mode 100644
index 0000000000..cecb4fb567
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.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.sca.binding.corba.impl;
+
+import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.binding.corba.CorbaBindingFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CorbaBindingFactoryImpl implements CorbaBindingFactory {
+
+ /**
+ * @see org.apache.tuscany.sca.binding.corba.CorbaBindingFactory#createCorbaBinding()
+ */
+ public CorbaBinding createCorbaBinding() {
+ return new CorbaBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java
new file mode 100644
index 0000000000..25d8ed6c99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.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.sca.binding.corba.impl;
+
+import org.apache.tuscany.sca.assembly.impl.BindingImpl;
+import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.host.corba.CorbaHostUtils;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CorbaBindingImpl extends BindingImpl implements CorbaBinding {
+ private String host;
+ private int port;
+ private String id;
+
+ /**
+ * @param type
+ */
+ public CorbaBindingImpl() {
+ super(CorbaBinding.BINDING_CORBA_QNAME);
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getCorbaname() {
+ return CorbaHostUtils.isValidCorbanameURI(getURI()) ? getURI(): CorbaHostUtils.createCorbanameURI(getHost(), getPort(), getName());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java
new file mode 100644
index 0000000000..8e5fcdc6e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.corba.impl;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
+import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.binding.corba.CorbaBindingFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CorbaBindingProcessor implements StAXArtifactProcessor<CorbaBinding> {
+ private CorbaBindingFactory factory;
+ private PolicyFactory policyFactory;
+ private PolicySubjectProcessor policyProcessor;
+
+ public CorbaBindingProcessor(FactoryExtensionPoint modelFactories) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.factory = modelFactories.getFactory(CorbaBindingFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#getArtifactType()
+ */
+ public QName getArtifactType() {
+ return CorbaBinding.BINDING_CORBA_QNAME;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#read(javax.xml.stream.XMLStreamReader)
+ */
+ public CorbaBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ CorbaBinding binding = factory.createCorbaBinding();
+
+ // Read the policies
+ policyProcessor.readPolicies(binding, reader);
+
+ binding.setHost(reader.getAttributeValue(null, "host"));
+ String port = reader.getAttributeValue(null, "port");
+ if (port != null) {
+ binding.setPort(Integer.parseInt(port));
+ }
+
+ // Read the name
+ String name = reader.getAttributeValue(null, "name");
+ if (name != null) {
+ binding.setName(name);
+ }
+
+ // Read binding URI
+ String uri = reader.getAttributeValue(null, "uri");
+ if (uri != null) {
+ binding.setURI(uri);
+ }
+
+ // Read CORBA id
+ String id = reader.getAttributeValue(null, "id");
+ if (id != null) {
+ binding.setId(id);
+ }
+ return binding;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#write(java.lang.Object, javax.xml.stream.XMLStreamWriter)
+ */
+ public void write(CorbaBinding model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // Write a <binding.corba>
+ writer.writeStartElement(CorbaBinding.BINDING_CORBA_QNAME.getNamespaceURI(), CorbaBinding.BINDING_CORBA);
+
+ if (model.getName() != null) {
+ writer.writeAttribute("name", model.getName());
+ }
+
+ if (model.getURI() != null) {
+ writer.writeAttribute("uri", model.getURI());
+ }
+
+ if (model.getHost() != null) {
+ writer.writeAttribute("host", model.getHost());
+ }
+
+ if (model.getPort() != -1) {
+ writer.writeAttribute("port", String.valueOf(model.getPort()));
+ }
+
+ if (model.getId() != null) {
+ writer.writeAttribute("id", model.getId());
+ }
+ writer.writeEndElement();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#getModelType()
+ */
+ public Class<CorbaBinding> getModelType() {
+ return CorbaBinding.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#resolve(java.lang.Object, org.apache.tuscany.sca.contribution.resolver.ModelResolver)
+ */
+ public void resolve(CorbaBinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.corba.CorbaBindingFactory b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.corba.CorbaBindingFactory
new file mode 100644
index 0000000000..57959840d4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.corba.CorbaBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.corba.impl.CorbaBindingFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..bafd086051
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.corba.impl.CorbaBindingProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.corba,model=org.apache.tuscany.sca.binding.corba.CorbaBinding,factory=org.apache.tuscany.sca.binding.corba.CorbaBindingFactory
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/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/sebastien/java/embed/modules/binding-ejb-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..7167936ade
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,39 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.ejb.corba;version="2.0
+ ",org.apache.tuscany.sca.binding.ejb.provider;version="2.0.0",org.apach
+ e.tuscany.sca.binding.ejb.util;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA EJB Binding Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA EJB Binding Runtime
+Import-Package: javax.ejb,
+ javax.ejb.spi,
+ javax.naming,
+ javax.rmi,
+ javax.rmi.CORBA,
+ net.sf.cglib.core,
+ net.sf.cglib.proxy,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.ejb;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.omg.CORBA,
+ org.omg.CORBA.portable,
+ org.omg.CORBA_2_3.portable,
+ org.omg.CosNaming,
+ org.omg.IOP,
+ org.omg.PortableInterceptor,
+ org.omg.stub.java.rmi,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.ejb.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/pom.xml
new file mode 100644
index 0000000000..1d842facef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/pom.xml
@@ -0,0 +1,169 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-ejb-runtime</artifactId>
+ <name>Apache Tuscany SCA EJB Binding Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ejb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_3.0_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-openejb</artifactId>
+ <version>2.0.2</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-connector</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-persistence-jpa10</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-ejbd</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-server</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-loader</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-jee</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-ejbd</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-javaagent</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm-commons</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>geronimo-repository</id>
+ <name>Geronimo Repository</name>
+ <url>http://svn.apache.org/repos/asf/geronimo/server/tags/2.0.2/repository</url>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ClassLoadingUtil.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ClassLoadingUtil.java
new file mode 100644
index 0000000000..c65868c23b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ClassLoadingUtil.java
@@ -0,0 +1,365 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.corba;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Utility class for loading classes by a variety of name variations.
+ * <p/>
+ * Supported names types are:
+ * <p/>
+ * 1) Fully qualified class name (e.g., "java.lang.String", "org.apache.geronimo.kernel.ClassLoading"
+ * 2) Method signature encoding ("Ljava.lang.String;", "J", "I", etc.)
+ * 3) Primitive type names ("int", "boolean", etc.)
+ * 4) Method array signature strings ("[I", "[Ljava.lang.String")
+ * 5) Arrays using Java code format ("int[]", "java.lang.String[][]")
+ * <p/>
+ * The classes are loaded using the provided class loader. For the basic types, the primitive
+ * reflection types are returned.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClassLoadingUtil {
+
+ /**
+ * Table for mapping primitive class names/signatures to the implementing
+ * class object
+ */
+ private static final HashMap PRIMITIVE_CLASS_MAP = new HashMap();
+
+ /**
+ * Table for mapping primitive classes back to their name signature type, which
+ * allows a reverse mapping to be performed from a class object into a resolvable
+ * signature.
+ */
+ private static final HashMap CLASS_TO_SIGNATURE_MAP = new HashMap();
+
+
+ /**
+ * Setup the primitives map. We make any entry for each primitive class using both the
+ * human readable name and the method signature shorthand type.
+ */
+ static {
+ PRIMITIVE_CLASS_MAP.put("boolean", boolean.class);
+ PRIMITIVE_CLASS_MAP.put("Z", boolean.class);
+ PRIMITIVE_CLASS_MAP.put("byte", byte.class);
+ PRIMITIVE_CLASS_MAP.put("B", byte.class);
+ PRIMITIVE_CLASS_MAP.put("char", char.class);
+ PRIMITIVE_CLASS_MAP.put("C", char.class);
+ PRIMITIVE_CLASS_MAP.put("short", short.class);
+ PRIMITIVE_CLASS_MAP.put("S", short.class);
+ PRIMITIVE_CLASS_MAP.put("int", int.class);
+ PRIMITIVE_CLASS_MAP.put("I", int.class);
+ PRIMITIVE_CLASS_MAP.put("long", long.class);
+ PRIMITIVE_CLASS_MAP.put("J", long.class);
+ PRIMITIVE_CLASS_MAP.put("float", float.class);
+ PRIMITIVE_CLASS_MAP.put("F", float.class);
+ PRIMITIVE_CLASS_MAP.put("double", double.class);
+ PRIMITIVE_CLASS_MAP.put("D", double.class);
+ PRIMITIVE_CLASS_MAP.put("void", void.class);
+ PRIMITIVE_CLASS_MAP.put("V", void.class);
+
+ // Now build a reverse mapping table. The table above has a many-to-one mapping for
+ // class names. To do the reverse, we need to pick just one. As long as the
+ // returned name supports "round tripping" of the requests, this will work fine.
+
+ CLASS_TO_SIGNATURE_MAP.put(boolean.class, "Z");
+ CLASS_TO_SIGNATURE_MAP.put(byte.class, "B");
+ CLASS_TO_SIGNATURE_MAP.put(char.class, "C");
+ CLASS_TO_SIGNATURE_MAP.put(short.class, "S");
+ CLASS_TO_SIGNATURE_MAP.put(int.class, "I");
+ CLASS_TO_SIGNATURE_MAP.put(long.class, "J");
+ CLASS_TO_SIGNATURE_MAP.put(float.class, "F");
+ CLASS_TO_SIGNATURE_MAP.put(double.class, "D");
+ CLASS_TO_SIGNATURE_MAP.put(void.class, "V");
+ }
+
+
+ /**
+ * Load a class that matches the requested name, using the provided class loader context.
+ * <p/>
+ * The class name may be a standard class name, the name of a primitive type Java
+ * reflection class (e.g., "boolean" or "int"), or a type in method type signature
+ * encoding. Array classes in either encoding form are also processed.
+ *
+ * @param className The name of the required class.
+ * @param classLoader The class loader used to resolve the class object.
+ * @return The Class object resolved from "className".
+ * @throws ClassNotFoundException When unable to resolve the class object.
+ * @throws IllegalArgumentException If either argument is null.
+ */
+ public static Class loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
+
+ // the tests require IllegalArgumentExceptions for null values on either of these.
+ if (className == null) {
+ throw new IllegalArgumentException("className is null");
+ }
+
+ if (classLoader == null) {
+ throw new IllegalArgumentException("classLoader is null");
+ }
+ // The easiest case is a proper class name. We just have the class loader resolve this.
+ // If the class loader throws a ClassNotFoundException, then we need to check each of the
+ // special name encodings we support.
+ try {
+ return classLoader.loadClass(className);
+ } catch (ClassNotFoundException ignore) {
+ // if not found, continue on to the other name forms.
+ }
+
+
+ // The second easiest version to resolve is a direct map to a primitive type name
+ // or method signature. Check our name-to-class map for one of those.
+ Class resolvedClass = (Class) PRIMITIVE_CLASS_MAP.get(className);
+ if (resolvedClass != null) {
+ return resolvedClass;
+ }
+
+ // Class names in method signature have the format "Lfully.resolved.name;",
+ // so if it ends in a semicolon and begins with an "L", this must be in
+ // this format. Have the class loader try to load this. There are no other
+ // options if this fails, so just allow the class loader to throw the
+ // ClassNotFoundException.
+ if (className.endsWith(";") && className.startsWith("L")) {
+ // pick out the name portion
+ String typeName = className.substring(1, className.length() - 1);
+ // and delegate the loading to the class loader.
+ return classLoader.loadClass(typeName);
+ }
+
+ // All we have left now are the array types. Method signature array types
+ // have a series of leading "[" characters to specify the number of dimensions.
+ // The other array type we handle uses trailing "[]" for the dimensions, just
+ // like the Java language syntax.
+
+ // first check for the signature form ([[[[type).
+ if (className.charAt(0) == '[') {
+ // we have at least one array marker, now count how many leading '['s we have
+ // to get the dimension count.
+ int count = 0;
+ int nameLen = className.length();
+
+ while (count < nameLen && className.charAt(count) == '[') {
+ count++;
+ }
+
+ // pull of the name subtype, which is everything after the last '['
+ String arrayTypeName = className.substring(count, className.length());
+ // resolve the type using a recursive call, which will load any of the primitive signature
+ // types as well as class names.
+ Class arrayType = loadClass(arrayTypeName, classLoader);
+
+ // Resolving array types require a little more work. The array classes are
+ // created dynamically when the first instance of a given dimension and type is
+ // created. We need to create one using reflection to do this.
+ return getArrayClass(arrayType, count);
+ }
+
+
+ // ok, last chance. Now check for an array specification in Java language
+ // syntax. This will be a type name followed by pairs of "[]" to indicate
+ // the number of dimensions.
+ if (className.endsWith("[]")) {
+ // get the base component class name and the arrayDimensions
+ int count = 0;
+ int position = className.length();
+
+ while (position > 1 && className.substring(position - 2, position).equals("[]")) {
+ // count this dimension
+ count++;
+ // and step back the probe position.
+ position -= 2;
+ }
+
+ // position now points at the location of the last successful test. This makes it
+ // easy to pick off the class name.
+
+ String typeName = className.substring(0, position);
+
+ // load the base type, again, doing this recursively
+ Class arrayType = loadClass(typeName, classLoader);
+ // and turn this into the class object
+ return getArrayClass(arrayType, count);
+ }
+
+ throw new ClassNotFoundException("Could not load class " + className + " from unknown classloader; " + classLoader);
+ }
+
+
+ /**
+ * Map a class object back to a class name. The returned class object
+ * must be "round trippable", which means
+ * <p/>
+ * type == ClassLoading.loadClass(ClassLoading.getClassName(type), classLoader)
+ * <p/>
+ * must be true. To ensure this, the class name is always returned in
+ * method signature format.
+ *
+ * @param type The class object we convert into name form.
+ * @return A string representation of the class name, in method signature
+ * format.
+ */
+ public static String getClassName(Class type) {
+ StringBuffer name = new StringBuffer();
+
+ // we test these in reverse order from the resolution steps,
+ // first handling arrays, then primitive types, and finally
+ // "normal" class objects.
+
+ // First handle arrays. If a class is an array, the type is
+ // element stored at that level. So, for a 2-dimensional array
+ // of ints, the top-level type will be "[I". We need to loop
+ // down the hierarchy until we hit a non-array type.
+ while (type.isArray()) {
+ // add another array indicator at the front of the name,
+ // and continue with the next type.
+ name.append('[');
+ type = type.getComponentType();
+ }
+
+ // we're down to the base type. If this is a primitive, then
+ // we poke in the single-character type specifier.
+ if (type.isPrimitive()) {
+ name.append((String) CLASS_TO_SIGNATURE_MAP.get(type));
+ }
+ // a "normal" class. This gets expressing using the "Lmy.class.name;" syntax.
+ else {
+ name.append('L');
+ name.append(type.getName());
+ name.append(';');
+ }
+ return name.toString();
+ }
+
+ private static Class getArrayClass(Class type, int dimension) {
+ // Array.newInstance() requires an array of the requested number of dimensions
+ // that gives the size for each dimension. We just request 0 in each of the
+ // dimensions, which is not unlike a black hole singularity.
+ int[] dimensions = new int[dimension];
+ // create an instance and return the associated class object.
+ return Array.newInstance(type, dimensions).getClass();
+ }
+
+ public static Set getAllTypes(Class type) {
+ Set allTypes = new LinkedHashSet();
+ allTypes.add(type);
+ allTypes.addAll(getAllSuperClasses(type));
+ allTypes.addAll(getAllInterfaces(type));
+ return allTypes;
+ }
+
+ private static Set getAllSuperClasses(Class clazz) {
+ Set allSuperClasses = new LinkedHashSet();
+ for (Class superClass = clazz.getSuperclass(); superClass != null; superClass = superClass.getSuperclass()) {
+ allSuperClasses.add(superClass);
+ }
+ return allSuperClasses;
+ }
+
+ private static Set getAllInterfaces(Class clazz) {
+ Set allInterfaces = new LinkedHashSet();
+ LinkedList stack = new LinkedList();
+ stack.addAll(Arrays.asList(clazz.getInterfaces()));
+ while (!stack.isEmpty()) {
+ Class intf = (Class) stack.removeFirst();
+ if (!allInterfaces.contains(intf)) {
+ allInterfaces.add(intf);
+ stack.addAll(Arrays.asList(intf.getInterfaces()));
+ }
+ }
+ return allInterfaces;
+ }
+
+ public static Set reduceInterfaces(Set source) {
+ Class[] classes = (Class[]) source.toArray(new Class[source.size()]);
+ classes = reduceInterfaces(classes);
+ return new LinkedHashSet(Arrays.asList(classes));
+ }
+
+ /**
+ * If there are multiple interfaces, and some of them extend each other,
+ * eliminate the superclass in favor of the subclasses that extend them.
+ *
+ * If one of the entries is a class (not an interface), make sure it's
+ * the first one in the array. If more than one of the entries is a
+ * class, throws an IllegalArgumentException
+ *
+ * @param source the original list of interfaces
+ * @return the equal or smaller list of interfaces
+ */
+ public static Class[] reduceInterfaces(Class[] source) {
+ // use a copy of the source array
+ source = (Class[]) source.clone();
+
+ for (int leftIndex = 0; leftIndex < source.length-1; leftIndex++) {
+ Class left = source[leftIndex];
+ if(left == null) {
+ continue;
+ }
+
+ for (int rightIndex = leftIndex +1; rightIndex < source.length; rightIndex++) {
+ Class right = source[rightIndex];
+ if(right == null) {
+ continue;
+ }
+
+ if(left == right || right.isAssignableFrom(left)) {
+ // right is the same as class or a sub class of left
+ source[rightIndex] = null;
+ } else if(left.isAssignableFrom(right)) {
+ // left is the same as class or a sub class of right
+ source[leftIndex] = null;
+
+ // the left has been eliminated; move on to the next left
+ break;
+ }
+ }
+ }
+
+ Class clazz = null;
+ for (int i = 0; i < source.length; i++) {
+ if (source[i] != null && !source[i].isInterface()) {
+ if (clazz != null) {
+ throw new IllegalArgumentException("Source contains two classes which are not subclasses of each other: " + clazz.getName() + ", " + source[i].getName());
+ }
+ clazz = source[i];
+ source[i] = null;
+ }
+ }
+
+ List list = new ArrayList(source.length);
+ if (clazz != null) list.add(clazz);
+ for (int i = 0; i < source.length; i++) {
+ if(source[i] != null) {
+ list.add(source[i]);
+ }
+ }
+ return (Class[]) list.toArray(new Class[list.size()]);
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/DynamicStubClassLoader.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/DynamicStubClassLoader.java
new file mode 100644
index 0000000000..82554a1c8f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/DynamicStubClassLoader.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.ejb.corba;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import javax.rmi.CORBA.Stub;
+
+import net.sf.cglib.core.NamingPolicy;
+import net.sf.cglib.core.Predicate;
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.CallbackFilter;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.FixedValue;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.NoOp;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DynamicStubClassLoader extends ClassLoader {
+ private static final String PACKAGE_PREFIX = "org.omg.stub.";
+
+ @Override
+ public synchronized Class loadClass(final String name) throws ClassNotFoundException {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ // check if the stub already exists first
+ try {
+ return classLoader.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ }
+
+ // if this is not a class from the org.omg.stub name space don't attempt to generate
+ if (!name.startsWith(PACKAGE_PREFIX)) {
+ throw new ClassNotFoundException("Could not load class: " + name);
+ }
+
+ // load the interfaces class we are attempting to create a stub for
+ Class iface = loadStubInterfaceClass(name, classLoader);
+
+ // create the stub builder
+ try {
+ Enhancer enhancer = new Enhancer();
+ enhancer.setSuperclass(Stub.class);
+ enhancer.setInterfaces(new Class[] {iface});
+ enhancer.setCallbackFilter(FILTER);
+ enhancer.setCallbackTypes(new Class[] {NoOp.class, MethodInterceptor.class, FixedValue.class});
+ enhancer.setUseFactory(false);
+ enhancer.setClassLoader(classLoader);
+ enhancer.setNamingPolicy(new NamingPolicy() {
+ public String getClassName(String s, String s1, Object o, Predicate predicate) {
+ return name;
+ }
+ });
+
+ // generate the class
+ Class result = enhancer.createClass();
+ assert result != null;
+
+ StubMethodInterceptor interceptor = new StubMethodInterceptor(iface);
+ Ids ids = new Ids(iface);
+ Enhancer.registerStaticCallbacks(result, new Callback[] {NoOp.INSTANCE, interceptor, ids});
+
+ return result;
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Error e) {
+ throw e;
+ }
+ }
+
+ private Class loadStubInterfaceClass(String name, ClassLoader classLoader) throws ClassNotFoundException {
+ try {
+ int begin = name.lastIndexOf('.') + 1;
+ String iPackage = name.substring(13, begin);
+ String iName = iPackage + name.substring(begin + 1, name.length() - 5);
+
+ return classLoader.loadClass(iName);
+ } catch (ClassNotFoundException e) {
+ // don't log exceptions from CosNaming because it attempts to load every
+ // class bound into the name server
+
+ //FIXME this variable is never read, can we remove the
+ // whole block of code??
+ //boolean shouldLog = true;
+ StackTraceElement[] stackTrace = e.getStackTrace();
+ for (int i = 0; i < stackTrace.length; i++) {
+ StackTraceElement stackTraceElement = stackTrace[i];
+ if (stackTraceElement.getClassName().equals("org.omg.CosNaming.NamingContextExtPOA") && stackTraceElement
+ .getMethodName().equals("_invoke")) {
+ //shouldLog = false;
+ break;
+ }
+ }
+
+ throw new ClassNotFoundException("Unable to generate stub", e);
+ }
+ }
+
+ private static final CallbackFilter FILTER = new CallbackFilter() {
+ public int accept(Method method) {
+ // we don't intercept non-public methods like finalize
+ if (!Modifier.isPublic(method.getModifiers())) {
+ return 0;
+ }
+
+ if (method.getReturnType().equals(String[].class) && method.getParameterTypes().length == 0
+ && method.getName().equals("_ids")) {
+ return 2;
+ }
+
+ if (Modifier.isAbstract(method.getModifiers())) {
+ return 1;
+ }
+
+ return 0;
+ }
+ };
+
+ private static final class Ids implements FixedValue {
+ private final String[] typeIds;
+
+ public Ids(Class type) {
+ typeIds = Java2IDLUtil.createCorbaIds(type);
+ }
+
+ public Object loadObject() throws Exception {
+ return typeIds;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/Java2IDLUtil.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/Java2IDLUtil.java
new file mode 100644
index 0000000000..de8090c45b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/Java2IDLUtil.java
@@ -0,0 +1,811 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.corba;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.ejb.spi.HandleDelegate;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+import org.omg.IOP.Codec;
+import org.omg.IOP.CodecFactory;
+import org.omg.IOP.ENCODING_CDR_ENCAPS;
+import org.omg.IOP.Encoding;
+
+/**
+ * Various utility functions.
+ * <p/>
+ * Note: #getORB() and #getCodec() rely on UtilInitializer to initialize the ORB and codec.
+ *
+ * @version $Rev$ $Date$
+ * @see UtilInitializer
+ */
+public final class Java2IDLUtil {
+ private static ORB orb;
+ private static Codec codec;
+ private static HandleDelegate handleDelegate;
+
+ public static ORB getORB() {
+ assert orb != null;
+ return orb;
+ }
+
+
+
+ public static void setORB(ORB orb) throws UserException {
+ if (Java2IDLUtil.orb == null) {
+ Java2IDLUtil.orb = orb;
+ CodecFactory factory = (CodecFactory) Java2IDLUtil.orb.resolve_initial_references("CodecFactory");
+ codec = factory.create_codec(new Encoding(ENCODING_CDR_ENCAPS.value, (byte) 1, (byte) 2));
+ }
+ }
+
+ public static Codec getCodec() {
+ assert codec != null;
+ return codec;
+ }
+
+ public static HandleDelegate getHandleDelegate() throws NamingException {
+ if (handleDelegate == null) {
+ InitialContext ic = new InitialContext();
+ handleDelegate = (HandleDelegate) ic.lookup("java:comp/HandleDelegate");
+ }
+ return handleDelegate;
+ }
+
+ private static final Pattern SCOPED_NAME_EXTRACTION_PATTERN = Pattern.compile("(\\\\\\\\)|(\\\\@)|(@)|(\\z)");
+
+ /**
+ * See csiv2 Specification 16.2.5 par. 63-64. We extract the username if any and un-escape any
+ * escaped \ and @ characters.
+ *
+ * @param scopedNameBytes
+ * @return
+ * @throws UnsupportedEncodingException
+ */
+ public static String extractUserNameFromScopedName(byte[] scopedNameBytes) throws UnsupportedEncodingException {
+ String scopedUserName = new String(scopedNameBytes, "UTF8");
+ return extractUserNameFromScopedName(scopedUserName);
+ }
+
+ public static String extractUserNameFromScopedName(String scopedUserName) {
+ Matcher m = SCOPED_NAME_EXTRACTION_PATTERN.matcher(scopedUserName);
+ StringBuffer buf = new StringBuffer();
+ while (m.find()) {
+ m.appendReplacement(buf, "");
+ if (m.group(1) != null) {
+ buf.append('\\');
+ } else if (m.group(2) != null) {
+ buf.append("@");
+ } else if (m.group(3) != null) {
+ break;
+ }
+ }
+ return buf.toString();
+ }
+
+ private static final Pattern SCOPED_NAME_ESCAPE_PATTERN = Pattern.compile("(\\\\)|(@)");
+
+ public static String buildScopedUserName(String user, String domain) {
+ StringBuffer buf = new StringBuffer();
+ if (user != null) {
+ escape(user, buf);
+ }
+ if (domain != null) {
+ buf.append('@');
+ escape(domain, buf);
+ }
+ return buf.toString();
+ }
+
+ private static void escape(String s, StringBuffer buf) {
+ Matcher m = SCOPED_NAME_ESCAPE_PATTERN.matcher(s);
+ while (m.find()) {
+ m.appendReplacement(buf, "");
+ if (m.group(1) != null) {
+ buf.append("\\\\");
+ } else if (m.group(2) != null) {
+ buf.append("\\@");
+ }
+ }
+ m.appendTail(buf);
+ }
+
+
+ public static String byteToString(byte[] data) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < data.length; i++) {
+ buffer.append(HEXCHAR[(data[i] >>> 4) & 0x0F]);
+ buffer.append(HEXCHAR[(data[i]) & 0x0F]);
+ }
+ return buffer.toString();
+
+ }
+
+ private static final char[] HEXCHAR = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+ };
+
+ public static void writeObject(Class type, Object object, OutputStream out) {
+ if (type == Void.TYPE) {
+ // do nothing for a void
+ } else if (type == Boolean.TYPE) {
+ out.write_boolean(((Boolean) object).booleanValue());
+ } else if (type == Byte.TYPE) {
+ out.write_octet(((Byte) object).byteValue());
+ } else if (type == Character.TYPE) {
+ out.write_wchar(((Character) object).charValue());
+ } else if (type == Double.TYPE) {
+ out.write_double(((Double) object).doubleValue());
+ } else if (type == Float.TYPE) {
+ out.write_float(((Float) object).floatValue());
+ } else if (type == Integer.TYPE) {
+ out.write_long(((Integer) object).intValue());
+ } else if (type == Long.TYPE) {
+ out.write_longlong(((Long) object).longValue());
+ } else if (type == Short.TYPE) {
+ out.write_short(((Short) object).shortValue());
+ } else {
+ // object types must be written in the context of the CORBA application server
+ // which properly write replaces our objects for CORBA
+ // ApplicationServer oldApplicationServer = ServerFederation.getApplicationServer();
+ try {
+ // ServerFederation.setApplicationServer(corbaApplicationServer);
+
+ // todo check if
+ // copy the result to force replacement
+ // CORBA does not call writeReplace on remote proxies
+ //
+ // HOWEVER, if this is an array, then we don't want to do the replacement
+ // because we can end up with a replacement element that's not compatible with the
+ // original array type, which results in an ArrayStoreException. Fortunately,
+ // the Yoko RMI support appears to be able to sort this out for us correctly.
+ if (object instanceof Serializable && !object.getClass().isArray()) {
+ try {
+ object = copyObj(Thread.currentThread().getContextClassLoader(), object);
+ } catch (Exception e) {
+ throw new UnknownException(e);
+ }
+ }
+
+ if (type == Object.class || type == Serializable.class) {
+ javax.rmi.CORBA.Util.writeAny(out, object);
+ } else if (org.omg.CORBA.Object.class.isAssignableFrom(type)) {
+ out.write_Object((org.omg.CORBA.Object) object);
+ } else if (Remote.class.isAssignableFrom(type)) {
+ javax.rmi.CORBA.Util.writeRemoteObject(out, object);
+ } else if (type.isInterface() && Serializable.class.isAssignableFrom(type)) {
+ javax.rmi.CORBA.Util.writeAbstractObject(out, object);
+ } else {
+ out.write_value((Serializable) object, type);
+ }
+ } finally {
+ // ServerFederation.setApplicationServer(oldApplicationServer);
+ }
+ }
+ }
+
+ private static Object copyObj(ClassLoader classLoader, Object object) throws IOException, ClassNotFoundException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(object);
+ oos.flush();
+ oos.close();
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStreamExt ois = new ObjectInputStreamExt(bais, classLoader);
+ return ois.readObject();
+ }
+
+ public static Object readObject(Class type, InputStream in) {
+ if (type == Void.TYPE) {
+ return null;
+ } else if (type == Boolean.TYPE) {
+ return new Boolean(in.read_boolean());
+ } else if (type == Byte.TYPE) {
+ return new Byte(in.read_octet());
+ } else if (type == Character.TYPE) {
+ return new Character(in.read_wchar());
+ } else if (type == Double.TYPE) {
+ return new Double(in.read_double());
+ } else if (type == Float.TYPE) {
+ return new Float(in.read_float());
+ } else if (type == Integer.TYPE) {
+ return new Integer(in.read_long());
+ } else if (type == Long.TYPE) {
+ return new Long(in.read_longlong());
+ } else if (type == Short.TYPE) {
+ return new Short(in.read_short());
+ } else if (type == Object.class || type == Serializable.class) {
+ return javax.rmi.CORBA.Util.readAny(in);
+ } else if (org.omg.CORBA.Object.class.isAssignableFrom(type)) {
+ return in.read_Object(type);
+ } else if (Remote.class.isAssignableFrom(type)) {
+ return PortableRemoteObject.narrow(in.read_Object(), type);
+ } else if (type.isInterface() && Serializable.class.isAssignableFrom(type)) {
+ return in.read_abstract_interface();
+ } else {
+ return in.read_value(type);
+ }
+ }
+
+ public static void throwException(Method method, InputStream in) throws Throwable {
+ // read the exception id
+ final String id = in.read_string();
+
+ // get the class name from the id
+ if (!id.startsWith("IDL:")) {
+ return;
+ }
+
+ Class[] exceptionTypes = method.getExceptionTypes();
+ for (int i = 0; i < exceptionTypes.length; i++) {
+ Class exceptionType = exceptionTypes[i];
+
+ String exceptionId = getExceptionId(exceptionType);
+ if (id.equals(exceptionId)) {
+ throw (Throwable) in.read_value(exceptionType);
+ }
+ }
+ throw new UnexpectedException(id);
+ }
+
+ public static OutputStream writeUserException(Method method, ResponseHandler reply, Exception exception) throws Exception {
+ if (exception instanceof RuntimeException || exception instanceof RemoteException) {
+ throw exception;
+ }
+
+ Class[] exceptionTypes = method.getExceptionTypes();
+ for (int i = 0; i < exceptionTypes.length; i++) {
+ Class exceptionType = exceptionTypes[i];
+ if (!exceptionType.isInstance(exception)) {
+ continue;
+ }
+
+ OutputStream out = (OutputStream) reply.createExceptionReply();
+ String exceptionId = getExceptionId(exceptionType);
+ out.write_string(exceptionId);
+ out.write_value(exception);
+ return out;
+ }
+ throw exception;
+ }
+
+ public static String getExceptionId(Class exceptionType) {
+ String exceptionName = exceptionType.getName().replace('.', '/');
+ if (exceptionName.endsWith("Exception")) {
+ exceptionName = exceptionName.substring(0, exceptionName.length() - "Exception".length());
+ }
+ exceptionName += "Ex";
+ String exceptionId = "IDL:" + exceptionName + ":1.0";
+ return exceptionId;
+ }
+
+ public static String[] createCorbaIds(Class type) {
+ List ids = new LinkedList();
+ for (Iterator iterator = getAllInterfaces(type).iterator(); iterator.hasNext();) {
+ Class superInterface = (Class) iterator.next();
+ if (Remote.class.isAssignableFrom(superInterface) && superInterface != Remote.class) {
+ ids.add("RMI:" + superInterface.getName() + ":0000000000000000");
+ }
+ }
+ return (String[]) ids.toArray(new String[ids.size()]);
+ }
+
+ private static Set getAllInterfaces(Class intfClass) {
+ Set allInterfaces = new LinkedHashSet();
+
+ LinkedList stack = new LinkedList();
+ stack.addFirst(intfClass);
+
+ while (!stack.isEmpty()) {
+ Class intf = (Class) stack.removeFirst();
+ allInterfaces.add(intf);
+ stack.addAll(0, Arrays.asList(intf.getInterfaces()));
+ }
+
+ return allInterfaces;
+ }
+
+ public static Map mapMethodToOperation(Class intfClass) {
+ return iiopMap(intfClass, false);
+ }
+
+ public static Map mapOperationToMethod(Class intfClass) {
+ return iiopMap(intfClass, true);
+ }
+
+ private static Map iiopMap(Class intfClass, boolean operationToMethod) {
+ Method[] methods = getAllMethods(intfClass);
+
+ // find every valid getter
+ HashMap getterByMethod = new HashMap(methods.length);
+ HashMap getterByName = new HashMap(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String methodName = method.getName();
+
+ // no arguments allowed
+ if (method.getParameterTypes().length != 0) {
+ continue;
+ }
+
+ // must start with get or is
+ String verb;
+ if (methodName.startsWith("get") && methodName.length() > 3 && method.getReturnType() != void.class) {
+ verb = "get";
+ } else if (methodName.startsWith("is") && methodName.length() > 2 && method.getReturnType() == boolean.class) {
+ verb = "is";
+ } else {
+ continue;
+ }
+
+ // must only throw Remote or Runtime Exceptions
+ boolean exceptionsValid = true;
+ Class[] exceptionTypes = method.getExceptionTypes();
+ for (int j = 0; j < exceptionTypes.length; j++) {
+ Class exceptionType = exceptionTypes[j];
+ if (!RemoteException.class.isAssignableFrom(exceptionType) &&
+ !RuntimeException.class.isAssignableFrom(exceptionType) &&
+ !Error.class.isAssignableFrom(exceptionType)) {
+ exceptionsValid = false;
+ break;
+ }
+ }
+ if (!exceptionsValid) {
+ continue;
+ }
+
+ String propertyName;
+ if (methodName.length() > verb.length() + 1 && Character.isUpperCase(methodName.charAt(verb.length() + 1))) {
+ propertyName = methodName.substring(verb.length());
+ } else {
+ propertyName = Character.toLowerCase(methodName.charAt(verb.length())) + methodName.substring(verb.length() + 1);
+ }
+ getterByMethod.put(method, propertyName);
+ getterByName.put(propertyName, method);
+ }
+
+ HashMap setterByMethod = new HashMap(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String methodName = method.getName();
+
+ // must have exactally one arg
+ if (method.getParameterTypes().length != 1) {
+ continue;
+ }
+
+ // must return non void
+ if (method.getReturnType() != void.class) {
+ continue;
+ }
+
+ // must start with set
+ if (!methodName.startsWith("set") || methodName.length() <= 3) {
+ continue;
+ }
+
+ // must only throw Remote or Runtime Exceptions
+ boolean exceptionsValid = true;
+ Class[] exceptionTypes = method.getExceptionTypes();
+ for (int j = 0; j < exceptionTypes.length; j++) {
+ Class exceptionType = exceptionTypes[j];
+ if (!RemoteException.class.isAssignableFrom(exceptionType) &&
+ !RuntimeException.class.isAssignableFrom(exceptionType) &&
+ !Error.class.isAssignableFrom(exceptionType)) {
+ exceptionsValid = false;
+ break;
+ }
+ }
+ if (!exceptionsValid) {
+ continue;
+ }
+
+ String propertyName;
+ if (methodName.length() > 4 && Character.isUpperCase(methodName.charAt(4))) {
+ propertyName = methodName.substring(3);
+ } else {
+ propertyName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
+ }
+
+ // must have a matching getter
+ Method getter = (Method) getterByName.get(propertyName);
+ if (getter == null) {
+ continue;
+ }
+
+ // setter property must match getter return value
+ if (!method.getParameterTypes()[0].equals(getter.getReturnType())) {
+ continue;
+ }
+ setterByMethod.put(method, propertyName);
+ }
+
+ // index the methods by name... used to determine which methods are overloaded
+ HashMap overloadedMethods = new HashMap(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (getterByMethod.containsKey(method) || setterByMethod.containsKey(method)) {
+ continue;
+ }
+ String methodName = method.getName();
+ List methodList = (List) overloadedMethods.get(methodName);
+ if (methodList == null) {
+ methodList = new LinkedList();
+ overloadedMethods.put(methodName, methodList);
+ }
+ methodList.add(method);
+ }
+
+ // index the methods by lower case name... used to determine which methods differ only by case
+ HashMap caseCollisionMethods = new HashMap(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (getterByMethod.containsKey(method) || setterByMethod.containsKey(method)) {
+ continue;
+ }
+ String lowerCaseMethodName = method.getName().toLowerCase();
+ Set methodSet = (Set) caseCollisionMethods.get(lowerCaseMethodName);
+ if (methodSet == null) {
+ methodSet = new HashSet();
+ caseCollisionMethods.put(lowerCaseMethodName, methodSet);
+ }
+ methodSet.add(method.getName());
+ }
+
+ String className = getClassName(intfClass);
+ Map iiopMap = new HashMap(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+
+ String iiopName = (String) getterByMethod.get(method);
+ if (iiopName != null) {
+ // if we have a leading underscore prepend with J
+ if (iiopName.charAt(0) == '_') {
+ iiopName = "J_get_" + iiopName.substring(1);
+ } else {
+ iiopName = "_get_" + iiopName;
+ }
+ } else {
+ iiopName = (String) setterByMethod.get(method);
+ if (iiopName != null) {
+ // if we have a leading underscore prepend with J
+ if (iiopName.charAt(0) == '_') {
+ iiopName = "J_set_" + iiopName.substring(1);
+ } else {
+ iiopName = "_set_" + iiopName;
+ }
+ } else {
+ iiopName = method.getName();
+
+ // if we have a leading underscore prepend with J
+ if (iiopName.charAt(0) == '_') {
+ iiopName = "J" + iiopName;
+ }
+ }
+ }
+
+ // if this name only differs by case add the case index to the end
+ Set caseCollisions = (Set) caseCollisionMethods.get(method.getName().toLowerCase());
+ if (caseCollisions != null && caseCollisions.size() > 1) {
+ iiopName += upperCaseIndexString(iiopName);
+ }
+
+ // if this is an overloaded method append the parameter string
+ List overloads = (List) overloadedMethods.get(method.getName());
+ if (overloads != null && overloads.size() > 1) {
+ iiopName += buildOverloadParameterString(method.getParameterTypes());
+ }
+
+ // if we have a leading underscore prepend with J
+ iiopName = replace(iiopName, '$', "U0024");
+
+ // if we have matched a keyword prepend with an underscore
+ if (keywords.contains(iiopName.toLowerCase())) {
+ iiopName = "_" + iiopName;
+ }
+
+ // if the name is the same as the class name, append an underscore
+ if (iiopName.equalsIgnoreCase(className)) {
+ iiopName += "_";
+ }
+
+ if (operationToMethod) {
+ iiopMap.put(iiopName, method);
+ } else {
+ iiopMap.put(method, iiopName);
+ }
+ }
+
+ return iiopMap;
+ }
+
+ private static Method[] getAllMethods(Class intfClass) {
+ LinkedList methods = new LinkedList();
+ for (Iterator iterator = getAllInterfaces(intfClass).iterator(); iterator.hasNext();) {
+ Class intf = (Class) iterator.next();
+ methods.addAll(Arrays.asList(intf.getDeclaredMethods()));
+ }
+
+ return (Method[]) methods.toArray(new Method[methods.size()]);
+ }
+
+ /**
+ * Return the a string containing an underscore '_' index of each uppercase character in the IIOP name.
+ *
+ * This is used for distinction of names that only differ by case, since CORBA does not support case sensitive names.
+ */
+ private static String upperCaseIndexString(String iiopName) {
+ StringBuffer stringBuffer = new StringBuffer();
+ for (int i = 0; i < iiopName.length(); i++) {
+ char c = iiopName.charAt(i);
+ if (Character.isUpperCase(c)) {
+ stringBuffer.append('_').append(i);
+ }
+ }
+ return stringBuffer.toString();
+ }
+
+ /**
+ * Replaces any occurances of the specified "oldChar" with the new string.
+ *
+ * This is used to replace occurances if '$' in CORBA names since '$' is a special character
+ */
+ private static String replace(String source, char oldChar, String newString) {
+ StringBuffer stringBuffer = new StringBuffer(source.length());
+ for (int i = 0; i < source.length(); i++) {
+ char c = source.charAt(i);
+ if (c == oldChar) {
+ stringBuffer.append(newString);
+ } else {
+ stringBuffer.append(c);
+ }
+ }
+ return stringBuffer.toString();
+ }
+
+ /**
+ * Return the a string containing a double underscore '__' list of parameter types encoded using the Java to IDL rules.
+ *
+ * This is used for distinction of methods that only differ by parameter lists.
+ */
+ private static String buildOverloadParameterString(Class[] parameterTypes) {
+ String name = "";
+ if (parameterTypes.length ==0) {
+ name += "__";
+ } else {
+ for (int i = 0; i < parameterTypes.length; i++) {
+ Class parameterType = parameterTypes[i];
+ name += buildOverloadParameterString(parameterType);
+ }
+ }
+ return name.replace('.', '_');
+ }
+
+ /**
+ * Returns a single parameter type encoded using the Java to IDL rules.
+ */
+ private static String buildOverloadParameterString(Class parameterType) {
+ String name = "_";
+
+ int arrayDimensions = 0;
+ while (parameterType.isArray()) {
+ arrayDimensions++;
+ parameterType = parameterType.getComponentType();
+ }
+
+ // arrays start with org_omg_boxedRMI_
+ if (arrayDimensions > 0) {
+ name += "_org_omg_boxedRMI";
+ }
+
+ // IDLEntity types must be prefixed with org_omg_boxedIDL_
+ if (IDLEntity.class.isAssignableFrom(parameterType)) {
+ name += "_org_omg_boxedIDL";
+ }
+
+ // add package... some types have special mappings in corba
+ String packageName = (String) specialTypePackages.get(parameterType.getName());
+ if (packageName == null) {
+ packageName = getPackageName(parameterType.getName());
+ }
+ if (packageName.length() > 0) {
+ name += "_" + packageName;
+ }
+
+ // arrays now contain a dimension indicator
+ if (arrayDimensions > 0) {
+ name += "_" + "seq" + arrayDimensions;
+ }
+
+ // add the class name
+ String className = (String) specialTypeNames.get(parameterType.getName());
+ if (className == null) {
+ className = buildClassName(parameterType);
+ }
+ name += "_" + className;
+
+ return name;
+ }
+
+ /**
+ * Returns a string containing an encoded class name.
+ */
+ private static String buildClassName(Class type) {
+ if (type.isArray()) {
+ throw new IllegalArgumentException("type is an array: " + type);
+ }
+
+ // get the classname
+ String typeName = type.getName();
+ int endIndex = typeName.lastIndexOf('.');
+ if (endIndex < 0) {
+ return typeName;
+ }
+ StringBuffer className = new StringBuffer(typeName.substring(endIndex + 1));
+
+ // for innerclasses replace the $ separator with two underscores
+ // we can't just blindly replace all $ characters since class names can contain the $ character
+ if (type.getDeclaringClass() != null) {
+ String declaringClassName = getClassName(type.getDeclaringClass());
+ assert className.toString().startsWith(declaringClassName + "$");
+ className.replace(declaringClassName.length(), declaringClassName.length() + 1, "__");
+ }
+
+ // if we have a leading underscore prepend with J
+ if (className.charAt(0) == '_') {
+ className.insert(0, "J");
+ }
+ return className.toString();
+ }
+
+ private static String getClassName(Class type) {
+ if (type.isArray()) {
+ throw new IllegalArgumentException("type is an array: " + type);
+ }
+
+ // get the classname
+ String typeName = type.getName();
+ int endIndex = typeName.lastIndexOf('.');
+ if (endIndex < 0) {
+ return typeName;
+ }
+ return typeName.substring(endIndex + 1);
+ }
+
+ private static String getPackageName(String interfaceName) {
+ int endIndex = interfaceName.lastIndexOf('.');
+ if (endIndex < 0) {
+ return "";
+ }
+ return interfaceName.substring(0, endIndex);
+ }
+
+ private static final Map specialTypeNames;
+ private static final Map specialTypePackages;
+ private static final Set keywords;
+
+ static {
+ specialTypeNames = new HashMap();
+ specialTypeNames.put("boolean", "boolean");
+ specialTypeNames.put("char", "wchar");
+ specialTypeNames.put("byte", "octet");
+ specialTypeNames.put("short", "short");
+ specialTypeNames.put("int", "long");
+ specialTypeNames.put("long", "long_long");
+ specialTypeNames.put("float", "float");
+ specialTypeNames.put("double", "double");
+ specialTypeNames.put("java.lang.Class", "ClassDesc");
+ specialTypeNames.put("java.lang.String", "WStringValue");
+ specialTypeNames.put("org.omg.CORBA.Object", "Object");
+
+ specialTypePackages = new HashMap();
+ specialTypePackages.put("boolean", "");
+ specialTypePackages.put("char", "");
+ specialTypePackages.put("byte", "");
+ specialTypePackages.put("short", "");
+ specialTypePackages.put("int", "");
+ specialTypePackages.put("long", "");
+ specialTypePackages.put("float", "");
+ specialTypePackages.put("double", "");
+ specialTypePackages.put("java.lang.Class", "javax.rmi.CORBA");
+ specialTypePackages.put("java.lang.String", "CORBA");
+ specialTypePackages.put("org.omg.CORBA.Object", "");
+
+ keywords = new HashSet();
+ keywords.add("abstract");
+ keywords.add("any");
+ keywords.add("attribute");
+ keywords.add("boolean");
+ keywords.add("case");
+ keywords.add("char");
+ keywords.add("const");
+ keywords.add("context");
+ keywords.add("custom");
+ keywords.add("default");
+ keywords.add("double");
+ keywords.add("enum");
+ keywords.add("exception");
+ keywords.add("factory");
+ keywords.add("false");
+ keywords.add("fixed");
+ keywords.add("float");
+ keywords.add("in");
+ keywords.add("inout");
+ keywords.add("interface");
+ keywords.add("long");
+ keywords.add("module");
+ keywords.add("native");
+ keywords.add("object");
+ keywords.add("octet");
+ keywords.add("oneway");
+ keywords.add("out");
+ keywords.add("private");
+ keywords.add("public");
+ keywords.add("raises");
+ keywords.add("readonly");
+ keywords.add("sequence");
+ keywords.add("short");
+ keywords.add("string");
+ keywords.add("struct");
+ keywords.add("supports");
+ keywords.add("switch");
+ keywords.add("true");
+ keywords.add("truncatable");
+ keywords.add("typedef");
+ keywords.add("union");
+ keywords.add("unsigned");
+ keywords.add("valuebase");
+ keywords.add("valuetype");
+ keywords.add("void");
+ keywords.add("wchar");
+ keywords.add("wstring");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ObjectInputStreamExt.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ObjectInputStreamExt.java
new file mode 100644
index 0000000000..1be4a98a48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ObjectInputStreamExt.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.sca.binding.ejb.corba;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.lang.reflect.Proxy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ObjectInputStreamExt extends ObjectInputStream {
+
+ private ClassLoader classloader;
+
+ public ObjectInputStreamExt(InputStream in, ClassLoader loader) throws IOException {
+ super(in);
+ this.classloader = loader;
+ }
+
+ @Override
+ protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
+ return ClassLoadingUtil.loadClass(classDesc.getName(), classloader);
+ }
+
+ @Override
+ protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
+ Class[] cinterfaces = new Class[interfaces.length];
+ for (int i = 0; i < interfaces.length; i++)
+ cinterfaces[i] = classloader.loadClass(interfaces[i]);
+
+ try {
+ return Proxy.getProxyClass(classloader, cinterfaces);
+ } catch (IllegalArgumentException e) {
+ throw new ClassNotFoundException(null, e);
+ }
+ }
+
+ ClassLoader getClassloader() {
+ return classloader;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/StubMethodInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/StubMethodInterceptor.java
new file mode 100644
index 0000000000..3ff0ed552a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/StubMethodInterceptor.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.corba;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.ejb.EJBObject;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Util;
+
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class StubMethodInterceptor implements MethodInterceptor {
+ private static final Method ISIDENTICAL;
+
+ static {
+ try {
+ ISIDENTICAL = EJBObject.class.getMethod("isIdentical", new Class[]{EJBObject.class});
+ } catch (NoSuchMethodException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ private final Class type;
+ private final Map operations;
+
+ public StubMethodInterceptor(Class type) {
+ this.type = type;
+ this.operations = Collections.unmodifiableMap(org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.mapMethodToOperation(type));
+ }
+
+ public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
+ Stub stub = (Stub) proxy;
+
+ // handle is identical in stub to avoid unnecessary round trip
+ if (method.equals(ISIDENTICAL)) {
+ org.omg.CORBA.Object otherObject = (org.omg.CORBA.Object) args[0];
+ return new Boolean(stub._is_equivalent(otherObject));
+ }
+
+ // get the operation name object
+ String operationName = (String) operations.get(method);
+ if (operationName == null) {
+ throw new IllegalStateException("Unknown method: " + method);
+ }
+
+ while (true) {
+ // if this is a stub to a remote object we invoke over the wire
+ if (!Util.isLocal(stub)) {
+
+ InputStream in = null;
+ try {
+ // create the request output stream
+ OutputStream out = (OutputStream) stub._request(operationName, true);
+
+ // write the arguments
+ Class[] parameterTypes = method.getParameterTypes();
+ for (int i = 0; i < parameterTypes.length; i++) {
+ Class parameterType = parameterTypes[i];
+ org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.writeObject(parameterType, args[i], out);
+ }
+
+ // send the invocation
+ in = (InputStream) stub._invoke(out);
+
+ // read the result
+ Object result = org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.readObject(method.getReturnType(), in);
+ return result;
+ } catch (RemarshalException exception) {
+ continue;
+ } catch (ApplicationException exception) {
+ org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.throwException(method, (InputStream) exception.getInputStream());
+ } catch (SystemException e) {
+ throw Util.mapSystemException(e);
+ } finally {
+ stub._releaseReply(in);
+ }
+ } else {
+ // get the servant
+ ServantObject servantObject = stub._servant_preinvoke(operationName, type);
+ if (servantObject == null) {
+ continue;
+ }
+
+ try {
+ // copy the arguments
+ Object[] argsCopy = Util.copyObjects(args, stub._orb());
+
+ // invoke the servant
+ Object result = null;
+ try {
+ result = method.invoke(servantObject.servant, argsCopy);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() != null) {
+ throw e.getCause();
+ }
+ throw e;
+ }
+
+ // copy the result
+ result = Util.copyObject(result, stub._orb());
+
+ return result;
+ } catch (Throwable throwable) {
+ // copy the exception
+ Throwable throwableCopy = (Throwable) Util.copyObject(throwable, stub._orb());
+
+ // if it is one of my exception rethrow it
+ Class[] exceptionTypes = method.getExceptionTypes();
+ for (int i = 0; i < exceptionTypes.length; i++) {
+ Class exceptionType = exceptionTypes[i];
+ if (exceptionType.isInstance(throwableCopy)) {
+ throw throwableCopy;
+ }
+ }
+
+ throw Util.wrapException(throwableCopy);
+ } finally {
+ stub._servant_postinvoke(servantObject);
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/UtilInitializer.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/UtilInitializer.java
new file mode 100644
index 0000000000..f9aa9ffa22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/UtilInitializer.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.corba;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableInterceptor.ORBInitInfo;
+import org.omg.PortableInterceptor.ORBInitializer;
+
+/**
+ * The sole purpose of this initializer is to register a non-singleton ORB
+ * with the class <code>Util</code>.
+ *
+ * @version $Revision$ $Date$
+ * @see Java2IDLUtil
+ */
+public class UtilInitializer extends LocalObject implements ORBInitializer {
+
+ private static final long serialVersionUID = 4901857563505370955L;
+
+ /**
+ * Called during ORB initialization. If it is expected that initial
+ * services registered by an interceptor will be used by other
+ * interceptors, then those initial services shall be registered at
+ * this point via calls to
+ * <code>ORBInitInfo.register_initial_reference</code>.
+ *
+ * @param info provides initialization attributes and operations by
+ * which Interceptors can be registered.
+ */
+ public void pre_init(ORBInitInfo info) {
+ }
+
+ /**
+ * Called during ORB initialization. If a service must resolve initial
+ * references as part of its initialization, it can assume that all
+ * initial references will be available at this point.
+ * <p/>
+ * Calling the <code>post_init</code> operations is not the final
+ * task of ORB initialization. The final task, following the
+ * <code>post_init</code> calls, is attaching the lists of registered
+ * interceptors to the ORB. Therefore, the ORB does not contain the
+ * interceptors during calls to <code>post_init</code>. If an
+ * ORB-mediated call is made from within <code>post_init</code>, no
+ * request interceptors will be invoked on that call.
+ * Likewise, if an operation is performed which causes an IOR to be
+ * created, no IOR interceptors will be invoked.
+ *
+ * @param info provides initialization attributes and
+ * operations by which Interceptors can be registered.
+ */
+ public void post_init(ORBInitInfo info) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
new file mode 100644
index 0000000000..323fa76006
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.ejb.provider;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.binding.ejb.util.EJBHandler;
+import org.apache.tuscany.sca.binding.ejb.util.NamingEndpoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * EJBTargetInvoker
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBBindingInvoker implements Invoker {
+
+ private Operation operation;
+ private String location;
+ private Class serviceInterface;
+
+ public EJBBindingInvoker(EJBBinding ejbBinding, Class serviceInterface, Operation operation) {
+ this.serviceInterface = serviceInterface;
+ this.location = ejbBinding.getURI();
+ this.operation = operation;
+ }
+
+ public Message invoke(Message msg) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(serviceInterface.getClassLoader());
+ Object resp = doInvoke(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ msg.setFaultBody(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ return msg;
+ }
+
+ /**
+ * Invoke a EJB operation
+ *
+ * @param payload
+ * @return
+ */
+ public Object doInvoke(final Object payload) {
+
+ // construct NamingendPoint
+ NamingEndpoint endpoint = getNamingEndpoint();
+
+ // lookup home and ejb stub
+ EJBHandler ejbHandler = new EJBHandler(endpoint, serviceInterface);
+
+ //
+ // If we really couldn't have anything but a JavaOperation maybe we should
+ // remove the if-block. Assuming we had some other type of operation, if
+ // that is possible, we might still need to map to a Java operation name,
+ // (for example because the WSDL operation name might be set using a JSR-181
+ // annotation to something other than the Java operation name.
+ //
+ // But for now we'll keep the else-block in here.
+ //
+ String methodName = null;
+ if (operation instanceof JavaOperation) {
+ JavaOperation javaOp = (JavaOperation) operation;
+ methodName = javaOp.getJavaMethod().getName();
+ } else {
+ methodName = operation.getName();
+ }
+
+ // invoke business method on ejb
+ Object response = ejbHandler.invoke(methodName, (Object[])payload);
+
+ return response;
+ }
+
+ protected NamingEndpoint getNamingEndpoint() {
+ return new NamingEndpoint(location);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java
new file mode 100644
index 0000000000..e94ac8bce1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.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 org.apache.tuscany.sca.binding.ejb.provider;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * A factory from creating the EJB binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBBindingProviderFactory implements BindingProviderFactory<EJBBinding> {
+
+ public EJBBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ // empty constructor
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new EJBBindingReferenceBindingProvider((RuntimeComponent)endpointReference.getComponent(),
+ (RuntimeComponentReference)endpointReference.getReference(),
+ (EJBBinding)endpointReference.getBinding());
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ // Service Binding not supported for EJB Binding
+ return null;
+ }
+
+ public Class<EJBBinding> getModelType() {
+ return EJBBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java
new file mode 100644
index 0000000000..2a02bf0d08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.provider;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of the ReferenceBindingProvider for the EJBBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBBindingReferenceBindingProvider implements ReferenceBindingProvider {
+ private EJBBinding ejbBinding;
+ private RuntimeComponentReference reference;
+
+ /**
+ * Constructor
+ *
+ * @param component
+ * @param reference
+ * @param binding
+ */
+ public EJBBindingReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ EJBBinding binding) {
+ this.reference = reference;
+ this.ejbBinding = binding;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Invoker createInvoker(Operation operation) {
+ return new EJBBindingInvoker(ejbBinding, ((JavaInterface)reference.getInterfaceContract().getInterface())
+ .getJavaClass(), operation);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
new file mode 100644
index 0000000000..c7c0f90710
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java
@@ -0,0 +1,338 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.RemoteException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ejb.EJBObject;
+import javax.rmi.CORBA.Util;
+
+import org.apache.tuscany.sca.binding.ejb.corba.ClassLoadingUtil;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * EJBMessageHandler
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBHandler {
+ private static final Map<String, Class> PRIMITIVE_TYPES = new HashMap<String, Class>();
+ static {
+ PRIMITIVE_TYPES.put("boolean", boolean.class);
+ PRIMITIVE_TYPES.put("byte", byte.class);
+ PRIMITIVE_TYPES.put("char", char.class);
+ PRIMITIVE_TYPES.put("short", short.class);
+ PRIMITIVE_TYPES.put("int", int.class);
+ PRIMITIVE_TYPES.put("long", long.class);
+ PRIMITIVE_TYPES.put("float", float.class);
+ PRIMITIVE_TYPES.put("double", double.class);
+ PRIMITIVE_TYPES.put("void", void.class);
+ }
+
+ private Object ejbStub;
+
+ private InterfaceInfo interfaceInfo;
+ private Class ejbInterface;
+
+ public EJBHandler(NamingEndpoint namingEndpoint, Class ejbInterface) {
+ this(namingEndpoint, InterfaceInfo.getInstance(ejbInterface));
+ this.ejbInterface = ejbInterface;
+ }
+
+ // locates the stub
+ private EJBHandler(NamingEndpoint namingEndpoint, InterfaceInfo ejbInterface) {
+ try {
+ this.ejbStub = EJBStubHelper.lookup(namingEndpoint, ejbInterface);
+ this.interfaceInfo = ejbInterface;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ private static Class loadClass(final String name) {
+ try {
+ return ClassLoadingUtil.loadClass(name, Thread.currentThread().getContextClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ // invokes EJB method
+ public Object invoke(String methodName, Object[] args) {
+ Object response = null;
+ try {
+ if (ejbStub instanceof ObjectImpl) {
+ ObjectImpl objectImpl = (ObjectImpl)ejbStub;
+ // TODO: If the Java 2 security is turned on, then
+ // the ORB will try to create proxy
+ // from the interfaces defined on the stub
+ if (System.getSecurityManager() == null && objectImpl._is_local()) {
+ /*
+ * CORBA.Stub is what the object from JNDI will be for a
+ * remote EJB in the same JVM as the client, but with no
+ * stub classes available on the client
+ */
+ response = invokeLocalCORBACall(objectImpl, methodName, args);
+ } else {
+ /*
+ * _EJBObject_Stub is what the object from JNDI will be for
+ * a remote EJB with no stub classes available on the client
+ */
+ response = invokeRemoteCORBACall(objectImpl, methodName, args);
+ }
+ } else {
+ /*
+ * A generated ejb stub or it must be an EJB in the same ear as
+ * the client or an AppServer with a single ClassLoader, so
+ * reflection can be used directly on the JNDI
+ */
+ JavaReflectionAdapter reflectionAdapter =
+ JavaReflectionAdapter.createJavaReflectionAdapter(ejbStub.getClass());
+ try {
+ Method method = reflectionAdapter.getMethod(methodName);
+ response = method.invoke(ejbStub, args);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ // FIXME need to throw really a business exception.
+ // ServiceBusinessException?
+ // Tuscany core doesn't have ServiceBusinessException
+ throw new ServiceRuntimeException(t);
+ }
+ }
+
+ return response;
+ } catch (Exception e) {
+ // FIXME this be business exception? Tuscany core doesn't have
+ // ServiceBusinessException
+ throw new ServiceRuntimeException(e);
+
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Get the IDL operation name for a java method
+ *
+ * @param methodName java method name
+ * @return The IDL operation name
+ */
+ private String getOperation(String methodName) {
+ if (interfaceInfo == null) {
+ return methodName;
+ }
+ MethodInfo methodInfo = interfaceInfo.getMethod(methodName);
+ if (methodInfo != null) {
+ return methodInfo.getIDLName();
+ } else {
+ return null;
+ }
+ }
+
+ /*
+ * Derive the EJB interface name from the Stub When loading a stub class
+ * corresponding to an interface or class <packagename>.<typename>, the
+ * class <packagename>._<typename>_Stub shall be used if it exists;
+ * otherwise, the class org.omg.stub.<packagename>._<typename>_Stub shall
+ * be used.
+ */
+ private static String getInterface(String stubName) {
+ int index = stubName.lastIndexOf('.');
+ String packageName = null;
+ String typeName = stubName;
+ if (index != -1) {
+ packageName = stubName.substring(0, index);
+ if (packageName.startsWith("org.omg.stub.")) {
+ packageName = packageName.substring("org.omg.stub.".length());
+ }
+ typeName = stubName.substring(index + 1);
+ }
+ if (typeName.startsWith("_") && typeName.endsWith("_Stub")) {
+ typeName = typeName.substring(1, typeName.length() - "_Stub".length());
+ }
+ if (packageName != null)
+ return packageName + "." + typeName;
+ else
+ return typeName;
+ }
+
+ /**
+ * Invoke a method on the local CORBA object
+ *
+ * @param stub
+ * @param methodName
+ * @param args
+ * @return
+ * @throws RemoteException
+ * @throws ServiceBusinessException
+ */
+ private Object invokeLocalCORBACall(final ObjectImpl stub, String methodName, Object[] args)
+ throws RemoteException {
+
+ final String operation = getOperation(methodName);
+
+ Class type = loadClass(getInterface(stub.getClass().getName()));
+ if (type == null)
+ type = (ejbInterface != null) ? ejbInterface : EJBObject.class;
+
+ ServantObject so = stub._servant_preinvoke(operation, type);
+ if (so == null) {
+ // The Servant is not local any more
+ return invokeRemoteCORBACall(stub, methodName, args);
+ }
+ Object[] newArgs = null;
+ ORB orb = stub._orb();
+ try {
+ if (args != null)
+ newArgs = Util.copyObjects(args, orb);
+ JavaReflectionAdapter reflectionAdapter =
+ JavaReflectionAdapter.createJavaReflectionAdapter(so.servant.getClass());
+ Method method = reflectionAdapter.getMethod(methodName);
+ Object obj = reflectionAdapter.invoke(method, so.servant, newArgs);
+ Object result = Util.copyObject(obj, orb);
+ return result;
+
+ } catch (InvocationTargetException e) {
+ Throwable exCopy = (Throwable)Util.copyObject(e.getTargetException(), orb);
+ MethodInfo methodInfo = interfaceInfo.getMethod(methodName);
+ String[] exceptionTypes = methodInfo.getExceptionTypes();
+ for (int i = 0; i < exceptionTypes.length; i++) {
+ Class exceptionType =
+ methodInfo.getMethod() != null ? methodInfo.getMethod().getExceptionTypes()[i]
+ : loadClass(exceptionTypes[i]);
+ if (exceptionType.isAssignableFrom(exCopy.getClass()))
+ throw new ServiceRuntimeException(exCopy); // FIXME should
+ // be business
+ // exception?
+ }
+ throw Util.wrapException(exCopy);
+ } catch (Throwable e) {
+ // Other exceptions thrown from "invoke"
+ throw new ServiceRuntimeException(e);
+ } finally {
+ stub._servant_postinvoke(so);
+ }
+ }
+
+ /**
+ * Invoke a method on a remote CORBA object
+ *
+ * @param stub The remote stub
+ * @param methodName The name of the method
+ * @param args Argument list
+ * @return
+ * @throws RemoteException
+ * @throws ServiceBusinessException
+ */
+ private Object invokeRemoteCORBACall(ObjectImpl stub, String methodName, Object[] args) throws RemoteException {
+
+ try {
+ String operation = getOperation(methodName);
+
+ MethodInfo methodInfo = interfaceInfo.getMethod(methodName);
+ if (methodInfo == null) {
+ throw new ServiceRuntimeException("Invalid Method " + methodName);
+ }
+ Class[] parameterTypes = null;
+ Class returnType = null;
+ if (methodInfo.getMethod() != null) {
+ parameterTypes = methodInfo.getMethod().getParameterTypes();
+ returnType = methodInfo.getMethod().getReturnType();
+ } else {
+ String[] types = methodInfo.getParameterTypes();
+ if (args != null) {
+ if (types.length != args.length)
+ throw new ServiceRuntimeException(
+ "The argument list doesn't match the method signature of " + methodName);
+ }
+
+ parameterTypes = new Class[types.length];
+ for (int i = 0; i < types.length; i++) {
+ parameterTypes[i] = loadClass(types[i]);
+ }
+ returnType = loadClass(methodInfo.getReturnType());
+ }
+
+ InputStream in = null;
+ try {
+ OutputStream out = (OutputStream)stub._request(operation, true);
+
+ for (int i = 0; i < parameterTypes.length; i++) {
+ // Object arg = (args.length < i) ? null : args[i];
+ writeValue(out, args[i], parameterTypes[i]);
+ }
+ if (returnType == void.class) {
+ // void return
+ stub._invoke(out);
+ return null;
+ } else {
+ // read the return value
+ in = (InputStream)stub._invoke(out);
+ Object response = readValue(in, returnType);
+ return response;
+ }
+
+ } catch (ApplicationException ex) {
+ in = (InputStream)ex.getInputStream();
+ try {
+ org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.throwException(methodInfo.getMethod(), in);
+ return null;
+ } catch (Throwable e) {
+ throw new RemoteException(e.getMessage(), e);
+ }
+ } catch (RemarshalException ex) {
+ return invokeRemoteCORBACall(stub, methodName, args);
+ } finally {
+ stub._releaseReply(in);
+ }
+ } catch (SystemException ex) {
+ throw Util.mapSystemException(ex);
+ }
+ }
+
+ /**
+ * @param out
+ * @param value
+ * @param type
+ */
+ private void writeValue(OutputStream out, Object value, Class type) {
+ org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.writeObject(type, value, out);
+ }
+
+ /**
+ * @param in
+ * @param type
+ * @return
+ */
+ private Object readValue(InputStream in, Class type) {
+ return org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.readObject(type, in);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
new file mode 100644
index 0000000000..0b97f42746
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java
@@ -0,0 +1,483 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.util;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NamingContextExt;
+
+/**
+ * CosNaming utility
+ *
+ * @version $Rev$ $Date$
+ */
+class EJBLocator {
+
+ /*
+ * Root Context Initial Reference Key ------------
+ * ----------------------------------- Server Root NameServiceServerRoot
+ * Cell Persistent Root NameServiceCellPersistentRoot Cell Root
+ * NameServiceCellRoot, NameService Node Root NameServiceNodeRoot
+ */
+ public static final String SERVER_ROOT = "NameServiceServerRoot";
+ public static final String CELL_PERSISTENT_ROOT = "NameServiceCellPersistentRoot";
+ public static final String CELL_ROOT = "NameServiceCellRoot";
+ public static final String NODE_ROOT = "NameServiceNodeRoot";
+ public static final String DEFAULT_ROOT = "NameService"; // Same as
+ // CELL_ROOT
+
+ public static final String DEFAULT_HOST = "127.0.0.1"; // Default host name
+ // or IP address for
+ // WebSphere
+ public static final int DEFAULT_NAMING_PORT = 2809; // Default port
+ public static final String NAMING_SERVICE = "NameService"; // The name of
+ // the naming
+ // service
+ private static final Set<String> ROOTS =
+ new HashSet<String>(Arrays.asList(new String[] {SERVER_ROOT, CELL_PERSISTENT_ROOT, CELL_ROOT, DEFAULT_ROOT,
+ NODE_ROOT}));
+
+ // private static final String CHARS_TO_ESCAPE = "\\/.";
+ private static final String RFC2396 =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789;/:?@&=+$,-_.!~*'()";
+ private static final String HEX = "0123456789ABCDEF";
+
+ private String hostName = DEFAULT_HOST;
+ private int port = DEFAULT_NAMING_PORT;
+ private String root = SERVER_ROOT;
+
+ private ORB orb = null;
+ private ObjectLocator locator = null;
+ private boolean managed = true;
+
+ EJBLocator(boolean managed) {
+ this.managed = managed;
+ if (!managed) {
+ String url = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(Context.PROVIDER_URL);
+ }
+ });
+ processCorbaURL(url);
+ }
+ }
+
+ EJBLocator(String hostName, int port) {
+ this.hostName = (hostName == null) ? DEFAULT_HOST : hostName;
+ this.port = port > 0 ? port : DEFAULT_NAMING_PORT;
+ this.root = SERVER_ROOT;
+ }
+
+ EJBLocator(String hostName, int port, String root) {
+ this(hostName, port);
+ if (ROOTS.contains(root)) {
+ this.root = root;
+ } else {
+ throw new IllegalArgumentException(root + " is not a legal root");
+ }
+ }
+
+ EJBLocator(String corbaName, boolean managed) {
+ this.managed = managed;
+ if (corbaName.startsWith("corbaname:iiop:")) {
+ processCorbaURL(corbaName);
+ } else {
+ throw new IllegalArgumentException(corbaName + " is not a legal corbaname");
+ }
+ }
+
+ private void processCorbaURL(String url) {
+ if (url != null && (url.startsWith("corbaname:iiop:") || url.startsWith("corbaloc:iiop:"))) {
+ /**
+ * corbaname:iiop:<hostName>:<port>/<root>#name corbaloc:iiop:<hostname>:<port>/<root>
+ * For example,
+ * "corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/MyEJBHome";
+ * or "corbaloc:iiop:myhost:2809/NameServiceServerRoot"
+ */
+ String[] parts = url.split("(:|/|#)");
+ if (parts.length > 2 && parts[2].length() > 0) {
+ hostName = parts[2]; // The host name
+ int index = hostName.lastIndexOf('@'); // version@hostname
+ if (index != -1) {
+ hostName = hostName.substring(index + 1);
+ }
+ }
+ if (parts.length > 3 && parts[3].length() > 0) {
+ port = Integer.parseInt(parts[3]); // The port number
+ }
+ if (parts.length > 4 && parts[4].length() > 0) {
+ root = parts[4]; // The root of naming
+ }
+ }
+ }
+
+ /**
+ * The corbaloc and corbaname formats enable you to provide a URL to access
+ * CORBA objects. Use the corbaloc format for resolving to a particular
+ * CORBAservice without going through a naming service. Use the corbaname
+ * format to resolve a stringified name from a specific naming context.
+ */
+
+ /**
+ * corbaname Syntax The full corbaname BNF is: &lt;corbaname&gt; =
+ * "corbaname:"&lt;corbaloc_obj&gt;["#"&lt;string_name&gt;]
+ * &lt;corbaloc_obj&gt; = &lt;obj_addr_list&gt; ["/"&lt;key_string&gt;]
+ * &lt;obj_addr_list&gt; = as defined in a corbaloc URL &lt;key_string&gt; =
+ * as defined in a corbaloc URL &lt;string_name&gt;= stringified Name
+ * empty_string Where:
+ * <ul>
+ * <li>corbaloc_obj: portion of a corbaname URL that identifies the naming
+ * context. The syntax is identical to its use in a corbaloc URL.
+ * <li>obj_addr_list: as defined in a corbaloc URL
+ * <li>key_string: as defined in a corbaloc URL.
+ * <li>string_name: a stringified Name with URL escapes as defined below.
+ * </ul>
+ *
+ * @param hostName The host name or IP address of the naming server
+ * @param port The port number of the naming service
+ * @param root The root of the namespace
+ * @param name The JNDI name
+ */
+ private static String getCorbaname(String hostName, int port, String root, String name) {
+ if (name == null) {
+ return "corbaname:iiop:" + hostName + ":" + port + "/" + root;
+ } else {
+ return "corbaname:iiop:" + hostName + ":" + port + "/" + root + "#" + toCorbaname(name);
+ }
+ }
+
+ String getCorbaname(String name) {
+ return getCorbaname(hostName, port, root, name);
+ }
+
+ /**
+ * Connect to the ORB.
+ */
+
+ // FIXME. May need to change the IBM classes if this binding is contributed
+ // to Tuscany
+ public ORB connect() {
+ if (orb == null) {
+ Properties props = new Properties();
+ /*
+ * This code is for IBM JVM props.put("org.omg.CORBA.ORBClass",
+ * "com.ibm.CORBA.iiop.ORB");
+ * props.put("com.ibm.CORBA.ORBInitRef.NameService",
+ * getCorbaloc(NAMING_SERVICE));
+ * props.put("com.ibm.CORBA.ORBInitRef.NameServiceServerRoot",
+ * getCorbaloc("NameServiceServerRoot"));
+ */
+ orb = ORB.init((String[])null, props);
+ }
+ return orb;
+ }
+
+ /**
+ * Replace substrings
+ *
+ * @param source The source string.
+ * @param match The string to search for within the source string.
+ * @param replace The replacement for any matching components.
+ * @return
+ */
+ private static String replace(String source, String match, String replace) {
+ int index = source.indexOf(match, 0);
+ if (index >= 0) {
+
+ // We have at least one match, so got to do the
+ // work...
+
+ StringBuffer result = new StringBuffer(source.length() + 16);
+ int matchLength = match.length();
+ int startIndex = 0;
+
+ while (index >= 0) {
+ result.append(source.substring(startIndex, index));
+ result.append(replace);
+ startIndex = index + matchLength;
+ index = source.indexOf(match, startIndex);
+ }
+
+ // Grab the last piece, if any...
+ if (startIndex < source.length()) {
+ result.append(source.substring(startIndex));
+ }
+
+ return result.toString();
+
+ } else {
+ // No matches, just return the source...
+ return source;
+ }
+ }
+
+ /**
+ * Resolved the JNDI name from the initial CosNaming context
+ *
+ * @param jndiName
+ * @return resolved CORBA object
+ * @throws NamingException
+ */
+ private static org.omg.CORBA.Object resovleString(NamingContextExt initCtx, String jndiName) throws NamingException {
+ try {
+ String name = stringify(jndiName);
+ return initCtx.resolve_str(name);
+ } catch (Exception e) {
+ NamingException ne = new NamingException(e.getMessage());
+ ne.setRootCause(e);
+ throw ne;
+ }
+ }
+
+ /**
+ * Look up a CORBA object by its JNDI name
+ *
+ * @param jndiName
+ * @return
+ * @throws NamingException
+ */
+ org.omg.CORBA.Object stringToObject(String jndiName) throws NamingException {
+ /*
+ * Using an existing ORB and invoking string_to_object with a CORBA
+ * object URL with multiple name server addresses to get an initial
+ * context CORBA object URLs can contain more than one bootstrap server
+ * address. Use this feature when attempting to obtain an initial
+ * context from a server cluster. You can specify the bootstrap server
+ * addresses for all servers in the cluster in the URL. The operation
+ * will succeed if at least one of the servers is running, eliminating a
+ * single point of failure. There is no guarantee of any particular
+ * order in which the address list will be processed. For example, the
+ * second bootstrap server address may be used to obtain the initial
+ * context even though the first bootstrap server in the list is
+ * available. An example of a corbaloc URL with multiple addresses
+ * follows. obj =
+ * orb.string_to_object("corbaloc::myhost1:9810,:myhost1:9811,:myhost2:9810/NameService");
+ */
+ String corbaName = null;
+ if (jndiName.startsWith("corbaloc:") || jndiName.startsWith("corbaname:")) {
+ // Keep the qualified URL
+ corbaName = jndiName;
+ } else {
+ // Create a corbaname URL
+ corbaName = getCorbaname(jndiName);
+ }
+
+ connect();
+ org.omg.CORBA.Object obj = orb.string_to_object(corbaName);
+ return obj;
+ }
+
+ private boolean isJndiConfigured() {
+ if (managed)
+ return true;
+ Boolean provided = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ String initCtxFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ if (initCtxFactory == null) {
+ URL file = Thread.currentThread().getContextClassLoader().getResource("jndi.properties");
+ if (file != null) {
+ return Boolean.TRUE;
+ } else {
+ return Boolean.FALSE;
+ }
+ } else {
+ return Boolean.TRUE;
+ }
+ }
+ });
+ return provided.booleanValue();
+ }
+
+ /**
+ * The character escape rules for the stringified name portion of an
+ * corbaname are: US-ASCII alphanumeric characters are not escaped.
+ * Characters outside this range are escaped, except for the following: ; / : ? @ & = + $ , - _ . ! ~ * ' ( )
+ * corbaname Escape Mechanism The percent '%' character is used as an
+ * escape. If a character that requires escaping is present in a name
+ * component it is encoded as two hexadecimal digits following a "%"
+ * character to represent the octet. (The first hexadecimal character
+ * represent the highorder nibble of the octet, the second hexadecimal
+ * character represents the low-order nibble.) If a '%' is not followed by
+ * two hex digits, the stringified name is syntactically invalid.
+ * @param s
+ * @return RFC2396-encoded stringified name
+ */
+ static String encode2396(String s) {
+ if (s == null) {
+ return null;
+ }
+ StringBuffer encoded = new StringBuffer(s);
+ for (int i = 0; i < encoded.length(); i++) {
+ char c = encoded.charAt(i);
+ if (RFC2396.indexOf(c) == -1) {
+ encoded.setCharAt(i, '%');
+ char[] ac = Integer.toHexString(c).toCharArray();
+ if (ac.length == 2) {
+ encoded.insert(i + 1, ac);
+ } else if (ac.length == 1) {
+ encoded.insert(i + 1, '0');
+ encoded.insert(i + 2, ac[0]);
+ } else {
+ throw new IllegalArgumentException("Invalid character '" + c + "' in \"" + s + "\"");
+ }
+ i += 2; // NOPMD
+ }
+ }
+ return encoded.toString();
+ }
+
+ /**
+ * Decode an RFC2396-encoded string
+ *
+ * @param s
+ * @return Plain string
+ */
+ static String decode2396(String s) {
+ if (s == null) {
+ return null;
+ }
+ StringBuffer decoded = new StringBuffer(s);
+ for (int i = 0; i < decoded.length(); i++) {
+ char c = decoded.charAt(i);
+ if (c == '%') {
+ if (i + 2 >= decoded.length()) {
+ throw new IllegalArgumentException("Incomplete key_string escape sequence");
+ }
+ int j;
+ j = HEX.indexOf(decoded.charAt(i + 1)) * 16 + HEX.indexOf(decoded.charAt(i + 2));
+ decoded.setCharAt(i, (char)j);
+ decoded.delete(i + 1, i + 3);
+ } else if (RFC2396.indexOf(c) == -1) {
+ throw new IllegalArgumentException("Invalid key_string character '" + c + "'");
+ }
+ }
+ return decoded.toString();
+ }
+
+ /**
+ * The backslash '\' character escapes the reserved meaning of '/', '.', and
+ * '\' in a stringified name.
+ *
+ * @param jndiName
+ * @return Escaped stringified name for CosNaming
+ */
+ private static String stringify(String jndiName) {
+ // Escape . into \. since it's an INS naming delimiter
+ return replace(encode2396(jndiName), ".", "\\.");
+ }
+
+ /**
+ * Escape the "." into "%5C%2E"
+ *
+ * @param jndiName
+ * @return corbaname treating "." as a literal
+ */
+ private static String toCorbaname(String jndiName) {
+ // Escape . into %5C%2E (\.) since it's an INS naming delimiter
+ // For example, sca.sample.StockQuote --->
+ // sca%5C%2Esample%5C%2EStockQuote/StockQuote
+ return replace(encode2396(jndiName), ".", "%5C%2E");
+ }
+
+ private ObjectLocator getObjectLocator() throws NamingException {
+ if (locator != null) {
+ return locator;
+ }
+ /*
+ * For managed env, JNDI is assumed to be configured by default For
+ * unmanaged environment, JNDI could have configured through
+ * jndi.properties file
+ */
+ if (isJndiConfigured()) {
+ locator = new JndiLocator();
+ } else { // this is definitely JSE env without JNDI configured. Use
+ // CORBA.
+ locator = new CosNamingLocator();
+ }
+ return locator;
+ }
+
+ public Object locate(String jndiName) throws NamingException {
+
+ Object result = getObjectLocator().locate(jndiName);
+ return result;
+ }
+
+ private static interface ObjectLocator {
+ Object locate(String name) throws NamingException;
+ }
+
+ private final class JndiLocator implements ObjectLocator {
+ private Context context;
+
+ private JndiLocator() throws NamingException {
+ /*
+ final Properties props = AccessController.doPrivileged(new PrivilegedAction<Properties>() {
+ public Properties run() {
+ return System.getProperties();
+ }
+ });
+ Properties properties = new Properties();
+ for (Map.Entry e : props.entrySet()) {
+ String name = (String)e.getKey();
+ if (name.startsWith("java.naming.")) {
+ properties.setProperty(name, (String)e.getValue());
+ }
+ }
+ // System.out.println(properties);
+ this.context = new InitialContext(properties);
+ */
+ this.context = new InitialContext();
+ }
+
+ public Object locate(String name) throws NamingException {
+ return context.lookup(name);
+ }
+ }
+
+ private final class CosNamingLocator implements ObjectLocator {
+ private NamingContextExt context;
+
+ private CosNamingLocator() {
+ }
+
+ public Object locate(String name) throws NamingException {
+ if (context != null) {
+ return resovleString(context, name);
+ } else {
+ return stringToObject(name);
+ }
+ }
+ }
+
+ public void setHostEnv(boolean managed) {
+ this.managed = managed;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java
new file mode 100644
index 0000000000..119282adb9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import javax.naming.NamingException;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.stub.java.rmi._Remote_Stub;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Factor class that is used to create EJB Proxies.
+ *
+ * @version $Rev$ $Date$
+ */
+final class EJBObjectFactory {
+
+ private EJBObjectFactory() {
+ }
+
+ /**
+ * Get either a generated of dynamic EJB stub using the specified JNDI
+ * properties.
+ * <p>
+ * The returned stub will implement the specified stubInterface Interface.
+ * If the underlying EJB stub is not assignable from the specified
+ * stubInterface then a proxy is used to convert between the two.
+ * <p>
+ * The returned EJB stub may be either the pregenerated EJB stub or a
+ * dynamic stub. This allows a client to invoke an EJB without requiring any
+ * of the pregenerated EJB stub classes be available in the classpath.
+ * <p>
+ */
+ static Object createStub(NamingEndpoint namingEndpoint, InterfaceInfo ejbInterface) throws NamingException,
+ RemoteException, CreateException {
+
+ EJBLocator locator = namingEndpoint.getLocator();
+ Object homeObject = locator.locate(namingEndpoint.getJndiName());
+ /*
+ * The type of the object returned from the lookup is as follows: If the
+ * generated stub exists on the classpath, it's an instance of that
+ * type, otherwise, "org.omg.stub.java.rmi._Remote_Stub" or
+ * "org.omg.stub.javax.ejb._EJBHome_Stub"
+ */
+ Object stub = getEJBStub(homeObject, ejbInterface);
+ // Cache dynamic stub only
+ return stub;
+ }
+
+ /**
+ * @param homeObject
+ * @param ejbHomeClass
+ * @return
+ * @throws RemoteException
+ */
+ private static Object getEJBStub(Object homeObject, InterfaceInfo ejbInterface) throws RemoteException,
+ CreateException {
+
+ Object stub = null;
+
+ // Get the business interface of the EJB
+ Class ejbInterfaceClass = null;
+ try {
+ ejbInterfaceClass = Thread.currentThread().getContextClassLoader().loadClass(ejbInterface.getName());
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+
+ if (ejbInterfaceClass != null && ejbInterfaceClass.isInstance(homeObject)) {
+ // EJB 3
+ stub = homeObject;
+ } else if (homeObject instanceof EJBLocalHome) {
+ // Local EJB
+ stub = createEJBLocalObject(homeObject);
+ } else {
+ // Handle dynamic stub
+ if (homeObject instanceof ObjectImpl) {
+ ObjectImpl objectImpl = (ObjectImpl)homeObject;
+ stub = createEJBObject(objectImpl);
+ }/**
+ * Above checks will be satisfied if Bean is running on servers like WebSphere. With this
+ * logic, client (SCA composite with EJB ref binding) doesn't need to include home class or
+ * client stubs.
+ *
+ * Below check is needed SCA composite with EJB ref binding is accessing openEJB implementation.
+ * For e.g if the bean is running on Geronimo.
+ */
+ else if ((javax.rmi.PortableRemoteObject.narrow(homeObject, javax.ejb.EJBHome.class)) instanceof javax.ejb.EJBHome) {
+ stub = createEJBObjectFromHome(homeObject);
+ } else
+ throw new ServiceRuntimeException("Invalid stub type: " + homeObject.getClass());
+ }
+ return stub;
+ }
+
+ /**
+ * Create a pre-generated EJB stub
+ *
+ * @param homeObject
+ * @return
+ * @throws RemoteException
+ */
+ static private Object createEJBLocalObject(Object homeObject) throws RemoteException {
+
+ Object stub = null;
+ try {
+ // Find the "create()" method
+ Method createMethod = homeObject.getClass().getMethod("create", null);
+ // Create an EJB object
+ stub = createMethod.invoke(homeObject, null);
+ } catch (NoSuchMethodException e) {
+ // "create()" method not found, it's still a dynamic stub
+ stub = null;
+ } catch (InvocationTargetException e) {
+ throw new RemoteException(e.getTargetException().toString());
+ } catch (Exception e) {
+ throw new RemoteException(e.toString());
+ }
+ return stub;
+ }
+
+ /**
+ * Here homeObject is instance of EJBHome
+ *
+ * @param homeObject
+ * @return
+ * @throws RemoteException
+ */
+ private static Object createEJBObjectFromHome(Object homeObject) throws RemoteException {
+
+ Object stub = null;
+ try {
+ // Find the "create()" method
+ Method createMethod = homeObject.getClass().getMethod("create", null);
+ // Create an EJB object
+ stub = createMethod.invoke(homeObject, null);
+ } catch (NoSuchMethodException e) {
+ // "create()" method not found, it's still a dynamic stub
+ stub = null;
+ } catch (InvocationTargetException e) {
+ throw new RemoteException(e.getTargetException().toString());
+ } catch (Exception e) {
+ throw new RemoteException(e.toString());
+ }
+ return stub;
+ }
+
+ /**
+ * Create an EJBObject using RMI/IIOP APIs
+ *
+ * @param ejbHomeObject
+ * @return The EJBObject remote stub
+ * @throws CreateException
+ * @throws RemoteException
+ */
+ private static Object createEJBObject(ObjectImpl ejbHomeObject) throws CreateException, RemoteException {
+
+ try {
+ org.omg.CORBA_2_3.portable.InputStream in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream out = ejbHomeObject._request("create", true);
+ in = (org.omg.CORBA_2_3.portable.InputStream)ejbHomeObject._invoke(out);
+ // The Remote stub should be available in JDK
+ // TODO: [rfeng] Work around an issue in Apache Yoko which doesn't understand the org.omg.stub.*
+ return in.read_Object(_Remote_Stub.class);
+ } catch (ApplicationException ex) {
+ in = (org.omg.CORBA_2_3.portable.InputStream)ex.getInputStream();
+ String id = in.read_string();
+ if (id.equals("IDL:javax/ejb/CreateEx:1.0")) {
+ throw (CreateException)in.read_value(CreateException.class);
+ }
+ throw new UnexpectedException(id);
+ } catch (RemarshalException ex) {
+ return createEJBObject(ejbHomeObject);
+ } finally {
+ ejbHomeObject._releaseReply(in);
+ }
+ } catch (SystemException ex) {
+ throw Util.mapSystemException(ex);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java
new file mode 100644
index 0000000000..72f7dc9e43
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.util;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.naming.NamingException;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+final class EJBStubHelper {
+
+ private static Object stub;
+ private static ServiceRuntimeException exception;
+
+ private EJBStubHelper() {
+ }
+
+ /**
+ * @param owner
+ * @param jndiName
+ * @return
+ */
+
+ static Object lookup(NamingEndpoint endpoint, InterfaceInfo ejbInterface) {
+ return getStub(endpoint, ejbInterface);
+ }
+
+ private static Object getStub(NamingEndpoint namingEndpoint, InterfaceInfo ejbInterface) {
+ try {
+ stub = EJBObjectFactory.createStub(namingEndpoint, ejbInterface);
+ } catch (NamingException e) {
+ exception = new ServiceUnavailableException(e);
+ e.printStackTrace();
+ throw (ServiceUnavailableException)exception;
+ } catch (CreateException e) {
+ exception = new ServiceUnavailableException(e);
+ throw (ServiceUnavailableException)exception;
+ } catch (RemoteException e) {
+ exception = new ServiceRuntimeException(e);
+ throw (ServiceRuntimeException)exception;
+ }
+
+ if (exception == null) {
+ return stub; // Normal result
+ } else {
+ throw exception; // Throw the exception
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java
new file mode 100644
index 0000000000..e60e526e01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.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.sca.binding.ejb.util;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil;
+
+/**
+ * The signature for a java interface
+ *
+ * @version $Rev$ $Date$
+ */
+class InterfaceInfo implements Serializable {
+
+ private static final Map<Class, InterfaceInfo> INTERFACES =
+ Collections.synchronizedMap(new WeakHashMap<Class, InterfaceInfo>());
+
+ private static final long serialVersionUID = 2314533906465094860L;
+ private String name;
+
+ private Map<String, MethodInfo> methods = new HashMap<String, MethodInfo>();
+
+ InterfaceInfo(final Class iface) {
+ super();
+ if (iface == null) {
+ throw new IllegalArgumentException("The interface cannot be null");
+ }
+ this.name = iface.getName();
+ // SECURITY
+ /*
+ * Permission: accessDeclaredMembers : Access denied
+ * (java.lang.RuntimePermission accessDeclaredMembers)
+ */
+ Map idlNames = AccessController.doPrivileged(new PrivilegedAction<Map>() {
+ public Map run() {
+ return Java2IDLUtil.mapMethodToOperation(iface);
+ }
+ });
+ Iterator i = idlNames.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry)i.next();
+ Method method = (Method)entry.getKey();
+ MethodInfo methodInfo = new MethodInfo(method);
+ methodInfo.setIDLName((String) entry.getValue());
+ methods.put(method.getName(), methodInfo);
+ methods.put(methodInfo.getIDLName(), methodInfo);
+ }
+ }
+
+ static final synchronized InterfaceInfo getInstance(final Class iface) {
+ InterfaceInfo info = (InterfaceInfo)INTERFACES.get(iface);
+ if (info == null) {
+ info = new InterfaceInfo(iface);
+ INTERFACES.put(iface, info);
+ }
+ return info;
+ }
+
+ /**
+ * @return
+ */
+ Map<String, MethodInfo> getMethods() {
+ return methods;
+ }
+
+ /**
+ * @return
+ */
+ MethodInfo getMethod(String name) {
+ return (MethodInfo)methods.get(name);
+ }
+
+ /**
+ * @return
+ */
+ String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("interface ").append(name).append("{ \n");
+ Iterator i = methods.values().iterator();
+ while (i.hasNext()) {
+ MethodInfo methodInfo = (MethodInfo)i.next();
+ sb.append("\t").append(methodInfo).append("\n");
+ }
+ sb.append("};\n");
+ return sb.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java
new file mode 100644
index 0000000000..651c967aad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.util;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * An adapter for java classes, indexes the methods by name and provides an
+ * invoke method that takes a method name.
+ *
+ * @version $Rev$ $Date$
+ */
+final class JavaReflectionAdapter {
+
+ private static Map<Class, JavaReflectionAdapter> adapters =
+ Collections.synchronizedMap(new WeakHashMap<Class, JavaReflectionAdapter>());
+
+ private static final Map<Class, Object> DEFAULT_VALUES = new HashMap<Class, Object>();
+ static {
+ DEFAULT_VALUES.put(boolean.class, Boolean.FALSE);
+ DEFAULT_VALUES.put(byte.class, new Byte((byte)0));
+ DEFAULT_VALUES.put(char.class, new Character((char)0));
+ DEFAULT_VALUES.put(short.class, new Short((short)0));
+ DEFAULT_VALUES.put(int.class, Integer.valueOf(0));
+ DEFAULT_VALUES.put(long.class, new Long(0));
+ DEFAULT_VALUES.put(float.class, new Float(0.0));
+ DEFAULT_VALUES.put(double.class, new Double(0.0));
+ }
+
+ private Map<String, Method> methodMap = new HashMap<String, Method>();
+
+ /**
+ * Constructor
+ *
+ * @param clazz
+ */
+ private JavaReflectionAdapter(final Class clazz) {
+ // Index the methods on the implementation class
+ // FIXME J2 Security - promote this to callers of this method
+ Method[] methods = AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+ public Method[] run() {
+ return clazz.getMethods();
+ }
+ });
+ for (int i = 0; i < methods.length; i++) {
+ methodMap.put(methods[i].getName(), methods[i]);
+ }
+ }
+
+ /**
+ * Create a java reflection adapter
+ *
+ * @param clazz
+ */
+ static synchronized JavaReflectionAdapter createJavaReflectionAdapter(Class clazz) {
+ JavaReflectionAdapter adapter = (JavaReflectionAdapter)adapters.get(clazz);
+ if (adapter == null) {
+ adapter = new JavaReflectionAdapter(clazz);
+ adapters.put(clazz, adapter);
+ }
+ return adapter;
+ }
+
+ /**
+ * Return the specified method
+ *
+ * @param methodName
+ * @return
+ * @throws NoSuchMethodException
+ */
+ Method getMethod(String methodName) throws NoSuchMethodException {
+
+ Method method = (Method)methodMap.get(methodName);
+ if (method == null) {
+ throw new NoSuchMethodException(methodName);
+ }
+ return method;
+ }
+
+ /**
+ * Returns a map containing the methods on the class, keyed by name
+ *
+ * @return
+ */
+ Map getMethods() {
+ return methodMap;
+ }
+
+ /**
+ * Invoke a method using Java reflection.
+ *
+ * @param method
+ * @param object
+ * @param args
+ * @return
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ */
+ Object invoke(Method method, Object object, Object[] args) throws InvocationTargetException,
+ IllegalAccessException {
+ Class[] parameterTypes = method.getParameterTypes();
+ for (int i = 0; i < parameterTypes.length; i++) {
+ Class parameterType = parameterTypes[i];
+ if (args[i] == null && parameterType.isPrimitive()) {
+ args[i] = DEFAULT_VALUES.get(parameterType);
+ }
+ }
+ return method.invoke(object, args);
+ }
+
+ /**
+ * Set the java bean property
+ *
+ * @param bean
+ * @param propertyName
+ * @param value
+ * @return
+ */
+ boolean setProperty(Object bean, String propertyName, Object value) {
+ try {
+ PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, bean.getClass());
+ Method writeMethod = propertyDescriptor.getWriteMethod();
+ writeMethod.invoke(bean, new Object[] {value});
+ return true;
+ } catch (InvocationTargetException e) {
+ throw new ServiceRuntimeException(e.getTargetException());
+ } catch (Exception e) {
+ return false;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java
new file mode 100644
index 0000000000..e7ea7c9077
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.ejb.util;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * MetaData for a java method
+ *
+ * @version $Rev$ $Date$
+ */
+class MethodInfo implements Serializable {
+
+ /** Automatically generated javadoc for: serialVersionUID */
+ private static final long serialVersionUID = -5557260979514687514L;
+ private String name;
+ private String returnType;
+ private String[] parameterTypes;
+ private String[] exceptionTypes;
+
+ private String IDLName;
+
+ private transient Method method;
+
+ /**
+ * Type Signature Java Type -------------- --------- Z boolean B byte C char
+ * S short I int J long F float D double L fully-qualified-class ;
+ * fully-qualified-class [ type type[] ( arg-types ) ret-type method type
+ */
+ private static final Map signatures = new HashMap();
+ static {
+ signatures.put("Z", boolean.class);
+ signatures.put("B", byte.class);
+ signatures.put("C", char.class);
+ signatures.put("S", short.class);
+ signatures.put("I", int.class);
+ signatures.put("J", long.class);
+ signatures.put("F", float.class);
+ signatures.put("D", double.class);
+ signatures.put("V", void.class);
+ }
+
+ MethodInfo(Method method) {
+ this.method = method;
+ this.name = method.getName();
+ // this.declaringClass = method.getDeclaringClass().getName();
+ this.returnType = method.getReturnType().getName();
+ Class[] types = method.getParameterTypes();
+ this.parameterTypes = new String[types.length];
+ for (int i = 0; i < types.length; i++) {
+ this.parameterTypes[i] = types[i].getName();
+ }
+ types = method.getExceptionTypes();
+ this.exceptionTypes = new String[types.length];
+ for (int i = 0; i < types.length; i++) {
+ this.exceptionTypes[i] = types[i].getName();
+ }
+ IDLName = this.name;
+ }
+
+ MethodInfo(String name, String returnType, String[] parameterTypes, String[] exceptionTypes) {
+ this.name = name;
+ this.returnType = returnType;
+ this.parameterTypes = parameterTypes;
+ this.exceptionTypes = exceptionTypes;
+ this.IDLName = name;
+ }
+
+ /**
+ * Parse the class name from the internal signature Sample signatures: int
+ * ---> I; int[] ---> [I Object ---> java/lang/Object Object[] --->
+ * [Ljava/lang/Object;
+ *
+ * @param value
+ * @return
+ */
+ private static String getName(String signature) {
+ String name = signature;
+ // Remove leading ARRAY ([) signatures
+ int index = name.lastIndexOf('[');
+ if (index != -1)
+ name = name.substring(index + 1);
+
+ // Remove L<...>;
+ if (name.charAt(0) == 'L' && name.charAt(name.length() - 1) == ';')
+ name = name.substring(1, name.length() - 1);
+
+ // Primitive types
+ Class primitiveClass = (Class)signatures.get(name);
+ if (primitiveClass != null) {
+ name = primitiveClass.getName();
+ }
+
+ for (int i = 0; i < index + 1; i++) {
+ name = name + "[]";
+ }
+ return name;
+ }
+
+ /**
+ * @return
+ */
+ String getName() {
+ return name;
+ }
+
+ /**
+ * @return
+ */
+ String[] getParameterTypes() {
+ return parameterTypes;
+ }
+
+ /**
+ * @return
+ */
+ String getReturnType() {
+ return returnType;
+ }
+
+ /**
+ * @return
+ */
+ String[] getExceptionTypes() {
+ return exceptionTypes;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getName(returnType)).append(" ").append(name).append("(");
+ for (int j = 0; j < parameterTypes.length; j++) {
+ sb.append(getName(parameterTypes[j])).append(" ").append("arg" + j);
+ if (j < (parameterTypes.length - 1))
+ sb.append(", ");
+ }
+ sb.append(")");
+ if (exceptionTypes.length > 0) {
+ sb.append(" throws ");
+ for (int k = 0; k < exceptionTypes.length; k++) {
+ sb.append(exceptionTypes[k]);
+ if (k < (exceptionTypes.length - 1))
+ sb.append(", ");
+ }
+ }
+ sb.append(";");
+ return sb.toString();
+ }
+
+ /**
+ * @return Returns the iDLName.
+ */
+ String getIDLName() {
+ return IDLName;
+ }
+
+ /**
+ * @param name The iDLName to set.
+ */
+ void setIDLName(String name) {
+ IDLName = name;
+ }
+
+ /**
+ * @return the method
+ */
+ Method getMethod() {
+ return method;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java
new file mode 100644
index 0000000000..346b7c5cf6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.util;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+public class NamingEndpoint {
+ private String jndiName;
+ private EJBLocator locator;
+ private boolean managed = true;
+
+ public NamingEndpoint(String hostName, int port, String jndiName) {
+ this.jndiName = jndiName;
+ this.locator = new EJBLocator(hostName, port);
+ }
+
+ public NamingEndpoint(String name) {
+
+ /**
+ * by default it's a managed environment means SCA composite with ref
+ * binding is running on an AppServer. If running on J2SE, pass
+ * -Dmanaged=false for the VM
+ */
+ final String managedEnv = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("managed");
+ }
+ });
+
+ if (managedEnv != null) {
+ managed = Boolean.valueOf(managedEnv);
+ }
+
+ if ((!managed) && name.startsWith("corbaname:iiop:")) {
+ /**
+ * if (name.startsWith("corbaname:iiop:")) { corbaname:iiop:<hostName>:<port>/<root>#name
+ * For example,
+ * "corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/MyEJBHome";
+ */
+
+ String[] parts = split(name, '#');
+ if (parts.length != 2) {
+ throw new IllegalArgumentException("Invalid corbaname: " + name);
+ }
+
+ this.jndiName = name; // The logical JNDI name
+ this.locator = new EJBLocator(parts[0], managed);
+
+ } else {
+ this.jndiName = name;
+ this.locator = new EJBLocator(managed);
+ }
+
+ }
+
+ private static String[] split(String str, char ch) {
+ int index = str.lastIndexOf(ch);
+ if (index == -1) {
+ return new String[] {str, ""};
+ } else {
+ return new String[] {str.substring(0, index), str.substring(index + 1)};
+ }
+ }
+
+ /**
+ * @return Returns the jndiName.
+ */
+ public String getJndiName() {
+ return jndiName;
+ }
+
+ public EJBLocator getLocator() {
+ return locator;
+ }
+
+ public String getCorbaname() {
+ return locator.getCorbaname(jndiName);
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof NamingEndpoint) {
+ NamingEndpoint endpoint = (NamingEndpoint)obj;
+ return jndiName.equals(endpoint.jndiName);
+ }
+ return false;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return jndiName.hashCode();
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return jndiName;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..556abbaeac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.ejb.provider.EJBBindingProviderFactory;model=org.apache.tuscany.sca.binding.ejb.EJBBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties
new file mode 100644
index 0000000000..28477dd3ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+UnknownEJBSessionType = Unknown EJB Session Type of {0} for {1}
+UnknownEJBVersion = Unknown EJB Version of {0} for {1}
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java
new file mode 100644
index 0000000000..337bb004b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.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 account;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ * Compatible EJB interface
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface BankManagerFacade {
+ Double getAccountBalance( String accountNo );
+ void changeAccountBalance( String accountNo, Double balance );
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/Customer.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/Customer.java
new file mode 100644
index 0000000000..8585301868
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/Customer.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 account;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Customer {
+
+ /**
+ * This method deposits the amount. method accesses external EJB to get the
+ * current balance and add the amount to existing balance.
+ *
+ * @param accountNo The number of the account into which to deposit the money
+ * @param amount The amount to be deposited
+ * @return total amount in customer account after deposit
+ */
+ Double depositAmount(java.lang.String accountNo, Double amount);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java
new file mode 100644
index 0000000000..7406b9bd37
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.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 account;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+import calculator.AddService;
+
+@Service(Customer.class)
+public class CustomerImpl implements Customer {
+
+ private AddService extEJBService = null;
+
+ public AddService getExtEJBService() {
+ return extEJBService;
+ }
+
+ @Reference
+ public void setExtEJBService(AddService extEJBService) {
+ this.extEJBService = extEJBService;
+ }
+
+ // this method invokes external EJB through EJB reference binding
+ public Double depositAmount(java.lang.String accountNo, Double amount) {
+
+ Double total = null;
+
+ System.out.println("In component implementation. Invoking external EJB through EJB reference binding ");
+
+ try {
+ Double balance = extEJBService.add(amount.doubleValue(), 1000); //invoke external ejb through ejb reference binding
+ total = balance + amount;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return total;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java
new file mode 100644
index 0000000000..2e79080d52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/calculator/AddService.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 calculator;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@WebService
+public interface AddService {
+ @WebMethod(operationName = "Add")
+ double add(double n1, double n2);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java
new file mode 100644
index 0000000000..799bcaa672
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.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 calculator;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+public interface AddServiceHome extends EJBHome {
+
+ AddService create() throws CreateException, RemoteException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java
new file mode 100644
index 0000000000..e480e648d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.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.
+ */
+
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.apache.geronimo.samples.bank.ejb;
+
+// copied from the Geronimo Bank sample: http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html#EJBsampleapplication-overview
+
+/**
+ * Remote interface for BankManagerFacadeBean.
+ * @xdoclet-generated at ${TODAY}
+ * @copyright The XDoclet Team
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BankManagerFacade
+ extends javax.ejb.EJBObject
+{
+
+ void changeAccountBalance( java.lang.String accountNo,java.lang.Double balance )
+ throws java.rmi.RemoteException;
+
+ java.lang.Double getAccountBalance( java.lang.String accountNo )
+ throws java.rmi.RemoteException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java
new file mode 100644
index 0000000000..0d02be3b95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.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.
+ */
+
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+
+// copied from the Geronimo Bank sample: http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html#EJBsampleapplication-overview
+
+package org.apache.geronimo.samples.bank.ejb;
+
+/**
+ * Home interface for BankManagerFacadeBean.
+ * @xdoclet-generated at ${TODAY}
+ * @copyright The XDoclet Team
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BankManagerFacadeHome
+ extends javax.ejb.EJBHome
+{
+ String COMP_NAME="java:comp/env/ejb/BankManagerFacadeBean";
+ String JNDI_NAME="org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean";
+
+ org.apache.geronimo.samples.bank.ejb.BankManagerFacade create()
+ throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
new file mode 100644
index 0000000000..e002e6ccb8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.ejb.tests;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import account.Customer;
+
+/**
+ * Invokes the component which calls the reference using the EJB binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBReferenceTestCase extends TestCase {
+ private static final int MOCK_PORT = 8085;
+ private Node node;
+
+ @Override
+ protected void setUp() throws Exception {
+ System.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
+ System.setProperty("java.naming.provider.url", "ejbd://localhost:" + MOCK_PORT);
+ System.setProperty("managed", "false");
+
+ String contribution = ContributionLocationHelper.getContributionLocation(EJBReferenceTestCase.class);
+ node = NodeFactory.newInstance().createNode("account/account.composite", new Contribution("account", contribution));
+ node.start();
+
+ // To capture the network traffic for the MockServer, uncomment the next line
+ // new Thread(new SocketTracer(MOCK_PORT, OPENEJB_PORT)).start();
+
+ // Start the mock server to simulate the remote EJB
+ new Thread(new MockServer(MOCK_PORT)).start();
+
+ // Wait enough for the server to be started
+ Thread.sleep(500);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+ public void testCalculator() throws Exception {
+ Customer customer = node.getService(Customer.class, "CustomerComponent");
+ // This is one of the customer numbers in bank application running on Geronimo
+ String accountNo = "1234567890";
+ Double balance = customer.depositAmount(accountNo, new Double(100));
+ // System.out.println("Balance amount for account " + accountNo + " is $" + balance);
+ assertEquals(1200.0, balance);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java
new file mode 100644
index 0000000000..48e87fb6d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.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.binding.ejb.tests;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public class MockServer implements Runnable {
+
+ private int listen;
+ byte[][] seq =
+ {
+ {79, 69, 74, 80, 47, 51, 46, 48, 1, -84, -19, 0, 5, 119, 58, 1, 27, 0, 54, 47, 104, 101, 108, 108, 111, 45,
+ 97, 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 66, 101,
+ 97, 110, 47, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101,
+ 112},
+
+ {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 3, 1, 13, 1, 118, 114, 0, 25, 99, 97, 108, 99, 117, 108,
+ 97, 116, 111, 114, 46, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 72, 111, 109, 101, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 120, 112, 118, 114, 0, 21, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46, 65, 100, 100, 83,
+ 101, 114, 118, 105, 99, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112, 112, 112, 119, 38, 7, 0, 31, 104,
+ 101, 108, 108, 111, 45, 97, 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100, 83, 101, 114, 118,
+ 105, 99, 101, 66, 101, 97, 110, -1, -1, 0, 0},
+
+ {79, 69, 74, 80, 47, 51, 46, 48, 0, -84, -19, 0, 5, 119, 1, 10, 116, 0, 31, 104, 101, 108, 108, 111, 45, 97,
+ 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 66, 101, 97,
+ 110, 119, 2, -1, -1, 112, 119, 1, 1, 112, 118, 114, 0, 25, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46,
+ 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 72, 111, 109, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112,
+ 119, 9, 0, 6, 99, 114, 101, 97, 116, 101, 0},
+ {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 2, 1, 4, 112},
+
+ {79, 69, 74, 80, 47, 51, 46, 48, 0, -84, -19, 0, 5, 119, 1, 23, 116, 0, 31, 104, 101, 108, 108, 111, 45, 97,
+ 100, 100, 115, 101, 114, 118, 105, 99, 101, 47, 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 66, 101, 97,
+ 110, 119, 2, -1, -1, 112, 119, 1, 1, 112, 118, 114, 0, 21, 99, 97, 108, 99, 117, 108, 97, 116, 111, 114, 46,
+ 65, 100, 100, 83, 101, 114, 118, 105, 99, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 112, 119, 24, 0, 3, 97,
+ 100, 100, 2, 4, 64, 89, 0, 0, 0, 0, 0, 0, 4, 64, -113, 64, 0, 0, 0, 0, 0},
+ {79, 69, 74, 80, 47, 50, 46, 48, -84, -19, 0, 5, 119, 2, 1, 4, 115, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97,
+ 110, 103, 46, 68, 111, 117, 98, 108, 101, -128, -77, -62, 74, 41, 107, -5, 4, 2, 0, 1, 68, 0, 5, 118, 97,
+ 108, 117, 101, 120, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 78, 117, 109, 98, 101, 114,
+ -122, -84, -107, 29, 11, -108, -32, -117, 2, 0, 0, 120, 112, 64, -111, 48, 0, 0, 0, 0, 0}
+
+ };
+
+ public MockServer(int listen) {
+ this.listen = listen;
+ }
+
+ public void run() {
+ try {
+ ServerSocket ss = new ServerSocket(listen);
+ for (int i = 0; i < seq.length; i += 2) {
+ // System.out.println("Processing request[" + i/2 + "]");
+ doExchange(ss.accept(), seq[i], seq[i + 1]);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void doExchange(Socket socket, byte[] read, byte[] write) throws IOException, InterruptedException {
+ Thread t2 = readBytes(socket, read.length);
+ Thread t1 = writeBytes(socket, write);
+ t1.join();
+ t2.join();
+ socket.close();
+ }
+
+ private Thread readBytes(Socket socket, int x) throws IOException, InterruptedException {
+ byte[] buf = new byte[x];
+ Thread t = new Reader(socket, buf);
+ t.start();
+ return t;
+ }
+
+ private Thread writeBytes(Socket socket, byte[] bs) throws IOException, InterruptedException {
+ Thread t = new Writer(socket, bs);
+ t.start();
+ return t;
+ }
+
+ private static class Reader extends Thread {
+
+ private InputStream is;
+ private byte[] buf;
+
+ Reader(Socket socket, byte[] buf) throws IOException {
+ this.is = socket.getInputStream();
+ this.buf = buf;
+ }
+
+ @Override
+ public void run() {
+ try {
+ int totalSize = buf.length;
+ int readSize = 0;
+ int offset = 0;
+ while (totalSize > 0 && (readSize = is.read(buf, offset, totalSize)) != -1) {
+ offset += readSize;
+ totalSize -= readSize;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private static class Writer extends Thread {
+
+ private OutputStream os;
+ private byte[] buf;
+
+ Writer(Socket socket, byte[] buf) throws IOException {
+ this.os = socket.getOutputStream();
+ this.buf = buf;
+ }
+
+ @Override
+ public void run() {
+ try {
+ os.write(buf);
+ os.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java
new file mode 100644
index 0000000000..66b3feb458
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.tests;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * Displays the bytes flowing across a Socket connection.
+ * Used to get the read count and reply data for the MockServer
+ *
+ * @version $Rev$ $Date$
+ */
+public class SocketTracer implements Runnable {
+
+ private int listen;
+ private int send;
+
+ SocketTracer(int listen, int send) {
+ this.listen = listen;
+ this.send = send;
+ }
+
+ public void run() {
+ try {
+ ServerSocket ss = new ServerSocket(listen);
+ while (true) {
+ Socket sin = ss.accept();
+
+ Socket sout = new Socket("localhost", send);
+
+ Thread st = new Thread(new Send(sin, sout));
+ st.start();
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @param buf
+ * @param count
+ */
+ static synchronized void dump(String str, byte[] buf, int count) {
+ // System.out.println(Thread.currentThread());
+ System.out.print(str+"{");
+ for (int j = 0; j < count; j++) {
+ if (j == count - 1) {
+ System.out.println(buf[j] + "}, ");
+ } else {
+ System.out.print(buf[j] + ", ");
+ }
+ }
+ }
+}
+
+
+class Send implements Runnable {
+
+ Socket sin;
+ Socket sout;
+
+ Send(Socket sin, Socket sout) {
+ this.sin = sin;
+ this.sout = sout;
+ }
+
+ public void run() {
+ try {
+
+ Reply rr = new Reply(sout.getInputStream(), sin.getOutputStream());
+ Thread rt = new Thread(rr);
+ rt.start();
+
+ OutputStream outout = sout.getOutputStream();
+ InputStream is = sin.getInputStream();
+ byte[] buf = new byte[4096];
+ int i = 0;
+ int count = 0;
+ while ((i = is.read()) != -1) {
+ buf[count++] = (byte)i;
+ outout.write(i);
+ }
+ SocketTracer.dump("Req: ", buf, count);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
+
+class Reply implements Runnable {
+
+ InputStream is;
+ OutputStream outout;
+
+ Reply(InputStream is, OutputStream outout) {
+ this.is = is;
+ this.outout = outout;
+ }
+
+ public void run() {
+ try {
+ byte[] buf = new byte[4096];
+ int i = 0;
+ int count = 0;
+ while ((i = is.read()) != -1) {
+ buf[count++] = (byte)i;
+ outout.write(i);
+ }
+ SocketTracer.dump("Res: ", buf, count);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/resources/account/account.composite b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/resources/account/account.composite
new file mode 100644
index 0000000000..f308daa32d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb-runtime/src/test/resources/account/account.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ name="account">
+
+ <!-- composite refrence with ejb binding. Modify host and port number in uri attribute based on where you have installed target ResumeBank EJB -->
+
+ <component name="CustomerComponent">
+ <implementation.java class="account.CustomerImpl" />
+ <reference name="extEJBService">
+ <!-- To use the CosNaming, use the following URI -->
+ <!--
+ <binding.ejb uri="corbaname:iiop:1.2@localhost:1050#AddServiceBean" />
+ -->
+ <binding.ejb uri="hello-addservice/AddServiceBean/calculator.AddService" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/LICENSE b/sandbox/sebastien/java/embed/modules/binding-ejb/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/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/sebastien/java/embed/modules/binding-ejb/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-ejb/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..e6179d19e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.ejb;uses:="org.apache.t
+ uscany.sca.assembly,javax.xml.namespace";version="2.0.0"
+Private-Package: org.apache.tuscany.sca.binding.ejb.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA EJB Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA EJB Binding Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.ejb;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.ejb
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/NOTICE b/sandbox/sebastien/java/embed/modules/binding-ejb/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/pom.xml b/sandbox/sebastien/java/embed/modules/binding-ejb/pom.xml
new file mode 100644
index 0000000000..79ce7affb8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/pom.xml
@@ -0,0 +1,60 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-ejb</artifactId>
+ <name>Apache Tuscany SCA EJB Binding Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java
new file mode 100644
index 0000000000..cfaaeb284c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.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.sca.binding.ejb;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * An implementation of EJBBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EJBBinding extends Binding, Base {
+ // Constants used when describing the EJB binding
+ // model and for setting up defaults
+ String BINDING_EJB = "binding.ejb";
+ QName BINDING_EJB_QNAME = new QName(SCA11_NS, BINDING_EJB);
+
+ // Constants for the XML describing the EJB Binding
+ String HOME_INTERFACE = "homeInterface";
+ String EJB_LINK_NAME = "ejb-link-name";
+ String EJB_VERSION = "ejb-version";
+ String NAME = "name";
+ String POLICY_SETS = "policySets";
+ String REQUIRES = "requires";
+ String URI = "uri";
+
+ // Enums for the EJB Binding
+ enum EJBVersion {
+ EJB2, EJB3
+ };
+
+ /**
+ * Gets the homeInterface.
+ *
+ * @return home interface of the service binding
+ */
+ String getHomeInterface();
+
+ /**
+ * Set homeInterface
+ *
+ * @param homeInterface
+ */
+ void setHomeInterface(String homeInterface);
+
+ /**
+ * get ejb-link-name
+ *
+ * @return ejb-link-name
+ */
+ String getEjbLinkName();
+
+ /**
+ * Set ejb-link-name
+ *
+ * @param ejb-link-name
+ */
+ void setEjbLinkName(String ejbLinkName);
+
+ EJBVersion getEjbVersion();
+ void setEjbVersion(EJBVersion ejbVersion);
+
+ // FIXME: Should use Intent instead of String
+ String getRequires();
+ void setRequires(String requires);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java
new file mode 100644
index 0000000000..6e2c8d358f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.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 org.apache.tuscany.sca.binding.ejb;
+
+/**
+ * Exception for the EJB Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBBindingException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * {@inheritDoc}
+ */
+ public EJBBindingException() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EJBBindingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EJBBindingException(String message) {
+ super(message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EJBBindingException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java
new file mode 100644
index 0000000000..13b069a6bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.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 org.apache.tuscany.sca.binding.ejb;
+
+/**
+ * Factory for the EJB binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EJBBindingFactory {
+
+ /**
+ * Creates a new EJB binding.
+ * @return the new EJB binding
+ */
+ EJBBinding createEJBBinding();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java
new file mode 100644
index 0000000000..e84de86eca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.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 org.apache.tuscany.sca.binding.ejb.impl;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.binding.ejb.EJBBindingFactory;
+
+/**
+ * Factory class for building EJBBindings.
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+public class EJBBindingFactoryImpl implements EJBBindingFactory {
+
+ public EJBBinding createEJBBinding() {
+ return new EJBBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
new file mode 100644
index 0000000000..4ee8f411a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+
+/**
+ * An implementation of EJBBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBBindingImpl implements EJBBinding {
+
+ /**
+ * CORBA location For example,
+ * "corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/MyEJBHome"
+ */
+ private String uri;
+
+ /**
+ * homeInterface. remote or local
+ */
+ private String homeInterface;
+
+ /**
+ * The ejb-link-name attribute allows a SCA client to bind to an EJB that is
+ * packaged in the same JEE EAR file as the SCA client. This is functionally
+ * equivalent to using the <ejb-link/> subelement of the <ejb-ref/> element
+ * in s EJB deployment descriptor. Used only for Service binding
+ */
+ private String ejbLinkName;
+
+ /**
+ * The name of this binding
+ */
+ private String name;
+
+ /**
+ * Whether the binding is unresolved
+ */
+ private boolean unresolved;
+
+ /**
+ * Clone the binding
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ /**
+ * The type of session for this EJB Binding
+ */
+ //private SessionType sessionType;
+
+ /**
+ * The EJB version for this EJB Binding
+ */
+ private EJBVersion ejbVersion;
+
+ private String requires;
+
+ /**
+ * Constructor
+ */
+ public EJBBindingImpl() {
+ super();
+ unresolved = true;
+ }
+
+ /**
+ * Gets the homeInterface.
+ *
+ * @return home interface of the service binding
+ */
+ public String getHomeInterface() {
+ return homeInterface;
+ }
+
+ /**
+ * Set homeInterface
+ *
+ * @param homeInterface
+ */
+ public void setHomeInterface(String homeInterface) {
+ this.homeInterface = homeInterface;
+ }
+
+ /**
+ * get ejb-link-name
+ *
+ * @return ejb-link-name
+ */
+ public String getEjbLinkName() {
+ return ejbLinkName;
+ }
+
+ /**
+ * Set ejb-link-name
+ *
+ * @param ejb-link-name
+ */
+ public void setEjbLinkName(String ejbLinkName) {
+ this.ejbLinkName = ejbLinkName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public QName getType() {
+ return BINDING_EJB_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return this.unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public void setEjbVersion(EJBVersion ejb_version_enum) {
+ this.ejbVersion = ejb_version_enum;
+ }
+
+ public void setRequires(String requires) {
+ this.requires = requires;
+ }
+
+ public EJBVersion getEjbVersion() {
+ return ejbVersion;
+ }
+
+ public String getRequires() {
+ return requires;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
new file mode 100644
index 0000000000..71386db450
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ejb.impl;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.binding.ejb.EJBBindingFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * A processor to read the XML that describes the EJB binding...
+ *
+ * <binding.ejb homeInterface="NCName"?
+ * ejb-link-name="string"?
+ * ejb-version="EJB2 or EJB3"?
+ * name="NCName"?
+ * policySets="sca:listOfQNames"?
+ * requires="sca:listOfQNames"?
+ * uri="anyURI"?>
+ * <wireFormat ... />?
+ * <operationSelector ... />?
+ *
+ * <!-- additional elements here --> *
+ * </binding.ejb>
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBBindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<EJBBinding> {
+ private PolicyFactory policyFactory;
+ private PolicySubjectProcessor policyProcessor;
+
+ private EJBBindingFactory ejbBindingFactory;
+
+ public EJBBindingProcessor(FactoryExtensionPoint modelFactories) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.ejbBindingFactory = modelFactories.getFactory(EJBBindingFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "binding-ejb-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public QName getArtifactType() {
+ return EJBBinding.BINDING_EJB_QNAME;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EJBBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ EJBBinding ejbBinding = ejbBindingFactory.createEJBBinding();
+
+ // Read the policies
+ policyProcessor.readPolicies(ejbBinding, reader);
+
+ // Read the name
+ String name = reader.getAttributeValue(null, EJBBinding.NAME);
+ if (name != null) {
+ ejbBinding.setName(name);
+ }
+
+ // Read binding URI
+ String uri = getURIString(reader, EJBBinding.URI);
+ if (uri != null) {
+ ejbBinding.setURI(uri);
+ }
+
+ String homeInterface = reader.getAttributeValue(null, EJBBinding.HOME_INTERFACE);
+ if (homeInterface != null) {
+ ejbBinding.setHomeInterface(homeInterface);
+ }
+
+ String ejbLinkName = reader.getAttributeValue(null, EJBBinding.EJB_LINK_NAME);
+ if (ejbLinkName != null) {
+ ejbBinding.setEjbLinkName(ejbLinkName);
+ }
+
+ String ejbVersion = reader.getAttributeValue(null, EJBBinding.EJB_VERSION);
+ if (ejbVersion != null) {
+ if (ejbVersion.equals("EJB2")) {
+ ejbBinding.setEjbVersion(EJBBinding.EJBVersion.EJB2);
+ } else if (ejbVersion.equals("EJB3")) {
+ ejbBinding.setEjbVersion(EJBBinding.EJBVersion.EJB3);
+ } else {
+ error(context.getMonitor(), "UnknownEJBVersion", reader, ejbVersion, name);
+ }
+ }
+
+ // TODO: Read requires
+ String requires = reader.getAttributeValue(null, EJBBinding.REQUIRES);
+ if (requires != null) {
+ ejbBinding.setRequires(requires);
+ }
+
+ return ejbBinding;
+ }
+
+ public void write(EJBBinding ejbBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ // Write a <binding.ejb>
+ writer.writeStartElement(Constants.SCA11_NS, EJBBinding.BINDING_EJB);
+
+ if (ejbBinding.getName() != null){
+ writer.writeAttribute(EJBBinding.NAME, ejbBinding.getName());
+ }
+
+ if (ejbBinding.getURI() != null){
+ writer.writeAttribute(EJBBinding.URI, ejbBinding.getURI());
+ }
+
+ // FIXME Implement the rest
+ writer.writeEndElement();
+ }
+
+ public Class<EJBBinding> getModelType() {
+ return EJBBinding.class;
+ }
+
+ public void resolve(EJBBinding ejbBinding, ModelResolver modelResolver, ProcessorContext context) throws ContributionResolveException {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory
new file mode 100644
index 0000000000..2be8babe4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.ejb.impl.EJBBindingFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..82edd9a61b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.binding.ejb.impl.EJBBindingProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#binding.ejb,model=org.apache.tuscany.sca.binding.ejb.EJBBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..0f970c8289
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/binding/ejb/policy/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties
new file mode 100644
index 0000000000..28477dd3ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+UnknownEJBSessionType = Unknown EJB Session Type of {0} for {1}
+UnknownEJBVersion = Unknown EJB Version of {0} for {1}
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml
new file mode 100644
index 0000000000..965e127d04
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:bindingType type="sca:binding.ejb" mayProvide="" alwaysProvides=""/>
+
+</sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ab90529320
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Binding Hazelcast Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Hazelcast Binding
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.hazelcast.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.wsdlgen;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0",
+ org.apache.tuscany.sca.endpoint.hazelcast;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca,
+ org.oasisopen.sca.annotation,
+ org.w3c.dom,
+ org.xml.sax
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/pom.xml
new file mode 100644
index 0000000000..189ab5d9e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/pom.xml
@@ -0,0 +1,58 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
+ <name>Apache Tuscany SCA Binding Hazelcast Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.java
new file mode 100644
index 0000000000..42f6193940
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/EndpointStash.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.sca.binding.hazelcast;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+
+public class EndpointStash {
+
+ // TODO a better way of sharing these endpoints than a static
+ // the issue is that the ServiceInvoker needs to get hold of the Endpoint
+ // for a URI. The ServiceInvoker runs in the context of a Hazelcast spawned
+ // thread so can only get to Tuscany via a static. The Hazelcast endpoint
+ // registry does actually have these endpoints so perhaps an alternative could be
+ // to use NodeFactory.getNodeFactories to get at the Hazelcast endpoint registry.
+ private static Map<String, RuntimeEndpoint> endpoints = new ConcurrentHashMap<String, RuntimeEndpoint>();
+
+ public static void addEndpoint(RuntimeEndpoint endpoint) {
+ endpoints.put(endpoint.getURI(), endpoint);
+ }
+
+ public static RuntimeEndpoint getEndpoint(String uri) {
+ for (RuntimeEndpoint ep : endpoints.values()) {
+ if (ep.matches(uri)) {
+ return ep;
+ }
+ }
+ return null;
+ }
+
+ public static void removeEndpoint(String uri) {
+ endpoints.remove(uri);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java
new file mode 100644
index 0000000000..1636ed16ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBinding.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.hazelcast;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.BindingImpl;
+
+public class HazelcastBinding extends BindingImpl {
+
+ public static final QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.hazelcast");
+
+ public HazelcastBinding() {
+ super(TYPE);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java
new file mode 100644
index 0000000000..f202e16a69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingProviderFactory.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.hazelcast;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+public class HazelcastBindingProviderFactory implements BindingProviderFactory<HazelcastBinding> {
+
+ private ExtensionPointRegistry extensionsRegistry;
+
+ public HazelcastBindingProviderFactory(ExtensionPointRegistry extensionsRegistry) {
+ this.extensionsRegistry = extensionsRegistry;
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ InterfaceContract interfaceContract = createDOMInterfaceContract(endpointReference.getComponent(), endpointReference.getReference());
+ return new HazelcastReferenceBindingProvider(extensionsRegistry, endpointReference.getBinding().getURI(), interfaceContract);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ InterfaceContract interfaceContract = createDOMInterfaceContract(endpoint.getComponent(), endpoint.getService());
+ return new HazelcastServiceBindingProvider(endpoint, interfaceContract);
+ }
+
+ private InterfaceContract createDOMInterfaceContract(Component component, Contract contract) {
+ WebServiceBindingFactory wsFactory = extensionsRegistry.getExtensionPoint(WebServiceBindingFactory.class);
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ BindingWSDLGenerator.generateWSDL(component, contract, wsBinding, extensionsRegistry, null);
+ InterfaceContract interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
+ return interfaceContract;
+ }
+
+ public Class<HazelcastBinding> getModelType() {
+ return HazelcastBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java
new file mode 100644
index 0000000000..29546f405e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastReferenceBindingProvider.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.hazelcast;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+
+public class HazelcastReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private ExtensionPointRegistry extensionsRegistry;
+ private String serviceURI;
+ private InterfaceContract interfaceContract;
+
+ public HazelcastReferenceBindingProvider(ExtensionPointRegistry extensionsRegistry, String serviceURI, InterfaceContract interfaceContract) {
+ this.extensionsRegistry = extensionsRegistry;
+ this.serviceURI = serviceURI;
+ this.interfaceContract = interfaceContract;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new ReferenceInvoker(extensionsRegistry, serviceURI, operation);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.java
new file mode 100644
index 0000000000..6ac3542a8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastServiceBindingProvider.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.binding.hazelcast;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class HazelcastServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+ private InterfaceContract interfaceContract;
+
+
+ public HazelcastServiceBindingProvider(RuntimeEndpoint endpoint, InterfaceContract interfaceContract) {
+ this.endpoint = endpoint;
+ this.interfaceContract = interfaceContract;
+ }
+
+ public void start() {
+ EndpointStash.addEndpoint(endpoint);
+ }
+
+ public void stop() {
+ EndpointStash.removeEndpoint(endpoint.getURI());
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java
new file mode 100644
index 0000000000..7caf3e4841
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ReferenceInvoker.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.hazelcast;
+
+import java.io.IOException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.FutureTask;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.endpoint.hazelcast.HazelcastEndpointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+import com.hazelcast.core.DistributedTask;
+import com.hazelcast.core.Member;
+
+public class ReferenceInvoker implements Invoker {
+
+ HazelcastEndpointRegistry hzRegistry;
+ DOMHelper domHelper;
+ String serviceURI;
+ private Operation operation;
+ MessageFactory messageFactory;
+
+ public ReferenceInvoker(ExtensionPointRegistry extensionsRegistry, String serviceURI, Operation operation) {
+ this.serviceURI = serviceURI;
+ this.operation = operation;
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
+ for (EndpointRegistry r : domainRegistryFactory.getEndpointRegistries()) {
+ if (r instanceof HazelcastEndpointRegistry) {
+ hzRegistry = (HazelcastEndpointRegistry)r;
+ break;
+ }
+ }
+ this.domHelper = DOMHelper.getInstance(extensionsRegistry);
+ FactoryExtensionPoint modelFactories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ }
+
+ public Message invoke(Message msg) {
+ Member owningMember = hzRegistry.getOwningMember(serviceURI);
+ if (owningMember == null) {
+ throw new ServiceRuntimeException("service not found: " + serviceURI);
+ }
+ String requestXML = getRequestXML(msg);
+ Callable<String> callable = new ServiceInvoker(serviceURI, operation.getName(), requestXML);
+ FutureTask<String> task = new DistributedTask<String>(callable, owningMember);
+ ExecutorService executorService = getExecutorService();
+ executorService.execute(task);
+ try {
+ return getResponseNode(task.get());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Hazelcast ExecutorService can't nest invocations so use a separate ExecutorService
+ * for nested calls. See http://groups.google.com/group/hazelcast/browse_thread/thread/1cc0b943716476e9
+ */
+ private ExecutorService getExecutorService() {
+ String threadName = Thread.currentThread().getName();
+ if (!threadName.startsWith("hz.executor.") || threadName.indexOf("binding.sca.") == -1) {
+ return hzRegistry.getHazelcastInstance().getExecutorService("binding.sca.1");
+ } else {
+ String oldName = threadName.substring(threadName.lastIndexOf("binding.sca."), threadName.lastIndexOf(".thread-"));
+ int x = Integer.parseInt(oldName.substring(oldName.lastIndexOf('.') + 1));
+ return hzRegistry.getHazelcastInstance().getExecutorService(oldName.substring(0, 12) + (x + 1));
+ }
+ }
+
+ private String getRequestXML(Message msg) {
+ Object[] args = msg.getBody();
+ String msgXML = domHelper.saveAsString((Node)args[0]);
+ return msgXML;
+ }
+
+ private Message getResponseNode(String responseXML) throws IOException, SAXException {
+ Message msg = messageFactory.createMessage();
+ if (responseXML.startsWith("DECLAREDEXCEPTION:")) {
+ Document responseDOM = domHelper.load(responseXML.substring(18));
+ FaultException e = new FaultException("remote exception", responseDOM);
+ Node node = ((Node)responseDOM).getFirstChild();
+ e.setFaultName(new QName(node.getNamespaceURI(), node.getLocalName()));
+ msg.setFaultBody(e);
+ } else if (responseXML.startsWith("EXCEPTION:")) {
+ throw new ServiceRuntimeException("Remote exception:" + responseXML.substring(10));
+ } else {
+ Document responseDOM = domHelper.load(responseXML);
+ msg.setBody(responseDOM);
+ }
+ return msg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java
new file mode 100644
index 0000000000..42cac191aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/java/org/apache/tuscany/sca/binding/hazelcast/ServiceInvoker.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.hazelcast;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.Callable;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+public class ServiceInvoker implements Callable<String>, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // all fields MUST be Serializable
+ private String serviceURI;
+ private String operationName;
+ private String requestXML;
+
+ public ServiceInvoker(String serviceURI, String operationName, String msgXML) {
+ this.serviceURI = serviceURI;
+ this.operationName = operationName;
+ this.requestXML = msgXML;
+ }
+
+ public String call() throws Exception {
+ RuntimeEndpoint endpoint = EndpointStash.getEndpoint(serviceURI);
+ if (endpoint == null) {
+ throw new NoSuchServiceException(serviceURI);
+ }
+ Operation operation = getRequestOperation(endpoint);
+ DOMHelper domHelper = DOMHelper.getInstance(endpoint.getCompositeContext().getExtensionPointRegistry());
+ Object[] args = getRequestArgs(domHelper);
+ String responseXML;
+ try {
+ Object response = endpoint.invoke(operation, args);
+ responseXML = getResponseXML(domHelper, response);
+ } catch (Exception e) {
+ if (e instanceof InvocationTargetException && ((InvocationTargetException)e).getTargetException() instanceof FaultException) {
+ responseXML = "DECLAREDEXCEPTION:" + getResponseXML(domHelper, ((FaultException)((InvocationTargetException)e).getTargetException()).getFaultInfo());
+ } else {
+ responseXML = "EXCEPTION: " + e.getClass() + ":" + e.getMessage();
+ }
+ }
+ return responseXML;
+ }
+
+ private Operation getRequestOperation(RuntimeEndpoint endpoint) {
+ InterfaceContract ic = endpoint.getBindingInterfaceContract();
+ Interface iface = ic.getInterface();
+ for (Operation op : iface.getOperations()) {
+ if (op.getName().equals(operationName)) {
+ return op;
+ }
+
+ }
+ // TODO: return err msg
+ throw new ServiceRuntimeException("operation not found " + operationName);
+ }
+
+ private Object[] getRequestArgs(DOMHelper domHelper) throws IOException, SAXException {
+ Document requestDOM = domHelper.load(requestXML);
+ return new Object[] {requestDOM};
+ }
+
+ private String getResponseXML(DOMHelper domHelper, Object response) {
+ String responseXML = domHelper.saveAsString((Node)response);
+ return responseXML;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..2fc977b41f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.hazelcast,model=org.apache.tuscany.sca.binding.hazelcast.HazelcastBinding
+
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..3878c5f0da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.hazelcast.HazelcastBindingProviderFactory;model=org.apache.tuscany.sca.binding.hazelcast.HazelcastBinding
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java
new file mode 100644
index 0000000000..937046f0b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/BadStringException.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.hazelcast;
+
+public class BadStringException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public BadStringException(String msg) {
+ super(msg);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java
new file mode 100644
index 0000000000..68353c89cf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/ComplexType.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.hazelcast;
+
+public class ComplexType {
+
+ private String s;
+
+ public void setString(String s) {
+ this.s = s;
+ }
+
+ public String getString() {
+ return s;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java
new file mode 100644
index 0000000000..18831eafac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/HazelcastBindingTestCase.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.hazelcast;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class HazelcastBindingTestCase {
+
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // Note use of NodeFactory.newInstance() so as to start separate runtimes
+ serviceNode = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("service.composite", new String[]{"target/test-classes"});
+ serviceNode.start();
+ clientNode = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("client.composite", new String[]{"target/test-classes"});
+ clientNode.start();
+ }
+
+ @Test
+ public void testNestedClient() throws Exception {
+ Node client2Node = NodeFactory.newInstance("uri:HazelcastBindingTestCase?bind=127.0.0.1").createNode("client2.composite", new String[]{"target/test-classes"});
+ client2Node.start();
+ TestService service = client2Node.getService(TestService.class, "TestServiceClient2");
+ assertNotNull(service);
+ assertEquals("Petra", service.echoString("Petra"));
+ client2Node.stop();
+ }
+
+ @Test
+ public void testEchoString() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ assertEquals("Petra", service.echoString("Petra"));
+ }
+
+ @Test
+ public void testOnewayString() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ service.onewayString("Petra");
+ }
+
+ @Test
+ public void testEchoComplexType() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ ComplexType ct = new ComplexType();
+ ct.setString("beate");
+ assertEquals("beate", service.echoComplexType(ct).getString());
+ }
+
+ @Test
+ public void testDeclaredException() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ try {
+ service.testExceptions("Sue");
+ fail();
+ } catch (BadStringException e) {
+ assertEquals("Sue", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testRuntimeException() throws Exception {
+ TestService service = clientNode.getService(TestService.class, "TestServiceClient");
+ assertNotNull(service);
+ try {
+ service.testExceptions("runtime");
+ fail();
+ } catch (ServiceRuntimeException e) {
+ assertEquals("org.oasisopen.sca.ServiceRuntimeException: Remote exception: class java.lang.RuntimeException:runtime", e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.java
new file mode 100644
index 0000000000..3ffcb0d384
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestService.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.hazelcast;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface TestService {
+ String echoString(String s);
+ void onewayString(String s);
+ ComplexType echoComplexType(ComplexType ct);
+ String testExceptions(String s) throws BadStringException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java
new file mode 100644
index 0000000000..4b462068f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceClient.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.hazelcast;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class TestServiceClient implements TestService {
+
+ @Reference
+ public TestService service;
+
+ public String echoString(String s) {
+ return service.echoString(s);
+ }
+
+ public void onewayString(String s) {
+ service.onewayString(s);
+ }
+
+ public ComplexType echoComplexType(ComplexType ct) {
+ return service.echoComplexType(ct);
+ }
+
+ public String testExceptions(String s) throws BadStringException {
+ return service.testExceptions(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java
new file mode 100644
index 0000000000..1f5a3872c6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/java/org/apache/tuscany/sca/binding/hazelcast/TestServiceImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.hazelcast;
+
+public class TestServiceImpl implements TestService {
+
+ public String echoString(String s) {
+ return s;
+ }
+
+ public void onewayString(String s) {
+ System.out.println("onewayString " + s);
+ }
+
+ public ComplexType echoComplexType(ComplexType ct) {
+ return ct;
+ }
+
+ public String testExceptions(String s) throws BadStringException {
+ if (s.equals("runtime")) {
+ throw new RuntimeException("runtime");
+ }
+ throw new BadStringException(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/client.composite b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/client.composite
new file mode 100644
index 0000000000..7436a5e24b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/client.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="TestServiceClient">
+
+ <component name="TestServiceClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.hazelcast.TestServiceClient"/>
+ <reference name="service" target="TestService"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/client2.composite b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/client2.composite
new file mode 100644
index 0000000000..20667984ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/client2.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="TestServiceClient2">
+
+ <component name="TestServiceClient2">
+ <implementation.java class="org.apache.tuscany.sca.binding.hazelcast.TestServiceClient"/>
+ <reference name="service" target="TestServiceClient"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/service.composite b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/service.composite
new file mode 100644
index 0000000000..83f13a35f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-hazelcast-runtime/src/test/resources/service.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://itest"
+ name="TestService">
+
+ <component name="TestService">
+ <implementation.java class="org.apache.tuscany.sca.binding.hazelcast.TestServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-http-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/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/sebastien/java/embed/modules/binding-http-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-http-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..175d11f601
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.http.provider;version="2.0.
+ 0",.;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA HTTP Binding Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA HTTP Binding Runtime
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.http;version="2.0.0",
+ org.apache.tuscany.sca.common.http;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.http.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-http-runtime/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-http-runtime/pom.xml
new file mode 100644
index 0000000000..b1f93ab0e3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-http-runtime</artifactId>
+ <name>Apache Tuscany SCA HTTP Binding Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java
new file mode 100644
index 0000000000..e2a3a5cf39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java
@@ -0,0 +1,462 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLDecoder;
+import java.text.ParseException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.common.http.HTTPCacheContext;
+import org.apache.tuscany.sca.common.http.HTTPContentTypeMapper;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+/**
+ * Servlet responsible for dispatching HTTP requests to the
+ * target component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPBindingListenerServlet extends HttpServlet {
+ private static final long serialVersionUID = 2865466417329430610L;
+
+ transient private Binding binding;
+
+ private MessageFactory messageFactory;
+ private Invoker getInvoker;
+ private Invoker conditionalGetInvoker;
+ private Invoker putInvoker;
+ private Invoker conditionalPutInvoker;
+ private Invoker postInvoker;
+ private Invoker conditionalPostInvoker;
+ private Invoker deleteInvoker;
+ private Invoker conditionalDeleteInvoker;
+
+ /**
+ * Constructs a new HTTPServiceListenerServlet.
+ */
+ public HTTPBindingListenerServlet(Binding binding, MessageFactory messageFactory) {
+ this.binding = binding;
+ this.messageFactory = messageFactory;
+ }
+
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ super.service(request, response);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Get the request path
+ String pathInfo = request.getPathInfo();
+ if (pathInfo == null || pathInfo.length() == 0) {
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+ String path = URLDecoder.decode(pathInfo, "UTF-8");
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+
+ String id = path.substring(1);
+
+ Message responseMessage = null;
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
+ } catch (ParseException e) {
+ }
+
+ // Route message based on availability of cache info and cache methods
+ if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalGetInvoker != null )) {
+ requestMessage.setBody(new Object[] {id, cacheContext});
+ responseMessage = conditionalGetInvoker.invoke(requestMessage);
+ } else {
+ requestMessage.setBody(new Object[] {id});
+ responseMessage = getInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+
+ int index = -1;
+ if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+ return;
+ } else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
+ return;
+ }
+
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+ if(response.getContentType() == null || response.getContentType().length() == 0){
+ // Calculate content-type based on extension
+ String contentType = HTTPContentTypeMapper.getContentType(id);
+ if(contentType != null && contentType.length() >0) {
+ response.setContentType(contentType);
+ }
+ }
+
+ // Write the response from the service implementation to the response
+ // output stream
+ InputStream is = (InputStream)responseMessage.getBody();
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ os.flush();
+ os.close();
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.length() ==0) {
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ String id = path.substring(1);
+
+ Message responseMessage = null;
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
+ } catch (ParseException e) {
+ }
+
+ // Route message based on availability of cache info and cache methods
+ if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalDeleteInvoker != null )) {
+ requestMessage.setBody(new Object[] {id, cacheContext});
+ responseMessage = conditionalDeleteInvoker.invoke(requestMessage);
+ } else {
+ requestMessage.setBody(new Object[] {id});
+ responseMessage = deleteInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+
+ int index = -1;
+ if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+ return;
+ } else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
+ return;
+ }
+
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+ // Write the response from the service implementation to the response
+ // output stream
+ InputStream is = (InputStream)responseMessage.getBody();
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ os.flush();
+ os.close();
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.length() ==0) {
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ String id = path.substring(1);
+
+ Message responseMessage = null;
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
+ } catch (ParseException e) {
+ }
+
+ // Route message based on availability of cache info and cache methods
+ if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalPutInvoker != null )) {
+ requestMessage.setBody(new Object[] {id, cacheContext});
+ responseMessage = conditionalPutInvoker.invoke(requestMessage);
+ } else {
+ requestMessage.setBody(new Object[] {id});
+ responseMessage = putInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+
+ int index = -1;
+ if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+ return;
+ } else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
+ return;
+ }
+
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+ // Write the response from the service implementation to the response
+ // output stream
+ InputStream is = (InputStream)responseMessage.getBody();
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ os.flush();
+ os.close();
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.length() ==0) {
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ // String id = path.substring(1);
+
+ Message responseMessage = null;
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
+ } catch (ParseException e) {
+ }
+
+ // Route message based on availability of cache info and cache methods
+ if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalPostInvoker != null )) {
+ requestMessage.setBody(new Object[] {cacheContext});
+ responseMessage = conditionalPostInvoker.invoke(requestMessage);
+ } else {
+ requestMessage.setBody(new Object[] {});
+ responseMessage = postInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+
+ int index = -1;
+ if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+ return;
+ } else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
+ return;
+ }
+
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+
+ // Test if the ETag and LastModified are returned as a cache context.
+ Object body = responseMessage.getBody();
+ if ( body.getClass() == HTTPCacheContext.class ) {
+ // Transfer to header if so.
+ HTTPCacheContext cc = (HTTPCacheContext)responseMessage.getBody();
+ if (( cc != null ) && ( cc.isEnabled() )) {
+ String eTag = cc.getETag();
+ if ( eTag != null )
+ response.setHeader( "ETag", cc.getETag() );
+ String lastModified = cc.getLastModified();
+ if ( lastModified != null)
+ response.setHeader( "LastModified", cc.getLastModified() );
+ }
+ }
+ }
+
+ /**
+ * @return the getInvoker
+ */
+ public Invoker getGetInvoker() {
+ return getInvoker;
+ }
+
+ /**
+ * @param getInvoker the getInvoker to set
+ */
+ public void setGetInvoker(Invoker getInvoker) {
+ this.getInvoker = getInvoker;
+ }
+
+ /**
+ * @return the conditionalGetInvoker
+ */
+ public Invoker getConditionalGetInvoker() {
+ return conditionalGetInvoker;
+ }
+
+ /**
+ * @param conditionalGetInvoker the conditionalGetInvoker to set
+ */
+ public void setConditionalGetInvoker(Invoker conditionalGetInvoker) {
+ this.conditionalGetInvoker = conditionalGetInvoker;
+ }
+
+ /**
+ * @return the putInvoker
+ */
+ public Invoker getPutInvoker() {
+ return putInvoker;
+ }
+
+ /**
+ * @param putInvoker the putInvoker to set
+ */
+ public void setPutInvoker(Invoker putInvoker) {
+ this.putInvoker = putInvoker;
+ }
+
+ /**
+ * @return the conditionalPutInvoker
+ */
+ public Invoker getConditionalPutInvoker() {
+ return conditionalPutInvoker;
+ }
+
+ /**
+ * @param conditionalPutInvoker the conditionalPutInvoker to set
+ */
+ public void setConditionalPutInvoker(Invoker conditionalPutInvoker) {
+ this.conditionalPutInvoker = conditionalPutInvoker;
+ }
+
+ /**
+ * @return the postInvoker
+ */
+ public Invoker getPostInvoker() {
+ return postInvoker;
+ }
+
+ /**
+ * @param postInvoker the postInvoker to set
+ */
+ public void setPostInvoker(Invoker postInvoker) {
+ this.postInvoker = postInvoker;
+ }
+
+ /**
+ * @return the conditionalPostInvoker
+ */
+ public Invoker getConditionalPostInvoker() {
+ return conditionalPostInvoker;
+ }
+
+ /**
+ * @param conditionalPostInvoker the conditionalPostInvoker to set
+ */
+ public void setConditionalPostInvoker(Invoker conditionalPostInvoker) {
+ this.conditionalPostInvoker = conditionalPostInvoker;
+ }
+
+ /**
+ * @return the deleteInvoker
+ */
+ public Invoker getDeleteInvoker() {
+ return deleteInvoker;
+ }
+
+ /**
+ * @param deleteInvoker the deleteInvoker to set
+ */
+ public void setDeleteInvoker(Invoker deleteInvoker) {
+ this.deleteInvoker = deleteInvoker;
+ }
+
+ /**
+ * @return the conditionalDeleteInvoker
+ */
+ public Invoker getConditionalDeleteInvoker() {
+ return conditionalDeleteInvoker;
+ }
+
+ /**
+ * @param conditionalDeleteInvoker the conditionalDeleteInvoker to set
+ */
+ public void setConditionalDeleteInvoker(Invoker conditionalDeleteInvoker) {
+ this.conditionalDeleteInvoker = conditionalDeleteInvoker;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java
new file mode 100644
index 0000000000..118a2c3bc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.provider;
+
+import org.apache.tuscany.sca.binding.http.HTTPBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+
+/**
+ * Factory for HTTP binding providers.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPBindingProviderFactory implements BindingProviderFactory<HTTPBinding> {
+ private ExtensionPointRegistry extensionPoints;
+ private MessageFactory messageFactory;
+ private ServletHost servletHost;
+
+ public HTTPBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ messageFactory = modelFactories.getFactory(MessageFactory.class);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ // Binding HTTP is currently NOT supporting References
+ return null;
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new HTTPServiceBindingProvider(endpoint, extensionPoints, messageFactory, servletHost);
+ }
+
+ public Class<HTTPBinding> getModelType() {
+ return HTTPBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPGetListenerServlet.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPGetListenerServlet.java
new file mode 100644
index 0000000000..e20d420d49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPGetListenerServlet.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.http.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLDecoder;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+/**
+ * Servlet responsible for dispatching HTTP GET requests to the
+ * target component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPGetListenerServlet extends HttpServlet {
+ private static final long serialVersionUID = 2865466417329430610L;
+
+ private MessageFactory messageFactory;
+ private Invoker getInvoker;
+
+ /**
+ * Constructs a new HTTPServiceListenerServlet.
+ */
+ public HTTPGetListenerServlet(Invoker getInvoker, MessageFactory messageFactory) {
+ this.getInvoker = getInvoker;
+ this.messageFactory = messageFactory;
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.length() ==0) {
+
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ String id = path.substring(1);
+ requestMessage.setBody(new Object[] {id});
+ Message responseMessage = getInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+ // Write the response from the service implementation to the response
+ // output stream
+ InputStream is = (InputStream)responseMessage.getBody();
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ os.flush();
+ os.close();
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
new file mode 100644
index 0000000000..41981d2db5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.provider;
+
+import javax.servlet.Servlet;
+
+import org.apache.tuscany.sca.binding.http.HTTPBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.EndpointProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Implementation of an HTTP binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPServiceBindingProvider implements EndpointProvider {
+ private ExtensionPointRegistry extensionPoints;
+
+ private RuntimeEndpoint endpoint;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private InterfaceContract serviceContract;
+ private HTTPBinding binding;
+ private MessageFactory messageFactory;
+
+ private OperationSelectorProvider osProvider;
+ private WireFormatProvider wfProvider;
+
+ private ServletHost servletHost;
+ private String servletMapping;
+ private HTTPBindingListenerServlet bindingListenerServlet;
+
+ public HTTPServiceBindingProvider(RuntimeEndpoint endpoint,
+ ExtensionPointRegistry extensionPoints,
+ MessageFactory messageFactory,
+ ServletHost servletHost) {
+
+ this.endpoint = endpoint;
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (HTTPBinding)endpoint.getBinding();
+
+ this.extensionPoints = extensionPoints;
+ this.messageFactory = messageFactory;
+ this.servletHost = servletHost;
+
+ // retrieve operation selector and wire format service providers
+
+ ProviderFactoryExtensionPoint providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+
+ if (binding.getOperationSelector() != null) {
+ // Configure the interceptors for operation selection
+ OperationSelectorProviderFactory osProviderFactory = (OperationSelectorProviderFactory) providerFactories.getProviderFactory(binding.getOperationSelector().getClass());
+ if (osProviderFactory != null) {
+ this.osProvider = osProviderFactory.createServiceOperationSelectorProvider(endpoint);
+ }
+ }
+
+ if (binding.getRequestWireFormat() != null && binding.getResponseWireFormat() != null) {
+ // Configure the interceptors for wire format
+ WireFormatProviderFactory wfProviderFactory = (WireFormatProviderFactory) providerFactories.getProviderFactory(binding.getRequestWireFormat().getClass());
+ if (wfProviderFactory != null) {
+ this.wfProvider = wfProviderFactory.createServiceWireFormatProvider(endpoint);
+ }
+ }
+
+
+
+ //clone the service contract to avoid databinding issues
+ try {
+ this.serviceContract = (InterfaceContract) service.getInterfaceContract().clone();
+
+ // configure data binding
+ if (this.wfProvider != null) {
+ wfProvider.configureWireFormatInterfaceContract(service.getInterfaceContract());
+ }
+ } catch(CloneNotSupportedException e) {
+ this.serviceContract = service.getInterfaceContract();
+ }
+
+ }
+
+ public void start() {
+ // Get the invokers for the supported operations
+ Servlet servlet = null;
+ bindingListenerServlet = new HTTPBindingListenerServlet(binding, messageFactory );
+ for (InvocationChain invocationChain : endpoint.getInvocationChains()) {
+ Operation operation = invocationChain.getTargetOperation();
+ String operationName = operation.getName();
+ if (operationName.equals("get")) {
+ Invoker getInvoker = invocationChain.getHeadInvoker();
+ bindingListenerServlet.setGetInvoker(getInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("conditionalGet")) {
+ Invoker conditionalGetInvoker = invocationChain.getHeadInvoker();
+ bindingListenerServlet.setConditionalGetInvoker(conditionalGetInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("delete")) {
+ Invoker deleteInvoker = invocationChain.getHeadInvoker();
+ bindingListenerServlet.setDeleteInvoker(deleteInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("conditionalDelete")) {
+ Invoker conditionalDeleteInvoker = invocationChain.getHeadInvoker();
+ bindingListenerServlet.setConditionalDeleteInvoker(conditionalDeleteInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("put")) {
+ Invoker putInvoker = invocationChain.getHeadInvoker();
+ bindingListenerServlet.setPutInvoker(putInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("conditionalPut")) {
+ Invoker conditionalPutInvoker = invocationChain.getHeadInvoker();
+ bindingListenerServlet.setConditionalPutInvoker(conditionalPutInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("post")) {
+ Invoker postInvoker = invocationChain.getHeadInvoker();
+ bindingListenerServlet.setPostInvoker(postInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("conditionalPost")) {
+ Invoker conditionalPostInvoker = invocationChain.getHeadInvoker();
+ bindingListenerServlet.setConditionalPostInvoker(conditionalPostInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("service")) {
+ Invoker serviceInvoker = invocationChain.getHeadInvoker();
+ servlet = new HTTPServiceListenerServlet(binding, serviceInvoker, messageFactory);
+ break;
+ }
+ }
+ if (servlet == null) {
+ throw new IllegalStateException("No get or service method found on the service");
+ }
+
+ // Create our HTTP service listener Servlet and register it with the
+ // Servlet host
+ servletMapping = binding.getURI();
+ if (!servletMapping.endsWith("/")) {
+ servletMapping += "/";
+ }
+ if (!servletMapping.endsWith("*")) {
+ servletMapping += "*";
+ }
+
+ servletHost.addServletMapping(servletMapping, servlet);
+ }
+
+ public void stop() {
+ // Unregister the Servlet from the Servlet host
+ servletHost.removeServletMapping(servletMapping);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return service.getInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ /**
+ * Add specific http interceptor to invocation chain
+ */
+ public void configure() {
+
+ InvocationChain bindingChain = endpoint.getBindingInvocationChain();
+
+ if(osProvider != null) {
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, osProvider.createInterceptor());
+ }
+
+ if (wfProvider != null) {
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, wfProvider.createInterceptor());
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceListenerServlet.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceListenerServlet.java
new file mode 100644
index 0000000000..f752dce3e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceListenerServlet.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.sca.binding.http.provider;
+
+import java.io.IOException;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+/**
+ * Servlet responsible for dispatching HTTP service requests to the
+ * target component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPServiceListenerServlet implements Servlet {
+ transient private Binding binding;
+ transient private ServletConfig config;
+ transient private MessageFactory messageFactory;
+ transient private Invoker serviceInvoker;
+
+ /**
+ * Constructs a new HTTPServiceListenerServlet.
+ */
+ public HTTPServiceListenerServlet(Binding binding, Invoker serviceInvoker, MessageFactory messageFactory) {
+ this.binding = binding;
+ this.serviceInvoker = serviceInvoker;
+ this.messageFactory = messageFactory;
+ }
+
+ public ServletConfig getServletConfig() {
+ return config;
+ }
+
+ public String getServletInfo() {
+ return "";
+ }
+
+ public void init(ServletConfig config) throws ServletException {
+ this.config = config;
+ }
+
+ public void destroy() {
+
+ }
+
+ public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ // Dispatch the service interaction to the service invoker
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[]{request, response});
+ Message responseMessage = serviceInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ // Turn a fault into an exception
+ //throw new ServletException((Throwable)responseMessage.getBody());
+ Throwable e = (Throwable)responseMessage.getBody();
+ ((HttpServletResponse)response).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..15b0e51b74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.http.provider.HTTPBindingProviderFactory;model=org.apache.tuscany.sca.binding.http.HTTPBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java
new file mode 100644
index 0000000000..eed7975bc6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java
@@ -0,0 +1,903 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * HTTP binding unit tests.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPBindingCacheTestCase {
+ // RFC 822 date time
+ protected static final SimpleDateFormat dateFormat = new SimpleDateFormat(
+ "EEE, dd MMM yyyy HH:mm:ss Z");
+
+ // Request with no predicates in header.
+ private static final String REQUEST1 = "{0} /httpbinding/{1} HTTP/1.0\n"
+ + "Host: localhost\n" + "Content-Type: text/xml\n"
+ + "Connection: close\n" + "Content-Length: {2}" + "\n\n{3}";
+
+ // Request with predicates in header
+ private static final String REQUEST2 = "{0} /httpbinding/{1} HTTP/1.0\n"
+ + "Host: localhost\n" + "Content-Type: text/xml\n" + "{2}: {3}\n" // predicate (If-Match, If-None-Match, If-Modified-Since, If-NotModified-Since): value (date or ETag)
+ + "Connection: close\n" + "Content-Length: {4}" + "\n\n{5}";
+
+ private static final int HTTP_PORT = 8085;
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(HTTPBindingCacheTestCase.class);
+ node = NodeFactory.newInstance().createNode("testCache.composite", new Contribution("test", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testGet() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST1, "GET", index, content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfModifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfModifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfUnmodifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Unmodified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfUnmodifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Unmodified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfNoneMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfNoneMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testDelete() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST1, "DELETE", index,
+ content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfModifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfModifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfUnmodifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Unmodified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfUnmodifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Unmodified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfNoneMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfNoneMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testPost() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST1, "POST", index, content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfModifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Modified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return code 200 OK
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfModifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfUnmodifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Unmodified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return code 200 OK
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfUnmodifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Unmodified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Match", "eTagMatch", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return code 200 OK.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat
+ .format(REQUEST2, "POST", index, "If-Match", "eTagNoneMatch",
+ content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfNoneMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-None-Match", "eTagNoneMatch", content.getBytes().length,
+ content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return code 200 OK
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfNoneMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-None-Match", "eTagMatch", content.getBytes().length,
+ content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testPut() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST1, "PUT", index, content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfModifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfModifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfUnmodifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Unmodified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfUnmodifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Unmodified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfNoneMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfNoneMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Read response stream from the given socket.
+ * @param socket
+ * @return
+ * @throws IOException
+ */
+ private static String read(Socket socket) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(socket
+ .getInputStream()));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java
new file mode 100644
index 0000000000..f314bed909
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.text.MessageFormat;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * HTTP binding unit tests.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPBindingTestCase {
+
+ private static final String REQUEST1_HEADER =
+ "GET /httpservice/test HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST1_CONTENT = "";
+ private static final String REQUEST1 =
+ REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT;
+
+ private static final String REQUEST2_HEADER =
+ "GET /webcontent/test.html HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST2_CONTENT = "";
+ private static final String REQUEST2 =
+ REQUEST2_HEADER + REQUEST2_CONTENT.getBytes().length + "\n\n" + REQUEST2_CONTENT;
+
+ private static final String REQUEST3_HEADER =
+ "GET /httpget/{0} HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST3_CONTENT = "";
+ private static final String REQUEST3 =
+ REQUEST3_HEADER + REQUEST3_CONTENT.getBytes().length + "\n\n" + REQUEST3_CONTENT;
+
+ private static final int HTTP_PORT = 8085;
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(HTTPBindingCacheTestCase.class);
+ node = NodeFactory.newInstance().createNode("test.composite", new Contribution("test", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ /**
+ * Test invoking a POJO service implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testServiceImplementation() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("<body><p>hey</body>") != -1);
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testGetImplementation() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String request = MessageFormat.format( REQUEST3, index );
+ os.write( request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ }
+
+ /**
+ * Test getting a static resource provided using the HTTP binding.
+ * @throws Exception
+ */
+ @Ignore("Implementation resource not available")
+ public void testStaticResourceImplementation() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST2.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("<body><p>hello</body>") != -1);
+ }
+
+ /**
+ * Read response stream from the given socket.
+ * @param socket
+ * @return
+ * @throws IOException
+ */
+ private static String read(Socket socket) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/NotModifiedException.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/NotModifiedException.java
new file mode 100644
index 0000000000..1d6efea2a1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/NotModifiedException.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.binding.http;
+
+/**
+ * Indicates that a resource was not modified.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NotModifiedException extends Exception {
+ private static final long serialVersionUID = -5046027674128627383L;
+
+ public NotModifiedException() {
+ }
+
+ public NotModifiedException(String message) {
+ super(message);
+ }
+
+ public NotModifiedException(Throwable cause) {
+ super(cause);
+ }
+
+ public NotModifiedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/PreconditionFailedException.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/PreconditionFailedException.java
new file mode 100644
index 0000000000..5728899ebe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/PreconditionFailedException.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.binding.http;
+
+/**
+ * Indicates that a resource was not modified.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PreconditionFailedException extends Exception {
+ private static final long serialVersionUID = -5046027674128627383L;
+
+ public PreconditionFailedException() {
+ }
+
+ public PreconditionFailedException(String message) {
+ super(message);
+ }
+
+ public PreconditionFailedException(Throwable cause) {
+ super(cause);
+ }
+
+ public PreconditionFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java
new file mode 100644
index 0000000000..959de1474c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java
@@ -0,0 +1,243 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Date;
+
+import org.apache.tuscany.sca.common.http.HTTPCacheContext;
+
+/**
+ * Test service implementation that implements a various conditional HTTP
+ * methods. For testing, the id==0 items are very old (Date(0)), not modified,
+ * and always match ETags and the id==1 items are always brand new (Date()),
+ * modified, and never match ETags. Using these ids one can test the
+ * LastModified and ETag headers of the requests.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestBindingCacheImpl {
+
+ /**
+ * Implements the HTTP get method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream get(String id) {
+ return new ByteArrayInputStream(
+ ("<html><body><p>item=" + id + "</body></html>").getBytes());
+ }
+
+ /**
+ * Implements the HTTP conditional get method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream conditionalGet(String id, HTTPCacheContext cacheContext)
+ throws NotModifiedException, PreconditionFailedException {
+
+ if (cacheContext != null) {
+ if (cacheContext.ifModifiedSince) {
+ if ((id.equals("1"))
+ && (0 > cacheContext.lastModifiedDate
+ .compareTo(new Date())))
+ throw new NotModifiedException("item 1 was modified on "
+ + new Date());
+ }
+ if (cacheContext.ifUnmodifiedSince) {
+ if ((id.equals("0"))
+ && (0 > cacheContext.lastModifiedDate
+ .compareTo(new Date())))
+ throw new PreconditionFailedException(
+ "item 0 was modified on " + new Date(0));
+ }
+ if (cacheContext.ifMatch) {
+ if (id.equals("1"))
+ throw new PreconditionFailedException(
+ "item 1 eTag does not match "
+ + cacheContext.getETag());
+ }
+ if (cacheContext.ifNoneMatch) {
+ if (id.equals("0"))
+ throw new PreconditionFailedException(
+ "item 0 eTag matches " + cacheContext.getETag());
+ }
+ }
+ return new ByteArrayInputStream(
+ ("<html><body><p>item=" + id + "</body></html>").getBytes());
+ }
+
+ /**
+ * Implements the HTTP delete method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream delete(String id) {
+ return new ByteArrayInputStream(
+ ("<html><body><p>deleted item=" + id + "</body></html>")
+ .getBytes());
+ }
+
+ /**
+ * Implements the HTTP conditional delete method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream conditionalDelete(String id, HTTPCacheContext cacheContext)
+ throws NotModifiedException, PreconditionFailedException {
+
+ if (cacheContext != null) {
+ if (cacheContext.ifModifiedSince) {
+ if ((id.equals("1"))
+ && (0 > cacheContext.lastModifiedDate
+ .compareTo(new Date())))
+ throw new NotModifiedException("item 1 was modified on "
+ + new Date());
+ }
+ if (cacheContext.ifUnmodifiedSince) {
+ if ((id.equals("0"))
+ && (0 > cacheContext.lastModifiedDate
+ .compareTo(new Date())))
+ throw new PreconditionFailedException(
+ "item 0 was modified on " + new Date(0));
+ }
+ if (cacheContext.ifMatch) {
+ if (id.equals("1"))
+ throw new PreconditionFailedException(
+ "item 1 eTag does not match "
+ + cacheContext.getETag());
+ }
+ if (cacheContext.ifNoneMatch) {
+ if (id.equals("0"))
+ throw new PreconditionFailedException(
+ "item 0 eTag matches " + cacheContext.getETag());
+ }
+ }
+ return new ByteArrayInputStream(
+ ("<html><body><p>deleted item=" + id + "</body></html>")
+ .getBytes());
+ }
+
+ /**
+ * Implements the HTTP post method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream post() {
+ int id = (new java.util.Random()).nextInt(Integer.MAX_VALUE);
+ return new ByteArrayInputStream(
+ ("<html><body><p>posted item=" + id + "</body></html>")
+ .getBytes());
+ }
+
+ /**
+ * Implements the HTTP conditional post method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public HTTPCacheContext conditionalPost(HTTPCacheContext cacheContext)
+ throws NotModifiedException, PreconditionFailedException {
+ String id = "" + (new java.util.Random()).nextInt(Integer.MAX_VALUE);
+
+ if (cacheContext != null) {
+ if (cacheContext.ifModifiedSince) {
+ if (0 >= cacheContext.lastModifiedDate.compareTo(new Date(0)))
+ throw new NotModifiedException("item was modified on "
+ + new Date());
+ }
+ if (cacheContext.ifUnmodifiedSince) {
+ if ((0 >= cacheContext.lastModifiedDate.compareTo(new Date(0))))
+ throw new PreconditionFailedException(
+ "item was modified on " + new Date(0));
+ }
+ if (cacheContext.ifMatch) {
+ if (cacheContext.getETag().equalsIgnoreCase("ETagNoneMatch"))
+ throw new PreconditionFailedException(
+ "item eTag does not match "
+ + cacheContext.getETag());
+ }
+ if (cacheContext.ifNoneMatch) {
+ if (cacheContext.getETag().equalsIgnoreCase("ETagMatch"))
+ throw new PreconditionFailedException("item eTag matches "
+ + cacheContext.getETag());
+ }
+ }
+
+ // Return the ETag and LastModfied fields by serialize to a byte array
+ HTTPCacheContext returnContext = new HTTPCacheContext();
+ returnContext.setETag( "ETag" + (new java.util.Random()).nextInt(Integer.MAX_VALUE) );
+ returnContext.setLastModified( new Date() );
+ return returnContext;
+ }
+
+ /**
+ * Implements the HTTP update/put method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream put(String id) {
+ return new ByteArrayInputStream(
+ ("<html><body><p>updated item=" + id + "</body></html>")
+ .getBytes());
+ }
+
+ /**
+ * Implements the HTTP conditional update/put method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream conditionalPut(String id, HTTPCacheContext cacheContext)
+ throws NotModifiedException, PreconditionFailedException {
+
+ if (cacheContext != null) {
+ if (cacheContext.ifModifiedSince) {
+ if ((id.equals("1"))
+ && (0 > cacheContext.lastModifiedDate
+ .compareTo(new Date())))
+ throw new NotModifiedException("item 1 was modified on "
+ + new Date());
+ }
+ if (cacheContext.ifUnmodifiedSince) {
+ if ((id.equals("0"))
+ && (0 > cacheContext.lastModifiedDate
+ .compareTo(new Date())))
+ throw new PreconditionFailedException(
+ "item 0 was modified on " + new Date(0));
+ }
+ if (cacheContext.ifMatch) {
+ if (id.equals("1"))
+ throw new PreconditionFailedException(
+ "item 1 eTag does not match "
+ + cacheContext.getETag());
+ }
+ if (cacheContext.ifNoneMatch) {
+ if (id.equals("0"))
+ throw new PreconditionFailedException(
+ "item 0 eTag matches " + cacheContext.getETag());
+ }
+ }
+
+ return new ByteArrayInputStream(
+ ("<html><body><p>updated item=" + id + "</body></html>")
+ .getBytes());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestGetImpl.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestGetImpl.java
new file mode 100644
index 0000000000..333bacbab3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestGetImpl.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.sca.binding.http;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+/**
+ * Test service implementation that implements a get method.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestGetImpl {
+
+ public InputStream get(String id) {
+ return new ByteArrayInputStream(("<html><body><p>item=" + id + "</body></html>").getBytes());
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceImpl.java b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceImpl.java
new file mode 100644
index 0000000000..b8c1223894
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceImpl.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.binding.http;
+
+import java.io.IOException;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Test service implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+
+@Service(Servlet.class)
+public class TestServiceImpl implements Servlet {
+
+ public void init(ServletConfig config) throws ServletException {
+ }
+
+ public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ //HttpServletResponse httpResponse = (HttpServletResponse)response;
+ response.getOutputStream().print("<html><body><p>hey</body></html>");
+ }
+
+ public void destroy() {
+ }
+
+ public ServletConfig getServletConfig() {
+ return null;
+ }
+
+ public String getServletInfo() {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/content/test.html b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/content/test.html
new file mode 100644
index 0000000000..f4b79d7f01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/content/test.html
@@ -0,0 +1,21 @@
+<html>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<body><p>hello</body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/test.composite b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/test.composite
new file mode 100644
index 0000000000..e3525f4afd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/test.composite
@@ -0,0 +1,47 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample/test"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sr="http://sample/test"
+ name="test">
+
+ <!-- component name="ResourceServiceComponent">
+ <tuscany:implementation.resource location="content"/>
+ <service name="Resource">
+ <tuscany:binding.http uri="http://localhost:8085/webcontent"/>
+ </service>
+ </component -->
+
+ <component name="HTTPServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.http.TestServiceImpl"/>
+ <service name="Servlet">
+ <tuscany:binding.http uri="http://localhost:8085/httpservice"/>
+ </service>
+ </component>
+
+ <component name="HTTPGetComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.http.TestGetImpl"/>
+ <service name="TestGetImpl">
+ <tuscany:binding.http uri="http://localhost:8085/httpget"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/testCache.composite b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/testCache.composite
new file mode 100644
index 0000000000..4923cfa74d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http-runtime/src/test/resources/testCache.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample/test"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sr="http://sample/test"
+ name="testCache">
+
+ <component name="HTTPBindingComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.http.TestBindingCacheImpl"/>
+ <service name="TestBindingCacheImpl">
+ <tuscany:binding.http uri="http://localhost:8085/httpbinding"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/LICENSE b/sandbox/sebastien/java/embed/modules/binding-http/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/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/sebastien/java/embed/modules/binding-http/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-http/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b0a4fc01fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.http;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,javax.xml.namespace,javax.servlet.http"
+Bundle-Name: Apache Tuscany SCA HTTP Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA HTTP Binding Model
+Import-Package: javax.servlet.http,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.http;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.http
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/NOTICE b/sandbox/sebastien/java/embed/modules/binding-http/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/pom.xml b/sandbox/sebastien/java/embed/modules/binding-http/pom.xml
new file mode 100644
index 0000000000..204dd1cf41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/pom.xml
@@ -0,0 +1,54 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-http</artifactId>
+ <name>Apache Tuscany SCA HTTP Binding Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java
new file mode 100644
index 0000000000..e0ab1cfff7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.http;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * HTTP binding model.
+ *
+ * @version $Rev$ $Date$
+*/
+public interface HTTPBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.http");
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java
new file mode 100644
index 0000000000..6ba6d8f934
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.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 org.apache.tuscany.sca.binding.http;
+
+/**
+ * Factory for the HTTP binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HTTPBindingFactory {
+
+ /**
+ * Creates a new HTTP binding.
+ * @return a new HTTP binding
+ */
+ HTTPBinding createHTTPBinding();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java
new file mode 100644
index 0000000000..678cd1a426
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.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 org.apache.tuscany.sca.binding.http.impl;
+
+import org.apache.tuscany.sca.binding.http.HTTPBinding;
+import org.apache.tuscany.sca.binding.http.HTTPBindingFactory;
+
+/**
+ * Factory for the HTTP binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPBindingFactoryImpl implements HTTPBindingFactory {
+
+ public HTTPBinding createHTTPBinding() {
+ return new HTTPBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java
new file mode 100644
index 0000000000..2555799f5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.http.HTTPBinding;
+
+
+/**
+ * Implementation of the HTTP binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class HTTPBindingImpl implements HTTPBinding {
+
+ private String name;
+ private String uri;
+
+ private WireFormat wireFormat;
+ private OperationSelector operationSelector;
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ 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 boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The sample binding is always resolved
+ }
+
+ // Wireformat and Operation selection
+
+ public WireFormat getRequestWireFormat() {
+ return wireFormat;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ this.wireFormat = wireFormat;
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return wireFormat;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ this.wireFormat = wireFormat;
+ }
+
+ public OperationSelector getOperationSelector() {
+ return operationSelector;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ this.operationSelector = operationSelector;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java
new file mode 100644
index 0000000000..bdec50bde0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.http.HTTPBinding;
+import org.apache.tuscany.sca.binding.http.HTTPBindingFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+public class HTTPBindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<HTTPBinding> {
+ private static final String NAME = "name";
+ private static final String URI = "uri";
+
+ private HTTPBindingFactory httpBindingFactory;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private StAXAttributeProcessor<Object> extensionAttributeProcessor;
+
+
+ public HTTPBindingProcessor(ExtensionPointRegistry extensionPoints,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.httpBindingFactory = modelFactories.getFactory(HTTPBindingFactory.class);
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+ }
+
+ public QName getArtifactType() {
+ return HTTPBinding.TYPE;
+ }
+
+ public Class<HTTPBinding> getModelType() {
+ return HTTPBinding.class;
+ }
+
+ public HTTPBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ HTTPBinding httpBinding = httpBindingFactory.createHTTPBinding();
+
+ while(reader.hasNext()) {
+ QName elementName = null;
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ elementName = reader.getName();
+
+ if (HTTPBinding.TYPE.equals(elementName)) {
+ String name = getString(reader, NAME);
+ if(name != null) {
+ httpBinding.setName(name);
+ }
+
+ String uri = getURIString(reader, URI);
+ if (uri != null) {
+ httpBinding.setURI(uri);
+ }
+ } else {
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof WireFormat) {
+ httpBinding.setRequestWireFormat((WireFormat)extension);
+ } else if(extension instanceof OperationSelector) {
+ httpBinding.setOperationSelector((OperationSelector)extension);
+ }
+ }
+ }
+ }
+
+ if (event == END_ELEMENT && HTTPBinding.TYPE.equals(reader.getName())) {
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return httpBinding;
+ }
+
+ public void write(HTTPBinding httpBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ //writer.writeStartElement(Constants.SCA10_NS, BINDING_HTTP);
+
+ writeStart(writer, HTTPBinding.TYPE.getNamespaceURI(), HTTPBinding.TYPE.getLocalPart());
+
+ // Write binding name
+ if (httpBinding.getName() != null) {
+ writer.writeAttribute(NAME, httpBinding.getName());
+ }
+
+ // Write binding URI
+ if (httpBinding.getURI() != null) {
+ writer.writeAttribute(URI, httpBinding.getURI());
+ }
+
+ writeEnd(writer);
+ //writer.writeEndElement();
+ }
+
+
+ public void resolve(HTTPBinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // Should not need to do anything here for now...
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory b/sandbox/sebastien/java/embed/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory
new file mode 100644
index 0000000000..3ca68b969b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.http.impl.HTTPBindingFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..f8c0fd2b64
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.http.xml.HTTPBindingProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.http,model=org.apache.tuscany.sca.binding.http.HTTPBinding,factory=org.apache.tuscany.sca.binding.http.HTTPBindingFactory
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/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/sebastien/java/embed/modules/binding-jms-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a25cc85adb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,40 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JMS Binding Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JMS Binding Runtime
+Import-Package: javax.jms,
+ javax.naming,
+ javax.security.auth,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om,
+ org.apache.axiom.om.impl.builder,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.jms;version="2.0.0",
+ org.apache.tuscany.sca.binding.jms.operationselector;version="2.0.0",
+ org.apache.tuscany.sca.binding.jms.policy.authentication.token;version="2.0.0",
+ org.apache.tuscany.sca.binding.jms.policy.header;version="2.0.0",
+ org.apache.tuscany.sca.binding.jms.wireformat;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.wsdlgen;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.authentication.token;version="2.0.0",
+ org.apache.tuscany.sca.policy.security;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.jms.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/pom.xml
new file mode 100644
index 0000000000..27dd79ff46
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/pom.xml
@@ -0,0 +1,117 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <name>Apache Tuscany SCA JMS Binding Runtime</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java
new file mode 100644
index 0000000000..e38a9d0c60
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.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.sca.binding.jms.context;
+
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+
+
+/**
+ * Context that the JMS binding puts on the Tuscany wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingContext {
+
+ private Message jmsMsg;
+ private Session jmsSession;
+ private Session jmsResponseSession;
+ private Destination requestDestination;
+ private Destination replyToDestination;
+ private JMSResourceFactory jmsResourceFactory;
+ private long timeToLive;
+ private boolean useBytesForWFJMSDefaultResponse;
+
+ public Message getJmsMsg() {
+ return jmsMsg;
+ }
+
+ public void setJmsMsg(Message jmsMsg) {
+ this.jmsMsg = jmsMsg;
+ }
+
+ public synchronized Session getJmsSession() {
+ if (jmsSession == null) {
+ try {
+ jmsSession = getJmsResourceFactory().createSession();
+ } catch (Exception e) {
+ throw new JMSBindingException(e);
+ }
+ }
+ return jmsSession;
+ }
+
+ public synchronized void closeJmsSession() {
+ if (jmsSession != null) {
+ try {
+ getJmsResourceFactory().closeSession(jmsSession);
+ } catch (Exception e) {
+ throw new JMSBindingException(e);
+ } finally {
+ jmsSession = null;
+ }
+ }
+ }
+
+ public synchronized Session getJmsResponseSession() {
+ if (jmsResponseSession == null) {
+ try {
+ jmsResponseSession = getJmsResourceFactory().createResponseSession();
+ } catch (Exception e) {
+ throw new JMSBindingException(e);
+ }
+ }
+ return jmsResponseSession;
+ }
+
+ public synchronized void closeJmsResponseSession() {
+ if (jmsResponseSession != null) {
+ try {
+ getJmsResourceFactory().closeResponseSession(jmsResponseSession);
+ } catch (Exception e) {
+ throw new JMSBindingException(e);
+ } finally {
+ jmsResponseSession = null;
+ }
+ }
+ }
+
+ public Destination getRequestDestination() {
+ return requestDestination;
+ }
+
+ public void setRequestDestination(Destination requestDestination) {
+ this.requestDestination = requestDestination;
+ }
+
+ public Destination getReplyToDestination() {
+ return replyToDestination;
+ }
+
+ public void setReplyToDestination(Destination replyToDestination) {
+ this.replyToDestination = replyToDestination;
+ }
+
+ // TODO - difficult to get the resource factory into all the JMS providers
+ // so it's here for the moment
+ public JMSResourceFactory getJmsResourceFactory() {
+ return jmsResourceFactory;
+ }
+
+ public void setJmsResourceFactory(JMSResourceFactory jmsResourceFactory) {
+ this.jmsResourceFactory = jmsResourceFactory;
+ }
+
+ public long getTimeToLive() {
+ return timeToLive;
+ }
+
+ public void setTimeToLive(long timeToLive) {
+ this.timeToLive = timeToLive;
+ }
+
+ public boolean isUseBytesForWFJMSDefaultResponse() {
+ return useBytesForWFJMSDefaultResponse;
+ }
+
+ public void setUseBytesForWFJMSDefaultResponse(
+ boolean useBytesForWFJMSDefaultResponse) {
+ this.useBytesForWFJMSDefaultResponse = useBytesForWFJMSDefaultResponse;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java
new file mode 100644
index 0000000000..9afce4243d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.headers;
+
+
+
+
+import java.util.Map;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSBindingServiceBindingProvider;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeaderReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpointReference runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+ private String correlationScheme;
+ private WireFormat requestWireFormat;
+ private WireFormat responseWireFormat;
+
+ public HeaderReferenceInterceptor(ExtensionPointRegistry extensions, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(extensions, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(extensions, jmsBinding);
+ this.correlationScheme = jmsBinding.getCorrelationScheme();
+
+ }
+
+ public Message invoke(Message msg) {
+
+ return next.invoke(invokeRequest(msg));
+
+ }
+
+ public Message invokeRequest(Message tuscanyMsg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = tuscanyMsg.getBindingContext();
+ javax.jms.Message jmsMsg = tuscanyMsg.getBody();
+
+ Operation operation = tuscanyMsg.getOperation();
+ String operationName = operation.getName();
+ RuntimeEndpointReference reference = runtimeWire;
+
+ // I think the OASIS spec suggests we do not need to do anything with
+ // @nativeOperation here on the reference side.
+ requestMessageProcessor.setOperationName(operationName, jmsMsg);
+
+ if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) {
+ if (jmsBinding.getOperationJMSDeliveryMode(operationName)) {
+ jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
+ } else {
+ jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ }
+ }
+
+ if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) {
+ jmsMsg.setJMSCorrelationID(jmsBinding.getOperationJMSCorrelationId(operationName));
+ }
+
+ if (jmsBinding.getOperationJMSPriority(operationName) != null) {
+ jmsMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName));
+ }
+
+ if (jmsBinding.getOperationJMSType(operationName) != null) {
+ jmsMsg.setJMSType(jmsBinding.getOperationJMSType(operationName));
+ }
+
+ if (tuscanyMsg.getFrom().getCallbackEndpoint() != null) {
+
+ String callbackDestName = getCallbackDestinationName(reference);
+ if (callbackDestName != null) {
+ jmsMsg.setStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY, "jms:jndi:" + callbackDestName);
+ if (operation.isNonBlocking()) {
+ Destination dest = context.getJmsResourceFactory().lookupDestination(callbackDestName);
+ jmsMsg.setJMSReplyTo(dest);
+ }
+ }
+ }
+
+ for (String propName : jmsBinding.getPropertyNames()) {
+ Object value = jmsBinding.getProperty(propName);
+ jmsMsg.setObjectProperty(propName, value);
+ }
+
+ Map<String, Object> operationProperties = jmsBinding.getOperationProperties(operationName);
+ if (operationProperties != null) {
+ for (String propName : operationProperties.keySet()) {
+ Object value = operationProperties.get(propName);
+ jmsMsg.setObjectProperty(propName, value);
+ }
+ }
+
+ if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) {
+ context.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(operationName) * 2);
+ } else {
+ context.setTimeToLive(JMSBindingConstants.DEFAULT_TIME_TO_LIVE);
+ }
+
+ return tuscanyMsg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ } catch (NamingException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+
+ protected String getCallbackDestinationName(RuntimeEndpointReference reference) {
+ RuntimeEndpoint endpoint = (RuntimeEndpoint) reference.getCallbackEndpoint();
+ if (endpoint != null) {
+ JMSBindingServiceBindingProvider bp = (JMSBindingServiceBindingProvider)endpoint.getBindingProvider();
+ return bp.getDestinationName();
+ }
+ return null;
+ }
+
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderServiceInterceptor.java
new file mode 100644
index 0000000000..178a87a53f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderServiceInterceptor.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.binding.jms.headers;
+
+import java.util.Map;
+
+import javax.jms.JMSException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+public class HeaderServiceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private JMSBinding jmsBinding;
+
+ public HeaderServiceInterceptor(JMSBinding jmsBinding) {
+ super();
+ this.jmsBinding = jmsBinding;
+ }
+
+ public Message invoke(Message msg) {
+ return invokeResponse(next.invoke(msg));
+ }
+
+ public Message invokeResponse(Message tuscanyMsg) {
+ try {
+
+ javax.jms.Message jmsMsg = tuscanyMsg.getBody();
+
+ Operation operation = tuscanyMsg.getOperation();
+ String operationName = operation.getName();
+
+ for (String propName : jmsBinding.getPropertyNames()) {
+ Object value = jmsBinding.getProperty(propName);
+ jmsMsg.setObjectProperty(propName, value);
+ }
+
+ Map<String, Object> operationProperties = jmsBinding.getOperationProperties(operationName);
+ if (operationProperties != null) {
+ for (String propName : operationProperties.keySet()) {
+ Object value = operationProperties.get(propName);
+ jmsMsg.setObjectProperty(propName, value);
+ }
+ }
+
+ return tuscanyMsg;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java
new file mode 100644
index 0000000000..cac346adf4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.host;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+public class DefaultJMSHostExtensionPoint implements JMSHostExtensionPoint {
+
+ private JMSServiceListenerFactory jmsServiceListenerFactory;
+
+ public DefaultJMSHostExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ WorkScheduler workScheduler = utilities.getUtility(WorkScheduler.class);
+ this.jmsServiceListenerFactory = new DefaultJMSServiceListenerFactory(workScheduler);
+ }
+
+ public JMSServiceListenerFactory getJMSServiceListenerFactory() {
+ return jmsServiceListenerFactory;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java
new file mode 100644
index 0000000000..aca0d58697
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.host;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+/**
+ * Implementation of the JMS service binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultJMSServiceListener implements JMSServiceListener {
+ private static final Logger logger = Logger.getLogger(DefaultJMSServiceListener.class.getName());
+
+ private MessageListener listener;
+ private String serviceName;
+ private boolean isCallbackService;
+ private JMSBinding jmsBinding;
+ private WorkScheduler workScheduler;
+
+ private JMSResourceFactory jmsResourceFactory;
+ private MessageConsumer consumer;
+ private boolean running;
+
+ private Destination destination;
+
+ public DefaultJMSServiceListener(MessageListener listener, String serviceName, boolean isCallbackService, JMSBinding jmsBinding, WorkScheduler workScheduler, JMSResourceFactory rf) {
+ this.listener = listener;
+ this.serviceName = serviceName;
+ this.isCallbackService = isCallbackService;
+ this.jmsBinding = jmsBinding;
+ this.workScheduler = workScheduler;
+ this.jmsResourceFactory = rf;
+ }
+
+ public void start() {
+ this.running = true;
+
+ try {
+ registerListerner();
+ } catch (Exception e) {
+ if (e instanceof JMSBindingException) throw (JMSBindingException)e;
+ throw new JMSBindingException("Error starting JMSServiceBinding", e);
+ }
+ }
+
+ public void stop() {
+ this.running = false;
+ try {
+ consumer.close();
+ jmsResourceFactory.closeConnection();
+ jmsResourceFactory.closeResponseConnection();
+ } catch (Exception e) {
+ // if using an embedded broker then when shutting down Tuscany the broker may get closed
+ // before this stop method is called. I can't see how to detect that so for now just
+ // ignore the exception if the message is that the transport is already disposed
+ if ((e.getMessage() == null) || !e.getMessage().contains("disposed")) {
+ throw new JMSBindingException("Error stopping JMSServiceBinding", e);
+ }
+ }
+ }
+
+ private void registerListerner() throws NamingException, JMSException {
+
+ Session session = jmsResourceFactory.createSession();
+ destination = lookupDestinationQueue();
+ if (destination == null) {
+ destination = session.createTemporaryQueue();
+ }
+
+ if (jmsBinding.getJMSSelector() != null) {
+ consumer = session.createConsumer(destination, jmsBinding.getJMSSelector());
+ } else {
+ consumer = session.createConsumer(destination);
+ }
+
+ try {
+
+ consumer.setMessageListener(listener);
+ jmsResourceFactory.startConnection();
+
+ } catch (javax.jms.JMSException e) {
+
+ // setMessageListener not allowed in JEE container so use Tuscany threads
+
+ jmsResourceFactory.startConnection();
+ workScheduler.scheduleWork(new Runnable() {
+ public void run() {
+ try {
+ while (running) {
+ final Message msg = consumer.receive();
+ workScheduler.scheduleWork(new Runnable() {
+ public void run() {
+ try {
+ listener.onMessage(msg);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ logger.log(Level.INFO, "JMS " + (isCallbackService ? "callback service" : "service")
+ + " '"
+ + serviceName
+ + "' listening on destination "
+ + ((destination instanceof Queue) ? ((Queue)destination).getQueueName() : ((Topic)destination).getTopicName()));
+ }
+
+ /**
+ * Looks up the Destination Queue for the JMS Binding.
+ * <p>
+ * What happens in the look up will depend on the create mode specified for the JMS Binding:
+ * <ul>
+ * <li>always - the JMS queue is always created. It is an error if the queue already exists
+ * <li>ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists
+ * <li>never - the JMS queue is never created. It is an error if the queue does not exist
+ * </ul>
+ * See the SCA JMS Binding specification for more information.
+ * <p>
+ *
+ * @return The Destination queue.
+ * @throws NamingException Failed to lookup JMS queue
+ * @throws JMSBindingException Failed to lookup JMS Queue. Probable cause is that the JMS queue's current existence/non-existence is not
+ * compatible with the create mode specified on the binding
+ */
+ private Destination lookupDestinationQueue() throws NamingException, JMSBindingException {
+
+ if (isCallbackService && (jmsBinding.getDestinationName() == null)) {
+ // if its a callback service returning null indicates to use a temporary queue
+ return null;
+ }
+
+ Destination destination = jmsResourceFactory.lookupDestination(jmsBinding.getDestinationName());
+
+ String qCreateMode = jmsBinding.getDestinationCreate();
+ if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) {
+ // In this mode, the queue must not already exist as we are creating it
+ if (destination != null) {
+ throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
+ + " already exists but has create mode of \""
+ + qCreateMode
+ + "\" while registering service "
+ + serviceName
+ + " listener");
+ }
+
+ // Create the queue
+ destination = jmsResourceFactory.createDestination(jmsBinding.getDestinationName());
+
+ } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ // In this mode, the queue may nor may not exist. It will be created if it does not exist
+ // but don't create when using jms:jndi uri format
+ if (destination == null && !"jndi".equals(jmsBinding.getDestinationType())) {
+ destination = jmsResourceFactory.createDestination(jmsBinding.getDestinationName());
+ }
+
+ } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) {
+ // In this mode, the queue must have already been created.
+ if (destination == null) {
+ throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
+ + " not found but create mode of \""
+ + qCreateMode
+ + "\" while registering service "
+ + serviceName
+ + " listener");
+ }
+ }
+
+ // Make sure we ended up with a queue
+ if (destination == null) {
+ throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
+ + " not found with create mode of \""
+ + qCreateMode
+ + "\" while registering service "
+ + serviceName
+ + " listener");
+ }
+
+ // Make sure its the expected type (queue or topic)
+ String type = (destination instanceof Queue) ? JMSBindingConstants.DESTINATION_TYPE_QUEUE : JMSBindingConstants.DESTINATION_TYPE_TOPIC;
+ if ("jndi".equals(jmsBinding.getDestinationType())) {
+ jmsBinding.setDestinationType(type);
+ } else {
+ if (!type.equals(jmsBinding.getDestinationType())) {
+ throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName()
+ + " expecting type of "
+ + jmsBinding.getDestinationType()
+ + " but found "
+ + type
+ + " while registering service "
+ + serviceName
+ + " listener");
+ }
+ }
+
+ return destination;
+ }
+
+ public String getDestinationName() {
+ try {
+ if (destination instanceof Queue) {
+ return ((Queue)destination).getQueueName();
+ } else if (destination instanceof Topic) {
+ return ((Topic)destination).getTopicName();
+ } else {
+ return null;
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java
new file mode 100644
index 0000000000..1976d687b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.host;
+
+import javax.jms.MessageListener;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.provider.JMSBindingServiceBindingProvider;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+public class DefaultJMSServiceListenerFactory implements JMSServiceListenerFactory {
+
+ private WorkScheduler workScheduler;
+
+ public DefaultJMSServiceListenerFactory(WorkScheduler workScheduler) {
+ this.workScheduler = workScheduler;
+ }
+
+ public JMSServiceListener createJMSServiceListener(JMSServiceListenerDetails jmsSLD) {
+ try {
+
+ JMSResourceFactory rf = ((JMSBindingServiceBindingProvider)jmsSLD).getResourceFactory();
+
+ RuntimeComponentService service = (RuntimeComponentService) jmsSLD.getEndpoint().getService();
+ MessageListener listener = new DefaultServiceInvoker(jmsSLD.getEndpoint(), jmsSLD.getTargetBinding(), jmsSLD.getMessageFactory(), rf);
+
+// return new ASFListener(listener, service.getName(), service.isCallback(), jmsSLD.getJmsBinding(), workScheduler, rf);
+// TODO: 2.x migration, service.isCallback()
+ return new DefaultJMSServiceListener(listener, service.getName(), false, jmsSLD.getJmsBinding(), workScheduler, rf);
+
+ } catch (NamingException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java
new file mode 100644
index 0000000000..9f3062f065
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.host;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * TODO RRB experiement
+ * Listener for the JMSBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultServiceInvoker implements MessageListener {
+
+ private static final Logger logger = Logger.getLogger(DefaultServiceInvoker.class.getName());
+
+ private RuntimeEndpoint endpoint;
+ private JMSBinding jmsBinding;
+ private Binding targetBinding;
+ private JMSResourceFactory jmsResourceFactory;
+ private RuntimeComponentService service;
+ private MessageFactory messageFactory;
+
+ public DefaultServiceInvoker(RuntimeEndpoint endpoint, Binding targetBinding, MessageFactory messageFactory, JMSResourceFactory rf) throws NamingException {
+ this.endpoint = endpoint;
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.jmsResourceFactory = rf;
+ this.service = (RuntimeComponentService) endpoint.getService();
+ this.targetBinding = targetBinding;
+ this.messageFactory = messageFactory;
+
+ }
+
+ public void onMessage(Message requestJMSMsg) {
+ logger.log(Level.FINE, "JMS service '" + service.getName() + "' received message " + requestJMSMsg);
+ try {
+ invokeService(requestJMSMsg);
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, "Exception send fault response '" + service.getName(), e);
+ }
+ }
+
+ protected void invokeService(Message requestJMSMsg) throws JMSException, InvocationTargetException {
+
+ // create the tuscany message
+ org.apache.tuscany.sca.invocation.Message tuscanyMsg = messageFactory.createMessage();
+
+ // populate the message context with JMS binding information
+ JMSBindingContext context = new JMSBindingContext();
+ tuscanyMsg.setBindingContext(context);
+
+ context.setJmsMsg(requestJMSMsg);
+ context.setJmsResourceFactory(jmsResourceFactory);
+ context.setReplyToDestination(requestJMSMsg.getJMSReplyTo());
+
+ // set the message body
+ tuscanyMsg.setBody(requestJMSMsg);
+
+ // call the runtime wire - the response is handled by the
+ // transport interceptor
+ getEndpoint(targetBinding).invoke(tuscanyMsg);
+
+ }
+
+ private RuntimeEndpoint getEndpoint(Binding targetBinding) {
+ for(Endpoint ep: service.getEndpoints()) {
+ if(ep.getBinding() == targetBinding) {
+ return (RuntimeEndpoint) ep;
+ }
+ }
+ return endpoint;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java
new file mode 100644
index 0000000000..a15a84b60e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.host;
+
+
+public interface JMSHostExtensionPoint {
+
+ JMSServiceListenerFactory getJMSServiceListenerFactory();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java
new file mode 100644
index 0000000000..444d796b12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.host;
+
+public interface JMSServiceListener {
+
+ void start();
+
+ void stop();
+
+ String getDestinationName();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java
new file mode 100644
index 0000000000..451f3680d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.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.sca.binding.jms.host;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public interface JMSServiceListenerDetails {
+
+ JMSBinding getJmsBinding();
+
+ Binding getTargetBinding();
+
+ RuntimeEndpoint getEndpoint();
+
+ MessageFactory getMessageFactory();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java
new file mode 100644
index 0000000000..9dc23f1d8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.host;
+
+
+public interface JMSServiceListenerFactory {
+
+ JMSServiceListener createJMSServiceListener(JMSServiceListenerDetails jmsServiceBindingProvider);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java
new file mode 100644
index 0000000000..61a2a076de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.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.binding.jms.operationselector.jmsdefault.runtime;
+
+import org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSDefault;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSDefaultProviderFactory implements OperationSelectorProviderFactory<OperationSelectorJMSDefault> {
+ private ExtensionPointRegistry registry;
+
+ public OperationSelectorJMSDefaultProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference) {
+ return null;
+ }
+
+ /**
+ */
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint) {
+ return new OperationSelectorJMSDefaultServiceProvider(registry, endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java
new file mode 100644
index 0000000000..cefba467e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.runtime;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.TextMessage;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSDefaultServiceInterceptor implements Interceptor {
+
+ private static final String ON_MESSAGE_METHOD_NAME = "onMessage";
+
+ private Invoker next;
+ private RuntimeEndpoint endpint;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+ private RuntimeComponentService service;
+ private List<Operation> serviceOperations;
+ private DOMHelper domHelper;
+
+ public OperationSelectorJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) {
+ super();
+ this.endpint = endpoint;
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.serviceOperations = service.getInterfaceContract().getInterface().getOperations();
+ this.domHelper = DOMHelper.getInstance(registry);
+ }
+
+ public Message invoke(Message msg) {
+ return next.invoke(invokeRequest(msg));
+ }
+
+ public Message invokeRequest(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ String operationName = requestMessageProcessor.getOperationName(jmsMsg);
+ Operation operation = getTargetOperation(operationName, jmsMsg);
+ msg.setOperation(operation);
+
+ return msg;
+ }
+
+ protected Operation getTargetOperation(String operationName, javax.jms.Message jmsMsg) {
+ Operation operation = null;
+
+ if (serviceOperations.size() == 1) {
+
+ // SCA JMS Binding Specification - Rule 1.5.1 line 203
+ operation = serviceOperations.get(0);
+
+ } else if (operationName != null) {
+
+ // SCA JMS Binding Specification - Rule 1.5.1 line 205
+ for (Operation op : serviceOperations) {
+ if (op.getName().equals(operationName)) {
+ operation = op;
+ break;
+ }
+ }
+ } else if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault
+ || jmsBinding.getRequestWireFormat() instanceof WireFormatJMSTextXML) {
+
+ Node rootElement;
+ String operationFromPayload;
+
+ try {
+ if (jmsMsg instanceof TextMessage) {
+ String xmlPayload = ((TextMessage) jmsMsg).getText();
+
+ if (xmlPayload != null) {
+ rootElement = domHelper.load(xmlPayload);
+ Node firstChild = rootElement.getFirstChild();
+ if (firstChild != null) {
+ operationFromPayload = firstChild.getLocalName();
+ for (Operation op : serviceOperations) {
+ if (op.getName().equals(operationFromPayload)) {
+ operation = op;
+ break;
+ }
+ }
+ }
+ }
+ } else if (jmsMsg instanceof BytesMessage) {
+ long noOfBytes = ((BytesMessage) jmsMsg).getBodyLength();
+ byte[] bytes = new byte[(int) noOfBytes];
+ ((BytesMessage) jmsMsg).readBytes(bytes);
+ ((BytesMessage) jmsMsg).reset();
+
+ if (bytes != null) {
+ rootElement = domHelper.load(new String(bytes));
+ Node firstChild = rootElement.getFirstChild();
+ if (firstChild != null) {
+ operationFromPayload = firstChild.getLocalName();
+ for (Operation op : serviceOperations) {
+ if (op.getName().equals(operationFromPayload)) {
+ operation = op;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ } catch (IOException e) {
+ //let's ignore this in case the client doesn't want to use a wrapped xml message
+ } catch (SAXException e) {
+ //let's ignore this in case the client doesn't want to use a wrapped xml message
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+
+ // If operation is still null we attempt the last rule
+ if (operation == null) {
+
+ // SCA JMS Binding Specification - Rule 1.5.1 line 207
+ for (Operation op : serviceOperations) {
+ if (op.getName().equals(ON_MESSAGE_METHOD_NAME)) {
+ operation = op;
+ break;
+ }
+ }
+ }
+ }
+
+ if (operation == null) {
+ throw new JMSBindingException("Cannot determine service operation");
+ }
+
+ return operation;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java
new file mode 100644
index 0000000000..da120ac6c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.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.sca.binding.jms.operationselector.jmsdefault.runtime;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSDefaultServiceProvider implements OperationSelectorProvider {
+ private RuntimeEndpoint endpoint;
+ private ExtensionPointRegistry registry;
+
+ public OperationSelectorJMSDefaultServiceProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint) {
+ super();
+ this.endpoint = endpoint;
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public Interceptor createInterceptor() {
+ return new OperationSelectorJMSDefaultServiceInterceptor(registry, null, endpoint);
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java
new file mode 100644
index 0000000000..4352f5d416
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.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 org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop.runtime;
+
+import org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSUserProp;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+public class OperationSelectorJMSUserPropProviderFactory implements OperationSelectorProviderFactory<OperationSelectorJMSUserProp> {
+ private ExtensionPointRegistry registry;
+
+ public OperationSelectorJMSUserPropProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference) {
+ return null;
+ }
+
+ /**
+ */
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint) {
+ return new OperationSelectorJMSUserPropServiceProvider(endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java
new file mode 100644
index 0000000000..343aa8d52a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop.runtime;
+
+import java.util.List;
+
+import javax.jms.JMSException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSUserProp;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Interceptor for user property based operation selection
+ *
+ * <operationSelector.jmsUser propertName="MyHeaderProperty"/>
+ *
+ */
+public class OperationSelectorJMSUserPropServiceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpoint endpoint;
+ private JMSBinding jmsBinding;
+ private OperationSelectorJMSUserProp operationSelector;
+ private RuntimeComponentService service;
+ private List<Operation> serviceOperations;
+
+ public OperationSelectorJMSUserPropServiceInterceptor(RuntimeEndpoint endpoint) {
+ super();
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.operationSelector = (OperationSelectorJMSUserProp)jmsBinding.getOperationSelector();
+ this.endpoint = endpoint;
+ this.service = (RuntimeComponentService) endpoint.getService();
+ this.serviceOperations = service.getInterfaceContract().getInterface().getOperations();
+ }
+
+ public Message invoke(Message msg) {
+ return next.invoke(invokeRequest(msg));
+ }
+
+ public Message invokeRequest(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ Operation operation = getTargetOperation(jmsMsg);
+ msg.setOperation(operation);
+
+ return msg;
+ }
+
+ protected Operation getTargetOperation(javax.jms.Message jmsMsg) {
+ String operationName = null;
+ String opSelectorPropertyName = operationSelector.getPropertyName();
+
+ try {
+ operationName = jmsMsg.getStringProperty(opSelectorPropertyName);
+ } catch(JMSException e) {
+ throw new JMSBindingException(e);
+ }
+
+ if (operationName == null){
+ throw new JMSBindingException("Property " + opSelectorPropertyName + " not found in message header");
+ }
+
+ for (Operation op : serviceOperations) {
+ if (op.getName().equals(operationName)) {
+ return op;
+ }
+ }
+
+ throw new JMSBindingException("Can't find operation " + operationName);
+ }
+
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java
new file mode 100644
index 0000000000..a151688c36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.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.sca.binding.jms.operationselector.jmsuserprop.runtime;
+
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class OperationSelectorJMSUserPropServiceProvider implements OperationSelectorProvider {
+ private RuntimeEndpoint endpoint;
+
+ public OperationSelectorJMSUserPropServiceProvider(RuntimeEndpoint endpoint) {
+ super();
+ this.endpoint = endpoint;
+ }
+
+ /**
+ */
+ public Interceptor createInterceptor() {
+ return new OperationSelectorJMSUserPropServiceInterceptor(endpoint);
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.java
new file mode 100644
index 0000000000..edecc18d2d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.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.sca.binding.jms.policy.authentication.token.provider;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationPolicyProviderFactory implements PolicyProviderFactory<JMSTokenAuthenticationPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public JMSTokenAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation)
+ */
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) {
+ return null;//new TokenAuthenticationImplementationPolicyProvider(component, implementation);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new JMSTokenAuthenticationReferencePolicyProvider(endpointReference);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new JMSTokenAuthenticationServicePolicyProvider(endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ return null;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent arg0) {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..c5d0705eb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyInterceptor.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.policy.authentication.token.provider;
+
+
+import javax.jms.JMSException;
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.token.TokenPrincipal;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationReferencePolicyInterceptor implements PhasedInterceptor {
+
+ private Invoker next;
+ private PolicySet policySet = null;
+ private String context;
+ private JMSTokenAuthenticationPolicy policy;
+ private String phase;
+
+ public JMSTokenAuthenticationReferencePolicyInterceptor(String context, PolicySet policySet, String phase) {
+ super();
+ this.policySet = policySet;
+ this.context = context;
+ this.phase = phase;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof JMSTokenAuthenticationPolicy){
+ policy = (JMSTokenAuthenticationPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ javax.jms.Message jmsMsg = msg.getBody();
+
+ if ( policy.getTokenName() != null){
+
+ Subject subject = SecurityUtil.getSubject(msg);
+ TokenPrincipal principal = SecurityUtil.getPrincipal(subject, TokenPrincipal.class);
+
+ if (principal == null){
+ // should call out here to some 3rd party system to get credentials
+ // and correct token. Here we are just putting in the token name
+ principal = new TokenPrincipal("DummyTokenID");
+ subject.getPrincipals().add(principal);
+ }
+
+ jmsMsg.setStringProperty(policy.getTokenName().toString(), principal.getName());
+ }
+
+ return getNext().invoke(msg);
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return phase;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.java
new file mode 100644
index 0000000000..b3c7f40c55
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.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.binding.jms.policy.authentication.token.provider;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationReferencePolicyProvider extends BasePolicyProvider<JMSTokenAuthenticationPolicy> {
+ private EndpointReference endpointReference;
+
+ public JMSTokenAuthenticationReferencePolicyProvider(EndpointReference endpointReference) {
+ super(JMSTokenAuthenticationPolicy.class, endpointReference);
+ this.endpointReference = endpointReference;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ PolicySet ps = findPolicySet();
+ return ps == null ? null : new JMSTokenAuthenticationReferencePolicyInterceptor(getContext(), ps, getPhase());
+
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
+ */
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_POLICY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyInterceptor.java
new file mode 100644
index 0000000000..c570354981
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyInterceptor.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.policy.authentication.token.provider;
+
+
+
+import javax.jms.JMSException;
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.token.TokenPrincipal;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+
+/**
+ * Policy handler to handle token based authentication
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationServicePolicyInterceptor implements PhasedInterceptor {
+ private Invoker next;
+ private PolicySet policySet = null;
+ private String context;
+ private JMSTokenAuthenticationPolicy policy;
+ private String phase;
+
+ public JMSTokenAuthenticationServicePolicyInterceptor(String context, PolicySet policySet, String phase) {
+ super();
+ this.policySet = policySet;
+ this.context = context;
+ this.phase = phase;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof JMSTokenAuthenticationPolicy){
+ policy = (JMSTokenAuthenticationPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+ try{
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ String token = jmsMsg.getStringProperty(policy.getTokenName().toString());
+
+ Subject subject = SecurityUtil.getSubject(msg);
+ TokenPrincipal principal = SecurityUtil.getPrincipal(subject, TokenPrincipal.class);
+
+ if (principal == null){
+ principal = new TokenPrincipal(token);
+ subject.getPrincipals().add(principal);
+ }
+
+ System.out.println("JMS service received token: " + principal.getName());
+
+ // call out here to some 3rd party system to do whatever you
+ // need to authenticate the principal
+
+ return getNext().invoke(msg);
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return phase;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.java
new file mode 100644
index 0000000000..351b1c3f0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.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.binding.jms.policy.authentication.token.provider;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationServicePolicyProvider extends BasePolicyProvider<JMSTokenAuthenticationPolicy> {
+
+ private Endpoint endpoint;
+
+ public JMSTokenAuthenticationServicePolicyProvider(Endpoint endpoint) {
+ super(JMSTokenAuthenticationPolicy.class, endpoint);
+ this.endpoint = endpoint;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ PolicySet ps = findPolicySet();
+ return ps == null ? null : new JMSTokenAuthenticationServicePolicyInterceptor(getContext(), ps, getPhase());
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_POLICY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderPolicyProviderFactory.java
new file mode 100644
index 0000000000..4a199bcdff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderPolicyProviderFactory.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.binding.jms.policy.header.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMSHeaderPolicyProviderFactory implements PolicyProviderFactory<JMSHeaderPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public JMSHeaderPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation)
+ */
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) {
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new JMSHeaderReferencePolicyProvider(endpointReference);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createServicePolicyProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() { // TODO Auto-generated method stub
+ return null;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent arg0) {
+ return null; // Not used for a Binding
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderReferencePolicyInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..967614f9b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderReferencePolicyInterceptor.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.jms.policy.header.provider;
+
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSHeaderReferencePolicyInterceptor implements PhasedInterceptor {
+
+ private Invoker next;
+ private PolicySet policySet = null;
+ private String context;
+ private JMSHeaderPolicy jmsHeaderPolicy;
+ private String phase;
+ private EndpointReference endpointReference;
+
+ public JMSHeaderReferencePolicyInterceptor(String context, EndpointReference endpointReference, PolicySet policySet, String phase) {
+ super();
+ this.endpointReference = endpointReference;
+ this.policySet = policySet;
+ this.context = context;
+ this.phase = phase;
+
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof JMSHeaderPolicy){
+ jmsHeaderPolicy = (JMSHeaderPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+
+ javax.jms.Message jmsMsg = msg.getBody();
+
+ // JMS header attrs set on MessageProducer via interceptors.
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return phase;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderReferencePolicyProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderReferencePolicyProvider.java
new file mode 100644
index 0000000000..b3d7b584aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/provider/JMSHeaderReferencePolicyProvider.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.policy.header.provider;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMSHeaderReferencePolicyProvider extends BasePolicyProvider<JMSHeaderPolicy> {
+
+ private EndpointReference endpointReference;
+
+ public JMSHeaderReferencePolicyProvider(EndpointReference endpointReference) {
+ super(JMSHeaderPolicy.class, endpointReference);
+ this.endpointReference = endpointReference;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ PolicySet ps = findPolicySet();
+ return ps == null ? null : new JMSHeaderReferencePolicyInterceptor(getContext(), endpointReference, ps, getPhase());
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
+ */
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_POLICY;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java
new file mode 100644
index 0000000000..35cc5769fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Base MessageProcessor for the JMSBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractMessageProcessor implements JMSMessageProcessor {
+ private static final Logger logger = Logger.getLogger(AbstractMessageProcessor.class.getName());
+
+ protected String operationPropertyName;
+ protected boolean xmlFormat = true;
+
+ public AbstractMessageProcessor(JMSBinding jmsBinding) {
+ this.operationPropertyName = jmsBinding.getOperationSelectorPropertyName();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#getOperationName(javax.jms.Message)
+ */
+ public String getOperationName(Message message) {
+ try {
+
+ return message.getStringProperty(operationPropertyName);
+
+ } catch (JMSException e) {
+ throw new JMSBindingException("Exception retreiving operation name from message", e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#setOperationName(javax.jms.Message, java.lang.String)
+ */
+ public void setOperationName(String operationName, Message message) {
+ try {
+
+ message.setStringProperty(operationPropertyName, operationName);
+
+ } catch (JMSException e) {
+ throw new JMSBindingException("Exception setting the operation name on message", e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#extractPayload(javax.jms.Session, java.lang.Object)
+ */
+ public Message insertPayloadIntoJMSMessage(Session session, Object o) {
+ return createJMSMessage(session, o);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#extractPayload(javax.jms.Message)
+ */
+ public Object extractPayloadFromJMSMessage(Message msg) {
+ try {
+ if (msg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) {
+ Object exc = ((ObjectMessage)msg).getObject();
+ if (exc instanceof RuntimeException) {
+ throw new ServiceRuntimeException("remote service exception, see nested exception", (Throwable)exc);
+ } else {
+ return new InvocationTargetException((Throwable) exc);
+ }
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ return extractPayload(msg);
+ }
+
+ public Message createFaultMessage(Session session, Throwable o) {
+ if (session == null) {
+ logger.fine("no response session to create fault message: " + String.valueOf(o));
+ return null;
+ }
+ try {
+
+ ObjectMessage message = session.createObjectMessage();
+ String causeMsg;
+ if (o instanceof RuntimeException) {
+ message.setObject(new ServiceRuntimeException(o.getMessage()));
+ } else {
+ // for a checked exception return the checked exception
+ message.setObject(o);
+ }
+ message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true);
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ protected abstract Object extractPayload(Message msg);
+
+ protected abstract Message createJMSMessage(Session session, Object o);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java
new file mode 100644
index 0000000000..7b14d29dfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.util.logging.Logger;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * MessageProcessor for sending/receiving javax.jms.BytesMessage with the JMSBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BytesMessageProcessor extends AbstractMessageProcessor {
+ private static final Logger logger = Logger.getLogger(AbstractMessageProcessor.class.getName());
+
+ public BytesMessageProcessor(JMSBinding jmsBinding, ExtensionPointRegistry registry) {
+ super(jmsBinding);
+ }
+
+/* TUSCANY-2967 - disable this change while we decide what to do and
+ * return faults as JMSObject messages to be consistent
+ * again with other wire formats
+ @Override
+ public Object extractPayloadFromJMSMessage(Message msg) {
+ byte [] bytes = (byte [])extractPayload(msg);
+
+ try {
+ if (msg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) {
+ return new InvocationTargetException(new ServiceRuntimeException(new String(bytes)));
+ } else {
+ return bytes;
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+*/
+
+ @Override
+ protected Object extractPayload(Message msg) {
+ try {
+
+ if (!(msg instanceof BytesMessage)) {
+ throw new IllegalStateException("expecting JMS BytesMessage: " + msg);
+ }
+
+ long noOfBytes = ((BytesMessage)msg).getBodyLength();
+ byte [] bytes = new byte[(int)noOfBytes];
+ ((BytesMessage)msg).readBytes(bytes);
+ ((BytesMessage)msg).reset();
+ return bytes;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+/* TUSCANY-2967 - disable this change while we decide what to do and
+ * return faults as JMSObject messages to be consistent
+ * again with other wire formats
+ @Override
+ public Message createFaultMessage(Session session, Throwable o) {
+ try {
+ Message message = createJMSMessage(session, o.toString().getBytes());
+ message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true);
+ return message;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+*/
+
+ @Override
+ protected Message createJMSMessage(Session session, Object o) {
+ if (session == null) {
+ logger.fine("no response session to create message: " + String.valueOf(o));
+ return null;
+ }
+ try {
+
+ // TODO - an experiment. How to enforce a single
+ // byte array parameter
+ BytesMessage message = session.createBytesMessage();
+
+ if (o != null){
+ message.writeBytes((byte[])o);
+ }
+
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java
new file mode 100644
index 0000000000..32531fa6c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.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.jms.provider;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+
+public class DefaultJMSResourceFactoryExtensionPoint implements JMSResourceFactoryExtensionPoint {
+
+ public JMSResourceFactory createJMSResourceFactory(JMSBinding binding) {
+ return new JMSResourceFactoryImpl(binding.getConnectionFactoryName(), binding.getResponseConnectionFactoryName(), binding.getInitialContextFactoryName(), binding.getJndiURL());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java
new file mode 100644
index 0000000000..c538dd01da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java
@@ -0,0 +1,302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * MessageProcessor for sending/receiving XML over javax.jms.TextMessage or javax.jms.BytesMessage
+ * with the JMSBinding.
+ * This is very specific to the default wire format and is not tied into the usual hierarchy
+ * of message processors
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultMessageProcessor extends AbstractMessageProcessor {
+ private static final Logger logger = Logger.getLogger(DefaultMessageProcessor.class.getName());
+
+ private DOMHelper domHelper;
+
+ public DefaultMessageProcessor(JMSBinding jmsBinding, ExtensionPointRegistry registry) {
+ super(jmsBinding);
+ this.domHelper = DOMHelper.getInstance(registry);
+ }
+
+ // inherited methods that don't do anything useful
+ @Override
+ protected Message createJMSMessage(Session session, Object o) {
+ // should not be used
+ return null;
+ }
+
+ @Override
+ protected Object extractPayload(Message msg) {
+ // if it's not a text/bytes message or a fault then we don;t know what to do with it
+ return null;
+ }
+
+ // TODO - This makes the assumption that whatever the text/bytes configuration of the
+ // jms binding, unchecked faults will be sent as bytes.
+ @Override
+ public Message createFaultMessage(Session session, Throwable o) {
+ return createFaultJMSBytesMessage(session, o);
+ }
+
+ // handle text messages
+
+ public Object extractPayloadFromJMSTextMessage(Message msg, Node wrapper) {
+ if (msg instanceof TextMessage) {
+ try {
+ String xml = ((TextMessage) msg).getText();
+
+ Object os;
+ if (xml != null && xml.length() > 0) {
+ os = domHelper.load(xml);
+ } else {
+ os = null;
+ }
+
+ if (wrapper != null){
+ //don't modify the original wrapper since it will be reused
+ //clone the wrapper
+ Node node = ((Node)os);
+ if (node == null) {
+ node = domHelper.newDocument();
+ }
+ Element newWrapper = DOMHelper.createElement((Document)node, new QName(wrapper.getNamespaceURI(), wrapper.getLocalName()));
+ if (os != null){
+ Node child = node.getFirstChild();
+ newWrapper.appendChild(child);
+ }
+ return newWrapper;
+ }
+
+ return os;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ } catch (IOException e) {
+ throw new JMSBindingException(e);
+ } catch (SAXException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ // handle the non-text fault case
+ return super.extractPayloadFromJMSMessage(msg);
+ }
+ }
+
+ public Message insertPayloadIntoJMSTextMessage(Session session, Object o, boolean unwrap) {
+
+ try {
+
+ TextMessage message = session.createTextMessage();
+
+ if (o instanceof Node) {
+
+ if (unwrap){
+ Node firstElement = ((Node)o).getFirstChild();
+ if (firstElement == null ) {
+ message.setText("");
+ } else {
+ message.setText(domHelper.saveAsString(firstElement));
+ }
+ }else {
+ message.setText(domHelper.saveAsString((Node)o));
+ }
+ } else if ((o instanceof Object[]) && ((Object[]) o)[0] instanceof Node) {
+ if (unwrap){
+ Node firstElement = ((Node)((Object[]) o)[0]).getFirstChild();
+ if (firstElement == null ) {
+ message.setText(null);
+ } else {
+ message.setText(domHelper.saveAsString(firstElement));
+ }
+ }else {
+ message.setText(domHelper.saveAsString((Node)((Object[])o)[0]));
+ }
+ } else if (o != null) {
+ throw new IllegalStateException("expecting Node payload: " + o);
+ }
+
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message createFaultJMSTextMessage(Session session, Throwable o) {
+
+ if (session == null) {
+ logger.fine("no response session to create fault message: " + String.valueOf(o));
+ return null;
+ }
+ if (o instanceof FaultException) {
+ try {
+
+ TextMessage message = session.createTextMessage();
+ message.setText(domHelper.saveAsString((Node)((FaultException)o).getFaultInfo()));
+ message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true);
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ // handle the non XML fault case
+ return super.createFaultMessage(session, o);
+ }
+ }
+
+ // handle bytes messages
+
+ public Object extractPayloadFromJMSBytesMessage(Message msg, Node wrapper) {
+
+ if (msg instanceof BytesMessage) {
+ try {
+ Object os;
+
+ long noOfBytes = ((BytesMessage) msg).getBodyLength();
+ byte[] bytes = new byte[(int) noOfBytes];
+ ((BytesMessage) msg).readBytes(bytes);
+ ((BytesMessage)msg).reset();
+
+ if ((bytes != null) && (bytes.length > 0)) {
+ os = domHelper.load(new String(bytes));
+ } else {
+ os = null;
+ }
+
+ if (wrapper != null){
+ //don't modify the original wrapper since it will be reused
+ //clone the wrapper
+ Node node = ((Node)os);
+ if (node == null) {
+ node = domHelper.newDocument();
+ }
+ Element newWrapper = DOMHelper.createElement((Document)node, new QName(wrapper.getNamespaceURI(), wrapper.getLocalName()));
+ if (os != null){
+ Node child = node.getFirstChild();
+ newWrapper.appendChild(child);
+ }
+ return newWrapper;
+ }
+
+ return os;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ } catch (IOException e) {
+ throw new JMSBindingException(e);
+ } catch (SAXException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ // trap the non-bytes fault case
+ return super.extractPayloadFromJMSMessage(msg);
+ }
+ }
+
+ public Message insertPayloadIntoJMSBytesMessage(Session session, Object o, boolean unwrap) {
+
+ try {
+
+ BytesMessage message = session.createBytesMessage();
+
+
+ if (o instanceof Node) {
+ if (unwrap) {
+ Node firstElement = ((Node)o).getFirstChild();
+ if (firstElement == null ) {
+ //do nothing, the message will just be set with a byte[0]
+ } else {
+ message.writeBytes(domHelper.saveAsString(firstElement).getBytes());
+ }
+
+ } else {
+ message.writeBytes(domHelper.saveAsString((Node)o).getBytes());
+ }
+
+ } else if ((o instanceof Object[]) && ((Object[]) o)[0] instanceof Node) {
+ if (unwrap){
+ Node firstElement = ((Node)((Object[]) o)[0]).getFirstChild();
+ if (firstElement == null ) {
+ //do nothing, the message will just be set with a byte[0]
+ } else {
+ message.writeBytes(domHelper.saveAsString(firstElement).getBytes());
+ }
+
+ }else {
+ message.writeBytes(domHelper.saveAsString((Node)((Object[]) o)[0]).getBytes());
+ }
+ } else if (o != null) {
+ throw new IllegalStateException("expecting Node payload: " + o);
+ }
+
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message createFaultJMSBytesMessage(Session session, Throwable o) {
+
+ if (session == null) {
+ logger.fine("no response session to create fault message: " + String.valueOf(o));
+ return null;
+ }
+
+ if (o instanceof FaultException) {
+ try {
+
+ BytesMessage message = session.createBytesMessage();
+ String s = domHelper.saveAsString((Node)((FaultException)o).getFaultInfo());
+ message.writeBytes(s.getBytes());
+ message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true);
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ return super.createFaultMessage(session, o);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java
new file mode 100644
index 0000000000..15bd8713f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.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.sca.binding.jms.provider;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.host.DefaultJMSHostExtensionPoint;
+import org.apache.tuscany.sca.binding.jms.host.JMSHostExtensionPoint;
+import org.apache.tuscany.sca.binding.jms.host.JMSServiceListenerFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * A factory from creating the JMS binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingProviderFactory implements BindingProviderFactory<JMSBinding> {
+
+ private ExtensionPointRegistry extensionPoints;
+ private JMSResourceFactoryExtensionPoint jmsRFEP;
+ private JMSServiceListenerFactory serviceListenerFactory;
+
+ public JMSBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+
+ jmsRFEP = (JMSResourceFactoryExtensionPoint)extensionPoints.getExtensionPoint(JMSResourceFactoryExtensionPoint.class);
+ if (jmsRFEP == null) {
+ jmsRFEP = new DefaultJMSResourceFactoryExtensionPoint();
+ extensionPoints.addExtensionPoint(jmsRFEP);
+ }
+
+ JMSHostExtensionPoint jmsHostExtensionPoint = (JMSHostExtensionPoint)extensionPoints.getExtensionPoint(JMSHostExtensionPoint.class);
+ if (jmsHostExtensionPoint == null) {
+ jmsHostExtensionPoint = new DefaultJMSHostExtensionPoint(extensionPoints);
+ extensionPoints.addExtensionPoint(jmsHostExtensionPoint);
+ }
+ serviceListenerFactory = jmsHostExtensionPoint.getJMSServiceListenerFactory();
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)endpointReference.getBinding());
+ return new JMSBindingReferenceBindingProvider(endpointReference, extensionPoints, jmsRF);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ JMSBinding binding = (JMSBinding)endpoint.getBinding();
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory(binding);
+ return new JMSBindingServiceBindingProvider(extensionPoints, endpoint, serviceListenerFactory, extensionPoints, jmsRF);
+ }
+
+ public Class<JMSBinding> getModelType() {
+ return JMSBinding.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java
new file mode 100644
index 0000000000..8053ba69e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import javax.jms.JMSException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.headers.HeaderReferenceInterceptor;
+import org.apache.tuscany.sca.binding.jms.transport.TransportReferenceInterceptor;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Implementation of the JMS reference binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingReferenceBindingProvider implements EndpointReferenceProvider {
+
+ private RuntimeEndpointReference endpointReference;
+ private RuntimeComponentReference reference;
+ private JMSBinding jmsBinding;
+ private JMSResourceFactory jmsResourceFactory;
+ private RuntimeComponent component;
+ private InterfaceContract interfaceContract;
+ private ExtensionPointRegistry extensions;
+
+ private ProviderFactoryExtensionPoint providerFactories;
+
+ private WireFormatProviderFactory requestWireFormatProviderFactory;
+ private WireFormatProvider requestWireFormatProvider;
+
+ private WireFormatProviderFactory responseWireFormatProviderFactory;
+ private WireFormatProvider responseWireFormatProvider;
+
+ public JMSBindingReferenceBindingProvider(RuntimeEndpointReference endpointReference, ExtensionPointRegistry extensions, JMSResourceFactory jmsResourceFactory) {
+ this.endpointReference = endpointReference;
+ this.reference = (RuntimeComponentReference) endpointReference.getReference();
+ this.jmsBinding = (JMSBinding) endpointReference.getBinding();
+ this.extensions = extensions;
+ this.component = (RuntimeComponent) endpointReference.getComponent();
+ this.jmsResourceFactory = jmsResourceFactory;
+
+ // Get the factories/providers for operation selection
+ this.providerFactories = extensions.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+ // Get the factories/providers for wire format
+ this.requestWireFormatProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass());
+ if (this.requestWireFormatProviderFactory != null){
+ this.requestWireFormatProvider = requestWireFormatProviderFactory.createReferenceWireFormatProvider(endpointReference);
+ }
+
+ this.responseWireFormatProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass());
+ if (this.responseWireFormatProviderFactory != null){
+ this.responseWireFormatProvider = responseWireFormatProviderFactory.createReferenceWireFormatProvider(endpointReference);
+ }
+
+ // create an interface contract that reflects both request and response
+ // wire formats
+ try {
+ interfaceContract = (InterfaceContract)reference.getInterfaceContract().clone();
+
+ requestWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract);
+ responseWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract);
+ } catch (CloneNotSupportedException ex){
+ interfaceContract = reference.getInterfaceContract();
+ }
+ }
+
+ public Invoker createInvoker(Operation operation) {
+
+ if (jmsBinding.getDestinationName() == null) {
+// if (!reference.isCallback()) { // TODO: 2.x migration, is this check needed?
+ throw new JMSBindingException("No destination specified for reference " + reference.getName());
+// }
+ }
+
+ Invoker invoker = null;
+ invoker = new RRBJMSBindingInvoker(operation, jmsResourceFactory, endpointReference);
+
+ return invoker;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public void start() {
+
+ }
+
+ public void stop() {
+ try {
+ jmsResourceFactory.closeConnection();
+ jmsResourceFactory.closeResponseConnection();
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ /*
+ * set up the reference binding wire with the right set of jms reference
+ * interceptors
+ */
+ public void configure() {
+
+ InvocationChain bindingChain = endpointReference.getBindingInvocationChain();
+
+ // add transport interceptor
+ bindingChain.addInterceptor(Phase.REFERENCE_BINDING_TRANSPORT,
+ new TransportReferenceInterceptor(jmsBinding,
+ jmsResourceFactory,
+ endpointReference) );
+
+ // add request wire format
+ bindingChain.addInterceptor(requestWireFormatProvider.getPhase(),
+ requestWireFormatProvider.createInterceptor());
+
+ // add response wire format, but only add it if it's different from the request
+ if (!jmsBinding.getRequestWireFormat().equals(jmsBinding.getResponseWireFormat())){
+ bindingChain.addInterceptor(responseWireFormatProvider.getPhase(),
+ responseWireFormatProvider.createInterceptor());
+ }
+
+ // add the header processor that comes after the wire formatter but before the
+ // policy interceptors
+ bindingChain.addInterceptor(Phase.REFERENCE_BINDING_WIREFORMAT,
+ new HeaderReferenceInterceptor(extensions,
+ jmsBinding,
+ jmsResourceFactory,
+ endpointReference) );
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
new file mode 100644
index 0000000000..8428a45c6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.headers.HeaderServiceInterceptor;
+import org.apache.tuscany.sca.binding.jms.host.JMSServiceListener;
+import org.apache.tuscany.sca.binding.jms.host.JMSServiceListenerDetails;
+import org.apache.tuscany.sca.binding.jms.host.JMSServiceListenerFactory;
+import org.apache.tuscany.sca.binding.jms.transport.TransportServiceInterceptor;
+import org.apache.tuscany.sca.binding.jms.wire.CallbackDestinationInterceptor;
+import org.apache.tuscany.sca.binding.jms.wire.OperationPropertiesInterceptor;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.EndpointProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Implementation of the JMS service binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingServiceBindingProvider implements EndpointProvider, JMSServiceListenerDetails {
+ private static final Logger logger = Logger.getLogger(JMSBindingServiceBindingProvider.class.getName());
+
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpoint endpoint;
+ private RuntimeComponentService service;
+ private Binding targetBinding;
+ private JMSBinding jmsBinding;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSServiceListenerFactory serviceListenerFactory;
+ private JMSServiceListener serviceListener;
+
+ private RuntimeComponent component;
+ private InterfaceContract interfaceContract;
+
+ private ProviderFactoryExtensionPoint providerFactories;
+ private FactoryExtensionPoint modelFactories;
+
+ private MessageFactory messageFactory;
+
+ private OperationSelectorProviderFactory operationSelectorProviderFactory;
+ private OperationSelectorProvider operationSelectorProvider;
+
+ private WireFormatProviderFactory requestWireFormatProviderFactory;
+ private WireFormatProvider requestWireFormatProvider;
+
+ private WireFormatProviderFactory responseWireFormatProviderFactory;
+ private WireFormatProvider responseWireFormatProvider;
+
+ public JMSBindingServiceBindingProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint, JMSServiceListenerFactory serviceListenerFactory, ExtensionPointRegistry extensionPoints, JMSResourceFactory jmsResourceFactory) {
+ this.endpoint = endpoint;
+ this.component = (RuntimeComponent) endpoint.getComponent();
+ this.service = (RuntimeComponentService) endpoint.getService();
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.serviceListenerFactory = serviceListenerFactory;
+ this.targetBinding = jmsBinding;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.registry = registry;
+
+ if (jmsBinding.getResponseActivationSpecName() != null && jmsBinding.getResponseActivationSpecName().length() > 0) {
+ throw new JMSBindingException("[BJM30023] response/activationSpec element MUST NOT be present when the binding is being used for an SCA service");
+ }
+
+ // Set the default destination when using a connection factory.
+ // If an activation spec is being used, do not set the destination
+ // because the activation spec provides the destination.
+ if (jmsBinding.getDestinationName() == null &&
+ (jmsBinding.getActivationSpecName() == null || jmsBinding.getActivationSpecName().equals(""))) {
+// if (!service.isCallback()) { // TODO: 2.x migration, is this check needed?
+ // use the SCA service name as the default destination name
+ jmsBinding.setDestinationName(service.getName());
+// }
+ }
+
+ // Get Message factory
+ modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ messageFactory = modelFactories.getFactory(MessageFactory.class);
+
+ // Get the factories/providers for operation selection
+ this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ this.operationSelectorProviderFactory =
+ (OperationSelectorProviderFactory)providerFactories.getProviderFactory(jmsBinding.getOperationSelector().getClass());
+ if (this.operationSelectorProviderFactory != null){
+ this.operationSelectorProvider = operationSelectorProviderFactory.createServiceOperationSelectorProvider(endpoint);
+ }
+
+ // Get the factories/providers for wire format
+ this.requestWireFormatProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass());
+ if (this.requestWireFormatProviderFactory != null){
+ this.requestWireFormatProvider = requestWireFormatProviderFactory.createServiceWireFormatProvider(endpoint);
+ }
+
+ this.responseWireFormatProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass());
+ if (this.responseWireFormatProviderFactory != null){
+ this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(endpoint);
+ }
+
+ // create an interface contract that reflects both request and response
+ // wire formats
+ try {
+ interfaceContract = (InterfaceContract)service.getInterfaceContract().clone();
+
+ requestWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract);
+ responseWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract);
+ } catch (CloneNotSupportedException ex){
+ interfaceContract = service.getInterfaceContract();
+ }
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return interfaceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ public void start() {
+ try {
+
+ this.serviceListener = serviceListenerFactory.createJMSServiceListener(this);
+ serviceListener.start();
+
+ } catch (Exception e) {
+ if (e instanceof JMSBindingException) throw (JMSBindingException)e;
+ throw new JMSBindingException("Error starting JMSServiceBinding", e);
+ }
+ }
+
+ public void stop() {
+ try {
+ serviceListener.stop();
+ } catch (Exception e) {
+ if (e instanceof JMSBindingException) throw (JMSBindingException)e;
+ throw new JMSBindingException("Error stopping JMSServiceBinding", e);
+ }
+ }
+
+ public String getDestinationName() {
+ return serviceListener.getDestinationName();
+ }
+
+ /*
+ * Adds JMS specific interceptors to the binding chain
+ */
+ public void configure() {
+
+ InvocationChain bindingChain = endpoint.getBindingInvocationChain();
+
+ // add transport interceptor
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_TRANSPORT,
+ new TransportServiceInterceptor(registry, jmsBinding,
+ jmsResourceFactory,
+ endpoint) );
+
+ // add operation selector interceptor
+ bindingChain.addInterceptor(operationSelectorProvider.getPhase(),
+ operationSelectorProvider.createInterceptor());
+
+ // add operationProperties interceptor after operation selector
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR,
+ new OperationPropertiesInterceptor(jmsBinding, endpoint));
+
+ // add callback destination interceptor after operation selector
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT,
+ new CallbackDestinationInterceptor(endpoint));
+
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, new HeaderServiceInterceptor(jmsBinding));
+
+ // add request wire format
+ bindingChain.addInterceptor(requestWireFormatProvider.getPhase(),
+ requestWireFormatProvider.createInterceptor());
+
+ // add response wire format, but only add it if it's different from the request
+ if (!jmsBinding.getRequestWireFormat().equals(jmsBinding.getResponseWireFormat())){
+ bindingChain.addInterceptor(responseWireFormatProvider.getPhase(),
+ responseWireFormatProvider.createInterceptor());
+ }
+
+ }
+
+ public RuntimeComponent getComponent() {
+ return component;
+ }
+
+ public RuntimeComponentService getService() {
+ return service;
+ }
+
+ public Binding getTargetBinding() {
+ return targetBinding;
+ }
+
+ public JMSBinding getJmsBinding() {
+ return jmsBinding;
+ }
+
+ public MessageFactory getMessageFactory() {
+ return messageFactory;
+ }
+
+ public JMSResourceFactory getResourceFactory() {
+ return jmsResourceFactory;
+ }
+
+ public RuntimeEndpoint getEndpoint() {
+ return endpoint;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java
new file mode 100644
index 0000000000..821b9d7873
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import javax.jms.Message;
+import javax.jms.Session;
+
+/**
+ * Interface for a component that does operation selection and message payload processing
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JMSMessageProcessor {
+
+ /**
+ * Get the operation name from a JMS Message
+ */
+ String getOperationName(Message message);
+
+ /**
+ * Set the operation name on a JMS Message
+ */
+ void setOperationName(String operationName, Message message);
+
+ /**
+ * Extracts the payload from a JMS Message
+ */
+ Object extractPayloadFromJMSMessage(Message msg);
+
+ /**
+ * Create a JMS Message containing the payload
+ */
+ Message insertPayloadIntoJMSMessage(Session session, Object payload);
+
+ /**
+ * Create a JMS Message for reporting an exception
+ */
+ Message createFaultMessage(Session session, Throwable responsePayload);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
new file mode 100644
index 0000000000..b7622c942e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * Utility methods to load JMS message processors.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSMessageProcessorUtil {
+
+ /**
+ * Used to create instances of the JMSResourceFactory and RequestMessageProcessor and ResponseMessageProcessor from
+ * string based class name provided in the configuration
+ *
+ * @param cl ClassLoader
+ * @param className the string based class name to load and instantiate
+ * @return the new object
+ */
+ private static Object instantiate(ClassLoader cl, String className, JMSBinding binding) {
+ Object instance;
+ if (cl == null) {
+ cl = binding.getClass().getClassLoader();
+ }
+
+ try {
+ Class<?> clazz;
+
+ try {
+ clazz = cl.loadClass(className);
+ } catch (ClassNotFoundException e) {
+ clazz = binding.getClass().getClassLoader().loadClass(className);
+ }
+
+ Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[] {JMSBinding.class});
+ instance = constructor.newInstance(binding);
+
+ } catch (Throwable e) {
+ throw new JMSBindingException("Exception instantiating OperationAndDataBinding class", e);
+ }
+
+ return instance;
+ }
+
+// public static JMSMessageProcessor getRequestMessageProcessor(JMSBinding binding) {
+// return (JMSMessageProcessor)instantiate(null, binding.getRequestMessageProcessorName(), binding);
+// }
+//
+// public static JMSMessageProcessor getResponseMessageProcessor(JMSBinding binding) {
+// return (JMSMessageProcessor)instantiate(null, binding.getResponseMessageProcessorName(), binding);
+// }
+//
+ private static Object instantiate(ClassLoader cl, String className, JMSBinding binding, ExtensionPointRegistry registry) {
+ Object instance;
+ if (cl == null) {
+ cl = binding.getClass().getClassLoader();
+ }
+
+ try {
+ Class<?> clazz;
+
+ try {
+ clazz = cl.loadClass(className);
+ } catch (ClassNotFoundException e) {
+ clazz = binding.getClass().getClassLoader().loadClass(className);
+ }
+
+ Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[] {JMSBinding.class, ExtensionPointRegistry.class});
+ instance = constructor.newInstance(binding, registry);
+
+ } catch (Throwable e) {
+ throw new JMSBindingException("Exception instantiating OperationAndDataBinding class", e);
+ }
+
+ return instance;
+ }
+
+ public static JMSMessageProcessor getRequestMessageProcessor(ExtensionPointRegistry registry, JMSBinding binding) {
+ return (JMSMessageProcessor)instantiate(null, binding.getRequestMessageProcessorName(), binding, registry);
+ }
+
+ public static JMSMessageProcessor getResponseMessageProcessor(ExtensionPointRegistry registry, JMSBinding binding) {
+ return (JMSMessageProcessor)instantiate(null, binding.getResponseMessageProcessorName(), binding, registry);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java
new file mode 100644
index 0000000000..cd53857ed8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+public interface JMSResourceFactory {
+
+ /*
+ * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
+ * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
+ * an AppServer Then we could leverage the JMS resources it provides
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection()
+ */
+ public abstract Connection getConnection() throws NamingException, JMSException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#createSession()
+ */
+ public abstract Session createSession() throws JMSException, NamingException;
+
+ public abstract void closeSession(Session session) throws JMSException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#startConnection()
+ */
+ public abstract void startConnection() throws JMSException, NamingException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#closeConnection()
+ */
+ public abstract void closeConnection() throws JMSException;
+
+ public abstract Destination lookupDestination(String destName) throws NamingException;
+
+ /**
+ * You can create a destination in ActiveMQ (and have it appear in JNDI) by putting "dynamicQueues/" in front of the queue name being looked up
+ */
+ public abstract Destination createDestination(String jndiName) throws NamingException;
+
+ /*
+ * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
+ * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
+ * an AppServer Then we could leverage the JMS resources it provides
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection()
+ */
+ public abstract Connection getResponseConnection() throws NamingException, JMSException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.jms.JMSResourceFactory#createSession()
+ */
+ public abstract Session createResponseSession() throws JMSException, NamingException;
+
+ public abstract void closeResponseSession(Session session) throws JMSException;
+
+ public abstract void closeResponseConnection() throws JMSException;
+
+ /*
+ * Indicates whether connections obtained using getConnection() or getResponseConnection()
+ * must be closed after each use. This is necessary in environments where connections are
+ * shared with other users, or where connections cannot be held across transaction boundaries.
+ */
+ public abstract boolean isConnectionClosedAfterUse();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java
new file mode 100644
index 0000000000..afd2508043
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.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 org.apache.tuscany.sca.binding.jms.provider;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+
+public interface JMSResourceFactoryExtensionPoint {
+
+ JMSResourceFactory createJMSResourceFactory(JMSBinding binding);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java
new file mode 100644
index 0000000000..61080516b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+
+/**
+ * Abstracts away any JMS provide specific feature from the JMS binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSResourceFactoryImpl implements JMSResourceFactory {
+
+ protected String initialContextFactoryName;
+ protected String connectionFactoryName = "ConnectionFactory";
+ protected String jndiURL;
+
+ protected Connection connection;
+ protected Context context;
+ protected boolean isConnectionStarted;
+ private Connection responseConnection;
+ private String responseConnectionFactoryName;
+
+ public JMSResourceFactoryImpl(String connectionFactoryName, String responseConnectionFactoryName, String initialContextFactoryName, String jndiURL) {
+ if (connectionFactoryName != null && connectionFactoryName.trim().length() > 0) {
+ this.connectionFactoryName = connectionFactoryName.trim();
+ }
+ if (responseConnectionFactoryName != null && responseConnectionFactoryName.trim().length() > 0) {
+ this.responseConnectionFactoryName = responseConnectionFactoryName.trim();
+ }
+ if (initialContextFactoryName != null && initialContextFactoryName.trim().length() > 0) {
+ this.initialContextFactoryName = initialContextFactoryName.trim();
+ }
+ if (jndiURL != null) {
+ this.jndiURL = jndiURL.trim();
+ }
+ }
+
+ /*
+ * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
+ * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
+ * an AppServer Then we could leverage the JMS resources it provides
+ *
+ * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#getConnection()
+ */
+ public Connection getConnection() throws NamingException, JMSException {
+ if (connection == null) {
+ createConnection();
+ }
+ return connection;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#createSession()
+ */
+ public Session createSession() throws JMSException, NamingException {
+ return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#closeSession(javax.jms.Session)
+ */
+ public void closeSession(Session session) throws JMSException {
+ session.close();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#startConnection()
+ */
+ public void startConnection() throws JMSException, NamingException {
+ if (!isConnectionStarted) {
+ getConnection().start();
+ isConnectionStarted = true;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#closeConnection()
+ */
+ public void closeConnection() throws JMSException {
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (JMSException e) {
+ // if using an embedded broker then when shutting down Tuscany the broker may get closed
+ // before this stop method is called. I can't see how to detect that so for now just
+ // ignore the exception if the message is that the transport is already disposed
+ if (!e.getMessage().contains("disposed")) {
+ throw e;
+ }
+ }
+ }
+ }
+
+ protected void createConnection() throws NamingException, JMSException {
+ ConnectionFactory connectionFactory = (ConnectionFactory)jndiLookUp(connectionFactoryName);
+ if (connectionFactory == null) {
+ throw new JMSBindingException("connection factory not found: " + connectionFactoryName);
+ }
+ connection = connectionFactory.createConnection();
+ }
+
+ protected synchronized Context getInitialContext() throws NamingException {
+ if (context == null) {
+ Properties props = new Properties();
+
+ if (initialContextFactoryName != null) {
+ props.setProperty(Context.INITIAL_CONTEXT_FACTORY, initialContextFactoryName);
+ }
+ if (jndiURL != null) {
+ props.setProperty(Context.PROVIDER_URL, jndiURL);
+ }
+
+ initJREEnvironment(props);
+
+ context = new InitialContext(props);
+ }
+ return context;
+ }
+
+ /**
+ * If using the WAS JMS Client with a non-IBM JRE then an additional
+ * environment property needs to be set to initialize the ORB correctly.
+ * See: http://www-1.ibm.com/support/docview.wss?uid=swg24012804
+ */
+ protected void initJREEnvironment(Properties props) {
+ if ("com.ibm.websphere.naming.WsnInitialContextFactory".equals(props.get(Context.INITIAL_CONTEXT_FACTORY))) {
+ String vendor = System.getProperty("java.vendor");
+ if (vendor == null || !vendor.contains("IBM")) {
+ props.setProperty("com.ibm.CORBA.ORBInit", "com.ibm.ws.sib.client.ORB");
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#lookupDestination(java.lang.String)
+ */
+ public Destination lookupDestination(String destName) throws NamingException {
+ if (destName == null) {
+ return null;
+ }
+
+ Destination dest = (Destination)jndiLookUp(destName);
+ if (dest == null) {
+ dest = lookupPhysical(destName);
+ }
+ return dest;
+ }
+
+ protected Destination lookupPhysical(String jndiName) {
+
+ // TODO: the SCA JMS spec says a destination name may be a non-jndi plain destination name
+
+// Session session = null;
+// try {
+//
+// Destination dest;
+// session = createSession();
+// dest = session.createQueue(jndiName);
+// return dest;
+//
+// } catch (JMSException e) {
+// throw new JMSBindingException(e);
+// } catch (NamingException e) {
+// throw new JMSBindingException(e);
+// } finally {
+// if (session != null) {
+// try {
+// session.close();
+// } catch (JMSException e) {
+// throw new JMSBindingException(e);
+// }
+// }
+// }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#createDestination(java.lang.String)
+ */
+ public Destination createDestination(String jndiName) throws NamingException {
+ return lookupDestination("dynamicQueues/" + jndiName);
+ }
+
+ protected Object jndiLookUp(String name) {
+ Object o = null;
+ try {
+ o = getInitialContext().lookup("java:comp/env/" + name);
+ } catch (Exception ex) {
+ // ignore
+ }
+ if (o == null) {
+ try {
+ o = getInitialContext().lookup(name);
+ } catch (NamingException ex) {
+ // ignore
+ }
+ }
+ return o;
+ }
+
+ public Session createResponseSession() throws JMSException, NamingException {
+ return getResponseConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+
+ public void closeResponseSession(Session session) throws JMSException {
+ session.close();
+ }
+
+ public Connection getResponseConnection() throws NamingException, JMSException {
+ if (responseConnection == null) {
+ if (responseConnectionFactoryName != null) {
+ ConnectionFactory connectionFactory = (ConnectionFactory)jndiLookUp(responseConnectionFactoryName);
+ if (connectionFactory == null) {
+ throw new JMSBindingException("connection factory not found: " + responseConnectionFactoryName);
+ }
+ responseConnection = connectionFactory.createConnection();
+ } else {
+ // if no response connection is defined in the SCDL use the request connection
+ responseConnection = getConnection();
+ }
+ }
+ return responseConnection;
+ }
+
+ public void closeResponseConnection() throws JMSException {
+ if (responseConnection != null && !responseConnection.equals(connection)) {
+ try {
+ responseConnection.close();
+ } catch (JMSException e) {
+ // if using an embedded broker then when shutting down Tuscany the broker may get closed
+ // before this stop method is called. I can't see how to detect that so for now just
+ // ignore the exception if the message is that the transport is already disposed
+ if (!e.getMessage().contains("disposed")) {
+ throw e;
+ }
+ }
+ }
+ }
+
+ public boolean isConnectionClosedAfterUse() {
+ // It is assumed this resource factory is used in an environment
+ // where the connection can be held for the life of the binding.
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java
new file mode 100644
index 0000000000..db0b94dce1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * MessageProcessor for sending/receiving Serializable objects with the JMSBinding.
+ *
+ */
+public class ObjectMessageProcessor extends AbstractMessageProcessor {
+ private static final Logger logger = Logger.getLogger(ObjectMessageProcessor.class.getName());
+
+ public ObjectMessageProcessor(JMSBinding jmsBinding, ExtensionPointRegistry registry) {
+ super(jmsBinding);
+ }
+
+ @Override
+ protected Message createJMSMessage(Session session, Object o) {
+ if (session == null) {
+ logger.fine("no response session to create message: " + String.valueOf(o));
+ return null;
+ }
+ try {
+
+ ObjectMessage message = session.createObjectMessage();
+
+ if (o != null){
+ if (!(o instanceof Serializable)) {
+ throw new IllegalStateException("JMS ObjectMessage payload not Serializable: " + o);
+ }
+
+ message.setObject((Serializable)o);
+ }
+
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ @Override
+ public Object extractPayloadFromJMSMessage(Message msg) {
+ try {
+ Object o = ((ObjectMessage)msg).getObject();
+ if (o instanceof Throwable ) {
+ if (o instanceof RuntimeException) {
+ throw new ServiceRuntimeException("remote service exception, see nested exception", (RuntimeException)o);
+ } else {
+ return new InvocationTargetException((Throwable) o);
+ }
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ return extractPayload(msg);
+ }
+
+ @Override
+ protected Object extractPayload(Message msg) {
+ try {
+
+ return ((ObjectMessage)msg).getObject();
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ // special methods for handling operations with single parameters
+
+ public Message createJMSMessageForSingleParamOperation(Session session, Object o, boolean wrapSingleInput) {
+ if (session == null) {
+ logger.fine("no response session to create message: " + String.valueOf(o));
+ return null;
+ }
+ try {
+
+ ObjectMessage message = session.createObjectMessage();
+
+ if (o != null) {
+ if (!(o instanceof Serializable)) {
+ throw new IllegalStateException("JMS ObjectMessage payload not Serializable: " + o);
+ }
+
+ // If the user has specifically requests that single parameters
+ // be wrapped then leave is as is as it will have already been
+ // wrapped by Tuscany. Otherwise unwrap it.
+ if (wrapSingleInput) {
+ message.setObject((Serializable) o);
+ } else { // unwrap from array
+ message.setObject((Serializable) ((Object[]) o)[0]);
+ }
+
+ }
+
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Object extractPayloadFromJMSMessageForSingleParamOperation(Message msg, Class<?> argType, boolean wrapSingle) {
+ // We always have a one arg operation if this method is called so we need to
+ // decide if the data on the wire is wrapped or not. This is the algorithm.
+ //
+ // If the payload is null then create an empty array and pass it on
+ // If the payload is not an array then it must represent an unwrapped
+ // single arg. Wrap it up and pass it on
+ // If the payload is an array then determine if it's a wrapped single arg or not
+ // If the service interface arg type matches the type of the array and not it's contents
+ // then it's an unwrapped argument so wrap it and pass it on
+ // If the service interface arg type matches the type of the contents and not the type
+ // of the array then the parameter is already wrapped so pass it on as is
+ // If the service interface arg type matches both the type of the
+ // array and the type of its contents then assume that the whole array is the
+ // parameter and decide whether to unwrap it or pass it on as is based on the
+ // setting of the wrapSingle attribute
+ //
+
+ try {
+ Object payload = ((ObjectMessage) msg).getObject();
+
+ if (payload instanceof Throwable) {
+ if (payload instanceof RuntimeException) {
+ throw new ServiceRuntimeException("remote service exception, see nested exception", (RuntimeException) payload);
+ } else {
+ return new InvocationTargetException((Throwable) payload);
+ }
+ }
+
+ if (payload == null) {
+ // methodA(null) was not wrapped on wire so wrap it here in order
+ // that it passes through the rest of the Tuscany wire successfully
+ return new Object[] { payload };
+ }
+
+ boolean payloadIsArray = payload.getClass().isArray();
+
+ // Non-array payload is single arg
+ if (!payloadIsArray) {
+ // methodB(arg) wasn't wrapped on wire so wrap it here in order
+ // that it passes through the rest of the Tuscany wire successfully
+ return new Object[] { payload };
+ } else {
+ int size = ((Object[]) payload).length;
+
+ // An initial quick check to determine whether the payload is not
+ // wrapped. If the array has anything other than a single entry
+ // then it's not the result of reference side wrapping so wrap it
+ // here and pass it on
+ if (size != 1) {
+ return new Object[] { payload };
+ }
+
+ // we know the array has only one entry now so get it
+ Object arrayContents = ((Object[]) payload)[0];
+
+ // Is the operation argument the same type as the array itself?
+ if (argType.isAssignableFrom(payload.getClass())) {
+
+ // So we believe that the whole array is the argument but need
+ // to check what is in the array to be sure
+ if (arrayContents == null) {
+ // There is nothing in the array so it could be an accident that
+ // the array type matches the argument type, e.g. op(Object)
+ // so rely on the wrapSingle setting to choose
+ if (wrapSingle) {
+ return payload;
+ } else {
+ return new Object[] { payload };
+ }
+ } else if (argType.isAssignableFrom(arrayContents.getClass())) {
+ // We can't tell as the argument type matches both the array type and
+ // the array contents type so use the wrapSingle setting to choose
+ if (wrapSingle) {
+ return payload;
+ } else {
+ return new Object[] { payload };
+ }
+ } else {
+ // So by now we know the whole array is intended to be the
+ // parameter to wrap it and send it on
+ return new Object[] { payload };
+ }
+
+ } else {
+ // The array type doesn't match the argument type so assume that the
+ // array contents will match the argument type and that hence the
+ // parameter is already wrapped so just send it as is. If the contents
+ // type doesn't match the argument type a exception will be thrown further
+ // along the wire
+ return payload;
+ }
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java
new file mode 100644
index 0000000000..b578d7e2a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Invoker for the JMS binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RRBJMSBindingInvoker implements Invoker {
+
+ protected Operation operation;
+ protected String operationName;
+
+ protected JMSBinding jmsBinding;
+ protected JMSResourceFactory jmsResourceFactory;
+ protected Destination bindingRequestDest;
+ protected Destination bindingReplyDest;
+ protected RuntimeEndpointReference endpointReference;
+
+ public RRBJMSBindingInvoker(Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference epr) {
+
+ this.operation = operation;
+ operationName = operation.getName();
+
+ this.endpointReference = epr;
+ this.jmsBinding = (JMSBinding) epr.getBinding();
+ this.jmsResourceFactory = jmsResourceFactory;
+
+ try {
+ // If this is a callback reference, the destination is determined dynamically based on
+ // properties of the inbound service request. We should not look for or require a
+ // statically-configured destination unless a message is received that does not have
+ // the necessary properties.
+// if (!reference.isCallback()) { // TODO: 2.x migration, is this check needed?
+ bindingRequestDest = lookupDestination();
+// }
+ bindingReplyDest = lookupResponseDestination();
+ } catch (NamingException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ /**
+ * Looks up the Destination Queue for the JMS Binding
+ *
+ * @return The Destination Queue
+ * @throws NamingException Failed to lookup Destination Queue
+ * @throws JMSBindingException Failed to lookup Destination Queue
+ * @see #lookupDestinationQueue(boolean)
+ */
+ protected Destination lookupDestination() throws NamingException, JMSBindingException {
+ return lookupDestinationQueue(false);
+ }
+
+ /**
+ * Looks up the Destination Response Queue for the JMS Binding
+ *
+ * @return The Destination Response Queue
+ * @throws NamingException Failed to lookup Destination Response Queue
+ * @throws JMSBindingException Failed to lookup Destination Response Queue
+ * @see #lookupDestinationQueue(boolean)
+ */
+ protected Destination lookupResponseDestination() throws NamingException, JMSBindingException {
+ return lookupDestinationQueue(true);
+ }
+
+ /**
+ * Looks up the Destination Queue for the JMS Binding.
+ * <p>
+ * What happens in the look up will depend on the create mode specified for the JMS Binding:
+ * <ul>
+ * <li>always - the JMS queue is always created. It is an error if the queue already exists
+ * <li>ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists
+ * <li>never - the JMS queue is never created. It is an error if the queue does not exist
+ * </ul>
+ * See the SCA JMS Binding specification for more information.
+ * <p>
+ *
+ * @param isReponseQueue <code>true</code> if we are creating a response queue.
+ * <code>false</code> if we are creating a request queue
+ * @return The Destination queue.
+ * @throws NamingException Failed to lookup JMS queue
+ * @throws JMSBindingException Failed to lookup JMS Queue. Probable cause is that
+ * the JMS queue's current existence/non-existence is not compatible with
+ * the create mode specified on the binding
+ */
+ protected Destination lookupDestinationQueue(boolean isReponseQueue) throws NamingException, JMSBindingException {
+ String queueName;
+ String queueType;
+ String qCreateMode;
+
+ if (isReponseQueue) {
+ queueName = jmsBinding.getResponseDestinationName();
+ queueType = "JMS Response Destination ";
+ qCreateMode = jmsBinding.getResponseDestinationCreate();
+ if (queueName == null) {
+ return null;
+ }
+ } else {
+ queueName = jmsBinding.getDestinationName();
+ queueType = "JMS Destination ";
+ qCreateMode = jmsBinding.getDestinationCreate();
+ }
+
+ Destination dest = jmsResourceFactory.lookupDestination(queueName);
+
+ if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) {
+ // In this mode, the queue must not already exist as we are creating it
+ if (dest != null) {
+ throw new JMSBindingException(queueType + queueName
+ + " already exists but has create mode of \""
+ + qCreateMode
+ + "\" while registering binding "
+ + jmsBinding.getName()
+ + " invoker");
+ }
+ // Create the queue
+ dest = jmsResourceFactory.createDestination(queueName);
+
+ } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ // In this mode, the queue may nor may not exist. It will be created if it does not exist
+ // but don't create when using jms:jndi uri format
+ if (dest == null && !"jndi".equals(jmsBinding.getDestinationType())) {
+ dest = jmsResourceFactory.createDestination(queueName);
+ }
+
+ } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) {
+ // In this mode, the queue must have already been created.
+ if (dest == null) {
+ throw new JMSBindingException(queueType + queueName
+ + " not found but create mode of \""
+ + qCreateMode
+ + "\" while registering binding "
+ + jmsBinding.getName()
+ + " invoker");
+ }
+ }
+
+ // Make sure we ended up with a queue
+ if (dest == null) {
+ throw new JMSBindingException(queueType + queueName
+ + " not found with create mode of \""
+ + qCreateMode
+ + "\" while registering binding "
+ + jmsBinding.getName()
+ + " invoker");
+ }
+
+ return dest;
+ }
+
+ public org.apache.tuscany.sca.invocation.Message invoke(org.apache.tuscany.sca.invocation.Message tuscanyMsg) {
+ try {
+ // populate the message context with JMS binding information
+ JMSBindingContext context = new JMSBindingContext();
+ context.setJmsResourceFactory(jmsResourceFactory);
+ tuscanyMsg.setBindingContext(context);
+
+ // get a jms session to cover the creation and sending of the message
+ Session session = context.getJmsSession();
+
+ context.setRequestDestination(getRequestDestination(tuscanyMsg, session));
+ context.setReplyToDestination(getReplyToDestination(session));
+
+ try {
+ tuscanyMsg = endpointReference.getBindingInvocationChain().getHeadInvoker().invoke(tuscanyMsg);
+ } catch (ServiceRuntimeException e) {
+ if (e.getCause() instanceof InvocationTargetException) {
+ if ((e.getCause().getCause() instanceof RuntimeException)) {
+ tuscanyMsg.setFaultBody(e.getCause());
+ } else {
+ tuscanyMsg.setFaultBody(((InvocationTargetException)e.getCause()).getTargetException());
+ }
+ } else if (e.getCause() instanceof FaultException) {
+ tuscanyMsg.setFaultBody(e.getCause());
+ } else {
+ tuscanyMsg.setFaultBody(e);
+ }
+ } catch (IllegalStateException e) {
+ tuscanyMsg.setFaultBody(e);
+ } catch (Throwable e) {
+ tuscanyMsg.setFaultBody(e);
+ } finally {
+ context.closeJmsSession();
+ if (jmsResourceFactory.isConnectionClosedAfterUse()) {
+ jmsResourceFactory.closeConnection();
+ }
+ }
+
+ return tuscanyMsg;
+ } catch (Exception e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ protected Destination getRequestDestination(org.apache.tuscany.sca.invocation.Message tuscanyMsg, Session session) throws JMSBindingException, NamingException, JMSException {
+ Destination requestDestination;
+// if (!reference.isCallback()) { // TODO: 2.x migration, is this check needed?
+// String toURI = tuscanyMsg.getTo().getURI();
+// if (toURI != null && toURI.startsWith("jms:")) {
+// // the msg to uri contains the callback destination name
+// // this is an jms physical name not a jndi name so need to use session.createQueue
+// requestDestination = session.createQueue(toURI.substring(4));
+// } else {
+// requestDestination = lookupDestination();
+// }
+// } else {
+ requestDestination = bindingRequestDest;
+// }
+
+ return requestDestination;
+ }
+
+ protected Destination getReplyToDestination(Session session) throws JMSException, JMSBindingException, NamingException {
+ Destination replyToDest;
+ if (operation.isNonBlocking()) {
+ replyToDest = null;
+ } else {
+ if (bindingReplyDest != null) {
+ replyToDest = bindingReplyDest;
+ } else {
+ replyToDest = session.createTemporaryQueue();
+ }
+ }
+ return replyToDest;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java
new file mode 100644
index 0000000000..b468c73e7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.util.logging.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * MessageProcessor for sending/receiving javax.jms.TextMessage with the JMSBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TextMessageProcessor extends AbstractMessageProcessor {
+ private static final Logger logger = Logger.getLogger(TextMessageProcessor.class.getName());
+
+ public TextMessageProcessor(JMSBinding jmsBinding, ExtensionPointRegistry registry) {
+ super(jmsBinding);
+ }
+
+ @Override
+ protected Object extractPayload(Message msg) {
+ try {
+
+ if (!(msg instanceof TextMessage)) {
+ throw new IllegalStateException("expecting JMS TextMessage: " + msg);
+ }
+
+ return ((TextMessage)msg).getText();
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ @Override
+ protected Message createJMSMessage(Session session, Object o) {
+ if (session == null) {
+ logger.fine("no response session to create message: " + String.valueOf(o));
+ return null;
+ }
+ try {
+
+ TextMessage message = session.createTextMessage();
+
+ if (o != null){
+ message.setText(String.valueOf(o));
+ }
+
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java
new file mode 100644
index 0000000000..69a69064d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.provider;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * MessageProcessor for sending/receiving XML javax.jms.BytesMessage with the JMSBinding.
+ */
+public class XMLBytesMessageProcessor extends AbstractMessageProcessor {
+ private static final Logger logger = Logger.getLogger(XMLBytesMessageProcessor.class.getName());
+
+ private DOMHelper domHelper;
+
+ public XMLBytesMessageProcessor(JMSBinding jmsBinding, ExtensionPointRegistry registry) {
+ super(jmsBinding);
+ this.domHelper = DOMHelper.getInstance(registry);
+ }
+
+ @Override
+ protected Object extractPayload(Message msg) {
+ try {
+
+ if (!(msg instanceof BytesMessage)) {
+ throw new IllegalStateException("expecting JMS BytesMessage: " + msg);
+ }
+
+ long noOfBytes = ((BytesMessage)msg).getBodyLength();
+ byte [] bytes = new byte[(int)noOfBytes];
+ ((BytesMessage)msg).readBytes(bytes);
+ ((BytesMessage)msg).reset();
+
+ Object os;
+ if (noOfBytes > 0) {
+ os = domHelper.load(new String(bytes));
+ } else {
+ os = null;
+ }
+ return os;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ } catch (IOException e) {
+ throw new JMSBindingException(e);
+ } catch (SAXException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ @Override
+ public Object extractPayloadFromJMSMessage(Message msg) {
+ if (msg instanceof BytesMessage) {
+ return extractPayload(msg);
+ } else {
+ return super.extractPayloadFromJMSMessage(msg);
+ }
+ }
+
+ @Override
+ protected Message createJMSMessage(Session session, Object o) {
+ if (session == null) {
+ logger.fine("no response session to create message: " + String.valueOf(o));
+ return null;
+ }
+ try {
+ BytesMessage message = session.createBytesMessage();
+
+ if (o instanceof Node) {
+ message.writeBytes(domHelper.saveAsString((Node)o).getBytes());
+ } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof Node) {
+ message.writeBytes(domHelper.saveAsString((Node)((Object[])o)[0]).getBytes());
+ } else if (o != null) {
+ throw new IllegalStateException("expecting Node payload: " + o);
+ }
+
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ @Override
+ public Message createFaultMessage(Session session, Throwable o) {
+
+ if (session == null) {
+ logger.fine("no response session to create fault message: " + String.valueOf(o));
+ return null;
+ }
+ if (o instanceof FaultException) {
+ try {
+
+ BytesMessage message = session.createBytesMessage();
+ message.writeBytes(domHelper.saveAsString((Node)((FaultException)o).getFaultInfo()).getBytes());
+ message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true);
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ return super.createFaultMessage(session, o);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java
new file mode 100644
index 0000000000..5031f55c6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.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.sca.binding.jms.provider;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * MessageProcessor for sending/receiving XML javax.jms.TextMessage with the JMSBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLTextMessageProcessor extends AbstractMessageProcessor {
+ private static final Logger logger = Logger.getLogger(XMLTextMessageProcessor.class.getName());
+
+ private DOMHelper domHelper;
+
+ public XMLTextMessageProcessor(JMSBinding jmsBinding, ExtensionPointRegistry registry) {
+ super(jmsBinding);
+ this.domHelper = DOMHelper.getInstance(registry);
+ }
+
+ @Override
+ protected Object extractPayload(Message msg) {
+ try {
+
+ String xml = ((TextMessage)msg).getText();
+ Object os;
+ if (xml != null) {
+ os = domHelper.load(xml);
+ } else {
+ os = null;
+ }
+ return os;
+
+ } catch (IOException e) {
+ throw new JMSBindingException(e);
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ } catch (SAXException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ @Override
+ public Object extractPayloadFromJMSMessage(Message msg) {
+ if (msg instanceof TextMessage) {
+ return extractPayload(msg);
+ } else {
+ return super.extractPayloadFromJMSMessage(msg);
+ }
+ }
+
+ @Override
+ protected Message createJMSMessage(Session session, Object o) {
+ if (session == null) {
+ logger.fine("no response session to create message: " + String.valueOf(o));
+ return null;
+ }
+ try {
+
+ TextMessage message = session.createTextMessage();
+
+ if (o instanceof Element) {
+ message.setText(domHelper.saveAsString((Node)o));
+ } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof Node) {
+ message.setText(domHelper.saveAsString((Node)((Object[])o)[0]));
+ } else if (o != null) {
+ throw new IllegalStateException("expecting Node payload: " + o);
+ }
+
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ @Override
+ public Message createFaultMessage(Session session, Throwable o) {
+ if (session == null) {
+ logger.fine("no response session to create fault message: " + String.valueOf(o));
+ return null;
+ }
+ if (o instanceof FaultException) {
+ try {
+
+ TextMessage message = session.createTextMessage();
+ message.setText(domHelper.saveAsString((Node)((FaultException)o).getFaultInfo()));
+ message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true);
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ return super.createFaultMessage(session, o);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
new file mode 100644
index 0000000000..9668333ebd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.transport;
+
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpointReference runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+
+ public TransportReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ }
+
+ public Message invoke(Message msg) {
+ Message responseMsg = invokeRequest(msg);
+
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+
+ if (context.getReplyToDestination() == null) {
+ responseMsg.setBody(null);
+ } else {
+ responseMsg = invokeResponse(msg);
+ }
+
+ return responseMsg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsSession();
+
+ MessageProducer producer = session.createProducer(context.getRequestDestination());
+
+ // Set JMS header attributes in producer, not message.
+ String opName = msg.getOperation().getName();
+ if (jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName()) != null) {
+ producer.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName()));
+ }
+ Integer priority = jmsBinding.getOperationJMSPriority( opName );
+ if (priority != null) {
+ producer.setPriority(priority.intValue());
+ }
+ Boolean deliveryModePersistent = jmsBinding.getOperationJMSDeliveryMode(opName);
+ if (deliveryModePersistent != null) {
+ if (deliveryModePersistent.booleanValue())
+ producer.setDeliveryMode(javax.jms.DeliveryMode.PERSISTENT);
+ else
+ producer.setDeliveryMode(javax.jms.DeliveryMode.NON_PERSISTENT);
+ }
+
+ try {
+ producer.send((javax.jms.Message)msg.getBody());
+ } finally {
+ producer.close();
+ }
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message invokeResponse(Message msg) {
+ JMSBindingContext context = msg.getBindingContext();
+ try {
+ Session session = context.getJmsResponseSession();
+
+ javax.jms.Message requestMessage = (javax.jms.Message)msg.getBody();
+
+ String msgSelector = "JMSCorrelationID = '" +
+ requestMessage.getJMSMessageID() +
+ "'";
+ MessageConsumer consumer = session.createConsumer(context.getReplyToDestination(), msgSelector);
+
+ javax.jms.Message replyMsg;
+ try {
+ context.getJmsResourceFactory().startConnection();
+ //jmsResourceFactory.startConnection();
+ replyMsg = consumer.receive(context.getTimeToLive());
+ } finally {
+ consumer.close();
+ }
+ if (replyMsg == null) {
+ throw new JMSBindingException("No reply message received on " +
+ context.getReplyToDestination() +
+ " for message id " +
+ requestMessage.getJMSMessageID());
+ }
+
+ msg.setBody(replyMsg);
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ } catch (NamingException e) {
+ throw new JMSBindingException(e);
+ } finally {
+ try {
+ context.closeJmsResponseSession();
+ if (jmsResourceFactory.isConnectionClosedAfterUse())
+ jmsResourceFactory.closeResponseConnection();
+ } catch (JMSException e) {
+ }
+ }
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
new file mode 100644
index 0000000000..4ba33695e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.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.sca.binding.jms.transport;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportServiceInterceptor implements Interceptor {
+ private static final Logger logger = Logger.getLogger(TransportServiceInterceptor.class.getName());
+
+ private Invoker next;
+ private RuntimeEndpoint endpoint;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+ private RuntimeComponentService service;
+ private String correlationScheme;
+ private AssemblyFactory assemblyFactory;
+
+
+ public TransportServiceInterceptor(ExtensionPointRegistry registry, JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.endpoint = endpoint;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.correlationScheme = jmsBinding.getCorrelationScheme();
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ return invokeResponse(next.invoke(invokeRequest(msg)));
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, "Exception invoking service '" + service.getName(), e);
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message replyJMSMsg = responseMessageProcessor.createFaultMessage(context.getJmsResponseSession(),
+ (Throwable)e);
+ msg.setBody(replyJMSMsg);
+ invokeResponse(msg);
+ return msg;
+ } finally {
+ try {
+ ((JMSBindingContext)msg.getBindingContext()).closeJmsResponseSession();
+ if (jmsResourceFactory.isConnectionClosedAfterUse())
+ jmsResourceFactory.closeResponseConnection();
+ } catch (JMSException e) {
+ }
+ }
+ }
+
+ public Message invokeRequest(Message msg) {
+// try {
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message requestJMSMsg = context.getJmsMsg();
+
+ EndpointReference from = assemblyFactory.createEndpointReference();
+ Endpoint fromEndpoint = assemblyFactory.createEndpoint();
+ from.setTargetEndpoint(fromEndpoint);
+ from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ msg.setFrom(from);
+ Endpoint callbackEndpoint = assemblyFactory.createEndpoint();
+// callbackEndpoint.setURI(callbackAddress); // TODO: is this needed? Seems to work without it
+ callbackEndpoint.setUnresolved(true);
+ from.setCallbackEndpoint(callbackEndpoint);
+
+ return msg;
+// } catch (JMSException e) {
+// throw new JMSBindingException(e);
+// }
+ }
+
+ public Message invokeResponse(Message msg) {
+ JMSBindingContext context = msg.getBindingContext();
+ try {
+
+ //if operation is oneway, return back.
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ Session session = context.getJmsResponseSession();
+ javax.jms.Message requestJMSMsg = context.getJmsMsg();
+ javax.jms.Message responseJMSMsg = msg.getBody();
+
+ Destination replyDest = requestJMSMsg.getJMSReplyTo();
+ if (replyDest == null) {
+ if (jmsBinding.getResponseDestinationName() != null) {
+ try {
+ replyDest = jmsResourceFactory.lookupDestination(jmsBinding.getResponseDestinationName());
+ } catch (NamingException e) {
+ throw new JMSBindingException("Exception lookingup response destination", e);
+ }
+ }
+ }
+
+ if (replyDest == null) {
+ // assume no reply is expected
+ if (msg.getBody() != null) {
+ logger.log(Level.FINE, "JMS service '" + service.getName() + "' dropped response as request has no replyTo");
+ }
+ return msg;
+ }
+
+ if (msg.getOperation() != null) {
+ String operationName = msg.getOperation().getName();
+ if (jmsBinding.getOperationJMSPriority(operationName) != null) {
+ responseJMSMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName));
+ }
+
+ if (jmsBinding.getOperationJMSType(operationName) != null) {
+ responseJMSMsg.setJMSType(jmsBinding.getOperationJMSType(operationName));
+ }
+ if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) {
+ if (jmsBinding.getOperationJMSDeliveryMode(operationName)) {
+ responseJMSMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
+ } else {
+ responseJMSMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ }
+ }
+ }
+
+ if (correlationScheme == null ||
+ JMSBindingConstants.CORRELATE_MSG_ID.equalsIgnoreCase(correlationScheme)) {
+ responseJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSMessageID());
+ } else if (JMSBindingConstants.CORRELATE_CORRELATION_ID.equalsIgnoreCase(correlationScheme)) {
+ responseJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSCorrelationID());
+ }
+
+ MessageProducer producer = session.createProducer(replyDest);
+
+ // Set jms header attributes in producer, not message.
+ int deliveryMode = requestJMSMsg.getJMSDeliveryMode();
+ producer.setDeliveryMode(deliveryMode);
+ int deliveryPriority = requestJMSMsg.getJMSPriority();
+ producer.setPriority(deliveryPriority);
+
+ producer.send((javax.jms.Message)msg.getBody());
+
+ producer.close();
+
+ return msg;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ } finally {
+ context.closeJmsResponseSession();
+ }
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java
new file mode 100644
index 0000000000..2245f61ee7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wire;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class CallbackDestinationInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeComponentService service;
+
+ public CallbackDestinationInterceptor(RuntimeEndpoint endpoint) {
+ super();
+ this.service = (RuntimeComponentService) endpoint.getService();
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Message invoke(Message msg) {
+ return next.invoke(invokeRequest(msg));
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ //ReferenceParameters parameters = msg.getFrom().getReferenceParameters(); TODO: 2.x migration, are these needed?
+
+ if (service.getInterfaceContract().getCallbackInterface() != null) {
+
+ String callbackdestName = jmsMsg.getStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY);
+ if (callbackdestName == null && msg.getOperation().isNonBlocking()) {
+ // if the request has a replyTo but this service operation is oneway but the service uses callbacks
+ // then use the replyTo as the callback destination
+ Destination replyTo = jmsMsg.getJMSReplyTo();
+ if (replyTo != null) {
+ callbackdestName = (replyTo instanceof Queue) ? ((Queue) replyTo).getQueueName() : ((Topic) replyTo).getTopicName();
+ }
+ }
+
+ if (callbackdestName != null) {
+ // append "jms:" to make it an absolute uri so the invoker can determine it came in on the request
+ // as otherwise the invoker should use the uri from the service callback binding
+// parameters.setCallbackReference(new EndpointReferenceImpl("jms:" + callbackdestName));
+ }
+
+ String callbackID = jmsMsg.getStringProperty(JMSBindingConstants.CALLBACK_ID_PROPERTY);
+ if (callbackID != null) {
+// parameters.setCallbackID(callbackID);
+ }
+ }
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+
+ return msg;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java
new file mode 100644
index 0000000000..bf046b473e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wire;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class OperationPropertiesInterceptor implements Interceptor {
+ private Invoker next;
+ private JMSBinding jmsBinding;
+ private RuntimeComponentService service;
+ private List<Operation> serviceOperations;
+
+ public OperationPropertiesInterceptor(JMSBinding jmsBinding, RuntimeEndpoint endpoint) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.service = (RuntimeComponentService) endpoint.getService();
+ this.serviceOperations = service.getInterfaceContract().getInterface().getOperations();
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Message invoke(Message msg) {
+ return next.invoke(invokeRequest(msg));
+ }
+
+ public Message invokeRequest(Message msg) {
+ // TODO - could probably optimize this better
+ String operationName = msg.getOperation().getName();
+ String operationNameOverride = jmsBinding.getNativeOperationName(operationName);
+ for (Operation op : serviceOperations) {
+ if (op.getName().equals(operationNameOverride)) {
+ msg.setOperation(op);
+ break;
+ }
+ }
+ return msg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java
new file mode 100644
index 0000000000..7675698cc7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.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.binding.jms.wireformat.jmsbytes.runtime;
+
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesProviderFactory implements WireFormatProviderFactory<WireFormatJMSBytes> {
+ private ExtensionPointRegistry registry;
+
+ public WireFormatJMSBytesProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return new WireFormatJMSBytesReferenceProvider(registry, endpointReference);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) {
+ return new WireFormatJMSBytesServiceProvider(registry, endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java
new file mode 100644
index 0000000000..4620063076
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.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.sca.binding.jms.wireformat.jmsbytes.runtime;
+
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpointReference endpointReference;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSBytesReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference) {
+ super();
+ this.endpointReference = endpointReference;
+ this.jmsBinding = (JMSBinding) endpointReference.getBinding();
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytes){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytes){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsSession();
+
+ Object[] requestParams = msg.getBody();
+ javax.jms.Message requestMsg = null;
+ if (requestParams != null && requestParams.length > 0 ){
+ requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, requestParams[0]);
+ } else {
+ requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, null);
+ }
+ msg.setBody(requestMsg);
+
+ requestMsg.setJMSReplyTo(context.getReplyToDestination());
+
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message invokeResponse(Message msg) {
+ if (msg.getBody() != null){
+ Object response = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody());
+ if (response instanceof InvocationTargetException) {
+ msg.setFaultBody(((InvocationTargetException) response).getCause());
+ } else {
+ if (response != null){
+ msg.setBody(response);
+ } else {
+ msg.setBody(null);
+ }
+ }
+ }
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java
new file mode 100644
index 0000000000..3d2c8ec18c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpointReference endpointReference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSBytesReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpointReference endpointReference) {
+ super();
+ this.registry = registry;
+ this.endpointReference = endpointReference;
+ this.binding = (JMSBinding) endpointReference.getBinding();
+
+ // configure the reference based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing however overried
+ // any message processors specied in the SCDL in this case
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME);
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME);
+ }
+
+ // just point to the reference interface contract so no
+ // databinding transformation takes place
+ interfaceContract = endpointReference.getReference().getReference().getInterfaceContract();
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null ) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSBytesReferenceInterceptor(registry, null, endpointReference);
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java
new file mode 100644
index 0000000000..506d47f8a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime;
+
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeEndpoint endpoint;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSBytesServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) {
+ super();
+ this.endpoint = endpoint;
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytes){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ //if it's oneway return back
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytes){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ msg.setBody(new Object[]{requestPayload});
+
+ return msg;
+ }
+
+ public Message invokeResponse(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsResponseSession();
+
+ javax.jms.Message responseJMSMsg;
+ if (msg.isFault()) {
+ responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
+ } else {
+ Object response = msg.getBody();
+ responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
+ }
+
+ msg.setBody(responseJMSMsg);
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java
new file mode 100644
index 0000000000..ef3530640f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpoint endpoint;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSBytesServiceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpoint endpoint) {
+ super();
+ this.registry = registry;
+ this.endpoint = endpoint;
+ this.binding = (JMSBinding) endpoint.getBinding();
+
+ // configure the service based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing however override
+ // any message processors specified in the SCDL in this case
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME);
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME);
+ }
+
+ // just point to the reference interface contract so no
+ // databinding transformation takes place
+ interfaceContract = endpoint.getService().getService().getInterfaceContract();
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null ) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ /**
+ */
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSBytesServiceInterceptor(registry, null, endpoint);
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java
new file mode 100644
index 0000000000..a791c5f0b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+
+public class WireFormatJMSBytesXMLProviderFactory implements WireFormatProviderFactory<WireFormatJMSBytes> {
+ private ExtensionPointRegistry registry;
+ private JMSResourceFactoryExtensionPoint jmsRFEP;
+
+ public WireFormatJMSBytesXMLProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ jmsRFEP = (JMSResourceFactoryExtensionPoint)registry.getExtensionPoint(JMSResourceFactoryExtensionPoint.class);
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return new WireFormatJMSBytesXMLReferenceProvider(registry, endpointReference);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) {
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)endpoint.getBinding());
+ return new WireFormatJMSBytesXMLServiceProvider(registry, endpoint, jmsRF);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java
new file mode 100644
index 0000000000..e453940d30
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.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.sca.binding.jms.wireformat.jmsbytesxml.runtime;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXML;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.w3c.dom.Node;
+
+
+public class WireFormatJMSBytesXMLReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpointReference endpointReference;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSBytesXMLReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference) {
+ super();
+ this.jmsBinding = (JMSBinding) endpointReference.getBinding();
+ this.endpointReference = endpointReference;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytesXML){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytesXML){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsSession();
+
+ javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+
+ msg.setBody(requestMsg);
+
+ requestMsg.setJMSReplyTo(context.getReplyToDestination());
+
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message invokeResponse(Message msg) {
+ if (msg.getBody() != null){
+ javax.jms.Message jmsMsg = (javax.jms.Message)msg.getBody();
+ Object response = responseMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ if (response != null ){
+ msg.setBody(response);
+ try {
+ if (jmsMsg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) {
+ FaultException e = new FaultException("remote exception", response);
+ Node om = ((Node)response).getFirstChild();
+ e.setFaultName(new QName(om.getNamespaceURI(), om.getLocalName()));
+ msg.setFaultBody(e);
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ msg.setBody(null);
+ }
+ }
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java
new file mode 100644
index 0000000000..e0f928de12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXML;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+public class WireFormatJMSBytesXMLReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpointReference endpointReference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSBytesXMLReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpointReference endpointReference) {
+ super();
+ this.registry = registry;
+ this.endpointReference = endpointReference;
+ this.binding = (JMSBinding)endpointReference.getBinding();
+
+ // configure the reference based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing however overried
+ // any message processors specied in the SCDL in this case
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytesXML){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_BYTES_MP_CLASSNAME);
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytesXML){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_BYTES_MP_CLASSNAME);
+ }
+
+ // create a local interface contract that is configured specifically to
+ // deal with the data format that this wire format is expecting to sent to
+ // and receive from the databinding interceptor. The request/response parts of
+ // this interface contract will be copied into the binding interface contract
+ // as required
+ WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class);
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ BindingWSDLGenerator.generateWSDL(endpointReference.getComponent(), endpointReference.getContract(), wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null ) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytesXML){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytesXML){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSBytesXMLReferenceInterceptor(registry, null, endpointReference);
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java
new file mode 100644
index 0000000000..c1e97a93d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime;
+
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXML;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class WireFormatJMSBytesXMLServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeEndpoint endpoint;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSBytesXMLServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) {
+ super();
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.endpoint = endpoint;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytesXML){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ //if it's oneway return back
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytesXML){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ msg.setBody(new Object[]{requestPayload});
+
+ return msg;
+ }
+
+ public Message invokeResponse(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsResponseSession();
+
+ javax.jms.Message responseJMSMsg;
+ if (msg.isFault()) {
+ responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
+ } else {
+ Object response = msg.getBody();
+ responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
+ }
+
+ msg.setBody(responseJMSMsg);
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java
new file mode 100644
index 0000000000..d2ff153227
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXML;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpoint endpoint;
+ private JMSBinding binding;
+ private JMSResourceFactory jmsResourceFactory;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSBytesXMLServiceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpoint endpoint,
+ JMSResourceFactory jmsResourceFactory) {
+ super();
+ this.registry = registry;
+ this.endpoint = endpoint;
+ this.binding = (JMSBinding)endpoint.getBinding();
+ this.jmsResourceFactory = jmsResourceFactory;
+
+ // configure the service based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing however override
+ // any message processors specified in the SCDL in this case
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytesXML){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_BYTES_MP_CLASSNAME);
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytesXML){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_BYTES_MP_CLASSNAME);
+ }
+
+ // create a local interface contract that is configured specifically to
+ // deal with the data format that this wire format is expecting to sent to
+ // and receive from the databinding interceptor. The request/response parts of
+ // this interface contract will be copied into the binding interface contract
+ // as required
+ WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class);
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), endpoint.getService(), wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null ) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytesXML){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytesXML){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ /**
+ */
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSBytesXMLServiceInterceptor(registry, jmsResourceFactory, endpoint);
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java
new file mode 100644
index 0000000000..adf8c03c10
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultProviderFactory implements WireFormatProviderFactory<WireFormatJMSDefault> {
+ private ExtensionPointRegistry registry;
+ private JMSResourceFactoryExtensionPoint jmsRFEP;
+
+ public WireFormatJMSDefaultProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ jmsRFEP = (JMSResourceFactoryExtensionPoint) registry.getExtensionPoint(JMSResourceFactoryExtensionPoint.class);
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return new WireFormatJMSDefaultReferenceProvider(registry, endpointReference);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) {
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding) endpoint.getBinding());
+ return new WireFormatJMSDefaultServiceProvider(registry, endpoint, jmsRF);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java
new file mode 100644
index 0000000000..87d99a014e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime;
+
+import java.util.HashMap;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.DefaultMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpointReference endpointReference;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private DefaultMessageProcessor requestMessageProcessor;
+ private DefaultMessageProcessor responseMessageProcessor;
+ private HashMap<String, Boolean> inputWrapperMap;
+ private HashMap<String, Node> outputWrapperMap;
+
+ public WireFormatJMSDefaultReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference, HashMap<String, Boolean> inputWrapperMap,
+ HashMap<String, Node> outputWrapperMap) {
+ super();
+ this.jmsBinding = (JMSBinding) endpointReference.getBinding();
+ this.endpointReference = endpointReference;
+ this.jmsResourceFactory = jmsResourceFactory;
+ // Note the default processor doesn't follow the normal processor pattern
+ // as it has to handle both text and bytes messages
+ this.requestMessageProcessor = new DefaultMessageProcessor(jmsBinding, registry);
+ this.responseMessageProcessor = new DefaultMessageProcessor(jmsBinding, registry);
+ this.inputWrapperMap = inputWrapperMap;
+ this.outputWrapperMap = outputWrapperMap;
+ }
+
+ public Message invoke(Message msg) {
+
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault) {
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSDefault) {
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsSession();
+
+ javax.jms.Message requestMsg;
+
+ if (((WireFormatJMSDefault) jmsBinding.getRequestWireFormat()).isUseBytesMessage()) {
+ requestMsg = requestMessageProcessor.insertPayloadIntoJMSBytesMessage(session, msg.getBody(), this.inputWrapperMap.get(msg.getOperation().getName()));
+ } else {
+ requestMsg = requestMessageProcessor.insertPayloadIntoJMSTextMessage(session, msg.getBody(), this.inputWrapperMap.get(msg.getOperation().getName()));
+ }
+
+ msg.setBody(requestMsg);
+
+ requestMsg.setJMSReplyTo(context.getReplyToDestination());
+
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message invokeResponse(Message msg) {
+ if (msg.getBody() != null) {
+ javax.jms.Message jmsMsg = (javax.jms.Message) msg.getBody();
+
+ Operation op = msg.getOperation();
+ DataType outputDataType = op.getOutputType();
+
+ Class<?> outputType = null;
+ if (outputDataType != null) {
+ outputType = outputDataType.getPhysical();
+ }
+
+ if (outputType != null && javax.jms.Message.class.isAssignableFrom(outputType)) {
+ msg.setBody(jmsMsg);
+ } else {
+
+ Node wrapper = null;
+ // if we have a fault no need to wrap the response
+ try {
+ if (!jmsMsg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) {
+ // If there is only one arg we must add a wrapper if the operation is wrapper style
+ wrapper = this.outputWrapperMap.get(msg.getOperation().getName());
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+
+ Object response;
+ if (jmsMsg instanceof BytesMessage) {
+ response = responseMessageProcessor.extractPayloadFromJMSBytesMessage(jmsMsg, wrapper);
+ } else {
+ response = responseMessageProcessor.extractPayloadFromJMSTextMessage(jmsMsg, wrapper);
+ }
+
+ if (response != null) {
+ msg.setBody(response);
+ try {
+ if (jmsMsg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) {
+ FaultException e = new FaultException("remote exception", response);
+ Node om = ((Node)response).getFirstChild();
+ e.setFaultName(new QName(om.getNamespaceURI(), om.getLocalName()));
+ msg.setFaultBody(e);
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ msg.setBody(null);
+ }
+ }
+ }
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java
new file mode 100644
index 0000000000..127680c283
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpointReference endpointReference;
+ private ComponentReference reference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+ private DOMHelper domHelper;
+ private HashMap<String, Boolean> inputWrapperMap;
+ private HashMap<String, Node> outputWrapperMap;
+
+ public WireFormatJMSDefaultReferenceProvider(ExtensionPointRegistry registry, RuntimeEndpointReference endpointReference) {
+ super();
+ this.registry = registry;
+ this.endpointReference = endpointReference;
+ this.binding = (JMSBinding) endpointReference.getBinding();
+
+ this.domHelper = DOMHelper.getInstance(registry);
+ this.inputWrapperMap = new HashMap<String, Boolean>();
+ this.outputWrapperMap = new HashMap<String, Node>();
+
+ // configure the reference based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing so set the message
+ // type here if not set explicitly in SCDL
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSDefault){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.DEFAULT_MP_CLASSNAME);
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSDefault){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.DEFAULT_MP_CLASSNAME);
+ }
+
+ this.reference = endpointReference.getReference();
+ // TODO - can be null if it's a $self$ reference. Need to decide if
+ // that's valid
+ if (reference.getReference() == null){
+ interfaceContract = reference.getInterfaceContract();
+ return;
+ }
+
+ List<Operation> opList = reference.getReference().getInterfaceContract().getInterface().getOperations();
+
+ // Go through each operation and add wrapper info
+
+ // set the binding interface contract to represent the WSDL for the
+ // xml messages that will be sent
+ // I think we have to check for asIs because the Java2WSDL will blow up when using javax.jms.Message
+ if (reference.getInterfaceContract() != null && !isAsIs()) {
+ WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class);
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ BindingWSDLGenerator.generateWSDL(endpointReference.getComponent(), reference, wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
+
+ List<Operation> wsdlOpList = interfaceContract.getInterface().getOperations();
+
+ for (Operation op : opList) {
+
+ String name = op.getName();
+ Operation matchingWsdlOp = null;
+
+ // find the matching wsdlop
+ for (Operation wsdlOp : wsdlOpList) {
+ if (name.equals(wsdlOp.getName())) {
+ matchingWsdlOp = wsdlOp;
+
+ break;
+ }
+ }
+
+ // only add operations that need to be wrapped/unwrapped
+ // we need to look at the wsdl interface to determine if the op is wrapped or not
+
+ // TODO - not sure we really support viewing the input/output as separately wrapped
+ // like the separate code paths imply. Not sure how many @OneWay tests we have, this might
+ // not be an issue.
+
+ if (matchingWsdlOp.isWrapperStyle()) {
+ if (op.getInputType().getLogical().size() == 1) {
+ this.inputWrapperMap.put(name, true);
+ } else {
+ this.inputWrapperMap.put(name, false);
+ }
+ } else {
+ this.inputWrapperMap.put(name, false);
+ }
+
+ if (matchingWsdlOp.isWrapperStyle()) {
+ // we only need to know what the wrapper is on the deserialization
+ // might need to change this when there input/output wrapper style is different
+ ElementInfo ei = op.getWrapper().getOutputWrapperElement();
+ String namespace = ei.getQName().getNamespaceURI();
+ String opName = ei.getQName().getLocalPart();
+ Document document = domHelper.newDocument();
+ Element wrapper = DOMHelper.createElement(document, new QName(namespace, opName));
+ this.outputWrapperMap.put(name, wrapper);
+ }
+ }
+ } else {
+ interfaceContract = reference.getReference().getInterfaceContract();
+ }
+
+ }
+
+ protected boolean isAsIs() {
+ InterfaceContract ic = reference.getInterfaceContract();
+ if (ic.getInterface().getOperations().size() != 1) {
+ return false;
+ }
+
+ List<DataType> inputDataTypes = ic.getInterface().getOperations().get(0).getInputType().getLogical();
+
+ if (inputDataTypes.size() != 1) {
+ return false;
+ }
+
+ Class<?> inputType = inputDataTypes.get(0).getPhysical();
+
+ if (javax.jms.Message.class.isAssignableFrom(inputType)) {
+ return true;
+ }
+ return false;
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null &&
+ !isAsIs()) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSDefault){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSDefault){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSDefaultReferenceInterceptor(registry, null, endpointReference, inputWrapperMap, outputWrapperMap);
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java
new file mode 100644
index 0000000000..da6f283ff9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.DefaultMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.w3c.dom.Node;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeEndpoint endpoint;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private DefaultMessageProcessor requestMessageProcessor;
+ private DefaultMessageProcessor responseMessageProcessor;
+ private HashMap<String, Node> inputWrapperMap;
+ private HashMap<String, Boolean> outputWrapperMap;
+
+ public WireFormatJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint, HashMap<String, Node> inputWrapperMap,
+ HashMap<String, Boolean> outputWrapperMap) {
+ super();
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.endpoint = endpoint;
+ this.jmsResourceFactory = jmsResourceFactory;
+ // Note the default processor doesn't follow the normal processor pattern
+ // as it has to handle both text and bytes messages
+ this.requestMessageProcessor = new DefaultMessageProcessor(jmsBinding, registry);
+ this.responseMessageProcessor = new DefaultMessageProcessor(jmsBinding, registry);
+ this.inputWrapperMap = inputWrapperMap;
+ this.outputWrapperMap = outputWrapperMap;
+
+ }
+
+ public Message invoke(Message msg) {
+
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault) {
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ // if it's oneway return back
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSDefault) {
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ Operation op = msg.getOperation();
+ List<DataType> inputDataTypes = op.getInputType().getLogical();
+
+ Class<?> inputType = null;
+ if (inputDataTypes.size() == 1) {
+ inputType = inputDataTypes.get(0).getPhysical();
+ }
+ if (inputType != null && javax.jms.Message.class.isAssignableFrom(inputType)) {
+ msg.setBody(new Object[] { jmsMsg });
+
+ if (jmsMsg instanceof BytesMessage) {
+ context.setUseBytesForWFJMSDefaultResponse(true);
+ } else {
+ context.setUseBytesForWFJMSDefaultResponse(false);
+ }
+ } else {
+
+ // If there is only one arg we must add a wrapper if the operation is wrapper style
+ Node wrapper = this.inputWrapperMap.get(msg.getOperation().getName());
+
+ Object requestPayload;
+ if (jmsMsg instanceof BytesMessage) {
+ requestPayload = responseMessageProcessor.extractPayloadFromJMSBytesMessage(jmsMsg, wrapper);
+ context.setUseBytesForWFJMSDefaultResponse(true);
+ } else {
+ requestPayload = responseMessageProcessor.extractPayloadFromJMSTextMessage(jmsMsg, wrapper );
+ context.setUseBytesForWFJMSDefaultResponse(false);
+ }
+
+ msg.setBody(new Object[] { requestPayload });
+ }
+
+ return msg;
+
+ }
+
+ public Message invokeResponse(Message msg) {
+
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsResponseSession();
+
+ javax.jms.Message responseJMSMsg;
+
+ boolean respondBytesMessage = context.isUseBytesForWFJMSDefaultResponse();
+
+ if (msg.isFault()) {
+ if (respondBytesMessage == true) {
+ responseJMSMsg = requestMessageProcessor.createFaultJMSBytesMessage(session, (Throwable) msg.getBody());
+ } else {
+ responseJMSMsg = responseMessageProcessor.createFaultJMSTextMessage(session, (Throwable) msg.getBody());
+ }
+ } else {
+ boolean unwrap = false;
+
+ if (this.outputWrapperMap.get(msg.getOperation().getName()) != null){
+ unwrap = this.outputWrapperMap.get(msg.getOperation().getName());
+ }
+
+ if (respondBytesMessage == true) {
+ responseJMSMsg = requestMessageProcessor.insertPayloadIntoJMSBytesMessage(session, msg.getBody(), unwrap);
+ } else {
+ responseJMSMsg = requestMessageProcessor.insertPayloadIntoJMSTextMessage(session, msg.getBody(), unwrap);
+ }
+ }
+
+
+ try {
+ responseJMSMsg.setStringProperty(JMSBindingConstants.DEFAULT_OPERATION_PROP_NAME, msg.getOperation().getName());
+ } catch (JMSException e) {
+ // Not sure what to do at this point.. it doesn't make sense to create a fault message.
+ // Throwing a runtime exception for now.
+ throw new JMSBindingException(e);
+ }
+
+ msg.setBody(responseJMSMsg);
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java
new file mode 100644
index 0000000000..3541666007
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpoint endpoint;
+ private ComponentService service;
+ private JMSBinding binding;
+ private JMSResourceFactory jmsResourceFactory;
+ private InterfaceContract interfaceContract;
+ private DOMHelper domHelper;
+ private HashMap<String, Node> inputWrapperMap;
+ private HashMap<String, Boolean> outputWrapperMap;
+
+ public WireFormatJMSDefaultServiceProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint, JMSResourceFactory jmsResourceFactory) {
+ super();
+ this.registry = registry;
+ this.endpoint = endpoint;
+ this.binding = (JMSBinding) endpoint.getBinding();
+ this.service = endpoint.getService();
+ this.jmsResourceFactory = jmsResourceFactory;
+
+ this.domHelper = DOMHelper.getInstance(registry);
+ this.inputWrapperMap = new HashMap<String, Node>();
+ this.outputWrapperMap = new HashMap<String, Boolean>();
+
+ // configure the service based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing so set the message
+ // type here if not set explicitly in SCDL
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSDefault){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.DEFAULT_MP_CLASSNAME);
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSDefault){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.DEFAULT_MP_CLASSNAME);
+ }
+
+ List<Operation> opList = service.getService().getInterfaceContract().getInterface().getOperations();
+
+ // Go through each operation and add wrapper info
+
+ // set the binding interface contract to represent the WSDL for the
+ // xml messages that will be sent
+
+ // I think we have to check for asIs because the Java2WSDL will blow up when using javax.jms.Message
+ if (service.getInterfaceContract() != null && !isAsIs()) {
+ WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class);
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), service, wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
+
+ List<Operation> wsdlOpList = interfaceContract.getInterface().getOperations();
+
+ for (Operation op : opList) {
+ String name = op.getName();
+
+ Operation matchingWsdlOp = null;
+
+ // find the matching wsdlop
+ for (Operation wsdlOp : wsdlOpList) {
+ if (name.equals(wsdlOp.getName())) {
+ matchingWsdlOp = wsdlOp;
+ break;
+ }
+ }
+
+ // only add operations that need to be wrapped/unwrapped
+
+ // TODO - not sure we really support viewing the input/output as separately wrapped
+ // like the separate code paths imply. Not sure how many @OneWay tests we have, this might
+ // not be an issue.
+ if (matchingWsdlOp.isWrapperStyle()) {
+ if (op.getInputType().getLogical().size() == 1) {
+ // we only need to know what the wrapper is on the deserialization
+ // might need to change this when the input/output wrapper style is different
+ ElementInfo ei = op.getWrapper().getInputWrapperElement();
+ String namespace = ei.getQName().getNamespaceURI();
+ String opName = ei.getQName().getLocalPart();
+ Document document = domHelper.newDocument();
+ Element wrapper = DOMHelper.createElement(document, new QName(namespace, opName));
+ this.inputWrapperMap.put(name, wrapper);
+ }
+ }
+
+ if (matchingWsdlOp.isWrapperStyle()) {
+ this.outputWrapperMap.put(name, true);
+ } else {
+ this.outputWrapperMap.put(name, false);
+ }
+
+ }
+
+ } else {
+ interfaceContract = service.getService().getInterfaceContract();
+ }
+ }
+
+ protected boolean isAsIs() {
+ InterfaceContract ic = service.getInterfaceContract();
+ if (ic.getInterface().getOperations().size() != 1) {
+ return false;
+ }
+
+ List<DataType> inputDataTypes = ic.getInterface().getOperations().get(0).getInputType().getLogical();
+
+ if (inputDataTypes.size() != 1) {
+ return false;
+ }
+
+ Class<?> inputType = inputDataTypes.get(0).getPhysical();
+
+ if (javax.jms.Message.class.isAssignableFrom(inputType)) {
+ return true;
+ }
+ return false;
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null &&
+ !isAsIs()) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSDefault){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSDefault){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSDefaultServiceInterceptor(registry, jmsResourceFactory, endpoint, this.inputWrapperMap, this.outputWrapperMap);
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java
new file mode 100644
index 0000000000..1e445f1b11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.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.binding.jms.wireformat.jmsobject.runtime;
+
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectProviderFactory implements WireFormatProviderFactory<WireFormatJMSObject> {
+ private ExtensionPointRegistry registry;
+
+ public WireFormatJMSObjectProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return new WireFormatJMSObjectReferenceProvider(registry, endpointReference);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) {
+ return new WireFormatJMSObjectServiceProvider(registry, endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java
new file mode 100644
index 0000000000..ec110ea0d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.provider.ObjectMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpointReference endpointReference;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ private HashMap<String, String> singleArgMap;
+
+ public WireFormatJMSObjectReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference, HashMap<String, String> hashMap) {
+ super();
+ this.jmsBinding = (JMSBinding) endpointReference.getBinding();
+ this.endpointReference = endpointReference;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ this.singleArgMap = hashMap;
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSObject){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSObject){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsSession();
+
+ javax.jms.Message requestMsg;
+
+ // Tuscany automatically wraps operation arguments in an array before we
+ // get to this point so here we need to decide how they are going to appear
+ // on the wire.
+ //
+ // If the operation has a single parameter and the user has set @wrapSingle=false
+ // then
+ // send the single parameter out onto the wire unwrapped
+ // else
+ // send out the message as is
+ //
+ if (singleArgMap.get(msg.getOperation().getName()) == null) {
+ requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+ } else {
+ // we know that wrapSinle is set to false here as the provider only
+ // populates singleArgMap if it is set false
+ requestMsg = ((ObjectMessageProcessor) requestMessageProcessor).createJMSMessageForSingleParamOperation(session, msg.getBody(), false);
+ }
+
+ msg.setBody(requestMsg);
+
+ requestMsg.setJMSReplyTo(context.getReplyToDestination());
+
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message invokeResponse(Message msg) {
+ if (msg.getBody() != null){
+ Object response = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody());
+
+ if (response instanceof InvocationTargetException) {
+ msg.setFaultBody(((InvocationTargetException) response).getCause());
+ } else {
+ if (response != null){
+ msg.setBody(response);
+ } else {
+ msg.setBody(null);
+ }
+ }
+ }
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java
new file mode 100644
index 0000000000..44e59a0226
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.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.sca.binding.jms.wireformat.jmsobject.runtime;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpointReference endpointReference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ private HashMap<String,String> singleArgMap; //map of one arg operations, leave empty if wrapSingleInput is true
+
+ public WireFormatJMSObjectReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpointReference endpointReference) {
+ super();
+ this.registry = registry;
+ this.endpointReference = endpointReference;
+ this.binding = (JMSBinding)endpointReference.getBinding();
+
+ this.singleArgMap = new HashMap<String,String>();
+ ComponentReference reference = endpointReference.getReference();
+
+ // configure the reference based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing however override
+ // any message processors specified in the SCDL in this case
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
+
+ //we don't need to create this map if wrapSingleInput is true
+ if (!((WireFormatJMSObject) this.binding.getRequestWireFormat()).isWrappedSingleInput()){
+ List<Operation> opList = reference.getReference().getInterfaceContract().getInterface().getOperations();
+
+ for (Operation op: opList) {
+ if (op.getInputType().getLogical().size() == 1){
+ this.singleArgMap.put(op.getName(), "");
+ }
+ }
+ }
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
+ }
+
+ // just point to the reference interface contract so no
+ // databinding transformation takes place
+ interfaceContract = reference.getReference().getInterfaceContract();
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null ) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSObjectReferenceInterceptor(registry, null, endpointReference, this.singleArgMap);
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java
new file mode 100644
index 0000000000..19baddd9da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime;
+
+import java.util.HashMap;
+
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.provider.ObjectMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeEndpoint endpoint;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+ private HashMap<String,Class<?>> singleArgMap;
+ private boolean wrapSingle;
+
+ public WireFormatJMSObjectServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory,
+ RuntimeEndpoint endpoint, HashMap<String, Class<?>> singleArgMap, boolean wrapSingle) {
+ super();
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.endpoint = endpoint;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ this.singleArgMap = singleArgMap;
+ this.wrapSingle = wrapSingle;
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSObject){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ //if it's oneway return back
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSObject){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+ Object requestPayload;
+
+ // If the service interface has a single argument then we need
+ // to check if the object from the wire is expected
+ // to be unwrapped or not
+ //
+ Class<?> argType = this.singleArgMap.get(msg.getOperation().getName());
+ if (argType == null) {
+ requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ }else {
+ requestPayload = ((ObjectMessageProcessor)requestMessageProcessor).extractPayloadFromJMSMessageForSingleParamOperation(jmsMsg, argType, wrapSingle);
+ }
+
+ if (requestPayload != null && requestPayload.getClass().isArray()) {
+ msg.setBody(requestPayload);
+ } else if (requestPayload == null) {
+ msg.setBody(new Object[0]);
+ } else {
+ msg.setBody(new Object[] {requestPayload});
+ }
+
+ return msg;
+ }
+
+ public Message invokeResponse(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsResponseSession();
+
+ javax.jms.Message responseJMSMsg = null;
+ if (msg.isFault()) {
+ responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
+ } else {
+ responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+ }
+
+ msg.setBody(responseJMSMsg);
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java
new file mode 100644
index 0000000000..2e50f27a47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime;
+
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpoint endpoint;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+ private HashMap<String,Class<?>> singleArgMap;
+ private boolean wrapSingle = true;
+
+ public WireFormatJMSObjectServiceProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint) {
+ super();
+ this.registry = registry;
+ this.endpoint = endpoint;
+ this.binding = (JMSBinding)endpoint.getBinding();
+ this.singleArgMap = new HashMap<String,Class<?>>();
+
+ ComponentService service = endpoint.getService();
+ // configure the service based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing however override
+ // any message processors specified in the SCDL in this case
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
+
+ List<Operation> opList = service.getService().getInterfaceContract().getInterface().getOperations();
+
+ for (Operation op: opList) {
+ if (op.getInputType().getLogical().size() == 1){
+ this.singleArgMap.put(op.getName(), op.getInputType().getLogical().get(0).getPhysical());
+ }
+ }
+
+ wrapSingle = ((WireFormatJMSObject) this.binding.getRequestWireFormat()).isWrappedSingleInput();
+
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
+ }
+
+ // just point to the reference interface contract so no
+ // databinding transformation takes place
+ interfaceContract = service.getService().getInterfaceContract();
+
+
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null ) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ /**
+ */
+ public Interceptor createInterceptor() {
+
+ return new WireFormatJMSObjectServiceInterceptor(registry, null, endpoint, this.singleArgMap, wrapSingle);
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java
new file mode 100644
index 0000000000..e3522616c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.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.binding.jms.wireformat.jmstext.runtime;
+
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextProviderFactory implements WireFormatProviderFactory<WireFormatJMSText> {
+ private ExtensionPointRegistry registry;
+
+ public WireFormatJMSTextProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return new WireFormatJMSTextReferenceProvider(registry, endpointReference);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) {
+ return new WireFormatJMSTextServiceProvider(registry, endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java
new file mode 100644
index 0000000000..fd512f7d27
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime;
+
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpointReference endpointReference;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSTextReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference) {
+ super();
+ this.jmsBinding = (JMSBinding) endpointReference.getBinding();
+ this.endpointReference = endpointReference;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSText){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSText){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsSession();
+
+ Object[] requestParams = msg.getBody();
+ javax.jms.Message requestMsg = null;
+ if (requestParams != null && requestParams.length > 0 ){
+ requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, requestParams[0]);
+ } else {
+ requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, null);
+ }
+ msg.setBody(requestMsg);
+
+ requestMsg.setJMSReplyTo(context.getReplyToDestination());
+
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message invokeResponse(Message msg) {
+ if (msg.getBody() != null){
+ Object response = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody());
+
+ if (response instanceof InvocationTargetException) {
+ msg.setFaultBody(((InvocationTargetException) response).getCause());
+ } else {
+ if (response != null){
+ msg.setBody(response);
+ } else {
+ msg.setBody(null);
+ }
+ }
+ }
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java
new file mode 100644
index 0000000000..5baffd48dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime;
+
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpointReference endpointReference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSTextReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpointReference endpointReference) {
+ super();
+ this.registry = registry;
+ this.endpointReference = endpointReference;
+ this.binding = (JMSBinding)endpointReference.getBinding();
+
+ // configure the reference based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing however override
+ // any message processors specified in the SCDL in this case
+
+ // this wire format doubles up as the execution logic for user defined
+ // message processors so check the processor name is still set to default
+ // before overwriting
+
+ if ((this.binding.getRequestWireFormat() instanceof WireFormatJMSText) &&
+ (this.binding.getRequestMessageProcessorName().equals(JMSBindingConstants.DEFAULT_MP_CLASSNAME))){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME);
+ }
+ if ((this.binding.getResponseWireFormat() instanceof WireFormatJMSText) &&
+ (this.binding.getResponseMessageProcessorName().equals(JMSBindingConstants.DEFAULT_MP_CLASSNAME))){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME);
+ }
+
+
+ // just point to the reference interface contract so no
+ // databinding transformation takes place
+ interfaceContract = endpointReference.getReference().getReference().getInterfaceContract();
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null ) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSTextReferenceInterceptor(registry, null, endpointReference);
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java
new file mode 100644
index 0000000000..c3f3660211
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime;
+
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeEndpoint endpoint;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSTextServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) {
+ super();
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.endpoint = endpoint;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSText){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ //if it's oneway return back
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSText){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ msg.setBody(new Object[]{requestPayload});
+
+ return msg;
+ }
+
+ public Message invokeResponse(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsResponseSession();
+
+ javax.jms.Message responseJMSMsg;
+ if (msg.isFault()) {
+ responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
+ } else {
+ Object response = msg.getBody();
+ responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
+ }
+
+ msg.setBody(responseJMSMsg);
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java
new file mode 100644
index 0000000000..f4ee1226c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.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.sca.binding.jms.wireformat.jmstext.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpoint endpoint;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSTextServiceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpoint endpoint) {
+ super();
+ this.registry = registry;
+ this.endpoint = endpoint;
+ this.binding = (JMSBinding)endpoint.getBinding();
+
+ // configure the service based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing however override
+ // any message processors specified in the SCDL in this case
+
+ // this wire format doubles up as the execution logic for user defined
+ // message processors so check the processor name is still set to default
+ // before overwriting
+
+ if ((this.binding.getRequestWireFormat() instanceof WireFormatJMSText) &&
+ (this.binding.getRequestMessageProcessorName().equals(JMSBindingConstants.DEFAULT_MP_CLASSNAME))){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME);
+ }
+ if ((this.binding.getResponseWireFormat() instanceof WireFormatJMSText) &&
+ (this.binding.getResponseMessageProcessorName().equals(JMSBindingConstants.DEFAULT_MP_CLASSNAME))){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME);
+ }
+
+ // just point to the reference interface contract so no
+ // databinding transformation takes place
+ interfaceContract = endpoint.getService().getService().getInterfaceContract();
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null ) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ /**
+ */
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSTextServiceInterceptor(registry, null, endpoint);
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java
new file mode 100644
index 0000000000..fb119078d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLProviderFactory implements WireFormatProviderFactory<WireFormatJMSTextXML> {
+ private ExtensionPointRegistry registry;
+ private JMSResourceFactoryExtensionPoint jmsRFEP;
+
+ public WireFormatJMSTextXMLProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ jmsRFEP = (JMSResourceFactoryExtensionPoint)registry.getExtensionPoint(JMSResourceFactoryExtensionPoint.class);
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return new WireFormatJMSTextXMLReferenceProvider(registry, endpointReference);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) {
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)endpoint.getBinding());
+ return new WireFormatJMSTextXMLServiceProvider(registry, endpoint, jmsRF);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java
new file mode 100644
index 0000000000..4d62022196
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime;
+
+
+
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeEndpointReference endpointReference;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+
+ public WireFormatJMSTextXMLReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference) {
+ super();
+ this.jmsBinding = (JMSBinding) endpointReference.getBinding();
+ this.endpointReference = endpointReference;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ }
+
+ public Message invoke(Message msg) {
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSTextXML){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSTextXML){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsSession();
+
+ javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+ msg.setBody(requestMsg);
+
+ requestMsg.setJMSReplyTo(context.getReplyToDestination());
+
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Message invokeResponse(Message msg) {
+ if (msg.getBody() != null){
+ javax.jms.Message jmsMsg = (javax.jms.Message)msg.getBody();
+ Object response = responseMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ if (response != null ){
+ msg.setBody(response);
+ try {
+ if (jmsMsg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) {
+ FaultException e = new FaultException("remote exception", response);
+ Node node = ((Node)response).getFirstChild();
+ e.setFaultName(new QName(node.getNamespaceURI(), node.getLocalName()));
+ msg.setFaultBody(e);
+ }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ } else {
+ msg.setBody(null);
+ }
+ }
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java
new file mode 100644
index 0000000000..957994a146
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.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.sca.binding.jms.wireformat.jmstextxml.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpointReference endpointReference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSTextXMLReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpointReference endpointReference) {
+ super();
+ this.registry = registry;
+ this.endpointReference = endpointReference;
+ this.binding = (JMSBinding)endpointReference.getBinding();
+
+ // configure the reference based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing so set the message
+ // type here if not set explicitly in SCDL
+
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME);
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME);
+ }
+
+ // create a local interface contract that is configured specifically to
+ // deal with the data format that this wire format is expecting to sent to
+ // and receive from the databinding interceptor. The request/response parts of
+ // this interface contract will be copied into the binding interface contract
+ // as required
+ WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class);
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ BindingWSDLGenerator.generateWSDL(endpointReference.getComponent(), endpointReference.getReference(), wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
+ }
+
+ protected boolean isOnMessage() {
+ InterfaceContract ic = endpointReference.getReference().getInterfaceContract();
+ if (ic.getInterface().getOperations().size() != 1) {
+ return false;
+ }
+ return "onMessage".equals(ic.getInterface().getOperations().get(0).getName());
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null && !isOnMessage()) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSTextXMLReferenceInterceptor(registry, null, endpointReference);
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java
new file mode 100644
index 0000000000..8e4f8fb90b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.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.sca.binding.jms.wireformat.jmstextxml.runtime;
+
+import javax.jms.Session;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeEndpoint endpoint;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSTextXMLServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) {
+ super();
+ this.jmsBinding = (JMSBinding) endpoint.getBinding();
+ this.endpoint = endpoint;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(registry, jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding);
+ }
+
+ public Message invoke(Message msg) {
+
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSTextXML){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ //if it's oneway return back
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSTextXML){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ msg.setBody(new Object[] { requestPayload });
+
+ return msg;
+ }
+
+ public Message invokeResponse(Message msg) {
+
+ // get the jms context
+ JMSBindingContext context = msg.getBindingContext();
+ Session session = context.getJmsResponseSession();
+
+ javax.jms.Message responseJMSMsg;
+ if (msg.isFault()) {
+ responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
+ } else {
+ responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+ }
+
+ msg.setBody(responseJMSMsg);
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java
new file mode 100644
index 0000000000..c56a9e0e50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingConstants;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpoint endpoint;
+ private JMSBinding binding;
+ private JMSResourceFactory jmsResourceFactory;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSTextXMLServiceProvider(ExtensionPointRegistry registry,
+ RuntimeEndpoint endpoint,
+ JMSResourceFactory jmsResourceFactory) {
+ super();
+ this.endpoint = endpoint;
+ this.binding = (JMSBinding)endpoint.getBinding();
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.registry = registry;
+
+ // configure the service based on this wire format
+
+ // currently maintaining the message processor structure which
+ // contains the details of jms message processing so set the message
+ // type here if not set explicitly in SCDL
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){
+ this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME);
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){
+ this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME);
+ }
+
+ // create a local interface contract that is configured specifically to
+ // deal with the data format that this wire format is expecting to sent to
+ // and receive from the databinding interceptor. The request/response parts of
+ // this interface contract will be copied into the binding interface contract
+ // as required
+ WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class);
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), endpoint.getService(), wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME);
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
+
+ if (this.interfaceContract != null) {
+ if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){
+ // set the request data transformation
+ interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface());
+ }
+ if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){
+ // set the response data transformation
+ interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface());
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ return new WireFormatJMSTextXMLServiceInterceptor(registry, jmsResourceFactory, endpoint);
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..1781985232
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.jms.provider.JMSBindingProviderFactory;model=org.apache.tuscany.sca.binding.jms.JMSBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
new file mode 100644
index 0000000000..b5d5117b84
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.runtime.OperationSelectorJMSDefaultProviderFactory;model=org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSDefault
+org.apache.tuscany.sca.binding.jms.operationselector.jmsuserprop.runtime.OperationSelectorJMSUserPropProviderFactory;model=org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSUserProp
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
new file mode 100644
index 0000000000..a54b133da6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -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 policy extension
+org.apache.tuscany.sca.binding.jms.policy.authentication.token.provider.JMSTokenAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
new file mode 100644
index 0000000000..4baf7ff14e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
@@ -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.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime.WireFormatJMSDefaultProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault
+org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime.WireFormatJMSTextXMLProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML
+org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime.WireFormatJMSBytesProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes
+org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime.WireFormatJMSBytesXMLProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXML
+org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime.WireFormatJMSTextProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText
+org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime.WireFormatJMSObjectProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..a3a2f0bf1e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldClientImpl implements HelloWorldService {
+
+ private HelloWorldService serviceA;
+
+ @Reference
+ public void setServiceA(HelloWorldService service) {
+ this.serviceA = service;
+ }
+
+ public String sayHello(String name) {
+ return serviceA.sayHello(name);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..d68270f7df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.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.sca.binding.jms;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Interface for the HelloWorld Service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface HelloWorldService {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..a8808c1bd1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.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.binding.jms;
+
+/**
+ * Implementation of the HelloWorldService.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "jmsHello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
new file mode 100644
index 0000000000..5b59389a18
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
@@ -0,0 +1,229 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.junit.Test;
+
+/**
+ * This unit test is used to ensure that a JMS Message delivered to a Component will select the correct operation based
+ * on the details in section 1.5 of the JMS Binding specification.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectionTestCaseFIXME {
+ /**
+ * This test attempts to invoke a Service with a Single method where scaOperationName is not specified in the JMS
+ * Message
+ * <p>
+ * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithOnlyOneOperationScaOperationNameNotSpecified() throws Exception {
+ // Create the operation we should match
+ final Operation expectedOperation = newOperation("myOperation");
+
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ operations.add(expectedOperation);
+
+ // The name of the Operation in the JMS Message - not specified
+ final String scaOperationName = null;
+
+ // Do the test
+ doTestJMSBinding(expectedOperation, operations, scaOperationName);
+ }
+
+ /**
+ * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message matches the
+ * method name on the Service
+ * <p>
+ * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithOnlyOneOperationScaOperationNameMatches() throws Exception {
+ // Create the operation we should match
+ final Operation expectedOperation = newOperation("myOperation");
+
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ operations.add(expectedOperation);
+
+ // The name of the Operation in the JMS Message - matches operation name
+ final String scaOperationName = expectedOperation.getName();
+
+ // Do the test
+ doTestJMSBinding(expectedOperation, operations, scaOperationName);
+ }
+
+ /**
+ * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message is
+ * different the method name on the Service
+ * <p>
+ * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithOnlyOneOperationScaOperationNameDifferent() throws Exception {
+ // Create the operation we should match
+ final Operation expectedOperation = newOperation("myOperation");
+
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ operations.add(expectedOperation);
+
+ // The name of the Operation in the JMS Message - different to operation name
+ final String scaOperationName = "Does Not Match Opeation Name";
+
+ // Do the test
+ doTestJMSBinding(expectedOperation, operations, scaOperationName);
+ }
+
+ /**
+ * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS
+ * Message matches an operation name
+ * <p>
+ * Expected behaviour is that the named method will be invoked.
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithMultipleOperationsScaOperationNameSpecified() throws Exception {
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ for (int i = 0; i < 5; i++) {
+ operations.add(newOperation("operation" + i));
+ }
+
+ // Now try and invoke each operation
+ for (Operation expectedOperation : operations) {
+ // The name of the Operation in the JMS Message
+ final String scaOperationName = expectedOperation.getName();
+
+ // Do the test
+ doTestJMSBinding(expectedOperation, operations, scaOperationName);
+ }
+ }
+
+ /**
+ * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS
+ * Message is not set so we invoke the onMessage() method
+ * <p>
+ * Expected behaviour is that the onMessage() method should be used instead
+ *
+ * @throws Exception Failed
+ */
+ @Test
+ public void testServiceWithMultipleOperationsScaOperationNotSpecified() throws Exception {
+ // Create the list of operations for the Service
+ final List<Operation> operations = new ArrayList<Operation>();
+ for (int i = 0; i < 5; i++) {
+ operations.add(newOperation("operation" + i));
+ }
+
+ // Add the onMessage operation to the Service Contract
+ final Operation onMessageOperation = newOperation("onMessage");
+ operations.add(onMessageOperation);
+
+ // The name of the Operation in the JMS Message is not set so it will attempt
+ // to invoke the onMessage() method
+ final String scaOperationName = null;
+
+ // Do the test
+ doTestJMSBinding(onMessageOperation, operations, scaOperationName);
+ }
+
+ /**
+ * This is the test method that will attempt to unit test invoking a Service with the specified operations using a
+ * JMS Message with the specified scaOperationName to ensure that it invokes the expectedOperation
+ *
+ * @param expectedOperation The Operation we are expecting to be invoked over JMS
+ * @param operations The list of Operations supported by the Service
+ * @param scaOperationName The value to set scaOperationName in the JMS Message
+ * @throws Exception Failed
+ */
+ private void doTestJMSBinding(Operation expectedOperation, List<Operation> operations, String scaOperationName)
+ throws Exception {
+ // Create the test JMS Binding
+ final JMSBinding jmsBinding = new JMSBinding();
+ JMSResourceFactory jmsResourceFactory = null;
+
+ // Extra information for the method we are invoking
+ final String operationParams = "Hello";
+ final Object operationReturnValue = "Operation Success";
+
+ // Mock up the Service. Basically, it is going to call:
+ // List<Operation> opList = service.getInterfaceContract().getInterface().getOperations();
+// final InterfaceContract ifaceContract = EasyMock.createStrictMock(InterfaceContract.class);
+// final RuntimeComponentService service = EasyMock.createStrictMock(RuntimeComponentService.class);
+// final Interface iface = EasyMock.createStrictMock(Interface.class);
+// EasyMock.expect(iface.getOperations()).andReturn(operations);
+// EasyMock.expect(ifaceContract.getInterface()).andReturn(iface);
+// EasyMock.expect(service.getInterfaceContract()).andReturn(ifaceContract);
+//
+// // Mock up getting and invoking the RuntimeWire. It is going to call:
+// // service.getRuntimeWire(jmsBinding).invoke(operation, (Object[])requestPayload);
+// final RuntimeWire runtimeWire = EasyMock.createStrictMock(RuntimeWire.class);
+// EasyMock.expect(service.getRuntimeWire(jmsBinding)).andReturn(runtimeWire);
+// EasyMock.expect(runtimeWire.invoke(expectedOperation, new Object[] {operationParams}))
+// .andReturn(operationReturnValue);
+//
+// // Create the JMS Binding Listener
+// // final DefaultJMSBindingListener bindingListener = new DefaultJMSBindingListener(jmsBinding, jmsResourceFactory, service, null);
+//
+// // Simulate a message
+// final TextMessage requestJMSMsg = EasyMock.createStrictMock(TextMessage.class);
+// EasyMock.expect(requestJMSMsg.getStringProperty("scaOperationName")).andReturn(scaOperationName);
+// EasyMock.expect(requestJMSMsg.getText()).andReturn(operationParams);
+// EasyMock.expect(requestJMSMsg.getJMSReplyTo()).andReturn(null);
+//
+// // Lets put all the mocks into replay mode
+// // EasyMock.replay(iface);
+// EasyMock.replay(ifaceContract);
+// EasyMock.replay(service);
+// EasyMock.replay(requestJMSMsg);
+// EasyMock.replay(runtimeWire);
+
+ // Do the test
+ // bindingListener.onMessage(requestJMSMsg);
+
+ // Verify our Mock objects
+ // EasyMock.verify(iface);
+ // EasyMock.verify(ifaceContract);
+ // EasyMock.verify(service);
+ // EasyMock.verify(requestJMSMsg);
+ // EasyMock.verify(runtimeWire);
+ }
+
+ private static Operation newOperation(String name) {
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+ return operation;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/resources/simple/client.composite b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/resources/simple/client.composite
new file mode 100644
index 0000000000..dcea428493
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/resources/simple/client.composite
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="RPCComposite">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>
+ <reference name="serviceA" />
+ </component>
+
+ <reference name="serviceA" promote="HelloWorldClient/serviceA">
+ <interface.java interface="org.apache.tuscany.sca.binding.jms.HelloWorldService" />
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61616">
+ <destination name="DestQueueA"/>
+ <response>
+ <destination name="RespQueueA"/>
+ </response>
+ </binding.jms>
+ </reference>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/resources/simple/service.composite b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/resources/simple/service.composite
new file mode 100644
index 0000000000..44b7b29610
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms-runtime/src/test/resources/simple/service.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"
+ name="RPCComposite">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
+ <service name="HelloWorldService">
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61616">
+ <destination name="DestQueueA" create="always"/>
+ <response>
+ <destination name="RespQueueA" create="always"/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/LICENSE b/sandbox/sebastien/java/embed/modules/binding-jms/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/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/sebastien/java/embed/modules/binding-jms/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-jms/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9b6da67343
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/META-INF/MANIFEST.MF
@@ -0,0 +1,62 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.jms;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.binding.jms.operationselector;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.binding.jms.policy;version="2.0.0",
+ org.apache.tuscany.sca.binding.jms.policy.authentication.token;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.binding.jms.policy.header;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.binding.jms.wireformat;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.namespace"
+Private-Package: org.apache.tuscany.sca.binding.jms.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JMS Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JMS Binding Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.binding.jms;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.jms
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/NOTICE b/sandbox/sebastien/java/embed/modules/binding-jms/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/pom.xml b/sandbox/sebastien/java/embed/modules/binding-jms/pom.xml
new file mode 100644
index 0000000000..dc3133cfd2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/pom.xml
@@ -0,0 +1,51 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-jms</artifactId>
+ <name>Apache Tuscany SCA JMS Binding Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java
new file mode 100644
index 0000000000..7aa62215ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+public class BindingProperty {
+
+ private String name;
+ private String type;
+ private Object value;
+
+ public BindingProperty(String name, String type, Object value) {
+ this.name = name;
+ this.type = type;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return (object instanceof BindingProperty) && equals((BindingProperty)object);
+ }
+
+ /**
+ * Test whether this and another Binding Property are equal.
+ *
+ * @param property
+ * @return true if all fields of property match.
+ */
+ public boolean equals(BindingProperty property) {
+ if (name == null && property.getName() != null)
+ return false;
+ else if (!name.equals(property.getName()))
+ return false;
+ else if (type == null && property.getType() != null)
+ return false;
+ else if (!type.equals(property.getType()))
+ return false;
+ else if (value == null && property.getValue() != null)
+ return false;
+ else if (!value.equals(property.getValue()))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
new file mode 100644
index 0000000000..977ef17d52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
@@ -0,0 +1,982 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Models a binding to a JMS resource.
+ *
+ * @version $Rev$ $Date$
+ */
+
+//public class JMSBinding implements BindingRRB, PolicySubject, OperationsConfigurator, DefinitionElement {
+public class JMSBinding implements Binding, PolicySubject, OperationsConfigurator {
+ QName TYPE = new QName(SCA11_NS, "binding.jms");
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ // properties required to implement the Tuscany binding extension SPI
+ private String uri = null;
+ private String name = null;
+ private boolean unresolved = false;
+ private List<Object> extensions = new ArrayList<Object>();
+
+ // properties required by PolicySetAttachPoint
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ // properties required by IntentAttachPoint
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+
+ // properties required to describe configured operations
+ private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
+
+ // properties required by DefinitionElement @575803A
+ private String targetNamespace;
+
+ // Properties required to describe the JMS binding model
+
+ private String correlationScheme = JMSBindingConstants.CORRELATE_MSG_ID;
+ private String initialContextFactoryName;
+ private String jndiURL;
+
+ private String destinationName = null;
+ private String destinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE;
+ private String destinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
+ private Map<String, BindingProperty> destinationProperties = new HashMap<String, BindingProperty>();
+
+ private String connectionFactoryName = null;
+ private String connectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
+ private Map<String, BindingProperty> connectionFactoryProperties = new HashMap<String, BindingProperty>();
+
+ private String activationSpecName = null;
+ private String activationSpecCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
+ private Map<String, BindingProperty> activationSpecProperties = new HashMap<String, BindingProperty>();
+
+ private String resourceAdapterName;;
+ private Map<String, BindingProperty> resourceAdapterProperties = new HashMap<String, BindingProperty>();
+
+ private String responseActivationSpecName = null;
+ private String responseActivationSpecCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
+ private Map<String, BindingProperty> responseActivationSpecProperties = new HashMap<String, BindingProperty>();
+
+ private String responseDestinationName = null;
+ private String responseDestinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE;
+ private String responseDestinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
+ private Map<String, BindingProperty> responseDestinationProperties = new HashMap<String, BindingProperty>();
+
+ private String responseConnectionFactoryName = null;
+ private String responseConnectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
+ private Map<String, BindingProperty> responseConnectionFactoryProperties = new HashMap<String, BindingProperty>();
+
+ // Provides the name of the factory that interfaces to the JMS API for us.
+ private String jmsResourceFactoryName = JMSBindingConstants.DEFAULT_RF_CLASSNAME;
+
+ // Message processors used to deal with the request and response messages
+ public String requestMessageProcessorName = JMSBindingConstants.DEFAULT_MP_CLASSNAME;
+ public String responseMessageProcessorName = JMSBindingConstants.DEFAULT_MP_CLASSNAME;
+
+ // The JMS message property used to hold the name of the operation being called
+ private String operationSelectorPropertyName = JMSBindingConstants.DEFAULT_OPERATION_PROP_NAME;
+
+ // If the operation selector is derived automatically from the service interface it's stored here
+ private String operationSelectorName = null;
+
+ private boolean containsHeaders = false;
+ private String replyTo;
+ private String jmsType;
+ private String jmsCorrelationId;
+ private Boolean deliveryModePersistent;
+ private Long timeToLive;
+ private Integer jmsPriority;
+
+ private Map<String, Object> properties = new HashMap<String, Object>();
+ private Map<String, Map<String, Object>> operationProperties = new HashMap<String, Map<String,Object>>();
+ private Map<String, String> nativeOperationNames = new HashMap<String, String>();
+ private Map<String, String> operationJMSTypes = new HashMap<String, String>();
+ private Map<String, String> operationJMSCorrelationIds = new HashMap<String, String>();
+ private Map<String, Boolean> operationJMSDeliveryModes = new HashMap<String, Boolean>();
+ private Map<String, Long> operationJMSTimeToLives = new HashMap<String, Long>();
+ private Map<String, Integer> operationJMSPriorities = new HashMap<String, Integer>();
+ private Map<String, Map<String, BindingProperty>> operationPropertiesProperties = new HashMap<String, Map<String,BindingProperty>>();
+
+ private String jmsSelector;
+ private QName requestConnectionName;
+ private QName responseConnectionName;
+ private QName operationPropertiesName;
+ private JMSBinding requestConnectionBinding;
+ private JMSBinding responseConnectionBinding;
+ private JMSBinding operationPropertiesBinding;
+
+ private WireFormat requestWireFormat;
+ private WireFormat responseWireFormat;
+ private OperationSelector operationSelector;
+ private ExtensionType extensionType;
+ private String jmsURI;
+
+ public JMSBinding() {
+ super();
+ }
+
+ // operations required by Binding
+ public String getURI() {
+ return this.uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isUnresolved() {
+ return this.unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return requestWireFormat;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ this.requestWireFormat = wireFormat;
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return responseWireFormat;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ this.responseWireFormat = wireFormat;
+ }
+
+ public OperationSelector getOperationSelector() {
+ return operationSelector;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ this.operationSelector = operationSelector;
+ }
+
+ // Methods for getting/setting JMS binding model information
+ // as derived from the XML of the binding.jms element
+
+ public void setCorrelationScheme(String correlationScheme) {
+ this.correlationScheme = correlationScheme;
+ }
+
+ public String getCorrelationScheme() {
+ return correlationScheme;
+ }
+
+ public String getInitialContextFactoryName() {
+ return initialContextFactoryName;
+ }
+
+ public void setInitialContextFactoryName(String initialContextFactoryName) {
+ this.initialContextFactoryName = initialContextFactoryName;
+ }
+
+ public String getJndiURL() {
+ return this.jndiURL;
+ }
+
+ public void setJndiURL(String jndiURL) {
+ this.jndiURL = jndiURL;
+ }
+
+ public String getDestinationName() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getDestinationName() != null) {
+ return requestConnectionBinding.getDestinationName();
+ } else {
+ return destinationName;
+ }
+ }
+
+ public void setDestinationName(String destinationName) {
+ this.destinationName = destinationName;
+ }
+
+ public String getDestinationType() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getDestinationType() != null) {
+ return requestConnectionBinding.getDestinationType();
+ } else {
+ return destinationType;
+ }
+ }
+
+ public void setDestinationType(String destinationType) {
+ this.destinationType = destinationType;
+ }
+
+ public String getDestinationCreate() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getDestinationCreate() != null) {
+ return requestConnectionBinding.getDestinationCreate();
+ } else {
+ return this.destinationCreate;
+ }
+ }
+
+ public void setDestinationCreate(String create) {
+ this.destinationCreate = create;
+ }
+
+ public String getConnectionFactoryName() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryName() != null) {
+ return requestConnectionBinding.getConnectionFactoryName();
+ } else {
+ return connectionFactoryName;
+ }
+ }
+
+ public void setConnectionFactoryName(String connectionFactoryName) {
+ this.connectionFactoryName = connectionFactoryName;
+ }
+
+ public String getConnectionFactoryCreate() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryCreate() != null) {
+ return requestConnectionBinding.getConnectionFactoryCreate();
+ } else {
+ return this.connectionFactoryCreate;
+ }
+ }
+
+ public void setConnectionFactoryCreate(String create) {
+ this.connectionFactoryCreate = create;
+ }
+
+ public String getResourceAdapterName() {
+ return resourceAdapterName;
+ }
+
+ public void setResourceAdapterName(String name) {
+ resourceAdapterName = name;
+ }
+
+ public String getActivationSpecName() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getActivationSpecName() != null) {
+ return requestConnectionBinding.getActivationSpecName();
+ } else {
+ return activationSpecName;
+ }
+ }
+
+ public void setActivationSpecName(String activationSpecName) {
+ this.activationSpecName = activationSpecName;
+ }
+
+ public String getActivationSpecCreate() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getActivationSpecCreate() != null) {
+ return requestConnectionBinding.getActivationSpecCreate();
+ } else {
+ return this.activationSpecCreate;
+ }
+ }
+
+ public void setActivationSpecCreate(String create) {
+ this.activationSpecCreate = create;
+ }
+
+ public String getResponseDestinationName() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationName() != null) {
+ return requestConnectionBinding.getResponseDestinationName();
+ } else {
+ return this.responseDestinationName;
+ }
+ }
+
+ public void setResponseDestinationName(String name) {
+ this.responseDestinationName = name;
+ }
+
+ public String getResponseDestinationType() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationType() != null) {
+ return requestConnectionBinding.getResponseDestinationType();
+ } else {
+ return this.responseDestinationType;
+ }
+ }
+
+ public void setResponseDestinationType(String type) {
+ this.responseDestinationType = type;
+ }
+
+ public String getResponseDestinationCreate() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationCreate() != null) {
+ return requestConnectionBinding.getResponseDestinationCreate();
+ } else {
+ return this.responseDestinationCreate;
+ }
+ }
+
+ public void setResponseDestinationCreate(String create) {
+ this.responseDestinationCreate = create;
+ }
+
+ public String getResponseConnectionFactoryName() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryName() != null) {
+ return requestConnectionBinding.getResponseConnectionFactoryName();
+ } else {
+ return responseConnectionFactoryName;
+ }
+ }
+
+ public void setResponseConnectionFactoryName(String connectionFactoryName) {
+ this.responseConnectionFactoryName = connectionFactoryName;
+ }
+
+ public String getResponseConnectionFactoryCreate() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryCreate() != null) {
+ return requestConnectionBinding.getResponseConnectionFactoryCreate();
+ } else {
+ return this.responseConnectionFactoryCreate;
+ }
+ }
+
+ public void setResponseConnectionFactoryCreate(String create) {
+ this.responseConnectionFactoryCreate = create;
+ }
+
+ public String getResponseActivationSpecName() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getResponseActivationSpecName() != null) {
+ return requestConnectionBinding.getResponseActivationSpecName();
+ } else {
+ return responseActivationSpecName;
+ }
+ }
+
+ public void setResponseActivationSpecName(String activationSpecName) {
+ this.responseActivationSpecName = activationSpecName;
+ }
+
+ public String getResponseActivationSpecCreate() {
+ if (requestConnectionBinding != null && requestConnectionBinding.getResponseActivationSpecCreate() != null) {
+ return requestConnectionBinding.getResponseActivationSpecCreate();
+ } else {
+ return this.responseActivationSpecCreate;
+ }
+ }
+
+ public void setResponseActivationSpecCreate(String create) {
+ this.responseActivationSpecCreate = create;
+ }
+
+ public String getJmsResourceFactoryName() {
+ return jmsResourceFactoryName;
+ }
+
+ public void setJmsResourceFactoryName(String jmsResourceFactoryName) {
+ this.jmsResourceFactoryName = jmsResourceFactoryName;
+ }
+
+ public void setRequestMessageProcessorName(String name) {
+ this.requestMessageProcessorName = name;
+ }
+
+ public String getRequestMessageProcessorName() {
+ return requestMessageProcessorName;
+ }
+
+ public void setResponseMessageProcessorName(String name) {
+ this.responseMessageProcessorName = name;
+ }
+
+ public String getResponseMessageProcessorName() {
+ return responseMessageProcessorName;
+ }
+
+ public String getOperationSelectorPropertyName() {
+ return operationSelectorPropertyName;
+ }
+
+ public void setOperationSelectorPropertyName(String operationSelectorPropertyName) {
+ this.operationSelectorPropertyName = operationSelectorPropertyName;
+ }
+
+ public String getOperationSelectorName() {
+ return operationSelectorName;
+ }
+
+ public void setOperationSelectorName(String operationSelectorName) {
+ this.operationSelectorName = operationSelectorName;
+ }
+
+ public void setHeaders( boolean containsHeaders ) {
+ this.containsHeaders = containsHeaders;
+ }
+
+ public boolean containsHeaders() {
+ return this.containsHeaders;
+ }
+
+ public String getReplyTo() {
+ return replyTo;
+ }
+
+ public void setReplyTo(String replyTo) {
+ this.replyTo = replyTo;
+ }
+
+ public String getJMSType() {
+ return jmsType;
+ }
+ public void setJMSType(String jmsType) {
+ setHeaders( true );
+ this.jmsType = jmsType;
+ }
+
+ public String getJMSCorrelationId() {
+ return jmsCorrelationId;
+ }
+
+ public void setJMSCorrelationId(String jmsCorrelationId) {
+ setHeaders( true );
+ this.jmsCorrelationId = jmsCorrelationId;
+ }
+
+ public Boolean isdeliveryModePersistent() {
+ return deliveryModePersistent;
+ }
+ public void setJMSDeliveryMode(boolean persistent) {
+ setHeaders( true );
+ this.deliveryModePersistent = Boolean.valueOf(persistent);
+ }
+
+ public Integer getJMSPriority() {
+ return jmsPriority;
+ }
+
+ public void setJMSPriority(int jmsPriority) {
+ setHeaders( true );
+ this.jmsPriority = Integer.valueOf(jmsPriority);
+ }
+
+ public Long getJMSTimeToLive() {
+ return timeToLive;
+ }
+
+ public void setJMSTimeToLive(long timeToLive) {
+ setHeaders( true );
+ this.timeToLive = Long.valueOf(timeToLive);
+ }
+
+ public Set<String> getPropertyNames() {
+ return properties.keySet();
+ }
+
+ public Object getProperty(String name) {
+ return properties.get(name);
+ }
+
+ public void setProperty(String name, Object value) {
+ properties.put(name, value);
+ }
+
+ protected Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ /**
+ * Adds an operationName to this binding.
+ * @param opName
+ */
+ public void addOperationName(String opName) {
+ Map<String, Object> props = operationProperties.get(opName);
+ if (props == null) {
+ props = new HashMap<String, Object>();
+ operationProperties.put(opName, props);
+ }
+ }
+
+ /**
+ * Provides set of operation names in this binding.
+ * @return a Set<String> of operation names
+ */
+ public Set<String> getOperationNames() {
+ if (operationPropertiesBinding != null) {
+ return operationPropertiesBinding.getOperationNames();
+ } else {
+ // Make a defensive copy since key changes affect map, map changes affect keys.
+ Set<String> opNames = operationProperties.keySet();
+ Set<String> opNamesCopy = new TreeSet<String>( opNames );
+ return opNamesCopy;
+ }
+ }
+
+ public Map<String, Object> getOperationProperties(String opName) {
+ if (operationPropertiesBinding != null) {
+ return operationPropertiesBinding.getOperationProperties(opName);
+ } else {
+ return operationProperties.get(opName);
+ }
+ }
+
+ public void setOperationProperty(String opName, String propName, Object value) {
+ Map<String, Object> props = operationProperties.get(opName);
+ if (props == null) {
+ props = new HashMap<String, Object>();
+ operationProperties.put(opName, props);
+ }
+ props.put(propName, value);
+ }
+
+ /**
+ * Provides the value of a property for a given operation
+ * @param opName is the name of the operation in this binding.
+ * @param propName is the key name for the property
+ * @return Object representing the property value for this property name. Returns
+ * null for non existant operation name or property name.
+ */
+ public Object getOperationProperty(String opName, String propName ) {
+ if (operationPropertiesBinding != null) {
+ return operationPropertiesBinding.getOperationProperty(opName, propName);
+ } else {
+ Map<String, Object> props = operationProperties.get(opName);
+ if (props == null) {
+ return null;
+ }
+ return props.get(propName);
+ }
+ }
+
+ public boolean hasNativeOperationName(String opName) {
+ if (operationPropertiesBinding != null) {
+ return operationPropertiesBinding.hasNativeOperationName(opName);
+ } else {
+ return nativeOperationNames.containsKey(opName);
+ }
+ }
+
+ public String getNativeOperationName(String opName) {
+ if (operationPropertiesBinding != null && operationPropertiesBinding.getNativeOperationName(opName) != null) {
+ return operationPropertiesBinding.getNativeOperationName(opName);
+ } else {
+ if (nativeOperationNames.containsKey(opName)) {
+ return nativeOperationNames.get(opName);
+ } else {
+ return opName;
+ }
+ }
+ }
+
+ public void setNativeOperationName(String opName, String nativeOpName) {
+ this.nativeOperationNames .put(opName, nativeOpName);
+ }
+
+ public String getOperationJMSType(String opName) {
+ if (operationPropertiesBinding != null && operationPropertiesBinding.getOperationJMSType(opName) != null) {
+ return operationPropertiesBinding.getOperationJMSType(opName);
+ } else {
+ if (operationJMSTypes.containsKey(opName)) {
+ return operationJMSTypes.get(opName);
+ } else {
+ return jmsType;
+ }
+ }
+ }
+ public void setOperationJMSType(String opName, String jmsType) {
+ this.operationJMSTypes.put(opName, jmsType);
+ }
+
+ public String getOperationJMSCorrelationId(String opName) {
+ if (operationPropertiesBinding != null) {
+ if (operationPropertiesBinding.getOperationJMSCorrelationId(opName) != null) {
+ return operationPropertiesBinding.getOperationJMSCorrelationId(opName);
+ } else {
+ return jmsCorrelationId;
+ }
+ } else {
+ if (operationJMSCorrelationIds.containsKey(opName)) {
+ return operationJMSCorrelationIds.get(opName);
+ } else {
+ return jmsCorrelationId;
+ }
+ }
+ }
+ public void setOperationJMSCorrelationId(String opName, String jmsCorrelationId) {
+ operationJMSCorrelationIds.put(opName, jmsCorrelationId);
+ }
+
+ public Boolean getOperationJMSDeliveryMode(String opName) {
+ if (operationPropertiesBinding != null) {
+ if (operationPropertiesBinding.getOperationJMSDeliveryMode(opName) != null) {
+ return operationPropertiesBinding.getOperationJMSDeliveryMode(opName);
+ } else {
+ return deliveryModePersistent;
+ }
+ } else {
+ if (operationJMSDeliveryModes.containsKey(opName)) {
+ return operationJMSDeliveryModes.get(opName);
+ } else {
+ return deliveryModePersistent;
+ }
+ }
+ }
+ public void setOperationJMSDeliveryMode(String opName, boolean b) {
+ operationJMSDeliveryModes.put(opName, b);
+ }
+
+ public Long getOperationJMSTimeToLive(String opName) {
+ if (operationPropertiesBinding != null) {
+ if (operationPropertiesBinding.getOperationJMSTimeToLive(opName) != null) {
+ return operationPropertiesBinding.getOperationJMSTimeToLive(opName);
+ } else {
+ return timeToLive;
+ }
+ } else {
+ if (operationJMSTimeToLives.containsKey(opName)) {
+ return operationJMSTimeToLives.get(opName);
+ } else {
+ return timeToLive;
+ }
+ }
+ }
+ public void setOperationJMSTimeToLive(String opName, Long ttl) {
+ operationJMSTimeToLives.put(opName, ttl);
+ }
+
+ public Integer getOperationJMSPriority(String opName) {
+ if (operationPropertiesBinding != null) {
+ if (operationPropertiesBinding.getOperationJMSPriority(opName) != null) {
+ return operationPropertiesBinding.getOperationJMSPriority(opName);
+ } else {
+ return jmsPriority;
+ }
+ } else {
+ if (operationJMSPriorities.containsKey(opName)) {
+ return operationJMSPriorities.get(opName);
+ } else {
+ return jmsPriority;
+ }
+ }
+ }
+ public void setOperationJMSPriority(String opName, int p) {
+ operationJMSPriorities.put(opName, p);
+ }
+
+ public String getJMSSelector() {
+ return jmsSelector;
+ }
+ public void setJMSSelector(String jmsSelector) {
+ this.jmsSelector = jmsSelector;
+ }
+
+ public QName getRequestConnectionName() {
+ return requestConnectionName;
+ }
+
+ public void setRequestConnectionName(QName requestConnectionName) {
+ this.requestConnectionName = requestConnectionName;
+ }
+
+ public void setResponseConnectionName(QName responseConnectionName) {
+ this.responseConnectionName = responseConnectionName;
+ }
+
+ public QName getResponseConnectionName() {
+ return responseConnectionName;
+ }
+
+ public void setRequestConnectionBinding(JMSBinding binding) {
+ this.requestConnectionBinding = binding;
+ }
+ public JMSBinding getRequestConnectionBinding() {
+ return requestConnectionBinding;
+ }
+
+ public void setResponseConnectionBinding(JMSBinding binding) {
+ this.responseConnectionBinding = binding;
+ }
+ public JMSBinding getResponseConnectionBinding() {
+ return responseConnectionBinding;
+ }
+
+ public void setOperationPropertiesName(QName nameValue) {
+ this.operationPropertiesName = nameValue;
+ }
+ public QName getOperationPropertiesName() {
+ return operationPropertiesName;
+ }
+
+ public void setOperationPropertiesBinding(JMSBinding binding) {
+ this.operationPropertiesBinding = binding;
+ }
+ public JMSBinding getOperationPropertiesBinding() {
+ return operationPropertiesBinding;
+ }
+
+ // operations required by PolicySetAttachPoint
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ // operations required by IntentAttachPoint
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public Map<String, BindingProperty> getDestinationProperties() {
+ return destinationProperties;
+ }
+
+ public Map<String, BindingProperty> getConnectionFactoryProperties() {
+ return connectionFactoryProperties;
+ }
+
+ public Map<String, BindingProperty> getResourceAdapterProperties() {
+ return resourceAdapterProperties;
+ }
+
+ public Map<String, BindingProperty> getActivationSpecProperties() {
+ return activationSpecProperties;
+ }
+
+ public Map<String, BindingProperty> getResponseActivationSpecProperties() {
+ return responseActivationSpecProperties;
+ }
+
+ public Map<String, BindingProperty> getResponseDestinationProperties() {
+ return responseDestinationProperties;
+ }
+
+ public Map<String, BindingProperty> getResponseConnectionFactoryProperties() {
+ return responseConnectionFactoryProperties;
+ }
+
+ public Map<String, BindingProperty> getOperationPropertiesProperties(String opName) {
+ if (operationPropertiesProperties.get(opName)==null) {
+ operationPropertiesProperties.put(opName, new HashMap<String, BindingProperty>());
+ }
+ return operationPropertiesProperties.get(opName);
+ }
+
+ public List<ConfiguredOperation> getConfiguredOperations() {
+ return configuredOperations;
+ }
+
+ public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations) {
+ this.configuredOperations = configuredOperations;
+ }
+
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String ns) {
+ targetNamespace = ns;
+ }
+
+ // hashCode() is here because binding elements in definitions documents are added
+ // to the model resolver hashmap. The namespace and name are keys.
+ @Override
+ public int hashCode() {
+ return (String.valueOf(getTargetNamespace()) + String.valueOf(getName())).hashCode();
+ }
+
+ @Override
+ public boolean equals( Object object ) {
+ return ( object instanceof JMSBinding ) && equals( (JMSBinding) object );
+ }
+
+ /**
+ * Compares two JMS bindings for equality.
+ * Because of the many fields, this comparison is rather large O(n).
+ * @param binding test binding for equality comparison
+ * @return boolean stating whether objects are equal
+ */
+ public boolean equals( JMSBinding binding ) {
+ // If the target namespace is set, this binding came from a definitions document.
+ // The target namespace and name are used as keys for doing model resolver hashmap lookups.
+ // Only the target namespace and name can be compared.
+ if (this.targetNamespace != null) {
+ if ( !optStringEquals( this.targetNamespace, binding.getTargetNamespace() )) return false;
+ if ( !optStringEquals( this.name, binding.getName() )) return false;
+ return true;
+ }
+
+ // Test all fields for equality.
+ // First test simple fields to quickly weed out mismatches.
+ if ( !optStringEquals( this.uri, binding.getURI() )) return false;
+ if ( !optStringEquals( this.name, binding.getName() )) return false;
+ if ( !optStringEquals( this.targetNamespace, binding.getTargetNamespace() )) return false;
+ if ( !optStringEquals( this.destinationName, binding.getDestinationName() )) return false;
+ if ( !optStringEquals( this.correlationScheme, binding.getCorrelationScheme() )) return false;
+ if ( !optStringEquals( this.initialContextFactoryName, binding.getInitialContextFactoryName() )) return false;
+ if ( !optStringEquals( this.jndiURL, binding.getJndiURL() )) return false;
+ if ( !optStringEquals( this.requestConnectionName, binding.getRequestConnectionName() )) return false;
+ if ( !optStringEquals( this.responseConnectionName, binding.getResponseConnectionName() )) return false;
+ if ( !optStringEquals( this.jmsSelector, binding.getJMSSelector() )) return false;
+ if ( !equals( properties, binding.getProperties()) )
+ return false;
+
+ // Test operation properties
+ Set<String> operationNamesA = this.getOperationNames();
+ Set<String> operationNamesB = binding.getOperationNames();
+ if ( operationNamesA != null && operationNamesB != null ) {
+ if ( operationNamesA == null && operationNamesB != null ) return false;
+ if ( operationNamesA != null && operationNamesB == null ) return false;
+ if ( operationNamesA.size() != operationNamesB.size() ) return false;
+ for(Iterator<String> it=operationNamesA.iterator(); it.hasNext(); ) {
+ String opName = it.next();
+ if ( !operationNamesB.contains( opName )) {
+ return false;
+ }
+ }
+ }
+
+ // Destination properties
+ if ( !optStringEquals( this.getDestinationName(), binding.getDestinationName() )) return false;
+ if ( !optStringEquals( this.getDestinationType(), binding.getDestinationType() )) return false;
+
+ // Connection factory properties
+ if ( !optStringEquals( this.getConnectionFactoryName(), binding.getConnectionFactoryName() )) return false;
+
+ // Activation spec properties
+ if ( !optStringEquals( this.getActivationSpecName(), binding.getActivationSpecName() )) return false;
+
+ // Response properties
+ if ( !optStringEquals( this.getResponseDestinationName(), binding.getResponseDestinationName() )) return false;
+ if ( !optStringEquals( this.getResponseActivationSpecName(), binding.getResponseActivationSpecName() )) return false;
+ if ( !optStringEquals( this.getResponseConnectionFactoryName(), binding.getResponseConnectionFactoryName() )) return false;
+
+ // Resource adapter
+ if ( !optStringEquals( this.getResourceAdapterName(), binding.getResourceAdapterName() )) return false;
+
+ // Configured operations
+ if ( this.configuredOperations.size() != binding.getConfiguredOperations().size() ) return false;
+
+ // wire format
+ if ( this.getRequestWireFormat().getClass() != binding.getRequestWireFormat().getClass()) return false;
+ if ( this.getResponseWireFormat().getClass() != binding.getResponseWireFormat().getClass()) return false;
+
+ // operation selector
+ if ( this.getOperationSelector().getClass() != binding.getOperationSelector().getClass()) return false;
+
+
+ // Other fields could also be checked for equality. See class fields for details.
+ return true;
+ }
+
+ /**
+ * Tests if Strings are equal.
+ * Either one may be null. This will match true if both
+ * are null or both are non-null and equal.
+ * @param p1 property list 1
+ * @param p2 property list 2
+ * @return whether or not properties are equal
+ */
+ public static boolean optStringEquals( Object s1, Object s2 ) {
+ if ( s1 == null && s2 == null ) return true;
+ if ( s1 != null && s2 == null ) return false;
+ if ( s1 == null && s2 != null ) return false;
+ return s1.equals( s2 );
+ }
+
+ /**
+ * Tests if two property lists are equal.
+ * Either one may be null. This will match true if both
+ * are null or both are non-null and equal.
+ * @param p1 property list 1
+ * @param p2 property list 2
+ * @return whether or not properties are equal
+ */
+ public static boolean equals( Map<String, Object> p1, Map<String, Object> p2 ) {
+ if ( p1 == null && p2 == null)
+ return true;
+ if ( p1 == null || p2 == null)
+ return false;
+ if ( p1.size() != p2.size())
+ return false;
+
+ // For both the keys and values of a map
+ for (Iterator it=p1.entrySet().iterator(); it.hasNext(); ) {
+ Map.Entry entry = (Map.Entry)it.next();
+ Object k1 = entry.getKey();
+ Object v1 = entry.getValue();
+ Object v2 = p2.get( k1 );
+
+ if ( v1 == null && v2 != null )
+ return false;
+ if ( v1 != null && v2 == null )
+ return false;
+ if ( !v1.equals( v2 ))
+ return false;
+ }
+
+ return true;
+ }
+
+ public ExtensionType getExtensionType() {
+ return extensionType;
+ }
+
+ public void setExtensionType(ExtensionType intentAttachPointType) {
+ this.extensionType = intentAttachPointType;
+ }
+
+ public String getJMSURI() {
+ return jmsURI;
+ }
+ public void setJMSURI(String jmsURI) {
+ this.jmsURI = jmsURI;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java
new file mode 100644
index 0000000000..25fbefa0a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.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.sca.binding.jms;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Constants for the JMS binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JMSBindingConstants {
+
+ // Constants used when describing the JMS binding
+ // model and for setting up defaults
+ String BINDING_JMS = "binding.jms";
+ QName BINDING_JMS_QNAME = new QName(Constants.SCA11_NS, BINDING_JMS);
+ String CORRELATE_MSG_ID = "requestmsgidtocorrelid";
+ String CORRELATE_CORRELATION_ID = "requestcorrelidtocorrelid";
+ String CORRELATE_NONE = "none";
+ List<String> VALID_CORRELATION_SCHEMES =
+ Arrays.asList(new String[] {CORRELATE_MSG_ID, CORRELATE_CORRELATION_ID, CORRELATE_NONE});
+ String DESTINATION_TYPE_QUEUE = "queue"; // 0
+ String DESTINATION_TYPE_TOPIC = "topic"; // 1
+ List<String> VALID_DESTINATION_TYPES =
+ Arrays.asList(new String[] {DESTINATION_TYPE_QUEUE, DESTINATION_TYPE_TOPIC});
+ String CREATE_ALWAYS = "always";
+ String CREATE_NEVER = "never";
+ String CREATE_IF_NOT_EXIST = "ifNotExist";
+ String DEFAULT_CONTEXT_FACTORY_NAME = "org.apache.activemq.jndi.ActiveMQInitialContextFactory";
+ String DEFAULT_JNDI_URL = "tcp://localhost:61616";
+ int DEFAULT_TIME_TO_LIVE = 20000; // in milliseconds
+ int DEFAULT_PRIORITY = 1;
+ int NON_PERSISTENT = 1; // Maps to javax.jms.DeliveryMode
+ String DEFAULT_RF_CLASSNAME = "org.apache.tuscany.sca.host.jms.activemq.JMSResourceFactoryImpl";
+ String XML_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor";
+ String TEXT_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.TextMessageProcessor";
+ String OBJECT_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.ObjectMessageProcessor";
+ String BYTES_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.BytesMessageProcessor";
+ String XML_BYTES_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.XMLBytesMessageProcessor";
+ String DEFAULT_MP_CLASSNAME = "org.apache.tuscany.sca.binding.jms.provider.DefaultMessageProcessor";
+ String DEFAULT_OPERATION_PROP_NAME = "scaOperationName";
+
+ String FAULT_PROPERTY = "org_apache_tuscany_sca_fault";
+
+ String CALLBACK_ID_PROPERTY = "CallbackID";
+ String CALLBACK_Q_PROPERTY = "scaCallbackDestination";
+ String CONVERSATION_ID_PROPERTY = "scaConversationId";
+
+ // XML element and attribute names
+ String HEADERS = "headers";
+
+ int MSG_CTXT_POSITION = 0;
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java
new file mode 100644
index 0000000000..74f030ca21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms;
+
+/**
+ * Base exception for the JMSBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ public JMSBindingException() {
+ super();
+ }
+
+ public JMSBindingException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ public JMSBindingException(String arg0) {
+ super(arg0);
+ }
+
+ public JMSBindingException(Throwable arg0) {
+ super(arg0);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
new file mode 100644
index 0000000000..dfb3dd9412
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
@@ -0,0 +1,1671 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+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.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.assembly.xml.ConfiguredOperationProcessor;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
+import org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSDefault;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * A processor to read the XML that describes the JMS binding...
+ *
+ * <binding.jms correlationScheme="string"?
+ * initialContextFactory="xs:anyURI"?
+ * jndiURL="xs:anyURI"?
+ * requestConnection="QName"?
+ * responseConnection="QName"?
+ * operationProperties="QName"?
+ * ...>
+ *
+ * <headers type="string"?
+ * deliveryMode="string"?
+ * timeToLive="int"?
+ * priority="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </headers>?
+ *
+ * <destination jndiName="xs:anyURI" type="string"? create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </destination>?
+ *
+ * <connectionFactory jndiName="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </connectionFactory>?
+ *
+ * <activationSpec name="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </activationSpec>?
+ *
+ * <response>
+ * <destination jndiName="xs:anyURI" type="string"? create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </destination>?
+ *
+ * <connectionFactory jndiName="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </connectionFactory>?
+ *
+ * <activationSpec name="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </activationSpec>?
+ *
+ * <wireFormat.someWireFormat/>?
+ * </response>?
+ *
+ * <complexType name="SubscriptionHeaders">
+ * <attribute name="JMSSelector" type="string"/>
+ * </complexType>
+ *
+ * <resourceAdapter name="NMTOKEN">?
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </resourceAdapter>?
+ *
+ * <operationProperties name="string" nativeOperation="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * <headers type="string"?
+ * deliveryMode="string"?
+ * timeToLive="int"?
+ * priority="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </headers>?
+ * </operationProperties>*
+ *
+ * <wireFormat.someWireFormat/>?
+ * </binding.jms>
+ *
+ * Parsing error messages are recorded locally and reported as validation exceptions. Parsing
+ * warnings do not cause validation exceptions.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<JMSBinding> {
+ private PolicyFactory policyFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private ConfiguredOperationProcessor configuredOperationProcessor;
+ protected StAXArtifactProcessor<Object> extensionProcessor;
+
+ public JMSBindingProcessor(FactoryExtensionPoint modelFactories, StAXArtifactProcessor<Object> extensionProcessor) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+
+ this.configuredOperationProcessor =
+ new ConfiguredOperationProcessor(modelFactories);
+ this.extensionProcessor = extensionProcessor;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "binding-jms-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report an error.
+ * One side effect is that error messages are saved for future validation calls.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "binding-jms-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return JMSBindingConstants.BINDING_JMS_QNAME;
+ }
+
+ public Class<JMSBinding> getModelType() {
+ return JMSBinding.class;
+ }
+
+ public JMSBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Monitor monitor = context.getMonitor();
+ JMSBinding jmsBinding = new JMSBinding();
+ // Reset validation message to keep track of validation issues.
+
+ // Read policies
+ policyProcessor.readPolicies(jmsBinding, reader);
+
+ // Read binding name
+ String name = reader.getAttributeValue(null, "name");
+ if (name != null) {
+ jmsBinding.setName(name);
+ }
+
+ // Read binding URI
+ String uri = reader.getAttributeValue(null, "uri");
+ if (uri != null && uri.length() > 0) {
+ parseURI(uri, jmsBinding, monitor);
+ }
+
+ // Read correlation scheme
+ String correlationScheme = reader.getAttributeValue(null, "correlationScheme");
+ if (correlationScheme != null && correlationScheme.length() > 0) {
+ if (JMSBindingConstants.VALID_CORRELATION_SCHEMES.contains(correlationScheme.toLowerCase())) {
+ jmsBinding.setCorrelationScheme(correlationScheme);
+ } else {
+ error(monitor, "InvalidCorrelationScheme", reader, correlationScheme);
+ }
+ }
+
+ // Read initial context factory
+ String initialContextFactory = getURIString(reader, "initialContextFactory");
+ if (initialContextFactory != null && initialContextFactory.length() > 0) {
+ jmsBinding.setInitialContextFactoryName(initialContextFactory);
+ }
+
+ // Read JNDI URL
+ String jndiURL = getURIString(reader, "jndiURL");
+ if (jndiURL != null && jndiURL.length() > 0) {
+ jmsBinding.setJndiURL(jndiURL);
+ }
+
+ // Read message processor class name
+ // TODO - maintain this for the time being but move over to
+ // configuring wire formats instead of message processors
+ String messageProcessorName = reader.getAttributeValue(null, "messageProcessor");
+ if (messageProcessorName != null && messageProcessorName.length() > 0) {
+ if ("XMLTextMessage".equalsIgnoreCase(messageProcessorName)) {
+ // may be overwritten be real wire format later
+ jmsBinding.setRequestWireFormat(new WireFormatJMSTextXML());
+ jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
+ } else if ("TextMessage".equalsIgnoreCase(messageProcessorName)) {
+ // may be overwritten be real wire format later
+ jmsBinding.setRequestWireFormat(new WireFormatJMSText());
+ jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
+ } else if ("ObjectMessage".equalsIgnoreCase(messageProcessorName)) {
+ // may be overwritten be real wire format later
+ jmsBinding.setRequestWireFormat(new WireFormatJMSObject());
+ jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
+ } else {
+ jmsBinding.setRequestMessageProcessorName(messageProcessorName);
+ jmsBinding.setResponseMessageProcessorName(messageProcessorName);
+ // exploit the text wire format code to drive the user selected
+ // message processor
+ jmsBinding.setRequestWireFormat(new WireFormatJMSText());
+ jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
+ }
+ }
+
+ String requestConnectionName = reader.getAttributeValue(null, "requestConnection");
+ if (requestConnectionName != null && requestConnectionName.length() > 0) {
+ jmsBinding.setRequestConnectionName(getQNameValue(reader, requestConnectionName));
+ }
+ String responseConnectionName = reader.getAttributeValue(null, "responseConnection");
+ if (responseConnectionName != null && responseConnectionName.length() > 0) {
+ jmsBinding.setResponseConnectionName(getQNameValue(reader, responseConnectionName));
+ }
+
+ String operationPropertiesName = reader.getAttributeValue(null, "operationProperties");
+ if (operationPropertiesName != null && operationPropertiesName.length() > 0) {
+ jmsBinding.setOperationPropertiesName(getQNameValue(reader, operationPropertiesName));
+ }
+
+ // Read sub-elements of binding.jms
+ boolean endFound = false;
+ while (!endFound) {
+ int fg = reader.next();
+ switch (fg) {
+ case START_ELEMENT:
+ String elementName = reader.getName().getLocalPart();
+ if ("destination".equals(elementName)) {
+ parseDestination(reader, jmsBinding, monitor);
+ } else if ("connectionFactory".equals(elementName)) {
+ parseConnectionFactory(reader, jmsBinding, monitor);
+ } else if ("activationSpec".equals(elementName)) {
+ parseActivationSpec(reader, jmsBinding, monitor);
+ } else if ("response".equals(elementName)) {
+ parseResponse(reader, jmsBinding, context);
+ } else if ("resourceAdapter".equals(elementName)) {
+ parseResourceAdapter(reader, jmsBinding, monitor);
+ } else if ("headers".equals(elementName)) {
+ parseHeaders(reader, jmsBinding, monitor);
+ } else if ("operationProperties".equals(elementName)) {
+ parseOperationProperties(reader, jmsBinding, monitor);
+ } else if ("messageSelection".equals(elementName)) {
+ parseSubscriptionHeaders(reader, jmsBinding);
+ } else if (Constants.OPERATION_QNAME.equals(reader.getName())) {
+ ConfiguredOperation confOp = configuredOperationProcessor.read(reader, context);
+ if (confOp != null) {
+ ((OperationsConfigurator)jmsBinding).getConfiguredOperations().add(confOp);
+ }
+ } else {
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof WireFormat) {
+ if (jmsBinding.getRequestWireFormat() == null) {
+ jmsBinding.setRequestWireFormat((WireFormat) extension);
+ } else {
+ error(monitor, "WireFormatAlreadyDefined", reader, extension.toString());
+ }
+ } else if (extension instanceof OperationSelector) {
+ if (jmsBinding.getOperationSelector() == null) {
+ jmsBinding.setOperationSelector((OperationSelector) extension);
+ } else {
+ error(monitor, "OpSelectorAlreadyDefined", reader, extension.toString());
+ }
+
+ } else {
+ error(monitor, "UnexpectedElement", reader, extension.toString());
+ }
+ }
+ }
+ //reader.next();
+ break;
+ case END_ELEMENT:
+ QName x = reader.getName();
+ if (Constants.OPERATION.equals(x.getLocalPart())) break;
+ // This assumption is not captured in schema, which isn't good, but will probably be fine for now.
+ // A better solution might be to require each processor to advance to its own END_ELEMENT.
+ if (x.getLocalPart().startsWith("wireFormat.") || x.getLocalPart().startsWith("operationSelector.")) {
+ break;
+ }
+ if (x.equals(JMSBindingConstants.BINDING_JMS_QNAME)) {
+ endFound = true;
+ } else {
+ error(monitor, "UnexpectedElement: expected " + JMSBindingConstants.BINDING_JMS_QNAME + ", found " + x.toString(),
+ reader, x.toString());
+ }
+ }
+ }
+
+ // if no operation selector is specified then assume the default
+ if (jmsBinding.getOperationSelector() == null){
+ jmsBinding.setOperationSelector(new OperationSelectorJMSDefault());
+ }
+
+ // if no request wire format specified then assume the default
+ if (jmsBinding.getRequestWireFormat() == null){
+ jmsBinding.setRequestWireFormat(new WireFormatJMSDefault());
+ }
+
+ // if no response wire format specific then assume the same as the request
+ if (jmsBinding.getResponseWireFormat() == null){
+ jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
+ }
+
+ validate( jmsBinding, monitor );
+
+ return jmsBinding;
+ }
+
+ protected void parseURI(String uri, JMSBinding jmsBinding, Monitor monitor) {
+ if (!(uri.startsWith("jms:jndi:") || uri.startsWith("jms:queue:") || uri.startsWith("jms:topic:"))) {
+ error(monitor, "MustStartWithSchema", jmsBinding, uri);
+ return;
+ }
+ int i = uri.indexOf('?');
+ if (i >= 0) {
+ StringTokenizer st = new StringTokenizer(uri.substring(i+1),"&");
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken();
+ if (s.startsWith("connectionFactoryName=")) {
+ jmsBinding.setConnectionFactoryName(s.substring(22));
+ } else if (s.startsWith("deliveryMode=")) {
+ jmsBinding.setJMSDeliveryMode("persistent".equals(s.substring(14)));
+ } else if (s.startsWith("priority=")) {
+ jmsBinding.setJMSPriority(Integer.parseInt(s.substring(9)));
+ } else if (s.startsWith("timeToLive=")) {
+ jmsBinding.setJMSTimeToLive(Long.parseLong(s.substring(11)));
+ } else if (s.startsWith("selector='")) {
+ String selector = s.substring(10);
+ if (selector.startsWith("\"") || selector.startsWith("'")) {
+ selector = selector.substring(1, selector.length());
+ }
+ if (selector.endsWith("\"") || selector.endsWith("'")) {
+ selector = selector.substring(0, selector.length() - 1);
+ }
+ jmsBinding.setJMSSelector(selector);
+ } else {
+ error(monitor, "UnknownTokenInURI", jmsBinding, s, uri);
+ return;
+ }
+ }
+ int j=uri.indexOf(':', 4);
+ jmsBinding.setDestinationName(uri.substring(j+1, i));
+ jmsBinding.setDestinationType(uri.substring(4, j));
+ } else {
+ int j=uri.indexOf(':', 4);
+ jmsBinding.setDestinationName(uri.substring(j+1));
+ jmsBinding.setDestinationType(uri.substring(4, j));
+ }
+ jmsBinding.setJMSURI(uri);
+ }
+
+ public void resolve(JMSBinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ if (model.getRequestConnectionName() != null) {
+ model.setRequestConnectionBinding(getConnectionBinding(model, "requestConnection", model.getRequestConnectionName(), resolver, context));
+ }
+ if (model.getResponseConnectionName() != null) {
+ model.setResponseConnectionBinding(getConnectionBinding(model, "responseConnection", model.getResponseConnectionName(), resolver, context));
+ }
+ if (model.getOperationPropertiesName() != null) {
+ model.setOperationPropertiesBinding(getConnectionBinding(model, "operationProperties", model.getOperationPropertiesName(), resolver, context));
+ }
+ }
+
+ private JMSBinding getConnectionBinding(JMSBinding model, String attrName, QName bindingName, ModelResolver resolver, ProcessorContext context) {
+ JMSBinding binding = new JMSBinding();
+ binding.setTargetNamespace(bindingName.getNamespaceURI());
+ binding.setName(bindingName.getLocalPart());
+ binding.setUnresolved(true);
+ binding = resolver.resolveModel(JMSBinding.class, binding, context);
+ if (binding.isUnresolved())
+ error(context.getMonitor(), "BindingNotFound", model, attrName, bindingName);
+ return binding;
+ }
+
+ private void parseDestination(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = getURIString(reader, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setDestinationName(name);
+ }
+
+ String type = reader.getAttributeValue(null, "type");
+ if (type != null && type.length() > 0) {
+ if (JMSBindingConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(type)) {
+ jmsBinding.setDestinationType(JMSBindingConstants.DESTINATION_TYPE_QUEUE);
+ } else if (JMSBindingConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(type)) {
+ jmsBinding.setDestinationType(JMSBindingConstants.DESTINATION_TYPE_TOPIC);
+ } else {
+ error(monitor, "InvalidDestinationType", reader, type);
+ }
+ }
+
+ String create = reader.getAttributeValue(null, "create");
+ if (create != null && create.length() > 0) {
+ validateCreate(create, reader, monitor);
+ jmsBinding.setDestinationCreate(create);
+ }
+
+ jmsBinding.getDestinationProperties().putAll(parseBindingProperties(reader, monitor));
+
+ if (jmsBinding.getDestinationCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader);
+ }
+ }
+ if (jmsBinding.getDestinationCreate().equals(JMSBindingConstants.CREATE_NEVER)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_NEVER", reader);
+ }
+ }
+ }
+
+ private void parseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = getURIString(reader, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setConnectionFactoryName(name);
+ } else {
+ error(monitor, "MissingConnectionFactoryName", reader);
+ }
+
+ String create = reader.getAttributeValue(null, "create");
+ if (create != null && create.length() > 0) {
+ validateCreate(create, reader, monitor);
+ jmsBinding.setConnectionFactoryCreate(create);
+ }
+ if (jmsBinding.getConnectionFactoryCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader);
+ }
+ }
+ if (jmsBinding.getConnectionFactoryCreate().equals(JMSBindingConstants.CREATE_NEVER)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_NEVER", reader);
+ }
+ }
+
+ jmsBinding.getConnectionFactoryProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setActivationSpecName(name);
+ }
+
+ String create = reader.getAttributeValue(null, "create");
+ if (create != null && create.length() > 0) {
+ validateCreate(create, reader, monitor);
+ jmsBinding.setActivationSpecCreate(create);
+ }
+ if (jmsBinding.getActivationSpecCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader);
+ }
+ }
+ if (jmsBinding.getActivationSpecCreate().equals(JMSBindingConstants.CREATE_NEVER)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_NEVER", reader);
+ }
+ }
+
+ jmsBinding.getActivationSpecProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseResponseDestination(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = getURIString(reader, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setResponseDestinationName(name);
+ }
+
+ String type = reader.getAttributeValue(null, "type");
+ if (type != null && type.length() > 0) {
+ warning(monitor, "DoesntProcessResponseDestinationType", jmsBinding);
+ if (JMSBindingConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(type)) {
+ jmsBinding.setResponseDestinationType(JMSBindingConstants.DESTINATION_TYPE_QUEUE);
+ } else if (JMSBindingConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(type)) {
+ jmsBinding.setResponseDestinationType(JMSBindingConstants.DESTINATION_TYPE_TOPIC);
+ } else {
+ error(monitor, "InvalidResponseDestinationType", reader, type);
+ }
+ }
+
+ String create = reader.getAttributeValue(null, "create");
+ if (create != null && create.length() > 0) {
+ validateCreate(create, reader, monitor);
+ jmsBinding.setResponseDestinationCreate(create);
+ }
+ if (jmsBinding.getResponseDestinationCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader);
+ }
+ }
+ if (jmsBinding.getResponseDestinationCreate().equals(JMSBindingConstants.CREATE_NEVER)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_NEVER", reader);
+ }
+ }
+
+ jmsBinding.getResponseDestinationProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseResponseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = getURIString(reader, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setResponseConnectionFactoryName(name);
+ } else {
+ warning(monitor, "MissingResponseConnectionFactory", reader);
+ }
+ String create = reader.getAttributeValue(null, "create");
+ if (create != null && create.length() > 0) {
+ validateCreate(create, reader, monitor);
+ jmsBinding.setResponseConnectionFactoryCreate(create);
+ }
+ if (jmsBinding.getResponseConnectionFactoryCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader);
+ }
+ }
+ if (jmsBinding.getResponseConnectionFactoryCreate().equals(JMSBindingConstants.CREATE_NEVER)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_NEVER", reader);
+ }
+ }
+ jmsBinding.getResponseConnectionFactoryProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseResponseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setResponseActivationSpecName(name);
+ }
+ String create = reader.getAttributeValue(null, "create");
+ if (create != null && create.length() > 0) {
+ validateCreate(create, reader, monitor);
+ jmsBinding.setResponseActivationSpecCreate(create);
+ }
+ if (jmsBinding.getResponseActivationSpecCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader);
+ }
+ }
+ if (jmsBinding.getResponseActivationSpecCreate().equals(JMSBindingConstants.CREATE_NEVER)) {
+ if (name == null || name.length() < 1) {
+ error(monitor, "MissingNameForCREATE_NEVER", reader);
+ }
+ }
+ jmsBinding.getResponseActivationSpecProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void validateCreate(String create, XMLStreamReader reader, Monitor monitor) {
+ if (JMSBindingConstants.CREATE_ALWAYS.equals(create)) {
+ return;
+ }
+ if (JMSBindingConstants.CREATE_NEVER.equals(create)) {
+ return;
+ }
+ if (JMSBindingConstants.CREATE_IF_NOT_EXIST.equals(create)) {
+ return;
+ }
+ error(monitor, "InvalidCreate", reader, create);
+ }
+
+ private void parseResponse(XMLStreamReader reader, JMSBinding jmsBinding, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ // Read sub-elements of response
+ Monitor monitor = context.getMonitor();
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ String elementName = reader.getName().getLocalPart();
+ if ("destination".equals(elementName)) {
+ parseResponseDestination(reader, jmsBinding, context.getMonitor());
+ } else if ("connectionFactory".equals(elementName)) {
+ parseResponseConnectionFactory(reader, jmsBinding, monitor);
+ } else if ("activationSpec".equals(elementName)) {
+ parseResponseActivationSpec(reader, jmsBinding, monitor);
+ } else {
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof WireFormat) {
+ if (jmsBinding.getResponseWireFormat() == null) {
+ jmsBinding.setResponseWireFormat((WireFormat)extension);
+ } else {
+ error(context.getMonitor(), "ResponseWireformatAlreadyDefined", reader, extension.toString());
+ }
+ } else {
+ error(context.getMonitor(), "UnexpectedElement", reader, extension.toString());
+ }
+ }
+ reader.next();
+ }
+ //reader.next();
+ break;
+ case END_ELEMENT:
+ QName x = reader.getName();
+ if (x.getLocalPart().equals("response")) {
+ return;
+ } else {
+ error(context.getMonitor(), "UnexpectedResponseElement", reader, x.toString());
+ }
+ }
+ }
+ }
+
+ private void parseResourceAdapter(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "name");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setResourceAdapterName(name);
+ } else {
+ error(monitor, "MissingResourceAdapterName", reader);
+ }
+ jmsBinding.getResourceAdapterProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ /**
+ * <headers JMSType="string"?
+ * JMSCorrelationID="string"?
+ * JMSDeliveryMode="PERSISTENT or NON_PERSISTENT"?
+ * timeToLive="long"?
+ * JMSPriority="0 .. 9"?>
+ * <property name="NMTOKEN" type="NMTOKEN"?>*
+ * </headers>?
+ */
+ private void parseHeaders(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String jmsType = reader.getAttributeValue(null, "type");
+ if (jmsType != null && jmsType.length() > 0) {
+ jmsBinding.setJMSType(jmsType);
+ }
+
+ String jmsDeliveryMode = reader.getAttributeValue(null, "deliveryMode");
+ if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) {
+ if ("persistent".equalsIgnoreCase(jmsDeliveryMode)) {
+ jmsBinding.setJMSDeliveryMode(true);
+ } else if ("nonpersistent".equalsIgnoreCase(jmsDeliveryMode)) {
+ jmsBinding.setJMSDeliveryMode(false);
+ } else {
+ error(monitor, "InvalidJMSDeliveryMode", jmsBinding, jmsDeliveryMode);
+ }
+ }
+
+ String jmsTimeToLive = reader.getAttributeValue(null, "timeToLive");
+ if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) {
+ jmsBinding.setJMSTimeToLive(Long.parseLong(jmsTimeToLive));
+ }
+
+ String jmsPriority = reader.getAttributeValue(null, "priority");
+ if (jmsPriority != null && jmsPriority.length() > 0) {
+ try {
+ int p = Integer.parseInt(jmsPriority);
+ if (p >= 0 && p <= 9) {
+ jmsBinding.setJMSPriority(p);
+ } else {
+ warning(monitor, "InvalidJMSPriority", jmsBinding, jmsPriority);
+ }
+ } catch (NumberFormatException ex) {
+ error(monitor, "InvalidJMSPriority", jmsBinding, jmsPriority);
+ }
+ }
+
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ if (reader.getName().getLocalPart().equals("property")) {
+ parseProperty(reader, jmsBinding);
+ }
+ break;
+ case END_ELEMENT:
+ QName x = reader.getName();
+ if (x.getLocalPart().equals("headers")) {
+ return;
+ } else {
+ error(monitor, "UnexpectedResponseElement", reader, x.toString());
+ }
+ }
+ }
+ }
+
+ private void parseProperty(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException {
+ jmsBinding.setHeaders( true );
+ String name = reader.getAttributeValue(null, "name");
+ String type = reader.getAttributeValue(null, "type");
+ if (name != null && name.length() > 0) {
+ Object value = reader.getElementText();
+ if ("boolean".equalsIgnoreCase(type)) {
+ value = Boolean.parseBoolean((String)value);
+ } else if ("byte".equalsIgnoreCase(type)) {
+ value = Byte.parseByte(((String)value));
+ } else if ("short".equalsIgnoreCase(type)) {
+ value = Short.parseShort((String)value);
+ } else if ("int".equalsIgnoreCase(type)) {
+ value = Integer.parseInt((String)value);
+ } else if ("long".equalsIgnoreCase(type)) {
+ value = Long.parseLong((String)value);
+ } else if ("float".equalsIgnoreCase(type)) {
+ value = Float.parseFloat((String)value);
+ } else if ("double".equalsIgnoreCase(type)) {
+ value = Double.parseDouble((String)value);
+ } else if ("String".equalsIgnoreCase(type)) {
+ // its already a string
+ }
+ jmsBinding.setProperty(name, value);
+ }
+ }
+
+ /**
+ * <operationProperties name="string" nativeOperation="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN"?>*
+ * <headers JMSType="string"?
+ * JMSCorrelationID="string"?
+ * JMSDeliveryMode="PERSISTENT or NON_PERSISTENT"?
+ * timeToLive="long"?
+ * JMSPriority="0 .. 9"?>
+ * <property name="NMTOKEN" type="NMTOKEN"?>*
+ * </headers>?
+ * </operationProperties>*
+ */
+ private void parseOperationProperties(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+
+ if (jmsBinding.getOperationPropertiesName() != null) {
+ error(monitor, "DuplicateOperationProperties", jmsBinding);
+ }
+
+ String opName = reader.getAttributeValue(null, "name");
+ if (opName == null || opName.length() < 1) {
+ warning(monitor, "MissingJMSOperationPropertyName", jmsBinding);
+ return;
+ }
+ // Since nativeOpName, headers, and property elements are optional, must add opName.
+ jmsBinding.addOperationName(opName);
+ String nativeOpName = reader.getAttributeValue(null, "nativeOperation"); // optional
+ if (nativeOpName != null && nativeOpName.length() > 0) {
+ jmsBinding.setNativeOperationName(opName, nativeOpName);
+ }
+
+ Map<String, BindingProperty> props = new HashMap<String, BindingProperty>();
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ if (reader.getName().getLocalPart().equals("headers")) { // optional
+ parseOperationHeaders(reader, jmsBinding, opName, monitor);
+ } else if (reader.getName().getLocalPart().equals("property")) { // optional
+ processProperty(reader, props, monitor);
+ }
+ break;
+ case END_ELEMENT:
+ if (reader.isEndElement()) {
+ QName x = reader.getName();
+ if (x.getLocalPart().equals("headers")) {
+ break;
+ }
+ if (x.getLocalPart().equals("property")) {
+ break;
+ }
+ if (x.getLocalPart().equals("operationProperties")) {
+ jmsBinding.getOperationPropertiesProperties(opName).putAll(props);
+ return;
+ } else {
+ error(monitor, "UnexpectedResponseElement", reader, x.toString());
+ }
+ }
+ }
+ }
+ }
+
+ private void parseOperationHeaders(XMLStreamReader reader, JMSBinding jmsBinding, String opName, Monitor monitor) throws XMLStreamException {
+ String jmsType = reader.getAttributeValue(null, "type");
+ if (jmsType != null && jmsType.length() > 0) {
+ jmsBinding.setOperationJMSType(opName, jmsType);
+ }
+
+ String jmsDeliveryMode = reader.getAttributeValue(null, "deliveryMode");
+ if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) {
+ if ("persistent".equalsIgnoreCase(jmsDeliveryMode)) {
+ jmsBinding.setOperationJMSDeliveryMode(opName, true);
+ } else if ("nonpersistent".equalsIgnoreCase(jmsDeliveryMode)) {
+ jmsBinding.setOperationJMSDeliveryMode(opName, false);
+ } else {
+ error(monitor, "InvalidOPJMSDeliveryMode", jmsBinding, jmsDeliveryMode);
+ }
+ }
+
+ String jmsTimeToLive = reader.getAttributeValue(null, "timeToLive");
+ if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) {
+ jmsBinding.setOperationJMSTimeToLive(opName, Long.parseLong(jmsTimeToLive));
+ }
+
+ String jmsPriority = reader.getAttributeValue(null, "priority");
+ if (jmsPriority != null && jmsPriority.length() > 0) {
+ try {
+ int p = Integer.parseInt(jmsPriority);
+ if (p >= 0 && p <= 9) {
+ jmsBinding.setOperationJMSPriority(opName, p);
+ } else {
+ warning(monitor, "InvalidOPJMSPriority", jmsBinding, jmsPriority);
+ }
+ } catch (NumberFormatException ex) {
+ error(monitor, "InvalidOPJMSPriority", jmsBinding, jmsPriority);
+ }
+ }
+
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ if (reader.getName().getLocalPart().equals("property")) {
+ parseOperationPropertyProperties(reader, jmsBinding, opName);
+ }
+ break;
+ case END_ELEMENT:
+ QName x = reader.getName();
+ if (x.getLocalPart().equals("headers")) {
+ return;
+ } else {
+ error(monitor, "UnexpectedResponseElement", reader, x.toString());
+ }
+ }
+ }
+ }
+
+ private void parseOperationPropertyProperties(XMLStreamReader reader, JMSBinding jmsBinding, String opName) throws XMLStreamException {
+ String propName = reader.getAttributeValue(null, "name");
+ String type = reader.getAttributeValue(null, "type");
+ if (propName != null && propName.length() > 0) {
+ Object value = reader.getElementText();
+ if ("boolean".equalsIgnoreCase(type)) {
+ value = Boolean.parseBoolean((String)value);
+ } else if ("byte".equalsIgnoreCase(type)) {
+ value = Byte.parseByte(((String)value));
+ } else if ("short".equalsIgnoreCase(type)) {
+ value = Short.parseShort((String)value);
+ } else if ("int".equalsIgnoreCase(type)) {
+ value = Integer.parseInt((String)value);
+ } else if ("long".equalsIgnoreCase(type)) {
+ value = Long.parseLong((String)value);
+ } else if ("float".equalsIgnoreCase(type)) {
+ value = Float.parseFloat((String)value);
+ } else if ("double".equalsIgnoreCase(type)) {
+ value = Double.parseDouble((String)value);
+ } else if ("String".equalsIgnoreCase(type)) {
+ // its already a string
+ }
+ jmsBinding.setOperationProperty(opName, propName, value);
+ }
+ }
+
+ private void parseSubscriptionHeaders(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException {
+ String jmsSelector = reader.getAttributeValue(null, "selector");
+ if (jmsSelector != null && jmsSelector.length() > 0 && jmsBinding.getJMSSelector() == null) {
+ jmsBinding.setJMSSelector(jmsSelector);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && "messageSelection".equals(reader.getName().getLocalPart())) {
+ break;
+ }
+ } // end while
+ }
+
+ private Map<String, BindingProperty> parseBindingProperties(XMLStreamReader reader, Monitor monitor) throws XMLStreamException {
+ Map<String, BindingProperty> props = new HashMap<String, BindingProperty>();
+ String parentName = reader.getName().getLocalPart();
+ // Parse for all the properties within this element, until the end of
+ // the element is reached.
+ boolean completed = false;
+ while (!completed) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ String elementName = reader.getName().getLocalPart();
+ if ("property".equals(elementName)) {
+ processProperty(reader, props, monitor);
+ }
+ break;
+ case END_ELEMENT:
+ String endName = reader.getName().getLocalPart();
+ if (parentName.equals(endName)) {
+ completed = true;
+ break;
+ }
+ }
+ }
+ return props;
+ }
+
+ private void processProperty(XMLStreamReader reader, Map<String, BindingProperty> props, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "name");
+ if (name == null || name.length() < 1) {
+ error(monitor, "InvalidPropertyElement", reader);
+ }
+ String type = reader.getAttributeValue(null, "type");
+ String value = reader.getElementText();
+ props.put(name, new BindingProperty(name, type, value));
+ }
+
+ /**
+ * Preserve an existing public method. The method validate() is a legacy method
+ * that was called from reading am XML stream via the read(XMLStreamReader) method above.
+ * However read(XMLStreamReader) now calls validate(JMSBinding jmsBinding) and
+ * passes in the jmsBinding model.
+ * The older validate() now calls validate(JMSBinding jmsBinding) with a null model.
+ */
+ public void validate() {
+ validate( null, null );
+ }
+
+ /**
+ * Validates JMS parsing and JMSBinding model.
+ * Validation rules are taken from the binding schema and the OSOA and OASIS specs:
+ * http://www.oasis-open.org/committees/documents.php?wg_abbrev=sca-bindings
+ * (sca-binding-jms-1.1-spec-cd01-rev4.pdf)
+ * http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ * (SCA JMS Binding V1.00 )
+ * @param jmsBinding an optional JMS binding model to check for validity.
+ * @since 1.4
+ */
+ protected void validate( JMSBinding jmsBinding, Monitor monitor ) {
+ // If no JMSBinding model is provided, that is all the validation we can do.
+ if ( jmsBinding == null ) {
+ return;
+ }
+
+ // Connection factory should not contradict destination type.
+ String connectionFactoryName = jmsBinding.getConnectionFactoryName();
+ if (( connectionFactoryName != null ) && ( connectionFactoryName.length() > 0 )) {
+ if (JMSBindingConstants.DESTINATION_TYPE_QUEUE == jmsBinding.getDestinationType()) {
+ if ( connectionFactoryName.contains( "topic" )) {
+ error(monitor, "DestinationQueueContradiction", jmsBinding, connectionFactoryName );
+ }
+ }
+ if (JMSBindingConstants.DESTINATION_TYPE_TOPIC == jmsBinding.getDestinationType()) {
+ if ( connectionFactoryName.contains( "queue" )) {
+ error(monitor, "DestinationTopicContradiction", jmsBinding, connectionFactoryName );
+ }
+ }
+ }
+
+ // Connection factory and activation Specification are mutually exclusive.
+ if (( connectionFactoryName != null ) && ( connectionFactoryName.length() > 0 )) {
+ String activationSpecName = jmsBinding.getActivationSpecName();
+ if ((activationSpecName != null) && (activationSpecName.length() > 0 )) {
+ error(monitor, "ConnectionFactoryActivationSpecContradiction", jmsBinding, connectionFactoryName, activationSpecName );
+ }
+ }
+
+ // If activation spec and destination are both specified, they have to match
+ if ( ( jmsBinding.getActivationSpecName() != null ) && (jmsBinding.getActivationSpecName().length() > 0 ) &&
+ (jmsBinding.getDestinationName() != null) && (jmsBinding.getDestinationName().length() > 0 ) ) {
+ if ( !jmsBinding.getActivationSpecName().equals(jmsBinding.getDestinationName())) {
+ error(monitor, "ActivationSpecAndDestinationMismatch", jmsBinding, jmsBinding.getActivationSpecName(), jmsBinding.getDestinationName());
+ }
+ }
+
+ // If Connection factory specified then destination name must also be
+ if (( connectionFactoryName != null ) && ( connectionFactoryName.length() > 0 )) {
+ String destinationName = jmsBinding.getDestinationName();
+ if ((destinationName == null) || (destinationName.length() < 1 )) {
+ error(monitor, "ConnectionFactoryDestinationContradiction", jmsBinding, connectionFactoryName);
+ }
+ }
+
+ // Given a response connection name attribute, there must not be a response element.
+ // 156 /binding.jms/@responseConnection - identifies a binding.jms element that is present in a
+ // 157 definition document, whose response child element is used to define the values for this binding. In
+ // 158 this case this binding.jms element MUST NOT contain a response element.
+ QName responseConnectionName = jmsBinding.getResponseConnectionName();
+ if (( responseConnectionName != null ) && ( responseConnectionName.getLocalPart().length() > 0 )) {
+ String responseDestinationName = jmsBinding.getResponseDestinationName();
+ if (( responseDestinationName != null ) && (responseDestinationName.length() > 0)) {
+ error(monitor, "ResponseAttrElement", jmsBinding, responseConnectionName, responseDestinationName );
+ }
+ }
+
+ // Other jmsBinding model validation may be added here.
+
+ }
+
+ /**
+ * Given a valid JMSBinding, write it as XML using the given XML writer.
+ *
+ * This high-level method handles binding.jms element and its attributes.
+ * Sub elements have their own writer methods and are called from here.
+ * <binding.jms
+ * correlationScheme="string"?
+ * initialContextFactory="xs:anyURI"?
+ * jndiURL="xs:anyURI"?
+ * requestConnection="QName"?
+ * responseConnection="QName"?
+ * operationProperties="QName"?
+ * ...>
+ * @param writer an XMLStreamWriter that writes XML attributes and elements
+ * @param jmsBinding JMSBinding model
+ */
+ public void write(JMSBinding jmsBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ // Write a <binding.jms>
+ writeStart(writer, Constants.SCA11_NS, JMSBindingConstants.BINDING_JMS,
+ new XAttr("requestConnection", jmsBinding.getRequestConnectionName()),
+ new XAttr("responseConnection", jmsBinding.getResponseConnectionName()),
+ new XAttr("operationProperties", jmsBinding.getOperationPropertiesName()));
+
+ if (jmsBinding.getName() != null) {
+ writer.writeAttribute("name", jmsBinding.getName());
+ }
+
+ if (jmsBinding.getJMSURI() != null) {
+ writer.writeAttribute("uri", jmsBinding.getJMSURI());
+ writeEnd(writer);
+ return;
+ }
+
+ //String dest = jmsBinding.getDestinationName();
+ //if (dest != null) {
+ // if ( dest != null ) {
+ // writer.writeAttribute("uri", "jms:" + jmsBinding.getDestinationName());
+ // }
+ //}
+
+ String correlationScheme = jmsBinding.getCorrelationScheme();
+ if ( correlationScheme != null ) {
+ if ( !correlationScheme.equals(JMSBindingConstants.CORRELATE_MSG_ID) ) {
+ writer.writeAttribute("correlationScheme", jmsBinding.getCorrelationScheme());
+ }
+ }
+
+ if ( jmsBinding.getInitialContextFactoryName() != null ) {
+ writer.writeAttribute("initialContextFactory", jmsBinding.getInitialContextFactoryName());
+ }
+
+ if ( jmsBinding.getJndiURL() != null ) {
+ writer.writeAttribute("jndiURL", jmsBinding.getJndiURL());
+ }
+
+ if ( jmsBinding.containsHeaders() ) {
+ writeHeaders( jmsBinding, writer);
+ }
+
+ writeOperationProperties( jmsBinding, writer );
+
+ writeSubscriptionHeaders( jmsBinding, writer );
+
+ writeDestinationProperties( jmsBinding, writer );
+
+ writeConnectionFactoryProperties( jmsBinding, writer );
+
+ writeActivationSpecProperties( jmsBinding, writer );
+
+ // Write response info, if names are not defaults.
+ String responseDestName = jmsBinding.getResponseDestinationName();
+ String responseCFName = jmsBinding.getResponseConnectionFactoryName();
+ String responseASName = jmsBinding.getResponseActivationSpecName();
+ if ( responseDestName != null ||
+ responseCFName != null ||
+ responseASName != null ) {
+
+ writer.writeStartElement(Constants.SCA11_NS, "response");
+ writeResponseDestinationProperties( jmsBinding, writer );
+ writeResponseConnectionFactoryProperties( jmsBinding, writer );
+ writeResponseActivationSpecProperties( jmsBinding, writer );
+
+ if ((jmsBinding.getResponseWireFormat() != null) &&
+ !(jmsBinding.getResponseWireFormat() instanceof WireFormatJMSDefault)){
+ writeWireFormat(jmsBinding.getResponseWireFormat(), writer, context);
+ }
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters( " " );
+ }
+
+ writeResourceAdapterProperties( jmsBinding, writer );
+
+ writeConfiguredOperations( jmsBinding, writer, context );
+
+ if ((jmsBinding.getRequestWireFormat() != null) &&
+ !(jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault)){
+ writeWireFormat(jmsBinding.getRequestWireFormat(), writer, context);
+ }
+
+ if ((jmsBinding.getOperationSelector() != null) &&
+ !(jmsBinding.getOperationSelector() instanceof OperationSelectorJMSDefault)){
+ writeOperationSelector(jmsBinding.getOperationSelector(), writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ /**
+ * Writes headers element and its attributes.
+ * <headers JMSType="string"?
+ * JMSCorrelationID="string"?
+ * JMSDeliveryMode="PERSISTENT or NON_PERSISTENT"?
+ * timeToLive="long"?
+ * JMSPriority="0 .. 9"?>
+ * <property name="NMTOKEN" type="NMTOKEN"?>*
+ * </headers>?
+ */
+ private void writeHeaders( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+
+ writer.writeStartElement(Constants.SCA11_NS, JMSBindingConstants.HEADERS);
+
+ String jmsType = jmsBinding.getJMSType();
+ if (jmsType != null && jmsType.length() > 0) {
+ writer.writeAttribute("type", jmsType);
+ }
+
+ Boolean jmsDeliveryMode = jmsBinding.isdeliveryModePersistent();
+ if (jmsDeliveryMode != null) {
+ if ( jmsDeliveryMode.booleanValue() )
+ writer.writeAttribute("deliveryMode", "persistent");
+ else
+ writer.writeAttribute("deliveryMode", "nonpersistent");
+ }
+
+ Long jmsTimeToLive = jmsBinding.getJMSTimeToLive();
+ if (jmsTimeToLive != null) {
+ writer.writeAttribute("timeToLive", jmsTimeToLive.toString());
+ }
+
+ Integer jmsPriority = jmsBinding.getJMSPriority();
+ if (jmsPriority != null) {
+ writer.writeAttribute("priority", jmsPriority.toString());
+ }
+
+ Map<String, Object> properties = jmsBinding.getProperties();
+ writeProperties( properties, writer );
+ //writer.writeCharacters( " " );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters( " " );
+ }
+
+ /**
+ * Writes a complete set of properties to the given XML stream writer.
+ * If the value is of type string, the property will be output:
+ * <property name="key">StringValue</property>
+ * If the value is of type box (e.g.Integer, Long) or BindingProperty, the output will be
+ * <property name="key" type="int">42</property>
+ */
+ @SuppressWarnings("unchecked")
+ private void writeProperties(Map<String, Object> properties, XMLStreamWriter writer) throws XMLStreamException {
+ if (( properties == null ) || ( properties.size() == 0 )) {
+ return;
+ }
+
+ // For both the keys and values of a map
+ for (Iterator it=properties.entrySet().iterator(); it.hasNext(); ) {
+ Map.Entry entry = (Map.Entry)it.next();
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+
+ writer.writeStartElement(Constants.SCA11_NS, "property" );
+ writer.writeAttribute("name", key.toString());
+
+ if ( value instanceof String) {
+ writer.writeCharacters( value.toString() );
+ } else if ( value instanceof BindingProperty ) {
+ BindingProperty property = (BindingProperty) value;
+ String type = property.getType();
+ if ( type != null ) {
+ writer.writeAttribute("type", type);
+ }
+ writer.writeCharacters( property.getValue().toString() );
+ } else if ( value instanceof Boolean ) {
+ writer.writeAttribute("type", "boolean");
+ writer.writeCharacters( value.toString() );
+ } else if ( value instanceof Byte ) {
+ writer.writeAttribute("type", "byte");
+ writer.writeCharacters( value.toString() );
+ } else if ( value instanceof Short ) {
+ writer.writeAttribute("type", "short");
+ writer.writeCharacters( value.toString() );
+ } else if ( value instanceof Integer ) {
+ writer.writeAttribute("type", "int");
+ writer.writeCharacters( value.toString() );
+ } else if ( value instanceof Long ) {
+ writer.writeAttribute("type", "long");
+ writer.writeCharacters( value.toString() );
+ } else if ( value instanceof Float ) {
+ writer.writeAttribute("type", "float");
+ writer.writeCharacters( value.toString() );
+ } else if ( value instanceof Double ) {
+ writer.writeAttribute("type", "double");
+ writer.writeCharacters( value.toString() );
+ } else {
+ writer.writeCharacters( value.toString() );
+ }
+ writer.writeEndElement();
+ }
+ }
+
+ /**
+ * Writes operation properties if there are any.
+ *
+ * <operationProperties name="string" nativeOperation="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * <headers JMSType="string"?
+ * JMSCorrelationID="string"?
+ * JMSDeliveryMode="string"?
+ * timeToLive="int"?
+ * JMSPriority="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </headers>?
+ * </operationProperties>*
+ * </binding.jms>
+ */
+ private void writeOperationProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ if (jmsBinding.getOperationPropertiesBinding() != null) {
+ return;
+ }
+ Set<String> operationNames = jmsBinding.getOperationNames();
+ if (operationNames == null || (operationNames.size() < 1)) {
+ return;
+ }
+
+ for(Iterator<String> it=operationNames.iterator(); it.hasNext(); ) {
+ String opName = it.next();
+
+ writer.writeStartElement(Constants.SCA11_NS, "operationProperties");
+ writer.writeAttribute("name", opName);
+
+ String nativeOperation = jmsBinding.getNativeOperationName(opName);
+ if (nativeOperation != null && nativeOperation.length() > 0) {
+ if ( !nativeOperation.equals( opName )) {
+ writer.writeAttribute("nativeOperation", nativeOperation);
+ }
+ }
+
+ Map<String, BindingProperty> operationPropertiesProperties =
+ jmsBinding.getOperationPropertiesProperties(opName);
+ writeBindingProperties( operationPropertiesProperties, writer );
+
+ String jmsType = jmsBinding.getOperationJMSType(opName);
+ String jmsCorrelationId = jmsBinding.getOperationJMSCorrelationId(opName);
+ Boolean jmsDeliveryMode = jmsBinding.getOperationJMSDeliveryMode(opName);
+ Long jmsTimeToLive = jmsBinding.getOperationJMSTimeToLive(opName);
+ Integer jmsPriority = jmsBinding.getOperationJMSPriority(opName);
+ Map<String, Object> operationProperties = jmsBinding.getOperationProperties(opName);
+
+ if (operationProperties != null){
+ if ((jmsType != null && jmsType.length() > 0) ||
+ (jmsCorrelationId != null && jmsCorrelationId.length() > 0) ||
+ jmsDeliveryMode != null || jmsTimeToLive != null ||
+ jmsPriority != null) {
+
+ writer.writeStartElement(Constants.SCA11_NS, JMSBindingConstants.HEADERS);
+
+ if (jmsType != null && jmsType.length() > 0) {
+ writer.writeAttribute("type", jmsType);
+ }
+
+ if (jmsDeliveryMode != null) {
+ if (jmsDeliveryMode.booleanValue())
+ writer.writeAttribute("deliveryMode", "persistent");
+ else
+ writer.writeAttribute("deliveryMode", "nonpersistent");
+ }
+
+ if (jmsTimeToLive != null) {
+ writer.writeAttribute("timeToLive", jmsTimeToLive.toString());
+ }
+
+ if (jmsPriority != null) {
+ writer.writeAttribute("priority", jmsPriority.toString());
+ }
+
+ writeProperties( operationProperties, writer );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ // writer.writeCharacters( " " );
+ }
+ }
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+ }
+
+ /**
+ * Writes a complete set of properties to the given XML stream writer.
+ * If the value is of type string, the property will be output:
+ * <property name="key">StringValue</property>
+ * If the value is of type box (e.g.Integer, Long) or BindingProperty, the output will be
+ * <property name="key" type="int">42</property>
+ */
+ @SuppressWarnings("unchecked")
+ private void writeBindingProperties(Map<String, BindingProperty> properties, XMLStreamWriter writer) throws XMLStreamException {
+ if (( properties == null ) || ( properties.size() == 0 )) {
+ return;
+ }
+
+ // For both the keys and values of a map
+ for (Iterator it=properties.entrySet().iterator(); it.hasNext(); ) {
+ Map.Entry entry = (Map.Entry)it.next();
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+
+ writer.writeStartElement(Constants.SCA11_NS, "property" );
+ if (key != null){
+ writer.writeAttribute("name", key.toString());
+ }
+
+ if ( value instanceof String) {
+ writer.writeCharacters( value.toString() );
+ } else if ( value instanceof BindingProperty ) {
+ BindingProperty property = (BindingProperty) value;
+ String type = property.getType();
+ if ( type != null ) {
+ writer.writeAttribute("type", type);
+ }
+ writer.writeCharacters( property.getValue().toString() );
+ } else {
+ writer.writeCharacters( value.toString() );
+ }
+ writer.writeEndElement();
+ }
+ }
+
+ /**
+ * Writes subscription headers if there are any.
+ * <complexType name="messageSelection">
+ * <attribute name="selector" type="string"/>
+ * </complexType>
+ *
+ */
+ private void writeSubscriptionHeaders( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ String jmsSubscriptionHeaders = jmsBinding.getJMSSelector();
+ if (jmsSubscriptionHeaders != null && jmsSubscriptionHeaders.length() > 0) {
+ writer.writeStartElement(Constants.SCA11_NS, "messageSelection");
+ writer.writeAttribute("selector", jmsSubscriptionHeaders);
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ // writer.writeCharacters( " " );
+ }
+ }
+
+ /**
+ * Writes destination properties if there are any.
+ * <destination jndiName="xs:anyURI" type="string"? create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </destination>?
+ */
+ private void writeDestinationProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ String destinationName = jmsBinding.getDestinationName();
+ if (destinationName == null || (destinationName.length() < 1)) {
+ return;
+ }
+ if (destinationName == null) {
+ return;
+ }
+
+ writer.writeStartElement(Constants.SCA11_NS, "destination");
+
+ if ( destinationName != null && destinationName.length() > 0) {
+ writer.writeAttribute("jndiName", destinationName);
+ }
+
+ // Type not handled yet
+ // String destinationType = jmsBinding.getDestinationType();
+ // if ( destinationType != null && destinationType.length() > 0) {
+ // writer.writeAttribute("type", destinationType);
+ // }
+
+ String destinationCreate = jmsBinding.getDestinationCreate();
+ if ( destinationCreate != null && destinationCreate.length() > 0 &&
+ !destinationCreate.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ writer.writeAttribute("create", destinationCreate);
+ }
+
+ Map<String, BindingProperty> destinationProperties =
+ jmsBinding.getDestinationProperties();
+ writeBindingProperties( destinationProperties, writer );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+
+ /**
+ * Writes connection factory properties if there are any.
+ * <connectionFactory jndiName="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </connectionFactory>?
+ */
+ private void writeConnectionFactoryProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ String cfName = jmsBinding.getConnectionFactoryName();
+ if (cfName == null || (cfName.length() < 1)) {
+ return;
+ }
+
+ writer.writeStartElement(Constants.SCA11_NS, "connectionFactory");
+
+ if ( cfName != null && cfName.length() > 0) {
+ writer.writeAttribute("jndiName", cfName);
+ }
+
+ String destinationCreate = jmsBinding.getConnectionFactoryCreate();
+ if ( destinationCreate != null && destinationCreate.length() > 0 &&
+ !destinationCreate.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
+ writer.writeAttribute("create", destinationCreate);
+ }
+
+ Map<String, BindingProperty> cfProperties =
+ jmsBinding.getConnectionFactoryProperties();
+ writeBindingProperties( cfProperties, writer );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+
+ /**
+ * Writes activation Spec properties if there are any.
+ * <activationSpec name="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </activationSpec>?
+ *
+ */
+ private void writeActivationSpecProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ String asName = jmsBinding.getActivationSpecName();
+ if (asName == null || (asName.length() < 1)) {
+ return;
+ }
+
+ writer.writeStartElement(Constants.SCA11_NS, "activationSpec");
+
+ if ( asName != null && asName.length() > 0) {
+ writer.writeAttribute("name", asName);
+ }
+
+ String destinationCreate = jmsBinding.getActivationSpecCreate();
+ if ( destinationCreate != null && destinationCreate.length() > 0) {
+ writer.writeAttribute("create", destinationCreate);
+ }
+
+ Map<String, BindingProperty> cfProperties =
+ jmsBinding.getActivationSpecProperties();
+ writeBindingProperties( cfProperties, writer );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+
+ /**
+ * Writes response destination properties if there are any.
+ * <destination jndiName="xs:anyURI" type="string"? create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </destination>?
+ */
+ private void writeResponseDestinationProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ String destinationName = jmsBinding.getResponseDestinationName();
+ if (destinationName == null || (destinationName.length() < 1)) {
+ return;
+ }
+ if (destinationName == null) {
+ return;
+ }
+
+ writer.writeStartElement(Constants.SCA11_NS, "destination");
+
+ if ( destinationName != null && destinationName.length() > 0) {
+ writer.writeAttribute("jndiName", destinationName);
+ }
+
+ // Type not handled yet
+ // String destinationType = jmsBinding.getDestinationType();
+ // if ( destinationType != null && destinationType.length() > 0) {
+ // writer.writeAttribute("type", destinationType);
+ // }
+
+ String destinationCreate = jmsBinding.getResponseDestinationCreate();
+ if ( destinationCreate != null && destinationCreate.length() > 0) {
+ writer.writeAttribute("create", destinationCreate);
+ }
+
+ Map<String, BindingProperty> destinationProperties =
+ jmsBinding.getResponseDestinationProperties();
+ writeBindingProperties( destinationProperties, writer );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+
+ /**
+ * Writes response connection factory properties if there are any.
+ * <connectionFactory jndiName="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </connectionFactory>?
+ *
+ */
+ private void writeResponseConnectionFactoryProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ String cfName = jmsBinding.getResponseConnectionFactoryName();
+ if (cfName == null || (cfName.length() < 1)) {
+ return;
+ }
+
+ writer.writeStartElement(Constants.SCA11_NS, "connectionFactory");
+
+ if ( cfName != null && cfName.length() > 0) {
+ writer.writeAttribute("jndiName", cfName);
+ }
+
+ String destinationCreate = jmsBinding.getResponseConnectionFactoryCreate();
+ if ( destinationCreate != null && destinationCreate.length() > 0) {
+ writer.writeAttribute("create", destinationCreate);
+ }
+
+ Map<String, BindingProperty> cfProperties =
+ jmsBinding.getResponseConnectionFactoryProperties();
+ writeBindingProperties( cfProperties, writer );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+
+ /**
+ * Writes response activation Spec properties if there are any.
+ * <activationSpec name="xs:anyURI" create="string"?>
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </activationSpec>?
+ *
+ */
+ private void writeResponseActivationSpecProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ String asName = jmsBinding.getResponseActivationSpecName();
+ if (asName == null || (asName.length() < 1)) {
+ return;
+ }
+
+ writer.writeStartElement(Constants.SCA11_NS, "activationSpec");
+
+ if ( asName != null && asName.length() > 0) {
+ writer.writeAttribute("name", asName);
+ }
+
+ String destinationCreate = jmsBinding.getResponseActivationSpecCreate();
+ if ( destinationCreate != null && destinationCreate.length() > 0) {
+ writer.writeAttribute("create", destinationCreate);
+ }
+
+ Map<String, BindingProperty> cfProperties =
+ jmsBinding.getResponseActivationSpecProperties();
+ writeBindingProperties( cfProperties, writer );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+
+ /**
+ * Writes resource adapter properties if there are any.
+ * <resourceAdapter name="NMTOKEN">?
+ * <property name="NMTOKEN" type="NMTOKEN">*
+ * </resourceAdapter>?
+ */
+ private void writeResourceAdapterProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException {
+ String asName = jmsBinding.getResourceAdapterName();
+ if (asName == null || (asName.length() < 1)) {
+ return;
+ }
+
+ writer.writeStartElement(Constants.SCA11_NS, "resourceAdapter");
+
+ if ( asName != null && asName.length() > 0) {
+ writer.writeAttribute("name", asName);
+ }
+
+ Map<String, BindingProperty> cfProperties =
+ jmsBinding.getResourceAdapterProperties();
+ writeBindingProperties( cfProperties, writer );
+
+ writer.writeEndElement();
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+
+ /**
+ * Writes configured operations if there are any.
+ * <binding.jms uri=\"jms:testQueue\" >"
+ * <operationProperties name=\"op1\">"
+ * </operationProperties >"
+ * <operation name=\"op1\" requires=\"IntentOne IntentTwo\"/>"
+ * </binding.jms>"
+ */
+ private void writeConfiguredOperations( JMSBinding jmsBinding, XMLStreamWriter writer, ProcessorContext context) throws XMLStreamException, ContributionWriteException {
+ List<ConfiguredOperation> configOps = jmsBinding.getConfiguredOperations();
+ if (configOps == null || (configOps.size() < 1)) {
+ return;
+ }
+
+ for( Iterator<ConfiguredOperation> it = configOps.iterator(); it.hasNext();) {
+ configuredOperationProcessor.write(it.next(), writer, context);
+ }
+
+ // Strange bug. Without white space, headers end tag improperly read.
+ writer.writeCharacters(" ");
+ }
+
+ /**
+ * Wire out a request or response wire format element. Uses extension processors
+ * to do this as wire format is an extension point
+ *
+ * @param wireFormat
+ * @param writer
+ */
+ private void writeWireFormat(WireFormat wireFormat, XMLStreamWriter writer, ProcessorContext context ) throws XMLStreamException, ContributionWriteException {
+ extensionProcessor.write(wireFormat, writer, context);
+ }
+
+ /**
+ * Wire out an operation selector element. Uses extension processors
+ * to do this as operation selector is an extension point
+ *
+ * @param operationSeletor
+ * @param writer
+ */
+ private void writeOperationSelector(OperationSelector operationSeletor, XMLStreamWriter writer, ProcessorContext context ) throws XMLStreamException, ContributionWriteException{
+ extensionProcessor.write(operationSeletor, writer, context);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java
new file mode 100644
index 0000000000..9573ddfc38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.operationselector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSDefault implements OperationSelector {
+ public static final QName OPERATION_SELECTOR_JMS_DEFAULT_QNAME = new QName(Constants.SCA11_NS, "operationSelector.jmsDefault");
+
+ public QName getSchemaName() {
+ return OPERATION_SELECTOR_JMS_DEFAULT_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefaultProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefaultProcessor.java
new file mode 100644
index 0000000000..4f09eeb9a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefaultProcessor.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.sca.binding.jms.operationselector;
+
+
+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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSDefaultProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<OperationSelectorJMSDefault> {
+
+ public QName getArtifactType() {
+ return OperationSelectorJMSDefault.OPERATION_SELECTOR_JMS_DEFAULT_QNAME;
+ }
+
+ public OperationSelectorJMSDefaultProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public OperationSelectorJMSDefault read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ OperationSelectorJMSDefault wireFormat = new OperationSelectorJMSDefault();
+
+ return wireFormat;
+ }
+
+ public void write(OperationSelectorJMSDefault wireFormat, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ writer.writeEndElement();
+ }
+
+ public Class<OperationSelectorJMSDefault> getModelType() {
+ return OperationSelectorJMSDefault.class;
+ }
+
+ public void resolve(OperationSelectorJMSDefault arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserProp.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserProp.java
new file mode 100644
index 0000000000..f978adfa58
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserProp.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.binding.jms.operationselector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Model of user property based operation selection
+ *
+ * <operationSelector.jmsUser propertName="MyHeaderProperty"/>
+ *
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSUserProp implements OperationSelector {
+ public static final QName OPERATION_SELECTOR_JMS_USERPROP_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "operationSelector.jmsUserProp");
+ public static final String OPERATION_SELECTOR_JMS_USERPROP_ATTR = "propertyName";
+
+ private String propertyName;
+
+ public QName getSchemaName() {
+ return OPERATION_SELECTOR_JMS_USERPROP_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserPropProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserPropProcessor.java
new file mode 100644
index 0000000000..9b731ffb1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserPropProcessor.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.operationselector;
+
+
+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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSUserPropProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<OperationSelectorJMSUserProp> {
+
+ public QName getArtifactType() {
+ return OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_QNAME;
+ }
+
+ public OperationSelectorJMSUserPropProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public OperationSelectorJMSUserProp read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ OperationSelectorJMSUserProp opSelector = new OperationSelectorJMSUserProp();
+ String propertyName = reader.getAttributeValue(null, OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR);
+ if (propertyName != null && propertyName.length() > 0) {
+ opSelector.setPropertyName(propertyName);
+ } else {
+ throw new ContributionReadException(OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_QNAME.toString() + ": " +
+ OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR + " is a required attribute.");
+ }
+
+ return opSelector;
+ }
+
+ public void write(OperationSelectorJMSUserProp opSelector, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ if (opSelector.getPropertyName() != null) {
+ writer.writeAttribute(OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR, opSelector.getPropertyName());
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<OperationSelectorJMSUserProp> getModelType() {
+ return OperationSelectorJMSUserProp.class;
+ }
+
+ public void resolve(OperationSelectorJMSUserProp arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicy.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicy.java
new file mode 100644
index 0000000000..24f43d3027
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicy.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.policy.authentication.token;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationPolicy {
+ public static final QName JMS_TOKEN_AUTHENTICATION_POLICY_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "jmsTokenAuthentication");
+ public static final String JMS_TOKEN_AUTHENTICATION_TOKEN_NAME = "tokenName";
+
+ private QName tokenName;
+
+ public QName getTokenName() {
+ return tokenName;
+ }
+
+ public void setTokenName(QName tokenName) {
+ this.tokenName = tokenName;
+ }
+
+ public QName getSchemaName() {
+ return JMS_TOKEN_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java
new file mode 100644
index 0000000000..4322595515
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.policy.authentication.token;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<JMSTokenAuthenticationPolicy> {
+
+ public QName getArtifactType() {
+ return JMSTokenAuthenticationPolicy.JMS_TOKEN_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public JMSTokenAuthenticationPolicyProcessor(ExtensionPointRegistry registry) {
+ }
+
+
+ public JMSTokenAuthenticationPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ JMSTokenAuthenticationPolicy policy = new JMSTokenAuthenticationPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if ( name.equals(getArtifactType()) ) {
+ policy.setTokenName(getQName(reader, JMSTokenAuthenticationPolicy.JMS_TOKEN_AUTHENTICATION_TOKEN_NAME));
+ }
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( getArtifactType().equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(JMSTokenAuthenticationPolicy policy, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ if ( policy.getTokenName() != null ) {
+ writer.writeAttribute(prefix,
+ getArtifactType().getNamespaceURI(),
+ JMSTokenAuthenticationPolicy.JMS_TOKEN_AUTHENTICATION_TOKEN_NAME,
+ policy.getTokenName().toString());
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<JMSTokenAuthenticationPolicy> getModelType() {
+ return JMSTokenAuthenticationPolicy.class;
+ }
+
+ public void resolve(JMSTokenAuthenticationPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java
new file mode 100644
index 0000000000..48fef397c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.policy.header;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSHeaderPolicy {
+ public static final QName JMS_HEADER_POLICY_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "jmsHeader");
+ public static final String JMS_HEADER_JMS_TYPE = "JMSType";
+ public static final String JMS_HEADER_JMS_CORRELATION_ID = "JMSCorrelationID";
+ public static final String JMS_HEADER_JMS_DELIVERY_MODE = "JMSDeliveryMode";
+ public static final String JMS_HEADER_JMS_TIME_TO_LIVE = "JMSTimeToLive";
+ public static final String JMS_HEADER_JMS_PRIORITY = "JMSPriority";
+ public static final String JMS_HEADER_JMS_PROPERTY = "property";
+ public static final String JMS_HEADER_JMS_PROPERTY_NAME = "name";
+
+ private String jmsType = null;
+ private String jmsCorrelationId = null;
+ private Boolean deliveryModePersistent = null;
+ private Long timeToLive = null;
+ private Integer jmsPriority = null;
+ private Map<String, String> properties = new Hashtable<String, String>();
+
+ public String getJmsType() {
+ return jmsType;
+ }
+
+ public void setJmsType(String jmsType) {
+ this.jmsType = jmsType;
+ }
+
+ public String getJmsCorrelationId() {
+ return jmsCorrelationId;
+ }
+
+ public void setJmsCorrelationId(String jmsCorrelationId) {
+ this.jmsCorrelationId = jmsCorrelationId;
+ }
+
+ public Boolean getDeliveryModePersistent() {
+ return deliveryModePersistent;
+ }
+
+ public void setDeliveryModePersistent(Boolean deliveryModePersistent) {
+ this.deliveryModePersistent = deliveryModePersistent;
+ }
+
+ public Long getTimeToLive() {
+ return timeToLive;
+ }
+
+ public void setTimeToLive(Long timeToLive) {
+ this.timeToLive = timeToLive;
+ }
+
+ public Integer getJmsPriority() {
+ return jmsPriority;
+ }
+
+ public void setJmsPriority(Integer jmsPriority) {
+ this.jmsPriority = jmsPriority;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ public QName getSchemaName() {
+ return JMS_HEADER_POLICY_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ @Override
+ public String toString() {
+ String result = "jmsHeader";
+
+ result += " JMSType ";
+ result += getJmsType();
+ result += " JMSDeliveryMode ";
+ result += getJmsCorrelationId();
+ result += " JMSDeliveryMode ";
+ result += getDeliveryModePersistent();
+ result += " JMSTimeToLive ";
+ result += getTimeToLive();
+ result += " JMSPriority ";
+ result += getJmsPriority();
+
+ for (String propertyName : properties.keySet()){
+ result += " property ";
+ result += propertyName;
+ result += " ";
+ result += properties.get(propertyName);
+ }
+
+ return result;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java
new file mode 100644
index 0000000000..c925c01554
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.policy.header;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.assembly.xml.Messages;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSHeaderPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<JMSHeaderPolicy> {
+
+
+
+ public QName getArtifactType() {
+ return JMSHeaderPolicy.JMS_HEADER_POLICY_QNAME;
+ }
+
+ public JMSHeaderPolicyProcessor(ExtensionPointRegistry modelFactories) {
+ }
+
+ /**
+ * Marshals warnings into the monitor
+ *
+ * @param message
+ * @param model
+ * @param messageParameters
+ */
+ protected void warning(Monitor monitor, String message, Object model, String... messageParameters) {
+ if (monitor != null){
+ Problem problem = monitor.createProblem(this.getClass().getName(), Messages.RESOURCE_BUNDLE, Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Marshals errors into the monitor
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), Messages.RESOURCE_BUNDLE, Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+
+ public JMSHeaderPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ JMSHeaderPolicy policy = new JMSHeaderPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+ Monitor monitor = context.getMonitor();
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if ( name.equals(getArtifactType()) ) {
+
+ policy.setJmsType(getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_TYPE));
+ policy.setJmsCorrelationId(getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_CORRELATION_ID));
+
+ String deliveryMode = getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_DELIVERY_MODE);
+ if (deliveryMode != null){
+ if (deliveryMode.equals("PERSISTENT")) {
+ policy.setDeliveryModePersistent(true);
+ } else if (deliveryMode.equals("NON_PERSISTENT")){
+ policy.setDeliveryModePersistent(false);
+ } else {
+ error(monitor, "InvalidDeliveryMode", policy, deliveryMode);
+ }
+ }
+
+ String timeToLive = getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_TIME_TO_LIVE);
+
+ if ( timeToLive != null){
+ try {
+ policy.setTimeToLive(Long.valueOf(timeToLive));
+ } catch (NumberFormatException ex){
+ error(monitor, "InvalidTimeToLive", policy, timeToLive);
+ }
+ }
+
+ String priority = getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_PRIORITY);
+
+ if ( priority != null){
+ try {
+ policy.setJmsPriority(Integer.valueOf(priority));
+ } catch (NumberFormatException ex){
+ error(monitor, "InvalidPriority", policy, priority);
+ }
+ }
+ } else if (name.getLocalPart().equals(JMSHeaderPolicy.JMS_HEADER_JMS_PROPERTY)) {
+ String propertyName = getString(reader, JMSHeaderPolicy.JMS_HEADER_JMS_PROPERTY_NAME);
+ String propertyValue = reader.getElementText();
+ policy.getProperties().put(propertyName, propertyValue);
+ }
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( getArtifactType().equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(JMSHeaderPolicy policy, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ if (policy.getJmsType() != null){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_TYPE, policy.getJmsType());
+ }
+
+ if (policy.getJmsCorrelationId() != null){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_CORRELATION_ID, policy.getJmsCorrelationId());
+ }
+
+ if (policy.getDeliveryModePersistent() == true){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_DELIVERY_MODE, "PERSISTENT");
+ } else {
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_DELIVERY_MODE, "NON_PERSISTENT");
+ }
+
+ if (policy.getTimeToLive()!= null){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_TIME_TO_LIVE, policy.getTimeToLive().toString());
+ }
+
+ if (policy.getJmsPriority()!= null){
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_PRIORITY, policy.getJmsPriority().toString());
+ }
+
+ for (String propertyName : policy.getProperties().keySet()){
+ writer.writeStartElement(prefix,
+ JMSHeaderPolicy.JMS_HEADER_JMS_PROPERTY,
+ getArtifactType().getNamespaceURI());
+ writer.writeAttribute(JMSHeaderPolicy.JMS_HEADER_JMS_PROPERTY_NAME, propertyName);
+ writer.writeCharacters(policy.getProperties().get(propertyName));
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<JMSHeaderPolicy> getModelType() {
+ return JMSHeaderPolicy.class;
+ }
+
+ public void resolve(JMSHeaderPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytes.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytes.java
new file mode 100644
index 0000000000..a16cdc9c4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytes.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytes implements WireFormat {
+ public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "wireFormat.jmsBytes");
+
+ public QName getSchemaName() {
+ return WIRE_FORMAT_JMS_BYTES_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesProcessor.java
new file mode 100644
index 0000000000..8be904da3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesProcessor.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.sca.binding.jms.wireformat;
+
+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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WireFormatJMSBytes> {
+
+ public QName getArtifactType() {
+ return WireFormatJMSBytes.WIRE_FORMAT_JMS_BYTES_QNAME;
+ }
+
+ public WireFormatJMSBytesProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public WireFormatJMSBytes read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ WireFormatJMSBytes wireFormat = new WireFormatJMSBytes();
+
+ return wireFormat;
+ }
+
+ public void write(WireFormatJMSBytes wireFormat, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ writer.writeEndElement();
+ }
+
+ public Class<WireFormatJMSBytes> getModelType() {
+ return WireFormatJMSBytes.class;
+ }
+
+ public void resolve(WireFormatJMSBytes arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXML.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXML.java
new file mode 100644
index 0000000000..4f7a91657f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXML.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+
+public class WireFormatJMSBytesXML implements WireFormat {
+ public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "wireFormat.jmsBytesXML");
+
+ public QName getSchemaName() {
+ return WIRE_FORMAT_JMS_BYTES_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXMLProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXMLProcessor.java
new file mode 100644
index 0000000000..33533b23eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXMLProcessor.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat;
+
+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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+
+public class WireFormatJMSBytesXMLProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WireFormatJMSBytesXML> {
+
+ public QName getArtifactType() {
+ return WireFormatJMSBytesXML.WIRE_FORMAT_JMS_BYTES_QNAME;
+ }
+
+ public WireFormatJMSBytesXMLProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public WireFormatJMSBytesXML read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ WireFormatJMSBytesXML wireFormat = new WireFormatJMSBytesXML();
+
+ return wireFormat;
+ }
+
+ public void write(WireFormatJMSBytesXML wireFormat, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ writer.writeEndElement();
+ }
+
+ public Class<WireFormatJMSBytesXML> getModelType() {
+ return WireFormatJMSBytesXML.class;
+ }
+
+ public void resolve(WireFormatJMSBytesXML arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java
new file mode 100644
index 0000000000..3b429e5475
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefault implements WireFormat {
+ public static final QName WIRE_FORMAT_JMS_DEFAULT_QNAME = new QName(Constants.SCA11_NS, "wireFormat.jmsDefault");
+
+ public static final String WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR = "sendFormat";
+
+ public static final String WIRE_FORMAT_JMS_DEFAULT_TEXT_FORMAT_VAL = "text";
+ public static final String WIRE_FORMAT_JMS_DEFAULT_BYTES_FORMAT_VAL = "bytes";
+
+ //default is to use a javax.jms.BytesMessage
+ private boolean useBytesMessage = true;
+
+ public QName getSchemaName() {
+ return WIRE_FORMAT_JMS_DEFAULT_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this.getClass() == obj.getClass();
+ }
+
+ public void setUseBytesMessage(boolean useBytesMessage) {
+ this.useBytesMessage = useBytesMessage;
+ }
+
+ public boolean isUseBytesMessage() {
+ return useBytesMessage;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefaultProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefaultProcessor.java
new file mode 100644
index 0000000000..6b5488a168
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefaultProcessor.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.sca.binding.jms.wireformat;
+
+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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WireFormatJMSDefault> {
+
+ public QName getArtifactType() {
+ return WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_QNAME;
+ }
+
+ public WireFormatJMSDefaultProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ public WireFormatJMSDefault read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ WireFormatJMSDefault wireFormat = new WireFormatJMSDefault();
+
+ String sendFormat = reader.getAttributeValue(null, WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR);
+ if (sendFormat != null && sendFormat.length() > 0) {
+ if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_TEXT_FORMAT_VAL.equalsIgnoreCase(sendFormat)) {
+ wireFormat.setUseBytesMessage(false);
+ }else if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_BYTES_FORMAT_VAL.equalsIgnoreCase(sendFormat)) {
+ wireFormat.setUseBytesMessage(true);
+ }else{
+ throw new ContributionReadException(WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_QNAME.toString() +" " +sendFormat + " is not a valid attribute value for " +
+ WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR);
+ }
+ }
+
+ return wireFormat;
+ }
+
+ public void write(WireFormatJMSDefault wireFormat, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix, getArtifactType().getLocalPart(), getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ if (wireFormat.isUseBytesMessage()) {
+ writer.writeAttribute(WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR, WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_BYTES_FORMAT_VAL);
+ } else {
+ writer.writeAttribute(WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR, WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_TEXT_FORMAT_VAL);
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<WireFormatJMSDefault> getModelType() {
+ return WireFormatJMSDefault.class;
+ }
+
+ public void resolve(WireFormatJMSDefault arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObject.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObject.java
new file mode 100644
index 0000000000..e043139010
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObject.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.binding.jms.wireformat;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObject implements WireFormat {
+ public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "wireFormat.jmsObject");
+
+ public static final String WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR = "wrapSingle";
+
+ private boolean wrappedSingleInput = false;
+
+ public QName getSchemaName() {
+ return WIRE_FORMAT_JMS_BYTES_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ public void setWrappedSingleInput(boolean wrappedSingleInput) {
+ this.wrappedSingleInput = wrappedSingleInput;
+ }
+
+ public boolean isWrappedSingleInput() {
+ return wrappedSingleInput;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObjectProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObjectProcessor.java
new file mode 100644
index 0000000000..cf0c0db0d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObjectProcessor.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.jms.wireformat;
+
+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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WireFormatJMSObject> {
+
+ public QName getArtifactType() {
+ return WireFormatJMSObject.WIRE_FORMAT_JMS_BYTES_QNAME;
+ }
+
+ public WireFormatJMSObjectProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public WireFormatJMSObject read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ WireFormatJMSObject wireFormat = new WireFormatJMSObject();
+
+ String wrappedSingleInput = reader.getAttributeValue(null, WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR);
+ if (wrappedSingleInput != null && wrappedSingleInput.length() > 0) {
+ if ("true".equalsIgnoreCase(wrappedSingleInput)) {
+ wireFormat.setWrappedSingleInput(true);
+ } else if ("false".equalsIgnoreCase(wrappedSingleInput)) {
+ wireFormat.setWrappedSingleInput(false);
+ } else {
+ throw new ContributionReadException(WireFormatJMSObject.WIRE_FORMAT_JMS_BYTES_QNAME.toString() + ": " + wrappedSingleInput +
+ " is not a valid attribute value for " + WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR);
+ }
+ }
+ return wireFormat;
+ }
+
+ public void write(WireFormatJMSObject wireFormat, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ writer.writeAttribute(WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR, String.valueOf(wireFormat.isWrappedSingleInput()));
+
+ writer.writeEndElement();
+ }
+
+ public Class<WireFormatJMSObject> getModelType() {
+ return WireFormatJMSObject.class;
+ }
+
+ public void resolve(WireFormatJMSObject arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSText.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSText.java
new file mode 100644
index 0000000000..4f728cea92
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSText.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSText implements WireFormat {
+ public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "wireFormat.jmsText");
+
+ public QName getSchemaName() {
+ return WIRE_FORMAT_JMS_BYTES_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextProcessor.java
new file mode 100644
index 0000000000..5c564e044c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextProcessor.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.sca.binding.jms.wireformat;
+
+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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WireFormatJMSText> {
+
+ public QName getArtifactType() {
+ return WireFormatJMSText.WIRE_FORMAT_JMS_BYTES_QNAME;
+ }
+
+ public WireFormatJMSTextProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public WireFormatJMSText read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ WireFormatJMSText wireFormat = new WireFormatJMSText();
+
+ return wireFormat;
+ }
+
+ public void write(WireFormatJMSText wireFormat, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ writer.writeEndElement();
+ }
+
+ public Class<WireFormatJMSText> getModelType() {
+ return WireFormatJMSText.class;
+ }
+
+ public void resolve(WireFormatJMSText arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXML.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXML.java
new file mode 100644
index 0000000000..be6187d2c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXML.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.wireformat;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXML implements WireFormat {
+ public static final QName WIRE_FORMAT_JMS_DEFAULT_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "wireFormat.jmsTextXML");
+
+ public QName getSchemaName() {
+ return WIRE_FORMAT_JMS_DEFAULT_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this.getClass() == obj.getClass();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXMLProcessor.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXMLProcessor.java
new file mode 100644
index 0000000000..ae544f3163
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXMLProcessor.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.sca.binding.jms.wireformat;
+
+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.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WireFormatJMSTextXML> {
+
+ public QName getArtifactType() {
+ return WireFormatJMSTextXML.WIRE_FORMAT_JMS_DEFAULT_QNAME;
+ }
+
+ public WireFormatJMSTextXMLProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public WireFormatJMSTextXML read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ WireFormatJMSTextXML wireFormat = new WireFormatJMSTextXML();
+
+ return wireFormat;
+ }
+
+ public void write(WireFormatJMSTextXML wireFormat, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS);
+
+ writer.writeEndElement();
+ }
+
+ public Class<WireFormatJMSTextXML> getModelType() {
+ return WireFormatJMSTextXML.class;
+ }
+
+ public void resolve(WireFormatJMSTextXML arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..8e984c511e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.jms.JMSBindingProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#binding.jms,model=org.apache.tuscany.sca.binding.jms.JMSBinding
+org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefaultProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#wireFormat.jmsDefault,model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault
+org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXMLProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.jmsTextXML,model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML
+org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.jmsBytes,model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes
+org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXMLProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.jmsBytesXML,model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXML
+org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.jmsText,model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSText
+org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObjectProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.jmsObject,model=org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject
+org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSDefaultProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#operationSelector.jmsDefault,model=org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSDefault
+org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSUserPropProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#operationSelector.jmsUserProp,model=org.apache.tuscany.sca.binding.jms.operationselector.OperationSelectorJMSUserProp
+org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#jmsTokenAuthentication,model=org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy
+org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#jmsHeader,model=org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..01b45bf203
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/binding/jms/policy/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties
new file mode 100644
index 0000000000..fd43b2c4e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+InvalidDeliveryMode = JMSDeliveryMode must be either PERSISTENT or NON_PERSISTENT but found {0}
+InvalidTimeToLive = JMSTimeToLive must be a long integer but found {0}
+InvalidPriority = JMSPriority must be a integer but found {0}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties
new file mode 100644
index 0000000000..91b24bb1a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties
@@ -0,0 +1,58 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+DoesntProcessOperationProperties = JMS Binding doesn't process operationProperties yet
+DoesntProcessHeaders = JMS Binding doesn't process headers yet
+DoesntProcessResourceAdapter = JMS Binding doesn't process resourceAdapter yet
+DoesntProcessResponseConnectionFactory = JMS Binding doesn't process response connectionFactory yet
+DoesntProcessResponseActivationSpec = JMS Binding doesn't process response activationSpec yet
+DoesntProcessResponseDestinationType = JMS Binding doesn't process response destination type yet
+DoesntProcessActivationSpec = JMS Binding doesn't process activationSpec yet
+DoesntProcessDestinationType = JMS Binding doesn't process destination type yet
+MissingConnectionFactoryName = Missing ConnectionFactory Name
+MissingResponseConnectionFactory = Missing response connectionFactory name
+InvalidResponseDestinationType = Invalid response destination type: {0}
+InvalidDestinationType = Invalid destination type: {0}
+MissingActivationSpecName = Missing ActivationSpec Name
+MissingResponseActivationSpec = Missing response ActivationSpec name
+UnknownTokenInURI = Unknown token {0} in uri: {1}
+MustStartWithSchema = URI must start with the scheme 'jms:jndi:' or 'jms:queue:' or 'jms:topic:' for uri: {0}
+InvalidCorrelationScheme = Invalid correlationScheme: {0}
+UnexpectedElement = Incomplete binding.jms definition found unexpected element: {0}
+UnexpectedResponseElement = Incomplete binding.jms/response definition found unexpected element: {0}
+InvalidJMSDeliveryMode = Invalid JMSDeliveryMode: {0}
+InvalidJMSPriority = Invalid JMSPriority: {0}
+MissingJMSOperationPropertyName = Missing JMSOperationProperty Name
+InvalidOPJMSDeliveryMode = Invalid OPJMSDeliveryMode: {0}
+InvalidOPJMSPriority = Invalid OPJMSPriority: {0}
+DestinationQueueContradiction = Destination type queue contradicts connection factory name: {0}
+DestinationTopicContradiction = Destination type topic contradicts connection factory name: {0}
+ConnectionFactoryActivationSpecContradiction = Connection factory \"{0}\" and activation specification \"{0}\" are mutually exclusive
+ConnectionFactoryDestinationContradiction = When connection factory \"{0}\" element is present then a destination name must also be defined
+ResponseAttrElement = Response connection \"{0}\" and response element \"{1}\" are mutually exclusive
+BindingNotFound = {0} refers to a binding definition {1} which is not found
+DuplicateOperationProperties = Must not use both operationProperties attribute and operationProperties element
+WireFormatAlreadyDefined = The request wireformat has already been defined. Only one request wire format can be specified.
+OpSelectorAlreadyDefined = More than one operation selector has been specified. Only one operation selector can be specified.
+ResponseWireformatAlreadyDefined = The response wireformat has already been defined. Only one response wire format can be specified.
+MissingNameForCREATE_NEVER = Must specify jndiName attribute when create mode is "never"
+MissingNameForCREATE_IF_NOT_EXIST = Must specify jndiName attribute when create mode is "ifNotExist"
+InvalidCreate = Attribute create {0} invalid, must be 'always', 'never', or 'ifNotExist'
+ActivationSpecAndDestinationMismatch = Activation spec name {0} must match destination name {1}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml
new file mode 100644
index 0000000000..343b4fc295
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:bindingType type="sca:binding.jms"
+ alwaysProvides="sca:JMS"
+ mayProvide="sca:atLeastOnce sca:atMostOnce sca:ordered sca:asyncInvocation" />
+
+</sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
new file mode 100644
index 0000000000..e945da22e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
@@ -0,0 +1,773 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import java.io.StringReader;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytes;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSObject;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+
+/**
+ * Tests for JMS binding xml
+ */
+public class JMSBindingProcessorTestCase extends TestCase {
+ // Note: If you are adding new JMS binding read test cases,
+ // consider adding a similar test case to JMSBindingProcessorWriteTestCase.
+ public static final String COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:jndi:testQueue\" />"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String HEADERS1 =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <headers type=\"myType\" deliveryMode=\"persistent\" timeToLive=\"54321\" priority=\"5\">"
+ + " </headers>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String HEADERS_INVALID_PRIORITY =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <headers type=\"myType\" deliveryMode=\"persistent\" timeToLive=\"54321\" priority=\"medium\">"
+ + " </headers>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String PROPERTIES1 =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <headers>"
+ + " <property name=\"p1\">bla</property>"
+ + " <property name=\"intProp\" type=\"int\">42</property>"
+ + " </headers>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String OP_PROPERTIES1 =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <operationProperties name=\"op1\">"
+ + " <headers type=\"op1Type\" >"
+ + " <property name=\"p1\">bla</property>"
+ + " <property name=\"intProp\" type=\"int\">42</property>"
+ + " </headers>"
+ + " </operationProperties >"
+ + " <operationProperties name=\"op2\" nativeOperation=\"nativeOp2\" >"
+ + " <headers type=\"op2Type\">"
+ + " <property name=\"p2\">op2bla</property>"
+ + " <property name=\"intProp\" type=\"int\">77</property>"
+ + " </headers>"
+ + " </operationProperties >"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String OP_NAMES_NO_PROPERTIES1 =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <operationProperties name=\"op1\">"
+ + " </operationProperties >"
+ + " <operationProperties name=\"op2\" nativeOperation=\"nativeOp2\" >"
+ + " </operationProperties >"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String SELECTOR =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <messageSelection selector=\"prop1 = 2\" />"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String COMPOSITE_INVALID_URI =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"invalidjms:testQueue\" />"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ // Invalid: contains both a response attribute and a response element.
+ public static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" responseConnection=\"responseConnectionAttrName\">"
+ + " <response>"
+ + " <destination jndiName=\"responseConnectionElementName\"/>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String DEST_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <destination jndiName=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </destination>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String CF_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <connectionFactory jndiName=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </connectionFactory>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String AS_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <activationSpec name=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </activationSpec>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String RESP_DEST_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <response>"
+ + " <destination jndiName=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </destination>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String RESP_CF_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <response>"
+ + " <connectionFactory jndiName=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </connectionFactory>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String RESP_AS_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <response>"
+ + " <activationSpec name=\"foo\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </activationSpec>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String OP_PROPS_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <operationProperties name=\"op1\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </operationProperties >"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String RES_ADPT_PROPS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <resourceAdapter name=\"r1\">"
+ + " <property name=\"xxx\" type=\"yyy\">"
+ + " some value text"
+ + " </property>"
+ + " <property name=\"two\">"
+ + " bla"
+ + " </property>"
+ + " </resourceAdapter>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String CONFIGURED_OPERATIONS =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <operationProperties name=\"op1\">"
+ + " </operationProperties >"
+ + " <operation name=\"op1\" requires=\"IntentOne IntentTwo\"/>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String WIRE_FORMAT =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <response>"
+ + " <destination jndiName=\"responseConnectionElementName\"/>"
+ + " <tuscany:wireFormat.jmsBytes/>"
+ + " </response>"
+ + " <tuscany:wireFormat.jmsObject/>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ public static final String OP_PROP_NAME =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms operationProperties=\"foo\"/>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ private XMLInputFactory inputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+
+ }
+
+ /**
+ * Test parsing valid composite definition. Valid composite populated with correct values expected.
+ * @throws Exception
+ */
+ public void testLoadValidComposite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("testQueue", binding.getDestinationName());
+ }
+
+ public void testHeaders1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(HEADERS1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("myType", binding.getJMSType());
+ assertTrue(binding.isdeliveryModePersistent());
+ assertEquals(54321, binding.getJMSTimeToLive().longValue());
+ assertEquals(5, binding.getJMSPriority().intValue());
+ }
+
+ public void testProperties1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("bla", binding.getProperty("p1"));
+ assertEquals(42, ((Integer)binding.getProperty("intProp")).intValue());
+ }
+
+ public void testOpProperties1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ Map<String, Object> op1Props = binding.getOperationProperties("op1");
+ assertEquals("op1Type", binding.getOperationJMSType("op1"));
+ assertEquals("bla", op1Props.get("p1"));
+ assertEquals(42, ((Integer)op1Props.get("intProp")).intValue());
+
+ assertEquals("op2Type", binding.getOperationJMSType("op2"));
+ Map<String, Object> op2Props = binding.getOperationProperties("op2");
+ assertEquals("op2bla", op2Props.get("p2"));
+ assertEquals(77, ((Integer)op2Props.get("intProp")).intValue());
+ }
+
+ public void testSubscriptionHeaders () throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(SELECTOR));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ assertEquals("prop1 = 2", binding.getJMSSelector());
+ }
+
+ /** Test various parsing validation requirements. */
+ public void testParsingValidationErrors1() throws Exception {
+ // Composite with malformed URI.
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID_URI));
+
+ try {
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ } catch(Exception e) {
+ // JMSBindingExceptions are expected with invalid composite.
+ if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
+ throw e;
+ // Do assertion to make sure test registers results.
+ assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
+ }
+ }
+
+ public void testParsingValidationErrors2() throws Exception {
+ // Composite with invalid priority
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(HEADERS_INVALID_PRIORITY));
+
+ try {
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ } catch(Exception e) {
+ // JMSBindingExceptions are expected with invalid composite.
+ if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
+ throw e;
+ // Do assertion to make sure test registers results.
+ assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
+ return;
+ }
+ }
+
+ /** Test various model validation requirements. */
+ public void testValidationErrors1() throws Exception {
+ // Composite with response connection attr and element.
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT));
+
+ try {
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ } catch(Exception e) {
+ // JMSBindingExceptions are expected with invalid composite.
+ if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
+ throw e;
+ // Do assertion to make sure test registers results.
+ assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
+ }
+ }
+
+ public void testDestinationProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(DEST_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getDestinationProperties());
+ assertEquals(2, binding.getDestinationProperties().size());
+ BindingProperty bp = binding.getDestinationProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getDestinationProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testConnectionFactoryProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(CF_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getConnectionFactoryProperties());
+ assertEquals(2, binding.getConnectionFactoryProperties().size());
+ BindingProperty bp = binding.getConnectionFactoryProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getConnectionFactoryProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testActivationSpecProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(AS_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getActivationSpecProperties());
+ assertEquals(2, binding.getActivationSpecProperties().size());
+ BindingProperty bp = binding.getActivationSpecProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getActivationSpecProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testResponseDestinationProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_DEST_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getResponseDestinationProperties());
+ assertEquals(2, binding.getResponseDestinationProperties().size());
+ BindingProperty bp = binding.getResponseDestinationProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getResponseDestinationProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testResponseConnectionFactoryProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_CF_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getResponseConnectionFactoryProperties());
+ assertEquals(2, binding.getResponseConnectionFactoryProperties().size());
+ BindingProperty bp = binding.getResponseConnectionFactoryProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getResponseConnectionFactoryProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testResponseActivationSpecProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RESP_AS_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getResponseActivationSpecProperties());
+ assertEquals(2, binding.getResponseActivationSpecProperties().size());
+ BindingProperty bp = binding.getResponseActivationSpecProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getResponseActivationSpecProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testOperationPropertiesProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPS_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertNotNull(binding.getOperationPropertiesProperties("op1"));
+ assertEquals(2, binding.getOperationPropertiesProperties("op1").size());
+ BindingProperty bp = binding.getOperationPropertiesProperties("op1").get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getOperationPropertiesProperties("op1").get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+ public void testResouceAdapterProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(RES_ADPT_PROPS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("r1", binding.getResourceAdapterName());
+ assertNotNull(binding.getResourceAdapterProperties());
+ assertEquals(2, binding.getResourceAdapterProperties().size());
+ BindingProperty bp = binding.getResourceAdapterProperties().get("xxx");
+ assertEquals("xxx", bp.getName());
+ assertEquals("yyy", bp.getType());
+ assertEquals("some value text", bp.getValue().toString().trim());
+ BindingProperty bp2 = binding.getResourceAdapterProperties().get("two");
+ assertEquals("two", bp2.getName());
+ assertEquals(null, bp2.getType());
+ assertEquals("bla", bp2.getValue().toString().trim());
+ }
+
+ /**
+ * Tests the APIs:
+ * public Set<String> getOperationNames();
+ * public Object getOperationProperty(String opName, String propName );
+ * @throws Exception
+ */
+ public void testOpProperties2() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ Set<String> opNames = binding.getOperationNames();
+ assertEquals( 2, opNames.size() );
+ // Recall that order is not guaranteed iterating over a set.
+ for (Iterator<String> it=opNames.iterator(); it.hasNext(); ) {
+ String opName = it.next();
+ assertTrue( opName.equals( "op1") || opName.equals( "op2"));
+ }
+
+ Object value = binding.getOperationProperty( "op1", "p1" );
+ assertEquals("bla", value);
+ value = binding.getOperationProperty( "op1", "intProp" );
+ assertEquals(42, ((Integer)value).intValue());
+
+ value = binding.getOperationProperty( "op2", "p2" );
+ assertEquals("op2bla", value);
+ value = binding.getOperationProperty( "op2", "intProp" );
+ assertEquals(77, ((Integer)value).intValue());
+ }
+
+ /**
+ * Tests the APIs:
+ * public Set<String> getOperationNames();
+ * Provides no optional properties or sub elements
+ * @throws Exception
+ */
+ public void testOpProperties3() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_NAMES_NO_PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ Set<String> opNames = binding.getOperationNames();
+ assertEquals( 2, opNames.size() );
+ // Recall that order is not guaranteed iterating over a set.
+ for (Iterator<String> it=opNames.iterator(); it.hasNext(); ) {
+ String opName = it.next();
+ assertTrue( opName.equals( "op1") || opName.equals( "op2"));
+ }
+ }
+
+ /**
+ * Tests the APIs:
+ * public Set<String> getOperationNames();
+ * Provides no optional properties or sub elements
+ * @throws Exception
+ */
+ public void testConfiguredOperations1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(CONFIGURED_OPERATIONS));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ OperationsConfigurator opConfig = ((OperationsConfigurator)binding);
+ assertEquals(opConfig.getConfiguredOperations().get(0).getRequiredIntents().size(), 2);
+ }
+
+ /**
+ * Tests the APIs:
+ * public WireFormat getRequstWireFormat();
+ * public WireFormat getResponseWireFormat();
+ *
+ * @throws Exception
+ */
+ public void testWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(WIRE_FORMAT));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ WireFormat requestWireFormat = binding.getRequestWireFormat();
+ assertEquals(WireFormatJMSObject.class, requestWireFormat.getClass());
+
+ WireFormat responseWireFormat = binding.getResponseWireFormat();
+ assertEquals(WireFormatJMSBytes.class, responseWireFormat.getClass());
+ }
+
+ public void testOpPropertiesName() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_PROP_NAME));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals( "foo", binding.getOperationPropertiesName().getLocalPart() );
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java
new file mode 100644
index 0000000000..db138aa30d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java
@@ -0,0 +1,438 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+
+/**
+ * Tests for JMS binding XML writes.
+ * In general, for each JMS binding XML read test case, there
+ * is a write test case.
+ */
+public class JMSBindingProcessorWriteTestCase extends TestCase {
+
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+
+ public static final String DEFAULT =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms>"
+ + " <destination jndiName=\"AAA\">"
+ + " <property name=\"AAAProp\" type=\"string\"/>"
+ + " </destination>"
+ + " <connectionFactory jndiName=\"ABC\"/>"
+ + " <response/>"
+ + " <headers/>"
+ + " <resourceAdapter name=\"GHI\"/>"
+ + " <operationProperties name=\"JKL\">"
+ + " </operationProperties>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ private ProcessorContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ /**
+ * Test parsing valid composite definition. Valid composite populated with correct values expected.
+ * @throws Exception
+ */
+ public void testLoadValidComposite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.COMPOSITE));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals( binding, binding2);
+ }
+
+ public void testHeaders1() throws Exception {
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.HEADERS1)), context);
+ JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals( binding, binding2 );
+ }
+
+ public void testProperties1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.PROPERTIES1));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals( binding, binding2 );
+ }
+
+ public void testOpProperties1() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.OP_PROPERTIES1));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testSubscriptionHeaders() throws Exception {
+ XMLStreamReader reader =
+ inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.SELECTOR));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testDestinationProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.DEST_PROPS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testConnectionFactoryProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.CF_PROPS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testActivationSpecProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.AS_PROPS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testResponseDestinationProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.RESP_DEST_PROPS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testResponseConnectionFactoryProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.RESP_CF_PROPS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testResponseActivationSpecProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.RESP_AS_PROPS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testOperationPropertiesProperties() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.OP_PROPS_PROPS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testResouceAdapterProperties() throws Exception {
+ XMLStreamReader reader =
+ inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.RES_ADPT_PROPS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testConfiguredOperations() throws Exception {
+ XMLStreamReader reader =
+ inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.CONFIGURED_OPERATIONS));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ public void testWireFormat() throws Exception {
+ XMLStreamReader reader =
+ inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.WIRE_FORMAT));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals(binding, binding2);
+ }
+
+ // TUSCANY-3120
+ // Checking we don't write out values unless the use has specified them on input
+ public void testDefault() throws Exception {
+ XMLStreamReader reader =
+ inputFactory.createXMLStreamReader(new StringReader(DEFAULT));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ System.out.println(bos.toString());
+ assertEquals(bos.toString(),
+ "<?xml version=\'1.0\' encoding=\'UTF-8\'?>" +
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">" +
+ "<component name=\"HelloWorldComponent\">" +
+ "<service name=\"HelloWorldService\">" +
+ "<binding.jms><operationProperties name=\"JKL\" /> " +
+ "<destination jndiName=\"AAA\">" +
+ "<property name=\"AAAProp\" type=\"string\"></property>" +
+ "</destination> " +
+ "<connectionFactory jndiName=\"ABC\" /> "+
+ "<resourceAdapter name=\"GHI\" /> " +
+ "</binding.jms>" +
+ "</service>" +
+ "</component>" +
+ "</composite>");
+ }
+
+ public void testOperationPropertiesName() throws Exception {
+ XMLStreamReader reader =
+ inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.OP_PROP_NAME));
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding);
+
+ // Write out JMSBinding model to stream.
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ // Read written JMSBinding to a different JMSBinding model.
+ XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+ Composite composite2 = (Composite)staxProcessor.read(reader2, context);
+ JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+ assertNotNull(binding2);
+
+ // Compare initial binding to written binding.
+ assertEquals("foo", binding2.getOperationPropertiesName().getLocalPart());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java
new file mode 100644
index 0000000000..326bb54cca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jms.policy;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy;
+import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicyProcessor;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy;
+import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicyProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Ignore("TODO: 2.x migration")
+public class PolicyProcessorTestCase {
+ private final static List<String> SEQ =
+ Arrays.asList("<tuscany:jmsHeader xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" JMSType=\"ABC\" JMSDeliveryMode=\"PERSISTENT\" JMSTimeToLive=\"123\" JMSPriority=\"4\"><tuscany:property name=\"aProperty\">property value</tuscany:property></tuscany:jmsHeader>",
+ "<tuscany:jmsTokenAuthentication xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" tuscany:tokenName=\"{http://tuscany.apache.org/foo}myname\" />");
+
+ @Test
+ public void testRead() throws Exception {
+ List<String> results = new ArrayList<String>();
+ Map<QName, StAXArtifactProcessor> processors = new HashMap<QName, StAXArtifactProcessor>();
+ processors.put(JMSHeaderPolicy.JMS_HEADER_POLICY_QNAME, new JMSHeaderPolicyProcessor(null));
+ processors.put(JMSTokenAuthenticationPolicy.JMS_TOKEN_AUTHENTICATION_POLICY_QNAME, new JMSTokenAuthenticationPolicyProcessor(null));
+
+ InputStream is = getClass().getResourceAsStream("mock_policy_definitions.xml");
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ ProcessorContext context =new ProcessorContext();
+ while (true) {
+ int event = reader.getEventType();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ if ("policySet".equals(reader.getName().getLocalPart())) {
+ reader.nextTag();
+ StAXArtifactProcessor processor = processors.get(reader.getName());
+ Object xxx = processor.read(reader, context);
+// Policy policy = (Policy)processor.read(reader);
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(outputStream);
+ processor.write(xxx, writer, context);
+// processor.write(policy, writer);
+ writer.flush();
+ results.add(outputStream.toString());
+ }
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ Assert.assertEquals(SEQ, results);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/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/sebastien/java/embed/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9c5633ae1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JSONP Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JSONP Binding Model
+Import-Package: javax.servlet;version="2.5.0",
+ javax.servlet.http;version="2.5.0",
+ org.apache.commons.codec,
+ org.apache.commons.codec.net,
+ org.apache.http;version="4.0.1",
+ org.apache.http.client;version="4.0.0",
+ org.apache.http.client.methods;version="4.0.0",
+ org.apache.http.client.utils;version="4.0.0",
+ org.apache.http.conn;version="4.0.0",
+ org.apache.http.impl.client;version="4.0.0",
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.jsonp;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.codehaus.jackson,
+ org.codehaus.jackson.map
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.jsonp.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/pom.xml
new file mode 100644
index 0000000000..7b9b31c35d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/pom.xml
@@ -0,0 +1,104 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <name>Apache Tuscany SCA JSONP Binding Runtime</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java
new file mode 100644
index 0000000000..1f2ed09c07
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.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.binding.jsonp.runtime;
+
+import org.apache.tuscany.sca.binding.jsonp.JSONPBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+public class JSONPBindingProviderFactory implements BindingProviderFactory<JSONPBinding> {
+
+ private ServletHost servletHost;
+
+ public JSONPBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ }
+
+ public Class<JSONPBinding> getModelType() {
+ return JSONPBinding.class;
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpoint) {
+ return new JSONPReferenceBindingProvider(endpoint);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new JSONPServiceBindingProvider(endpoint, servletHost);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
new file mode 100644
index 0000000000..6b0bfec213
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jsonp.runtime;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.commons.codec.EncoderException;
+import org.apache.commons.codec.net.URLCodec;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+
+public class JSONPInvoker implements Invoker {
+
+ protected Operation operation;
+ protected EndpointReference endpoint;
+
+ protected ObjectMapper mapper; // TODO: share mapper btw invoker and servlet or move to databinding
+
+ public JSONPInvoker(Operation operation, EndpointReference endpoint) {
+ this.operation = operation;
+ this.endpoint = endpoint;
+ this.mapper = new ObjectMapper();
+ }
+
+ public Message invoke(Message msg) {
+ try {
+
+ return doInvoke(msg);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Message doInvoke(Message msg) throws JsonGenerationException, JsonMappingException, IOException, EncoderException {
+ String uri = endpoint.getBinding().getURI() + "/" + operation.getName();
+ //String[] jsonArgs = objectsToJSON((Object[])msg.getBody());
+ String[] jsonArgs = objectsToJSONStrings((Object[])msg.getBody());
+
+ String responseJSON = invokeHTTPRequest(uri, jsonArgs);
+
+ //Object response = jsonToObjects(responseJSON)[0];
+ msg.setBody(responseJSON);
+
+ return msg;
+ }
+
+ protected String invokeHTTPRequest(String url, String[] jsonArgs) throws IOException, EncoderException {
+
+ HttpClient httpclient = new DefaultHttpClient();
+
+
+ URLCodec uc = new URLCodec();
+ for (int i=0 ; i<jsonArgs.length; i++) {
+ if (i == 0) {
+ url += '?';
+ } else {
+ url += '&';
+ }
+ url += "arg" + i + "=";
+ url += uc.encode(jsonArgs[i]);
+ }
+
+ HttpGet httpget = new HttpGet(url);
+
+ HttpResponse response = httpclient.execute(httpget);
+
+ StringBuffer responseJSON = new StringBuffer();
+
+ HttpEntity entity = response.getEntity();
+
+ // If the response does not enclose an entity, there is no need
+ // to worry about connection release
+ if (entity != null) {
+ InputStream instream = entity.getContent();
+ try {
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
+ String s = null;
+ while ((s = reader.readLine()) != null) {
+ responseJSON.append(s);
+ }
+
+ } catch (IOException ex) {
+
+ // In case of an IOException the connection will be released
+ // back to the connection manager automatically
+ throw ex;
+
+ } catch (RuntimeException ex) {
+
+ // In case of an unexpected exception you may want to abort
+ // the HTTP request in order to shut down the underlying
+ // connection and release it back to the connection manager.
+ httpget.abort();
+ throw ex;
+
+ } finally {
+
+ // Closing the input stream will trigger connection release
+ instream.close();
+
+ }
+
+ // When HttpClient instance is no longer needed,
+ // shut down the connection manager to ensure
+ // immediate deallocation of all system resources
+ httpclient.getConnectionManager().shutdown();
+ }
+
+ return responseJSON.toString();
+ }
+
+/* Not required now JSON conversion is delegated to databinding
+ protected String[] objectsToJSON(Object[] msgArgs) throws JsonGenerationException, JsonMappingException, IOException {
+ String[] jsonArgs = new String[msgArgs.length];
+ for (int i=0; i<msgArgs.length; i++) {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ mapper.writeValue(os , msgArgs[i]);
+ jsonArgs[i] = os.toString();
+ }
+ return jsonArgs;
+ }
+*/
+
+ protected String[] objectsToJSONStrings(Object[] msgArgs) throws JsonGenerationException, JsonMappingException, IOException {
+ String[] jsonArgs = new String[msgArgs.length];
+ for (int i=0; i<msgArgs.length; i++) {
+ jsonArgs[i] = msgArgs[i].toString();
+ }
+ return jsonArgs;
+ }
+
+/* Not required now JSON conversion is delegated to databinding
+ protected Object[] jsonToObjects(String jsonRequest) throws JsonParseException, JsonMappingException, IOException {
+ Class<?> c = new Object[0].getClass();
+ Object[] args = (Object[])mapper.readValue("[" + jsonRequest +"]", c);
+ return args;
+ }
+*/
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java
new file mode 100644
index 0000000000..eda70e275e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.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.sca.binding.jsonp.runtime;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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;
+
+public class JSONPReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private EndpointReference endpoint;
+ private InterfaceContract contract;
+
+ public JSONPReferenceBindingProvider(EndpointReference endpoint) {
+ this.endpoint = endpoint;
+
+ try {
+ contract = (InterfaceContract)endpoint.getComponentReferenceInterfaceContract().clone();
+ } catch (Exception ex){
+ // we know this supports clone
+ }
+ contract.getInterface().resetDataBinding("JSON");
+ }
+ public Invoker createInvoker(Operation operation) {
+ return new JSONPInvoker(operation, endpoint);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return contract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java
new file mode 100644
index 0000000000..991aeb3a21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.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.sca.binding.jsonp.runtime;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+public class JSONPServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+ private ServletHost servletHost;
+ private InterfaceContract contract;
+
+ public JSONPServiceBindingProvider(RuntimeEndpoint endpoint, ServletHost servletHost) {
+ this.endpoint = endpoint;
+ this.servletHost = servletHost;
+
+ try {
+ contract = (InterfaceContract)endpoint.getComponentServiceInterfaceContract().clone();
+ } catch (Exception ex){
+ // we know this supports clone
+ }
+ contract.getInterface().resetDataBinding("JSON");
+ }
+
+ public void start() {
+ ComponentService service = endpoint.getService();
+ Interface serviceInterface = service.getInterfaceContract().getInterface();
+ for (Operation op : serviceInterface.getOperations()) {
+ JSONPServlet servlet = new JSONPServlet(endpoint, op);
+ String path = endpoint.getBinding().getURI() + "/" + op.getName();
+ servletHost.addServletMapping(path, servlet);
+ }
+ }
+
+ public void stop() {
+ ComponentService service = endpoint.getService();
+ Interface serviceInterface = service.getInterfaceContract().getInterface();
+ for (Operation op : serviceInterface.getOperations()) {
+ String path = endpoint.getBinding().getURI() + "/" + op.getName();
+ servletHost.removeServletMapping(path);
+ }
+ }
+
+ // TODO: Why are these two still on the ServiceBindingProvider interface?
+ public InterfaceContract getBindingInterfaceContract() {
+ return contract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java
new file mode 100644
index 0000000000..aadb4d9853
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jsonp.runtime;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.servlet.GenericServlet;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+
+public class JSONPServlet extends GenericServlet {
+ private static final long serialVersionUID = 1L;
+
+ protected transient RuntimeEndpoint wire;
+ protected transient Operation operation;
+ protected transient ObjectMapper mapper;
+
+ public JSONPServlet(RuntimeEndpoint wire, Operation operation) {
+ this.wire = wire;
+ this.operation = operation;
+ this.mapper = new ObjectMapper();
+ }
+
+ @Override
+ public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
+ //String jsonRequest = getJSONRequest(servletRequest);
+ //Object[] args = jsonToObjects(jsonRequest);
+ Object[] args = getJSONRequestStringArray(servletRequest);
+ Object response = invokeService(args);
+ //String jsonResponse = getJSONResponse(servletRequest, response);
+ String jsonResponse = getJSONResponseAsString(servletRequest, response);
+ servletResponse.getOutputStream().println(jsonResponse);
+ }
+
+ /**
+ * Turn the request into JSON
+ */
+/* Not required now JSON conversion is delegated to databinding
+ protected String getJSONRequest(ServletRequest servletRequest) throws IOException, JsonParseException, JsonMappingException {
+
+ List<DataType> types = operation.getInputType().getLogical();
+ int typesIndex = 0;
+
+ String jsonRequest = "";
+ for (String name : getOrderedParameterNames(servletRequest)) {
+ if (!name.startsWith("_") && !"callback".equals(name)) {
+ if (jsonRequest.length() > 1) {
+ jsonRequest += ", ";
+ }
+
+ // automatically quote string parammeters so clients work in the usual javascript way
+ if (typesIndex < types.size() && String.class.equals(types.get(typesIndex).getGenericType())) {
+ String x = servletRequest.getParameter(name);
+ // TODO: do this more properly
+ if (!x.startsWith("\"")) {
+ jsonRequest += "\"" + x + "\"";
+ } else {
+ jsonRequest += x;
+ }
+ } else {
+ jsonRequest += servletRequest.getParameter(name);
+ }
+
+ }
+ }
+
+ return "[" + jsonRequest + "]";
+ }
+*/
+
+ /**
+ * Turn the request into a string array of JSON structures. The Databinding
+ * layer will then convert each of the individual parameters into the appropriate
+ * types for the implementation interface
+ *
+ */
+ protected Object[] getJSONRequestStringArray(ServletRequest servletRequest) throws IOException, JsonParseException, JsonMappingException {
+
+ List<DataType> types = operation.getInputType().getLogical();
+ int typesIndex = 0;
+
+ List<String> jsonRequestArray = new ArrayList<String>();
+
+ for (String name : getOrderedParameterNames(servletRequest)) {
+ String jsonRequest = "";
+ if (!name.startsWith("_") && !"callback".equals(name)) {
+
+ // automatically quote string parameters so clients work in the usual javascript way
+ if (typesIndex < types.size() && String.class.equals(types.get(typesIndex).getGenericType())) {
+ String x = servletRequest.getParameter(name);
+ // TODO: do this more properly
+ if (!x.startsWith("\"")) {
+ jsonRequest += "\"" + x + "\"";
+ } else {
+ jsonRequest += x;
+ }
+ } else {
+ jsonRequest += servletRequest.getParameter(name);
+ }
+ jsonRequestArray.add(jsonRequest);
+ }
+ }
+
+ return jsonRequestArray.toArray();
+ }
+
+ /**
+ * Get the request parameter names in the correct order.
+ * The request args need to be in the correct order to invoke the service so work out the
+ * order from the order in the query string. Eg, the url:
+ * http://localhost:8085/HelloWorldService/sayHello2?first=petra&last=arnold&callback=foo"
+ * should invoke:
+ * sayHello2("petra", "arnold")
+ * so the parameter names should be ordered: "first", "last"
+ */
+ protected SortedSet<String> getOrderedParameterNames(ServletRequest servletRequest) {
+ final String queryString = ((HttpServletRequest)servletRequest).getQueryString();
+
+ SortedSet<String> sortedNames = new TreeSet<String>(new Comparator<String>(){
+ public int compare(String o1, String o2) {
+ int i = queryString.indexOf(o1);
+ int j = queryString.indexOf(o2);
+ return i - j;
+ }});
+
+ Set<String> parameterNames = servletRequest.getParameterMap().keySet();
+ for (String name : parameterNames) {
+ sortedNames.add(name);
+ }
+
+ return sortedNames;
+ }
+
+ /**
+ * Turn the response object into JSON
+ */
+/* Not required now JSON conversion is delegated to databinding
+ protected String getJSONResponse(ServletRequest servletRequest, Object response) throws IOException, JsonParseException {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ mapper.writeValue(os , response);
+ String jsonResponse = os.toString();
+
+ String callback = servletRequest.getParameter("callback");
+ if (callback != null && callback.length() > 1) {
+ jsonResponse = callback + "(" + jsonResponse + ");";
+ }
+
+ return jsonResponse;
+ }
+*/
+
+ /**
+ * The databinding layer will have converterted the return type into a JSON string so simply
+ * add wrap it for return.
+ */
+ protected String getJSONResponseAsString(ServletRequest servletRequest, Object response) throws IOException, JsonParseException {
+ String jsonResponse = response.toString();
+
+ String callback = servletRequest.getParameter("callback");
+ if (callback != null && callback.length() > 1) {
+ jsonResponse = callback + "(" + jsonResponse + ");";
+ }
+
+ return jsonResponse;
+ }
+
+ /**
+ * Turn the request JSON into objects
+ */
+/* Not required now JSON conversion is delegated to databinding
+ protected Object[] jsonToObjects(String jsonRequest) throws IOException, JsonParseException, JsonMappingException {
+ Class<?> c = new Object[0].getClass();
+ Object[] args = (Object[])mapper.readValue(jsonRequest, c);
+ return args;
+ }
+*/
+
+
+ /**
+ * Send the request down the wire to invoke the service
+ */
+ protected Object invokeService(Object[] args) {
+ try {
+ return wire.invoke(operation, args);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..f5d9de2a77
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.jsonp.runtime.JSONPBindingProviderFactory;model=org.apache.tuscany.sca.binding.jsonp.JSONPBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/BeanA.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/BeanA.java
new file mode 100644
index 0000000000..c8fd365da5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/BeanA.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 helloworld;
+
+public class BeanA {
+
+ protected Boolean b;
+ protected String s;
+ protected int x;
+ protected Integer y;
+
+ public Boolean getB() {
+ return b;
+ }
+
+ public void setB(Boolean b) {
+ this.b = b;
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public Integer getY() {
+ return y;
+ }
+
+ public void setY(Integer y) {
+ this.y = y;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..66cf8f5b98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.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 helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorldService {
+
+ @Reference
+ public HelloWorldService ref;
+
+ public String sayHello(String name) {
+ return ref.sayHello(name);
+ }
+
+ public String sayHello2(String firstName, String lastName) {
+ return ref.sayHello2(firstName, lastName);
+ }
+
+ public BeanA sayHello3(BeanA bean) {
+ return ref.sayHello3(bean);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..94b7c64dba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.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 helloworld;
+
+
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ public String sayHello2(String firstName, String lastName) {
+ return "Hello " + firstName + " " + lastName;
+ }
+
+ public BeanA sayHello3(BeanA bean) {
+ bean.setS("XYZ");
+ return bean;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..a215ecf4be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.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 helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+
+ String sayHello(String name);
+
+ String sayHello2(String firstName, String lastName);
+
+ BeanA sayHello3(BeanA bean);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java
new file mode 100644
index 0000000000..6923243d1a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 test;
+
+import helloworld.BeanA;
+import helloworld.HelloWorldService;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.http.jetty.JettyServer;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class BindingTestCase {
+
+ private static Node node;
+
+ @Test
+ public void testService() throws MalformedURLException, IOException {
+ URL url = new URL("http://localhost:8085/HelloWorldComponent/HelloWorldService/sayHello?name=petra&callback=foo");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ String response = br.readLine();
+ Assert.assertEquals("foo(\"Hello petra\");", response);
+
+ }
+
+ @Test
+ public void testTwoArgs() throws MalformedURLException, IOException {
+ URL url = new URL("http://localhost:8085/HelloWorldComponent/HelloWorldService/sayHello2?first=petra&last=arnold&callback=foo");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ String response = br.readLine();
+ Assert.assertEquals("foo(\"Hello petra arnold\");", response);
+
+ }
+
+ @Test
+ public void testReference() throws MalformedURLException, IOException {
+
+ HelloWorldService client = node.getService(HelloWorldService.class, "HelloWorldClient");
+
+ Assert.assertEquals("Hello beate", client.sayHello("beate"));
+ Assert.assertEquals("Hello beate arnold", client.sayHello2("beate", "arnold"));
+ }
+
+ @Test
+ //@Ignore("TUSCANY-3635")
+ public void testComplexParams() throws MalformedURLException, IOException {
+
+ HelloWorldService client = node.getService(HelloWorldService.class, "HelloWorldClient");
+
+ BeanA bean = new BeanA();
+ bean.setB(true);
+ bean.setS("Fred");
+ bean.setX(2);
+ bean.setX(5);
+
+ Assert.assertEquals("XYZ", client.sayHello3(bean).getS());
+ }
+
+ /*
+ * Uncomment to keep the server running so you can ping it manually from a browser
+ * try:
+ * http://localhost:8085/HelloWorldComponent/HelloWorldService/sayHello3?bean={%22b%22:%22true%22,%22s%22:%22a%20string%22,%22x%22:%2227%22,%22y%22:%2213%22}&callback=submitSucess
+ */
+ @Test
+ @Ignore
+ public void waitForInput(){
+ System.out.println("Press a key");
+ try {
+ System.in.read();
+ } catch (Exception ex){
+ // do nothing
+ }
+ }
+
+ @BeforeClass
+ public static void init() throws Exception {
+ JettyServer.portDefault = 8085;
+ node = NodeFactory.newInstance().createNode("helloworld.composite").start();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite
new file mode 100644
index 0000000000..065e888bb7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://itest"
+ name="HelloWorldComposite">
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <tuscany:binding.jsonp />
+ </service>
+ </component>
+
+ <component name="HelloWorldClient">
+ <implementation.java class="helloworld.HelloWorldClient"/>
+ <reference name="ref" >
+ <tuscany:binding.jsonp uri="http://localhost:8085/HelloWorldComponent/HelloWorldService"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/resources/jquery.html b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/resources/jquery.html
new file mode 100644
index 0000000000..a61cee3155
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp-runtime/src/test/resources/jquery.html
@@ -0,0 +1,51 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <title>Tuscany JQuery Client HelloWorld Sample</TITLE>
+
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
+ <script language="JavaScript">
+
+ function getGreeting() {
+ var name = document.getElementById("name").value;
+ $.getJSON('http://localhost:8081/HelloWorldService/sayHello?name=' + name + '&callback=?', handleResponse);
+ }
+ function handleResponse(data) {
+ document.getElementById('greeting').innerHTML=data;
+ }
+
+ </script>
+
+ </head>
+
+ <body>
+ <h2>Tuscany JSONP HelloWorld Sample</h2>
+
+ This example uses the JQuery getJSON to make JSONP requests to the SCA service 'HelloWorldService'
+
+ <p>Enter Name: &nbsp;&nbsp;&nbsp;
+ <input type="text" id="name" size="30"/>
+ <input type="button" value="Submit" onclick="getGreeting()" />
+
+ </p><div id='greeting'></div>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/LICENSE b/sandbox/sebastien/java/embed/modules/binding-jsonp/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/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/sebastien/java/embed/modules/binding-jsonp/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-jsonp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..019cfda386
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.jsonp;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,javax.xml.namespace"
+Private-Package: org.apache.tuscany.sca.binding.jsonp.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JSONP Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JSONP Binding Model
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.jsonp;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.jsonp
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/NOTICE b/sandbox/sebastien/java/embed/modules/binding-jsonp/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/pom.xml b/sandbox/sebastien/java/embed/modules/binding-jsonp/pom.xml
new file mode 100644
index 0000000000..89c83bad67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/pom.xml
@@ -0,0 +1,41 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-jsonp</artifactId>
+ <name>Apache Tuscany SCA JSONP Binding Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java
new file mode 100644
index 0000000000..8872d78fa6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.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.sca.binding.jsonp;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * JSONP Binding model
+ */
+public interface JSONPBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.jsonp");
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java
new file mode 100644
index 0000000000..2e8bebef0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.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.sca.binding.jsonp;
+
+/**
+ * Factory to create JSONPBinding instances
+ */
+public interface JSONPBindingFactory {
+
+ /**
+ * Create JSONPBinding model
+ */
+ JSONPBinding createJSONPBinding();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java
new file mode 100644
index 0000000000..be74a28e39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jsonp.impl;
+
+import org.apache.tuscany.sca.binding.jsonp.JSONPBinding;
+import org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory;
+
+/**
+ * Factory implementation to create JSONP Models
+ */
+public class JSONPBindingFactoryImpl implements JSONPBindingFactory {
+
+ public JSONPBinding createJSONPBinding() {
+ return new JSONPBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java
new file mode 100644
index 0000000000..4d0f03fe4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.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.binding.jsonp.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.jsonp.JSONPBinding;
+
+/**
+ * Represents a binding to an RMI service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONPBindingImpl implements JSONPBinding {
+
+ private String name;
+ private String uri;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean arg0) {
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory
new file mode 100644
index 0000000000..e1e8c6d3a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.jsonp.impl.JSONPBindingFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..f962b70f04
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.jsonp,model=org.apache.tuscany.sca.binding.jsonp.JSONPBinding,factory=org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..f6c99dfaba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+binding-jsonp.xsd
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd
new file mode 100644
index 0000000000..e533ecd168
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd
@@ -0,0 +1,41 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912" />
+
+ <element name="binding.jsonp" type="t:JSONPBinding" substitutionGroup="sca:binding"/>
+
+ <complexType name="JSONPBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <!-- sequence>
+ <any namespace="##targetNamespace" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence -->
+ <!-- anyAttribute namespace="##other" processContents="lax"/-->
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/LICENSE b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/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/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a8d4ba39b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.jsonrpc.js.dojo;uses:="
+ org.apache.tuscany.sca.binding.jsonrpc,org.apache.tuscany.sca.assembl
+ y,org.apache.tuscany.sca.web.javascript,javax.xml.namespace";version=
+ "2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JSON-RPC Binding JavaScript using Dojo
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JSON-RPC Binding JavaScript usi
+ ng Dojo
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.jsonrpc;version="2.0.0",
+ org.apache.tuscany.sca.binding.jsonrpc.js.dojo;version="2.0.0",
+ org.apache.tuscany.sca.web.javascript;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.jsonrpc-js.dojo
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/NOTICE b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/pom.xml b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/pom.xml
new file mode 100644
index 0000000000..01a55bc902
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/pom.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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-jsonrpc-js-dojo</artifactId>
+ <name>Apache Tuscany SCA JSON-RPC Binding JavaScript using Dojo</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-web-javascript</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/js/dojo/JSONRPCBindingJavascriptProxyFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/js/dojo/JSONRPCBindingJavascriptProxyFactoryImpl.java
new file mode 100644
index 0000000000..0388c8bd77
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/js/dojo/JSONRPCBindingJavascriptProxyFactoryImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jsonrpc.js.dojo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory;
+
+public class JSONRPCBindingJavascriptProxyFactoryImpl implements JavascriptProxyFactory {
+ private static final QName NAME = new QName("http://tuscany.apache.org/xmlns/sca/1.1", "binding.jsonrpc");
+
+ public Class<?> getModelType() {
+ return JSONRPCBinding.class;
+ }
+
+ public QName getQName() {
+ return NAME;
+ }
+
+ public String getJavascriptProxyFile() {
+ return null;
+ }
+
+ public InputStream getJavascriptProxyFileAsStream() throws IOException {
+ return null;
+ }
+
+ public String createJavascriptHeader(ComponentReference componentReference) throws IOException {
+ return "dojo.require('dojo.rpc.JsonService');";
+ }
+
+ public String createJavascriptReference(ComponentReference componentReference) throws IOException {
+ EndpointReference epr = componentReference.getEndpointReferences().get(0);
+ Endpoint targetEndpoint = epr.getTargetEndpoint();
+ if (targetEndpoint.isUnresolved()) {
+ //force resolution and targetEndpoint binding calculations
+ //by calling the getInvocationChain
+ ((RuntimeEndpointReference) epr).getInvocationChains();
+ targetEndpoint = epr.getTargetEndpoint();
+ }
+
+ Binding binding = targetEndpoint.getBinding();
+
+ URI targetURI = URI.create(binding.getURI());
+ String targetPath = targetURI.getPath();
+
+ return "dojo.rpc.JsonService(\"" + targetPath + "?smd\")";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory
new file mode 100644
index 0000000000..88f2fa0dbe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-js-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory
@@ -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 Javascript Proxy Factory
+org.apache.tuscany.sca.binding.jsonrpc.js.dojo.JSONRPCBindingJavascriptProxyFactoryImpl;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.jsonrpc,model=org.apache.tuscany.sca.binding.atom.JSONRPCBinding \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/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/sebastien/java/embed/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..7c7b8e14a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,43 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JSON-RPC Binding Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JSON-RPC Binding Runtime
+Import-Package: javax.security.auth.login,
+ javax.servlet,
+ javax.servlet.http,
+ org.apache.http,
+ org.apache.http.client,
+ org.apache.http.client.methods,
+ org.apache.http.conn,
+ org.apache.http.conn.scheme,
+ org.apache.http.entity,
+ org.apache.http.impl.client,
+ org.apache.http.impl.conn.tsccm,
+ org.apache.http.params,
+ org.apache.http.protocol,
+ org.apache.http.util,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.jsonrpc;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.databinding.json;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.jabsorb,
+ org.jabsorb.client,
+ org.json,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.jsonrpc.runtime
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/NOTICE
new file mode 100644
index 0000000000..28064e5de1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/NOTICE
@@ -0,0 +1,11 @@
+${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 includes/uses JSON-RPC JavaScript client (jsonrpc.js)
+ Copyright (c) 2003-2004 Jan-Klaas Kollhof
+ Copyright (c) 2005 Michael Clark, Metaparadigm Pte Ltd
+
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/pom.xml
new file mode 100644
index 0000000000..2c7829dda8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/pom.xml
@@ -0,0 +1,154 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <name>Apache Tuscany SCA JSON-RPC Binding Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jabsorb</groupId>
+ <artifactId>jabsorb</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+
+ <!-- Explicitly add slf4j so that jabsorb uses the latest versions -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.5.11</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>httpunit</groupId>
+ <artifactId>httpunit</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java
new file mode 100644
index 0000000000..ecca09dc92
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jsonrpc.provider;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.util.EntityUtils;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+/**
+ * Invoker for the JSONRPC Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBindingInvoker implements Invoker {
+ private EndpointReference endpointReference;
+ private Operation operation;
+ private String uri;
+
+ private HttpClient httpClient;
+
+ public JSONRPCBindingInvoker(EndpointReference endpointReference, Operation operation, HttpClient httpClient) {
+ this.endpointReference = endpointReference;
+ this.operation = operation;
+ this.uri = ((JSONRPCBinding) endpointReference.getBinding()).getURI();
+
+ this.httpClient = httpClient;
+ }
+
+ public Message invoke(Message msg) {
+ HttpPost post = null;
+ HttpResponse response = null;
+ try {
+ String requestId = "1";
+ post = new HttpPost(uri);
+
+ final String db = msg.getOperation().getWrapper().getDataBinding();
+ String req;
+ if (!db.equals(JSONDataBinding.NAME)) {
+
+
+ JSONObject jsonRequest = null;;
+ Object[] args = null;
+ try {
+ // Extract the method
+ jsonRequest = new JSONObject();
+ jsonRequest.putOpt("method", "Service" + "." + msg.getOperation().getName());
+
+ // Extract the arguments
+ args = msg.getBody();
+ JSONArray array = new JSONArray();
+ for (int i = 0; i < args.length; i++) {
+ array.put(args[i]);
+ }
+ jsonRequest.putOpt("params", array);
+ jsonRequest.put("id", requestId);
+
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to parse JSON parameter", e);
+ }
+ req = jsonRequest.toString();
+ } else {
+ req = (String)((Object[])msg.getBody())[0];
+ }
+ StringEntity entity = new StringEntity(req, "UTF-8");
+ post.setEntity(entity);
+
+ response = httpClient.execute(post);
+
+ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+ //success
+ try {
+ String entityResponse = EntityUtils.toString(response.getEntity());
+ if (!db.equals(JSONDataBinding.NAME)) {
+ JSONObject jsonResponse = new JSONObject(entityResponse);
+
+ //check requestId
+ if (! jsonResponse.getString("id").equalsIgnoreCase(requestId)) {
+ throw new RuntimeException("Invalid response id:" + requestId );
+ }
+
+ msg.setBody(jsonResponse.get("result"));
+ } else {
+ msg.setBody(entityResponse);
+ }
+
+ } catch (Exception e) {
+ //FIXME Exceptions are not handled correctly here
+ // They should be reported to the client JavaScript as proper
+ // JavaScript exceptions.
+ throw new RuntimeException("Unable to parse response", e);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ msg.setFaultBody(e);
+ }
+
+ return msg;
+ }
+
+ private static JSONObject getJSONRequest(Message msg) {
+
+ JSONObject jsonRequest = null;;
+ Object[] args = null;
+ Object id = null;
+ try {
+ // Extract the method
+ jsonRequest = new JSONObject();
+ jsonRequest.putOpt("method", "Service" + "." + msg.getOperation().getName());
+
+ // Extract the arguments
+ args = msg.getBody();
+ JSONArray array = new JSONArray();
+ for (int i = 0; i < args.length; i++) {
+ array.put(args[i]);
+ }
+ jsonRequest.putOpt("params", array);
+ id = jsonRequest.put("id", "1");
+
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to parse JSON parameter", e);
+ }
+
+ return jsonRequest;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java
new file mode 100644
index 0000000000..c9b9328b61
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.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.sca.binding.jsonrpc.provider;
+
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * JSON-RPC Provider Factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBindingProviderFactory implements BindingProviderFactory<JSONRPCBinding> {
+
+ private MessageFactory messageFactory;
+ private ServletHost servletHost;
+
+ public JSONRPCBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ messageFactory = modelFactories.getFactory(MessageFactory.class);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+
+ return new JSONRPCReferenceBindingProvider(endpointReference);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new JSONRPCServiceBindingProvider(endpoint, messageFactory, servletHost);
+ }
+
+ public Class<JSONRPCBinding> getModelType() {
+ return JSONRPCBinding.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java
new file mode 100644
index 0000000000..2b0859c416
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.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.binding.jsonrpc.provider;
+
+import java.lang.reflect.Method;
+
+import org.apache.http.client.HttpClient;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.jabsorb.client.Client;
+import org.jabsorb.client.Session;
+import org.jabsorb.client.TransportRegistry;
+
+/**
+ * Invoker for the JSONRPC Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCClientInvoker implements Invoker {
+ private EndpointReference endpointReference;
+ private Operation operation;
+ private Method method;
+ private String uri;
+
+ public JSONRPCClientInvoker(EndpointReference endpointReference, Operation operation, HttpClient httpClient) {
+ this.endpointReference = endpointReference;
+ this.operation = operation;
+ this.method = ((JavaOperation)operation).getJavaMethod();
+ this.uri = ((JSONRPCBinding)endpointReference.getBinding()).getURI();
+ }
+
+ public Message invoke(Message msg) {
+ Session session = TransportRegistry.i().createSession(uri);
+ Client client = new Client(session);
+ Object proxy = client.openProxy("", method.getDeclaringClass());
+
+ try {
+ Object result = client.invoke(proxy, method, (Object[])msg.getBody());
+ msg.setBody(result);
+ } catch (Exception e) {
+ msg.setFaultBody(e);
+ } finally {
+ client.closeProxy(proxy);
+ session.close();
+ }
+ return msg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java
new file mode 100644
index 0000000000..3cdcb32830
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.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.sca.binding.jsonrpc.provider;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * JSONRPC Binding helper class to handle setting the proper
+ * data binding in the interface contract for JSONRPC
+ * services and references
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCDatabindingHelper {
+
+ @SuppressWarnings("unchecked")
+ static void setDataBinding(Interface interfaze) {
+ List<Operation> operations = interfaze.getOperations();
+ for (Operation operation : operations) {
+ operation.setDataBinding(JSONDataBinding.NAME);
+ DataType<List<DataType>> inputType = operation.getInputType();
+ if (inputType != null) {
+ List<DataType> logical = inputType.getLogical();
+ for (DataType inArg : logical) {
+ if (!SimpleJavaDataBinding.NAME.equals(inArg.getDataBinding())) {
+ inArg.setDataBinding(JSONDataBinding.NAME);
+ }
+ }
+ }
+ DataType outputType = operation.getOutputType();
+ if (outputType != null) {
+ if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding())) {
+ outputType.setDataBinding(JSONDataBinding.NAME);
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java
new file mode 100644
index 0000000000..d1e35730b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jsonrpc.provider;
+
+import org.apache.http.HttpHost;
+import org.apache.http.client.HttpClient;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.HTTP;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of the JSONRPC Binding Provider for References
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private EndpointReference endpointReference;
+ private RuntimeComponentReference reference;
+ private InterfaceContract referenceContract;
+
+ private HttpClient httpClient;
+
+ public JSONRPCReferenceBindingProvider(EndpointReference endpointReference) {
+
+ this.endpointReference = endpointReference;
+ this.reference = (RuntimeComponentReference) endpointReference.getReference();
+
+ //clone the service contract to avoid databinding issues
+ /*
+ try {
+ this.referenceContract = (InterfaceContract)reference.getInterfaceContract().clone();
+ } catch(CloneNotSupportedException e) {
+ this.referenceContract = reference.getInterfaceContract();
+ }
+
+ JSONRPCDatabindingHelper.setDataBinding(referenceContract.getInterface());
+ */
+
+ // Create an HTTP client
+ HttpParams defaultParameters = new BasicHttpParams();
+ //defaultParameters.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 10);
+ HttpProtocolParams.setContentCharset(defaultParameters, HTTP.UTF_8);
+ HttpConnectionParams.setConnectionTimeout(defaultParameters, 60000);
+ HttpConnectionParams.setSoTimeout(defaultParameters, 60000);
+
+ SchemeRegistry supportedSchemes = new SchemeRegistry();
+ supportedSchemes.register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, PlainSocketFactory.getSocketFactory(), 80));
+
+ ClientConnectionManager connectionManager = new ThreadSafeClientConnManager(defaultParameters, supportedSchemes);
+
+ httpClient = new DefaultHttpClient(connectionManager, defaultParameters);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ //return referenceContract;
+ return reference.getInterfaceContract();
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ final Interface intf = reference.getInterfaceContract().getInterface();
+ if (intf.isDynamic())
+ return new JSONRPCBindingInvoker(endpointReference, operation, httpClient);
+ return new JSONRPCClientInvoker(endpointReference, operation, httpClient);
+ }
+
+ public void start() {
+
+ }
+
+ public void stop() {
+
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java
new file mode 100644
index 0000000000..10e9368936
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.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.sca.binding.jsonrpc.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+
+/**
+ * Implementation of the JSONRPC Binding Provider for Services
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCServiceBindingProvider implements ServiceBindingProvider {
+ private MessageFactory messageFactory;
+
+ private RuntimeEndpoint endpoint;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private InterfaceContract serviceContract;
+ private JSONRPCBinding binding;
+ private ServletHost servletHost;
+ private List<String> servletMappings = new ArrayList<String>();
+
+ public JSONRPCServiceBindingProvider(RuntimeEndpoint endpoint,
+ MessageFactory messageFactory,
+ ServletHost servletHost) {
+ this.endpoint = endpoint;
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (JSONRPCBinding) endpoint.getBinding();
+ this.messageFactory = messageFactory;
+ this.servletHost = servletHost;
+
+ //clone the service contract to avoid databinding issues
+ try {
+ this.serviceContract = (InterfaceContract)service.getInterfaceContract().clone();
+ } catch(CloneNotSupportedException e) {
+ this.serviceContract = service.getInterfaceContract();
+ }
+
+ JSONRPCDatabindingHelper.setDataBinding(serviceContract.getInterface());
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return serviceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ // Set default databinding to json
+ // serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME);
+
+ // Determine the service business interface
+ Class<?> serviceInterface = getTargetJavaClass(serviceContract.getInterface());
+
+ // Create a Java proxy to the target service
+ Object proxy = component.getComponentContext().getServiceReference(serviceInterface, endpoint).getService();
+
+ // Create and register a Servlet for this service
+ JSONRPCServiceServlet serviceServlet =
+ new JSONRPCServiceServlet(messageFactory, endpoint, serviceInterface, proxy);
+ String mapping = binding.getURI();
+ if (!mapping.endsWith("/")) {
+ mapping += "/";
+ }
+ if (!mapping.endsWith("*")) {
+ mapping += "*";
+ }
+
+ servletHost.addServletMapping(mapping, serviceServlet);
+ servletMappings.add(mapping);
+ servletHost.addServletMapping(binding.getURI(), serviceServlet);
+ servletMappings.add(binding.getURI());
+ }
+
+ public void stop() {
+
+ // Remove the Servlet mappings we've added
+ for (String mapping: servletMappings) {
+ servletHost.removeServletMapping(mapping);
+ }
+
+ }
+
+ private Class<?> getTargetJavaClass(Interface targetInterface) {
+ // TODO: right now assume that the target is always a Java
+ // Implementation. Need to figure out how to generate Java
+ // Interface in cases where the target is not a Java Implementation
+ return ((JavaInterface)targetInterface).getJavaClass();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
new file mode 100644
index 0000000000..c24d90e2d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
@@ -0,0 +1,394 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jsonrpc.provider;
+
+import java.io.BufferedReader;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.net.URLDecoder;
+import java.security.MessageDigest;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.jabsorb.JSONRPCBridge;
+import org.jabsorb.JSONRPCResult;
+import org.jabsorb.JSONRPCServlet;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Servlet that handles JSON-RPC requests invoking SCA services.
+ *
+ * There is an instance of this Servlet for each <binding.jsonrpc>
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCServiceServlet extends JSONRPCServlet {
+ private static final long serialVersionUID = 1L;
+
+ transient MessageFactory messageFactory;
+
+ transient Binding binding;
+ transient String serviceName;
+ transient Object serviceInstance;
+ transient RuntimeEndpoint endpoint;
+ transient Class<?> serviceInterface;
+
+ public JSONRPCServiceServlet(MessageFactory messageFactory,
+ RuntimeEndpoint endpoint,
+ Class<?> serviceInterface,
+ Object serviceInstance) {
+ this.endpoint = endpoint;
+ this.messageFactory = messageFactory;
+ this.binding = endpoint.getBinding();
+ this.serviceName = binding.getName();
+ this.serviceInterface = serviceInterface;
+ this.serviceInstance = serviceInstance;
+ }
+
+ /**
+ * Override to do nothing as the JSONRPCServlet is setup by the
+ * service method in this class.
+ */
+ @Override
+ public void init(ServletConfig config) {
+ }
+
+ @Override
+ public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ if ("smd".equals(request.getQueryString())) {
+ handleSMDRequest(request, response);
+ } else {
+ try {
+ handleServiceRequest(request, response);
+
+ } catch(RuntimeException re) {
+ if (re.getCause() instanceof javax.security.auth.login.LoginException) {
+ response.setHeader("WWW-Authenticate", "BASIC realm=\"" + "ldap-realm" + "\"");
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+ } else {
+ re.printStackTrace();
+ }
+ } finally {
+ HttpSession session = request.getSession(false);
+ if (session != null) {
+ session.removeAttribute("JSONRPCBridge");
+ }
+ }
+ }
+ }
+
+ private void handleServiceRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ // Decode using the charset in the request if it exists otherwise
+ // use UTF-8 as this is what all browser implementations use.
+ // The JSON-RPC-Java JavaScript client is ASCII clean so it
+ // although here we can correctly handle data from other clients
+ // that do not escape non ASCII data
+ String charset = request.getCharacterEncoding();
+ if (charset == null) {
+ charset = "UTF-8";
+ }
+
+ CharArrayWriter data = new CharArrayWriter();
+ if (request.getMethod().equals("GET")) {
+ // if using GET Support (see http://groups.google.com/group/json-rpc/web/json-rpc-over-http)
+
+ //parse the GET QueryString
+ try {
+ String params = new String(Base64.decodeBase64(URLDecoder.decode(request.getParameter("params"),charset).getBytes()));
+ StringBuffer sb = new StringBuffer();
+ sb.append("{");
+ sb.append("\"method\": \"" + request.getParameter("method") + "\",");
+ sb.append("\"params\": " + params + ",");
+ sb.append("\"id\":" + request.getParameter("id"));
+ sb.append("}");
+
+ data.write(sb.toString().toCharArray(), 0, sb.length());
+ } catch (Exception e) {
+ //FIXME Exceptions are not handled correctly here
+ // They should be reported to the client JavaScript as proper
+ // JavaScript exceptions.
+ throw new RuntimeException("Unable to parse request", e);
+ }
+
+ } else {
+ // default POST style
+ BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), charset));
+
+ // Read the request into charArray
+ char[] buf = new char[4096];
+ int ret;
+ while ((ret = in.read(buf, 0, 4096)) != -1) {
+ data.write(buf, 0, ret);
+ }
+ }
+
+ JSONObject jsonReq = null;
+ String method = null;
+ //parse the JSON payload
+ try {
+ jsonReq = new JSONObject(data.toString());
+ method = jsonReq.getString("method");
+ } catch (Exception e) {
+ //FIXME Exceptions are not handled correctly here
+ // They should be reported to the client JavaScript as proper
+ // JavaScript exceptions.
+ throw new RuntimeException("Unable to parse request", e);
+ }
+
+ // check if it's a system request
+ // or a method invocation
+ byte[] bout;
+ try {
+ if (method.startsWith("system.")) {
+ bout = handleJSONRPCSystemInvocation(request, response, data.toString());
+ } else {
+ bout = handleJSONRPCMethodInvocation(request, response, jsonReq);
+ }
+ } catch (JSONException e) {
+ throw new RuntimeException(e);
+ }
+
+ // Send response to client
+ // Encode using UTF-8, although We are actually ASCII clean as
+ // all unicode data is JSON escaped using backslash u. This is
+ // less data efficient for foreign character sets but it is
+ // needed to support naughty browsers such as Konqueror and Safari
+ // which do not honour the charset set in the response
+ response.setContentType("text/plain;charset=utf-8");
+
+ //set Cache-Control to no-cache to avoid intermediary
+ //proxy/reverse-proxy caches and always hit the server
+ //that would identify if the value was current or not
+ response.setHeader("Cache-Control", "no-cache");
+ response.setHeader("Expires", new Date(0).toGMTString());
+
+ //handle etag if using GET
+ if( request.getMethod().equals("GET")) {
+ String eTag = calculateETag(bout);
+
+ // Test request for predicates.
+ String predicate = request.getHeader( "If-Match" );
+ if (( predicate != null ) && ( !predicate.equals(eTag) )) {
+ // No match, should short circuit
+ response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
+ return;
+ }
+ predicate = request.getHeader( "If-None-Match" );
+ if (( predicate != null ) && ( predicate.equals(eTag) )) {
+ // Match, should short circuit
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+
+ response.addHeader("ETag", eTag);
+ }
+
+ OutputStream out = response.getOutputStream();
+ out.write(bout);
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * handles requests for the SMD descriptor for a service
+ */
+ protected void handleSMDRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, UnsupportedEncodingException {
+ String serviceUrl = request.getRequestURL().toString();
+ String smd = JavaToSmd.interfaceToSmd(serviceInterface, serviceUrl);
+
+ response.setContentType("text/plain;charset=utf-8");
+ OutputStream out = response.getOutputStream();
+ byte[] bout = smd.getBytes("UTF-8");
+ out.write(bout);
+ out.flush();
+ out.close();
+ }
+
+ protected byte[] handleJSONRPCSystemInvocation(HttpServletRequest request, HttpServletResponse response, String requestData) throws IOException,
+ UnsupportedEncodingException, JSONException {
+ /*
+ * Create a new bridge for every request to avoid all the problems with
+ * JSON-RPC-Java storing the bridge in the session
+ */
+ HttpSession session = request.getSession();
+
+ JSONRPCBridge jsonrpcBridge = new JSONRPCBridge();
+ jsonrpcBridge.registerObject("Service", serviceInstance, serviceInterface);
+ session.setAttribute("JSONRPCBridge", jsonrpcBridge);
+
+ org.json.JSONObject jsonReq = null;
+ JSONRPCResult jsonResp = null;
+ jsonReq = new org.json.JSONObject(requestData);
+
+ String method = jsonReq.getString("method");
+ if ((method != null) && (method.indexOf('.') < 0)) {
+ jsonReq.putOpt("method", "Service" + "." + method);
+ }
+
+ // invoke the request
+ jsonResp = jsonrpcBridge.call(new Object[] {request}, jsonReq);
+
+ return jsonResp.toString().getBytes("UTF-8");
+ }
+
+ protected byte[] handleJSONRPCMethodInvocation(HttpServletRequest request, HttpServletResponse response, JSONObject jsonReq) throws IOException,
+ UnsupportedEncodingException {
+
+ String method = null;
+ Object[] args = null;
+ Object id = null;
+ try {
+ // Extract the method
+ method = jsonReq.getString("method");
+ if ((method != null) && (method.indexOf('.') < 0)) {
+ jsonReq.putOpt("method", "Service" + "." + method);
+ }
+
+ // Extract the arguments
+ JSONArray array = jsonReq.getJSONArray("params");
+ args = new Object[array.length()];
+ for (int i = 0; i < args.length; i++) {
+ args[i] = array.get(i);
+ }
+ id = jsonReq.get("id");
+
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to find json method name", e);
+ }
+
+ // invoke the request
+ Operation jsonOperation = findOperation(method);
+ Object result = null;
+
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setOperation(jsonOperation);
+
+ requestMessage.getHeaders().put("RequestMessage", request);
+
+ if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME))
+ requestMessage.setBody(new Object[]{jsonReq.toString()});
+ else
+ requestMessage.setBody(args);
+
+ //result = wire.invoke(jsonOperation, args);
+ Message responseMessage = null;
+ try {
+ responseMessage = endpoint.getInvocationChain(jsonOperation).getHeadInvoker().invoke(requestMessage);
+ } catch (RuntimeException re) {
+ if (re.getCause() instanceof javax.security.auth.login.LoginException) {
+ throw re;
+ } else {
+ //some other exception
+ JSONRPCResult errorResult = new JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, re);
+ return errorResult.toString().getBytes("UTF-8");
+ }
+ }
+
+ if (!responseMessage.isFault()) {
+ //successful execution of the invocation
+ if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME)) {
+ result = responseMessage.getBody();
+ return result.toString().getBytes("UTF-8");
+ } else {
+ try {
+ result = responseMessage.getBody();
+ JSONObject jsonResponse = new JSONObject();
+ jsonResponse.put("result", result);
+ jsonResponse.putOpt("id", id);
+ //get response to send to client
+ return jsonResponse.toString().getBytes("UTF-8");
+ } catch (Exception e) {
+ throw new ServiceRuntimeException("Unable to create JSON response", e);
+ }
+ }
+ } else {
+ //exception thrown while executing the invocation
+ Throwable exception = (Throwable)responseMessage.getBody();
+ JSONRPCResult errorResult = new JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, exception );
+ return errorResult.toString().getBytes("UTF-8");
+ }
+
+ }
+
+ /**
+ * Find the operation from the component service contract
+ * @param componentService
+ * @param method
+ * @return
+ */
+ private Operation findOperation(String method) {
+ if (method.contains(".")) {
+ method = method.substring(method.lastIndexOf(".") + 1);
+ }
+
+ List<Operation> operations = endpoint.getComponentServiceInterfaceContract().getInterface().getOperations();
+ //endpoint.getComponentTypeServiceInterfaceContract().getInterface().getOperations();
+ //componentService.getBindingProvider(binding).getBindingInterfaceContract().getInterface().getOperations();
+
+
+ Operation result = null;
+ for (Operation o : operations) {
+ if (o.isDynamic())
+ return o;
+ if (o.getName().equalsIgnoreCase(method)) {
+ result = o;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ private String calculateETag(byte[] content) {
+ String eTag = "invalid";
+ try {
+ MessageDigest messageDigest = MessageDigest.getInstance("MD5");
+ byte[] digest = messageDigest.digest(content);
+ BigInteger number = new BigInteger(1, digest);
+ StringBuffer sb = new StringBuffer('0');
+ sb.append(number.toString(16));
+ eTag = sb.toString();
+ } catch(Exception e) {
+ //ignore, we will return random etag
+ eTag = Integer.toString((new java.util.Random()).nextInt(Integer.MAX_VALUE));
+ }
+ return eTag;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JavaToSmd.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JavaToSmd.java
new file mode 100644
index 0000000000..64339fda7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JavaToSmd.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 org.apache.tuscany.sca.binding.jsonrpc.provider;
+
+import java.lang.reflect.Method;
+
+/**
+ * Utility class to create a Simple Method Description (SMD) descriptor
+ * from a Java class. See http://dojo.jot.com/SMD.
+ *
+ * TODO: Change to work from the Tuscany Interface instead of a Java class
+ *
+ * @version $Rev$ $Date$
+ */
+class JavaToSmd {
+
+ static String interfaceToSmd(Class<?> klazz, String serviceUrl) {
+ String name = klazz.getSimpleName();
+ Method[] methods = klazz.getMethods();
+
+ StringBuffer smdSb = new StringBuffer();
+ smdSb.append("{\"SMDVersion\":\".1\",\"objectName\":\"" + name + "\",\"serviceType\":\"JSON-RPC\",\"serviceURL\":\""+ serviceUrl + "\",\"methods\":[");
+ for (int i = 0; i < methods.length; i++) {
+ if (i != 0) smdSb.append(",");
+ Class<?>[] params = methods[i].getParameterTypes();
+ smdSb.append("{\"name\":\""+methods[i].getName() + "\",\"parameters\":[");
+ for (int j = 0; j < params.length; j++) {
+ if (j != 0) smdSb.append(",");
+ // right now Dojo doesn't look at the type value, so we'll default it to STRING
+ // also, since we can't introspect the method parameter names we'll just create an incrementing parameter name
+ smdSb.append("{\"name\":\"param" + j + "\",\"type\":\"STRING\"}");
+ }
+ smdSb.append("]}");
+ }
+ smdSb.append("]}");
+
+ return smdSb.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..ceb74cffce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCBindingProviderFactory;model=org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/resources/org/apache/tuscany/sca/binding/jsonrpc/provider/jsonrpc.js b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/resources/org/apache/tuscany/sca/binding/jsonrpc/provider/jsonrpc.js
new file mode 100644
index 0000000000..d837bab91c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/main/resources/org/apache/tuscany/sca/binding/jsonrpc/provider/jsonrpc.js
@@ -0,0 +1,493 @@
+/*
+ * JSON-RPC JavaScript client
+ *
+ * $Id: jsonrpc.js,v 1.36.2.3 2006/03/08 15:09:37 mclark Exp $
+ *
+ * Copyright (c) 2003-2004 Jan-Klaas Kollhof
+ * Copyright (c) 2005 Michael Clark, Metaparadigm Pte Ltd
+ *
+ * This code is based on Jan-Klaas' JavaScript o lait library (jsolait).
+ *
+ * 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.
+ *
+ */
+
+/*
+ * Modifications for Apache Tuscany:
+ * - JSONRpcClient_createMethod changed so callback is last arg
+ */
+
+/* escape a character */
+
+escapeJSONChar =
+function escapeJSONChar(c)
+{
+ if(c == "\"" || c == "\\") return "\\" + c;
+ else if (c == "\b") return "\\b";
+ else if (c == "\f") return "\\f";
+ else if (c == "\n") return "\\n";
+ else if (c == "\r") return "\\r";
+ else if (c == "\t") return "\\t";
+ var hex = c.charCodeAt(0).toString(16);
+ if(hex.length == 1) return "\\u000" + hex;
+ else if(hex.length == 2) return "\\u00" + hex;
+ else if(hex.length == 3) return "\\u0" + hex;
+ else return "\\u" + hex;
+};
+
+
+/* encode a string into JSON format */
+
+escapeJSONString =
+function escapeJSONString(s)
+{
+ /* The following should suffice but Safari's regex is b0rken
+ (doesn't support callback substitutions)
+ return "\"" + s.replace(/([^\u0020-\u007f]|[\\\"])/g,
+ escapeJSONChar) + "\"";
+ */
+
+ /* Rather inefficient way to do it */
+ var parts = s.split("");
+ for(var i=0; i < parts.length; i++) {
+ var c =parts[i];
+ if(c == '"' ||
+ c == '\\' ||
+ c.charCodeAt(0) < 32 ||
+ c.charCodeAt(0) >= 128)
+ parts[i] = escapeJSONChar(parts[i]);
+ }
+ return "\"" + parts.join("") + "\"";
+};
+
+
+/* Marshall objects to JSON format */
+
+toJSON = function toJSON(o)
+{
+ if(o == null) {
+ return "null";
+ } else if(o.constructor == String) {
+ return escapeJSONString(o);
+ } else if(o.constructor == Number) {
+ return o.toString();
+ } else if(o.constructor == Boolean) {
+ return o.toString();
+ } else if(o.constructor == Date) {
+ return '{javaClass: "java.util.Date", time: ' + o.valueOf() +'}';
+ } else if(o.constructor == Array) {
+ var v = [];
+ for(var i = 0; i < o.length; i++) v.push(toJSON(o[i]));
+ return "[" + v.join(", ") + "]";
+ } else {
+ var v = [];
+ for(attr in o) {
+ if(o[attr] == null) v.push("\"" + attr + "\": null");
+ else if(typeof o[attr] == "function"); /* skip */
+ else v.push(escapeJSONString(attr) + ": " + toJSON(o[attr]));
+ }
+ return "{" + v.join(", ") + "}";
+ }
+};
+
+
+/* JSONRpcClient constructor */
+
+JSONRpcClient =
+function JSONRpcClient_ctor(serverURL, user, pass, objectID)
+{
+ this.serverURL = serverURL;
+ this.user = user;
+ this.pass = pass;
+ this.objectID = objectID;
+
+ /* Add standard methods */
+ if(this.objectID) {
+ this._addMethods(["listMethods"]);
+ var req = this._makeRequest("listMethods", []);
+ } else {
+ this._addMethods(["system.listMethods"]);
+ var req = this._makeRequest("system.listMethods", []);
+ }
+ var m = this._sendRequest(req);
+ this._addMethods(m);
+};
+
+
+/* JSONRpcCLient.Exception */
+
+JSONRpcClient.Exception =
+function JSONRpcClient_Exception_ctor(code, message, javaStack)
+{
+ this.code = code;
+ var name;
+ if(javaStack) {
+ this.javaStack = javaStack;
+ var m = javaStack.match(/^([^:]*)/);
+ if(m) name = m[0];
+ }
+ if(name) this.name = name;
+ else this.name = "JSONRpcClientException";
+ this.message = message;
+};
+
+JSONRpcClient.Exception.CODE_REMOTE_EXCEPTION = 490;
+JSONRpcClient.Exception.CODE_ERR_CLIENT = 550;
+JSONRpcClient.Exception.CODE_ERR_PARSE = 590;
+JSONRpcClient.Exception.CODE_ERR_NOMETHOD = 591;
+JSONRpcClient.Exception.CODE_ERR_UNMARSHALL = 592;
+JSONRpcClient.Exception.CODE_ERR_MARSHALL = 593;
+
+JSONRpcClient.Exception.prototype = new Error();
+
+JSONRpcClient.Exception.prototype.toString =
+function JSONRpcClient_Exception_toString(code, msg)
+{
+ return this.name + ": " + this.message;
+};
+
+
+/* Default top level exception handler */
+
+JSONRpcClient.default_ex_handler =
+function JSONRpcClient_default_ex_handler(e) { alert(e); };
+
+
+/* Client settable variables */
+
+JSONRpcClient.toplevel_ex_handler = JSONRpcClient.default_ex_handler;
+JSONRpcClient.profile_async = false;
+JSONRpcClient.max_req_active = 1;
+JSONRpcClient.requestId = 1;
+
+
+/* JSONRpcClient implementation */
+
+JSONRpcClient.prototype._createMethod =
+function JSONRpcClient_createMethod(methodName)
+{
+ var fn=function()
+ {
+ var args = [];
+ var callback = null;
+ for(var i=0;i<arguments.length;i++) args.push(arguments[i]);
+
+/* TUSCANY change callback to be last arg instead of first to match binding.ajax
+ if(typeof args[0] == "function") callback = args.shift();
+*/
+ if(typeof args[arguments.length-1] == "function") callback = args.pop();
+
+ var req = fn.client._makeRequest.call(fn.client, fn.methodName,
+ args, callback);
+ if(callback == null) {
+ return fn.client._sendRequest.call(fn.client, req);
+ } else {
+ JSONRpcClient.async_requests.push(req);
+ JSONRpcClient.kick_async();
+ return req.requestId;
+ }
+ };
+ fn.client = this;
+ fn.methodName = methodName;
+ return fn;
+};
+
+JSONRpcClient.prototype._addMethods =
+function JSONRpcClient_addMethods(methodNames)
+{
+ for(var i=0; i<methodNames.length; i++) {
+ var obj = this;
+ var names = methodNames[i].split(".");
+ for(var n=0; n<names.length-1; n++) {
+ var name = names[n];
+ if(obj[name]) {
+ obj = obj[name];
+ } else {
+ obj[name] = new Object();
+ obj = obj[name];
+ }
+ }
+ var name = names[names.length-1];
+ if(!obj[name]) {
+ var method = this._createMethod(methodNames[i]);
+ obj[name] = method;
+ }
+ }
+};
+
+JSONRpcClient._getCharsetFromHeaders =
+function JSONRpcClient_getCharsetFromHeaders(http)
+{
+ try {
+ var contentType = http.getResponseHeader("Content-type");
+ var parts = contentType.split(/\s*;\s*/);
+ for(var i =0; i < parts.length; i++) {
+ if(parts[i].substring(0, 8) == "charset=")
+ return parts[i].substring(8, parts[i].length);
+ }
+ } catch (e) {}
+ return "UTF-8"; /* default */
+};
+
+/* Async queue globals */
+JSONRpcClient.async_requests = [];
+JSONRpcClient.async_inflight = {};
+JSONRpcClient.async_responses = [];
+JSONRpcClient.async_timeout = null;
+JSONRpcClient.num_req_active = 0;
+
+JSONRpcClient._async_handler =
+function JSONRpcClient_async_handler()
+{
+ JSONRpcClient.async_timeout = null;
+
+ while(JSONRpcClient.async_responses.length > 0) {
+ var res = JSONRpcClient.async_responses.shift();
+ if(res.canceled) continue;
+ if(res.profile) res.profile.dispatch = new Date();
+ try {
+ res.cb(res.result, res.ex, res.profile);
+ } catch(e) {
+ JSONRpcClient.toplevel_ex_handler(e);
+ }
+ }
+
+ while(JSONRpcClient.async_requests.length > 0 &&
+ JSONRpcClient.num_req_active < JSONRpcClient.max_req_active) {
+ var req = JSONRpcClient.async_requests.shift();
+ if(req.canceled) continue;
+ req.client._sendRequest.call(req.client, req);
+ }
+};
+
+JSONRpcClient.kick_async =
+function JSONRpcClient_kick_async()
+{
+ if(JSONRpcClient.async_timeout == null)
+ JSONRpcClient.async_timeout =
+ setTimeout(JSONRpcClient._async_handler, 0);
+};
+
+JSONRpcClient.cancelRequest =
+function JSONRpcClient_cancelRequest(requestId)
+{
+ /* If it is in flight then mark it as canceled in the inflight map
+ and the XMLHttpRequest callback will discard the reply. */
+ if(JSONRpcClient.async_inflight[requestId]) {
+ JSONRpcClient.async_inflight[requestId].canceled = true;
+ return true;
+ }
+
+ /* If its not in flight yet then we can just mark it as canceled in
+ the the request queue and it will get discarded before being sent. */
+ for(var i in JSONRpcClient.async_requests) {
+ if(JSONRpcClient.async_requests[i].requestId == requestId) {
+ JSONRpcClient.async_requests[i].canceled = true;
+ return true;
+ }
+ }
+
+ /* It may have returned from the network and be waiting for its callback
+ to be dispatched, so mark it as canceled in the response queue
+ and the response will get discarded before calling the callback. */
+ for(var i in JSONRpcClient.async_responses) {
+ if(JSONRpcClient.async_responses[i].requestId == requestId) {
+ JSONRpcClient.async_responses[i].canceled = true;
+ return true;
+ }
+ }
+
+ return false;
+};
+
+JSONRpcClient.prototype._makeRequest =
+function JSONRpcClient_makeRequest(methodName, args, cb)
+{
+ var req = {};
+ req.client = this;
+ req.requestId = JSONRpcClient.requestId++;
+
+ var obj = {};
+ obj.id = req.requestId;
+ if (this.objectID)
+ obj.method = ".obj#" + this.objectID + "." + methodName;
+ else
+ obj.method = methodName;
+ obj.params = args;
+
+ if (cb) req.cb = cb;
+ if (JSONRpcClient.profile_async)
+ req.profile = { "submit": new Date() };
+ req.data = toJSON(obj);
+
+ return req;
+};
+
+JSONRpcClient.prototype._sendRequest =
+function JSONRpcClient_sendRequest(req)
+{
+ if(req.profile) req.profile.start = new Date();
+
+ /* Get free http object from the pool */
+ var http = JSONRpcClient.poolGetHTTPRequest();
+ JSONRpcClient.num_req_active++;
+
+ /* Send the request */
+ if (typeof(this.user) == "undefined") {
+ http.open("POST", this.serverURL, (req.cb != null));
+ } else {
+ http.open("POST", this.serverURL, (req.cb != null), this.user, this.pass);
+ }
+
+ /* setRequestHeader is missing in Opera 8 Beta */
+ try { http.setRequestHeader("Content-type", "text/plain"); } catch(e) {}
+
+ /* Construct call back if we have one */
+ if(req.cb) {
+ var self = this;
+ http.onreadystatechange = function() {
+ if(http.readyState == 4) {
+ http.onreadystatechange = function () {};
+ var res = { "cb": req.cb, "result": null, "ex": null};
+ if (req.profile) {
+ res.profile = req.profile;
+ res.profile.end = new Date();
+ }
+ try { res.result = self._handleResponse(http); }
+ catch(e) { res.ex = e; }
+ if(!JSONRpcClient.async_inflight[req.requestId].canceled)
+ JSONRpcClient.async_responses.push(res);
+ delete JSONRpcClient.async_inflight[req.requestId];
+ JSONRpcClient.kick_async();
+ }
+ };
+ } else {
+ http.onreadystatechange = function() {};
+ }
+
+ JSONRpcClient.async_inflight[req.requestId] = req;
+
+ try {
+ http.send(req.data);
+ } catch(e) {
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+ throw new JSONRpcClient.Exception
+ (JSONRpcClient.Exception.CODE_ERR_CLIENT, "Connection failed");
+ }
+
+ if(!req.cb) return this._handleResponse(http);
+};
+
+JSONRpcClient.prototype._handleResponse =
+function JSONRpcClient_handleResponse(http)
+{
+ /* Get the charset */
+ if(!this.charset) {
+ this.charset = JSONRpcClient._getCharsetFromHeaders(http);
+ }
+
+ /* Get request results */
+ var status, statusText, data;
+ try {
+ status = http.status;
+ statusText = http.statusText;
+ data = http.responseText;
+ } catch(e) {
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+ JSONRpcClient.kick_async();
+ throw new JSONRpcClient.Exception
+ (JSONRpcClient.Exception.CODE_ERR_CLIENT, "Connection failed");
+ }
+
+ /* Return http object to the pool; */
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+
+ /* Unmarshall the response */
+ if(status != 200) {
+ throw new JSONRpcClient.Exception(status, statusText);
+ }
+ var obj;
+ try {
+ eval("obj = " + data);
+ } catch(e) {
+ throw new JSONRpcClient.Exception(550, "error parsing result");
+ }
+ if(obj.error)
+ throw new JSONRpcClient.Exception(obj.error.code, obj.error.msg,
+ obj.error.trace);
+ var res = obj.result;
+
+ /* Handle CallableProxy */
+ if(res && res.objectID && res.JSONRPCType == "CallableReference")
+ return new JSONRpcClient(this.serverURL, this.user,
+ this.pass, res.objectID);
+
+ return res;
+};
+
+
+/* XMLHttpRequest wrapper code */
+
+/* XMLHttpRequest pool globals */
+JSONRpcClient.http_spare = [];
+JSONRpcClient.http_max_spare = 8;
+
+JSONRpcClient.poolGetHTTPRequest =
+function JSONRpcClient_pool_getHTTPRequest()
+{
+ if(JSONRpcClient.http_spare.length > 0) {
+ return JSONRpcClient.http_spare.pop();
+ }
+ return JSONRpcClient.getHTTPRequest();
+};
+
+JSONRpcClient.poolReturnHTTPRequest =
+function JSONRpcClient_poolReturnHTTPRequest(http)
+{
+ if(JSONRpcClient.http_spare.length >= JSONRpcClient.http_max_spare)
+ delete http;
+ else
+ JSONRpcClient.http_spare.push(http);
+};
+
+JSONRpcClient.msxmlNames = [ "MSXML2.XMLHTTP.5.0",
+ "MSXML2.XMLHTTP.4.0",
+ "MSXML2.XMLHTTP.3.0",
+ "MSXML2.XMLHTTP",
+ "Microsoft.XMLHTTP" ];
+
+JSONRpcClient.getHTTPRequest =
+function JSONRpcClient_getHTTPRequest()
+{
+ /* Mozilla XMLHttpRequest */
+ try {
+ JSONRpcClient.httpObjectName = "XMLHttpRequest";
+ return new XMLHttpRequest();
+ } catch(e) {}
+
+ /* Microsoft MSXML ActiveX */
+ for (var i=0;i < JSONRpcClient.msxmlNames.length; i++) {
+ try {
+ JSONRpcClient.httpObjectName = JSONRpcClient.msxmlNames[i];
+ return new ActiveXObject(JSONRpcClient.msxmlNames[i]);
+ } catch (e) {}
+ }
+
+ /* None found */
+ JSONRpcClient.httpObjectName = null;
+ throw new JSONRpcClient.Exception(0, "Can't create XMLHttpRequest object");
+};
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java
new file mode 100644
index 0000000000..4b159fb563
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 bean;
+
+public class TestBean {
+ private String testString;
+ private String[] testStringArray;
+ private int testInt;
+
+
+ public String getTestString() {
+ return testString;
+ }
+
+ public void setTestString(String testString) {
+ this.testString = testString;
+ }
+
+ public String[] getTestStringArray() {
+ return testStringArray;
+ }
+
+ public void setStringArray(String[] stringArray) {
+ this.testStringArray = stringArray;
+ }
+
+ public int getTestInt() {
+ return testInt;
+ }
+
+ public void setTestInt(int testInt) {
+ this.testInt = testInt;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java
new file mode 100644
index 0000000000..322008de1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 echo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+import bean.TestBean;
+
+/**
+ * Interface of our sample JSONRPC service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Echo {
+
+ String echo(String msg);
+
+ void echoRuntimeException() throws RuntimeException;
+
+ void echoBusinessException() throws EchoBusinessException;
+
+ int echoInt(int param);
+
+ boolean echoBoolean(boolean param);
+
+ Map echoMap(HashMap map);
+
+ TestBean echoBean(TestBean testBean);
+
+ List echoList(ArrayList list);
+
+ String [] echoArrayString(String[] stringArray);
+
+ int [] echoArrayInt(int[] intArray);
+
+ Set echoSet(HashSet set);
+
+ void get\u03a9\u03bb\u03c0();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java
new file mode 100644
index 0000000000..bd9d905475
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 echo;
+
+public class EchoBusinessException extends Exception {
+ private static final long serialVersionUID = 7234119326657905710L;
+
+ public EchoBusinessException(String message)
+ {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java
new file mode 100644
index 0000000000..f76ec74b16
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.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 echo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.oasisopen.sca.annotation.Reference;
+
+import bean.TestBean;
+
+public class EchoClientImpl implements Echo {
+ @Reference
+ protected Echo echoReference;
+
+ public String echo(String msg) {
+ return echoReference.echo(msg);
+ }
+
+ public int[] echoArrayInt(int[] intArray) {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public String[] echoArrayString(String[] stringArray) {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public TestBean echoBean(TestBean testBean) {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public boolean echoBoolean(boolean param) {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public void echoBusinessException() throws EchoBusinessException {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public int echoInt(int param) {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public List echoList(ArrayList list) {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public Map echoMap(HashMap map) {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public void echoRuntimeException() throws RuntimeException {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public Set echoSet(HashSet set) {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+ public void get\u03a9\u03bb\u03c0() {
+ throw new UnsupportedOperationException("UNsupported !");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java
new file mode 100644
index 0000000000..08ccb6e6d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.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 echo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import bean.TestBean;
+
+/**
+ * A simple client component that uses a reference with an JSONRPC binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoComponentImpl implements Echo {
+
+ public String echo(String msg) {
+ System.out.println("Echo: "+ msg);
+ return "echo: " + msg;
+ }
+
+ public void echoBusinessException() throws EchoBusinessException {
+ throw new EchoBusinessException("Business Exception");
+
+ }
+
+ public void echoRuntimeException() throws RuntimeException {
+ throw new RuntimeException("Runtime Exception");
+ }
+
+ public int echoInt(int param) {
+ int value = param;
+ return value;
+ }
+
+ public boolean echoBoolean(boolean param) {
+ boolean value = param;
+ return value;
+ }
+
+ public Map echoMap(HashMap param) {
+ Map map = new HashMap();
+ map = param;
+ return map;
+ }
+
+ public TestBean echoBean(TestBean testBean1) {
+ TestBean testBean = new TestBean();
+ testBean.setTestString(testBean1.getTestString());
+ testBean.setTestInt(testBean1.getTestInt());
+ return testBean;
+ }
+
+ public List echoList(ArrayList param){
+ List list = new ArrayList();
+ for(Iterator itr = param.iterator();itr.hasNext();)
+ {
+ list.add(itr.next());
+ }
+ return list;
+ }
+
+ public String[] echoArrayString(String[] stringArray) {
+ return stringArray;
+ }
+
+ public int[] echoArrayInt(int[] intArray) {
+ return intArray;
+ }
+
+ public Set echoSet(HashSet param){
+ Set set = new HashSet();
+ set = param;
+ return set;
+
+ }
+
+
+ public void get\u03a9\u03bb\u03c0() {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
new file mode 100644
index 0000000000..0fd622d29b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jsonrpc;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCDataTypeTestCase {
+
+ private static final String SERVICE_PATH = "/EchoService";
+ private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH;
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(JSONRPCDataTypeTestCase.class);
+ node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testInt() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{ \"method\": \"echoInt\", \"params\": [12345], \"id\": 4}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+
+ Assert.assertEquals(12345, jsonResp.getInt("result"));
+ }
+
+ @Test
+ public void testBoolean() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+
+ Assert.assertEquals(true, jsonResp.getBoolean("result"));
+ }
+
+ @Test
+ public void testMap() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+
+ Assert.assertEquals("JSON-RPC", jsonResp.getJSONObject("result").getJSONObject("map").getString("Binding"));
+ }
+
+ @Test
+ public void testBean() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"bean.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+
+ Assert.assertEquals("JSON-RPC", jsonResp.getJSONObject("result").getString("testString"));
+ }
+
+ @Test
+ public void testList() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{ \"method\": \"echoList\", \"params\": [[0,1,2,3,4]], \"id\": 8}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+
+ Assert.assertEquals(0, jsonResp.getJSONArray("result").get(0));
+ }
+
+ @Test
+ public void testArrayString() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"id\":9}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+
+ Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0));
+ }
+
+
+ @Test
+ public void testArrayInt() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{\"params\":[[1,2]],\"method\":\"echoArrayInt\",\"id\":10}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+
+ Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0));
+ }
+
+
+ @Test
+ public void testSet() throws Exception {
+ JSONObject jsonRequest = new JSONObject(
+ "{ \"method\": \"echoSet\", \"params\": [[\"red\", \"blue\"]],\"id\": 11}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+
+ Assert.assertEquals("red", jsonResp.getJSONArray("result").get(0));
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java
new file mode 100644
index 0000000000..56080058c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jsonrpc;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCExceptionTestCase{
+
+ private static final String SERVICE_PATH = "/EchoService";
+
+ private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH;
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(JSONRPCExceptionTestCase.class);
+ node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testRuntimeException() throws Exception{
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoRuntimeException\", \"params\": [], \"id\": 2}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonErr = new JSONObject(response.getText()).getJSONObject("error");
+
+ Assert.assertEquals("Runtime Exception", jsonErr.getString("msg"));
+ }
+
+ @Test
+ public void testBusinessException() throws Exception{
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBusinessException\", \"params\": [], \"id\": 3}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonErr = new JSONObject(response.getText()).getJSONObject("error");
+
+ Assert.assertEquals("Business Exception", jsonErr.getString("msg"));
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java
new file mode 100644
index 0000000000..efdb0a23db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.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.binding.jsonrpc;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import echo.Echo;
+
+public class JSONRPCReferenceTestCase {
+ private static final String SERVICE_PATH = "/EchoService";
+ private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH;
+
+ private static Node nodeServer;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(JSONRPCReferenceTestCase.class);
+ nodeServer = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("testServer", contribution));
+ nodeServer.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ nodeServer.stop();
+ }
+
+ @Test
+ public void testInvokeReference() throws Exception {
+ Node node = null;
+
+ String contribution = ContributionLocationHelper.getContributionLocation(JSONRPCReferenceTestCase.class);
+ node = NodeFactory.newInstance().createNode("JSONRPCReference.composite", new Contribution("testClient", contribution));
+ node.start();
+
+ Echo echoComponent = node.getService(Echo.class,"EchoComponentWithReference");
+ String result = echoComponent.echo("ABC");
+ Assert.assertEquals("echo: ABC", result);
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
new file mode 100644
index 0000000000..7c6ba6a99f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jsonrpc;
+
+import java.io.ByteArrayInputStream;
+import java.net.URLEncoder;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.om.util.Base64;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCServiceTestCase{
+
+ private static final String SERVICE_PATH = "/EchoService";
+
+ private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH;
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(JSONRPCServiceTestCase.class);
+ node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testJSONRPCBinding() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"echo\", \"params\": [\"Hello JSON-RPC\"], \"id\": 1}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+ Assert.assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
+ }
+
+ @Test
+ public void testJSONRPCBindingGET() throws Exception {
+ String params = Base64.encode("[\"Hello JSON-RPC\"]".getBytes());
+ String queryString = "?method=echo&params=" + URLEncoder.encode(params,"UTF-8") + "&id=1";
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL + queryString);
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+ Assert.assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
+ }
+
+
+
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java
new file mode 100644
index 0000000000..a1b076c0e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jsonrpc;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCSmdTestCase {
+
+ private static final String SERVICE_PATH = "/EchoService";
+
+ private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH;
+
+ private static final String SMD_URL = SERVICE_URL + "?smd";
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(JSONRPCSmdTestCase.class);
+ node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ /**
+ * This test make sure the JSON-RPC Binding can handle special characters when generating SMD
+ */
+ public void testJSONRPCSmdSpecialCharacters() throws Exception {
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SMD_URL);
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertNotNull(response.getText());
+
+ //System.out.println(">>>SMD:" + response.getText());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite
new file mode 100644
index 0000000000..9c97574db7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://jsonrpc"
+ xmlns:jsonrpc="http://jsonrpc"
+ name="JSONRPCBinding">
+
+ <!--service name="EchoService" promote="EchoComponent">
+ <interface.java interface="echo.Echo"/>
+ <tuscany:binding.jsonrpc uri="http://localhost:8085/SCADomain/EchoService"/>
+ </service -->
+
+ <component name="EchoComponent">
+ <implementation.java class="echo.EchoComponentImpl"/>
+ <service name="Echo">
+ <tuscany:binding.jsonrpc uri="http://localhost:8085/SCADomain/EchoService"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite
new file mode 100644
index 0000000000..16dcbce45f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://jsonrpc"
+ xmlns:jsonrpc="http://jsonrpc"
+ name="JSONRPCReference">
+
+ <component name="EchoComponentWithReference">
+ <implementation.java class="echo.EchoClientImpl"/>
+ <reference name="echoReference">
+ <tuscany:binding.jsonrpc uri="http://localhost:8085/SCADomain/EchoService"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/LICENSE b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/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/sebastien/java/embed/modules/binding-jsonrpc/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a2a44e4e79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.jsonrpc;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,javax.xml.namespace"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JSON-RPC Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JSON-RPC Binding Model
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.jsonrpc;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.jsonrpc
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/NOTICE b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/pom.xml b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/pom.xml
new file mode 100644
index 0000000000..8df899f83a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/pom.xml
@@ -0,0 +1,46 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-jsonrpc</artifactId>
+ <name>Apache Tuscany SCA JSON-RPC Binding Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java
new file mode 100644
index 0000000000..1e14502d93
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.jsonrpc;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * A model for the JSONRPC binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JSONRPCBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.jsonrpc");
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java
new file mode 100644
index 0000000000..707a9d7103
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.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 org.apache.tuscany.sca.binding.jsonrpc;
+
+
+/**
+ * Factory for the JSON RPC binding model.
+ *
+ * @version $Rev$ $Date$
+*/
+public interface JSONRPCBindingFactory {
+
+ /**
+ * Creates a new JSON RPC Binding
+ * @return a new JSON RPC Binding
+ */
+ JSONRPCBinding createJSONRPCBinding();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingFactoryImpl.java
new file mode 100644
index 0000000000..625457a668
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingFactoryImpl.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 org.apache.tuscany.sca.binding.jsonrpc.impl;
+
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory;
+
+
+/**
+ * Factory for the JSON RPC binding model.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JSONRPCBindingFactoryImpl implements JSONRPCBindingFactory {
+
+ public JSONRPCBinding createJSONRPCBinding() {
+ return new JSONRPCBindingImpl();
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.java
new file mode 100644
index 0000000000..4c1a261e81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.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.sca.binding.jsonrpc.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
+
+/**
+ * A model for the JSONRPC binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBindingImpl implements JSONRPCBinding {
+ private String name;
+ private String uri;
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isUnresolved() {
+ // The binding is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory
new file mode 100644
index 0000000000..9f68137afe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.jsonrpc.impl.JSONRPCBindingFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..4d14d00112
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.jsonrpc,model=org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding,factory=org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/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/sebastien/java/embed/modules/binding-rest-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..415357c314
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,51 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.rest.provider;version="2.0.
+ 0",.;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA REST Binding Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA REST Binding Runtime
+Import-Package: javax.jws,
+ javax.servlet,
+ javax.servlet.http,
+ javax.ws.rs,
+ javax.ws.rs.core,
+ javax.ws.rs.ext,
+ javax.xml,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.operationselector.jaxrs;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.operationselector.rpc;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.wireformat.json;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.wireformat.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.http;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.wink.client,
+ org.apache.wink.client.handlers,
+ org.apache.wink.common,
+ org.apache.wink.common.internal.registry,
+ org.apache.wink.common.internal.registry.metadata,
+ org.apache.wink.server.internal,
+ org.apache.wink.server.internal.registry,
+ org.apache.wink.server.internal.servlet,
+ org.apache.wink.server.utils,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rest.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/pom.xml
new file mode 100644
index 0000000000..c3b8bac602
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/pom.xml
@@ -0,0 +1,175 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-rest-runtime</artifactId>
+ <name>Apache Tuscany SCA REST Binding Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxrs</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-server</artifactId>
+ <version>1.1.1-incubating</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-client</artifactId>
+ <version>1.1.1-incubating</version>
+ </dependency>
+
+ <dependency>
+ <groupId>httpunit</groupId>
+ <artifactId>httpunit</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <reportFormat>brief</reportFormat>
+ <useFile>false</useFile>
+ <forkMode>once</forkMode>
+ <argLine>-ea -Xmx256m</argLine>
+ <parallel>off</parallel>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java
new file mode 100644
index 0000000000..928b80a044
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.operationselector.jaxrs.provider;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.net.URLDecoder;
+import java.util.List;
+
+import javax.activation.DataSource;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+
+import org.apache.tuscany.sca.common.http.HTTPContext;
+import org.apache.tuscany.sca.common.http.HTTPUtil;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * JAXRS operation selector Interceptor.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JAXRSOperationSelectorInterceptor implements Interceptor {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpoint endpoint;
+
+ private RuntimeComponentService service;
+ private InterfaceContract interfaceContract;
+ private List<Operation> serviceOperations;
+
+ private Invoker next;
+
+ public JAXRSOperationSelectorInterceptor(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.extensionPoints = extensionPoints;
+ this.endpoint = endpoint;
+
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.interfaceContract = service.getInterfaceContract();
+ this.serviceOperations = service.getInterfaceContract().getInterface().getOperations();
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ HTTPContext bindingContext = (HTTPContext)msg.getBindingContext();
+
+ // By-pass the operation selector
+ if (bindingContext == null) {
+ return getNext().invoke(msg);
+ }
+
+ String path = URLDecoder.decode(HTTPUtil.getRequestPath(bindingContext.getHttpRequest()), "UTF-8");
+
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+
+ List<Operation> operations =
+ filterOperationsByHttpMethod(interfaceContract, bindingContext.getHttpRequest().getMethod());
+
+ Operation operation = findOperation(path, operations);
+
+ final JavaOperation javaOperation = (JavaOperation)operation;
+ final Method method = javaOperation.getJavaMethod();
+
+ if (path != null && path.length() > 0) {
+ if (method.getAnnotation(Path.class) != null) {
+ msg.setBody(new Object[] {path});
+ }
+ }
+
+ // FIXME: [rfeng] We should follow JAX-RS rules to identify the entity parameter
+ Class<?>[] paramTypes = method.getParameterTypes();
+ if (paramTypes.length == 1) {
+ Class<?> type = paramTypes[0];
+ InputStream is = (InputStream)((Object[])msg.getBody())[0];
+ Object target = convert(is, bindingContext.getHttpRequest().getContentType(), type);
+ msg.setBody(new Object[] {target});
+ } else if (paramTypes.length == 0) {
+ msg.setBody(null);
+ }
+
+ msg.setOperation(operation);
+
+ return getNext().invoke(msg);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private Object convert(InputStream content, String contentType, Class<?> type) {
+ if (type == DataSource.class) {
+ return type.cast(new InputStreamDataSource(content, contentType));
+ } else if (type == InputStream.class) {
+ return type.cast(content);
+ } else if (type == String.class) {
+ try {
+ StringWriter sw = new StringWriter();
+ InputStreamReader reader = new InputStreamReader(content, "UTF-8");
+ char[] buf = new char[8192];
+ while (true) {
+ int size = reader.read(buf);
+ if (size < 0) {
+ break;
+ }
+ sw.write(buf, 0, size);
+ }
+ return type.cast(sw.toString());
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else if (type == byte[].class) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buf = new byte[8192];
+ while (true) {
+ int size = content.read(buf);
+ if (size < 0) {
+ break;
+ }
+ bos.write(buf, 0, size);
+ }
+ return type.cast(bos.toByteArray());
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ return content;
+ }
+ }
+
+ public static final class InputStreamDataSource implements DataSource {
+
+ public static final String DEFAULT_TYPE = "application/octet-stream";
+
+ private final InputStream in;
+ private final String ctype;
+
+ public InputStreamDataSource(InputStream in) {
+ this(in, null);
+ }
+
+ public InputStreamDataSource(InputStream in, String ctype) {
+ this.in = in;
+ this.ctype = (ctype != null) ? ctype : DEFAULT_TYPE;
+ }
+
+ public String getContentType() {
+ return ctype;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ return in;
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return null;
+ }
+
+ }
+
+ /**
+ * Find the operation from the component service contract
+ * @param componentService
+ * @param http_method
+ * @return
+ */
+ private static List<Operation> filterOperationsByHttpMethod(InterfaceContract interfaceContract, String http_method) {
+ List<Operation> operations = null;
+
+ if (http_method.equalsIgnoreCase("get")) {
+ operations = (List<Operation>)interfaceContract.getInterface().getAttributes().get(GET.class);
+ } else if (http_method.equalsIgnoreCase("put")) {
+ operations = (List<Operation>)interfaceContract.getInterface().getAttributes().get(PUT.class);
+ } else if (http_method.equalsIgnoreCase("post")) {
+ operations = (List<Operation>)interfaceContract.getInterface().getAttributes().get(POST.class);
+ } else if (http_method.equalsIgnoreCase("delete")) {
+ operations = (List<Operation>)interfaceContract.getInterface().getAttributes().get(DELETE.class);
+ }
+
+ return operations;
+ }
+
+ /**
+ * Find the operation from the component service contract
+ * @param componentService
+ * @param http_method
+ * @return
+ */
+ private Operation findOperation(String path, List<Operation> operations) {
+ Operation operation = null;
+
+ for (Operation op : operations) {
+ final JavaOperation javaOperation = (JavaOperation)op;
+ final Method method = javaOperation.getJavaMethod();
+
+ if (path != null && path.length() > 0) {
+ if (method.getAnnotation(Path.class) != null) {
+ operation = op;
+ break;
+ }
+ } else {
+ if (method.getAnnotation(Path.class) == null) {
+ operation = op;
+ break;
+ }
+ }
+ }
+
+ return operation;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFactory.java
new file mode 100644
index 0000000000..d057f1a852
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFactory.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.binding.rest.operationselector.jaxrs.provider;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * JAXRS operation selector Provider Factory.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JAXRSOperationSelectorProviderFactory implements OperationSelectorProviderFactory<JAXRSOperationSelector>{
+ private ExtensionPointRegistry extensionPoints;
+
+ public JAXRSOperationSelectorProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference) {
+ return new JAXRSOperationSelectorReferenceProvider(extensionPoints, endpointReference);
+ }
+
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint) {
+ return new JAXRSOperationSelectorServiceProvider(extensionPoints, endpoint);
+ }
+
+ public Class<JAXRSOperationSelector> getModelType() {
+ return JAXRSOperationSelector.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorReferenceProvider.java
new file mode 100644
index 0000000000..c560a13ae2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorReferenceProvider.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.binding.rest.operationselector.jaxrs.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * JAXRS operation selector Reference Provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JAXRSOperationSelectorReferenceProvider implements OperationSelectorProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpointReference endpointReference;
+
+ public JAXRSOperationSelectorReferenceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpointReference endpointReference ) {
+ this.extensionPoints = extensionPoints;
+ this.endpointReference = endpointReference;
+ }
+
+ public Interceptor createInterceptor() {
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorServiceProvider.java
new file mode 100644
index 0000000000..105c84ebda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorServiceProvider.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.binding.rest.operationselector.jaxrs.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * JAXRS operation selector Service Provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JAXRSOperationSelectorServiceProvider implements OperationSelectorProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpoint endpoint;
+
+ private Binding binding;
+
+ public JAXRSOperationSelectorServiceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.extensionPoints = extensionPoints;
+ this.endpoint = endpoint;
+ this.binding = endpoint.getBinding();
+ }
+
+ public Interceptor createInterceptor() {
+ if(binding.getOperationSelector() != null && binding.getOperationSelector() instanceof JAXRSOperationSelector) {
+ return new JAXRSOperationSelectorInterceptor(extensionPoints, endpoint);
+ }
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorInterceptor.java
new file mode 100644
index 0000000000..0df6e5e0fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorInterceptor.java
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.operationselector.rpc.provider;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.QueryParam;
+
+import org.apache.tuscany.sca.common.http.HTTPContext;
+import org.apache.tuscany.sca.common.http.HTTPUtil;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * RPC operation selector Interceptor.
+ *
+ * @version $Rev$ $Date$
+*/
+public class RPCOperationSelectorInterceptor implements Interceptor {
+ private ExtensionPointRegistry extensionPoints;
+ private SimpleTypeMapper simpleTypeMapper;
+
+ private RuntimeEndpoint endpoint;
+
+ private RuntimeComponentService service;
+ private InterfaceContract interfaceContract;
+ private List<Operation> serviceOperations;
+
+ private Invoker next;
+
+ public RPCOperationSelectorInterceptor(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.extensionPoints = extensionPoints;
+
+ UtilityExtensionPoint utilityExtensionPoint = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.simpleTypeMapper = utilityExtensionPoint.getUtility(SimpleTypeMapper.class);
+
+ this.endpoint = endpoint;
+
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.interfaceContract = service.getInterfaceContract();
+ this.serviceOperations = service.getInterfaceContract().getInterface().getOperations();
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ HTTPContext bindingContext = (HTTPContext)msg.getBindingContext();
+
+ if(! "get".equalsIgnoreCase(bindingContext.getHttpRequest().getMethod())) {
+ throw new RuntimeException("RPC Invocation only allowed over HTTP GET operations");
+ }
+
+ String path = URLDecoder.decode(HTTPUtil.getRequestPath(bindingContext.getHttpRequest()), "UTF-8");
+
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+
+
+ String operationName = bindingContext.getHttpRequest().getParameter("method");
+ Operation operation = findOperation( operationName );
+
+ if (operation == null) {
+ throw new RuntimeException("Invalid Operation '" + operationName + "'" );
+ }
+
+ final JavaOperation javaOperation = (JavaOperation)operation;
+ final Method method = javaOperation.getJavaMethod();
+
+ List<Object> messageParameters = new ArrayList<Object>();
+ for(int i=0; i<method.getParameterTypes().length; i++) {
+ for(Annotation annotation : method.getParameterAnnotations()[i]) {
+ if (annotation instanceof QueryParam) {
+ QueryParam queryParam = (QueryParam) annotation;
+ String name = queryParam.value();
+ String[] values = bindingContext.getHttpRequest().getParameterValues(name);
+
+ if(values.length == 1) {
+ //process value, making necessary map from string to expected value
+ Class<?> clazz = method.getParameterTypes()[i];
+ TypeInfo typeInfo = simpleTypeMapper.getXMLType(clazz);
+ Object v = simpleTypeMapper.toJavaObject(typeInfo.getQName(), values[0], null);
+ messageParameters.add(v);
+ } else {
+ //process value, making necessary map from string to expected value
+ Class<?> clazz = (method.getParameterTypes()[i]).getComponentType();
+ TypeInfo typeInfo = simpleTypeMapper.getXMLType(clazz);
+
+
+ Object objectArray = Array.newInstance(clazz, values.length);
+ for (int count = 0; count < values.length; ++count) {
+ Object v = simpleTypeMapper.toJavaObject(typeInfo.getQName(), values[count], null);
+ Array.set(objectArray, count, v);
+ }
+
+ messageParameters.add(objectArray);
+ }
+ }
+ }
+ }
+
+ Object[] body = new Object[messageParameters.size()];
+ messageParameters.toArray(body);
+
+ msg.setBody(body);
+ msg.setOperation(operation);
+
+ Message responseMessage = getNext().invoke(msg);
+
+ //set Cache-Control to no-cache to avoid intermediary
+ //proxy/reverse-proxy caches and always hit the server
+ //that would identify if the value was current or not
+ bindingContext.getHttpResponse().setHeader("Cache-Control", "no-cache");
+ bindingContext.getHttpResponse().setHeader("Expires", new Date(0).toGMTString());
+
+
+ String eTag = HTTPUtil.calculateHashETag(responseMessage.getBody().toString().getBytes("UTF-8"));
+
+ // Test request for predicates.
+ String predicate = bindingContext.getHttpRequest().getHeader( "If-Match" );
+ if (( predicate != null ) && ( !predicate.equals(eTag) )) {
+ // No match, should short circuit
+ bindingContext.getHttpResponse().sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
+ }
+ predicate = bindingContext.getHttpRequest().getHeader( "If-None-Match" );
+ if (( predicate != null ) && ( predicate.equals(eTag) )) {
+ // Match, should short circuit
+ bindingContext.getHttpResponse().sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ }
+
+ bindingContext.getHttpResponse().addHeader("ETag", eTag);
+
+ return responseMessage;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Find the operation from the component service contract
+ * @param componentService
+ * @param method
+ * @return
+ */
+ private Operation findOperation(String method) {
+ if (method.contains(".")) {
+ method = method.substring(method.lastIndexOf(".") + 1);
+ }
+
+ List<Operation> operations = endpoint.getComponentServiceInterfaceContract().getInterface().getOperations();
+
+ Operation result = null;
+ for (Operation o : operations) {
+ if (o.getName().equalsIgnoreCase(method)) {
+ result = o;
+ break;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorProviderFactory.java
new file mode 100644
index 0000000000..011e89e7cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorProviderFactory.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.binding.rest.operationselector.rpc.provider;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * RPC operation selector Provider Factory.
+ *
+ * @version $Rev$ $Date$
+*/
+public class RPCOperationSelectorProviderFactory implements OperationSelectorProviderFactory<RPCOperationSelector>{
+ private ExtensionPointRegistry extensionPoints;
+
+ public RPCOperationSelectorProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference) {
+ return new RPCOperationSelectorReferenceProvider(extensionPoints, endpointReference);
+ }
+
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint) {
+ return new RPCOperationSelectorServiceProvider(extensionPoints, endpoint);
+ }
+
+ public Class<RPCOperationSelector> getModelType() {
+ return RPCOperationSelector.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorReferenceProvider.java
new file mode 100644
index 0000000000..c87b2fc21d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorReferenceProvider.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.binding.rest.operationselector.rpc.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * RPC operation selector Reference Provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class RPCOperationSelectorReferenceProvider implements OperationSelectorProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpointReference endpointReference;
+
+ public RPCOperationSelectorReferenceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpointReference endpointReference ) {
+ this.extensionPoints = extensionPoints;
+ this.endpointReference = endpointReference;
+ }
+
+ public Interceptor createInterceptor() {
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorServiceProvider.java
new file mode 100644
index 0000000000..e4a003d4b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorServiceProvider.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.binding.rest.operationselector.rpc.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * RPC operation selector Service Provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class RPCOperationSelectorServiceProvider implements OperationSelectorProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpoint endpoint;
+
+ private Binding binding;
+
+ public RPCOperationSelectorServiceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.extensionPoints = extensionPoints;
+ this.endpoint = endpoint;
+ this.binding = endpoint.getBinding();
+ }
+
+ public Interceptor createInterceptor() {
+ if(binding.getOperationSelector() != null && binding.getOperationSelector() instanceof RPCOperationSelector) {
+ return new RPCOperationSelectorInterceptor(extensionPoints, endpoint);
+ }
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java
new file mode 100644
index 0000000000..1ccdb868d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.provider;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.activation.DataSource;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.Provider;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * A JAX-RS provider that leverages Tuscany's databinding framework to handle read/write
+ * for JAX-RS runtime
+ */
+@Provider
+public abstract class DataBindingJAXRSProvider {
+ protected DataBindingExtensionPoint dataBindingExtensionPoint;
+ protected Mediator mediator;
+
+ public DataBindingJAXRSProvider(ExtensionPointRegistry registry) {
+ this.dataBindingExtensionPoint = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.mediator = utilities.getUtility(Mediator.class);
+ }
+
+ protected <A extends Annotation> A getAnnotation(Annotation[] annotations, Class<A> type) {
+ for (Annotation a : annotations) {
+ if (a.annotationType() == type) {
+ return type.cast(a);
+ }
+ }
+ return null;
+ }
+
+ protected void introspectAnnotations(Annotation[] annotations, DataType targetDataType) {
+ WebResult result = getAnnotation(annotations, WebResult.class);
+ if (result != null) {
+ QName name = new QName(result.targetNamespace(), result.name());
+ targetDataType.setLogical(new XMLType(name, null));
+ }
+
+ WebParam param = getAnnotation(annotations, WebParam.class);
+ if (param != null) {
+ QName name = new QName(param.targetNamespace(), param.name());
+ targetDataType.setLogical(new XMLType(name, null));
+ }
+ }
+
+ protected DataType createDataType(Class<?> type, Type genericType) {
+ DataType dataType = new DataTypeImpl(null, type, type, genericType);
+ dataBindingExtensionPoint.introspectType(dataType, null);
+ return dataType;
+ }
+
+ protected boolean supports(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ // Some media types have parameters
+ mediaType = new MediaType(mediaType.getType(), mediaType.getSubtype());
+ return MediaType.APPLICATION_JSON_TYPE.isCompatible(mediaType) || MediaType.APPLICATION_XML_TYPE.isCompatible(mediaType)
+ || MediaType.TEXT_XML_TYPE.isCompatible(mediaType);
+ }
+
+ protected Object convert(InputStream content, String contentType, Class<?> type) throws IOException {
+ if (type == DataSource.class) {
+ return type.cast(new InputStreamDataSource(content, contentType));
+ } else if (type == InputStream.class) {
+ return type.cast(content);
+ } else if (type == Reader.class) {
+ return type.cast(new InputStreamReader(content, "UTF-8"));
+ } else if (type == String.class) {
+ try {
+ StringWriter sw = new StringWriter();
+ InputStreamReader reader = new InputStreamReader(content, "UTF-8");
+ char[] buf = new char[8192];
+ while (true) {
+ int size = reader.read(buf);
+ if (size < 0) {
+ break;
+ }
+ sw.write(buf, 0, size);
+ }
+ return type.cast(sw.toString());
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else if (type == byte[].class) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buf = new byte[8192];
+ while (true) {
+ int size = content.read(buf);
+ if (size < 0) {
+ break;
+ }
+ bos.write(buf, 0, size);
+ }
+ return type.cast(bos.toByteArray());
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ return content;
+ }
+ }
+
+ protected void write(OutputStream out, Object content, Class<?> type) throws IOException {
+ if (content == null) {
+ return;
+ }
+ InputStream in = null;
+ if (DataSource.class.isAssignableFrom(type)) {
+ in = ((DataSource)content).getInputStream();
+ } else if (InputStream.class.isAssignableFrom(type)) {
+ in = (InputStream)content;
+ } else if (type == String.class) {
+ in = new ByteArrayInputStream(((String)content).getBytes("UTF-8"));
+ } else if (type == byte[].class) {
+ in = new ByteArrayInputStream((byte[])content);
+ }
+ if (in == null) {
+ throw new IllegalArgumentException("Type is not supported: " + type);
+ }
+ byte[] buf = new byte[8192];
+ while (true) {
+ int len = in.read(buf);
+ if (len < 0) {
+ in.close();
+ break;
+ }
+ out.write(buf, 0, len);
+ }
+ }
+
+ public static final class InputStreamDataSource implements DataSource {
+
+ public static final String DEFAULT_TYPE = "application/octet-stream";
+
+ private final InputStream in;
+ private final String ctype;
+
+ public InputStreamDataSource(InputStream in) {
+ this(in, null);
+ }
+
+ public InputStreamDataSource(InputStream in, String ctype) {
+ this.in = in;
+ this.ctype = (ctype != null) ? ctype : DEFAULT_TYPE;
+ }
+
+ public String getContentType() {
+ return ctype;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ return in;
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return null;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java
new file mode 100644
index 0000000000..d38881eb28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.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.rest.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+
+/**
+ * The generic JAX-RS message body reader based on Tuscany's databindingframework
+ */
+@Provider
+public class DataBindingJAXRSReader<T> extends DataBindingJAXRSProvider implements MessageBodyReader<T> {
+
+ public DataBindingJAXRSReader(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+// DataType dataType = createDataType(type, genericType);
+ return supports(type, genericType, annotations, mediaType);
+ }
+
+ public T readFrom(Class<T> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType,
+ MultivaluedMap<String, String> httpHeaders,
+ InputStream entityStream) throws IOException, WebApplicationException {
+
+ Object source = entityStream;
+ DataType targetDataType = createDataType(type, genericType);
+
+ String dataBinding = null;
+
+ mediaType = new MediaType(mediaType.getType(), mediaType.getSubtype());
+ // FIXME: [rfeng] This is a hack to handle application/json
+ if (MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
+ dataBinding = mediaType.toString() + "#" + InputStream.class.getName();
+ } else if ("application/x-protobuf".equals(mediaType.toString())) {
+ dataBinding = mediaType.toString() + "#" + InputStream.class.getName();
+ }
+ else if (MediaType.APPLICATION_XML_TYPE.equals(mediaType) || MediaType.TEXT_XML_TYPE.equals(mediaType)) {
+ dataBinding = InputStream.class.getName();
+ } else {
+ dataBinding = targetDataType.getDataBinding();
+ source = convert(entityStream, mediaType.toString(), type);
+ return (T) source;
+ }
+ DataType sourceDataType =
+ new DataTypeImpl(dataBinding, InputStream.class, InputStream.class, InputStream.class);
+
+ Object result = mediator.mediate(source, sourceDataType, targetDataType, Collections.<String, Object>emptyMap());
+ return (T)result;
+ }
+
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java
new file mode 100644
index 0000000000..be2a9555d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.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.sca.binding.rest.provider;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+
+/**
+ * The generic JAX-RS message body writer based on Tuscany's databindingframework
+ */
+@Provider
+public class DataBindingJAXRSWriter<T> extends DataBindingJAXRSProvider implements MessageBodyWriter<T> {
+
+ public DataBindingJAXRSWriter(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public long getSize(T t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ // DataType dataType = createDataType(type, genericType);
+ return supports(type, genericType, annotations, mediaType);
+ }
+
+ public void writeTo(T t,
+ Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException, WebApplicationException {
+ DataType dataType = createDataType(type, genericType);
+ mediaType = new MediaType(mediaType.getType(), mediaType.getSubtype());
+ String dataBinding = OutputStream.class.getName();
+ // FIXME: [rfeng] This is a hack to handle application/json
+ if (MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
+ dataBinding = mediaType.toString() + "#" + OutputStream.class.getName();
+ } else if (MediaType.APPLICATION_XML_TYPE.equals(mediaType) || MediaType.TEXT_XML_TYPE.equals(mediaType)) {
+ dataBinding = OutputStream.class.getName();
+ } else if ("application/x-protobuf".equals(mediaType.toString())) {
+ dataBinding = mediaType.toString() + "#" + OutputStream.class.getName();
+ }
+ else {
+ dataBinding = dataType.getDataBinding();
+ write(entityStream, t, type);
+ return;
+ }
+ DataType targetDataType =
+ new DataTypeImpl(dataBinding, OutputStream.class, OutputStream.class, OutputStream.class);
+ // dataBindingExtensionPoint.introspectType(targetDataType, null);
+
+ introspectAnnotations(annotations, targetDataType);
+
+ mediator.mediate(t, entityStream, dataType, targetDataType, Collections.<String, Object> emptyMap());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/JAXRSHelper.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/JAXRSHelper.java
new file mode 100644
index 0000000000..2bf95f0677
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/JAXRSHelper.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.provider;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.Path;
+
+/**
+ * A utility class that deals with JAX-RS annotations
+ */
+public class JAXRSHelper {
+ private JAXRSHelper() {
+
+ }
+
+ /**
+ * A resource class is a Java class that uses JAX-RS annotations to implement a corresponding Web resource.
+ * Resource classes are POJOs that have at least one method annotated with @Path or a request method designator.
+ * @param cls
+ * @return
+ */
+ public static boolean isJAXRSResource(Class<?> cls) {
+ for (Method method : cls.getMethods()) {
+ if (method.isAnnotationPresent(Path.class)) {
+ return true;
+ }
+ if (isResourceMethod(method)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Root resource class is a resource class annotated with @Path. Root resource classes provide the roots of the
+ * resource class tree and provide access to sub-resources
+ * @param cls
+ * @return
+ */
+ public static boolean isJAXRSRootResource(Class<?> cls) {
+ return cls.isAnnotationPresent(Path.class) && isJAXRSResource(cls);
+ }
+
+ public static boolean isResourceMethod(Method method) {
+ for (Annotation a : method.getAnnotations()) {
+ Class<?> annotationType = a.annotationType();
+ if (annotationType == HttpMethod.class) {
+ return true;
+ }
+ // Http method related annotations such as @GET, @POST will have itself annotated with
+ // @HttpMethod
+ HttpMethod m = a.annotationType().getAnnotation(HttpMethod.class);
+ if (m != null) {
+ return true;
+ }
+ }
+ return false;
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
new file mode 100644
index 0000000000..1673f3aefa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.provider;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.CookieParam;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.OPTIONS;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Cookie;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+import org.apache.tuscany.sca.common.http.HTTPCacheContext;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.wink.client.ClientConfig;
+import org.apache.wink.client.Resource;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.client.handlers.BasicAuthSecurityHandler;
+
+/**
+ *
+ */
+public class RESTBindingInvoker implements Invoker {
+ private ExtensionPointRegistry registry;
+ private RESTBinding binding;
+ private Operation operation;
+ private RestClient restClient;
+ private String httpMethod;
+ private Class<?> responseType;
+
+ public RESTBindingInvoker(ExtensionPointRegistry registry, RESTBinding binding, Operation operation) {
+ super();
+ this.registry = registry;
+ this.binding = binding;
+ this.operation = operation;
+ this.restClient = createRestClient();
+ }
+
+ private static Map<Class<?>, String> mapping = new HashMap<Class<?>, String>();
+ static {
+ mapping.put(GET.class, HttpMethod.GET);
+ mapping.put(POST.class, HttpMethod.POST);
+ mapping.put(PUT.class, HttpMethod.PUT);
+ mapping.put(DELETE.class, HttpMethod.DELETE);
+ mapping.put(HEAD.class, HttpMethod.HEAD);
+ mapping.put(OPTIONS.class, HttpMethod.OPTIONS);
+ }
+
+ private static <T extends Annotation> T getAnnotation(Annotation[] annotations, Class<T> type) {
+ for (Annotation a : annotations) {
+ if (a.annotationType() == type) {
+ return type.cast(a);
+ }
+ }
+ return null;
+ }
+
+ private RestClient createRestClient() {
+ ClientConfig config = new ClientConfig();
+
+ // configureBasicAuth(config, userName, password);
+
+ config.applications(new Application() {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ Set<Object> providers = new HashSet<Object>();
+ providers.add(new DataBindingJAXRSReader(registry));
+ providers.add(new DataBindingJAXRSWriter(registry));
+ return providers;
+ }
+
+ });
+ RestClient client = new RestClient(config);
+
+ // Default to GET for RPC
+ httpMethod = HttpMethod.GET;
+
+ for (Map.Entry<Class<?>, String> e : mapping.entrySet()) {
+ if (operation.getAttributes().get(e.getKey()) != null) {
+ httpMethod = e.getValue();
+ break;
+ }
+ }
+
+ if (operation.getOutputType() != null) {
+ responseType = operation.getOutputType().getPhysical();
+ } else {
+ responseType = null;
+ }
+ return client;
+ }
+
+ private void configureBasicAuth(ClientConfig config, String userName, String password) {
+ BasicAuthSecurityHandler basicAuthSecurityHandler = new BasicAuthSecurityHandler();
+ basicAuthSecurityHandler.setUserName(userName);
+ basicAuthSecurityHandler.setPassword(password);
+ config.handlers(basicAuthSecurityHandler);
+ }
+
+ public Message invoke(Message msg) {
+
+ Object entity = null;
+ Object[] args = msg.getBody();
+
+ URI uri = URI.create(binding.getURI());
+ UriBuilder uriBuilder = UriBuilder.fromUri(uri);
+
+ Method method = ((JavaOperation)operation).getJavaMethod();
+
+ if (method.isAnnotationPresent(Path.class)) {
+ // Only for resource method
+ uriBuilder.path(method);
+ }
+
+ if (!JAXRSHelper.isResourceMethod(method)) {
+ // This is RPC over GET
+ uriBuilder.replaceQueryParam("method", method.getName());
+ }
+
+ Map<String, Object> pathParams = new HashMap<String, Object>();
+ Map<String, Object> matrixParams = new HashMap<String, Object>();
+ Map<String, Object> queryParams = new HashMap<String, Object>();
+ Map<String, Object> headerParams = new HashMap<String, Object>();
+ Map<String, Object> formParams = new HashMap<String, Object>();
+ Map<String, Object> cookieParams = new HashMap<String, Object>();
+
+ for (int i = 0; i < method.getParameterTypes().length; i++) {
+ boolean isEntity = true;
+ Annotation[] annotations = method.getParameterAnnotations()[i];
+ PathParam pathParam = getAnnotation(annotations, PathParam.class);
+ if (pathParam != null) {
+ isEntity = false;
+ pathParams.put(pathParam.value(), args[i]);
+ }
+ MatrixParam matrixParam = getAnnotation(annotations, MatrixParam.class);
+ if (matrixParam != null) {
+ isEntity = false;
+ matrixParams.put(matrixParam.value(), args[i]);
+ }
+ QueryParam queryParam = getAnnotation(annotations, QueryParam.class);
+ if (queryParam != null) {
+ isEntity = false;
+ queryParams.put(queryParam.value(), args[i]);
+ }
+ HeaderParam headerParam = getAnnotation(annotations, HeaderParam.class);
+ if (headerParam != null) {
+ isEntity = false;
+ headerParams.put(headerParam.value(), args[i]);
+ }
+ FormParam formParam = getAnnotation(annotations, FormParam.class);
+ if (formParam != null) {
+ isEntity = false;
+ formParams.put(formParam.value(), args[i]);
+ }
+ CookieParam cookieParam = getAnnotation(annotations, CookieParam.class);
+ if (cookieParam != null) {
+ isEntity = false;
+ cookieParams.put(cookieParam.value(), args[i]);
+ }
+ if (isEntity) {
+ entity = args[i];
+ }
+ }
+
+ for (Map.Entry<String, Object> p : queryParams.entrySet()) {
+ uriBuilder.replaceQueryParam(p.getKey(), p.getValue());
+ }
+ for (Map.Entry<String, Object> p : matrixParams.entrySet()) {
+ uriBuilder.replaceMatrixParam(p.getKey(), p.getValue());
+ }
+
+ uri = uriBuilder.buildFromMap(pathParams);
+ Resource resource = restClient.resource(uri);
+
+ for (Map.Entry<String, Object> p : headerParams.entrySet()) {
+ resource.header(p.getKey(), String.valueOf(p.getValue()));
+ }
+
+ for (Map.Entry<String, Object> p : cookieParams.entrySet()) {
+ Cookie cookie = new Cookie(p.getKey(), String.valueOf(p.getValue()));
+ resource.cookie(cookie);
+ }
+
+ resource.contentType(getContentType());
+ resource.accept(getAccepts());
+
+ //handles declarative headers configured on the composite
+ for (HTTPHeader header : binding.getHttpHeaders()) {
+ //treat special headers that need to be calculated
+ if (header.getName().equalsIgnoreCase("Expires")) {
+ GregorianCalendar calendar = new GregorianCalendar();
+ calendar.setTime(new Date());
+
+ calendar.add(Calendar.HOUR, Integer.parseInt(header.getValue()));
+
+ resource.header("Expires", HTTPCacheContext.RFC822DateFormat.format(calendar.getTime()));
+ } else {
+ //default behaviour to pass the header value to HTTP response
+ resource.header(header.getName(), header.getValue());
+ }
+ }
+
+ Object result = resource.invoke(httpMethod, responseType, entity);
+ msg.setBody(result);
+ return msg;
+ }
+
+ private String getContentType() {
+ String contentType = MediaType.APPLICATION_OCTET_STREAM;
+ Consumes consumes = ((JavaOperation)operation).getJavaMethod().getAnnotation(Consumes.class);
+ if (consumes != null && consumes.value().length > 0) {
+ contentType = consumes.value()[0];
+ }
+ WireFormat wf = binding.getRequestWireFormat();
+ if (wf != null) {
+ if (XMLWireFormat.REST_WIREFORMAT_XML_QNAME.equals(wf.getSchemaName())) {
+ contentType = MediaType.APPLICATION_XML;
+ } else if (JSONWireFormat.REST_WIREFORMAT_JSON_QNAME.equals(wf.getSchemaName())) {
+ contentType = MediaType.APPLICATION_JSON;
+ }
+ }
+ return contentType;
+ }
+
+ private String[] getAccepts() {
+ String accepts[] = {MediaType.APPLICATION_OCTET_STREAM};
+ Produces produces = ((JavaOperation)operation).getJavaMethod().getAnnotation(Produces.class);
+ if (produces != null) {
+ accepts = produces.value();
+ }
+ WireFormat wf = binding.getResponseWireFormat();
+ if (wf != null) {
+ if (XMLWireFormat.REST_WIREFORMAT_XML_QNAME.equals(wf.getSchemaName())) {
+ accepts = new String[] {MediaType.APPLICATION_XML};
+ } else if (JSONWireFormat.REST_WIREFORMAT_JSON_QNAME.equals(wf.getSchemaName())) {
+ accepts = new String[] {MediaType.APPLICATION_JSON};
+ }
+ }
+ return accepts;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java
new file mode 100644
index 0000000000..4583b11879
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java
@@ -0,0 +1,582 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLDecoder;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.common.http.HTTPCacheContext;
+import org.apache.tuscany.sca.common.http.HTTPContentTypeMapper;
+import org.apache.tuscany.sca.common.http.HTTPContext;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+/**
+ * Servlet responsible for dispatching HTTP requests to the
+ * target component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingListenerServlet extends HttpServlet {
+ private static final long serialVersionUID = 2865466417329430610L;
+
+ transient private MessageFactory messageFactory;
+
+ transient private RESTBinding binding;
+ transient private Invoker bindingInvoker;
+
+ private Invoker invoker;
+ private Invoker getInvoker;
+ private Invoker conditionalGetInvoker;
+ private Invoker putInvoker;
+ private Invoker conditionalPutInvoker;
+ private Invoker postInvoker;
+ private Invoker conditionalPostInvoker;
+ private Invoker deleteInvoker;
+ private Invoker conditionalDeleteInvoker;
+
+ /**
+ * Constructs a new RESTServiceListenerServlet.
+ */
+ public RESTBindingListenerServlet(Binding binding, Invoker bindingInvoker, MessageFactory messageFactory) {
+ this.binding = (RESTBinding) binding;
+ this.bindingInvoker = bindingInvoker;
+ this.messageFactory = messageFactory;
+ }
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ if( binding.getOperationSelector() != null || binding.getRequestWireFormat() != null) {
+ HTTPContext bindingContext = new HTTPContext();
+ bindingContext.setHttpRequest(request);
+ bindingContext.setHttpResponse(response);
+
+ // Dispatch the service interaction to the service invoker
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBindingContext(bindingContext);
+
+ requestMessage.setBody(new Object[] {request.getInputStream()});
+
+ Message responseMessage = bindingInvoker.invoke(requestMessage);
+
+ // return response to client
+ if (responseMessage.isFault()) {
+ // Turn a fault into an exception
+ Throwable e = (Throwable)responseMessage.getBody();
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+ } else {
+
+ for(HTTPHeader header : binding.getHttpHeaders()) {
+ //treat special headers that need to be calculated
+ if(header.getName().equalsIgnoreCase("Expires")) {
+ GregorianCalendar calendar = new GregorianCalendar();
+ calendar.setTime(new Date());
+
+ calendar.add(Calendar.HOUR, Integer.parseInt(header.getValue()));
+
+ response.setHeader("Expires", HTTPCacheContext.RFC822DateFormat.format( calendar.getTime() ));
+ } else {
+ //default behaviour to pass the header value to HTTP response
+ response.setHeader(header.getName(), header.getValue());
+ }
+
+ }
+
+ //handle void operations
+ write(response.getOutputStream(), responseMessage.getBody());
+ response.getOutputStream().flush();
+ response.getOutputStream().close();
+ }
+ } else {
+ super.service(request, response);
+ }
+
+
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.length() ==0) {
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+
+ String id = path.substring(1);
+
+ Message responseMessage = null;
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
+ } catch (ParseException e) {
+
+ }
+
+ if (path == null || path.length() == 0 || path.equals("/")) {
+
+ }
+
+ // Route message based on availability of cache info and cache methods
+ if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalGetInvoker != null )) {
+ if(id != null && id.length() > 0) {
+ requestMessage.setBody(new Object[] {id, cacheContext});
+ } else {
+ requestMessage.setBody(new Object[] {cacheContext});
+ }
+
+ responseMessage = conditionalGetInvoker.invoke(requestMessage);
+ } else {
+ if(id != null && id.length() > 0) {
+ requestMessage.setBody(new Object[] {id});
+ } else {
+ //requestMessage.setBody(new Object[] {id});
+ }
+
+ responseMessage = getInvoker.invoke(requestMessage);
+ }
+
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+
+ int index = -1;
+ if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
+ if ( index > -1 ) {
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
+ } else {
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+ }
+ return;
+ } else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
+ if ( index > -1 ) {
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
+ } else {
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
+ }
+ return;
+ }
+
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+ if(response.getContentType() == null || response.getContentType().length() == 0){
+ // Calculate content-type based on extension
+ String contentType = HTTPContentTypeMapper.getContentType(id);
+ if(contentType != null && contentType.length() >0) {
+ response.setContentType(contentType);
+ }
+ }
+
+ // Write the response from the service implementation to the response
+ // output stream
+ InputStream is = (InputStream)responseMessage.getBody();
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ os.flush();
+ os.close();
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.length() ==0) {
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ String id = path.substring(1);
+
+ Message responseMessage = null;
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
+ } catch (ParseException e) {
+ }
+
+ // Route message based on availability of cache info and cache methods
+ if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalDeleteInvoker != null )) {
+ requestMessage.setBody(new Object[] {id, cacheContext});
+ responseMessage = conditionalDeleteInvoker.invoke(requestMessage);
+ } else {
+ requestMessage.setBody(new Object[] {id});
+ responseMessage = deleteInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+
+ int index = -1;
+ if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
+ if ( index > -1 ) {
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
+ } else {
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+ }
+ return;
+ } else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
+ if ( index > -1 ) {
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
+ } else {
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
+ }
+ return;
+ }
+
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+ // Write the response from the service implementation to the response
+ // output stream
+ InputStream is = (InputStream)responseMessage.getBody();
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ os.flush();
+ os.close();
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.length() ==0) {
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ String id = path.substring(1);
+
+ Message responseMessage = null;
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
+ } catch (ParseException e) {
+ }
+
+ // Route message based on availability of cache info and cache methods
+ if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalPutInvoker != null )) {
+ requestMessage.setBody(new Object[] {id, cacheContext});
+ responseMessage = conditionalPutInvoker.invoke(requestMessage);
+ } else {
+ requestMessage.setBody(new Object[] {id});
+ responseMessage = putInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+
+ int index = -1;
+ if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
+ if ( index > -1 ) {
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
+ } else {
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+ }
+ return;
+ } else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
+ if ( index > -1 ) {
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
+ } else {
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
+ }
+ return;
+ }
+
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+ // Write the response from the service implementation to the response
+ // output stream
+ InputStream is = (InputStream)responseMessage.getBody();
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ os.flush();
+ os.close();
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.length() ==0) {
+ // Redirect to a URL ending with / to make relative hrefs work
+ // relative to the served resource.
+ response.sendRedirect(request.getRequestURL().append('/').toString());
+ return;
+ }
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ // String id = path.substring(1);
+
+ Message responseMessage = null;
+ HTTPCacheContext cacheContext = null;
+ try {
+ cacheContext = HTTPCacheContext.createCacheContextFromRequest(request);
+ } catch (ParseException e) {
+ }
+
+ // Route message based on availability of cache info and cache methods
+ if (( cacheContext != null ) && (cacheContext.isEnabled()) && (conditionalPostInvoker != null )) {
+ requestMessage.setBody(new Object[] {cacheContext});
+ responseMessage = conditionalPostInvoker.invoke(requestMessage);
+ } else {
+ requestMessage.setBody(new Object[] {});
+ responseMessage = postInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+
+ int index = -1;
+ if ( -1 < (index = body.getClass().getName().indexOf( "NotModifiedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+ return;
+ } else if ( -1 < (index = body.getClass().getName().indexOf( "PreconditionFailedException")) ) {
+ if ( index > -1 )
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED, body.toString().substring( index ));
+ else
+ response.sendError( HttpServletResponse.SC_PRECONDITION_FAILED );
+ return;
+ }
+
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+
+
+ // Test if the ETag and LastModified are returned as a cache context.
+ Object body = responseMessage.getBody();
+ if ( body.getClass() == HTTPCacheContext.class ) {
+ // Transfer to header if so.
+ HTTPCacheContext cc = (HTTPCacheContext)responseMessage.getBody();
+ if (( cc != null ) && ( cc.isEnabled() )) {
+ String eTag = cc.getETag();
+ if ( eTag != null ) {
+ response.setHeader( "ETag", cc.getETag() );
+ }
+ String lastModified = cc.getLastModified();
+ if ( lastModified != null) {
+ response.setHeader( "LastModified", cc.getLastModified() );
+ }
+ }
+ }
+ }
+
+
+ public void setInvoker(Invoker invoker) {
+ this.invoker = invoker;
+ }
+
+ public Invoker getInvoker() {
+ return invoker;
+ }
+
+
+ /**
+ * @return the getInvoker
+ */
+ public Invoker getGetInvoker() {
+ return getInvoker;
+ }
+
+ /**
+ * @param getInvoker the getInvoker to set
+ */
+ public void setGetInvoker(Invoker getInvoker) {
+ this.getInvoker = getInvoker;
+ }
+
+ /**
+ * @return the conditionalGetInvoker
+ */
+ public Invoker getConditionalGetInvoker() {
+ return conditionalGetInvoker;
+ }
+
+ /**
+ * @param conditionalGetInvoker the conditionalGetInvoker to set
+ */
+ public void setConditionalGetInvoker(Invoker conditionalGetInvoker) {
+ this.conditionalGetInvoker = conditionalGetInvoker;
+ }
+
+ /**
+ * @return the putInvoker
+ */
+ public Invoker getPutInvoker() {
+ return putInvoker;
+ }
+
+ /**
+ * @param putInvoker the putInvoker to set
+ */
+ public void setPutInvoker(Invoker putInvoker) {
+ this.putInvoker = putInvoker;
+ }
+
+ /**
+ * @return the conditionalPutInvoker
+ */
+ public Invoker getConditionalPutInvoker() {
+ return conditionalPutInvoker;
+ }
+
+ /**
+ * @param conditionalPutInvoker the conditionalPutInvoker to set
+ */
+ public void setConditionalPutInvoker(Invoker conditionalPutInvoker) {
+ this.conditionalPutInvoker = conditionalPutInvoker;
+ }
+
+ /**
+ * @return the postInvoker
+ */
+ public Invoker getPostInvoker() {
+ return postInvoker;
+ }
+
+ /**
+ * @param postInvoker the postInvoker to set
+ */
+ public void setPostInvoker(Invoker postInvoker) {
+ this.postInvoker = postInvoker;
+ }
+
+ /**
+ * @return the conditionalPostInvoker
+ */
+ public Invoker getConditionalPostInvoker() {
+ return conditionalPostInvoker;
+ }
+
+ /**
+ * @param conditionalPostInvoker the conditionalPostInvoker to set
+ */
+ public void setConditionalPostInvoker(Invoker conditionalPostInvoker) {
+ this.conditionalPostInvoker = conditionalPostInvoker;
+ }
+
+ /**
+ * @return the deleteInvoker
+ */
+ public Invoker getDeleteInvoker() {
+ return deleteInvoker;
+ }
+
+ /**
+ * @param deleteInvoker the deleteInvoker to set
+ */
+ public void setDeleteInvoker(Invoker deleteInvoker) {
+ this.deleteInvoker = deleteInvoker;
+ }
+
+ /**
+ * @return the conditionalDeleteInvoker
+ */
+ public Invoker getConditionalDeleteInvoker() {
+ return conditionalDeleteInvoker;
+ }
+
+ /**
+ * @param conditionalDeleteInvoker the conditionalDeleteInvoker to set
+ */
+ public void setConditionalDeleteInvoker(Invoker conditionalDeleteInvoker) {
+ this.conditionalDeleteInvoker = conditionalDeleteInvoker;
+ }
+
+ /**
+ *
+ * Utility methods
+ *
+ */
+
+
+
+ private void write(OutputStream out, Object obj) throws IOException {
+ if (obj == null) {
+ return;
+ }
+ if (obj instanceof String) {
+ out.write(((String)obj).getBytes("UTF-8"));
+ } else if (obj instanceof byte[]) {
+ out.write((byte[])obj);
+ } else if (obj instanceof InputStream) {
+ byte[] buf = new byte[8192];
+ InputStream in = (InputStream)obj;
+ while (true) {
+ int size = in.read(buf);
+ if (size < 0) {
+ break;
+ }
+ out.write(buf, 0, size);
+ }
+ } else {
+ out.write(obj.toString().getBytes("UTF-8"));
+ }
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java
new file mode 100644
index 0000000000..0f5047deef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.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.sca.binding.rest.provider;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+
+/**
+ * Factory for REST binding providers.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingProviderFactory implements BindingProviderFactory<RESTBinding> {
+ private ExtensionPointRegistry extensionPoints;
+ private MessageFactory messageFactory;
+ private ServletHost servletHost;
+
+ public RESTBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ messageFactory = modelFactories.getFactory(MessageFactory.class);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new RESTReferenceBindingProvider(extensionPoints, endpointReference);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new RESTServiceBindingProvider(endpoint, extensionPoints, messageFactory, servletHost);
+ }
+
+ public Class<RESTBinding> getModelType() {
+ return RESTBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
new file mode 100644
index 0000000000..e218f32573
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.provider;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ *
+ */
+public class RESTReferenceBindingProvider implements EndpointReferenceProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeEndpointReference endpointReference;
+
+ public RESTReferenceBindingProvider(ExtensionPointRegistry registry, RuntimeEndpointReference endpointReference) {
+ super();
+ this.registry = registry;
+ this.endpointReference = endpointReference;
+ }
+
+ public void configure() {
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new RESTBindingInvoker(registry, (RESTBinding)endpointReference.getBinding(), operation);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return endpointReference.getComponentReferenceInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
new file mode 100644
index 0000000000..9a9e5a108e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
@@ -0,0 +1,371 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.provider;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.Servlet;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.jaxrs.RootResourceClassGenerator;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.EndpointProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.wink.server.utils.RegistrationUtils;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Implementation of an HTTP binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTServiceBindingProvider implements EndpointProvider {
+ private static Map<QName, String> wireFormatToMediaTypeMapping = new HashMap<QName, String>();
+
+ static {
+ wireFormatToMediaTypeMapping.put(JSONWireFormat.REST_WIREFORMAT_JSON_QNAME, MediaType.APPLICATION_JSON);
+ wireFormatToMediaTypeMapping.put(XMLWireFormat.REST_WIREFORMAT_XML_QNAME, MediaType.APPLICATION_XML);
+ }
+
+ private ExtensionPointRegistry extensionPoints;
+
+ private RuntimeEndpoint endpoint;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private InterfaceContract serviceContract;
+ private RESTBinding binding;
+ private MessageFactory messageFactory;
+
+ private OperationSelectorProvider osProvider;
+ private WireFormatProvider wfProvider;
+ private WireFormatProvider wfResponseProvider;
+
+ private ServletHost servletHost;
+ private String servletMapping;
+ private RESTBindingListenerServlet bindingListenerServlet;
+
+ private SimpleApplication application;
+
+ public RESTServiceBindingProvider(RuntimeEndpoint endpoint,
+ ExtensionPointRegistry extensionPoints,
+ MessageFactory messageFactory,
+ ServletHost servletHost) {
+
+ this.endpoint = endpoint;
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (RESTBinding)endpoint.getBinding();
+
+ this.extensionPoints = extensionPoints;
+ this.messageFactory = messageFactory;
+ this.servletHost = servletHost;
+
+ // retrieve operation selector and wire format service providers
+
+ ProviderFactoryExtensionPoint providerFactories =
+ extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+ if (binding.getOperationSelector() != null) {
+ // Configure the interceptors for operation selection
+ OperationSelectorProviderFactory osProviderFactory =
+ (OperationSelectorProviderFactory)providerFactories.getProviderFactory(binding.getOperationSelector()
+ .getClass());
+ if (osProviderFactory != null) {
+ this.osProvider = osProviderFactory.createServiceOperationSelectorProvider(endpoint);
+ }
+ }
+
+ if (binding.getRequestWireFormat() != null) {
+ // Configure the interceptors for wire format
+ WireFormatProviderFactory wfProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(binding.getRequestWireFormat()
+ .getClass());
+ if (wfProviderFactory != null) {
+ this.wfProvider = wfProviderFactory.createServiceWireFormatProvider(endpoint);
+ }
+ }
+
+ if (binding.getResponseWireFormat() != null) {
+ // Configure the interceptors for wire format
+ WireFormatProviderFactory wfProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(binding.getResponseWireFormat()
+ .getClass());
+ if (wfProviderFactory != null) {
+ this.wfResponseProvider = wfProviderFactory.createServiceWireFormatProvider(endpoint);
+ }
+ }
+
+ //clone the service contract to avoid databinding issues
+ try {
+ this.serviceContract = (InterfaceContract)service.getInterfaceContract().clone();
+
+ // configure data binding
+ if (wfProvider != null) {
+ wfProvider.configureWireFormatInterfaceContract(serviceContract);
+ }
+
+ if (wfResponseProvider != null) {
+ wfResponseProvider.configureWireFormatInterfaceContract(serviceContract);
+ }
+ } catch (CloneNotSupportedException e) {
+ this.serviceContract = service.getInterfaceContract();
+ }
+
+ }
+
+ public void start() {
+ InvocationChain bindingChain = endpoint.getBindingInvocationChain();
+
+ application = registerWithJAXRS();
+ if (application != null) {
+ return;
+ }
+
+ // Get the invokers for the supported operations
+ Servlet servlet = null;
+ Invoker bindingInvoker = bindingChain.getHeadInvoker();
+ bindingListenerServlet = new RESTBindingListenerServlet(binding, bindingInvoker, messageFactory);
+ for (InvocationChain invocationChain : endpoint.getInvocationChains()) {
+
+ Operation operation = invocationChain.getTargetOperation();
+ Invoker serviceInvoker = invocationChain.getHeadInvoker();
+ String operationName = operation.getName();
+
+ if (binding.getOperationSelector() != null || binding.getRequestWireFormat() != null) {
+ bindingListenerServlet.setInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("get")) {
+ bindingListenerServlet.setGetInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("conditionalGet")) {
+ bindingListenerServlet.setConditionalGetInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("delete")) {
+ bindingListenerServlet.setDeleteInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("conditionalDelete")) {
+ bindingListenerServlet.setConditionalDeleteInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("put")) {
+ bindingListenerServlet.setPutInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("conditionalPut")) {
+ bindingListenerServlet.setConditionalPutInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("post")) {
+ bindingListenerServlet.setPostInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("conditionalPost")) {
+ bindingListenerServlet.setConditionalPostInvoker(serviceInvoker);
+ servlet = bindingListenerServlet;
+ } else if (operationName.equals("service")) {
+ servlet = new RESTServiceListenerServlet(binding, serviceInvoker, messageFactory);
+ break;
+ }
+ }
+ if (servlet == null) {
+ throw new IllegalStateException("No get or service method found on the service");
+ }
+
+ // Create our HTTP service listener Servlet and register it with the
+ // Servlet host
+ servletMapping = binding.getURI();
+ if (!servletMapping.endsWith("/")) {
+ servletMapping += "/";
+ }
+ if (!servletMapping.endsWith("*")) {
+ servletMapping += "*";
+ }
+
+ servletHost.addServletMapping(servletMapping, servlet);
+ }
+
+ public void stop() {
+ if (application != null) {
+ application.destroy();
+ }
+ // Unregister the Servlet from the Servlet host
+ servletHost.removeServletMapping(servletMapping);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return serviceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ /**
+ * Register a Tuscany REST Servlet to handle JAX-RS Resources on a binding endpoint
+ * @return
+ */
+ private SimpleApplication registerWithJAXRS() {
+ try {
+ SimpleApplication application = null;
+
+ JavaInterface javaInterface = (JavaInterface)endpoint.getComponentServiceInterfaceContract().getInterface();
+ Class<?> interfaze = javaInterface.getJavaClass();
+
+ // The @Path annotation can be from the binding uri
+ boolean isJAXRS = JAXRSHelper.isJAXRSResource(interfaze);
+ if (isJAXRS) {
+ application = new SimpleApplication(interfaze);
+
+ TuscanyRESTServlet restServlet = new TuscanyRESTServlet(extensionPoints, application.resourceClass);
+
+ // Create our HTTP service listener Servlet and register it with the
+ // Servlet host
+ servletMapping = binding.getURI();
+ if (!servletMapping.endsWith("/")) {
+ servletMapping += "/";
+ }
+ if (!servletMapping.endsWith("*")) {
+ servletMapping += "*";
+ }
+
+ servletHost.addServletMapping(servletMapping, restServlet);
+ RegistrationUtils.registerApplication(application, restServlet.getServletContext());
+ return application;
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ private class SimpleApplication extends Application {
+ private Class<?> resourceClass;
+
+ public SimpleApplication(Class<?> resourceClass) {
+ super();
+ if (resourceClass.isInterface()) {
+ this.resourceClass = generateResourceClass(resourceClass);
+ } else {
+ this.resourceClass = resourceClass;
+ }
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(resourceClass);
+ return classes;
+ }
+
+ private Class<?> generateResourceClass(Class<?> interfaze) {
+ try {
+ QName requestWireFormat = null;
+ if (binding.getRequestWireFormat() != null) {
+ requestWireFormat = binding.getRequestWireFormat().getSchemaName();
+ }
+ QName responeWireFormat = null;
+ if (binding.getResponseWireFormat() != null) {
+ responeWireFormat = binding.getRequestWireFormat().getSchemaName();
+ }
+ String requestMediaType = wireFormatToMediaTypeMapping.get(requestWireFormat);
+ String responseMediaType = wireFormatToMediaTypeMapping.get(responeWireFormat);
+
+ String uri = endpoint.getBinding().getURI();
+ String path = URI.create(uri).getPath();
+
+ // FIXME: [rfeng] We need to have a better way to deal with URI template for bindings
+ if (path.startsWith(servletHost.getContextPath())) {
+ path = path.substring(servletHost.getContextPath().length());
+ }
+ Class<?> cls =
+ RootResourceClassGenerator.generateRootResourceClass(interfaze,
+ path,
+ requestMediaType,
+ responseMediaType);
+ ProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(extensionPoints);
+ Object proxy = proxyFactory.createProxy(interfaze, endpoint);
+ RootResourceClassGenerator.injectProxy(cls, proxy);
+ return cls;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public void destroy() {
+ resourceClass = null;
+ }
+ }
+
+ /**
+ * Add specific rest interceptor to invocation chain
+ */
+ public void configure() {
+
+ InvocationChain bindingChain = endpoint.getBindingInvocationChain();
+
+ if (wfProvider != null) {
+ Interceptor interceptor = wfProvider.createInterceptor();
+ if (interceptor != null) {
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, interceptor);
+ }
+ }
+
+ if (wfResponseProvider != null) {
+ Interceptor interceptor = wfResponseProvider.createInterceptor();
+ if (interceptor != null) {
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, interceptor);
+ }
+
+ }
+
+ if (osProvider != null) {
+ Interceptor interceptor = osProvider.createInterceptor();
+ if (interceptor != null) {
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, interceptor);
+ }
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java
new file mode 100644
index 0000000000..1dac8a2c9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.provider;
+
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.common.http.HTTPCacheContext;
+import org.apache.tuscany.sca.common.http.HTTPContext;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+/**
+ * Servlet responsible for dispatching HTTP service requests to the
+ * target component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTServiceListenerServlet extends HttpServlet implements Servlet {
+
+ private static final long serialVersionUID = -5543706958107836637L;
+
+ transient private RESTBinding binding;
+ transient private ServletConfig config;
+ transient private MessageFactory messageFactory;
+ transient private Invoker serviceInvoker;
+
+ /**
+ * Constructs a new HTTPServiceListenerServlet.
+ */
+ public RESTServiceListenerServlet(Binding binding, Invoker serviceInvoker, MessageFactory messageFactory) {
+ this.binding = (RESTBinding) binding;
+ this.serviceInvoker = serviceInvoker;
+ this.messageFactory = messageFactory;
+ }
+
+ public ServletConfig getServletConfig() {
+ return config;
+ }
+
+ public String getServletInfo() {
+ return "";
+ }
+
+ public void init(ServletConfig config) throws ServletException {
+ this.config = config;
+ }
+
+ public void destroy() {
+
+ }
+
+ @Override
+ public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ HTTPContext bindingContext = new HTTPContext();
+ bindingContext.setHttpRequest(request);
+ bindingContext.setHttpResponse(response);
+
+ // Dispatch the service interaction to the service invoker
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBindingContext(bindingContext);
+ requestMessage.setBody(new Object[]{request, response});
+ Message responseMessage = serviceInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ // Turn a fault into an exception
+ //throw new ServletException((Throwable)responseMessage.getBody());
+ Throwable e = (Throwable)responseMessage.getBody();
+ ((HttpServletResponse)response).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+ } else {
+ //handles declarative headers configured on the composite
+ for(HTTPHeader header : binding.getHttpHeaders()) {
+ //treat special headers that need to be calculated
+ if(header.getName().equalsIgnoreCase("Expires")) {
+ GregorianCalendar calendar = new GregorianCalendar();
+ calendar.setTime(new Date());
+
+ calendar.add(Calendar.HOUR, Integer.parseInt(header.getValue()));
+
+ response.setHeader("Expires", HTTPCacheContext.RFC822DateFormat.format( calendar.getTime() ));
+ } else {
+ //default behaviour to pass the header value to HTTP response
+ response.setHeader(header.getName(), header.getValue());
+ }
+
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
new file mode 100644
index 0000000000..23b951c88a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.provider;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.wink.common.internal.registry.ProvidersRegistry;
+import org.apache.wink.common.internal.registry.metadata.MethodMetadata;
+import org.apache.wink.server.internal.DeploymentConfiguration;
+import org.apache.wink.server.internal.RequestProcessor;
+import org.apache.wink.server.internal.registry.ResourceRecord;
+import org.apache.wink.server.internal.servlet.RestServlet;
+
+/**
+ *
+ */
+public class TuscanyRESTServlet extends RestServlet {
+ private static final long serialVersionUID = 89997233133964915L;
+ private ExtensionPointRegistry registry;
+ private Class<?> resourceClass;
+ private boolean fixed;
+
+ public TuscanyRESTServlet(ExtensionPointRegistry registry, Class<?> resourceClass) {
+ super();
+ this.registry = registry;
+ this.resourceClass = resourceClass;
+ }
+
+ @Override
+ public DeploymentConfiguration getDeploymentConfiguration() throws ClassNotFoundException, InstantiationException,
+ IllegalAccessException, IOException {
+ DeploymentConfiguration config = super.getDeploymentConfiguration();
+
+ // [rfeng] FIXME: This is a hack to fool Apache wink to not remove the servlet path
+ config.setFilterConfig(new FilterConfig() {
+
+ public ServletContext getServletContext() {
+ return getServletContext();
+ }
+
+ public Enumeration getInitParameterNames() {
+ return getInitParameterNames();
+ }
+
+ public String getInitParameter(String arg0) {
+ return getInitParameter(arg0);
+ }
+
+ public String getFilterName() {
+ return getServletName();
+ }
+ });
+
+ ProvidersRegistry providers = config.getProvidersRegistry();
+ providers.addProvider(new DataBindingJAXRSReader(registry), 0.001, true);
+ providers.addProvider(new DataBindingJAXRSWriter(registry), 0.001, true);
+
+ return config;
+ }
+
+ private synchronized void fixMediaTypes(DeploymentConfiguration config) {
+ if (fixed) {
+ return;
+ }
+ // FIXME: A hacky workaround for https://issues.apache.org/jira/browse/TUSCANY-3572
+ ResourceRecord record = config.getResourceRegistry().getRecord(resourceClass);
+
+ for (MethodMetadata methodMetadata : record.getMetadata().getResourceMethods()) {
+ String method = methodMetadata.getHttpMethod();
+ if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
+ methodMetadata.addConsumes(MediaType.APPLICATION_OCTET_STREAM_TYPE);
+ methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
+ }
+ if (HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
+ methodMetadata.addProduces(MediaType.APPLICATION_OCTET_STREAM_TYPE);
+ methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
+ }
+ }
+ for (MethodMetadata methodMetadata : record.getMetadata().getSubResourceMethods()) {
+ String method = methodMetadata.getHttpMethod();
+ if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
+ methodMetadata.addConsumes(MediaType.APPLICATION_OCTET_STREAM_TYPE);
+ methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
+ }
+ if (HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
+ methodMetadata.addProduces(MediaType.APPLICATION_OCTET_STREAM_TYPE);
+ methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
+ }
+ }
+ fixed = true;
+ }
+
+ @Override
+ public RequestProcessor getRequestProcessor() {
+ RequestProcessor processor = super.getRequestProcessor();
+ // The 1st call returns null
+ if (processor != null) {
+ fixMediaTypes(processor.getConfiguration());
+ }
+ return processor;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java
new file mode 100644
index 0000000000..e5ce32328c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.wireformat.json.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.common.http.HTTPContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.json.JSONObject;
+
+/**
+ * JSON wire format Interceptor.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JSONWireFormatInterceptor implements Interceptor {
+ private Invoker next;
+ private RESTBinding binding;
+
+ public JSONWireFormatInterceptor(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.binding = (RESTBinding) endpoint.getBinding();
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Message invoke(Message msg) {
+ HTTPContext bindingContext = (HTTPContext) msg.getBindingContext();
+ if (bindingContext == null) {
+ return getNext().invoke(msg);
+ }
+
+
+ if (binding.getRequestWireFormat() instanceof JSONWireFormat) {
+ if( isPayloadSupported(bindingContext.getHttpRequest().getMethod()) && msg.getBody() != null) {
+ msg = invokeRequest(bindingContext, msg);
+ }
+ }
+
+ msg = getNext().invoke(msg);
+
+ //if it's oneway return back
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ if (binding.getResponseWireFormat() instanceof JSONWireFormat) {
+ msg = invokeResponse(bindingContext, msg);
+ }
+
+ return msg;
+ }
+
+ /**
+ * Handle any wire format specific transformations required for request data
+ * @param bindingContext the binding context (e.g. HTTP Request, Response objects)
+ * @param msg the invocation message
+ * @return processed request message
+ */
+ private Message invokeRequest(HTTPContext bindingContext, Message msg) {
+
+ // Decode using the charset in the request if it exists otherwise
+ // use UTF-8 as this is what all browser implementations use.
+ String charset = bindingContext.getHttpRequest().getCharacterEncoding();
+ if (charset == null) {
+ charset = "UTF-8";
+ }
+
+ try {
+ Object[] args = msg.getBody();
+ InputStream in = (InputStream) args[0];
+ String data = read(in, charset);
+ JSONObject jsonPayload = new JSONObject(data);
+ msg.setBody(new Object[]{jsonPayload});
+ } catch(Exception e) {
+ throw new RuntimeException("Unable to parse json paylod: " + msg.getBody().toString());
+ }
+
+ return msg;
+ }
+
+ /**
+ * Handle any wire format specific transformation required for the response data
+ * @param bindingContext the binding context (e.g. HTTP Request, Response objects)
+ * @param msg the response message
+ * @return processed response message
+ */
+ private Message invokeResponse(HTTPContext bindingContext, Message msg) {
+ return msg;
+ }
+
+
+ /**
+ * Check if HTTP Operation should support payload
+ * @param operation
+ * @return
+ */
+ private static boolean isPayloadSupported(String operation) {
+ boolean isGet = "get".equalsIgnoreCase(operation);
+ boolean isDelete = "delete".equalsIgnoreCase(operation);
+
+ return isGet == false && isDelete == false;
+ }
+
+ /**
+ * Read JSON payload from HTTP Request Body
+ * @param in
+ * @param charset
+ * @return
+ * @throws IOException
+ */
+ private static String read(InputStream in, String charset) throws IOException {
+ StringWriter sw = new StringWriter();
+ InputStreamReader reader = new InputStreamReader(in, "UTF-8");
+ char[] buf = new char[8192];
+ while (true) {
+ int size = reader.read(buf);
+ if (size < 0) {
+ break;
+ }
+ sw.write(buf, 0, size);
+ }
+ return sw.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFactory.java
new file mode 100644
index 0000000000..6b1bb6cca7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFactory.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.binding.rest.wireformat.json.provider;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * JSON wire format Provider Factory.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JSONWireFormatProviderFactory implements WireFormatProviderFactory<JSONWireFormat>{
+ private ExtensionPointRegistry extensionPoints;
+
+ public JSONWireFormatProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return new JSONWireFormatReferenceProvider(extensionPoints, endpointReference);
+ }
+
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) {
+ return new JSONWireFormatServiceProvider(extensionPoints, endpoint);
+ }
+
+ public Class<JSONWireFormat> getModelType() {
+ return JSONWireFormat.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatReferenceProvider.java
new file mode 100644
index 0000000000..830b02a3e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatReferenceProvider.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.sca.binding.rest.wireformat.json.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * JSON wire format Reference Provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JSONWireFormatReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpointReference endpointReference;
+
+ public JSONWireFormatReferenceProvider(ExtensionPointRegistry extensionPoints,RuntimeEndpointReference endpointReference ) {
+ this.extensionPoints = extensionPoints;
+ this.endpointReference = endpointReference;
+ }
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
+ return null;
+ }
+
+ public Interceptor createInterceptor() {
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java
new file mode 100644
index 0000000000..fcb311a105
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.wireformat.json.provider;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.provider.JAXRSHelper;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * JSON wire format service provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class JSONWireFormatServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpoint endpoint;
+
+ private InterfaceContract serviceContract;
+ private Binding binding;
+ private boolean jaxrs;
+
+ public JSONWireFormatServiceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.extensionPoints = extensionPoints;
+ this.endpoint = endpoint;
+ this.binding = endpoint.getBinding();
+ this.jaxrs = isJAXRSResource();
+ }
+
+ private boolean isJAXRSResource() {
+ Interface interfaze = endpoint.getComponentServiceInterfaceContract().getInterface();
+ if (interfaze instanceof JavaInterface) {
+ if (JAXRSHelper.isJAXRSResource(((JavaInterface)interfaze).getJavaClass())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
+ serviceContract = interfaceContract;
+
+ if (!jaxrs) {
+ boolean configureInput = binding.getRequestWireFormat() != null;
+ boolean configureOutput = binding.getRequestWireFormat() != null || binding.getResponseWireFormat() != null;
+
+ //set JSON databinding
+ setDataBinding(serviceContract.getInterface(), configureInput, configureOutput);
+ }
+
+ return serviceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ if (jaxrs) {
+ return null;
+ }
+ if( (binding.getRequestWireFormat() != null && binding.getRequestWireFormat() instanceof JSONWireFormat) ||
+ (binding.getResponseWireFormat() != null && binding.getResponseWireFormat() instanceof JSONWireFormat) ){
+ return new JSONWireFormatInterceptor(extensionPoints, endpoint);
+ }
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+
+ /**
+ * Utility method to reset data binding for the interface contract.
+ * We need to handle special case where :
+ * - global wire format for binding
+ * - wire format configured only for response
+ * @param interfaze
+ */
+ @SuppressWarnings({"deprecation", "unchecked"})
+ private void setDataBinding(Interface interfaze, boolean configureInput, boolean configureOutput) {
+ List<Operation> operations = interfaze.getOperations();
+ for (Operation operation : operations) {
+ // handle input types
+ if (configureInput) {
+ operation.setDataBinding(JSONDataBinding.NAME);
+ DataType<List<DataType>> inputType = operation.getInputType();
+ if (inputType != null) {
+ List<DataType> logical = inputType.getLogical();
+ for (DataType inArg : logical) {
+ if (!SimpleJavaDataBinding.NAME.equals(inArg.getDataBinding())) {
+ inArg.setDataBinding(JSONDataBinding.NAME);
+ }
+ }
+ }
+ }
+
+ // handle output types
+ if (configureOutput) {
+ DataType outputType = operation.getOutputType();
+ if (outputType != null) {
+ if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding())) {
+ outputType.setDataBinding(JSONDataBinding.NAME);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatInterceptor.java
new file mode 100644
index 0000000000..d5055b6701
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatInterceptor.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.wireformat.xml.provider;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+import org.apache.tuscany.sca.common.http.HTTPContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * JSON wire format Interceptor.
+ *
+ * @version $Rev$ $Date$
+*/
+public class XMLWireFormatInterceptor implements Interceptor {
+ private XMLInputFactory inputFactory;
+
+ private Invoker next;
+ private RESTBinding binding;
+
+ public XMLWireFormatInterceptor(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ inputFactory = factories.getFactory(XMLInputFactory.class);
+
+ this.binding = (RESTBinding) endpoint.getBinding();
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Message invoke(Message msg) {
+ HTTPContext bindingContext = (HTTPContext) msg.getBindingContext();
+ if (bindingContext == null) {
+ return getNext().invoke(msg);
+ }
+
+
+ if (binding.getRequestWireFormat() instanceof XMLWireFormat) {
+ if( isPayloadSupported(bindingContext.getHttpRequest().getMethod()) && msg.getBody() != null) {
+ msg = invokeRequest(bindingContext, msg);
+ }
+ }
+
+ msg = getNext().invoke(msg);
+
+ //if it's oneway return back
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ if (binding.getResponseWireFormat() instanceof XMLWireFormat) {
+ msg = invokeResponse(bindingContext, msg);
+ }
+
+ return msg;
+ }
+
+ /**
+ * Handle any wire format specific transformations required for request data
+ * @param bindingContext the binding context (e.g. HTTP Request, Response objects)
+ * @param msg the invocation message
+ * @return processed request message
+ */
+ private Message invokeRequest(HTTPContext bindingContext, Message msg) {
+ // Decode using the charset in the request if it exists otherwise
+ // use UTF-8 as this is what all browser implementations use.
+ String charset = bindingContext.getHttpRequest().getCharacterEncoding();
+ if (charset == null) {
+ charset = "UTF-8";
+ }
+
+ try {
+ if(msg.getBody() != null) {
+ Object[] args = msg.getBody();
+ InputStream data = (InputStream) args[0];
+ XMLStreamReader xmlPayload = inputFactory.createXMLStreamReader(data, charset);
+ msg.setBody(new Object[]{xmlPayload});
+ }
+ } catch(Exception e) {
+ throw new RuntimeException("Unable to process xml paylod: " + msg.getBody().toString());
+ }
+
+ return msg;
+ }
+
+
+ /**
+ * Handle any wire format specific transformation required for the response data
+ * @param bindingContext the binding context (e.g. HTTP Request, Response objects)
+ * @param msg the response message
+ * @return processed response message
+ */
+ private Message invokeResponse(HTTPContext bindingContext, Message msg) {
+ return msg;
+ }
+
+ /**
+ * Check if HTTP Operation should support payload
+ * @param operation
+ * @return
+ */
+ private static boolean isPayloadSupported(String operation) {
+ boolean isGet = "get".equalsIgnoreCase(operation);
+ boolean isDelete = "delete".equalsIgnoreCase(operation);
+
+ return isGet == false && isDelete == false;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFactory.java
new file mode 100644
index 0000000000..33900b3de9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFactory.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.binding.rest.wireformat.xml.provider;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * XML wire format Provider Factory.
+ *
+ * @version $Rev$ $Date$
+*/
+public class XMLWireFormatProviderFactory implements WireFormatProviderFactory<XMLWireFormat>{
+ private ExtensionPointRegistry extensionPoints;
+
+ public XMLWireFormatProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return new XMLWireFormatReferenceProvider(extensionPoints, endpointReference);
+ }
+
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint) {
+ return new XMLWireFormatServiceProvider(extensionPoints, endpoint);
+ }
+
+ public Class<XMLWireFormat> getModelType() {
+ return XMLWireFormat.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatReferenceProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatReferenceProvider.java
new file mode 100644
index 0000000000..c9e0ac4578
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatReferenceProvider.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.sca.binding.rest.wireformat.xml.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * XML wire format Reference Provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class XMLWireFormatReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpointReference endpointReference;
+
+ public XMLWireFormatReferenceProvider(ExtensionPointRegistry extensionPoints,RuntimeEndpointReference endpointReference ) {
+ this.extensionPoints = extensionPoints;
+ this.endpointReference = endpointReference;
+ }
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
+ return null;
+ }
+
+ public Interceptor createInterceptor() {
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java
new file mode 100644
index 0000000000..32d718b509
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.wireformat.xml.provider;
+
+import java.util.List;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.provider.JAXRSHelper;
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
+import org.apache.tuscany.sca.databinding.xml.XMLStringDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * XML wire format service provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class XMLWireFormatServiceProvider implements WireFormatProvider {
+ private static final String DATABABINDING = XMLStreamReader.class.getName();
+
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpoint endpoint;
+
+ private InterfaceContract serviceContract;
+ private Binding binding;
+
+ private boolean jaxrs;
+
+ public XMLWireFormatServiceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.extensionPoints = extensionPoints;
+ this.endpoint = endpoint;
+ this.binding = endpoint.getBinding();
+ this.jaxrs = isJAXRSResource();
+ }
+
+ private boolean isJAXRSResource() {
+ Interface interfaze = endpoint.getComponentServiceInterfaceContract().getInterface();
+ if (interfaze instanceof JavaInterface) {
+ if (JAXRSHelper.isJAXRSResource(((JavaInterface)interfaze).getJavaClass())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
+ serviceContract = interfaceContract;
+
+ if (!jaxrs) {
+ boolean configureInput = binding.getRequestWireFormat() != null;
+ boolean configureOutput = binding.getRequestWireFormat() != null || binding.getResponseWireFormat() != null;
+
+ //set XML databinding
+ setDataBinding(serviceContract.getInterface(), configureInput, configureOutput);
+ }
+
+ return serviceContract;
+ }
+
+ public Interceptor createInterceptor() {
+ if (jaxrs) {
+ return null;
+ }
+
+ if( (binding.getRequestWireFormat() != null && binding.getRequestWireFormat() instanceof XMLWireFormat) ||
+ (binding.getResponseWireFormat() != null && binding.getResponseWireFormat() instanceof XMLWireFormat) ){
+ return new XMLWireFormatInterceptor(extensionPoints, endpoint);
+ }
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+
+ /**
+ * Utility method to reset data binding for the interface contract
+ * @param interfaze
+ */
+ @SuppressWarnings({"deprecation", "unchecked"})
+ private void setDataBinding(Interface interfaze, boolean configureInput, boolean configureOutput) {
+ List<Operation> operations = interfaze.getOperations();
+ for (Operation operation : operations) {
+ // handle input types
+ if (configureInput) {
+ operation.setDataBinding(DATABABINDING);
+ DataType<List<DataType>> inputType = operation.getInputType();
+ if (inputType != null) {
+ List<DataType> logical = inputType.getLogical();
+ for (DataType inArg : logical) {
+ if (!SimpleJavaDataBinding.NAME.equals(inArg.getDataBinding())) {
+ inArg.setDataBinding(DATABABINDING);
+ }
+ }
+ }
+ }
+
+ // handle output types
+ if (configureOutput) {
+ DataType outputType = operation.getOutputType();
+ if (outputType != null) {
+ outputType.setDataBinding(XMLStringDataBinding.NAME);
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..4a682c1cb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.rest.provider.RESTBindingProviderFactory;model=org.apache.tuscany.sca.binding.rest.RESTBinding
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
new file mode 100644
index 0000000000..be5e3ab636
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
@@ -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 wire format provider factory
+org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.provider.JAXRSOperationSelectorProviderFactory;model=org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector
+org.apache.tuscany.sca.binding.rest.operationselector.rpc.provider.RPCOperationSelectorProviderFactory;model=org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
new file mode 100644
index 0000000000..80062349ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
@@ -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 wire format provider factory
+org.apache.tuscany.sca.binding.rest.wireformat.json.provider.JSONWireFormatProviderFactory;model=org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat
+org.apache.tuscany.sca.binding.rest.wireformat.xml.provider.XMLWireFormatProviderFactory;model=org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/NotModifiedException.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/NotModifiedException.java
new file mode 100644
index 0000000000..49e7d67a76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/NotModifiedException.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.binding.rest;
+
+/**
+ * Indicates that a resource was not modified.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NotModifiedException extends Exception {
+ private static final long serialVersionUID = -5046027674128627383L;
+
+ public NotModifiedException() {
+ }
+
+ public NotModifiedException(String message) {
+ super(message);
+ }
+
+ public NotModifiedException(Throwable cause) {
+ super(cause);
+ }
+
+ public NotModifiedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/PreconditionFailedException.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/PreconditionFailedException.java
new file mode 100644
index 0000000000..1463e1a5db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/PreconditionFailedException.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.binding.rest;
+
+/**
+ * Indicates that a resource was not modified.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PreconditionFailedException extends Exception {
+ private static final long serialVersionUID = -5046027674128627383L;
+
+ public PreconditionFailedException() {
+ }
+
+ public PreconditionFailedException(String message) {
+ super(message);
+ }
+
+ public PreconditionFailedException(Throwable cause) {
+ super(cause);
+ }
+
+ public PreconditionFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/RESTBindingCacheTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/RESTBindingCacheTestCase.java
new file mode 100644
index 0000000000..4db7fd64dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/RESTBindingCacheTestCase.java
@@ -0,0 +1,903 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * HTTP binding unit tests.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingCacheTestCase {
+ // RFC 822 date time
+ protected static final SimpleDateFormat dateFormat = new SimpleDateFormat(
+ "EEE, dd MMM yyyy HH:mm:ss Z");
+
+ // Request with no predicates in header.
+ private static final String REQUEST1 = "{0} /httpbinding/{1} HTTP/1.0\n"
+ + "Host: localhost\n" + "Content-Type: text/xml\n"
+ + "Connection: close\n" + "Content-Length: {2}" + "\n\n{3}";
+
+ // Request with predicates in header
+ private static final String REQUEST2 = "{0} /httpbinding/{1} HTTP/1.0\n"
+ + "Host: localhost\n" + "Content-Type: text/xml\n" + "{2}: {3}\n" // predicate (If-Match, If-None-Match, If-Modified-Since, If-NotModified-Since): value (date or ETag)
+ + "Connection: close\n" + "Content-Length: {4}" + "\n\n{5}";
+
+ private static final int HTTP_PORT = 8085;
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(RESTBindingCacheTestCase.class);
+ node = NodeFactory.newInstance().createNode("testCache.composite", new Contribution("test", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testGet() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST1, "GET", index, content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfModifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)),
+ content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfModifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfUnmodifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Unmodified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfUnmodifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Unmodified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfNoneMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalGetIfNoneMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "GET", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testDelete() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST1, "DELETE", index,
+ content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfModifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfModifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfUnmodifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Unmodified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfUnmodifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Unmodified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfNoneMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalDeleteIfNoneMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "DELETE", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("deleted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testPost() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST1, "POST", index, content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfModifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Modified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return code 200 OK
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfModifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfUnmodifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Unmodified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return code 200 OK
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfUnmodifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Unmodified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-Match", "eTagMatch", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return code 200 OK.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat
+ .format(REQUEST2, "POST", index, "If-Match", "eTagNoneMatch",
+ content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfNoneMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-None-Match", "eTagNoneMatch", content.getBytes().length,
+ content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return code 200 OK
+ Assert.assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPostIfNoneMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "POST", index,
+ "If-None-Match", "eTagMatch", content.getBytes().length,
+ content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("posted item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testPut() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST1, "PUT", index, content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfModifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfModifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Modified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfUnmodifiedNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Unmodified-Since", dateFormat.format(new Date()), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 304 Not Modified.
+ // assertTrue(document.indexOf("HTTP/1.1 304") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfUnmodifiedPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Unmodified-Since", dateFormat.format(new Date(0)), content
+ .getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfNoneMatchNegative() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 1;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ Assert.assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 precondition failed.
+ // assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Test invoking a conditional method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testConditionalPutIfNoneMatchPositive() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String content = "";
+ String request = MessageFormat.format(REQUEST2, "PUT", index,
+ "If-None-Match", "eTagXXX", content.getBytes().length, content);
+ os.write(request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ // Should return item
+ // assertTrue(document.indexOf("updated item=" + index) != -1);
+ // Should return code 412 PreconditionFailed.
+ Assert.assertTrue(document.indexOf("HTTP/1.1 412") != -1);
+ }
+
+ /**
+ * Read response stream from the given socket.
+ * @param socket
+ * @return
+ * @throws IOException
+ */
+ private static String read(Socket socket) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(socket
+ .getInputStream()));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/RESTBindingTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/RESTBindingTestCase.java
new file mode 100644
index 0000000000..e08069f479
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/RESTBindingTestCase.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.text.MessageFormat;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * HTTP binding unit tests.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingTestCase {
+
+ private static final String REQUEST1_HEADER =
+ "GET /httpservice/test HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST1_CONTENT = "";
+ private static final String REQUEST1 =
+ REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT;
+
+ private static final String REQUEST2_HEADER =
+ "GET /webcontent/test.html HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST2_CONTENT = "";
+ private static final String REQUEST2 =
+ REQUEST2_HEADER + REQUEST2_CONTENT.getBytes().length + "\n\n" + REQUEST2_CONTENT;
+
+ private static final String REQUEST3_HEADER =
+ "GET /httpget/{0} HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST3_CONTENT = "";
+ private static final String REQUEST3 =
+ REQUEST3_HEADER + REQUEST3_CONTENT.getBytes().length + "\n\n" + REQUEST3_CONTENT;
+
+ private static final int HTTP_PORT = 8085;
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(RESTBindingCacheTestCase.class);
+ node = NodeFactory.newInstance().createNode("test.composite", new Contribution("test", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ /**
+ * Test invoking a POJO service implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testServiceImplementation() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("<body><p>hey</body>") != -1);
+ }
+
+ /**
+ * Test invoking a POJO get method implementation using the HTTP binding.
+ * @throws Exception
+ */
+ @Test
+ public void testGetImplementation() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ int index = 0;
+ String request = MessageFormat.format( REQUEST3, index );
+ os.write( request.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("<body><p>item=" + index) != -1);
+ }
+
+ /**
+ * Test getting a static resource provided using the HTTP binding.
+ * @throws Exception
+ */
+ @Ignore("Implementation resource not available")
+ public void testStaticResourceImplementation() throws Exception {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST2.getBytes());
+ os.flush();
+
+ String document = read(client);
+ Assert.assertTrue(document.indexOf("<body><p>hello</body>") != -1);
+ }
+
+ /**
+ * Read response stream from the given socket.
+ * @param socket
+ * @return
+ * @throws IOException
+ */
+ private static String read(Socket socket) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestBindingCacheImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestBindingCacheImpl.java
new file mode 100644
index 0000000000..5c5e4db8ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestBindingCacheImpl.java
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Date;
+
+import org.apache.tuscany.sca.common.http.HTTPCacheContext;
+
+/**
+ * Test service implementation that implements a various conditional HTTP
+ * methods. For testing, the id==0 items are very old (Date(0)), not modified,
+ * and always match ETags and the id==1 items are always brand new (Date()),
+ * modified, and never match ETags. Using these ids one can test the
+ * LastModified and ETag headers of the requests.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestBindingCacheImpl {
+
+ /**
+ * Implements the HTTP get method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream get(String id) {
+ return new ByteArrayInputStream(("<html><body><p>item=" + id + "</body></html>").getBytes());
+ }
+
+ /**
+ * Implements the HTTP conditional get method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream conditionalGet(String id, HTTPCacheContext cacheContext) throws NotModifiedException,
+ PreconditionFailedException {
+
+ if (cacheContext != null) {
+ if (cacheContext.ifModifiedSince) {
+ if ((id.equals("1")) && (0 > cacheContext.lastModifiedDate.compareTo(new Date())))
+ throw new NotModifiedException("item 1 was modified on " + new Date());
+ }
+ if (cacheContext.ifUnmodifiedSince) {
+ if ((id.equals("0")) && (0 > cacheContext.lastModifiedDate.compareTo(new Date())))
+ throw new PreconditionFailedException("item 0 was modified on " + new Date(0));
+ }
+ if (cacheContext.ifMatch) {
+ if (id.equals("1"))
+ throw new PreconditionFailedException("item 1 eTag does not match " + cacheContext.getETag());
+ }
+ if (cacheContext.ifNoneMatch) {
+ if (id.equals("0"))
+ throw new PreconditionFailedException("item 0 eTag matches " + cacheContext.getETag());
+ }
+ }
+ return new ByteArrayInputStream(("<html><body><p>item=" + id + "</body></html>").getBytes());
+ }
+
+ /**
+ * Implements the HTTP delete method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream delete(String id) {
+ return new ByteArrayInputStream(("<html><body><p>deleted item=" + id + "</body></html>").getBytes());
+ }
+
+ /**
+ * Implements the HTTP conditional delete method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream conditionalDelete(String id, HTTPCacheContext cacheContext) throws NotModifiedException,
+ PreconditionFailedException {
+
+ if (cacheContext != null) {
+ if (cacheContext.ifModifiedSince) {
+ if ((id.equals("1")) && (0 > cacheContext.lastModifiedDate.compareTo(new Date())))
+ throw new NotModifiedException("item 1 was modified on " + new Date());
+ }
+ if (cacheContext.ifUnmodifiedSince) {
+ if ((id.equals("0")) && (0 > cacheContext.lastModifiedDate.compareTo(new Date())))
+ throw new PreconditionFailedException("item 0 was modified on " + new Date(0));
+ }
+ if (cacheContext.ifMatch) {
+ if (id.equals("1"))
+ throw new PreconditionFailedException("item 1 eTag does not match " + cacheContext.getETag());
+ }
+ if (cacheContext.ifNoneMatch) {
+ if (id.equals("0"))
+ throw new PreconditionFailedException("item 0 eTag matches " + cacheContext.getETag());
+ }
+ }
+ return new ByteArrayInputStream(("<html><body><p>deleted item=" + id + "</body></html>").getBytes());
+ }
+
+ /**
+ * Implements the HTTP post method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream post() {
+ int id = (new java.util.Random()).nextInt(Integer.MAX_VALUE);
+ return new ByteArrayInputStream(("<html><body><p>posted item=" + id + "</body></html>").getBytes());
+ }
+
+ /**
+ * Implements the HTTP conditional post method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public HTTPCacheContext conditionalPost(HTTPCacheContext cacheContext) throws NotModifiedException,
+ PreconditionFailedException {
+ String id = "" + (new java.util.Random()).nextInt(Integer.MAX_VALUE);
+
+ if (cacheContext != null) {
+ if (cacheContext.ifModifiedSince) {
+ if (0 >= cacheContext.lastModifiedDate.compareTo(new Date(0)))
+ throw new NotModifiedException("item was modified on " + new Date());
+ }
+ if (cacheContext.ifUnmodifiedSince) {
+ if ((0 >= cacheContext.lastModifiedDate.compareTo(new Date(0))))
+ throw new PreconditionFailedException("item was modified on " + new Date(0));
+ }
+ if (cacheContext.ifMatch) {
+ if (cacheContext.getETag().equalsIgnoreCase("ETagNoneMatch"))
+ throw new PreconditionFailedException("item eTag does not match " + cacheContext.getETag());
+ }
+ if (cacheContext.ifNoneMatch) {
+ if (cacheContext.getETag().equalsIgnoreCase("ETagMatch"))
+ throw new PreconditionFailedException("item eTag matches " + cacheContext.getETag());
+ }
+ }
+
+ // Return the ETag and LastModfied fields by serialize to a byte array
+ HTTPCacheContext returnContext = new HTTPCacheContext();
+ returnContext.setETag("ETag" + (new java.util.Random()).nextInt(Integer.MAX_VALUE));
+ returnContext.setLastModified(new Date());
+ return returnContext;
+ }
+
+ /**
+ * Implements the HTTP update/put method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream put(String id) {
+ return new ByteArrayInputStream(("<html><body><p>updated item=" + id + "</body></html>").getBytes());
+ }
+
+ /**
+ * Implements the HTTP conditional update/put method of the collection implementation.
+ * @param id
+ * @return
+ */
+ public InputStream conditionalPut(String id, HTTPCacheContext cacheContext) throws NotModifiedException,
+ PreconditionFailedException {
+
+ if (cacheContext != null) {
+ if (cacheContext.ifModifiedSince) {
+ if ((id.equals("1")) && (0 > cacheContext.lastModifiedDate.compareTo(new Date())))
+ throw new NotModifiedException("item 1 was modified on " + new Date());
+ }
+ if (cacheContext.ifUnmodifiedSince) {
+ if ((id.equals("0")) && (0 > cacheContext.lastModifiedDate.compareTo(new Date())))
+ throw new PreconditionFailedException("item 0 was modified on " + new Date(0));
+ }
+ if (cacheContext.ifMatch) {
+ if (id.equals("1"))
+ throw new PreconditionFailedException("item 1 eTag does not match " + cacheContext.getETag());
+ }
+ if (cacheContext.ifNoneMatch) {
+ if (id.equals("0"))
+ throw new PreconditionFailedException("item 0 eTag matches " + cacheContext.getETag());
+ }
+ }
+
+ return new ByteArrayInputStream(("<html><body><p>updated item=" + id + "</body></html>").getBytes());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestGetImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestGetImpl.java
new file mode 100644
index 0000000000..4cb1bce73f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestGetImpl.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.sca.binding.rest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+/**
+ * Test service implementation that implements a get method.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestGetImpl {
+
+ public InputStream get(String id) {
+ return new ByteArrayInputStream(("<html><body><p>item=" + id + "</body></html>").getBytes());
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestServiceImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestServiceImpl.java
new file mode 100644
index 0000000000..6b21d6094f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/TestServiceImpl.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.binding.rest;
+
+import java.io.IOException;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Test service implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+
+@Service(Servlet.class)
+public class TestServiceImpl implements Servlet {
+
+ public void init(ServletConfig config) throws ServletException {
+ }
+
+ public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ //HttpServletResponse httpResponse = (HttpServletResponse)response;
+ response.getOutputStream().print("<html><body><p>hey</body></html>");
+ }
+
+ public void destroy() {
+ }
+
+ public ServletConfig getServletConfig() {
+ return null;
+ }
+
+ public String getServletInfo() {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java
new file mode 100644
index 0000000000..a96f8ebb03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.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.sca.binding.rest.rpc;
+
+import java.net.Socket;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+public class EchoServiceTestCase {
+ private static final String SERVICE_URL_JSON = "http://localhost:8085/EchoService/json";
+ private static final String SERVICE_URL_XML = "http://localhost:8085/EchoService/xml";
+
+ private static final String XML_RESPONSE = "" +
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<return xmlns:ns2=\"http://echo.services/\" "+
+ "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" " +
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
+ "xsi:type=\"xs:string\">Hello RPC</return>";
+
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(EchoServiceTestCase.class);
+ node = NodeFactory.newInstance().createNode("echo.composite", new Contribution("echo", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if(node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testPing() throws Exception {
+ new Socket("127.0.0.1", 8085);
+ // System.in.read();
+ }
+
+ @Test
+ public void testJSONRPCGetOperationWithString() throws Exception {
+ String queryString = "?method=echo&msg=Hello RPC";
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL_JSON + queryString);
+ request.setHeaderField("Content-Type", "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals("Hello RPC", response.getText());
+ }
+
+ @Test
+ public void testJSONRPCGetOperationWithInt() throws Exception {
+ String queryString = "?method=echoInt&param=1000";
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL_JSON + queryString);
+ request.setHeaderField("Content-Type", "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals("1000", response.getText());
+ }
+
+ @Test
+ public void testRPCGetArrayOperationWithString() throws Exception {
+ String queryString = "?method=echoArrayString&msgArray=Hello RPC1&msgArray=Hello RPC2";
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL_JSON + queryString);
+ request.setHeaderField("Content-Type", "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals("[\"Hello RPC1\",\"Hello RPC2\"]", response.getText());
+ }
+
+ @Test
+ public void testRPCGetArrayOperationWithInt() throws Exception {
+ String queryString = "?method=echoArrayInt&intArray=1000&intArray=2000";
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL_JSON + queryString);
+ request.setHeaderField("Content-Type", "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals("[1000,2000]", response.getText());
+ }
+
+
+ @Test
+ public void testXMLRPCGetOperation() throws Exception {
+ String queryString = "?method=echo&msg=Hello RPC";
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL_XML + queryString);
+ request.setHeaderField("Content-Type", "application/xml");
+ WebResponse response = wc.getResource(request);
+
+ //System.out.println("Expected>>" + XML_RESPONSE);
+ //System.out.println("Received>>" + response.getText());
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals(XML_RESPONSE, response.getText());
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java
new file mode 100644
index 0000000000..2ca662ec4e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.wireformat.binary;
+
+import java.io.ByteArrayInputStream;
+import java.net.Socket;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.PutMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+public class BinaryServiceTestCase {
+ private static final String SERVICE_URL = "http://localhost:8085/Binary";
+
+ private static final String CONTENT = "ABCDefgh";
+ private static final String UPDATED_CONTENT = "abcdEFGH";
+
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(BinaryServiceTestCase.class);
+ node = NodeFactory.newInstance().createNode("binary.composite", new Contribution("binary", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testPing() throws Exception {
+ new Socket("127.0.0.1", 8085);
+ //System.in.read();
+ }
+
+ @Test
+ public void testMethods() throws Exception {
+ WebConversation wc = new WebConversation();
+
+ // Create content
+ WebRequest request =
+ new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(CONTENT.getBytes("UTF-8")),
+ "application/octet-stream");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(204, response.getResponseCode());
+
+ // Read the content
+ request = new GetMethodWebRequest(SERVICE_URL);
+ response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals(CONTENT, response.getText());
+
+ request =
+ new PutMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(UPDATED_CONTENT.getBytes("UTF-8")),
+ "application/octet-stream");
+ response = wc.getResource(request);
+
+ Assert.assertEquals(204, response.getResponseCode());
+
+ //read new results and expect to get new item back in the response
+ request = new GetMethodWebRequest(SERVICE_URL);
+ response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals(UPDATED_CONTENT, response.getText());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java
new file mode 100644
index 0000000000..2aa59af508
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.wireformat.json;
+
+import java.io.ByteArrayInputStream;
+import java.net.Socket;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+public class CatalogServiceTestCase {
+ private static final String SERVICE_URL = "http://localhost:8085/Catalog";
+
+ private static final String GET_RESPONSE = "{\"items\":[{\"price\":\"$1.55\",\"name\":\"Pear\"},{\"price\":\"$2.99\",\"name\":\"Apple\"},{\"price\":\"$3.55\",\"name\":\"Orange\"}]}";
+ private static final String NEW_ITEM = "{\"price\":\"$4.35\",\"name\":\"Grape\"}\"";
+ private static final String GET_NEW_RESPONSE = "{\"items\":[{\"price\":\"$1.55\",\"name\":\"Pear\"},{\"price\":\"$2.99\",\"name\":\"Apple\"},{\"price\":\"$3.55\",\"name\":\"Orange\"},{\"price\":\"$4.35\",\"name\":\"Grape\"}]}";
+ private static final String UPDATED_ITEM = "{\"price\":\"$1.35\",\"name\":\"Grape\"}\"";
+ private static final String GET_UPDATED_RESPONSE = "{\"items\":[{\"price\":\"$1.55\",\"name\":\"Pear\"},{\"price\":\"$2.99\",\"name\":\"Apple\"},{\"price\":\"$3.55\",\"name\":\"Orange\"},{\"price\":\"$1.35\",\"name\":\"Grape\"}]}";
+
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(CatalogServiceTestCase.class);
+ node = NodeFactory.newInstance().createNode("store.composite", new Contribution("catalog", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if(node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testPing() throws Exception {
+ new Socket("127.0.0.1", 8085);
+ //System.in.read();
+ }
+
+ @Test
+ public void testGetInvocation() throws Exception {
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL);
+ request.setHeaderField("Content-Type", "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertNotNull(response.getText());
+ Assert.assertTrue(validateJsonResponse(GET_RESPONSE,response.getText()));
+ }
+
+
+ @Test
+ public void testPostInvocation() throws Exception {
+ //Add new item to catalog
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(NEW_ITEM.getBytes("UTF-8")),"application/json");
+ request.setHeaderField("Content-Type", "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(204, response.getResponseCode());
+
+ //read new results and expect to get new item back in the response
+ request = new GetMethodWebRequest(SERVICE_URL);
+ request.setHeaderField("Content-Type", "application/json");
+ response = wc.getResource(request);
+
+ //for debug purposes
+ //System.out.println(">>>" + GET_UPDATED_RESPONSE);
+ //System.out.println(">>>" + response.getText());
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertNotNull(response.getText());
+ Assert.assertTrue(validateJsonResponse(GET_NEW_RESPONSE,response.getText()));
+ }
+
+ @Test
+ public void testPutInvocation() throws Exception {
+ //Add new item to catalog
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(UPDATED_ITEM.getBytes("UTF-8")),"application/json");
+ request.setHeaderField("Content-Type", "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(204, response.getResponseCode());
+
+ //read new results and expect to get new item back in the response
+ request = new GetMethodWebRequest(SERVICE_URL);
+ request.setHeaderField("Content-Type", "application/json");
+ response = wc.getResource(request);
+
+ //for debug purposes
+ //System.out.println(">>>" + GET_UPDATED_RESPONSE);
+ //System.out.println(">>>" + response.getText());
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertNotNull(response.getText());
+ Assert.assertTrue(validateJsonResponse(GET_UPDATED_RESPONSE,response.getText()));
+ }
+
+
+ private boolean validateJsonResponse(String expected, String actual) throws JSONException {
+ JSONObject jsonExpected = new JSONObject(expected);
+ JSONObject jsonActual = new JSONObject(actual);
+
+ if(jsonExpected.getJSONArray("items").length() != jsonActual.getJSONArray("items").length()) {
+ return false;
+ }
+
+ return true;
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/CustomerServiceTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/CustomerServiceTestCase.java
new file mode 100644
index 0000000000..a7cbda20f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/CustomerServiceTestCase.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.wireformat.xml;
+
+import java.io.ByteArrayInputStream;
+import java.net.Socket;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+public class CustomerServiceTestCase {
+ private static final String SERVICE_URL = "http://localhost:8085/Customer";
+
+ private static final String GET_RESPONSE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Customer xmlns:ns2=\"http://tuscany.apache.org/xmlns/sca/databinding/jaxb/1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"customer\"><email>john@domain.com</email><id>John</id><name>John</name></Customer>";
+ private static final String UPDATED_ITEM = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Customer xmlns:ns2=\"http://customer.services/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"customer\"><email>john@updated-domain.com</email><id>John</id><name>John</name></Customer>";
+ private static final String GET_UPDATED_RESPONSE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Customer xmlns:ns2=\"http://tuscany.apache.org/xmlns/sca/databinding/jaxb/1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"customer\"><email>john@updated-domain.com</email><id>John</id><name>John</name></Customer>";
+
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(CustomerServiceTestCase.class);
+ node = NodeFactory.newInstance().createNode("customer.composite", new Contribution("customer", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if(node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testPing() throws Exception {
+ new Socket("127.0.0.1", 8085);
+ //System.in.read();
+ }
+
+ @Test
+ public void testGetInvocation() throws Exception {
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL);
+ request.setHeaderField("Content-Type", "application/xml");
+ WebResponse response = wc.getResource(request);
+
+ //for debug purposes
+ //list the response headers
+ //for(String headerField : response.getHeaderFieldNames()) {
+ // System.out.println(">>> Header:" + headerField + " - " + response.getHeaderField(headerField));
+ //}
+
+ //for debug purposes
+ //System.out.println(">>>" + GET_RESPONSE);
+ //System.out.println(">>>" + response.getText());
+
+ Assert.assertEquals(200, response.getResponseCode());
+// Assert.assertEquals("no-cache", response.getHeaderField("Cache-Control"));
+// Assert.assertEquals("tuscany", response.getHeaderField("X-Tuscany"));
+ Assert.assertEquals(GET_RESPONSE, response.getText());
+
+ }
+
+ @Test
+ public void testPutInvocation() throws Exception {
+ //Add new item to catalog
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(UPDATED_ITEM.getBytes("UTF-8")),"application/xml");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(201, response.getResponseCode());
+ System.out.println(response.getHeaderField("Location"));
+
+ //read new results and expect to get new item back in the response
+ request = new GetMethodWebRequest(SERVICE_URL);
+ request.setHeaderField("Content-Type", "application/xml");
+ response = wc.getResource(request);
+
+ //for debug purposes
+ //System.out.println(">>>" + GET_UPDATED_RESPONSE);
+ //System.out.println(">>>" + response.getText());
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals(GET_UPDATED_RESPONSE, response.getText());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/binary/BinaryService.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/binary/BinaryService.java
new file mode 100644
index 0000000000..4749383a0c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/binary/BinaryService.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package services.binary;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataSource;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface BinaryService {
+ @GET
+ InputStream get();
+
+ @PUT
+ void update(InputStream is) throws IOException;
+
+ @POST
+ void create(DataSource dataSource) throws IOException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/binary/BinaryServiceImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/binary/BinaryServiceImpl.java
new file mode 100644
index 0000000000..aefbf64504
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/binary/BinaryServiceImpl.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 services.binary;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataSource;
+
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ *
+ */
+@Scope("COMPOSITE")
+public class BinaryServiceImpl implements BinaryService {
+ private byte[] content;
+ private int length;
+
+ public void create(DataSource dataSource) throws IOException {
+ content = new byte[10240];
+ InputStream is = dataSource.getInputStream();
+ length = is.read(content);
+ System.out.println("Content received: " + length);
+ }
+
+ public InputStream get() {
+ byte[] bytes = new byte[length];
+ System.arraycopy(content, 0, bytes, 0, length);
+ System.out.println("Content sent: " + length);
+ return new ByteArrayInputStream(bytes);
+ }
+
+ public void update(InputStream is) throws IOException {
+ length = is.read(content);
+ System.out.println("Content updated: " + length);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/Customer.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/Customer.java
new file mode 100644
index 0000000000..08506ebd48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/Customer.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 services.customer;
+
+
+/**
+ * Customer data
+ */
+public class Customer {
+ private String id;
+ private String email;
+ private String name;
+
+ public Customer() {
+ super();
+ }
+
+ public Customer(String id, String name, String email) {
+ super();
+ this.id = id;
+ this.email = email;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return "id: " + id + " name: " + name + " e-mail: " + email;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/CustomerService.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/CustomerService.java
new file mode 100644
index 0000000000..94ebc1e1b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/CustomerService.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 services.customer;
+
+import javax.jws.WebResult;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.core.Response;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CustomerService {
+
+ @GET
+ @WebResult(name = "Customer", targetNamespace = "")
+ Customer get();
+
+ @GET
+ @WebResult(name = "Customer", targetNamespace = "")
+ Response getResponse();
+
+ @POST
+ Response addCustomer(Customer customer);
+
+ @PUT
+ void updateCustomer(Customer customer);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/CustomerServiceImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/CustomerServiceImpl.java
new file mode 100644
index 0000000000..22e63e0f91
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/customer/CustomerServiceImpl.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services.customer;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class CustomerServiceImpl implements CustomerService {
+ private Map<String, Customer> customers = new HashMap<String, Customer>();
+
+ @Init
+ public void init() {
+ customers.put("John", new Customer("John", "John", "john@domain.com"));
+ }
+
+ public Customer get() {
+ return customers.values().iterator().next();
+ }
+
+ public Response getResponse() {
+ return Response.ok(get()).build();
+ }
+
+ public Response addCustomer(Customer customer) {
+ customers.put(customer.getName(), customer);
+ return Response.created(URI.create("/001")).build();
+ }
+
+ public void updateCustomer(Customer customer) {
+ if(customers.get(customer.getName()) != null) {
+ customers.put(customer.getName(), customer);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java
new file mode 100644
index 0000000000..b93ff0838b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/echo/Echo.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 services.echo;
+
+import javax.ws.rs.QueryParam;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Interface of our sample JSONRPC service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Echo {
+
+ String echo(@QueryParam("msg") String msg);
+
+ int echoInt(@QueryParam("param") int param);
+
+ String [] echoArrayString(@QueryParam("msgArray") String[] stringArray);
+
+ int [] echoArrayInt(@QueryParam("intArray") int[] intArray);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java
new file mode 100644
index 0000000000..6bc22bd41a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package services.echo;
+
+
+/**
+ * A simple client component that uses a reference with an JSONRPC binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoImpl implements Echo {
+
+ public String echo(String msg) {
+ return msg;
+ }
+
+ public int echoInt(int param) {
+ int value = param;
+ return value;
+ }
+
+ public String[] echoArrayString(String[] stringArray) {
+ return stringArray;
+ }
+
+ public int[] echoArrayInt(int[] intArray) {
+ return intArray;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java
new file mode 100644
index 0000000000..7e579c6aba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services.store;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+public interface Catalog {
+
+ @GET
+ Items getItem();
+
+ @GET
+ @Path("{id}")
+ Item getItemById(@PathParam("id") String itemId);
+
+ @POST
+ void addItem(Item item);
+
+ @PUT
+ void updateItem(Item item);
+
+ @DELETE
+ @Path("{id}")
+ void deleteItem(@PathParam("id") String itemId);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverter.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverter.java
new file mode 100644
index 0000000000..45f8949633
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverter.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services.store;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CurrencyConverter {
+ public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount);
+
+ public String getCurrencySymbol(String currencyCode);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverterImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverterImpl.java
new file mode 100644
index 0000000000..9956e207e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverterImpl.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 services.store;
+
+public class CurrencyConverterImpl implements CurrencyConverter {
+ public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) {
+ if (toCurrencyCode.equals("USD"))
+ return amount;
+ else if (toCurrencyCode.equals("EUR"))
+ return ((double)Math.round(amount * 0.7256 * 100)) /100;
+ return 0;
+ }
+
+ public String getCurrencySymbol(String currencyCode) {
+ if (currencyCode.equals("USD"))
+ return "$";
+ else if (currencyCode.equals("EUR"))
+ return "E"; //"€";
+ return "?";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java
new file mode 100644
index 0000000000..afe3d3863e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.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 services.store;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class FruitsCatalogImpl implements Catalog {
+
+ @Property
+ public String currencyCode = "USD";
+
+ @Reference
+ public CurrencyConverter currencyConverter;
+
+ private Map<String, Item> catalog = new HashMap<String, Item>();
+
+ @Init
+ public void init() {
+ String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
+ catalog.put("Apple", new Item("Apple", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99)));
+ catalog.put("Orange", new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55)));
+ catalog.put("Pear", new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55)));
+ }
+
+ public Items getItem() {
+ Items items = new Items();
+ items.setItems(new ArrayList<Item>(catalog.values()));
+ return items;
+ }
+
+ public Item getItemById(String itemId) {
+ return catalog.get(itemId);
+ }
+
+ public void addItem(Item item) {
+ catalog.put(item.getName(),item);
+ }
+
+ public void updateItem(Item item) {
+ if(catalog.get(item.getName()) != null) {
+ catalog.put(item.getName(), item);
+ }
+ }
+
+ public void deleteItem(String itemId) {
+ if(catalog.get(itemId) != null) {
+ catalog.remove(itemId);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Item.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Item.java
new file mode 100644
index 0000000000..d5a298eee5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Item.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 services.store;
+
+public class Item {
+ private String name;
+ private String price;
+
+ public Item() {
+ }
+
+ public Item(String name, String price) {
+ this.name = name;
+ this.price = price;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPrice() {
+ return price;
+ }
+
+ public void setPrice(String price) {
+ this.price = price;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Items.java b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Items.java
new file mode 100644
index 0000000000..82a995943d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/java/services/store/Items.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 services.store;
+
+import java.util.List;
+
+/**
+ *
+ */
+public class Items {
+ private List<Item> items;
+
+ public List<Item> getItems() {
+ return items;
+ }
+
+ public void setItems(List<Item> items) {
+ this.items = items;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/binary.composite b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/binary.composite
new file mode 100644
index 0000000000..821ae7fcbf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/binary.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://binary"
+ name="Binary">
+
+ <component name="BinaryService">
+ <implementation.java class="services.binary.BinaryServiceImpl"/>
+ <service name="BinaryService">
+ <tuscany:binding.rest uri="http://localhost:8085/Binary">
+ <tuscany:operationSelector.jaxrs />
+ </tuscany:binding.rest>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/content/test.html b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/content/test.html
new file mode 100644
index 0000000000..f4b79d7f01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/content/test.html
@@ -0,0 +1,21 @@
+<html>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<body><p>hello</body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/customer.composite b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/customer.composite
new file mode 100644
index 0000000000..7b33145afd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/customer.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://customer"
+ name="customer">
+
+ <component name="CustomerService">
+ <implementation.java class="services.customer.CustomerServiceImpl"/>
+ <service name="CustomerService">
+ <tuscany:binding.rest uri="http://localhost:8085/Customer">
+ <tuscany:wireFormat.xml />
+ <tuscany:operationSelector.jaxrs />
+ <tuscany:http-headers>
+ <tuscany:header name="Cache-Control" value="no-cache"/>
+ <tuscany:header name="Expires" value="-1"/>
+ <tuscany:header name="X-Tuscany" value="tuscany"/>
+ </tuscany:http-headers>
+ </tuscany:binding.rest>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/echo.composite b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/echo.composite
new file mode 100644
index 0000000000..9e56b84315
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/echo.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://echo"
+ xmlns:echo="http://echo"
+ name="Echo">
+
+ <component name="EchoComponent">
+ <implementation.java class="services.echo.EchoImpl"/>
+ <service name="Echo">
+ <tuscany:binding.rest name="json" uri="http://localhost:8085/EchoService/json">
+ <tuscany:operationSelector.rpc />
+ <tuscany:response>
+ <tuscany:wireFormat.json />
+ </tuscany:response>
+ </tuscany:binding.rest>
+
+ <tuscany:binding.rest name="xml" uri="http://localhost:8085/EchoService/xml">
+ <tuscany:operationSelector.rpc />
+ <tuscany:response>
+ <tuscany:wireFormat.xml />
+ </tuscany:response>
+ </tuscany:binding.rest>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/store.composite b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/store.composite
new file mode 100644
index 0000000000..7a87929985
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/store.composite
@@ -0,0 +1,41 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://store"
+ name="store">
+
+ <component name="Catalog">
+ <implementation.java class="services.store.FruitsCatalogImpl"/>
+ <property name="currencyCode">USD</property>
+ <service name="Catalog">
+ <tuscany:binding.rest uri="http://localhost:8085/Catalog">
+ <tuscany:wireFormat.json />
+ <tuscany:operationSelector.jaxrs />
+ </tuscany:binding.rest>
+ </service>
+ <reference name="currencyConverter" target="CurrencyConverter"/>
+ </component>
+
+ <component name="CurrencyConverter">
+ <implementation.java class="services.store.CurrencyConverterImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/test.composite b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/test.composite
new file mode 100644
index 0000000000..835633ac6d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/test.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample/test"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sr="http://sample/test"
+ name="test">
+
+ <component name="HTTPServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.rest.TestServiceImpl"/>
+ <service name="Servlet">
+ <tuscany:binding.rest uri="http://localhost:8085/httpservice"/>
+ </service>
+ </component>
+
+ <component name="HTTPGetComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.rest.TestGetImpl"/>
+ <service name="TestGetImpl">
+ <tuscany:binding.rest uri="http://localhost:8085/httpget"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/testCache.composite b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/testCache.composite
new file mode 100644
index 0000000000..3401608c51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest-runtime/src/test/resources/testCache.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample/test"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sr="http://sample/test"
+ name="testCache">
+
+ <component name="HTTPBindingComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.rest.TestBindingCacheImpl"/>
+ <service name="TestBindingCacheImpl">
+ <tuscany:binding.rest uri="http://localhost:8085/httpbinding"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/LICENSE b/sandbox/sebastien/java/embed/modules/binding-rest/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/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/sebastien/java/embed/modules/binding-rest/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-rest/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..767844f4ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rest;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,javax.xml.namespace,javax.servlet.http",
+ org.apache.tuscany.sca.binding.rest.operationselector.jaxrs;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.operationselector.rpc;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.wireformat.json;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.wireformat.xml;version="2.0.0"
+Bundle-Name: Apache Tuscany SCA REST Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA HTTP Binding Model
+Import-Package: javax.servlet.http,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest;version="2.0.0",
+ org.apache.tuscany.sca.common.http;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rest
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/NOTICE b/sandbox/sebastien/java/embed/modules/binding-rest/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/pom.xml b/sandbox/sebastien/java/embed/modules/binding-rest/pom.xml
new file mode 100644
index 0000000000..6c5ea2e44e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/pom.xml
@@ -0,0 +1,60 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-rest</artifactId>
+ <name>Apache Tuscany SCA REST Binding Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java
new file mode 100644
index 0000000000..dd01c37537
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.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 org.apache.tuscany.sca.binding.rest;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+
+/**
+ * REST binding model.
+ *
+ * @version $Rev$ $Date$
+*/
+public interface RESTBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.rest");
+
+ public List<HTTPHeader> getHttpHeaders();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java
new file mode 100644
index 0000000000..38d68d532a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.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 org.apache.tuscany.sca.binding.rest;
+
+
+/**
+ * Factory for the REST binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RESTBindingFactory {
+
+ /**
+ * Creates a new REST binding.
+ * @return a new REST binding
+ */
+ RESTBinding createRESTBinding();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java
new file mode 100644
index 0000000000..00d5584190
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.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 org.apache.tuscany.sca.binding.rest.impl;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.RESTBindingFactory;
+
+/**
+ * Factory for the REST binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingFactoryImpl implements RESTBindingFactory {
+
+ public RESTBinding createRESTBinding() {
+ return new RESTBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
new file mode 100644
index 0000000000..93b59de5a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+
+
+/**
+ * Implementation of the HTTP binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class RESTBindingImpl implements RESTBinding {
+
+ private String name;
+ private String uri;
+
+ private List<HTTPHeader> httpHeaders = new ArrayList<HTTPHeader>();
+
+ private WireFormat requestWireFormat;
+ private WireFormat responseWireFormat;
+ private OperationSelector operationSelector;
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<HTTPHeader> getHttpHeaders() {
+ return this.httpHeaders;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The sample binding is always resolved
+ }
+
+ // Wireformat and Operation selection
+
+ public WireFormat getRequestWireFormat() {
+ return requestWireFormat;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ this.requestWireFormat = wireFormat;
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return responseWireFormat;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ this.responseWireFormat = wireFormat;
+ }
+
+ public OperationSelector getOperationSelector() {
+ return operationSelector;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ this.operationSelector = operationSelector;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelector.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelector.java
new file mode 100644
index 0000000000..aea3dce7ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelector.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.operationselector.jaxrs;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * JAX_RS Operation Selector model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JAXRSOperationSelector extends OperationSelector {
+ /**
+ * QName representing the REST JAX_RS Operation Selector extension
+ */
+ public static final QName REST_OPERATION_SELECTOR_JAXRS_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "operationSelector.jaxrs");
+
+ /**
+ * Return the QName identifying the operation selector
+ * @return the QName identifying the operation selector
+ */
+ QName getSchemaName();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelectorFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelectorFactory.java
new file mode 100644
index 0000000000..bdd3eca740
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelectorFactory.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 org.apache.tuscany.sca.binding.rest.operationselector.jaxrs;
+
+
+/**
+ * JAX-RS Operation Selector model factory
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JAXRSOperationSelectorFactory {
+
+ /**
+ * Create a new JAX-RS Operation Selector
+ * @return
+ */
+ JAXRSOperationSelector createJAXRSOperationSelector();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorFactoryImpl.java
new file mode 100644
index 0000000000..c47087e660
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorFactoryImpl.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 org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.impl;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector;
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory;
+
+/**
+ * JAX-RS Operation Selector model factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXRSOperationSelectorFactoryImpl implements JAXRSOperationSelectorFactory {
+
+ public JAXRSOperationSelector createJAXRSOperationSelector() {
+ return new JAXRSOperationSelectorImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorImpl.java
new file mode 100644
index 0000000000..ef214c3642
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector;
+
+
+/**
+ * JAX-RS Operation Selector model implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXRSOperationSelectorImpl implements JAXRSOperationSelector {
+
+ public QName getSchemaName() {
+ return JAXRSOperationSelector.REST_OPERATION_SELECTOR_JAXRS_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelector.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelector.java
new file mode 100644
index 0000000000..7730a1e75e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelector.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.operationselector.rpc;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * RPC Operation Selector model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RPCOperationSelector extends OperationSelector {
+ /**
+ * QName representing the RPC Operation Selector extension
+ */
+ public static final QName REST_OPERATION_SELECTOR_RPC_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "operationSelector.rpc");
+
+ /**
+ * Return the QName identifying the operation selector
+ * @return the QName identifying the operation selector
+ */
+ QName getSchemaName();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelectorFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelectorFactory.java
new file mode 100644
index 0000000000..27a56c374d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelectorFactory.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 org.apache.tuscany.sca.binding.rest.operationselector.rpc;
+
+
+/**
+ * RPC Operation Selector model factory
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RPCOperationSelectorFactory {
+
+ /**
+ * Create a new RPC Operation Selector
+ * @return
+ */
+ RPCOperationSelector createRPCOperationSelector();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorFactoryImpl.java
new file mode 100644
index 0000000000..9e67f35bc0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorFactoryImpl.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 org.apache.tuscany.sca.binding.rest.operationselector.rpc.impl;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector;
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory;
+
+/**
+ * RPC Operation Selector model factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class RPCOperationSelectorFactoryImpl implements RPCOperationSelectorFactory {
+
+ public RPCOperationSelector createRPCOperationSelector() {
+ return new RPCOperationSelectorImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorImpl.java
new file mode 100644
index 0000000000..bca8218f8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.operationselector.rpc.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector;
+
+
+/**
+ * RPC Operation Selector model implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class RPCOperationSelectorImpl implements RPCOperationSelector {
+
+ public QName getSchemaName() {
+ return RPCOperationSelector.REST_OPERATION_SELECTOR_RPC_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormat.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormat.java
new file mode 100644
index 0000000000..d9136da58e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormat.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.wireformat.json;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+
+/**
+ * JSON Wireformat model for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JSONWireFormat extends WireFormat {
+
+ /**
+ * QName representing the JSON Wireformat for REST Binding
+ */
+ public static final QName REST_WIREFORMAT_JSON_QNAME = new QName(SCA11_TUSCANY_NS, "wireFormat.json");
+
+ /**
+ * Return the QName identifying the wire format
+ * @return the QName identifying the wire format
+ */
+ QName getSchemaName();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormatFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormatFactory.java
new file mode 100644
index 0000000000..f297320b39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormatFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.wireformat.json;
+
+/**
+ * JSON Wireformat factory for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JSONWireFormatFactory {
+
+ /**
+ * Create a new JSON wireformat for REST Binding
+ * @return the new JSON wire format
+ */
+ JSONWireFormat createRESTWireFormatJSON();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatFactoryImpl.java
new file mode 100644
index 0000000000..0ddeb8e557
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatFactoryImpl.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 org.apache.tuscany.sca.binding.rest.wireformat.json.impl;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory;
+
+/**
+ * JSON Wireformat factory implementation for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONWireFormatFactoryImpl implements JSONWireFormatFactory {
+
+ public JSONWireFormat createRESTWireFormatJSON() {
+ return new JSONWireFormatImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatImpl.java
new file mode 100644
index 0000000000..2ce3b95453
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatImpl.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.binding.rest.wireformat.json.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+
+/**
+ * JSON Wireformat implementation for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONWireFormatImpl implements JSONWireFormat {
+
+ public QName getSchemaName() {
+ return JSONWireFormat.REST_WIREFORMAT_JSON_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // no op
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormat.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormat.java
new file mode 100644
index 0000000000..7eff067cdc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormat.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.wireformat.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+
+/**
+ * XML Wireformat model for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface XMLWireFormat extends WireFormat {
+
+ /**
+ * QName representing the XML Wireformat for REST Binding
+ */
+ public static final QName REST_WIREFORMAT_XML_QNAME = new QName(SCA11_TUSCANY_NS, "wireFormat.xml");
+
+ /**
+ * Return the QName identifying the wire format
+ * @return the QName identifying the wire format
+ */
+ QName getSchemaName();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormatFactory.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormatFactory.java
new file mode 100644
index 0000000000..82d9ad6132
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormatFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.wireformat.xml;
+
+/**
+ * XML Wireformat factory for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface XMLWireFormatFactory {
+
+ /**
+ * Create a new XML wireformat for REST Binding
+ * @return the new XML wire format
+ */
+ XMLWireFormat createRESTWireFormatXML();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatFactoryImpl.java
new file mode 100644
index 0000000000..b6fd3d6aed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatFactoryImpl.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.sca.binding.rest.wireformat.xml.impl;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory;
+
+/**
+ * XML Wireformat factory implementation for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLWireFormatFactoryImpl implements XMLWireFormatFactory {
+
+ public XMLWireFormat createRESTWireFormatXML() {
+ return new XMLWireFormatImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatImpl.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatImpl.java
new file mode 100644
index 0000000000..3f51fb8832
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatImpl.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.binding.rest.wireformat.xml.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+
+/**
+ * XML Wireformat implementation for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLWireFormatImpl implements XMLWireFormat {
+
+ public QName getSchemaName() {
+ return XMLWireFormat.REST_WIREFORMAT_XML_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // no op
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java
new file mode 100644
index 0000000000..81463b2889
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.Base;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.RESTBindingFactory;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * REST Binding Artifact Processor
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<RESTBinding> {
+ private static final QName HEADERS_QNAME = new QName(Base.SCA11_TUSCANY_NS, "http-headers");
+ private static final QName HEADER_QNAME = new QName(Base.SCA11_TUSCANY_NS, "header");
+ private static final QName RESPONSE_QNAME = new QName(Base.SCA11_TUSCANY_NS, "response");
+
+ private static final String NAME = "name";
+ private static final String VALUE = "value";
+ private static final String URI = "uri";
+
+ private RESTBindingFactory httpBindingFactory;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+
+ public RESTBindingProcessor(ExtensionPointRegistry extensionPoints,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> extensionAttributeProcessor) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.httpBindingFactory = modelFactories.getFactory(RESTBindingFactory.class);
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+ }
+
+ public QName getArtifactType() {
+ return RESTBinding.TYPE;
+ }
+
+ public Class<RESTBinding> getModelType() {
+ return RESTBinding.class;
+ }
+
+ public RESTBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ RESTBinding restBinding = httpBindingFactory.createRESTBinding();
+
+ /**
+ * <tuscany:binding.rest uri="http://localhost:8085/Customer">
+ * <tuscany:wireFormat.xml />
+ * <tuscany:operationSelector.jaxrs />
+ * <tuscany:http-headers>
+ * <tuscany:header name="Cache-Control" value="no-cache"/>
+ * <tuscany:header name="Expires" value="-1"/>
+ * </tuscany:http-headers>
+ * <tuscany:response>
+ * <tuscany:wireFormat.json />
+ * </tuscany:response>
+ * </tuscany:binding.rest>
+ *
+ */
+ while(reader.hasNext()) {
+ QName elementName = null;
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ elementName = reader.getName();
+
+ if(RESTBinding.TYPE.equals(elementName)) {
+
+ // binding attributes
+ String name = getString(reader, NAME);
+ if(name != null) {
+ restBinding.setName(name);
+ }
+
+ String uri = getURIString(reader, URI);
+ if (uri != null) {
+ restBinding.setURI(uri);
+ }
+ break;
+
+ } else if (HEADERS_QNAME.equals(elementName)) {
+
+ // ignore wrapper element
+ break;
+
+ } else if (HEADER_QNAME.equals(elementName)) {
+
+ // header name/value pair
+ String name = getString(reader, NAME);
+ String value = getURIString(reader, VALUE);
+
+ if(name != null) {
+ restBinding.getHttpHeaders().add(new HTTPHeader(name, value));
+ }
+ break;
+
+ } else if (RESPONSE_QNAME.equals(elementName)) {
+
+ // skip response
+ reader.next();
+ // and position to the next start_element event
+ while (reader.hasNext()) {
+ int sub_event = reader.getEventType();
+ switch (sub_event) {
+ case START_ELEMENT:
+ elementName = reader.getName();
+ break;
+ default: reader.next();
+ }
+ break;
+ }
+
+ // dispatch to read wire format for the response
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof WireFormat) {
+ restBinding.setResponseWireFormat((WireFormat)extension);
+ }
+ }
+ break;
+ } else {
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof WireFormat) {
+ restBinding.setRequestWireFormat((WireFormat)extension);
+ restBinding.setResponseWireFormat((WireFormat)extension);
+ } else if(extension instanceof OperationSelector) {
+ restBinding.setOperationSelector((OperationSelector)extension);
+ }
+ }
+ break;
+ }
+
+ case END_ELEMENT:
+ elementName = reader.getName();
+
+ if(RESTBinding.TYPE.equals(elementName)) {
+ return restBinding;
+ }
+ break;
+ }
+
+
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return restBinding;
+ }
+
+ public void write(RESTBinding restBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ writeStart(writer, RESTBinding.TYPE.getNamespaceURI(), RESTBinding.TYPE.getLocalPart());
+
+ // Write binding name
+ if (restBinding.getName() != null) {
+ writer.writeAttribute(NAME, restBinding.getName());
+ }
+
+ // Write binding URI
+ if (restBinding.getURI() != null) {
+ writer.writeAttribute(URI, restBinding.getURI());
+ }
+
+ // Write operation selectors
+ if ( restBinding.getOperationSelector() != null ) {
+ extensionProcessor.write(restBinding.getOperationSelector(), writer, context);
+ }
+
+ // Write wire formats
+ if ( restBinding.getRequestWireFormat() != null ) {
+ extensionProcessor.write(restBinding.getRequestWireFormat(), writer, context);
+ }
+
+ if ( restBinding.getResponseWireFormat() != null && restBinding.getRequestWireFormat() != restBinding.getResponseWireFormat()) {
+ writeStart(writer, RESPONSE_QNAME.getNamespaceURI(), RESPONSE_QNAME.getLocalPart());
+ extensionProcessor.write(restBinding.getResponseWireFormat(), writer, context);
+ writeEnd(writer);
+ }
+
+
+ writeEnd(writer);
+ }
+
+
+ public void resolve(RESTBinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // Should not need to do anything here for now...
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory
new file mode 100644
index 0000000000..e228ebc528
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.rest.impl.RESTBindingFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory
new file mode 100644
index 0000000000..e108988ecf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.impl.JAXRSOperationSelectorFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory
new file mode 100644
index 0000000000..7da7b6bf0e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.rest.operationselector.rpc.impl.RPCOperationSelectorFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory
new file mode 100644
index 0000000000..8cc248c7d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.rest.wireformat.json.impl.JSONWireFormatFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory
new file mode 100644
index 0000000000..54d5635e59
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.rest.wireformat.xml.impl.XMLWireFormatFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..d88cba48f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.rest.xml.RESTBindingProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.rest,model=org.apache.tuscany.sca.binding.rest.RESTBinding,factory=org.apache.tuscany.sca.binding.rest.RESTBindingFactory
+
+# Implementation class for the wireFormat processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.json,model=org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat,factory=org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.xml,model=org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat,factory=org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory
+
+# Implementation class for operationSelector processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#operationSelector.jaxrs,model=org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector,factory=org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#operationSelector.rpc,model=org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector,factory=org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorProcessorTestCase.java
new file mode 100644
index 0000000000..e808daff6d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorProcessorTestCase.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.operationselector.jaxrs.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JSON wire format processor tests to verify properly processing of
+ * wireFormat content in binding configuration in the composite file
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXRSOperationSelectorProcessorTestCase {
+ public static final String BINDING_WITH_OPERATION_SELECTOR =
+ "<binding.rest xmlns=\"http://tuscany.apache.org/xmlns/sca/1.1\" uri=\"http://localhost:8080/uri\">"
+ + "<operationSelector.jaxrs />"
+ + "</binding.rest>";
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+
+ context = new ProcessorContext(extensionPoints);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+
+ }
+
+ /**
+ * Tests the APIs:
+ * public OperationSelector getRequstOperationSelector();
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_OPERATION_SELECTOR));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+
+ OperationSelector operationSelector = binding.getOperationSelector();
+ Assert.assertEquals(JAXRSOperationSelector.class, operationSelector.getClass().getInterfaces()[0]);
+ }
+
+ @Test
+ public void testWriteWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_OPERATION_SELECTOR));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(binding, bos, context);
+
+ // used for debug comparison
+ // System.out.println(BINDING_WITH_OPERATION_SELECTOR);
+ // System.out.println(bos.toString());
+
+ Assert.assertEquals(BINDING_WITH_OPERATION_SELECTOR, bos.toString());
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatProcessorTestCase.java
new file mode 100644
index 0000000000..1528bb2f4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatProcessorTestCase.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.sca.binding.rest.wireformat.json.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JSON wire format processor tests to verify properly processing of
+ * wireFormat content in binding configuration in the composite file
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONWireFormatProcessorTestCase {
+
+ public static final String BINDING_WITH_WIRE_FORMAT =
+ "<binding.rest xmlns=\"http://tuscany.apache.org/xmlns/sca/1.1\" uri=\"http://localhost:8080/uri\">"
+ + "<wireFormat.json />"
+ + "</binding.rest>";
+
+ public static final String BINDING_WITH_RESPONSE_WIRE_FORMAT =
+ "<binding.rest xmlns=\"http://tuscany.apache.org/xmlns/sca/1.1\" uri=\"http://localhost:8080/uri\">"
+ + "<response>"
+ + "<wireFormat.json />"
+ + "</response>"
+ + "</binding.rest>";
+
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+
+ context = new ProcessorContext(extensionPoints);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+
+ }
+
+ /**
+ * Tests the APIs:
+ * public WireFormat getRequstWireFormat();
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_WIRE_FORMAT));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+
+ WireFormat requestWireFormat = binding.getRequestWireFormat();
+ Assert.assertEquals(JSONWireFormat.class, requestWireFormat.getClass().getInterfaces()[0]);
+ }
+
+ /**
+ * Tests the APIs:
+ * public WireFormat getResponseWireFormat();
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testResponseWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_RESPONSE_WIRE_FORMAT));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+
+ WireFormat responseWireFormat = binding.getResponseWireFormat();
+ Assert.assertEquals(JSONWireFormat.class, responseWireFormat.getClass().getInterfaces()[0]);
+ }
+
+
+ @Test
+ public void testWriteWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_WIRE_FORMAT));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(binding, bos, context);
+
+ // used for debug comparison
+ // System.out.println(BINDING_WITH_WIRE_FORMAT);
+ // System.out.println(bos.toString());
+
+ Assert.assertEquals(BINDING_WITH_WIRE_FORMAT, bos.toString());
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java
new file mode 100644
index 0000000000..55a539044d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rest.xml;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingProcessorTestCase {
+
+ private static final String COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" targetNamespace=\"http://binding-rest\" name=\"binding-rest\">"
+ + " <component name=\"CustomerService\">"
+ + " <implementation.java class=\"services.customer.CustomerServiceImpl\"/>"
+ + " <service name=\"CustomerService\">"
+ + " <tuscany:binding.rest uri=\"http://localhost:8085/Customer\">"
+ + " <tuscany:wireFormat.xml />"
+ + " <tuscany:operationSelector.jaxrs />"
+ + " <tuscany:http-headers>"
+ + " <tuscany:header name=\"Cache-Control\" value=\"no-cache\"/>"
+ + " <tuscany:header name=\"Expires\" value=\"-1\"/>"
+ + " </tuscany:http-headers>"
+ + " </tuscany:binding.rest>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ /**
+ * Test parsing valid composite definition. Valid composite populated with correct values expected.
+ * @throws Exception
+ */
+ @Test
+ public void testLoadValidComposite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ RESTBinding binding = (RESTBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ Assert.assertNotNull(binding);
+ Assert.assertEquals(2, binding.getHttpHeaders().size());
+ Assert.assertEquals("Cache-Control", binding.getHttpHeaders().get(0).getName());
+ Assert.assertEquals("no-cache", binding.getHttpHeaders().get(0).getValue());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/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/sebastien/java/embed/modules/binding-rmi-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..8ee04bdf37
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA RMI Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA RMI Binding Extension
+Import-Package: net.sf.cglib.core,
+ net.sf.cglib.proxy,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.rmi;version="2.0.0",
+ org.apache.tuscany.sca.common.java.classloader;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.rmi;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.objectweb.asm
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rmi.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/pom.xml
new file mode 100644
index 0000000000..d6d89a24c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <name>Apache Tuscany SCA RMI Binding Extension</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java
new file mode 100644
index 0000000000..3cbc66f765
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rmi.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.tuscany.sca.host.rmi.RMIHost;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Invoker for RMI References.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIBindingInvoker implements Invoker {
+
+ private RMIHost rmiHost;
+ private String uri;
+ private Method remoteMethod;
+ // private Remote proxy;
+
+ public RMIBindingInvoker(RMIHost rmiHost, String uri, Method remoteMethod) {
+ this.rmiHost = rmiHost;
+ this.remoteMethod = remoteMethod;
+ this.uri = uri;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+
+ Object[] args = msg.getBody();
+ Object resp = invokeTarget(args);
+ msg.setBody(resp);
+
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+
+ return msg;
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException, SecurityException,
+ NoSuchMethodException, IllegalArgumentException, IllegalAccessException {
+ Remote proxy = null;
+ final Class<?> remote = remoteMethod.getDeclaringClass();
+ final ClassLoader stubClassLoader = remote.getClassLoader();
+ // The generated remote interface is not available for the service lookup
+ final ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(stubClassLoader);
+ return tccl;
+ }
+ });
+ try {
+ // The proxy cannot be cached as the remote services can be rebound
+ proxy = rmiHost.findService(uri);
+ } finally {
+ AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ ClassLoader current = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(tccl);
+ return current;
+ }
+ });
+ }
+
+ remoteMethod = proxy.getClass().getMethod(remoteMethod.getName(), remoteMethod.getParameterTypes());
+
+ if (payload != null && !payload.getClass().isArray()) {
+ return remoteMethod.invoke(proxy, payload);
+ } else {
+ return remoteMethod.invoke(proxy, (Object[])payload);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java
new file mode 100644
index 0000000000..3b903cc846
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.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.binding.rmi.provider;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.rmi.ExtensibleRMIHost;
+import org.apache.tuscany.sca.host.rmi.RMIHost;
+import org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * RMI Binding Provider Factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIBindingProviderFactory implements BindingProviderFactory<RMIBinding> {
+
+ private RMIHost rmiHost;
+
+ public RMIBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ RMIHostExtensionPoint rmiHosts = extensionPoints.getExtensionPoint(RMIHostExtensionPoint.class);
+ this.rmiHost = new ExtensibleRMIHost(rmiHosts);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+
+ return new RMIReferenceBindingProvider(endpointReference, rmiHost);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new RMIServiceBindingProvider(endpoint, rmiHost);
+ }
+
+ public Class<RMIBinding> getModelType() {
+ return RMIBinding.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.java
new file mode 100644
index 0000000000..8d13b0a24f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.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.rmi.provider;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.host.rmi.RMIHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of the RMI Binding Provider for References
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private RuntimeComponentReference reference;
+ private RMIBinding binding;
+ private RMIHost rmiHost;
+
+ public RMIReferenceBindingProvider(EndpointReference endpointReference,
+ RMIHost rmiHost) {
+ this.reference = (RuntimeComponentReference)endpointReference.getReference();
+ this.binding = (RMIBinding)endpointReference.getBinding();
+ this.rmiHost = rmiHost;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ Class<?> iface = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass();
+ Method remoteMethod;
+ try {
+ remoteMethod = JavaInterfaceUtil.findMethod(iface, operation);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ return new RMIBindingInvoker(rmiHost, binding.getURI(), remoteMethod);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java
new file mode 100644
index 0000000000..7e343e4413
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rmi.provider;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.server.UnicastRemoteObject;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.common.java.classloader.ClassLoaderDelegate;
+import org.apache.tuscany.sca.host.rmi.RMIHost;
+import org.apache.tuscany.sca.host.rmi.RMIHostException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Implementation of a Service for the RMIBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private RMIBinding binding;
+ private RMIHost rmiHost;
+ private RuntimeEndpoint endpoint;
+ private Remote rmiProxy;
+
+ public RMIServiceBindingProvider(RuntimeEndpoint endpoint, RMIHost rmiHost) {
+ this.endpoint = endpoint;
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (RMIBinding)endpoint.getBinding();
+ this.rmiHost = rmiHost;
+ }
+
+ public void start() {
+
+ Interface serviceInterface = service.getInterfaceContract().getInterface();
+
+ rmiProxy = createRmiService(serviceInterface);
+
+ try {
+
+ String uri = rmiHost.registerService(binding.getURI(), rmiProxy);
+ // Update the binding with the physical URI
+ binding.setURI(uri);
+
+ } catch (RMIHostException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public void stop() {
+ rmiHost.unregisterService(binding.getURI());
+ try {
+ UnicastRemoteObject.unexportObject(rmiProxy, false);
+ } catch (NoSuchObjectException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ private int getPort(String port) {
+ int portNumber = RMIHost.RMI_DEFAULT_PORT;
+ if (port != null && port.length() > 0) {
+ portNumber = Integer.decode(port);
+ }
+ return portNumber;
+ }
+
+ private Remote createRmiService(final Interface serviceInterface) {
+ Enhancer enhancer = new Enhancer();
+ enhancer.setSuperclass(UnicastRemoteObject.class);
+ enhancer.setCallback(new MethodInterceptor() {
+ public Object intercept(Object arg0, Method method, Object[] args, MethodProxy arg3) throws Throwable {
+ try {
+ return invokeTarget(JavaInterfaceUtil.findOperation(method, serviceInterface.getOperations()), args);
+ } catch (InvocationTargetException e) {
+ final Throwable cause = e.getCause();
+ for (Class<?> declaredType : method.getExceptionTypes()) {
+ if (declaredType.isInstance(cause)) {
+ throw e;
+ }
+ }
+
+ if (cause.getCause() != null) {
+ // TUSCANY-2545: don't inlcude nested cause object
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ Field field = Throwable.class.getDeclaredField("cause");
+ field.setAccessible(true);
+ field.set(cause, null);
+ field.setAccessible(false);
+ return null;
+ }
+ });
+ }
+
+ throw cause;
+ }
+ }
+ });
+ Class<?> targetJavaInterface = getTargetJavaClass(serviceInterface);
+ targetJavaInterface = RemoteInterfaceGenerator.generate(targetJavaInterface);
+ /*
+ * In OSGi, the classloader for the interface cannot access the classes for the CGLIB
+ */
+ enhancer.setClassLoader(new ClassLoaderDelegate(targetJavaInterface.getClassLoader(), getClass().getClassLoader()));
+ enhancer.setInterfaces(new Class[] {targetJavaInterface});
+ return (Remote)enhancer.create();
+ }
+
+ private Object invokeTarget(Operation op, Object[] args) throws InvocationTargetException {
+ return endpoint.invoke(op, args);
+ }
+
+ private Class<?> getTargetJavaClass(Interface targetInterface) {
+ // TODO: right now assume that the target is always a Java
+ // Implementation. Need to figure out
+ // how to generate Java Interface in cases where the target is not a
+ // Java Implementation
+ return ((JavaInterface)targetInterface).getJavaClass();
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return service.getInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RemoteInterfaceGenerator.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RemoteInterfaceGenerator.java
new file mode 100644
index 0000000000..b351bfacc7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RemoteInterfaceGenerator.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rmi.provider;
+
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import net.sf.cglib.core.Constants;
+
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Type;
+
+/**
+ *
+ */
+public class RemoteInterfaceGenerator {
+ private final static Map<Class<?>, Class<? extends Remote>> remoteInterfaces =
+ Collections.synchronizedMap(new WeakHashMap<Class<?>, Class<? extends Remote>>());
+
+ static class RemoteInterfaceClassLoader extends ClassLoader {
+ public RemoteInterfaceClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+
+ public Class<?> defineClass(String name, byte[] byteArray) {
+ return defineClass(name, byteArray, 0, byteArray.length);
+ }
+ }
+
+ /**
+ * if the interface of the component whose serviceBindings must be exposed as RMI Service, does not
+ * implement java.rmi.Remote, then generate such an interface. This method will stop with just
+ * generating the bytecode. Defining the class from the byte code must be the responsibility of the
+ * caller of this method, since it requires a ClassLoader to be created to define and load this interface.
+ */
+ private static byte[] generateRemoteInterface(Class<?> serviceInterface) {
+ String interfazeName = serviceInterface.getName();
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+
+ cw.visit(Constants.V1_5, Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE, interfazeName
+ .replace('.', '/'), null, "java/lang/Object", new String[] {"java/rmi/Remote"});
+
+ StringBuffer argsAndReturn = null;
+ Method[] methods = serviceInterface.getMethods();
+ for (Method method : methods) {
+ argsAndReturn = new StringBuffer("(");
+ Class<?>[] paramTypes = method.getParameterTypes();
+ Class<?> returnType = method.getReturnType();
+
+ for (Class<?> paramType : paramTypes) {
+ argsAndReturn.append(Type.getType(paramType));
+ }
+ argsAndReturn.append(")");
+ argsAndReturn.append(Type.getType(returnType));
+
+ cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT,
+ method.getName(),
+ argsAndReturn.toString(),
+ null,
+ new String[] {"java/rmi/RemoteException"});
+ }
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
+ public static Class<? extends Remote> generate(Class<?> javaInterface) {
+ if (!Remote.class.isAssignableFrom(javaInterface)) {
+ Class<? extends Remote> remote = remoteInterfaces.get(javaInterface);
+ if (remote == null) {
+ RemoteInterfaceClassLoader classloader = new RemoteInterfaceClassLoader(javaInterface.getClassLoader());
+ final byte[] byteCode = generateRemoteInterface(javaInterface);
+ javaInterface = classloader.defineClass(javaInterface.getName(), byteCode);
+ remote = (Class<? extends Remote>)javaInterface;
+ remoteInterfaces.put(javaInterface, remote);
+ }
+ return remote;
+ } else {
+ return (Class<? extends Remote>)javaInterface;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..679543e0f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.rmi.provider.RMIBindingProviderFactory;model=org.apache.tuscany.sca.binding.rmi.RMIBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java
new file mode 100644
index 0000000000..cbc860ecc6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.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 helloworld;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2570611055132507470L;
+
+ /**
+ *
+ */
+ public HelloException() {
+ }
+
+ /**
+ * @param message
+ */
+ public HelloException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public HelloException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public HelloException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..cd7a0fd625
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.oasisopen.sca.annotation.Service;
+
+
+/**
+ * This class implements the HelloWorld service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello from the RMI Service to - " + name;
+ }
+
+ public String sayHi(String name, String greeter) throws HelloException {
+ if (name == null || greeter == null) {
+ throw new HelloException("Invalid name or greeter: name=" + name + " greeter=" + greeter);
+ }
+ return "Hi from " + greeter + " in RMI Service to - " + name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java
new file mode 100644
index 0000000000..89ea795529
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.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 helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(HelloWorldRmiService.class)
+public class HelloWorldRmiImpl implements HelloWorldRmiService {
+ private HelloWorldService extService;
+
+ public HelloWorldService getExtService() {
+ return extService;
+ }
+
+ @Reference
+ public void setExtService(HelloWorldService extService) {
+ this.extService = extService;
+ }
+
+ public String sayRmiHello(String name) {
+ return extService.sayHello(name) + " thro the RMI Reference";
+ }
+
+ public String sayRmiHi(String name, String greeter) throws HelloException {
+ return extService.sayHi(name, greeter) + " thro the RMI Reference";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java
new file mode 100644
index 0000000000..461c176e1e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.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 helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HelloWorldRmiService {
+
+ String sayRmiHello(String name);
+ String sayRmiHi(String name, String greeter) throws HelloException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..3b705d2c97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.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 helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HelloWorldService {
+
+ String sayHello(String name);
+ String sayHi(String name, String greeter) throws HelloException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java
new file mode 100644
index 0000000000..c3cd710f1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rmi;
+
+import helloworld.HelloException;
+import helloworld.HelloWorldRmiService;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for the RMIBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindingTestCase {
+ private static HelloWorldRmiService helloWorldRmiService;
+ private static Node node;
+
+ @Test
+ public void testRmiService() {
+ String msg = helloWorldRmiService.sayRmiHello("Tuscany World!");
+ System.out.println(msg);
+ Assert.assertEquals("Hello from the RMI Service to - Tuscany World! thro the RMI Reference", msg);
+
+ try {
+ msg = helloWorldRmiService.sayRmiHi("Tuscany World!", "Apache World");
+ System.out.println(msg);
+ Assert.assertEquals("Hi from Apache World in RMI Service to - Tuscany World! thro the RMI Reference", msg);
+ } catch (HelloException e) {
+ Assert.fail(e.getMessage());
+ }
+ try {
+ msg = helloWorldRmiService.sayRmiHi(null, "Apache World");
+ Assert.fail("HelloException should have been thrown");
+ } catch (HelloException e) {
+ System.out.println("Expected exception :" + e.getClass().getName());
+ }
+ }
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(BindingTestCase.class);
+ node = NodeFactory.newInstance().createNode("RMIBindingTest.composite", new Contribution("test", contribution));
+ node.start();
+ helloWorldRmiService = node.getService(HelloWorldRmiService.class, "HelloWorldRmiServiceComponent");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..59e7606bbb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType
@@ -0,0 +1,23 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+</componentType>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType
new file mode 100644
index 0000000000..819a00f978
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType
@@ -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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldRmiService">
+ <interface.java interface="helloworld.HelloWorldRmiService"/>
+ </service>
+
+ <reference name="extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </reference>
+</componentType>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite
new file mode 100644
index 0000000000..9d526b7f11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite
@@ -0,0 +1,41 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="HelloWorldRmiComposite">
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <service name="HelloWorldService" >
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService"/>
+ </service>
+ </component>
+
+ <component name="HelloWorldRmiServiceComponent">
+ <implementation.java class="helloworld.HelloWorldRmiImpl"/>
+ <reference name="extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/LICENSE b/sandbox/sebastien/java/embed/modules/binding-rmi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/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/sebastien/java/embed/modules/binding-rmi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-rmi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..66c1003087
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rmi;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,javax.xml.namespace"
+Private-Package: org.apache.tuscany.sca.binding.rmi.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA RMI Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA RMI Binding Model
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.rmi;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rmi
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/NOTICE b/sandbox/sebastien/java/embed/modules/binding-rmi/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/pom.xml b/sandbox/sebastien/java/embed/modules/binding-rmi/pom.xml
new file mode 100644
index 0000000000..205cf3ac04
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/pom.xml
@@ -0,0 +1,41 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-rmi</artifactId>
+ <name>Apache Tuscany SCA RMI Binding Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java
new file mode 100644
index 0000000000..36354ddc01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rmi;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * RMI Binding model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RMIBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.rmi");
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java
new file mode 100644
index 0000000000..38445fa838
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rmi;
+
+/**
+ * Factory to create RMIBinding instances
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RMIBindingFactory {
+ /**
+ * Create RMIBinding model
+ * @return
+ */
+ RMIBinding createRMIBinding();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java
new file mode 100644
index 0000000000..1331ff4fb1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.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 org.apache.tuscany.sca.binding.rmi.impl;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.binding.rmi.RMIBindingFactory;
+
+/**
+ * Factory implementation to create RMI Models
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIBindingFactoryImpl implements RMIBindingFactory {
+ public RMIBinding createRMIBinding() {
+ return new RMIBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java
new file mode 100644
index 0000000000..df129319af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.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.binding.rmi.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+
+/**
+ * Represents a binding to an RMI service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIBindingImpl implements RMIBinding {
+ private String uri;
+ private String name;
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory
new file mode 100644
index 0000000000..b82480ba7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.rmi.impl.RMIBindingFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..31af0ec40f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.rmi,model=org.apache.tuscany.sca.binding.rmi.RMIBinding,factory=org.apache.tuscany.sca.binding.rmi.RMIBindingFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/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/sebastien/java/embed/modules/binding-rss-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c78875e887
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rss.collection
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA RSS Feed Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA RSS Feed Binding Extension
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.rss;version="2.0.0",
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.interfacedef,
+ org.apache.tuscany.sca.interfacedef.impl,
+ org.apache.tuscany.sca.interfacedef.util,
+ org.apache.tuscany.sca.monitor
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rss.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/pom.xml
new file mode 100644
index 0000000000..a6bb39de01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/pom.xml
@@ -0,0 +1,170 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-rss-runtime</artifactId>
+ <name>Apache Tuscany SCA RSS Feed Binding Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rss</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.0.1</version>
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.binding.rss.rome</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.binding.rss*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java
new file mode 100644
index 0000000000..581ae59ae6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rss.collection;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+
+
+/**
+ * Provides access to a collection of resources using RSS.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Collection {
+
+ /**
+ * Get an RSS feed for a collection of resources.
+ *
+ * @return the RSS feed
+ */
+ SyndFeed getFeed();
+
+ /**
+ * Get an RSS feed for a collection of resources resulting from a query.
+ *
+ * @param queryString the query string
+ * @return the RSS feed
+ */
+ SyndFeed query(String queryString);
+
+ /**
+ * Retrieves an RSS entry.
+ *
+ * @param id The entry ID
+ * @return The requested entry
+ * @throws NotFoundException No entry found with the given ID
+ */
+ SyndEntry get(String id) throws NotFoundException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java
new file mode 100644
index 0000000000..a2b83465da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.rss.collection;
+
+import java.io.InputStream;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+import com.sun.syndication.feed.atom.Entry;
+
+/**
+ * Provides access to a collection of resources using Atom.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface MediaCollection extends Collection {
+
+ /**
+ * Creates a new media entry
+ *
+ * @param title
+ * @param slug
+ * @param contentType
+ * @param media
+ */
+ Entry postMedia(String title, String slug, String contentType, InputStream media);
+
+ /**
+ * Update a media entry.
+ *
+ * @param id
+ * @param contentType
+ * @param media
+ * @return
+ */
+ void putMedia(String id, String contentType, InputStream media) throws NotFoundException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java
new file mode 100644
index 0000000000..0912878938
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss.collection;
+
+/**
+ * Indicates that a resource could not be found.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NotFoundException extends Exception {
+ private static final long serialVersionUID = -5046027674128627383L;
+
+ public NotFoundException() {
+ }
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+ public NotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java
new file mode 100644
index 0000000000..e3a177198c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.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.sca.binding.rss.provider;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.XmlReader;
+
+/**
+ * Invoker for the RSS binding.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSBindingInvoker implements Invoker , DataExchangeSemantics {
+ private static final Logger logger = Logger.getLogger(RSSBindingInvoker.class.getName());
+
+ private String uri;
+
+ RSSBindingInvoker(String uri, String feedType) {
+ this.uri = uri;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ logger.fine("invoke " + uri);
+
+ // Read an RSS feed into a Synd feed
+ SyndFeedInput input = new SyndFeedInput();
+ SyndFeed feed = input.build(new XmlReader(new URL(uri)));
+
+ //FIXME Support conversion to data-api entries
+
+ msg.setBody(feed);
+
+ } catch (MalformedURLException e) {
+ msg.setFaultBody(e);
+ } catch (IllegalArgumentException e) {
+ msg.setFaultBody(e);
+ } catch (FeedException e) {
+ msg.setFaultBody(e);
+ } catch (IOException e) {
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java
new file mode 100644
index 0000000000..44c84ce5bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java
@@ -0,0 +1,397 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rss.provider;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.tuscany.sca.data.collection.Item;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.feed.synd.SyndLink;
+import com.sun.syndication.feed.synd.SyndLinkImpl;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedOutput;
+
+/**
+ * An RSS binding listener, implemented as a Servlet and
+ * registered in a Servlet host provided by the SCA hosting runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSBindingListenerServlet extends HttpServlet {
+ private static final Logger logger = Logger.getLogger(RSSBindingListenerServlet.class.getName());
+ private static final long serialVersionUID = 1L;
+
+ private Invocable wire;
+ private Invoker getFeedInvoker;
+ private Invoker getAllInvoker;
+ private Invoker queryInvoker;
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private DataType<?> itemClassType;
+ private DataType<?> itemXMLType;
+ private boolean supportsFeedEntries;
+
+ /**
+ * Constructs a new binding listener.
+ *
+ * @param wire
+ * @param messageFactory
+ */
+ RSSBindingListenerServlet(Invocable wire, MessageFactory messageFactory, Mediator mediator) {
+ this.wire = wire;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+
+ // Get the invokers for the supported operations
+ Operation getOperation = null;
+ for (InvocationChain invocationChain : this.wire.getInvocationChains()) {
+ invocationChain.setAllowsPassByReference(true);
+ Operation operation = invocationChain.getTargetOperation();
+ String operationName = operation.getName();
+ if (operationName.equals("getFeed")) {
+ getFeedInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("getAll")) {
+ getAllInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("query")) {
+ queryInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("get")) {
+ getOperation = operation;
+ }
+ }
+
+ // Determine the collection item type
+ if (getOperation != null) {
+ itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
+ Class<?> itemClass = getOperation.getOutputType().getPhysical();
+ if (itemClass == SyndEntry.class) {
+ supportsFeedEntries = true;
+ }
+ DataType<XMLType> outputType = getOperation.getOutputType();
+ QName qname = outputType.getLogical().getElementName();
+ qname = new QName(qname.getNamespaceURI(), itemClass.getSimpleName());
+ itemClassType = new DataTypeImpl<XMLType>("java:complexType", itemClass, new XMLType(qname, null));
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // No authentication required for a get request
+
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+
+ logger.fine("get " + request.getRequestURI());
+
+ // Handle an RSS request
+ if (path == null || path.length() == 0 || path.equals("/")) {
+
+ // Return an RSS feed containing the entries in the collection
+ SyndFeed feed = null;
+ if (supportsFeedEntries) {
+
+ // The service implementation supports feed entries, invoke its getFeed operation
+ Message requestMessage = messageFactory.createMessage();
+ Message responseMessage = getFeedInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ feed = (SyndFeed)responseMessage.getBody();
+
+ } else {
+
+ // The service implementation does not support feed entries, invoke its
+ // getAll operation to get the data item collection. then create feed entries
+ // from the data items
+ Message requestMessage = messageFactory.createMessage();
+ Message responseMessage;
+ if (request.getQueryString() != null) {
+ requestMessage.setBody(new Object[] {request.getQueryString()});
+ responseMessage = queryInvoker.invoke(requestMessage);
+ } else {
+ responseMessage = getAllInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ org.apache.tuscany.sca.data.collection.Entry<Object, Object>[] collection =
+ (org.apache.tuscany.sca.data.collection.Entry<Object, Object>[])responseMessage.getBody();
+ if (collection != null) {
+ // Create the feed
+ feed = new SyndFeedImpl();
+ feed.setTitle("Feed");
+ feed.setDescription("Feed description");
+
+ for (org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry: collection) {
+ SyndEntry feedEntry = createFeedEntry(entry);
+ feed.getEntries().add(feedEntry);
+ }
+ }
+ }
+
+ // Convert to an RSS feed
+ if (feed != null) {
+ response.setContentType("application/rss+xml; charset=utf-8");
+ feed.setFeedType("rss_2.0");
+ feed.setLink(path);
+ SyndFeedOutput syndOutput = new SyndFeedOutput();
+ try {
+ syndOutput.output(feed, getWriter(response));
+ } catch (FeedException e) {
+ throw new ServletException(e);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ }
+
+ /**
+ * Create an RSS entry from a data collection entry.
+ * @param entry
+ * @return
+ */
+ private SyndEntry createFeedEntry(org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry) {
+ Object key = entry.getKey();
+ Object data = entry.getData();
+ if (data instanceof Item) {
+ Item item = (Item)data;
+
+ SyndEntry feedEntry = new SyndEntryImpl();
+ feedEntry.setUri(key.toString());
+ feedEntry.setTitle(item.getTitle());
+
+ String value = item.getContents();
+ if (value != null) {
+ SyndContent content = new SyndContentImpl();
+ content.setType("text/xml");
+ content.setValue(value);
+ List<SyndContent> contents = new ArrayList<SyndContent>();
+ contents.add(content);
+ feedEntry.setContents(contents);
+ }
+
+ String href = item.getLink();
+ if (href == null) {
+ href = key.toString();
+ }
+ SyndLink link = new SyndLinkImpl();
+ link.setRel("edit");
+ link.setHref(href);
+ feedEntry.getLinks().add(link);
+ link = new SyndLinkImpl();
+ link.setRel("alternate");
+ link.setHref(href);
+ feedEntry.getLinks().add(link);
+ feedEntry.setLink(href);
+
+ Date date = item.getDate();
+ if (date == null) {
+ date = new Date();
+ }
+ feedEntry.setPublishedDate(date);
+ return feedEntry;
+
+ } else if (data != null) {
+ SyndEntry feedEntry = new SyndEntryImpl();
+ feedEntry.setUri(key.toString());
+ feedEntry.setTitle("item");
+
+ // Convert the item to XML
+ String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString();
+
+ SyndContent content = new SyndContentImpl();
+ content.setType("text/xml");
+ content.setValue(value);
+ List<SyndContent> contents = new ArrayList<SyndContent>();
+ contents.add(content);
+ feedEntry.setContents(contents);
+
+ SyndLink link = new SyndLinkImpl();
+ link.setRel("edit");
+ link.setHref(key.toString());
+ feedEntry.getLinks().add(link);
+ link = new SyndLinkImpl();
+ link.setRel("alternate");
+ link.setHref(key.toString());
+ feedEntry.getLinks().add(link);
+
+ feedEntry.setPublishedDate(new Date());
+ return feedEntry;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create a data collection entry from an RSS entry.
+ * @param feedEntry
+ * @return
+ */
+ private org.apache.tuscany.sca.data.collection.Entry<Object, Object> createEntry(SyndEntry feedEntry) {
+ if (feedEntry != null) {
+ if (itemClassType.getPhysical() == Item.class) {
+ String key = feedEntry.getUri();
+
+ Item item = new Item();
+ item.setTitle(feedEntry.getTitle());
+
+ List<?> contents = feedEntry.getContents();
+ if (!contents.isEmpty()) {
+ SyndContent content = (SyndContent)contents.get(0);
+ String value = content.getValue();
+ item.setContents(value);
+ }
+
+ for (Object l : feedEntry.getLinks()) {
+ SyndLink link = (SyndLink)l;
+ if (link.getRel() == null || "edit".equals(link.getRel())) {
+ String href = link.getHref();
+ if (href.startsWith("null/")) {
+ href = href.substring(5);
+ }
+ item.setLink(href);
+ break;
+ }
+ }
+
+ item.setDate(feedEntry.getPublishedDate());
+
+ return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, item);
+
+ } else {
+ String key = feedEntry.getUri();
+
+ // Create the item from XML
+ List<?> contents = feedEntry.getContents();
+ if (contents.isEmpty()) {
+ return null;
+ }
+ SyndContent content = (SyndContent)contents.get(0);
+ String value = content.getValue();
+ Object data = mediator.mediate(value, itemXMLType, itemClassType, null);
+
+ return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, data);
+ }
+ } else {
+ return null;
+ }
+ }
+
+
+ private Writer getWriter(HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+ Writer writer = new OutputStreamWriter(response.getOutputStream(), "UTF-8");
+ return writer;
+ }
+
+ /**
+ * Process the authorization header
+ *
+ * @param request
+ * @return
+ * @throws ServletException
+ */
+ private String processAuthorizationHeader(HttpServletRequest request) throws ServletException {
+ try {
+ String authorization = request.getHeader("Authorization");
+ if (authorization != null) {
+ StringTokenizer tokens = new StringTokenizer(authorization);
+ if (tokens.hasMoreTokens()) {
+ String basic = tokens.nextToken();
+ if (basic.equalsIgnoreCase("Basic")) {
+ String credentials = tokens.nextToken();
+ String userAndPassword = new String(Base64.decodeBase64(credentials.getBytes()));
+ int colon = userAndPassword.indexOf(":");
+ if (colon != -1) {
+ String user = userAndPassword.substring(0, colon);
+ String password = userAndPassword.substring(colon + 1);
+
+ // Authenticate the User.
+ if (authenticate(user, password)) {
+ return user;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ return null;
+ }
+
+ /**
+ * Authenticate a user.
+ *
+ * @param user
+ * @param password
+ * @return
+ */
+ private boolean authenticate(String user, String password) {
+
+ // TODO Handle this using SCA security policies
+ //FIXME Why are we using endsWith instead of equals here??
+ return ("admin".endsWith(user) && "admin".equals(password));
+ }
+
+ /**
+ * Reject an unauthorized request.
+ *
+ * @param response
+ */
+ private void unauthorized(HttpServletResponse response) throws IOException {
+ response.setHeader("WWW-Authenticate", "BASIC realm=\"Tuscany\"");
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java
new file mode 100644
index 0000000000..e1bafdd3cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rss.provider;
+
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Implementation of the RSS binding provider factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RSSBindingProviderFactory implements BindingProviderFactory<RSSBinding> {
+
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private ServletHost servletHost;
+
+ public RSSBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ this.servletHost = servletHosts.getServletHosts().get(0);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ this.mediator = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new RSSReferenceBindingProvider(endpointReference, mediator);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new RSSServiceBindingProvider(endpoint, messageFactory, mediator, servletHost);
+ }
+
+ public Class<RSSBinding> getModelType() {
+ return RSSBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java
new file mode 100644
index 0000000000..d234a0c92c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rss.provider;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+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.RuntimeComponentReference;
+
+/**
+ * Implementation of the RSS binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private EndpointReference endpointReference;
+
+ private RuntimeComponentReference reference;
+ private RSSBinding binding;
+
+ RSSReferenceBindingProvider(EndpointReference endpointReference,
+ Mediator mediator) {
+ this.endpointReference = endpointReference;
+ this.reference = (RuntimeComponentReference) endpointReference.getReference();
+ this.binding = (RSSBinding) endpointReference.getBinding();
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new RSSBindingInvoker(binding.getURI(), "rss_2.0");
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java
new file mode 100644
index 0000000000..25ab939341
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rss.provider;
+
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Implementation of the RSS binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+
+ //private RuntimeComponentService service;
+ private RSSBinding binding;
+
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private ServletHost servletHost;
+
+ private String servletMapping;
+
+ RSSServiceBindingProvider(RuntimeEndpoint endpoint,
+ MessageFactory messageFactory,
+ Mediator mediator,
+ ServletHost servletHost) {
+ this.endpoint = endpoint;
+
+ //this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (RSSBinding) endpoint.getBinding();
+ this.servletHost = servletHost;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return endpoint.getComponentTypeServiceInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ Invocable wire = (RuntimeEndpoint) endpoint;
+
+ RSSBindingListenerServlet servlet =
+ new RSSBindingListenerServlet(wire, messageFactory, mediator);
+
+ servletMapping = binding.getURI();
+ if (!servletMapping.endsWith("/")) {
+ servletMapping += "/";
+ }
+ if (!servletMapping.endsWith("*")) {
+ servletMapping += "*";
+ }
+ servletHost.addServletMapping(servletMapping, servlet);
+
+ // Save the actual binding URI in the binding
+ //binding.setURI(servletHost.getURLMapping(binding.getURI()).toString());
+ }
+
+ public void stop() {
+ servletHost.removeServletMapping(servletMapping);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..e60dc2855a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.rss.provider.RSSBindingProviderFactory;model=org.apache.tuscany.sca.binding.rss.RSSBinding
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java
new file mode 100644
index 0000000000..1ae4515e70
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rss;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+
+public class Consumer {
+
+ public static void main(String[] args) throws Exception {
+
+ String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class);
+ Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/feed/Consumer.composite", new Contribution("consumer", contribution));
+
+ node.start();
+
+ CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient");
+ testService.testCustomerCollection();
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java
new file mode 100644
index 0000000000..af87155f45
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+public interface CustomerClient {
+
+ void testCustomerCollection() throws Exception;
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java
new file mode 100644
index 0000000000..a80f721136
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+import org.apache.tuscany.sca.binding.rss.collection.Collection;
+import org.oasisopen.sca.annotation.Reference;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+
+
+public class CustomerClientImpl implements CustomerClient {
+
+ @Reference
+ public Collection resourceCollection;
+
+ public void testCustomerCollection() throws Exception {
+
+ System.out.println(">>> get collection");
+ SyndFeed feed = resourceCollection.getFeed();
+ System.out.println("<<< get collection");
+ for (Object o : feed.getEntries()) {
+ SyndEntry e = (SyndEntry)o;
+ System.out.println("id = " + e.getUri() + " entry = " + e.getTitle());
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java
new file mode 100644
index 0000000000..4b5bf373e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rss;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.binding.rss.collection.Collection;
+import org.apache.tuscany.sca.binding.rss.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Scope;
+
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.feed.synd.SyndLink;
+import com.sun.syndication.feed.synd.SyndLinkImpl;
+
+@Scope("COMPOSITE")
+public class CustomerCollectionImpl implements Collection {
+
+ private Map<String, SyndEntry> entries = new HashMap<String, SyndEntry>();
+
+ public CustomerCollectionImpl() {
+
+ for (int i = 0; i < 4; i++) {
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+
+ SyndEntry entry = new SyndEntryImpl();
+ entry.setTitle("customer " + "Jane Doe_" + String.valueOf(i));
+ entry.setUri(id);
+
+ SyndContent content = new SyndContentImpl();
+ content.setValue("Jane Doe_" + String.valueOf(i));
+ content.setType("text");
+ entry.setContents(Collections.singletonList(content));
+
+ List<SyndLink> links = new ArrayList<SyndLink>();
+ SyndLink link = new SyndLinkImpl();
+ link.setRel("edit");
+ link.setHref("" + id);
+ links.add(link);
+ entry.setLinks(links);
+
+ links = new ArrayList<SyndLink>();
+ link = new SyndLinkImpl();
+ link.setRel("alternate");
+ link.setHref("" + id);
+ links.add(link);
+ entry.setLinks(links);
+
+ entry.setPublishedDate(new Date());
+
+ entries.put(id, entry);
+ System.out.println(">>> id=" + id);
+ }
+ }
+
+ public SyndFeed getFeed() {
+ System.out.println(">>> CustomerCollectionImpl.getFeed");
+
+ SyndFeed feed = new SyndFeedImpl();
+ feed.setTitle("customers");
+ feed.setDescription("This is a sample feed");
+ feed.getEntries().addAll(entries.values());
+ return feed;
+ }
+
+ public SyndFeed query(String queryString) {
+ System.out.println(">>> CustomerCollectionImpl.query");
+
+ SyndFeed feed = new SyndFeedImpl();
+ feed.setTitle("customers");
+ feed.setDescription("This is a sample feed");
+ feed.getEntries().addAll(entries.values());
+ return feed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public SyndEntry get(String id) throws NotFoundException {
+ final SyndEntry entry = entries.get(id);
+ if (id == null) {
+ throw new NotFoundException("No entry found with ID " + id);
+ }
+
+ return entry;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java
new file mode 100644
index 0000000000..6dc23ac503
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.rss;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class Provider {
+
+ public static void main(String[] args) {
+
+
+ String contribution = ContributionLocationHelper.getContributionLocation(Provider.class);
+ Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/feed/Provider.composite", new Contribution("provider", contribution));
+
+ node.start();
+
+ System.out.println("Provider.composite ready...");
+
+ try {
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java
new file mode 100644
index 0000000000..5a786f3bd0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.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.rss;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Basic test case that will get the feed entries from an RSS feed.
+ */
+public class RSSGetTestCase {
+ protected static Node scaConsumerNode;
+ protected static Node scaProviderNode;
+ protected static CustomerClient testService;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println(">>>RSSGetTestCase.init entry");
+ String contribution = ContributionLocationHelper.getContributionLocation(RSSGetTestCase.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Provider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ scaConsumerNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Consumer.composite", new Contribution("consumer", contribution));
+ scaConsumerNode.start();
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // System.out.println(">>>RSSGetTestCase.destroy entry");
+ if (scaConsumerNode != null) {
+ scaConsumerNode.stop();
+ }
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(testService);
+ }
+
+ @Test
+ @Ignore("TUSCANY-3537")
+ public void testRSSGet() throws Exception {
+ testService.testCustomerCollection();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite
new file mode 100644
index 0000000000..22141805cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://customer"
+ name="Consumer">
+
+ <component name="CustomerClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.rss.CustomerClientImpl"/>
+ <reference name="resourceCollection">
+ <tuscany:binding.rss uri="http://localhost:8084/customer"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite
new file mode 100644
index 0000000000..b2b1f3d776
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace = "http://customer"
+ name="Provider">
+
+ <service name="customer" promote="CustomerCollection">
+ <tuscany:binding.rss uri = "http://localhost:8084/customer"/>
+ </service>
+
+ <component name="CustomerCollection">
+ <implementation.java class="org.apache.tuscany.sca.binding.rss.CustomerCollectionImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/LICENSE b/sandbox/sebastien/java/embed/modules/binding-rss/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/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/sebastien/java/embed/modules/binding-rss/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-rss/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a0886018d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rss;
+ uses:="org.apache.tuscany.sca.assembly";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA RSS Feed Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA RSS Feed Binding Extension
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.rss;version="2.0.0",
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rss
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/NOTICE b/sandbox/sebastien/java/embed/modules/binding-rss/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/pom.xml b/sandbox/sebastien/java/embed/modules/binding-rss/pom.xml
new file mode 100644
index 0000000000..a52b183471
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-rss</artifactId>
+ <name>Apache Tuscany SCA RSS Feed Binding Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBinding.java b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBinding.java
new file mode 100644
index 0000000000..bda3210e73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBinding.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * RSS Feed binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RSSBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.rss");
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBindingFactory.java
new file mode 100644
index 0000000000..3e691e636e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBindingFactory.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 org.apache.tuscany.sca.binding.rss;
+
+/**
+ * Factory for the RSS binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RSSBindingFactory {
+
+ /**
+ * Creates a new RSS binding.
+ * @return the new RSS binding
+ */
+ RSSBinding createRSSBinding();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingFactoryImpl.java
new file mode 100644
index 0000000000..a4e6a8283d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingFactoryImpl.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 org.apache.tuscany.sca.binding.rss.impl;
+
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+import org.apache.tuscany.sca.binding.rss.RSSBindingFactory;
+
+/**
+ * Factory for the RSS binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RSSBindingFactoryImpl implements RSSBindingFactory {
+
+ public RSSBinding createRSSBinding() {
+ return new RSSBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingImpl.java
new file mode 100644
index 0000000000..00abffafb5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingImpl.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.sca.binding.rss.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+
+/**
+ * Implementation of the RSS Feed binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSBindingImpl implements RSSBinding {
+
+ private String name;
+ private String uri;
+
+ public QName getType() {
+ return RSSBinding.TYPE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory
new file mode 100644
index 0000000000..73c47a3f41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.rss.impl.RSSBindingFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..d298c16673
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.rss,model=org.apache.tuscany.sca.binding.rss.RSSBinding,factory=org.apache.tuscany.sca.binding.rss.RSSBindingFactory
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/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/sebastien/java/embed/modules/binding-sca-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..0732ffc0d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,43 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.sca.provider;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Default Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Default Binding Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.sca.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.binding.sca.provider;version="2.0.0";
+ uses:="org.apache.tuscany.sca.databinding,
+ org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.provider,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.interfacedef,
+ javax.xml.namespace,
+ org.apache.tuscany.sca.invocation,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.assembly.builder"
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/pom.xml
new file mode 100644
index 0000000000..3d260a30e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/pom.xml
@@ -0,0 +1,72 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <name>Apache Tuscany SCA Binding SCA Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java
new file mode 100644
index 0000000000..4105c74efc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DefaultSCABindingMapper.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.provider;
+
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+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.extensibility.ServiceDeclarationParser;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.provider.ProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Default implementation of SCABindingMapper
+ */
+public class DefaultSCABindingMapper implements SCABindingMapper {
+ private final static Logger logger = Logger.getLogger(DefaultSCABindingMapper.class.getName());
+ protected ExtensionPointRegistry registry;
+ protected ProviderFactoryExtensionPoint providerFactories;
+ protected StAXArtifactProcessor processor;
+ protected BindingBuilder builder;
+ protected QName mappedBinding;
+ private Binding bindingTemplate;
+ private boolean remotable;
+
+ public DefaultSCABindingMapper(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ this.registry = registry;
+ if (attributes != null) {
+ String qname = attributes.get("mappedBinding");
+ if (qname != null) {
+ mappedBinding = ServiceDeclarationParser.getQName(qname);
+ }
+ }
+ if (mappedBinding == null) {
+ String qname =
+ System.getProperty("org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper.mappedBinding");
+ if (qname != null) {
+ mappedBinding = ServiceDeclarationParser.getQName(qname);
+ } else {
+ // By default, mapping to binding.ws or if thats not available then binding.rmi
+ mappedBinding = new QName(Base.SCA11_TUSCANY_NS, "binding.hazelcast");
+ if (registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class).getProcessor(mappedBinding) == null) {
+ mappedBinding = new QName(Base.SCA11_NS, "binding.ws");
+ if (registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class).getProcessor(mappedBinding) == null) {
+ mappedBinding = new QName(Base.SCA11_TUSCANY_NS, "binding.rmi");
+ }
+ }
+ }
+ }
+
+ providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ StAXArtifactProcessorExtensionPoint processors =
+ registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ processor = processors.getProcessor(mappedBinding);
+ if (processor == null) {
+ logger.warning("Mapped binding for binding.sca is not supported: " + mappedBinding);
+ }
+
+ try {
+ if (processor != null) {
+ bindingTemplate = createDelegatingBinding();
+ ProviderFactory providerFactory = providerFactories.getProviderFactory(bindingTemplate.getClass());
+ if (providerFactory == null) {
+ logger.warning("Mapped binding for binding.sca is not supported: " + mappedBinding);
+ processor = null;
+ }
+ }
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ BuilderExtensionPoint builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ builder = builders.getBindingBuilder(mappedBinding);
+ remotable = isDistributed() && processor != null;
+ }
+
+ // FIXME: [rfeng] This is a HACK to check if we should make binding.sca remotable
+ // by checking if we have distributed domain registry present
+ private boolean isDistributed() {
+ DomainRegistryFactoryExtensionPoint factories =
+ registry.getExtensionPoint(DomainRegistryFactoryExtensionPoint.class);
+ List<DomainRegistryFactory> list = factories.getDomainRegistryFactories();
+ if (list.size() == 1) {
+ String[] schemes = list.get(0).getSupportedSchemes();
+ if (Arrays.asList(schemes).contains("local")) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public RuntimeEndpoint map(RuntimeEndpoint endpoint) {
+ if (processor == null) {
+ return null;
+ }
+ // create a copy of the endpoint but with the web service binding in
+ RuntimeEndpoint ep = null;
+ try {
+ ep = (RuntimeEndpoint)endpoint.clone();
+ } catch (Exception ex) {
+ // we know we can clone endpoint references
+ }
+
+ Binding binding = map(endpoint.getBinding());
+ ep.setBinding(binding);
+ if (builder != null) {
+ builder.build(ep.getComponent(), ep.getService(), binding, new BuilderContext(registry), false);
+ }
+ return ep;
+ }
+
+ public RuntimeEndpointReference map(RuntimeEndpointReference endpointReference) {
+ if (processor == null) {
+ return null;
+ }
+ // create a copy of the endpoint but with the web service binding in
+ RuntimeEndpointReference epr = null;
+ try {
+ epr = (RuntimeEndpointReference)endpointReference.clone();
+ } catch (Exception ex) {
+ // we know we can clone endpoint references
+ }
+
+ Binding binding = map(endpointReference.getBinding());
+ epr.setBinding(binding);
+
+ // epr.setTargetEndpoint(map((RuntimeEndpoint)epr.getTargetEndpoint()));
+
+ if (builder != null) {
+ builder.build(epr.getComponent(), epr.getReference(), binding, new BuilderContext(registry), false);
+ }
+
+ return epr;
+ }
+
+ protected Binding map(Binding scaBinding) {
+ try {
+ Binding binding = createDelegatingBinding();
+ binding.setName(scaBinding.getName());
+ binding.setURI(scaBinding.getURI());
+ binding.setOperationSelector(scaBinding.getOperationSelector());
+ binding.setRequestWireFormat(scaBinding.getRequestWireFormat());
+ binding.setResponseWireFormat(scaBinding.getResponseWireFormat());
+ if (binding instanceof PolicySubject && scaBinding instanceof PolicySubject) {
+ PolicySubject subject1 = (PolicySubject)binding;
+ PolicySubject subject2 = (PolicySubject)scaBinding;
+ subject1.getPolicySets().addAll(subject2.getPolicySets());
+ subject1.getRequiredIntents().addAll(subject2.getRequiredIntents());
+ }
+ return binding;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ }
+
+ private Binding createDelegatingBinding() throws XMLStreamException, ContributionReadException {
+ if (bindingTemplate != null) {
+ try {
+ return (Binding)bindingTemplate.clone();
+ } catch (CloneNotSupportedException e) {
+ // Ignore
+ }
+ }
+ // This is a hack to create an instance of the binding using the XML QName
+ StringBuffer xml = new StringBuffer();
+ xml.append("<").append(mappedBinding.getLocalPart()).append(" xmlns:b=\"").append(mappedBinding
+ .getNamespaceURI()).append("\"/>");
+
+ StAXHelper staxHelper = StAXHelper.getInstance(registry);
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(new StringReader(xml.toString()));
+ reader.nextTag();
+ Binding binding = (Binding)processor.read(reader, new ProcessorContext(registry));
+ return binding;
+ }
+
+ public boolean isRemotable() {
+ return remotable;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java
new file mode 100644
index 0000000000..a8fec07f5c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.provider;
+
+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.EndpointReferenceProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * The reference binding provider for the remote sca binding implementation.
+ */
+public class DelegatingSCAReferenceBindingProvider implements EndpointReferenceProvider {
+
+ private ReferenceBindingProvider provider;
+
+ public DelegatingSCAReferenceBindingProvider(RuntimeEndpointReference endpointReference,
+ SCABindingMapper mapper) {
+ RuntimeEndpointReference epr = mapper.map(endpointReference);
+ if (epr != null) {
+ provider = epr.getBindingProvider();
+ }
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return provider.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return provider.supportsOneWayInvocation();
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return provider.createInvoker(operation);
+ }
+
+ public void start() {
+ provider.start();
+ }
+
+ public void stop() {
+ provider.stop();
+ }
+
+ public void configure() {
+ if (provider instanceof EndpointReferenceProvider) {
+ ((EndpointReferenceProvider)provider).configure();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAServiceBindingProvider.java
new file mode 100644
index 0000000000..ca90878633
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAServiceBindingProvider.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.sca.binding.sca.provider;
+
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * The service binding provider for the remote sca binding implementation. Relies on the
+ * binding-ws-axis implementation for providing a remote message endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class DelegatingSCAServiceBindingProvider implements ServiceBindingProvider {
+
+ private static final Logger logger = Logger.getLogger(DelegatingSCAServiceBindingProvider.class.getName());
+
+ private ServiceBindingProvider provider;
+ private RuntimeEndpoint endpoint;
+ private RuntimeEndpoint mappedEndpoint;
+ private boolean started = false;
+
+ public DelegatingSCAServiceBindingProvider(RuntimeEndpoint endpoint, SCABindingMapper mapper) {
+ this.endpoint = endpoint;
+ this.mappedEndpoint = mapper.map(endpoint);
+ if (mappedEndpoint != null) {
+ provider = mappedEndpoint.getBindingProvider();
+ }
+
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return provider.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return provider.supportsOneWayInvocation();
+ }
+
+ public void start() {
+ if (started) {
+ return;
+ } else {
+ provider.start();
+ // Set the resolved binding URI back to the binding.sca
+ endpoint.getBinding().setURI(mappedEndpoint.getBinding().getURI());
+ started = true;
+ }
+ }
+
+ public void stop() {
+ if (!started) {
+ return;
+ }
+ try {
+ provider.stop();
+ } finally {
+ started = false;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java
new file mode 100644
index 0000000000..331f152b50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.provider;
+
+/**
+ * TODO: TUSCANY-2578, implement a pluggable mechanism so sca binding impls can
+ * add their own code to the decision on whether or not to use
+ * the remote binding provider.
+ */
+public class RemoteBindingHelper {
+
+ private static boolean alwaysRemote;
+ static {
+ try {
+ Class.forName("org.apache.tuscany.sca.binding.sca.jms.JMSSCABindingProviderFactory");
+ alwaysRemote = true;
+ } catch (ClassNotFoundException e) {
+ alwaysRemote = false;
+ }
+ }
+
+ public static boolean isTargetRemote() {
+ return alwaysRemote;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java
new file mode 100644
index 0000000000..393b8f400c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.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 org.apache.tuscany.sca.binding.sca.provider;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * The factory for creating SCA Binding providers
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeSCABindingProviderFactory implements BindingProviderFactory<SCABinding> {
+
+ private ExtensionPointRegistry extensionPoints;
+
+ public RuntimeSCABindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+
+ return new RuntimeSCAReferenceBindingProvider(extensionPoints, endpointReference);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new RuntimeSCAServiceBindingProvider(extensionPoints, endpoint);
+ }
+
+ public Class<SCABinding> getModelType() {
+ return SCABinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
new file mode 100644
index 0000000000..08f2bee3b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.provider;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+/**
+ * The sca reference binding provider mediates between the twin requirements of
+ * local sca bindings and remote sca bindings. In the local case is does
+ * very little. When the sca binding model is set as being remote (because a
+ * reference target can't be resolved in the current model) this binding will
+ * try and create a remote connection to it
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeSCAReferenceBindingProvider implements EndpointReferenceProvider {
+
+ private RuntimeEndpointReference endpointReference;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private SCABinding binding;
+ private boolean remotable;
+ private boolean started = false;
+
+ private ReferenceBindingProvider distributedProvider;
+ private Mediator mediator;
+ private InterfaceContractMapper interfaceContractMapper;
+ private SCABindingMapper scaBindingMapper;
+
+ public RuntimeSCAReferenceBindingProvider(ExtensionPointRegistry extensionPoints,
+ RuntimeEndpointReference endpointReference) {
+ this.endpointReference = endpointReference;
+ this.component = (RuntimeComponent)endpointReference.getComponent();
+ this.reference = (RuntimeComponentReference)endpointReference.getReference();
+ this.binding = (SCABinding)endpointReference.getBinding();
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.mediator = utilities.getUtility(Mediator.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ this.scaBindingMapper = utilities.getUtility(SCABindingMapper.class);
+ remotable = isTargetRemote();
+ getDistributedProvider();
+ }
+
+ private boolean isTargetRemote() {
+ return endpointReference.getTargetEndpoint().isRemote();
+ }
+
+ private ReferenceBindingProvider getDistributedProvider() {
+
+ if (remotable) {
+ // initialize the remote provider if it hasn't been done already
+ if (distributedProvider == null) {
+ if (reference.getInterfaceContract() != null && !reference.getInterfaceContract().getInterface()
+ .isRemotable()) {
+ throw new ServiceRuntimeException("Reference interface not remotable for component: " + component
+ .getName()
+ + " and reference: "
+ + reference.getName());
+ }
+
+ if (scaBindingMapper.isRemotable()) {
+ distributedProvider =
+ new DelegatingSCAReferenceBindingProvider(endpointReference, scaBindingMapper);
+ }
+ }
+ }
+
+ return distributedProvider;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ if (remotable && distributedProvider != null) {
+ return distributedProvider.getBindingInterfaceContract();
+ } else {
+ // Check if there is a target
+ RuntimeEndpoint endpoint = (RuntimeEndpoint)endpointReference.getTargetEndpoint();
+ if (endpoint != null) {
+ return endpoint.getComponentTypeServiceInterfaceContract();
+ } else {
+ return endpointReference.getComponentTypeReferenceInterfaceContract();
+ }
+ }
+ }
+
+ public boolean supportsOneWayInvocation() {
+ if (remotable && distributedProvider != null) {
+ return distributedProvider.supportsOneWayInvocation();
+ } else {
+ return false;
+ }
+ }
+
+ private Invoker getInvoker(RuntimeEndpointReference epr, Operation operation) {
+ Endpoint target = epr.getTargetEndpoint();
+ if (target != null) {
+ RuntimeComponentService service = (RuntimeComponentService)target.getService();
+ if (service != null) { // not a callback wire
+ InvocationChain chain = ((RuntimeEndpoint)target).getInvocationChain(operation);
+
+ boolean passByValue = false;
+ Operation targetOp = chain.getTargetOperation();
+ if (!operation.getInterface().isRemotable()) {
+ if (interfaceContractMapper.isCompatibleByReference(operation, targetOp, Compatibility.SUBSET)) {
+ passByValue = false;
+ }
+ } else {
+// boolean allowsPBR = chain.allowsPassByReference(); TODO: TUSCANY-3479 this breaks the conformance tests as it needs to consider _both_ ends
+ boolean allowsPBR = false;
+ if (allowsPBR && interfaceContractMapper.isCompatibleByReference(operation,
+ targetOp,
+ Compatibility.SUBSET)) {
+ passByValue = false;
+ } else if (interfaceContractMapper.isCompatibleByValue(operation, targetOp, Compatibility.SUBSET)) {
+ passByValue = true;
+ }
+ }
+ // it turns out that the chain source and target operations are the same, and are the operation
+ // from the target, not sure if thats by design or a bug. The SCA binding invoker needs to know
+ // the source and target class loaders so pass in the real source operation in the constructor
+ return chain == null ? null : new SCABindingInvoker(chain, operation, mediator, passByValue, epr);
+ }
+ }
+ return null;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ if (remotable && distributedProvider != null) {
+ return distributedProvider.createInvoker(operation);
+ } else {
+ Invoker invoker = getInvoker(endpointReference, operation);
+ if (invoker == null) {
+ throw new ServiceUnavailableException(
+ "Unable to create SCA binding invoker for local target " + component
+ .getName()
+ + " reference "
+ + reference.getName()
+ + " (bindingURI="
+ + binding.getURI()
+ + " operation="
+ + operation.getName()
+ + ")");
+ }
+ return invoker;
+ }
+ }
+
+ public void start() {
+ if (started) {
+ return;
+ }
+ if (distributedProvider != null) {
+ distributedProvider.start();
+ }
+ started = true;
+ }
+
+ public void stop() {
+ if (!started) {
+ return;
+ }
+
+ try {
+ if (distributedProvider != null) {
+ distributedProvider.stop();
+ }
+ } finally {
+ started = false;
+ }
+ }
+
+ public void configure() {
+ if (distributedProvider instanceof EndpointReferenceProvider) {
+ ((EndpointReferenceProvider)distributedProvider).configure();
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
new file mode 100644
index 0000000000..14d7284846
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.sca.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * The sca service binding provider mediates between the twin requirements of
+ * local sca bindings and remote sca bindings. In the local case is does
+ * very little. When the sca binding model is set as being remote this binding will
+ * try and create a remote service endpoint for remote references to connect to
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider {
+ private RuntimeEndpoint endpoint;
+ private RuntimeComponentService service;
+
+ private ServiceBindingProvider distributedProvider;
+ private SCABindingMapper scaBindingMapper;
+
+ public RuntimeSCAServiceBindingProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.endpoint = endpoint;
+ this.service = (RuntimeComponentService)endpoint.getService();
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.scaBindingMapper = utilities.getUtility(SCABindingMapper.class);
+
+ // if there is potentially a wire to this service that crosses the node boundary
+ // then we need to create a remote endpoint
+ if (service.getInterfaceContract().getInterface().isRemotable()) {
+
+ if (scaBindingMapper.isRemotable()) {
+ distributedProvider = new DelegatingSCAServiceBindingProvider(endpoint, scaBindingMapper);
+ }
+ }
+ }
+
+ /*
+ protected boolean isDistributed(ExtensionPointRegistry extensionPoints, Endpoint endpoint) {
+ // find if the node config is for distributed endpoints
+ // TODO: temp, need a much better way to do this
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPoints);
+ Collection<EndpointRegistry> eprs = domainRegistryFactory.getEndpointRegistries();
+ if (eprs.size() > 0) {
+ String eprName = eprs.iterator().next().getClass().getName();
+ return !eprName.equals("org.apache.tuscany.sca.core.assembly.impl.EndpointRegistryImpl");
+ }
+ return false;
+ }
+ */
+
+ public InterfaceContract getBindingInterfaceContract() {
+ if (distributedProvider != null) {
+ return distributedProvider.getBindingInterfaceContract();
+ } else {
+ return endpoint.getComponentTypeServiceInterfaceContract();
+ }
+ }
+
+ public boolean supportsOneWayInvocation() {
+ if (distributedProvider != null) {
+ return distributedProvider.supportsOneWayInvocation();
+ }
+ return false;
+ }
+
+ public void start() {
+ if (distributedProvider != null) {
+ distributedProvider.start();
+ }
+ }
+
+ public void stop() {
+ if (distributedProvider != null) {
+ distributedProvider.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
new file mode 100644
index 0000000000..c2a9038367
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.sca.provider;
+
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCABindingInvoker implements Interceptor {
+ private InvocationChain chain;
+ private Mediator mediator;
+ private Operation sourceOperation;
+ private Operation targetOperation;
+ private boolean passByValue;
+ private RuntimeEndpointReference epr;
+ private RuntimeEndpoint ep;
+
+ /**
+ * Construct a SCABindingInvoker that delegates to the service invocaiton chain
+ */
+ public SCABindingInvoker(InvocationChain chain, Operation sourceOperation, Mediator mediator, boolean passByValue, RuntimeEndpointReference epr) {
+ super();
+ this.chain = chain;
+ this.mediator = mediator;
+ this.sourceOperation = sourceOperation;
+ this.targetOperation = chain.getTargetOperation();
+ this.passByValue = passByValue;
+ this.epr = epr;
+ this.ep = (RuntimeEndpoint)epr.getTargetEndpoint();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#getNext()
+ */
+ public Invoker getNext() {
+ return chain.getHeadInvoker(Phase.SERVICE_POLICY);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#setNext(org.apache.tuscany.sca.invocation.Invoker)
+ */
+ public void setNext(Invoker next) {
+ // NOOP
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message)
+ */
+ public Message invoke(Message msg) {
+
+ if (passByValue) {
+ msg.setBody(mediator.copyInput(msg.getBody(), sourceOperation, targetOperation));
+ }
+
+ ep.getInvocationChains();
+ if ( !ep.getCallbackEndpointReferences().isEmpty() ) {
+ RuntimeEndpointReference asyncEPR = (RuntimeEndpointReference) ep.getCallbackEndpointReferences().get(0);
+ // Place a link to the callback EPR into the message headers...
+ msg.getHeaders().put("ASYNC_CALLBACK", asyncEPR );
+ }
+
+ Message resultMsg = getNext().invoke(msg);
+
+ if (passByValue) {
+ // Note source and target operation swapped so result is in source class loader
+ if (resultMsg.isFault()) {
+ resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), sourceOperation, targetOperation));
+ } else {
+ if (sourceOperation.getOutputType() != null) {
+ resultMsg.setBody(mediator.copyOutput(resultMsg.getBody(), sourceOperation, targetOperation));
+ }
+ }
+ }
+
+ return resultMsg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingMapper.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingMapper.java
new file mode 100644
index 0000000000..03aa44a04e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingMapper.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.binding.sca.provider;
+
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * SCABindingMapper allows us to map binding.sca to any of the bindings available to the runtime
+ */
+public interface SCABindingMapper {
+
+ /**
+ * Map an endpoint with binding.sca to an endpoint
+ * @param endpoint The endpoint for binding.sca
+ * @return The endpoint for the mapped binding
+ */
+ public RuntimeEndpoint map(RuntimeEndpoint endpoint);
+
+ /**
+ * Map an endpoint reference with binding.sca to an endpoint reference with the mapped binding
+ * @param endpointReference
+ * @return The endpoint reference for the mapped binding
+ */
+ public RuntimeEndpointReference map(RuntimeEndpointReference endpointReference);
+
+ /**
+ * Check if the remote SCA binding is supported
+ * @return
+ */
+ boolean isRemotable();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper
new file mode 100644
index 0000000000..2719598883
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.binding.sca.provider.DefaultSCABindingMapper \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..151c00eec8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/binding/sca/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..86e3d1e829
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.sca.provider.RuntimeSCABindingProviderFactory;model=org.apache.tuscany.sca.assembly.SCABinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
new file mode 100644
index 0000000000..1cfce8fa87
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- MJE 22/06/2010 - add asyncInvocation to the @mayProvide list, for async services support -->
+ <sca:bindingType type="sca:binding.sca" mayProvide="sca:asyncInvocation" alwaysProvides=""/>
+ </sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java
new file mode 100644
index 0000000000..d968e2891d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apace.tuscany.sca.binding.sca;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.xml.CompositeModelResolver;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * SCABindingTestCase
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCABindingTestCase {
+
+ private XMLInputFactory inputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private CompositeModelResolver resolver;
+ private ExtensionPointRegistry extensionPoints;
+
+ @Before
+ public void init() throws Exception {
+ extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+
+ resolver = new CompositeModelResolver(null, null);
+ }
+
+ @Test
+ public void testSCABindingFactory() {
+ SCABindingFactory factory =
+ extensionPoints.getExtensionPoint(FactoryExtensionPoint.class).getFactory(SCABindingFactory.class);
+
+ Assert.assertNotNull(factory.createSCABinding());
+ }
+
+ @Test
+ @Ignore
+ public void testBuildModel() {
+ try {
+ InputStream is = getClass().getResourceAsStream("/Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ProcessorContext context = new ProcessorContext(extensionPoints);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+
+ is.close();
+ Assert.assertNotNull(composite);
+
+ resolver.addModel(composite, context);
+
+ staxProcessor.resolve(composite, resolver, new ProcessorContext());
+
+ SCABinding referenceSCABinding =
+ (SCABinding)composite.getComponents().get(0).getReferences().get(0).getBindings().get(0);
+ SCABinding serviceSCABinding =
+ (SCABinding)composite.getComponents().get(1).getServices().get(0).getBindings().get(0);
+
+ Assert.assertNotNull(referenceSCABinding);
+ Assert.assertNotNull(serviceSCABinding);
+ } catch (Exception ex) {
+ Assert.fail(ex.getMessage());
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java
new file mode 100644
index 0000000000..895a551f79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.apace.tuscany.sca.binding.sca.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("/CalculatorServiceImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ComponentType componentType = (ComponentType)staxProcessor.read(reader, context);
+ assertNotNull(componentType);
+
+ SCABinding referenceSCABinding = (SCABinding) componentType.getReferences().get(0).getBindings().get(0);
+ assertNotNull(referenceSCABinding);
+
+ SCABinding serviceSCABinding = (SCABinding) componentType.getServices().get(0).getBindings().get(0);
+ assertNotNull(serviceSCABinding);
+
+ //new PrintUtil(System.out).print(componentType);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("/Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+
+ SCABinding referenceSCABinding = (SCABinding) composite.getComponents().get(0).getReferences().get(0).getBindings().get(0);
+ SCABinding serviceSCABinding = (SCABinding) composite.getComponents().get(1).getServices().get(0).getBindings().get(0);
+
+ Assert.assertNotNull(referenceSCABinding);
+ Assert.assertNotNull(serviceSCABinding);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java
new file mode 100644
index 0000000000..93bd129a65
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.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.apace.tuscany.sca.binding.sca.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test reading/write WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase {
+
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ @Ignore // broken in 2.0 bring up
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("/CalculatorServiceImpl.componentType");
+ ComponentType componentType = (ComponentType)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(componentType);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos), context);
+ assertEquals("<?xml version='1.0' encoding='UTF-8'?><componentType xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" ><service name=\"CalculatorService\"><binding.sca /><interface.java interface=\"calculator.CalculatorService\" /></service><reference name=\"addService\"><binding.sca /><interface.java interface=\"calculator.AddService\" /></reference></componentType>",
+ bos.toString());
+ }
+
+ @Test
+ @Ignore // broken in 2.0 bring up
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("/Calculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(composite);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+ assertEquals("<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://calc\" name=\"Calculator\"><service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><binding.sca /><interface.java interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><implementation.java class=\"calculator.CalculatorServiceImpl\" /><reference name=\"addService\" target=\"AddServiceComponent\"><binding.sca /></reference><reference name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\" /></component><component name=\"AddServiceComponent\"><implementation.java class=\"calculator.AddServiceImpl\" /><service name=\"AddService\"><binding.sca /><interface.java interface=\"calculator.AddService\" /></service></component><component name=\"SubtractServiceComponent\"><implementation.java class=\"calculator.SubtractServiceImpl\" /></component><component name=\"MultiplyServiceComponent\"><implementation.java class=\"calculator.MultiplyServiceImpl\" /></component><component name=\"DivideServiceComponent\"><implementation.java class=\"calculator.DivideServiceImpl\" /></component></composite>",
+ bos.toString());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/resources/Calculator.composite b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/resources/Calculator.composite
new file mode 100644
index 0000000000..1847b2b452
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/resources/Calculator.composite
@@ -0,0 +1,59 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="Calculator">
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ <binding.sca/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent">
+ <binding.sca/>
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ <service name="AddService">
+ <interface.java interface="calculator.AddService"/>
+ <binding.sca/>
+ </service>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType
new file mode 100644
index 0000000000..da4219759f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ <binding.sca/>
+ </service>
+
+ <reference name="addService">
+ <interface.java interface="calculator.AddService" />
+ <binding.sca/>
+ </reference>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/LICENSE b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/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/sebastien/java/embed/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2ad383d9f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
@@ -0,0 +1,151 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.ws.axis2;version="2.0.0";
+ uses:="org.apache.axis2.deployment.util,
+ org.apache.tuscany.sca.definitions,
+ org.apache.ws.security.handler,
+ javax.xml.namespace,
+ org.apache.axiom.om,
+ org.xml.sax,
+ org.apache.commons.httpclient,
+ org.apache.axiom.soap,
+ org.apache.axis2.util,
+ javax.servlet,
+ javax.xml.stream,
+ org.apache.tuscany.sca.core.assembly,
+ org.apache.axis2.transport.http.server,
+ org.oasisopen.sca,
+ org.apache.axis2.i18n,
+ org.apache.axis2.transport,
+ org.apache.axis2.transport.jms,
+ org.apache.axis2.client,
+ org.apache.axis2.context,
+ org.apache.axiom.om.impl.builder,
+ org.apache.tuscany.sca.interfacedef.java,
+ org.w3c.dom,
+ javax.wsdl,
+ org.apache.tuscany.sca.xsd.xml,
+ org.apache.tuscany.sca.binding.ws,
+ org.apache.axis2.engine,
+ org.apache.axis2.receivers,
+ org.apache.commons.httpclient.params,
+ org.apache.tuscany.sca.interfacedef.wsdl,
+ org.apache.tuscany.sca.xsd,
+ org.apache.tuscany.sca.databinding,
+ org.apache.axis2.addressing,
+ org.apache.axis2.deployment,
+ org.apache.axis2.transport.http,
+ org.apache.axis2.transport.local,
+ org.apache.tuscany.sca.runtime,
+ org.apache.commons.logging,
+ org.apache.tuscany.sca.interfacedef.util,
+ org.apache.tuscany.sca.provider,
+ org.apache.tuscany.sca.core,
+ javax.xml.transform.dom,
+ org.apache.tuscany.sca.policy,
+ org.apache.axis2.description,
+ javax.wsdl.extensions,
+ org.apache.tuscany.sca.host.http,
+ org.apache.tuscany.sca.policy.util,
+ org.apache.axis2.util.threadpool,
+ org.apache.ws.security,
+ org.apache.axis2,
+ org.apache.ws.commons.schema,
+ org.apache.tuscany.sca.assembly,
+ org.apache.ws.commons.schema.resolver,
+ javax.wsdl.extensions.soap,
+ org.apache.tuscany.sca.interfacedef,
+ org.apache.tuscany.sca.invocation,
+ javax.xml.transform,
+ javax.wsdl.extensions.soap12,
+ org.apache.tuscany.sca.contribution.processor,
+ javax.servlet.http"
+Private-Package:
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Axis2-based WS Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Axis2-based WS Binding Extension
+Eclipse-RegisterBuddy: org.apache.axis2.kernel
+Import-Package: javax.activation;resolution:=optional,
+ javax.security.auth.callback;resolution:=optional,
+ javax.servlet,
+ javax.servlet.http,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.extensions.soap12,
+ javax.wsdl.factory;resolution:=optional,
+ javax.wsdl.xml;resolution:=optional,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.ws,
+ org.apache.axiom.om,
+ org.apache.axiom.om.impl.builder,
+ org.apache.axiom.om.util,
+ org.apache.axiom.soap,
+ org.apache.axis2,
+ org.apache.axis2.addressing,
+ org.apache.axis2.addressing.wsdl,
+ org.apache.axis2.client,
+ org.apache.axis2.context,
+ org.apache.axis2.deployment,
+ org.apache.axis2.deployment.util,
+ org.apache.axis2.description,
+ org.apache.axis2.engine,
+ org.apache.axis2.handlers,
+ org.apache.axis2.i18n,
+ org.apache.axis2.receivers,
+ org.apache.axis2.transport,
+ org.apache.axis2.transport.http,
+ org.apache.axis2.transport.http.server,
+ org.apache.axis2.transport.jms,
+ org.apache.axis2.transport.local,
+ org.apache.axis2.util,
+ org.apache.axis2.util.threadpool,
+ org.apache.commons.httpclient,
+ org.apache.commons.httpclient.params,
+ org.apache.commons.logging;resolution:=optional,
+ org.apache.neethi,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.common.xml;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.authentication.basic;version="2.0.0",
+ org.apache.tuscany.sca.policy.security;version="2.0.0",
+ org.apache.tuscany.sca.policy.security.http.ssl;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.tuscany.sca.xsd.xml;version="2.0.0",
+ org.apache.ws.commons.schema,
+ org.apache.ws.commons.schema.resolver,
+ org.apache.ws.security,
+ org.apache.ws.security.handler,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.ws.axis2
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,
+ JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/NOTICE b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/pom.xml b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/pom.xml
new file mode 100644
index 0000000000..c6a4253468
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/pom.xml
@@ -0,0 +1,436 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <name>Apache Tuscany SCA Axis2-1.5-based WS Binding Runtime</name>
+
+ <repositories>
+ <repository>
+ <id>apache.ws</id>
+ <name>Apache WebServices Repository</name>
+ <url>http://ws.zones.apache.org/repository/</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <!-- Compile dependencies -->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb-axiom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>1.5.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-java2wsdl</artifactId>
+ <version>1.5.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xom</groupId>
+ <artifactId>xom</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-codegen</artifactId>
+ <version>1.5.1</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-mtompolicy</artifactId>
+ <version>1.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>mex</artifactId>
+ <version>1.5.1</version>
+ <classifier>impl</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-http</artifactId>
+ <version>1.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-local</artifactId>
+ <version>1.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-jms</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-dom</artifactId>
+ <version>1.2.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.neethi</groupId>
+ <artifactId>neethi</artifactId>
+ <version>2.0.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore-nio</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-discovery</groupId>
+ <artifactId>commons-discovery</artifactId>
+ <version>0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.santuario</groupId>
+ <artifactId>xmlsec</artifactId>
+ <version>1.4.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.security</groupId>
+ <artifactId>wss4j</artifactId>
+ <version>1.5.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>bouncycastle</groupId>
+ <artifactId>bcprov-jdk13</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>bouncycastle</groupId>
+ <artifactId>bcprov-jdk15</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.rampart</groupId>
+ <artifactId>rampart-core</artifactId>
+ <version>1.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>addressing</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-xmlbeans</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>mex</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-codegen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb-codegen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>bouncycastle</groupId>
+ <artifactId>bcprov-jdk13</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>bouncycastle</groupId>
+ <artifactId>bcprov-jdk15</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- xerces, xalan, and xml-apis are required for running in websphere -->
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.0</version>
+ <scope>optional</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Test dependencies -->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java
new file mode 100644
index 0000000000..699846ead2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.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.binding.ws.axis2.policy.authentication.basic;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationPolicyProviderFactory implements PolicyProviderFactory<BasicAuthenticationPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public BasicAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new BasicAuthenticationReferencePolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new BasicAuthenticationServicePolicyProvider(endpoint);
+ }
+
+ public Class<BasicAuthenticationPolicy> getModelType() {
+ return BasicAuthenticationPolicy.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..04b46485d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.policy.authentication.basic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.HttpTransportProperties;
+import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationReferencePolicyInterceptor implements PhasedInterceptor {
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication");
+
+ private Invoker next;
+ private PolicySet policySet = null;
+ private String context;
+ private BasicAuthenticationPolicy policy;
+
+ public BasicAuthenticationReferencePolicyInterceptor(String context, PolicySet policySet) {
+ super();
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ // TODO - how to get the appropriate expression out of the
+ // policy set. Need WS Policy help here
+ if (policySet != null) {
+ for (PolicyExpression policyExpression : policySet.getPolicies()){
+ if (policyExpression.getPolicy() instanceof BasicAuthenticationPolicy){
+ policy = (BasicAuthenticationPolicy)policyExpression.getPolicy();
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+
+ OperationClient operationClient = msg.getBindingContext();
+
+ String username = null;
+ String password = null;
+
+ // get the security context
+ Subject subject = SecurityUtil.getSubject(msg);
+ BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject,
+ BasicAuthenticationPrincipal.class);
+
+ // could use the security principal to look up basic auth credentials
+ if ( principal != null ) {
+ username = ((BasicAuthenticationPrincipal)principal).getName();
+ password = ((BasicAuthenticationPrincipal)principal).getPassword();
+ } else if (policy != null ){
+ username = policy.getUserName();
+ password = policy.getPassword();
+
+ principal = new BasicAuthenticationPrincipal(username,
+ password);
+ subject.getPrincipals().add(principal);
+ }
+
+ if (username == null || password == null ){
+ throw new ServiceRuntimeException("Basic authentication username and/or password is null");
+ }
+
+ HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
+ List<String> auth = new ArrayList<String>();
+ auth.add(Authenticator.BASIC);
+ authenticator.setAuthSchemes(auth);
+ authenticator.setPreemptiveAuthentication(true);
+ authenticator.setUsername(username);
+ authenticator.setPassword(password);
+
+ operationClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE,
+ authenticator);
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_POLICY;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java
new file mode 100644
index 0000000000..d4b3851d97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationReferencePolicyProvider extends BasePolicyProvider<BasicAuthenticationPolicy> {
+
+ public BasicAuthenticationReferencePolicyProvider(EndpointReference endpointReference) {
+ super(BasicAuthenticationPolicy.class, endpointReference);
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ PolicySet ps = findPolicySet();
+ return ps == null ? null : new BasicAuthenticationReferencePolicyInterceptor(getContext(), ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java
new file mode 100644
index 0000000000..3d73410ae9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.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.sca.binding.ws.axis2.policy.authentication.basic;
+
+
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.util.Base64;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationServicePolicyInterceptor implements PhasedInterceptor {
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication");
+
+ private Invoker next;
+ private PolicySet policySet = null;
+ private String context;
+ private BasicAuthenticationPolicy policy;
+
+ public BasicAuthenticationServicePolicyInterceptor(String context, PolicySet policySet) {
+ super();
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ // TODO - how to get the appropriate expression out of the
+ // policy set. Need WS Policy help here
+ if (policySet != null) {
+ for (PolicyExpression policyExpression : policySet.getPolicies()){
+ if (policyExpression.getPolicy() instanceof BasicAuthenticationPolicy){
+ policy = (BasicAuthenticationPolicy)policyExpression.getPolicy();
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+
+ MessageContext messageContext = msg.getBindingContext();
+ Map httpHeaderProperties = (Map)messageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
+
+ String basicAuthString = (String)httpHeaderProperties.get("Authorization");
+ String decodedBasicAuthString = null;
+ String username = null;
+ String password = null;
+
+ if (basicAuthString != null) {
+ basicAuthString = basicAuthString.trim();
+
+ if (basicAuthString.startsWith("Basic ")) {
+ decodedBasicAuthString = new String(Base64.decode(basicAuthString.substring(6)));
+ }
+
+ int collonIndex = decodedBasicAuthString.indexOf(':');
+
+ if (collonIndex == -1){
+ username = decodedBasicAuthString;
+ } else {
+ username = decodedBasicAuthString.substring(0, collonIndex);
+ password = decodedBasicAuthString.substring(collonIndex + 1);
+ }
+ }
+
+ // get the security context
+ Subject subject = SecurityUtil.getSubject(msg);
+ BasicAuthenticationPrincipal principal = new BasicAuthenticationPrincipal(username,
+ password);
+ subject.getPrincipals().add(principal);
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_POLICY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java
new file mode 100644
index 0000000000..ec4536c309
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.policy.authentication.basic;
+
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationServicePolicyProvider extends BasePolicyProvider<BasicAuthenticationPolicy> {
+
+ public BasicAuthenticationServicePolicyProvider(Endpoint endpoint) {
+ super(BasicAuthenticationPolicy.class, endpoint);
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ PolicySet ps = findPolicySet();
+ return ps == null ? null : new BasicAuthenticationServicePolicyInterceptor(getContext(), ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
new file mode 100644
index 0000000000..ded09392ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.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.sca.binding.ws.axis2.policy.configuration;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicy {
+ private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName NAME = new QName(SCA11_TUSCANY_NS, "wsConfigParam");
+ private Map<String, OMElement> paramElements = new Hashtable<String, OMElement>();
+
+ public Map<String, OMElement> getParamElements() {
+ return paramElements;
+ }
+
+ public QName getSchemaName() {
+ return NAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java
new file mode 100644
index 0000000000..c13c009edf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.policy.configuration;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicyProcessor implements StAXArtifactProcessor<Axis2ConfigParamPolicy> {
+ public static final QName AXIS2_CONFIG_PARAM_POLICY_QNAME = Axis2ConfigParamPolicy.NAME;
+ public static final String PARAMETER = "parameter";
+ public QName getArtifactType() {
+ return AXIS2_CONFIG_PARAM_POLICY_QNAME;
+ }
+
+ public Axis2ConfigParamPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ public Axis2ConfigParamPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Axis2ConfigParamPolicy policy = new Axis2ConfigParamPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+ OMElement parameterElement = null;
+ String paramName = null;
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if ( PARAMETER.equals(name.getLocalPart()) ) {
+ paramName = reader.getAttributeValue(null, "name");
+ parameterElement = loadElement(reader);
+ policy.getParamElements().put(paramName, parameterElement);
+ }
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( AXIS2_CONFIG_PARAM_POLICY_QNAME.equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(Axis2ConfigParamPolicy arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<Axis2ConfigParamPolicy> getModelType() {
+ return Axis2ConfigParamPolicy.class;
+ }
+
+ public void resolve(Axis2ConfigParamPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+ private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement head = fac.createOMElement(reader.getName());
+ OMElement current = head;
+ while (true) {
+ switch (reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ //since the axis2 code checks against a no namespace we need to generate accordingly
+ QName name = new QName(reader.getName().getLocalPart());
+ OMElement child = fac.createOMElement(name, current);
+
+ int count = reader.getNamespaceCount();
+ for (int i = 0; i < count; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ child.declareNamespace(ns, prefix);
+ }
+
+ if(!"".equals(name.getNamespaceURI())) {
+ child.declareNamespace(name.getNamespaceURI(), name.getPrefix());
+ }
+
+ // add the attributes for this element
+ count = reader.getAttributeCount();
+ for (int i = 0; i < count; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+
+ if (ns != null) {
+ child.addAttribute(qname, value, fac.createOMNamespace(ns, prefix));
+ child.declareNamespace(ns, prefix);
+ } else {
+ child.addAttribute(qname, value, null);
+ }
+ }
+ current = child;
+ break;
+ case XMLStreamConstants.CDATA:
+ fac.createOMText(current, reader.getText());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ fac.createOMText(current, reader.getText());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if ( current == head ) {
+ return head;
+ } else {
+ current = (OMElement)current.getParent();
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java
new file mode 100644
index 0000000000..a77f71b734
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.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.binding.ws.axis2.policy.configuration;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicyProvider extends BasePolicyProvider<Axis2ConfigParamPolicy> {
+
+ public Axis2ConfigParamPolicyProvider(PolicySubject subject) {
+ super(Axis2ConfigParamPolicy.class, subject);
+ }
+
+ public void configureBinding(Object context) {
+ ConfigurationContext configurationContext = ((Axis2BaseBindingProvider)context).getAxisConfigurationContext();
+ Axis2ConfigParamPolicy axis2ConfigParamPolicy = null;
+ Parameter configParam = null;
+ for (Object policy : findPolicies()) {
+ if (policy instanceof Axis2ConfigParamPolicy) {
+ axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy;
+ for (String paramName : axis2ConfigParamPolicy.getParamElements().keySet()) {
+ configParam =
+ new Parameter(paramName, axis2ConfigParamPolicy.getParamElements().get(paramName)
+ .getFirstElement());
+ configParam.setParameterElement(axis2ConfigParamPolicy.getParamElements().get(paramName));
+ try {
+ configurationContext.getAxisConfiguration().addParameter(configParam);
+ } catch (AxisFault e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java
new file mode 100644
index 0000000000..c4c93cd33d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.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.sca.binding.ws.axis2.policy.configuration;
+
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicyProviderFactory implements PolicyProviderFactory<Axis2ConfigParamPolicy> {
+
+ public Axis2ConfigParamPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new Axis2ConfigParamPolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new Axis2ConfigParamPolicyProvider(endpoint);
+ }
+
+ public Class<Axis2ConfigParamPolicy> getModelType() {
+ return Axis2ConfigParamPolicy.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java
new file mode 100644
index 0000000000..e27da2bbd1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.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.binding.ws.axis2.policy.mtom;
+
+import org.apache.axis2.Constants.Configuration;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2MTOMPolicyProvider extends BasePolicyProvider<Object> {
+
+ public Axis2MTOMPolicyProvider(PolicySubject subject) {
+ super(Object.class, subject);
+ }
+
+ public void configureBinding(Object configuration) {
+
+ if (configuration instanceof ConfigurationContext){
+ ConfigurationContext configurationContext = (ConfigurationContext)configuration;
+ configurationContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setLocked(false);
+ configurationContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setValue("true");
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java
new file mode 100644
index 0000000000..8355c0fa4e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.policy.security.http.ssl;
+
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider;
+import org.apache.tuscany.sca.host.http.SecurityContext;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HTTPSPolicyProvider extends BasePolicyProvider<HTTPSPolicy> {
+ private final Logger logger = Logger.getLogger(HTTPSPolicyProvider.class.getName());
+
+ public HTTPSPolicyProvider(PolicySubject subject) {
+ super(HTTPSPolicy.class, subject);
+ }
+
+ public void configureBinding(Object context) {
+ SecurityContext securityContext = ((Axis2BaseBindingProvider)context).getHttpSecurityContext();
+
+ for (Object policy : findPolicies()) {
+ if (policy instanceof HTTPSPolicy) {
+ HTTPSPolicy httpsPolicy = (HTTPSPolicy)policy;
+
+ securityContext.setSSLEnabled(true);
+ securityContext.setSSLProperties(httpsPolicy.toProperties());
+
+ // TODO - what is the right way to set trust/key store on client side?
+
+ logger.info("HTTPSPolicyProvider: Setting JVM trust store to " + httpsPolicy.getTrustStore());
+ System.setProperty("javax.net.ssl.trustStore", httpsPolicy.getTrustStore());
+ System.setProperty("javax.net.ssl.trustStorePassword", httpsPolicy.getTrustStorePassword());
+ System.setProperty("javax.net.ssl.trustStoreType", httpsPolicy.getTrustStoreType());
+
+ logger.info("HTTPSPolicyProvider: Setting JVM key store to " + httpsPolicy.getKeyStore());
+ System.setProperty("javax.net.ssl.keyStore", httpsPolicy.getKeyStore());
+ System.setProperty("javax.net.ssl.keyStorePassword", httpsPolicy.getKeyStorePassword());
+ System.setProperty("javax.net.ssl.keyStoreType", httpsPolicy.getKeyStoreType());
+
+ return;
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java
new file mode 100644
index 0000000000..592300aaa3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.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.binding.ws.axis2.policy.security.http.ssl;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HTTPSPolicyProviderFactory implements PolicyProviderFactory<BasicAuthenticationPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public HTTPSPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new HTTPSPolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new HTTPSPolicyProvider(endpoint);
+ }
+
+ public Class<BasicAuthenticationPolicy> getModelType() {
+ return BasicAuthenticationPolicy.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BaseBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BaseBindingProvider.java
new file mode 100644
index 0000000000..dbefbf4a2d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BaseBindingProvider.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.sca.binding.ws.axis2.provider;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.host.http.SecurityContext;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+public class Axis2BaseBindingProvider {
+
+ // Tuscany extensions
+ protected ExtensionPointRegistry extensionPoints;
+ protected FactoryExtensionPoint modelFactories;
+ protected MessageFactory messageFactory;
+
+ // derived policy configuration
+ protected boolean isSOAP12Required = false;
+ protected boolean isSOAP11Required = false;
+ protected boolean isRampartRequired = false;
+ protected boolean isMTOMRequired = false;
+ protected boolean isJMSRequired = false;
+
+ // The Axis2 configuration that the binding creates
+ protected ConfigurationContext configContext;
+ protected SecurityContext httpSecurityContext;
+
+ public Axis2BaseBindingProvider(ExtensionPointRegistry extensionPoints) {
+
+ this.extensionPoints = extensionPoints;
+
+ this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+
+ this.httpSecurityContext = new SecurityContext();
+ }
+
+ public ConfigurationContext getAxisConfigurationContext() {
+ return configContext;
+ }
+
+ public SecurityContext getHttpSecurityContext() {
+ return httpSecurityContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BindingProviderFactory.java
new file mode 100644
index 0000000000..bd9b177c39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2BindingProviderFactory.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.sca.binding.ws.axis2.provider;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Axis2BindingProviderFactory
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class Axis2BindingProviderFactory implements BindingProviderFactory<WebServiceBinding> {
+
+ public static final QName MTOM_INTENT = new QName(Constants.SCA11_TUSCANY_NS, "MTOM");
+
+ private ExtensionPointRegistry extensionPoints;
+ private ServletHost servletHost;
+
+ public Axis2BindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new Axis2ReferenceBindingProvider(extensionPoints, endpointReference);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new Axis2ServiceBindingProvider(extensionPoints, endpoint, servletHost);
+ }
+
+ public Class<WebServiceBinding> getModelType() {
+ return WebServiceBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java
new file mode 100644
index 0000000000..a8d35c3381
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java
@@ -0,0 +1,540 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Port;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.deployment.URLBasedAxisConfigurator;
+import org.apache.axis2.deployment.util.Utils;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.transport.local.LocalResponder;
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.common.xml.XMLDocumentHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaExternal;
+import org.apache.ws.commons.schema.resolver.URIResolver;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public class Axis2EngineIntegration {
+
+ //=========================================================
+ // most of the following is related to rewriting WSDL imports
+ // I'd like to move this but don't know where to yet.
+
+ public static final String IMPORT_TAG = "import";
+ public static final String INCLUDE_TAG = "include";
+
+ public static final QName QNAME_WSA_ADDRESS =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS);
+ public static final QName QNAME_WSA_FROM =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM);
+ public static final QName QNAME_WSA_REFERENCE_PARAMETERS =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS);
+
+ //Schema element names
+ public static final String ELEM_SCHEMA = "schema";
+
+ //Schema URI
+ public static final String NS_URI_XSD_1999 = "http://www.w3.org/1999/XMLSchema";
+ public static final String NS_URI_XSD_2000 = "http://www.w3.org/2000/10/XMLSchema";
+ public static final String NS_URI_XSD_2001 = "http://www.w3.org/2001/XMLSchema";
+
+ //Schema QNames
+ public static final QName Q_ELEM_XSD_1999 = new QName(NS_URI_XSD_1999, ELEM_SCHEMA);
+ public static final QName Q_ELEM_XSD_2000 = new QName(NS_URI_XSD_2000, ELEM_SCHEMA);
+ public static final QName Q_ELEM_XSD_2001 = new QName(NS_URI_XSD_2001, ELEM_SCHEMA);
+ public static final List<QName> XSD_QNAME_LIST =
+ Arrays.asList(new QName[] {Q_ELEM_XSD_1999, Q_ELEM_XSD_2000, Q_ELEM_XSD_2001});
+
+ //=========================================================
+
+ /*
+ * Create the whole configuration context for the Axis engine
+ */
+ private static class Axis2Config {
+ private ClassLoaderContext classLoaderContext;
+ private URL axis2xmlURL;
+ private URL repositoryURL;
+ }
+
+ // Cache the discovered axis2 configuration but we need to create a new instance of ConfigurationContext every time
+ private static Axis2Config axis2Config;
+
+ public synchronized static ConfigurationContext getAxisConfigurationContext(final ServiceDiscovery serviceDiscovery) {
+
+ // get the axis configuration context from the Tuscany axis2.xml file
+ // Allow privileged access to read properties. Requires PropertyPermission read in
+ // security policy.
+ if (axis2Config == null) {
+ try {
+ axis2Config = AccessController.doPrivileged(new PrivilegedExceptionAction<Axis2Config>() {
+ public Axis2Config run() throws AxisFault, MalformedURLException {
+ // collect together the classloaders that Axis2 requireds in order to load
+ // pluggable items such as the Tuscany MessageReceivers and the xerces
+ // document builder.
+ ClassLoader wsBindingCL = getClass().getClassLoader();
+ ClassLoader axis2CL = URLBasedAxisConfigurator.class.getClassLoader();
+ ClassLoader localtransportCL = LocalResponder.class.getClassLoader();
+ ClassLoaderContext classLoaderContext =
+ new ClassLoaderContext(wsBindingCL, axis2CL, localtransportCL);
+
+ classLoaderContext =
+ new ClassLoaderContext(classLoaderContext.getClassLoader(), serviceDiscovery,
+ XMLInputFactory.class, DocumentBuilderFactory.class);
+
+ URL axis2xmlURL =
+ wsBindingCL
+ .getResource("org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml");
+ if (axis2xmlURL != null) {
+ URL repositoryURL = new URL(axis2xmlURL, "../repository/");
+ Axis2Config config = new Axis2Config();
+ config.classLoaderContext = classLoaderContext;
+ config.axis2xmlURL = axis2xmlURL;
+ config.repositoryURL = repositoryURL;
+ return config;
+ } else {
+ return null;
+ }
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new ServiceRuntimeException(e.getException());
+ }
+ }
+
+ if (axis2Config == null) {
+ return null;
+ }
+
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ConfigurationContext>() {
+ public ConfigurationContext run() throws AxisFault {
+ ClassLoader oldTCCL = axis2Config.classLoaderContext.setContextClassLoader();
+ try {
+ ConfigurationContext configurationContext =
+ ConfigurationContextFactory.createConfigurationContextFromURIs(axis2Config.axis2xmlURL,
+ axis2Config.repositoryURL);
+ return configurationContext;
+ } finally {
+ if (oldTCCL != null) {
+ Thread.currentThread().setContextClassLoader(oldTCCL);
+ }
+ }
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new ServiceRuntimeException(e.getException());
+ }
+
+ }
+
+ //=========================================================
+
+ /**
+ * Create an AxisService from the Java interface class of the SCA service interface
+ */
+ public static AxisService createJavaAxisService(String endpointURL,
+ ConfigurationContext configContext,
+ AbstractContract contract) throws AxisFault {
+ AxisService axisService = new AxisService();
+ String path = URI.create(endpointURL).getPath();
+ axisService.setName(path);
+ axisService.setServiceDescription("Tuscany configured AxisService for service: " + endpointURL);
+ axisService.setClientSide(false);
+ Parameter classParam =
+ new Parameter(Constants.SERVICE_CLASS,
+ ((JavaInterface)contract.getInterfaceContract().getInterface()).getJavaClass().getName());
+ axisService.addParameter(classParam);
+ try {
+ Utils.fillAxisService(axisService, configContext.getAxisConfiguration(), null, null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return axisService;
+ }
+
+ //=========================================================
+
+ /**
+ * Create an AxisService from the WSDL doc used by ws binding
+ */
+ public static AxisService createWSDLAxisService(String endpointURL,
+ Port port,
+ WebServiceBinding wsBinding) throws AxisFault {
+
+ Definition definition = wsBinding.getGeneratedWSDLDocument();
+ QName serviceQName = wsBinding.getService().getQName();
+ Definition def = getDefinition(definition, serviceQName);
+
+ final WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(def, serviceQName, port.getName());
+ builder.setServerSide(true);
+ // [rfeng] Add a custom resolver to work around WSCOMMONS-228
+ // TODO - 228 is resolved, is this still required
+ builder.setCustomResolver(new URIResolverImpl(def));
+ builder.setBaseUri(def.getDocumentBaseURI());
+ // [rfeng]
+ // AxisService axisService = builder.populateService();
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ AxisService axisService;
+ try {
+ axisService = AccessController.doPrivileged(new PrivilegedExceptionAction<AxisService>() {
+ public AxisService run() throws AxisFault {
+ return builder.populateService();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (AxisFault)e.getException();
+ }
+
+ String name = URI.create(endpointURL).getPath();
+ //[nash] HTTP endpoints need a leading slash for WSDL imports to work with ?wsdl
+ if (endpointURL.startsWith("jms")) {
+ name = name.startsWith("/") ? name.substring(1) : name;
+ }
+ axisService.setName(name);
+ axisService.setEndpointURL(endpointURL);
+ axisService.setDocumentation("Tuscany configured AxisService for service: " + endpointURL);
+
+ // TODO - again, do we ever have more than one endpoint
+ // on the service side?
+ for (Iterator i = axisService.getEndpoints().values().iterator(); i.hasNext();) {
+ AxisEndpoint ae = (AxisEndpoint)i.next();
+ if (endpointURL.startsWith("jms")) {
+// not in Axis2 1.5.1
+// Parameter qcf = new Parameter(JMSConstants.CONFAC_PARAM, null);
+// qcf.setValue(DEFAULT_QUEUE_CONNECTION_FACTORY);
+// axisService.addParameter(qcf);
+ break;
+ }
+ }
+
+ // Add schema information to the AxisService (needed for "?xsd=" support)
+ addSchemas(wsBinding.getUserSpecifiedWSDLDefinition(), axisService);
+
+ // Use the existing WSDL
+ Parameter wsdlParam = new Parameter("wsdl4jDefinition", null);
+ wsdlParam.setValue(definition);
+ axisService.addParameter(wsdlParam);
+ Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
+ axisService.addParameter(userWSDL);
+
+ // Modify schema imports and includes to add "servicename?xsd=" prefix.
+ // Axis2 does this for schema extensibility elements, but Tuscany has
+ // overriden the WSDl4J deserializer to create UnknownExtensibilityElement
+ // elements in place of these.
+ modifySchemaImportsAndIncludes(definition, name);
+
+ // Axis2 1.3 has a bug with returning incorrect values for the port
+ // addresses. To work around this, compute the values here.
+ Parameter modifyAddr = new Parameter("modifyUserWSDLPortAddress", "false");
+ axisService.addParameter(modifyAddr);
+
+ return axisService;
+ }
+
+
+ /**
+ * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205
+ */
+ private static Definition getDefinition(Definition definition, QName serviceName) {
+
+ if (serviceName == null) {
+ return definition;
+ }
+
+ if (definition == null) {
+ return null;
+ }
+ Object service = definition.getServices().get(serviceName);
+ if (service != null) {
+ return definition;
+ }
+ for (Object i : definition.getImports().values()) {
+ List<Import> imports = (List<Import>)i;
+ for (Import imp : imports) {
+ Definition d = getDefinition(imp.getDefinition(), serviceName);
+ if (d != null) {
+ return d;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static void addSchemas(WSDLDefinition wsdlDef, AxisService axisService) {
+ for (XSDefinition xsDef : wsdlDef.getXmlSchemas()) {
+ if (xsDef.getSchema() != null) {
+ axisService.addSchema(xsDef.getSchema());
+ updateSchemaRefs(xsDef.getSchema(), axisService.getName());
+ }
+ }
+ for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) {
+ addSchemas(impDef, axisService);
+ }
+ }
+
+ private static void updateSchemaRefs(XmlSchema parentSchema, String name) {
+ for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) {
+ Object obj = iter.next();
+ if (obj instanceof XmlSchemaExternal) {
+ XmlSchemaExternal extSchema = (XmlSchemaExternal)obj;
+ String location = extSchema.getSchemaLocation();
+ if (location.length() > 0 && location.indexOf(":/") < 0 && location.indexOf("?xsd=") < 0) {
+ extSchema.setSchemaLocation(name + "?xsd=" + location);
+ }
+ if (extSchema.getSchema() != null) {
+ updateSchemaRefs(extSchema.getSchema(), name);
+ }
+ }
+ }
+ }
+
+ private static void modifySchemaImportsAndIncludes(Definition definition, String name) {
+ // adjust the schema locations in types section
+ Types types = definition.getTypes();
+ if (types != null) {
+ for (Iterator iter = types.getExtensibilityElements().iterator(); iter.hasNext();) {
+ Object ext = iter.next();
+ if (ext instanceof UnknownExtensibilityElement && XSD_QNAME_LIST
+ .contains(((UnknownExtensibilityElement)ext).getElementType())) {
+ changeLocations(((UnknownExtensibilityElement)ext).getElement(), name);
+ }
+ }
+ }
+ for (Iterator iter = definition.getImports().values().iterator(); iter.hasNext();) {
+ Vector values = (Vector)iter.next();
+ for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
+ Import wsdlImport = (Import)valuesIter.next();
+ modifySchemaImportsAndIncludes(wsdlImport.getDefinition(), name);
+ }
+ }
+ }
+
+ private static void changeLocations(Element element, String name) {
+ NodeList nodeList = element.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ String tagName = nodeList.item(i).getLocalName();
+ if (IMPORT_TAG.equals(tagName) || INCLUDE_TAG.equals(tagName)) {
+ processImport(nodeList.item(i), name);
+ }
+ }
+ }
+
+ private static void processImport(Node importNode, String name) {
+ NamedNodeMap nodeMap = importNode.getAttributes();
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ Node attribute = nodeMap.item(i);
+ if (attribute.getNodeName().equals("schemaLocation")) {
+ String location = attribute.getNodeValue();
+ if (location.indexOf(":/") < 0 & location.indexOf("?xsd=") < 0) {
+ attribute.setNodeValue(name + "?xsd=" + location);
+ }
+ }
+ }
+ }
+
+ //=========================================================
+
+ /*
+ * Create the service message receivers and the service provider that will push
+ * messages out onto the binding wire
+ */
+ public static void createAxisServiceProviders(AxisService axisService,
+ RuntimeEndpoint endpoint,
+ WebServiceBinding wsBinding,
+ ExtensionPointRegistry extensionPoints) {
+ for (Iterator<?> i = axisService.getOperations(); i.hasNext();) {
+ AxisOperation axisOp = (AxisOperation)i.next();
+ Operation op = getOperation(axisOp, wsBinding);
+ if (op != null) {
+
+ if (op.isNonBlocking()) {
+ axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY);
+ } else {
+ axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT);
+ }
+
+ MessageReceiver msgrec = null;
+ TuscanyServiceProvider serviceProvider = new TuscanyServiceProvider(extensionPoints, endpoint, wsBinding, op);
+ if (op.isNonBlocking()) {
+ msgrec = new Axis2ServiceInMessageReceiver(serviceProvider);
+ } else {
+ msgrec = new Axis2ServiceInOutSyncMessageReceiver(serviceProvider);
+ }
+ axisOp.setMessageReceiver(msgrec);
+ }
+ }
+ }
+
+ private static Operation getOperation(AxisOperation axisOp,WebServiceBinding wsBinding) {
+ String operationName = axisOp.getName().getLocalPart();
+ Interface iface = wsBinding.getBindingInterfaceContract().getInterface();
+ for (Operation op : iface.getOperations()) {
+ if (op.getName().equalsIgnoreCase(operationName)) {
+ return op;
+ }
+ }
+ return null;
+ }
+
+ //=========================================================
+
+ public static String getPortAddress(Port port) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ return ((SOAPAddress)ext).getLocationURI();
+ }
+ if (ext instanceof SOAP12Address) {
+ return ((SOAP12Address)ext).getLocationURI();
+ }
+ return null;
+ }
+
+ public static void setPortAddress(Port port, String locationURI) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ ((SOAPAddress)ext).setLocationURI(locationURI);
+ }
+ if (ext instanceof SOAP12Address) {
+ ((SOAP12Address)ext).setLocationURI(locationURI);
+ }
+ }
+
+ /**
+ * This method is copied from AxisService.createClientSideAxisService to
+ * work around http://issues.apache.org/jira/browse/WSCOMMONS-228
+ *
+ * @param wsdlDefinition
+ * @param wsdlServiceName
+ * @param portName
+ * @param options
+ * @return
+ * @throws AxisFault
+ */
+ @Deprecated
+ public static AxisService createClientSideAxisService(Definition definition,
+ QName serviceName,
+ String portName,
+ Options options) throws AxisFault {
+ Definition def = getDefinition(definition, serviceName);
+ final WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(def, serviceName, portName);
+ serviceBuilder.setServerSide(false);
+ // [rfeng] Add a custom resolver to work around WSCOMMONS-228
+ serviceBuilder.setCustomResolver(new URIResolverImpl(def));
+ serviceBuilder.setBaseUri(def.getDocumentBaseURI());
+ // [rfeng]
+ // Allow access to read properties. Requires PropertiesPermission in security policy.
+ AxisService axisService;
+ try {
+ axisService = AccessController.doPrivileged(new PrivilegedExceptionAction<AxisService>() {
+ public AxisService run() throws AxisFault {
+ return serviceBuilder.populateService();
+ }
+ });
+ } catch ( PrivilegedActionException e ) {
+ throw (AxisFault) e.getException();
+ }
+
+ AxisEndpoint axisEndpoint = (AxisEndpoint)axisService.getEndpoints().get(axisService.getEndpointName());
+ options.setTo(new EndpointReference(axisEndpoint.getEndpointURL()));
+ if (axisEndpoint != null) {
+ options.setSoapVersionURI((String)axisEndpoint.getBinding().getProperty(WSDL2Constants.ATTR_WSOAP_VERSION));
+ }
+ return axisService;
+ }
+
+ /**
+ * URI resolver implementation for XML schema
+ */
+ public static class URIResolverImpl implements URIResolver {
+ private Definition definition;
+
+ public URIResolverImpl(Definition definition) {
+ this.definition = definition;
+ }
+
+ public org.xml.sax.InputSource resolveEntity(java.lang.String targetNamespace,
+ java.lang.String schemaLocation,
+ java.lang.String baseUri) {
+ try {
+ if (baseUri == null) {
+ baseUri = definition.getDocumentBaseURI();
+ }
+ URL url = new URL(new URL(baseUri), schemaLocation);
+ return XMLDocumentHelper.getInputSource(url);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
new file mode 100644
index 0000000000..32f6ee9ca5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
@@ -0,0 +1,380 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.addressing.wsdl.WSDL11ActionHelper;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+
+/**
+ * Axis2BindingInvoker creates an Axis2 OperationClient to pass down the
+ * binding chain
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2ReferenceBindingInvoker implements Invoker {
+ public static final QName QNAME_WSA_FROM =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM, AddressingConstants.WSA_DEFAULT_PREFIX);
+ public static final QName QNAME_WSA_TO =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_TO, AddressingConstants.WSA_DEFAULT_PREFIX);
+ public static final QName QNAME_WSA_ACTION =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_ACTION, AddressingConstants.WSA_DEFAULT_PREFIX);
+ public static final QName QNAME_WSA_RELATESTO =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_RELATES_TO, AddressingConstants.WSA_DEFAULT_PREFIX);
+ public static final QName QNAME_WSA_MESSAGEID =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_MESSAGE_ID, AddressingConstants.WSA_DEFAULT_PREFIX);
+
+
+ private RuntimeEndpointReference endpointReference;
+ private ServiceClient serviceClient;
+ private QName wsdlOperationName;
+ private Options options;
+ private SOAPFactory soapFactory;
+ private WebServiceBinding wsBinding;
+
+ public Axis2ReferenceBindingInvoker(RuntimeEndpointReference endpointReference,
+ ServiceClient serviceClient,
+ QName wsdlOperationName,
+ Options options,
+ SOAPFactory soapFactory,
+ WebServiceBinding wsBinding) {
+ this.endpointReference = endpointReference;
+ this.serviceClient = serviceClient;
+ this.wsdlOperationName = wsdlOperationName;
+ this.options = options;
+ this.soapFactory = soapFactory;
+ this.wsBinding = wsBinding;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ final OperationClient operationClient = createOperationClient(msg);
+ msg.setBindingContext(operationClient);
+ msg = endpointReference.getBindingInvocationChain().getHeadInvoker().invoke(msg);
+
+ if (wsBinding.isRpcLiteral()){
+ // remove the wrapping element containing
+ // the operation response name
+ OMElement operationResponseElement = msg.getBody();
+ if (operationResponseElement != null){
+ msg.setBody(operationResponseElement.getChildElements().next());
+ }
+ }
+
+ } catch (AxisFault e) {
+ if (e.getDetail() != null ) {
+ FaultException f = new FaultException(e.getMessage(), e.getDetail(), e);
+ f.setFaultName(e.getDetail().getQName());
+ msg.setFaultBody(f);
+ } else {
+ msg.setFaultBody(e);
+ }
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+
+ return msg;
+ }
+
+ @SuppressWarnings("deprecation")
+ protected OperationClient createOperationClient(Message msg) throws AxisFault {
+ SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+ Object[] args = (Object[])msg.getBody();
+ if (args != null && args.length > 0) {
+
+ if (wsBinding.isRpcLiteral()){
+ // create the wrapping element containing
+ // the operation name
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ String wrapperNamespace = null;
+
+ // the rpc style creates a wrapper with a namespace where the namespace is
+ // defined on the wsdl binding operation. If no binding is provided by the
+ // user then default to the namespace of the WSDL itself.
+ if (wsBinding.getBinding() != null){
+ Iterator iter = wsBinding.getBinding().getBindingOperations().iterator();
+ loopend:
+ while(iter.hasNext()){
+ BindingOperation bOp = (BindingOperation)iter.next();
+ if (bOp.getName().equals(msg.getOperation().getName())){
+ for (Object ext : bOp.getBindingInput().getExtensibilityElements()){
+ if (ext instanceof javax.wsdl.extensions.soap.SOAPBody){
+ wrapperNamespace = ((javax.wsdl.extensions.soap.SOAPBody)ext).getNamespaceURI();
+ break loopend;
+ }
+ }
+ }
+ }
+ }
+
+ if (wrapperNamespace == null){
+ wrapperNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getNamespace();
+ }
+
+ QName operationQName = new QName(wrapperNamespace,
+ msg.getOperation().getName());
+ OMElement operationNameElement = factory.createOMElement(operationQName);
+
+ // add the parameters as children of the operation name element
+ for (Object bc : args) {
+ if (bc instanceof OMElement) {
+ operationNameElement.addChild((OMElement)bc);
+ } else {
+ throw new IllegalArgumentException( "Can't handle mixed payloads between OMElements and other types for endpoint reference " + endpointReference);
+ }
+ }
+
+ SOAPBody body = env.getBody();
+ body.addChild(operationNameElement);
+
+ } else if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not supported for endpoint reference " + endpointReference);
+ } else if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not supported for endpoint reference " + endpointReference);
+ // } else if (wsBinding.isDocLiteralUnwrapped()){
+ // throw new ServiceRuntimeException("doc/literal/unwrapped WSDL style not supported for endpoint reference " + endpointReference);
+ } else if (wsBinding.isDocLiteralWrapped() ||
+ wsBinding.isDocLiteralUnwrapped()){
+ // it's doc/lit
+ SOAPBody body = env.getBody();
+ for (Object bc : args) {
+ if (bc instanceof OMElement) {
+ body.addChild((OMElement)bc);
+ } else {
+ throw new IllegalArgumentException( "Can't handle mixed payloads between OMElements and other types for endpoint reference " + endpointReference);
+ }
+ }
+ } else {
+ throw new ServiceRuntimeException("Unrecognized WSDL style for endpoint reference " + endpointReference);
+ }
+ }
+
+ final MessageContext requestMC = new MessageContext();
+ requestMC.setEnvelope(env);
+
+ // Axis2 operationClients can not be shared so create a new one for each request
+ final OperationClient operationClient = serviceClient.createClient(wsdlOperationName);
+ operationClient.setOptions(options);
+
+ Endpoint callbackEndpoint = msg.getFrom().getCallbackEndpoint();
+
+ SOAPEnvelope sev = requestMC.getEnvelope();
+ SOAPHeader sh = sev.getHeader();
+
+ // Add WS-Addressing header for the invocation of a bidirectional service
+ if (callbackEndpoint != null) {
+ // Load the actual callback endpoint URI into an Axis EPR ready to form the content of the wsa:From header
+ EndpointReference fromEPR = new EndpointReference(callbackEndpoint.getBinding().getURI());
+
+ addWSAFromHeader( sh, fromEPR );
+ addWSAActionHeader( sh );
+ addWSAMessageIDHeader( sh, (String)msg.getHeaders().get("MESSAGE_ID"));
+
+ requestMC.setFrom(fromEPR);
+ } // end if
+
+ String toAddress = getToAddress( msg );
+ requestMC.setTo( new EndpointReference(toAddress) );
+
+ // For callback references, add wsa:To, wsa:Action and wsa:RelatesTo headers
+ if( isInvocationForCallback( msg ) ) {
+ addWSAToHeader( sh, toAddress, msg );
+ addWSAActionHeader( sh );
+ addWSARelatesTo( sh, msg );
+ } // end if
+
+ // Allow privileged access to read properties. Requires PropertiesPermission read in security policy.
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws AxisFault {
+ operationClient.addMessageContext(requestMC);
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (AxisFault)e.getException();
+ }
+ return operationClient;
+ } // end method createOperationClient
+
+ private String getToAddress( Message msg ) throws ServiceRuntimeException {
+ String address = null;
+
+ // if target endpoint was not specified when this invoker was created,
+ // use dynamically specified target endpoint passed in with the message
+ if (options.getTo() == null) {
+ Endpoint ep = msg.getTo();
+ if (ep != null && ep.getBinding() != null) {
+ address = ep.getBinding().getURI();
+ } else {
+ throw new ServiceRuntimeException("[BWS20025] Unable to determine destination endpoint for endpoint reference " + endpointReference);
+ }
+ } else {
+ address = options.getTo().getAddress();
+ }
+
+ return address;
+ } // end method getToAddress
+
+ /**
+ * Add wsa:From SOAP header to the message
+ * @param sh - the SOAP header for the message
+ * @param fromEPR - the (Axis2) EPR to include in the wsa:From
+ * @throws AxisFault - if an error occurs setting the wsa:From into the header
+ */
+ private void addWSAFromHeader( SOAPHeader sh, EndpointReference fromEPR ) throws AxisFault {
+ OMElement epr = EndpointReferenceHelper.toOM(sh.getOMFactory(),
+ fromEPR,
+ QNAME_WSA_FROM,
+ AddressingConstants.Final.WSA_NAMESPACE);
+ sh.addChild(epr);
+
+ } // end method addWSAFromHeader
+
+ /**
+ * Add wsa:MessageID SOAP header to the message
+ * @param sh - the SOAP header for the message
+ * @param msgID - the message ID
+ * @throws AxisFault - if an error occurs setting the wsa:From into the header
+ */
+ private void addWSAMessageIDHeader( SOAPHeader sh, String msgID ) throws AxisFault {
+ OMElement idHeader = sh.getOMFactory().createOMElement(QNAME_WSA_MESSAGEID);
+ idHeader.setText( msgID );
+
+ sh.addChild(idHeader);
+
+ } // end method addWSAMessageIDHeader
+
+ private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS";
+ /**
+ * Add wsa:To SOAP header to the message - also handles ReferenceParameters, if present
+ * @param sh - the SOAP header for the message
+ * @param address - the address to use
+ * @param msg - the Tuscany message
+ */
+ private void addWSAToHeader( SOAPHeader sh, String address, Message msg ) {
+ if( address == null ) return;
+
+ // Create wsa:To header which is required by ws-addressing spec
+ OMElement wsaToOM = sh.getOMFactory().createOMElement(QNAME_WSA_TO);
+ wsaToOM.setText( address );
+ sh.addChild(wsaToOM);
+
+ if( msg == null ) return;
+
+ // Deal with Reference Parameters, if present - copy to the header without the wsa:ReferenceParameters wrapper
+ OMElement refParms = (OMElement) msg.getHeaders().get(WS_REF_PARMS);
+ if( refParms != null ) {
+ Iterator<?> children = refParms.getChildren();
+ while( children.hasNext() ) {
+ OMNode node = (OMNode) children.next();
+ sh.addChild(node);
+ }
+ } // end if
+
+ } // end method addWSAActionHeader
+
+
+ private void addWSAActionHeader( SOAPHeader sh ) {
+ // Create wsa:Action header which is required by ws-addressing spec
+ String action = options.getAction();
+
+ if (action == null) {
+ PortType portType = ((WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface()).getPortType();
+ Operation op = portType.getOperation(wsdlOperationName.getLocalPart(), null, null);
+ action = WSDL11ActionHelper.getActionFromInputElement(wsBinding.getGeneratedWSDLDocument(), portType, op, op.getInput());
+ }
+
+ OMElement actionOM = sh.getOMFactory().createOMElement(QNAME_WSA_ACTION);
+ actionOM.setText(action == null ? "" : action);
+ sh.addChild(actionOM);
+ } // end method addWSAActionHeader
+
+ private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ protected static String SCA_CALLBACK_REL = "http://docs.oasis-open.org/opencsa/sca-bindings/ws/callback";
+ /**
+ * Adds a wsa:RelatesTo SOAP header if the incoming invocation had a wsa:MessageID SOAP header present
+ * - note that OASIS SCA requires that the RelationshipType attribute is set to a particular SCA value
+ * @param sh - the SOAP headers
+ * @param msg - the message
+ */
+ private void addWSARelatesTo( SOAPHeader sh, Message msg ) {
+ String idValue = (String) msg.getHeaders().get(WS_MESSAGE_ID);
+ if( idValue != null ){
+ OMElement relatesToOM = sh.getOMFactory().createOMElement( QNAME_WSA_RELATESTO );
+ OMAttribute relType = sh.getOMFactory().createOMAttribute("RelationshipType", null, SCA_CALLBACK_REL);
+ relatesToOM.addAttribute( relType );
+ relatesToOM.setText( idValue );
+ sh.addChild( relatesToOM );
+ }
+ } // end method addWSARelatesTo
+
+ /**
+ * Indicates if the invocation is for the callback of a bidirectional service
+ * @param msg the Message
+ * @return true if the invocation is for the callback of a bidirectional service, false otherwise
+ */
+ private boolean isInvocationForCallback( Message msg ) {
+ org.apache.tuscany.sca.assembly.EndpointReference fromEPR = msg.getFrom();
+ if( fromEPR != null ) {
+ ComponentReference ref = fromEPR.getReference();
+ if( ref != null ) return ref.isForCallback();
+ } // end if
+ return false;
+ } // end method isInvocationForCallback
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
new file mode 100644
index 0000000000..20f5e004cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
@@ -0,0 +1,382 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+import java.util.List;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.util.threadpool.ThreadPool;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.axis2.transport.TransportReferenceInterceptor;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.policy.util.PolicyHelper;
+import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class Axis2ReferenceBindingProvider extends Axis2BaseBindingProvider implements EndpointReferenceProvider {
+
+ // the endpoint reference configuration that's driving this binding provider
+ // and some convenience data retrieved from the endpoint reference
+ private RuntimeEndpointReference endpointReference;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private WebServiceBinding wsBinding;
+
+ // The Axis2 configuration that the binding creates
+ private ServiceClient serviceClient;
+ private AxisService axisClientSideService;
+
+
+ public Axis2ReferenceBindingProvider(ExtensionPointRegistry extensionPoints,
+ EndpointReference endpointReference) {
+
+ super(extensionPoints);
+
+ this.endpointReference = (RuntimeEndpointReference)endpointReference;
+
+ this.wsBinding = (WebServiceBinding)endpointReference.getBinding();
+ this.component = (RuntimeComponent)endpointReference.getComponent();
+ this.reference = (RuntimeComponentReference)endpointReference.getReference();
+
+ // A WSDL document should always be present in the binding
+ if (wsBinding.getGeneratedWSDLDocument() == null) {
+ throw new ServiceRuntimeException("No WSDL document for " + component.getName() + "/" + reference.getName());
+ }
+
+ // Set to use the Axiom data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ if (contract.getInterface() != null) {
+ contract.getInterface().resetDataBinding(OMElement.class.getName());
+ }
+
+ isSOAP11Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP11_INTENT);
+ isSOAP12Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP12_INTENT);
+
+ isMTOMRequired = PolicyHelper.isIntentRequired(wsBinding, Axis2BindingProviderFactory.MTOM_INTENT);
+
+ // TODO - this is not correct as there may be other, custom, policies that
+ // require rampart. For example this is not going to pick up the case
+ // of external policy attachment
+ isRampartRequired = PolicyHelper.isIntentRequired(wsBinding, Constants.AUTHENTICATION_INTENT) ||
+ PolicyHelper.isIntentRequired(wsBinding, Constants.CONFIDENTIALITY_INTENT) ||
+ PolicyHelper.isIntentRequired(wsBinding, Constants.INTEGRITY_INTENT);
+
+ // Apply the configuration from any other policies
+
+ for (PolicyProvider pp : this.endpointReference.getPolicyProviders()) {
+ pp.configureBinding(this);
+ }
+
+ // check the WSDL style as we currently only support some of them
+ if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not supported. Component " + endpointReference.getComponent().getName() +
+ " Reference " + endpointReference.getReference() +
+ " Binding " + endpointReference.getBinding().getName());
+ }
+
+ if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not supported. Component " + endpointReference.getComponent().getName() +
+ " Reference " + endpointReference.getReference() +
+ " Binding " + endpointReference.getBinding().getName());
+ }
+
+ if (wsBinding.isDocLiteralUnwrapped()){
+ //throw new ServiceRuntimeException("doc/literal/unwrapped WSDL style not supported for endpoint reference " + endpointReference);
+ }
+
+ // Validate that the WSDL is not using SOAP v1.2 if requires="SOAP.v1_1" has been specified
+ if ( isSOAP11Required ) {
+ Definition def = wsBinding.getGeneratedWSDLDocument();
+ Binding binding = def.getBinding(wsBinding.getBinding().getQName());
+ for ( Object ext : binding.getExtensibilityElements() ) {
+ if ( ext instanceof SOAP12Binding )
+ throw new ServiceRuntimeException("WSDL document is using SOAP v1.2 but SOAP v1.1 " +
+ "is required by the specified policy intents");
+ }
+ }
+
+ // Validate that the WSDL is not using SOAP v1.1 if requires="SOAP.v1_2" has been specified
+ if ( isSOAP12Required ) {
+ Definition def = wsBinding.getGeneratedWSDLDocument();
+ Binding binding = def.getBinding(wsBinding.getBinding().getQName());
+ for ( Object ext : binding.getExtensibilityElements() ) {
+ if ( ext instanceof SOAPBinding )
+ throw new ServiceRuntimeException("WSDL document is using SOAP v1.1 but SOAP v1.2 " +
+ "is required by the specified policy intents");
+ }
+ }
+ }
+
+ public void start() {
+ configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery());
+
+ try {
+ Definition definition = wsBinding.getGeneratedWSDLDocument();
+ QName serviceQName = wsBinding.getService().getQName();
+ Port port = wsBinding.getPort();
+ if (port == null) {
+ // service has multiple ports, select one port to use
+ // TODO - it feels like there is much more to this than is
+ // here at the moment as need to match with the service side
+ // assuming that it's available
+ Collection<Port> ports = wsBinding.getService().getPorts().values();
+ for (Port p : ports) {
+ // look for a SOAP 1.1 port first
+ if (p.getExtensibilityElements().get(0) instanceof SOAPAddress) {
+ port = p;
+ break;
+ }
+ }
+ if (port == null) {
+ // no SOAP 1.1 port available, so look for a SOAP 1.2 port
+ for (Port p : ports) {
+ if (p.getExtensibilityElements().get(0) instanceof SOAP12Address) {
+ port = p;
+ break;
+ }
+ }
+ }
+ }
+
+ axisClientSideService = Axis2EngineIntegration.createClientSideAxisService(definition, serviceQName, port.getName(), new Options());
+
+ HttpClient httpClient = (HttpClient)configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
+ if (httpClient == null) {
+ MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+ HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams();
+ connectionManagerParams.setDefaultMaxConnectionsPerHost(2);
+ connectionManagerParams.setTcpNoDelay(true);
+ connectionManagerParams.setStaleCheckingEnabled(true);
+ connectionManagerParams.setLinger(0);
+ connectionManager.setParams(connectionManagerParams);
+ httpClient = new HttpClient(connectionManager);
+ configContext.setThreadPool(new ThreadPool(1, 5));
+ configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
+ configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
+ }
+
+ serviceClient = new ServiceClient(configContext, axisClientSideService);
+
+ } catch (AxisFault e) {
+ throw new RuntimeException(e); // TODO: better exception
+ }
+ }
+
+ public void stop() {
+ if (serviceClient != null) {
+ // close all connections that we have initiated, so that the jetty server
+ // can be restarted without seeing ConnectExceptions
+ HttpClient httpClient =
+ (HttpClient)serviceClient.getServiceContext().getConfigurationContext()
+ .getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
+ if (httpClient != null)
+ ((MultiThreadedHttpConnectionManager)httpClient.getHttpConnectionManager()).shutdown();
+
+ serviceClient = null;
+ }
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ Options options = new Options();
+ org.apache.axis2.addressing.EndpointReference epTo = getWSATOEPR(wsBinding);
+ if (epTo != null) {
+ options.setTo(epTo);
+ }
+ options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
+
+ String operationName = operation.getName();
+
+ String soapAction = getSOAPAction(operationName);
+ if (soapAction != null && soapAction.length() > 1) {
+ options.setAction(soapAction);
+ }
+
+ options.setTimeOutInMilliSeconds(30 * 1000); // 30 seconds
+
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ SOAPFactory soapFactory = AccessController.doPrivileged(new PrivilegedAction<SOAPFactory>() {
+ public SOAPFactory run() {
+ if (isSOAP12Required)
+ return OMAbstractFactory.getSOAP12Factory();
+ else
+ return OMAbstractFactory.getSOAP11Factory();
+
+ }
+ });
+ QName wsdlOperationQName = new QName(operationName);
+ if (isMTOMRequired)
+ {
+ options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_MTOM, org.apache.axis2.Constants.VALUE_TRUE);
+ }
+
+ return new Axis2ReferenceBindingInvoker(endpointReference, serviceClient, wsdlOperationQName, options, soapFactory, wsBinding);
+
+/*
+ if (operation.isNonBlocking()) {
+ invoker = new Axis2OneWayBindingInvoker(this, wsdlOperationQName, options, soapFactory, wsBinding);
+ } else {
+ invoker = new Axis2BindingInvoker(endpointReference, serviceClient, wsdlOperationQName, options, soapFactory, wsBinding);
+ }
+
+ return invoker;
+*/
+ }
+
+ /*
+ * set up the reference binding wire with the right set of ws reference
+ * interceptors
+ */
+ public void configure() {
+ InvocationChain bindingChain = endpointReference.getBindingInvocationChain();
+
+ // add transport interceptor
+ bindingChain.addInterceptor(Phase.REFERENCE_BINDING_TRANSPORT,
+ new TransportReferenceInterceptor());
+
+ }
+
+ // Reference specific utility operations
+
+ protected org.apache.axis2.addressing.EndpointReference getWSATOEPR(WebServiceBinding binding) {
+ org.apache.axis2.addressing.EndpointReference epr = getEPR(binding);
+ if (epr == null) {
+ epr = getPortLocationEPR(binding);
+ } else if (epr.getAddress() == null || epr.getAddress().length() < 1) {
+ org.apache.axis2.addressing.EndpointReference bindingEPR = getPortLocationEPR(binding);
+ if (bindingEPR != null) {
+ epr.setAddress(bindingEPR.getAddress());
+ }
+ }
+ return epr;
+ }
+
+ protected org.apache.axis2.addressing.EndpointReference getPortLocationEPR(WebServiceBinding binding) {
+ String ep = null;
+ if (binding.getPort() != null) {
+ List<?> wsdlPortExtensions = binding.getPort().getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ ep = ((SOAPAddress)extension).getLocationURI();
+ break;
+ }
+ if (extension instanceof SOAP12Address) {
+ SOAP12Address address = (SOAP12Address)extension;
+ ep = address.getLocationURI();
+ break;
+ }
+ }
+ }
+ if(ep == null || ep.equals("")) {
+ ep = binding.getURI();
+ }
+ return ep == null || "".equals(ep) ? null : new org.apache.axis2.addressing.EndpointReference(ep);
+ }
+
+ protected org.apache.axis2.addressing.EndpointReference getEPR(WebServiceBinding wsBinding) {
+ if (wsBinding.getEndPointReference() == null) {
+ return null;
+ }
+ try {
+
+ XMLStreamReader parser =
+ XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(wsBinding.getEndPointReference()));
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMElement omElement = builder.getDocumentElement();
+ org.apache.axis2.addressing.EndpointReference epr = EndpointReferenceHelper.fromOM(omElement);
+ return epr;
+
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected String getSOAPAction(String operationName) {
+ Binding binding = wsBinding.getBinding();
+ if (binding != null) {
+ for (Object o : binding.getBindingOperations()) {
+ BindingOperation bop = (BindingOperation)o;
+ if (bop.getName().equalsIgnoreCase(operationName)) {
+ for (Object o2 : bop.getExtensibilityElements()) {
+ if (o2 instanceof SOAPOperation) {
+ return ((SOAPOperation)o2).getSoapActionURI();
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
new file mode 100644
index 0000000000..e327be86be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.wsdl.Port;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.transport.jms.JMSListener;
+import org.apache.axis2.transport.jms.JMSSender;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.mtom.Axis2MTOMPolicyProvider;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.util.PolicyHelper;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class Axis2ServiceBindingProvider extends Axis2BaseBindingProvider implements ServiceBindingProvider {
+ private static final Logger logger = Logger.getLogger(Axis2ServiceBindingProvider.class.getName());
+
+ // Tuscany extensions
+ private AssemblyFactory assemblyFactory;
+ private ServletHost servletHost;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+
+ // the endpoint configuration that's driving this binding provider
+ // and some convenience data retrieved from the endpoint
+ private RuntimeEndpoint endpoint;
+ private WebServiceBinding wsBinding;
+ private Port wsdlPort;
+ private String endpointURI;
+ private String deployedURI;
+ private InterfaceContract contract;
+
+ // The Axis2 configuration that the binding creates
+ private JMSSender jmsSender;
+ private JMSListener jmsListener;
+
+ public Axis2ServiceBindingProvider(ExtensionPointRegistry extensionPoints,
+ RuntimeEndpoint endpoint,
+ ServletHost servletHost ) {
+ super(extensionPoints);
+
+ this.extensionPoints = extensionPoints;
+ this.endpoint = endpoint;
+ this.servletHost = servletHost;
+
+ this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+ this.wsBinding = (WebServiceBinding)endpoint.getBinding();
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+
+ // A WSDL document should always be present in the binding
+ if (wsBinding.getGeneratedWSDLDocument() == null) {
+ throw new ServiceRuntimeException("No WSDL document for " + component.getName() + "/" + service.getName());
+ }
+
+ // Set to use the Axiom data binding
+ contract = wsBinding.getBindingInterfaceContract();
+ contract.getInterface().resetDataBinding(OMElement.class.getName());
+
+ configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery());
+
+ // set the root context for this instance of Axis
+ configContext.setContextRoot(servletHost.getContextPath());
+
+ // Determine the configuration from the bindings "mayProvides" intents
+
+ isSOAP12Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP12_INTENT);
+
+ isMTOMRequired = PolicyHelper.isIntentRequired(wsBinding, Axis2BindingProviderFactory.MTOM_INTENT);
+
+ // this is not correct as there may be other, custom, policies that
+ // require rampart. For example this is not going to pick up the case
+ // of external policy attachment
+ isRampartRequired = PolicyHelper.isIntentRequired(wsBinding, Constants.AUTHENTICATION_INTENT) ||
+ PolicyHelper.isIntentRequired(wsBinding, Constants.CONFIDENTIALITY_INTENT) ||
+ PolicyHelper.isIntentRequired(wsBinding, Constants.INTEGRITY_INTENT);
+
+
+ // Apply the configuration from any other policies
+
+ for (PolicyProvider pp : endpoint.getPolicyProviders()) {
+ pp.configureBinding(this);
+ }
+
+ // Update port addresses with runtime information
+ // We can safely assume there is only one port here because you configure
+ // a binding in the following ways:
+ // 1/ default - one port generated = host domain : host port / structural path
+ // 2/ uri="absolute addr" - one port generated = host domain : uri port / uri path
+ // 3/ uri="relative addr" - one port generated = host domain : host port / structural path / relative path
+ // 4/ wsdl.binding - one port generated = host domain : host port / structural path
+ // 5/ wsdl.port - one port generated = host domain : port port / port path
+ // 6/ wsa:Address - one port generated = host domain : address port / address path
+ // 7/ 4 + 6 - as 6
+ wsdlPort = (Port)wsBinding.getService().getPorts().values().iterator().next();
+
+ if (wsdlPort == null){
+ throw new ServiceRuntimeException("No WSDL port for ws binding of " + component.getName() + "/" + service.getName());
+ }
+
+ endpointURI = Axis2EngineIntegration.getPortAddress(wsdlPort);
+
+ if (endpointURI.startsWith("jms:")) {
+ deployedURI = endpointURI;
+ isJMSRequired = true;
+ } else {
+ if (servletHost == null) {
+ throw new ServiceRuntimeException("No Servlet host is avaible for HTTP web services");
+ }
+ deployedURI = servletHost.getURLMapping(endpointURI, httpSecurityContext).toString();
+ }
+
+ Axis2EngineIntegration.setPortAddress(wsdlPort, deployedURI);
+
+ // Apply the configuration from the mayProvides intents
+
+ if (isRampartRequired){
+ // TODO - do we need to go back to configurator?
+ }
+
+ if (isMTOMRequired) {
+ new Axis2MTOMPolicyProvider(endpoint).configureBinding(configContext);
+ }
+
+ if (isJMSRequired){
+ // TODO - do we need to go back to configurator?
+ }
+ wsBinding.setURI(deployedURI);
+
+ // Check the WSDL style as we only support some of them
+
+ if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not supported. Component " + endpoint.getComponent().getName() +
+ " Service " + endpoint.getService() +
+ " Binding " + endpoint.getBinding().getName());
+ }
+
+ if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not supported. Component " + endpoint.getComponent().getName() +
+ " Service " + endpoint.getService() +
+ " Binding " + endpoint.getBinding().getName());
+ }
+
+ // if (wsBinding.isDocLiteralUnwrapped()){
+ // throw new ServiceRuntimeException("doc/literal/unwrapped WSDL style not supported for endpoint " + endpoint);
+ // }
+ }
+
+ private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory";
+
+ public void start() {
+ try {
+ createAxisService(deployedURI, wsdlPort);
+
+ if (deployedURI.startsWith("http://") ||
+ deployedURI.startsWith("https://") ||
+ deployedURI.startsWith("/")) {
+ Axis2ServiceServlet servlet = new Axis2ServiceServlet();
+ servlet.init(configContext);
+
+ if (httpSecurityContext.isSSLEnabled()){
+ deployedURI = servletHost.addServletMapping(endpointURI, servlet, httpSecurityContext);
+ } else {
+ deployedURI = servletHost.addServletMapping(endpointURI, servlet);
+ }
+ } else if (deployedURI.startsWith("jms")) {
+ logger.log(Level.INFO, "Axis2 JMS URL=" + deployedURI);
+
+ jmsListener = new JMSListener();
+ jmsSender = new JMSSender();
+ ListenerManager listenerManager = configContext.getListenerManager();
+ TransportInDescription trsIn =
+ configContext.getAxisConfiguration().getTransportIn(org.apache.axis2.Constants.TRANSPORT_JMS);
+
+ // get JMS transport parameters from the computed URL
+//not in Axis2 1.5.1
+// Map<String, String> jmsProps = JMSUtils.getProperties(endpointURL);
+
+ // collect the parameters used to configure the JMS transport
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement parms = fac.createOMElement(DEFAULT_QUEUE_CONNECTION_FACTORY, null);
+/*
+ for (String key : jmsProps.keySet()) {
+ OMElement param = fac.createOMElement("parameter", null);
+ param.addAttribute("name", key, null);
+ param.addChild(fac.createOMText(param, jmsProps.get(key)));
+ parms.addChild(param);
+ }
+*/
+ Parameter queueConnectionFactory = new Parameter(DEFAULT_QUEUE_CONNECTION_FACTORY, parms);
+ trsIn.addParameter(queueConnectionFactory);
+
+ trsIn.setReceiver(jmsListener);
+
+ configContext.getAxisConfiguration().addTransportIn(trsIn);
+ TransportOutDescription trsOut =
+ configContext.getAxisConfiguration().getTransportOut(org.apache.axis2.Constants.TRANSPORT_JMS);
+ //configContext.getAxisConfiguration().addTransportOut( trsOut );
+ trsOut.setSender(jmsSender);
+
+ if (listenerManager == null) {
+ listenerManager = new ListenerManager();
+ listenerManager.init(configContext);
+ }
+ listenerManager.addListener(trsIn, true);
+ jmsSender.init(configContext, trsOut);
+ jmsListener.init(configContext, trsIn);
+ jmsListener.start();
+ }
+ } catch (AxisFault e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stop() {
+ try {
+ if (jmsListener != null) {
+ jmsListener.stop();
+ jmsListener.destroy();
+ } else {
+ servletHost.removeServletMapping(endpointURI);
+ }
+
+ if (jmsSender != null) {
+ jmsSender.stop();
+ }
+
+ servletHost = null;
+
+ // get the path to the service
+ // [nash] Need a leading slash for WSDL imports to work with ?wsdl
+ URI uriPath = new URI(deployedURI);
+ String stringURIPath = uriPath.getPath();
+ configContext.getAxisConfiguration().removeService(stringURIPath);
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ } catch (AxisFault e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ // Service specific utility operations
+
+ private void createAxisService(String endpointURL, Port port) throws AxisFault {
+ AxisService axisService;
+ if (wsBinding.getGeneratedWSDLDocument() != null) {
+ axisService = Axis2EngineIntegration.createWSDLAxisService(endpointURL, port, wsBinding);
+ } else {
+ axisService = Axis2EngineIntegration.createJavaAxisService(endpointURL, configContext, service);
+ }
+
+ Axis2EngineIntegration.createAxisServiceProviders(axisService, endpoint, wsBinding, extensionPoints);
+
+ configContext.getAxisConfiguration().addService(axisService);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInMessageReceiver.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInMessageReceiver.java
new file mode 100644
index 0000000000..b1f3b35636
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInMessageReceiver.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractInMessageReceiver;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver {
+
+ private TuscanyServiceProvider provider;
+
+ public Axis2ServiceInMessageReceiver(TuscanyServiceProvider provider) {
+ this.provider = provider;
+ }
+
+ public Axis2ServiceInMessageReceiver() {
+ }
+
+ @Override
+ public void invokeBusinessLogic(MessageContext inMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+
+ provider.invoke(requestOM, inMC);
+
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new RuntimeException(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw AxisFault.makeFault(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInOutSyncMessageReceiver.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInOutSyncMessageReceiver.java
new file mode 100644
index 0000000000..d6694c9f7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceInOutSyncMessageReceiver.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.binding.ws.axis2.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver {
+ private static final Logger logger = Logger.getLogger(Axis2ServiceInOutSyncMessageReceiver.class.getName());
+
+ private TuscanyServiceProvider provider;
+
+ public Axis2ServiceInOutSyncMessageReceiver(TuscanyServiceProvider provider) {
+ this.provider = provider;
+ }
+
+ public Axis2ServiceInOutSyncMessageReceiver() {
+ }
+
+ @Override
+ public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+
+ OMElement responseOM = (OMElement)provider.invoke(requestOM, inMC);
+
+ SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope();
+ if (null != responseOM ) {
+ soapEnvelope.getBody().addChild(responseOM);
+ }
+ outMC.setEnvelope(soapEnvelope);
+ outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ if (t instanceof FaultException && ((FaultException)t).getFaultInfo() instanceof OMElement) {
+ OMElement faultDetail = (OMElement)((FaultException)t).getFaultInfo();
+ inMC.setProperty(Constants.FAULT_NAME, faultDetail.getQName().getLocalPart());
+ AxisFault f = new AxisFault(null, e.getMessage(), "faultNode", "faultRole", faultDetail);
+ throw f;
+ }
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ logger.log(Level.SEVERE, e.getMessage(), t);
+ throw new ServiceRuntimeException(e);
+ } catch (Throwable e) {
+ if( "AsyncResponse".equals(e.getMessage()) ) {
+ // Do nothing for an async response exception - it is a signal that the service has been
+ // invoked asynchronously
+ } else {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ } // end if
+ throw AxisFault.makeFault(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceServlet.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceServlet.java
new file mode 100644
index 0000000000..2f6b396786
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceServlet.java
@@ -0,0 +1,300 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.transport.http.AxisServlet;
+
+/**
+ * This overrides the Servlet init of the AxisServlet so Tuscany can use
+ * a single Axis2 ConfigurationContext instance shared between AxisServlet
+ * instances for each SCA service with a ws binding.
+ * TODO: need to review if thats really what we want to be doing
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2ServiceServlet extends AxisServlet {
+
+ protected TuscanyListingAgent agent;
+
+ private static final long serialVersionUID = 1L;
+ private static final ServletConfig DUMMY_CONFIG = createDummyServletConfig();
+
+ private boolean initCalled = false;
+
+//JIRA TUSCANY-1561 Port to Axis2 1.3
+ private ConfigurationContext tmpconfigContext;
+
+ public void init(ConfigurationContext configContext) {
+ this.tmpconfigContext = configContext;
+ //try {
+ //super.init(DUMMY_CONFIG);
+ //init(DUMMY_CONFIG);
+ //} catch (ServletException e) {
+ // throw new RuntimeException(e);
+ //}
+ agent = new TuscanyListingAgent(configContext);
+ }
+
+ /**
+ * Override Axis2 Servlet method to avoid loop when init
+ * is called after servletConfig already initialized by
+ * this classes init(ConfigurationContext) method.
+ */
+ @Override
+ public void init() throws ServletException {
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ ServletContext servletContext = config.getServletContext();
+ servletContext.setAttribute(CONFIGURATION_CONTEXT, tmpconfigContext);
+
+ super.init(config);
+ }
+
+ /**
+ * We've setup the Servlet by passing in a ConfigurationContext on our init method
+ * override this method to just return that
+ */
+ @Override
+ protected ConfigurationContext initConfigContext(ServletConfig config) throws ServletException {
+ return this.tmpconfigContext;
+ }
+
+ @Override
+ public ServletConfig getServletConfig() {
+ return DUMMY_CONFIG;
+ }
+
+ @Override
+ public String getServletName() {
+ return "TuscanyAxis2Servlet";
+ }
+
+ /**
+ * The AxisServlet gets NPE during init without a ServletConfig so this is a mocked up one to prevent that.
+ */
+ private static ServletConfig createDummyServletConfig() {
+ ServletConfig sc = new ServletConfig() {
+
+ public String getServletName() {
+ return "TuscanyAxis2DummyServlet";
+ }
+
+ public ServletContext getServletContext() {
+ return new ServletContext() {
+
+ public ServletContext getContext(String uripath) {
+ return null;
+ }
+
+ @SuppressWarnings("unused") // it's on the Servlet 2.5 API so we need it
+ public String getContextPath() {
+ return null;
+ }
+
+ public int getMajorVersion() {
+ return 0;
+ }
+
+ public int getMinorVersion() {
+ return 0;
+ }
+
+ public String getMimeType(String file) {
+ return null;
+ }
+
+ public Set<?> getResourcePaths(String path) {
+ return Collections.emptySet();
+ }
+
+ public URL getResource(String path) throws MalformedURLException {
+ if("/".equals(path)) {
+ // HACK: To avoid NPE
+ return new URL("/axis2");
+ }
+ return null;
+ }
+
+ public InputStream getResourceAsStream(String path) {
+ return null;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path) {
+ return null;
+ }
+
+ public RequestDispatcher getNamedDispatcher(String arg0) {
+ return null;
+ }
+
+ public Servlet getServlet(String arg0) throws ServletException {
+ return null;
+ }
+
+ public Enumeration getServlets() {
+ return null;
+ }
+
+ public Enumeration getServletNames() {
+ return null;
+ }
+
+ public void log(String arg0) {
+ }
+
+ public void log(Exception arg0, String arg1) {
+ }
+
+ public void log(String arg0, Throwable arg1) {
+ }
+
+ public String getRealPath(String arg0) {
+ return null;
+ }
+
+ public String getServerInfo() {
+ return null;
+ }
+
+ public String getInitParameter(String arg0) {
+ return null;
+ }
+
+ public Enumeration getInitParameterNames() {
+ return null;
+ }
+
+ public Object getAttribute(String arg0) {
+ return null;
+ }
+
+ public Enumeration getAttributeNames() {
+ return null;
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ }
+
+ public void removeAttribute(String arg0) {
+ }
+
+ public String getServletContextName() {
+ return null;
+ }
+ };
+ }
+
+ public String getInitParameter(String arg0) {
+ return null;
+ }
+
+ public Enumeration getInitParameterNames() {
+ return new Vector().elements();
+ }
+ };
+ return sc;
+ }
+
+ @Override
+ public void destroy() {
+ try {
+ super.destroy();
+ servletConfig = null;
+ if (tmpconfigContext.getListenerManager() != null){
+ tmpconfigContext.getListenerManager().destroy();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Override the AxisServlet doGet to use the TuscanyListingAgent for ?wsdl
+ */
+ @Override
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+
+ initContextRoot(request);
+
+ String query = request.getQueryString();
+ if ((query != null) && (query.indexOf("wsdl2") >= 0 ||
+ query.indexOf("wsdl") >= 0 || query.indexOf("xsd") >= 0 ||
+ query.indexOf("policy") >= 0)) {
+ agent.processListService(request, response);
+ } else {
+ super.doGet(request, response);
+ }
+ }
+
+ /**
+
+ /**
+ * Override the AxisServlet method so as to not add "/services" into the URL
+ * and to work with Tuscany service names. can go once moved to Axis2 1.3
+ */
+/*
+ @Override
+ public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault {
+ //RUNNING_PORT
+ String port = (String) configContext.getProperty(ListingAgent.RUNNING_PORT);
+ if (port == null) {
+ port = "8080";
+ }
+ if (ip == null) {
+ try {
+ ip = HttpUtils.getIpAddress();
+ if (ip == null) {
+ ip = "localhost";
+ }
+ } catch (SocketException e) {
+//TUSCANY-1561 Port to Axis2 1.3
+// throw new AxisFault.(e);
+ throw AxisFault.makeFault(e);
+ }
+ }
+
+ URI epURI = URI.create("http://" + ip + ":" + port + "/" + serviceName).normalize();
+
+ return new EndpointReference[]{new EndpointReference(epURI.toString())};
+ }
+ */
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyDispatcher.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyDispatcher.java
new file mode 100644
index 0000000000..0a20de5067
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyDispatcher.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.net.URI;
+import java.util.HashMap;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.RequestURIBasedDispatcher;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A Tuscany specific Axis2 Dispatcher that enables using services
+ * exposed at the SCA defined service URI instead of /services/<serviceName>
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyDispatcher extends RequestURIBasedDispatcher {
+
+ public static final String NAME = "TuscanyDispatcher";
+ private static final Log log = LogFactory.getLog(RequestURIBasedDispatcher.class);
+ private static final boolean isDebugEnabled = log.isDebugEnabled();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext)
+ */
+ @Override
+ public AxisService findService(MessageContext messageContext) throws AxisFault {
+ EndpointReference toEPR = messageContext.getTo();
+
+ if (toEPR != null) {
+ if(isDebugEnabled){
+ log.debug("Checking for Service using target endpoint address : " + toEPR.getAddress());
+ }
+
+ String path = URI.create(toEPR.getAddress()).getPath();
+
+ ConfigurationContext configurationContext = messageContext.getConfigurationContext();
+ AxisConfiguration registry = configurationContext.getAxisConfiguration();
+
+ String serviceName = findAxisServiceName(registry, path);
+ return registry.getService(serviceName);
+
+ } else {
+ if(isDebugEnabled){
+ log.debug("Attempted to check for Service using null target endpoint URI");
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public void initDispatcher() {
+ init(new HandlerDescription(NAME));
+ }
+
+ protected String findAxisServiceName(AxisConfiguration registry, String path) {
+ HashMap services = registry.getServices();
+ if (services == null) {
+ return null;
+ }
+ String[] parts = path.split("/");
+ String serviceName = "";
+ for (int i=parts.length-1; i>=0; i--) {
+ serviceName = parts[i] + serviceName;
+ if (services.containsKey(serviceName)) {
+ return serviceName;
+ }
+ serviceName = "/" + serviceName;
+ if (services.containsKey(serviceName)) {
+ return serviceName;
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyListingAgent.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyListingAgent.java
new file mode 100644
index 0000000000..c44454196d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyListingAgent.java
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.transport.http.ListingAgent;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaExternal;
+
+/**
+ * A Tuscany specific Axis2 ListingAgent as the Axis2 one does not work
+ * with the Tuscany service names which include slash ('/') characters.
+ * Unfortunately it ends up having to copy a fair amount of Axis2 code to do this.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyListingAgent extends ListingAgent {
+
+ private static final String LIST_SINGLE_SERVICE_JSP_NAME =
+ "listSingleService.jsp";
+
+ public TuscanyListingAgent(ConfigurationContext aConfigContext) {
+ super(aConfigContext);
+ }
+
+ /**
+ * This method overrides the Axis2 listing agent's computation of the
+ * service name.
+ */
+ @Override
+ public String extractServiceName(String urlString) {
+ String serviceName = findAxisServiceName(urlString);
+ setContextRoot(urlString, serviceName);
+ return serviceName;
+ }
+
+ /**
+ * Override ?xsd processing so that WSDL documents with XSD imports
+ * and includes work correctly. When we move to Axis2 1.4, we may
+ * be able to use SchemaSupplier to do this in a cleaner way. Also
+ * ensure that the correct IP address and port are returned by ?wsdl.
+ */
+ @Override
+ public void processListService(HttpServletRequest req,
+ HttpServletResponse res)
+ throws IOException, ServletException {
+
+ String url = req.getRequestURL().toString();
+ String query = req.getQueryString();
+
+ // for ?wsdl requests, need to update the WSDL with correct IPaddr and port
+ int wsdl = query.indexOf("wsdl");
+ if (wsdl >= 0) {
+ String serviceName = extractServiceName(url);
+ HashMap services = configContext.getAxisConfiguration().getServices();
+ if ((services != null) && !services.isEmpty()) {
+ AxisService axisService = (AxisService)services.get(serviceName);
+ Parameter wsld4jdefinition = axisService.getParameter("wsdl4jDefinition");
+ Definition definition = (Definition)wsld4jdefinition.getValue();
+ for (Object s : definition.getServices().values()) {
+ for (Object p : ((Service)s).getPorts().values()) {
+ String endpointURL = Axis2EngineIntegration.getPortAddress((Port)p);
+ String modifiedURL = setIPAddress(endpointURL, url);
+ modifiedURL = addContextRoot(modifiedURL, serviceName);
+ Axis2EngineIntegration.setPortAddress((Port)p, modifiedURL);
+ }
+ }
+ }
+ }
+
+ // handle ?xsd requests here
+ int xsd = query.indexOf("xsd");
+ if (xsd >= 0) {
+ String serviceName = extractServiceName(url);
+ HashMap services = configContext.getAxisConfiguration().getServices();
+ if ((services != null) && !services.isEmpty()) {
+ Object serviceObj = services.get(serviceName);
+ if (serviceObj != null) {
+ String xsds = req.getParameter("xsd");
+ if (xsds != null && !"".equals(xsds)) {
+ // a schema name (perhaps with path) is present
+ AxisService axisService = (AxisService)serviceObj;
+ ArrayList schemas = axisService.getSchema();
+ for (Object rootSchema : axisService.getSchema()) {
+ XmlSchema schema = getSchema(((XmlSchema)rootSchema), xsds);
+ if (schema != null) {
+ // found the schema
+ res.setContentType("text/xml");
+ OutputStream out = res.getOutputStream();
+ schema.write(new OutputStreamWriter(out, "UTF8"));
+ out.flush();
+ out.close();
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // in all other cases, delegate to the Axis2 code
+ super.processListService(req, res);
+ }
+
+ private String addContextRoot(String modifiedURL, String serviceName) {
+ if (!"/".equals(configContext.getContextRoot())) {
+ if (modifiedURL.endsWith(serviceName)) {
+ URI uri = URI.create(modifiedURL);
+ if (!uri.getPath().startsWith(configContext.getContextRoot())) {
+ modifiedURL = modifiedURL.substring(0, modifiedURL.length() - serviceName.length()) + configContext.getContextRoot() + serviceName;
+ }
+ }
+ }
+ return modifiedURL;
+ }
+
+ private XmlSchema getSchema(XmlSchema parentSchema, String name) {
+ for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) {
+ Object obj = iter.next();
+ if (obj instanceof XmlSchemaExternal) {
+ XmlSchemaExternal extSchema = (XmlSchemaExternal)obj;
+ if (extSchema.getSchemaLocation().endsWith(name)) {
+ return extSchema.getSchema();
+ } else {
+ XmlSchema schema = getSchema(extSchema.getSchema(), name);
+ if (schema != null) {
+ return schema;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private String findAxisServiceName(String path) {
+ HashMap services = configContext.getAxisConfiguration().getServices();
+ if (services == null) {
+ return null;
+ }
+ String[] parts = path.split("/");
+ String serviceName = "";
+ for (int i=parts.length-1; i>=0; i--) {
+ serviceName = parts[i] + serviceName;
+ if (services.containsKey(serviceName)) {
+ return serviceName;
+ }
+ serviceName = "/" + serviceName;
+ if (services.containsKey(serviceName)) {
+ return serviceName;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Hack for Tuscany to get ?wsdl working with Tuscany service names
+ * Can go once moved up to Axis2 1.3
+ */
+ private void setContextRoot(String filePart, String serviceName) {
+ String contextRoot = configContext.getContextRoot();
+ if (contextRoot != null && contextRoot.length() > 0) {
+ if (contextRoot.equals("/")) {
+ configContext.setServicePath("/");
+ } else {
+ int i = filePart.indexOf(contextRoot) + contextRoot.length();
+ int j = filePart.lastIndexOf(serviceName);
+ if (i>=j || (i+1 == j)) {
+ configContext.setServicePath("/");
+ } else {
+ String mapping = filePart.substring(i+1, j);
+ configContext.setServicePath(mapping);
+ }
+ }
+ configContext.setContextRoot(contextRoot);
+ }
+ }
+
+ private static String setIPAddress(String wsdlURI, String requestURI) {
+ try {
+ URI wsdlURIObj = new URI(wsdlURI);
+ String wsdlHost = wsdlURIObj.getHost();
+ int wsdlPort = wsdlURIObj.getPort();
+ String wsdlAddr = wsdlHost + (wsdlPort != -1 ? ":" + Integer.toString(wsdlPort) : "");
+ URI requestURIObj = new URI(requestURI);
+// not in Axis2 1.5.1
+// String ipAddr = HttpUtils.getIpAddress();
+// int requestPort = requestURIObj.getPort();
+// String newAddr = ipAddr + (requestPort != -1 ? ":" + Integer.toString(requestPort) : "");
+// return wsdlURI.replace(wsdlAddr, newAddr);
+ return wsdlURI;
+ } catch (Exception e) {
+ // URI string not in expected format, so return the WSDL URI unmodified
+ return wsdlURI;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
new file mode 100644
index 0000000000..ba23e80d88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
@@ -0,0 +1,296 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.wsdl.BindingOperation;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class TuscanyServiceProvider {
+ private static final Logger logger = Logger.getLogger(TuscanyServiceProvider.class.getName());
+
+ public static final QName QNAME_WSA_ADDRESS =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS);
+ public static final QName QNAME_WSA_FROM =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM);
+ public static final QName QNAME_WSA_REPLYTO =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_REPLY_TO);
+ public static final QName QNAME_WSA_REFERENCE_PARAMETERS =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS);
+ public static final QName QNAME_WSA_MESSAGEID =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_MESSAGE_ID);
+ public static final QName QNAME_WSA_RELATESTO =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_RELATES_TO, AddressingConstants.WSA_DEFAULT_PREFIX);
+
+ private RuntimeEndpoint endpoint;
+ private WebServiceBinding wsBinding;
+ private MessageFactory messageFactory;
+ private FactoryExtensionPoint modelFactories;
+ private RuntimeAssemblyFactory assemblyFactory;
+ private WebServiceBindingFactory webServiceBindingFactory;
+ private Operation operation;
+
+ public TuscanyServiceProvider(ExtensionPointRegistry extensionPoints,
+ RuntimeEndpoint endpoint,
+ WebServiceBinding wsBinding,
+ Operation operation) {
+ this.endpoint = endpoint;
+ this.wsBinding = wsBinding;
+ this.operation = operation;
+ this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+ this.webServiceBindingFactory = (WebServiceBindingFactory)modelFactories.getFactory(WebServiceBindingFactory.class);
+ }
+
+ // Special WS_Addressing values
+ private static String WS_ADDR_ANONYMOUS = "http://www.w3.org/2005/08/addressing/anonymous";
+ private static String WS_ADDR_NONE = "http://www.w3.org/2005/08/addressing/none";
+ /**
+ * Check if the received callback address has either of the special WS-Addressing forms which are outlawed by the
+ * Web Service Binding specification [BWS50004]
+ * @param callbackAddress - the received callback address
+ * @param inMC - the Axis message context for the received forward call
+ * @throws AxisFault - throws a "OnlyNonAnonymousAddressSupportedFault" if the callback address has either of the special forms
+ */
+ private void checkCallbackAddress( String callbackAddress, MessageContext inMC ) throws AxisFault {
+ // If the address is anonymous or none, throw a SOAP fault...
+ if( WS_ADDR_ANONYMOUS.equals(callbackAddress) || WS_ADDR_NONE.equals(callbackAddress) ) {
+ AddressingFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(inMC, "wsa:From");
+ }
+ } // end method checkCallbackAddress
+
+ public OMElement invoke(OMElement requestOM, MessageContext inMC) throws InvocationTargetException, AxisFault {
+ String callbackAddress = null;
+
+ // create a message object and set the args as its body
+ Message msg = messageFactory.createMessage();
+ msg.setOperation(operation);
+ msg.setBindingContext(inMC);
+
+ if (wsBinding.isRpcLiteral()){
+ // remove the wrapping element containing
+ // the operation name
+ Iterator iter = requestOM.getChildElements();
+ List<OMNode> list = new ArrayList<OMNode>();
+ while(iter.hasNext()){
+ OMNode node = (OMNode)iter.next();
+ list.add(node);
+ }
+
+ Object[] args = list.toArray();
+ msg.setBody(args);
+
+ } else if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not supported for endpoint " + endpoint);
+ } else if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not supported for endpoint " + endpoint);
+ //} else if (wsBinding.isDocLiteralUnwrapped()){
+ // throw new ServiceRuntimeException("doc/literal/unwrapped WSDL style not supported for endpoint " + endpoint);
+ } else if (wsBinding.isDocLiteralWrapped() ||
+ wsBinding.isDocLiteralUnwrapped()){
+ Object[] args = new Object[] {requestOM};
+ msg.setBody(args);
+ } else {
+ throw new ServiceRuntimeException("Unrecognized WSDL style for endpoint " + endpoint);
+ }
+
+ SOAPHeader header = inMC.getEnvelope().getHeader();
+ if (header != null) {
+ // Retrieve callback-related headers
+ callbackAddress = handleCallbackAddress( header, msg );
+ handleMessageIDHeader( header, msg );
+ handleRelatesToHeader( header, msg );
+ } // end if
+
+ // Create a from EPR to hold the details of the callback endpoint, if any
+ createCallbackEPR( callbackAddress, inMC, msg );
+
+ Message response = endpoint.invoke(msg);
+
+ if(response.isFault()) {
+ throw new InvocationTargetException((Throwable) response.getBody());
+ }
+
+ OMElement responseOM = response.getBody();
+
+ if (wsBinding.isRpcLiteral()){
+ // add the response wrapping element
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ String wrapperNamespace = null;
+
+ // the rpc style creates a wrapper with a namespace where the namespace is
+ // defined on the wsdl binding operation. If no binding is provided by the
+ // user then default to the namespace of the WSDL itself.
+ if (wsBinding.getBinding() != null){
+ Iterator iter = wsBinding.getBinding().getBindingOperations().iterator();
+ loopend:
+ while(iter.hasNext()){
+ BindingOperation bOp = (BindingOperation)iter.next();
+ if (bOp.getName().equals(msg.getOperation().getName())){
+ for (Object ext : bOp.getBindingOutput().getExtensibilityElements()){
+ if (ext instanceof javax.wsdl.extensions.soap.SOAPBody){
+ wrapperNamespace = ((javax.wsdl.extensions.soap.SOAPBody)ext).getNamespaceURI();
+ break loopend;
+ }
+ }
+ }
+ }
+ }
+
+ if (wrapperNamespace == null){
+ wrapperNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getNamespace();
+ }
+
+ QName operationResponseQName = new QName(wrapperNamespace,
+ msg.getOperation().getName() + "Response");
+ OMElement operationResponseElement = factory.createOMElement(operationResponseQName);
+ operationResponseElement.addChild(responseOM);
+ responseOM = operationResponseElement;
+ }
+
+ return responseOM;
+ } // end method
+
+ /**
+ * If there is a callback address, create an EPR for the callback with a referenced endpoint that contains
+ * the binding and the target callback address
+ * @param callbackAddress - the callback address - may be null
+ * @param inMC - the Axis incoming message context
+ * @param msg - the Tuscany message
+ * @throws AxisFault - if the callback address has any of the disallowed forms of callback address
+ */
+ private void createCallbackEPR( String callbackAddress, MessageContext inMC, Message msg ) throws AxisFault {
+ if (callbackAddress != null ) {
+ // Check for special (& not allowed!) WS_Addressing values
+ checkCallbackAddress( callbackAddress, inMC );
+ //
+ EndpointReference from = assemblyFactory.createEndpointReference();
+ Endpoint fromEndpoint = assemblyFactory.createEndpoint();
+ from.setTargetEndpoint(fromEndpoint);
+ from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ msg.setFrom(from);
+ Endpoint callbackEndpoint = assemblyFactory.createEndpoint();
+ //
+ WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
+ cbBinding.setURI(callbackAddress);
+ callbackEndpoint.setBinding(cbBinding);
+ //
+ callbackEndpoint.setURI(callbackAddress);
+ callbackEndpoint.setUnresolved(true);
+ from.setCallbackEndpoint(callbackEndpoint);
+ } // end if
+ } // end method createCallbackEPR
+
+ private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS";
+ /**
+ * Deal with any Callback address contained in the SOAP headers of the received message
+ * The callback address is contained in one of two headers (in the priority order stated by the SCA Web Service Binding spec):
+ * - wsa:From
+ * - wsa:ReplyTo
+ * Either of these headers should then contain a wsa:Address element containing the callback address
+ * A callback address may also be accompanied by wsa:ReferenceParameters
+ * - if present, ReferenceParameters must be read, stored unchanged and then sent in the header of any message sent to the
+ * callback address, as stated in the WSW-Addressing specification
+ * Any ReferenceParameters are stored into the headers of the Tuscany message under the key "WS_REFERENCE_PARAMETERS"
+ * @param header - the SOAP header for the message
+ * @param msg - the Tuscany message data structure
+ * @return - the callback address, as a String - null if no callback address is found
+ */
+ private String handleCallbackAddress( SOAPHeader header, Message msg ) {
+ String callbackAddress = null;
+
+ // See if there is a wsa:From element - if not search for a wsa:ReplyTo element
+ OMElement from = header.getFirstChildWithName(QNAME_WSA_FROM);
+ if( from == null ) from = header.getFirstChildWithName(QNAME_WSA_REPLYTO);
+
+ if (from != null) {
+ OMElement callbackAddrElement = from.getFirstChildWithName(QNAME_WSA_ADDRESS);
+ if (callbackAddrElement != null) {
+ callbackAddress = callbackAddrElement.getText();
+ OMElement refParms = from.getFirstChildWithName(QNAME_WSA_REFERENCE_PARAMETERS);
+ if( refParms != null ) msg.getHeaders().put(WS_REF_PARMS, refParms);
+ }
+ } // end if
+
+ return callbackAddress;
+ } // end method handleCallbackAddress
+
+ private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ /**
+ * Handle a SOAP wsa:MessageID header - place the contents into the Tuscany message for use by any callback
+ * @param header - the SOAP Headers
+ * @param msg - the Tuscany Message
+ */
+ private void handleMessageIDHeader( SOAPHeader header, Message msg ) {
+ if( header == null ) return;
+ OMElement messageID = header.getFirstChildWithName(QNAME_WSA_MESSAGEID);
+ if (messageID != null) {
+ String idValue = messageID.getText();
+ // Store the value of the message ID element into the message under "WS_MESSAGE_ID"...
+ msg.getHeaders().put(WS_MESSAGE_ID, idValue);
+ } // end if
+ } // end method handleMessageID
+
+ private static String WS_RELATES_TO = "WS_RELATES_TO";
+ /**
+ * Handle a SOAP wsa:RelatesTo header - place the contents into the Tuscany message for use by any callback
+ * @param header - the SOAP Headers
+ * @param msg - the Tuscany Message
+ */
+ private void handleRelatesToHeader( SOAPHeader header, Message msg ) {
+ if( header == null ) return;
+ OMElement messageID = header.getFirstChildWithName(QNAME_WSA_RELATESTO);
+ if (messageID != null) {
+ String idValue = messageID.getText();
+ // Store the value of the message ID element into the message under "WS_MESSAGE_ID"...
+ msg.getHeaders().put(WS_MESSAGE_ID, idValue);
+ } // end if
+ } // end method handleMessageID
+} // end class AsyncResponseHandler
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/transport/TransportReferenceInterceptor.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/transport/TransportReferenceInterceptor.java
new file mode 100644
index 0000000000..7daa58bf29
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/transport/TransportReferenceInterceptor.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.transport;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Use an Axis2 OperationClient to invoke a remote web service
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+
+ public TransportReferenceInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = null;
+
+ if (msg.getOperation().isNonBlocking()) {
+ resp = invokeTargetOneWay(msg);
+ } else {
+ resp = invokeTarget(msg);
+ }
+
+ msg.setBody(resp);
+ } catch (AxisFault e) {
+ if (e.getDetail() != null ) {
+ FaultException f = new FaultException(e.getMessage(), e.getDetail(), e);
+ f.setFaultName(e.getDetail().getQName());
+ msg.setFaultBody(f);
+ } else {
+ msg.setFaultBody(e);
+ }
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+
+ return msg;
+ }
+
+ protected Object invokeTarget(Message msg) throws AxisFault {
+ final OperationClient operationClient = msg.getBindingContext();
+
+ // ensure connections are tracked so that they can be closed by the reference binding
+ MessageContext requestMC = operationClient.getMessageContext("Out");
+ requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
+ requestMC.getOptions().setTimeOutInMilliSeconds(240000L);
+
+
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws AxisFault {
+ operationClient.execute(true);
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ operationClient.complete(requestMC);
+ throw (AxisFault)e.getException();
+ }
+
+ MessageContext responseMC = operationClient.getMessageContext("In");
+
+ OMElement response = responseMC.getEnvelope().getBody().getFirstElement();
+
+ // FIXME: [rfeng] We have to pay performance penalty to build the complete OM as the operationClient.complete() will
+ // release the underlying HTTP connection.
+ // Force the response to be populated, see https://issues.apache.org/jira/browse/TUSCANY-1541
+ if (response != null) {
+ response.build();
+ }
+
+ operationClient.complete(requestMC);
+
+ return response;
+ }
+
+ protected Object invokeTargetOneWay(Message msg) throws AxisFault {
+ OperationClient operationClient = msg.getBindingContext();
+
+ // ensure connections are tracked so that they can be closed by the reference binding
+ MessageContext requestMC = operationClient.getMessageContext("Out");
+ //requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
+ Options opt = requestMC.getOptions();
+ opt.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
+ opt.setUseSeparateListener(true);
+ opt.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,Boolean.TRUE);
+
+ operationClient.execute(false);
+
+ // REVIEW it seems ok to return null
+ return null;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..090b2550ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/binding/ws/axis2/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..a35f2502f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BindingProviderFactory;model=org.apache.tuscany.sca.binding.ws.WebServiceBinding,ranking=462
+
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
new file mode 100644
index 0000000000..ae1acbd541
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -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 binding-ws-runtime-axis2 specific policy extensions
+org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.BasicAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.security.http.ssl.HTTPSPolicyProviderFactory;model=org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicy
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml
new file mode 100644
index 0000000000..13296ac65b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml
@@ -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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- MJE 22/06/2010 - add asyncInvocation to the @mayProvide list, for async services support -->
+ <sca:bindingType type="sca:binding.ws"
+ mayProvide="sca:SOAP sca:SOAP.v1_1 sca:SOAP.v1_2 tuscany:MTOM sca:asyncInvocation"
+ alwaysProvides=""/>
+
+ <!-- see the file sca-policy-1.1-intents-definitions.xml in the -->
+ <!-- assembly-xsd module for spec defined intents -->
+
+ <!-- PolicyIntents defined by the SCA Runtime Extension for WS Binding Axis 2 -->
+
+ <sca:intent name="MTOM" constrains="sca:binding.ws">
+ <sca:description>
+ Communication through this binding requires MTOM support
+ </sca:description>
+ </sca:intent>
+
+ </sca:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml
new file mode 100644
index 0000000000..28fb6fac45
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml
@@ -0,0 +1,507 @@
+<?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.
+ -->
+
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment">true</parameter>
+ <parameter name="hotupdate">false</parameter>
+ <parameter name="enableMTOM">false</parameter>
+ <parameter name="enableSwA">false</parameter>
+
+ <!-- Customized by Tuscany -->
+ <!-- parameter name="OutflowSecurity">
+ <action>
+ <items>Timestamp</items>
+ </action>
+ </parameter-->
+
+ <!--Uncomment if you want to enable file caching for attachments -->
+ <!--parameter name="cacheAttachments">true</parameter>
+ <parameter name="attachmentDIR"></parameter>
+ <parameter name="sizeThreshold">4000</parameter-->
+
+ <!--This will give out the timout of the configuration contexts, in milliseconds-->
+ <parameter name="ConfigContextTimeoutInterval">30000</parameter>
+
+ <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
+ <!--that behavior.-->
+
+ <!-- Customized by Tuscany -->
+ <parameter name="sendStacktraceDetailsWithFaults">true</parameter>
+
+ <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
+ <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+ <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+ <!--is set, then Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+ <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
+
+ <parameter name="userName">admin</parameter>
+ <parameter name="password">axis2</parameter>
+
+ <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
+ <!--ServicesDirectory only works on the following cases-->
+ <!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
+ <!---When creating URL Based configurator with URL “file://†-->
+ <!--- War based configurator with expanded case , -->
+
+ <!--All the other scenarios it will be ignored.-->
+ <!--<parameter name="ServicesDirectory">service</parameter>-->
+ <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
+ <!--<parameter name="ModulesDirectory">modules</parameter>-->
+
+
+
+ <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+ <!--root which can configured using the following contextRoot parameter-->
+ <!--<parameter name="contextRoot">axis2</parameter>-->
+
+ <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguiush those endpoints-->
+ <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this -->
+ <!--context path to proper Axis2 servlets-->
+
+ <!-- Customized by Tuscany -->
+ <parameter name="servicePath">/</parameter>
+
+ <!--<parameter name="restPath">rest</parameter>-->
+
+ <!-- Following parameter will completely disable REST handling in Axis2-->
+
+ <parameter name="disableREST" locked="true">false</parameter>
+
+ <!--POJO deployer , this will allow users to drop .class file and make that into a service-->
+ <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
+
+ <!-- Following parameter will set the host name for the epr-->
+ <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
+
+ <!-- If you have a frontend host which exposes this webservice using a different public URL -->
+ <!-- use this parameter to override autodetected url -->
+ <!--<parameter name="httpFrontendHostUrl">https://someotherhost/context</parameter>-->
+
+
+ <!-- The way of adding listener to the system-->
+ <!-- <listener class="org.apache.axis2.ObserverIMPL">-->
+ <!-- <parameter name="RSS_URL">http://127.0.0.1/rss</parameter>-->
+ <!-- </listener>-->
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the deafult MessageReceiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can ovrride this for a particular service by adding the same element with your requirement-->
+ <messageReceivers>
+
+ <!-- Added by Tuscany -->
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ServiceInMessageReceiver"/>
+
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+
+ <!-- Added by Tuscany -->
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ServiceInOutSyncMessageReceiver"/>
+
+ <!-- Added by Tuscany -->
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
+ class="org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ServiceInMessageReceiver"/>
+
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+
+ <!-- Added by Tuscany -->
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
+ class="org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ServiceInOutSyncMessageReceiver"/>
+
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Message Formatter -->
+ <!-- ================================================= -->
+ <!--Following content type to message formatter mapping can be used to implement support for different message -->
+ <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
+ <messageFormatters>
+ <messageFormatter contentType="application/x-www-form-urlencoded"
+ class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
+ <messageFormatter contentType="multipart/form-data"
+ class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
+ <messageFormatter contentType="application/xml"
+ class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
+ </messageFormatters>
+
+ <!-- ================================================= -->
+ <!-- Message Builders -->
+ <!-- ================================================= -->
+ <!--Following content type to builder mapping can be used to implement support for different message -->
+ <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
+ <messageBuilders>
+ <messageBuilder contentType="application/xml"
+ class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
+ <messageBuilder contentType="application/x-www-form-urlencoded"
+ class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
+ <messageBuilder contentType="multipart/form-data"
+ class="org.apache.axis2.builder.MultipartFormDataBuilder"/>
+ </messageBuilders>
+
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+
+ <!-- Customized by Tuscany -->
+ <parameter name="port" locked="false">6060</parameter>
+
+ <!-- Here is the complete list of supported parameters (see example settings further below):
+ port: the port to listen on (default 6060)
+ hostname: if non-null, url prefix used in reply-to endpoint references (default null)
+ originServer: value of http Server header in outgoing messages (default "Simple-Server/1.1")
+ requestTimeout: value in millis of time that requests can wait for data (default 20000)
+ requestTcpNoDelay: true to maximize performance and minimize latency (default true)
+ false to minimize bandwidth consumption by combining segments
+ requestCoreThreadPoolSize: number of threads available for request processing (unless queue fills up) (default 25)
+ requestMaxThreadPoolSize: number of threads available for request processing if queue fills up (default 150)
+ note that default queue never fills up: see HttpFactory
+ threadKeepAliveTime: time to keep threads in excess of core size alive while inactive (default 180)
+ note that no such threads can exist with default unbounded request queue
+ threadKeepAliveTimeUnit: TimeUnit of value in threadKeepAliveTime (default SECONDS) (default SECONDS)
+ -->
+ <!-- <parameter name="hostname">http://www.myApp.com/ws</parameter> -->
+ <!-- <parameter name="originServer">My-Server/1.1</parameter> -->
+ <!-- <parameter name="requestTimeout">10000</parameter> -->
+ <!-- <parameter name="requestTcpNoDelay">false</parameter> -->
+ <!-- <parameter name="requestCoreThreadPoolSize">50</parameter> -->
+ <!-- <parameter name="RequestMaxThreadPoolSize">100</parameter> -->
+ <!-- <parameter name="threadKeepAliveTime">240000</parameter> -->
+ <!-- <parameter name="threadKeepAliveTimeUnit">MILLISECONDS</parameter> -->
+ </transportReceiver>
+
+ <!-- Added by Tuscany -->
+ <!-- transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener" -->
+ <!-- These configuation parameters now come from the binding.ws uri
+ or from a policy set
+ <parameter name="myTopicConnectionFactory">
+ <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</parameter>
+ </parameter>
+
+ <parameter name="myQueueConnectionFactory">
+ <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter>
+ </parameter>
+
+ <parameter name="default">
+ <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter>
+ </parameter>
+ -->
+ <!-- /transportReceiver-->
+
+ <!-- ================================================= -->
+ <!-- Non-blocking http/s Transport Listener -->
+
+ <!-- the non blocking http transport based on HttpCore + NIO extensions
+ <transportReceiver name="http" class="org.apache.axis2.transport.nhttp.HttpCoreNIOListener">
+ <parameter name="port" locked="false">9000</parameter>
+ <parameter name="non-blocking" locked="false">true</parameter>
+ </transportReceiver>-->
+
+ <!-- the non blocking https transport based on HttpCore + SSL-NIO extensions
+ <transportReceiver name="https" class="org.apache.axis2.transport.nhttp.HttpCoreNIOSSLListener">
+ <parameter name="port" locked="false">9002</parameter>
+ <parameter name="non-blocking" locked="false">true</parameter>
+ <parameter name="keystore" locked="false">
+ <KeyStore>
+ <Location>identity.jks</Location>
+ <Type>JKS</Type>
+ <Password>password</Password>
+ <KeyPassword>password</KeyPassword>
+ </KeyStore>
+ </parameter>
+ <parameter name="truststore" locked="false">
+ <TrustStore>
+ <Location>trust.jks</Location>
+ <Type>JKS</Type>
+ <Password>password</Password>
+ </TrustStore>
+ </parameter>-->
+ <!--<parameter name="SSLVerifyClient">require</parameter>
+ supports optional|require or defaults to none -->
+ <!--</transportReceiver>-->
+
+ <!-- ================================================= -->
+ <!-- Mail Transport Listener -->
+ <!-- This is a sample configuration. It assumes a mail server running in localhost.
+ Listener pops messages that comes to the email address red@localhost. Users
+ password is red. Listener connect to the server every 3000 milliseconds.
+ Parameters with "transport." prefix is Axis2 specific. Others are all from Java Mail API.
+ http://people.apache.org/~pzf/SMTPBase64Binding-0.2.html
+ -->
+ <!-- ================================================= -->
+ <!--<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.SimpleMailListener">
+ <parameter name="mail.pop3.host">localhost</parameter>
+ <parameter name="mail.pop3.user">red</parameter>
+ <parameter name="mail.store.protocol">pop3</parameter>
+ <parameter name="transport.mail.pop3.password">red</parameter>
+ <parameter name="transport.mail.replyToAddress">red@localhost</parameter>
+ <parameter name="transport.listener.interval">3000</parameter>
+ </transportReceiver>-->
+
+ <!--Uncomment if you want to have TCP transport support-->
+ <!--transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port">6060</parameter-->>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncomment the following paramter , and set it as you required.-->
+ <!--<parameter name="hostname">tcp://myApp.com/ws</parameter>-->
+ <!-- /transportReceiver -->
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+ <!--
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ -->
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding">chunked</parameter>
+
+ <!-- If following is set to 'true', optional action part of the Content-Type will not be added to the SOAP 1.2 messages -->
+ <!-- <parameter name="OmitSOAP12Action">true</parameter> -->
+ </transportSender>
+
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding">chunked</parameter>
+ </transportSender>
+
+ <!-- transportSender name="jms"
+ class="org.apache.axis2.transport.jms.JMSSender"/-->
+
+ <!-- ================================================= -->
+ <!-- Non-blocking http/s Transport Sender -->
+
+ <!-- the non-blocking http transport sender based on HttpCore + NIO extensions
+ <transportSender name="http" class="org.apache.axis2.transport.nhttp.HttpCoreNIOSender">
+ <parameter name="non-blocking" locked="false">true</parameter>
+ </transportSender>-->
+
+ <!-- the non-blocking https transport sender based on HttpCore + NIO SSL extensions
+ <transportSender name="https" class="org.apache.axis2.transport.nhttp.HttpCoreNIOSSLSender">
+ <parameter name="non-blocking" locked="false">true</parameter>
+ <parameter name="keystore" locked="false">
+ <KeyStore>
+ <Location>identity.jks</Location>
+ <Type>JKS</Type>
+ <Password>password</Password>
+ <KeyPassword>password</KeyPassword>
+ </KeyStore>
+ </parameter>
+ <parameter name="truststore" locked="false">
+ <TrustStore>
+ <Location>trust.jks</Location>
+ <Type>JKS</Type>
+ <Password>password</Password>
+ </TrustStore>
+ </parameter>-->
+ <!--<parameter name="HostnameVerifier">DefaultAndLocalhost</parameter>
+ supports Strict|AllowAll|DefaultAndLocalhost or the default if none specified -->
+ <!--</transportSender>-->
+
+ <!-- ================================================= -->
+ <!-- Mail Transport Sender -->
+ <!--Only need to uncomment the sender. Configuration is achieved with every client.
+ At any instant mail host should be given. Sample configuration has been given.
+ http://people.apache.org/~pzf/SMTPBase64Binding-0.2.html
+ -->
+ <!-- ================================================= -->
+ <!--<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
+ <parameter name="mail.smtp.host">localhost</parameter>
+ </transportSender>-->
+
+ <!-- ================================================= -->
+ <!-- Global Modules -->
+ <!-- ================================================= -->
+ <!-- Comment this to disable Addressing -->
+
+ <!-- Commented out by Tuscany
+ <module ref="addressing"/>
+ -->
+
+ <!-- Added by Tuscany -->
+ <!--
+ <module ref="rampart"/>
+ -->
+
+ <!-- wsp:Policy wsu:Id="UTOverTransport" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" />
+ </wsp:Policy>
+ </sp:SignedSupportingTokens>
+
+ <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+ <ramp:user>TuscanyWsUser</ramp:user>
+ <ramp:passwordType>PasswordText</ramp:passwordType>
+ <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.ClientPWCBHandler</ramp:passwordCallbackClass>
+ </ramp:RampartConfig>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy-->
+
+ <!--Configuring module , providing parameters for modules whether they refer or not-->
+ <!--<moduleConfig name="addressing">-->
+ <!--<parameter name="addressingPara">N/A</parameter>-->
+ <!--</moduleConfig>-->
+
+ <!-- ================================================= -->
+ <!-- Clustering -->
+ <!-- ================================================= -->
+ <!-- Configure and uncomment following for preparing Axis2 to a clustered environment -->
+ <!--
+ <cluster class="org.apache.axis2.cluster.tribes.TribesClusterManager">
+ <parameter name="param1">value1</parameter>
+ <parameter name="domain">apache.axis2.domain</parameter>
+ <configurationManager class="org.apache.axis2.cluster.configuration.TribesConfigurationManager">
+ <listener class="org.apache.axis2.cluster.configuration.DefaultConfigurationManagerListener"/>
+ </configurationManager>
+ <contextManager class="org.apache.axis2.cluster.context.TribesContextManager">
+ <listener class="org.apache.axis2.cluster.context.DefaultContextManagerListener"/>
+ </contextManager>
+ </cluster>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="InFlow">
+ <!-- System pre defined phases -->
+ <phase name="Transport">
+
+ <!-- Added by Tuscany -->
+ <handler name="TuscanyDispatcher"
+ class="org.apache.tuscany.sca.binding.ws.axis2.provider.TuscanyDispatcher">
+ <order phase="Transport"/>
+ </handler>
+
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ </phase>
+ <phase name="Addressing">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+ <order phase="Addressing"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+ <handler name="RequestURIOperationDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+<!--
+ <handler name="HTTPLocationBasedDispatcher"
+ class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+-->
+ </phase>
+ <phase name="RMPhase"/>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ <phase name="soapmonitorPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="soapmonitorPhase"/>
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="RMPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ <phase name="Security"/>
+ </phaseOrder>
+ <phaseOrder type="InFaultFlow">
+ <phase name="Addressing">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+ <order phase="Addressing"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+ <handler name="RequestURIOperationDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+<!--
+ <handler name="HTTPLocationBasedDispatcher"
+ class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+-->
+ </phase>
+ <phase name="RMPhase"/>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ <phase name="soapmonitorPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFaultFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="soapmonitorPhase"/>
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="RMPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ <phase name="Security"/>
+ </phaseOrder>
+</axisconfig>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/modules.list b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/modules.list
new file mode 100644
index 0000000000..e6e70dfd4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/modules.list
@@ -0,0 +1 @@
+rampart-1.4.mar \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/rampart-1.4.mar b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/rampart-1.4.mar
new file mode 100644
index 0000000000..ec870734a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/modules/rampart-1.4.mar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/services/services.list b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/services/services.list
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/repository/services/services.list
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java
new file mode 100644
index 0000000000..a482477d3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/HelloWorldTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class HelloWorldTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite",
+ new Contribution("test", "target/test-classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingTestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingTestCase.java
new file mode 100644
index 0000000000..b55779fa25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class WSDLBindingTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite",
+ new Contribution("test", "target/test-classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingURITestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingURITestCase.java
new file mode 100644
index 0000000000..54f25694e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingURITestCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class WSDLBindingURITestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.composite",
+ new Contribution("test", "target/test-classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingWSATestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingWSATestCase.java
new file mode 100644
index 0000000000..addcf67ac0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLBindingWSATestCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class WSDLBindingWSATestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite",
+ new Contribution("test", "target/test-classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..98eb6e361b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..2c6c4fc92c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/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 org.apache.tuscany.sca.binding.ws.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorldWS;
+
+ public String getGreetings(String s) {
+ String response = helloWorldWS.getGreetings(s);
+ System.out.println("At client: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..3662007984
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/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 org.apache.tuscany.sca.binding.ws.axis2.helloworld;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ String response = "Hello " + s;
+ System.out.println("At service: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite
new file mode 100644
index 0000000000..fdbb68baea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort1)"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/>
+ <service name="HelloWorld">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)">
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/services/HelloWorldWebService1</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..0d5fd064ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/helloworld/helloworld.wsdl
@@ -0,0 +1,86 @@
+<?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="HelloWorldSoapPort1">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService1"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite
new file mode 100644
index 0000000000..863d13b97e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbinding/helloworld.composite
@@ -0,0 +1,41 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="wsdlbinding">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8080/HelloWorldService/HelloWorld"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/>
+ <service name="HelloWorld">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.composite b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.composite
new file mode 100644
index 0000000000..a877f9be26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindinguri/helloworld.composite
@@ -0,0 +1,42 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="wsdlbindinguri">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort1)"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/>
+ <service name="HelloWorld">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/services/HelloWorldWebService1"
+ wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite
new file mode 100644
index 0000000000..7b0263b019
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlbindingwsa/helloworld.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="wsdlbindingwsa">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort1)"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/>
+ <service name="HelloWorld">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.binding(HelloWorldSoapBinding)">
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/services/HelloWorldWebService1</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/LICENSE b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/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/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2bde2fad22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/META-INF/MANIFEST.MF
@@ -0,0 +1,54 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JAXWS RI based WS Binding Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397353000
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JAXWS-based WS Binding Extensio
+ n
+Import-Package: javax.security.auth.callback;resolution:=optional,
+ javax.servlet,
+ javax.servlet.http,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.extensions.soap12,
+ javax.wsdl.factory;resolution:=optional,
+ javax.wsdl.xml;resolution:=optional,
+ javax.xml.namespace,
+ javax.xml.soap,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.ws,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.authentication.basic;version="2.0.0",
+ org.apache.tuscany.sca.policy.security;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.tuscany.sca.xsd.xml;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.ws.jaxws.ri
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/NOTICE b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/pom.xml b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/pom.xml
new file mode 100644
index 0000000000..c6b397b852
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/pom.xml
@@ -0,0 +1,151 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-ws-runtime-jaxws-ri</artifactId>
+ <name>Apache Tuscany SCA JAXWS RI based WS Binding Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-jaxws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+
+ <!-- Test dependencies -->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSBindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSBindingProviderFactory.java
new file mode 100644
index 0000000000..45463fcd53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSBindingProviderFactory.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.ws.jaxws.ri;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+/**
+ * JAXWSBindingProviderFactory
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class JAXWSBindingProviderFactory implements BindingProviderFactory<WebServiceBinding> {
+
+ private FactoryExtensionPoint modelFactories;
+ private ServletHost servletHost;
+ private DataBindingExtensionPoint dataBindings;
+ private String defaultPort = "8085";
+
+ public JAXWSBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ List<ServletHost> hosts = servletHosts.getServletHosts();
+ if (!hosts.isEmpty()) {
+ this.servletHost = hosts.get(0);
+ }
+ modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
+
+ RuntimeProperties ps = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class);
+ String pp = ps.getProperties().getProperty(this.getClass().getName() + ".defaultPort");
+ if (pp != null) {
+ this.defaultPort = ps.getProperties().getProperty(this.getClass().getName() + ".defaultPort");
+ }
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new JAXWSReferenceBindingProvider(endpointReference, modelFactories, dataBindings);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new JAXWSServiceBindingProvider(endpoint, servletHost, modelFactories, dataBindings, defaultPort);
+ }
+
+ public Class<WebServiceBinding> getModelType() {
+ return WebServiceBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSReferenceBindingProvider.java
new file mode 100644
index 0000000000..7a1b8f356a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSReferenceBindingProvider.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.ws.jaxws.ri;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingInvoker;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+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.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Node;
+
+public class JAXWSReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private javax.xml.soap.MessageFactory messageFactory;
+ private WebServiceBinding wsBinding;
+ private RuntimeEndpointReference endpointReference;
+
+ public JAXWSReferenceBindingProvider(RuntimeEndpointReference endpointReference,
+ FactoryExtensionPoint modelFactories,
+ DataBindingExtensionPoint dataBindings) {
+
+ this.endpointReference = endpointReference;
+ this.messageFactory = modelFactories.getFactory(javax.xml.soap.MessageFactory.class);
+ this.wsBinding = (WebServiceBinding) endpointReference.getBinding();
+
+ // A WSDL document should always be present in the binding
+ if (wsBinding.getGeneratedWSDLDocument() == null) {
+ throw new ServiceRuntimeException("No WSDL document for " + endpointReference.getURI());
+ }
+
+ // Set to use the DOM data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ if (contract.getInterface() != null) {
+ contract.getInterface().resetDataBinding(Node.class.getName());
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new JAXWSBindingInvoker(operation, null, messageFactory, wsBinding, endpointReference);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java
new file mode 100644
index 0000000000..516ca62c11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws.ri;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingProvider;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+@WebServiceProvider
+@ServiceMode(Mode.MESSAGE)
+public class JAXWSServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+ private WebServiceBinding wsBinding;
+
+ private JAXWSBindingProvider jaxwsBindingProvider;
+
+ private Endpoint wsEndpoint;
+
+ public JAXWSServiceBindingProvider(RuntimeEndpoint endpoint,
+ ServletHost servletHost,
+ FactoryExtensionPoint modelFactories,
+ DataBindingExtensionPoint dataBindings, String defaultPort) {
+
+ this.endpoint = endpoint;
+ this.wsBinding = (WebServiceBinding)endpoint.getBinding();
+
+ jaxwsBindingProvider = new JAXWSBindingProvider(endpoint,
+ servletHost,
+ modelFactories,
+ dataBindings,
+ defaultPort);
+ }
+
+ public void start() {
+ // create the JAXWS endpoint based on the provider
+ wsEndpoint = Endpoint.create(SOAPBinding.SOAP11HTTP_BINDING, jaxwsBindingProvider);
+
+ // TODO - There is something odd in the way that service name is calculated in
+ // some circumstances
+ // sometimes getServiceName() returns null
+ // sometimes getService().getQName returns a QName namespace that doesn't match the WSDL
+ // sometimes getNamespace() returns null
+ // So here we delve directly into the WSDL4J model as the Tuscany model isn't up to date
+ String targetNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getDefinition().getTargetNamespace();
+
+ //set up WSDL for Provider
+ List<Source> metadata = new ArrayList<Source>();
+
+ // WSDL DOM seems to be null here so went with writing out
+ // string version of WSDL and reading it back in again
+ //Node node = wsBinding.getWSDLDefinition().getDefinition().getDocumentationElement();
+ //Source source = new DOMSource(node);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ try {
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(wsBinding.getUserSpecifiedWSDLDefinition().getDefinition(), outStream);
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+
+ //System.out.println(outStream.toString());
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ Source source = new StreamSource(inStream);
+ source.setSystemId(targetNamespace);
+
+ metadata.add(source);
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+
+ QName portName = new QName(targetNamespace,
+ wsBinding.getPort().getName());
+ properties.put(Endpoint.WSDL_PORT, portName);
+
+ QName serviceName = new QName(targetNamespace,
+ wsBinding.getService().getQName().getLocalPart());
+ properties.put(Endpoint.WSDL_SERVICE, serviceName);
+
+ wsEndpoint.setMetadata(metadata);
+ wsEndpoint.setProperties(properties);
+
+ // Start up the endpoint
+ wsEndpoint.publish(wsBinding.getURI());
+
+ jaxwsBindingProvider.start();
+ }
+
+ public void stop() {
+ jaxwsBindingProvider.stop();
+ wsEndpoint.stop();
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..452c9f2f5e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/binding/ws/jaxws/ri/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..9a36d0e461
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.ws.jaxws.ri.JAXWSBindingProviderFactory;model=org.apache.tuscany.sca.binding.ws.WebServiceBinding
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml
new file mode 100644
index 0000000000..74a35634ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/ri/definitions.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+
+<!-- $Rev: 907636 $ $Date: 2010-02-09 01:39:16 +1300 (Tue, 09 Feb 2010) $ -->
+
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:bindingType type="sca:binding.ws" mayProvide="sca:SOAP sca:SOAP.v1_1 sca:SOAP.v1_2 tuscany:MTOM" alwaysProvides=""/>
+
+ <!-- see the file sca-policy-1.1-intents-definitions.xml in the -->
+ <!-- assembly-xsd module for spec defined intents -->
+
+ <!-- PolicyIntents defined by the SCA Runtime Extension for WS Binding Axis 2 -->
+
+ <sca:intent name="MTOM" constrains="sca:binding.ws">
+ <sca:description>
+ Communication through this binding requires MTOM support
+ </sca:description>
+ </sca:intent>
+
+ </sca:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLPortTestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLPortTestCase.java
new file mode 100644
index 0000000000..80aa145098
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLPortTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class WSDLPortTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.composite",
+ new Contribution("test", "target/test-classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ }
+
+ public void testMessageExchange() throws Exception {
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ public void testQuestionMarkWSDL() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/HelloWorldService/HelloWorld?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/HelloWorldService/HelloWorld?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName("http://helloworld",
+ "HelloWorldService"));
+ Port port = service.getPort("HelloWorldSoapPort");
+
+ String endpoint = getEndpoint(port);
+ assertEquals("http://localhost:8085/HelloWorldService/HelloWorld", endpoint);
+ }
+
+ protected String getEndpoint(Port port) {
+ List wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..98eb6e361b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..2c6c4fc92c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/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 org.apache.tuscany.sca.binding.ws.axis2.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorldWS;
+
+ public String getGreetings(String s) {
+ String response = helloWorldWS.getGreetings(s);
+ System.out.println("At client: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..3662007984
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/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 org.apache.tuscany.sca.binding.ws.axis2.helloworld;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ String response = "Hello " + s;
+ System.out.println("At service: " + response);
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.composite b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.composite
new file mode 100644
index 0000000000..9f74fc5c09
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="wsdlbinding">
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldClient"/>
+ <reference name="helloWorldWS">
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.helloworld.HelloWorldService"/>
+ <service name="HelloWorld">
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.wsdl b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.wsdl
new file mode 100644
index 0000000000..c5b59f1462
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws-ri/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/wsdlport/helloworld.wsdl
@@ -0,0 +1,80 @@
+<?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:8085/HelloWorldService/HelloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/LICENSE b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/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/sebastien/java/embed/modules/binding-ws-runtime-jaxws/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ac68264fcb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/META-INF/MANIFEST.MF
@@ -0,0 +1,55 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JAXWS-based WS Binding Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397353000
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JAXWS-based WS Binding Extensio
+ n
+Import-Package: javax.security.auth.callback;resolution:=optional,
+ javax.servlet,
+ javax.servlet.http,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.extensions.soap12,
+ javax.wsdl.factory;resolution:=optional,
+ javax.wsdl.xml;resolution:=optional,
+ javax.xml.namespace,
+ javax.xml.soap,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.ws,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.authentication.basic;version="2.0.0",
+ org.apache.tuscany.sca.policy.security;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.tuscany.sca.xsd.xml;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.ws.jaxws
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.binding.ws.jaxws;version="2.0.0"
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/NOTICE b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/pom.xml b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/pom.xml
new file mode 100644
index 0000000000..f0adefc38f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/pom.xml
@@ -0,0 +1,235 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-ws-runtime-jaxws</artifactId>
+ <name>Apache Tuscany SCA JAXWS-based WS Binding Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Test dependencies -->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!--
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+-->
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+<!--
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsimport</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>com.example.weather</packageName>
+ <wsdlDirectory>${basedir}/src/test/resources/wsdl</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>WeatherForecast.wsdl</wsdlFile>
+ </wsdlFiles>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>2.1</target>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <verbose>false</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </plugin>
+-->
+ </plugins>
+ </build>
+
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java
new file mode 100644
index 0000000000..bf573f9970
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java
@@ -0,0 +1,580 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Input;
+import javax.wsdl.OperationType;
+import javax.wsdl.PortType;
+import javax.wsdl.extensions.AttributeExtensible;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.extensions.soap12.SOAP12Operation;
+import javax.xml.namespace.QName;
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Node;
+
+/**
+ * Uses JAXWS Dispatch to invoke a remote web service
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXWSBindingInvoker implements Invoker, DataExchangeSemantics {
+ private final static String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ public static final String WSA_FINAL_NAMESPACE = "http://www.w3.org/2005/08/addressing";
+ public static final QName QNAME_WSA_FROM = new QName(WSA_FINAL_NAMESPACE, "From", "wsa");
+ public static final QName QNAME_WSA_TO = new QName(WSA_FINAL_NAMESPACE, "To", "wsa");
+ public static final QName QNAME_WSA_ACTION = new QName(WSA_FINAL_NAMESPACE, "Action", "wsa");
+ public static final QName QNAME_WSA_RELATESTO = new QName(WSA_FINAL_NAMESPACE, "RelatesTo", "wsa");
+ private static final QName submissionWSAWNS = new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing",
+ QNAME_WSA_ACTION.getLocalPart());
+ private static final QName finalWSANS = new QName("http://www.w3.org/2005/08/addressing",
+ QNAME_WSA_ACTION.getLocalPart());
+ private static final QName finalWSAWNS = new QName("http://www.w3.org/2006/05/addressing/wsdl",
+ QNAME_WSA_ACTION.getLocalPart());
+ private static final QName finalWSAMNS = new QName("http://www.w3.org/2007/05/addressing/metadata",
+ QNAME_WSA_ACTION.getLocalPart());
+
+ public static final String TUSCANY_PREFIX = "tuscany";
+ public static final QName CALLBACK_ID_REFPARM_QN = new QName(SCA11_TUSCANY_NS, "CallbackID", TUSCANY_PREFIX);
+ public static final QName CONVERSATION_ID_REFPARM_QN =
+ new QName(SCA11_TUSCANY_NS, "ConversationID", TUSCANY_PREFIX);
+
+ private Dispatch<SOAPMessage> dispatch;
+ private MessageFactory messageFactory;
+ private Operation operation;
+ private WebServiceBinding wsBinding;
+ private RuntimeEndpointReference endpointReference;
+
+ public JAXWSBindingInvoker(Operation operation,
+ WebServiceFeature[] features,
+ MessageFactory messageFactory,
+ WebServiceBinding wsBinding,
+ RuntimeEndpointReference endpointReference) {
+ this.messageFactory = messageFactory;
+ this.operation = operation;
+ this.wsBinding = wsBinding;
+ this.endpointReference = endpointReference;
+ this.dispatch = createDispatch(wsBinding);
+ }
+
+ private Dispatch<SOAPMessage> createDispatch(WebServiceBinding wsBinding) {
+ URL wsdlLocation = null;
+ try {
+ wsdlLocation = new URL(wsBinding.getGeneratedWSDLDocument().getDocumentBaseURI());
+ } catch (Exception e) {
+ try {
+ if (wsBinding.getUserSpecifiedWSDLDefinition().getLocation() != null) {
+ wsdlLocation = wsBinding.getUserSpecifiedWSDLDefinition().getLocation().toURL();
+ }
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+
+ QName serviceName = null;
+ QName portName = null;
+ Service service = null;
+
+ if (wsdlLocation != null) {
+ serviceName = wsBinding.getServiceName();
+ portName = new QName(serviceName.getNamespaceURI(), wsBinding.getPortName());
+ service = Service.create(wsdlLocation, serviceName);
+ } else {
+ serviceName = wsBinding.getService().getQName();
+ portName = new QName(serviceName.getNamespaceURI(), wsBinding.getPort().getName());
+ service = Service.create(serviceName);
+ service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, wsBinding.getURI());
+ }
+
+ return service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ SOAPMessage resp = invokeTarget(msg);
+ SOAPBody body = resp.getSOAPBody();
+ if (body != null) {
+ SOAPFault fault = body.getFault();
+ if (fault != null) {
+ // setFault(msg, fault);
+ } else {
+ // The 1st child element
+ msg.setBody(body.getChildElements().next());
+ }
+
+ }
+ } catch (SOAPFaultException e) {
+ setFault(msg, e);
+ } catch (WebServiceException e) {
+ msg.setFaultBody(e);
+ } catch (SOAPException e) {
+ msg.setFaultBody(e);
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+
+ return msg;
+ }
+
+ private void setFault(Message msg, SOAPFaultException e) {
+ SOAPFault fault = e.getFault();
+ Detail detail = fault.getDetail();
+ if (detail != null) {
+ for (Iterator i = detail.getDetailEntries(); i.hasNext();) {
+ DetailEntry entry = (DetailEntry)i.next();
+ FaultException fe = new FaultException(e.getMessage(), entry.getFirstChild(), e);
+ fe.setFaultName(entry.getElementQName());
+ msg.setFaultBody(fe);
+ }
+ }
+ }
+
+ protected String getSOAPAction(String operationName) {
+ Binding binding = wsBinding.getBinding();
+ if (binding != null) {
+ for (Object o : binding.getBindingOperations()) {
+ BindingOperation bop = (BindingOperation)o;
+ if (bop.getName().equalsIgnoreCase(operationName)) {
+ for (Object o2 : bop.getExtensibilityElements()) {
+ if (o2 instanceof SOAPOperation) {
+ return ((SOAPOperation)o2).getSoapActionURI();
+ } else if (o2 instanceof SOAP12Operation) {
+ return ((SOAP12Operation)o2).getSoapActionURI();
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ protected SOAPMessage invokeTarget(Message msg) throws SOAPException {
+ SOAPMessage soapMessage = messageFactory.createMessage();
+ SOAPPart soapPart = soapMessage.getSOAPPart();
+ javax.xml.soap.SOAPEnvelope envelope = soapPart.getEnvelope();
+
+ String action = getSOAPAction(operation.getName());
+
+ setHeaders(envelope.getHeader(), msg, action);
+
+ javax.xml.soap.SOAPBody body = envelope.getBody();
+ Object[] args = (Object[])msg.getBody();
+ // In the unit test the owner doc is null
+ // so explicitly adopt the node instead
+ // body.addDocument(((Node)args[0]).getOwnerDocument());
+ Node msgNode = body.getOwnerDocument().importNode((Node)args[0], true);
+ body.appendChild(msgNode);
+ soapMessage.saveChanges();
+ if (operation.isNonBlocking()) {
+ dispatch.invokeOneWay(soapMessage);
+ return null;
+ }
+
+ if (action != null) {
+ dispatch.getRequestContext().put(Dispatch.SOAPACTION_USE_PROPERTY, true);
+ dispatch.getRequestContext().put(Dispatch.SOAPACTION_URI_PROPERTY, action);
+ }
+ SOAPMessage response = dispatch.invoke(soapMessage);
+ return response;
+ }
+
+ protected void setHeaders(SOAPHeader sh, Message msg, String action) throws SOAPException {
+
+ Endpoint callbackEndpoint = msg.getFrom().getCallbackEndpoint();
+
+ // add WS-Addressing header for the invocation of a bidirectional
+ // service
+ // FIXME: is there any way to use the Axis2 addressing support for this?
+ if (callbackEndpoint != null) {
+ // // Load the actual callback endpoint URI into an Axis EPR ready
+ // to form the content of the wsa:From header
+ // EndpointReference fromEPR = new
+ // EndpointReference(callbackEndpoint.getBinding().getURI());
+ //
+ // addWSAFromHeader(sh, fromEPR);
+ SOAPHeaderElement fromH = sh.addHeaderElement(QNAME_WSA_FROM);
+ fromH.setTextContent(callbackEndpoint.getBinding().getURI());
+
+ addWSAActionHeader(sh, action);
+
+ // requestMC.setFrom(fromEPR);
+ } // end if
+
+ String toAddress = getToAddress(msg);
+ // requestMC.setTo( new EndpointReference(toAddress) );
+
+ if (isInvocationForCallback(msg)) {
+ addWSAToHeader(sh, toAddress, msg);
+ addWSAActionHeader(sh, action);
+ addWSARelatesTo(sh, msg);
+ } // end if
+
+ }
+
+ private String getToAddress(Message msg) throws ServiceRuntimeException {
+ String address = null;
+
+ // if target endpoint was not specified when this invoker was created,
+ // use dynamically specified target endpoint passed in with the message
+
+ String to = getPortLocation(wsBinding);
+ if (to == null) {
+ Endpoint ep = msg.getTo();
+ if (ep != null && ep.getBinding() != null) {
+ address = ep.getBinding().getURI();
+ } else {
+ throw new ServiceRuntimeException(
+ "[BWS20025] Unable to determine destination endpoint for endpoint reference " + endpointReference);
+ }
+ } else {
+ address = to;
+ }
+
+ return address;
+ } // end method getToAddress
+
+ protected String getPortLocation(WebServiceBinding binding) {
+ String ep = null;
+ if (binding.getPort() != null) {
+ List<?> wsdlPortExtensions = binding.getPort().getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ ep = ((SOAPAddress)extension).getLocationURI();
+ break;
+ }
+ if (extension instanceof SOAP12Address) {
+ SOAP12Address address = (SOAP12Address)extension;
+ ep = address.getLocationURI();
+ break;
+ }
+ }
+ }
+ if (ep == null || ep.equals("")) {
+ ep = binding.getURI();
+ }
+ return ep;
+ }
+
+ // private void addWSAFromHeader( SOAPHeader sh, EndpointReference fromEPR )
+ // throws AxisFault {
+ // OMElement epr = EndpointReferenceHelper.toOM(sh.getOMFactory(),
+ // fromEPR,
+ // QNAME_WSA_FROM,
+ // AddressingConstants.Final.WSA_NAMESPACE);
+ // sh.addChild(epr);
+ //
+ // } // end method addWSAFromHeader
+
+ private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS";
+
+ private void addWSAToHeader(SOAPHeader sh, String address, Message msg) throws SOAPException {
+ // Create wsa:To header which is required by ws-addressing spec
+ // OMElement wsaToOM = sh.getOMFactory().createOMElement(QNAME_WSA_TO);
+ // wsaToOM.setText( address );
+ // sh.addChild(wsaToOM);
+ SOAPHeaderElement toH = sh.addHeaderElement(QNAME_WSA_TO);
+ toH.setTextContent(address);
+
+ // Deal with Reference Parameters, if present - copy to the header
+ // without the wsa:ReferenceParameters wrapper
+ // OMElement refParms = (OMElement) msg.getHeaders().get(WS_REF_PARMS);
+ // Iterator ces = sh.getChildElements(new QName(WSA_FINAL_NAMESPACE,
+ // WS_REF_PARMS));
+ Iterator<SOAPElement> ces = sh.getChildElements();
+ while (ces.hasNext()) {
+ SOAPElement se = ces.next();
+ if (WS_REF_PARMS.equals(se.getElementQName().getLocalPart())) {
+ // if( refParms != null ) {
+ Iterator<SOAPElement> children = se.getChildElements();
+ while (children.hasNext()) {
+ SOAPElement node = (SOAPElement)children.next();
+ toH.addChildElement(node);
+ }
+ // } // end if
+ }
+ }
+
+ } // end method addWSAActionHeader
+
+ private void addWSAActionHeader(SOAPHeader sh, String action) throws SOAPException {
+ // Create wsa:Action header which is required by ws-addressing spec
+
+ if (action == null) {
+ PortType portType = ((WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface()).getPortType();
+ javax.wsdl.Operation op = portType.getOperation(operation.getName(), null, null);
+ action = getActionFromInputElement(wsBinding.getGeneratedWSDLDocument(), portType, op, op.getInput());
+ }
+
+ // OMElement actionOM =
+ // sh.getOMFactory().createOMElement(QNAME_WSA_ACTION);
+ // actionOM.setText(action == null ? "" : action);
+ // sh.addChild(actionOM);
+
+ SOAPHeaderElement actionH = sh.addHeaderElement(QNAME_WSA_ACTION);
+ actionH.setTextContent(action == null ? "" : action);
+
+ } // end method addWSAActionHeader
+
+ private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ protected static String SCA_CALLBACK_REL = "http://docs.oasis-open.org/opencsa/sca-bindings/ws/callback";
+
+ /**
+ * Adds a wsa:RelatesTo SOAP header if the incoming invocation had a
+ * wsa:MessageID SOAP header present - note that OASIS SCA requires that the
+ * RelationshipType attribute is set to a particular SCA value
+ *
+ * @param sh - the SOAP headers
+ * @param msg - the message
+ * @throws SOAPException
+ */
+ private void addWSARelatesTo(SOAPHeader sh, Message msg) throws SOAPException {
+ String idValue = (String)msg.getHeaders().get(WS_MESSAGE_ID);
+ if (idValue != null) {
+ SOAPHeaderElement relatesToH = sh.addHeaderElement(QNAME_WSA_RELATESTO);
+ relatesToH.addAttribute(new QName(null, "RelationshipType"), SCA_CALLBACK_REL);
+ relatesToH.setTextContent(idValue);
+ // OMElement relatesToOM = sh.getOMFactory().createOMElement(
+ // QNAME_WSA_RELATESTO );
+ // OMAttribute relType =
+ // sh.getOMFactory().createOMAttribute("RelationshipType", null,
+ // SCA_CALLBACK_REL);
+ // relatesToOM.addAttribute( relType );
+ // relatesToOM.setText( idValue );
+ // sh.addChild( relatesToOM );
+ }
+ } // end method addWSARelatesTo
+
+ /**
+ * Indicates if the invocation is for the callback of a bidirectional
+ * service
+ *
+ * @param msg the Message
+ * @return true if the invocation is for the callback of a bidirectional
+ * service, false otherwise
+ */
+ private boolean isInvocationForCallback(Message msg) {
+ org.apache.tuscany.sca.assembly.EndpointReference fromEPR = msg.getFrom();
+ if (fromEPR != null) {
+ ComponentReference ref = fromEPR.getReference();
+ if (ref != null)
+ return ref.isForCallback();
+ } // end if
+ return false;
+ } // end method isInvocationForCallback
+
+ /**
+ * getActionFromInputElement
+ *
+ * @param def the wsdl:definitions which contains the wsdl:portType
+ * @param wsdl4jPortType the wsdl:portType which contains the wsdl:operation
+ * @param op the wsdl:operation which contains the input element
+ * @param input the input element to be examined to generate the wsa:Action
+ * @return either the wsaw:Action from the input element or an action
+ * generated using the DefaultActionPattern
+ */
+ public static String getActionFromInputElement(Definition def,
+ PortType wsdl4jPortType,
+ javax.wsdl.Operation op,
+ Input input) {
+ String result = getWSAWActionExtensionAttribute(input);
+ if (result == null) {
+ result = generateActionFromInputElement(def, wsdl4jPortType, op, input);
+ }
+ return result;
+ }
+
+ private static String getWSAWActionExtensionAttribute(AttributeExtensible ae) {
+ // Search first for a wsaw:Action using the submission namespace
+ Object attribute = ae.getExtensionAttribute(submissionWSAWNS);
+ // Then if that did not exist one using the w3c WSAM namespace
+ if (attribute == null) {
+ attribute = ae.getExtensionAttribute(finalWSAMNS);
+ }
+ // Then if that did not exist one using the w3c WSAW namespace
+ // (for backwards compat reasons)
+ if (attribute == null) {
+ attribute = ae.getExtensionAttribute(finalWSAWNS);
+ }
+ // Then finally if that did not exist, try the 2005/08 NS
+ // (Included here because it's needed for Apache Muse)
+ if (attribute == null) {
+ attribute = ae.getExtensionAttribute(finalWSANS);
+ }
+
+ // wsdl4j may return a String, QName or a List of either
+ // If it is a list, extract the first element
+ if (attribute instanceof List) {
+ List l = (List)attribute;
+ if (l.size() > 0) {
+ attribute = l.get(0);
+ } else {
+ attribute = null;
+ }
+ }
+
+ // attribute must now be a QName or String or null
+ // If it is a QName, take the LocalPart as a String
+ if (attribute instanceof QName) {
+ QName qn = (QName)attribute;
+ attribute = qn.getLocalPart();
+ }
+
+ if ((attribute instanceof String)) {
+ String result = (String)attribute;
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Generate the Action for an Input using the Default Action Pattern
+ * <p/>
+ * Pattern is defined as [target namespace][delimiter][port type
+ * name][delimiter][input name]
+ *
+ * @param def is required to obtain the targetNamespace
+ * @param wsdl4jPortType is required to obtain the portType name
+ * @param op is required to generate the input name if not explicitly
+ * specified
+ * @param input is required for its name if specified
+ * @return a wsa:Action value based on the Default Action Pattern and the
+ * provided objects
+ */
+ public static String generateActionFromInputElement(Definition def,
+ PortType wsdl4jPortType,
+ javax.wsdl.Operation op,
+ Input input) {
+ // Get the targetNamespace of the wsdl:definitions
+ String targetNamespace = def.getTargetNamespace();
+
+ // Determine the delimiter. Per the spec: 'is ":" when the [target
+ // namespace] is a URN, otherwise "/".
+ // Note that for IRI schemes other than URNs which aren't path-based
+ // (i.e. those that outlaw the "/"
+ // character), the default action value may not conform to the rules of
+ // the IRI scheme. Authors
+ // are advised to specify explicit values in the WSDL in this case.'
+ String delimiter = SLASH;
+ if (targetNamespace.toLowerCase().startsWith(URN)) {
+ delimiter = COLON;
+ }
+
+ // Get the portType name (as a string to be included in the action)
+ String portTypeName = wsdl4jPortType.getQName().getLocalPart();
+ // Get the name of the input element (and generate one if none
+ // explicitly specified)
+ String inputName = getNameFromInputElement(op, input);
+
+ // Append the bits together
+ StringBuffer sb = new StringBuffer();
+ sb.append(targetNamespace);
+ // Deal with the problem that the targetNamespace may or may not have a
+ // trailing delimiter
+ if (!targetNamespace.endsWith(delimiter)) {
+ sb.append(delimiter);
+ }
+ sb.append(portTypeName);
+ sb.append(delimiter);
+ sb.append(inputName);
+
+ // Resolve the action from the StringBuffer
+ String result = sb.toString();
+
+ return result;
+ }
+
+ /**
+ * Get the name of the specified Input element using the rules defined in
+ * WSDL 1.1 Section 2.4.5 http://www.w3.org/TR/wsdl#_names
+ */
+ private static String getNameFromInputElement(javax.wsdl.Operation op, Input input) {
+ // Get the name from the input element if specified.
+ String result = input.getName();
+
+ // If not we'll have to generate it.
+ if (result == null) {
+ // If Request-Response or Solicit-Response do something special per
+ // WSDL 1.1 Section 2.4.5
+ OperationType operationType = op.getStyle();
+ if (null != operationType) {
+ if (operationType.equals(OperationType.REQUEST_RESPONSE)) {
+ result = op.getName() + REQUEST;
+ } else if (operationType.equals(OperationType.SOLICIT_RESPONSE)) {
+ result = op.getName() + RESPONSE;
+ }
+ }
+ // If the OperationType was not available for some reason, assume
+ // on-way or notification
+ if (result == null) {
+ result = op.getName();
+ }
+ }
+ return result;
+ }
+
+ private static final String URN = "urn";
+ private static final String SLASH = "/";
+ private static final String COLON = ":";
+ private static final String REQUEST = "Request";
+ private static final String RESPONSE = "Response";
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingProvider.java b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingProvider.java
new file mode 100644
index 0000000000..5cc9277201
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingProvider.java
@@ -0,0 +1,314 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.jaxws;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.xml.namespace.QName;
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceProvider;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+@WebServiceProvider
+@ServiceMode(Mode.MESSAGE)
+public class JAXWSBindingProvider implements Provider<SOAPMessage> {
+ public static final String WSA_FINAL_NAMESPACE = "http://www.w3.org/2005/08/addressing";
+ public static final QName QNAME_WSA_ADDRESS = new QName(WSA_FINAL_NAMESPACE, "Address");
+ public static final QName QNAME_WSA_FROM = new QName(WSA_FINAL_NAMESPACE, "From");
+ public static final QName QNAME_WSA_REPLYTO = new QName(WSA_FINAL_NAMESPACE, "ReplyTo");
+ public static final QName QNAME_WSA_REFERENCE_PARAMETERS = new QName(WSA_FINAL_NAMESPACE, "ReferenceParameters");
+ public static final QName QNAME_WSA_MESSAGEID = new QName(WSA_FINAL_NAMESPACE, "MessageID");
+
+ private MessageFactory messageFactory;
+ private RuntimeEndpoint endpoint;
+ private WebServiceBinding wsBinding;
+ private javax.xml.soap.MessageFactory soapMessageFactory;
+ private SOAPFactory soapFactory;
+
+ @Resource
+ private WebServiceContext context;
+ private RuntimeAssemblyFactory assemblyFactory;
+ private WebServiceBindingFactory webServiceBindingFactory;
+
+ public JAXWSBindingProvider(){
+ // to keep Axis2 JAXWS implementation happy
+ }
+
+ public JAXWSBindingProvider(RuntimeEndpoint endpoint,
+ ServletHost servletHost,
+ FactoryExtensionPoint modelFactories,
+ DataBindingExtensionPoint dataBindings, String defaultPort) {
+
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+
+ this.soapMessageFactory = modelFactories.getFactory(javax.xml.soap.MessageFactory.class);
+ this.soapFactory = modelFactories.getFactory(SOAPFactory.class);
+ this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+ this.webServiceBindingFactory = (WebServiceBindingFactory)modelFactories.getFactory(WebServiceBindingFactory.class);
+
+ // soapMessageFactory = javax.xml.soap.MessageFactory.newInstance();
+ // soapFactory = SOAPFactory.newInstance();
+
+ this.endpoint = endpoint;
+ this.wsBinding = (WebServiceBinding)endpoint.getBinding();
+
+ // A WSDL document should always be present in the binding
+ if (wsBinding.getGeneratedWSDLDocument() == null) {
+ throw new ServiceRuntimeException("No WSDL document for " + endpoint.getURI());
+ }
+
+ // Set to use the DOM data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ contract.getInterface().resetDataBinding(Node.class.getName());
+
+ // Can we safely assume there is only one port because you configure
+ // a binding in the following ways:
+ // 1/ default - one port generated = host domain : host port / structural path
+ // 2/ uri="absolute addr" - one port generated = host domain : uri port / uri path
+ // 3/ uri="relative addr" - one port generated = host domain : host port / structural path / relative path
+ // 4/ wsdl.binding - one port generated = host domain : host port / structural path
+ // 5/ wsdl.port - one port generated = host domain : port port / port path
+ // 6/ wsa:Address - one port generated = host domain : address port / address path
+ // 7/ 4 + 6 - as 6
+
+ // TODO the binding URI will currently have been calculated during build
+ // however we don't give the provider a chance to get in and effect the
+ // calculation (see above comment). For now just fake the addition of binding
+ // specific processing by adding a root if it's not already present
+ if (!wsBinding.getURI().startsWith("http://")) {
+ String serviceURI = null;
+
+ // look in the port for the location URL
+ List wsdlPortExtensions = wsBinding.getPort().getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ serviceURI = ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+
+ if (serviceURI == null ||
+ !serviceURI.startsWith("http://")){
+ serviceURI = "http://localhost:" + defaultPort + wsBinding.getURI();
+ }
+
+ wsBinding.setURI(serviceURI);
+ }
+ System.out.println("Binding.ws JAXWS provider - Service URI: " + wsBinding.getURI());
+ }
+
+ public void start() {
+ // TODO - do we need this?
+ }
+
+ public void stop() {
+ // TODO - do we need this?
+ }
+
+ public SOAPMessage invoke(SOAPMessage request) {
+ try {
+ // Assuming document-literal-wrapper style
+ Node root = request.getSOAPBody().getFirstChild();
+ String operationName = root.getLocalName();
+ Operation operation = null;
+ for (InvocationChain invocationChain : endpoint.getInvocationChains()) {
+ if (operationName.equals(invocationChain.getSourceOperation().getName())) {
+ operation = invocationChain.getSourceOperation();
+ break;
+ }
+ }
+ if (operation == null) {
+ throw new SOAPException("Operation not found: " + operationName);
+ }
+
+ Message requestMsg = messageFactory.createMessage();
+ Object[] body = new Object[]{root};
+ requestMsg.setBody(body);
+ requestMsg.setOperation(operation);
+
+ SOAPHeader header = request.getSOAPHeader();
+ String callbackAddress = null;
+ if (header != null) {
+ callbackAddress = handleCallbackAddress( header, requestMsg );
+ // Retrieve other callback-related headers
+ handleMessageIDHeader( header, requestMsg );
+ } // end if
+
+ // Create a from EPR to hold the details of the callback endpoint
+ EndpointReference from = null;
+ if (callbackAddress != null ) {
+ // Check for special (& not allowed!) WS_Addressing values
+ checkCallbackAddress( callbackAddress, request );
+ //
+ from = assemblyFactory.createEndpointReference();
+ Endpoint fromEndpoint = assemblyFactory.createEndpoint();
+ from.setTargetEndpoint(fromEndpoint);
+ from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ requestMsg.setFrom(from);
+ Endpoint callbackEndpoint = assemblyFactory.createEndpoint();
+ //
+ WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
+ cbBinding.setURI(callbackAddress);
+ callbackEndpoint.setBinding(cbBinding);
+ //
+ callbackEndpoint.setURI(callbackAddress);
+ callbackEndpoint.setUnresolved(true);
+ from.setCallbackEndpoint(callbackEndpoint);
+ }
+
+ Message responseMsg = endpoint.invoke(operation, requestMsg);
+
+ SOAPMessage response = soapMessageFactory.createMessage();
+ if (responseMsg.isFault()) {
+// ServiceRuntimeException e = responseMsg.getBody();
+// throw e;
+
+ FaultException fe = responseMsg.getBody();
+ SOAPFault fault = response.getSOAPBody().addFault(new QName(response.getSOAPBody().getNamespaceURI(), "Server"), fe.getMessage());
+ Detail d = fault.addDetail();
+ DetailEntry de = d.addDetailEntry(fe.getFaultName());
+ SOAPElement dece = de.addChildElement("message");
+ if (fe.getMessage() != null) {
+ dece.addTextNode(fe.getMessage());
+ }
+
+ } else {
+ Element element = responseMsg.getBody();
+ response.getSOAPBody().addChildElement(soapFactory.createElement(element));
+ }
+ return response;
+ } catch (SOAPException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS";
+ private String handleCallbackAddress( SOAPHeader header, Message msg ) {
+ String callbackAddress = null;
+
+ Iterator<SOAPElement> it = header.getChildElements(QNAME_WSA_FROM);
+ SOAPElement from = it.hasNext() ? it.next() : null;
+ if( from == null ) {
+ Iterator<SOAPElement> it2 = header.getChildElements(QNAME_WSA_REPLYTO);
+ from = it2.hasNext() ? it2.next() : null;
+ }
+
+ if (from != null) {
+ Iterator<SOAPElement> it2 = header.getChildElements(QNAME_WSA_ADDRESS);
+ SOAPElement callbackAddrElement = it2.hasNext() ? it2.next() : null;
+ if (callbackAddrElement != null) {
+ if (endpoint.getService().getInterfaceContract().getCallbackInterface() != null) {
+ callbackAddress = callbackAddrElement.getTextContent();
+ }
+// OMElement refParms = from.getFirstChildWithName(QNAME_WSA_REFERENCE_PARAMETERS);
+ Iterator<SOAPElement> it3 = header.getChildElements(QNAME_WSA_REFERENCE_PARAMETERS);
+ SOAPElement refParms = it3.hasNext() ? it3.next() : null;
+ if( refParms != null ) msg.getHeaders().put(WS_REF_PARMS, refParms);
+ }
+ } // end if
+
+ return callbackAddress;
+ } // end method handleCallbackAddress
+
+ private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ /**
+ * Handle a SOAP wsa:MessageID header - place the contents into the Tuscany message for use by any callback
+ * @param header - the SOAP Headers
+ * @param msg - the Tuscany Message
+ */
+ private void handleMessageIDHeader( SOAPHeader header, Message msg ) {
+ if( header == null ) return;
+ Iterator<SOAPElement> it = header.getChildElements(QNAME_WSA_MESSAGEID);
+ SOAPElement messageID = it.hasNext() ? it.next() : null;
+ if (messageID != null) {
+ String idValue = messageID.getTextContent();
+ // Store the value of the message ID element into the message under "WS_MESSAGE_ID"...
+ msg.getHeaders().put(WS_MESSAGE_ID, idValue);
+ } // end if
+ } // end method handleMessageID
+ // Special WS_Addressing values
+ private static String WS_ADDR_ANONYMOUS = "http://www.w3.org/2005/08/addressing/anonymous";
+ private static String WS_ADDR_NONE = "http://www.w3.org/2005/08/addressing/none";
+
+ /**
+ * Check if the received callback address has either of the special WS-Addressing forms which are outlawed by the
+ * Web Service Binding specification [BWS50004]
+ * @param callbackAddress - the received callback address
+ * @param inMC - the Axis message context for the received forward call
+ * @throws AxisFault - throws a "OnlyNonAnonymousAddressSupportedFault" if the callback address has either of the special forms
+ */
+ private void checkCallbackAddress( String callbackAddress, SOAPMessage request) {
+ // If the address is anonymous or none, throw a SOAP fault...
+ if( WS_ADDR_ANONYMOUS.equals(callbackAddress) || WS_ADDR_NONE.equals(callbackAddress) ) {
+ triggerOnlyNonAnonymousAddressSupportedFault(request, "wsa:From");
+ }
+ } // end method checkCallbackAddress
+ // wsa:OnlyAnonymousAddressSupported
+
+ // wsa:OnlyNonAnonymousAddressSupported
+ public void triggerOnlyNonAnonymousAddressSupportedFault(SOAPMessage request, String incorrectHeaderName){
+// TODO
+// String namespace = (String)messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+// if (Submission.WSA_NAMESPACE.equals(namespace)) {
+// triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
+// AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
+// incorrectHeaderName, Submission.FAULT_INVALID_HEADER,
+// null, AddressingMessages.getMessage(
+// "spec.submission.FAULT_INVALID_HEADER_REASON"));
+// } else {
+// triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
+// AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
+// incorrectHeaderName, Final.FAULT_INVALID_HEADER,
+// Final.FAULT_ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED,
+// AddressingMessages.getMessage(
+// "spec.final.FAULT_INVALID_HEADER_REASON"));
+// }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/LICENSE b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/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/sebastien/java/embed/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c71dfdb8d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF
@@ -0,0 +1,60 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.ws.wsdlgen;uses:="org.a
+ pache.tuscany.sca.databinding,org.apache.tuscany.sca.interfacedef.uti
+ l,org.apache.tuscany.sca.core,org.apache.tuscany.sca.policy,javax.wsd
+ l.extensions.schema,javax.xml.namespace,javax.wsdl.xml,javax.wsdl.ext
+ ensions,org.apache.tuscany.sca.contribution.resolver,org.oasisopen.sca,org
+ .apache.ws.commons.schema,javax.wsdl.factory,org.apache.tuscany.sca.a
+ ssembly,javax.wsdl.extensions.soap,javax.xml.parsers,org.apache.tusca
+ ny.sca.monitor,org.apache.tuscany.sca.interfacedef.java,org.apache.tu
+ scany.sca.interfacedef,org.w3c.dom,javax.wsdl,org.apache.tuscany.sca.
+ binding.ws,javax.wsdl.extensions.soap12,org.apache.tuscany.sca.databi
+ nding.jaxb,org.apache.tuscany.sca.interfacedef.wsdl,org.apache.ws.com
+ mons.schema.utils,org.apache.tuscany.sca.xsd";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Web Service binding WSDL Generator
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Web Service binding WSDL Genera
+ tor
+Import-Package: javax.jws;resolution:=optional,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.schema,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.extensions.soap12,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.bind.annotation;resolution:=optional,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.ws;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.wsdlgen;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.jaxb;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.jaxws;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.tuscany.sca.xsd.xml;version="2.0.0";resolution:=optional,
+ org.apache.ws.commons.schema,
+ org.apache.ws.commons.schema.utils,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.ws.wsdlgen
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/NOTICE b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/pom.xml b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/pom.xml
new file mode 100644
index 0000000000..5d56109cde
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/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-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <name>Apache Tuscany SCA Web Service binding WSDL Generator</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
new file mode 100644
index 0000000000..516a62a556
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
@@ -0,0 +1,359 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.wsdlgen;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ResolverExtension;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BindingWSDLGenerator {
+ private static final Logger logger = Logger.getLogger(BindingWSDLGenerator.class.getName());
+ private static final QName SOAP12_INTENT = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "SOAP.v1_2");
+
+ public static boolean printWSDL; // external code sets this to print generated WSDL
+
+ private BindingWSDLGenerator() {
+ // this class has static methods only and cannot be instantiated
+ }
+
+ /**
+ * Log a warning message.
+ * @param problem
+ */
+ private static void logWarning(Problem problem) {
+ Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getResourceBundleName());
+ if (problemLogger != null){
+ problemLogger.logp(Level.WARNING, problem.getSourceClassName(), null, problem.getMessageId(), problem.getMessageParams());
+ } else {
+ logger.severe("Can't get logger " + problem.getSourceClassName()+ " with bundle " + problem.getResourceBundleName());
+ }
+ }
+
+ /**
+ * Report a warning.
+ * @param message
+ * @param binding
+ * @param parameters
+ */
+ private static void warning(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) {
+ Problem problem = monitor.createProblem(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.WARNING, wsBinding, message, (Object[])messageParameters);
+ if (monitor != null) {
+ monitor.problem(problem);
+ } else {
+ logWarning(problem);
+ }
+ }
+
+ /**
+ * Report an error.
+ * @param message
+ * @param binding
+ * @param parameters
+ */
+ private static void error(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) {
+ Problem problem = monitor.createProblem(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR, wsBinding, message, (Object[])messageParameters);
+ if (monitor != null) {
+ monitor.problem(problem);
+ } else {
+ throw new WSDLGenerationException(problem.toString(), null, problem);
+ }
+ }
+
+ /**
+ * Report an exception error.
+ * @param message
+ * @param binding
+ * @param exception
+ */
+ private static void error(Monitor monitor, String message, WebServiceBinding wsBinding, Exception ex) {
+ Problem problem = monitor.createProblem(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR, wsBinding, message, ex);
+ if (monitor != null) {
+ monitor.problem(problem);
+ } else {
+ throw new WSDLGenerationException(problem.toString(), ex, problem);
+ }
+ }
+
+ /**
+ * Report a fatal error.
+ * @param message
+ * @param binding
+ * @param exception
+ */
+ private static void fatal(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) {
+ Problem problem = monitor.createProblem(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR,wsBinding, message, (Object[])messageParameters);
+ throw new WSDLGenerationException(problem.toString(), null, problem);
+ }
+
+ /**
+ * Report a fatal exception error.
+ * @param message
+ * @param binding
+ * @param exception
+ */
+ private static void fatal(Monitor monitor, String message, WebServiceBinding wsBinding, Exception ex) {
+ Problem problem = monitor.createProblem(BindingWSDLGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR, wsBinding, message, ex);
+ throw new WSDLGenerationException(problem.toString(), ex, problem);
+ }
+
+ /**
+ * This method can be called from the binding builder or from the runtime.
+ * Report problems and exceptions in the most appropriate way for both
+ * of these cases.
+ */
+ public static void generateWSDL(Component component,
+ Contract contract,
+ WebServiceBinding wsBinding,
+ ExtensionPointRegistry extensionPoints,
+ Monitor monitor) {
+ if (monitor == null) {
+ monitor = new BuilderContext(extensionPoints).getMonitor();
+ }
+ try {
+ createWSDLDocument(component, contract, wsBinding, extensionPoints, monitor);
+ } catch (WSDLGenerationException ex) {
+ if (ex.getProblem() != null) {
+ warning(monitor, "WsdlGenProblem", wsBinding, component.getName(), contract.getName());
+ if (monitor != null) {
+ monitor.problem(ex.getProblem());
+ } else {
+ throw ex;
+ }
+ } else if (ex.getCause() instanceof Exception) {
+ warning(monitor, "WsdlGenException", wsBinding, component.getName(), contract.getName());
+ error(monitor, "WsdlGenException2", wsBinding, (Exception)ex.getCause());
+ } else { // should never happen
+ throw new IllegalStateException(ex);
+ }
+ } catch (RuntimeException ex) {
+ warning(monitor, "WsdlGenException", wsBinding, component.getName(), contract.getName());
+ error(monitor, "WsdlGenException2", wsBinding, component.getName(), contract.getName(), ex.getMessage());
+ }
+ }
+
+ private static void createWSDLDocument(Component component,
+ Contract contract,
+ WebServiceBinding wsBinding,
+ ExtensionPointRegistry extensionPoints,
+ Monitor monitor) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ DataBindingExtensionPoint dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
+ WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+
+ if (((Contract)contract).getInterfaceContract(wsBinding) == null) {
+ // can happen if incorrect component service name
+ fatal(monitor, "MissingInterfaceContract", wsBinding, component.getName(), contract.getName());
+ }
+
+ InterfaceContract icontract = wsBinding.getBindingInterfaceContract();
+ if (icontract == null) {
+ icontract = ((Contract)contract).getInterfaceContract(wsBinding).makeUnidirectional(false);
+ if (icontract instanceof JavaInterfaceContract) {
+ ModelResolver resolver = component instanceof ResolverExtension ?
+ ((ResolverExtension)component).getModelResolver() : null;
+ icontract = createWSDLInterfaceContract(
+ (JavaInterfaceContract)icontract,
+ requiresSOAP12(wsBinding),
+ resolver,
+ dataBindings,
+ wsdlFactory,
+ xsdFactory,
+ documentBuilderFactory,
+ monitor);
+ } else {
+ try {
+ //TUSCANY-2316 Cloning the Interface Contract to avoid overriding data binding information
+ icontract = (InterfaceContract)icontract.clone();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ wsBinding.setBindingInterfaceContract(icontract);
+ }
+
+ /*
+ // Look at all the Web Service bindings of the SCA service to see if any
+ // of them have an existing generated WSDL definitions document. If found,
+ // use it for this binding as well. If not found, generate a new document.
+ Definition definition = null;
+ for (Binding binding : contract.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ definition = ((WebServiceBinding)binding).getWSDLDocument();
+ if (definition != null) {
+ wsBinding.setWSDLDocument(definition);
+ break;
+ }
+ }
+ }
+ */
+ // The above code is currently not used. Instead, we only look
+ // for a WSDL definitions document in this binding and don't
+ // attempt to share the same document across multiple bindings.
+
+ // generate a WSDL definitions document if needed
+ Definition definition = wsBinding.getGeneratedWSDLDocument();
+ if (definition == null) {
+ definition = WSDLServiceGenerator.configureWSDLDefinition(wsBinding, component, contract, monitor);
+ wsBinding.setGeneratedWSDLDocument(definition);
+ }
+ }
+
+ protected static boolean requiresSOAP12(WebServiceBinding wsBinding) {
+ if (wsBinding instanceof PolicySubject) {
+ List<Intent> intents = ((PolicySubject)wsBinding).getRequiredIntents();
+ for (Intent intent : intents) {
+ if (SOAP12_INTENT.equals(intent.getName())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Create a WSDLInterfaceContract from a JavaInterfaceContract
+ */
+ public static WSDLInterfaceContract createWSDLInterfaceContract(JavaInterfaceContract contract,
+ boolean requiresSOAP12,
+ ModelResolver resolver,
+ DataBindingExtensionPoint dataBindings,
+ WSDLFactory wsdlFactory,
+ XSDFactory xsdFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ Monitor monitor) {
+
+ WSDLInterfaceContract wsdlContract = wsdlFactory.createWSDLInterfaceContract();
+
+ if (contract.getInterface() != null){
+ WSDLInterface wsdlInterface = createWSDLInterface((JavaInterface)contract.getInterface(),
+ requiresSOAP12,
+ resolver,
+ dataBindings,
+ wsdlFactory,
+ xsdFactory,
+ documentBuilderFactory,
+ monitor);
+ wsdlContract.setInterface(wsdlInterface);
+ }
+
+ if (contract.getCallbackInterface() != null){
+ WSDLInterface wsdlInterface = createWSDLInterface((JavaInterface)contract.getCallbackInterface(),
+ requiresSOAP12,
+ resolver,
+ dataBindings,
+ wsdlFactory,
+ xsdFactory,
+ documentBuilderFactory,
+ monitor);
+ wsdlContract.setCallbackInterface(wsdlInterface);
+ }
+
+ return wsdlContract;
+ }
+
+ /**
+ * Create a WSDLInterface from a JavaInterface
+ */
+ public static WSDLInterface createWSDLInterface(JavaInterface javaInterface,
+ boolean requiresSOAP12,
+ ModelResolver resolver,
+ DataBindingExtensionPoint dataBindings,
+ WSDLFactory wsdlFactory,
+ XSDFactory xsdFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ Monitor monitor) {
+
+ WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface();
+ WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
+
+ Definition def = null;
+ try {
+ Interface2WSDLGenerator wsdlGenerator =
+ new Interface2WSDLGenerator(requiresSOAP12, resolver, dataBindings, xsdFactory, documentBuilderFactory, monitor);
+ def = wsdlGenerator.generate(javaInterface, wsdlDefinition);
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+
+ // for debugging
+ if (printWSDL) {
+ try {
+ System.out.println("Generated WSDL for Java interface " + javaInterface.getName() + " class " + javaInterface.getJavaClass().getName());
+ WSDLWriter writer = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(def, System.out);
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+ }
+
+ wsdlDefinition.setDefinition(def);
+ wsdlInterface.setWsdlDefinition(wsdlDefinition);
+ wsdlInterface.setRemotable(true);
+ wsdlInterface.setUnresolved(false);
+ wsdlInterface.setRemotable(true);
+ PortType portType = (PortType)def.getAllPortTypes().values().iterator().next();
+ wsdlInterface.setPortType(portType);
+
+ try {
+ wsdlFactory.createWSDLInterface(wsdlInterface, portType, wsdlDefinition, resolver, monitor);
+ } catch (InvalidInterfaceException e) {
+ throw new WSDLGenerationException(e);
+ }
+
+ return wsdlInterface;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
new file mode 100644
index 0000000000..a072b31322
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
@@ -0,0 +1,897 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.wsdlgen;
+
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.OperationType;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.wsdl.PortType;
+import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.factory.WSDLFactory;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaException;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Interface2WSDLGenerator {
+ private static final Logger logger = Logger.getLogger(Interface2WSDLGenerator.class.getName());
+ private static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+ private static final String SCHEMA_NAME = "schema";
+ private static final QName SCHEMA_QNAME = new QName(SCHEMA_NS, SCHEMA_NAME);
+ private static final String XMLNS_NS = "http://www.w3.org/2000/xmlns/";
+
+ private static final String ANYTYPE_NAME = "anyType";
+ private static final QName ANYTYPE_QNAME = new QName(SCHEMA_NS, ANYTYPE_NAME);
+
+
+ private WSDLFactory factory;
+ private DataBindingExtensionPoint dataBindings;
+ private WSDLDefinitionGenerator definitionGenerator;
+ private DocumentBuilderFactory documentBuilderFactory;
+ private boolean requiresSOAP12;
+ private ModelResolver resolver;
+ private XSDFactory xsdFactory;
+ private Monitor monitor;
+
+ public Interface2WSDLGenerator(boolean requiresSOAP12,
+ ModelResolver resolver,
+ DataBindingExtensionPoint dataBindings,
+ XSDFactory xsdFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ Monitor monitor) throws WSDLException {
+ super();
+ this.requiresSOAP12 = requiresSOAP12;
+ this.resolver = resolver;
+ this.documentBuilderFactory = documentBuilderFactory;
+ definitionGenerator = new WSDLDefinitionGenerator(requiresSOAP12);
+ this.dataBindings = dataBindings;
+ this.xsdFactory = xsdFactory;
+ this.monitor = monitor;
+ this.factory = WSDLFactory.newInstance();
+ }
+
+ /**
+ * Log a warning message.
+ * @param problem
+ */
+ private static void logWarning(Problem problem) {
+ Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getResourceBundleName());
+ if (problemLogger != null){
+ problemLogger.logp(Level.WARNING, problem.getSourceClassName(), null, problem.getMessageId(), problem.getMessageParams());
+ } else {
+ logger.severe("Can't get logger " + problem.getSourceClassName()+ " with bundle " + problem.getResourceBundleName());
+ }
+ }
+
+ /**
+ * Report a warning.
+ * @param message
+ * @param binding
+ * @param parameters
+ */
+ private void warning(String message, Interface interfaze, String... messageParameters) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "wsdlgen-validation-messages", Severity.WARNING, interfaze, message, (Object[])messageParameters);
+ if (monitor != null) {
+ monitor.problem(problem);
+ } else {
+ logWarning(problem);
+ }
+ }
+
+ /**
+ * Report a fatal error.
+ * @param message
+ * @param binding
+ * @param parameters
+ */
+ private void fatal(String message, Interface interfaze, String... messageParameters) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "wsdlgen-validation-messages", Severity.ERROR, interfaze, message, (Object[])messageParameters);
+ throw new WSDLGenerationException(problem.toString(), null, problem);
+ }
+
+ private XMLTypeHelper getTypeHelper(DataType type, Map<String, XMLTypeHelper> helpers) {
+ if (type == null) {
+ return null;
+ }
+ String db = type.getDataBinding();
+ if (db == null) {
+ return null;
+ }
+ if ("java:array".equals(db)) {
+ DataType dt = (DataType)type.getLogical();
+ db = dt.getDataBinding();
+ }
+ return helpers.get(db);
+ }
+
+ private boolean inputTypesCompatible(DataType wrapperType, DataType<List<DataType>> inputType, Map<String, XMLTypeHelper> helpers) {
+ XMLTypeHelper wrapperHelper = getTypeHelper(wrapperType, helpers);
+ for (DataType dt : inputType.getLogical()) {
+ if (getTypeHelper(dt, helpers) != wrapperHelper) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean outputTypeCompatible(DataType wrapperType, DataType outputType, Map<String, XMLTypeHelper> helpers) {
+ if (getTypeHelper(outputType, helpers) != getTypeHelper(wrapperType, helpers)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private void addDataType(Map<XMLTypeHelper, List<DataType>> map, DataType type, Map<String, XMLTypeHelper> helpers) {
+ if (type == null) {
+ return;
+ }
+ String db = type.getDataBinding();
+ if (db == null) {
+ return;
+ }
+ if ("java:array".equals(db)) {
+ DataType dt = (DataType)type.getLogical();
+ db = dt.getDataBinding();
+ }
+ XMLTypeHelper helper = helpers.get(db);
+ List<DataType> types = map.get(helper);
+ if (types == null) {
+ types = new ArrayList<DataType>();
+ map.put(helper, types);
+ }
+ types.add(type);
+ }
+
+ private Map<XMLTypeHelper, List<DataType>> getDataTypes(Interface intf, boolean useWrapper, Map<String, XMLTypeHelper> helpers) {
+ Map<XMLTypeHelper, List<DataType>> dataTypes = new HashMap<XMLTypeHelper, List<DataType>>();
+ for (Operation op : intf.getOperations()) {
+ WrapperInfo wrapper = op.getWrapper();
+ DataType dt1 = null;
+ boolean useInputWrapper = useWrapper & wrapper != null;
+ if (useInputWrapper) {
+ dt1 = wrapper.getInputWrapperType();
+ useInputWrapper &= inputTypesCompatible(dt1, op.getInputType(), helpers);
+ }
+ if (useInputWrapper) {
+ addDataType(dataTypes, dt1, helpers);
+ } else {
+ for (DataType dt : op.getInputType().getLogical()) {
+ addDataType(dataTypes, dt, helpers);
+ }
+ }
+
+ DataType dt2 = null;
+ boolean useOutputWrapper = useWrapper & wrapper != null;
+ if (useOutputWrapper) {
+ dt2 = wrapper.getOutputWrapperType();
+ useOutputWrapper &= outputTypeCompatible(dt2, op.getOutputType(), helpers);
+ }
+ if (useOutputWrapper) {
+ addDataType(dataTypes, dt2, helpers);
+ } else {
+ dt2 = op.getOutputType();
+ addDataType(dataTypes, dt2, helpers);
+ }
+
+ for (DataType<DataType> dt3 : op.getFaultTypes()) {
+ DataType dt4 = dt3.getLogical();
+ addDataType(dataTypes, dt4, helpers);
+ }
+ }
+ // Adding classes referenced by @XmlSeeAlso in the java interface
+ if (intf instanceof JavaInterface) {
+ JavaInterface javaInterface = (JavaInterface)intf;
+ Class<?>[] seeAlso = getSeeAlso(javaInterface.getJavaClass());
+ if (seeAlso != null) {
+ for (Class<?> cls : seeAlso) {
+ DataType dt = new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls, XMLType.UNKNOWN);
+ addDataType(dataTypes, dt, helpers);
+ }
+ }
+ seeAlso = getSeeAlso(javaInterface.getCallbackClass());
+ if (seeAlso != null) {
+ for (Class<?> cls : seeAlso) {
+ DataType dt = new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls, XMLType.UNKNOWN);
+ addDataType(dataTypes, dt, helpers);
+ }
+ }
+ }
+ return dataTypes;
+ }
+
+ private static Class<?>[] getSeeAlso(Class<?> interfaze) {
+ if (interfaze == null) {
+ return null;
+ }
+ XmlSeeAlso seeAlso = interfaze.getAnnotation(XmlSeeAlso.class);
+ if (seeAlso == null) {
+ return null;
+ } else {
+ return seeAlso.value();
+ }
+ }
+
+
+ public Definition generate(Interface interfaze, WSDLDefinition wsdlDefinition) throws WSDLException {
+ if (interfaze == null) {
+ return null;
+ }
+ if (interfaze instanceof WSDLInterface) {
+ return ((WSDLInterface)interfaze).getWsdlDefinition().getDefinition();
+ }
+ JavaInterface iface = (JavaInterface)interfaze;
+ if (!interfaze.isRemotable()) {
+ fatal("InterfaceNotRemotable", interfaze, iface.getName());
+ }
+ QName name = getQName(iface);
+ Definition definition = factory.newDefinition();
+ if (requiresSOAP12) {
+ definition.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ } else {
+ definition.addNamespace("SOAP", "http://schemas.xmlsoap.org/wsdl/soap/");
+ }
+ definition.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
+ definition.addNamespace("xs", SCHEMA_NS);
+
+ String namespaceURI = name.getNamespaceURI();
+ definition.setTargetNamespace(namespaceURI);
+ definition.setQName(new QName(namespaceURI, name.getLocalPart() + "Service", name.getPrefix()));
+ definition.addNamespace(name.getPrefix(), namespaceURI);
+
+ PortType portType = definition.createPortType();
+ portType.setQName(name);
+ Binding binding = definitionGenerator.createBinding(definition, portType);
+ Map<String, XMLTypeHelper> helpers = new HashMap<String, XMLTypeHelper>();
+ Map<QName, List<ElementInfo>> wrappers = new HashMap<QName, List<ElementInfo>>();
+ for (Operation op : interfaze.getOperations()) {
+ javax.wsdl.Operation operation = generateOperation(definition, op, helpers, wrappers);
+ portType.addOperation(operation);
+ String action = ((JavaOperation)op).getAction();
+ if ((action == null || "".equals(action)) && !op.isWrapperStyle() && op.getWrapper() == null) {
+ // Bare style
+ action = "urn:" + op.getName();
+ }
+ BindingOperation bindingOp = definitionGenerator.createBindingOperation(definition, operation, action);
+ binding.addBindingOperation(bindingOp);
+ }
+ portType.setUndefined(false);
+ definition.addPortType(portType);
+ binding.setUndefined(false);
+ definition.addBinding(binding);
+ wsdlDefinition.setBinding(binding);
+
+ // call each helper in turn to populate the wsdl.types element
+ XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
+
+ for (Map.Entry<XMLTypeHelper, List<DataType>> en: getDataTypes(interfaze, false, helpers).entrySet()) {
+ XMLTypeHelper helper = en.getKey();
+ if (helper == null) {
+ continue;
+ }
+ List<XSDefinition> xsDefinitions = helper.getSchemaDefinitions(xsdFactory, resolver, en.getValue());
+ for (XSDefinition xsDef: xsDefinitions) {
+ addSchemaExtension(xsDef, schemaCollection, wsdlDefinition, definition);
+ }
+ }
+
+ // remove global wrapper elements with schema definitions from generation list
+ for (QName wrapperName: new HashSet<QName>(wrappers.keySet())) {
+ if (wsdlDefinition.getXmlSchemaElement(wrapperName) != null) {
+ wrappers.remove(wrapperName);
+ }
+ }
+
+ // generate schema elements for wrappers that aren't defined in the schemas
+ if (wrappers.size() > 0) {
+ int i = 0;
+ int index = 0;
+ Map<String, XSDefinition> wrapperXSDs = new HashMap<String, XSDefinition>();
+ Map<Element, Map<String, String>> prefixMaps = new HashMap<Element, Map<String, String>>();
+ for (Map.Entry<QName, List<ElementInfo>> entry: wrappers.entrySet()) {
+ String targetNS = entry.getKey().getNamespaceURI();
+ Document schemaDoc = null;
+ Element schema = null;
+ XSDefinition xsDef = wrapperXSDs.get(targetNS);
+ if (xsDef != null) {
+ schemaDoc = xsDef.getDocument();
+ schema = schemaDoc.getDocumentElement();
+ } else {
+ schemaDoc = createDocument();
+ schema = schemaDoc.createElementNS(SCHEMA_NS, "xs:schema");
+ // The elementFormDefault should be set to unqualified, see TUSCANY-2388
+ schema.setAttribute("elementFormDefault", "unqualified");
+ schema.setAttribute("attributeFormDefault", "qualified");
+ schema.setAttribute("targetNamespace", targetNS);
+ schema.setAttributeNS(XMLNS_NS, "xmlns:xs", SCHEMA_NS);
+ schemaDoc.appendChild(schema);
+ Schema schemaExt = createSchemaExt(definition);
+ schemaExt.setElement(schema);
+ prefixMaps.put(schema, new HashMap<String, String>());
+ xsDef = xsdFactory.createXSDefinition();
+ xsDef.setUnresolved(true);
+ xsDef.setNamespace(targetNS);
+ xsDef.setDocument(schemaDoc);
+ // TUSCANY-2465: Set the system id to avoid schema conflict
+ xsDef.setLocation(URI.create("xsd_" + index + ".xsd"));
+ index++;
+ wrapperXSDs.put(targetNS, xsDef);
+ }
+ Element wrapper = schemaDoc.createElementNS(SCHEMA_NS, "xs:element");
+ schema.appendChild(wrapper);
+ wrapper.setAttribute("name", entry.getKey().getLocalPart());
+ if (entry.getValue().size() == 1 && entry.getValue().get(0).getQName() == null) {
+ // special case for global fault element
+ QName typeName = entry.getValue().get(0).getType().getQName();
+ String nsURI = typeName.getNamespaceURI();
+ if ("".equals(nsURI)) {
+ wrapper.setAttribute("type", typeName.getLocalPart());
+ addSchemaImport(schema, "", schemaDoc);
+ } else if (targetNS.equals(nsURI)) {
+ wrapper.setAttribute("type", typeName.getLocalPart());
+ } else if (SCHEMA_NS.equals(nsURI)) {
+ wrapper.setAttribute("type", "xs:" + typeName.getLocalPart());
+ } else {
+ Map<String, String> prefixMap = prefixMaps.get(schema);
+ String prefix = prefixMap.get(nsURI);
+ if (prefix == null) {
+ prefix = "ns" + i++;
+ prefixMap.put(nsURI, prefix);
+ schema.setAttributeNS(XMLNS_NS, "xmlns:" + prefix, nsURI);
+ addSchemaImport(schema, nsURI, schemaDoc);
+ }
+ wrapper.setAttribute("type", prefix + ":" + typeName.getLocalPart());
+ }
+ } else {
+ // normal wrapper containing type definition inline
+ Element complexType = schemaDoc.createElementNS(SCHEMA_NS, "xs:complexType");
+ wrapper.appendChild(complexType);
+ if (entry.getValue().size() > 0) {
+ Element sequence = schemaDoc.createElementNS(SCHEMA_NS, "xs:sequence");
+ complexType.appendChild(sequence);
+ for (ElementInfo element: entry.getValue()) {
+ Element xsElement = schemaDoc.createElementNS(SCHEMA_NS, "xs:element");
+ if (element.isMany()) {
+ xsElement.setAttribute("maxOccurs", "unbounded");
+ }
+ xsElement.setAttribute("minOccurs", "0");
+ xsElement.setAttribute("name", element.getQName().getLocalPart());
+ if (element.isNillable()) {
+ xsElement.setAttribute("nillable", "true");
+ }
+ QName typeName = element.getType().getQName();
+ String nsURI = typeName.getNamespaceURI();
+ if ("".equals(nsURI)) {
+ xsElement.setAttribute("type", typeName.getLocalPart());
+ addSchemaImport(schema, "", schemaDoc);
+ } else if (SCHEMA_NS.equals(nsURI)) {
+ xsElement.setAttribute("type", "xs:" + typeName.getLocalPart());
+ } else {
+ Map<String, String> prefixMap = prefixMaps.get(schema);
+ String prefix = prefixMap.get(nsURI);
+ if (prefix == null) {
+ if (targetNS.equals(nsURI)) {
+ prefix = "tns";
+ } else {
+ prefix = "ns" + i++;
+ addSchemaImport(schema, nsURI, schemaDoc);
+ }
+ prefixMap.put(nsURI, prefix);
+ schema.setAttributeNS(XMLNS_NS, "xmlns:" + prefix, nsURI);
+ }
+ xsElement.setAttribute("type", prefix + ":" + typeName.getLocalPart());
+ }
+ sequence.appendChild(xsElement);
+ }
+ }
+ }
+ }
+
+ // resolve XSDefinitions containing generated wrappers
+ for (XSDefinition xsDef: wrapperXSDs.values()) {
+ loadXSD(schemaCollection, xsDef);
+ wsdlDefinition.getXmlSchemas().add(xsDef);
+ }
+ }
+
+ return definition;
+ }
+
+ private static void addSchemaImport(Element schema, String nsURI, Document schemaDoc) {
+ Element imp = schemaDoc.createElementNS(SCHEMA_NS, "xs:import");
+ if (!"".equals(nsURI)) {
+ imp.setAttribute("namespace", nsURI);
+ }
+ // Scan all xs:import elements to match namespace
+ NodeList childNodes = schema.getElementsByTagNameNS(SCHEMA_NS, "import");
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node childNode = childNodes.item(i);
+ if (childNode instanceof Element) {
+ String ns = ((Element)childNode).getAttributeNS(SCHEMA_NS, "namespace");
+ if (nsURI.equals(ns)) {
+ // The xs:import with the same namespace has been declared
+ return;
+ }
+ }
+ }
+ // Try to find the first node after the import elements
+ Node firstNodeAfterImport = null;
+ if (childNodes.getLength() > 0) {
+ firstNodeAfterImport = childNodes.item(childNodes.getLength() - 1).getNextSibling();
+ } else {
+ firstNodeAfterImport = schema.getFirstChild();
+ }
+
+ if (firstNodeAfterImport == null) {
+ schema.appendChild(imp);
+ } else {
+ schema.insertBefore(imp, firstNodeAfterImport);
+ }
+ }
+
+ private void addSchemaExtension(XSDefinition xsDef,
+ XmlSchemaCollection schemaCollection,
+ WSDLDefinition wsdlDefinition,
+ Definition definition) throws WSDLException {
+ if (xsDef.getAggregatedDefinitions() != null) {
+ for (XSDefinition xsd: xsDef.getAggregatedDefinitions()) {
+ addSchemaExtension(xsd, schemaCollection, wsdlDefinition, definition);
+ }
+ } else {
+ String nsURI = xsDef.getNamespace();
+ Document document = xsDef.getDocument();
+ if (document == null) {
+ try {
+ NamespaceMap prefixMap = new NamespaceMap();
+ prefixMap.add("xs", SCHEMA_NS);
+ prefixMap.add("tns", nsURI);
+ XmlSchema schemaDef = xsDef.getSchema();
+ schemaDef.setNamespaceContext(prefixMap);
+ Document[] docs = schemaDef.getAllSchemas();
+ document = docs[docs.length-1];
+ document.setDocumentURI(xsDef.getLocation().toString());
+ xsDef.setDocument(document);
+ } catch (XmlSchemaException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ loadXSD(schemaCollection, xsDef);
+ wsdlDefinition.getXmlSchemas().add(xsDef);
+ Element schema = document.getDocumentElement();
+ Schema schemaExt = createSchemaExt(definition);
+ schemaExt.setDocumentBaseURI(document.getDocumentURI());
+ schemaExt.setElement(schema);
+ }
+ }
+
+ private static void loadXSD(XmlSchemaCollection schemaCollection, XSDefinition definition) {
+ if (definition.getSchema() != null) {
+ return;
+ }
+ if (definition.getDocument() != null) {
+ String uri = null;
+ if (definition.getLocation() != null) {
+ uri = definition.getLocation().toString();
+ }
+ XmlSchema schema = schemaCollection.read(definition.getDocument(), uri, null);
+ if (definition.getSchemaCollection() == null) {
+ definition.setSchemaCollection(schemaCollection);
+ }
+ if (definition.getSchema() == null) {
+ definition.setSchema(schema);
+ }
+ }
+ }
+
+ public Schema createSchemaExt(Definition definition) throws WSDLException {
+ Types types = definition.getTypes();
+ if (types == null) {
+ types = definition.createTypes();
+ definition.setTypes(types);
+ }
+
+ Schema schemaExt = createSchema(definition);
+ types.addExtensibilityElement(schemaExt);
+
+ return schemaExt;
+ }
+
+ public Schema createSchema(Definition definition) throws WSDLException {
+ return (Schema)definition.getExtensionRegistry().createExtension(Types.class, SCHEMA_QNAME);
+ }
+
+ public Document createDocument() {
+ Document document;
+ try {
+ if (documentBuilderFactory == null) {
+ documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ }
+ document = documentBuilderFactory.newDocumentBuilder().newDocument();
+ } catch (ParserConfigurationException ex) {
+ throw new WSDLGenerationException(ex);
+ }
+ // document.setDocumentURI("http://");
+ return document;
+ }
+
+ protected QName getQName(Interface interfaze) {
+ JavaInterface iface = (JavaInterface)interfaze;
+ QName qname = iface.getQName();
+ if (qname != null) {
+ return qname;
+ } else {
+ Class<?> javaClass = iface.getJavaClass();
+ return new QName(JavaXMLMapper.getNamespace(javaClass), javaClass.getSimpleName(), "tns");
+ }
+ }
+
+ public javax.wsdl.Operation generateOperation(Definition definition,
+ Operation op,
+ Map<String, XMLTypeHelper> helpers,
+ Map<QName, List<ElementInfo>> wrappers)
+ throws WSDLException {
+ javax.wsdl.Operation operation = definition.createOperation();
+ operation.setName(op.getName());
+ operation.setUndefined(false);
+
+ Input input = definition.createInput();
+ Message inputMsg = definition.createMessage();
+ String namespaceURI = definition.getQName().getNamespaceURI();
+ QName inputMsgName = new QName(namespaceURI, op.getName());
+ inputMsg.setQName(inputMsgName);
+ inputMsg.setUndefined(false);
+ definition.addMessage(inputMsg);
+
+ List<ElementInfo> elements = null;
+ // FIXME: By default, java interface is mapped to doc-lit-wrapper style WSDL
+ if (op.getWrapper() != null) {
+ // Generate doc-lit-wrapper style
+ inputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, true));
+ } else {
+ // Bare style
+ int i = 0;
+ for (DataType d : op.getInputType().getLogical()) {
+ inputMsg.addPart(generatePart(definition, d, "arg" + i));
+ elements = new ArrayList<ElementInfo>();
+ ElementInfo element = getElementInfo(d.getPhysical(), d, null, helpers);
+ elements.add(element);
+ QName elementName = ((XMLType)d.getLogical()).getElementName();
+ wrappers.put(elementName, elements);
+ i++;
+ }
+ }
+ input.setMessage(inputMsg);
+ operation.setInput(input);
+
+ if (!op.isNonBlocking()) {
+ Output output = definition.createOutput();
+ Message outputMsg = definition.createMessage();
+ QName outputMsgName = new QName(namespaceURI, op.getName() + "Response");
+ outputMsg.setQName(outputMsgName);
+ outputMsg.setUndefined(false);
+ definition.addMessage(outputMsg);
+
+ if (op.getWrapper() != null) {
+ outputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, false));
+ } else {
+ DataType outputType = op.getOutputType();
+ if (outputType != null) {
+ outputMsg.addPart(generatePart(definition, outputType, "return"));
+ elements = new ArrayList<ElementInfo>();
+ ElementInfo element = getElementInfo(outputType.getPhysical(), outputType, null, helpers);
+ elements.add(element);
+ QName elementName = ((XMLType)outputType.getLogical()).getElementName();
+ wrappers.put(elementName, elements);
+ }
+ }
+ output.setMessage(outputMsg);
+
+ operation.setOutput(output);
+ operation.setStyle(OperationType.REQUEST_RESPONSE);
+ } else {
+ operation.setStyle(OperationType.ONE_WAY);
+ }
+
+ for (DataType<DataType> faultType: op.getFaultTypes()) {
+ Fault fault = definition.createFault();
+ QName faultName = ((XMLType)faultType.getLogical().getLogical()).getElementName();
+ fault.setName(faultName.getLocalPart());
+ Message faultMsg = definition.getMessage(faultName);
+ if (faultMsg == null) {
+ faultMsg = definition.createMessage();
+ faultMsg.setQName(faultName);
+ faultMsg.setUndefined(false);
+ definition.addMessage(faultMsg);
+ faultMsg.addPart(generatePart(definition, faultType.getLogical(), faultName.getLocalPart()));
+ }
+ fault.setMessage(faultMsg);
+ operation.addFault(fault);
+ if (faultType.getLogical().getPhysical() != faultType.getPhysical()) {
+ // create special wrapper for type indirection to real fault bean
+ DataType logical = faultType.getLogical();
+ elements = new ArrayList<ElementInfo>();
+ elements.add(getElementInfo(logical.getPhysical(), logical, null, helpers));
+ } else {
+ // convert synthesized fault bean to a wrapper type
+ for (DataType<XMLType> propDT: op.getFaultBeans().get(faultName)) {
+ XMLType logical = propDT.getLogical();
+ elements = new ArrayList<ElementInfo>();
+ elements.add(getElementInfo(propDT.getPhysical(), propDT, logical.getElementName(), helpers));
+ }
+ }
+ wrappers.put(faultName, elements);
+ }
+
+ operation.setUndefined(false);
+ return operation;
+ }
+
+ public Part generatePart(Definition definition, DataType arg, String partName) {
+ Part part = definition.createPart();
+ part.setName(partName);
+ if (arg != null && arg.getLogical() instanceof XMLType) {
+ XMLType xmlType = (XMLType)arg.getLogical();
+ QName elementName = xmlType.getElementName();
+ part.setElementName(elementName);
+ addNamespace(definition, elementName);
+ if (xmlType.getElementName() == null) {
+ QName typeName = xmlType.getTypeName();
+ part.setTypeName(typeName);
+ addNamespace(definition, typeName);
+ }
+ }
+ return part;
+ }
+
+ public Part generateWrapperPart(Definition definition,
+ Operation operation,
+ Map<String, XMLTypeHelper> helpers,
+ Map<QName, List<ElementInfo>> wrappers,
+ boolean input) throws WSDLException {
+ Part part = definition.createPart();
+ String partName = input ? operation.getName() : (operation.getName() + "Response");
+ part.setName(partName);
+ WrapperInfo opWrapper = operation.getWrapper();
+ if (opWrapper != null) {
+ ElementInfo elementInfo =
+ input ? opWrapper.getInputWrapperElement() : opWrapper.getOutputWrapperElement();
+ List<ElementInfo> elements =
+ input ? opWrapper.getInputChildElements() : opWrapper.getOutputChildElements();
+ QName wrapperName = elementInfo.getQName();
+ part.setElementName(wrapperName);
+ addNamespace(definition, wrapperName);
+ wrappers.put(wrapperName, elements);
+
+ // FIXME: [rfeng] Ideally, we should try to register the wrappers only. But we are
+ // expriencing the problem that we cannot handle XSD imports
+ /*
+ Class<?> wrapperClass = input ? opWrapper.getInputWrapperClass() : opWrapper.getOutputWrapperClass();
+ DataType wrapperDT = input ? opWrapper.getInputWrapperType() : opWrapper.getOutputWrapperType();
+ if (wrapperClass != null) {
+ getElementInfo(wrapperClass, wrapperDT, wrapperName, helpers);
+ return part;
+ }
+ */
+
+ Method method = ((JavaOperation)operation).getJavaMethod();
+ if (input) {
+ Class<?>[] paramTypes = method.getParameterTypes();
+ for (int i = 0; i < paramTypes.length; i++) {
+ DataType dataType = operation.getInputType().getLogical().get(i);
+ elements.set(i, getElementInfo(paramTypes[i], dataType, elements.get(i).getQName(), helpers));
+ }
+ } else {
+ Class<?> returnType = method.getReturnType();
+ if (returnType != Void.TYPE) {
+ DataType dataType = operation.getOutputType();
+ elements.set(0, getElementInfo(returnType, dataType, elements.get(0).getQName(), helpers));
+ }
+ }
+ }
+ return part;
+ }
+
+ private ElementInfo getElementInfo(Class javaType,
+ DataType dataType,
+ QName name,
+ Map<String, XMLTypeHelper> helpers) {
+ String db = dataType.getDataBinding();
+ while ("java:array".equals(db)) {
+ dataType = (DataType)dataType.getLogical();
+ db = dataType.getDataBinding();
+ }
+ XMLTypeHelper helper = helpers.get(db);
+ if (helper == null) {
+ DataBinding dataBinding = dataBindings.getDataBinding(db);
+ if (dataBinding == null) {
+ QName element = name;
+ if (element == null || dataType.getLogical() instanceof XMLType) {
+ XMLType xmlType = (XMLType)dataType.getLogical();
+ if (xmlType.getElementName() != null) {
+ element = xmlType.getElementName();
+ }
+ }
+ return new ElementInfo(element, new TypeInfo(ANYTYPE_QNAME, false, null));
+ // throw new ServiceRuntimeException("No data binding for " + db);
+ }
+
+ helper = dataBinding.getXMLTypeHelper();
+ if (helper == null) {
+ // Default to JAXB
+ helper = helpers.get(JAXBDataBinding.NAME);
+ if (helper == null) {
+ helper = dataBindings.getDataBinding(JAXBDataBinding.NAME).getXMLTypeHelper();
+ helpers.put(JAXBDataBinding.NAME, helper);
+ }
+ }
+ helpers.put(db, helper);
+ }
+ // TUSCANY-3616 - don't revert a byte[] to a byte type but retain the mapping to base64Binary
+ // which is carried in the dataType and the original javaType
+ TypeInfo typeInfo = null;
+ ElementInfo element = null;
+ if (byte[].class == javaType){
+ typeInfo = helper.getTypeInfo(javaType, dataType.getLogical());
+ element = new ElementInfo(name, typeInfo);
+ element.setMany(false);
+ } else {
+ typeInfo = helper.getTypeInfo(javaType.isArray() ? javaType.getComponentType() : javaType, dataType.getLogical());
+ element = new ElementInfo(name, typeInfo);
+ element.setMany(javaType.isArray());
+ }
+
+ element.setNillable(!javaType.isPrimitive());
+ return element;
+ }
+
+ private static void addNamespace(Definition definition, QName name) {
+ String namespace = name.getNamespaceURI();
+ if (definition.getPrefix(namespace) == null) {
+ definition.addNamespace("ns" + definition.getNamespaces().size(), namespace);
+ }
+ }
+
+ /*
+ // currently not using the next three methods
+ public XmlSchemaType getXmlSchemaType(DataType type) {
+ return null;
+ }
+
+ // FIXME: WE need to add databinding-specific Java2XSD generation
+ public Element generateXSD(DataType dataType) {
+ DataBinding dataBinding = dataBindings.getDataBinding(dataType.getDataBinding());
+ if (dataBinding != null) {
+ // return dataBinding.generateSchema(dataType);
+ }
+ return null;
+ }
+
+ public void generateWrapperElements(Operation op) {
+ XmlSchemaCollection collection = new XmlSchemaCollection();
+ String ns = getQName(op.getInterface()).getNamespaceURI();
+ XmlSchema schema = new XmlSchema(ns, collection);
+ schema.setAttributeFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
+ schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
+
+ XmlSchemaElement inputElement = new XmlSchemaElement();
+ inputElement.setQName(new QName(ns, op.getName()));
+ XmlSchemaComplexType inputType = new XmlSchemaComplexType(schema);
+ inputType.setName("");
+ XmlSchemaSequence inputSeq = new XmlSchemaSequence();
+ inputType.setParticle(inputSeq);
+ List<DataType> argTypes = op.getInputType().getLogical();
+ for (DataType argType : argTypes) {
+ XmlSchemaElement child = new XmlSchemaElement();
+ Object logical = argType.getLogical();
+ if (logical instanceof XMLType) {
+ child.setName(((XMLType)logical).getElementName().getLocalPart());
+ XmlSchemaType type = getXmlSchemaType(argType);
+ child.setType(type);
+ }
+ inputSeq.getItems().add(child);
+ }
+ inputElement.setType(inputType);
+
+ XmlSchemaElement outputElement = new XmlSchemaElement();
+ outputElement.setQName(new QName(ns, op.getName() + "Response"));
+ XmlSchemaComplexType outputType = new XmlSchemaComplexType(schema);
+ outputType.setName("");
+ XmlSchemaSequence outputSeq = new XmlSchemaSequence();
+ outputType.setParticle(outputSeq);
+ DataType returnType = op.getOutputType();
+ XmlSchemaElement child = new XmlSchemaElement();
+ Object logical = returnType.getLogical();
+ if (logical instanceof XMLType) {
+ child.setName(((XMLType)logical).getElementName().getLocalPart());
+ XmlSchemaType type = getXmlSchemaType(returnType);
+ child.setType(type);
+ }
+ outputSeq.getItems().add(child);
+ outputElement.setType(outputType);
+
+ schema.getElements().add(inputElement.getQName(), inputElement);
+ schema.getElements().add(outputElement.getQName(), outputElement);
+
+ }
+ */
+
+ public WSDLFactory getFactory() {
+ return factory;
+ }
+
+ public void setFactory(WSDLFactory factory) {
+ this.factory = factory;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLContractBuilder.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLContractBuilder.java
new file mode 100644
index 0000000000..25a566bd24
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLContractBuilder.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.binding.ws.wsdlgen;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ResolverExtension;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+
+/**
+ * Created WSDL contracts for Endpoints or EndpointReferences for use during
+ * interface contract mapping. The assmebly spec defines WSDL as the lowest
+ * common denominator for contract mapping.
+ */
+public class WSDLContractBuilder implements ContractBuilder {
+
+ private ExtensionPointRegistry extensionPoints;
+ private FactoryExtensionPoint modelFactories;
+ private DataBindingExtensionPoint dataBindings;
+ private WSDLFactory wsdlFactory;
+ private XSDFactory xsdFactory;
+ private DocumentBuilderFactory documentBuilderFactory;
+
+ public WSDLContractBuilder(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+
+ modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
+ wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+
+ }
+
+ public boolean build(InterfaceContract interfaceContract, BuilderContext context){
+// Uncomment the printWSDL = lines to see the WSDL that is generated
+// for interface matching purposes
+// BindingWSDLGenerator.printWSDL = true;
+ JavaInterfaceContract javaContract = (JavaInterfaceContract)interfaceContract;
+ WSDLInterfaceContract wsdlContract =
+ BindingWSDLGenerator.createWSDLInterfaceContract(javaContract,
+ false,
+ null,
+ dataBindings,
+ wsdlFactory,
+ xsdFactory,
+ documentBuilderFactory,
+ null);
+ javaContract.setNormailizedWSDLContract(wsdlContract);
+// BindingWSDLGenerator.printWSDL = false;
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java
new file mode 100644
index 0000000000..56fd02a611
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java
@@ -0,0 +1,305 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.wsdlgen;
+
+import java.util.Iterator;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingFault;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.wsdl.extensions.soap.SOAPFault;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
+import javax.wsdl.extensions.soap12.SOAP12Body;
+import javax.wsdl.extensions.soap12.SOAP12Fault;
+import javax.wsdl.extensions.soap12.SOAP12Operation;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLDefinitionGenerator {
+ private static final String SOAP_NS = "http://schemas.xmlsoap.org/wsdl/soap/";
+ public static final QName SOAP_ADDRESS = new QName(SOAP_NS, "address");
+ private static final QName SOAP_BINDING = new QName(SOAP_NS, "binding");
+ private static final QName SOAP_BODY = new QName(SOAP_NS, "body");
+ private static final QName SOAP_FAULT = new QName(SOAP_NS, "fault");
+ private static final QName SOAP_OPERATION = new QName(SOAP_NS, "operation");
+ private static final String SOAP12_NS = "http://schemas.xmlsoap.org/wsdl/soap12/";
+ public static final QName SOAP12_ADDRESS = new QName(SOAP12_NS, "address");
+ private static final QName SOAP12_BINDING = new QName(SOAP12_NS, "binding");
+ private static final QName SOAP12_BODY = new QName(SOAP12_NS, "body");
+ private static final QName SOAP12_FAULT = new QName(SOAP12_NS, "fault");
+ private static final QName SOAP12_OPERATION = new QName(SOAP12_NS, "operation");
+
+ private static final String BINDING_SUFFIX = "Binding";
+ private static final String SERVICE_SUFFIX = "Service";
+ private static final String PORT_SUFFIX = "Port";
+
+ private boolean requiresSOAP12;
+ private QName soapAddress;
+ private QName soapBinding;
+ private QName soapBody;
+ private QName soapFault;
+ private QName soapOperation;
+
+ public WSDLDefinitionGenerator(boolean requiresSOAP12) {
+ super();
+ this.requiresSOAP12 = requiresSOAP12;
+ soapAddress = requiresSOAP12 ? SOAP12_ADDRESS : SOAP_ADDRESS;
+ soapBinding = requiresSOAP12 ? SOAP12_BINDING : SOAP_BINDING;
+ soapBody = requiresSOAP12 ? SOAP12_BODY : SOAP_BODY;
+ soapFault = requiresSOAP12 ? SOAP12_FAULT : SOAP_FAULT;
+ soapOperation = requiresSOAP12 ? SOAP12_OPERATION : SOAP_OPERATION;
+ }
+
+ public Definition cloneDefinition(WSDLFactory factory, Definition definition) throws WSDLException {
+ Element root = definition.getDocumentationElement();
+ root = (Element)root.cloneNode(true);
+ WSDLReader reader = factory.newWSDLReader();
+ return reader.readWSDL(definition.getDocumentBaseURI(), root);
+ }
+
+ public Types createTypes(Definition definition) {
+ Types types = definition.createTypes();
+ definition.setTypes(types);
+ return types;
+ }
+
+ public Binding createBinding(Definition definition, PortType portType) {
+ try {
+ Binding binding = definition.createBinding();
+ binding.setPortType(portType);
+ configureBinding(definition, binding, portType);
+ ExtensibilityElement bindingExtension =
+ definition.getExtensionRegistry().createExtension(Binding.class, soapBinding);
+ if (requiresSOAP12) {
+ ((SOAP12Binding)bindingExtension).setStyle("document");
+ ((SOAP12Binding)bindingExtension).setTransportURI("http://schemas.xmlsoap.org/soap/http");
+ } else {
+ ((SOAPBinding)bindingExtension).setStyle("document");
+ ((SOAPBinding)bindingExtension).setTransportURI("http://schemas.xmlsoap.org/soap/http");
+ }
+ binding.addExtensibilityElement(bindingExtension);
+ return binding;
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+ }
+
+ protected void configureBinding(Definition definition, Binding binding, PortType portType) throws WSDLException {
+ QName portTypeName = portType.getQName();
+ if (portTypeName != null) {
+ // Choose <porttype>Binding if available. If this name is in use, insert
+ // separating underscores until there is no clash.
+ for (String suffix = BINDING_SUFFIX; ; suffix = "_" + suffix) {
+ QName name = new QName(definition.getTargetNamespace(), portTypeName.getLocalPart() + suffix);
+ if (definition.getBinding(name) == null) {
+ binding.setQName(name);
+ break;
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void createBindingOperations(Definition definition, Binding binding, PortType portType) {
+ try {
+ for (Iterator oi = portType.getOperations().iterator(); oi.hasNext();) {
+ Operation operation = (Operation)oi.next();
+ BindingOperation bindingOperation =
+ createBindingOperation(definition, operation, "urn:" + operation.getName());
+ binding.addBindingOperation(bindingOperation);
+ }
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public BindingOperation createBindingOperation(Definition definition, Operation operation, String action)
+ throws WSDLException {
+ BindingOperation bindingOperation = definition.createBindingOperation();
+ bindingOperation.setOperation(operation);
+ configureBindingOperation(bindingOperation, operation);
+ ExtensibilityElement operationExtension =
+ definition.getExtensionRegistry().createExtension(BindingOperation.class, soapOperation);
+ if (requiresSOAP12) {
+ ((SOAP12Operation)operationExtension).setSoapActionURI(action);
+ } else {
+ ((SOAPOperation)operationExtension).setSoapActionURI(action);
+ }
+ bindingOperation.addExtensibilityElement(operationExtension);
+ if (operation.getInput() != null) {
+ BindingInput bindingInput = definition.createBindingInput();
+ configureBindingInput(bindingInput, operation.getInput());
+ ExtensibilityElement inputExtension =
+ definition.getExtensionRegistry().createExtension(BindingInput.class, soapBody);
+ if (requiresSOAP12) {
+ ((SOAP12Body)inputExtension).setUse("literal");
+ } else {
+ ((SOAPBody)inputExtension).setUse("literal");
+ }
+ bindingInput.addExtensibilityElement(inputExtension);
+ bindingOperation.setBindingInput(bindingInput);
+ }
+ if (operation.getOutput() != null) {
+ BindingOutput bindingOutput = definition.createBindingOutput();
+ configureBindingOutput(bindingOutput, operation.getOutput());
+ ExtensibilityElement outputExtension =
+ definition.getExtensionRegistry().createExtension(BindingOutput.class, soapBody);
+ if (requiresSOAP12) {
+ ((SOAP12Body)outputExtension).setUse("literal");
+ } else {
+ ((SOAPBody)outputExtension).setUse("literal");
+ }
+ bindingOutput.addExtensibilityElement(outputExtension);
+ bindingOperation.setBindingOutput(bindingOutput);
+ }
+ for (Iterator fi = operation.getFaults().values().iterator(); fi.hasNext();) {
+ Fault fault = (Fault)fi.next();
+ BindingFault bindingFault = definition.createBindingFault();
+ ExtensibilityElement faultExtension =
+ definition.getExtensionRegistry().createExtension(BindingFault.class, soapFault);
+ configureBindingFault(bindingFault, faultExtension, fault);
+ bindingFault.addExtensibilityElement(faultExtension);
+ bindingOperation.addBindingFault(bindingFault);
+ }
+ return bindingOperation;
+ }
+
+ protected void configureBindingOperation(BindingOperation bindingOperation, Operation operation)
+ throws WSDLException {
+ bindingOperation.setName(operation.getName());
+ }
+
+ protected void configureBindingInput(BindingInput bindingInput, Input input) throws WSDLException {
+ bindingInput.setName(input.getName());
+ }
+
+ protected void configureBindingOutput(BindingOutput bindingOutput, Output output) throws WSDLException {
+ bindingOutput.setName(output.getName());
+ }
+
+ protected void configureBindingFault(BindingFault bindingFault,
+ ExtensibilityElement faultExtension,
+ Fault fault)
+ throws WSDLException {
+ String faultName = fault.getName();
+ bindingFault.setName(faultName);
+ if (requiresSOAP12) {
+ ((SOAP12Fault)faultExtension).setName(faultName);
+ ((SOAP12Fault)faultExtension).setUse("literal");
+ } else {
+ ((SOAPFault)faultExtension).setName(faultName);
+ ((SOAPFault)faultExtension).setUse("literal");
+ }
+ }
+
+ public Service createService(Definition definition, PortType portType) {
+ try {
+ Service service = definition.createService();
+ configureService(definition, service, portType);
+ // createPort(definition, binding, service);
+ definition.addService(service);
+ return service;
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+ }
+
+ public Service createService(Definition definition, Binding binding) {
+ try {
+ Service service = definition.createService();
+ configureService(definition, service, binding.getPortType());
+ // createPort(definition, binding, service);
+ definition.addService(service);
+ return service;
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+ }
+
+ protected void configureService(Definition definition, Service service, PortType portType) throws WSDLException {
+ QName portTypeName = portType.getQName();
+ if (portTypeName != null) {
+ // Choose <porttype>Service if available. If this name is in use, insert
+ // separating underscores until there is no clash.
+ for (String suffix = SERVICE_SUFFIX; ; suffix = "_" + suffix) {
+ QName name = new QName(definition.getTargetNamespace(), portTypeName.getLocalPart() + suffix);
+ if (definition.getService(name) == null) {
+ service.setQName(name);
+ break;
+ }
+ }
+ }
+ }
+
+ public Port createPort(Definition definition, Binding binding, Service service, String uri) {
+ try {
+ Port port = definition.createPort();
+ port.setBinding(binding);
+ configurePort(port, binding);
+ if (uri != null) {
+ ExtensibilityElement portExtension =
+ definition.getExtensionRegistry().createExtension(Port.class, soapAddress);
+ if (requiresSOAP12) {
+ ((SOAP12Address)portExtension).setLocationURI(uri);
+ } else {
+ ((SOAPAddress)portExtension).setLocationURI(uri);
+ }
+ port.addExtensibilityElement(portExtension);
+ }
+ service.addPort(port);
+ return port;
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+ }
+
+ protected void configurePort(Port port, Binding binding) throws WSDLException {
+ if (binding.getPortType() != null && binding.getPortType().getQName() != null) {
+ port.setName(binding.getPortType().getQName().getLocalPart() + PORT_SUFFIX);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java
new file mode 100644
index 0000000000..1a9b26d618
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.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.sca.binding.ws.wsdlgen;
+
+import org.apache.tuscany.sca.monitor.Problem;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class WSDLGenerationException extends ServiceRuntimeException {
+ private static final long serialVersionUID = 1L;
+ private Problem problem;
+
+ public WSDLGenerationException() {
+ super();
+ }
+
+ public WSDLGenerationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public WSDLGenerationException(String message) {
+ super(message);
+ }
+
+ public WSDLGenerationException(Throwable cause) {
+ super(cause);
+ }
+
+ public WSDLGenerationException(String message, Throwable cause, Problem problem) {
+ super(message, cause);
+ this.problem = problem;
+ }
+
+ public Problem getProblem() {
+ return problem;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
new file mode 100644
index 0000000000..3bc784401a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
@@ -0,0 +1,527 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.wsdlgen;
+
+//FIXME: trim the import list down to what's really needed
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Message;
+import javax.wsdl.Part;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * WSDLServiceGenerator generates a binding WSDL service document.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLServiceGenerator {
+ // the following switch is temporary for debugging
+ public static boolean printWSDL; // external code sets this to print generated WSDL
+
+ private static final Logger logger = Logger.getLogger(WSDLServiceGenerator.class.getName());
+ private static final QName TRANSPORT_JMS_QUALIFIED_INTENT =
+ new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "transport.jms");
+ private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory";
+ private static final String ADDRESS = "Address";
+
+ private WSDLServiceGenerator() {
+ // this class has static methods only and cannot be instantiated
+ }
+
+ /**
+ * Log a warning message.
+ * @param problem
+ */
+ private static void logWarning(Problem problem) {
+ Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getResourceBundleName());
+ if (problemLogger != null){
+ problemLogger.logp(Level.WARNING, problem.getSourceClassName(), null, problem.getMessageId(), problem.getMessageParams());
+ } else {
+ logger.severe("Can't get logger " + problem.getSourceClassName()+ " with bundle " + problem.getResourceBundleName());
+ }
+ }
+
+ /**
+ * Report a warning.
+ * @param message
+ * @param binding
+ * @param parameters
+ */
+ private static void warning(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) {
+ Problem problem = monitor.createProblem(WSDLServiceGenerator.class.getName(), "wsdlgen-validation-messages", Severity.WARNING, wsBinding, message, (Object[])messageParameters);
+ if (monitor != null) {
+ monitor.problem(problem);
+ } else {
+ logWarning(problem);
+ }
+ }
+
+ /**
+ * Report an error.
+ * @param message
+ * @param binding
+ * @param parameters
+ */
+ private static void error(Monitor monitor, String message, WebServiceBinding wsBinding, String... messageParameters) {
+ Problem problem = monitor.createProblem(WSDLServiceGenerator.class.getName(), "wsdlgen-validation-messages", Severity.ERROR, wsBinding, message, (Object[])messageParameters);
+ if (monitor != null) {
+ monitor.problem(problem);
+ } else {
+ throw new WSDLGenerationException(problem.toString(), null, problem);
+ }
+ }
+
+ /**
+ * Generate a suitably configured WSDL definition
+ */
+ protected static Definition configureWSDLDefinition(WebServiceBinding wsBinding,
+ Component component,
+ AbstractContract contract,
+ Monitor monitor) {
+
+ //[nash] changes to the builder sequence avoid calling this for a CompositeService
+ assert !(contract instanceof CompositeService);
+
+ String contractName = contract.getName();
+
+ List<Port> ports = new ArrayList<Port>();
+ WSDLDefinition wsdlDefinition = wsBinding.getUserSpecifiedWSDLDefinition();
+ if (wsdlDefinition == null) {
+ error(monitor, "NoWsdlInterface", wsBinding, component.getName(), contract.getName());
+ return null;
+ }
+ Definition def = wsdlDefinition.getDefinition();
+ if (wsdlDefinition.getBinding() == null) {
+ // The WSDL document was provided by the user. Generate a new
+ // WSDL document with imports from the user-provided document.
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+ Definition newDef = factory.newDefinition();
+
+ // Construct a target namespace from the base URI of the user's
+ // WSDL document (is this what we should be using?) and a path
+ // computed according to the SCA Web Service binding spec.
+ String nsName = component.getName() + "/" + contractName;
+ String namespaceURI = null;
+ try {
+ URI userTNS = new URI(def.getTargetNamespace());
+ namespaceURI = userTNS.resolve("/" + nsName).toString();
+ } catch (URISyntaxException e1) {
+ throw new WSDLGenerationException(e1);
+ } catch (IllegalArgumentException e2) {
+ throw new WSDLGenerationException(e2);
+ }
+
+ // set name and targetNamespace attributes on the definition
+ String defsName = component.getName() + "." + contractName;
+ newDef.setQName(new QName(namespaceURI, defsName));
+ newDef.setTargetNamespace(namespaceURI);
+ newDef.addNamespace("tns", namespaceURI);
+
+ // set wsdl namespace prefix on the definition
+ newDef.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
+
+ // import the service or reference interface portType
+ List<WSDLDefinition> imports = new ArrayList<WSDLDefinition>();
+ Interface interfaze = wsBinding.getBindingInterfaceContract().getInterface();
+ if (interfaze instanceof WSDLInterface) {
+ PortType portType = ((WSDLInterface)interfaze).getPortType();
+ boolean ok = importPortType(portType, wsdlDefinition, newDef, imports);
+ if (!ok) {
+ error(monitor, "PortTypeNotFound", wsBinding, portType.getQName().toString(),
+ component.getName(), contract.getName());
+ }
+ }
+
+ // import an existing binding if specified
+ Binding binding = wsBinding.getBinding();
+ if (binding != null) {
+ boolean ok = importBinding(binding, wsdlDefinition, newDef, imports);
+ if (ok) {
+ boolean ok2 = importPortType(binding.getPortType(), wsdlDefinition, newDef, imports);
+ if (!ok2) {
+ error(monitor, "PortTypeNotFound", wsBinding, binding.getPortType().getQName().toString(),
+ component.getName(), contract.getName());
+ }
+ } else {
+ error(monitor, "BindingNotFound", wsBinding, binding.getQName().toString(),
+ component.getName(), contract.getName());
+ }
+ }
+
+ // import bindings and portTypes needed by services and ports
+ QName serviceQName = wsBinding.getServiceName();
+ String portName = wsBinding.getPortName();
+ if (serviceQName != null) {
+ Service service = def.getService(serviceQName);
+ if (portName != null) {
+ Port port = service.getPort(portName);
+ Port newPort = copyPort(newDef, port, wsBinding);
+ if (newPort != null) {
+ importBinding(port.getBinding(), wsdlDefinition, newDef, imports);
+ ports.add(newPort);
+ } else {
+ error(monitor, "InvalidPort", wsBinding, serviceQName.toString(), portName,
+ component.getName(), contract.getName());
+ }
+ } else {
+ for (Object port : service.getPorts().values()) {
+ Port newPort = copyPort(newDef, (Port)port, wsBinding);
+ if (newPort != null) {
+ importBinding(((Port)port).getBinding(), wsdlDefinition, newDef, imports);
+ ports.add(newPort);
+ } else {
+ // not an error, just ignore the port
+ warning(monitor, "IgnoringPort", wsBinding, serviceQName.toString(), ((Port)port).getName(),
+ component.getName(), contract.getName());
+ }
+ }
+ if (ports.size() == 0) {
+ error(monitor, "NoValidPorts", wsBinding, serviceQName.toString(),
+ component.getName(), contract.getName());
+ }
+ }
+ }
+
+ // replace original WSDL definition by the generated definition
+ def = newDef;
+
+ } else {
+ // The WSDL definition was generated by Interface2WSDLGenerator.
+ // Reuse it instead of creating a new definition here.
+ }
+
+ // add a service and ports to the generated definition
+ WSDLDefinitionGenerator helper =
+ new WSDLDefinitionGenerator(BindingWSDLGenerator.requiresSOAP12(wsBinding));
+ WSDLInterface wi = (WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface();
+ PortType portType = wi.getPortType();
+ Service service = helper.createService(def, portType);
+ if (wsBinding.getBinding() == null && ports.size() == 0) {
+ Binding binding = helper.createBinding(def, portType);
+ if (BindingWSDLGenerator.requiresSOAP12(wsBinding)) {
+ def.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ } else {
+ def.addNamespace("SOAP11", "http://schemas.xmlsoap.org/wsdl/soap/");
+ }
+ helper.createBindingOperations(def, binding, portType);
+ binding.setUndefined(false);
+
+ // set binding style based on the interface specified by the
+ // user if one is available
+ // TODO - set encoding style also currently default to literal
+ if (wsdlDefinition != null && wsdlDefinition.getDefinition() != null){
+ Message firstMessage = (Message)wsdlDefinition.getDefinition().getMessages().values().iterator().next();
+ Part firstPart = (Part)firstMessage.getParts().values().iterator().next();
+ if (firstPart.getTypeName() != null){
+ for (Object ext : binding.getExtensibilityElements()){
+ if (ext instanceof SOAPBinding){
+ ((SOAPBinding)ext).setStyle("rpc");
+ break;
+ }
+ }
+ }
+ }
+
+ def.addBinding(binding);
+
+ String endpointURI = computeActualURI(wsBinding, null);
+ Port port = helper.createPort(def, binding, service, endpointURI);
+ wsBinding.setService(service);
+ wsBinding.setPort(port);
+ } else {
+ if (ports.size() > 0) {
+ // there are one or more user-specified valid ports
+ for (Port port : ports) {
+ service.addPort(port);
+ }
+ if (ports.size() == 1) {
+ // only one port, so use it
+ wsBinding.setPort(ports.get(0));
+ } else {
+ // multiple ports, make them all available
+ wsBinding.setPort(null);
+ }
+ } else {
+ // no valid user-specified ports, so create a suitably configured port
+ String endpointURI = computeActualURI(wsBinding, null);
+ Port port = helper.createPort(def, wsBinding.getBinding(), service, endpointURI);
+ if (BindingWSDLGenerator.requiresSOAP12(wsBinding)) {
+ def.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ } else {
+ def.addNamespace("SOAP11", "http://schemas.xmlsoap.org/wsdl/soap/");
+ }
+ wsBinding.setPort(port);
+ }
+ wsBinding.setService(service);
+ }
+
+ // for debugging
+ if (printWSDL) {
+ try {
+ System.out.println("Generated WSDL for " + component.getName() + "/" + contractName);
+ WSDLWriter writer = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(def, System.out);
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+ }
+
+ return def;
+ }
+
+ private static boolean importPortType(PortType portType,
+ WSDLDefinition wsdlDef,
+ Definition newDef,
+ List<WSDLDefinition> imports) {
+ return addImport(portType.getQName(), PortType.class, wsdlDef, newDef, imports);
+ }
+
+ private static boolean importBinding(Binding binding,
+ WSDLDefinition wsdlDef,
+ Definition newDef,
+ List<WSDLDefinition> imports) {
+ boolean ok = addImport(binding.getQName(), Binding.class, wsdlDef, newDef, imports);
+ if (ok) {
+ List bindingExtensions = binding.getExtensibilityElements();
+ for (final Object extension : bindingExtensions) {
+ if (extension instanceof SOAPBinding) {
+ newDef.addNamespace("SOAP11", "http://schemas.xmlsoap.org/wsdl/soap/");
+ }
+ if (extension instanceof SOAP12Binding) {
+ newDef.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ }
+ }
+ }
+ return ok;
+ }
+
+ private static boolean addImport(QName name,
+ Class type,
+ WSDLDefinition wsdlDef,
+ Definition newDef,
+ List<WSDLDefinition> imports) {
+ String namespace = name.getNamespaceURI();
+ if (newDef.getImports(namespace) == null) {
+ WSDLDefinition impDef = findDefinition(wsdlDef, name, type);
+ if (impDef != null) {
+ Import imp = newDef.createImport();
+ imp.setNamespaceURI(namespace);
+ imp.setLocationURI(impDef.getURI().toString());
+ imp.setDefinition(impDef.getDefinition());
+ newDef.addNamespace("ns" + imports.size(), namespace);
+ newDef.addImport(imp);
+ imports.add(impDef);
+ return true;
+ } else {
+ // import was not added because element not found
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static WSDLDefinition findDefinition(WSDLDefinition wsdlDef, QName name, Class type) {
+ if (wsdlDef == null || name == null) {
+ return wsdlDef;
+ }
+ if (wsdlDef.getURI() != null) { // not a facade
+ Definition def = wsdlDef.getDefinition();
+ Map types = type == PortType.class ? def.getPortTypes() : def.getBindings();
+ if (types.get(name) != null) {
+ return wsdlDef;
+ }
+ }
+ for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) {
+ WSDLDefinition d = findDefinition(impDef, name, type);
+ if (d != null) {
+ return d;
+ }
+ }
+ return null;
+ }
+
+ private static Port copyPort(Definition def, Port port, WebServiceBinding wsBinding) {
+ Port newPort = def.createPort();
+ newPort.setName(port.getName());
+ newPort.setBinding(port.getBinding());
+ List portExtensions = port.getExtensibilityElements();
+ for (final Object extension : portExtensions) {
+ ExtensibilityElement newExt = null;
+ if (extension instanceof SOAPAddress) {
+ def.addNamespace("SOAP11", "http://schemas.xmlsoap.org/wsdl/soap/");
+ try {
+ newExt = def.getExtensionRegistry().createExtension(
+ Port.class, WSDLDefinitionGenerator.SOAP_ADDRESS);
+ } catch (WSDLException e) {
+ }
+ String uri = computeActualURI(wsBinding, port);
+ ((SOAPAddress)newExt).setLocationURI(uri);
+ newPort.addExtensibilityElement(newExt);
+ } else if (extension instanceof SOAP12Address) {
+ def.addNamespace("SOAP12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ try {
+ newExt = def.getExtensionRegistry().createExtension(
+ Port.class, WSDLDefinitionGenerator.SOAP12_ADDRESS);
+ } catch (WSDLException e) {
+ }
+ String uri = computeActualURI(wsBinding, port);
+ ((SOAP12Address)newExt).setLocationURI(uri);
+ newPort.addExtensibilityElement(newExt);
+ } else {
+ // we don't support ports with other extensibility elements such as HTTPAddress
+ return null;
+ }
+ }
+ return newPort;
+ }
+
+ /**
+ * Compute the endpoint URI based on section 2.1.1 of the WS binding Specification
+ * 1. The URIs in the endpoint(s) of the referenced WSDL, which may be relative
+ * 2. The URI specified by the wsa:Address element of the
+ * wsa:EndpointReference, which may be relative
+ * 3. The explicitly stated URI in the "uri" attribute of the binding.ws element,
+ * which may be relative,
+ * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly Specification
+ * If the <binding.ws> has no wsdlElement but does have a uri attribute then
+ * the uri takes precedence over any implicitly used WSDL.
+ *
+ */
+ private static String computeActualURI(WebServiceBinding wsBinding, Port port) {
+
+ URI eprURI = null;
+ if (wsBinding.getEndPointReference() != null) {
+ eprURI = getEPR(wsBinding);
+ }
+
+ URI wsdlURI = null;
+ if (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null) {
+ // <binding.ws> explicitly points at a WSDL port, may be a relative URI
+ wsdlURI = getEndpoint(port);
+ }
+
+ // if the WSDL port/endpoint has an absolute URI use that
+ if (wsdlURI != null && wsdlURI.isAbsolute()) {
+ return wsdlURI.toString();
+ }
+
+ // if the wsa:EndpointReference has an address element with an absolute URI use that
+ if (eprURI != null && eprURI.isAbsolute()) {
+ return eprURI.toString();
+ }
+
+ // either there is no WSDL port endpoint URI or that URI is relative
+ String actualURI = wsBinding.getURI();
+ if (eprURI != null && eprURI.toString().length() != 0) {
+ // there is a relative URI in the binding EPR
+ actualURI = actualURI + "/" + eprURI;
+ }
+
+ if (wsdlURI != null && wsdlURI.toString().length() != 0) {
+ // there is a relative URI in the WSDL port
+ actualURI = actualURI + "/" + wsdlURI;
+ }
+
+ if (actualURI != null) {
+ actualURI = URI.create(actualURI).normalize().toString();
+ }
+
+ return actualURI;
+ }
+
+ private static URI getEPR(WebServiceBinding wsBinding) {
+ NodeList nodeList = wsBinding.getEndPointReference().getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node childNode = nodeList.item(i);
+ if (childNode instanceof Element && ADDRESS.equals(childNode.getLocalName())) {
+ NodeList addrNodes = childNode.getChildNodes();
+ for (int j = 0; j < addrNodes.getLength(); j++) {
+ Node addrNode = addrNodes.item(j);
+ if (addrNode instanceof Text) {
+ return URI.create(((Text)addrNode).getWholeText());
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the endpoint of a given port.
+ */
+ private static URI getEndpoint(Port wsdlPort) {
+ if (wsdlPort != null) {
+ List<?> wsdlPortExtensions = wsdlPort.getExtensibilityElements();
+ for (Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ String uri = ((SOAPAddress)extension).getLocationURI();
+ return (uri == null || "".equals(uri)) ? null : URI.create(uri);
+ }
+ if (extension instanceof SOAP12Address) {
+ SOAP12Address address = (SOAP12Address)extension;
+ String uri = address.getLocationURI();
+ return (uri == null || "".equals(uri)) ? null : URI.create(uri);
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
new file mode 100644
index 0000000000..0117ee5d79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.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.binding.ws.wsdlgen;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * A factory for the calculated WSDL document needed by Web Service bindings.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceBindingBuilder implements BindingBuilder<WebServiceBinding> {
+
+ private ExtensionPointRegistry extensionPoints;
+
+ public WebServiceBindingBuilder(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+
+ /**
+ * Create a calculated WSDL document and save it in the Web Service binding.
+ */
+ public void build(Component component, Contract contract, WebServiceBinding binding, BuilderContext context, boolean rebuild) {
+ // in some cases (callback service endpoint processing) we need to re-generate the
+ // WSDL doc from a ws binding that already has one.
+ if (rebuild == true){
+ binding.setGeneratedWSDLDocument(null);
+ }
+ BindingWSDLGenerator.generateWSDL(component, contract, binding, extensionPoints, context.getMonitor());
+ }
+
+ public QName getBindingType() {
+ return WebServiceBinding.TYPE;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder
new file mode 100644
index 0000000000..e39d9352b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder
@@ -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.binding.ws.wsdlgen.WebServiceBindingBuilder;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#binding.ws
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ContractBuilder b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ContractBuilder
new file mode 100644
index 0000000000..01333bf670
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ContractBuilder
@@ -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.binding.ws.wsdlgen.WSDLContractBuilder
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties
new file mode 100644
index 0000000000..42fffcc44f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties
@@ -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.
+#
+#
+WsdlGenProblem = Unable to generate WSDL for {0}/{1}
+WsdlGenException = Exception while generating WSDL for {0}/{1}
+WsdlGenException2 =[JCA90040] Exception while generating WSDL for {0}/{1} exception was: {2}
+UnexpectedException = Exception thrown was: {0}
+MissingInterfaceContract = No interface contract for {0}/{1}
+InterfaceNotRemotable = Interface not remotable: {0}
+IgnoringPort = Port {0}/{1} in {2}/{3} is not supported and was ignored
+PortTypeNotFound = PortType {0} in {1}/{2} was not found
+BindingNotFound = Binding {0} in {1}/{2} was not found
+InvalidPort = Port {0}/{1} in {2}/{3} is not supported
+NoValidPorts = No valid ports for service {0} in {1}/{2}
+NoWsdlInterface = No WSDL interface definition for {0}/{1}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java
new file mode 100644
index 0000000000..7e6a1de546
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.ws.other;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Other {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name ) {
+ this.name = name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java
new file mode 100644
index 0000000000..f10a2286e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://other.ws.binding.sca.tuscany.apache.org/")
+package org.apache.tuscany.sca.binding.ws.other;
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java
new file mode 100644
index 0000000000..f905c10bf7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.wsdlgen;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor;
+import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSFaultExceptionMapper;
+import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.xml.XSDModelResolver;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindingWSDLGeneratorTestCase extends TestCase {
+
+ public void testCreateWSDLInterfaceContract() throws InvalidInterfaceException {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ org.apache.tuscany.sca.core.FactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(registry);
+ WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+ JavaInterfaceFactory factory = new DefaultJavaInterfaceFactory(registry);
+ JavaInterfaceContract javaIC = factory.createJavaInterfaceContract();
+ JavaInterface iface = factory.createJavaInterface(HelloWorld.class);
+ DefaultDataBindingExtensionPoint dataBindings = new DefaultDataBindingExtensionPoint(registry);
+ JAXWSFaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings, null);
+ new JAXWSJavaInterfaceProcessor(registry).visitInterface(iface);
+ new DataBindingJavaInterfaceProcessor(registry).visitInterface(iface);
+ javaIC.setInterface(iface);
+ WSDLInterfaceContract wsdlIC = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, documentBuilderFactory, null);
+ assertNotNull(wsdlIC);
+ WSDLInterface wsdlInterface = (WSDLInterface)wsdlIC.getInterface();
+ assertNotNull(wsdlInterface);
+ assertEquals(1, wsdlInterface.getOperations().size());
+ assertEquals("sayHello", wsdlInterface.getOperations().get(0).getName());
+ assertNotNull(wsdlInterface.getPortType());
+
+ JavaInterfaceContract javaIC2 = factory.createJavaInterfaceContract();
+ JavaInterface iface2 = factory.createJavaInterface(TestJavaInterface.class);
+ new JAXWSJavaInterfaceProcessor(registry).visitInterface(iface2);
+ new DataBindingJavaInterfaceProcessor(registry).visitInterface(iface2);
+ javaIC2.setInterface(iface2);
+ WSDLInterfaceContract wsdlIC2 = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC2, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, documentBuilderFactory, null);
+ assertNotNull(wsdlIC2);
+ }
+
+}
+
+@Remotable
+interface HelloWorld {
+ String sayHello(String s);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java
new file mode 100644
index 0000000000..c80a929a90
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.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.sca.binding.ws.wsdlgen;
+
+import java.io.StringWriter;
+
+import javax.wsdl.Definition;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor;
+import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSFaultExceptionMapper;
+import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor;
+import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.xsd.DefaultXSDFactory;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.xml.XSDModelResolver;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Interface2WSDLGeneratorTestCase {
+
+ @Test
+ public void testGenerate() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ JavaInterfaceFactory iFactory = new DefaultJavaInterfaceFactory(registry);
+ JavaInterface iface = iFactory.createJavaInterface(TestJavaInterface.class);
+ DefaultDataBindingExtensionPoint dataBindings = new DefaultDataBindingExtensionPoint(new DefaultExtensionPointRegistry());
+ JAXWSFaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings, null);
+ new JAXWSJavaInterfaceProcessor(registry).visitInterface(iface);
+ new DataBindingJavaInterfaceProcessor(registry).visitInterface(iface);
+ DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(registry);
+ WSDLFactory wFactory = new DefaultWSDLFactory(registry);
+ DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+ WSDLDefinition wsdlDefinition = wFactory.createWSDLDefinition();
+ XSDFactory factory = new DefaultXSDFactory();
+ Interface2WSDLGenerator generator = new Interface2WSDLGenerator(false, new XSDModelResolver(null, null), dataBindings, factory, documentBuilderFactory, null);
+ Definition definition = generator.generate(iface, wsdlDefinition);
+
+ // print the generated WSDL file and inline schemas
+ WSDLWriter writer = generator.getFactory().newWSDLWriter();
+ StringWriter sw = new StringWriter();
+ writer.writeWSDL(definition, sw);
+ System.out.println(sw.toString());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java
new file mode 100644
index 0000000000..1e4f802e01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.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.sca.binding.ws.wsdlgen;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestException extends Exception {
+
+ private String userdata;
+
+ public TestException(String message) {
+ super(message);
+ }
+
+ public TestException(String message, String userdata) {
+ super(message);
+ this.userdata = userdata;
+ }
+
+ public String getUserdata() {
+ return userdata;
+ }
+
+ public void setUserdata(String userdata) {
+ this.userdata = userdata;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java
new file mode 100644
index 0000000000..da2c285bac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.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.sca.binding.ws.wsdlgen;
+
+import javax.xml.ws.WebFault;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+@WebFault(faultBean="org.apache.tuscany.sca.binding.ws.wsdlgen.TestFaultBean")
+public class TestFault extends Exception {
+
+ private TestFaultBean bean;
+
+ public TestFault(TestFaultBean bean, String message) {
+ super(message);
+ this.bean = bean;
+ }
+
+ public TestFault(TestFaultBean bean, String message, Throwable cause) {
+ super(message, cause);
+ this.bean = bean;
+ }
+
+ public TestFaultBean getFaultInfo() {
+ return bean;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java
new file mode 100644
index 0000000000..64cce0e49d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.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.sca.binding.ws.wsdlgen;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestFaultBean {
+ private String lastName;
+ private String firstName;
+ private float age;
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public float getAge() {
+ return age;
+ }
+
+ public void setAge(float age) {
+ this.age = age;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java
new file mode 100644
index 0000000000..3fd7361ae1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.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.binding.ws.wsdlgen;
+import org.apache.tuscany.sca.binding.ws.other.Other;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestJavaClass {
+ public Other other;
+ public String name;
+ public int number;
+ public float balance;
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java
new file mode 100644
index 0000000000..69265c1528
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.wsdlgen;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+@WebService
+public interface TestJavaInterface {
+ String m1(String str);
+
+ @OneWay
+ @WebMethod
+ void m2(int i);
+
+ @WebMethod
+ String m3();
+
+ void m4();
+
+ @WebMethod
+ String m5(String str, int i);
+
+ @WebMethod(exclude = true)
+ void dummy();
+
+ @WebMethod
+ void m6(TestJavaClass info) throws TestException;
+
+ @WebMethod
+ void m7(TestJavaClass info) throws TestFault;
+
+ @WebMethod
+ @SOAPBinding(parameterStyle=ParameterStyle.BARE)
+ void m8(String str);
+
+ @WebMethod
+ @SOAPBinding(parameterStyle=ParameterStyle.BARE)
+ int m9(String str);
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/LICENSE b/sandbox/sebastien/java/embed/modules/binding-ws/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-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/sebastien/java/embed/modules/binding-ws/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/binding-ws/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..0672cae141
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/META-INF/MANIFEST.MF
@@ -0,0 +1,45 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.ws;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.interfacedef.wsdl,
+ org.apache.tuscany.sca.assembly.builder,
+ org.apache.tuscany.sca.interfacedef,
+ org.w3c.dom,
+ javax.wsdl,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.binding.ws.addressing;version="2.0.0";uses:="javax.xml.namespace",
+ org.apache.tuscany.sca.binding.ws.xml
+Private-Package: org.apache.tuscany.sca.binding.ws.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA WS Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA WS Binding Model
+Import-Package: javax.wsdl,
+ javax.wsdl.extensions;version="1.6.2",
+ javax.wsdl.extensions.soap;version="1.6.2",
+ javax.wsdl.extensions.soap12;version="1.6.2",
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.addressing;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.ws
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/NOTICE b/sandbox/sebastien/java/embed/modules/binding-ws/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/pom.xml b/sandbox/sebastien/java/embed/modules/binding-ws/pom.xml
new file mode 100644
index 0000000000..0798b530c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <name>Apache Tuscany SCA WS Binding Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <!-- Apache repository for Web Services artifacts -->
+ <repository>
+ <id>apache.ws.zone</id>
+ <name>Apache WS Zone Repository</name>
+ <url>http://ws.zones.apache.org/repository2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
new file mode 100644
index 0000000000..b6bcb38645
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws;
+
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.w3c.dom.Element;
+
+
+/**
+ * Represents a WebService binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WebServiceBinding extends Binding {
+ QName TYPE = new QName(SCA11_NS, "binding.ws");
+
+ /**
+ * Sets the WSDL location.
+ * @param location the WSDL location
+ */
+ void setLocation(String location);
+
+ /**
+ * Returns the WSDL location
+ * @return the WSDL location
+ */
+ String getLocation();
+
+ /**
+ * Returns the wsdli:location attribute namespace mappings
+ * @return a Map with key being namespace and value the location
+ */
+ Map<String, String> getWsdliLocations();
+
+ /**
+ * Returns the name of the WSDL service.
+ *
+ * @return the name of the WSDL service
+ */
+ QName getServiceName();
+
+ /**
+ * Sets the name of the WSDL service.
+ *
+ * @param serviceName the name of the WSDL service
+ */
+ void setServiceName(QName serviceName);
+
+ /**
+ * Returns the name of the WSDL port.
+ *
+ * @return the name of the WSDL port
+ */
+ String getPortName();
+
+ /**
+ * Sets the name of the WSDL port.
+ *
+ * @param portName the name of the WSDL port
+ */
+ void setPortName(String portName);
+
+ /**
+ * Returns the name of the WSDL binding.
+ *
+ * @return the name of the WSDL binding
+ */
+ QName getBindingName();
+
+ /**
+ * Sets the name of the WSDL binding.
+ *
+ * @param bindingName the name of the WSDL binding
+ */
+ void setBindingName(QName bindingName);
+
+ /**
+ * Returns the name of the WSDL endpoint.
+ *
+ * @return the name of the WSDL endpoint
+ */
+ String getEndpointName();
+
+ /**
+ * Sets the name of the WSDL endpoint.
+ *
+ * @param endpointName the name of the WSDL endpoint
+ */
+ void setEndpointName(String endpointName);
+
+ /**
+ * Returns the WSDL service
+ * @return the WSDL service
+ */
+ Service getService();
+
+ /**
+ * Sets the WSDL service.
+ * @param service the WSDL service
+ */
+ void setService(Service service);
+
+ /**
+ * Returns the WSDL port
+ * @return the WSDL port
+ */
+ Port getPort();
+
+ /**
+ * Sets the WSDL endpoint
+ * @param endpoint the WSDL endpoint
+ */
+ void setEndpoint(Port endpoint);
+
+ /**
+ * Returns the WSDL endpoint
+ * @return the WSDL endpoint
+ */
+ Port getEndpoint();
+
+ /**
+ * Sets the WSDL port
+ * @param port the WSDL port
+ */
+ void setPort(Port port);
+
+ /**
+ * Returns the WSDL binding.
+ * @return the WSDL binding
+ */
+ javax.wsdl.Binding getBinding();
+
+ /**
+ * Sets the WSDL binding
+ * @param binding the WSDL binding
+ */
+ void setBinding(javax.wsdl.Binding binding);
+
+ /**
+ * Returns the WSDL definition that was specified by the
+ * user either via and interface.wsdl or via a wsdlElement
+ * on the binding. This may be empty if no WSDL was specified
+ * explicitly in which case the generated WSDL should contain
+ * a full WSDL description
+ *
+ * @return the WSDL definition
+ */
+ WSDLDefinition getUserSpecifiedWSDLDefinition();
+
+ /**
+ * Sets the WSDL definition if one was specified by the user in the
+ * composite file either via and interface.wsdl or via a wsdlElement
+ * on the binding
+ *
+ * @param wsdlDefinition the WSDL definition
+ */
+ void setUserSpecifiedWSDLDefinition(WSDLDefinition wsdlDefinition);
+
+ /**
+ * Returns the WSDL namespace.
+ * @return the WSDL namespace
+ */
+ String getNamespace();
+
+ /**
+ * Sets the WSDL namespace
+ * @param namespace the WSDL namespace
+ */
+ void setNamespace(String namespace);
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ InterfaceContract getBindingInterfaceContract();
+
+ void setBindingInterfaceContract(InterfaceContract bindingInterfaceContract);
+
+ Element getEndPointReference();
+
+ void setEndPointReference(Element element);
+
+ /**
+ * Returns the generated WSDL definitions document.
+ * @return the generated WSDL definitions document
+ */
+ Definition getGeneratedWSDLDocument();
+
+ /**
+ * Sets the generated WSDL definitions document. The WSDL is generated
+ * from the component implementation
+ *
+ * @param definition the generated WSDL definitions document
+ */
+ void setGeneratedWSDLDocument(Definition definition);
+
+ /**
+ * Returns string from the WSDL that represents the SOAP binding transport
+ */
+ String getBindingTransport();
+
+ /**
+ * Returns true if the WSDL style is rpc/encoded
+ */
+ boolean isRpcEncoded();
+
+ /**
+ * Returns true if the WSDL style is rpc/literal
+ */
+ boolean isRpcLiteral();
+
+ /**
+ * Returns true if the WSDL style is doc/encoded
+ */
+ boolean isDocEncoded();
+
+ /**
+ * Returns true is the WSDL style is doc/literal
+ */
+ boolean isDocLiteralUnwrapped();
+
+ /**
+ * Returns true if the WSDL style is doc/literal/wrapped
+ */
+ boolean isDocLiteralWrapped();
+
+ /**
+ * Returns true if the WSDL style is doc/literal
+ * and the mapping to the interface is bare
+ */
+ boolean isDocLiteralBare();
+
+ /**
+ * Returns true is the WSBinding is configured, via WSDL,
+ * to use an HTTP transport
+ */
+ boolean isHTTPTransport();
+
+ /**
+ * Returns true is the WSBinding is configured, via WSDL,
+ * to use a JMS transport
+ */
+ boolean isJMSTransport();
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java
new file mode 100644
index 0000000000..1ad38c69e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.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 org.apache.tuscany.sca.binding.ws;
+
+/**
+ * Factory for the Web Service binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WebServiceBindingFactory {
+
+ /**
+ * Creates a new WebService binding.
+ *
+ * @return a new WebService binding
+ */
+ WebServiceBinding createWebServiceBinding();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java
new file mode 100644
index 0000000000..a13584a3c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.addressing;
+
+import java.net.URI;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Defines a model for WS-Addressing
+ * &lt;wsa:EndpointReference&gt;
+ * &lt;wsa:Address&gt;xs:anyURI&lt;/wsa:Address&gt;
+ * &lt;wsa:ReferenceProperties&gt;... &lt;/wsa:ReferenceProperties&gt; ?
+ * &lt;wsa:ReferenceParameters&gt;... &lt;/wsa:ReferenceParameters&gt; ?
+ * &lt;wsa:PortType&gt;xs:QName&lt;/wsa:PortType&gt; ?
+ * &lt;wsa:ServiceName PortName="xs:NCName"?&gt;xs:QName&lt;/wsa:ServiceName&gt; ?
+ * &lt;wsp:Policy&gt; ... &lt;/wsp:Policy&gt;*
+ * &lt;/wsa:EndpointReference&gt;
+ * @version $Rev$ $Date$
+ */
+public interface EndPointReference {
+ URI getAddress();
+
+ void setAddress(URI address);
+
+ QName getPortType();
+
+ void setPortType(QName portType);
+
+ QName getServiceName();
+
+ void setServiceName(QName serviceName);
+
+ QName getPortName();
+
+ void setPortName(QName portName);
+
+ List<Object> getReferenceProperties();
+
+ List<Object> getReferenceParameters();
+
+ List<Object> getPolicies();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java
new file mode 100644
index 0000000000..055e2012dc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.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 org.apache.tuscany.sca.binding.ws.impl;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+
+/**
+ * A factory for the WSDL model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceBindingFactoryImpl implements WebServiceBindingFactory {
+
+ public WebServiceBinding createWebServiceBinding() {
+ return new WebServiceBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
new file mode 100644
index 0000000000..8e3c9262a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
@@ -0,0 +1,460 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Message;
+import javax.wsdl.Part;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Element;
+
+/**
+ * Represents a WebService binding.
+ *
+ * @version $Rev$ $Date$
+ */
+class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensible {
+ private String name;
+ private String uri;
+ private boolean unresolved;
+ private List<Object> extensions = new ArrayList<Object>();
+ private List<Extension> attributeExtensions = new ArrayList<Extension>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private ExtensionType extensionType;
+ private String location;
+ private Binding binding;
+ private Service service;
+ private Port port;
+ private Port endpoint;
+ private QName bindingName;
+ private String portName;
+ private QName serviceName;
+ private String endpointName;
+ private InterfaceContract bindingInterfaceContract;
+ private Element endPointReference;
+ private String wsdlNamespace;
+ private WSDLDefinition userSpecifiedWSDLDefinition;
+ private Definition generatedWSDLDocument;
+ private boolean isDocumentStyle;
+ private boolean isLiteralEncoding;
+ private boolean isMessageWrapped;
+ private Map<String, String> wsdliLocations = new HashMap<String, String>();
+
+ protected WebServiceBindingImpl() {
+ }
+
+ /**
+ * Provide a meaningful representation of this Binding
+ */
+ public String toString() {
+ return "Web Service Binding: " + name;
+ } // end method toString
+
+ 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 boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public List<Extension> getAttributeExtensions() {
+ return attributeExtensions;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public Binding getBinding() {
+ if (binding == null) {
+ if (getUserSpecifiedWSDLDefinition() != null && userSpecifiedWSDLDefinition.getBinding() != null) {
+ binding = userSpecifiedWSDLDefinition.getBinding();
+ determineWSDLCharacteristics();
+ }
+ }
+ return binding;
+ }
+
+ public QName getBindingName() {
+ if (isUnresolved()) {
+ return bindingName;
+ } else if (binding != null) {
+ return binding.getQName();
+ } else {
+ return null;
+ }
+ }
+
+ public String getEndpointName() {
+ if (isUnresolved()) {
+ return endpointName;
+ } else if (endpoint != null) {
+ //TODO support WSDL 2.0
+ return endpoint.getName();
+ } else {
+ return null;
+ }
+ }
+
+ public Port getEndpoint() {
+ return endpoint;
+ }
+
+ public Port getPort() {
+ return port;
+ }
+
+ public String getPortName() {
+ if (isUnresolved()) {
+ return portName;
+ } else if (port != null) {
+ return port.getName();
+ } else {
+ return null;
+ }
+ }
+
+ public Service getService() {
+ return service;
+ }
+
+ public QName getServiceName() {
+ if (isUnresolved()) {
+ return serviceName;
+ } else if (service != null) {
+ return service.getQName();
+ } else {
+ return null;
+ }
+ }
+
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ determineWSDLCharacteristics();
+ }
+
+ public void setBindingName(QName bindingName) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ }
+ this.bindingName = bindingName;
+ }
+
+ public void setEndpoint(Port endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public void setEndpointName(String endpointName) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ }
+ this.endpointName = endpointName;
+ }
+
+ public void setPort(Port port) {
+ this.port = port;
+ }
+
+ public void setPortName(String portName) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ }
+ this.portName = portName;
+ }
+
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ public void setServiceName(QName serviceName) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ }
+ this.serviceName = serviceName;
+ }
+
+ public WSDLDefinition getUserSpecifiedWSDLDefinition() {
+ if (userSpecifiedWSDLDefinition == null) {
+ Interface iface = bindingInterfaceContract.getInterface();
+ if (iface instanceof WSDLInterface) {
+ userSpecifiedWSDLDefinition = ((WSDLInterface) iface).getWsdlDefinition();
+ }
+ }
+ return userSpecifiedWSDLDefinition;
+ }
+
+ public void setUserSpecifiedWSDLDefinition(WSDLDefinition wsdlDefinition) {
+ this.userSpecifiedWSDLDefinition = wsdlDefinition;
+ }
+
+ public String getNamespace() {
+ return wsdlNamespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.wsdlNamespace = namespace;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return bindingInterfaceContract;
+ }
+
+ public void setBindingInterfaceContract(InterfaceContract bindingInterfaceContract) {
+ this.bindingInterfaceContract = bindingInterfaceContract;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return extensionType;
+ }
+
+ public void setExtensionType(ExtensionType intentAttachPointType) {
+ this.extensionType = intentAttachPointType;
+ }
+
+ public Element getEndPointReference() {
+ return endPointReference;
+ }
+
+ public void setEndPointReference(Element epr) {
+ this.endPointReference = epr;
+ }
+
+ public Definition getGeneratedWSDLDocument() {
+ return generatedWSDLDocument;
+ }
+
+ public void setGeneratedWSDLDocument(Definition definition) {
+ this.generatedWSDLDocument = definition;
+ determineWSDLCharacteristics();
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+ /**
+ * Some items get calculated and cached as they are used at runtime
+ * to decide what message processing is required
+ */
+ protected void determineWSDLCharacteristics() {
+ setIsDocumentStyle();
+ setIsLiteralEncoding();
+ setIsMessageWrapped();
+ }
+
+ protected void setIsDocumentStyle() {
+
+ if (binding == null){
+ if (userSpecifiedWSDLDefinition != null && userSpecifiedWSDLDefinition.getDefinition() != null){
+ Message firstMessage = (Message)userSpecifiedWSDLDefinition.getDefinition().getMessages().values().iterator().next();
+ Part firstPart = (Part)firstMessage.getParts().values().iterator().next();
+ if (firstPart.getTypeName() != null){
+ isDocumentStyle = false;
+ return;
+ }
+ }
+
+ // default to document style
+ isDocumentStyle = true;
+ return;
+ } else {
+ for (Object ext : binding.getExtensibilityElements()){
+ if (ext instanceof SOAPBinding){
+ if (((SOAPBinding)ext).getStyle().equals("rpc")){
+ isDocumentStyle = false;
+ return;
+ } else {
+ isDocumentStyle = true;
+ return;
+ }
+ }
+ }
+ isDocumentStyle = true;
+ return;
+ }
+
+ }
+
+ protected void setIsLiteralEncoding() {
+
+ if (binding == null){
+ // default to literal encoding
+ isLiteralEncoding = true;
+ return;
+ } else {
+ for(Object ext : ((BindingOperation)binding.getBindingOperations().get(0)).getBindingInput().getExtensibilityElements()){
+ if (ext instanceof SOAPBody){
+ if (((SOAPBody)ext).getUse().equals("literal")){
+ isLiteralEncoding = true;
+ return;
+ } else {
+ isLiteralEncoding = false;
+ return;
+ }
+ }
+ }
+ isLiteralEncoding = true;
+ return;
+ }
+ }
+
+ protected void setIsMessageWrapped() {
+ if (getBindingInterfaceContract() != null){
+ isMessageWrapped = getBindingInterfaceContract().getInterface().getOperations().get(0).isWrapperStyle();
+ }
+ }
+
+ public boolean isRpcEncoded() {
+ return (!isDocumentStyle) && (!isLiteralEncoding);
+ }
+
+ public boolean isRpcLiteral() {
+ return (!isDocumentStyle) && (isLiteralEncoding);
+ }
+
+ public boolean isDocEncoded() {
+ return (isDocumentStyle) && (!isLiteralEncoding);
+ }
+
+ public boolean isDocLiteralUnwrapped() {
+ setIsMessageWrapped();
+ return (isDocumentStyle) && (isLiteralEncoding) && (!isMessageWrapped);
+ }
+
+ public boolean isDocLiteralWrapped() {
+ setIsMessageWrapped();
+ return (isDocumentStyle) && (isLiteralEncoding) &&(isMessageWrapped);
+ }
+
+ public boolean isDocLiteralBare() {
+ setIsMessageWrapped();
+ return (isDocumentStyle) && (isLiteralEncoding);
+ }
+
+ public boolean isHTTPTransport() {
+ return getBindingTransport().equals("http://schemas.xmlsoap.org/soap/http");
+ }
+
+ public boolean isJMSTransport() {
+ return getBindingTransport().equals("http://schemas.xmlsoap.org/soap/jms");
+ }
+
+ public String getBindingTransport() {
+ if (binding != null){
+ for (Object ext : binding.getExtensibilityElements()){
+ if (ext instanceof SOAPBinding){
+ return ((SOAPBinding)ext).getTransportURI();
+ }
+ }
+ }
+
+ // if no binding is explicitly specified by the user then default to http
+ return "http://schemas.xmlsoap.org/soap/http";
+ }
+
+ public Map<String, String> getWsdliLocations() {
+ return wsdliLocations ;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java
new file mode 100644
index 0000000000..9051dc0af7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.xml;
+
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * Helper methods to read and write a wsa:endpointReference
+ * TODO: almost direct copy of code for Assembly properties
+ * must be able to move to a common utility
+ *
+ * @version $Rev$ $Date$
+ */
+public class EndPointReferenceHelper {
+
+ /**
+ * Read a wsa:endpointReference into a DOM Element
+ */
+ public static Element readEndPointReference(XMLStreamReader reader) {
+ try {
+
+ return loadElement(reader);
+
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Write a wsa:endpointReference from a DOM Element
+ */
+ public static void writeEndPointReference(Element element, XMLStreamWriter writer) {
+ try {
+
+ saveElement(element, writer);
+
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Element loadElement(XMLStreamReader reader) throws XMLStreamException, ParserConfigurationException {
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ Node root = document;
+ Node current = root;
+ while (true) {
+ switch (reader.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ Element child = createElement(document, name);
+
+ // push the new element and make it the current one
+ current.appendChild(child);
+ current = child;
+
+ int count = reader.getNamespaceCount();
+ for (int i = 0; i < count; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ declareNamespace(child, prefix, ns);
+ }
+
+ if(!"".equals(name.getNamespaceURI()))
+ declareNamespace(child, name.getPrefix(), name.getNamespaceURI());
+
+ // add the attributes for this element
+ count = reader.getAttributeCount();
+ for (int i = 0; i < count; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+ if (prefix != null && prefix.length() != 0) {
+ qname = prefix + ":" + qname;
+ }
+ child.setAttributeNS(ns, qname, value);
+ if (ns != null) {
+ declareNamespace(child, prefix, ns);
+ }
+ }
+
+ break;
+ case XMLStreamConstants.CDATA:
+ current.appendChild(document.createCDATASection(reader.getText()));
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ current.appendChild(document.createTextNode(reader.getText()));
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ // if we are back at the root then we are done
+ if ("EndpointReference".equals(reader.getName().getLocalPart())) {
+ return document.getDocumentElement();
+ }
+
+ // pop the element off the stack
+ current = current.getParentNode();
+ }
+ if ( reader.hasNext()) reader.next();
+ }
+ }
+
+ private static Element createElement(Document document, QName name) {
+ String prefix = name.getPrefix();
+ String qname =
+ (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name.getLocalPart();
+ return document.createElementNS(name.getNamespaceURI(), qname);
+ }
+
+ private static void declareNamespace(Element element, String prefix, String ns) {
+ if (ns == null) {
+ ns = "";
+ }
+ if (prefix == null) {
+ prefix = "";
+ }
+ String qname = null;
+ if ("".equals(prefix)) {
+ qname = "xmlns";
+ } else {
+ qname = "xmlns:" + prefix;
+ }
+ Node node = element;
+ boolean declared = false;
+ while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+ NamedNodeMap attrs = node.getAttributes();
+ if (attrs == null) {
+ break;
+ }
+ Node attr = attrs.getNamedItem(qname);
+ if (attr != null) {
+ declared = ns.equals(attr.getNodeValue());
+ break;
+ }
+ node = node.getParentNode();
+ }
+ if (!declared) {
+ org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname);
+ attr.setValue(ns);
+ element.setAttributeNodeNS(attr);
+ }
+ }
+
+ private static void saveElement(Element element, XMLStreamWriter writer) throws XMLStreamException{
+
+ XMLStreamReader reader =
+ XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(element));
+
+ while (reader.hasNext()) {
+ switch (reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ writer.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
+
+ int namespaces = reader.getNamespaceCount();
+ for (int i = 0; i < namespaces; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ writer.writeNamespace(prefix, ns);
+ }
+
+ if (!"".equals(name.getNamespaceURI())) {
+ writer.writeNamespace(name.getPrefix(), name.getNamespaceURI());
+ }
+
+ // add the attributes for this element
+ namespaces = reader.getAttributeCount();
+ for (int i = 0; i < namespaces; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+
+ writer.writeAttribute(prefix, ns, qname, value);
+ }
+
+ break;
+ case XMLStreamConstants.CDATA:
+ writer.writeCData(reader.getText());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ writer.writeCharacters(reader.getText());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ writer.writeEndElement();
+ break;
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
new file mode 100644
index 0000000000..d528516160
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
@@ -0,0 +1,526 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.binding.ws.xml.WebServiceConstants.SCA11_NS;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+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.Callback;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * This is the StAXArtifactProcessor for the Web Services Binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WebServiceBinding>, WebServiceConstants {
+
+ private ExtensionPointRegistry extensionPoints;
+ private WSDLFactory wsdlFactory;
+ private WebServiceBindingFactory wsFactory;
+ private PolicyFactory policyFactory;
+ private PolicySubjectProcessor policyProcessor;
+ //private PolicyFactory intentAttachPointTypeFactory;
+
+
+ public WebServiceBindingProcessor(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.wsFactory = modelFactories.getFactory(WebServiceBindingFactory.class);
+ this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "binding-wsxml-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "binding-wsxml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public WebServiceBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Monitor monitor = context.getMonitor();
+ // Read a <binding.ws>
+ WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
+ /*ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
+ bindingType.setName(getArtifactType());
+ bindingType.setUnresolved(true);
+ ((PolicySubject)wsBinding).setType(bindingType);*/
+ wsBinding.setUnresolved(true);
+
+ // Read policies
+ policyProcessor.readPolicies(wsBinding, reader);
+
+ // Read the binding name
+ String name = reader.getAttributeValue(null, NAME);
+ if (name != null) {
+ wsBinding.setName(name);
+ }
+
+ // a collection of endpoint specifications so that we can test that
+ // only one is present
+ List<String> endpointSpecifications = new ArrayList<String>();
+
+ // Read URI
+ String uri = getURIString(reader, URI);
+ if (uri != null) {
+ wsBinding.setURI(uri);
+
+ // BWS20001
+ if (context.getParentModel() instanceof Reference){
+ try {
+ URI tmpURI = new URI(uri);
+
+ if (!tmpURI.isAbsolute()){
+ error(monitor, "URINotAbsolute", reader, uri);
+ }
+ } catch (URISyntaxException ex){
+ error(monitor, "InvalidURISyntax", reader, ex.getMessage());
+ }
+ endpointSpecifications.add("uri");
+ }
+
+ // BWS20020
+ if ((context.getParentModel() instanceof Callback) &&
+ (((Callback)context.getParentModel()).getParentContract() instanceof org.apache.tuscany.sca.assembly.Service)){
+ error(monitor, "URIFoundForServiceCallback", reader, uri);
+ }
+ }
+
+ // Read a qname in the form:
+ // namespace#wsdl.???(name)
+ Boolean wsdlElementIsBinding = null;
+ String wsdlElement = getURIString(reader, WSDL_ELEMENT);
+ if (wsdlElement != null) {
+ int index = wsdlElement.indexOf('#');
+ if (index == -1) {
+ error(monitor, "InvalidWsdlElementAttr", reader, wsdlElement);
+ //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
+ return wsBinding;
+ }
+ String namespace = wsdlElement.substring(0, index);
+ wsBinding.setNamespace(namespace);
+ String localName = wsdlElement.substring(index + 1);
+ if (localName.startsWith("wsdl.service")) {
+
+ // BWS20003
+ if (context.getParentModel() instanceof org.apache.tuscany.sca.assembly.Service){
+ error(monitor, "WSDLServiceOnService", reader, wsdlElement);
+ }
+
+ // Read a wsdl.service
+ localName = localName.substring("wsdl.service(".length(), localName.length() - 1);
+ wsBinding.setServiceName(new QName(namespace, localName));
+
+ endpointSpecifications.add("#wsdl.service");
+
+ } else if (localName.startsWith("wsdl.port")) {
+
+ // Read a wsdl.port
+ localName = localName.substring("wsdl.port(".length(), localName.length() - 1);
+ int s = localName.indexOf('/');
+ if (s == -1) {
+ error(monitor, "InvalidWsdlElementAttr", reader, wsdlElement);
+ //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
+ } else {
+ wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
+ wsBinding.setPortName(localName.substring(s + 1));
+ }
+
+ endpointSpecifications.add("#wsdl.port");
+ } else if (localName.startsWith("wsdl.endpoint")) {
+
+ // Read a wsdl.endpoint
+ localName = localName.substring("wsdl.endpoint(".length(), localName.length() - 1);
+ int s = localName.indexOf('/');
+ if (s == -1) {
+ error(monitor, "InvalidWsdlElementAttr", reader, wsdlElement);
+ //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
+ } else {
+ wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
+ wsBinding.setEndpointName(localName.substring(s + 1));
+ }
+
+ } else if (localName.startsWith("wsdl.binding")) {
+
+ // Read a wsdl.binding
+ localName = localName.substring("wsdl.binding(".length(), localName.length() - 1);
+ wsBinding.setBindingName(new QName(namespace, localName));
+
+ wsdlElementIsBinding = true;
+
+ } else {
+ error(monitor, "InvalidWsdlElementAttr", reader, wsdlElement);
+ //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
+ }
+ }
+
+ // Read wsdlLocation
+ String wsdliLocation = reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION);
+ if (wsdliLocation != null) {
+ if (wsdlElement == null) {
+ error(monitor, "WsdliLocationMissingWsdlElement", reader);
+ }
+ String[] iris = wsdliLocation.split(" ");
+ if (iris.length % 2 != 0) {
+ error(monitor, "WsdliLocationNotIRIPairs", reader);
+ }
+ for (int i=0; i<iris.length-1; i=i+2) {
+ wsBinding.getWsdliLocations().put(iris[i], iris[i+1]);
+ }
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ int event = reader.next();
+ switch (event) {
+ case START_ELEMENT: {
+ if (END_POINT_REFERENCE.equals(reader.getName().getLocalPart())) {
+ if (wsdlElement != null && (wsdlElementIsBinding == null || !wsdlElementIsBinding)) {
+ error(monitor, "MustUseWsdlBinding", reader, wsdlElement);
+ throw new ContributionReadException(wsdlElement + " must use wsdl.binding when using wsa:EndpointReference");
+ }
+
+ wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader));
+ endpointSpecifications.add("wsa:EndpointReference");
+ }
+ }
+ break;
+
+ }
+
+ if (event == END_ELEMENT && BINDING_WS_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ if (endpointSpecifications.size() > 1){
+ error(monitor, "MultipleEndpointsSpecified", reader, endpointSpecifications.toString() );
+ }
+
+ return wsBinding;
+ }
+
+ protected void processEndPointReference(XMLStreamReader reader, WebServiceBinding wsBinding) {
+ }
+
+ public void write(WebServiceBinding wsBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write a <binding.ws>
+ writer.writeStartElement(SCA11_NS, BINDING_WS);
+ policyProcessor.writePolicyAttributes(wsBinding, writer);
+
+ // Write binding name
+ if (wsBinding.getName() != null) {
+ writer.writeAttribute(NAME, wsBinding.getName());
+ }
+
+ // Write binding URI
+ if (wsBinding.getURI() != null) {
+ writer.writeAttribute(URI, wsBinding.getURI());
+ }
+
+ // Write wsdlElement attribute
+ if (wsBinding.getPortName() != null) {
+
+ // Write namespace#wsdl.port(service/port)
+ String wsdlElement =
+ wsBinding.getServiceName().getNamespaceURI() + "#wsdl.port("
+ + wsBinding.getServiceName().getLocalPart()
+ + "/"
+ + wsBinding.getPortName()
+ + ")";
+ writer.writeAttribute(WSDL_ELEMENT, wsdlElement);
+
+ } else if (wsBinding.getEndpointName() != null) {
+
+ // Write namespace#wsdl.endpoint(service/endpoint)
+ String wsdlElement =
+ wsBinding.getServiceName().getNamespaceURI() + "#wsdl.endpoint("
+ + wsBinding.getServiceName().getLocalPart()
+ + "/"
+ + wsBinding.getEndpointName()
+ + ")";
+ writer.writeAttribute(WSDL_ELEMENT, wsdlElement);
+
+ } else if (wsBinding.getBindingName() != null) {
+
+ // Write namespace#wsdl.binding(binding)
+ String wsdlElement =
+ wsBinding.getBindingName().getNamespaceURI() + "#wsdl.binding("
+ + wsBinding.getBindingName().getLocalPart()
+ + ")";
+ writer.writeAttribute(WSDL_ELEMENT, wsdlElement);
+
+ } else if (wsBinding.getServiceName() != null) {
+
+ // Write namespace#wsdl.service(service)
+ String wsdlElement =
+ wsBinding.getServiceName().getNamespaceURI() + "#wsdl.service("
+ + wsBinding.getServiceName().getLocalPart()
+ + ")";
+ writer.writeAttribute(WSDL_ELEMENT, wsdlElement);
+ }
+
+ // Write wsdli:location
+ if (wsBinding.getWsdliLocations().size() > 0) {
+ StringBuilder wsdliLocation = new StringBuilder();
+ Map<String, String> wl = wsBinding.getWsdliLocations();
+ for (String ns : wl.keySet()) {
+ if (wsdliLocation.length() > 0) {
+ wsdliLocation.append(' ');
+ }
+ wsdliLocation.append(ns);
+ wsdliLocation.append(' ');
+ wsdliLocation.append(wl.get(ns));
+ }
+ writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsdliLocation.toString());
+ }
+
+ if (wsBinding.getEndPointReference() != null) {
+ EndPointReferenceHelper.writeEndPointReference(wsBinding.getEndPointReference(), writer);
+ }
+
+ writer.writeEndElement();
+ }
+
+ public void resolve(WebServiceBinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (model == null || !model.isUnresolved())
+ return;
+ Monitor monitor = context.getMonitor();
+ WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition.setNamespace(model.getNamespace());
+ wsdlDefinition.setNameOfBindingToResolve(model.getBindingName());
+ wsdlDefinition.setNameOfServiceToResolve(model.getServiceName());
+ wsdlDefinition.getWsdliLocations().putAll(model.getWsdliLocations());
+ WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition, context);
+
+ if (!resolved.isUnresolved()) {
+ wsdlDefinition.setDefinition(resolved.getDefinition());
+ wsdlDefinition.setLocation(resolved.getLocation());
+ wsdlDefinition.setURI(resolved.getURI());
+ wsdlDefinition.getImportedDefinitions().addAll(resolved.getImportedDefinitions());
+ wsdlDefinition.getXmlSchemas().addAll(resolved.getXmlSchemas());
+ wsdlDefinition.setUnresolved(false);
+ model.setUserSpecifiedWSDLDefinition(wsdlDefinition);
+ if (model.getBindingName() != null) {
+ WSDLObject<Binding> binding = wsdlDefinition.getWSDLObject(Binding.class, model.getBindingName());
+ if (binding != null) {
+ wsdlDefinition.setDefinition(binding.getDefinition());
+ model.setBinding(binding.getElement());
+ } else {
+ error(monitor, "WsdlBindingDoesNotMatch", wsdlDefinition, model.getBindingName());
+ }
+ }
+ if (model.getServiceName() != null) {
+ WSDLObject<Service> service = wsdlDefinition.getWSDLObject(Service.class, model.getServiceName());
+ if (service != null) {
+ wsdlDefinition.setDefinition(service.getDefinition());
+ model.setService(service.getElement());
+
+ Port port = null;
+ if (model.getPortName() != null) {
+ port = service.getElement().getPort(model.getPortName());
+ } else {
+ // BWS20006 - no port specified so pick the first one
+ port = (Port)service.getElement().getPorts().values().iterator().next();
+ }
+
+ if (port != null) {
+ model.setPort(port);
+ model.setBinding(port.getBinding());
+
+ // if no URI specified set it from the WSDL port location
+ if (model.getURI() == null){
+ model.setURI(getPortAddress(port));
+ }
+ } else {
+ error(monitor, "WsdlPortTypeDoesNotMatch", wsdlDefinition, model.getPortName());
+ }
+ } else {
+ error(monitor, "WsdlServiceDoesNotMatch", wsdlDefinition, model.getServiceName());
+ }
+ }
+
+ PortType portType = getPortType(model);
+ if (portType != null) {
+ WSDLInterfaceContract interfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ WSDLInterface wsdlInterface = null;
+ try {
+ wsdlInterface = wsdlFactory.createWSDLInterface(portType, wsdlDefinition, resolver, context.getMonitor());
+ } catch (InvalidInterfaceException e) {
+ warning(monitor, "InvalidInterfaceException", wsdlFactory, model.getName(), e.getMessage());
+ }
+ interfaceContract.setInterface(wsdlInterface);
+ interfaceContract.setCallbackInterface(wsdlInterface.getCallbackInterface());
+ model.setBindingInterfaceContract(interfaceContract);
+ }
+
+ validateWSDL(context, model);
+ } else {
+ if (model.getBindingName() != null){
+ error(monitor, "WsdlBindingDoesNotMatch", model, model.getBindingName());
+ }
+
+ if (model.getServiceName() != null){
+ error(monitor, "WsdlServiceDoesNotMatch", model, model.getServiceName());
+ }
+ }
+
+ policyProcessor.resolvePolicies(model, resolver, context);
+ }
+
+ private void validateWSDL(ProcessorContext context, WebServiceBinding model) {
+ WSDLDefinition wsdlDefinition = model.getUserSpecifiedWSDLDefinition();
+
+ Port port = model.getPort();
+
+ if (port != null){
+ validateWSDLPort(context, model, port);
+ }
+
+ Binding binding = model.getBinding();
+
+ if (binding != null){
+ validateWSDLBinding(context, model, binding);
+ }
+ }
+
+ private void validateWSDLPort(ProcessorContext context, WebServiceBinding model, Port port){
+
+ validateWSDLBinding(context, model, port.getBinding());
+
+ }
+
+ private void validateWSDLBinding(ProcessorContext context, WebServiceBinding model, Binding binding){
+ // BWS20005 & BWS20010
+ // Check that the WSDL binding is of a supported type
+ if (!model.isHTTPTransport() && !model.isJMSTransport()){
+ error(context.getMonitor(),
+ "InvalidWSDLBindingTransport",
+ model,
+ model.getBindingTransport());
+ }
+ }
+
+ private PortType getPortType(WebServiceBinding model) {
+ PortType portType = null;
+ if (model.getPort() != null) {
+ portType = model.getPort().getBinding().getPortType();
+ } else if (model.getEndpoint() != null) {
+ portType = model.getPort().getBinding().getPortType();
+ } else if (model.getBinding() != null) {
+ portType = model.getBinding().getPortType();
+ } else if (model.getService() != null) {
+ // FIXME: How to find the compatible port?
+ Map ports = model.getService().getPorts();
+ if (!ports.isEmpty()) {
+ Port port = (Port)ports.values().iterator().next();
+ portType = port.getBinding().getPortType();
+ }
+ }
+ return portType;
+ }
+
+ public static String getPortAddress(Port port) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ return ((SOAPAddress)ext).getLocationURI();
+ }
+ if (ext instanceof SOAP12Address) {
+ return ((SOAP12Address)ext).getLocationURI();
+ }
+ return null;
+ }
+
+ public QName getArtifactType() {
+ return WebServiceConstants.BINDING_WS_QNAME;
+ }
+
+ public Class<WebServiceBinding> getModelType() {
+ return WebServiceBinding.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java
new file mode 100644
index 0000000000..a7126a67ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.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.sca.binding.ws.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants for the Web Services Binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WebServiceConstants {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ String BINDING_WS = "binding.ws";
+ QName BINDING_WS_QNAME = new QName(SCA11_NS, BINDING_WS);
+
+ String WSDL_ELEMENT = "wsdlElement";
+ QName WSDL_ELEMENT_QNAME = new QName(SCA11_NS, WSDL_ELEMENT);
+
+ String WSDL_LOCATION = "wsdlLocation";
+ String WSDLI_NS = "http://www.w3.org/ns/wsdl-instance";
+
+ QName WSDL_LOCATION_QNAME = new QName(WSDLI_NS, WSDL_LOCATION);
+
+ String NAME = "name";
+ String URI = "uri";
+ String END_POINT_REFERENCE = "EndpointReference";
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory
new file mode 100644
index 0000000000..29fa81e2af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.ws.impl.WebServiceBindingFactoryImpl
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..75a0170373
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.binding.ws.xml.WebServiceBindingProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#binding.ws,model=org.apache.tuscany.sca.binding.ws.WebServiceBinding
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties
new file mode 100644
index 0000000000..4c2a857d6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties
@@ -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.
+#
+#
+InvalidWsdlElementAttr = Invalid WebService binding wsdlElement attribute: {0}
+MustUseWsdlBinding = {0} must use wsdl.binding when using wsa:EndpointReference
+InvalidInterfaceException = Exception creating interface from WSDL for binding {0} exception {1}
+WsdlBindingDoesNotMatch = The #wsdl.binding({0}) not found in the available WSDL Definitions
+WsdlServiceDoesNotMatch = [BWS20005] The #wsdl.service({0}) not found in the available WSDL Definitions
+WsdlPortTypeDoesNotMatch = The #wsdl.port({0}) does not match with the WSDL Definitions
+WsdliLocationMissingWsdlElement = [BWS20017] binding.ws has a @wsdli:wsdlLocation attribute but no @wsdlElement attribute
+WsdliLocationNotIRIPairs = The binding.ws @wsdli:wsdlLocation attribute MUST be a list of pairs of IRIs
+URINotAbsolute = [BWS20001] The URI value for binding.ws on an SCA reference must be absolute. Non-absolute value found {0}
+InvalidURISyntax = The URI value {0} found on binding.ws has invalid syntax
+WSDLServiceOnService = [BWS20003] The wsdlElement attribute of a binding.ws on an SCA service must not specify the wsdl.service form of URI. The following URI was found {0}
+URIFoundForServiceCallback = [BWS20020] For the callback element of an SCA service, the binding must not specify an endpoint address URI or a WS-Addressing wsa:EndpointReference
+InvalidWSDLBindingTransport = [BWS20005][BWS20010] The WSDL binding transport {0} is not supported by Tuscany
+MultipleEndpointsSpecified = [BWS20019] with binding.ws you can only specify one of url, wsa:EndpointReference, #wsdl.service or #wsdl.port. The following were found {0}
+
+
+
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java
new file mode 100644
index 0000000000..85d41bd15c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.ws.xml;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ComponentType componentType = (ComponentType)staxProcessor.read(reader, context);
+ assertNotNull(componentType);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ }
+
+ @Test
+ public void testReadPolicies() throws Exception {
+ InputStream is = getClass().getResourceAsStream("PoliciedCalculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ }
+
+ /**
+ * This test makes sure that an exception is thrown when a bad wsdlElement is present along with EndpointReference.
+ *
+ * Ref: Web Service Binding Specification v1.0 - Sec 2.1 - Lines 61 to 65.
+ * When an EndpointReference is present along with the wsdlElement attribute on the parent element, the wsdlElement attribute value MUST
+ * be of the 'Binding' form.
+ */
+ @Test
+ public void testReadBadWsdlElement() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator-bad-wsdlElement.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ try {
+ staxProcessor.read(reader, context);
+ fail("ContributionReadException expected.");
+ } catch(ContributionReadException e) {
+ // Expected
+ assertNotSame(-1, e.getMessage().indexOf("must use wsdl.binding when using wsa:EndpointReference"));
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java
new file mode 100644
index 0000000000..805b1862ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.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.sca.binding.ws.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading/write WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentType componentType = (ComponentType)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(componentType);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos), context);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(composite);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+ System.out.println(bos.toString());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite
new file mode 100644
index 0000000000..2404e9ba28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite
@@ -0,0 +1,59 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://sample.calculator"
+ targetNamespace="http://calc"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
+ name="Calculator-bad-wsdlElement">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)">
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/Calculator</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite
new file mode 100644
index 0000000000..64965a689c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite
@@ -0,0 +1,63 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://sample.calculator"
+ targetNamespace="http://calc"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ <binding.ws uri="http://localhost:8085/Calculator" wsdlElement="http://sample/calculator#wsdl.service(CalculatorService)"/>
+ <binding.ws wsdli:wsdlLocation="http://tempuri.org" wsdlElement="http://sample/calculator#wsdl.binding(CalculatorBinding)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.endpoint(CalculatorService/CalculatorEndpoint)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.binding(CalculatorBinding)">
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>http://localhost:8085/services/HelloWorldWebService</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..b86683b79a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance">
+
+ <service name="CalculatorService">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ <binding.ws uri="http://localhost:8085/Calculator" wsdlElement="http://sample/calculator#wsdl.service(CalculatorService)"/>
+ <binding.ws wsdli:wsdlLocation="http://tempuri.org" wsdlElement="http://sample/calculator#wsdl.binding(CalculatorBinding)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.endpoint(CalculatorService/CalculatorEndpoint)"/>
+ </service>
+
+ <reference name="divideService">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Divide)"/>
+ <binding.ws uri="tempuri.org" wsdlElement="http://sample/calculator#wsdl.service(DivideService)"/>
+ <binding.ws uri="tempuri.org" wsdlElement="http://sample/calculator#wsdl.binding(DivideBinding)"/>
+ <binding.ws uri="tempuri.org" wsdlElement="http://sample/calculator#wsdl.port(DivideService/DividePort)"/>
+ <binding.ws uri="tempuri.org" wsdlElement="http://sample/calculator#wsdl.endpoint(DivideService/DivideEndpoint)"/>
+ <binding.ws>
+ <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <wsa:Address>myURI</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </reference>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite
new file mode 100644
index 0000000000..1b6423be1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite
@@ -0,0 +1,60 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://sample.calculator"
+ targetNamespace="http://calc"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ <binding.ws uri="http://localhost:8085/Calculator" wsdlElement="http://sample/calculator#wsdl.service(CalculatorService)">
+ <operation name="add" requires="IntentOne IntentTwo"/>
+ </binding.ws>
+ <binding.ws wsdli:wsdlLocation="http://tempuri.org" wsdlElement="http://sample/calculator#wsdl.binding(CalculatorBinding)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.port(CalculatorService/CalculatorPort)"/>
+ <binding.ws wsdlElement="http://sample/calculator#wsdl.endpoint(CalculatorService/CalculatorEndpoint)"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl
new file mode 100644
index 0000000000..5e8e5dad0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl
@@ -0,0 +1,26 @@
+<?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://www.example.org"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="example">
+
+ <wsdl:portType name="HelloWorld">
+ </wsdl:portType>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl
new file mode 100644
index 0000000000..ad81fc7867
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice1">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput" />
+ <output message="tns:GetLastTradePriceOutput" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd
new file mode 100644
index 0000000000..241ec15d36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl
new file mode 100644
index 0000000000..39cd5547d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput" />
+ <output message="tns:GetLastTradePriceOutput" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl
new file mode 100644
index 0000000000..8e26f7b4b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl
@@ -0,0 +1,45 @@
+<?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:import location="test2.wsdl" namespace="http://helloworld"></wsdl:import>
+
+ <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:8085/sample-helloworldws-1.0-SNAPSHOT/services/HelloWorldWebService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd
new file mode 100644
index 0000000000..c2210f4a94
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd
@@ -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.
+-->
+<schema targetNamespace="http://www.example.com/Customer" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO" xmlns:tns="http://www.example.com/Customer">
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd" />
+
+ <complexType name="Customer">
+ <sequence>
+ <element name="customerID" type="string"></element>
+ <element name="name" type="string"></element>
+ <element name="order" type="ipo:PurchaseOrderType" />
+ </sequence>
+ </complexType>
+ <element name="customer" type="tns:Customer"></element>
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl
new file mode 100644
index 0000000000..529b395fd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl
@@ -0,0 +1,63 @@
+<?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">
+
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd" />
+
+ <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:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl
new file mode 100644
index 0000000000..666a7e4069
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput1">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput1">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <message name="GetLastTradePriceInput2">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ <part name="other" type="xsd:string"/>
+ </message>
+
+ <message name="GetLastTradePriceOutput2">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput1" />
+ <output message="tns:GetLastTradePriceOutput1" />
+ </operation>
+ <operation name="getLastTradePrice1">
+ <input message="tns:GetLastTradePriceInput1" />
+ <output message="tns:GetLastTradePriceOutput1" />
+ </operation>
+ <operation name="getLastTradePrice2">
+ <input message="tns:GetLastTradePriceInput2" />
+ <output message="tns:GetLastTradePriceOutput2" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/builder/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/builder/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b85e8999f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/META-INF/MANIFEST.MF
@@ -0,0 +1,43 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Model Builders
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Assembly Model
+Import-Package: javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.sax,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.jaxb;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.ws.commons.schema,
+ org.oasisopen.sca;version="2.0.0",
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.builder
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/builder/pom.xml b/sandbox/sebastien/java/embed/modules/builder/pom.xml
new file mode 100644
index 0000000000..5ea1b8052b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/pom.xml
@@ -0,0 +1,65 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-builder</artifactId>
+ <name>Apache Tuscany SCA Model Builders</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
new file mode 100644
index 0000000000..4c5bca204b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
@@ -0,0 +1,355 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * Configuration of binding URIs.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindingURIBuilderImpl implements CompositeBuilder {
+
+ public BindingURIBuilderImpl(ExtensionPointRegistry registry) {
+ }
+
+ /**
+ * Called by CompositeBindingURIBuilderImpl
+ *
+ * @param composite the composite to be configured
+ */
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ configureBindingURIs(composite, null, context.getDefinitions(), context.getBindingBaseURIs(), context.getMonitor());
+ return composite;
+ }
+
+
+ /**
+ * Fully resolve the binding URIs based on available information. This includes information
+ * from the ".composite" files, from resources associated with the binding, e.g. WSDL files,
+ * from any associated policies and from the default information for each binding type.
+ *
+ * NOTE: This method repeats some of the processing performed by the configureComponents()
+ * method above. The duplication is needed because NodeConfigurationServiceImpl
+ * calls this method without previously calling configureComponents(). In the
+ * normal builder sequence used by CompositeBuilderImpl, both of these methods
+ * are called.
+ *
+ * TODO: Share the URL calculation algorithm with the configureComponents() method above
+ * although keeping the configureComponents() methods signature as is because when
+ * a composite is actually build in a node the node default information is currently
+ * available
+ *
+ * @param composite the composite to be configured
+ * @param uri the path to the composite provided through any nested composite component implementations
+ * @param defaultBindings list of default binding configurations
+ */
+ private void configureBindingURIs(Composite composite,
+ String uri,
+ Definitions definitions,
+ Map<QName, List<String>> defaultBindings,
+ Monitor monitor) throws CompositeBuilderException {
+
+ String parentComponentURI = uri;
+
+ monitor.pushContext("Composite: " + composite.getName().toString());
+ try {
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ // Process nested composite
+ configureBindingURIs((Composite)implementation, component.getURI(), definitions, defaultBindings, monitor);
+ }
+ }
+
+ // Initialize composite service binding URIs
+ List<Service> compositeServices = composite.getServices();
+ for (Service service : compositeServices) {
+
+ // Initialize binding names and URIs
+ for (Binding binding : service.getBindings()) {
+ constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor);
+ }
+ }
+
+ // Initialize component service binding URIs
+ for (Component component : composite.getComponents()) {
+
+ monitor.pushContext("Component: " + component.getName());
+ try {
+ for (ComponentService service : component.getServices()) {
+
+ // Initialize binding names and URIs
+ for (Binding binding : service.getBindings()) {
+ constructBindingURI(component, service, binding, defaultBindings, monitor);
+ }
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ /**
+ * URI construction for composite bindings based on Assembly Specification section 1.7.2, This method
+ * assumes that the component URI part of the binding URI is formed from the part to the
+ * composite in question and just calls the generic constructBindingURI method with this
+ * information
+ *
+ * @param parentComponentURI
+ * @param composite
+ * @param service
+ * @param binding
+ * @param defaultBindings
+ */
+ private void constructBindingURI(String parentComponentURI,
+ Composite composite,
+ Service service,
+ Binding binding,
+ Map<QName, List<String>> defaultBindings,
+ Monitor monitor) throws CompositeBuilderException {
+ // This is a composite service so there is no component to provide a component URI
+ // The path to this composite (through nested composites) is used.
+ constructBindingURI(parentComponentURI, service, binding, defaultBindings, monitor);
+ }
+
+ /**
+ * URI construction for component bindings based on Assembly Specification section 1.7.2. This method
+ * calculates the component URI part based on component information before calling the generic
+ * constructBindingURI method
+ *
+ * @param component the component that holds the service
+ * @param service the service that holds the binding
+ * @param binding the binding for which the URI is being constructed
+ * @param defaultBindings the list of default binding configurations
+ */
+ private void constructBindingURI(Component component,
+ Service service,
+ Binding binding,
+ Map<QName, List<String>> defaultBindings,
+ Monitor monitor) throws CompositeBuilderException {
+ constructBindingURI(component.getURI(), service, binding, defaultBindings, monitor);
+ }
+
+ /**
+ * Generic URI construction for bindings based on Assembly Specification section 1.7.2
+ *
+ * @param componentURIString the string version of the URI part that comes from the component name
+ * @param service the service in question
+ * @param binding the binding for which the URI is being constructed
+ * @param includeBindingName when set true the serviceBindingURI part should be used
+ * @param defaultBindings the list of default binding configurations
+ * @throws CompositeBuilderException
+ */
+ private void constructBindingURI(String componentURIString,
+ Service service,
+ Binding binding,
+ Map<QName, List<String>> defaultBindings,
+ Monitor monitor) throws CompositeBuilderException {
+
+ try {
+
+ boolean includeBindingName = !service.getName().equals(binding.getName());
+
+ // calculate the service binding URI
+ URI bindingURI = binding.getURI() == null ? null : new URI(binding.getURI());
+ if (binding instanceof SCABinding) {
+ // Per assembly spec, the @uri for service side binding.sca should be ignored
+ bindingURI = null;
+ }
+
+ // if the user has provided an absolute binding URI then use it
+ if (bindingURI != null && bindingURI.isAbsolute()) {
+ return;
+ }
+
+ String serviceName = service.getName();
+ // Get the service binding name
+ String bindingName;
+ if (binding.getName() != null) {
+ bindingName = binding.getName();
+ } else {
+ bindingName = serviceName;
+ }
+
+ // calculate the component URI
+ URI componentURI = null;
+ if (componentURIString != null) {
+ componentURI = new URI(addSlashToPath(componentURIString));
+ }
+
+ // calculate the base URI
+ URI baseURI = null;
+ if (!(binding instanceof SCABinding)) {
+ if (defaultBindings != null) {
+ List<String> uris = defaultBindings.get(binding.getType());
+ if (uris != null && uris.size() > 0) {
+ baseURI = new URI(addSlashToPath(uris.get(0)));
+ }
+ }
+ }
+
+ binding.setURI(constructBindingURI(baseURI,
+ componentURI,
+ bindingURI,
+ serviceName,
+ includeBindingName,
+ bindingName));
+ } catch (URISyntaxException ex) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "URLSyntaxException",
+ componentURIString,
+ service.getName(),
+ binding.getName());
+ }
+ }
+
+ /**
+ * Use to ensure that URI paths end in "/" as here we want to maintain the
+ * last path element of an base URI when other URI are resolved against it. This is
+ * not the default behaviour of URI resolution as defined in RFC 2369
+ *
+ * @param path the path string to which the "/" is to be added
+ * @return the resulting path with a "/" added if it not already there
+ */
+ private static String addSlashToPath(String path) {
+ if (path.endsWith("/") || path.endsWith("#")) {
+ return path;
+ } else {
+ return path + "/";
+ }
+ }
+
+ /**
+ * Concatenate binding URI parts together based on Assembly Specification section 1.7.2
+ *
+ * @param baseURI the base of the binding URI
+ * @param componentURI the middle part of the binding URI derived from the component name
+ * @param bindingURI the end part of the binding URI
+ * @param includeBindingName when set true the binding name part should be used
+ * @param bindingName the binding name
+ * @return the resulting URI as a string
+ */
+ private static String constructBindingURI(URI baseURI,
+ URI componentURI,
+ URI bindingURI,
+ String serviceName,
+ boolean includeBindingName,
+ String bindingName) {
+ String name = includeBindingName ? serviceName + "/" + bindingName : serviceName;
+ String uriString;
+
+ if (baseURI == null) {
+ if (componentURI == null) {
+ if (bindingURI != null) {
+ uriString = name + "/" + bindingURI.toString();
+ } else {
+ uriString = name;
+ }
+ } else {
+ if (bindingURI != null) {
+ if (bindingURI.toString().startsWith("/")) {
+ uriString = componentURI.resolve(bindingURI).toString();
+ } else {
+ uriString = componentURI.resolve(name + "/" + bindingURI).toString();
+ }
+ } else {
+ uriString = componentURI.resolve(name).toString();
+ }
+ }
+ } else {
+ if (componentURI == null) {
+ if (bindingURI != null) {
+ uriString = basedURI(baseURI, bindingURI).toString();
+ } else {
+ uriString = basedURI(baseURI, URI.create(name)).toString();
+ }
+ } else {
+ if (bindingURI != null) {
+ uriString = basedURI(baseURI, componentURI.resolve(bindingURI)).toString();
+ } else {
+ uriString = basedURI(baseURI, componentURI.resolve(name)).toString();
+ }
+ }
+ }
+
+ // tidy up by removing any trailing "/"
+ if (uriString.endsWith("/")) {
+ uriString = uriString.substring(0, uriString.length() - 1);
+ }
+
+ URI uri = URI.create(uriString);
+ if (!uri.isAbsolute()) {
+ uri = URI.create("/").resolve(uri);
+ }
+ return uri.toString();
+ }
+
+ /**
+ * Combine a URI with a base URI.
+ *
+ * @param baseURI
+ * @param uri
+ * @return
+ */
+ private static URI basedURI(URI baseURI, URI uri) {
+ if (uri.getScheme() != null) {
+ return uri;
+ }
+ String str = uri.toString();
+ if (str.startsWith("/")) {
+ str = str.substring(1);
+ }
+ return URI.create(baseURI.toString() + str).normalize();
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.BindingURIBuilder";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
new file mode 100644
index 0000000000..ebc05c68f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
@@ -0,0 +1,1695 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.assembly.xsd.Constants;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ComponentBuilderImpl {
+ protected static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ protected static final String BINDING_SCA = "binding.sca";
+ protected static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA);
+
+ private CompositeComponentTypeBuilderImpl componentTypeBuilder;
+ protected ComponentPolicyBuilderImpl policyBuilder;
+ private AssemblyFactory assemblyFactory;
+ private SCABindingFactory scaBindingFactory;
+ private DocumentBuilderFactory documentBuilderFactory;
+ protected TransformerFactory transformerFactory;
+ private InterfaceContractMapper interfaceContractMapper;
+ private BuilderExtensionPoint builders;
+ private Mediator mediator;
+ private ContractBuilder contractBuilder;
+
+ public ComponentBuilderImpl(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
+ documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+ transformerFactory = modelFactories.getFactory(TransformerFactory.class);
+
+ interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ policyBuilder = new ComponentPolicyBuilderImpl(registry);
+ builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ mediator = new MediatorImpl(registry);
+ contractBuilder = builders.getContractBuilder();
+ }
+
+ public void setComponentTypeBuilder(CompositeComponentTypeBuilderImpl componentTypeBuilder) {
+ this.componentTypeBuilder = componentTypeBuilder;
+ }
+
+ /**
+ * Configure the component based on its component type using OASIS rules
+ *
+ * @Param outerCompoment the component that uses the parentComposite as its implementation
+ * @Param parentComposite the composite that contains the component being configured. Required for property processing
+ * @param component the component to be configured
+ */
+ public void configureComponentFromComponentType(Component outerComponent, Composite parentComposite, Component component, BuilderContext context) {
+
+ Monitor monitor = context.getMonitor();
+ monitor.pushContext("Component: " + component.getName().toString());
+
+ try {
+ // do any work we need to do before we calculate the component type
+ // for this component. Anything that needs to be pushed down the promotion
+ // hierarchy must be done before we calculate the component type
+
+ // check that the implementation is present
+ if (!isComponentImplementationPresent(component, monitor)){
+ return;
+ }
+
+ // carry out any implementation specific builder processing
+ Implementation impl = component.getImplementation();
+ if (impl != null) {
+ ImplementationBuilder builder = builders.getImplementationBuilder(impl.getType());
+ if (builder != null) {
+ builder.build(component, impl, context);
+ }
+ }
+
+ // Properties on the composite component type are not affected by the components
+ // that the composite contains. Instead the child components might source
+ // composite level property values. Hence we have to calculate whether the component
+ // type property value should be overridden by this component's property value
+ // before we go ahead and calculate the component type
+ configureProperties(outerComponent, parentComposite, component, monitor);
+
+ // create the component type for this component
+ // taking any nested composites into account
+ createComponentType(component, context);
+
+ // configure services based on the calculated component type
+ configureServices(component, context);
+
+ // configure services based on the calculated component type
+ configureReferences(component, context);
+
+ // NOTE: configureServices/configureReferences may add callback references and services
+ policyBuilder.configure(component, context);
+
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ /**
+ * Checks that a component implementation is present and resolved
+ * before doing anything else
+ *
+ * @param component
+ * @return true if the implementation is present and resolved
+ */
+ private boolean isComponentImplementationPresent(Component component, Monitor monitor){
+ Implementation implementation = component.getImplementation();
+ if (implementation == null) {
+ // A component must have an implementation
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "NoComponentImplementation",
+ component.getName());
+ return false;
+ } else if (implementation.isUnresolved()) {
+ // The implementation must be fully resolved
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "UnresolvedComponentImplementation",
+ component,
+ component.getName(),
+ implementation.getURI());
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Use the component type builder to build the component type for
+ * this component.
+ *
+ * @param component
+ */
+ private void createComponentType(Component component, BuilderContext context) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ componentTypeBuilder.createComponentType(component, (Composite)implementation, context);
+ }
+ }
+
+ /**
+ * Configure this component's services based on the services in its
+ * component type and the configuration from the composite file
+ *
+ * @param component
+ */
+ private void configureServices(Component component, BuilderContext context) {
+ Monitor monitor = context.getMonitor();
+
+ // If the component type has services that are not described in this
+ // component then create services for this component
+ addServicesFromComponentType(component, monitor);
+
+ // Connect this component's services to the
+ // services from its component type
+ connectServicesToComponentType(component, monitor);
+
+ // look at each component service in turn and calculate its
+ // configuration based on OASIS rules
+ for (ComponentService componentService : component.getServices()) {
+
+ Service componentTypeService = componentService.getService();
+
+ if (componentTypeService == null) {
+ // raise error?
+ // can be null in some of the assembly-xml unit tests
+ continue;
+ }
+
+ // interface contracts
+ calculateServiceInterfaceContract(component, componentService, componentTypeService, monitor);
+
+ // bindings
+ calculateBindings(component, componentService, componentTypeService, context);
+
+ // add callback reference model objects
+ createCallbackReference(component, componentService, monitor);
+ }
+ }
+
+ /**
+ * Configure this component's references based on the references in its
+ * component type and the configuration from the composite file
+ *
+ * @param component
+ */
+ private void configureReferences(Component component, BuilderContext context) {
+ Monitor monitor = context.getMonitor();
+
+ // If the component type has references that are not described in this
+ // component then create references for this component
+ addReferencesFromComponentType(component, monitor);
+
+ // Connect this component's references to the
+ // references from its component type
+ connectReferencesToComponentType(component, monitor);
+
+ // look at each component reference in turn and calculate its
+ // configuration based on OASIS rules
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference componentTypeReference = componentReference.getReference();
+
+ if (componentTypeReference == null) {
+ // raise error?
+ // can be null in some of the assembly-xml unit tests
+ continue;
+ }
+
+ // reference multiplicity
+ reconcileReferenceMultiplicity(component, componentReference, componentTypeReference, monitor);
+
+ // interface contracts
+ calculateReferenceInterfaceContract(component, componentReference, componentTypeReference, monitor);
+
+ // bindings
+ calculateBindings(componentReference, componentTypeReference);
+
+ // add callback service model objects
+ createCallbackService(component, componentReference, monitor);
+
+ // Propagate autowire setting from the component down the structural
+ // hierarchy
+ if (componentReference.getAutowire() == null) {
+ componentReference.setAutowire(component.getAutowire());
+ }
+ }
+ }
+
+ /**
+ * Configure this component's properties based on the properties in its
+ * component type and the configuration from the composite file
+ *
+ * @param component
+ */
+ private void configureProperties(Component outerComponent, Composite parentComposite, Component component, Monitor monitor) {
+ // If the component type has properties that are not described in this
+ // component then create properties for this component
+ addPropertiesFromComponentType(component, monitor);
+
+ // Connect this component's properties to the
+ // properties from its component type
+ connectPropertiesToComponentType(component, monitor);
+
+ // Reconcile component properties and their component type properties
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ reconcileComponentPropertyWithComponentType(component, componentProperty, monitor);
+
+ // configure the property value based on the @source attribute
+ // At the moment this is done in the parent composite component
+ // type calculation
+ processPropertySourceAttribute(outerComponent, parentComposite, component, componentProperty, monitor);
+
+ // configure the property value based on the @file attribute
+ processPropertyFileAttribute(component, componentProperty, monitor);
+
+ // Check that a value is supplied
+ if (componentProperty.isMustSupply() && !isPropertyValueSet(componentProperty)) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyMustSupplyNull",
+ component.getName(),
+ componentProperty.getName());
+ }
+
+ // check that not too many values are supplied
+ if (!componentProperty.isMany() && isPropertyManyValued(componentProperty)){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyHasManyValues",
+ component.getName(),
+ componentProperty.getName());
+ }
+
+ // check the property type
+ checkComponentPropertyType(component, componentProperty, monitor);
+
+ }
+ }
+
+ private void addServicesFromComponentType(Component component, Monitor monitor) {
+
+ // Create a component service for each service
+ if (component.getImplementation() != null) {
+ for (Service service : component.getImplementation().getServices()) {
+ // check for duplicate service names in implementation
+ if (service != component.getImplementation().getService(service.getName())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "DuplicateImplementationServiceName",
+ component.getName(),
+ service.getName());
+ }
+
+ ComponentService componentService = (ComponentService)component.getService(service.getName());
+
+ // if the component doesn't have a service with the same name as the
+ // component type service then create one
+ if (componentService == null) {
+ componentService = assemblyFactory.createComponentService();
+ componentService.setForCallback(service.isForCallback());
+ String name = service.getName();
+ componentService.setName(name);
+ component.getServices().add(componentService);
+ }
+ }
+ }
+ }
+
+ private void addReferencesFromComponentType(Component component, Monitor monitor) {
+
+ // Create a component reference for each reference
+ if (component.getImplementation() != null) {
+ for (Reference reference : component.getImplementation().getReferences()) {
+ // check for duplicate reference names in implementation
+ if (reference != component.getImplementation().getReference(reference.getName())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "DuplicateImplementationReferenceName",
+ component.getName(),
+ reference.getName());
+ }
+
+ ComponentReference componentReference = (ComponentReference)component.getReference(reference.getName());
+
+ // if the component doesn't have a reference with the same name as the
+ // component type reference then create one
+ if (componentReference == null) {
+ componentReference = assemblyFactory.createComponentReference();
+ componentReference.setForCallback(reference.isForCallback());
+ componentReference.setName(reference.getName());
+ componentReference.setReference(reference);
+ component.getReferences().add(componentReference);
+ }
+ }
+ }
+ }
+
+ private void addPropertiesFromComponentType(Component component, Monitor monitor) {
+
+ // Create component property for each property
+ if (component.getImplementation() != null) {
+ for (Property property : component.getImplementation().getProperties()) {
+ // check for duplicate property names in implementation
+ if (property != component.getImplementation().getProperty(property.getName())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "DuplicateImplementationPropertyName",
+ component.getName(),
+ property.getName());
+ }
+ ComponentProperty componentProperty = (ComponentProperty)component.getProperty(property.getName());
+
+ // if the component doesn't have a property with the same name as
+ // the component type property then create one
+ if (componentProperty == null) {
+ componentProperty = assemblyFactory.createComponentProperty();
+ componentProperty.setName(property.getName());
+ componentProperty.setValue(property.getValue());
+ componentProperty.setMany(property.isMany());
+ componentProperty.setMustSupply(property.isMustSupply());
+ componentProperty.setXSDElement(property.getXSDElement());
+ componentProperty.setXSDType(property.getXSDType());
+ componentProperty.setProperty(property);
+ component.getProperties().add(componentProperty);
+ }
+ }
+ }
+ }
+
+ private void connectServicesToComponentType(Component component, Monitor monitor) {
+
+ // Connect each component service to the corresponding component type service
+ for (ComponentService componentService : component.getServices()) {
+ // check for duplicate service names in component
+ if (componentService != component.getService(componentService.getName())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "DuplicateComponentServiceName",
+ component.getName(),
+ componentService.getName());
+ }
+
+ if (componentService.getService() != null || componentService.isForCallback()) {
+ continue;
+ }
+
+ if (component.getImplementation() == null) {
+ // is null in some of our basic unit tests
+ continue;
+ }
+
+ Service service = component.getImplementation().getService(componentService.getName());
+
+ if (service != null) {
+ componentService.setService(service);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ServiceNotFoundForComponentService",
+ component.getName(),
+ componentService.getName());
+ }
+ }
+ }
+
+ private void connectReferencesToComponentType(Component component, Monitor monitor) {
+
+ // Connect each component reference to the corresponding component type reference
+ for (ComponentReference componentReference : component.getReferences()) {
+ // check for duplicate reference names in component
+ if (componentReference != component.getReference(componentReference.getName())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "DuplicateComponentReferenceName",
+ component.getName(),
+ componentReference.getName());
+ }
+
+ if (componentReference.getReference() != null || componentReference.isForCallback()) {
+ continue;
+ }
+
+ if (component.getImplementation() == null) {
+ // is null in some of our basic unit tests
+ continue;
+ }
+
+ Reference reference = component.getImplementation().getReference(componentReference.getName());
+
+ if (reference != null) {
+ componentReference.setReference(reference);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceNotFoundForComponentReference",
+ component.getName(),
+ componentReference.getName());
+ }
+ }
+ }
+
+ private void connectPropertiesToComponentType(Component component, Monitor monitor) {
+ // Connect each component property to the corresponding component type property
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ // check for duplicate property names in component
+ if (componentProperty != component.getProperty(componentProperty.getName())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "DuplicateComponentPropertyName",
+ component.getName(),
+ componentProperty.getName());
+ }
+
+ Property property = component.getImplementation().getProperty(componentProperty.getName());
+
+ if (property != null) {
+ componentProperty.setProperty(property);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyNotFound",
+ component.getName(),
+ componentProperty.getName());
+ }
+ }
+ }
+
+ private void reconcileReferenceMultiplicity(Component component,
+ Reference componentReference,
+ Reference componentTypeReference,
+ Monitor monitor) {
+ if (componentReference.getMultiplicity() != null) {
+ if (!isValidMultiplicityOverride(componentTypeReference.getMultiplicity(), componentReference
+ .getMultiplicity())) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceIncompatibleMultiplicity",
+ component.getName(),
+ componentReference.getName());
+ }
+ } else {
+ componentReference.setMultiplicity(componentTypeReference.getMultiplicity());
+ }
+ }
+
+ private void reconcileComponentPropertyWithComponentType(Component component, ComponentProperty componentProperty, Monitor monitor) {
+ Property componentTypeProperty = componentProperty.getProperty();
+ if (componentTypeProperty != null) {
+
+ // Check that a component property does not override the
+ // mustSupply attribute
+ if (!componentTypeProperty.isMustSupply() && componentProperty.isMustSupply()) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyMustSupplyIncompatible",
+ component.getName(),
+ componentProperty.getName());
+ }
+
+ // Default to the mustSupply attribute specified on the property
+ if (!componentProperty.isMustSupply())
+ componentProperty.setMustSupply(componentTypeProperty.isMustSupply());
+
+ // Default to the value specified on the component type property
+ if (!isPropertyValueSet(componentProperty)) {
+ componentProperty.setValue(componentTypeProperty.getValue());
+ }
+
+ // Override the property value for the composite
+ if (component.getImplementation() instanceof Composite) {
+ componentTypeProperty.setValue(componentProperty.getValue());
+ }
+
+ // Check that a component property does not override the
+ // many attribute
+ if (!componentTypeProperty.isMany() && componentProperty.isMany()) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyOverrideManyAttribute",
+ component.getName(),
+ componentProperty.getName());
+ }
+
+ // Default to the many attribute defined on the property
+ componentProperty.setMany(componentTypeProperty.isMany());
+
+ // Default to the type and element defined on the property
+ if (componentProperty.getXSDType() == null) {
+ componentProperty.setXSDType(componentTypeProperty.getXSDType());
+ }
+ if (componentProperty.getXSDElement() == null) {
+ componentProperty.setXSDElement(componentTypeProperty.getXSDElement());
+ }
+
+ // Check that a type or element are specified
+ if (componentProperty.getXSDElement() == null && componentProperty.getXSDType() == null) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "NoTypeForComponentProperty",
+ component.getName(),
+ componentProperty.getName());
+ }
+
+ // check that the types specified in the component type and component property match
+ if ( componentProperty.getXSDElement() != null &&
+ !componentProperty.getXSDElement().equals(componentTypeProperty.getXSDElement())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertXSDElementsDontMatch",
+ component.getName(),
+ componentProperty.getName(),
+ componentProperty.getXSDElement(),
+ componentTypeProperty.getXSDElement());
+ }
+
+ if ( componentProperty.getXSDType() != null &&
+ !componentProperty.getXSDType().equals(componentTypeProperty.getXSDType())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertXSDTypesDontMatch",
+ component.getName(),
+ componentProperty.getName(),
+ componentProperty.getXSDType(),
+ componentTypeProperty.getXSDType());
+ }
+ }
+ }
+
+ /**
+ * checks that the component property value is correctly typed when compared with
+ * the type specified in the composite file property
+ *
+ * TODO - Don't yet handle multiplicity
+ * Need to check composite properties also
+ *
+ * @param component
+ * @param componentProperty
+ * @param monitor
+ */
+ private void checkComponentPropertyType(Component component, ComponentProperty componentProperty, Monitor monitor) {
+
+ QName propertyXSDType = componentProperty.getXSDType();
+ QName propertyElementType = componentProperty.getXSDElement();
+
+ if (propertyXSDType != null){
+ if (propertyXSDType.getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema")) {
+ // The property has a simple schema type so we can use the
+ // data binding framework to see if the XML value can be transformed
+ // into a simple Java value
+ Document doc = (Document)componentProperty.getValue();
+ Node source = (doc == null) ? null : doc.getDocumentElement().getFirstChild();
+ DataType<XMLType> sourceDataType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME,
+ Node.class,
+ new XMLType(null, componentProperty.getXSDType()));
+ DataType<XMLType> targetDataType = new DataTypeImpl<XMLType>(JAXBDataBinding.NAME,
+ Object.class,
+ new XMLType(null, componentProperty.getXSDType()));
+ try {
+ mediator.mediate(source, sourceDataType, targetDataType, null);
+ } catch (Exception ex){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyValueDoesNotMatchSimpleType",
+ componentProperty.getName(),
+ component.getName(),
+ componentProperty.getXSDType().toString());
+ }
+ } else {
+ // The property has a complex schema type so we fluff up a schema
+ // and use that to validate the property value
+ XSDefinition xsdDefinition = (XSDefinition)componentProperty.getXSDDefinition();
+
+ if (xsdDefinition != null) {
+ try {
+ // create schema factory for XML schema
+ SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+ Document schemaDom = xsdDefinition.getSchema().getSchemaDocument();
+
+ String valueSchema = null;
+ Schema schema = null;
+
+ if (componentProperty.getXSDType().getNamespaceURI().equals(Constants.SCA11_NS)){
+ // include the referenced schema as it's already in the OASIS namespace
+ valueSchema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " +
+ "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" "+
+ "xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" "+
+ "xmlns:__tmp=\"" + componentProperty.getXSDType().getNamespaceURI() + "\" "+
+ "targetNamespace=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
+ "elementFormDefault=\"qualified\">" +
+ "<include schemaLocation=\"" + xsdDefinition.getLocation() + "\"/>" +
+// "<element name=\"value\" type=\"" + "__tmp:" + componentProperty.getXSDType().getLocalPart() + "\"/>" +
+ "</schema>";
+// Source sources[] = {new StreamSource(new StringReader(valueSchema))};
+ Source sources[] = {new DOMSource(schemaDom)};
+ schema = factory.newSchema(sources);
+
+ // The SCA schema already contains a "value" element so I can't create this schema
+ // the SCA value element is an any so return assuming that it validates.
+ return;
+ } else {
+ // import the referenced schema
+ valueSchema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " +
+ "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" "+
+ "xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" "+
+ "xmlns:__tmp=\"" + componentProperty.getXSDType().getNamespaceURI() + "\" "+
+ "targetNamespace=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
+ "elementFormDefault=\"qualified\">" +
+ "<import namespace=\"" + componentProperty.getXSDType().getNamespaceURI() + "\"/>" +
+ "<element name=\"value\" type=\"" + "__tmp:" + componentProperty.getXSDType().getLocalPart() + "\"/>" +
+ "</schema>";
+ Source sources[] = {new DOMSource(schemaDom), new StreamSource(new StringReader(valueSchema))};
+ schema = factory.newSchema(sources);
+ }
+
+ // get the value child of the property element
+ Document property = (Document)componentProperty.getValue();
+ Element value = (Element)property.getDocumentElement().getFirstChild();
+
+ // validate the element property/value from the DOM
+ Validator validator = schema.newValidator();
+ validator.validate(new DOMSource(value));
+
+ } catch (Exception e) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyValueDoesNotMatchComplexType",
+ componentProperty.getName(),
+ component.getName(),
+ componentProperty.getXSDType().toString(),
+ e.getMessage());
+ }
+ }
+ }
+ } else if (propertyElementType != null) {
+ // TODO - TUSCANY-3530 - still need to add validation for element type
+
+ }
+ }
+
+ /**
+ * If the property has a source attribute use this to retrieve the value from a
+ * property in the parent composite
+ *
+ * @param parentCompoent the composite that contains the component
+ * @param component
+ * @param componentProperty
+ */
+ private void processPropertySourceAttribute(Component outerComponent,
+ Composite parentComposite,
+ Component component,
+ ComponentProperty componentProperty,
+ Monitor monitor) {
+ String source = componentProperty.getSource();
+
+ if (source == null) return;
+
+ try {
+ String sourceName = extractSourcePropertyName( source );
+
+ Property sourceProp = null;
+ if (outerComponent != null) {
+ sourceProp = outerComponent.getProperty(sourceName);
+ } else {
+ sourceProp = parentComposite.getProperty(sourceName);
+ }
+ if (sourceProp == null) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertySourceNotFound",
+ source,
+ componentProperty.getName(),
+ component.getName());
+ } else {
+
+ Document sourcePropValue = (Document)sourceProp.getValue();
+
+ try {
+ // FIXME: How to deal with namespaces?
+ Document node =
+ evaluateXPath2(sourcePropValue,
+ componentProperty.getSourceXPathExpression(),
+ documentBuilderFactory);
+
+ if (node != null) {
+ componentProperty.setValue(node);
+ } else {
+ Monitor.warning(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyXpathExpressionReturnedNull",
+ component.getName(),
+ componentProperty.getName(),
+ componentProperty.getSource());
+ } // end if
+
+ } catch (Exception ex) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertySourceXpathInvalid",
+ source,
+ componentProperty.getName(),
+ component.getName(),
+ ex);
+ } // end try
+ } // end if
+ } catch (IllegalArgumentException e ) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertySourceValueInvalid",
+ source,
+ componentProperty.getName(),
+ component.getName());
+ } // end try
+ } // end method
+
+ /**
+ * Extracts the name of the source property from the value of an @source attribute string
+ * @param source - the value of the @source attribute
+ * @return - the source property name as a String
+ */
+ private String extractSourcePropertyName( String source ) throws IllegalArgumentException {
+ String propertyName = null;
+
+ // Possible values for the source string:
+ // a) $name
+ // b) $name/expression
+ // c) $name[xx]
+ // d) $name[xx]/expression
+ // ...and note that the expression MAY contain '/' and '[' characters
+ if( source.charAt(0) != '$' ) throw new IllegalArgumentException("Source value does not start with '$'");
+
+ int index = source.indexOf('/');
+ int bracket = source.indexOf('[');
+
+ if( index == -1 && bracket == -1 ) {
+ // Format a) - simply remove the '$'
+ propertyName = source.substring(1);
+ } else if ( bracket == -1 ) {
+ // Format b) - remove the '$' and the '/' and everything following it
+ propertyName = source.substring(1, index);
+ } else if ( index == -1 ) {
+ // Format c) - remove the '$' and the '[' and everything following it
+ propertyName = source.substring(1, bracket);
+ } else {
+ // Format d) - but need to ensure that the '[' is BEFORE the '/'
+ if( bracket < index ) {
+ // Format d) - remove the '$' and the '[' and everything following it
+ propertyName = source.substring(1, bracket);
+ } else {
+ // Format b) variant where there is a '[' in the expression...
+ propertyName = source.substring(1, index);
+ } // end if
+ } // end if
+
+ return propertyName;
+ } // end method extractSourcePropertyName( source, monitor )
+
+ /**
+ * If the property has a file attribute use this to retrieve the property value from a local file
+ * Format of the property value file is defined in the SCA Assembly specification in ASM50046
+ *
+ * @param component the component holding the property
+ * @param componentProperty - the property
+ * @param monitor - a Monitor object for reporting problems
+ */
+ /**
+ * Property file format:
+ * MUST contain a <sca:values/> element
+ * - either contains one or more <sca:value/> subelements (mandatory for property with a simple XML type)
+ * - or contains one or more global elements of the type of the property
+ *
+ * eg.
+ * <?xml version="1.0" encoding="UTF-8"?>
+ * <values>
+ * <value>MyValue</value>
+ * </values>
+ *
+ * <?xml version="1.0" encoding="UTF-8"?>
+ * <values>
+ * <foo:fooElement>
+ * <foo:a>AValue</foo:a>
+ * <foo:b>InterestingURI</foo:b>
+ * </foo:fooElement>
+ * </values/>
+ */
+ private void processPropertyFileAttribute(Component component, ComponentProperty componentProperty, Monitor monitor) {
+ String file = componentProperty.getFile();
+ if (file == null) return;
+ try {
+/*
+ URI uri = URI.create(file);
+ // URI resolution for relative URIs is done when the composite is resolved.
+ URL url = uri.toURL();
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ InputStream is = null;
+ try {
+
+ is = connection.getInputStream();
+
+ Source streamSource = new SAXSource(new InputSource(is));
+ DOMResult result = new DOMResult();
+ javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
+ transformer.transform(streamSource, result);
+
+ Document document = (Document)result.getNode();
+*/
+ Document document = readPropertyFileData( file );
+
+ Element docElement = document.getDocumentElement();
+ if( docElement == null ) throw new Exception("Property File has no XML document element");
+
+ if( !"values".equals( docElement.getLocalName() ) ) {
+ throw new Exception("Property File does not start with <values/> element");
+ } // end if
+
+ // The property value is the subelement(s) of the <values/> element
+ NodeList values = docElement.getChildNodes();
+
+ Document newdoc = documentBuilderFactory.newDocumentBuilder().newDocument();
+ Element newProperty = newdoc.createElementNS(SCA11_NS, "property");
+ newdoc.appendChild( newProperty );
+
+ int count = 0;
+
+ // Copy the property values under the new <property/> element
+ for( int i = 0 ; i < values.getLength() ; i++ ) {
+ Node valueNode = values.item(i);
+ // Only <value/> elements or global elements are valid values...
+ if( valueNode.getNodeType() == Node.ELEMENT_NODE ) {
+ newProperty.appendChild(newdoc.importNode(values.item(i), true));
+ count++;
+ } // end if
+ } // end for
+
+ if( count == 0 ) {
+ throw new Exception("Property File has no property values");
+ } // end if
+
+ componentProperty.setValue(newdoc);
+
+/*
+ // TUSCANY-2377, Add a fake value element so it's consistent with
+ // the DOM tree loaded from inside SCDL
+ if (!document.getDocumentElement().getLocalName().equals("value")){
+ Element root = document.createElementNS(null, "value");
+ root.appendChild(document.getDocumentElement());
+
+ // remove all the child nodes as they will be replaced by the "value" node
+ NodeList children = document.getChildNodes();
+ for (int i=0; i < children.getLength(); i++){
+ document.removeChild(children.item(i));
+ }
+
+ // add the value node back in
+ document.appendChild(root);
+ }
+ componentProperty.setValue(document);
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ } // end try
+*/
+ } catch (Exception ex) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyFileValueInvalid",
+ file,
+ componentProperty.getName(),
+ component.getName(),
+ ex);
+ } // end try
+ } // end method processPropertyFileAttribute
+
+ private Document readPropertyFileData( String file ) throws Exception {
+ Document doc = null;
+
+ URI uri = URI.create(file);
+ // URI resolution for relative URIs is done when the composite is resolved.
+ URL url = uri.toURL();
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ InputStream is = null;
+ try {
+ is = connection.getInputStream();
+
+ Source streamSource = new SAXSource(new InputSource(is));
+ DOMResult result = new DOMResult();
+ javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
+ transformer.transform(streamSource, result);
+
+ doc = (Document)result.getNode();
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ } // end try
+
+ return doc;
+ } // end method readPropertyFileData
+
+ /**
+ * Evaluate an XPath expression against a Property value, returning the result as a Property value
+ * @param node - the document root element of a Property value
+ * @param expression - the XPath expression
+ * @param documentBuilderFactory - a DOM document builder factory
+ * @return - a DOM Document representing the result of the evaluation as a Property value
+ * @throws XPathExpressionException
+ * @throws ParserConfigurationException
+ */
+ private Document evaluateXPath(Document node,
+ XPathExpression expression,
+ DocumentBuilderFactory documentBuilderFactory) throws XPathExpressionException,
+ ParserConfigurationException {
+
+ // The document element is a <sca:property/> element
+ Node property = node.getDocumentElement();
+ // The first child of the <property/> element is a <value/> element
+ Node value = property.getFirstChild();
+
+ Node result = (Node)expression.evaluate(value, XPathConstants.NODE);
+ if (result == null) {
+ return null;
+ }
+
+ if (result instanceof Document) {
+ return (Document)result;
+ } else {
+ Document document = documentBuilderFactory.newDocumentBuilder().newDocument();
+ Element newProperty = document.createElementNS(SCA11_NS, "property");
+
+ if (result.getNodeType() == Node.ELEMENT_NODE) {
+ // If the result is a <value/> element, use it directly in the result
+ newProperty.appendChild(document.importNode(result, true));
+ } else {
+ // If the result is not a <value/> element, create a <value/> element to contain the result
+ Element newValue = document.createElementNS(SCA11_NS, "value");
+ newValue.appendChild(document.importNode(result, true));
+ newProperty.appendChild(newValue);
+ } // end if
+ document.appendChild(newProperty);
+
+ return document;
+ }
+ }
+
+ /**
+ * Evaluate an XPath expression against a Property value, returning the result as a Property value
+ * - deals with multi-valued input property values and with multi-valued output property values
+ * @param node - the document root element of a Property value
+ * @param expression - the XPath expression
+ * @param documentBuilderFactory - a DOM document builder factory
+ * @return - a DOM Document representing the result of the evaluation as a Property value
+ * @throws XPathExpressionException
+ * @throws ParserConfigurationException
+ */
+ private Document evaluateXPath2(Document node,
+ XPathExpression expression,
+ DocumentBuilderFactory documentBuilderFactory) throws XPathExpressionException,
+ ParserConfigurationException {
+
+ // The document element is a <sca:property/> element
+ Element property = node.getDocumentElement();
+
+ NodeList result = (NodeList)expression.evaluate(property, XPathConstants.NODESET);
+ if (result == null || result.getLength() == 0) return null;
+
+ if (result instanceof Document) {
+ return (Document)result;
+ } else {
+ Document document = documentBuilderFactory.newDocumentBuilder().newDocument();
+ Element newProperty = document.createElementNS(SCA11_NS, "property");
+
+ for( int i = 0 ; i < result.getLength() ; i++ ) {
+ if (result.item(i).getNodeType() == Node.ELEMENT_NODE) {
+ // If the result is an element, use it directly in the result
+ newProperty.appendChild(document.importNode(result.item(i), true));
+ } else {
+ // If the result is not an element, create a <value/> element to contain the result
+ Element newValue = document.createElementNS(SCA11_NS, "value");
+ newValue.appendChild(document.importNode(result.item(i), true));
+ newProperty.appendChild(newValue);
+ } // end if
+ } // end for
+
+ document.appendChild(newProperty);
+
+ return document;
+ } // end if
+ } // end method
+
+ /**
+ * Create a callback reference for a component service
+ *
+ * @param component
+ * @param service
+ */
+ private void createCallbackReference(Component component, ComponentService service, Monitor monitor) {
+
+ // if the service has a callback interface create a reference
+ // to represent the callback
+ if (service.getInterfaceContract() != null && // can be null in unit tests
+ service.getInterfaceContract().getCallbackInterface() != null) {
+
+ ComponentReference callbackReference = assemblyFactory.createComponentReference();
+ callbackReference.setForCallback(true);
+ callbackReference.setName(service.getName());
+ // MJE: multiplicity = 0..n for these callback references
+ callbackReference.setMultiplicity(Multiplicity.ZERO_N);
+ try {
+ InterfaceContract contract = (InterfaceContract)service.getInterfaceContract().clone();
+ contract.setInterface(contract.getCallbackInterface());
+ contract.setCallbackInterface(null);
+ callbackReference.setInterfaceContract(contract);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ Service implService = service.getService();
+ if (implService != null) {
+
+ // If the implementation service is a CompositeService, ensure that the Reference that is
+ // created is a CompositeReference, otherwise create a Reference
+ Reference implReference;
+ if (implService instanceof CompositeService) {
+ CompositeReference implCompReference = assemblyFactory.createCompositeReference();
+ // Set the promoted component from the promoted component of the composite service
+ implCompReference.getPromotedComponents().add(((CompositeService)implService)
+ .getPromotedComponent());
+
+ // Get the promoted component reference corresponding to the service with the callback
+ // fist checking that the promoted service is resolved lest we get a NPE trying to
+ // retrieve the promoted component. It could be unresolved if the user gets the
+ // promotes string wrong
+ // TODO - is there any danger that the callback reference name will clash with other
+ // reference names. Old code used to qualify it with promoted component name
+ if (((CompositeService)implService).getPromotedService().isUnresolved() == false){
+ String referenceName = ((CompositeService)implService).getPromotedService().getName();
+ ComponentReference promotedReference = ((CompositeService)implService).getPromotedComponent().getReference(referenceName);
+
+ if (promotedReference != null){
+ implCompReference.getPromotedReferences().add(promotedReference);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PromotedCallbackReferenceNotFound",
+ component.getName(),
+ service.getName(),
+ ((CompositeService)implService).getPromotedComponent().getName(),
+ referenceName);
+ }
+ }
+ implReference = implCompReference;
+
+ // Add the composite reference to the composite implementation artifact
+ Implementation implementation = component.getImplementation();
+ if (implementation != null && implementation instanceof Composite) {
+ ((Composite)implementation).getReferences().add(implCompReference);
+ }
+ } else {
+ implReference = assemblyFactory.createReference();
+ }
+
+ implReference.setName(implService.getName());
+ // MJE: Fixup multiplicity as 0..n for callback references in the component type
+ implReference.setMultiplicity(Multiplicity.ZERO_N);
+ try {
+ InterfaceContract implContract = (InterfaceContract)implService.getInterfaceContract().clone();
+ implContract.setInterface(implContract.getCallbackInterface());
+ implContract.setCallbackInterface(null);
+ implReference.setInterfaceContract(implContract);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ callbackReference.setReference(implReference);
+ }
+ component.getReferences().add(callbackReference);
+
+ // Set the bindings of the callback reference
+ if (callbackReference.getBindings().isEmpty()) {
+ // If there are specific callback bindings set in the SCDL service
+ // callback element then use them
+ // at runtime a callback binding will be selected based on the forward call
+ if (service.getCallback() != null && service.getCallback().getBindings().size() > 0) {
+ callbackReference.getBindings().addAll(service.getCallback().getBindings());
+ } else {
+ // otherwise take a copy of all the bindings on the forward service
+ // at runtime a callback binding will be selected based on the forward call
+ List<Binding> serviceBindings = service.getBindings();
+ for ( Binding serviceBinding: serviceBindings ) {
+ try {
+ Binding referenceBinding = (Binding)serviceBinding.clone();
+ referenceBinding.setURI(null);
+ callbackReference.getBindings().add(referenceBinding);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ } // end try
+ } // end for
+
+ // if there are still no bindings for the callback create a default binding which
+ // will cause the EPR for this reference to be marked as EndpointReference.NOT_CONFIGURED
+ if( serviceBindings.size() == 0 ) {
+ createSCABinding(callbackReference, null);
+ } // end if
+ }
+ }
+ service.setCallbackReference(callbackReference);
+ }
+ }
+
+ /**
+ * Create a callback service for a component reference
+ *
+ * @param component
+ * @param service
+ */
+ private void createCallbackService(Component component, ComponentReference reference, Monitor monitor) {
+ if (reference.getInterfaceContract() != null && // can be null in unit tests
+ reference.getInterfaceContract().getCallbackInterface() != null) {
+ ComponentService callbackService = assemblyFactory.createComponentService();
+ callbackService.setForCallback(true);
+ callbackService.setName(reference.getName());
+ try {
+ InterfaceContract contract = (InterfaceContract)reference.getInterfaceContract().clone();
+ contract.setInterface(contract.getCallbackInterface());
+ contract.setCallbackInterface(null);
+ callbackService.setInterfaceContract(contract);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ Reference implReference = reference.getReference();
+ if (implReference != null) {
+ // If the implementation reference is a CompositeReference, ensure that the Service that is
+ // created is a CompositeService, otherwise create a Service
+ Service implService;
+ if (implReference instanceof CompositeReference) {
+ CompositeService implCompService = assemblyFactory.createCompositeService();
+ // TODO The reality here is that the composite reference which has the callback COULD promote more than
+ // one component reference - and there must be a separate composite callback service for each of these component
+ // references
+
+ // Set the promoted component from the promoted component of the composite reference
+ implCompService.setPromotedComponent(((CompositeReference)implReference).getPromotedComponents().get(0));
+ implCompService.setForCallback(true);
+
+ // Get the promoted component service corresponding to the reference with the callback
+ // fist checking that the promoted reference is resolved lest we get a NPE trying to
+ // retrieve the promoted component. It could be unresolved if the user gets the
+ // promotes string wrong
+ if (((CompositeReference)implReference).getPromotedReferences().get(0).isUnresolved() == false){
+ String serviceName = ((CompositeReference)implReference).getPromotedReferences().get(0).getName();
+ ComponentService promotedService = ((CompositeReference)implReference).getPromotedComponents().get(0).getService(serviceName);
+
+ if (promotedService != null){
+ implCompService.setPromotedService(promotedService);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PromotedCallbackServiceNotFound",
+ component.getName(),
+ reference.getName(),
+ ((CompositeReference)implReference).getPromotedComponents().get(0).getName(),
+ serviceName);
+ }
+ }
+
+ implService = implCompService;
+ // Add the composite service to the composite implementation artifact
+ Implementation implementation = component.getImplementation();
+ if (implementation != null && implementation instanceof Composite) {
+ ((Composite)implementation).getServices().add(implCompService);
+ } // end if
+ //
+ } else {
+ implService = assemblyFactory.createService();
+ } // end if
+ //
+ implService.setName(implReference.getName());
+ try {
+ InterfaceContract implContract = (InterfaceContract)implReference.getInterfaceContract().clone();
+ implContract.setInterface(implContract.getCallbackInterface());
+ implContract.setCallbackInterface(null);
+ implService.setInterfaceContract(implContract);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ callbackService.setService(implService);
+ }
+ component.getServices().add(callbackService);
+
+ // configure bindings for the callback service
+ if (callbackService.getBindings().isEmpty()) {
+ if (reference.getCallback() != null && reference.getCallback().getBindings().size() > 0) {
+ // set bindings of the callback service based on the information provided in
+ // SCDL reference callback element
+ callbackService.getBindings().addAll(reference.getCallback().getBindings());
+ } else if (reference.getBindings().size() > 0) {
+ // use any bindings explicitly declared on the forward reference
+ for (Binding binding : reference.getBindings()) {
+ try {
+ Binding clonedBinding = (Binding)binding.clone();
+ // binding uri will be calculated during runtime build
+ clonedBinding.setURI(null);
+ callbackService.getBindings().add(clonedBinding);
+ } catch (CloneNotSupportedException ex) {
+
+ }
+ }
+ } else {
+ // create a default binding which will have the correct policy
+ // and URI added. We check later to see if a new binding is required
+ // based on the forward binding but can then copy policy and URI
+ // details from here.
+ // TODO - there is a hole here. If the user explicitly specified an
+ // SCA callback binding that is different from the forward
+ // binding type then we're in trouble
+ createSCABinding(callbackService, null);
+ }
+ }
+
+ reference.setCallbackService(callbackService);
+ }
+ }
+
+ /**
+ * Create a default SCA binding in the case that no binding
+ * is specified by the user
+ *
+ * @param contract
+ * @param definitions
+ */
+ protected void createSCABinding(Contract contract, Definitions definitions) {
+
+ SCABinding scaBinding = scaBindingFactory.createSCABinding();
+ scaBinding.setName(contract.getName());
+
+ if (definitions != null) {
+ for (ExtensionType attachPointType : definitions.getBindingTypes()) {
+ if (attachPointType.getType().equals(BINDING_SCA_QNAME)) {
+ ((PolicySubject)scaBinding).setExtensionType(attachPointType);
+ }
+ }
+ }
+
+ contract.getBindings().add(scaBinding);
+ contract.setOverridingBindings(false);
+ }
+
+ /**
+ * Look to see if any value elements have been set into the property
+ * A bit involved as the value is stored as a DOM Document
+ *
+ * @param property the property to be tested
+ * @return true is values are present
+ */
+ private boolean isPropertyValueSet(Property property) {
+ Document value = (Document)property.getValue();
+
+ if (value == null) {
+ return false;
+ }
+
+ if (value.getDocumentElement() == null) {
+ return false;
+ }
+
+ if (value.getDocumentElement().getChildNodes().getLength() == 0) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Look to see is a property has more than one value
+ *
+ * @param property
+ * @return true is the property has more than one value
+ */
+ private boolean isPropertyManyValued(Property property) {
+
+ if (isPropertyValueSet(property)){
+ Document value = (Document)property.getValue();
+ if (value.getDocumentElement().getChildNodes().getLength() > 1){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isValidMultiplicityOverride(Multiplicity definedMul, Multiplicity overridenMul) {
+ if (definedMul != overridenMul) {
+ switch (definedMul) {
+ case ZERO_N:
+ return overridenMul == Multiplicity.ZERO_ONE || overridenMul == Multiplicity.ONE_ONE
+ || overridenMul == Multiplicity.ONE_N;
+ case ONE_N:
+ return overridenMul == Multiplicity.ONE_ONE;
+ case ZERO_ONE:
+ return overridenMul == Multiplicity.ONE_ONE;
+ default:
+ return false;
+ }
+ } else {
+ return true;
+ }
+ }
+
+
+ /**
+ * Interface contract from higher in the implementation hierarchy takes precedence
+ * When it comes to checking compatibility the top level service interface is a
+ * subset of the promoted service interface so treat the top level interface as
+ * the source
+ *
+ * @param topContract the top contract
+ * @param bottomContract the bottom contract
+ */
+ private void calculateServiceInterfaceContract(Component component, Service topContract, Service bottomContract, Monitor monitor) {
+
+ // Use the interface contract from the bottom level contract if
+ // none is specified on the top level contract
+ InterfaceContract topInterfaceContract = topContract.getInterfaceContract();
+ InterfaceContract bottomInterfaceContract = bottomContract.getInterfaceContract();
+
+ if (topInterfaceContract == null) {
+ topContract.setInterfaceContract(bottomInterfaceContract);
+ } else if (bottomInterfaceContract != null) {
+ // Check that the top and bottom interface contracts are compatible
+ boolean isCompatible = true;
+ String incompatibilityReason = "";
+ try{
+ isCompatible = checkSubsetCompatibility(topInterfaceContract,
+ bottomInterfaceContract);
+ } catch (IncompatibleInterfaceContractException ex){
+ isCompatible = false;
+ incompatibilityReason = ex.getMessage();
+ }
+ if (!isCompatible) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ServiceIncompatibleComponentInterface",
+ component.getName(),
+ topContract.getName(),
+ incompatibilityReason);
+ }
+
+ // TODO - there is an issue with the following code if the
+ // contracts are of different types. Need to use the
+ // normalized form
+
+ // fix up the forward interface based on the promoted component
+ // Someone might have manually specified a callback interface but
+ // left out the forward interface
+ if (topInterfaceContract.getInterface() == null){
+ topInterfaceContract.setInterface(bottomInterfaceContract.getInterface());
+ }
+
+ // fix up the callback interface based on the promoted component
+ // Someone might have manually specified a forward interface but
+ // left out the callback interface
+ if (topInterfaceContract.getCallbackInterface() == null){
+ topInterfaceContract.setCallbackInterface(bottomInterfaceContract.getCallbackInterface());
+ }
+ }
+ }
+
+ /**
+ * Interface contract from higher in the implementation hierarchy takes precedence
+ * When it comes to checking compatibility the top level reference interface is a
+ * superset of the promoted reference interface so treat the promoted
+ * (bottom) interface as the source
+ *
+ * @param topContract the top contract
+ * @param bottomContract the bottom contract
+ */
+ private void calculateReferenceInterfaceContract(Component component, Reference topContract, Reference bottomContract, Monitor monitor) {
+
+ // Use the interface contract from the bottom level contract if
+ // none is specified on the top level contract
+ InterfaceContract topInterfaceContract = topContract.getInterfaceContract();
+ InterfaceContract bottomInterfaceContract = bottomContract.getInterfaceContract();
+
+ if (topInterfaceContract == null) {
+ topContract.setInterfaceContract(bottomInterfaceContract);
+ } else if (bottomInterfaceContract != null) {
+ // Check that the top and bottom interface contracts are compatible
+ boolean isCompatible = true;
+ String incompatibilityReason = "";
+ try{
+ isCompatible = checkSubsetCompatibility(bottomInterfaceContract,
+ topInterfaceContract);
+ } catch (IncompatibleInterfaceContractException ex){
+ isCompatible = false;
+ incompatibilityReason = ex.getMessage();
+ }
+ if (!isCompatible) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceIncompatibleComponentInterface",
+ component.getName(),
+ topContract.getName(),
+ incompatibilityReason);
+ }
+
+ // TODO - there is an issue with the following code if the
+ // contracts of of different types. Need to use the
+ // normalized form
+
+ // fix up the forward interface based on the promoted component
+ // Someone might have manually specified a callback interface but
+ // left out the forward interface
+ if (topInterfaceContract.getInterface() == null){
+ topInterfaceContract.setInterface(bottomInterfaceContract.getInterface());
+ }
+
+ // fix up the callback interface based on the promoted component
+ // Someone might have manually specified a forward interface but
+ // left out the callback interface
+ if (topInterfaceContract.getCallbackInterface() == null){
+ topInterfaceContract.setCallbackInterface(bottomInterfaceContract.getCallbackInterface());
+ }
+ }
+ }
+
+ /**
+ * Bindings from higher in the hierarchy take precedence
+ *
+ * @param componentService the top service
+ * @param componentTypeService the bottom service
+ */
+ private void calculateBindings(Component component, Service componentService, Service componentTypeService, BuilderContext context) {
+ Monitor monitor = context.getMonitor();
+
+ // forward bindings
+ if (componentService.getBindings().isEmpty()) {
+ componentService.getBindings().addAll(componentTypeService.getBindings());
+ }
+
+ if (componentService.getBindings().isEmpty()) {
+ createSCABinding(componentService, context.getDefinitions());
+ }
+
+ // callback bindings
+ if (componentService.getCallback() == null) {
+ componentService.setCallback(componentTypeService.getCallback());
+ if (componentService.getCallback() == null) {
+ // Create an empty callback to avoid null check
+ componentService.setCallback(assemblyFactory.createCallback());
+ }
+ } else if (componentService.getCallback().getBindings().isEmpty() && componentTypeService.getCallback() != null) {
+ componentService.getCallback().getBindings().addAll(componentTypeService.getCallback().getBindings());
+ }
+
+ // [ASM90005] validate that binding.sca has no uri set
+ for (Binding binding : componentService.getBindings()){
+ if (binding instanceof SCABinding){
+ if ((binding.getURI() != null) &&
+ (binding.getURI().length() > 0)){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "URIFoundOnServiceSCABinding",
+ binding.getName(),
+ component.getName(),
+ componentService.getName(),
+ binding.getURI());
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Bindings from higher in the hierarchy take precedence
+ *
+ * @param componentReference the top service
+ * @param componentTypeReference the bottom service
+ */
+ private void calculateBindings(Reference componentReference, Reference componentTypeReference) {
+ // forward bindings
+ if (componentReference.getBindings().isEmpty()) {
+ componentReference.getBindings().addAll(componentTypeReference.getBindings());
+ }
+
+ // callback bindings
+ if (componentReference.getCallback() == null) {
+ componentReference.setCallback(componentTypeReference.getCallback());
+ } else if (componentReference.getCallback().getBindings().isEmpty() && componentTypeReference.getCallback() != null) {
+ componentReference.getCallback().getBindings().addAll(componentTypeReference.getCallback().getBindings());
+ }
+ }
+
+ /**
+ * A local wrapper for the interface contract mapper as we need to normalize the
+ * interface contracts if appropriate and the mapper doesn't have the right
+ * dependencies to be able to do it.
+ *
+ * Sometimes the two interfaces can be presented using different IDLs, for example
+ * Java and WSDL. In this case interfaces are converted so that they are both WSDL1.1 interfaces
+ * and they are then compared. The generated WSDL is cached on the interface object for
+ * any subsequent matching
+ *
+ * @param contractA
+ * @param contractB
+ * @return true if the interface contracts match
+ */
+ private boolean checkSubsetCompatibility(InterfaceContract contractA, InterfaceContract contractB)
+ throws IncompatibleInterfaceContractException {
+
+ if (contractA.getClass() != contractB.getClass()) {
+
+ if (contractA instanceof JavaInterfaceContract){
+ contractBuilder.build(contractA, null);
+ contractA = ((JavaInterfaceContract)contractA).getNormalizedWSDLContract();
+ }
+
+ if (contractB instanceof JavaInterfaceContract){
+ contractBuilder.build(contractB, null);
+ contractB = ((JavaInterfaceContract)contractB).getNormalizedWSDLContract();
+ }
+ }
+
+ return interfaceContractMapper.checkCompatibility(contractA,
+ contractB,
+ Compatibility.SUBSET,
+ false,
+ false);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
new file mode 100644
index 0000000000..6ce0a3a7d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java
@@ -0,0 +1,582 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+/**
+ * A composite builder that computes policy sets based on attached intents and policy sets.
+ * Useful if you want to build the model without making any runtime decisions such as
+ * reference/services matching
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentPolicyBuilderImpl {
+
+ protected BuilderExtensionPoint builders;
+
+ public ComponentPolicyBuilderImpl(ExtensionPointRegistry registry) {
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param monitor
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ Monitor.warning(monitor, this, Messages.BUILDER_VALIDATION_BUNDLE, message, messageParameters);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param monitor
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ Monitor.error(monitor, this, Messages.BUILDER_VALIDATION_BUNDLE, message, messageParameters);
+ }
+
+
+ /**
+ * Inherit the intents and policySets from the list of models
+ *
+ * @param policySubject - the subject to which intents will be added
+ * @param intentType - choose to copy interaction or implementation intents. Null = both
+ * @param ignoreExclusiveIntents - when set true mutually exclusive intents won't be copied
+ * @param models - the subjects from which intents will be copied
+ */
+ protected void inherit(PolicySubject policySubject, Intent.Type intentType, boolean ignoreExclusiveIntents, Object... models) {
+ for (Object model : models) {
+ if (model instanceof PolicySubject) {
+ PolicySubject subject = (PolicySubject)model;
+
+ if (!ignoreExclusiveIntents) {
+ // The intents are merged and the exclusion check will be done after
+ for (Intent intent : subject.getRequiredIntents()) {
+ if (!policySubject.getRequiredIntents().contains(intent)){
+ if ((intent.getType() != null) && (intentType != null) ) {
+ if (intent.getType().equals(intentType)){
+ policySubject.getRequiredIntents().add(intent);
+ }
+ } else {
+ policySubject.getRequiredIntents().add(intent);
+ }
+ }
+ }
+ } else {
+ Set<Intent> intents = new HashSet<Intent>();
+ for (Intent i1 : subject.getRequiredIntents()) {
+ boolean exclusive = false;
+ for (Intent i2 : policySubject.getRequiredIntents()) {
+ if (i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1)) {
+ exclusive = true;
+ break;
+ }
+ }
+ if (!exclusive) {
+ if (!intents.contains(i1)){
+ if (intentType != null) {
+ if (i1.getType().equals(intentType)){
+ intents.add(i1);
+ }
+ } else {
+ intents.add(i1);
+ }
+ }
+ }
+ }
+ policySubject.getRequiredIntents().addAll(intents);
+ }
+ //FIXME this duplicates the intents for a implementation
+ //e.g <implementation.java requires="managedTransaction.local managedTransaction.local"
+ //becomes twice
+ //[{http://docs.oasis-open.org/ns/opencsa/sca/200912}managedTransaction.local,
+ //{http://docs.oasis-open.org/ns/opencsa/sca/200912}managedTransaction.local]
+ for (PolicySet policySet : subject.getPolicySets()){
+ if (!policySubject.getPolicySets().contains(policySet)){
+ policySubject.getPolicySets().add(policySet);
+ }
+ }
+ }
+ }
+ }
+
+ protected void configure(PolicySubject subject1, PolicySubject subject2, Intent.Type intentType, BuilderContext context) {
+ if (subject1 != null) {
+ resolveAndCheck(subject1, context);
+ }
+ if (subject2 != null) {
+ resolveAndCheck(subject2, context);
+ }
+ inherit(subject1, intentType, false, subject2);
+ checkMutualExclusion(subject1, context);
+ }
+
+ protected void configure(ComponentService componentService, BuilderContext context) {
+ Service service = componentService.getService();
+ if (service != null) {
+ configure(componentService, service, null, context);
+ configureBindings(componentService, service, context);
+ }
+ }
+
+ private void configureBindings(Contract componentContract, Contract componentTypeContract, BuilderContext context) {
+ if (componentTypeContract == null) {
+ return;
+ }
+ Map<String, Binding> componentTypeContractBindings = new HashMap<String, Binding>();
+ for (Binding binding : componentTypeContract.getBindings()) {
+ componentTypeContractBindings.put(binding.getName(), binding);
+ }
+ for (Binding binding : componentContract.getBindings()) {
+ Binding componentTypeBinding = componentTypeContractBindings.get(binding.getName());
+ if (binding instanceof PolicySubject &&
+ componentTypeBinding instanceof PolicySubject) {
+ configure((PolicySubject)binding, (PolicySubject)componentTypeBinding, Intent.Type.interaction, context);
+ }
+ }
+ }
+
+ protected void configure(ComponentReference componentReference, BuilderContext context) {
+ Reference reference = componentReference.getReference();
+ if (reference != null) {
+ configure(componentReference, reference, null, context);
+ configureBindings(componentReference, reference, context);
+ }
+ }
+
+ protected void configure(CompositeService compositeService, BuilderContext context) {
+ configure(compositeService, compositeService.getPromotedService(), null, context);
+ }
+
+ protected void configure(CompositeReference compositeReference, BuilderContext context) {
+ for (ComponentReference reference : compositeReference.getPromotedReferences()) {
+ configure(compositeReference, reference, null, context);
+ }
+ }
+
+ public void configure(Component component, BuilderContext context) {
+ Monitor monitor = context.getMonitor();
+
+ // fix up the component type by copying all implementation level
+ // interaction intents to *all* the component type services
+ for (ComponentService componentService : component.getServices()) {
+ monitor.pushContext("Service: " + componentService.getName());
+ try {
+ configure(componentService, component.getImplementation(), Intent.Type.interaction, context);
+ removeConstrainedIntents(componentService, context);
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ // Inherit the intents and policySets from the componentType
+ for (ComponentReference componentReference : component.getReferences()) {
+ monitor.pushContext("Reference: " + componentReference.getName());
+ try {
+ configure(componentReference, context);
+ removeConstrainedIntents(componentReference, context);
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ for (ComponentService componentService : component.getServices()) {
+ monitor.pushContext("Service: " + componentService.getName());
+ try {
+ configure(componentService, context);
+ removeConstrainedIntents(componentService, context);
+ } finally {
+ monitor.popContext();
+ }
+ }
+ }
+
+ /**
+ * Checks if any qualifiable intents of intents in an excluded intent list match
+ * with a second intent. looking for the case where
+ *
+ * <intent name="intentA" excludes="intentB"/>
+ * <intent name="intentB" >
+ * <sca:qualifier name="q1" default="true"/>
+ * <sca:qualifier name="q2" default="true"/>
+ * </intent>
+ *
+ * And were
+ *
+ * requires="intentA intentB.q1" appears on an element
+ *
+ * @param excludedIntentList
+ * @param intent
+ * @return
+ */
+ protected boolean checkQualifiedMutualExclusion(List<Intent> excludedIntentList, Intent intent){
+ for (Intent excludedIntent : excludedIntentList){
+ if (intent.getQualifiableIntent() != null &&
+ excludedIntent != null &&
+ intent.getQualifiableIntent().equals(excludedIntent)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if two intents are mutually exclusive
+ *
+ * @param i1
+ * @param i2
+ * @param context
+ * @return
+ */
+ protected boolean checkMutualExclusion(Intent i1, Intent i2, BuilderContext context){
+ if ((i1 != i2) &&
+ (i1.getExcludedIntents().contains(i2) ||
+ i2.getExcludedIntents().contains(i1) ||
+ checkQualifiedMutualExclusion(i1.getExcludedIntents(), i2) ||
+ checkQualifiedMutualExclusion(i2.getExcludedIntents(), i1))) {
+ error(context.getMonitor(), "MutuallyExclusiveIntentsAtBuild", this, i1, i2);
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Check if a single policy subject requires mutually exclusive intents
+ * @param subject1 - the policy subject to check
+ * @param context - context containing useful things like the monitor instance
+ * @return true if the policy subject contains mutually exclusive intents
+ */
+ protected boolean checkMutualExclusion(PolicySubject subject1, BuilderContext context) {
+ if (subject1 == null) {
+ return false;
+ }
+ for (Intent i1 : subject1.getRequiredIntents()) {
+ for (Intent i2 : subject1.getRequiredIntents()) {
+ if (checkMutualExclusion(i1, i2, context)){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if two policy subjects requires mutually exclusive intents
+ * @param subject1
+ * @param subject2
+ * @param monitor
+ * @return
+ */
+ protected boolean checkMutualExclusion(PolicySubject subject1, PolicySubject subject2, BuilderContext context) {
+ if (subject1 == subject2 || subject1 == null || subject2 == null) {
+ return false;
+ }
+ for (Intent i1 : subject1.getRequiredIntents()) {
+ for (Intent i2 : subject2.getRequiredIntents()) {
+ if (checkMutualExclusion(i1, i2, context)){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected boolean resolveAndCheck(PolicySubject subject, BuilderContext context) {
+ if (subject == null) {
+ return false;
+ }
+ // FIXME: [rfeng] Should we resolve the intents during the "build" phase?
+ resolveAndNormalize(subject, context);
+
+ checkMutualExclusion(subject, context);
+
+ return false;
+ }
+
+ /**
+ * Check if two names are equal
+ * @param name1
+ * @param name2
+ * @return
+ */
+ protected boolean isEqual(String name1, String name2) {
+ if (name1 == name2) {
+ return true;
+ }
+ if (name1 != null) {
+ return name1.equals(name2);
+ } else {
+ return name2.equals(name1);
+ }
+ }
+
+ protected static Intent resolve(Definitions definitions, Intent proxy) {
+ for (Intent i : definitions.getIntents()) {
+ if (i.equals(proxy)) {
+ return i;
+ }
+ for (Intent qi : i.getQualifiedIntents()) {
+ if (qi.equals(proxy)) {
+ return qi;
+ }
+ }
+ }
+ return null;
+ }
+
+ // Replace qualifiable intents with their default qualifier. This can't be done until
+ // after inheritance.
+ protected void expandDefaultIntents(PolicySubject subject, BuilderContext context) {
+
+ Set<Intent> copy = new HashSet<Intent>(subject.getRequiredIntents());
+ for (Intent i : copy) {
+ if (i.getDefaultQualifiedIntent() != null) {
+ subject.getRequiredIntents().remove(i);
+ subject.getRequiredIntents().add(i.getDefaultQualifiedIntent());
+ }
+ }
+ }
+ protected void resolveAndNormalize(PolicySubject subject, BuilderContext context) {
+ Definitions definitions = context.getDefinitions();
+ Set<Intent> intents = new HashSet<Intent>();
+ if (definitions != null) {
+ for (Intent i : subject.getRequiredIntents()) {
+ Intent resolved = resolve(definitions, i);
+ if (resolved != null) {
+ intents.add(resolved);
+ } else {
+ error(context.getMonitor(), "IntentNotFoundAtBuild", subject, i);
+ // Intent cannot be resolved
+ }
+ }
+ }
+
+ // Replace profile intents with their required intents
+ while (!intents.isEmpty()) {
+ boolean profileIntentsFound = false;
+ Set<Intent> copy = new HashSet<Intent>(intents);
+ for (Intent i : copy) {
+ if (!i.getRequiredIntents().isEmpty()) {
+ intents.remove(i);
+ intents.addAll(i.getRequiredIntents());
+ profileIntentsFound = true;
+ }
+ }
+ if (!profileIntentsFound) {
+ // No more profileIntents
+ break;
+ }
+ }
+
+ // Replace unqualified intents if there is a qualified intent in the list
+ Set<Intent> copy = new HashSet<Intent>(intents);
+ for (Intent i : copy) {
+ if (i.getQualifiableIntent() != null) {
+ intents.remove(i.getQualifiableIntent());
+ }
+
+ }
+
+
+ subject.getRequiredIntents().clear();
+ subject.getRequiredIntents().addAll(intents);
+
+ // TUSCANY-3503 - policy sets now only applied through direct
+ // or external attachement
+ // resolve policy set names that have been specified for the
+ // policy subject against the real policy sets from the
+ // definitions files
+ Set<PolicySet> policySets = new HashSet<PolicySet>();
+ if (definitions != null) {
+ for (PolicySet policySet : subject.getPolicySets()) {
+ int index = definitions.getPolicySets().indexOf(policySet);
+ if (index != -1) {
+ policySets.add(definitions.getPolicySets().get(index));
+ } else {
+ // PolicySet cannot be resolved
+ warning(context.getMonitor(), "PolicySetNotFoundAtBuild", subject, policySet);
+ }
+ }
+ }
+
+ subject.getPolicySets().clear();
+ subject.getPolicySets().addAll(policySets);
+ }
+
+ protected void removeConstrainedIntents(PolicySubject subject, BuilderContext context) {
+ List<Intent> intents = subject.getRequiredIntents();
+
+ // Remove the intents whose @contrains do not include the current element
+ ExtensionType extensionType = subject.getExtensionType();
+ if(extensionType != null){
+ List<Intent> copy = new ArrayList<Intent>(intents);
+ for (Intent i : copy) {
+ List<ExtensionType> constrainedTypes = i.getConstrainedTypes();
+ if (( constrainedTypes.size() == 0 ) && ( i.getQualifiableIntent() != null ) )
+ constrainedTypes = i.getQualifiableIntent().getConstrainedTypes();
+
+ if (constrainedTypes.size() > 0){
+ boolean constraintFound = false;
+ for (ExtensionType constrainedType : constrainedTypes){
+ if (constrainedType.getType().equals(extensionType.getType()) ||
+ constrainedType.getType().equals(extensionType.getBaseType())){
+ constraintFound = true;
+ break;
+ }
+ }
+ if(!constraintFound){
+ intents.remove(i);
+ }
+ }
+ }
+ }
+ }
+
+ protected void checkIntentsResolved(PolicySubject subject, BuilderContext context) {
+ // find the policy sets that satisfy the intents that are now
+ // attached to the policy subject. From the OASIS policy
+ // spec CD02 rev7:
+ // 1272 A policySet provides an intent if any of the statements are true:
+ // 1273 1. The intent is contained in the policySet @provides list.
+ // 1274 2. The intent is a qualified intent and the unqualified form of the intent is contained in the policySet
+ // 1275 @provides list.
+ // 1276 3. The policySet @provides list contains a qualified form of the intent (where the intent is qualifiable).
+ for (Intent intent : subject.getRequiredIntents()) {
+ boolean intentMatched = false;
+
+ loop: for (PolicySet ps : subject.getPolicySets()) {
+ // FIXME: We will have to check the policy references and intentMap too
+ // as well as the appliesTo
+ if (ps.getProvidedIntents().contains(intent)) {
+ intentMatched = true;
+ break;
+ }
+
+ for (Intent psProvidedIntent : ps.getProvidedIntents()){
+ if (isQualifiedBy(psProvidedIntent, intent)){
+ intentMatched = true;
+ break loop;
+ }
+ }
+
+ for (IntentMap map : ps.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (intent.equals(q.getIntent())) {
+ intentMatched = true;
+ break loop;
+ }
+ }
+ }
+ }
+
+ if (!intentMatched){
+
+ // Reference side intents can still be resolved by the service binding, so we can only issue a
+ // warning here.
+ if ( subject instanceof EndpointReference ) {
+ warning(context.getMonitor(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
+ } else {
+ // Need to check the ExtensionType to see if the intent is provided there. If not, throw an error
+ ExtensionType type = subject.getExtensionType();
+
+
+ if ( type == null ) {
+ error(context.getMonitor(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
+ } else {
+ // The ExtensionType on the subject only has the binding name. The one in the system
+ // definitions will have the mayProvide/alwaysProvides values
+ for ( ExtensionType et : context.getDefinitions().getBindingTypes() ) {
+ if ( type.getType().equals(et.getType()) ) {
+ type = et;
+ }
+ }
+
+ if ( !type.getAlwaysProvidedIntents().contains(intent) && !type.getMayProvidedIntents().contains(intent)) {
+ error(context.getMonitor(), "IntentNotSatisfiedAtBuild", subject, intent.getName(), subject.toString());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected Set<QName> getPolicyNames(PolicySubject subject) {
+ if (subject == null) {
+ return Collections.emptySet();
+ }
+ Set<QName> names = new HashSet<QName>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ names.add(exp.getName());
+ }
+ }
+ return names;
+ }
+
+ protected boolean isQualifiedBy(Intent qualifiableIntent, Intent qualifiedIntent){
+ if (qualifiedIntent.getQualifiableIntent() == qualifiableIntent){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java
new file mode 100644
index 0000000000..38ab265c6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.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.sca.builder.impl;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * A composite builder that performs any additional building steps that
+ * component reference bindings may need. Used for WSDL generation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder {
+
+ private BuilderExtensionPoint builders;
+
+ public ComponentReferenceBindingBuilderImpl(ExtensionPointRegistry registry) {
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ buildReferenceBindings(composite, context);
+ return composite;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferenceBindingBuilder";
+ }
+
+ private void buildReferenceBindings(Composite composite, BuilderContext context) {
+
+ // find all the component reference bindings (starting at top level)
+ for (Component component : composite.getComponents()) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (Binding binding : componentReference.getBindings()) {
+ BindingBuilder builder = builders.getBindingBuilder(binding.getType());
+ if (builder != null) {
+ builder.build(component, componentReference, binding, context, false);
+ }
+ }
+ }
+ }
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildReferenceBindings((Composite)implementation, context);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java
new file mode 100644
index 0000000000..2debe41f2d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * A composite builder that performs any additional building steps that
+ * component service bindings may need. Used for WSDL generation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentServiceBindingBuilderImpl implements CompositeBuilder {
+ private BuilderExtensionPoint builders;
+
+ public ComponentServiceBindingBuilderImpl(ExtensionPointRegistry registry) {
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentServiceBindingBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ buildServiceBindings(composite, context);
+ return composite;
+ }
+
+ private void buildServiceBindings(Composite composite, BuilderContext context) {
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildServiceBindings((Composite)implementation, context);
+ }
+ }
+
+ // find all the component service bindings
+ for (Component component : composite.getComponents()) {
+ for (ComponentService componentService : component.getServices()) {
+ for (Binding binding : componentService.getBindings()) {
+ BindingBuilder builder = builders.getBindingBuilder(binding.getType());
+ if (builder != null) {
+ builder.build(component, componentService, binding, context, false);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java
new file mode 100644
index 0000000000..148a3b5368
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+
+/**
+ * A composite builder that clones nested composites.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeCloneBuilderImpl implements CompositeBuilder {
+
+ public CompositeCloneBuilderImpl() {
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+
+ if (Composite.DOMAIN_COMPOSITE.equals(composite.getName())) {
+ // Try to avoid clone for top-level composites that are added to the domain composite
+ for (Composite included : composite.getIncludes()) {
+ cloneIncludes(included);
+ cloneCompositeImplementations(included);
+ }
+ } else {
+ // Clone the includes
+ cloneIncludes(composite);
+ cloneCompositeImplementations(composite);
+ }
+
+ return composite;
+ }
+
+ private void cloneIncludes(Composite composite) {
+ List<Composite> includes = new ArrayList<Composite>();
+ for (Composite included : composite.getIncludes()) {
+ try {
+ includes.add((Composite)included.clone());
+ } catch (CloneNotSupportedException e) {
+ throw new UnsupportedOperationException(e);
+ }
+ }
+ composite.getIncludes().clear();
+ composite.getIncludes().addAll(includes);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeCloneBuilder";
+ }
+
+ /**
+ * Clone composite component implementations
+ *
+ * @param composite
+ * @param problems
+ */
+ private void cloneCompositeImplementations(Composite composite) {
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+
+ Composite compositeImplementation = (Composite)implementation;
+ try {
+ // Please note the clone method is recursive
+ Composite clone = (Composite)compositeImplementation.clone();
+ component.setImplementation(clone);
+ } catch (CloneNotSupportedException e) {
+ throw new UnsupportedOperationException(e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
new file mode 100644
index 0000000000..f87854cac4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
@@ -0,0 +1,696 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+
+// TODO - really implementation.composite component type builder - CompositeComponentTypeBuilder?
+
+public class CompositeComponentTypeBuilderImpl {
+ private static final Logger logger = Logger.getLogger(CompositeComponentTypeBuilderImpl.class.getName());
+
+ protected static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ protected static final String BINDING_SCA = "binding.sca";
+ protected static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA);
+
+ private ComponentBuilderImpl componentBuilder;
+ private AssemblyFactory assemblyFactory;
+ private SCABindingFactory scaBindingFactory;
+ private InterfaceContractMapper interfaceContractMapper;
+ private BuilderExtensionPoint builders;
+ private ContractBuilder contractBuilder;
+
+ public CompositeComponentTypeBuilderImpl(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
+
+ interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ contractBuilder = builders.getContractBuilder();
+ }
+
+ public void setComponentBuilder(ComponentBuilderImpl componentBuilder) {
+ this.componentBuilder = componentBuilder;
+ }
+
+ /**
+ * Calculate the component type for the provided implementation
+ *
+ * @param implementation
+ * @return component type
+ */
+ public void createComponentType(Component outerComponent, Composite composite, BuilderContext context) {
+
+ Monitor monitor = context.getMonitor();
+ monitor.pushContext("Composite: " + composite.getName().toString());
+
+ try {
+ // first make sure that each child component has been properly configured based
+ // on its own component type
+ for (Component component : composite.getComponents()) {
+
+ // Check for duplicate component names
+ if (component != composite.getComponent(component.getName())) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "DuplicateComponentName",
+ composite.getName().toString(),
+ component.getName());
+ }
+
+ // do any work we need to do before we configure the component
+ // Anything that needs to be pushed down the promotion
+ // hierarchy must be done before we configure the component
+
+ // Push down the autowire flag from the composite to components
+ if (component.getAutowire() == null) {
+ component.setAutowire(composite.getAutowire());
+ }
+
+ // configure the component from its component type
+ componentBuilder.configureComponentFromComponentType(outerComponent, composite, component, context);
+ }
+
+ // create the composite component type based on the promoted artifacts
+ // from the components that it contains
+
+ // index all the components, services and references in the
+ // component type so that they are easy to find
+ Map<String, Component> components = new HashMap<String, Component>();
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
+
+ // services
+ calculateServices(composite, components, componentServices, context);
+
+ // references
+ calculateReferences(composite, components, componentReferences, context);
+
+ // properties
+ // Properties on the composite component are unaffected by properties
+ // on child components. Instead child component properties might take their
+ // values from composite properties. Hence there is nothing to do here.
+ //calculateProperties(composite, components);
+
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ /**
+ * Index components, services and references inside a composite.
+ *
+ * @param composite
+ * @param components
+ * @param componentServices
+ * @param componentReferences
+ */
+ private void indexComponentsServicesAndReferences(Composite composite,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences) {
+
+ for (Component component : composite.getComponents()) {
+
+ // Index components by name
+ components.put(component.getName(), component);
+
+ ComponentService nonCallbackService = null;
+ int nonCallbackServices = 0;
+ for (ComponentService componentService : component.getServices()) {
+
+ // Index component services by component name / service name
+ String uri = component.getName() + '/' + componentService.getName();
+ componentServices.put(uri, componentService);
+
+ // count how many non-callback services there are
+ // if there is only one the component name also acts as the service name
+ if (!componentService.isForCallback()) {
+
+ // Check how many non callback non-promoted services we have
+ if (nonCallbackServices == 0) {
+ nonCallbackService = componentService;
+ }
+ nonCallbackServices++;
+ }
+ }
+
+ if (nonCallbackServices == 1) {
+ // If we have a single non callback service, index it by
+ // component name as well
+ componentServices.put(component.getName(), nonCallbackService);
+ }
+
+ // Index references by component name / reference name
+ for (ComponentReference componentReference : component.getReferences()) {
+ String uri = component.getName() + '/' + componentReference.getName();
+ componentReferences.put(uri, componentReference);
+ }
+ }
+ }
+
+ /**
+ * Connect the services in the component type to the component services that
+ * they promote
+ *
+ * @param componentType
+ * @param component
+ */
+ private void calculateServices(ComponentType componentType,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ BuilderContext context) {
+
+ Monitor monitor = context.getMonitor();
+
+ // Connect this component type's services to the
+ // services from child components which it promotes
+ connectPromotedServices(componentType, components, componentServices, monitor);
+
+ // look at each component type service in turn and
+ // calculate its configuration based on OASIS rules
+ for (Service service : componentType.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ ComponentService promotedComponentService = compositeService.getPromotedService();
+
+ // promote interface contracts
+ calculatePromotedServiceInterfaceContract(compositeService, promotedComponentService, monitor);
+
+ // promote bindings
+ calculatePromotedBindings(compositeService, promotedComponentService);
+
+ componentBuilder.policyBuilder.configure(compositeService, context);
+ }
+ }
+
+ /**
+ * Connect the references in the component type to the component references that
+ * they promote
+ *
+ * @param componentType
+ * @param component
+ */
+ private void calculateReferences(ComponentType componentType,
+ Map<String, Component> components,
+ Map<String, ComponentReference> componentReferences,
+ BuilderContext context) {
+ Monitor monitor = context.getMonitor();
+ // Connect this component type's references to the
+ // references from child components which it promotes
+ connectPromotedReferences(componentType, components, componentReferences, monitor);
+
+ // look at each component type reference in turn and
+ // calculate its configuration based on OASIS rules
+ for (Reference reference : componentType.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences();
+
+ for (ComponentReference promotedComponentReference : promotedReferences) {
+
+ // promote multiplicity
+ reconcileReferenceMultiplicity(componentType, compositeReference, promotedComponentReference, monitor);
+
+ // check nonOverridable
+ validateNonOverridable(componentType, compositeReference, promotedComponentReference, monitor);
+
+ // promote interface contracts
+ calculatePromotedReferenceInterfaceContract(compositeReference, promotedComponentReference, monitor);
+
+ // promote bindings
+ // Don't need to promote reference bindings as any lower level binding will
+ // already be targeting the correct service without need for promotion
+ //calculatePromotedBindings(compositeReference, promotedComponentReference);
+ }
+
+ componentBuilder.policyBuilder.configure(compositeReference, context);
+ }
+ }
+
+ /**
+ * Connect the services in the component type to the component services that
+ * they promote
+ *
+ * @param componentType
+ * @param component
+ */
+ private void connectPromotedServices(ComponentType componentType,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ Monitor monitor) {
+
+ for (Service service : componentType.getServices()) {
+ // Connect composite (component type) services to the component services
+ // that they promote
+ CompositeService compositeService = (CompositeService)service;
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null && componentService.isUnresolved()) {
+ // get the name of the promoted component/service
+ String promotedComponentName = compositeService.getPromotedComponent().getName();
+ String promotedServiceName;
+ if (componentService.getName() != null) {
+ if (compositeService.isForCallback()) {
+ // For callbacks the name already has the form "componentName/servicename"
+ promotedServiceName = componentService.getName();
+ } else {
+ promotedServiceName = promotedComponentName + '/' + componentService.getName();
+ }
+ } else {
+ promotedServiceName = promotedComponentName;
+ }
+
+ // find the promoted service
+ ComponentService promotedService = componentServices.get(promotedServiceName);
+
+ if (promotedService != null) {
+
+ // Point to the resolved component
+ Component promotedComponent = components.get(promotedComponentName);
+ compositeService.setPromotedComponent(promotedComponent);
+
+ // Point to the resolved component service
+ compositeService.setPromotedService(promotedService);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PromotedServiceNotFound",
+ ((Composite)componentType).getName().toString(),
+ promotedServiceName);
+ }
+ }
+ }
+ }
+
+ /**
+ * Connect the references in the component type to the component references that
+ * they promote
+ *
+ * @param componentType
+ * @param component
+ */
+ private void connectPromotedReferences(ComponentType componentType,
+ Map<String, Component> components,
+ Map<String, ComponentReference> componentReferences,
+ Monitor monitor) {
+
+ // Connect composite (component type) references to the component references that they promote
+ for (Reference reference : componentType.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences();
+ for (int i = 0, n = promotedReferences.size(); i < n; i++) {
+ ComponentReference componentReference = promotedReferences.get(i);
+ if (componentReference.isUnresolved()) {
+ String componentReferenceName = componentReference.getName();
+ componentReference = componentReferences.get(componentReferenceName);
+ if (componentReference != null) {
+ // Set the promoted component
+ Component promotedComponent = compositeReference.getPromotedComponents().get(i);
+ promotedComponent = components.get(promotedComponent.getName());
+ compositeReference.getPromotedComponents().set(i, promotedComponent);
+
+ componentReference.setPromoted(true);
+
+ // Point to the resolved component reference
+ promotedReferences.set(i, componentReference);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PromotedReferenceNotFound",
+ ((Composite)componentType).getName().toString(),
+ componentReferenceName);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Create a default SCA binding in the case that no binding
+ * is specified by the user
+ *
+ * @param contract
+ * @param definitions
+ */
+ protected void createSCABinding(Contract contract, Definitions definitions) {
+
+ SCABinding scaBinding = scaBindingFactory.createSCABinding();
+ scaBinding.setName(contract.getName());
+
+ if (definitions != null) {
+ for (ExtensionType attachPointType : definitions.getBindingTypes()) {
+ if (attachPointType.getType().equals(BINDING_SCA_QNAME)) {
+ ((PolicySubject)scaBinding).setExtensionType(attachPointType);
+ }
+ }
+ }
+
+ contract.getBindings().add(scaBinding);
+ contract.setOverridingBindings(false);
+ }
+
+ /**
+ * The following methods implement rules that the OASIS specification defined explicitly
+ * to control how configuration from a component type is inherited by a component
+ */
+
+ /**
+ * Interface contract from higher in the implementation hierarchy takes precedence.
+ * When it comes to checking compatibility the top level service interface is a
+ * subset of the promoted service interface so treat the top level interface as
+ * the source
+ *
+ * @param topContract the top contract
+ * @param bottomContract the bottom contract
+ */
+ private void calculatePromotedServiceInterfaceContract(Service topContract, Service bottomContract, Monitor monitor) {
+ // Use the interface contract from the bottom level contract if
+ // none is specified on the top level contract
+ InterfaceContract topInterfaceContract = topContract.getInterfaceContract();
+ InterfaceContract bottomInterfaceContract = bottomContract.getInterfaceContract();
+
+ if (topInterfaceContract == null) {
+ topContract.setInterfaceContract(bottomInterfaceContract);
+ } else if (bottomInterfaceContract != null) {
+ // Check that the top and bottom interface contracts are compatible
+ boolean isCompatible = true;
+ String incompatibilityReason = "";
+ try{
+ isCompatible = checkSubsetCompatibility(topInterfaceContract, bottomInterfaceContract);
+ } catch (IncompatibleInterfaceContractException ex){
+ isCompatible = false;
+ incompatibilityReason = ex.getMessage();
+ }
+ if (!isCompatible) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ServiceInterfaceNotSubSet",
+ topContract.getName(),
+ incompatibilityReason);
+ }
+
+ // TODO - there is an issue with the following code if the
+ // contracts of of different types. Need to use the
+ // normalized form
+
+ // fix up the forward interface based on the promoted component
+ // Someone might have manually specified a callback interface but
+ // left out the forward interface
+ if (topInterfaceContract.getInterface() == null){
+ topInterfaceContract.setInterface(bottomInterfaceContract.getInterface());
+ }
+
+ // fix up the callback interface based on the promoted component
+ // Someone might have manually specified a forward interface but
+ // left out the callback interface
+ if (topInterfaceContract.getCallbackInterface() == null){
+ topInterfaceContract.setCallbackInterface(bottomInterfaceContract.getCallbackInterface());
+ }
+ }
+ }
+
+ /**
+ * Interface contract from higher in the implementation hierarchy takes precedence.
+ * When it comes to checking compatibility the top level reference interface is a
+ * superset of the promoted reference interface so treat the promoted
+ * (bottom) interface as the source
+ *
+ * @param topContract the top contract
+ * @param bottomContract the bottom contract
+ */
+ private void calculatePromotedReferenceInterfaceContract(Reference topContract, Reference bottomContract, Monitor monitor) {
+ // Use the interface contract from the bottom level contract if
+ // none is specified on the top level contract
+ InterfaceContract topInterfaceContract = topContract.getInterfaceContract();
+ InterfaceContract bottomInterfaceContract = bottomContract.getInterfaceContract();
+
+ if (topInterfaceContract == null) {
+ topContract.setInterfaceContract(bottomInterfaceContract);
+ } else if (bottomInterfaceContract != null) {
+ // Check that the top and bottom interface contracts are compatible
+ boolean isCompatible = true;
+ String incompatibilityReason = "";
+ try{
+ isCompatible = checkSubsetCompatibility(bottomInterfaceContract, topInterfaceContract);
+ } catch (IncompatibleInterfaceContractException ex){
+ isCompatible = false;
+ incompatibilityReason = ex.getMessage();
+ }
+ if (!isCompatible) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceInterfaceNotSubSet",
+ topContract.getName(),
+ incompatibilityReason);
+ }
+
+ // TODO - there is an issue with the following code if the
+ // contracts of of different types. Need to use the
+ // normalized form
+
+ // fix up the forward interface based on the promoted component
+ // Someone might have manually specified a callback interface but
+ // left out the forward interface
+ if (topInterfaceContract.getInterface() == null){
+ topInterfaceContract.setInterface(bottomInterfaceContract.getInterface());
+ }
+
+ // fix up the callback interface based on the promoted component
+ // Someone might have manually specified a forward interface but
+ // left out the callback interface
+ if (topInterfaceContract.getCallbackInterface() == null){
+ topInterfaceContract.setCallbackInterface(bottomInterfaceContract.getCallbackInterface());
+ }
+ }
+ }
+
+ /**
+ * Bindings from higher in the implementation hierarchy take precedence
+ *
+ * @param compositeService
+ * @param promotedComponentService
+ */
+ private void calculatePromotedBindings(CompositeService compositeService, ComponentService promotedComponentService) {
+ // forward bindings
+ if (compositeService.getBindings().isEmpty()) {
+ for (Binding binding : promotedComponentService.getBindings()) {
+ try {
+ compositeService.getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+
+ if (compositeService.getBindings().isEmpty()) {
+ createSCABinding(compositeService, null);
+ }
+
+ // callback bindings
+ if (promotedComponentService.getCallback() != null) {
+ if (compositeService.getCallback() != null) {
+ compositeService.getCallback().getBindings().clear();
+ } else {
+ compositeService.setCallback(assemblyFactory.createCallback());
+ }
+
+ for (Binding binding : promotedComponentService.getCallback().getBindings()) {
+ try {
+ compositeService.getCallback().getBindings().add((Binding)binding.clone());
+ } catch (CloneNotSupportedException ex) {
+ // this binding can't be used in the promoted service
+ }
+ }
+ }
+ }
+
+ private void reconcileReferenceMultiplicity(ComponentType componentType,
+ Reference compositeReference,
+ Reference promotedComponentReference,
+ Monitor monitor) {
+ if (compositeReference.getMultiplicity() != null) {
+ if (!isValidMultiplicityOverride(promotedComponentReference.getTargets().size() > 0,
+ promotedComponentReference.getMultiplicity(),
+ compositeReference.getMultiplicity())) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "CompositeReferenceIncompatibleMultiplicity",
+ componentType.getURI(),
+ compositeReference.getName(),
+ promotedComponentReference.getName());
+ }
+ } else {
+ compositeReference.setMultiplicity(promotedComponentReference.getMultiplicity());
+ }
+ }
+
+ private boolean isValidMultiplicityOverride(boolean componentRefHasTarget,
+ Multiplicity componentRefMul,
+ Multiplicity compositeRefMul) {
+ if ((componentRefMul != null) &&
+ (compositeRefMul != null) &&
+ componentRefMul != compositeRefMul) {
+ if (componentRefHasTarget){
+ switch (componentRefMul) {
+ case ZERO_ONE:
+ return compositeRefMul == Multiplicity.ZERO_ONE ||
+ compositeRefMul == Multiplicity.ONE_ONE;
+ case ONE_ONE:
+ return compositeRefMul == Multiplicity.ZERO_ONE ||
+ compositeRefMul == Multiplicity.ONE_ONE;
+ case ZERO_N:
+ return true;
+ case ONE_N:
+ return true;
+ default:
+ return false;
+ }
+ } else {
+ switch (componentRefMul) {
+ case ZERO_ONE:
+ return compositeRefMul == Multiplicity.ONE_ONE;
+ case ONE_ONE:
+ return compositeRefMul == Multiplicity.ONE_ONE;
+ case ZERO_N:
+ return true;
+ case ONE_N:
+ return compositeRefMul == Multiplicity.ONE_ONE ||
+ compositeRefMul == Multiplicity.ONE_N;
+
+ default:
+ return false;
+ }
+ }
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * ASM50042 - Checks that if a component reference with multiplicity="1..1" is marked
+ * as nonOveridable then there are no composite references that promote it
+ *
+ * @param componentType
+ * @param compositeReference
+ * @param promotedComponentReference
+ * @param monitor
+ */
+ private void validateNonOverridable(ComponentType componentType,
+ Reference compositeReference,
+ Reference promotedComponentReference,
+ Monitor monitor){
+ if ((promotedComponentReference.getMultiplicity() == Multiplicity.ONE_ONE) &&
+ (((ComponentReference)promotedComponentReference)).isNonOverridable() == true) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "CompositeReferencePromotesNonOverridableReference",
+ componentType.getURI(),
+ compositeReference.getName(),
+ promotedComponentReference.getName());
+ }
+ }
+
+ /**
+ * A local wrapper for the interface contract mapper as we need to normalize the
+ * interface contracts if appropriate and the mapper doesn't have the right
+ * dependencies to be able to do it.
+ *
+ * Sometimes the two interfaces can be presented using different IDLs, for example
+ * Java and WSDL. In this case interfaces are converted so that they are both WSDL1.1 interfaces
+ * and they are then compared. The generated WSDL is cached on the interface object for
+ * any subsequent matching
+ *
+ * @param contractA
+ * @param contractB
+ * @return true if the interface contracts match
+ */
+ private boolean checkSubsetCompatibility(InterfaceContract contractA, InterfaceContract contractB)
+ throws IncompatibleInterfaceContractException {
+
+ if (contractA.getClass() != contractB.getClass()) {
+
+ if (contractA instanceof JavaInterfaceContract){
+ contractBuilder.build(contractA, null);
+ contractA = ((JavaInterfaceContract)contractA).getNormalizedWSDLContract();
+ }
+
+ if (contractB instanceof JavaInterfaceContract){
+ contractBuilder.build(contractB, null);
+ contractB = ((JavaInterfaceContract)contractB).getNormalizedWSDLContract();
+ }
+ }
+
+ return interfaceContractMapper.checkCompatibility(contractA,
+ contractB,
+ Compatibility.SUBSET,
+ false,
+ false);
+ }
+
+} //end class
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java
new file mode 100644
index 0000000000..63864e5832
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * Implementation of a CompositeBuilder.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeIncludeBuilderImpl implements CompositeBuilder {
+
+ public CompositeIncludeBuilderImpl() {
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeIncludeBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ return processIncludes(composite, context.getMonitor());
+ }
+
+ /**
+ * Merge the elements from the included composites into the including composite
+ * @param composite
+ * @param monitor
+ * @return
+ */
+ private Composite processIncludes(Composite composite, Monitor monitor) {
+ monitor.pushContext("Composite: " + composite.getName().toString());
+
+ try {
+ // process any composites referenced through implementation.composite
+ for (Component component : composite.getComponents()) {
+
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ processIncludes((Composite)implementation, monitor);
+ }
+ }
+
+ // get the components etc. from any included composites
+ for (Composite included : composite.getIncludes()) {
+ if (included.isLocal() && !composite.isLocal()) {
+ // ASM60041
+ Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "IllegalCompositeIncusion", composite
+ .getName().toString(), included.getName().toString());
+ return null;
+ }
+
+ // The included has been cloned during composite.clone()
+ Composite merged = processIncludes(included, monitor);
+ if (merged != null) {
+ for (Component component : merged.getComponents()) {
+ // apply the autowire flag on this composite to any inline
+ // components - Assembly 5.6 point 4
+ if (component.getAutowire() == null && Boolean.TRUE.equals(merged.getAutowire())) {
+ component.setAutowire(Boolean.TRUE);
+ }
+ // Merge the intents and policySets from the included composite into
+ // component/service/reference elements under the composite
+ component.getRequiredIntents().addAll(merged.getRequiredIntents());
+ component.getPolicySets().addAll(merged.getPolicySets());
+ }
+
+ for (Service service : merged.getServices()) {
+ service.getRequiredIntents().addAll(merged.getRequiredIntents());
+ service.getPolicySets().addAll(merged.getPolicySets());
+ }
+
+ for (Reference reference : merged.getReferences()) {
+ reference.getRequiredIntents().addAll(merged.getRequiredIntents());
+ reference.getPolicySets().addAll(merged.getPolicySets());
+ }
+ composite.getComponents().addAll(merged.getComponents());
+ composite.getServices().addAll(merged.getServices());
+ composite.getReferences().addAll(merged.getReferences());
+ composite.getProperties().addAll(merged.getProperties());
+ composite.getWires().addAll(merged.getWires());
+ // FIXME: What should we do for the extensions
+ /*
+ clone.getExtensions().addAll(fusedComposite.getExtensions());
+ clone.getAttributeExtensions().addAll(fusedComposite.getAttributeExtensions());
+ */
+ }
+ }
+
+ composite.getIncludes().clear();
+
+ // return the fused composite we have built up so far
+ return composite;
+ } finally {
+ monitor.popContext();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
new file mode 100644
index 0000000000..9c4da518d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
@@ -0,0 +1,477 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.policy.util.PolicyHelper;
+
+/**
+ * A composite builder that computes policy sets based on attached intents and policy sets.
+ * Useful if you want to build the model without making any runtime decisions such as
+ * reference/services matching
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl implements CompositeBuilder {
+ private final static QName NOLISTENER_INTENT = new QName(Base.SCA11_NS, "noListener");
+ private CompositeBuilder policyAppliesToBuilder = null;
+
+ public CompositePolicyBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
+
+ policyAppliesToBuilder = new PolicyAppliesToBuilderImpl(registry);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositePolicyBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context) throws CompositeBuilderException {
+ computePolicies(composite, context);
+ checkPolicies(composite, context);
+ buildPolicies(composite, context);
+ return composite;
+ }
+
+ protected void computePolicies(Composite composite, BuilderContext context) {
+ Monitor monitor = context.getMonitor();
+ monitor.pushContext("Composite: " + composite.getName().toString());
+
+ try {
+ resolveAndCheck(composite, context);
+
+ // compute policies recursively
+ for (Component component : composite.getComponents()) {
+ monitor.pushContext("Component: " + component.getName());
+
+ //resolve component level
+ resolveAndCheck(component, context);
+
+ try {
+ Implementation implementation = component.getImplementation();
+
+ for (ComponentService componentService : component.getServices()) {
+ monitor.pushContext("Service: " + componentService.getName());
+
+ try {
+ resolveAndCheck(componentService, context);
+
+ if (componentService.getInterfaceContract() != null) {
+ resolveAndCheck(componentService.getInterfaceContract().getInterface(), context);
+
+ resolveAndCheck(componentService.getInterfaceContract().getCallbackInterface(), context);
+
+ }
+
+ for (Endpoint ep : componentService.getEndpoints()) {
+
+
+ // Inherit from binding
+ inherit(ep, null, true, ep.getBinding());
+
+ // Inherit from composite/component/service
+ inherit(ep, null, true, ep.getService(), ep.getComponent(), composite );
+
+ if (componentService.getInterfaceContract() != null) {
+ // Inherit from the component.service.interface
+ // Do not check mutual exclusion here.. interfaces do not follow normal rules
+ // of the structural hierarchy (Policy spec 4.10)
+ inherit(ep, null, false, componentService.getInterfaceContract().getInterface());
+ }
+
+ // Replace profile intents with their required intents
+ // Replace unqualified intents if there is a qualified intent in the list
+ // Replace qualifiable intents with the default qualied intent
+ resolveAndNormalize(ep, context);
+
+ // Replace qualifiable intents with their default qualifier
+ expandDefaultIntents(ep, context);
+
+ // Remove the intents whose @contraints do not include the current element
+ removeConstrainedIntents(ep, context);
+
+ // Remove any direct policy sets if an external one has been applied
+ removeDirectPolicySetsIfExternalExists(ep, context);
+
+ // Validate that noListener is not specified on a service endpoint
+ checkForNoListenerIntent(ep, context);
+
+ // check that all intents are resolved
+ checkIntentsResolved(ep, context);
+
+ // check that the resulting endpoint has no mutually exclusive intents
+ checkMutualExclusion(ep, context);
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ for (ComponentReference componentReference : component.getReferences()) {
+ monitor.pushContext("Reference: " + componentReference.getName().toString());
+
+ try {
+
+ if (componentReference.getInterfaceContract() != null) {
+ resolveAndCheck(componentReference.getInterfaceContract().getInterface(), context);
+
+ resolveAndCheck(componentReference.getInterfaceContract().getCallbackInterface(),
+ context);
+ }
+
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+
+ // Inherit from binding
+ inherit(epr, null, true, epr.getBinding());
+
+ // Inherit from composite/component/reference
+ inherit(epr, null, true, epr.getReference(), epr.getComponent(), composite);
+
+ // Inherit from the component.reference.interface
+ if (componentReference.getInterfaceContract() != null) {
+ // Do not check mutual exclusion here.. interfaces do not follow normal rules
+ // of the structural hierarchy (Policy spec 4.10)
+ inherit(epr, null, true, componentReference.getInterfaceContract().getInterface());
+ }
+
+ // Replace profile intents with their required intents
+ // Replace unqualified intents if there is a qualified intent in the list
+ // Replace qualifiable intents with the default qualified intent
+ resolveAndNormalize(epr, context);
+
+ // Replace qualifiable intents with their default qualifier
+ expandDefaultIntents(epr, context);
+
+ // Remove the intents whose @contraints do not include the current element
+ removeConstrainedIntents(epr, context);
+
+ removeDirectPolicySetsIfExternalExists(epr, context);
+
+ // check that all intents are resolved
+ checkIntentsResolved(epr, context);
+
+ // check that the resulting endpoint reference has no mutually exclusive intents
+ checkMutualExclusion(epr, context);
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ if (implementation instanceof Composite) {
+ resolveAndCheck(implementation, context);
+ inherit(implementation, Intent.Type.implementation, true, component, composite);
+ computePolicies((Composite)implementation, context);
+ expandDefaultIntents(implementation,context);
+ checkIntentsResolved(implementation,context);
+ } else {
+ resolveAndCheck(implementation, context);
+ if (implementation != null) {
+ inherit(implementation, Intent.Type.implementation, true, component, composite);
+
+ // Remove the intents whose @contraints do not include the current element
+ removeConstrainedIntents(implementation, context);
+
+ removeDirectPolicySetsIfExternalExists(implementation, context);
+
+ // Replace qualifiable intents with their default qualifier
+ expandDefaultIntents(implementation, context);
+
+ // check that all intents are resolved
+ checkIntentsResolved(implementation, context);
+ }
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+ removeConstrainedIntents(composite, context);
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ private void validateTransactionIntents(Composite composite, BuilderContext context) {
+
+ for ( Component component : composite.getComponents() ) {
+ if ( component.getImplementation() != null ) {
+ if ( component.getImplementation() instanceof Composite )
+ validateTransactionIntents((Composite) component.getImplementation(), context);
+
+ for ( Intent implIntent : component.getImplementation().getRequiredIntents() ) {
+ if ( Constants.MANAGED_TRANSACTION_LOCAL_INTENT.equals(implIntent.getName() ) ) {
+ for ( ComponentReference reference : component.getReferences() ) {
+ for ( EndpointReference epr : reference.getEndpointReferences() ) {
+ for ( Intent eprIntent : epr.getRequiredIntents() ) {
+ if ( Constants.TRANSACTED_ONE_WAY_INTENT.equals(eprIntent.getName())) {
+ error(context.getMonitor(),
+ "TransactedOneWayWithManagedTransactionLocal",
+ this,
+ "reference",
+ epr.getComponent().getName(),
+ epr.getReference().getName());
+ } else if ( Constants.PROPAGATES_TRANSACTION_INTENT.equals(eprIntent.getName())) {
+ error(context.getMonitor(),
+ "PropagatesTransactionWithLocalTran",
+ this,
+ "reference",
+ epr.getComponent().getName(),
+ epr.getReference().getName());
+ }
+ }
+ }
+ }
+ for ( ComponentService service : component.getServices() ) {
+ for ( Endpoint ep : service.getEndpoints() ) {
+ for ( Intent epIntent : ep.getRequiredIntents() ) {
+ if ( Constants.TRANSACTED_ONE_WAY_INTENT.equals(epIntent.getName())) {
+ error(context.getMonitor(),
+ "TransactedOneWayWithManagedTransactionLocal",
+ this,
+ "service",
+ ep.getComponent().getName(),
+ ep.getService().getName());
+ } else if ( Constants.PROPAGATES_TRANSACTION_INTENT.equals(epIntent.getName())) {
+ error(context.getMonitor(),
+ "PropagatesTransactionWithLocalTran",
+ this,
+ "service",
+ ep.getComponent().getName(),
+ ep.getService().getName());
+ }
+ }
+ }
+ }
+ } else if ( Constants.NO_MANAGED_TRANSACTION_INTENT.equals(implIntent.getName())) {
+ for ( ComponentService service : component.getServices() ) {
+ for ( Endpoint ep : service.getEndpoints() ) {
+ for ( Intent epIntent : ep.getRequiredIntents() ) {
+ if ( Constants.PROPAGATES_TRANSACTION_INTENT.equals(epIntent.getName())) {
+ error(context.getMonitor(),
+ "PropagatesTransactionWithNoManagedTran",
+ this,
+ "service",
+ ep.getComponent().getName(),
+ ep.getService().getName());
+ }
+ }
+ }
+ }
+ for ( ComponentReference reference : component.getReferences() ) {
+ for ( EndpointReference epr : reference.getEndpointReferences() ) {
+ for ( Intent eprIntent : epr.getRequiredIntents() ) {
+ if ( Constants.PROPAGATES_TRANSACTION_INTENT.equals(eprIntent.getName())) {
+ error(context.getMonitor(),
+ "PropagatesTransactionWithNoManagedTran",
+ this,
+ "reference",
+ epr.getComponent().getName(),
+ epr.getReference().getName());
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ for ( ComponentReference reference : component.getReferences()) {
+ for ( EndpointReference epr : reference.getEndpointReferences() ) {
+ for ( Intent eprIntent : epr.getRequiredIntents() ) {
+ if ( Constants.TRANSACTED_ONE_WAY_INTENT.equals(eprIntent.getName()) ) {
+ for ( Operation o : epr.getComponentReferenceInterfaceContract().getInterface().getOperations() ) {
+ if ( !o.isNonBlocking() ) {
+ error(context.getMonitor(),
+ "TransactedOneWayWithTwoWayOp",
+ this,
+ reference.getName(),
+ o.getName());
+ }
+
+ }
+ } else if ( Constants.IMMEDIATE_ONE_WAY_INTENT.equals(eprIntent.getName())) {
+ for ( Operation o : epr.getComponentReferenceInterfaceContract().getInterface().getOperations() ) {
+ if ( !o.isNonBlocking() ) {
+ error(context.getMonitor(),
+ "ImmediateOneWayWithTwoWayOp",
+ this,
+ reference.getName(),
+ o.getName());
+ }
+
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+
+
+ private void checkForNoListenerIntent(Endpoint ep, BuilderContext context) {
+ PolicyHelper helper = new PolicyHelper();
+ if ( helper.getIntent(ep, NOLISTENER_INTENT) != null ) {
+ error(context.getMonitor(),
+ "NoListenerIntentSpecifiedOnService",
+ this,
+ ep.toString());
+ }
+
+ }
+
+ private void removeDirectPolicySetsIfExternalExists(PolicySubject subject,
+ BuilderContext context) {
+ boolean foundExternalPolicySet = false;
+ for (PolicySet ps : subject.getPolicySets() ) {
+ if ( ps.isExternalAttachment() ) {
+ foundExternalPolicySet = true;
+ break;
+ }
+ }
+
+ if ( foundExternalPolicySet ) {
+ List<PolicySet> copy = new ArrayList<PolicySet>(subject.getPolicySets());
+ for ( PolicySet ps : copy ) {
+ if ( !ps.isExternalAttachment() ) {
+ subject.getPolicySets().remove(ps);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * This is mainly about removing policies that don't "applyTo" the element where
+ * they have ended up after all the attachment and inheritance processing
+ *
+ * @param composite
+ * @param context
+ */
+ protected void checkPolicies(Composite composite, BuilderContext context) throws CompositeBuilderException{
+ policyAppliesToBuilder.build(composite, context);
+ validateTransactionIntents(composite, context);
+ }
+
+ protected void buildPolicies(Composite composite, BuilderContext context) {
+
+ // build policies recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildPolicies((Composite)implementation, context);
+ }
+ }
+
+ for (Component component : composite.getComponents()) {
+
+ for (ComponentService componentService : component.getServices()) {
+ for (Endpoint ep : componentService.getEndpoints()) {
+ Set<QName> policyNames = getPolicyNames(ep);
+
+ // check that only one policy language is present in the endpoint's policy sets
+ if (policyNames.size() > 1){
+ error(context.getMonitor(),
+ "MultiplePolicyLanguagesInEP",
+ this,
+ ep.toString(),
+ policyNames.toString());
+ } else {
+ for (QName policyType : policyNames) {
+ PolicyBuilder builder = builders.getPolicyBuilder(policyType);
+ if (builder != null) {
+ builder.build(ep, context);
+ }
+ }
+ }
+ }
+ }
+
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ Set<QName> policyNames = getPolicyNames(epr);
+
+ // check that only one policy language is present in the endpoint references's policy sets
+ if (policyNames.size() > 1){
+ error(context.getMonitor(),
+ "MultiplePolicyLanguagesInEPR",
+ this,
+ epr.toString(),
+ policyNames.toString());
+ } else {
+ for (QName policyType : policyNames) {
+ PolicyBuilder builder = builders.getPolicyBuilder(policyType);
+ if (builder != null) {
+ builder.build(epr, context);
+ }
+ }
+ }
+ }
+ }
+
+ Implementation implementation = component.getImplementation();
+ if (implementation != null) {
+ Set<QName> policyNames = getPolicyNames(implementation);
+
+ // check that only one policy language is present in the implementations's policy sets
+ if (policyNames.size() > 1){
+ error(context.getMonitor(),
+ "MultiplePolicyLanguagesInImplementation",
+ this,
+ component.toString(),
+ policyNames.toString());
+ } else {
+ for (QName policyType : policyNames) {
+ PolicyBuilder builder = builders.getPolicyBuilder(policyType);
+ if (builder != null) {
+ builder.build(component, implementation, context);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeWireApplierImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeWireApplierImpl.java
new file mode 100644
index 0000000000..3167b8cdb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeWireApplierImpl.java
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * Apply any <wire/> elements in the composites by creating suitable reference targets
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeWireApplierImpl implements CompositeBuilder {
+
+ private InterfaceContractMapper interfaceContractMapper;
+
+
+ public CompositeWireApplierImpl(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeWireApplierImpl";
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+
+ processComposite(composite, context);
+
+ return composite;
+ }
+
+ private void processComposite(Composite composite, BuilderContext context){
+ // Index components, services and references
+ Map<String, Component> components = new HashMap<String, Component>();
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
+
+ // Connect component references as described in wires
+ connectWires(composite, componentServices, componentReferences, context.getMonitor());
+
+ for (Component component : composite.getComponents()) {
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ processComposite((Composite)implementation, context);
+ }
+ }
+ }
+
+ protected void indexComponentsServicesAndReferences(Composite composite,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences) {
+
+ for (Component component : composite.getComponents()) {
+
+ // Index components by name
+ components.put(component.getName(), component);
+
+ ComponentService nonCallbackService = null;
+ int nonCallbackServices = 0;
+ for (ComponentService componentService : component.getServices()) {
+
+ // Index component services by component name / service name
+ String uri = component.getName() + '/'
+ + componentService.getName();
+ componentServices.put(uri, componentService);
+
+ // count how many non-callback services there are
+ // if there is only one the component name also acts as the
+ // service name
+ if (!componentService.isForCallback()) {
+ // Check how many non callback non-promoted services we have
+ if (nonCallbackServices == 0) {
+ nonCallbackService = componentService;
+ }
+ nonCallbackServices++;
+ }
+ }
+
+ if (nonCallbackServices == 1) {
+ // If we have a single non callback service, index it by
+ // component name as well
+ componentServices.put(component.getName(), nonCallbackService);
+ }
+
+ // Index references by component name / reference name
+ for (ComponentReference componentReference : component
+ .getReferences()) {
+ String uri = component.getName() + '/'
+ + componentReference.getName();
+ componentReferences.put(uri, componentReference);
+ }
+ }
+ }
+
+ /**
+ * Resolve wires and connect the sources to their targets
+ *
+ * @param composite
+ * @param componentServices
+ * @param componentReferences
+ * @param problems
+ */
+ private void connectWires(Composite composite,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences,
+ Monitor monitor) {
+
+ // For each wire, resolve the source reference, the target service, and
+ // add it to the list of targets of the reference
+ List<Wire> wires = composite.getWires();
+ for (int i = 0, n = wires.size(); i < n; i++) {
+ Wire wire = wires.get(i);
+
+ ComponentReference resolvedReference;
+ ComponentService resolvedService;
+
+ // Resolve the source reference
+ ComponentReference source = wire.getSource();
+ if (source != null && source.isUnresolved()) {
+ resolvedReference = componentReferences.get(source.getName());
+ if (resolvedReference != null) {
+ wire.setSource(resolvedReference);
+ } else {
+ Monitor.warning(monitor, this, Messages.ASSEMBLY_VALIDATION, "WireSourceNotFound", source
+ .getName());
+ }
+ } else {
+ resolvedReference = wire.getSource();
+ }
+
+ // Resolve the target service
+ ComponentService target = wire.getTarget();
+ if (target != null && target.isUnresolved()) {
+ resolvedService = componentServices.get(target.getName());
+ if (resolvedService != null) {
+ wire.setTarget(target);
+ } else {
+ Monitor.warning(monitor, this, Messages.ASSEMBLY_VALIDATION, "WireTargetNotFound", target
+ .getName());
+ }
+ } else {
+ resolvedService = wire.getTarget();
+ }
+
+ // Add the target service to the list of targets of the
+ // reference
+ if (resolvedReference != null && resolvedService != null) {
+ // Check that the target component service provides
+ // a superset of
+ // the component reference interface
+ if (resolvedReference.getInterfaceContract() == null || interfaceContractMapper
+ .isCompatibleSubset(resolvedReference.getInterfaceContract(), resolvedService.getInterfaceContract())) {
+
+ //resolvedReference.getTargets().add(resolvedService);
+ if (wire.isReplace()) {
+ resolvedReference.getTargets().clear();
+ }
+ resolvedReference.getTargets().add(wire.getTarget());
+ } else {
+ Monitor.warning(monitor, this, Messages.ASSEMBLY_VALIDATION, "WireIncompatibleInterface", source
+ .getName(), target.getName());
+ }
+ }
+ }
+
+ // Clear the list of wires
+ composite.getWires().clear();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java
new file mode 100644
index 0000000000..c1ba47661a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * creates endpoint models for component services.
+ */
+public class EndpointBuilderImpl implements CompositeBuilder {
+ private static final String BUILDER_VALIDATION_BUNDLE = "org.apache.tuscany.sca.builder.builder-validation-messages";
+
+ private AssemblyFactory assemblyFactory;
+
+ public EndpointBuilderImpl(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ }
+
+ /**
+ * Create endpoint models for all component services.
+ *
+ * @param composite - the top-level composite to build the models for
+ * @param definitions
+ * @param monitor - a Monitor for logging errors
+ */
+ public Composite build(Composite composite, BuilderContext context) throws CompositeBuilderException {
+
+ processComponentServices(composite, context);
+ return composite;
+
+ }
+
+ private void processComponentServices(Composite composite, BuilderContext context) {
+
+ Monitor monitor = context.getMonitor();
+
+ for (Component component : composite.getComponents()) {
+
+ try {
+ monitor.pushContext("Component: " + component.getName().toString());
+
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ processComponentServices((Composite)implementation, context);
+ }
+
+ // create an endpoint for each component service binding
+ for (ComponentService service : component.getServices()) {
+ try {
+ monitor.pushContext("Service: " + service.getName());
+
+ //verify JAX-WS async assertions as in JavaCAA section 11.1
+ List<Operation> asyncOperations = null;
+ try {
+ asyncOperations = (List<Operation>) service.getInterfaceContract().getInterface().getAttributes().get("JAXWS-ASYNC-OPERATIONS");
+ }catch(Exception e) {
+ //ignore
+ }
+
+ if(asyncOperations != null) {
+ if( ! asyncOperations.isEmpty()) {
+
+ //error JCA100006
+
+ //FIXME create a java validation message resource bundle
+ Monitor.error(monitor,
+ this,
+ BUILDER_VALIDATION_BUNDLE,
+ "JaxWSClientAsyncMethodsNotAllowed",
+ service,
+ service.getName());
+ }
+ }
+
+ // We maintain all endpoints at the right level now
+ // but endpoints for promoting services must point down
+ // to the services they promote. This is not actually done
+ // until the wire is created though in order that the
+ // uri is calculated correctly
+ // Callback endpoints may not be added here in the case that the
+ // forward reference is not yet resolved.
+ for (Binding binding : service.getBindings()) {
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(component);
+ endpoint.setService(service);
+ endpoint.setBinding(binding);
+ endpoint.setUnresolved(false);
+ service.getEndpoints().add(endpoint);
+ } // end for
+ } finally {
+ monitor.popContext();
+ }
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.EndpointBuilder";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
new file mode 100644
index 0000000000..7af1451f68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
@@ -0,0 +1,883 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Creates endpoint reference models.
+ */
+public class EndpointReferenceBuilderImpl {
+ private final Logger logger = Logger.getLogger(EndpointReferenceBuilderImpl.class.getName());
+
+ private AssemblyFactory assemblyFactory;
+ private InterfaceContractMapper interfaceContractMapper;
+
+ // causes dependency between builders and core
+ //private EndpointReferenceBinder endpointReferenceBinder;
+
+ public EndpointReferenceBuilderImpl(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+
+ // causes dependency between builders and core
+ //endpointReferenceBinder = registry.getExtensionPoint(EndpointReferenceBinder.class);
+ }
+
+ /**
+ * Create endpoint references for all component references.
+ *
+ * @param composite
+ */
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+
+ // create endpoint references for each reference
+ createEndpointReferences(composite, context);
+
+ // validate component references
+ // left until this stage, after all endpoints have been created,
+ // to to catch more complex cases caused by reference promotion
+ validateComponentReferences(composite, context.getMonitor());
+
+ // TODO - move the following buld time matching code
+ // to somewhere else because of
+ // the dependency between builders and core
+
+ // create temporary local registry for all available local endpoints
+ //EndpointRegistry registry = new EndpointRegistryImpl();
+
+ // populate the registry with all the endpoints that are present in the model
+ //populateLocalRegistry(composite, registry, context);
+
+ // match all local services against the endpoint references
+ // we've just created
+ //matchEndpointReferences(composite, registry, context);
+
+ return composite;
+ }
+
+ /**
+ * Iterate down through the composites creating end point references for
+ * all component references
+ *
+ * @param composite
+ * @param context
+ */
+ private void createEndpointReferences(Composite composite, BuilderContext context){
+
+ context.getMonitor().pushContext("Composite: " + composite.getName().toString());
+
+ try {
+ for (Component component : composite.getComponents()) {
+ context.getMonitor().pushContext("Component: " + component.getName());
+
+ try {
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ createEndpointReferences((Composite)implementation, context);
+ }
+
+ for (ComponentReference reference : component.getReferences()) {
+ // create the endpoint references for this component reference
+ processComponentReference(composite,
+ component,
+ reference,
+ context);
+
+ // we assume that endpoints have already been created so we can now
+ // create the links between enpoint references and endpoints that
+ // represent callbacks
+ fixUpCallbackLinks(component,
+ reference);
+
+ // push down endpoint references into the leaf component references
+ // in the case where this component reference promotes a reference from
+ // a composite implementation
+ pushDownEndpointReferences(composite,
+ component,
+ reference,
+ context.getMonitor());
+
+ }
+
+ // Validate that references are wired or promoted, according
+ // to their multiplicity. This validates as we go and catches cases
+ // where a reference has been configured directly incorrectly with its
+ // immediate multiplicity setting. We re-run this validation again later
+ // to catch to more complex cases where reference promotion causes
+ // multiplicity errors.
+ validateReferenceMultiplicity(composite, component, context.getMonitor());
+
+ } finally {
+ context.getMonitor().popContext();
+ }
+ }
+ } finally {
+ context.getMonitor().popContext();
+ }
+ }
+
+ /**
+ * Create endpoint references for a component references. Endpoint references can be
+ * implied by refrence targets, autowire or binding settings
+ *
+ * @param composite
+ * @param component
+ * @param reference
+ * @param context
+ */
+ private void processComponentReference(Composite composite,
+ Component component,
+ ComponentReference reference,
+ BuilderContext context){
+
+ context.getMonitor().pushContext("Reference: " + reference.getName());
+
+ try {
+ // Get reference targets
+ List<ComponentService> refTargets = getReferenceTargets(reference);
+
+ // This autowire processing really needs to move to the matching
+ // algorithm but dependency problems means it has to stay here for now
+ if (Boolean.TRUE.equals(reference.getAutowire()) && reference.getTargets().isEmpty()) {
+ // Find suitable targets in the current composite for an
+ // autowired reference
+ Multiplicity multiplicity = reference.getMultiplicity();
+ for (Component targetComponent : composite.getComponents()) {
+
+ // Tuscany specific selection of the first autowire reference
+ // when there are more than one (ASM_60025)
+ if ((multiplicity == Multiplicity.ZERO_ONE ||
+ multiplicity == Multiplicity.ONE_ONE) &&
+ (reference.getEndpointReferences().size() != 0)) {
+ break;
+ }
+
+ // Prevent autowire connecting to self
+ if (targetComponent == component)
+ continue;
+
+ for (ComponentService targetComponentService : targetComponent.getServices()) {
+ if (reference.getInterfaceContract() == null ||
+ interfaceContractMapper.isCompatibleSubset(reference.getInterfaceContract(),
+ targetComponentService.getInterfaceContract())) {
+
+ if (intentsMatch(reference.getRequiredIntents(), targetComponentService.getRequiredIntents())) {
+ EndpointReference endpointRef = createEndpointRef(component, reference, false);
+ endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
+ reference.getEndpointReferences().add(endpointRef);
+
+ // Stop with the first match for 0..1 and 1..1 references
+ if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) {
+ break;
+ } // end if
+ }
+ } // end if
+ } // end for
+ } // end for
+
+ if (multiplicity == Multiplicity.ONE_N || multiplicity == Multiplicity.ONE_ONE) {
+ if (reference.getEndpointReferences().size() == 0) {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "NoComponentReferenceTarget",
+ reference.getName());
+ }
+ }
+
+ setSingleAutoWireTarget(reference);
+
+ // as this is the autowire case we ignore any further configuration
+ return;
+ }
+
+ // check to see if explicit reference targets have been specified
+ if (!refTargets.isEmpty()) {
+ // Check that the component reference does not mix the use of endpoint references
+ // specified via the target attribute with the presence of binding elements
+ if (bindingsIdentifyTargets(reference)) {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceEndPointMixWithTarget",
+ composite.getName().toString(),
+ component.getName(),
+ reference.getName());
+ }
+
+ // create endpoint references for targets
+ for (ComponentService target : refTargets) {
+
+ EndpointReference endpointRef = createEndpointRef(component, reference, true);
+ endpointRef.setTargetEndpoint(createEndpoint(component, target.getName()));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
+ reference.getEndpointReferences().add(endpointRef);
+
+ // There is a special case where the user has defined policies on a
+ // non-targetted, i.e. no URI, binding.sca in order to control the
+ // intended QoS of the wire when matching takes place. If any other
+ // bindings are specified then the test later on will complain about
+ // mixing targts with bindings
+ if (reference.getBindings().size() == 1){
+ Binding binding = reference.getBindings().get(0);
+ if ((binding instanceof SCABinding) && (binding.getURI() == null)){
+ endpointRef.setBinding(binding);
+ }
+ }
+ }
+ }
+
+ // if no endpoints have been found so far the bindings hold the targets.
+ if (reference.getEndpointReferences().isEmpty()) {
+ for (Binding binding : reference.getBindings()) {
+
+ String uri = binding.getURI();
+
+ // user hasn't put a uri on the binding so it's not a target name and the assumption is that
+ // the target is established via configuration of the binding element itself
+ if (uri == null) {
+ // Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets
+ // and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint
+ if (!reference.isForCallback() && (binding instanceof SCABinding))
+ continue;
+
+ // create endpoint reference for manually configured bindings with a resolved endpoint to
+ // signify that this reference is pointing at some unwired endpoint
+ EndpointReference endpointRef = createEndpointRef(component, reference, binding, null, false);
+ if (binding instanceof SCABinding) {
+ // Assume that the system needs to resolve this binding later as
+ // it's the SCA binding
+ endpointRef.setTargetEndpoint(createEndpoint(true));
+ endpointRef.setStatus(EndpointReference.Status.NOT_CONFIGURED);
+ } else {
+ // The user has configured a binding so assume they know what
+ // they are doing and mark in as already resolved.
+ endpointRef.setTargetEndpoint(createEndpoint(false));
+ endpointRef.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ }
+
+ reference.getEndpointReferences().add(endpointRef);
+ continue;
+ } // end if
+
+ // if it's an absolute URI then assume that it's a resolved binding
+ try {
+ URI tmpURI = new URI(uri);
+ if (tmpURI.isAbsolute()){
+ // The user has configured a binding with an absolute URI so assume
+ // they know what they are doing and mark in as already resolved.
+ EndpointReference endpointRef = createEndpointRef(component, reference, binding, null, false);
+ endpointRef.setTargetEndpoint(createEndpoint(false));
+ endpointRef.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ reference.getEndpointReferences().add(endpointRef);
+ continue;
+ }
+ } catch (Exception ex){
+ // do nothing and go to the next bit of code
+ // which assumes that the URI is an SCA usi
+ }
+
+ // The user has put something in the binding uri but we don't know if it's
+ // a real URI or a target name. We can't tell until we have access to the
+ // fully populated registry at run time. The "createComponent()" call here
+ // will do its best to parse out component/service/binding elements assuming
+ // that the getSCATargetParts detects that there are three "/" separated
+ // parts in the uri.
+ EndpointReference endpointRef = createEndpointRef(component, reference, binding, null, false);
+ Endpoint endpoint = null;
+ try {
+ getSCATargetParts(uri);
+
+ // the target uri might be an SCA target so create an endpoint
+ // so that the binder can test it against the fully populated
+ // registry
+ endpoint = createEndpoint(component, uri);
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_IN_BINDING_URI);
+ } catch (Exception ex) {
+ // the target string definitely isn't an SCA target string
+ // so we can assume here that the user has configured a
+ // resolved binding
+ endpoint = createEndpoint(false);
+ endpoint.setURI(uri);
+ endpoint.setBinding(binding);
+ endpointRef.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ }
+
+ endpointRef.setTargetEndpoint(endpoint);
+ reference.getEndpointReferences().add(endpointRef);
+ }
+ }
+ } finally {
+ context.getMonitor().popContext();
+ }
+ }
+
+ private boolean intentsMatch(List<Intent> referenceIntents, List<Intent> serviceIntents) {
+ Set<Intent> referenceIntentSet = new HashSet<Intent>(referenceIntents);
+ Set<Intent> serviceIntentSet = new HashSet<Intent>(serviceIntents);
+ return referenceIntentSet.equals(serviceIntentSet);
+ }
+
+ /**
+ * The validate stage is separate from the process stage as endpoint references are
+ * pushed down the hierarchy. We don't know the full set of endpoint references until
+ * all processing is complete. Hence we can't validate as we go
+ *
+ * @param composite
+ * @param monitor
+ */
+ private void validateComponentReferences(Composite composite, Monitor monitor) {
+
+ monitor.pushContext("Composite: " + composite.getName().toString());
+ try {
+ // create endpoint references for each component's references
+ for (Component component : composite.getComponents()) {
+ monitor.pushContext("Component: " + component.getName());
+
+ try {
+
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ validateComponentReferences((Composite)implementation, monitor);
+ }
+ // Validate that references are wired or promoted, according
+ // to their multiplicity
+ validateReferenceMultiplicity(composite, component, monitor);
+
+ } finally {
+ monitor.popContext();
+ }
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ /**
+ * Reference targets have to be resolved in the context in which they are
+ * defined so they can't be pushed down the hierarchy during the static build.
+ * So we wait until we have calculated the endpoint references before pushing them
+ * down. Muliplicity errors will be caught by the multiplicity validation check that
+ * comes next
+ *
+ * @param composite
+ * @param component
+ * @param reference
+ * @param monitor
+ */
+ private void pushDownEndpointReferences(Composite composite,
+ Component component,
+ ComponentReference componentReference,
+ Monitor monitor) {
+ Reference reference = componentReference.getReference();
+
+ if (reference instanceof CompositeReference) {
+ List<ComponentReference> leafComponentReferences = getPromotedComponentReferences((CompositeReference)reference);
+
+ // for each leaf component reference copy in the endpoint references for this
+ // higher level (promoting) reference
+ // TODO - the elements are inserted starting at 0 here because the code allows references multiplicity
+ // validation constraints to be broken if the reference is autowire. At runtime the
+ // first one is chosen if max multiplicity is 1. We have an OSOA test that assumes that
+ // promoted references overwrite leaf references. This insert gives the same effect in the
+ // autowire case. We need to think about if there is a more correct answer.
+ for (ComponentReference leafRef : leafComponentReferences){
+ int insertLocation = 0;
+ for (EndpointReference epr : componentReference.getEndpointReferences()){
+ // copy the epr
+ EndpointReference eprCopy = copyHigherReference(epr, leafRef);
+ leafRef.getEndpointReferences().add(insertLocation, eprCopy);
+ insertLocation++;
+ }
+ }
+ }
+
+ // TODO - what to do about callbacks in the reference promotion case
+ }
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @return
+ */
+ private List<ComponentReference> getPromotedComponentReferences(CompositeReference compositeReference) {
+ List<ComponentReference> componentReferences = new ArrayList<ComponentReference>();
+ collectPromotedComponentReferences(compositeReference, componentReferences);
+ return componentReferences;
+ }
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @param componentReferences
+ * @return
+ */
+ private void collectPromotedComponentReferences(CompositeReference compositeReference,
+ List<ComponentReference> componentReferences) {
+ for (ComponentReference componentReference : compositeReference.getPromotedReferences()) {
+ // If the user has entered an incorrect promotion string an error will be reported to
+ // tell them but the processing will still reach here so only continue processing
+ // if the promotion chain is well formed
+ if (componentReference != null){
+ Reference reference = componentReference.getReference();
+ if (reference instanceof CompositeReference) {
+
+ // Continue to follow the reference promotion chain
+ collectPromotedComponentReferences((CompositeReference)reference, componentReferences);
+
+ } else if (reference != null) {
+
+ // Found a non-composite reference
+ componentReferences.add(componentReference);
+ }
+ }
+ }
+ }
+
+ /**
+ * Copy a higher level EndpointReference down to a lower level reference which it promotes
+ * @param epRef - the endpoint reference
+ * @param promotedReference - the promoted reference
+ * @return - a copy of the EndpointReference with data merged from the promoted reference
+ */
+ private EndpointReference copyHigherReference(EndpointReference epRef, ComponentReference promotedReference) {
+ EndpointReference epRefClone = null;
+ try {
+ epRefClone = (EndpointReference)epRef.clone();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ } // end try
+ // Copy across details of the inner reference
+ //ComponentReference ref = epRefClone.getReference();
+ //FIXME
+ epRefClone.setReference(promotedReference);
+ return epRefClone;
+ }
+
+ /**
+ * For all references in a component check that multiplicity is correct
+ *
+ * @param composite
+ * @param component
+ * @param monitor
+ */
+ private void validateReferenceMultiplicity(Composite composite, Component component, Monitor monitor) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ if (!validateMultiplicity(componentReference.getMultiplicity(),
+ componentReference.getEndpointReferences())) {
+ if (componentReference.getEndpointReferences().isEmpty()) {
+
+ // No error if the reference is promoted out of the current composite
+ boolean promoted = false;
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ if (compositeReference.getPromotedReferences().contains(componentReference)) {
+ promoted = true;
+ break;
+ }
+ }
+ if (!promoted && !componentReference.isForCallback() && !componentReference.isWiredByImpl()) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceWithoutTargets",
+ composite.getName().toString(),
+ componentReference.getName());
+ }
+ } else {
+ // no error if reference is autowire and more targets
+ // than multiplicity have been found
+ if (Boolean.TRUE.equals(componentReference.getAutowire())) {
+ break;
+ }
+
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "TooManyReferenceTargets",
+ componentReference.getName());
+ }
+ }
+ }
+
+ }
+
+ /**
+ * For a single component reference check that multiplicity is correct
+ *
+ * @param multiplicity
+ * @param endpointReferences
+ * @return
+ */
+ private boolean validateMultiplicity(Multiplicity multiplicity, List<EndpointReference> endpointReferences) {
+
+ // In some tests multiplicity is not set
+ if (multiplicity == null) {
+ return true;
+ }
+
+ // Count targets
+ int count = endpointReferences.size();
+
+ switch (multiplicity) {
+ case ZERO_N:
+ break;
+ case ZERO_ONE:
+ if (count > 1) {
+ return false;
+ }
+ break;
+ case ONE_ONE:
+ if (count != 1) {
+ return false;
+ }
+ break;
+ case ONE_N:
+ if (count < 1) {
+ return false;
+ }
+ break;
+ }
+ return true;
+ }
+
+ /**
+ * Evaluates whether the bindings attached to a reference identify one or more target services.
+ * @param reference - the reference
+ * @return true if the bindings identify a target, false otherwise
+ */
+ private boolean bindingsIdentifyTargets(ComponentReference reference) {
+ for (Binding binding : reference.getBindings()) {
+ // <binding.sca without a URI does not identify a target
+ if ((binding instanceof SCABinding) && (binding.getURI() == null))
+ continue;
+ // any other binding implies a target
+ // TODO Processing for other binding types
+ return true;
+ } // end for
+ return false;
+ } // end bindingsIdentifyTargets
+
+ /**
+ * Helper method which obtains a list of targets for a reference
+ * @param reference - Component reference
+ * @return - the list of targets, which will be empty if there are no targets
+ */
+ private List<ComponentService> getReferenceTargets(ComponentReference reference) {
+ List<ComponentService> theTargets = reference.getTargets();
+ if (theTargets.isEmpty()) {
+ // Component reference list of targets is empty, try the implementation reference
+ if (reference.getReference() != null) {
+ theTargets = reference.getReference().getTargets();
+ } // end if
+ } // end if
+ return theTargets;
+ } // end method getReferenceTargets
+
+ /**
+ * Helper method to create an Endpoint Reference
+ * @param component
+ * @param reference
+ * @param binding
+ * @param endpoint
+ * @param unresolved
+ * @return the endpoint reference
+ */
+ private EndpointReference createEndpointRef(Component component,
+ ComponentReference reference,
+ Binding binding,
+ Endpoint endpoint,
+ boolean unresolved) {
+ EndpointReference endpointRef = createEndpointRef(component, reference, unresolved);
+ endpointRef.setBinding(binding);
+ endpointRef.setTargetEndpoint(endpoint);
+ return endpointRef;
+ } // end method
+
+ /**
+ * Helper method to create an Endpoint Reference
+ * @param component
+ * @param reference
+ * @param unresolved
+ * @return the endpoint reference
+ */
+ private EndpointReference createEndpointRef(Component component, ComponentReference reference, boolean unresolved) {
+ EndpointReference endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setUnresolved(unresolved);
+ return endpointRef;
+ } // end method createEndpointRef
+
+ /**
+ * Helper method to create an Endpoint
+ * @param unresolved
+ * @return the endpoint
+ */
+ private Endpoint createEndpoint(boolean unresolved) {
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ endpoint.setUnresolved(unresolved);
+ return endpoint;
+ } // end method createEndpoint
+
+
+ /**
+ * Separates a target name into component/service/binding parts. Throws an exceptions
+ * if the number of parts <1 or > 3
+ * @param targetName
+ * @return String[] the recovered target parts
+ */
+ private String[] getSCATargetParts(String targetName){
+ String[] parts = targetName.split("/");
+ if (parts.length < 1 || parts.length > 3) {
+ throw new IllegalArgumentException("Invalid target URI: " + targetName);
+ }
+ return parts;
+ }
+
+ /**
+ * Helper method to create an Endpoint
+ *
+ * @param component The component that owns the reference
+ * @param targetName It can be one of the following formats
+ * <ul>
+ * <li>componentName
+ * <li>componentName/serviceName
+ * <li>componentName/serviceName/bindingName
+ * </ul>
+ * @return the endpoint
+ */
+ private Endpoint createEndpoint(Component component, String targetName) {
+ String[] parts = getSCATargetParts(targetName);
+
+ // Find the parent uri
+ String uri = component.getURI();
+ int index = uri.lastIndexOf('/');
+ if (index == -1) {
+ uri = "";
+ } else {
+ uri = uri.substring(0, index);
+ }
+
+ if (parts.length >= 1) {
+ // Append the target component name
+ if (uri.length() == 0) {
+ uri = parts[0];
+ } else {
+ uri = uri + "/" + parts[0];
+ }
+ }
+ if (parts.length == 3) {
+ // <componentURI>#service-binding(serviceName/bindingName)
+ uri = uri + "#service-binding(" + parts[1] + "/" + parts[2] + ")";
+ } else if (parts.length == 2) {
+ // <componentURI>#service(serviceName)
+ uri = uri + "#service(" + parts[1] + ")";
+ }
+
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ endpoint.setUnresolved(true);
+ endpoint.setURI(uri);
+ return endpoint;
+ } // end method createEndpoint
+
+ /**
+ * Helper method to create an endpoint
+ * @param component
+ * @param service
+ * @param unresolved
+ * @return the endpoint
+ */
+ private Endpoint createEndpoint(Component component, ComponentService service, boolean unresolved) {
+ Endpoint endpoint = createEndpoint(unresolved);
+ endpoint.setComponent(component);
+ endpoint.setService(service);
+ endpoint.setUnresolved(unresolved);
+ return endpoint;
+ } // end method createEndpoint
+
+ /**
+ * ASM_5021: where a <reference/> of a <component/> has @autowire=true
+ * and where the <reference/> has a <binding/> child element which
+ * declares a single target service, the reference is wired only to
+ * the single service identified by the <wire/> element
+ */
+ private void setSingleAutoWireTarget(ComponentReference reference) {
+ if (reference.getEndpointReferences().size() > 1 && reference.getBindings() != null
+ && reference.getBindings().size() == 1) {
+ String uri = reference.getBindings().get(0).getURI();
+ if (uri != null) {
+ if (uri.indexOf('/') > -1) {
+ // TODO: must be a way to avoid this fiddling
+ int i = uri.indexOf('/');
+ String c = uri.substring(0, i);
+ String s = uri.substring(i + 1);
+ uri = c + "#service(" + s + ")";
+ }
+ for (EndpointReference er : reference.getEndpointReferences()) {
+ if (er.getTargetEndpoint() != null && uri.equals(er.getTargetEndpoint().getURI())) {
+ reference.getEndpointReferences().clear();
+ reference.getEndpointReferences().add(er);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * The SCA callback model causes services and references to be automatically created
+ * to present the callback services and references. These are identifiable as their names
+ * will match the name of the forward reference or service to which they relate. In the general
+ * endpoint reference and endpoint processing we will have created endpoints and endpoint references
+ * for these callback services and references. We now need to related forward enspoint references with
+ * callback endpoints and forward endpoints with callback endpoint references. Here's the model...
+ *
+ * Client Component Target Component
+ * Reference (with callback iface) Service (with callback iface)
+ * EndpointReference ----------------------------------> Endpoint
+ * | |
+ * | |
+ * Service \/ (for the callback) Reference \/ (for the callback)
+ * Endpoint <--------------------------------------------EndpointReference
+ *
+ * TODO - there are issues here with callback binding multiplicities and which callback
+ * endpoint is associated with which endpointreference
+ *
+ * @param reference
+ * @param component
+ */
+ private void fixUpCallbackLinks (Component component, ComponentReference reference){
+
+ // fix up the links between endpoint references and endpoints that represent callbacks
+ // [rfeng] Populate the callback endpoints
+ if (reference.getCallbackService() != null) {
+ List<Endpoint> callbackEndpoints = reference.getCallbackService().getEndpoints();
+ if (!callbackEndpoints.isEmpty()) {
+ for (EndpointReference endpointReference : reference.getEndpointReferences()){
+ // [rfeng] FIXME: how to select the callback endpoints?
+ endpointReference.setCallbackEndpoint(callbackEndpoints.get(0));
+ }
+ }
+ }
+
+ // fix up links between endpoints and endpoint references that represent callbacks
+ for (ComponentService service : component.getServices()) {
+ if ((service.getInterfaceContract() != null) && (service.getInterfaceContract()
+ .getCallbackInterface() != null)) {
+ if (reference.getName().equals(service.getName())) {
+ for (Endpoint endpoint : service.getEndpoints()) {
+ endpoint.getCallbackEndpointReferences().addAll(reference
+ .getEndpointReferences());
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ //=========================================================================
+ // methods below related to build time matching which is currently disabled
+/*
+ private void populateLocalRegistry(Composite composite, EndpointRegistry registry, BuilderContext context){
+ for (Component component : composite.getComponents()) {
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ populateLocalRegistry((Composite)implementation, registry, context);
+ }
+
+ for (ComponentService service : component.getServices()) {
+ for (Endpoint endpoint : service.getEndpoints()){
+ registry.addEndpoint(endpoint);
+ }
+ }
+
+
+ for (ComponentReference reference : component.getReferences()) {
+ for (EndpointReference epr : reference.getEndpointReferences()){
+ registry.addEndpointReference(epr);
+ }
+ }
+
+ // remove all autowire place holders so they don't cause wires to be created
+ // have to pass in reference as we don't have access to the registry in
+ // the builders
+ for (EndpointReference epr : registry.getEndpointReferences()){
+ if (epr.getStatus() == EndpointReference.Status.AUTOWIRE_PLACEHOLDER){
+ epr.getReference().getEndpointReferences().remove(epr);
+ }
+ }
+ }
+ }
+
+ private void matchEndpointReferences(Composite composite, EndpointRegistry registry, BuilderContext context){
+
+ // look at all the endpoint references and try to match them to
+ // endpoints
+ for (EndpointReference endpointReference : registry.getEndpointReferences()){
+ endpointReferenceBinder.bindBuildTime(registry, endpointReference);
+ }
+ }
+*/
+
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/IntentValidator.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/IntentValidator.java
new file mode 100644
index 0000000000..b2f7a4ceed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/IntentValidator.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Intent Validator
+ */
+public class IntentValidator implements PolicyBuilder {
+
+ /**
+ * Defaut constructor
+ * @param registry Extension Registry
+ */
+ public IntentValidator(ExtensionPointRegistry registry) {
+ super();
+ }
+
+ public boolean build(Endpoint endpoint, BuilderContext context) {
+ return checkMutualExclusion(endpoint, context);
+ }
+
+ public boolean build(EndpointReference endpointReference, BuilderContext context) {
+ boolean ok = checkMutualExclusion(endpointReference, context);
+ if(!ok) {
+ return false;
+ }
+
+ Endpoint endpoint = endpointReference.getTargetEndpoint();
+ if (endpoint == null) {
+ return true;
+ }
+ ok = checkMutualExclusion(endpointReference, endpoint, context);
+ List<Intent> intentList1 = endpointReference.getRequiredIntents();
+ List<Intent> intentList2 = endpoint.getRequiredIntents();
+ return ok;
+ }
+
+ public boolean build(Component component, Implementation implementation, BuilderContext context) {
+ return true;
+ }
+
+ public boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context) {
+ return true;
+ }
+
+ public QName getPolicyType() {
+ return null;
+ }
+
+ public List<QName> getSupportedBindings() {
+ return null;
+ }
+
+ /**
+ * Check if two policy subjects requires multually exclusive intents
+ * @param subject1
+ * @param subject2
+ * @param monitor
+ * @return
+ */
+ private boolean checkMutualExclusion(PolicySubject subject1, PolicySubject subject2, BuilderContext context) {
+ if (subject1 == subject2 || subject1 == null || subject2 == null) {
+ return false;
+ }
+ for (Intent i1 : subject1.getRequiredIntents()) {
+ for (Intent i2 : subject2.getRequiredIntents()) {
+ if (i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1)) {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "MutuallyExclusiveIntents",
+ new Object[] {subject1, subject2},
+ i1,
+ i2);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean checkMutualExclusion(PolicySubject subject, BuilderContext context) {
+ if (subject == null) {
+ return false;
+ }
+ List<Intent> intents = subject.getRequiredIntents();
+ int size = intents.size();
+ for (int i = 0; i < size; i++) {
+ for (int j = i + 1; j < size; j++) {
+ Intent i1 = intents.get(i);
+ Intent i2 = intents.get(j);
+ if (i1 != i2 && i1.getExcludedIntents().contains(i2) || i2.getExcludedIntents().contains(i1)) {
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "MutuallyExclusiveIntents",
+ subject,
+ i1,
+ i2);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
new file mode 100644
index 0000000000..cf1c9cb05f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+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.FactoryExtensionPoint;
+
+public class ModelBuilderImpl implements CompositeBuilder {
+ private ExtensionPointRegistry registry;
+
+ private CompositeBuilder compositeIncludeBuilder;
+ private CompositeBuilder compositeCloneBuilder;
+ private CompositeComponentTypeBuilderImpl compositeComponentTypeBuilder;
+ private ComponentBuilderImpl componentBuilder;
+
+ private CompositeBuilder structuralURIBuilder;
+ private BindingURIBuilderImpl bindingURIBuilder;
+ private ComponentServiceBindingBuilderImpl componentServiceBindingBuilder;
+ private ComponentReferenceBindingBuilderImpl componentReferenceBindingBuilder;
+ private CompositeBuilder compositeWireApplier;
+ private EndpointBuilderImpl endpointBuilder;
+ private EndpointReferenceBuilderImpl endpointReferenceBuilder;
+
+ private CompositeBuilder policyAttachmentBuilder;
+ private CompositePolicyBuilderImpl compositePolicyBuilder;
+
+ /**
+ * Constructs a new composite builder.
+ *
+ * @param registry the extension point registry
+ */
+ public ModelBuilderImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+
+ compositeIncludeBuilder = new CompositeIncludeBuilderImpl();
+ compositeCloneBuilder = new CompositeCloneBuilderImpl();
+
+ compositeComponentTypeBuilder = new CompositeComponentTypeBuilderImpl(registry);
+ componentBuilder = new ComponentBuilderImpl(registry);
+
+ compositeComponentTypeBuilder.setComponentBuilder(componentBuilder);
+ componentBuilder.setComponentTypeBuilder(compositeComponentTypeBuilder);
+
+ structuralURIBuilder = new StructuralURIBuilderImpl(registry);
+ bindingURIBuilder = new BindingURIBuilderImpl(registry);
+ componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(registry);
+ componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(registry);
+ compositeWireApplier = new CompositeWireApplierImpl(registry);
+ endpointBuilder = new EndpointBuilderImpl(registry);
+ endpointReferenceBuilder = new EndpointReferenceBuilderImpl(registry);
+
+ policyAttachmentBuilder = new PolicyAttachmentBuilderImpl(registry);
+ compositePolicyBuilder = new CompositePolicyBuilderImpl(registry);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositeBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ try {
+ // Clone the composites that are included or referenced in implementation.composite
+ composite = compositeCloneBuilder.build(composite, context);
+
+ // Collect and fuse includes. Copy all of the components
+ // out of the included composite into the including composite
+ // and discards the included composite
+ composite = compositeIncludeBuilder.build(composite, context);
+
+ // Set up the structural URIs for components (services/references/bindings)
+ composite = structuralURIBuilder.build(composite, context);
+
+ // Apply policy external attachment. Happens before the composite type
+ // is created so that suitable promotion and structural processing is
+ // applied to the attached policies
+ // TODO - Can you attach a policy to a component and have it promoted to the
+ // components services and references. If yes this call is in the
+ // right place
+ composite = policyAttachmentBuilder.build(composite, context);
+
+ // Process the implementation hierarchy by calculating the component type
+ // for the top level implementation (composite). This has the effect of
+ // recursively calculating component types and configuring the
+ // components that depend on them
+ compositeComponentTypeBuilder.createComponentType(null, composite, context);
+
+ // Calculate the URI associated with service bindings
+ composite = bindingURIBuilder.build(composite, context);
+
+ // perform any binding specific build processing
+ composite = componentServiceBindingBuilder.build(composite, context); // binding specific build
+ composite = componentReferenceBindingBuilder.build(composite, context); // binding specific build
+
+ // calculate which reference targets are implied by the wire elements
+ // that can appear at the composite level
+ composite = compositeWireApplier.build(composite, context);
+
+ // compute all the service endpoints
+ endpointBuilder.build(composite, context);
+
+ // compute all the reference endpoint references
+ endpointReferenceBuilder.build(composite, context);
+
+ // calculate intents and policy sets across the model hierarchy
+ // relies on the endpoints and endpoint references having been calculated
+ composite = compositePolicyBuilder.build(composite, context);
+
+ // For debugging - in success cases
+ //System.out.println(dumpBuiltComposite(composite));
+
+ return composite;
+ } catch (Exception e) {
+ // For debugging - in failure cases
+ //System.out.println(dumpBuiltComposite(composite));
+ throw new CompositeBuilderException("Exception while building model " + composite.getName(), e);
+ }
+ }
+
+ /**
+ * For debugging the build process
+ *
+ * @return a tring version of the built model
+ */
+ public String dumpBuiltComposite(Composite composite) {
+
+ StAXArtifactProcessorExtensionPoint xmlProcessors =
+ registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<Composite> compositeProcessor =
+ xmlProcessors.getProcessor(Composite.class);
+
+ return writeComposite(composite, compositeProcessor);
+ }
+
+ private String writeComposite(Composite composite, StAXArtifactProcessor<Composite> compositeProcessor){
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLOutputFactory outputFactory =
+ registry.getExtensionPoint(FactoryExtensionPoint.class)
+ .getFactory(XMLOutputFactory.class);
+
+ try {
+ compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(registry));
+ } catch(Exception ex) {
+ return ex.toString();
+ }
+
+ String result = bos.toString();
+
+ // write out and nested composites
+ for (Component component : composite.getComponents()) {
+ if (component.getImplementation() instanceof Composite) {
+ result += "\n<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->\n" +
+ writeComposite((Composite)component.getImplementation(),
+ compositeProcessor);
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java
new file mode 100644
index 0000000000..c9cd6b36d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A builder that checks that policy sets apply to the elements to which they are attached.
+ * Any that don't are removed. It first creates a DOM model for the composite so that the xpath
+ * expression can be evaluated. For each element that holds a policy set is calculates the
+ * appliesTo nodes and checks that the current element is in the set. If not the policySet is
+ * removed from the element
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyAppliesToBuilderImpl extends PolicyAttachmentBuilderImpl {
+
+ public PolicyAppliesToBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.policy.builder.PolicyAppliesToBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ try {
+ // create a DOM for the Domain Composite Infoset
+ Document document = saveAsDOM(composite);
+
+ // create a cache of evaluated node against each policy set so we don't
+ // have to keep evaluating policy sets that appear in multiple places
+ Map<PolicySet, List<PolicySubject>> appliesToSubjects = new HashMap<PolicySet, List<PolicySubject>>();
+
+ // for all implementations, endpoint and endpoint references check that
+ // the policy sets validly apply
+ return checkAppliesTo(document, appliesToSubjects, composite, context);
+
+ } catch (Exception e) {
+ throw new CompositeBuilderException(e);
+ }
+ }
+
+ private Composite checkAppliesTo(Document document, Map<PolicySet, List<PolicySubject>> appliesToSubjects, Composite topComposite, BuilderContext context) throws Exception {
+
+ for ( Component component : topComposite.getComponents() ) {
+ if ( component.getImplementation() instanceof Composite ) {
+ Composite nested = (Composite) component.getImplementation();
+ checkAppliesTo(saveAsDOM(nested),new HashMap<PolicySet, List<PolicySubject>>(), nested, context );
+ }
+ }
+
+ for (Component component : topComposite.getComponents()) {
+
+ for (ComponentService componentService : component.getServices()) {
+ for (Endpoint ep : componentService.getEndpoints()) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, (PolicySubject)ep.getService(), ep.getPolicySets());
+ if (ep.getBinding() instanceof PolicySubject) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, (PolicySubject)ep.getBinding(), ep.getPolicySets());
+ }
+ }
+ }
+
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, (PolicySubject)epr.getReference(), epr.getPolicySets());
+ if (epr.getBinding() instanceof PolicySubject) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, (PolicySubject)epr.getBinding(), epr.getPolicySets());
+ }
+ }
+ }
+
+ Implementation implementation = component.getImplementation();
+ if (implementation != null &&
+ implementation instanceof PolicySubject) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, implementation, implementation.getPolicySets());
+ }
+ }
+
+ return topComposite;
+ }
+
+
+ /**
+ * Checks that all the provided policy sets apply to the provided policy subject
+ *
+ * @param document
+ * @param appliesToSubjects
+ * @param policySubject
+ * @param policySets
+ * @return
+ * @throws Exception
+ */
+ private void checkAppliesToSubject(Document document, Map<PolicySet, List<PolicySubject>> appliesToSubjects, Composite composite, PolicySubject policySubject, List<PolicySet> policySets) throws Exception {
+ List<PolicySet> policySetsToRemove = new ArrayList<PolicySet>();
+
+ for (PolicySet policySet : policySets){
+ List<PolicySubject> subjects = appliesToSubjects.get(policySet);
+
+ if (subjects == null){
+ XPathExpression appliesTo = policySet.getAppliesToXPathExpression();
+ if (appliesTo != null) {
+ NodeList nodes = (NodeList)appliesTo.evaluate(document, XPathConstants.NODESET);
+
+ if (nodes.getLength() > 0){
+ subjects = new ArrayList<PolicySubject>();
+ appliesToSubjects.put(policySet, subjects);
+ }
+
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ String index = getStructuralURI(node);
+ PolicySubject subject = lookup(composite, index);
+ if ( subject != null )
+ subjects.add(subject);
+ }
+ }
+ }
+
+ if (subjects != null){
+ if (!subjects.contains(policySubject)){
+ policySetsToRemove.add(policySet);
+ }
+ }
+
+ // TODO - If no "appliesTo" is provided does the policy set apply to
+ // everything or nothing?
+
+ }
+
+ policySets.removeAll(policySetsToRemove);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
new file mode 100644
index 0000000000..4d1a7d52b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
@@ -0,0 +1,389 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+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.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.ExternalAttachment;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * A builder that attaches policy sets to the domain composite using the xpath defined by
+ * the attachTo attribute. It first creates a DOM model for the composite so that the xpath
+ * expression can be evaluated. For the nodes selected by the xpath, caluclate the element
+ * URI and add the policy set into the composite model
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyAttachmentBuilderImpl implements CompositeBuilder {
+ protected static final String BUILDER_VALIDATION_BUNDLE = "org.apache.tuscany.sca.builder.builder-validation-messages";
+
+ protected StAXHelper staxHelper;
+ protected DOMHelper domHelper;
+ protected ExtensionPointRegistry registry;
+ protected StAXArtifactProcessor<Composite> processor;
+
+ public PolicyAttachmentBuilderImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ domHelper = DOMHelper.getInstance(registry);
+ staxHelper = StAXHelper.getInstance(registry);
+ StAXArtifactProcessorExtensionPoint processors =
+ registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ processor = processors.getProcessor(Composite.class);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.policy.builder.PolicyAttachmentBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ try {
+ Composite patched = applyXPath(composite, context.getDefinitions(), context.getMonitor());
+ return patched;
+ } catch (Exception e) {
+ throw new CompositeBuilderException(e);
+ }
+ }
+
+ /**
+ * Apply the attachTo XPath against the composite model
+ * @param composite The orginal composite
+ * @param definitions SCA definitions that contain the policy sets
+ * @param monitor The monitor
+ * @return A reloaded composite
+ * @throws Exception
+ */
+ private Composite applyXPath(Composite composite, Definitions definitions, Monitor monitor) throws Exception {
+
+ monitor.pushContext("Composite: " + composite.getName().toString());
+
+ try {
+ if (definitions == null || (definitions.getPolicySets().isEmpty() && definitions.getExternalAttachments().isEmpty()) ) {
+ return composite;
+ }
+
+
+ Document document = null;
+
+ for (PolicySet ps : definitions.getPolicySets()) {
+ XPathExpression exp = ps.getAttachToXPathExpression();
+ if ( exp != null ) {
+ if ( document == null ) {
+ document = saveAsDOM(composite);
+ }
+ NodeList nodes = (NodeList) exp.evaluate(document, XPathConstants.NODESET);
+ attachPolicySetToNodes(composite, monitor, nodes, ps);
+ }
+ }
+
+ for ( ExternalAttachment ea : definitions.getExternalAttachments() ) {
+ XPathExpression exp = ea.getAttachToXPathExpression();
+ if ( exp != null ) {
+ if ( document == null ) {
+ document = saveAsDOM(composite);
+ }
+ NodeList nodes = (NodeList) exp.evaluate(document, XPathConstants.NODESET);
+ for ( PolicySet ps : ea.getPolicySets() ) {
+ attachPolicySetToNodes(composite, monitor, nodes, ps);
+ }
+ }
+ }
+
+ // Recursively apply the xpath against the composites referenced by <implementation.composite>
+ // If the composite or component has policy sets attached, we have to ignore policy sets
+ // attached to the inner composite.
+ if ( composite.getPolicySets().isEmpty() ) {
+ for (Component component : composite.getComponents()) {
+ if ( component.getPolicySets().isEmpty() ) {
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ Composite patched = applyXPath((Composite)impl, definitions, monitor);
+ if (patched != impl) {
+ component.setImplementation(patched);
+ }
+ }
+ }
+ }
+ }
+
+ return composite;
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ private void attachPolicySetToNodes(Composite composite,
+ Monitor monitor, NodeList nodes, PolicySet ps) {
+
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+
+ if ( isAttachedToProperty(node) ) {
+ Monitor.error(monitor,
+ this,
+ BUILDER_VALIDATION_BUNDLE,
+ "PolicyAttachedToProperty",
+ ps.getName().toString());
+ }
+
+
+ // The node can be a component, service, reference or binding
+ String index = getStructuralURI(node);
+ PolicySubject subject = lookup(composite, index);
+ if (subject != null) {
+ ps.setIsExternalAttachment(true);
+ // Remove any PolicySets with the same name that may have been added
+ List<PolicySet> subjectPSCopy = new ArrayList<PolicySet>(subject.getPolicySets());
+ for ( PolicySet existingPS : subjectPSCopy ) {
+ if ( existingPS.getName().equals(ps.getName()) ) {
+ subject.getPolicySets().remove(existingPS);
+ }
+ }
+ subject.getPolicySets().add(ps);
+ } else {
+ // raise a warning that the XPath node didn't match a node in the
+ // models
+ Monitor.warning(monitor,
+ this,
+ BUILDER_VALIDATION_BUNDLE,
+ "PolicyDOMModelMissmatch",
+ ps.getName().toString(),
+ index);
+ }
+
+ }
+ }
+
+ /**
+ * POL_40002 - you can't attach a policy to a property node
+ * or one of it's children. walk backwards up the node tree
+ * looking for an element called property and raise an error
+ * if we find one
+ * @param node
+ * @return
+ */
+ private boolean isAttachedToProperty(Node node) {
+
+ Node testNode = node;
+ while (testNode != null){
+ if ((node.getNodeType() == Node.ELEMENT_NODE) &&
+ (node.getLocalName().equals("property"))){
+ return true;
+ }
+ testNode = testNode.getParentNode();
+ }
+ return false;
+ }
+
+ protected Document saveAsDOM(Composite composite) throws XMLStreamException, ContributionWriteException, IOException,
+ SAXException {
+ // First write the composite into a DOM document so that we can apply the xpath
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter writer = staxHelper.createXMLStreamWriter(sw);
+ // Write the composite into a DOM document
+ processor.write(composite, writer, new ProcessorContext(registry));
+ writer.close();
+
+ Document document = domHelper.load(sw.toString());
+
+ // Debugging
+ //System.out.println("<!-- DOM to which XPath will be applies is -->\n" + sw.toString());
+
+ return document;
+ }
+
+ private static final QName COMPONENT = new QName(Base.SCA11_NS, "component");
+ private static final QName SERVICE = new QName(Base.SCA11_NS, "service");
+ private static final QName REFERENCE = new QName(Base.SCA11_NS, "reference");
+
+ protected static String getStructuralURI(Node node) {
+ if (node != null) {
+ QName name = new QName(node.getNamespaceURI(), node.getLocalName());
+ if (COMPONENT.equals(name)) {
+ Element element = (Element)node;
+ return element.getAttributeNS(null, "uri");
+ } else if (SERVICE.equals(name)) {
+ Element component = (Element)node.getParentNode();
+ String uri = component.getAttributeNS(null, "uri");
+ String service = ((Element)node).getAttributeNS(null, "name");
+ return uri + "#service(" + service + ")";
+ } else if (REFERENCE.equals(name)) {
+ Element component = (Element)node.getParentNode();
+ String uri = component.getAttributeNS(null, "uri");
+ String reference = ((Element)node).getAttributeNS(null, "name");
+ return uri + "#reference(" + reference + ")";
+ } else if ( new QName(Base.SCA11_NS, "composite").equals(name)) {
+ return "";
+ } else {
+ String localName = node.getLocalName();
+ if (localName.startsWith("binding.")) {
+ String bindingName = ((Element)node).getAttributeNS(null, "name");
+ Element contract = (Element)node.getParentNode();
+ String contractName = contract.getAttributeNS(null, "name");
+ Element component = (Element)node.getParentNode().getParentNode();
+ String uri = component.getAttributeNS(null, "uri");
+ return uri + "#" + contract.getLocalName() + "(" + contractName + "/" + bindingName + ")";
+ } else if (localName.startsWith("implementation.")) {
+ Element component = (Element)node.getParentNode();
+ String uri = component.getAttributeNS(null, "uri");
+ return uri + "#implementation()";
+ } else if (localName.startsWith("interface.")) {
+ Element contract = (Element)node.getParentNode();
+ String contractName = contract.getAttributeNS(null, "name");
+ Element component = (Element)node.getParentNode().getParentNode();
+ String uri = component.getAttributeNS(null, "uri");
+ return uri + "#" + contractName + "#interface()"; //(" + contractName + "/" + interfaceName + ")"
+ }
+ }
+ }
+ return null;
+ }
+
+ protected Binding getBinding(Contract contract, String name) {
+ for (Binding binding : contract.getBindings()) {
+ if (name.equals(binding.getName())) {
+ return binding;
+ }
+ }
+ return null;
+ }
+
+ protected PolicySubject lookup(Composite composite, String structuralURI) {
+ if (structuralURI == null) {
+ return null;
+ } else if ( structuralURI.equals("")) {
+ return composite;
+ }
+ int index = structuralURI.indexOf('#');
+ String componentURI = structuralURI;
+ String service = null;
+ String reference = null;
+ String binding = null;
+ boolean isInterface = false;
+ boolean impl = false;
+
+ if (index != -1) {
+ componentURI = structuralURI.substring(0, index);
+ String fragment = structuralURI.substring(index + 1);
+ int begin = fragment.indexOf('(');
+ int end = fragment.indexOf(')');
+ if (begin != -1 && end != -1) {
+ String path = fragment.substring(begin + 1, end).trim();
+ String prefix = fragment.substring(0, begin).trim();
+ if (prefix.equals("implementation")) {
+ impl = true;
+ } else {
+ int pos = path.indexOf('/');
+ if (pos != -1) {
+ binding = path.substring(pos + 1);
+ path = path.substring(0, pos);
+ if ("service-binding".equals(prefix)) {
+ service = path;
+ } else if ("reference-binding".equals(prefix)) {
+ reference = path;
+ }
+ }
+ if ("service".equals(prefix)) {
+ service = path;
+ } else if ("reference".equals(prefix)) {
+ reference = path;
+ } else if ( prefix.indexOf("#interface") != -1 ) {
+ service = prefix.substring(0, prefix.indexOf("#interface"));
+ isInterface = true;
+ }
+ }
+ }
+ }
+ for (Component component : composite.getComponents()) {
+ if (component.getURI().equals(componentURI)) {
+ if (service != null) {
+ ComponentService componentService = component.getService(service);
+ if ( isInterface ) {
+ return componentService.getInterfaceContract().getInterface();
+ } else if (binding != null) {
+ Binding b = getBinding(componentService, binding);
+ if (b instanceof PolicySubject) {
+ return (PolicySubject)b;
+ }
+ } else {
+ return componentService;
+ }
+ } else if (reference != null) {
+ ComponentReference componentReference = component.getReference(reference);
+ if (binding != null) {
+ Binding b = getBinding(componentReference, binding);
+ if (b instanceof PolicySubject) {
+ return (PolicySubject)b;
+ }
+ } else {
+ return componentReference;
+ }
+ } else if (impl) {
+ return component.getImplementation();
+ }
+ return component;
+ } else if (structuralURI.startsWith(component.getURI() + "/")) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ return lookup((Composite)implementation, structuralURI);
+ } else {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
new file mode 100644
index 0000000000..7c2d86862b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * Configuration of binding URIs.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StructuralURIBuilderImpl implements CompositeBuilder {
+
+ public StructuralURIBuilderImpl(ExtensionPointRegistry registry) {
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.StructualURIBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ configureStructuralURIs(composite,
+ null,
+ context.getDefinitions(),
+ context.getBindingBaseURIs(),
+ context.getMonitor());
+ return composite;
+ }
+
+
+ /**
+ * If a binding name is not provided by the user, construct it based on the service
+ * or reference name
+ *
+ * @param contract the service or reference
+ */
+ private void constructBindingNames(Contract contract, Monitor monitor) {
+ List<Binding> bindings = contract.getBindings();
+ Map<String, Binding> bindingMap = new HashMap<String, Binding>();
+ for (Binding binding : bindings) {
+ // set the default binding name if one is required
+ // if there is no name on the binding then set it to the service or reference name
+ if (binding.getName() == null) {
+ binding.setName(contract.getName());
+ }
+ Binding existed = bindingMap.put(binding.getName(), binding);
+ // Check that multiple bindings do not have the same name
+ if (existed != null && existed != binding) {
+ if (contract instanceof Service) {
+ Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "MultipleBindingsForService", contract
+ .getName(), binding.getName());
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "MultipleBindingsForReference",
+ contract.getName(),
+ binding.getName());
+ }
+ }
+ }
+
+ if (contract.getCallback() != null) {
+ bindings = contract.getCallback().getBindings();
+ bindingMap.clear();
+ for (Binding binding : bindings) {
+ // set the default binding name if one is required
+ // if there is no name on the binding then set it to the service or reference name
+ if (binding.getName() == null) {
+ binding.setName(contract.getName());
+ }
+ Binding existed = bindingMap.put(binding.getName(), binding);
+ // Check that multiple bindings do not have the same name
+ if (existed != null && existed != binding) {
+ if (contract instanceof Service) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "MultipleBindingsForServiceCallback",
+ contract.getName(),
+ binding.getName());
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "MultipleBindingsForReferenceCallback",
+ contract.getName(),
+ binding.getName());
+ }
+ }
+ }
+ }
+ }
+
+ private void configureStructuralURIs(Composite composite,
+ String parentComponentURI,
+ Definitions definitions,
+ Map<QName, List<String>> defaultBindings,
+ Monitor monitor) throws CompositeBuilderException {
+
+ monitor.pushContext("Composite: " + composite.getName().toString());
+ try {
+ for (Service service : composite.getServices()) {
+ constructBindingNames(service, monitor);
+ }
+
+ for (Reference reference : composite.getReferences()) {
+ constructBindingNames(reference, monitor);
+ }
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ // Initialize component URI
+ String componentURI;
+ if (parentComponentURI == null) {
+ componentURI = component.getName();
+ } else {
+ componentURI = parentComponentURI + '/' + component.getName();
+ }
+ component.setURI(componentURI);
+
+ monitor.pushContext("Component: " + component.getName());
+ try {
+ for (ComponentService service : component.getServices()) {
+ constructBindingNames(service, monitor);
+ }
+ for (ComponentReference service : component.getReferences()) {
+ constructBindingNames(service, monitor);
+ }
+ } finally {
+ monitor.popContext();
+ }
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ // Process nested composite
+ configureStructuralURIs((Composite)implementation,
+ componentURI,
+ definitions,
+ defaultBindings,
+ monitor);
+ }
+ }
+
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/WireBuilderImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/WireBuilderImpl.java
new file mode 100644
index 0000000000..21725fb1b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/WireBuilderImpl.java
@@ -0,0 +1,1028 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Creates endpoint reference models.
+ */
+public class WireBuilderImpl {
+
+ private AssemblyFactory assemblyFactory;
+ private InterfaceContractMapper interfaceContractMapper;
+
+ public WireBuilderImpl(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ }
+
+ /**
+ * Create endpoint references for all component references.
+ *
+ * @param composite
+ */
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ Monitor monitor = context.getMonitor();
+
+ // process component references
+ processComponentReferences(composite, monitor);
+
+ // validate component references
+ validateComponentReferences(composite, monitor);
+
+ return composite;
+ }
+
+ private void processComponentReferences(Composite composite, Monitor monitor) {
+
+ monitor.pushContext("Composite: " + composite.getName().toString());
+ try {
+ // Index components, services and references
+ Map<String, Component> components = new HashMap<String, Component>();
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
+
+ // Connect component references as described in wires
+ connectWires(composite, componentServices, componentReferences, monitor);
+
+ // create endpoint references for each component's references
+ for (Component component : composite.getComponents()) {
+ monitor.pushContext("Component: " + component.getName());
+
+ try {
+
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ processComponentReferences((Composite)implementation, monitor);
+ }
+
+ // create endpoint references to represent the component reference
+ for (ComponentReference reference : component.getReferences()) {
+ createReferenceEndpointReferences(composite,
+ component,
+ reference,
+ components,
+ componentServices,
+ monitor);
+
+ // fix up links between endpoints and endpoint references that represent callbacks
+ for (ComponentService service : component.getServices()) {
+ if ((service.getInterfaceContract() != null) && (service.getInterfaceContract()
+ .getCallbackInterface() != null)) {
+ if (reference.getName().equals(service.getName())) {
+ for (Endpoint endpoint : service.getEndpoints()) {
+ endpoint.getCallbackEndpointReferences().addAll(reference
+ .getEndpointReferences());
+ }
+ break;
+ } // end if
+ } // end if
+ } // end for
+
+ // push down endpoint references into the leaf component references
+ // in the case where this component reference promotes a reference from
+ // a composite implementation
+ pushDownEndpointReferences(composite,
+ component,
+ reference,
+ monitor);
+
+ } // end for
+
+ // Validate that references are wired or promoted, according
+ // to their multiplicity. This validates as we go and catches cases
+ // where a reference has been configured directly incorrectly with its
+ // immediate multiplicity setting. We re-run this validation again later
+ // to catch to more complex cases where reference promotion causes
+ // multiplicity errors.
+ validateReferenceMultiplicity(composite, component, monitor);
+
+ } finally {
+ monitor.popContext();
+ }
+ } // end for
+
+ } finally {
+ monitor.popContext();
+ }
+
+ } // end method processCompoenntReferences
+
+
+ /**
+ * The validate stage is separate from the process stage as enpoint references are
+ * pushed down the hierarchy. We don't know the full set of endpoint references until
+ * all processing is complete. Hence we can't validate as we go
+ *
+ * @param composite
+ * @param monitor
+ */
+ private void validateComponentReferences(Composite composite, Monitor monitor) {
+
+ monitor.pushContext("Composite: " + composite.getName().toString());
+ try {
+ // create endpoint references for each component's references
+ for (Component component : composite.getComponents()) {
+ monitor.pushContext("Component: " + component.getName());
+
+ try {
+
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ validateComponentReferences((Composite)implementation, monitor);
+ }
+ // Validate that references are wired or promoted, according
+ // to their multiplicity
+ validateReferenceMultiplicity(composite, component, monitor);
+
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ } finally {
+ monitor.popContext();
+ }
+
+ }
+
+ protected void indexComponentsServicesAndReferences(Composite composite,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences) {
+
+ for (Component component : composite.getComponents()) {
+
+ // Index components by name
+ components.put(component.getName(), component);
+
+ ComponentService nonCallbackService = null;
+ int nonCallbackServices = 0;
+ for (ComponentService componentService : component.getServices()) {
+
+ // Index component services by component name / service name
+ String uri = component.getName() + '/' + componentService.getName();
+ componentServices.put(uri, componentService);
+
+ // count how many non-callback services there are
+ // if there is only one the component name also acts as the
+ // service name
+ if (!componentService.isForCallback()) {
+ // Check how many non callback non-promoted services we have
+ if (nonCallbackServices == 0) {
+ nonCallbackService = componentService;
+ }
+ nonCallbackServices++;
+ }
+ }
+
+ if (nonCallbackServices == 1) {
+ // If we have a single non callback service, index it by
+ // component name as well
+ componentServices.put(component.getName(), nonCallbackService);
+ }
+
+ // Index references by component name / reference name
+ for (ComponentReference componentReference : component.getReferences()) {
+ String uri = component.getName() + '/' + componentReference.getName();
+ componentReferences.put(uri, componentReference);
+ }
+ }
+ }
+
+ /**
+ * Resolve wires and connect the sources to their targets
+ *
+ * @param composite
+ * @param componentServices
+ * @param componentReferences
+ * @param problems
+ */
+ private void connectWires(Composite composite,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences,
+ Monitor monitor) {
+
+ // For each wire, resolve the source reference, the target service, and
+ // add it to the list of targets of the reference
+ List<Wire> wires = composite.getWires();
+ for (int i = 0, n = wires.size(); i < n; i++) {
+ Wire wire = wires.get(i);
+
+ ComponentReference resolvedReference;
+ ComponentService resolvedService;
+
+ // Resolve the source reference
+ ComponentReference source = wire.getSource();
+ if (source != null && source.isUnresolved()) {
+ resolvedReference = componentReferences.get(source.getName());
+ if (resolvedReference != null) {
+ wire.setSource(resolvedReference);
+ } else {
+ Monitor.warning(monitor, this, Messages.ASSEMBLY_VALIDATION, "WireSourceNotFound", source
+ .getName());
+ }
+ } else {
+ resolvedReference = wire.getSource();
+ }
+
+ // Resolve the target service
+ ComponentService target = wire.getTarget();
+ if (target != null && target.isUnresolved()) {
+ resolvedService = componentServices.get(target.getName());
+ if (resolvedService != null) {
+ wire.setTarget(target);
+ } else {
+ Monitor.warning(monitor, this, Messages.ASSEMBLY_VALIDATION, "WireTargetNotFound", target
+ .getName());
+ }
+ } else {
+ resolvedService = wire.getTarget();
+ }
+
+ // Add the target service to the list of targets of the
+ // reference
+ if (resolvedReference != null && resolvedService != null) {
+ // Check that the target component service provides
+ // a superset of
+ // the component reference interface
+ if (resolvedReference.getInterfaceContract() == null || interfaceContractMapper
+ .isCompatibleSubset(resolvedReference.getInterfaceContract(), resolvedService.getInterfaceContract())) {
+
+ //resolvedReference.getTargets().add(resolvedService);
+ if (wire.isReplace()) {
+ resolvedReference.getTargets().clear();
+ }
+ resolvedReference.getTargets().add(wire.getTarget());
+ } else {
+ Monitor.warning(monitor, this, Messages.ASSEMBLY_VALIDATION, "WireIncompatibleInterface", source
+ .getName(), target.getName());
+ }
+ }
+ }
+
+ // Clear the list of wires
+ composite.getWires().clear();
+ }
+
+ private void createReferenceEndpointReferences(Composite composite,
+ Component component,
+ ComponentReference reference,
+ Map<String, Component> components,
+ Map<String, ComponentService> componentServices,
+ Monitor monitor) {
+
+ monitor.pushContext("Reference: " + reference.getName());
+
+ // Get reference targets
+ List<ComponentService> refTargets = getReferenceTargets(reference);
+ if (Boolean.TRUE.equals(reference.getAutowire()) && reference.getTargets().isEmpty()) {
+
+ // Find suitable targets in the current composite for an
+ // autowired reference
+ Multiplicity multiplicity = reference.getMultiplicity();
+ for (Component targetComponent : composite.getComponents()) {
+
+ // Tuscany specific selection of the first autowire reference
+ // when there are more than one (ASM_60025)
+ if ((multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) && (reference
+ .getEndpointReferences().size() != 0)) {
+ break;
+ }
+
+ // Prevent autowire connecting to self
+ if (targetComponent == component)
+ continue;
+
+ for (ComponentService targetComponentService : targetComponent.getServices()) {
+ if (reference.getInterfaceContract() == null || interfaceContractMapper.isCompatibleSubset(reference
+ .getInterfaceContract(), targetComponentService.getInterfaceContract())) {
+
+ if (intentsMatch(reference.getRequiredIntents(), targetComponentService.getRequiredIntents())) {
+ EndpointReference endpointRef = createEndpointRef(component, reference, false);
+ endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_READY_FOR_MATCHING);
+ reference.getEndpointReferences().add(endpointRef);
+
+ // Stop with the first match for 0..1 and 1..1 references
+ if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) {
+ break;
+ } // end if
+ }
+
+ } // end if
+ } // end for
+ } // end for
+
+ if (multiplicity == Multiplicity.ONE_N || multiplicity == Multiplicity.ONE_ONE) {
+ if (reference.getEndpointReferences().size() == 0) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "NoComponentReferenceTarget",
+ reference.getName());
+ }
+ }
+
+ setSingleAutoWireTarget(reference);
+
+ } else if (!refTargets.isEmpty()) {
+ // Check that the component reference does not mix the use of endpoint references
+ // specified via the target attribute with the presence of binding elements
+ if (bindingsIdentifyTargets(reference)) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceEndPointMixWithTarget",
+ composite.getName().toString(),
+ component.getName(),
+ reference.getName());
+ }
+
+ // Resolve targets specified on the component reference
+ for (ComponentService target : refTargets) {
+
+ String targetName = getComponentServiceName(target.getName());
+ String bindingName = getBindingName(target.getName());
+ ComponentService targetComponentService = componentServices.get(targetName);
+
+ Component targetComponent = getComponentFromTargetName(components, targetName);
+
+ if (targetComponentService != null) {
+ // Check that target component service provides a superset of the component reference interface
+ if (reference.getInterfaceContract() == null || interfaceContractMapper.isCompatibleSubset(reference
+ .getInterfaceContract(), targetComponentService.getInterfaceContract())) {
+
+ if (bindingName != null) {
+ // the user has selected a binding as part of the target name
+ Binding targetBinding = null;
+
+ for (Binding tmp : targetComponentService.getBindings()) {
+ if (tmp.getName().equals(bindingName)) {
+ targetBinding = tmp;
+ continue;
+ }
+ }
+
+ if (targetBinding != null) {
+ EndpointReference endpointRef = createEndpointRef(component, reference, false);
+ endpointRef.setTargetEndpoint(createEndpoint(targetComponent,
+ targetComponentService,
+ targetBinding,
+ true));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ // relying on the registry here to resolve the real endpoint
+ reference.getEndpointReferences().add(endpointRef);
+
+ } else {
+ EndpointReference endpointRef = createEndpointRef(component, reference, true);
+ endpointRef.setTargetEndpoint(createEndpoint(component, targetName));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
+ reference.getEndpointReferences().add(endpointRef);
+ Monitor.warning(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ComponentReferenceTargetNotFound",
+ composite.getName().toString(),
+ targetName);
+ }
+
+ } else {
+ // the user hasn't selected a binding as part of the target name
+
+ EndpointReference endpointRef = createEndpointRef(component, reference, false);
+ endpointRef
+ .setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_READY_FOR_MATCHING);
+ reference.getEndpointReferences().add(endpointRef);
+ }
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceIncompatibleInterface",
+ composite.getName().toString(),
+ component.getName() + "." + reference.getName(),
+ targetName);
+ }
+ } else {
+ // add an unresolved endpoint reference with an unresolved endpoint to go with it
+ EndpointReference endpointRef = createEndpointRef(component, reference, true);
+ endpointRef.setTargetEndpoint(createEndpoint(component, targetName));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
+ reference.getEndpointReferences().add(endpointRef);
+ Monitor.warning(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ComponentReferenceTargetNotFound",
+ composite.getName().toString(),
+ targetName);
+ } // end if
+ } // end for
+ } // end if
+
+ // if no endpoints have found so far the bindings hold the targets.
+ if (reference.getEndpointReferences().isEmpty()) {
+ for (Binding binding : reference.getBindings()) {
+
+ String uri = binding.getURI();
+
+ // user hasn't put a uri on the binding so it's not a target name and the assumption is that
+ // the target is established via configuration of the binding element itself
+ if (uri == null) {
+ // Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets
+ // and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint
+ if (!reference.isForCallback() && (binding instanceof SCABinding))
+ continue;
+
+ // create endpoint reference for manually configured bindings with a resolved endpoint to
+ // signify that this reference is pointing at some unwired endpoint
+ EndpointReference endpointRef = createEndpointRef(component, reference, binding, null, false);
+ if (binding instanceof SCABinding) {
+ // Assume that the system needs to resolve this binding later as
+ // it's the SCA binding
+ endpointRef.setTargetEndpoint(createEndpoint(true));
+ endpointRef.setStatus(EndpointReference.Status.NOT_CONFIGURED);
+ } else {
+ // The user has configured a binding so assume they know what
+ // they are doing and mark in as already resolved.
+ endpointRef.setTargetEndpoint(createEndpoint(false));
+ endpointRef.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ }
+ reference.getEndpointReferences().add(endpointRef);
+ continue;
+ } // end if
+
+ // user might have put a local target name in the uri - see if it refers to a target we know about
+ // - if it does the reference binding will be matched with a service binding
+ // - if it doesn't it is assumed to be an external reference
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+
+ String targetName = getComponentServiceName(uri);
+ String bindingName = getBindingName(uri);
+
+ // Resolve the target component and service
+ ComponentService targetComponentService = componentServices.get(targetName);
+ Component targetComponent = getComponentFromTargetName(components, targetName);
+
+ // If the binding URI matches a component in the composite, configure an endpoint reference with
+ // this component as the target.
+ // If not, the binding URI is assumed to reference an external service
+ if (targetComponentService != null) {
+
+ // Check that the target component service provides
+ // a superset of the component reference interface
+ if (reference.getInterfaceContract() == null || interfaceContractMapper.isCompatibleSubset(reference
+ .getInterfaceContract(), targetComponentService.getInterfaceContract())) {
+ if (bindingName != null) {
+ // the user has selected a binding as part of the target name
+ Binding targetBinding = null;
+
+ for (Binding tmp : targetComponentService.getBindings()) {
+ if (tmp.getName().equals(bindingName)) {
+ targetBinding = tmp;
+ continue;
+ }
+ }
+
+ if (targetBinding != null) {
+ EndpointReference endpointRef = createEndpointRef(component, reference, false);
+ endpointRef.setTargetEndpoint(createEndpoint(targetComponent,
+ targetComponentService,
+ targetBinding,
+ true));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
+ // relying on the registry here to resolve the real endpoint
+ reference.getEndpointReferences().add(endpointRef);
+
+ } else {
+ EndpointReference endpointRef = createEndpointRef(component, reference, true);
+ endpointRef.setTargetEndpoint(createEndpoint(component, targetName));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
+ reference.getEndpointReferences().add(endpointRef);
+ Monitor.warning(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ComponentReferenceTargetNotFound",
+ composite.getName().toString(),
+ targetName);
+ }
+
+ } else {
+ // create endpoint reference with dummy endpoint which will be replaced when policies
+ // are matched and bindings are configured later
+ EndpointReference endpointRef =
+ createEndpointRef(component, reference, binding, null, false);
+ endpointRef
+ .setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
+ endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_READY_FOR_MATCHING);
+ reference.getEndpointReferences().add(endpointRef);
+ }
+ } else {
+ Monitor.warning(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceIncompatibleInterface",
+ composite.getName().toString(),
+ reference.getName(),
+ uri);
+ }
+ } else {
+ // create endpoint reference for manually configured bindings with resolved endpoint
+ // to signify that this reference is pointing at some unwired endpoint. The endpoint
+ // is given the configured binding as a representation of the endpoint configuration.
+ EndpointReference endpointRef = createEndpointRef(component, reference, binding, null, false);
+ Endpoint endpoint = createEndpoint(false);
+ endpoint.setBinding(binding);
+ endpointRef.setTargetEndpoint(endpoint);
+ endpointRef.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ reference.getEndpointReferences().add(endpointRef);
+ } // end if
+ }
+ }
+
+ monitor.popContext();
+
+ } // end method
+
+ private boolean intentsMatch(List<Intent> referenceIntents, List<Intent> serviceIntents) {
+ Set<Intent> referenceIntentSet = new HashSet<Intent>(referenceIntents);
+ Set<Intent> serviceIntentSet = new HashSet<Intent>(serviceIntents);
+ return referenceIntentSet.equals(serviceIntentSet);
+ }
+
+ /**
+ * Reference targets have to be resolved in the context in which they are
+ * defined so they can't be push down the hierarchy during the static build.
+ * So we wait until we have calculated the enpoint references before pushing them
+ * down. Muliplicity errors will be caught by the multiplicity validation check that
+ * comes next
+ *
+ * @param composite
+ * @param component
+ * @param reference
+ * @param monitor
+ */
+ private void pushDownEndpointReferences(Composite composite,
+ Component component,
+ ComponentReference componentReference,
+ Monitor monitor) {
+ Reference reference = componentReference.getReference();
+
+ if (reference instanceof CompositeReference) {
+ List<ComponentReference> leafComponentReferences = getPromotedComponentReferences((CompositeReference)reference);
+
+ // for each leaf component reference copy in the endpoint references for this
+ // higher level (promoting) reference
+ // TODO - the elements are inserted starting at 0 here because the code allows references multiplicity
+ // validation constraints to be broken if the reference is autowire. At runtime the
+ // first one is chosen if max multiplicity is 1. We have an OSOA test that assumes that
+ // promoted references overwrite leaf references. This insert gives the same effect in the
+ // autowire case. We need to think about if there is a more correct answer.
+ for (ComponentReference leafRef : leafComponentReferences){
+ int insertLocation = 0;
+ for (EndpointReference epr : componentReference.getEndpointReferences()){
+ // copy the epr
+ EndpointReference eprCopy = copyHigherReference(epr, leafRef);
+ leafRef.getEndpointReferences().add(insertLocation, eprCopy);
+ insertLocation++;
+ }
+ }
+ }
+
+ // TODO - what to do about callbacks in the reference promotion case
+ }
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @return
+ */
+ private List<ComponentReference> getPromotedComponentReferences(CompositeReference compositeReference) {
+ List<ComponentReference> componentReferences = new ArrayList<ComponentReference>();
+ collectPromotedComponentReferences(compositeReference, componentReferences);
+ return componentReferences;
+ }
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @param componentReferences
+ * @return
+ */
+ private void collectPromotedComponentReferences(CompositeReference compositeReference,
+ List<ComponentReference> componentReferences) {
+ for (ComponentReference componentReference : compositeReference.getPromotedReferences()) {
+ Reference reference = componentReference.getReference();
+ if (reference instanceof CompositeReference) {
+
+ // Continue to follow the reference promotion chain
+ collectPromotedComponentReferences((CompositeReference)reference, componentReferences);
+
+ } else if (reference != null) {
+
+ // Found a non-composite reference
+ componentReferences.add(componentReference);
+ }
+ }
+ }
+
+ /**
+ * Copy a higher level EndpointReference down to a lower level reference which it promotes
+ * @param epRef - the endpoint reference
+ * @param promotedReference - the promoted reference
+ * @return - a copy of the EndpointReference with data merged from the promoted reference
+ */
+ private EndpointReference copyHigherReference(EndpointReference epRef, ComponentReference promotedReference) {
+ EndpointReference epRefClone = null;
+ try {
+ epRefClone = (EndpointReference)epRef.clone();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ // Ignore (we know that EndpointReference2 can be cloned)
+ } // end try
+ // Copy across details of the inner reference
+ // ComponentReference ref = epRefClone.getReference();
+ //FIXME
+ epRefClone.setReference(promotedReference);
+ return epRefClone;
+ }
+
+ private void validateReferenceMultiplicity(Composite composite, Component component, Monitor monitor) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ if (!validateMultiplicity(componentReference.getMultiplicity(),
+ componentReference.getEndpointReferences())) {
+ if (componentReference.getEndpointReferences().isEmpty()) {
+
+ // No error if the reference is promoted out of the current composite
+ boolean promoted = false;
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ if (compositeReference.getPromotedReferences().contains(componentReference)) {
+ promoted = true;
+ break;
+ }
+ }
+ if (!promoted && !componentReference.isForCallback() && !componentReference.isWiredByImpl()) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceWithoutTargets",
+ composite.getName().toString(),
+ componentReference.getName());
+ }
+ } else {
+ // no error if reference is autowire and more targets
+ // than multiplicity have been found
+ if (Boolean.TRUE.equals(componentReference.getAutowire())) {
+ break;
+ }
+
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "TooManyReferenceTargets",
+ componentReference.getName());
+ }
+ }
+ }
+
+ }
+
+ private boolean validateMultiplicity(Multiplicity multiplicity, List<EndpointReference> endpointReferences) {
+
+ // In some tests multiplicity is not set
+ if (multiplicity == null) {
+ return true;
+ }
+
+ // Count targets
+ int count = endpointReferences.size();
+
+ switch (multiplicity) {
+ case ZERO_N:
+ break;
+ case ZERO_ONE:
+ if (count > 1) {
+ return false;
+ }
+ break;
+ case ONE_ONE:
+ if (count != 1) {
+ return false;
+ }
+ break;
+ case ONE_N:
+ if (count < 1) {
+ return false;
+ }
+ break;
+ }
+ return true;
+ }
+
+ /**
+ * Evaluates whether the bindings attached to a reference identify one or more target services.
+ * @param reference - the reference
+ * @return true if the bindings identify a target, false otherwise
+ */
+ private boolean bindingsIdentifyTargets(ComponentReference reference) {
+ for (Binding binding : reference.getBindings()) {
+ // <binding.sca without a URI does not identify a target
+ if ((binding instanceof SCABinding) && (binding.getURI() == null))
+ continue;
+ // any other binding implies a target
+ // TODO Processing for other binding types
+ return true;
+ } // end for
+ return false;
+ } // end bindingsIdentifyTargets
+
+ /**
+ * Helper method which obtains a list of targets for a reference
+ * @param reference - Component reference
+ * @return - the list of targets, which will be empty if there are no targets
+ */
+ private List<ComponentService> getReferenceTargets(ComponentReference reference) {
+ List<ComponentService> theTargets = reference.getTargets();
+ if (theTargets.isEmpty()) {
+ // Component reference list of targets is empty, try the implementation reference
+ if (reference.getReference() != null) {
+ theTargets = reference.getReference().getTargets();
+ } // end if
+ } // end if
+ return theTargets;
+ } // end method getReferenceTargets
+
+ /**
+ * Target names can take the form
+ * component/service/binding
+ * This extracts the component/service part
+ *
+ * @param targetName
+ * @return String the component/service name
+ */
+ private String getComponentServiceName(String targetName) {
+ String[] parts = targetName.split("/");
+
+ if (parts.length > 1) {
+ return parts[0] + "/" + parts[1];
+ } else {
+ return parts[0];
+ }
+ }
+
+ /**
+ * Target names can take the form
+ * component/service/binding
+ * This extracts the binding part and returns
+ * it. If there is no binding part it returns null
+ *
+ * @param targetName
+ * @return String the binding name or null if there is no binding name
+ */
+ private String getBindingName(String targetName) {
+ String[] parts = targetName.split("/");
+
+ if (parts.length == 3) {
+ return parts[2];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Helper method that finds the Component given a target name
+ * @param components
+ * @param targetName
+ * @return the component
+ */
+ private Component getComponentFromTargetName(Map<String, Component> components, String targetName) {
+ Component theComponent;
+ int s = targetName.indexOf('/');
+ if (s == -1) {
+ theComponent = components.get(targetName);
+ } else {
+ theComponent = components.get(targetName.substring(0, s));
+ }
+ return theComponent;
+ } // end method getComponentFromTargetName
+
+ /**
+ * Helper method to create an Endpoint Reference
+ * @param component
+ * @param reference
+ * @param binding
+ * @param endpoint
+ * @param unresolved
+ * @return the endpoint reference
+ */
+ private EndpointReference createEndpointRef(Component component,
+ ComponentReference reference,
+ Binding binding,
+ Endpoint endpoint,
+ boolean unresolved) {
+ EndpointReference endpointRef = createEndpointRef(component, reference, unresolved);
+ endpointRef.setBinding(binding);
+ endpointRef.setTargetEndpoint(endpoint);
+ return endpointRef;
+ } // end method
+
+ /**
+ * Helper method to create an Endpoint Reference
+ * @param component
+ * @param reference
+ * @param unresolved
+ * @return the endpoint reference
+ */
+ private EndpointReference createEndpointRef(Component component, ComponentReference reference, boolean unresolved) {
+ EndpointReference endpointRef = assemblyFactory.createEndpointReference();
+ endpointRef.setComponent(component);
+ endpointRef.setReference(reference);
+ endpointRef.setUnresolved(unresolved);
+ return endpointRef;
+ } // end method createEndpointRef
+
+ /**
+ * Helper method to create an endpoint
+ * @param component
+ * @param service
+ * @param unresolved
+ * @return the endpoint
+ */
+ private Endpoint createEndpoint(Component component, ComponentService service, boolean unresolved) {
+ Endpoint endpoint = createEndpoint(unresolved);
+ endpoint.setComponent(component);
+ endpoint.setService(service);
+ endpoint.setUnresolved(unresolved);
+ return endpoint;
+ } // end method createEndpoint
+
+ /**
+ * Helper method to create an endpoint
+ * @param component
+ * @param service
+ * @param binding
+ * @param unresolved
+ * @return the endpoint
+ */
+ private Endpoint createEndpoint(Component component, ComponentService service, Binding binding, boolean unresolved) {
+ Endpoint endpoint = createEndpoint(unresolved);
+ endpoint.setComponent(component);
+ endpoint.setService(service);
+ endpoint.setBinding(binding);
+ endpoint.setUnresolved(unresolved);
+ return endpoint;
+ } // end method createEndpoint
+
+ /**
+ * Helper method to create an Endpoint
+ * @param unresolved
+ * @return the endpoint
+ */
+ private Endpoint createEndpoint(boolean unresolved) {
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ endpoint.setUnresolved(unresolved);
+ return endpoint;
+ } // end method createEndpoint
+
+ /**
+ * Helper method to create an Endpoint
+ *
+ * @param component The component that owns the reference
+ * @param targetName It can be one of the following formats
+ * <ul>
+ * <li>componentName
+ * <li>componentName/serviceName
+ * <li>componentName/serviceName/bindingName
+ * </ul>
+ * @return the endpoint
+ */
+ private Endpoint createEndpoint(Component component, String targetName) {
+ String[] parts = targetName.split("/");
+ if (parts.length < 1 || parts.length > 3) {
+ throw new IllegalArgumentException("Invalid target URI: " + targetName);
+ }
+
+ // Find the parent uri
+ String uri = component.getURI();
+ int index = uri.lastIndexOf('/');
+ if (index == -1) {
+ uri = "";
+ } else {
+ uri = uri.substring(0, index);
+ }
+
+ if (parts.length >= 1) {
+ // Append the target component name
+ if (uri.length() == 0) {
+ uri = parts[0];
+ } else {
+ uri = uri + "/" + parts[0];
+ }
+ }
+ if (parts.length == 3) {
+ // <componentURI>#service-binding(serviceName/bindingName)
+ uri = uri + "#service-binding(" + parts[1] + "/" + parts[2] + ")";
+ } else if (parts.length == 2) {
+ // <componentURI>#service(serviceName)
+ uri = uri + "#service(" + parts[1] + ")";
+ }
+
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ endpoint.setUnresolved(true);
+ endpoint.setURI(uri);
+ return endpoint;
+ } // end method createEndpoint
+
+ /**
+ * ASM_5021: where a <reference/> of a <component/> has @autowire=true
+ * and where the <reference/> has a <binding/> child element which
+ * declares a single target service, the reference is wired only to
+ * the single service identified by the <wire/> element
+ */
+ private void setSingleAutoWireTarget(ComponentReference reference) {
+ if (reference.getEndpointReferences().size() > 1 && reference.getBindings() != null
+ && reference.getBindings().size() == 1) {
+ String uri = reference.getBindings().get(0).getURI();
+ if (uri != null) {
+ if (uri.indexOf('/') > -1) {
+ // TODO: must be a way to avoid this fiddling
+ int i = uri.indexOf('/');
+ String c = uri.substring(0, i);
+ String s = uri.substring(i + 1);
+ uri = c + "#service(" + s + ")";
+ }
+ for (EndpointReference er : reference.getEndpointReferences()) {
+ if (er.getTargetEndpoint() != null && uri.equals(er.getTargetEndpoint().getURI())) {
+ reference.getEndpointReferences().clear();
+ reference.getEndpointReferences().add(er);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+} // end class
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/WireMatcherImpl.java b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/WireMatcherImpl.java
new file mode 100644
index 0000000000..761f53ff11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/WireMatcherImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.assembly.builder.WireBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+
+/**
+ *
+ */
+public class WireMatcherImpl implements WireBuilder {
+ private InterfaceContractMapper interfaceContractMapper;
+ private BuilderExtensionPoint builderExtensionPoint;
+
+ /**
+ * @param registry
+ */
+ public WireMatcherImpl(ExtensionPointRegistry registry) {
+ super();
+ this.builderExtensionPoint = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ }
+
+ public boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context) {
+ InterfaceContract sourceIC = endpointReference.getComponentReferenceInterfaceContract();
+ InterfaceContract targetIC = endpoint.getComponentServiceInterfaceContract();
+ if (!interfaceContractMapper.isCompatibleSubset(sourceIC, targetIC)) {
+ return false;
+ }
+ for (PolicyBuilder policyBuilder : builderExtensionPoint.getPolicyBuilders()) {
+ if (!policyBuilder.build(endpointReference, endpoint, context)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder b/sandbox/sebastien/java/embed/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder
new file mode 100644
index 0000000000..f7b8a0374f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder
@@ -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.builder.impl.ModelBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeBuilder
+
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties b/sandbox/sebastien/java/embed/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties
new file mode 100644
index 0000000000..2d519a28ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties
@@ -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.
+#
+#
+
+# there are a whole stack of builder related messages that
+# are still yet to be moved here from assembly-validation-messages.properties
+PolicyAttachedToProperty = [POL40002] The policy {0} has been attached to a property or one of its children. This is not allowed.
+PolicyDOMModelMissmatch = The DOM node which has been found as a result of evaluating the XPath attachment of policy {0} cannot be mapped back to an element in the SCA model. The structural URI of the node is {1}
+MultiplePolicyLanguagesInEP = The policy sets for endpoint {0} contain policies specified in more than one language {1}
+MultiplePolicyLanguagesInEPR = The policy sets for endpoint reference {0} contain policies specified in more than one language {1}
+MultiplePolicyLanguagesInImpl = The policy sets for component {0} implementation contain policies specified in more than one language {1}
+JaxWSClientAsyncMethodsNotAllowed = [JCA100006] JAX-WS client-side asynchronous polling and callback methods are not allowed in service interfaces
+PolicySetNotFoundAtBuild = PolicySet {0} is not defined in SCA definitions
+IntentNotSatisfiedAtBuild = The intent {0} associated with policy subject {1} has no matching policy set
+MutuallyExclusiveIntentsAtBuild = [POL40009,ASM60009,ASM60010,JCA70001,JCA70003] Intent {0} and {1} are mutually exclusive
+IntentNotFoundAtBuild = Intent {0} is not defined in SCA definitions
+NoListenerIntentSpecifiedOnService = The noListener intent may only be specified on a reference.
+TransactedOneWayWithManagedTransactionLocal = The Component {0} {2} can not require transactedOneWay because the implementation for Component {1} requires managedTransaction.local
+PropagatesTransactionWithNoManagedTran = The component {0} {2} can not require propagatesTransaction because the implementation for component {1} requires noManagedTransaction
+TransactedOneWayWithTwoWayOp = The component reference {0} can not require transactedOneWay because the operation {1} is a two way operation
+ImmediateOneWayWithTwoWayOp = The component reference {0} can not require immediateOneWay because the operation {1} is a two way operation
+PropagatesTransactionWithLocalTran = The component {0} {2} can not require propagatesTransaction because the implementation for component {1} requires managedTransaction.local
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java
new file mode 100644
index 0000000000..b3586a2346
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.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.sca.builder.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuildPolicyTestCase {
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static ModelResolver resolver;
+ private static CompositeBuilder compositeBuilder;
+ private static Composite composite;
+ private static Monitor monitor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ compositeBuilder =
+ extensionPoints.getExtensionPoint(BuilderExtensionPoint.class)
+ .getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ List<Definitions> policyDefinitions = new ArrayList<Definitions>();
+ resolver = new DefaultModelResolver();
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ monitor = monitorFactory.createMonitor();
+
+ URLArtifactProcessorExtensionPoint documentProcessors =
+ new DefaultURLArtifactProcessorExtensionPoint(extensionPoints);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ URL url = BuildPolicyTestCase.class.getResource("Calculator.composite");
+ URI uri = URI.create("TestAllCalculator.composite");
+ composite = (Composite)documentProcessor.read(null, uri, url, context);
+ assertNotNull(composite);
+
+ url = BuildPolicyTestCase.class.getResource("test_definitions.xml");
+ uri = URI.create("test_definitions.xml");
+ Definitions definitions = (Definitions)policyDefinitionsProcessor.read(null, uri, url, context);
+ assertNotNull(definitions);
+ policyDefinitions.add(definitions);
+
+ documentProcessor.resolve(definitions, resolver, context);
+ documentProcessor.resolve(composite, resolver, context);
+
+ BuilderContext builderContext = new BuilderContext(definitions, null, monitor);
+ compositeBuilder.build(composite, builderContext);
+ }
+
+ @Test
+ @Ignore("There are so many errors with this composite the builder doesn't have enough to go on")
+ public void testPolicyIntentInheritance() throws Exception {
+ String namespaceUri = "http://test";
+
+ PolicySubject policiedComposite = composite;
+ assertEquals(policiedComposite.getRequiredIntents().size(), 1);
+ assertEquals(policiedComposite.getRequiredIntents().get(0).getName(),
+ new QName(namespaceUri, "tuscanyIntent_1"));
+
+ Component component = composite.getComponents().get(0);
+ Endpoint ep = component.getServices().get(0).getEndpoints().get(0);
+ EndpointReference epr = component.getReferences().get(0).getEndpointReferences().get(0);
+
+ System.out.println(ep.getRequiredIntents());
+ System.out.println(epr.getRequiredIntents());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java
new file mode 100644
index 0000000000..a99d0df91c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test the CompositeBuilder.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeBuilderTestCase {
+
+ private static AssemblyFactory assemblyFactory;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ assemblyFactory = new DefaultAssemblyFactory();
+ MonitorFactory mf = new DefaultMonitorFactory();
+ monitor = mf.createMonitor();
+ }
+
+ @Test
+ public void testFuseIncludes() throws Exception {
+ Composite c1 = assemblyFactory.createComposite();
+ c1.setName(new QName("http://foo", "C1"));
+ Component a = assemblyFactory.createComponent();
+ a.setName("a");
+ c1.getComponents().add(a);
+ CompositeService s = assemblyFactory.createCompositeService();
+ s.setName("s");
+ c1.getServices().add(s);
+ CompositeReference r = assemblyFactory.createCompositeReference();
+ r.setName("r");
+ c1.getReferences().add(r);
+
+ Composite c2 = assemblyFactory.createComposite();
+ c2.setName(new QName("http://foo", "C2"));
+ c1.getIncludes().add(c2);
+ Component b = assemblyFactory.createComponent();
+ b.setName("b");
+ c2.getComponents().add(b);
+
+ Composite c = assemblyFactory.createComposite();
+ c.setName(new QName("http://foo", "C"));
+ c.getIncludes().add(c1);
+
+ new CompositeIncludeBuilderImpl().build(c, new BuilderContext(monitor));
+
+ assertTrue(c.getComponents().get(0).getName().equals("a"));
+ assertTrue(c.getComponents().get(1).getName().equals("b"));
+ assertTrue(c.getServices().get(0).getName().equals("s"));
+ assertTrue(c.getReferences().get(0).getName().equals("r"));
+ }
+
+ @Test
+ public void testExpandComposites() throws Exception {
+ Composite c1 = assemblyFactory.createComposite();
+ c1.setName(new QName("http://foo", "C1"));
+ Component a = assemblyFactory.createComponent();
+ a.setName("a");
+ c1.getComponents().add(a);
+ CompositeService s = assemblyFactory.createCompositeService();
+ s.setName("s");
+ c1.getServices().add(s);
+ CompositeReference r = assemblyFactory.createCompositeReference();
+ r.setName("r");
+ c1.getReferences().add(r);
+
+ Composite c2 = assemblyFactory.createComposite();
+ c2.setName(new QName("http://foo", "C2"));
+ Component b = assemblyFactory.createComponent();
+ b.setName("b");
+ c2.getComponents().add(b);
+
+ Composite c = assemblyFactory.createComposite();
+ c.setName(new QName("http://foo", "C"));
+ Component x = assemblyFactory.createComponent();
+ x.setName("x");
+ x.setImplementation(c1);
+ c.getComponents().add(x);
+ Component y = assemblyFactory.createComponent();
+ y.setName("y");
+ y.setImplementation(c2);
+ c.getComponents().add(y);
+ Component z = assemblyFactory.createComponent();
+ z.setName("z");
+ z.setImplementation(c1);
+ c.getComponents().add(z);
+
+ new CompositeCloneBuilderImpl().build(c, new BuilderContext(monitor));
+
+ assertTrue(c.getComponents().get(0).getImplementation() != c1);
+ assertTrue(c.getComponents().get(1).getImplementation() != c2);
+ assertTrue(c.getComponents().get(2).getImplementation() != c1);
+
+ Composite i = (Composite)c.getComponents().get(0).getImplementation();
+ assertTrue(i.getComponents().get(0) != a);
+ assertTrue(i.getComponents().get(0).getName().equals("a"));
+ assertTrue(i.getServices().get(0).getName().equals("s"));
+ assertTrue(i.getServices().get(0) != s);
+ assertTrue(i.getReferences().get(0).getName().equals("r"));
+ assertTrue(i.getReferences().get(0) != r);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java
new file mode 100644
index 0000000000..dac50ec227
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.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.sca.builder.impl;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Mocked Policy
+ */
+public class MockPolicy {
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java
new file mode 100644
index 0000000000..9102257b77
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.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.builder.impl;
+
+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.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyAttachmentTestCase {
+
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+
+ private static ExtensionPointRegistry extensionPoints;
+ private static XMLInputFactory inputFactory;
+ private static AssemblyFactory assemblyFactory;
+ private static BuilderExtensionPoint builders;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ inputFactory = factories.getFactory(XMLInputFactory.class);
+ // Create a monitor
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ if (monitorFactory != null) {
+ monitor = monitorFactory.createMonitor();
+ utilities.addUtility(monitorFactory);
+ }
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ builders = extensionPoints.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ @Test
+ public void testBuild() throws Exception {
+ Definitions definitions = load("test_definitions.xml");
+ Composite composite = load("Calculator.composite");
+
+ CompositeBuilder uriBuilder = new StructuralURIBuilderImpl(extensionPoints);
+
+ BuilderContext builderContext = new BuilderContext(extensionPoints);
+ builderContext.setDefinitions(definitions);
+ composite = uriBuilder.build(composite, builderContext);
+ PolicyAttachmentBuilderImpl builder = new PolicyAttachmentBuilderImpl(extensionPoints);
+ builder.build(composite, builderContext);
+ }
+
+ private <T> T load(String file) throws IOException, XMLStreamException, ContributionReadException {
+ URL url = getClass().getResource(file);
+ InputStream urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+ reader.nextTag();
+
+ T model = (T)staxProcessor.read(reader, context);
+ reader.close();
+ return model;
+ }
+
+ @Test
+ public void testComplexBuild() throws Exception {
+ Definitions definitions = load("definitions.xml");
+ Composite composite1 = load("Composite1.composite");
+ Composite composite2 = load("Composite2.composite");
+ Composite composite3 = load("Composite3.composite");
+ Composite composite4 = load("Composite4.composite");
+ composite1.getIncludes().clear();
+ composite1.getIncludes().add(composite3);
+
+ composite1.getComponent("Component1B").setImplementation(composite4);
+ composite2.getComponent("Component2B").setImplementation(composite4);
+
+ Composite domainComposite = assemblyFactory.createComposite();
+ domainComposite.setName(new QName(Base.SCA11_NS, ""));
+ domainComposite.setLocal(false);
+ domainComposite.getIncludes().add(composite1);
+ domainComposite.getIncludes().add(composite2);
+
+ CompositeBuilder includeBuilder = new CompositeIncludeBuilderImpl();
+ CompositeBuilder cloneBuilder = new CompositeCloneBuilderImpl();
+ CompositeBuilder uriBuilder = new StructuralURIBuilderImpl(extensionPoints);
+
+ BuilderContext context = new BuilderContext(extensionPoints);
+ context.setDefinitions(definitions);
+ domainComposite = cloneBuilder.build(domainComposite, context);
+ domainComposite = includeBuilder.build(domainComposite, context);
+ domainComposite = uriBuilder.build(domainComposite, context);
+
+ PolicyAttachmentBuilderImpl builder = new PolicyAttachmentBuilderImpl(extensionPoints);
+ domainComposite = builder.build(domainComposite, context);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java
new file mode 100644
index 0000000000..1201b6e36f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.builder.impl;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A PolicyProcessor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<MockPolicy> {
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public MockPolicy read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new MockPolicy();
+ }
+
+ public void write(MockPolicy arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ }
+
+ public Class<MockPolicy> getModelType() {
+ return MockPolicy.class;
+ }
+
+ public void resolve(MockPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite
new file mode 100644
index 0000000000..0e7aad877e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent" requires="confidentiality">
+ <implementation.java class="calculator.CalculatorServiceImpl" xmlns:test="http://test" requiers="test:TestIntentOne"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite
new file mode 100644
index 0000000000..584f27eea7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite1">
+ <include composite="sample:Composite3"/>
+
+ <component name="Component1A">
+ <implementation.java class="sample.Component1AImpl"/>
+ </component>
+
+ <component name="Component1B">
+ <implementation.composite name="sample:Composite4"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite
new file mode 100644
index 0000000000..12cf984b88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite2">
+
+ <component name="Component2A">
+ <implementation.java class="sample.Component2AImpl"/>
+ </component>
+
+ <component name="Component2B">
+ <implementation.composite name="sample:Composite4"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite
new file mode 100644
index 0000000000..e6be99195e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite3">
+
+ <component name="Component3A">
+ <implementation.java class="sample.Component3AImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite
new file mode 100644
index 0000000000..02167e43cf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite4">
+
+ <service name="Service1" promote="Component4A/Service1"/>
+ <reference name="reference1" promote="Component4A/reference1"/>
+
+ <component name="Component4A">
+ <implementation.java class="sample.Component4AImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml
new file mode 100644
index 0000000000..5b22d5b596
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <policySet name="PolicySet1" appliesTo="sca:implementation.java"
+ attachTo = "//composite[@name='']">
+ </policySet>
+
+ <policySet name="PolicySet2" appliesTo="sca:implementation.java"
+ attachTo = "//component[@name='Component3A']">
+ </policySet>
+
+ <policySet name="PolicySet3" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[sca:URIRef('Component2B/Component4A')]">
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg
new file mode 100644
index 0000000000..a010bb1bf1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png
new file mode 100644
index 0000000000..e1f78f6423
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml
new file mode 100644
index 0000000000..dc7f5c422c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/common-http/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/common-http/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..942e695a71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-http/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Common HTTP
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Common HTTP
+Bundle-SymbolicName: org.apache.tuscany.sca.common.http
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.common.http;version="2.0.0"
+Import-Package: javax.servlet.http
+
+
diff --git a/sandbox/sebastien/java/embed/modules/common-http/pom.xml b/sandbox/sebastien/java/embed/modules/common-http/pom.xml
new file mode 100644
index 0000000000..2fa94a708c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-http/pom.xml
@@ -0,0 +1,47 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-common-http</artifactId>
+ <name>Apache Tuscany SCA Common HTTP</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version> <!-- to keep compatible with older servlet containers -->
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java
new file mode 100644
index 0000000000..248ea6eeb8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.http;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * A class to store cache settings for Atom and HTTP requests and responses.
+ *
+ * Predicates are statements that work in conjunction with
+ * ETags and LastModified dates to determine if a precondition
+ * or postcondition is satisfied.
+ * See HTTP specification for how predicates wrk:
+ * http://tools.ietf.org/html/rfc2616
+ * Example predicates in HTTP include If-Match, If-None-Match,
+ * If-Modified-Since, If-Unmodified-Since, If-Range.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPCacheContext {
+ public static final SimpleDateFormat RFC822DateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
+
+ public boolean enabled;
+ public String eTag;
+ public String lastModified;
+ public Date lastModifiedDate;
+ public boolean ifModifiedSince;
+ public boolean ifUnmodifiedSince;
+ public boolean ifMatch;
+ public boolean ifNoneMatch;
+ public boolean ifRange;
+
+ /**
+ * Gets the cache context information (ETag, LastModified, predicates) from the Http request.
+ * @param request
+ * @return
+ */
+ public static HTTPCacheContext createCacheContextFromRequest( HttpServletRequest request ) throws java.text.ParseException {
+ HTTPCacheContext context = new HTTPCacheContext();
+
+ String eTag = request.getHeader( "If-Match" );
+ if ( eTag != null ) {
+ context.setETag( eTag );
+ context.setIfMatch( true );
+ }
+ eTag = request.getHeader( "If-None-Match" );
+ if ( eTag != null ) {
+ context.setETag( eTag );
+ context.setIfNoneMatch( true );
+ }
+ String lastModifiedString = request.getHeader( "If-Modified-Since" );
+ if ( lastModifiedString != null ) {
+ context.setLastModified( lastModifiedString );
+ context.setIfModifiedSince( true );
+ }
+ lastModifiedString = request.getHeader( "If-Unmodified-Since" );
+ if ( lastModifiedString != null ) {
+ context.setLastModified( lastModifiedString );
+ context.setIfUnmodifiedSince( true );
+ }
+ lastModifiedString = request.getHeader( "If-Range" );
+ if ( lastModifiedString != null ) {
+ context.setLastModified( lastModifiedString );
+ context.setIfRange( true );
+ }
+ return context;
+ }
+
+ /**
+ * Enabled is true whenever ETag, LastModified, or predicate is set.
+ * @return the enabled
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ /**
+ * An ETag is a unique ID for an item. It changes when
+ * a field in the item or the update date changes.
+ * See HTTP specification for how ETags work:
+ * http://tools.ietf.org/html/rfc2616
+ * @return the eTag
+ */
+ public String getETag() {
+ return eTag;
+ }
+ /**
+ * @param tag the eTag to set
+ */
+ public void setETag(String tag) {
+ eTag = tag;
+ enabled = true;
+ }
+ /**
+ * The LastModified date is the time the item was last
+ * changed. See HTTP specification for how ETags work:
+ * http://tools.ietf.org/html/rfc2616
+ * @return the lastModified
+ */
+ public String getLastModified() {
+ return lastModified;
+ }
+ /**
+ * The LastModified date is the time the item was last
+ * changed. See HTTP specification for how ETags work:
+ * http://tools.ietf.org/html/rfc2616
+ * @return the lastModified
+ */
+ public Date getLastModifiedAsDate() {
+ return lastModifiedDate;
+ }
+ /**
+ * @param lastModified the lastModified to set
+ */
+ public void setLastModified(String lastModified) throws java.text.ParseException {
+ this.lastModified = lastModified;
+ // Catch date formatting on input to help debugging.
+ lastModifiedDate = RFC822DateFormat.parse( lastModified );
+ enabled = true;
+ }
+
+ /**
+ * @param lastModified the lastModified to set
+ */
+ public void setLastModified(Date updated) {
+ this.lastModified = RFC822DateFormat.format( updated );
+ lastModifiedDate = updated;
+ enabled = true;
+ }
+
+ /**
+ * @return the ifModifedSince
+ */
+ public boolean isIfModifiedSince() {
+ return ifModifiedSince;
+ }
+ /**
+ * @param ifModifedSince the ifModifedSince to set
+ */
+ public void setIfModifiedSince(boolean ifModifiedSince) {
+ this.ifModifiedSince = ifModifiedSince;
+ if ( ifModifiedSince )
+ enabled = true;
+ }
+ /**
+ * @return the ifUnModifiedSince
+ */
+ public boolean isIfUnmodifiedSince() {
+ return ifUnmodifiedSince;
+ }
+ /**
+ * @param ifUnModifiedSince the ifUnModifiedSince to set
+ */
+ public void setIfUnmodifiedSince(boolean ifUnmodifiedSince) {
+ this.ifUnmodifiedSince = ifUnmodifiedSince;
+ if ( ifUnmodifiedSince )
+ enabled = true;
+ }
+ /**
+ * @return the ifMatch
+ */
+ public boolean isIfMatch() {
+ return ifMatch;
+ }
+ /**
+ * @param ifMatch the ifMatch to set
+ */
+ public void setIfMatch(boolean ifMatch) {
+ this.ifMatch = ifMatch;
+ if ( ifMatch )
+ enabled = true;
+ }
+ /**
+ * @return the ifNoneMatch
+ */
+ public boolean isIfNoneMatch() {
+ return ifNoneMatch;
+ }
+ /**
+ * @param ifNoneMatch the ifNoneMatch to set
+ */
+ public void setIfNoneMatch(boolean ifNoneMatch) {
+ this.ifNoneMatch = ifNoneMatch;
+ if ( ifNoneMatch )
+ enabled = true;
+ }
+ /**
+ * @return the ifRange
+ */
+ public boolean isIfRange() {
+ return ifRange;
+ }
+ /**
+ * @param ifRange the ifRange to set
+ */
+ public void setIfRange(boolean ifRange) {
+ this.ifRange = ifRange;
+ if ( ifRange )
+ enabled = true;
+ }
+
+ public String toString() {
+ final String PREDPREFIX = ", predicates=";
+ StringBuffer sb = new StringBuffer(PREDPREFIX);
+ if ( ifMatch || ifNoneMatch || ifModifiedSince || ifUnmodifiedSince || ifRange ) {
+ if ( ifMatch ) {
+ if ( sb.length() > PREDPREFIX.length() ) sb.append( ", ");
+ sb.append("If-Match");
+ }
+ if ( ifNoneMatch ) {
+ if ( sb.length() > PREDPREFIX.length() ) sb.append( ", ");
+ sb.append("If-None-Match");
+ }
+ if ( ifModifiedSince ) {
+ if ( sb.length() > PREDPREFIX.length() ) sb.append( ", ");
+ sb.append("If-Modified-Since");
+ }
+ if ( ifUnmodifiedSince ) {
+ if ( sb.length() > PREDPREFIX.length() ) sb.append( ", ");
+ sb.append("If-UnModified-Since");
+ }
+ if ( ifRange ) {
+ if ( sb.length() > PREDPREFIX.length() ) sb.append( ", ");
+ sb.append("If-Range");
+ }
+ } else {
+ sb.append("null");
+ }
+
+ return "eTag=" + eTag + ", lastModified=" + lastModified
+ + sb.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.java
new file mode 100644
index 0000000000..056e7f5f54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPConstants.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 org.apache.tuscany.sca.common.http;
+
+/**
+ * HTTP generic constants
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HTTPConstants {
+ public static final String CHARACTER_ENCODING_UTF8 = "UTF-8";
+
+ public static final String HTM = "htm";
+ public static final String HTML = "html";
+ public static final String JAVASCRIPT = "js";
+
+ public static final String HTML_CONTENT_TYPE = "text/html";
+ public static final String JAVASCRIPT_CONTENT_TYPE = "text/javascript";
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java
new file mode 100644
index 0000000000..035e7c0fa6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContentTypeMapper.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.http;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Utility class to provide default HTTP Content-Type header
+ * based on resource type
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPContentTypeMapper implements HTTPConstants{
+ private static Map<String, String> contentTypeTable = new HashMap<String, String>();
+
+ static {
+ contentTypeTable.put(HTM, HTML_CONTENT_TYPE);
+ contentTypeTable.put(HTML, HTML_CONTENT_TYPE);
+ contentTypeTable.put(JAVASCRIPT, JAVASCRIPT_CONTENT_TYPE);
+ }
+
+ /**
+ * Provided a resource path, identify default content-type based on the resource extension
+ * @param resourcePath
+ * @return
+ */
+ public static String getContentType(String resourcePath) {
+ return contentTypeTable.get(getResourceType(resourcePath));
+ }
+
+ /**
+ * Utility function to calculate file type based on its extension
+ * Useful to map HTTP content-type based on file extension
+ * @param resource the resource/file name
+ * @return the resource type/extension
+ */
+ private static String getResourceType(String resource) {
+ return resource.substring(resource.lastIndexOf(".") + 1);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContext.java b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContext.java
new file mode 100644
index 0000000000..3324be6ef1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPContext.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.sca.common.http;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * HTTP Context used as binding context in HTTP related bindings
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPContext {
+ private HttpServletRequest request;
+ private HttpServletResponse response;
+
+ public HttpServletRequest getHttpRequest() {
+ return request;
+ }
+ public void setHttpRequest(HttpServletRequest request) {
+ this.request = request;
+ }
+ public HttpServletResponse getHttpResponse() {
+ return response;
+ }
+ public void setHttpResponse(HttpServletResponse response) {
+ this.response = response;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPHeader.java b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPHeader.java
new file mode 100644
index 0000000000..40691dfd7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPHeader.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.common.http;
+
+/**
+ * Wrapper for HTTP header name/value pair
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class HTTPHeader {
+ private String name;
+ private String value;
+
+ public HTTPHeader() {
+ super();
+ }
+
+ public HTTPHeader(String name, String value) {
+ super();
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Get header name
+ * @return the header name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set header value
+ * @param name the header name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get header value
+ * @return the header value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Set header value
+ * @param value the header value
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java
new file mode 100644
index 0000000000..f810970869
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.http;
+
+import java.math.BigInteger;
+import java.security.MessageDigest;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public class HTTPUtil {
+
+ /**
+ * Calculate the relative request path taking in consideration if
+ * the application is running in a embedded webContatiner or from
+ * within a web application server host environment
+ *
+ * @param request The http request
+ * @return the relative path
+ */
+ public static String getRequestPath(HttpServletRequest request) {
+ // Get the request path
+ String contextPath = request.getContextPath();
+ String servletPath = request.getServletPath();
+ String requestURI = request.getRequestURI();
+
+ int contextPathLength = contextPath.length();
+ int servletPathLenght = servletPath.contains(contextPath) ? servletPath.length() - contextPath.length() : servletPath.length();
+
+ String requestPath = requestURI.substring(contextPathLength + servletPathLenght);
+
+ return requestPath;
+ }
+
+ /**
+ * Calculate the context root for an application taking in consideration if
+ * the application is running in a embedded webContatiner or from
+ * within a web application server host environment.
+ *
+ * In the case of webContainer the contextRoot will always be a empty string.
+ *
+ * @param request The http request
+ * @return the contextRoot
+ */
+ public static String getContextRoot(HttpServletRequest request) {
+ // Get the request path
+ String contextPath = request.getContextPath();
+ String requestURI = request.getRequestURI();
+
+ int contextPathLength = contextPath.length();
+
+ String contextRoot = requestURI.substring(0, contextPathLength);
+
+ return contextRoot;
+ }
+
+ public static String calculateHashETag(byte[] content) {
+ String eTag = "invalid";
+ try {
+ MessageDigest messageDigest = MessageDigest.getInstance("MD5");
+ byte[] digest = messageDigest.digest(content);
+ BigInteger number = new BigInteger(1, digest);
+ StringBuffer sb = new StringBuffer('0');
+ sb.append(number.toString(16));
+ eTag = sb.toString();
+ } catch(Exception e) {
+ //ignore, we will return random etag
+ eTag = Integer.toString((new java.util.Random()).nextInt(Integer.MAX_VALUE));
+ }
+ return eTag;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/common-java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5fd3a2a7f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Common Java
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Common Java
+Import-Package: org.apache.tuscany.sca.common.java.classloader;version="2.0.0",
+ org.apache.tuscany.sca.common.java.collection;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.java.reflection;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.common.java
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.common.java.classloader;version="2.0.0",
+ org.apache.tuscany.sca.common.java.collection;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.java.reflection;version="2.0.0";uses:="org.apache.tuscany.sca.core"
+
+
diff --git a/sandbox/sebastien/java/embed/modules/common-java/pom.xml b/sandbox/sebastien/java/embed/modules/common-java/pom.xml
new file mode 100644
index 0000000000..3b01272ae1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/pom.xml
@@ -0,0 +1,55 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-common-java</artifactId>
+ <name>Apache Tuscany SCA Common Java</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>jdk15</id>
+ <activation>
+ <jdk>1.5</jdk>
+ </activation>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java
new file mode 100644
index 0000000000..522880711c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.common.java.classloader;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.tuscany.sca.common.java.collection.CompoundEnumeration;
+
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public class ClassLoaderDelegate extends ClassLoader {
+ private final List<ClassLoader> classLoaders = new ArrayList<ClassLoader>();
+
+ /**
+ * @param parent The parent classloaders
+ * @param loaders A list of classloaders to be used to load classes or resources
+ */
+ public ClassLoaderDelegate(ClassLoader parent, ClassLoader... loaders) {
+ super(parent);
+ if (loaders != null) {
+ for (ClassLoader cl : loaders) {
+ if (cl != null && cl != parent && !classLoaders.contains(cl)) {
+ this.classLoaders.add(cl);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param parent The parent classloaders
+ * @param loaders A list of classloaders to be used to load classes or resources
+ */
+ public ClassLoaderDelegate(ClassLoader parent, Collection<ClassLoader> loaders) {
+ super(parent);
+ if (loaders != null) {
+ for (ClassLoader cl : loaders) {
+ if (cl != null && cl != parent && !classLoaders.contains(cl)) {
+ this.classLoaders.add(cl);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected Class<?> findClass(String className) throws ClassNotFoundException {
+ for (ClassLoader parent : classLoaders) {
+ try {
+ return parent.loadClass(className);
+ } catch (ClassNotFoundException e) {
+ continue;
+ }
+ }
+ throw new ClassNotFoundException(className);
+ }
+
+ @Override
+ protected URL findResource(String resName) {
+ for (ClassLoader parent : classLoaders) {
+ URL url = parent.getResource(resName);
+ if (url != null) {
+ return url;
+ }
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Enumeration<URL> findResources(String resName) throws IOException {
+ Enumeration<URL>[] enums = new Enumeration[classLoaders.size()];
+ int index = 0;
+ for (ClassLoader parent : classLoaders) {
+ enums[index++] = parent.getResources(resName);
+ }
+ return new CompoundEnumeration<URL>(enums);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java
new file mode 100644
index 0000000000..0db80c891d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.common.java.collection;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * A Map with Collection values
+ */
+public class CollectionMap<K, V> extends ConcurrentHashMap<K, Collection<V>> {
+ private static final long serialVersionUID = -8926174610229029369L;
+
+ public boolean putValue(K key, V value) {
+ Collection<V> collection = get(key);
+ if (collection == null) {
+ collection = createCollection();
+ put(key, collection);
+ }
+ return collection.add(value);
+ }
+
+ public boolean putValues(K key, Collection<? extends V> value) {
+ Collection<V> collection = get(key);
+ if (collection == null) {
+ collection = createCollection();
+ put(key, collection);
+ }
+ return collection.addAll(value);
+ }
+
+ public boolean removeValue(K key, V value) {
+ return removeValue(key, value, false);
+ }
+
+ /**
+ * Remove an entry from the collection for a key
+ * @param key The key
+ * @param value The value in the collection
+ * @param removeEmptyEntry Indicate if the entry should be removed if the collection is empty
+ * @return
+ */
+ public boolean removeValue(K key, V value, boolean removeEmptyEntry) {
+ Collection<V> collection = get(key);
+ if (collection == null) {
+ return false;
+ }
+ boolean result = collection.remove(value);
+ if(removeEmptyEntry && collection.isEmpty()) {
+ remove(key);
+ }
+ return result;
+ }
+
+ protected Collection<V> createCollection() {
+ return new ArrayList<V>();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundEnumeration.java b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundEnumeration.java
new file mode 100644
index 0000000000..dc6a7e0f90
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundEnumeration.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.java.collection;
+
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+public class CompoundEnumeration<T> implements Enumeration<T> {
+ private Enumeration<T>[] enumerations = null;
+ private int index = 0;
+
+ public CompoundEnumeration(Enumeration<T>... enums) {
+ enumerations = enums;
+ }
+
+ public boolean hasMoreElements() {
+ // if the current enum is null that means this enum is finished
+ if (currentEnumeration() == null) {
+ // No next enum
+ return false;
+ }
+ // If the current enum has more elements, lets go
+ return currentEnumeration().hasMoreElements();
+ }
+
+ private Enumeration<T> findNextEnumeration(boolean moveCursor) {
+ return findNextEnumeration(index, moveCursor);
+ }
+
+ private Enumeration<T> findNextEnumeration(int cursor, boolean moveCursor) {
+ // next place in the array
+ int next = cursor + 1;
+ // If the cursor is still in the array
+ if (next < enumerations.length) {
+
+ // If there is something in that place
+ // AND the enum is not empty
+ if (enumerations[next] != null && enumerations[next].hasMoreElements()) {
+ // OK
+ if (moveCursor) {
+ index = next;
+ }
+ return enumerations[next];
+ }
+ // Try next element
+ return findNextEnumeration(next, moveCursor);
+ }
+ // No more elements available
+ return null;
+ }
+
+ public T nextElement() {
+ // ask for the next element of the current enum.
+ if (currentEnumeration() != null) {
+ return currentEnumeration().nextElement();
+ }
+
+ // no more elements in this Enum
+ // We must throw a NoSuchElementException
+ throw new NoSuchElementException("No more elements");
+ }
+
+ private Enumeration<T> currentEnumeration() {
+ if (enumerations != null) {
+ if (index < enumerations.length) {
+ Enumeration<T> e = enumerations[index];
+ if (e == null || !e.hasMoreElements()) {
+ // the current enum is null or empty
+ // we probably want to switch to the next one
+ e = findNextEnumeration(true);
+ }
+ return e;
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundIterator.java b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundIterator.java
new file mode 100644
index 0000000000..997ba89881
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundIterator.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.sca.common.java.collection;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+public class CompoundIterator<T> implements Iterator<T> {
+ private Iterator<T>[] iterators = null;
+ private int index = 0;
+
+ public CompoundIterator(Iterator<T>... iterators) {
+ this.iterators = iterators;
+ }
+
+ @SuppressWarnings("unchecked")
+ public CompoundIterator(Collection<T>... collections) {
+ this.iterators = new Iterator[collections.length];
+ for (int i = 0; i < collections.length; i++) {
+ this.iterators[i] = collections[i].iterator();
+ }
+ }
+
+ public boolean hasNext() {
+ // if the current enum is null that means this enum is finished
+ if (currentIterator() == null) {
+ // No next enum
+ return false;
+ }
+ // If the current enum has more elements, lets go
+ return currentIterator().hasNext();
+ }
+
+ private Iterator<T> findNextIterator(boolean moveCursor) {
+ return findNextIterator(index, moveCursor);
+ }
+
+ private Iterator<T> findNextIterator(int cursor, boolean moveCursor) {
+ // next place in the array
+ int next = cursor + 1;
+ // If the cursor is still in the array
+ if (next < iterators.length) {
+
+ // If there is something in that place
+ // AND the enum is not empty
+ if (iterators[next] != null && iterators[next].hasNext()) {
+ // OK
+ if (moveCursor) {
+ index = next;
+ }
+ return iterators[next];
+ }
+ // Try next element
+ return findNextIterator(next, moveCursor);
+ }
+ // No more elements available
+ return null;
+ }
+
+ public T next() {
+ // ask for the next element of the current enum.
+ if (currentIterator() != null) {
+ return currentIterator().next();
+ }
+
+ // no more elements in this Enum
+ // We must throw a NoSuchElementException
+ throw new NoSuchElementException("No more elements");
+ }
+
+ public void remove() {
+ // ask for the next element of the current enum.
+ if (currentIterator() != null) {
+ currentIterator().remove();
+ }
+
+ // no more elements in this Enum
+ // We must throw a NoSuchElementException
+ throw new NoSuchElementException("No more elements");
+ }
+
+ private Iterator<T> currentIterator() {
+ if (iterators != null) {
+ if (index < iterators.length) {
+ Iterator<T> e = iterators[index];
+ if (e == null || !e.hasNext()) {
+ // the current enum is null or empty
+ // we probably want to switch to the next one
+ e = findNextIterator(true);
+ }
+ return e;
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.java b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.java
new file mode 100644
index 0000000000..41286aa0f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.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.sca.common.java.collection;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * A Simple LRU Cache
+ *
+ * @version $Revision$
+ * @param <K>
+ * @param <V>
+ * @tuscany.spi.extension.asclient
+ */
+
+public class LRUCache<K, V> extends LinkedHashMap<K, V> {
+ private static final long serialVersionUID = -342098639681884413L;
+ protected int maxCacheSize = 4096;
+
+ /**
+ * Default constructor for an LRU Cache The default capacity is 4096
+ */
+ public LRUCache() {
+ this(0, 4096, 0.75f, true);
+ }
+
+ /**
+ * Constructs a LRUCache with a maximum capacity
+ *
+ * @param maximumCacheSize
+ */
+ public LRUCache(int maximumCacheSize) {
+ this(0, maximumCacheSize, 0.75f, true);
+ }
+
+ /**
+ * Constructs an empty <tt>LRUCache</tt> instance with the specified
+ * initial capacity, maximumCacheSize,load factor and ordering mode.
+ *
+ * @param initialCapacity the initial capacity.
+ * @param maximumCacheSize
+ * @param loadFactor the load factor.
+ * @param accessOrder the ordering mode - <tt>true</tt> for access-order,
+ * <tt>false</tt> for insertion-order.
+ * @throws IllegalArgumentException if the initial capacity is negative or
+ * the load factor is non-positive.
+ */
+
+ public LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder) {
+ super(initialCapacity, loadFactor, accessOrder);
+ this.maxCacheSize = maximumCacheSize;
+ }
+
+ /**
+ * @return Returns the maxCacheSize.
+ */
+ public int getMaxCacheSize() {
+ return maxCacheSize;
+ }
+
+ /**
+ * @param maxCacheSize The maxCacheSize to set.
+ */
+ public void setMaxCacheSize(int maxCacheSize) {
+ this.maxCacheSize = maxCacheSize;
+ }
+
+ @Override
+ protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
+ return size() > maxCacheSize;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java
new file mode 100644
index 0000000000..91aef7a65f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.java.io;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * Helper class for I/O operations
+ * @tuscany.spi.extension.asclient
+ */
+public class IOHelper {
+
+ public static InputStream openStream(URL url) throws IOException {
+ // Handle file:<relative path> which strictly speaking is not a valid file URL
+ File file = toFile(url);
+ if (file != null) {
+ return new FileInputStream(file);
+ }
+ URLConnection connection = url.openConnection();
+ if (connection instanceof JarURLConnection) {
+ // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041014
+ connection.setUseCaches(false);
+ }
+ InputStream is = connection.getInputStream();
+ return is;
+ }
+
+ public static void close(InputStream is) {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ /**
+ * Escape the space in URL string
+ * @param uri
+ * @return
+ */
+ public static URI createURI(String uri) {
+ if (uri == null) {
+ return null;
+ }
+ if (uri.indexOf('%') != -1) {
+ // Avoid double-escaping
+ return URI.create(uri);
+ }
+ int index = uri.indexOf(':');
+ String scheme = null;
+ String ssp = uri;
+ if (index != -1) {
+ scheme = uri.substring(0, index);
+ ssp = uri.substring(index + 1);
+ }
+ try {
+ return new URI(scheme, ssp, null);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static URI toURI(URL url) {
+ if (url == null) {
+ return null;
+ }
+ return createURI(url.toString());
+ }
+
+ public static URL normalize(URL url) {
+ // Make sure the trailing / is added to the file directory URL so that
+ // URLClassLoader can load classes from that
+ try {
+ File file = toFile(url);
+ if (file != null) {
+ return file.toURI().toURL();
+ } else {
+ return toURI(url).toURL();
+ }
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Returns the File object representing the given URL.
+ *
+ * @param url
+ * @return
+ */
+ public static File toFile(URL url) {
+ if (url == null || !url.getProtocol().equals("file")) {
+ return null;
+ } else {
+ String filename = url.getFile().replace('/', File.separatorChar);
+ int pos = 0;
+ while ((pos = filename.indexOf('%', pos)) >= 0) {
+ if (pos + 2 < filename.length()) {
+ String hexStr = filename.substring(pos + 1, pos + 3);
+ char ch = (char)Integer.parseInt(hexStr, 16);
+ filename = filename.substring(0, pos) + ch + filename.substring(pos + 3);
+ }
+ }
+ return new File(filename);
+ }
+ }
+
+ /**
+ * Returns the location of the classpath entry, JAR, WAR etc. containing the given class.
+ *
+ * @param clazz
+ * @return
+ */
+ public static URL codeLocation(Class<?> clazz) {
+ URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
+ if (url == null) {
+ url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class");
+ }
+ return url;
+ }
+
+ /**
+ * Returns a location string as a URL
+ * @param location
+ * @return
+ */
+ public static URL getLocationAsURL(String location) {
+ URI uri = IOHelper.createURI(location);
+ if (uri.getScheme() == null) {
+ uri = new File(location).toURI();
+ }
+ try {
+ return uri.toURL();
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(location, e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java
new file mode 100644
index 0000000000..ae4f01c032
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java
@@ -0,0 +1,586 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.java.reflection;
+
+import java.beans.Introspector;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Implements various reflection-related operations
+ *
+ * @version $Rev$ $Date$
+ */
+public final class JavaIntrospectionHelper {
+ private static final Logger logger = Logger.getLogger(JavaIntrospectionHelper.class.getName());
+ private static final Class<?>[] EMPTY_CLASS_ARRY = new Class[0];
+
+ private ExtensionPointRegistry registry;
+
+ public JavaIntrospectionHelper(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public static JavaIntrospectionHelper getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilities.getUtility(JavaIntrospectionHelper.class);
+ }
+
+ private static boolean matches(int modifiers, int include, int exclude) {
+ if (include != -1) {
+ if ((modifiers & include) == 0) {
+ return false;
+ }
+ }
+ if (exclude != -1) {
+ if ((modifiers & exclude) != 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Recursively evaluates the type hierarchy to return all fields that are
+ * public or protected
+ * @param clazz The java class
+ * @param fields The set that collects all fields
+ * @param include The modifiers to be included
+ * @param exclude The modifiers to be excluded
+ * @return The set that collects all matched fields
+ */
+ private static Set<Field> getAllFields(Class<?> clazz, Set<Field> fields, int include, int exclude) {
+ if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
+ return fields;
+ }
+ fields = getAllFields(clazz.getSuperclass(), fields, include, exclude);
+ Field[] declaredFields = clazz.getDeclaredFields();
+ for (final Field field : declaredFields) {
+ int modifiers = field.getModifiers();
+ if (matches(modifiers, include, exclude)) {
+ // Allow privileged access to set accessibility. Requires ReflectPermission
+ // in security policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ field.setAccessible(true); // ignore Java accessibility
+ return null;
+ }
+ });
+ fields.add(field);
+ }
+ }
+ return fields;
+ }
+
+ /**
+ * @param cls
+ * @return
+ */
+ public Set<Field> getAllNonStaticOrFinalFields(Class<?> cls) {
+ Set<Field> fields = new HashSet<Field>();
+ return getAllFields(cls, fields, -1, Modifier.STATIC | Modifier.FINAL);
+ }
+
+ /**
+ * @param cls
+ * @return
+ */
+ public Set<Method> getAllNonStaticMethods(Class<?> cls) {
+ Set<Method> methods = new HashSet<Method>();
+ return getAllUniqueMethods(cls, methods, -1, Modifier.STATIC);
+ }
+
+ /**
+ * Recursively evaluates the type hierarchy to return all unique methods
+ */
+ private static Set<Method> getAllUniqueMethods(Class<?> pClass, Set<Method> methods, int include, int exclude) {
+ if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
+ return methods;
+ }
+ // we first evaluate methods of the subclass and then move to the parent
+ Method[] declaredMethods = pClass.getDeclaredMethods();
+ for (final Method declaredMethod : declaredMethods) {
+ int modifiers = declaredMethod.getModifiers();
+ if (!matches(modifiers, include, exclude)) {
+ continue;
+ }
+ if (methods.size() == 0) {
+ methods.add(declaredMethod);
+ } else {
+ List<Method> temp = new ArrayList<Method>();
+ boolean matched = false;
+ for (Method method : methods) {
+ // only add if not already in the set from a superclass (i.e.
+ // the method is not overridden)
+ if (exactMethodMatch(declaredMethod, method)) {
+ matched = true;
+ break;
+ }
+ }
+ if (!matched) {
+ // Allow privileged access to set accessibility. Requires ReflectPermission
+ // in security policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ declaredMethod.setAccessible(true);
+ return null;
+ }
+ });
+ temp.add(declaredMethod);
+ }
+ methods.addAll(temp);
+ temp.clear();
+ }
+ }
+ // evaluate class hierarchy - this is done last to track inherited
+ // methods
+ methods = getAllUniqueMethods(pClass.getSuperclass(), methods, include, exclude);
+ return methods;
+ }
+
+ /**
+ * Finds the closest matching field with the given name, that is, a field of
+ * the exact specified type or, alternately, of a supertype.
+ *
+ * @param name the name of the field
+ * @param type the field type
+ * @param fields the collection of fields to search
+ * @return the matching field or null if not found
+ */
+ public static Field findClosestMatchingField(String name, Class type, Set<Field> fields) {
+ Field candidate = null;
+ for (Field field : fields) {
+ if (field.getName().equals(name)) {
+ if (field.getType().equals(type)) {
+ return field; // exact match
+ } else if (field.getType().isAssignableFrom(type) || (field.getType().isPrimitive() && primitiveAssignable(field
+ .getType(),
+ type))) {
+ // We could have the situation where a field parameter is a
+ // primitive and the demarshalled value is
+ // an object counterpart (e.g. Integer and int)
+ // @spec issue
+ // either an interface or super class, so keep a reference
+ // until
+ // we know there are no closer types
+ candidate = field;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Finds the closest matching method with the given name, that is, a method
+ * taking the exact parameter types or, alternately, parameter supertypes.
+ *
+ * @param name the name of the method
+ * @param types the method parameter types
+ * @param methods the collection of methods to search
+ * @return the matching method or null if not found
+ */
+ public static Method findClosestMatchingMethod(String name, Class[] types, Set<Method> methods) {
+ if (types == null) {
+ types = EMPTY_CLASS_ARRY;
+ }
+ Method candidate = null;
+ for (Method method : methods) {
+ if (method.getName().equals(name) && method.getParameterTypes().length == types.length) {
+ Class<?>[] params = method.getParameterTypes();
+ boolean disqualify = false;
+ boolean exactMatch = true;
+ for (int i = 0; i < params.length; i++) {
+ if (!params[i].equals(types[i]) && !params[i].isAssignableFrom(types[i])) {
+ // no match
+ disqualify = true;
+ exactMatch = false;
+ break;
+ } else if (!params[i].equals(types[i]) && params[i].isAssignableFrom(types[i])) {
+ // not exact match
+ exactMatch = false;
+ }
+ }
+ if (disqualify) {
+ continue;
+ } else if (exactMatch) {
+ return method;
+ } else {
+ candidate = method;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Determines if two methods "match" - that is, they have the same method
+ * names and exact parameter types (one is not a supertype of the other)
+ */
+ public static boolean exactMethodMatch(Method method1, Method method2) {
+ if (!method1.getName().equals(method2.getName())) {
+ return false;
+ }
+ Class<?>[] types1 = method1.getParameterTypes();
+ Class<?>[] types2 = method2.getParameterTypes();
+ if (types1.length != types2.length) {
+ return false;
+ }
+ boolean matched = true;
+ for (int i = 0; i < types1.length; i++) {
+ if (types1[i] != types2[i]) {
+ matched = false;
+ break;
+ }
+ }
+ return matched;
+ }
+
+ public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws NoSuchMethodException {
+ return clazz.getConstructor();
+ }
+
+ /**
+ * Returns the simple name of a class - i.e. the class name devoid of its
+ * package qualifier
+ *
+ * @param implClass the implementation class
+ */
+ public static String getBaseName(Class<?> implClass) {
+ return implClass.getSimpleName();
+ }
+
+ public static boolean isImmutable(Class<?> clazz) {
+ return String.class == clazz || clazz.isPrimitive()
+ || Number.class.isAssignableFrom(clazz)
+ || Boolean.class.isAssignableFrom(clazz)
+ || Character.class.isAssignableFrom(clazz)
+ || Byte.class.isAssignableFrom(clazz);
+ }
+
+ /**
+ * Takes a property name and converts it to a getter method name according
+ * to JavaBean conventions. For example, property
+ * <code>foo<code> is returned as <code>getFoo</code>
+ */
+ public static String toGetter(String name) {
+ return "get" + name.toUpperCase().substring(0, 1) + name.substring(1);
+ }
+
+ /**
+ * Takes a setter or getter method name and converts it to a property name
+ * according to JavaBean conventions. For example, <code>setFoo(var)</code>
+ * is returned as property <code>foo<code>
+ */
+ public static String toPropertyName(Method method) {
+ if (isGetter(method) || isSetter(method)) {
+ String name = method.getName();
+ if (name.startsWith("get") || name.startsWith("set")) {
+ return Introspector.decapitalize(name.substring(3));
+ } else {
+ // Starts with is
+ return Introspector.decapitalize(name.substring(2));
+ }
+ } else {
+ throw new IllegalArgumentException("Method is not a setter or getter: " + method);
+ }
+ }
+
+ public static Class<?> getErasure(Type type) {
+ if (type instanceof Class) {
+ return (Class<?>)type;
+ } else if (type instanceof GenericArrayType) {
+ // FIXME: How to deal with the []?
+ GenericArrayType arrayType = (GenericArrayType)type;
+ return getErasure(arrayType.getGenericComponentType());
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType)type;
+ return getErasure(pType.getRawType());
+ } else if (type instanceof WildcardType) {
+ WildcardType wType = (WildcardType)type;
+ Type[] types = wType.getUpperBounds();
+ return getErasure(types[0]);
+ } else if (type instanceof TypeVariable) {
+ TypeVariable<?> var = (TypeVariable<?>)type;
+ Type[] types = var.getBounds();
+ return getErasure(types[0]);
+ }
+ return null;
+ }
+
+ public static Class<?> getBaseType(Class<?> cls, Type genericType) {
+ if (cls.isArray()) {
+ return cls.getComponentType();
+ } else if (Collection.class.isAssignableFrom(cls)) {
+ if (genericType instanceof ParameterizedType) {
+ // Collection<BaseType>
+ ParameterizedType parameterizedType = (ParameterizedType)genericType;
+ Type baseType = parameterizedType.getActualTypeArguments()[0];
+ if (baseType instanceof GenericArrayType) {
+ // Base is array
+ return cls;
+ } else {
+ return getErasure(baseType);
+ }
+ } else {
+ return cls;
+ }
+ } else {
+ return cls;
+ }
+ }
+
+ public static Type getParameterType(Type type) {
+ if (type instanceof ParameterizedType) {
+ // Collection<BaseType>
+ ParameterizedType parameterizedType = (ParameterizedType)type;
+ Type baseType = parameterizedType.getActualTypeArguments()[0];
+ return baseType;
+ } else {
+ return Object.class;
+ }
+ }
+
+ public static Class<?> getBusinessInterface(Class<?> cls, Type callableReferenceType) {
+ if (ServiceReference.class.isAssignableFrom(cls) && callableReferenceType instanceof ParameterizedType) {
+ // Collection<BaseType>
+ ParameterizedType parameterizedType = (ParameterizedType)callableReferenceType;
+ Type baseType = parameterizedType.getActualTypeArguments()[0];
+ if (baseType instanceof GenericArrayType) {
+ // Base is array
+ return cls;
+ } else {
+ return getErasure(baseType);
+ }
+ }
+ return Object.class;
+ }
+
+ /**
+ * Takes a property name and converts it to a setter method name according
+ * to JavaBean conventions. For example, the property
+ * <code>foo<code> is returned as <code>setFoo(var)</code>
+ */
+ public static String toSetter(String name) {
+ return "set" + name.toUpperCase().substring(0, 1) + name.substring(1);
+ }
+
+ /**
+ * Compares a two types, assuming one is a primitive, to determine if the
+ * other is its object counterpart
+ */
+ private static boolean primitiveAssignable(Class<?> memberType, Class<?> param) {
+ if (memberType == Integer.class) {
+ return param == Integer.TYPE;
+ } else if (memberType == Double.class) {
+ return param == Double.TYPE;
+ } else if (memberType == Float.class) {
+ return param == Float.TYPE;
+ } else if (memberType == Short.class) {
+ return param == Short.TYPE;
+ } else if (memberType == Character.class) {
+ return param == Character.TYPE;
+ } else if (memberType == Boolean.class) {
+ return param == Boolean.TYPE;
+ } else if (memberType == Byte.class) {
+ return param == Byte.TYPE;
+ } else if (param == Integer.class) {
+ return memberType == Integer.TYPE;
+ } else if (param == Double.class) {
+ return memberType == Double.TYPE;
+ } else if (param == Float.class) {
+ return memberType == Float.TYPE;
+ } else if (param == Short.class) {
+ return memberType == Short.TYPE;
+ } else if (param == Character.class) {
+ return memberType == Character.TYPE;
+ } else if (param == Boolean.class) {
+ return memberType == Boolean.TYPE;
+ } else if (param == Byte.class) {
+ return memberType == Byte.TYPE;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the generic types represented in the given type. Usage as
+ * follows: <code>
+ * JavaIntrospectionHelper.getGenerics(field.getGenericType());
+ * <p/>
+ * JavaIntrospectionHelper.getGenerics(m.getGenericParameterTypes()[0];); </code>
+ *
+ * @return the generic types in order of declaration or an empty array if
+ * the type is not genericized
+ */
+ public static List<? extends Type> getGenerics(Type genericType) {
+ List<Type> classes = new ArrayList<Type>();
+ if (genericType instanceof ParameterizedType) {
+ ParameterizedType ptype = (ParameterizedType)genericType;
+ // get the type arguments
+ Type[] targs = ptype.getActualTypeArguments();
+ for (Type targ : targs) {
+ classes.add(targ);
+ }
+ }
+ return classes;
+ }
+
+ /**
+ * Returns the generic type specified by the class at the given position as
+ * in: <p/> <code> public class Foo<Bar,Baz>{ //.. }
+ * <p/>
+ * JavaIntrospectionHelper.introspectGeneric(Foo.class,1); <code>
+ * <p/>
+ * will return Baz.
+ */
+ public static Class introspectGeneric(Class<?> clazz, int pos) {
+ assert clazz != null : "No class specified";
+ Type type = clazz.getGenericSuperclass();
+ if (type instanceof ParameterizedType) {
+ Type[] args = ((ParameterizedType)type).getActualTypeArguments();
+ if (args.length <= pos) {
+ throw new IllegalArgumentException("Invalid index value for generic class " + clazz.getName());
+ }
+ return (Class)((ParameterizedType)type).getActualTypeArguments()[pos];
+ } else {
+ Type[] interfaces = clazz.getGenericInterfaces();
+ for (Type itype : interfaces) {
+ if (!(itype instanceof ParameterizedType)) {
+ continue;
+ }
+ ParameterizedType interfaceType = (ParameterizedType)itype;
+ return (Class)interfaceType.getActualTypeArguments()[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the set of interfaces implemented by the given class and its
+ * ancestors or a blank set if none
+ */
+ public Set<Class<?>> getAllInterfaces(Class<?> clazz) {
+ Set<Class<?>> implemented = new HashSet<Class<?>>();
+ getAllInterfaces(clazz, implemented);
+ return implemented;
+ }
+
+ private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) {
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for (Class<?> interfaze : interfaces) {
+ implemented.add(interfaze);
+ }
+ Class<?> superClass = clazz.getSuperclass();
+ // Object has no superclass so check for null
+ if (superClass != null && !superClass.equals(Object.class)) {
+ getAllInterfaces(superClass, implemented);
+ }
+ }
+
+ /**
+ * Test if a method follows the JavaBeans setter pattern
+ * @param method
+ * @return
+ */
+ public static boolean isSetter(Method method) {
+ return (void.class == method.getReturnType() && method.getParameterTypes().length == 1
+ && method.getName().startsWith("set") && method.getName().length() > 3);
+ }
+
+ /**
+ * Test if a method follows the JavaBeans getter pattern
+ * @param method
+ * @return
+ */
+ public static boolean isGetter(Method method) {
+ if (method.getParameterTypes().length == 0) {
+ return false;
+ }
+ Class<?> returnType = method.getReturnType();
+ if (returnType == void.class || returnType == Void.class) {
+ return false;
+ }
+ String name = method.getName();
+ if (returnType == boolean.class)
+ if (name.length() > 2 && name.startsWith("is")) {
+ return true;
+ }
+ return name.length() > 3 && name.startsWith("get");
+ }
+
+ private final static Map<Class<?>, String> signatures = new HashMap<Class<?>, String>();
+ static {
+ signatures.put(boolean.class, "Z");
+ signatures.put(byte.class, "B");
+ signatures.put(char.class, "C");
+ signatures.put(short.class, "S");
+ signatures.put(int.class, "I");
+ signatures.put(long.class, "J");
+ signatures.put(float.class, "F");
+ signatures.put(double.class, "D");
+ };
+
+ public static String getSignature(Class<?> cls) {
+ if (cls.isPrimitive()) {
+ return signatures.get(cls);
+ }
+ if (cls.isArray()) {
+ return "[" + getSignature(cls.getComponentType());
+ }
+ return "L" + cls.getName().replace('.', '/') + ";";
+ }
+
+ public static Class<?> getArrayType(Class<?> componentType, int dims) throws ClassNotFoundException {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < dims; i++) {
+ buf.append('[');
+ }
+ buf.append(getSignature(componentType));
+ return Class.forName(buf.toString(), false, componentType.getClassLoader());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java
new file mode 100644
index 0000000000..11931a354f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.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.common.java.reflection;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class JavaIntrospectionHelperTestCase {
+ private static JavaIntrospectionHelper helper;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ helper = JavaIntrospectionHelper.getInstance(new DefaultExtensionPointRegistry());
+ }
+
+ @Test
+ public void testGetMethods() {
+ Set<Method> methods = helper.getAllNonStaticMethods(SubTestImpl.class);
+ System.out.println(methods);
+ }
+
+ @Test
+ public void testGetFields() {
+ Set<Field> fields = helper.getAllNonStaticOrFinalFields(SubTestImpl.class);
+ System.out.println(fields);
+ }
+
+ @Test
+ public void testGetAllInterfaces() {
+ Set<Class<?>> interfaces = helper.getAllInterfaces(SubTestImpl.class);
+ System.out.println(interfaces);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ helper = null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/SubTestImpl.java b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/SubTestImpl.java
new file mode 100644
index 0000000000..77595f3281
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/SubTestImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.common.java.reflection;
+
+/**
+ *
+ */
+public class SubTestImpl extends TestImpl implements Test2 {
+ private final int age = 0;
+ public String message;
+ protected static Test1 test1;
+
+ public void test2(int i) {
+ System.out.println(age + i);
+ }
+
+ @Override
+ public String test(String str) {
+ return hello(str);
+ }
+
+ private String hello(String str) {
+ return message + ":" + str;
+ }
+
+ public static void test4() {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test1.java b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test1.java
new file mode 100644
index 0000000000..c7a25d95c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test1.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 org.apache.tuscany.sca.common.java.reflection;
+
+/**
+ *
+ */
+public interface Test1 {
+ String test(String str);
+ void test1(int i);
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test2.java b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test2.java
new file mode 100644
index 0000000000..2b751af3eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test2.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 org.apache.tuscany.sca.common.java.reflection;
+
+/**
+ *
+ */
+public interface Test2 {
+ String test(String str);
+ void test2(int i);
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/TestImpl.java b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/TestImpl.java
new file mode 100644
index 0000000000..1bb7432b63
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/TestImpl.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.common.java.reflection;
+
+/**
+ *
+ */
+public class TestImpl implements Test1 {
+ private String message;
+ protected Test2 test2;
+
+ public void test1(int i) {
+ }
+
+ protected void setTest2(Test2 test2) {
+ this.test2 = test2;
+ }
+
+ public String test(String str) {
+ return hello(str);
+ }
+
+ private String hello(String str) {
+ return message + ":" + str;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/common-xml/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..0025ccea7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/META-INF/MANIFEST.MF
@@ -0,0 +1,57 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Common XML
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Common XML
+Import-Package: javax.xml.datatype,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.stream.util,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.sax,
+ javax.xml.transform.stream,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.common.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.sax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax.reader;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.xpath;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.ext,
+ org.xml.sax.helpers
+Bundle-SymbolicName: org.apache.tuscany.sca.common.xml
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.common.xml;version="2.0.0";
+ uses:="org.xml.sax",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0";
+ uses:="org.xml.sax.ext,
+ javax.xml.transform,
+ javax.xml.parsers,
+ org.apache.tuscany.sca.core,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.xml.sax",
+ org.apache.tuscany.sca.common.xml.sax;version="2.0.0";uses:="javax.xml.parsers,org.apache.tuscany.sca.core,org.xml.sax",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0";
+ uses:="org.apache.tuscany.sca.common.xml.dom,
+ javax.xml.stream,
+ javax.xml.transform,
+ org.apache.tuscany.sca.core,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.xml.sax",
+ org.apache.tuscany.sca.common.xml.stax.reader;version="2.0.0";
+ uses:="javax.xml.stream,
+ javax.xml.stream.util,
+ org.w3c.dom,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.common.xml.xpath;version="2.0.0";uses:="javax.xml.xpath,org.apache.tuscany.sca.core,javax.xml.namespace"
+
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/pom.xml b/sandbox/sebastien/java/embed/modules/common-xml/pom.xml
new file mode 100644
index 0000000000..663851dd03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/pom.xml
@@ -0,0 +1,98 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-common-xml</artifactId>
+ <name>Apache Tuscany SCA Common XML</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>jdk15</id>
+ <activation>
+ <jdk>1.5</jdk>
+ </activation>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.12</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ </profile>
+ </profiles>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java
new file mode 100644
index 0000000000..3bc24f8939
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.xml.sax.InputSource;
+
+/**
+ * @version $Rev$ $Date$]
+ * @tuscany.spi.extension.asclient
+ */
+public class XMLDocumentHelper {
+ protected static final int BUFFER_SIZE = 256;
+
+ /**
+ * Detect the XML encoding of the document
+ *
+ * @param is The input stream
+ * @return The encoding
+ * @throws IOException
+ */
+ public static String getEncoding(InputStream is) throws IOException {
+ if (!is.markSupported())
+ is = new BufferedInputStream(is);
+
+ byte[] buffer = readBuffer(is);
+ return getXMLEncoding(buffer);
+ }
+
+ /**
+ * Searches the array of bytes to determine the XML encoding.
+ */
+ protected static String getXMLEncoding(byte[] bytes) {
+ String javaEncoding = null;
+
+ if (bytes.length >= 4) {
+ if (((bytes[0] == -2) && (bytes[1] == -1)) || ((bytes[0] == 0) && (bytes[1] == 60)))
+ javaEncoding = "UnicodeBig";
+ else if (((bytes[0] == -1) && (bytes[1] == -2)) || ((bytes[0] == 60) && (bytes[1] == 0)))
+ javaEncoding = "UnicodeLittle";
+ else if ((bytes[0] == -17) && (bytes[1] == -69) && (bytes[2] == -65))
+ javaEncoding = "UTF8";
+ }
+
+ String header = null;
+
+ try {
+ if (javaEncoding != null)
+ header = new String(bytes, 0, bytes.length, javaEncoding);
+ else
+ header = new String(bytes, 0, bytes.length);
+ } catch (UnsupportedEncodingException e) {
+ return null;
+ }
+
+ if (!header.startsWith("<?xml"))
+ return "UTF-8";
+
+ int endOfXMLPI = header.indexOf("?>");
+ int encodingIndex = header.indexOf("encoding", 6);
+
+ if ((encodingIndex == -1) || (encodingIndex > endOfXMLPI))
+ return "UTF-8";
+
+ int firstQuoteIndex = header.indexOf("\"", encodingIndex);
+ int lastQuoteIndex;
+
+ if ((firstQuoteIndex == -1) || (firstQuoteIndex > endOfXMLPI)) {
+ firstQuoteIndex = header.indexOf("'", encodingIndex);
+ lastQuoteIndex = header.indexOf("'", firstQuoteIndex + 1);
+ } else
+ lastQuoteIndex = header.indexOf("\"", firstQuoteIndex + 1);
+
+ return header.substring(firstQuoteIndex + 1, lastQuoteIndex);
+ }
+
+ protected static byte[] readBuffer(InputStream is) throws IOException {
+ if (is.available() == 0) {
+ return new byte[0];
+ }
+
+ byte[] buffer = new byte[BUFFER_SIZE];
+ is.mark(BUFFER_SIZE);
+ int bytesRead = is.read(buffer, 0, BUFFER_SIZE);
+ int totalBytesRead = bytesRead;
+
+ while (bytesRead != -1 && (totalBytesRead < BUFFER_SIZE)) {
+ bytesRead = is.read(buffer, totalBytesRead, BUFFER_SIZE - totalBytesRead);
+
+ if (bytesRead != -1)
+ totalBytesRead += bytesRead;
+ }
+
+ if (totalBytesRead < BUFFER_SIZE) {
+ byte[] smallerBuffer = new byte[totalBytesRead];
+ System.arraycopy(buffer, 0, smallerBuffer, 0, totalBytesRead);
+ smallerBuffer = buffer;
+ }
+
+ is.reset();
+ return buffer;
+ }
+
+ public static InputSource getInputSource(URL url) throws IOException {
+ InputStream is = openStream(url);
+ return getInputSource(url, is);
+ }
+
+ private static InputStream openStream(URL url) throws IOException {
+ URLConnection connection = url.openConnection();
+ if (connection instanceof JarURLConnection) {
+ // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041014
+ connection.setUseCaches(false);
+ }
+ InputStream is = connection.getInputStream();
+ return is;
+ }
+
+ public static InputSource getInputSource(URL url, InputStream is) throws IOException {
+ // is = new BufferedInputStream(is);
+ // String encoding = getEncoding(is);
+ InputSource inputSource = new InputSource(is);
+ // inputSource.setEncoding(encoding);
+ // [rfeng] Make sure we set the system id as it will be used as the base URI for nested import/include
+ inputSource.setSystemId(url.toString());
+ return inputSource;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java
new file mode 100644
index 0000000000..304275beb7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.dom;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.sca.common.xml.dom.impl.SAX2DOMAdapter;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+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;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * Helper for DOM
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class DOMHelper {
+ private DocumentBuilderFactory documentBuilderFactory;
+ private TransformerFactory transformerFactory;
+
+ public static DOMHelper getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilities.getUtility(DOMHelper.class);
+ }
+
+ public DOMHelper(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ documentBuilderFactory = factories.getFactory(DocumentBuilderFactory.class);
+ documentBuilderFactory.setNamespaceAware(true);
+ transformerFactory = factories.getFactory(TransformerFactory.class);
+ }
+
+ /**
+ * @param documentBuilderFactory
+ * @param transformerFactory
+ */
+ public DOMHelper(DocumentBuilderFactory documentBuilderFactory, TransformerFactory transformerFactory) {
+ super();
+ this.documentBuilderFactory = documentBuilderFactory;
+ this.transformerFactory = transformerFactory;
+ }
+
+ public Document newDocument() {
+ return newDocumentBuilder().newDocument();
+
+ }
+
+ public DocumentBuilder newDocumentBuilder() {
+ try {
+ return documentBuilderFactory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Document load(String xmlString) throws IOException, SAXException {
+ DocumentBuilder builder = newDocumentBuilder();
+ InputSource is = new InputSource(new StringReader(xmlString));
+ return builder.parse(is);
+ }
+
+ public Document load(Source source) {
+ Transformer transformer = newTransformer();
+ DOMResult result = new DOMResult(newDocument());
+ try {
+ transformer.transform(source, result);
+ } catch (TransformerException e) {
+ throw new IllegalArgumentException(e);
+ }
+ return (Document)result.getNode();
+ }
+
+ public NodeContentHandler createContentHandler(Node root) {
+ if (root == null) {
+ root = newDocument();
+ }
+ return new SAX2DOMAdapter(root);
+ }
+
+ public String saveAsString(Node node) {
+ Transformer transformer = newTransformer();
+ StringWriter sw = new StringWriter();
+ StreamResult result = new StreamResult(sw);
+ try {
+ transformer.transform(new DOMSource(node), result);
+ } catch (TransformerException e) {
+ throw new IllegalArgumentException(e);
+ }
+ return result.getWriter().toString();
+ }
+
+ private Transformer newTransformer() {
+ Transformer transformer = null;
+ try {
+ transformer = transformerFactory.newTransformer();
+ } catch (TransformerConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ return transformer;
+ }
+
+ public void saveAsSAX(Node node, ContentHandler contentHandler) {
+ Transformer transformer = newTransformer();
+ SAXResult result = new SAXResult(contentHandler);
+ try {
+ transformer.transform(new DOMSource(node), result);
+ } catch (TransformerException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static QName getQName(Node node) {
+ String ns = node.getNamespaceURI();
+ String prefix = node.getPrefix();
+ String localName = node.getLocalName();
+ if (localName == null) {
+ localName = node.getNodeName();
+ }
+ if (ns == null) {
+ ns = "";
+ }
+ if (prefix == null) {
+ prefix = "";
+ }
+ return new QName(ns, localName, prefix);
+ }
+
+ public static Element createElement(Document document, QName name) {
+ String prefix = name.getPrefix();
+ String qname =
+ (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name.getLocalPart();
+ return document.createElementNS(name.getNamespaceURI(), qname);
+ }
+
+ /**
+ * Wrap an element as a DOM document
+ * @param node
+ * @return
+ */
+ public static Document promote(Node node) {
+ if (node instanceof Document) {
+ return (Document)node;
+ }
+ Element element = (Element)node;
+ Document doc = element.getOwnerDocument();
+ if (doc.getDocumentElement() == element) {
+ return doc;
+ }
+ 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();
+ }
+ return doc;
+ }
+
+ public static String getPrefix(Element element, String namespace) {
+ if (element.isDefaultNamespace(namespace)) {
+ return XMLConstants.DEFAULT_NS_PREFIX;
+ }
+ return element.lookupPrefix(namespace);
+ }
+
+ public static String getNamespaceURI(Element element, String prefix) {
+ if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
+ prefix = null;
+ }
+ return element.lookupNamespaceURI(prefix);
+ }
+
+ public static interface NodeContentHandler extends ContentHandler, LexicalHandler {
+ Node getNode();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/impl/SAX2DOMAdapter.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/impl/SAX2DOMAdapter.java
new file mode 100644
index 0000000000..11d692c81e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/impl/SAX2DOMAdapter.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2001-2004 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.sca.common.xml.dom.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper.NodeContentHandler;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * SAX2DOM adapter
+ *
+ * @version $Rev$ $Date$
+ */
+public class SAX2DOMAdapter implements DOMHelper.NodeContentHandler {
+ public static final String EMPTYSTRING = "";
+ public static final String XML_PREFIX = "xml";
+ public static final String XMLNS_PREFIX = "xmlns";
+ public static final String XMLNS_STRING = "xmlns:";
+ public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
+
+ private Node root;
+
+ private Document document;
+
+ private Node nextSibling;
+
+ private Stack<Node> nodeStk = new Stack<Node>();
+
+ private List<String> namespaceDecls;
+
+ private Node lastSibling;
+
+ public SAX2DOMAdapter(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ DOMHelper domHelper = utilities.getUtility(DOMHelper.class);
+ this.document = domHelper.newDocument();
+ this.root = document;
+ }
+
+ public SAX2DOMAdapter(Node root, Node nextSibling) {
+ this.root = root;
+ if (root instanceof Document) {
+ this.document = (Document)root;
+ } else if (root != null) {
+ this.document = root.getOwnerDocument();
+ }
+
+ this.nextSibling = nextSibling;
+ }
+
+ public SAX2DOMAdapter(Node root) {
+ this(root, null);
+ }
+
+ public Node getNode() {
+ return root;
+ }
+
+ public void characters(char[] ch, int start, int length) {
+ final Node last = nodeStk.peek();
+
+ // No text nodes can be children of root (DOM006 exception)
+ if (last != document) {
+ final String text = new String(ch, start, length);
+ if (lastSibling != null && lastSibling.getNodeType() == Node.TEXT_NODE) {
+ ((Text)lastSibling).appendData(text);
+ } else if (last == root && nextSibling != null) {
+ lastSibling = last.insertBefore(document.createTextNode(text), nextSibling);
+ } else {
+ lastSibling = last.appendChild(document.createTextNode(text));
+ }
+
+ }
+ }
+
+ public void startDocument() {
+ nodeStk.push(root);
+ }
+
+ public void endDocument() {
+ nodeStk.pop();
+ }
+
+ public void startElement(String namespace, String localName, String qName, Attributes attrs) {
+ final Element tmp = document.createElementNS(namespace, qName);
+
+ // Add namespace declarations first
+ if (namespaceDecls != null) {
+ final int nDecls = namespaceDecls.size();
+ for (int i = 0; i < nDecls; i++) {
+ final String prefix = namespaceDecls.get(i++);
+
+ if (prefix == null || prefix.equals(EMPTYSTRING)) {
+ tmp.setAttributeNS(XMLNS_URI, XMLNS_PREFIX, namespaceDecls.get(i));
+ } else {
+ tmp.setAttributeNS(XMLNS_URI, XMLNS_STRING + prefix, namespaceDecls.get(i));
+ }
+ }
+ namespaceDecls.clear();
+ }
+
+ // Add attributes to element
+ final int nattrs = attrs.getLength();
+ for (int i = 0; i < nattrs; i++) {
+ if (attrs.getLocalName(i) == null) {
+ tmp.setAttribute(attrs.getQName(i), attrs.getValue(i));
+ } else {
+ tmp.setAttributeNS(attrs.getURI(i), attrs.getQName(i), attrs.getValue(i));
+ }
+ }
+
+ // Append this new node onto current stack node
+ Node last = nodeStk.peek();
+
+ // If the SAX2DOM is created with a non-null next sibling node,
+ // insert the result nodes before the next sibling under the root.
+ if (last == root && nextSibling != null) {
+ last.insertBefore(tmp, nextSibling);
+ } else {
+ last.appendChild(tmp);
+ }
+
+ // Push this node onto stack
+ nodeStk.push(tmp);
+ lastSibling = null;
+ }
+
+ public void endElement(String namespace, String localName, String qName) {
+ nodeStk.pop();
+ lastSibling = null;
+ }
+
+ public void startPrefixMapping(String prefix, String uri) {
+ if (namespaceDecls == null) {
+ namespaceDecls = new ArrayList<String>(2);
+ }
+ namespaceDecls.add(prefix);
+ namespaceDecls.add(uri);
+ }
+
+ public void endPrefixMapping(String prefix) {
+ // do nothing
+ }
+
+ /**
+ * This class is only used internally so this method should never be called.
+ */
+ public void ignorableWhitespace(char[] ch, int start, int length) {
+ }
+
+ /**
+ * adds processing instruction node to DOM.
+ */
+ public void processingInstruction(String target, String data) {
+ final Node last = nodeStk.peek();
+ ProcessingInstruction pi = document.createProcessingInstruction(target, data);
+ if (pi != null) {
+ if (last == root && nextSibling != null) {
+ last.insertBefore(pi, nextSibling);
+ } else {
+ last.appendChild(pi);
+ }
+
+ lastSibling = pi;
+ }
+ }
+
+ /**
+ * This class is only used internally so this method should never be called.
+ */
+ public void setDocumentLocator(Locator locator) {
+ }
+
+ /**
+ * This class is only used internally so this method should never be called.
+ */
+ public void skippedEntity(String name) {
+ }
+
+ /**
+ * Lexical Handler method to create comment node in DOM tree.
+ */
+ public void comment(char[] ch, int start, int length) {
+ final Node last = nodeStk.peek();
+ Comment comment = document.createComment(new String(ch, start, length));
+ if (comment != null) {
+ if (last == root && nextSibling != null) {
+ last.insertBefore(comment, nextSibling);
+ } else {
+ last.appendChild(comment);
+ }
+
+ lastSibling = comment;
+ }
+ }
+
+ // Lexical Handler methods- not implemented
+ public void startCDATA() {
+ }
+
+ public void endCDATA() {
+ }
+
+ public void startEntity(java.lang.String name) {
+ }
+
+ public void endDTD() {
+ }
+
+ public void endEntity(String name) {
+ }
+
+ public void startDTD(String name, String publicId, String systemId) throws SAXException {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/sax/SAXHelper.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/sax/SAXHelper.java
new file mode 100644
index 0000000000..dd22912b17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/sax/SAXHelper.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.common.xml.sax;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Helper class for SAX parsing
+ */
+public class SAXHelper {
+ private final SAXParserFactory saxParserFactory;
+
+ /**
+ * @param saxParserFactory
+ */
+ public SAXHelper(SAXParserFactory saxParserFactory) {
+ super();
+ this.saxParserFactory = saxParserFactory;
+ }
+
+ public SAXHelper(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ saxParserFactory = factories.getFactory(SAXParserFactory.class);
+ saxParserFactory.setNamespaceAware(true);
+ }
+
+ public SAXHelper getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilities.getUtility(SAXHelper.class);
+ }
+
+ public SAXParser newSAXParser() throws SAXException {
+ try {
+ return saxParserFactory.newSAXParser();
+ } catch (ParserConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public XMLReader newXMLReader() throws SAXException {
+ return newSAXParser().getXMLReader();
+ }
+
+ public void parse(String xmlString, ContentHandler handler) throws SAXException, IOException {
+ XMLReader reader = newXMLReader();
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(new StringReader(xmlString)));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java
new file mode 100644
index 0000000000..d7c85f01b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java
@@ -0,0 +1,573 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.StreamFilter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.common.xml.stax.impl.StAX2SAXAdapter;
+import org.apache.tuscany.sca.common.xml.stax.impl.XMLStreamSerializer;
+import org.apache.tuscany.sca.common.xml.stax.reader.DOMXMLStreamReader;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Helper class for StAX
+ * @tuscany.spi.extension.asclient
+ */
+public class StAXHelper {
+ private final XMLInputFactory inputFactory;
+ private final XMLOutputFactory outputFactory;
+ private final DOMHelper domHelper;
+
+ public StAXHelper(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ factories.getFactory(XMLInputFactory.class);
+ inputFactory = factories.getFactory(XMLInputFactory.class);
+ outputFactory = factories.getFactory(XMLOutputFactory.class);
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ domHelper = utilities.getUtility(DOMHelper.class);
+ }
+
+ public static StAXHelper getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilities.getUtility(StAXHelper.class);
+ }
+
+ /**
+ * @param inputFactory
+ * @param outputFactory
+ * @param domHelper
+ */
+ public StAXHelper(XMLInputFactory inputFactory, XMLOutputFactory outputFactory, DOMHelper domHelper) {
+ super();
+ this.inputFactory = inputFactory;
+ this.outputFactory = outputFactory;
+ if (outputFactory != null) {
+ this.outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ }
+ this.domHelper = domHelper;
+ }
+
+ public XMLStreamReader createXMLStreamReader(InputStream inputStream) throws XMLStreamException {
+ return inputFactory.createXMLStreamReader(inputStream);
+ }
+
+ public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException {
+ return inputFactory.createXMLStreamReader(reader);
+ }
+
+ public XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException {
+ return inputFactory.createXMLStreamReader(source);
+ }
+
+ public XMLStreamReader createXMLStreamReader(Node node) throws XMLStreamException {
+ /*
+ // DOMSource is not supported by the XMLInputFactory from JDK 6
+ DOMSource source = new DOMSource(node);
+ return createXMLStreamReader(source);
+ */
+ return new DOMXMLStreamReader(node);
+ }
+
+ public XMLStreamReader createXMLStreamReader(String string) throws XMLStreamException {
+ StringReader reader = new StringReader(string);
+ return createXMLStreamReader(reader);
+ }
+
+ private static InputStream openStream(URL url) throws IOException {
+ URLConnection connection = url.openConnection();
+ if (connection instanceof JarURLConnection) {
+ // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041014
+ connection.setUseCaches(false);
+ }
+ InputStream is = connection.getInputStream();
+ return is;
+ }
+
+ public XMLStreamReader createXMLStreamReader(URL url) throws XMLStreamException {
+ try {
+ // Set up a StreamSource from the url, since this has an associated URL that
+ // can be used by the parser to find references to other files such as DTDs
+ StreamSource scdlSource = new StreamSource( openStream(url), url.toString() );
+ return inputFactory.createXMLStreamReader(scdlSource);
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ public String saveAsString(XMLStreamReader reader) throws XMLStreamException {
+ StringWriter writer = new StringWriter();
+ save(reader, writer);
+ return writer.toString();
+ }
+
+ public void save(XMLStreamReader reader, OutputStream outputStream) throws XMLStreamException {
+ XMLStreamWriter streamWriter = createXMLStreamWriter(outputStream);
+ save(reader, streamWriter);
+ }
+
+ public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream) throws XMLStreamException {
+ return outputFactory.createXMLStreamWriter(outputStream);
+ }
+
+ public void save(XMLStreamReader reader, Writer writer) throws XMLStreamException {
+ XMLStreamWriter streamWriter = createXMLStreamWriter(writer);
+ save(reader, streamWriter);
+ }
+
+ public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException {
+ return outputFactory.createXMLStreamWriter(writer);
+ }
+
+ public Node saveAsNode(XMLStreamReader reader) throws XMLStreamException {
+ // woodstox 3.2.4 fails due to http://jira.codehaus.org/browse/WSTX-144
+ // this issue has been fixed in woodstox 3.2.9
+ // We can use the commented code once we move to woodstox 3.2.9
+ /*
+ XMLStreamSerializer serializer = new XMLStreamSerializer();
+ Document document = domHelper.newDocument();
+ DOMResult result = new DOMResult(document);
+ XMLStreamWriter streamWriter = createXMLStreamWriter(result);
+ serializer.serialize(reader, streamWriter);
+ streamWriter.flush();
+ return result.getNode();
+ */
+ Document root = domHelper.newDocument();
+ ContentHandler handler = domHelper.createContentHandler(root);
+ try {
+ saveAsSAX(reader, handler);
+ } catch (SAXException e) {
+ throw new XMLStreamException(e);
+ }
+ return root;
+ }
+
+ public XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException {
+ return outputFactory.createXMLStreamWriter(result);
+ }
+
+ public void save(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ XMLStreamSerializer serializer = new XMLStreamSerializer(isReparingNamespaces());
+ serializer.serialize(reader, writer);
+ writer.flush();
+ }
+
+ public void saveAsSAX(XMLStreamReader reader, ContentHandler contentHandler) throws XMLStreamException,
+ SAXException {
+ new StAX2SAXAdapter(false).parse(reader, contentHandler);
+ }
+
+ /**
+ * @param url
+ * @param element
+ * @param attribute
+ * @param rootOnly
+ * @return
+ * @throws IOException
+ * @throws XMLStreamException
+ */
+ public String readAttribute(URL url, QName element, String attribute) throws IOException, XMLStreamException {
+ if (attribute == null) {
+ attribute = "targetNamespace";
+ }
+ XMLStreamReader reader = createXMLStreamReader(url);
+ try {
+ return readAttributeFromRoot(reader, element, attribute);
+ } finally {
+ reader.close();
+ }
+ }
+
+ public List<String> readAttributes(URL url, QName element, String attribute) throws IOException, XMLStreamException {
+ if (attribute == null) {
+ attribute = "targetNamespace";
+ }
+ XMLStreamReader reader = createXMLStreamReader(url);
+ try {
+ Attribute attr = new Attribute(element, attribute);
+ return readAttributes(reader, attr)[0].getValues();
+ } finally {
+ reader.close();
+ }
+ }
+
+ /**
+ * Returns the boolean value of an attribute.
+ * @param reader
+ * @param name
+ * @return
+ */
+ public static Boolean getAttributeAsBoolean(XMLStreamReader reader, String name) {
+ String value = reader.getAttributeValue(null, name);
+ if (value == null) {
+ return null;
+ }
+ return Boolean.valueOf(value);
+ }
+
+ /**
+ * Returns the QName value of an attribute.
+ * @param reader
+ * @param name
+ * @return
+ */
+ public static QName getAttributeAsQName(XMLStreamReader reader, String name) {
+ String qname = reader.getAttributeValue(null, name);
+ return getValueAsQName(reader, qname);
+ }
+
+ /**
+ * Returns the value of an attribute as a list of QNames.
+ * @param reader
+ * @param name
+ * @return
+ */
+ public static List<QName> getAttributeAsQNames(XMLStreamReader reader, String name) {
+ String value = reader.getAttributeValue(null, name);
+ if (value != null) {
+ List<QName> qnames = new ArrayList<QName>();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ qnames.add(getValueAsQName(reader, tokens.nextToken()));
+ }
+ return qnames;
+ } else {
+ return Collections.emptyList();
+ }
+ }
+
+ /**
+ * Returns a QName from a string.
+ * @param reader
+ * @param value
+ * @return
+ */
+ public static QName getValueAsQName(XMLStreamReader reader, String value) {
+ if (value != null) {
+ int index = value.indexOf(':');
+ String prefix = index == -1 ? "" : value.substring(0, index);
+ String localName = index == -1 ? value : value.substring(index + 1);
+ String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
+ if (ns == null) {
+ ns = "";
+ }
+ return new QName(ns, localName, prefix);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the string value of an attribute.
+ * @param reader
+ * @param name
+ * @return
+ */
+ public static String getAttributeAsString(XMLStreamReader reader, String name) {
+ return reader.getAttributeValue(null, name);
+ }
+
+ /**
+ * TUSCANY-242
+ *
+ * Returns the URI value of an attribute as a string and first applies the
+ * URI whitespace processing as defined in section 4.3.6 of XML Schema Part2: Datatypes
+ * [http://www.w3.org/TR/xmlschema-2/#rf-facets]. anyURI is defined with the following
+ * XSD:
+ * <xs:simpleType name="anyURI" id="anyURI">
+ * <xs:restriction base="xs:anySimpleType">
+ * <xs:whiteSpace value="collapse" fixed="true" id="anyURI.whiteSpace"/>
+ * </xs:restriction>
+ * </xs:simpleType>
+ *
+ * The <xs:whiteSpace value="collapse"/> constraining facet is defined as follows
+ *
+ * replace
+ * All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are replaced with #x20 (space)
+ * collapse
+ * After the processing implied by replace, contiguous sequences of #x20's are collapsed to a single #x20,
+ * and leading and trailing #x20's are removed
+ *
+ * It seems that the StAX parser does apply this rule so we do it here.
+ *
+ * @param reader
+ * @param name
+ * @return
+ */
+ public static String getAttributeAsURIString(XMLStreamReader reader, String name) {
+ // get the basic string value
+ String uri = reader.getAttributeValue(null, name);
+
+ // apply the "collapse" rule
+ if (uri != null){
+ // turn tabs, line feeds and carriage returns into spaces
+ uri = uri.replace('\t', ' ');
+ uri = uri.replace('\n', ' ');
+ uri = uri.replace('\r', ' ');
+
+ // remote leading and trailing spaces. Other whitespace
+ // has already been converted to spaces above
+ uri = uri.trim();
+
+ // collapse any contiguous spaces into a single space
+ StringBuilder sb= new StringBuilder(uri.length());
+ boolean spaceFound= false;
+ for(int i=0; i< uri.length(); ++i){
+ char c= uri.charAt(i);
+ if(c == ' '){
+ if(!spaceFound){
+ sb.append(c);
+ spaceFound = true;
+ } else {
+ // collapse the space by ignoring it
+ }
+ }else{
+ sb.append(c);
+ spaceFound= false;
+ }
+ }
+ uri = sb.toString();
+ }
+
+ return uri;
+ }
+
+ /**
+ * Returns the value of xsi:type attribute
+ * @param reader The XML stream reader
+ * @return The QName of the type, if the attribute is not present, null is
+ * returned.
+ */
+ public static QName getXSIType(XMLStreamReader reader) {
+ String qname = reader.getAttributeValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type");
+ return getValueAsQName(reader, qname);
+ }
+
+ /**
+ * Test if an attribute is explicitly set
+ * @param reader
+ * @param name
+ * @return
+ */
+ public static boolean isAttributePresent(XMLStreamReader reader, String name) {
+ return reader.getAttributeValue(null, name) != null;
+ }
+
+ /**
+ * Advance the stream to the next END_ELEMENT event skipping any nested
+ * content.
+ * @param reader the reader to advance
+ * @throws XMLStreamException if there was a problem reading the stream
+ */
+ public static void skipToEndElement(XMLStreamReader reader) throws XMLStreamException {
+ int depth = 0;
+ while (reader.hasNext()) {
+ int event = reader.next();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ depth++;
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
+ if (depth == 0) {
+ return;
+ }
+ depth--;
+ }
+ }
+ }
+
+ private Attribute[] readAttributes(XMLStreamReader reader, AttributeFilter filter) throws XMLStreamException {
+ XMLStreamReader newReader = inputFactory.createFilteredReader(reader, filter);
+ while (filter.proceed() && newReader.hasNext()) {
+ newReader.next();
+ }
+ return filter.attributes;
+ }
+
+ public Attribute[] readAttributes(URL url, Attribute... attributes) throws XMLStreamException {
+ XMLStreamReader reader = createXMLStreamReader(url);
+ try {
+ return readAttributes(reader, attributes);
+ } finally {
+ reader.close();
+ }
+ }
+
+ public Attribute[] readAttributes(XMLStreamReader reader, Attribute... attributes) throws XMLStreamException {
+ return readAttributes(reader, new AttributeFilter(false, attributes));
+ }
+
+ private String readAttributeFromRoot(XMLStreamReader reader, Attribute filter) throws XMLStreamException {
+ Attribute[] attrs = readAttributes(reader, new AttributeFilter(true, filter));
+ List<String> values = attrs[0].getValues();
+ if (values.isEmpty()) {
+ return null;
+ } else {
+ return values.get(0);
+ }
+ }
+
+ public String readAttributeFromRoot(XMLStreamReader reader, QName element, String attributeName)
+ throws XMLStreamException {
+ Attribute filter = new Attribute(element, attributeName);
+ return readAttributeFromRoot(reader, filter);
+ }
+
+ /**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+ public static class Attribute {
+ private QName element;
+ private String name;
+ private List<String> values = new ArrayList<String>();
+
+ /**
+ * @param element
+ * @param name
+ */
+ public Attribute(QName element, String name) {
+ super();
+ this.element = element;
+ this.name = name;
+ }
+
+ public List<String> getValues() {
+ return values;
+ }
+
+ }
+
+ private static class AttributeFilter implements StreamFilter {
+ private boolean proceed = true;
+ private Attribute[] attributes;
+ private boolean rootOnly;
+
+ /**
+ * @param rootOnly
+ */
+ public AttributeFilter(boolean rootOnly, Attribute... attributes) {
+ super();
+ this.rootOnly = rootOnly;
+ this.attributes = attributes;
+ }
+
+ public boolean accept(XMLStreamReader reader) {
+ if (attributes == null || attributes.length == 0) {
+ proceed = false;
+ return true;
+ }
+ if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
+ QName name = reader.getName();
+ for (Attribute attr : attributes) {
+ if (attr.element.equals(name)) {
+ attr.values.add(reader.getAttributeValue(null, attr.name));
+ }
+ }
+ if (rootOnly) {
+ proceed = false;
+ }
+ }
+ return true;
+ }
+
+ public boolean proceed() {
+ return proceed;
+ }
+
+ }
+
+ public XMLInputFactory getInputFactory() {
+ return inputFactory;
+ }
+
+ private boolean isReparingNamespaces() {
+ if (outputFactory == null) {
+ return Boolean.TRUE;
+ }
+ return outputFactory.getProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES) == Boolean.TRUE;
+ }
+
+ public XMLOutputFactory getOutputFactory() {
+ return outputFactory;
+ }
+
+ public String writeAttribute(XMLStreamWriter writer, QName name, String value) throws XMLStreamException {
+ return writeAttribute(writer, name.getPrefix(), name.getLocalPart(), name.getNamespaceURI(), value);
+ }
+
+ public String writeAttribute(XMLStreamWriter writer,
+ String prefix,
+ String localName,
+ String namespaceURI,
+ String value) throws XMLStreamException {
+ if (value == null) {
+ return null;
+ }
+ XMLStreamSerializer serializer = new XMLStreamSerializer(isReparingNamespaces());
+ return serializer.writeAttribute(writer, prefix, localName, namespaceURI, value);
+ }
+
+ public void writeStartElement(XMLStreamWriter writer, QName name) throws XMLStreamException {
+ writeStartElement(writer, name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
+ }
+
+ public void writeStartElement(XMLStreamWriter writer, String prefix, String localName, String namespaceURI)
+ throws XMLStreamException {
+ XMLStreamSerializer serializer = new XMLStreamSerializer(isReparingNamespaces());
+ serializer.writeStartElement(writer, prefix, localName, namespaceURI);
+ }
+
+ public String writeNamespace(XMLStreamWriter writer, String prefix, String namespaceURI) throws XMLStreamException {
+ XMLStreamSerializer serializer = new XMLStreamSerializer(isReparingNamespaces());
+ return serializer.writeNamespace(writer, prefix, namespaceURI);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/StAX2SAXAdapter.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/StAX2SAXAdapter.java
new file mode 100644
index 0000000000..df0fc069b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/StAX2SAXAdapter.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.impl;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * Adapter that converts from StAX to SAX event streams. Currently the following
+ * SAX events are not generated:
+ * <ul>
+ * <li>ignorableWhitespace</li>
+ * <li>skippedEntity</li>
+ * <ul>
+ * Also the following StAX events are not mapped:
+ * <ul>
+ * <li>CDATA</li>
+ * <li>COMMENT</li>
+ * <li>DTD</li>
+ * <li>ENTITY_DECLARATION</li>
+ * <li>ENTITY_REFERENCE</li>
+ * <li>NOTATION_DECLARATION</li>
+ * <li>SPACE</li>
+ * </ul>
+ * StAX ATTRIBUTE events are ignored but the equivalent attributes (derived from
+ * the START_ELEMENT event) are supplied in the SAX startElement event's
+ * Attributes parameter. If the adaptor is configured to pass namespace prefixes
+ * then namespace information will also be included in the Attributes; StAX
+ * NAMESPACE events are ignored. <p/> Another issue is namespace processing. If
+ * the reader is positioned at a sub-node, we cannot capture all the in-scope
+ * namespace bindings. Therefore we cannot re-create a proper SAX event stream
+ * from a StAX parser. <p/> For example <p/> &lt;a:root xmlns:a="foo"
+ * xmlns:b="bar"&gt;&lt;b:sub&gt;a:foo&lt;/b:sub&gt;&lt;/a:root&gt; <p/> And if
+ * you are handed a parser at &lt;b:sub&gt;, then your SAX events should look
+ * like: <p/> &lt;b:sub xmlns:a="foo" xmlns:b="bar"&gt;a:foo&lt;/b:sub&gt; <p/>
+ * not: <p/> &lt;b:sub&gt;a:foo&lt;/b:sub&gt; <p/> <p/> Proposal: we change the
+ * receiver of SAX events (SDOXMLResourceImpl) so that it uses NamespaceContext
+ * to resolve prefix (as opposed to record start/endPrefixMappings and use it
+ * for resolution.)
+ *
+ * @version $Rev$ $Date$
+ */
+public class StAX2SAXAdapter {
+ private final boolean namespacePrefixes;
+
+ /**
+ * Construct a new StAX to SAX adapter that will convert a StAX event stream
+ * into a SAX event stream.
+ *
+ * @param namespacePrefixes whether xmlns attributes should be included in
+ * startElement events;
+ */
+ public StAX2SAXAdapter(boolean namespacePrefixes) {
+ this.namespacePrefixes = namespacePrefixes;
+ }
+
+ /**
+ * Pull events from the StAX stream and dispatch to the SAX ContentHandler.
+ * The StAX stream would typically be located on a START_DOCUMENT or
+ * START_ELEMENT event and when this method returns it will be located on
+ * the associated END_DOCUMENT or END_ELEMENT event. Behaviour with other
+ * start events is undefined.
+ *
+ * @param reader StAX event source to read
+ * @param handler SAX ContentHandler for processing events
+ * @throws XMLStreamException if there was a problem reading the stream
+ * @throws SAXException passed through from the ContentHandler
+ */
+ public void parse(XMLStreamReader reader, ContentHandler handler) throws XMLStreamException, SAXException {
+ handler.setDocumentLocator(new LocatorAdaptor(reader.getLocation()));
+
+ // remembers the nest level of elements to know when we are done
+ int level = 0;
+ int event = reader.getEventType();
+ while (true) {
+ switch (event) {
+ case XMLStreamConstants.START_DOCUMENT:
+ level++;
+ handler.startDocument();
+ break;
+ case XMLStreamConstants.START_ELEMENT:
+ level++;
+ handleStartElement(reader, handler);
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ handler.processingInstruction(reader.getPITarget(), reader.getPIData());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ handler.characters(reader.getTextCharacters(), reader.getTextStart(), reader
+ .getTextLength());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ handleEndElement(reader, handler);
+ level--;
+ if (level == 0) {
+ return;
+ }
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ handler.endDocument();
+ return;
+ /*
+ * uncomment to handle all events rather than just mapped
+ * ones // StAX events that are not mapped to SAX case
+ * XMLStreamConstants.COMMENT: case
+ * XMLStreamConstants.SPACE: case
+ * XMLStreamConstants.ENTITY_REFERENCE: case
+ * XMLStreamConstants.DTD: case XMLStreamConstants.CDATA:
+ * case XMLStreamConstants.NOTATION_DECLARATION: case
+ * XMLStreamConstants.ENTITY_DECLARATION: break; // StAX
+ * events handled in START_ELEMENT case
+ * XMLStreamConstants.ATTRIBUTE: case
+ * XMLStreamConstants.NAMESPACE: break; default: throw new
+ * AssertionError("Unknown StAX event: " + event);
+ */
+ }
+ event = reader.next();
+ }
+ }
+
+ private void handleStartElement(XMLStreamReader reader, ContentHandler handler) throws SAXException {
+ // send startPrefixMapping events immediately before startElement event
+ int nsCount = reader.getNamespaceCount();
+ for (int i = 0; i < nsCount; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ if (prefix == null) { // true for default namespace
+ prefix = "";
+ }
+ handler.startPrefixMapping(prefix, reader.getNamespaceURI(i));
+ }
+
+ // fire startElement
+ QName qname = reader.getName();
+ String prefix = qname.getPrefix();
+ String rawname;
+ if (prefix == null || prefix.length() == 0) {
+ rawname = qname.getLocalPart();
+ } else {
+ rawname = prefix + ':' + qname.getLocalPart();
+ }
+ Attributes attrs = getAttributes(reader);
+ handler.startElement(qname.getNamespaceURI(), qname.getLocalPart(), rawname, attrs);
+ }
+
+ private static void handleEndElement(XMLStreamReader reader, ContentHandler handler) throws SAXException {
+ // fire endElement
+ QName qname = reader.getName();
+ handler.endElement(qname.getNamespaceURI(), qname.getLocalPart(), qname.toString());
+
+ // send endPrefixMapping events immediately after endElement event
+ // we send them in the opposite order to that returned but this is not
+ // actually required by SAX
+ int nsCount = reader.getNamespaceCount();
+ for (int i = nsCount - 1; i >= 0; i--) {
+ String prefix = reader.getNamespacePrefix(i);
+ if (prefix == null) { // true for default namespace
+ prefix = "";
+ }
+ handler.endPrefixMapping(prefix);
+ }
+ }
+
+ /**
+ * Get the attributes associated with the current START_ELEMENT event.
+ *
+ * @return the StAX attributes converted to org.xml.sax.Attributes
+ */
+ private Attributes getAttributes(XMLStreamReader reader) {
+ assert reader.getEventType() == XMLStreamConstants.START_ELEMENT;
+
+ AttributesImpl attrs = new AttributesImpl();
+
+ // add namespace declarations if required
+ if (namespacePrefixes) {
+ for (int i = 0; i < reader.getNamespaceCount(); i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String uri = reader.getNamespaceURI(i);
+ attrs.addAttribute(null, prefix, "xmlns:" + prefix, "CDATA", uri);
+ }
+ }
+
+ // Regular attributes
+ for (int i = 0; i < reader.getAttributeCount(); i++) {
+ String uri = reader.getAttributeNamespace(i);
+ if (uri == null) {
+ uri = "";
+ }
+ String localName = reader.getAttributeLocalName(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname;
+ if (prefix == null || prefix.length() == 0) {
+ qname = localName;
+ } else {
+ qname = prefix + ':' + localName;
+ }
+ String type = reader.getAttributeType(i);
+ String value = reader.getAttributeValue(i);
+
+ attrs.addAttribute(uri, localName, qname, type, value);
+ }
+
+ return attrs;
+ }
+
+ /**
+ * Adaptor for mapping Locator information.
+ */
+ private static final class LocatorAdaptor implements Locator {
+ private final Location location;
+
+ private LocatorAdaptor(Location location) {
+ this.location = location;
+ }
+
+ public int getColumnNumber() {
+ return location == null ? 0 : location.getColumnNumber();
+ }
+
+ public int getLineNumber() {
+ return location == null ? 0 : location.getLineNumber();
+ }
+
+ public String getPublicId() {
+ return location == null ? "" : location.getPublicId();
+ }
+
+ public String getSystemId() {
+ return location == null ? "" : location.getSystemId();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java
new file mode 100644
index 0000000000..883199e4dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java
@@ -0,0 +1,368 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.impl;
+
+import static javax.xml.XMLConstants.DEFAULT_NS_PREFIX;
+import static javax.xml.XMLConstants.NULL_NS_URI;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * The XMLStreamSerializer pulls events from the XMLStreamReader and dumps into the XMLStreamWriter
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLStreamSerializer implements XMLStreamConstants {
+ public static final String NAMESPACE_PREFIX = "ns";
+ private static int namespaceSuffix;
+
+ /*
+ * The behavior of the Serializer is such that it returns when it encounters the starting element for the second
+ * time. The depth variable tracks the depth of the Serializer and tells it when to return. Note that it is assumed
+ * that this Serialization starts on an Element.
+ */
+
+ /**
+ * Field depth
+ */
+ private int depth;
+
+ /**
+ * A flag to tell if the writer has javax.xml.stream.isRepairingNamespaces set to true
+ */
+ private boolean isRepairingNamespaces = true;
+
+ /**
+ * @param isRepairingNamespaces
+ */
+ public XMLStreamSerializer(boolean isRepairingNamespaces) {
+ super();
+ this.isRepairingNamespaces = isRepairingNamespaces;
+ }
+
+ public XMLStreamSerializer() {
+ this(true);
+ }
+
+ /**
+ * Generates a unique namespace prefix that is not in the scope of the NamespaceContext
+ *
+ * @param nsCtxt
+ * @return string
+ */
+ private String generateUniquePrefix(NamespaceContext nsCtxt) {
+ String prefix = NAMESPACE_PREFIX + namespaceSuffix++;
+ // null should be returned if the prefix is not bound!
+ while (nsCtxt.getNamespaceURI(prefix) != null) {
+ prefix = NAMESPACE_PREFIX + namespaceSuffix++;
+ }
+
+ return prefix;
+ }
+
+ /**
+ * Method serialize.
+ *
+ * @param node
+ * @param writer
+ * @throws XMLStreamException
+ */
+ public void serialize(XMLStreamReader node, XMLStreamWriter writer) throws XMLStreamException {
+ serializeNode(node, writer);
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeAttributes(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ int count = reader.getAttributeCount();
+ String prefix;
+ String namespaceName;
+ String localName;
+ String value;
+ for (int i = 0; i < count; i++) {
+ prefix = reader.getAttributePrefix(i);
+ namespaceName = reader.getAttributeNamespace(i);
+ localName = reader.getAttributeLocalName(i);
+ value = reader.getAttributeValue(i);
+
+ writeAttribute(writer, prefix, localName, namespaceName, value);
+
+ }
+ }
+
+ public void writeAttribute(XMLStreamWriter writer, QName name, String value) throws XMLStreamException {
+ writeAttribute(writer, name.getPrefix(), name.getLocalPart(), name.getNamespaceURI(), value);
+ }
+
+ public String writeAttribute(XMLStreamWriter writer,
+ String prefix,
+ String localName,
+ String namespaceURI,
+ String value) throws XMLStreamException {
+ String writerPrefix;
+ /*
+ * Due to parser implementations returning null as the namespace URI (for the empty namespace) we need to
+ * make sure that we deal with a namespace name that is not null. The best way to work around this issue is
+ * to set the namespace URI to "" if it is null
+ */
+ if (namespaceURI == null) {
+ namespaceURI = NULL_NS_URI;
+ }
+
+ if (prefix == null) {
+ prefix = DEFAULT_NS_PREFIX;
+ }
+
+ if (isRepairingNamespaces) {
+ writer.writeAttribute(prefix, namespaceURI, localName, value);
+ return writer.getPrefix(namespaceURI);
+ }
+
+ writerPrefix = writer.getPrefix(namespaceURI);
+
+ if (!NULL_NS_URI.equals(namespaceURI)) {
+ if (writerPrefix != null && isDefaultNSPrefix(prefix)) {
+ // prefix has already being declared but this particular attrib has a
+ // no prefix attached. So use the prefix provided by the writer
+
+ writer.writeAttribute(writerPrefix, namespaceURI, localName, value);
+ return writerPrefix;
+
+ } else if (!isDefaultNSPrefix(prefix) && !prefix.equals(writerPrefix)) {
+ // writer prefix is available but different from the current
+ // prefix of the attrib. We should be declaring the new prefix
+ // as a namespace declaration
+
+ writer.writeNamespace(prefix, namespaceURI);
+ writer.writeAttribute(prefix, namespaceURI, localName, value);
+ return prefix;
+
+ } else if (isDefaultNSPrefix(prefix)) {
+ // prefix is null (or empty), but the namespace name is valid! it has not
+ // being written previously also. So we need to generate a prefix here
+
+ prefix = generateUniquePrefix(writer.getNamespaceContext());
+ writer.writeNamespace(prefix, namespaceURI);
+ writer.writeAttribute(prefix, namespaceURI, localName, value);
+ return prefix;
+ } else {
+ writer.writeAttribute(prefix, namespaceURI, localName, value);
+ return prefix;
+ }
+ } else {
+ // empty namespace is equal to no namespace!
+ writer.writeAttribute(localName, value);
+ return prefix;
+ }
+ }
+
+ private boolean isDefaultNSPrefix(String prefix) {
+ return (prefix == null || prefix.equals(DEFAULT_NS_PREFIX));
+ }
+
+ /**
+ * Method serializeCData.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeCData(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeCData(reader.getText());
+ }
+
+ /**
+ * Method serializeComment.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeComment(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeComment(reader.getText());
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ writeStartElement(writer, reader.getName());
+
+ // add the namespaces
+ int count = reader.getNamespaceCount();
+ String namespacePrefix;
+ for (int i = 0; i < count; i++) {
+ namespacePrefix = reader.getNamespacePrefix(i);
+ serializeNamespace(namespacePrefix, reader.getNamespaceURI(i), writer);
+ }
+
+ // add attributes
+ serializeAttributes(reader, writer);
+
+ }
+
+ public void writeStartElement(XMLStreamWriter writer, QName name) throws XMLStreamException {
+ writeStartElement(writer, name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
+ }
+
+ public void writeStartElement(XMLStreamWriter writer, String prefix, String localName, String namespaceURI)
+ throws XMLStreamException {
+
+ if (namespaceURI == null) {
+ namespaceURI = NULL_NS_URI;
+ }
+ if (prefix == null) {
+ prefix = DEFAULT_NS_PREFIX;
+ }
+
+ if (isRepairingNamespaces) {
+ writer.writeStartElement(prefix, localName, namespaceURI);
+ return;
+ }
+
+ String writerPrefix = writer.getPrefix(namespaceURI);
+ if (writerPrefix != null) {
+ // Namespace is bound
+ writer.writeStartElement(writerPrefix, localName, namespaceURI);
+ } else {
+ // Namespace is not bound
+ if (NULL_NS_URI.equals(namespaceURI)) {
+ writer.writeStartElement(localName);
+ String defaultNS = writer.getNamespaceContext().getNamespaceURI(DEFAULT_NS_PREFIX);
+ if (defaultNS != null && !NULL_NS_URI.equals(defaultNS)) {
+ writer.writeNamespace(prefix, namespaceURI);
+ }
+ } else {
+ writer.writeStartElement(prefix, localName, namespaceURI);
+ // writeNamespace() will call setPrefix()
+ writer.writeNamespace(prefix, namespaceURI);
+ }
+ }
+ }
+
+ /**
+ * Method serializeEndElement.
+ *
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeEndElement();
+ }
+
+ /**
+ * Method serializeNamespace.
+ *
+ * @param prefix
+ * @param uri
+ * @param writer
+ * @throws XMLStreamException
+ */
+ private void serializeNamespace(String prefix, String uri, XMLStreamWriter writer) throws XMLStreamException {
+ writeNamespace(writer, prefix, uri);
+ }
+
+ public String writeNamespace(XMLStreamWriter writer, String prefix, String uri) throws XMLStreamException {
+ if (uri == null) {
+ uri = NULL_NS_URI;
+ }
+ String prefix1 = writer.getPrefix(uri);
+ if (prefix1 == null) {
+ if (prefix == null) {
+ prefix = DEFAULT_NS_PREFIX;
+ }
+ if (DEFAULT_NS_PREFIX.equals(prefix) && !XMLConstants.NULL_NS_URI.equals(uri)) {
+ String ns = writer.getNamespaceContext().getNamespaceURI(prefix);
+ if (ns != null) {
+ prefix = generateUniquePrefix(writer.getNamespaceContext());
+ }
+ }
+ writer.writeNamespace(prefix, uri);
+ return prefix;
+ } else {
+ return prefix1;
+ }
+ }
+
+ /**
+ * Method serializeNode.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeNode(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ while (true) {
+ int event = reader.getEventType();
+ if (event == START_ELEMENT) {
+ serializeElement(reader, writer);
+ depth++;
+ } else if (event == ATTRIBUTE) {
+ serializeAttributes(reader, writer);
+ } else if (event == CHARACTERS) {
+ serializeText(reader, writer);
+ } else if (event == COMMENT) {
+ serializeComment(reader, writer);
+ } else if (event == CDATA) {
+ serializeCData(reader, writer);
+ } else if (event == END_ELEMENT) {
+ serializeEndElement(writer);
+ depth--;
+ } else if (event == START_DOCUMENT) {
+ depth++; // if a start document is found then increment
+ writer.writeStartDocument();
+ // the depth
+ } else if (event == END_DOCUMENT) {
+ if (depth != 0) {
+ depth--; // for the end document - reduce the depth
+ }
+ writer.writeEndDocument();
+ }
+ if (depth == 0) {
+ break;
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeText(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeCharacters(reader.getText());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXMLStreamReader.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXMLStreamReader.java
new file mode 100644
index 0000000000..b0224b6ca5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXMLStreamReader.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 org.apache.tuscany.sca.common.xml.stax.reader;
+
+import org.w3c.dom.Node;
+
+public class DOMXMLStreamReader extends XmlTreeStreamReaderImpl {
+
+ public DOMXMLStreamReader(Node node) {
+ super(new DOMXmlNodeImpl(node));
+ switch (node.getNodeType()) {
+ case Node.DOCUMENT_NODE:
+ break;
+ case Node.ELEMENT_NODE:
+ break;
+ default:
+ throw new IllegalArgumentException("Illegal node type: " + node);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXmlNodeImpl.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXmlNodeImpl.java
new file mode 100644
index 0000000000..faa56701ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXmlNodeImpl.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.common.xml.stax.reader;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DOMXmlNodeImpl implements XmlNode {
+ private Node node;
+ private Map<String, String> namespaces;
+ private Type type;
+
+ /**
+ * @param element
+ */
+ public DOMXmlNodeImpl(Node element) {
+ super();
+ if (element.getNodeType() == Node.DOCUMENT_NODE) {
+ this.node = ((Document)element).getDocumentElement();
+ } else {
+ this.node = element;
+ }
+ switch (node.getNodeType()) {
+ case Node.CDATA_SECTION_NODE:
+ this.type = Type.CHARACTERS;
+ break;
+ case Node.ELEMENT_NODE:
+ this.type = Type.ELEMENT;
+ break;
+ case Node.TEXT_NODE:
+ this.type = Type.CHARACTERS;
+ break;
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#attributes()
+ */
+ public List<XmlNode> attributes() {
+ if (type != Type.ELEMENT) {
+ return null;
+ }
+ NamedNodeMap attrs = node.getAttributes();
+ List<XmlNode> xmlAttrs = new ArrayList<XmlNode>();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ Attr attr = (Attr)attrs.item(i);
+ if (!attr.getName().equals("xmlns") && !attr.getName().startsWith("xmlns:")) {
+ xmlAttrs.add(new SimpleXmlNodeImpl(getQName(attr), attr.getValue(), XmlNode.Type.ATTRIBUTE));
+ }
+ }
+ return xmlAttrs;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#children()
+ */
+ public Iterator<XmlNode> children() {
+ if (type != Type.ELEMENT) {
+ return null;
+ }
+ NodeList nodes = node.getChildNodes();
+ List<XmlNode> xmlNodes = new ArrayList<XmlNode>();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node child = (Node)nodes.item(i);
+ int nodeType = child.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE || nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ xmlNodes.add(new DOMXmlNodeImpl(child));
+ }
+ }
+ return xmlNodes.iterator();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#getName()
+ */
+ public QName getName() {
+ return getQName(node);
+ }
+
+ private static QName getQName(Node node) {
+ return DOMHelper.getQName(node);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#getValue()
+ */
+ public String getValue() {
+ return node.getNodeValue();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#namespaces()
+ */
+ public Map<String, String> namespaces() {
+ if (type != Type.ELEMENT) {
+ return null;
+ }
+ if (namespaces == null) {
+ namespaces = new HashMap<String, String>();
+ NamedNodeMap attrs = node.getAttributes();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ Attr attr = (Attr)attrs.item(i);
+ if ("xmlns".equals(attr.getPrefix())) {
+ namespaces.put(attr.getLocalName(), attr.getValue());
+ }
+ if ("xmlns".equals(attr.getName())) {
+ namespaces.put("", attr.getValue());
+ }
+ }
+ }
+ return namespaces;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DelegatingNamespaceContext.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DelegatingNamespaceContext.java
new file mode 100644
index 0000000000..8f136df7df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DelegatingNamespaceContext.java
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.ArrayList;
+import java.util.EmptyStackException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.NamespaceContext;
+
+public class DelegatingNamespaceContext implements NamespaceContext {
+ private static int count;
+
+ private class WrappingIterator implements Iterator {
+
+ private Iterator containedIterator;
+
+ public WrappingIterator(Iterator containedIterator) {
+ this.containedIterator = containedIterator;
+ }
+
+ public Iterator getContainedIterator() {
+ return containedIterator;
+ }
+
+ public boolean hasNext() {
+ return containedIterator.hasNext();
+ }
+
+ public Object next() {
+ return containedIterator.next();
+ }
+
+ /**
+ * As per the contract on the API of Namespace context the returned iterator should be immutable
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContainedIterator(Iterator containedIterator) {
+ this.containedIterator = containedIterator;
+ }
+ }
+
+ private NamespaceContext parentNsContext;
+
+ private FastStack<String> prefixStack = new FastStack<String>();
+
+ // Keep two ArrayLists for the prefixes and namespaces. They should be in
+ // sync
+ // since the index of the entry will be used to relate them
+ // use the minimum initial capacity to let things handle memory better
+
+ private FastStack<String> uriStack = new FastStack<String>();
+
+ /**
+ * Generates a unique namespace prefix that is not in the scope of the NamespaceContext
+ *
+ * @return string
+ */
+ public String generateUniquePrefix() {
+ String prefix = "p" + count++;
+ // null should be returned if the prefix is not bound!
+ while (getNamespaceURI(prefix) != null) {
+ prefix = "p" + count++;
+ }
+
+ return prefix;
+ }
+
+ public String getNamespaceURI(String prefix) {
+ // do the corrections as per the Javadoc
+ int index = prefixStack.search(prefix);
+ if (index != -1) {
+ return uriStack.get(index);
+ }
+ if (parentNsContext != null) {
+ return parentNsContext.getPrefix(prefix);
+ }
+ return null;
+ }
+
+ public NamespaceContext getParentNsContext() {
+ return parentNsContext;
+ }
+
+ public String getPrefix(String uri) {
+ // do the corrections as per the Javadoc
+ int index = uriStack.search(uri);
+ if (index != -1) {
+ return prefixStack.get(index);
+ }
+
+ if (parentNsContext != null) {
+ return parentNsContext.getPrefix(uri);
+ }
+ return null;
+ }
+
+ public Iterator getPrefixes(String uri) {
+ // create an ArrayList that contains the relevant prefixes
+ String[] uris = uriStack.toArray(new String[uriStack.size()]);
+ List<String> tempList = new ArrayList<String>();
+ for (int i = uris.length - 1; i >= 0; i--) {
+ if (uris[i].equals(uri)) {
+ tempList.add(prefixStack.get(i));
+ // we assume that array conversion preserves the order
+ }
+ }
+ // by now all the relevant prefixes are collected
+ // make a new iterator and provide a wrapper iterator to
+ // obey the contract on the API
+ return new WrappingIterator(tempList.iterator());
+ }
+
+ /**
+ * Pop a namespace
+ */
+ public void popNamespace() {
+ prefixStack.pop();
+ uriStack.pop();
+ }
+
+ /**
+ * Register a namespace in this context
+ *
+ * @param prefix
+ * @param uri
+ */
+ public void pushNamespace(String prefix, String uri) {
+ prefixStack.push(prefix);
+ uriStack.push(uri);
+
+ }
+
+ public void setParentNsContext(NamespaceContext parentNsContext) {
+ this.parentNsContext = parentNsContext;
+ }
+
+ /**
+ * An implementation of the {@link java.util.Stack} API that is based on an <code>ArrayList</code> instead of a
+ * <code>Vector</code>, so it is not synchronized to protect against multi-threaded access. The implementation is
+ * therefore operates faster in environments where you do not need to worry about multiple thread contention.
+ * <p>
+ * The removal order of an <code>ArrayStack</code> is based on insertion order: The most recently added element is
+ * removed first. The iteration order is <i>not</i> the same as the removal order. The iterator returns elements
+ * from the bottom up, whereas the {@link #remove()} method removes them from the top down.
+ * <p>
+ * Unlike <code>Stack</code>, <code>ArrayStack</code> accepts null entries.
+ */
+ public static class FastStack<T> extends ArrayList<T> {
+
+ /** Ensure Serialization compatibility */
+ private static final long serialVersionUID = 2130079159931574599L;
+
+ /**
+ * Constructs a new empty <code>ArrayStack</code>. The initial size is controlled by <code>ArrayList</code>
+ * and is currently 10.
+ */
+ public FastStack() {
+ super();
+ }
+
+ /**
+ * Constructs a new empty <code>ArrayStack</code> with an initial size.
+ *
+ * @param initialSize the initial size to use
+ * @throws IllegalArgumentException if the specified initial size is negative
+ */
+ public FastStack(int initialSize) {
+ super(initialSize);
+ }
+
+ /**
+ * Return <code>true</code> if this stack is currently empty.
+ * <p>
+ * This method exists for compatibility with <code>java.util.Stack</code>. New users of this class should use
+ * <code>isEmpty</code> instead.
+ *
+ * @return true if the stack is currently empty
+ */
+ public boolean empty() {
+ return isEmpty();
+ }
+
+ /**
+ * Returns the top item off of this stack without removing it.
+ *
+ * @return the top item on the stack
+ * @throws EmptyStackException if the stack is empty
+ */
+ public T peek() throws EmptyStackException {
+ int n = size();
+ if (n <= 0) {
+ throw new EmptyStackException();
+ } else {
+ return get(n - 1);
+ }
+ }
+
+ /**
+ * Returns the n'th item down (zero-relative) from the top of this stack without removing it.
+ *
+ * @param n the number of items down to go
+ * @return the n'th item on the stack, zero relative
+ * @throws EmptyStackException if there are not enough items on the stack to satisfy this request
+ */
+ public T peek(int n) throws EmptyStackException {
+ int m = (size() - n) - 1;
+ if (m < 0) {
+ throw new EmptyStackException();
+ } else {
+ return get(m);
+ }
+ }
+
+ /**
+ * Pops the top item off of this stack and return it.
+ *
+ * @return the top item on the stack
+ * @throws EmptyStackException if the stack is empty
+ */
+ public T pop() throws EmptyStackException {
+ int n = size();
+ if (n <= 0) {
+ throw new EmptyStackException();
+ } else {
+ return remove(n - 1);
+ }
+ }
+
+ /**
+ * Pushes a new item onto the top of this stack. The pushed item is also returned. This is equivalent to calling
+ * <code>add</code>.
+ *
+ * @param item the item to be added
+ * @return the item just pushed
+ */
+ public Object push(T item) {
+ add(item);
+ return item;
+ }
+
+ /**
+ * Returns the top-most index for the object in the stack
+ *
+ * @param object the object to be searched for
+ * @return top-most index, or -1 if not found
+ */
+ public int search(T object) {
+ int i = size() - 1; // Current index
+ while (i >= 0) {
+ T current = get(i);
+ if ((object == null && current == null) || (object != null && object.equals(current))) {
+ return i;
+ }
+ i--;
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the element on the top of the stack.
+ *
+ * @return the element on the top of the stack
+ * @throws EmptyStackException if the stack is empty
+ */
+ public T get() {
+ int size = size();
+ if (size == 0) {
+ throw new EmptyStackException();
+ }
+ return get(size - 1);
+ }
+
+ /**
+ * Removes the element on the top of the stack.
+ *
+ * @return the removed element
+ * @throws EmptyStackException if the stack is empty
+ */
+ public T remove() {
+ int size = size();
+ if (size == 0) {
+ throw new EmptyStackException();
+ }
+ return remove(size - 1);
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValueArrayStreamReader.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValueArrayStreamReader.java
new file mode 100644
index 0000000000..ec3b6e083b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValueArrayStreamReader.java
@@ -0,0 +1,404 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+
+
+public class NameValueArrayStreamReader implements XMLFragmentStreamReader {
+
+ private static final int START_ELEMENT_STATE = 0;
+ private static final int TEXT_STATE = 1;
+ private static final int END_ELEMENT_STATE = 2;
+ private static final int FINAL_END_ELEMENT_STATE = 3;
+ private static final int START_ELEMENT_STATE_WITH_NULL = 4;
+
+ private DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext();
+ // the index of the array
+ private int arrayIndex;
+
+ private QName name;
+ private String[] values;
+
+ // start element is the default state
+ private int state = START_ELEMENT_STATE;
+
+ public NameValueArrayStreamReader(QName name, String[] values) {
+ this.name = name;
+ this.values = values;
+ }
+
+ public void setParentNamespaceContext(NamespaceContext nsContext) {
+ this.namespaceContext.setParentNsContext(nsContext);
+ }
+
+ public void init() {
+ // TODO what if the QName namespace has not been declared
+ }
+
+ public Object getProperty(String string) throws IllegalArgumentException {
+ return null;
+ }
+
+ /**
+ * @throws XMLStreamException
+ */
+ public int next() throws XMLStreamException {
+ switch (state) {
+ case START_ELEMENT_STATE:
+ if (values.length > 0) {
+ state = TEXT_STATE;
+ return CHARACTERS;
+ } else {
+ state = FINAL_END_ELEMENT_STATE;
+ return END_ELEMENT;
+ }
+
+ case START_ELEMENT_STATE_WITH_NULL:
+ if (arrayIndex == (values.length - 1)) {
+ state = FINAL_END_ELEMENT_STATE;
+ } else {
+ state = END_ELEMENT_STATE;
+ }
+ return END_ELEMENT;
+ case FINAL_END_ELEMENT_STATE:
+ // oops, not supposed to happen!
+ throw new XMLStreamException("end already reached!");
+ case END_ELEMENT_STATE:
+ // we've to have more values since this is not the
+ // last value
+ // increment the counter
+ arrayIndex++;
+ if (values[arrayIndex] == null) {
+ state = START_ELEMENT_STATE_WITH_NULL;
+ } else {
+ state = START_ELEMENT_STATE;
+ }
+ return START_ELEMENT;
+ case TEXT_STATE:
+ if (arrayIndex == (values.length - 1)) {
+ state = FINAL_END_ELEMENT_STATE;
+ return END_ELEMENT;
+ } else {
+ state = END_ELEMENT_STATE;
+ return END_ELEMENT;
+ }
+
+ default:
+ throw new XMLStreamException("unknown event type!");
+ }
+ }
+
+ public void require(int i, String string, String string1) throws XMLStreamException {
+ // nothing done here
+ }
+
+ public String getElementText() throws XMLStreamException {
+ return null; // not implemented
+ }
+
+ public int nextTag() throws XMLStreamException {
+ return 0; // not implemented
+ }
+
+ public String getAttributeValue(String string, String string1) {
+ if (state == TEXT_STATE) {
+ // TODO something
+ return null;
+ } else {
+ return null;
+ }
+
+ }
+
+ public int getAttributeCount() {
+ if (state == START_ELEMENT_STATE_WITH_NULL) {
+ return 1;
+ }
+ if (state == START_ELEMENT_STATE) {
+ return 0;
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public QName getAttributeName(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return NIL_QNAME;
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeNamespace(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return NIL_QNAME.getNamespaceURI();
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeLocalName(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return NIL_QNAME.getLocalPart();
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributePrefix(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return NIL_QNAME.getPrefix();
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeType(int i) {
+ return null; // not implemented
+ }
+
+ public String getAttributeValue(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return NIL_VALUE_TRUE;
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ return false; // not supported
+ }
+
+ public int getNamespaceCount() {
+ if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent()) {
+ return 1;
+ } else {
+ return 0;
+ }
+
+ }
+
+ public String getNamespacePrefix(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent() && i == 0) {
+ return NIL_QNAME.getPrefix();
+ } else {
+ return null;
+ }
+ }
+
+ public String getNamespaceURI(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent() && i == 0) {
+ return NIL_QNAME.getNamespaceURI();
+ } else {
+ return null;
+ }
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return this.namespaceContext;
+ }
+
+ public boolean isDone() {
+ return state == FINAL_END_ELEMENT_STATE;
+ }
+
+ public int getEventType() {
+ switch (state) {
+ case START_ELEMENT_STATE:
+ return START_ELEMENT;
+ case END_ELEMENT_STATE:
+ return END_ELEMENT;
+ case TEXT_STATE:
+ return CHARACTERS;
+ case FINAL_END_ELEMENT_STATE:
+ return END_ELEMENT;
+ default:
+ throw new UnsupportedOperationException();
+ // we've no idea what this is!!!!!
+ }
+
+ }
+
+ public String getText() {
+ if (state == TEXT_STATE) {
+ return values[arrayIndex];
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public char[] getTextCharacters() {
+ if (state == TEXT_STATE) {
+ return values[arrayIndex].toCharArray();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ // not implemented
+ throw new UnsupportedOperationException();
+ }
+
+ public int getTextStart() {
+ if (state == TEXT_STATE) {
+ return 0;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextLength() {
+ if (state == TEXT_STATE) {
+ return values[arrayIndex].length();
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public String getEncoding() {
+ return null;
+ }
+
+ public boolean hasText() {
+ return state == TEXT_STATE;
+ }
+
+ public Location getLocation() {
+ return null; // not supported
+ }
+
+ public QName getName() {
+ if (state != TEXT_STATE) {
+ return name;
+ } else {
+ return null;
+ }
+ }
+
+ public String getLocalName() {
+ if (state != TEXT_STATE) {
+ return name.getLocalPart();
+ } else {
+ return null;
+ }
+ }
+
+ public boolean hasName() {
+ return state != TEXT_STATE;
+
+ }
+
+ public String getNamespaceURI() {
+ if (state != TEXT_STATE) {
+ return name.getNamespaceURI();
+ } else {
+ return null;
+ }
+
+ }
+
+ public String getPrefix() {
+ if (state != TEXT_STATE) {
+ return name.getPrefix();
+ } else {
+ return null;
+ }
+ }
+
+ public String getVersion() {
+ return null; // TODO 1.0 ?
+ }
+
+ public boolean isStandalone() {
+ return false;
+ }
+
+ public boolean standaloneSet() {
+ return false;
+ }
+
+ public String getCharacterEncodingScheme() {
+ return null;
+ }
+
+ public String getPITarget() {
+ return null;
+ }
+
+ public String getPIData() {
+ return null;
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ return state != FINAL_END_ELEMENT_STATE;
+ }
+
+ public void close() throws XMLStreamException {
+ // Do nothing - we've nothing to free here
+ }
+
+ public String getNamespaceURI(String prefix) {
+ return namespaceContext.getNamespaceURI(prefix);
+ }
+
+ public boolean isStartElement() {
+ return state == START_ELEMENT_STATE;
+ }
+
+ public boolean isEndElement() {
+ return state == END_ELEMENT_STATE;
+ }
+
+ public boolean isCharacters() {
+ return state == TEXT_STATE;
+ }
+
+ public boolean isWhiteSpace() {
+ return false; // no whitespaces here
+ }
+
+ /**
+ * Test whether the xsi namespace is present
+ */
+ private boolean isXsiNamespacePresent() {
+ return namespaceContext.getNamespaceURI(NIL_QNAME.getPrefix()) != null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValuePairStreamReader.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValuePairStreamReader.java
new file mode 100644
index 0000000000..4abf9b3dcf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValuePairStreamReader.java
@@ -0,0 +1,348 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+
+
+
+public class NameValuePairStreamReader implements XMLFragmentStreamReader {
+
+ private static final int START_ELEMENT_STATE = 0;
+ private static final int TEXT_STATE = 1;
+ private static final int END_ELEMENT_STATE = 2;
+
+ private DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext();
+
+ private QName name;
+ private String value;
+
+ private int state = START_ELEMENT_STATE;
+ // initiate at the start element state
+
+ // keeps track whether the namespace is declared
+ // false by default
+ private boolean nsDeclared;
+
+ public NameValuePairStreamReader(QName name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public Object getProperty(String key) throws IllegalArgumentException {
+ return null;
+ }
+
+ public int next() throws XMLStreamException {
+ // no need to handle null here. it should have been handled
+ // already
+ switch (state) {
+ case START_ELEMENT_STATE:
+ state = TEXT_STATE;
+ return CHARACTERS;
+ case END_ELEMENT_STATE:
+ // oops, not supposed to happen!
+ throw new XMLStreamException("end already reached!");
+ case TEXT_STATE:
+ state = END_ELEMENT_STATE;
+ return END_ELEMENT;
+ default:
+ throw new XMLStreamException("unknown event type!");
+ }
+ }
+
+ public void require(int i, String string, String string1) throws XMLStreamException {
+ // not implemented
+ }
+
+ public String getElementText() throws XMLStreamException {
+ if (state == START_ELEMENT) {
+ // move to the end state and return the value
+ state = END_ELEMENT_STATE;
+ return value;
+ } else {
+ throw new XMLStreamException();
+ }
+
+ }
+
+ public int nextTag() throws XMLStreamException {
+ return 0; // TODO
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ return state != END_ELEMENT_STATE;
+ }
+
+ public void close() throws XMLStreamException {
+ // Do nothing - we've nothing to free here
+ }
+
+ public String getNamespaceURI(String prefix) {
+ return namespaceContext.getNamespaceURI(prefix);
+ }
+
+ public boolean isStartElement() {
+ return state == START_ELEMENT_STATE;
+ }
+
+ public boolean isEndElement() {
+ return state == END_ELEMENT_STATE;
+ }
+
+ public boolean isCharacters() {
+ return state == TEXT_STATE;
+ }
+
+ public boolean isWhiteSpace() {
+ return false; // no whitespaces here
+ }
+
+ public String getAttributeValue(String string, String string1) {
+ return null;
+ }
+
+ public int getAttributeCount() {
+ return 0;
+ }
+
+ public QName getAttributeName(int i) {
+ return null;
+ }
+
+ public String getAttributeNamespace(int i) {
+ return null;
+ }
+
+ public String getAttributeLocalName(int i) {
+ return null;
+ }
+
+ public String getAttributePrefix(int i) {
+ return null;
+ }
+
+ public String getAttributeType(int i) {
+ return null;
+ }
+
+ public String getAttributeValue(int i) {
+ return null;
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ return false; // no attributes here
+ }
+
+ public int getNamespaceCount() {
+ return nsDeclared ? 1 : 0;
+ }
+
+ public String getNamespacePrefix(int i) {
+ return (nsDeclared && i == 0) ? name.getPrefix() : null;
+ }
+
+ public String getNamespaceURI(int i) {
+ return (nsDeclared && i == 0) ? name.getNamespaceURI() : null;
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return this.namespaceContext;
+ }
+
+ public int getEventType() {
+ switch (state) {
+ case START_ELEMENT_STATE:
+ return START_ELEMENT;
+ case END_ELEMENT_STATE:
+ return END_ELEMENT;
+ case TEXT_STATE:
+ return CHARACTERS;
+ default:
+ throw new UnsupportedOperationException();
+ // we've no idea what this is!!!!!
+ }
+
+ }
+
+ public String getText() {
+ if (state == TEXT_STATE) {
+ return value;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public char[] getTextCharacters() {
+ if (state == TEXT_STATE) {
+ return value.toCharArray();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ // not implemented
+ throw new UnsupportedOperationException();
+ }
+
+ public int getTextStart() {
+ if (state == TEXT_STATE) {
+ return 0;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextLength() {
+ if (state == TEXT_STATE) {
+ return value.length();
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public String getEncoding() {
+ return null;
+ }
+
+ public boolean hasText() {
+ return state == TEXT_STATE;
+ }
+
+ public Location getLocation() {
+ return new Location() {
+ public int getLineNumber() {
+ return 0;
+ }
+
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ public int getCharacterOffset() {
+ return 0;
+ }
+
+ public String getPublicId() {
+ return null;
+ }
+
+ public String getSystemId() {
+ return null;
+ }
+ };
+ }
+
+ public QName getName() {
+ if (state != TEXT_STATE) {
+ return name;
+ } else {
+ return null;
+ }
+ }
+
+ public String getLocalName() {
+ if (state != TEXT_STATE) {
+ return name.getLocalPart();
+ } else {
+ return null;
+ }
+ }
+
+ public boolean hasName() {
+ return state != TEXT_STATE;
+
+ }
+
+ public String getNamespaceURI() {
+ if (state != TEXT_STATE) {
+ return name.getNamespaceURI();
+ } else {
+ return null;
+ }
+
+ }
+
+ public String getPrefix() {
+ if (state != TEXT_STATE) {
+ return name.getPrefix();
+ } else {
+ return null;
+ }
+ }
+
+ public String getVersion() {
+ return null; // TODO 1.0 ?
+ }
+
+ public boolean isStandalone() {
+ return false;
+ }
+
+ public boolean standaloneSet() {
+ return false;
+ }
+
+ public String getCharacterEncodingScheme() {
+ return null;
+ }
+
+ public String getPITarget() {
+ return null;
+ }
+
+ public String getPIData() {
+ return null;
+ }
+
+ public boolean isDone() {
+ return state == END_ELEMENT_STATE;
+ }
+
+ public void setParentNamespaceContext(NamespaceContext nsContext) {
+ this.namespaceContext.setParentNsContext(nsContext);
+ }
+
+ public void init() {
+ // just add the current elements namespace and prefix to the this
+ // elements nscontext
+ addToNsMap(name.getPrefix(), name.getNamespaceURI());
+
+ }
+
+ /**
+ * @param prefix
+ * @param uri
+ */
+ private void addToNsMap(String prefix, String uri) {
+ // TODO - need to fix this up to cater for cases where
+ // namespaces are having no prefixes
+ if (!uri.equals(namespaceContext.getNamespaceURI(prefix))) {
+ // this namespace is not there. Need to declare it
+ namespaceContext.pushNamespace(prefix, uri);
+ nsDeclared = true;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamedProperty.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamedProperty.java
new file mode 100644
index 0000000000..dc5954f541
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamedProperty.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * A named property
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamedProperty implements Map.Entry<QName, Object> {
+ private QName key;
+
+ private Object value;
+
+ public NamedProperty(QName key, Object value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public NamedProperty(String key, Object value) {
+ this.key = new QName(key);
+ this.value = value;
+ }
+
+ public QName getKey() {
+ return key;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object setValue(Object value) {
+ Object v = this.value;
+ this.value = value;
+ return v;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamespaceContextImpl.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamespaceContextImpl.java
new file mode 100644
index 0000000000..d88f298a6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamespaceContextImpl.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+
+public class NamespaceContextImpl implements NamespaceContext {
+ private NamespaceContext parent;
+ private Map<String, String> map = new HashMap<String, String>();
+
+ /**
+ * @param parent
+ */
+ public NamespaceContextImpl(NamespaceContext parent) {
+ super();
+ this.parent = parent;
+ if (parent == null) {
+ map.put("xml", "http://www.w3.org/XML/1998/namespace");
+ map.put("xmlns", "http://www.w3.org/2000/xmlns/");
+ }
+ }
+
+ public String getNamespaceURI(String prefix) {
+ if (prefix == null) {
+ throw new IllegalArgumentException("Prefix is null");
+ }
+
+ String ns = (String)map.get(prefix);
+ if (ns != null) {
+ return ns;
+ }
+ if (parent != null) {
+ return parent.getNamespaceURI(prefix);
+ }
+ return null;
+ }
+
+ public String getPrefix(String nsURI) {
+ if (nsURI == null)
+ throw new IllegalArgumentException("Namespace is null");
+ for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String, String> entry = i.next();
+ if (entry.getValue().equals(nsURI)) {
+ return entry.getKey();
+ }
+ }
+ if (parent != null) {
+ return parent.getPrefix(nsURI);
+ }
+ return null;
+ }
+
+ public Iterator getPrefixes(String nsURI) {
+ List<String> prefixList = new ArrayList<String>();
+ for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String, String> entry = i.next();
+ if (entry.getValue().equals(nsURI)) {
+ prefixList.add(entry.getKey());
+ }
+ }
+ final Iterator<String> currentIterator = prefixList.iterator();
+ final Iterator parentIterator = parent == null ? null : parent.getPrefixes(nsURI);
+ return new Iterator() {
+
+ public boolean hasNext() {
+ return currentIterator.hasNext() || (parentIterator != null && parentIterator.hasNext());
+ }
+
+ public Object next() {
+ if (!hasNext()) {
+ throw new IllegalStateException("End of iterator has reached");
+ }
+ return currentIterator.hasNext() ? currentIterator.next() : parentIterator.next();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+
+ }
+
+ public void register(String prefix, String ns) {
+ map.put(prefix, ns);
+ }
+
+ public NamespaceContext getParent() {
+ return parent;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer(map.toString());
+ if (parent != null) {
+ sb.append("\nParent: ");
+ sb.append(parent);
+ }
+ return sb.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NilElementStreamReader.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NilElementStreamReader.java
new file mode 100644
index 0000000000..cee70f64df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NilElementStreamReader.java
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+
+public class NilElementStreamReader implements XMLFragmentStreamReader {
+
+ private static final int END_ELEMENT_STATE = 2;
+
+ private static final int START_ELEMENT_STATE = 1;
+ private int currentState = START_ELEMENT;
+
+ private QName elementQName;
+
+ public NilElementStreamReader(QName elementQName) {
+ this.elementQName = elementQName;
+ }
+
+ public void setParentNamespaceContext(NamespaceContext nsContext) {
+ // NOOP
+ }
+
+ public void close() throws XMLStreamException {
+ // do nothing
+ }
+
+ public int getAttributeCount() {
+ return 1;
+ }
+
+ public String getAttributeLocalName(int i) {
+ return (i == 0) ? NIL_QNAME.getLocalPart() : null;
+ }
+
+ public QName getAttributeName(int i) {
+ return (i == 0) ? NIL_QNAME : null;
+ }
+
+ public String getAttributeNamespace(int i) {
+ return (i == 0) ? NIL_QNAME.getNamespaceURI() : null;
+ }
+
+ public String getAttributePrefix(int i) {
+ return (i == 0) ? NIL_QNAME.getPrefix() : null;
+ }
+
+ public String getAttributeType(int i) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAttributeValue(int i) {
+ return (i == 0) ? NIL_VALUE_TRUE : null;
+ }
+
+ public String getAttributeValue(String string, String string1) {
+ if (string == null && NIL_QNAME.getLocalPart().equals(string1)) {
+ return NIL_VALUE_TRUE;
+ }
+ return null;
+ }
+
+ public String getCharacterEncodingScheme() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getElementText() throws XMLStreamException {
+ return null;
+ }
+
+ public String getEncoding() {
+ return null;
+ }
+
+ public int getEventType() {
+ int returnEvent = START_DOCUMENT;
+ switch (currentState) {
+ case START_ELEMENT_STATE:
+ returnEvent = START_ELEMENT;
+ break;
+ case END_ELEMENT_STATE:
+ returnEvent = END_ELEMENT;
+ break;
+ }
+ return returnEvent;
+ }
+
+ public String getLocalName() {
+ return elementQName.getLocalPart();
+ }
+
+ public Location getLocation() {
+ return new Location() {
+ public int getCharacterOffset() {
+ return 0;
+ }
+
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ public int getLineNumber() {
+ return 0;
+ }
+
+ public String getPublicId() {
+ return null;
+ }
+
+ public String getSystemId() {
+ return null;
+ }
+ };
+ }
+
+ public QName getName() {
+ return elementQName;
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getNamespaceCount() {
+ return 0;
+ }
+
+ public String getNamespacePrefix(int i) {
+ return null;
+ }
+
+ public String getNamespaceURI() {
+ return elementQName.getNamespaceURI();
+ }
+
+ public String getNamespaceURI(int i) {
+ return null;
+ }
+
+ public String getNamespaceURI(String string) {
+ if (elementQName.getPrefix() != null && elementQName.getPrefix().equals(string)) {
+ return elementQName.getNamespaceURI();
+ } else {
+ return null;
+ }
+ }
+
+ public String getPIData() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPITarget() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPrefix() {
+ return elementQName.getPrefix();
+ }
+
+ public Object getProperty(String key) throws IllegalArgumentException {
+ // since optimization is a global property
+ // we've to implement it everywhere
+ return null;
+ }
+
+ public String getText() {
+ return null;
+ }
+
+ public char[] getTextCharacters() {
+ return new char[0];
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ return 0;
+ }
+
+ public int getTextLength() {
+ return 0;
+ }
+
+ public int getTextStart() {
+ return 0;
+ }
+
+ public String getVersion() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasName() {
+ return true;
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ return currentState != END_ELEMENT_STATE;
+
+ }
+
+ public boolean hasText() {
+ return false;
+ }
+
+ public void init() {
+ // NOOP
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ return i == 0;
+ }
+
+ public boolean isCharacters() {
+ return false;
+ }
+
+ public boolean isDone() {
+ return currentState == END_ELEMENT_STATE;
+ }
+
+ public boolean isEndElement() {
+ return currentState == END_ELEMENT_STATE;
+ }
+
+ public boolean isStandalone() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isStartElement() {
+ return currentState == START_ELEMENT_STATE;
+ }
+
+ public boolean isWhiteSpace() {
+ return false;
+ }
+
+ public int next() throws XMLStreamException {
+ int returnEvent = START_DOCUMENT;
+ switch (currentState) {
+ case START_ELEMENT_STATE:
+ currentState = END_ELEMENT_STATE;
+ returnEvent = END_ELEMENT;
+ break;
+ case END_ELEMENT_STATE:
+ throw new XMLStreamException("parser completed!");
+
+ }
+ return returnEvent;
+ }
+
+ public int nextTag() throws XMLStreamException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void require(int i, String string, String string1) throws XMLStreamException {
+ // nothing
+ }
+
+ public boolean standaloneSet() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/SimpleXmlNodeImpl.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/SimpleXmlNodeImpl.java
new file mode 100644
index 0000000000..30f388543c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/SimpleXmlNodeImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleXmlNodeImpl implements XmlNode {
+ private static final String XSI_PREFIX = "xsi";
+ private static final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
+ private static final QName XSI_NIL = new QName(XSI_NS, "nil", XSI_PREFIX);
+ private static final Map<String, String> NS_MAP = new HashMap<String, String>();
+ static {
+ NS_MAP.put(XSI_PREFIX, XSI_NS);
+ }
+
+ protected Type type;
+ protected QName name;
+ protected Object value;
+
+ public SimpleXmlNodeImpl(QName name, Object value) {
+ this(name, value, name != null ? Type.ELEMENT : Type.CHARACTERS);
+ }
+
+ public SimpleXmlNodeImpl(QName name, Object value, Type type) {
+ super();
+ this.type = type;
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#attributes()
+ */
+ public List<XmlNode> attributes() {
+ if (type == Type.ELEMENT && value == null) {
+ // Nil element
+ XmlNode attr = new SimpleXmlNodeImpl(XSI_NIL, "true");
+ return Arrays.asList(attr);
+ }
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#children()
+ */
+ public Iterator<XmlNode> children() {
+ if (type == Type.ELEMENT && value != null) {
+ // Nil element
+ XmlNode node = new SimpleXmlNodeImpl(null, value);
+ return Arrays.asList(node).iterator();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#getName()
+ */
+ public QName getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#getValue()
+ */
+ public String getValue() {
+ return value == null ? null : String.valueOf(value);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#namespaces()
+ */
+ public Map<String, String> namespaces() {
+ if (type == Type.ELEMENT && value == null) {
+ return NS_MAP;
+ }
+ return null;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/WrappingXMLStreamReader.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/WrappingXMLStreamReader.java
new file mode 100644
index 0000000000..896f4b5b71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/WrappingXMLStreamReader.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.StreamReaderDelegate;
+
+public class WrappingXMLStreamReader extends StreamReaderDelegate implements XMLFragmentStreamReader {
+
+ private boolean done;
+ private int level;
+
+ public WrappingXMLStreamReader(XMLStreamReader realReader) throws XMLStreamException {
+ super(realReader);
+ if (realReader == null) {
+ throw new UnsupportedOperationException("Reader cannot be null");
+ }
+
+ if (realReader instanceof XMLFragmentStreamReader) {
+ ((XMLFragmentStreamReader)realReader).init();
+ }
+
+ if (realReader.getEventType() == START_DOCUMENT) {
+ // Position to the 1st element
+ realReader.nextTag();
+ }
+ if (realReader.getEventType() != START_ELEMENT) {
+ throw new IllegalStateException("The reader is not positioned at START_DOCUMENT or START_ELEMENT");
+ }
+ this.done = false;
+ this.level = 1;
+ }
+
+ @Override
+ public boolean hasNext() throws XMLStreamException {
+ return !done && super.hasNext();
+ }
+
+ @Override
+ public int next() throws XMLStreamException {
+ if (!hasNext()) {
+ throw new IllegalStateException("No more events");
+ }
+ int event = super.next();
+ if (!super.hasNext()) {
+ done = true;
+ }
+ if (event == START_ELEMENT) {
+ level++;
+ } else if (event == END_ELEMENT) {
+ level--;
+ if (level == 0) {
+ done = true;
+ }
+ }
+ return event;
+ }
+
+ @Override
+ public int nextTag() throws XMLStreamException {
+ int event = 0;
+ while (true) {
+ event = next();
+ if (event == START_ELEMENT || event == END_ELEMENT) {
+ return event;
+ }
+ }
+ }
+
+ public void setParentNamespaceContext(NamespaceContext nsContext) {
+ // nothing to do here
+ }
+
+ public void init() {
+ // Nothing to do here
+ }
+
+ public boolean isDone() {
+ return done;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLDocumentStreamReader.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLDocumentStreamReader.java
new file mode 100644
index 0000000000..a020a8a61e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLDocumentStreamReader.java
@@ -0,0 +1,482 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.NoSuchElementException;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This class is derived from Apache Axis2 class
+ * org.apache.axis2.util.StreamWrapper</a>. It's used wrap a XMLStreamReader to
+ * create a XMLStreamReader representing a document and it will produce
+ * START_DOCUMENT, END_DOCUMENT events.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLDocumentStreamReader implements XMLStreamReader {
+ private static final int STATE_COMPLETE_AT_NEXT = 2; // The wrapper
+ // will produce
+ // END_DOCUMENT
+
+ private static final int STATE_COMPLETED = 3; // Done
+
+ private static final int STATE_INIT = 0; // The wrapper will produce
+ // START_DOCUMENT
+
+ private static final int STATE_SWITCHED = 1; // The real reader will
+ // produce events
+
+ private XMLStreamReader realReader;
+ private boolean fragment;
+ private int level = 1;
+
+ private int state = STATE_INIT;
+
+ public XMLDocumentStreamReader(XMLStreamReader realReader) {
+ if (realReader == null) {
+ throw new UnsupportedOperationException("Reader cannot be null");
+ }
+
+ this.realReader = realReader;
+
+ if (realReader instanceof XMLFragmentStreamReader) {
+ ((XMLFragmentStreamReader)realReader).init();
+ }
+
+ // If the real reader is positioned at START_DOCUMENT, always use
+ // the real reader
+ if (realReader.getEventType() == START_DOCUMENT) {
+ fragment = false;
+ state = STATE_SWITCHED;
+ }
+ }
+
+ public void close() throws XMLStreamException {
+ realReader.close();
+ }
+
+ public int getAttributeCount() {
+ if (isDelegating()) {
+ return realReader.getAttributeCount();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeLocalName(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeLocalName(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public QName getAttributeName(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeName(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeNamespace(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeNamespace(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributePrefix(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributePrefix(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeType(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeType(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeValue(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeValue(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeValue(String s, String s1) {
+ if (isDelegating()) {
+ return realReader.getAttributeValue(s, s1);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getCharacterEncodingScheme() {
+ return realReader.getCharacterEncodingScheme();
+ }
+
+ public String getElementText() throws XMLStreamException {
+ if (isDelegating()) {
+ return realReader.getElementText();
+ } else {
+ throw new XMLStreamException();
+ }
+ }
+
+ public String getEncoding() {
+ return realReader.getEncoding();
+ }
+
+ public int getEventType() {
+ int event = -1;
+ switch (state) {
+ case STATE_SWITCHED:
+ case STATE_COMPLETE_AT_NEXT:
+ event = realReader.getEventType();
+ break;
+ case STATE_INIT:
+ event = START_DOCUMENT;
+ break;
+ case STATE_COMPLETED:
+ event = END_DOCUMENT;
+ break;
+ }
+ return event;
+ }
+
+ public String getLocalName() {
+ if (isDelegating()) {
+ return realReader.getLocalName();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public Location getLocation() {
+ if (isDelegating()) {
+ return realReader.getLocation();
+ } else {
+ return null;
+ }
+ }
+
+ public QName getName() {
+ if (isDelegating()) {
+ return realReader.getName();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return realReader.getNamespaceContext();
+ }
+
+ public int getNamespaceCount() {
+ if (isDelegating()) {
+ return realReader.getNamespaceCount();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespacePrefix(int i) {
+ if (isDelegating()) {
+ return realReader.getNamespacePrefix(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespaceURI() {
+ if (isDelegating()) {
+ return realReader.getNamespaceURI();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespaceURI(int i) {
+ if (isDelegating()) {
+ return realReader.getNamespaceURI(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespaceURI(String s) {
+ if (isDelegating()) {
+ return realReader.getNamespaceURI(s);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getPIData() {
+ if (isDelegating()) {
+ return realReader.getPIData();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getPITarget() {
+ if (isDelegating()) {
+ return realReader.getPITarget();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getPrefix() {
+ if (isDelegating()) {
+ return realReader.getPrefix();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public Object getProperty(String s) throws IllegalArgumentException {
+ if (isDelegating()) {
+ return realReader.getProperty(s);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public String getText() {
+ if (isDelegating()) {
+ return realReader.getText();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public char[] getTextCharacters() {
+ if (isDelegating()) {
+ return realReader.getTextCharacters();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ if (isDelegating()) {
+ return realReader.getTextCharacters(i, chars, i1, i2);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextLength() {
+ if (isDelegating()) {
+ return realReader.getTextLength();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextStart() {
+ if (isDelegating()) {
+ return realReader.getTextStart();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getVersion() {
+ if (isDelegating()) {
+ return realReader.getVersion();
+ } else {
+ return null;
+ }
+ }
+
+ public boolean hasName() {
+ if (isDelegating()) {
+ return realReader.hasName();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ if (state == STATE_COMPLETE_AT_NEXT) {
+ return true;
+ } else if (state == STATE_COMPLETED) {
+ return false;
+ } else if (state == STATE_SWITCHED) {
+ return realReader.hasNext();
+ } else {
+ return true;
+ }
+ }
+
+ public boolean hasText() {
+ if (isDelegating()) {
+ return realReader.hasText();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ if (isDelegating()) {
+ return realReader.isAttributeSpecified(i);
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isCharacters() {
+ if (isDelegating()) {
+ return realReader.isCharacters();
+ } else {
+ return false;
+ }
+ }
+
+ private boolean isDelegating() {
+ return state == STATE_SWITCHED || state == STATE_COMPLETE_AT_NEXT;
+ }
+
+ public boolean isEndElement() {
+ if (isDelegating()) {
+ return realReader.isEndElement();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isStandalone() {
+ if (isDelegating()) {
+ return realReader.isStandalone();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isStartElement() {
+ if (isDelegating()) {
+ return realReader.isStartElement();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isWhiteSpace() {
+ if (isDelegating()) {
+ return realReader.isWhiteSpace();
+ } else {
+ return false;
+ }
+ }
+
+ public int next() throws XMLStreamException {
+ int returnEvent;
+
+ switch (state) {
+ case STATE_SWITCHED:
+ returnEvent = realReader.next();
+ if (returnEvent == END_DOCUMENT) {
+ state = STATE_COMPLETED;
+ } else if (!realReader.hasNext()) {
+ state = STATE_COMPLETE_AT_NEXT;
+ }
+ if (fragment && returnEvent == END_ELEMENT) {
+ level--;
+ if (level == 0) {
+ // We are now at the end of the top-level element in the fragment
+ state = STATE_COMPLETE_AT_NEXT;
+ }
+ }
+ if (fragment && returnEvent == START_ELEMENT) {
+ level++;
+ }
+ break;
+ case STATE_INIT:
+ state = STATE_SWITCHED;
+ returnEvent = realReader.getEventType();
+ if (returnEvent == START_ELEMENT) {
+ // The real reader is positioned at the top-level element in the fragment
+ level = 0;
+ fragment = true;
+ }
+ break;
+ case STATE_COMPLETE_AT_NEXT:
+ state = STATE_COMPLETED;
+ returnEvent = END_DOCUMENT;
+ break;
+ case STATE_COMPLETED:
+ // oops - no way we can go beyond this
+ throw new NoSuchElementException("End of stream has reached.");
+ default:
+ throw new UnsupportedOperationException();
+ }
+
+ return returnEvent;
+ }
+
+ public int nextTag() throws XMLStreamException {
+ if (isDelegating()) {
+ int returnEvent = realReader.nextTag();
+ if (fragment && returnEvent == END_ELEMENT) {
+ level--;
+ if (level == 0) {
+ // We are now at the end of the top-level element in the fragment
+ state = STATE_COMPLETE_AT_NEXT;
+ }
+ }
+ if (fragment && returnEvent == START_ELEMENT) {
+ level++;
+ }
+ return returnEvent;
+ } else {
+ throw new XMLStreamException();
+ }
+ }
+
+ public void require(int i, String s, String s1) throws XMLStreamException {
+ if (isDelegating()) {
+ realReader.require(i, s, s1);
+ }
+ }
+
+ public boolean standaloneSet() {
+ if (isDelegating()) {
+ return realReader.standaloneSet();
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReader.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReader.java
new file mode 100644
index 0000000000..95ede0a840
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReader.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.sca.common.xml.stax.reader;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+public interface XMLFragmentStreamReader extends XMLStreamReader {
+ QName NIL_QNAME = new QName("http://www.w3.org/2001/XMLSchema-instance", "nil", "xsi");
+ String NIL_VALUE_TRUE = "true";
+
+ /**
+ * this will help to handle Text within the current element. user should
+ * pass the element text to the property list as this ELEMENT_TEXT as the
+ * key. This key deliberately has a space in it so that it is not a valid
+ * XML name
+ */
+ String ELEMENT_TEXT = "Element Text";
+
+ /**
+ * Extra method to query the state of the pullparser
+ */
+ boolean isDone();
+
+ /**
+ * add the parent namespace context to this parser
+ */
+ void setParentNamespaceContext(NamespaceContext nsContext);
+
+ /**
+ * Initiate the parser - this will do whatever the needed tasks to initiate
+ * the parser and must be called before attempting any specific parsing
+ * using this parser
+ */
+ void init();
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReaderImpl.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReaderImpl.java
new file mode 100644
index 0000000000..4fd70bea67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReaderImpl.java
@@ -0,0 +1,858 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+
+/**
+ * This is the new implementation of the XMLFramentStreamReader. The approach
+ * here is simple When the pull parser needs to generate events for a particular
+ * name-value(s) pair it always hands over (delegates) the task to another pull
+ * parser which knows how to deal with it The common types of name value pairs
+ * we'll come across are
+ * <ul>
+ * <li> String name/QName name - String value
+ * <li> String name/QName name - String[] value
+ * <li> QName name/String name - XMLStreamReader value
+ * <li> QName name/String name - XMLStreamable value
+ * <li> QName name/String name - Java bean
+ * <li> QName name/String name - Datahandler
+ *
+ * </ul>
+ * <p/> As for the attributes, these are the possible combinations in the array
+ * <ul>
+ * <li> String name/QName name - String value
+ * </ul>
+ * Note that certain array methods have been deliberately removed to avoid
+ * complications. The generated code will take the trouble to lay the elements
+ * of the array in the correct order <p/> <p/> Hence there will be a parser impl
+ * that knows how to handle these types, and this parent parser will always
+ * delegate these tasks to the child pullparasers in effect this is one huge
+ * state machine that has only a few states and delegates things down to the
+ * child parsers whenever possible <p/>
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLFragmentStreamReaderImpl implements XMLFragmentStreamReader {
+
+ private static final int DELEGATED_STATE = 2;
+ private static final int END_ELEMENT_STATE = 1;
+ // states for this pullparser - it can only have four states
+ private static final int START_ELEMENT_STATE = 0;
+ private static final int TEXT_STATE = 3;
+
+ protected NamedProperty[] attributes;
+
+ // reference to the child reader
+ protected XMLFragmentStreamReader childReader;
+ // current property index
+ // initialized at zero
+ protected int index;
+ protected Map<String, String> declaredNamespaceMap = new HashMap<String, String>();
+ protected QName elementQName;
+
+ // we always create a new namespace context
+ protected DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext();
+
+ protected NamedProperty[] elements;
+
+ // integer field that keeps the state of this
+ // parser.
+ protected int state = START_ELEMENT_STATE;
+
+ /*
+ * we need to pass in a namespace context since when delegated, we've no
+ * idea of the current namespace context. So it needs to be passed on here!
+ */
+ public XMLFragmentStreamReaderImpl(QName elementQName, NamedProperty[] elements, NamedProperty[] attributes) {
+ // validate the lengths, since both the arrays are supposed
+ // to have
+ this.elements = elements == null ? new NamedProperty[0] : elements;
+ this.elementQName = elementQName;
+ this.attributes = attributes == null ? new NamedProperty[0] : attributes;
+ }
+
+ protected XMLFragmentStreamReaderImpl(QName elementQName) {
+ this.elementQName = elementQName;
+ }
+
+ /**
+ * add the namespace context
+ */
+
+ public void setParentNamespaceContext(NamespaceContext nsContext) {
+ // register the namespace context passed in to this
+ this.namespaceContext.setParentNsContext(nsContext);
+
+ }
+
+ protected NamedProperty[] getElements() {
+ return elements;
+ }
+
+ protected NamedProperty[] getAttributes() {
+ return attributes;
+ }
+
+ protected QName[] getNamespaces() {
+ return new QName[0];
+ }
+
+ /**
+ * @param prefix
+ * @param uri
+ */
+ protected void addToNsMap(String prefix, String uri) {
+ if (!uri.equals(namespaceContext.getNamespaceURI(prefix))) {
+ namespaceContext.pushNamespace(prefix, uri);
+ declaredNamespaceMap.put(prefix, uri);
+ }
+ }
+
+ public void close() throws XMLStreamException {
+ // do nothing here - we have no resources to free
+ }
+
+ public int getAttributeCount() {
+ return (state == DELEGATED_STATE) ? childReader.getAttributeCount() : (state == START_ELEMENT_STATE
+ ? getAttributes().length : 0);
+ }
+
+ public String getAttributeLocalName(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributeLocalName(i);
+ } else if (state == START_ELEMENT_STATE) {
+ QName name = getAttributeName(i);
+ if (name == null) {
+ return null;
+ } else {
+ return name.getLocalPart();
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ /**
+ * @param i
+ */
+ public QName getAttributeName(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributeName(i);
+ } else if (state == START_ELEMENT_STATE) {
+ if ((i >= (getAttributes().length)) || i < 0) { // out of range
+ return null;
+ } else {
+ // get the attribute pointer
+ QName attribPointer = getAttributes()[i].getKey();
+ // case one - attrib name is null
+ // this should be the pointer to the OMAttribute then
+ if (attribPointer == null) {
+ throw new UnsupportedOperationException();
+ } else if (attribPointer instanceof QName) {
+ return attribPointer;
+ } else {
+ return null;
+ }
+ }
+ } else {
+ throw new IllegalStateException(); // as per the API contract
+ }
+
+ }
+
+ public String getAttributeNamespace(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributeNamespace(i);
+ } else if (state == START_ELEMENT_STATE) {
+ QName name = getAttributeName(i);
+ if (name == null) {
+ return null;
+ } else {
+ return name.getNamespaceURI();
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributePrefix(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributePrefix(i);
+ } else if (state == START_ELEMENT_STATE) {
+ QName name = getAttributeName(i);
+ if (name == null) {
+ return null;
+ } else {
+ return name.getPrefix();
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeType(int i) {
+ return null; // not supported
+ }
+
+ public String getAttributeValue(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributeValue(i);
+ } else if (state == START_ELEMENT_STATE) {
+ if ((i >= (getAttributes().length)) || i < 0) { // out of range
+ return null;
+ } else {
+ // get the attribute pointer
+ QName attribPointer = getAttributes()[i].getKey();
+ Object omAttribObj = getAttributes()[i].getValue();
+ // case one - attrib name is null
+ // this should be the pointer to the OMAttribute then
+ if (attribPointer == null) {
+ throw new UnsupportedOperationException();
+ } else if (attribPointer instanceof QName) {
+ return (String)omAttribObj;
+ } else {
+ return null;
+ }
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public String getAttributeValue(String nsUri, String localName) {
+
+ int attribCount = getAttributeCount();
+ String returnValue = null;
+ QName attribQualifiedName;
+ for (int i = 0; i < attribCount; i++) {
+ attribQualifiedName = getAttributeName(i);
+ if (nsUri == null) {
+ if (localName.equals(attribQualifiedName.getLocalPart())) {
+ returnValue = getAttributeValue(i);
+ break;
+ }
+ } else {
+ if (localName.equals(attribQualifiedName.getLocalPart()) && nsUri.equals(attribQualifiedName
+ .getNamespaceURI())) {
+ returnValue = getAttributeValue(i);
+ break;
+ }
+ }
+
+ }
+
+ return returnValue;
+ }
+
+ public String getCharacterEncodingScheme() {
+ return null; // TODO - should we return something for this ?
+ }
+
+ /**
+ * TODO implement the right contract for this
+ *
+ * @throws XMLStreamException
+ */
+ public String getElementText() throws XMLStreamException {
+ if (state == DELEGATED_STATE) {
+ return childReader.getElementText();
+ } else {
+ return null;
+ }
+
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // / attribute handling
+ // /////////////////////////////////////////////////////////////////////////
+
+ public String getEncoding() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getEncoding();
+ } else {
+ // we've no idea what the encoding is going to be in this case
+ // perhaps we ought to return some constant here, which the user
+ // might
+ // have access to change!
+ return null;
+ }
+ }
+
+ public int getEventType() {
+ if (state == START_ELEMENT_STATE) {
+ return START_ELEMENT;
+ } else if (state == END_ELEMENT_STATE) {
+ return END_ELEMENT;
+ } else if (state == TEXT_STATE) {
+ return CHARACTERS;
+ } else { // this is the delegated state
+ return childReader.getEventType();
+ }
+ }
+
+ public String getLocalName() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getLocalName();
+ } else if (state != TEXT_STATE) {
+ return elementQName.getLocalPart();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ /**
+ */
+ public Location getLocation() {
+ // return a default location
+ return new Location() {
+ public int getCharacterOffset() {
+ return 0;
+ }
+
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ public int getLineNumber() {
+ return 0;
+ }
+
+ public String getPublicId() {
+ return null;
+ }
+
+ public String getSystemId() {
+ return null;
+ }
+ };
+ }
+
+ public QName getName() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getName();
+ } else if (state != TEXT_STATE) {
+ return elementQName;
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespaceContext();
+ } else {
+ return namespaceContext;
+ }
+
+ }
+
+ public int getNamespaceCount() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespaceCount();
+ } else {
+ return declaredNamespaceMap.size();
+ }
+ }
+
+ /**
+ * @param i
+ */
+ public String getNamespacePrefix(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespacePrefix(i);
+ } else if (state != TEXT_STATE) {
+ // order the prefixes
+ String[] prefixes = makePrefixArray();
+ if ((i >= prefixes.length) || (i < 0)) {
+ return null;
+ } else {
+ return prefixes[i];
+ }
+
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public String getNamespaceURI() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespaceURI();
+ } else if (state == TEXT_STATE) {
+ return null;
+ } else {
+ return elementQName.getNamespaceURI();
+ }
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // //////////// end of attribute handling
+ // /////////////////////////////////////////////////////////////////////////
+
+ // //////////////////////////////////////////////////////////////////////////
+ // //////////// namespace handling
+ // //////////////////////////////////////////////////////////////////////////
+
+ public String getNamespaceURI(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespaceURI(i);
+ } else if (state != TEXT_STATE) {
+ String namespacePrefix = getNamespacePrefix(i);
+ return namespacePrefix == null ? null : (String)declaredNamespaceMap.get(namespacePrefix);
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public String getNamespaceURI(String prefix) {
+ return namespaceContext.getNamespaceURI(prefix);
+ }
+
+ public String getPIData() {
+ throw new UnsupportedOperationException("Yet to be implemented !!");
+ }
+
+ public String getPITarget() {
+ throw new UnsupportedOperationException("Yet to be implemented !!");
+ }
+
+ public String getPrefix() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getPrefix();
+ } else if (state == TEXT_STATE) {
+ return null;
+ } else {
+ String prefix = elementQName.getPrefix();
+ return "".equals(prefix) ? null : prefix;
+ }
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // /////// end of namespace handling
+ // /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * @param key
+ * @throws IllegalArgumentException
+ */
+ public Object getProperty(String key) throws IllegalArgumentException {
+ if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) {
+ return null;
+ } else if (state == TEXT_STATE) {
+ return null;
+ } else if (state == DELEGATED_STATE) {
+ return childReader.getProperty(key);
+ } else {
+ return null;
+ }
+
+ }
+
+ public String getText() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getText();
+ } else if (state == TEXT_STATE) {
+ return (String)getElements()[index - 1].getValue();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public char[] getTextCharacters() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getTextCharacters();
+ } else if (state == TEXT_STATE) {
+ return getElements()[index - 1].getValue() == null ? new char[0] : ((String)getElements()[index - 1]
+ .getValue()).toCharArray();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ private int copy(int sourceStart, char[] target, int targetStart, int length) {
+ char[] source = getTextCharacters();
+ if (sourceStart > source.length) {
+ throw new IndexOutOfBoundsException("source start > source length");
+ }
+ int sourceLen = source.length - sourceStart;
+ if (length > sourceLen) {
+ length = sourceLen;
+ }
+ System.arraycopy(source, sourceStart, target, targetStart, length);
+ return sourceLen;
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ if (state == DELEGATED_STATE) {
+ return childReader.getTextCharacters(i, chars, i1, i2);
+ } else if (state == TEXT_STATE) {
+ return copy(i, chars, i1, i2);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextLength() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getTextLength();
+ } else if (state == TEXT_STATE) {
+ return getTextCharacters().length;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextStart() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getTextStart();
+ } else if (state == TEXT_STATE) {
+ return 0; // assume text always starts at 0
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getVersion() {
+ return null;
+ }
+
+ public boolean hasName() {
+ // since this parser always has a name, the hasName
+ // has to return true if we are still navigating this element
+ // if not we should ask the child reader for it.
+ if (state == DELEGATED_STATE) {
+ return childReader.hasName();
+ } else {
+ return state != TEXT_STATE;
+ }
+ }
+
+ /**
+ * @throws XMLStreamException
+ */
+ public boolean hasNext() throws XMLStreamException {
+ if (state == DELEGATED_STATE) {
+ if (childReader.isDone()) {
+ // the child reader is done. We shouldn't be getting the
+ // hasNext result from the child pullparser then
+ return true;
+ } else {
+ return childReader.hasNext();
+ }
+ } else {
+ return state == START_ELEMENT_STATE || state == TEXT_STATE;
+
+ }
+ }
+
+ /**
+ * check the validity of this implementation
+ */
+ public boolean hasText() {
+ if (state == DELEGATED_STATE) {
+ return childReader.hasText();
+ } else {
+ return state == TEXT_STATE;
+ }
+
+ }
+
+ /**
+ * we need to split out the calling to the populate namespaces separately
+ * since this needs to be done *after* setting the parent namespace context.
+ * We cannot assume it will happen at construction!
+ */
+ public void init() {
+ // here we have an extra issue to attend to. we need to look at the
+ // prefixes and URIs (the combination) and populate a HashMap of
+ // namespaces. The HashMap of namespaces will be used to serve the
+ // namespace context
+
+ populateNamespaceContext();
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ return false; // not supported
+ }
+
+ public boolean isCharacters() {
+ if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) {
+ return false;
+ }
+ return childReader.isCharacters();
+ }
+
+ /**
+ * are we done ?
+ */
+ public boolean isDone() {
+ return state == END_ELEMENT_STATE;
+ }
+
+ public boolean isEndElement() {
+ if (state == START_ELEMENT_STATE) {
+ return false;
+ } else if (state == END_ELEMENT_STATE) {
+ return true;
+ }
+ return childReader.isEndElement();
+ }
+
+ public boolean isStandalone() {
+ return true;
+ }
+
+ public boolean isStartElement() {
+ if (state == START_ELEMENT_STATE) {
+ return true;
+ } else if (state == END_ELEMENT_STATE) {
+ return false;
+ }
+ return childReader.isStartElement();
+ }
+
+ public boolean isWhiteSpace() {
+ if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) {
+ return false;
+ }
+ return childReader.isWhiteSpace();
+ }
+
+ /**
+ * Get the prefix list from the HashTable and take that into an array
+ */
+ private String[] makePrefixArray() {
+ String[] prefixes = declaredNamespaceMap.keySet().toArray(new String[declaredNamespaceMap.size()]);
+ Arrays.sort(prefixes);
+ return prefixes;
+ }
+
+ /**
+ * By far this should be the most important method in this class this method
+ * changes the state of the parser
+ */
+ public int next() throws XMLStreamException {
+ int returnEvent = -1; // invalid state is the default state
+ switch (state) {
+ case START_ELEMENT_STATE:
+ // current element is start element. We should be looking at the
+ // property list and making a pullparser for the property value
+ if (getElements() == null || getElements().length == 0) {
+ // no properties - move to the end element state
+ // straight away
+ state = END_ELEMENT_STATE;
+ returnEvent = END_ELEMENT;
+ } else {
+ // there are properties. now we should delegate this task to
+ // a
+ // child reader depending on the property type
+ returnEvent = processProperties();
+
+ }
+ break;
+ case END_ELEMENT_STATE:
+ // we've reached the end element already. If the user tries to
+ // push
+ // further ahead then it is an exception
+ throw new XMLStreamException("Trying to go beyond the end of the pullparser");
+
+ case DELEGATED_STATE:
+ if (childReader.isDone()) {
+ // we've reached the end!
+ if (index > (getElements().length - 1)) {
+ state = END_ELEMENT_STATE;
+ returnEvent = END_ELEMENT;
+ } else {
+ returnEvent = processProperties();
+ }
+ } else {
+ returnEvent = childReader.next();
+ }
+ break;
+
+ case TEXT_STATE:
+ // if there are any more event we should be delegating to
+ // processProperties. if not we just return an end element
+ if (index > (getElements().length - 1)) {
+ state = END_ELEMENT_STATE;
+ returnEvent = END_ELEMENT;
+ } else {
+ returnEvent = processProperties();
+ }
+ break;
+ }
+ return returnEvent;
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // / Other utility methods
+ // ////////////////////////////////////////////////////////////////////////
+
+ /**
+ * TODO implement this
+ *
+ * @throws XMLStreamException
+ */
+ public int nextTag() throws XMLStreamException {
+ return 0;
+ }
+
+ /**
+ * Populates a namespace context
+ */
+ private void populateNamespaceContext() {
+
+ // first add the current element namespace to the namespace context
+ // declare it if not found
+ addToNsMap(elementQName.getPrefix(), elementQName.getNamespaceURI());
+
+ for (QName n : getNamespaces()) {
+ addToNsMap(n.getPrefix(), n.getNamespaceURI());
+ }
+
+ // traverse through the attributes and populate the namespace context
+ // the attrib list can be of many combinations
+ // the valid combinations are
+ // String - String
+ // QName - QName
+ // null - OMAttribute
+
+ for (int i = 0; i < getAttributes().length; i++) { // jump in two
+ QName attrQName = getAttributes()[i].getKey();
+ if (!"".equals(attrQName.getNamespaceURI())) {
+ addToNsMap(attrQName.getPrefix(), attrQName.getNamespaceURI());
+ }
+ }
+ }
+
+ /**
+ * A convenient method to reuse the properties
+ *
+ * @return event to be thrown
+ * @throws XMLStreamException
+ */
+ private int processProperties() throws XMLStreamException {
+ // move to the next property depending on the current property
+ // index
+ QName propertyQName = getElements()[index].getKey();
+ boolean textFound = false;
+ if (propertyQName == null) {
+ throw new XMLStreamException("property key cannot be null!");
+ } else if (ELEMENT_TEXT.equals(propertyQName.getLocalPart())) {
+ // propPointer being a String has a special case
+ // that is it can be a the special constant ELEMENT_TEXT that
+ // says this text event
+ textFound = true;
+ }
+
+ // OK! we got the key. Now look at the value
+ Object propertyValue = getElements()[index].getValue();
+ // cater for the special case now
+ if (textFound) {
+ // no delegation here - make the parser null and immediately
+ // return with the event characters
+ childReader = null;
+ state = TEXT_STATE;
+ ++index;
+ return CHARACTERS;
+ } else if (propertyValue == null) {
+ // if the value is null we delegate the work to a nullable
+ // parser
+ childReader = new NilElementStreamReader(propertyQName);
+ childReader.setParentNamespaceContext(this.namespaceContext);
+ childReader.init();
+ } else if (propertyValue instanceof String) {
+ // strings are handled by the NameValuePairStreamReader
+ childReader = new NameValuePairStreamReader(propertyQName, (String)propertyValue);
+ childReader.setParentNamespaceContext(this.namespaceContext);
+ childReader.init();
+ } else if (propertyValue instanceof String[]) {
+ // string[] are handled by the NameValueArrayStreamReader
+ // if the array is empty - skip it
+ if (((String[])propertyValue).length == 0) {
+ // advance the index
+ ++index;
+ return processProperties();
+ } else {
+ childReader = new NameValueArrayStreamReader(propertyQName, (String[])propertyValue);
+ childReader.setParentNamespaceContext(this.namespaceContext);
+ childReader.init();
+ }
+
+ } else if (propertyValue instanceof XMLStreamable) {
+ // ADBbean has it's own method to get a reader
+ XMLStreamReader reader = ((XMLStreamable)propertyValue).getXMLStreamReader(propertyQName);
+ // we know for sure that this is an ADB XMLStreamreader.
+ // However we need to make sure that it is compatible
+ if (reader instanceof XMLFragmentStreamReader) {
+ childReader = (XMLFragmentStreamReader)reader;
+ childReader.setParentNamespaceContext(this.namespaceContext);
+ childReader.init();
+ } else {
+ // wrap it to make compatible
+ childReader = new WrappingXMLStreamReader(reader);
+ }
+ } else if (propertyValue instanceof XMLStreamReader) {
+ XMLStreamReader reader = (XMLStreamReader)propertyValue;
+ if (reader instanceof XMLFragmentStreamReader) {
+ childReader = (XMLFragmentStreamReader)reader;
+ childReader.setParentNamespaceContext(this.namespaceContext);
+ childReader.init();
+ } else {
+ // wrap it to make compatible
+ childReader = new WrappingXMLStreamReader(reader);
+ }
+
+ } else {
+ // all special possibilities has been tried! Let's treat
+ // the thing as a bean and try generating events from it
+ throw new UnsupportedOperationException("Property type is not supported");
+ // we cannot register the namespace context here
+ }
+
+ // set the state here
+ state = DELEGATED_STATE;
+ // we are done with the delegation
+ // increment the property index
+ ++index;
+ return childReader.getEventType();
+ }
+
+ public void require(int i, String string, String string1) throws XMLStreamException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean standaloneSet() {
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLStreamable.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLStreamable.java
new file mode 100644
index 0000000000..f433753f96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLStreamable.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.sca.common.xml.stax.reader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * An interface represents data that can be read using StAX streaming
+ *
+ * @version $Rev$ $Date$
+ */
+public interface XMLStreamable {
+ /**
+ * Get the XMLStreamReader for StAX processing
+ *
+ * @param rootElementName the name of the element to be generated
+ * @return Returns a pull parser.
+ */
+ XMLStreamReader getXMLStreamReader(QName rootElementName);
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNode.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNode.java
new file mode 100644
index 0000000000..9e39f58b31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNode.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface XmlNode {
+ enum Type {ELEMENT, ATTRIBUTE, CHARACTERS, READER};
+ /**
+ * Returns the children of the receiver as an <code>Iterator</code>.
+ */
+ Iterator<XmlNode> children();
+
+ /**
+ * Returns the attributes of the element as an <code>List</code>. Namespace declarations
+ * should be excluded.
+ *
+ * @return
+ */
+ List<XmlNode> attributes();
+
+ /**
+ * Returns a map of prefix to namespace URI
+ * @return
+ */
+ Map<String, String> namespaces();
+
+ /**
+ * Return the QName of the element. If it's for a text node, the name is null.
+ * @return
+ */
+ QName getName();
+
+ /**
+ * Return the text value of the leaf element
+ * @return
+ */
+ <T> T getValue();
+
+ /**
+ * Return the type of the XML node
+ * @return
+ */
+ Type getType();
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNodeIterator.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNodeIterator.java
new file mode 100644
index 0000000000..e0eba9a35d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNodeIterator.java
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.ArrayList;
+import java.util.EmptyStackException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class XmlNodeIterator implements Iterator<XmlNode> {
+ public static final int START = 0;
+ public static final int END = 1;
+
+ protected FastStack<ElementHolder> stack;
+ protected int state;
+ protected NamespaceContextImpl nsContext;
+
+ public XmlNodeIterator(XmlNode rootNode) {
+ super();
+ List<XmlNode> v = new ArrayList<XmlNode>(1);
+ v.add(rootNode);
+ stack = new FastStack<ElementHolder>();
+ Iterator<XmlNode> i = v.iterator();
+ stack.push(new ElementHolder(null, i));
+ this.state = START;
+ this.nsContext = new NamespaceContextImpl(null);
+ }
+
+ public boolean hasNext() {
+ return !(stack.empty() || (state == END && stack.peek().parent == null));
+ }
+
+ public XmlNode next() {
+ this.state = START;
+ ElementHolder element = stack.peek();
+ Iterator<XmlNode> it = element.children;
+ if (it == null || (!it.hasNext())) {
+ // End of the children, return END event of parent
+ stack.pop();
+ this.state = END;
+ this.nsContext = (NamespaceContextImpl)nsContext.getParent();
+ return element.parent;
+ }
+ XmlNode node = it.next();
+ stack.push(new ElementHolder(node, node.children()));
+ this.nsContext = new NamespaceContextImpl(this.nsContext);
+ populateNamespaces(node);
+ return node;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return nsContext;
+ }
+
+ private void populateNamespaces(XmlNode element) {
+ if (element.getName() != null) {
+ if (element.namespaces() != null) {
+ for (Map.Entry<String, String> e : element.namespaces().entrySet()) {
+ nsContext.register(e.getKey(), e.getValue());
+ }
+ }
+ }
+ }
+
+ private static class ElementHolder {
+ private XmlNode parent;
+ private Iterator<XmlNode> children;
+
+ public ElementHolder(XmlNode parent, Iterator<XmlNode> children) {
+ this.parent = parent;
+ this.children = children;
+ }
+ }
+
+ /**
+ * An implementation of the {@link java.util.Stack} API that is based on an <code>ArrayList</code> instead of a
+ * <code>Vector</code>, so it is not synchronized to protect against multi-threaded access. The implementation is
+ * therefore operates faster in environments where you do not need to worry about multiple thread contention.
+ * <p>
+ * The removal order of an <code>ArrayStack</code> is based on insertion order: The most recently added element is
+ * removed first. The iteration order is <i>not</i> the same as the removal order. The iterator returns elements
+ * from the bottom up, whereas the {@link #remove()} method removes them from the top down.
+ * <p>
+ * Unlike <code>Stack</code>, <code>ArrayStack</code> accepts null entries.
+ */
+ public static class FastStack<T> extends ArrayList<T> {
+
+ /** Ensure Serialization compatibility */
+ private static final long serialVersionUID = 2130079159931574599L;
+
+ /**
+ * Constructs a new empty <code>ArrayStack</code>. The initial size is controlled by <code>ArrayList</code>
+ * and is currently 10.
+ */
+ public FastStack() {
+ super();
+ }
+
+ /**
+ * Constructs a new empty <code>ArrayStack</code> with an initial size.
+ *
+ * @param initialSize the initial size to use
+ * @throws IllegalArgumentException if the specified initial size is negative
+ */
+ public FastStack(int initialSize) {
+ super(initialSize);
+ }
+
+ /**
+ * Return <code>true</code> if this stack is currently empty.
+ * <p>
+ * This method exists for compatibility with <code>java.util.Stack</code>. New users of this class should use
+ * <code>isEmpty</code> instead.
+ *
+ * @return true if the stack is currently empty
+ */
+ public boolean empty() {
+ return isEmpty();
+ }
+
+ /**
+ * Returns the top item off of this stack without removing it.
+ *
+ * @return the top item on the stack
+ * @throws EmptyStackException if the stack is empty
+ */
+ public T peek() throws EmptyStackException {
+ int n = size();
+ if (n <= 0) {
+ throw new EmptyStackException();
+ } else {
+ return get(n - 1);
+ }
+ }
+
+ /**
+ * Returns the n'th item down (zero-relative) from the top of this stack without removing it.
+ *
+ * @param n the number of items down to go
+ * @return the n'th item on the stack, zero relative
+ * @throws EmptyStackException if there are not enough items on the stack to satisfy this request
+ */
+ public T peek(int n) throws EmptyStackException {
+ int m = (size() - n) - 1;
+ if (m < 0) {
+ throw new EmptyStackException();
+ } else {
+ return get(m);
+ }
+ }
+
+ /**
+ * Pops the top item off of this stack and return it.
+ *
+ * @return the top item on the stack
+ * @throws EmptyStackException if the stack is empty
+ */
+ public T pop() throws EmptyStackException {
+ int n = size();
+ if (n <= 0) {
+ throw new EmptyStackException();
+ } else {
+ return remove(n - 1);
+ }
+ }
+
+ /**
+ * Pushes a new item onto the top of this stack. The pushed item is also returned. This is equivalent to calling
+ * <code>add</code>.
+ *
+ * @param item the item to be added
+ * @return the item just pushed
+ */
+ public Object push(T item) {
+ add(item);
+ return item;
+ }
+
+ /**
+ * Returns the top-most index for the object in the stack
+ *
+ * @param object the object to be searched for
+ * @return top-most index, or -1 if not found
+ */
+ public int search(T object) {
+ int i = size() - 1; // Current index
+ while (i >= 0) {
+ T current = get(i);
+ if ((object == null && current == null) || (object != null && object.equals(current))) {
+ return i;
+ }
+ i--;
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the element on the top of the stack.
+ *
+ * @return the element on the top of the stack
+ * @throws EmptyStackException if the stack is empty
+ */
+ public T get() {
+ int size = size();
+ if (size == 0) {
+ throw new EmptyStackException();
+ }
+ return get(size - 1);
+ }
+
+ /**
+ * Removes the element on the top of the stack.
+ *
+ * @return the removed element
+ * @throws EmptyStackException if the stack is empty
+ */
+ public T remove() {
+ int size = size();
+ if (size == 0) {
+ throw new EmptyStackException();
+ }
+ return remove(size - 1);
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderImpl.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderImpl.java
new file mode 100644
index 0000000000..3c4c1bdb06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderImpl.java
@@ -0,0 +1,531 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax.reader;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class XmlTreeStreamReaderImpl implements XMLStreamReader {
+
+ protected int state;
+ protected XmlNodeIterator iterator;
+ protected XmlNode current;
+
+ protected XMLStreamReader reader;
+
+ /*
+ * we need to pass in a namespace context since when delegated, we've no
+ * idea of the current namespace context. So it needs to be passed on here!
+ */
+ public XmlTreeStreamReaderImpl(XmlNode root) {
+ this.iterator = new XmlNodeIterator(root);
+ this.current = null;
+ this.state = START_DOCUMENT;
+ this.reader = null;
+ }
+
+ public void close() throws XMLStreamException {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+
+ private void checkElementState() {
+ if (getEventType() != START_ELEMENT && getEventType() != END_ELEMENT) {
+ throw new IllegalStateException();
+ }
+ }
+
+ private List<XmlNode> getAttributes() {
+ if (current != null && current.attributes() != null) {
+ return current.attributes();
+ } else {
+ return Collections.emptyList();
+ }
+ }
+
+ public int getAttributeCount() {
+ checkElementState();
+ if (reader != null) {
+ return reader.getAttributeCount();
+ }
+ return getAttributes().size();
+ }
+
+ public String getAttributeLocalName(int i) {
+ checkElementState();
+ if (reader != null) {
+ return reader.getAttributeLocalName(i);
+ }
+ return getAttributes().get(i).getName().getLocalPart();
+ }
+
+ /**
+ * @param i
+ */
+ public QName getAttributeName(int i) {
+ checkElementState();
+ if (reader != null) {
+ return reader.getAttributeName(i);
+ }
+ return getAttributes().get(i).getName();
+ }
+
+ public String getAttributeNamespace(int i) {
+ checkElementState();
+ if (reader != null) {
+ return reader.getAttributeNamespace(i);
+ }
+ return getAttributes().get(i).getName().getNamespaceURI();
+ }
+
+ public String getAttributePrefix(int i) {
+ checkElementState();
+ if (reader != null) {
+ return reader.getAttributePrefix(i);
+ }
+ return getAttributes().get(i).getName().getPrefix();
+ }
+
+ public String getAttributeType(int i) {
+ if (reader != null) {
+ return reader.getAttributeType(i);
+ }
+ return null; // not supported
+ }
+
+ public String getAttributeValue(int i) {
+ checkElementState();
+ if (reader != null) {
+ return reader.getAttributeValue(i);
+ }
+ return getAttributes().get(i).getValue();
+ }
+
+ public String getAttributeValue(String nsUri, String localName) {
+ checkElementState();
+ if (reader != null) {
+ return reader.getAttributeValue(nsUri, localName);
+ }
+ int count = getAttributeCount();
+ String value = null;
+ QName attrQName;
+ for (int i = 0; i < count; i++) {
+ attrQName = getAttributeName(i);
+ if (nsUri == null) {
+ if (localName.equals(attrQName.getLocalPart())) {
+ value = getAttributeValue(i);
+ break;
+ }
+ } else {
+ if (localName.equals(attrQName.getLocalPart()) && nsUri.equals(attrQName.getNamespaceURI())) {
+ value = getAttributeValue(i);
+ break;
+ }
+ }
+
+ }
+
+ return value;
+ }
+
+ public String getCharacterEncodingScheme() {
+ if (reader != null) {
+ return reader.getCharacterEncodingScheme();
+ }
+ return "UTF-8";
+ }
+
+ public String getElementText() throws XMLStreamException {
+ checkElementState();
+ if (reader != null) {
+ return reader.getElementText();
+ }
+ return current.getValue();
+ }
+
+ public String getEncoding() {
+ if (reader != null) {
+ return reader.getEncoding();
+ }
+ return "UTF-8";
+ }
+
+ public int getEventType() {
+ return state;
+ }
+
+ public String getLocalName() {
+ checkElementState();
+ if (reader != null) {
+ return reader.getLocalName();
+ }
+ return current.getName().getLocalPart();
+ }
+
+ /**
+ */
+ public Location getLocation() {
+ if (reader != null) {
+ return reader.getLocation();
+ }
+ // return a default location
+ return new Location() {
+ public int getCharacterOffset() {
+ return 0;
+ }
+
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ public int getLineNumber() {
+ return 0;
+ }
+
+ public String getPublicId() {
+ return null;
+ }
+
+ public String getSystemId() {
+ return null;
+ }
+ };
+ }
+
+ public QName getName() {
+ checkElementState();
+ if (reader != null) {
+ return reader.getName();
+ }
+ return current.getName();
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ if (reader != null) {
+ return reader.getNamespaceContext();
+ }
+ return iterator.getNamespaceContext();
+ }
+
+ private Map<String, String> getNamespaces() {
+ if (current != null && current.namespaces() != null) {
+ return current.namespaces();
+ } else {
+ return Collections.emptyMap();
+ }
+ }
+
+ public int getNamespaceCount() {
+ checkElementState();
+ if (reader != null) {
+ return reader.getNamespaceCount();
+ }
+ return getNamespaces().size();
+ }
+
+ /**
+ * @param i
+ */
+ public String getNamespacePrefix(int i) {
+ checkElementState();
+ if (reader != null) {
+ return reader.getNamespacePrefix(i);
+ }
+ return new ArrayList<Map.Entry<String, String>>(getNamespaces().entrySet()).get(i).getKey();
+ }
+
+ public String getNamespaceURI() {
+ checkElementState();
+ if (reader != null) {
+ return reader.getNamespaceURI();
+ }
+ return current.getName().getNamespaceURI();
+ }
+
+ public String getNamespaceURI(int i) {
+ checkElementState();
+ if (reader != null) {
+ return reader.getNamespaceURI(i);
+ }
+ return new ArrayList<Map.Entry<String, String>>(getNamespaces().entrySet()).get(i).getValue();
+ }
+
+ public String getNamespaceURI(String prefix) {
+ if (reader != null) {
+ return reader.getNamespaceURI(prefix);
+ }
+ return getNamespaceContext().getNamespaceURI(prefix);
+ }
+
+ public String getPIData() {
+ if (reader != null) {
+ return reader.getPIData();
+ }
+ throw new UnsupportedOperationException("Yet to be implemented !!");
+ }
+
+ public String getPITarget() {
+ if (reader != null) {
+ return reader.getPITarget();
+ }
+ throw new UnsupportedOperationException("Yet to be implemented !!");
+ }
+
+ public String getPrefix() {
+ if (reader != null) {
+ return reader.getPrefix();
+ }
+ if (state == START_ELEMENT || state == END_ELEMENT) {
+ String prefix = current.getName().getPrefix();
+ return "".equals(prefix) ? null : prefix;
+ } else if (state == START_DOCUMENT) {
+ return null;
+ } else {
+ throw new IllegalStateException("State==" + state);
+ }
+ }
+
+ /**
+ * @param key
+ * @throws IllegalArgumentException
+ */
+ public Object getProperty(String key) throws IllegalArgumentException {
+ if (reader != null) {
+ return reader.getProperty(key);
+ }
+ return null;
+ }
+
+ public String getText() {
+ if (reader != null) {
+ return reader.getText();
+ }
+ return current.getValue();
+ }
+
+ public char[] getTextCharacters() {
+ if (reader != null) {
+ return reader.getTextCharacters();
+ }
+ String value = current.getValue();
+ return value == null ? new char[0] : value.toCharArray();
+ }
+
+ private int copy(int sourceStart, char[] target, int targetStart, int length) {
+ char[] source = getTextCharacters();
+ if (sourceStart > source.length) {
+ throw new IndexOutOfBoundsException("source start > source length");
+ }
+ int sourceLen = source.length - sourceStart;
+ if (length > sourceLen) {
+ length = sourceLen;
+ }
+ System.arraycopy(source, sourceStart, target, targetStart, length);
+ return sourceLen;
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ if (reader != null) {
+ return reader.getTextCharacters(i, chars, i1, i2);
+ }
+ return copy(i, chars, i1, i2);
+ }
+
+ public int getTextLength() {
+ if (reader != null) {
+ return reader.getTextLength();
+ }
+ return getTextCharacters().length;
+ }
+
+ public int getTextStart() {
+ if (reader != null) {
+ return reader.getTextStart();
+ }
+ return 0;
+ }
+
+ public String getVersion() {
+ return "1.0";
+ }
+
+ public boolean hasName() {
+ if (reader != null) {
+ return reader.hasName();
+ }
+ return current.getName() != null;
+ }
+
+ /**
+ * @throws XMLStreamException
+ */
+ public boolean hasNext() throws XMLStreamException {
+ return iterator.hasNext() || state != END_DOCUMENT || (reader != null && reader.hasNext());
+ }
+
+ public boolean hasText() {
+ if (reader != null) {
+ return reader.hasText();
+ }
+ return current.getType() == XmlNode.Type.CHARACTERS;
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ if (reader != null) {
+ return reader.isAttributeSpecified(i);
+ }
+ return false; // not supported
+ }
+
+ public boolean isCharacters() {
+ if (reader != null) {
+ return reader.isCharacters();
+ }
+ return current.getType() == XmlNode.Type.CHARACTERS;
+ }
+
+ public boolean isEndElement() {
+ if (reader != null) {
+ return reader.isEndElement();
+ }
+ return getEventType() == END_ELEMENT;
+ }
+
+ public boolean isStandalone() {
+ return true;
+ }
+
+ public boolean isStartElement() {
+ if (reader != null) {
+ return reader.isStartElement();
+ }
+ return getEventType() == START_ELEMENT;
+ }
+
+ public boolean isWhiteSpace() {
+ if (reader != null) {
+ return reader.isWhiteSpace();
+ }
+ return false;
+ }
+
+ /**
+ * By far this should be the most important method in this class this method
+ * changes the state of the parser
+ */
+ public int next() throws XMLStreamException {
+ if (!hasNext()) {
+ throw new IllegalStateException("No more events");
+ }
+ if (reader != null) {
+ if (!reader.hasNext()) {
+ this.reader = null;
+ } else {
+ // Go to the delegation mode
+ state = reader.next();
+ return state;
+ }
+ }
+ if (!iterator.hasNext()) {
+ state = END_DOCUMENT;
+ current = null;
+ return state;
+ }
+ current = iterator.next();
+ XmlNode.Type type = current.getType();
+
+ int itState = iterator.getState();
+ if (itState == XmlNodeIterator.END) {
+ if (type == XmlNode.Type.ELEMENT) {
+ state = END_ELEMENT;
+ } else {
+ // Ignore the pop
+ state = next();
+ }
+ }
+ if (itState == XmlNodeIterator.START) {
+ if (type == XmlNode.Type.ELEMENT) {
+ state = START_ELEMENT;
+ } else if (type == XmlNode.Type.CHARACTERS) {
+ state = CHARACTERS;
+ } else if (type == XmlNode.Type.READER) {
+ XMLStreamReader value = current.getValue();
+ this.reader = new WrappingXMLStreamReader(value);
+ state = reader.getEventType();
+ return state;
+ }
+ }
+ return state;
+ }
+
+ /**
+ * TODO implement this
+ *
+ * @throws XMLStreamException
+ */
+ public int nextTag() throws XMLStreamException {
+ while (true) {
+ int event = next();
+ if (event == START_ELEMENT || event == END_ELEMENT) {
+ return event;
+ }
+ }
+ }
+
+ public void require(int i, String ns, String localPart) throws XMLStreamException {
+ if (reader != null) {
+ reader.require(i, ns, localPart);
+ return;
+ }
+ int event = getEventType();
+ if (event != i) {
+ throw new IllegalStateException("Event type is " + event + " (!=" + i + ")");
+ }
+ QName name = getName();
+ String ns1 = name.getNamespaceURI();
+ String localName1 = name.getLocalPart();
+
+ if (ns != null && !ns.equals(ns1)) {
+ throw new IllegalStateException("Namespace URI is " + ns1 + " (!=" + ns + ")");
+ }
+
+ if (localPart != null && !localPart.equals(localName1)) {
+ throw new IllegalStateException("Local name is " + localName1 + " (!=" + localPart + ")");
+ }
+
+ }
+
+ public boolean standaloneSet() {
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XMLCharHelper.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XMLCharHelper.java
new file mode 100644
index 0000000000..ea659ce344
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XMLCharHelper.java
@@ -0,0 +1,613 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.xpath;
+
+/**
+ * This class defines the basic XML character properties. The data
+ * in this class can be used to verify that a character is a valid
+ * XML character or if the character is a space, name start, or name
+ * character.
+ * <p/>
+ * A series of convenience methods are supplied to ease the burden
+ * of the developer. Because inlining the checks can improve per
+ * character performance, the tables of character properties are
+ * public. Using the character as an index into the <code>CHARS</code>
+ * array and applying the appropriate mask flag (e.g.
+ * <code>MASK_VALID</code>), yields the same results as calling the
+ * convenience methods. There is one exception: check the comments
+ * for the <code>isValid</code> method for details.
+ */
+public class XMLCharHelper {
+
+ //
+ // Constants
+ //
+
+ /**
+ * Character flags.
+ */
+ private static final byte[] CHARS = new byte[1 << 16];
+
+ /**
+ * Valid character mask.
+ */
+ public static final int MASK_VALID = 0x01;
+
+ /**
+ * Space character mask.
+ */
+ public static final int MASK_SPACE = 0x02;
+
+ /**
+ * Name start character mask.
+ */
+ public static final int MASK_NAME_START = 0x04;
+
+ /**
+ * Name character mask.
+ */
+ public static final int MASK_NAME = 0x08;
+
+ /**
+ * Pubid character mask.
+ */
+ public static final int MASK_PUBID = 0x10;
+
+ /**
+ * Content character mask. Special characters are those that can
+ * be considered the start of markup, such as '&lt;' and '&amp;'.
+ * The various newline characters are considered special as well.
+ * All other valid XML characters can be considered content.
+ * <p/>
+ * This is an optimization for the inner loop of character scanning.
+ */
+ public static final int MASK_CONTENT = 0x20;
+
+ /**
+ * NCName start character mask.
+ */
+ public static final int MASK_NCNAME_START = 0x40;
+
+ /**
+ * NCName character mask.
+ */
+ public static final int MASK_NCNAME = 0x80;
+
+ //
+ // Static initialization
+ //
+
+ static {
+
+ //
+ // [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
+ // [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ //
+
+ int charRange[] = {0x0009, 0x000A, 0x000D, 0x000D, 0x0020, 0xD7FF, 0xE000, 0xFFFD,};
+
+ //
+ // [3] S ::= (#x20 | #x9 | #xD | #xA)+
+ //
+
+ int spaceChar[] = {0x0020, 0x0009, 0x000D, 0x000A,};
+
+ //
+ // [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' |
+ // CombiningChar | Extender
+ //
+
+ int nameChar[] = {0x002D, 0x002E, // '-' and '.'
+ };
+
+ //
+ // [5] Name ::= (Letter | '_' | ':') (NameChar)*
+ //
+
+ int nameStartChar[] = {0x003A, 0x005F, // ':' and '_'
+ };
+
+ //
+ // [13] PubidChar ::= #x20 | 0xD | 0xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
+ //
+
+ int pubidChar[] = {0x000A, 0x000D, 0x0020, 0x0021, 0x0023, 0x0024, 0x0025, 0x003D, 0x005F};
+
+ int pubidRange[] = {0x0027, 0x003B, 0x003F, 0x005A, 0x0061, 0x007A};
+
+ //
+ // [84] Letter ::= BaseChar | Ideographic
+ //
+
+ int letterRange[] =
+ {
+ // BaseChar
+ 0x0041, 0x005A, 0x0061, 0x007A, 0x00C0, 0x00D6, 0x00D8, 0x00F6, 0x00F8, 0x0131, 0x0134, 0x013E, 0x0141,
+ 0x0148, 0x014A, 0x017E, 0x0180, 0x01C3, 0x01CD, 0x01F0, 0x01F4, 0x01F5, 0x01FA, 0x0217, 0x0250, 0x02A8,
+ 0x02BB, 0x02C1, 0x0388, 0x038A, 0x038E, 0x03A1, 0x03A3, 0x03CE, 0x03D0, 0x03D6, 0x03E2, 0x03F3, 0x0401,
+ 0x040C, 0x040E, 0x044F, 0x0451, 0x045C, 0x045E, 0x0481, 0x0490, 0x04C4, 0x04C7, 0x04C8, 0x04CB, 0x04CC,
+ 0x04D0, 0x04EB, 0x04EE, 0x04F5, 0x04F8, 0x04F9, 0x0531, 0x0556, 0x0561, 0x0586, 0x05D0, 0x05EA, 0x05F0,
+ 0x05F2, 0x0621, 0x063A, 0x0641, 0x064A, 0x0671, 0x06B7, 0x06BA, 0x06BE, 0x06C0, 0x06CE, 0x06D0, 0x06D3,
+ 0x06E5, 0x06E6, 0x0905, 0x0939, 0x0958, 0x0961, 0x0985, 0x098C, 0x098F, 0x0990, 0x0993, 0x09A8, 0x09AA,
+ 0x09B0, 0x09B6, 0x09B9, 0x09DC, 0x09DD, 0x09DF, 0x09E1, 0x09F0, 0x09F1, 0x0A05, 0x0A0A, 0x0A0F, 0x0A10,
+ 0x0A13, 0x0A28, 0x0A2A, 0x0A30, 0x0A32, 0x0A33, 0x0A35, 0x0A36, 0x0A38, 0x0A39, 0x0A59, 0x0A5C, 0x0A72,
+ 0x0A74, 0x0A85, 0x0A8B, 0x0A8F, 0x0A91, 0x0A93, 0x0AA8, 0x0AAA, 0x0AB0, 0x0AB2, 0x0AB3, 0x0AB5, 0x0AB9,
+ 0x0B05, 0x0B0C, 0x0B0F, 0x0B10, 0x0B13, 0x0B28, 0x0B2A, 0x0B30, 0x0B32, 0x0B33, 0x0B36, 0x0B39, 0x0B5C,
+ 0x0B5D, 0x0B5F, 0x0B61, 0x0B85, 0x0B8A, 0x0B8E, 0x0B90, 0x0B92, 0x0B95, 0x0B99, 0x0B9A, 0x0B9E, 0x0B9F,
+ 0x0BA3, 0x0BA4, 0x0BA8, 0x0BAA, 0x0BAE, 0x0BB5, 0x0BB7, 0x0BB9, 0x0C05, 0x0C0C, 0x0C0E, 0x0C10, 0x0C12,
+ 0x0C28, 0x0C2A, 0x0C33, 0x0C35, 0x0C39, 0x0C60, 0x0C61, 0x0C85, 0x0C8C, 0x0C8E, 0x0C90, 0x0C92, 0x0CA8,
+ 0x0CAA, 0x0CB3, 0x0CB5, 0x0CB9, 0x0CE0, 0x0CE1, 0x0D05, 0x0D0C, 0x0D0E, 0x0D10, 0x0D12, 0x0D28, 0x0D2A,
+ 0x0D39, 0x0D60, 0x0D61, 0x0E01, 0x0E2E, 0x0E32, 0x0E33, 0x0E40, 0x0E45, 0x0E81, 0x0E82, 0x0E87, 0x0E88,
+ 0x0E94, 0x0E97, 0x0E99, 0x0E9F, 0x0EA1, 0x0EA3, 0x0EAA, 0x0EAB, 0x0EAD, 0x0EAE, 0x0EB2, 0x0EB3, 0x0EC0,
+ 0x0EC4, 0x0F40, 0x0F47, 0x0F49, 0x0F69, 0x10A0, 0x10C5, 0x10D0, 0x10F6, 0x1102, 0x1103, 0x1105, 0x1107,
+ 0x110B, 0x110C, 0x110E, 0x1112, 0x1154, 0x1155, 0x115F, 0x1161, 0x116D, 0x116E, 0x1172, 0x1173, 0x11AE,
+ 0x11AF, 0x11B7, 0x11B8, 0x11BC, 0x11C2, 0x1E00, 0x1E9B, 0x1EA0, 0x1EF9, 0x1F00, 0x1F15, 0x1F18, 0x1F1D,
+ 0x1F20, 0x1F45, 0x1F48, 0x1F4D, 0x1F50, 0x1F57, 0x1F5F, 0x1F7D, 0x1F80, 0x1FB4, 0x1FB6, 0x1FBC, 0x1FC2,
+ 0x1FC4, 0x1FC6, 0x1FCC, 0x1FD0, 0x1FD3, 0x1FD6, 0x1FDB, 0x1FE0, 0x1FEC, 0x1FF2, 0x1FF4, 0x1FF6, 0x1FFC,
+ 0x212A, 0x212B, 0x2180, 0x2182, 0x3041, 0x3094, 0x30A1, 0x30FA, 0x3105, 0x312C, 0xAC00, 0xD7A3,
+ // Ideographic
+ 0x3021, 0x3029, 0x4E00, 0x9FA5,};
+ int letterChar[] =
+ {
+ // BaseChar
+ 0x0386, 0x038C, 0x03DA, 0x03DC, 0x03DE, 0x03E0, 0x0559, 0x06D5, 0x093D, 0x09B2, 0x0A5E, 0x0A8D, 0x0ABD,
+ 0x0AE0, 0x0B3D, 0x0B9C, 0x0CDE, 0x0E30, 0x0E84, 0x0E8A, 0x0E8D, 0x0EA5, 0x0EA7, 0x0EB0, 0x0EBD, 0x1100,
+ 0x1109, 0x113C, 0x113E, 0x1140, 0x114C, 0x114E, 0x1150, 0x1159, 0x1163, 0x1165, 0x1167, 0x1169, 0x1175,
+ 0x119E, 0x11A8, 0x11AB, 0x11BA, 0x11EB, 0x11F0, 0x11F9, 0x1F59, 0x1F5B, 0x1F5D, 0x1FBE, 0x2126, 0x212E,
+ // Ideographic
+ 0x3007,};
+
+ //
+ // [87] CombiningChar ::= ...
+ //
+
+ int combiningCharRange[] =
+ {0x0300, 0x0345, 0x0360, 0x0361, 0x0483, 0x0486, 0x0591, 0x05A1, 0x05A3, 0x05B9, 0x05BB, 0x05BD, 0x05C1,
+ 0x05C2, 0x064B, 0x0652, 0x06D6, 0x06DC, 0x06DD, 0x06DF, 0x06E0, 0x06E4, 0x06E7, 0x06E8, 0x06EA, 0x06ED,
+ 0x0901, 0x0903, 0x093E, 0x094C, 0x0951, 0x0954, 0x0962, 0x0963, 0x0981, 0x0983, 0x09C0, 0x09C4, 0x09C7,
+ 0x09C8, 0x09CB, 0x09CD, 0x09E2, 0x09E3, 0x0A40, 0x0A42, 0x0A47, 0x0A48, 0x0A4B, 0x0A4D, 0x0A70, 0x0A71,
+ 0x0A81, 0x0A83, 0x0ABE, 0x0AC5, 0x0AC7, 0x0AC9, 0x0ACB, 0x0ACD, 0x0B01, 0x0B03, 0x0B3E, 0x0B43, 0x0B47,
+ 0x0B48, 0x0B4B, 0x0B4D, 0x0B56, 0x0B57, 0x0B82, 0x0B83, 0x0BBE, 0x0BC2, 0x0BC6, 0x0BC8, 0x0BCA, 0x0BCD,
+ 0x0C01, 0x0C03, 0x0C3E, 0x0C44, 0x0C46, 0x0C48, 0x0C4A, 0x0C4D, 0x0C55, 0x0C56, 0x0C82, 0x0C83, 0x0CBE,
+ 0x0CC4, 0x0CC6, 0x0CC8, 0x0CCA, 0x0CCD, 0x0CD5, 0x0CD6, 0x0D02, 0x0D03, 0x0D3E, 0x0D43, 0x0D46, 0x0D48,
+ 0x0D4A, 0x0D4D, 0x0E34, 0x0E3A, 0x0E47, 0x0E4E, 0x0EB4, 0x0EB9, 0x0EBB, 0x0EBC, 0x0EC8, 0x0ECD, 0x0F18,
+ 0x0F19, 0x0F71, 0x0F84, 0x0F86, 0x0F8B, 0x0F90, 0x0F95, 0x0F99, 0x0FAD, 0x0FB1, 0x0FB7, 0x20D0, 0x20DC,
+ 0x302A, 0x302F,};
+
+ int combiningCharChar[] =
+ {0x05BF, 0x05C4, 0x0670, 0x093C, 0x094D, 0x09BC, 0x09BE, 0x09BF, 0x09D7, 0x0A02, 0x0A3C, 0x0A3E, 0x0A3F,
+ 0x0ABC, 0x0B3C, 0x0BD7, 0x0D57, 0x0E31, 0x0EB1, 0x0F35, 0x0F37, 0x0F39, 0x0F3E, 0x0F3F, 0x0F97, 0x0FB9,
+ 0x20E1, 0x3099, 0x309A,};
+
+ //
+ // [88] Digit ::= ...
+ //
+
+ int digitRange[] =
+ {0x0030, 0x0039, 0x0660, 0x0669, 0x06F0, 0x06F9, 0x0966, 0x096F, 0x09E6, 0x09EF, 0x0A66, 0x0A6F, 0x0AE6,
+ 0x0AEF, 0x0B66, 0x0B6F, 0x0BE7, 0x0BEF, 0x0C66, 0x0C6F, 0x0CE6, 0x0CEF, 0x0D66, 0x0D6F, 0x0E50, 0x0E59,
+ 0x0ED0, 0x0ED9, 0x0F20, 0x0F29,};
+
+ //
+ // [89] Extender ::= ...
+ //
+
+ int extenderRange[] = {0x3031, 0x3035, 0x309D, 0x309E, 0x30FC, 0x30FE,};
+
+ int extenderChar[] = {0x00B7, 0x02D0, 0x02D1, 0x0387, 0x0640, 0x0E46, 0x0EC6, 0x3005,};
+
+ //
+ // SpecialChar ::= '<', '&', '\n', '\r', ']'
+ //
+
+ int specialChar[] = {'<', '&', '\n', '\r', ']',};
+
+ //
+ // Initialize
+ //
+
+ // set valid characters
+ for (int i = 0; i < charRange.length; i += 2) {
+ for (int j = charRange[i]; j <= charRange[i + 1]; j++) {
+ CHARS[j] |= MASK_VALID | MASK_CONTENT;
+ }
+ }
+
+ // remove special characters
+ for (int i = 0; i < specialChar.length; i++) {
+ CHARS[specialChar[i]] = (byte)(CHARS[specialChar[i]] & ~MASK_CONTENT);
+ }
+
+ // set space characters
+ for (int i = 0; i < spaceChar.length; i++) {
+ CHARS[spaceChar[i]] |= MASK_SPACE;
+ }
+
+ // set name start characters
+ for (int i = 0; i < nameStartChar.length; i++) {
+ CHARS[nameStartChar[i]] |= MASK_NAME_START | MASK_NAME | MASK_NCNAME_START | MASK_NCNAME;
+ }
+ for (int i = 0; i < letterRange.length; i += 2) {
+ for (int j = letterRange[i]; j <= letterRange[i + 1]; j++) {
+ CHARS[j] |= MASK_NAME_START | MASK_NAME | MASK_NCNAME_START | MASK_NCNAME;
+ }
+ }
+ for (int i = 0; i < letterChar.length; i++) {
+ CHARS[letterChar[i]] |= MASK_NAME_START | MASK_NAME | MASK_NCNAME_START | MASK_NCNAME;
+ }
+
+ // set name characters
+ for (int i = 0; i < nameChar.length; i++) {
+ CHARS[nameChar[i]] |= MASK_NAME | MASK_NCNAME;
+ }
+ for (int i = 0; i < digitRange.length; i += 2) {
+ for (int j = digitRange[i]; j <= digitRange[i + 1]; j++) {
+ CHARS[j] |= MASK_NAME | MASK_NCNAME;
+ }
+ }
+ for (int i = 0; i < combiningCharRange.length; i += 2) {
+ for (int j = combiningCharRange[i]; j <= combiningCharRange[i + 1]; j++) {
+ CHARS[j] |= MASK_NAME | MASK_NCNAME;
+ }
+ }
+ for (int i = 0; i < combiningCharChar.length; i++) {
+ CHARS[combiningCharChar[i]] |= MASK_NAME | MASK_NCNAME;
+ }
+ for (int i = 0; i < extenderRange.length; i += 2) {
+ for (int j = extenderRange[i]; j <= extenderRange[i + 1]; j++) {
+ CHARS[j] |= MASK_NAME | MASK_NCNAME;
+ }
+ }
+ for (int i = 0; i < extenderChar.length; i++) {
+ CHARS[extenderChar[i]] |= MASK_NAME | MASK_NCNAME;
+ }
+
+ // remove ':' from allowable MASK_NCNAME_START and MASK_NCNAME chars
+ CHARS[':'] &= ~(MASK_NCNAME_START | MASK_NCNAME);
+
+ // set Pubid characters
+ for (int i = 0; i < pubidChar.length; i++) {
+ CHARS[pubidChar[i]] |= MASK_PUBID;
+ }
+ for (int i = 0; i < pubidRange.length; i += 2) {
+ for (int j = pubidRange[i]; j <= pubidRange[i + 1]; j++) {
+ CHARS[j] |= MASK_PUBID;
+ }
+ }
+
+ } // <clinit>()
+
+ //
+ // Public static methods
+ //
+
+ /**
+ * Returns true if the specified character is a supplemental character.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isSupplemental(int c) {
+ return (c >= 0x10000 && c <= 0x10FFFF);
+ }
+
+ /**
+ * Returns true the supplemental character corresponding to the given
+ * surrogates.
+ *
+ * @param h The high surrogate.
+ * @param l The low surrogate.
+ */
+ public static int supplemental(char h, char l) {
+ return (h - 0xD800) * 0x400 + (l - 0xDC00) + 0x10000;
+ }
+
+ /**
+ * Returns the high surrogate of a supplemental character
+ *
+ * @param c The supplemental character to "split".
+ */
+ public static char highSurrogate(int c) {
+ return (char)(((c - 0x00010000) >> 10) + 0xD800);
+ }
+
+ /**
+ * Returns the low surrogate of a supplemental character
+ *
+ * @param c The supplemental character to "split".
+ */
+ public static char lowSurrogate(int c) {
+ return (char)(((c - 0x00010000) & 0x3FF) + 0xDC00);
+ }
+
+ /**
+ * Returns whether the given character is a high surrogate
+ *
+ * @param c The character to check.
+ */
+ public static boolean isHighSurrogate(int c) {
+ return (0xD800 <= c && c <= 0xDBFF);
+ }
+
+ /**
+ * Returns whether the given character is a low surrogate
+ *
+ * @param c The character to check.
+ */
+ public static boolean isLowSurrogate(int c) {
+ return (0xDC00 <= c && c <= 0xDFFF);
+ }
+
+ /**
+ * Returns true if the specified character is valid. This method
+ * also checks the surrogate character range from 0x10000 to 0x10FFFF.
+ * <p/>
+ * If the program chooses to apply the mask directly to the
+ * <code>CHARS</code> array, then they are responsible for checking
+ * the surrogate character range.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isValid(int c) {
+ return (c < 0x10000 && (CHARS[c] & MASK_VALID) != 0) || (0x10000 <= c && c <= 0x10FFFF);
+ } // isValid(int):boolean
+
+ /**
+ * Returns true if the specified character is invalid.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isInvalid(int c) {
+ return !isValid(c);
+ } // isInvalid(int):boolean
+
+ /**
+ * Returns true if the specified character can be considered content.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isContent(int c) {
+ return (c < 0x10000 && (CHARS[c] & MASK_CONTENT) != 0) || (0x10000 <= c && c <= 0x10FFFF);
+ } // isContent(int):boolean
+
+ /**
+ * Returns true if the specified character can be considered markup.
+ * Markup characters include '&lt;', '&amp;', and '%'.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isMarkup(int c) {
+ return c == '<' || c == '&' || c == '%';
+ } // isMarkup(int):boolean
+
+ /**
+ * Returns true if the specified character is a space character
+ * as defined by production [3] in the XML 1.0 specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isSpace(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_SPACE) != 0;
+ } // isSpace(int):boolean
+
+ /**
+ * Returns true if the specified character is a space character
+ * as amdended in the XML 1.1 specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isXML11Space(int c) {
+ return (c < 0x10000 && (CHARS[c] & MASK_SPACE) != 0) || c == 0x85 || c == 0x2028;
+ } // isXML11Space(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid name start
+ * character as defined by production [5] in the XML 1.0
+ * specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isNameStart(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_NAME_START) != 0;
+ } // isNameStart(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid name
+ * character as defined by production [4] in the XML 1.0
+ * specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isName(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_NAME) != 0;
+ } // isName(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid NCName start
+ * character as defined by production [4] in Namespaces in XML
+ * recommendation.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isNCNameStart(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_NCNAME_START) != 0;
+ } // isNCNameStart(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid NCName
+ * character as defined by production [5] in Namespaces in XML
+ * recommendation.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isNCName(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_NCNAME) != 0;
+ } // isNCName(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid Pubid
+ * character as defined by production [13] in the XML 1.0
+ * specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isPubid(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_PUBID) != 0;
+ } // isPubid(int):boolean
+
+ /*
+ * [5] Name ::= (Letter | '_' | ':') (NameChar)*
+ */
+ /**
+ * Check to see if a string is a valid Name according to [5]
+ * in the XML 1.0 Recommendation
+ *
+ * @param name string to check
+ * @return true if name is a valid Name
+ */
+ public static boolean isValidName(String name) {
+ if (name.length() == 0) {
+ return false;
+ }
+ char ch = name.charAt(0);
+ if (!isNameStart(ch)) {
+ return false;
+ }
+ for (int i = 1; i < name.length(); i++) {
+ ch = name.charAt(i);
+ if (!isName(ch)) {
+ return false;
+ }
+ }
+ return true;
+ } // isValidName(String):boolean
+
+ /*
+ * from the namespace rec
+ * [4] NCName ::= (Letter | '_') (NCNameChar)*
+ */
+ /**
+ * Check to see if a string is a valid NCName according to [4]
+ * from the XML Namespaces 1.0 Recommendation
+ *
+ * @param ncName string to check
+ * @return true if name is a valid NCName
+ */
+ public static boolean isValidNCName(String ncName) {
+ if (ncName.length() == 0) {
+ return false;
+ }
+ char ch = ncName.charAt(0);
+ if (!isNCNameStart(ch)) {
+ return false;
+ }
+ for (int i = 1; i < ncName.length(); i++) {
+ ch = ncName.charAt(i);
+ if (!isNCName(ch)) {
+ return false;
+ }
+ }
+ return true;
+ } // isValidNCName(String):boolean
+
+ /*
+ * [7] Nmtoken ::= (NameChar)+
+ */
+ /**
+ * Check to see if a string is a valid Nmtoken according to [7]
+ * in the XML 1.0 Recommendation
+ *
+ * @param nmtoken string to check
+ * @return true if nmtoken is a valid Nmtoken
+ */
+ public static boolean isValidNmtoken(String nmtoken) {
+ if (nmtoken.length() == 0) {
+ return false;
+ }
+ for (int i = 0; i < nmtoken.length(); i++) {
+ char ch = nmtoken.charAt(i);
+ if (!isName(ch)) {
+ return false;
+ }
+ }
+ return true;
+ } // isValidName(String):boolean
+
+ // encodings
+
+ /**
+ * Returns true if the encoding name is a valid IANA encoding.
+ * This method does not verify that there is a decoder available
+ * for this encoding, only that the characters are valid for an
+ * IANA encoding name.
+ *
+ * @param ianaEncoding The IANA encoding name.
+ */
+ public static boolean isValidIANAEncoding(String ianaEncoding) {
+ if (ianaEncoding != null) {
+ int length = ianaEncoding.length();
+ if (length > 0) {
+ char c = ianaEncoding.charAt(0);
+ if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
+ for (int i = 1; i < length; i++) {
+ c = ianaEncoding.charAt(i);
+ if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z')
+ && (c < '0' || c > '9')
+ && c != '.'
+ && c != '_'
+ && c != '-') {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ } // isValidIANAEncoding(String):boolean
+
+ /**
+ * Returns true if the encoding name is a valid Java encoding.
+ * This method does not verify that there is a decoder available
+ * for this encoding, only that the characters are valid for an
+ * Java encoding name.
+ *
+ * @param javaEncoding The Java encoding name.
+ */
+ public static boolean isValidJavaEncoding(String javaEncoding) {
+ if (javaEncoding != null) {
+ int length = javaEncoding.length();
+ if (length > 0) {
+ for (int i = 1; i < length; i++) {
+ char c = javaEncoding.charAt(i);
+ if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z')
+ && (c < '0' || c > '9')
+ && c != '.'
+ && c != '_'
+ && c != '-') {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ } // isValidIANAEncoding(String):boolean
+
+} // class XMLChar
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java
new file mode 100644
index 0000000000..d364aa199f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.xpath;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.tuscany.sca.common.xml.stax.reader.NamespaceContextImpl;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+
+/**
+ * Helper for XPath operations
+ */
+public class XPathHelper {
+ private XPathFactory factory;
+
+ /**
+ * @param factory
+ */
+ public XPathHelper(XPathFactory factory) {
+ super();
+ this.factory = factory;
+ }
+
+ public XPathHelper(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.factory = factories.getFactory(XPathFactory.class);
+ }
+
+ public static XPathHelper getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilities.getUtility(XPathHelper.class);
+ }
+
+ public XPath newXPath() {
+ return factory.newXPath();
+ }
+
+ public XPathExpression compile(NamespaceContext context, String expression) throws XPathExpressionException {
+ XPath path = newXPath();
+ context = getNamespaceContext(expression, context);
+ return compile(path, context, expression);
+ }
+
+ public XPathExpression compile(XPath path, NamespaceContext context, String expression)
+ throws XPathExpressionException {
+ path.setNamespaceContext(context);
+ return path.compile(expression);
+ }
+
+ /**
+ * Take a snapshot of the given namespace context based on the prefixes found in the expression.
+ * In StAX, the prefix/namespace mapping in the namespace context can change as the event moves
+ * @param expression
+ * @param context
+ * @return
+ */
+ public NamespaceContext getNamespaceContext(String expression, NamespaceContext context) {
+ NamespaceContextImpl nsContext = new NamespaceContextImpl(null);
+
+ boolean found = false;
+ for (String prefix : getPrefixes(expression)) {
+ String namespace = context.getNamespaceURI(prefix);
+ if (namespace != null && !XMLConstants.NULL_NS_URI.equals(namespace)) {
+ nsContext.register(prefix, namespace);
+ if ( (namespace.equals("http://docs.oasis-open.org/ns/opencsa/sca/200912")) && !prefix.equals(XMLConstants.DEFAULT_NS_PREFIX))
+ found = true;
+ }
+ }
+
+ if(!found) {
+ nsContext.register("__sca", "http://docs.oasis-open.org/ns/opencsa/sca/200912");
+ }
+ return nsContext;
+ }
+
+ /**
+ * Registers a prefix in an existing NamespaceContext
+ * @param prefix
+ * @param namespace
+ * @param context
+ */
+ public void registerPrefix(String prefix, String namespace, NamespaceContext context) {
+ NamespaceContextImpl nsContext = (NamespaceContextImpl) context;
+ nsContext.register(prefix, namespace);
+ }
+
+ /**
+ * Parse the XPath expression to collect all the prefixes for namespaces
+ * @param expression
+ * @return A collection of prefixes
+ */
+ private Collection<String> getPrefixes(String expression) {
+ Collection<String> prefixes = new HashSet<String>();
+ prefixes.add(XMLConstants.DEFAULT_NS_PREFIX);
+ Pattern pattern = Pattern.compile("([a-zA-Z.]+):([a-zA-Z.]+)");
+ Matcher matcher = pattern.matcher(expression);
+ while (matcher.find()) {
+ String prefix = extractNCName(matcher.group(1), true);
+ String local = extractNCName(matcher.group(2), false);
+ if (prefix != null && local != null) {
+ prefixes.add(prefix);
+ }
+ }
+ return prefixes;
+ }
+
+ private String extractNCName(String str, boolean reverse) {
+ if (str.length() < 1) {
+ return null;
+ }
+ if (!reverse) {
+ if (!XMLCharHelper.isNCNameStart(str.charAt(0))) {
+ return null;
+ }
+ int i = 0, j = str.length();
+ // Find the last non-NCName char
+ for (; i < j; i++) {
+ if (!XMLCharHelper.isNCName(str.charAt(i))) {
+ break;
+ }
+ }
+ return str.substring(0, i);
+ } else {
+ int j = str.length() - 1;
+ // Find the first non-NCName char
+ for (; j >= 0; j--) {
+ if (!XMLCharHelper.isNCName(str.charAt(j))) {
+ break;
+ }
+ }
+ // j is before the first char of the prefix
+ if (j != (str.length() - 1) && XMLCharHelper.isNCNameStart(str.charAt(j + 1))) {
+ return str.substring(j + 1);
+ } else {
+ return null;
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/dom/DOMHelperTestCase.java b/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/dom/DOMHelperTestCase.java
new file mode 100644
index 0000000000..176ea35c1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/dom/DOMHelperTestCase.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.sca.common.xml.dom;
+
+import static org.junit.Assert.assertNotNull;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.common.xml.sax.SAXHelper;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.ContentHandler;
+
+/**
+ * Test Case for StAXHelper
+ *
+ * @version $Rev$ $Date$
+ */
+public class DOMHelperTestCase {
+ private static final String XML =
+ "<a:foo xmlns:a='http://a' name='foo'><bar name='bar'>" + "<doo a:name='doo' xmlns:a='http://doo'/>"
+ + "</bar></a:foo>";
+
+ private static ExtensionPointRegistry registry;
+
+ @BeforeClass
+ public static void init() {
+ registry = new DefaultExtensionPointRegistry();
+ registry.start();
+ }
+
+ @AfterClass
+ public static void destroy() {
+ if (registry != null) {
+ registry.stop();
+ }
+ }
+
+ @Test
+ public void testHelper() throws Exception {
+ DOMHelper helper = DOMHelper.getInstance(registry);
+ Document document = helper.load(XML);
+ String xml = helper.saveAsString(document);
+ XMLAssert.assertXMLEqual(XML, xml);
+
+ Document root = helper.newDocument();
+ ContentHandler handler = helper.createContentHandler(root);
+
+ DOMHelper helper2 = DOMHelper.getInstance(registry);
+ Assert.assertSame(helper, helper2);
+
+ SAXHelper saxHelper = new SAXHelper(registry);
+ saxHelper.parse(XML, handler);
+
+ assertNotNull(root.getFirstChild());
+ xml = helper.saveAsString(root);
+ XMLAssert.assertXMLEqual(XML, xml);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/StAXHelperTestCase.java b/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/StAXHelperTestCase.java
new file mode 100644
index 0000000000..77f060b081
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/StAXHelperTestCase.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.stax;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper.Attribute;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Node;
+
+/**
+ * Test Case for StAXHelper
+ *
+ * @version $Rev$ $Date$
+ */
+public class StAXHelperTestCase {
+ private static final String XML =
+ "<a:foo xmlns:a='http://foo' name='foo' xmlns='http://foo1'><bar name='bar'>" + "<doo a:name='doo' xmlns:a='http://doo'/>"
+ + "</bar><bar1 xmlns='http://bar1' name='bar1'/><bar2 xmlns='' name='bar2'/></a:foo>";
+ public static final QName WSDL11 = new QName("http://schemas.xmlsoap.org/wsdl/", "definitions");
+ public static final QName WSDL20 = new QName("http://www.w3.org/ns/wsdl", "description");
+ public static final QName XSD = new QName("http://www.w3.org/2001/XMLSchema", "schema");
+
+ @Test
+ public void testHelper() throws Exception {
+ StAXHelper helper = new StAXHelper(new DefaultExtensionPointRegistry());
+ XMLStreamReader reader = helper.createXMLStreamReader(XML);
+ String xml = helper.saveAsString(reader);
+ XMLAssert.assertXMLEqual(XML, xml);
+ reader = helper.createXMLStreamReader(xml);
+ assertNotNull(reader);
+
+ Node node = helper.saveAsNode(reader);
+ assertNotNull(node.getFirstChild());
+ reader = helper.createXMLStreamReader(node);
+ xml = helper.saveAsString(reader);
+ XMLAssert.assertXMLEqual(XML, xml);
+ }
+
+ @Test
+ public void testNoRepairingNamespaces() throws Exception {
+ StAXHelper helper = new StAXHelper(new DefaultExtensionPointRegistry());
+ helper.getOutputFactory().setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE);
+ XMLStreamReader reader = helper.createXMLStreamReader(XML);
+ String xml = helper.saveAsString(reader);
+ XMLAssert.assertXMLEqual(XML, xml);
+ reader = helper.createXMLStreamReader(xml);
+ assertNotNull(reader);
+ }
+
+ @Test
+ public void testIndex() throws Exception {
+ StAXHelper helper = new StAXHelper(new DefaultExtensionPointRegistry());
+ URL xsd = getClass().getResource("test.xsd");
+ String tns = helper.readAttribute(xsd, XSD, "targetNamespace");
+ Assert.assertEquals("http://www.example.org/test/", tns);
+
+ List<String> tnsList = helper.readAttributes(xsd, XSD, "targetNamespace");
+ Assert.assertEquals(1, tnsList.size());
+ Assert.assertEquals("http://www.example.org/test/", tnsList.get(0));
+
+ URL wsdl = getClass().getResource("test.wsdl");
+ tns = helper.readAttribute(wsdl, WSDL11, "targetNamespace");
+ Assert.assertEquals("http://www.example.org/test/wsdl", tns);
+
+ tns = helper.readAttribute(wsdl, XSD, "targetNamespace");
+ Assert.assertNull(tns);
+
+ tnsList = helper.readAttributes(wsdl, XSD, "targetNamespace");
+ Assert.assertEquals(2, tnsList.size());
+ Assert.assertEquals("http://www.example.org/test/xsd1", tnsList.get(0));
+ Assert.assertEquals("http://www.example.org/test/xsd2", tnsList.get(1));
+
+ Attribute attr1 = new Attribute(WSDL11, "targetNamespace");
+ Attribute attr2 = new Attribute(XSD, "targetNamespace");
+ Attribute[] attrs = helper.readAttributes(wsdl, attr1, attr2);
+
+ Assert.assertEquals(2, attrs.length);
+ Assert.assertEquals("http://www.example.org/test/wsdl", attrs[0].getValues().get(0));
+ Assert.assertEquals("http://www.example.org/test/xsd1", attrs[1].getValues().get(0));
+ Assert.assertEquals("http://www.example.org/test/xsd2", attrs[1].getValues().get(1));
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderTestCase.java b/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderTestCase.java
new file mode 100644
index 0000000000..264c1a0d61
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderTestCase.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.sca.common.xml.stax.reader;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.common.xml.stax.impl.XMLStreamSerializer;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class XmlTreeStreamReaderTestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private static final String XML_RESULT =
+ "<?xml version='1.0' encoding='UTF-8'?>" + "<p1:e1 xmlns:p1=\"http://ns\">"
+ + "<p2:e11 xmlns:p2=\"http://ns1\">MyText</p2:e11>"
+ + "<p1:e12><p1:e121 /></p1:e12>"
+ + "<ipo:purchaseOrder xmlns:ipo=\"http://www.example.com/IPO\" "
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ + "xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\" orderDate=\"1999-12-01\"> "
+ + "<shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\"> "
+ + "<name>Helen Zoe</name> <street>47 Eden Street</street> "
+ + "<city>Cambridge</city> <postcode>CB1 1JR</postcode> </shipTo> "
+ + "<billTo xsi:type=\"ipo:USAddress\"> <name>Robert Smith</name> "
+ + "<street>8 Oak Avenue</street> <city>Old Town</city> <state>PA</state> "
+ + "<zip>95819</zip> </billTo> <items> <item partNum=\"833-AA\"> "
+ + "<productName>Lapis necklace</productName> <quantity>1</quantity> "
+ + "<USPrice>99.95</USPrice> <ipo:comment>Want this for the holidays</ipo:comment> "
+ + "<shipDate>1999-12-05</shipDate> </item> </items></ipo:purchaseOrder></p1:e1>";
+ private XmlNodeImpl root;
+
+ @Before
+ public void setUp() throws Exception {
+ root = new XmlNodeImpl();
+ root.name = new QName("http://ns", "e1", "p1");
+
+ XmlNodeImpl e11 = new XmlNodeImpl();
+ e11.name = new QName("http://ns1", "e11", "p2");
+
+ XmlNodeImpl e12 = new XmlNodeImpl();
+ e12.name = new QName("http://ns", "e12");
+
+ root.children.add(e11);
+ root.children.add(e12);
+
+ XmlNodeImpl e121 = new XmlNodeImpl();
+ e121.name = new QName("http://ns", "e121");
+ e12.children.add(e121);
+
+ XmlNodeImpl e111 = new XmlNodeImpl();
+ e111.value = "MyText";
+ e11.children.add(e111);
+
+ XmlNodeImpl e13 = new XmlNodeImpl();
+ e13.value = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(IPO_XML));
+ root.children.add(e13);
+
+ }
+
+ @Test
+ public void testIterator() {
+ List<QName> elements = new ArrayList<QName>();
+ XmlNodeIterator i = new XmlNodeIterator(root);
+ for (; i.hasNext();) {
+ XmlNode e = i.next();
+ elements.add(e.getName());
+ }
+ // System.out.println(elements);
+ QName[] names =
+ {new QName("http://ns", "e1"), new QName("http://ns1", "e11"), null, null, new QName("http://ns1", "e11"),
+ new QName("http://ns", "e12"), new QName("http://ns", "e121"), new QName("http://ns", "e121"),
+ new QName("http://ns", "e12"), null, null, new QName("http://ns", "e1")};
+ Assert.assertEquals(Arrays.asList(names), elements);
+ }
+
+ @Test
+ public void testReader() throws Exception {
+ XmlTreeStreamReaderImpl reader = new XmlTreeStreamReaderImpl(root);
+ XMLStreamSerializer serializer = new XMLStreamSerializer();
+ StringWriter sw = new StringWriter();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
+ serializer.serialize(reader, writer);
+ String xml = sw.toString();
+ XMLAssert.assertXMLEqual(XML_RESULT, xml);
+ }
+
+ private static class XmlNodeImpl implements XmlNode {
+ private List<XmlNode> children = new ArrayList<XmlNode>();
+ private List<XmlNode> attrs = new ArrayList<XmlNode>();
+ private Map<String, String> namespaces = new HashMap<String, String>();
+ private QName name;
+ private Object value = "123";
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#attributes()
+ */
+ public List<XmlNode> attributes() {
+ return attrs;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#children()
+ */
+ public Iterator<XmlNode> children() {
+ return children.iterator();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#getName()
+ */
+ public QName getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#getValue()
+ */
+ public <T> T getValue() {
+ return (T)value;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.common.xml.stax.reader.databinding.xml.XmlNode#namespaces()
+ */
+ public Map<String, String> namespaces() {
+ return namespaces;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ public Type getType() {
+ if (value instanceof XMLStreamReader) {
+ return Type.READER;
+ }
+ return name == null ? Type.CHARACTERS : Type.ELEMENT;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java b/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
new file mode 100644
index 0000000000..3b1f7b52f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.common.xml.xpath;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ */
+public class XPathHelperTestCase {
+ private static XPathHelper xpathHelper;
+ private static StAXHelper staxHelper;
+ private static DOMHelper domHelper;
+
+ private static String XML =
+ "<r:root name=\"root\" xmlns:r=\"http://root\">" + "<c:child xmlns:c=\"http://child\" name=\"child\">"
+ + "<c:child1 xmlns:c=\"http://child1\" name=\"child1\"/>"
+ + "</c:child>"
+ + "</r:root>";
+
+ private static String XML2 = "<definitions xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
+ "xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
+ "xmlns:test=\"http://docs.oasis-open.org/ns/opencsa/scatests/200903\" " +
+ "targetNamespace=\"http://docs.oasis-open.org/ns/opencsa/scatests/200903\"></definitions>";
+
+ private static String XPATH =
+ "<policySet attachTo=\"//c:child1[@name='child1']/self::node()\" xmlns:c=\"http://child1\" xmlns=\"http://p\">" + "<child xmlns:c=\"http://c2\"/></policySet>";
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ xpathHelper = XPathHelper.getInstance(registry);
+ domHelper = DOMHelper.getInstance(registry);
+ staxHelper = StAXHelper.getInstance(registry);
+ }
+
+ @Test
+ public void testNewXPath() {
+ XPath path = xpathHelper.newXPath();
+ Assert.assertNotNull(path);
+ }
+
+ @Test
+ public void testCompile() throws Exception {
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(XPATH);
+ reader.nextTag();
+ String xpath = reader.getAttributeValue(null, "attachTo");
+ XPathExpression expression = xpathHelper.compile(reader.getNamespaceContext(), xpath);
+ // Advance the reader so that the namespace context changes its prefix/namespace mapping
+ reader.nextTag();
+ reader.close();
+
+ Document doc = domHelper.load(XML);
+ NodeList nodes = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);
+ Assert.assertEquals(1, nodes.getLength());
+ Node node = nodes.item(0);
+ Assert.assertTrue(node instanceof Element);
+ Assert.assertEquals(node.getNodeName(), "c:child1");
+ }
+
+ @Test
+ public void testCompile2() throws Exception {
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(XPATH);
+ reader.nextTag();
+ String xpathExp = reader.getAttributeValue(null, "attachTo");
+ XPath xpath = xpathHelper.newXPath();
+ // Compile the expression without taking a snapshot of the namespace context
+ XPathExpression expression = xpathHelper.compile(xpath, reader.getNamespaceContext(), xpathExp);
+ // Advance the reader so that the namespace context changes its prefix/namespace mapping
+ reader.nextTag();
+ reader.close();
+
+ Document doc = domHelper.load(XML);
+ NodeList nodes = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);
+ Assert.assertEquals(1, nodes.getLength());
+ Node node = nodes.item(0);
+ Assert.assertTrue(node instanceof Element);
+ Assert.assertEquals(node.getNodeName(), "c:child1");
+ }
+
+ @Test
+ public void testGetPrefixes() throws Exception {
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(XML2);
+ reader.nextTag();
+ NamespaceContext ctx = xpathHelper.getNamespaceContext("//sca:reference[IntentRefs('test:foo')]",
+ reader.getNamespaceContext());
+ Assert.assertNotNull(ctx.getNamespaceURI("sca"));
+ Assert.assertNotNull(ctx.getNamespaceURI("test"));
+
+ }
+
+ @Test
+ public void testGetPrefixes2() throws Exception {
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(XML2);
+ reader.nextTag();
+ NamespaceContext ctx = xpathHelper.getNamespaceContext("//sca:implementation.java[ IntentRefs( 'test:foo' ) ]",
+ reader.getNamespaceContext());
+ Assert.assertNotNull(ctx.getNamespaceURI("sca"));
+ Assert.assertNotNull(ctx.getNamespaceURI("test"));
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ xpathHelper = null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.wsdl b/sandbox/sebastien/java/embed/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.wsdl
new file mode 100644
index 0000000000..d7274f64af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.wsdl
@@ -0,0 +1,60 @@
+<?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 name="TestDefinition"
+ targetNamespace="http://www.example.org/test/wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://www.example.org/test/wsdl"
+ xmlns:xsd1="http://www.example.org/test/xsd1"
+ xmlns:xsd2="http://www.example.org/test/xsd2"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.example.org/test/xsd1">
+ <xsd:element name="test">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="in" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="testResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="out" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <xsd:schema targetNamespace="http://www.example.org/test/xsd2">
+ <xsd:element name="test2" type="xsd:string"></xsd:element>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="testRequest">
+ <wsdl:part name="parameters" element="xsd1:test"></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="testResponse">
+ <wsdl:part name="parameters" element="xsd1:testResponse"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Test">
+ <wsdl:operation name="test">
+ <wsdl:input message="tns:testRequest"></wsdl:input>
+ <wsdl:output message="tns:testResponse"></wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.xsd b/sandbox/sebastien/java/embed/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.xsd
new file mode 100644
index 0000000000..903d419720
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.xsd
@@ -0,0 +1,30 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.org/test/" targetNamespace="http://www.example.org/test/">
+
+ <element name="root" type="tns:Name"></element>
+ <complexType name="Name">
+ <sequence>
+ <element name="firstName" type="string"/>
+ <element name="lastName" type="string"/>
+ </sequence>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/LICENSE b/sandbox/sebastien/java/embed/modules/contribution-osgi/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/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/sebastien/java/embed/modules/contribution-osgi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/contribution-osgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..fdebec4d1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.tuscany.sca.contribution.osgi
+Bundle-Version: 2.0.0
+Bundle-ActivationPolicy: lazy
+Bundle-Name: Apache Tuscany SCA Contribution OSGi Bundle
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: true
+Bundle-Activator: org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleActivator
+Bundle-Description: Apache Tuscany SCA OSGi Implementation
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+SCA-Version: 1.1
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.osgi;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.contribution.scanner;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.osgi.framework;version="1.4.0"
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.contribution.osgi;version="2.0.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/NOTICE b/sandbox/sebastien/java/embed/modules/contribution-osgi/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/pom.xml b/sandbox/sebastien/java/embed/modules/contribution-osgi/pom.xml
new file mode 100644
index 0000000000..9a914276aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/pom.xml
@@ -0,0 +1,72 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <name>Apache Tuscany SCA Contribution OSGi Bundle</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/BundleReference.java b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/BundleReference.java
new file mode 100644
index 0000000000..3f82f6fb17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/BundleReference.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.osgi;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * A reference to an OSGi bundle
+ *
+ * @version $Rev$ $Date$
+ */
+public class BundleReference {
+
+ /**
+ * The bundle.
+ */
+ private Bundle bundle;
+
+ /**
+ * The bundle version.
+ */
+ private String version;
+
+ /**
+ * The bundle name and version.
+ */
+ private String symbolicName;
+
+ /**
+ * Constructs a new BundleReference.
+ *
+ * @param bundle
+ */
+ public BundleReference(Bundle bundle) {
+ this.bundle = bundle;
+ this.symbolicName = bundle.getSymbolicName();
+ this.version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+ }
+
+ /**
+ * Constructs a new BundleReference.
+ *
+ * @param bundleSymbolicName The bundle symbolic name
+ * @param bundleVersion The bundle version
+ */
+ public BundleReference(String bundleSymbolicName, String bundleVersion) {
+ this.version = bundleVersion;
+ this.symbolicName = bundleSymbolicName;
+ }
+
+ /**
+ * Get the referenced bundle.
+ *
+ * @return The referenced bundle
+ */
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ /**
+ * Get the referenced bundle version.
+ *
+ * @return The bundle version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Get the referenced bundle name and version.
+ *
+ * @return The bundle name
+ */
+ public String getSymbolicName() {
+ return symbolicName;
+ }
+
+ /**
+ * Returns true if the bundle reference is unresolved.
+ *
+ * @return Whether or not the bundle has been resolved
+ */
+ public boolean isUnresolved() {
+ return bundle == null;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((symbolicName == null) ? 0 : symbolicName.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BundleReference other = (BundleReference)obj;
+ if (symbolicName == null) {
+ if (other.symbolicName != null)
+ return false;
+ } else if (!symbolicName.equals(other.symbolicName))
+ return false;
+ if (version == null) {
+ if (other.version != null)
+ return false;
+ } else if (!version.equals(other.version))
+ return false;
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleActivator.java b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleActivator.java
new file mode 100644
index 0000000000..af13d2ee98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleActivator.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.osgi.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * The Bundle Activator that receives the BundleContext
+ */
+public class OSGiBundleActivator implements BundleActivator {
+ private static BundleContext bundleContext;
+
+ public static BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
+ public void start(BundleContext context) throws Exception {
+ bundleContext = context;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ bundleContext = null;
+ }
+
+ public static Bundle findBundle(URL bundleURL) {
+ if (bundleContext == null) {
+ return null;
+ }
+ Bundle[] installedBundles = bundleContext.getBundles();
+ for (Bundle bundle : installedBundles) {
+ URL root = bundle.getEntry("/");
+ if (root != null && root.getHost() != null && root.getHost().equals(bundleURL.getHost())) {
+ return bundle;
+ }
+ }
+ return null;
+ }
+
+ public static Bundle findBundle(String symbolicName, String version) {
+ if (bundleContext == null) {
+ return null;
+ }
+ Bundle[] bundles = bundleContext.getBundles();
+ if (version == null) {
+ version = "0.0.0";
+ }
+ for (Bundle b : bundles) {
+ String v = (String)b.getHeaders().get(Constants.BUNDLE_VERSION);
+ if (v == null) {
+ v = "0.0.0";
+ }
+ if (b.getSymbolicName().equals(symbolicName) && (version.equals("0.0.0") || v.equals(version))) {
+ return b;
+ }
+ }
+ return null;
+ }
+
+ public static Bundle installBundle(String location, InputStream is) throws BundleException {
+ getBundleContext();
+ return bundleContext.installBundle(location, is);
+ }
+
+ public static Bundle installBundle(String location) throws BundleException, IOException {
+ getBundleContext();
+
+ URL url = new URL(location);
+ Bundle bundle = null;
+ InputStream is = url.openStream();
+ JarInputStream jar = new JarInputStream(is);
+
+ Manifest manifest = jar.getManifest();
+ jar.close();
+ if (manifest != null) {
+ String symbolicName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+ String version = manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
+ if (symbolicName != null) {
+ bundle = findBundle(symbolicName, version);
+ if (bundle != null) {
+ return bundle;
+ }
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ try {
+ is = url.openStream();
+ bundle = bundleContext.installBundle(location, is);
+ } finally {
+ is.close();
+ }
+ return bundle;
+ }
+
+ public static Bundle findBundleByLocation(String bundleLocation) {
+ if (bundleContext != null) {
+ Bundle[] installedBundles = bundleContext.getBundles();
+ for (Bundle bundle : installedBundles) {
+ if (bundle.getLocation().equals(bundleLocation))
+ return bundle;
+ }
+ }
+ return null;
+ }
+
+ public static Bundle findBundle(String bundleLocation) {
+ if (bundleContext != null) {
+ if (bundleLocation.startsWith("bundle:") || bundleLocation.startsWith("bundleresource:")
+ || bundleLocation.startsWith("bundleentry:")) {
+ try {
+ return findBundle(new URL(bundleLocation));
+ } catch (MalformedURLException e) {
+ // ignore
+ }
+ } else {
+ return findBundleByLocation(bundleLocation);
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java
new file mode 100644
index 0000000000..111f1f370c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.osgi.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.PackageType;
+import org.apache.tuscany.sca.contribution.processor.ContributionException;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.scanner.ContributionScanner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * Bundle Contribution package processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiBundleContributionScanner implements ContributionScanner {
+ private ContributionFactory contributionFactory;
+
+ public OSGiBundleContributionScanner(ContributionFactory contributionFactory) {
+ this.contributionFactory = contributionFactory;
+ }
+
+ public String getContributionType() {
+ return PackageType.BUNDLE;
+ }
+
+ public List<Artifact> scan(Contribution contribution) throws ContributionReadException {
+ Bundle bundle = OSGiBundleActivator.findBundle(contribution.getLocation());
+
+ if (bundle == null) {
+ throw new IllegalArgumentException("Could not find OSGi bundle " + contribution.getLocation());
+ }
+
+ List<Artifact> artifacts = new ArrayList<Artifact>();
+ Set<String> bundleClassPath = new HashSet<String>();
+ String cp = (String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
+ if (cp != null) {
+ String[] paths = cp.split(",");
+ for (String path : paths) {
+ bundleClassPath.add(path.trim());
+ }
+ }
+
+ try {
+ // Test if the bundle is an Eclipse project
+ boolean devMode = (bundle.getEntry("/.project") != null);
+ // FIXME: The entries can come from fragments. Do we need to have a way to differentiate the entries?
+ Enumeration<?> entries = bundle.findEntries("/", "*", true);
+ while (entries.hasMoreElements()) {
+ URL entry = (URL)entries.nextElement();
+ String entryName = entry.getPath();
+ if (devMode && entryName.contains("/.svn/")
+ || entryName.startsWith("/.")
+ || entryName.startsWith("/target/")
+ || entryName.startsWith("/src/")) {
+ // Ignore .svn files
+ // Ignore .classpath, .project, src, and target
+ continue;
+ }
+ if (entryName.startsWith("/")) {
+ entryName = entryName.substring(1);
+ }
+
+ //Add artifact to list
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(entryName);
+ artifact.setLocation(entry.toString());
+
+ artifacts.add(artifact);
+
+ //if Artifact is a JAR, add jar artifacts as well
+ /*
+ if (entryName.endsWith(".jar") && bundleClassPath.contains(entryName)) {
+ List<String> jarArtifactURIs = getJarArtifacts(entry, entry.openStream());
+ for( String uri : jarArtifactURIs) {
+ Artifact jarArtifact = contributionFactory.createArtifact();
+ jarArtifact.setURI(uri);
+ URL url = bundle.getResource(uri);
+ String location = null;
+ if(url!=null) {
+ location = url.toString();
+ }
+ jarArtifact.setLocation(location);
+ artifacts.add(jarArtifact);
+
+ }
+ }
+ */
+
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ contribution.getExtensions().add(bundle);
+ contribution.getTypes().add(getContributionType());
+ contribution.setClassLoader(new BundleClassLoader(bundle));
+ return artifacts;
+ }
+
+ /**
+ * Retrieve a list of Artifact URIs for a given JAR
+ * @param packageSourceURL
+ * @param inputStream
+ * @return
+ * @throws ContributionException
+ * @throws IOException
+ */
+ private List<String> getJarArtifacts(URL packageSourceURL, InputStream inputStream) throws ContributionException, IOException {
+ if (packageSourceURL == null) {
+ throw new IllegalArgumentException("Invalid null package source URL.");
+ }
+
+ if (inputStream == null) {
+ throw new IllegalArgumentException("Invalid null source inputstream.");
+ }
+
+ // Assume the root is a jar file
+ JarInputStream jar = new JarInputStream(inputStream);
+ try {
+ Set<String> names = new HashSet<String>();
+ while (true) {
+ JarEntry entry = jar.getNextJarEntry();
+ if (entry == null) {
+ // EOF
+ break;
+ }
+
+ // FIXME: Maybe we should externalize the filter as a property
+ String name = entry.getName();
+ if (!name.startsWith(".") && !entry.isDirectory()) {
+
+ // Trim trailing /
+ if (name.endsWith("/")) {
+ name = name.substring(0, name.length() - 1);
+ }
+
+ // Add the entry name
+ if (!names.contains(name) && name.length() > 0) {
+ names.add(name);
+
+ }
+ }
+ }
+
+ // Return list of URIs
+ List<String> artifacts = new ArrayList<String>();
+ for (String name : names) {
+ artifacts.add(name);
+ }
+ return artifacts;
+
+ } finally {
+ jar.close();
+ }
+ }
+
+
+
+ private static class BundleClassLoader extends ClassLoader {
+ private Bundle bundle;
+ public BundleClassLoader(Bundle bundle) {
+ super(null);
+ this.bundle = bundle;
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ return bundle.loadClass(name);
+ }
+
+ @Override
+ protected URL findResource(String name) {
+ return bundle.getResource(name);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Enumeration<URL> findResources(String name) throws IOException {
+ Enumeration<URL> urls = bundle.getResources(name);
+ if (urls == null) {
+ List<URL> list = Collections.emptyList();
+ return Collections.enumeration(list);
+ } else {
+ return urls;
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java
new file mode 100644
index 0000000000..0b0d49de3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.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.sca.contribution.osgi.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.osgi.BundleReference;
+import org.osgi.framework.Bundle;
+
+/**
+ * OSGi bundle processor
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiBundleProcessor {
+
+ // private boolean initializedOSGi;
+ // private OSGiRuntime osgiRuntime;
+
+ public OSGiBundleProcessor() {
+ }
+
+ public Object installContributionBundle(Contribution contribution) {
+
+ Object bundle = null;
+ try {
+ bundle = OSGiBundleActivator.installBundle(contribution.getLocation());
+ } catch (Exception e) {
+ // If OSGi cannot process the jar, treat the bundle as a plain jar file.
+ }
+ return bundle;
+ }
+
+ public BundleReference installNestedBundle(Contribution contribution,
+ String bundleSymbolicName,
+ String bundleVersion) {
+
+ BundleReference bundleReference = null;
+
+ List<Artifact> artifacts = contribution.getArtifacts();
+ for (Artifact a : artifacts) {
+ if (a.getURI().endsWith(".jar")) {
+ try {
+ Bundle bundle = OSGiBundleActivator.installBundle(a.getLocation());
+ if (bundle != null) {
+ bundleReference = new BundleReference(bundle);
+ break;
+ }
+ } catch (Exception e) {
+ // If OSGi cannot process the jar, treat the bundle as a plain jar file.
+ }
+ }
+ }
+ return bundleReference;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java
new file mode 100644
index 0000000000..7958eb4b6d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.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.sca.contribution.osgi.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.osgi.BundleReference;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.osgi.framework.Bundle;
+
+/**
+ * A Model Resolver for BundleReferences.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiBundleReferenceModelResolver implements ModelResolver {
+ private Contribution contribution;
+ private Map<BundleReference, BundleReference> refs = new HashMap<BundleReference, BundleReference>();
+
+ private OSGiBundleProcessor bundleProcessor;
+
+ public OSGiBundleReferenceModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ this.bundleProcessor = new OSGiBundleProcessor();
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ BundleReference bundleRef = (BundleReference)resolved;
+ refs.put(bundleRef, bundleRef);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return refs.remove(resolved);
+ }
+
+ /**
+ * Handle artifact resolution when the specific class reference is imported from another contribution
+ * @param unresolved
+ * @param context
+ * @return
+ */
+ private BundleReference resolveImportedModel(BundleReference unresolved, ProcessorContext context) {
+ BundleReference resolved = unresolved;
+
+ if (this.contribution != null) {
+ for (Import import_ : this.contribution.getImports()) {
+
+ resolved = import_.getModelResolver().resolveModel(BundleReference.class, unresolved, context);
+ if (resolved != unresolved)
+ break;
+ }
+
+ }
+ return resolved;
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ Object resolved = refs.get(unresolved);
+
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ if (OSGiBundleActivator.getBundleContext() == null)
+ return unresolved;
+
+ //Load a class on demand
+ Bundle bundle = null;
+ String bundleName = ((BundleReference)unresolved).getSymbolicName();
+ String bundleVersion = ((BundleReference)unresolved).getVersion();
+
+ bundle = OSGiBundleActivator.findBundle(bundleName, bundleVersion);
+ BundleReference bundleReference;
+
+ if (bundle == null) {
+ bundleReference = bundleProcessor.installNestedBundle(contribution, bundleName, bundleVersion);
+ } else {
+ bundleReference = new BundleReference(bundle);
+ }
+
+ if (bundleReference != null) {
+ //if we load the class
+
+ refs.put(((BundleReference)unresolved), bundleReference);
+
+ // Return the resolved BundleReference
+ return modelClass.cast(bundleReference);
+ } else {
+ //delegate resolution of the class
+ resolved = this.resolveImportedModel((BundleReference)unresolved, context);
+ return modelClass.cast(resolved);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java
new file mode 100644
index 0000000000..3963968940
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.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.contribution.osgi.impl;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.osgi.framework.Bundle;
+
+/**
+ * A Model Resolver for ClassReferences.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiClassReferenceModelResolver implements ModelResolver {
+ // private Contribution contribution;
+ private Bundle bundle;
+
+ public OSGiClassReferenceModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ // this.contribution = contribution;
+ this.bundle = OSGiBundleActivator.findBundle(contribution.getLocation());
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return resolved;
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ //Load a class on demand
+ Class<?> clazz = null;
+ if (bundle != null) {
+ try {
+ clazz = bundle.loadClass(((ClassReference)unresolved).getClassName());
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+
+ if (clazz != null) {
+ //if we load the class
+ // Store a new ClassReference wrapping the loaded class
+ ClassReference classReference = new ClassReference(clazz);
+
+ // Return the resolved ClassReference
+ return modelClass.cast(classReference);
+ } else {
+ return unresolved;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..87c2208e40
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -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.
+
+org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleReferenceModelResolver;model=org.apache.tuscany.sca.contribution.osgi.BundleReference
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner
new file mode 100644
index 0000000000..5c26e07e0c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Eclipse Equinox
+org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleContributionScanner;type=bundleentry
+org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleContributionScanner;type=bundleresource
+# Apache Felix
+org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleContributionScanner;type=bundle
diff --git a/sandbox/sebastien/java/embed/modules/contribution/LICENSE b/sandbox/sebastien/java/embed/modules/contribution/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/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/sebastien/java/embed/modules/contribution/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/contribution/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5ba88ca08f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/META-INF/MANIFEST.MF
@@ -0,0 +1,59 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.contribution.scanner;uses:="org
+ .apache.tuscany.sca.contribution.processor,org.apache.tuscany.sca.ext
+ ensibility";version="2.0.0",org.apache.tuscany.sca.contribution.resolve
+ r;uses:="org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.contribution,org.apache.tuscany.sca.extensibil
+ ity";version="2.0.0",org.apache.tuscany.sca.contribution.processor;uses
+ :="org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.core,org.ap
+ ache.tuscany.sca.policy,org.apache.tuscany.sca.monitor,org.apache.tus
+ cany.sca.extensibility,org.xml.sax,javax.xml.namespace,javax.xml.stre
+ am,javax.xml.stream.util,javax.xml.transform,org.apache.tuscany.sca.c
+ ontribution.resolver,javax.xml.transform.stream,javax.xml.validation,
+ org.xml.sax.helpers";version="2.0.0",org.apache.tuscany.sca.contributio
+ n;uses:="org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.contr
+ ibution.resolver";version="2.0.0",org.apache.tuscany.sca.contribution
+ .namespace;uses:="org.apache.tuscany.sca.contribution";version="2.0.0
+ ",org.apache.tuscany.sca.contribution.java;uses:="org.apache.tuscany.
+ sca.contribution";version="2.0.0"
+Private-Package: org.apache.tuscany.sca.contribution.impl;version="1.4
+ "
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Contribution Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Contribution Model
+Import-Package: javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.stream.events,
+ javax.xml.stream.util,
+ javax.xml.transform,
+ javax.xml.transform.sax,
+ javax.xml.transform.stream,
+ javax.xml.validation,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xsd;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.java;version="2.0.0",
+ org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.contribution.scanner;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.w3c.dom,
+ org.w3c.dom.ls,
+ org.xml.sax,
+ org.xml.sax.helpers
+Bundle-SymbolicName: org.apache.tuscany.sca.contribution
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/contribution/NOTICE b/sandbox/sebastien/java/embed/modules/contribution/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/pom.xml b/sandbox/sebastien/java/embed/modules/contribution/pom.xml
new file mode 100644
index 0000000000..809b983c09
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/pom.xml
@@ -0,0 +1,69 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-contribution</artifactId>
+ <name>Apache Tuscany SCA Contribution Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java
new file mode 100644
index 0000000000..238cc8c2fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.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.sca.contribution;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+
+/**
+ * Represents an artifact in an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Artifact extends Base {
+
+ /**
+ * Returns the URI that unique identifies the artifact inside the contribution.
+ *
+ * @return The artifact URI
+ */
+ String getURI();
+
+ /**
+ * Sets the URI that uniquely identifies the artifact inside the contribution.
+ *
+ * @param uri The artifact URI
+ */
+ void setURI(String uri);
+
+ /**
+ * Returns the location of the artifact.
+ *
+ * @return The artifact location
+ */
+ String getLocation();
+
+ /**
+ * Set the location of the artifact.
+ *
+ * @param location The artifact location
+ */
+ void setLocation(String location);
+
+
+ /**
+ * Returns the in-memory model representing the artifact.
+ *
+ * @return The model object
+ */
+ <T> T getModel();
+
+ /**
+ * Sets the in-memory model representing the artifact.
+ *
+ * @param model The model object
+ */
+ void setModel(Object model);
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java
new file mode 100644
index 0000000000..81b0b08b9d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.contribution;
+
+/**
+ * Constants for the main supported contribution package type.
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public interface ContentType {
+
+ /**
+ * Java compressed contribution package
+ */
+ String JAR = "application/x-compressed";
+
+ /**
+ * Filesystem folder contribution package
+ */
+ String FOLDER = "application/vnd.tuscany.folder";
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java
new file mode 100644
index 0000000000..777ba1f986
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The representation of an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Contribution extends Artifact, Extensible {
+
+ /**
+ * Default location of contribution metadata in an SCA contribution.
+ */
+ String SCA_CONTRIBUTION_META = "META-INF/sca-contribution.xml";
+
+ /**
+ * Default location of a generated contribution metadata in an SCA contribution.
+ */
+ String SCA_CONTRIBUTION_GENERATED_META = "META-INF/sca-contribution-generated.xml";
+
+ /**
+ * Returns a list of exports based on the contribution metadata.
+ *
+ * @return The list of exports in this contribution
+ */
+ List<Export> getExports();
+
+ /**
+ * Returns a list of imports based on the contribution metadata.
+ *
+ * @return The list of imports in this contribution
+ */
+ List<Import> getImports();
+
+ /**
+ * Returns the list of deployable composites in the contribution.
+ *
+ * @return The list of deployable composites
+ */
+ List<Composite> getDeployables();
+
+ /**
+ * Returns the list of artifacts in the contribution.
+ *
+ * @return The list of artifacts in the contribution
+ */
+ List<Artifact> getArtifacts();
+
+ /**
+ * Returns the model resolver for the models representing the artifacts
+ * visible in the scope of this contribution.
+ *
+ * @return The model resolver
+ */
+ ModelResolver getModelResolver();
+
+ /**
+ * Sets the model resolver for the models representing the artifacts
+ * visible in the scope of this contribution.
+ *
+ * @param modelResolver The model resolver
+ */
+ void setModelResolver(ModelResolver modelResolver);
+
+ /**
+ * Returns the list of contributions that this contribution depends on.
+ *
+ * @return
+ */
+ List<Contribution> getDependencies();
+
+ /**
+ * Returns the ClassLoader used to load classes and resources from
+ * this contribution
+ *
+ * FIXME Remove this, the base contribution model should not depend
+ * on Java ClassLoaders.
+ *
+ * @return The contribution ClassLoader
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ * Sets the ClassLoader used to load classes and resources from
+ * this contribution
+ *
+ * FIXME Remove this, the base contribution model should not depend
+ * on Java ClassLoaders.
+ *
+ * @param classLoader the contribution class loader
+ */
+ void setClassLoader(ClassLoader classLoader);
+
+ /**
+ * Get a list of mime types that apply to this contribution archive
+ * @return
+ */
+ Set<String> getTypes();
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java
new file mode 100644
index 0000000000..5937d535d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution;
+
+
+/**
+ * A factory for the contribution model.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ContributionFactory {
+
+ /**
+ * Create a contribution model object
+ *
+ * @return The new contribution model object
+ */
+ Contribution createContribution();
+
+ /**
+ * Create a contribution metadata model object
+ *
+ * @return The new contribution metadata model object
+ */
+ ContributionMetadata createContributionMetadata();
+
+ /**
+ * Create an artifact model object
+ *
+ * @return The new artifact model object
+ */
+ Artifact createArtifact();
+
+ /**
+ * Create a default import model object.
+ *
+ * @return the new default import model object
+ */
+ DefaultImport createDefaultImport();
+
+ /**
+ * Create a default export model object.
+ *
+ * @return the new default export model object
+ */
+ DefaultExport createDefaultExport();
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java
new file mode 100644
index 0000000000..a62d7155c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.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.contribution;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Extensible;
+
+/**
+ * The representation of SCA contribution metadata.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContributionMetadata extends Base, Extensible {
+
+ /**
+ * Returns the spec version of the contribution metadata used to build this model
+ *
+ * @return the spec version used to build this model
+ */
+ String getSpecVersion();
+
+ /**
+ * Sets the spec version of the contribution metadata used to build this model
+ *
+ * @param specVersion the spec version used to build this model
+ */
+ void setSpecVersion(String specVersion);
+
+ /**
+ * Returns a list of exports based on the contribution metadata.
+ *
+ * @return The list of exports
+ */
+ List<Export> getExports();
+
+ /**
+ * Returns a list of imports based on the contribution metadata.
+ *
+ * @return The list of imports
+ */
+ List<Import> getImports();
+
+ /**
+ * Returns the list of deployable based on the contribution metadata.
+ *
+ * @return The list of deployable composites
+ */
+ List<Composite> getDeployables();
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java
new file mode 100644
index 0000000000..98954c288a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.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.contribution;
+
+import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl;
+
+
+/**
+ * Default implementation of a contribution model factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultContributionFactory extends ContributionFactoryImpl {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java
new file mode 100644
index 0000000000..b2eddb8336
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.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.contribution;
+
+
+/**
+ * The representation of an export that exports all artifacts in
+ * a contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DefaultExport extends Export {
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java
new file mode 100644
index 0000000000..4b3d157554
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.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.sca.contribution;
+
+
+/**
+ * The representation of a default import that imports artifacts from
+ * all contributions.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface DefaultImport extends Import {
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java
new file mode 100644
index 0000000000..a6e5afe7b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.contribution;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The representation of an export.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Export extends Extensible {
+
+ /**
+ * Returns the model resolver for the models representing artifacts
+ * made available by this export.
+ *
+ * @return The model resolver
+ */
+ ModelResolver getModelResolver();
+
+ /**
+ * Sets the model resolver for the models representing artifacts
+ * made available by this export.
+ *
+ * @param modelResolver
+ */
+ void setModelResolver(ModelResolver modelResolver);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java
new file mode 100644
index 0000000000..450476b79b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+
+/**
+ * The representation of an import.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Import extends Extensible {
+
+ /**
+ * Returns the model resolver for the models representing artifacts
+ * made available by this import.
+ *
+ * @return The model resolver
+ */
+ ModelResolver getModelResolver();
+
+ /**
+ * Sets the model resolver for the models representing artifacts
+ * made available by this import.
+ *
+ * @param modelResolver The model resolver
+ */
+ void setModelResolver(ModelResolver modelResolver);
+
+ /**
+ * Verify that a specific export actually exports what is being imported.
+ *
+ * @param export The Exported being verified
+ * @return true/false
+ */
+ boolean match(Export export);
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java
new file mode 100644
index 0000000000..c6c0aff737
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.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.contribution;
+
+/**
+ * Constants for the main supported contribution package types.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PackageType {
+
+ /**
+ * Java compressed contribution package
+ */
+ String JAR = "application/java-archive";
+
+ /**
+ * Zip archive contribution package
+ */
+ String ZIP = "application/zip";
+
+ /**
+ * Filesystem folder contribution package
+ */
+ String FOLDER = "application/vnd.tuscany.folder";
+
+
+ String BUNDLE = "application/osgi.bundle";
+
+ /**
+ * Java EE Web Application Archive
+ */
+ String WAR = "application/war";
+
+ /**
+ * Java EE Enterprise Application Archive
+ */
+ String EAR = "application/ear";
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java
new file mode 100644
index 0000000000..a362e97fc6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.contribution.impl;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+
+
+/**
+ * The model representing an artifact in a contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+class ArtifactImpl implements Artifact {
+ private String uri;
+ private String location;
+ private Object model;
+ private boolean unresolved;
+
+ ArtifactImpl() {
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public <T> T getModel() {
+ return (T) model;
+ }
+
+ public void setModel(Object model) {
+ this.model = model;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ @Override
+ public int hashCode() {
+ return uri.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else {
+ if (obj instanceof Artifact) {
+ return uri.equals(((Artifact)obj).getURI());
+ } else {
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Artifact:" + uri + "\n" +
+ "at: " + location;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java
new file mode 100644
index 0000000000..64bfb20bed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.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.contribution.impl;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.DefaultExport;
+import org.apache.tuscany.sca.contribution.DefaultImport;
+
+
+/**
+ * Default implementation of a contribution model factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionFactoryImpl implements ContributionFactory {
+
+ protected ContributionFactoryImpl() {
+ }
+
+ public Contribution createContribution() {
+ return new ContributionImpl();
+ }
+
+ public ContributionMetadata createContributionMetadata() {
+ return new ContributionMetadataImpl();
+ }
+
+ public Artifact createArtifact() {
+ return new ArtifactImpl();
+ }
+
+ public DefaultExport createDefaultExport() {
+ return new DefaultExportImpl();
+ }
+
+ public DefaultImport createDefaultImport() {
+ return new DefaultImportImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java
new file mode 100644
index 0000000000..c31763151d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The representation of a deployed contribution
+ *
+ * @version $Rev$ $Date$
+ */
+class ContributionImpl extends ExtensibleImpl implements Contribution {
+ private String uri;
+ private String location;
+ private Object model;
+ private byte[] contents;
+ private List<Export> exports = new ArrayList<Export>();
+ private List<Import> imports = new ArrayList<Import>();
+ private List<Composite> deployables = new ArrayList<Composite>();
+ private List<Artifact> artifacts = new ArrayList<Artifact>();
+ private List<Contribution> dependencies = new ArrayList<Contribution>();
+ private ModelResolver modelResolver;
+ private Set<String> types = new HashSet<String>();
+
+ // FIXME remove this dependency on Java ClassLoaders
+ private ClassLoader classLoader;
+
+ ContributionImpl() {
+ }
+
+ public String getLocation() {
+ return this.location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ //FIXME Remove dependency on Java ClassLoaders
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ //FIXME Remove dependency on Java ClassLoaders
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+
+ public String getURI() {
+ return this.uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public <T> T getModel() {
+ return (T) model;
+ }
+
+ public void setModel(Object model) {
+ this.model = model;
+ }
+
+ public byte[] getContents() {
+ return contents;
+ }
+
+ public void setContents(byte[] contents) {
+ this.contents = contents;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+ public List<Contribution> getDependencies() {
+ return dependencies;
+ }
+
+ public List<Export> getExports() {
+ return exports;
+ }
+
+ public List<Import> getImports() {
+ return imports;
+ }
+
+ public List<Composite> getDeployables() {
+ return deployables;
+ }
+
+ public List<Artifact> getArtifacts() {
+ return artifacts;
+ }
+
+ @Override
+ public int hashCode() {
+ return uri.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else {
+ if (obj instanceof Artifact) {
+ return uri.equals(((Artifact)obj).getURI());
+ } else {
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Contribution : " + uri + " \n" +
+ "from: " + location;
+ }
+
+ public Set<String> getTypes() {
+ return types;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java
new file mode 100644
index 0000000000..e2397c6f26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.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.sca.contribution.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+
+/**
+ * The representation of a deployed contribution
+ *
+ * @version $Rev$ $Date$
+ */
+class ContributionMetadataImpl extends ExtensibleImpl implements ContributionMetadata {
+
+ private String specVersion = "undefined";
+ private List<Export> exports = new ArrayList<Export>();
+ private List<Import> imports = new ArrayList<Import>();
+ private List<Composite> deployables = new ArrayList<Composite>();
+ private boolean unresolved;
+
+ ContributionMetadataImpl() {
+ }
+
+ public String getSpecVersion() {
+ return specVersion;
+ }
+
+ public void setSpecVersion(String specVersion) {
+ this.specVersion = specVersion;
+ }
+
+ public List<Export> getExports() {
+ return exports;
+ }
+
+ public List<Import> getImports() {
+ return imports;
+ }
+
+ public List<Composite> getDeployables() {
+ return deployables;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java
new file mode 100644
index 0000000000..d4614e5427
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.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.sca.contribution.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
+import org.apache.tuscany.sca.contribution.DefaultExport;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The representation of an export for the contribution
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultExportImpl extends ExtensibleImpl implements DefaultExport {
+ private ModelResolver modelResolver;
+
+ protected DefaultExportImpl() {
+ super();
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java
new file mode 100644
index 0000000000..7ab535f916
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.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 org.apache.tuscany.sca.contribution.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
+import org.apache.tuscany.sca.contribution.DefaultExport;
+import org.apache.tuscany.sca.contribution.DefaultImport;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The representation of an import for the contribution
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultImportImpl extends ExtensibleImpl implements DefaultImport {
+ private ModelResolver modelResolver;
+
+ protected DefaultImportImpl() {
+ super();
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+
+ public boolean match(Export export) {
+ if (export instanceof DefaultExport) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultJavaImportExportFactory.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultJavaImportExportFactory.java
new file mode 100644
index 0000000000..886c61c00a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultJavaImportExportFactory.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.contribution.java;
+
+import org.apache.tuscany.sca.contribution.java.impl.JavaImportExportFactoryImpl;
+
+/**
+ * Default Java Import/Export Factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultJavaImportExportFactory extends JavaImportExportFactoryImpl implements JavaImportExportFactory {
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaExport.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaExport.java
new file mode 100644
index 0000000000..41e93ec148
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaExport.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.contribution.java;
+
+import org.apache.tuscany.sca.contribution.Export;
+
+/**
+ * Base Java Export model interface
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaExport extends Export {
+ /**
+ * Get java package that identifies the import
+ *
+ * @return The package name
+ */
+ String getPackage();
+
+ /**
+ * Set java package that identifies the import
+ *
+ * @param packageName The package name
+ */
+ void setPackage(String packageName);
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImport.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImport.java
new file mode 100644
index 0000000000..d3568f6283
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImport.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java;
+
+import org.apache.tuscany.sca.contribution.Import;
+
+/**
+ * Base Java Import model interface
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaImport extends Import {
+
+ /**
+ * Get the location used to resolve the definitions for this import
+ *
+ * @return The import location
+ */
+ String getLocation();
+
+ /**
+ * Set the location used to resolve the definitions for this import
+ *
+ * @param location The import location
+ */
+ void setLocation(String location);
+
+ /**
+ * Get java package that identifies the import
+ *
+ * @return The package name
+ */
+ String getPackage();
+
+ /**
+ * Set java package that identifies the import
+ *
+ * @param packageName The package name
+ */
+ void setPackage(String packageName);
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImportExportFactory.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImportExportFactory.java
new file mode 100644
index 0000000000..ee94d889ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImportExportFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java;
+
+/**
+ * Base Java Import/Export model factory
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaImportExportFactory {
+
+ /**
+ * Create a java import model object
+ *
+ * @return The new JavaImport model object
+ */
+ JavaImport createJavaImport();
+
+ /**
+ * Create a java export model object
+ *
+ * @return The new JavaExport model object
+ */
+ JavaExport createJavaExport();
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
new file mode 100644
index 0000000000..1ba394dde9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.DefaultDelegatingModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+
+/**
+ * A Model Resolver for ClassReferences.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClassLoaderModelResolver extends URLClassLoader implements ModelResolver {
+ private WeakReference<Contribution> contribution;
+ private ProcessorContext context;
+ private Map<String, ModelResolver> importResolvers = new HashMap<String, ModelResolver>();
+
+ // a space to pass back the contribution that was used to resolve
+ // a class via an import
+ private Contribution contributionContainingClass;
+
+ private static ClassLoader parentClassLoader(Contribution contribution) {
+ if (contribution.getClassLoader() != null) {
+ return contribution.getClassLoader();
+ }
+ ClassLoader parentClassLoader = ServiceDiscovery.getInstance().getContextClassLoader();
+ return parentClassLoader;
+ }
+
+ private static URL[] getContributionURLs(final Contribution contribution) throws IOException {
+ if (contribution.getClassLoader() != null) {
+ // Do not include the contribution url
+ return new URL[0];
+ }
+ List<URL> urls = new ArrayList<URL>();
+ urls.add(new URL(contribution.getLocation()));
+ urls.addAll(ContributionHelper.getNestedJarUrls(contribution));
+ return urls.toArray(new URL[urls.size()]);
+ }
+
+ public ClassLoaderModelResolver(final Contribution contribution, FactoryExtensionPoint modelFactories) throws IOException {
+ super(getContributionURLs(contribution), parentClassLoader(contribution));
+ this.contribution = new WeakReference<Contribution>(contribution);
+ // Index Java import resolvers by package name
+ Map<String, List<ModelResolver>> resolverMap = new HashMap<String, List<ModelResolver>>();
+ for (Import import_: this.contribution.get().getImports()) {
+ if (import_ instanceof JavaImport) {
+ JavaImport javaImport = (JavaImport)import_;
+ List<ModelResolver> resolvers = resolverMap.get(javaImport.getPackage());
+ if (resolvers == null) {
+ resolvers = new ArrayList<ModelResolver>();
+ resolverMap.put(javaImport.getPackage(), resolvers);
+ }
+ resolvers.add(javaImport.getModelResolver());
+ }
+ }
+
+ // Create a delegating model resolver for each imported package
+ for (Map.Entry<String, List<ModelResolver>> entry: resolverMap.entrySet()) {
+ importResolvers.put(entry.getKey(), new DefaultDelegatingModelResolver(entry.getValue()));
+ }
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ if (!(unresolved instanceof ClassReference)) {
+ return unresolved;
+ }
+
+ try {
+ this.context = context;
+ contributionContainingClass = contribution.get();
+
+ // Load the class and return a class reference for it
+ String className = ((ClassReference)unresolved).getClassName();
+ Class<?> clazz = Class.forName(className, false, this);
+ ClassReference classReference = new ClassReference(clazz);
+ classReference.setContributionContainingClass(contributionContainingClass);
+ contributionContainingClass = null;
+ return modelClass.cast(classReference);
+
+ } catch (ClassNotFoundException e) {
+ return unresolved;
+ }
+ }
+
+ @Override
+ public URL findResource(String name) {
+
+ //TODO delegate to the Java import resolvers
+
+ URL url = super.findResource(name);
+ return url;
+ }
+
+ @Override
+ public Enumeration<URL> findResources(String name) throws IOException {
+
+ //TODO delegate to the Java import resolvers
+ //Enumeration<URL> importedResources;
+
+ Enumeration<URL> resources = super.findResources(name);
+ List<URL> allResources = new ArrayList<URL>();
+ //for (; importedResources.hasMoreElements(); ) {
+ // allResources.add(importedResources.nextElement());
+ //}
+ for (; resources.hasMoreElements(); ) {
+ allResources.add(resources.nextElement());
+ }
+ return Collections.enumeration(allResources);
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+
+ // Extract the package name
+ int d = name.lastIndexOf('.');
+ String packageName;
+ if (d != -1) {
+ packageName = name.substring(0, d);
+ } else {
+ packageName = null;
+ }
+
+ // First try to load the class using the Java import resolvers
+ ModelResolver importResolver = importResolvers.get(packageName);
+ if (importResolver != null) {
+ ClassReference classReference = importResolver.resolveModel(ClassReference.class, new ClassReference(name), context);
+ if (!classReference.isUnresolved()) {
+ contributionContainingClass = classReference.getContributionContainingClass();
+ return classReference.getJavaClass();
+ }
+ }
+
+ // Next, try to load the class from the current contribution
+ Class<?> clazz = super.findClass(name);
+ return clazz;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoader.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoader.java
new file mode 100644
index 0000000000..25b3eae350
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoader.java
@@ -0,0 +1,386 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+
+
+public class ContributionClassLoader extends URLClassLoader {
+// public class ContributionClassLoader {
+
+ private Contribution contribution;
+ // private b urlClassLoader;
+
+ /**
+ * Constructor for contribution ClassLoader
+ *
+ * @param contribution
+ * @param parent
+ * @throws MalformedURLException
+ */
+ public ContributionClassLoader(Contribution contribution, final ClassLoader parent) {
+ super(new URL[0], parent);
+ // Note that privileged use of getContextClassLoader have been promoted to callers.
+ // super(new URL[0], parent == null?Thread.currentThread().getContextClassLoader(): null);
+ this.contribution = contribution;
+ if (contribution.getLocation() != null) {
+ try {
+ this.addURL(new URL(contribution.getLocation()));
+ for (URL url : ContributionHelper.getNestedJarUrls(contribution)) {
+ this.addURL(url);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /*
+ * Return the ClassLoader corresponding to a contribution providing an export
+ * Create a new ClassLoader for the contribution if one does not exist
+ */
+ private ClassLoader getExportClassLoader(Contribution exportingContribution) {
+ ClassLoader cl = exportingContribution.getClassLoader();
+ if (!(cl instanceof ContributionClassLoader)) {
+ if (cl == null) {
+ cl = getParent();
+ }
+
+ cl = new ContributionClassLoader(exportingContribution, cl);
+ exportingContribution.setClassLoader(cl);
+ }
+ return cl;
+ }
+
+ /* (non-Javadoc)
+ * @see java.net.URLClassLoader#findClass(java.lang.String)
+ *
+ * Search path for class:
+ * This contribution
+ * Imported contributions
+ */
+ @Override
+ protected Class<?> findClass(String className) throws ClassNotFoundException {
+
+ Class<?> clazz = null;
+ try {
+ clazz = findClassFromContribution(className);
+ } catch (ClassNotFoundException e) {
+
+ for (Import import_ : this.contribution.getImports()) {
+ if (classNameMatchesImport(className, import_)) {
+ // Delegate the resolution to the imported contribution
+ for (Contribution exportingContribution : ((JavaImportModelResolver)import_.getModelResolver()).getExportContributions()) {
+
+ ClassLoader exportClassLoader = getExportClassLoader(exportingContribution);
+ if (exportClassLoader instanceof ContributionClassLoader) {
+
+ for (Export export : exportingContribution.getExports()) {
+ try {
+ if (import_.match(export)) {
+ clazz = ((ContributionClassLoader)exportClassLoader).findClassFromContribution(className);
+ break;
+ }
+ } catch (ClassNotFoundException e1) {
+ continue;
+ }
+
+ }
+ if (clazz != null) break;
+ }
+ }
+ if (clazz != null) break;
+ }
+ }
+
+ if (clazz == null) throw e;
+ }
+ return clazz;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
+ *
+ * Search path for class:
+ * Parent ClassLoader
+ * This contribution
+ * Imported contributions
+ *
+ */
+ @Override
+ protected synchronized Class<?> loadClass(String className, boolean resolveClass)
+ throws ClassNotFoundException {
+
+ Class<?> clazz = null;
+ try {
+
+ if (this.getParent() != null)
+ clazz = this.getParent().loadClass(className);
+
+ } catch (ClassNotFoundException e) {
+ }
+
+ if (clazz == null)
+ clazz = findClass(className);
+
+
+ if (resolveClass)
+ this.resolveClass(clazz);
+ return clazz;
+
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.net.URLClassLoader#findResource(java.lang.String)
+ */
+ @Override
+ public URL findResource(String name) {
+
+ URL url = findResourceFromContribution(name);
+
+ if (url == null) {
+ for (Import import_ : this.contribution.getImports()) {
+ if (resourceNameMatchesImport(name, import_)) {
+ // Delegate the resolution to the imported contribution
+ for (Contribution exportingContribution : ((JavaImportModelResolver)import_.getModelResolver()).getExportContributions()) {
+
+ ClassLoader exportClassLoader = getExportClassLoader(exportingContribution);
+ if (exportClassLoader instanceof ContributionClassLoader) {
+
+ for (Export export : exportingContribution.getExports()) {
+ if (import_.match(export)) {
+ url = ((ContributionClassLoader)exportClassLoader).findResourceFromContribution(name);
+ if (url != null) break;
+ }
+ }
+ if (url != null) break;
+ }
+ }
+ if (url != null) break;
+ }
+ }
+
+ }
+ return url;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.net.URLClassLoader#findResources(java.lang.String)
+ */
+ @Override
+ public Enumeration<URL> findResources(String name) throws IOException {
+
+ return Collections.enumeration(findResourceSet(name));
+ }
+
+
+
+
+ /* (non-Javadoc)
+ * @see java.lang.ClassLoader#getResource(java.lang.String)
+ *
+ * Find a resource.
+ * Search path for resource:
+ * Parent ClassLoader
+ * This contribution
+ * Imported contributions
+ */
+ @Override
+ public URL getResource(String resName) {
+
+ URL resource = null;
+
+ if (this.getParent() != null) {
+ resource = this.getParent().getResource(resName);
+ }
+ if (resource == null)
+ resource = findResource(resName);
+
+ return resource;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see java.lang.ClassLoader#getResources(java.lang.String)
+ *
+ * Return list of resources from this contribution, resources
+ * imported through imported contributions and resources from parent
+ * ClassLoader.
+ */
+ @Override
+ public Enumeration<URL> getResources(String resName) throws IOException {
+
+ HashSet<URL> resourceSet = findResourceSet(resName);
+ addEnumerationToCollection(resourceSet, super.getResources(resName));
+
+ return Collections.enumeration(resourceSet);
+ }
+
+
+ /*
+ * Find set of resources
+ */
+ private HashSet<URL> findResourceSet(String name) throws IOException {
+
+ HashSet<URL> resources = new HashSet<URL>();
+
+ addEnumerationToCollection(resources, super.findResources(name));
+
+ for (Import import_ : this.contribution.getImports()) {
+ if (!(import_ instanceof JavaImport)) {
+ continue;
+ }
+ if (resourceNameMatchesImport(name, import_)) {
+ // Delegate the resolution to the imported contribution
+ for (Contribution exportingContribution : ((JavaImportModelResolver)import_.getModelResolver()).getExportContributions()) {
+
+ ClassLoader exportClassLoader = getExportClassLoader(exportingContribution);
+ if (exportClassLoader instanceof ContributionClassLoader) {
+
+ for (Export export : exportingContribution.getExports()) {
+ if (import_.match(export)) {
+ addEnumerationToCollection(resources,
+ ((ContributionClassLoader)exportClassLoader).findResources(name));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return resources;
+ }
+
+
+ /*
+ * Find class from contribution. If class has already been loaded, return loaded class.
+ */
+ private Class<?> findClassFromContribution(String className) throws ClassNotFoundException {
+
+ Class<?> clazz = findLoadedClass(className);
+ if (clazz == null)
+ clazz = super.findClass(className);
+ return clazz;
+
+ }
+
+ /*
+ * Find resource from contribution.
+ */
+ private URL findResourceFromContribution(String name) {
+
+ return super.findResource(name);
+ }
+
+ /**
+ * Check if a class name matches an import statement.
+ * Class matches if the package name used in <import.java/> matches
+ *
+ * @param name Name of class
+ * @param import_ SCA contribution import
+ * @return true if this is a matching import
+ */
+ private boolean classNameMatchesImport(String name, Import import_) {
+
+ if (import_ instanceof JavaImport && name != null && name.lastIndexOf('.') > 0) {
+ JavaImport javaImport = (JavaImport) import_;
+
+ String packageName = name.substring(0, name.lastIndexOf('.'));
+ if (javaImport.getPackage().endsWith(".*")) {
+ String prefix = javaImport.getPackage().substring(0, javaImport.getPackage().length() -1);
+ if (packageName.startsWith(prefix)) {
+ return true;
+ }
+ } else {
+ return packageName.equals(javaImport.getPackage());
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Check if a resource name matches an import statement.
+ * Resource matches if package/namespace match the directory of resource.
+ *
+ * @param name Name of resource
+ * @param import_ SCA contribution import
+ * @return true if this is a matching import
+ */
+ private boolean resourceNameMatchesImport(String name, Import import_) {
+
+
+ if (name == null || name.lastIndexOf('/') <= 0)
+ return false;
+ else if (import_ instanceof JavaImport) {
+ JavaImport javaImport = (JavaImport) import_;
+
+ if (javaImport.getPackage().endsWith(".*")) {
+ String packageName = name.substring(0, name.lastIndexOf('/')).replace('/', '.');
+ String prefix = javaImport.getPackage().substring(0, javaImport.getPackage().length() -1);
+ if (packageName.startsWith(prefix)) {
+ return true;
+ }
+ } else {
+ // 'name' is a resource : contains "/" as separators
+ // Get package name from resource name
+ String packageName = name.substring(0, name.lastIndexOf('/'));
+ return packageName.equals(javaImport.getPackage().replaceAll("\\.", "/"));
+ }
+ }
+ return false;
+ }
+
+ /*
+ * Add an enumeration to a Collection
+ */
+ private <T extends Object> void addEnumerationToCollection(Collection<T> collection, Enumeration<T> enumeration) {
+
+ while (enumeration.hasMoreElements())
+ collection.add(enumeration.nextElement());
+ }
+
+
+ @Override
+ public String toString() {
+ return "SCA Contribution ClassLoader location: " + contribution.getLocation() + " parent ClassLoader: " + getParent();
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java
new file mode 100644
index 0000000000..be175d000e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+
+public class ContributionHelper {
+
+ public static List<URL> getNestedJarUrls(final Contribution contribution) throws IOException {
+ List<URL> urls = new ArrayList<URL>();
+ boolean isZipContribution = contribution.getLocation().endsWith(".zip");
+ URI uri = URI.create(contribution.getLocation());
+ boolean isFolderContribution = !isZipContribution && uri.getScheme().equals("file") && new File(uri.getSchemeSpecificPart()).isDirectory();
+ if (isZipContribution || isFolderContribution) {
+ for (Artifact a : contribution.getArtifacts()) {
+ if (a.getLocation().endsWith(".jar")) {
+ if (isZipContribution) {
+ urls.add(createTempJar(a, contribution));
+ } else {
+ urls.add(new URL(a.getLocation()));
+ }
+ }
+ }
+ }
+ return urls;
+ }
+
+ /**
+ * URLClassLoader doesn't seem to work with URLs to jars within an archive so as a work around
+ * copy the jar to a temp file and use the url to that.
+ */
+ private static URL createTempJar(Artifact artifact, Contribution contribution) throws IOException {
+ FileOutputStream fileOutputStream = null;
+ ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(new File(URI.create(contribution.getLocation()))));
+ try {
+ ZipEntry zipEntry = zipInputStream.getNextEntry();
+ while (zipEntry != null) {
+ if (artifact.getLocation().endsWith(zipEntry.getName())) {
+
+ String tempName = ("tmp." + artifact.getURI().substring(0, artifact.getURI().length() - 3)).replace('/', '.');
+ File tempFile = File.createTempFile(tempName, ".jar");
+ tempFile.deleteOnExit();
+ fileOutputStream = new FileOutputStream(tempFile);
+
+ byte[] buf = new byte[2048];
+ int n;
+ while ((n = zipInputStream.read(buf, 0, buf.length)) > -1) {
+ fileOutputStream.write(buf, 0, n);
+ }
+
+ fileOutputStream.close();
+ zipInputStream.closeEntry();
+
+ return tempFile.toURI().toURL();
+
+ }
+ zipEntry = zipInputStream.getNextEntry();
+ }
+ } finally {
+ zipInputStream.close();
+ if (fileOutputStream != null) {
+ fileOutputStream.close();
+ }
+ }
+
+ throw new IllegalStateException();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java
new file mode 100644
index 0000000000..c0bd9465e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * Implementation of a Java Import model
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaExportImpl extends ExtensibleImpl implements JavaExport {
+ private ModelResolver modelResolver;
+
+ /**
+ * Java package being exported
+ */
+ private String packageName;
+
+ public JavaExportImpl() {
+ super();
+ }
+
+ public String getPackage() {
+ return this.packageName;
+ }
+
+ public void setPackage(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportModelResolver.java
new file mode 100644
index 0000000000..9b02ce4abb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportModelResolver.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.contribution.java.impl;
+
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A model resolver for Java exports.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaExportModelResolver implements ModelResolver {
+
+ private JavaExport export;
+ private ModelResolver resolver;
+
+ public JavaExportModelResolver(JavaExport export, ModelResolver resolver) {
+ this.export = export;
+ this.resolver = resolver;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ if (!(unresolved instanceof ClassReference)) {
+ return unresolved;
+ }
+
+ // Filter package name
+ ClassReference classReference = (ClassReference)unresolved;
+ String className = classReference.getClassName();
+ int d = className.lastIndexOf('.');
+ String packageName;
+ if (d != -1) {
+ packageName = className.substring(0, d);
+ } else {
+ packageName = "";
+ }
+ if (export.getPackage().equals(packageName)) {
+
+ // Package matches the exported package, delegate to the
+ // contribution's resolver
+ return resolver.resolveModel(modelClass, unresolved, context);
+ } else {
+
+ // Package is not exported, return the unresolved object
+ return unresolved;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java
new file mode 100644
index 0000000000..bfa89d02fe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.java.JavaImportExportFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Artifact processor for Java Export
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaExportProcessor implements StAXArtifactProcessor<JavaExport> {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private static final QName EXPORT_JAVA = new QName(SCA11_NS, "export.java");
+
+ private static final String PACKAGE = "package";
+
+ private final JavaImportExportFactory factory;
+
+ public JavaExportProcessor(FactoryExtensionPoint modelFactories) {
+ super();
+ this.factory = modelFactories.getFactory(JavaImportExportFactory.class);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-java-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return EXPORT_JAVA;
+ }
+
+ public Class<JavaExport> getModelType() {
+ return JavaExport.class;
+ }
+
+ /**
+ * Process <export package=""/>
+ */
+ public JavaExport read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ JavaExport javaExport = this.factory.createJavaExport();
+ QName element = null;
+
+ try {
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ element = reader.getName();
+
+ // Read <export.java>
+ if (EXPORT_JAVA.equals(element)) {
+ String packageName = reader.getAttributeValue(null, PACKAGE);
+ if (packageName == null) {
+ error(context.getMonitor(), "AttributePackageMissing", reader);
+ //throw new ContributionReadException("Attribute 'package' is missing");
+ } else
+ javaExport.setPackage(packageName);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (EXPORT_JAVA.equals(reader.getName())) {
+ return javaExport;
+ }
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "XMLStreamException", reader, ex);
+ }
+
+ return javaExport;
+ }
+
+ public void write(JavaExport javaExport, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <export.java>
+ writer.writeStartElement(EXPORT_JAVA.getNamespaceURI(), EXPORT_JAVA.getLocalPart());
+
+ if (javaExport.getPackage() != null) {
+ writer.writeAttribute(PACKAGE, javaExport.getPackage());
+ }
+
+ writer.writeEndElement();
+ }
+
+ public void resolve(JavaExport javaExport, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (javaExport.getPackage() != null)
+ // Initialize the export resolver
+ javaExport.setModelResolver(new JavaExportModelResolver(javaExport, resolver));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportExportFactoryImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportExportFactoryImpl.java
new file mode 100644
index 0000000000..3bf9e54774
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportExportFactoryImpl.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.contribution.java.impl;
+
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.java.JavaImportExportFactory;
+
+/**
+ * Java Import/Export Factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaImportExportFactoryImpl implements JavaImportExportFactory {
+
+ public JavaImport createJavaImport() {
+ return new JavaImportImpl();
+ }
+
+ public JavaExport createJavaExport() {
+ return new JavaExportImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java
new file mode 100644
index 0000000000..f2fdb3278e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * Implementation of a Java Import model
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaImportImpl extends ExtensibleImpl implements JavaImport {
+ private ModelResolver modelResolver;
+ private List<Contribution> contributions;
+ /**
+ * Java package name being imported
+ */
+ private String packageName;
+ /**
+ * Contribution URI where the artifact is imported from
+ */
+ private String location;
+
+ public JavaImportImpl() {
+ super();
+ }
+
+ public String getLocation() {
+ return this.location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String getPackage() {
+ return this.packageName;
+ }
+
+ public void setPackage(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public ModelResolver getModelResolver() {
+ return this.modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+ public List<Contribution> getExportContributions() {
+ return contributions;
+ }
+
+ public void setExportContributions(List<Contribution> contributions) {
+ this.contributions = contributions;
+ }
+
+ /**
+ * Match a JavaImport to a given JavaExport based on :
+ * location is not provided
+ * import and export packages match
+ */
+ public boolean match(Export export) {
+ if(export instanceof JavaExport) {
+ JavaExport javaExport = (JavaExport)export;
+ String exportedPackage = javaExport.getPackage();
+ if (packageName.equals(exportedPackage)) {
+ return true;
+ } else {
+ if (packageName.endsWith(".*")) {
+ String prefix = packageName.substring(0, packageName.length() - 1);
+ if (exportedPackage.startsWith(prefix)) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(packageName);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportModelResolver.java
new file mode 100644
index 0000000000..344e730bdc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportModelResolver.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.sca.contribution.java.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A JavaImport specific model resolver. This model resolver is temporary
+ * and provides the ContributionClassLoader with the list of exporting
+ * contributions that it currently needs.
+ *
+ * FIXME Remove this class after the ContributionClassLoader is simplified
+ * and cleaned up.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaImportModelResolver implements ModelResolver {
+
+ private ModelResolver modelResolver;
+ private List<Contribution> contributions;
+
+ public JavaImportModelResolver(List<Contribution> contributions, ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ this.contributions = contributions;
+ }
+
+ public List<Contribution> getExportContributions() {
+ return contributions;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ modelResolver.addModel(resolved, context);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return modelResolver.removeModel(resolved, context);
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ return modelResolver.resolveModel(modelClass, unresolved, context);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java
new file mode 100644
index 0000000000..a199f6874c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.java.JavaImportExportFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Artifact Processor for Java Imports
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaImportProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<JavaImport> {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private static final QName IMPORT_JAVA = new QName(SCA11_NS, "import.java");
+
+ private static final String PACKAGE = "package";
+ private static final String LOCATION = "location";
+
+ private final JavaImportExportFactory factory;
+
+ public JavaImportProcessor(FactoryExtensionPoint modelFactories) {
+ super();
+ this.factory = modelFactories.getFactory(JavaImportExportFactory.class);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-java-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return IMPORT_JAVA;
+ }
+
+ public Class<JavaImport> getModelType() {
+ return JavaImport.class;
+ }
+
+ /**
+ * Process <import.java package="" location=""/>
+ */
+ public JavaImport read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ JavaImport javaImport = this.factory.createJavaImport();
+ QName element = null;
+
+ try {
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ element = reader.getName();
+
+ // Read <import.java>
+ if (IMPORT_JAVA.equals(element)) {
+ String packageName = reader.getAttributeValue(null, PACKAGE);
+ if (packageName == null) {
+ error(context.getMonitor(), "AttributePackageMissing", reader);
+ //throw new ContributionReadException("Attribute 'package' is missing");
+ } else
+ javaImport.setPackage(packageName);
+
+ String location = getURIString(reader, LOCATION);
+ javaImport.setLocation(location);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (IMPORT_JAVA.equals(reader.getName())) {
+ return javaImport;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "XMLStreamException", reader, ex);
+ }
+
+ return javaImport;
+ }
+
+ public void write(JavaImport javaImport, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <import.java>
+ writer.writeStartElement(IMPORT_JAVA.getNamespaceURI(), IMPORT_JAVA.getLocalPart());
+
+ if (javaImport.getPackage() != null) {
+ writer.writeAttribute(PACKAGE, javaImport.getPackage());
+ }
+ if (javaImport.getLocation() != null) {
+ writer.writeAttribute(LOCATION, javaImport.getLocation());
+ }
+
+ writer.writeEndElement();
+ }
+
+
+ public void resolve(JavaImport model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/DefaultNamespaceImportExportFactory.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/DefaultNamespaceImportExportFactory.java
new file mode 100644
index 0000000000..a71fa61a54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/DefaultNamespaceImportExportFactory.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.contribution.namespace;
+
+import org.apache.tuscany.sca.contribution.namespace.impl.NamespaceImportExportFactoryImpl;
+
+/**
+ * Default Namespace Import/Export model factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultNamespaceImportExportFactory extends NamespaceImportExportFactoryImpl implements NamespaceImportExportFactory {
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceExport.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceExport.java
new file mode 100644
index 0000000000..c68aee8521
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceExport.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.sca.contribution.namespace;
+
+import org.apache.tuscany.sca.contribution.Export;
+
+
+/**
+ * The representation of an XML namespace export.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface NamespaceExport extends Export {
+
+ /**
+ * Get Namespace that identifies the export
+ *
+ * @return The exported namespace
+ */
+ String getNamespace();
+
+ /**
+ * Set Namespace that identifies the export
+ *
+ * @param namespace The exported namespace
+ */
+ void setNamespace(String namespace);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.java
new file mode 100644
index 0000000000..c452b15ee9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.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.contribution.namespace;
+
+import org.apache.tuscany.sca.contribution.Import;
+
+/**
+ * The representation of an XML namespace import.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface NamespaceImport extends Import {
+
+ /**
+ * Get the location used to resolve the definitions for this import
+ *
+ * @return The import location
+ */
+ String getLocation();
+
+ /**
+ * Set the location used to resolve the definitions for this import
+ *
+ * @param location The import location
+ */
+ void setLocation(String location);
+
+ /**
+ * Get Namespace that identifies the import
+ *
+ * @return The namespace
+ */
+ String getNamespace();
+
+ /**
+ * Set Namespace that identifies the import
+ *
+ * @param namespace The namespace
+ */
+ void setNamespace(String namespace);
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImportExportFactory.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImportExportFactory.java
new file mode 100644
index 0000000000..cfbac8bb1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImportExportFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.namespace;
+
+/**
+ * Base Namespace import/export model factory
+ *
+ * @version $Rev$ $Date$
+ */
+public interface NamespaceImportExportFactory {
+
+ /**
+ * Create a namespace import model object
+ *
+ * @return The new NamespaceImport model object
+ */
+ NamespaceImport createNamespaceImport();
+
+ /**
+ * Create a namespace export model object
+ *
+ * @return The new NamespaceExport model object
+ */
+ NamespaceExport createNamespaceExport();
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
new file mode 100644
index 0000000000..99af328964
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.contribution.namespace.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The representation of an export for the contribution
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamespaceExportImpl extends ExtensibleImpl implements NamespaceExport {
+ private String namespace;
+ private ModelResolver modelResolver;
+
+ protected NamespaceExportImpl() {
+ super();
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java
new file mode 100644
index 0000000000..7bf3c32c93
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.contribution.namespace.impl;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A model resolver for namespace exports.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamespaceExportModelResolver implements ModelResolver {
+
+ private ModelResolver resolver;
+
+ public NamespaceExportModelResolver(ModelResolver resolver) {
+ this.resolver = resolver;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ // Just delegate to the contribution's model resolver, namespace
+ // based filtering is implemented in the model specific model
+ // resolver, which know how to get the namespace of the particular
+ // type of model that they handle
+ return resolver.resolveModel(modelClass, unresolved, context);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
new file mode 100644
index 0000000000..0d410fb377
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.namespace.impl;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Artifact processor for Namespace export
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamespaceExportProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<NamespaceExport> {
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static final QName EXPORT = new QName(SCA11_NS, "export");
+ private static final String NAMESPACE = "namespace";
+
+ private final NamespaceImportExportFactory factory;
+ private final AssemblyFactory extensionFactory;
+ private final StAXArtifactProcessor<Object> extensionProcessor;
+ private final StAXAttributeProcessor<Object> attributeProcessor;
+
+ public NamespaceExportProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> attributeProcessor) {
+ this.factory = modelFactories.getFactory(NamespaceImportExportFactory.class);
+ this.extensionFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.attributeProcessor = attributeProcessor;
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-namespace-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return EXPORT;
+ }
+
+ public Class<NamespaceExport> getModelType() {
+ return NamespaceExport.class;
+ }
+
+ /**
+ * Process <export namespace=""/>
+ */
+ public NamespaceExport read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ NamespaceExport namespaceExport = this.factory.createNamespaceExport();
+ QName element = null;
+
+ try {
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ element = reader.getName();
+
+ // Read <export>
+ if (EXPORT.equals(element)) {
+ String ns = reader.getAttributeValue(null, NAMESPACE);
+ if (ns == null) {
+ error(context.getMonitor(), "AttributeNameSpaceMissing", reader);
+ //throw new ContributionReadException("Attribute 'namespace' is missing");
+ } else {
+ namespaceExport.setNamespace(ns);
+ }
+ readExtendedAttributes(reader, namespaceExport, attributeProcessor, extensionFactory, context);
+ } else {
+ //read extended elements
+ Object ext = extensionProcessor.read(reader, context);
+ if (namespaceExport != null) {
+ namespaceExport.getExtensions().add(ext);
+ }
+ }
+
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (EXPORT.equals(reader.getName())) {
+ return namespaceExport;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "XMLStreamException", reader, ex);
+ }
+
+ return namespaceExport;
+ }
+
+ public void write(NamespaceExport namespaceExport, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <export>
+ writer.writeStartElement(EXPORT.getNamespaceURI(), EXPORT.getLocalPart());
+
+ if (namespaceExport.getNamespace() != null) {
+ writer.writeAttribute(NAMESPACE, namespaceExport.getNamespace());
+ }
+
+ writeExtendedAttributes(writer, namespaceExport, attributeProcessor, context);
+
+ // handle extended elements
+ for (Object ext : namespaceExport.getExtensions()) {
+ extensionProcessor.write(ext, writer, context);
+ }
+
+ writer.writeEndElement();
+ }
+
+ public void resolve(NamespaceExport namespaceExport, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (namespaceExport.getNamespace() != null)
+ // Initialize the export's resolver
+ namespaceExport.setModelResolver(new NamespaceExportModelResolver(resolver));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java
new file mode 100644
index 0000000000..1146e593a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.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.contribution.namespace.impl;
+
+import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory;
+
+/**
+ * Namespace Import/Export model factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamespaceImportExportFactoryImpl implements NamespaceImportExportFactory {
+
+ public NamespaceImport createNamespaceImport() {
+ return new NamespaceImportImpl();
+ }
+
+ public NamespaceExport createNamespaceExport() {
+ return new NamespaceExportImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
new file mode 100644
index 0000000000..35e2d539d4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.namespace.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The representation of an import for the contribution
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamespaceImportImpl extends ExtensibleImpl implements NamespaceImport {
+ private ModelResolver modelResolver;
+
+ /**
+ * The namespace to be imported
+ */
+ private String namespace;
+ /**
+ * Optional location URI pointing to a Contribution that exports the namespace
+ */
+ private String location;
+
+
+ protected NamespaceImportImpl() {
+ super();
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+
+ /**
+ * Match a NamespaceImport to a given NamespaceExport based on :
+ * location is not provided
+ * import and export namespaces match
+ */
+ public boolean match(Export export) {
+ if (export instanceof NamespaceExport) {
+ if (this.getNamespace().equals(((NamespaceExport)export).getNamespace())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(namespace);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
new file mode 100644
index 0000000000..17b0dc3953
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.namespace.impl;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Artifact processor for Namespace import
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamespaceImportProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<NamespaceImport> {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private static final QName IMPORT = new QName(SCA11_NS, "import");
+
+ private static final String NAMESPACE = "namespace";
+ private static final String LOCATION = "location";
+
+ private final NamespaceImportExportFactory factory;
+ private final AssemblyFactory extensionFactory;
+ private final StAXArtifactProcessor<Object> extensionProcessor;
+ private final StAXAttributeProcessor<Object> attributeProcessor;
+
+ public NamespaceImportProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> attributeProcessor) {
+ this.factory = modelFactories.getFactory(NamespaceImportExportFactory.class);
+ this.extensionFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.attributeProcessor = attributeProcessor;
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-namespace-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return IMPORT;
+ }
+
+ public Class<NamespaceImport> getModelType() {
+ return NamespaceImport.class;
+ }
+
+ /**
+ * Process <import namespace="" location=""/>
+ */
+ public NamespaceImport read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ NamespaceImport namespaceImport = this.factory.createNamespaceImport();
+ QName element;
+
+ try {
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ element = reader.getName();
+
+ // Read <import>
+ if (IMPORT.equals(element)) {
+ String ns = reader.getAttributeValue(null, NAMESPACE);
+ if (ns == null) {
+ error(context.getMonitor(), "AttributeNameSpaceMissing", reader);
+ //throw new ContributionReadException("Attribute 'namespace' is missing");
+ } else {
+ namespaceImport.setNamespace(ns);
+ }
+
+ String location = getURIString(reader, LOCATION);
+ if (location != null) {
+ namespaceImport.setLocation(location);
+ }
+ readExtendedAttributes(reader, namespaceImport, attributeProcessor, extensionFactory, context);
+ } else {
+ // handle extended elements
+ Object ext = extensionProcessor.read(reader, context);
+ if (namespaceImport != null) {
+ namespaceImport.getExtensions().add(ext);
+ }
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (IMPORT.equals(reader.getName())) {
+ return namespaceImport;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ }
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "XMLStreamException", reader, ex);
+ }
+
+ return namespaceImport;
+ }
+
+ public void write(NamespaceImport namespaceImport, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <import>
+ writer.writeStartElement(IMPORT.getNamespaceURI(), IMPORT.getLocalPart());
+
+ if (namespaceImport.getNamespace() != null) {
+ writer.writeAttribute(NAMESPACE, namespaceImport.getNamespace());
+ }
+ if (namespaceImport.getLocation() != null) {
+ writer.writeAttribute(LOCATION, namespaceImport.getLocation());
+ }
+
+ writeExtendedAttributes(writer, namespaceImport, attributeProcessor, context);
+
+ //handle extended elements
+ for (Object ext : namespaceImport.getExtensions()) {
+ extensionProcessor.write(ext, writer, context);
+ }
+
+ writer.writeEndElement();
+ }
+
+
+ public void resolve(NamespaceImport model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java
new file mode 100644
index 0000000000..9ac3aebaf6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.contribution.processor;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * Base interface for artifact processors.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ArtifactProcessor<M> {
+
+ /**
+ * Resolve references from this model to other models. For example references
+ * from a composite to another one, or references from a composite to a WSDL
+ * model.
+ *
+ * @param model The model to resolve
+ * @param resolver The resolver to use to resolve referenced models
+ * @param context The context for the processor
+ */
+ void resolve(M model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException;
+
+ /**
+ * Returns the type of model handled by this artifact processor.
+ *
+ * @return The type of model handled by this artifact processor
+ */
+ Class<M> getModelType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java
new file mode 100644
index 0000000000..82902a11fe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java
@@ -0,0 +1,532 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.NamespaceContext;
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+
+
+/**
+ * A base class with utility methods for the other artifact processors in this module.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class BaseStAXArtifactProcessor {
+ private static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ /**
+ * The StAXHelper without states
+ */
+ private static final StAXHelper helper = new StAXHelper(null, null, null);
+ /**
+ * Returns a QName from a string.
+ * @param reader
+ * @param value
+ * @return
+ */
+ protected QName getQNameValue(XMLStreamReader reader, String value) {
+ return StAXHelper.getValueAsQName(reader, value);
+ }
+
+ /**
+ * Returns the boolean value of an attribute.
+ * @param reader
+ * @param name
+ * @return
+ */
+ protected boolean getBoolean(XMLStreamReader reader, String name) {
+ Boolean attr = StAXHelper.getAttributeAsBoolean(reader, name);
+ if (attr == null) {
+ return false;
+ } else {
+ return attr.booleanValue();
+ }
+ }
+
+ /**
+ * Returns the QName value of an attribute.
+ * @param reader
+ * @param name
+ * @return
+ */
+ protected QName getQName(XMLStreamReader reader, String name) {
+ return StAXHelper.getAttributeAsQName(reader, name);
+ }
+
+ /**
+ * Returns the value of an attribute as a list of QNames.
+ * @param reader
+ * @param name
+ * @return
+ */
+ protected List<QName> getQNames(XMLStreamReader reader, String name) {
+ return StAXHelper.getAttributeAsQNames(reader, name);
+ }
+
+ /**
+ * Returns the string value of an attribute.
+ * @param reader
+ * @param name
+ * @return
+ */
+ protected String getString(XMLStreamReader reader, String name) {
+ return StAXHelper.getAttributeAsString(reader, name);
+ }
+
+ /**
+ * Returns the string value of an attribute.
+ * @param reader
+ * @param name
+ * @return
+ */
+ protected String getURIString(XMLStreamReader reader, String name) {
+ return StAXHelper.getAttributeAsURIString(reader, name);
+ }
+
+ /**
+ * Test if an attribute is explicitly set
+ * @param reader
+ * @param name
+ * @return
+ */
+ protected boolean isSet(XMLStreamReader reader, String name) {
+ return StAXHelper.isAttributePresent(reader, name);
+ }
+
+ /**
+ * Returns the value of xsi:type attribute
+ * @param reader The XML stream reader
+ * @return The QName of the type, if the attribute is not present, null is
+ * returned.
+ */
+ protected QName getXSIType(XMLStreamReader reader) {
+ return StAXHelper.getXSIType(reader);
+ }
+
+ /**
+ * Parse the next child element.
+ * @param reader
+ * @return
+ * @throws XMLStreamException
+ */
+ protected boolean nextChildElement(XMLStreamReader reader) throws XMLStreamException {
+ while (reader.hasNext()) {
+ int event = reader.next();
+ if (event == END_ELEMENT) {
+ return false;
+ }
+ if (event == START_ELEMENT) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Advance the stream to the next END_ELEMENT event skipping any nested
+ * content.
+ * @param reader the reader to advance
+ * @throws XMLStreamException if there was a problem reading the stream
+ */
+ protected void skipToEndElement(XMLStreamReader reader) throws XMLStreamException {
+ StAXHelper.skipToEndElement(reader);
+ }
+
+ /**
+ *
+ * @param writer
+ * @param uri
+ * @throws XMLStreamException
+ */
+ private String setPrefix(XMLStreamWriter writer, String uri) throws XMLStreamException {
+ if (uri == null) {
+ return null;
+ }
+ String prefix = writer.getPrefix(uri);
+ if (prefix != null) {
+ return null;
+ } else {
+
+ // Find an available prefix and bind it to the given URI
+ NamespaceContext nsc = writer.getNamespaceContext();
+ for (int i=1; ; i++) {
+ prefix = "ns" + i;
+ if (nsc.getNamespaceURI(prefix) == null) {
+ break;
+ }
+ }
+ writer.setPrefix(prefix, uri);
+ return prefix;
+ }
+
+ }
+
+ /**
+ * Start an element.
+ * @param uri
+ * @param name
+ * @param attrs
+ * @throws XMLStreamException
+ */
+ protected void writeStart(XMLStreamWriter writer, String uri, String name, XAttr... attrs)
+ throws XMLStreamException {
+ helper.writeStartElement(writer, "", name, uri);
+ writeAttributes(writer, attrs);
+ }
+
+ /**
+ * Start an element.
+ * @param qname
+ * @param attrs
+ * @throws XMLStreamException
+ */
+ protected void writeStart(XMLStreamWriter writer, QName qname, XAttr... attrs) throws XMLStreamException {
+ writeStart(writer, qname.getNamespaceURI(), qname.getLocalPart(), attrs);
+ }
+
+ /**
+ * End an element.
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writeEnd(XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeEndElement();
+ }
+
+ /**
+ * Start a document.
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writeStartDocument(XMLStreamWriter writer, String uri, String name, XAttr... attrs) throws XMLStreamException {
+ writer.writeStartDocument();
+ writer.setDefaultNamespace(uri);
+ writeStart(writer, uri, name, attrs);
+ // writer.writeDefaultNamespace(uri);
+ }
+
+ /**
+ * Start a document.
+ * @param writer
+ * @param qname
+ * @param attrs
+ * @throws XMLStreamException
+ */
+ protected void writeStartDocument(XMLStreamWriter writer, QName qname, XAttr... attrs) throws XMLStreamException {
+ writeStartDocument(writer, qname.getNamespaceURI(), qname.getLocalPart(), attrs);
+ }
+
+ /**
+ * End a document.
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void writeEndDocument(XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeEndDocument();
+ }
+
+ /**
+ * Write attributes to the current element.
+ * @param writer
+ * @param attrs
+ * @throws XMLStreamException
+ */
+ protected void writeAttributes(XMLStreamWriter writer, XAttr... attrs) throws XMLStreamException {
+ for (XAttr attr : attrs) {
+ if (attr != null)
+ attr.write(writer);
+ }
+ }
+
+ /**
+ *
+ * @param reader
+ * @param extensible
+ * @param extensionAttributeProcessor
+ * @param extensionAttributeProcessor
+ * @param extensionFactory
+ * @param context TODO
+ * @param elementName
+ * @throws ContributionReadException
+ * @throws XMLStreamException
+ */
+ protected void readExtendedAttributes(XMLStreamReader reader,
+ Extensible extensible,
+ StAXAttributeProcessor extensionAttributeProcessor,
+ AssemblyFactory extensionFactory, ProcessorContext context) throws ContributionReadException,
+ XMLStreamException {
+ QName elementName = reader.getName();
+ for (int a = 0; a < reader.getAttributeCount(); a++) {
+ QName attributeName = reader.getAttributeName(a);
+ if (attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
+ if (!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI())) {
+ Object attributeValue = extensionAttributeProcessor.read(attributeName, reader, context);
+ Extension attributeExtension;
+ if (attributeValue instanceof Extension) {
+ attributeExtension = (Extension)attributeValue;
+ } else {
+ attributeExtension = extensionFactory.createExtension();
+ attributeExtension.setQName(attributeName);
+ attributeExtension.setValue(attributeValue);
+ attributeExtension.setAttribute(true);
+ }
+ extensible.getAttributeExtensions().add(attributeExtension);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param writer
+ * @param extensibleElement
+ * @param extensionAttributeProcessor
+ * @param context TODO
+ * @param attributeModel
+ * @throws ContributionWriteException
+ * @throws XMLStreamException
+ */
+ protected void writeExtendedAttributes(XMLStreamWriter writer,
+ Extensible extensibleElement,
+ StAXAttributeProcessor extensionAttributeProcessor, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ for (Extension extension : extensibleElement.getAttributeExtensions()) {
+ if (extension.isAttribute()) {
+ extensionAttributeProcessor.write(extension, writer, context);
+ }
+ }
+ }
+
+ protected void readExtendedElement(XMLStreamReader reader,
+ Extensible extensible,
+ StAXArtifactProcessor extensionProcessor, ProcessorContext context)
+ throws ContributionReadException, XMLStreamException {
+
+ Object ext = extensionProcessor.read(reader, context);
+ if (extensible != null) {
+ extensible.getExtensions().add(ext);
+ }
+ }
+
+ protected void writeExtendedElements(XMLStreamWriter writer,
+ Extensible extensible,
+ StAXArtifactProcessor extensionProcessor, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ List <Object> otherExtensions = new ArrayList<Object>();
+
+ // write all generic extensions as elements
+ // to produce semanticaly equal xml output
+ for (Object ext : extensible.getExtensions()) {
+ if (ext instanceof Extension) {
+ extensionProcessor.write(ext, writer, context);
+ } else {
+ otherExtensions.add(ext);
+ }
+ }
+
+ //wrap xml extensibility into a extension wrapper element
+ if(otherExtensions.size() > 0) {
+
+ writeStart(writer, SCA11_NS, "extensions");
+
+ for (Object extension : otherExtensions) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ }
+
+ /**
+ * Represents an XML attribute that needs to be written to a document.
+ */
+ public static class XAttr {
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private String uri = SCA11_NS;
+ private String name;
+ private Object value;
+
+ public XAttr(String uri, String name, String value) {
+ this.uri = uri;
+ this.name = name;
+ this.value = value;
+ }
+
+ public XAttr(String name, String value) {
+ this(null, name, value);
+ }
+
+ public XAttr(String uri, String name, List<?> values) {
+ this.uri = uri;
+ this.name = name;
+ this.value = values;
+ }
+
+ public XAttr(String name, List<?> values) {
+ this(null, name, values);
+ }
+
+ public XAttr(String uri, String name, Boolean value) {
+ this.uri = uri;
+ this.name = name;
+ this.value = value;
+ }
+
+ public XAttr(String name, Boolean value) {
+ this(null, name, value);
+ }
+
+ public XAttr(String uri, String name, Integer value) {
+ this.uri = uri;
+ this.name = name;
+ this.value = value;
+ }
+
+ public XAttr(String name, Integer value) {
+ this(null, name, value);
+ }
+
+ public XAttr(String uri, String name, Double value) {
+ this.uri = uri;
+ this.name = name;
+ this.value = value;
+ }
+
+ public XAttr(String name, Double value) {
+ this(null, name, value);
+ }
+
+ public XAttr(String uri, String name, QName value) {
+ this.uri = uri;
+ this.name = name;
+ this.value = value;
+ }
+
+ public XAttr(String name, QName value) {
+ this(null, name, value);
+ }
+
+ public String toString() {
+ return uri == null ? name + "=\"" + value + "\"" : "{" + uri + "}" + name + "=\"" + value + "\"";
+ }
+
+ /**
+ * Writes a string from a QName and registers a prefix for its namespace.
+ * @param reader
+ * @param value
+ * @return
+ */
+ private String writeQNameValue(XMLStreamWriter writer, QName qname) throws XMLStreamException {
+ if (qname != null) {
+ String prefix = helper.writeNamespace(writer, qname.getPrefix(), qname.getNamespaceURI());
+ if ("".equals(prefix)) {
+ return qname.getLocalPart();
+ } else {
+ return prefix + ":" + qname.getLocalPart();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Write to document
+ * @param writer
+ * @throws XMLStreamException
+ */
+ public void write(XMLStreamWriter writer) throws XMLStreamException {
+ String str;
+ if (value instanceof QName) {
+
+ // Write a QName
+ str = writeQNameValue(writer, (QName)value);
+
+ } else if (value instanceof Collection) {
+
+ // Write a list of values
+ Collection<?> values = (Collection<?>)value;
+ if (values.isEmpty()) {
+ return;
+ }
+ StringBuffer buffer = new StringBuffer();
+ for (Object v: values) {
+ if (v == null) {
+ // Skip null values
+ continue;
+ }
+
+ if (v instanceof XAttr) {
+ // Write an XAttr value
+ ((XAttr)v).write(writer);
+ continue;
+ }
+
+ if (buffer.length() != 0) {
+ buffer.append(' ');
+ }
+ if (v instanceof QName) {
+ // Write a QName value
+ buffer.append(writeQNameValue(writer, (QName)v));
+ } else {
+ // Write value as a string
+ buffer.append(String.valueOf(v));
+ }
+ }
+ str = buffer.toString();
+
+ } else {
+
+ // Write a string
+ if (value == null) {
+ return;
+ }
+ str = String.valueOf(value);
+ }
+ if (str.length() == 0 && (value instanceof Collection)) {
+ return;
+ }
+
+ helper.writeAttribute(writer, "", name, uri, str);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java
new file mode 100644
index 0000000000..93cb8c7fc7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.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.sca.contribution.processor;
+
+/**
+ * Base class for exceptions raised by contribution services.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ContributionException extends Exception {
+
+ private static final long serialVersionUID = 4432880414927652578L;
+
+ protected ContributionException() {
+ super();
+ }
+
+ protected ContributionException(String message) {
+ super(message);
+ }
+
+ protected ContributionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java
new file mode 100644
index 0000000000..ced2ad1899
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+
+/**
+ * Denotes an exception while reading artifacts inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ContributionReadException extends ContributionException {
+ public static final int UNDEFINED = -1;
+ private static final long serialVersionUID = -7459051598906813461L;
+ private String resourceURI;
+ private int line = UNDEFINED;
+ private int column = UNDEFINED;
+
+ public ContributionReadException(String message) {
+ super(message);
+ }
+
+ public ContributionReadException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionReadException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the location of the resource that was being read.
+ *
+ * @return the location of the resource that was being read
+ */
+ public String getResourceURI() {
+ return resourceURI;
+ }
+
+ /**
+ * Sets the location of the resource that was being read.
+ *
+ * @param resourceURI the location of the resource that was being read
+ */
+ public void setResourceURI(String resourceURI) {
+ this.resourceURI = resourceURI;
+ }
+
+ /**
+ * Returns the line inside the resource that was being read.
+ * @return the line inside the resource that was being read
+ */
+ public int getLine() {
+ return line;
+ }
+
+ /**
+ * Sets the line inside the resource that was being read.
+ * @param line the line inside the resource that was being read
+ */
+ public void setLine(int line) {
+ this.line = line;
+ }
+
+ /**
+ * Returns the column inside the resource that was being read.
+ * @return the column inside the resource that was being read
+ */
+ public int getColumn() {
+ return column;
+ }
+
+ /**
+ * Sets the column inside the resource that was being read.
+ * @param column the column inside the resource that was being read
+ */
+ public void setColumn(int column) {
+ this.column = column;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java
new file mode 100644
index 0000000000..af42c25734
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.contribution.processor;
+
+
+/**
+ * Denotes a problem while resolving models inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ContributionResolveException extends ContributionException {
+ private static final long serialVersionUID = -7459051598906813461L;
+
+ public ContributionResolveException(String message) {
+ super(message);
+ }
+
+ public ContributionResolveException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionResolveException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java
new file mode 100644
index 0000000000..9db6292e3d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.contribution.processor;
+
+/**
+ * Base class for runtime exceptions raised by contribution services.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ContributionRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = 7711215366287498896L;
+
+ protected ContributionRuntimeException() {
+ super();
+ }
+
+ protected ContributionRuntimeException(String message) {
+ super(message);
+ }
+
+ protected ContributionRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java
new file mode 100644
index 0000000000..4e1cd287bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.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.sca.contribution.processor;
+
+
+
+/**
+ * Denotes an exception while writing artifacts inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ContributionWriteException extends ContributionException {
+ private static final long serialVersionUID = -7459051598906813461L;
+ private String resourceURI;
+
+ public ContributionWriteException(String message) {
+ super(message);
+ }
+
+ public ContributionWriteException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionWriteException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the location of the resource that was being written.
+ *
+ * @return the location of the resource that was being written
+ */
+ public String getResourceURI() {
+ return resourceURI;
+ }
+
+ /**
+ * Sets the location of the resource that was being written.
+ *
+ * @param resourceURI the location of the resource that was being written
+ */
+ public void setResourceURI(String resourceURI) {
+ this.resourceURI = resourceURI;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..c871e4c868
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The default implementation of an artifact processor extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class DefaultArtifactProcessorExtensionPoint<P extends ArtifactProcessor<?>> {
+ protected final Map<Object, P> processorsByArtifactType = new HashMap<Object, P>();
+ protected final Map<Class<?>, P> processorsByModelType = new HashMap<Class<?>, P>();
+
+ /**
+ * Constructs a new loader registry.
+ */
+ DefaultArtifactProcessorExtensionPoint() {
+ }
+
+ /**
+ * Returns the processor associated with the given artifact type.
+ *
+ * @param artifactType An artifact type
+ * @return The processor associated with the given artifact type
+ */
+ public P getProcessor(Object artifactType) {
+ return processorsByArtifactType.get(artifactType);
+ }
+
+ /**
+ * Returns the processor associated with the given model type.
+ *
+ * @param modelType A model type
+ * @return The processor associated with the given model type
+ */
+ public <T> P getProcessor(Class<T> modelType) {
+ Class<?>[] classes = modelType.getInterfaces();
+ for (Class<?> c : classes) {
+ P processor = processorsByModelType.get(c);
+ if (processor != null) {
+ return processor;
+ }
+ }
+ return processorsByModelType.get(modelType);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..151edeae0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
@@ -0,0 +1,325 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDeclarationParser;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * The default implementation of an extension point for StAX artifact processors.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultStAXArtifactProcessorExtensionPoint extends
+ DefaultArtifactProcessorExtensionPoint<StAXArtifactProcessor<?>> implements StAXArtifactProcessorExtensionPoint {
+
+ private ExtensionPointRegistry registry;
+ private FactoryExtensionPoint modelFactories;
+ private boolean loaded;
+ private StAXArtifactProcessor<Object> extensibleStAXProcessor;
+ private StAXAttributeProcessor<Object> extensibleStAXAttributeProcessor;
+
+ /**
+ * Constructs a new extension point.
+ */
+ public DefaultStAXArtifactProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ this.registry = extensionPoints;
+ this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ this.extensibleStAXProcessor = new ExtensibleStAXArtifactProcessor(this, inputFactory, outputFactory);
+
+ StAXAttributeProcessorExtensionPoint attributeExtensionPoint =
+ extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ this.extensibleStAXAttributeProcessor =
+ new ExtensibleStAXAttributeProcessor(attributeExtensionPoint, inputFactory, outputFactory);
+ }
+
+ public void addArtifactProcessor(StAXArtifactProcessor<?> artifactProcessor) {
+ if (artifactProcessor.getArtifactType() != null) {
+ processorsByArtifactType.put((Object)artifactProcessor.getArtifactType(), artifactProcessor);
+ }
+ if (artifactProcessor.getModelType() != null) {
+ processorsByModelType.put(artifactProcessor.getModelType(), artifactProcessor);
+ }
+ }
+
+ public void removeArtifactProcessor(StAXArtifactProcessor<?> artifactProcessor) {
+ if (artifactProcessor.getArtifactType() != null) {
+ processorsByArtifactType.remove((Object)artifactProcessor.getArtifactType());
+ }
+ if (artifactProcessor.getModelType() != null) {
+ processorsByModelType.remove(artifactProcessor.getModelType());
+ }
+ }
+
+ @Override
+ public <T> StAXArtifactProcessor<T> getProcessor(Class<T> modelType) {
+ loadArtifactProcessors();
+ return (StAXArtifactProcessor<T>)super.getProcessor(modelType);
+ }
+
+ @Override
+ public StAXArtifactProcessor<?> getProcessor(Object artifactType) {
+ loadArtifactProcessors();
+ return super.getProcessor(artifactType);
+ }
+
+ /**
+ * Lazily load artifact processors registered in the extension point.
+ */
+ private synchronized void loadArtifactProcessors() {
+ if (loaded)
+ return;
+
+ // Get the processor service declarations
+ Collection<ServiceDeclaration> processorDeclarations;
+ try {
+ processorDeclarations =
+ registry.getServiceDiscovery().getServiceDeclarations(StAXArtifactProcessor.class.getName());
+ } catch (IOException e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+
+ for (ServiceDeclaration processorDeclaration : processorDeclarations) {
+ Map<String, String> attributes = processorDeclaration.getAttributes();
+
+ // Load a StAX artifact processor
+
+ // Get the model QName
+ QName artifactType = ServiceDeclarationParser.getQName(attributes.get("qname"));
+
+ // Get the model class name
+ String modelTypeName = attributes.get("model");
+
+ // Get the model factory class name
+ String factoryName = attributes.get("factory");
+
+ // Create a processor wrapper and register it
+ StAXArtifactProcessor<?> processor =
+ new LazyStAXArtifactProcessor(artifactType, modelTypeName, factoryName, processorDeclaration,
+ registry, modelFactories, extensibleStAXProcessor,
+ extensibleStAXAttributeProcessor);
+ addArtifactProcessor(processor);
+ }
+
+ loaded = true;
+ }
+
+ /**
+ * A wrapper around an Artifact processor class allowing lazy loading and
+ * initialization of artifact processors.
+ */
+ private static class LazyStAXArtifactProcessor implements StAXArtifactProcessor {
+
+ private ExtensionPointRegistry extensionPoints;
+ private QName artifactType;
+ private String modelTypeName;
+ private String factoryName;
+ private ServiceDeclaration processorDeclaration;
+ private StAXArtifactProcessor<?> processor;
+ private Class<?> modelType;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private StAXAttributeProcessor<Object> extensionAttributeProcessor;
+
+ LazyStAXArtifactProcessor(QName artifactType,
+ String modelTypeName,
+ String factoryName,
+ ServiceDeclaration processorDeclaration,
+ ExtensionPointRegistry extensionPoints,
+ FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> extensionAttributeProcessor) {
+
+ this.extensionPoints = extensionPoints;
+ this.artifactType = artifactType;
+ this.modelTypeName = modelTypeName;
+ this.factoryName = factoryName;
+ this.processorDeclaration = processorDeclaration;
+ this.extensionProcessor = extensionProcessor;
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+ }
+
+ public QName getArtifactType() {
+ return artifactType;
+ }
+
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private StAXArtifactProcessor getProcessor() {
+ if (processor == null) {
+
+ if (processorDeclaration.getClassName()
+ .equals("org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor")) {
+
+ // Specific initialization for the DefaultBeanModelProcessor
+ FactoryExtensionPoint modelFactories =
+ extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ try {
+ Class<StAXArtifactProcessor> processorClass =
+ (Class<StAXArtifactProcessor>)processorDeclaration.loadClass();
+ Object modelFactory;
+ if (factoryName != null) {
+ Class<?> factoryClass = (Class<?>)processorDeclaration.loadClass(factoryName);
+ modelFactory = modelFactories.getFactory(factoryClass);
+ } else {
+ modelFactory = null;
+ }
+ Constructor<StAXArtifactProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class,
+ QName.class,
+ Class.class,
+ Object.class);
+ processor = constructor.newInstance(modelFactories, artifactType, getModelType(), modelFactory);
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+ } else {
+ FactoryExtensionPoint modelFactories =
+ extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+
+ // Load and instantiate the processor class
+ try {
+ Class<StAXArtifactProcessor> processorClass =
+ (Class<StAXArtifactProcessor>)processorDeclaration.loadClass();
+ try {
+ Constructor<StAXArtifactProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class);
+ processor = constructor.newInstance(modelFactories);
+ } catch (NoSuchMethodException e) {
+ try {
+ Constructor<StAXArtifactProcessor> constructor =
+ processorClass.getConstructor(ExtensionPointRegistry.class);
+ processor = constructor.newInstance(extensionPoints);
+ } catch (NoSuchMethodException e1) {
+ try {
+ Constructor<StAXArtifactProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class,
+ StAXArtifactProcessor.class);
+ processor = constructor.newInstance(modelFactories, extensionProcessor);
+ } catch (NoSuchMethodException e2) {
+ try {
+ Constructor<StAXArtifactProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class,
+ StAXArtifactProcessor.class,
+ StAXAttributeProcessor.class);
+ processor =
+ constructor.newInstance(modelFactories,
+ extensionProcessor,
+ extensionAttributeProcessor);
+ } catch (NoSuchMethodException e2a) {
+ try {
+ Constructor<StAXArtifactProcessor> constructor =
+ processorClass.getConstructor(ExtensionPointRegistry.class,
+ StAXArtifactProcessor.class);
+ processor = constructor.newInstance(extensionPoints, extensionProcessor);
+ } catch (NoSuchMethodException e3) {
+ try {
+ Constructor<StAXArtifactProcessor> constructor =
+ processorClass.getConstructor(ExtensionPointRegistry.class,
+ StAXArtifactProcessor.class,
+ StAXAttributeProcessor.class);
+ processor =
+ constructor.newInstance(extensionPoints,
+ extensionProcessor,
+ extensionAttributeProcessor);
+ } catch (NoSuchMethodException e3a) {
+
+ Constructor<StAXArtifactProcessor> constructor =
+ processorClass.getConstructor();
+ processor = constructor.newInstance();
+
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+ }
+ }
+ return processor;
+ }
+
+ public Object read(XMLStreamReader inputSource, ProcessorContext context) throws ContributionReadException,
+ XMLStreamException {
+ return getProcessor().read(inputSource, context);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void write(Object model, XMLStreamWriter outputSource, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ getProcessor().write(model, outputSource, context);
+ }
+
+ public Class<?> getModelType() {
+ if (modelTypeName != null && modelType == null) {
+ try {
+ modelType = processorDeclaration.loadClass(modelTypeName);
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+ }
+ return modelType;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void resolve(Object model, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ getProcessor().resolve(model, resolver, context);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
new file mode 100644
index 0000000000..e76d6cb299
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
@@ -0,0 +1,292 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDeclarationParser;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * The default implementation of an extension point for StAX artifact processors.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultStAXAttributeProcessorExtensionPoint extends
+ DefaultArtifactProcessorExtensionPoint<StAXAttributeProcessor<?>> implements StAXAttributeProcessorExtensionPoint {
+
+ private ExtensionPointRegistry registry;
+ private FactoryExtensionPoint modelFactories;
+ private StAXAttributeProcessor<Object> extensibleStAXAttributeProcessor;
+ private boolean loaded;
+ private Monitor monitor = null;
+
+ /**
+ * Constructs a new extension point.
+ */
+ public DefaultStAXAttributeProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ this.registry = extensionPoints;
+ this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ UtilityExtensionPoint utilities = this.registry.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ if (monitorFactory != null) {
+ this.monitor = monitorFactory.createMonitor();
+ }
+ this.extensibleStAXAttributeProcessor = new ExtensibleStAXAttributeProcessor(this, inputFactory, outputFactory);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public void addArtifactProcessor(StAXAttributeProcessor<?> artifactProcessor) {
+ if (artifactProcessor.getArtifactType() != null) {
+ processorsByArtifactType.put((Object)artifactProcessor.getArtifactType(), artifactProcessor);
+ }
+ if (artifactProcessor.getModelType() != null) {
+ processorsByModelType.put(artifactProcessor.getModelType(), artifactProcessor);
+ }
+ }
+
+ public void removeArtifactProcessor(StAXAttributeProcessor<?> artifactProcessor) {
+ if (artifactProcessor.getArtifactType() != null) {
+ processorsByArtifactType.remove((Object)artifactProcessor.getArtifactType());
+ }
+ if (artifactProcessor.getModelType() != null) {
+ processorsByModelType.remove(artifactProcessor.getModelType());
+ }
+ }
+
+ @Override
+ public <T> StAXAttributeProcessor<T> getProcessor(Class<T> modelType) {
+ loadArtifactProcessors();
+ return (StAXAttributeProcessor<T>)super.getProcessor(modelType);
+ }
+
+ @Override
+ public StAXAttributeProcessor<?> getProcessor(Object artifactType) {
+ loadArtifactProcessors();
+ return super.getProcessor(artifactType);
+ }
+
+ /**
+ * Lazily load artifact processors registered in the extension point.
+ */
+ private synchronized void loadArtifactProcessors() {
+ if (loaded)
+ return;
+
+ // Get the processor service declarations
+ Collection<ServiceDeclaration> processorDeclarations;
+ try {
+ processorDeclarations =
+ registry.getServiceDiscovery().getServiceDeclarations(StAXAttributeProcessor.class.getName());
+ } catch (IOException e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ error("IllegalStateException", extensibleStAXAttributeProcessor, ie);
+ throw ie;
+ }
+
+ for (ServiceDeclaration processorDeclaration : processorDeclarations) {
+ Map<String, String> attributes = processorDeclaration.getAttributes();
+
+ // Load a StAX artifact processor
+
+ // Get the model QName
+ QName artifactType = ServiceDeclarationParser.getQName(attributes.get("qname"));
+
+ // Get the model class name
+ String modelTypeName = attributes.get("model");
+
+ // Get the model factory class name
+ String factoryName = attributes.get("factory");
+
+ // Create a processor wrapper and register it
+ StAXAttributeProcessor<?> processor =
+ new LazyStAXAttributeProcessor(artifactType, modelTypeName, factoryName, processorDeclaration,
+ registry, modelFactories, extensibleStAXAttributeProcessor);
+ addArtifactProcessor(processor);
+ }
+
+ loaded = true;
+ }
+
+ /**
+ * A wrapper around an Artifact processor class allowing lazy loading and
+ * initialization of artifact processors.
+ */
+ private static class LazyStAXAttributeProcessor implements StAXAttributeProcessor {
+
+ private ExtensionPointRegistry extensionPoints;
+ private QName artifactType;
+ private String modelTypeName;
+ private String factoryName;
+ private ServiceDeclaration processorDeclaration;
+ private StAXAttributeProcessor<?> processor;
+ private Class<?> modelType;
+ private StAXAttributeProcessor<Object> extensionProcessor;
+
+ LazyStAXAttributeProcessor(QName artifactType,
+ String modelTypeName,
+ String factoryName,
+ ServiceDeclaration processorDeclaration,
+ ExtensionPointRegistry extensionPoints,
+ FactoryExtensionPoint modelFactories,
+ StAXAttributeProcessor<Object> extensionProcessor) {
+
+ this.extensionPoints = extensionPoints;
+ this.artifactType = artifactType;
+ this.modelTypeName = modelTypeName;
+ this.factoryName = factoryName;
+ this.processorDeclaration = processorDeclaration;
+ this.extensionProcessor = extensionProcessor;
+ }
+
+ public QName getArtifactType() {
+ return artifactType;
+ }
+
+ @SuppressWarnings("unchecked")
+ private StAXAttributeProcessor getProcessor() {
+ if (processor == null) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+
+ // Load and instantiate the processor class
+ try {
+ Class<StAXAttributeProcessor> processorClass =
+ (Class<StAXAttributeProcessor>)processorDeclaration.loadClass();
+ try {
+ Constructor<StAXAttributeProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class);
+ processor = constructor.newInstance(modelFactories);
+ } catch (NoSuchMethodException e) {
+ try {
+ Constructor<StAXAttributeProcessor> constructor =
+ processorClass.getConstructor(ExtensionPointRegistry.class);
+ processor = constructor.newInstance(extensionPoints);
+ } catch (NoSuchMethodException e1) {
+ try {
+ Constructor<StAXAttributeProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class,
+ StAXArtifactProcessor.class);
+ processor = constructor.newInstance(modelFactories, extensionProcessor);
+ } catch (NoSuchMethodException e2) {
+ try {
+ Constructor<StAXAttributeProcessor> constructor =
+ processorClass.getConstructor(ExtensionPointRegistry.class,
+ StAXArtifactProcessor.class);
+ processor = constructor.newInstance(extensionPoints, extensionProcessor);
+ } catch (NoSuchMethodException e3) {
+ try {
+ Constructor<StAXAttributeProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class);
+ processor = constructor.newInstance(modelFactories);
+ } catch (NoSuchMethodException e4) {
+ try {
+ Constructor<StAXAttributeProcessor> constructor =
+ processorClass.getConstructor(ExtensionPointRegistry.class);
+ processor = constructor.newInstance(extensionPoints);
+ } catch (NoSuchMethodException e4a) {
+
+ Constructor<StAXAttributeProcessor> constructor =
+ processorClass.getConstructor();
+ processor = constructor.newInstance();
+
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+
+ }
+ return processor;
+ }
+
+ public Object read(QName attributeName, XMLStreamReader inputSource, ProcessorContext context)
+ throws ContributionReadException, XMLStreamException {
+ return getProcessor().read(attributeName, inputSource, context);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void write(Object model, XMLStreamWriter outputSource, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ getProcessor().write(model, outputSource, context);
+ }
+
+ public Class<?> getModelType() {
+ if (modelTypeName != null && modelType == null) {
+ try {
+ modelType = processorDeclaration.loadClass(modelTypeName);
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+ }
+ return modelType;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void resolve(Object model, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ getProcessor().resolve(model, resolver, context);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..e22d7762fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
@@ -0,0 +1,320 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+/**
+ * The default implementation of a URL artifact processor extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultURLArtifactProcessorExtensionPoint extends
+ DefaultArtifactProcessorExtensionPoint<URLArtifactProcessor<?>> implements URLArtifactProcessorExtensionPoint {
+
+ private ExtensionPointRegistry registry;
+ private StAXArtifactProcessor<?> staxProcessor;
+ private boolean loaded;
+
+ /**
+ * Constructs a new extension point.
+ */
+ public DefaultURLArtifactProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ this.registry = extensionPoints;
+ FactoryExtensionPoint modelFactories = this.registry.getExtensionPoint(FactoryExtensionPoint.class);
+ XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ public void addArtifactProcessor(URLArtifactProcessor<?> artifactProcessor) {
+ if (artifactProcessor.getArtifactType() != null) {
+ Pattern pattern = Pattern.compile(wildcard2regex(artifactProcessor.getArtifactType()));
+ processorsByArtifactType.put(pattern, artifactProcessor);
+ }
+ if (artifactProcessor.getModelType() != null) {
+ processorsByModelType.put(artifactProcessor.getModelType(), artifactProcessor);
+ }
+ }
+
+ public void removeArtifactProcessor(URLArtifactProcessor<?> artifactProcessor) {
+ if (artifactProcessor.getArtifactType() != null) {
+ String regex = wildcard2regex(artifactProcessor.getArtifactType());
+ for (Object key : processorsByArtifactType.keySet()) {
+ if ((key instanceof Pattern) && ((Pattern)key).pattern().equals(regex)) {
+ processorsByArtifactType.remove(key);
+ }
+ }
+ processorsByArtifactType.remove((Object)artifactProcessor.getArtifactType());
+ }
+ if (artifactProcessor.getModelType() != null) {
+ processorsByModelType.remove(artifactProcessor.getModelType());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> URLArtifactProcessor<T> getProcessor(Class<T> modelType) {
+ loadProcessors();
+ return (URLArtifactProcessor<T>)super.getProcessor(modelType);
+ }
+
+ public Collection<URLArtifactProcessor<?>> getProcessors(Object artifactType) {
+ loadProcessors();
+ String uri = (String)artifactType;
+ if (uri.endsWith("/")) {
+ // Ignore directories
+ return Collections.emptyList();
+ }
+ if (!uri.startsWith("/")) {
+ uri = "/" + uri;
+ }
+ List<URLArtifactProcessor<?>> processors = new ArrayList<URLArtifactProcessor<?>>();
+ for (Map.Entry<Object, URLArtifactProcessor<?>> e : processorsByArtifactType.entrySet()) {
+ Pattern pattern = (Pattern)e.getKey();
+ if (pattern.matcher(uri).matches()) {
+ processors.add(e.getValue());
+ }
+ }
+ return processors;
+ }
+
+ @SuppressWarnings("unchecked")
+ public URLArtifactProcessor<?> getProcessor(Object artifactType) {
+ Collection<URLArtifactProcessor<?>> processors = getProcessors(artifactType);
+ return processors.isEmpty() ? null : processors.iterator().next();
+ }
+
+ private static String wildcard2regex(String pattern) {
+ String wildcard = pattern;
+ if (wildcard.endsWith("/")) {
+ // Directory: xyz/ --> xyz/**
+ wildcard = wildcard + "**";
+ }
+ if (wildcard.startsWith(".")) {
+ // File extension: .xyz --> **/*.xyz
+ wildcard = "**/*" + wildcard;
+ } else if (wildcard.indexOf('/') == -1) {
+ // File name: abc.txt --> **/abc.txt
+ wildcard = "**/" + wildcard;
+ } else if (!(wildcard.startsWith("/") || wildcard.startsWith("**"))) {
+ wildcard = '/' + wildcard;
+ }
+ StringBuffer regex = new StringBuffer();
+ char[] chars = wildcard.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ switch (chars[i]) {
+ case '*':
+ if (i < chars.length - 1 && chars[i + 1] == '*') {
+ // Next char is '*'
+ if (i < chars.length - 2) {
+ if (chars[i + 2] == '/') {
+ // The wildcard is **/, it matches zero or more directories
+ regex.append("(.*/)*");
+ i += 2; // Skip */
+ } else {
+ // ** can only be followed by /
+ throw new IllegalArgumentException("** can only be used as the name for a directory");
+ }
+ } else {
+ regex.append(".*");
+ i++; // Skip next *
+ }
+ } else {
+ // Non-directory
+ regex.append("[^/]*");
+ }
+ break;
+ case '?':
+ regex.append("[^/]");
+ break;
+ case '\\':
+ case '|':
+ case '(':
+ case ')':
+ // case '[':
+ // case ']':
+ // case '{':
+ // case '}':
+ case '^':
+ case '$':
+ case '+':
+ case '.':
+ case '<':
+ case '>':
+ regex.append("\\").append(chars[i]);
+ break;
+ default:
+ regex.append(chars[i]);
+ break;
+ }
+ }
+ return regex.toString();
+ }
+
+ /**
+ * Lazily load artifact processors registered in the extension point.
+ */
+ private synchronized void loadProcessors() {
+ if (loaded)
+ return;
+
+ // Get the processor service declarations
+ Collection<ServiceDeclaration> processorDeclarations;
+ try {
+ processorDeclarations =
+ registry.getServiceDiscovery().getServiceDeclarations(URLArtifactProcessor.class.getName());
+ } catch (IOException e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+
+ for (ServiceDeclaration processorDeclaration : processorDeclarations) {
+ Map<String, String> attributes = processorDeclaration.getAttributes();
+ // Load a URL artifact processor
+ String artifactType = attributes.get("type");
+ String modelTypeName = attributes.get("model");
+
+ // Create a processor wrapper and register it
+ URLArtifactProcessor<?> processor =
+ new LazyURLArtifactProcessor(artifactType, modelTypeName, processorDeclaration, registry,
+ staxProcessor);
+ addArtifactProcessor(processor);
+ }
+
+ loaded = true;
+ }
+
+ /**
+ * A wrapper around an Artifact processor class allowing lazy loading and
+ * initialization of artifact processors.
+ */
+ private static class LazyURLArtifactProcessor implements ExtendedURLArtifactProcessor {
+
+ private ExtensionPointRegistry extensionPoints;
+ private String artifactType;
+ private String modelTypeName;
+ private ServiceDeclaration processorDeclaration;
+ private URLArtifactProcessor<?> processor;
+ private Class<?> modelType;
+ private StAXArtifactProcessor<?> staxProcessor;
+
+ LazyURLArtifactProcessor(String artifactType,
+ String modelTypeName,
+ ServiceDeclaration processorDeclaration,
+ ExtensionPointRegistry extensionPoints,
+ StAXArtifactProcessor<?> staxProcessor) {
+ this.artifactType = artifactType;
+ this.modelTypeName = modelTypeName;
+ this.processorDeclaration = processorDeclaration;
+ this.extensionPoints = extensionPoints;
+ this.staxProcessor = staxProcessor;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ @SuppressWarnings("unchecked")
+ private URLArtifactProcessor getProcessor() {
+ if (processor == null) {
+ try {
+ FactoryExtensionPoint modelFactories =
+ extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ Class<URLArtifactProcessor> processorClass =
+ (Class<URLArtifactProcessor>)processorDeclaration.loadClass();
+ try {
+ Constructor<URLArtifactProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class);
+ processor = constructor.newInstance(modelFactories);
+ } catch (NoSuchMethodException e) {
+ try {
+ Constructor<URLArtifactProcessor> constructor =
+ processorClass.getConstructor(FactoryExtensionPoint.class,
+ StAXArtifactProcessor.class);
+ processor = constructor.newInstance(modelFactories, staxProcessor);
+ } catch (NoSuchMethodException e2) {
+ Constructor<URLArtifactProcessor> constructor =
+ processorClass.getConstructor(ExtensionPointRegistry.class,
+ StAXArtifactProcessor.class);
+ processor = constructor.newInstance(extensionPoints, staxProcessor);
+ }
+ }
+ } catch (Throwable e) {
+ IllegalStateException ie = new IllegalStateException("Exception during getProcessor() for " +
+ processorDeclaration.getClassName(), e);
+ throw ie;
+ }
+ }
+ return processor;
+ }
+
+ public Object read(URL contributionURL, URI artifactURI, URL artifactURL, ProcessorContext context) throws ContributionReadException {
+ return getProcessor().read(contributionURL, artifactURI, artifactURL, context);
+ }
+
+ public Class<?> getModelType() {
+ if (modelTypeName != null && modelType == null) {
+ try {
+ modelType = processorDeclaration.loadClass(modelTypeName);
+ } catch (ClassNotFoundException e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+ }
+ return modelType;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void resolve(Object model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ getProcessor().resolve(model, resolver, context);
+ } // end method resolve
+
+ /**
+ * Preresolve phase, for ExtendedURLArtifactProcessors only
+ */
+ @SuppressWarnings("unchecked")
+ public void preResolve( Object model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ URLArtifactProcessor<?> processor = getProcessor();
+ if( processor instanceof ExtendedURLArtifactProcessor ) {
+ ((ExtendedURLArtifactProcessor)processor).preResolve(model, resolver, context);
+ } // end if
+ } // end method resolve
+
+ } // end class LazyURLArtifactProcessor
+} // end class DefaultURLArtifactProcessorExtensionPoint
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java
new file mode 100644
index 0000000000..59fa5990d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.stream.EventFilter;
+import javax.xml.stream.StreamFilter;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLReporter;
+import javax.xml.stream.XMLResolver;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.XMLEventAllocator;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.tuscany.sca.assembly.xsd.Constants;
+import org.apache.tuscany.sca.common.xml.XMLDocumentHelper;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Default implementation of an XMLInputFactory that creates validating
+ * XMLStreamReaders.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultValidatingXMLInputFactory extends ValidatingXMLInputFactory implements LSResourceResolver {
+ private ExtensionPointRegistry registry;
+ private XMLInputFactory inputFactory;
+ private DocumentBuilderFactory documentBuilderFactory;
+ private DOMImplementationLS ls;
+ private ValidationSchemaExtensionPoint schemas;
+ private MonitorFactory monitorFactory;
+ private boolean initialized;
+ private boolean hasSchemas;
+ private Schema aggregatedSchema;
+ private StAXHelper helper;
+
+ public DefaultValidatingXMLInputFactory(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.inputFactory = factoryExtensionPoint.getFactory(XMLInputFactory.class);
+ this.documentBuilderFactory = factoryExtensionPoint.getFactory(DocumentBuilderFactory.class);
+ this.schemas = registry.getExtensionPoint(ValidationSchemaExtensionPoint.class);
+ this.monitorFactory =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
+ this.helper = StAXHelper.getInstance(registry);
+ }
+
+ /**
+ * Constructs a new XMLInputFactory.
+ *
+ * @param inputFactory
+ * @param schemas
+ */
+ // FOR Test only
+ public DefaultValidatingXMLInputFactory(XMLInputFactory inputFactory, ValidationSchemaExtensionPoint schemas) {
+ this.inputFactory = inputFactory;
+ this.schemas = schemas;
+ this.registry = new DefaultExtensionPointRegistry();
+ }
+
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Throwable ex) {
+ Monitor.error(monitor, this, "contribution-validation-messages", message, ex);
+ }
+
+ private void warn(Monitor monitor, String message, Object model, Throwable ex) {
+ Monitor.warning(monitor, this, "contribution-validation-messages", message, ex);
+ }
+
+ public static final QName XSD = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "schema");
+
+ private Collection<? extends Source> aggregate(URL... urls) throws IOException, XMLStreamException {
+ if (urls.length == 1) {
+ return Collections.singletonList(new SAXSource(XMLDocumentHelper.getInputSource(urls[0])));
+ }
+ Map<String, Collection<URL>> map = new HashMap<String, Collection<URL>>();
+
+ for (URL url : urls) {
+ String tns = helper.readAttribute(url, XSD, "targetNamespace");
+ Collection<URL> collection = map.get(tns);
+ if (collection == null) {
+ collection = new HashSet<URL>();
+ map.put(tns, collection);
+ }
+ collection.add(url);
+ }
+ List<Source> sources = new ArrayList<Source>();
+ for (Map.Entry<String, Collection<URL>> e : map.entrySet()) {
+ if (e.getValue().size() == 1) {
+ sources.add(new SAXSource(XMLDocumentHelper.getInputSource(e.getValue().iterator().next())));
+ } else {
+ StringBuffer xsd = new StringBuffer("<schema xmlns=\"http://www.w3.org/2001/XMLSchema\"");
+ if (e.getKey() != null) {
+ xsd.append(" targetNamespace=\"").append(e.getKey()).append("\"");
+ }
+ xsd.append(">");
+ for (URL url : e.getValue()) {
+ xsd.append("<include schemaLocation=\"").append(url).append("\"/>");
+ }
+ xsd.append("</schema>");
+ SAXSource source = new SAXSource(new InputSource(new StringReader(xsd.toString())));
+ sources.add(source);
+ }
+ }
+ return sources;
+ }
+
+ /**
+ * Initialize the registered schemas and create an aggregated schema for
+ * validation.
+ * @param monitor TODO
+ */
+ private synchronized void initializeSchemas(Monitor monitor) {
+ if (initialized) {
+ return;
+ }
+ initialized = true;
+
+ // Load the XSDs registered in the validation schema extension point
+ try {
+ List<String> uris = schemas.getSchemas();
+ int n = uris.size();
+ if (n ==0) {
+ return;
+ } else {
+ hasSchemas = true;
+ }
+
+ URL[] urls = new URL[uris.size()];
+ for (int i = 0; i < urls.length; i++) {
+ urls[i] = new URL(uris.get(i));
+ }
+ final Collection<? extends Source> sources = aggregate(urls);
+
+ final SchemaFactory schemaFactory = newSchemaFactory();
+ DOMImplementation impl = null;
+ try {
+ impl = documentBuilderFactory.newDocumentBuilder().getDOMImplementation();
+ } catch (ParserConfigurationException e) {
+ // Ignore
+ }
+ if (impl instanceof DOMImplementationLS) {
+ ls = (DOMImplementationLS)impl;
+ schemaFactory.setResourceResolver(this);
+ }
+ // Allow privileged access to check files. Requires FilePermission
+ // in security policy.
+ try {
+ aggregatedSchema = AccessController.doPrivileged(new PrivilegedExceptionAction<Schema>() {
+ public Schema run() throws SAXException {
+ return schemaFactory.newSchema(sources.toArray(new Source[sources.size()]));
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ warn(monitor, "PrivilegedActionException", schemaFactory, (SAXException)e.getException());
+ hasSchemas = false;
+ throw (SAXException)e.getException();
+ }
+
+ } catch (SAXException e) {
+// IllegalStateException ie = new IllegalStateException(e);
+// error("IllegalStateException", schemas, ie);
+// throw ie;
+ } catch (Throwable e) {
+ //FIXME Log this, some old JDKs don't support XMLSchema validation
+ warn(monitor, e.getMessage(), schemas, e);
+ hasSchemas = false;
+ }
+ }
+
+ /**
+ * For OSGi:
+ * Create a SchemaFactory in the context of service provider classloaders
+ * @return
+ */
+ private SchemaFactory newSchemaFactory() {
+ ClassLoader cl =
+ ClassLoaderContext.setContextClassLoader(getClass().getClassLoader(),
+ registry.getServiceDiscovery(),
+ SchemaFactory.class,
+ TransformerFactory.class,
+ SAXParserFactory.class,
+ DocumentBuilderFactory.class
+ );
+ try {
+ // Create an aggregated validation schemas from all the XSDs
+ return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } finally {
+ if (cl != null) {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+ }
+
+ @Override
+ public XMLEventReader createFilteredReader(XMLEventReader arg0, EventFilter arg1) throws XMLStreamException {
+ return inputFactory.createFilteredReader(arg0, arg1);
+ }
+
+ @Override
+ public XMLStreamReader createFilteredReader(XMLStreamReader arg0, StreamFilter arg1) throws XMLStreamException {
+ return inputFactory.createFilteredReader(arg0, arg1);
+ }
+
+ @Override
+ public XMLEventReader createXMLEventReader(InputStream arg0, String arg1) throws XMLStreamException {
+ return inputFactory.createXMLEventReader(arg0, arg1);
+ }
+
+ @Override
+ public XMLEventReader createXMLEventReader(InputStream arg0) throws XMLStreamException {
+ return inputFactory.createXMLEventReader(arg0);
+ }
+
+ @Override
+ public XMLEventReader createXMLEventReader(Reader arg0) throws XMLStreamException {
+ return inputFactory.createXMLEventReader(arg0);
+ }
+
+ @Override
+ public XMLEventReader createXMLEventReader(Source arg0) throws XMLStreamException {
+ return inputFactory.createXMLEventReader(arg0);
+ }
+
+ @Override
+ public XMLEventReader createXMLEventReader(String arg0, InputStream arg1) throws XMLStreamException {
+ return inputFactory.createXMLEventReader(arg0, arg1);
+ }
+
+ @Override
+ public XMLEventReader createXMLEventReader(String arg0, Reader arg1) throws XMLStreamException {
+ return inputFactory.createXMLEventReader(arg0, arg1);
+ }
+
+ @Override
+ public XMLEventReader createXMLEventReader(XMLStreamReader arg0) throws XMLStreamException {
+ return inputFactory.createXMLEventReader(arg0);
+ }
+
+ @Override
+ public XMLStreamReader createXMLStreamReader(InputStream arg0, String arg1) throws XMLStreamException {
+ Monitor monitor = monitorFactory.getContextMonitor();
+ initializeSchemas(monitor);
+ if (hasSchemas) {
+ return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0, arg1), aggregatedSchema, monitor);
+ }else {
+ return inputFactory.createXMLStreamReader(arg0, arg1);
+ }
+ }
+
+ @Override
+ public XMLStreamReader createXMLStreamReader(InputStream arg0) throws XMLStreamException {
+ Monitor monitor = monitorFactory.getContextMonitor();
+ initializeSchemas(monitor);
+ if (hasSchemas) {
+ return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0), aggregatedSchema, monitor);
+ } else {
+ return inputFactory.createXMLStreamReader(arg0);
+ }
+ }
+
+ @Override
+ public XMLStreamReader createXMLStreamReader(Reader arg0) throws XMLStreamException {
+ Monitor monitor = monitorFactory.getContextMonitor();
+ initializeSchemas(monitor);
+ if (hasSchemas) {
+ return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0), aggregatedSchema, monitor);
+ } else {
+ return inputFactory.createXMLStreamReader(arg0);
+ }
+ }
+
+ @Override
+ public XMLStreamReader createXMLStreamReader(Source arg0) throws XMLStreamException {
+ Monitor monitor = monitorFactory.getContextMonitor();
+ initializeSchemas(monitor);
+ if (hasSchemas) {
+ return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0), aggregatedSchema, monitor);
+ } else {
+ return inputFactory.createXMLStreamReader(arg0);
+ }
+ }
+
+ @Override
+ public XMLStreamReader createXMLStreamReader(String arg0, InputStream arg1) throws XMLStreamException {
+ Monitor monitor = monitorFactory.getContextMonitor();
+ initializeSchemas(monitor);
+ if (hasSchemas) {
+ return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0, arg1), aggregatedSchema, monitor);
+ } else {
+ return inputFactory.createXMLStreamReader(arg0, arg1);
+ }
+ }
+
+ @Override
+ public XMLStreamReader createXMLStreamReader(String arg0, Reader arg1) throws XMLStreamException {
+ Monitor monitor = monitorFactory.getContextMonitor();
+ initializeSchemas(monitor);
+ if (hasSchemas) {
+ return new ValidatingXMLStreamReader(inputFactory.createXMLStreamReader(arg0, arg1), aggregatedSchema, monitor);
+ } else {
+ return inputFactory.createXMLStreamReader(arg0, arg1);
+ }
+ }
+
+ @Override
+ public XMLEventAllocator getEventAllocator() {
+ return inputFactory.getEventAllocator();
+ }
+
+ @Override
+ public Object getProperty(String arg0) throws IllegalArgumentException {
+ return inputFactory.getProperty(arg0);
+ }
+
+ @Override
+ public XMLReporter getXMLReporter() {
+ return inputFactory.getXMLReporter();
+ }
+
+ @Override
+ public XMLResolver getXMLResolver() {
+ return inputFactory.getXMLResolver();
+ }
+
+ @Override
+ public boolean isPropertySupported(String arg0) {
+ return inputFactory.isPropertySupported(arg0);
+ }
+
+ @Override
+ public void setEventAllocator(XMLEventAllocator arg0) {
+ inputFactory.setEventAllocator(arg0);
+ }
+
+ @Override
+ public void setProperty(String arg0, Object arg1) throws IllegalArgumentException {
+ inputFactory.setProperty(arg0, arg1);
+ }
+
+ @Override
+ public void setXMLReporter(XMLReporter arg0) {
+ inputFactory.setXMLReporter(arg0);
+ }
+
+ @Override
+ public void setXMLResolver(XMLResolver arg0) {
+ inputFactory.setXMLResolver(arg0);
+ }
+
+ public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
+ String key = null;
+ if("http://www.w3.org/2001/XMLSchema".equals(type)) {
+ key = namespaceURI;
+ } else if("http://www.w3.org/TR/REC-xml".equals(type)) {
+ key = publicId;
+ }
+ URL url = Constants.CACHED_XSDS.get(key);
+ if (url != null && !Constants.SCA11_NS.equals(namespaceURI)) {
+ systemId = url.toString();
+ } else if (url != null && systemId == null) {
+ systemId = url.toString();
+ }
+
+ LSInput input = ls.createLSInput();
+ input.setBaseURI(baseURI);
+ input.setPublicId(publicId);
+ input.setSystemId(systemId);
+ return input;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java
new file mode 100644
index 0000000000..4cb83cd5ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.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.sca.contribution.processor;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+/**
+ * Default implementation of an extension point for XML schemas.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultValidationSchemaExtensionPoint implements ValidationSchemaExtensionPoint {
+ private boolean enabled = true;
+ private List<String> schemas = new ArrayList<String>();
+ private boolean loaded;
+ private ExtensionPointRegistry registry;
+
+ public DefaultValidationSchemaExtensionPoint(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ super();
+ this.registry = registry;
+ if (attributes != null) {
+ String attr = attributes.get("enabled");
+ if (attr != null) {
+ enabled = Boolean.parseBoolean(attr);
+ }
+ }
+ }
+
+ public void addSchema(String uri) {
+ schemas.add(uri);
+ }
+
+ public void removeSchema(String uri) {
+ schemas.remove(uri);
+ }
+
+ /**
+ * Load schema declarations from META-INF/services/
+ * org.apache.tuscany.sca.contribution.processor.ValidationSchema files
+ */
+ private synchronized void loadSchemas() {
+ if (loaded || (!enabled))
+ return;
+
+ // Get the schema declarations
+ Collection<ServiceDeclaration> schemaDeclarations;
+ try {
+ schemaDeclarations =
+ registry.getServiceDiscovery()
+ .getServiceDeclarations("org.apache.tuscany.sca.contribution.processor.ValidationSchema");
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // TODO - temp fix to ensure that the schema tuscany-sca.xsd always comes first
+ String tuscanyScaXsd = null;
+
+ // Find each schema
+ for (ServiceDeclaration schemaDeclaration : schemaDeclarations) {
+ URL url = schemaDeclaration.getResource(schemaDeclaration.getClassName());
+ if (url == null) {
+ throw new IllegalArgumentException(new FileNotFoundException(schemaDeclaration.getClassName()));
+ }
+
+ if (url.toString().contains("tuscany-sca-1.1.xsd")) {
+ tuscanyScaXsd = url.toString();
+ } else {
+ schemas.add(url.toString());
+ }
+ }
+
+ if (tuscanyScaXsd != null) {
+ schemas.add(0, tuscanyScaXsd);
+ }
+
+ loaded = true;
+ }
+
+ public List<String> getSchemas() {
+ if (enabled) {
+ loadSchemas();
+ return schemas;
+ } else {
+ return Collections.emptyList();
+ }
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java
new file mode 100644
index 0000000000..ca579110ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.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.contribution.processor;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * Interface for extended Artifact Processors which require a pre-resolve phase prior to the resolve phase
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ExtendedArtifactProcessor<M> extends ArtifactProcessor<M> {
+
+ /**
+ * Pre-resolve references from this model to other models. Used for models where initial setup of
+ * the resolve phase is required. An example is Contribution models with imports and exports which must
+ * be set up prior to the main resolve phase
+ *
+ * @param model The model to resolve
+ * @param resolver The resolver to use to resolve referenced models
+ * @param context The context
+ */
+ void preResolve(M model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException;
+
+} // end interface
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java
new file mode 100644
index 0000000000..2639a21e41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.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.contribution.processor;
+
+
+/**
+ * An extended artifact processor that can read models from a URL.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ExtendedURLArtifactProcessor<M> extends ExtendedArtifactProcessor<M>, URLArtifactProcessor<M> {
+
+} // end interface
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
new file mode 100644
index 0000000000..132b7a8858
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
@@ -0,0 +1,283 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Implementation of an extensible StAX artifact processor.
+ *
+ * Takes a StAXArtifactProcessorExtensionPoint and delegates to the proper
+ * StAXArtifactProcessor by element QName
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleStAXArtifactProcessor implements StAXArtifactProcessor<Object> {
+ private static final Logger logger = Logger.getLogger(ExtensibleStAXArtifactProcessor.class.getName());
+ private static final String XMLSCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+ public static final QName ANY_ELEMENT = new QName(XMLSCHEMA_NS, "any");
+
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private StAXArtifactProcessorExtensionPoint processors;
+
+ /**
+ * Constructs a new ExtensibleStAXArtifactProcessor.
+ * @param processors
+ * @param inputFactory
+ * @param outputFactory
+ */
+ public ExtensibleStAXArtifactProcessor(StAXArtifactProcessorExtensionPoint processors,
+ XMLInputFactory inputFactory,
+ XMLOutputFactory outputFactory) {
+ super();
+ this.processors = processors;
+ this.inputFactory = inputFactory;
+ this.outputFactory = outputFactory;
+ if (this.outputFactory != null) {
+ this.outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ }
+ }
+
+ public ExtensibleStAXArtifactProcessor(ExtensionPointRegistry registry) {
+ super();
+ this.processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.inputFactory = factories.getFactory(XMLInputFactory.class);
+ this.outputFactory = factories.getFactory(XMLOutputFactory.class);
+ if (this.outputFactory != null) {
+ this.outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ }
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public Object read(XMLStreamReader source, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Monitor monitor = context.getMonitor();
+ // Delegate to the processor associated with the element QName
+ int event = source.getEventType();
+ if (event == XMLStreamConstants.START_DOCUMENT) {
+ source.nextTag();
+ }
+ QName name = source.getName();
+ StAXArtifactProcessor<?> processor = (StAXArtifactProcessor<?>)processors.getProcessor(name);
+ if (processor == null) {
+ Location location = source.getLocation();
+ error(monitor, "ElementCannotBeProcessed", processors, name, location);
+
+ StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT);
+ if (anyElementProcessor != null) {
+ return anyElementProcessor.read(source, context);
+ } else {
+ return null;
+ }
+ }
+ return processor.read(source, context);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void write(Object model, XMLStreamWriter outputSource, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // Delegate to the processor associated with the model type
+ if (model != null) {
+ StAXArtifactProcessor processor = processors.getProcessor(model.getClass());
+ if (processor != null) {
+ processor.write(model, outputSource, context);
+ } else {
+ if (logger.isLoggable(Level.WARNING)) {
+ logger.warning("No StAX processor is configured to handle " + model.getClass());
+ }
+ StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT);
+ if ((model instanceof Extension) && anyElementProcessor != null) {
+ anyElementProcessor.write(model, outputSource, context);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void resolve(Object model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Delegate to the processor associated with the model type
+ if (model != null) {
+ StAXArtifactProcessor processor = processors.getProcessor(model.getClass());
+ if (processor != null) {
+ processor.resolve(model, resolver, context);
+ }
+ }
+ }
+
+ /**
+ * Read a model from an InputStream.
+ * @param is The artifact InputStream
+ * @param type Model type
+ * @param context TODO
+ * @return The model
+ * @throws ContributionReadException
+ */
+ public <M> M read(InputStream is, Class<M> type, ProcessorContext context) throws ContributionReadException {
+ Monitor monitor = context.getMonitor();
+ try {
+ XMLStreamReader reader;
+ try {
+ reader = inputFactory.createXMLStreamReader(is);
+ try {
+ reader.nextTag();
+ QName name = reader.getName();
+ Object mo = read(reader, context);
+ if (type.isInstance(mo)) {
+ return type.cast(mo);
+ } else {
+ error(monitor, "UnrecognizedElementException", reader, name);
+ UnrecognizedElementException e = new UnrecognizedElementException(name);
+ throw e;
+ }
+ } catch (ContributionReadException e) {
+ Location location = reader.getLocation();
+ e.setLine(location.getLineNumber());
+ e.setColumn(location.getColumnNumber());
+ error(monitor, "ContributionReadException", reader, e);
+ throw e;
+ } finally {
+ try {
+ reader.close();
+ } catch (XMLStreamException e) {
+ // ignore
+ }
+ }
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", inputFactory, ce);
+ throw ce;
+ }
+ }
+
+ /**
+ * Write a model to an OutputStream.
+ * @param model
+ * @param os
+ * @param context
+ * @throws ContributionWriteException
+ */
+ public void write(Object model, OutputStream os, ProcessorContext context) throws ContributionWriteException {
+ try {
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(os);
+ write(model, writer, context);
+ writer.flush();
+ writer.close();
+ } catch (XMLStreamException e) {
+ ContributionWriteException cw = new ContributionWriteException(e);
+ error(context.getMonitor(), "ContributionWriteException", outputFactory, cw);
+ throw cw;
+ }
+ }
+
+ public QName getArtifactType() {
+ return null;
+ }
+
+ public Class<Object> getModelType() {
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java
new file mode 100644
index 0000000000..aa159ac629
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Implementation of an extensible StAX attribute processor.
+ *
+ * Takes a StAXAttributeProcessorExtensionPoint and delegates to the proper
+ * StAXAttributeProcessor by attribute QName
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleStAXAttributeProcessor implements StAXAttributeProcessor<Object> {
+
+ private static final Logger logger = Logger.getLogger(ExtensibleStAXAttributeProcessor.class.getName());
+ private static final String XMLSCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+ public static final QName ANY_ATTRIBUTE = new QName(XMLSCHEMA_NS, "anyAttribute");
+
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private StAXAttributeProcessorExtensionPoint processors;
+ /**
+ * Constructs a new ExtensibleStAXArtifactProcessor.
+ * @param processors
+ * @param inputFactory
+ * @param outputFactory
+ */
+ public ExtensibleStAXAttributeProcessor(StAXAttributeProcessorExtensionPoint processors,
+ XMLInputFactory inputFactory,
+ XMLOutputFactory outputFactory) {
+ super();
+ this.processors = processors;
+ this.inputFactory = inputFactory;
+ this.outputFactory = outputFactory;
+ if (this.outputFactory != null) {
+ this.outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ }
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public Object read(QName attributeName, XMLStreamReader source, ProcessorContext context) throws ContributionReadException,
+ XMLStreamException {
+ // Delegate to the processor associated with the attribute QName
+ int event = source.getEventType();
+ if (event == XMLStreamConstants.START_DOCUMENT) {
+ source.nextTag();
+ }
+
+ StAXAttributeProcessor<?> processor = null;
+
+ //lookup for registered attribute processors
+ processor = (StAXAttributeProcessor<?>)processors.getProcessor(attributeName);
+ if (processor == null) {
+ Location location = source.getLocation();
+ // Skip xsi:type, xsi:nil and xsi:schemaLocation etc
+ if (!W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(attributeName.getNamespaceURI())) {
+ if (logger.isLoggable(Level.WARNING)) {
+ logger.warning("Attribute " + attributeName + " cannot be processed. (" + location + ")");
+ }
+ warning(context.getMonitor(), "AttributeCannotBeProcessed", processors, attributeName, location);
+ }
+ } else {
+ return processor.read(attributeName, source, context);
+ }
+
+ //handle extension attributes without processors
+ processor = (StAXAttributeProcessor<?>)processors.getProcessor(ANY_ATTRIBUTE);
+ if (processor == null) {
+ Location location = source.getLocation();
+ if (logger.isLoggable(Level.WARNING)) {
+ logger.warning("Could not find Default Attribute processor !");
+ }
+ warning(context.getMonitor(), "DefaultAttributeProcessorNotAvailable", processors, ANY_ATTRIBUTE, location);
+ }
+
+ return processor == null ? null : processor.read(attributeName, source, context);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void write(Object model, XMLStreamWriter outputSource, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ if (model == null) {
+ return;
+ }
+
+ // Delegate to the processor associated with the model type
+ StAXAttributeProcessor processor = processors.getProcessor(model.getClass());
+ if (processor == null) {
+ if (!Extension.class.isInstance(model)) {
+ if (logger.isLoggable(Level.WARNING)) {
+ logger.warning("No StAX processor is configured to handle " + model.getClass());
+ }
+ warning(context.getMonitor(), "NoStaxProcessor", processors, model.getClass());
+ }
+ } else {
+ processor.write(model, outputSource, context);
+ return;
+ }
+
+ //handle extension attributes without processors
+ processor = (StAXAttributeProcessor<?>)processors.getProcessor(ANY_ATTRIBUTE);
+ if (processor == null) {
+ if (logger.isLoggable(Level.WARNING)) {
+ logger.warning("No Default StAX processor is configured to handle " + model.getClass());
+ }
+ warning(context.getMonitor(), "NoDefaultStaxProcessor", processors, model.getClass());
+ } else {
+ processor.write(model, outputSource, context);
+ return;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void resolve(Object model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Delegate to the processor associated with the model type
+ if (model != null) {
+ StAXAttributeProcessor processor = processors.getProcessor(model.getClass());
+ if (processor != null) {
+ processor.resolve(model, resolver, context);
+ }
+ }
+ }
+
+ /**
+ * Read a model from an InputStream.
+ * @param is The artifact InputStream
+ * @param type Model type
+ * @return The model
+ * @throws ContributionReadException
+ */
+ public <M> M read(InputStream is, Class<M> type) throws ContributionReadException {
+ return null;
+ }
+
+ /**
+ * Write a model to an OutputStream.
+ * @param model
+ * @param os
+ * @throws ContributionWriteException
+ */
+ public void write(Object model, OutputStream os, ProcessorContext context) throws ContributionWriteException {
+ try {
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(os);
+ write(model, writer, context);
+ writer.flush();
+ writer.close();
+ } catch (XMLStreamException e) {
+ ContributionWriteException cw = new ContributionWriteException(e);
+ error(context.getMonitor(), "ContributionWriteException", outputFactory, cw);
+ throw cw;
+ }
+ }
+
+ public QName getArtifactType() {
+ return null;
+ }
+
+ public Class<Object> getModelType() {
+ return Object.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java
new file mode 100644
index 0000000000..77940df5aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.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.sca.contribution.processor;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Implementation of an extensible URL artifact processor.
+ *
+ * Takes a URLArtifactProcessorExtensionPoint and delegates to the proper URLArtifactProcessor
+ * by either fileName or fileExtention
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleURLArtifactProcessor implements URLArtifactProcessor<Object> {
+
+ private URLArtifactProcessorExtensionPoint processors;
+
+ /**
+ * Constructs a new ExtensibleURLArtifactProcessor.
+ *
+ * @param processors
+ */
+ public ExtensibleURLArtifactProcessor(URLArtifactProcessorExtensionPoint processors) {
+ this.processors = processors;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object read(URL contributionURL, URI sourceURI, URL sourceURL, ProcessorContext context) throws ContributionReadException {
+ URLArtifactProcessor<Object> processor = null;
+ if (sourceURI != null) {
+ //try to retrieve a processor for the specific URI
+ String uri = sourceURI.toString();
+ if (!uri.startsWith("/")) {
+ uri = "/" + uri;
+ }
+ // Register the URI as the artifact type starts with /
+ processor = (URLArtifactProcessor<Object>)processors.getProcessor(uri);
+ }
+
+ /*
+ if (processor == null) {
+ // Delegate to the processor associated with file extension
+ String fileName = getFileName(sourceURL);
+
+ //try to retrieve a processor for the specific filename
+ processor = (URLArtifactProcessor<Object>)processors.getProcessor(fileName);
+ }
+
+ if (processor == null) {
+ //try to find my file type (extension)
+ String extension = sourceURL.getPath();
+
+ int extensionStart = extension.lastIndexOf('.');
+ //handle files without extension (e.g NOTICE)
+ if (extensionStart > 0) {
+ // File extensions are registered as .<extension>
+ extension = extension.substring(extensionStart);
+ processor = (URLArtifactProcessor<Object>)processors.getProcessor(extension);
+ }
+ }
+ */
+
+ if (processor == null) {
+ return null;
+ }
+ return processor.read(contributionURL, sourceURI, sourceURL, context);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void resolve(Object model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Delegate to the processor associated with the model type
+ if (model != null) {
+ URLArtifactProcessor processor = processors.getProcessor(model.getClass());
+ if (processor != null) {
+ processor.resolve(model, resolver, context);
+ }
+ }
+ }
+
+ public <M> M read(URL contributionURL, URI artifactURI, URL artifactUrl, ProcessorContext context, Class<M> type)
+ throws ContributionReadException {
+ Object mo = read(contributionURL, artifactURI, artifactUrl, context);
+ if (type.isInstance(mo)) {
+ return type.cast(mo);
+ } else {
+ UnrecognizedElementException e = new UnrecognizedElementException(null);
+ e.setResourceURI(artifactURI.toString());
+ error(context.getMonitor(), "UnrecognizedElementException", processors, artifactURI.toString());
+ throw e;
+ }
+ }
+
+ public String getArtifactType() {
+ return "";
+ }
+
+ public Class<Object> getModelType() {
+ return Object.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java
new file mode 100644
index 0000000000..d464af40f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+
+/**
+ * Context for contribution processors
+ * @tuscany.spi.extension.asclient
+ */
+public class ProcessorContext {
+ protected Contribution contribution;
+ protected Artifact artifact;
+ protected Monitor monitor;
+ protected Object parentModel;
+
+ /**
+ * @param contribution
+ * @param monitor
+ */
+ public ProcessorContext(Contribution contribution, Monitor monitor) {
+ super();
+ this.contribution = contribution;
+ this.monitor = monitor;
+ }
+
+ public ProcessorContext(Monitor monitor) {
+ super();
+ this.monitor = monitor;
+ }
+
+ public ProcessorContext(ExtensionPointRegistry registry) {
+ super();
+ MonitorFactory monitorFactory =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
+ this.monitor = monitorFactory.createMonitor();
+ }
+
+ public ProcessorContext() {
+ super();
+ this.monitor = new DefaultMonitorFactory().createMonitor();
+ }
+
+ /**
+ * Get the current contribution
+ * @return The current contribution
+ */
+ public Contribution getContribution() {
+ return contribution;
+ }
+
+ /**
+ * Set the current contribution
+ * @param contribution
+ * @return
+ */
+ public Contribution setContribution(Contribution contribution) {
+ Contribution old = this.contribution;
+ this.contribution = contribution;
+ return old;
+ }
+
+ public Monitor getMonitor() {
+ return monitor;
+ }
+
+ public Monitor setMonitor(Monitor monitor) {
+ Monitor old = this.monitor;
+ this.monitor = monitor;
+ return old;
+ }
+
+ public Object getParentModel() {
+ return parentModel;
+ }
+
+ public Object setParentModel(Object parentMObject) {
+ Object old = this.parentModel;
+ this.parentModel = parentMObject;
+ return old;
+ }
+
+ /**
+ * Get the current artifact
+ * @return The current artifact
+ */
+ public Artifact getArtifact() {
+ return artifact;
+ }
+
+ /**
+ * Set the current artifact. This should be called by URLArtifactProcessor to set the document
+ * context (such as the URI of the composite file).
+ *
+ * @param artifact The new artifact
+ * @return The old artifact
+ */
+ public Artifact setArtifact(Artifact artifact) {
+ Artifact old = this.artifact;
+ this.artifact = artifact;
+ return old;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java
new file mode 100644
index 0000000000..cbdb5c38a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.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.contribution.processor;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+
+/**
+ * An artifact processor that can read models from a StAX XMLStreamReader.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface StAXArtifactProcessor<M> extends ArtifactProcessor<M> {
+
+ /**
+ * Reads a model from an XMLStreamReader.
+ *
+ * @param reader The XMLStreamReader
+ * @param context The context
+ * @return A model representation of the input.
+ */
+ M read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException;
+
+ /**
+ * Writes a model to an XMLStreamWriter.
+ *
+ * @param model A model representing the source
+ * @param writer The XML stream writer
+ * @param context TODO
+ * @throws ContributionWriteException
+ * @throws XMLStreamException
+ */
+ void write(M model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException;
+
+ /**
+ * Returns the type of artifact handled by this artifact processor.
+ *
+ * @return The type of artifact handled by this artifact processor
+ */
+ QName getArtifactType();
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..a5c66bc1ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.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.contribution.processor;
+
+/**
+ * An extension point for StAX artifact processors.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface StAXArtifactProcessorExtensionPoint {
+ /**
+ * Add an artifact processor.
+ *
+ * @param artifactProcessor The artifact processor to add
+ */
+ void addArtifactProcessor(StAXArtifactProcessor<?> artifactProcessor);
+
+ /**
+ * Remove an artifact processor.
+ *
+ * @param artifactProcessor The artifact processor to remove
+ */
+ void removeArtifactProcessor(StAXArtifactProcessor<?> artifactProcessor);
+
+ /**
+ * Returns the processor associated with the given artifact type.
+ *
+ * @param artifactType An artifact type
+ * @return The processor associated with the given artifact type
+ */
+ <T> StAXArtifactProcessor<T> getProcessor(Object artifactType);
+
+ /**
+ * Returns the processor associated with the given model type.
+ *
+ * @param modelType A model type
+ * @return The processor associated with the given model type
+ */
+ <T> StAXArtifactProcessor<T> getProcessor(Class<T> modelType);
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java
new file mode 100644
index 0000000000..e9fca5fc4c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+
+
+/**
+ * An artifact processor that can read attributes from a StAX XMLStreamReader.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface StAXAttributeProcessor<M> extends ArtifactProcessor<M>{
+
+ /**
+ * Reads a model from an XMLStreamReader.
+ * @param reader The XMLStreamReader
+ * @param context The context
+ *
+ * @return A model representation of the input.
+ */
+ M read(QName attributeName, XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException;
+
+ /**
+ * Writes a model to an XMLStreamWriter.
+ *
+ * @param model A model representing the source
+ * @param writer The XML stream writer
+ * @param context The context
+ * @throws ContributionWriteException
+ * @throws XMLStreamException
+ */
+ void write(M model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException;
+
+ /**
+ * Returns the type of artifact handled by this artifact processor.
+ *
+ * @return The type of artifact handled by this artifact processor
+ */
+ QName getArtifactType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java
new file mode 100644
index 0000000000..dbc0a2c7bc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.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 org.apache.tuscany.sca.contribution.processor;
+
+/**
+ * An extension point for StAX artifact processors.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface StAXAttributeProcessorExtensionPoint {
+ /**
+ * Add an artifact processor.
+ *
+ * @param artifactProcessor The artifact processor to add
+ */
+ void addArtifactProcessor(StAXAttributeProcessor<?> artifactProcessor);
+
+ /**
+ * Remove an artifact processor.
+ *
+ * @param artifactProcessor The artifact processor to remove
+ */
+ void removeArtifactProcessor(StAXAttributeProcessor<?> artifactProcessor);
+
+ /**
+ * Returns the processor associated with the given artifact type.
+ *
+ * @param artifactType An artifact type
+ * @return The processor associated with the given artifact type
+ */
+ <T> StAXAttributeProcessor<T> getProcessor(Object artifactType);
+
+ /**
+ * Returns the processor associated with the given model type.
+ *
+ * @param modelType A model type
+ * @return The processor associated with the given model type
+ */
+ <T> StAXAttributeProcessor<T> getProcessor(Class<T> modelType);
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java
new file mode 100644
index 0000000000..035a753649
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.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.contribution.processor;
+
+import java.net.URI;
+import java.net.URL;
+
+
+/**
+ * An artifact processor that can read models from a URL.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface URLArtifactProcessor<M> extends ArtifactProcessor<M> {
+
+ /**
+ * Reads a model from a URL.
+ *
+ * @param contributionURL Contribution location URL
+ * @param artifactURI Artifact URI
+ * @param artifactURL Artifact location URL
+ * @param context The context
+ * @return A model representation of the input.
+ */
+ M read(URL contributionURL, URI artifactURI, URL artifactURL, ProcessorContext context) throws ContributionReadException;
+
+ /**
+ * Returns the type of artifact handled by this artifact processor.
+ *
+ * @return The type of artifact handled by this artifact processor
+ */
+ String getArtifactType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..e5b3492767
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import java.util.Collection;
+
+/**
+ * An extension point for URL artifact processors.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface URLArtifactProcessorExtensionPoint {
+ /**
+ * Add an artifact processor.
+ *
+ * @param artifactProcessor The artifact processor to add
+ */
+ void addArtifactProcessor(URLArtifactProcessor<?> artifactProcessor);
+
+ /**
+ * Remove an artifact processor.
+ *
+ * @param artifactProcessor The artifact processor to remove
+ */
+ void removeArtifactProcessor(URLArtifactProcessor<?> artifactProcessor);
+
+ /**
+ * Returns the processor associated with the given artifact type.
+ *
+ * @param artifactType An artifact type
+ * @return The processor associated with the given artifact type
+ */
+ <T> URLArtifactProcessor<T> getProcessor(Object artifactType);
+
+ /**
+ * Returns the processor associated with the given model type.
+ *
+ * @param modelType A model type
+ * @return The processor associated with the given model type
+ */
+ <T> URLArtifactProcessor<T> getProcessor(Class<T> modelType);
+
+ /**
+ * Return a collection of artifact processors that match the artifactType
+ * @param artifactType
+ * @return A collection of processors
+ */
+ Collection<URLArtifactProcessor<?>> getProcessors(Object artifactType);
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java
new file mode 100644
index 0000000000..4c6f0b7282
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.contribution.processor;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Exception that indicates an element was encountered that could not be handled.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnrecognizedElementException extends ContributionReadException {
+ private static final long serialVersionUID = 2549543622209829032L;
+ private final QName element;
+
+ /**
+ * Constructor that indicates which element could not be handled.
+ * @param element the element that could not be handled
+ */
+ public UnrecognizedElementException(QName element) {
+ super("Unrecognized element: " + element);
+ this.element = element;
+ }
+
+ /**
+ * Returns the element that could not be handled.
+ * @return the element that could not be handled.
+ */
+ public QName getElement() {
+ return element;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java
new file mode 100644
index 0000000000..8a166e42f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.contribution.processor;
+
+
+/**
+ * Exception thrown to indicate that a Content-Type is not supported by this SCA Domain.
+ * The Content-Type value supplied will be returned as the message text for this exception.
+ *
+ * FIXME Don't use as it's deprecated and replaced by UnsupportedPackageTypeException.
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public class UnsupportedContentTypeException extends ContributionException {
+ private static final long serialVersionUID = -1831797280021355672L;
+
+ /**
+ * Constructs a new UnsupportedContentTypeException.
+ *
+ * @param message
+ */
+ public UnsupportedContentTypeException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java
new file mode 100644
index 0000000000..ce94cef6a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.contribution.processor;
+
+
+/**
+ * Exception thrown to indicate that a Content-Type is not supported by this SCA Domain.
+ * The Content-Type value supplied will be returned as the message text for this exception.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnsupportedPackageTypeException extends ContributionException {
+ private static final long serialVersionUID = -1831797280021355672L;
+
+ /**
+ * Constructs a new UnsupportedPackageTypeException.
+ *
+ * @param message
+ */
+ public UnsupportedPackageTypeException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java
new file mode 100644
index 0000000000..0ad8259287
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * Base marker class for validating XML input factories.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ValidatingXMLInputFactory extends XMLInputFactory {
+
+ /**
+ * Allows the monitor to be set in lieu of the context being passed
+ * into the create methods. The base definitions of the create methods
+ * don't allow for this.
+ *
+ * @param reader the XMLStreamReader instance
+ * @param monitor the current monitor object
+ *
+ * @tuscany.spi.extension.asclient
+ */
+ public static void setMonitor(XMLStreamReader reader, Monitor monitor) {
+ if (reader instanceof ValidatingXMLStreamReader) {
+ ((ValidatingXMLStreamReader)reader).setMonitor(monitor);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java
new file mode 100644
index 0000000000..6de25d4eeb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java
@@ -0,0 +1,409 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor;
+
+import java.util.logging.Logger;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.StreamReaderDelegate;
+import javax.xml.validation.Schema;
+import javax.xml.validation.ValidatorHandler;
+
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.xml.sax.Attributes;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ *
+ * A validating XMLStreamReader that reports XMLSchema validation errors.
+ *
+ * @version $Rev$ $Date$
+ */
+class ValidatingXMLStreamReader extends StreamReaderDelegate implements XMLStreamReader {
+
+ private static final Logger logger = Logger.getLogger(ValidatingXMLStreamReader.class.getName());
+
+ private ValidatorHandler handler;
+ private Schema schema;
+ private Monitor monitor;
+
+ /**
+ * Constructs a new ValidatingXMLStreamReader.
+ *
+ * @param reader
+ * @param schema
+ * @throws XMLStreamException
+ */
+ ValidatingXMLStreamReader(XMLStreamReader reader, Schema schema, Monitor monitor) throws XMLStreamException {
+ super(reader);
+ this.monitor = monitor;
+ this.schema = schema;
+ }
+
+ void setMonitor(Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ private synchronized ValidatorHandler getHandler() throws XMLStreamException {
+ if (schema == null || handler!=null) {
+ return handler;
+ }
+ handler = schema.newValidatorHandler();
+ handler.setDocumentLocator(new LocatorAdapter());
+ try {
+ handler.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+ } catch (SAXException e) {
+ XMLStreamException xse = new XMLStreamException(e);
+ error("XMLStreamException", handler, xse);
+ throw xse;
+ }
+
+ // These validation errors are just warnings for us as we want to support
+ // running from an XML document with XSD validation errors, as long as we can
+ // get the metadata we need from the document
+ handler.setErrorHandler(new ErrorHandler() {
+ private String getMessage(SAXParseException e) {
+ return "XMLSchema validation problem in: " + getArtifactName( e.getSystemId() ) + ", line: " + e.getLineNumber() + ", column: " + e.getColumnNumber() + "\n" + e.getMessage();
+ }
+
+ public void error(SAXParseException exception) throws SAXException {
+ if (ValidatingXMLStreamReader.this.monitor == null)
+ logger.warning(getMessage(exception));
+ else
+ ValidatingXMLStreamReader.this.error("SchemaError", ValidatingXMLStreamReader.this.getClass(), getArtifactName( exception.getSystemId() ),
+ exception.getLineNumber(), exception.getColumnNumber(), exception.getMessage());
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException {
+ if (ValidatingXMLStreamReader.this.monitor == null)
+ logger.warning(getMessage(exception));
+ else
+ ValidatingXMLStreamReader.this.error("SchemaFatalError", ValidatingXMLStreamReader.this.getClass(), getArtifactName( exception.getSystemId() ),
+ exception.getLineNumber(), exception.getColumnNumber(), exception.getMessage());
+ }
+
+ public void warning(SAXParseException exception) throws SAXException {
+ if (ValidatingXMLStreamReader.this.monitor == null)
+ logger.warning(getMessage(exception));
+ else
+ ValidatingXMLStreamReader.this.warning("SchemaWarning", ValidatingXMLStreamReader.this.getClass(), getArtifactName( exception.getSystemId() ),
+ exception.getLineNumber(), exception.getColumnNumber(), exception.getMessage());
+ }
+
+ private String getArtifactName( String input ) {
+ String artifactName = null;
+ if( ValidatingXMLStreamReader.this.monitor != null ) {
+ artifactName = ValidatingXMLStreamReader.this.monitor.getArtifactName();
+ }
+ if (artifactName == null){
+ artifactName = input;
+ }
+ return artifactName;
+ }
+ });
+ return handler;
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ @Override
+ public int next() throws XMLStreamException {
+ if (getHandler() == null) {
+ return super.next();
+ }
+
+ int event = super.getEventType();
+ try {
+ if (event == START_DOCUMENT) {
+ // We need to trigger the startDocument()
+ handler.startDocument();
+ }
+ event = super.next();
+ validate(event);
+ } catch (SAXException e) {
+ XMLStreamException xse = new XMLStreamException(e.getMessage(), e);
+ error("XMLStreamException", handler, xse);
+ throw xse;
+ }
+ return event;
+ }
+
+ private void validate(int event) throws SAXException {
+ switch (event) {
+ case START_DOCUMENT:
+ handler.startDocument();
+ break;
+ case START_ELEMENT:
+ handleStartElement();
+ break;
+ case PROCESSING_INSTRUCTION:
+ handler.processingInstruction(super.getPITarget(), super.getPIData());
+ break;
+ case CHARACTERS:
+ case CDATA:
+ case SPACE:
+ case ENTITY_REFERENCE:
+ handler.characters(super.getTextCharacters(), super.getTextStart(), super.getTextLength());
+ break;
+ case END_ELEMENT:
+ handleEndElement();
+ break;
+ case END_DOCUMENT:
+ handler.endDocument();
+ break;
+ }
+ }
+
+ @Override
+ public int nextTag() throws XMLStreamException {
+ if (getHandler() == null) {
+ return super.nextTag();
+ }
+ while (true) {
+ int event = super.getEventType();
+ try {
+ if (event == START_DOCUMENT) {
+ // We need to trigger the startDocument()
+ handler.startDocument();
+ }
+ event = super.next();
+ validate(event);
+ } catch (SAXException e) {
+ XMLStreamException xse = new XMLStreamException(e);
+ error("XMLStreamException", handler, xse);
+ throw xse;
+ }
+
+ if ((event == CHARACTERS && isWhiteSpace()) // skip whitespace
+ || (event == CDATA && isWhiteSpace())
+ // skip whitespace
+ || event == SPACE
+ || event == PROCESSING_INSTRUCTION
+ || event == COMMENT) {
+ continue;
+ }
+ if (event != START_ELEMENT && event != END_ELEMENT) {
+ throw new XMLStreamException("expected start or end tag", getLocation());
+ }
+ return event;
+ }
+ }
+
+ @Override
+ public String getElementText() throws XMLStreamException {
+ if (getHandler() == null) {
+ return super.getElementText();
+ }
+
+ if (getEventType() != START_ELEMENT) {
+ return super.getElementText();
+ }
+ StringBuffer text = new StringBuffer();
+
+ for (;;) {
+ int event = next();
+ switch (event) {
+ case END_ELEMENT:
+ return text.toString();
+
+ case COMMENT:
+ case PROCESSING_INSTRUCTION:
+ continue;
+
+ case CHARACTERS:
+ case CDATA:
+ case SPACE:
+ case ENTITY_REFERENCE:
+ text.append(getText());
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ @Override
+ public NamespaceContext getNamespaceContext(){
+ return super.getNamespaceContext();
+ }
+
+ /**
+ * Handle a start element event.
+ *
+ * @throws SAXException
+ */
+ private void handleStartElement() throws SAXException {
+
+ // send startPrefixMapping events immediately before startElement event
+ int nsCount = super.getNamespaceCount();
+ for (int i = 0; i < nsCount; i++) {
+ String prefix = super.getNamespacePrefix(i);
+ if (prefix == null) { // true for default namespace
+ prefix = "";
+ }
+ handler.startPrefixMapping(prefix, super.getNamespaceURI(i));
+ }
+
+ // fire startElement
+ QName qname = super.getName();
+ String prefix = qname.getPrefix();
+ String rawname;
+ if (prefix == null || prefix.length() == 0) {
+ rawname = qname.getLocalPart();
+ } else {
+ rawname = prefix + ':' + qname.getLocalPart();
+ }
+ Attributes attrs = getAttributes();
+ handler.startElement(qname.getNamespaceURI(), qname.getLocalPart(), rawname, attrs);
+ }
+
+ /**
+ * Handle an endElement event.
+ *
+ * @throws SAXException
+ */
+ private void handleEndElement() throws SAXException {
+
+ // fire endElement
+ QName qname = super.getName();
+ handler.endElement(qname.getNamespaceURI(), qname.getLocalPart(), qname.toString());
+
+ // send endPrefixMapping events immediately after endElement event
+ // we send them in the opposite order to that returned but this is not
+ // actually required by SAX
+ int nsCount = super.getNamespaceCount();
+ for (int i = nsCount - 1; i >= 0; i--) {
+ String prefix = super.getNamespacePrefix(i);
+ if (prefix == null) { // true for default namespace
+ prefix = "";
+ }
+ handler.endPrefixMapping(prefix);
+ }
+ }
+
+ /**
+ * Get the attributes associated with the current START_ELEMENT event.
+ *
+ * @return the StAX attributes converted to org.xml.sax.Attributes
+ */
+ private Attributes getAttributes() {
+ AttributesImpl attrs = new AttributesImpl();
+
+ // add namespace declarations
+ for (int i = 0; i < super.getNamespaceCount(); i++) {
+ String prefix = super.getNamespacePrefix(i);
+ String uri = super.getNamespaceURI(i);
+ if (prefix == null) {
+ attrs.addAttribute("", "", "xmlns", "CDATA", uri);
+ } else {
+ attrs.addAttribute("", "", "xmlns:" + prefix, "CDATA", uri);
+ }
+ }
+
+ // Regular attributes
+ for (int i = 0; i < super.getAttributeCount(); i++) {
+ String uri = super.getAttributeNamespace(i);
+ if (uri == null) {
+ uri = "";
+ }
+ String localName = super.getAttributeLocalName(i);
+ String prefix = super.getAttributePrefix(i);
+ String qname;
+ if (prefix == null || prefix.length() == 0) {
+ qname = localName;
+ } else {
+ qname = prefix + ':' + localName;
+ }
+ String type = super.getAttributeType(i);
+ String value = super.getAttributeValue(i);
+
+ attrs.addAttribute(uri, localName, qname, type, value);
+ }
+
+ return attrs;
+ }
+
+ /**
+ * Adapter for mapping Locator information.
+ */
+ private final class LocatorAdapter implements Locator {
+
+ private LocatorAdapter() {
+ }
+
+ public int getColumnNumber() {
+ Location location = getLocation();
+ return location == null ? 0 : location.getColumnNumber();
+ }
+
+ public int getLineNumber() {
+ Location location = getLocation();
+ return location == null ? 0 : location.getLineNumber();
+ }
+
+ public String getPublicId() {
+ Location location = getLocation();
+ return location == null ? "" : location.getPublicId();
+ }
+
+ public String getSystemId() {
+ Location location = getLocation();
+ return location == null ? "" : location.getSystemId();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java
new file mode 100644
index 0000000000..67ec55b72e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.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.sca.contribution.processor;
+
+import java.util.List;
+
+
+/**
+ * An extension point for XML schemas used for validation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ValidationSchemaExtensionPoint {
+ /**
+ * Set the flag to control if schema validation should be enabled
+ * @param enabled
+ */
+ void setEnabled(boolean enabled);
+
+ /**
+ * Test the schema validation is enabled
+ * @return
+ */
+ boolean isEnabled();
+
+ /**
+ * Add a schema.
+ *
+ * @param uri the URI of the schema
+ */
+ void addSchema(String uri);
+
+ /**
+ * Remove a schema.
+ *
+ * @param uri the URI of the schema
+ */
+ void removeSchema(String uri);
+
+ /**
+ * Returns the list of schemas registered in the extension point.
+ * @return the list of schemas
+ */
+ List<String> getSchemas();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
new file mode 100644
index 0000000000..6e6346fe47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor.impl;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.DefaultExport;
+import org.apache.tuscany.sca.contribution.DefaultImport;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ExtendedURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.contribution.scanner.ContributionScanner;
+import org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint;
+import org.apache.tuscany.sca.contribution.scanner.impl.DirectoryContributionScanner;
+import org.apache.tuscany.sca.contribution.scanner.impl.JarContributionScanner;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * URLArtifactProcessor that handles contribution files and the artifacts they contain
+ * and returns a contribution model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionContentProcessor implements ExtendedURLArtifactProcessor<Contribution>{
+ private ContributionFactory contributionFactory;
+ private ModelResolverExtensionPoint modelResolvers;
+ private FactoryExtensionPoint modelFactories;
+ private URLArtifactProcessor<Object> artifactProcessor;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private ContributionScannerExtensionPoint scanners;
+ // Marks pre-resolve phase completed
+ private boolean preResolved = false;
+
+ public ContributionContentProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<Object> extensionProcessor) {
+ this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
+ URLArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ this.artifactProcessor = new ExtensibleURLArtifactProcessor(artifactProcessors);
+ this.extensionProcessor = extensionProcessor;
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.scanners = extensionPoints.getExtensionPoint(ContributionScannerExtensionPoint.class);
+ }
+
+ public String getArtifactType() {
+ return ".contribution/content";
+ }
+
+ public Class<Contribution> getModelType() {
+ return Contribution.class;
+ }
+
+ private File toFile(URL url) {
+ if("file".equalsIgnoreCase(url.getProtocol())) {
+ try {
+ return new File(url.toURI());
+ } catch(URISyntaxException e) {
+ return new File(url.getPath());
+ } catch(IllegalArgumentException e) {
+ // Hack for file:./a.txt or file:../a/c.wsdl
+ return new File(url.getPath());
+ }
+ }
+ return null;
+ }
+
+ public Contribution read(URL parentURL, URI contributionURI, URL contributionURL, ProcessorContext context) throws ContributionReadException {
+
+
+ // Create contribution model
+ Contribution contribution = contributionFactory.createContribution();
+ contribution.setURI(contributionURI.toString());
+ contribution.setLocation(contributionURL.toString());
+ ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
+ contribution.setModelResolver(modelResolver);
+ contribution.setUnresolved(true);
+
+ Monitor monitor = context.getMonitor();
+ monitor.pushContext("Contribution: " + contribution.getURI());
+
+ Contribution old = context.setContribution(contribution);
+ try {
+ // Create a contribution scanner
+ ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
+ if (scanner == null) {
+ File file = toFile(contributionURL);
+ if (file != null && file.isDirectory()) {
+ scanner = new DirectoryContributionScanner(contributionFactory);
+ } else {
+ scanner = new JarContributionScanner(contributionFactory);
+ }
+ }
+
+ // Scan the contribution and list the artifacts contained in it
+ boolean contributionMetadata = false;
+ List<Artifact> artifacts = scanner.scan(contribution);
+ for (Artifact artifact : artifacts) {
+ // Add the deployed artifact model to the contribution
+ modelResolver.addModel(artifact, context);
+
+ monitor.pushContext("Artifact: " + artifact.getURI());
+
+ Artifact oldArtifact = context.setArtifact(artifact);
+ try {
+ // Read each artifact
+ URL artifactLocationURL = null;
+ try {
+ artifactLocationURL = new URL(artifact.getLocation());
+ } catch(MalformedURLException e) {
+ //ignore
+ }
+
+ Object model = artifactProcessor.read(contributionURL, URI.create(artifact.getURI()), artifactLocationURL, context);
+ if (model != null) {
+ artifact.setModel(model);
+
+ // Add the loaded model to the model resolver
+ modelResolver.addModel(model, context);
+
+ // Merge contribution metadata into the contribution model
+ if (model instanceof ContributionMetadata) {
+ contributionMetadata = true;
+ ContributionMetadata c = (ContributionMetadata)model;
+ contribution.getImports().addAll(c.getImports());
+ contribution.getExports().addAll(c.getExports());
+ contribution.getDeployables().addAll(c.getDeployables());
+ contribution.getExtensions().addAll(c.getExtensions());
+ contribution.getAttributeExtensions().addAll(c.getAttributeExtensions());
+ }
+ }
+ } finally {
+ monitor.popContext();
+ context.setArtifact(oldArtifact);
+ }
+ }
+
+ List<Artifact> contributionArtifacts = contribution.getArtifacts();
+ contributionArtifacts.addAll(artifacts);
+
+ // If no sca-contribution.xml file was provided then just consider
+ // all composites in the contribution as deployables
+ if (!contributionMetadata) {
+ for (Artifact artifact: artifacts) {
+ if (artifact.getModel() instanceof Composite) {
+ contribution.getDeployables().add((Composite)artifact.getModel());
+ }
+ }
+
+ // Add default contribution import and export
+ DefaultImport defaultImport = contributionFactory.createDefaultImport();
+ defaultImport.setModelResolver(new DefaultModelResolver());
+ contribution.getImports().add(defaultImport);
+ DefaultExport defaultExport = contributionFactory.createDefaultExport();
+ contribution.getExports().add(defaultExport);
+ } else {
+ if (contribution.getDeployables().size() > 0) {
+ // Update the deployable Composite objects with the correct Composite object for the artifact
+ for (Artifact a : contribution.getArtifacts()) {
+ if (a.getModel() instanceof Composite) {
+ for (ListIterator<Composite> lit = contribution.getDeployables().listIterator(); lit.hasNext();) {
+ if (lit.next().getName().equals(((Composite)a.getModel()).getName())) {
+ lit.set((Composite)a.getModel());
+ }
+ }
+ }
+ }
+ }
+ }
+ } finally {
+ monitor.popContext();
+ context.setContribution(old);
+ }
+
+ return contribution;
+ }
+
+ /**
+ * A pre-resolution step, which is required for Contributions to handle the resolution of imports and exports so that
+ * at resolve time, imports can be followed to exports and anything exported that is required can be resolved on demand
+ * without the need to have already resolved the whole of the Contribution containing the export
+ * @param contribution - the Contribution
+ * @param resolver - the Resolver to use
+ * @throws ContributionResolveException
+ */
+ public void preResolve(Contribution contribution, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // Resolve the contribution model itself
+ ModelResolver contributionResolver = contribution.getModelResolver();
+ contribution.setUnresolved(false);
+ contributionResolver.addModel(contribution, context);
+
+ // Resolve Exports
+ resolveExports(contribution, contributionResolver, context);
+ // Resolve Imports
+ resolveImports(contribution, contributionResolver, context);
+
+ preResolved = true;
+ } // end method preResolve
+
+ public void resolve(Contribution contribution, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ Monitor monitor = context.getMonitor();
+ Contribution old = context.setContribution(contribution);
+ try {
+ monitor.pushContext("Contribution: " + contribution.getURI());
+
+ if( !preResolved ) preResolve( contribution, resolver, context);
+ ModelResolver contributionResolver = contribution.getModelResolver();
+
+ // Validate Java Exports: [JCI100007] A Java package that is specified on an export
+ // element MUST be contained within the contribution containing the export element.
+ for (Export export: contribution.getExports()) {
+ if (export instanceof JavaExport) {
+ boolean available = false;
+ String packageName = ((JavaExport)export).getPackage();
+ for (Artifact artifact : contribution.getArtifacts()) {
+ if (packageName.equals(artifact.getURI().replace("/", ".")))
+ available = true;
+ }
+ if (! available)
+ throw new ContributionResolveException("[JCI100007] A Java package "+ packageName +" that is specified on an export " +
+ "element MUST be contained within the contribution containing the export element.");
+ }
+ }
+
+ // Resolve all artifact models
+ for (Artifact artifact : contribution.getArtifacts()) {
+ Object model = artifact.getModel();
+ if (model != null) {
+ Artifact oldArtifact = context.setArtifact(artifact);
+ try {
+ artifactProcessor.resolve(model, contributionResolver, context);
+ } catch (Throwable e) {
+ throw new ContributionResolveException(e);
+ } finally {
+ context.setArtifact(oldArtifact);
+ }
+ }
+ }
+
+ // Resolve deployable composites
+ List<Composite> deployables = contribution.getDeployables();
+ Artifact oldArtifact = context.setArtifact(contribution);
+ try {
+ for (int i = 0, n = deployables.size(); i < n; i++) {
+ Composite deployable = deployables.get(i);
+ Composite resolved =
+ (Composite)contributionResolver.resolveModel(Composite.class, deployable, context);
+ if (resolved != deployable) {
+ deployables.set(i, resolved);
+ }
+ } // end for
+ } finally {
+ context.setArtifact(oldArtifact);
+ }
+ } finally {
+ monitor.popContext();
+ context.setContribution(old);
+ } // end try
+ } // end method resolve
+
+ /**
+ * Resolves the Exports of the contribution
+ * @param contribution
+ * @param resolver
+ */
+ private void resolveExports(Contribution contribution, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ for (Export export: contribution.getExports()) {
+ if (export instanceof DefaultExport) {
+ // Initialize the default export's resolver
+ export.setModelResolver(resolver);
+ } else {
+ extensionProcessor.resolve(export, resolver, context);
+ } // end if
+ } // end for
+
+ } // end method resolveExports
+
+ /**
+ * Resolves the Imports of the contribution
+ * @param contribution
+ * @param resolver
+ */
+ private void resolveImports(Contribution contribution, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ for (Import import_: contribution.getImports()) {
+ extensionProcessor.resolve(import_, resolver, context);
+ } // end for
+ } // end method resolveImports
+
+} // end class ContributionContentProcessor
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java
new file mode 100644
index 0000000000..f589c6b911
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.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.contribution.processor.xml;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A Policy Processor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AnyAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor<Extension> {
+
+ private AssemblyFactory assemblyFactory;
+
+ public AnyAttributeProcessor(FactoryExtensionPoint modelFactories) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ }
+
+ public QName getArtifactType() {
+ return ExtensibleStAXAttributeProcessor.ANY_ATTRIBUTE;
+ }
+
+ public Class<Extension> getModelType() {
+ return Extension.class;
+ }
+
+ public Extension read(QName attributeName, XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ String attributeValue = reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart());
+ Extension ext = assemblyFactory.createExtension();
+ ext.setQName(attributeName);
+ ext.setAttribute(true);
+ ext.setValue(attributeValue);
+ return ext;
+ }
+
+ public void write(Extension attributeExtension, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ writer.writeAttribute(attributeExtension.getQName().getPrefix(),
+ attributeExtension.getQName().getNamespaceURI(),
+ attributeExtension.getQName().getLocalPart(),
+ attributeExtension.getValue().toString()); //for extended attributes, we can assume values
+ // are just the string representation fo the attribute
+ }
+
+ public void resolve(Extension model, ModelResolver modelResolver, ProcessorContext context) throws ContributionResolveException {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
new file mode 100644
index 0000000000..db4feeec48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.processor.xml;
+
+import java.io.StringReader;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+public class AnyElementProcessor implements StAXArtifactProcessor<Extension> {
+ private AssemblyFactory assemblyFactory;
+ private StAXHelper helper;
+
+ public AnyElementProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<Object> extensionProcessor) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.helper = StAXHelper.getInstance(extensionPoints);
+ }
+
+ public QName getArtifactType() {
+ return ExtensibleStAXArtifactProcessor.ANY_ELEMENT;
+ }
+
+ public Class<Extension> getModelType() {
+ return Extension.class;
+ }
+
+ /**
+ * Reads the contetns of the unknown elements and generates a custom
+ * implementation of XMLStreamReader i.e. XMLEventsStreamReader
+ *
+ * @param reader
+ * @return
+ * @throws XMLStreamException
+ */
+ public Extension read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ QName name = reader.getName();
+ String xml = helper.saveAsString(reader);
+ Extension ext = assemblyFactory.createExtension();
+ ext.setQName(name);
+ ext.setValue(xml);
+
+ return ext;
+ }
+
+ /**
+ * Writes unknown portions back to the writer
+ *
+ * @param model
+ * @param writer
+ */
+ public void write(Extension model, XMLStreamWriter writer, ProcessorContext context) throws XMLStreamException {
+ Object value = model.getValue();
+ if (!(value instanceof String)) {
+ return;
+ }
+ String xml = (String) value;
+ XMLStreamReader reader = helper.createXMLStreamReader(new StringReader(xml));
+ // Position the reader to the root element
+ reader.nextTag();
+ helper.save(reader, writer);
+ }
+
+ public void resolve(Extension model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java
new file mode 100644
index 0000000000..7d8f2ef1c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.resolver;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.contribution.Contribution;
+
+/**
+ * A weak reference to a class, which should be used to register classes
+ * with an ArtifactResolver and resolve these classes later.
+ *
+ * FIXME The core contribution model should not have dependencies on classes
+ * and ClassLoaders. This should move to the Java import support module.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ClassReference implements Base {
+
+ private WeakReference<Class<?>> clazz;
+ private String className;
+ private Contribution contributionContainingClass;
+
+ /**
+ * Constructs a new ClassReference.
+ *
+ * @param clazz The class reference
+ */
+ public ClassReference(Class<?> clazz) {
+ this.clazz = new WeakReference<Class<?>>(clazz);
+ this.className = clazz.getName();
+ }
+
+ /**
+ * Constructs a new ClassReference.
+ *
+ * @param className The class name
+ */
+ public ClassReference(String className) {
+ this.className = className;
+ }
+
+ /**
+ * Get the referenced class.
+ *
+ * @return The referenced class
+ */
+ public Class<?> getJavaClass() {
+ if (clazz != null) {
+ return clazz.get();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Get the referenced class name.
+ *
+ * @return The class name
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ public boolean isUnresolved() {
+ return clazz == null;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public int hashCode() {
+ return className.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else {
+ if (obj instanceof ClassReference) {
+ return className.equals(((ClassReference)obj).className);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * A Java class may reference a WSDL file via a JAXWS annotation. We need to resolve
+ * the WSDL file location in the context of the same contribution that holds the
+ * Java file. In order to do this we need to pass back the actual contribution that
+ * was used to resolve a Java class. It's possible that multiple contributions hold
+ * the same class so just scanning the artifacts in all the contribution is not good
+ * enough
+ *
+ * @return
+ */
+ public Contribution getContributionContainingClass() {
+ return contributionContainingClass;
+ }
+
+ public void setContributionContainingClass(
+ Contribution contributionContainingClass) {
+ this.contributionContainingClass = contributionContainingClass;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java
new file mode 100644
index 0000000000..e17dd176a6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.resolver;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+
+/**
+ * A model resolver implementation that delegates to a list of model resolvers.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultDelegatingModelResolver implements ModelResolver {
+
+ private List<ModelResolver> resolvers;
+
+ public DefaultDelegatingModelResolver(List<ModelResolver> resolvers) {
+ this.resolvers = resolvers;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ //TODO optimize and cache results of the resolution later
+
+ // Go over all resolvers
+ for (ModelResolver resolver: resolvers) {
+
+ Object resolved = resolver.resolveModel(modelClass, unresolved, context);
+
+ // Return the resolved model object
+ if (resolved instanceof Base) {
+ if (!((Base)resolved).isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+
+ // Model object was not resolved
+ return unresolved;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java
new file mode 100644
index 0000000000..7745253bba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.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.sca.contribution.resolver;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+
+/**
+ * A model resolver implementation that considers Exports in a list of contributions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultImportAllModelResolver implements ModelResolver {
+
+ private Import import_;
+ private List<Contribution> contributions;
+
+ public DefaultImportAllModelResolver(Import import_, List<Contribution> contributions) {
+ this.import_ = import_;
+ this.contributions = contributions;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ //TODO optimize and cache results of the resolution later
+
+ // Go over all available contributions
+ for (Contribution contribution : contributions) {
+
+ // Go over all exports in the contribution
+ for (Export export : contribution.getExports()) {
+
+ // If the export matches the export, try to resolve the model object
+ if (import_.match(export)) {
+ Object resolved = export.getModelResolver().resolveModel(modelClass, unresolved, context);
+
+ // Return the resolved model object
+ if (resolved instanceof Base) {
+ if (!((Base)resolved).isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+ }
+
+ // Model object was not resolved
+ return unresolved;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java
new file mode 100644
index 0000000000..8a11cb42f8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.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.contribution.resolver;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+
+/**
+ * A model resolver implementation that delegates to a list of exports.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultImportModelResolver implements ModelResolver {
+
+ private List<Export> exports;
+
+ public DefaultImportModelResolver(List<Export> exports) {
+ this.exports = exports;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ throw new IllegalStateException();
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ //TODO optimize and cache results of the resolution later
+
+ // Go over all exports
+ for (Export export: exports) {
+
+ Object resolved = export.getModelResolver().resolveModel(modelClass, unresolved, context);
+
+ // Return the resolved model object
+ if (resolved instanceof Base) {
+ if (!((Base)resolved).isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+
+ // Model object was not resolved
+ return unresolved;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
new file mode 100644
index 0000000000..94b2fb0058
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.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.sca.contribution.resolver;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DefaultImport;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A default implementation of a model resolver based on a map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultModelResolver implements ModelResolver {
+
+ private Contribution contribution;
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ public DefaultModelResolver() {
+ }
+
+ public DefaultModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+
+ // Return the resolved object
+ return modelClass.cast(resolved);
+
+ } else {
+
+ // by default try and resolve through a default import
+ // if there is one.
+ if (contribution != null){
+ for (Import _import : contribution.getImports()){
+ if (_import instanceof DefaultImport){
+ resolved = _import.getModelResolver().resolveModel(modelClass, unresolved, context);
+ if (resolved != unresolved){
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+
+ // Return the unresolved object
+ return unresolved;
+ }
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(resolved);
+ }
+
+ // FIXME: TUSCANY-2499: temporarily give access to the models to get the jms binding
+ // use of definitions.xml working while the definitions.xml processing is being refactored
+ public Map<Object, Object> getModels() {
+ return map;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
new file mode 100644
index 0000000000..a1eb85edca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.resolver;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+
+/**
+ * The default implementation of a model resolver extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultModelResolverExtensionPoint implements ModelResolverExtensionPoint {
+
+ private final Map<Class<?>, Class<? extends ModelResolver>> resolvers = new HashMap<Class<?>, Class<? extends ModelResolver>>();
+ private Map<String, ServiceDeclaration> loadedResolvers;
+ private ExtensionPointRegistry registry;
+
+ /**
+ * Constructs a new DefaultModelResolverExtensionPoint.
+ */
+ public DefaultModelResolverExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public void addResolver(Class<?> modelType, Class<? extends ModelResolver> resolver) {
+ resolvers.put(modelType, resolver);
+ }
+
+ public void removeResolver(Class<?> modelType) {
+ resolvers.remove(modelType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class<? extends ModelResolver> getResolver(Class<?> modelType) {
+ loadModelResolvers();
+
+ Class<?>[] classes = modelType.getInterfaces();
+ for (Class<?> c : classes) {
+ Class<? extends ModelResolver> resolver = resolvers.get(c);
+ if (resolver == null) {
+ ServiceDeclaration resolverClass = loadedResolvers.get(c.getName());
+ if (resolverClass != null) {
+ try {
+ return (Class<? extends ModelResolver>)resolverClass.loadClass();
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ } else {
+ return resolver;
+ }
+ }
+
+ Class<? extends ModelResolver > resolver = resolvers.get(modelType);
+ if (resolver == null) {
+ ServiceDeclaration resolverClass = loadedResolvers.get(modelType.getName());
+ if (resolverClass != null) {
+ try {
+ return (Class<? extends ModelResolver>)resolverClass.loadClass();
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ }
+ return resolver;
+ }
+
+ /**
+ * Dynamically load model resolvers declared under META-INF/services
+ */
+ private synchronized void loadModelResolvers() {
+ if (loadedResolvers != null)
+ return;
+ loadedResolvers = new HashMap<String, ServiceDeclaration>();
+
+ // Get the model resolver service declarations
+ Collection<ServiceDeclaration> modelResolverDeclarations;
+ try {
+ modelResolverDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ModelResolver.class, true);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ List<ServiceDeclaration> list = new ArrayList<ServiceDeclaration>(modelResolverDeclarations);
+
+ // Load model resolvers, add entries from lower ranking to higher ranking so that higher ranking ones override
+ // the map
+ for (int i = list.size() - 1; i >= 0; i--) {
+ ServiceDeclaration modelResolverDeclaration = list.get(i);
+ Map<String, String> attributes = modelResolverDeclaration.getAttributes();
+ String model = attributes.get("model");
+ // The model can be a list of interfaces so that one model resolver can be used
+ // to resolve different types of models
+ if (model != null) {
+ StringTokenizer tokenizer = new StringTokenizer(model);
+ while (tokenizer.hasMoreTokens()) {
+ String key = tokenizer.nextToken();
+ loadedResolvers.put(key, modelResolverDeclaration);
+ }
+
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
new file mode 100644
index 0000000000..72e4b03c7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.resolver;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * An implementation of an extensible model resolver which delegates to the
+ * proper resolver extension based on the class of the model to resolve.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleModelResolver implements ModelResolver {
+ private final ModelResolverExtensionPoint resolverExtensions;
+ private final FactoryExtensionPoint modelFactories;
+ private final Contribution contribution;
+ private ModelResolver defaultResolver;
+ private final Map<Class<?>, ModelResolver> resolversByModelType = new HashMap<Class<?>, ModelResolver>();
+ private final Map<Class<?>, ModelResolver> resolversByImplementationClass = new HashMap<Class<?>, ModelResolver>();
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+ private Object lastUnresolved;
+
+ /**
+ * Constructs an extensible model resolver
+ *
+ * @param resolverExtensions
+ * @param contribution
+ * @param modelFactories
+ */
+ public ExtensibleModelResolver(Contribution contribution,
+ ModelResolverExtensionPoint resolverExtensions,
+ FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ this.resolverExtensions = resolverExtensions;
+ this.modelFactories = modelFactories;
+ }
+
+ /**
+ * Returns the proper resolver instance based on the interfaces of the model
+ * If one is not available on the registry, instantiate on demand
+ *
+ * @param modelType
+ * @return
+ */
+ private ModelResolver getModelResolverInstance(Class<?> modelType) {
+ // Look up a model resolver instance for the model class or
+ // each implemented interface
+ Class<?>[] interfaces = modelType.getInterfaces();
+ Class<?>[] classes = new Class<?>[interfaces.length + 1];
+ classes[0] = modelType;
+ if (interfaces.length != 0) {
+ System.arraycopy(interfaces, 0, classes, 1, interfaces.length);
+ }
+ for (Class<?> c : classes) {
+
+ // Look up an existing model resolver instance
+ ModelResolver resolverInstance = resolversByModelType.get(c);
+ if (resolverInstance != null) {
+ return resolverInstance;
+ }
+
+ // We don't have an instance, lookup a model resolver class
+ // and instantiate it
+ Class<? extends ModelResolver> resolverClass = resolverExtensions.getResolver(c);
+ if (resolverClass != null) {
+
+ // Construct the model resolver instance and cache it
+ resolverInstance = resolversByImplementationClass.get(resolverClass);
+ if (resolverInstance != null) {
+ resolversByModelType.put(c, resolverInstance);
+ return resolverInstance;
+ }
+ try {
+ Constructor<? extends ModelResolver> constructor =
+ resolverClass
+ .getConstructor(new Class[] {Contribution.class, FactoryExtensionPoint.class});
+ if (constructor != null) {
+
+ resolverInstance = constructor.newInstance(contribution, modelFactories);
+ resolversByImplementationClass.put(resolverClass, resolverInstance);
+ resolversByModelType.put(c, resolverInstance);
+ return resolverInstance;
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ ModelResolver resolver = getModelResolverInstance(resolved.getClass());
+ if (resolver != null) {
+ resolver.addModel(resolved, context);
+ } else {
+ map.put(resolved, resolved);
+ }
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ ModelResolver resolver = getModelResolverInstance(resolved.getClass());
+ if (resolver != null) {
+ return resolver.removeModel(resolved, context);
+ } else {
+ return map.remove(resolved);
+ }
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ // Protect against dependency cycles causing infinite recursion
+ // Save the current unresolved object and check later if we are trying
+ // to resolve the same object again
+ if (unresolved == lastUnresolved) {
+ return unresolved;
+ }
+ lastUnresolved = unresolved;
+
+ ModelResolver resolver = getModelResolverInstance(unresolved.getClass());
+ if (resolver != null) {
+ Object resolved = resolver.resolveModel(modelClass, unresolved, context);
+ if (resolved != null && resolved != unresolved) {
+ lastUnresolved = null;
+ return modelClass.cast(resolved);
+ }
+ } else {
+ //FIXME Remove this default resolver, this is currently used to resolve policy declarations
+ // but they should be handled by the contribution import/export mechanism instead of this
+ // defaultResolver hack.
+ if (defaultResolver != null) {
+ Object resolved = defaultResolver.resolveModel(modelClass, unresolved, context);
+ if (resolved != null && resolved != unresolved) {
+ lastUnresolved = null;
+ return modelClass.cast(resolved);
+ }
+ }
+
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+ // Return the resolved object
+ lastUnresolved = null;
+ return modelClass.cast(resolved);
+ }
+ }
+
+ return unresolved;
+ }
+
+ // FIXME: TUSCANY-2499: temporarily give access to the defaultResolver to get the jms binding
+ // use of definitions.xml working while the definitions.xml processing is being refactored
+ public ModelResolver getDefaultModelResolver() {
+ return defaultResolver;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java
new file mode 100644
index 0000000000..c0267261f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.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.sca.contribution.resolver;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+
+/**
+ * A model resolver, responsible for resolving models in the scope of an
+ * SCA contribution.
+ *
+ * SCA Assemblies reference artifacts of a wide variety of types. These
+ * include:
+ * <ul>
+ * <li> Reference from one SCA composite to another SCA composite
+ * <li> Reference to PolicySet files
+ * <li> Reference to interface definition files, either WSDL or Java interfaces
+ * <li> Reference to XSD files
+ * <li> Reference to any of a wide variety of implementation artifact files,
+ * including Java classes, BPEL scripts, C++ DLLs and classes, PHP scripts
+ * </ul>
+ *
+ * In the SCA assemblies, these various artifacts are referenced using either
+ * QNames or logical URIs. Model resolvers are used to resolve these references
+ * and get the in-memory models representing the referenced artifacts.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ModelResolver {
+
+ /**
+ * Resolve the model representing an artifact.
+ *
+ * @param modelClass the type of artifact
+ * @param unresolved the unresolved model
+ * @param context The context
+ * @return the resolved model
+ */
+ <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context);
+
+ /**
+ * Add a resolved model.
+ *
+ * @param resolved The model
+ * @param context
+ */
+ void addModel(Object resolved, ProcessorContext context);
+
+ /**
+ * Remove a resolved model.
+ *
+ * @param resolved
+ * @param context
+ * @return The removed model, or null if the model was not removed
+ */
+ Object removeModel(Object resolved, ProcessorContext context);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java
new file mode 100644
index 0000000000..4a25059792
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.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.contribution.resolver;
+
+
+/**
+ * An extension point for model resolvers
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ModelResolverExtensionPoint {
+
+ /**
+ * Register a model resolver class using the model type as the key
+ *
+ * @param modelType The model type
+ * @param resolver The model resolver Class
+ */
+ void addResolver(Class<?> modelType, Class <? extends ModelResolver> resolver);
+
+ /**
+ * Remove the model resolver class for a specific model type
+ *
+ * @param modelType The model type
+ */
+ void removeResolver(Class<?> modelType);
+
+ /**
+ * Retrieve a model resolver class for a specific model type
+ *
+ * @param modelType The model artifact type
+ * @return The model resolver Class
+ */
+ Class <? extends ModelResolver> getResolver(Class<?> modelType);
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java
new file mode 100644
index 0000000000..bcf146cbfe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.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.sca.contribution.resolver;
+
+/**
+ * Extension to assembly model implementations to provide a model resolver.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ResolverExtension {
+
+ /**
+ * Returns the model resolver for the models representing the artifacts
+ * visible in the scope of this contribution.
+ *
+ * @return The model resolver
+ */
+ ModelResolver getModelResolver();
+
+ /**
+ * Sets the model resolver for the models representing the artifacts
+ * visible in the scope of this contribution.
+ *
+ * @param modelResolver The model resolver
+ */
+ void setModelResolver(ModelResolver modelResolver);
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java
new file mode 100644
index 0000000000..dfe8f08719
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.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.sca.contribution.resolver;
+
+import java.net.URL;
+
+/**
+ * A resource URL, which should be used to register resources
+ * with an ArtifactResolver and resolve these resources later.
+ *
+ * FIXME Don't use as its deprecated, use Artifact instead.
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public class ResourceReference {
+
+ private URL resourceURL;
+ private String resourceName;
+
+ /**
+ * Constructs a new ResourceReference.
+ *
+ * @param resourceName Name of resource
+ * @param resourceURL The resource URL
+ */
+ public ResourceReference(String resourceName, URL resourceURL) {
+ this.resourceURL = resourceURL;
+ this.resourceName = resourceName;
+ }
+
+ /**
+ * Constructs a new ResourceReference.
+ *
+ * @param resourceName Name of resource
+ */
+ public ResourceReference(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ /**
+ * Get the resource URL.
+ *
+ * @return The resource URL
+ */
+ public URL getResource() {
+ return resourceURL;
+ }
+
+ /**
+ * Get the resource name.
+ *
+ * @return The resource name
+ */
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ /**
+ * Returns true if the resource reference is unresolved.
+ *
+ * @return Whether or not the resource has been resolved
+ */
+ public boolean isUnresolved() {
+ return resourceURL == null;
+ }
+
+ @Override
+ public int hashCode() {
+ return resourceName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else {
+ if (obj instanceof ResourceReference) {
+ return resourceName.equals(((ResourceReference)obj).resourceName);
+ } else {
+ return false;
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java
new file mode 100644
index 0000000000..91697111af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.contribution.scanner;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+
+/**
+ * Interface for contribution package scanners
+ *
+ * Contribution scanners understand the format of the contribution and how to get the
+ * artifacts in the contribution.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ContributionScanner {
+
+ /**
+ * Returns the type of package supported by this package scanner.
+ *
+ * @return the package type
+ */
+ String getContributionType();
+
+ /**
+ * Returns a list of artifacts in the contribution.
+ *
+ * @param contribution Contribution URL
+ * @return List of artifact populated with URIs and location URL
+ * @throws ContributionReadException
+ * @throws IOException
+ */
+ List<Artifact> scan(Contribution contribution) throws ContributionReadException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java
new file mode 100644
index 0000000000..1ca9def4ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.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.contribution.scanner;
+
+/**
+ * An extension point for contribution scanners
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContributionScannerExtensionPoint {
+
+ /**
+ * Add a ContributionScanner using the contribution type as the key.
+ *
+ * @param scanner The contribution scanner
+ */
+ void addContributionScanner(ContributionScanner scanner);
+
+ /**
+ * Remove a ContributionScanner.
+ *
+ * @param scanner The contribution scanner
+ */
+ void removeContributionScanner(ContributionScanner scanner);
+
+ /**
+ * Returns the ContributionScanner for the given contribution type.
+ *
+ * @param contributionType The contribution type
+ * @return The contribution scanner
+ */
+ ContributionScanner getContributionScanner(String contributionType);
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
new file mode 100644
index 0000000000..c5aed5ccd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.scanner;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+/**
+ * Default implementation of a contribution scanner extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultContributionScannerExtensionPoint implements ContributionScannerExtensionPoint {
+
+ private Map<String, ContributionScanner> scanners = new HashMap<String, ContributionScanner>();
+ private boolean loaded;
+ private ExtensionPointRegistry registry;
+
+ public DefaultContributionScannerExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public void addContributionScanner(ContributionScanner scanner) {
+ scanners.put(scanner.getContributionType(), scanner);
+ }
+
+ public void removeContributionScanner(ContributionScanner scanner) {
+ scanners.remove(scanner.getContributionType());
+ }
+
+ public ContributionScanner getContributionScanner(String contentType) {
+ loadScanners();
+ return scanners.get(contentType);
+ }
+
+ private synchronized void loadScanners() {
+ if (loaded)
+ return;
+
+ // Get the scanner service declarations
+ Collection<ServiceDeclaration> scannerDeclarations;
+ try {
+ scannerDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ContributionScanner.class.getName());
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration scannerDeclaration: scannerDeclarations) {
+ Map<String, String> attributes = scannerDeclaration.getAttributes();
+
+ // Load a URL artifact scanner
+ String contributionType = attributes.get("type");
+
+ // Create a scanner wrapper and register it
+ ContributionScanner scanner = new LazyContributionScanner(registry, contributionType, scannerDeclaration);
+ addContributionScanner(scanner);
+ }
+
+ loaded = true;
+ }
+
+ /**
+ * A facade for contribution scanners.
+ */
+ private static class LazyContributionScanner implements ContributionScanner {
+ private ExtensionPointRegistry registry;
+ private ServiceDeclaration scannerDeclaration;
+ private String contributionType;
+ private ContributionScanner scanner;
+ private ContributionFactory contributionFactory;
+
+ private LazyContributionScanner(ExtensionPointRegistry registry, String contributionType, ServiceDeclaration scannerDeclaration) {
+ this.registry = registry;
+ this.scannerDeclaration = scannerDeclaration;
+ this.contributionType = contributionType;
+
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.contributionFactory = factories.getFactory(ContributionFactory.class);
+ }
+
+ public List<Artifact> scan(Contribution contributionSourceURL) throws ContributionReadException {
+ return getScanner().scan(contributionSourceURL);
+ }
+
+ public String getContributionType() {
+ return contributionType;
+ }
+
+ private ContributionScanner getScanner() {
+ if (scanner == null) {
+ try {
+ Class<ContributionScanner> scannerClass = (Class<ContributionScanner>)scannerDeclaration.loadClass();
+ Constructor<ContributionScanner> constructor = scannerClass.getConstructor(ContributionFactory.class);
+ scanner = constructor.newInstance(contributionFactory);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return scanner;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java
new file mode 100644
index 0000000000..0800dfaac5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.scanner.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.PackageType;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.scanner.ContributionScanner;
+
+/**
+ * Folder contribution processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DirectoryContributionScanner implements ContributionScanner {
+ private ContributionFactory contributionFactory;
+
+ public DirectoryContributionScanner(ContributionFactory contributionFactory) {
+ this.contributionFactory = contributionFactory;
+ }
+
+ public String getContributionType() {
+ return PackageType.FOLDER;
+ }
+
+ public List<Artifact> scan(Contribution contribution) throws ContributionReadException {
+ File directory = directory(contribution);
+ List<Artifact> artifacts = new ArrayList<Artifact>();
+ List<String> artifactURIs = scanContributionArtifacts(contribution);
+ for(String uri : artifactURIs) {
+ try {
+ File file = new File(directory, uri);
+
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(uri);
+ artifact.setLocation(file.toURI().toURL().toString());
+
+ artifacts.add(artifact);
+ } catch (MalformedURLException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ contribution.getTypes().add(getContributionType());
+ return artifacts;
+ }
+
+
+ /**
+ * Scan the contribution to retrieve all artifact uris
+ *
+ * @param contribution
+ * @return
+ * @throws ContributionReadException
+ */
+ private List<String> scanContributionArtifacts(Contribution contribution) throws ContributionReadException {
+ File directory = directory(contribution);
+ List<String> artifacts = new ArrayList<String>();
+ // [rfeng] There are cases that the folder contains symbolic links that point to the same physical directory
+ Set<File> visited = new HashSet<File>();
+ try {
+ traverse(artifacts, directory, directory, visited);
+ } catch (IOException e) {
+ throw new ContributionReadException(e);
+ }
+
+ return artifacts;
+ }
+
+ /**
+ * Recursively traverse a root directory
+ *
+ * @param fileList
+ * @param file
+ * @param root
+ * @param visited The visited directories
+ * @throws IOException
+ */
+ private static void traverse(List<String> fileList, File file, File root, Set<File> visited) throws IOException {
+ if (file.isFile()) {
+ fileList.add(root.toURI().relativize(file.toURI()).toString());
+ } else if (file.isDirectory()) {
+ File dir = file.getCanonicalFile();
+ if (!visited.contains(dir)) {
+ // [rfeng] Add the canonical file into the visited set to avoid duplicate navigation of directories
+ // following the symbolic links
+ visited.add(dir);
+ String uri = root.toURI().relativize(file.toURI()).toString();
+ if (uri.endsWith("/")) {
+ uri = uri.substring(0, uri.length() - 1);
+ }
+ fileList.add(uri);
+
+ File[] files = file.listFiles();
+ for (File f : files) {
+ if (!f.getName().startsWith(".")) {
+ traverse(fileList, f, root, visited);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Get the contribution location as a file
+ *
+ * @param contribution
+ * @return
+ * @throws ContributionReadException
+ */
+ private File directory(Contribution contribution) throws ContributionReadException {
+ File file;
+ URI uri = null;
+ try {
+ uri = new URI(contribution.getLocation());
+ file = new File(uri);
+ } catch (URISyntaxException e) {
+ throw new ContributionReadException(e);
+ } catch(IllegalArgumentException e) {
+ // Hack for file:./a.txt or file:../a/c.wsdl
+ return new File(uri.getPath());
+ }
+ if (!file.exists() || !file.isDirectory()) {
+ throw new ContributionReadException(contribution.getLocation());
+ }
+ return file;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.java
new file mode 100644
index 0000000000..25be92c310
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.scanner.impl;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.PackageType;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.scanner.ContributionScanner;
+
+/**
+ * JAR Contribution processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JarContributionScanner implements ContributionScanner {
+ private ContributionFactory contributionFactory;
+
+ public JarContributionScanner(ContributionFactory contributionFactory) {
+ this.contributionFactory = contributionFactory;
+ }
+
+ public String getContributionType() {
+ return PackageType.JAR;
+ }
+
+ public List<Artifact> scan(Contribution contribution) throws ContributionReadException {
+
+ // Assume the URL references a JAR file
+ try {
+ URL url = new URL(contribution.getLocation());
+ JarInputStream jar = new JarInputStream(IOHelper.openStream(url));
+ try {
+ Set<String> names = new HashSet<String>();
+ while (true) {
+ JarEntry entry = jar.getNextJarEntry();
+ if (entry == null) {
+ // EOF
+ break;
+ }
+
+ String name = entry.getName();
+ if (name.length() != 0 && !name.startsWith(".")) {
+
+ // Trim trailing /
+ if (name.endsWith("/")) {
+ name = name.substring(0, name.length() - 1);
+ }
+
+ // Add the entry name
+ if (!names.contains(name)) {
+ names.add(name);
+
+ // Add parent folder names to the list too
+ for (;;) {
+ int s = name.lastIndexOf('/');
+ if (s == -1) {
+ name = "";
+ } else {
+ name = name.substring(0, s);
+ }
+ if (name.length() != 0 && !names.contains(name)) {
+ names.add(name);
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Return list of artifacts
+ List<Artifact> artifacts = new ArrayList<Artifact>();
+ for(String uri : names) {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(uri);
+ artifact.setLocation(getArtifactURL(contribution, uri).toString());
+
+ artifacts.add(artifact);
+ }
+
+ contribution.getTypes().add(getContributionType());
+ return artifacts;
+
+ } finally {
+ jar.close();
+ }
+ } catch (IOException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ /**
+ * Produces a location URL for a given artifact in the contribution
+ *
+ * @param contribution
+ * @param artifact
+ * @return
+ * @throws ContributionReadException
+ */
+ private static URL getArtifactURL(Contribution contribution, String artifact) throws ContributionReadException {
+ try {
+ URL url;
+ if (contribution.toString().startsWith("jar:")) {
+ url = new URL(new URL(contribution.getLocation()), artifact.toString());
+ } else {
+ url = new URL("jar:" + contribution.getLocation() + "!/" + artifact);
+ }
+ return url;
+ } catch (MalformedURLException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionGeneratedMetadataDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionGeneratedMetadataDocumentProcessor.java
new file mode 100644
index 0000000000..0ad3ecbd4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionGeneratedMetadataDocumentProcessor.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.contribution.xml;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * URLArtifactProcessor that handles sca-contribution-generated.xml files.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionGeneratedMetadataDocumentProcessor extends ContributionMetadataDocumentProcessor {
+
+ public ContributionGeneratedMetadataDocumentProcessor(XMLInputFactory inputFactory,
+ StAXArtifactProcessor staxProcessor) {
+ super(inputFactory, staxProcessor);
+ }
+
+ public ContributionGeneratedMetadataDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor) {
+ super(modelFactories, staxProcessor);
+ }
+
+ @Override
+ public String getArtifactType() {
+ return "/META-INF/sca-contribution-generated.xml";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java
new file mode 100644
index 0000000000..30220901a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * URLArtifactProcessor that handles sca-contribution.xml files.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionMetadataDocumentProcessor implements URLArtifactProcessor<ContributionMetadata>{
+ private final StAXArtifactProcessor staxProcessor;
+ private final XMLInputFactory inputFactory;
+
+ public ContributionMetadataDocumentProcessor(XMLInputFactory inputFactory,
+ StAXArtifactProcessor staxProcessor) {
+ this.inputFactory = inputFactory;
+ this.staxProcessor = staxProcessor;
+ }
+
+ public ContributionMetadataDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor) {
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ this.staxProcessor = staxProcessor;
+ }
+
+ public String getArtifactType() {
+ return "/META-INF/sca-contribution.xml";
+ }
+
+ public Class<ContributionMetadata> getModelType() {
+ return ContributionMetadata.class;
+ }
+
+ public ContributionMetadata read(URL contributionURL, URI uri, URL url, ProcessorContext context) throws ContributionReadException {
+ InputStream urlStream = null;
+ try {
+
+ // Create a stream reader
+ urlStream = IOHelper.openStream(url);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
+ ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
+
+ reader.nextTag();
+
+ // Read the contribution model
+ ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader, context);
+
+ return contribution;
+
+ } catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "XMLStreamException", inputFactory, ex);
+ throw ex;
+ } catch (IOException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "IOException", inputFactory, ex);
+ throw ex;
+ } finally {
+ try {
+ if (urlStream != null) {
+ urlStream.close();
+ urlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+
+ public void resolve(ContributionMetadata contribution, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ staxProcessor.resolve(contribution, resolver, context);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-xml-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
new file mode 100644
index 0000000000..823684f422
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
@@ -0,0 +1,270 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.xml;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Processor for contribution metadata
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionMetadataProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<ContributionMetadata> {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private static final QName CONTRIBUTION_QNAME = new QName(SCA11_NS, "contribution");
+ private static final QName DEPLOYABLE_QNAME = new QName(SCA11_NS, "deployable");
+
+ private final AssemblyFactory assemblyFactory;
+ private final ContributionFactory contributionFactory;
+ private final StAXArtifactProcessor<Object> extensionProcessor;
+ private final StAXAttributeProcessor<Object> attributeProcessor;
+
+
+ public ContributionMetadataProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> attributeProcessor) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.attributeProcessor = attributeProcessor;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "contribution-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(), "contribution-xml-validation-messages", Severity.ERROR,
+ model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return CONTRIBUTION_QNAME;
+ }
+
+ public Class<ContributionMetadata> getModelType() {
+ return ContributionMetadata.class;
+ }
+
+ public ContributionMetadata read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException {
+ ContributionMetadata contribution = null;
+ QName name = null;
+
+ try {
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+
+ if (CONTRIBUTION_QNAME.equals(name)) {
+
+ // Read <contribution>
+ contribution = this.contributionFactory.createContributionMetadata();
+ contribution.setSpecVersion(SCA11_NS);
+ contribution.setUnresolved(true);
+ readExtendedAttributes(reader, contribution, attributeProcessor, assemblyFactory, context);
+
+ } else if (DEPLOYABLE_QNAME.equals(name)) {
+
+ // Read <deployable>
+ QName compositeName = getQName(reader, "composite");
+ if (compositeName == null) {
+ error(context.getMonitor(), "AttributeCompositeMissing", reader);
+ //throw new ContributionReadException("Attribute 'composite' is missing");
+ } else {
+ if (contribution != null) {
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(compositeName);
+ composite.setUnresolved(true);
+ contribution.getDeployables().add(composite);
+ }
+ }
+ } else {
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null && contribution != null) {
+ if (extension instanceof Import) {
+ // The value of the @package attribute on the <import.java/> element MUST be
+ // unique across all other <import.java/> elements within the contribution.
+ if (extension instanceof JavaImport) {
+ for (Import imports : contribution.getImports()) {
+ if (imports instanceof JavaImport) {
+ if (((JavaImport)extension).getPackage().equals(((JavaImport) imports).getPackage())) {
+ error(context.getMonitor(), "DuplicateJavaImports", reader);
+ }
+ }
+ }
+ }
+ contribution.getImports().add((Import)extension);
+ } else if (extension instanceof Export) {
+ // The value of the @package attribute on the <export.java/> element MUST be
+ // unique across all other <export.java/> elements within the contribution.
+ if (extension instanceof JavaExport) {
+ for (Export exports : contribution.getExports()) {
+ if (exports instanceof JavaExport) {
+ if (((JavaExport)extension).getPackage().equals(((JavaExport) exports).getPackage())) {
+ error(context.getMonitor(), "DuplicateJavaExports", reader);
+ }
+ }
+ }
+ }
+ contribution.getExports().add((Export)extension);
+ } else {
+ contribution.getExtensions().add(extension);
+ }
+ }
+ }
+ break;
+
+ case XMLStreamConstants.END_ELEMENT:
+ if (CONTRIBUTION_QNAME.equals(reader.getName())) {
+ return contribution;
+ }
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ } catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error(context.getMonitor(), "XMLStreamException", reader, ex);
+ }
+
+ return contribution;
+ }
+
+ public void write(ContributionMetadata contribution, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write <contribution>
+ writeStartDocument(writer, CONTRIBUTION_QNAME.getNamespaceURI(), CONTRIBUTION_QNAME.getLocalPart());
+ writeExtendedAttributes(writer, contribution, attributeProcessor, context);
+
+ // Write <import>
+ for (Import imp : contribution.getImports()) {
+ extensionProcessor.write(imp, writer, context);
+ }
+
+ // Write <export>
+ for (Export export : contribution.getExports()) {
+ extensionProcessor.write(export, writer, context);
+ }
+
+ // Write <deployable>
+ for (Composite deployable : contribution.getDeployables()) {
+ writeStart(writer,
+ DEPLOYABLE_QNAME.getNamespaceURI(),
+ DEPLOYABLE_QNAME.getLocalPart(),
+ new XAttr("composite", deployable.getName()));
+ writeEnd(writer);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(ContributionMetadata contribution, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Resolve imports and exports
+ for (Export export : contribution.getExports()) {
+ extensionProcessor.resolve(export, resolver, context);
+ }
+ for (Import import_ : contribution.getImports()) {
+ extensionProcessor.resolve(import_, resolver, context);
+ }
+
+ // Resolve deployable composites
+ List<Composite> deployables = contribution.getDeployables();
+ for (int i = 0, n = deployables.size(); i < n; i++) {
+ Composite deployable = deployables.get(i);
+ Composite resolved = (Composite)resolver.resolveModel(Composite.class, deployable, context);
+ if (resolved != deployable) {
+ deployables.set(i, resolved);
+ }
+ }
+
+ for (Object ext : contribution.getExtensions()) {
+ extensionProcessor.resolve(ext, resolver, context);
+ }
+
+ contribution.setUnresolved(false);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionModelResolver.java
new file mode 100644
index 0000000000..916630939e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionModelResolver.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.contribution.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A Model Resolver for Contribution models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionModelResolver implements ModelResolver {
+
+ private Map<String, Contribution> map = new HashMap<String, Contribution>();
+
+ public ContributionModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ Contribution contribution = (Contribution)resolved;
+ map.put(contribution.getURI(), contribution);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(((Contribution)resolved).getURI());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ // Lookup a contribution for the given URI
+ String uri = ((Contribution)unresolved).getURI();
+ if (uri != null) {
+ Contribution resolved = (Contribution) map.get(uri);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+ return unresolved;
+ } else {
+
+ // If no URI was specified, just return the first contribution
+ if (!map.isEmpty()) {
+ Contribution resolved = map.values().iterator().next();
+ return modelClass.cast(resolved);
+ } else {
+ return unresolved;
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory
new file mode 100644
index 0000000000..8fc5aac46f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory
@@ -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.contribution.DefaultContributionFactory
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory
new file mode 100644
index 0000000000..6abfa4f978
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory
@@ -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.
+
+org.apache.tuscany.sca.contribution.java.impl.JavaImportExportFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory
new file mode 100644
index 0000000000..7c86815365
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory
@@ -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.
+
+org.apache.tuscany.sca.contribution.namespace.impl.NamespaceImportExportFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..bbc1421599
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.contribution.xml.ContributionMetadataProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#contribution,model=org.apache.tuscany.sca.contribution.ContributionMetadata
+org.apache.tuscany.sca.contribution.processor.xml.AnyElementProcessor;qname=http://www.w3.org/2001/XMLSchema#any,model=org.apache.tuscany.sca.assembly.Extension
+org.apache.tuscany.sca.contribution.namespace.impl.NamespaceImportProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#import,model=org.apache.tuscany.sca.contribution.namespace.NamespaceImport
+org.apache.tuscany.sca.contribution.namespace.impl.NamespaceExportProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#export,model=org.apache.tuscany.sca.contribution.namespace.NamespaceExport
+org.apache.tuscany.sca.contribution.java.impl.JavaImportProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#import.java,model=org.apache.tuscany.sca.contribution.java.JavaImport
+org.apache.tuscany.sca.contribution.java.impl.JavaExportProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#export.java,model=org.apache.tuscany.sca.contribution.java.JavaExport
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint
new file mode 100644
index 0000000000..fdd96edc20
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor
new file mode 100644
index 0000000000..d18c8e1b5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor
@@ -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 attribute processor extension
+org.apache.tuscany.sca.contribution.processor.xml.AnyAttributeProcessor;qname=http://www.w3.org/2001/XMLSchema#anyAttribute,model=org.apache.tuscany.sca.assembly.Extension
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint
new file mode 100644
index 0000000000..eef775786c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.contribution.processor.DefaultStAXAttributeProcessorExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..67b610963e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.contribution.xml.ContributionMetadataDocumentProcessor;type=/META-INF/sca-contribution.xml,model=org.apache.tuscany.sca.contribution.ContributionMetadata
+org.apache.tuscany.sca.contribution.xml.ContributionGeneratedMetadataDocumentProcessor;type=/META-INF/sca-contribution-generated.xml
+org.apache.tuscany.sca.contribution.processor.impl.ContributionContentProcessor;type=.contribution/content,model=org.apache.tuscany.sca.contribution.Contribution
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint
new file mode 100644
index 0000000000..970186b696
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory
new file mode 100644
index 0000000000..cd9bf88b23
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.contribution.processor.DefaultValidatingXMLInputFactory
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint
new file mode 100644
index 0000000000..b43db516df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..581391bbfe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -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.
+
+org.apache.tuscany.sca.contribution.xml.ContributionModelResolver;model=org.apache.tuscany.sca.contribution.Contribution
+org.apache.tuscany.sca.contribution.java.impl.ClassLoaderModelResolver;model=org.apache.tuscany.sca.contribution.resolver.ClassReference
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint
new file mode 100644
index 0000000000..f54f5c3546
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.contribution.resolver.DefaultModelResolverExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint
new file mode 100644
index 0000000000..a5186c3c6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.contribution.scanner.DefaultContributionScannerExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-java-validation-messages.properties b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-java-validation-messages.properties
new file mode 100644
index 0000000000..09fc3e9fff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-java-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+AttributePackageMissing = Attribute 'package' is missing
+XMLStreamException = XMLStreamException occured due to : {0}
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-namespace-validation-messages.properties b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-namespace-validation-messages.properties
new file mode 100644
index 0000000000..c1cbd06e7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-namespace-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+AttributeNameSpaceMissing = Attribute 'namespace' is missing
+XMLStreamException = XMLStreamException occured due to : {0}
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-validation-messages.properties b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-validation-messages.properties
new file mode 100644
index 0000000000..63c4746a4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-validation-messages.properties
@@ -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.
+#
+#
+SchemaError = XMLSchema validation error occured in: {0} ,line = {1}, column = {2}, Message = {3}
+SchemaFatalError = XMLSchema validation fatal error occured in: {0} ,line = {1}, column = {2}, Message = {3}
+SchemaWarning = XMLSchema validation warning occured in: {0} ,line = {1}, column = {2}, Message = {3}
+UnsupportedPackageTypeException = Unsupported contribution package type: {0}
+ElementCannotBeProcessed = Element {0} cannot be processed. ({1})
+AttributeCannotBeProcessed = Attribute {0} cannot be processed. ({1})
+NoStaxProcessor = No StAX processor is configured to handle {0}
+ContributionWriteException = ContributionWriteException occured due to :
+ContributionReadException = ContributionReadException occured due to :
+UnrecognizedElementException = Unrecognized Element : {0}
+IllegalArgumentException = Invalid qname: {0}
+PrivilegedActionException = PrivilegedActionException occured due to : {0}
+AttributeCannotBeProcessed = Attribute {0} cannot be processed. ({1})
+
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties
new file mode 100644
index 0000000000..d92df203e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties
@@ -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.
+#
+#
+XMLStreamException = XMLStreamException occured due to : {0}
+IOException = IOException occured due to : {0}
+AttributeCompositeMissing = Attribute 'composite' is missing
+DuplicateJavaImports = [JCI10001] The value of the @package attribute on the <import.java/> element is not unique across all other <import.java/> elements within the contribution.
+DuplicateJavaExports = [JCI10004] The value of the @package attribute on the <export.java/> element is not unique across all other <export.java/> elements within the contribution.
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
new file mode 100644
index 0000000000..8409dd9491
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.java.JavaImportExportFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test ContributionClassLoader.
+ *
+ */
+public class ContributionClassLoaderTestCase {
+
+ private static ContributionFactory contributionFactory;
+ private static JavaImportExportFactory javaImportExportFactory;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ javaImportExportFactory = modelFactories.getFactory(JavaImportExportFactory.class);
+ }
+
+ private Contribution createContribution(String fileName) throws MalformedURLException {
+ Contribution contrib = contributionFactory.createContribution();
+ File contribDir = new File(fileName);
+ contrib.setLocation(contribDir.toURI().toURL().toString());
+ ClassLoader contextClassLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ contrib.setClassLoader(new ContributionClassLoader(contrib, contextClassLoader));
+ return contrib;
+ }
+
+
+ @Test
+ public void testClassLoadingFromContribution() throws ClassNotFoundException, MalformedURLException {
+
+ Contribution contribA = createContribution("target/test-classes");
+ Contribution contribB = createContribution("target");
+ Contribution contribC = createContribution("target/test-classes/deployables/sample-calculator.jar");
+
+ // Class present in contribution, also in parent. Class is loaded from parent
+ Class<?> testClassA = contribA.getClassLoader().loadClass(this.getClass().getName());
+ Assert.assertNotNull(testClassA);
+ Assert.assertSame(this.getClass(), testClassA);
+
+ // Class not present in contribution, but present in parent ClassLoader
+ Class<?> testClassB = contribB.getClassLoader().loadClass(this.getClass().getName());
+ Assert.assertNotNull(testClassB);
+ Assert.assertSame(this.getClass(), testClassB);
+
+ // Class present in contribution, but not in parent
+ Class<?> testClassC = contribC.getClassLoader().loadClass("calculator.AddService");
+ Assert.assertNotNull(testClassC);
+
+ // Class not present in contribution or in parent
+ try {
+ contribA.getClassLoader().loadClass("NonExistent");
+
+ Assert.assertTrue("ClassNotFoundException not thrown as expected", false);
+
+ } catch (ClassNotFoundException e) {
+ }
+
+
+
+ }
+
+ @Test
+ public void testResourceLoadingFromContribution() throws ClassNotFoundException, MalformedURLException {
+
+ Contribution contribA = createContribution("target/test-classes");
+ Contribution contribB = createContribution("target");
+ Contribution contribC = createContribution("target/test-classes/deployables/sample-calculator.jar");
+
+ // Resource present in contribution, and in parent
+ URL resA = contribA.getClassLoader().getResource("deployables/sample-calculator.jar");
+ Assert.assertNotNull(resA);
+
+ // Resource not present in contribution, but present in parent ClassLoader
+ URL resB = contribB.getClassLoader().getResource("deployables/sample-calculator.jar");
+ Assert.assertNotNull(resB);
+
+ // Resource present in contribution, but not in parent
+ URL resC = contribC.getClassLoader().getResource("calculator/AddService.class");
+ Assert.assertNotNull(resC);
+
+ // Load Java class as resource from parent
+ String classResName = this.getClass().getName().replaceAll("\\.", "/") + ".class";
+ URL classResA = contribA.getClassLoader().getResource(classResName);
+ Assert.assertNotNull(classResA);
+
+ // Non-existent resource
+ URL res = contribA.getClassLoader().getResource("deployables/NonExistent");
+ Assert.assertNull(res);
+
+ }
+
+ private static String getPackageName(Class<?> cls) {
+ String name = cls.getName();
+ int index = name.lastIndexOf('.');
+ return index == -1 ? "" : name.substring(0, index);
+ }
+
+ @Test
+ public void testClassLoadingFromImportedContribution() throws ClassNotFoundException, MalformedURLException {
+
+ Contribution contribA = createContribution("target/test-classes");
+ Contribution contribB = createContribution("target");
+ Contribution contribC = createContribution("target/test-classes/deployables/sample-calculator.jar");
+ ArrayList<Contribution> exportContribList = new ArrayList<Contribution>();
+ exportContribList.add(contribA);
+ exportContribList.add(contribC);
+
+ JavaImport import_ = javaImportExportFactory.createJavaImport();
+ import_.setPackage(getPackageName(getClass()));
+ import_.setModelResolver(new JavaImportModelResolver(exportContribList, null));
+ contribB.getImports().add(import_);
+ import_ = javaImportExportFactory.createJavaImport();
+ import_.setPackage("calculator");
+ import_.setModelResolver(new JavaImportModelResolver(exportContribList, null));
+ contribB.getImports().add(import_);
+
+ JavaExport export = javaImportExportFactory.createJavaExport();
+ export.setPackage(getPackageName(getClass()));
+ contribA.getExports().add(export);
+ export = javaImportExportFactory.createJavaExport();
+ export.setPackage("calculator");
+ contribC.getExports().add(export);
+
+ // Load class from parent, class is also present in imported contribution. Class should
+ // be loaded from parent
+ Class<?> testClassB = contribB.getClassLoader().loadClass(this.getClass().getName());
+ Assert.assertNotNull(testClassB);
+ Assert.assertSame(this.getClass(), testClassB);
+
+ // Load class from parent, class is also present in parent. Class should be loaded
+ // from parent.
+ Class<?> testClassA = contribA.getClassLoader().loadClass(this.getClass().getName());
+ Assert.assertNotNull(testClassA);
+ Assert.assertSame(this.getClass(), testClassA);
+
+ // Imported class should be the same as the one loaded by the exporting contribution
+ Assert.assertSame(testClassA, testClassB);
+
+ // Load class from imported contribution, class is not present in parent
+ Class<?> testClassB1 = contribB.getClassLoader().loadClass("calculator.AddService");
+ Assert.assertNotNull(testClassB1);
+
+ // Imported class should be the same as the one loaded by the exporting contribution
+ Class<?> testClassC = contribC.getClassLoader().loadClass("calculator.AddService");
+ Assert.assertNotNull(testClassC);
+ Assert.assertSame(testClassC, testClassB1);
+
+
+ // Try to load class from package which is not explicitly imported - should throw ClassNotFoundException
+ try {
+ contribA.getClassLoader().loadClass("calculator.AddService");
+
+ Assert.assertTrue("ClassNotFoundException not thrown as expected", false);
+
+ } catch (ClassNotFoundException e) {
+ }
+
+ // Try to load non-existent class from imported package - should throw ClassNotFoundException
+ try {
+ contribB.getClassLoader().loadClass(getPackageName(getClass()) + ".NonExistentClass");
+
+ Assert.assertTrue("ClassNotFoundException not thrown as expected", false);
+
+ } catch (ClassNotFoundException e) {
+ }
+
+ }
+
+ @Test
+ public void testResourceLoadingFromImportedContribution() throws ClassNotFoundException, MalformedURLException {
+
+ Contribution contribA = createContribution("target/test-classes");
+ Contribution contribB = createContribution("target");
+ Contribution contribC = createContribution("target/test-classes/deployables/sample-calculator.jar");
+
+ ArrayList<Contribution> exportContribList = new ArrayList<Contribution>();
+ exportContribList.add(contribA);
+ exportContribList.add(contribC);
+
+ JavaImport import_ = javaImportExportFactory.createJavaImport();
+ import_.setPackage(getPackageName(getClass()));
+ import_.setModelResolver(new JavaImportModelResolver(exportContribList, null));
+ contribB.getImports().add(import_);
+ JavaImport import1_ = javaImportExportFactory.createJavaImport();
+ import1_.setPackage("calculator");
+ import1_.setModelResolver(new JavaImportModelResolver(exportContribList, null));
+ contribB.getImports().add(import1_);
+
+ JavaExport export = javaImportExportFactory.createJavaExport();
+ export.setPackage(getPackageName(getClass()));
+ contribA.getExports().add(export);
+ JavaExport export1 = javaImportExportFactory.createJavaExport();
+ export1.setPackage("calculator");
+ contribC.getExports().add(export1);
+
+
+ // Load resource from parent
+ URL resB = contribB.getClassLoader().getResource("deployables/sample-calculator.jar");
+ Assert.assertNotNull(resB);
+
+ // Load Java class as resource from imported contribution with JavaImport
+ String classResName = this.getClass().getName().replaceAll("\\.", "/") + ".class";
+ URL classResB = contribB.getClassLoader().getResource(classResName);
+ Assert.assertNotNull(classResB);
+
+ // Load Java class as resource from imported contribution with JavaImport
+ URL classResB1 = contribB.getClassLoader().getResource("calculator/AddService.class");
+ Assert.assertNotNull(classResB1);
+
+ // Try to load resource not explicitly imported by contribution
+ URL classResA1 = contribA.getClassLoader().getResource("calculator/AddService.class");
+ Assert.assertNull(classResA1);
+
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessorTestCase.java
new file mode 100644
index 0000000000..25c4b91eaa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessorTestCase.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.sca.contribution.java.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test JavaExportProcessorTestCase
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaExportProcessorTestCase {
+
+ private static final String VALID_XML =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<export.java xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:ns=\"http://ns\" package=\"org.apache.tuscany.sca.contribution.java\"/>";
+
+ private static final String INVALID_XML =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<export.java xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\"/>";
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+ private static ProcessorContext context;
+
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ monitor = context.getMonitor();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ /**
+ * Test loading a valid export element from a contribution metadata stream
+ * @throws Exception
+ */
+ @Test
+ public void testLoad() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
+ JavaExport javaExport = (JavaExport)staxProcessor.read(reader, context);
+ Assert.assertEquals("org.apache.tuscany.sca.contribution.java", javaExport.getPackage());
+ }
+
+ /**
+ * Test loading an INVALID export element from a contribution metadata stream
+ * @throws Exception
+ */
+ @Test
+ public void testLoadInvalid() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(INVALID_XML));
+ /*try {
+ staxProcessor.read(reader);
+ fail("readerException should have been thrown");
+ } catch (ContributionReadException e) {
+ assertTrue(true);
+ }*/
+ staxProcessor.read(reader, context);
+ Problem problem = monitor.getLastProblem();
+ assertNotNull(problem);
+ assertEquals("AttributePackageMissing", problem.getMessageId());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessorTestCase.java
new file mode 100644
index 0000000000..e9bfa4b5f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessorTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.java.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test JavaImportProcessorTestCase
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaImportProcessorTestCase {
+
+ private static final String VALID_XML =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<import.java xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:ns=\"http://ns\" package=\"org.apache.tuscany.sca.contribution.java\" location=\"sca://contributions/001\"/>";
+
+ private static final String INVALID_XML =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<import.java xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:ns=\"http://ns\" location=\"sca://contributions/001\"/>";
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+
+ private static ProcessorContext context;
+
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ monitor = context.getMonitor();
+ inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ /**
+ * Test loading a valid import element from a contribution metadata stream
+ * @throws Exception
+ */
+ @Test
+ public void testLoad() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
+ JavaImport javaImport = (JavaImport)staxProcessor.read(reader, context);
+
+ assertEquals("org.apache.tuscany.sca.contribution.java", javaImport.getPackage());
+ assertEquals("sca://contributions/001", javaImport.getLocation());
+ }
+
+ /**
+ * Test loading a INVALID import element from a contribution metadata stream
+ * @throws Exception
+ */
+ @Test
+ public void testLoadInvalid() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(INVALID_XML));
+ /*try {
+ staxProcessor.read(reader);
+ fail("readerException should have been thrown");
+ } catch (ContributionReadException e) {
+ assertTrue(true);
+ }*/
+ staxProcessor.read(reader, context);
+ Problem problem = monitor.getLastProblem();
+ assertNotNull(problem);
+ assertEquals("AttributePackageMissing", problem.getMessageId());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java
new file mode 100644
index 0000000000..384892ce62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.namespace.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test NamespaceExportProcessorTestCase
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamespaceExportProcessorTestCase {
+
+ private static final String VALID_XML =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<export xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:ns=\"http://ns\""
+ + " ns:ext=\"extended\" namespace=\"http://foo\">"
+ + "<ns:foo/></export>";
+
+ private static final String INVALID_XML =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<export xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:ns=\"http://ns\"/>";
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ monitor = context.getMonitor();
+ inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ /**
+ * Test loading a valid export element from a contribution metadata stream
+ * @throws Exception
+ */
+ @Test
+ public void testLoad() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
+ NamespaceExport namespaceExport = (NamespaceExport)staxProcessor.read(reader, context);
+ assertEquals("http://foo", namespaceExport.getNamespace());
+ assertEquals(1, namespaceExport.getAttributeExtensions().size());
+ assertEquals(1, namespaceExport.getExtensions().size());
+ }
+
+ /**
+ * Test loading an INVALID export element from a contribution metadata stream
+ * @throws Exception
+ */
+ @Test
+ public void testLoadInvalid() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(INVALID_XML));
+ /*try {
+ staxProcessor.read(reader);
+ fail("readerException should have been thrown");
+ } catch (ContributionReadException e) {
+ assertTrue(true);
+ }*/
+ staxProcessor.read(reader, context);
+ Problem problem = monitor.getLastProblem();
+ assertNotNull(problem);
+ assertEquals("AttributeNameSpaceMissing", problem.getMessageId());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java
new file mode 100644
index 0000000000..32f95e86ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.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.sca.contribution.namespace.impl;
+
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test NamespaceImportProcessorTestCase
+ *
+ * @version $Rev$ $Date$
+ */
+public class NamespaceImportProcessorTestCase {
+
+ private static final String VALID_XML =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<import xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:ns=\"http://ns\""
+ + " namespace=\"http://foo\" location=\"sca://contributions/001\" ns:ext=\"extended\">"
+ + "<ns:foo/></import>";
+
+ private static final String INVALID_XML =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<import xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:ns=\"http://ns\" location=\"sca://contributions/001\"/>";
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ monitor = context.getMonitor();
+ inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ /**
+ * Test loading a valid import element from a contribution metadata stream
+ * @throws Exception
+ */
+ @Test
+ public void testLoad() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
+ NamespaceImport namespaceImport = (NamespaceImport)staxProcessor.read(reader, context);
+
+ assertEquals("http://foo", namespaceImport.getNamespace());
+ assertEquals("sca://contributions/001", namespaceImport.getLocation());
+ assertEquals(1, namespaceImport.getAttributeExtensions().size());
+ assertEquals(1, namespaceImport.getExtensions().size());
+ }
+
+ /**
+ * Test loading a INVALID import element from a contribution metadata stream
+ * @throws Exception
+ */
+ @Test
+ public void testLoadInvalid() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(INVALID_XML));
+ /*try {
+ staxProcessor.read(reader);
+ fail("readerException should have been thrown");
+ } catch (ContributionReadException e) {
+ assertTrue(true);
+ }*/
+ staxProcessor.read(reader, context);
+ Problem problem = monitor.getLastProblem();
+ assertNotNull(problem);
+ assertEquals("AttributeNameSpaceMissing", problem.getMessageId());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java
new file mode 100644
index 0000000000..9587d3c024
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.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.sca.contribution.processor;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * URL Artifact Processor Extension Point test case
+ * Verifies the right registration and lookup for processors that handle filename and file types
+ *
+ * @version $Rev$ $Date$
+ */
+public class URLartifactProcessorExtensionPointTestCase {
+
+ private static URLArtifactProcessorExtensionPoint artifactProcessors;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ artifactProcessors = new DefaultURLArtifactProcessorExtensionPoint(extensionPoints);
+ artifactProcessors.addArtifactProcessor(new FileTypeArtifactProcessor());
+ artifactProcessors.addArtifactProcessor(new FileNameArtifactProcessor());
+ }
+
+ @Test
+ public final void testFileTypeProcessor() {
+ assertNotNull(artifactProcessors.getProcessor("dir1/file1.m1"));
+ assertNotNull(artifactProcessors.getProcessor("file1.m1"));
+ }
+
+ @Test
+ public final void testFileNameProcessor() {
+ assertNotNull(artifactProcessors.getProcessor("file.m2"));
+ assertNotNull(artifactProcessors.getProcessor("dir1/file.m2"));
+ assertNull(artifactProcessors.getProcessor("onefile.m2"));
+ }
+
+ /**
+ * Internal mock classes
+ *
+ */
+
+ private class M1 {
+ }
+
+ private class M2 {
+ }
+
+ private static class FileTypeArtifactProcessor implements URLArtifactProcessor<M1> {
+ public FileTypeArtifactProcessor() {
+ }
+
+ public M1 read(URL contributionURL, URI uri, URL url, ProcessorContext context) throws ContributionReadException {
+ return null;
+ }
+
+ public void resolve(M1 m1, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+
+ public String getArtifactType() {
+ return ".m1";
+ }
+
+ public Class<M1> getModelType() {
+ return M1.class;
+ }
+ }
+
+ private static class FileNameArtifactProcessor implements URLArtifactProcessor<M2> {
+ public FileNameArtifactProcessor() {
+ }
+
+ public M2 read(URL contributionURL, URI uri, URL url, ProcessorContext context) throws ContributionReadException {
+ return null;
+ }
+
+ public void resolve(M2 m2, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+
+ public String getArtifactType() {
+ return "file.m2";
+ }
+
+ public Class<M2> getModelType() {
+ return M2.class;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java
new file mode 100644
index 0000000000..58d1616aa2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.contribution.resolver;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.DefaultContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test the default model resolver implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultModelResolverTestCase {
+
+ private ModelResolver resolver;
+ private ContributionFactory factory;
+
+ @Before
+ public void setUp() throws Exception {
+ resolver = new DefaultModelResolver();
+ factory = new DefaultContributionFactory();
+ }
+
+ @Test
+ public void testResolved() {
+ ProcessorContext context = new ProcessorContext();
+ Model a = new Model("a");
+ resolver.addModel(a, context);
+ Model x = new Model("a");
+ x = resolver.resolveModel(Model.class, x, context);
+ assertTrue(x == a);
+ }
+
+ @Test
+ public void testUnresolved() {
+ Model x = new Model("a");
+ Model y = resolver.resolveModel(Model.class, x, new ProcessorContext());
+ assertTrue(x == y);
+ }
+
+ @Test
+ public void testResolvedArtifact() {
+ ProcessorContext context = new ProcessorContext();
+ Artifact artifact = factory.createArtifact();
+ artifact.setURI("foo/bar");
+ resolver.addModel(artifact, context);
+ Artifact x = factory.createArtifact();
+ x.setURI("foo/bar");
+ x = resolver.resolveModel(Artifact.class, x, context);
+ assertTrue(x == artifact);
+ }
+
+ class Model {
+ private String name;
+
+ Model(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return name.equals(((Model)obj).name);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java
new file mode 100644
index 0000000000..7692c8ecdf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java
@@ -0,0 +1,137 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT 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.contribution.resolver;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.DefaultContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test DefaultArtifactResolver.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleModelResolverTestCase {
+ private ExtensibleModelResolver resolver;
+
+ private ContributionFactory factory;
+ private ProcessorContext context;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(registry);
+ resolvers.addResolver(Model.class, TestModelResolver.class);
+ context = new ProcessorContext();
+ FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(registry);
+
+ resolver = new ExtensibleModelResolver(null, resolvers, factories);
+
+ factory = new DefaultContributionFactory();
+ }
+
+ @Test
+ public void testResolvedDefault() {
+ OtherModel a = new OtherModel("a");
+ resolver.addModel(a, context);
+ OtherModel x = new OtherModel("a");
+ x = resolver.resolveModel(OtherModel.class, x, context);
+ assertTrue(x == a);
+ }
+
+ @Test
+ public void testResolvedRegisteredClass() {
+ Model a = new Model("a");
+ resolver.addModel(a, context);
+ Model x = new Model("a");
+ x = resolver.resolveModel(Model.class, x, context);
+ assertTrue(x == a);
+ }
+
+ @Test
+ public void testUnresolvedDefault() {
+ OtherModel x = new OtherModel("a");
+ OtherModel y = resolver.resolveModel(OtherModel.class, x, context);
+ assertTrue(x == y);
+ }
+
+ @Test
+ public void testUnresolved() {
+ Model x = new Model("a");
+ Model y = resolver.resolveModel(Model.class, x, context);
+ assertTrue(x == y);
+ }
+
+ @Test
+ public void testResolvedArtifact() {
+ Artifact artifact = factory.createArtifact();
+ artifact.setURI("foo/bar");
+ resolver.addModel(artifact, context);
+ Artifact x = factory.createArtifact();
+ x.setURI("foo/bar");
+ x = resolver.resolveModel(Artifact.class, x, context);
+ assertTrue(x == artifact);
+ }
+
+ private class Model {
+ private String name;
+
+ Model(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return name.equals(((Model)obj).name);
+ }
+ }
+
+ private class OtherModel {
+ private String name;
+
+ OtherModel(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return name.equals(((OtherModel)obj).name);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java
new file mode 100644
index 0000000000..c04d56cafe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.resolver;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A test implementation of a model resolver, based on a map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestModelResolver implements ModelResolver {
+
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ public TestModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+ // Return the resolved object
+ return modelClass.cast(resolved);
+ }
+ // Return the unresolved object
+ return unresolved;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(resolved);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
new file mode 100644
index 0000000000..1e4dcd8023
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.contribution.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test the contribution metadata processor.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class ContributionMetadataProcessorTestCase {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private static final String VALID_XML =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<contribution xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " xmlns:ns=\"http://ns\" ns:foo=\"extended\">"
+ + "<deployable composite=\"ns:Composite1\"/>"
+ + "<deployable xmlns:ns2=\"http://ns2\" composite=\"ns2:Composite2\"/>"
+ + "<ns:bar x=\"1\"/>"
+ + "</contribution>";
+
+ private static final String INVALID_XML =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<contribution xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:ns=\"http://ns\">"
+ + "<deployable composite=\"ns:Composite1\"/>"
+ + "<deployable/>"
+ + "</contribution>";
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ monitor = context.getMonitor();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ public void testRead() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
+ ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader, context);
+ assertNotNull(contribution);
+ assertEquals(2, contribution.getDeployables().size());
+ assertEquals(1, contribution.getAttributeExtensions().size());
+ assertEquals(1, contribution.getExtensions().size());
+ reader.close();
+ }
+
+ @Test
+ public void testReadInvalid() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(INVALID_XML));
+ /*try {
+ staxProcessor.read(reader);
+ fail("InvalidException should have been thrown");
+ } catch (ContributionReadException e) {
+ assertTrue(true);
+ }*/
+ staxProcessor.read(reader, context);
+ Problem problem = monitor.getLastProblem();
+ assertNotNull(problem);
+ assertEquals("AttributeCompositeMissing", problem.getMessageId());
+ reader.close();
+ }
+
+ @Test
+ public void testReadSpecVersion() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
+ ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader, context);
+ assertNotNull(contribution);
+ assertEquals(SCA11_NS, contribution.getSpecVersion());
+ reader.close();
+ }
+
+ @Test
+ public void testWrite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
+ ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader, context);
+
+ validateContribution(contribution);
+
+ //write the contribution metadata contents
+ StringWriter stringWriter = new StringWriter();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(stringWriter);
+ staxProcessor.write(contribution, writer, context);
+ stringWriter.close();
+
+ reader = inputFactory.createXMLStreamReader(new StringReader(stringWriter.toString()));
+ contribution = (ContributionMetadata)staxProcessor.read(reader, context);
+
+ validateContribution(contribution);
+
+ reader.close();
+ }
+
+ private void validateContribution(ContributionMetadata contribution) {
+ QName deployable;
+
+ assertNotNull(contribution);
+ assertEquals(2, contribution.getDeployables().size());
+ deployable = new QName("http://ns", "Composite1");
+ assertEquals(deployable, contribution.getDeployables().get(0).getName());
+ deployable = new QName("http://ns2", "Composite2");
+ assertEquals(deployable, contribution.getDeployables().get(1).getName());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/deployables/sample-calculator.jar b/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/deployables/sample-calculator.jar
new file mode 100644
index 0000000000..0ca3a1b781
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/deployables/sample-calculator.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/repository/sample-calculator.jar b/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/repository/sample-calculator.jar
new file mode 100644
index 0000000000..9c46c679d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/repository/sample-calculator.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/test.composite b/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/test.composite
new file mode 100644
index 0000000000..1e09549194
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/contribution/src/test/resources/test.composite
@@ -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.
+-->
+<composite>
+ This file just needs to exist
+</composite> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/LICENSE b/sandbox/sebastien/java/embed/modules/core-databinding/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/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/sebastien/java/embed/modules/core-databinding/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/core-databinding/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..fe68b72498
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.core.databinding.module;versio
+ n="2.0.0",org.apache.tuscany.sca.core.databinding.processor;version="2.0.0",
+ org.apache.tuscany.sca.core.databinding.transformers;version="2.0.0"
+ ,org.apache.tuscany.sca.core.databinding.wire;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Core/DataBinding Integration
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Core/DataBinding Integration
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.annotation;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.core.databinding
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.core.databinding.processor;
+ version="2.0.0";uses:="org.w3c.dom"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/NOTICE b/sandbox/sebastien/java/embed/modules/core-databinding/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/pom.xml b/sandbox/sebastien/java/embed/modules/core-databinding/pom.xml
new file mode 100644
index 0000000000..53574b9a1e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/pom.xml
@@ -0,0 +1,91 @@
+<?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</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany SCA Core/DataBinding Integration</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <scope>runtime</scope>
+ <version>3.2.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java
new file mode 100644
index 0000000000..01a3c1813c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.processor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.annotation.DataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+
+/**
+ * The databinding annotation processor for java interfaces
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataBindingJavaInterfaceProcessor implements JavaInterfaceVisitor {
+ private DataBindingExtensionPoint dataBindingRegistry;
+
+ public DataBindingJavaInterfaceProcessor(ExtensionPointRegistry registry) {
+ super();
+ this.dataBindingRegistry = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ }
+
+ public void visitInterface(JavaInterface javaInterface) throws InvalidInterfaceException {
+ if (!javaInterface.isRemotable()) {
+ return;
+ }
+ List<Operation> operations = javaInterface.getOperations();
+ processInterface(javaInterface, operations);
+ }
+
+ private void processInterface(JavaInterface javaInterface, List<Operation> operations) {
+ Class<?> clazz = javaInterface.getJavaClass();
+ DataBinding dataBinding = clazz.getAnnotation(DataBinding.class);
+ String dataBindingId = null;
+ boolean wrapperStyle = false;
+ if (dataBinding != null) {
+ dataBindingId = dataBinding.value();
+ wrapperStyle = dataBinding.wrapped();
+ }
+
+ Map<String, Operation> opMap = new HashMap<String, Operation>();
+ for (Operation op : javaInterface.getOperations()) {
+ opMap.put(op.getName(), op);
+ // In the case of @WebMethod, the method name can be different from the operation name
+ if (op instanceof JavaOperation) {
+ opMap.put(((JavaOperation)op).getJavaMethod().getName(), op);
+ }
+ if (dataBindingId != null) {
+ op.setDataBinding(dataBindingId);
+ op.setWrapperStyle(wrapperStyle);
+ }
+ }
+ for (Method method : clazz.getMethods()) {
+ if (method.getDeclaringClass() == Object.class) {
+ continue;
+ }
+ Operation operation = opMap.get(method.getName());
+ if (operation == null) { // @WebMethod exclude=true
+ continue;
+ }
+ DataBinding methodDataBinding = clazz.getAnnotation(DataBinding.class);
+ if (methodDataBinding == null) {
+ methodDataBinding = dataBinding;
+ }
+ dataBindingId = null;
+ wrapperStyle = false;
+ if (dataBinding != null) {
+ dataBindingId = dataBinding.value();
+ wrapperStyle = dataBinding.wrapped();
+ operation.setDataBinding(dataBindingId);
+ operation.setWrapperStyle(wrapperStyle);
+ }
+
+ // FIXME: We need a better way to identify simple java types
+ int i = 0;
+ for (org.apache.tuscany.sca.interfacedef.DataType<?> d : operation.getInputType().getLogical()) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBindingId);
+ }
+ for (Annotation a : method.getParameterAnnotations()[i]) {
+ if (a.annotationType() == org.apache.tuscany.sca.databinding.annotation.DataType.class) {
+ String value = ((org.apache.tuscany.sca.databinding.annotation.DataType)a).value();
+ d.setDataBinding(value);
+ }
+ }
+ dataBindingRegistry.introspectType(d, operation);
+ i++;
+ }
+ if (operation.getOutputType() != null) {
+ DataType<?> d = operation.getOutputType();
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBindingId);
+ }
+ org.apache.tuscany.sca.databinding.annotation.DataType dt =
+ method.getAnnotation(org.apache.tuscany.sca.databinding.annotation.DataType.class);
+ if (dt != null) {
+ d.setDataBinding(dt.value());
+ }
+ dataBindingRegistry.introspectType(d, operation);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java
new file mode 100644
index 0000000000..a5526ab031
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.processor;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+
+/**
+ * The databinding annotation processor for java interfaces
+ *
+ * @version $Rev$ $Date$
+ */
+public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor {
+ private static final String JAXB_DATABINDING = "javax.xml.bind.JAXBElement";
+ private DataBindingExtensionPoint dataBindingRegistry;
+
+ public WrapperJavaInterfaceProcessor(ExtensionPointRegistry registry) {
+ super();
+ this.dataBindingRegistry = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ }
+
+ public void visitInterface(JavaInterface javaInterface) throws InvalidInterfaceException {
+ if (!javaInterface.isRemotable()) {
+ return;
+ }
+ for (Operation operation : javaInterface.getOperations()) {
+ WrapperInfo wrapper = operation.getWrapper();
+ if (wrapper == null) {
+ continue;
+ }
+ // JIRA: TUSCANY-842
+ String db = wrapper.getDataBinding();
+ if (db == null || JAXB_DATABINDING.equals(db)) {
+ db = assignOperationDataBinding(operation);
+ }
+
+ // Introspect the wrapper data type
+ org.apache.tuscany.sca.databinding.DataBinding dbObj = dataBindingRegistry.getDataBinding(db);
+ WrapperHandler handler = dbObj == null ? null : dbObj.getWrapperHandler();
+ if (handler != null) {
+ wrapper.setInputWrapperType(handler.getWrapperType(operation, true));
+ wrapper.setOutputWrapperType(handler.getWrapperType(operation, false));
+ }
+ if (dbObj != null && handler == null) {
+ // To avoid JAXB wrapper bean generation
+ wrapper.setInputWrapperType(null);
+ wrapper.setOutputWrapperType(null);
+ }
+ }
+ }
+
+ /*
+ * Assigns an operation DB if one of the input types, output type, fault types has a non-default DB.
+ * However, if two of the input types, output type, fault types have two different non-default DBs
+ * ( e.g. SDO and JAXB), then we do nothing to the operation DB.
+ *
+ * The method logic assumes the JavaBeans DataBinding is the default
+ */
+ private String assignOperationDataBinding(Operation operation) {
+
+ Set<String> dbs = new HashSet<String>();
+
+ // Can't use DataType<?> since operation.getInputType() returns: DataType<List<DataType>>
+ List<DataType> opDataTypes = new LinkedList<DataType>();
+
+ opDataTypes.addAll(operation.getInputType().getLogical());
+ opDataTypes.add(operation.getOutputType());
+ for (DataType<DataType> ft : operation.getFaultTypes()) {
+ opDataTypes.add(ft.getLogical());
+ }
+
+ for (DataType<?> d : opDataTypes) {
+ if (d != null) {
+ String dataBinding = d.getDataBinding();
+ if ("java:array".equals(dataBinding)) {
+ dataBinding = ((DataType)d.getLogical()).getDataBinding();
+ }
+ if (dataBinding != null) {
+ dbs.add(dataBinding);
+ }
+ }
+ }
+
+ dbs.remove(JavaBeansDataBinding.NAME);
+ dbs.remove(SimpleJavaDataBinding.NAME);
+
+ if (dbs.size() == 1) {
+ String db = dbs.iterator().next();
+ operation.getWrapper().setDataBinding(db);
+ return db;
+ } else {
+ return operation.getWrapper().getDataBinding();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Array2ArrayTransformer.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Array2ArrayTransformer.java
new file mode 100644
index 0000000000..4997a872ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Array2ArrayTransformer.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.transformers;
+
+import java.lang.reflect.Array;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * This is a special transformer to transform the output from one IDL to the
+ * other one
+ *
+ * @version $Rev$ $Date$
+ */
+public class Array2ArrayTransformer extends BaseTransformer<Object, Object> implements PullTransformer<Object, Object> {
+
+ protected Mediator mediator;
+
+ public Array2ArrayTransformer(ExtensionPointRegistry registry) {
+ super();
+ this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return "java:array";
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return "java:array";
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getTargetType()
+ */
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.Transformer#getWeight()
+ */
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object transform(Object array, TransformationContext context) {
+ try {
+ if (array == null) {
+ return null;
+ }
+ DataType<DataType> sourceType = context.getSourceDataType();
+ DataType<DataType> targetType = context.getTargetDataType();
+ int length = Array.getLength(array);
+ Object targetArray = Array.newInstance(targetType.getPhysical().getComponentType(), length);
+ for (int i = 0; i < length; i++) {
+ Object sourceItem = Array.get(array, i);
+ Object targetItem =
+ mediator.mediate(sourceItem, sourceType.getLogical(), targetType.getLogical(), context
+ .getMetadata());
+ Array.set(targetArray, i, targetItem);
+ }
+ return targetArray;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Collection2CollectionTransformer.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Collection2CollectionTransformer.java
new file mode 100644
index 0000000000..dcd3c3fda3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Collection2CollectionTransformer.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.transformers;
+
+import java.util.Collection;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * This is a special transformer to transform the output from one IDL to the
+ * other one
+ *
+ * @version $Rev$ $Date$
+ */
+public class Collection2CollectionTransformer extends BaseTransformer<Collection, Collection> implements
+ PullTransformer<Collection, Collection> {
+
+ private static final String JAVA_COLLECTION = "java:collection";
+ protected Mediator mediator;
+
+ public Collection2CollectionTransformer(ExtensionPointRegistry registry) {
+ super();
+ this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JAVA_COLLECTION;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAVA_COLLECTION;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Collection> getSourceType() {
+ return Collection.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getTargetType()
+ */
+ @Override
+ protected Class<Collection> getTargetType() {
+ return Collection.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.Transformer#getWeight()
+ */
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection transform(Collection sourceCollection, TransformationContext context) {
+ try {
+ if (sourceCollection == null) {
+ return null;
+ }
+ DataType<DataType> sourceType = context.getSourceDataType();
+ DataType<DataType> targetType = context.getTargetDataType();
+ Collection targetCollection = createCollection(targetType.getPhysical());
+ for (Object sourceItem : sourceCollection) {
+ Object targetItem =
+ mediator.mediate(sourceItem, sourceType.getLogical(), targetType.getLogical(), context
+ .getMetadata());
+ targetCollection.add(targetItem);
+ }
+ return targetCollection;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ private Collection createCollection(Class<?> collectionClass) throws Exception {
+ return (Collection) collectionClass.newInstance();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Exception2ExceptionTransformer.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Exception2ExceptionTransformer.java
new file mode 100644
index 0000000000..e78610cce0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Exception2ExceptionTransformer.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.transformers;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.FaultExceptionMapper;
+
+/**
+ * This is a special transformer to transform the exception from one IDL to the
+ * other one
+ *
+ * @version $Rev$ $Date$
+ */
+public class Exception2ExceptionTransformer extends BaseTransformer<Throwable, Throwable> implements
+ PullTransformer<Throwable, Throwable> {
+
+ protected Mediator mediator;
+ protected FaultExceptionMapper faultExceptionMapper;
+
+ public Exception2ExceptionTransformer(ExtensionPointRegistry registry) {
+ super();
+ UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.mediator = utilityExtensionPoint.getUtility(Mediator.class);
+ this.faultExceptionMapper = utilityExtensionPoint.getUtility(FaultExceptionMapper.class);
+ }
+
+ protected Exception2ExceptionTransformer(Mediator mediator, FaultExceptionMapper faultExceptionMapper) {
+ super();
+ this.mediator = mediator;
+ this.faultExceptionMapper = faultExceptionMapper;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return DataBinding.IDL_FAULT;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return DataBinding.IDL_FAULT;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Throwable> getSourceType() {
+ return Throwable.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getTargetType()
+ */
+ @Override
+ protected Class<Throwable> getTargetType() {
+ return Throwable.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.Transformer#getWeight()
+ */
+ @Override
+ public int getWeight() {
+ return 10000;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Throwable transform(Throwable source, TransformationContext context) {
+ DataType<DataType> sourceType = context.getSourceDataType();
+
+ DataType<DataType> targetType = context.getTargetDataType();
+
+ Object sourceFaultInfo = faultExceptionMapper.getFaultInfo(source, sourceType.getLogical().getPhysical(), context.getSourceOperation());
+ Object targetFaultInfo =
+ mediator.mediate(sourceFaultInfo, sourceType.getLogical(), targetType.getLogical(), context.getMetadata());
+
+ Throwable targetException =
+ faultExceptionMapper.wrapFaultInfo(targetType, source.getMessage(), targetFaultInfo, source.getCause(), context.getTargetOperation());
+
+ // FIXME
+ return targetException == null ? source : targetException;
+
+ }
+
+ public void setFaultExceptionMapper(FaultExceptionMapper faultExceptionMapper) {
+ this.faultExceptionMapper = faultExceptionMapper;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java
new file mode 100644
index 0000000000..2efc3578bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java
@@ -0,0 +1,270 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.transformers;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * This is a special transformer to transform the input from one IDL to the
+ * other one
+ *
+ * @version $Rev$ $Date$
+ */
+public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> implements
+ PullTransformer<Object[], Object[]> {
+ protected Mediator mediator;
+
+ public Input2InputTransformer(ExtensionPointRegistry registry) {
+ super();
+ this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return DataBinding.IDL_INPUT;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return DataBinding.IDL_INPUT;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Object[]> getSourceType() {
+ return Object[].class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getTargetType()
+ */
+ @Override
+ protected Class<Object[]> getTargetType() {
+ return Object[].class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.Transformer#getWeight()
+ */
+ @Override
+ public int getWeight() {
+ return 10000;
+ }
+
+ /**
+ * Match the structure of the wrapper element. If it matches, then we can do
+ * wrapper to wrapper transformation. Otherwise, we do child to child.
+ * @param w1
+ * @param w2
+ * @return
+ */
+ private boolean matches(WrapperInfo w1, WrapperInfo w2) {
+ if (w1 == null || w2 == null) {
+ return false;
+ }
+ if (!w1.getInputWrapperElement().equals(w2.getInputWrapperElement())) {
+ return false;
+ }
+
+ // Compare the child elements
+ List<ElementInfo> list1 = w1.getInputChildElements();
+ List<ElementInfo> list2 = w2.getInputChildElements();
+ if (list1.size() != list2.size()) {
+ return false;
+ }
+ // FXIME: [rfeng] At this point, the J2W generates local elments under the namespace
+ // of the interface instead of "". We only compare the local parts only to work around
+ // the namespace mismatch
+ for (int i = 0; i < list1.size(); i++) {
+ String n1 = list1.get(i).getQName().getLocalPart();
+ String n2 = list2.get(i).getQName().getLocalPart();
+ if (!n1.equals(n2)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object[] transform(Object[] source, TransformationContext context) {
+ // Check if the source operation is wrapped
+ DataType<List<DataType>> sourceType = context.getSourceDataType();
+ Operation sourceOp = context.getSourceOperation();
+ boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle() && sourceOp.getWrapper() != null;
+ boolean sourceBare = sourceOp != null && !sourceOp.isWrapperStyle() && sourceOp.getWrapper() == null;
+
+ // Find the wrapper handler for source data
+ WrapperHandler sourceWrapperHandler = null;
+ String sourceDataBinding = getDataBinding(sourceOp);
+ sourceWrapperHandler = getWrapperHandler(sourceDataBinding, sourceWrapped);
+
+ // Check if the target operation is wrapped
+ DataType<List<DataType>> targetType = context.getTargetDataType();
+ Operation targetOp = (Operation)context.getTargetOperation();
+ boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle() && targetOp.getWrapper() != null;
+ boolean targetBare = targetOp != null && !targetOp.isWrapperStyle() && targetOp.getWrapper() == null;
+
+ // Find the wrapper handler for target data
+ WrapperHandler targetWrapperHandler = null;
+ String targetDataBinding = getDataBinding(targetOp);
+ targetWrapperHandler = getWrapperHandler(targetDataBinding, targetWrapped);
+
+ if ((!sourceWrapped && !sourceBare) && targetWrapped) {
+ // Unwrapped --> Wrapped
+ WrapperInfo wrapper = targetOp.getWrapper();
+ // ElementInfo wrapperElement = wrapper.getInputWrapperElement();
+
+ // Class<?> targetWrapperClass = wrapper != null ? wrapper.getInputWrapperClass() : null;
+
+ if (source == null) {
+ // Empty child elements
+ Object targetWrapper = targetWrapperHandler.create(targetOp, true);
+ return new Object[] {targetWrapper};
+ }
+
+ // If the source can be wrapped, wrapped it first
+ if (sourceWrapperHandler != null) {
+ WrapperInfo sourceWrapperInfo = sourceOp.getWrapper();
+ DataType sourceWrapperType = sourceWrapperInfo != null ? sourceWrapperInfo.getInputWrapperType() : null;
+
+ // We only do wrapper to wrapper transformation if the source has a wrapper and both sides
+ // match by XML structure
+ if (sourceWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) {
+ Class<?> sourceWrapperClass = sourceWrapperType.getPhysical();
+
+ // Create the source wrapper
+ Object sourceWrapper = sourceWrapperHandler.create(sourceOp, true);
+
+ // Populate the source wrapper
+ if (sourceWrapper != null) {
+ sourceWrapperHandler.setChildren(sourceWrapper,
+ source,
+ sourceOp,
+ true);
+
+ // Transform the data from source wrapper to target wrapper
+ Object targetWrapper =
+ mediator.mediate(sourceWrapper, sourceWrapperType, targetType.getLogical().get(0), context
+ .getMetadata());
+ return new Object[] {targetWrapper};
+ }
+ }
+ }
+ // Fall back to child by child transformation
+ Object targetWrapper = targetWrapperHandler.create(targetOp, true);
+ List<DataType> argTypes = wrapper.getUnwrappedInputType().getLogical();
+ Object[] targetChildren = new Object[source.length];
+ for (int i = 0; i < source.length; i++) {
+ // ElementInfo argElement = wrapper.getInputChildElements().get(i);
+ DataType<XMLType> argType = argTypes.get(i);
+ targetChildren[i] =
+ mediator.mediate(source[i], sourceType.getLogical().get(i), argType, context.getMetadata());
+ }
+ targetWrapperHandler.setChildren(targetWrapper,
+ targetChildren,
+ targetOp,
+ true);
+ return new Object[] {targetWrapper};
+
+ } else if (sourceWrapped && (!targetWrapped && !targetBare)) {
+ // Wrapped to Unwrapped
+ Object sourceWrapper = source[0];
+ Object[] target = null;
+
+ // List<ElementInfo> childElements = sourceOp.getWrapper().getInputChildElements();
+ if (targetWrapperHandler != null) {
+ // ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement();
+ // FIXME: This is a workaround for the wsdless support as it passes in child elements
+ // under the wrapper that only matches by position
+ if (sourceWrapperHandler.isInstance(sourceWrapper, sourceOp, true)) {
+
+ WrapperInfo targetWrapperInfo = targetOp.getWrapper();
+ DataType targetWrapperType =
+ targetWrapperInfo != null ? targetWrapperInfo.getInputWrapperType() : null;
+ if (targetWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) {
+ Object targetWrapper =
+ mediator.mediate(sourceWrapper, sourceType.getLogical().get(0), targetWrapperType, context
+ .getMetadata());
+ target = targetWrapperHandler.getChildren(targetWrapper, targetOp, true).toArray();
+ return target;
+ }
+ }
+ }
+ Object[] sourceChildren = sourceWrapperHandler.getChildren(sourceWrapper, sourceOp, true).toArray();
+ target = new Object[sourceChildren.length];
+ for (int i = 0; i < sourceChildren.length; i++) {
+ DataType<XMLType> childType = sourceOp.getWrapper().getUnwrappedInputType().getLogical().get(i);
+ target[i] =
+ mediator.mediate(sourceChildren[i], childType, targetType.getLogical().get(i), context
+ .getMetadata());
+ }
+ return target;
+ } else {
+ // Assuming wrapper to wrapper conversion can be handled here as well
+ Object[] newArgs = new Object[source.length];
+ for (int i = 0; i < source.length; i++) {
+ Object child =
+ mediator.mediate(source[i], sourceType.getLogical().get(i), targetType.getLogical().get(i), context
+ .getMetadata());
+ newArgs[i] = child;
+ }
+ return newArgs;
+ }
+ }
+
+ private WrapperHandler getWrapperHandler(String dataBindingId, boolean required) {
+ WrapperHandler wrapperHandler = null;
+ if (dataBindingId != null) {
+ DataBinding dataBinding = mediator.getDataBindings().getDataBinding(dataBindingId);
+ wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler();
+ }
+ if (wrapperHandler == null && required) {
+ throw new TransformationException("No wrapper handler is provided for databinding: " + dataBindingId);
+ }
+ return wrapperHandler;
+ }
+
+ private String getDataBinding(Operation operation) {
+ WrapperInfo wrapper = operation.getWrapper();
+ if (wrapper != null) {
+ return wrapper.getDataBinding();
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Map2MapTransformer.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Map2MapTransformer.java
new file mode 100644
index 0000000000..5be7ba1da4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Map2MapTransformer.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.transformers;
+
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * This is a special transformer to transform the output from one IDL to the
+ * other one
+ *
+ * @version $Rev$ $Date$
+ */
+public class Map2MapTransformer extends BaseTransformer<Map, Map> implements PullTransformer<Map, Map> {
+
+ private static final String JAVA_MAP = "java:map";
+ protected Mediator mediator;
+
+ public Map2MapTransformer(ExtensionPointRegistry registry) {
+ super();
+ this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JAVA_MAP;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAVA_MAP;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Map> getSourceType() {
+ return Map.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getTargetType()
+ */
+ @Override
+ protected Class<Map> getTargetType() {
+ return Map.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.Transformer#getWeight()
+ */
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map transform(Map sourceMap, TransformationContext context) {
+ try {
+ if (sourceMap == null) {
+ return null;
+ }
+ DataType<DataType> sourceType = context.getSourceDataType();
+ DataType<DataType> targetType = context.getTargetDataType();
+ Map targetMap = createMap(targetType.getPhysical());
+ for (Object sourceItem : sourceMap.entrySet()) {
+ Map.Entry entry = (Map.Entry)sourceItem;
+ Object targetValue =
+ mediator.mediate(entry.getValue(), sourceType.getLogical(), targetType.getLogical(), context
+ .getMetadata());
+ targetMap.put(entry.getKey(), targetValue);
+ }
+ return targetMap;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ private Map createMap(Class<?> collectionClass) throws Exception {
+ return (Map)collectionClass.newInstance();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java
new file mode 100644
index 0000000000..71dcc654eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.transformers;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * This is a special transformer to transform the output from one IDL to the
+ * other one
+ *
+ * @version $Rev$ $Date$
+ */
+public class Output2OutputTransformer extends BaseTransformer<Object, Object> implements
+ PullTransformer<Object, Object> {
+
+ protected Mediator mediator;
+
+ /**
+ * @param wrapperHandler
+ */
+ public Output2OutputTransformer(ExtensionPointRegistry registry) {
+ super();
+ this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return DataBinding.IDL_OUTPUT;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return DataBinding.IDL_OUTPUT;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getTargetType()
+ */
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.Transformer#getWeight()
+ */
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ private String getDataBinding(Operation operation) {
+ WrapperInfo wrapper = operation.getWrapper();
+ if (wrapper != null) {
+ return wrapper.getDataBinding();
+ } else {
+ return null;
+ }
+ }
+
+ private WrapperHandler getWrapperHandler(String dataBindingId, boolean required) {
+ WrapperHandler wrapperHandler = null;
+ if (dataBindingId != null) {
+ DataBinding dataBinding = mediator.getDataBindings().getDataBinding(dataBindingId);
+ wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler();
+ }
+ if (wrapperHandler == null && required) {
+ throw new TransformationException("No wrapper handler is provided for databinding: " + dataBindingId);
+ }
+ return wrapperHandler;
+ }
+
+ /**
+ * Match the structure of the wrapper element. If it matches, then we can do
+ * wrapper to wrapper transformation. Otherwise, we do child to child.
+ * @param w1
+ * @param w2
+ * @return
+ */
+ private boolean matches(WrapperInfo w1, WrapperInfo w2) {
+ if (w1 == null || w2 == null) {
+ return false;
+ }
+ if (!w1.getOutputWrapperElement().equals(w2.getOutputWrapperElement())) {
+ return false;
+ }
+
+ // Compare the child elements
+ List<ElementInfo> list1 = w1.getOutputChildElements();
+ List<ElementInfo> list2 = w2.getOutputChildElements();
+ if (list1.size() != list2.size()) {
+ return false;
+ }
+ // FXIME: [rfeng] At this point, the J2W generates local elments under the namespace
+ // of the interface instead of "". We only compare the local parts only to work around
+ // the namespace mismatch
+ for (int i = 0; i < list1.size(); i++) {
+ String n1 = list1.get(i).getQName().getLocalPart();
+ String n2 = list2.get(i).getQName().getLocalPart();
+ if (!n1.equals(n2)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object transform(Object response, TransformationContext context) {
+ try {
+ DataType<DataType> sourceType = context.getSourceDataType();
+ Operation sourceOp = context.getSourceOperation();
+ boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle() && sourceOp.getWrapper() != null;
+ boolean sourceBare = sourceOp != null && !sourceOp.isWrapperStyle() && sourceOp.getWrapper() == null;
+
+ WrapperHandler sourceWrapperHandler = null;
+ String sourceDataBinding = getDataBinding(sourceOp);
+ sourceWrapperHandler = getWrapperHandler(sourceDataBinding, sourceWrapped);
+
+ DataType<DataType> targetType = context.getTargetDataType();
+ Operation targetOp = (Operation)context.getTargetOperation();
+ boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle() && targetOp.getWrapper() != null;
+ boolean targetBare = targetOp != null && !targetOp.isWrapperStyle() && targetOp.getWrapper() == null;
+
+ WrapperHandler targetWrapperHandler = null;
+ String targetDataBinding = getDataBinding(targetOp);
+ targetWrapperHandler = getWrapperHandler(targetDataBinding, targetWrapped);
+
+ if ((!sourceWrapped &&!sourceBare) && targetWrapped) {
+ // Unwrapped --> Wrapped
+ WrapperInfo wrapper = targetOp.getWrapper();
+ ElementInfo wrapperElement = wrapper.getOutputWrapperElement();
+ List<ElementInfo> childElements = wrapper.getOutputChildElements();
+ Class<?> targetWrapperClass = wrapper != null ? wrapper.getOutputWrapperClass() : null;
+
+ // If the source can be wrapped, wrapped it first
+ if (sourceWrapperHandler != null) {
+ WrapperInfo sourceWrapperInfo = sourceOp.getWrapper();
+ DataType sourceWrapperType =
+ sourceWrapperInfo != null ? sourceWrapperInfo.getOutputWrapperType() : null;
+
+ if (sourceWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) {
+ Class<?> sourceWrapperClass = sourceWrapperType.getPhysical();
+
+ Object sourceWrapper = sourceWrapperHandler.create(sourceOp, false);
+ if (sourceWrapper != null) {
+ if (!childElements.isEmpty()) {
+ // Set the return value
+ sourceWrapperHandler.setChildren(sourceWrapper,
+ new Object[] {response},
+ sourceOp,
+ false);
+ }
+ Object targetWrapper =
+ mediator.mediate(sourceWrapper, sourceWrapperType, targetType.getLogical(), context
+ .getMetadata());
+ return targetWrapper;
+ }
+ }
+ }
+ Object targetWrapper = targetWrapperHandler.create(targetOp, false);
+
+ if (childElements.isEmpty()) {
+ // void output
+ return targetWrapper;
+ }
+
+ DataType<XMLType> argType = wrapper.getUnwrappedOutputType();
+ Object child = response;
+ child = mediator.mediate(response, sourceType.getLogical(), argType, context.getMetadata());
+ targetWrapperHandler.setChildren(targetWrapper, new Object[] {child}, targetOp, false);
+ return targetWrapper;
+ } else if (sourceWrapped && (!targetWrapped && !targetBare)) {
+ // Wrapped to Unwrapped
+ Object sourceWrapper = response;
+ List<ElementInfo> childElements = sourceOp.getWrapper().getOutputChildElements();
+ if (childElements.isEmpty()) {
+ // The void output
+ return null;
+ }
+ if (targetWrapperHandler != null) {
+ ElementInfo wrapperElement = sourceOp.getWrapper().getOutputWrapperElement();
+
+ // FIXME: This is a workaround for the wsdless support as it passes in child elements
+ // under the wrapper that only matches by position
+ if (sourceWrapperHandler.isInstance(sourceWrapper, sourceOp, false)) {
+
+ WrapperInfo targetWrapperInfo = targetOp.getWrapper();
+ DataType targetWrapperType =
+ targetWrapperInfo != null ? targetWrapperInfo.getOutputWrapperType() : null;
+
+ if (targetWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) {
+ Object targetWrapper =
+ mediator.mediate(sourceWrapper, sourceType.getLogical(), targetWrapperType, context
+ .getMetadata());
+ return targetWrapperHandler.getChildren(targetWrapper, targetOp, false).get(0);
+ }
+ }
+ }
+ Object child = sourceWrapperHandler.getChildren(sourceWrapper, sourceOp, false).get(0);
+ DataType<?> childType = sourceOp.getWrapper().getUnwrappedOutputType();
+ return mediator.mediate(child, childType, targetType.getLogical(), context.getMetadata());
+ } else {
+ // FIXME: Do we want to handle wrapped to wrapped?
+ return mediator.mediate(response, sourceType.getLogical(), targetType.getLogical(), context
+ .getMetadata());
+ }
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
new file mode 100644
index 0000000000..0e615519f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.wire;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+
+/**
+ * This processor is responsible to add an interceptor to invocation chain if
+ * the source and target operations have different databinding requirements
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor {
+ private Mediator mediator;
+
+ public DataBindingRuntimeWireProcessor(ExtensionPointRegistry registry) {
+ super();
+ this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ public boolean isTransformationRequired(DataType source, DataType target) {
+ if (source == null || target == null) { // void return type
+ return false;
+ }
+ if (source == target) {
+ return false;
+ }
+
+ // Output type can be null
+ if (source == null && target == null) {
+ return false;
+ } else if (source == null || target == null) {
+ return true;
+ }
+ String sourceDataBinding = source.getDataBinding();
+ String targetDataBinding = target.getDataBinding();
+ if (sourceDataBinding == targetDataBinding) {
+ return false;
+ }
+ if (sourceDataBinding == null || targetDataBinding == null) {
+ // TODO: If any of the databinding is null, then no transformation
+ return false;
+ }
+ return !sourceDataBinding.equals(targetDataBinding);
+ }
+
+ public boolean isTransformationRequired(Operation source, Operation target) {
+ if (source == target) {
+ return false;
+ }
+
+ if (source.isWrapperStyle() != target.isWrapperStyle()) {
+ return true;
+ }
+
+ // Check output type
+ DataType sourceOutputType = source.getOutputType();
+ DataType targetOutputType = target.getOutputType();
+
+ // Note the target output type is now the source for checking
+ // compatibility
+ if (isTransformationRequired(targetOutputType, sourceOutputType)) {
+ return true;
+ }
+
+ List<DataType> sourceInputType = source.getInputType().getLogical();
+ List<DataType> targetInputType = target.getInputType().getLogical();
+
+ int size = sourceInputType.size();
+ if (size != targetInputType.size()) {
+ // TUSCANY-1682: The wrapper style may have different arguments
+ return true;
+ }
+ for (int i = 0; i < size; i++) {
+ if (isTransformationRequired(sourceInputType.get(i), targetInputType.get(i))) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private boolean isTransformationRequired(InterfaceContract sourceContract,
+ Operation sourceOperation,
+ InterfaceContract targetContract,
+ Operation targetOperation) {
+ if (targetContract == null) {
+ targetContract = sourceContract;
+ }
+ if (sourceContract == targetContract) {
+ return false;
+ }
+ return isTransformationRequired(sourceOperation, targetOperation);
+ }
+
+ public void process(RuntimeEndpoint endpoint) {
+ InterfaceContract sourceContract = endpoint.getBindingInterfaceContract();
+ InterfaceContract targetContract = endpoint.getComponentTypeServiceInterfaceContract();
+ if (targetContract == null) {
+ targetContract = sourceContract;
+ }
+
+ if (!sourceContract.getInterface().isRemotable()) {
+ return;
+ }
+ List<InvocationChain> chains = endpoint.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ Operation sourceOperation = chain.getSourceOperation();
+ Operation targetOperation = chain.getTargetOperation();
+
+ Interceptor interceptor = null;
+ if (isTransformationRequired(sourceContract, sourceOperation, targetContract, targetOperation)) {
+ // Add the interceptor to the source side because multiple
+ // references can be wired to the same service
+ interceptor = new DataTransformationInterceptor(endpoint, sourceOperation, targetOperation, mediator);
+ }
+ if (interceptor != null) {
+ String phase = Phase.SERVICE_INTERFACE;
+ chain.addInterceptor(phase, interceptor);
+ }
+ }
+
+ }
+
+ public void process(RuntimeEndpointReference endpointReference) {
+ InterfaceContract sourceContract = endpointReference.getComponentTypeReferenceInterfaceContract();
+ InterfaceContract targetContract = endpointReference.getBindingInterfaceContract();
+ if (targetContract == null) {
+ targetContract = sourceContract;
+ }
+
+ if (sourceContract == null || !sourceContract.getInterface().isRemotable()) {
+ return;
+ }
+ List<InvocationChain> chains = endpointReference.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ Operation sourceOperation = chain.getSourceOperation();
+ Operation targetOperation = chain.getTargetOperation();
+
+ Interceptor interceptor = null;
+ if (isTransformationRequired(sourceContract, sourceOperation, targetContract, targetOperation)) {
+ // Add the interceptor to the source side because multiple
+ // references can be wired to the same service
+ interceptor = new DataTransformationInterceptor(endpointReference, sourceOperation, targetOperation, mediator);
+ }
+ if (interceptor != null) {
+ String phase = Phase.REFERENCE_INTERFACE;
+ chain.addInterceptor(phase, interceptor);
+ }
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java
new file mode 100644
index 0000000000..de29088c1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.wire;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.Invocable;
+
+/**
+ * An interceptor to transform data across databindings on the wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataTransformationInterceptor implements Interceptor {
+ private Invoker next;
+
+ private Operation sourceOperation;
+
+ private Operation targetOperation;
+ private Invocable invocable;
+ private Mediator mediator;
+
+ public DataTransformationInterceptor(Invocable invocable,
+ Operation sourceOperation,
+ Operation targetOperation,
+ Mediator mediator) {
+ super();
+ this.sourceOperation = sourceOperation;
+ this.targetOperation = targetOperation;
+ this.mediator = mediator;
+ this.invocable = invocable;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public Message invoke(Message msg) {
+ Map<String, Object> metadata = new HashMap<String, Object>();
+ metadata.put(Invocable.class.getName(), invocable);
+ Object input = mediator.mediateInput(msg.getBody(), sourceOperation, targetOperation, metadata);
+ msg.setBody(input);
+ Message resultMsg = next.invoke(msg);
+ Object result = resultMsg.getBody();
+ if (sourceOperation.isNonBlocking()) {
+ // Not to reset the message body
+ return resultMsg;
+ }
+
+ if (resultMsg.isFault()) {
+ Object transformedFault = null;
+ if ((result instanceof Exception) && !(result instanceof RuntimeException)) {
+ transformedFault = mediator.mediateFault(result, sourceOperation, targetOperation, metadata);
+ if (transformedFault != result) {
+ resultMsg.setFaultBody(transformedFault);
+ }
+ }
+ //
+ // Leave it to another layer to actually throw the Exception which constitutes
+ // the message body. We don't throw it here.
+ //
+ } else {
+ assert !(result instanceof Throwable) : "Expected messages that are not throwable " + result;
+ Object newResult = mediator.mediateOutput(result, sourceOperation, targetOperation, metadata);
+ resultMsg.setBody(newResult);
+ }
+
+ return resultMsg;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
new file mode 100644
index 0000000000..44e5072e61
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.databinding.wire;
+
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Implementation of an interceptor that enforces pass-by-value semantics
+ * on operation invocations by copying the operation input and output data.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PassByValueInterceptor implements Interceptor {
+
+ private Mediator mediator;
+ private Operation operation;
+ private Invoker nextInvoker;
+ private InvocationChain chain;
+
+ /**
+ * Constructs a new PassByValueInterceptor.
+ * @param dataBindings databinding extension point
+ * @param operation the intercepted operation
+ */
+ public PassByValueInterceptor(Mediator mediator, InvocationChain chain, Operation operation) {
+ this.mediator = mediator;
+ this.chain = chain;
+ this.operation = operation;
+ }
+
+ public Message invoke(Message msg) {
+ if (chain.allowsPassByReference()) {
+ return nextInvoker.invoke(msg);
+ }
+
+ msg.setBody(mediator.copyInput(msg.getBody(), operation));
+
+ Message resultMsg = nextInvoker.invoke(msg);
+
+ if (!resultMsg.isFault() && operation.getOutputType() != null) {
+ resultMsg.setBody(mediator.copyOutput(resultMsg.getBody(), operation));
+ }
+
+ if (resultMsg.isFault()) {
+ resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), operation));
+ }
+ return resultMsg;
+ }
+
+ public Invoker getNext() {
+ return nextInvoker;
+ }
+
+ public void setNext(Invoker next) {
+ this.nextInvoker = next;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..a1f5d37ff3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -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.
+
+# Implementation classes for special transformers
+#
+# Java array --> Java array
+org.apache.tuscany.sca.core.databinding.transformers.Array2ArrayTransformer;source=java:array,target=java:array,weight=10,public=false
+# Java exception --> Java exception
+org.apache.tuscany.sca.core.databinding.transformers.Exception2ExceptionTransformer;source=idl:fault,target=idl:fault,weight=10,public=false
+# Input to Input
+org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer;source=idl:input,target=idl:input,weight=10,public=false
+# Output to Output
+org.apache.tuscany.sca.core.databinding.transformers.Output2OutputTransformer;source=idl:output,target=idl:output,weight=10,public=false
+# Group to Group
+org.apache.tuscany.sca.databinding.impl.Group2GroupTransformer;source=databinding:group,target=databinding:group,weight=10,public=false
+
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
new file mode 100644
index 0000000000..875814fccc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
@@ -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.
+
+org.apache.tuscany.sca.core.databinding.processor.DataBindingJavaInterfaceProcessor;ranking=300
+org.apache.tuscany.sca.core.databinding.processor.WrapperJavaInterfaceProcessor;ranking=200
diff --git a/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor
new file mode 100644
index 0000000000..dfd86a3a53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.core.databinding.wire.DataBindingRuntimeWireProcessor
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/LICENSE b/sandbox/sebastien/java/embed/modules/core-spi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/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/sebastien/java/embed/modules/core-spi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/core-spi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1ae10356d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/META-INF/MANIFEST.MF
@@ -0,0 +1,48 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.context;version="2.0.0";
+ uses:="org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.core,
+ org.oasisopen.sca,
+ org.apache.tuscany.sca.extensibility",
+ org.apache.tuscany.sca.invocation;version="2.0.0";uses:="org.apache.tuscany.sca.runtime,org.apache.tuscany.sca.interfacedef",
+ org.apache.tuscany.sca.management;version="2.0.0";uses:="org.apache.tuscany.sca.runtime",
+ org.apache.tuscany.sca.provider;version="2.0.0";
+ uses:="org.apache.tuscany.sca.invocation,
+ org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.definitions,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.interfacedef,
+ org.apache.tuscany.sca.extensibility",
+ org.apache.tuscany.sca.runtime;version="2.0.0";
+ uses:="org.apache.tuscany.sca.invocation,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.endpointresolver,
+ org.apache.tuscany.sca.provider,
+ org.oasisopen.sca,
+ org.apache.tuscany.sca.interfacedef",
+ org.apache.tuscany.sca.work;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Core SPI
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Core SPI
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.management;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.core.spi
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/NOTICE b/sandbox/sebastien/java/embed/modules/core-spi/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/pom.xml b/sandbox/sebastien/java/embed/modules/core-spi/pom.xml
new file mode 100644
index 0000000000..08cb196fa6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/pom.xml
@@ -0,0 +1,118 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-core-spi</artifactId>
+ <name>Apache Tuscany SCA Core SPI</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <version>1.0-beta-4</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <buildNumberPropertyName>sources.version</buildNumberPropertyName>
+ <timestampPropertyName>build.timestamp</timestampPropertyName>
+ <doCheck>false</doCheck>
+ <doUpdate>true</doUpdate>
+ <revisionOnScmFailure>00000</revisionOnScmFailure>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>process-resources</id>
+ <phase>process-resources</phase>
+ <configuration>
+ <tasks>
+ <filter token="version" value="${pom.version}"/>
+ <filter token="svnRevision" value="${sources.version}"/>
+ <filter token="buildtime" value="${build.timestamp}"/>
+ <copy toDir="${basedir}/target/classes/org/apache/tuscany/sca/runtime" overwrite="true"
+ filtering="on" file="${basedir}/src/main/resources/org/apache/tuscany/sca/runtime/revision.properties"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/doc/Context Model.emx b/sandbox/sebastien/java/embed/modules/core-spi/src/doc/Context Model.emx
new file mode 100644
index 0000000000..0445ea5a6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/doc/Context Model.emx
@@ -0,0 +1,673 @@
+<?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.
+-->
+<!--xtools2_universal_type_manager-->
+<uml:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.ibm.com/xtools/1.5.0/Notation" xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML" xmlns:umlnotation="http://www.ibm.com/xtools/1.5.0/Umlnotation" xmi:id="_al1S8NovEdqRBPR5WyT36A" name="Context Model" appliedProfile="_al1S9NovEdqRBPR5WyT36A _al1S99ovEdqRBPR5WyT36A _al1S-tovEdqRBPR5WyT36A _al1S_dovEdqRBPR5WyT36A _al1TANovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S8dovEdqRBPR5WyT36A" source="uml2.diagrams" references="_al1S8tovEdqRBPR5WyT36A">
+ <contents xmi:type="notation:Diagram" xmi:id="_al1S8tovEdqRBPR5WyT36A" type="Class" name="Main">
+ <children xmi:id="_ePDcYdovEdqRBPR5WyT36A" sourceEdges="_Fd3lQdowEdqRBPR5WyT36A _R5Rjwdo1EdqRBPR5WyT36A _pdfmkNo2EdqRBPR5WyT36A" targetEdges="_hmIF4dovEdqRBPR5WyT36A _mu9A4dovEdqRBPR5WyT36A _pe3jwNovEdqRBPR5WyT36A" element="_ePDcYNovEdqRBPR5WyT36A">
+ <children xmi:id="_ePJjANovEdqRBPR5WyT36A" type="ImageCompartment" element="_ePDcYNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_ePJjAdovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_ePJjAtovEdqRBPR5WyT36A" type="Stereotype" element="_ePDcYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ePJjA9ovEdqRBPR5WyT36A" type="Kind" element="_ePDcYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ePJjBNovEdqRBPR5WyT36A" type="Name" element="_ePDcYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ePJjBdovEdqRBPR5WyT36A" type="AttributeCompartment" element="_ePDcYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ePJjBtovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_ePJjB9ovEdqRBPR5WyT36A" type="OperationCompartment" element="_ePDcYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ePJjCNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_ePJjCdovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_ePDcYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ePJjCtovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_ePDcYtovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_ePDcY9ovEdqRBPR5WyT36A" x="6693" y="3545"/>
+ </children>
+ <children xmi:id="_fs1pANovEdqRBPR5WyT36A" sourceEdges="_hmIF4dovEdqRBPR5WyT36A _pe3jwNovEdqRBPR5WyT36A" targetEdges="_xInjYdovEdqRBPR5WyT36A" element="_fsviYNovEdqRBPR5WyT36A">
+ <children xmi:id="_fs1pA9ovEdqRBPR5WyT36A" type="ImageCompartment" element="_fsviYNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_fs1pBNovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_fs1pBdovEdqRBPR5WyT36A" type="Stereotype" element="_fsviYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_fs1pBtovEdqRBPR5WyT36A" type="Kind" element="_fsviYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_fs1pB9ovEdqRBPR5WyT36A" type="Name" element="_fsviYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_fs1pCNovEdqRBPR5WyT36A" type="AttributeCompartment" element="_fsviYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_fs1pCdovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_fs1pCtovEdqRBPR5WyT36A" type="OperationCompartment" element="_fsviYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_fs1pC9ovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_fs1pDNovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_fsviYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_fs1pDdovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_fs1pAdovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_fs1pAtovEdqRBPR5WyT36A" x="2226" y="8268"/>
+ </children>
+ <children xmi:id="_ikr_4NovEdqRBPR5WyT36A" sourceEdges="_mu9A4dovEdqRBPR5WyT36A" element="_ikl5QNovEdqRBPR5WyT36A">
+ <children xmi:id="_ikr_49ovEdqRBPR5WyT36A" type="ImageCompartment" element="_ikl5QNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_ikr_5NovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_ikr_5dovEdqRBPR5WyT36A" type="Stereotype" element="_ikl5QNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ikr_5tovEdqRBPR5WyT36A" type="Kind" element="_ikl5QNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ikr_59ovEdqRBPR5WyT36A" type="Name" element="_ikl5QNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ikr_6NovEdqRBPR5WyT36A" type="AttributeCompartment" element="_ikl5QNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ikr_6dovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_ikr_6tovEdqRBPR5WyT36A" type="OperationCompartment" element="_ikl5QNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ikr_69ovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_ikr_7NovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_ikl5QNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ikr_7dovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_ikr_4dovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_ikr_4tovEdqRBPR5WyT36A" x="9222" y="8268"/>
+ </children>
+ <children xmi:id="_tZF9odovEdqRBPR5WyT36A" sourceEdges="_xInjYdovEdqRBPR5WyT36A _BkUg0dowEdqRBPR5WyT36A" element="_tZF9oNovEdqRBPR5WyT36A">
+ <children xmi:id="_tZF9pNovEdqRBPR5WyT36A" type="ImageCompartment" element="_tZF9oNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_tZF9pdovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_tZF9ptovEdqRBPR5WyT36A" type="Stereotype" element="_tZF9oNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_tZF9p9ovEdqRBPR5WyT36A" type="Kind" element="_tZF9oNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_tZF9qNovEdqRBPR5WyT36A" type="Name" element="_tZF9oNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_tZF9qdovEdqRBPR5WyT36A" type="AttributeCompartment" element="_tZF9oNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_tZF9qtovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_tZF9q9ovEdqRBPR5WyT36A" type="OperationCompartment" element="_tZF9oNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_tZF9rNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_tZF9rdovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_tZF9oNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_tZF9rtovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_tZF9otovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_tZF9o9ovEdqRBPR5WyT36A" x="2226" y="12084"/>
+ </children>
+ <children xmi:id="_z_m-oNovEdqRBPR5WyT36A" sourceEdges="_cN4xsdo2EdqRBPR5WyT36A" targetEdges="_3Ic-4NovEdqRBPR5WyT36A _9XeF4tovEdqRBPR5WyT36A _Fd3lQdowEdqRBPR5WyT36A" element="_z_g4ANovEdqRBPR5WyT36A">
+ <children xmi:id="_z_m-o9ovEdqRBPR5WyT36A" type="ImageCompartment" element="_z_g4ANovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_z_m-pNovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_z_m-pdovEdqRBPR5WyT36A" type="Stereotype" element="_z_g4ANovEdqRBPR5WyT36A"/>
+ <children xmi:id="_z_m-ptovEdqRBPR5WyT36A" type="Kind" element="_z_g4ANovEdqRBPR5WyT36A"/>
+ <children xmi:id="_z_m-p9ovEdqRBPR5WyT36A" type="Name" element="_z_g4ANovEdqRBPR5WyT36A"/>
+ <children xmi:id="_z_m-qNovEdqRBPR5WyT36A" type="AttributeCompartment" element="_z_g4ANovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_z_m-qdovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_z_m-qtovEdqRBPR5WyT36A" type="OperationCompartment" element="_z_g4ANovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_z_m-q9ovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_z_m-rNovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_z_g4ANovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_z_m-rdovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_z_m-odovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_z_m-otovEdqRBPR5WyT36A" x="17172" y="6996"/>
+ </children>
+ <children xmi:id="_1y-ZsNovEdqRBPR5WyT36A" sourceEdges="_3Ic-4NovEdqRBPR5WyT36A _9-BEUNo2EdqRBPR5WyT36A" targetEdges="_BkUg0dowEdqRBPR5WyT36A" element="_1yyMcNovEdqRBPR5WyT36A">
+ <children xmi:id="_1y-Zs9ovEdqRBPR5WyT36A" type="ImageCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_1y-ZtNovEdqRBPR5WyT36A" width="1320" height="1320"/>
+ </children>
+ <children xmi:id="_1y-ZtdovEdqRBPR5WyT36A" type="Stereotype" element="_1yyMcNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_1y-ZttovEdqRBPR5WyT36A" type="Name" element="_1yyMcNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_1y-Zt9ovEdqRBPR5WyT36A" type="AttributeCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_1y-ZuNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_1y-ZudovEdqRBPR5WyT36A" type="OperationCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_1y-ZutovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_1y-Zu9ovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_1y-ZvNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_1y-ZvdovEdqRBPR5WyT36A" visible="false" type="StructureCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLShapeCompartmentStyle" xmi:id="_1y-ZvtovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLShapeStyle" xmi:id="_1y-ZsdovEdqRBPR5WyT36A" showStereotype="Label"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_1y-ZstovEdqRBPR5WyT36A" x="13992" y="12084"/>
+ </children>
+ <children xmi:id="_4WSrANovEdqRBPR5WyT36A" sourceEdges="_9XeF4tovEdqRBPR5WyT36A _9PaR4No2EdqRBPR5WyT36A" element="_4WMkYNovEdqRBPR5WyT36A">
+ <children xmi:id="_4WSrA9ovEdqRBPR5WyT36A" type="ImageCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_4WSrBNovEdqRBPR5WyT36A" width="1320" height="1320"/>
+ </children>
+ <children xmi:id="_4WSrBdovEdqRBPR5WyT36A" type="Stereotype" element="_4WMkYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_4WSrBtovEdqRBPR5WyT36A" type="Name" element="_4WMkYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_4WSrB9ovEdqRBPR5WyT36A" type="AttributeCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_4WSrCNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_4WSrCdovEdqRBPR5WyT36A" type="OperationCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_4WSrCtovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_4WSrC9ovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_4WSrDNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_4WSrDdovEdqRBPR5WyT36A" visible="false" type="StructureCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLShapeCompartmentStyle" xmi:id="_4WSrDtovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLShapeStyle" xmi:id="_4WSrAdovEdqRBPR5WyT36A" showStereotype="Label"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_4WSrAtovEdqRBPR5WyT36A" x="19716" y="12084"/>
+ </children>
+ <children xmi:id="_o2m3oNo0EdqRBPR5WyT36A" targetEdges="_9PaR4No2EdqRBPR5WyT36A _9-BEUNo2EdqRBPR5WyT36A" element="_o2gxANo0EdqRBPR5WyT36A">
+ <children xmi:id="_o2m3o9o0EdqRBPR5WyT36A" type="ImageCompartment" element="_o2gxANo0EdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_o2m3pNo0EdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_o2m3pdo0EdqRBPR5WyT36A" type="Stereotype" element="_o2gxANo0EdqRBPR5WyT36A"/>
+ <children xmi:id="_o2m3pto0EdqRBPR5WyT36A" type="Kind" element="_o2gxANo0EdqRBPR5WyT36A"/>
+ <children xmi:id="_o2m3p9o0EdqRBPR5WyT36A" type="Name" element="_o2gxANo0EdqRBPR5WyT36A"/>
+ <children xmi:id="_o2m3qNo0EdqRBPR5WyT36A" type="AttributeCompartment" element="_o2gxANo0EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_o2m3qdo0EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_o2m3qto0EdqRBPR5WyT36A" type="OperationCompartment" element="_o2gxANo0EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_o2m3q9o0EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_o2m3rNo0EdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_o2gxANo0EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_o2m3rdo0EdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_o2m3odo0EdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_o2m3oto0EdqRBPR5WyT36A" x="23532" y="6996"/>
+ </children>
+ <children xmi:id="_M0FLkNo1EdqRBPR5WyT36A" targetEdges="_R5Rjwdo1EdqRBPR5WyT36A _V7zlEdo1EdqRBPR5WyT36A" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <children xmi:id="_M0FLk9o1EdqRBPR5WyT36A" type="ImageCompartment" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_M0FLlNo1EdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_M0FLldo1EdqRBPR5WyT36A" type="Stereotype" element="_Mz_E8No1EdqRBPR5WyT36A"/>
+ <children xmi:id="_M0FLlto1EdqRBPR5WyT36A" type="Kind" element="_Mz_E8No1EdqRBPR5WyT36A"/>
+ <children xmi:id="_M0FLl9o1EdqRBPR5WyT36A" type="Name" element="_Mz_E8No1EdqRBPR5WyT36A"/>
+ <children xmi:id="_M0FLmNo1EdqRBPR5WyT36A" type="AttributeCompartment" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_M0FLmdo1EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_M0FLmto1EdqRBPR5WyT36A" type="OperationCompartment" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_M0FLm9o1EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_M0FLnNo1EdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_M0FLndo1EdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_M0FLkdo1EdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_M0FLkto1EdqRBPR5WyT36A" x="6678" y="318"/>
+ </children>
+ <children xmi:id="_TJHbANo1EdqRBPR5WyT36A" sourceEdges="_V7zlEdo1EdqRBPR5WyT36A" targetEdges="_cN4xsdo2EdqRBPR5WyT36A" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <children xmi:id="_TJHbA9o1EdqRBPR5WyT36A" type="ImageCompartment" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_TJHbBNo1EdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_TJHbBdo1EdqRBPR5WyT36A" type="Stereotype" element="_TI7NwNo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_TJHbBto1EdqRBPR5WyT36A" type="Kind" element="_TI7NwNo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_TJHbB9o1EdqRBPR5WyT36A" type="Name" element="_TI7NwNo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_TJHbCNo1EdqRBPR5WyT36A" type="AttributeCompartment" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_TJHbCdo1EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_TJHbCto1EdqRBPR5WyT36A" type="OperationCompartment" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_TJHbC9o1EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_TJHbDNo1EdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_TJHbDdo1EdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_TJHbAdo1EdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_TJHbAto1EdqRBPR5WyT36A" x="16854" y="318"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLDiagramStyle" xmi:id="_al1S89ovEdqRBPR5WyT36A"/>
+ <edges xmi:id="_hmIF4dovEdqRBPR5WyT36A" element="_hmIF4NovEdqRBPR5WyT36A" source="_fs1pANovEdqRBPR5WyT36A" target="_ePDcYdovEdqRBPR5WyT36A">
+ <children xmi:id="_hmIF5NovEdqRBPR5WyT36A" type="NameLabel" element="_hmIF4NovEdqRBPR5WyT36A">
+ <children xmi:id="_hmIF5tovEdqRBPR5WyT36A" type="Stereotype" element="_hmIF4NovEdqRBPR5WyT36A"/>
+ <children xmi:id="_hmIF59ovEdqRBPR5WyT36A" type="Name" element="_hmIF4NovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_hmIF5dovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_hmIF4tovEdqRBPR5WyT36A" routing="Tree" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_hmIF49ovEdqRBPR5WyT36A" points="[26, -31, -110, 148]$[140, -148, 4, 31]"/>
+ </edges>
+ <edges xmi:id="_mu9A4dovEdqRBPR5WyT36A" element="_mu9A4NovEdqRBPR5WyT36A" source="_ikr_4NovEdqRBPR5WyT36A" target="_ePDcYdovEdqRBPR5WyT36A">
+ <children xmi:id="_mu9A5NovEdqRBPR5WyT36A" type="NameLabel" element="_mu9A4NovEdqRBPR5WyT36A">
+ <children xmi:id="_mu9A5tovEdqRBPR5WyT36A" type="Stereotype" element="_mu9A4NovEdqRBPR5WyT36A"/>
+ <children xmi:id="_mu9A59ovEdqRBPR5WyT36A" type="Name" element="_mu9A4NovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_mu9A5dovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_mu9A4tovEdqRBPR5WyT36A" routing="Tree" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_mu9A49ovEdqRBPR5WyT36A" points="[-185, -820, 2937, 3916]$[-185, -3042, 2937, 1694]$[-3255, -3042, -133, 1694]$[-3255, -3916, -133, 820]"/>
+ </edges>
+ <edges xmi:id="_pe3jwNovEdqRBPR5WyT36A" element="_peM1YNovEdqRBPR5WyT36A" source="_fs1pANovEdqRBPR5WyT36A" target="_ePDcYdovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jw9ovEdqRBPR5WyT36A" type="NameLabel" element="_peM1YNovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jxdovEdqRBPR5WyT36A" type="Stereotype" element="_peM1YNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_pe3jxtovEdqRBPR5WyT36A" type="Name" element="_peM1YNovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3jxNovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_pe3jx9ovEdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_peM1YtovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jydovEdqRBPR5WyT36A" type="ToMultiplicity" element="_peM1YtovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3jyNovEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_pe3jytovEdqRBPR5WyT36A" type="ToRoleLabel" element="_peM1YtovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jzNovEdqRBPR5WyT36A" type="ToRole" element="_peM1YtovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3jy9ovEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_pe3jzdovEdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_peM1YdovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jz9ovEdqRBPR5WyT36A" type="FromMultiplicity" element="_peM1YdovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3jztovEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_pe3j0NovEdqRBPR5WyT36A" type="FromRoleLabel" element="_peM1YdovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3j0tovEdqRBPR5WyT36A" type="FromRole" element="_peM1YdovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3j0dovEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_pe3j09ovEdqRBPR5WyT36A" type="ToQualifierLabel" element="_peM1YtovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3j1dovEdqRBPR5WyT36A" type="QualifierCompartment" element="_peM1YtovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pe3j1tovEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3j1NovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_pe3j19ovEdqRBPR5WyT36A" type="FromQualifierLabel" element="_peM1YdovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3j2dovEdqRBPR5WyT36A" type="QualifierCompartment" element="_peM1YdovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pe3j2tovEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3j2NovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_pe3jwdovEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_pe3jwtovEdqRBPR5WyT36A" points="[-317, -820, -3916, 3916]$[-1931, -4762, -5530, -26]$[2382, -4762, -1217, -26]"/>
+ </edges>
+ <edges xmi:id="_xInjYdovEdqRBPR5WyT36A" element="_xInjYNovEdqRBPR5WyT36A" source="_tZF9odovEdqRBPR5WyT36A" target="_fs1pANovEdqRBPR5WyT36A">
+ <children xmi:id="_xInjZNovEdqRBPR5WyT36A" type="NameLabel" element="_xInjYNovEdqRBPR5WyT36A">
+ <children xmi:id="_xInjZtovEdqRBPR5WyT36A" type="Stereotype" element="_xInjYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_xInjZ9ovEdqRBPR5WyT36A" type="Name" element="_xInjYNovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_xInjZdovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_xInjYtovEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_xInjY9ovEdqRBPR5WyT36A" points="[-4, -31, 1, 113]$[-4, -115, 1, 29]"/>
+ </edges>
+ <edges xmi:id="_3Ic-4NovEdqRBPR5WyT36A" element="_3IW4QNovEdqRBPR5WyT36A" source="_1y-ZsNovEdqRBPR5WyT36A" target="_z_m-oNovEdqRBPR5WyT36A">
+ <children xmi:id="_3Ic-49ovEdqRBPR5WyT36A" type="NameLabel" element="_3IW4QNovEdqRBPR5WyT36A">
+ <children xmi:id="_3Ic-5dovEdqRBPR5WyT36A" type="Stereotype" element="_3IW4QNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_3Ic-5tovEdqRBPR5WyT36A" type="Name" element="_3IW4QNovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_3Ic-5NovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_3Ic-4dovEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_3Ic-4tovEdqRBPR5WyT36A" points="[6, -24, -37, 154]$[-22, -170, -65, 8]"/>
+ </edges>
+ <edges xmi:id="_9XeF4tovEdqRBPR5WyT36A" element="_9XeF4NovEdqRBPR5WyT36A" source="_4WSrANovEdqRBPR5WyT36A" target="_z_m-oNovEdqRBPR5WyT36A">
+ <children xmi:id="_9XeF5dovEdqRBPR5WyT36A" type="NameLabel" element="_9XeF4NovEdqRBPR5WyT36A">
+ <children xmi:id="_9XeF59ovEdqRBPR5WyT36A" type="Stereotype" element="_9XeF4NovEdqRBPR5WyT36A"/>
+ <children xmi:id="_9XeF6NovEdqRBPR5WyT36A" type="Name" element="_9XeF4NovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9XeF5tovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_9XeF49ovEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_9XeF5NovEdqRBPR5WyT36A" points="[-23, -23, 162, 151]$[-121, -170, 64, 4]"/>
+ </edges>
+ <edges xmi:id="_BkUg0dowEdqRBPR5WyT36A" element="_Bj8GUNowEdqRBPR5WyT36A" source="_tZF9odovEdqRBPR5WyT36A" target="_1y-ZsNovEdqRBPR5WyT36A">
+ <children xmi:id="_BkancNowEdqRBPR5WyT36A" type="NameLabel" element="_Bj8GUNowEdqRBPR5WyT36A">
+ <children xmi:id="_BkanctowEdqRBPR5WyT36A" type="Stereotype" element="_Bj8GUNowEdqRBPR5WyT36A"/>
+ <children xmi:id="_Bkanc9owEdqRBPR5WyT36A" type="Name" element="_Bj8GUNowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkancdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_BkandNowEdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_Bj8GUtowEdqRBPR5WyT36A">
+ <children xmi:id="_BkandtowEdqRBPR5WyT36A" type="ToMultiplicity" element="_Bj8GUtowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkanddowEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_Bkand9owEdqRBPR5WyT36A" type="ToRoleLabel" element="_Bj8GUtowEdqRBPR5WyT36A">
+ <children xmi:id="_BkanedowEdqRBPR5WyT36A" type="ToRole" element="_Bj8GUtowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkaneNowEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_BkanetowEdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_Bj8GUdowEdqRBPR5WyT36A">
+ <children xmi:id="_BkanfNowEdqRBPR5WyT36A" type="FromMultiplicity" element="_Bj8GUdowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Bkane9owEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_BkanfdowEdqRBPR5WyT36A" type="FromRoleLabel" element="_Bj8GUdowEdqRBPR5WyT36A">
+ <children xmi:id="_Bkanf9owEdqRBPR5WyT36A" type="FromRole" element="_Bj8GUdowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkanftowEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_BkangNowEdqRBPR5WyT36A" type="ToQualifierLabel" element="_Bj8GUtowEdqRBPR5WyT36A">
+ <children xmi:id="_BkangtowEdqRBPR5WyT36A" type="QualifierCompartment" element="_Bj8GUtowEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_Bkang9owEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkangdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_BkanhNowEdqRBPR5WyT36A" type="FromQualifierLabel" element="_Bj8GUdowEdqRBPR5WyT36A">
+ <children xmi:id="_BkanhtowEdqRBPR5WyT36A" type="QualifierCompartment" element="_Bj8GUdowEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_Bkanh9owEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkanhdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_BkUg0towEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_BkUg09owEdqRBPR5WyT36A" points="[83, -24, -490, 123]$[486, -151, -87, -4]"/>
+ </edges>
+ <edges xmi:id="_Fd3lQdowEdqRBPR5WyT36A" element="_FdlRYNowEdqRBPR5WyT36A" source="_ePDcYdovEdqRBPR5WyT36A" target="_z_m-oNovEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lRNowEdqRBPR5WyT36A" type="NameLabel" element="_FdlRYNowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lRtowEdqRBPR5WyT36A" type="Stereotype" element="_FdlRYNowEdqRBPR5WyT36A"/>
+ <children xmi:id="_Fd3lR9owEdqRBPR5WyT36A" type="Name" element="_FdlRYNowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lRdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_Fd3lSNowEdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_FdlRYtowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lStowEdqRBPR5WyT36A" type="ToMultiplicity" element="_FdlRYtowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lSdowEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_Fd3lS9owEdqRBPR5WyT36A" type="ToRoleLabel" element="_FdlRYtowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lTdowEdqRBPR5WyT36A" type="ToRole" element="_FdlRYtowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lTNowEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_Fd3lTtowEdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_FdlRYdowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lUNowEdqRBPR5WyT36A" type="FromMultiplicity" element="_FdlRYdowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lT9owEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_Fd3lUdowEdqRBPR5WyT36A" type="FromRoleLabel" element="_FdlRYdowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lU9owEdqRBPR5WyT36A" type="FromRole" element="_FdlRYdowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lUtowEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_Fd3lVNowEdqRBPR5WyT36A" type="ToQualifierLabel" element="_FdlRYtowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lVtowEdqRBPR5WyT36A" type="QualifierCompartment" element="_FdlRYtowEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_Fd3lV9owEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lVdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_Fd3lWNowEdqRBPR5WyT36A" type="FromQualifierLabel" element="_FdlRYdowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lWtowEdqRBPR5WyT36A" type="QualifierCompartment" element="_FdlRYdowEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_Fd3lW9owEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lWdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_Fd3lQtowEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Fd3lQ9owEdqRBPR5WyT36A" points="[46, -11, -369, -9]$[351, -11, -64, -9]"/>
+ </edges>
+ <edges xmi:id="_R5Rjwdo1EdqRBPR5WyT36A" element="_R5RjwNo1EdqRBPR5WyT36A" source="_ePDcYdovEdqRBPR5WyT36A" target="_M0FLkNo1EdqRBPR5WyT36A">
+ <children xmi:id="_R5RjxNo1EdqRBPR5WyT36A" type="NameLabel" element="_R5RjwNo1EdqRBPR5WyT36A">
+ <children xmi:id="_R5Rjxto1EdqRBPR5WyT36A" type="Stereotype" element="_R5RjwNo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_R5Rjx9o1EdqRBPR5WyT36A" type="Name" element="_R5RjwNo1EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_R5Rjxdo1EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_R5Rjwto1EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_R5Rjw9o1EdqRBPR5WyT36A" points="[-2, -31, -2, 91]$[-2, -91, -2, 31]"/>
+ </edges>
+ <edges xmi:id="_V7zlEdo1EdqRBPR5WyT36A" element="_V7zlENo1EdqRBPR5WyT36A" source="_TJHbANo1EdqRBPR5WyT36A" target="_M0FLkNo1EdqRBPR5WyT36A">
+ <children xmi:id="_V7zlFNo1EdqRBPR5WyT36A" type="NameLabel" element="_V7zlENo1EdqRBPR5WyT36A">
+ <children xmi:id="_V7zlFto1EdqRBPR5WyT36A" type="Stereotype" element="_V7zlENo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_V7zlF9o1EdqRBPR5WyT36A" type="Name" element="_V7zlENo1EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_V7zlFdo1EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_V7zlEto1EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_V7zlE9o1EdqRBPR5WyT36A" points="[-73, 0, 339, 0]$[-457, 0, -45, 0]"/>
+ </edges>
+ <edges xmi:id="_cN4xsdo2EdqRBPR5WyT36A" targetEdges="_pdfmkNo2EdqRBPR5WyT36A" element="_cNskcNo2EdqRBPR5WyT36A" source="_z_m-oNovEdqRBPR5WyT36A" target="_TJHbANo1EdqRBPR5WyT36A">
+ <children xmi:id="_cN4xtNo2EdqRBPR5WyT36A" type="NameLabel" element="_cNskcNo2EdqRBPR5WyT36A">
+ <children xmi:id="_cN4xtto2EdqRBPR5WyT36A" type="Stereotype" element="_cNskcNo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_cN4xt9o2EdqRBPR5WyT36A" type="Name" element="_cNskcNo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN4xtdo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_cN4xuNo2EdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_cNskcto2EdqRBPR5WyT36A">
+ <children xmi:id="_cN4xuto2EdqRBPR5WyT36A" type="ToMultiplicity" element="_cNskcto2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN4xudo2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_cN4xu9o2EdqRBPR5WyT36A" type="ToRoleLabel" element="_cNskcto2EdqRBPR5WyT36A">
+ <children xmi:id="_cN4xvdo2EdqRBPR5WyT36A" type="ToRole" element="_cNskcto2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN4xvNo2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_cN_fYNo2EdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_cNskcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_cN_fYto2EdqRBPR5WyT36A" type="FromMultiplicity" element="_cNskcdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN_fYdo2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_cN_fY9o2EdqRBPR5WyT36A" type="FromRoleLabel" element="_cNskcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_cN_fZdo2EdqRBPR5WyT36A" type="FromRole" element="_cNskcdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN_fZNo2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_cN_fZto2EdqRBPR5WyT36A" type="ToQualifierLabel" element="_cNskcto2EdqRBPR5WyT36A">
+ <children xmi:id="_cN_faNo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_cNskcto2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_cN_fado2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN_fZ9o2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_cN_fato2EdqRBPR5WyT36A" type="FromQualifierLabel" element="_cNskcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_cN_fbNo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_cNskcdo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_cN_fbdo2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN_fa9o2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_cN4xsto2EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_cN4xs9o2EdqRBPR5WyT36A" points="[-2, -29, 1, 91]$[26, -89, 29, 31]"/>
+ </edges>
+ <edges xmi:id="_pdfmkNo2EdqRBPR5WyT36A" element="_pdHMENo2EdqRBPR5WyT36A" source="_ePDcYdovEdqRBPR5WyT36A" target="_cN4xsdo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfml9o2EdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_pdTZUdo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmmdo2EdqRBPR5WyT36A" type="ToMultiplicity" element="_pdTZUdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmmNo2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_pdfmmto2EdqRBPR5WyT36A" type="ToRoleLabel" element="_pdTZUdo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmnNo2EdqRBPR5WyT36A" type="ToRole" element="_pdTZUdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmm9o2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_pdfmndo2EdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_pdTZUNo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmn9o2EdqRBPR5WyT36A" type="FromMultiplicity" element="_pdTZUNo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmnto2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_pdfmoNo2EdqRBPR5WyT36A" type="FromRoleLabel" element="_pdTZUNo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmoto2EdqRBPR5WyT36A" type="FromRole" element="_pdTZUNo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmodo2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_pdfmo9o2EdqRBPR5WyT36A" type="ToQualifierLabel" element="_pdTZUdo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmpdo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_pdTZUdo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfmpto2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmpNo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_pdfmp9o2EdqRBPR5WyT36A" type="FromQualifierLabel" element="_pdTZUNo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmqdo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_pdTZUNo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfmqto2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmqNo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_pdfmq9o2EdqRBPR5WyT36A" element="_pdHMENo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmrto2EdqRBPR5WyT36A" type="ImageCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_pdfmr9o2EdqRBPR5WyT36A" width="1320" height="1320"/>
+ </children>
+ <children xmi:id="_pdfmsNo2EdqRBPR5WyT36A" type="Stereotype" element="_pdHMENo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_pdfmsdo2EdqRBPR5WyT36A" type="Name" element="_pdHMENo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_pdfmsto2EdqRBPR5WyT36A" type="AttributeCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfms9o2EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_pdfmtNo2EdqRBPR5WyT36A" type="OperationCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfmtdo2EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_pdfmtto2EdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfmt9o2EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_pdfmuNo2EdqRBPR5WyT36A" visible="false" type="StructureCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLShapeCompartmentStyle" xmi:id="_pdfmudo2EdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLShapeStyle" xmi:id="_pdfmrNo2EdqRBPR5WyT36A" showStereotype="Label"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_pdfmrdo2EdqRBPR5WyT36A" y="1323"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_pdfmkdo2EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_pdfmkto2EdqRBPR5WyT36A" points="[46, 3, -366, 94]$[412, -91, 0, 0]"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_pdrz0No2EdqRBPR5WyT36A" id="100"/>
+ </edges>
+ <edges xmi:id="_9PaR4No2EdqRBPR5WyT36A" element="_9PH-ANo2EdqRBPR5WyT36A" source="_4WSrANovEdqRBPR5WyT36A" target="_o2m3oNo0EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR49o2EdqRBPR5WyT36A" type="NameLabel" element="_9PH-ANo2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR5do2EdqRBPR5WyT36A" type="Stereotype" element="_9PH-ANo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_9PaR5to2EdqRBPR5WyT36A" type="Name" element="_9PH-ANo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR5No2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_9PaR59o2EdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_9PH-Ato2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR6do2EdqRBPR5WyT36A" type="ToMultiplicity" element="_9PH-Ato2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR6No2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_9PaR6to2EdqRBPR5WyT36A" type="ToRoleLabel" element="_9PH-Ato2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR7No2EdqRBPR5WyT36A" type="ToRole" element="_9PH-Ato2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR69o2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_9PaR7do2EdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_9PH-Ado2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR79o2EdqRBPR5WyT36A" type="FromMultiplicity" element="_9PH-Ado2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR7to2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_9PaR8No2EdqRBPR5WyT36A" type="FromRoleLabel" element="_9PH-Ado2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR8to2EdqRBPR5WyT36A" type="FromRole" element="_9PH-Ado2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR8do2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_9PgYgNo2EdqRBPR5WyT36A" type="ToQualifierLabel" element="_9PH-Ato2EdqRBPR5WyT36A">
+ <children xmi:id="_9PgYgto2EdqRBPR5WyT36A" type="QualifierCompartment" element="_9PH-Ato2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_9PgYg9o2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PgYgdo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_9PgYhNo2EdqRBPR5WyT36A" type="FromQualifierLabel" element="_9PH-Ado2EdqRBPR5WyT36A">
+ <children xmi:id="_9PgYhto2EdqRBPR5WyT36A" type="QualifierCompartment" element="_9PH-Ado2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_9PgYh9o2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PgYhdo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_9PaR4do2EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_9PaR4to2EdqRBPR5WyT36A" points="[12, -24, -94, 162]$[80, -155, -26, 31]"/>
+ </edges>
+ <edges xmi:id="_9-BEUNo2EdqRBPR5WyT36A" element="_99uwcNo2EdqRBPR5WyT36A" source="_1y-ZsNovEdqRBPR5WyT36A" target="_o2m3oNo0EdqRBPR5WyT36A">
+ <children xmi:id="_9-BEU9o2EdqRBPR5WyT36A" type="NameLabel" element="_99uwcNo2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK8No2EdqRBPR5WyT36A" type="Stereotype" element="_99uwcNo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_9-HK8do2EdqRBPR5WyT36A" type="Name" element="_99uwcNo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-BEVNo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_9-HK8to2EdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_99uwcto2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK9No2EdqRBPR5WyT36A" type="ToMultiplicity" element="_99uwcto2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK89o2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_9-HK9do2EdqRBPR5WyT36A" type="ToRoleLabel" element="_99uwcto2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK99o2EdqRBPR5WyT36A" type="ToRole" element="_99uwcto2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK9to2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_9-HK-No2EdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_99uwcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK-to2EdqRBPR5WyT36A" type="FromMultiplicity" element="_99uwcdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK-do2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_9-HK-9o2EdqRBPR5WyT36A" type="FromRoleLabel" element="_99uwcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK_do2EdqRBPR5WyT36A" type="FromRole" element="_99uwcdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK_No2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_9-HK_to2EdqRBPR5WyT36A" type="ToQualifierLabel" element="_99uwcto2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HLANo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_99uwcto2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_9-HLAdo2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK_9o2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_9-HLAto2EdqRBPR5WyT36A" type="FromQualifierLabel" element="_99uwcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HLBNo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_99uwcdo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_9-HLBdo2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HLA9o2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_9-BEUdo2EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_9-BEUto2EdqRBPR5WyT36A" points="[49, -24, -290, 162]$[404, -163, 65, 23]"/>
+ </edges>
+ </contents>
+ </eAnnotations>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1S9NovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S9dovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1S9tovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_PROFILES/Basic.profile.uml2#_6mFRgK86Edih9-GG5afQ0g"/>
+ <importedProfile href="pathmap://UML2_PROFILES/Basic.profile.uml2#_6mFRgK86Edih9-GG5afQ0g"/>
+ </packageImport>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1S99ovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S-NovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1S-dovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_PROFILES/Intermediate.profile.uml2#_Cz7csK87Edih9-GG5afQ0g"/>
+ <importedProfile href="pathmap://UML2_PROFILES/Intermediate.profile.uml2#_Cz7csK87Edih9-GG5afQ0g"/>
+ </packageImport>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1S-tovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S-9ovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1S_NovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_PROFILES/Complete.profile.uml2#_M7pTkK87Edih9-GG5afQ0g"/>
+ <importedProfile href="pathmap://UML2_PROFILES/Complete.profile.uml2#_M7pTkK87Edih9-GG5afQ0g"/>
+ </packageImport>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1S_dovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S_tovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1S_9ovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_MSL_PROFILES/Default.epx#_a_S3wNWLEdiy4IqP8whjFA?Default"/>
+ <importedProfile href="pathmap://UML2_MSL_PROFILES/Default.epx#_a_S3wNWLEdiy4IqP8whjFA?Default"/>
+ </packageImport>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1TANovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1TAdovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1TAtovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_MSL_PROFILES/Deployment.epx#_vjbuwOvHEdiDX5bji0iVSA?Deployment"/>
+ <importedProfile href="pathmap://UML2_MSL_PROFILES/Deployment.epx#_vjbuwOvHEdiDX5bji0iVSA?Deployment"/>
+ </packageImport>
+ <packageImport xmi:id="_al1TA9ovEdqRBPR5WyT36A">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML2_LIBRARIES/UML2PrimitiveTypes.library.uml2#_EfRZoK86EdieaYgxtVWN8Q"/>
+ </packageImport>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_ePDcYNovEdqRBPR5WyT36A" name="Context">
+ <generalization xmi:id="_R5RjwNo1EdqRBPR5WyT36A" general="_Mz_E8No1EdqRBPR5WyT36A"/>
+ <ownedAttribute xmi:id="_FdlRYdowEdqRBPR5WyT36A" name="scopecontext" visibility="private" type="_z_g4ANovEdqRBPR5WyT36A" association="_FdlRYNowEdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_FdlRZNowEdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_FdlRY9owEdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_fsviYNovEdqRBPR5WyT36A" name="CompositeContext">
+ <generalization xmi:id="_hmIF4NovEdqRBPR5WyT36A" general="_ePDcYNovEdqRBPR5WyT36A"/>
+ <ownedAttribute xmi:id="_peM1YdovEdqRBPR5WyT36A" name="context" visibility="private" type="_ePDcYNovEdqRBPR5WyT36A" association="_peM1YNovEdqRBPR5WyT36A" aggregation="composite">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_peM1ZNovEdqRBPR5WyT36A" value="-1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_peM1Y9ovEdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_ikl5QNovEdqRBPR5WyT36A" name="AtomicContext">
+ <generalization xmi:id="_mu9A4NovEdqRBPR5WyT36A" general="_ePDcYNovEdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_peM1YNovEdqRBPR5WyT36A" memberEnd="_peM1YdovEdqRBPR5WyT36A _peM1YtovEdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_peM1YtovEdqRBPR5WyT36A" visibility="private" type="_fsviYNovEdqRBPR5WyT36A" association="_peM1YNovEdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_tZF9oNovEdqRBPR5WyT36A" name="DeploymentContext">
+ <generalization xmi:id="_xInjYNovEdqRBPR5WyT36A" general="_fsviYNovEdqRBPR5WyT36A"/>
+ <ownedAttribute xmi:id="_Bj8GUdowEdqRBPR5WyT36A" name="modulescopecontext" visibility="private" type="_1yyMcNovEdqRBPR5WyT36A" association="_Bj8GUNowEdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_Bj8GVNowEdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_Bj8GU9owEdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_z_g4ANovEdqRBPR5WyT36A" name="ScopeContext">
+ <ownedAttribute xmi:id="_cNskcdo2EdqRBPR5WyT36A" name="instancewrapper" visibility="private" type="_TI7NwNo1EdqRBPR5WyT36A" association="_cNskcNo2EdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_cNskdNo2EdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_cNskc9o2EdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Class" xmi:id="_1yyMcNovEdqRBPR5WyT36A" name="ModuleScopeContext" clientDependency="_3IW4QNovEdqRBPR5WyT36A">
+ <implementation xmi:id="_3IW4QNovEdqRBPR5WyT36A" client="_1yyMcNovEdqRBPR5WyT36A" supplier="_z_g4ANovEdqRBPR5WyT36A" realizingClassifier="_z_g4ANovEdqRBPR5WyT36A" contract="_z_g4ANovEdqRBPR5WyT36A">
+ <mapping xmi:id="_3IW4QdovEdqRBPR5WyT36A"/>
+ </implementation>
+ <ownedAttribute xmi:id="_99uwcdo2EdqRBPR5WyT36A" name="scoperegistry" visibility="private" type="_o2gxANo0EdqRBPR5WyT36A" association="_99uwcNo2EdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_99uwdNo2EdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_99uwc9o2EdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Class" xmi:id="_4WMkYNovEdqRBPR5WyT36A" name="HTTPSessionScopeContext" clientDependency="_9XeF4NovEdqRBPR5WyT36A">
+ <implementation xmi:id="_9XeF4NovEdqRBPR5WyT36A" client="_4WMkYNovEdqRBPR5WyT36A" supplier="_z_g4ANovEdqRBPR5WyT36A" realizingClassifier="_z_g4ANovEdqRBPR5WyT36A" contract="_z_g4ANovEdqRBPR5WyT36A">
+ <mapping xmi:id="_9XeF4dovEdqRBPR5WyT36A"/>
+ </implementation>
+ <ownedAttribute xmi:id="_9PH-Ado2EdqRBPR5WyT36A" name="scoperegistry" visibility="private" type="_o2gxANo0EdqRBPR5WyT36A" association="_9PH-ANo2EdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_9PH-BNo2EdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_9PH-A9o2EdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_Bj8GUNowEdqRBPR5WyT36A" memberEnd="_Bj8GUdowEdqRBPR5WyT36A _Bj8GUtowEdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_Bj8GUtowEdqRBPR5WyT36A" visibility="private" type="_tZF9oNovEdqRBPR5WyT36A" association="_Bj8GUNowEdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_FdlRYNowEdqRBPR5WyT36A" memberEnd="_FdlRYdowEdqRBPR5WyT36A _FdlRYtowEdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_FdlRYtowEdqRBPR5WyT36A" visibility="private" type="_ePDcYNovEdqRBPR5WyT36A" association="_FdlRYNowEdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_o2gxANo0EdqRBPR5WyT36A" name="ScopeRegistry"/>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_Mz_E8No1EdqRBPR5WyT36A" name="Lifecycle"/>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_TI7NwNo1EdqRBPR5WyT36A" name="InstanceWrapper">
+ <generalization xmi:id="_V7zlENo1EdqRBPR5WyT36A" general="_Mz_E8No1EdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_cNskcNo2EdqRBPR5WyT36A" memberEnd="_cNskcdo2EdqRBPR5WyT36A _cNskcto2EdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_cNskcto2EdqRBPR5WyT36A" visibility="private" type="_z_g4ANovEdqRBPR5WyT36A" association="_cNskcNo2EdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:AssociationClass" xmi:id="_pdHMENo2EdqRBPR5WyT36A" name="AssociationClass1" memberEnd="_pdTZUNo2EdqRBPR5WyT36A _pdTZUdo2EdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_pdTZUNo2EdqRBPR5WyT36A" visibility="private" type="_cNskcNo2EdqRBPR5WyT36A" association="_pdHMENo2EdqRBPR5WyT36A"/>
+ <ownedEnd xmi:id="_pdTZUdo2EdqRBPR5WyT36A" visibility="private" type="_ePDcYNovEdqRBPR5WyT36A" association="_pdHMENo2EdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_9PH-ANo2EdqRBPR5WyT36A" memberEnd="_9PH-Ado2EdqRBPR5WyT36A _9PH-Ato2EdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_9PH-Ato2EdqRBPR5WyT36A" visibility="private" type="_4WMkYNovEdqRBPR5WyT36A" association="_9PH-ANo2EdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_99uwcNo2EdqRBPR5WyT36A" memberEnd="_99uwcdo2EdqRBPR5WyT36A _99uwcto2EdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_99uwcto2EdqRBPR5WyT36A" visibility="private" type="_1yyMcNovEdqRBPR5WyT36A" association="_99uwcNo2EdqRBPR5WyT36A"/>
+ </ownedMember>
+</uml:Model>
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java
new file mode 100644
index 0000000000..2a690dbf0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.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 org.apache.tuscany.sca.context;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ComponentContext;
+
+/**
+ * Interface implemented by the provider of the ComponentContext.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentContextFactory {
+ /**
+ * Create an instance of ComponentContext
+ *
+ * @param component The runtime component
+ * @return An instance of ComponentContext for the component
+ */
+ ComponentContext createComponentContext(CompositeContext compositeContext, RuntimeComponent component);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java
new file mode 100644
index 0000000000..23a50e5f22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.context;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+
+/**
+ * The context associated with the Node that provides access to ExtensionPointRegistry and EndpointRegistry
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeContext {
+ protected final static InheritableThreadLocal<CompositeContext> context = new InheritableThreadLocal<CompositeContext>();
+ protected ExtensionPointRegistry extensionPointRegistry;
+ protected EndpointRegistry endpointRegistry;
+ protected ComponentContextFactory componentContextFactory;
+ protected Composite domainComposite;
+ protected String nodeURI;
+ protected String domainURI;
+ protected Definitions systemDefinitions;
+
+ public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry, Composite domainComposite, String domainURI, String nodeURI, Definitions systemDefinitions) {
+ this.extensionPointRegistry = registry;
+ this.endpointRegistry = endpointRegistry;
+ ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class);
+ this.componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class);
+ this.domainComposite = domainComposite;
+ this.domainURI = domainURI;
+ this.nodeURI = nodeURI;
+ this.systemDefinitions = systemDefinitions;
+ }
+
+ public CompositeContext(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) {
+ this(registry, endpointRegistry, null, "default", "default", null);
+ }
+
+ /**
+ * @return
+ */
+ public static RuntimeComponent getCurrentComponent() {
+ Message message = ThreadMessageContext.getMessageContext();
+ if (message != null) {
+ Endpoint to = message.getTo();
+ if (to == null) {
+ return null;
+ }
+ RuntimeComponent component = (RuntimeComponent)message.getTo().getComponent();
+ return component;
+ }
+ return null;
+ }
+
+ /**
+ * @return
+ */
+ public static CompositeContext getCurrentCompositeContext() {
+ RuntimeComponent component = getCurrentComponent();
+ if (component != null) {
+ RuntimeComponentContext componentContext = component.getComponentContext();
+ return componentContext.getCompositeContext();
+ }
+ CompositeContext compositeContext = context.get();
+ if (compositeContext != null) {
+ return compositeContext;
+ }
+ return null;
+ }
+
+ public void bindComponent(RuntimeComponent runtimeComponent) {
+ RuntimeComponentContext componentContext =
+ (RuntimeComponentContext)componentContextFactory.createComponentContext(this, runtimeComponent);
+ runtimeComponent.setComponentContext(componentContext);
+ }
+ /**
+ *
+ * @param endpointReference
+ */
+ public void bindEndpointReference(EndpointReference endpointReference) {
+
+ }
+
+ /**
+ * Get the ExtensionPointRegistry for this node
+ * @return The ExtensionPointRegistry
+ */
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ return extensionPointRegistry;
+ }
+
+ /**
+ * Get the EndpointRegistry
+ * @return The EndpointRegistry for this node
+ */
+ public EndpointRegistry getEndpointRegistry() {
+ return endpointRegistry;
+ }
+
+ public Composite getDomainComposite() {
+ return domainComposite;
+ }
+
+ public static void setThreadCompositeContext(CompositeContext value) {
+ context.set(value);
+ }
+
+ public static void removeCompositeContext() {
+ context.remove();
+ }
+
+ public String getNodeURI() {
+ return nodeURI;
+ }
+
+ public String getDomainURI() {
+ return domainURI;
+ }
+
+ /**
+ * The system definitions that result from starting the runtime.
+ * TODO - these can be null when the SCAClient starts the runtime
+ *
+ * @return systemDefinitions
+ */
+ public Definitions getSystemDefinitions() {
+ return systemDefinitions;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
new file mode 100644
index 0000000000..ddcc46a1ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.context;
+
+/**
+ * An extension point for context factories.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ContextFactoryExtensionPoint {
+
+ /**
+ * Add a context factory extension.
+ *
+ * @param factory The factory to add
+ */
+ void addFactory(Object factory);
+
+ /**
+ * Remove a context factory extension.
+ *
+ * @param factory The factory to remove
+ */
+ void removeFactory(Object factory);
+
+ /**
+ * Get a factory implementing the given interface.
+ * @param factoryInterface the lookup key (factory interface)
+ * @return The factory
+ */
+ <T> T getFactory(Class<T> factoryInterface);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
new file mode 100644
index 0000000000..50882c9498
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.context;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+/**
+ * Default implementation of a model factory extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultContextFactoryExtensionPoint implements ContextFactoryExtensionPoint {
+
+ /**
+ * The Map of Factories that have been registered.
+ */
+ private HashMap<Class<?>, Object> factories = new HashMap<Class<?>, Object>();
+
+ private ExtensionPointRegistry registry;
+
+ public DefaultContextFactoryExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Add a model factory extension.
+ *
+ * @param factory The factory to add.
+ * @throws IllegalArgumentException if factory is null
+ */
+ public void addFactory(Object factory) throws IllegalArgumentException {
+ if (factory == null) {
+ throw new IllegalArgumentException("Cannot add null as a factory");
+ }
+
+ Class<?>[] interfaces = factory.getClass().getInterfaces();
+ for (int i = 0; i<interfaces.length; i++) {
+ factories.put(interfaces[i], factory);
+ }
+ }
+
+ /**
+ * Remove a model factory extension.
+ *
+ * @param factory The factory to remove
+ * @throws IllegalArgumentException if factory is null
+ */
+ public void removeFactory(Object factory) throws IllegalArgumentException {
+ if (factory == null) {
+ throw new IllegalArgumentException("Cannot remove null as a factory");
+ }
+
+ Class<?>[] interfaces = factory.getClass().getInterfaces();
+ for (int i = 0; i<interfaces.length; i++) {
+ factories.remove(interfaces[i]);
+ }
+ }
+
+ /**
+ * Get a factory implementing the given interface.
+ *
+ * @param factoryInterface The lookup key (factory interface)
+ * @return The factory
+ */
+ public <T> T getFactory(Class<T> factoryInterface) throws IllegalArgumentException {
+ if (factoryInterface == null) {
+ throw new IllegalArgumentException("Cannot get null as a factory");
+ }
+
+ Object factory = factories.get(factoryInterface);
+ if (factory == null) {
+
+ // Dynamically load a factory class declared under META-INF/services
+ try {
+ ServiceDeclaration factoryDeclaration = registry.getServiceDiscovery().getServiceDeclaration(factoryInterface.getName());
+ if (factoryDeclaration != null) {
+ Class<?> factoryClass = factoryDeclaration.loadClass();
+
+ // Default empty constructor
+ Constructor<?> constructor = factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+
+ // Cache the loaded factory
+ addFactory(factory);
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ }
+
+ return factoryInterface.cast(factory);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java
new file mode 100644
index 0000000000..5b91db124c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.context;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+
+/**
+ * Interface implemented by the provider of the property values
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PropertyValueFactory {
+
+ /**
+ * This method will create an instance of the value for the specified Property.
+ *
+ * @param property The Property from which to retrieve the property value
+ * @param type The type of the property value being retrieved from the Property
+ * @param <B> Type type of the property value being looked up
+ *
+ * @return the value for the Property
+ */
+ <B> B createPropertyValue(ComponentProperty property, Class<B> type);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java
new file mode 100644
index 0000000000..4475427d4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.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 org.apache.tuscany.sca.context;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.RequestContext;
+
+/**
+ * Interface implemented by the provider of the RequestContext.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface RequestContextFactory {
+ /**
+ * @return An instance of RequestContext for the current invocation
+ */
+ RequestContext createRequestContext(RuntimeComponent component);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java
new file mode 100644
index 0000000000..d6237b7ce3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.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.context;
+
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Class for tunnelling a WorkContext through the invocation of a user class.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class ThreadMessageContext {
+
+ private static final ThreadLocal<Message> CONTEXT = new ThreadLocal<Message>();
+
+ private ThreadMessageContext() {
+ }
+
+ public static Message setMessageContext(Message context) {
+ Message old = CONTEXT.get();
+ CONTEXT.set(context);
+ return old;
+ }
+
+ /**
+ * Returns the WorkContext for the current thread.
+ *
+ * @return the WorkContext for the current thread
+ */
+ public static Message getMessageContext() {
+ return CONTEXT.get();
+ }
+
+ /**
+ * Removes and state from the current thread to ensure that
+ * any associated classloaders can be GCd
+ */
+ public static void removeMessageContext() {
+ CONTEXT.remove();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java
new file mode 100644
index 0000000000..957a15ce8a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.invocation;
+
+/**
+ * An invoker or interceptor can optionally implement this interface to indicate if they can
+ * enforce the pass-by-value semantics for an operation on remotable interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DataExchangeSemantics {
+ /**
+ * Indicate if the data can be passed in by reference as they won't be mutated.
+ * @return true if pass-by-reference is allowed
+ */
+ boolean allowsPassByReference();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java
new file mode 100644
index 0000000000..42954555b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.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.invocation;
+
+/**
+ * Synchronous mediation associated with a client- or target- side wire.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Interceptor extends Invoker {
+
+ /**
+ * Sets the next invoker
+ * @param next The next invoker
+ */
+ void setNext(Invoker next);
+
+ /**
+ * Returns the next invoker or null
+ * @return The next Invoker
+ */
+ Invoker getNext();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
new file mode 100644
index 0000000000..579e0c3da9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.invocation;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * A wire consists of 1..n invocation chains associated with the operations of its source service contract.
+ * <p/>
+ * Invocation chains may contain <code>Interceptors</code> that process invocations.
+ * <p/>
+ * A <code>Message</code> is used to pass data associated with an invocation through the chain.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface InvocationChain {
+ /**
+ * Returns the target operation for this invocation chain.
+ *
+ * @return The target operation for this invocation chain
+ */
+ Operation getTargetOperation();
+
+ /**
+ * Updates the target operation for this invocation chain.
+ *
+ * @param operation The new target operation for this invocation chain
+ */
+ void setTargetOperation(Operation operation);
+
+ /**
+ * Returns the source operation for this invocation chain.
+ *
+ * @return The source operation for this invocation chain
+ */
+ Operation getSourceOperation();
+
+ /**
+ * Updates the source operation for this invocation chain.
+ *
+ * @param operation The new source operation for this invocation chain
+ */
+ void setSourceOperation(Operation operation);
+
+ /**
+ * Adds an interceptor to the chain. For reference side, it will be added to
+ * Phase.REFERENCE. For service side, it will be added to Phase.SERVICE
+ *
+ * @param interceptor The interceptor to add
+ */
+ void addInterceptor(Interceptor interceptor);
+
+ /**
+ * Adds an invoker to the chain
+ *
+ * @param invoker The invoker to add
+ */
+ void addInvoker(Invoker invoker);
+
+ /**
+ * Returns the first invoker in the chain.
+ *
+ * @return The first invoker in the chain
+ */
+ Invoker getHeadInvoker();
+
+ /**
+ * Get the first invoker that is on the same or later phase
+ * @param phase
+ * @return The first invoker that is on the same or later phase
+ */
+ Invoker getHeadInvoker(String phase);
+
+ /**
+ * Add an interceptor to the given phase
+ * @param phase
+ * @param interceptor
+ */
+ void addInterceptor(String phase, Interceptor interceptor);
+
+ /**
+ * Indicate if the data can be passed in by reference as they won't be mutated.
+ * @return true if pass-by-reference is allowed
+ */
+ boolean allowsPassByReference();
+ /**
+ * Force the invocation to allow pass-by-reference
+ * @param allowsPBR
+ */
+ void setAllowsPassByReference(boolean allowsPBR);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java
new file mode 100644
index 0000000000..69309f6dd0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.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.sca.invocation;
+
+/**
+ * Synchronous mediation associated with a client- or target- side wire.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface Invoker {
+
+ /**
+ * Process a synchronous wire
+ *
+ * @param msg The request Message for the wire
+ * @return The response Message from the wire
+ */
+ Message invoke(Message msg);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java
new file mode 100644
index 0000000000..2bafdb64b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.invocation;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * Represents a request, response, or exception flowing through a wire
+ *
+ * @version $Rev $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Message {
+
+ /**
+ * Returns the body of the message, which will be the payload or parameters associated with the wire
+ * @return The body of the message
+ */
+ <T> T getBody();
+
+ /**
+ * Sets the body of the message.
+ * @param body The body of the message
+ */
+ <T> void setBody(T body);
+
+ /**
+ * Get the end point reference of the source reference
+ * @return The end point reference of the reference originating the message
+ */
+ EndpointReference getFrom();
+
+ /**
+ * Set the end point reference of the reference originating the message
+ * @param from The end point reference of the reference originating the message
+ */
+ void setFrom(EndpointReference from);
+
+ /**
+ * Get the end point reference of target service
+ * @return The end point reference of the service that the message targets
+ */
+ Endpoint getTo();
+
+ /**
+ * Set the end point reference of target service
+ * @param to The end point reference of the service that the message targets
+ */
+ void setTo(Endpoint to);
+
+ /**
+ * Returns the id of the message
+ * @return The message Id
+ */
+ Object getMessageID();
+
+ /**
+ * Sets the id of the message
+ * @param messageId The message ID
+ */
+ void setMessageID(Object messageId);
+
+ /**
+ * Determines if the message represents a fault/exception
+ *
+ * @return true If the message body is a fault object, false if the body is a normal payload
+ */
+ boolean isFault();
+
+ /**
+ * Set the message body with a fault object. After this method is called, isFault() returns true.
+ *
+ * @param fault The fault object represents an exception
+ */
+ <T> void setFaultBody(T fault);
+
+ /**
+ * Returns the operation that created the message.
+ *
+ * @return The operation that created the message
+ */
+ Operation getOperation();
+
+ /**
+ * Sets the operation that created the message.
+ *
+ * @param op The operation that created the message
+ */
+ void setOperation(Operation op);
+
+ /**
+ * Returns a list of objects that are contained in the message header
+ *
+ * @return
+ */
+ Map<String, Object> getHeaders();
+
+ /**
+ * Returns the binding context in force for this message
+ */
+ <T> T getBindingContext();
+
+ /**
+ * Set the binding context that is in force for this message
+ * @param bindingContext
+ */
+ <T> void setBindingContext(T bindingContext);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java
new file mode 100644
index 0000000000..711c09728b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.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.sca.invocation;
+
+
+/**
+ * A factory for messages
+ *
+ * @version $Rev $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface MessageFactory {
+
+ /**
+ * Creates a new message.
+ *
+ * @return The new message
+ */
+ Message createMessage();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java
new file mode 100644
index 0000000000..8bb81b7eda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.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.invocation;
+
+/**
+ * Tuscany built-in phases for the invocation chain. The phases are organized
+ * here such that a message passing from reference component implementation to
+ * service component implementation passes through the phases from top to bottom
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Phase {
+
+ // Reference operation chains
+
+ String REFERENCE = "component.reference"; // The first phase for outgoing invocations via a reference
+ String REFERENCE_INTERFACE = "reference.interface"; // data transformation and validation
+ String REFERENCE_POLICY = "reference.policy"; // reference policy handling
+ String REFERENCE_BINDING = "reference.binding"; // reference binding invoker
+
+ // Reference binding chain
+
+ String REFERENCE_BINDING_WIREFORMAT = "reference.binding.wireformat";
+ String REFERENCE_BINDING_POLICY = "reference.binding.policy";
+ String REFERENCE_BINDING_TRANSPORT = "reference.binding.transport";
+
+ // Service binding chain
+
+ String SERVICE_BINDING_TRANSPORT = "service.binding.transport";
+ String SERVICE_BINDING_OPERATION_SELECTOR = "service.binding.operationselector";
+ String SERVICE_BINDING_WIREFORMAT = "service.binding.wireformat";
+ String SERVICE_BINDING_POLICY = "service.binding.policy";
+
+ // Service operation chains
+
+ String SERVICE_BINDING = "service.binding"; // The first phase for incoming invocations via a service
+ String SERVICE_POLICY = "service.policy"; // service policy handling
+ String SERVICE_INTERFACE = "service.interface"; // data validation and transformation
+ String SERVICE = "component.service"; // TODO: not sure if we need to have this phase
+ String IMPLEMENTATION_POLICY = "implementation.policy"; // implementation policy handling
+ String IMPLEMENTATION = "component.implementation"; // implementation invoker
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.java
new file mode 100644
index 0000000000..f77a662779
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.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.invocation;
+
+/**
+ * An interceptor that is designated to be a given phase
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PhasedInterceptor extends Interceptor {
+ /**
+ * Get the name of the phase that this interceptor is positioned
+ * @return
+ */
+ String getPhase();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java
new file mode 100644
index 0000000000..7d20ec7fc0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.management;
+
+import java.util.Map;
+
+public interface ConfigAttributes {
+ Map<String, String> getAttributes();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java
new file mode 100644
index 0000000000..3887db4873
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.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.sca.management;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Interface for the management service abstraction. The implementation
+ * could be based on a variety of technologies including JMX, WSDM,
+ * SNMP etc.
+ *
+ * @version $Revision$ $Date$
+ */
+public interface ManagementService {
+
+ /**
+ * Registers a component for management.
+ *
+ * @param name Name of the component.
+ * @param component Component to be registered.
+ */
+ void registerComponent(String name, RuntimeComponent component);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java
new file mode 100644
index 0000000000..d4fcc0e8fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.provider;
+
+import java.security.Policy;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicyContainer;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Abstract base class for policy providers
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class BasePolicyProvider<T> implements PolicyProvider {
+ protected Class<T> policyType;
+ protected PolicySubject subject;
+
+ protected BasePolicyProvider(Class<T> policyType, PolicySubject subject) {
+ this.policyType = policyType;
+ this.subject = subject;
+ }
+
+ protected List<T> findPolicies() {
+ List<T> policies = new ArrayList<T>();
+ List<PolicySet> policySets = subject.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (policyType.isInstance(p)) {
+ policies.add(policyType.cast(p));
+ }
+
+ if (p instanceof PolicyExpression) {
+ PolicyExpression exp = (PolicyExpression)p;
+ if (policyType.isInstance(exp.getPolicy())) {
+ policies.add(policyType.cast(exp.getPolicy()));
+ }
+
+ // TODO - some code to handle the case where the
+ // policy expression is a WS-Policy
+ // Experimental at the moment.
+ if (PolicyContainer.class.isInstance(exp.getPolicy())){
+ Object policy = ((PolicyContainer)exp.getPolicy()).getChildPolicy(policyType);
+ if(policy != null){
+ policies.add(policyType.cast(policy));
+ }
+ }
+ }
+ }
+ }
+ return policies;
+ }
+
+ protected List<PolicySet> findPolicySets() {
+ List<PolicySet> policies = new ArrayList<PolicySet>();
+ List<PolicySet> policySets = subject.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (policyType.isInstance(p)) {
+ policies.add(ps);
+ }
+ if (p instanceof PolicyExpression) {
+ PolicyExpression exp = (PolicyExpression)p;
+ if (policyType.isInstance(exp.getPolicy())) {
+ policies.add(ps);
+ }
+ }
+ }
+ }
+ return policies;
+ }
+
+ protected PolicySet findPolicySet() {
+ List<PolicySet> policySets = subject.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (policyType.isInstance(p)) {
+ return ps;
+ }
+ if (p instanceof PolicyExpression) {
+ PolicyExpression exp = (PolicyExpression)p;
+ if (policyType.isInstance(exp.getPolicy())) {
+ return ps;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ protected String getContext() {
+ if (subject instanceof Endpoint) {
+ Endpoint endpoint = (Endpoint)subject;
+ return endpoint.getURI();
+ } else if (subject instanceof EndpointReference) {
+ EndpointReference endpointReference = (EndpointReference)subject;
+ return endpointReference.getURI();
+ } else if (subject instanceof Component) {
+ Component component = (Component)subject;
+ return component.getURI();
+ }
+ return null;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ return null;
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ return null;
+ }
+
+ public void configureBinding(Object configuration){
+ }
+
+ protected InvocationChain getInvocationChain() {
+ if (subject instanceof RuntimeEndpoint) {
+ RuntimeEndpoint endpoint = (RuntimeEndpoint)subject;
+ List<InvocationChain> chains = endpoint.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getTargetOperation());
+ }
+
+ } else if (subject instanceof RuntimeEndpointReference) {
+ RuntimeEndpointReference endpointReference = (RuntimeEndpointReference)subject;
+ List<InvocationChain> chains = endpointReference.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getSourceOperation());
+ }
+ } else if (subject instanceof RuntimeComponent) {
+ RuntimeComponent component = (RuntimeComponent)subject;
+ for (ComponentService s : component.getServices()) {
+ RuntimeComponentService service = (RuntimeComponentService)s;
+ for (Endpoint ep : service.getEndpoints()) {
+ List<InvocationChain> chains = ((RuntimeEndpoint)ep).getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getTargetOperation());
+ }
+ }
+
+ }
+ }
+ return null;
+ }
+
+ protected void configure(InvocationChain invocationChain, Operation operation) {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java
new file mode 100644
index 0000000000..5f2e6bd315
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.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.sca.provider;
+
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+
+/**
+ * TODO RRB experiment
+ * This is an experiment extension to try out the request response
+ * binding function
+ * @version $Rev$ $Date$
+ */
+public interface BindingPolicyProvider extends PolicyProvider {
+ /**
+ * Create a binding interceptor
+ * @return An interceptor that realize the policySet
+ */
+ PhasedInterceptor createBindingInterceptor();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java
new file mode 100644
index 0000000000..36e34c11b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * A factory for creating the runtime artifacts that represent bindings.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface BindingProviderFactory<M extends Binding> extends ProviderFactory<M> {
+
+ /**
+ * Creates a new reference binding provider for the given endpoint reference
+ *
+ * @param endpointReference defines the component/reference/binding against which to create the provider
+ * @return The binding provider
+ */
+ ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference);
+
+ /**
+ * Creates a new service binding provider for the given component and
+ * service.
+ *
+ * @param endpoint defines the component/service/binding against which to create the provider
+ * @return The binding provider
+ */
+ ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
new file mode 100644
index 0000000000..40b6275667
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
@@ -0,0 +1,500 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.provider;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Default implementation of a provider factory extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExtensionPoint {
+
+ private ExtensionPointRegistry registry;
+ private final Map<Class<?>, ProviderFactory> providerFactories = new HashMap<Class<?>, ProviderFactory>();
+ private final List<PolicyProviderFactory> policyProviderFactories = new ArrayList<PolicyProviderFactory>();
+ private boolean loaded;
+
+ /**
+ * The default constructor. Does nothing.
+ *
+ */
+ public DefaultProviderFactoryExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Add a provider factory.
+ *
+ * @param providerFactory The provider factory
+ */
+ public void addProviderFactory(ProviderFactory providerFactory) {
+ if(providerFactory instanceof PolicyProviderFactory) {
+ policyProviderFactories.add((PolicyProviderFactory)providerFactory);
+ }
+ // Only add the 1st instance so that the ones with higher ranking with prevail
+ if (!providerFactories.containsKey(providerFactory.getModelType())) {
+ providerFactories.put(providerFactory.getModelType(), providerFactory);
+ }
+ }
+
+ /**
+ * Remove a provider factory.
+ *
+ * @param providerFactory The provider factory
+ */
+ public void removeProviderFactory(ProviderFactory providerFactory) {
+ if(providerFactory instanceof PolicyProviderFactory) {
+ policyProviderFactories.remove((PolicyProviderFactory)providerFactory);
+ }
+ providerFactories.remove(providerFactory.getModelType());
+ }
+
+ /**
+ * Returns the provider factory associated with the given model type.
+ * @param modelType A model type
+ * @return The provider factory associated with the given model type
+ */
+ public ProviderFactory getProviderFactory(Class<?> modelType) {
+ loadProviderFactories();
+
+ Class<?>[] classes = modelType.getInterfaces();
+ for (Class<?> c : classes) {
+ ProviderFactory factory = providerFactories.get(c);
+ if (factory != null) {
+ return factory;
+ }
+ }
+ return providerFactories.get(modelType);
+ }
+
+ public List<PolicyProviderFactory> getPolicyProviderFactories() {
+ loadProviderFactories();
+ return policyProviderFactories;
+ }
+
+ public <P extends ProviderFactory> Collection<P> getProviderFactories(Class<P> factoryType) {
+ loadProviderFactories();
+ List<P> factories = new ArrayList<P>();
+ for (ProviderFactory pf : providerFactories.values()) {
+ if (factoryType.isInstance(pf)) {
+ factories.add(factoryType.cast(pf));
+ }
+ }
+ return factories;
+ }
+
+ /**
+ * Load provider factories declared under META-INF/services.
+ * @param registry
+ */
+ private synchronized void loadProviderFactories() {
+ if (loaded)
+ return;
+
+ loadProviderFactories(BindingProviderFactory.class);
+ loadProviderFactories(ImplementationProviderFactory.class);
+ loadProviderFactories(PolicyProviderFactory.class);
+ loadProviderFactories(WireFormatProviderFactory.class);
+ loadProviderFactories(OperationSelectorProviderFactory.class);
+
+ loaded = true;
+ }
+
+ /**
+ * Load provider factories declared under META-INF/services.
+ * @param registry
+ * @param factoryClass
+ * @return
+ */
+ private List<ProviderFactory> loadProviderFactories(Class<?> factoryClass) {
+
+ // Get the provider factory service declarations
+ Collection<ServiceDeclaration> factoryDeclarations;
+ ServiceDiscovery serviceDiscovery = registry.getServiceDiscovery();
+ try {
+ factoryDeclarations = serviceDiscovery.getServiceDeclarations(factoryClass.getName(), true);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ List<ProviderFactory> factories = new ArrayList<ProviderFactory>();
+
+ for (ServiceDeclaration factoryDeclaration : factoryDeclarations) {
+ Map<String, String> attributes = factoryDeclaration.getAttributes();
+
+ // Load an implementation provider factory
+ if (factoryClass == ImplementationProviderFactory.class) {
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ ImplementationProviderFactory factory =
+ new LazyImplementationProviderFactory(registry, modelTypeName, factoryDeclaration);
+ addProviderFactory(factory);
+ factories.add(factory);
+
+ } else if (factoryClass == BindingProviderFactory.class) {
+
+ // Load a binding provider factory
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ BindingProviderFactory factory =
+ new LazyBindingProviderFactory(registry, modelTypeName, factoryDeclaration);
+ addProviderFactory(factory);
+ factories.add(factory);
+ } else if (factoryClass == PolicyProviderFactory.class) {
+ // Load a policy provider factory
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ PolicyProviderFactory factory =
+ new LazyPolicyProviderFactory(registry, modelTypeName, factoryDeclaration);
+ addProviderFactory(factory);
+ factories.add(factory);
+ } else if (factoryClass == WireFormatProviderFactory.class) {
+
+ // Load a wire format provider factory
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ WireFormatProviderFactory factory =
+ new LazyWireFormatProviderFactory(registry, modelTypeName, factoryDeclaration);
+ addProviderFactory(factory);
+ factories.add(factory);
+ } else if (factoryClass == OperationSelectorProviderFactory.class) {
+
+ // Load a wire format provider factory
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ OperationSelectorProviderFactory factory =
+ new LazyOperationSelectorProviderFactory(registry, modelTypeName, factoryDeclaration);
+ addProviderFactory(factory);
+ factories.add(factory);
+ }
+ }
+ return factories;
+ }
+
+ /**
+ * A wrapper around an implementation provider factory allowing lazy
+ * loading and initialization of implementation providers.
+ */
+ private static class LazyBindingProviderFactory implements BindingProviderFactory {
+
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration factoryDeclaration;
+ private BindingProviderFactory factory;
+ private Class<?> modelType;
+
+ private LazyBindingProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration factoryDeclaration) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.factoryDeclaration = factoryDeclaration;
+ }
+
+ @SuppressWarnings("unchecked")
+ private BindingProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<BindingProviderFactory> factoryClass =
+ (Class<BindingProviderFactory>)factoryDeclaration.loadClass();
+ Constructor<BindingProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return getFactory().createReferenceBindingProvider(endpointReference);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return getFactory().createServiceBindingProvider(endpoint);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+ modelType = factoryDeclaration.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+
+ }
+
+ /**
+ * A wrapper around an implementation provider factory allowing lazy
+ * loading and initialization of implementation providers.
+ */
+ private class LazyImplementationProviderFactory implements ImplementationProviderFactory {
+
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration providerClass;
+ private ImplementationProviderFactory factory;
+ private Class<?> modelType;
+
+ private LazyImplementationProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration providerClass) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.providerClass = providerClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private ImplementationProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<ImplementationProviderFactory> factoryClass =
+ (Class<ImplementationProviderFactory>)providerClass.loadClass();
+ Constructor<ImplementationProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ Implementation Implementation) {
+ return getFactory().createImplementationProvider(component, Implementation);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+
+ }
+
+ /**
+ * A wrapper around an policy provider factory allowing lazy
+ * loading and initialization of policy providers.
+ */
+ private class LazyPolicyProviderFactory implements PolicyProviderFactory {
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration providerClass;
+ private PolicyProviderFactory factory;
+ private Class<?> modelType;
+
+ private LazyPolicyProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration providerClass) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.providerClass = providerClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private PolicyProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<PolicyProviderFactory> factoryClass = (Class<PolicyProviderFactory>)providerClass.loadClass();
+ Constructor<PolicyProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return getFactory().createImplementationPolicyProvider(component);
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return getFactory().createReferencePolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return getFactory().createServicePolicyProvider(endpoint);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+ }
+
+ /**
+ * A wrapper around a wire format provider factory allowing lazy
+ * loading and initialization of wire format providers.
+ */
+ private class LazyWireFormatProviderFactory implements WireFormatProviderFactory {
+
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration providerClass;
+ private WireFormatProviderFactory factory;
+ private Class<?> modelType;
+
+ private LazyWireFormatProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration providerClass) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.providerClass = providerClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private WireFormatProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<WireFormatProviderFactory> factoryClass =
+ (Class<WireFormatProviderFactory>)providerClass.loadClass();
+ Constructor<WireFormatProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference){
+ return getFactory().createReferenceWireFormatProvider(endpointReference);
+ }
+
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint){
+ return getFactory().createServiceWireFormatProvider(endpoint);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+ }
+
+ /**
+ * A wrapper around a operation selector provider factory allowing lazy
+ * loading and initialization of operation selector providers.
+ */
+ private class LazyOperationSelectorProviderFactory implements OperationSelectorProviderFactory {
+
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration providerClass;
+ private OperationSelectorProviderFactory factory;
+ private Class<?> modelType;
+
+ private LazyOperationSelectorProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration providerClass) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.providerClass = providerClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private OperationSelectorProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<OperationSelectorProviderFactory> factoryClass =
+ (Class<OperationSelectorProviderFactory>)providerClass.loadClass();
+ Constructor<OperationSelectorProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference){
+ return getFactory().createReferenceOperationSelectorProvider(endpointReference);
+ }
+
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint){
+ return getFactory().createServiceOperationSelectorProvider(endpoint);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java
new file mode 100644
index 0000000000..a25814234a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.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 org.apache.tuscany.sca.provider;
+
+
+/**
+ * Defines the extra operation that service binding providers implement
+ * to configure the binding chain.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface EndpointProvider extends ServiceBindingProvider {
+ /**
+ * Configure the binding invocation chain
+ */
+ void configure();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.java
new file mode 100644
index 0000000000..209b057859
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.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 org.apache.tuscany.sca.provider;
+
+
+/**
+ * Defines the extra operation that reference binding providers implement
+ * to configure the binding chain.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface EndpointReferenceProvider extends ReferenceBindingProvider {
+ /**
+ * Configure the binding invocation chain
+ */
+ void configure();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java
new file mode 100644
index 0000000000..4e9fddb135
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.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.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * A component implementation can implement this interface in order to tie
+ * into the Tuscany runtime
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ImplementationProvider extends RuntimeProvider {
+
+ /**
+ * Create an invoker for the component implementation in the invocation
+ * chain. The invoker will be responsible for calling the implementation
+ * logic for the given component.
+ *
+ * @param service The component service
+ * @param operation The operation that the interceptor will handle
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
+ */
+ Invoker createInvoker(RuntimeComponentService service, Operation operation);
+
+ /**
+ * For bindings that invoke one-way callback operations asynchronously,
+ * there is no need to perform a thread switch before calling the invoker.
+ * This method indicates whether the binding has this capability.
+ *
+ * @return true if the callback invoker is able to invoke one-way operations
+ * asynchronously, false if all invocations are synchronous
+ */
+ boolean supportsOneWayInvocation();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java
new file mode 100644
index 0000000000..cfb06d9c70
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.provider;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * An interface for factories that create implementation providers.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ImplementationProviderFactory<M extends Implementation> extends ProviderFactory<M> {
+
+ /**
+ * Creates a new implementation provider for the given
+ * component.
+ *
+ * @param component The runtime component
+ * @param Implementation The implementation type
+ * @return The implementation provider
+ */
+ ImplementationProvider createImplementationProvider(RuntimeComponent component, M Implementation);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java
new file mode 100644
index 0000000000..c0346780d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.provider;
+
+import org.apache.tuscany.sca.invocation.Interceptor;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface OperationSelectorProvider {
+ /**
+ * Create an interceptor for the operation selector
+ * @return An interceptor that realize the policySet
+ */
+ Interceptor createInterceptor();
+
+ /**
+ * Get the phase that the interceptor should be added
+ * @return The phase that this interceptor belongs to
+ */
+ String getPhase();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java
new file mode 100644
index 0000000000..43ea8d171b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.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.provider;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface OperationSelectorProviderFactory<M extends OperationSelector> extends ProviderFactory<M> {
+ /**
+ * Create wire format provider for a given reference binding
+ * @param endpointReference TODO
+ * @return
+ */
+ OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param endpoint TODO
+ * @return
+ */
+ OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java
new file mode 100644
index 0000000000..f2b59a7c54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.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 org.apache.tuscany.sca.provider;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This interface can be optionally implemented by the Binding or Implementation providers to
+ * indicate if they implement the policies in the binding/implementation provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PolicyImplementor {
+ /**
+ * Get a list of policy names that are implemented by this policy implementor
+ * @return A list of policy names
+ */
+ List<QName> getImplementedPolicies();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java
new file mode 100644
index 0000000000..de0b62eecd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface PolicyProvider extends RuntimeProvider {
+ /**
+ * Create an interceptor for a given operation
+ *
+ * @param operation
+ * @return An interceptor that realizes the policySet
+ */
+ PhasedInterceptor createInterceptor(Operation operation);
+
+ /**
+ * Create a binding interceptor. The binding wire is
+ * not operation specific so an operation parameter
+ * isn't required
+ *
+ * @return An interceptor that realizes the policySet
+ */
+ PhasedInterceptor createBindingInterceptor();
+
+ /**
+ * Give the provider an opportunity to affect the
+ * binding configuration if required
+ *
+ * @param configurationContext the configuration context of the
+ * binding that will be modified
+ */
+ void configureBinding(Object configuration);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
new file mode 100644
index 0000000000..134df1c37e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.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.provider;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PolicyProviderFactory<M> extends ProviderFactory<M> {
+ /**
+ * Create policy provider for a given reference binding
+ * @param endpointReference The endpoint reference
+ * @return A policy provider for the endpoint reference
+ */
+ PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param endpoint The endpoint
+ * @return A policy provider for the endpoint
+ */
+ PolicyProvider createServicePolicyProvider(Endpoint endpoint);
+
+ /**
+ * Create policy provider for a given component implementation
+ * @param component
+ * @return A policy provider for the implementation
+ */
+ PolicyProvider createImplementationPolicyProvider(RuntimeComponent component);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java
new file mode 100644
index 0000000000..2102806881
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.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 org.apache.tuscany.sca.provider;
+
+/**
+ * A factory for runtime providers.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ProviderFactory<M> {
+
+ /**
+ * The model type that this factory creates providers for.
+ *
+ * @return the model type
+ */
+ Class<M> getModelType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java
new file mode 100644
index 0000000000..75c5544aa3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.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.sca.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+
+/**
+ * An extension point for provider factories. Holds all of the provider
+ * factories from loaded extension points. Allows a provider factory
+ * to be located based on a given model type. Hence the runtime can
+ * generate runtime artifacts from the in memory assembly model.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ProviderFactoryExtensionPoint {
+
+
+ /**
+ * Add a provider factory.
+ *
+ * @param providerFactory The provider factory
+ */
+ void addProviderFactory(ProviderFactory providerFactory);
+
+ /**
+ * Remove a provider factory.
+ *
+ * @param providerFactory The provider factory
+ */
+ void removeProviderFactory(ProviderFactory providerFactory);
+
+ /**
+ * Returns the provider factory associated with the given model type.
+ * @param modelType A model type
+ * @return The provider factory associated with the given model type
+ */
+ ProviderFactory getProviderFactory(Class<?> modelType);
+
+ /**
+ * Get a list of registered PolicyProviderFactory
+ * @return a list of registered PolicyProviderFactory
+ */
+ List<PolicyProviderFactory> getPolicyProviderFactories();
+
+ /**
+ * Get a collection of provider factories by the factory type
+ * @param <P>
+ * @param factoryType The factory type such as BindingProviderFactory
+ * @return a collection of provider factories of the factory type
+ */
+ <P extends ProviderFactory> Collection<P> getProviderFactories(Class<P> factoryType);
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java
new file mode 100644
index 0000000000..ab864dba3f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.provider;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+
+/**
+ * A reference binding implementation can options implement this
+ * interface to tie into the Tuscany SCA runtime
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ReferenceBindingProvider extends RuntimeProvider {
+ /**
+ * Create an invoker for the reference binding in the invocation chain. The
+ * invoker is responsible for making the outbound invocation over the
+ * binding protocol.
+ *
+ * @param operation The operation that the interceptor will handle
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
+ */
+ Invoker createInvoker(Operation operation);
+
+ /**
+ * Get the effective interface contract imposed by the binding. For example,
+ * it will be interface contract introspected from the WSDL portType used by
+ * the endpoint for a WebService binding.
+ *
+ * @return The effective interface contract, if null is returned, the
+ * interface contract for the component reference will be used
+ */
+ InterfaceContract getBindingInterfaceContract();
+
+ /**
+ * For bindings that invoke one-way operations asynchronously, there is no
+ * need to perform a thread switch before calling the invoker. This method
+ * indicates whether the binding has this capability.
+ *
+ * @return true if the binding invoker is able to invoke one-way operations
+ * asynchronously, false if all invocations are synchronous
+ */
+ boolean supportsOneWayInvocation();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/RuntimeProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/RuntimeProvider.java
new file mode 100644
index 0000000000..2afd44af31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/RuntimeProvider.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 org.apache.tuscany.sca.provider;
+
+/**
+ * The base interface for runtime providers that can be started or stoppped
+ */
+public interface RuntimeProvider {
+ /**
+ * This method will be invoked when the corresponding SCA component is started.
+ */
+ void start();
+
+ /**
+ * This method will be invoked when the corresponding SCA component is stopped
+ */
+ void stop();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java
new file mode 100644
index 0000000000..e7df45bfa8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.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.sca.provider;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * A service binding can optionally implement this interface to tie
+ * into the Tuscany SCA runtime
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ServiceBindingProvider extends RuntimeProvider {
+
+ /**
+ * Get the effective interface contract imposed by the binding. For example,
+ * it will be interface contract introspected from the WSDL portType used by
+ * the endpoint for a WebService binding.
+ *
+ * @return The effective interface contract, if null is returned, the
+ * interface contract for the component service will be used
+ */
+ InterfaceContract getBindingInterfaceContract();
+
+ /**
+ * For bindings that invoke one-way callback operations asynchronously,
+ * there is no need to perform a thread switch before calling the invoker.
+ * This method indicates whether the binding has this capability.
+ *
+ * @return true if the callback invoker is able to invoke one-way operations
+ * asynchronously, false if all invocations are synchronous
+ */
+ boolean supportsOneWayInvocation();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java
new file mode 100644
index 0000000000..674b708ef8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.provider;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface WireFormatProvider {
+
+ /**
+ * Set up the contract that describes the interface that
+ * is providing data to or accepting data from the
+ * wire format interceptor. The wire format's job
+ * is to translate between this interface contract and the
+ * format on the wire. The interface contract may be
+ * configured separately for request and response
+ * wire formats
+ *
+ * @return the wire format interface contract
+ */
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract);
+
+ /**
+ * Create an interceptor for the wire format
+ * @return An interceptor that realize the policySet
+ */
+ Interceptor createInterceptor();
+
+ /**
+ * Get the phase that the interceptor should be added
+ * @return The phase that this interceptor belongs to
+ */
+ String getPhase();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java
new file mode 100644
index 0000000000..3f629ddeef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.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.provider;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface WireFormatProviderFactory<M extends WireFormat> extends ProviderFactory<M> {
+ /**
+ * Create wire format provider for a given reference binding
+ * @param endpointReference The endpoint reference
+ * @return
+ */
+ WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param endpoint TODO
+ * @return
+ */
+ WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java
new file mode 100644
index 0000000000..b015891e93
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.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.sca.runtime;
+
+
+/**
+ * Denotes an error starting the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public class ActivationException extends Exception {
+ private static final long serialVersionUID = 8612661660934426123L;
+
+ public ActivationException(String message) {
+ super(message);
+ }
+
+ public ActivationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistryFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistryFactory.java
new file mode 100644
index 0000000000..4f6a29bbcc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseDomainRegistryFactory.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+
+/**
+ * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the
+ * given domain
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class BaseDomainRegistryFactory implements DomainRegistryFactory, LifeCycleListener {
+ protected ExtensionPointRegistry registry;
+ protected Map<Object, EndpointRegistry> endpointRegistries = new ConcurrentHashMap<Object, EndpointRegistry>();
+ protected List<EndpointListener> listeners = new ArrayList<EndpointListener>();
+
+ /**
+ * @param extensionRegistry
+ */
+ public BaseDomainRegistryFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public void start() {
+ }
+
+ public synchronized EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI) {
+ if (endpointRegistryURI == null) {
+ endpointRegistryURI = domainURI;
+ }
+
+ Object key = getKey(endpointRegistryURI, domainURI);
+
+ EndpointRegistry endpointRegistry = endpointRegistries.get(key);
+ if (endpointRegistry != null) {
+ return endpointRegistry;
+ }
+
+ endpointRegistry = createEndpointRegistry(endpointRegistryURI, domainURI);
+
+ if (endpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)endpointRegistry).start();
+ }
+
+ for (EndpointListener listener : listeners) {
+ endpointRegistry.addListener(listener);
+ }
+ endpointRegistries.put(key, endpointRegistry);
+ return endpointRegistry;
+ }
+
+ protected Object getKey(String endpointRegistryURI, String domainURI) {
+ return endpointRegistryURI + "," + domainURI;
+ }
+
+ protected abstract EndpointRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI);
+
+ public void stop() {
+ for (EndpointRegistry endpointRegistry : endpointRegistries.values()) {
+ if (endpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)endpointRegistry).stop();
+ }
+ }
+ endpointRegistries.clear();
+ listeners.clear();
+ }
+
+ public synchronized Collection<EndpointRegistry> getEndpointRegistries() {
+ return new ArrayList<EndpointRegistry>(endpointRegistries.values());
+ }
+
+ public synchronized void addListener(EndpointListener listener) {
+ listeners.add(listener);
+ for (EndpointRegistry registry : endpointRegistries.values()) {
+ registry.addListener(listener);
+ }
+ }
+
+ public synchronized List<EndpointListener> getListeners() {
+ return listeners;
+ }
+
+ public synchronized void removeListener(EndpointListener listener) {
+ listeners.remove(listener);
+ for (EndpointRegistry registry : endpointRegistries.values()) {
+ registry.removeListener(listener);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseEndpointRegistry.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseEndpointRegistry.java
new file mode 100644
index 0000000000..0b6b93edc0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/BaseEndpointRegistry.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.sca.runtime;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+
+/**
+ * A replicated EndpointRegistry based on Apache Tomcat Tribes
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class BaseEndpointRegistry implements EndpointRegistry, LifeCycleListener {
+ protected final static Logger logger = Logger.getLogger(BaseEndpointRegistry.class.getName());
+
+ protected String domainRegistryURI;
+ protected String domainURI;
+
+ protected List<EndpointReference> endpointreferences = new CopyOnWriteArrayList<EndpointReference>();
+ protected List<EndpointListener> listeners = new CopyOnWriteArrayList<EndpointListener>();
+ protected ExtensionPointRegistry registry;
+ protected Map<String, String> attributes;
+
+ public BaseEndpointRegistry(ExtensionPointRegistry registry,
+ Map<String, String> attributes,
+ String domainRegistryURI,
+ String domainURI) {
+ this.registry = registry;
+ this.domainURI = domainURI;
+ this.domainRegistryURI = domainRegistryURI;
+ this.attributes = attributes;
+ }
+
+ public abstract void addEndpoint(Endpoint endpoint);
+
+ public void addEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.add(endpointReference);
+ logger.fine("Add endpoint reference - " + endpointReference);
+ }
+
+ public void addListener(EndpointListener listener) {
+ listeners.add(listener);
+ }
+
+ protected void endpointAdded(Endpoint endpoint) {
+ ((RuntimeEndpoint)endpoint).bind(registry, this);
+ for (EndpointListener listener : listeners) {
+ listener.endpointAdded(endpoint);
+ }
+ }
+
+ protected void endpointRemoved(Endpoint endpoint) {
+ ((RuntimeEndpoint)endpoint).bind(registry, this);
+ for (EndpointListener listener : listeners) {
+ listener.endpointRemoved(endpoint);
+ }
+ }
+
+ protected void endpointUpdated(Endpoint oldEp, Endpoint newEp) {
+ ((RuntimeEndpoint)newEp).bind(registry, this);
+ for (EndpointListener listener : listeners) {
+ listener.endpointUpdated(oldEp, newEp);
+ }
+ }
+
+ public List<Endpoint> findEndpoint(EndpointReference endpointReference) {
+ logger.fine("Find endpoint for reference - " + endpointReference);
+
+ if (endpointReference.getReference() != null) {
+ Endpoint targetEndpoint = endpointReference.getTargetEndpoint();
+ String uri = targetEndpoint.getURI();
+ // [rfeng] This is a workaround to deal with the case that the endpoint URI doesn't have the
+ // service name to avoid confusion between structural URIs and service URIs
+ if (uri.indexOf('#') == -1) {
+ uri = uri + "#service()";
+ }
+ return findEndpoint(uri);
+ }
+
+ return new ArrayList<Endpoint>();
+ }
+
+ public abstract List<Endpoint> findEndpoint(String uri);
+
+ public List<EndpointReference> findEndpointReference(Endpoint endpoint) {
+ return endpointreferences;
+ }
+
+ public abstract Endpoint getEndpoint(String uri);
+
+ public List<EndpointReference> getEndpointReferences() {
+ return endpointreferences;
+ }
+
+ public abstract Collection<Endpoint> getEndpoints();
+
+ public List<EndpointListener> getListeners() {
+ return listeners;
+ }
+
+ public abstract void removeEndpoint(Endpoint endpoint);
+
+ public void removeEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.remove(endpointReference);
+ logger.fine("Remove endpoint reference - " + endpointReference);
+ }
+
+ public void removeListener(EndpointListener listener) {
+ listeners.remove(listener);
+ }
+
+ public String getDomainURI() {
+ return domainURI;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java
new file mode 100644
index 0000000000..d9bdc2b6f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.context.CompositeContext;
+
+/**
+ * Start/stop a composite
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompositeActivator {
+ /**
+ * Activate a composite
+ * @param compositeContext The context of the Node
+ * @param composite
+ */
+ void activate(CompositeContext compositeContext, Composite composite) throws ActivationException;
+
+ /**
+ * Activate a component reference
+ * @param compositeContext The context of the Node
+ * @param component
+ * @param ref
+ */
+ void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference ref);
+
+ /**
+ * Activate a component reference
+ * @param compositeContext The context of the Node
+ * @param component
+ * @param ref
+ */
+ void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentService service);
+
+ /**
+ * De-activate a component reference
+ * @param component
+ * @param ref
+ */
+ void deactivate(RuntimeComponent component, RuntimeComponentReference ref);
+
+ /**
+ * De-activate a component reference
+ * @param component
+ * @param ref
+ */
+ void deactivate(RuntimeComponent component, RuntimeComponentService service);
+
+ /**
+ * Stop a composite
+ * @param composite
+ */
+ void deactivate(Composite composite) throws ActivationException;
+
+ /**
+ * Start a component reference
+ * @param compositeContext The context of the Node
+ * @param component
+ * @param ref
+ */
+ void start(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference ref);
+
+
+ /**
+ * Start a component
+ * @param component
+ */
+ void start(CompositeContext compositeContext, Component component) throws ActivationException;
+
+ /**
+ * Stop a component
+ * @param component
+ */
+ void stop(CompositeContext compositeContext, Component component) throws ActivationException;
+
+ /**
+ * Start components in a composite
+ * @param composite
+ */
+ void start(CompositeContext compositeContext, Composite composite) throws ActivationException;
+
+ /**
+ * Stop components in a composite
+ * @param composite
+ */
+ void stop(CompositeContext compositeContext, Composite composite) throws ActivationException;
+
+ /**
+ * Activate an endpoint
+ * @param compositeContext
+ * @param endpoint
+ */
+ void activate(CompositeContext compositeContext, RuntimeEndpoint endpoint);
+
+ /**
+ * Activate an endpoint reference
+ * @param compositeContext
+ * @param endpointReference
+ */
+ void activate(CompositeContext compositeContext, RuntimeEndpointReference endpointReference);
+
+ /**
+ * Deactivate an endpoint
+ * @param endpoint
+ */
+ void deactivate(RuntimeEndpoint endpoint);
+
+ /**
+ * Deactivate an endpoint reference
+ * @param endpointReference
+ */
+ void deactivate(RuntimeEndpointReference endpointReference);
+
+ /**
+ * Start an endpoint
+ * @param compositeContext
+ * @param endpoint
+ */
+ void start(CompositeContext compositeContext, RuntimeEndpoint endpoint);
+
+ /**
+ * Start an endpoint reference
+ * @param compositeContext
+ * @param endpointReference
+ */
+ void start(CompositeContext compositeContext, RuntimeEndpointReference endpointReference);
+
+ /**
+ * Stop an endpoint
+ * @param endpoint
+ */
+ void stop(RuntimeEndpoint endpoint);
+
+ /**
+ * Stop an endpoint reference
+ * @param endpointReference
+ */
+ void stop(RuntimeEndpointReference endpointReference);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultDomainRegistryFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultDomainRegistryFactoryExtensionPoint.java
new file mode 100644
index 0000000000..f74d80b882
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultDomainRegistryFactoryExtensionPoint.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.sca.runtime;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceHelper;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Default implementation of DomainRegistryFactoryExtensionPoint
+ */
+public class DefaultDomainRegistryFactoryExtensionPoint implements DomainRegistryFactoryExtensionPoint,
+ LifeCycleListener {
+ private ExtensionPointRegistry registry;
+ private boolean loaded;
+ private List<DomainRegistryFactory> factories = new ArrayList<DomainRegistryFactory>();
+ private Map<String, String> domainRegistryMapping = new HashMap<String, String>();
+
+ /**
+ * @param registry
+ */
+ public DefaultDomainRegistryFactoryExtensionPoint(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ super();
+ this.registry = registry;
+ // Populate the domainRegistryMapping
+ domainRegistryMapping.putAll(attributes);
+ domainRegistryMapping.remove("class");
+ domainRegistryMapping.remove("ranking");
+ }
+
+ public void addDomainRegistryFactory(DomainRegistryFactory factory) {
+ ServiceHelper.start(factory);
+ factories.add(factory);
+ }
+
+ public List<DomainRegistryFactory> getDomainRegistryFactories() {
+ load();
+ return factories;
+ }
+
+ private synchronized void load() {
+ if (loaded) {
+ return;
+ }
+ try {
+ Collection<ServiceDeclaration> declarations =
+ registry.getServiceDiscovery().getServiceDeclarations(DomainRegistryFactory.class, true);
+ for (ServiceDeclaration declaration : declarations) {
+ DomainRegistryFactory factory = ServiceHelper.newInstance(registry, declaration);
+ addDomainRegistryFactory(factory);
+ }
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ } finally {
+ loaded = true;
+ }
+ }
+
+ public void removeDomainRegistryFactory(DomainRegistryFactory factory) {
+ if (factories.remove(factory)) {
+ ServiceHelper.stop(factory);
+ }
+
+ }
+
+ public void start() {
+ // Empty
+ }
+
+ public void stop() {
+ ServiceHelper.stop(factories);
+ }
+
+ public Map<String, String> getDomainRegistryMapping() {
+ return domainRegistryMapping;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java
new file mode 100644
index 0000000000..283d1d1a8b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+
+/**
+ * The default implementation of a <code>WireProcessorExtensionPoint</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultWireProcessorExtensionPoint implements RuntimeWireProcessorExtensionPoint, LifeCycleListener {
+ private ExtensionPointRegistry registry;
+ private boolean loaded;
+
+ /**
+ * @param registry
+ */
+ public DefaultWireProcessorExtensionPoint(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ * The list of WireProcessors available to the runtime
+ */
+ private final List<RuntimeWireProcessor> processors = new ArrayList<RuntimeWireProcessor>();
+
+ /**
+ * Registers a wire-processor in the runtime
+ *
+ * @param processor The processor to register
+ */
+ public void addWireProcessor(RuntimeWireProcessor processor) {
+ processors.add(processor);
+ if (processor instanceof LifeCycleListener) {
+ ((LifeCycleListener)processor).start();
+ }
+ }
+
+ /**
+ * De-registers a wire-processor in the runtime
+ *
+ * @param processor The processor to de-register
+ */
+ public void removeWireProcessor(RuntimeWireProcessor processor) {
+ boolean found = processors.remove(processor);
+ if (found && (processor instanceof LifeCycleListener)) {
+ ((LifeCycleListener)processor).stop();
+ }
+ }
+
+ /**
+ * Returns a list of registered wire-processors.
+ *
+ * @return The list of wire processors
+ */
+ public List<RuntimeWireProcessor> getWireProcessors() {
+ loadWireProcessors();
+ return processors;
+ }
+
+ private synchronized void loadWireProcessors() {
+ if (loaded) {
+ return;
+ }
+ try {
+ Collection<ServiceDeclaration> sds =
+ registry.getServiceDiscovery().getServiceDeclarations(RuntimeWireProcessor.class, true);
+ for (ServiceDeclaration sd : sds) {
+ Class type = sd.loadClass();
+ Constructor constructor = null;
+ RuntimeWireProcessor processor = null;
+ try {
+ constructor = type.getConstructor(ExtensionPointRegistry.class);
+ processor = (RuntimeWireProcessor)constructor.newInstance(registry);
+
+ } catch (NoSuchMethodException e) {
+ constructor = type.getConstructor();
+ processor = (RuntimeWireProcessor)constructor.newInstance();
+ }
+ if (processor != null) {
+ addWireProcessor(processor);
+ }
+ }
+ loaded = true;
+ } catch (Throwable e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ for (RuntimeWireProcessor processor : processors) {
+ if ((processor instanceof LifeCycleListener)) {
+ ((LifeCycleListener)processor).stop();
+ }
+ }
+ processors.clear();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java
new file mode 100644
index 0000000000..c79fab1f47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.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.sca.runtime;
+
+import java.util.Collection;
+
+/**
+ * A DomainRegistryFactory is responsible for creating an instance of the DomainRegistry for a given
+ * registry URI and domain URI
+ */
+public interface DomainRegistryFactory {
+ /**
+ * Get the EndpointRegistry for the given registry URI and domain URI
+ * @param endpointRegistryURI A URI can be used to connect to the registry, such as vm://localhost
+ * or multicast://200.0.100.200:50000/...
+ * @param domainURI The domain URI
+ * @return
+ */
+ EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI);
+
+ /**
+ * Return all active endpoint registries
+ * @return
+ */
+ Collection<EndpointRegistry> getEndpointRegistries();
+
+ /**
+ * Add an EndpointListener
+ * @param listener
+ */
+ void addListener(EndpointListener listener);
+
+ /**
+ * Remove an EndpointListener
+ * @param listener
+ */
+ void removeListener(EndpointListener listener);
+
+ /**
+ * Return an array of schemes that this factory supports
+ * @return
+ */
+ String[] getSupportedSchemes();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactoryExtensionPoint.java
new file mode 100644
index 0000000000..f1582c3d70
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactoryExtensionPoint.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Extension point for DomainRegistryFactory
+ */
+public interface DomainRegistryFactoryExtensionPoint {
+ /**
+ * Return a mapping between domain URI and domain registry URI
+ * @return A mutable map
+ */
+ Map<String, String> getDomainRegistryMapping();
+
+ /**
+ * Add a DomainRegistryFactory
+ * @param factory
+ */
+ void addDomainRegistryFactory(DomainRegistryFactory factory);
+
+ /**
+ * Remove a DomainRegistryFactory
+ * @param factory
+ */
+ void removeDomainRegistryFactory(DomainRegistryFactory factory);
+
+ /**
+ * @return A list of DomainRegistryFactory
+ */
+ List<DomainRegistryFactory> getDomainRegistryFactories();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java
new file mode 100644
index 0000000000..6de0878383
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryURI.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * Utility to parse the config uri string.
+ *
+ * tuscany:[domainName]?listen=[port|ip:port]]&password=abc&multicast=[off|port|ip:port]&remotes=ip:port,ip:port,...
+
+ * listen - defines the local bind address and port, it defaults to all network interfaces on port 14820 and if that port in use it will try incrementing by one till a free port is found.
+ * password - is the password other nodes must use to connect to this domain. The default is 'tuscany'.
+ * multicast - defines if multicast discovery is used and if so what multicast ip group and port is used.
+ * The default is multicast is off if remotes= is specified (only for now due to a Hazelcast limitation that is planned to be fixed),
+ * otherwise if remotes= is not specified then multicast defaults to 224.5.12.10:51482
+ * remotes - a list of ipAddress:port for remote nodes
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public class DomainRegistryURI {
+
+ private String domainName = "default";
+ private String bindAddress = null; // null means all network adapters
+ private int listenPort = 14820;
+ private String password = "tuscany";
+ private boolean multicastDisabled = false;
+ private String multicastAddress = "224.5.12.10";
+ private int multicastPort = 51482;
+ private List<String> remotes = new ArrayList<String>();
+ private String uri;
+
+ public DomainRegistryURI(String uri) {
+ this.uri = uri;
+ parseURI(uri);
+ }
+
+ private void parseURI(String uri) {
+ if (uri.startsWith("tuscanyclient:")) {
+ uri = uri.replace("tuscanyclient:", "tuscany:");
+ }
+
+ if (!uri.startsWith("tuscany:")) {
+ throw new IllegalArgumentException("Config URI must start with 'tuscany:'");
+ }
+
+ // make it a URI so java.net.URI can be used to parse it
+ int i = uri.indexOf(":");
+ if (uri.charAt("tuscany:".length()) != '/') {
+ uri = uri.replaceFirst(":", ":/");
+ }
+ if (uri.charAt("tuscany:".length()+1) != '/') {
+ uri = uri.replaceFirst(":/", "://");
+ }
+ URI configURI = URI.create(uri);
+
+ this.domainName = configURI.getHost();
+
+ String query = configURI.getQuery();
+ if (query != null && query.length() > 0) {
+ String[] params = query.split("&");
+ Map<String, String> paramMap = new HashMap<String, String>();
+ for (String param : params) {
+ paramMap.put(param.split("=")[0], param.split("=")[1]);
+ }
+ for (String name : paramMap.keySet()) {
+ String value = paramMap.get(name);
+ if ("listen".equals(name)) {
+ if (value.indexOf(":") == -1) {
+ this.listenPort = Integer.parseInt(value);
+ } else {
+ String[] addr = value.split(":");
+ this.bindAddress = addr[0];
+ this.listenPort = Integer.parseInt(addr[1]);
+ }
+ } else if ("multicast".equals(name)) {
+ if ("off".equalsIgnoreCase(value)) {
+ this.multicastDisabled = true;
+ } else {
+ if (value.indexOf(":") == -1) {
+ this.multicastAddress = value;
+ } else {
+ String[] addr = value.split(":");
+ this.multicastAddress = addr[0];
+ this.multicastPort = Integer.parseInt(addr[1]);
+ }
+ }
+ } else if ("password".equals(name)) {
+ this.password = value;
+ } else if ("remotes".equals(name)) {
+ String[] ips = value.split(",");
+ for (String ip : ips) {
+ if (ip.indexOf(":") == -1) {
+ remotes.add(ip + ":14820");
+ } else {
+ remotes.add(ip);
+ }
+ }
+ if (paramMap.containsKey("multicast")) {
+// throw new IllegalArgumentException("Cannot have multicast and remotes (for now)");
+ } else {
+ this.multicastDisabled = true;
+ }
+ }
+ }
+ }
+ }
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public String getBindAddress() {
+ return bindAddress;
+ }
+
+ public int getListenPort() {
+ return listenPort;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public boolean isMulticastDisabled() {
+ return multicastDisabled;
+ }
+
+ public String getMulticastAddress() {
+ return multicastAddress;
+ }
+
+ public int getMulticastPort() {
+ return multicastPort;
+ }
+
+ public List<String> getRemotes() {
+ return remotes;
+ }
+
+ public String toString() {
+ return uri;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java
new file mode 100644
index 0000000000..13d193c464
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.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.sca.runtime;
+
+import java.util.EventListener;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+
+/**
+ * A listener for endpoint events
+ */
+public interface EndpointListener extends EventListener {
+ /**
+ * The method is invoked when a new endpoint is added to the registry
+ * @param endpoint
+ */
+ void endpointAdded(Endpoint endpoint);
+ /**
+ * The method is invoked when an endpoint is removed the registry
+ * @param endpoint
+ */
+ void endpointRemoved(Endpoint endpoint);
+ /**
+ * The method is invoked when an endpoint is updated in the registry
+ * @param oldEndpoint
+ * @param newEndpoint
+ */
+ void endpointUpdated(Endpoint oldEndpoint, Endpoint newEndpoint);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java
new file mode 100644
index 0000000000..b2ce3f5b7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.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.runtime;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+
+/**
+ * A utility responsible for resolving the endpoint reference against a matching endpoint published
+ * to the EndpointRegistry
+ */
+public interface EndpointReferenceBinder {
+
+ /**
+ * @param endpointRegistry
+ * @param endpointReference
+ * @return
+ */
+ void bindBuildTime(EndpointRegistry endpointRegistry, EndpointReference endpointReference);
+
+
+ /**
+ * @param endpointRegistry
+ * @param endpointReference
+ * @return
+ */
+ void bindRunTime(EndpointRegistry endpointRegistry, EndpointReference endpointReference);
+
+ /**
+ *
+ * @param endpointRegistry
+ * @param endpointReference
+ * @return
+ */
+ boolean isOutOfDate(EndpointRegistry endpointRegistry, EndpointReference endpointReference);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
new file mode 100644
index 0000000000..2c01eb115a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.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.runtime;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+
+/**
+ * The EndpointRegistry holds the active service endpoints for the SCA domain
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface EndpointRegistry {
+ /**
+ * Add an enpoint to the registry. If the endpoint URI is the same as an existing endpoint in the registry,
+ * the existing one will be updated
+ * @param endpoint
+ */
+ void addEndpoint(Endpoint endpoint);
+
+ /**
+ * Remove an enpoint from the registry
+ * @param endpoint
+ */
+ void removeEndpoint(Endpoint endpoint);
+
+ /**
+ * Look up an enpoint from the registry
+ * @param uri The endpoint URI
+ * @return
+ */
+ Endpoint getEndpoint(String uri);
+
+ /**
+ * Get all endpoints in the registry
+ * @return
+ */
+ Collection<Endpoint> getEndpoints();
+
+ List<Endpoint> findEndpoint(String uri);
+ List<Endpoint> findEndpoint(EndpointReference endpointReference);
+
+ void addEndpointReference(EndpointReference endpointReference);
+ void removeEndpointReference(EndpointReference endpointReference);
+ // List<EndpointReference> findEndpointReference(Endpoint endpoint);
+ List<EndpointReference> getEndpointReferences();
+
+ void addListener(EndpointListener listener);
+ void removeListener(EndpointListener listener);
+
+ String getDomainURI();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java
new file mode 100644
index 0000000000..981872fdfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.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 org.apache.tuscany.sca.runtime;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+
+/**
+ * A utility to seralize/deserialize Endpoint/EndpointReference objects
+ */
+public interface EndpointSerializer {
+ EndpointReference readEndpointReference(String xml);
+
+ String write(EndpointReference endpointReference);
+
+ Endpoint readEndpoint(String xml);
+
+ String write(Endpoint endpoint);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.java
new file mode 100644
index 0000000000..d1d0fb2b29
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ExtensibleDomainRegistryFactory.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.sca.runtime;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * A delegating DomainRegistryFactory
+ */
+public class ExtensibleDomainRegistryFactory implements DomainRegistryFactory {
+ private final DomainRegistryFactoryExtensionPoint factories;
+ private String[] allSchemes;
+ private String defaultScheme = "tuscany";
+
+ public ExtensibleDomainRegistryFactory(ExtensionPointRegistry registry) {
+ this.factories = registry.getExtensionPoint(DomainRegistryFactoryExtensionPoint.class);
+ RuntimeProperties ps = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class);
+ if (ps.getProperties().containsKey("defaultScheme")) {
+ defaultScheme = ps.getProperties().getProperty("defaultScheme");
+ }
+
+ }
+
+ public ExtensibleDomainRegistryFactory(DomainRegistryFactoryExtensionPoint factories) {
+ this.factories = factories;
+ }
+
+ public static ExtensibleDomainRegistryFactory getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilities.getUtility(ExtensibleDomainRegistryFactory.class);
+ }
+
+ public void addListener(EndpointListener listener) {
+ for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) {
+ factory.addListener(listener);
+ }
+ }
+
+ public Collection<EndpointRegistry> getEndpointRegistries() {
+ List<EndpointRegistry> registries = new ArrayList<EndpointRegistry>();
+ for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) {
+ registries.addAll(factory.getEndpointRegistries());
+ }
+ return registries;
+ }
+
+ public EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI) {
+ if (endpointRegistryURI == null) {
+ endpointRegistryURI = factories.getDomainRegistryMapping().get(domainURI);
+ if (endpointRegistryURI == null) {
+ endpointRegistryURI = domainURI;
+ }
+ }
+
+ String scheme = endpointRegistryURI == null ? null : URI.create(endpointRegistryURI).getScheme();
+ if (scheme == null) {
+
+ // See if there is a previously created registry for that domain
+ for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) {
+ for (EndpointRegistry endpointRegistry : factory.getEndpointRegistries()) {
+ if (endpointRegistry.getDomainURI().equals(domainURI)) {
+ return endpointRegistry;
+ }
+ }
+ }
+
+ scheme = defaultScheme;
+ endpointRegistryURI = scheme + ":" + endpointRegistryURI;
+ } else {
+ scheme = scheme.toLowerCase();
+ }
+ for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) {
+ String[] schemes = factory.getSupportedSchemes();
+ if (schemes != null && Arrays.asList(schemes).contains(scheme)) {
+ EndpointRegistry endpointRegistry = factory.getEndpointRegistry(endpointRegistryURI, domainURI);
+ if (endpointRegistry == null) {
+ continue;
+ } else {
+ return endpointRegistry;
+ }
+ }
+ }
+ throw new ServiceRuntimeException("No EndpointRegistry can support " + endpointRegistryURI);
+ }
+
+ public void removeListener(EndpointListener listener) {
+ for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) {
+ factory.removeListener(listener);
+ }
+ }
+
+ public synchronized String[] getSupportedSchemes() {
+ if (allSchemes == null) {
+ Set<String> supportedSchemes = new HashSet<String>();
+ for (DomainRegistryFactory factory : factories.getDomainRegistryFactories()) {
+ String[] schemes = factory.getSupportedSchemes();
+ if (schemes != null) {
+ supportedSchemes.addAll(Arrays.asList(schemes));
+ }
+ }
+ allSchemes = supportedSchemes.toArray(new String[supportedSchemes.size()]);
+ }
+ return allSchemes;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java
new file mode 100644
index 0000000000..2df1761aec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+
+/**
+ * The abstraction of an invocable model that contains invocation chains
+ * @tuscany.spi.extension.asclient
+ */
+public interface Invocable {
+ /**
+ * Bind the invocable to the composite context
+ * @param context
+ */
+ void bind(CompositeContext context);
+
+ /**
+ * Bind the invocable to the extension point registry and endpoint registry. This is typically
+ * called after the endpoint or endpoint reference is deserialized
+ * @param registry
+ * @param endpointRegistry
+ */
+ void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry);
+
+ /**
+ * Get the associated composite context
+ * @return
+ */
+ CompositeContext getCompositeContext();
+
+ /**
+ * Unbind the invocable from the composite context
+ */
+ void unbind();
+
+ /**
+ * Get the component
+ * @return
+ */
+ Component getComponent();
+
+ /**
+ * Get the service or reference (contract)
+ * @return
+ */
+ Contract getContract();
+
+ /**
+ * Get the binding
+ * @return
+ */
+ Binding getBinding();
+
+ /**
+ * Returns the invocation chains for service operations associated with the
+ * wire
+ *
+ * @return the invocation chains for service operations associated with the
+ * wire
+ */
+ List<InvocationChain> getInvocationChains();
+
+ /**
+ * Lookup the invocation chain by operation
+ * @param operation The operation
+ * @return The invocation chain for the given operation
+ */
+ InvocationChain getInvocationChain(Operation operation);
+
+ /**
+ * Get the invocation chain for the binding-specific handling
+ * @return The binding invocation chain
+ */
+ InvocationChain getBindingInvocationChain();
+
+ /**
+ * This invoke method assumes that the binding invocation chain is in force
+ * and that there will be an operation selector element there to
+ * determine which operation to call
+ * @param msg The request message
+ * @return The response message
+ */
+ Message invoke(Message msg);
+
+ /**
+ * Invoke an operation with given arguments
+ * @param operation The operation
+ * @param args The arguments
+ * @return The result
+ * @throws InvocationTargetException
+ */
+ Object invoke(Operation operation, Object[] args) throws InvocationTargetException;
+
+ /**
+ * Invoke an operation with a context message
+ * @param operation The operation
+ * @param msg The request message
+ * @return The response message
+ * @throws InvocationTargetException
+ */
+ Message invoke(Operation operation, Message msg);
+
+ /**
+ * Get a list of policy providers
+ * @return
+ */
+ List<PolicyProvider> getPolicyProviders();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java
new file mode 100644
index 0000000000..928c77fd04
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+
+/**
+ * Parameters for the EndPointReference
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ReferenceParameters extends Cloneable {
+ /**
+ * Get the callback ID
+ * @return the callbackID
+ */
+ Object getCallbackID();
+
+ /**
+ * Set the callback ID
+ * @param callbackID the callbackID to set
+ */
+ void setCallbackID(Object callbackID);
+
+ /**
+ * Get the ID for the non-ServiceReference callback object
+ * @return
+ */
+ Object getCallbackObjectID();
+
+ /**
+ * Set the ID for the non-ServiceReference callback object
+ * @param callbackObjectID
+ */
+ void setCallbackObjectID(Object callbackObjectID);
+
+ EndpointReference getCallbackReference();
+
+ void setCallbackReference(EndpointReference callback);
+
+ Object clone() throws CloneNotSupportedException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java
new file mode 100644
index 0000000000..efc4b278b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+
+/**
+ * The runtime component interface. Provides the bridge between the
+ * assembly model representation of a component and its runtime
+ * realization.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface RuntimeComponent extends Component {
+ /**
+ * Set the implementation-specific configuration for this component
+ * @param implementationProvider The object that manages the component implementation
+ */
+ void setImplementationProvider(ImplementationProvider implementationProvider);
+
+ /**
+ * Get the implementation-specific configuration for this component
+ * @return The implementation provider for this component
+ */
+ ImplementationProvider getImplementationProvider();
+
+ /**
+ * Get the associated component context
+ * @return
+ */
+ RuntimeComponentContext getComponentContext();
+
+ /**
+ * Set the associated component context
+ * @param context
+ */
+ void setComponentContext(RuntimeComponentContext context);
+
+ /**
+ * Tests if the RuntimeComponent is started
+ * @return true if the RuntimeComponent is started otherwise false
+ */
+ boolean isStarted();
+
+ /**
+ * Sets the RuntimeComponent started state
+ * @param started the state to set
+ */
+ void setStarted(boolean started);
+
+ /**
+ * Add a policy provider to the component
+ * @param policyProvider
+ */
+ void addPolicyProvider(PolicyProvider policyProvider);
+
+ /**
+ * Get a list of policy providers configured for this component
+ * @return
+ */
+ List<PolicyProvider> getPolicyProviders();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java
new file mode 100644
index 0000000000..861ca2d6f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.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.runtime;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeComponentContext extends ComponentContext {
+ /**
+ * Activate the reference (creating runtime wires)
+ * @param reference
+ */
+ void start(RuntimeComponentReference reference);
+
+ /**
+ * Get the CallableReference for a given component reference
+ * @param <B>
+ * @param businessInterface The business interface
+ * @param endpointReference The endpointReference to be used
+ * @return A service reference representing the wire
+ */
+ <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
+ RuntimeEndpointReference endpointReference);
+
+
+ /**
+ * Create a CallableReference for the given component service
+ * @param <B>
+ * @param businessInterface
+ * @param component
+ * @param service
+ * @return
+ */
+ <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, RuntimeEndpoint endpoint);
+
+ /**
+ * @param <B>
+ * @param businessInterface
+ * @param service
+ * @return
+ */
+ <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, ComponentService service);
+
+ ExtensionPointRegistry getExtensionPointRegistry();
+
+ CompositeContext getCompositeContext();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java
new file mode 100644
index 0000000000..8abecee0bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.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 org.apache.tuscany.sca.runtime;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+
+/**
+ * The runtime component reference. Provides the bridge between the
+ * assembly model representation of a component reference and its runtime
+ * realization
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface RuntimeComponentReference extends ComponentReference {
+ /**
+ * Set the owning component
+ * @param component
+ */
+ void setComponent(RuntimeComponent component);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java
new file mode 100644
index 0000000000..1eefdc978e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.runtime;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+
+/**
+ * The runtime component service. Provides the bridge between the
+ * assembly model representation of a component service and its runtime
+ * realization
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface RuntimeComponentService extends ComponentService {
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java
new file mode 100644
index 0000000000..78f2d9546c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.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.runtime;
+
+import java.io.Serializable;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+
+/**
+ * The runtime representation of a service endpoint
+ * @tuscany.spi.extension.asclient
+ */
+public interface RuntimeEndpoint extends Endpoint, Invocable, Serializable {
+ /**
+ * Attach the service binding provider
+ * @param provider
+ */
+ void setBindingProvider(ServiceBindingProvider provider);
+
+ /**
+ * Get the service binding provider
+ * @return
+ */
+ ServiceBindingProvider getBindingProvider();
+
+ /**
+ * Get the interface contract for the binding. This represents the data types that the binding
+ * protocol stack can process.
+ * @return The binding interface contract
+ */
+ InterfaceContract getBindingInterfaceContract();
+
+ /**
+ * Get the interface contract of the service of the target component type, i.e., the
+ * componentType.service.interfaceContract. This represents the data types that the implementation
+ * code can process.
+ * @return The target component type service interface contract
+ */
+ InterfaceContract getComponentTypeServiceInterfaceContract();
+
+
+ /**
+ * Check that endpoint has compatible interface at the component and binding ends.
+ * The user can specify the interfaces at both ends so there is a danger that they won't be compatible.
+ */
+ void validateServiceInterfaceCompatibility();
+
+ /**
+ * Get the composite context for the composite that contains this endpoint. This
+ * is useful for accessing various composite level objects from within the
+ * runtime code
+ */
+ CompositeContext getCompositeContext();
+
+ /**
+ * Retrieve the normalized WSDL contract relating to the input WSDL contract
+ *
+ * @param interfaceContract
+ * @return
+ */
+ public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java
new file mode 100644
index 0000000000..42e7328c0a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import java.io.Serializable;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+
+/**
+ * The runtime representation of an endpoint reference
+ * @tuscany.spi.extension.asclient
+ */
+public interface RuntimeEndpointReference extends EndpointReference, Invocable, Serializable {
+ /**
+ * Set the reference binding provider for the endpoint reference
+ * @param provider The binding provider
+ */
+ void setBindingProvider(ReferenceBindingProvider provider);
+
+ /**
+ * Get the reference binding provider for the endpoint reference
+ * @return The binding provider
+ */
+ ReferenceBindingProvider getBindingProvider();
+
+ /**
+ * Get the interface contract for the binding. This represents the data types that the binding
+ * protocol stack can process.
+ * @return The binding interface contract
+ */
+ InterfaceContract getBindingInterfaceContract();
+
+
+ /**
+ * Get the interface contract of the reference of the source component type, i.e., the
+ * componentType.reference.interfaceContract. This represents the data types that the
+ * implementation code uses to make the outbound call.
+ * @return The source component type reference interface contract
+ */
+ InterfaceContract getComponentTypeReferenceInterfaceContract();
+
+ /**
+ * Check that endpoint reference has compatible interface at the component and binding ends.
+ * The user can specify the interfaces at both ends so there is a danger that they won't be compatible.
+ * There is checking in the activator but of course endpoint references may not have a binding assigned
+ * until final resolution.
+ */
+ public void validateReferenceInterfaceCompatibility();
+
+ boolean isOutOfDate();
+ void rebuild();
+ boolean isStarted();
+
+ /**
+ * Retrieve the normalized WSDL contract relating to the input WSDL contract
+ *
+ * @param interfaceContract
+ * @return
+ */
+ public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.java
new file mode 100644
index 0000000000..c413276b37
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeProperties.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.sca.runtime;
+
+import java.util.Properties;
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public interface RuntimeProperties {
+ Properties getProperties();
+ void setProperties(Properties properties);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java
new file mode 100644
index 0000000000..997e170b22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.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.sca.runtime;
+
+/**
+ * Implementations are called after wires are decorated with policy and before they are connected.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface RuntimeWireProcessor {
+ /**
+ * Configure the runtime endpoint
+ * @param endpoint
+ */
+ void process(RuntimeEndpoint endpoint);
+
+ /**
+ * Configure the runtime endpoint reference
+ * @param endpointReference
+ */
+ void process(RuntimeEndpointReference endpointReference);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java
new file mode 100644
index 0000000000..4b2c71b397
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.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.sca.runtime;
+
+import java.util.List;
+
+/**
+ * Acts as a delegating <code>WireProcessorExtensionPoint</code>, delegating
+ * processing of wires after policies have been applied and source and targets
+ * have been connected.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeWireProcessorExtensionPoint {
+
+ /**
+ * Registers a wire-processor in the runtime
+ *
+ * @param processor The processor to register
+ */
+ void addWireProcessor(RuntimeWireProcessor processor);
+
+ /**
+ * De-registers a wire-processor in the runtime
+ *
+ * @param processor The processor to de-register
+ */
+ void removeWireProcessor(RuntimeWireProcessor processor);
+
+ /**
+ * Returns a list of registered wire-processors.
+ *
+ * @return The list of wire processors
+ */
+ List<RuntimeWireProcessor> getWireProcessors();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.java
new file mode 100644
index 0000000000..5d3ed1ce41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Version.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.sca.runtime;
+
+import java.util.ResourceBundle;
+
+public class Version {
+
+ public static final String VERSION;
+ public static final String REVISION;
+ public static final String BUILDTIME;
+ static {
+ ResourceBundle rb = ResourceBundle.getBundle("org/apache/tuscany/sca/runtime/revision");
+ VERSION = rb.getString("version");
+ REVISION = rb.getString("revision");
+ BUILDTIME = rb.getString("buildtime");
+ }
+
+ public static String getVersion() {
+ return VERSION;
+ }
+
+ public static String getRevsion() {
+ return REVISION;
+ }
+
+ public static String getBuildTime() {
+ return BUILDTIME;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java
new file mode 100644
index 0000000000..d32af450ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.work;
+
+/**
+ * A callback interface that can be optionally used for registering
+ * interest in status of asynchronously scheduled unit of work.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface NotificationListener<T extends Runnable> {
+
+ /**
+ * Callback method when the unit of work is accepted.
+ *
+ * @param work Work that was accepted.
+ */
+ void workAccepted(T work);
+
+ /**
+ * Callback method when the unit of work is successfully completed.
+ *
+ * @param work Work that was successfully completed.
+ */
+ void workCompleted(T work);
+
+ /**
+ * Callback when the unit of work is started.
+ *
+ * @param work Unit of work that was started.
+ */
+ void workStarted(T work);
+
+ /**
+ * Callback when the unit of work is rejected.
+ *
+ * @param work Unit of work that was rejected.
+ */
+ void workRejected(T work);
+
+ /**
+ * Callback when the unit of work fails to complete.
+ *
+ * @param work Unit of work that failed to complete.
+ * @param error Error that caused the unit of work to fail.
+ */
+ void workFailed(T work, Throwable error);
+
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java
new file mode 100644
index 0000000000..2c5fb556bc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.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.sca.work;
+
+/**
+ * Defines the contract for scheduling asynchronous units of work.
+ *
+ * <p>
+ * Units of work can be scheduled with an optional <code>NotificationListener</code>.
+ * If a notification listener is specified, the caller will be notified regarding the
+ * status of the work. The unit of work can either be completed, rejected or completed
+ * with an error. If the work completed with an error, the caller is notified with the
+ * error details.
+ * </p>
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface WorkScheduler {
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener
+ * is used to register interest in callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ * @param listener Notification listener for callbacks.
+ */
+ <T extends Runnable>void scheduleWork(T work, NotificationListener<T> listener);
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener
+ * is used to register interest in callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ */
+ <T extends Runnable>void scheduleWork(T work);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java
new file mode 100644
index 0000000000..18ec2dfeaa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.work;
+
+
+/**
+ * Exception thrown by the work scheduler in case of unexpected exceptions.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
+ */
+public class WorkSchedulerException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkSchedulerException() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkSchedulerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkSchedulerException(String message) {
+ super(message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkSchedulerException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint
new file mode 100644
index 0000000000..454d1796cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.context.DefaultContextFactoryExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint
new file mode 100644
index 0000000000..19cf2a444f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.provider.DefaultProviderFactoryExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint
new file mode 100644
index 0000000000..be585a1e03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.runtime.DefaultDomainRegistryFactoryExtensionPoint \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint
new file mode 100644
index 0000000000..1ab308cc71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.runtime.DefaultWireProcessorExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/org/apache/tuscany/sca/runtime/revision.properties b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/org/apache/tuscany/sca/runtime/revision.properties
new file mode 100644
index 0000000000..9018bd1a1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/main/resources/org/apache/tuscany/sca/runtime/revision.properties
@@ -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.
+#
+#
+
+#-- Don't edit these. They're updated from the build, see the
+# buildnumber-maven-plugin in this modules pom.xml
+version=@version@
+revision=@svnRevision@
+buildtime=@buildtime@
+#----------------------
+
+
+
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java b/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java
new file mode 100644
index 0000000000..6486a5ed4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.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.sca.context;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * This test case will test the class
+ * org.apache.tuscany.sca.context.DefaultContextFactoryExtensionPoint
+ *
+ * $Date$ $Rev$
+ */
+public class DefaultContextFactoryExtensionPointTestCase {
+
+ /**
+ * Tests adding/getting/removing a factory with no interfaces
+ */
+ @Test
+ public void testFactoryWithNoInterfaces() {
+ Object factory = new FactoryWithNoInterfaces();
+ Class<?>[] ifaces = {};
+ addGetRemoveFactory(factory, ifaces);
+ }
+
+ /**
+ * Tests adding/getting/removing a factory with one interface
+ */
+ @Test
+ public void testFactoryWithOneInterface() {
+ Object factory = new FactoryWithOneInterface();
+ Class<?>[] ifaces = { FactoryOneInterface.class };
+ addGetRemoveFactory(factory, ifaces);
+ }
+
+ /**
+ * Tests adding/getting/removing a factory with two interfaces
+ */
+ @Test
+ public void testFactoryWithTwoInterfaces() {
+ Object factory = new FactoryWithTwoInterfaces();
+ Class<?>[] ifaces = { FactoryTwoInterfacesA.class, FactoryTwoInterfacesB.class };
+ addGetRemoveFactory(factory, ifaces);
+ }
+
+ /**
+ * Tests having multiple factories registered
+ */
+ @Test
+ public void testMultipleFactories() {
+ // Create new factories
+ FactoryWithOneInterface factory1 = new FactoryWithOneInterface();
+ FactoryWithTwoInterfaces factory2 = new FactoryWithTwoInterfaces();
+
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+
+ // Register the factories
+ DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry);
+ ctxFactory.addFactory(factory1);
+ ctxFactory.addFactory(factory2);
+
+ // Re-get each of the factories
+ FactoryOneInterface regotFactory1 = ctxFactory.getFactory(FactoryOneInterface.class);
+ Assert.assertNotNull(regotFactory1);
+ Assert.assertSame(factory1, regotFactory1);
+ FactoryTwoInterfacesA regotFactory2A = ctxFactory.getFactory(FactoryTwoInterfacesA.class);
+ Assert.assertNotNull(regotFactory2A);
+ Assert.assertSame(factory2, regotFactory2A);
+ FactoryTwoInterfacesB regotFactory2B = ctxFactory.getFactory(FactoryTwoInterfacesB.class);
+ Assert.assertNotNull(regotFactory1);
+ Assert.assertSame(factory2, regotFactory2B);
+ }
+
+ /**
+ * Tests passing in null to addFactory()
+ */
+ @Test
+ public void testAddingNullFactory() {
+
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry);
+ try {
+ ctxFactory.addFactory(null);
+ Assert.fail("Should have thrown IllegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ // As expected
+ }
+ }
+
+ /**
+ * Test passing in null to removeFactory()
+ */
+ @Test
+ public void testRemovingNullFactory() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry);
+ try {
+ ctxFactory.removeFactory(null);
+ Assert.fail("Should have thrown IllegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ // As expected
+ }
+ }
+
+ /**
+ * Test passing in null to getFactory()
+ */
+ @Test
+ public void testGetNullFactory() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry);
+ try {
+ ctxFactory.getFactory(null);
+ Assert.fail("Should have thrown IllegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ // As expected
+ }
+ }
+
+ /**
+ * Utility method for testing adding and removing a factory
+ *
+ * @param factory The factory class to test
+ * @param factoryInterfaces The list of interfaces implemented by the factory
+ */
+ private void addGetRemoveFactory(Object factory, Class<?>[] factoryInterfaces) {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry);
+
+ // Make sure factory not already present
+ for (Class<?> iface : factoryInterfaces) {
+ Assert.assertNull(ctxFactory.getFactory(iface));
+ }
+
+ // Add the factory
+ ctxFactory.addFactory(factory);
+
+ // Make sure we can get the factory recently registered factory
+ for (Class<?> iface : factoryInterfaces) {
+ Object regot = ctxFactory.getFactory(iface);
+ Assert.assertNotNull(regot);
+ Assert.assertSame(factory, regot);
+ }
+
+ // Remove the factory
+ ctxFactory.removeFactory(factory);
+
+ // Make sure factory is no longer registered
+ for (Class<?> iface : factoryInterfaces) {
+ Assert.assertNull(ctxFactory.getFactory(iface));
+ }
+ }
+
+ /**
+ * Simple factory with no interfaces
+ */
+ private class FactoryWithNoInterfaces {
+ }
+
+ /**
+ * Simple interface for the factory with one interface
+ */
+ private interface FactoryOneInterface {
+ }
+
+ /**
+ * Simple factory with one interface
+ */
+ private class FactoryWithOneInterface implements FactoryOneInterface {
+ }
+
+ /**
+ * Simple interface for the factory with two interfaces
+ */
+ private interface FactoryTwoInterfacesA {
+ }
+
+ /**
+ * Simple interface for the factory with two interfaces
+ */
+ private interface FactoryTwoInterfacesB {
+ }
+
+ /**
+ * Simple factory with two interfaces
+ */
+ private class FactoryWithTwoInterfaces implements FactoryTwoInterfacesA, FactoryTwoInterfacesB {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java b/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java
new file mode 100644
index 0000000000..b7e96a8b28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/ConfigURITestCase.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.runtime;
+
+import java.net.UnknownHostException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.runtime.DomainRegistryURI;
+import org.junit.Test;
+
+public class ConfigURITestCase {
+
+ @Test
+ public void testInvalidPrefix() throws UnknownHostException {
+ try {
+ new DomainRegistryURI("foo");
+ Assert.fail();
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testDomainName() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ }
+
+ @Test
+ public void testListenAddr() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?listen=4321");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ Assert.assertEquals(4321, configURI.getListenPort());
+ Assert.assertNull(configURI.getBindAddress());
+ }
+ @Test
+ public void testListenAddr2() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?listen=1.1.1.1:4321");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ Assert.assertEquals(4321, configURI.getListenPort());
+ Assert.assertEquals("1.1.1.1", configURI.getBindAddress());
+ }
+
+ @Test
+ public void testMulticase1() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=off");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertTrue(configURI.isMulticastDisabled());
+ }
+
+ @Test
+ public void testMulticase2() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=1.2.3.4:67");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ Assert.assertEquals("1.2.3.4", configURI.getMulticastAddress());
+ Assert.assertEquals(67, configURI.getMulticastPort());
+ }
+
+ @Test
+ public void testMulticase3() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?multicast=1.2.3.4");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertFalse(configURI.isMulticastDisabled());
+ Assert.assertEquals("1.2.3.4", configURI.getMulticastAddress());
+ Assert.assertEquals(51482, configURI.getMulticastPort());
+ }
+
+ @Test
+ public void testPassword() {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?password=bla");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertEquals("bla", configURI.getPassword());
+ }
+
+ @Test
+ public void testRemotes() throws UnknownHostException {
+ DomainRegistryURI configURI = new DomainRegistryURI("tuscany:myDomain?remotes=1.1.1.1:23,2.2.2.2");
+ Assert.assertEquals("myDomain", configURI.getDomainName());
+ Assert.assertTrue(configURI.isMulticastDisabled());
+ Assert.assertEquals(2, configURI.getRemotes().size());
+ Assert.assertEquals("1.1.1.1:23", configURI.getRemotes().get(0));
+ Assert.assertEquals("2.2.2.2:14820", configURI.getRemotes().get(1));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java b/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.java
new file mode 100644
index 0000000000..89ca99484c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core-spi/src/test/java/org/apache/tuscany/sca/runtime/VersionTestCase.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 org.apache.tuscany.sca.runtime;
+
+import org.junit.Test;
+import org.junit.Ignore;
+
+/**
+ */
+@Ignore
+public class VersionTestCase {
+
+ @Test
+ public void testRevision() {
+ // Doesn't test much, just that it has been initilized to a number
+ System.out.println(Version.getVersion() + " " + Version.getRevsion() + " " + Version.getBuildTime());
+ Integer.parseInt(Version.getRevsion());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/LICENSE b/sandbox/sebastien/java/embed/modules/core/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/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/sebastien/java/embed/modules/core/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/core/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..62fc183f20
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/META-INF/MANIFEST.MF
@@ -0,0 +1,66 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.core.assembly;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.core",
+ org.apache.tuscany.sca.core.context;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.context,
+ org.oasisopen.sca,
+ org.apache.tuscany.sca.core",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0";
+ uses:="org.apache.tuscany.sca.invocation,
+ org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.oasisopen.sca,
+ org.apache.tuscany.sca.work,
+ org.apache.tuscany.sca.core.factory,
+ org.apache.tuscany.sca.core.context.impl,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.interfacedef",
+ org.apache.tuscany.sca.core.scope;version="2.0.0";
+ uses:="org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.provider,
+ org.apache.tuscany.sca.core.scope.impl,
+ org.apache.tuscany.sca.core.factory"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Core Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Core Runtime
+Import-Package: javax.security.auth,
+ javax.xml.namespace,
+ javax.xml.stream,
+ net.sf.cglib.proxy;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.common.java.collection;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core.context;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.core.scope;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.core
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/core/NOTICE b/sandbox/sebastien/java/embed/modules/core/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/core/pom.xml b/sandbox/sebastien/java/embed/modules/core/pom.xml
new file mode 100644
index 0000000000..422ddfa783
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-core</artifactId>
+ <name>Apache Tuscany SCA Core Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java
new file mode 100644
index 0000000000..790cc6ec98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.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.sca.core.assembly;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentImpl;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentReferenceImpl;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentServiceImpl;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
+
+
+/**
+ * The runtime version of assembly factory
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class RuntimeAssemblyFactory extends DefaultAssemblyFactory implements AssemblyFactory {
+
+ public RuntimeAssemblyFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public Component createComponent() {
+ return new RuntimeComponentImpl();
+ }
+
+ @Override
+ public ComponentReference createComponentReference() {
+ return new RuntimeComponentReferenceImpl();
+ }
+
+ @Override
+ public ComponentService createComponentService() {
+ return new RuntimeComponentServiceImpl();
+ }
+
+ @Override
+ public Endpoint createEndpoint() {
+ // Create an instance of EndpointImpl that can be serialized/deserialized using the Tuscany
+ // runtime extension points and extensions
+ return new RuntimeEndpointImpl(registry);
+ }
+
+ @Override
+ public EndpointReference createEndpointReference() {
+ return new RuntimeEndpointReferenceImpl(registry);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
new file mode 100644
index 0000000000..db345826d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
@@ -0,0 +1,607 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.ScopeRegistry;
+import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.RuntimeProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeActivatorImpl implements CompositeActivator {
+ final Logger logger = Logger.getLogger(CompositeActivatorImpl.class.getName());
+
+ private final ScopeRegistry scopeRegistry;
+ private final ProviderFactoryExtensionPoint providerFactories;
+
+ public CompositeActivatorImpl(ExtensionPointRegistry extensionPoints) {
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.scopeRegistry = utilities.getUtility(ScopeRegistry.class);
+ this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ }
+
+ //=========================================================================
+ // Activation
+ //=========================================================================
+
+ // Composite activation/deactivation
+
+ public void activate(CompositeContext compositeContext, Composite composite) throws ActivationException {
+ try {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Activating composite: " + composite.getName());
+ }
+ for (Component component : composite.getComponents()) {
+ activateComponent(compositeContext, component);
+ }
+ } catch (Exception e) {
+ throw new ActivationException(e);
+ }
+ }
+
+ public void deactivate(Composite composite) throws ActivationException {
+ try {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Deactivating composite: " + composite.getName());
+ }
+ for (Component component : composite.getComponents()) {
+ deactivateComponent(component);
+ }
+ } catch (Exception e) {
+ throw new ActivationException(e);
+ }
+ }
+
+ // Component activation/deactivation
+
+ public void activateComponent(CompositeContext compositeContext, Component component)
+ throws ActivationException {
+ try {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Activating component: " + component.getURI());
+ }
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ activate(compositeContext, (Composite) implementation);
+ } else if (implementation != null) {
+ addImplementationProvider((RuntimeComponent) component,
+ implementation);
+ addScopeContainer(component);
+ }
+
+ for (ComponentService service : component.getServices()) {
+ activate(compositeContext,
+ (RuntimeComponent) component, (RuntimeComponentService) service);
+ }
+
+ for (ComponentReference reference : component.getReferences()) {
+ activate(compositeContext,
+ (RuntimeComponent) component, (RuntimeComponentReference) reference);
+ }
+ } catch (Exception e) {
+ throw new ActivationException(e);
+ }
+ }
+
+ public void deactivateComponent(Component component)
+ throws ActivationException {
+ try {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Deactivating component: " + component.getURI());
+ }
+ for (ComponentService service : component.getServices()) {
+ deactivate((RuntimeComponent) component,
+ (RuntimeComponentService) service);
+ }
+
+ for (ComponentReference reference : component.getReferences()) {
+ deactivate((RuntimeComponent) component,
+ (RuntimeComponentReference) reference);
+ }
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ deactivate((Composite) implementation);
+ } else if (implementation != null) {
+ removeImplementationProvider((RuntimeComponent) component);
+ removeScopeContainer(component);
+ }
+ } catch (Exception e) {
+ throw new ActivationException(e);
+ }
+ }
+
+ // add/remove artifacts required to get the implementation going
+
+ private void addImplementationProvider(RuntimeComponent component, Implementation implementation) {
+ ImplementationProviderFactory providerFactory =
+ (ImplementationProviderFactory)providerFactories.getProviderFactory(implementation.getClass());
+ if (providerFactory != null) {
+ @SuppressWarnings("unchecked")
+ ImplementationProvider implementationProvider =
+ providerFactory.createImplementationProvider(component, implementation);
+ if (implementationProvider != null) {
+ component.setImplementationProvider(implementationProvider);
+ }
+ } else {
+ throw new IllegalStateException("Provider factory not found for class: " + implementation.getClass()
+ .getName());
+ }
+ for (PolicyProviderFactory f : providerFactories.getPolicyProviderFactories()) {
+ PolicyProvider policyProvider = f.createImplementationPolicyProvider(component);
+ if (policyProvider != null) {
+ component.addPolicyProvider(policyProvider);
+ }
+ }
+
+ }
+
+ private void removeImplementationProvider(RuntimeComponent component) {
+ component.setImplementationProvider(null);
+ component.getPolicyProviders().clear();
+ }
+
+ private void addScopeContainer(Component component) {
+ if (!(component instanceof ScopedRuntimeComponent)) {
+ return;
+ }
+ ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
+ ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(runtimeComponent);
+ runtimeComponent.setScopeContainer(scopeContainer);
+ }
+
+ private void removeScopeContainer(Component component) {
+ if (!(component instanceof ScopedRuntimeComponent)) {
+ return;
+ }
+ ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
+ ScopeContainer scopeContainer = runtimeComponent.getScopeContainer();
+ runtimeComponent.setScopeContainer(null);
+ }
+
+
+ // Service activation/deactivation
+
+ public void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentService service) {
+ if (service.getService() == null) {
+ if (logger.isLoggable(Level.WARNING)) {
+ logger.warning("Skipping component service not defined in the component type: " + component.getURI()
+ + "#"
+ + service.getName());
+ }
+ return;
+ }
+
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Activating component service: " + component.getURI() + "#" + service.getName());
+ }
+
+ // Add a wire for each service Endpoint
+ for ( Endpoint endpoint : service.getEndpoints()){
+ RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
+ activate(compositeContext, ep);
+
+ // create the interface contract for the binding and service ends of the wire
+ // that are created as forward only contracts
+ // FIXME: [rfeng] We might need a better way to get the impl interface contract
+ Service targetService = service.getService();
+ if (targetService == null) {
+ targetService = service;
+ }
+ // endpoint.setInterfaceContract(targetService.getInterfaceContract().makeUnidirectional(false));
+ }
+ }
+
+ public void activate(CompositeContext compositeContext, RuntimeEndpoint ep) {
+ ep.bind(compositeContext);
+
+ // Check that the service binding interface is compatible with the
+ // service interface
+ ep.validateServiceInterfaceCompatibility();
+ }
+
+ public void deactivate(RuntimeComponent component, RuntimeComponentService service) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Deactivating component service: " + component.getURI() + "#" + service.getName());
+ }
+ for(Endpoint ep: service.getEndpoints()) {
+ if(ep instanceof RuntimeEndpoint) {
+ deactivate((RuntimeEndpoint) ep);
+ }
+ }
+ }
+
+ public void deactivate(RuntimeEndpoint ep) {
+ ep.unbind();
+ }
+
+ // Reference activation/deactivation
+
+ public void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference reference) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Activating component reference: " + component.getURI() + "#" + reference.getName());
+ }
+
+ // set the parent component onto the reference. It's used at start time when the
+ // reference is asked to return it's runtime wires. If there are none the reference
+ // asks the component context to start the reference which creates the wires
+ reference.setComponent(component);
+ for(EndpointReference epr: reference.getEndpointReferences()) {
+ activate(compositeContext, (RuntimeEndpointReference) epr);
+ }
+
+ }
+
+ public void deactivate(RuntimeComponent component, RuntimeComponentReference reference) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Deactivating component reference: " + component.getURI() + "#" + reference.getName());
+ }
+ for(EndpointReference endpointReference: reference.getEndpointReferences()) {
+ deactivate((RuntimeEndpointReference)endpointReference);
+ }
+ }
+
+ public void activate(CompositeContext compositeContext, RuntimeEndpointReference epr) {
+ // create the wire
+ // null endpoint passed in here as the endpoint reference may
+ // not be resolved yet
+ epr.bind(compositeContext);
+
+ ComponentReference reference = epr.getReference();
+ InterfaceContract sourceContract = epr.getComponentTypeReferenceInterfaceContract();
+
+ // TODO - EPR - interface contract seems to be null in the implementation.web
+ // case. Not introspecting the CT properly?
+ if (sourceContract == null){
+ // TODO - Can't do this with move of matching to wire
+ // take the contract from the service to which the reference is connected
+ sourceContract = ((RuntimeEndpoint) epr.getTargetEndpoint()).getComponentTypeServiceInterfaceContract();
+ reference.setInterfaceContract(sourceContract);
+ }
+
+ // endpointReference.setInterfaceContract(sourceContract.makeUnidirectional(false));
+
+ // if the reference already has a binding we can check the reference binding interface
+ // and reference interfaces for compatibility. If we can't check now compatibility
+ // will be checked when the endpoint reference is resolved.
+ if (epr.getStatus() == EndpointReference.Status.RESOLVED_BINDING){
+ epr.validateReferenceInterfaceCompatibility();
+ }
+ }
+
+ public void deactivate(RuntimeEndpointReference endpointReference) {
+ endpointReference.unbind();
+ }
+
+ //=========================================================================
+ // Start
+ //=========================================================================
+
+ // Composite start/stop
+
+ public void start(CompositeContext compositeContext, Composite composite) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Starting composite: " + composite.getName());
+ }
+ for (Component component : composite.getComponents()) {
+ start(compositeContext, component);
+ }
+
+ for (Component component : composite.getComponents()) {
+ if (component instanceof ScopedRuntimeComponent) {
+ start(compositeContext, (ScopedRuntimeComponent)component);
+ }
+ }
+ }
+
+ public void stop(CompositeContext compositeContext, Composite composite) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Stopping composite: " + composite.getName());
+ }
+ for (final Component component : composite.getComponents()) {
+ stop(compositeContext, component);
+ }
+ }
+
+ // Component start/stop
+
+ public void start(CompositeContext compositeContext, Component component) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Starting component: " + component.getURI());
+ }
+ RuntimeComponent runtimeComponent = ((RuntimeComponent)component);
+ if(runtimeComponent.isStarted()) {
+ return;
+ }
+
+ compositeContext.bindComponent(runtimeComponent);
+ Implementation implementation = component.getImplementation();
+
+ List<RuntimeProvider> providers = new ArrayList<RuntimeProvider>();
+ try {
+
+ if (implementation instanceof Composite) {
+ try {
+ start(compositeContext, (Composite)implementation);
+ } catch (Throwable e) {
+ try {
+ stop(compositeContext, (Composite) implementation);
+ } catch (Throwable e1) {
+ logger.log(Level.SEVERE, e1.getMessage(), e1);
+ }
+ rethrow(e);
+ }
+ } else {
+ for (PolicyProvider policyProvider : runtimeComponent.getPolicyProviders()) {
+ policyProvider.start();
+ providers.add(policyProvider);
+ }
+ ImplementationProvider implementationProvider = runtimeComponent.getImplementationProvider();
+ if (implementationProvider != null) {
+ implementationProvider.start();
+ providers.add(implementationProvider);
+ }
+ }
+
+ // Reference bindings aren't started until the wire is first used although this may
+ // happen when the scope container is started in the case of @EagerInit
+
+ for (ComponentService service : component.getServices()) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Starting component service: " + component.getURI() + "#" + service.getName());
+ }
+ for (Endpoint endpoint : service.getEndpoints()) {
+ RuntimeEndpoint ep = (RuntimeEndpoint)endpoint;
+ startEndpoint(compositeContext, ep, providers);
+ }
+ }
+ } catch (Throwable e) {
+ for (int i = providers.size() - 1; i >= 0; i--) {
+ try {
+ providers.get(i).stop();
+ } catch (Throwable e1) {
+ logger.log(Level.SEVERE, e1.getMessage(), e1);
+ }
+ }
+ rethrow(e);
+ } finally {
+ providers.clear();
+ }
+
+ runtimeComponent.setStarted(true);
+ }
+
+ private void rethrow(Throwable e) throws Error {
+ if(e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ } else if(e instanceof Error) {
+ throw (Error) e;
+ }
+ }
+
+ public void start(CompositeContext compositeContext, RuntimeEndpoint ep) {
+ startEndpoint(compositeContext, ep, null);
+ }
+
+ private void startEndpoint(CompositeContext compositeContext, RuntimeEndpoint ep, final List<RuntimeProvider> providers) {
+ // FIXME: Should the policy providers be started before the endpoint is started?
+ for (PolicyProvider policyProvider : ep.getPolicyProviders()) {
+ policyProvider.start();
+ if (providers != null) {
+ providers.add(policyProvider);
+ }
+ }
+
+ final ServiceBindingProvider bindingProvider = ep.getBindingProvider();
+ if (bindingProvider != null) {
+ // bindingProvider.start();
+ // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ bindingProvider.start();
+ if (providers != null) {
+ providers.add(bindingProvider);
+ }
+ return null;
+ }
+ });
+ compositeContext.getEndpointRegistry().addEndpoint(ep);
+ }
+ }
+
+ public void stop(CompositeContext compositeContext, Component component) {
+ if (!((RuntimeComponent)component).isStarted()) {
+ return;
+ }
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Stopping component: " + component.getURI());
+ }
+ for (ComponentService service : component.getServices()) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Stopping component service: " + component.getURI() + "#" + service.getName());
+ }
+ for (Endpoint endpoint : service.getEndpoints()) {
+ RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
+ stop(ep);
+ }
+ }
+ for (ComponentReference reference : component.getReferences()) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Stopping component reference: " + component.getURI() + "#" + reference.getName());
+ }
+
+ for (EndpointReference endpointReference : reference.getEndpointReferences()) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
+ stop(epr);
+ }
+ }
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ stop(compositeContext, (Composite)implementation);
+ } else {
+ final ImplementationProvider implementationProvider = ((RuntimeComponent)component).getImplementationProvider();
+ if (implementationProvider != null) {
+ // Allow bindings to read properties. Requires PropertyPermission read in security policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ implementationProvider.stop();
+ return null;
+ }
+ });
+ }
+ for (PolicyProvider policyProvider : ((RuntimeComponent)component).getPolicyProviders()) {
+ policyProvider.stop();
+ }
+ }
+
+ if (component instanceof ScopedRuntimeComponent) {
+ ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
+ if (runtimeComponent.getScopeContainer() != null &&
+ runtimeComponent.getScopeContainer().getLifecycleState() != ScopeContainer.STOPPED) {
+ runtimeComponent.getScopeContainer().stop();
+ }
+ }
+
+ ((RuntimeComponent)component).setStarted(false);
+ }
+
+ public void stop(RuntimeEndpoint ep) {
+ ep.getCompositeContext().getEndpointRegistry().removeEndpoint(ep);
+ final ServiceBindingProvider bindingProvider = ep.getBindingProvider();
+ if (bindingProvider != null) {
+ // Allow bindings to read properties. Requires PropertyPermission read in security policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ bindingProvider.stop();
+ return null;
+ }
+ });
+ }
+ for (PolicyProvider policyProvider : ep.getPolicyProviders()) {
+ policyProvider.stop();
+ }
+ }
+
+ // Scope container start/stop
+ // separate off from component start that all endpoints are
+ // registered before any @EagerInit takes place
+ public void start(CompositeContext compositeContext, ScopedRuntimeComponent scopedRuntimeComponent) {
+ if (scopedRuntimeComponent.getScopeContainer() != null) {
+ scopedRuntimeComponent.getScopeContainer().start();
+ }
+ }
+
+ // Service start/stop
+
+ // done as part of the component start above
+
+ // Reference start/stop
+ // Used by component context start
+
+ public void start(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference componentReference) {
+ synchronized (componentReference) {
+
+ if (!(componentReference instanceof RuntimeComponentReference)) {
+ return;
+ }
+
+ // create a wire for each endpoint reference. An endpoint reference says either that
+ // - a target has been specified and hence the reference has been wired in some way.
+ // - an unwired binding ha been specified
+ // and endpoint reference representing a wired reference may not at this point
+ // be resolved (the service to which it points may not be present in the
+ // current composite). Endpoint reference resolution takes place when the wire
+ // is first used (when the chains are created)
+ for (EndpointReference endpointReference : componentReference.getEndpointReferences()){
+ // addReferenceWire(compositeContext, endpointReference);
+ start(compositeContext, (RuntimeEndpointReference) endpointReference);
+ }
+
+ }
+ }
+
+ public void start(CompositeContext compositeContext, RuntimeEndpointReference endpointReference) {
+ compositeContext.getEndpointRegistry().addEndpointReference(endpointReference);
+ }
+
+ public void stop(Component component, ComponentReference reference) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Stopping component reference: " + component.getURI() + "#" + reference.getName());
+ }
+ RuntimeComponentReference runtimeRef = ((RuntimeComponentReference)reference);
+ for ( EndpointReference endpointReference : runtimeRef.getEndpointReferences()){
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
+ stop(epr);
+ }
+ }
+
+ public void stop(RuntimeEndpointReference epr) {
+ if (epr.isStarted()) {
+ CompositeContext compositeContext = epr.getCompositeContext();
+ if (compositeContext == null) {
+ throw new IllegalStateException("The endpoint reference is not bound");
+ }
+ compositeContext.getEndpointRegistry().removeEndpointReference(epr);
+ ReferenceBindingProvider bindingProvider = epr.getBindingProvider();
+ if (bindingProvider != null) {
+ bindingProvider.stop();
+ }
+ for (PolicyProvider policyProvider : epr.getPolicyProviders()) {
+ policyProvider.stop();
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
new file mode 100644
index 0000000000..aa1a4001a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.runtime.BaseEndpointRegistry;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * A EndpointRegistry implementation that sees registrations from the same JVM
+ */
+public class EndpointRegistryImpl extends BaseEndpointRegistry implements EndpointRegistry, LifeCycleListener {
+ private final Logger logger = Logger.getLogger(EndpointRegistryImpl.class.getName());
+
+ private List<Endpoint> endpoints = new ArrayList<Endpoint>();
+
+ public EndpointRegistryImpl(ExtensionPointRegistry extensionPoints, String endpointRegistryURI, String domainURI) {
+ super(extensionPoints, null, endpointRegistryURI, domainURI);
+ }
+
+ public synchronized void addEndpoint(Endpoint endpoint) {
+ endpoints.add(endpoint);
+ for (EndpointListener listener : listeners) {
+ listener.endpointAdded(endpoint);
+ }
+ logger.info("Add endpoint - " + endpoint.toString());
+ }
+
+ public List<Endpoint> findEndpoint(String uri) {
+ List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
+ for (Endpoint endpoint : endpoints) {
+ if (endpoint.matches(uri)) {
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
+ }
+ // else the service name doesn't match
+ }
+ return foundEndpoints;
+ }
+
+ public synchronized void removeEndpoint(Endpoint endpoint) {
+ endpoints.remove(endpoint);
+ endpointRemoved(endpoint);
+ logger.info("Remove endpoint - " + endpoint.toString());
+ }
+
+ public synchronized List<Endpoint> getEndpoints() {
+ return endpoints;
+ }
+
+ public synchronized Endpoint getEndpoint(String uri) {
+ for (Endpoint ep : endpoints) {
+ String epURI =
+ ep.getComponent().getURI() + "#" + ep.getService().getName() + "/" + ep.getBinding().getName();
+ if (epURI.equals(uri)) {
+ return ep;
+ }
+ if (ep.getBinding().getName() == null || ep.getBinding().getName().equals(ep.getService().getName())) {
+ epURI = ep.getComponent().getURI() + "#" + ep.getService().getName();
+ if (epURI.equals(uri)) {
+ return ep;
+ }
+ }
+ }
+ return null;
+
+ }
+
+ public synchronized void updateEndpoint(String uri, Endpoint endpoint) {
+ Endpoint oldEndpoint = getEndpoint(uri);
+ if (oldEndpoint == null) {
+ throw new IllegalArgumentException("Endpoint is not found: " + uri);
+ }
+ endpoints.remove(oldEndpoint);
+ endpoints.add(endpoint);
+ for (EndpointListener listener : listeners) {
+ listener.endpointUpdated(oldEndpoint, endpoint);
+ }
+ }
+
+ public synchronized void start() {
+ }
+
+ public synchronized void stop() {
+ for (Iterator<Endpoint> i = endpoints.iterator(); i.hasNext();) {
+ Endpoint ep = i.next();
+ i.remove();
+ endpointRemoved(ep);
+ }
+ endpointreferences.clear();
+ listeners.clear();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
new file mode 100644
index 0000000000..4e5275058e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+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.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.EndpointSerializer;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class EndpointSerializerImpl implements EndpointSerializer {
+ private ExtensionPointRegistry registry;
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private StAXArtifactProcessor<Endpoint> processor;
+ private StAXArtifactProcessor<EndpointReference> refProcessor;
+
+ public EndpointSerializerImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ inputFactory = factories.getFactory(XMLInputFactory.class);
+ outputFactory = factories.getFactory(XMLOutputFactory.class);
+ StAXArtifactProcessorExtensionPoint processors =
+ registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ processor = processors.getProcessor(Endpoint.class);
+ refProcessor = processors.getProcessor(EndpointReference.class);
+ }
+
+ public Endpoint readEndpoint(String xml) {
+ try {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
+ Endpoint result = processor.read(reader, new ProcessorContext(registry));
+ result.setRemote(true);
+ reader.close();
+ return result;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public String write(Endpoint endpoint) {
+ StringWriter sw = new StringWriter();
+ try {
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
+ processor.write(endpoint, writer, new ProcessorContext(registry));
+ writer.flush();
+ writer.close();
+ return sw.toString();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public EndpointReference readEndpointReference(String xml) {
+ try {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
+ EndpointReference result = refProcessor.read(reader, new ProcessorContext(registry));
+ reader.close();
+ return result;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public String write(EndpointReference endpointReference) {
+ StringWriter sw = new StringWriter();
+ try {
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
+ refProcessor.write(endpointReference, writer, new ProcessorContext(registry));
+ writer.flush();
+ writer.close();
+ return sw.toString();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/LocalDomainRegistryFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/LocalDomainRegistryFactory.java
new file mode 100644
index 0000000000..b7d83e754a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/LocalDomainRegistryFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.runtime.BaseDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the
+ * given domain
+ */
+public class LocalDomainRegistryFactory extends BaseDomainRegistryFactory {
+ private final static String[] schemes = new String[] {"local", "vm"};
+
+ /**
+ * @param extensionRegistry
+ */
+ public LocalDomainRegistryFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ protected EndpointRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI) {
+ EndpointRegistry endpointRegistry =
+ new EndpointRegistryImpl(registry, endpointRegistryURI, domainURI);
+ return endpointRegistry;
+ }
+
+ public String[] getSupportedSchemes() {
+ return schemes;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java
new file mode 100644
index 0000000000..4d6a98ca5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.ReferenceParameters;
+
+/**
+ * Artifact processor for reference parameters.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceParameterProcessor implements StAXArtifactProcessor<ReferenceParameters> {
+ private static final QName REFERENCE_PARAMETERS =
+ new QName("http://tuscany.apache.org/xmlns/sca/1.1", "referenceParameters", "tuscany");
+
+ /**
+ * Constructs a new processor.
+ *
+ * @param modelFactories
+ */
+ public ReferenceParameterProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#getArtifactType()
+ */
+ public QName getArtifactType() {
+ return REFERENCE_PARAMETERS;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#read(javax.xml.stream.XMLStreamReader, ProcessorContext)
+ */
+ public ReferenceParameters read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ ReferenceParameters parameters = new ReferenceParametersImpl();
+ parameters.setCallbackID(reader.getAttributeValue(null, "callbackID"));
+ return parameters;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#write(java.lang.Object, javax.xml.stream.XMLStreamWriter, ProcessorContext)
+ */
+ public void write(ReferenceParameters model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ writer.writeStartElement(REFERENCE_PARAMETERS.getPrefix(),
+ REFERENCE_PARAMETERS.getLocalPart(),
+ REFERENCE_PARAMETERS.getNamespaceURI());
+ writer.writeNamespace(REFERENCE_PARAMETERS.getPrefix(), REFERENCE_PARAMETERS.getNamespaceURI());
+
+ if (model.getCallbackID() != null) {
+ writer.writeAttribute("callbackID", model.getCallbackID().toString());
+ }
+ writer.writeEndElement();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#getModelType()
+ */
+ public Class<ReferenceParameters> getModelType() {
+ return ReferenceParameters.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#resolve(java.lang.Object, org.apache.tuscany.sca.contribution.resolver.ModelResolver, ProcessorContext)
+ */
+ public void resolve(ReferenceParameters model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java
new file mode 100644
index 0000000000..7bd56271a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.runtime.ReferenceParameters;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReferenceParametersImpl implements ReferenceParameters {
+ private Object callbackID;
+ private EndpointReference callbackReference;
+ private Object callbackObjectID;
+
+ /**
+ * @return the callbackID
+ */
+ public Object getCallbackID() {
+ return callbackID;
+ }
+ /**
+ * @param callbackID the callbackID to set
+ */
+ public void setCallbackID(Object callbackID) {
+ this.callbackID = callbackID;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.runtime.ReferenceParameters#getCallbackReference()
+ */
+ public EndpointReference getCallbackReference() {
+ return callbackReference;
+ }
+ /**
+ * @see org.apache.tuscany.sca.runtime.ReferenceParameters#setCallback(java.lang.Object)
+ */
+ public void setCallbackReference(EndpointReference callback) {
+ this.callbackReference = callback;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ /**
+ * @return the callbackObjectID
+ */
+ public Object getCallbackObjectID() {
+ return callbackObjectID;
+ }
+ /**
+ * @param callbackObjectID the callbackObjectID to set
+ */
+ public void setCallbackObjectID(Object callbackObjectID) {
+ this.callbackObjectID = callbackObjectID;
+ }
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((callbackID == null) ? 0 : callbackID.hashCode());
+ result = prime * result + ((callbackObjectID == null) ? 0 : callbackObjectID.hashCode());
+ result = prime * result + ((callbackReference == null) ? 0 : callbackReference.hashCode());
+ return result;
+ }
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof ReferenceParametersImpl))
+ return false;
+ final ReferenceParametersImpl other = (ReferenceParametersImpl)obj;
+ if (callbackID == null) {
+ if (other.callbackID != null)
+ return false;
+ } else if (!callbackID.equals(other.callbackID))
+ return false;
+ if (callbackObjectID == null) {
+ if (other.callbackObjectID != null)
+ return false;
+ } else if (!callbackObjectID.equals(other.callbackObjectID))
+ return false;
+ if (callbackReference == null) {
+ if (other.callbackReference != null)
+ return false;
+ } else if (!callbackReference.equals(other.callbackReference))
+ return false;
+
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
new file mode 100644
index 0000000000..6032005b9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.impl.ComponentImpl;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ResolverExtension;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RuntimeComponentImpl extends ComponentImpl implements RuntimeComponent,
+ ScopedRuntimeComponent, ResolverExtension {
+ protected RuntimeComponentContext componentContext;
+ protected ImplementationProvider implementationProvider;
+ protected List<PolicyProvider> policyProviders = new ArrayList<PolicyProvider>();
+ protected ScopeContainer scopeContainer;
+ protected boolean started;
+ protected ModelResolver modelResolver;
+
+ /**
+ */
+ public RuntimeComponentImpl() {
+ super();
+ }
+
+ public ImplementationProvider getImplementationProvider() {
+ return implementationProvider;
+ }
+
+ public void setImplementationProvider(ImplementationProvider provider) {
+ this.implementationProvider = provider;
+ }
+
+ public ScopeContainer getScopeContainer() {
+ return scopeContainer;
+ }
+
+ public void setScopeContainer(ScopeContainer scopeContainer) {
+ this.scopeContainer = scopeContainer;
+ }
+
+ public boolean isStarted() {
+ return started;
+ }
+
+ public void setStarted(boolean started) {
+ this.started = started;
+ }
+
+ /**
+ * @return the componentContext
+ */
+ public RuntimeComponentContext getComponentContext() {
+ return componentContext;
+ }
+
+ /**
+ * @param componentContext the componentContext to set
+ */
+ public void setComponentContext(RuntimeComponentContext componentContext) {
+ this.componentContext = componentContext;
+ }
+
+ public void addPolicyProvider(PolicyProvider policyProvider) {
+ policyProviders.add(policyProvider);
+ }
+
+ public List<PolicyProvider> getPolicyProviders() {
+ return policyProviders;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java
new file mode 100644
index 0000000000..2eea60ccea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of a Component Reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implements RuntimeComponentReference {
+
+ private RuntimeComponent component;
+
+ public RuntimeComponentReferenceImpl() {
+ super();
+ }
+
+ /**
+ * @return the component
+ */
+ public RuntimeComponent getComponent() {
+ return component;
+ }
+
+ /**
+ * @param component the component to set
+ */
+ public void setComponent(RuntimeComponent component) {
+ this.component = component;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ RuntimeComponentReferenceImpl ref = (RuntimeComponentReferenceImpl)super.clone();
+ return ref;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java
new file mode 100644
index 0000000000..bc7e6df878
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Implementation of a Component Service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeComponentServiceImpl extends ComponentServiceImpl implements RuntimeComponentService {
+
+ public RuntimeComponentServiceImpl() {
+ super();
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
new file mode 100644
index 0000000000..3f6f05daf9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
@@ -0,0 +1,835 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.StringReader;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.impl.EndpointImpl;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.core.invocation.AsyncResponseHandler;
+import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
+import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
+import org.apache.tuscany.sca.core.invocation.RuntimeInvoker;
+import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl;
+import org.apache.tuscany.sca.core.invocation.impl.PhaseManager;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.EndpointProvider;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.EndpointSerializer;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Runtime model for Endpoint that supports java serialization
+ */
+public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint, Externalizable {
+ private static final long serialVersionUID = 1L;
+ private transient CompositeContext compositeContext;
+ private transient RuntimeWireProcessor wireProcessor;
+ private transient ProviderFactoryExtensionPoint providerFactories;
+ private transient InterfaceContractMapper interfaceContractMapper;
+ private transient WorkScheduler workScheduler;
+ private transient PhaseManager phaseManager;
+ private transient MessageFactory messageFactory;
+ private transient RuntimeInvoker invoker;
+ private transient EndpointSerializer serializer;
+
+ private transient List<InvocationChain> chains;
+ private transient Map<Operation, InvocationChain> invocationChainMap =
+ new ConcurrentHashMap<Operation, InvocationChain>();
+ private transient InvocationChain bindingInvocationChain;
+
+ private transient ServiceBindingProvider bindingProvider;
+ private transient List<PolicyProvider> policyProviders;
+ private String xml;
+
+ protected InterfaceContract bindingInterfaceContract;
+ protected InterfaceContract serviceInterfaceContract;
+
+ /**
+ * No-arg constructor for Java serialization
+ */
+ public RuntimeEndpointImpl() {
+ super(null);
+ }
+
+ public RuntimeEndpointImpl(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ protected void copyFrom(RuntimeEndpointImpl copy) {
+ this.xml = copy.xml;
+
+ this.component = copy.component;
+ this.service = copy.service;
+ this.interfaceContract = copy.interfaceContract;
+ this.serviceInterfaceContract = copy.serviceInterfaceContract;
+
+ this.binding = copy.binding;
+ this.bindingInterfaceContract = copy.interfaceContract;
+ this.bindingInvocationChain = copy.bindingInvocationChain;
+
+ this.callbackEndpointReferences = copy.callbackEndpointReferences;
+
+ this.requiredIntents = copy.requiredIntents;
+ this.policySets = copy.policySets;
+
+ this.uri = copy.uri;
+ this.remote = copy.remote;
+ this.unresolved = copy.unresolved;
+
+ this.chains = copy.chains;
+ this.invocationChainMap = copy.invocationChainMap;
+ this.bindingProvider = copy.bindingProvider;
+ this.policyProviders = copy.policyProviders;
+
+ if (this.compositeContext == null && copy.compositeContext != null) {
+ bind(copy.compositeContext);
+ }
+ }
+
+ public void bind(CompositeContext compositeContext) {
+ this.compositeContext = compositeContext;
+ bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry());
+ }
+
+ public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) {
+ if (compositeContext == null) {
+ compositeContext = new CompositeContext(registry, endpointRegistry);
+ }
+ this.registry = registry;
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ this.workScheduler = utilities.getUtility(WorkScheduler.class);
+ this.wireProcessor =
+ new ExtensibleWireProcessor(registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class));
+
+ this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class);
+ this.invoker = new RuntimeInvoker(this.messageFactory, this);
+
+ this.phaseManager = utilities.getUtility(PhaseManager.class);
+ this.serializer = utilities.getUtility(EndpointSerializer.class);
+ this.providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ this.contractBuilder = builders.getContractBuilder();
+ }
+
+ public void unbind() {
+ compositeContext = null;
+ bindingInvocationChain = null;
+ chains = null;
+ bindingProvider = null;
+ policyProviders = null;
+ invocationChainMap.clear();
+ }
+
+ public synchronized List<InvocationChain> getInvocationChains() {
+ if (chains == null) {
+ initInvocationChains();
+ }
+ return chains;
+ }
+
+ public synchronized InvocationChain getBindingInvocationChain() {
+ if (bindingInvocationChain == null) {
+ bindingInvocationChain = new InvocationChainImpl(null, null, false, phaseManager);
+ initServiceBindingInvocationChains();
+ }
+
+ // Init the operation invocation chains now. We know they will
+ // be needed as well as the binding invocation chain and this
+ // makes the wire processors run
+ getInvocationChains();
+
+ return bindingInvocationChain;
+ }
+
+ /**
+ * A dummy invocation chain representing null as ConcurrentHashMap doesn't allow null values
+ */
+ private static final InvocationChain NULL_CHAIN = new InvocationChainImpl(null, null, false, null);
+
+ public InvocationChain getInvocationChain(Operation operation) {
+ InvocationChain cached = invocationChainMap.get(operation);
+ if (cached == null) {
+ for (InvocationChain chain : getInvocationChains()) {
+ Operation op = chain.getTargetOperation();
+
+ // We used to check compatibility here but this is now validated when the
+ // chain is created. As the chain operations are the real interface types
+ // they may be incompatible just because they are described in different
+ // IDLs
+ if (operation.getInterface().isRemotable()) {
+ if (operation.getName().equals(op.getName())) {
+ invocationChainMap.put(operation, chain);
+ return chain;
+ }
+ if (interfaceContractMapper.isCompatible(operation, op, Compatibility.SUBSET)) {
+ invocationChainMap.put(operation, chain);
+ return chain;
+ }
+ } else {
+ // [rfeng] We need to run the compatibility check for local operations as they
+ // can be overloaded
+ if (interfaceContractMapper.isCompatible(operation, op, Compatibility.SUBSET)) {
+ invocationChainMap.put(operation, chain);
+ return chain;
+ }
+ }
+ }
+ // Cache it with the NULL_CHAIN to avoid NPE
+ invocationChainMap.put(operation, NULL_CHAIN);
+ return null;
+ } else {
+ if (cached == NULL_CHAIN) {
+ cached = null;
+ }
+ return cached;
+ }
+ }
+
+ public Message invoke(Message msg) {
+ // Deal with async callback
+ // Ensure invocation chains are built...
+ getInvocationChains();
+ if ( !this.getCallbackEndpointReferences().isEmpty() ) {
+ RuntimeEndpointReference asyncEPR = (RuntimeEndpointReference) this.getCallbackEndpointReferences().get(0);
+ // Place a link to the callback EPR into the message headers...
+ msg.getHeaders().put("ASYNC_CALLBACK", asyncEPR );
+ }
+ // end of async callback handling
+ return invoker.invokeBinding(msg);
+ }
+
+ public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
+ return invoker.invoke(operation, args);
+ }
+
+ public Message invoke(Operation operation, Message msg) {
+ return invoker.invoke(operation, msg);
+ }
+
+ /**
+ * Navigate the component/componentType inheritence chain to find the leaf contract
+ * @param contract
+ * @return
+ */
+ private Contract getLeafContract(Contract contract) {
+ Contract prev = null;
+ Contract current = contract;
+ while (current != null) {
+ prev = current;
+ if (current instanceof ComponentReference) {
+ current = ((ComponentReference)current).getReference();
+ } else if (current instanceof CompositeReference) {
+ current = ((CompositeReference)current).getPromotedReferences().get(0);
+ } else if (current instanceof ComponentService) {
+ current = ((ComponentService)current).getService();
+ } else if (current instanceof CompositeService) {
+ current = ((CompositeService)current).getPromotedService();
+ } else {
+ break;
+ }
+ if (current == null) {
+ return prev;
+ }
+ }
+ return current;
+ }
+
+ /**
+ * Initialize the invocation chains
+ */
+ private void initInvocationChains() {
+ chains = new ArrayList<InvocationChain>();
+ InterfaceContract sourceContract = getBindingInterfaceContract();
+
+ // It's the service wire
+ RuntimeComponentService service = (RuntimeComponentService)getService();
+ RuntimeComponent serviceComponent = (RuntimeComponent)getComponent();
+
+ //InterfaceContract targetContract = getInterfaceContract();
+ // TODO - EPR - why is this looking at the component types. The endpoint should have the right interface contract by this time
+ InterfaceContract targetContract = getComponentTypeServiceInterfaceContract();
+ // setInterfaceContract(targetContract);
+ validateServiceInterfaceCompatibility();
+ for (Operation operation : sourceContract.getInterface().getOperations()) {
+ Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
+ if (targetOperation == null) {
+ throw new ServiceRuntimeException("No matching operation for " + operation.getName()
+ + " is found in service "
+ + serviceComponent.getURI()
+ + "#"
+ + service.getName());
+ }
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false, phaseManager);
+ if (operation.isNonBlocking()) {
+ addNonBlockingInterceptor(chain);
+ }
+ addServiceBindingInterceptor(chain, operation);
+ addImplementationInterceptor(serviceComponent, service, chain, targetOperation);
+ chains.add(chain);
+
+ // Handle cases where the operation is an async server
+ if( targetOperation.isAsyncServer() ) {
+ createAsyncServerCallback( this, operation );
+ } // end if
+ }
+
+ wireProcessor.process(this);
+ }
+
+ /**
+ * Creates the async callback for the supplied Endpoint and Operation, if it does not already exist
+ * and stores it into the Endpoint
+ * @param endpoint - the Endpoint
+ * @param operation - the Operation
+ */
+ private void createAsyncServerCallback( RuntimeEndpoint endpoint, Operation operation ) {
+ // Check to see if the callback already exists
+ if( asyncCallbackExists( endpoint ) ) return;
+
+ RuntimeEndpointReference asyncEPR = createAsyncEPR( endpoint );
+
+ // Store the new callback EPR into the Endpoint
+ endpoint.getCallbackEndpointReferences().add(asyncEPR);
+ } // end method createAsyncServerCallback
+
+ /**
+ * Creates the Endpoint object for the async callback
+ * @param endpoint - the endpoint which has the async server operations
+ * @return the EndpointReference object representing the callback
+ */
+ private RuntimeEndpointReference createAsyncEPR( RuntimeEndpoint endpoint ){
+ CompositeContext compositeContext = endpoint.getCompositeContext();
+ RuntimeAssemblyFactory assemblyFactory = getAssemblyFactory( compositeContext );
+ RuntimeEndpointReference epr = (RuntimeEndpointReference)assemblyFactory.createEndpointReference();
+ epr.bind( compositeContext );
+
+ // Create pseudo-reference
+ ComponentReference reference = assemblyFactory.createComponentReference();
+ ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ JavaInterfaceFactory javaInterfaceFactory = (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ try {
+ interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(AsyncResponseHandler.class));
+ } catch (InvalidInterfaceException e1) {
+ // Nothing to do here - will not happen
+ } // end try
+ reference.setInterfaceContract(interfaceContract);
+ String referenceName = endpoint.getService().getName() + "_asyncCallback";
+ reference.setName(referenceName);
+ reference.setForCallback(true);
+ epr.setReference(reference);
+
+ // Create a binding
+ Binding binding = createMatchingBinding( endpoint.getBinding(), (RuntimeComponent)endpoint.getComponent(), reference, registry );
+ epr.setBinding(binding);
+
+ // Need to establish policies here (binding has some...)
+ epr.getRequiredIntents().addAll( endpoint.getRequiredIntents() );
+ epr.getPolicySets().addAll( endpoint.getPolicySets() );
+ String eprURI = endpoint.getComponent().getName() + "#reference-binding(" + referenceName + "/" + referenceName + ")";
+ epr.setURI(eprURI);
+
+ // Attach a dummy endpoint to the epr
+ RuntimeEndpoint ep = (RuntimeEndpoint)assemblyFactory.createEndpoint();
+ ep.setUnresolved(false);
+ epr.setTargetEndpoint(ep);
+ //epr.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ epr.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ epr.setUnresolved(false);
+
+ return epr;
+ } // end method RuntimeEndpointReference
+
+ private boolean asyncCallbackExists( RuntimeEndpoint endpoint ) {
+ if( endpoint.getCallbackEndpointReferences().isEmpty() ) return false;
+ return true;
+ } // end method asyncCallbackExists
+
+ /**
+ * Create a matching binding to a supplied binding
+ * - the matching binding has the same binding type, but is for the supplied component and service
+ * @param matchBinding - the binding to match
+ * @param component - the component
+ * @param service - the service
+ * @param registry - registry for extensions
+ * @return - the matching binding, or null if it could not be created
+ */
+ @SuppressWarnings("unchecked")
+ private Binding createMatchingBinding( Binding matchBinding, RuntimeComponent component,
+ ComponentReference reference, ExtensionPointRegistry registry ) {
+ // Since there is no simple way to obtain a Factory for a binding where the type is not known ahead of
+ // time, the process followed here is to generate the <binding.xxx/> XML element from the binding type QName
+ // and then read the XML using the processor for that XML...
+ QName bindingName = matchBinding.getType();
+ String bindingXML = "<ns1:" + bindingName.getLocalPart() + " xmlns:ns1='" + bindingName.getNamespaceURI() + "'/>";
+
+ StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<?> processor = (StAXArtifactProcessor<?>)processors.getProcessor(bindingName);
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ ValidatingXMLInputFactory inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ StreamSource source = new StreamSource( new StringReader(bindingXML) );
+
+ ProcessorContext context = new ProcessorContext();
+ try {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(source);
+ reader.next();
+ Binding newBinding = (Binding) processor.read(reader, context );
+ newBinding.setName("asyncCallback");
+
+ // Create a URI address for the callback based on the Component_Name/Reference_Name pattern
+ String callbackURI = "/" + component.getName() + "/" + reference.getName();
+ //newBinding.setURI(callbackURI);
+
+ BuilderExtensionPoint builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ BindingBuilder builder = builders.getBindingBuilder(newBinding.getType());
+ if (builder != null) {
+ org.apache.tuscany.sca.assembly.builder.BuilderContext builderContext = new BuilderContext(registry);
+ builder.build(component, reference, newBinding, builderContext, true);
+ } // end if
+
+ return newBinding;
+ } catch (ContributionReadException e) {
+ e.printStackTrace();
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ } // end method createMatchingBinding
+
+ /**
+ * Gets a RuntimeAssemblyFactory from the CompositeContext
+ * @param compositeContext
+ * @return the RuntimeAssemblyFactory
+ */
+ private RuntimeAssemblyFactory getAssemblyFactory( CompositeContext compositeContext ) {
+ ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ return (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+ } // end method RuntimeAssemblyFactory
+
+ /**
+ * Check that endpoint has compatible interface at the component and binding ends.
+ * The user can specify the interfaces at both ends so there is a danger that they won't be compatible.
+ */
+ public void validateServiceInterfaceCompatibility() {
+
+ InterfaceContract serviceContract = getComponentServiceInterfaceContract();
+ InterfaceContract bindingContract = getBindingInterfaceContract();
+
+ if ((serviceContract != null) &&
+ (bindingContract != null)){
+
+ boolean bindingHasCallback = bindingContract.getCallbackInterface() != null;
+
+ try {
+
+ // Use the normalized contract if the interface types are different or if
+ // a normalized contract has been previously generate, for example, by virtue
+ // of finding a JAXWS annotation on a Java class that references a WSDL file
+ if (serviceContract.getClass() != bindingContract.getClass() ||
+ serviceContract.getNormalizedWSDLContract() != null ||
+ bindingContract.getNormalizedWSDLContract() != null) {
+ interfaceContractMapper.checkCompatibility(getGeneratedWSDLContract(serviceContract),
+ getGeneratedWSDLContract(bindingContract),
+ Compatibility.SUBSET,
+ !bindingHasCallback, // ignore callbacks if binding doesn't have one
+ false);
+ } else {
+ interfaceContractMapper.checkCompatibility(serviceContract,
+ bindingContract,
+ Compatibility.SUBSET,
+ !bindingHasCallback, // ignore callbacks if binding doesn't have one
+ false);
+ }
+ } catch (Exception ex){
+ throw new ServiceRuntimeException("Component " +
+ this.getComponent().getName() +
+ " Service " +
+ getService().getName() +
+ " interface is incompatible with the interface of the reference binding - " +
+ getBinding().getName() +
+ " - " +
+ ex.getMessage() +
+ " - [" + this.toString() + "]");
+ }
+ }
+
+ }
+
+ private void initServiceBindingInvocationChains() {
+
+ // add the binding interceptors to the service binding wire
+ ServiceBindingProvider provider = getBindingProvider();
+ if ((provider != null) && (provider instanceof EndpointProvider)) {
+ ((EndpointProvider)provider).configure();
+ }
+
+ // add the policy interceptors to the service binding wire
+ List<PolicyProvider> pps = getPolicyProviders();
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ Interceptor interceptor = p.createBindingInterceptor();
+ if (interceptor != null) {
+ bindingInvocationChain.addInterceptor(interceptor);
+ }
+ }
+
+ }
+
+ // TODO - add something on the end of the wire to invoke the
+ // invocation chain. Need to split out the runtime
+ // wire invoker into conversation, callback interceptors etc
+ bindingInvocationChain.addInvoker(invoker);
+
+ }
+
+ /**
+ * Add the interceptor for a binding
+ *
+ * @param reference
+ * @param binding
+ * @param chain
+ * @param operation
+ */
+ private void addServiceBindingInterceptor(InvocationChain chain, Operation operation) {
+ List<PolicyProvider> pps = getPolicyProviders();
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ Interceptor interceptor = p.createInterceptor(operation);
+ if (interceptor != null) {
+ chain.addInterceptor(interceptor);
+ }
+ }
+ }
+ }
+
+ /**
+ * Add a non-blocking interceptor if the service binding needs it
+ *
+ * @param service
+ * @param binding
+ * @param chain
+ */
+ private void addNonBlockingInterceptor(InvocationChain chain) {
+ ServiceBindingProvider provider = getBindingProvider();
+ if (provider != null) {
+ if (!provider.supportsOneWayInvocation()) {
+ chain.addInterceptor(Phase.SERVICE, new NonBlockingInterceptor(workScheduler));
+ }
+ }
+ }
+
+ /**
+ * Add the interceptor for a component implementation
+ *
+ * @param component
+ * @param service
+ * @param chain
+ * @param operation
+ */
+ private void addImplementationInterceptor(Component component,
+ ComponentService service,
+ InvocationChain chain,
+ Operation operation) {
+
+ if (service.getService() instanceof CompositeService) {
+ CompositeService compositeService = (CompositeService)service.getService();
+ component = getPromotedComponent(compositeService);
+ service = getPromotedComponentService(compositeService);
+ }
+
+ ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider();
+
+ if (provider != null) {
+ Invoker invoker = null;
+ invoker = provider.createInvoker((RuntimeComponentService)service, operation);
+ chain.addInvoker(invoker);
+ }
+ // TODO - EPR - don't we need to get the policy from the right level in the
+ // model rather than the leafmost level
+ List<PolicyProvider> pps = ((RuntimeComponent)component).getPolicyProviders();
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ Interceptor interceptor = p.createInterceptor(operation);
+ if (interceptor != null) {
+ //chain.addInterceptor(p.createInterceptor(operation));
+ chain.addInterceptor(interceptor);
+ }
+ }
+ }
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ RuntimeEndpointImpl copy = (RuntimeEndpointImpl)super.clone();
+ copy.invoker = new RuntimeInvoker(copy.messageFactory, copy);
+ return copy;
+ }
+
+ /**
+ * Follow a service promotion chain down to the inner most (non composite)
+ * component service.
+ *
+ * @param topCompositeService
+ * @return
+ */
+ private ComponentService getPromotedComponentService(CompositeService compositeService) {
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ Service service = componentService.getService();
+ if (componentService.getName() != null && service instanceof CompositeService) {
+
+ // Continue to follow the service promotion chain
+ return getPromotedComponentService((CompositeService)service);
+
+ } else {
+
+ // Found a non-composite service
+ return componentService;
+ }
+ } else {
+
+ // No promoted service
+ return null;
+ }
+ }
+
+ /**
+ * Follow a service promotion chain down to the innermost (non-composite) component.
+ *
+ * @param compositeService
+ * @return
+ */
+ private Component getPromotedComponent(CompositeService compositeService) {
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ Service service = componentService.getService();
+ if (componentService.getName() != null && service instanceof CompositeService) {
+
+ // Continue to follow the service promotion chain
+ return getPromotedComponent((CompositeService)service);
+
+ } else {
+
+ // Found a non-composite service
+ return compositeService.getPromotedComponent();
+ }
+ } else {
+
+ // No promoted service
+ return null;
+ }
+ }
+
+ public synchronized ServiceBindingProvider getBindingProvider() {
+ resolve();
+ if (bindingProvider == null) {
+ BindingProviderFactory factory =
+ (BindingProviderFactory)providerFactories.getProviderFactory(getBinding().getClass());
+ if (factory == null) {
+ throw new ServiceRuntimeException("No provider factory is registered for binding " + getBinding()
+ .getType());
+ }
+ this.bindingProvider = factory.createServiceBindingProvider(this);
+ }
+ return bindingProvider;
+ }
+
+ public synchronized List<PolicyProvider> getPolicyProviders() {
+ resolve();
+ if (policyProviders == null) {
+ policyProviders = new ArrayList<PolicyProvider>();
+ for (PolicyProviderFactory factory : providerFactories.getPolicyProviderFactories()) {
+ PolicyProvider provider = factory.createServicePolicyProvider(this);
+ if (provider != null) {
+ policyProviders.add(provider);
+ }
+ }
+ }
+ return policyProviders;
+ }
+
+ public void setBindingProvider(ServiceBindingProvider provider) {
+ this.bindingProvider = provider;
+ }
+
+ public Contract getContract() {
+ return getService();
+ }
+
+ public CompositeContext getCompositeContext() {
+ return compositeContext;
+ }
+
+ @Override
+ protected void reset() {
+ super.reset();
+ this.xml = null;
+ }
+
+ @Override
+ protected synchronized void resolve() {
+ if (xml != null && component == null) {
+ if (compositeContext == null) {
+ compositeContext = CompositeContext.getCurrentCompositeContext();
+ if (compositeContext != null) {
+ bind(compositeContext);
+ }
+ }
+ if (serializer != null) {
+ RuntimeEndpointImpl ep = (RuntimeEndpointImpl)serializer.readEndpoint(xml);
+ copyFrom(ep);
+ } else {
+ // FIXME: [rfeng] What should we do here?
+ }
+ }
+ super.resolve();
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ resolve();
+ if (bindingInterfaceContract != null) {
+ return bindingInterfaceContract;
+ }
+ bindingInterfaceContract = getBindingProvider().getBindingInterfaceContract();
+ if (bindingInterfaceContract == null) {
+ bindingInterfaceContract = getComponentServiceInterfaceContract();
+ }
+ if (bindingInterfaceContract == null) {
+ bindingInterfaceContract = getComponentTypeServiceInterfaceContract();
+ }
+ return bindingInterfaceContract;
+ }
+
+ public InterfaceContract getComponentTypeServiceInterfaceContract() {
+ resolve();
+ if (serviceInterfaceContract != null) {
+ return serviceInterfaceContract;
+ }
+ if (service == null) {
+ return getComponentServiceInterfaceContract();
+ }
+ serviceInterfaceContract = getLeafContract(service).getInterfaceContract();
+ if (serviceInterfaceContract == null) {
+ serviceInterfaceContract = getComponentServiceInterfaceContract();
+ }
+ return serviceInterfaceContract;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.uri = in.readUTF();
+ this.xml = in.readUTF();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeUTF(getURI());
+ if (serializer == null && xml != null) {
+ out.writeUTF(xml);
+ } else {
+ if (serializer != null) {
+ out.writeUTF(serializer.write(this));
+ } else {
+ throw new IllegalStateException("No serializer is configured");
+ }
+ }
+ }
+ public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract) {
+
+ if ( interfaceContract.getNormalizedWSDLContract() == null){
+ if (getComponentServiceInterfaceContract() instanceof JavaInterfaceContract){
+ if (contractBuilder == null){
+ throw new ServiceRuntimeException("Contract builder not found while calculating WSDL contract for " + this.toString());
+ }
+ contractBuilder.build(interfaceContract, null);
+ }
+ }
+
+ return interfaceContract.getNormalizedWSDLContract();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
new file mode 100644
index 0000000000..0277c37962
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
@@ -0,0 +1,619 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.assembly.impl;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
+import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
+import org.apache.tuscany.sca.core.invocation.RuntimeInvoker;
+import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl;
+import org.apache.tuscany.sca.core.invocation.impl.PhaseManager;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.EndpointSerializer;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Runtime model for Endpoint that supports java serialization
+ */
+public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implements RuntimeEndpointReference, Externalizable {
+ private transient CompositeContext compositeContext;
+ private transient RuntimeWireProcessor wireProcessor;
+ private transient InterfaceContractMapper interfaceContractMapper;
+ private transient WorkScheduler workScheduler;
+ private transient PhaseManager phaseManager;
+ private transient MessageFactory messageFactory;
+ private transient RuntimeInvoker invoker;
+ private transient EndpointRegistry endpointRegistry;
+
+ private transient List<InvocationChain> chains;
+ private transient Map<Operation, InvocationChain> invocationChainMap =
+ new ConcurrentHashMap<Operation, InvocationChain>();
+ private transient InvocationChain bindingInvocationChain;
+
+ private transient EndpointReferenceBinder eprBinder;
+ private transient ReferenceBindingProvider bindingProvider;
+ private transient ProviderFactoryExtensionPoint providerFactories;
+ private transient List<PolicyProvider> policyProviders;
+ private transient EndpointSerializer serializer;
+
+ protected InterfaceContract bindingInterfaceContract;
+ protected InterfaceContract referenceInterfaceContract;
+
+ //protected InterfaceContract generatedReferenceWSDLInterfaceContract;
+
+ private String xml;
+
+ private boolean started;
+
+ /**
+ * No-arg constructor for Java serilization
+ */
+ public RuntimeEndpointReferenceImpl() {
+ super(null);
+ }
+
+ public RuntimeEndpointReferenceImpl(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ protected void copyFrom(RuntimeEndpointReferenceImpl copy) {
+ this.xml = copy.xml;
+
+ this.component = copy.component;
+ this.reference = copy.reference;
+ this.interfaceContract = copy.interfaceContract;
+ this.referenceInterfaceContract = copy.referenceInterfaceContract;
+ this.callbackEndpoint = copy.callbackEndpoint;
+ this.targetEndpoint = copy.targetEndpoint;
+
+ this.binding = copy.binding;
+ this.bindingInterfaceContract = copy.interfaceContract;
+ this.bindingInvocationChain = copy.bindingInvocationChain;
+
+ this.requiredIntents = copy.requiredIntents;
+ this.policySets = copy.policySets;
+
+ this.uri = copy.uri;
+ this.unresolved = copy.unresolved;
+ this.status = copy.status;
+
+ this.chains = copy.chains;
+ this.invocationChainMap = copy.invocationChainMap;
+ this.bindingProvider = copy.bindingProvider;
+ this.policyProviders = copy.policyProviders;
+
+ if (this.compositeContext == null && copy.compositeContext != null) {
+ bind(copy.compositeContext);
+ }
+ }
+
+ public void bind(CompositeContext compositeContext) {
+ this.compositeContext = compositeContext;
+ bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry());
+ }
+
+ public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) {
+ if (compositeContext == null) {
+ compositeContext = new CompositeContext(registry, endpointRegistry);
+ }
+ this.registry = registry;
+ this.endpointRegistry = endpointRegistry;
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ this.workScheduler = utilities.getUtility(WorkScheduler.class);
+ this.wireProcessor =
+ new ExtensibleWireProcessor(registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class));
+
+ this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class);
+ this.invoker = new RuntimeInvoker(this.messageFactory, this);
+
+ this.phaseManager = utilities.getUtility(PhaseManager.class);
+ this.serializer = utilities.getUtility(EndpointSerializer.class);
+ this.providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ this.contractBuilder = builders.getContractBuilder();
+ }
+
+ public synchronized List<InvocationChain> getInvocationChains() {
+ if (chains == null) {
+ initInvocationChains();
+ }
+ return chains;
+ }
+
+ public synchronized InvocationChain getBindingInvocationChain() {
+ if (bindingInvocationChain == null) {
+ bindingInvocationChain = new InvocationChainImpl(null, null, true, phaseManager);
+ initReferenceBindingInvocationChains();
+ }
+ return bindingInvocationChain;
+ }
+
+ public InvocationChain getInvocationChain(Operation operation) {
+ InvocationChain cached = invocationChainMap.get(operation);
+ if (cached == null) {
+ for (InvocationChain chain : getInvocationChains()) {
+ Operation op = chain.getSourceOperation();
+
+ // We used to check compatibility here but this is now validated when the
+ // chain is created. As the chain operations are the real interface types
+ // they may be incompatible just because they are described in different
+ // IDLs
+ if (operation.getName().equals(op.getName())) {
+ invocationChainMap.put(operation, chain);
+ return chain;
+ }
+ }
+ invocationChainMap.put(operation, null);
+ return null;
+ } else {
+ return cached;
+ }
+ }
+
+ public Message invoke(Message msg) {
+ return invoker.invoke(msg);
+ }
+
+ public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
+ return invoker.invoke(operation, args);
+ }
+
+ public Message invoke(Operation operation, Message msg) {
+ return invoker.invoke(operation, msg);
+ }
+
+ /**
+ * Navigate the component/componentType inheritence chain to find the leaf contract
+ * @param contract
+ * @return
+ */
+ private Contract getLeafContract(Contract contract) {
+ Contract prev = null;
+ Contract current = contract;
+ while (current != null) {
+ prev = current;
+ if (current instanceof ComponentReference) {
+ current = ((ComponentReference)current).getReference();
+ } else if (current instanceof CompositeReference) {
+ current = ((CompositeReference)current).getPromotedReferences().get(0);
+ } else if (current instanceof ComponentService) {
+ current = ((ComponentService)current).getService();
+ } else if (current instanceof CompositeService) {
+ current = ((CompositeService)current).getPromotedService();
+ } else {
+ break;
+ }
+ if (current == null) {
+ return prev;
+ }
+ }
+ return current;
+ }
+
+ /**
+ * Initialize the invocation chains
+ */
+ private void initInvocationChains() {
+ InterfaceContract sourceContract = getComponentTypeReferenceInterfaceContract();
+ // TODO - EPR why is this looking at the component types. The endpoint reference should have the right interface contract by this time
+ //InterfaceContract sourceContract = getLeafInterfaceContract(endpointReference);
+
+ // It's the reference wire
+ resolveEndpointReference();
+
+ InterfaceContract targetContract = getBindingInterfaceContract();
+ // TODO - EPR why is this looking at the component types. The endpoint should have the right interface contract by this time
+ //InterfaceContract targetContract = getLeafInterfaceContract(endpoint);
+
+ if (sourceContract == null && targetContract != null) {
+ // TODO: until the web component introspection is brought up
+ try {
+ sourceContract = (InterfaceContract)targetContract.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ validateReferenceInterfaceCompatibility();
+
+ List<InvocationChain> chainList = new ArrayList<InvocationChain>();
+ if(sourceContract != null && targetContract != null) {
+ RuntimeComponentReference reference = (RuntimeComponentReference)getReference();
+ for (Operation operation : sourceContract.getInterface().getOperations()) {
+ Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
+ if (targetOperation == null) {
+ throw new ServiceRuntimeException("No matching operation for " + operation.getName()
+ + " is found in reference "
+ + getComponent().getURI()
+ + "#"
+ + reference.getName());
+ }
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true, phaseManager);
+ if (operation.isNonBlocking()) {
+ addNonBlockingInterceptor(chain);
+ }
+ chainList.add(chain);
+ addReferenceBindingInterceptor(chain, operation);
+ }
+ }
+
+ // Set the chains until it's fully populated. If we initialize too early, any exeception could
+ // leave this endpoint reference in a wrong state with an empty chain.
+ chains = chainList;
+ wireProcessor.process(this);
+ }
+
+ /**
+ * Check that endpoint reference has compatible interface at the component and binding ends.
+ * The user can specify the interfaces at both ends so there is a danger that they won't be compatible.
+ * There is checking in the activator but of course endpoint references may not have a binding assigned
+ * until final resolution.
+ */
+ public void validateReferenceInterfaceCompatibility() {
+
+ InterfaceContract referenceContract = getComponentReferenceInterfaceContract();
+ InterfaceContract bindingContract = getBindingInterfaceContract();
+
+ if ((referenceContract != null) &&
+ (bindingContract != null)){
+
+ boolean bindingHasCallback = bindingContract.getCallbackInterface() != null;
+
+ try {
+ // Use the normalized contract if the interface types are different or if
+ // a normalized contract has been previously generate, for example, by virtue
+ // of finding a JAXWS annotation on a Java class that references a WSDL file
+ if (referenceContract.getClass() != bindingContract.getClass() ||
+ referenceContract.getNormalizedWSDLContract() != null ||
+ bindingContract.getNormalizedWSDLContract() != null) {
+ interfaceContractMapper.checkCompatibility(getGeneratedWSDLContract(referenceContract),
+ getGeneratedWSDLContract(bindingContract),
+ Compatibility.SUBSET,
+ !bindingHasCallback, // ignore callbacks if binding doesn't have one
+ false);
+ } else {
+ interfaceContractMapper.checkCompatibility(referenceContract,
+ bindingContract,
+ Compatibility.SUBSET,
+ !bindingHasCallback, // ignore callbacks if binding doesn't have one
+ false);
+ }
+ } catch (Exception ex){
+ throw new ServiceRuntimeException("Component " +
+ this.getComponent().getName() +
+ " Reference " +
+ getReference().getName() +
+ " interface is incompatible with the interface of the reference binding " +
+ getBinding().getName() +
+ " - " +
+ ex.getMessage() +
+ " - [" + this.toString() + "]");
+ }
+ }
+ }
+
+ /**
+ * This code used to be in the activator but has moved here as
+ * the endpoint reference may not now be resolved until the wire
+ * is first used
+ */
+ private void resolveEndpointReference() {
+ resolve();
+
+ eprBinder.bindRunTime(endpointRegistry, this);
+
+ // start the binding provider
+ final ReferenceBindingProvider bindingProvider = getBindingProvider();
+
+ if (bindingProvider != null) {
+ // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ bindingProvider.start();
+ return null;
+ }
+ });
+ }
+ for (PolicyProvider policyProvider : getPolicyProviders()) {
+ policyProvider.start();
+ }
+
+ started = true;
+ // InterfaceContract bindingContract = getBindingInterfaceContract();
+ // endpoint.setInterfaceContract(bindingContract);
+ }
+
+ private void initReferenceBindingInvocationChains() {
+
+ // add the binding interceptors to the reference binding wire
+ ReferenceBindingProvider provider = getBindingProvider();
+ if ((provider != null) && (provider instanceof EndpointReferenceProvider)) {
+ ((EndpointReferenceProvider)provider).configure();
+ }
+
+ // add the policy interceptors to the service binding wire
+ // find out which policies are active
+ for (PolicyProvider p : getPolicyProviders()) {
+ Interceptor interceptor = p.createBindingInterceptor();
+ if (interceptor != null) {
+ bindingInvocationChain.addInterceptor(interceptor);
+ }
+ }
+ }
+
+ public void rebuild() {
+ // TODO - can we use the idea of setTarget to rebuild the wire?
+ // used at the moment by binding.sca when it resets the
+ // source interface contract for local wires
+ this.chains = null;
+
+ if (getStatus() == EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED){
+ setStatus(EndpointReference.Status.NOT_CONFIGURED);
+ }
+
+ // TODO - cheating here as I fixed the RuntimeComponentService code
+ // to call this when it resets the interface contract
+ //endpointReference.setInterfaceContract(epr.getInterfaceContract());
+ }
+
+ /**
+ * Add the interceptor for a reference binding
+ *
+ * @param reference
+ * @param binding
+ * @param chain
+ * @param operation
+ */
+ private void addReferenceBindingInterceptor(InvocationChain chain, Operation operation) {
+ ReferenceBindingProvider provider = getBindingProvider();
+ if (provider != null) {
+ Invoker invoker = provider.createInvoker(operation);
+ if (invoker != null) {
+ chain.addInvoker(invoker);
+ }
+ }
+ List<PolicyProvider> pps = getPolicyProviders();
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ Interceptor interceptor = p.createBindingInterceptor();
+ if (interceptor != null) {
+ chain.addInterceptor(interceptor);
+ }
+ }
+ }
+ }
+
+ /**
+ * Add a non-blocking interceptor if the reference binding needs it
+ *
+ * @param reference
+ * @param binding
+ * @param chain
+ */
+ private void addNonBlockingInterceptor(InvocationChain chain) {
+ ReferenceBindingProvider provider = getBindingProvider();
+ if (provider != null) {
+ boolean supportsOneWayInvocation = provider.supportsOneWayInvocation();
+ if (!supportsOneWayInvocation) {
+ chain.addInterceptor(Phase.REFERENCE, new NonBlockingInterceptor(workScheduler));
+ }
+ }
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ RuntimeEndpointReferenceImpl copy = (RuntimeEndpointReferenceImpl)super.clone();
+ copy.invoker = new RuntimeInvoker(copy.messageFactory, copy);
+ return copy;
+ }
+
+ public boolean isOutOfDate() {
+ resolve();
+ return eprBinder.isOutOfDate(endpointRegistry, this);
+ }
+
+ public synchronized ReferenceBindingProvider getBindingProvider() {
+ resolve();
+ // For the case that binding.sca is implemented by another binding
+ if (binding == null) {
+ return null;
+ }
+ if (bindingProvider == null) {
+ BindingProviderFactory factory =
+ (BindingProviderFactory)providerFactories.getProviderFactory(getBinding().getClass());
+ if (factory == null) {
+ throw new ServiceRuntimeException("No provider factory is registered for binding " + getBinding()
+ .getType());
+ }
+ this.bindingProvider = factory.createReferenceBindingProvider(this);
+ }
+ return bindingProvider;
+ }
+
+ public void setBindingProvider(ReferenceBindingProvider bindingProvider) {
+ this.bindingProvider = bindingProvider;
+ }
+
+ public synchronized List<PolicyProvider> getPolicyProviders() {
+ resolve();
+ if (policyProviders == null) {
+ policyProviders = new ArrayList<PolicyProvider>();
+ for (PolicyProviderFactory factory : providerFactories.getPolicyProviderFactories()) {
+ PolicyProvider provider = factory.createReferencePolicyProvider(this);
+ if (provider != null) {
+ policyProviders.add(provider);
+ }
+ }
+ }
+ return policyProviders;
+ }
+
+ public void unbind() {
+ bindingInvocationChain = null;
+ chains = null;
+ bindingProvider = null;
+ policyProviders = null;
+ invocationChainMap.clear();
+ }
+
+ public Contract getContract() {
+ return getReference();
+ }
+
+ public CompositeContext getCompositeContext() {
+ return compositeContext;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ resolve();
+ if (bindingInterfaceContract != null) {
+ return bindingInterfaceContract;
+ }
+ bindingInterfaceContract = getBindingProvider().getBindingInterfaceContract();
+ if (bindingInterfaceContract == null) {
+ bindingInterfaceContract = getComponentReferenceInterfaceContract();
+ }
+ if (bindingInterfaceContract == null) {
+ bindingInterfaceContract = getComponentTypeReferenceInterfaceContract();
+ }
+ return bindingInterfaceContract;
+ }
+
+ public InterfaceContract getComponentTypeReferenceInterfaceContract() {
+ resolve();
+ if (referenceInterfaceContract != null) {
+ return referenceInterfaceContract;
+ }
+ if (reference == null) {
+ return getComponentReferenceInterfaceContract();
+ }
+ referenceInterfaceContract = getLeafContract(reference).getInterfaceContract();
+ if (referenceInterfaceContract == null) {
+ referenceInterfaceContract = getComponentReferenceInterfaceContract();
+ }
+ return referenceInterfaceContract;
+ }
+
+ @Override
+ protected synchronized void resolve() {
+ if (xml != null && component == null) {
+ if (compositeContext == null) {
+ compositeContext = CompositeContext.getCurrentCompositeContext();
+ if (compositeContext != null) {
+ bind(compositeContext);
+ }
+ }
+ RuntimeEndpointReferenceImpl epr = (RuntimeEndpointReferenceImpl)serializer.readEndpointReference(xml);
+ copyFrom(epr);
+ }
+ super.resolve();
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.uri = in.readUTF();
+ this.xml = in.readUTF();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeUTF(getURI());
+ if (serializer == null && xml != null) {
+ out.writeUTF(xml);
+ } else {
+ if (serializer != null) {
+ out.writeUTF(serializer.write(this));
+ } else {
+ throw new IllegalStateException("No serializer is configured");
+ }
+ }
+ }
+
+ public boolean isStarted() {
+ return started;
+ }
+
+ public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract) {
+
+ if ( interfaceContract.getNormalizedWSDLContract() == null){
+ if (getComponentReferenceInterfaceContract() instanceof JavaInterfaceContract){
+ if (contractBuilder == null){
+ throw new ServiceRuntimeException("Contract builder not found while calculating WSDL contract for " + this.toString());
+ }
+ contractBuilder.build(interfaceContract, null);
+ }
+ }
+
+ return interfaceContract.getNormalizedWSDLContract();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java
new file mode 100644
index 0000000000..2de52bebb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.context;
+
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.context.impl.ComponentContextImpl;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DefaultComponentContextFactory implements ComponentContextFactory {
+ private final ExtensionPointRegistry registry;
+
+ public DefaultComponentContextFactory(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public ComponentContext createComponentContext(CompositeContext compositeContext, RuntimeComponent component) {
+ return new ComponentContextImpl(registry, compositeContext, component);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java
new file mode 100644
index 0000000000..ace4dc48e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.context;
+
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.context.impl.RequestContextImpl;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.RequestContext;
+
+/**
+ * Default implementation of RequestContextFactory
+ */
+public class DefaultRequestContextFactory implements RequestContextFactory {
+
+ public DefaultRequestContextFactory(ExtensionPointRegistry registry) {
+ }
+
+ public RequestContext createRequestContext(RuntimeComponent component) {
+ return new RequestContextImpl(component);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java
new file mode 100644
index 0000000000..5206f0945e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.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.core.context;
+
+import java.io.Externalizable;
+
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Extended ServiceReference
+ */
+public interface ServiceReferenceExt<B> extends ServiceReference<B>, Externalizable {
+
+ /**
+ * Return the EndpointReference that sits behind this service reference
+ * @return endpoint reference
+ */
+ RuntimeEndpointReference getEndpointReference();
+
+ B getProxy();
+ void setProxy(B proxy);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java
new file mode 100644
index 0000000000..542a80f926
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.context.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> {
+ private RuntimeEndpointReference callbackEPR;
+ private List<? extends EndpointReference> callbackEPRs;
+ private Endpoint resolvedEndpoint;
+
+ /*
+ * Public constructor for Externalizable serialization/deserialization
+ */
+ public CallbackServiceReferenceImpl() {
+ super();
+ }
+
+ public CallbackServiceReferenceImpl(Class<B> interfaze,
+ List<? extends EndpointReference> callbackEPRs) {
+ super(interfaze, null, getCompositeContext(callbackEPRs));
+ this.callbackEPRs = callbackEPRs;
+ init();
+ }
+
+ private static CompositeContext getCompositeContext(List<? extends EndpointReference> callbackEPRs) {
+ if(!callbackEPRs.isEmpty()) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) callbackEPRs.get(0);
+ return epr.getCompositeContext();
+ }
+ return null;
+ }
+
+ public void init() {
+ Message msgContext = ThreadMessageContext.getMessageContext();
+ callbackEPR = selectCallbackEPR(msgContext);
+ if (callbackEPR == null) {
+ throw new ServiceRuntimeException("No callback binding found for " + msgContext.getTo().toString());
+ }
+ resolvedEndpoint = msgContext.getFrom().getCallbackEndpoint();
+ }
+
+ @Override
+ protected B createProxy() throws Exception {
+ return proxyFactory.createCallbackProxy(this);
+ }
+
+ public RuntimeEndpointReference getCallbackEPR() {
+ if (resolvedEndpoint == null) {
+ return null;
+ } else {
+ return cloneAndBind(callbackEPR);
+ }
+ }
+
+ public Endpoint getResolvedEndpoint() {
+ return resolvedEndpoint;
+ }
+
+ private RuntimeEndpointReference selectCallbackEPR(Message msgContext) {
+ // look for callback binding with same name as service binding
+ Endpoint to = msgContext.getTo();
+ if (to == null) {
+ //FIXME: need better exception
+ throw new ServiceRuntimeException("Destination for forward call is not available");
+ }
+ for (EndpointReference epr : callbackEPRs) {
+ if (epr.getBinding().getName().equals(to.getBinding().getName())) {
+ return (RuntimeEndpointReference) epr;
+ }
+ }
+
+ // if no match, look for callback binding with same type as service binding
+ for (EndpointReference epr : callbackEPRs) {
+ if (epr.getBinding().getType().equals(to.getBinding().getType())) {
+ return (RuntimeEndpointReference) epr;
+ }
+ }
+
+ // no suitable callback wire was found
+ return null;
+ }
+
+ private RuntimeEndpointReference cloneAndBind(RuntimeEndpointReference endpointReference) {
+ if (resolvedEndpoint != null) {
+
+ try {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference.clone();
+ epr.setTargetEndpoint(resolvedEndpoint);
+ return epr;
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ throw new ServiceRuntimeException(e);
+ }
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
new file mode 100644
index 0000000000..cfa2a3c7e3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
@@ -0,0 +1,546 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.context.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+
+/**
+ * Implementation of ComponentContext that delegates to a ComponentContextProvider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentContextImpl implements RuntimeComponentContext {
+ private final RuntimeComponent component;
+
+ private final CompositeContext compositeContext;
+ private final CompositeActivator compositeActivator;
+ private final RequestContextFactory requestContextFactory;
+ private final ProxyFactory proxyFactory;
+ private final AssemblyFactory assemblyFactory;
+ private final JavaInterfaceFactory javaInterfaceFactory;
+ private final PropertyValueFactory propertyFactory;
+ private final EndpointReferenceBinder eprBinder;
+ private final ExtensionPointRegistry registry;
+
+ public ComponentContextImpl(ExtensionPointRegistry registry,
+ CompositeContext compositeContext,
+ RuntimeComponent component) {
+ this.component = component;
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.compositeContext = compositeContext;
+
+ this.compositeActivator = utilities.getUtility(CompositeActivator.class);
+
+ this.requestContextFactory =
+ registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class);
+ this.proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ this.propertyFactory = factories.getFactory(PropertyValueFactory.class);
+
+ this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
+
+ this.registry = registry;
+ }
+
+ public String getURI() {
+ return component.getURI();
+ }
+
+ public <B> ServiceReference<B> cast(B target) throws IllegalArgumentException {
+ return proxyFactory.cast(target);
+ }
+
+ public <B> B getService(Class<B> businessInterface, String referenceName) throws IllegalArgumentException {
+ B service = null;
+
+ ServiceReference<B> serviceRef = getServiceReference(businessInterface, referenceName);
+ if(serviceRef != null) {
+ service = serviceRef.getService();
+ }
+
+ return service;
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) throws IllegalArgumentException {
+
+ for (ComponentReference ref : component.getReferences()) {
+ if (referenceName.equals(ref.getName())) {
+ Multiplicity multiplicity = ref.getMultiplicity();
+ if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) {
+ throw new IllegalArgumentException("Reference " + referenceName
+ + " has multiplicity "
+ + multiplicity);
+ }
+ if (ref.getEndpointReferences().size() < 1) {
+ return null;
+ }
+ ServiceReference<B> sr = getServiceReference(businessInterface, (RuntimeEndpointReference)getEndpointReference(ref));
+ if (sr == null) {
+ throw new IllegalArgumentException("Reference " + referenceName + " is null");
+ }
+ return sr;
+ }
+ }
+ throw new IllegalArgumentException("[JCA80011] Reference not found: " + referenceName);
+
+ }
+
+ /**
+ * Select an endpoint reference from the component reference
+ * @param ref
+ * @return
+ */
+ private EndpointReference getEndpointReference(ComponentReference ref) {
+ List<EndpointReference> eprs = ref.getEndpointReferences();
+ if (eprs.size() == 1) {
+ // Return 1st one
+ return eprs.get(0);
+ } else {
+ for (EndpointReference epr : eprs) {
+ // Try to see if there is an EPR using binding.sca
+ if (epr.getBinding().getType().equals(SCABinding.TYPE)) {
+ return epr;
+ }
+ }
+ return eprs.get(0);
+ }
+ }
+
+ /**
+ * Select an endpoint reference from the component reference
+ * @param ref
+ * @return
+ */
+ private Endpoint getEndpoint(ComponentService service, String bindingName) {
+ if (bindingName == null) {
+ // The default binding name is the name of the promoted service
+ bindingName = getPromotedService(service).getName();
+ }
+ Endpoint returnEp = null;
+ List<Endpoint> eps = service.getEndpoints();
+ for (Endpoint ep : eps) {
+ Binding binding = ep.getBinding();
+ if (bindingName.equals(binding.getName()) || binding.getName() == null) {
+ returnEp = ep;
+ break;
+ }
+ }
+ //TUSCANY-3543
+ if(returnEp == null) {
+ returnEp = eps.get(0);
+ }
+
+ return returnEp;
+ }
+
+ private ComponentService getPromotedService(ComponentService componentService) {
+ Service service = componentService.getService();
+ if (service instanceof CompositeService) {
+ return getPromotedService(((CompositeService)service).getPromotedService());
+ } else {
+ return componentService;
+ }
+
+ }
+
+ /**
+ * Gets the value for the specified property with the specified type.
+ *
+ * @param type The type of the property value we are getting
+ * @param propertyName The name of the property we are getting
+ * @param B The class of the property value we are getting
+ *
+ * @throws ServiceRuntimeException If a Property for the specified propertyName
+ * is not found
+ *
+ * @see #setPropertyValueFactory(PropertyValueFactory)
+ */
+ public <B> B getProperty(Class<B> type, String propertyName) {
+ for (ComponentProperty p : component.getProperties()) {
+ if (propertyName.equals(p.getName())) {
+ return propertyFactory.createPropertyValue(p, type);
+ }
+ }
+ throw new IllegalArgumentException("Property not found: " + propertyName);
+ }
+
+ /**
+ * @param component
+ */
+ public static ComponentService getSingleService(Component component) {
+ ComponentService targetService;
+ List<ComponentService> services = component.getServices();
+ List<ComponentService> regularServices = new ArrayList<ComponentService>();
+ for (ComponentService service : services) {
+ if (service.isForCallback()) {
+ continue;
+ }
+ String name = service.getName();
+ if (!name.startsWith("$") || name.startsWith("$dynamic$")) {
+ regularServices.add(service);
+ }
+ }
+ if (regularServices.size() == 0) {
+ throw new ServiceRuntimeException("No service is declared on component " + component.getURI());
+ }
+ if (regularServices.size() != 1) {
+ throw new ServiceRuntimeException("More than one service is declared on component " + component.getURI()
+ + ". Service name is required to get the service.");
+ }
+ targetService = regularServices.get(0);
+ return targetService;
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
+ ComponentService service = getSingleService(component);
+ try {
+ return createSelfReference(businessInterface, service);
+ } catch (IllegalArgumentException iae) {
+ throw iae;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e.getMessage(), e);
+ }
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) {
+ if (serviceName == null) {
+ return createSelfReference(businessInterface);
+ }
+ try {
+ String bindingName = null;
+ int index = serviceName.indexOf('/');
+ if (index != -1) {
+ bindingName = serviceName.substring(index + 1);
+ serviceName = serviceName.substring(0, index);
+ }
+ for (ComponentService service : component.getServices()) {
+ if (serviceName.equals(service.getName())) {
+ Endpoint endpoint = getEndpoint(service, bindingName);
+ if (endpoint == null) {
+ break;
+ }
+ return getServiceReference(businessInterface, (RuntimeEndpoint)endpoint);
+ }
+ }
+ throw new IllegalArgumentException("Service not found: " + serviceName);
+ } catch (IllegalArgumentException iae) {
+ throw iae;
+ } catch (ServiceRuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * @param <B>
+ * @param businessInterface
+ * @param service
+ * @return
+ */
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, ComponentService service) {
+ try {
+ RuntimeEndpointReference ref =
+ (RuntimeEndpointReference)createEndpointReference(component, service, null, businessInterface);
+ ref.setComponent(component);
+ return getServiceReference(businessInterface, ref);
+ } catch (IllegalArgumentException iae) {
+ throw iae;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public RequestContext getRequestContext() {
+ if (requestContextFactory != null) {
+ return requestContextFactory.createRequestContext(component);
+ } else {
+ return new RequestContextImpl(component);
+ }
+ }
+
+ /**
+ * @param businessInterface
+ * @param reference
+ * @return
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
+ RuntimeEndpointReference endpointReference) {
+ ServiceReference<B> result = null;
+
+ try {
+ InterfaceContract interfaceContract = endpointReference.getComponentTypeReferenceInterfaceContract();
+ if (businessInterface == null) {
+ businessInterface = (Class<B>)((JavaInterface)interfaceContract.getInterface()).getJavaClass();
+ }
+ RuntimeComponentReference ref = (RuntimeComponentReference)endpointReference.getReference();
+ InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface);
+ if (refInterfaceContract != null) {
+ if (refInterfaceContract != interfaceContract) {
+ ref = (RuntimeComponentReference)ref.clone();
+ if (interfaceContract != null) {
+ ref.setInterfaceContract(interfaceContract);
+ } else {
+ ref.setInterfaceContract(refInterfaceContract);
+ }
+ }
+
+ ref.setComponent(component);
+ result = new ServiceReferenceImpl<B>(businessInterface, endpointReference, component.getComponentContext().getCompositeContext());
+ }
+ } catch (IllegalArgumentException iae ) {
+ throw iae;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ return result;
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, RuntimeEndpoint endpoint) {
+ try {
+ if (businessInterface == null) {
+ InterfaceContract contract = endpoint.getComponentTypeServiceInterfaceContract();
+ businessInterface = (Class<B>)((JavaInterface)contract.getInterface()).getJavaClass();
+ }
+ RuntimeEndpointReference ref =
+ (RuntimeEndpointReference)createEndpointReference(endpoint, businessInterface);
+ ref.setComponent(component);
+ return new ServiceReferenceImpl<B>(businessInterface, ref, compositeContext);
+ } catch (IllegalArgumentException iae) {
+ throw iae;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Create a self-reference for a component service
+ * @param component
+ * @param service
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ private EndpointReference createEndpointReference(Component component,
+ ComponentService service,
+ String bindingName,
+ Class<?> businessInterface) throws CloneNotSupportedException,
+ InvalidInterfaceException {
+
+ Endpoint endpoint = getEndpoint(service, bindingName);
+ return createEndpointReference(endpoint, businessInterface);
+ }
+
+ private EndpointReference createEndpointReference(Endpoint endpoint, Class<?> businessInterface)
+ throws CloneNotSupportedException, InvalidInterfaceException {
+ Component component = endpoint.getComponent();
+ ComponentService service = endpoint.getService();
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName("$self$." + service.getName());
+
+ componentReference.setCallback(service.getCallback());
+ componentReference.getTargets().add(service);
+ componentReference.getPolicySets().addAll(service.getPolicySets());
+ componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
+ componentReference.getBindings().add(endpoint.getBinding());
+
+ InterfaceContract interfaceContract = service.getInterfaceContract();
+ Service componentTypeService = service.getService();
+ if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
+ interfaceContract = componentTypeService.getInterfaceContract();
+ }
+ interfaceContract = getInterfaceContract(interfaceContract, businessInterface);
+ componentReference.setInterfaceContract(interfaceContract);
+ componentReference.setMultiplicity(Multiplicity.ONE_ONE);
+ // component.getReferences().add(componentReference);
+
+ // create endpoint reference
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setComponent(component);
+ endpointReference.setReference(componentReference);
+ endpointReference.setBinding(endpoint.getBinding());
+ endpointReference.setUnresolved(false);
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_READY_FOR_MATCHING);
+
+ endpointReference.setTargetEndpoint(endpoint);
+
+ componentReference.getEndpointReferences().add(endpointReference);
+ ((RuntimeComponentReference)componentReference).setComponent((RuntimeComponent)component);
+ ((RuntimeEndpointReference)endpointReference).bind(compositeContext);
+
+ return endpointReference;
+ }
+
+ /**
+ * @param interfaceContract
+ * @param businessInterface
+ * @return
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ private InterfaceContract getInterfaceContract(InterfaceContract interfaceContract, Class<?> businessInterface)
+ throws CloneNotSupportedException, InvalidInterfaceException {
+ if (businessInterface == null) {
+ return interfaceContract;
+ }
+ if (interfaceContract == null) {
+ JavaInterfaceContract ic = javaInterfaceFactory.createJavaInterfaceContract();
+ ic.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
+ return ic;
+ }
+ boolean compatible = false;
+ if (interfaceContract != null && interfaceContract.getInterface() != null) {
+ Interface interfaze = interfaceContract.getInterface();
+ if (interfaze instanceof JavaInterface) {
+ Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
+ if (businessInterface.isAssignableFrom(cls)) {
+ compatible = true;
+ }
+ if(!compatible) {
+ InterfaceContract biContract = javaInterfaceFactory.createJavaInterfaceContract();
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(businessInterface);
+ biContract.setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ biContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(callInterface
+ .getCallbackClass()));
+ }
+ InterfaceContractMapper ifcm = registry.getExtensionPoint(InterfaceContractMapper.class);
+ compatible = ifcm.isCompatibleSubset(biContract , interfaceContract);
+ }
+
+ }
+ }
+
+ if(!compatible) {
+ // JCA-9011
+ throw new IllegalArgumentException("Business interface " + businessInterface.getName() + " is not compatible with " + interfaceContract.getInterface().getClass().getName());
+ }
+
+ return interfaceContract;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.runtime.RuntimeComponentContext#start(org.apache.tuscany.sca.runtime.RuntimeComponentReference)
+ */
+ public void start(RuntimeComponentReference reference) {
+ compositeActivator.start(compositeContext, component, reference);
+ }
+
+ /* ******************** Contribution for issue TUSCANY-2281 ******************** */
+
+ /**
+ * @see ComponentContext#getServices(Class<B>, String)
+ */
+ public <B> Collection<B> getServices(Class<B> businessInterface, String referenceName) {
+ ArrayList<B> services = new ArrayList<B>();
+ Collection<ServiceReference<B>> serviceRefs = getServiceReferences(businessInterface, referenceName);
+ for (ServiceReference<B> serviceRef : serviceRefs) {
+ services.add(serviceRef.getService());
+ }
+ return services;
+ }
+
+ /**
+ * @see ComponentContext#getServiceReferences(Class<B>, String)
+ */
+ public <B> Collection<ServiceReference<B>> getServiceReferences(Class<B> businessInterface, String referenceName) {
+ try {
+ for (ComponentReference ref : component.getReferences()) {
+ if (referenceName.equals(ref.getName())) {
+ if ( ref.getMultiplicity() == Multiplicity.ONE_ONE )
+ throw new IllegalArgumentException("Reference " + referenceName + " is not a valid argument for getServiceReferences because it has a multiplicity of 1..1");
+ if (ref.getMultiplicity() == Multiplicity.ZERO_ONE)
+ throw new IllegalArgumentException("Reference " + referenceName + " is not a valid argument for getServiceReferences because it has a multiplicity of 0..1");
+
+ ArrayList<ServiceReference<B>> serviceRefs = new ArrayList<ServiceReference<B>>();
+ for (EndpointReference endpointReference : ref.getEndpointReferences()) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference;
+ serviceRefs.add(getServiceReference(businessInterface, epr));
+ }
+ return serviceRefs;
+ }
+ }
+ throw new IllegalArgumentException("Reference not found: " + referenceName);
+ } catch (IllegalArgumentException iae) {
+ throw iae;
+ } catch (ServiceRuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e.getMessage(), e);
+ }
+ }
+
+ /* ******************** Contribution for issue TUSCANY-2281 ******************** */
+
+ public CompositeContext getCompositeContext() {
+ return compositeContext;
+ }
+
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ return getCompositeContext().getExtensionPointRegistry();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java
new file mode 100644
index 0000000000..5d0527682e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.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.sca.core.context.impl;
+
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RequestContextImpl implements RequestContext {
+
+ public RequestContextImpl(RuntimeComponent component) {
+ }
+
+ public Subject getSecuritySubject() {
+
+ Message msgContext = ThreadMessageContext.getMessageContext();
+
+ if (msgContext == null){
+ // message in thread context could be null if the user has
+ // spun up a new thread inside their component implementation
+ return null;
+ }
+
+ Subject subject = null;
+ for (Object header : msgContext.getHeaders().values()){
+ if (header instanceof Subject){
+ subject = (Subject)header;
+ break;
+ }
+ }
+ return subject;
+ }
+
+ public String getServiceName() {
+ Message msgContext = ThreadMessageContext.getMessageContext();
+
+ if (msgContext != null){
+ return msgContext.getTo().getService().getName();
+ } else {
+ // message in thread context could be null if the user has
+ // spun up a new thread inside their component implementation
+ return null;
+ }
+ }
+
+ public <B> ServiceReference<B> getServiceReference() {
+ Message msgContext = ThreadMessageContext.getMessageContext();
+ if (msgContext == null){
+ // message in thread context could be null if the user has
+ // spun up a new thread inside their component implementation
+ return null;
+ }
+ // FIXME: [rfeng] Is this the service reference matching the caller side?
+ RuntimeEndpoint to = (RuntimeEndpoint) msgContext.getTo();
+ RuntimeComponent component = (RuntimeComponent) to.getComponent();
+
+ ServiceReference<B> callableReference = component.getComponentContext().getServiceReference(null, to);
+
+ return callableReference;
+ }
+
+ public <CB> CB getCallback() {
+ ServiceReference<CB> cb = getCallbackReference();
+ if (cb == null) {
+ return null;
+ }
+ return cb.getService();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <CB> ServiceReference<CB> getCallbackReference() {
+ Message msgContext = ThreadMessageContext.getMessageContext();
+ if (msgContext == null){
+ // message in thread context could be null if the user has
+ // spun up a new thread inside their component implementation
+ return null;
+ }
+
+ Endpoint to = msgContext.getTo();
+ RuntimeComponentService service = (RuntimeComponentService) to.getService();
+ RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
+ if (callbackReference == null) {
+ return null;
+ }
+ JavaInterface javaInterface = (JavaInterface) callbackReference.getInterfaceContract().getInterface();
+ Class<CB> javaClass = (Class<CB>)javaInterface.getJavaClass();
+ List<EndpointReference> wires = callbackReference.getEndpointReferences();
+ ServiceReferenceImpl ref = new CallbackServiceReferenceImpl(javaClass, wires);
+
+ return ref;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
new file mode 100644
index 0000000000..0cda879011
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.context.impl;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.StringWriter;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+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.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Default implementation of a ServiceReference.
+ *
+ * @version $Rev$ $Date$
+ * @param <B> the type of the business interface
+ */
+public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> {
+ private static final long serialVersionUID = 6763709434194361540L;
+
+ protected transient ProxyFactory proxyFactory;
+ protected transient Class<B> businessInterface;
+ protected transient B proxy;
+
+ protected Object callbackID; // The callbackID should be serializable
+
+ protected transient RuntimeEndpointReference endpointReference;
+
+// protected String scdl;
+//
+// private transient XMLStreamReader xmlReader;
+
+ protected transient CompositeContext compositeContext;
+ protected ExtensionPointRegistry registry;
+ protected FactoryExtensionPoint modelFactories;
+ protected RuntimeAssemblyFactory assemblyFactory;
+ protected StAXArtifactProcessorExtensionPoint staxProcessors;
+ protected StAXArtifactProcessor<EndpointReference> staxProcessor;
+ protected XMLInputFactory xmlInputFactory;
+ protected XMLOutputFactory xmlOutputFactory;
+ protected BuilderExtensionPoint builders;
+
+ /*
+ * Public constructor for Externalizable serialization/deserialization
+ */
+ public ServiceReferenceImpl() {
+ super();
+ }
+
+ public ServiceReferenceImpl(Class<B> businessInterface,
+ Invocable endpointReference,
+ CompositeContext compositeContext) {
+ this.businessInterface = businessInterface;
+ this.endpointReference = (RuntimeEndpointReference) endpointReference;
+ if (compositeContext == null) {
+ compositeContext = endpointReference.getCompositeContext();
+ }
+ bind(compositeContext);
+ }
+
+ public ServiceReferenceImpl(Class<B> businessInterface,
+ Invocable endpointReference) {
+ this(businessInterface, endpointReference, null);
+ }
+
+ protected void bind(CompositeContext context) {
+ this.compositeContext = context;
+ this.registry = compositeContext.getExtensionPointRegistry();
+ this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+ this.xmlInputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ this.xmlOutputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ this.staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ this.staxProcessor = staxProcessors.getProcessor(EndpointReference.class);
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ this.proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ }
+
+ public RuntimeEndpointReference getEndpointReference() {
+ return endpointReference;
+ }
+
+ public B getProxy() throws ObjectCreationException {
+ try {
+ if (proxy == null) {
+ proxy = createProxy();
+ }
+ return proxy;
+ } catch (Exception e) {
+ throw new ObjectCreationException(e);
+ }
+ }
+
+ public void setProxy(B proxy) {
+ this.proxy = proxy;
+ }
+
+ protected B createProxy() throws Exception {
+ return proxyFactory.createProxy(this);
+ }
+
+ public B getService() {
+ try {
+ resolve();
+ return getProxy();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public Class<B> getBusinessInterface() {
+ try {
+ resolve();
+ return businessInterface;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Follow a service promotion chain down to the inner most (non composite)
+ * component service.
+ *
+ * @param topCompositeService
+ * @return
+ */
+ private ComponentService getPromotedComponentService(CompositeService compositeService) {
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ Service service = componentService.getService();
+ if (componentService.getName() != null && service instanceof CompositeService) {
+
+ // Continue to follow the service promotion chain
+ return getPromotedComponentService((CompositeService)service);
+
+ } else {
+
+ // Found a non-composite service
+ return componentService;
+ }
+ } else {
+
+ // No promoted service
+ return null;
+ }
+ }
+
+ // ============ WRITE AND READ THE REFERENCE TO EXTERNAL XML ========================
+
+ /**
+ * write the reference to a stream
+ *
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(endpointReference);
+ /*
+ try {
+ String xml = null;
+ if (scdl == null) {
+ xml = toXMLString();
+ } else {
+ xml = scdl;
+ }
+
+ if (xml == null) {
+ out.writeBoolean(false);
+ } else {
+ out.writeBoolean(true);
+ out.writeUTF(xml);
+ }
+ } catch (Exception e) {
+ // e.printStackTrace();
+ throw new IOException(e.toString());
+ }
+ */
+ }
+
+ /**
+ * write the endpoint reference into an xml string
+ */
+ public String toXMLString() throws IOException, XMLStreamException, ContributionWriteException {
+ StringWriter writer = new StringWriter();
+ XMLStreamWriter streamWriter = xmlOutputFactory.createXMLStreamWriter(writer);
+ staxProcessor.write(endpointReference, streamWriter, new ProcessorContext(registry));
+ return writer.toString();
+ }
+
+ /**
+ * Read the reference from a stream
+ *
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.endpointReference = (RuntimeEndpointReference) in.readObject();
+ // Force resolve
+ endpointReference.getComponent();
+ bind(endpointReference.getCompositeContext());
+
+ RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
+ reference.setComponent((RuntimeComponent)endpointReference.getComponent());
+
+ Interface i = reference.getInterfaceContract().getInterface();
+ if (i instanceof JavaInterface) {
+ JavaInterface javaInterface = (JavaInterface)i;
+ if (javaInterface.isUnresolved()) {
+ // Allow privileged access to get ClassLoader. Requires RuntimePermission in
+ // security policy.
+ ClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+
+ javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName()));
+ JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeContext);
+
+ try {
+ javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass());
+ } catch (InvalidInterfaceException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ //FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO),
+ // this needs to be done here. We usually search for XSDs in the current
+ // contribution at resolve time. Is it possible to locate the current
+ // contribution at runtime?
+ }
+ this.businessInterface = (Class<B>)javaInterface.getJavaClass();
+ }
+
+ Binding binding = endpointReference.getBinding();
+ if (binding != null) {
+ BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getType());
+ if (bindingBuilder != null) {
+ org.apache.tuscany.sca.assembly.builder.BuilderContext context = new BuilderContext(registry);
+ bindingBuilder.build(endpointReference.getComponent(), reference, endpointReference.getBinding(), context, false);
+ }
+ }
+
+ this.proxyFactory = getProxyFactory(this.compositeContext);
+
+ /*
+ endpointReference.bind(CompositeContext.getCurrentCompositeContext());
+ endpointReference.rebuild();
+ */
+ /*
+ final boolean hasSCDL = in.readBoolean();
+ if (hasSCDL) {
+ this.scdl = in.readUTF();
+ } else {
+ this.scdl = null;
+ }
+ */
+ }
+
+ /**
+ * Read xml string into the endpoint reference
+ */
+ /*
+ public void fromXMLString() throws IOException, XMLStreamException, ContributionReadException {
+
+ XMLStreamReader streamReader = xmlReader;
+
+ if (scdl != null) {
+ Reader reader = new StringReader(scdl);
+
+ if (xmlInputFactory == null) {
+ // this is a reference being read from a external stream
+ // so set up enough of the reference in order to resolved the
+ // xml being read
+ bind(CompositeContext.getCurrentCompositeContext());
+ }
+
+ streamReader = xmlInputFactory.createXMLStreamReader(reader);
+ }
+
+ endpointReference = (RuntimeEndpointReference) staxProcessor.read(streamReader, new ProcessorContext(registry));
+
+ // ok to GC
+ xmlReader = null;
+ scdl = null;
+ }
+ */
+
+ /**
+ * @throws IOException
+ */
+ private synchronized void resolve() throws Exception {
+ /*
+ if ((scdl != null || xmlReader != null) && endpointReference == null) {
+ fromXMLString();
+
+ compositeContext.bindComponent((RuntimeComponent) endpointReference.getComponent());
+
+ RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
+ reference.setComponent((RuntimeComponent)endpointReference.getComponent());
+
+ ReferenceParameters parameters = null;
+ for (Object ext : reference.getExtensions()) {
+ if (ext instanceof ReferenceParameters) {
+ parameters = (ReferenceParameters)ext;
+ break;
+ }
+ }
+
+ if (parameters != null) {
+ this.callbackID = parameters.getCallbackID();
+ }
+
+ Interface i = reference.getInterfaceContract().getInterface();
+ if (i instanceof JavaInterface) {
+ JavaInterface javaInterface = (JavaInterface)i;
+ if (javaInterface.isUnresolved()) {
+ // Allow privileged access to get ClassLoader. Requires RuntimePermission in
+ // security policy.
+ ClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+
+ javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName()));
+ JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeContext);
+
+ javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass());
+ //FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO),
+ // this needs to be done here. We usually search for XSDs in the current
+ // contribution at resolve time. Is it possible to locate the current
+ // contribution at runtime?
+ }
+ this.businessInterface = (Class<B>)javaInterface.getJavaClass();
+ }
+
+ Binding binding = endpointReference.getBinding();
+ if (binding != null) {
+ BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getType());
+ if (bindingBuilder != null) {
+ BuilderContext context = new BuilderContext(registry);
+ bindingBuilder.build(endpointReference.getComponent(), reference, endpointReference.getBinding(), context);
+ }
+ }
+
+ this.proxyFactory = getProxyFactory(this.compositeContext);
+ } else if (compositeContext == null) {
+ this.compositeContext = CompositeContext.getCurrentCompositeContext();
+ if (this.compositeContext != null) {
+ this.proxyFactory = getProxyFactory(this.compositeContext);
+ }
+ }
+ */
+ }
+
+ private JavaInterfaceFactory getJavaInterfaceFactory(CompositeContext compositeContext) {
+ ExtensionPointRegistry extensionPointRegistry = compositeContext.getExtensionPointRegistry();
+ FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ return javaInterfaceFactory;
+ }
+
+ private ProxyFactory getProxyFactory(CompositeContext compositeContext) {
+ ExtensionPointRegistry extensionPointRegistry = compositeContext.getExtensionPointRegistry();
+ return ExtensibleProxyFactory.getInstance(extensionPointRegistry);
+ }
+
+ // ==================================================================================
+
+ /*
+ public XMLStreamReader getXMLReader() {
+ return xmlReader;
+ }
+ */
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java
new file mode 100644
index 0000000000..4b563b0079
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.factory;
+
+import org.apache.tuscany.sca.core.scope.TargetDestructionException;
+import org.apache.tuscany.sca.core.scope.TargetInitializationException;
+
+
+/**
+ * Provides lifecycle management for an implementation instance associated with
+ * a component for use by the component's associated {@link org.apache.tuscany.sca.core.scope.ScopeContainer}
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface InstanceWrapper<T> {
+
+ /**
+ * @return
+ */
+ T getInstance();
+
+ /**
+ * @throws TargetInitializationException
+ */
+ void start() throws TargetInitializationException;
+
+ /**
+ * @throws TargetDestructionException
+ */
+ void stop() throws TargetDestructionException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java
new file mode 100644
index 0000000000..820faf6259
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.factory;
+
+
+/**
+ * Denotes an error creating a new object instance
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ObjectCreationException extends RuntimeException {
+ private static final long serialVersionUID = -6423113430265944499L;
+
+ public ObjectCreationException() {
+ super();
+ }
+
+ public ObjectCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ObjectCreationException(String message) {
+ super(message);
+ }
+
+ public ObjectCreationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java
new file mode 100644
index 0000000000..db10b6cff2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.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 org.apache.tuscany.sca.core.factory;
+
+/**
+ * Implementations create new instances of a particular type
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ObjectFactory<T> {
+
+ /**
+ * Return a instance of the type that this factory creates.
+ *
+ * @return a instance from this factory
+ */
+ T getInstance() throws ObjectCreationException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncFaultWrapper.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncFaultWrapper.java
new file mode 100644
index 0000000000..3d98de9e21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncFaultWrapper.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.invocation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * A class which is used to wrap an Exception of any type thrown by an asynchronous service operation and
+ * which is returned through a separate one-way message sent asynchronously from the server to the client.
+ *
+ */
+public class AsyncFaultWrapper {
+
+ private String faultClassName = null;
+ private String faultMessage = null;
+ private AsyncFaultWrapper containedFault = null;
+
+
+ public AsyncFaultWrapper() {
+ super();
+ }
+
+ /**
+ * Constructor which creates an AsyncFaultWrapper which wraps the supplied Throwable
+ * @param e - a Throwable which is wrapped by this AsyncFaultWrapper
+ */
+ public AsyncFaultWrapper( Throwable e ) {
+ super();
+ storeFault( e );
+ }
+
+ /**
+ * Stores a given Throwable in this AsyncFaultWrapper
+ * If the supplied Throwable itself contains an embedded Throwable ("cause"), this is recursively
+ * wrapped by a nested AsyncFaultWrapper
+ * @param e - the Throwable
+ */
+ public void storeFault( Throwable e ) {
+ setFaultClassName( e.getClass().getCanonicalName() );
+ setFaultMessage( e.getMessage() );
+ Throwable cause = e.getCause();
+ if( cause != null ) setContainedFault( new AsyncFaultWrapper( cause ) );
+ }
+
+ /**
+ * Retrieves the Throwable wrapped by this AsyncFaultWrapper
+ *
+ * Note: When this method is invoked, the method attempts to instantiate an instance of the wrapped Throwable.
+ * It does this using the Thread Context Class Loader (TCCL) - the caller *MUST* ensure that the TCCL has access
+ * to the class of the wrapped Throwable and also to the classes of any nested Throwables. If this is not done,
+ * a ClassNotFound exception is thrown
+ *
+ * @return - the Throwable wrapped by this AsyncFaultWrapper - the Throwable will contain any nested Throwable(s)
+ * in its cause property
+ * @throws ClassNotFound exception, if the class of the wrapped Throwable is not accessible from the TCCL
+ */
+ public Throwable retrieveFault( ) {
+ try {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ Class<?> faultClass = tccl.loadClass(faultClassName);
+ Class<Throwable> xclass = (Class<Throwable>) faultClass;
+ if( containedFault != null ) {
+ // If there is a nested fault, retrieve this recursively
+ Constructor cons = xclass.getConstructor(String.class, Throwable.class);
+ return (Throwable) cons.newInstance(faultMessage, getContainedFault().retrieveFault());
+ } else {
+ Constructor cons = xclass.getConstructor(String.class);
+ return (Throwable) cons.newInstance(faultMessage);
+ } // end if
+ } catch (Exception e) {
+ return e;
+ } // end try
+ } // end method retrieveFault
+
+ public void setFaultClassName( String name ) { this.faultClassName = name; }
+ public String getFaultClassName() { return this.faultClassName; }
+
+ public String getFaultMessage() { return faultMessage; }
+ public void setFaultMessage(String faultMessage) { this.faultMessage = faultMessage; }
+
+ public AsyncFaultWrapper getContainedFault() { return containedFault; }
+ public void setContainedFault(AsyncFaultWrapper containedFault) { this.containedFault = containedFault; }
+
+} // end class AsyncFaultWrapper
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseException.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseException.java
new file mode 100644
index 0000000000..df90c3286d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseException.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.sca.core.invocation;
+
+/**
+ * An exception which is used to signal that a service has been invoked asynchronously
+ * and that the result will be sent separately
+ *
+ */
+public class AsyncResponseException extends RuntimeException {
+
+ private static final long serialVersionUID = 457954562860541631L;
+
+ public AsyncResponseException() {
+ super();
+ }
+
+ public AsyncResponseException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ public AsyncResponseException(String arg0) {
+ super(arg0);
+ }
+
+ public AsyncResponseException(Throwable arg0) {
+ super(arg0);
+ }
+
+} // end class AsyncResponseException
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseHandler.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseHandler.java
new file mode 100644
index 0000000000..d8eac8a166
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseHandler.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation;
+
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * An interface which describes a general response pattern for the asynchronous invocation of a service
+ *
+ * @param <V> - the type of the non-fault response
+ */
+@Remotable()
+public interface AsyncResponseHandler<V> {
+
+ /**
+ * Async process completed with a Fault. Must only be invoked once
+ * @param e - the wrapper containing the Fault to send
+ * @throws IllegalStateException if either the setResponse method or the setFault method have been called previously
+ */
+ @OneWay
+ public void setFault(AsyncFaultWrapper e);
+
+ /**
+ * Async process completed with a response message. Must only be invoked once
+ * @throws IllegalStateException if either the setResponse method or the setFault method have been called previously
+ * @param res - the response message, which is of type V
+ */
+ @OneWay
+ public void setResponse(V res);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java
new file mode 100644
index 0000000000..400bb333fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Uses a wire to return a CallableReference
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class CallableReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> {
+ private Class<?> businessInterface;
+ private RuntimeEndpointReference endpointReference;
+
+ /**
+ * Constructor.
+ *
+ * To support the @Reference protected CallableReference<MyService> ref;
+ *
+ * @param businessInterface the interface to inject
+ * @param component the component defining the reference to be injected
+ * @param reference the reference to be injected
+ * @param binding the binding for the reference
+ */
+ public CallableReferenceObjectFactory(Class<?> businessInterface,
+ RuntimeEndpointReference endpointReference) {
+ this.businessInterface = businessInterface;
+ this.endpointReference = endpointReference;
+ }
+
+ public ServiceReference<?> getInstance() throws ObjectCreationException {
+ RuntimeComponent component = (RuntimeComponent) endpointReference.getComponent();
+ return component.getComponentContext().getServiceReference(businessInterface, endpointReference);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java
new file mode 100644
index 0000000000..588eaa2d15
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.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.core.invocation;
+
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * An interceptor applied to the forward direction of a wire that ensures the callback target implements the required
+ * service contract. This is required as callback targets may be set dynamically by service implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallbackInterfaceInterceptor implements Interceptor {
+ private Invoker next;
+
+ public CallbackInterfaceInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+
+ /* TODO - EPR - not required for OASIS
+ ReferenceParameters parameters = msg.getFrom().getReferenceParameters();
+ if (parameters.getCallbackObjectID() != null || parameters.getCallbackReference() != msg.getFrom()
+ .getCallbackEndpoint()) {
+ */
+ return next.invoke(msg);
+ /*
+ } else {
+ throw new NoRegisteredCallbackException("Callback target does not implement the callback interface");
+ }
+ */
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java
new file mode 100644
index 0000000000..a56983a5d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.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.core.invocation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Uses a wire to return a CallableReference
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class CallbackReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> {
+ private Class<?> businessInterface;
+ private ProxyFactory proxyFactory;
+ private List<EndpointReference> wires;
+
+ public CallbackReferenceObjectFactory(Class<?> interfaze, ProxyFactory proxyFactory, List<EndpointReference> wires) {
+ this.businessInterface = interfaze;
+ this.proxyFactory = proxyFactory;
+ this.wires = wires;
+ }
+
+ public ServiceReference<?> getInstance() throws ObjectCreationException {
+ return new CallbackServiceReferenceImpl(businessInterface, wires);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
new file mode 100644
index 0000000000..fff3727d87
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.invocation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+
+/**
+ * Returns proxy instance for a wire callback
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class CallbackWireObjectFactory<B> implements ObjectFactory<B> {
+ private Class<B> businessInterface;
+ private ProxyFactory proxyFactory;
+ private List<Invocable> wires;
+
+ public CallbackWireObjectFactory(Class<B> interfaze, ProxyFactory proxyFactory, List<Invocable> wires) {
+ this.businessInterface = interfaze;
+ this.proxyFactory = proxyFactory;
+ this.wires = wires;
+ }
+
+ public B getInstance() throws ObjectCreationException {
+ return proxyFactory.createCallbackProxy(businessInterface, wires);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
new file mode 100644
index 0000000000..cb2c01f7d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.Factory;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
+import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
+import org.apache.tuscany.sca.core.invocation.impl.JDKCallbackInvocationHandler;
+import org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * The implementation of a wire service that uses cglib dynamic proxies
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class CglibProxyFactory implements ProxyFactory {
+ private MessageFactory messageFactory;
+
+ public CglibProxyFactory(MessageFactory messageFactory, InterfaceContractMapper mapper) {
+ this.messageFactory = messageFactory;
+
+ }
+
+ public <T> T createProxy(final Class<T> interfaze, Invocable invocable) throws ProxyCreationException {
+ if (invocable instanceof RuntimeEndpoint) {
+ Enhancer enhancer = new Enhancer();
+ enhancer.setSuperclass(interfaze);
+ enhancer.setCallback(new CglibMethodInterceptor<T>(interfaze, invocable));
+ Object proxy = enhancer.create();
+ return interfaze.cast(proxy);
+ }
+ ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, invocable, null);
+ return createProxy(serviceReference);
+ }
+
+ /**
+ * create the proxy with cglib. use the same JDKInvocationHandler as
+ * JDKProxyService.
+ */
+ public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException {
+ Enhancer enhancer = new Enhancer();
+ Class<T> interfaze = callableReference.getBusinessInterface();
+ enhancer.setSuperclass(interfaze);
+ enhancer.setCallback(new CglibMethodInterceptor<T>(callableReference));
+ Object proxy = enhancer.create();
+ ((ServiceReferenceImpl)callableReference).setProxy(proxy);
+ return interfaze.cast(proxy);
+ }
+
+ /**
+ * create the callback proxy with cglib. use the same
+ * JDKCallbackInvocationHandler as JDKProxyService.
+ */
+ public <T> T createCallbackProxy(Class<T> interfaze, final List<? extends Invocable> wires) throws ProxyCreationException {
+ ServiceReferenceImpl<T> callbackReference = new ServiceReferenceImpl(interfaze, wires.get(0), null);
+ return callbackReference != null ? createCallbackProxy(callbackReference) : null;
+ }
+
+ /**
+ * create the callback proxy with cglib. use the same
+ * JDKCallbackInvocationHandler as JDKProxyService.
+ */
+ public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
+ Enhancer enhancer = new Enhancer();
+ Class<T> interfaze = callbackReference.getBusinessInterface();
+ enhancer.setSuperclass(interfaze);
+ enhancer.setCallback(new CglibMethodInterceptor<T>(callbackReference));
+ Object object = enhancer.create();
+ T proxy = interfaze.cast(object);
+ ((ServiceReferenceExt<T>)callbackReference).setProxy(proxy);
+ return proxy;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
+ if (isProxyClass(target.getClass())) {
+ Factory factory = (Factory)target;
+ Callback[] callbacks = factory.getCallbacks();
+ if (callbacks.length != 1 || !(callbacks[0] instanceof CglibMethodInterceptor)) {
+ throw new IllegalArgumentException("The object is not a known proxy.");
+ }
+ CglibMethodInterceptor interceptor = (CglibMethodInterceptor)callbacks[0];
+ return (R)interceptor.invocationHandler.getCallableReference();
+ } else {
+ throw new IllegalArgumentException("The object is not a known proxy.");
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#isProxyClass(java.lang.Class)
+ */
+ public boolean isProxyClass(Class<?> clazz) {
+ return Factory.class.isAssignableFrom(clazz);
+ }
+
+ private class CglibMethodInterceptor<T> implements MethodInterceptor {
+ private JDKInvocationHandler invocationHandler;
+
+ public CglibMethodInterceptor(ServiceReference<T> callableReference) {
+ invocationHandler = new JDKInvocationHandler(messageFactory, callableReference);
+ }
+
+ public CglibMethodInterceptor(Class<?> interfaze, Invocable invocable) {
+ invocationHandler = new JDKInvocationHandler(messageFactory, interfaze, invocable);
+ }
+
+ public CglibMethodInterceptor(ServiceReferenceImpl<T> callbackReference) {
+ invocationHandler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
+ }
+
+ /**
+ * @see net.sf.cglib.proxy.MethodInterceptor#intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], net.sf.cglib.proxy.MethodProxy)
+ */
+ public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
+ Object result = invocationHandler.invoke(proxy, method, args);
+ return result;
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java
new file mode 100644
index 0000000000..af6f039775
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.invocation;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.impl.JDKProxyFactory;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+/**
+ * Default implementation of a ProxyFactoryExtensionPoint.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultProxyFactoryExtensionPoint implements ProxyFactoryExtensionPoint, LifeCycleListener {
+ private InterfaceContractMapper interfaceContractMapper;
+ private MessageFactory messageFactory;
+
+ private ProxyFactory interfaceFactory;
+ private ProxyFactory classFactory;
+
+ public DefaultProxyFactoryExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+
+ interfaceFactory = new JDKProxyFactory(messageFactory, interfaceContractMapper);
+ }
+
+ public DefaultProxyFactoryExtensionPoint(MessageFactory messageFactory, InterfaceContractMapper mapper) {
+ this.interfaceContractMapper = mapper;
+ this.messageFactory = messageFactory;
+ interfaceFactory = new JDKProxyFactory(messageFactory, mapper);
+ }
+
+ public ProxyFactory getClassProxyFactory() {
+ return classFactory;
+ }
+
+ public ProxyFactory getInterfaceProxyFactory() {
+ return interfaceFactory;
+ }
+
+ public void setClassProxyFactory(ProxyFactory factory) {
+ this.classFactory = factory;
+
+ }
+
+ public void setInterfaceProxyFactory(ProxyFactory factory) {
+ this.interfaceFactory = factory;
+
+ }
+
+ public void start() {
+ if (interfaceFactory instanceof LifeCycleListener) {
+ ((LifeCycleListener)interfaceFactory).start();
+ }
+ if (classFactory instanceof LifeCycleListener) {
+ ((LifeCycleListener)classFactory).start();
+ }
+ }
+
+ public void stop() {
+ if (interfaceFactory instanceof LifeCycleListener) {
+ ((LifeCycleListener)interfaceFactory).stop();
+ }
+ if (classFactory instanceof LifeCycleListener) {
+ ((LifeCycleListener)classFactory).stop();
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java
new file mode 100644
index 0000000000..049c73f258
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * An extensible proxy factory.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class ExtensibleProxyFactory implements ProxyFactory {
+
+ private ProxyFactoryExtensionPoint proxyFactories;
+
+ public ExtensibleProxyFactory(ProxyFactoryExtensionPoint proxyFactories) {
+ this.proxyFactories = proxyFactories;
+ }
+
+ public ExtensibleProxyFactory(ExtensionPointRegistry registry) {
+ this.proxyFactories = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ }
+
+ public static ExtensibleProxyFactory getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilities.getUtility(ExtensibleProxyFactory.class);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#cast(java.lang.Object)
+ */
+ @SuppressWarnings("unchecked")
+ public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
+ ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
+ ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
+ if (interfaceFactory.isProxyClass(target.getClass())) {
+ return (R)interfaceFactory.cast(target);
+ } else if (classFactory != null && classFactory.isProxyClass(target.getClass())) {
+ return (R)classFactory.cast(target);
+ } else {
+ throw new IllegalArgumentException("The target is not a callable proxy");
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createCallbackProxy(java.lang.Class,
+ * java.util.List)
+ */
+ public <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> wires) throws ProxyCreationException {
+ ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
+ ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
+ if (interfaze.isInterface()) {
+ return interfaceFactory.createCallbackProxy(interfaze, wires);
+ } else {
+ return classFactory.createCallbackProxy(interfaze, wires);
+ }
+ }
+
+ public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException {
+ ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
+ ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
+ if (callableReference.getBusinessInterface().isInterface()) {
+ return interfaceFactory.createProxy(callableReference);
+ } else {
+ return classFactory.createProxy(callableReference);
+ }
+ }
+
+ public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
+ ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
+ ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
+ if (callbackReference.getBusinessInterface().isInterface()) {
+ return interfaceFactory.createCallbackProxy(callbackReference);
+ } else {
+ return classFactory.createCallbackProxy(callbackReference);
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createProxy(java.lang.Class,
+ * org.apache.tuscany.sca.runtime.Invocable)
+ */
+ public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException {
+ ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
+ ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
+ if (interfaze.isInterface()) {
+ return interfaceFactory.createProxy(interfaze, wire);
+ } else {
+ return classFactory.createProxy(interfaze, wire);
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#isProxyClass(java.lang.Class)
+ */
+ public boolean isProxyClass(Class<?> clazz) {
+ ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
+ ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
+ return interfaceFactory.isProxyClass(clazz) || (classFactory != null && classFactory.isProxyClass(clazz));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java
new file mode 100644
index 0000000000..08019ec3e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation;
+
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
+
+/**
+ * The default implementation of an extensible <code>WireProcessor</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleWireProcessor implements RuntimeWireProcessor {
+
+ private RuntimeWireProcessorExtensionPoint processors;
+
+ public ExtensibleWireProcessor(RuntimeWireProcessorExtensionPoint processors) {
+ this.processors = processors;
+ }
+
+ public void process(RuntimeEndpoint endpoint) {
+ for (RuntimeWireProcessor processor : processors.getWireProcessors()) {
+ processor.process(endpoint);
+ }
+ }
+
+ public void process(RuntimeEndpointReference endpointReference) {
+ for (RuntimeWireProcessor processor : processors.getWireProcessors()) {
+ processor.process(endpointReference);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
new file mode 100644
index 0000000000..a31a126977
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation;
+
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Adds non-blocking behavior to an invocation chain
+ *
+ * @version $Rev$ $Date$
+ */
+public class NonBlockingInterceptor implements Interceptor {
+
+ private static final Message RESPONSE = new ImmutableMessage();
+
+ /**
+ * The JDK logger that will be used to log messages.
+ */
+ private static final Logger LOGGER = Logger.getLogger(NonBlockingInterceptor.class.getName());
+
+ private WorkScheduler workScheduler;
+ private Invoker next;
+
+ public NonBlockingInterceptor(WorkScheduler workScheduler) {
+ this.workScheduler = workScheduler;
+ }
+
+ public NonBlockingInterceptor(WorkScheduler workScheduler, Interceptor next) {
+ this.workScheduler = workScheduler;
+ this.next = next;
+ }
+
+ /**
+ * Sets desired workScheduler to NonBlockingInterceptor. This is a useful function for the extension framework
+ * to set desired workmanager on the InvocationChain, other than default workmanager which is set per Tuscany runtime.
+ * Using this function, extension framework can set desired workmanager on InvocationChain during post wire processing.
+ * @param workScheduler workScheduler which contains workmanager
+ */
+ public void setWorkScheduler(WorkScheduler workScheduler){
+ this.workScheduler = workScheduler;
+ }
+
+ public Message invoke(final Message msg) {
+ // Schedule the invocation of the next interceptor in a new Work instance
+ try {
+ workScheduler.scheduleWork(new Runnable() {
+ public void run() {
+ Message context = ThreadMessageContext.setMessageContext(msg);
+ try {
+ Message response = null;
+
+ Throwable ex = null;
+ try {
+ response = next.invoke(msg);
+ } catch (Throwable t) {
+ ex = t;
+ }
+
+ // Tuscany-2225 - Did the @OneWay method complete successfully?
+ // (i.e. no exceptions)
+ if (response != null && response.isFault()) {
+ // The @OneWay method threw an Exception. Lets log it and
+ // then pass it on to the WorkScheduler so it can notify any
+ // listeners
+ ex = (Throwable)response.getBody();
+ }
+ if (ex != null) {
+ LOGGER.log(Level.SEVERE, "Exception from @OneWay invocation", ex);
+ throw new ServiceRuntimeException("Exception from @OneWay invocation", ex);
+ }
+ } finally {
+ ThreadMessageContext.setMessageContext(context);
+ }
+ }
+ });
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return RESPONSE;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ /**
+ * A dummy message passed back on an invocation
+ */
+ private static class ImmutableMessage implements Message {
+
+ public <T> T getBody() {
+ return null;
+ }
+
+ public void setBody(Object body) {
+ if (body != null) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public Object getMessageID() {
+ return null;
+ }
+
+ public void setMessageID(Object messageId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isFault() {
+ return false;
+ }
+
+ public void setFaultBody(Object fault) {
+ throw new UnsupportedOperationException();
+ }
+
+ public EndpointReference getFrom() {
+ return null;
+ }
+
+ public Endpoint getTo() {
+ return null;
+ }
+
+ public void setFrom(EndpointReference from) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setTo(Endpoint to) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Operation getOperation() {
+ return null;
+ }
+
+ public void setOperation(Operation op) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<String, Object> getHeaders() {
+ return null;
+ }
+ public <T> T getBindingContext() {
+ return null;
+ }
+
+ public <T> void setBindingContext(T bindingContext) {
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java
new file mode 100644
index 0000000000..0b36b178f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.invocation;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+
+
+/**
+ * Denotes an error creating a proxy
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProxyCreationException extends ObjectCreationException {
+ private static final long serialVersionUID = 8002454344828513781L;
+
+ public ProxyCreationException() {
+ super();
+ }
+
+ public ProxyCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProxyCreationException(String message) {
+ super(message);
+ }
+
+ public ProxyCreationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java
new file mode 100644
index 0000000000..f2d272757d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.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.core.invocation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Creates proxies that implement Java interfaces and invocation handlers for fronting wires
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+
+public interface ProxyFactory {
+
+ /**
+ * Creates a Java proxy for the given wire
+ *
+ * @param interfaze the interface the proxy implements
+ * @param invocable the wire to proxy
+ * @return the proxy
+ * @throws ProxyCreationException
+ */
+ <T> T createProxy(Class<T> interfaze, Invocable invocable) throws ProxyCreationException;
+
+ /**
+ * Creates a Java proxy for the given CallableReference
+ *
+ * @param callableReference The CallableReference
+ * @return the proxy
+ * @throws ProxyCreationException
+ */
+ <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException;
+
+ /**
+ * Creates a Java proxy for the service contract callback
+ *
+ * @param interfaze the interface the proxy should implement
+ * @return the proxy
+ * @throws ProxyCreationException
+ */
+ <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> invocables) throws ProxyCreationException;
+
+ /**
+ * Creates a Java proxy for the given callback reference
+ *
+ * @param callableReference The CallableReference
+ * @return the proxy
+ * @throws ProxyCreationException
+ */
+ <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException;
+
+ /**
+ * Cast a proxy to a CallableReference.
+ *
+ * @param target a proxy generated by this implementation
+ * @return a CallableReference (or subclass) equivalent to this proxy
+ * @throws IllegalArgumentException if the object supplied is not a proxy
+ */
+ <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException;
+
+ /**
+ * Test if a given class is a generated proxy class by this factory
+ * @param clazz A java class or interface
+ * @return true if the class is a generated proxy class by this factory
+ */
+ boolean isProxyClass(Class<?> clazz);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java
new file mode 100644
index 0000000000..3e0bd7cb17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.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.sca.core.invocation;
+
+
+/**
+ * The extension point to plug in proxy factories
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ProxyFactoryExtensionPoint {
+
+ /**
+ * Get the proxy factory for java interfaces
+ * @return
+ */
+ ProxyFactory getInterfaceProxyFactory();
+
+ /**
+ * Get the proxy factory for java classes
+ * @return
+ */
+ ProxyFactory getClassProxyFactory();
+
+ /**
+ * Set the proxy factory for java interfaces
+ * @param factory
+ */
+ void setInterfaceProxyFactory(ProxyFactory factory);
+
+ /**
+ * Set the proxy factory for java classes
+ * @param factory
+ */
+ void setClassProxyFactory(ProxyFactory factory);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
new file mode 100644
index 0000000000..0751fd631b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+
+/**
+ * Invoker for a endpoint or endpoint reference
+ * @version $Rev$ $Date$
+ */
+public class RuntimeInvoker implements Invoker {
+ protected MessageFactory messageFactory;
+ protected Invocable invocable;
+
+ public RuntimeInvoker(MessageFactory messageFactory, Invocable invocable) {
+ this.messageFactory = messageFactory;
+ this.invocable = invocable;
+ }
+
+ public Message invokeBinding(Message msg) {
+ Message context = ThreadMessageContext.setMessageContext(msg);
+ try {
+ return invocable.getBindingInvocationChain().getHeadInvoker().invoke(msg);
+ } finally {
+ ThreadMessageContext.setMessageContext(context);
+ }
+ }
+
+ public Message invoke(Message msg) {
+ return invoke(msg.getOperation(), msg);
+ }
+
+ public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
+ Message msg = messageFactory.createMessage();
+ msg.setBody(args);
+ Message resp = invoke(operation, msg);
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw new InvocationTargetException((Throwable)body);
+ }
+ return body;
+ }
+
+
+ public Message invoke(Operation operation, Message msg) {
+ InvocationChain chain = invocable.getInvocationChain(operation);
+ return invoke(chain, msg);
+ }
+
+ public Message invoke(InvocationChain chain, Message msg) {
+
+ if (invocable instanceof Endpoint) {
+ msg.setTo((Endpoint)invocable);
+ } else if (invocable instanceof EndpointReference) {
+ msg.setFrom((EndpointReference)invocable);
+ }
+
+ Invoker headInvoker = chain.getHeadInvoker();
+ Operation operation = chain.getTargetOperation();
+ msg.setOperation(operation);
+
+ Message msgContext = ThreadMessageContext.setMessageContext(msg);
+ try {
+ return headInvoker.invoke(msg);
+ } finally {
+ ThreadMessageContext.setMessageContext(msgContext);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java
new file mode 100644
index 0000000000..489d06a3e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.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 org.apache.tuscany.sca.core.invocation;
+
+import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.impl.NoMethodForOperationException;
+import org.apache.tuscany.sca.runtime.Invocable;
+
+/**
+ * Uses a wire to return an object instance
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class WireObjectFactory<T> implements ObjectFactory<T> {
+ private Class<T> interfaze;
+ private Invocable wire;
+ private ProxyFactory proxyService;
+
+ /**
+ * Constructor.
+ *
+ * @param interfaze the interface to inject on the client
+ * @param wire the backing wire
+ * @param proxyService the wire service to create the proxy
+ * @throws NoMethodForOperationException
+ */
+ public WireObjectFactory(Class<T> interfaze, Invocable wire, ProxyFactory proxyService) {
+ this.interfaze = interfaze;
+ this.wire = wire;
+ this.proxyService = proxyService;
+ }
+
+ public T getInstance() throws ObjectCreationException {
+ return new ServiceReferenceImpl<T>(interfaze, wire, null).getProxy();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java
new file mode 100644
index 0000000000..8db469b25e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import javax.xml.ws.Response;
+
+import org.apache.tuscany.sca.core.invocation.AsyncFaultWrapper;
+import org.apache.tuscany.sca.core.invocation.AsyncResponseHandler;
+
+/**
+ * A class which provides an Implementation of a Future<V> and Response<V> for use with the JAXWS defined client
+ * asynchronous APIs.
+ *
+ * This implementation class provides the interfaces for use by the client code, but also provides methods for the
+ * Tuscany system code to set the result of the asynchronous service invocation, both Regular and Fault responses.
+ *
+ * This class is constructed to be fully thread-safe
+ *
+ * @param <V> - this is the type of the response message from the invoked service.
+ */
+public class AsyncInvocationFutureImpl<V> implements Future<V>, Response<V>, AsyncResponseHandler<V> {
+
+ // Lock for handling the completion of this Future
+ private final Lock lock = new ReentrantLock();
+ private final Condition isDone = lock.newCondition();
+
+ // The result
+ private volatile V response = null;
+ private volatile Throwable fault = null;
+
+ private String uniqueID = UUID.randomUUID().toString();
+
+ private ClassLoader classLoader = null;
+
+ protected AsyncInvocationFutureImpl() {
+ super();
+ } // end constructor
+
+ /**
+ * Public constructor for AsyncInvocationFutureImpl - newInstance is necessary in order to enable the Type variable
+ * to be set for the class instances
+ * @param <V> - the type of the response from the asynchronously invoked service
+ * @param type - the type of the AsyncInvocationFutureImpl expressed as a parameter
+ * @param classLoader - the classloader used for the business interface to which this Future applies
+ * @return - an instance of AsyncInvocationFutureImpl<V>
+ */
+ public static <V> AsyncInvocationFutureImpl<V> newInstance( Class<V> type, ClassLoader classLoader ) {
+ AsyncInvocationFutureImpl<V> future = new AsyncInvocationFutureImpl<V>();
+ future.setClassLoader( classLoader );
+ return future;
+ }
+
+ /**
+ * Cancels the asynchronous process
+ * - not possible in this version, so always returns false
+ */
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ return false;
+ }
+
+ /**
+ * Gets the response value returned by the asynchronous process
+ * - waits forever
+ * @return - the response value of type V
+ * @throws InterruptedException if the get() method was interrupted while waiting for the async process to finish
+ * @throws ExecutionException if the async process threw an exception - the exception thrown is nested
+ */
+ public V get() throws InterruptedException, ExecutionException {
+ try {
+ V response = get(Long.MAX_VALUE, TimeUnit.SECONDS);
+ return response;
+ } catch (TimeoutException t) {
+ throw new InterruptedException("Timed out waiting for Future to complete");
+ } // end try
+ } // end method get()
+
+ /**
+ * Gets the response value returned by the asynchronous process
+ * @return - the response value of type V
+ * @throws InterruptedException if the get() method was interrupted while waiting for the async process to finish
+ * @throws ExecutionException if the async process threw an exception - the exception thrown is nested
+ * @throws TimeoutException if the get() method timed out waiting for the async process to finish
+ */
+ public V get(long timeout, TimeUnit unit) throws InterruptedException,
+ ExecutionException, TimeoutException {
+ lock.lock();
+ try {
+ // wait for result to be available
+ if( notSetYet() ) isDone.await( timeout, unit);
+ if( response != null ) return response;
+ if( fault != null ) throw new ExecutionException( fault );
+ throw new TimeoutException("get on this Future timed out");
+ } finally {
+ lock.unlock();
+ } // end try
+
+ } // end method get(long timeout, TimeUnit unit)
+
+ /**
+ * Indicates if the asynchronous process has been cancelled
+ * - not possible in this version so always returns false
+ */
+ public boolean isCancelled() {
+ return false;
+ }
+
+ /**
+ * Indicates if the asynchronous process is completed
+ * @return - true if the process is completed, false otherwise
+ */
+ public boolean isDone() {
+ lock.lock();
+ try {
+ return !notSetYet();
+ } finally {
+ lock.unlock();
+ } // end try
+ } // end method isDone
+
+ /**
+ * Async process completed with a Fault. Must only be invoked once
+ * @param e - the Fault to send
+ * @throws IllegalStateException if either the setResponse method or the setFault method have been called previously
+ */
+ public void setFault(AsyncFaultWrapper w) {
+
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ Throwable e;
+ try {
+ // Set the TCCL to the classloader of the business interface
+ Thread.currentThread().setContextClassLoader(this.getClassLoader());
+ e = w.retrieveFault();
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ } // end try
+
+ if( e == null ) throw new IllegalArgumentException("AsyncFaultWrapper did not return an Exception");
+ lock.lock();
+ try {
+ if( notSetYet() ) {
+ fault = e;
+ isDone.signalAll();
+ } else {
+ throw new IllegalStateException("setResponse() or setFault() has been called previously");
+ } // end if
+ } finally {
+ lock.unlock();
+ } // end try
+
+ } // end method setFault
+
+ /**
+ * Async process completed with a response message. Must only be invoked once
+ * @throws IllegalStateException if either the setResponse method or the setFault method have been called previously
+ * @param res - the response message, which is of type V
+ */
+ public void setResponse(V res) {
+
+ lock.lock();
+ try {
+ if( notSetYet() ) {
+ response = res;
+ isDone.signalAll();
+ } else {
+ throw new IllegalStateException("setResponse() or setFault() has been called previously");
+ }
+ } finally {
+ lock.unlock();
+ } // end try
+
+ } // end method setResponse
+
+ /**
+ * Gets the unique ID of this future as a String
+ */
+ public String getUniqueID() { return uniqueID; }
+
+ /**
+ * Indicates that setting a response value is OK - can only set the response value or fault once
+ * @return - true if it is OK to set the response, false otherwise
+ */
+ private boolean notSetYet() {
+ return ( response == null && fault == null );
+ }
+
+ /**
+ * Returns the JAXWS context for the response
+ * @return - a Map containing the context
+ */
+ public Map<String, Object> getContext() {
+ // Intentionally returns null
+ return null;
+ }
+
+ /**
+ * Gets the classloader associated with the business interface to which this Future relates
+ * @return the ClassLoader of the business interface
+ */
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ /**
+ * Sets the classloader associated with the business interface to which this Future relates
+ * @param classLoader - the classloader of the business interface
+ */
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+
+} // end class AsyncInvocationFutureImpl
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java
new file mode 100644
index 0000000000..4371399f58
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java
@@ -0,0 +1,571 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.io.StringReader;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.core.invocation.AsyncFaultWrapper;
+import org.apache.tuscany.sca.core.invocation.AsyncResponseException;
+import org.apache.tuscany.sca.core.invocation.AsyncResponseHandler;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * An InvocationHandler which deals with JAXWS-defined asynchronous client Java API method calls
+ *
+ * 2 asynchronous mappings exist for any given synchronous service operation, as shown in this example:
+ * public interface StockQuote {
+ * float getPrice(String ticker);
+ * Response<Float> getPriceAsync(String ticker);
+ * Future<?> getPriceAsync(String ticker, AsyncHandler<Float> handler);
+ * }
+ *
+ * - the second method is called the "polling method", since the returned Response<?> object permits
+ * the client to poll to see if the async call has completed
+ * - the third method is called the "async callback method", since in this case the client application can specify
+ * a callback operation that is automatically called when the async call completes
+ */
+public class AsyncJDKInvocationHandler extends JDKInvocationHandler {
+
+ private static final long serialVersionUID = 1L;
+
+ private static int invocationCount = 10; // # of threads to use
+ private static long maxWaitTime = 30; // Max wait time for completion = 30sec
+
+ // Run the async service invocations using a ThreadPoolExecutor
+ private static ThreadPoolExecutor theExecutor = new ThreadPoolExecutor( invocationCount, invocationCount,
+ maxWaitTime, TimeUnit.SECONDS,
+ new ArrayBlockingQueue<Runnable>( invocationCount ) );
+
+
+ public AsyncJDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
+ super(messageFactory, callableReference);
+ }
+
+ public AsyncJDKInvocationHandler(MessageFactory messageFactory,
+ Class<?> businessInterface,
+ Invocable source) {
+ super(messageFactory, businessInterface, source);
+ }
+
+ /**
+ * Perform the invocation of the operation
+ * - provides support for all 3 forms of client method: synchronous, polling and async callback
+ */
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+
+ // force the bind of the reference so that we can look at the
+ // target contract to see if it's asynchronous
+ source.getInvocationChains();
+
+ if (isAsyncCallback(method)) {
+ return doInvokeAsyncCallback(proxy, method, args);
+ } else if (isAsyncPoll(method)) {
+ return doInvokeAsyncPoll(proxy, method, args);
+ } else {
+ // Regular synchronous method call
+ return doInvokeSync(proxy, method, args);
+ }
+ }
+
+ /**
+ * Indicates if a supplied method has the form of an async callback method
+ * @param method - the method
+ * @return - true if the method has the form of an async callback
+ */
+ protected boolean isAsyncCallback(Method method) {
+ if (method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Future.class))) {
+ if (method.getParameterTypes().length > 0) {
+ return method.getParameterTypes()[method.getParameterTypes().length-1].isAssignableFrom(AsyncHandler.class);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Indicates is a supplied method has the form of an async polling method
+ * @param method - the method
+ * @return - true if the method has the form of an async polling method
+ */
+ protected boolean isAsyncPoll(Method method) {
+ return method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Response.class));
+ }
+
+ /**
+ * Invoke an async polling method
+ * @param proxy - the reference proxy
+ * @param asyncMethod - the async method to invoke
+ * @param args - array of input arguments to the method
+ * @return - the Response<?> object that is returned to the client application, typed by the
+ * type of the response
+ */
+ @SuppressWarnings("unchecked")
+ protected Response doInvokeAsyncPoll(Object proxy, Method asyncMethod, Object[] args) {
+ Class<?> returnType = getNonAsyncMethod(asyncMethod).getReturnType();
+ // Allocate the Future<?> / Response<?> object - note: Response<?> is a subclass of Future<?>
+ AsyncInvocationFutureImpl future = AsyncInvocationFutureImpl.newInstance( returnType, getInterfaceClassloader() );
+ try {
+ invokeAsync(proxy, getNonAsyncMethod(asyncMethod), args, future);
+ } catch (Exception e) {
+ future.setFault( new AsyncFaultWrapper(e) );
+ } catch (Throwable t ) {
+ Exception e = new ServiceRuntimeException("Received Throwable: " + t.getClass().getName() +
+ " when invoking: " + asyncMethod.getName(), t);
+ future.setFault( new AsyncFaultWrapper(e) );
+ } // end try
+ return future;
+ } // end method doInvokeAsyncPoll
+
+ /**
+ * Provide a synchronous invocation of a service operation that is either synchronous or asynchronous
+ * @return
+ */
+ protected Object doInvokeSync(Object proxy, Method method, Object[] args) throws Throwable {
+ if ( isAsyncInvocation( source ) ) {
+ // Target service is asynchronous
+ Class<?> returnType = method.getReturnType();
+ AsyncInvocationFutureImpl future = AsyncInvocationFutureImpl.newInstance( returnType, getInterfaceClassloader() );
+ invokeAsync(proxy, method, args, future);
+ // Wait for some maximum time for the result - 1000 seconds here
+ // Really, if the service is async, the client should use async client methods to invoke the service
+ // - and be prepared to wait a *really* long time
+ Object response = null;
+ try {
+ response = future.get(1000, TimeUnit.SECONDS);
+ } catch(ExecutionException ex) {
+ throw ex.getCause();
+ }
+ return response;
+ } else {
+ // Target service is not asynchronous, so perform sync invocation
+ return super.invoke(proxy, method, args);
+ } // end if
+ } // end method doInvokeSync
+
+ /**
+ * Invoke an async callback method - note that this form of the async client API has as its final parameter
+ * an AsyncHandler method, used for callbacks to the client code
+ * @param proxy - the reference proxy
+ * @param asyncMethod - the async method to invoke
+ * @param args - array of input arguments to the method
+ * @return - the Future<?> object that is returned to the client application, typed by the type of
+ * the response
+ */
+ @SuppressWarnings("unchecked")
+ private Object doInvokeAsyncCallback(Object proxy, Method asyncMethod, Object[] args) {
+ AsyncHandler handler = (AsyncHandler)args[args.length-1];
+ Response response = doInvokeAsyncPoll(proxy,asyncMethod,Arrays.copyOf(args, args.length-1));
+ // Invoke the callback handler, if present
+ if( handler != null ) {
+ handler.handleResponse(response);
+ } // end if
+
+ return response;
+ } // end method doInvokeAsyncCallback
+
+ /**
+ * Invoke the target (synchronous) method asynchronously
+ * @param proxy - the reference proxy object
+ * @param method - the method to invoke
+ * @param args - arguments for the call
+ * @param future - Future for handling the response
+ * @return - returns the response from the invocation
+ * @throws Throwable - if an exception is thrown during the invocation
+ */
+ @SuppressWarnings("unchecked")
+ private void invokeAsync(Object proxy, Method method, Object[] args, AsyncInvocationFutureImpl future) throws Throwable {
+ if (source == null) {
+ throw new ServiceRuntimeException("No runtime source is available");
+ }
+
+ if (source instanceof RuntimeEndpointReference) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference)source;
+ if (epr.isOutOfDate()) {
+ epr.rebuild();
+ chains.clear();
+ }
+ } // end if
+
+ InvocationChain chain = getInvocationChain(method, source);
+
+ if (chain == null) {
+ throw new IllegalArgumentException("No matching operation is found: " + method);
+ }
+
+ // Organize for an async service
+ RuntimeEndpoint theEndpoint = getAsyncCallback( source );
+ boolean isAsyncService = false;
+ if( theEndpoint != null ) {
+ // ... the service is asynchronous ...
+ attachFuture( theEndpoint, future );
+ isAsyncService = true;
+ } else {
+ // ... the service is synchronous ...
+ } // end if
+
+ // Perform the invocations on separate thread...
+ theExecutor.execute( new separateThreadInvoker( chain, args, source, future, isAsyncService ) );
+
+ return;
+ } // end method invokeAsync
+
+ /**
+ * An inner class which acts as a runnable task for invoking services asynchronously on threads that are separate from
+ * those used to execute operations of components
+ *
+ * This supports both synchronous services and asynchronous services
+ */
+ private class separateThreadInvoker implements Runnable {
+
+ private AsyncInvocationFutureImpl future;
+ private InvocationChain chain;
+ private Object[] args;
+ private Invocable invocable;
+ private boolean isAsyncService;
+
+ public separateThreadInvoker( InvocationChain chain, Object[] args, Invocable invocable,
+ AsyncInvocationFutureImpl future, boolean isAsyncService ) {
+ super();
+ this.chain = chain;
+ this.args = args;
+ this.invocable = invocable;
+ this.future = future;
+ this.isAsyncService = isAsyncService;
+ } // end constructor
+
+ public void run() {
+ Object result;
+
+ try {
+ if( isAsyncService ) {
+ invoke(chain, args, invocable, future.getUniqueID());
+ // The result is returned asynchronously via the future...
+ } else {
+ // ... the service is synchronous ...
+ result = invoke(chain, args, invocable);
+ future.setResponse(result);
+ } // end if
+ } catch ( ServiceRuntimeException s ) {
+ Throwable e = s.getCause();
+ if( e != null && e instanceof FaultException ) {
+ if( "AsyncResponse".equals(e.getMessage()) ) {
+ // Do nothing...
+ } else {
+ future.setFault( new AsyncFaultWrapper( s ) );
+ } // end if
+ } // end if
+ } catch ( AsyncResponseException ar ) {
+ // do nothing
+ } catch ( Throwable t ) {
+ System.out.println("Async invoke got exception: " + t.toString());
+ future.setFault( new AsyncFaultWrapper( t ) );
+ } // end try
+
+ } // end method run
+
+ } // end class separateThreadInvoker
+
+ /**
+ * Attaches a future to the callback endpoint - so that the Future is triggered when a response is
+ * received from the asynchronous service invocation associated with the Future
+ * @param endpoint - the async callback endpoint
+ * @param future - the async invocation future to attach
+ */
+ private void attachFuture( RuntimeEndpoint endpoint, AsyncInvocationFutureImpl<?> future ) {
+ Implementation impl = endpoint.getComponent().getImplementation();
+ AsyncResponseHandlerImpl<?> asyncHandler = (AsyncResponseHandlerImpl<?>) impl;
+ asyncHandler.addFuture(future);
+ } // end method attachFuture
+
+ /**
+ * Get the async callback endpoint - if not already created, create and start it
+ * @param source - the RuntimeEndpointReference which needs an async callback endpoint
+ * @param future
+ * @return - the RuntimeEndpoint of the async callback
+ */
+ private RuntimeEndpoint getAsyncCallback( Invocable source ) {
+ if( !(source instanceof RuntimeEndpointReference) ) return null;
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) source;
+ if( !isAsyncInvocation( epr ) ) return null;
+ RuntimeEndpoint endpoint;
+ synchronized( epr ) {
+ endpoint = (RuntimeEndpoint)epr.getCallbackEndpoint();
+ // If the async callback endpoint is already created, return it...
+ if( endpoint != null ) return endpoint;
+ // Create the endpoint for the async callback
+ endpoint = createAsyncCallbackEndpoint( epr );
+ epr.setCallbackEndpoint(endpoint);
+ } // end synchronized
+
+ // Activate the new callback endpoint
+ startEndpoint( epr.getCompositeContext(), endpoint );
+ endpoint.getInvocationChains();
+
+ return endpoint;
+ } // end method setupAsyncCallback
+
+ /**
+ * Start the callback endpoint
+ * @param compositeContext - the composite context
+ * @param ep - the endpoint to start
+ */
+ private void startEndpoint(CompositeContext compositeContext, RuntimeEndpoint ep ) {
+ for (PolicyProvider policyProvider : ep.getPolicyProviders()) {
+ policyProvider.start();
+ } // end for
+
+ final ServiceBindingProvider bindingProvider = ep.getBindingProvider();
+ if (bindingProvider != null) {
+ // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ bindingProvider.start();
+ return null;
+ }
+ });
+ compositeContext.getEndpointRegistry().addEndpoint(ep);
+ }
+ } // end method startEndpoint
+
+ /**
+ * Create the async callback endpoint for a reference that is going to invoke an asyncInvocation service
+ * @param epr - the RuntimeEndpointReference for which the callback is created
+ * @return - a RuntimeEndpoint representing the callback endpoint
+ */
+ private RuntimeEndpoint createAsyncCallbackEndpoint( RuntimeEndpointReference epr ) {
+ CompositeContext compositeContext = epr.getCompositeContext();
+ RuntimeAssemblyFactory assemblyFactory = getAssemblyFactory( compositeContext );
+ RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
+ endpoint.bind( compositeContext );
+
+ // Create a pseudo-component and pseudo-service
+ // - need to end with a chain with an invoker into the AsyncCallbackHandler class
+ RuntimeComponent fakeComponent = null;
+ try {
+ fakeComponent = (RuntimeComponent)epr.getComponent().clone();
+ applyImplementation( fakeComponent );
+ } catch (CloneNotSupportedException e2) {
+ // will not happen
+ } // end try
+ endpoint.setComponent(fakeComponent);
+
+ // Create pseudo-service
+ ComponentService service = assemblyFactory.createComponentService();
+ ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ JavaInterfaceFactory javaInterfaceFactory = (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ try {
+ interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(AsyncResponseHandler.class));
+ } catch (InvalidInterfaceException e1) {
+ // Nothing to do here - will not happen
+ } // end try
+ service.setInterfaceContract(interfaceContract);
+ String serviceName = epr.getReference().getName() + "_asyncCallback";
+ service.setName(serviceName);
+ endpoint.setService(service);
+ // Set pseudo-service onto the pseudo-component
+ List<ComponentService> services = fakeComponent.getServices();
+ services.clear();
+ services.add(service);
+
+ // Create a binding
+ Binding binding = createMatchingBinding( epr.getBinding(), fakeComponent, service, registry );
+ endpoint.setBinding(binding);
+
+ // Need to establish policies here (binding has some...)
+ endpoint.getRequiredIntents().addAll( epr.getRequiredIntents() );
+ endpoint.getPolicySets().addAll( epr.getPolicySets() );
+ String epURI = epr.getComponent().getName() + "#service-binding(" + serviceName + "/" + serviceName + ")";
+ endpoint.setURI(epURI);
+ endpoint.setUnresolved(false);
+ return endpoint;
+ }
+
+ /**
+ * Create a matching binding to a supplied binding
+ * - the matching binding has the same binding type, but is for the supplied component and service
+ * @param matchBinding - the binding to match
+ * @param component - the component
+ * @param service - the service
+ * @param registry - registry for extensions
+ * @return - the matching binding, or null if it could not be created
+ */
+ @SuppressWarnings("unchecked")
+ private Binding createMatchingBinding( Binding matchBinding, RuntimeComponent component,
+ ComponentService service, ExtensionPointRegistry registry ) {
+ // Since there is no simple way to obtain a Factory for a binding where the type is not known ahead of
+ // time, the process followed here is to generate the <binding.xxx/> XML element from the binding type QName
+ // and then read the XML using the processor for that XML...
+ QName bindingName = matchBinding.getType();
+ String bindingXML = "<ns1:" + bindingName.getLocalPart() + " xmlns:ns1='" + bindingName.getNamespaceURI() + "'/>";
+
+ StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<?> processor = (StAXArtifactProcessor<?>)processors.getProcessor(bindingName);
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ ValidatingXMLInputFactory inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ StreamSource source = new StreamSource( new StringReader(bindingXML) );
+
+ ProcessorContext context = new ProcessorContext();
+ try {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(source);
+ reader.next();
+ Binding newBinding = (Binding) processor.read(reader, context );
+
+ // Create a URI address for the callback based on the Component_Name/Reference_Name pattern
+ String callbackURI = "/" + component.getName() + "/" + service.getName();
+ newBinding.setURI(callbackURI);
+
+ BuilderExtensionPoint builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ BindingBuilder builder = builders.getBindingBuilder(newBinding.getType());
+ if (builder != null) {
+ org.apache.tuscany.sca.assembly.builder.BuilderContext builderContext = new BuilderContext(registry);
+ builder.build(component, service, newBinding, builderContext, true);
+ } // end if
+
+ return newBinding;
+ } catch (ContributionReadException e) {
+ e.printStackTrace();
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ } // end method createMatchingBinding
+
+ /**
+ * Gets a RuntimeAssemblyFactory from the CompositeContext
+ * @param compositeContext
+ * @return the RuntimeAssemblyFactory
+ */
+ private RuntimeAssemblyFactory getAssemblyFactory( CompositeContext compositeContext ) {
+ ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ return (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+ } // end method RuntimeAssemblyFactory
+
+ /**
+ * Applies an AsyncResponseHandlerImpl as the implementation of a RuntimeComponent
+ * - the AsyncResponseHandlerImpl acts as both the implementation class and the implementation provider...
+ * @param component - the component
+ */
+ private void applyImplementation( RuntimeComponent component ) {
+ AsyncResponseHandlerImpl<?> asyncHandler = new AsyncResponseHandlerImpl<Object>();
+ component.setImplementation( asyncHandler );
+ component.setImplementationProvider( asyncHandler );
+ return;
+ } // end method getImplementationProvider
+
+ private static QName ASYNC_INVOKE = new QName( Constants.SCA11_NS, "asyncInvocation" );
+ /**
+ * Determines if the service invocation is asynchronous
+ * @param source - the EPR involved in the invocation
+ * @return - true if the invocation is async
+ */
+ private boolean isAsyncInvocation( Invocable source ) {
+ if( !(source instanceof RuntimeEndpointReference) ) return false;
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) source;
+ // First check is to see if the EPR itself has the asyncInvocation intent marked
+ for( Intent intent : epr.getRequiredIntents() ) {
+ if ( intent.getName().equals(ASYNC_INVOKE) ) return true;
+ } // end for
+
+ // Second check is to see if the target service has the asyncInvocation intent marked
+ Endpoint ep = epr.getTargetEndpoint();
+ for( Intent intent : ep.getRequiredIntents() ) {
+ if ( intent.getName().equals(ASYNC_INVOKE) ) return true;
+ } // end for
+ return false;
+ } // end isAsyncInvocation
+
+ /**
+ * Return the synchronous method that is the equivalent of an async method
+ * @param asyncMethod - the async method
+ * @return - the equivalent synchronous method
+ */
+ protected Method getNonAsyncMethod(Method asyncMethod) {
+ String methodName = asyncMethod.getName().substring(0, asyncMethod.getName().length()-5);
+ for (Method m : businessInterface.getMethods()) {
+ if (methodName.equals(m.getName())) {
+ return m;
+ }
+ }
+ throw new IllegalStateException("No synchronous method matching async method " + asyncMethod.getName());
+ } // end method getNonAsyncMethod
+
+ /**
+ * Gets the classloader of the business interface
+ * @return
+ */
+ private ClassLoader getInterfaceClassloader( ) {
+ return businessInterface.getClassLoader();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java
new file mode 100644
index 0000000000..7b459f3e7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.xml.ws.Response;
+
+public class AsyncResponse implements Response {
+
+ private Object response;
+ private boolean isException;
+
+ public AsyncResponse(Object response, boolean isException) {
+ this.response = response;
+ this.isException = isException;
+ }
+
+ public Map getContext() {
+ return new HashMap();
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ return false;
+ }
+
+ public Object get() throws InterruptedException, ExecutionException {
+ if (isException) {
+ throw new ExecutionException((Throwable)response);
+ } else {
+ return response;
+ }
+ }
+
+ public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ return get();
+ }
+
+ public boolean isCancelled() {
+ return false;
+ }
+
+ public boolean isDone() {
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponseHandlerImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponseHandlerImpl.java
new file mode 100644
index 0000000000..aa9cf4ad48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponseHandlerImpl.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.core.invocation.AsyncFaultWrapper;
+import org.apache.tuscany.sca.core.invocation.AsyncResponseHandler;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * A class intended to form the final link in the chain calling into a Future which represents
+ * the response to an asynchronous service invocation
+ *
+ * Most methods are dummies, required to fulfil the contracts for ImplementationProvider, Implementation
+ * and Invoker, since this class collapses together the functions of these separate interfaces, due to its
+ * specialized nature, where most of the function will never be used.
+ *
+ * The class acts as the implementation object that terminates the chain - and also as the provider of the implementation.
+ * The class accepts Future objects which represent individual invocations of forward operations on the async service
+ * and expects that the responses it handles as invocations will carry the unique ID of one of the Future objects in the
+ * message header. On receipt of each message, the class seeks out the Future with that unique ID and completes the future
+ * either with a response message or with a Fault.
+ *
+ * @param <V>
+ */
+public class AsyncResponseHandlerImpl<V> implements AsyncResponseHandler<V>,
+ ImplementationProvider, Implementation, Invoker {
+
+ private ConcurrentHashMap< String, AsyncInvocationFutureImpl<?> > table =
+ new ConcurrentHashMap< String, AsyncInvocationFutureImpl<?> >();
+
+ /**
+ * This class is its own invoker...
+ */
+ public Invoker createInvoker(RuntimeComponentService service,
+ Operation operation) {
+ return this;
+ }
+
+ /**
+ * Add a future to this response handler
+ * @param future - the future
+ */
+ public void addFuture( AsyncInvocationFutureImpl<?> future ) {
+ // The Future is stored in the table indexed by its unique ID
+ table.put(future.getUniqueID(), future);
+ } // end method addFuture
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ public void start() {}
+
+ public void stop() {}
+
+ public List<Operation> getOperations() {
+ return null;
+ }
+
+ public QName getType() {
+ return null;
+ }
+
+ public List<Property> getProperties() {
+ return null;
+ }
+
+ public Property getProperty(String name) {
+ return null;
+ }
+
+ public Reference getReference(String name) {
+ return null;
+ }
+
+ public List<Reference> getReferences() {
+ return null;
+ }
+
+ public Service getService(String name) {
+ return null;
+ }
+
+ public List<Service> getServices() {
+ return null;
+ }
+
+ public String getURI() {
+ return null;
+ }
+
+ public void setURI(String uri) {}
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {}
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return null;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {}
+
+ public void setFault(AsyncFaultWrapper e) {}
+
+ public void setResponse(V res) { }
+
+ /**
+ * Method which is the termination for the invocation chain from the callback endpoint
+ * @param msg - the Tuscany message containing the response from the async service invocation
+ * which is either the Response message or an exception of some kind
+ */
+ private static final String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ public Message invoke(Message msg) {
+ // Get the unique ID from the message header
+ String idValue = (String)msg.getHeaders().get(WS_MESSAGE_ID);
+ if (idValue == null){
+ idValue = (String)msg.getHeaders().get("MESSAGE_ID");
+ }
+
+ if( idValue == null ) {
+ System.out.println( "Async message ID not found ");
+ } else {
+ // Fetch the Future with that Unique ID
+ AsyncInvocationFutureImpl future = table.get(idValue);
+ if( future == null ) {
+ System.out.println("Future not found for id: " + idValue);
+ } else {
+ // Complete the Future with a Response message
+ Object payload = msg.getBody();
+ Object response;
+ if( payload == null ) {
+ System.out.println("Returned response message was null");
+ } else {
+ if (payload.getClass().isArray()) {
+ response = ((Object[])payload)[0];
+ } else {
+ response = payload;
+ } // end if
+ if( response.getClass().equals(AsyncFaultWrapper.class)) {
+ future.setFault((AsyncFaultWrapper) response );
+ } else {
+ future.setResponse(response);
+ } // end if
+ } // end if
+ } // end if
+ } // end if
+
+ // Prepare an empty response message
+ msg.setBody(null);
+ return msg;
+ } // end method invoke
+
+} // end class
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
new file mode 100644
index 0000000000..8569af0de8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+
+/**
+ * Default implementation of an invocation chain
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvocationChainImpl implements InvocationChain {
+ private Operation sourceOperation;
+ private Operation targetOperation;
+ private List<Node> nodes = new ArrayList<Node>();
+
+ private final PhaseManager phaseManager;
+ private boolean forReference;
+ private boolean allowsPassByReference;
+
+ public InvocationChainImpl(Operation sourceOperation, Operation targetOperation, boolean forReference, PhaseManager phaseManager) {
+ this.targetOperation = targetOperation;
+ this.sourceOperation = sourceOperation;
+ this.forReference = forReference;
+ this.phaseManager = phaseManager;
+ }
+
+ public Operation getTargetOperation() {
+ return targetOperation;
+ }
+
+ public void setTargetOperation(Operation operation) {
+ this.targetOperation = operation;
+ }
+
+ public void addInterceptor(Interceptor interceptor) {
+ if (interceptor instanceof PhasedInterceptor) {
+ PhasedInterceptor pi = (PhasedInterceptor)interceptor;
+ if (pi.getPhase() != null) {
+ addInvoker(pi.getPhase(), pi);
+ return;
+ }
+ }
+ String phase = forReference ? Phase.REFERENCE : Phase.SERVICE;
+ addInterceptor(phase, interceptor);
+ }
+
+ public void addInvoker(Invoker invoker) {
+ if (invoker instanceof PhasedInterceptor) {
+ PhasedInterceptor pi = (PhasedInterceptor)invoker;
+ if (pi.getPhase() != null) {
+ addInvoker(pi.getPhase(), pi);
+ return;
+ }
+ }
+ String phase = forReference ? Phase.REFERENCE_BINDING : Phase.IMPLEMENTATION;
+ addInvoker(phase, invoker);
+ }
+
+ public Invoker getHeadInvoker() {
+ return nodes.isEmpty() ? null : nodes.get(0).getInvoker();
+ }
+
+ public Invoker getHeadInvoker(String phase) {
+ int index = phaseManager.getAllPhases().indexOf(phase);
+ if (index == -1) {
+ throw new IllegalArgumentException("Invalid phase name: " + phase);
+ }
+ for (Node node : nodes) {
+ if (index <= node.getPhaseIndex()) {
+ return node.getInvoker();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return the sourceOperation
+ */
+ public Operation getSourceOperation() {
+ return sourceOperation;
+ }
+
+ /**
+ * @param sourceOperation the sourceOperation to set
+ */
+ public void setSourceOperation(Operation sourceOperation) {
+ this.sourceOperation = sourceOperation;
+ }
+
+ public void addInterceptor(String phase, Interceptor interceptor) {
+ addInvoker(phase, interceptor);
+ }
+
+ private void addInvoker(String phase, Invoker invoker) {
+ int index = phaseManager.getAllPhases().indexOf(phase);
+ if (index == -1) {
+ throw new IllegalArgumentException("Invalid phase name: " + phase);
+ }
+ Node node = new Node(index, invoker);
+ ListIterator<Node> li = nodes.listIterator();
+ Node before = null, after = null;
+ boolean found = false;
+ while (li.hasNext()) {
+ before = after;
+ after = li.next();
+ if (after.getPhaseIndex() > index) {
+ // Move back
+ li.previous();
+ li.add(node);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ // Add to the end
+ nodes.add(node);
+ before = after;
+ after = null;
+ }
+
+ // Relink the interceptors
+ if (before != null) {
+ if (before.getInvoker() instanceof Interceptor) {
+ ((Interceptor)before.getInvoker()).setNext(invoker);
+ }
+ }
+ if (after != null) {
+ if (invoker instanceof Interceptor) {
+ ((Interceptor)invoker).setNext(after.getInvoker());
+ }
+ }
+
+ }
+
+ public boolean allowsPassByReference() {
+ if (allowsPassByReference) {
+ // No need to check the invokers
+ return true;
+ }
+ // Check if any of the invokers allows pass-by-reference
+ boolean allowsPBR = false;
+ for (Node i : nodes) {
+ if (i.getInvoker() instanceof DataExchangeSemantics) {
+ if (((DataExchangeSemantics)i.getInvoker()).allowsPassByReference()) {
+ allowsPBR = true;
+ break;
+ }
+ }
+ }
+ return allowsPBR;
+ }
+
+ public void setAllowsPassByReference(boolean allowsPBR) {
+ this.allowsPassByReference = allowsPBR;
+ }
+
+ private static class Node {
+ private int phaseIndex;
+ private Invoker invoker;
+
+ public Node(int phaseIndex, Invoker invoker) {
+ super();
+ this.phaseIndex = phaseIndex;
+ this.invoker = invoker;
+ }
+
+ public int getPhaseIndex() {
+ return phaseIndex;
+ }
+
+ public Invoker getInvoker() {
+ return invoker;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + phaseIndex + ")" + invoker;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
new file mode 100644
index 0000000000..168af952db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.invocation.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Responsible for dispatching to a callback through a wire. <p/> TODO cache
+ * target invoker
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKCallbackInvocationHandler extends JDKInvocationHandler {
+ private static final long serialVersionUID = -3350283555825935609L;
+
+ public JDKCallbackInvocationHandler(MessageFactory messageFactory, ServiceReference<?> ref) {
+ super(messageFactory, ref);
+ this.fixedWire = false;
+ }
+
+ @Override
+ @SuppressWarnings( {"unchecked"})
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+
+ if (Object.class == method.getDeclaringClass()) {
+ return invokeObjectMethod(method, args);
+ }
+
+ // obtain a dedicated wire to be used for this callback invocation
+ RuntimeEndpointReference wire = ((CallbackServiceReferenceImpl)callableReference).getCallbackEPR();
+ if (wire == null) {
+ //FIXME: need better exception
+ throw new ServiceRuntimeException("No callback wire found");
+ }
+
+ setEndpoint(((CallbackServiceReferenceImpl)callableReference).getResolvedEndpoint());
+
+ InvocationChain chain = getInvocationChain(method, wire);
+ if (chain == null) {
+ throw new IllegalArgumentException("No matching operation is found: " + method);
+ }
+
+ try {
+ return invoke(chain, args, wire);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ throw t;
+ } finally {
+ // allow the cloned wire to be reused by subsequent callbacks
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
new file mode 100644
index 0000000000..d0095f45ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
@@ -0,0 +1,311 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JDKInvocationHandler implements InvocationHandler, Serializable {
+ private static final long serialVersionUID = -3366410500152201371L;
+
+ protected MessageFactory messageFactory;
+ protected Endpoint target;
+ protected Invocable source;
+ protected ServiceReferenceExt<?> callableReference;
+ protected Class<?> businessInterface;
+
+ protected boolean fixedWire = true;
+
+ protected transient Map<Method, InvocationChain> chains = new IdentityHashMap<Method, InvocationChain>();
+
+ public JDKInvocationHandler(MessageFactory messageFactory, Class<?> businessInterface, Invocable source) {
+ this.messageFactory = messageFactory;
+ this.source = source;
+ this.businessInterface = businessInterface;
+ }
+
+ public JDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
+ this.messageFactory = messageFactory;
+ this.callableReference = (ServiceReferenceExt<?>)callableReference;
+ if (callableReference != null) {
+ this.businessInterface = callableReference.getBusinessInterface();
+ this.source = (RuntimeEndpointReference) this.callableReference.getEndpointReference();
+ }
+ }
+
+
+ public Class<?> getBusinessInterface() {
+ return businessInterface;
+ }
+
+ protected Object getCallbackID() {
+ return null;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (Object.class == method.getDeclaringClass()) {
+ return invokeObjectMethod(method, args);
+ }
+ if (source == null) {
+ throw new ServiceRuntimeException("No runtime source is available");
+ }
+
+ if (source instanceof RuntimeEndpointReference) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference)source;
+ if (epr.isOutOfDate()) {
+ epr.rebuild();
+ chains.clear();
+ }
+ }
+
+ InvocationChain chain = getInvocationChain(method, source);
+
+ if (chain == null) {
+ throw new IllegalArgumentException("No matching operation is found: " + method);
+ }
+
+ // send the invocation down the source
+ Object result = invoke(chain, args, source);
+
+ return result;
+ }
+
+ /**
+ * Handle the methods on the Object.class
+ * @param method
+ * @param args
+ */
+ protected Object invokeObjectMethod(Method method, Object[] args) throws Throwable {
+ String name = method.getName();
+ if ("toString".equals(name)) {
+ return "[Proxy - " + toString() + "]";
+ } else if ("equals".equals(name)) {
+ Object obj = args[0];
+ if (obj == null) {
+ return false;
+ }
+ if (!Proxy.isProxyClass(obj.getClass())) {
+ return false;
+ }
+ return equals(Proxy.getInvocationHandler(obj));
+ } else if ("hashCode".equals(name)) {
+ return hashCode();
+ } else {
+ return method.invoke(this);
+ }
+ }
+
+ /**
+ * Determines if the given operation matches the given method
+ *
+ * @return true if the operation matches, false if does not
+ */
+ // FIXME: Should it be in the InterfaceContractMapper?
+ @SuppressWarnings("unchecked")
+ private static boolean match(Operation operation, Method method) {
+ if (operation instanceof JavaOperation) {
+ JavaOperation javaOp = (JavaOperation)operation;
+ Method m = javaOp.getJavaMethod();
+ if (!method.getName().equals(m.getName())) {
+ return false;
+ }
+ if (method.equals(m)) {
+ return true;
+ }
+ } else {
+ if (!method.getName().equals(operation.getName())) {
+ return false;
+ }
+ }
+
+ // For remotable interface, operation is not overloaded.
+ if (operation.getInterface().isRemotable()) {
+ return true;
+ }
+
+ Class<?>[] params = method.getParameterTypes();
+
+ DataType<List<DataType>> inputType = null;
+ if (operation.isWrapperStyle()) {
+ inputType = operation.getWrapper().getUnwrappedInputType();
+ } else {
+ inputType = operation.getInputType();
+ }
+ List<DataType> types = inputType.getLogical();
+ boolean matched = true;
+ if (types.size() == params.length && method.getName().equals(operation.getName())) {
+ for (int i = 0; i < params.length; i++) {
+ Class<?> clazz = params[i];
+ Class<?> type = types.get(i).getPhysical();
+ // Object.class.isAssignableFrom(int.class) returns false
+ if (type != Object.class && (!type.isAssignableFrom(clazz))) {
+ matched = false;
+ }
+ }
+ } else {
+ matched = false;
+ }
+ return matched;
+
+ }
+
+ protected synchronized InvocationChain getInvocationChain(Method method, Invocable source) {
+ if (source instanceof RuntimeEndpoint) {
+ InvocationChain invocationChain = source.getBindingInvocationChain();
+ for (InvocationChain chain : source.getInvocationChains()) {
+ Operation operation = chain.getTargetOperation();
+ if (method.getName().equals(operation.getName())) {
+ invocationChain.setTargetOperation(operation);
+ }
+ }
+ return source.getBindingInvocationChain();
+ }
+ if (fixedWire && chains.containsKey(method)) {
+ return chains.get(method);
+ }
+ InvocationChain found = null;
+ for (InvocationChain chain : source.getInvocationChains()) {
+ Operation operation = chain.getSourceOperation();
+ if (operation.isDynamic()) {
+ operation.setName(method.getName());
+ found = chain;
+ break;
+ } else if (match(operation, method)) {
+ found = chain;
+ break;
+ }
+ }
+ if (fixedWire) {
+ chains.put(method, found);
+ }
+ return found;
+ }
+
+ protected void setEndpoint(Endpoint endpoint) {
+ this.target = endpoint;
+ }
+
+ protected Object invoke(InvocationChain chain, Object[] args, Invocable source)
+ throws Throwable {
+ return invoke( chain, args, source, null );
+ }
+
+ /**
+ * Invoke the chain
+ * @param chain - the chain
+ * @param args - arguments to the invocation as an array of Objects
+ * @param source - the Endpoint or EndpointReference to which the chain relates
+ * @param msgID - an ID for the message being sent, may be null
+ * @return - the Response message from the invocation
+ * @throws Throwable - if any exception occurs during the invocation
+ */
+ protected Object invoke(InvocationChain chain, Object[] args, Invocable source, String msgID)
+ throws Throwable {
+ Message msg = messageFactory.createMessage();
+ if (source instanceof RuntimeEndpointReference) {
+ msg.setFrom((RuntimeEndpointReference)source);
+ }
+ if (target != null) {
+ msg.setTo(target);
+ } else {
+ if (source instanceof RuntimeEndpointReference) {
+ msg.setTo(((RuntimeEndpointReference)source).getTargetEndpoint());
+ }
+ }
+ Invoker headInvoker = chain.getHeadInvoker();
+ Operation operation = chain.getTargetOperation();
+ msg.setOperation(operation);
+ msg.setBody(args);
+
+ Message msgContext = ThreadMessageContext.getMessageContext();
+
+ // Deal with header information that needs to be copied from the message context to the new message...
+ transferMessageHeaders( msg, msgContext);
+
+ ThreadMessageContext.setMessageContext(msg);
+
+ // If there is a supplied message ID, place its value into the Message Header under "MESSAGE_ID"
+ if( msgID != null ){
+ msg.getHeaders().put("MESSAGE_ID", msgID);
+ } // end if
+
+ try {
+ // dispatch the source down the chain and get the response
+ Message resp = headInvoker.invoke(msg);
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw (Throwable)body;
+ }
+ return body;
+ } finally {
+ ThreadMessageContext.setMessageContext(msgContext);
+ }
+ }
+
+ /**
+ * Transfer relevant header information from the old message (incoming) to the new message (outgoing)
+ * @param newMsg
+ * @param oldMsg
+ */
+ private void transferMessageHeaders( Message newMsg, Message oldMsg ) {
+ if( oldMsg == null ) return;
+ // For the present, simply copy all the headers
+ if( !oldMsg.getHeaders().isEmpty() ) newMsg.getHeaders().putAll( oldMsg.getHeaders() );
+ } // end transferMessageHeaders
+
+ /**
+ * @return the callableReference
+ */
+ public ServiceReference<?> getCallableReference() {
+ return callableReference;
+ }
+
+ /**
+ * @param callableReference the callableReference to set
+ */
+ public void setCallableReference(ServiceReference<?> callableReference) {
+ this.callableReference = (ServiceReferenceExt<?>)callableReference;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java
new file mode 100644
index 0000000000..87a7f0910b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.List;
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.tuscany.sca.common.java.collection.LRUCache;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
+import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
+import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
+import org.apache.tuscany.sca.core.invocation.ProxyCreationException;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+
+/**
+ * the default implementation of a wire service that uses JDK dynamic proxies
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKProxyFactory implements ProxyFactory, LifeCycleListener {
+ protected InterfaceContractMapper contractMapper;
+ private MessageFactory messageFactory;
+
+ public JDKProxyFactory(MessageFactory messageFactory, InterfaceContractMapper mapper) {
+ this.contractMapper = mapper;
+ this.messageFactory = messageFactory;
+ }
+
+ /**
+ * The original createProxy method assumes that the proxy doesn't want to
+ * share conversation state so sets the conversation object to null
+ */
+ public <T> T createProxy(final Class<T> interfaze, Invocable invocable) throws ProxyCreationException {
+ if (invocable instanceof RuntimeEndpoint) {
+ InvocationHandler handler;
+// TUSCANY-3659 - Always install a asynch handler regardless of whether ref is sync or async
+// needs tidying
+// if (isAsync(interfaze)) {
+ handler = new AsyncJDKInvocationHandler(messageFactory, interfaze, invocable);
+// } else {
+// handler = new JDKInvocationHandler(messageFactory, interfaze, invocable);
+// }
+ // Allow privileged access to class loader. Requires RuntimePermission in security policy.
+ ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return interfaze.getClassLoader();
+ }
+ });
+ T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler));
+ return proxy;
+ }
+ ServiceReference<T> serviceReference = new ServiceReferenceImpl<T>(interfaze, invocable, null);
+ return createProxy(serviceReference);
+ }
+
+ public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException {
+ assert callableReference != null;
+ final Class<T> interfaze = callableReference.getBusinessInterface();
+ InvocationHandler handler;
+// TUSCANY-3659 - Always install a asynch handler regardless of whether ref is sync or async
+// needs tidying
+// if (isAsync(interfaze)) {
+ handler = new AsyncJDKInvocationHandler(messageFactory, callableReference);
+// } else {
+// handler = new JDKInvocationHandler(messageFactory, callableReference);
+// }
+ // Allow privileged access to class loader. Requires RuntimePermission in security policy.
+ ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return interfaze.getClassLoader();
+ }
+ });
+ T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler));
+ ((ServiceReferenceExt<T>)callableReference).setProxy(proxy);
+ return proxy;
+ }
+
+ private boolean isAsync(Class<?> interfaze) {
+ for (Method method : interfaze.getMethods()) {
+ if (method.getName().endsWith("Async")) {
+ if (method.getReturnType().isAssignableFrom(Future.class)) {
+ if (method.getParameterTypes().length > 0) {
+ if (method.getParameterTypes()[method.getParameterTypes().length-1].isAssignableFrom(AsyncHandler.class)) {
+ return true;
+ }
+ }
+ }
+ if (method.getReturnType().isAssignableFrom(Response.class)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> wires) throws ProxyCreationException {
+ ServiceReferenceImpl<T> callbackReference = null;
+ try {
+ callbackReference = new CallbackServiceReferenceImpl(interfaze, wires);
+ } catch (ServiceRuntimeException e) {
+ // [rfeng] In case that the call is not from a bidirectional interface, the field should be injected with null
+ callbackReference = null;
+ }
+ return callbackReference != null ? createCallbackProxy(callbackReference) : null;
+ }
+
+ public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
+ assert callbackReference != null;
+ Class<T> interfaze = callbackReference.getBusinessInterface();
+ InvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
+ ClassLoader cl = interfaze.getClassLoader();
+ T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler));
+ ((ServiceReferenceExt<T>) callbackReference).setProxy(proxy);
+ return proxy;
+ }
+
+ public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
+ InvocationHandler handler = Proxy.getInvocationHandler(target);
+ if (handler instanceof JDKInvocationHandler) {
+ return (R)((JDKInvocationHandler)handler).getCallableReference();
+ } else {
+ throw new IllegalArgumentException("The object is not a known proxy.");
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#isProxyClass(java.lang.Class)
+ */
+ public boolean isProxyClass(Class<?> clazz) {
+ return Proxy.isProxyClass(clazz);
+ }
+
+ // This is a cache containing the proxy class constructor for each business interface.
+ // This improves performance compared to calling Proxy.newProxyInstance()
+ // every time that a proxy is needed.
+ private final LRUCache<Class<?>, Constructor<?>> cache = new LRUCache<Class<?>, Constructor<?>>(512);
+
+ public Object newProxyInstance(ClassLoader classloader,
+ Class<?> interfaces[],
+ InvocationHandler invocationhandler) throws IllegalArgumentException {
+ if (interfaces.length > 1) {
+ // We only cache the proxy constructors with one single interface which the case in SCA where
+ // one reference can have one interface
+ return Proxy.newProxyInstance(classloader, interfaces, invocationhandler);
+ }
+ try {
+ if (invocationhandler == null)
+ throw new NullPointerException("InvocationHandler is null");
+ // Lookup cached constructor. aclass[0] is the reference's business interface.
+ Constructor<?> proxyCTOR;
+ synchronized (cache) {
+ proxyCTOR = cache.get(interfaces[0]);
+ }
+ if (proxyCTOR == null) {
+ Class<?> proxyClass = Proxy.getProxyClass(classloader, interfaces);
+ proxyCTOR = proxyClass.getConstructor(InvocationHandler.class);
+ synchronized (cache) {
+ cache.put(interfaces[0], proxyCTOR);
+ }
+ }
+ return proxyCTOR.newInstance(invocationhandler);
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ cache.clear();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java
new file mode 100644
index 0000000000..6ce2ffca21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.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 org.apache.tuscany.sca.core.invocation.impl;
+
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+/**
+ * Implementation of MessageFactory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MessageFactoryImpl implements MessageFactory {
+
+ public Message createMessage() {
+ return new MessageImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java
new file mode 100644
index 0000000000..cc8cb48cc5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * The default implementation of a message flowed through a wire during an invocation
+ *
+ * @version $Rev $Date$
+ */
+public class MessageImpl implements Message {
+ private Map<String, Object> headers = new HashMap<String, Object>();
+ private Object body;
+ private Object messageID;
+ private boolean isFault;
+ private Operation operation;
+
+ private EndpointReference from;
+ private Endpoint to;
+
+ private Object bindingContext;
+
+ public MessageImpl() {
+ this.from = null;
+ this.to = null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getBody() {
+ return (T)body;
+ }
+
+ public <T> void setBody(T body) {
+ this.isFault = false;
+ this.body = body;
+ }
+
+ public Object getMessageID() {
+ return messageID;
+ }
+
+ public void setMessageID(Object messageId) {
+ this.messageID = messageId;
+ }
+
+ public boolean isFault() {
+ return isFault;
+ }
+
+ public void setFaultBody(Object fault) {
+ this.isFault = true;
+ this.body = fault;
+ }
+
+ public EndpointReference getFrom() {
+ return from;
+ }
+
+ public void setFrom(EndpointReference from) {
+ this.from = from;
+ }
+
+ public Endpoint getTo() {
+ return to;
+ }
+
+ public void setTo(Endpoint to) {
+ this.to = to;
+ }
+
+ public Operation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(Operation op) {
+ this.operation = op;
+ }
+
+ public Map<String, Object> getHeaders() {
+ return headers;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getBindingContext() {
+ return (T)bindingContext;
+ }
+
+ public <T> void setBindingContext(T bindingContext) {
+ this.bindingContext = bindingContext;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java
new file mode 100644
index 0000000000..45f4bf52bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.invocation.impl;
+
+import org.apache.tuscany.sca.core.invocation.ProxyCreationException;
+
+
+/**
+ * Thrown when an {@link org.apache.tuscany.sca.core.factory.model.Operation} cannot be mapped to a method on an interface
+ * @version $Rev$ $Date$
+ */
+public class NoMethodForOperationException extends ProxyCreationException {
+ private static final long serialVersionUID = 5116536602309483679L;
+
+ public NoMethodForOperationException() {
+ }
+
+ public NoMethodForOperationException(String message) {
+ super(message);
+ }
+
+ public NoMethodForOperationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoMethodForOperationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
new file mode 100644
index 0000000000..85ef79b5d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
@@ -0,0 +1,313 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION;
+import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_TRANSPORT;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_WIREFORMAT;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_INTERFACE;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_TRANSPORT;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_WIREFORMAT;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_INTERFACE;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_POLICY;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PhaseManager {
+ private static final Logger log = Logger.getLogger(PhaseManager.class.getName());
+
+ public static final String STAGE_REFERENCE = "reference";
+ public static final String STAGE_REFERENCE_BINDING = "reference.binding";
+ public static final String STAGE_SERVICE_BINDING = "service.binding";
+ public static final String STAGE_SERVICE = "service";
+ public static final String STAGE_IMPLEMENTATION = "implementation";
+
+ private static final String[] SYSTEM_REFERENCE_PHASES =
+ {REFERENCE, REFERENCE_POLICY, REFERENCE_INTERFACE, REFERENCE_BINDING};
+
+ private static final String[] SYSTEM_REFERENCE_BINDING_PHASES =
+ {REFERENCE_BINDING_WIREFORMAT, REFERENCE_BINDING_POLICY, REFERENCE_BINDING_TRANSPORT};
+
+ private static final String[] SYSTEM_SERVICE_BINDING_PHASES =
+ {SERVICE_BINDING_TRANSPORT, SERVICE_BINDING_OPERATION_SELECTOR, SERVICE_BINDING_WIREFORMAT, SERVICE_BINDING_POLICY};
+
+ private static final String[] SYSTEM_SERVICE_PHASES =
+ {SERVICE_BINDING, SERVICE_INTERFACE, SERVICE_POLICY, SERVICE};
+
+ private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {IMPLEMENTATION_POLICY, IMPLEMENTATION};
+
+ private ExtensionPointRegistry registry;
+ private String pattern = Phase.class.getName();
+ private Map<String, Stage> stages;
+ private List<String> phases;
+
+ public class Stage {
+ private String name;
+ private PhaseSorter<String> sorter = new PhaseSorter<String>();
+ private Set<String> firstSet = new HashSet<String>();
+ private Set<String> lastSet = new HashSet<String>();
+ private List<String> phases = new ArrayList<String>();
+
+ public Stage(String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public PhaseSorter<String> getSorter() {
+ return sorter;
+ }
+
+ public Set<String> getFirstSet() {
+ return firstSet;
+ }
+
+ public Set<String> getLastSet() {
+ return lastSet;
+ }
+
+ public List<String> getPhases() {
+ return phases;
+ }
+
+ @Override
+ public String toString() {
+ return name + phases;
+ }
+ }
+
+ /**
+ * @param registry
+ */
+ public PhaseManager(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public static PhaseManager getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilityExtensionPoint.getUtility(PhaseManager.class);
+ }
+
+ // For unit test purpose
+ PhaseManager(String pattern) {
+ super();
+ this.pattern = pattern;
+ this.registry = new DefaultExtensionPointRegistry();
+ }
+
+ private List<String> getPhases(String stage) {
+ Stage s = getStages().get(stage);
+ return s == null ? null : s.getPhases();
+ }
+
+ public List<String> getReferencePhases() {
+ return getPhases(STAGE_REFERENCE);
+ }
+
+ public List<String> getServicePhases() {
+ return getPhases(STAGE_SERVICE);
+ }
+
+ public List<String> getReferenceBindingPhases() {
+ return getPhases(STAGE_REFERENCE_BINDING);
+ }
+
+ public List<String> getServiceBindingPhases() {
+ return getPhases(STAGE_SERVICE_BINDING);
+ }
+
+ public List<String> getImplementationPhases() {
+ return getPhases(STAGE_IMPLEMENTATION);
+ }
+
+ public synchronized List<String> getAllPhases() {
+ if (phases == null) {
+ phases = new ArrayList<String>();
+ phases.addAll(getReferencePhases());
+ phases.addAll(getReferenceBindingPhases());
+ phases.addAll(getServiceBindingPhases());
+ phases.addAll(getServicePhases());
+ phases.addAll(getImplementationPhases());
+ }
+ return phases;
+ }
+
+ public synchronized Map<String, Stage> getStages() {
+ if (stages != null) {
+ return stages;
+ }
+ init();
+
+ Collection<ServiceDeclaration> services;
+ try {
+ services = registry.getServiceDiscovery().getServiceDeclarations(pattern);
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ for (ServiceDeclaration d : services) {
+ if (log.isLoggable(Level.FINE)) {
+ log.fine(d.getLocation() + ": " + d.getAttributes());
+ }
+ String name = d.getAttributes().get("name");
+ if (name == null) {
+ throw new ServiceRuntimeException("Required attribute 'name' is missing.");
+ }
+ String stageName = d.getAttributes().get("stage");
+ if (stageName == null) {
+ throw new ServiceRuntimeException("Required attribute 'stage' is missing.");
+ }
+ Stage stage = stages.get(stageName);
+ if (stage == null) {
+ throw new ServiceRuntimeException("Invalid stage: " + stageName);
+ }
+ PhaseSorter<String> graph = stage.getSorter();
+ Set<String> firstSet = stage.getFirstSet(), lastSet = stage.getLastSet();
+
+ String before = d.getAttributes().get("before");
+ String after = d.getAttributes().get("after");
+ if (before != null) {
+ StringTokenizer tokenizer = new StringTokenizer(before);
+ while (tokenizer.hasMoreTokens()) {
+ String p = tokenizer.nextToken();
+ if (!"*".equals(p)) {
+ graph.addEdge(name, p);
+ } else {
+ firstSet.add(name);
+ }
+ }
+ }
+ if (after != null) {
+ StringTokenizer tokenizer = new StringTokenizer(after);
+ while (tokenizer.hasMoreTokens()) {
+ String p = tokenizer.nextToken();
+ if (!"*".equals(p)) {
+ graph.addEdge(p, name);
+ } else {
+ lastSet.add(name);
+ }
+ }
+ }
+ graph.addVertext(name);
+ if(firstSet.size()>1) {
+ log.warning("More than one phases are declared to be first: "+firstSet);
+ }
+ for (String s : firstSet) {
+ for (String v : new HashSet<String>(graph.getVertices().keySet())) {
+ if (!firstSet.contains(v)) {
+ graph.addEdge(s, v);
+ }
+ }
+ }
+ if(lastSet.size()>1) {
+ log.warning("More than one phases are declared to be the last: "+lastSet);
+ }
+ for (String s : lastSet) {
+ for (String v : new HashSet<String>(graph.getVertices().keySet())) {
+ if (!lastSet.contains(v)) {
+ graph.addEdge(v, s);
+ }
+ }
+ }
+
+ }
+
+ for (Stage s : stages.values()) {
+ List<String> phases = s.getSorter().topologicalSort(false);
+ s.getPhases().clear();
+ s.getPhases().addAll(phases);
+ }
+ if (log.isLoggable(Level.FINE)) {
+ log.fine("Stages: " + stages);
+ }
+ return stages;
+ }
+
+ private void init() {
+ stages = new HashMap<String, Stage>();
+
+ Stage referenceStage = new Stage(STAGE_REFERENCE);
+ for (int i = 1; i < SYSTEM_REFERENCE_PHASES.length; i++) {
+ referenceStage.getSorter().addEdge(SYSTEM_REFERENCE_PHASES[i - 1], SYSTEM_REFERENCE_PHASES[i]);
+ }
+ referenceStage.getLastSet().add(REFERENCE_BINDING);
+ stages.put(referenceStage.getName(), referenceStage);
+
+ Stage referenceBindingStage = new Stage(STAGE_REFERENCE_BINDING);
+ for (int i = 1; i < SYSTEM_REFERENCE_BINDING_PHASES.length; i++) {
+ referenceBindingStage.getSorter().addEdge(SYSTEM_REFERENCE_BINDING_PHASES[i - 1], SYSTEM_REFERENCE_BINDING_PHASES[i]);
+ }
+ stages.put(referenceBindingStage.getName(), referenceBindingStage);
+
+ Stage serviceBindingStage = new Stage(STAGE_SERVICE_BINDING);
+ for (int i = 1; i < SYSTEM_SERVICE_BINDING_PHASES.length; i++) {
+ serviceBindingStage.getSorter().addEdge(SYSTEM_SERVICE_BINDING_PHASES[i - 1], SYSTEM_SERVICE_BINDING_PHASES[i]);
+ }
+ stages.put(serviceBindingStage.getName(), serviceBindingStage);
+
+
+ Stage serviceStage = new Stage(STAGE_SERVICE);
+ for (int i = 1; i < SYSTEM_SERVICE_PHASES.length; i++) {
+ serviceStage.getSorter().addEdge(SYSTEM_SERVICE_PHASES[i - 1], SYSTEM_SERVICE_PHASES[i]);
+ }
+ stages.put(serviceStage.getName(), serviceStage);
+
+ Stage implementationStage = new Stage(STAGE_IMPLEMENTATION);
+ for (int i = 1; i < SYSTEM_IMPLEMENTATION_PHASES.length; i++) {
+ implementationStage.getSorter().addEdge(SYSTEM_IMPLEMENTATION_PHASES[i - 1],
+ SYSTEM_IMPLEMENTATION_PHASES[i]);
+ }
+ implementationStage.getLastSet().add(IMPLEMENTATION);
+ stages.put(implementationStage.getName(), implementationStage);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java
new file mode 100644
index 0000000000..175f3463ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Directed, weighted graph
+ *
+ * @param <V> The type of vertex object
+ * @param <E> The type of edge object
+ *
+ * @version $Rev$ $Date$
+ */
+public class PhaseSorter<V> implements Cloneable {
+ private final Map<V, Vertex> vertices = new HashMap<V, Vertex>();
+
+ /**
+ * Vertex of a graph
+ */
+ public final class Vertex {
+ private V value;
+
+ // TODO: Do we want to support multiple edges for a vertex pair? If so,
+ // we should use a List instead of Map
+ private Map<Vertex, Edge> outEdges = new HashMap<Vertex, Edge>();
+ private Map<Vertex, Edge> inEdges = new HashMap<Vertex, Edge>();
+
+ private Vertex(V value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + value + ")";
+ }
+
+ public V getValue() {
+ return value;
+ }
+
+ public Map<Vertex, Edge> getOutEdges() {
+ return outEdges;
+ }
+
+ public Map<Vertex, Edge> getInEdges() {
+ return inEdges;
+ }
+
+ }
+
+ /**
+ * An Edge connects two vertices in one direction
+ */
+ public final class Edge {
+ private Vertex sourceVertex;
+
+ private Vertex targetVertex;
+
+ public Edge(Vertex source, Vertex target) {
+ this.sourceVertex = source;
+ this.targetVertex = target;
+ }
+
+ @Override
+ public String toString() {
+ return sourceVertex + "->" + targetVertex;
+ }
+
+ public Vertex getTargetVertex() {
+ return targetVertex;
+ }
+
+ public void setTargetVertex(Vertex vertex) {
+ this.targetVertex = vertex;
+ }
+
+ public Vertex getSourceVertex() {
+ return sourceVertex;
+ }
+
+ public void setSourceVertex(Vertex sourceVertex) {
+ this.sourceVertex = sourceVertex;
+ }
+ }
+
+ public void addEdge(V source, V target) {
+ Vertex s = getVertex(source);
+ if (s == null) {
+ s = new Vertex(source);
+ vertices.put(source, s);
+ }
+ Vertex t = getVertex(target);
+ if (t == null) {
+ t = new Vertex(target);
+ vertices.put(target, t);
+ }
+ Edge edge = new Edge(s, t);
+ s.outEdges.put(t, edge);
+ t.inEdges.put(s, edge);
+ }
+
+ public void addVertext(V source) {
+ Vertex s = getVertex(source);
+ if (s == null) {
+ s = new Vertex(source);
+ vertices.put(source, s);
+ }
+ }
+
+ public Vertex getVertex(V source) {
+ Vertex s = vertices.get(source);
+ return s;
+ }
+
+ public boolean removeEdge(V source, V target) {
+ Vertex s = getVertex(source);
+ if (s == null) {
+ return false;
+ }
+
+ Vertex t = getVertex(target);
+ if (t == null) {
+ return false;
+ }
+
+ return s.outEdges.remove(t) != null && t.inEdges.remove(s) != null;
+
+ }
+
+ public void removeEdge(Edge edge) {
+ edge.sourceVertex.outEdges.remove(edge.targetVertex);
+ edge.targetVertex.inEdges.remove(edge.sourceVertex);
+ }
+
+ public void removeVertex(Vertex vertex) {
+ vertices.remove(vertex.getValue());
+ for (Edge e : new ArrayList<Edge>(vertex.outEdges.values())) {
+ removeEdge(e);
+ }
+ for (Edge e : new ArrayList<Edge>(vertex.inEdges.values())) {
+ removeEdge(e);
+ }
+ }
+
+ public Edge getEdge(Vertex source, Vertex target) {
+ return source.outEdges.get(target);
+ }
+
+ public Edge getEdge(V source, V target) {
+ Vertex sv = getVertex(source);
+ if (sv == null) {
+ return null;
+ }
+ Vertex tv = getVertex(target);
+ if (tv == null) {
+ return null;
+ }
+ return getEdge(getVertex(source), getVertex(target));
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ for (Vertex v : vertices.values()) {
+ sb.append(v.outEdges.values()).append("\n");
+ }
+ return sb.toString();
+ }
+
+ public Map<V, Vertex> getVertices() {
+ return vertices;
+ }
+
+ public void addGraph(PhaseSorter<V> otherGraph) {
+ for (Vertex v : otherGraph.vertices.values()) {
+ for (Edge e : v.outEdges.values()) {
+ addEdge(e.sourceVertex.value, e.targetVertex.value);
+ }
+ }
+ }
+
+ private Vertex getFirst() {
+ for (Vertex v : vertices.values()) {
+ if (v.inEdges.isEmpty()) {
+ return v;
+ }
+ }
+ if (!vertices.isEmpty()) {
+ throw new IllegalArgumentException("Circular ordering has been detected: " + toString());
+ } else {
+ return null;
+ }
+ }
+
+ public List<V> topologicalSort(boolean readOnly) {
+ PhaseSorter<V> graph = (!readOnly) ? this : (PhaseSorter<V>)clone();
+ List<V> list = new ArrayList<V>();
+ while (true) {
+ Vertex v = graph.getFirst();
+ if (v == null) {
+ break;
+ }
+ list.add(v.getValue());
+ graph.removeVertex(v);
+ }
+
+ return list;
+ }
+
+ @Override
+ public Object clone() {
+ PhaseSorter<V> copy = new PhaseSorter<V>();
+ copy.addGraph(this);
+ return copy;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
new file mode 100644
index 0000000000..96d44b3bc2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
@@ -0,0 +1,875 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.runtime.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.util.Audit;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * A builder that takes endpoint references and resolves them. It either finds local
+ * service endpoints if they are available or asks the domain. The main function here
+ * is to perform binding and policy matching.
+ *
+ * This is a separate from the builders so that the mechanism for reference/service matching
+ * can be used at runtime as well as build time and can also be replaced independently
+ *
+ * @version $Rev$ $Date$
+ */
+public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
+ private static final Logger logger = Logger.getLogger(EndpointReferenceBinderImpl.class.getName());
+
+ protected ExtensionPointRegistry extensionPoints;
+ protected AssemblyFactory assemblyFactory;
+ protected InterfaceContractMapper interfaceContractMapper;
+ protected BuilderExtensionPoint builders;
+ protected CompositeActivator compositeActivator;
+ protected Monitor monitor;
+
+
+ public EndpointReferenceBinderImpl(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+ UtilityExtensionPoint utils = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utils.getUtility(InterfaceContractMapper.class);
+
+ MonitorFactory monitorFactory = utils.getUtility(MonitorFactory.class);
+ monitor = monitorFactory.createMonitor();
+
+ this.builders = extensionPoints.getExtensionPoint(BuilderExtensionPoint.class);
+ this.compositeActivator = extensionPoints.getExtensionPoint(CompositeActivator.class);
+ }
+
+ /**
+ * Bind a single endpoint reference at build time. Here we only expect the
+ * registry to have a record of local endpoints
+ *
+ * @param endpointRegistry
+ * @param endpointReference
+ */
+ public void bindBuildTime(EndpointRegistry endpointRegistry,
+ EndpointReference endpointReference) {
+ bind(endpointRegistry, endpointReference, false);
+ }
+
+ /**
+ * Bind a single endpoint reference at build time. Here we expect the
+ * registry to be populated with endpoints from across the domain
+ *
+ * @param endpointRegistry
+ * @param endpointReference
+ */
+ public void bindRunTime(EndpointRegistry endpointRegistry,
+ EndpointReference endpointReference) {
+ bind(endpointRegistry, endpointReference, true);
+ }
+
+ /**
+ * Bind a reference to a service endpoint
+ *
+ * @param endpointRegistry
+ * @param endpointReference
+ * @param runtime set true if called from the runtime
+ */
+ public void bind(EndpointRegistry endpointRegistry,
+ EndpointReference endpointReference,
+ boolean runtime){
+
+ logger.fine("Binding " + endpointReference.toString());
+
+ Audit matchAudit = new Audit();
+
+ // This logic does post build autowire matching but isn't actually used at the moment
+ // as problems with dependencies mean we still do this during build
+ if (endpointReference.getStatus() == EndpointReference.Status.AUTOWIRE_PLACEHOLDER){
+
+ // do autowire matching
+ // will only be called at build time at the moment
+ Multiplicity multiplicity = endpointReference.getReference().getMultiplicity();
+ for (Endpoint endpoint : endpointRegistry.getEndpoints()){
+// if (endpoint is in the same composite as endpoint reference){
+ if ((multiplicity == Multiplicity.ZERO_ONE ||
+ multiplicity == Multiplicity.ONE_ONE) &&
+ (endpointReference.getReference().getEndpointReferences().size() > 1)) {
+ break;
+ }
+
+ // Prevent autowire connecting to self
+ if (endpointReference.getComponent() ==
+ endpoint.getComponent()) {
+ continue;
+ }
+
+ if (haveMatchingPolicy(endpointReference, endpoint, matchAudit) &&
+ haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit)){
+ // matching service so find if this reference already has
+ // an endpoint reference for this endpoint
+ Endpoint autowireEndpoint = null;
+
+ for (EndpointReference epr : endpointReference.getReference().getEndpointReferences()){
+ if (epr.getTargetEndpoint() == endpoint){
+ autowireEndpoint = endpoint;
+ break;
+ }
+ }
+
+ if (autowireEndpoint == null){
+ // create new EPR for autowire
+ EndpointReference autowireEndpointRefrence = null;
+ try {
+ autowireEndpointRefrence = (EndpointReference)endpointReference.clone();
+ } catch (Exception ex){
+ // won't happen as clone is supported
+ }
+
+ autowireEndpointRefrence.setTargetEndpoint(endpoint);
+ autowireEndpointRefrence.setBinding(endpoint.getBinding());
+ autowireEndpointRefrence.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ endpointReference.getReference().getEndpointReferences().add(autowireEndpointRefrence);
+ }
+ }
+// }
+ }
+
+ if (multiplicity == Multiplicity.ONE_N || multiplicity == Multiplicity.ONE_ONE) {
+ if (endpointReference.getReference().getEndpointReferences().size() == 1) {
+ Monitor.error(monitor,
+ this,
+ "endpoint-validation-messages",
+ "NoComponentReferenceTarget",
+ endpointReference.getReference().getName());
+ throw new ServiceRuntimeException("Unable to bind " +
+ monitor.getLastProblem().toString());
+ }
+ }
+
+ setSingleAutoWireTarget(endpointReference.getReference());
+
+ } else if ( endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED||
+ endpointReference.getStatus() == EndpointReference.Status.RESOLVED_BINDING ) {
+ // The endpoint reference is already resolved to either
+ // a service endpoint local to this composite or it has
+ // a remote binding
+
+ // still need to check that the callback endpoint is set correctly
+ if (hasCallback(endpointReference) &&
+ (endpointReference.getCallbackEndpoint() == null
+ || endpointReference.getCallbackEndpoint().isUnresolved())) {
+ selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService(),
+ matchAudit);
+ }
+ } else if (endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_FOUND_READY_FOR_MATCHING ){
+ // The endpoint reference is already resolved to either
+ // a service endpoint but no binding was specified in the
+ // target URL and/or the policies have yet to be matched.
+ // TODO - is this really required now
+
+ selectForwardEndpoint(endpointReference,
+ endpointReference.getTargetEndpoint().getService().getEndpoints(),
+ matchAudit);
+
+ if (hasCallback(endpointReference)){
+ selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService(),
+ matchAudit);
+ }
+ } else if (endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_IN_BINDING_URI ||
+ endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_NOT_FOUND ||
+ endpointReference.getStatus() == EndpointReference.Status.NOT_CONFIGURED){
+ // The reference is not yet matched to a service
+
+ // find the service in the endpoint registry
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+
+ if ((endpoints.size() == 0) &&
+ (runtime == true) ) {
+
+ // tweak to test if this could be a resolve binding. This is the back end of the test
+ // in the builder that pulls the URI out of the binding if there are no targets
+ // on the reference. have to wait until here to see if the binding uri matches any
+ // available services. If not we assume here that it's a resolved binding
+ if (endpointReference.getStatus() == EndpointReference.Status.WIRED_TARGET_IN_BINDING_URI){
+ endpointReference.getTargetEndpoint().setBinding(endpointReference.getBinding());
+ endpointReference.setStatus(EndpointReference.Status.RESOLVED_BINDING);
+ } else {
+ Monitor.error(monitor,
+ this,
+ "endpoint-validation-messages",
+ "NoEndpointsFound",
+ endpointReference.toString());
+ throw new ServiceRuntimeException("Unable to bind " +
+ monitor.getLastProblem().toString());
+ }
+ }
+
+ selectForwardEndpoint(endpointReference,
+ endpoints,
+ matchAudit);
+
+ if (hasCallback(endpointReference)){
+ selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService(),
+ matchAudit);
+ }
+ }
+
+ logger.fine(matchAudit.toString());
+
+ if (endpointReference.getStatus() != EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED &&
+ endpointReference.getStatus() != EndpointReference.Status.RESOLVED_BINDING){
+
+ if (runtime){
+ Monitor.error(monitor,
+ this,
+ "endpoint-validation-messages",
+ "EndpointReferenceCantBeMatched",
+ endpointReference.toString(),
+ matchAudit);
+ } else {
+ Monitor.warning(monitor,
+ this,
+ "endpoint-validation-messages",
+ "ComponentReferenceTargetNotFound",
+ endpointReference.toString());
+ }
+
+ throw new ServiceRuntimeException("Unable to bind " +
+ monitor.getLastProblem().toString());
+ }
+
+ // Now the endpoint reference is resolved check that the binding interfaces contract
+ // and the reference contract are compatible
+ ((RuntimeEndpointReference)endpointReference).validateReferenceInterfaceCompatibility();
+
+ // System.out.println("MATCH AUDIT:" + matchAudit.toString());
+ }
+
+ /**
+ * Returns true if the reference has a callback
+ */
+ private boolean hasCallback(EndpointReference endpointReference){
+ if (endpointReference.getReference().getInterfaceContract() == null ||
+ endpointReference.getReference().getInterfaceContract().getCallbackInterface() == null ||
+ endpointReference.getReference().getName().startsWith("$self$.")){
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Selects a forward endpoint from a list of possible candidates
+ *
+ * @param endpointReference
+ * @param endpoints
+ */
+ private void selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints, Audit matchAudit) {
+
+ Endpoint matchedEndpoint = null;
+
+ if (endpointReference.getReference().getName().startsWith("$self$.")){
+ // just select the first one and don't do any policy matching
+ matchedEndpoint = endpoints.get(0);
+ } else {
+ // find the first endpoint that matches this endpoint reference
+ for (Endpoint endpoint : endpoints){
+ if (haveMatchingPolicy(endpointReference, endpoint, matchAudit) &&
+ haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit)){
+ matchedEndpoint = endpoint;
+ break;
+ }
+ }
+ }
+
+ if (matchedEndpoint == null){
+ return;
+ } else {
+ endpointReference.setTargetEndpoint(matchedEndpoint);
+ Binding binding = endpointReference.getTargetEndpoint().getBinding();
+ endpointReference.setBinding(binding);
+ build(endpointReference);
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+ endpointReference.setUnresolved(false);
+ }
+ }
+
+ private void build(EndpointReference endpointReference) {
+ BindingBuilder builder = builders.getBindingBuilder(endpointReference.getBinding().getType());
+ if (builder != null) {
+ builder.build(endpointReference.getComponent(),
+ endpointReference.getReference(),
+ endpointReference.getBinding(),
+ new BuilderContext(extensionPoints),
+ false);
+ }
+ }
+
+ /**
+ * Selects a callback endpoint from a list of possible candidates
+ *
+ * @param endpointReference
+ * @param endpoints
+ */
+ private void selectCallbackEndpoint(EndpointReference endpointReference, ComponentService callbackService, Audit matchAudit) {
+
+ // find the first callback endpoint that matches a callback endpoint reference
+ // at the service
+ RuntimeEndpoint callbackEndpoint = null;
+ match:
+ for ( EndpointReference callbackEndpointReference : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
+ for (Endpoint endpoint : callbackService.getEndpoints()){
+ if (haveMatchingPolicy(callbackEndpointReference, endpoint, matchAudit) &&
+ haveMatchingInterfaceContracts(callbackEndpointReference, endpoint, matchAudit)){
+ callbackEndpoint = (RuntimeEndpoint)endpoint;
+ break match;
+ }
+ }
+ }
+
+ // if no callback endpoint was found or if the binding is the SCA binding and it doesn't match
+ // the forward binding then create a new callback endpoint
+ // TODO - there is a hole here in that the user may explicitly specify an SCA binding for the
+ // callback that is different from the forward binding. Waiting for feedback form OASIS
+ // before doing more drastic surgery to fix this corner case as there are other things
+ // wrong with the default case, such as what to do about policy
+ if (callbackEndpoint == null ||
+ (callbackEndpoint.getBinding().getType().equals(SCABinding.TYPE) &&
+ !endpointReference.getBinding().getType().equals(SCABinding.TYPE))){
+ // no endpoint in place so we need to create one
+ callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
+ callbackEndpoint.setComponent(endpointReference.getComponent());
+ callbackEndpoint.setService(callbackService);
+
+ Binding forwardBinding = endpointReference.getBinding();
+ Binding callbackBinding = null;
+ for (EndpointReference callbackEPR : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
+ if (callbackEPR.getBinding().getType().equals(forwardBinding.getType())){
+ try {
+ callbackBinding = (Binding)callbackEPR.getBinding().clone();
+ } catch (CloneNotSupportedException ex){
+
+ }
+ break;
+ }
+ }
+
+ // get the callback binding URI by looking at the SCA binding
+ // that will have been added at build time
+ callbackBinding.setURI(null);
+ for (Endpoint endpoint : callbackService.getEndpoints()){
+ if (endpoint.getBinding().getType().equals(SCABinding.TYPE)){
+ callbackBinding.setURI(endpoint.getBinding().getURI());
+ }
+ }
+
+ callbackEndpoint.setBinding(callbackBinding);
+ callbackService.getBindings().add(callbackBinding);
+
+ callbackEndpoint.setUnresolved(false);
+ callbackService.getEndpoints().add(callbackEndpoint);
+
+ // build it
+ build(callbackEndpoint);
+
+ // activate it
+ compositeActivator.activate(((RuntimeEndpointReferenceImpl)endpointReference).getCompositeContext(),
+ callbackEndpoint);
+
+ // start it
+ compositeActivator.start(((RuntimeEndpointReferenceImpl)endpointReference).getCompositeContext(),
+ callbackEndpoint);
+ }
+
+ endpointReference.setCallbackEndpoint(callbackEndpoint);
+ }
+
+ private void build(Endpoint endpoint) {
+
+ BindingBuilder builder = builders.getBindingBuilder(endpoint.getBinding().getType());
+ if (builder != null) {
+ builder.build(endpoint.getComponent(),
+ endpoint.getService(),
+ endpoint.getBinding(),
+ new BuilderContext(extensionPoints),
+ true);
+ }
+ }
+
+ /**
+ * Determine if endpoint reference and endpoint policies match. We know by this stage
+ * that
+ * - a given policy set will only contain expressions from a single language
+ * - a given endpoint or endpoint reference's policy sets will only contain
+ * expressions from a single language
+ *
+ * Matching algorithm (read from the top down):
+ * - FAIL if there are intents that are mutually exclusive between reference and service
+ * - PASS if there are no intents or policies present at reference and service
+ * - FAIL if there are unresolved intents (intents with no policy set) at the reference (service should have been checked previously)
+ * - PASS if there are no policies at reference and service (now we know all intents are resolved)
+ * - FAIL if there are some policies on one side but not on the other
+ * - PASS if the QName of the policy sets on each side match
+ * - FAIL if the policy languages on both sides are different
+ * - Perform policy specific match
+ *
+ */
+ private boolean haveMatchingPolicy(EndpointReference endpointReference, Endpoint endpoint, Audit matchAudit){
+ matchAudit.append("Match policy of " + endpointReference.toString() + " to " + endpoint.toString() + " ");
+
+ List<PolicySet> referencePolicySets = new ArrayList<PolicySet>();
+ Binding binding = null;
+
+ if (endpointReference.getBinding() == null){
+ binding = endpoint.getBinding();
+ } else {
+ binding = endpointReference.getBinding();
+ }
+
+ // if there are any intents that are mutually exclusive between
+ // service and reference then they don't match
+ for (Intent eprIntent : endpointReference.getRequiredIntents()){
+ for (Intent epIntent : endpoint.getRequiredIntents()){
+ if (eprIntent.getExcludedIntents().contains(epIntent) ||
+ epIntent.getExcludedIntents().contains(eprIntent) ||
+ checkQualifiedMutualExclusion(eprIntent.getExcludedIntents(), epIntent) ||
+ checkQualifiedMutualExclusion(epIntent.getExcludedIntents(), eprIntent)){
+ matchAudit.append("No match because the following intents are mutually exclusive " +
+ eprIntent.toString() +
+ " " +
+ epIntent.toString() +
+ " ");
+ matchAudit.appendSeperator();
+ return false;
+ }
+ }
+ }
+
+ // Find the set of policy sets from this reference. This includes
+ // the policy sets that are specific to the service binding and
+ // any policy sets that are not binding specific
+ for (PolicySet policySet : endpointReference.getPolicySets()){
+ PolicyBuilder policyBuilder = null;
+
+ if (policySet.getPolicies().size() > 0){
+ QName policyType = policySet.getPolicies().get(0).getName();
+ policyBuilder = builders.getPolicyBuilder(policyType);
+ }
+
+ if ((policyBuilder == null) ||
+ (policyBuilder != null && policyBuilder.getSupportedBindings() == null) ||
+ (policyBuilder != null && policyBuilder.getSupportedBindings().contains(binding.getType()))){
+ referencePolicySets.add(policySet);
+ }
+ }
+
+ // the "appliesTo" algorithm to remove any policy sets that
+ // don't apply to the service binding will already have been
+ // run during the build phase
+
+ // Determine if there are any reference policies
+ boolean noEndpointReferencePolicies = true;
+
+ for (PolicySet policySet : referencePolicySets){
+ if (policySet.getPolicies().size() > 0){
+ noEndpointReferencePolicies = false;
+ break;
+ }
+ }
+
+ // Determine of there are any service policies
+ boolean noEndpointPolicies = true;
+
+ for (PolicySet policySet : endpoint.getPolicySets()){
+ if (policySet.getPolicies().size() > 0){
+ noEndpointPolicies = false;
+ break;
+ }
+ }
+
+ // if no policy sets or intents are present then they match
+ if ((endpointReference.getRequiredIntents().size() == 0) &&
+ (endpoint.getRequiredIntents().size() == 0) &&
+ (noEndpointReferencePolicies) &&
+ (noEndpointPolicies)) {
+ matchAudit.append("Match because there are no intents or policies ");
+ matchAudit.appendSeperator();
+ return true;
+ }
+
+ // check that the intents on the reference side are resolved
+ // can't do this until this point as the service binding
+ // may come into play. Intents may be satisfied by the default
+ // or optional intents that the binding type provides. Failing
+ // this they must be satisfied by reference policy sets
+ // Failing this the intent is unresolved and the reference and
+ // service don't match
+
+
+
+ // TODO - seems that we should do this loop on a binding by binding basis
+ // rather than each time we do matching
+ BindingType bindingType = null;
+ Definitions systemDefinitions = ((RuntimeEndpoint)endpoint).getCompositeContext().getSystemDefinitions();
+ for (BindingType loopBindingType : systemDefinitions.getBindingTypes()){
+ if (loopBindingType.getType().equals(binding.getType())){
+ bindingType = loopBindingType;
+ break;
+ }
+ }
+
+ // Before we start examining intents, remove any whose constrained
+ // types don't include the binding type
+ removeConstrainedIntents(endpointReference, bindingType);
+
+ List<Intent> eprIntents = new ArrayList<Intent>();
+ eprIntents.addAll(endpointReference.getRequiredIntents());
+
+ // first check the binding type
+ for (Intent intent : endpointReference.getRequiredIntents()){
+ if (bindingType != null &&
+ bindingType.getAlwaysProvidedIntents().contains(intent)){
+ eprIntents.remove(intent);
+ } else if (bindingType != null &&
+ bindingType.getMayProvidedIntents().contains(intent)){
+ eprIntents.remove(intent);
+ } else {
+ // TODO - this code also appears in the ComponentPolicyBuilder
+ // so should rationalize
+ loop: for (PolicySet policySet : referencePolicySets){
+ if (policySet.getProvidedIntents().contains(intent)){
+ eprIntents.remove(intent);
+ break;
+ }
+
+ for (Intent psProvidedIntent : policySet.getProvidedIntents()){
+ if (isQualifiedBy(psProvidedIntent, intent)){
+ eprIntents.remove(intent);
+ break loop;
+ }
+ }
+
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (intent.equals(q.getIntent())) {
+ eprIntents.remove(intent);
+ break loop;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // if there are unresolved intents the service and reference don't match
+ if (eprIntents.size() > 0){
+ matchAudit.append("No match because there are unresolved intents " + eprIntents.toString() + " ");
+ matchAudit.appendSeperator();
+ return false;
+ }
+
+ // if there are no policies on epr or ep side then
+ // they match
+ if (noEndpointPolicies && noEndpointReferencePolicies){
+ matchAudit.append("Match because the intents are resolved and there are no policy sets ");
+ matchAudit.appendSeperator();
+ return true;
+ }
+
+ // if there are some policies on one side and not the other then
+ // the don't match
+ if (noEndpointPolicies && !noEndpointReferencePolicies) {
+ matchAudit.append("No match because there are policy sets at the endpoint reference but not at the endpoint ");
+ matchAudit.appendSeperator();
+ return false;
+ }
+
+ if (!noEndpointPolicies && noEndpointReferencePolicies){
+ matchAudit.append("No match because there are policy sets at the endpoint but not at the endpoint reference ");
+ matchAudit.appendSeperator();
+ return false;
+ }
+
+ // If policy set QNames from epr and er match exactly then the reference and
+ // service policies are compatible
+ Set<PolicySet> referencePolicySet = new HashSet<PolicySet>(referencePolicySets);
+ Set<PolicySet> servicePolicySet = new HashSet<PolicySet>(endpoint.getPolicySets());
+ if(referencePolicySet.equals(servicePolicySet)){
+ matchAudit.append("Match because the policy sets on both sides are eactly the same ");
+ matchAudit.appendSeperator();
+ return true;
+ }
+
+ // if policy set language at ep and epr are not the same then there is no
+ // match. We get the policy language by looking at the first expression
+ // of the first policy set. By this stage we know that all the policy sets
+ // in an endpoint or endpoint reference will use a single language and we know
+ // that there is at least one policy set with at least one policy
+ QName eprLanguage = null;
+
+ for (PolicySet policySet : referencePolicySets){
+ if (policySet.getPolicies().size() > 0){
+ eprLanguage = policySet.getPolicies().get(0).getName();
+ break;
+ }
+ }
+
+ QName epLanguage = null;
+
+ for (PolicySet policySet : endpoint.getPolicySets()){
+ if (policySet.getPolicies().size() > 0){
+ epLanguage = policySet.getPolicies().get(0).getName();
+ break;
+ }
+ }
+
+ if(!eprLanguage.equals(epLanguage)){
+ matchAudit.append("No match because the policy sets on either side have policies in differnt languages " +
+ eprLanguage +
+ " and " +
+ epLanguage +
+ " ");
+ matchAudit.appendSeperator();
+ return false;
+ }
+
+ // now do a policy specific language match
+ PolicyBuilder builder = builders.getPolicyBuilder(eprLanguage);
+ boolean match = false;
+
+ // switch the derived list of policy sets into the reference
+ // it will be left there if there is a match
+ List<PolicySet> originalPolicySets = endpointReference.getPolicySets();
+ endpointReference.getPolicySets().clear();
+ endpointReference.getPolicySets().addAll(referencePolicySets);
+
+ if (builder != null) {
+ // TODO - where to get builder context from?
+ BuilderContext builderContext = new BuilderContext(monitor);
+
+ match = builder.build(endpointReference, endpoint, builderContext);
+ }
+
+ if (!match){
+ matchAudit.append("No match because the language specific matching failed ");
+ matchAudit.appendSeperator();
+ endpointReference.getPolicySets().clear();
+ endpointReference.getPolicySets().addAll(originalPolicySets);
+ } else {
+ matchAudit.append("Match because the language specific matching succeeded ");
+ matchAudit.appendSeperator();
+ }
+
+ return match;
+ }
+
+ // Copied from ComponentPolicyBuilder, should probably be refactored
+ protected void removeConstrainedIntents(EndpointReference subject, BindingType bindingType) {
+ List<Intent> intents = subject.getRequiredIntents();
+
+ // Remove the intents whose @contrains do not include the current element
+ if(bindingType != null){
+ List<Intent> copy = new ArrayList<Intent>(intents);
+ for (Intent i : copy) {
+ List<ExtensionType> constrainedTypes = i.getConstrainedTypes();
+ if (( constrainedTypes.size() == 0 ) && ( i.getQualifiableIntent() != null ) )
+ constrainedTypes = i.getQualifiableIntent().getConstrainedTypes();
+
+ if (constrainedTypes.size() > 0){
+ boolean constraintFound = false;
+ for (ExtensionType constrainedType : i.getConstrainedTypes()){
+ if (constrainedType.getType().equals(bindingType.getType()) ||
+ constrainedType.getType().equals(bindingType.getBaseType())){
+ constraintFound = true;
+ break;
+ }
+ }
+ if(!constraintFound){
+ intents.remove(i);
+ }
+ }
+ }
+ }
+ }
+
+
+ protected boolean isQualifiedBy(Intent qualifiableIntent, Intent qualifiedIntent){
+ if (qualifiedIntent.getQualifiableIntent() == qualifiableIntent){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ protected boolean checkQualifiedMutualExclusion(List<Intent> excludedIntentList, Intent intent){
+ for (Intent excludedIntent : excludedIntentList){
+ if (intent.getQualifiableIntent() != null &&
+ excludedIntent != null &&
+ intent.getQualifiableIntent().equals(excludedIntent)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Determine if endpoint reference and endpoint interface contracts match
+ */
+ private boolean haveMatchingInterfaceContracts(EndpointReference endpointReference, Endpoint endpoint, Audit matchAudit){
+ matchAudit.append("Match interface of " + endpointReference.toString() + " to " + endpoint.toString() + " ");
+
+ InterfaceContract endpointReferenceContract = endpointReference.getReference().getInterfaceContract();
+ InterfaceContract endpointContract = endpoint.getComponentServiceInterfaceContract();
+
+ if (endpointReferenceContract == null){
+ matchAudit.append("Match because there is no interface contract on the reference ");
+ matchAudit.appendSeperator();
+ return true;
+ }
+
+ // TODO - is there a better test for this. Would have to cast to the
+ // correct iface type to get to the resolved flag
+ // We need to rely on normailzed interfaces in this case!!
+ if (endpointContract.getInterface().getOperations().size() == 0){
+ // the interface contract is likely remote but unresolved
+ // we discussed this on the ML and decided that we could
+ // live with this for the case where there is no central matching of references
+ // to services. Any errors will be detected when the message flows.
+ matchAudit.append("Match because the endpoint is remote and we don't have a copy of it's interface contract ");
+ matchAudit.appendSeperator();
+ return true;
+ }
+
+ // If the contracts are not of the same type or normalized interfaces are available
+ // use them
+ if (endpointReferenceContract.getClass() != endpointContract.getClass() ||
+ endpointReferenceContract.getNormalizedWSDLContract() != null ||
+ endpointContract.getNormalizedWSDLContract() != null) {
+ endpointReferenceContract = ((RuntimeEndpointReference)endpointReference).getGeneratedWSDLContract(endpointReferenceContract);
+ endpointContract = ((RuntimeEndpoint)endpoint).getGeneratedWSDLContract(endpointContract);
+ }
+
+ boolean match = false;
+ match = interfaceContractMapper.isCompatibleSubset(endpointReferenceContract,
+ endpointContract,
+ matchAudit);
+
+ if (!match){
+ matchAudit.append("Match failed because the interface contract mapper failed ");
+ } else {
+ matchAudit.append("Match because the interface contract mapper succeeded ");
+ }
+
+ matchAudit.appendSeperator();
+
+ return match;
+ }
+
+ /**
+ * Checks to see if the registry has been updated since the reference was last matched
+ *
+ * @return true is the registry has changed
+ */
+ public boolean isOutOfDate(EndpointRegistry endpointRegistry, EndpointReference endpointReference) {
+ Endpoint te = endpointReference.getTargetEndpoint();
+ if (te != null && !te.isUnresolved()
+ && te.getURI() != null
+ && endpointReference.getStatus() != EndpointReference.Status.RESOLVED_BINDING) {
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+ return ! endpoints.contains(endpointReference.getTargetEndpoint());
+ }
+ return false;
+ }
+
+ /**
+ * ASM_5021: where a <reference/> of a <component/> has @autowire=true
+ * and where the <reference/> has a <binding/> child element which
+ * declares a single target service, the reference is wired only to
+ * the single service identified by the <wire/> element
+ */
+ private void setSingleAutoWireTarget(ComponentReference reference) {
+ if (reference.getEndpointReferences().size() > 1 && reference.getBindings() != null
+ && reference.getBindings().size() == 1) {
+ String uri = reference.getBindings().get(0).getURI();
+ if (uri != null) {
+ if (uri.indexOf('/') > -1) {
+ // TODO: must be a way to avoid this fiddling
+ int i = uri.indexOf('/');
+ String c = uri.substring(0, i);
+ String s = uri.substring(i + 1);
+ uri = c + "#service(" + s + ")";
+ }
+ for (EndpointReference er : reference.getEndpointReferences()) {
+ if (er.getTargetEndpoint() != null && uri.equals(er.getTargetEndpoint().getURI())) {
+ reference.getEndpointReferences().clear();
+ reference.getEndpointReferences().add(er);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.java
new file mode 100644
index 0000000000..cd8bc936af
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/RuntimePropertiesImpl.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 org.apache.tuscany.sca.core.runtime.impl;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+public class RuntimePropertiesImpl implements RuntimeProperties {
+
+ private Properties properties = new Properties();
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java
new file mode 100644
index 0000000000..4674456925
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.scope;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Implements functionality common to scope contexts.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractScopeContainer<KEY> implements ScopeContainer<KEY> {
+ protected Map<KEY, InstanceWrapper<?>> wrappers = new ConcurrentHashMap<KEY, InstanceWrapper<?>>();
+ protected final Scope scope;
+
+ protected RuntimeComponent component;
+ protected volatile int lifecycleState = UNINITIALIZED;
+
+
+ public AbstractScopeContainer(Scope scope, RuntimeComponent component) {
+ this.scope = scope;
+ this.component = component;
+ }
+
+ protected void checkInit() {
+ if (getLifecycleState() != RUNNING) {
+ throw new IllegalStateException("Scope container not running [" + getLifecycleState() + "]");
+ }
+ }
+
+ /**
+ * Creates a new physical instance of a component, wrapped in an
+ * InstanceWrapper.
+ *
+ * @param component the component whose instance should be created
+ * @return a wrapped instance that has been injected but not yet started
+ * @throws TargetResolutionException if there was a problem creating the
+ * instance
+ */
+ protected InstanceWrapper createInstanceWrapper() throws TargetResolutionException {
+ ImplementationProvider implementationProvider = component.getImplementationProvider();
+ if (implementationProvider instanceof ScopedImplementationProvider) {
+ return ((ScopedImplementationProvider)implementationProvider).createInstanceWrapper();
+ }
+ return null;
+ }
+
+ public InstanceWrapper getAssociatedWrapper(KEY contextId) throws TargetResolutionException {
+ return getWrapper(contextId); // TODO: what is this method supposed to do diff than getWrapper?
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException {
+ return wrappers.get(contextId);
+ }
+
+ public void addWrapperReference(KEY existingContextId, KEY newContextId)
+ throws TargetResolutionException {
+ // do nothing here. the conversational scope container implements this
+ }
+
+ public void registerWrapper(InstanceWrapper wrapper, KEY contextId) throws TargetResolutionException {
+ // do nothing here. the conversational scope container implements this
+ }
+
+ protected boolean isEagerInit() {
+ ImplementationProvider implementationProvider = ((RuntimeComponent)component).getImplementationProvider();
+ if (implementationProvider instanceof ScopedImplementationProvider) {
+ return ((ScopedImplementationProvider)implementationProvider).isEagerInit();
+ }
+ return false;
+ }
+
+ public void returnWrapper(InstanceWrapper wrapper, KEY contextId) throws TargetDestructionException {
+ }
+
+ /**
+ * Default implementation of remove which does nothing
+ *
+ * @param contextId the identifier of the context to remove.
+ */
+ public void remove(KEY contextId)
+ throws TargetDestructionException {
+ }
+
+ public synchronized void start() {
+ int lifecycleState = getLifecycleState();
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
+ }
+ setLifecycleState(RUNNING);
+ }
+
+ public void startContext(KEY contextId) {
+ if(isEagerInit()) {
+ try {
+ getWrapper(contextId);
+ } catch (TargetResolutionException e) {
+ //
+ }
+ }
+ }
+
+ public synchronized void stop() {
+ int lifecycleState = getLifecycleState();
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]");
+ }
+ setLifecycleState(STOPPED);
+ }
+
+ public void stopContext(KEY contextId) {
+ wrappers.remove(contextId);
+ }
+
+ @Override
+ public String toString() {
+ String s;
+ switch (lifecycleState) {
+ case ScopeContainer.CONFIG_ERROR:
+ s = "CONFIG_ERROR";
+ break;
+ case ScopeContainer.ERROR:
+ s = "ERROR";
+ break;
+ case ScopeContainer.INITIALIZING:
+ s = "INITIALIZING";
+ break;
+ case ScopeContainer.INITIALIZED:
+ s = "INITIALIZED";
+ break;
+ case ScopeContainer.RUNNING:
+ s = "RUNNING";
+ break;
+ case ScopeContainer.STOPPING:
+ s = "STOPPING";
+ break;
+ case ScopeContainer.STOPPED:
+ s = "STOPPED";
+ break;
+ case ScopeContainer.UNINITIALIZED:
+ s = "UNINITIALIZED";
+ break;
+ default:
+ s = "UNKNOWN";
+ break;
+ }
+ return "In state [" + s + ']';
+ }
+
+ public RuntimeComponent getComponent() {
+ return component;
+ }
+
+ public void setComponent(RuntimeComponent component) {
+ this.component = component;
+ }
+
+ public int getLifecycleState() {
+ return lifecycleState;
+ }
+
+ /**
+ * Set the current state of the Lifecycle.
+ *
+ * @param lifecycleState the new state
+ */
+ protected void setLifecycleState(int lifecycleState) {
+ this.lifecycleState = lifecycleState;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
new file mode 100644
index 0000000000..2ea724ccf6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.scope;
+
+import org.apache.tuscany.sca.core.scope.impl.CompositeScopeContainerFactory;
+import org.apache.tuscany.sca.core.scope.impl.ScopeRegistryImpl;
+import org.apache.tuscany.sca.core.scope.impl.StatelessScopeContainerFactory;
+
+/**
+ * A default scope registry implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultScopeRegistry extends ScopeRegistryImpl implements ScopeRegistry {
+
+ public DefaultScopeRegistry() {
+ ScopeContainerFactory[] factories =
+ new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), new StatelessScopeContainerFactory()};
+ for (ScopeContainerFactory f : factories) {
+ register(f);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java
new file mode 100644
index 0000000000..35da433af0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.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.sca.core.scope;
+
+/**
+ * The default implementation scopes supported by assemblies.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class Scope {
+ public static final Scope STATELESS = new Scope("STATELESS");
+ public static final Scope COMPOSITE = new Scope("COMPOSITE");
+ public static final Scope INVALID = new Scope("INVALID");
+
+ private String scope;
+
+ public Scope(String scope) {
+ this.scope = scope.toUpperCase().intern();
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ final Scope scope1 = (Scope) o;
+ return !(scope != null ? scope != scope1.scope.intern() : scope1.scope != null);
+ }
+
+ @Override
+ public int hashCode() {
+ return scope != null ? scope.hashCode() : 0;
+ }
+
+ @Override
+ public String toString() {
+ return scope;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java
new file mode 100644
index 0000000000..7d34a0144b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.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.sca.core.scope;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+
+/**
+ * Manages the lifecycle and visibility of instances associated with a an {@link RuntimeComponent}.
+ *
+ * @version $Rev$ $Date$
+ * @param <KEY> the type of IDs that this container uses to identify its contexts.
+ * For example, for COMPOSITE scope this could be the URI of the composite component,
+ * or for HTTP Session scope it might be the HTTP session ID.
+ *
+ * @tuscany.spi.extension.asclient
+ */
+public interface ScopeContainer<KEY> {
+
+ /**
+ * Returns the Scope that this container supports.
+ *
+ * @return the Scope that this container supports
+ */
+ Scope getScope();
+
+ /**
+ * Start a new context with the supplied ID.
+ *
+ * @param contextId an ID that uniquely identifies the context.
+ */
+ void startContext(KEY contextId);
+
+ /**
+ * Stop the context with the supplied ID.
+ *
+ * @param contextId an ID that uniquely identifies the context.
+ */
+ void stopContext(KEY contextId);
+
+ /**
+ * Returns an instance wrapper associated with the current scope context, creating one if necessary
+ * @param contextId the id for the scope context
+ *
+ * @return the wrapper for the target instance
+ * @throws TargetResolutionException if there was a problem instantiating the target instance
+ */
+ InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException;
+
+ /**
+ * Allows a component to be registered against more than one context id. This is required in the
+ * case of stateful callbacks where we want to identify the originating client component instance
+ * as the callback target but we don't want to reuse the clients original conversation id
+ *
+ * @param existingContextId an id that identifies an existing component instance
+ * @param newContextId a new id against which this component will also be registered
+ * @throws TargetResolutionException
+ */
+ void addWrapperReference(KEY existingContextId, KEY newContextId)
+ throws TargetResolutionException;
+
+ /**
+ * Register an existing instance against a context id. This is needed
+ * for a stateful callback where the service reference for the forward call
+ * contains a callback object that is not a service reference.
+ *
+ * @param wrapper the instance wrapper for the instance to be registered
+ * @param contextId the id for the scope context
+ * @throws TargetResolutionException
+ */
+ void registerWrapper(InstanceWrapper wrapper, KEY contextId)
+ throws TargetResolutionException;
+
+ /**
+ * Returns an implementation instance associated with the current scope context.
+ * If no instance is found, a {@link TargetNotFoundException} is thrown.
+ * @param contextId the id for the scope context
+ *
+ * @return the wrapper for the target instance
+ * @throws TargetResolutionException if there was a problem instantiating the target instance
+ */
+ InstanceWrapper getAssociatedWrapper(KEY contextId)
+ throws TargetResolutionException;
+
+ /**
+ * Return a wrapper after use (for example, after invoking the instance).
+ * @param wrapper the wrapper for the target instance being returned
+ * @param contextId the id for the scope context
+ *
+ * @throws TargetDestructionException if there was a problem returning the target instance
+ */
+ void returnWrapper(InstanceWrapper wrapper, KEY contextId)
+ throws TargetDestructionException;
+
+ /**
+ * Removes an identified component implementation instance associated with the current
+ * context from persistent storage
+ *
+ * @param contextId the identifier of the context to remove.
+ */
+ void remove(KEY contextId)
+ throws TargetDestructionException;
+
+ /* A configuration error state */
+ int CONFIG_ERROR = -1;
+ /* Has not been initialized */
+ int UNINITIALIZED = 0;
+ /* In the process of being configured and initialized */
+ int INITIALIZING = 1;
+ /* Instantiated and configured */
+ int INITIALIZED = 2;
+ /* Configured and initialized */
+ int RUNNING = 4;
+ /* In the process of being shutdown */
+ int STOPPING = 5;
+ /* Has been shutdown and removed from the composite */
+ int STOPPED = 6;
+ /* In an error state */
+ int ERROR = 7;
+
+ /**
+ * Returns the lifecycle state
+ *
+ * @see #UNINITIALIZED
+ * @see #INITIALIZING
+ * @see #INITIALIZED
+ * @see #RUNNING
+ * @see #STOPPING
+ * @see #STOPPED
+ */
+ int getLifecycleState();
+
+ /**
+ * Starts the Lifecycle.
+ */
+ void start();
+
+ /**
+ * Stops the Lifecycle.
+ */
+ void stop();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java
new file mode 100644
index 0000000000..b19c14b3e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.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.core.scope;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Factory to create ScopeContainer for components
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ScopeContainerFactory {
+ ScopeContainer createScopeContainer(RuntimeComponent component);
+ Scope getScope();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java
new file mode 100644
index 0000000000..842ed4c547
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.scope;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+
+/**
+ * Manages {@link ScopeContainer}s in the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ScopeRegistry {
+
+ /**
+ * Returns the scope container for the given scope or null if one not found
+ *
+ * @param scope the scope
+ * @return the scope container for the given scope or null if one not found
+ */
+ ScopeContainer getScopeContainer(RuntimeComponent component);
+
+ /**
+ * @param factory
+ */
+ void register(ScopeContainerFactory factory);
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java
new file mode 100644
index 0000000000..ee55917f2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.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 org.apache.tuscany.sca.core.scope;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+
+/**
+ * A component implementation can implement this interface to provide scope
+ * management for the components
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ScopedImplementationProvider extends ImplementationProvider {
+ /**
+ * Get the scope for the component implementation
+ *
+ * @return The scope for the component implementation, if null is returned,
+ * STATELESS will be used
+ */
+ Scope getScope();
+
+ /**
+ * Indicate if the component needs to be eagerly initialized
+ *
+ * @return true if the component is marked to be eagerly initialized, false
+ * otherwise
+ */
+ boolean isEagerInit();
+
+ /**
+ * Create a wrapper for the component instance for the scope management
+ *
+ * @return A wrapper for the component instance
+ */
+ InstanceWrapper createInstanceWrapper();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java
new file mode 100644
index 0000000000..98c5f84c71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.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.core.scope;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Scoped runtime component
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ScopedRuntimeComponent extends RuntimeComponent {
+ /**
+ * Set the associated scope container
+ * @param scopeContainer
+ */
+ void setScopeContainer(ScopeContainer scopeContainer);
+ /**
+ * Get the assoicated scope container
+ * @return
+ */
+ ScopeContainer getScopeContainer();
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java
new file mode 100644
index 0000000000..5c85fead2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.scope;
+
+/**
+ * Denotes an error destroying a target
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class TargetDestructionException extends TargetResolutionException {
+ private static final long serialVersionUID = -6126684147851674709L;
+
+ public TargetDestructionException() {
+ super();
+ }
+
+ public TargetDestructionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetDestructionException(String message) {
+ super(message);
+ }
+
+ public TargetDestructionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java
new file mode 100644
index 0000000000..89ddd7e538
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.scope;
+
+/**
+ * Denotes an error initializing a target
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class TargetInitializationException extends TargetResolutionException {
+ private static final long serialVersionUID = -6228778208649752698L;
+
+ public TargetInitializationException() {
+ super();
+ }
+
+ public TargetInitializationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetInitializationException(String message) {
+ super(message);
+ }
+
+ public TargetInitializationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java
new file mode 100644
index 0000000000..bb46a2499b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.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.core.scope;
+
+/**
+ * Thrown when a target of an operation cannot be found
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetNotFoundException extends TargetResolutionException {
+ private static final long serialVersionUID = 5541830480658471186L;
+
+ public TargetNotFoundException() {
+ super();
+ }
+
+ public TargetNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetNotFoundException(String message) {
+ super(message);
+ }
+
+ public TargetNotFoundException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java
new file mode 100644
index 0000000000..17afd36219
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.scope;
+
+/**
+ * Denotes an error retrieving a target instance
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class TargetResolutionException extends Exception {
+ private static final long serialVersionUID = 2912513650522019405L;
+
+ public TargetResolutionException() {
+ super();
+ }
+
+ public TargetResolutionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetResolutionException(String message) {
+ super(message);
+ }
+
+ public TargetResolutionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java
new file mode 100644
index 0000000000..730f92e0f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.scope.impl;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.core.scope.AbstractScopeContainer;
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.TargetDestructionException;
+import org.apache.tuscany.sca.core.scope.TargetNotFoundException;
+import org.apache.tuscany.sca.core.scope.TargetResolutionException;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+/**
+ * A scope context which manages atomic component instances keyed by composite
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeScopeContainer<KEY> extends AbstractScopeContainer<KEY> {
+ private InstanceWrapper<?> wrapper;
+
+ public CompositeScopeContainer(RuntimeComponent component) {
+ super(Scope.COMPOSITE, component);
+ }
+
+ @Override
+ public synchronized void stop() {
+ super.stop();
+ if (wrapper != null) {
+ try {
+ wrapper.stop();
+ } catch (TargetDestructionException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ wrapper = null;
+ }
+
+ @Override
+ public synchronized InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException {
+ if (wrapper == null) {
+ try {
+ wrapper = createInstanceWrapper();
+ wrapper.start();
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+ return wrapper;
+ }
+
+ @Override
+ public InstanceWrapper getAssociatedWrapper(KEY contextId) throws TargetResolutionException {
+ if (wrapper == null) {
+ throw new TargetNotFoundException(component.getURI());
+ }
+ return wrapper;
+ }
+
+ @Override
+ public synchronized void start() {
+ super.start();
+ if (isEagerInit()) {
+ try {
+ getWrapper(null);
+ } catch (TargetResolutionException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java
new file mode 100644
index 0000000000..f61e70a598
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.scope.impl;
+
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeScopeContainerFactory implements ScopeContainerFactory {
+
+ public ScopeContainer createScopeContainer(RuntimeComponent component) {
+ return new CompositeScopeContainer(component);
+ }
+
+ public Scope getScope() {
+ return Scope.COMPOSITE;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java
new file mode 100644
index 0000000000..9884c5f053
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.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.core.scope.impl;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
+import org.apache.tuscany.sca.core.scope.ScopeRegistry;
+import org.apache.tuscany.sca.core.scope.ScopedImplementationProvider;
+import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * The default implementation of a scope registry
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeRegistryImpl implements ScopeRegistry {
+ private final Map<Scope, ScopeContainerFactory> scopeCache = new ConcurrentHashMap<Scope, ScopeContainerFactory>();
+
+ public void register(ScopeContainerFactory factory) {
+ scopeCache.put(factory.getScope(), factory);
+ }
+
+ public ScopeContainer getScopeContainer(RuntimeComponent runtimeComponent) {
+ if (!(runtimeComponent instanceof ScopedRuntimeComponent)) {
+ return null;
+ }
+ ScopedRuntimeComponent component = (ScopedRuntimeComponent)runtimeComponent;
+ if (component.getScopeContainer() != null) {
+ return component.getScopeContainer();
+ }
+ ImplementationProvider implementationProvider = component.getImplementationProvider();
+ if (implementationProvider instanceof ScopedImplementationProvider) {
+ ScopedImplementationProvider provider = (ScopedImplementationProvider)implementationProvider;
+ Scope scope = provider.getScope();
+ if (scope == null) {
+ scope = Scope.STATELESS;
+ } else if (scope.equals(Scope.INVALID)) {
+ return null;
+ }
+ ScopeContainerFactory factory = scopeCache.get(scope);
+ ScopeContainer container = factory.createScopeContainer(component);
+ component.setScopeContainer(container);
+ return container;
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java
new file mode 100644
index 0000000000..1235fd2a67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.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.sca.core.scope.impl;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.core.scope.AbstractScopeContainer;
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.TargetDestructionException;
+import org.apache.tuscany.sca.core.scope.TargetResolutionException;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * A scope context which manages stateless atomic component instances in a non-pooled fashion.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StatelessScopeContainer<KEY> extends AbstractScopeContainer<KEY> {
+
+ public StatelessScopeContainer(RuntimeComponent component) {
+ super(Scope.STATELESS, component);
+ }
+
+ @Override
+ public InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException {
+ if (lifecycleState != RUNNING) {
+ throw new TargetResolutionException("scope container not running, lifecycleState=" + lifecycleState);
+ }
+ InstanceWrapper ctx = createInstanceWrapper();
+ ctx.start();
+ return ctx;
+ }
+
+ @Override
+ public InstanceWrapper getAssociatedWrapper(KEY contextId)
+ throws TargetResolutionException {
+ return getWrapper(contextId);
+ }
+
+ @Override
+ public void returnWrapper(InstanceWrapper wrapper, KEY contextId)
+ throws TargetDestructionException {
+ wrapper.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java
new file mode 100644
index 0000000000..5bf20a6a5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.scope.impl;
+
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessScopeContainerFactory implements ScopeContainerFactory {
+
+ public ScopeContainer createScopeContainer(RuntimeComponent component) {
+ return new StatelessScopeContainer(component);
+ }
+
+ public Scope getScope() {
+ return Scope.STATELESS;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java
new file mode 100644
index 0000000000..380ca818c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.work.NotificationListener;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.apache.tuscany.sca.work.WorkSchedulerException;
+
+/**
+ * A work scheduler implementation based on a JSR 237 work manager.
+ * <p/>
+ * <p/>
+ * This needs a JSR 237 work manager implementation available for scheduling work. Instances can be configured with a
+ * work manager implementation that is injected in. It is the responsibility of the runtime environment to make a work
+ * manager implementation available. For example, if the managed environment supports work manager the runtime can use
+ * the appropriate lookup mechanism to inject the work manager implementation. </p>
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultWorkScheduler implements WorkScheduler, LifeCycleListener {
+
+ /**
+ * Underlying JSR-237 work manager
+ */
+ private ThreadPoolWorkManager jsr237WorkManager;
+ private int maxThreads = 0;
+
+ /**
+ * Initializes the JSR 237 work manager.
+ *
+ * @param jsr237WorkManager JSR 237 work manager.
+ */
+ public DefaultWorkScheduler(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ if (attributes != null) {
+ String value = attributes.get("maxThreads");
+ if (value != null) {
+ maxThreads = Integer.parseInt(value.trim());
+ }
+ }
+ }
+
+ private synchronized ThreadPoolWorkManager getWorkManager() {
+ if (jsr237WorkManager != null) {
+ return jsr237WorkManager;
+ }
+// try {
+// InitialContext ctx = new InitialContext();
+// jsr237WorkManager = (ThreadPoolWorkManager)ctx.lookup("java:comp/env/wm/TuscanyWorkManager");
+// } catch (Throwable e) {
+// // ignore
+// }
+ if (jsr237WorkManager == null) {
+ jsr237WorkManager = new ThreadPoolWorkManager(maxThreads);
+ }
+ return jsr237WorkManager;
+ }
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener is used to register interest in
+ * callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ */
+ public <T extends Runnable> void scheduleWork(T work) {
+ scheduleWork(work, null);
+ }
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener is used to register interest in
+ * callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ * @param listener Notification listener for callbacks.
+ */
+ public <T extends Runnable> void scheduleWork(T work, NotificationListener<T> listener) {
+
+ if (work == null) {
+ throw new IllegalArgumentException("Work cannot be null");
+ }
+
+ Work<T> jsr237Work = new Work<T>(work);
+ try {
+ if (listener == null) {
+ getWorkManager().schedule(jsr237Work);
+ } else {
+ Jsr237WorkListener<T> jsr237WorkListener = new Jsr237WorkListener<T>(listener, work);
+ getWorkManager().schedule(jsr237Work, jsr237WorkListener);
+ }
+ } catch (IllegalArgumentException ex) {
+ if (listener != null) {
+ listener.workRejected(work);
+ } else {
+ throw new WorkSchedulerException(ex);
+ }
+ } catch (Exception ex) {
+ throw new WorkSchedulerException(ex);
+ }
+
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ if (jsr237WorkManager instanceof ThreadPoolWorkManager) {
+ // Allow privileged access to modify threads. Requires RuntimePermission in security
+ // policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ ((ThreadPoolWorkManager)jsr237WorkManager).destroy();
+ return null;
+ }
+ });
+ }
+ }
+
+ /*
+ * WorkListener for keeping track of work status callbacks.
+ *
+ */
+ private class Jsr237WorkListener<T extends Runnable> implements WorkListener {
+
+ // Notification listener
+ private NotificationListener<T> listener;
+
+ // Work
+ private T work;
+
+ /*
+ * Initializes the notification listener.
+ */
+ public Jsr237WorkListener(NotificationListener<T> listener, T work) {
+ this.listener = listener;
+ this.work = work;
+ }
+
+ /*
+ * Callback when the work is accepted.
+ */
+ public void workAccepted(WorkEvent workEvent) {
+ T work = getWork();
+ listener.workAccepted(work);
+ }
+
+ /*
+ * Callback when the work is rejected.
+ */
+ public void workRejected(WorkEvent workEvent) {
+ T work = getWork();
+ listener.workRejected(work);
+ }
+
+ /*
+ * Callback when the work is started.
+ */
+ public void workStarted(WorkEvent workEvent) {
+ T work = getWork();
+ listener.workStarted(work);
+ }
+
+ /*
+ * Callback when the work is completed.
+ */
+ public void workCompleted(WorkEvent workEvent) {
+ T work = getWork();
+ Exception exception = workEvent.getException();
+ if (exception != null) {
+ listener.workFailed(work, exception);
+ } else {
+ listener.workCompleted(work);
+ }
+ }
+
+ /*
+ * Gets the underlying work from the work event.
+ */
+ private T getWork() {
+ return work;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java
new file mode 100644
index 0000000000..1cd70c75de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ThreadFactory;
+
+import org.apache.tuscany.sca.work.WorkSchedulerException;
+
+/**
+ * A thread-pool based implementation for the JSR-237 work manager.
+ * <p/>
+ * <p/>
+ * This implementation supports only local work.
+ * <p/>
+ * TODO Elaborate the implementation. </p>
+ *
+ * @version $Rev$ $Date$
+ */
+public class ThreadPoolWorkManager {
+
+ // Map of work items currently handled by the work manager
+ private Map<WorkItem, WorkListener> workItems = new ConcurrentHashMap<WorkItem, WorkListener>();
+
+ // Thread-pool
+ private ExecutorService executor;
+
+ /**
+ * Initializes the thread-pool.
+ *
+ * @param threadPoolSize Thread-pool size. If the size <1, then a cached pool is created
+ */
+ public ThreadPoolWorkManager(int threadPoolSize) {
+ ThreadFactory factory = new ThreadFactory() {
+ public Thread newThread(Runnable r) {
+ Thread thread = new Thread(r);
+ thread.setDaemon(true);
+ return thread;
+ }
+ };
+ if (threadPoolSize <= 0) {
+
+ // Creates a new Executor, use a custom ThreadFactory that
+ // creates daemon threads.
+ executor = Executors.newCachedThreadPool(factory);
+ } else {
+ executor = Executors.newFixedThreadPool(threadPoolSize, factory);
+ }
+ }
+
+ /**
+ * Schedules a unit of work asynchronously.
+ *
+ * @param work Work that needs to be scheduled.
+ * @return Work Work item representing the asynchronous work
+ */
+ public WorkItem schedule(Work work) throws IllegalArgumentException {
+ return schedule(work, null);
+ }
+
+ /**
+ * Schedules a unit of work asynchronously.
+ *
+ * @param work Work that needs to be scheduled.
+ * @param workListener Work listener for callbacks.
+ * @return Work Work item representing the asynchronous work
+ */
+ public WorkItem schedule(Work work, WorkListener workListener) throws IllegalArgumentException {
+
+ WorkItem workItem = new WorkItem(UUID.randomUUID().toString(), work);
+ if (workListener != null) {
+ workItems.put(workItem, workListener);
+ }
+ workAccepted(workItem, work);
+ if (scheduleWork(work, workItem)) {
+ return workItem;
+ } else {
+ workItem.setStatus(WorkEvent.WORK_REJECTED);
+ if (workListener != null) {
+ workListener.workRejected(new WorkEvent(workItem));
+ }
+ throw new IllegalArgumentException("Unable to schedule work");
+ }
+ }
+
+ /**
+ * Wait for all the specified units of work to finish.
+ *
+ * @param works Units of the work that need to finish.
+ * @param timeout Timeout for waiting for the units of work to finish.
+ */
+ public boolean waitForAll(Collection works, long timeout) {
+ throw new UnsupportedOperationException("waitForAll not supported");
+ }
+
+ /**
+ * Wait for any of the specified units of work to finish.
+ *
+ * @param works Units of the work that need to finish.
+ * @param timeout Timeout for waiting for the units of work to finish.
+ */
+ public Collection waitForAny(Collection works, long timeout) {
+ throw new UnsupportedOperationException("waitForAny not supported");
+ }
+
+ /**
+ * Method provided for subclasses to indicate a work acceptance.
+ *
+ * @param workItem Work item representing the work that was accepted.
+ * @param work Work that was accepted.
+ */
+ private void workAccepted(final WorkItem workItem, final Work work) {
+ WorkListener listener = workItems.get(workItem);
+ if (listener != null) {
+ workItem.setStatus(WorkEvent.WORK_ACCEPTED);
+ WorkEvent event = new WorkEvent(workItem);
+ listener.workAccepted(event);
+ }
+ }
+
+ /*
+ * Method to indicate a work start.
+ */
+ private void workStarted(final WorkItem workItem, final Work work) {
+ WorkListener listener = workItems.get(workItem);
+ if (listener != null) {
+ workItem.setStatus(WorkEvent.WORK_STARTED);
+ WorkEvent event = new WorkEvent(workItem);
+ listener.workStarted(event);
+ }
+ }
+
+ /*
+ * Method to indicate a work completion.
+ */
+ private void workCompleted(final WorkItem workItem, final Work work) {
+ workCompleted(workItem, work, null);
+ }
+
+ /*
+ * Method to indicate a work completion.
+ */
+ private void workCompleted(final WorkItem workItem, final Work work, final WorkSchedulerException exception) {
+ WorkListener listener = workItems.get(workItem);
+ if (listener != null) {
+ workItem.setStatus(WorkEvent.WORK_COMPLETED);
+ workItem.setResult(work);
+ workItem.setException(exception);
+ WorkEvent event = new WorkEvent(workItem);
+ listener.workCompleted(event);
+ workItems.remove(workItem);
+ }
+ }
+
+ /*
+ * Schedules the work using the ThreadPool.
+ */
+ private boolean scheduleWork(final Work work, final WorkItem workItem) {
+ try {
+ executor.execute(new DecoratingWork(workItem, work));
+ return true;
+ } catch (RejectedExecutionException ex) {
+ return false;
+ }
+ }
+
+ /*
+ * Class that decorates the original worker so that it can get callbacks when work is done.
+ */
+ private final class DecoratingWork implements Runnable {
+
+ // Work item for this work.
+ private WorkItem workItem;
+
+ // The original work.
+ private Work decoratedWork;
+
+ /*
+ * Initializes the work item and underlying work.
+ */
+ private DecoratingWork(final WorkItem workItem, final Work decoratedWork) {
+ this.workItem = workItem;
+ this.decoratedWork = decoratedWork;
+ }
+
+ /*
+ * Overrides the run method.
+ */
+ public void run() {
+ workStarted(workItem, decoratedWork);
+ try {
+ decoratedWork.run();
+ workCompleted(workItem, decoratedWork);
+ } catch (Throwable th) {
+ workCompleted(workItem, decoratedWork, new WorkSchedulerException(th.getMessage(), th));
+ }
+ }
+
+ }
+
+ public void destroy() {
+ executor.shutdown();
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java
new file mode 100644
index 0000000000..ca06d0e854
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.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.sca.core.work.impl;
+
+/**
+ * JCA work wrapper.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Work<T extends Runnable> {
+
+ // Work that is being executed.
+ private T work;
+
+ /*
+ * Initializes the work instance.
+ */
+ public Work(T work) {
+ this.work = work;
+ }
+
+ /*
+ * Returns the completed work.
+ */
+ public T getWork() {
+ return work;
+ }
+
+ /*
+ * Release the work.
+ */
+ public void release() {
+ }
+
+ /*
+ * Work attributes are not daemon.
+ */
+ public boolean isDaemon() {
+ return false;
+ }
+
+ /*
+ * Runs the work.
+ */
+ public void run() {
+ work.run();
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java
new file mode 100644
index 0000000000..4580011806
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import org.apache.tuscany.sca.work.WorkSchedulerException;
+
+
+
+/**
+ * Default immutable implementation of the <code>WorkEvent</code> class.
+ *
+ * @version $Rev$ $Date$
+ */
+class WorkEvent {
+
+ public static final int WORK_ACCEPTED = 1;
+ public static final int WORK_REJECTED = 2;
+ public static final int WORK_STARTED = 3;
+ public static final int WORK_COMPLETED = 4;
+
+ // Work item for this event
+ private WorkItem workItem;
+
+ // Exception if something has gone wrong
+ private WorkSchedulerException exception;
+
+ /**
+ * Instantiates the event.
+ *
+ * @param workItem Work item for this event.
+ */
+ public WorkEvent(final WorkItem workItem) {
+ this.workItem = workItem;
+ this.exception = workItem.getException();
+ }
+
+ /**
+ * Returns the work type based on whether the work was accepted, started,
+ * rejected or completed.
+ *
+ * @return Work type.
+ */
+ public int getType() {
+ return workItem.getStatus();
+ }
+
+ /**
+ * Returns the work item associated with this work type.
+ *
+ * @return Work item.
+ */
+ public WorkItem getWorkItem() {
+ return workItem;
+ }
+
+ /**
+ * Returns the exception if the work completed with an exception.
+ *
+ * @return Work exception.
+ */
+ public WorkSchedulerException getException() {
+ return exception;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java
new file mode 100644
index 0000000000..0fc104d0fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import org.apache.tuscany.sca.work.WorkSchedulerException;
+
+/**
+ * An identity based immutable implementation of the <code>WorkItem</code>
+ * interface.
+ *
+ * @version $Rev$ $Date$
+ */
+class WorkItem {
+
+ // Id scoped for the VM
+ private String id;
+
+ // Status
+ private int status = -1;
+
+ // Result
+ private Work<?> result;
+
+ // Original work
+ private Work<?> originalWork;
+
+ // Exception
+ private WorkSchedulerException exception;
+
+ /**
+ * Instantiates an id for this item.
+ *
+ * @param id of this work event.
+ */
+ protected WorkItem(final String id, final Work<?> orginalWork) {
+ this.id = id;
+ this.originalWork = orginalWork;
+ }
+
+ /**
+ * Returns the id.
+ *
+ * @return Id of this item.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns the original work.
+ *
+ * @return Original work.
+ */
+ public Work<?> getOriginalWork() {
+ return originalWork;
+ }
+
+ /**
+ * Returns the work result if the work completed.
+ *
+ * @return Work.
+ * @throws WorkException If the work completed with an exception.
+ */
+ public Work<?> getResult() {
+ return result;
+ }
+
+ /**
+ * Sets the result.
+ *
+ * @param result Result.
+ */
+ protected void setResult(final Work<?> result) {
+ this.result = result;
+ }
+
+ /**
+ * Returns the exception if work completed with an exception.
+ *
+ * @return Work exception.
+ */
+ protected WorkSchedulerException getException() {
+ return exception;
+ }
+
+ /**
+ * Sets the exception.
+ *
+ * @param exception Exception.
+ */
+ protected void setException(final WorkSchedulerException exception) {
+ this.exception = exception;
+ }
+
+ /**
+ * Returns the work type based on whether the work was accepted, started,
+ * rejected or completed.
+ *
+ * @return Work status.
+ */
+ public int getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status.
+ *
+ * @param status Status.
+ */
+ protected void setStatus(final int status) {
+ this.status = status;
+ }
+
+ /**
+ * @see Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param obj Object to be compared.
+ * @return true if this object is the same as the obj argument; false
+ * otherwise..
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ return (obj != null) && (obj.getClass() == WorkItem.class) && ((WorkItem) obj).id.equals(id);
+ }
+
+ /**
+ * Compares this object with the specified object for order. Returns a
+ * negative integer, zero, or a positive integer as this object is less
+ * than, equal to, or greater than the specified object.
+ *
+ * @param o Object to be compared.
+ * @return A negative integer, zero, or a positive integer as this object
+ * is less than, equal to, or greater than the specified object.
+ * @throws ClassCastException needs better documentation.
+ */
+ public int compareTo(final Object o) {
+ if (o.getClass() != WorkItem.class) {
+ throw new ClassCastException(o.getClass().getName());
+ } else {
+ return ((WorkItem) o).getId().compareTo(getId());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java
new file mode 100644
index 0000000000..38bbaeebe0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.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.core.work.impl;
+
+public interface WorkListener {
+
+ long IMMEDIATE = 0;
+ long INDEFINITE = java.lang.Long.MAX_VALUE;
+
+ void workAccepted(WorkEvent event);
+ void workCompleted(WorkEvent event);
+ void workRejected(WorkEvent event);
+ void workStarted(WorkEvent event);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
new file mode 100644
index 0000000000..e8ee318b6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
@@ -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.
+# Set the ranking to be greater than the DefaultAssemblyFactory
+org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;ranking=100
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory
new file mode 100644
index 0000000000..51ed2449fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.core.context.DefaultComponentContextFactory
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory
new file mode 100644
index 0000000000..70b17a2f00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.core.context.DefaultRequestContextFactory
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..94c83ceeab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.core.assembly.impl.ReferenceParameterProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#referenceParameters,model=org.apache.tuscany.sca.runtime.ReferenceParameters
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint
new file mode 100644
index 0000000000..c6567aa904
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.core.invocation.DefaultProxyFactoryExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry
new file mode 100644
index 0000000000..2aa000efc0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry
@@ -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.
+
+org.apache.tuscany.sca.core.scope.DefaultScopeRegistry
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory
new file mode 100644
index 0000000000..a21b75b570
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory
@@ -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.
+
+org.apache.tuscany.sca.core.invocation.impl.MessageFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator
new file mode 100644
index 0000000000..0182f52086
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator
@@ -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.
+
+org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
new file mode 100644
index 0000000000..f2a6f0b4c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.core.assembly.impl.LocalDomainRegistryFactory
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder
new file mode 100644
index 0000000000..61edf5111e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder
@@ -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.core.runtime.impl.EndpointReferenceBinderImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer
new file mode 100644
index 0000000000..fb951e75d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.core.assembly.impl.EndpointSerializerImpl
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeProperties b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeProperties
new file mode 100644
index 0000000000..66e0277d59
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeProperties
@@ -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.core.runtime.impl.RuntimePropertiesImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
new file mode 100644
index 0000000000..90e887739a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.core.work.impl.DefaultWorkScheduler;maxThreads=0
diff --git a/sandbox/sebastien/java/embed/modules/core/src/main/resources/endpoint-validation-messages.properties b/sandbox/sebastien/java/embed/modules/core/src/main/resources/endpoint-validation-messages.properties
new file mode 100644
index 0000000000..6e12d11d68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/main/resources/endpoint-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+NoEndpointsFound = No endpoints found in the domain that match the reference {0}
+EndpointReferenceCantBeMatched = = Unable to match the endpoint reference {0} with the policy of the service to which it refers, matching process was {1}
+ComponentReferenceTargetNotFound = Component reference target not found, it might be a remote service running elsewhere in the SCA Domain: {1}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java
new file mode 100644
index 0000000000..1302bed681
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.invocation.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvocationChainImplTestCase {
+
+ @Test
+ public void testInsertAtEnd() throws Exception {
+ Operation op = newOperation("foo");
+ InvocationChain chain = new InvocationChainImpl(op, op, true, new PhaseManager(new DefaultExtensionPointRegistry()));
+ Interceptor inter2 = new MockInterceptor();
+ Interceptor inter1 = new MockInterceptor();
+ chain.addInterceptor(inter1);
+ chain.addInterceptor(inter2);
+ Interceptor head = (Interceptor)chain.getHeadInvoker();
+ assertEquals(inter1, head);
+ assertEquals(inter2, head.getNext());
+ }
+
+ @Test
+ public void testAddByPhase() throws Exception {
+ Operation op = newOperation("foo");
+ InvocationChain chain = new InvocationChainImpl(op, op, false, new PhaseManager(new DefaultExtensionPointRegistry()));
+ Interceptor inter1 = new MockInterceptor();
+ Interceptor inter2 = new MockInterceptor();
+ Interceptor inter3 = new MockInterceptor();
+ Interceptor inter4 = new MockInterceptor();
+ chain.addInterceptor(inter3); // SERVICE
+ chain.addInterceptor(Phase.IMPLEMENTATION_POLICY, inter4);
+ chain.addInterceptor(Phase.SERVICE_POLICY, inter2);
+ chain.addInterceptor(Phase.SERVICE_BINDING, inter1);
+ Interceptor head = (Interceptor)chain.getHeadInvoker();
+ assertEquals(inter1, head);
+ assertEquals(inter2, inter1.getNext());
+ assertEquals(inter3, inter2.getNext());
+ assertEquals(inter4, inter3.getNext());
+ }
+
+ private class MockInterceptor implements Interceptor {
+
+ private Invoker next;
+
+ public Message invoke(Message msg) {
+ return null;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ }
+
+ private static Operation newOperation(String name) {
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+ return operation;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java
new file mode 100644
index 0000000000..8fcead004d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.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.core.invocation.impl;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PhaseManagerTestCase {
+
+ @Test
+ public void testDiscovery() {
+ PhaseManager pm = new PhaseManager("org.apache.tuscany.sca.invocation.PhaseTest");
+ List<String> phases = pm.getAllPhases();
+ System.out.println(phases.size());
+ System.out.println(phases);
+ // Assert.assertEquals(15, phases.size());
+ Assert.assertEquals("reference.first", phases.get(0));
+
+ int rt = phases.indexOf("reference.transaction");
+ Assert.assertTrue(rt > phases.indexOf("reference.interface"));
+
+ int st = phases.indexOf("service.transaction");
+ Assert.assertTrue(st > phases.indexOf("service.binding"));
+
+ int it = phases.indexOf("implementation.transaction");
+ Assert.assertTrue(it < phases.indexOf("implementation.policy"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java
new file mode 100644
index 0000000000..c268e133e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.invocation.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PhaseSorterTestCase {
+ private PhaseSorter<String> graph;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = new PhaseSorter<String>();
+ }
+
+ @Test
+ public void testSort() {
+ graph.addEdge("a", "b");
+ graph.addEdge("a", "c");
+ graph.addEdge("c", "d");
+ graph.addEdge("b", "c");
+ List<String> order = graph.topologicalSort(true);
+ assertEquals(Arrays.asList("a", "b", "c", "d"), order);
+ assertTrue(!graph.getVertices().isEmpty());
+
+ graph.addEdge("d", "a");
+ try {
+ order = graph.topologicalSort(true);
+ assertTrue("Should have failed", false);
+ } catch (IllegalArgumentException e) {
+ assertTrue(true);
+ }
+
+ graph.removeEdge("d", "a");
+ order = graph.topologicalSort(false);
+ assertEquals(Arrays.asList("a", "b", "c", "d"), order);
+ assertTrue(graph.getVertices().isEmpty());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java
new file mode 100644
index 0000000000..16ca5fd00e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.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.sca.core.work.impl;
+
+
+
+/**
+ * Simple Work item that will throw an exception
+ *
+ * @version $Rev$ $Date$
+ */
+public class FailingWork extends Work {
+
+ public FailingWork() {
+ super(null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDaemon() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void release() {
+ }
+
+ /**
+ * Throws an IllegalArgumentException
+ */
+ public void run() {
+ System.out.println("Starting " + this + " and throwing an Exception");
+ throw new IllegalArgumentException("Sample exception from " + this);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java
new file mode 100644
index 0000000000..2d791e5012
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.core.work.impl;
+
+/**
+ * Simple Runnable that throws an IllegalArgumentException
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSR237MyFailingRunnable extends JSR237MyRunnable {
+
+ /**
+ * Constructor
+ */
+ public JSR237MyFailingRunnable() {
+ super(-1);
+ }
+
+ /**
+ * Sleeps for a period of time defined by sleepTime
+ */
+ @Override
+ public void run() {
+ System.out.println("Starting " + this + " and throwing an Exception");
+ throw new IllegalArgumentException("Sample exception from " + this);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java
new file mode 100644
index 0000000000..c0183b6f9b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.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.core.work.impl;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Simple Runnable that is used for testing Jsr237WorkScheduler
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSR237MyRunnable implements Runnable {
+
+ /**
+ * Count of workAccepted() method calls
+ */
+ private AtomicInteger runCompletedCount = new AtomicInteger();
+
+ /**
+ * The amount of time to sleep in the Run loop
+ */
+ private final long sleepTime;
+
+ /**
+ * Constructor
+ *
+ * @param sleepTime The amount of time to sleep (in milliseconds) in the run() method
+ */
+ public JSR237MyRunnable(long sleepTime) {
+ this.sleepTime = sleepTime;
+ }
+
+ /**
+ * Sleeps for a period of time defined by sleepTime
+ */
+ public void run() {
+ System.out.println("Starting " + this);
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("Done " + this);
+ runCompletedCount.incrementAndGet();
+ }
+
+ /**
+ * Returns the number of completed calls to run()
+ *
+ * @return The number of completed calls to run()
+ */
+ public int getRunCompletedCount() {
+ return runCompletedCount.get();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java
new file mode 100644
index 0000000000..307f24aca7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.tuscany.sca.work.NotificationListener;
+
+/**
+ * Simple NotificationListener that is used for testing Jsr237WorkScheduler
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSR237MyRunnerListener implements NotificationListener<JSR237MyRunnable> {
+
+ /**
+ * Count of workAccepted() method calls
+ */
+ private AtomicInteger workAcceptedCallCount = new AtomicInteger();
+
+ /**
+ * Count of workStarted() method calls
+ */
+ private AtomicInteger workStartedCallCount = new AtomicInteger();
+
+ /**
+ * Count of workCompleted() method calls
+ */
+ private AtomicInteger workCompletedCallCount = new AtomicInteger();
+
+ /**
+ * Count of workFailed() method calls
+ */
+ private AtomicInteger workFailedCallCount = new AtomicInteger();
+
+ /**
+ * Count of workRejected() method calls
+ */
+ private AtomicInteger workRejectedCallCount = new AtomicInteger();
+
+ /**
+ * List of all exceptions thrown by Work items
+ */
+ private List<Throwable> workExceptions = Collections.synchronizedList(new ArrayList<Throwable>());
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workAccepted(JSR237MyRunnable work) {
+ workAcceptedCallCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workCompleted(JSR237MyRunnable work) {
+ workCompletedCallCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workFailed(JSR237MyRunnable work, Throwable error) {
+ workExceptions.add(error);
+ workFailedCallCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workRejected(JSR237MyRunnable work) {
+ workRejectedCallCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workStarted(JSR237MyRunnable work) {
+ workStartedCallCount.incrementAndGet();
+ }
+
+ /**
+ * Returns the number of calls to workAccepted()
+ *
+ * @return The number of calls to workAccepted()
+ */
+ public int getWorkAcceptedCallCount() {
+ return workAcceptedCallCount.get();
+ }
+
+ /**
+ * Returns the number of calls to workStarted()
+ *
+ * @return The number of calls to workStarted()
+ */
+ public int getWorkStartedCallCount() {
+ return workStartedCallCount.get();
+ }
+
+ /**
+ * Returns the number of calls to workCompleted()
+ *
+ * @return The number of calls to workCompleted()
+ */
+ public int getWorkCompletedCallCount() {
+ return workCompletedCallCount.get();
+ }
+
+ /**
+ * Returns the number of calls to workFailed()
+ *
+ * @return The number of calls to workFailed()
+ */
+ public int getWorkFailedCallCount() {
+ return workFailedCallCount.get();
+ }
+
+ /**
+ * Returns the number of calls to workRejected()
+ *
+ * @return The number of calls to workRejected()
+ */
+ public int getWorkRejectedCallCount() {
+ return workRejectedCallCount.get();
+ }
+
+ /**
+ * Returns a List of all exceptions that are thrown by the Work items
+ *
+ * @return A List of all exceptions that are thrown by the Work items
+ */
+ public List<Throwable> getWorkExceptions() {
+ return Collections.unmodifiableList(workExceptions);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java
new file mode 100644
index 0000000000..4ec0f55867
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test case for Jsr237WorkScheduler
+ *
+ * @version $Rev$ $Date$
+ */
+public class Jsr237WorkSchedulerTestCase {
+
+ /**
+ * Wait up to 20 seconds for the Work units to complete
+ */
+ private static final long WAIT_TIMEOUT = 20000;
+
+ /**
+ * This is the shared instance of the ThreadPoolWorkManager used by the tests
+ */
+ private static DefaultWorkScheduler workSchedular = null;
+
+ /**
+ * Setup the Jsr237WorkScheduler
+ */
+ @BeforeClass
+ public static void setup() {
+ workSchedular = new DefaultWorkScheduler(null, null);
+ }
+
+ /**
+ * Make sure that the Jsr237WorkScheduler is stopped after running the tests
+ */
+ @AfterClass
+ public static void destroy() {
+ if (workSchedular != null) {
+ workSchedular.stop();
+ }
+ }
+
+ /**
+ * Tests running a single fast job on the Jsr237WorkScheduler
+ */
+ @Test
+ public void testSingleFastJob() {
+ // Create the work and register it
+ JSR237MyRunnable fast = new JSR237MyRunnable(10);
+ JSR237MyRunnerListener listener = new JSR237MyRunnerListener();
+ workSchedular.scheduleWork(fast, listener);
+
+ // Wait for the 1 job to complete
+ waitForWorkToComplete(listener, 1);
+
+ // Test that the job completed successfully.
+ Assert.assertEquals(1, listener.getWorkAcceptedCallCount());
+ Assert.assertEquals(0, listener.getWorkRejectedCallCount());
+ Assert.assertEquals(1, listener.getWorkStartedCallCount());
+ Assert.assertEquals(1, listener.getWorkCompletedCallCount());
+ Assert.assertEquals(0, listener.getWorkExceptions().size());
+ }
+
+ /**
+ * Tests running a single job that fails on the Jsr237WorkScheduler
+ */
+ @Test
+ public void testSingleFailingJob() {
+ // Create the work and register it
+ JSR237MyFailingRunnable fail = new JSR237MyFailingRunnable();
+ JSR237MyRunnerListener listener = new JSR237MyRunnerListener();
+ workSchedular.scheduleWork(fail, listener);
+
+ // Wait for the 1 job to complete
+ waitForWorkToComplete(listener, 1);
+
+ // Test that the job completed successfully.
+ Assert.assertEquals(1, listener.getWorkAcceptedCallCount());
+ Assert.assertEquals(0, listener.getWorkRejectedCallCount());
+ Assert.assertEquals(1, listener.getWorkStartedCallCount());
+ Assert.assertEquals(0, listener.getWorkCompletedCallCount());
+ Assert.assertEquals(1, listener.getWorkFailedCallCount());
+ Assert.assertEquals(1, listener.getWorkExceptions().size());
+ }
+
+ /**
+ * Tests running a mixture of fast and slow jobs on the Jsr237WorkScheduler
+ */
+ @Test
+ public void testMultipleJobs() {
+ // Create the work and register it
+ JSR237MyRunnable fast1 = new JSR237MyRunnable(5);
+ JSR237MyRunnable fast2 = new JSR237MyRunnable(10);
+ JSR237MyRunnable fast3 = new JSR237MyRunnable(20);
+ JSR237MyRunnable slow1= new JSR237MyRunnable(200);
+ JSR237MyRunnable slow2 = new JSR237MyRunnable(200);
+ JSR237MyRunnerListener listener = new JSR237MyRunnerListener();
+ workSchedular.scheduleWork(fast1, listener);
+ workSchedular.scheduleWork(fast2, listener);
+ workSchedular.scheduleWork(fast3, listener);
+ workSchedular.scheduleWork(slow1, listener);
+ workSchedular.scheduleWork(slow2, listener);
+
+ // Wait for the 5 jobs to complete
+ waitForWorkToComplete(listener, 5);
+
+ // Test that the job completed successfully.
+ Assert.assertEquals(5, listener.getWorkAcceptedCallCount());
+ Assert.assertEquals(0, listener.getWorkRejectedCallCount());
+ Assert.assertEquals(5, listener.getWorkStartedCallCount());
+ Assert.assertEquals(5, listener.getWorkCompletedCallCount());
+ Assert.assertEquals(0, listener.getWorkExceptions().size());
+ }
+
+ /**
+ * Tests running a mixture of fast and slow jobs some of which fail on the
+ * Jsr237WorkScheduler
+ */
+ @Test
+ public void testMultipleJobsSomeFail() {
+ // Create the work and register it
+ JSR237MyRunnable fast1 = new JSR237MyRunnable(5);
+ JSR237MyRunnable fast2 = new JSR237MyRunnable(10);
+ JSR237MyRunnable fast3 = new JSR237MyRunnable(20);
+ JSR237MyRunnable slow1= new JSR237MyRunnable(200);
+ JSR237MyRunnable slow2 = new JSR237MyRunnable(200);
+ JSR237MyFailingRunnable fail1 = new JSR237MyFailingRunnable();
+ JSR237MyFailingRunnable fail2 = new JSR237MyFailingRunnable();
+ JSR237MyRunnerListener listener = new JSR237MyRunnerListener();
+ workSchedular.scheduleWork(fast1, listener);
+ workSchedular.scheduleWork(fast2, listener);
+ workSchedular.scheduleWork(fail1, listener);
+ workSchedular.scheduleWork(fast3, listener);
+ workSchedular.scheduleWork(slow1, listener);
+ workSchedular.scheduleWork(fail2, listener);
+ workSchedular.scheduleWork(slow2, listener);
+
+ // Wait for the 7 jobs to complete
+ waitForWorkToComplete(listener, 7);
+
+ // Test that the job completed successfully.
+ Assert.assertEquals(7, listener.getWorkAcceptedCallCount());
+ Assert.assertEquals(0, listener.getWorkRejectedCallCount());
+ Assert.assertEquals(7, listener.getWorkStartedCallCount());
+ Assert.assertEquals(5, listener.getWorkCompletedCallCount());
+ Assert.assertEquals(2, listener.getWorkFailedCallCount());
+ Assert.assertEquals(2, listener.getWorkExceptions().size());
+ }
+
+ /**
+ * Tests running a single job that has no listener
+ */
+ @Test
+ public void testSingleFastJobWithNoListener() {
+ // Create the work and register it
+ JSR237MyRunnable fast = new JSR237MyRunnable(10);
+ workSchedular.scheduleWork(fast);
+
+ // Wait for the job to complete
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ int completedCount = fast.getRunCompletedCount();
+ if (completedCount == 1) {
+ break;
+ }
+
+ if (System.currentTimeMillis() - startTime > WAIT_TIMEOUT) {
+ Assert.fail("Only " + completedCount + " work items completed before timeout");
+ return;
+ }
+
+ // Lets wait for the job to complete
+ try {
+ Thread.sleep(25);
+ } catch (InterruptedException ex) {
+ Assert.fail("Unexpected exception: " + ex);
+ }
+ }
+ }
+
+ /**
+ * Tests scheduling a null as the work item
+ */
+ @Test
+ public void testNullWork() {
+ try {
+ workSchedular.scheduleWork(null);
+ Assert.fail("Should have thrown IllegalArgumentException ");
+ } catch (IllegalArgumentException ex) {
+ // As expected
+ Assert.assertTrue(ex.toString().indexOf("null") != -1);
+ }
+ }
+
+ /**
+ * Waits for the specified number of jobs to complete or the timeout to fire.
+ *
+ * @param listener The listener to use to track Work unit completion
+ * @param completedWorkItemsToWaitFor The number of Work items to complete
+ */
+ private void waitForWorkToComplete(JSR237MyRunnerListener listener, int completedWorkItemsToWaitFor) {
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ int completedCount = listener.getWorkCompletedCallCount() + listener.getWorkFailedCallCount();
+ if (completedCount == completedWorkItemsToWaitFor) {
+ return;
+ }
+
+ if (System.currentTimeMillis() - startTime > WAIT_TIMEOUT) {
+ Assert.fail("Only " + completedCount + " work items completed before timeout");
+ return;
+ }
+
+ // Lets wait for more jobs to complete
+ try {
+ Thread.sleep(25);
+ } catch (InterruptedException ex) {
+ Assert.fail("Unexpected exception: " + ex);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java
new file mode 100644
index 0000000000..a452d6f371
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.tuscany.sca.work.WorkSchedulerException;
+import org.junit.Assert;
+
+/**
+ * A simple WorkListener that tracks invocations to it.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestWorkListener implements WorkListener {
+
+ /**
+ * Count of workAccepted() method calls
+ */
+ private AtomicInteger workAcceptedCallCount = new AtomicInteger();
+
+ /**
+ * Count of workStarted() method calls
+ */
+ private AtomicInteger workStartedCallCount = new AtomicInteger();
+
+ /**
+ * Count of workCompleted() method calls
+ */
+ private AtomicInteger workCompletedCallCount = new AtomicInteger();
+
+ /**
+ * Count of workRejected() method calls
+ */
+ private AtomicInteger workRejectedCallCount = new AtomicInteger();
+
+ /**
+ * List of all exceptions thrown by Work items
+ */
+ private List<WorkSchedulerException> workExceptions = Collections.synchronizedList(new ArrayList<WorkSchedulerException>());
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workAccepted(WorkEvent work) {
+ workAcceptedCallCount.incrementAndGet();
+
+ // Validate the WorkEvent
+ Assert.assertNotNull(work.getWorkItem());
+ Assert.assertEquals(WorkEvent.WORK_ACCEPTED, work.getType());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workStarted(WorkEvent work) {
+ workStartedCallCount.incrementAndGet();
+
+ // Validate the WorkEvent
+ Assert.assertNotNull(work.getWorkItem());
+ Assert.assertEquals(WorkEvent.WORK_STARTED, work.getType());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workCompleted(WorkEvent work) {
+ if (work.getException() != null) {
+ workExceptions.add(work.getException());
+ }
+
+ // Validate the WorkEvent
+ Assert.assertNotNull(work.getWorkItem());
+ Assert.assertEquals(WorkEvent.WORK_COMPLETED, work.getType());
+
+ workCompletedCallCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void workRejected(WorkEvent work) {
+ workRejectedCallCount.incrementAndGet();
+
+ // Validate the WorkEvent
+ Assert.assertNotNull(work.getWorkItem());
+ Assert.assertEquals(WorkEvent.WORK_REJECTED, work.getType());
+ }
+
+ /**
+ * Returns the number of calls to workAccepted()
+ *
+ * @return The number of calls to workAccepted()
+ */
+ public int getWorkAcceptedCallCount() {
+ return workAcceptedCallCount.get();
+ }
+
+ /**
+ * Returns the number of calls to workStarted()
+ *
+ * @return The number of calls to workStarted()
+ */
+ public int getWorkStartedCallCount() {
+ return workStartedCallCount.get();
+ }
+
+ /**
+ * Returns the number of calls to workCompleted()
+ *
+ * @return The number of calls to workCompleted()
+ */
+ public int getWorkCompletedCallCount() {
+ return workCompletedCallCount.get();
+ }
+
+ /**
+ * Returns the number of calls to workRejected()
+ *
+ * @return The number of calls to workRejected()
+ */
+ public int getWorkRejectedCallCount() {
+ return workRejectedCallCount.get();
+ }
+
+ /**
+ * Returns a List of all exceptions that are thrown by the Work items
+ *
+ * @return A List of all exceptions that are thrown by the Work items
+ */
+ public List<WorkSchedulerException> getWorkExceptions() {
+ return Collections.unmodifiableList(workExceptions);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java
new file mode 100644
index 0000000000..122609d7e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This test case will test the ThreadPoolWorkManager
+ *
+ * @version $Rev$ $Date$
+ */
+public class ThreadPoolWorkManagerTestCase {
+
+ /**
+ * Wait up to 20 seconds for the Work units to complete
+ */
+ private static final long WAIT_TIMEOUT = 20000;
+
+ /**
+ * This is the shared instance of the ThreadPoolWorkManager used by the tests
+ */
+ private static ThreadPoolWorkManager workManager = null;
+
+ /**
+ * Setup the ThreadPoolWorkManager
+ */
+ @BeforeClass
+ public static void setup() {
+ workManager = new ThreadPoolWorkManager(10);
+ }
+
+ /**
+ * Make sure that the ThreadPoolWorkManager is stopped after running the tests
+ */
+ @AfterClass
+ public static void destroy() {
+ if (workManager != null) {
+ workManager.destroy();
+ }
+ }
+
+ /**
+ * Tests running a single fast job on the ThreadPoolWorkManager
+ */
+ @Test
+ public void testSingleFastJob() {
+ // Create the work and register it
+ TimeDelayWork fast = new TimeDelayWork(10);
+ TestWorkListener listener = new TestWorkListener();
+ workManager.schedule(fast, listener);
+
+ // Wait for the 1 job to complete
+ waitForWorkToComplete(listener, 1);
+
+ // Test that the job completed successfully.
+ Assert.assertEquals(1, listener.getWorkAcceptedCallCount());
+ Assert.assertEquals(0, listener.getWorkRejectedCallCount());
+ Assert.assertEquals(1, listener.getWorkStartedCallCount());
+ Assert.assertEquals(1, listener.getWorkCompletedCallCount());
+ Assert.assertEquals(0, listener.getWorkExceptions().size());
+ }
+
+ /**
+ * Tests running a single job that fails on the ThreadPoolWorkManager
+ */
+ @Test
+ public void testSingleFailingJob() {
+ // Create the work and register it
+ FailingWork fail = new FailingWork();
+ TestWorkListener listener = new TestWorkListener();
+ workManager.schedule(fail, listener);
+
+ // Wait for the 1 job to complete
+ waitForWorkToComplete(listener, 1);
+
+ // Test that the job completed successfully.
+ Assert.assertEquals(1, listener.getWorkAcceptedCallCount());
+ Assert.assertEquals(0, listener.getWorkRejectedCallCount());
+ Assert.assertEquals(1, listener.getWorkStartedCallCount());
+ Assert.assertEquals(1, listener.getWorkCompletedCallCount());
+ Assert.assertEquals(1, listener.getWorkExceptions().size());
+ }
+
+ /**
+ * Tests running a mixture of fast and slow jobs on the ThreadPoolWorkManager
+ */
+ @Test
+ public void testMultipleJobs() {
+ // Create the work and register it
+ TimeDelayWork fast1 = new TimeDelayWork(5);
+ TimeDelayWork fast2 = new TimeDelayWork(10);
+ TimeDelayWork fast3 = new TimeDelayWork(20);
+ TimeDelayWork slow1= new TimeDelayWork(200);
+ TimeDelayWork slow2 = new TimeDelayWork(200);
+ TestWorkListener listener = new TestWorkListener();
+ workManager.schedule(fast1, listener);
+ workManager.schedule(fast2, listener);
+ workManager.schedule(fast3, listener);
+ workManager.schedule(slow1, listener);
+ workManager.schedule(slow2, listener);
+
+ // Wait for the 5 jobs to complete
+ waitForWorkToComplete(listener, 5);
+
+ // Test that the job completed successfully.
+ Assert.assertEquals(5, listener.getWorkAcceptedCallCount());
+ Assert.assertEquals(0, listener.getWorkRejectedCallCount());
+ Assert.assertEquals(5, listener.getWorkStartedCallCount());
+ Assert.assertEquals(5, listener.getWorkCompletedCallCount());
+ Assert.assertEquals(0, listener.getWorkExceptions().size());
+ }
+
+ /**
+ * Tests running a mixture of fast and slow jobs some of which fail on the
+ * ThreadPoolWorkManager
+ */
+ @Test
+ public void testMultipleJobsSomeFail() {
+ // Create the work and register it
+ TimeDelayWork fast1 = new TimeDelayWork(5);
+ TimeDelayWork fast2 = new TimeDelayWork(10);
+ TimeDelayWork fast3 = new TimeDelayWork(20);
+ TimeDelayWork slow1= new TimeDelayWork(200);
+ TimeDelayWork slow2 = new TimeDelayWork(200);
+ FailingWork fail1 = new FailingWork();
+ FailingWork fail2 = new FailingWork();
+ TestWorkListener listener = new TestWorkListener();
+ workManager.schedule(fast1, listener);
+ workManager.schedule(fast2, listener);
+ workManager.schedule(fail1, listener);
+ workManager.schedule(fast3, listener);
+ workManager.schedule(slow1, listener);
+ workManager.schedule(fail2, listener);
+ workManager.schedule(slow2, listener);
+
+ // Wait for the 7 jobs to complete
+ waitForWorkToComplete(listener, 7);
+
+ // Test that the job completed successfully.
+ Assert.assertEquals(7, listener.getWorkAcceptedCallCount());
+ Assert.assertEquals(0, listener.getWorkRejectedCallCount());
+ Assert.assertEquals(7, listener.getWorkStartedCallCount());
+ Assert.assertEquals(7, listener.getWorkCompletedCallCount());
+ Assert.assertEquals(2, listener.getWorkExceptions().size());
+ }
+
+ /**
+ * Tests running a single job that has no listener
+ */
+ @Test
+ public void testSingleFastJobWithNoListener() {
+ // Create the work and register it
+ TimeDelayWork fast = new TimeDelayWork(10);
+ workManager.schedule(fast);
+
+ // Wait for the job to complete
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ int completedCount = fast.getRunCompletedCount();
+ if (completedCount == 1) {
+ break;
+ }
+
+ if (System.currentTimeMillis() - startTime > WAIT_TIMEOUT) {
+ Assert.fail("Only " + completedCount + " work items completed before timeout");
+ return;
+ }
+
+ // Lets wait for the job to complete
+ try {
+ Thread.sleep(25);
+ } catch (InterruptedException ex) {
+ Assert.fail("Unexpected exception: " + ex);
+ }
+ }
+
+ // Make sure we have got one completed run
+ Assert.assertEquals(1, fast.getRunCompletedCount());
+ }
+
+ /**
+ * Waits for the specified number of jobs to complete or the timeout to fire.
+ *
+ * @param listener The listener to use to track Work unit completion
+ * @param completedWorkItemsToWaitFor The number of Work items to complete
+ */
+ private void waitForWorkToComplete(TestWorkListener listener, int completedWorkItemsToWaitFor) {
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ int completedCount = listener.getWorkCompletedCallCount();
+ if (completedCount == completedWorkItemsToWaitFor) {
+ return;
+ }
+
+ if (System.currentTimeMillis() - startTime > WAIT_TIMEOUT) {
+ Assert.fail("Only " + completedCount + " work items completed before timeout");
+ return;
+ }
+
+ // Lets wait for more jobs to complete
+ try {
+ Thread.sleep(25);
+ } catch (InterruptedException ex) {
+ Assert.fail("Unexpected exception: " + ex);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java
new file mode 100644
index 0000000000..f6435659ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core.work.impl;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Simple Work item that will sleep in the run() method for the specified
+ * period of time
+ *
+ * @version $Rev$ $Date$
+ */
+public class TimeDelayWork extends Work {
+
+ /**
+ * Count of completed run() method calls
+ */
+ private AtomicInteger runCompletedCount = new AtomicInteger();
+
+ /**
+ * The amount of time to sleep in the Run loop
+ */
+ private final long sleepTime;
+
+ /**
+ * Constructor
+ *
+ * @param sleepTime The amount of time to sleep (in milliseconds) in the run() method
+ */
+ public TimeDelayWork(long sleepTime) {
+ super(null);
+ this.sleepTime = sleepTime;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDaemon() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void release() {
+ }
+
+ /**
+ * Sleeps for a period of time defined by sleepTime
+ */
+ public void run() {
+ System.out.println("Starting " + this);
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("Done " + this);
+ runCompletedCount.incrementAndGet();
+ }
+
+ /**
+ * Returns the number of completed calls to run()
+ *
+ * @return The number of completed calls to run()
+ */
+ public int getRunCompletedCount() {
+ return runCompletedCount.get();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java
new file mode 100644
index 0000000000..ca7bf9b3d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.scope;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.junit.Test;
+/**
+ * @version $Rev$ $Date$
+ */
+public class ScopeTestCase {
+
+ @Test
+ public void testEquals() throws Exception {
+ Scope scope = new Scope("COMPOSITE");
+ assertTrue(scope.equals(Scope.COMPOSITE));
+ }
+
+ @Test
+ public void testEqualsNew() throws Exception {
+ Scope foo = new Scope("foo");
+ Scope foo2 = new Scope("FOO");
+ assertTrue(foo.equals(foo2));
+ }
+
+ @Test
+ public void testNotEquals() throws Exception {
+ Scope foo = new Scope("BAR");
+ Scope foo2 = new Scope("FOO");
+ assertFalse(foo.equals(foo2));
+ }
+
+ @Test
+ public void testNotEqualsDifferent() throws Exception {
+ Scope foo = new Scope("FOO");
+ assertFalse(foo.equals(new Bar("FOO")));
+ }
+
+ public class Bar {
+ String scope;
+
+ public Bar(String scope) {
+ this.scope = scope;
+ }
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest b/sandbox/sebastien/java/embed/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
new file mode 100644
index 0000000000..ad23df3761
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name=implementation.last, stage=implementation, after=*
+name=reference.first, stage=reference, before=*
+name=reference.transaction, stage=reference, after=reference.interface
+name=reference.binding.header, stage=reference.binding, after=reference.binding.transport
+name=service.binding.header, stage=service.binding, after=service.binding.transport
+name=service.transaction, stage=service, after=service.binding, before=component.service
+name=implementation.transaction, stage=implementation, before=implementation.policy
diff --git a/sandbox/sebastien/java/embed/modules/data-api/LICENSE b/sandbox/sebastien/java/embed/modules/data-api/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/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/sebastien/java/embed/modules/data-api/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/data-api/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a8b156bff2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.data.collection;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data API
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data API
+Import-Package:
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.data.api
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/data-api/NOTICE b/sandbox/sebastien/java/embed/modules/data-api/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/data-api/pom.xml b/sandbox/sebastien/java/embed/modules/data-api/pom.xml
new file mode 100644
index 0000000000..5da4d2ef0a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/pom.xml
@@ -0,0 +1,38 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-data-api</artifactId>
+ <name>Apache Tuscany SCA Data API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java
new file mode 100644
index 0000000000..fa4da391a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.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.data.collection;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+@Remotable
+public interface Collection <K, D> {
+
+ /**
+ * Get the whole collection.
+ *
+ * @return the whole collection.
+ */
+ Entry<K, D>[] getAll();
+
+ /**
+ * Returns a collection resulting from a query.
+ *
+ * @return the collection.
+ */
+ Entry<K, D>[] query(String queryString);
+
+ /**
+ * Creates a new item.
+ *
+ * @param key
+ * @param item
+ * @return
+ */
+ K post(K key, D item);
+
+ /**
+ * Retrieves an item.
+ *
+ * @param key
+ * @return
+ */
+ D get(K key) throws NotFoundException;
+
+ /**
+ * Updates an item.
+ *
+ * @param key
+ * @param item
+ * @return
+ */
+ void put(K key, D item) throws NotFoundException;
+
+ /**
+ * Delete an item.
+ *
+ * @param key
+ */
+ void delete(K key) throws NotFoundException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java
new file mode 100644
index 0000000000..f9ecd6c641
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.data.collection;
+
+
+/**
+ * Represents a key/data pair in a data collection.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class Entry <K, D> {
+
+ private K key;
+ private D data;
+
+ /**
+ * Constructs a new entry.
+ */
+ public Entry() {
+ }
+
+ /**
+ * Constructs a new entry.
+ * @param key the entry key
+ * @param data the entry data
+ */
+ public Entry(K key, D data) {
+ this.key = key;
+ this.data = data;
+ }
+
+ /**
+ * Returns the entry key.
+ * @return the key
+ */
+ public K getKey() {
+ return key;
+ }
+
+ /**
+ * Sets the entry key.
+ * @param key the key
+ */
+ public void setKey(K key) {
+ this.key = key;
+ }
+
+ /**
+ * Returns the entry data.
+ * @return the entry data
+ */
+ public D getData() {
+ return data;
+ }
+
+ /**
+ * Sets the entry data
+ * @param data the entry data
+ */
+ public void setData(D data) {
+ this.data = data;
+ }
+
+ //FIXME Temporary methods to make JAXB register the Item
+ // class when the Entry class is registered in a JAXB context
+ public void setDummy(Item item) {}
+ public Item getDummy() { return null; }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java
new file mode 100644
index 0000000000..37042c0895
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.data.collection;
+
+import java.util.Date;
+
+
+/**
+ * Represents a data item.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Item {
+
+ private String title;
+ private String contents;
+ private String link;
+ private String related;
+ private String alternate;
+ private Date date;
+
+ /**
+ * Constructs a new item.
+ */
+ public Item() {
+ }
+
+ /**
+ * Constructs a new item.
+ * @param title the item title
+ * @param contents the item contents
+ * @param link the item link to a web resource
+ * @param related the item link to a related web resource
+ * @param date the item date
+ */
+ public Item(String title, String contents, String link, String related, Date date) {
+ this.title = title;
+ this.contents = contents;
+ this.link = link;
+ this.related = related;
+ this.date = date;
+ }
+
+ /**
+ * Returns the item title.
+ * @return the item title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets the item title.
+ * @param title the item title
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Returns the item contents
+ * @return the item contents
+ */
+ public String getContents() {
+ return contents;
+ }
+
+ /**
+ * Sets the item contents
+ * @param contents the item contents
+ */
+ public void setContents(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Returns the item link to a web resource
+ * @return the item link to a web resource
+ */
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * Sets the item link to a web resource
+ * @param link the item link to a web resource
+ */
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ /**
+ * Returns the item link to a related web resource
+ * @return the item link to a related web resource
+ */
+ public String getRelated() {
+ return related;
+ }
+
+ /**
+ * Sets the item link to a related web resource.
+ *
+ * @param related the item link to a related web resource
+ */
+ public void setRelated(String related) {
+ this.related = related;
+ }
+
+ /**
+ * Returns the item link to an alternate web resource
+ * @return the item link to an alternate web resource
+ */
+ public String getAlternate() {
+ return alternate;
+ }
+
+ /**
+ * Sets the item link to an alternate web resource.
+ *
+ * @param alternate the item link to an alternate web resource
+ */
+ public void setAlternate(String alternate) {
+ this.alternate = alternate;
+ }
+
+ /**
+ * Returns the item date
+ * @return the item date
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * Sets the item date
+ * @param date the item date
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java
new file mode 100644
index 0000000000..229b29f5cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.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.data.collection;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface ItemCollection extends Collection<String, Item> {
+}
diff --git a/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java
new file mode 100644
index 0000000000..69512058b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.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 org.apache.tuscany.sca.data.collection;
+
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface LocalItemCollection extends Collection<String, Item> {
+}
diff --git a/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java
new file mode 100644
index 0000000000..7f13db5228
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.data.collection;
+
+/**
+ * Indicates that an item could not be found in a collection.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NotFoundException extends Exception {
+ private static final long serialVersionUID = 6792367409396084646L;
+
+ public NotFoundException() {
+ }
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+ public NotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/LICENSE b/sandbox/sebastien/java/embed/modules/databinding-axiom/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/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/sebastien/java/embed/modules/databinding-axiom/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/databinding-axiom/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..545f8432ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.databinding.axiom;uses:="org.ap
+ ache.tuscany.sca.databinding,org.apache.tuscany.sca.interfacedef.util
+ ,org.apache.tuscany.sca.databinding.impl,org.apache.axiom.om.impl.bui
+ lder,org.apache.tuscany.sca.interfacedef,org.apache.axiom.om,javax.xm
+ l.namespace,javax.xml.stream,org.apache.tuscany.sca.interfacedef.impl
+ ,org.apache.tuscany.sca.databinding.javabeans";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data Binding for Axiom
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data Binding for Axiom
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om,
+ org.apache.axiom.om.impl.builder,
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.axiom;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="1.4",
+ org.apache.tuscany.sca.policy;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding.axiom
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/NOTICE b/sandbox/sebastien/java/embed/modules/databinding-axiom/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/pom.xml b/sandbox/sebastien/java/embed/modules/databinding-axiom/pom.xml
new file mode 100644
index 0000000000..f46bd41d7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/pom.xml
@@ -0,0 +1,112 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <name>Apache Tuscany SCA Data Binding for Axiom</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ </dependency>
+ -->
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.8</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java
new file mode 100644
index 0000000000..014a0f5223
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.axiom;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * DataBinding for AXIOM
+ *
+ * @version $Rev$ $Date$
+ */
+public class AxiomDataBinding extends BaseDataBinding {
+
+ public static final String NAME = OMElement.class.getName();
+
+ public AxiomDataBinding() {
+ super(NAME, OMElement.class);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.impl.BaseDataBinding#getWrapperHandler()
+ */
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return new OMElementWrapperHandler();
+ }
+
+ @Override
+ public Object copy(Object source,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ if ( OMElement.class.isAssignableFrom(source.getClass()) ) {
+ try {
+ OMElement sourceElement = (OMElement)source;
+ return sourceElement.cloneOMElement();
+ } catch ( Exception e ) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return super.copy(source, sourceDataType, targetDataType, sourceOperation, targetOperation);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomHelper.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomHelper.java
new file mode 100644
index 0000000000..cd820ab4b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomHelper.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.axiom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Helper for AXIOM
+ *
+ * @version $Rev$ $Date$
+ */
+public class AxiomHelper {
+ private static final String DEFAULT_PREFIX = "_ns_";
+
+ private AxiomHelper() {
+ }
+
+ /**
+ * See http://issues.apache.org/jira/browse/WSCOMMONS-240
+ * @param om
+ */
+ public static void completeAndClose(OMElement om) {
+ // Get the builder associated with the om element
+ OMXMLParserWrapper builder = om.getBuilder();
+ if (builder != null) {
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).releaseParserOnClose(true);
+ }
+ OMElement document = builder.getDocumentElement();
+ if (document != null) {
+ document.build();
+ }
+ }
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).close();
+ }
+ }
+
+ /**
+ * This method will close the builder immediately. Any subsequent Axiom objects won't
+ * be built or accessible.
+ */
+ public static void closeImmediately(OMElement om) {
+ // Get the builder associated with the om element
+ OMXMLParserWrapper builder = om.getBuilder();
+ if (builder != null) {
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).releaseParserOnClose(true);
+ ((StAXBuilder)builder).close();
+ }
+ // builder.close();
+ }
+ }
+
+ /**
+ * @param context
+ * @param element
+ */
+ public static void adjustElementName(TransformationContext context, OMElement element) {
+ if (context != null) {
+ DataType dataType = context.getTargetDataType();
+ Object logical = dataType == null ? null : dataType.getLogical();
+ if (!(logical instanceof XMLType)) {
+ return;
+ }
+ XMLType xmlType = (XMLType)logical;
+ if (xmlType.isElement() && !xmlType.getElementName().equals(element.getQName())) {
+ // FIXME:: Throw exception or switch to the new Element?
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ QName name = xmlType.getElementName();
+ OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix());
+ element.setNamespace(namespace);
+ element.setLocalName(name.getLocalPart());
+ }
+ }
+ }
+
+ public static OMElement createOMElement(OMFactory factory, QName element) {
+ String localName = element.getLocalPart();
+ OMNamespace ns = createOMNamespace(factory, element);
+
+ return factory.createOMElement(localName, ns);
+
+ }
+
+ public static OMElement createOMElement(OMFactory factory, QName element, OMDataSource dataSource) {
+ String localName = element.getLocalPart();
+ OMNamespace ns = createOMNamespace(factory, element);
+
+ return factory.createOMElement(dataSource, localName, ns);
+
+ }
+
+ /**
+ * @param factory
+ * @param name
+ * @return
+ */
+ public static OMNamespace createOMNamespace(OMFactory factory, QName name) {
+ String namespaceURI = name.getNamespaceURI();
+ String prefix = name.getPrefix();
+
+ OMNamespace ns = null;
+
+ // Qualified Element: we need an OMNamespace
+ if (prefix.length() == 0) {
+ // The prefix does not appear to be specified, let's create one
+ prefix = DEFAULT_PREFIX;
+ }
+ ns = factory.createOMNamespace(namespaceURI, prefix);
+
+ return ns;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java
new file mode 100644
index 0000000000..f44297edb7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.axiom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.javabeans.Java2XMLMapperException;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLTransformer;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Exception2OMElement extends JavaBean2XMLTransformer<OMElement> {
+
+ public static final String GETCAUSE = "getCause";
+ public static final String GETLOCALIZEDMESSAGE = "getLocalizedMessage";
+ public static final String GETSTACKTRACE = "getStackTrace";
+ public static final String GETCLASS = "getClass";
+
+ private OMFactory factory;
+
+ public Exception2OMElement() {
+ super();
+ factory = OMAbstractFactory.getOMFactory();
+ }
+
+ @Override
+ public OMElement transform(Object source, TransformationContext context) {
+ OMElement element = super.transform(source, context);
+ AxiomHelper.adjustElementName(context, element);
+ return element;
+ }
+
+ @Override
+ protected boolean isMappedGetter(String methodName) {
+ if (GETCAUSE.equals(methodName)
+ || GETLOCALIZEDMESSAGE.equals(methodName)
+ || GETSTACKTRACE.equals(methodName)
+ || GETCLASS.equals(methodName)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ @Override
+ public void appendChild(OMElement parentElement, OMElement childElement) throws Java2XMLMapperException {
+ parentElement.addChild(childElement);
+ }
+
+ @Override
+ public OMElement createElement(QName qName) throws Java2XMLMapperException {
+ return factory.createOMElement(qName);
+ }
+
+ @Override
+ public void appendText(OMElement parentElement, String textData) throws Java2XMLMapperException {
+ if (textData == null) {
+ OMNamespace xsi = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
+ OMAttribute nil = factory.createOMAttribute("nil", xsi, "true");
+ parentElement.addAttribute(nil);
+ } else {
+ factory.createOMText(parentElement, textData);
+ }
+ }
+
+ @Override
+ public Class getTargetType() {
+ return OMElement.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java
new file mode 100644
index 0000000000..cede1c4689
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.axiom;
+
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.ObjectOutputStream;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Externalizable2OMElement extends BaseTransformer<Externalizable, OMElement> implements
+ PullTransformer<Externalizable, OMElement> {
+
+ @Override
+ protected Class<Externalizable> getSourceType() {
+ return Externalizable.class;
+ }
+
+ @Override
+ protected Class<OMElement> getTargetType() {
+ return OMElement.class;
+ }
+
+ public OMElement transform(Externalizable source, TransformationContext context) {
+ OMElement element = null;
+
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(bos);
+ out.writeObject(source);
+ out.close();
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = AxiomHelper.createOMNamespace(factory, new QName("http://callable"));
+ element = factory.createOMElement("reference",ns);
+ element.setText(Base64Binary.encode(bos.toByteArray()));
+ return element;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java
new file mode 100644
index 0000000000..947cd99a19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.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.databinding.axiom;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer;
+import org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException;
+
+/**
+ * Transformer to convert data from an OMElement to a Java Exception
+ *
+ * @version $Rev$ $Date$
+ */
+public class OMElement2Exception extends XML2JavaBeanTransformer<OMElement> {
+
+ @Override
+ public OMElement getRootElement(OMElement element) throws XML2JavaMapperException {
+ return element;
+ }
+
+ @Override
+ public Iterator<OMElement> getChildElements(OMElement parent) throws XML2JavaMapperException {
+ return parent.getChildElements();
+ }
+
+ @Override
+ public String getElementName(OMElement element) throws XML2JavaMapperException {
+ return element.getLocalName();
+ }
+
+ @Override
+ public String getText(OMElement element) throws XML2JavaMapperException {
+ return element.getText();
+ }
+
+ @Override
+ public boolean isTextElement(OMElement element) throws XML2JavaMapperException {
+ return false;
+ }
+
+ @Override
+ public boolean isTextOnly(OMElement element) throws XML2JavaMapperException {
+ OMNode firstChild = element.getFirstOMChild();
+ return firstChild instanceof OMText && firstChild.getNextOMSibling() == null;
+ }
+
+ @Override
+ public OMElement getFirstChildWithName(OMElement element, QName name) throws XML2JavaMapperException {
+ return element.getFirstChildWithName(name);
+ }
+
+ @Override
+ public Class getSourceType() {
+ return OMElement.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java
new file mode 100644
index 0000000000..f4bbea81cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.axiom;
+
+import java.io.ByteArrayInputStream;
+import java.io.Externalizable;
+import java.io.ObjectInputStream;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary;
+
+/**
+ * Transformer to convert data from an OMElement to XML String
+ *
+ * @version $Rev$ $Date$
+ */
+public class OMElement2Externalizable extends BaseTransformer<OMElement, Externalizable> implements PullTransformer<OMElement, Externalizable> {
+ // private XmlOptions options;
+
+ public Externalizable transform(OMElement source, TransformationContext context) {
+ try {
+ String value = source.getText();
+ ByteArrayInputStream bis = new ByteArrayInputStream(Base64Binary.decode(value));
+ ObjectInputStream ois = new ObjectInputStream(bis);
+ Object obj = ois.readObject();
+ ois.close();
+ Externalizable aReference = (Externalizable) obj;
+ return aReference;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<OMElement> getSourceType() {
+ return OMElement.class;
+ }
+
+ @Override
+ protected Class<Externalizable> getTargetType() {
+ return Externalizable.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Object.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Object.java
new file mode 100644
index 0000000000..ea40e61746
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Object.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.databinding.axiom;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.databinding.impl.SimpleType2JavaTransformer;
+
+/**
+ * Transformer to convert data from a simple java Object to OMElement.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OMElement2Object extends SimpleType2JavaTransformer<OMElement> {
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.impl.SimpleType2JavaTransformer#close(java.lang.Object)
+ */
+ @Override
+ protected void close(OMElement source) {
+ if (source != null) {
+ AxiomHelper.completeAndClose(source);
+ }
+ }
+
+ @Override
+ protected String getText(OMElement source) {
+ return source.getText();
+ }
+
+ @Override
+ public Class getSourceType() {
+ return OMElement.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2String.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2String.java
new file mode 100644
index 0000000000..0fc2cfa8a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2String.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.axiom;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+
+/**
+ * Transformer to convert data from an OMElement to XML String
+ *
+ * @version $Rev$ $Date$
+ */
+public class OMElement2String extends BaseTransformer<OMElement, String> implements PullTransformer<OMElement, String> {
+ // private XmlOptions options;
+
+ public String transform(OMElement source, TransformationContext context) {
+ try {
+ StringWriter writer = new StringWriter();
+ source.serialize(writer);
+ return writer.toString();
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<OMElement> getSourceType() {
+ return OMElement.class;
+ }
+
+ @Override
+ protected Class<String> getTargetType() {
+ return String.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java
new file mode 100644
index 0000000000..e0da9ad428
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.axiom;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class OMElement2XMLStreamReader extends BaseTransformer<OMElement, XMLStreamReader> implements
+ PullTransformer<OMElement, XMLStreamReader> {
+ // private XmlOptions options;
+
+ public static final QName QNAME_NIL = new QName("http://www.w3.org/2001/XMLSchema-instance", "nil");
+
+ public XMLStreamReader transform(OMElement source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ } else {
+ if ("true".equals(source.getAttributeValue(QNAME_NIL))) {
+ return null;
+ } else {
+ return source.getXMLStreamReader();
+ }
+ }
+ }
+
+ @Override
+ protected Class<OMElement> getSourceType() {
+ return OMElement.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java
new file mode 100644
index 0000000000..9084f09dc0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.axiom;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * OMElement wrapper handler implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class OMElementWrapperHandler implements WrapperHandler<OMElement> {
+
+ private OMFactory factory;
+
+ public OMElementWrapperHandler() {
+ super();
+ this.factory = OMAbstractFactory.getOMFactory();
+ }
+
+ public OMElement create(Operation operation, boolean input) {
+ WrapperInfo wrapperInfo = operation.getWrapper();
+ ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement();
+ // Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass();
+ OMElement wrapper = AxiomHelper.createOMElement(factory, element.getQName());
+ return wrapper;
+ }
+
+ public void setChildren(OMElement wrapper, Object[] childObjects, Operation operation, boolean input) {
+ List<ElementInfo> childElements =
+ input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements();
+ for (int i = 0; i < childElements.size(); i++) {
+ setChild(wrapper, i, childElements.get(i), childObjects[i]);
+ }
+
+ }
+
+ public void setChild(OMElement wrapper, int i, ElementInfo childElement, Object value) {
+ if (childElement.isMany()) {
+ Object[] elements = (Object[])value;
+ if (value != null) {
+ for (Object e : elements) {
+ addChild(wrapper, childElement, (OMElement)e);
+ }
+ }
+ } else {
+ OMElement element = (OMElement)value;
+ addChild(wrapper, childElement, element);
+ }
+ }
+
+ private void addChild(OMElement wrapper, ElementInfo childElement, OMElement element) {
+ if (element == null) {
+ OMElement e = wrapper.getOMFactory().createOMElement(childElement.getQName(), wrapper);
+ attachXSINil(e);
+ return;
+ }
+ QName elementName = childElement.getQName();
+ // Make it a bit tolerating of element QName
+ if (!elementName.equals(element.getQName())) {
+ OMNamespace namespace = factory.createOMNamespace(elementName.getNamespaceURI(), elementName.getPrefix());
+ element.setNamespace(namespace);
+ element.setLocalName(childElement.getQName().getLocalPart());
+ }
+ wrapper.addChild(element);
+ }
+
+ public List getChildren(OMElement wrapper, Operation operation, boolean input) {
+ List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements():
+ operation.getWrapper().getOutputChildElements();
+
+ List<Object> elements = new ArrayList<Object>();
+ int i = 0;
+ for (ElementInfo e : childElements) {
+ elements.add(getChild(wrapper, e, i));
+ i++;
+ }
+ return elements;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean)
+ */
+ public DataType getWrapperType(Operation operation, boolean input) {
+ WrapperInfo wrapper = operation.getWrapper();
+ ElementInfo element = input ? wrapper.getInputWrapperElement() : wrapper.getOutputWrapperElement();
+ DataType<XMLType> wrapperType =
+ new DataTypeImpl<XMLType>(AxiomDataBinding.NAME, OMElement.class, new XMLType(element));
+ return wrapperType;
+ }
+
+ public boolean isInstance(Object wrapperObj, Operation operation, boolean input) {
+ WrapperInfo wrapperInfo = operation.getWrapper();
+ ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement();
+ // List<ElementInfo> childElements =
+ // input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements();
+ OMElement wrapper = (OMElement)wrapperObj;
+ if (!element.getQName().equals(wrapper.getQName())) {
+ return false;
+ }
+ return true;
+ /*
+ Set<QName> names = new HashSet<QName>();
+ for (ElementInfo e : childElements) {
+ names.add(e.getQName());
+ }
+ for (Iterator i = wrapper.getChildElements(); i.hasNext();) {
+ OMElement child = (OMElement)i.next();
+ if (!names.contains(child.getQName())) {
+ return false;
+ }
+ }
+ return true;
+ */
+ }
+
+ private static final QName XSI_TYPE_QNAME = new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi");
+
+ private List<List<OMElement>> getElements(OMElement wrapper) {
+ List<List<OMElement>> elements = new ArrayList<List<OMElement>>();
+ List<OMElement> current = new ArrayList<OMElement>();
+ elements.add(current);
+ boolean first = true;
+ QName last = null;
+
+ for (Iterator i = wrapper.getChildElements(); i.hasNext();) {
+ OMElement element = (OMElement)i.next();
+ if (first || element.getQName().equals(last)) {
+ current.add(element);
+ last = element.getQName();
+ } else {
+ current = new ArrayList<OMElement>();
+ elements.add(current);
+ current.add(element);
+ last = element.getQName();
+ }
+ first = false;
+ }
+ return elements;
+ }
+
+ public Object getChild(OMElement wrapper, ElementInfo childElement, int index) {
+ Iterator children = wrapper.getChildrenWithName(childElement.getQName());
+ if (!children.hasNext()) {
+ // No name match, try by index
+ List<List<OMElement>> list = getElements(wrapper);
+ List<OMElement> elements = list.get(index);
+ if (!childElement.isMany()) {
+ return elements.isEmpty() ? null : attachXSIType(childElement, elements.get(0));
+ } else {
+ Object[] array = elements.toArray();
+ for (Object item : array) {
+ attachXSIType(childElement, (OMElement)item);
+ }
+ return array;
+ }
+ }
+ if (!childElement.isMany()) {
+ if (children.hasNext()) {
+ OMElement child = (OMElement)children.next();
+ attachXSIType(childElement, child);
+ return child;
+ } else {
+ return null;
+ }
+ } else {
+ List<OMElement> elements = new ArrayList<OMElement>();
+ for (; children.hasNext();) {
+ OMElement child = (OMElement)children.next();
+ attachXSIType(childElement, child);
+ elements.add(child);
+ }
+ return elements.toArray();
+ }
+ }
+
+ /**
+ * Create xis:type if required
+ * @param childElement
+ * @param element
+ * @return
+ */
+ private OMElement attachXSIType(ElementInfo childElement, OMElement element) {
+ TypeInfo type = childElement.getType();
+ if (type != null && type.getQName() != null) {
+ OMAttribute attr = element.getAttribute(XSI_TYPE_QNAME);
+ if (attr == null) {
+ String typeNS = type.getQName().getNamespaceURI();
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(typeNS)) {
+ return element;
+ }
+ OMNamespace ns = element.getOMFactory().createOMNamespace(typeNS, "_typens_");
+ element.declareNamespace(ns);
+ OMNamespace xsiNS =
+ element.getOMFactory().createOMNamespace(XSI_TYPE_QNAME.getNamespaceURI(),
+ XSI_TYPE_QNAME.getPrefix());
+ element.declareNamespace(xsiNS);
+ attr =
+ element.getOMFactory().createOMAttribute("type",
+ xsiNS,
+ "_typens_:" + type.getQName().getLocalPart());
+ element.addAttribute(attr);
+ }
+ }
+ return element;
+ }
+
+ private void attachXSINil(OMElement element) {
+ OMNamespace xsiNS =
+ element.getOMFactory().createOMNamespace(XSI_TYPE_QNAME.getNamespaceURI(), XSI_TYPE_QNAME.getPrefix());
+ element.declareNamespace(xsiNS);
+ OMAttribute attr = element.getOMFactory().createOMAttribute("nil", xsiNS, "true");
+ element.addAttribute(attr);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Object2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Object2OMElement.java
new file mode 100644
index 0000000000..88d6b462c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Object2OMElement.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.sca.databinding.axiom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.Java2SimpleTypeTransformer;
+
+/**
+ * Transformer to convert data from an simple OMElement to Java Object
+ *
+ * @version $Rev$ $Date$
+ */
+public class Object2OMElement extends Java2SimpleTypeTransformer<OMElement> {
+
+ private OMFactory factory;
+
+ public Object2OMElement() {
+ super();
+ factory = OMAbstractFactory.getOMFactory();
+ }
+
+ @Override
+ protected OMElement createElement(QName element, String text, TransformationContext context) {
+ OMElement omElement = AxiomHelper.createOMElement(factory, element);
+ if (text == null) {
+ OMNamespace xsi = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
+ OMAttribute nil = factory.createOMAttribute("nil", xsi, "true");
+ omElement.addAttribute(nil);
+ } else {
+ factory.createOMText(omElement, text);
+ }
+ return omElement;
+ }
+
+ @Override
+ public Class getTargetType() {
+ return OMElement.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/String2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/String2OMElement.java
new file mode 100644
index 0000000000..4881eef105
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/String2OMElement.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.axiom;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class String2OMElement extends BaseTransformer<String, OMElement> implements
+ PullTransformer<String, OMElement> {
+
+ @SuppressWarnings("unchecked")
+ public OMElement transform(String source, TransformationContext context) {
+ try {
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(source.getBytes()));
+ OMElement element = builder.getDocumentElement();
+ AxiomHelper.adjustElementName(context, element);
+ return element;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<OMElement> getTargetType() {
+ return OMElement.class;
+ }
+
+ @Override
+ protected Class<String> getSourceType() {
+ return String.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/XMLStreamReader2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/XMLStreamReader2OMElement.java
new file mode 100644
index 0000000000..173a9ab384
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/XMLStreamReader2OMElement.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.databinding.axiom;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLStreamReader2OMElement extends BaseTransformer<XMLStreamReader, OMElement> implements
+ PullTransformer<XMLStreamReader, OMElement> {
+
+ public XMLStreamReader2OMElement() {
+ super();
+ }
+
+ public OMElement transform(XMLStreamReader source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ StAXOMBuilder builder = new StAXOMBuilder(source);
+ OMElement element = builder.getDocumentElement();
+ AxiomHelper.adjustElementName(context, element);
+ return element;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<OMElement> getTargetType() {
+ return OMElement.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
new file mode 100644
index 0000000000..f2b874e0e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# implementation classes for the databindings
+org.apache.tuscany.sca.databinding.axiom.AxiomDataBinding;name=org.apache.axiom.om.OMElement
+
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..70318b3930
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -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.
+
+# Implementation classes for the transformers
+# org.apache.tuscany.sca.databinding.axiom.CallableReference2OMElement;source=org.oasisopen.sca.CallableReference,target=org.apache.axiom.om.OMElement,weight=10
+# org.apache.tuscany.sca.databinding.axiom.OMElement2CallableReference;source=org.apache.axiom.om.OMElement,target=org.oasisopen.sca.CallableReference,weight=10
+org.apache.tuscany.sca.databinding.axiom.Externalizable2OMElement;source=java.io.Externalizable,target=org.apache.axiom.om.OMElement,weight=10
+org.apache.tuscany.sca.databinding.axiom.OMElement2Externalizable;source=org.apache.axiom.om.OMElement,target=java.io.Externalizable,weight=10
+org.apache.tuscany.sca.databinding.axiom.Exception2OMElement;source=java:exception,target=org.apache.axiom.om.OMElement,weight=10
+org.apache.tuscany.sca.databinding.axiom.OMElement2Exception;source=org.apache.axiom.om.OMElement,target=java:exception,weight=10
+# org.apache.tuscany.sca.databinding.axiom.Object2OMElement;source=java:simpleType,target=org.apache.axiom.om.OMElement,weight=80000
+# org.apache.tuscany.sca.databinding.axiom.OMElement2Object;source=org.apache.axiom.om.OMElement,target=java:simpleType,weight=80000
+org.apache.tuscany.sca.databinding.axiom.OMElement2String;source=org.apache.axiom.om.OMElement,target=java.lang.String,weight=80
+org.apache.tuscany.sca.databinding.axiom.OMElement2XMLStreamReader;source=org.apache.axiom.om.OMElement,target=javax.xml.stream.XMLStreamReader,weight=60
+org.apache.tuscany.sca.databinding.axiom.String2OMElement;source=java.lang.String,target=org.apache.axiom.om.OMElement,weight=80
+org.apache.tuscany.sca.databinding.axiom.XMLStreamReader2OMElement;source=javax.xml.stream.XMLStreamReader,target=org.apache.axiom.om.OMElement,weight=60
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementTestCase.java
new file mode 100644
index 0000000000..951a0483cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementTestCase.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.axiom;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class OMElementTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ public final void testStringTransform() {
+ String2OMElement t1 = new String2OMElement();
+ OMElement element = t1.transform(IPO_XML, null);
+ OMElement2String t2 = new OMElement2String();
+ String xml = t2.transform(element, null);
+ Assert.assertNotNull(xml);
+ Assert.assertNotNull(xml.indexOf("<ipo:comment>") != -1);
+ }
+
+ public final void testStringTransform2() {
+ String str =
+ "<p0:firstName xmlns:xml=\"http://www.w3.org/XML/1998/namespace\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ + "xmlns:p0=\"http://helloworld\">Robert</p0:firstName>";
+ String2OMElement t1 = new String2OMElement();
+ OMElement element = t1.transform(str, null);
+ OMElement2String t2 = new OMElement2String();
+ String xml = t2.transform(element, null);
+ Assert.assertNotNull(xml);
+ Assert.assertNotNull(xml.indexOf("<ipo:comment>") != -1);
+ }
+
+ public final void testStAXTransform() {
+ String2OMElement t1 = new String2OMElement();
+ OMElement element = t1.transform(IPO_XML, null);
+
+ OMElement2XMLStreamReader t2 = new OMElement2XMLStreamReader();
+ XMLStreamReader reader = t2.transform(element, null);
+
+ XMLStreamReader2OMElement t3 = new XMLStreamReader2OMElement();
+ OMElement element2 = t3.transform(reader, null);
+
+ Assert.assertEquals(element2.getQName(), element.getQName());
+ Assert.assertEquals(new QName("http://www.example.com/IPO", "purchaseOrder"), element2.getQName());
+ }
+
+ public final void testCopy() {
+ String2OMElement t1 = new String2OMElement();
+ OMElement element = t1.transform(IPO_XML, null);
+ OMElement copy = (OMElement)new AxiomDataBinding().copy(element, null, null, null, null);
+ assertNotSame(element, copy);
+ assertEquals(new QName("http://www.example.com/IPO", "purchaseOrder"), copy.getQName());
+ }
+
+ private static final QName XSI_NIL = new QName("http://www.w3.org/2001/XMLSchema-instance", "nil", "xsi");
+
+ public final void testNil() {
+ Object2OMElement t1 = new Object2OMElement();
+ TransformationContext context = new TransformationContextImpl();
+ DataType<XMLType> dataType =
+ new DataTypeImpl<XMLType>(int.class, new XMLType(new QName("http://ns1", "nilElement"),
+ SimpleTypeMapperImpl.XSD_INT));
+ context.setTargetDataType(dataType);
+ OMElement element = t1.transform(null, context);
+ OMAttribute attribute = element.getAttribute(XSI_NIL);
+ Assert.assertNotNull(attribute);
+ Assert.assertEquals("true", attribute.getAttributeValue());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/ipo.xml b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/ipo.xml
new file mode 100644
index 0000000000..df901d183d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/ipo.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ipo:purchaseOrder
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ipo="http://www.example.com/IPO"
+ xsi:schemaLocation="http://www.example.com/IPO ipo.xsd"
+ orderDate="1999-12-01">
+
+ <shipTo exportCode="1" xsi:type="ipo:UKAddress">
+ <name>Helen Zoe</name>
+ <street>47 Eden Street</street>
+ <city>Cambridge</city>
+ <postcode>CB1 1JR</postcode>
+ </shipTo>
+
+ <billTo xsi:type="ipo:USAddress">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Old Town</city>
+ <state>PA</state>
+ <zip>95819</zip>
+ </billTo>
+
+ <items>
+ <item partNum="833-AA">
+ <productName>Lapis necklace</productName>
+ <quantity>1</quantity>
+ <USPrice>99.95</USPrice>
+ <ipo:comment>Want this for the holidays</ipo:comment>
+ <shipDate>1999-12-05</shipDate>
+ </item>
+ </items>
+</ipo:purchaseOrder>
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/ipo.xsd b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..af1e73172d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/ipo.xsd
@@ -0,0 +1,137 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/order.wsdl b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/order.wsdl
new file mode 100644
index 0000000000..913d9e4928
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-axiom/src/test/resources/order.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/order.wsdl" xmlns:tns="http://example.com/order.wsdl"
+ xmlns:xsd1="http://example.com/order.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/order.xsd" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd"/>
+ <element name="checkOrderStatus">
+ <complexType>
+ <sequence>
+ <element name="customerId" type="string" />
+ <element name="order" type="ipo:PurchaseOrderType" />
+ <element name="flag" type="int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="checkOrderStatusResponse">
+ <complexType>
+ <sequence>
+ <element name="status" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="note" type="string" />
+ </schema>
+ </types>
+
+ <message name="CheckOrderStatusInput1">
+ <part name="body" element="xsd1:checkOrderStatus" />
+ </message>
+
+ <message name="CheckOrderStatusOutput1">
+ <part name="body" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <message name="CheckOrderStatusInput2">
+ <part name="p1" element="xsd1:checkOrderStatus" />
+ <part name="p2" element="xsd1:note" />
+ </message>
+
+ <message name="CheckOrderStatusOutput2">
+ <part name="p1" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <portType name="OrderPortType">
+ <operation name="checkOrderStatus">
+ <input message="tns:CheckOrderStatusInput1" />
+ <output message="tns:CheckOrderStatusOutput1" />
+ </operation>
+ <operation name="checkOrderStatus2">
+ <input message="tns:CheckOrderStatusInput2" />
+ <output message="tns:CheckOrderStatusOutput2" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/LICENSE b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/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/sebastien/java/embed/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..334906b75b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF
@@ -0,0 +1,38 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.databinding.jaxb.axiom;version
+ ="1.4",org.apache.tuscany.sca.databinding.jaxb.axiom.ext;version="1.4
+ "
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data Binding for JAXB-AXIOM
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data Binding for JAXB-AXIOM
+Import-Package: javax.xml.bind,
+ javax.xml.bind.annotation;resolution:=optional,
+ javax.xml.bind.attachment,
+ javax.xml.datatype;resolution:=optional,
+ javax.xml.namespace,
+ javax.xml.stream,
+ javax.xml.stream.util,
+ javax.xml.transform,
+ javax.xml.transform.stream,
+ org.apache.axiom.om,
+ org.apache.axiom.om.ds,
+ org.apache.axiom.om.impl,
+ org.apache.axiom.om.impl.builder,
+ org.apache.axiom.om.util,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.jaxb;version="2.0.0",
+ org.apache.tuscany.sca.databinding.jaxb.axiom;resolution:=optional,
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.w3c.dom;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding.jaxb.axiom
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/NOTICE b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/pom.xml b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/pom.xml
new file mode 100644
index 0000000000..744fe474da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/pom.xml
@@ -0,0 +1,175 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding-jaxb-axiom</artifactId>
+ <name>Apache Tuscany SCA Data Binding for JAXB-AXIOM</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.8</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxb-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <version>0.7.1</version>
+ <executions>
+ <execution>
+ <id>generate-jaxb</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generatePackage>com.example.ipo.jaxb</generatePackage>
+ <generateDirectory>${project.build.directory}/jaxb-source</generateDirectory>
+ <schemaDirectory>${basedir}/src/test/resources</schemaDirectory>
+ <schemaIncludes>
+ <include>ipo.xsd</include>
+ </schemaIncludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/AxiomHelper.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/AxiomHelper.java
new file mode 100644
index 0000000000..93277e77bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/AxiomHelper.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb.axiom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Helper for AXIOM
+ *
+ * @version $Rev$ $Date$
+ */
+public class AxiomHelper {
+ private static final String DEFAULT_PREFIX = "_ns_";
+
+ private AxiomHelper() {
+ }
+
+ /**
+ * See http://issues.apache.org/jira/browse/WSCOMMONS-240
+ * @param om
+ */
+ public static void completeAndClose(OMElement om) {
+ // Get the builder associated with the om element
+ OMXMLParserWrapper builder = om.getBuilder();
+ if (builder != null) {
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).releaseParserOnClose(true);
+ }
+ OMElement document = builder.getDocumentElement();
+ if (document != null) {
+ document.build();
+ }
+ }
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).close();
+ }
+ }
+
+ /**
+ * This method will close the builder immediately. Any subsequent Axiom objects won't
+ * be built or accessible.
+ */
+ public static void closeImmediately(OMElement om) {
+ // Get the builder associated with the om element
+ OMXMLParserWrapper builder = om.getBuilder();
+ if (builder != null) {
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).releaseParserOnClose(true);
+ ((StAXBuilder)builder).close();
+ }
+ // builder.close();
+ }
+ }
+
+ /**
+ * @param context
+ * @param element
+ */
+ public static void adjustElementName(TransformationContext context, OMElement element) {
+ if (context != null) {
+ DataType<?> dataType = context.getTargetDataType();
+ Object logical = dataType == null ? null : dataType.getLogical();
+ if (!(logical instanceof XMLType)) {
+ return;
+ }
+ XMLType xmlType = (XMLType)logical;
+ if (xmlType.isElement() && !xmlType.getElementName().equals(element.getQName())) {
+ // FIXME:: Throw exception or switch to the new Element?
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ QName name = xmlType.getElementName();
+ OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix());
+ element.setNamespace(namespace);
+ element.setLocalName(name.getLocalPart());
+ }
+ }
+ }
+
+ public static OMElement createOMElement(OMFactory factory, QName element) {
+ String localName = element.getLocalPart();
+ OMNamespace ns = createOMNamespace(factory, element);
+
+ return factory.createOMElement(localName, ns);
+
+ }
+
+ public static OMElement createOMElement(OMFactory factory, QName element, OMDataSource dataSource) {
+ String localName = element.getLocalPart();
+ OMNamespace ns = createOMNamespace(factory, element);
+
+ return factory.createOMElement(dataSource, localName, ns);
+
+ }
+
+ /**
+ * @param factory
+ * @param name
+ * @return
+ */
+ public static OMNamespace createOMNamespace(OMFactory factory, QName name) {
+ String namespaceURI = name.getNamespaceURI();
+ String prefix = name.getPrefix();
+
+ OMNamespace ns = null;
+ // Qualified Element: we need an OMNamespace
+ if (prefix.length() == 0) {
+ // The prefix does not appear to be specified, let's create one
+ prefix = DEFAULT_PREFIX;
+ }
+ ns = factory.createOMNamespace(namespaceURI, prefix);
+ return ns;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java
new file mode 100644
index 0000000000..c90a1c6d5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb.axiom;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
+
+/**
+ * JAXB Object --> AXIOM OMElement transformer
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXB2OMElement extends BaseTransformer<Object, OMElement> implements PullTransformer<Object, OMElement> {
+ private OMFactory factory = OMAbstractFactory.getOMFactory();
+ private JAXBContextHelper contextHelper;
+
+ public JAXB2OMElement(ExtensionPointRegistry registry) {
+ super();
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+
+ public OMElement transform(Object source, TransformationContext context) throws TransformationException {
+ JAXBContext jaxbContext;
+ try {
+ jaxbContext = contextHelper.createJAXBContext(context, true);
+ } catch (JAXBException e) {
+ throw new TransformationException(e);
+ }
+ Object element = JAXBContextHelper.createJAXBElement(jaxbContext, context.getTargetDataType(), source);
+ QName name = jaxbContext.createJAXBIntrospector().getElementName(element);
+ JAXBDataSource dataSource = new JAXBDataSource(element, jaxbContext, contextHelper);
+ OMElement omElement = AxiomHelper.createOMElement(factory, name, dataSource);
+ return omElement;
+ }
+
+ @Override
+ public Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ public Class<OMElement> getTargetType() {
+ return OMElement.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 3000;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java
new file mode 100644
index 0000000000..0dacce996f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb.axiom;
+
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXBDataSource implements OMDataSource {
+ private JAXBContext context;
+ private Object element;
+ private JAXBContextHelper contextHelper;
+
+ public JAXBDataSource(Object element, JAXBContext context, JAXBContextHelper contextHelper) {
+ this.element = element;
+ this.context = context;
+ this.contextHelper = contextHelper;
+ }
+
+ public XMLStreamReader getReader() throws XMLStreamException {
+ // FIXME: [rfeng] This is a quick and dirty implementation
+ // We could use the fastinfoset to optimize the roundtrip
+ StringWriter writer = new StringWriter();
+ serialize(writer, new OMOutputFormat());
+ StringReader reader = new StringReader(writer.toString());
+ // FIXME: We need to use Tuscany extension point to create the reader
+ return StAXUtils.createXMLStreamReader(reader);
+ }
+
+ public void serialize(final XMLStreamWriter xmlWriter) throws XMLStreamException {
+ try {
+ // marshaller.setProperty(Marshaller.JAXB_ENCODING, format.getCharSetEncoding());
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ Marshaller marshaller = null;
+ try {
+ marshaller = contextHelper.getMarshaller(context);
+ marshaller.marshal(element, xmlWriter);
+ } finally {
+ contextHelper.releaseJAXBMarshaller(context, marshaller);
+ }
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new XMLStreamException(e.getException());
+ }
+ }
+
+ public void serialize(final OutputStream output, OMOutputFormat format) throws XMLStreamException {
+ try {
+ // marshaller.setProperty(Marshaller.JAXB_ENCODING, format.getCharSetEncoding());
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ Marshaller marshaller = null;
+ try {
+ marshaller = contextHelper.getMarshaller(context);
+ marshaller.marshal(element, output);
+ } finally {
+ contextHelper.releaseJAXBMarshaller(context, marshaller);
+ }
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new XMLStreamException(e.getException());
+ }
+ }
+
+ public void serialize(final Writer writer, OMOutputFormat format) throws XMLStreamException {
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ Marshaller marshaller = null;
+ try {
+ marshaller = contextHelper.getMarshaller(context);
+ marshaller.marshal(element, writer);
+ } finally {
+ contextHelper.releaseJAXBMarshaller(context, marshaller);
+ }
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new XMLStreamException(e.getException());
+ }
+ }
+
+ public Object getObject() {
+ return element;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
new file mode 100644
index 0000000000..f7de7f4425
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb.axiom;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.StreamReaderDelegate;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OMElement2JAXB extends BaseTransformer<OMElement, Object> implements PullTransformer<OMElement, Object> {
+ private JAXBContextHelper contextHelper;
+
+ public OMElement2JAXB(ExtensionPointRegistry registry) {
+ super();
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+ @Override
+ public String getSourceDataBinding() {
+ return org.apache.axiom.om.OMElement.class.getName();
+ }
+
+ public Object transform(final OMElement source, final TransformationContext context) throws TransformationException {
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws JAXBException, XMLStreamException {
+ Unmarshaller unmarshaller = null;
+ XMLStreamReader reader = null;
+ Object result = null;
+ // Marshalling directly to the output stream is faster than marshalling through the
+ // XMLStreamWriter.
+ // Take advantage of this optimization if there is an output stream.
+ JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
+ try {
+ unmarshaller = contextHelper.getUnmarshaller(jaxbContext);
+ reader = source.getXMLStreamReaderWithoutCaching();
+ // https://issues.apache.org/jira/browse/WSCOMMONS-395
+ reader = new StreamReaderDelegate(reader) {
+ // Fix the issue in WSCOMMONS-395
+ public String getAttributeType(int index) {
+ String type = super.getAttributeType(index);
+ return type == null ? "CDATA" : type;
+ }
+ };
+ result = unmarshaller.unmarshal(reader, JAXBContextHelper.getJavaType(context.getTargetDataType()));
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ contextHelper.releaseJAXBUnmarshaller(jaxbContext, unmarshaller);
+ }
+ return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new TransformationException(e.getException());
+ }
+ }
+
+ @Override
+ public Class<OMElement> getSourceType() {
+ return OMElement.class;
+ }
+
+ @Override
+ public Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 3000;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBCustomBuilder.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBCustomBuilder.java
new file mode 100644
index 0000000000..f30a6c1cb8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBCustomBuilder.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb.axiom.ext;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.CustomBuilder;
+
+/**
+ * JAXBCustomBuilder creates an OMSourcedElement backed by a JAXBDataSource
+ * for the specified namespace and localPart.
+ */
+public class JAXBCustomBuilder implements CustomBuilder {
+
+ private JAXBDSContext jdsContext;
+
+ /**
+ * Create a JAXBCustomBuilder
+ * @param context JAXBDSContext
+ */
+ public JAXBCustomBuilder(JAXBDSContext context) {
+ super();
+ this.jdsContext = context;
+ }
+
+ public OMElement create(String namespace,
+ String localPart,
+ OMContainer parent,
+ XMLStreamReader reader,
+ OMFactory factory) throws OMException {
+
+ // There are some situations where we want to use normal
+ // unmarshalling, so return null
+ if (!shouldUnmarshal(namespace, localPart)) {
+ // JAXBCustomBuilderMonitor.updateTotalFailedCreates();
+ return null;
+ }
+ try {
+ // Create an OMSourcedElement backed by an unmarshalled JAXB object
+ OMNamespace ns = factory.createOMNamespace(namespace, reader.getPrefix());
+
+ Object jaxb = jdsContext.unmarshal(reader);
+
+ OMDataSource ds = new JAXBDataSourceExt(jaxb, jdsContext);
+ OMElement omse = factory.createOMElement(ds, localPart, ns);
+
+ parent.addChild(omse);
+ // JAXBCustomBuilderMonitor.updateTotalCreates();
+ return omse;
+ } catch (JAXBException e) {
+ // JAXBCustomBuilderMonitor.updateTotalFailedCreates();
+ throw new OMException(e);
+ }
+ }
+
+ /**
+ * The namespace identifier for the SOAP 1.1 envelope.
+ */
+ public static final String URI_NS_SOAP_1_1_ENVELOPE = "http://schemas.xmlsoap.org/soap/envelope/";
+ /**
+ * The namespace identifier for the SOAP 1.2 envelope.
+ */
+ public static final String URI_NS_SOAP_1_2_ENVELOPE = "http://www.w3.org/2003/05/soap-envelope";
+
+ /**
+ * @param namespace
+ * @param localPart
+ * @return true if this ns and local part is acceptable for unmarshalling
+ */
+ private boolean shouldUnmarshal(String namespace, String localPart) {
+
+ // Don't unmarshall SOAPFaults or anything else in the SOAP
+ // namespace.
+ // Don't unmarshall elements that are unqualified
+ if (localPart == null || namespace == null
+ || namespace.length() == 0
+ || URI_NS_SOAP_1_1_ENVELOPE.equals(namespace)
+ || URI_NS_SOAP_1_2_ENVELOPE.equals(namespace)) {
+ return false;
+ }
+
+ // Don't unmarshal if this looks like encrypted data
+ if (localPart.equals("EncryptedData")) {
+ return false;
+ }
+
+ return true;
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java
new file mode 100644
index 0000000000..f6bd33864f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb.axiom.ext;
+
+import java.io.OutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.attachment.AttachmentMarshaller;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+
+/*
+ * To marshal or unmarshal a JAXB object, the JAXBContext is necessary.
+ * In addition, access to the MessageContext and other context objects may be necessary
+ * to get classloader information, store attachments etc.
+ *
+ * The JAXBDSContext bundles all of this information together.
+ */
+public class JAXBDSContext {
+
+ private static final Logger log = Logger.getLogger(JAXBDSContext.class.getName());
+ private static final boolean DEBUG_ENABLED = log.isLoggable(Level.FINER);
+
+ private JAXBContext jaxbContext = null; // JAXBContext
+ private JAXBContextHelper contextHelper;
+
+ /**
+ * "Dispatch" Constructor Use this full constructor when the JAXBContent is provided by the
+ * customer.
+ *
+ * @param jaxbContext
+ */
+ public JAXBDSContext(JAXBContext jaxbContext, JAXBContextHelper contextHelper) {
+ this.jaxbContext = jaxbContext;
+ this.contextHelper = contextHelper;
+ }
+
+ public JAXBContext getJAXBContext() {
+ return jaxbContext;
+ }
+
+ /**
+ * Unmarshal the xml into a JAXB object
+ * @param reader
+ * @return
+ * @throws JAXBException
+ */
+ public Object unmarshal(XMLStreamReader reader) throws JAXBException {
+
+ Unmarshaller u = contextHelper.getUnmarshaller(getJAXBContext());
+
+ Object jaxb = null;
+
+ // Unmarshal into the business object.
+ jaxb = unmarshalElement(u, reader); // preferred and always used for
+ // style=document
+
+ // Successfully unmarshalled the object
+ // JAXBUtils.releaseJAXBUnmarshaller(getJAXBContext(cl), u);
+
+ // Don't close the reader. The reader is owned by the caller, and it
+ // may contain other xml instance data (other than this JAXB object)
+ // reader.close();
+ return jaxb;
+ }
+
+ /**
+ * Marshal the jaxb object
+ * @param obj
+ * @param writer
+ * @param am AttachmentMarshaller, optional Attachment
+ */
+ public void marshal(Object obj, XMLStreamWriter writer) throws JAXBException {
+
+ // Very easy, use the Context to get the Marshaller.
+ // Use the marshaller to write the object.
+ Marshaller m = contextHelper.getMarshaller(getJAXBContext());
+ AttachmentMarshaller am = m.getAttachmentMarshaller();
+ boolean xop = am != null ? am.isXOPPackage() : false;
+ // Marshal the object
+ marshalElement(obj, m, writer, !xop);
+ }
+
+ /**
+ * Preferred way to marshal objects.
+ *
+ * @param b Object that can be rendered as an element and the element name is known by the
+ * Marshaller
+ * @param m Marshaller
+ * @param writer XMLStreamWriter
+ */
+ private static void marshalElement(final Object b,
+ final Marshaller m,
+ final XMLStreamWriter writer,
+ final boolean optimize) {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ // Marshalling directly to the output stream is faster than marshalling through the
+ // XMLStreamWriter.
+ // Take advantage of this optimization if there is an output stream.
+ try {
+ OutputStream os = (optimize) ? getOutputStream(writer) : null;
+ if (os != null) {
+ writer.flush();
+ m.marshal(b, os);
+ } else {
+ m.marshal(b, writer);
+ }
+ } catch (OMException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new OMException(t);
+ }
+ return null;
+ }
+ });
+ }
+
+ /**
+ * If the writer is backed by an OutputStream, then return the OutputStream
+ * @param writer
+ * @return OutputStream or null
+ */
+ private static OutputStream getOutputStream(XMLStreamWriter writer) throws XMLStreamException {
+ if (writer.getClass() == MTOMXMLStreamWriter.class) {
+ return ((MTOMXMLStreamWriter)writer).getOutputStream();
+ }
+ if (writer.getClass() == XMLStreamWriterWithOS.class) {
+ return ((XMLStreamWriterWithOS)writer).getOutputStream();
+ }
+ return null;
+ }
+
+ /**
+ * Preferred way to unmarshal objects
+ *
+ * @param u Unmarshaller
+ * @param reader XMLStreamReader
+ * @return Object that represents an element
+ */
+ private static Object unmarshalElement(final Unmarshaller u, final XMLStreamReader reader) {
+ try {
+ return AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ return u.unmarshal(reader);
+ } catch (OMException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new OMException(t);
+ }
+ }
+ });
+
+ } catch (OMException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new OMException(t);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDataSourceExt.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDataSourceExt.java
new file mode 100644
index 0000000000..5a5afc13cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDataSourceExt.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.sca.databinding.jaxb.axiom.ext;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.ds.OMDataSourceExtBase;
+import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * OMDataSource backed by a jaxb object
+ */
+public class JAXBDataSourceExt extends OMDataSourceExtBase {
+
+ private static final Logger log = Logger.getLogger(JAXBDataSourceExt.class.getName());
+
+ private Object jaxb;
+ private JAXBDSContext context;
+
+ public JAXBDataSourceExt(Object jaxb, JAXBDSContext context) {
+ super();
+ this.jaxb = jaxb;
+ this.context = context;
+ }
+
+ public void close() {
+ }
+
+ public OMDataSourceExt copy() {
+ return new JAXBDataSourceExt(jaxb, context);
+ }
+
+ public Object getObject() {
+ return jaxb;
+ }
+
+ public JAXBDSContext getContext() {
+ return context;
+ }
+
+ public XMLStreamReader getReader() throws XMLStreamException {
+
+ try {
+ String encoding = "utf-8";
+ InputStream is = new ByteArrayInputStream(getXMLBytes(encoding));
+ return StAXUtils.createXMLStreamReader(is, encoding);
+ } catch (UnsupportedEncodingException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
+ MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
+ serialize(writer);
+ writer.flush();
+ try {
+ writer.close();
+ } catch (XMLStreamException e) {
+ // An exception can occur if nothing is written to the
+ // writer. This is possible if the underlying data source
+ // writers to the output stream directly.
+ if (log.isLoggable(Level.FINER)) {
+ log.finer("Catching and swallowing exception " + e);
+ }
+ }
+ }
+
+ public void serialize(Writer writerTarget, OMOutputFormat format) throws XMLStreamException {
+ MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writerTarget));
+ writer.setOutputFormat(format);
+ serialize(writer);
+ writer.flush();
+ writer.close();
+ }
+
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ try {
+ context.marshal(jaxb, xmlWriter);
+ } catch (JAXBException je) {
+ throw new XMLStreamException(je);
+ }
+ }
+
+ public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ // Exposes getOutputStream, which allows faster writes.
+ XMLStreamWriterWithOS writer = new XMLStreamWriterWithOS(baos, encoding);
+
+ // Write the business object to the writer
+ serialize(writer);
+
+ // Flush the writer
+ writer.flush();
+ writer.close();
+ return baos.toByteArray();
+ } catch (XMLStreamException e) {
+ throw new OMException(e);
+ }
+ }
+
+ public boolean isDestructiveRead() {
+ return false;
+ }
+
+ public boolean isDestructiveWrite() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java
new file mode 100644
index 0000000000..0a12654524
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.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.sca.databinding.jaxb.axiom.ext;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.ds.OMDataSourceExtBase;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * OMDataSource backed by a source
+ */
+public class SourceDataSource extends OMDataSourceExtBase {
+ private Source data;
+
+ public SourceDataSource(Source data) {
+ super();
+ this.data = data;
+ }
+
+ public void close() {
+ }
+
+ public OMDataSourceExt copy() {
+ return new SourceDataSource(data);
+ }
+
+ public Object getObject() {
+ return data;
+ }
+
+ public XMLStreamReader getReader() throws XMLStreamException {
+
+ try {
+ String encoding = "UTF-8";
+ InputStream is = new ByteArrayInputStream(getXMLBytes(encoding));
+ return StAXUtils.createXMLStreamReader(is, encoding);
+ } catch (UnsupportedEncodingException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
+ byte[] bytes = null;
+ try {
+ bytes = (byte[])null;
+
+ if (data instanceof StreamSource) {
+ InputStream is = ((StreamSource)data).getInputStream();
+ if (is != null) {
+ bytes = getBytesFromStream(is);
+ }
+ } else {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ Result result = new StreamResult(out);
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.transform(data, result);
+ bytes = out.toByteArray();
+ }
+ } catch (OMException e) {
+ throw e;
+ } catch (UnsupportedEncodingException e) {
+ throw e;
+ } catch (Throwable e) {
+ throw new OMException(e);
+ }
+
+ return bytes;
+ }
+
+ public boolean isDestructiveRead() {
+ return false;
+ }
+
+ public boolean isDestructiveWrite() {
+ return false;
+ }
+
+ private static byte[] getBytesFromStream(InputStream is) throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buf = new byte[4096];
+ while (true) {
+ int size = is.read(buf);
+ if (size < 0) {
+ break;
+ }
+ bos.write(buf, 0, size);
+ }
+ return bos.toByteArray();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStreamWriterWithOS.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStreamWriterWithOS.java
new file mode 100644
index 0000000000..44e34c3647
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStreamWriterWithOS.java
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb.axiom.ext;
+
+import java.io.OutputStream;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * XMLStreamReader that exposes direct access to the OutputStream.
+ * Writing to the output stream is faster in some cases.
+ */
+public class XMLStreamWriterWithOS implements XMLStreamWriter {
+ private XMLStreamWriter writer;
+ private String charSetEncoding;
+ private OutputStream os;
+
+ public XMLStreamWriterWithOS(OutputStream os, String charSetEncoding) throws XMLStreamException {
+ super();
+ writer = null; // Writer is created when needed
+ this.os = os;
+ this.charSetEncoding = charSetEncoding;
+ }
+
+ /**
+ * The writer is created lazily.
+ * If only the output stream is used, then the writer is never created.
+ */
+ private void createWriter() throws XMLStreamException {
+ if (writer == null) {
+ writer = StAXUtils.createXMLStreamWriter(os, charSetEncoding);
+ }
+ }
+
+ public void close() throws XMLStreamException {
+ if (writer != null) {
+ writer.close();
+ }
+ }
+
+ public void flush() throws XMLStreamException {
+ if (writer != null) {
+ writer.flush();
+ }
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ try {
+ createWriter();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return writer.getNamespaceContext();
+ }
+
+ public String getPrefix(String arg0) throws XMLStreamException {
+ createWriter();
+ return writer.getPrefix(arg0);
+ }
+
+ public Object getProperty(String arg0) throws IllegalArgumentException {
+ try {
+ createWriter();
+ } catch (XMLStreamException e) {
+ throw new IllegalArgumentException(e);
+ }
+ return writer.getProperty(arg0);
+ }
+
+ public void setDefaultNamespace(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.setDefaultNamespace(arg0);
+ }
+
+ public void setNamespaceContext(NamespaceContext arg0) throws XMLStreamException {
+ createWriter();
+ writer.setNamespaceContext(arg0);
+ }
+
+ public void setPrefix(String arg0, String arg1) throws XMLStreamException {
+ createWriter();
+ writer.setPrefix(arg0, arg1);
+ }
+
+ public void writeAttribute(String arg0, String arg1, String arg2, String arg3) throws XMLStreamException {
+ createWriter();
+ writer.writeAttribute(arg0, arg1, arg2, arg3);
+ }
+
+ public void writeAttribute(String arg0, String arg1, String arg2) throws XMLStreamException {
+ createWriter();
+ writer.writeAttribute(arg0, arg1, arg2);
+ }
+
+ public void writeAttribute(String arg0, String arg1) throws XMLStreamException {
+ createWriter();
+ writer.writeAttribute(arg0, arg1);
+ }
+
+ public void writeCData(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeCData(arg0);
+ }
+
+ public void writeCharacters(char[] arg0, int arg1, int arg2) throws XMLStreamException {
+ createWriter();
+ writer.writeCharacters(arg0, arg1, arg2);
+ }
+
+ public void writeCharacters(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeCharacters(arg0);
+ }
+
+ public void writeComment(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeComment(arg0);
+ }
+
+ public void writeDefaultNamespace(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeDefaultNamespace(arg0);
+ }
+
+ public void writeDTD(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeDTD(arg0);
+ }
+
+ public void writeEmptyElement(String arg0, String arg1, String arg2) throws XMLStreamException {
+ createWriter();
+ writer.writeEmptyElement(arg0, arg1, arg2);
+ }
+
+ public void writeEmptyElement(String arg0, String arg1) throws XMLStreamException {
+ createWriter();
+ writer.writeEmptyElement(arg0, arg1);
+ }
+
+ public void writeEmptyElement(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeEmptyElement(arg0);
+ }
+
+ public void writeEndDocument() throws XMLStreamException {
+ createWriter();
+ writer.writeEndDocument();
+ }
+
+ public void writeEndElement() throws XMLStreamException {
+ createWriter();
+ writer.writeEndElement();
+ }
+
+ public void writeEntityRef(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeEntityRef(arg0);
+ }
+
+ public void writeNamespace(String arg0, String arg1) throws XMLStreamException {
+ createWriter();
+ writer.writeNamespace(arg0, arg1);
+ }
+
+ public void writeProcessingInstruction(String arg0, String arg1) throws XMLStreamException {
+ createWriter();
+ writer.writeProcessingInstruction(arg0, arg1);
+ }
+
+ public void writeProcessingInstruction(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeProcessingInstruction(arg0);
+ }
+
+ public void writeStartDocument() throws XMLStreamException {
+ createWriter();
+ writer.writeStartDocument();
+ }
+
+ public void writeStartDocument(String arg0, String arg1) throws XMLStreamException {
+ createWriter();
+ writer.writeStartDocument(arg0, arg1);
+ }
+
+ public void writeStartDocument(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeStartDocument(arg0);
+ }
+
+ public void writeStartElement(String arg0, String arg1, String arg2) throws XMLStreamException {
+ createWriter();
+ writer.writeStartElement(arg0, arg1, arg2);
+ }
+
+ public void writeStartElement(String arg0, String arg1) throws XMLStreamException {
+ createWriter();
+ writer.writeStartElement(arg0, arg1);
+ }
+
+ public void writeStartElement(String arg0) throws XMLStreamException {
+ createWriter();
+ writer.writeStartElement(arg0);
+ }
+
+ /**
+ * If this XMLStreamWriter is connected to an OutputStream
+ * then the OutputStream is returned. This allows a node
+ * (perhaps an OMSourcedElement) to write its content
+ * directly to the OutputStream.
+ * @return OutputStream or null
+ */
+ public OutputStream getOutputStream() throws XMLStreamException {
+
+ if (os != null) {
+ // Flush the state of the writer..Many times the
+ // write defers the writing of tag characters (>)
+ // until the next write. Flush out this character
+ if (writer != null) {
+ this.writeCharacters("");
+ this.flush();
+ }
+ }
+ return os;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java
new file mode 100644
index 0000000000..e8e3193e24
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb.axiom.ext;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.ds.OMDataSourceExtBase;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * OMDataSource backed by a string containing xml data
+ */
+public class XMLStringDataSource extends OMDataSourceExtBase {
+ private String data;
+
+ public XMLStringDataSource(String data) {
+ super();
+ this.data = data;
+ }
+
+ public void close() {
+ }
+
+ public OMDataSourceExt copy() {
+ return new XMLStringDataSource(data);
+ }
+
+ public Object getObject() {
+ return data;
+ }
+
+ public XMLStreamReader getReader() throws XMLStreamException {
+ StringReader reader = new StringReader(data);
+ return StAXUtils.createXMLStreamReader(reader);
+ }
+
+ public void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException {
+ try {
+ writer.write(data);
+ } catch (UnsupportedEncodingException e) {
+ throw new XMLStreamException(e);
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
+ return data.getBytes(encoding);
+ }
+
+ public boolean isDestructiveRead() {
+ return false;
+ }
+
+ public boolean isDestructiveWrite() {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..d1799abaff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation classes for the transformers
+org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement;source=javax.xml.bind.JAXBElement,target=org.apache.axiom.om.OMElement,weight=3000
+org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement;source=java:simpleType,target=org.apache.axiom.om.OMElement,weight=3000
+org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement;source=java:complexType,target=org.apache.axiom.om.OMElement,weight=3000
+
+org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;source=org.apache.axiom.om.OMElement,target=javax.xml.bind.JAXBElement,weight=3000,public=false
+org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;source=org.apache.axiom.om.OMElement,target=java:complexType,weight=90000,public=false
+org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;source=org.apache.axiom.om.OMElement,target=java:simpleType,weight=90000,public=false
+
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java
new file mode 100644
index 0000000000..df2b6dc4e3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.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.databinding.jaxb.axiom;
+
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+import org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement;
+import org.apache.tuscany.sca.databinding.xml.Node2XMLStreamReader;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.junit.Test;
+import org.w3c.dom.Node;
+
+import com.example.ipo.jaxb.ObjectFactory;
+import com.example.ipo.jaxb.PurchaseOrderType;
+import com.example.ipo.jaxb.USAddress;
+import com.example.ipo.jaxb.USState;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JAXB2OMTestCase {
+ @Test
+ public void testTransformElement() throws Exception {
+ JAXBElement<PurchaseOrderType> po = createPO();
+ DataType<?> sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, XMLType.UNKNOWN);
+ DataType<?> targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(po.getName(), null));
+ TransformationContext tContext = new TransformationContextImpl();
+ tContext.setSourceDataType(sourceDataType);
+ tContext.setTargetDataType(targetDataType);
+
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ JAXBContextHelper contextHelper = JAXBContextHelper.getInstance(registry);
+ // Force the JAXBContext to be cached
+ contextHelper.createJAXBContext(tContext, true);
+
+ long start = System.currentTimeMillis();
+ JAXB2OMElement t1 = new JAXB2OMElement(registry);
+ OMElement om = t1.transform(po, tContext);
+ long duration1 = System.currentTimeMillis() - start;
+ StringWriter sw = new StringWriter();
+ // serializeAndConsume() will trigger the JAXBDataSource.serialize(Writer, OMOutputFormat)
+ om.serializeAndConsume(sw);
+ System.out.println(sw.toString());
+
+ start = System.currentTimeMillis();
+ Node node = new JAXB2Node(new DefaultExtensionPointRegistry()).transform(po, tContext);
+ XMLStreamReader reader = new Node2XMLStreamReader().transform(node, null);
+ om = new StAXOMBuilder(reader).getDocumentElement();
+ sw = new StringWriter();
+ om.serializeAndConsume(sw);
+ long duration2 = System.currentTimeMillis() - start;
+ System.out.println(sw.toString());
+ System.out.println(duration1 + " vs. " + duration2);
+ }
+
+ @Test
+ public void testTransformType() throws Exception {
+ JAXBElement<PurchaseOrderType> po = createPO();
+ DataType<?> sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, XMLType.UNKNOWN);
+ DataType<?> targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(po.getName(), null));
+ TransformationContext tContext = new TransformationContextImpl();
+ tContext.setSourceDataType(sourceDataType);
+ tContext.setTargetDataType(targetDataType);
+ OMElement om = new JAXB2OMElement(new DefaultExtensionPointRegistry()).transform(po.getValue(), tContext);
+ StringWriter sw = new StringWriter();
+ om.serializeAndConsume(sw);
+ System.out.println(sw.toString());
+ }
+
+ private JAXBElement<PurchaseOrderType> createPO() {
+ ObjectFactory factory = new ObjectFactory();
+ PurchaseOrderType type = factory.createPurchaseOrderType();
+ JAXBElement<PurchaseOrderType> po = factory.createPurchaseOrder(type);
+ type.setItems(factory.createItems());
+ type.setComment("123");
+ USAddress address = factory.createUSAddress();
+ address.setCity("San Jose");
+ address.setStreet("ABC St.");
+ address.setState(USState.CA);
+ type.setShipTo(address);
+ return po;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java
new file mode 100644
index 0000000000..abfcf358d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.jaxb.axiom;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.junit.Test;
+
+import com.example.ipo.jaxb.PurchaseOrderType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OMElement2JAXBTestCase {
+ private static final String XML =
+ "<ns0:root xmlns:ns0=\"http://ns0\" xmlns:ns2=\"http://www.example.com/IPO\">" + "<ns1:next xmlns:ns1=\"http://ns1\">"
+ + "<ns2:purchaseOrder>"
+ + "<shipTo xsi:type=\"ns2:USAddress\" "
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ + "<street>ABC St.</street><city>San Jose</city><state>CA</state></shipTo>"
+ + "<ns2:comment>123</ns2:comment><items/>"
+ + "</ns2:purchaseOrder>"
+ + "</ns1:next>"
+ + "</ns0:root>";
+
+ @Test
+ public void testTransform() throws Exception {
+ DataType<?> sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, XMLType.UNKNOWN);
+ QName qname = new QName("http://www.example.com/IPO", "purchaseOrder");
+ DataType<?> targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(qname, null));
+ TransformationContext tContext = new TransformationContextImpl();
+ tContext.setSourceDataType(sourceDataType);
+ tContext.setTargetDataType(targetDataType);
+
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(XML.getBytes("UTF-8")));
+ OMElement root = builder.getDocumentElement();
+ OMElement next = (OMElement)root.getChildElements().next();
+ OMElement po = (OMElement)next.getChildElements().next();
+ Object jaxb = new OMElement2JAXB(new DefaultExtensionPointRegistry()).transform(po, tContext);
+ Assert.assertTrue(jaxb instanceof PurchaseOrderType);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/resources/ipo.xsd b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/resources/ipo.xsd
new file mode 100644
index 0000000000..241ec15d36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb-axiom/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/LICENSE b/sandbox/sebastien/java/embed/modules/databinding-jaxb/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/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/sebastien/java/embed/modules/databinding-jaxb/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/databinding-jaxb/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b0fb20a6de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/META-INF/MANIFEST.MF
@@ -0,0 +1,53 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.databinding.jaxb;uses:="org.apa
+ che.tuscany.sca.databinding,org.apache.tuscany.sca.interfacedef.util,
+ javax.xml.transform.dom,org.xml.sax,javax.xml.namespace,javax.imageio
+ ,javax.xml.stream,org.apache.tuscany.sca.contribution.resolver,org.ap
+ ache.tuscany.sca.databinding.util,org.oasisopen.sca,org.apache.tuscany.sca
+ .databinding.xml,org.apache.tuscany.sca.databinding.impl,org.apache.w
+ s.commons.schema.resolver,org.apache.tuscany.sca.interfacedef,org.w3c
+ .dom,javax.xml.datatype,javax.activation,javax.xml.bind.attachment,ja
+ vax.xml.transform,javax.xml.bind.annotation,javax.xml.transform.strea
+ m,org.apache.tuscany.sca.interfacedef.impl,org.apache.tuscany.sca.xsd
+ ,javax.xml.bind";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data Binding for JAXB
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data Binding for JAXB
+Import-Package: javax.activation,
+ javax.imageio,
+ javax.xml.bind,
+ javax.xml.bind.annotation,
+ javax.xml.bind.annotation.adapters,
+ javax.xml.bind.attachment,
+ javax.xml.datatype,
+ javax.xml.namespace,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.common.java.collection;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.jaxb;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.w3c.dom,
+ org.xml.sax
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding.jaxb
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/NOTICE b/sandbox/sebastien/java/embed/modules/databinding-jaxb/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/pom.xml b/sandbox/sebastien/java/embed/modules/databinding-jaxb/pom.xml
new file mode 100644
index 0000000000..23ba8ac8d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/pom.xml
@@ -0,0 +1,175 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <name>Apache Tuscany SCA DataBinding for JAXB</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.12</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxb-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <version>0.7.1</version>
+ <executions>
+ <execution>
+ <id>generate-jaxb</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generatePackage>com.example.ipo.jaxb</generatePackage>
+ <generateDirectory>${project.build.directory}/jaxb-source</generateDirectory>
+ <schemaDirectory>${basedir}/src/test/resources</schemaDirectory>
+ <schemaIncludes>
+ <include>ipo.xsd</include>
+ </schemaIncludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java
new file mode 100644
index 0000000000..57922e1c89
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.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.sca.databinding.jaxb;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * This special XmlAdapter can be used by JAXB classes to annotate the references to java interfaces
+ */
+public class AnyTypeXmlAdapter extends XmlAdapter<Object, Object> {
+
+ @Override
+ public Object marshal(Object v) throws Exception {
+ return v;
+ }
+
+ @Override
+ public Object unmarshal(Object v) throws Exception {
+ return v;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java
new file mode 100644
index 0000000000..91cb39b0f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.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.databinding.jaxb;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.w3c.dom.Element;
+
+/**
+ * A generic XmlAdapter for JAXB to marshal/unmarshal between the java objects and DOM elements
+ */
+public class DOMElementXmlAdapter extends XmlAdapter<Element, Object> {
+ private Mediator mediator;
+ private DataType dataType;
+ private DataType domType;
+
+ public DOMElementXmlAdapter(Mediator mediator, DataType dataType) {
+ this.mediator = mediator;
+ this.dataType = dataType;
+ this.domType = new DataTypeImpl(DOMDataBinding.NAME, Element.class, dataType.getLogical());
+ }
+
+ @Override
+ public Element marshal(Object value) throws Exception {
+ return (Element) mediator.mediate(value, dataType, domType, null);
+ }
+
+ @Override
+ public Object unmarshal(Element element) throws Exception {
+ return mediator.mediate(element, domType, dataType, null);
+ }
+
+ public void setMediator(Mediator mediator) {
+ this.mediator = mediator;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DataConverter.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DataConverter.java
new file mode 100644
index 0000000000..35adffe23b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DataConverter.java
@@ -0,0 +1,378 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.awt.Image;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.activation.DataHandler;
+import javax.imageio.ImageIO;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Provides utilities to convert an object into a different kind of Object. For example, convert a
+ * String[] into a List<String>
+ */
+public class DataConverter {
+
+ /**
+ * This method should return true if the convert method will succeed.
+ * <p/>
+ * Note that any changes to isConvertable() must also be accompanied by similar changes to
+ * convert()
+ *
+ * @param obj source object or class
+ * @param dest destination class
+ * @return boolean true if convert(..) can convert obj to the destination class
+ */
+ public static boolean isConvertable(Object obj, Class dest) {
+ Class src = null;
+
+ if (obj != null) {
+ if (obj instanceof Class) {
+ src = (Class)obj;
+ } else {
+ src = obj.getClass();
+ }
+ }
+
+ if (dest == null) {
+ return false;
+ }
+
+ if (src == null) {
+ return true;
+ }
+
+ // If we're directly assignable, we're good.
+ if (dest.isAssignableFrom(src)) {
+ return true;
+ }
+
+ // If it's a wrapping conversion, we're good.
+ if (getWrapperClass(src) == dest) {
+ return true;
+ }
+ if (getWrapperClass(dest) == src) {
+ return true;
+ }
+
+ // If it's List -> Array or vice versa, we're good.
+ if ((Collection.class.isAssignableFrom(src) || src.isArray()) && (Collection.class.isAssignableFrom(dest) || dest
+ .isArray())) {
+
+ // TODO this should consider the component types instead of returning true.
+ return true;
+ }
+
+ // Allow mapping of HashMaps to Hashtables
+ if (src == HashMap.class && dest == Hashtable.class)
+ return true;
+
+ // Allow mapping of Calendar to Date
+ if (Calendar.class.isAssignableFrom(src) && dest == Date.class) {
+ return true;
+ }
+
+ if (src.isPrimitive()) {
+ return isConvertable(getWrapperClass(src), dest);
+ }
+
+ if (InputStream.class.isAssignableFrom(src) && dest == byte[].class) {
+ return true;
+ }
+
+ if (Source.class.isAssignableFrom(src) && dest == byte[].class) {
+ return true;
+ }
+
+ if (DataHandler.class.isAssignableFrom(src) && isConvertable(byte[].class, dest)) {
+ return true;
+ }
+
+ if (DataHandler.class.isAssignableFrom(src) && dest == Image.class) {
+ return true;
+ }
+
+ if (DataHandler.class.isAssignableFrom(src) && dest == Source.class) {
+ return true;
+ }
+
+ if (byte[].class.isAssignableFrom(src) && dest == String.class) {
+ return true;
+ }
+
+ // If it's a MIME type mapping and we want a DataHandler,
+ // then we're good.
+ // REVIEW Do we want to support this
+ /*
+ if (dest.getName().equals("javax.activation.DataHandler")) {
+ String name = src.getName();
+ if (src == String.class
+ || src == java.awt.Image.class
+ || name.equals("javax.mail.internet.MimeMultipart")
+ || name.equals("javax.xml.transform.Source"))
+ return true;
+ }
+ */
+
+ return false;
+ }
+
+ /**
+ * Utility function to convert an Object to some desired Class.
+ * <p/>
+ * Normally this is used for T[] to List<T> processing. Other conversions are also done (i.e.
+ * HashMap <->Hashtable, etc.)
+ * <p/>
+ * Use the isConvertable() method to determine if conversion is possible. Note that any changes
+ * to convert() must also be accompanied by similar changes to isConvertable()
+ *
+ * @param arg the array to convert
+ * @param destClass the actual class we want
+ * @return object of destClass if conversion possible, otherwise returns arg
+ */
+ public static Object convert(Object arg, Class<?> destClass) {
+ if (destClass == null) {
+ return arg;
+ }
+
+ if (arg != null && destClass.isAssignableFrom(arg.getClass())) {
+ return arg;
+ }
+
+ // Convert between Calendar and Date
+ if (arg instanceof Calendar && destClass == Date.class) {
+ return ((Calendar)arg).getTime();
+ }
+
+ // Convert between HashMap and Hashtable
+ if (arg instanceof HashMap && destClass == Hashtable.class) {
+ return new Hashtable((HashMap)arg);
+ }
+
+ if (arg instanceof InputStream && destClass == byte[].class) {
+
+ try {
+ InputStream is = (InputStream)arg;
+ return getBytesFromStream(is);
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ if (arg instanceof Source && destClass == byte[].class) {
+ try {
+ if (arg instanceof StreamSource) {
+ InputStream is = ((StreamSource)arg).getInputStream();
+ if (is != null) {
+ return getBytesFromStream(is);
+ }
+ }
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ Result result = new StreamResult(out);
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.transform((Source)arg, result);
+ byte[] bytes = out.toByteArray();
+ return bytes;
+
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ if (arg instanceof DataHandler) {
+ try {
+ InputStream is = ((DataHandler)arg).getInputStream();
+ if (destClass == Image.class) {
+ return ImageIO.read(is);
+ } else if (destClass == Source.class) {
+ return new StreamSource(is);
+ }
+ byte[] bytes = getBytesFromStream(is);
+ return convert(bytes, destClass);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ if (arg instanceof byte[] && destClass == String.class) {
+ return new String((byte[])arg);
+ }
+
+ // If the destination is an array and the source
+ // is a suitable component, return an array with
+ // the single item.
+ /* REVIEW do we need to support atomic to array conversion ?
+ if (arg != null &&
+ destClass.isArray() &&
+ !destClass.getComponentType().equals(Object.class) &&
+ destClass.getComponentType().isAssignableFrom(arg.getClass())) {
+ Object array =
+ Array.newInstance(destClass.getComponentType(), 1);
+ Array.set(array, 0, arg);
+ return array;
+ }
+ */
+
+ // Return if no conversion is available
+ if (!(arg instanceof Collection || (arg != null && arg.getClass().isArray()))) {
+ return arg;
+ }
+
+ if (arg == null) {
+ return null;
+ }
+
+ // The arg may be an array or List
+ Object destValue = null;
+ int length = 0;
+ if (arg.getClass().isArray()) {
+ length = Array.getLength(arg);
+ } else {
+ length = ((Collection)arg).size();
+ }
+
+ try {
+ if (destClass.isArray()) {
+ if (destClass.getComponentType().isPrimitive()) {
+
+ Object array = Array.newInstance(destClass.getComponentType(), length);
+ // Assign array elements
+ if (arg.getClass().isArray()) {
+ for (int i = 0; i < length; i++) {
+ Array.set(array, i, Array.get(arg, i));
+ }
+ } else {
+ int idx = 0;
+ for (Iterator i = ((Collection)arg).iterator(); i.hasNext();) {
+ Array.set(array, idx++, i.next());
+ }
+ }
+ destValue = array;
+
+ } else {
+ Object[] array;
+ try {
+ array = (Object[])Array.newInstance(destClass.getComponentType(), length);
+ } catch (Exception e) {
+ return arg;
+ }
+
+ // Use convert to assign array elements.
+ if (arg.getClass().isArray()) {
+ for (int i = 0; i < length; i++) {
+ array[i] = convert(Array.get(arg, i), destClass.getComponentType());
+ }
+ } else {
+ int idx = 0;
+ for (Iterator i = ((Collection)arg).iterator(); i.hasNext();) {
+ array[idx++] = convert(i.next(), destClass.getComponentType());
+ }
+ }
+ destValue = array;
+ }
+ } else if (Collection.class.isAssignableFrom(destClass)) {
+ Collection newList = null;
+ try {
+ // if we are trying to create an interface, build something
+ // that implements the interface
+ if (destClass == Collection.class || destClass == List.class) {
+ newList = new ArrayList();
+ } else if (destClass == Set.class) {
+ newList = new HashSet();
+ } else {
+ newList = (Collection)destClass.newInstance();
+ }
+ } catch (Exception e) {
+ // No FFDC code needed
+ // Couldn't build one for some reason... so forget it.
+ return arg;
+ }
+
+ if (arg.getClass().isArray()) {
+ for (int j = 0; j < length; j++) {
+ newList.add(Array.get(arg, j));
+ }
+ } else {
+ for (Iterator j = ((Collection)arg).iterator(); j.hasNext();) {
+ newList.add(j.next());
+ }
+ }
+ destValue = newList;
+ } else {
+ destValue = arg;
+ }
+ } catch (Throwable t) {
+ throw new ServiceRuntimeException(t);
+ }
+
+ return destValue;
+ }
+
+ private static byte[] getBytesFromStream(InputStream is) throws IOException {
+ // TODO This code assumes that available is the length of the stream.
+ byte[] bytes = new byte[is.available()];
+ is.read(bytes);
+ return bytes;
+ }
+
+ public static Class getWrapperClass(Class primitive) {
+ if (primitive == int.class) {
+ return java.lang.Integer.class;
+ } else if (primitive == short.class) {
+ return java.lang.Short.class;
+ } else if (primitive == boolean.class) {
+ return java.lang.Boolean.class;
+ } else if (primitive == byte.class) {
+ return java.lang.Byte.class;
+ } else if (primitive == long.class) {
+ return java.lang.Long.class;
+ } else if (primitive == double.class) {
+ return java.lang.Double.class;
+ } else if (primitive == float.class) {
+ return java.lang.Float.class;
+ } else if (primitive == char.class) {
+ return java.lang.Character.class;
+ }
+
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DefaultXMLAdapterExtensionPoint.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DefaultXMLAdapterExtensionPoint.java
new file mode 100644
index 0000000000..062da48206
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DefaultXMLAdapterExtensionPoint.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.databinding.jaxb;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DefaultXMLAdapterExtensionPoint implements XMLAdapterExtensionPoint {
+ private Map<Class<?>, Class<? extends XmlAdapter>> adapters =
+ new ConcurrentHashMap<Class<?>, Class<? extends XmlAdapter>>();
+
+ public void addAdapter(Class<?> boundType, Class<? extends XmlAdapter> adapter) {
+ adapters.put(boundType, adapter);
+ }
+
+ public Class<? extends XmlAdapter> getAdapter(Class<?> boundType) {
+ Class<? extends XmlAdapter> cls = adapters.get(boundType);
+ if (cls != null) {
+ return cls;
+ }
+ for (Map.Entry<Class<?>, Class<? extends XmlAdapter>> e : adapters.entrySet()) {
+ if (e.getKey().isAssignableFrom(boundType)) {
+ return e.getValue();
+ }
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class<? extends XmlAdapter> removeAdapter(Class<?> boundType) {
+ return adapters.remove(boundType);
+ }
+
+ public Map<Class<?>, Class<? extends XmlAdapter>> getAdapters() {
+ return adapters;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
new file mode 100644
index 0000000000..3d25af5b25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.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.sca.databinding.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXB2Node extends BaseTransformer<Object, Node> implements PullTransformer<Object, Node> {
+ private DOMHelper helper;
+ private JAXBContextHelper contextHelper;
+
+ public JAXB2Node(ExtensionPointRegistry registry) {
+ super();
+ helper = DOMHelper.getInstance(registry);
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+
+ public Node transform(Object source, TransformationContext tContext) {
+// if (source == null) {
+// return null;
+// }
+ try {
+ JAXBContext context = contextHelper.createJAXBContext(tContext, true);
+ Marshaller marshaller = context.createMarshaller();
+ // FIXME: The default Marshaller doesn't support
+ // marshaller.getNode()
+ Document document = helper.newDocument();
+ Object jaxbElement = JAXBContextHelper.createJAXBElement(context, tContext.getSourceDataType(), source);
+ marshaller.marshal(jaxbElement, document);
+ return DOMDataBinding.adjustElementName(tContext, document.getDocumentElement());
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ protected Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 30;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
new file mode 100644
index 0000000000..a0b6ff8237
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.xml.sax.ContentHandler;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JAXB2SAX extends BaseTransformer<Object, ContentHandler> implements
+ PushTransformer<Object, ContentHandler> {
+
+ private JAXBContextHelper contextHelper;
+
+ public JAXB2SAX(ExtensionPointRegistry registry) {
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ protected Class<ContentHandler> getTargetType() {
+ return ContentHandler.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.PushTransformer#transform(java.lang.Object, java.lang.Object, org.apache.tuscany.sca.databinding.TransformationContext)
+ */
+ public void transform(Object source, ContentHandler target, TransformationContext tContext) {
+ try {
+ JAXBContext context = contextHelper.createJAXBContext(tContext, true);
+ Marshaller marshaller = context.createMarshaller();
+ Object jaxbElement = JAXBContextHelper.createJAXBElement(context, tContext.getSourceDataType(), source);
+ marshaller.marshal(jaxbElement, target);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public int getWeight() {
+ return 20;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
new file mode 100644
index 0000000000..7ecca3a042
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.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.sca.databinding.jaxb;
+
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.xml.XMLStringDataBinding;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXB2String extends BaseTransformer<Object, String> implements PullTransformer<Object, String> {
+ private JAXBContextHelper contextHelper;
+
+ public JAXB2String(ExtensionPointRegistry registry) {
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+ public String transform(Object source, TransformationContext tContext) {
+ try {
+ JAXBContext context = contextHelper.createJAXBContext(tContext, true);
+ Marshaller marshaller = context.createMarshaller();
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
+ Object jaxbElement = JAXBContextHelper.createJAXBElement(context, tContext.getSourceDataType(), source);
+ marshaller.marshal(jaxbElement, result);
+ return writer.toString();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ protected Class<String> getTargetType() {
+ return String.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 30;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return XMLStringDataBinding.NAME;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
new file mode 100644
index 0000000000..025b4f7c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
@@ -0,0 +1,561 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.awt.Image;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.ref.SoftReference;
+import java.net.URI;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.transform.Source;
+
+import org.apache.tuscany.sca.common.java.collection.LRUCache;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JAXBContextCache {
+ private static final int CACHE_SIZE = 128;
+
+ private static HashMap<String, Class<?>> loadClassMap = new HashMap<String, Class<?>>();
+
+ static {
+ loadClassMap.put("byte", byte.class);
+ loadClassMap.put("int", int.class);
+ loadClassMap.put("short", short.class);
+ loadClassMap.put("long", long.class);
+ loadClassMap.put("float", float.class);
+ loadClassMap.put("double", double.class);
+ loadClassMap.put("boolean", boolean.class);
+ loadClassMap.put("char", char.class);
+ loadClassMap.put("void", void.class);
+ }
+
+ protected static Class<?>[] JAXB_BUILTIN_CLASSES =
+ {byte[].class, boolean.class, byte.class, char.class, double.class, float.class, int.class, long.class,
+ short.class, void.class, java.awt.Image.class, java.io.File.class, java.lang.Boolean.class,
+ java.lang.Byte.class, java.lang.Character.class, java.lang.Class.class, java.lang.Double.class,
+ java.lang.Float.class, java.lang.Integer.class, java.lang.Long.class, java.lang.Object.class,
+ java.lang.Short.class, java.lang.String.class, java.lang.Void.class, java.math.BigDecimal.class,
+ java.math.BigInteger.class, java.net.URI.class, java.net.URL.class, java.util.Calendar.class,
+ java.util.Date.class, java.util.GregorianCalendar.class, java.util.UUID.class,
+ javax.activation.DataHandler.class, javax.xml.bind.JAXBElement.class, javax.xml.datatype.Duration.class,
+ javax.xml.datatype.XMLGregorianCalendar.class, javax.xml.namespace.QName.class,
+ javax.xml.transform.Source.class};
+
+ protected static final Set<Class<?>> BUILTIN_CLASSES_SET = new HashSet<Class<?>>(Arrays.asList(JAXB_BUILTIN_CLASSES));
+
+ /*
+ protected static Class<?>[] COMMON_ARRAY_CLASSES =
+ new Class[] {char[].class, short[].class, int[].class, long[].class, float[].class, double[].class,
+ String[].class
+ };
+
+ protected static final Set<Class<?>> COMMON_CLASSES_SET = new HashSet<Class<?>>(Arrays.asList(COMMON_ARRAY_CLASSES));
+ */
+
+ protected LRUCache<Object, JAXBContext> cache;
+ protected Pool<JAXBContext, Marshaller> mpool;
+ protected Pool<JAXBContext, Unmarshaller> upool;
+
+ // protected JAXBContext commonContext;
+ protected JAXBContext defaultContext;
+ private ExtensionPointRegistry registry;
+
+ public JAXBContextCache(ExtensionPointRegistry registry) {
+ this(CACHE_SIZE, CACHE_SIZE, CACHE_SIZE, registry);
+ }
+
+ public JAXBContextCache(int contextSize, int marshallerSize, int unmarshallerSize, ExtensionPointRegistry registry) {
+ this.registry = registry;
+ cache = new LRUCache<Object, JAXBContext>(contextSize);
+ mpool = new Pool<JAXBContext, Marshaller>();
+ upool = new Pool<JAXBContext, Unmarshaller>();
+ defaultContext = getDefaultJAXBContext();
+ }
+
+ private JAXBContext newJAXBContext(final Class<?>... classesToBeBound) throws JAXBException {
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
+ public JAXBContext run() throws JAXBException {
+ // Try to set up TCCL so that JAXBContext service discovery works in OSGi
+ ClassLoader tccl =
+ ClassLoaderContext.setContextClassLoader(JAXBContextCache.class.getClassLoader(),
+ registry.getServiceDiscovery(),
+ // The service provider of JAXBContext doesn't extend JAXBContext
+ // We should use the service name instead of the class
+ JAXBContext.class.getName(),
+ DatatypeFactory.class.getName());
+ try {
+ JAXBContext context = JAXBContext.newInstance(classesToBeBound);
+ return context;
+ } finally {
+ if (tccl != null) {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (JAXBException)e.getException();
+ }
+ }
+
+
+ public JAXBContext getDefaultJAXBContext() {
+ try {
+ return newJAXBContext();
+ } catch (JAXBException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * @param name of primitive type
+ * @return primitive Class or null
+ */
+ public static Class<?> getPrimitiveClass(String text) {
+ return loadClassMap.get(text);
+ }
+
+ /**
+ * Return the class for this name
+ *
+ * @return Class
+ */
+ private static Class<?> forName(final String className, final boolean initialize, final ClassLoader classloader)
+ throws ClassNotFoundException {
+ // NOTE: This method must remain private because it uses AccessController
+ Class<?> cl = null;
+ try {
+ cl = AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws ClassNotFoundException {
+ // Class.forName does not support primitives
+ Class<?> cls = getPrimitiveClass(className);
+ if (cls == null) {
+ cls = Class.forName(className, initialize, classloader);
+ }
+ return cls;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (ClassNotFoundException)e.getException();
+ }
+
+ return cl;
+ }
+
+ public Marshaller getMarshaller(JAXBContext context) throws JAXBException {
+ Marshaller marshaller = mpool.get(context);
+ if (marshaller == null) {
+ marshaller = context.createMarshaller();
+ }
+ marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
+ return marshaller;
+ }
+
+ public void releaseJAXBMarshaller(JAXBContext context, Marshaller marshaller) {
+ if (marshaller != null) {
+ marshaller.setAttachmentMarshaller(null);
+ mpool.put(context, marshaller);
+ // No point unsetting marshaller's JAXB_FRAGMENT property, since we'll just reset it when
+ // doing the next get.
+ }
+ }
+
+ public Unmarshaller getUnmarshaller(JAXBContext context) throws JAXBException {
+ Unmarshaller unmarshaller = upool.get(context);
+ if (unmarshaller == null) {
+ unmarshaller = context.createUnmarshaller();
+ }
+ return unmarshaller;
+ }
+
+ public void releaseJAXBUnmarshaller(JAXBContext context, Unmarshaller unmarshaller) {
+ if (unmarshaller != null) {
+ unmarshaller.setAttachmentUnmarshaller(null);
+ upool.put(context, unmarshaller);
+ }
+ }
+
+ public LRUCache<Object, JAXBContext> getCache() {
+ return cache;
+ }
+
+ public JAXBContext getJAXBContext(Class<?> cls) throws JAXBException {
+ if (BUILTIN_CLASSES_SET.contains(cls)) {
+ return defaultContext;
+ }
+ return getJAXBContext(new Class<?>[] {cls});
+ }
+
+ public JAXBContext getJAXBContext(Class<?>[] classes) throws JAXBException {
+ Set<Class<?>> classSet = new HashSet<Class<?>>(Arrays.asList(classes));
+ return getJAXBContext(classSet);
+ }
+
+ public JAXBContext getJAXBContext(Set<Class<?>> classes) throws JAXBException {
+ // Remove the JAXB built-in types to maximize the cache hit
+ Set<Class<?>> classSet = new HashSet<Class<?>>(classes);
+ classSet.removeAll(BUILTIN_CLASSES_SET);
+
+ // FIXME: [rfeng] Remove java classes that are mapped to the same XSD type to avoid
+ // conflicts
+ if (classSet.contains(Date[].class)) {
+ classSet.remove(Calendar[].class);
+ }
+
+ if (classSet.contains(URI[].class)) {
+ classSet.remove(UUID[].class);
+ }
+
+ if (classSet.contains(Source[].class)) {
+ classSet.remove(Image[].class);
+ classSet.remove(DataHandler[].class);
+ }
+
+ classSet = getJAXBClasses(classSet);
+
+ if(classSet.isEmpty()) {
+ return defaultContext;
+ }
+
+ synchronized (cache) {
+ JAXBContext context = cache.get(classSet);
+ if (context != null) {
+ return context;
+ }
+ context = newJAXBContext(classSet.toArray(new Class<?>[classSet.size()]));
+ cache.put(classSet, context);
+ return context;
+ }
+ }
+
+ public void clear() {
+ synchronized (cache) {
+ cache.clear();
+ }
+ /*
+ synchronized (upool) {
+ upool.clear();
+ }
+ synchronized (upool) {
+ upool.clear();
+ }
+ */
+ }
+
+ //
+ // This inner class is copied in its entirety from the Axis2 utility class,
+ // org.apache.axis2.jaxws.message.databinding.JAXBUtils. We could look into extending but it's such a basic data structure
+ // without other dependencies so we might be better off copying it and avoiding a new
+ // Axis2 dependency here.
+ //
+
+ /**
+ * Pool a list of items for a specific key
+ *
+ * @param <K> Key
+ * @param <V> Pooled object
+ */
+ private static class Pool<K,V> {
+ private SoftReference<Map<K,List<V>>> softMap =
+ new SoftReference<Map<K,List<V>>>(
+ new ConcurrentHashMap<K, List<V>>());
+
+ // The maps are freed up when a LOAD FACTOR is hit
+ private static final int MAX_LIST_FACTOR = 50;
+ private static final int MAX_LOAD_FACTOR = 32; // Maximum number of JAXBContext to store
+
+ /**
+ * @param key
+ * @return removed item from pool or null.
+ */
+ public V get(K key) {
+ List<V> values = getValues(key);
+ synchronized (values) {
+ if (values.size()>0) {
+ V v = values.remove(values.size()-1);
+ return v;
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add item back to pool
+ * @param key
+ * @param value
+ */
+ public void put(K key, V value) {
+ adjustSize();
+ List<V> values = getValues(key);
+ synchronized (values) {
+ if (values.size() < MAX_LIST_FACTOR) {
+ values.add(value);
+ }
+ }
+ }
+
+ /**
+ * Get or create a list of the values for the key
+ * @param key
+ * @return list of values.
+ */
+ private List<V> getValues(K key) {
+ Map<K,List<V>> map = softMap.get();
+ List<V> values = null;
+ if (map != null) {
+ values = map.get(key);
+ if(values !=null) {
+ return values;
+ }
+ }
+ synchronized (this) {
+ if (map != null) {
+ values = map.get(key);
+ }
+ if (values == null) {
+ if (map == null) {
+ map = new ConcurrentHashMap<K, List<V>>();
+ softMap =
+ new SoftReference<Map<K,List<V>>>(map);
+ }
+ values = new ArrayList<V>();
+ map.put(key, values);
+
+ }
+ return values;
+ }
+ }
+
+ /**
+ * AdjustSize
+ * When the number of keys exceeds the maximum load, half
+ * of the entries are deleted.
+ *
+ * The assumption is that the JAXBContexts, UnMarshallers, Marshallers, etc. require
+ * a large footprint.
+ */
+ private void adjustSize() {
+ Map<K,List<V>> map = softMap.get();
+ if (map != null && map.size() > MAX_LOAD_FACTOR) {
+ // Remove every other Entry in the map.
+ Iterator it = map.entrySet().iterator();
+ boolean removeIt = false;
+ while (it.hasNext()) {
+ it.next();
+ if (removeIt) {
+ it.remove();
+ }
+ removeIt = !removeIt;
+ }
+ }
+ }
+ }
+
+ /**
+ * Find the JAXB classes (looking into packages) to be bound
+ * @param classes A collection of classes
+ * @return A set of classes that include the ObjectFactory and indexed JAXB classes
+ * @throws JAXBException
+ */
+ private static Set<Class<?>> getJAXBClasses(Collection<Class<?>> classes) throws JAXBException {
+ Set<Class<?>> classSet = new HashSet<Class<?>>();
+ // Index the packages
+ Map<Package, ClassLoader> pkgs = getPackages(classes);
+ Set<Package> nonJAXBPackages = new HashSet<Package>();
+ for (Map.Entry<Package, ClassLoader> p : pkgs.entrySet()) {
+ Package pkg = p.getKey();
+ if (pkg == null) {
+ continue;
+ }
+ Set<Class<?>> set = getJAXBClasses(pkg.getName(), p.getValue());
+ if (set.isEmpty()) {
+ // No JAXB package
+ nonJAXBPackages.add(pkg);
+ } else {
+ // Add JAXB ObjectFactory and indexed classes
+ classSet.addAll(set);
+ }
+ }
+ // Adding classes that are not part of JAXB packages
+ for (Class<?> cls : classes) {
+
+ Package pkg = getPackage(cls);
+ if (pkg == null || nonJAXBPackages.contains(pkg)) {
+ classSet.add(cls);
+ } else {
+ // TUSCANY-3162: Test if a class is generated by JAXB
+ // There might be the case that non-JAXB classes are in the same package as the JAXB classes
+ if (!cls.isAnnotationPresent(XmlType.class)
+ && !cls.isAnnotationPresent(XmlEnum.class)
+ && !cls.isAnnotationPresent(XmlSeeAlso.class)
+ && !cls.isAnnotationPresent(XmlRootElement.class)
+ && !cls.isAnnotationPresent(XmlTransient.class)) {
+ classSet.add(cls);
+ }
+ }
+ }
+ return classSet;
+ }
+
+ /**
+ * Get the package for a class, taking array into account
+ * @param cls
+ * @return
+ */
+ private static Package getPackage(Class<?> cls) {
+ Class<?> type = cls;
+ while (type.isArray()) {
+ type = type.getComponentType();
+ }
+ return type.getPackage();
+ }
+
+ /**
+ * Get a map of packages
+ * @param classes
+ * @return
+ */
+ private static Map<Package, ClassLoader> getPackages(Collection<Class<?>> classes) {
+ Map<Package, ClassLoader> pkgs = new HashMap<Package, ClassLoader>();
+ for (Class<?> cls : classes) {
+ Package pkg = getPackage(cls);
+ if (pkg != null) {
+ pkgs.put(pkg, cls.getClassLoader());
+ }
+ }
+ return pkgs;
+ }
+
+ /**
+ * Find ObjectFactory and indexed JAXB classes for the package
+ * @param pkg
+ * @param classLoader
+ * @return
+ * @throws JAXBException
+ */
+ private static Set<Class<?>> getJAXBClasses(String pkg, ClassLoader classLoader) throws JAXBException {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ List<Class<?>> indexedClasses;
+
+ // look for ObjectFactory and load it
+ final Class<?> o;
+ try {
+ o = forName(pkg + ".ObjectFactory", false, classLoader);
+ classes.add(o);
+ } catch (ClassNotFoundException e) {
+ // not necessarily an error
+ }
+
+ // look for jaxb.index and load the list of classes
+ try {
+ indexedClasses = loadIndexedClasses(pkg, classLoader);
+ } catch (IOException e) {
+ throw new JAXBException(e);
+ }
+ if (indexedClasses != null) {
+ classes.addAll(indexedClasses);
+ }
+
+ return classes;
+ }
+
+ /**
+ * Look for jaxb.index file in the specified package and load it's contents
+ *
+ * @param pkg package name to search in
+ * @param classLoader ClassLoader to search in
+ * @return a List of Class objects to load, null if there weren't any
+ * @throws IOException if there is an error reading the index file
+ * @throws JAXBException if there are any errors in the index file
+ */
+ private static List<Class<?>> loadIndexedClasses(String pkg, ClassLoader classLoader) throws IOException,
+ JAXBException {
+ if (classLoader == null) {
+ return null;
+ }
+ final String resource = pkg.replace('.', '/') + "/jaxb.index";
+ final InputStream resourceAsStream = classLoader.getResourceAsStream(resource);
+
+ if (resourceAsStream == null) {
+ return null;
+ }
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(resourceAsStream, "UTF-8"));
+ try {
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ String className = in.readLine();
+ while (className != null) {
+ className = className.trim();
+ if (className.startsWith("#") || (className.length() == 0)) {
+ className = in.readLine();
+ continue;
+ }
+
+ try {
+ classes.add(forName(pkg + '.' + className, false, classLoader));
+ } catch (ClassNotFoundException e) {
+ throw new JAXBException(e);
+ }
+
+ className = in.readLine();
+ }
+ return classes;
+ } finally {
+ in.close();
+ }
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
new file mode 100644
index 0000000000..50fc346270
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
@@ -0,0 +1,492 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.JAXBIntrospector;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchema;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.java.collection.LRUCache;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+// FIXME: [rfeng] We probably should turn this into a pluggable system service
+public final class JAXBContextHelper {
+ private final JAXBContextCache cache;
+ private final static SimpleTypeMapper SIMPLE_TYPE_MAPPER = new SimpleTypeMapperImpl();
+
+ public JAXBContextHelper(ExtensionPointRegistry registry) {
+ cache = new JAXBContextCache(registry);
+ }
+
+ public static JAXBContextHelper getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilityExtensionPoint.getUtility(JAXBContextHelper.class);
+ }
+
+ /**
+ * Create a JAXBContext for a given class
+ * @param cls
+ * @return
+ * @throws JAXBException
+ */
+ public JAXBContext createJAXBContext(Class<?> cls) throws JAXBException {
+ return cache.getJAXBContext(cls);
+ }
+
+ public JAXBContext createJAXBContext(TransformationContext tContext, boolean source) throws JAXBException {
+ if (tContext == null)
+ throw new TransformationException("JAXB context is not set for the transformation.");
+
+ // TODO: [rfeng] Need to figure out what's the best granularity to create the JAXBContext
+ // per interface, operation or parameter
+ Operation op = source ? tContext.getSourceOperation() : tContext.getTargetOperation();
+ if (op != null) {
+ synchronized (op) {
+ JAXBContext context = op.getInputType().getMetaData(JAXBContext.class);
+ if (context == null) {
+ context = createJAXBContext(getDataTypes(op, true));
+ op.getInputType().setMetaData(JAXBContext.class, context);
+ }
+ return context;
+ }
+ }
+
+ // For property transformation, the operation can be null
+ DataType<?> dataType = source ? tContext.getSourceDataType() : tContext.getTargetDataType();
+ return createJAXBContext(dataType);
+
+ }
+
+ private static Class<?>[] getSeeAlso(Class<?> interfaze) {
+ if (interfaze == null) {
+ return null;
+ }
+ XmlSeeAlso seeAlso = interfaze.getAnnotation(XmlSeeAlso.class);
+ if (seeAlso == null) {
+ return null;
+ } else {
+ return seeAlso.value();
+ }
+ }
+
+ public JAXBContext createJAXBContext(DataType dataType) throws JAXBException {
+ return createJAXBContext(findClasses(dataType));
+ }
+
+ public Unmarshaller getUnmarshaller(JAXBContext context) throws JAXBException {
+ return cache.getUnmarshaller(context);
+ }
+
+ public void releaseJAXBUnmarshaller(JAXBContext context, Unmarshaller unmarshaller) {
+ cache.releaseJAXBUnmarshaller(context, unmarshaller);
+ }
+
+ public Marshaller getMarshaller(JAXBContext context) throws JAXBException {
+ return cache.getMarshaller(context);
+ }
+
+ public void releaseJAXBMarshaller(JAXBContext context, Marshaller marshaller) {
+ cache.releaseJAXBMarshaller(context, marshaller);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Object createJAXBElement(JAXBContext context, DataType dataType, Object value) {
+ Class<?> type = dataType == null ? value.getClass() : dataType.getPhysical();
+ QName name = JAXBDataBinding.ROOT_ELEMENT;
+ if (context != null) {
+ Object logical = dataType == null ? null : dataType.getLogical();
+ if (logical instanceof XMLType) {
+ XMLType xmlType = (XMLType)logical;
+ if (xmlType.isElement()) {
+ name = xmlType.getElementName();
+ } else {
+ /**
+ * Set the declared type to Object.class so that xsi:type
+ * will be produced
+ */
+ type = Object.class;
+ }
+ } else {
+ type = Object.class;
+ }
+ }
+
+ JAXBIntrospector introspector = context.createJAXBIntrospector();
+ Object element = null;
+ if (value != null && introspector.isElement(value)) {
+ // NOTE: [rfeng] We cannot wrap an element in a JAXBElement
+ element = value;
+ }
+ if (element == null) {
+ // For local elements, we still have to produce xsi:type
+ element = new JAXBElement(name, Object.class, value);
+ }
+ return element;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Object createReturnValue(JAXBContext context, DataType dataType, Object value) {
+ Class<?> cls = getJavaType(dataType);
+ if (cls == JAXBElement.class) {
+ return createJAXBElement(context, dataType, value);
+ } else {
+ if (value instanceof JAXBElement) {
+ Object returnValue = ((JAXBElement)value).getValue();
+
+ if (returnValue == null){
+ // TUSCANY-3530
+ // something went wrong in the transformation that
+ // generated the JAXBElement. Have seen this when trying
+ // to convert a value to a simple type with an incompatible
+ // value.
+ throw new TransformationException("Null returned when trying to convert value to: " + cls.getName());
+ }
+ return returnValue;
+ } else {
+ return value;
+ }
+ }
+ }
+
+ /**
+ * Create a JAXContext for an array of classes
+ * @param classes
+ * @return
+ * @throws JAXBException
+ */
+ public JAXBContext createJAXBContext(Class<?>[] classes) throws JAXBException {
+ return cache.getJAXBContext(classes);
+ }
+
+ public JAXBContext createJAXBContext(Set<Class<?>> classes) throws JAXBException {
+ return cache.getJAXBContext(classes);
+ }
+
+ /**
+ * Create a JAXBContext for a given java interface
+ * @param intf
+ * @return
+ * @throws JAXBException
+ */
+ public JAXBContext createJAXBContext(Interface intf, boolean useWrapper) throws JAXBException {
+ synchronized (cache) {
+ LRUCache<Object, JAXBContext> map = cache.getCache();
+ Integer key = new Integer(System.identityHashCode(intf));
+ JAXBContext context = map.get(key);
+ if (context != null) {
+ return context;
+ }
+ List<DataType> dataTypes = getDataTypes(intf, useWrapper);
+ context = createJAXBContext(dataTypes);
+ map.put(key, context);
+ return context;
+ }
+ }
+
+ public JAXBContext createJAXBContext(List<DataType> dataTypes) throws JAXBException {
+ JAXBContext context;
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ Set<Type> visited = new HashSet<Type>();
+ for (DataType d : dataTypes) {
+ findClasses(d, classes, visited);
+ }
+
+ context = createJAXBContext(classes);
+ return context;
+ }
+
+ private static Set<Class<?>> findClasses(DataType d) {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ Set<Type> visited = new HashSet<Type>();
+ findClasses(d, classes, visited);
+ return classes;
+ }
+
+ private static void findClasses(DataType d, Set<Class<?>> classes, Set<Type> visited) {
+ if (d == null) {
+ return;
+ }
+ String db = d.getDataBinding();
+ if (JAXBDataBinding.NAME.equals(db) || (db != null && db.startsWith("java:")) || db == null) {
+ if (!d.getPhysical().isInterface() && !JAXBElement.class.isAssignableFrom(d.getPhysical())) {
+ classes.add(d.getPhysical());
+ }
+ }
+ if (d.getPhysical() != d.getGenericType()) {
+ findClasses(d.getGenericType(), classes, visited);
+ }
+ }
+
+ /**
+ * Find referenced classes in the generic type
+ * @param type
+ * @param classSet
+ * @param visited
+ */
+ private static void findClasses(Type type, Set<Class<?>> classSet, Set<Type> visited) {
+ if (visited.contains(type) || type == null) {
+ return;
+ }
+ visited.add(type);
+ if (type instanceof Class) {
+ Class<?> cls = (Class<?>)type;
+ if (!cls.isInterface()) {
+ classSet.add(cls);
+ }
+ return;
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType)type;
+ findClasses(pType.getRawType(), classSet, visited);
+ for (Type t : pType.getActualTypeArguments()) {
+ findClasses(t, classSet, visited);
+ }
+ } else if (type instanceof TypeVariable) {
+ TypeVariable<?> tv = (TypeVariable<?>)type;
+ for (Type t : tv.getBounds()) {
+ findClasses(t, classSet, visited);
+ }
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType gType = (GenericArrayType)type;
+ findClasses(gType.getGenericComponentType(), classSet, visited);
+ } else if (type instanceof WildcardType) {
+ WildcardType wType = (WildcardType)type;
+ for (Type t : wType.getLowerBounds()) {
+ findClasses(t, classSet, visited);
+ }
+ for (Type t : wType.getUpperBounds()) {
+ findClasses(t, classSet, visited);
+ }
+ }
+ }
+
+ public JAXBContext createJAXBContext(Interface intf) throws JAXBException {
+ return createJAXBContext(intf, true);
+ }
+
+ /**
+ * @param intf
+ * @param useWrapper Use wrapper classes?
+ * @return
+ */
+ private static List<DataType> getDataTypes(Interface intf, boolean useWrapper) {
+ List<DataType> dataTypes = new ArrayList<DataType>();
+ for (Operation op : intf.getOperations()) {
+ getDataTypes(dataTypes, op, useWrapper);
+ }
+ return dataTypes;
+ }
+
+ private static List<DataType> getDataTypes(Operation op, boolean useWrapper) {
+ List<DataType> dataTypes = new ArrayList<DataType>();
+ getDataTypes(dataTypes, op, useWrapper);
+ // Adding classes referenced by @XmlSeeAlso in the java interface
+ Interface interface1 = op.getInterface();
+ if (interface1 instanceof JavaInterface) {
+ JavaInterface javaInterface = (JavaInterface)interface1;
+ Class<?>[] seeAlso = getSeeAlso(javaInterface.getJavaClass());
+ if (seeAlso != null) {
+ for (Class<?> cls : seeAlso) {
+ dataTypes.add(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls, XMLType.UNKNOWN));
+ }
+ }
+ seeAlso = getSeeAlso(javaInterface.getCallbackClass());
+ if (seeAlso != null) {
+ for (Class<?> cls : seeAlso) {
+ dataTypes.add(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls, XMLType.UNKNOWN));
+ }
+ }
+ }
+ return dataTypes;
+ }
+
+ private static void getDataTypes(List<DataType> dataTypes, Operation op, boolean useWrapper) {
+ WrapperInfo wrapper = op.getWrapper();
+ if (useWrapper && wrapper != null) {
+ DataType dt1 = wrapper.getInputWrapperType();
+ if (dt1 != null) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = wrapper.getOutputWrapperType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ }
+ // FIXME: [rfeng] We may need to find the referenced classes in the child types
+ // else
+ {
+ for (DataType dt1 : op.getInputType().getLogical()) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = op.getOutputType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ }
+ for (DataType<DataType> dt3 : op.getFaultTypes()) {
+ DataType dt4 = dt3.getLogical();
+ if (dt4 != null) {
+ dataTypes.add(dt4);
+ }
+ }
+ }
+
+ public static Class<?> getJavaType(DataType<?> dataType) {
+ if (dataType == null) {
+ return null;
+ }
+ Class type = dataType.getPhysical();
+ if (JAXBElement.class.isAssignableFrom(type)) {
+ Type generic = dataType.getGenericType();
+ type = Object.class;
+ }
+ if (type == Object.class && dataType.getLogical() instanceof XMLType) {
+ XMLType xType = (XMLType)dataType.getLogical();
+ Class javaType = SIMPLE_TYPE_MAPPER.getJavaType(xType.getTypeName());
+ if (javaType != null) {
+ type = javaType;
+ }
+ }
+ return type;
+ }
+
+ public static XMLType getXmlTypeName(Class<?> javaType) {
+ if (javaType.isInterface()) {
+ // JAXB doesn't support interfaces
+ return null;
+ }
+ String namespace = null;
+ String name = null;
+ Package pkg = javaType.getPackage();
+ if (pkg != null) {
+ XmlSchema schema = pkg.getAnnotation(XmlSchema.class);
+ if (schema != null) {
+ namespace = schema.namespace();
+ }
+ }
+
+ QName elementQName = null;
+ QName typeQName = null;
+ XmlRootElement rootElement = javaType.getAnnotation(XmlRootElement.class);
+ if (rootElement != null) {
+ String elementName = rootElement.name();
+ String elementNamespace = rootElement.namespace();
+ if (elementNamespace.equals("##default")) {
+ elementNamespace = namespace;
+ }
+ if (elementName.equals("##default")) {
+ elementName = jaxbDecapitalize(javaType.getSimpleName());
+ }
+ elementQName = new QName(elementNamespace, elementName);
+ }
+ XmlType type = javaType.getAnnotation(XmlType.class);
+ if (type != null) {
+ String typeNamespace = type.namespace();
+ String typeName = type.name();
+
+ if (typeNamespace.equals("##default")) {
+ // namespace is from the package
+ typeNamespace = namespace;
+ }
+
+ if (typeName.equals("##default")) {
+ typeName = jaxbDecapitalize(javaType.getSimpleName());
+ }
+ typeQName = new QName(typeNamespace, typeName);
+ } else {
+ XmlEnum xmlEnum = javaType.getAnnotation(XmlEnum.class);
+ // POJO can have the @XmlSchema on the package-info too
+ if (xmlEnum != null || namespace != null) {
+ name = jaxbDecapitalize(javaType.getSimpleName());
+ typeQName = new QName(namespace, name);
+ }
+ }
+ if (elementQName == null && typeQName == null) {
+ return null;
+ }
+ return new XMLType(elementQName, typeQName);
+ }
+
+ /**
+ * The JAXB RI doesn't implement the decapitalization algorithm in the
+ * JAXB spec. See Sun bug 6505643 for details. This means that instead
+ * of calling java.beans.Introspector.decapitalize() as the JAXB spec says,
+ * Tuscany needs to mimic the incorrect JAXB RI algorithm.
+ */
+ public static String jaxbDecapitalize(String name) {
+ // find first lower case char in name
+ int lower = name.length();
+ for (int i = 0; i < name.length(); i++) {
+ if (Character.isLowerCase(name.charAt(i))) {
+ lower = i;
+ break;
+ }
+ }
+
+ int decap;
+ if (name.length() == 0) {
+ decap = 0; // empty string: nothing to do
+ } else if (lower == 0) {
+ decap = 0; // first char is lower case: nothing to do
+ } else if (lower == 1) {
+ decap = 1; // one upper followed by lower: decapitalize 1 char
+ } else if (lower < name.length()) {
+ decap = lower - 1; // n uppers followed by at least one lower: decapitalize n-1 chars
+ } else {
+ decap = name.length(); // all upper case: decapitalize all chars
+ }
+
+ return name.substring(0, decap).toLowerCase() + name.substring(decap);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
new file mode 100644
index 0000000000..5d7527cfa7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.w3c.dom.Document;
+
+/**
+ * JAXB DataBinding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXBDataBinding extends BaseDataBinding {
+ public static final String NAME = JAXBElement.class.getName();
+
+ public static final String ROOT_NAMESPACE = "http://tuscany.apache.org/xmlns/sca/databinding/jaxb/1.0";
+ public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "root");
+
+ private JAXBWrapperHandler wrapperHandler;
+ private JAXBTypeHelper xmlTypeHelper;
+ private DOMHelper domHelper;
+ private JAXBContextHelper contextHelper;
+
+ public JAXBDataBinding(ExtensionPointRegistry registry) {
+ super(NAME, JAXBElement.class);
+ this.wrapperHandler = new JAXBWrapperHandler();
+ this.xmlTypeHelper = new JAXBTypeHelper(registry);
+ this.domHelper = DOMHelper.getInstance(registry);
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+
+ @Override
+ public boolean introspect(DataType dataType, Operation operation) {
+ Class javaType = dataType.getPhysical();
+ if (JAXBElement.class.isAssignableFrom(javaType)) {
+ Type type = javaType.getGenericSuperclass();
+ if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = ((ParameterizedType)type);
+ Type rawType = parameterizedType.getRawType();
+ if (rawType == JAXBElement.class) {
+ Type actualType = parameterizedType.getActualTypeArguments()[0];
+ if (actualType instanceof Class) {
+ XMLType xmlType = JAXBContextHelper.getXmlTypeName((Class)actualType);
+ dataType.setLogical(xmlType);
+ dataType.setDataBinding(NAME);
+ return true;
+ }
+ }
+ }
+ if (dataType.getLogical() == null) {
+ dataType.setLogical(XMLType.UNKNOWN);
+ }
+ dataType.setDataBinding(NAME);
+ return true;
+ }
+
+ XMLType xmlType = JAXBContextHelper.getXmlTypeName(javaType);
+ if (xmlType == null) {
+ return false;
+ }
+ dataType.setLogical(xmlType);
+ dataType.setDataBinding(NAME);
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object copy(Object arg,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ try {
+ boolean isElement = false;
+ if (sourceDataType == null) {
+ Class cls = arg.getClass();
+ if (arg instanceof JAXBElement) {
+ isElement = true;
+ cls = ((JAXBElement)arg).getDeclaredType();
+ }
+ sourceDataType = new DataTypeImpl<XMLType>(NAME, cls, XMLType.UNKNOWN);
+ }
+ JAXBContext context = contextHelper.createJAXBContext(sourceDataType);
+ arg = JAXBContextHelper.createJAXBElement(context, sourceDataType, arg);
+ Document doc = domHelper.newDocument();
+ context.createMarshaller().marshal(arg, doc);
+
+ Object value;
+ if (targetDataType != null && targetDataType.getPhysical() != sourceDataType.getPhysical()) {
+ JAXBContext targetContext = contextHelper.createJAXBContext(targetDataType);
+ value = targetContext.createUnmarshaller().unmarshal(doc, targetDataType.getPhysical());
+ } else {
+ value = context.createUnmarshaller().unmarshal(doc, sourceDataType.getPhysical());
+ }
+
+ if (isElement && value instanceof JAXBElement) {
+ return value;
+ }
+ return JAXBContextHelper.createReturnValue(context, sourceDataType, value);
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return wrapperHandler;
+ }
+
+ @Override
+ public XMLTypeHelper getXMLTypeHelper() {
+ // return new JAXBTypeHelper();
+ return xmlTypeHelper;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBPropertyDescriptor.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBPropertyDescriptor.java
new file mode 100644
index 0000000000..217345caba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBPropertyDescriptor.java
@@ -0,0 +1,302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * A PropertyDescriptor provides access to a bean property. Values can be queried/changed using the
+ * read and writer methods of the PropertyDescriptor.
+ * <p/>
+ * A PropertyDescriptorPlus object wraps a PropertyDescriptor and supplies enhanced set/get methods
+ * that match JAXB semantics.
+ * <p/>
+ * For example, the set(..) method is smart enough to add lists, arrays and atomic values on JAXB
+ * beans.
+ * <p/>
+ * The PropertyDescriptorPlus object also stores the xmlName of the property.
+ *
+ * @See XMLRootElementUtil.createPropertyDescriptorMap , which creates the PropertyDescriptorPlus
+ * objects
+ */
+public class JAXBPropertyDescriptor implements Comparable<JAXBPropertyDescriptor> {
+ PropertyDescriptor descriptor;
+ QName xmlName = null;
+ int index;
+
+ /**
+ * Package protected constructor. Only created by XMLRootElementUtil.createPropertyDescriptorMap
+ * @param descriptor
+ * @param index TODO
+ * @param propertyName
+ *
+ * @see XMLRootElementUtil.createPropertyDescriptorMap
+ */
+ JAXBPropertyDescriptor(PropertyDescriptor descriptor, QName xmlName, int index) {
+ super();
+ this.descriptor = descriptor;
+ this.xmlName = xmlName;
+ }
+
+ /**
+ * Package protected constructor. Only created by XMLRootElementUtil.createPropertyDescriptorMap
+ * @param descriptor
+ * @param index TODO
+ * @param propertyName
+ *
+ * @see XMLRootElementUtil.createPropertyDescriptorMap
+ */
+ JAXBPropertyDescriptor(PropertyDescriptor descriptor, String xmlName, int index) {
+ super();
+ this.descriptor = descriptor;
+ this.xmlName = new QName("", xmlName);
+ }
+
+ public int compareTo(JAXBPropertyDescriptor o) {
+ return index - o.index;
+ }
+
+ /** @return xmlname */
+ public String getXmlName() {
+ return xmlName.getLocalPart();
+ }
+
+ public QName getXmlQName() {
+ return xmlName;
+ }
+
+ /** @return property type */
+ public Class<?> getPropertyType() {
+ return descriptor.getPropertyType();
+ }
+
+ /** @return property name */
+ public String getPropertyName() {
+ return descriptor.getName();
+ }
+
+ /**
+ * Get the object
+ *
+ * @param targetBean
+ * @return Object for this property or null
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ */
+ public Object get(Object targetBean) throws InvocationTargetException, IllegalAccessException {
+ Method method = descriptor.getReadMethod();
+ if (method == null && descriptor.getPropertyType() == Boolean.class) {
+ String propertyName = descriptor.getName();
+ if (propertyName != null) {
+ String methodName = "is";
+ methodName =
+ methodName + ((propertyName.length() > 0) ? propertyName.substring(0, 1).toUpperCase() : "");
+ methodName = methodName + ((propertyName.length() > 1) ? propertyName.substring(1) : "");
+ try {
+ method = targetBean.getClass().getMethod(methodName);
+ } catch (NoSuchMethodException e) {
+ }
+ }
+ }
+ if (method == null) {
+ throw new ServiceRuntimeException("No getter is found");
+ }
+ Object ret = method.invoke(targetBean);
+ if (method.getReturnType() == JAXBElement.class) {
+ ret = ((JAXBElement<?>)ret).getValue();
+ }
+ return ret;
+ }
+
+ /**
+ * Set the object
+ *
+ * @param targetBean
+ * @param propValue
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ * @throws JAXBWrapperException
+ */
+ public void set(Object targetBean, Object propValue) throws InvocationTargetException, IllegalAccessException,
+ JAXBWrapperException {
+
+ Method writeMethod = null;
+ try {
+ // No set occurs if the value is null
+ if (propValue == null) {
+ return;
+ }
+
+ // There are 3 different types of setters that can occur.
+ // 1) Normal Attomic Setter : setFoo(type)
+ // 2) Indexed Array Setter : setFoo(type[])
+ // 3) No Setter case if the property is a List<T>.
+
+ writeMethod = descriptor.getWriteMethod();
+ if (descriptor instanceof IndexedPropertyDescriptor) {
+ // Set for indexed T[]
+ setIndexedArray(targetBean, propValue, writeMethod);
+ } else if (writeMethod == null) {
+ // Set for List<T>
+ setList(targetBean, propValue);
+ } else if (descriptor.getPropertyType() == JAXBElement.class) {
+ if (propValue != null) {
+ Class<?> clazz = propValue.getClass();
+ JAXBElement<?> element = new JAXBElement(xmlName, clazz, propValue);
+ setAtomic(targetBean, element, writeMethod);
+ }
+ } else {
+ // Normal case
+ setAtomic(targetBean, propValue, writeMethod);
+ }
+ } catch (RuntimeException e) {
+ throw e;
+ }
+ }
+
+ /**
+ * Set the property value onto targetBean using the writeMethod
+ *
+ * @param targetBean
+ * @param propValue
+ * @param writeMethod (set(T))
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ * @throws JAXBWrapperException
+ */
+ private void setAtomic(Object targetBean, Object propValue, Method writeMethod) throws InvocationTargetException,
+ IllegalAccessException, JAXBWrapperException {
+ // JAXB provides setters for atomic value.
+
+ if (propValue != null) {
+ // Normal case
+ Object[] SINGLE_PARAM = new Object[1];
+ SINGLE_PARAM[0] = propValue;
+ writeMethod.invoke(targetBean, SINGLE_PARAM);
+ } else {
+ Class<?>[] paramTypes = writeMethod.getParameterTypes();
+
+ if (paramTypes != null && paramTypes.length == 1) {
+ Class<?> paramType = paramTypes[0];
+ if (paramType.isPrimitive() && propValue == null) {
+ //Ignoring null value for primitive type, this could potentially be the way of a customer indicating to set
+ //default values defined in JAXBObject/xmlSchema.
+ return;
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Set the property value using the indexed array setter
+ *
+ * @param targetBean
+ * @param propValue
+ * @param writeMethod set(T[])
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ * @throws JAXBWrapperException
+ */
+ private void setIndexedArray(Object targetBean, Object propValue, Method writeMethod)
+ throws InvocationTargetException, IllegalAccessException, JAXBWrapperException {
+
+ Class<?> paramType = writeMethod.getParameterTypes()[0];
+ Object value = asArray(propValue, paramType);
+ // JAXB provides setters for atomic value.
+ Object[] SINGLE_PARAM = new Object[1];
+ SINGLE_PARAM[0] = value;
+
+ writeMethod.invoke(targetBean, SINGLE_PARAM);
+ }
+
+ /**
+ * Set the property value for the collection case.
+ *
+ * @param targetBean
+ * @param propValue
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ * @throws JAXBWrapperException
+ */
+ private void setList(Object targetBean, Object propValue) throws InvocationTargetException, IllegalAccessException,
+ JAXBWrapperException {
+ // For the List<T> case, there is no setter.
+ // You are supposed to use the getter to obtain access to the collection and then add the collection
+
+ Collection value = asCollection(propValue, descriptor.getPropertyType());
+ Collection collection = (Collection)get(targetBean);
+
+ // Now add our our object to the collection
+ collection.clear();
+ if (propValue != null) {
+ collection.addAll(value);
+ }
+ }
+
+ /**
+ * @param propValue
+ * @param destType
+ * @return propValue as a Collection
+ */
+ private static Collection asCollection(Object propValue, Class<?> destType) {
+ // TODO Missing function
+ // Convert the object into an equivalent object that is a collection
+ if (DataConverter.isConvertable(propValue, destType)) {
+ return (Collection)DataConverter.convert(propValue, destType);
+ } else {
+ String objectClass = (propValue == null) ? "null" : propValue.getClass().getName();
+ throw new ServiceRuntimeException("Cannot convert " + objectClass);
+ }
+ }
+
+ /**
+ * @param propValue
+ * @param destType T[]
+ * @return array of component type
+ */
+ private static Object asArray(Object propValue, Class<?> destType) {
+ if (DataConverter.isConvertable(propValue, destType)) {
+ return DataConverter.convert(propValue, destType);
+ } else {
+ String objectClass = (propValue == null) ? "null" : propValue.getClass().getName();
+ throw new ServiceRuntimeException("Cannot convert " + objectClass);
+
+ }
+ }
+
+ @Override
+ public String toString() {
+ String value = "PropertyDescriptorPlus[";
+ value += " name=" + this.getPropertyName();
+ value += " type=" + this.getPropertyType().getName();
+ value += " propertyDecriptor=" + this.descriptor;
+ return value + "]";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
new file mode 100644
index 0000000000..84529752de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Document;
+
+public class JAXBTypeHelper implements XMLTypeHelper {
+ private static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+ private static final String ANYTYPE_NAME = "anyType";
+ private static final QName ANYTYPE_QNAME = new QName(SCHEMA_NS, ANYTYPE_NAME);
+
+ private JAXBContextHelper contextHelper;
+
+ public JAXBTypeHelper(ExtensionPointRegistry registry) {
+ super();
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+
+ public TypeInfo getTypeInfo(Class javaType, Object logical) {
+ QName xmlType = JavaXMLMapper.getXMLType(javaType);
+ if (xmlType != null) {
+ return new TypeInfo(xmlType, true, null);
+ } else if (javaType.isInterface()) {
+ return new TypeInfo(ANYTYPE_QNAME, true, null);
+ } else {
+ // types.add(javaType);
+ if (logical instanceof XMLType) {
+ xmlType = ((XMLType)logical).getTypeName();
+ }
+ if (xmlType == null) {
+ xmlType = new QName(JAXBContextHelper.jaxbDecapitalize(javaType.getSimpleName()));
+ }
+ return new TypeInfo(xmlType, false, null);
+ }
+ }
+
+ /*
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver) {
+ List<XSDefinition> definitions = new ArrayList<XSDefinition>();
+ generateJAXBSchemas(definitions, factory);
+ return definitions;
+ }
+ */
+
+ public static Map<String, String> generateSchema(JAXBContext context) throws IOException {
+ StringResolverImpl resolver = new StringResolverImpl();
+ context.generateSchema(resolver);
+ Map<String, String> xsds = new HashMap<String, String>();
+ for (Map.Entry<String, StreamResult> xsd : resolver.getResults().entrySet()) {
+ xsds.put(xsd.getKey(), xsd.getValue().getWriter().toString());
+ }
+ return xsds;
+ }
+
+// private static class XSDResolver implements URIResolver {
+// private Map<String, String> xsds;
+//
+// public XSDResolver(Map<String, String> xsds) {
+// super();
+// this.xsds = xsds;
+// }
+//
+// public InputSource resolveEntity(java.lang.String namespace,
+// java.lang.String schemaLocation,
+// java.lang.String baseUri) {
+// String xsd = xsds.get(schemaLocation);
+// if (xsd == null) {
+// return null;
+// }
+// return new InputSource(new StringReader(xsd));
+// }
+//
+// }
+
+ /*
+ private void generateJAXBSchemas1(List<XSDefinition> definitions, XSDFactory factory) {
+ if (types.size() > 0) {
+ try {
+ XmlSchemaCollection collection = new XmlSchemaCollection();
+ Class[] typesArray = new Class[types.size()];
+ typesArray = types.toArray(typesArray);
+ JAXBContext context = JAXBContextHelper.createJAXBContext(typesArray);
+ Map<String, String> results = generateSchema(context);
+ collection.setSchemaResolver(new XSDResolver(results));
+
+ for (Map.Entry<String, String> entry : results.entrySet()) {
+ XSDefinition definition = factory.createXSDefinition();
+ int index = entry.getKey().lastIndexOf('#');
+ String ns = entry.getKey().substring(0, index);
+ String file = entry.getKey().substring(index + 1);
+ definition.setUnresolved(true);
+ definition.setNamespace(ns);
+ definition.setSchema(collection.read(new StringReader(entry.getValue()), null));
+ definition.setSchemaCollection(collection);
+ definition.setUnresolved(false);
+ definitions.add(definition);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ */
+
+ private static class DOMResolverImpl extends SchemaOutputResolver {
+ private Map<String, DOMResult> results = new HashMap<String, DOMResult>();
+
+ @Override
+ public Result createOutput(String ns, String file) throws IOException {
+ DOMResult result = new DOMResult();
+ // TUSCANY-2498: Set the system id to "" so that the xsd:import doesn't produce
+ // an illegal schemaLocation attr
+ result.setSystemId("");
+ results.put(ns, result);
+ return result;
+ }
+
+ public Map<String, DOMResult> getResults() {
+ return results;
+ }
+ }
+
+ /*
+ private void generateJAXBSchemas(List<XSDefinition> definitions, XSDFactory factory) {
+ if (types.size() > 0) {
+ try {
+ Class<?>[] typesArray = new Class<?>[types.size()];
+ typesArray = types.toArray(typesArray);
+ JAXBContext context = JAXBContext.newInstance(typesArray);
+ generateSchemas(definitions, factory, context);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ */
+
+ private void generateSchemas(List<XSDefinition> definitions, XSDFactory factory, JAXBContext context)
+ throws IOException {
+ DOMResolverImpl resolver = new DOMResolverImpl();
+ context.generateSchema(resolver);
+ Map<String, DOMResult> results = resolver.getResults();
+ for (Map.Entry<String, DOMResult> entry : results.entrySet()) {
+ XSDefinition definition = factory.createXSDefinition();
+ definition.setUnresolved(true);
+ definition.setDocument((Document)entry.getValue().getNode());
+ definition.setNamespace(entry.getKey());
+ URI location = null;
+ try {
+ location = new URI(entry.getValue().getSystemId());
+ } catch (URISyntaxException e) {
+ // ignore: use null value
+ }
+ definition.setLocation(location);
+ definitions.add(definition);
+ }
+ }
+
+ private static class StringResolverImpl extends SchemaOutputResolver {
+ private Map<String, StreamResult> results = new HashMap<String, StreamResult>();
+
+ @Override
+ public Result createOutput(String ns, String file) throws IOException {
+ StringWriter sw = new StringWriter();
+ StreamResult result = new StreamResult(sw);
+ String sysId = ns + '#' + file;
+ result.setSystemId(sysId);
+ results.put(sysId, result);
+ return result;
+ }
+
+ public Map<String, StreamResult> getResults() {
+ return results;
+ }
+ }
+
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, Interface intf) {
+ try {
+ JAXBContext context = contextHelper.createJAXBContext(intf, false);
+ List<XSDefinition> definitions = new ArrayList<XSDefinition>();
+ generateSchemas(definitions, factory, context);
+ return definitions;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, List<DataType> dataTypes) {
+ try {
+
+ JAXBContext context = contextHelper.createJAXBContext(dataTypes);
+ List<XSDefinition> definitions = new ArrayList<XSDefinition>();
+ generateSchemas(definitions, factory, context);
+ return definitions;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperException.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperException.java
new file mode 100644
index 0000000000..7473a8e56e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperException.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 org.apache.tuscany.sca.databinding.jaxb;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class JAXBWrapperException extends ServiceRuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ public JAXBWrapperException() {
+ super();
+
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public JAXBWrapperException(String message, Throwable cause) {
+ super(message, cause);
+
+ }
+
+ /** @param message */
+ public JAXBWrapperException(String message) {
+ super(message);
+
+ }
+
+ /** @param cause */
+ public JAXBWrapperException(Throwable cause) {
+ super(cause);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java
new file mode 100644
index 0000000000..a1f4c12c8f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.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.databinding.jaxb;
+
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+
+/**
+ * JAXB WrapperHandler implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXBWrapperHandler implements WrapperHandler<Object> {
+ private JAXBWrapperHelper helper = new JAXBWrapperHelper();
+
+ public Object create(Operation operation, boolean input) {
+ WrapperInfo wrapperInfo = operation.getWrapper();
+ ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement();
+ final Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass();
+ try {
+ if (wrapperClass == null) {
+ return null;
+ }
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ return wrapperClass.newInstance();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public void setChildren(Object wrapper, Object[] childObjects, Operation operation, boolean input) {
+ List<ElementInfo> childElements =
+ input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements();
+ List<String> childNames = new ArrayList<String>();
+ Map<String, Object> values = new HashMap<String, Object>();
+ for (int i = 0; i < childElements.size(); i++) {
+ ElementInfo e = childElements.get(i);
+ String name = e.getQName().getLocalPart();
+ childNames.add(name);
+ values.put(name, childObjects[i]);
+ }
+ // Get the property descriptor map
+ Map<String, JAXBPropertyDescriptor> pdMap = null;
+ try {
+ pdMap = XMLRootElementUtil.createPropertyDescriptorMap(wrapper.getClass());
+ } catch (Throwable t) {
+ throw new JAXBWrapperException(t);
+ }
+ helper.wrap(wrapper, childNames, values, pdMap);
+ }
+
+ public void setChild(Object wrapper, int i, ElementInfo childElement, Object value) {
+ Object wrapperValue = wrapper;
+ Class<?> wrapperClass = wrapperValue.getClass();
+
+ // FIXME: We probably should use the jaxb-reflection to handle the properties
+ try {
+ String prop = childElement.getQName().getLocalPart();
+ boolean collection = (value instanceof Collection);
+ Method getter = null;
+ for (Method m : wrapperClass.getMethods()) {
+ Class<?>[] paramTypes = m.getParameterTypes();
+ if (paramTypes.length == 1 && m.getName().equals("set" + capitalize(prop))) {
+ m.invoke(wrapperValue, new Object[] {value});
+ return;
+ }
+ if (collection && paramTypes.length == 0 && m.getName().equals("get" + capitalize(prop))) {
+ getter = m;
+ }
+ }
+ if (getter != null && Collection.class.isAssignableFrom(getter.getReturnType())) {
+ ((Collection)getter.invoke(wrapperValue)).addAll((Collection)value);
+ }
+
+ } catch (Throwable e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ private static String capitalize(String name) {
+ char first = Character.toUpperCase(name.charAt(0));
+ return first + name.substring(1);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#getChildren(java.lang.Object, Operation, boolean)
+ */
+ public List getChildren(Object wrapper, Operation operation, boolean input) {
+ List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements():
+ operation.getWrapper().getOutputChildElements();
+
+ List<String> childNames = new ArrayList<String>();
+ for (ElementInfo e : childElements) {
+ childNames.add(e.getQName().getLocalPart());
+ }
+ return Arrays.asList(helper.unwrap(wrapper, childNames));
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean)
+ */
+ public DataType getWrapperType(Operation operation, boolean input) {
+ WrapperInfo wrapper = operation.getWrapper();
+ DataType dt = input ? wrapper.getInputWrapperType() : wrapper.getOutputWrapperType();
+ return dt;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#isInstance(java.lang.Object, Operation, boolean)
+ */
+ public boolean isInstance(Object wrapper, Operation operation, boolean input) {
+ Class<?> wrapperClass =
+ input ? operation.getWrapper().getInputWrapperClass() : operation.getWrapper().getOutputWrapperClass();
+ return wrapperClass == null ? false : wrapperClass.isInstance(wrapper);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHelper.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHelper.java
new file mode 100644
index 0000000000..5f90aa4d7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHelper.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The JAXBWrapper tool is used to create a JAXB Object from a series of child objects (wrap) or get
+ * the child objects from a JAXB Object (unwrap)
+ */
+public class JAXBWrapperHelper {
+
+ /**
+ * unwrap Returns the list of child objects of the jaxb object
+ *
+ * @param jaxbObject that represents the type
+ * @param childNames list of xml child names as String
+ * @param pdMap PropertyDescriptor map for this jaxbObject
+ * @return list of Objects in the same order as the element names.
+ */
+ public Object[] unwrap(Object jaxbObject, List<String> childNames, Map<String, JAXBPropertyDescriptor> pdMap)
+ throws JAXBWrapperException {
+
+ // Get the object that will have the property descriptors (i.e. the object representing the complexType)
+ Object jaxbComplexTypeObj = jaxbObject;
+
+ // Get the PropertyDescriptorPlus map.
+ // The method makes sure that each child name has a matching jaxb property
+ // checkPropertyDescriptorMap(jaxbComplexTypeObj.getClass(), childNames, pdMap);
+
+ // Get the corresponsing objects from the jaxb bean
+ ArrayList<Object> objList = new ArrayList<Object>();
+ int index = 0;
+ for (String childName : childNames) {
+ JAXBPropertyDescriptor propInfo = getPropertyDescriptor(pdMap, childName, index);
+
+ Object object = null;
+ try {
+ object = propInfo.get(jaxbComplexTypeObj);
+ } catch (Throwable e) {
+ throw new JAXBWrapperException(e);
+ }
+
+ objList.add(object);
+ index++;
+ }
+ Object[] jaxbObjects = objList.toArray();
+ objList = null;
+ return jaxbObjects;
+
+ }
+
+ private JAXBPropertyDescriptor getPropertyDescriptor(Map<String, JAXBPropertyDescriptor> pdMap,
+ String childName,
+ int index) {
+ JAXBPropertyDescriptor propInfo = pdMap.get(childName);
+ if (propInfo == null) {
+ // FIXME: [rfeng] Sometimes the child element names don't match. Get chilld by location?
+ List<JAXBPropertyDescriptor> props = new ArrayList<JAXBPropertyDescriptor>(pdMap.values());
+ // Sort the properties by index. We might need to take propOrder into consideration
+ Collections.sort(props);
+ propInfo = props.get(index);
+ }
+ return propInfo;
+ }
+
+ /**
+ * wrap Creates a jaxb object that is initialized with the child objects.
+ * <p/>
+ * Note that the jaxbClass must be the class the represents the complexType. (It should never be
+ * JAXBElement)
+ *
+ * @param jaxbClass
+ * @param childNames list of xml child names as String
+ * @param childObjects, component type objects
+ * @param pdMap PropertyDescriptor map for this jaxbObject
+ */
+ public Object wrap(Class<?> jaxbClass,
+ List<String> childNames,
+ Map<String, Object> childObjects,
+ Map<String, JAXBPropertyDescriptor> pdMap) throws JAXBWrapperException {
+
+ // Just like unWrap, get the property info map
+ // checkPropertyDescriptorMap(jaxbClass, childNames, pdMap);
+
+ // The jaxb object always has a default constructor. Create the object
+ Object jaxbObject = null;
+ try {
+ jaxbObject = jaxbClass.newInstance();
+ } catch (Throwable t) {
+ throw new JAXBWrapperException(t);
+ }
+
+ wrap(jaxbObject, childNames, childObjects, pdMap);
+
+ // Return the jaxb object
+ return jaxbObject;
+ }
+
+ public void wrap(Object jaxbObject,
+ List<String> childNames,
+ Map<String, Object> childObjects,
+ Map<String, JAXBPropertyDescriptor> pdMap) {
+ // Now set each object onto the jaxb object
+ int index = 0;
+ for (String childName : childNames) {
+ JAXBPropertyDescriptor propInfo = getPropertyDescriptor(pdMap, childName, index);
+ Object value = childObjects.get(childName);
+ try {
+ propInfo.set(jaxbObject, value);
+ } catch (Throwable t) {
+ throw new JAXBWrapperException(t);
+ }
+ index++;
+ }
+ }
+
+ public Object[] unwrap(Object jaxbObject, List<String> childNames) throws JAXBWrapperException {
+ // Get the property descriptor map for this JAXBClass
+ Class<?> jaxbClass = jaxbObject.getClass();
+ Map<String, JAXBPropertyDescriptor> pdMap = null;
+ try {
+ pdMap = XMLRootElementUtil.createPropertyDescriptorMap(jaxbClass);
+ } catch (Throwable t) {
+ throw new JAXBWrapperException(t);
+ }
+
+ // Delegate
+ return unwrap(jaxbObject, childNames, pdMap);
+ }
+
+ public Object wrap(Class<?> jaxbClass, List<String> childNames, Map<String, Object> childObjects)
+ throws JAXBWrapperException {
+ // Get the property descriptor map
+ Map<String, JAXBPropertyDescriptor> pdMap = null;
+ try {
+ pdMap = XMLRootElementUtil.createPropertyDescriptorMap(jaxbClass);
+ } catch (Throwable t) {
+ throw new JAXBWrapperException(t);
+ }
+
+ // Delegate
+ return wrap(jaxbClass, childNames, childObjects, pdMap);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
new file mode 100644
index 0000000000..e6fc1b4405
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.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.sca.databinding.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Node2JAXB extends BaseTransformer<Node, Object> implements PullTransformer<Node, Object> {
+ private JAXBContextHelper contextHelper;
+
+ public Node2JAXB(ExtensionPointRegistry registry) {
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+
+ public Object transform(Node source, TransformationContext context) {
+ if (source == null)
+ return null;
+ try {
+ JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ Object result = unmarshaller.unmarshal(source, JAXBContextHelper.getJavaType(context.getTargetDataType()));
+ return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Node> getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 30;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
new file mode 100644
index 0000000000..b063d9524f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.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.databinding.jaxb;
+
+import java.io.Reader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Reader2JAXB extends BaseTransformer<Reader, Object> implements
+ PullTransformer<Reader, Object> {
+ private JAXBContextHelper contextHelper;
+
+ public Reader2JAXB(ExtensionPointRegistry registry) {
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+ public Object transform(final Reader source, final TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ StreamSource streamSource = new StreamSource(source);
+ Object result = unmarshaller.unmarshal(streamSource, JAXBContextHelper.getJavaType(context.getTargetDataType()));
+ return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Reader> getSourceType() {
+ return Reader.class;
+ }
+
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 30;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
new file mode 100644
index 0000000000..9d0accefcc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.io.StringReader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.xml.XMLStringDataBinding;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class String2JAXB extends BaseTransformer<String, Object> implements
+ PullTransformer<String, Object> {
+ private JAXBContextHelper contextHelper;
+
+ public String2JAXB(ExtensionPointRegistry registry) {
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+
+ public Object transform(final String source, final TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ StreamSource streamSource = new StreamSource(new StringReader(source));
+ Object result = unmarshaller.unmarshal(streamSource, JAXBContextHelper.getJavaType(context.getTargetDataType()));
+ return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<String> getSourceType() {
+ return String.class;
+ }
+
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 30;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return XMLStringDataBinding.NAME;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLAdapterExtensionPoint.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLAdapterExtensionPoint.java
new file mode 100644
index 0000000000..5fa98b5ed1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLAdapterExtensionPoint.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.databinding.jaxb;
+
+import java.util.Map;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface XMLAdapterExtensionPoint {
+ /**
+ * @param boundType
+ * @param adapter
+ */
+ void addAdapter(Class<?> boundType, Class<? extends XmlAdapter> adapter);
+
+ /**
+ * @param boundType
+ * @return
+ */
+ Class<? extends XmlAdapter> getAdapter(Class<?> boundType);
+
+ /**
+ * @param boundType
+ * @return
+ */
+ Class<? extends XmlAdapter> removeAdapter(Class<?> boundType);
+
+ /**
+ * @return
+ */
+ Map<Class<?>, Class<? extends XmlAdapter>> getAdapters();
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLRootElementUtil.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLRootElementUtil.java
new file mode 100644
index 0000000000..d177d53eda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLRootElementUtil.java
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.WeakHashMap;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchema;
+import javax.xml.namespace.QName;
+
+/**
+ *
+ */
+public class XMLRootElementUtil {
+
+ /**
+ * TUSCANY-3167
+ * Cache for property descriptors
+ */
+ private static Map<Class<?>, Map<String, JAXBPropertyDescriptor>> PROPERTY_MAP =
+ new WeakHashMap<Class<?>, Map<String, JAXBPropertyDescriptor>>();
+
+ /** Constructor is intentionally private. This class only provides static utility methods */
+ private XMLRootElementUtil() {
+
+ }
+
+ /**
+ * @param clazz
+ * @return namespace of root element qname or null if this is not object does not represent a
+ * root element
+ */
+ public static QName getXmlRootElementQNameFromObject(Object obj) {
+
+ // A JAXBElement stores its name
+ if (obj instanceof JAXBElement) {
+ return ((JAXBElement<?>)obj).getName();
+ }
+
+ Class<?> clazz = (obj instanceof java.lang.Class) ? (Class<?>)obj : obj.getClass();
+ return getXmlRootElementQName(clazz);
+ }
+
+ /**
+ * @param clazz
+ * @return namespace of root element qname or null if this is not object does not represent a
+ * root element
+ */
+ public static QName getXmlRootElementQName(Class<?> clazz) {
+
+ // See if the object represents a root element
+ XmlRootElement root = (XmlRootElement)getAnnotation(clazz, XmlRootElement.class);
+ if (root == null) {
+ return null;
+ }
+
+ String name = root.name();
+ String namespace = root.namespace();
+
+ // The name may need to be defaulted
+ if (name == null || name.length() == 0 || name.equals("##default")) {
+ name = getSimpleName(clazz.getCanonicalName());
+ }
+
+ // The namespace may need to be defaulted
+ if (namespace == null || namespace.length() == 0 || namespace.equals("##default")) {
+ Package pkg = clazz.getPackage();
+ XmlSchema schema = (XmlSchema)getAnnotation(pkg, XmlSchema.class);
+ if (schema != null) {
+ namespace = schema.namespace();
+ } else {
+ namespace = "";
+ }
+ }
+
+ return new QName(namespace, name);
+ }
+
+ /**
+ * @param clazz
+ * @return namespace of root element qname or null if this is not object does not represent a root element
+ */
+ public static String getEnumValue(Enum<?> myEnum) {
+ Field f;
+ String value;
+ try {
+ f = myEnum.getClass().getField(myEnum.name());
+
+ f.setAccessible(true);
+
+ XmlEnumValue xev = (XmlEnumValue)getAnnotation(f, XmlEnumValue.class);
+ if (xev == null) {
+ value = f.getName();
+ } else {
+ value = xev.value();
+ }
+ } catch (SecurityException e) {
+ value = null;
+ } catch (NoSuchFieldException e) {
+ value = null;
+ }
+
+ return value;
+ }
+
+ /**
+ * utility method to get the last token in a "."-delimited package+classname string
+ *
+ * @return
+ */
+ private static String getSimpleName(String in) {
+ if (in == null || in.length() == 0) {
+ return in;
+ }
+ String out = null;
+ StringTokenizer tokenizer = new StringTokenizer(in, ".");
+ if (tokenizer.countTokens() == 0)
+ out = in;
+ else {
+ while (tokenizer.hasMoreTokens()) {
+ out = tokenizer.nextToken();
+ }
+ }
+ return out;
+ }
+
+ /**
+ * The JAXBClass has a set of bean properties each represented by a PropertyDescriptor Each of
+ * the fields of the class has an associated xml name. The method returns a map where the key is
+ * the xml name and value is the PropertyDescriptor
+ *
+ * @param jaxbClass
+ * @return map
+ */
+ public synchronized static Map<String, JAXBPropertyDescriptor> createPropertyDescriptorMap(Class<?> jaxbClass)
+ throws NoSuchFieldException, IntrospectionException {
+
+ Map<String, JAXBPropertyDescriptor> map = PROPERTY_MAP.get(jaxbClass);
+ if (map != null) {
+ return map;
+ }
+
+ map = new HashMap<String, JAXBPropertyDescriptor>();
+ PropertyDescriptor[] pds = Introspector.getBeanInfo(jaxbClass).getPropertyDescriptors();
+
+ // Unfortunately the element names are stored on the fields.
+ // Get all of the fields in the class and super classes
+
+ List<Field> fields = getFields(jaxbClass);
+
+ // Now match up the fields with the property descriptors...Sigh why didn't JAXB put the @XMLElement annotations on the
+ // property methods!
+ for (PropertyDescriptor pd : pds) {
+
+ // Skip over the class property..it is never represented as an xml element
+ if (pd.getName().equals("class")) {
+ continue;
+ }
+
+ // For the current property, find a matching field...so that we can get the xml name
+ boolean found = false;
+
+ int index = 0;
+ for (Field field : fields) {
+ String fieldName = field.getName();
+
+ // Use the name of the field and property to find the match
+ if (fieldName.equalsIgnoreCase(pd.getDisplayName()) || fieldName.equalsIgnoreCase(pd.getName())) {
+ // Get the xmlElement name for this field
+ QName xmlName = getXmlElementRefOrElementQName(field.getDeclaringClass(), field);
+ found = true;
+ map.put(xmlName.getLocalPart(), new JAXBPropertyDescriptor(pd, xmlName, index));
+ index++;
+ break;
+ }
+
+ // Unfortunately, sometimes the field name is preceeded by an underscore
+ if (fieldName.startsWith("_")) {
+ fieldName = fieldName.substring(1);
+ if (fieldName.equalsIgnoreCase(pd.getDisplayName()) || fieldName.equalsIgnoreCase(pd.getName())) {
+ // Get the xmlElement name for this field
+ QName xmlName = getXmlElementRefOrElementQName(field.getDeclaringClass(), field);
+ found = true;
+
+ map.put(xmlName.getLocalPart(), new JAXBPropertyDescriptor(pd, xmlName, index));
+ index++;
+ break;
+ }
+ }
+ }
+
+ // We didn't find a field. Default the xmlname to the property name
+ if (!found) {
+ String xmlName = pd.getName();
+
+ map.put(xmlName, new JAXBPropertyDescriptor(pd, xmlName, index));
+ index++;
+ }
+ }
+ PROPERTY_MAP.put(jaxbClass, map);
+ return map;
+ }
+
+ /**
+ * Gets all of the fields in this class and the super classes
+ *
+ * @param beanClass
+ * @return
+ */
+ static private List<Field> getFields(final Class<?> beanClass) {
+ // This class must remain private due to Java 2 Security concerns
+ List<Field> fields = AccessController.doPrivileged(new PrivilegedAction<List<Field>>() {
+ public List<Field> run() {
+ List<Field> fields = new ArrayList<Field>();
+ Class<?> cls = beanClass;
+ while (cls != null) {
+ Field[] fieldArray = cls.getDeclaredFields();
+ for (Field field : fieldArray) {
+ fields.add(field);
+ }
+ cls = cls.getSuperclass();
+ }
+ return fields;
+ }
+ });
+
+ return fields;
+ }
+
+ /**
+ * Get the name of the field by looking at the XmlElement annotation.
+ *
+ * @param jaxbClass
+ * @param fieldName
+ * @return
+ * @throws NoSuchFieldException
+ */
+ private static QName getXmlElementRefOrElementQName(Class<?> jaxbClass, Field field) throws NoSuchFieldException {
+ XmlElementRef xmlElementRef = (XmlElementRef)getAnnotation(field, XmlElementRef.class);
+ if (xmlElementRef != null) {
+ return new QName(xmlElementRef.namespace(), xmlElementRef.name());
+ }
+ XmlElement xmlElement = (XmlElement)getAnnotation(field, XmlElement.class);
+
+ // If XmlElement does not exist, default to using the field name
+ if (xmlElement == null || xmlElement.name().equals("##default")) {
+ return new QName("", field.getName());
+ }
+ return new QName(xmlElement.namespace(), xmlElement.name());
+ }
+
+ /**
+ * Get an annotation. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static <T extends Annotation> T getAnnotation(final AnnotatedElement element, final Class<T> annotation) {
+ return AccessController.doPrivileged(new PrivilegedAction<T>() {
+ public T run() {
+ return element.getAnnotation(annotation);
+ }
+ });
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
new file mode 100644
index 0000000000..9c3760b119
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLStreamReader2JAXB extends BaseTransformer<XMLStreamReader, Object> implements
+ PullTransformer<XMLStreamReader, Object> {
+
+ private JAXBContextHelper contextHelper;
+
+ public XMLStreamReader2JAXB(ExtensionPointRegistry registry) {
+ contextHelper = JAXBContextHelper.getInstance(registry);
+ }
+
+ public Object transform(XMLStreamReader source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ // FIXME: [rfeng] If the java type is Object.class, the unmarshalled result will be
+ // a DOM Node
+ Object result = unmarshaller.unmarshal(source, JAXBContextHelper.getJavaType(context.getTargetDataType()));
+ source.close();
+ return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public Class<XMLStreamReader> getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/package.html b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/package.html
new file mode 100644
index 0000000000..3dd869384a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/package.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+Base Package for the JAXB databinding extension.
+
+Whilst this package and its subpackages are not currently deemed to represent extension developers SPI, this extension has a special relationship with binding-atom-runtime. binding-atom-runtime can be viewed as a specialization of binding.http.
+
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
new file mode 100644
index 0000000000..1447ed4e7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
@@ -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 classes for the databindings
+org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;name=javax.xml.bind.JAXBElement
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..673e75d50c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -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.
+
+# Implementation classes for the transformers
+org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;source=javax.xml.bind.JAXBElement,target=org.w3c.dom.Node,weight=500
+org.apache.tuscany.sca.databinding.jaxb.Node2JAXB;source=org.w3c.dom.Node,target=javax.xml.bind.JAXBElement,weight=500
+org.apache.tuscany.sca.databinding.jaxb.Reader2JAXB;source=java.io.Reader,target=javax.xml.bind.JAXBElement,weight=510
+org.apache.tuscany.sca.databinding.jaxb.XMLStreamReader2JAXB;source=javax.xml.stream.XMLStreamReader,target=javax.xml.bind.JAXBElement,weight=490
+
+org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;source=java:complexType,target=org.w3c.dom.Node,weight=90000
+org.apache.tuscany.sca.databinding.jaxb.Node2JAXB;source=org.w3c.dom.Node,target=java:complexType,weight=90000
+
+org.apache.tuscany.sca.databinding.jaxb.Node2JAXB;source=org.w3c.dom.Node,target=java:simpleType,weight=90000
+org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;source=java:simpleType,target=org.w3c.dom.Node,weight=90000
+
+org.apache.tuscany.sca.databinding.jaxb.XMLStreamReader2JAXB;source=javax.xml.stream.XMLStreamReader,target=java:complexType,weight=90000
+org.apache.tuscany.sca.databinding.jaxb.XMLStreamReader2JAXB;source=javax.xml.stream.XMLStreamReader,target=java:simpleType,weight=90000
+
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint
new file mode 100644
index 0000000000..b8d185b468
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.databinding.jaxb.DefaultXMLAdapterExtensionPoint
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/com/example/stock/StockQuoteOffer.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/com/example/stock/StockQuoteOffer.java
new file mode 100644
index 0000000000..5c5c892f33
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/com/example/stock/StockQuoteOffer.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.example.stock;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"input"})
+@XmlRootElement(name = "stockQuoteOffer")
+public class StockQuoteOffer {
+
+ protected String input;
+
+ public String getInput() {
+ return this.input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java
new file mode 100644
index 0000000000..9dd5892f7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.common.java.collection.LRUCache;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.example.ipo.jaxb.Address;
+import com.example.ipo.jaxb.PurchaseOrderType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JAXBContextCacheTestCase {
+ @Test
+ public void testCache() throws JAXBException {
+ JAXBContextCache cache = new JAXBContextCache(new DefaultExtensionPointRegistry());
+ JAXBContext context1 = cache.getJAXBContext(String.class);
+ JAXBContext context2 = cache.getJAXBContext(int.class);
+ JAXBContext context3 = cache.getJAXBContext(String[].class);
+ JAXBContext context4 = cache.getJAXBContext(Source.class);
+ Assert.assertSame(context1, context2);
+ Assert.assertNotSame(context2, context3);
+ Assert.assertSame(context1, context4);
+
+ QName name = new QName("http://example.com/ns1", "e1");
+ JAXBElement<String> element = new JAXBElement<String>(name, String.class, "123");
+ StringWriter sw = new StringWriter();
+ context4.createMarshaller().marshal(element, sw);
+ StreamSource source = new StreamSource(new StringReader(sw.toString()), null);
+ context4.createUnmarshaller().unmarshal(source, String.class);
+
+ JAXBContext context5 = cache.getJAXBContext(Address.class);
+ JAXBContext context6 = cache.getJAXBContext(PurchaseOrderType.class);
+ Assert.assertSame(context5, context6);
+ }
+
+ @Test
+ public void testLRUCache() {
+ LRUCache<String, String> cache = new LRUCache<String, String>(3);
+ cache.put("1", "A");
+ Assert.assertEquals(1, cache.size());
+ cache.put("2", "B");
+ Assert.assertEquals(2, cache.size());
+ cache.put("3", "C");
+ Assert.assertEquals(3, cache.size());
+ cache.put("4", "D");
+ Assert.assertEquals(3, cache.size());
+ String data = cache.get("1");
+ Assert.assertNull(data);
+ data = cache.get("2");
+ Assert.assertEquals("B", data);
+ cache.put("5", "E");
+ data = cache.get("2");
+ Assert.assertEquals("B", data);
+ }
+
+ @Test
+ public void testPerf() throws JAXBException {
+ JAXBContextCache cache = new JAXBContextCache(new DefaultExtensionPointRegistry());
+
+ // Test JAXBContext for simple java classes
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < 100; i++) {
+ JAXBContext context = JAXBContext.newInstance(String.class);
+ }
+ long end = System.currentTimeMillis();
+ long d1 = end - start;
+ start = System.currentTimeMillis();
+ for (int i = 0; i < 100; i++) {
+ JAXBContext context = cache.getJAXBContext(String.class);
+ }
+ end = System.currentTimeMillis();
+ long d2 = end - start;
+ System.out.println(d1 + "ms vs. " + d2 + "ms");
+
+ // Test JAXBContext for generated JAXB classes
+ start = System.currentTimeMillis();
+ for (int i = 0; i < 20; i++) {
+ JAXBContext context = JAXBContext.newInstance(PurchaseOrderType.class);
+ }
+ end = System.currentTimeMillis();
+ d1 = end - start;
+ start = System.currentTimeMillis();
+ for (int i = 0; i < 20; i++) {
+ JAXBContext context = cache.getJAXBContext(PurchaseOrderType.class);
+ }
+ end = System.currentTimeMillis();
+ d2 = end - start;
+ System.out.println(d1 + "ms vs. " + d2 + "ms");
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBindingTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBindingTestCase.java
new file mode 100644
index 0000000000..ec414641c6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBindingTestCase.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.example.ipo.jaxb.ObjectFactory;
+import com.example.ipo.jaxb.PurchaseOrderType;
+import com.example.ipo.jaxb.USAddress;
+import com.example.ipo.jaxb.USState;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXBDataBindingTestCase {
+ private JAXBDataBinding binding;
+
+ @Before
+ public void setUp() throws Exception {
+ binding = new JAXBDataBinding(new DefaultExtensionPointRegistry());
+ }
+
+ /**
+ * Test method for
+ * {@link org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding#introspect(java.lang.Class, Operation)}.
+ */
+ @Test
+ public final void testIntrospect() {
+ DataType dataType = new DataTypeImpl<Class>(JAXBElement.class, null);
+ Operation op = null;
+ boolean yes = binding.introspect(dataType, op);
+ assertTrue(yes);
+ assertTrue(dataType.getDataBinding().equals(binding.getName()));
+ assertTrue(dataType.getPhysical() == JAXBElement.class && dataType.getLogical() == XMLType.UNKNOWN);
+ dataType = new DataTypeImpl<Class>(MockJAXBElement.class, null);
+ yes = binding.introspect(dataType, op);
+ assertTrue(yes);
+ assertEquals(MockJAXBElement.class, dataType.getPhysical());
+ assertEquals(new QName("http://www.example.com/IPO", "PurchaseOrderType"), ((XMLType)dataType.getLogical())
+ .getTypeName());
+ dataType = new DataTypeImpl<Class>(USAddress.class, null);
+ yes = binding.introspect(dataType, op);
+ assertTrue(yes);
+ assertEquals(USAddress.class, dataType.getPhysical());
+ assertEquals(new QName("http://www.example.com/IPO", "USAddress"), ((XMLType)dataType.getLogical())
+ .getTypeName());
+ dataType = new DataTypeImpl<Class>(USState.class, null);
+ yes = binding.introspect(dataType, op);
+ assertTrue(yes);
+ assertTrue(dataType.getDataBinding().equals(binding.getName()));
+ assertEquals(USState.class, dataType.getPhysical());
+ assertEquals(new QName("http://www.example.com/IPO", "USState"), ((XMLType)dataType.getLogical()).getTypeName());
+
+ }
+
+ private static class MockJAXBElement extends JAXBElement<PurchaseOrderType> {
+
+ private static final long serialVersionUID = -2767569071002707973L;
+
+ /**
+ * @param elementName
+ * @param type
+ * @param value
+ */
+ public MockJAXBElement(QName elementName, Class<PurchaseOrderType> type, PurchaseOrderType value) {
+ super(elementName, type, value);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testCopy() {
+ ObjectFactory factory = new ObjectFactory();
+ PurchaseOrderType poType = factory.createPurchaseOrderType();
+ JAXBElement<PurchaseOrderType> po = factory.createPurchaseOrder(poType);
+ JAXBElement<PurchaseOrderType> copy = (JAXBElement<PurchaseOrderType>)binding.copy(po, null, null, null, null);
+ assertEquals(new QName("http://www.example.com/IPO", "purchaseOrder"), copy.getName());
+ }
+
+ @Test
+ public void testCopyNonElement() {
+ ObjectFactory factory = new ObjectFactory();
+ PurchaseOrderType poType = factory.createPurchaseOrderType();
+ poType.setComment("Comment");
+ PurchaseOrderType copy = (PurchaseOrderType)binding.copy(poType, null, null, null, null);
+ assertTrue(copy instanceof PurchaseOrderType);
+ assertEquals("Comment", (copy).getComment());
+ }
+
+ @Test
+ public void testCopyNonRoot() {
+ ObjectFactory factory = new ObjectFactory();
+ USAddress address = factory.createUSAddress();
+ address.setCity("San Jose");
+ USAddress copy = (USAddress)binding.copy(address, null, null, null, null);
+ assertTrue(copy instanceof USAddress);
+ assertEquals("San Jose", (copy).getCity());
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBReflectionTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBReflectionTestCase.java
new file mode 100644
index 0000000000..f5cff68969
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBReflectionTestCase.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.sca.databinding.jaxb;
+
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JAXBReflectionTestCase {
+
+ @Test
+ public void testGenerateSchema() throws Exception {
+ JAXBContext context = JAXBContext.newInstance("com.example.ipo.jaxb");
+ Map<String, String> schemas = JAXBTypeHelper.generateSchema(context);
+ System.out.println(schemas);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java
new file mode 100644
index 0000000000..6e2a540ada
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Node;
+
+import com.example.ipo.jaxb.ObjectFactory;
+import com.example.ipo.jaxb.PurchaseOrderType;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXBTestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private static ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+
+ @Test
+ public void testTransform() throws Exception {
+ Reader2JAXB t0 = new Reader2JAXB(registry);
+
+ DataType targetDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
+
+ TransformationContext tContext = new TransformationContextImpl();
+ tContext.setTargetDataType(targetDataType);
+
+ Object object1 = t0.transform(new StringReader(IPO_XML), tContext);
+
+ DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
+
+ TransformationContext tContext1 = new TransformationContextImpl();
+ tContext1.setSourceDataType(sourceDataType);
+
+ JAXB2Node t1 = new JAXB2Node(registry);
+ Node node = t1.transform(object1, tContext1);
+
+ Assert.assertNotNull(node);
+
+ Node2JAXB t2 = new Node2JAXB(registry);
+ Object object2 = t2.transform(node, tContext);
+ Assert.assertNotNull(object2);
+
+ }
+
+ @Test
+ public void testTransform2() throws Exception {
+ Reader2JAXB t0 = new Reader2JAXB(registry);
+
+ QName root = new QName("http://www.example.com/IPO", "purchaseOrder");
+ DataType targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
+ // targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
+
+ TransformationContext tContext = new TransformationContextImpl();
+ tContext.setTargetDataType(targetDataType);
+ Object object1 = t0.transform(new StringReader(IPO_XML), tContext);
+
+ DataType sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
+ // sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
+
+ TransformationContext tContext1 = new TransformationContextImpl();
+ tContext1.setSourceDataType(sourceDataType);
+
+ JAXB2Node t1 = new JAXB2Node(registry);
+ Node node = t1.transform(object1, tContext1);
+
+ Assert.assertNotNull(node);
+
+ Node2JAXB t2 = new Node2JAXB(registry);
+ Object object2 = t2.transform(node, tContext);
+ Assert.assertNotNull(object2);
+
+ }
+
+ @Test
+ public void testTransform3() throws Exception {
+
+ DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
+
+ TransformationContext tContext1 = new TransformationContextImpl();
+ tContext1.setSourceDataType(sourceDataType);
+
+
+ JAXB2Node t1 = new JAXB2Node(registry);
+ PurchaseOrderType po = new ObjectFactory().createPurchaseOrderType();
+ Node node = t1.transform(po, tContext1);
+
+ Assert.assertNotNull(node);
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java
new file mode 100644
index 0000000000..6037212e5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.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.databinding.jaxb;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.example.stock.StockQuoteOffer;
+
+/**
+ * Test case for JAXBExceptionHandler
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXBWrapperHandlerTestCase {
+ private static final QName ELEMENT = new QName("http://www.example.com/stock", "stockQuoteOffer");
+ private static final QName INPUT = new QName("", "input");
+ private JAXBWrapperHandler handler;
+
+ @Before
+ public void setUp() throws Exception {
+ this.handler = new JAXBWrapperHandler();
+ }
+
+ @Test
+ public void testCreate() {
+ ElementInfo element = new ElementInfo(ELEMENT, null);
+ Operation op = new OperationImpl();
+ WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, element, null, null, null);
+ wrapperInfo.setInputWrapperType(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, StockQuoteOffer.class,
+ XMLType.UNKNOWN));
+ op.setWrapper(wrapperInfo);
+ Object offer = handler.create(op, true);
+ Assert.assertTrue(offer instanceof StockQuoteOffer);
+ }
+
+ @Test
+ public void testSetChild() {
+ StockQuoteOffer wrapper = new StockQuoteOffer();
+ handler.setChild(wrapper, 0, new ElementInfo(INPUT, null), "IBM");
+ Assert.assertEquals("IBM", wrapper.getInput());
+ }
+
+ @Test
+ public void testGetChildren() {
+ StockQuoteOffer wrapper = new StockQuoteOffer();
+ wrapper.setInput("IBM");
+ List<ElementInfo> elements = new ArrayList<ElementInfo>();
+ elements.add(new ElementInfo(INPUT, null));
+ WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, null, null, elements, null);
+ Operation op = new OperationImpl();
+ op.setWrapper(wrapperInfo);
+ List children = handler.getChildren(wrapper, op, true);
+ assertNotNull(children);
+ assertEquals(1, children.size());
+ assertEquals("IBM", children.get(0));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyBean.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyBean.java
new file mode 100644
index 0000000000..9bdfb108fe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyBean.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class MyBean {
+ private int age;
+ private String name;
+ private float[] rates = new float[] {1.0f, 2.0f};
+ private List<String> notes = new ArrayList<String>();
+ private Map<String, Integer> map = new HashMap<String, Integer>();
+ private Object service;
+ private Object otherService;
+ private boolean good;
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<String> getNotes() {
+ return notes;
+ }
+
+ public void setNotes(List<String> notes) {
+ this.notes = notes;
+ }
+
+ public float[] getRates() {
+ return rates;
+ }
+
+ public void setRates(float[] rates) {
+ this.rates = rates;
+ }
+
+ public Map<String, Integer> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, Integer> map) {
+ this.map = map;
+ }
+
+ public Object getService() {
+ return service;
+ }
+
+ public void setService(Object service) {
+ this.service = service;
+ }
+
+ public Object getOtherService() {
+ return otherService;
+ }
+
+ public void setOtherService(Object otherService) {
+ this.otherService = otherService;
+ }
+
+ public boolean isGood() {
+ return good;
+ }
+
+ public void setGood(boolean good) {
+ this.good = good;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + age;
+ result = prime * result + (good ? 1231 : 1237);
+ result = prime * result + ((map == null) ? 0 : map.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((notes == null) ? 0 : notes.hashCode());
+ result = prime * result + ((otherService == null) ? 0 : otherService.hashCode());
+ result = prime * result + Arrays.hashCode(rates);
+ result = prime * result + ((service == null) ? 0 : service.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final MyBean other = (MyBean)obj;
+ if (age != other.age)
+ return false;
+ if (good != other.good)
+ return false;
+ if (map == null) {
+ if (other.map != null)
+ return false;
+ } else if (!map.equals(other.map))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (notes == null) {
+ if (other.notes != null)
+ return false;
+ } else if (!notes.equals(other.notes))
+ return false;
+ if (otherService == null) {
+ if (other.otherService != null)
+ return false;
+ } else if (!otherService.equals(other.otherService))
+ return false;
+ if (!Arrays.equals(rates, other.rates))
+ return false;
+ if (service == null) {
+ if (other.service != null)
+ return false;
+ } else if (!service.equals(other.service))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterface.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterface.java
new file mode 100644
index 0000000000..b8e9ee7f7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterface.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface MyInterface {
+ void setId(String id);
+
+ String getId();
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterfaceImpl.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterfaceImpl.java
new file mode 100644
index 0000000000..5c511e6ccb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterfaceImpl.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.jaxb;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MyInterfaceImpl implements MyInterface {
+ private String id;
+
+ /**
+ * @see org.apache.tuscany.databinding.jaxb.MyInterface#getId()
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @see org.apache.tuscany.databinding.jaxb.MyInterface#setId(java.lang.String)
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final MyInterfaceImpl other = (MyInterfaceImpl)obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyJaxbBean.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyJaxbBean.java
new file mode 100644
index 0000000000..3c3992524a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyJaxbBean.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.w3c.dom.Element;
+
+/**
+ *
+ */
+@XmlRootElement(name = "myBean", namespace = "http://ns1")
+public class MyJaxbBean {
+ public MyBean myBean;
+
+ @XmlJavaTypeAdapter(AnyTypeXmlAdapter.class)
+ public MyInterface myInterface;
+
+ @XmlElement(type = MyInterfaceImpl.class)
+ public MyInterface myInterface1;
+
+ @XmlJavaTypeAdapter(MyInterfaceAdapter.class)
+ public MyInterface myInterface2;
+
+ public Object myObject;
+
+ @XmlAnyElement
+ public Element anyElement;
+
+ public static class MyInterfaceAdapter extends XmlAdapter<MyInterfaceImpl, MyInterface> {
+
+ @Override
+ public MyInterfaceImpl marshal(MyInterface v) throws Exception {
+ return (MyInterfaceImpl) v;
+ }
+
+ @Override
+ public MyInterface unmarshal(MyInterfaceImpl v) throws Exception {
+ return (MyInterface) v;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MySubBean.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MySubBean.java
new file mode 100644
index 0000000000..62dfa6f73c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MySubBean.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 org.apache.tuscany.sca.databinding.jaxb;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MySubBean extends MyBean {
+ private String addtional;
+
+ public String getAddtional() {
+ return addtional;
+ }
+
+ public void setAddtional(String addtional) {
+ this.addtional = addtional;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java
new file mode 100644
index 0000000000..98aefed546
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.jaxb;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Test;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class POJOTestCase {
+
+ @Test
+ public void testAdapter() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(MyJaxbBean.class, MyInterfaceImpl.class);
+ StringWriter writer = new StringWriter();
+ MyJaxbBean bean = new MyJaxbBean();
+ bean.myBean = new MySubBean();
+ bean.myBean.setName("Ray");
+ bean.myInterface = new MyInterfaceImpl();
+ bean.myInterface.setId("001");
+ bean.myObject = new MyBean();
+ ((MyBean) bean.myObject).setName("Y");
+ context.createMarshaller().marshal(bean, writer);
+ System.out.println(writer.toString());
+ Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
+ assertTrue(result instanceof MyJaxbBean);
+ Map<String, String> schemas = JAXBTypeHelper.generateSchema(context);
+ System.out.println(schemas);
+ }
+
+ @Test
+ public void testPOJO() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(MyBean.class, MyInterfaceImpl.class);
+ StringWriter writer = new StringWriter();
+ MyBean bean = new MyBean();
+ bean.setName("Test");
+ bean.setAge(20);
+ bean.getNotes().add("1");
+ bean.getNotes().add("2");
+ bean.getMap().put("1", 1);
+ MyInterface service = new MyInterfaceImpl();
+ service.setId("ID001");
+ bean.setService(service);
+ bean.setOtherService(service);
+ JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, bean);
+ context.createMarshaller().marshal(element, writer);
+ // System.out.println(writer.toString());
+
+ Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertTrue(e2.getValue() instanceof MyBean);
+ MyBean newBean = (MyBean)e2.getValue();
+ assertEquals(bean, newBean);
+ }
+
+ @Test
+ public void testPOJOArray() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(MyBean[].class, MySubBean.class);
+ StringWriter writer = new StringWriter();
+ MySubBean bean = new MySubBean();
+ bean.setAddtional("SUB");
+ bean.setName("Test");
+ bean.setAge(20);
+ bean.getNotes().add("1");
+ bean.getNotes().add("2");
+ bean.getMap().put("1", 1);
+
+ JAXBElement<Object> element =
+ new JAXBElement<Object>(new QName("http://ns1", "beans"), Object.class, new MyBean[] {bean});
+ context.createMarshaller().marshal(element, writer);
+ System.out.println(writer.toString());
+
+ Object result =
+ context.createUnmarshaller().unmarshal(new StreamSource(new StringReader(writer.toString())),
+ MyBean[].class);
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertTrue(e2.getValue() instanceof MyBean[]);
+ MyBean newBean = ((MyBean[])e2.getValue())[0];
+ assertTrue(newBean instanceof MySubBean);
+ }
+
+ /*
+ public void testXMLStreamReader() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(MyBean.class, MyInterfaceImpl.class);
+
+ MyBean bean = new MyBean();
+ bean.setName("Test");
+ bean.setAge(20);
+ bean.getNotes().add("1");
+ bean.getNotes().add("2");
+ bean.getMap().put("1", 1);
+ MyInterface service = new MyInterfaceImpl();
+ service.setId("ID001");
+ bean.setService(service);
+ bean.setOtherService(service);
+ QName name = new QName("http://ns1", "bean");
+ JAXBElement<Object> element = new JAXBElement<Object>(name, Object.class, bean);
+ TransformationContext tContext = new TransformationContextImpl();
+ XMLStreamReader reader = new JAXB2XMLStreamReader().transform(element, tContext);
+
+// XMLStreamReader2String t2 = new XMLStreamReader2String();
+// String xml = t2.transform(reader, null);
+ // System.out.println(xml);
+ Object result = context.createUnmarshaller().unmarshal(reader, MyBean.class);
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertTrue(e2.getValue() instanceof MyBean);
+ MyBean newBean = (MyBean)e2.getValue();
+ // FIXME :To be implemented
+ // assertEquals(bean, newBean);
+ }
+ */
+
+ @Test
+ public void testString() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(String.class);
+ StringWriter writer = new StringWriter();
+ JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, "ABC");
+ context.createMarshaller().marshal(element, writer);
+ // System.out.println(writer.toString());
+
+ Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertEquals("ABC", e2.getValue());
+ }
+
+ @Test
+ public void testNull() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(String.class);
+ StringWriter writer = new StringWriter();
+ JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, null);
+ element.setNil(true);
+ context.createMarshaller().marshal(element, writer);
+ // System.out.println(writer.toString());
+ StreamSource source = new StreamSource(new StringReader(writer.toString()));
+ Object result = context.createUnmarshaller().unmarshal(source, String.class);
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertNull(e2.getValue());
+ }
+
+ @Test
+ public void testArray() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(String[].class);
+ StringWriter writer = new StringWriter();
+ JAXBElement<Object> element =
+ new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, new String[] {"ABC", "123"});
+ context.createMarshaller().marshal(element, writer);
+ // System.out.println(writer.toString());
+
+ Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertTrue(e2.getValue() instanceof String[]);
+ }
+
+ @Test
+ public void testByteArray() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(byte[].class);
+ StringWriter writer = new StringWriter();
+ JAXBElement<Object> element =
+ new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, "ABC".getBytes());
+ context.createMarshaller().marshal(element, writer);
+ String xml = writer.toString();
+ assertTrue(xml.contains("QUJD"));
+ assertTrue(xml.contains("base64Binary"));
+
+ Object result = context.createUnmarshaller().unmarshal(new StringReader(xml));
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertTrue(e2.getValue() instanceof byte[]);
+ }
+
+ @Test
+ public void testPrimitive() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(int.class);
+ StringWriter writer = new StringWriter();
+ JAXBElement<Integer> element = new JAXBElement<Integer>(new QName("http://ns1", "bean"), Integer.class, 1);
+ context.createMarshaller().marshal(element, writer);
+ // System.out.println(writer.toString());
+
+ StreamSource source = new StreamSource(new StringReader(writer.toString()));
+ Object result = context.createUnmarshaller().unmarshal(source, int.class);
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertEquals(1, e2.getValue());
+ }
+
+ /*
+ public void testException() throws Exception {
+ JAXBContext context = JAXBContext.newInstance(IllegalArgumentException.class);
+ StringWriter writer = new StringWriter();
+ Exception e = new IllegalArgumentException("123");
+ JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, e);
+ context.createMarshaller().marshal(element, writer);
+ System.out.println(writer.toString());
+
+ Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
+ assertTrue(result instanceof JAXBElement);
+ JAXBElement e2 = (JAXBElement)result;
+ assertTrue(e2.getValue() instanceof Exception);
+ }
+ */
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/resources/ipo.xsd b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..04e8cb44f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-jaxb/src/test/resources/ipo.xsd
@@ -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.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <element name="note" type="ipo:Note" />
+ <complexType name="Note" mixed="true">
+ <sequence>
+ <any namespace="##any" processContents="lax" minOccurs="0"/>
+ </sequence>
+ <anyAttribute/>
+ </complexType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/LICENSE b/sandbox/sebastien/java/embed/modules/databinding-json/LICENSE
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/LICENSE
@@ -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/sebastien/java/embed/modules/databinding-json/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/databinding-json/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..42674a55f8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/META-INF/MANIFEST.MF
@@ -0,0 +1,37 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.databinding.json;version="2.0.0",
+ org.apache.tuscany.sca.databinding.json.axiom;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data Binding for JSON
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data Binding for JSON
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om,
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.codehaus.jackson,
+ org.codehaus.jackson.map,
+ org.codehaus.jackson.map.introspect,
+ org.codehaus.jackson.map.type,
+ org.codehaus.jackson.type,
+ org.codehaus.jackson.xc;resolution:=optional,
+ org.codehaus.jettison.badgerfish,
+ org.codehaus.jettison.json,
+ org.codehaus.jettison.mapped,
+ org.jabsorb,
+ org.jabsorb.serializer,
+ org.json,
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding.json
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/NOTICE b/sandbox/sebastien/java/embed/modules/databinding-json/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/pom.xml b/sandbox/sebastien/java/embed/modules/databinding-json/pom.xml
new file mode 100644
index 0000000000..c81d554cfc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/pom.xml
@@ -0,0 +1,140 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <name>Apache Tuscany SCA Data Binding for JSON</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-xc</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jabsorb</groupId>
+ <artifactId>jabsorb</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.8</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2JavaBean.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2JavaBean.java
new file mode 100644
index 0000000000..a9edc66ae8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2JavaBean.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.json;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.jabsorb.JSONSerializer;
+import org.jabsorb.serializer.SerializerState;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSON2JavaBean implements PullTransformer<Object, Object> {
+ private JSONSerializer serializer;
+
+ public JSON2JavaBean() {
+ super();
+ serializer = new JSONSerializer();
+ try {
+ serializer.registerDefaultSerializers();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ serializer.setMarshallClassHints(true);
+ serializer.setMarshallNullAttributes(true);
+ }
+
+ public Object transform(Object source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+
+ try {
+ SerializerState state = new SerializerState();
+ return serializer.unmarshall(state, context.getTargetDataType().getPhysical(), source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+
+ }
+
+ public String getSourceDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+ public String getTargetDataBinding() {
+ return JavaBeansDataBinding.NAME;
+ }
+
+ public int getWeight() {
+ return 5000;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2String.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2String.java
new file mode 100644
index 0000000000..4577e7260e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2String.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.sca.databinding.json;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSON2String extends BaseTransformer<Object, String> implements
+ PullTransformer<Object, String> {
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ protected Class<String> getTargetType() {
+ return String.class;
+ }
+
+ public String transform(Object source, TransformationContext context) {
+ try {
+ return source.toString();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public int getWeight() {
+ return 500;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2XMLStreamReader.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2XMLStreamReader.java
new file mode 100644
index 0000000000..4989f59143
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2XMLStreamReader.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.sca.databinding.json;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.codehaus.jettison.badgerfish.BadgerFishXMLStreamReader;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSON2XMLStreamReader extends BaseTransformer<Object, XMLStreamReader> implements
+ PullTransformer<Object, XMLStreamReader> {
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ public XMLStreamReader transform(Object source, TransformationContext context) {
+ try {
+ JSONObject json = JSONHelper.toJettison(source);
+ return new BadgerFishXMLStreamReader(json);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public int getWeight() {
+ return 500;
+ }
+ @Override
+ public String getSourceDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java
new file mode 100644
index 0000000000..1557c90bce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.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.databinding.json;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * JAXB DataBinding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONDataBinding extends BaseDataBinding {
+ public static final String NAME = "JSON";
+
+ public static final String ROOT_NAMESPACE = "http://tuscany.apache.org/xmlns/sca/databinding/json/1.0";
+ public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "root");
+
+ public JSONDataBinding() {
+ super(NAME, org.json.JSONObject.class);
+ }
+
+ @Override
+ public boolean introspect(DataType type, Operation operation) {
+ assert type != null;
+ Class cls = type.getPhysical();
+ if (JSONObject.class.isAssignableFrom(cls) || org.json.JSONObject.class.isAssignableFrom(cls)) {
+ type.setDataBinding(getName());
+ if (type.getLogical() == null) {
+ type.setLogical(XMLType.UNKNOWN);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object copy(Object arg,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ if (arg == null) {
+ return null;
+ }
+ try {
+ Class type = arg != null ? arg.getClass() : null;
+ return JSONHelper.toJSON(arg.toString(), type);
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java
new file mode 100644
index 0000000000..028690a789
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json;
+
+import java.util.Collection;
+
+import org.apache.tuscany.sca.databinding.json.jackson.JacksonHelper;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.json.JSONArray;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSONHelper {
+ private JSONHelper() {
+
+ }
+
+ /**
+ * Convert to Jettison JSONObject
+ * @param source
+ * @return
+ */
+ public static JSONObject toJettison(Object source) {
+ JSONObject json = null;
+ if (source instanceof JSONObject) {
+ json = (JSONObject)source;
+ } else if (source instanceof org.json.JSONObject || source instanceof String) {
+ json = stringToJettision(source.toString());
+ } else if (source instanceof JsonNode) {
+ json = stringToJettision(JacksonHelper.toString((JsonNode)source));
+ } else if (source instanceof JsonParser) {
+ json = stringToJettision(JacksonHelper.toString((JsonParser)source));
+ }
+ return json;
+ }
+
+ private static JSONObject stringToJettision(String content) {
+ try {
+ return new JSONObject(content);
+ } catch (JSONException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Convert to org.json.JSONObject
+ * @param source
+ * @return
+ */
+ public static org.json.JSONObject toJSONOrg(Object source) {
+ org.json.JSONObject json = null;
+ if (source instanceof JSONObject) {
+ try {
+ json = new org.json.JSONObject(((JSONObject)source).toString());
+ } catch (org.json.JSONException e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else if (source instanceof org.json.JSONObject) {
+ json = (org.json.JSONObject)source;
+ }
+ return json;
+ }
+
+ public static Object toJSON(String json, Class<?> type) {
+ if (type == JSONObject.class) {
+ try {
+ return new JSONObject(json);
+ } catch (JSONException e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ if (type == null) {
+ type = org.json.JSONObject.class;
+ }
+ try {
+ if (type == JSONArray.class || type.isArray() || Collection.class.isAssignableFrom(type)) {
+ return new JSONArray(json);
+ }
+ return new org.json.JSONObject(json);
+ } catch (org.json.JSONException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSON.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSON.java
new file mode 100644
index 0000000000..17ed06298e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSON.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.sca.databinding.json;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.jabsorb.JSONSerializer;
+import org.jabsorb.serializer.SerializerState;
+
+public class JavaBean2JSON extends BaseTransformer<Object, Object> implements PullTransformer<Object, Object> {
+ private JSONSerializer serializer;
+
+ public JavaBean2JSON() {
+ serializer = new JSONSerializer();
+ try {
+ serializer.registerDefaultSerializers();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ serializer.setMarshallClassHints(true);
+ serializer.setMarshallNullAttributes(true);
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JavaBeansDataBinding.NAME;
+ }
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ public Object toJSON(Object source) throws Exception {
+ if (source == null) {
+ return org.json.JSONObject.NULL;
+ }
+
+ SerializerState state = new SerializerState();
+ return serializer.marshall(state, null, source, new Integer(0));
+ }
+
+ public Object transform(Object source, TransformationContext context) {
+ try {
+ return toJSON(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONObject.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONObject.java
new file mode 100644
index 0000000000..9ec3bd7e19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONObject.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONObject;
+
+public class JavaBean2JSONObject extends BaseTransformer<Object, Object> implements PullTransformer<Object, Object> {
+ private static final SimpleTypeMapper SIMPLE_TYPE_MAPPER = new SimpleTypeMapperImpl();
+
+ private static final Comparator<PropertyDescriptor> COMPARATOR = new Comparator<PropertyDescriptor>() {
+ public int compare(PropertyDescriptor o1, PropertyDescriptor o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ };
+
+ private static final SimpleTypeMapperImpl MAPPER = new SimpleTypeMapperImpl();
+ private static final Object[] NULL = null;
+
+ private static String getStringValue(Object o) {
+ if (o == null) {
+ return null;
+ }
+ TypeInfo info = SIMPLE_TYPE_MAPPER.getXMLType(o.getClass());
+ if (info != null) {
+ return MAPPER.toXMLLiteral(info.getQName(), o, null);
+ } else {
+ return String.valueOf(o);
+ }
+ }
+
+ private static boolean isSimpleType(Class<?> javaType) {
+ return SIMPLE_TYPE_MAPPER.getXMLType(javaType) != null;
+ }
+
+ public JavaBean2JSONObject() {
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JavaBeansDataBinding.NAME;
+ }
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ public Object toJSON(Object source) throws Exception {
+ if (source == null) {
+ return JSONObject.NULL;
+ }
+ Class<?> type = source.getClass();
+ if (isSimpleType(type)) {
+ return source;
+ } else if (type.isArray()) {
+ JSONArray array = new JSONArray();
+ int i1 = Array.getLength(source);
+ for (int j = 0; j < i1; j++) {
+ Object o = Array.get(source, j);
+ array.put(toJSON(o));
+ }
+ return array;
+ } else if (Collection.class.isAssignableFrom(type)) {
+ Collection c = (Collection)source;
+ JSONArray array = new JSONArray();
+ for (Object element : c) {
+ array.put(toJSON(element));
+ }
+ return array;
+ }
+ JSONObject json = new JSONObject();
+ BeanInfo beanInfo = Introspector.getBeanInfo(type);
+ PropertyDescriptor[] propDescs = beanInfo.getPropertyDescriptors();
+ Collections.sort(Arrays.asList(propDescs), COMPARATOR);
+
+ for (int i = 0; i < propDescs.length; i++) {
+ PropertyDescriptor propDesc = propDescs[i];
+ Class<?> pType = propDesc.getPropertyType();
+ if ("class".equals(propDesc.getName())) {
+ continue;
+ }
+ Object pValue = propDesc.getReadMethod().invoke(source, NULL);
+ json.put(propDesc.getName(), toJSON(pValue));
+ }
+ return json;
+
+ }
+
+ public Object transform(Object source, TransformationContext context) {
+ try {
+ return toJSON(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/String2JSON.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/String2JSON.java
new file mode 100644
index 0000000000..7d89927f51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/String2JSON.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class String2JSON extends BaseTransformer<String, Object> implements PullTransformer<String, Object> {
+
+ @Override
+ protected Class<String> getSourceType() {
+ return String.class;
+ }
+
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ public Object transform(String source, TransformationContext context) {
+ try {
+ Class type = null;
+ if (context != null && context.getTargetDataType() != null) {
+ type = context.getTargetDataType().getPhysical();
+ }
+ return JSONHelper.toJSON(source, type);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public int getWeight() {
+ return 500;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/XMLStreamReader2JSON.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/XMLStreamReader2JSON.java
new file mode 100644
index 0000000000..76ccc69c55
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/XMLStreamReader2JSON.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.databinding.json;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class XMLStreamReader2JSON extends BaseTransformer<XMLStreamReader, Object> implements
+ PullTransformer<XMLStreamReader, Object> {
+
+ private StAXHelper staxHelper;
+
+ public XMLStreamReader2JSON(ExtensionPointRegistry registry) {
+ staxHelper = StAXHelper.getInstance(registry);
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ public Object transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ StringWriter writer = new StringWriter();
+ XMLStreamWriter jsonWriter = new BadgerFishXMLStreamWriter(writer);
+ staxHelper.save(source, jsonWriter);
+ source.close();
+ Class type = null;
+ if (context != null && context.getTargetDataType() != null) {
+ type = context.getTargetDataType().getPhysical();
+ }
+ return JSONHelper.toJSON(writer.toString(), type);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public int getWeight() {
+ return 500;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSON2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSON2OMElement.java
new file mode 100644
index 0000000000..c7c9adc882
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSON2OMElement.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.json.axiom;
+
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.Transformer;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.apache.tuscany.sca.databinding.json.JSONHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.codehaus.jettison.json.JSONObject;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Service(Transformer.class)
+public class JSON2OMElement extends BaseTransformer<Object, OMElement> implements PullTransformer<Object, OMElement> {
+
+ private OMFactory factory = OMAbstractFactory.getOMFactory();
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ protected Class<OMElement> getTargetType() {
+ return OMElement.class;
+ }
+
+ public OMElement transform(Object source, TransformationContext context) {
+ try {
+ JSONObject json = JSONHelper.toJettison(source);
+ if (json == null) {
+ return null;
+ }
+ String ns = JSONDataBinding.ROOT_ELEMENT.getNamespaceURI();
+ String name = JSONDataBinding.ROOT_ELEMENT.getLocalPart();
+ if (context != null) {
+ DataType<?> dataType = context.getTargetDataType();
+ Object logical = dataType.getLogical();
+ if (logical instanceof XMLType) {
+ XMLType xmlType = (XMLType)logical;
+ if (xmlType.isElement()) {
+ ns = xmlType.getElementName().getNamespaceURI();
+ name = xmlType.getElementName().getLocalPart();
+ }
+ }
+ }
+ JSONBadgerfishDataSource ds = new JSONBadgerfishDataSource(json);
+ OMNamespace namespace = factory.createOMNamespace(ns, "");
+ return factory.createOMElement(ds, name, namespace);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public int getWeight() {
+ return 500;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONBadgerfishDataSource.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONBadgerfishDataSource.java
new file mode 100644
index 0000000000..adc38772be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONBadgerfishDataSource.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.databinding.json.axiom;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.codehaus.jettison.badgerfish.BadgerFishXMLStreamReader;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * JSONDataSource keeps the JSON String inside and consumes it when needed. This is to be kept in the
+ * OMSourcedElementImpl and can be used either to expand the tree or get the JSON String directly without expanding.
+ * This uses the "Badgerfish" JSON convention.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class JSONBadgerfishDataSource extends JSONDataSource {
+
+ public JSONBadgerfishDataSource(JSONObject json) {
+ super(json);
+ }
+
+ /**
+ * Gives the StAX reader using the "Badgerfish" formatted input JSON String.
+ *
+ * @return The XMLStreamReader according to the JSON String.
+ * @throws javax.xml.stream.XMLStreamException if there is an error while making the StAX reader.
+ */
+ @Override
+ public javax.xml.stream.XMLStreamReader getReader() throws XMLStreamException {
+ try {
+ return new BadgerFishXMLStreamReader(json);
+ } catch (JSONException e) {
+ throw new XMLStreamException(e);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONDataSource.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONDataSource.java
new file mode 100644
index 0000000000..5b0312056e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONDataSource.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json.axiom;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMOutputFormat;
+import org.codehaus.jettison.json.JSONObject;
+import org.codehaus.jettison.json.JSONTokener;
+import org.codehaus.jettison.mapped.MappedXMLInputFactory;
+
+/**
+ * JSONDataSource keeps the JSON String inside and consumes it when needed. This is to be kept in the
+ * OMSourcedElementImpl and can be used either to expand the tree or get the JSON String directly without expanding.
+ * This uses the "Mapped" JSON convention.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class JSONDataSource implements OMDataSource {
+ protected JSONObject json;
+
+ public JSONDataSource(JSONObject json) {
+ this.json = json;
+ }
+
+ /**
+ * Writes JSON into the output stream. As this should write JSON, it directly gets the JSON string and writes it
+ * without expanding the tree.
+ *
+ * @param outputStream the stream to be written into
+ * @param omOutputFormat format of the message, this is ignored.
+ * @throws javax.xml.stream.XMLStreamException if there is an error while writing the message in to the output
+ * stream.
+ */
+ public void serialize(OutputStream outputStream, OMOutputFormat omOutputFormat)
+ throws javax.xml.stream.XMLStreamException {
+ try {
+ String encoding = omOutputFormat == null ? "UTF-8" : omOutputFormat.getCharSetEncoding();
+ outputStream.write(getJSONString().getBytes(encoding));
+ } catch (IOException e) {
+ throw new OMException();
+ }
+ }
+
+ /**
+ * Writes JSON through the writer. As this should write JSON, it directly gets the JSON string and writes it without
+ * expanding the tree.
+ *
+ * @param writer Writer to be written into
+ * @param omOutputFormat format of the message, this is ignored.
+ * @throws javax.xml.stream.XMLStreamException if there is an error while writing the message through the writer.
+ */
+ public void serialize(Writer writer, OMOutputFormat omOutputFormat) throws javax.xml.stream.XMLStreamException {
+ try {
+ writer.write(getJSONString());
+ } catch (IOException e) {
+ throw new OMException();
+ }
+ }
+
+ /**
+ * Writes XML through the XMLStreamWriter. As the input data source is JSON, this method needs to get a StAX reader
+ * from that JSON String. Therefore this uses the getReader() method to get the StAX reader writes the events into
+ * the XMLStreamWriter.
+ *
+ * @param xmlStreamWriter StAX writer to be written into
+ * @throws javax.xml.stream.XMLStreamException if there is an error while writing the message through the StAX
+ * writer.
+ */
+ public void serialize(javax.xml.stream.XMLStreamWriter xmlStreamWriter) throws javax.xml.stream.XMLStreamException {
+ XMLStreamReader reader = getReader();
+ xmlStreamWriter.writeStartDocument();
+ while (reader.hasNext()) {
+ int x = reader.next();
+ switch (x) {
+ case XMLStreamConstants.START_ELEMENT:
+ xmlStreamWriter.writeStartElement(reader.getPrefix(), reader.getLocalName(), reader
+ .getNamespaceURI());
+ int namespaceCount = reader.getNamespaceCount();
+ for (int i = namespaceCount - 1; i >= 0; i--) {
+ xmlStreamWriter.writeNamespace(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
+ }
+ int attributeCount = reader.getAttributeCount();
+ for (int i = 0; i < attributeCount; i++) {
+ xmlStreamWriter.writeAttribute(reader.getAttributePrefix(i),
+ reader.getAttributeNamespace(i),
+ reader.getAttributeLocalName(i),
+ reader.getAttributeValue(i));
+ }
+ break;
+ case XMLStreamConstants.START_DOCUMENT:
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ xmlStreamWriter.writeCharacters(reader.getText());
+ break;
+ case XMLStreamConstants.CDATA:
+ xmlStreamWriter.writeCData(reader.getText());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ xmlStreamWriter.writeEndElement();
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ xmlStreamWriter.writeEndDocument();
+ break;
+ case XMLStreamConstants.SPACE:
+ break;
+ case XMLStreamConstants.COMMENT:
+ xmlStreamWriter.writeComment(reader.getText());
+ break;
+ case XMLStreamConstants.DTD:
+ xmlStreamWriter.writeDTD(reader.getText());
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ xmlStreamWriter.writeProcessingInstruction(reader.getPITarget(), reader.getPIData());
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ xmlStreamWriter.writeEntityRef(reader.getLocalName());
+ break;
+ default:
+ throw new OMException();
+ }
+ }
+ xmlStreamWriter.writeEndDocument();
+ }
+
+ /**
+ * Gives the StAX reader using the "Mapped" formatted input JSON String.
+ *
+ * @return The XMLStreamReader according to the JSON String.
+ * @throws javax.xml.stream.XMLStreamException if there is an error while making the StAX reader.
+ */
+
+ public javax.xml.stream.XMLStreamReader getReader() throws javax.xml.stream.XMLStreamException {
+
+ Map<String, String> nsMap = new HashMap<String, String>();
+ nsMap.put("", "");
+
+ // input factory for "Mapped" convention
+ MappedXMLInputFactory inputFactory = new MappedXMLInputFactory(nsMap);
+ String jsonString = this.getJSONString();
+ return inputFactory.createXMLStreamReader(new JSONTokener(jsonString));
+ }
+
+ // returns the json string by consuming the JSON input stream.
+ protected String getJSONString() {
+ return json.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/InputStream2JSON.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/InputStream2JSON.java
new file mode 100644
index 0000000000..57b9d55b44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/InputStream2JSON.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json.jackson;
+
+import java.io.InputStream;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+
+/**
+ *
+ */
+public class InputStream2JSON implements PullTransformer<InputStream, Object> {
+
+ public String getSourceDataBinding() {
+ return "application/json" + "#" + InputStream.class.getName();
+ }
+
+ public String getTargetDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+ public Object transform(InputStream source, TransformationContext context) {
+ return JacksonHelper.createJsonParser(source);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2Object.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2Object.java
new file mode 100644
index 0000000000..3620fc117f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2Object.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.sca.databinding.json.jackson;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.type.TypeFactory;
+import org.codehaus.jackson.type.JavaType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSON2Object implements PullTransformer<Object, Object> {
+ private ObjectMapper mapper;
+
+ public JSON2Object() {
+ super();
+ mapper = JacksonHelper.createObjectMapper();
+ }
+
+ public Object transform(Object source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+
+ try {
+ JavaType javaType = TypeFactory.type(context.getTargetDataType().getGenericType());
+ if (source instanceof String) {
+ return mapper.readValue((String)source, javaType);
+ } else if (source instanceof JsonNode) {
+ return mapper.treeToValue((JsonNode)source, context.getTargetDataType().getPhysical());
+ } else if (source instanceof JsonParser) {
+ return mapper.readValue((JsonParser)source, javaType);
+ } else {
+ return mapper.readValue(source.toString(), javaType);
+ }
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public String getSourceDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+ public String getTargetDataBinding() {
+ return JavaBeansDataBinding.NAME;
+ }
+
+ public int getWeight() {
+ return 5000;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2OutputStream.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2OutputStream.java
new file mode 100644
index 0000000000..920485a540
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2OutputStream.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.sca.databinding.json.jackson;
+
+import java.io.OutputStream;
+
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+
+/**
+ *
+ */
+public class JSON2OutputStream implements PushTransformer<Object, OutputStream> {
+
+ public String getSourceDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+ public String getTargetDataBinding() {
+ return "application/json" + "#" + OutputStream.class.getName();
+ }
+
+ public void transform(Object source, OutputStream sink, TransformationContext context) {
+ if (source == null) {
+ return;
+ }
+ if (source instanceof JsonNode) {
+ JacksonHelper.write((JsonNode)source, sink);
+ } else if (source instanceof JsonParser) {
+ JacksonHelper.write((JsonParser)source, sink);
+ } else {
+ try {
+ sink.write(source.toString().getBytes("UTF-8"));
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+ }
+
+ public int getWeight() {
+ return 50;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonHelper.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonHelper.java
new file mode 100644
index 0000000000..ae3bb8fd48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonHelper.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json.jackson;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+
+import org.codehaus.jackson.JsonEncoding;
+import org.codehaus.jackson.JsonFactory;
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.map.AnnotationIntrospector;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
+import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
+
+/**
+ *
+ */
+public class JacksonHelper {
+ public static ObjectMapper createObjectMapper() {
+ ObjectMapper mapper = new ObjectMapper();
+ AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
+ AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
+ AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
+ mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
+ // [rfeng] To avoid complaints about javaClass
+ mapper.getDeserializationConfig().set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
+ mapper.getSerializationConfig().setAnnotationIntrospector(pair);
+ return mapper;
+ }
+
+ public static String toString(JsonNode node) {
+ try {
+ JsonFactory jsonFactory = new JsonFactory();
+ StringWriter sw = new StringWriter();
+ JsonGenerator generator = jsonFactory.createJsonGenerator(sw);
+ generator.writeTree(node);
+ return sw.toString();
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static String toString(JsonParser parser) {
+ try {
+ JsonFactory jsonFactory = new JsonFactory();
+ StringWriter sw = new StringWriter();
+ JsonGenerator generator = jsonFactory.createJsonGenerator(sw);
+ JsonNode node = parser.readValueAs(JsonNode.class);
+ generator.writeTree(node);
+ return sw.toString();
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static JsonParser createJsonParser(String content) {
+ JsonFactory jsonFactory = new JsonFactory();
+ try {
+ return jsonFactory.createJsonParser(content);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static JsonParser createJsonParser(InputStream content) {
+ JsonFactory jsonFactory = new JsonFactory();
+ try {
+ return jsonFactory.createJsonParser(content);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static JsonParser createJsonParser(Reader content) {
+ JsonFactory jsonFactory = new JsonFactory();
+ try {
+ return jsonFactory.createJsonParser(content);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static void write(JsonNode node, OutputStream out) {
+ try {
+ JsonFactory jsonFactory = new JsonFactory();
+ JsonGenerator generator = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
+ generator.writeTree(node);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static void write(JsonParser parser, OutputStream out) {
+ try {
+ JsonFactory jsonFactory = new JsonFactory();
+ JsonGenerator generator = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
+ JsonNode node = parser.readValueAs(JsonNode.class);
+ generator.writeTree(node);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java
new file mode 100644
index 0000000000..0948341b76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.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.databinding.json.jackson;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.apache.tuscany.sca.databinding.json.JSONHelper;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.map.ObjectMapper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Object2JSON implements PullTransformer<Object, Object> {
+ private ObjectMapper mapper;
+
+ public Object2JSON() {
+ super();
+ mapper = JacksonHelper.createObjectMapper();
+ }
+
+ public Object transform(Object source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+
+ Class<?> targetType = null;
+ if (context != null && context.getTargetDataType() != null) {
+ targetType = context.getTargetDataType().getPhysical();
+ }
+ if (targetType == null) {
+ targetType = String.class;
+ }
+ try {
+ String value = mapper.writeValueAsString(source);
+ if (targetType == String.class || targetType == Object.class) {
+ return value;
+ } else if (JsonNode.class.isAssignableFrom(targetType)) {
+ return JacksonHelper.createJsonParser(value).readValueAsTree();
+ }
+ if (JsonParser.class.isAssignableFrom(targetType)) {
+ return JacksonHelper.createJsonParser(value);
+ } else {
+ return JSONHelper.toJSON(value, targetType);
+ }
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public String getSourceDataBinding() {
+ return JavaBeansDataBinding.NAME;
+ }
+
+ public String getTargetDataBinding() {
+ return JSONDataBinding.NAME;
+ }
+
+ public int getWeight() {
+ return 5000;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
new file mode 100644
index 0000000000..aec4184afa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
@@ -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 classes for the databindings
+org.apache.tuscany.sca.databinding.json.JSONDataBinding;name=JSON
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..3590a46c47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -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.
+
+# Implementation classes for the transformers
+org.apache.tuscany.sca.databinding.json.JSON2XMLStreamReader;source=JSON,target=javax.xml.stream.XMLStreamReader,weight=5000
+org.apache.tuscany.sca.databinding.json.XMLStreamReader2JSON;source=javax.xml.stream.XMLStreamReader,target=JSON,weight=5000,public=false
+org.apache.tuscany.sca.databinding.json.jackson.Object2JSON;source=java:complexType,target=JSON,weight=90000,public=true
+org.apache.tuscany.sca.databinding.json.jackson.Object2JSON;source=java:simpleType,target=JSON,weight=90000,public=false
+org.apache.tuscany.sca.databinding.json.axiom.JSON2OMElement;source=JSON,target=org.apache.axiom.om.OMElement,weight=500
+org.apache.tuscany.sca.databinding.json.jackson.Object2JSON;source=java:array,target=JSON,weight=90000,public=false
+org.apache.tuscany.sca.databinding.json.jackson.Object2JSON;source=commonj.sdo.DataObject,target=JSON,weight=90000,public=false
+org.apache.tuscany.sca.databinding.json.jackson.Object2JSON;source=javax.xml.bind.JAXBElement,target=JSON,weight=90000,public=false
+org.apache.tuscany.sca.databinding.json.jackson.JSON2Object;source=JSON,target=java:complexType,weight=90000,public=false
+org.apache.tuscany.sca.databinding.json.jackson.JSON2Object;source=JSON,target=java:simpleType,weight=90000,public=false
+org.apache.tuscany.sca.databinding.json.jackson.JSON2Object;source=JSON,target=commonj.sdo.DataObject,weight=90000,public=false
+org.apache.tuscany.sca.databinding.json.jackson.JSON2Object;source=JSON,target=javax.xml.bind.JAXBElement,weight=90000,public=false
+org.apache.tuscany.sca.databinding.json.jackson.JSON2Object;source=JSON,target=java:array,weight=90000,public=false
+
+org.apache.tuscany.sca.databinding.json.jackson.InputStream2JSON;source=application/json#java.io.InputStream;target=JSON,weight=50,public=true
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
new file mode 100644
index 0000000000..c3272d1425
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.databinding.json.jackson.JSON2OutputStream;source=JSON;target=application/json#java.io.OutputStream,weight=50,public=true
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.java
new file mode 100644
index 0000000000..1aa6cf3dab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.databinding.json.axiom.JSON2OMElement;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.json.JSONObject;
+import org.junit.Test;
+
+public class JSONTransformerTestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private static final String JSON_STR =
+ "{\"xsl:root\":{\"@xmlns\":{\"xsl\":\"http://foo.com\"},\"data\":{\"$\":\"my json string\"}}}";
+
+ @Test
+ public void testXML2JSON() throws Exception {
+ ExtensionPointRegistry extensionPointRegistry = new DefaultExtensionPointRegistry();
+ StAXHelper staxHelper = StAXHelper.getInstance(extensionPointRegistry);
+
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(new StringReader(IPO_XML));
+ XMLStreamReader2JSON t1 = new XMLStreamReader2JSON(extensionPointRegistry);
+ JSONObject json = (JSONObject)t1.transform(reader, null);
+ Assert.assertNotNull(json);
+
+ // Cannot round-trip as we hit a bug in Jettison: http://jira.codehaus.org/browse/JETTISON-93
+ /*
+ JSON2XMLStreamReader t2 = new JSON2XMLStreamReader();
+ XMLStreamReader reader2 = t2.transform(json, null);
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter streamWriter = staxHelper.createXMLStreamWriter(sw);
+ staxHelper.save(reader2, streamWriter);
+ streamWriter.flush();
+ System.out.println(sw.toString());
+ */
+
+ }
+
+ @Test
+ public void testJSON2XML() throws Exception {
+ ExtensionPointRegistry extensionPointRegistry = new DefaultExtensionPointRegistry();
+ StAXHelper helper = StAXHelper.getInstance(extensionPointRegistry);
+
+ JSON2XMLStreamReader t2 = new JSON2XMLStreamReader();
+ XMLStreamReader reader2 = t2.transform(new JSONObject(JSON_STR), null);
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(sw);
+ helper.save(reader2, streamWriter);
+ Assert.assertTrue(sw.toString()
+ .contains("<xsl:root xmlns:xsl=\"http://foo.com\"><data>my json string</data></xsl:root>"));
+ }
+
+ @Test
+ public void testJSON2OMElement() throws Exception {
+ JSON2OMElement t1 = new JSON2OMElement();
+ TransformationContext context = new TransformationContextImpl();
+ DataType dt = new DataTypeImpl(Object.class, new XMLType(new QName("http://foo.com", "root"), null));
+ context.setTargetDataType(dt);
+ OMElement element = t1.transform(new JSONObject(JSON_STR), context);
+ StringWriter writer = new StringWriter();
+ element.serialize(writer);
+ // System.out.println(writer.toString());
+ }
+
+ @Test
+ public void testString2JSON() throws Exception {
+ String json = "{\"name\":\"John\",\"age\":25}";
+ String2JSON t1 = new String2JSON();
+ JSONObject jsonObject = (JSONObject)t1.transform(json, null);
+ Assert.assertEquals(jsonObject.getString("name"), "John");
+ Assert.assertEquals(jsonObject.getInt("age"), 25);
+ JSON2String t2 = new JSON2String();
+ String str = t2.transform(jsonObject, null);
+ Assert.assertTrue(str.contains("\"name\":\"John\""));
+ Assert.assertTrue(str.contains("\"age\":25"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.java
new file mode 100644
index 0000000000..3b36f5be74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.json.JSONObject;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaBean2JSONTestCase {
+
+ public static class MyBean {
+ private String name;
+ private int age;
+ private boolean vip;
+ private String friends[];
+ private List<String> books;
+ private YourBean you;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public boolean isVip() {
+ return vip;
+ }
+
+ public void setVip(boolean vip) {
+ this.vip = vip;
+ }
+
+ public String[] getFriends() {
+ return friends;
+ }
+
+ public void setFriends(String[] friends) {
+ this.friends = friends;
+ }
+
+ public List<String> getBooks() {
+ return books;
+ }
+
+ public void setBooks(List<String> books) {
+ this.books = books;
+ }
+
+ public YourBean getYou() {
+ return you;
+ }
+
+ public void setYou(YourBean you) {
+ this.you = you;
+ }
+
+ }
+
+ public static class YourBean {
+ private int id;
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ @Test
+ public void testBean2JSON() throws Exception {
+ MyBean me = new MyBean();
+ me.setAge(30);
+ me.setBooks(new ArrayList<String>());
+ me.setFriends(new String[] {"John", "Mike"});
+ me.setVip(true);
+ me.setName("Me");
+ YourBean you = new YourBean();
+ you.setId(123);
+ you.setName(null);
+ me.setYou(you);
+ JavaBean2JSON t1 = new JavaBean2JSON();
+ Object result = t1.transform(me, null);
+ System.out.println(result);
+ JSON2JavaBean t2 = new JSON2JavaBean();
+ TransformationContext context = new TransformationContextImpl();
+ context.setTargetDataType(new DataTypeImpl(MyBean.class, null));
+ Object v = t2.transform(new JSONObject(result.toString()), context);
+ Assert.assertTrue(v instanceof MyBean);
+ // String json =
+ // "{\"age\":30,\"books\":[],\"friends\":[\"John\",\"Mike\"],\"name\":\"Me\",\"vip\":true,\"you\":{\"id\":123,\"name\":null}}";
+ // Assert.assertEquals(json, result.toString());
+ }
+
+ @Test
+ public void testString2JSON() throws Exception {
+ JavaBean2JSONObject t1 = new JavaBean2JSONObject();
+ Object result = t1.transform("ABC", null);
+ System.out.println(result);
+ JSON2JavaBean t2 = new JSON2JavaBean();
+ TransformationContext context = new TransformationContextImpl();
+ context.setTargetDataType(new DataTypeImpl(String.class, null));
+ Object v = t2.transform(result, context);
+ Assert.assertTrue(v instanceof String);
+ Assert.assertEquals("ABC", v);
+ }
+
+ @Test
+ public void testStringArray2JSON() throws Exception {
+ JavaBean2JSON t1 = new JavaBean2JSON();
+ Object result = t1.transform(new String[] {"ABC", "DF"}, null);
+ System.out.println(result);
+ JSON2JavaBean t2 = new JSON2JavaBean();
+ TransformationContext context = new TransformationContextImpl();
+ context.setTargetDataType(new DataTypeImpl(String[].class, null));
+ Object v = t2.transform(result, context);
+ Assert.assertTrue(v instanceof String[]);
+ String[] strs = (String[])v;
+ Assert.assertEquals("ABC", strs[0]);
+ Assert.assertEquals("DF", strs[1]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyBean.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyBean.java
new file mode 100644
index 0000000000..60b293c1d4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyBean.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MyBean {
+ private int age;
+ private String name;
+ private float[] rates = new float[] {1.0f, 2.0f};
+ private List<String> notes = new ArrayList<String>();
+ private Map<String, Integer> map = new HashMap<String, Integer>();
+ private Object service;
+ private Object otherService;
+ private boolean good;
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<String> getNotes() {
+ return notes;
+ }
+
+ public void setNotes(List<String> notes) {
+ this.notes = notes;
+ }
+
+ public float[] getRates() {
+ return rates;
+ }
+
+ public void setRates(float[] rates) {
+ this.rates = rates;
+ }
+
+ public Map<String, Integer> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, Integer> map) {
+ this.map = map;
+ }
+
+ public Object getService() {
+ return service;
+ }
+
+ public void setService(Object service) {
+ this.service = service;
+ }
+
+ public Object getOtherService() {
+ return otherService;
+ }
+
+ public void setOtherService(Object otherService) {
+ this.otherService = otherService;
+ }
+
+ public boolean isGood() {
+ return good;
+ }
+
+ public void setGood(boolean good) {
+ this.good = good;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + age;
+ result = prime * result + (good ? 1231 : 1237);
+ result = prime * result + ((map == null) ? 0 : map.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((notes == null) ? 0 : notes.hashCode());
+ result = prime * result + ((otherService == null) ? 0 : otherService.hashCode());
+ result = prime * result + Arrays.hashCode(rates);
+ result = prime * result + ((service == null) ? 0 : service.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final MyBean other = (MyBean)obj;
+ if (age != other.age)
+ return false;
+ if (good != other.good)
+ return false;
+ if (map == null) {
+ if (other.map != null)
+ return false;
+ } else if (!map.equals(other.map))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (notes == null) {
+ if (other.notes != null)
+ return false;
+ } else if (!notes.equals(other.notes))
+ return false;
+ if (otherService == null) {
+ if (other.otherService != null)
+ return false;
+ } else if (!otherService.equals(other.otherService))
+ return false;
+ if (!Arrays.equals(rates, other.rates))
+ return false;
+ if (service == null) {
+ if (other.service != null)
+ return false;
+ } else if (!service.equals(other.service))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterface.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterface.java
new file mode 100644
index 0000000000..d32e0763c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterface.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface MyInterface {
+ void setId(String id);
+
+ String getId();
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.java
new file mode 100644
index 0000000000..3a2b95a4e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.json;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MyInterfaceImpl implements MyInterface {
+ private String id;
+
+ /**
+ * @see org.apache.tuscany.databinding.jaxb.MyInterface#getId()
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @see org.apache.tuscany.databinding.jaxb.MyInterface#setId(java.lang.String)
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final MyInterfaceImpl other = (MyInterfaceImpl)obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java
new file mode 100644
index 0000000000..fd0557d0a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.json;
+
+import java.lang.reflect.Array;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.junit.Test;
+
+public class POJOTestCase {
+ public void testPOJO() throws Exception {
+ MyBean bean = new MyBean();
+ bean.setName("Test");
+ bean.setAge(20);
+ bean.getNotes().add("1");
+ bean.getNotes().add("2");
+ bean.getMap().put("1", 1);
+ MyInterface service = new MyInterfaceImpl();
+ service.setId("ID001");
+ bean.setService(service);
+ bean.setOtherService(service);
+
+ roundTrip(bean);
+ }
+
+ private <T> void roundTrip(T bean) {
+ JavaBean2JSON t1 = new JavaBean2JSON();
+
+ Object json = t1.transform(bean, null);
+ System.out.println(json);
+ JSON2JavaBean t2 = new JSON2JavaBean();
+
+ TransformationContext context = new TransformationContextImpl();
+ context.setTargetDataType(new DataTypeImpl(bean == null ? Object.class : bean.getClass(), null));
+ Object newBean = t2.transform(json, context);
+
+ if (newBean != null && newBean.getClass().isArray()) {
+ int len = Array.getLength(newBean);
+ Assert.assertEquals(Array.getLength(bean), len);
+ for (int i = 0; i < len; i++) {
+ Assert.assertEquals(Array.get(bean, i), Array.get(newBean, i));
+ }
+ return;
+ }
+ Assert.assertEquals(bean, newBean);
+ }
+
+ @Test
+ public void testString() throws Exception {
+ roundTrip("ABC");
+ }
+
+ @Test
+ public void testNull() throws Exception {
+ roundTrip(null);
+ }
+
+ @Test
+ public void testArray() throws Exception {
+ roundTrip(new String[] {"123", "ABC"});
+ }
+
+ @Test
+ public void testByteArray() throws Exception {
+ roundTrip("ABC".getBytes());
+ }
+
+ @Test
+ public void testPrimitive() throws Exception {
+ roundTrip(123);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonTestCase.java
new file mode 100644
index 0000000000..5254ca7742
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.json.jackson;
+
+import java.lang.reflect.Array;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.databinding.json.MyBean;
+import org.apache.tuscany.sca.databinding.json.MyInterface;
+import org.apache.tuscany.sca.databinding.json.MyInterfaceImpl;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.junit.Test;
+
+public class JacksonTestCase {
+ public void testPOJO() throws Exception {
+ MyBean bean = new MyBean();
+ bean.setName("Test");
+ bean.setAge(20);
+ bean.getNotes().add("1");
+ bean.getNotes().add("2");
+ bean.getMap().put("1", 1);
+ MyInterface service = new MyInterfaceImpl();
+ service.setId("ID001");
+ bean.setService(service);
+ bean.setOtherService(service);
+
+ roundTrip(bean);
+ }
+
+ private <T> void roundTrip(T bean) {
+ Object2JSON t1 = new Object2JSON();
+
+ Object json = t1.transform(bean, null);
+ System.out.println(json);
+ JSON2Object t2 = new JSON2Object();
+
+ TransformationContext context = new TransformationContextImpl();
+ context.setTargetDataType(new DataTypeImpl(bean == null ? Object.class : bean.getClass(), null));
+ Object newBean = t2.transform(json, context);
+
+ if (newBean != null && newBean.getClass().isArray()) {
+ int len = Array.getLength(newBean);
+ Assert.assertEquals(Array.getLength(bean), len);
+ for (int i = 0; i < len; i++) {
+ Assert.assertEquals(Array.get(bean, i), Array.get(newBean, i));
+ }
+ return;
+ }
+ Assert.assertEquals(bean, newBean);
+ }
+
+ @Test
+ public void testString() throws Exception {
+ roundTrip("ABC");
+ }
+
+ @Test
+ public void testNull() throws Exception {
+ roundTrip(null);
+ }
+
+ @Test
+ public void testArray() throws Exception {
+ roundTrip(new String[] {"123", "ABC"});
+ }
+
+ @Test
+ public void testByteArray() throws Exception {
+ roundTrip("ABC".getBytes());
+ }
+
+ @Test
+ public void testPrimitive() throws Exception {
+ roundTrip(123);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSONTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSONTestCase.java
new file mode 100644
index 0000000000..b401e7012d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSONTestCase.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.json.jackson;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Object2JSONTestCase {
+
+ public static class MyBean {
+ private String name;
+ private int age;
+ private boolean vip;
+ private String friends[];
+ private List<String> books;
+ private YourBean you;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public boolean isVip() {
+ return vip;
+ }
+
+ public void setVip(boolean vip) {
+ this.vip = vip;
+ }
+
+ public String[] getFriends() {
+ return friends;
+ }
+
+ public void setFriends(String[] friends) {
+ this.friends = friends;
+ }
+
+ public List<String> getBooks() {
+ return books;
+ }
+
+ public void setBooks(List<String> books) {
+ this.books = books;
+ }
+
+ public YourBean getYou() {
+ return you;
+ }
+
+ public void setYou(YourBean you) {
+ this.you = you;
+ }
+
+ }
+
+ public static class YourBean {
+ private int id;
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ @Test
+ public void testBean2JSON() throws Exception {
+ MyBean me = new MyBean();
+ me.setAge(30);
+ me.setBooks(new ArrayList<String>());
+ me.setFriends(new String[] {"John", "Mike"});
+ me.setVip(true);
+ me.setName("Me");
+ YourBean you = new YourBean();
+ you.setId(123);
+ you.setName(null);
+ me.setYou(you);
+ Object2JSON t1 = new Object2JSON();
+ Object result = t1.transform(me, null);
+ System.out.println(result);
+ JSON2Object t2 = new JSON2Object();
+ TransformationContext context = new TransformationContextImpl();
+ context.setTargetDataType(new DataTypeImpl(MyBean.class, null));
+ Object v = t2.transform(result.toString(), context);
+ Assert.assertTrue(v instanceof MyBean);
+ // String json =
+ // "{\"age\":30,\"books\":[],\"friends\":[\"John\",\"Mike\"],\"name\":\"Me\",\"vip\":true,\"you\":{\"id\":123,\"name\":null}}";
+ // Assert.assertEquals(json, result.toString());
+ }
+
+ @Test
+ public void testString2JSON() throws Exception {
+ Object2JSON t1 = new Object2JSON();
+ Object result = t1.transform("ABC", null);
+ System.out.println(result);
+ JSON2Object t2 = new JSON2Object();
+ TransformationContext context = new TransformationContextImpl();
+ context.setTargetDataType(new DataTypeImpl(String.class, null));
+ Object v = t2.transform(result, context);
+ Assert.assertTrue(v instanceof String);
+ Assert.assertEquals("ABC", v);
+ }
+
+ @Test
+ public void testStringArray2JSON() throws Exception {
+ Object2JSON t1 = new Object2JSON();
+ Object result = t1.transform(new String[] {"ABC", "DF"}, null);
+ System.out.println(result);
+ JSON2Object t2 = new JSON2Object();
+ TransformationContext context = new TransformationContextImpl();
+ context.setTargetDataType(new DataTypeImpl(String[].class, null));
+ Object v = t2.transform(result, context);
+ Assert.assertTrue(v instanceof String[]);
+ String[] strs = (String[])v;
+ Assert.assertEquals("ABC", strs[0]);
+ Assert.assertEquals("DF", strs[1]);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-json/src/test/resources/ipo.xsd b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/resources/ipo.xsd
new file mode 100644
index 0000000000..5a493e1746
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-json/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/LICENSE b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/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/sebastien/java/embed/modules/databinding-sdo-axiom/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a40e93b8b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data Binding for SDO and AXIOM
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data Binding for SDO
+Import-Package: commonj.sdo;version="2.1",
+ commonj.sdo.helper;version="2.1",
+ commonj.sdo.impl;version="2.1",
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding.sdo.axiom
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/NOTICE b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/pom.xml b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/pom.xml
new file mode 100644
index 0000000000..b438818c9d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/pom.xml
@@ -0,0 +1,148 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding-sdo-axiom</artifactId>
+ <name>Apache Tuscany SCA Data Binding for SDO/AXIOM</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.8</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/sdo-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <id>generate-po-sdo</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/test/resources/ipo.xsd</schemaFile>
+ <javaPackage>com.example.ipo.sdo</javaPackage>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-stock-sdo</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/test/resources/stock.xsd</schemaFile>
+ <javaPackage>com.example.stock.sdo</javaPackage>
+ <prefix>Stock</prefix>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/AxiomHelper.java b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/AxiomHelper.java
new file mode 100644
index 0000000000..02f43000b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/AxiomHelper.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo2om;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Helper for AXIOM
+ *
+ * @version $Rev$ $Date$
+ */
+public class AxiomHelper {
+ private static final String DEFAULT_PREFIX = "_ns_";
+
+ private AxiomHelper() {
+ }
+
+ /**
+ * See http://issues.apache.org/jira/browse/WSCOMMONS-240
+ * @param om
+ */
+ public static void completeAndClose(OMElement om) {
+ // Get the builder associated with the om element
+ OMXMLParserWrapper builder = om.getBuilder();
+ if (builder != null) {
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).releaseParserOnClose(true);
+ }
+ OMElement document = builder.getDocumentElement();
+ if (document != null) {
+ document.build();
+ }
+ }
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).close();
+ }
+ }
+
+ /**
+ * This method will close the builder immediately. Any subsequent Axiom objects won't
+ * be built or accessible.
+ */
+ public static void closeImmediately(OMElement om) {
+ // Get the builder associated with the om element
+ OMXMLParserWrapper builder = om.getBuilder();
+ if (builder != null) {
+ if (builder instanceof StAXBuilder) {
+ ((StAXBuilder)builder).releaseParserOnClose(true);
+ ((StAXBuilder)builder).close();
+ }
+ // builder.close();
+ }
+ }
+
+ /**
+ * @param context
+ * @param element
+ */
+ public static void adjustElementName(TransformationContext context, OMElement element) {
+ if (context != null) {
+ DataType dataType = context.getTargetDataType();
+ Object logical = dataType == null ? null : dataType.getLogical();
+ if (!(logical instanceof XMLType)) {
+ return;
+ }
+ XMLType xmlType = (XMLType)logical;
+ if (xmlType.isElement() && !xmlType.getElementName().equals(element.getQName())) {
+ // FIXME:: Throw exception or switch to the new Element?
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ QName name = xmlType.getElementName();
+ OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix());
+ element.setNamespace(namespace);
+ element.setLocalName(name.getLocalPart());
+ }
+ }
+ }
+
+ public static OMElement createOMElement(OMFactory factory, QName element) {
+ String localName = element.getLocalPart();
+ OMNamespace ns = createOMNamespace(factory, element);
+
+ return factory.createOMElement(localName, ns);
+
+ }
+
+ public static OMElement createOMElement(OMFactory factory, QName element, OMDataSource dataSource) {
+ String localName = element.getLocalPart();
+ OMNamespace ns = createOMNamespace(factory, element);
+
+ return factory.createOMElement(dataSource, localName, ns);
+
+ }
+
+ /**
+ * @param factory
+ * @param name
+ * @return
+ */
+ public static OMNamespace createOMNamespace(OMFactory factory, QName name) {
+ String namespaceURI = name.getNamespaceURI();
+ String prefix = name.getPrefix();
+
+ OMNamespace ns = null;
+ if (namespaceURI.length() != 0) {
+ // Qualified Element: we need an OMNamespace
+ if (prefix.length() == 0) {
+ // The prefix does not appear to be specified, let's create one
+ prefix = DEFAULT_PREFIX;
+ }
+ ns = factory.createOMNamespace(namespaceURI, prefix);
+ }
+ return ns;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/DataObject2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/DataObject2OMElement.java
new file mode 100644
index 0000000000..d306290245
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/DataObject2OMElement.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo2om;
+
+import static org.apache.tuscany.sca.databinding.sdo.SDODataBinding.ROOT_ELEMENT;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.sdo.SDOContextHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+/**
+ * SDO DataObject --> AXIOM OMElement transformer
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataObject2OMElement extends BaseTransformer<DataObject, OMElement> implements
+ PullTransformer<DataObject, OMElement> {
+
+ public OMElement transform(DataObject source, TransformationContext context) {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+
+ QName name = ROOT_ELEMENT;
+ if (context != null) {
+ DataType dataType = context.getTargetDataType();
+ Object logical = dataType == null ? null : dataType.getLogical();
+ if (logical instanceof XMLType) {
+ XMLType xmlType = (XMLType)logical;
+ if (xmlType.isElement()) {
+ name = xmlType.getElementName();
+ }
+ }
+ }
+
+ XMLDocument document = helperContext.getXMLHelper().createDocument(source,
+ name.getNamespaceURI(),
+ name.getLocalPart());
+ SDODataSource dataSource = new SDODataSource(document, helperContext);
+ OMElement element = AxiomHelper.createOMElement(factory, name, dataSource);
+ return element;
+ }
+
+ @Override
+ protected Class<DataObject> getSourceType() {
+ return DataObject.class;
+ }
+
+ @Override
+ protected Class<OMElement> getTargetType() {
+ return OMElement.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/SDODataSource.java b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/SDODataSource.java
new file mode 100644
index 0000000000..dc3c2610a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/SDODataSource.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.sca.databinding.sdo2om;
+
+import static org.apache.tuscany.sca.databinding.sdo.SDODataBinding.ROOT_ELEMENT;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDODataSource implements OMDataSource {
+ private HelperContext helperContext;
+ private XMLDocument sourceDocument;
+
+ public SDODataSource(XMLDocument source, HelperContext helperContext) {
+ this.sourceDocument = source;
+ this.helperContext = helperContext;
+ }
+
+ public SDODataSource(DataObject obj, HelperContext helperContext) {
+ this.helperContext = helperContext;
+ this.sourceDocument =
+ helperContext.getXMLHelper().createDocument(obj,
+ ROOT_ELEMENT.getNamespaceURI(),
+ ROOT_ELEMENT.getLocalPart());
+ }
+
+ public XMLStreamReader getReader() throws XMLStreamException {
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(helperContext);
+ return streamHelper.createXMLStreamReader(sourceDocument);
+ }
+
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ StreamingOMSerializer serializer = new StreamingOMSerializer();
+ serializer.serialize(getReader(), xmlWriter);
+ }
+
+ public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
+ try {
+ helperContext.getXMLHelper().save(sourceDocument, output, null);
+ } catch (Exception e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ public void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException {
+ try {
+ helperContext.getXMLHelper().save(sourceDocument, writer, null);
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/XMLDocument2OMElement.java b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/XMLDocument2OMElement.java
new file mode 100644
index 0000000000..3a2391b41a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/java/org/apache/tuscany/sca/databinding/sdo2om/XMLDocument2OMElement.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.sca.databinding.sdo2om;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.sdo.SDOContextHelper;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+/**
+ * SDO XMLDocument --> AXIOM OMElement transformer
+ * @version $Rev$ $Date$
+ */
+public class XMLDocument2OMElement extends BaseTransformer<XMLDocument, OMElement> implements
+ PullTransformer<XMLDocument, OMElement> {
+
+ public OMElement transform(XMLDocument source, TransformationContext context) {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
+ SDODataSource dataSource = new SDODataSource(source, helperContext);
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ QName name = new QName(source.getRootElementURI(), source.getRootElementName());
+ OMElement element = AxiomHelper.createOMElement(factory, name, dataSource);
+ return element;
+ }
+
+ @Override
+ protected Class<XMLDocument> getSourceType() {
+ return XMLDocument.class;
+ }
+
+ @Override
+ protected Class<OMElement> getTargetType() {
+ return OMElement.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..c870ec2406
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -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 classes for the transformers
+org.apache.tuscany.sca.databinding.sdo2om.DataObject2OMElement;source=commonj.sdo.DataObject,target=org.apache.axiom.om.OMElement,weight=3000
+org.apache.tuscany.sca.databinding.sdo2om.XMLDocument2OMElement;source=commonj.sdo.helper.XMLDocument,target=org.apache.axiom.om.OMElement,weight=3000
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/DataObject2OMElementTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/DataObject2OMElementTestCase.java
new file mode 100644
index 0000000000..57dd056526
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/DataObject2OMElementTestCase.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.databinding.sdo2om;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+import commonj.sdo.DataObject;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataObject2OMElementTestCase extends SDOTransformerTestCaseBase {
+
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataTypeImpl<XMLType>(DataObject.class.getName(), DataObject.class, new XMLType(ORDER_QNAME, null));
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataTypeImpl<XMLType>(OMElement.class.getName(), OMElement.class, new XMLType(ORDER_QNAME, null));
+ }
+
+ public final void testTransform() throws XMLStreamException {
+ OMElement element = new DataObject2OMElement().transform(dataObject, context);
+ Assert.assertEquals(ORDER_QNAME.getNamespaceURI(), element.getNamespace().getNamespaceURI());
+ Assert.assertEquals(ORDER_QNAME.getLocalPart(), element.getLocalName());
+ // TODO: See https://issues.apache.org/jira/browse/WSCOMMONS-226
+ // element.getBuilder().setCache(false);
+ StringWriter writer = new StringWriter();
+ element.serialize(writer);
+ }
+
+ public final void testTransformWrapper() throws XMLStreamException {
+ OMElement element = new DataObject2OMElement().transform(dataObject, context);
+ Assert.assertEquals(ORDER_QNAME.getNamespaceURI(), element.getNamespace().getNamespaceURI());
+ Assert.assertEquals(ORDER_QNAME.getLocalPart(), element.getLocalName());
+
+ OMNamespace ns = OMAbstractFactory.getOMFactory().createOMNamespace("http://ns1", "ns1");
+ element.setNamespace(ns);
+ element.setLocalName("dummy");
+ // TODO: See https://issues.apache.org/jira/browse/WSCOMMONS-226
+ // element.getBuilder().setCache(true);
+ StringWriter writer = new StringWriter();
+ element.serializeAndConsume(writer);
+ // System.out.println(writer);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/SDOTransformerTestCaseBase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/SDOTransformerTestCaseBase.java
new file mode 100644
index 0000000000..901217a58e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/SDOTransformerTestCaseBase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo2om;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.databinding.sdo.SDODataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import com.example.ipo.sdo.SdoFactory;
+import com.example.ipo.sdo.USAddress;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.impl.HelperProvider;
+
+
+/**
+ * The base class for SDO-related test cases
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class SDOTransformerTestCaseBase extends TestCase {
+ protected static final QName ORDER_QNAME = new QName("http://www.example.com/IPO", "purchaseOrder");
+
+ protected HelperContext helperContext;
+ protected String binding = DataObject.class.getName();
+ protected TransformationContext context;
+ protected TransformationContext reversedContext;
+ protected DataObject dataObject;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ new SDODataBinding(new DefaultExtensionPointRegistry());
+ helperContext = HelperProvider.getDefaultContext();
+ SdoFactory.INSTANCE.register(helperContext);
+
+ context = new TransformationContextImpl();
+ context.setSourceDataType(getSourceDataType());
+ context.setTargetDataType(getTargetDataType());
+
+ reversedContext = new TransformationContextImpl();
+ reversedContext.setSourceDataType(getTargetDataType());
+ reversedContext.setTargetDataType(getSourceDataType());
+
+ PurchaseOrderType po = SdoFactory.INSTANCE.createPurchaseOrderType();
+ USAddress address = SdoFactory.INSTANCE.createUSAddress();
+ address.setCity("San Jose");
+ address.setStreet("123 ABC St");
+ address.setState("CA");
+ address.setStreet("95131");
+ po.setBillTo(address);
+ dataObject = (DataObject) po;
+ }
+
+ protected abstract DataType<?> getSourceDataType();
+
+ protected abstract DataType<?> getTargetDataType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/XMLDocument2OMElementTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/XMLDocument2OMElementTestCase.java
new file mode 100644
index 0000000000..5015a1b697
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/java/org/apache/tuscany/sca/databinding/sdo2om/XMLDocument2OMElementTestCase.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.sca.databinding.sdo2om;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+import commonj.sdo.helper.XMLDocument;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLDocument2OMElementTestCase extends SDOTransformerTestCaseBase {
+
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataTypeImpl<XMLType>(XMLDocument.class.getName(), XMLDocument.class, new XMLType(ORDER_QNAME, null));
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataTypeImpl<XMLType>(OMElement.class.getName(), OMElement.class, new XMLType(ORDER_QNAME, null));
+ }
+
+ public final void testTransform() throws XMLStreamException {
+ XMLDocument document =
+ helperContext.getXMLHelper().createDocument(dataObject,
+ ORDER_QNAME.getNamespaceURI(),
+ ORDER_QNAME.getLocalPart());
+ OMElement element = new XMLDocument2OMElement().transform(document, context);
+ Assert.assertEquals(ORDER_QNAME.getNamespaceURI(), element.getNamespace().getNamespaceURI());
+ Assert.assertEquals(ORDER_QNAME.getLocalPart(), element.getLocalName());
+ StringWriter writer = new StringWriter();
+ element.serialize(writer);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/resources/ipo.xsd b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/resources/ipo.xsd
new file mode 100644
index 0000000000..241ec15d36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/resources/stock.xsd b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/resources/stock.xsd
new file mode 100644
index 0000000000..a0a6717371
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo-axiom/src/test/resources/stock.xsd
@@ -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.
+-->
+<schema targetNamespace="http://www.example.com/stock" xmlns="http://www.w3.org/2001/XMLSchema">
+ <!-- Faults -->
+ <element name="InvalidSymbolFault">
+ <complexType>
+ <sequence>
+ <element name="message" minOccurs="1" type="string" />
+ <element name="symbol" minOccurs="1" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="MarketClosedFault" type="string" />
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/LICENSE b/sandbox/sebastien/java/embed/modules/databinding-sdo/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/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/sebastien/java/embed/modules/databinding-sdo/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/databinding-sdo/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..98ea88ea0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/META-INF/MANIFEST.MF
@@ -0,0 +1,37 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.databinding.sdo;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data Binding for SDO
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data Binding for SDO
+Import-Package: commonj.sdo;version="2.1",
+ commonj.sdo.helper;version="2.1",
+ commonj.sdo.impl;version="2.1",
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.transform.dom,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.common.java.collection;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.util;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding.sdo
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Require-Bundle: org.apache.tuscany.sca.extensibility
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/NOTICE b/sandbox/sebastien/java/embed/modules/databinding-sdo/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/pom.xml b/sandbox/sebastien/java/embed/modules/databinding-sdo/pom.xml
new file mode 100644
index 0000000000..d8e5d79742
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/pom.xml
@@ -0,0 +1,157 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <name>Apache Tuscany SCA Data Binding for SDO</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <!-- FIXME: We might want to create a separate module to host the processor -->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-lib</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>runtime</artifactId>
+ <version>3.4.0-v20080512</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>contenttype</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>contenttype</artifactId>
+ <version>3.3.0-v20080604-1400</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>3.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/sdo-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <id>generate-po-sdo</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/test/resources/ipo.xsd</schemaFile>
+ <javaPackage>com.example.ipo.sdo</javaPackage>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-stock-sdo</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/test/resources/stock.xsd</schemaFile>
+ <javaPackage>com.example.stock.sdo</javaPackage>
+ <prefix>Stock</prefix>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2Node.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2Node.java
new file mode 100644
index 0000000000..80f4602fac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2Node.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.sca.databinding.sdo;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+public class DataObject2Node extends BaseTransformer<DataObject, Node> implements
+ PullTransformer<DataObject, Node> {
+
+ public Node transform(DataObject source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
+ XMLHelper xmlHelper = helperContext.getXMLHelper();
+ QName elementName = SDOContextHelper.getElement(context);
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ DOMResult result = new DOMResult(doc);
+ XMLDocument xmlDoc = xmlHelper.createDocument(source, elementName.getNamespaceURI(), elementName.getLocalPart());
+ xmlHelper.save(xmlDoc, result, null);
+ return doc.getDocumentElement();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<DataObject> getSourceType() {
+ return DataObject.class;
+ }
+
+ @Override
+ protected Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2String.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2String.java
new file mode 100644
index 0000000000..eaaf153dd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2String.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLHelper;
+
+public class DataObject2String extends BaseTransformer<DataObject, String> implements
+ PullTransformer<DataObject, String> {
+
+ public String transform(DataObject source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
+ XMLHelper xmlHelper = helperContext.getXMLHelper();
+ QName elementName = SDOContextHelper.getElement(context);
+ return xmlHelper.save(source, elementName.getNamespaceURI(), elementName.getLocalPart());
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<DataObject> getSourceType() {
+ return DataObject.class;
+ }
+
+ @Override
+ protected Class<String> getTargetType() {
+ return String.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReader.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReader.java
new file mode 100644
index 0000000000..7d66810ca0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReader.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.sca.databinding.sdo;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+public class DataObject2XMLStreamReader extends BaseTransformer<DataObject, XMLStreamReader> implements
+ PullTransformer<DataObject, XMLStreamReader> {
+
+ public XMLStreamReader transform(final DataObject source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(helperContext);
+ final QName elementName = SDOContextHelper.getElement(context);
+ final XMLHelper xmlHelper = helperContext.getXMLHelper();
+ // Allow privileged access to read properties. REquires java.util.PropertyPermission
+ // XML.load.form.lax read in security policy.
+ XMLDocument document = AccessController.doPrivileged(new PrivilegedAction<XMLDocument>() {
+ public XMLDocument run() {
+ return xmlHelper.createDocument(source, elementName.getNamespaceURI(), elementName.getLocalPart());
+ }
+ });
+
+ return streamHelper.createXMLStreamReader(document);
+ } catch (XMLStreamException e) {
+ // TODO: Add context to the exception
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<DataObject> getSourceType() {
+ return DataObject.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDO.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDO.java
new file mode 100644
index 0000000000..d59698cdb3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDO.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.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.impl.BaseImpl;
+
+import commonj.sdo.helper.HelperContext;
+
+/**
+ * The model object for import.sdo
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImportSDO extends BaseImpl {
+ public static final QName IMPORT_SDO =
+ new QName(Base.SCA11_TUSCANY_NS, "import.sdo");
+
+ private HelperContext helperContext;
+ private String factoryClassName;
+ private String schemaLocation;
+
+ public ImportSDO(HelperContext helperContext) {
+ super();
+ this.helperContext = helperContext;
+ setUnresolved(true);
+ }
+
+ public HelperContext getHelperContext() {
+ return helperContext;
+ }
+
+ /**
+ * @return the factoryClassName
+ */
+ public String getFactoryClassName() {
+ return factoryClassName;
+ }
+
+ /**
+ * @param factoryClassName the factoryClassName to set
+ */
+ public void setFactoryClassName(String factoryClassName) {
+ this.factoryClassName = factoryClassName;
+ }
+
+ /**
+ * @return the schemaLocation
+ */
+ public String getSchemaLocation() {
+ return schemaLocation;
+ }
+
+ /**
+ * @param schemaLocation the schemaLocation to set
+ */
+ public void setSchemaLocation(String schemaLocation) {
+ this.schemaLocation = schemaLocation;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java
new file mode 100644
index 0000000000..117d61ff26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static org.apache.tuscany.sca.databinding.sdo.ImportSDO.IMPORT_SDO;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLConnection;
+
+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.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * Loader that handles &lt;import.sdo&gt; elements.
+ *
+ * @version $Rev$ $Date$
+ * @deprecated
+ */
+@Deprecated
+public class ImportSDOProcessor implements StAXArtifactProcessor<ImportSDO> {
+
+ private ContributionFactory contributionFactory;
+
+ public ImportSDOProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
+ message, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR, message,model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getXMLType() {
+ return IMPORT_SDO;
+ }
+
+ public ImportSDO read(XMLStreamReader reader,ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ assert IMPORT_SDO.equals(reader.getName());
+
+ // FIXME: How do we associate the application HelperContext with the one
+ // imported by the composite
+ ImportSDO importSDO = new ImportSDO(SDOContextHelper.getDefaultHelperContext());
+ String factoryName = reader.getAttributeValue(null, "factory");
+ if (factoryName != null) {
+ importSDO.setFactoryClassName(factoryName);
+ }
+ String location = reader.getAttributeValue(null, "location");
+ if (location != null) {
+ importSDO.setSchemaLocation(location);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && ImportSDO.IMPORT_SDO.equals(reader.getName())) {
+ break;
+ }
+ }
+ return importSDO;
+ }
+
+ private void importFactory(ImportSDO importSDO, ModelResolver resolver,ProcessorContext context) throws ContributionResolveException {
+ String factoryName = importSDO.getFactoryClassName();
+ if (factoryName != null) {
+ ClassReference reference = new ClassReference(factoryName);
+ ClassReference resolved = resolver.resolveModel(ClassReference.class, reference,context);
+ if (resolved != null && !resolved.isUnresolved()) {
+ try {
+ Class<?> factoryClass = resolved.getJavaClass();
+ register(factoryClass, importSDO.getHelperContext());
+ importSDO.setUnresolved(false);
+ } catch (Exception e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ } else {
+ error(context.getMonitor(), "FailToResolveClass", resolver, factoryName);
+ //ContributionResolveException loaderException =
+ //new ContributionResolveException("Fail to resolve class: " + factoryName);
+ //throw loaderException;
+ }
+ }
+ }
+
+ private static void register(Class factoryClass, HelperContext helperContext) throws Exception {
+ Field field = factoryClass.getField("INSTANCE");
+ Object factory = field.get(null);
+ Method method = factory.getClass().getMethod("register", new Class[] {HelperContext.class});
+ method.invoke(factory, new Object[] {helperContext});
+
+ // HelperContext defaultContext = HelperProvider.getDefaultContext();
+ // method.invoke(factory, new Object[] {defaultContext});
+ }
+
+ private void importWSDL(ImportSDO importSDO, ModelResolver resolver,ProcessorContext context) throws ContributionResolveException {
+ String location = importSDO.getSchemaLocation();
+ if (location != null) {
+ try {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(location);
+ artifact = resolver.resolveModel(Artifact.class, artifact,context);
+ if (artifact.getLocation() != null) {
+ String wsdlURL = artifact.getLocation();
+ URLConnection connection = new URL(wsdlURL).openConnection();
+ connection.setUseCaches(false);
+ InputStream xsdInputStream = connection.getInputStream();
+ try {
+ XSDHelper xsdHelper = importSDO.getHelperContext().getXSDHelper();
+ xsdHelper.define(xsdInputStream, wsdlURL);
+ } finally {
+ xsdInputStream.close();
+ }
+ importSDO.setUnresolved(false);
+ } else {
+ error(context.getMonitor(), "FailToResolveLocation", resolver, location);
+ //ContributionResolveException loaderException = new ContributionResolveException("Fail to resolve location: " + location);
+ //throw loaderException;
+ }
+ } catch (IOException e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ }
+ }
+
+ public QName getArtifactType() {
+ return ImportSDO.IMPORT_SDO;
+ }
+
+ public void write(ImportSDO model, XMLStreamWriter outputSource,ProcessorContext context) throws ContributionWriteException {
+ // Not implemented as <import.sdo> is deprecated
+ }
+
+ public Class<ImportSDO> getModelType() {
+ return ImportSDO.class;
+ }
+
+ public void resolve(ImportSDO importSDO, ModelResolver resolver,ProcessorContext context) throws ContributionResolveException {
+ importFactory(importSDO, resolver,context);
+ importWSDL(importSDO, resolver,context);
+ if (!importSDO.isUnresolved()) {
+ resolver.addModel(importSDO,context);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/Node2DataObject.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/Node2DataObject.java
new file mode 100644
index 0000000000..a7fc9aeb5c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/Node2DataObject.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.sca.databinding.sdo;
+
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+public class Node2DataObject extends BaseTransformer<Node, DataObject> implements PullTransformer<Node, DataObject> {
+
+private DOMHelper helper;
+
+public Node2DataObject(ExtensionPointRegistry registry) {
+ super();
+ helper = DOMHelper.getInstance(registry);
+}
+ public DataObject transform(Node source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, false);
+ XMLHelper xmlHelper = helperContext.getXMLHelper();
+ Document doc = helper.promote(source);
+ DOMSource domSource = new DOMSource(doc);
+ XMLDocument xmlDoc = xmlHelper.load(domSource, doc.getDocumentURI(), null);
+ return xmlDoc.getRootObject();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Node> getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class<DataObject> getTargetType() {
+ return DataObject.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelper.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelper.java
new file mode 100644
index 0000000000..23063317e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelper.java
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.java.collection.LRUCache;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.util.DataTypeHelper;
+import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ * Helper class to get TypeHelper from the context
+ *
+ * @version $Rev$ $Date$
+ */
+public final class SDOContextHelper {
+ private static final LRUCache<Object, HelperContext> cache = new LRUCache<Object, HelperContext>(1024);
+
+ private static ExtensionPointRegistry registry = null;
+ private static HelperContext defaultHelperContext;
+
+ private SDOContextHelper() {
+ }
+
+ /**
+ * Static method used to set the registry used to locate the SDO implementation provider
+ * MUST be called before using any other methods on this class
+ * @param theRegistry
+ */
+ public static void setRegistry( ExtensionPointRegistry theRegistry ) {
+ registry = theRegistry;
+ } // end setRegistry
+
+ public static HelperContext getHelperContext(TransformationContext context, boolean source) {
+ if (context == null) {
+ return getDefaultHelperContext();
+ }
+
+ HelperContext helperContext = null;
+ Operation op = source ? context.getSourceOperation() : context.getTargetOperation();
+ if (op == null) {
+ DataType<?> dt = source ? context.getSourceDataType() : context.getTargetDataType();
+
+ helperContext = dt.getMetaData(HelperContext.class);
+ if (helperContext != null) {
+ return helperContext;
+ }
+ helperContext = SDOUtil.createHelperContext();
+ boolean found = register(helperContext, dt);
+ if (!found) {
+ helperContext = getDefaultHelperContext();
+ }
+ dt.setMetaData(HelperContext.class, helperContext);
+ return helperContext;
+ } else {
+ return getHelperContext(op);
+ }
+
+ }
+
+ public static HelperContext getHelperContext(Operation op) {
+ if (op == null) {
+ return getDefaultHelperContext();
+ }
+
+ HelperContext helperContext = op.getInputType().getMetaData(HelperContext.class);
+
+ if (helperContext != null) {
+ return helperContext;
+ }
+
+ // Use the default HelperContext until a type is registered later on
+ helperContext = getDefaultHelperContext();
+
+ /*
+ List<DataType> dataTypes = DataTypeHelper.getDataTypes(op, false);
+ boolean found = false;
+ for (DataType d : dataTypes) {
+ if (register(helperContext, d)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ helperContext = getDefaultHelperContext();
+ }
+ */
+ op.getInputType().setMetaData(HelperContext.class, helperContext);
+ return helperContext;
+ }
+
+ /**
+ * @param helperContext
+ * @param dataType
+ * @return
+ */
+ private static boolean register(HelperContext helperContext, DataType dataType) {
+ if (dataType == null) {
+ return false;
+ }
+ Set<Class<?>> classes = DataTypeHelper.findClasses(dataType);
+ boolean found = false;
+ for (Class<?> cls : classes) {
+ found = register(helperContext, dataType.getPhysical()) || found;
+ }
+ return found;
+ }
+
+ /**
+ * FIXME: [rfeng] This is a hack to get the factory out a SDO class
+ * @param helperContext
+ * @param javaType
+ */
+
+ public static boolean register(HelperContext helperContext, Class javaType) {
+ if (javaType == null || DataObject.class == javaType) {
+ return false;
+ }
+ try {
+ Type type = helperContext.getTypeHelper().getType(javaType);
+ return register(helperContext, type);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public static boolean register(HelperContext helperContext, Type type) {
+ if (type != null && (!type.isDataType())) {
+ try {
+ Method method = type.getClass().getMethod("getEPackage");
+ Object factory = method.invoke(type, new Object[] {});
+ method = factory.getClass().getMethod("register", HelperContext.class);
+ method.invoke(factory, new Object[] {helperContext});
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public static HelperContext getDefaultHelperContext( ) {
+ // Return a chached value if available...
+ if( defaultHelperContext != null ) return defaultHelperContext;
+
+ // Try to set up TCCL so that SDO Helper Provider service discovery works in OSGi
+ if( registry == null ) return null;
+
+ ClassLoader oldTccl =
+ ClassLoaderContext.setContextClassLoader(SDOContextHelper.class.getClassLoader(),
+ registry.getServiceDiscovery(),
+ // SDO Helper Provider
+ "commonj.sdo.impl.HelperProvider"
+ );
+ try {
+ // Load the HelperProvider (using the new TCCL) and get the default HelperContext
+ // cache the returned HelperContext...
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ HelperProvider.setDefaultInstance(tccl);
+ defaultHelperContext = HelperProvider.getDefaultContext();
+ return defaultHelperContext;
+ } catch (Exception e ){
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (oldTccl != null) {
+ Thread.currentThread().setContextClassLoader(oldTccl);
+ }
+ } // end try
+ } // end getDefaultHelperContext()
+
+ public static QName getElement(TransformationContext context) {
+ if (context == null) {
+ return SDODataBinding.ROOT_ELEMENT;
+ }
+ DataType<?> dataType = context.getTargetDataType();
+ Object logical = dataType.getLogical();
+ QName elementName = null;
+ if (logical instanceof XMLType) {
+ XMLType xmlType = (XMLType)logical;
+ QName element = xmlType.getElementName();
+ if (element != null) {
+ elementName = element;
+ }
+ }
+ if (elementName == null) {
+ // Try source type
+ dataType = context.getSourceDataType();
+ logical = dataType.getLogical();
+ if (logical instanceof XMLType) {
+ XMLType xmlType = (XMLType)logical;
+ QName element = xmlType.getElementName();
+ if (element != null) {
+ elementName = element;
+ }
+ }
+ }
+ if (elementName != null) {
+ return elementName;
+ } else {
+ return SDODataBinding.ROOT_ELEMENT;
+ }
+ }
+
+ public static String generateSchema(HelperContext context, Class<?>[] classes) {
+ TypeHelper typeHelper = context.getTypeHelper();
+ List<Type> types = new ArrayList<Type>();
+ for (Class<?> cls : classes) {
+ Type type = typeHelper.getType(cls);
+ if (type != null) {
+ types.add(type);
+ }
+ }
+ return generateSchema(context, types);
+ }
+
+ public static String generateSchema(HelperContext context, List<Type> types) {
+ // FIXME: SDO throws IllegalArgumentException for types generated from existing XSDs
+ return context.getXSDHelper().generate(types);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java
new file mode 100644
index 0000000000..0003e7d46f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDODataBinding.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.sdo;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+/**
+ * SDO Databinding
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDODataBinding extends BaseDataBinding {
+ public static final String NAME = DataObject.class.getName();
+
+ public static final String ROOT_NAMESPACE = "commonj.sdo";
+ public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "dataObject");
+
+ private WrapperHandler<Object> wrapperHandler;
+ private XMLTypeHelper xmlTypeHelper;
+
+ public SDODataBinding( ExtensionPointRegistry registry ) {
+ super(NAME, DataObject.class);
+ SDOContextHelper.setRegistry( registry );
+ wrapperHandler = new SDOWrapperHandler();
+ xmlTypeHelper = new SDOTypeHelper();
+ }
+
+ @Override
+ public boolean introspect(DataType dataType, final Operation operation) {
+ final Class javaType = dataType.getPhysical();
+ // Allow privileged access to read system properties. Requires PropertyPermission
+ // java.specification.version read in security policy.
+ final HelperContext context = AccessController.doPrivileged(new PrivilegedAction<HelperContext>() {
+ public HelperContext run() {
+ return SDOContextHelper.getHelperContext(operation);
+ }
+ });
+
+ final Type type = context.getTypeHelper().getType(javaType);
+ if (type == null) {
+ // FIXME: Need a better to test dynamic SDO
+ if (DataObject.class.isAssignableFrom(javaType)) {
+ // Dynamic SDO
+ dataType.setDataBinding(getName());
+ if (dataType.getLogical() == null) {
+ dataType.setLogical(XMLType.UNKNOWN);
+ }
+ return true;
+ }
+ return false;
+ }
+ if (type.isDataType()) {
+ // FIXME: Ignore simple types?
+ return false;
+ }
+
+ // Found a SDO type, replace the default context with a private one
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ if (context == SDOContextHelper.getDefaultHelperContext()) {
+ HelperContext newContext = SDOUtil.createHelperContext();
+ SDOContextHelper.register(newContext, type);
+ if (operation != null) {
+ operation.getInputType().setMetaData(HelperContext.class, newContext);
+ }
+ } else {
+ SDOContextHelper.register(context, type);
+ }
+ return null;
+ }
+ });
+
+ String namespace = type.getURI();
+ String name = context.getXSDHelper().getLocalName(type);
+ QName xmlType = new QName(namespace, name);
+ dataType.setDataBinding(getName());
+ QName elementName = null;
+ Object logical = dataType.getLogical();
+ if (logical instanceof XMLType) {
+ elementName = ((XMLType)logical).getElementName();
+ }
+ dataType.setLogical(new XMLType(elementName, xmlType));
+
+ return true;
+ }
+
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return wrapperHandler;
+ }
+
+ @Override
+ public XMLTypeHelper getXMLTypeHelper() {
+ // return new SDOTypeHelper();
+ return xmlTypeHelper;
+ }
+
+ @Override
+ public Object copy(Object arg, DataType dataType, DataType targetDataType, Operation operation, Operation targetOperation) {
+ HelperContext context = SDOContextHelper.getHelperContext(operation);
+ CopyHelper copyHelper = context.getCopyHelper();
+ if (arg instanceof XMLDocument) {
+ XMLDocument document = (XMLDocument)arg;
+ DataObject dataObject = copyHelper.copy(document.getRootObject());
+ return context.getXMLHelper().createDocument(dataObject,
+ document.getRootElementURI(),
+ document.getRootElementName());
+ } else if (arg instanceof DataObject) {
+ return context.getCopyHelper().copy((DataObject)arg);
+ } else {
+ return super.copy(arg, dataType, targetDataType, operation, targetOperation);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOSimpleTypeMapper.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOSimpleTypeMapper.java
new file mode 100644
index 0000000000..7e26990b32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOSimpleTypeMapper.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.sca.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * SDO Java/XML mapping for simple XSD types
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDOSimpleTypeMapper implements SimpleTypeMapper {
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+
+ public SDOSimpleTypeMapper() {
+ super();
+ }
+
+ public Object toJavaObject(QName typeName, String value, TransformationContext context) {
+ Type type = null;
+ if (URI_2001_SCHEMA_XSD.equals(typeName.getNamespaceURI())) {
+ type = SDOUtil.getXSDSDOType(typeName.getLocalPart());
+ } else {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, false);
+ TypeHelper typeHelper = helperContext.getTypeHelper();
+ type = typeHelper.getType(typeName.getNamespaceURI(), typeName.getLocalPart());
+ }
+ return SDOUtil.createFromString(type, value);
+ }
+
+ public String toXMLLiteral(QName typeName, Object obj, TransformationContext context) {
+ Type type = null;
+ if (URI_2001_SCHEMA_XSD.equals(typeName.getNamespaceURI())) {
+ type = SDOUtil.getXSDSDOType(typeName.getLocalPart());
+ } else {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
+ TypeHelper typeHelper = helperContext.getTypeHelper();
+ type = typeHelper.getType(typeName.getNamespaceURI(), typeName.getLocalPart());
+ }
+ return SDOUtil.convertToString(type, obj);
+ }
+
+ public Class<?> getJavaType(QName xmlType) {
+
+ return null;
+ }
+
+ public TypeInfo getXMLType(Class<?> javaType) {
+ return null;
+ }
+
+ public boolean isSimpleXSDType(QName xmlType) {
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java
new file mode 100644
index 0000000000..381249d9bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import java.beans.Introspector;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSParser;
+
+import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class SDOTypeHelper implements XMLTypeHelper {
+ private static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+
+ private TypeHelper typeHelper;
+ private XSDHelper xsdHelper;
+
+ private ProcessorContext context;
+ // private Map<String, List<Type>> xsdTypesMap = new HashMap<String, List<Type>>();
+ // private Map<String, List<Type>> typesMap = new HashMap<String, List<Type>>();
+
+ public SDOTypeHelper( ProcessorContext context ) {
+ super();
+ this.context=context;
+ //Should we use this.context to get helper objects ???
+ typeHelper = SDOContextHelper.getDefaultHelperContext().getTypeHelper();
+ xsdHelper = SDOContextHelper.getDefaultHelperContext().getXSDHelper();
+ }
+ //Should we remove this constructor???? otherwise we context gets created
+ public SDOTypeHelper() {
+ this(null);
+ /*
+ super();
+ this.context=null;
+ //Should we use this.context to get helper objects ???
+ typeHelper = SDOContextHelper.getDefaultHelperContext().getTypeHelper();
+ xsdHelper = SDOContextHelper.getDefaultHelperContext().getXSDHelper();
+ */
+ }
+ public TypeInfo getTypeInfo(Class javaType, Object logical) {
+ QName xmlType = JavaXMLMapper.getXMLType(javaType);
+ if (xmlType != null) {
+ return new TypeInfo(xmlType, true, null);
+ } else {
+ // introspect(javaType, xsdTypesMap, typesMap);
+ if (logical instanceof XMLType) {
+ xmlType = ((XMLType)logical).getTypeName();
+ }
+ if (xmlType == null) {
+ xmlType =
+ new QName(JavaXMLMapper.getNamespace(javaType), Introspector.decapitalize(javaType.getSimpleName()));
+ }
+ return new TypeInfo(xmlType, false, null);
+ }
+ }
+
+ private void introspect(Class javaType, Map<String, List<Type>> xsdTypesMap, Map<String, List<Type>> typesMap) {
+ Type type = typeHelper.getType(javaType);
+ if (type == null) {
+ return;
+ }
+ if (xsdHelper.isXSD(type)) {
+ addToMap(xsdTypesMap, type);
+ } else {
+ addToMap(typesMap, type);
+ }
+ }
+
+ private void addToMap(Map<String, List<Type>> map, Type type) {
+ List<Type> types = map.get(type.getURI());
+ if (types == null) {
+ types = new ArrayList<Type>();
+ map.put(type.getURI(), types);
+ }
+ if (!types.contains(type)) {
+ types.add(type);
+ }
+ }
+
+ /*
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver) {
+ List<XSDefinition> definitions = new ArrayList<XSDefinition>();
+ generateSDOSchemas(definitions, factory, typesMap);
+ addResolvedXSDs(definitions, factory, resolver, xsdTypesMap);
+ return definitions;
+ }
+ */
+
+ private void generateSDOSchemas(List<XSDefinition> definitions, XSDFactory factory, Map<String, List<Type>> map) {
+ for (Map.Entry<String, List<Type>> entry : map.entrySet()) {
+ List<Type> types = entry.getValue();
+ String ns = entry.getKey();
+ generateSchema(definitions, factory, types, ns);
+ }
+ }
+
+ private void generateSchema(List<XSDefinition> definitions, XSDFactory factory, List<Type> types, String ns) {
+ String schema = xsdHelper.generate(types);
+ DOMImplementationRegistry registry = null;
+ try {
+ registry = DOMImplementationRegistry.newInstance();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
+ DOMImplementationLS ls = (DOMImplementationLS)impl.getFeature("LS", "3.0");
+ LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, SCHEMA_NS);
+ LSInput input = ls.createLSInput();
+ input.setCharacterStream(new StringReader(schema));
+ Document document = parser.parse(input);
+ XSDefinition definition = factory.createXSDefinition();
+ definition.setUnresolved(true);
+ definition.setDocument(document);
+ definition.setNamespace(ns);
+ definitions.add(definition);
+ }
+
+ private void addResolvedXSDs(List<XSDefinition> definitions,
+ XSDFactory factory,
+ ModelResolver resolver,
+ Map<String, List<Type>> map) {
+ for (Map.Entry<String, List<Type>> entry : map.entrySet()) {
+ XSDefinition definition = factory.createXSDefinition();
+ definition.setUnresolved(true);
+ definition.setNamespace(entry.getKey());
+ //FIXME: set location URI
+
+ XSDefinition resolved = resolver.resolveModel(XSDefinition.class, definition,context);
+ if (resolved.getSchema() == null) {
+ //FIXME: create a checked exception and propagate it back up to the activator
+ throw new RuntimeException("No XSD found for namespace " + entry.getKey());
+ }
+ // make sure all the required types are defined in the resolved schema
+ for (Type type : entry.getValue()) {
+ String name = xsdHelper.getLocalName(type);
+ QName typeName = null;
+ if (name.endsWith("_._type")) {
+ // FIXME: Anonymous tyype
+ name = name.substring(0, name.length() - "_._type".length());
+ typeName = new QName(type.getURI(), name);
+ if (resolved.getXmlSchemaElement(typeName) == null) {
+ //FIXME: create a checked exception and propagate it back up to the activator
+ throw new RuntimeException("No XSD found for " + typeName.toString());
+ }
+ } else {
+ typeName = new QName(type.getURI(), name);
+ if (resolved.getXmlSchemaType(typeName) == null) {
+ //FIXME: create a checked exception and propagate it back up to the activator
+ throw new RuntimeException("No XSD found for " + typeName.toString());
+ }
+ }
+
+ }
+ definitions.add(resolved);
+ }
+ }
+
+ private static List<DataType> getDataTypes(Interface intf) {
+ List<DataType> dataTypes = new ArrayList<DataType>();
+ for (Operation op : intf.getOperations()) {
+ WrapperInfo wrapperInfo = op.getWrapper();
+
+ if (wrapperInfo != null ) {
+ DataType dt1 = wrapperInfo.getInputWrapperType();
+ if (dt1 != null) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = wrapperInfo.getOutputWrapperType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ } else {
+ for (DataType dt1 : op.getInputType().getLogical()) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = op.getOutputType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ for (DataType<DataType> dt3 : op.getFaultTypes()) {
+ DataType dt4 = dt3.getLogical();
+ if (dt4 != null) {
+ dataTypes.add(dt4);
+ }
+ }
+ }
+ }
+ return dataTypes;
+ }
+
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, Interface intf) {
+ return getSchemaDefinitions(factory, resolver, getDataTypes(intf));
+ }
+
+ public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, List<DataType> dataTypes) {
+ Map<String, List<Type>> xsdTypesMap = new HashMap<String, List<Type>>();
+ Map<String, List<Type>> typesMap = new HashMap<String, List<Type>>();
+ for (DataType d : dataTypes) {
+ if (SDODataBinding.NAME.equals(d.getDataBinding())) {
+ introspect(d.getPhysical(), xsdTypesMap, typesMap);
+ }
+ }
+ List<XSDefinition> definitions = new ArrayList<XSDefinition>();
+ generateSDOSchemas(definitions, factory, typesMap);
+ addResolvedXSDs(definitions, factory, resolver, xsdTypesMap);
+ return definitions;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java
new file mode 100644
index 0000000000..1ef689185a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypes.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+import commonj.sdo.Type;
+
+/**
+ * The model object for sdo.types
+ *
+ * @version $Rev$ $Date$
+ *
+ * This extends the META-INF/sca-contribution.xml to register SDO types from static factory classes or WSDL/XSD files
+ *
+ * &lt;contribution xmlns=&quot;http://tuscany.apache.org/xmlns/sca/1.1&quot;<br>
+ * &nbsp;&nbsp;&nbsp;&nbsp;xmlns:tuscany=&quot;http://tuscany.apache.org/xmlns/sca/1.0&quot;&gt;<br>
+ * &nbsp;&nbsp;&nbsp;&nbsp;&lt;tuscany:sdo.types namespace=&quot;http://helloworld&quot; location=&quot;wsdl/helloworld.wsdl&quot;/&gt;<br>
+ * &lt;/contribution&gt;
+ *
+ */
+public class SDOTypes {
+ public static final QName SDO_TYPES = new QName(Base.SCA11_TUSCANY_NS, "sdo.types");
+
+ private String factory;
+ private String schemaLocation;
+ private String namespace;
+
+ private List<Type> types = new ArrayList<Type>();
+
+ private boolean unresolved;
+
+ public SDOTypes() {
+ super();
+ setUnresolved(true);
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ /**
+ * @return the factoryClassName
+ */
+ public String getFactory() {
+ return factory;
+ }
+
+ /**
+ * @param factoryClassName the factoryClassName to set
+ */
+ public void setFactory(String factoryClassName) {
+ this.factory = factoryClassName;
+ }
+
+ /**
+ * @return the schemaLocation
+ */
+ public String getSchemaLocation() {
+ return schemaLocation;
+ }
+
+ /**
+ * @param schemaLocation the schemaLocation to set
+ */
+ public void setSchemaLocation(String schemaLocation) {
+ this.schemaLocation = schemaLocation;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public List<Type> getTypes() {
+ return types;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java
new file mode 100644
index 0000000000..58c69858b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * SDO Wrapper Handler
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDOWrapperHandler implements WrapperHandler<Object> {
+
+ public Object create(Operation operation, boolean input) {
+ WrapperInfo wrapperInfo = operation.getWrapper();
+
+
+ ElementInfo element = input ? wrapperInfo.getInputWrapperElement() :
+ wrapperInfo.getOutputWrapperElement();
+
+ HelperContext helperContext = SDOContextHelper.getHelperContext(operation);
+ Type sdoType = getSDOType(helperContext, element);
+ if (sdoType != null) {
+ DataFactory dataFactory = helperContext.getDataFactory();
+ return dataFactory.create(sdoType);
+ }
+ return null;
+ }
+
+ public void setChildren(Object wrapper, Object[] childObjects, Operation operation, boolean input) {
+ WrapperInfo wrapperInfo = operation.getWrapper();
+
+
+ List<ElementInfo> childElements = input? wrapperInfo.getInputChildElements():
+ wrapperInfo.getOutputChildElements();
+
+ for (int i = 0; i < childElements.size(); i++) {
+ setChild(wrapper, i, childElements.get(i), childObjects[i]);
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#setChild(java.lang.Object, int, ElementInfo,
+ * java.lang.Object)
+ */
+ public void setChild(Object wrapper, int i, ElementInfo childElement, Object value) {
+ DataObject wrapperDO =
+ (wrapper instanceof XMLDocument) ? ((XMLDocument)wrapper).getRootObject() : (DataObject)wrapper;
+ String name = childElement.getQName().getLocalPart();
+ if (childElement.isMany()) {
+ // FIXME: If we look up by name, we need to make sure the WrapperInfo has the correct element names
+ wrapperDO.getList(i).addAll((Collection)value);
+ } else {
+ wrapperDO.set(i, value);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public List getChildren(Object wrapper, Operation operation, boolean input) {
+ DataObject wrapperDO =
+ (wrapper instanceof XMLDocument) ? ((XMLDocument)wrapper).getRootObject() : (DataObject)wrapper;
+ List<Property> properties = wrapperDO.getInstanceProperties();
+ List<Object> elements = new ArrayList<Object>();
+ Type type = wrapperDO.getType();
+ if (type.isSequenced()) {
+ // Add values in the sequence
+ Sequence sequence = wrapperDO.getSequence();
+ for (int i = 0; i < sequence.size(); i++) {
+ // Skip mixed text
+ if (sequence.getProperty(i) != null) {
+ elements.add(sequence.getValue(i));
+ }
+ }
+ } else {
+ for (Property p : properties) {
+ Object child = wrapperDO.get(p);
+ if (p.isMany()) {
+ for (Object c : (Collection<?>)child) {
+ elements.add(c);
+ }
+ } else {
+ elements.add(child);
+ }
+ }
+ }
+ return elements;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean)
+ */
+ public DataType getWrapperType(Operation operation, boolean input) {
+ WrapperInfo wrapperInfo = operation.getWrapper();
+
+
+ ElementInfo element = input ? wrapperInfo.getInputWrapperElement() :
+ wrapperInfo.getOutputWrapperElement();
+
+ HelperContext helperContext = SDOContextHelper.getHelperContext(operation);
+ Type sdoType = getSDOType(helperContext, element);
+ if (sdoType != null) {
+ // Check if child elements matches
+ Class physical = sdoType.getInstanceClass();
+ DataType<XMLType> wrapperType =
+ new DataTypeImpl<XMLType>(SDODataBinding.NAME, physical, new XMLType(element));
+ return wrapperType;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @param helperContext
+ * @param element
+ * @return
+ */
+ private Type getSDOType(HelperContext helperContext, ElementInfo element) {
+ XSDHelper xsdHelper = helperContext.getXSDHelper();
+ Type sdoType = null;
+ Property prop =
+ xsdHelper.getGlobalProperty(element.getQName().getNamespaceURI(), element.getQName().getLocalPart(), true);
+ if (prop != null) {
+ sdoType = prop.getType();
+ } else {
+ TypeInfo type = element.getType();
+ QName typeName = type != null ? type.getQName() : null;
+ if (typeName != null) {
+ sdoType = helperContext.getTypeHelper().getType(typeName.getNamespaceURI(), typeName.getLocalPart());
+ }
+ }
+ return sdoType;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#isInstance(java.lang.Object, Operation, boolean)
+ */
+ public boolean isInstance(Object wrapper, Operation operation, boolean input) {
+ WrapperInfo wrapperInfo = operation.getWrapper();
+
+
+ ElementInfo element = input ? wrapperInfo.getInputWrapperElement() :
+ wrapperInfo.getOutputWrapperElement();
+
+ // List<ElementInfo> childElements =
+ // input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements();
+ HelperContext helperContext = SDOContextHelper.getHelperContext(operation);
+ Type sdoType = getSDOType(helperContext, element);
+ if (sdoType != null) {
+ return sdoType.isInstance(wrapper);
+ }
+ return false;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/String2DataObject.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/String2DataObject.java
new file mode 100644
index 0000000000..a48e357960
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/String2DataObject.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.sca.databinding.sdo;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLHelper;
+
+public class String2DataObject extends BaseTransformer<String, DataObject> implements
+ PullTransformer<String, DataObject> {
+
+ public DataObject transform(String source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, false);
+ XMLHelper xmlHelper = helperContext.getXMLHelper();
+ return xmlHelper.load(source).getRootObject();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<String> getSourceType() {
+ return String.class;
+ }
+
+ @Override
+ protected Class<DataObject> getTargetType() {
+ return DataObject.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 50;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2String.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2String.java
new file mode 100644
index 0000000000..d73f714384
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2String.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.sca.databinding.sdo;
+
+import java.io.StringWriter;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+public class XMLDocument2String extends BaseTransformer<XMLDocument, String> implements
+ PullTransformer<XMLDocument, String> {
+
+ public String transform(XMLDocument source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
+ XMLHelper xmlHelper = helperContext.getXMLHelper();
+ StringWriter writer = new StringWriter();
+ xmlHelper.save(source, writer, null);
+ return writer.toString();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<XMLDocument> getSourceType() {
+ return XMLDocument.class;
+ }
+
+ @Override
+ protected Class<String> getTargetType() {
+ return String.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2XMLStreamReader.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2XMLStreamReader.java
new file mode 100644
index 0000000000..2f41fb1957
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2XMLStreamReader.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+public class XMLDocument2XMLStreamReader extends BaseTransformer<XMLDocument, XMLStreamReader> implements
+ PullTransformer<XMLDocument, XMLStreamReader> {
+ /**
+ * @param source
+ * @param context
+ * @return
+ */
+ public XMLStreamReader transform(XMLDocument source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(helperContext);
+ return streamHelper.createXMLStreamReader(source);
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<XMLDocument> getSourceType() {
+ return XMLDocument.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLStreamReader2DataObject.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLStreamReader2DataObject.java
new file mode 100644
index 0000000000..fbc13e6fed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLStreamReader2DataObject.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.sdo;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+
+public class XMLStreamReader2DataObject extends BaseTransformer<XMLStreamReader, DataObject> implements
+ PullTransformer<XMLStreamReader, DataObject> {
+
+ public DataObject transform(XMLStreamReader source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, false);
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(helperContext);
+ // The XMLStreamHelper requires that the reader is positioned at
+ // START_ELEMENT
+ while (source.getEventType() != XMLStreamConstants.START_ELEMENT && source.hasNext()) {
+ source.next();
+ }
+ DataObject target = streamHelper.loadObject(source);
+ source.close();
+ return target;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<DataObject> getTargetType() {
+ return DataObject.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 15;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLStreamReader2XMLDocument.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLStreamReader2XMLDocument.java
new file mode 100644
index 0000000000..658fe115a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/XMLStreamReader2XMLDocument.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+
+public class XMLStreamReader2XMLDocument extends BaseTransformer<XMLStreamReader, XMLDocument> implements
+ PullTransformer<XMLStreamReader, XMLDocument> {
+
+ public XMLDocument transform(XMLStreamReader source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ HelperContext helperContext = SDOContextHelper.getHelperContext(context, false);
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(helperContext);
+ XMLDocument target = streamHelper.load(source);
+ source.close();
+ return target;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<XMLDocument> getTargetType() {
+ return XMLDocument.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 15;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java
new file mode 100644
index 0000000000..020a8edd7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.sdo.SDOTypes;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * SDO types model resolver that aggregates the SDO type registration for an SCA contribution
+ */
+public class SDOTypesModelResolver implements ModelResolver {
+ private Contribution contribution;
+ private HelperContext helperContext;
+ private List<SDOTypes> sdoTypes = new ArrayList<SDOTypes>();
+ private ContributionFactory contributionFactory;
+ private XSDFactory xsdFactory;
+ private ProcessorContext context;
+
+ public SDOTypesModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ super();
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ if (helperContext == null) {
+ helperContext = SDOUtil.createHelperContext();
+ }
+ this.context = context;
+ SDOTypes types = (SDOTypes)resolved;
+ try {
+ loadSDOTypes(types, contribution.getModelResolver());
+ } catch (ContributionResolveException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ sdoTypes.add(types);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ SDOTypes types = (SDOTypes)resolved;
+
+ return sdoTypes.remove(types);
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ SDOTypes types = (SDOTypes)unresolved;
+ String ns = types.getNamespace();
+ this.context = context;
+ for (SDOTypes t : sdoTypes) {
+ if (t.getNamespace().equals(types.getNamespace())) {
+ try {
+ loadSDOTypes(types, contribution.getModelResolver());
+ } catch (ContributionResolveException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return (T)t;
+ }
+ }
+ return (T)types;
+ }
+
+ private static void register(Class<?> factoryClass, HelperContext helperContext) throws Exception {
+ Field field = factoryClass.getField("INSTANCE");
+ Object factory = field.get(null);
+ Method method = factory.getClass().getMethod("register", new Class[] {HelperContext.class});
+ method.invoke(factory, new Object[] {helperContext});
+ }
+
+ private void defineFromFactory(SDOTypes importSDO, ModelResolver resolver) throws ContributionResolveException {
+ String factoryName = importSDO.getFactory();
+ if (factoryName != null) {
+ ClassReference reference = new ClassReference(factoryName);
+ ClassReference resolved = resolver.resolveModel(ClassReference.class, reference, context);
+ if (resolved != null && !resolved.isUnresolved()) {
+ try {
+ Class<?> factoryClass = resolved.getJavaClass();
+ // Get the namespace
+ Field field = factoryClass.getField("NAMESPACE_URI");
+ importSDO.setNamespace((String)field.get(null));
+ register(factoryClass, helperContext);
+ importSDO.setUnresolved(false);
+ } catch (Exception e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ } else {
+ error(context.getMonitor(), "FailToResolveClass", resolver, factoryName);
+ //ContributionResolveException loaderException =
+ //new ContributionResolveException("Fail to resolve class: " + factoryName);
+ //throw loaderException;
+ }
+ }
+ }
+
+ private void defineFromXSD(SDOTypes importSDO, ModelResolver resolver) throws ContributionResolveException {
+ String location = importSDO.getSchemaLocation();
+ if (location != null) {
+ try {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(location);
+ artifact = resolver.resolveModel(Artifact.class, artifact, context);
+ if (artifact.getLocation() != null) {
+ String wsdlURL = artifact.getLocation();
+ URLConnection connection = new URL(wsdlURL).openConnection();
+ connection.setUseCaches(false);
+ InputStream xsdInputStream = connection.getInputStream();
+ try {
+ XSDHelper xsdHelper = helperContext.getXSDHelper();
+ List<Type> sdoTypes = xsdHelper.define(xsdInputStream, wsdlURL);
+ for (Type t : sdoTypes) {
+ importSDO.setNamespace(t.getURI());
+ break;
+ }
+ importSDO.getTypes().addAll(sdoTypes);
+ } finally {
+ xsdInputStream.close();
+ }
+ importSDO.setUnresolved(false);
+ } else {
+ error(context.getMonitor(), "FailToResolveLocation", resolver, location);
+ //ContributionResolveException loaderException = new ContributionResolveException("Fail to resolve location: " + location);
+ //throw loaderException;
+ }
+ } catch (IOException e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ } else {
+ String ns = importSDO.getNamespace();
+ if (ns != null) {
+ XSDefinition xsd = xsdFactory.createXSDefinition();
+ xsd.setUnresolved(true);
+ xsd.setNamespace(ns);
+ xsd = resolver.resolveModel(XSDefinition.class, xsd, context);
+ if (!xsd.isUnresolved()) {
+ XSDHelper xsdHelper = helperContext.getXSDHelper();
+ xsdHelper.define(xsd.getLocation().toString());
+ }
+ }
+ }
+ }
+
+ private void loadSDOTypes(SDOTypes types, ModelResolver resolver) throws ContributionResolveException {
+ synchronized (types) {
+ if (types.isUnresolved()) {
+ defineFromFactory(types, resolver);
+ defineFromXSD(types, resolver);
+ types.setUnresolved(false);
+ }
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
+ message, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
+ message, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java
new file mode 100644
index 0000000000..b851d38dae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo.xml;
+
+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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.sdo.SDOTypes;
+
+
+/**
+ * Loader that handles &lt;import.sdo&gt; elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDOTypesProcessor implements StAXArtifactProcessor<SDOTypes> {
+
+ public SDOTypesProcessor(ExtensionPointRegistry registry) {
+ }
+
+ public QName getXMLType() {
+ return SDOTypes.SDO_TYPES;
+ }
+
+ public SDOTypes read(XMLStreamReader reader,ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ assert SDOTypes.SDO_TYPES.equals(reader.getName());
+
+ // FIXME: How do we associate the application HelperContext with the one
+ // imported by the composite
+ SDOTypes sdoTypes = new SDOTypes();
+ String factoryName = reader.getAttributeValue(null, "factory");
+ if (factoryName != null) {
+ sdoTypes.setFactory(factoryName);
+ }
+ String location = reader.getAttributeValue(null, "location");
+ if (location != null) {
+ sdoTypes.setSchemaLocation(location);
+ }
+ String ns = reader.getAttributeValue(null, "namespace");
+ sdoTypes.setNamespace(ns);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && SDOTypes.SDO_TYPES.equals(reader.getName())) {
+ break;
+ }
+ }
+ return sdoTypes;
+ }
+
+ public QName getArtifactType() {
+ return SDOTypes.SDO_TYPES;
+ }
+
+ public void write(SDOTypes model, XMLStreamWriter writer,ProcessorContext context) throws ContributionWriteException {
+ try {
+ writer.writeStartElement(SDOTypes.SDO_TYPES.getNamespaceURI(), SDOTypes.SDO_TYPES.getLocalPart());
+ if (model.getNamespace() != null) {
+ writer.writeAttribute("namespace", model.getNamespace());
+ }
+ if (model.getSchemaLocation() != null) {
+ writer.writeAttribute("location", model.getSchemaLocation());
+ }
+ if (model.getFactory() != null) {
+ writer.writeAttribute("factory", model.getFactory());
+ }
+ writer.writeEndElement();
+ } catch (XMLStreamException e) {
+ throw new ContributionWriteException(e);
+ }
+ }
+
+ public Class<SDOTypes> getModelType() {
+ return SDOTypes.class;
+ }
+
+ public void resolve(SDOTypes types, ModelResolver resolver,ProcessorContext context) throws ContributionResolveException {
+ // Defer the resolution to SDOTypesResolver which aggragates the type registrations into an instance of HelperContext
+ resolver.addModel(types,context);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..27fa6e85ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.databinding.sdo.ImportSDOProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#import.sdo,model=org.apache.tuscany.sca.databinding.sdo.ImportSDO
+org.apache.tuscany.sca.databinding.sdo.xml.SDOTypesProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#sdo.types,model=org.apache.tuscany.sca.databinding.sdo.SDOTypes
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..6252de51c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.databinding.sdo.xml.SDOTypesModelResolver;model=org.apache.tuscany.sca.databinding.sdo.SDOTypes \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
new file mode 100644
index 0000000000..5ae557cc74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
@@ -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 classes for the databindings
+org.apache.tuscany.sca.databinding.sdo.SDODataBinding;name=commonj.sdo.DataObject
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..b1916fd32a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation classes for the transformers
+org.apache.tuscany.sca.databinding.sdo.DataObject2String;source=commonj.sdo.DataObject,target=java.lang.String,weight=510
+org.apache.tuscany.sca.databinding.sdo.DataObject2XMLStreamReader;source=commonj.sdo.DataObject,target=javax.xml.stream.XMLStreamReader,weight=490
+org.apache.tuscany.sca.databinding.sdo.XMLDocument2String;source=commonj.sdo.helper.XMLDocument,target=java.lang.String,weight=510
+org.apache.tuscany.sca.databinding.sdo.String2DataObject;source=java.lang.String,target=commonj.sdo.DataObject,weight=500
+org.apache.tuscany.sca.databinding.sdo.XMLDocument2XMLStreamReader;source=commonj.sdo.helper.XMLDocument,target=javax.xml.stream.XMLStreamReader,weight=490
+org.apache.tuscany.sca.databinding.sdo.XMLStreamReader2DataObject;source=javax.xml.stream.XMLStreamReader,target=commonj.sdo.DataObject,weight=490
+org.apache.tuscany.sca.databinding.sdo.XMLStreamReader2XMLDocument;source=javax.xml.stream.XMLStreamReader,target=commonj.sdo.helper.XMLDocument,weight=490
+org.apache.tuscany.sca.databinding.sdo.DataObject2Node;source=commonj.sdo.DataObject,target=org.w3c.dom.Node,weight=500
+org.apache.tuscany.sca.databinding.sdo.Node2DataObject;source=org.w3c.dom.Node,target=commonj.sdo.DataObject,weight=500
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/databinding-sdo-validation-messages.properties b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/databinding-sdo-validation-messages.properties
new file mode 100644
index 0000000000..f53f08f377
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/main/resources/databinding-sdo-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+FailToResolveClass = Fail to resolve class: {0}
+FailToResolveLocation = Fail to resolve location: {0}
+ContributionResolveException = ContributionResolveException occured due to:
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.java
new file mode 100644
index 0000000000..5a0208b290
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/com/example/stock/sdo/fault/InvalidSymbolFault_Exception.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 com.example.stock.sdo.fault;
+
+import javax.xml.namespace.QName;
+
+import com.example.stock.sdo.InvalidSymbolFault;
+
+/**
+ * Hand-crafted java exception for SDO fault
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidSymbolFault_Exception extends Exception {
+ private static final long serialVersionUID = 8602157311925253920L;
+
+ /**
+ * Generated QName for the fault element
+ */
+ public static final QName FAULT_ELEMENT = new QName("http://www.example.com/stock", "InvalidSymbolFault");
+ /**
+ * Java type that goes as soapenv:Fault detail element.
+ */
+ private InvalidSymbolFault faultInfo;
+
+ /**
+ * @param faultInfo
+ * @param message
+ */
+ public InvalidSymbolFault_Exception(String message, InvalidSymbolFault faultInfo) {
+ super(message);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @param faultInfo
+ * @param message
+ * @param cause
+ */
+ public InvalidSymbolFault_Exception(String message, InvalidSymbolFault faultInfo, Throwable cause) {
+ super(message, cause);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @return returns fault bean:
+ * org.apache.tuscany.sca.test.exceptions.impl.jaxb.InvalidSymbolFault
+ */
+ public InvalidSymbolFault getFaultInfo() {
+ return faultInfo;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2NodeTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2NodeTestCase.java
new file mode 100644
index 0000000000..012af9ed1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2NodeTestCase.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.sca.databinding.sdo;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import commonj.sdo.DataObject;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataObject2NodeTestCase extends SDOTransformerTestCaseBase {
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataTypeImpl<XMLType>(binding, PurchaseOrderType.class, new XMLType(ORDER_QNAME, null));
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataTypeImpl<Class<String>>(String.class, String.class);
+ }
+
+ public final void testTransform() {
+ Node node = new DataObject2Node().transform(dataObject, context);
+ Assert.assertNotNull(node);
+ Element element = (Element) node;
+ Assert.assertEquals(ORDER_QNAME.getNamespaceURI(), element.getNamespaceURI());
+ Assert.assertEquals(ORDER_QNAME.getLocalPart(), element.getLocalName());
+ DataObject po = new Node2DataObject(new DefaultExtensionPointRegistry()).transform(node, reversedContext);
+ Assert.assertTrue(po instanceof PurchaseOrderType);
+ PurchaseOrderType orderType = (PurchaseOrderType)po;
+ Assert.assertEquals("San Jose", orderType.getBillTo().getCity());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2StringTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2StringTestCase.java
new file mode 100644
index 0000000000..44d11cd586
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2StringTestCase.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.sca.databinding.sdo;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import commonj.sdo.DataObject;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataObject2StringTestCase extends SDOTransformerTestCaseBase {
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataTypeImpl<XMLType>(binding, PurchaseOrderType.class, new XMLType(ORDER_QNAME, null));
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataTypeImpl<Class<String>>(String.class, String.class);
+ }
+
+ public final void testTransform() {
+ String xml = new DataObject2String().transform(dataObject, context);
+ Assert.assertTrue(xml.indexOf("<city>San Jose</city>") != -1);
+ DataObject po = new String2DataObject().transform(xml, reversedContext);
+ Assert.assertTrue(po instanceof PurchaseOrderType);
+ PurchaseOrderType orderType = (PurchaseOrderType)po;
+ Assert.assertEquals("San Jose", orderType.getBillTo().getCity());
+ }
+
+ public final void testXML() {
+ String xml =
+ "<foo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ + "xmlns:ipo=\"http://www.example.com/IPO\" xsi:type=\"ipo:USAddress\"/>";
+ DataObject dataObject = new String2DataObject().transform(xml, reversedContext);
+ context.setSourceDataType(new DataTypeImpl<XMLType>(DataObject.class.getName(), DataObject.class, null));
+ xml = new DataObject2String().transform(dataObject, context);
+ Assert.assertTrue(xml.contains("xsi:type=\"ipo:USAddress\""));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReaderTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReaderTestCase.java
new file mode 100644
index 0000000000..c2a9f46059
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReaderTestCase.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.sca.databinding.sdo;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.Node2String;
+import org.apache.tuscany.sca.databinding.xml.XMLStreamReader2Node;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.EqualityHelper;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataObject2XMLStreamReaderTestCase extends SDOTransformerTestCaseBase {
+
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataTypeImpl<XMLType>(binding, PurchaseOrderType.class, new XMLType(ORDER_QNAME, null));
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataTypeImpl<Class<XMLStreamReader>>(XMLStreamReader.class, XMLStreamReader.class);
+ }
+
+ public final void testTransform() throws XMLStreamException {
+ XMLStreamReader reader = new DataObject2XMLStreamReader().transform(dataObject, context);
+ while (reader.hasNext()) {
+ int event = reader.next();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ break;
+ }
+ }
+ DataObject d = new XMLStreamReader2DataObject().transform(reader, reversedContext);
+ assertNotNull(d);
+ assertTrue(EqualityHelper.INSTANCE.equal(dataObject, d));
+ }
+
+ public final void testTransform1() throws XMLStreamException {
+ XMLStreamReader reader = new DataObject2XMLStreamReader().transform(dataObject, context);
+ XMLStreamReader2Node t2 = new XMLStreamReader2Node(new DefaultExtensionPointRegistry());
+ org.w3c.dom.Node node = t2.transform(reader, context);
+ assertNotNull(node);
+ Node2String t3 = new Node2String(new DefaultExtensionPointRegistry());
+ String xml = t3.transform(node, context);
+ assertTrue(xml.contains("xmlns:xsi"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java
new file mode 100644
index 0000000000..1fcae3cb73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.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.sca.databinding.sdo;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.example.ipo.sdo.SdoFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImportSDOProcessorTestCase {
+ private static boolean inited;
+
+ private static ExtensionPointRegistry registry;
+ private static ImportSDOProcessor loader;
+ private static XMLInputFactory xmlFactory;
+
+ @Test
+ public void testMinimal() throws Exception {
+ String xml = "<import.sdo xmlns='http://tuscany.apache.org/xmlns/sca/1.1'/>";
+ XMLStreamReader reader = getReader(xml);
+ assertTrue(loader.read(reader, new ProcessorContext(registry)) instanceof ImportSDO);
+ }
+
+ @Test
+ public void testLocation() throws Exception {
+ String xml = "<import.sdo xmlns='http://tuscany.apache.org/xmlns/sca/1.1' location='ipo.xsd'/>";
+ XMLStreamReader reader = getReader(xml);
+ assertTrue(loader.read(reader, new ProcessorContext(registry)) instanceof ImportSDO);
+ }
+
+ @Test
+ public void testFactory() throws Exception {
+ String xml = "<import.sdo xmlns='http://tuscany.apache.org/xmlns/sca/1.1' " + "factory='"
+ + MockFactory.class.getName()
+ + "'/>";
+ XMLStreamReader reader = getReader(xml);
+ assertFalse(inited);
+ ProcessorContext context = new ProcessorContext(registry);
+ ImportSDO importSDO = loader.read(reader, context);
+ assertNotNull(importSDO);
+ ModelResolver resolver = new TestModelResolver();
+ resolver.addModel(new ClassReference(MockFactory.class), context);
+ loader.resolve(importSDO, resolver, context);
+ assertTrue(inited);
+ }
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ registry = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ loader = new ImportSDOProcessor(registry);
+ xmlFactory = factories.getFactory(XMLInputFactory.class);
+ }
+
+ protected XMLStreamReader getReader(String xml) throws XMLStreamException {
+ XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(xml));
+ reader.next();
+ return reader;
+ }
+
+ public static class MockFactory {
+ public static final Object INSTANCE = SdoFactory.INSTANCE;
+
+ static {
+ ImportSDOProcessorTestCase.inited = true;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelperTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelperTestCase.java
new file mode 100644
index 0000000000..e0d1c9bf12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOContextHelperTestCase.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.sdo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.junit.Test;
+
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SDOContextHelperTestCase {
+ @Test
+ public void testGenerateSchema() throws IOException {
+ HelperContext context = SDOUtil.createHelperContext();
+ URL url = getClass().getResource("/ipo.xsd");
+ Assert.assertNotNull(url);
+ InputStream is = url.openStream();
+ XSDHelper xsdHelper = context.getXSDHelper();
+ xsdHelper.define(is, url.toExternalForm());
+ TypeHelper typeHelper = context.getTypeHelper();
+ Type type = typeHelper.getType("http://www.example.com/IPO", "PurchaseOrderType");
+ Assert.assertNotNull(type);
+ /*
+ SDOContextHelper.generateSchema(context, Arrays.asList(type));
+ */
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDODataBindingTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDODataBindingTestCase.java
new file mode 100644
index 0000000000..400b424a97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDODataBindingTestCase.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import com.example.ipo.sdo.SdoFactory;
+import com.example.ipo.sdo.USAddress;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDODataBindingTestCase extends TestCase {
+ protected static final QName ORDER_QNAME = new QName("http://www.example.com/IPO", "purchaseOrder");
+ private SDODataBinding binding;
+ private HelperContext context;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ binding = new SDODataBinding(new DefaultExtensionPointRegistry());
+ context = HelperProvider.getDefaultContext();
+ SdoFactory.INSTANCE.register(context);
+ }
+
+ public final void testIntrospect() {
+ Operation op = null;
+ DataType dataType = new DataTypeImpl<Class>(DataObject.class, null);
+ boolean yes = binding.introspect(dataType, op);
+ assertTrue(yes);
+ assertTrue(dataType.getDataBinding().equals(binding.getName()));
+ assertTrue(dataType.getPhysical() == DataObject.class && dataType.getLogical() == XMLType.UNKNOWN);
+ dataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
+ yes = binding.introspect(dataType, op);
+ assertTrue(yes);
+ assertEquals(PurchaseOrderType.class, dataType.getPhysical());
+ assertEquals(new QName("http://www.example.com/IPO", "PurchaseOrderType"), ((XMLType)dataType.getLogical())
+ .getTypeName());
+ dataType = new DataTypeImpl<Class>(USAddress.class, null);
+ yes = binding.introspect(dataType, op);
+ assertTrue(yes);
+ assertEquals(USAddress.class, dataType.getPhysical());
+ assertEquals(new QName("http://www.example.com/IPO", "USAddress"), ((XMLType)dataType.getLogical())
+ .getTypeName());
+ }
+
+ public final void testCopyRoot() {
+ PurchaseOrderType po = SdoFactory.INSTANCE.createPurchaseOrderType();
+ po.setComment("Comment");
+ Object copy = binding.copy(po, null, null, null, null);
+ assertTrue(copy instanceof PurchaseOrderType);
+ assertTrue(po != copy);
+ assertTrue(context.getEqualityHelper().equal((DataObject)po, (DataObject)copy));
+ assertEquals("Comment", ((PurchaseOrderType)copy).getComment());
+ }
+
+ public final void testCopyNonRoot() {
+ USAddress address = SdoFactory.INSTANCE.createUSAddress();
+ address.setCity("San Jose");
+ Object copy = binding.copy(address, null, null, null, null);
+ assertTrue(copy instanceof USAddress);
+ assertTrue(address != copy);
+ assertTrue(context.getEqualityHelper().equal((DataObject)address, (DataObject)copy));
+ assertEquals("San Jose", ((USAddress)copy).getCity());
+ }
+
+ public final void testCopyXMLDocument() {
+ PurchaseOrderType po = SdoFactory.INSTANCE.createPurchaseOrderType();
+ po.setComment("Comment");
+ XMLDocument doc =
+ context.getXMLHelper().createDocument((DataObject)po,
+ ORDER_QNAME.getNamespaceURI(),
+ ORDER_QNAME.getLocalPart());
+ Object copy = binding.copy(doc, null, null, null, null);
+ assertTrue(copy instanceof XMLDocument);
+ XMLDocument docCopy = (XMLDocument)copy;
+ assertTrue(doc != copy);
+ assertTrue(context.getEqualityHelper().equal((DataObject)po, docCopy.getRootObject()));
+ assertEquals("Comment", ((PurchaseOrderType)docCopy.getRootObject()).getComment());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOTransformerTestCaseBase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOTransformerTestCaseBase.java
new file mode 100644
index 0000000000..4d415f2895
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOTransformerTestCaseBase.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import com.example.ipo.sdo.SdoFactory;
+import com.example.ipo.sdo.USAddress;
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ * The base class for SDO-related test cases
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class SDOTransformerTestCaseBase extends TestCase {
+ protected static final QName ORDER_QNAME = new QName("http://www.example.com/IPO", "purchaseOrder");
+
+ protected HelperContext helperContext;
+ protected String binding = DataObject.class.getName();
+ protected TransformationContext context;
+ protected TransformationContext reversedContext;
+ protected DataObject dataObject;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ new SDODataBinding(new DefaultExtensionPointRegistry());
+ helperContext = HelperProvider.getDefaultContext();
+ SdoFactory.INSTANCE.register(helperContext);
+
+ context = new TransformationContextImpl();
+ context.setSourceDataType(getSourceDataType());
+ context.setTargetDataType(getTargetDataType());
+
+ reversedContext = new TransformationContextImpl();
+ reversedContext.setSourceDataType(getTargetDataType());
+ reversedContext.setTargetDataType(getSourceDataType());
+
+ PurchaseOrderType po = SdoFactory.INSTANCE.createPurchaseOrderType();
+ USAddress address = SdoFactory.INSTANCE.createUSAddress();
+ address.setCity("San Jose");
+ address.setStreet("123 ABC St");
+ address.setState("CA");
+ address.setStreet("95131");
+ po.setBillTo(address);
+ dataObject = (DataObject) po;
+ }
+
+ protected abstract DataType<?> getSourceDataType();
+
+ protected abstract DataType<?> getTargetDataType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java
new file mode 100644
index 0000000000..2326d1b93b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.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.sca.databinding.sdo;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SDOWrapperHandlerTestCase extends TestCase {
+ private HelperContext context;
+ private SDOWrapperHandler handler;
+
+ @Override
+ public void setUp() throws Exception {
+ new SDODataBinding(new DefaultExtensionPointRegistry());
+ context = SDOUtil.createHelperContext();
+ handler = new SDOWrapperHandler();
+ }
+
+ public void testWrapperAnyType() throws Exception {
+ XMLHelper xmlHelper = context.getXMLHelper();
+ XMLDocument document = xmlHelper.load(getClass().getResourceAsStream("/wrapper.xml"));
+ Operation op = new OperationImpl();
+ List children = handler.getChildren(document, op, true);
+ assertEquals(5, children.size());
+ }
+
+ public void testWrapper() throws Exception {
+ XSDHelper xsdHelper = context.getXSDHelper();
+ xsdHelper.define(getClass().getResourceAsStream("/wrapper.xsd"), null);
+ XMLHelper xmlHelper = context.getXMLHelper();
+ XMLDocument document = xmlHelper.load(getClass().getResourceAsStream("/wrapper.xml"));
+ Operation op = new OperationImpl();
+ List children = handler.getChildren(document, op, true);
+ assertEquals(5, children.size());
+ }
+
+ public void testCreate() {
+ HelperContext context = HelperProvider.getDefaultContext();
+ XSDHelper xsdHelper = context.getXSDHelper();
+ xsdHelper.define(getClass().getResourceAsStream("/wrapper.xsd"), null);
+ ElementInfo element = new ElementInfo(new QName("http://www.example.com/wrapper", "op"), null);
+ Operation op = new OperationImpl();
+ WrapperInfo wrapperInfo = new WrapperInfo(SDODataBinding.NAME, element, null, null, null);
+ op.setWrapper(wrapperInfo);
+ DataObject wrapper = (DataObject) handler.create(op, true);
+ assertNotNull(wrapper);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/TestModelResolver.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/TestModelResolver.java
new file mode 100644
index 0000000000..3f742b49a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/TestModelResolver.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+
+/**
+ * A default implementation of an artifact resolver, based on a map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestModelResolver implements ModelResolver {
+ private static final long serialVersionUID = -7826976465762296634L;
+
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ public TestModelResolver() {
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+
+ // Return the resolved object
+ return modelClass.cast(resolved);
+
+ } else {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(resolved);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2XMLStreamReaderTestCase.java b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2XMLStreamReaderTestCase.java
new file mode 100644
index 0000000000..2beadc5b61
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/XMLDocument2XMLStreamReaderTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.sdo;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import commonj.sdo.helper.XMLDocument;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLDocument2XMLStreamReaderTestCase extends SDOTransformerTestCaseBase {
+
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataTypeImpl<XMLType>(XMLDocument.class.getName(), XMLDocument.class, new XMLType(ORDER_QNAME, null));
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataTypeImpl<Class<XMLStreamReader>>(XMLStreamReader.class, XMLStreamReader.class);
+ }
+
+ public final void testTransform() throws XMLStreamException {
+ XMLDocument document =
+ helperContext.getXMLHelper().createDocument(dataObject,
+ ORDER_QNAME.getNamespaceURI(),
+ ORDER_QNAME.getLocalPart());
+ XMLStreamReader reader = new XMLDocument2XMLStreamReader().transform(document, context);
+ XMLDocument document2 = new XMLStreamReader2XMLDocument().transform(reader, reversedContext);
+ Assert.assertEquals(ORDER_QNAME.getNamespaceURI(), document2.getRootElementURI());
+ Assert.assertEquals(ORDER_QNAME.getLocalPart(), document2.getRootElementName());
+ Assert.assertTrue(document2.getRootObject() instanceof PurchaseOrderType);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/ipo.xsd b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..241ec15d36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/stock.xsd b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/stock.xsd
new file mode 100644
index 0000000000..a0a6717371
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/stock.xsd
@@ -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.
+-->
+<schema targetNamespace="http://www.example.com/stock" xmlns="http://www.w3.org/2001/XMLSchema">
+ <!-- Faults -->
+ <element name="InvalidSymbolFault">
+ <complexType>
+ <sequence>
+ <element name="message" minOccurs="1" type="string" />
+ <element name="symbol" minOccurs="1" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="MarketClosedFault" type="string" />
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/wrapper.xml b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/wrapper.xml
new file mode 100644
index 0000000000..2526629409
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/wrapper.xml
@@ -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.
+-->
+<p:op xmlns:p="http://www.example.com/wrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.example.com/wrapper wrapper.xsd ">
+ <message>message</message>
+ <symbol>symbol</symbol>
+ <message>message1</message>
+ <symbol>symbol1</symbol>
+ <symbol>symbol2</symbol>
+</p:op>
diff --git a/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/wrapper.xsd b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/wrapper.xsd
new file mode 100644
index 0000000000..ea4dc5f7f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding-sdo/src/test/resources/wrapper.xsd
@@ -0,0 +1,38 @@
+<?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.
+-->
+<schema targetNamespace="http://www.example.com/wrapper" xmlns="http://www.w3.org/2001/XMLSchema">
+ <!-- Faults -->
+ <element name="op">
+ <complexType>
+ <sequence maxOccurs="unbounded">
+ <element name="message" minOccurs="1" type="string" />
+ <element name="symbol" minOccurs="1" maxOccurs="3" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="opResponse">
+ <complexType>
+ <sequence maxOccurs="1">
+ <element name="price" minOccurs="1" maxOccurs="unbounded" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/databinding/LICENSE b/sandbox/sebastien/java/embed/modules/databinding/LICENSE
new file mode 100644
index 0000000000..616bec99ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/LICENSE
@@ -0,0 +1,244 @@
+
+ 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.
+
+-----------------------------------------------------------------
+The test cases use xmlunit with the following license:
+-----------------------------------------------------------------
+
+/*
+******************************************************************
+Copyright (c) 2001-2007, Jeff Martin, Tim Bacon
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of the xmlunit.sourceforge.net nor the names
+ of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+******************************************************************
+*/
+
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/databinding/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..8fed859030
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/META-INF/MANIFEST.MF
@@ -0,0 +1,71 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.databinding;uses:="org.apache.t
+ uscany.sca.interfacedef.util,org.apache.tuscany.sca.databinding.impl,
+ org.apache.tuscany.sca.interfacedef,org.apache.tuscany.sca.extensibil
+ ity,javax.xml.namespace,org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.interfacedef.impl,org.apache.tuscany.sca.xsd";
+ version="2.0.0",org.apache.tuscany.sca.databinding.xml;uses:="org.apach
+ e.tuscany.sca.databinding,org.apache.tuscany.sca.interfacedef.util,or
+ g.apache.tuscany.sca.databinding.impl,javax.xml.parsers,javax.xml.tra
+ nsform.dom,org.w3c.dom,org.apache.tuscany.sca.interfacedef,org.xml.sa
+ x,javax.xml.namespace,javax.xml.stream,javax.xml.stream.util,org.xml.
+ sax.ext,javax.xml.transform,javax.xml.transform.stream,org.apache.tus
+ cany.sca.interfacedef.impl,javax.xml.transform.sax,org.apache.tuscany
+ .sca.databinding.javabeans,org.xml.sax.helpers";version="2.0.0",org.apa
+ che.tuscany.sca.databinding.impl;uses:="org.apache.tuscany.sca.databi
+ nding,org.apache.tuscany.sca.interfacedef.util,javax.xml.parsers,org.
+ apache.tuscany.sca.interfacedef,org.w3c.dom,javax.xml.datatype,javax.
+ xml.namespace,javax.xml.transform,org.apache.tuscany.sca.interfacedef
+ .impl";version="2.0.0",org.apache.tuscany.sca.databinding.util;uses:="o
+ rg.apache.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.interf
+ acedef";version="2.0.0",org.apache.tuscany.sca.databinding.annotation;v
+ ersion="2.0.0",org.apache.tuscany.sca.databinding.javabeans;uses:="org.
+ apache.tuscany.sca.databinding,org.apache.tuscany.sca.databinding.xml
+ ,org.apache.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.data
+ binding.impl,javax.xml.parsers,org.w3c.dom,org.apache.tuscany.sca.int
+ erfacedef,javax.xml.datatype,javax.xml.namespace,javax.xml.stream";ve
+ rsion="2.0.0"
+Private-Package: org.apache.tuscany.sca.databinding.externalizable;ver
+ sion="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA DataBinding Framework
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA DataBinding Framework
+Import-Package: javax.xml.datatype,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.stream.util,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.sax,
+ javax.xml.transform.stream,
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.sax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax.reader;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.annotation;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.databinding.util;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.ext,
+ org.xml.sax.helpers
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/databinding/NOTICE b/sandbox/sebastien/java/embed/modules/databinding/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding/pom.xml b/sandbox/sebastien/java/embed/modules/databinding/pom.xml
new file mode 100644
index 0000000000..354d31c05a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/pom.xml
@@ -0,0 +1,97 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding</artifactId>
+ <name>Apache Tuscany SCA DataBinding Framework</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+<!--
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/BaseDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/BaseDataBinding.java
new file mode 100644
index 0000000000..aa019ebdcf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/BaseDataBinding.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding;
+
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Base Implementation of DataBinding
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class BaseDataBinding implements DataBinding {
+
+ private Class<?> baseType;
+
+ private String name;
+
+ /**
+ * Create a databinding with the base java type whose name will be used as
+ * the name of the databinding
+ *
+ * @param baseType The base java class or interface representing the
+ * databinding, for example, org.w3c.dom.Node
+ */
+ protected BaseDataBinding(Class<?> baseType) {
+ this(baseType.getName(), baseType);
+ }
+
+ /**
+ * Create a databinding with the name and base java type
+ *
+ * @param name The name of the databinding
+ * @param baseType The base java class or interface representing the
+ * databinding, for example, org.w3c.dom.Node
+ */
+ protected BaseDataBinding(String name, Class<?> baseType) {
+ this.name = name;
+ this.baseType = baseType;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean introspect(DataType type, Operation operation) {
+ assert type != null;
+ Class cls = type.getPhysical();
+ if (baseType != null && baseType.isAssignableFrom(cls)) {
+ type.setDataBinding(getName());
+ if (type.getLogical() == null) {
+ type.setLogical(XMLType.UNKNOWN);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public DataType introspect(Object value, Operation operation) {
+ if (value == null) {
+ return null;
+ } else {
+ DataType<Class> dataType = new DataTypeImpl<Class>(value.getClass(), value.getClass());
+ if (introspect(dataType, (Operation) null)) {
+ return dataType;
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.DataBinding#getWrapperHandler()
+ */
+ public WrapperHandler getWrapperHandler() {
+ return null;
+ }
+
+ public Object copy(Object object, DataType sourceDataType, DataType targetDataType, Operation sourceOperation, Operation targetOperation) {
+ return object;
+ }
+
+ public XMLTypeHelper getXMLTypeHelper() {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/BaseTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/BaseTransformer.java
new file mode 100644
index 0000000000..f5b92de2fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/BaseTransformer.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.databinding;
+
+
+/**
+ * Base Implementation of Transformer which provides the registration to the
+ * transformer registry
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class BaseTransformer<S, T> implements Transformer {
+
+ protected BaseTransformer() {
+ super();
+ }
+
+ protected abstract Class<S> getSourceType();
+
+ protected abstract Class<T> getTargetType();
+
+ public String getSourceDataBinding() {
+ return getSourceType().getName();
+ }
+
+ public String getTargetDataBinding() {
+ return getTargetType().getName();
+ }
+
+ public int getWeight() {
+ // default to 50
+ return 50;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java
new file mode 100644
index 0000000000..fd5cf4ac1d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding;
+
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * DataBinding represents a data representation, for example, SDO, JAXB and AXIOM
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface DataBinding {
+ /**
+ * A special databinding for input message of an operation
+ */
+ String IDL_INPUT = "idl:input";
+ /**
+ * A special databinding for output message of an operation
+ */
+ String IDL_OUTPUT = "idl:output";
+ /**
+ * A special databinding for fault message of an operation
+ */
+ String IDL_FAULT = "idl:fault";
+ /**
+ * The name of a databinding should be case-insensitive and unique
+ *
+ * @return The name of the databinding
+ */
+ String getName();
+
+ /**
+ * Introspect and populate information to a DataType model
+ *
+ * @param dataType The data type to be introspected
+ * @param operation The operation
+ * @return true if the databinding has recognized the given data type
+ */
+ boolean introspect(DataType dataType, Operation operation);
+
+ /**
+ * Introspect the data to figure out the corresponding data type
+ *
+ * @param value The object to be checked
+ * @param operation The operation
+ * @return The DataType or null if the java type is not supported by this databinding
+ */
+ DataType introspect(Object value, Operation operation);
+
+ /**
+ * Provide a WrapperHandler for this databinding
+ * @return A wrapper handler which can handle wrapping/wrapping for this databinding
+ */
+ WrapperHandler getWrapperHandler();
+
+ /**
+ * Make a copy of the object for "pass-by-value" semantics and cross classloader invocations.
+ *
+ * @param object source object to copy
+ * @param sourceDataType The source data type
+ * @param targetDataType the target data type
+ * @param sourceOperation The source operation
+ * @param targetOperation The target operation
+ * @return copy of the object passed in as argument
+ */
+ Object copy(Object object, DataType sourceDataType, DataType targetDataType, Operation sourceOperation, Operation targetOperation);
+
+ /**
+ * Get the XML type helper for Java types
+ * @return The databinding-specific XML type helper class
+ */
+ XMLTypeHelper getXMLTypeHelper();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingContext.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingContext.java
new file mode 100644
index 0000000000..c77d0ad0f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingContext.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * The context for databinding processing
+ */
+public class DataBindingContext {
+
+ private String contentType;
+ private Class<?> type;
+ private Type genericType;
+ private Annotation[] annotations;
+ private Operation operation;
+
+ public DataBindingContext(Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ Operation operation,
+ String contentType) {
+ super();
+ this.type = type;
+ this.genericType = genericType;
+ this.annotations = annotations;
+ this.operation = operation;
+ this.contentType = contentType;
+ }
+
+ public DataBindingContext(Class<?> type, Type genericType, Annotation[] annotations) {
+ super();
+ this.type = type;
+ this.genericType = genericType;
+ this.annotations = annotations;
+ }
+
+ public DataBindingContext(Class<?> type) {
+ super();
+ this.type = type;
+ this.genericType = type;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public Type getGenericType() {
+ return genericType;
+ }
+
+ public Annotation[] getAnnotations() {
+ return annotations;
+ }
+
+ public Operation getOperation() {
+ return operation;
+ }
+
+ public <A extends Annotation> A getAnnotation(Class<A> type) {
+ if (annotations == null) {
+ return null;
+ }
+ for (Annotation a : annotations) {
+ if (a.annotationType() == type) {
+ return type.cast(a);
+ }
+ }
+ return null;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java
new file mode 100644
index 0000000000..ff3afd8181
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.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.sca.databinding;
+
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * An extension point for data binding extensions.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface DataBindingExtensionPoint {
+
+ /**
+ * Register a data binding
+ *
+ * @param dataBinding
+ */
+ void addDataBinding(DataBinding dataBinding);
+
+ /**
+ * Look up a data binding by id
+ *
+ * @param id The name of the databinding
+ * @return The databinding
+ */
+ DataBinding getDataBinding(String id);
+
+ /**
+ * Unregister a data binding
+ *
+ * @param id
+ * @return The unregistered databinding
+ */
+ DataBinding removeDataBinding(String id);
+
+ /**
+ * Introspect the java class to figure out what DataType supports it.
+ *
+ * @param dataType The initial data type
+ * @param operation TODO
+ * @return A DataType representing the java type or null if no databinding
+ * recognizes the java type
+ */
+ boolean introspectType(DataType dataType, Operation operation);
+
+ /**
+ * Introspect the value to figure out the corresponding DataType
+ *
+ * @param value The object value
+ * @param operation TODO
+ * @return A DataType representing the value or null if no databinding
+ * recognizes the value
+ */
+ DataType introspectType(Object value, Operation operation);
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipe.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipe.java
new file mode 100644
index 0000000000..505a810276
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipe.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.sca.databinding;
+
+/**
+ * Data pipe allows a data source pushes data into its sink and pipe the data into its result
+ *
+ * @param <S> The data binding type of the sink
+ * @param <R> The data binding type of the result
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DataPipe<S, R> {
+
+ /**
+ * Returns a sink (for example, java.io.OutputStream, java.io.Writer or org.xml.sax.ContentHandler) to receive data
+ * pushed by the source
+ *
+ * @return The sink to consume data
+ */
+ S getSink();
+
+ /**
+ * Returns the data populated by the sink
+ *
+ * @return
+ */
+ R getResult();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipeTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipeTransformer.java
new file mode 100644
index 0000000000..1aac6d48be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipeTransformer.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding;
+
+/**
+ * Data pipe allows a data source pushes data into its sink and pipe the data into its result
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DataPipeTransformer<S, R> extends Transformer {
+
+ DataPipe<S, R> newInstance();
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
new file mode 100644
index 0000000000..22b6e8646e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.databinding.javabeans.JavaExceptionDataBinding;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * The default implementation of a data binding extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultDataBindingExtensionPoint implements DataBindingExtensionPoint {
+ private ExtensionPointRegistry registry;
+ private final Map<String, DataBinding> bindings = new HashMap<String, DataBinding>();
+ private final List<DataBinding> databindings = new ArrayList<DataBinding>();
+ private static final Logger logger = Logger.getLogger(DefaultDataBindingExtensionPoint.class.getName());
+ private boolean loadedDataBindings;
+
+// public DefaultDataBindingExtensionPoint() {
+// }
+
+ public DefaultDataBindingExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public DataBinding getDataBinding(String id) {
+ if (id == null) {
+ return null;
+ }
+ loadDataBindings();
+ DataBinding dataBinding = bindings.get(id.toLowerCase());
+ if (dataBinding == null) {
+ loadDataBindings();
+ dataBinding = bindings.get(id.toLowerCase());
+ }
+ return dataBinding;
+ }
+
+ public void addDataBinding(DataBinding dataBinding) {
+ if (logger.isLoggable(Level.FINE)) {
+ String className = dataBinding.getClass().getName();
+ boolean lazy = false;
+ if (dataBinding instanceof LazyDataBinding) {
+ className = ((LazyDataBinding)dataBinding).dataBindingDeclaration.getClassName();
+ lazy = true;
+ }
+ logger.fine("Adding databinding: " + className + ";name=" + dataBinding.getName() + ",lazy=" + lazy);
+ }
+ databindings.add(dataBinding);
+ bindings.put(dataBinding.getName().toLowerCase(), dataBinding);
+
+ }
+
+ public DataBinding removeDataBinding(String id) {
+ if (id == null) {
+ return null;
+ }
+ DataBinding dataBinding = bindings.remove(id.toLowerCase());
+ if (dataBinding != null) {
+ databindings.remove(dataBinding);
+ }
+ return dataBinding;
+ }
+
+ /**
+ * Dynamically load data bindings declared under META-INF/services
+ */
+ private synchronized void loadDataBindings() {
+ if (loadedDataBindings)
+ return;
+
+ // Get the databinding service declarations
+ Collection<ServiceDeclaration> dataBindingDeclarations;
+ try {
+ dataBindingDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DataBinding.class.getName());
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Load data bindings
+ for (ServiceDeclaration dataBindingDeclaration : dataBindingDeclarations) {
+ Map<String, String> attributes = dataBindingDeclaration.getAttributes();
+ String name = attributes.get("name");
+
+ // Create a data binding wrapper and register it
+ DataBinding dataBinding = new LazyDataBinding(name, dataBindingDeclaration);
+ addDataBinding(dataBinding);
+ }
+
+ loadedDataBindings = true;
+ }
+
+ /**
+ * A data binding facade allowing data bindings to be lazily loaded and
+ * initialized.
+ */
+ private class LazyDataBinding implements DataBinding {
+
+ private String name;
+ private ServiceDeclaration dataBindingDeclaration;
+ private DataBinding dataBinding;
+
+ private LazyDataBinding(String type, ServiceDeclaration dataBindingDeclaration) {
+ this.name = type;
+ this.dataBindingDeclaration = dataBindingDeclaration;
+ }
+
+ /**
+ * Load and instantiate the data binding class.
+ *
+ * @return The data binding.
+ */
+ @SuppressWarnings("unchecked")
+ private DataBinding getDataBinding() {
+ if (dataBinding == null) {
+ try {
+ Class<DataBinding> dataBindingClass = (Class<DataBinding>)dataBindingDeclaration.loadClass();
+ try {
+ Constructor<DataBinding> constructor = dataBindingClass.getConstructor();
+ dataBinding = constructor.newInstance();
+ } catch (NoSuchMethodException e) {
+ Constructor<DataBinding> constructor =
+ dataBindingClass.getConstructor(ExtensionPointRegistry.class);
+ dataBinding = constructor.newInstance(DefaultDataBindingExtensionPoint.this.registry);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return dataBinding;
+ }
+
+ public Object copy(Object object, DataType sourceDataType, DataType targetDataType, Operation sourceOperation, Operation targetOperation) {
+ return getDataBinding().copy(object, sourceDataType, targetDataType, sourceOperation, targetOperation);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public XMLTypeHelper getXMLTypeHelper() {
+ return getDataBinding().getXMLTypeHelper();
+ }
+
+ public WrapperHandler getWrapperHandler() {
+ return getDataBinding().getWrapperHandler();
+ }
+
+ public boolean introspect(DataType dataType, Operation operation) {
+ return getDataBinding().introspect(dataType, operation);
+ }
+
+ public DataType introspect(Object value, Operation operation) {
+ return getDataBinding().introspect(value, operation);
+ }
+ }
+
+ //FIXME The following methods should not be on the extension point
+ // they should be on a separate class
+ public boolean introspectType(DataType dataType, Operation operation) {
+ loadDataBindings();
+ for (DataBinding binding : databindings) {
+ // don't introspect for JavaBeansDatabinding as all javatypes will
+ // anyways match to its basetype
+ // which is java.lang.Object. Default to this only if no databinding
+ // results
+ if (!binding.getName().equals(JavaBeansDataBinding.NAME)) {
+ if (binding.introspect(dataType, operation)) {
+ return true;
+ }
+ }
+ }
+ // FIXME: Should we honor the databinding from operation/interface
+ // level?
+ Class<?> physical = dataType.getPhysical();
+ if (physical == Object.class) {
+ dataType.setDataBinding(JavaBeansDataBinding.NAME);
+ return false;
+ }
+ if (dataType.getPhysical().isArray()) {
+ introspectArray(dataType, operation);
+ return true;
+ } else if (Throwable.class.isAssignableFrom(physical)) {
+ dataType.setDataBinding(JavaExceptionDataBinding.NAME);
+ return true;
+ } else {
+ dataType.setDataBinding(JavaBeansDataBinding.NAME);
+ return false;
+ }
+ }
+
+ private boolean introspectArray(DataType dataType, Operation operation) {
+ Class<?> physical = dataType.getPhysical();
+ if (!physical.isArray() || physical == byte[].class) {
+ return false;
+ }
+ Class<?> componentType = physical.getComponentType();
+ Type genericComponentType = componentType;
+ if(dataType.getGenericType() instanceof GenericArrayType) {
+ genericComponentType = ((GenericArrayType) dataType.getGenericType()).getGenericComponentType();
+ }
+ DataType logical = new DataTypeImpl(dataType.getDataBinding(), componentType, genericComponentType, dataType.getLogical());
+ introspectType(logical, operation);
+ dataType.setDataBinding("java:array");
+ dataType.setLogical(logical);
+ return true;
+ }
+
+ public DataType introspectType(Object value, Operation operation) {
+ loadDataBindings();
+ DataType dataType = null;
+ for (DataBinding binding : databindings) {
+ // don't introspect for JavaBeansDatabinding as all javatypes will
+ // anyways match to its basetype
+ // which is java.lang.Object. Default to this only if no databinding
+ // results
+ if (!binding.getName().equals(JavaBeansDataBinding.NAME)) {
+ dataType = binding.introspect(value, operation);
+ }
+ if (dataType != null) {
+ return dataType;
+ }
+ }
+ return new DataTypeImpl<XMLType>(JavaBeansDataBinding.NAME, value.getClass(), XMLType.UNKNOWN);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
new file mode 100644
index 0000000000..39889b1e97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
@@ -0,0 +1,321 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.impl.DirectedGraph;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DefaultTransformerExtensionPoint implements TransformerExtensionPoint {
+ private static final Logger logger = Logger.getLogger(DefaultTransformerExtensionPoint.class.getName());
+ private boolean loadedTransformers;
+
+ private ExtensionPointRegistry registry;
+ private final DirectedGraph<Object, Transformer> graph = new DirectedGraph<Object, Transformer>();
+
+ public DefaultTransformerExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public void addTransformer(String sourceType, String resultType, int weight, Transformer transformer, boolean publicTransformer) {
+ if (logger.isLoggable(Level.FINE)) {
+ String className = transformer.getClass().getName();
+ boolean lazy = false;
+ boolean pull = (transformer instanceof PullTransformer);
+ if (transformer instanceof LazyPullTransformer) {
+ className = ((LazyPullTransformer)transformer).transformerDeclaration.getClassName();
+ lazy = true;
+ }
+ if (transformer instanceof LazyPushTransformer) {
+ className = ((LazyPushTransformer)transformer).transformerDeclaration.getClassName();
+ lazy = true;
+ }
+
+ logger.fine("Adding transformer: " + className
+ + ";source="
+ + sourceType
+ + ",target="
+ + resultType
+ + ",weight="
+ + weight
+ + ",type="
+ + (pull ? "pull" : "push")
+ + ",lazy="
+ + lazy);
+ }
+ graph.addEdge(sourceType, resultType, transformer, weight, publicTransformer);
+ }
+
+ public void addTransformer(Transformer transformer, boolean publicTransformer) {
+ addTransformer(transformer.getSourceDataBinding(),
+ transformer.getTargetDataBinding(),
+ transformer.getWeight(),
+ transformer, publicTransformer);
+ }
+
+ public boolean removeTransformer(String sourceType, String resultType) {
+ return graph.removeEdge(sourceType, resultType);
+ }
+
+ public Transformer getTransformer(String sourceType, String resultType) {
+ loadTransformers();
+
+ DirectedGraph<Object, Transformer>.Edge edge = graph.getEdge(sourceType, resultType);
+ return (edge == null) ? null : edge.getValue();
+ }
+
+ /**
+ * Dynamically load transformers registered under META-INF/services.
+ *
+ */
+ private synchronized void loadTransformers() {
+ if (loadedTransformers) {
+ return;
+ }
+ loadedTransformers = true;
+ loadTransformers(PullTransformer.class);
+ loadTransformers(PushTransformer.class);
+
+ }
+
+ /**
+ * Dynamically load transformers registered under META-INF/services.
+ *
+ * @param transformerClass
+ */
+ private synchronized void loadTransformers(Class<?> transformerClass) {
+
+ // Get the transformer service declarations
+ Collection<ServiceDeclaration> transformerDeclarations;
+
+ try {
+ transformerDeclarations = registry.getServiceDiscovery().getServiceDeclarations(transformerClass.getName());
+
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Load transformers
+ for (ServiceDeclaration transformerDeclaration : transformerDeclarations) {
+ Map<String, String> attributes = transformerDeclaration.getAttributes();
+
+ String source = attributes.get("source");
+ String target = attributes.get("target");
+ int weight = Integer.valueOf(attributes.get("weight"));
+ String b = attributes.get("public");
+ boolean pub = true;
+ if (b != null) {
+ pub = Boolean.valueOf(b);
+ }
+
+ // Create a transformer wrapper and register it
+ Transformer transformer;
+ if (transformerClass == PullTransformer.class) {
+ transformer = new LazyPullTransformer(source, target, weight, transformerDeclaration);
+ } else {
+ transformer = new LazyPushTransformer(source, target, weight, transformerDeclaration);
+ }
+ addTransformer(transformer, pub);
+ }
+ }
+
+ /**
+ * A transformer facade allowing transformers to be lazily loaded
+ * and initialized.
+ */
+ private class LazyPullTransformer implements PullTransformer<Object, Object> {
+
+ private String source;
+ private String target;
+ private int weight;
+ private ServiceDeclaration transformerDeclaration;
+ private PullTransformer<Object, Object> transformer;
+
+ public LazyPullTransformer(String source, String target, int weight, ServiceDeclaration transformerDeclaration) {
+ this.source = source;
+ this.target = target;
+ this.weight = weight;
+ this.transformerDeclaration = transformerDeclaration;
+ }
+
+ /**
+ * Load and instantiate the transformer class.
+ *
+ * @return The transformer.
+ */
+ @SuppressWarnings("unchecked")
+ private PullTransformer<Object, Object> getTransformer() {
+ if (transformer == null) {
+ try {
+ Class<PullTransformer<Object, Object>> transformerClass =
+ (Class<PullTransformer<Object, Object>>)transformerDeclaration.loadClass();
+ try {
+ Constructor<PullTransformer<Object, Object>> constructor = transformerClass.getConstructor();
+ transformer = constructor.newInstance();
+ } catch (NoSuchMethodException e) {
+ Constructor<PullTransformer<Object, Object>> constructor =
+ transformerClass.getConstructor(ExtensionPointRegistry.class);
+ transformer = constructor.newInstance(registry);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return transformer;
+ }
+
+ public String getSourceDataBinding() {
+ return source;
+ }
+
+ public String getTargetDataBinding() {
+ return target;
+ }
+
+ public int getWeight() {
+ return weight;
+ }
+
+ public Object transform(Object source, TransformationContext context) {
+ return getTransformer().transform(source, context);
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer(super.toString());
+ sb.append(";className=").append(transformerDeclaration.getClassName());
+ return sb.toString();
+ }
+ }
+
+ /**
+ * A transformer facade allowing transformers to be lazily loaded
+ * and initialized.
+ */
+ private class LazyPushTransformer implements PushTransformer<Object, Object> {
+
+ private String source;
+ private String target;
+ private int weight;
+ private ServiceDeclaration transformerDeclaration;
+ private PushTransformer<Object, Object> transformer;
+
+ public LazyPushTransformer(String source, String target, int weight, ServiceDeclaration transformerDeclaration) {
+ this.source = source;
+ this.target = target;
+ this.weight = weight;
+ this.transformerDeclaration = transformerDeclaration;
+ }
+
+ /**
+ * Load and instantiate the transformer class.
+ *
+ * @return The transformer.
+ */
+ @SuppressWarnings("unchecked")
+ private PushTransformer<Object, Object> getTransformer() {
+ if (transformer == null) {
+ try {
+ Class<PushTransformer<Object, Object>> transformerClass =
+ (Class<PushTransformer<Object, Object>>)transformerDeclaration.loadClass();
+ try {
+ Constructor<PushTransformer<Object, Object>> constructor = transformerClass.getConstructor();
+ transformer = constructor.newInstance();
+ } catch (NoSuchMethodException e) {
+ Constructor<PushTransformer<Object, Object>> constructor =
+ transformerClass.getConstructor(ExtensionPointRegistry.class);
+ transformer = constructor.newInstance(registry);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return transformer;
+ }
+
+ public String getSourceDataBinding() {
+ return source;
+ }
+
+ public String getTargetDataBinding() {
+ return target;
+ }
+
+ public int getWeight() {
+ return weight;
+ }
+
+ public void transform(Object source, Object sink, TransformationContext context) {
+ getTransformer().transform(source, sink, context);
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer(super.toString());
+ sb.append(";className=").append(transformerDeclaration.getClassName());
+ return sb.toString();
+ }
+ }
+
+ //FIXME The following methods should be on a different class from
+ // extension point
+
+ public List<Transformer> getTransformerChain(String sourceType, String resultType) {
+ loadTransformers();
+
+ String source = sourceType;
+ String result = resultType;
+ List<Transformer> transformers = new ArrayList<Transformer>();
+ // First check if there is a direct path, if yes, use it regardless of the weight
+ DirectedGraph<Object, Transformer>.Edge link = graph.getEdge(sourceType, resultType);
+ if (link != null) {
+ transformers.add(link.getValue());
+ } else {
+ DirectedGraph<Object, Transformer>.Path path = graph.getShortestPath(source, result);
+ if (path == null) {
+ return null;
+ }
+ for (DirectedGraph<Object, Transformer>.Edge edge : path.getEdges()) {
+ transformers.add(edge.getValue());
+ }
+ }
+ return transformers;
+ }
+
+ @Override
+ public String toString() {
+ loadTransformers();
+
+ return graph.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.java
new file mode 100644
index 0000000000..e768c60030
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding;
+
+import java.util.Map;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * This interface will be used as a Tuscany system service to perform data mediations
+ *
+ * Mediate the data from one type to the other one
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Mediator {
+
+ /**
+ * Mediate the data from the source type to the target type
+ * @param source The data to be mediated
+ * @param sourceDataType Data type for the source data
+ * @param targetDataType Data type for the target data
+ * @param context
+ * @return
+ */
+ Object mediate(Object source, DataType sourceDataType, DataType targetDataType, Map<String, Object> context);
+
+ /**
+ * Mediate the source data into the target which is a sink to receive the data
+ * @param source The data to be mediated
+ * @param target The sink to receive data
+ * @param sourceDataType Data type for the source data
+ * @param targetDataType Data type for the target data
+ */
+ void mediate(Object source,
+ Object target,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Map<String, Object> context);
+
+ /**
+ * Transform the input parameters for the source operation to the expected parameters for
+ * the target operation
+ * @param input The input data, typically an array of parameters
+ * @param sourceOperation The source operation
+ * @param targetOperation The target operation
+ * @param metadata Additional metadata
+ * @return The transformed input data for the target operation
+ */
+ Object mediateInput(Object input, Operation sourceOperation, Operation targetOperation, Map<String, Object> metadata);
+
+ /**
+ * Transform the return value for the target operation to the expected return value for
+ * the source operation
+ * @param output The output data, typically the return value
+ * @param sourceOperation The source operation
+ * @param targetOperation The target operation
+ * @param metadata Additional metadata
+ * @return The transformed output data for the source operation
+ */
+ Object mediateOutput(Object output,
+ Operation sourceOperation,
+ Operation targetOperation,
+ Map<String, Object> metadata);
+
+ /**
+ * Transform the fault data for the target operation to the expected fault data for
+ * the source operation
+ * @param fault The fault data, such as Java exception or fault message
+ * @param sourceOperation The source operation
+ * @param targetOperation The target operation
+ * @param metadata Additional metadata
+ * @return The transformed fault data for the source operation
+ */
+ Object mediateFault(Object fault, Operation sourceOperation, Operation targetOperation, Map<String, Object> metadata);
+
+ /**
+ * Copy the data
+ * @param data The orginal data
+ * @param dataType The data type
+ * @return The copy
+ */
+ Object copy(Object data, DataType dataType);
+
+ /**
+ * Copy the data
+ * @param data The orginal data
+ * @param dataType The source data type
+ * @param targetDataType The target data type
+ * @return The copy
+ */
+ Object copy(Object data, DataType sourceDataType, DataType targetDataType);
+
+ /**
+ * Copy the data
+ * @param data The orginal data
+ * @param sourceDataType The source data type
+ * @param targetDataType The target data type
+ * @param sourceOperation The source operation
+ * @param targetOperation The target operation
+ * @return The copy
+ */
+ Object copy(Object data,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Operation sourceOperation,
+ Operation targetOperation);
+
+ /**
+ * Copy an array of data objects passed to an operation
+ * @param data array of objects to copy
+ * @return the copy
+ */
+ public Object copyInput(Object input, Operation operation);
+
+ /**
+ * Copy an array of data objects passed to an operation
+ * @param sourceOperation The source operation
+ * @param targetOperation The target operation
+ * @return the copy
+ */
+ public Object copyInput(Object input, Operation sourceOperation, Operation targetOperation);
+
+ /**
+ * Copy the output data
+ * @param data The orginal output
+ * @param operation The operation
+ * @return The copy
+ */
+ Object copyOutput(Object data, Operation operation);
+
+ /**
+ * Copy the output data from target operation into source operation
+ * @param data The orginal output
+ * @param sourceOperation The operation
+ * @param targetOperation The target operation
+ * @return The copy
+ */
+ Object copyOutput(Object data, Operation sourceOperation, Operation targetOperation);
+
+ /**
+ * Copy the fault data
+ * @param fault The orginal fault data
+ * @param operation The operation
+ * @return The copy
+ */
+ Object copyFault(Object fault, Operation operation);
+
+ /**
+ * Copy the fault data from target operation into source operation
+ * @param fault The orginal fault data
+ * @param sourceOperation The operation
+ * @param targetOperation The target operation
+ * @return The copy
+ */
+ Object copyFault(Object fault, Operation sourceOperation, Operation targetOperation);
+
+ /**
+ * Get the DataBindings used by this mediator.
+ * @return
+ */
+ DataBindingExtensionPoint getDataBindings();
+
+ /**
+ * Get the Transformers used by this mediator.
+ * @return
+ */
+ TransformerExtensionPoint getTransformers();
+
+ /**
+ * Create an instance of TransformationContext
+ * @return
+ */
+ TransformationContext createTransformationContext();
+
+ /**
+ * Create an instance of TransformationContext
+ * @param sourceDataType
+ * @param targetDataType
+ * @param metadata
+ * @return
+ */
+ TransformationContext createTransformationContext(DataType sourceDataType,
+ DataType targetDataType,
+ Map<String, Object> metadata);
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.java
new file mode 100644
index 0000000000..b65d392393
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.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.sca.databinding;
+
+/**
+ * PullTransformer transforms data from one binding format to the other one which can be directly consumed
+ *
+ * @param <S> The source data type
+ * @param <R> the target data type
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PullTransformer<S, R> extends Transformer {
+ /**
+ * Transform source data into the result type.
+ *
+ * @param source The source data
+ * @param context The context for the transformation
+ * @return The transformed result
+ */
+ R transform(S source, TransformationContext context);
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PushTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PushTransformer.java
new file mode 100644
index 0000000000..600a6477f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PushTransformer.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 org.apache.tuscany.sca.databinding;
+
+/**
+ * A transformer that pushes data from its source into the sink
+ *
+ * @param <S>
+ * @param <R>
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PushTransformer<S, R> extends Transformer {
+ /**
+ * @param source The source data
+ * @param sink The sink to receive the data
+ * @param context
+ */
+ void transform(S source, R sink, TransformationContext context);
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.java
new file mode 100644
index 0000000000..6f2795fb51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.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.databinding;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+
+/**
+ * Type Mapper between XML schema simple data types and java objects
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface SimpleTypeMapper {
+ /**
+ * Parse the XML lexical representation into a java object
+ * @param simpleType The XSD simple type
+ * @param value the XML lexical representation
+ * @param context The context of the transformation
+ * @return A java object for the XML value
+ */
+ Object toJavaObject(QName simpleType, String value, TransformationContext context);
+ /**
+ * Create the XML lexical representation for a java object
+ * @param simpleType The XSD simple type
+ * @param obj The java object
+ * @param context The context of the transformation
+ * @return The XML lexical representation
+ */
+ String toXMLLiteral(QName simpleType, Object obj, TransformationContext context);
+
+ /**
+ * Get the java type for a simple xml type
+ * @param xmlType
+ * @return
+ */
+ Class<?> getJavaType(QName xmlType);
+
+ /**
+ * Get the xml type for a java type
+ * @param javaType
+ * @return
+ */
+ TypeInfo getXMLType(Class<?> javaType);
+
+ /**
+ * Check if an xml type is a simple type
+ * @param xmlType
+ * @return
+ */
+ boolean isSimpleXSDType(QName xmlType);
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.java
new file mode 100644
index 0000000000..64740b8e08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.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.sca.databinding;
+
+import java.util.Map;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * Context for data transformation
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface TransformationContext {
+
+ /**
+ * @return
+ */
+ Operation getSourceOperation();
+
+ /**
+ * @param sourceOperation
+ */
+ void setSourceOperation(Operation sourceOperation);
+
+ /**
+ * @return
+ */
+ Operation getTargetOperation();
+
+ /**
+ * @param targetOperation
+ */
+ void setTargetOperation(Operation targetOperation);
+
+ /**
+ * Get the source data type
+ *
+ * @return
+ */
+ DataType getSourceDataType();
+
+ /**
+ * Get the target data type
+ *
+ * @return
+ */
+ DataType getTargetDataType();
+
+ /**
+ * Set the source data type
+ *
+ * @param sourceDataType
+ */
+ void setSourceDataType(DataType sourceDataType);
+
+ /**
+ * Set the target data type
+ *
+ * @param targetDataType
+ */
+ void setTargetDataType(DataType targetDataType);
+
+ /**
+ * Get a map of metadata
+ *
+ * @return Returns a map of the metadata
+ */
+ Map<String, Object> getMetadata();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.java
new file mode 100644
index 0000000000..f32465d63a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding;
+
+
+/**
+ * Reports problems during data transformation
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class TransformationException extends RuntimeException {
+
+ private static final long serialVersionUID = 7662385613693006428L;
+ private String sourceDataBinding;
+ private String targetDataBinding;
+
+ public TransformationException() {
+ super();
+ }
+
+ public TransformationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TransformationException(String message) {
+ super(message);
+ }
+
+ public TransformationException(Throwable cause) {
+ super(cause);
+ }
+
+ public String getSourceDataBinding() {
+ return sourceDataBinding;
+ }
+
+ public void setSourceDataBinding(String sourceDataBinding) {
+ this.sourceDataBinding = sourceDataBinding;
+ }
+
+ public String getTargetDataBinding() {
+ return targetDataBinding;
+ }
+
+ public void setTargetDataBinding(String targetDataBinding) {
+ this.targetDataBinding = targetDataBinding;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Transformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Transformer.java
new file mode 100644
index 0000000000..2aa0ad7c15
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Transformer.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding;
+
+/**
+ * A transformer provides the data transformation from source type to target type. The cost of the transformation is
+ * modelled as weight.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Transformer {
+ /**
+ * Get the source type that this transformer transforms data from. The type is used as the key when the transformer
+ * is registered with TransformerRegistry.
+ *
+ * @return A key identifying the source type
+ */
+ String getSourceDataBinding();
+
+ /**
+ * Get the target type that this transformer transforms data into. The type is used as the key when the transformer
+ * is registered with TransformerRegistry.
+ *
+ * @return A key identifying the target type
+ */
+ String getTargetDataBinding();
+
+ /**
+ * Get the cost of the transformation. The weight can be used to choose the most efficient path if there are more
+ * than one available from the source to the target.
+ *
+ * @return An integer representing the cost of the transformation
+ */
+ int getWeight();
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformerExtensionPoint.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformerExtensionPoint.java
new file mode 100644
index 0000000000..ee7efe4860
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformerExtensionPoint.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.sca.databinding;
+
+import java.util.List;
+
+/**
+ * An extension point for data transformer extensions.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TransformerExtensionPoint {
+
+ /**
+ * Register a transformer
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @param weight
+ * @param transformer
+ * @param publicTransformer TODO
+ */
+ void addTransformer(String sourceDataBinding,
+ String targetDataBinding,
+ int weight,
+ Transformer transformer,
+ boolean publicTransformer);
+
+ /**
+ * Register a transformer
+ *
+ * @param transformer
+ * @param publicTransformer TODO
+ */
+ void addTransformer(Transformer transformer, boolean publicTransformer);
+
+ /**
+ * Unregister a transformer
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ boolean removeTransformer(String sourceDataBinding, String targetDataBinding);
+
+ /**
+ * Get the direct Transformer which can transform data from source type to
+ * result type
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ Transformer getTransformer(String sourceDataBinding, String targetDataBinding);
+
+ /**
+ * Get the a chain of Transformers which can transform data from source type
+ * to result type
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ List<Transformer> getTransformerChain(String sourceDataBinding, String targetDataBinding);
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java
new file mode 100644
index 0000000000..4d32b41d4c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.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.databinding;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * A contract for transformers to deal with wrapping/unwrapping for WSDL wrapper style operations
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface WrapperHandler<T> {
+ /**
+ * Create a wrapper element
+ * @param operation The operation
+ * @param input Is it for input or output
+ * @return An object representing the wrapper element
+ */
+ T create(Operation operation, boolean input);
+
+ /**
+ * Get the data type for the wrapper
+ * @param operation The operation
+ * @param input Is it for input or output?
+ * @return The data type of the wrapper, null if it's not a wrapper type
+ */
+ DataType getWrapperType(Operation operation, boolean input);
+
+ /**
+ * Check if the given data is an instance of the wrapper
+ * @param wrapper
+ * @param operation The operation
+ * @param input Input or output
+ * @return
+ */
+ boolean isInstance(Object wrapper, Operation operation, boolean input);
+
+ /**
+ * Populate the wrapper element with the child objects
+ * @param wrapper The wrapper object
+ * @param childObjects The child objects
+ * @param operation The operation
+ * @param input Is it for input or output
+ */
+ void setChildren(T wrapper,
+ Object[] childObjects,
+ Operation operation,
+ boolean input);
+
+ /**
+ * Get a list of child elements from the wrapper
+ * @param wrapper The wrapper object
+ * @param operation The operation
+ * @param input Is it for input or output
+ * @return child elements under the wrapper
+ */
+ List getChildren(T wrapper, Operation operation, boolean input);
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.java
new file mode 100644
index 0000000000..19e1f7e13f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+
+/**
+ * XML and schema helper for Java types
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface XMLTypeHelper {
+
+ // FIXME: This method seems to require the XMLHelper instance to be stateful
+ /**
+ * Convert a Java type into XML type information
+ * @param javaType the physical Java class
+ * @param logical the logical type information
+ * @return the XML type information
+ */
+ TypeInfo getTypeInfo(Class javaType, Object logical);
+
+ /**
+ * Get schema definitions for the Java types known to this helper
+ * @return A list of schema definitions
+ */
+ // List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver);
+
+ /**
+ * Get a list of XML schemas for the given data types
+ * @param factory
+ * @param resolver
+ * @param dataTypes
+ * @return
+ */
+ List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, List<DataType> dataTypes);
+ /**
+ * Get a list of XML schemas for the given interface
+ * @param factory
+ * @param resolver
+ * @param intf
+ * @return
+ */
+ List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, Interface intf);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataBinding.java
new file mode 100644
index 0000000000..4405077e29
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataBinding.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 org.apache.tuscany.sca.databinding.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Used to demarcate the mapping style for an interface or operation
+ *
+ * @version $Rev$ $Date$
+ */
+// FIXME: [rfeng] We should consider to use javax.jws.soap.SOAPBinding
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+public @interface DataBinding {
+
+ /**
+ * Indicate the effective databinding that controls the WSDL/Java mapping of the
+ * interface/operation
+ *
+ * @return the data binding with the MIME media type syntax
+ */
+ String value();
+
+ /**
+ * Indicate if the operation is mapped using WRAPPED or BARE style. Originated from
+ * javax.jws.soap.SOAPBinding.ParameterStyle: Determines whether method parameters
+ * represent the entire message body, or whether the parameters are elements wrapped
+ * inside a top-level element named after the operation
+ *
+ * @return true if the parameter style is WRAPPED, false if BARE
+ */
+ boolean wrapped() default false;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataType.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataType.java
new file mode 100644
index 0000000000..650e909c61
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataType.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Used to demarcate expected data types for parameters and return type
+ *
+ * @version $Rev$ $Date$
+ */
+@Target( {METHOD, PARAMETER})
+@Retention(RUNTIME)
+public @interface DataType {
+
+ /**
+ * Returns the data binding configuration in MIME media type syntax
+ * @return the data binding
+ */
+ String value();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/externalizable/ExternalizableDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/externalizable/ExternalizableDataBinding.java
new file mode 100644
index 0000000000..2c14d4c380
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/externalizable/ExternalizableDataBinding.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.sca.databinding.externalizable;
+
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+
+/**
+ * DataNinding for Externalizable objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExternalizableDataBinding extends BaseDataBinding {
+
+ public static final String NAME = java.io.Externalizable.class.getName();
+
+ public ExternalizableDataBinding() {
+ super(NAME, java.io.Externalizable.class);
+ }
+
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java
new file mode 100644
index 0000000000..a551671452
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java
@@ -0,0 +1,469 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+/**
+ * Directed, weighted graph
+ *
+ * @param <V> The type of vertex object
+ * @param <E> The type of edge object
+ *
+ * @version $Rev$ $Date$
+ */
+public class DirectedGraph<V, E> implements Cloneable {
+ private final static Logger logger = Logger.getLogger(DirectedGraph.class.getName());
+ private final Map<V, Vertex> vertices = new HashMap<V, Vertex>();
+
+ /**
+ * Key for the shortest path cache
+ */
+ private final class VertexPair {
+ private Vertex source;
+
+ private Vertex target;
+
+ /**
+ * @param source
+ * @param target
+ */
+ private VertexPair(Vertex source, Vertex target) {
+ super();
+ this.source = source;
+ this.target = target;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!VertexPair.class.isInstance(object)) {
+ return false;
+ }
+ VertexPair pair = (VertexPair)object;
+ return source == pair.source && target == pair.target;
+ }
+
+ @Override
+ public int hashCode() {
+ int x = source == null ? 0 : source.hashCode();
+ int y = target == null ? 0 : target.hashCode();
+ return x ^ y;
+ }
+
+ }
+
+ // Fix for TUSCANY-2069, making the map concurrent
+ private final Map<VertexPair, Path> paths = new ConcurrentHashMap<VertexPair, Path>();
+ private final Path NULL_PATH = new Path();
+
+ /**
+ * Vertex of a graph
+ */
+ public final class Vertex {
+ private V value;
+
+ // TODO: Do we want to support multiple edges for a vertex pair? If so,
+ // we should use a List instead of Map
+ private Map<Vertex, Edge> outEdges = new HashMap<Vertex, Edge>();
+ private Map<Vertex, Edge> inEdges = new HashMap<Vertex, Edge>();
+
+ private Vertex(V value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + value + ")";
+ }
+
+ public V getValue() {
+ return value;
+ }
+
+ public Map<Vertex, Edge> getOutEdges() {
+ return outEdges;
+ }
+
+ public Map<Vertex, Edge> getInEdges() {
+ return inEdges;
+ }
+
+ }
+
+ /**
+ * An Edge connects two vertices in one direction
+ */
+ public final class Edge {
+ private Vertex sourceVertex;
+
+ private Vertex targetVertex;
+
+ private E value;
+
+ private int weight;
+
+ private boolean pub = true;
+
+ public Edge(Vertex source, Vertex target, E value, int weight, boolean pub) {
+ this.sourceVertex = source;
+ this.targetVertex = target;
+ this.value = value;
+ this.weight = weight;
+ this.pub = pub;
+ }
+
+ @Override
+ public String toString() {
+ return sourceVertex + "->" + targetVertex + "[" + value + "," + weight + "]";
+ }
+
+ public E getValue() {
+ return value;
+ }
+
+ public void setValue(E value) {
+ this.value = value;
+ }
+
+ public Vertex getTargetVertex() {
+ return targetVertex;
+ }
+
+ public void setTargetVertex(Vertex vertex) {
+ this.targetVertex = vertex;
+ }
+
+ public int getWeight() {
+ return weight;
+ }
+
+ public void setWeight(int weight) {
+ this.weight = weight;
+ }
+
+ public Vertex getSourceVertex() {
+ return sourceVertex;
+ }
+
+ public void setSourceVertex(Vertex sourceVertex) {
+ this.sourceVertex = sourceVertex;
+ }
+
+ public boolean isPublic() {
+ return pub;
+ }
+
+ public void setPublic(boolean pub) {
+ this.pub = pub;
+ }
+ }
+
+ private final class Node implements Comparable<Node> {
+
+ private long distance = Integer.MAX_VALUE;
+
+ private Node previous; // NOPMD by rfeng on 9/26/06 9:17 PM
+
+ private Vertex vertex; // NOPMD by rfeng on 9/26/06 9:17 PM
+
+ private Node(Vertex vertex) {
+ this.vertex = vertex;
+ }
+
+ public int compareTo(Node o) {
+ return (distance > o.distance) ? 1 : ((distance == o.distance) ? 0 : -1);
+ }
+ }
+
+ public void addEdge(V source, V target, E edgeValue, int weight, boolean publicEdge) {
+ // Fix for TUSCANY-3456
+ // First check if we already has an edge
+ Edge edge = getEdge(source, target);
+ if (edge != null) {
+ // An existing edge has higher weight, let's replace it
+ if (edge.weight > weight) {
+ logger.fine("An edge exists with higher weight: " + edge);
+ removeEdge(edge);
+ } else {
+ // Don't add this edge
+ logger.fine("An edge exists with lower weight: " + edge);
+ return;
+ }
+ }
+
+ Vertex s = getVertex(source);
+ if (s == null) {
+ s = new Vertex(source);
+ vertices.put(source, s);
+ }
+ Vertex t = getVertex(target);
+ if (t == null) {
+ t = new Vertex(target);
+ vertices.put(target, t);
+ }
+ edge = new Edge(s, t, edgeValue, weight, publicEdge);
+ s.outEdges.put(t, edge);
+ t.inEdges.put(s, edge);
+ }
+
+ public void addEdge(V soure, V target) {
+ addEdge(soure, target, null, 0, true);
+ }
+
+ public Vertex getVertex(V source) {
+ Vertex s = vertices.get(source);
+ return s;
+ }
+
+ public boolean removeEdge(V source, V target) {
+ Vertex s = getVertex(source);
+ if (s == null) {
+ return false;
+ }
+
+ Vertex t = getVertex(target);
+ if (t == null) {
+ return false;
+ }
+
+ return s.outEdges.remove(t) != null && t.inEdges.remove(s) != null;
+
+ }
+
+ public void removeEdge(Edge edge) {
+ edge.sourceVertex.outEdges.remove(edge.targetVertex);
+ edge.targetVertex.inEdges.remove(edge.sourceVertex);
+ }
+
+ public void removeVertex(Vertex vertex) {
+ vertices.remove(vertex.getValue());
+ for (Edge e : new ArrayList<Edge>(vertex.outEdges.values())) {
+ removeEdge(e);
+ }
+ for (Edge e : new ArrayList<Edge>(vertex.inEdges.values())) {
+ removeEdge(e);
+ }
+ }
+
+ public Edge getEdge(Vertex source, Vertex target) {
+ return source.outEdges.get(target);
+ }
+
+ public Edge getEdge(V source, V target) {
+ Vertex sv = getVertex(source);
+ if (sv == null) {
+ return null;
+ }
+ Vertex tv = getVertex(target);
+ if (tv == null) {
+ return null;
+ }
+ return getEdge(getVertex(source), getVertex(target));
+ }
+
+ /**
+ * Get the shortest path from the source vertex to the target vertex using
+ * Dijkstra's algorithm. If there's no path, null will be returned. If the
+ * source is the same as the target, it returns a path with empty edges with
+ * weight 0.
+ *
+ * @param sourceValue The value identifies the source
+ * @param targetValue The value identifies the target
+ * @return The shortest path
+ */
+ public Path getShortestPath(V sourceValue, V targetValue) {
+ Vertex source = getVertex(sourceValue);
+ if (source == null) {
+ return null;
+ }
+ Vertex target = getVertex(targetValue);
+ if (target == null) {
+ return null;
+ }
+
+ VertexPair pair = new VertexPair(source, target);
+ Path path = null;
+ if (paths.containsKey(pair)) {
+ path = paths.get(pair);
+ return path == NULL_PATH? null: path;
+ }
+
+ // Check if there is a direct link, if yes, use it instead
+ Edge direct = getEdge(source, target);
+ path = new Path();
+ if (direct != null) {
+ path.addEdge(direct);
+ paths.put(pair, path);
+ return path;
+ }
+
+ Map<Vertex, Node> nodes = new HashMap<Vertex, Node>();
+ for (Vertex v : vertices.values()) {
+ Node node = new Node(v);
+ if (v == source) {
+ node.distance = 0;
+ }
+ nodes.put(v, node);
+ }
+
+ Set<Node> otherNodes = new HashSet<Node>(nodes.values());
+ Set<Node> nodesOnPath = new HashSet<Node>();
+ Node nextNode = null;
+ while (!otherNodes.isEmpty()) {
+ nextNode = extractMin(otherNodes);
+ if (nextNode.vertex == target) {
+ path = getPath(nextNode);
+ paths.put(pair, path); // Cache it
+ return path == NULL_PATH? null: path;
+ }
+ nodesOnPath.add(nextNode);
+ for (Edge edge : nextNode.vertex.outEdges.values()) {
+ Node adjacentNode = nodes.get(edge.targetVertex);
+ // The private edge can only be used if the edge connects to the target directly
+ if (edge.isPublic() || edge.getTargetVertex() == target) {
+ if (nextNode.distance + edge.weight < adjacentNode.distance) {
+ adjacentNode.distance = nextNode.distance + edge.weight;
+ adjacentNode.previous = nextNode;
+ }
+ }
+ }
+ }
+ paths.put(pair, NULL_PATH); // Cache it
+ return null;
+ }
+
+ /**
+ * Searches for the vertex u in the vertex set Q that has the least d[u]
+ * value. That vertex is removed from the set Q and returned to the user.
+ *
+ * @param nodes
+ * @return
+ */
+ private Node extractMin(Set<Node> nodes) {
+ Node node = Collections.min(nodes);
+ nodes.remove(node);
+ return node;
+ }
+
+ /**
+ * The path between two vertices
+ */
+ public final class Path {
+ private List<Edge> edges = new LinkedList<Edge>();
+
+ private int weight;
+
+ public int getWeight() {
+ return weight;
+ }
+
+ public List<Edge> getEdges() {
+ return edges;
+ }
+
+ public void addEdge(Edge edge) {
+ edges.add(0, edge);
+ weight += edge.weight;
+ }
+
+ @Override
+ public String toString() {
+ return edges + ", " + weight;
+ }
+ }
+
+ private Path getPath(Node t) {
+ if (t.distance == Integer.MAX_VALUE) {
+ return NULL_PATH;
+ }
+ Path path = new Path();
+ Node u = t;
+ while (u.previous != null) {
+ Edge edge = getEdge(u.previous.vertex, u.vertex);
+ path.addEdge(edge);
+ u = u.previous;
+ }
+ return path;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ for (Vertex v : vertices.values()) {
+ sb.append(v.outEdges.values()).append("\n");
+ }
+ return sb.toString();
+ }
+
+ public Map<V, Vertex> getVertices() {
+ return vertices;
+ }
+
+ public void addGraph(DirectedGraph<V, E> otherGraph) {
+ for (Vertex v : otherGraph.vertices.values()) {
+ for (Edge e : v.outEdges.values()) {
+ addEdge(e.sourceVertex.value, e.targetVertex.value, e.value, e.weight, true);
+ }
+ }
+ }
+
+ private Vertex getFirst() {
+ for (Vertex v : vertices.values()) {
+ if (v.inEdges.isEmpty()) {
+ return v;
+ }
+ }
+ if (!vertices.isEmpty()) {
+ throw new IllegalArgumentException("Circular ordering has been detected: " + toString());
+ } else {
+ return null;
+ }
+ }
+
+ public List<V> topologicalSort(boolean readOnly) {
+ DirectedGraph<V, E> graph = (!readOnly) ? this : (DirectedGraph<V, E>)clone();
+ List<V> list = new ArrayList<V>();
+ while (true) {
+ Vertex v = graph.getFirst();
+ if (v == null) {
+ break;
+ }
+ list.add(v.getValue());
+ graph.removeVertex(v);
+ }
+
+ return list;
+ }
+
+ @Override
+ public Object clone() {
+ DirectedGraph<V, E> copy = new DirectedGraph<V, E>();
+ copy.addGraph(this);
+ return copy;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.java
new file mode 100644
index 0000000000..d4d0312bc0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.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.sca.databinding.impl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * This is a special transformer to transform the output from one IDL to the
+ * other one
+ *
+ * @version $Rev$ $Date$
+ */
+public class Group2GroupTransformer extends BaseTransformer<Object, Object> implements
+ PullTransformer<Object, Object> {
+
+ protected Mediator mediator;
+
+ /**
+ * @param wrapperHandler
+ */
+ public Group2GroupTransformer(ExtensionPointRegistry registry) {
+ super();
+ this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return GroupDataBinding.NAME;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return GroupDataBinding.NAME;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.BaseTransformer#getTargetType()
+ */
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.Transformer#getWeight()
+ */
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object transform(Object source, TransformationContext context) {
+ DataType<DataType> sourceType = context.getSourceDataType();
+ DataType<DataType> targetType = context.getTargetDataType();
+
+ return mediator.mediate(source, sourceType.getLogical(), targetType.getLogical(), context.getMetadata());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.java
new file mode 100644
index 0000000000..1c7220fa67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.impl;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * The base class for a special databinding which represents a group of other databindings
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class GroupDataBinding extends BaseDataBinding {
+ public static final String NAME = "databinding:group";
+
+ /**
+ * Marker type is a java class or interface representing the data format.
+ */
+ protected Class[] markerTypes;
+
+ public GroupDataBinding(Class[] types) {
+ super(NAME, GroupDataBinding.class);
+ this.markerTypes = types;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean introspect(DataType type, Operation operation) {
+ if (markerTypes == null) {
+ return false;
+ }
+ Type physical = type.getPhysical();
+ if (physical instanceof ParameterizedType) {
+ physical = ((ParameterizedType)physical).getRawType();
+ }
+ if (!(physical instanceof Class)) {
+ return false;
+ }
+ Class cls = (Class)physical;
+ for (Class<?> c : markerTypes) {
+ if (isTypeOf(c, cls)) {
+ type.setDataBinding(getDataBinding(c));
+ Object logical = getLogical(cls, null);
+ if (logical != null) {
+ type.setLogical(getLogical(cls, null));
+ } else {
+ type.setLogical(XMLType.UNKNOWN);
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Test if the given type is a subtype of the base type
+ * @param markerType
+ * @param type
+ * @return
+ */
+ protected boolean isTypeOf(Class<?> markerType, Class<?> type) {
+ return markerType.isAssignableFrom(type);
+ }
+
+ /**
+ * Derive the databinding name from a base class
+ * @param baseType
+ * @return
+ */
+ protected String getDataBinding(Class<?> baseType) {
+ return baseType.getName();
+ }
+
+ /**
+ * Get the logical type
+ * @param type The java type
+ * @param operation TODO
+ * @return
+ */
+ protected abstract Object getLogical(Class<?> type, Operation operation);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.java
new file mode 100644
index 0000000000..f6e8e53459
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Transformer to convert data from a simple java object to a databinding's representation
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class Java2SimpleTypeTransformer<T> extends BaseTransformer<Object, T> implements
+ PullTransformer<Object, T> {
+
+ protected SimpleTypeMapper mapper;
+
+ public Java2SimpleTypeTransformer() {
+ this.mapper = new SimpleTypeMapperImpl();
+ }
+
+ public Java2SimpleTypeTransformer(SimpleTypeMapper mapper) {
+ this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperImpl();
+ }
+
+ public T transform(Object source, TransformationContext context) {
+ XMLType xmlType = (XMLType) context.getTargetDataType().getLogical();
+ String text = mapper.toXMLLiteral(xmlType.getTypeName(), source, context);
+ return createElement(xmlType.getElementName(), text, context);
+ }
+
+ @Override
+ public Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 10000;
+ }
+
+ protected abstract T createElement(QName element, String literal, TransformationContext context);
+
+ @Override
+ public String getSourceDataBinding() {
+ return SimpleJavaDataBinding.NAME;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
new file mode 100644
index 0000000000..5227b95432
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
@@ -0,0 +1,629 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.impl;
+
+import static org.apache.tuscany.sca.databinding.DataBinding.IDL_FAULT;
+import static org.apache.tuscany.sca.databinding.DataBinding.IDL_OUTPUT;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.Transformer;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.FaultExceptionMapper;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+
+/**
+ * Default Mediator implementation
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class MediatorImpl implements Mediator {
+ private static final String TARGET_OPERATION = "target.operation";
+ private static final String SOURCE_OPERATION = "source.operation";
+ private ExtensionPointRegistry registry;
+ private DataBindingExtensionPoint dataBindings;
+ private TransformerExtensionPoint transformers;
+ private InterfaceContractMapper interfaceContractMapper;
+ private FaultExceptionMapper faultExceptionMapper;
+
+ MediatorImpl(DataBindingExtensionPoint dataBindings, TransformerExtensionPoint transformers) {
+ this.dataBindings = dataBindings;
+ this.transformers = transformers;
+ }
+
+ public MediatorImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ this.dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ this.transformers = registry.getExtensionPoint(TransformerExtensionPoint.class);
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ this.faultExceptionMapper = utilities.getUtility(FaultExceptionMapper.class);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object mediate(Object source, DataType sourceDataType, DataType targetDataType, Map<String, Object> metadata) {
+ if (sourceDataType == null || sourceDataType.getDataBinding() == null) {
+ if (source != null) {
+ Operation operation = (Operation)metadata.get(SOURCE_OPERATION);
+ sourceDataType = dataBindings.introspectType(source, operation);
+ }
+ }
+ if (sourceDataType == null || targetDataType == null) {
+ return source;
+ } else if (sourceDataType.equals(targetDataType)) {
+ return source;
+ }
+
+ List<Transformer> path = getTransformerChain(sourceDataType, targetDataType);
+
+ Object result = source;
+ int size = path.size();
+ int i = 0;
+ while (i < size) {
+ Transformer transformer = path.get(i);
+ TransformationContext context =
+ createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);
+ // the source and target type
+ if (transformer instanceof PullTransformer) {
+ // For intermediate node, set data type to null
+ result = ((PullTransformer)transformer).transform(result, context);
+ } else if (transformer instanceof PushTransformer) {
+ DataPipeTransformer dataPipeFactory = (i < size - 1) ? (DataPipeTransformer)path.get(++i) : null;
+ DataPipe dataPipe = dataPipeFactory == null ? null : dataPipeFactory.newInstance();
+ ((PushTransformer)transformer).transform(result, dataPipe.getSink(), context);
+ result = dataPipe.getResult();
+ }
+ i++;
+ }
+
+ return result;
+ }
+
+ private TransformationContext createTransformationContext(DataType sourceDataType,
+ DataType targetDataType,
+ int size,
+ int index,
+ Transformer transformer,
+ Map<String, Object> metadata) {
+ DataType sourceType =
+ (index == 0) ? sourceDataType : new DataTypeImpl<Object>(transformer.getSourceDataBinding(), Object.class,
+ sourceDataType.getLogical());
+ DataType targetType =
+ (index == size - 1) ? targetDataType : new DataTypeImpl<Object>(transformer.getTargetDataBinding(),
+ Object.class, targetDataType.getLogical());
+
+ Map<String, Object> copy = new HashMap<String, Object>();
+ if (metadata != null) {
+ copy.putAll(metadata);
+ }
+ copy.put(ExtensionPointRegistry.class.getName(), registry);
+
+ TransformationContext context = new TransformationContextImpl(sourceType, targetType, copy);
+ return context;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void mediate(Object source,
+ Object target,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Map<String, Object> metadata) {
+ if (source == null) {
+ // Shortcut for null value
+ return;
+ }
+ if (sourceDataType == null || sourceDataType.getDataBinding() == null) {
+ Operation operation = (Operation)metadata.get(SOURCE_OPERATION);
+ sourceDataType = dataBindings.introspectType(source, operation);
+ }
+ if (sourceDataType == null) {
+ return;
+ } else if (sourceDataType.equals(targetDataType)) {
+ return;
+ }
+
+ List<Transformer> path = getTransformerChain(sourceDataType, targetDataType);
+ Object result = source;
+ int size = path.size();
+ for (int i = 0; i < size; i++) {
+ Transformer transformer = path.get(i);
+ TransformationContext context =
+ createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);
+
+ if (transformer instanceof PullTransformer) {
+ result = ((PullTransformer)transformer).transform(result, context);
+ } else if (transformer instanceof PushTransformer) {
+ DataPipeTransformer dataPipeFactory = (i < size - 1) ? (DataPipeTransformer)path.get(++i) : null;
+ DataPipe dataPipe = dataPipeFactory == null ? null : dataPipeFactory.newInstance();
+ Object sink = dataPipe != null ? dataPipe.getSink() : target;
+ ((PushTransformer)transformer).transform(result, sink, context);
+ result = (dataPipe != null) ? dataPipe.getResult() : null;
+ }
+ }
+ }
+
+ private List<Transformer> getTransformerChain(DataType sourceDataType, DataType targetDataType) {
+ String sourceId = sourceDataType.getDataBinding();
+ String targetId = targetDataType.getDataBinding();
+ List<Transformer> path = transformers.getTransformerChain(sourceId, targetId);
+ if (path == null) {
+ TransformationException ex =
+ new TransformationException("No path found for the transformation: " + sourceId + "->" + targetId);
+ ex.setSourceDataBinding(sourceId);
+ ex.setTargetDataBinding(targetId);
+ throw ex;
+ }
+ return path;
+ }
+
+ public DataBindingExtensionPoint getDataBindings() {
+ return dataBindings;
+ }
+
+ public TransformerExtensionPoint getTransformers() {
+ return transformers;
+ }
+
+ /**
+ * Find the fault data type behind the exception data type
+ * @param exceptionType The exception data type
+ * @return The fault data type
+ */
+ private DataType getFaultType(DataType exceptionType) {
+ return exceptionType == null ? null : (DataType)exceptionType.getLogical();
+ }
+
+ /**
+ * @param qn1
+ * @param qn2
+ */
+ private boolean matches(QName qn1, QName qn2) {
+ if (qn1 == qn2) {
+ return true;
+ }
+ if (qn1 == null || qn2 == null) {
+ return false;
+ }
+ String ns1 = qn1.getNamespaceURI();
+ String ns2 = qn2.getNamespaceURI();
+ String e1 = qn1.getLocalPart();
+ String e2 = qn2.getLocalPart();
+ if (e1.equals(e2) && (ns1.equals(ns2) || ns1.equals(ns2 + "/") || ns2.equals(ns1 + "/"))) {
+ // Tolerating the trailing / which is required by JAX-WS java package --> xml ns mapping
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @param source The source exception
+ * @param sourceExType The data type for the source exception
+ * @param targetExType The data type for the target exception
+ * @param sourceType The fault type for the source
+ * @param targetType The fault type for the target
+ * @return
+ */
+ private Object transformException(Object source,
+ DataType sourceExType,
+ DataType targetExType,
+ DataType sourceType,
+ DataType targetType,
+ Map<String, Object> metadata) {
+
+ if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
+ return source;
+ }
+
+ DataType<DataType> eSourceDataType =
+ new DataTypeImpl<DataType>(IDL_FAULT, sourceExType.getPhysical(), sourceType);
+ DataType<DataType> eTargetDataType =
+ new DataTypeImpl<DataType>(IDL_FAULT, targetExType.getPhysical(), targetType);
+
+ return mediate(source, eSourceDataType, eTargetDataType, metadata);
+ }
+
+ //
+ // Assumes we're going from target->source, knowing that we're throwing BACK an exception, rather than the more
+ // obvious source->target
+ //
+ public Object mediateFault(Object result,
+ Operation sourceOperation,
+ Operation targetOperation,
+ Map<String, Object> metadata) {
+
+ // FIXME: How to match fault data to a fault type for the
+ // operation?
+
+ // If the result is from an InvocationTargetException look at
+ // the actual cause.
+ if (result instanceof InvocationTargetException) {
+ result = ((InvocationTargetException)result).getCause();
+ }
+
+ DataType targetDataType = findFaultDataType(targetOperation, result);
+ DataType targetFaultType = getFaultType(targetDataType);
+
+
+ if (targetFaultType == null) {
+ // No matching fault type, it's a system exception
+ Throwable cause = (Throwable)result;
+ throw new ServiceRuntimeException(cause);
+ }
+
+ // FIXME: How to match a source fault type to a target fault
+ // type?
+ DataType sourceDataType = null;
+ DataType sourceFaultType = null;
+ for (DataType exType : sourceOperation.getFaultTypes()) {
+ DataType faultType = getFaultType(exType);
+ // Match by the QName (XSD element) of the fault type
+ if (faultType != null && typesMatch(targetFaultType.getLogical(), faultType.getLogical())) {
+ sourceDataType = exType;
+ sourceFaultType = faultType;
+ break;
+ }
+ }
+
+ if (sourceFaultType == null) {
+ // No matching fault type, it's a system exception
+ Throwable cause = (Throwable)result;
+ throw new ServiceRuntimeException(cause);
+ }
+
+ Map<String, Object> context = new HashMap<String, Object>();
+ if (metadata != null) {
+ context.putAll(metadata);
+ }
+ if (targetOperation != null) {
+ context.put(SOURCE_OPERATION, targetOperation);
+ }
+ if (sourceOperation != null) {
+ context.put(TARGET_OPERATION, sourceOperation);
+ }
+
+ Object newResult =
+ transformException(result, targetDataType, sourceDataType, targetFaultType, sourceFaultType, context);
+
+ return newResult;
+
+ }
+
+ /**
+ * Look up the fault data type that matches the fault or exception instance
+ * @param operation The operation
+ * @param faultOrException The fault or exception
+ * @return The matching fault data type
+ */
+ private DataType findFaultDataType(Operation operation, Object faultOrException) {
+ DataType targetDataType = null;
+ for (DataType exType : operation.getFaultTypes()) {
+ if (((Class)exType.getPhysical()).isInstance(faultOrException)) {
+ if (faultOrException instanceof FaultException) {
+ DataType faultType = (DataType)exType.getLogical();
+ if (((FaultException)faultOrException).isMatchingType(faultType.getLogical())) {
+ targetDataType = exType;
+ break;
+ }
+ } else {
+ targetDataType = exType;
+ break;
+ }
+ }
+ }
+ return targetDataType;
+ }
+
+ private boolean typesMatch(Object first, Object second) {
+ if (first.equals(second)) {
+ return true;
+ }
+ if (first instanceof XMLType && second instanceof XMLType) {
+ XMLType t1 = (XMLType)first;
+ XMLType t2 = (XMLType)second;
+ // TUSCANY-2113, we should compare element names only
+ return matches(t1.getElementName(), t2.getElementName());
+ }
+ return false;
+ }
+
+ /**
+ * Assumes we're going from target-to-source, knowing that we're sending BACK an output response, rather than the more
+ * obvious source-to-target.
+ *
+ * @param output
+ * @param sourceOperation
+ * @param targetOperation
+ * @return
+ */
+ public Object mediateOutput(Object output,
+ Operation sourceOperation,
+ Operation targetOperation,
+ Map<String, Object> metadata) {
+ // Create a data type to represent the ouput produced by the target operation
+ DataType<DataType> targetType =
+ new DataTypeImpl<DataType>(IDL_OUTPUT, Object.class, targetOperation.getOutputType());
+
+ // Create a data type to represent the ouput expected by the source operation
+ DataType<DataType> sourceType =
+ new DataTypeImpl<DataType>(IDL_OUTPUT, Object.class, sourceOperation.getOutputType());
+
+ if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
+ return output;
+ }
+ Map<String, Object> context = new HashMap<String, Object>();
+ if (metadata != null) {
+ context.putAll(metadata);
+ }
+ if (targetOperation != null) {
+ context.put(SOURCE_OPERATION, targetOperation);
+ }
+ if (sourceOperation != null) {
+ context.put(TARGET_OPERATION, sourceOperation);
+ }
+ return mediate(output, targetType, sourceType, context);
+ }
+
+ public Object mediateInput(Object input,
+ Operation sourceOperation,
+ Operation targetOperation,
+ Map<String, Object> metadata) {
+ // Get the data type to represent the input passed in by the source operation
+ DataType sourceType = sourceOperation.getInputType();
+
+ // Get the data type to represent the input expected by the target operation
+ DataType targetType = targetOperation.getInputType();
+
+ if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
+ return input;
+ }
+ Map<String, Object> context = new HashMap<String, Object>();
+ if (metadata != null) {
+ context.putAll(metadata);
+ }
+ if (sourceOperation != null) {
+ context.put(SOURCE_OPERATION, sourceOperation);
+ }
+ if (targetOperation != null) {
+ context.put(TARGET_OPERATION, targetOperation);
+ }
+ return mediate(input, sourceType, targetType, context);
+ }
+
+ public TransformationContext createTransformationContext() {
+ return new TransformationContextImpl();
+ }
+
+ public TransformationContext createTransformationContext(DataType sourceDataType,
+ DataType targetDataType,
+ Map<String, Object> metadata) {
+ return new TransformationContextImpl(sourceDataType, targetDataType, metadata);
+ }
+
+ public Object copy(Object data, DataType dataType) {
+ return copy(data, dataType, dataType, null, null);
+ }
+
+ public Object copy(Object data, DataType sourceDataType, DataType targetDataType) {
+ return copy(data, sourceDataType, targetDataType, null, null);
+ }
+
+ /**
+ * Copy data using the specified databinding.
+ * @param data input data
+ * @param sourceDataType
+ * @return a copy of the data
+ */
+ public Object copy(Object data,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ if (data == null) {
+ return null;
+ }
+ Class<?> clazz = data.getClass();
+ if (String.class == clazz || clazz.isPrimitive()
+ || Number.class.isAssignableFrom(clazz)
+ || Boolean.class.isAssignableFrom(clazz)
+ || Character.class.isAssignableFrom(clazz)
+ || Byte.class.isAssignableFrom(clazz)
+ || URI.class == clazz
+ || UUID.class == clazz
+ || QName.class == clazz) {
+ // Immutable classes
+ return data;
+ }
+
+ DataBinding javaBeansDataBinding = dataBindings.getDataBinding(JavaBeansDataBinding.NAME);
+ // FIXME: The JAXB databinding is hard-coded here
+ DataBinding jaxbDataBinding = dataBindings.getDataBinding("javax.xml.bind.JAXBElement");
+ DataBinding dataBinding = dataBindings.getDataBinding(sourceDataType.getDataBinding());
+ // If no databinding was specified, introspect the given arg to
+ // determine its databinding
+ if (dataBinding == null) {
+ if (!"java:array".equals(sourceDataType.getDataBinding())) {
+ sourceDataType = dataBindings.introspectType(data, sourceOperation);
+ if (sourceDataType != null) {
+ String db = sourceDataType.getDataBinding();
+ dataBinding = dataBindings.getDataBinding(db);
+ if (dataBinding == null && db != null) {
+ return data;
+ }
+ }
+ }
+ if (dataBinding == null) {
+
+ // Default to the JavaBean databinding
+ dataBinding = dataBindings.getDataBinding(JavaBeansDataBinding.NAME);
+ }
+ }
+
+ // Use the JAXB databinding to copy non-Serializable data
+ if (dataBinding == javaBeansDataBinding) {
+
+ // If the input data is an array containing non Serializable elements
+ // use JAXB
+ clazz = data.getClass();
+ if (clazz.isArray()) {
+ if (Array.getLength(data) != 0) {
+ Object element = Array.get(data, 0);
+ if (element != null && !(element instanceof Serializable)) {
+ dataBinding = jaxbDataBinding;
+ }
+ }
+ } else {
+
+ // If the input data is not Serializable use JAXB
+ if (!((data instanceof Serializable) || (data instanceof Cloneable))) {
+ dataBinding = jaxbDataBinding;
+ }
+ }
+ }
+
+ if (dataBinding == null) {
+ return data;
+ }
+
+ return dataBinding.copy(data, sourceDataType, targetDataType, sourceOperation, targetOperation);
+ }
+
+ /**
+ * Copy an array of data objects passed to an operation
+ * @param data array of objects to copy
+ * @return the copy
+ */
+ public Object copyInput(Object input, Operation operation) {
+ return copyInput(input, operation, operation);
+ }
+ public Object copyInput(Object input, Operation sourceOperation, Operation targetOperation) {
+ if (input == null) {
+ return null;
+ }
+ Object[] data = (input instanceof Object[]) ? (Object[])input : new Object[] {input};
+ List<DataType> inputTypes = sourceOperation.getInputType().getLogical();
+ List<DataType> inputTypesTarget = targetOperation == null ? null : targetOperation.getInputType().getLogical();
+ Object[] copy = new Object[data.length];
+ Map<Object, Object> map = new IdentityHashMap<Object, Object>();
+ for (int i = 0, size = inputTypes.size(); i < size; i++) {
+ Object arg = data[i];
+ if (arg == null) {
+ copy[i] = null;
+ } else {
+ Object copiedArg = map.get(arg);
+ if (copiedArg != null) {
+ copy[i] = copiedArg;
+ } else {
+ copiedArg =
+ copy(arg,
+ inputTypes.get(i),
+ inputTypesTarget == null ? null : inputTypesTarget.get(i),
+ sourceOperation,
+ targetOperation);
+ map.put(arg, copiedArg);
+ copy[i] = copiedArg;
+ }
+ }
+ }
+ return copy;
+ }
+
+ public Object copyOutput(Object data, Operation operation) {
+ return copyOutput(data, operation, operation);
+ }
+
+ public Object copyOutput(Object data, Operation sourceOperation, Operation targetOperation) {
+ return copy(data, targetOperation.getOutputType(), sourceOperation.getOutputType(), targetOperation, sourceOperation);
+ }
+
+ public Object copyFault(Object fault, Operation operation) {
+ return copyFault(fault, operation, operation);
+ }
+
+ public Object copyFault(Object fault, Operation sourceOperation, Operation targetOperation) {
+ if (faultExceptionMapper == null) {
+ return fault;
+ }
+ List<DataType> fts = targetOperation.getFaultTypes();
+ for (int i = 0; i < fts.size(); i++) {
+ DataType et = fts.get(i);
+ if (et.getPhysical().isInstance(fault)) {
+ Throwable ex = (Throwable)fault;
+ DataType<DataType> exType = findFaultDataType(targetOperation, fault);
+ DataType faultType = getFaultType(exType);
+ Object faultInfo = faultExceptionMapper.getFaultInfo(ex, faultType.getPhysical(), targetOperation);
+ DataType targetExType = findSourceFaultDataType(sourceOperation, exType);
+ DataType targetFaultType = getFaultType(targetExType);
+ faultInfo = copy(faultInfo, faultType, targetFaultType, targetOperation, sourceOperation);
+ fault = faultExceptionMapper.wrapFaultInfo(targetExType, ex.getMessage(), faultInfo, ex.getCause(), sourceOperation);
+ return fault;
+ }
+ }
+ return fault;
+ }
+
+ /**
+ * Lookup a fault data type from the source operation which matches the target fault data type
+ * @param sourceOperation The source operation
+ * @param targetExceptionType The target fault data type
+ * @return The matching source target fault type
+ */
+ private DataType findSourceFaultDataType(Operation sourceOperation, DataType targetExceptionType) {
+ boolean remotable = sourceOperation.getInterface().isRemotable();
+ DataType targetFaultType = getFaultType(targetExceptionType);
+ for (DataType dt : sourceOperation.getFaultTypes()) {
+ DataType sourceFaultType = getFaultType(dt);
+ if (interfaceContractMapper.isCompatible(targetFaultType, sourceFaultType, remotable)) {
+ return dt;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/PipedTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/PipedTransformer.java
new file mode 100644
index 0000000000..a1a89005b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/PipedTransformer.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.databinding.impl;
+
+import org.apache.tuscany.sca.databinding.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+
+/**
+ * A utility class to connect PushTransformer and DataPipe to create a
+ * PullTransformer
+ *
+ * @param <S> Source type
+ * @param <I> Intermediate type
+ * @param <R> Result type
+ *
+ * @version $Rev$ $Date$
+ */
+public class PipedTransformer<S, I, R> implements PullTransformer<S, R> {
+ private PushTransformer<S, I> pusher;
+
+ private DataPipeTransformer<I, R> pipe;
+
+ /**
+ * @param pumper
+ * @param pipe
+ */
+ public PipedTransformer(PushTransformer<S, I> pumper, DataPipeTransformer<I, R> pipe) {
+ super();
+ this.pusher = pumper;
+ this.pipe = pipe;
+ }
+
+ public R transform(S source, TransformationContext context) {
+ DataPipe<I, R> dataPipe = pipe.newInstance();
+ pusher.transform(source, dataPipe.getSink(), context);
+ return dataPipe.getResult();
+ }
+
+ public String getSourceDataBinding() {
+ return pusher.getSourceDataBinding();
+ }
+
+ public String getTargetDataBinding() {
+ return pipe.getTargetDataBinding();
+ }
+
+ public int getWeight() {
+ return pusher.getWeight() + pipe.getWeight();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.java
new file mode 100644
index 0000000000..a7849498b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.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.sca.databinding.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Transformer to convert data from a databinding's representation of simple
+ * types to Java Objects
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class SimpleType2JavaTransformer<T> extends BaseTransformer<T, Object> implements
+ PullTransformer<T, Object> {
+
+ protected SimpleTypeMapper mapper;
+
+ public SimpleType2JavaTransformer() {
+ this.mapper = new SimpleTypeMapperImpl();
+ }
+
+ public SimpleType2JavaTransformer(SimpleTypeMapper mapper) {
+ this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperImpl();
+ }
+
+ public Object transform(T source, TransformationContext context) {
+ XMLType xmlType = (XMLType)context.getSourceDataType().getLogical();
+ QName type = (xmlType != null) ? xmlType.getTypeName() : null;
+ if (type == null) {
+ xmlType = (XMLType)context.getTargetDataType().getLogical();
+ type = (xmlType != null) ? xmlType.getTypeName() : null;
+ }
+ Object result = mapper.toJavaObject(type, getText(source), context);
+ close(source);
+ return result;
+ }
+
+ @Override
+ protected Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ @Override
+ public int getWeight() {
+ // Cannot be used for intermediate
+ return 10000;
+ }
+
+ /**
+ * Get the string value from the source
+ * @param source
+ * @return A string
+ */
+ protected abstract String getText(T source);
+
+ /**
+ * To be overrided by the subclass
+ * @param source
+ */
+ protected void close(T source) {
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return SimpleJavaDataBinding.NAME;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.java
new file mode 100644
index 0000000000..16eb4b42ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.java
@@ -0,0 +1,402 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.impl;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+
+/**
+ * Simple type mapper that maps from XSD types to Java Classes and Java Classes to XSD types.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class SimpleTypeMapperImpl extends XSDDataTypeConverter implements SimpleTypeMapper {
+
+ public static final Map<Class, String> JAVA2XML = new HashMap<Class, String>();
+
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+
+ public static final Map<String, Class> XML2JAVA = new HashMap<String, Class>();
+
+ public static final QName XSD_ANY = new QName(URI_2001_SCHEMA_XSD, "any");
+
+ public static final QName XSD_ANYSIMPLETYPE = new QName(URI_2001_SCHEMA_XSD, "anySimpleType");
+
+ public static final QName XSD_ANYTYPE = new QName(URI_2001_SCHEMA_XSD, "anyType");
+
+ public static final QName XSD_ANYURI = new QName(URI_2001_SCHEMA_XSD, "anyURI");
+
+ public static final QName XSD_BASE64 = new QName(URI_2001_SCHEMA_XSD, "base64Binary");
+
+ public static final QName XSD_BOOLEAN = new QName(URI_2001_SCHEMA_XSD, "boolean");
+
+ public static final QName XSD_BYTE = new QName(URI_2001_SCHEMA_XSD, "byte");
+
+ public static final QName XSD_DATE = new QName(URI_2001_SCHEMA_XSD, "date");
+
+ public static final QName XSD_DATETIME = new QName(URI_2001_SCHEMA_XSD, "dateTime");
+
+ public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay");
+
+ public static final QName XSD_DECIMAL = new QName(URI_2001_SCHEMA_XSD, "decimal");
+
+ public static final QName XSD_DOUBLE = new QName(URI_2001_SCHEMA_XSD, "double");
+
+ public static final QName XSD_DURATION = new QName(URI_2001_SCHEMA_XSD, "duration");
+
+ public static final QName XSD_ENTITIES = new QName(URI_2001_SCHEMA_XSD, "ENTITIES");
+
+ public static final QName XSD_ENTITY = new QName(URI_2001_SCHEMA_XSD, "ENTITY");
+
+ public static final QName XSD_FLOAT = new QName(URI_2001_SCHEMA_XSD, "float");
+
+ public static final QName XSD_HEXBIN = new QName(URI_2001_SCHEMA_XSD, "hexBinary");
+
+ public static final QName XSD_IDREF = new QName(URI_2001_SCHEMA_XSD, "IDREF");
+
+ public static final QName XSD_IDREFS = new QName(URI_2001_SCHEMA_XSD, "IDREFS");
+
+ public static final QName XSD_INT = new QName(URI_2001_SCHEMA_XSD, "int");
+
+ public static final QName XSD_INTEGER = new QName(URI_2001_SCHEMA_XSD, "integer");
+
+ public static final QName XSD_LONG = new QName(URI_2001_SCHEMA_XSD, "long");
+
+ public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth");
+
+ public static final QName XSD_MONTHDAY = new QName(URI_2001_SCHEMA_XSD, "gMonthDay");
+
+ public static final QName XSD_NAME = new QName(URI_2001_SCHEMA_XSD, "Name");
+
+ public static final QName XSD_NCNAME = new QName(URI_2001_SCHEMA_XSD, "NCName");
+
+ public static final QName XSD_NEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "negativeInteger");
+
+ public static final QName XSD_NMTOKEN = new QName(URI_2001_SCHEMA_XSD, "NMTOKEN");
+
+ public static final QName XSD_NMTOKENS = new QName(URI_2001_SCHEMA_XSD, "NMTOKENS");
+
+ public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonNegativeInteger");
+
+ public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonPositiveInteger");
+
+ public static final QName XSD_NORMALIZEDSTRING = new QName(URI_2001_SCHEMA_XSD, "normalizedString");
+
+ public static final QName XSD_NOTATION = new QName(URI_2001_SCHEMA_XSD, "NOTATION");
+
+ public static final QName XSD_POSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "positiveInteger");
+
+ public static final QName XSD_QNAME = new QName(URI_2001_SCHEMA_XSD, "QName");
+
+ public static final QName XSD_SHORT = new QName(URI_2001_SCHEMA_XSD, "short");
+
+ public static final Map<String, TypeInfo> XSD_SIMPLE_TYPES = new HashMap<String, TypeInfo>();
+
+ public static final QName XSD_STRING = new QName(URI_2001_SCHEMA_XSD, "string");
+
+ public static final QName XSD_TIME = new QName(URI_2001_SCHEMA_XSD, "time");
+
+ public static final QName XSD_TOKEN = new QName(URI_2001_SCHEMA_XSD, "token");
+
+ public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte");
+
+ public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt");
+
+ public static final QName XSD_UNSIGNEDLONG = new QName(URI_2001_SCHEMA_XSD, "unsignedLong");
+
+ public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort");
+
+ public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear");
+
+ public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth");
+
+ private static final String[] XSD_TYPE_NAMES =
+ {"string", "boolean", "double", "float", "int", "integer", "long", "short", "byte", "decimal", "base64Binary",
+ "hexBinary", "anySimpleType", "anyType", "any", "QName", "dateTime", "date", "time", "normalizedString",
+ "token", "unsignedLong", "unsignedInt", "unsignedShort", "unsignedByte", "positiveInteger", "negativeInteger",
+ "nonNegativeInteger", "nonPositiveInteger", "gYearMonth", "gMonthDay", "gYear", "gMonth", "gDay", "duration",
+ "Name", "NCName", "NMTOKEN", "NMTOKENS", "NOTATION", "ENTITY", "ENTITIES", "IDREF", "IDREFS", "anyURI",
+ "language", "ID"};
+
+ static {
+ for (String type : XSD_TYPE_NAMES) {
+ TypeInfo simpleType = new TypeInfo(new QName(URI_2001_SCHEMA_XSD, type), true, null);
+ XSD_SIMPLE_TYPES.put(type, simpleType);
+ }
+ }
+
+ static {
+ JAVA2XML.put(boolean.class, "boolean");
+ JAVA2XML.put(byte.class, "byte");
+ JAVA2XML.put(short.class, "short");
+ JAVA2XML.put(int.class, "int");
+ JAVA2XML.put(long.class, "long");
+ JAVA2XML.put(float.class, "float");
+ JAVA2XML.put(double.class, "double");
+ JAVA2XML.put(Boolean.class, "boolean");
+ JAVA2XML.put(Byte.class, "byte");
+ JAVA2XML.put(Short.class, "short");
+ JAVA2XML.put(Integer.class, "int");
+ JAVA2XML.put(Long.class, "long");
+ JAVA2XML.put(Float.class, "float");
+ JAVA2XML.put(Double.class, "double");
+ JAVA2XML.put(java.lang.String.class, "string");
+ JAVA2XML.put(java.math.BigInteger.class, "integer");
+ JAVA2XML.put(java.math.BigDecimal.class, "decimal");
+ JAVA2XML.put(java.util.Calendar.class, "dateTime");
+ JAVA2XML.put(java.util.Date.class, "dateTime");
+ JAVA2XML.put(javax.xml.namespace.QName.class, "QName");
+ JAVA2XML.put(java.net.URI.class, "string");
+ JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, "anySimpleType");
+ JAVA2XML.put(javax.xml.datatype.Duration.class, "duration");
+ JAVA2XML.put(java.lang.Object.class, "anyType");
+ JAVA2XML.put(java.awt.Image.class, "base64Binary");
+ JAVA2XML.put(byte[].class, "base64Binary");
+ // java2XSD.put(javax.activation.DataHandler.class, "base64Binary");
+ JAVA2XML.put(javax.xml.transform.Source.class, "base64Binary");
+ JAVA2XML.put(java.util.UUID.class, "string");
+ }
+
+ static {
+ XML2JAVA.put("string", java.lang.String.class);
+ XML2JAVA.put("integer", java.math.BigInteger.class);
+ XML2JAVA.put("int", int.class);
+ XML2JAVA.put("long", long.class);
+ XML2JAVA.put("short", short.class);
+ XML2JAVA.put("decimal", java.math.BigDecimal.class);
+ XML2JAVA.put("float", float.class);
+ XML2JAVA.put("double", double.class);
+ XML2JAVA.put("boolean", boolean.class);
+ XML2JAVA.put("byte", byte.class);
+ XML2JAVA.put("QName", javax.xml.namespace.QName.class);
+ XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("base64Binary", byte[].class);
+ XML2JAVA.put("hexBinary", byte[].class);
+ XML2JAVA.put("unsignedInt", long.class);
+ XML2JAVA.put("unsignedShort", int.class);
+ XML2JAVA.put("unsignedByte", short.class);
+ XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements
+ // XML2JAVA.put("anySimpleType", java.lang.String.class); // For
+ // attributes
+ XML2JAVA.put("duration", javax.xml.datatype.Duration.class);
+ XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class);
+ }
+
+ private DatatypeFactory factory;
+
+ public SimpleTypeMapperImpl() {
+ super();
+ try {
+ this.factory = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Class<?> getJavaType(QName xmlType) {
+ if (xmlType != null && URI_2001_SCHEMA_XSD.equals(xmlType.getNamespaceURI())) {
+ return XML2JAVA.get(xmlType.getLocalPart());
+ } else {
+ return null;
+ }
+ }
+
+ public TypeInfo getXMLType(Class javaType) {
+ return XSD_SIMPLE_TYPES.get(JAVA2XML.get(javaType));
+ }
+
+ public Object toJavaObject(QName simpleType, String literal, TransformationContext context) {
+ /**
+ * <ul>
+ * <li>xsd:string --- java.lang.String
+ * <li>xsd:integer --- java.math.BigInteger
+ * <li>xsd:int --- int
+ * <li>xsd:long --- long
+ * <li>xsd:short --- short
+ * <li>xsd:decimal --- java.math.BigDecimal
+ * <li>xsd:float --- float
+ * <li>xsd:double --- double
+ * <li>xsd:boolean --- boolean
+ * <li>xsd:byte --- byte
+ * <li>xsd:QName --- javax.xml.namespace.QName
+ * <li>xsd:dateTime --- javax.xml.datatype.XMLGregorianCalendar
+ * <li>xsd:base64Binary --- byte[]
+ * <li>xsd:hexBinary --- byte[]
+ * <li>xsd:unsignedInt --- long
+ * <li>xsd:unsignedShort --- int
+ * <li>xsd:unsignedByte --- short
+ * <li>xsd:time --- javax.xml.datatype.XMLGregorianCalendar
+ * <li>xsd:date --- javax.xml.datatype.XMLGregorianCalendar
+ * <li>xsd:g* --- javax.xml.datatype.XMLGregorianCalendar
+ * <li>xsd:anySimpleType (for xsd:element of this type)a
+ * java.lang.Object
+ * <li>xsd:anySimpleType (for xsd:attribute of this type)
+ * java.lang.String
+ * <li>xsd:duration javax.xml.datatype.Duration
+ * <li>xsd:NOTATION javax.xml.namespace.QName
+ * </ul>
+ */
+
+ if (literal == null) {
+ return null;
+ }
+ String value = literal.trim();
+
+ QName type = simpleType;
+ if (type.equals(XSD_STRING)) {
+ return parseString(value);
+ } else if (type.equals(XSD_INT)) {
+ return parseInt(value);
+ } else if (type.equals(XSD_INTEGER)) {
+ return parseInteger(value);
+ } else if (type.equals(XSD_INT)) {
+ return parseInt(value);
+ } else if (type.equals(XSD_FLOAT)) {
+ return parseFloat(value);
+ } else if (type.equals(XSD_DOUBLE)) {
+ return parseDouble(value);
+ } else if (type.equals(XSD_SHORT)) {
+ return parseShort(value);
+ } else if (type.equals(XSD_DECIMAL)) {
+ return parseDecimal(value);
+ } else if (type.equals(XSD_BOOLEAN)) {
+ return parseBoolean(value);
+ } else if (type.equals(XSD_BYTE)) {
+ return parseByte(value);
+ } else if (type.equals(XSD_LONG)) {
+ return parseLong(value);
+ } else if (type.equals(XSD_UNSIGNEDBYTE)) {
+ return parseUnsignedShort(value);
+ } else if (type.equals(XSD_UNSIGNEDSHORT)) {
+ return parseUnsignedShort(value);
+ } else if (type.equals(XSD_UNSIGNEDINT)) {
+ return parseUnsignedInt(value);
+ } else if (type.equals(XSD_UNSIGNEDLONG)) {
+ return parseUnsignedInt(value);
+ } else if (type.equals(XSD_DATETIME)) {
+ return parseDateTime(value);
+ } else if (type.equals(XSD_DATE)) {
+ return parseDate(value);
+ } else if (type.equals(XSD_TIME)) {
+ return parseTime(value);
+ } else if (type.equals(XSD_DURATION)) {
+ return parseDuration(value);
+ } else if (type.equals(XSD_HEXBIN)) {
+ return parseHexBinary(value);
+ } else if (type.equals(XSD_BASE64)) {
+ return parseBase64Binary(value);
+ } else if (type.equals(XSD_QNAME)) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class.getName()) : null);
+ return parseQName(value, namespaceContext);
+ } else if (type.equals(XSD_NOTATION)) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class.getName()) : null);
+ return parseQName(value, namespaceContext);
+ } else if (type.equals(XSD_YEAR)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_MONTH)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_DAY)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_YEARMONTH)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_MONTHDAY)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else {
+ return value;
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private XMLGregorianCalendar toXMLGregorianCalendar(Date date) {
+ GregorianCalendar c =
+ new GregorianCalendar(date.getYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(),
+ date.getSeconds());
+ return factory.newXMLGregorianCalendar(c);
+ }
+
+ private XMLGregorianCalendar toXMLGregorianCalendar(GregorianCalendar calendar) {
+ return factory.newXMLGregorianCalendar(calendar);
+ }
+
+ public String toXMLLiteral(QName simpleType, Object obj, TransformationContext context) {
+ if(obj == null) {
+ // It could be null if nilable=true
+ return null;
+ }
+ if (obj instanceof Float || obj instanceof Double) {
+ if (obj instanceof Float) {
+ return printDouble(((Float)obj).floatValue());
+ } else {
+ return printDouble(((Double)obj).doubleValue());
+ }
+ } else if (obj instanceof GregorianCalendar) {
+ GregorianCalendar calendar = (GregorianCalendar)obj;
+ return toXMLGregorianCalendar(calendar).toXMLFormat();
+ } else if (obj instanceof Date) {
+ return toXMLGregorianCalendar((Date)obj).toXMLFormat();
+ } else if (obj instanceof XMLGregorianCalendar) {
+ return ((XMLGregorianCalendar)obj).toXMLFormat();
+ } else if (obj instanceof byte[]) {
+ if (simpleType != null) {
+ if (simpleType.equals(XSD_BASE64)) {
+ return printBase64Binary((byte[])obj);
+ } else if (simpleType.equals(XSD_HEXBIN)) {
+ return printHexBinary((byte[])obj);
+ }
+ }
+ } else if (obj instanceof QName) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class.getName()) : null);
+ return printQName((QName)obj, namespaceContext);
+ }
+ return obj.toString();
+ }
+
+ public boolean isSimpleXSDType(QName typeName) {
+ if (typeName == null) {
+ return false;
+ }
+ return typeName.getNamespaceURI().equals(URI_2001_SCHEMA_XSD)
+ && XSD_SIMPLE_TYPES.get(typeName.getLocalPart()) != null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.java
new file mode 100644
index 0000000000..7af63f1ad6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+public class TransformationContextImpl implements TransformationContext {
+ private static final String SOURCE_OPERATION = "source.operation";
+
+ private static final String TARGET_OPERATION = "target.operation";
+
+ private DataType sourceDataType;
+
+ private DataType targetDataType;
+
+ private final Map<String, Object> metadata = new HashMap<String, Object>();
+
+ public TransformationContextImpl() {
+ super();
+ }
+
+ public TransformationContextImpl(DataType sourceDataType,
+ DataType targetDataType,
+ Map<String, Object> metadata) {
+ super();
+ this.sourceDataType = sourceDataType;
+ this.targetDataType = targetDataType;
+ if (metadata != null) {
+ this.metadata.putAll(metadata);
+ }
+ }
+
+ public DataType getSourceDataType() {
+ return sourceDataType;
+ }
+
+ public DataType getTargetDataType() {
+ return targetDataType;
+ }
+
+ public void setSourceDataType(DataType sourceDataType) {
+ this.sourceDataType = sourceDataType;
+ }
+
+ public void setTargetDataType(DataType targetDataType) {
+ this.targetDataType = targetDataType;
+ }
+
+ public Map<String, Object> getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * @return the sourceOperation
+ */
+ public Operation getSourceOperation() {
+ return (Operation) metadata.get(SOURCE_OPERATION);
+ }
+
+ /**
+ * @param sourceOperation the sourceOperation to set
+ */
+ public void setSourceOperation(Operation sourceOperation) {
+ this.metadata.put(SOURCE_OPERATION, sourceOperation);
+ }
+
+ /**
+ * @return the targetOperation
+ */
+ public Operation getTargetOperation() {
+ return (Operation) metadata.get(TARGET_OPERATION);
+ }
+
+ /**
+ * @param targetOperation the targetOperation to set
+ */
+ public void setTargetOperation(Operation targetOperation) {
+ this.metadata.put(TARGET_OPERATION, targetOperation);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
new file mode 100644
index 0000000000..0664902feb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
@@ -0,0 +1,951 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.impl;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.FieldPosition;
+import java.text.Format;
+import java.text.ParsePosition;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import javax.xml.XMLConstants;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * Utility class for XSD data type conversions
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class XSDDataTypeConverter {
+ /**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+ public static final class Base64Binary {
+ private static final char[] S_BASE64CHAR =
+ {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
+ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4',
+ '5', '6', '7', '8', '9', '+', '/'};
+
+ private static final char S_BASE64PAD = '=';
+
+ private static final byte[] S_DECODETABLE = new byte[128];
+
+ static {
+ for (int i = 0; i < S_DECODETABLE.length; i++) {
+ S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
+ }
+ for (int i = 0; i < S_BASE64CHAR.length; i++) {
+ // 0 to 63
+ S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i;
+ }
+ }
+
+ private Base64Binary() {
+ }
+
+ /**
+ *
+ */
+ public static byte[] decode(char[] data, int off, int len) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[len / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public static byte[] decode(String data) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[data.length() / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public static void decode(String data, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
+ }
+
+ private static int decode0(char[] ibuf, byte[] obuf, int index) {
+ int wp = index;
+ int outlen = 3;
+ if (ibuf[3] == S_BASE64PAD) {
+ outlen = 2;
+ }
+ if (ibuf[2] == S_BASE64PAD) {
+ outlen = 1;
+ }
+ int b0 = S_DECODETABLE[ibuf[0]];
+ int b1 = S_DECODETABLE[ibuf[1]];
+ int b2 = S_DECODETABLE[ibuf[2]];
+ int b3 = S_DECODETABLE[ibuf[3]];
+ switch (outlen) {
+ case 1:
+ obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ return 1;
+ case 2:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ return 2;
+ case 3:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
+ return 3;
+ default:
+ throw new IllegalArgumentException("The character sequence is not base64 encoded.");
+ }
+ }
+
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data) {
+ return encode(data, 0, data.length);
+ }
+
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data, int off, int len) {
+ if (len <= 0) {
+ return "";
+ }
+ char[] out = new char[len / 3 * 4 + 4];
+ int rindex = off;
+ int windex = 0;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 18];
+ out[windex++] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[windex++] = S_BASE64CHAR[i & 0x3f];
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[windex++] = S_BASE64CHAR[i >> 2];
+ out[windex++] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ out[windex++] = S_BASE64PAD;
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 10];
+ out[windex++] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ }
+ return new String(out, 0, windex);
+ }
+
+ /**
+ * Outputs base64 representation of the specified byte array to a byte stream.
+ */
+ public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ byte[] out = new byte[4];
+ int rindex = off;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[0] = (byte) S_BASE64CHAR[i >> 18];
+ out[1] = (byte) S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = (byte) S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = (byte) S_BASE64CHAR[i & 0x3f];
+ ostream.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = (byte) S_BASE64CHAR[i >> 2];
+ out[1] = (byte) S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = (byte) S_BASE64PAD;
+ out[3] = (byte) S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = (byte) S_BASE64CHAR[i >> 10];
+ out[1] = (byte) S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = (byte) S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = (byte) S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ }
+ }
+
+ /**
+ * Outputs base64 representation of the specified byte array to a character stream.
+ */
+ public static void encode(byte[] data, int off, int len, Writer writer) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ char[] out = new char[4];
+ int rindex = off;
+ int rest = len - off;
+ int output = 0;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 18];
+ out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = S_BASE64CHAR[i & 0x3f];
+ writer.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ output += 4;
+ if (output % 76 == 0) {
+ writer.write("\n");
+ }
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = S_BASE64CHAR[i >> 2];
+ out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = S_BASE64PAD;
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 10];
+ out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ }
+ }
+ }
+
+ /**
+ * <p/>
+ * Utility class for xs:hexbinary. </p>
+ */
+ public static final class HexBinary {
+ private HexBinary() {
+ }
+
+ /**
+ * Converts the string <code>pValue</code> into an array of hex bytes.
+ */
+ public static byte[] decode(String pValue) {
+ if ((pValue.length() % 2) != 0) {
+ throw new IllegalArgumentException("A HexBinary string must have even length.");
+ }
+ byte[] result = new byte[pValue.length() / 2];
+ int j = 0;
+ int i = 0;
+ while (i < pValue.length()) {
+ byte b;
+ char c = pValue.charAt(i++);
+ char d = pValue.charAt(i++);
+ if (c >= '0' && c <= '9') {
+ b = (byte) ((c - '0') << 4);
+ } else if (c >= 'A' && c <= 'F') {
+ b = (byte) ((c - 'A' + 10) << 4);
+ } else if (c >= 'a' && c <= 'f') {
+ b = (byte) ((c - 'a' + 10) << 4);
+ } else {
+ throw new IllegalArgumentException("Invalid hex digit: " + c);
+ }
+ if (d >= '0' && d <= '9') {
+ b += (byte) (d - '0');
+ } else if (d >= 'A' && d <= 'F') {
+ b += (byte) (d - 'A' + 10);
+ } else if (d >= 'a' && d <= 'f') {
+ b += (byte) (d - 'a' + 10);
+ } else {
+ throw new IllegalArgumentException("Invalid hex digit: " + d);
+ }
+ result[j++] = b;
+ }
+ return result;
+ }
+
+ /**
+ * Converts the byte array <code>pHexBinary</code> into a string.
+ */
+ public static String encode(byte[] pHexBinary) {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < pHexBinary.length; i++) {
+ byte b = pHexBinary[i];
+ byte c = (byte) ((b & 0xf0) >> 4);
+ if (c <= 9) {
+ result.append((char) ('0' + c));
+ } else {
+ result.append((char) ('A' + c - 10));
+ }
+ c = (byte) (b & 0x0f);
+ if (c <= 9) {
+ result.append((char) ('0' + c));
+ } else {
+ result.append((char) ('A' + c - 10));
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Creates a clone of the given byte array.
+ */
+ public static byte[] getClone(byte[] pHexBinary) {
+ byte[] result = new byte[pHexBinary.length];
+ System.arraycopy(pHexBinary, 0, result, 0, pHexBinary.length);
+ return result;
+ }
+ }
+
+ public class XSDDateFormat extends XSDDateTimeFormat {
+ private static final long serialVersionUID = -1629412916827246627L;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDDateFormat() {
+ super(true, false);
+ }
+ }
+
+ /**
+ * <p/>
+ * An instance of {@link java.text.Format}, which may be used to parse and format <code>xs:dateTime</code> values.
+ * </p>
+ */
+ public static class XSDDateTimeFormat extends Format {
+ private static final long serialVersionUID = -1148332471737068969L;
+
+ final boolean parseDate;
+
+ final boolean parseTime;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDDateTimeFormat() {
+ this(true, true);
+ }
+
+ XSDDateTimeFormat(boolean pParseDate, boolean pParseTime) {
+ parseDate = pParseDate;
+ parseTime = pParseTime;
+ }
+
+ private void append(StringBuffer pBuffer, int pNum, int pMinLen) {
+ String s = Integer.toString(pNum);
+ for (int i = s.length(); i < pMinLen; i++) {
+ pBuffer.append('0');
+ }
+ pBuffer.append(s);
+ }
+
+ @Override
+ public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
+ assert pCalendar != null : "The Calendar argument must not be null.";
+ assert pBuffer != null : "The StringBuffer argument must not be null.";
+ assert pPos != null : "The FieldPosition argument must not be null.";
+
+ Calendar cal = (Calendar) pCalendar;
+ if (parseDate) {
+ int year = cal.get(Calendar.YEAR);
+ if (year < 0) {
+ pBuffer.append('-');
+ year = -year;
+ }
+ append(pBuffer, year, 4);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.MONTH) + 1, 2);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2);
+ if (parseTime) {
+ pBuffer.append('T');
+ }
+ }
+ if (parseTime) {
+ append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.MINUTE), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.SECOND), 2);
+ int millis = cal.get(Calendar.MILLISECOND);
+ if (millis > 0) {
+ pBuffer.append('.');
+ append(pBuffer, millis, 3);
+ }
+ }
+ TimeZone tz = cal.getTimeZone();
+ // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis());
+ int offset = cal.get(Calendar.ZONE_OFFSET);
+ if (tz.inDaylightTime(cal.getTime())) {
+ offset += cal.get(Calendar.DST_OFFSET);
+ }
+ if (offset == 0) {
+ pBuffer.append('Z');
+ } else {
+ if (offset < 0) {
+ pBuffer.append('-');
+ offset = -offset;
+ } else {
+ pBuffer.append('+');
+ }
+ int minutes = offset / (60 * 1000);
+ int hours = minutes / 60;
+ minutes -= hours * 60;
+ append(pBuffer, hours, 2);
+ pBuffer.append(':');
+ append(pBuffer, minutes, 2);
+ }
+ return pBuffer;
+ }
+
+ private int parseInt(String pString, int offset, StringBuffer pDigits) {
+ int length = pString.length();
+ int pOffset = offset;
+ pDigits.setLength(0);
+ while (pOffset < length) {
+ char c = pString.charAt(pOffset);
+ if (Character.isDigit(c)) {
+ pDigits.append(c);
+ ++pOffset;
+ } else {
+ break;
+ }
+ }
+ return pOffset;
+ }
+
+ @Override
+ public Object parseObject(String pString, ParsePosition pParsePosition) {
+ assert pString != null : "The String argument must not be null.";
+ assert pParsePosition != null : "The ParsePosition argument must not be null.";
+ int offset = pParsePosition.getIndex();
+ int length = pString.length();
+
+ boolean isMinus = false;
+ StringBuffer digits = new StringBuffer();
+ int year = 0;
+ int month = 0;
+ int mday = 0;
+ if (parseDate) {
+ // Sign
+ if (offset < length) {
+ char c = pString.charAt(offset);
+ if (c == '+') {
+ ++offset;
+ } else if (c == '-') {
+ ++offset;
+ isMinus = true;
+ }
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() < 4) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ year = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '-') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ month = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '-') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ mday = Integer.parseInt(digits.toString());
+
+ if (parseTime) {
+ if (offset < length && pString.charAt(offset) == 'T') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ }
+ } else {
+ year = month = mday = 0;
+ }
+
+ int hour = 0;
+ int minute = 0;
+ int second = 0;
+ int millis = 0;
+ if (parseTime) {
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ hour = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == ':') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ minute = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == ':') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ second = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '.') {
+ ++offset;
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() > 0) {
+ millis = Integer.parseInt(digits.toString());
+ } else {
+ millis = 0;
+ }
+ } else {
+ millis = 0;
+ }
+ } else {
+ hour = minute = second = millis = 0;
+ }
+
+ digits.setLength(0);
+ digits.append("GMT");
+ if (offset < length) {
+ char c = pString.charAt(offset);
+ if (c == 'Z') {
+ // Ignore UTC, it is the default
+ ++offset;
+ } else if (c == '+' || c == '-') {
+ digits.append(c);
+ ++offset;
+ for (int i = 0; i < 5; i++) {
+ if (offset >= length) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ c = pString.charAt(offset);
+ if ((i != 2 && Character.isDigit(c)) || (i == 2 && c == ':')) {
+ digits.append(c);
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ ++offset;
+ }
+ }
+ }
+
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(digits.toString()));
+ cal.set(isMinus ? -year : year, parseDate ? month - 1 : month, mday, hour, minute, second);
+ cal.set(Calendar.MILLISECOND, millis);
+ pParsePosition.setIndex(offset);
+ return cal;
+ }
+ }
+
+ public static class XSDTimeFormat extends XSDDateTimeFormat {
+ private static final long serialVersionUID = 1346506860724640517L;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDTimeFormat() {
+ super(false, true);
+ }
+ }
+
+ private static final long MAX_UNSIGNED_INT = (((long) Integer.MAX_VALUE) * 2) + 1;
+
+ private static final int MAX_UNSIGNED_SHORT = Short.MAX_VALUE * 2 + 1;
+
+ public String parseAnySimpleType(String value) {
+ return value;
+ }
+
+ public byte[] parseBase64Binary(String value) {
+ return Base64Binary.decode(value);
+ }
+
+ public boolean parseBoolean(String value) {
+ return Boolean.valueOf(value).booleanValue();
+ }
+
+ public byte parseByte(String value) {
+ return Byte.parseByte(value);
+ }
+
+ public Calendar parseDate(String value) {
+ XSDDateFormat format = new XSDDateFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse date " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public Calendar parseDateTime(String value) {
+ XSDDateTimeFormat format = new XSDDateTimeFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse dateTime " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public BigDecimal parseDecimal(String value) {
+ return new BigDecimal(value);
+ }
+
+ public double parseDouble(String value) {
+ if ("INF".equals(value)) {
+ return Double.POSITIVE_INFINITY;
+ } else if ("-INF".equals(value)) {
+ return Double.NEGATIVE_INFINITY;
+ } else if ("NaN".equals(value)) {
+ return Double.NaN;
+ } else {
+ return Double.parseDouble(value);
+ }
+ }
+
+ public Duration parseDuration(String pDuration) {
+ try {
+ return DatatypeFactory.newInstance().newDuration(pDuration);
+ } catch (DatatypeConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public float parseFloat(String value) {
+ if ("INF".equals(value)) {
+ return Float.POSITIVE_INFINITY;
+ } else if ("-INF".equals(value)) {
+ return Float.NEGATIVE_INFINITY;
+ } else if ("NaN".equals(value)) {
+ return Float.NaN;
+ } else {
+ return Float.parseFloat(value);
+ }
+ }
+
+ public byte[] parseHexBinary(String value) {
+ return HexBinary.decode(value);
+ }
+
+ public int parseInt(String value) {
+ return Integer.parseInt(value);
+ }
+
+ public BigInteger parseInteger(String value) {
+ return new BigInteger(value);
+ }
+
+ public long parseLong(String value) {
+ return Long.parseLong(value);
+ }
+
+ public QName parseQName(String value, NamespaceContext context) {
+ int offset = value.indexOf(':');
+ String uri;
+ String localName;
+ switch (offset) {
+ case -1:
+ localName = value;
+ uri = context.getNamespaceURI("");
+ if (uri == null) {
+ // Should not happen, indicates an error in the
+ // NamespaceContext
+ // implementation
+ throw new IllegalArgumentException("The default prefix is not bound.");
+ }
+ break;
+ case 0:
+ throw new IllegalArgumentException("Default prefix must be indicated by not using a colon: "
+ + value);
+ default:
+ String prefix = value.substring(0, offset);
+ localName = value.substring(offset + 1);
+ uri = context.getNamespaceURI(prefix);
+ if (uri == null) {
+ throw new IllegalArgumentException("The prefix " + prefix + " is not bound.");
+ }
+ }
+ return new QName(uri, localName);
+ }
+
+ public short parseShort(String value) {
+ return Short.parseShort(value);
+ }
+
+ public String parseString(String value) {
+ return value;
+ }
+
+ public Calendar parseTime(String value) {
+ XSDTimeFormat format = new XSDTimeFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse time " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public long parseUnsignedInt(String value) {
+ long l = Long.parseLong(value);
+ if (l < 0) {
+ throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
+ + ": result is negative");
+ }
+ if (l > MAX_UNSIGNED_INT) {
+ throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
+ + ": result exceeds maximum value " + MAX_UNSIGNED_INT);
+ }
+ return l;
+ }
+
+ public int parseUnsignedShort(String value) {
+ int i = Integer.parseInt(value);
+ if (i < 0) {
+ throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
+ + ": result is negative");
+ }
+ if (i > MAX_UNSIGNED_SHORT) {
+ throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
+ + ": result exceeds maximum value " + MAX_UNSIGNED_SHORT);
+ }
+ return i;
+ }
+
+ public String printAnySimpleType(String value) {
+ return value;
+ }
+
+ public String printBase64Binary(byte[] value) {
+ return Base64Binary.encode(value);
+ }
+
+ public String printBoolean(boolean value) {
+ return (value ? Boolean.TRUE : Boolean.FALSE).toString();
+ }
+
+ public String printByte(byte value) {
+ return Byte.toString(value);
+ }
+
+ public String printDate(Calendar value) {
+ return new XSDDateFormat().format(value);
+ }
+
+ public String printDateTime(Calendar value) {
+ return new XSDDateTimeFormat().format(value);
+ }
+
+ public String printDecimal(BigDecimal value) {
+ return value.toString();
+ }
+
+ public String printDouble(double value) {
+ return Double.toString(value);
+ }
+
+ public String printDuration(Duration pDuration) {
+ return pDuration.toString();
+ }
+
+ public String printFloat(float value) {
+ return Float.toString(value);
+ }
+
+ public String printHexBinary(byte[] value) {
+ return HexBinary.encode(value);
+ }
+
+ public String printInt(int value) {
+ return Integer.toString(value);
+ }
+
+ public String printInteger(BigInteger value) {
+ return value.toString();
+ }
+
+ public String printLong(long value) {
+ return Long.toString(value);
+ }
+
+ public String printQName(QName value, NamespaceContext context) {
+ String prefix = context.getPrefix(value.getNamespaceURI());
+ if (prefix == null) {
+ throw new IllegalArgumentException("The namespace URI " + value.getNamespaceURI()
+ + " is not bound.");
+ } else if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
+ return value.getLocalPart();
+ } else {
+ return prefix + ":" + value.getLocalPart();
+ }
+ }
+
+ public String printShort(short value) {
+ return Short.toString(value);
+ }
+
+ public String printString(String value) {
+ return value;
+ }
+
+ public String printTime(Calendar value) {
+ return new XSDTimeFormat().format(value);
+ }
+
+ public String printUnsignedInt(long value) {
+ return Long.toString(value);
+ }
+
+ public String printUnsignedShort(int value) {
+ return Integer.toString(value);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/DOMNode2JavaBeanTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/DOMNode2JavaBeanTransformer.java
new file mode 100644
index 0000000000..fbca9b0444
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/DOMNode2JavaBeanTransformer.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.javabeans;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Transformer to convert data from DOM Node to JavaBean
+ *
+ * @version $Rev$ $Date$
+ */
+public class DOMNode2JavaBeanTransformer extends XML2JavaBeanTransformer<Node> {
+
+ @Override
+ public Node getRootElement(Node element) throws XML2JavaMapperException {
+ if (element instanceof Document) {
+ return ((Document)element).getDocumentElement();
+ } else {
+ return element;
+ }
+
+ }
+
+ @Override
+ public Iterator<Node> getChildElements(Node parent) throws XML2JavaMapperException {
+ NodeList nodeList = parent.getChildNodes();
+ List<Node> nodeArrayList = new ArrayList<Node>(nodeList.getLength());
+ for (int count = 0; count < nodeList.getLength(); ++count) {
+ nodeArrayList.add(nodeList.item(count));
+ }
+
+ return nodeArrayList.iterator();
+ }
+
+ @Override
+ public String getElementName(Node element) throws XML2JavaMapperException {
+ return element.getLocalName();
+ }
+
+ @Override
+ public String getText(Node element) throws XML2JavaMapperException {
+ if (element instanceof Document) {
+ element = ((Document)element).getDocumentElement();
+ }
+ return element.getTextContent();
+ }
+
+ @Override
+ public boolean isTextElement(Node element) throws XML2JavaMapperException {
+ return element.getNodeType() == Node.TEXT_NODE;
+ }
+
+ @Override
+ public boolean isTextOnly(Node element) throws XML2JavaMapperException {
+ NodeList childNodes = element.getChildNodes();
+ return childNodes.getLength() == 1 && isTextElement(childNodes.item(0));
+ }
+
+ @Override
+ public Node getFirstChildWithName(Node element, QName name) throws XML2JavaMapperException {
+ Node child;
+ for (child = element.getFirstChild();
+ child != null && !(child.getNodeName() == name.getLocalPart()
+ && child.getNamespaceURI() == name.getNamespaceURI()) ;
+ child = child.getNextSibling()) {
+ }
+ return child;
+ }
+
+ @Override
+ public Class getSourceType() {
+ return Node.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/Java2XMLMapperException.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/Java2XMLMapperException.java
new file mode 100644
index 0000000000..5dc13bd60b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/Java2XMLMapperException.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.javabeans;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This exception is used to encapsulate and rethrow exceptions that arise out
+ * of converting JavaBean objects to XML
+ *
+ * @version $Rev$ $Date$
+ */
+public class Java2XMLMapperException extends RuntimeException {
+ private static final long serialVersionUID = 6811924384399578686L;
+
+ private QName xmlElementName;
+ private String javaFieldName;
+ private Class javaType;
+
+ public Java2XMLMapperException(String message) {
+ super(message);
+ }
+
+ public Java2XMLMapperException(Throwable cause) {
+ super(cause);
+ }
+
+ public String getJavaFieldName() {
+ return javaFieldName;
+ }
+
+ public void setJavaFieldName(String javaFieldName) {
+ this.javaFieldName = javaFieldName;
+ }
+
+ public Class getJavaType() {
+ return javaType;
+ }
+
+ public void setJavaType(Class javaType) {
+ this.javaType = javaType;
+ }
+
+ public QName getXmlElementName() {
+ return xmlElementName;
+ }
+
+ public void setXmlElementName(QName xmlElementName) {
+ this.xmlElementName = xmlElementName;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2DOMNodeTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2DOMNodeTransformer.java
new file mode 100644
index 0000000000..f582499b70
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2DOMNodeTransformer.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.sca.databinding.javabeans;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * Transformer to convert data from a JavaBean object to DOM Node
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaBean2DOMNodeTransformer extends JavaBean2XMLTransformer<Node> {
+
+ public static final String COLON = ":";
+ private DOMHelper helper;
+
+ public JavaBean2DOMNodeTransformer(ExtensionPointRegistry registry) {
+ super();
+ helper = DOMHelper.getInstance(registry);
+ }
+
+ @Override
+ public void appendChild(Node parentElement, Node childElement) throws Java2XMLMapperException {
+ parentElement.appendChild(childElement);
+ }
+
+ @Override
+ public Node createElement(QName qName) throws Java2XMLMapperException {
+ String qualifedName =
+ (qName.getPrefix() == null || qName.getPrefix().length() <= 0) ? qName.getLocalPart()
+ : qName.getPrefix() + COLON + qName.getLocalPart();
+ return helper.newDocument().createElementNS(qName.getNamespaceURI(), qualifedName);
+ }
+
+ @Override
+ public void appendText(Node parentElement, String textData) throws Java2XMLMapperException {
+ Document document = helper.newDocument();
+ Node textNode;
+ if (textData != null) {
+ textNode = document.createTextNode(textData);
+ } else {
+ Attr nil = document.createAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:nil");
+ nil.setValue("true");
+ textNode = nil;
+ }
+ appendChild(parentElement, textNode);
+ }
+
+ @Override
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLStreamReaderTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLStreamReaderTransformer.java
new file mode 100644
index 0000000000..43bda3d769
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLStreamReaderTransformer.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.javabeans;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.xml.BeanXMLStreamReaderImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Transformer to convert data from a JavaBean object to XMLStreamReader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaBean2XMLStreamReaderTransformer extends BaseTransformer<Object, XMLStreamReader> implements
+ PullTransformer<Object, XMLStreamReader> {
+
+ public XMLStreamReader transform(Object source, TransformationContext context) {
+ try {
+ javax.xml.namespace.QName name = null;
+ if (context != null) {
+ Object logical = context.getSourceDataType().getLogical();
+ if (logical instanceof XMLType) {
+ name = ((XMLType)logical).getElementName();
+ }
+ }
+ return new BeanXMLStreamReaderImpl(name, source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 50;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLTransformer.java
new file mode 100644
index 0000000000..28d716e4f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLTransformer.java
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.javabeans;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Transformer to convert data from a JavaBean object to xml
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class JavaBean2XMLTransformer<T> extends BaseTransformer<Object, T> implements
+ PullTransformer<Object, T> {
+
+ public static final String GET = "get";
+ public static final String PREFIX = "n";
+ public static final String PERIOD = ".";
+ public static final String FWD_SLASH = "/";
+ public static final String HTTP = "http://";
+ private static int prefixCount = 1;
+
+ protected SimpleTypeMapperImpl mapper;
+
+ public JavaBean2XMLTransformer() {
+ this.mapper = new SimpleTypeMapperImpl();
+ }
+
+ public T transform(Object source, TransformationContext context) {
+ QName rootElement = null;
+ if (context != null) {
+ DataType<?> type = context.getTargetDataType();
+ if (type != null) {
+ Object logical = type.getLogical();
+ if (logical instanceof XMLType) {
+ rootElement = ((XMLType)logical).getElementName();
+ }
+ }
+ }
+ //FIXME See how/if we still need to get the metadata here
+ //QName rootElementName = (QName)context.getTargetDataType().getMetadata("RootElementName");
+ //if (rootElementName == null) {
+ QName rootElementName = new QName(resolveRootElementName(source.getClass()));
+ //}
+
+ T root = createElement(rootElementName);
+ appendChildElements(root, resolveElementName(source.getClass()), source.getClass(), source, context);
+ return root;
+ }
+
+ private void appendChildElements(T parent,
+ QName elementName,
+ Class javaType,
+ Object javaObject,
+ TransformationContext context) {
+ T element = null;
+ if (javaObject != null) {
+ if (javaType.isPrimitive() || isSimpleJavaType(javaObject)) {
+ appendText(parent, mapper.toXMLLiteral(null, javaObject, context));
+ } else if (javaType.isArray()) {
+ int size = Array.getLength(javaObject);
+ for (int count = 0; count < size; ++count) {
+ Object item = Array.get(javaObject, count);
+ element = createElement(elementName);
+ appendChild(parent, element);
+ appendChildElements(element, elementName, javaType.getComponentType(), item, context);
+ }
+ } else {
+ Field[] javaFields = javaType.getFields();
+ for (Field aField : javaFields) {
+ try {
+ QName fieldElementName = new QName(aField.getName());
+ if (!aField.getType().isArray()) {
+ element = createElement(fieldElementName);
+ appendChild(parent, element);
+ appendChildElements(element,
+ fieldElementName,
+ aField.getType(),
+ aField.get(javaObject),
+ context);
+ } else {
+ appendChildElements(parent,
+ fieldElementName,
+ aField.getType(),
+ aField.get(javaObject),
+ context);
+ }
+ } catch (IllegalAccessException e) {
+ Java2XMLMapperException java2xmlEx = new Java2XMLMapperException(e);
+ java2xmlEx.setJavaFieldName(aField.getName());
+ java2xmlEx.setJavaType(javaType);
+ throw java2xmlEx;
+ }
+ }
+
+ Method[] methods = javaType.getMethods();
+ String fieldName = null;
+ for (Method aMethod : methods) {
+ try {
+ if (Modifier.isPublic(aMethod.getModifiers()) && aMethod.getName().startsWith(GET)
+ && aMethod.getParameterTypes().length == 0
+ && isMappedGetter(aMethod.getName())) {
+ fieldName = resolveFieldFromMethod(aMethod.getName());
+ try {
+ javaType.getField(fieldName);
+ } catch (NoSuchFieldException e) {
+ QName fieldElementName = new QName(fieldName);
+ if (aMethod.getReturnType().isArray()) {
+ appendChildElements(parent, fieldElementName, aMethod.getReturnType(), aMethod
+ .invoke(javaObject, new Object[0]), context);
+ } else {
+ element = createElement(fieldElementName);
+ appendChild(parent, element);
+ appendChildElements(element, fieldElementName, aMethod.getReturnType(), aMethod
+ .invoke(javaObject, new Object[0]), context);
+ }
+ }
+ }
+ } catch (IllegalAccessException e) {
+ Java2XMLMapperException java2xmlEx = new Java2XMLMapperException(e);
+ java2xmlEx.setJavaFieldName(fieldName);
+ java2xmlEx.setJavaType(javaType);
+ throw java2xmlEx;
+ } catch (InvocationTargetException e) {
+ Java2XMLMapperException java2xmlEx = new Java2XMLMapperException(e);
+ java2xmlEx.setJavaFieldName(fieldName);
+ java2xmlEx.setJavaType(javaType);
+ throw java2xmlEx;
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Subclasses can override this method to prevent some getter methods
+ * from being mapped. The default implementation provided by this class
+ * maps all getter methods.
+ */
+ protected boolean isMappedGetter(String methodName) {
+ return true;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JavaBeansDataBinding.NAME;
+ }
+
+ @Override
+ public Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ private boolean isSimpleJavaType(Object javaObject) {
+ if (javaObject instanceof String) {
+ return true;
+ }
+ if (javaObject instanceof Byte || javaObject instanceof Character
+ || javaObject instanceof Short
+ || javaObject instanceof Integer
+ || javaObject instanceof Long
+ || javaObject instanceof Float
+ || javaObject instanceof Double
+ || javaObject instanceof Boolean) {
+ return true;
+ }
+ if (javaObject instanceof GregorianCalendar || javaObject instanceof Date
+ || javaObject instanceof XMLGregorianCalendar
+ || javaObject instanceof byte[]
+ || javaObject instanceof QName) {
+ return true;
+ }
+ return false;
+ }
+
+ private String resolveRootElementName(Class javaType) {
+ if (javaType.isArray()) {
+ return javaType.getComponentType().getSimpleName() + "_collection";
+ } else {
+ return javaType.getSimpleName() + "_instance";
+ }
+ }
+
+ private QName resolveElementName(Class javaType) {
+ if (javaType.isArray()) {
+ return new QName(javaType.getComponentType().getSimpleName());
+ } else {
+ return new QName(javaType.getSimpleName());
+ }
+ }
+
+ private String resolveFieldFromMethod(String methodName) {
+ StringBuffer fieldName = new StringBuffer();
+ fieldName.append(Character.toLowerCase(methodName.charAt(GET.length())));
+ fieldName.append(methodName.substring(GET.length() + 1));
+ return fieldName.toString();
+ }
+
+ public String getNexPrefix() {
+ return PREFIX + prefixCount++;
+ }
+
+ @Override
+ public int getWeight() {
+ return JavaBeansDataBinding.HEAVY_WEIGHT;
+ }
+
+ /**
+ * Create an element with the given name
+ * @param qName
+ * @return
+ * @throws Java2XMLMapperException
+ */
+ public abstract T createElement(QName qName) throws Java2XMLMapperException;
+
+ /**
+ * Create a text node and add it to the parent
+ * @param parentElement
+ * @param textData
+ * @throws Java2XMLMapperException
+ */
+ public abstract void appendText(T parentElement, String textData) throws Java2XMLMapperException;
+
+ /**
+ * Add the child element to the parent
+ * @param parentElement
+ * @param childElement
+ * @throws Java2XMLMapperException
+ */
+ public abstract void appendChild(T parentElement, T childElement) throws Java2XMLMapperException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.java
new file mode 100644
index 0000000000..5e5774f338
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.javabeans;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * DataBinding for JavaBeans
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaBeansDataBinding extends BaseDataBinding {
+ private final static Logger logger = Logger.getLogger(JavaBeansDataBinding.class.getName());
+ /**
+ * Defining a weight to a very high number so that the transformer won't be picked
+ * up by other paths unless it's the only available path
+ */
+ public static final int HEAVY_WEIGHT = 10000;
+ public static final String NAME = "java:complexType";
+
+ public JavaBeansDataBinding() {
+ super(NAME, Object.class);
+ }
+
+ protected JavaBeansDataBinding(String name, Class<?> baseType) {
+ super(name, baseType);
+ }
+
+ @Override
+ public Object copy(Object arg, DataType sourceDataType, DataType targetDataType, Operation sourceOperation, Operation targetOperation) {
+ if (arg == null) {
+ return null;
+ }
+ final Class<?> clazz = arg.getClass();
+ if (String.class == clazz || clazz.isPrimitive()
+ || Number.class.isAssignableFrom(clazz)
+ || Boolean.class.isAssignableFrom(clazz)
+ || Character.class.isAssignableFrom(clazz)
+ || Byte.class.isAssignableFrom(clazz)) {
+ // Immutable classes
+ return arg;
+ }
+ try {
+ if (arg instanceof Serializable) {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = getObjectOutputStream(bos);
+ oos.writeObject(arg);
+ oos.close();
+ bos.close();
+
+ // Work out which ClassLoader to use for deserializing arg
+ // We want to use:
+ // * The ClassLoader of the targetDataType if it is not the System ClassLoader
+ // * The ClassLoader of arg if it is not the System ClassLoader
+ // * The ThreadContext ClassLoader if the ClassLoader of arg is the System ClassLoader
+ // because Collection classes are loaded by the System ClassLoader but their contents
+ // may be loaded from another ClassLoader
+ //
+ ClassLoader classLoaderToUse = targetDataType.getPhysical().getClassLoader();
+ if (classLoaderToUse == null) {
+ classLoaderToUse = clazz.getClassLoader();
+ }
+ if (classLoaderToUse == null)
+ {
+ // ClassLoader of arg is the System ClassLoader so we will use the ThreadContext ClassLoader
+ // instead
+ classLoaderToUse = Thread.currentThread().getContextClassLoader();
+ }
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ ObjectInputStream ois = getObjectInputStream(bis, classLoaderToUse);
+ Object objectCopy = ois.readObject();
+ ois.close();
+ bis.close();
+ return objectCopy;
+ } else if (arg instanceof Cloneable) {
+ Method clone;
+ try {
+ clone = arg.getClass().getMethod("clone");
+ try {
+ return clone.invoke(arg, (Object[])null);
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof CloneNotSupportedException) {
+ // Ignore
+ } else {
+ throw new IllegalArgumentException(e);
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ } catch (NoSuchMethodException e) {
+ // Ignore it
+ }
+ }
+ // return arg;
+ logger.warning("Argument type '" + arg.getClass().getName()
+ + "' is not Serializable or Cloneable. Pass-by-value is skipped.");
+ return arg;
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Pass-by-value is not supported for the given object: " + arg.getClass()
+ .getName(), e);
+ }
+ }
+
+ protected ObjectOutputStream getObjectOutputStream(OutputStream os) throws IOException {
+ return new ObjectOutputStream(os);
+ }
+
+ protected ObjectInputStream getObjectInputStream(InputStream is, final ClassLoader cl) throws IOException {
+ ObjectInputStream ois = new ObjectInputStream(is) {
+ @Override
+ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
+ try {
+ return Class.forName(desc.getName(), false, cl);
+ } catch (ClassNotFoundException e) {
+ try {
+ // For OSGi, use context ClassLoader if the bundle ClassLoader cannot load the class
+ if (cl != Thread.currentThread().getContextClassLoader()) {
+ return Class.forName(desc.getName(), false, Thread.currentThread().getContextClassLoader());
+ }
+ } catch (ClassNotFoundException e1) {
+ // ignore
+ } catch (NoClassDefFoundError e1) {
+ // ignore
+ }
+ return super.resolveClass(desc);
+ }
+ }
+
+ };
+ return ois;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaExceptionDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaExceptionDataBinding.java
new file mode 100644
index 0000000000..6886462ac8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaExceptionDataBinding.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 org.apache.tuscany.sca.databinding.javabeans;
+
+
+/**
+ * DataBinding for Java Exceptions
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaExceptionDataBinding extends JavaBeansDataBinding {
+
+ public static final String NAME = "java:exception";
+
+ public JavaExceptionDataBinding() {
+ super(NAME, null);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java
new file mode 100644
index 0000000000..a1bb7e6235
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.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.sca.databinding.javabeans;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.databinding.xml.XMLStringDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * DataBinding for Java simple types
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class SimpleJavaDataBinding extends BaseDataBinding {
+ public static final String NAME = "java:simpleType";
+ private SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl();
+
+ public SimpleJavaDataBinding(ExtensionPointRegistry registry) {
+ super(NAME, Object.class);
+// UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+// this.simpleTypeMapper = utilityExtensionPoint.getUtility(SimpleTypeMapper.class);
+ }
+
+ @Override
+ public Object copy(Object arg,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ if (arg instanceof byte[]) {
+ return ((byte[])arg).clone();
+ }
+ return arg;
+ }
+
+ @Override
+ public boolean introspect(DataType type, Operation operation) {
+ Class<?> cls = type.getPhysical();
+ if (cls == Object.class) {
+ return false;
+ }
+ // HACK: [rfeng] By pass the one know to XMLString
+ String db = type.getDataBinding();
+ if (db != null && (XMLStringDataBinding.NAME.equals(db))) {
+ return false;
+ }
+ if (SimpleTypeMapperImpl.JAVA2XML.keySet().contains(cls)) {
+ type.setDataBinding(NAME);
+ QName elementName = null;
+ Object logical = type.getLogical();
+ if (logical instanceof XMLType) {
+ elementName = ((XMLType)logical).getElementName();
+ }
+ TypeInfo typeInfo = simpleTypeMapper.getXMLType(cls);
+ type.setLogical(new XMLType(elementName, typeInfo == null ? null : typeInfo.getQName()));
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaBeanTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaBeanTransformer.java
new file mode 100644
index 0000000000..6881ec6038
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaBeanTransformer.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.javabeans;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Transformer to convert data from XML to JavaBean
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class XML2JavaBeanTransformer<T> extends BaseTransformer<T, Object> implements
+ PullTransformer<T, Object> {
+
+ public static final String SET = "set";
+ public static final QName QNAME_MESSAGE = new QName("message");
+
+ protected SimpleTypeMapperImpl mapper;
+
+ public XML2JavaBeanTransformer() {
+ this.mapper = new SimpleTypeMapperImpl();
+ }
+
+ @Override
+ public int getWeight() {
+ return JavaBeansDataBinding.HEAVY_WEIGHT;
+ }
+
+ public Object transform(T source, TransformationContext context) {
+ //FIXME why is the logical type sometimes a Class instead of an XMLType?
+ if (context.getSourceDataType().getLogical() instanceof XMLType) {
+ XMLType xmlType = (XMLType) context.getSourceDataType().getLogical();
+ return toJavaObject(xmlType.getTypeName(), getRootElement(source), context);
+ } else {
+ return toJavaObject(null, getRootElement(source), context);
+ }
+ }
+
+ public Object toJavaObject(QName xmlType, T xmlElement, TransformationContext context) {
+ if (xmlType != null && mapper.isSimpleXSDType(xmlType)) {
+ return mapper.toJavaObject(xmlType, getText(xmlElement), context);
+ } else {
+ Class<?> javaType = (Class<?>)context.getTargetDataType().getPhysical();
+ return createJavaObject(xmlElement, javaType, context);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private <L> L createJavaObject(T element, Class<L> javaType, TransformationContext context)
+ throws XML2JavaMapperException {
+ if (isTextOnly(element)) {
+ return (L) mapper.toJavaObject(mapper.getXMLType(javaType).getQName(),
+ getText(element),
+ context);
+ } else {
+ String fieldName = null;
+ try {
+ L javaInstance;
+ T detailMsg = null;
+ if (Throwable.class.isAssignableFrom(javaType)) {
+ T msgElement = getFirstChildWithName(element, QNAME_MESSAGE);
+ if (msgElement != null && isTextOnly(msgElement)) {
+ detailMsg = msgElement; // skip this when handling child elements
+ Constructor constructor = javaType.getConstructor(new Class[] {String.class});
+ javaInstance = (L)constructor.newInstance(new Object[] {getText(detailMsg)});
+ } else {
+ javaInstance = javaType.newInstance();
+ }
+ } else {
+ javaInstance = javaType.newInstance();
+ }
+ Map<Field, List<Object>> arrayFields = new Hashtable<Field, List<Object>>();
+ Map<Method, List<Object>> arraySetters = new Hashtable<Method, List<Object>>();
+
+ for (Iterator<T> childElements = getChildElements(element); childElements.hasNext(); ) {
+ T childElement = childElements.next();
+ if (!isTextElement(childElement) && childElement != detailMsg) {
+ fieldName = getElementName(childElement);
+ try {
+ Field javaField = javaType.getField(fieldName);
+ setFieldValue(javaInstance,
+ javaField,
+ childElement,
+ arrayFields,
+ context);
+
+ } catch (NoSuchFieldException e1) {
+ setFieldValueUsingSetter(javaType,
+ javaInstance,
+ fieldName,
+ childElement,
+ arraySetters,
+ context);
+ }
+ }
+ }
+
+ setArrayValues(javaInstance, arrayFields, arraySetters);
+ return javaInstance;
+ } catch (Exception e2) {
+ XML2JavaMapperException xml2JavaEx = new XML2JavaMapperException(e2);
+ xml2JavaEx.setJavaType(javaType);
+ xml2JavaEx.setJavaFieldName(fieldName);
+ throw xml2JavaEx;
+ }
+ }
+ }
+
+ private void setFieldValue(Object javaInstance,
+ Field javaField,
+ T fieldValue,
+ Map<Field, List<Object>> arrayFields,
+ TransformationContext context) throws IllegalAccessException {
+ Class<?> javaFieldType = (Class<?>) javaField.getType();
+
+ if (javaFieldType.isArray()) {
+ Class<?> componentType = javaFieldType.getComponentType();
+ List<Object> fldValueArray = arrayFields.get(javaField);
+ if (fldValueArray == null) {
+ fldValueArray = new ArrayList<Object>();
+ arrayFields.put(javaField, fldValueArray);
+ }
+ fldValueArray.add(createJavaObject(fieldValue, componentType, context));
+ } else {
+ javaField.setAccessible(true);
+ javaField.set(javaInstance, createJavaObject(fieldValue, javaFieldType, context));
+ }
+ }
+
+ private void setFieldValueUsingSetter(Class javaType,
+ Object javaInstance,
+ String fieldName,
+ T fieldValue,
+ Map<Method, List<Object>> arraySetters,
+ TransformationContext context) throws IllegalAccessException,
+ InvocationTargetException {
+ char firstChar = Character.toUpperCase(fieldName.charAt(0));
+ StringBuilder methodName = new StringBuilder(SET + fieldName);
+ methodName.setCharAt(SET.length(), firstChar);
+ boolean methodNotFound = true;
+
+ for (int methodCount = 0; methodNotFound && methodCount < javaType.getMethods().length; ++methodCount) {
+ Method aMethod = javaType.getMethods()[methodCount];
+ if (aMethod.getName().equals(methodName.toString())
+ && aMethod.getParameterTypes().length == 1) {
+ Class<?> paramType = aMethod.getParameterTypes()[0];
+
+ if (paramType.isArray()) {
+ Class<?> componentType = paramType.getComponentType();
+ List<Object> setterValueArray = arraySetters.get(aMethod);
+ if (setterValueArray == null) {
+ setterValueArray = new ArrayList<Object>();
+ arraySetters.put(aMethod, setterValueArray);
+ }
+ setterValueArray.add(createJavaObject(fieldValue, componentType, context));
+ } else {
+ aMethod.invoke(javaInstance, new Object[] {createJavaObject(fieldValue,
+ paramType,
+ context)});
+ }
+ methodNotFound = false;
+ }
+ }
+
+ if (methodNotFound) {
+ XML2JavaMapperException xml2JavaEx =
+ new XML2JavaMapperException("No field or setter method to configure xml data");
+ xml2JavaEx.setJavaFieldName(fieldName);
+ xml2JavaEx.setJavaType(javaType);
+ throw xml2JavaEx;
+ }
+ }
+
+ private void setArrayValues(Object javaInstance,
+ Map<Field, List<Object>> arrayFields,
+ Map<Method, List<Object>> arraySetters) throws IllegalAccessException,
+ InvocationTargetException {
+ if (arrayFields.size() > 0) {
+ for (Field javaField : arrayFields.keySet()) {
+ javaField.setAccessible(true);
+
+ if (javaField.getType().getComponentType().isPrimitive()) {
+ javaField.set(javaInstance, createPrimitiveArray(javaField.getType()
+ .getComponentType(),
+ arrayFields.get(javaField)));
+ } else {
+ javaField.set(javaInstance,
+ createNonPrimitiveArray(javaField.getType().getComponentType(),
+ arrayFields.get(javaField)));
+ }
+ }
+ }
+
+ if (arraySetters.size() > 0) {
+ for (Method aMethod : arraySetters.keySet()) {
+ Class<?> paramType = aMethod.getParameterTypes()[0];
+ if (paramType.getComponentType().isPrimitive()) {
+ aMethod.invoke(javaInstance,
+ new Object[] {createPrimitiveArray(paramType.getComponentType(),
+ arraySetters.get(aMethod))});
+ } else {
+ aMethod.invoke(javaInstance,
+ new Object[] {createNonPrimitiveArray(paramType.getComponentType(),
+ arraySetters.get(aMethod))});
+ }
+ }
+ }
+ }
+
+ private Object createNonPrimitiveArray(Class fieldType, List values) {
+ Object objectArray = Array.newInstance(fieldType, values.size());
+ for (int count = 0; count < values.size(); ++count) {
+ Array.set(objectArray, count, values.get(count));
+ }
+ return objectArray;
+ }
+
+ private Object createPrimitiveArray(Class fieldType, List values) {
+ if (fieldType.isPrimitive()) {
+ if (fieldType.getName().equals("int")) {
+ int[] primitiveValues = new int[values.size()];
+ for (int count = 0; count < values.size(); ++count) {
+ primitiveValues[count] = ((Integer) values.get(count)).intValue();
+ }
+ return primitiveValues;
+ } else if (fieldType.getName().equals("float")) {
+ float[] primitiveValues = new float[values.size()];
+ for (int count = 0; count < values.size(); ++count) {
+ primitiveValues[count] = ((Float) values.get(count)).floatValue();
+ }
+ return primitiveValues;
+ } else if (fieldType.getName().equals("boolean")) {
+ boolean[] primitiveValues = new boolean[values.size()];
+ for (int count = 0; count < values.size(); ++count) {
+ primitiveValues[count] = ((Boolean) values.get(count)).booleanValue();
+ }
+ return primitiveValues;
+ } else if (fieldType.getName().equals("char")) {
+ char[] primitiveValues = new char[values.size()];
+ for (int count = 0; count < values.size(); ++count) {
+ primitiveValues[count] = ((Character) values.get(count)).charValue();
+ }
+ return primitiveValues;
+ } else if (fieldType.getName().equals("byte")) {
+ byte[] primitiveValues = new byte[values.size()];
+ for (int count = 0; count < values.size(); ++count) {
+ primitiveValues[count] = ((Byte) values.get(count)).byteValue();
+ }
+ return primitiveValues;
+ } else if (fieldType.getName().equals("short")) {
+ short[] primitiveValues = new short[values.size()];
+ for (int count = 0; count < values.size(); ++count) {
+ primitiveValues[count] = ((Short) values.get(count)).shortValue();
+ }
+ return primitiveValues;
+ } else if (fieldType.getName().equals("long")) {
+ long[] primitiveValues = new long[values.size()];
+ for (int count = 0; count < values.size(); ++count) {
+ primitiveValues[count] = ((Long) values.get(count)).longValue();
+ }
+ return primitiveValues;
+ } else if (fieldType.getName().equals("double")) {
+ double[] primitiveValues = new double[values.size()];
+ for (int count = 0; count < values.size(); ++count) {
+ primitiveValues[count] = ((Double) values.get(count)).doubleValue();
+ }
+ return primitiveValues;
+ }
+ }
+ return values;
+ }
+
+ public abstract String getText(T source) throws XML2JavaMapperException;
+
+ public abstract Iterator<T> getChildElements(T parent) throws XML2JavaMapperException;
+
+ public abstract String getElementName(T element) throws XML2JavaMapperException;
+
+ public abstract boolean isTextElement(T element) throws XML2JavaMapperException;
+
+ public abstract boolean isTextOnly(T element) throws XML2JavaMapperException;
+
+ public abstract T getFirstChildWithName(T element, QName name) throws XML2JavaMapperException;
+
+ public abstract T getRootElement(T element) throws XML2JavaMapperException;
+
+ @Override
+ public Class<Object> getTargetType() {
+ return Object.class;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JavaBeansDataBinding.NAME;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaMapperException.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaMapperException.java
new file mode 100644
index 0000000000..ae06d68e67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaMapperException.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.sca.databinding.javabeans;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This exception is used to encapsulate and rethrow exceptions that arise out
+ * of converting XML Data to Java Objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XML2JavaMapperException extends RuntimeException {
+ private static final long serialVersionUID = 6596530102591630642L;
+
+ private QName xmlElementName;
+ private String javaFieldName;
+ private Class javaType;
+
+ public XML2JavaMapperException(String message) {
+ super(message);
+ }
+
+ public XML2JavaMapperException(Throwable cause) {
+ super(cause);
+ }
+
+ public QName getXmlElementName() {
+ return xmlElementName;
+ }
+
+ public void setXmlElementName(QName xmlElementName) {
+ this.xmlElementName = xmlElementName;
+ }
+
+ public String getJavaFieldName() {
+ return javaFieldName;
+ }
+
+ public void setJavaFieldName(String javaFieldName) {
+ this.javaFieldName = javaFieldName;
+ }
+
+ public Class getJavaType() {
+ return javaType;
+ }
+
+ public void setJavaType(Class javaType) {
+ this.javaType = javaType;
+ }
+
+ @Override
+ public String getMessage() {
+ return super.getMessage() + " <" + getJavaFieldName() + "> " + " in <" + getJavaType() + ">";
+ }
+
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java
new file mode 100644
index 0000000000..847fcf226c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.util;
+
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public final class DataTypeHelper {
+ private DataTypeHelper() {
+ }
+
+ /**
+ * Find all classes referenced by this data type though java generics
+ * @param d
+ * @return
+ */
+ public static Set<Class<?>> findClasses(DataType d) {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ Set<Type> visited = new HashSet<Type>();
+ findClasses(d, classes, visited);
+ return classes;
+ }
+
+ private static void findClasses(DataType d, Set<Class<?>> classes, Set<Type> visited) {
+ if (d == null) {
+ return;
+ }
+ classes.add(d.getPhysical());
+ if (d.getPhysical() != d.getGenericType()) {
+ findClasses(d.getGenericType(), classes, visited);
+ }
+ }
+
+ /**
+ * Find referenced classes in the generic type
+ * @param type
+ * @param classSet
+ * @param visited
+ */
+ private static void findClasses(Type type, Set<Class<?>> classSet, Set<Type> visited) {
+ if (visited.contains(type) || type == null) {
+ return;
+ }
+ visited.add(type);
+ if (type instanceof Class) {
+ Class<?> cls = (Class<?>)type;
+ if (!cls.isInterface()) {
+ classSet.add(cls);
+ }
+ return;
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType)type;
+ findClasses(pType.getRawType(), classSet, visited);
+ for (Type t : pType.getActualTypeArguments()) {
+ findClasses(t, classSet, visited);
+ }
+ } else if (type instanceof TypeVariable) {
+ TypeVariable<?> tv = (TypeVariable<?>)type;
+ for (Type t : tv.getBounds()) {
+ findClasses(t, classSet, visited);
+ }
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType gType = (GenericArrayType)type;
+ findClasses(gType, classSet, visited);
+ } else if (type instanceof WildcardType) {
+ WildcardType wType = (WildcardType)type;
+ for (Type t : wType.getLowerBounds()) {
+ findClasses(t, classSet, visited);
+ }
+ for (Type t : wType.getUpperBounds()) {
+ findClasses(t, classSet, visited);
+ }
+ }
+ }
+
+ /**
+ * Get all the data types in the interface
+ * @param intf The interface
+ * @param useWrapper Use wrapper classes?
+ * @return A list of DataTypes
+ */
+ public static List<DataType> getDataTypes(Interface intf, boolean useWrapper) {
+ List<DataType> dataTypes = new ArrayList<DataType>();
+ for (Operation op : intf.getOperations()) {
+ getDataTypes(dataTypes, op, useWrapper);
+ }
+ return dataTypes;
+ }
+
+ /**
+ * Get all the data types in the operation
+ * @param op The operation
+ * @param useWrapper Use wrapper classes?
+ * @return A list of DataTypes
+ */
+ public static List<DataType> getDataTypes(Operation op, boolean useWrapper) {
+ List<DataType> dataTypes = new ArrayList<DataType>();
+ getDataTypes(dataTypes, op, useWrapper);
+ return dataTypes;
+ }
+
+ private static void getDataTypes(List<DataType> dataTypes, Operation op, boolean useWrapper) {
+ WrapperInfo wrapper = op.getWrapper();
+ if (useWrapper && wrapper != null) {
+ DataType dt1 = wrapper.getInputWrapperType();
+ if (dt1 != null) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = wrapper.getOutputWrapperType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ }
+ // FIXME: [rfeng] We may need to find the referenced classes in the child types
+ // else
+ {
+ for (DataType dt1 : op.getInputType().getLogical()) {
+ dataTypes.add(dt1);
+ }
+ DataType dt2 = op.getOutputType();
+ if (dt2 != null) {
+ dataTypes.add(dt2);
+ }
+ }
+ for (DataType<DataType> dt3 : op.getFaultTypes()) {
+ DataType dt4 = dt3.getLogical();
+ if (dt4 != null) {
+ dataTypes.add(dt4);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
new file mode 100644
index 0000000000..ed59911a0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
@@ -0,0 +1,300 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.stax.reader.SimpleXmlNodeImpl;
+import org.apache.tuscany.sca.common.xml.stax.reader.XmlNode;
+import org.apache.tuscany.sca.common.xml.stax.reader.XmlTreeStreamReaderImpl;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BeanXMLStreamReaderImpl extends XmlTreeStreamReaderImpl {
+ private static final Comparator<Accessor> COMPARATOR = new Comparator<Accessor>() {
+ public int compare(Accessor o1, Accessor o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ };
+
+ public static class BeanXmlNodeImpl extends SimpleXmlNodeImpl implements XmlNode {
+ private static final Object[] NULL = null;
+ private static final SimpleTypeMapper MAPPER = new SimpleTypeMapperImpl();
+
+ public BeanXmlNodeImpl(Object bean) {
+ super(getName(bean == null ? null : bean.getClass()), bean);
+ }
+
+ public BeanXmlNodeImpl(QName name, Object bean) {
+ super(name, bean);
+ }
+
+ private static boolean isSimpleType(Class<?> javaType) {
+ return MAPPER.getXMLType(javaType) != null;
+ }
+
+ private static String getStringValue(Object o) {
+ if (o == null) {
+ return null;
+ }
+ TypeInfo info = MAPPER.getXMLType(o.getClass());
+ if (info != null) {
+ return MAPPER.toXMLLiteral(info.getQName(), o, null);
+ } else {
+ return String.valueOf(o);
+ }
+ }
+
+ @Override
+ public Iterator<XmlNode> children() {
+ if (name == null) {
+ return null;
+ }
+ if (value == null) {
+ return super.children();
+ }
+ if (isSimpleType(value.getClass())) {
+ XmlNode textNode = new BeanXmlNodeImpl(null, value);
+ return Arrays.asList(textNode).iterator();
+ }
+ if (Map.class.isAssignableFrom(value.getClass())) {
+ List<XmlNode> entries = new ArrayList<XmlNode>();
+ QName entryName = new QName(name.getNamespaceURI(), "entry");
+ Map map = (Map)value;
+ if (map != null) {
+ for (Object e : map.entrySet()) {
+ Map.Entry entry = (Map.Entry)e;
+ entries.add(new BeanXmlNodeImpl(entryName, entry));
+ }
+ }
+ return entries.iterator();
+ }
+ try {
+ Map<String, Accessor> accessorMap = getAccessors(value);
+ List<Accessor> accessorList = new ArrayList<Accessor>(accessorMap.values());
+ Collections.sort(accessorList, COMPARATOR);
+
+ List<XmlNode> props = new ArrayList<XmlNode>();
+ for (Accessor accessor : accessorList) {
+ Class<?> pType = accessor.getType();
+
+ QName pName = new QName(name.getNamespaceURI(), accessor.getName());
+ Object pValue = accessor.getValue();
+ if (pType.isArray()) {
+ if (pValue != null) {
+ int i1 = Array.getLength(pValue);
+ for (int j = 0; j < i1; j++) {
+ Object o = Array.get(pValue, j);
+ props.add(new BeanXmlNodeImpl(pName, o));
+ }
+ } else {
+ // TODO: How to handle null?
+ }
+ } else if (Collection.class.isAssignableFrom(pType)) {
+ Collection objList = (Collection)pValue;
+ if (objList != null && objList.size() > 0) {
+ for (Iterator j = objList.iterator(); j.hasNext();) {
+ Object o = j.next();
+ props.add(new BeanXmlNodeImpl(pName, o));
+ }
+
+ } else {
+ // How to handle null
+ }
+ } else {
+ props.add(new BeanXmlNodeImpl(pName, pValue));
+ }
+ }
+ return props.iterator();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ @Override
+ public QName getName() {
+ return name;
+ }
+
+ @Override
+ public String getValue() {
+ return getStringValue(value);
+ }
+
+ private static String getPackageName(Class<?> cls) {
+ String name = cls.getName();
+ int index = name.lastIndexOf('.');
+ return index == -1 ? "" : name.substring(0, index);
+ }
+
+ public static QName getName(Class<?> cls) {
+ if (cls == null) {
+ return null;
+ }
+
+ String packageName = getPackageName(cls);
+
+ if ("".equals(packageName)) {
+ return new QName("", cls.getSimpleName());
+ }
+ StringBuffer ns = new StringBuffer("http://");
+ String[] names = packageName.split("\\.");
+ for (int i = names.length - 1; i >= 0; i--) {
+ ns.append(names[i]);
+ if (i != 0) {
+ ns.append('.');
+ }
+ }
+ ns.append('/');
+ return new QName(ns.toString(), cls.getSimpleName());
+ }
+
+ }
+
+ public BeanXMLStreamReaderImpl(QName name, Object bean) {
+ super(getXmlNode(name, bean));
+ }
+
+ private static BeanXmlNodeImpl getXmlNode(QName name, Object bean) {
+ BeanXmlNodeImpl root = null;
+ if (name != null) {
+ root = new BeanXmlNodeImpl(name, bean);
+ } else {
+ root = new BeanXmlNodeImpl(bean);
+ }
+ return root;
+ }
+
+ public static interface Accessor {
+ String getName();
+
+ Class<?> getType();
+
+ Object getValue() throws Exception;
+
+ void setValue(Object value) throws Exception;
+ }
+
+ private static class FieldAccessor implements Accessor {
+ private Object target;
+ private Field field;
+
+ public FieldAccessor(Object target, Field field) {
+ super();
+ this.target = target;
+ this.field = field;
+ this.field.setAccessible(true);
+ }
+
+ public String getName() {
+ return field.getName();
+ }
+
+ public Object getValue() throws Exception {
+ return field.get(target);
+ }
+
+ public void setValue(Object value) throws Exception {
+ field.set(target, value);
+ }
+
+ public Class<?> getType() {
+ return field.getType();
+ }
+
+ }
+
+ private static class PropertyAccessor implements Accessor {
+ private Object target;
+ private PropertyDescriptor prop;
+
+ public PropertyAccessor(Object target, PropertyDescriptor prop) {
+ super();
+ this.target = target;
+ this.prop = prop;
+ }
+
+ public String getName() {
+ return prop.getName();
+ }
+
+ public Class<?> getType() {
+ return prop.getPropertyType();
+ }
+
+ public Object getValue() throws Exception {
+ Method getter = prop.getReadMethod();
+ if (getter != null) {
+ getter.setAccessible(true);
+ return getter.invoke(target);
+ }
+ throw new IllegalAccessException("The property cannot be read: " + getName());
+ }
+
+ public void setValue(Object value) throws Exception {
+ Method setter = prop.getWriteMethod();
+ if (setter != null) {
+ setter.setAccessible(true);
+ setter.invoke(target);
+ }
+ throw new IllegalAccessException("The property cannot be written: " + getName());
+ }
+
+ }
+
+ private static Map<String, Accessor> getAccessors(Object target) throws Exception {
+ if (target == null) {
+ return Collections.emptyMap();
+ }
+ Map<String, Accessor> map = new HashMap<String, Accessor>();
+ Class<?> type = target.getClass();
+ for (Field f : type.getFields()) {
+ map.put(f.getName(), new FieldAccessor(target, f));
+ }
+ BeanInfo info = Introspector.getBeanInfo(type, Object.class);
+ for (PropertyDescriptor p : info.getPropertyDescriptors()) {
+ // if (p.getReadMethod() != null && p.getWriteMethod() != null) {
+ map.put(p.getName(), new PropertyAccessor(target, p));
+ // }
+ }
+ return map;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.java
new file mode 100644
index 0000000000..b21a531c53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+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;
+
+/**
+ * DOM DataBinding
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class DOMDataBinding extends BaseDataBinding {
+ public static final String NAME = Node.class.getName();
+
+ public static final String ROOT_NAMESPACE = "http://tuscany.apache.org/xmlns/sca/databinding/dom/1.0";
+ public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "root");
+
+ private DOMHelper domHelper;
+
+ public DOMDataBinding(ExtensionPointRegistry registry) {
+ super(NAME, Node.class);
+ this.domHelper = DOMHelper.getInstance(registry);
+ }
+
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return new DOMWrapperHandler(domHelper);
+ }
+
+ @Override
+ public Object copy(Object source,
+ DataType dataType,
+ DataType targetDataType,
+ Operation operation,
+ Operation targetOperation) {
+ if (Node.class.isAssignableFrom(source.getClass())) {
+ Node nodeSource = (Node)source;
+ return nodeSource.cloneNode(true);
+ }
+ return super.copy(source, dataType, targetDataType, operation, targetOperation);
+ }
+
+ @Override
+ public boolean introspect(DataType type, Operation operation) {
+ if (Node.class.isAssignableFrom(type.getPhysical())) {
+ if (type.getLogical() == null) {
+ type.setLogical(new XMLType(ROOT_ELEMENT, null));
+ }
+ type.setDataBinding(NAME);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @param context
+ * @param element
+ */
+ public static Element adjustElementName(TransformationContext context, Element element) {
+ if (context != null) {
+ DataType dataType = context.getTargetDataType();
+ Object logical = dataType == null ? null : dataType.getLogical();
+ if (!(logical instanceof XMLType)) {
+ return element;
+ }
+ XMLType xmlType = (XMLType)logical;
+ QName name = new QName(element.getNamespaceURI(), element.getLocalName());
+ if (xmlType.isElement() && !xmlType.getElementName().equals(name)) {
+ QName newName = xmlType.getElementName();
+ String prefix = newName.getPrefix();
+ String qname = newName.getLocalPart();
+ if (prefix != null && !prefix.equals("")) {
+ qname = prefix + ":" + qname;
+ }
+ Document doc = element.getOwnerDocument();
+ Element newElement = doc.createElementNS(newName.getNamespaceURI(), qname);
+ // Copy the attributes to the new element
+ NamedNodeMap attrs = element.getAttributes();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ Attr attr = (Attr)doc.importNode(attrs.item(i), true);
+ newElement.getAttributes().setNamedItem(attr);
+ }
+
+ // Move all the children
+ while (element.hasChildNodes()) {
+ newElement.appendChild(element.getFirstChild());
+ }
+
+ // Replace the old node with the new node
+ if (element.getParentNode() != null) {
+ element.getParentNode().replaceChild(newElement, element);
+ }
+
+ return newElement;
+ }
+ }
+ return element;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java
new file mode 100644
index 0000000000..4ce5dc6c69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class DOMWrapperHandler implements WrapperHandler<Node> {
+ private DOMHelper domHelper;
+
+ public DOMWrapperHandler(DOMHelper domHelper) {
+ super();
+ this.domHelper = domHelper;
+ }
+
+ public Node create(Operation operation, boolean input) {
+
+ WrapperInfo wrapperInfo = operation.getWrapper();
+ ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement();
+ // Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass();
+ Document document = domHelper.newDocument();
+ QName name = element.getQName();
+ return DOMHelper.createElement(document, name);
+ }
+
+ public void setChildren(Node wrapper,
+ Object[] childObjects,
+ Operation operation, boolean input) {
+ List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements():
+ operation.getWrapper().getOutputChildElements();
+ for (int i = 0; i < childElements.size(); i++) {
+ setChild(wrapper, i, childElements.get(i), childObjects[i]);
+ }
+
+ }
+ public void setChild(Node wrapper, int i, ElementInfo childElement, Object value) {
+ Node node = (Node)value;
+ if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ node = ((Document)node).getDocumentElement();
+ }
+ wrapper.appendChild(wrapper.getOwnerDocument().importNode(node, true));
+ }
+
+ public List getChildren(Node wrapper, Operation operation, boolean input) {
+ assert wrapper != null;
+ List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements():
+ operation.getWrapper().getOutputChildElements();
+ if (wrapper.getNodeType() == Node.DOCUMENT_NODE) {
+ wrapper = ((Document)wrapper).getDocumentElement();
+ }
+ List<Node> elements = new ArrayList<Node>();
+ NodeList nodes = wrapper.getChildNodes();
+ for (int j = 0; j < nodes.getLength(); j++) {
+ Node node = nodes.item(j);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ elements.add(node);
+ }
+ }
+ return elements;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean)
+ */
+ public DataType getWrapperType(Operation operation, boolean input) {
+ WrapperInfo wrapper = operation.getWrapper();
+ ElementInfo element = input? wrapper.getInputWrapperElement(): wrapper.getOutputWrapperElement();
+ DataType<XMLType> wrapperType =
+ new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(element));
+ return wrapperType;
+ }
+
+ public boolean isInstance(Object wrapperObj,
+ Operation operation,
+ boolean input) {
+ WrapperInfo wrapperInfo = operation.getWrapper();
+ ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement();
+ List<ElementInfo> childElements =
+ input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements();
+ Node wrapper = (Node)wrapperObj;
+ if (wrapper.getNodeType() == Node.DOCUMENT_NODE) {
+ wrapper = ((Document)wrapper).getDocumentElement();
+ }
+ QName elementName = new QName(wrapper.getNamespaceURI(), wrapper.getLocalName());
+ if (!element.getQName().equals(elementName)) {
+ return false;
+ }
+ Set<QName> names = new HashSet<QName>();
+ for (ElementInfo e : childElements) {
+ names.add(e.getQName());
+ }
+ NodeList nodes = wrapper.getChildNodes();
+ for (int j = 0; j < nodes.getLength(); j++) {
+ Node node = nodes.item(j);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ elementName = new QName(wrapper.getNamespaceURI(), wrapper.getLocalName());
+ if (!names.contains(elementName)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.java
new file mode 100644
index 0000000000..0bb0513011
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.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.sca.databinding.xml;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+/**
+ * Push DOM InputSource to Node
+ *
+ * @version $Rev$ $Date$
+ */
+public class InputSource2Node extends BaseTransformer<InputSource, Node> implements
+ PullTransformer<InputSource, Node> {
+
+ private final Source2ResultTransformer TRANSFORMER;
+
+ public InputSource2Node(ExtensionPointRegistry registry) {
+ super();
+ this.TRANSFORMER = new Source2ResultTransformer(registry);
+ }
+
+ public Node transform(InputSource source, TransformationContext context) {
+ try {
+ Source streamSource = new StreamSource(source.getCharacterStream());
+ DOMResult result = new DOMResult();
+ TRANSFORMER.transform(streamSource, result, context);
+ return result.getNode();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public Class<InputSource> getSourceType() {
+ return InputSource.class;
+ }
+
+ @Override
+ public Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2SAX.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2SAX.java
new file mode 100644
index 0000000000..b0b5d336f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2SAX.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.sca.databinding.xml;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Push InputSource to SAX
+ *
+ * @version $Rev$ $Date$
+ */
+public class InputSource2SAX extends BaseTransformer<InputSource, ContentHandler> implements
+ PushTransformer<InputSource, ContentHandler> {
+
+ public void transform(InputSource source, ContentHandler target, TransformationContext context) {
+ try {
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
+ reader.setContentHandler(target);
+ reader.parse(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public Class<InputSource> getSourceType() {
+ return InputSource.class;
+ }
+
+ @Override
+ public Class<ContentHandler> getTargetType() {
+ return ContentHandler.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.java
new file mode 100644
index 0000000000..c9183c4cbf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.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.sca.databinding.xml;
+
+import java.io.InputStream;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.sax.SAXSource;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+/**
+ * Push DOM InputSource to Node
+ *
+ * @version $Rev$ $Date$
+ */
+public class InputStream2Node extends BaseTransformer<InputStream, Node> implements
+ PullTransformer<InputStream, Node> {
+ private final Source2ResultTransformer TRANSFORMER;
+
+ public InputStream2Node(ExtensionPointRegistry registry) {
+ super();
+ this.TRANSFORMER = new Source2ResultTransformer(registry);
+ }
+
+
+ public Node transform(InputStream source, TransformationContext context) {
+ try {
+ Source streamSource = new SAXSource(new InputSource(source));
+ DOMResult result = new DOMResult();
+ TRANSFORMER.transform(streamSource, result, context);
+ return result.getNode();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public Class<InputStream> getSourceType() {
+ return InputStream.class;
+ }
+
+ @Override
+ public Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2SAX.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2SAX.java
new file mode 100644
index 0000000000..f762122350
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2SAX.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import java.io.InputStream;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Push InputStream to SAX
+ *
+ * @version $Rev$ $Date$
+ */
+public class InputStream2SAX extends BaseTransformer<InputStream, ContentHandler> implements
+ PushTransformer<InputStream, ContentHandler> {
+ public void transform(InputStream source, ContentHandler target, TransformationContext context) {
+ try {
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setContentHandler(target);
+ reader.parse(new InputSource(source));
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public Class<InputStream> getSourceType() {
+ return InputStream.class;
+ }
+
+ @Override
+ public Class<ContentHandler> getTargetType() {
+ return ContentHandler.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.java
new file mode 100644
index 0000000000..25ed70dda5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.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.sca.databinding.xml;
+
+import java.io.OutputStream;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+
+/**
+ * Push DOM Node to OutputStream
+ *
+ * @version $Rev$ $Date$
+ */
+public class Node2OutputStream extends BaseTransformer<Node, OutputStream> implements
+ PushTransformer<Node, OutputStream> {
+
+ private final Source2ResultTransformer TRANSFORMER;
+
+ public Node2OutputStream(ExtensionPointRegistry registry) {
+ super();
+ this.TRANSFORMER = new Source2ResultTransformer(registry);
+ }
+
+ public void transform(Node source, OutputStream writer, TransformationContext context) {
+ try {
+ Source domSource = new DOMSource(source);
+ Result result = new StreamResult(writer);
+ TRANSFORMER.transform(domSource, result, context);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Node> getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class<OutputStream> getTargetType() {
+ return OutputStream.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SimpleJavaType.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SimpleJavaType.java
new file mode 100644
index 0000000000..d5bf7e76b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SimpleJavaType.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.xml;
+
+import org.apache.tuscany.sca.databinding.impl.SimpleType2JavaTransformer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * Transformer to convert data from a simple java Object to OMElement.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Node2SimpleJavaType extends SimpleType2JavaTransformer<Node> {
+
+ @Override
+ protected String getText(Node source) {
+ if (source instanceof Document) {
+ source = ((Document)source).getDocumentElement();
+ }
+ return source.getTextContent();
+
+ }
+
+ @Override
+ public Class getSourceType() {
+ return Node.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SourceTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SourceTransformer.java
new file mode 100644
index 0000000000..cb33d3548a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SourceTransformer.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.sca.databinding.xml;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+
+/**
+ * Transform TrAX Node to Source
+ *
+ * @version $Rev$ $Date$
+ */
+public class Node2SourceTransformer extends BaseTransformer<Node, Source> implements
+ PullTransformer<Node, Source> {
+
+ public Source transform(Node source, TransformationContext context) {
+ try {
+ return new DOMSource(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Node> getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class<Source> getTargetType() {
+ return Source.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java
new file mode 100644
index 0000000000..fb3023345c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import java.io.StringWriter;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+
+/**
+ * Transform DOM Node to XML String
+ *
+ * @version $Rev$ $Date$
+ */
+public class Node2String extends BaseTransformer<Node, String> implements PullTransformer<Node, String> {
+ private final Node2Writer TRANSFORMER;
+
+ public Node2String(ExtensionPointRegistry registry) {
+ super();
+ this.TRANSFORMER = new Node2Writer(registry);
+ }
+
+ public String transform(Node source, TransformationContext context) {
+ try {
+ StringWriter writer = new StringWriter();
+ TRANSFORMER.transform(source, writer, context);
+ return writer.toString();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ public Class<Node> getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ public Class<String> getTargetType() {
+ return String.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.java
new file mode 100644
index 0000000000..6c1d241ce9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.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.sca.databinding.xml;
+
+import java.io.Writer;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+
+/**
+ * Push DOM Node to Writer
+ *
+ * @version $Rev$ $Date$
+ */
+public class Node2Writer extends BaseTransformer<Node, Writer> implements PushTransformer<Node, Writer> {
+
+ private final Source2ResultTransformer TRANSFORMER;
+
+ public Node2Writer(ExtensionPointRegistry registry) {
+ super();
+ this.TRANSFORMER = new Source2ResultTransformer(registry);
+ }
+
+ public void transform(Node source, Writer writer, TransformationContext context) {
+ try {
+ Source domSource = new DOMSource(source);
+ Result result = new StreamResult(writer);
+ TRANSFORMER.transform(domSource, result, context);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Node> getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class<Writer> getTargetType() {
+ return Writer.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2XMLStreamReader.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2XMLStreamReader.java
new file mode 100644
index 0000000000..2e0612b9b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2XMLStreamReader.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.sca.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.xml.stax.reader.DOMXMLStreamReader;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+
+/**
+ * Transform DOM Node to XML XMLStreamReader
+ *
+ * @version $Rev$ $Date$
+ */
+public class Node2XMLStreamReader extends BaseTransformer<Node, XMLStreamReader> implements
+ PullTransformer<Node, XMLStreamReader> {
+
+ public XMLStreamReader transform(Node source, TransformationContext context) {
+ if (source == null) {
+ return null;
+ }
+ try {
+ DOMXMLStreamReader reader = new DOMXMLStreamReader(source);
+ return reader;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Node> getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.java
new file mode 100644
index 0000000000..1866f3864a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.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.databinding.xml;
+
+import java.io.Reader;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+
+/**
+ * Push DOM Reader to Node
+ *
+ * @version $Rev$ $Date$
+ */
+public class Reader2Node extends BaseTransformer<Reader, Node> implements PullTransformer<Reader, Node> {
+ private final Source2ResultTransformer TRANSFORMER;
+
+ public Reader2Node(ExtensionPointRegistry registry) {
+ super();
+ this.TRANSFORMER = new Source2ResultTransformer(registry);
+ }
+
+ public Node transform(Reader source, TransformationContext context) {
+ try {
+ Source streamSource = new StreamSource(source);
+ DOMResult result = new DOMResult();
+ TRANSFORMER.transform(streamSource, result, context);
+ return result.getNode();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Reader> getSourceType() {
+ return Reader.class;
+ }
+
+ @Override
+ protected Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2SAX.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2SAX.java
new file mode 100644
index 0000000000..396038ec08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2SAX.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.databinding.xml;
+
+import java.io.Reader;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+
+/**
+ * Transform XML string to SAX
+ *
+ * @version $Rev$ $Date$
+ */
+public class Reader2SAX extends BaseTransformer<Reader, ContentHandler> implements
+ PushTransformer<Reader, ContentHandler> {
+ public void transform(Reader source, ContentHandler target, TransformationContext context) {
+ try {
+ new InputSource2SAX().transform(new InputSource(source), target, context);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Reader> getSourceType() {
+ return Reader.class;
+ }
+
+ @Override
+ protected Class<ContentHandler> getTargetType() {
+ return ContentHandler.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SAX2DOMPipe.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SAX2DOMPipe.java
new file mode 100644
index 0000000000..9bc5f99304
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SAX2DOMPipe.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.databinding.xml;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+
+public class SAX2DOMPipe extends BaseTransformer<ContentHandler, Node> implements DataPipeTransformer<ContentHandler, Node> {
+ private DOMHelper domHelper;
+ /**
+ *
+ */
+ public SAX2DOMPipe(ExtensionPointRegistry registry) {
+ super();
+ domHelper = DOMHelper.getInstance(registry);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.DataPipeTransformer#newInstance()
+ */
+ public DataPipe<ContentHandler, Node> newInstance() {
+ return new Pipe();
+ }
+
+ @Override
+ protected Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class<ContentHandler> getSourceType() {
+ return ContentHandler.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 30;
+ }
+
+ private class Pipe implements DataPipe<ContentHandler, Node> {
+ private DOMHelper.NodeContentHandler pipe;
+
+ public Pipe() {
+ super();
+ this.pipe = domHelper.createContentHandler(null);
+ }
+
+ public Node getResult() {
+ return pipe.getNode();
+ }
+
+ public ContentHandler getSink() {
+ return pipe;
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SimpleJavaType2Node.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SimpleJavaType2Node.java
new file mode 100644
index 0000000000..0bb13bb3ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SimpleJavaType2Node.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.Java2SimpleTypeTransformer;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * Transformer to convert data from an simple OMElement to Java Object
+ *
+ * @version $Rev$ $Date$
+ */
+public class SimpleJavaType2Node extends Java2SimpleTypeTransformer<Node> {
+ private DOMHelper helper;
+
+ public SimpleJavaType2Node(ExtensionPointRegistry registry) {
+ super();
+ helper = DOMHelper.getInstance(registry);
+ }
+
+ @Override
+ protected Node createElement(QName element, String text, TransformationContext context) {
+ if (element == null) {
+ element = DOMDataBinding.ROOT_ELEMENT;
+ }
+ Document factory = helper.newDocument();
+ Node root = DOMHelper.createElement(factory, element);
+ if (text != null) {
+ root.appendChild(factory.createTextNode(text));
+ } else {
+ Attr nil = factory.createAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:nil");
+ nil.setValue("true");
+ root.appendChild(nil);
+ }
+ return root;
+ }
+
+ @Override
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2NodeTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2NodeTransformer.java
new file mode 100644
index 0000000000..d2fb8305e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2NodeTransformer.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.databinding.xml;
+
+import javax.xml.transform.Source;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * Transform TrAX Source to Node
+ *
+ * @version $Rev$ $Date$
+ */
+public class Source2NodeTransformer extends BaseTransformer<Source, Node> implements
+ PullTransformer<Source, Node> {
+ private DOMHelper helper;
+
+ public Source2NodeTransformer(ExtensionPointRegistry registry) {
+ super();
+ helper = DOMHelper.getInstance(registry);
+ }
+
+ public Node transform(Source source, TransformationContext context) {
+ try {
+ Document doc = helper.load(source);
+ return DOMDataBinding.adjustElementName(context, doc.getDocumentElement());
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Source> getSourceType() {
+ return Source.class;
+ }
+
+ @Override
+ protected Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.java
new file mode 100644
index 0000000000..dd69e3ea66
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.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.databinding.xml;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+/**
+ * Transform TrAX Source to Result
+ *
+ * @version $Rev$ $Date$
+ */
+public class Source2ResultTransformer extends BaseTransformer<Source, Result> implements
+ PushTransformer<Source, Result> {
+ private final TransformerFactory factory;
+
+ public Source2ResultTransformer(ExtensionPointRegistry registry) {
+ super();
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ factory = factories.getFactory(TransformerFactory.class);
+ }
+
+ public void transform(Source source, Result result, TransformationContext context) {
+ try {
+ javax.xml.transform.Transformer transformer = factory.newTransformer();
+ transformer.transform(source, result);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Source> getSourceType() {
+ return Source.class;
+ }
+
+ @Override
+ protected Class<Result> getTargetType() {
+ return Result.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.java
new file mode 100644
index 0000000000..0c3db2a477
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.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.sca.databinding.xml;
+
+import java.io.StringWriter;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+/**
+ * Transform TrAX Source to String
+ *
+ * @version $Rev$ $Date$
+ */
+public class Source2StringTransformer extends BaseTransformer<Source, String> implements
+ PullTransformer<Source, String> {
+ private final TransformerFactory factory;
+
+ public Source2StringTransformer(ExtensionPointRegistry registry) {
+ super();
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ factory = factories.getFactory(TransformerFactory.class);
+ }
+
+ public String transform(Source source, TransformationContext context) {
+ try {
+ javax.xml.transform.Transformer transformer = factory.newTransformer();
+ StringWriter sw = new StringWriter();
+ StreamResult result = new StreamResult(sw);
+ transformer.transform(source, result);
+ return sw.toString();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<Source> getSourceType() {
+ return Source.class;
+ }
+
+ @Override
+ protected Class<String> getTargetType() {
+ return String.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StAXDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StAXDataBinding.java
new file mode 100644
index 0000000000..f8ae31b96c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StAXDataBinding.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.sca.databinding.xml;
+
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * A DataBinding for the StAX
+ *
+ * @version $Rev$ $Date$
+ */
+public class StAXDataBinding extends BaseDataBinding {
+ public static final String NAME = XMLStreamReader.class.getName();
+
+ public StAXDataBinding() {
+ super(NAME, XMLStreamReader.class);
+ }
+
+ @Override
+ public boolean introspect(DataType type, Operation operation) {
+ if (super.introspect(type, operation)) {
+ type.setLogical(XMLType.UNKNOWN);
+ type.setDataBinding(NAME);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StreamDataPipe.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StreamDataPipe.java
new file mode 100644
index 0000000000..38f8327ae4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StreamDataPipe.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.sca.databinding.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+
+public class StreamDataPipe extends BaseTransformer<OutputStream, InputStream> implements
+ DataPipeTransformer<OutputStream, InputStream> {
+
+ public DataPipe<OutputStream, InputStream> newInstance() {
+ return new Pipe();
+ }
+
+ @Override
+ protected Class<InputStream> getTargetType() {
+ return InputStream.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 50;
+ }
+
+ @Override
+ protected Class<OutputStream> getSourceType() {
+ return OutputStream.class;
+ }
+
+ public static class Pipe implements DataPipe<OutputStream, InputStream> {
+ private ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+ public InputStream getResult() {
+ return new ByteArrayInputStream(outputStream.toByteArray());
+ }
+
+ public OutputStream getSink() {
+ return outputStream;
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2Node.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2Node.java
new file mode 100644
index 0000000000..cfcbce2e12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2Node.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.databinding.xml;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Node;
+
+public class String2Node extends BaseTransformer<String, Node> implements PullTransformer<String, Node> {
+ private DOMHelper helper;
+
+ public String2Node(ExtensionPointRegistry registry) {
+ super();
+ helper = DOMHelper.getInstance(registry);
+ }
+
+ public Node transform(String source, TransformationContext context) {
+ try {
+ return helper.load(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<String> getSourceType() {
+ return String.class;
+ }
+
+ @Override
+ protected Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 50;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SAX.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SAX.java
new file mode 100644
index 0000000000..461adbe938
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SAX.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.sca.databinding.xml;
+
+import java.io.StringReader;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+
+/**
+ * Transform XML string to SAX
+ *
+ * @version $Rev$ $Date$
+ */
+public class String2SAX extends BaseTransformer<String, ContentHandler> implements
+ PushTransformer<String, ContentHandler> {
+
+ public void transform(String source, ContentHandler target, TransformationContext context) {
+ try {
+ new InputSource2SAX().transform(new InputSource(new StringReader(source)), target, context);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<String> getSourceType() {
+ return String.class;
+ }
+
+ @Override
+ protected Class<ContentHandler> getTargetType() {
+ return ContentHandler.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SourceTransformer.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SourceTransformer.java
new file mode 100644
index 0000000000..31093b8587
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SourceTransformer.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.databinding.xml;
+
+import java.io.StringReader;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+/**
+ * Transform XML String to Source
+ *
+ * @version $Rev$ $Date$
+ */
+public class String2SourceTransformer extends BaseTransformer<String, Source> implements
+ PullTransformer<String, Source> {
+
+ public Source transform(String source, TransformationContext context) {
+ try {
+ return new StreamSource(new StringReader(source));
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<String> getSourceType() {
+ return String.class;
+ }
+
+ @Override
+ protected Class<Source> getTargetType() {
+ return Source.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2XMLStreamReader.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2XMLStreamReader.java
new file mode 100644
index 0000000000..156e15d8c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2XMLStreamReader.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.databinding.xml;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+public class String2XMLStreamReader extends BaseTransformer<String, XMLStreamReader> implements
+ PullTransformer<String, XMLStreamReader> {
+ private StAXHelper helper;
+
+ public String2XMLStreamReader(ExtensionPointRegistry registry) {
+ helper = StAXHelper.getInstance(registry);
+ }
+
+ public XMLStreamReader transform(String source, TransformationContext context) {
+ try {
+ return helper.createXMLStreamReader(source);
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<String> getSourceType() {
+ return String.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 50;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Writer2ReaderDataPipe.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Writer2ReaderDataPipe.java
new file mode 100644
index 0000000000..0544631a73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Writer2ReaderDataPipe.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.sca.databinding.xml;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+
+public class Writer2ReaderDataPipe extends BaseTransformer<Writer, Reader> implements DataPipeTransformer<Writer, Reader> {
+
+ public DataPipe<Writer, Reader> newInstance() {
+ return new Pipe();
+ }
+
+ @Override
+ protected Class<Reader> getTargetType() {
+ return Reader.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 50;
+ }
+
+ @Override
+ protected Class<Writer> getSourceType() {
+ return Writer.class;
+ }
+
+ private static class Pipe implements DataPipe<Writer, Reader> {
+ private StringWriter writer = new StringWriter();
+
+ public Reader getResult() {
+ return new StringReader(writer.toString());
+ }
+
+ public Writer getSink() {
+ return writer;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLGroupDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLGroupDataBinding.java
new file mode 100644
index 0000000000..f7c895db1e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLGroupDataBinding.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.databinding.xml;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.databinding.impl.GroupDataBinding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+
+/**
+ * A Group DataBinding
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLGroupDataBinding extends GroupDataBinding {
+
+ public XMLGroupDataBinding() {
+ super(new Class[] {InputStream.class, OutputStream.class, Reader.class, Writer.class,
+ // Source.class, Result.class,
+ InputSource.class, ContentHandler.class, XMLStreamReader.class,
+ XMLStreamWriter.class, XMLEventReader.class, XMLEventWriter.class});
+ }
+
+ @Override
+ protected Object getLogical(Class<?> markerType, Operation operation) {
+ return XMLType.UNKNOWN;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2Node.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2Node.java
new file mode 100644
index 0000000000..f8f21736ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2Node.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.sca.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.DataPipe;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+
+/**
+ * Transform DOM Node to XML XMLStreamReader
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLStreamReader2Node extends BaseTransformer<XMLStreamReader, Node> implements
+ PullTransformer<XMLStreamReader, Node> {
+
+ private XMLStreamReader2SAX stax2sax;
+ private SAX2DOMPipe sax2domPipe;
+
+ public XMLStreamReader2Node(ExtensionPointRegistry registry) {
+ stax2sax = new XMLStreamReader2SAX(registry);
+ sax2domPipe = new SAX2DOMPipe(registry);
+ }
+
+ public Node transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ DataPipe<ContentHandler, Node> pipe = sax2domPipe.newInstance();
+ stax2sax.transform(source, pipe.getSink(), context);
+ Node node = pipe.getResult();
+ source.close();
+ if (node instanceof Document) {
+ Document doc = (Document)node;
+ return DOMDataBinding.adjustElementName(context, doc.getDocumentElement());
+ } else {
+ return node;
+ }
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ protected Class<Node> getTargetType() {
+ return Node.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2SAX.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2SAX.java
new file mode 100644
index 0000000000..11dc23e4b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2SAX.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.xml.sax.ContentHandler;
+
+/**
+ * XMLStreamReader to SAX events
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLStreamReader2SAX extends BaseTransformer<XMLStreamReader, ContentHandler> implements
+ PushTransformer<XMLStreamReader, ContentHandler> {
+
+ private StAXHelper helper;
+
+ public XMLStreamReader2SAX(ExtensionPointRegistry registry) {
+ helper = StAXHelper.getInstance(registry);
+ }
+
+ @Override
+ protected Class<ContentHandler> getTargetType() {
+ return ContentHandler.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.PushTransformer#getWeight()
+ */
+ @Override
+ public int getWeight() {
+ return 20;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.PushTransformer#transform(java.lang.Object,
+ * java.lang.Object,
+ * org.apache.tuscany.sca.databinding.TransformationContext)
+ */
+ public void transform(XMLStreamReader source, ContentHandler sink, TransformationContext context) {
+ try {
+ helper.saveAsSAX(source, sink);
+ source.close();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2String.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2String.java
new file mode 100644
index 0000000000..64c93d74a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2String.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseTransformer;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+public class XMLStreamReader2String extends BaseTransformer<XMLStreamReader, String> implements
+ PullTransformer<XMLStreamReader, String> {
+ private StAXHelper helper;
+
+ public XMLStreamReader2String(ExtensionPointRegistry registry) {
+ helper = StAXHelper.getInstance(registry);
+ }
+
+ public String transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ String str = helper.saveAsString(source);
+ source.close();
+ return str;
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ @Override
+ protected Class<String> getTargetType() {
+ return String.class;
+ }
+
+ @Override
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.java b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.java
new file mode 100644
index 0000000000..b360b5b9a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * A DataBinding for the XML string
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class XMLStringDataBinding extends BaseDataBinding {
+ public static final String NAME = String.class.getName();
+
+ public XMLStringDataBinding() {
+ super(NAME, String.class);
+ }
+
+ @Override
+ public boolean introspect(DataType type, Operation operation) {
+ if (type.getPhysical() == String.class && NAME.equals(type.getDataBinding())) {
+ type.setDataBinding(NAME);
+ type.setLogical(XMLType.UNKNOWN);
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
new file mode 100644
index 0000000000..ef8a825d68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
@@ -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.
+
+# implementation classes for the databindings
+org.apache.tuscany.sca.databinding.xml.DOMDataBinding;name=org.w3c.dom.Node
+org.apache.tuscany.sca.databinding.xml.XMLStringDataBinding;name=java.lang.String
+org.apache.tuscany.sca.databinding.xml.XMLGroupDataBinding;name=databinding:group
+org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;name=java:complexType
+org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;name=java:simpleType
+org.apache.tuscany.sca.databinding.javabeans.JavaExceptionDataBinding;name=java:exception
+org.apache.tuscany.sca.databinding.externalizable.ExternalizableDataBinding;name=java.io.Externalizable
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint
new file mode 100644
index 0000000000..4cad1181b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.Mediator b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.Mediator
new file mode 100644
index 0000000000..c91908e630
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.Mediator
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.databinding.impl.MediatorImpl
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..9f609be7e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -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.
+
+# Implementation classes for the transformers
+org.apache.tuscany.sca.databinding.xml.InputSource2Node;source=org.xml.sax.InputSource,target=org.w3c.dom.Node,weight=80
+org.apache.tuscany.sca.databinding.xml.InputStream2Node;source=java.io.InputStream,target=org.w3c.dom.Node,weight=80
+# org.apache.tuscany.sca.databinding.javabeans.DOMNode2JavaBeanTransformer;source=org.w3c.dom.Node,target=java:complexType,weight=80000
+org.apache.tuscany.sca.databinding.xml.Node2String;source=org.w3c.dom.Node,target=java.lang.String,weight=80
+org.apache.tuscany.sca.databinding.xml.Node2XMLStreamReader;source=org.w3c.dom.Node,target=javax.xml.stream.XMLStreamReader,weight=80
+# org.apache.tuscany.sca.databinding.javabeans.JavaBean2DOMNodeTransformer;source=java:complexType,target=org.w3c.dom.Node,weight=80000
+# org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReaderTransformer;source=java:complexType,target=javax.xml.stream.XMLStreamReader,weight=79000
+org.apache.tuscany.sca.databinding.xml.Reader2Node;source=java.io.Reader,target=org.w3c.dom.Node,weight=80
+org.apache.tuscany.sca.databinding.xml.SAX2DOMPipe;source=org.xml.sax.ContentHandler,target=org.w3c.dom.Node,weight=70
+org.apache.tuscany.sca.databinding.xml.StreamDataPipe;source=java.io.OutputStream,target=java.io.InputStream,weight=90
+org.apache.tuscany.sca.databinding.xml.String2Node;source=java.lang.String,target=org.w3c.dom.Node,weight=90
+org.apache.tuscany.sca.databinding.xml.String2XMLStreamReader;source=java.lang.String,target=javax.xml.stream.XMLStreamReader,weight=90
+org.apache.tuscany.sca.databinding.xml.Writer2ReaderDataPipe;source=java.io.Writer,target=java.io.Reader,weight=90
+org.apache.tuscany.sca.databinding.xml.XMLStreamReader2Node;source=javax.xml.stream.XMLStreamReader,target=org.w3c.dom.Node,weight=80
+org.apache.tuscany.sca.databinding.xml.XMLStreamReader2String;source=javax.xml.stream.XMLStreamReader,target=java.lang.String,weight=80
+org.apache.tuscany.sca.databinding.xml.Node2SimpleJavaType;source=org.w3c.dom.Node,target=java:simpleType,weight=95000
+org.apache.tuscany.sca.databinding.xml.SimpleJavaType2Node;source=java:simpleType,target=org.w3c.dom.Node,weight=95000
+org.apache.tuscany.sca.databinding.xml.Source2NodeTransformer;source=javax.xml.transform.Source,target=org.w3c.dom.Node,weight=80
+org.apache.tuscany.sca.databinding.xml.Source2StringTransformer;source=javax.xml.transform.Source,target=java.lang.String,weight=80
+
+org.apache.tuscany.sca.databinding.xml.Node2SourceTransformer;source=org.w3c.dom.Node,target=javax.xml.transform.Source,weight=80
+org.apache.tuscany.sca.databinding.xml.String2SourceTransformer;source=java.lang.String,target=javax.xml.transform.Source,weight=80
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
new file mode 100644
index 0000000000..6c04591a1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation classes for the transformers
+org.apache.tuscany.sca.databinding.xml.InputSource2SAX;source=org.xml.sax.InputSource,target=org.xml.sax.ContentHandler,weight=80
+org.apache.tuscany.sca.databinding.xml.InputStream2SAX;source=java.io.InputStream,target=org.xml.sax.ContentHandler,weight=80
+org.apache.tuscany.sca.databinding.xml.Node2OutputStream;source=org.w3c.dom.Node,target=java.io.OutputStream,weight=80
+org.apache.tuscany.sca.databinding.xml.Node2Writer;source=org.w3c.dom.Node,target=java.io.Writer,weight=80
+org.apache.tuscany.sca.databinding.xml.Reader2SAX;source=java.io.Reader,target=org.xml.sax.ContentHandler,weight=80
+org.apache.tuscany.sca.databinding.xml.Source2ResultTransformer;source=javax.xml.transform.Source,target=javax.xml.transform.Result,weight=80
+org.apache.tuscany.sca.databinding.xml.String2SAX;source=java.lang.String,target=org.xml.sax.ContentHandler,weight=80
+org.apache.tuscany.sca.databinding.xml.XMLStreamReader2SAX;source=javax.xml.stream.XMLStreamReader,target=org.xml.sax.ContentHandler,weight=70
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.SimpleTypeMapper b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.SimpleTypeMapper
new file mode 100644
index 0000000000..f905a9aa7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.SimpleTypeMapper
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.databinding.impl.SimpleTypeMapperImpl
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint
new file mode 100644
index 0000000000..07762a14b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.java
new file mode 100644
index 0000000000..defa62a49e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.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.databinding.extension;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.BaseDataBinding;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.junit.Test;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataBindingExtensionTestCase {
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testExtension() {
+ DataBinding1 binding1 = new DataBinding1(Node.class);
+ assertEquals(Node.class.getName(), binding1.getName());
+ DataType dt1 = new DataTypeImpl<Class>(Element.class, null);
+ assertTrue(binding1.introspect(dt1, null));
+ DataType dt2 = new DataTypeImpl<Class>(String.class, null);
+ assertFalse(binding1.introspect(dt2, null));
+ assertNull(binding1.getWrapperHandler());
+
+ DataBindingExtensionPoint registry = new DefaultDataBindingExtensionPoint(new DefaultExtensionPointRegistry());
+ registry.addDataBinding(binding1);
+
+ assertNotNull(registry.getDataBinding(Node.class.getName()));
+
+ DataBinding1 binding2 = new DataBinding1("dom", Node.class);
+ assertEquals("dom", binding2.getName());
+ }
+
+ private static class DataBinding1 extends BaseDataBinding {
+
+ /**
+ * @param baseType
+ */
+ public DataBinding1(Class<?> baseType) {
+ super(baseType);
+ }
+
+ /**
+ * @param name
+ * @param baseType
+ */
+ public DataBinding1(String name, Class<?> baseType) {
+ super(name, baseType);
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/SimpleTypeMapperExtensionTestCase.java.fixme b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/SimpleTypeMapperExtensionTestCase.java.fixme
new file mode 100644
index 0000000000..562c22354c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/SimpleTypeMapperExtensionTestCase.java.fixme
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.extension;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.easymock.EasyMock;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class SimpleTypeMapperExtensionTestCase extends TestCase {
+
+ private static final Map<String, Object> SAMPLE_VALUES = new HashMap<String, Object>();
+
+ static {
+ SAMPLE_VALUES.put("anyURI", "http://www.w3.com");
+ SAMPLE_VALUES.put("boolean", new String[] {"true", "false", "1", "0"});
+ SAMPLE_VALUES.put("byte", new String[] {"-128", "127"});
+ SAMPLE_VALUES.put("date", new String[] {"2004-03-15", "2002-09-24-06:00"});
+ SAMPLE_VALUES.put("dateTime", "2003-12-25T08:30:00");
+ SAMPLE_VALUES.put("decimal", "3.1415292");
+ SAMPLE_VALUES.put("double", new String[] {"3.1415292", "INF", "NaN"});
+ SAMPLE_VALUES.put("duration", new String[] {"P8M3DT7H33M2S", "P5Y2M10DT15H"});
+ SAMPLE_VALUES.put("float", new String[] {"3.1415292", "INF", "NaN"});
+ SAMPLE_VALUES.put("gDay", "---11");
+ if (System.getProperty("java.vendor").toUpperCase().contains("SUN") && System.getProperty("java.version").contains("1.5.0")
+ ||
+ System.getProperty("java.vendor").toUpperCase().contains("APPLE INC.") && System.getProperty("java.version").contains("1.5.0")) {
+
+ // Work around a bug in SUN JDK (including Mac OS JDK)
+ SAMPLE_VALUES.put("gMonth", "--02--");
+ } else {
+ SAMPLE_VALUES.put("gMonth", "--02");
+ }
+ SAMPLE_VALUES.put("gMonthDay", "--02-14");
+ SAMPLE_VALUES.put("gYear", "1999");
+ SAMPLE_VALUES.put("gYearMonth", "1972-08");
+ SAMPLE_VALUES.put("ID", "id-102");
+ SAMPLE_VALUES.put("IDREF", "id-102");
+ SAMPLE_VALUES.put("IDREFS", "id-102 id-103 id-100");
+ SAMPLE_VALUES.put("int", "77");
+ SAMPLE_VALUES.put("integer", "77");
+ SAMPLE_VALUES.put("long", "214");
+ SAMPLE_VALUES.put("negativeInteger", "-123");
+ SAMPLE_VALUES.put("nonNegativeInteger", "2");
+ SAMPLE_VALUES.put("nonPositiveInteger", "0");
+ SAMPLE_VALUES.put("positiveInteger", "500");
+ SAMPLE_VALUES.put("short", "476");
+ SAMPLE_VALUES.put("string", "Joeseph");
+ SAMPLE_VALUES.put("time", "13:02:00");
+ SAMPLE_VALUES.put("base64Binary", "TWFu");
+ SAMPLE_VALUES.put("hexBinary", "2CDB5F");
+ SAMPLE_VALUES.put("QName", "f:foo");
+ SAMPLE_VALUES.put("NOTATION", "f:bar");
+ }
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testMap() throws Exception {
+ SimpleTypeMapperImpl extension = new SimpleTypeMapperImpl();
+ TransformationContext context = EasyMock.createMock(TransformationContext.class);
+ Map<String, Object> metaData = new HashMap<String, Object>();
+ EasyMock.expect(context.getMetadata()).andReturn(metaData).anyTimes();
+ EasyMock.replay(context);
+
+ NamespaceContext namespaceContext = EasyMock.createMock(NamespaceContext.class);
+ EasyMock.expect(namespaceContext.getNamespaceURI(EasyMock.eq("f"))).andReturn("http://foo").anyTimes();
+ EasyMock.expect(namespaceContext.getPrefix(EasyMock.eq("http://foo"))).andReturn("f").anyTimes();
+ EasyMock.replay(namespaceContext);
+ context.getMetadata().put(NamespaceContext.class.getName(), namespaceContext);
+ for (TypeInfo simpleType : SimpleTypeMapperImpl.XSD_SIMPLE_TYPES.values()) {
+ String name = simpleType.getQName().getLocalPart();
+ Object value = SAMPLE_VALUES.get(name);
+ if (value instanceof String[]) {
+ for (String s : (String[])value) {
+ Object obj = extension.toJavaObject(simpleType.getQName(), s, context);
+ String str = extension.toXMLLiteral(simpleType.getQName(), obj, context);
+ assertNotNull(str);
+ // assertTrue("[" + name + "] " + s + " " + str,
+ // str.contains((String) s));
+ }
+ } else if (value instanceof String) {
+ Object obj = extension.toJavaObject(simpleType.getQName(), (String)value, context);
+ String str = extension.toXMLLiteral(simpleType.getQName(), obj, context);
+ assertNotNull(str);
+ // assertTrue("[" + name + "] " + value + " " + str,
+ // str.contains((String) value));
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/TransformerExtensionTestCase.java.fixme b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/TransformerExtensionTestCase.java.fixme
new file mode 100644
index 0000000000..243ac71201
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/TransformerExtensionTestCase.java.fixme
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.extension;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.databinding.Transformer;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+import org.easymock.EasyMock;
+import org.w3c.dom.Node;
+
+/**
+ * Test case for TransformerExtension
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransformerExtensionTestCase extends TestCase {
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testExtension() {
+ MyTransformer transformer = new MyTransformer();
+ assertEquals(Node.class.getName(), transformer.getSourceDataBinding());
+ assertEquals(XMLStreamReader.class.getName(), transformer.getTargetDataBinding());
+ assertEquals(50, transformer.getWeight());
+ TransformerExtensionPoint registry = EasyMock.createMock(TransformerExtensionPoint.class);
+ registry.addTransformer(EasyMock.isA(Transformer.class), EasyMock.eq(true));
+ EasyMock
+ .expect(registry.getTransformer(transformer.getSourceDataBinding(), transformer.getTargetDataBinding()))
+ .andReturn(transformer);
+ EasyMock.replay(registry);
+ registry.addTransformer(transformer, true);
+ assertSame(transformer, registry.getTransformer(transformer.getSourceDataBinding(), transformer
+ .getTargetDataBinding()));
+ }
+
+ private static class MyTransformer extends BaseTransformer<Node, XMLStreamReader> {
+
+ @Override
+ protected Class<Node> getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class<XMLStreamReader> getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/XSDDataTypeConverterTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/XSDDataTypeConverterTestCase.java
new file mode 100644
index 0000000000..a337dc113c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/XSDDataTypeConverterTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.extension;
+
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class XSDDataTypeConverterTestCase {
+
+ @Test
+ public void testConvert() throws Exception {
+ XSDDataTypeConverter c = new XSDDataTypeConverter();
+ assertEquals("123", c.parseAnySimpleType(c.printAnySimpleType("123")));
+ assertEquals(true, c.parseBoolean(c.printBoolean(true)));
+ assertEquals(false, c.parseBoolean(c.printBoolean(false)));
+ assertEquals(123.0, c.parseDouble(c.printDouble(123.0)), 0);
+ assertEquals(123.0f, c.parseFloat(c.printFloat(123.0f)), 0);
+ assertEquals(64, c.parseByte(c.printByte((byte)64)));
+ assertEquals(123, c.parseInt(c.printInt(123)));
+ assertEquals(new BigInteger("123456"), c.parseInteger(c.printInteger(new BigInteger("123456"))));
+ assertEquals(123456L, c.parseLong(c.printLong(123456L)));
+ assertEquals((short)123, c.parseShort(c.printShort((short)123)));
+
+ Calendar calendar = new GregorianCalendar();
+ String s = c.printDate(calendar);
+ calendar = c.parseDate(s);
+ assertEquals(s, c.printDate(calendar));
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DataBindingTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DataBindingTestCase.java
new file mode 100644
index 0000000000..c5d6dbbcc1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DataBindingTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.databinding.annotation.DataBinding;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataBindingTestCase {
+ @org.junit.Test
+ public void testDataType() throws Exception {
+ Class<Test> testClass = Test.class;
+ DataBinding d = testClass.getAnnotation(DataBinding.class);
+ assertEquals(d.value(), "sdo");
+
+ Method method = testClass.getMethod("test", new Class[] {Object.class});
+ DataBinding d2 = method.getAnnotation(DataBinding.class);
+ assertEquals(d2.value(), "jaxb");
+ }
+
+ @DataBinding("sdo")
+ private static interface Test {
+ @DataBinding("jaxb")
+ Object test(Object object);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.java
new file mode 100644
index 0000000000..9ab2b51c95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.tuscany.sca.databinding.impl.DirectedGraph.Edge;
+import org.apache.tuscany.sca.databinding.impl.DirectedGraph.Vertex;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DirectedGraphTestCase {
+ private DirectedGraph<String, Object> graph;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = new DirectedGraph<String, Object>();
+ }
+
+ @Test
+ public void testGraph() {
+ graph.addEdge("a", "b", null, 4, true);
+ graph.addEdge("a", "b", null, 5, true);
+ Assert.assertEquals(4, graph.getEdge("a", "b").getWeight());
+ graph.addEdge("a", "b", null, 3, true);
+ Assert.assertEquals(3, graph.getEdge("a", "b").getWeight());
+ graph.addEdge("b", "c", null, 1, true);
+ // graph.addEdge("a", "c", null, 8, true);
+ graph.addEdge("a", "d", null, 3, true);
+ graph.addEdge("b", "d", null, 2, true);
+ graph.addEdge("d", "c", null, 3, true);
+ graph.addEdge("c", "b", null, 1, true);
+ graph.addEdge("c", "d", null, 2, true);
+ graph.addEdge("d", "b", null, 1, true);
+ graph.addEdge("a", "e", null, 8, true);
+ graph.addEdge("c", "c", null, 2, true);
+ graph.addEdge("f", "g", null, 2, false);
+ graph.addEdge("f", "h", null, 8, true);
+ graph.addEdge("g", "j", null, 2, false);
+ graph.addEdge("j", "i", null, 2, true);
+ graph.addEdge("h", "i", null, 8, true);
+
+ Vertex vertex = graph.getVertex("a");
+ Assert.assertNotNull(vertex);
+ Assert.assertEquals(vertex.getValue(), "a");
+
+ Assert.assertNull(graph.getVertex("1"));
+
+ Edge edge = graph.getEdge("a", "b");
+ Assert.assertNotNull(edge);
+ Assert.assertEquals(edge.getWeight(), 3);
+
+ edge = graph.getEdge("b", "a");
+ Assert.assertNull(edge);
+
+ DirectedGraph<String, Object>.Path path = graph.getShortestPath("a", "c");
+
+ List<DirectedGraph<String, Object>.Edge> edges = path.getEdges();
+ Assert.assertEquals(edges.size(), 2);
+ Assert.assertEquals(edges.get(0), graph.getEdge("a", "b"));
+ Assert.assertEquals(edges.get(1), graph.getEdge("b", "c"));
+
+ Assert.assertEquals(path.getWeight(), 4);
+
+ DirectedGraph<String, Object>.Path path2 = graph.getShortestPath("b", "e");
+ Assert.assertNull(path2);
+
+ DirectedGraph<String, Object>.Path path3 = graph.getShortestPath("a", "a");
+ Assert.assertTrue(path3.getWeight() == 0 && path3.getEdges().isEmpty());
+
+ DirectedGraph<String, Object>.Path path4 = graph.getShortestPath("c", "c");
+ Assert.assertTrue(path4.getWeight() == 2 && path4.getEdges().size() == 1);
+
+ DirectedGraph<String, Object>.Path path5 = graph.getShortestPath("f", "i");
+ Assert.assertTrue(path5.getWeight() == 16 && path5.getEdges().size() == 2);
+
+ }
+
+ @Test
+ public void testSort() {
+ graph.addEdge("a", "b");
+ graph.addEdge("a", "c");
+ graph.addEdge("c", "d");
+ graph.addEdge("b", "c");
+ List<String> order = graph.topologicalSort(true);
+ assertEquals(Arrays.asList("a", "b", "c", "d"), order);
+ assertTrue(!graph.getVertices().isEmpty());
+
+ graph.addEdge("d", "a");
+ try {
+ order = graph.topologicalSort(true);
+ assertTrue("Should have failed", false);
+ } catch (IllegalArgumentException e) {
+ assertTrue(true);
+ }
+
+ graph.removeEdge("d", "a");
+ order = graph.topologicalSort(false);
+ assertEquals(Arrays.asList("a", "b", "c", "d"), order);
+ assertTrue(graph.getVertices().isEmpty());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java
new file mode 100644
index 0000000000..953e539dd1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.impl;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.xml.Node2String;
+import org.apache.tuscany.sca.databinding.xml.Node2Writer;
+import org.apache.tuscany.sca.databinding.xml.SAX2DOMPipe;
+import org.apache.tuscany.sca.databinding.xml.String2SAX;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Test case for MediatorImpl
+ *
+ * @version $Rev$ $Date$
+ */
+public class MediatorImplTestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + "<state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + "<USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private MediatorImpl mediator;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPointRegistry = new DefaultExtensionPointRegistry();
+ DataBindingExtensionPoint dataBindingRegistry = new DefaultDataBindingExtensionPoint(extensionPointRegistry);
+ TransformerExtensionPoint registry = new DefaultTransformerExtensionPoint(extensionPointRegistry);
+
+ registry.addTransformer(new String2SAX(), true);
+ registry.addTransformer(new SAX2DOMPipe(extensionPointRegistry), true);
+ registry.addTransformer(new Node2String(extensionPointRegistry), true);
+ registry.addTransformer(new Node2Writer(extensionPointRegistry), true);
+
+ mediator = new MediatorImpl(dataBindingRegistry, registry);
+ }
+
+ private TransformationContext createTransformationContext(Class sourceType, Class targetType) {
+ TransformationContext context = new TransformationContextImpl();
+ DataType sourceDataType = new DataTypeImpl<Class>(sourceType.getName(), sourceType, sourceType);
+ DataType targetDataType = new DataTypeImpl<Class>(targetType.getName(), targetType, targetType);
+ context.setSourceDataType(sourceDataType);
+ context.setTargetDataType(targetDataType);
+ return context;
+ }
+
+ @Test
+ public void testTransform1() {
+ TransformationContext context = createTransformationContext(String.class, Node.class);
+ Object node =
+ mediator.mediate(IPO_XML, context.getSourceDataType(), context.getTargetDataType(), null);
+ Assert.assertTrue(node instanceof Document);
+ Element root = ((Document)node).getDocumentElement();
+ Assert.assertEquals(root.getNamespaceURI(), "http://www.example.com/IPO");
+ Assert.assertEquals(root.getLocalName(), "purchaseOrder");
+ }
+
+ @Test
+ public void testTransform2() {
+ TransformationContext context = createTransformationContext(String.class, Writer.class);
+ Writer writer = new StringWriter();
+ mediator.mediate(IPO_XML, writer, context.getSourceDataType(), context.getTargetDataType(), null);
+ String str = writer.toString();
+ Assert.assertTrue(str != null && str.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/XMLDocumentStreamReaderTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/XMLDocumentStreamReaderTestCase.java
new file mode 100644
index 0000000000..e240592adf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/XMLDocumentStreamReaderTestCase.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.databinding.impl;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.common.xml.stax.reader.XMLDocumentStreamReader;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.xml.XMLStreamReader2String;
+import org.junit.Assert;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class XMLDocumentStreamReaderTestCase {
+ private static final String xml = "<e1><e2 a2=\"a2\"><e4>E4</e4></e2><e3 a3=\"a3\"/></e1>";
+
+ @org.junit.Test
+ public void testReader() throws Exception {
+ ExtensionPointRegistry extensionPointRegistry = new DefaultExtensionPointRegistry();
+
+ StAXHelper helper = StAXHelper.getInstance(extensionPointRegistry);
+ XMLStreamReader r1 = helper.createXMLStreamReader(new StringReader(xml));
+ XMLDocumentStreamReader r2 = new XMLDocumentStreamReader(r1);
+ XMLStreamReader2String t1 = new XMLStreamReader2String(extensionPointRegistry);
+ String result = t1.transform(r2, null);
+ System.out.println(result);
+ XMLStreamReader r3 = helper.createXMLStreamReader(new StringReader(xml));
+ r3.nextTag();
+ r3.nextTag();
+ Assert.assertEquals(XMLStreamConstants.START_ELEMENT, r3.getEventType());
+ Assert.assertEquals(new QName(null, "e2"), r3.getName());
+ XMLDocumentStreamReader r4 = new XMLDocumentStreamReader(r3);
+ result = t1.transform(r4, null);
+ System.out.println(result);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java
new file mode 100644
index 0000000000..95f21ff4c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.custommonkey.xmlunit.Diff;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanXMLStreamReaderTestCase {
+ private static final String XML_RESULT =
+ "<?xml version='1.0' encoding='UTF-8'?>" + "<MyBean xmlns=\"http://xml.databinding.sca.tuscany.apache.org/\">"
+ + "<arr>1</arr><arr>2</arr><arr>3</arr><bean><name>Name</name></bean><i>1</i>"
+ + "<list>Item1</list><list>Item2</list>"
+ + "<map><entry><key>key1</key><value>value1</value></entry>"
+ + "<entry><key>key2</key><value>value2</value></entry></map>"
+ + "<nil xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />"
+ + "<str>ABC</str></MyBean>";
+
+ // The map entries can come in a different order
+ private static final String XML_RESULT1 =
+ "<?xml version='1.0' encoding='UTF-8'?>" + "<MyBean xmlns=\"http://xml.databinding.sca.tuscany.apache.org/\">"
+ + "<arr>1</arr><arr>2</arr><arr>3</arr><bean><name>Name</name></bean><i>1</i>"
+ + "<list>Item1</list><list>Item2</list>"
+ + "<map><entry><key>key2</key><value>value2</value></entry>"
+ + "<entry><key>key1</key><value>value1</value></entry></map>"
+ + "<nil xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />"
+ + "<str>ABC</str></MyBean>";
+
+
+ @Test
+ public void testTransformation() throws Exception {
+ MyBean bean = new MyBean();
+ bean.str = "ABC";
+ bean.i = 1;
+ bean.arr = new long[] {1, 2, 3};
+ bean.bean = new AnotherBean();
+ bean.bean.setName("Name");
+ bean.list.add("Item1");
+ bean.list.add("Item2");
+ bean.map.put("key1", "value1");
+ bean.map.put("key2", "value2");
+ XMLStreamReader reader = new BeanXMLStreamReaderImpl(null, bean);
+ XMLStreamReader2String t3 = new XMLStreamReader2String(new DefaultExtensionPointRegistry());
+ String xml = t3.transform(reader, null);
+ Diff diff = new Diff(XML_RESULT, xml);
+ Diff diff1 = new Diff(XML_RESULT1, xml);
+ assertTrue(diff.similar() || diff1.similar());
+ }
+
+ private static class MyBean {
+ private long arr[];
+ private String str;
+ private int i;
+ private String nil;
+ private List<String> list = new ArrayList<String>();
+ private AnotherBean bean;
+ private Map<String, String> map = new HashMap<String, String>();
+
+ /**
+ * @return the i
+ */
+ public int getI() {
+ return i;
+ }
+
+ /**
+ * @param i the i to set
+ */
+ public void setI(int i) {
+ this.i = i;
+ }
+
+ /**
+ * @return the arr
+ */
+ public long[] getArr() {
+ return arr;
+ }
+
+ /**
+ * @param arr the arr to set
+ */
+ public void setArr(long[] arr) {
+ this.arr = arr;
+ }
+
+ /**
+ * @return the str
+ */
+ public String getStr() {
+ return str;
+ }
+
+ /**
+ * @param str the str to set
+ */
+ public void setStr(String str) {
+ this.str = str;
+ }
+
+ /**
+ * @return the bean
+ */
+ public AnotherBean getBean() {
+ return bean;
+ }
+
+ /**
+ * @param bean the bean to set
+ */
+ public void setBean(AnotherBean bean) {
+ this.bean = bean;
+ }
+
+ public List<String> getList() {
+ return list;
+ }
+
+ public void setList(List<String> list) {
+ this.list = list;
+ }
+
+ public String getNil() {
+ return nil;
+ }
+
+ public void setNil(String nil) {
+ this.nil = nil;
+ }
+
+ public Map<String, String> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, String> map) {
+ this.map = map;
+ }
+
+ }
+
+ private static class AnotherBean {
+ private String name;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java
new file mode 100644
index 0000000000..27d111374a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.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.sca.databinding.xml;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.common.xml.stax.reader.DOMXmlNodeImpl;
+import org.apache.tuscany.sca.common.xml.stax.reader.XmlTreeStreamReaderImpl;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DOM2StAXTestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private static final String CRAZY_XML =
+ "<p:e1 xmlns=\"http://ns0\" xmlns:p=\"http://p1\">" + "<p:e2 xmlns:p=\"http://p2\"/><e3/><e4 xmlns=\"\">E4</e4></p:e1>";
+
+ private static ExtensionPointRegistry registry;
+
+ @BeforeClass
+ public static void init() {
+ registry = new DefaultExtensionPointRegistry();
+ }
+
+ @Test
+ public void testTransformation() throws Exception {
+ String2Node t1 = new String2Node(registry);
+ Node node = t1.transform(IPO_XML, null);
+ Node2XMLStreamReader t2 = new Node2XMLStreamReader();
+ XMLStreamReader reader = t2.transform(node, null);
+ XMLStreamReader2String t3 = new XMLStreamReader2String(registry);
+ String xml = t3.transform(reader, null);
+ XMLAssert.assertXMLEqual(IPO_XML, xml);
+ // assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
+ }
+
+ @Test
+ public void testTransformation2() throws Exception {
+ String2Node t1 = new String2Node(registry);
+ Node node = t1.transform(CRAZY_XML, null);
+ Node2XMLStreamReader t2 = new Node2XMLStreamReader();
+ XMLStreamReader reader = t2.transform(node, null);
+ XMLStreamReader2String t3 = new XMLStreamReader2String(registry);
+ String xml = t3.transform(reader, null);
+ // System.out.println(xml);
+ XMLAssert.assertXMLEqual(CRAZY_XML, xml);
+ assertTrue(xml.contains("<p:e2 xmlns:p=\"http://p2\""));
+ }
+
+ @Test
+ public void testTransformation3() throws Exception {
+ String2Node t1 = new String2Node(registry);
+ Node node = t1.transform(IPO_XML, null);
+ DOMXmlNodeImpl element = new DOMXmlNodeImpl(node);
+ XmlTreeStreamReaderImpl reader = new XmlTreeStreamReaderImpl(element);
+ XMLStreamReader2String t3 = new XMLStreamReader2String(registry);
+ String xml = t3.transform(reader, null);
+ XMLAssert.assertXMLEqual(IPO_XML, xml);
+ // assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java
new file mode 100644
index 0000000000..da18a4f89c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+import org.apache.tuscany.sca.databinding.impl.PipedTransformer;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Test case for DataPipe
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataPipeTestCase {
+
+ @Test
+ public final void testStreamPipe() throws IOException {
+ byte[] bytes = new byte[] {1, 2, 3};
+ DataPipeTransformer<OutputStream, InputStream> pipe = new StreamDataPipe();
+ DataPipe<OutputStream, InputStream> dataPipe = pipe.newInstance();
+ OutputStream os = dataPipe.getSink();
+ os.write(bytes);
+ byte[] newBytes = new byte[16];
+ int count = dataPipe.getResult().read(newBytes);
+ Assert.assertEquals(3, count);
+ for (int i = 0; i < bytes.length; i++) {
+ Assert.assertEquals(bytes[i], newBytes[i]);
+ }
+ }
+
+ @Test
+ public final void testWriter2ReaderPipe() throws IOException {
+ String str = "ABC";
+ Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe();
+ Assert.assertSame(Writer.class, pipe.getSourceType());
+ Assert.assertSame(Reader.class, pipe.getTargetType());
+ DataPipe<Writer, Reader> dataPipe = pipe.newInstance();
+ dataPipe.getSink().write(str);
+ char[] buf = new char[16];
+ int count = dataPipe.getResult().read(buf);
+ Assert.assertEquals(3, count);
+ for (int i = 0; i < str.length(); i++) {
+ Assert.assertEquals(str.charAt(i), buf[i]);
+ }
+ }
+
+ @Test
+ public final void testPiped() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ Node2Writer node2Writer = new Node2Writer(registry);
+ Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe();
+ PipedTransformer<Node, Writer, Reader> transformer =
+ new PipedTransformer<Node, Writer, Reader>(node2Writer, pipe);
+ Document document = DOMHelper.getInstance(registry).newDocument();
+ Element element = document.createElementNS("http://ns1", "root");
+ document.appendChild(element);
+ Reader reader = transformer.transform(document, null);
+ Assert.assertEquals(transformer.getWeight(), node2Writer.getWeight() + pipe.getWeight());
+ Assert.assertEquals(transformer.getSourceDataBinding(), node2Writer.getSourceDataBinding());
+ Assert.assertEquals(transformer.getTargetDataBinding(), pipe.getTargetDataBinding());
+ char[] buf = new char[120];
+ int count = reader.read(buf);
+ String xml = new String(buf, 0, count);
+ Assert.assertTrue(xml.contains("<root xmlns=\"http://ns1\"/>"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java
new file mode 100644
index 0000000000..8919453731
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReaderTransformer;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaBean2XMLStreamReaderTestCase {
+ private static final String XML_RESULT =
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ + "<MyBean xmlns=\"http://xml.databinding.sca.tuscany.apache.org/\">"
+ + "<arr>1</arr><arr>2</arr><arr>3</arr><bean><name>Name</name></bean><i>1</i><str>ABC</str>"
+ + "</MyBean>";
+
+ @Test
+ public void testTransformation() throws Exception {
+ JavaBean2XMLStreamReaderTransformer t2 = new JavaBean2XMLStreamReaderTransformer();
+ MyBean bean = new MyBean();
+ bean.str = "ABC";
+ bean.i = 1;
+ bean.arr = new long[] {1, 2, 3};
+ bean.bean = new AnotherBean();
+ bean.bean.setName("Name");
+ XMLStreamReader reader = t2.transform(bean, null);
+ XMLStreamReader2String t3 = new XMLStreamReader2String(new DefaultExtensionPointRegistry());
+ String xml = t3.transform(reader, null);
+ XMLAssert.assertXMLEqual(XML_RESULT, xml);
+
+ }
+
+ private static class MyBean {
+ private String str;
+ private int i;
+ private long arr[];
+ private AnotherBean bean;
+
+ /**
+ * @return the arr
+ */
+ public long[] getArr() {
+ return arr;
+ }
+
+ /**
+ * @param arr the arr to set
+ */
+ public void setArr(long[] arr) {
+ this.arr = arr;
+ }
+
+ /**
+ * @return the i
+ */
+ public int getI() {
+ return i;
+ }
+
+ /**
+ * @param i the i to set
+ */
+ public void setI(int i) {
+ this.i = i;
+ }
+
+ /**
+ * @return the str
+ */
+ public String getStr() {
+ return str;
+ }
+
+ /**
+ * @param str the str to set
+ */
+ public void setStr(String str) {
+ this.str = str;
+ }
+
+ /**
+ * @return the bean
+ */
+ public AnotherBean getBean() {
+ return bean;
+ }
+
+ /**
+ * @param bean the bean to set
+ */
+ public void setBean(AnotherBean bean) {
+ this.bean = bean;
+ }
+
+ }
+
+ private static class AnotherBean {
+ private String name;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java
new file mode 100644
index 0000000000..75c43dbf79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.databinding.xml;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Node2StringTestCase {
+
+ @Test
+ public void testTransformation() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ Document document = DOMHelper.getInstance(registry).newDocument();
+ Element element = document.createElementNS("http://ns1", "test");
+ document.appendChild(element);
+
+ new Node2String(registry).transform(document, null);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java
new file mode 100644
index 0000000000..5027f64f01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.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.sca.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.impl.PipedTransformer;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class PushTransformationTestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ @Test
+ public void testTransformation() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ String2XMLStreamReader t1 = new String2XMLStreamReader(registry);
+ XMLStreamReader reader = t1.transform(IPO_XML, null);
+ XMLStreamReader2SAX t2 = new XMLStreamReader2SAX(registry);
+ PipedTransformer<XMLStreamReader, ContentHandler, Node> t3 =
+ new PipedTransformer<XMLStreamReader, ContentHandler, Node>(t2, new SAX2DOMPipe(registry));
+ Node node = t3.transform(reader, null);
+ Assert.assertNotNull(node);
+ Node2String t4 = new Node2String(registry);
+ String xml = t4.transform(node, null);
+ Assert.assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java
new file mode 100644
index 0000000000..6fd8ce2e8b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URL;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Node;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TraxTransformerTestCase {
+ private URL url;
+
+ @Before
+ public void setUp() throws Exception {
+ url = getClass().getResource("foo.xml");
+ }
+
+ @Test
+ public void testTransformDOM() throws IOException {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ InputStream is = url.openStream();
+ InputStream2Node t1 = new InputStream2Node(registry);
+ Node node = t1.transform(is, null);
+ is.close();
+ Writer writer = new StringWriter();
+ Node2Writer t2 = new Node2Writer(registry);
+ t2.transform(node, writer, null);
+ String str = writer.toString();
+ StringReader reader = new StringReader(str);
+ Reader2Node t3 = new Reader2Node(registry);
+ node = t3.transform(reader, null);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ Node2OutputStream t4 = new Node2OutputStream(registry);
+ t4.transform(node, os, null);
+ InputSource inputSource = new InputSource(new ByteArrayInputStream(os.toByteArray()));
+ InputSource2Node t5 = new InputSource2Node(registry);
+ node = t5.transform(inputSource, null);
+ }
+
+ @Test
+ public void testTransformSAX() throws IOException {
+ MyContentHandler handler = new MyContentHandler();
+ InputStream is = url.openStream();
+ InputStream2SAX t1 = new InputStream2SAX();
+ t1.transform(is, handler, null);
+ is.close();
+
+ String xml = "<foo xmlns=\"http://foo\">bar</foo>";
+
+ InputSource inputSource = new InputSource(new StringReader(xml));
+ InputSource2SAX t2 = new InputSource2SAX();
+ MyContentHandler handler2 = new MyContentHandler();
+ t2.transform(inputSource, handler2, null);
+
+ }
+
+ private static class MyContentHandler extends DefaultHandler {
+
+ @Override
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
+ throws SAXException {
+ super.startElement(namespaceURI, localName, qName, atts);
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/ipo.xsd b/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/ipo.xsd
new file mode 100644
index 0000000000..92a576fb98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/order.wsdl b/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/order.wsdl
new file mode 100644
index 0000000000..f011ca9f32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/order.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/order.wsdl" xmlns:tns="http://example.com/order.wsdl"
+ xmlns:xsd1="http://example.com/order.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/order.xsd" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd"/>
+ <element name="checkOrderStatus">
+ <complexType>
+ <sequence>
+ <element name="customerId" type="string" />
+ <element name="order" type="ipo:PurchaseOrderType" />
+ <element name="flag" type="int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="checkOrderStatusResponse">
+ <complexType>
+ <sequence>
+ <element name="status" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="note" type="string" />
+ </schema>
+ </types>
+
+ <message name="CheckOrderStatusInput1">
+ <part name="body" element="xsd1:checkOrderStatus" />
+ </message>
+
+ <message name="CheckOrderStatusOutput1">
+ <part name="body" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <message name="CheckOrderStatusInput2">
+ <part name="p1" element="xsd1:checkOrderStatus" />
+ <part name="p2" element="xsd1:note" />
+ </message>
+
+ <message name="CheckOrderStatusOutput2">
+ <part name="p1" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <portType name="OrderPortType">
+ <operation name="checkOrderStatus">
+ <input message="tns:CheckOrderStatusInput1" />
+ <output message="tns:CheckOrderStatusOutput1" />
+ </operation>
+ <operation name="checkOrderStatus2">
+ <input message="tns:CheckOrderStatusInput2" />
+ <output message="tns:CheckOrderStatusOutput2" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/xml/foo.xml b/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/xml/foo.xml
new file mode 100644
index 0000000000..0ba8ade1e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/xml/foo.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.
+-->
+<f:foo xmlns:f="http://foo" name="foo">
+ <b:bar xmlns:b="http://bar">bar</b:bar>
+</f:foo> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/deployment/LICENSE b/sandbox/sebastien/java/embed/modules/deployment/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/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/sebastien/java/embed/modules/deployment/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/deployment/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..58d085ce87
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/META-INF/MANIFEST.MF
@@ -0,0 +1,51 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.deployment;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.contribution,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.assembly.builder",
+ org.apache.tuscany.sca.deployment.impl;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.definitions,
+ org.apache.tuscany.sca.common.xml.stax,
+ org.apache.tuscany.sca.contribution,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.deployment,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.assembly.builder"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Deployment
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Node Implementation
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xsd;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.java;version="2.0.0",
+ org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0",
+ org.apache.tuscany.sca.deployment;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.deployment
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/deployment/NOTICE b/sandbox/sebastien/java/embed/modules/deployment/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/deployment/pom.xml b/sandbox/sebastien/java/embed/modules/deployment/pom.xml
new file mode 100644
index 0000000000..68205135a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/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>
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-deployment</artifactId>
+ <name>Apache Tuscany SCA Deployment</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-builder</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/DefaultDeployer.java b/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/DefaultDeployer.java
new file mode 100644
index 0000000000..42c7596b15
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/DefaultDeployer.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.deployment;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.deployment.impl.DeployerImpl;
+
+/**
+ * Default implementation of Deployer
+ */
+public class DefaultDeployer extends DeployerImpl {
+
+ public DefaultDeployer() {
+ super(new DefaultExtensionPointRegistry());
+ }
+
+ /**
+ * @param registry
+ */
+ public DefaultDeployer(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java b/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java
new file mode 100644
index 0000000000..dba21e7197
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.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.sca.deployment;
+
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+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.Composite;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A utility that provides system functions to handle Tuscany SCA application deployment
+ */
+public interface Deployer extends LifeCycleListener {
+ /**
+ * Check if Schema Validation for XML Documents is enabled
+ * @return
+ */
+ boolean isSchemaValidationEnabled();
+
+ /**
+ * Sets Schema Validation for XML Documents flag
+ * @param schemaValidationEnabled
+ */
+ void setSchemaValidationEnabled(boolean schemaValidationEnabled);
+
+ /**
+ * Attach a deployment composite to the given contribution
+ * @param contribution The target contribution
+ * @param composite The deployment composite
+ * @param appending A flag to indicate if existing deployable composites in the contribution should be appended or replaced
+ * @return uri of attached composite
+ */
+ String attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending);
+
+ /**
+ * Configure a list of contributions to create a composite representing a view of the domain
+ * @param contributions
+ * @param allContributions
+ * @param bindingBaseURIs
+ * @param monitor
+ * @return
+ * @throws ContributionResolveException
+ * @throws CompositeBuilderException
+ */
+ Composite build(List<Contribution> contributions, List<Contribution> allContributions, Map<QName, List<String>> bindingBaseURIs, Monitor monitor)
+ throws ContributionResolveException, CompositeBuilderException;
+
+ /**
+ * Load an artifact from the given location
+ * @param uri
+ * @param location
+ * @param monitor
+ * @return
+ * @throws ContributionReadException
+ */
+ Artifact loadArtifact(URI uri, URL location, Monitor monitor) throws ContributionReadException;
+
+ /**
+ * Load a contribution from the given location
+ * @param uri
+ * @param location
+ * @param monitor
+ * @return
+ * @throws ContributionReadException
+ */
+ Contribution loadContribution(URI uri, URL location, Monitor monitor) throws ContributionReadException;
+
+ /**
+ * @param <T>
+ * @param uri
+ * @param location
+ * @param monitor
+ * @return
+ * @throws ContributionReadException
+ */
+ <T> T loadDocument(URI uri, URL location, Monitor monitor) throws ContributionReadException;
+
+ /**
+ * @param <T>
+ * @param reader
+ * @param monitor
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ */
+ <T> T loadXMLDocument(Reader reader, Monitor monitor) throws XMLStreamException, ContributionReadException;
+
+ /**
+ * @param <T>
+ * @param location
+ * @param monitor
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ */
+ <T> T loadXMLDocument(URL location, Monitor monitor) throws XMLStreamException, ContributionReadException;
+
+ /**
+ * @param <T>
+ * @param reader
+ * @param monitor
+ * @return
+ * @throws ContributionReadException
+ * @throws XMLStreamException
+ */
+ <T> T loadXMLElement(XMLStreamReader reader, Monitor monitor) throws ContributionReadException, XMLStreamException;
+
+ /**
+ * Save the model as XML
+ * @param model
+ * @param writer
+ * @param monitor
+ * @throws XMLStreamException
+ * @throws ContributionWriteException
+ */
+ void saveXMLDocument(Object model, Writer writer, Monitor monitor) throws XMLStreamException,
+ ContributionWriteException;
+
+ /**
+ * Save the model as XML
+ * @param model
+ * @param writer
+ * @param monitor
+ * @throws XMLStreamException
+ * @throws ContributionWriteException
+ */
+ void saveXMLElement(Object model, XMLStreamWriter writer, Monitor monitor) throws XMLStreamException,
+ ContributionWriteException;
+
+ /**
+ *
+ * @return
+ */
+ Monitor createMonitor();
+
+ /**
+ * Create an instance of {@link BuilderContext}
+ * @return
+ */
+ BuilderContext createBuilderContext();
+
+ /**
+ * Create an instance of {@link ProcessorContext}
+ * @return
+ */
+ ProcessorContext createProcessorContext();
+
+ /**
+ * Get the {@link ExtensionPointRegistry}
+ * @return
+ */
+ ExtensionPointRegistry getExtensionPointRegistry();
+
+ /**
+ * Get the system definitions
+ */
+ Definitions getSystemDefinitions();
+
+ /**
+ * Resolve a contributions dependencies
+ *
+ * @param c
+ * @param allContributions
+ * @param monitor
+ * @throws ContributionResolveException
+ * @throws CompositeBuilderException
+ */
+ void resolve(Contribution c, List<Contribution> dependentContributions, Monitor monitor) throws ContributionResolveException, CompositeBuilderException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java b/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java
new file mode 100644
index 0000000000..8180ac6465
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.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.sca.deployment.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * A Contribution impl wrapping multiple other contributions
+ * Currently the sole reason for this is so
+ */
+public class Contributions implements Contribution {
+
+ private List<Contribution> contributions = new ArrayList<Contribution>();
+ private String location;
+ private String uri;
+ private Object model;
+ private byte[] contents;
+ private boolean unresolved;
+ private ModelResolver modelResolver;
+ private List<Contribution> dependencies = new ArrayList<Contribution>();
+
+ public Contributions(List<Contribution> contributions) {
+ this.contributions = contributions;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public Object getModel() {
+ return model;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public void setModel(Object model) {
+ this.model = model;
+ }
+
+ public byte[] getContents() {
+ return contents;
+ }
+
+ public void setContents(byte[] contents) {
+ this.contents = contents;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public List<Contribution> getContributions() {
+ return contributions;
+ }
+
+ public List<Artifact> getArtifacts() {
+ return (List<Artifact>)(Object)contributions;
+ }
+
+ public List<Contribution> getDependencies() {
+ return dependencies;
+ }
+
+ public ClassLoader getClassLoader() {
+ //FIXME Remove later
+ return null;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ //FIXME Remove later
+ }
+
+ public List<Composite> getDeployables() {
+ List<Composite> deployables = new ArrayList<Composite>();
+ for (Contribution contribution: contributions) {
+ deployables.addAll(contribution.getDeployables());
+ }
+ return deployables;
+ }
+
+ public List<Export> getExports() {
+ List<Export> exports = new ArrayList<Export>();
+ for (Contribution contribution: contributions) {
+ exports.addAll(contribution.getExports());
+ }
+ return exports;
+ }
+
+ public List<Import> getImports() {
+ List<Import> imports = new ArrayList<Import>();
+ for (Contribution contribution: contributions) {
+ imports.addAll(contribution.getImports());
+ }
+ return imports;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+ public List<Extension> getAttributeExtensions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Object> getExtensions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Set<String> getTypes() {
+ return Collections.emptySet();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java b/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
new file mode 100644
index 0000000000..cf94c5a8b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
@@ -0,0 +1,721 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.deployment.impl;
+
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.xsd.Constants;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.DefaultImport;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ExtendedURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultImportModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.definitions.DefinitionsFactory;
+import org.apache.tuscany.sca.definitions.util.DefinitionsUtil;
+import org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+
+/**
+ *
+ */
+public class DeployerImpl implements Deployer {
+ protected static final Logger logger = Logger.getLogger(DeployerImpl.class.getName());
+
+ protected boolean inited;
+ protected boolean schemaValidationEnabled;
+ protected StAXHelper staxHelper;
+ protected AssemblyFactory assemblyFactory;
+ protected CompositeBuilder compositeBuilder;
+ protected ContributionFactory contributionFactory;
+ protected ExtendedURLArtifactProcessor<Contribution> contributionProcessor;
+ protected ExtensionPointRegistry registry;
+ protected FactoryExtensionPoint modelFactories;
+ protected ModelResolverExtensionPoint modelResolvers;
+ protected Contribution systemContribution;
+ protected Definitions systemDefinitions;
+ protected ExtensibleURLArtifactProcessor artifactProcessor;
+ protected ExtensibleStAXArtifactProcessor staxProcessor;
+ protected ValidationSchemaExtensionPoint validationSchema;
+
+ protected MonitorFactory monitorFactory;
+
+ protected static final String DEPLOYER_IMPL_VALIDATION_MESSAGES =
+ "org.apache.tuscany.sca.deployment.impl.deployer-impl-validation-messages";
+
+ public static final QName XSD = new QName("http://www.w3.org/2001/XMLSchema", "schema");
+
+ /**
+ * @param registry
+ */
+ public DeployerImpl(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public Monitor createMonitor() {
+ init();
+ return monitorFactory.createMonitor();
+ }
+
+ public synchronized void stop() {
+ if (inited) {
+ staxHelper = null;
+ assemblyFactory = null;
+ compositeBuilder = null;
+ contributionFactory = null;
+ contributionProcessor = null;
+ modelFactories = null;
+ modelResolvers = null;
+ systemContribution = null;
+ systemDefinitions = null;
+ artifactProcessor = null;
+ staxProcessor = null;
+ monitorFactory = null;
+ inited = false;
+ }
+ }
+
+ /**
+ * Analyze a contribution and add its dependencies to the given dependency set.
+ */
+ protected void addContributionDependencies(Contribution contribution,
+ List<Contribution> contributions,
+ List<Contribution> dependencies,
+ Set<Contribution> set,
+ Monitor monitor) {
+
+ // Go through the contribution imports
+ for (Import import_ : contribution.getImports()) {
+ boolean resolved = false;
+
+ // Go through all contribution candidates and their exports
+ List<Export> matchingExports = new ArrayList<Export>();
+ for (Contribution dependency : contributions) {
+ if (dependency == contribution) {
+ // Do not self import
+ continue;
+ }
+
+ // When a contribution contains a reference to an artifact from a namespace that
+ // is declared in an import statement of the contribution, if the SCA artifact
+ // resolution mechanism is used to resolve the artifact, the SCA runtime MUST resolve
+ // artifacts from the locations identified by the import statement(s) for the namespace.
+ if (import_ instanceof NamespaceImport) {
+ NamespaceImport namespaceImport = (NamespaceImport)import_;
+ if (namespaceImport.getLocation() != null)
+ if (!namespaceImport.getLocation().equals(dependency.getURI()))
+ continue;
+ }
+ if (import_ instanceof JavaImport) {
+ JavaImport javaImport = (JavaImport)import_;
+ if (javaImport.getLocation() != null)
+ if (!javaImport.getLocation().equals(dependency.getURI()))
+ continue;
+ }
+
+ for (Export export : dependency.getExports()) {
+
+ // If an export from a contribution matches the import in hand
+ // add that contribution to the dependency set
+ if (import_.match(export)) {
+ resolved = true;
+ matchingExports.add(export);
+
+ if (!set.contains(dependency)) {
+ set.add(dependency);
+ dependencies.add(dependency);
+
+ // Now add the dependencies of that contribution
+ addContributionDependencies(dependency, contributions, dependencies, set, monitor);
+ } // end if
+ } // end if
+ } // end for
+ } // end for
+
+ if (resolved) {
+ // Initialize the import's model resolver with a delegating model
+ // resolver which will delegate to the matching exports
+ import_.setModelResolver(new DefaultImportModelResolver(matchingExports));
+
+ } else {
+ // Record import resolution issue
+ if (!(import_ instanceof DefaultImport)) {
+ // Add the (empty) matchingExports List and report a warning
+ import_.setModelResolver(new DefaultImportModelResolver(matchingExports));
+
+ // push context here as the "stack" in this case is a list of nexted contributions
+ // through which imports have been chased which may not make much sense to the
+ // user so just report the contribution in error
+ monitor.pushContext("Contribution: " + contribution.getLocation());
+ Monitor.error(monitor, this, DEPLOYER_IMPL_VALIDATION_MESSAGES, "UnresolvedImport", import_);
+ monitor.popContext();
+ }
+ } // end if
+ }
+ }
+
+ protected void buildDependencies(Contribution contribution, List<Contribution> contributions, Monitor monitor) {
+ contribution.getDependencies().clear();
+
+ List<Contribution> dependencies = new ArrayList<Contribution>();
+ Set<Contribution> set = new HashSet<Contribution>();
+
+ dependencies.add(contribution);
+ set.add(contribution);
+ addContributionDependencies(contribution, contributions, dependencies, set, monitor);
+
+ Collections.reverse(dependencies);
+
+ contribution.getDependencies().addAll(dependencies);
+ }
+
+ /**
+ * Pre-resolve phase for contributions, to set up handling of imports and exports prior to full resolution
+ * @param contributions - the contributions to preresolve
+ * @param resolver - the ModelResolver to use
+ * @throws ContributionResolveException
+ */
+ protected void contributionsPreresolve(List<Contribution> contributions,
+ ModelResolver resolver,
+ ProcessorContext context) throws ContributionResolveException {
+
+ for (Contribution contribution : contributions) {
+ contributionProcessor.preResolve(contribution, resolver, context);
+ } // end for
+ } // end method contributionsPreresolve
+
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ return registry;
+ }
+
+ public void start() {
+ // Defer to the init() method
+ }
+
+ public synchronized void init() {
+ if (inited) {
+ return;
+ }
+
+ // Enable schema validation only of the logger level is FINE or higher
+ if (isSchemaValidationEnabled()) {
+ ValidationSchemaExtensionPoint schemas = registry.getExtensionPoint(ValidationSchemaExtensionPoint.class);
+ if (schemas != null) {
+ schemas.setEnabled(true);
+ }
+ }
+
+ // Use the runtime-enabled assembly factory
+ modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+
+ // Create a monitor
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ staxHelper = utilities.getUtility(StAXHelper.class);
+
+ monitorFactory = utilities.getUtility(MonitorFactory.class);
+
+ // Initialize the Tuscany module activators
+ // The module activators will be started
+ registry.getExtensionPoint(ModuleActivatorExtensionPoint.class);
+
+ // Get contribution workspace and assembly model factories
+ contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+
+ // Create XML artifact processors
+ staxProcessor = new ExtensibleStAXArtifactProcessor(registry);
+
+ // Create contribution content processor
+ URLArtifactProcessorExtensionPoint docProcessorExtensions =
+ registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ artifactProcessor = new ExtensibleURLArtifactProcessor(docProcessorExtensions);
+
+ contributionProcessor =
+ (ExtendedURLArtifactProcessor<Contribution>)docProcessorExtensions.getProcessor(Contribution.class);
+
+ // Get the model resolvers
+ modelResolvers = registry.getExtensionPoint(ModelResolverExtensionPoint.class);
+
+ // Get composite builders
+ BuilderExtensionPoint compositeBuilders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ compositeBuilder =
+ compositeBuilders.getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ // get the validation schema
+ validationSchema = registry.getExtensionPoint(ValidationSchemaExtensionPoint.class);
+
+ loadSystemContribution(new ProcessorContext(monitorFactory.createMonitor()));
+
+ inited = true;
+
+ }
+
+ protected void loadSystemContribution(ProcessorContext context) {
+ DefinitionsFactory definitionsFactory = modelFactories.getFactory(DefinitionsFactory.class);
+ systemDefinitions = definitionsFactory.createDefinitions();
+
+ DefinitionsExtensionPoint definitionsExtensionPoint =
+ registry.getExtensionPoint(DefinitionsExtensionPoint.class);
+
+ Monitor monitor = context.getMonitor();
+ monitor.pushContext("Extension points definitions");
+ try {
+ for (Definitions defs : definitionsExtensionPoint.getDefinitions()) {
+ DefinitionsUtil.aggregate(defs, systemDefinitions, monitor);
+ }
+ } finally {
+ monitor.popContext();
+ }
+
+ // create a system contribution to hold the definitions. The contribution
+ // will be extended later with definitions from application contributions
+ systemContribution = contributionFactory.createContribution();
+ systemContribution.setURI("http://tuscany.apache.org/SystemContribution");
+ systemContribution.setLocation("http://tuscany.apache.org/SystemContribution");
+ ModelResolver modelResolver = new ExtensibleModelResolver(systemContribution, modelResolvers, modelFactories);
+ systemContribution.setModelResolver(modelResolver);
+ systemContribution.setUnresolved(true);
+
+ // create an artifact to represent the system defintions and
+ // add it to the contribution
+ List<Artifact> artifacts = systemContribution.getArtifacts();
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI("http://tuscany.apache.org/SystemContribution/Definitions");
+ artifact.setLocation("Derived");
+ artifact.setModel(systemDefinitions);
+ artifacts.add(artifact);
+
+ // now resolve and add the system contribution
+ try {
+ contributionProcessor.resolve(systemContribution, modelResolver, context);
+ } catch (ContributionResolveException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ protected Contribution cloneSystemContribution(Monitor monitor) {
+ init();
+ Contribution contribution = contributionFactory.createContribution();
+ contribution.setURI(systemContribution.getURI());
+ contribution.setLocation(systemContribution.getLocation());
+
+ ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
+ contribution.setModelResolver(modelResolver);
+ contribution.setUnresolved(true);
+
+ DefinitionsFactory definitionsFactory = modelFactories.getFactory(DefinitionsFactory.class);
+ Definitions definitions = definitionsFactory.createDefinitions();
+ DefinitionsUtil.aggregate(systemDefinitions, definitions, monitor);
+
+ // create an artifact to represent the system defintions and
+ // add it to the contribution
+ List<Artifact> artifacts = contribution.getArtifacts();
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI("http://tuscany.apache.org/SystemContribution/Definitions");
+ artifact.setLocation("Derived");
+ artifact.setModel(definitions);
+ artifacts.add(artifact);
+
+ // create resolver entries to represent the SCA schema. We don't create artifacts
+ // in the contribution as the XSD schema are only actually loaded on demand
+ // so as long as they are in the model resolver we are set. We do it on the clone
+ // so that every copy of the system contribution has the schema
+ ProcessorContext context = new ProcessorContext(monitor);
+ XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ List<String> scaSchemas = validationSchema.getSchemas();
+ for (String scaSchemaLocation : scaSchemas){
+ try {
+ URL scaSchemaURL = new URL(scaSchemaLocation);
+ String namespace = staxHelper.readAttribute(scaSchemaURL, XSD, "targetNamespace");
+
+ // if this is the SCA schema store it in the system contribution
+ if (namespace.equals(Constants.SCA11_TUSCANY_NS)){
+
+ // add the schema to the model resolver under the Tuscany namespace
+ XSDefinition scaSchema = xsdFactory.createXSDefinition();
+ scaSchema.setUnresolved(true);
+ scaSchema.setNamespace(namespace);
+ scaSchema.setLocation(IOHelper.toURI(scaSchemaURL));
+ scaSchema.setUnresolved(false);
+// modelResolver.addModel(scaSchema, context);
+ } else if (namespace.equals(Constants.SCA11_NS)) {
+ // we know that the SCA schema's are referenced form the Tuscany schemas so
+ // register the schema under the SCA namespace too
+ XSDefinition scaSchema = xsdFactory.createXSDefinition();
+ scaSchema.setUnresolved(true);
+ scaSchema.setNamespace(Constants.SCA11_NS);
+ scaSchema.setLocation(IOHelper.toURI(scaSchemaURL));
+ scaSchema.setUnresolved(false);
+ modelResolver.addModel(scaSchema, context);
+ }
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ return contribution;
+ }
+
+ public String attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending) {
+ init();
+
+ String compositeArtifactURI = composite.getName().getLocalPart() + ".composite";
+
+ if (appending) {
+ // check its not already there
+ for (Artifact a : contribution.getArtifacts()) {
+ if (compositeArtifactURI.equals(a.getURI())) {
+ throw new IllegalStateException("artifact '" + compositeArtifactURI + "' already exists in contribution: " + contribution.getURI());
+ }
+ }
+ }
+
+ // Create an artifact for the deployment composite
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(compositeArtifactURI);
+
+ artifact.setLocation(compositeArtifactURI);
+ artifact.setModel(composite);
+ artifact.setUnresolved(false);
+ // Add it to the contribution
+ contribution.getArtifacts().add(artifact);
+
+ // Replace the deployable composites with the deployment composites
+ // Clear the deployable composites if it's the first deployment composite
+ if (!appending) {
+ contribution.getDeployables().clear();
+ }
+ contribution.getDeployables().add(composite);
+ return compositeArtifactURI;
+ }
+
+ public Composite build(List<Contribution> contributions, List<Contribution> allContributions, Map<QName, List<String>> bindingMap, Monitor monitor)
+ throws ContributionResolveException, CompositeBuilderException {
+ init();
+ List<Contribution> contributionList = new ArrayList<Contribution>(contributions);
+
+ Contribution systemContribution = cloneSystemContribution(monitor);
+ Definitions systemDefinitions = systemContribution.getArtifacts().get(0).getModel();
+ // Build an aggregated SCA definitions model. Must be done before we try and
+ // resolve any contributions or composites as they may depend on the full
+ // definitions.xml picture
+
+ // get all definitions.xml artifacts from contributions and aggregate
+ // into the system contribution. In turn add a default import into
+ // each contribution so that, for unresolved items, the resolution
+ // processing will look in the system contribution
+ ProcessorContext context = new ProcessorContext(monitor);
+ for (Contribution contribution : contributionList) {
+ monitor.pushContext("Contribution: " + contribution.getURI());
+ try {
+ // aggregate definitions
+ for (Artifact artifact : contribution.getArtifacts()) {
+ if (!"META-INF/definitions.xml".equals(artifact.getURI())) {
+ continue;
+ }
+ Object model = artifact.getModel();
+ // FIXME: Should we check the artifact URI is META-INF/definitions.xml?
+ if (model instanceof Definitions) {
+ try {
+ monitor.pushContext("Definitions: " + artifact.getLocation());
+ DefinitionsUtil.aggregate((Definitions)model, systemDefinitions, monitor);
+ } finally {
+ monitor.popContext();
+ }
+ }
+ }
+
+ // create a default import and wire it up to the system contribution
+ // model resolver. This is the trick that makes the resolution processing
+ // skip over to the system contribution if resolution is unsuccessful
+ // in the current contribution
+ DefaultImport defaultImport = contributionFactory.createDefaultImport();
+ defaultImport.setModelResolver(systemContribution.getModelResolver());
+ contribution.getImports().add(defaultImport);
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ ExtensibleModelResolver modelResolver =
+ new ExtensibleModelResolver(new Contributions(contributionList), modelResolvers, modelFactories);
+
+ // now resolve and add the system contribution
+ contributionProcessor.resolve(systemContribution, modelResolver, context);
+ contributionList.add(systemContribution);
+
+ // pre-resolve the contributions
+ contributionsPreresolve(contributionList, modelResolver, context);
+
+ // Build the contribution dependencies
+ Set<Contribution> resolved = new HashSet<Contribution>();
+
+ for (Contribution contribution : contributionList) {
+ buildDependencies(contribution, allContributions, monitor);
+
+ // Resolve contributions
+ for (Contribution dependency : contribution.getDependencies()) {
+ if (!resolved.contains(dependency)) {
+ resolved.add(dependency);
+ contributionProcessor.resolve(dependency, modelResolver, context);
+ }
+ }
+ }
+
+ // Create a top level composite to host our composite
+ // This is temporary to make the activator happy
+ Composite domainComposite = assemblyFactory.createComposite();
+ domainComposite.setName(Composite.DOMAIN_COMPOSITE);
+ domainComposite.setURI(Base.SCA11_NS);
+
+ for (Contribution contribution : contributionList) {
+ for (Composite composite : contribution.getDeployables()) {
+ // Include the node composite in the top-level composite
+ domainComposite.getIncludes().add(composite);
+ }
+ }
+
+ // build the top level composite
+ BuilderContext builderContext = new BuilderContext(systemDefinitions, bindingMap, monitor);
+ compositeBuilder.build(domainComposite, builderContext);
+ // analyzeProblems(monitor);
+
+ return domainComposite;
+ }
+
+ public void resolve(Contribution c, List<Contribution> dependentContributions, Monitor monitor) throws ContributionResolveException, CompositeBuilderException {
+ init();
+ List<Contribution> contributionList = new ArrayList<Contribution>();
+ contributionList.add(c);
+
+ Contribution systemContribution = cloneSystemContribution(monitor);
+ Definitions systemDefinitions = systemContribution.getArtifacts().get(0).getModel();
+ // Build an aggregated SCA definitions model. Must be done before we try and
+ // resolve any contributions or composites as they may depend on the full
+ // definitions.xml picture
+
+ // get all definitions.xml artifacts from contributions and aggregate
+ // into the system contribution. In turn add a default import into
+ // each contribution so that, for unresolved items, the resolution
+ // processing will look in the system contribution
+ ProcessorContext context = new ProcessorContext(monitor);
+ for (Contribution contribution : contributionList) {
+ monitor.pushContext("Contribution: " + contribution.getURI());
+ try {
+ // aggregate definitions
+ for (Artifact artifact : contribution.getArtifacts()) {
+ if (!"META-INF/definitions.xml".equals(artifact.getURI())) {
+ continue;
+ }
+ Object model = artifact.getModel();
+ if (model instanceof Definitions) {
+ try {
+ monitor.pushContext("Definitions: " + artifact.getLocation());
+ DefinitionsUtil.aggregate((Definitions)model, systemDefinitions, monitor);
+ } finally {
+ monitor.popContext();
+ }
+ }
+ }
+
+ // create a default import and wire it up to the system contribution
+ // model resolver. This is the trick that makes the resolution processing
+ // skip over to the system contribution if resolution is unsuccessful
+ // in the current contribution
+ DefaultImport defaultImport = contributionFactory.createDefaultImport();
+ defaultImport.setModelResolver(systemContribution.getModelResolver());
+ contribution.getImports().add(defaultImport);
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ ExtensibleModelResolver modelResolver =
+ new ExtensibleModelResolver(new Contributions(contributionList), modelResolvers, modelFactories);
+
+ // now resolve and add the system contribution
+ contributionProcessor.resolve(systemContribution, modelResolver, context);
+ contributionList.add(systemContribution);
+
+ // pre-resolve the contributions
+ contributionsPreresolve(contributionList, modelResolver, context);
+
+ // Build the contribution dependencies
+ Set<Contribution> resolved = new HashSet<Contribution>();
+
+ for (Contribution contribution : contributionList) {
+ buildDependencies(contribution, dependentContributions, monitor);
+
+ // Resolve contributions
+ for (Contribution dependency : contribution.getDependencies()) {
+ if (!resolved.contains(dependency)) {
+ resolved.add(dependency);
+ contributionProcessor.resolve(dependency, modelResolver, context);
+ }
+ }
+ }
+ }
+
+ public Artifact loadArtifact(URI uri, URL location, Monitor monitor) throws ContributionReadException {
+ init();
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setLocation(location.toString());
+ artifact.setURI(uri.toString());
+ URLArtifactProcessorExtensionPoint artifactProcessors =
+ registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ ExtensibleURLArtifactProcessor processor = new ExtensibleURLArtifactProcessor(artifactProcessors);
+ Object model = processor.read(null, uri, location, new ProcessorContext(monitor));
+ artifact.setModel(model);
+ return artifact;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T loadDocument(URI uri, URL location, Monitor monitor) throws ContributionReadException {
+ init();
+ Object model = artifactProcessor.read(null, uri, location, new ProcessorContext(monitor));
+ return (T)model;
+ }
+
+ public Object loadXMLDocument(URL document, Monitor monitor) throws XMLStreamException, ContributionReadException {
+ init();
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(document);
+ reader.nextTag();
+ ValidatingXMLInputFactory.setMonitor(reader, monitor);
+ try {
+ return loadXMLElement(reader, monitor);
+ } finally {
+ reader.close();
+ }
+ }
+
+ public void saveXMLDocument(Object model, Writer writer, Monitor monitor) throws XMLStreamException,
+ ContributionWriteException {
+ init();
+ XMLStreamWriter streamWriter = staxHelper.createXMLStreamWriter(writer);
+ staxProcessor.write(model, streamWriter, new ProcessorContext(monitor));
+ }
+
+ public void saveXMLElement(Object model, XMLStreamWriter writer, Monitor monitor) throws XMLStreamException,
+ ContributionWriteException {
+ init();
+ staxProcessor.write(model, writer, new ProcessorContext(monitor));
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object loadXMLElement(XMLStreamReader reader, Monitor monitor) throws ContributionReadException,
+ XMLStreamException {
+ init();
+ return staxProcessor.read(reader, new ProcessorContext(monitor));
+ }
+
+ public Object loadXMLDocument(Reader document, Monitor monitor) throws XMLStreamException, ContributionReadException {
+ init();
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(document);
+ ValidatingXMLInputFactory.setMonitor(reader, monitor);
+ reader.nextTag();
+ try {
+ return loadXMLElement(reader, monitor);
+ } finally {
+ reader.close();
+ }
+ }
+
+ public Contribution loadContribution(URI uri, URL location, Monitor monitor) throws ContributionReadException {
+ init();
+ ProcessorContext context = new ProcessorContext(monitor);
+ // Load the contribution
+ Contribution contribution = contributionProcessor.read(null, uri, location, context);
+ return contribution;
+ }
+
+ public ProcessorContext createProcessorContext() {
+ init();
+ return new ProcessorContext(monitorFactory.createMonitor());
+ }
+
+ public BuilderContext createBuilderContext() {
+ init();
+ return new BuilderContext(monitorFactory.createMonitor());
+ }
+
+ public boolean isSchemaValidationEnabled() {
+ return schemaValidationEnabled;
+ }
+
+ public void setSchemaValidationEnabled(boolean schemaValidationEnabled) {
+ this.schemaValidationEnabled = schemaValidationEnabled;
+ }
+
+ public Definitions getSystemDefinitions() {
+ init();
+ return systemDefinitions;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer b/sandbox/sebastien/java/embed/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer
new file mode 100644
index 0000000000..46e6eba7f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer
@@ -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.deployment.DefaultDeployer
+
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties b/sandbox/sebastien/java/embed/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties
new file mode 100644
index 0000000000..0c07a3a30f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties
@@ -0,0 +1,22 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+UnresolvedImport = Unresolved import: Import = {0}
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/test/java/hello/deployer/HelloWorld.java b/sandbox/sebastien/java/embed/modules/deployment/src/test/java/hello/deployer/HelloWorld.java
new file mode 100644
index 0000000000..2480a5e4d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/test/java/hello/deployer/HelloWorld.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 hello.deployer;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * HelloWorld interface
+ */
+@Remotable
+public interface HelloWorld {
+ String hello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java b/sandbox/sebastien/java/embed/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java
new file mode 100644
index 0000000000..fc81dc2167
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.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 hello.deployer;
+
+/**
+ * HelloWorldImpl
+ */
+public class HelloWorldImpl implements HelloWorld {
+ public String hello(String name) {
+ System.out.println("Hello: " + name);
+ return "Hello, " + name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java b/sandbox/sebastien/java/embed/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java
new file mode 100644
index 0000000000..e5c0a499a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.deployment.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Arrays;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class DeployerImplTestCase {
+ private static ExtensionPointRegistry registry;
+ private static Deployer deployer;
+
+ private static URL contributionURL;
+ private static URL compositeURL;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ compositeURL = DeployerImplTestCase.class.getResource("HelloWorld.composite");
+ contributionURL = new URL(compositeURL, "../");
+ registry = new DefaultExtensionPointRegistry();
+ deployer = new DeployerImpl(registry);
+ deployer.start();
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ deployer.stop();
+ }
+
+ /**
+ * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#build(java.util.List, java.util.Map, org.apache.tuscany.sca.monitor.Monitor)}.
+ */
+ @Test
+ public void testBuild() throws Exception {
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(contributionURL.toURI(), contributionURL, monitor);
+ Composite composite = deployer.build(Arrays.asList(contribution), Arrays.asList(contribution), null, monitor);
+ assertTrue(composite != null);
+ }
+
+ /**
+ * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#loadArtifact(java.net.URI, java.net.URL, org.apache.tuscany.sca.monitor.Monitor)}.
+ */
+ @Test
+ public void testLoadArtifact() throws Exception {
+ Monitor monitor = deployer.createMonitor();
+ Artifact artifact = deployer.loadArtifact(compositeURL.toURI(), compositeURL, monitor);
+ assertTrue(artifact.getModel() instanceof Composite);
+ Composite composite = artifact.getModel();
+ assertEquals(composite.getName(), new QName("http://sample/composite", "HelloWorld1"));
+ }
+
+ /**
+ * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#loadDocument(java.net.URI, java.net.URL, org.apache.tuscany.sca.monitor.Monitor)}.
+ */
+ @Test
+ public void testLoadDocument() throws Exception {
+ Monitor monitor = deployer.createMonitor();
+ Composite composite = deployer.loadDocument(compositeURL.toURI(), compositeURL, monitor);
+ assertEquals(composite.getName(), new QName("http://sample/composite", "HelloWorld1"));
+ }
+
+ /**
+ * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#loadXMLDocument(java.net.URL, org.apache.tuscany.sca.monitor.Monitor)}.
+ */
+ @Test
+ public void testLoadXMLDocumentURLMonitor() throws Exception {
+ Monitor monitor = deployer.createMonitor();
+ Composite composite = deployer.loadXMLDocument(compositeURL, monitor);
+ assertEquals(composite.getName(), new QName("http://sample/composite", "HelloWorld1"));
+ Writer sw = new StringWriter();
+ deployer.saveXMLDocument(composite, sw, monitor);
+ assertTrue(sw.toString() != null);
+ }
+
+ /**
+ * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#loadContribution(java.net.URI, java.net.URL, org.apache.tuscany.sca.monitor.Monitor)}.
+ * @throws URISyntaxException
+ * @throws ContributionReadException
+ */
+ @Test
+ public void testLoadContribution() throws Exception {
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(contributionURL.toURI(), contributionURL, monitor);
+ Composite composite = contribution.getDeployables().get(0);
+ assertEquals(composite.getName(), new QName("http://sample/composite", "HelloWorld1"));
+ assertTrue(contribution.getArtifacts().size() >= 2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/test/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/modules/deployment/src/test/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..5dc99a46a7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/test/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sc="http://sample/composite">
+ <deployable composite="sc:HelloWorld1" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite b/sandbox/sebastien/java/embed/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite
new file mode 100644
index 0000000000..23555ea491
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample/composite"
+ name="HelloWorld1">
+
+ <component name="HelloWorld1">
+ <implementation.java class="hello.deployer.HelloWorldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/LICENSE b/sandbox/sebastien/java/embed/modules/domain-node/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/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/sebastien/java/embed/modules/domain-node/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/domain-node/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..80ccd80dc2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Export-Package: org.apache.tuscany.sca.node2;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.contribution,org.apache.tuscany.sca.core,org.apache.tuscany.sca.deployment,org.apache.tuscany.sca.monitor,org.apache.tuscany.sca.runtime,org.apache.tuscany.sca.work,javax.xml.namespace,javax.xml.stream,org.oasisopen.sca"
+Bundle-Name: Apache Tuscany SCA Domain Node
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Domain Node
+Import-Package:
+ org.apache.tuscany.sca.management;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node2;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.domain.node
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/NOTICE b/sandbox/sebastien/java/embed/modules/domain-node/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/pom.xml b/sandbox/sebastien/java/embed/modules/domain-node/pom.xml
new file mode 100644
index 0000000000..b4980b2105
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/pom.xml
@@ -0,0 +1,75 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-domain-node</artifactId>
+ <name>Apache Tuscany SCA Domain Node</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
new file mode 100644
index 0000000000..8a30cf2f71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.domain.node;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+public class DomainNode {
+
+ private static final String DEFAULT_DOMAIN_SCHEME = "vm";
+ private static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
+ private static final String DEFAULT_CONFIG_URI = DEFAULT_DOMAIN_SCHEME + "://" + DEFAULT_DOMAIN_NAME;
+
+ private String domainName;
+ private String domainRegistryURI;
+
+ private Map<String, Node> nodes = new HashMap<String, Node>();
+
+ public DomainNode() {
+ this(DEFAULT_CONFIG_URI, new String[]{});
+ }
+
+ public DomainNode(String... contributionLocations) {
+ this(DEFAULT_CONFIG_URI, contributionLocations);
+ }
+
+ public DomainNode(String configURI, String[] contributionLocations) {
+ this.domainRegistryURI = configURI;
+ initDomainName(configURI);
+ if (contributionLocations == null || contributionLocations.length == 0) {
+ addContribution(null, "_null");
+ } else {
+ for (String loc : contributionLocations) {
+ addContribution(loc);
+ }
+ }
+ }
+
+ public void stop() {
+ for (Node node : nodes.values()) {
+ node.stop();
+ }
+ }
+
+ public String addContribution(String location) {
+ String uri = location;
+ addContribution(uri, location);
+ return uri;
+ }
+
+ public void addContribution(String location, String uri) {
+ if (nodes.containsKey(uri)) {
+ throw new IllegalArgumentException("contribution already added: " + uri);
+ }
+ NodeConfiguration configuration = NodeFactory.getInstance().createNodeConfiguration();
+ if (location != null) {
+ configuration.addContribution(uri, location);
+ }
+ configuration.setDomainRegistryURI(domainRegistryURI);
+ configuration.setDomainURI(domainName);
+ configuration.setURI(uri); //???
+ Node node = NodeFactory.getInstance().createNode(configuration).start();
+ nodes.put(uri, node);
+ }
+
+ public void removeContribution(String uri) {
+ if (!nodes.containsKey(uri)) {
+ throw new IllegalArgumentException("contribution not found: " + uri);
+ }
+ Node node = nodes.remove(uri);
+ node.stop();
+ }
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public String getDomainConfigURI() {
+ return domainRegistryURI;
+ }
+
+ public List<String> getServiceNames() {
+ List<String> serviceNames = new ArrayList<String>();
+ if (nodes.size() > 0) {
+ ExtensionPointRegistry extensionsRegistry = ((NodeImpl)nodes.values().iterator().next()).getExtensionPointRegistry();
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
+ EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry(getDomainConfigURI(), getDomainName());
+ for (Endpoint endpoint : endpointRegistry.getEndpoints()) {
+ // Would be nice if Endpoint.getURI() returned this:
+ String name = endpoint.getComponent().getName() + "/" + endpoint.getService().getName();
+ if (endpoint.getBinding() != null) {
+ // TODO: shouldn't the binding name be null if its not explicitly specified?
+ // For now don't include it if the same as the default
+ if (!endpoint.getService().getName().equals(endpoint.getBinding().getName())) {
+ name += "/" + endpoint.getBinding().getName();
+ }
+ }
+ serviceNames.add(name);
+ }
+ }
+ return serviceNames;
+ }
+
+ public <T> T getService(Class<T> interfaze, String uri) throws NoSuchServiceException {
+ try {
+ return SCAClientFactory.newInstance(URI.create(getDomainName())).getService(interfaze, uri);
+ } catch (NoSuchDomainException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ protected void initDomainName(String configURI) {
+// URI uri = URI.create(fixScheme(configURI));
+// String dn = uri.getHost();
+// if (dn == null || dn.length() < 1) {
+// dn = DEFAULT_DOMAIN_NAME;
+// }
+ if (configURI.startsWith("tuscany:vm:")) {
+ domainName = configURI.substring("tuscany:vm:".length());
+ } else if (configURI.startsWith("tuscany:")) {
+ int i = configURI.indexOf('?');
+ if (i == -1) {
+ domainName = configURI.substring("tuscany:".length());
+ } else{
+ domainName = configURI.substring("tuscany:".length(), i);
+ }
+ } else {
+ domainName = configURI;
+ }
+ }
+
+ /**
+ * I keep typing the scheme part with just a colon instead of colon slash slash
+ * which URI doesn't parse properly which irritates me so fix it up here
+ */
+ protected String fixScheme(String uri) {
+ int i = uri.indexOf(":");
+ if (i > -1 && uri.charAt(i+1) != '/') {
+ uri = uri.replaceFirst(":", ":/");
+ }
+ if (i > -1 && uri.charAt(i+2) != '/') {
+ uri = uri.replaceFirst(":/", "://");
+ }
+ return uri;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java
new file mode 100644
index 0000000000..0d9f4172f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.domain.node;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class DomainNodeMain {
+
+ /**
+ * Start an SCA domain node
+ * @param args a list of contribution jars for the node to run
+ */
+ public static void main(String[] args) throws Exception {
+
+ String configURI = "uri:default";
+
+ List<String> contributions = new ArrayList<String>();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("vm:") || args[i].startsWith("tribes:") || args[i].startsWith("tuscany:") || args[i].startsWith("uri:") || args[i].startsWith("properties:")) {
+ configURI = args[i];
+ } else{
+ File f = new File(args[i]);
+ if (!f.exists()) {
+ System.err.println("contribution not found: " + f);
+ System.exit(1);
+ }
+ contributions.add(f.toURI().toString());
+ }
+ }
+
+ Node node = NodeFactory.newInstance(configURI).createNode((String)null, contributions.toArray(new String[contributions.size()]));
+ node.start();
+
+ System.out.println("Hit enter to stop node...");
+ if (System.in.read() == -1) {
+ // no sysin so wait for ever letting caller do the terminate
+ Object lock = new Object();
+ synchronized (lock) {
+ lock.wait();
+ }
+ }
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java
new file mode 100644
index 0000000000..5f4e4d3017
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node2;
+
+import java.io.Reader;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public interface Node {
+
+ /**
+ * Creates an installed contribution from a supplied root contribution and installed at a supplied base URI.
+ * See section 10.5.1 of the Assembly Specification.
+ *
+ * @param uri the base uri of where to install the contribution
+ * @param contributionURL the URL where the contribution is located
+ * @param metaDataURL the location of an optional generated Contribution Metadata Document. See section 10.2.2
+ * of the Assembly Specification. May be null.
+ * @param dependentContributionURIs specifies the contributions that are used to resolve the dependencies of the
+ * root contribution and other dependent contributions. May be null.
+ * @param runDeployables true if the composites defined as deployable in the contributions sca-contribution.xml
+ * file or supplied metaData file should be run, false if they should not be.
+ * @return the URI of the installed contribution
+ *
+ * @throws ContributionReadException
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ String installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException;
+
+ /**
+ * Creates an installed contribution from a supplied Contribution object.
+ * See section 10.5.1 of the Assembly Specification.
+ *
+ * @param contribution the Contribution object
+ * @param dependentContributionURIs specifies the contributions that are used to resolve the dependencies of the
+ * root contribution and other dependent contributions. May be null.
+ * @param runDeployables true if the composites defined as deployable in the contributions sca-contribution.xml
+ * file or supplied metaData file should be run, false if they should not be.
+ * @return the URI of the installed contribution
+ *
+ * @throws ContributionReadException
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ String installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException;
+
+ /**
+ * Creates an installed contribution from a supplied root contribution.
+ * See section 10.5.1 of the Assembly Specification.
+ *
+ * @param contributionURL the URL where the contribution is located
+ * @return the URI of the installed contribution
+ *
+ * @throws ContributionReadException
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException;
+
+ /**
+ * 4577 10.5.1 install Contribution & update Contribution
+ * 4578 Creates or updates an installed contribution with a supplied root contribution, and installed at a supplied
+ * 4579 base URI. A supplied dependent contribution list (<export/> elements) specifies the contributions that are
+ * 4580 used to resolve the dependencies of the root contribution and other dependent contributions. These
+ * 4581 override any dependent contributions explicitly listed via the @location attribute in the import statements
+ * 4582 of the contribution.
+ * 4583 SCA follows the simplifying assumption that the use of a contribution for resolving anything also means
+ * 4584 that all other exported artifacts can be used from that contribution. Because of this, the dependent
+ * 4585 contribution list is just a list of installed contribution URIs. There is no need to specify what is being used
+ * 4586 from each one.
+ * 4587 Each dependent contribution is also an installed contribution, with its own dependent contributions. By
+ * 4588 default these dependent contributions of the dependent contributions (which we will call indirect
+ * 4589 dependent contributions) are included as dependent contributions of the installed contribution. However,
+ * 4590 if a contribution in the dependent contribution list exports any conflicting definitions with an indirect
+ * 4591 dependent contribution, then the indirect dependent contribution is not included (i.e. the explicit list
+ * 4592 overrides the default inclusion of indirect dependent contributions). Also, if there is ever a conflict
+ * 4593 between two indirect dependent contributions, then the conflict MUST be resolved by an explicit entry in
+ * 4594 the dependent contribution list.
+ * 4595 [ASM12009]
+ * 4596 Note that in many cases, the dependent contribution list can be generated. In particular, if the creator of
+ * 4597 a Domain is careful to avoid creating duplicate definitions for the same qualified name, then it is easy for
+ * 4598 this list to be generated by tooling.
+ *
+ * @param uri
+ * @param contributionURL
+ */
+ void updateContribution(String uri, String contributionURL);
+ void updateContribution(Contribution contribution);
+
+ /**
+ * 4599 10.5.2 add Deployment Composite & update Deployment Composite
+ * 4600 Adds or updates a deployment composite using a supplied composite ("composite by value" - a data
+ * 4601 structure, not an existing resource in the Domain) to the contribution identified by a supplied contribution
+ * 4602 URI. The added or updated deployment composite is given a relative URI that matches the @name
+ * 4603 attribute of the composite, with a ".composite" suffix. Since all composites run within the context of a
+ * 4604 installed contribution (any component implementations or other definitions are resolved within that
+ * 4605 contribution), this functionality makes it possible for the deployer to create a composite with final
+ * 4606 configuration and wiring decisions and add it to an installed contribution without having to modify the
+ * 4607 contents of the root contribution.
+ * 4608 Also, in some use cases, a contribution might include only implementation code (e.g. PHP scripts). It is
+ * 4609 then possible for those to be given component names by a (possibly generated) composite that is added
+ * 4610 into the installed contribution, without having to modify the packaging. *
+ *
+ * @param uri
+ * @param compositeXML
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException;
+ String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException, ValidationException;
+
+ /**
+ * 4599 10.5.2 add Deployment Composite & update Deployment Composite
+ * 4600 Adds or updates a deployment composite using a supplied composite ("composite by value" - a data
+ * 4601 structure, not an existing resource in the Domain) to the contribution identified by a supplied contribution
+ * 4602 URI. The added or updated deployment composite is given a relative URI that matches the @name
+ * 4603 attribute of the composite, with a ".composite" suffix. Since all composites run within the context of a
+ * 4604 installed contribution (any component implementations or other definitions are resolved within that
+ * 4605 contribution), this functionality makes it possible for the deployer to create a composite with final
+ * 4606 configuration and wiring decisions and add it to an installed contribution without having to modify the
+ * 4607 contents of the root contribution.
+ * 4608 Also, in some use cases, a contribution might include only implementation code (e.g. PHP scripts). It is
+ * 4609 then possible for those to be given component names by a (possibly generated) composite that is added
+ * 4610 into the installed contribution, without having to modify the packaging. *
+ *
+ * @param uri
+ * @param compositeXML
+ * @return
+ */
+ String updateDeploymentComposite(String uri, Reader compositeXML);
+ String updateDeploymentComposite(String uri, Composite composite);
+
+ /**
+ * 4611 11.4.310.5.3 remove Contribution
+ * 4612 Removes the deployed contribution identified by a supplied contribution URI.
+ *
+ * @param contributionURI
+ * @return List of contribution URIs (includes dependent contributions) which were removed
+ * @throws ActivationException
+ */
+ List<String> removeContribution(String contributionURI) throws ActivationException;
+
+ /**
+ * 4677 10.7.1 add To Domain-Level Composite
+ * 4678 This functionality adds the composite identified by a supplied URI to the Domain Level Composite. The
+ * 4679 supplied composite URI refers to a composite within an installed contribution. The composite's installed
+ * 4680 contribution determines how the composite's artifacts are resolved (directly and indirectly). The supplied
+ * 4681 composite is added to the domain composite with semantics that correspond to the domain-level
+ * 4683 components become top-level components and the component services become externally visible
+ * 4684 services (eg. they would be present in a WSDL description of the Domain). The meaning of any promoted
+ * 4685 services and references in the supplied composite is not defined; since there is no composite scope
+ * 4686 outside the domain composite, the usual idea of promotion has no utility.
+ *
+ * @param cotributionURI
+ * @param compositeURI
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ void addToDomainLevelComposite(String contributionURI, String compositeURI) throws ActivationException, ValidationException;
+
+ /**
+ * 4687 10.7.2 remove From Domain-Level Composite
+ * 4688 Removes from the Domain Level composite the elements corresponding to the composite identified by a
+ * 4689 supplied composite URI. This means that the removal of the components, wires, services and references
+ * 4690 originally added to the domain level composite by the identified composite. *
+ * @param contributionURI
+ * @param compositeURI
+ * @throws ActivationException
+ */
+ void removeFromDomainLevelComposite(String contributionURI, String compositeURI) throws ActivationException;
+
+ /**
+ * 10.7.3 get Domain-Level Composite
+ * Returns a <composite> definition that has an <include> line for each composite that had been added to
+ * the domain level composite. It is important to note that, in dereferencing the included composites, any
+ * referenced artifacts are resolved in terms of that installed composite.
+ *
+ * @return
+ */
+ Composite getDomainLevelComposite();
+
+ /* that previous one returns a Composte object but not sure what would be most appropriate, and having one return a string seems convenient: */
+ String getDomainLevelCompositeAsString();
+
+ /**
+ * 4695 10.7.4 get QName Definition
+ * 4696 In order to make sense of the domain-level composite (as returned by get Domain-Level Composite), it
+ * 4697 needs to be possible to get the definitions for named artifacts in the included composites. This
+ * 4698 functionality takes the supplied URI of an installed contribution (which provides the context), a supplied
+ * 4699 qualified name of a definition to look up, and a supplied symbol space (as a QName, e.g.
+ * 4700 wsdl:PortTypeportType). The result is a single definition, in whatever form is appropriate for that
+ * 4701 definition type.
+ * 4702 Note that this, like all the other domain-level operations, is a conceptual operation. Its capabilities need to
+ * 4703 exist in some form, but not necessarily as a service operation with exactly this signature.
+ * @param contributionURI
+ * @param definition
+ * @param symbolSpace
+ * @return
+ */
+ Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace);
+
+ /**
+ * Probably want to be able to stop it all at once so a method called stop or shutdown or destroy
+ */
+ void stop();
+
+ /**
+ * Would also be convenient to get service proxys as from SCAClientFactory
+ */
+ <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException;
+
+ /**
+ * Get a contributions deployed composites.
+ * @param contributionURI the contribution URI
+ * @return the List of deployed composites
+ */
+ List<String> getDeployedCompostes(String contributionURI);
+
+ /**
+ * Get the URIs of all the contributions installed on this Node
+ * @return the list of installed contribution URIs
+ */
+ List<String> getInstalledContributions();
+
+ /**
+ * Get an installed Contribution
+ * @param uri the URI of the contribution
+ * @return the Contribution
+ */
+ Contribution getInstalledContribution(String uri);
+
+ String getDomainName();
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java
new file mode 100644
index 0000000000..153a5341cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node2;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.core.assembly.impl.EndpointRegistryImpl;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.node2.impl.NodeImpl;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+public class NodeFactory {
+
+ private Deployer deployer;
+ private ExtensionPointRegistry extensionPointRegistry;
+ private CompositeActivator compositeActivator;
+ private ExtensibleDomainRegistryFactory domainRegistryFactory;
+ private RuntimeAssemblyFactory assemblyFactory;
+
+ public static NodeFactory newInstance() {
+ return new NodeFactory(null);
+ }
+ public static NodeFactory newInstance(Properties config) {
+ return new NodeFactory(config);
+ }
+
+ /**
+ * A helper method to simplify creating a standalone Node
+ * @param compositeURI URI within the contribution of a composite to run
+ * if compositeURI is null then all deployable composites in the contribution will be run
+ * @param contributionURL URL of the contribution
+ * @param dependentContributionURLs optional URLs of dependent contributions
+ * @return a Node with installed contributions
+ */
+ public static Node newStandaloneNode(String compositeURI, String contributionURL, String... dependentContributionURLs) {
+ try {
+ NodeFactory nodeFactory = newInstance();
+ EndpointRegistry endpointRegistry = new EndpointRegistryImpl(nodeFactory.extensionPointRegistry, null, null);
+ NodeImpl node = new NodeImpl("default", nodeFactory.deployer, nodeFactory.compositeActivator, endpointRegistry, nodeFactory.extensionPointRegistry, nodeFactory);
+
+ if (dependentContributionURLs != null) {
+ for (int i=dependentContributionURLs.length-1; i>-1; i--) {
+ node.installContribution(null, dependentContributionURLs[i], null, null, false);
+ }
+ }
+
+ String curi = node.installContribution(null, contributionURL, null, null, compositeURI == null);
+ if (compositeURI != null) {
+ node.addToDomainLevelComposite(curi, compositeURI);
+ }
+ return node;
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected NodeFactory(Properties config) {
+ init(config);
+ }
+
+ public Node createNode(String domainURI) {
+ String domainName = getDomainName(domainURI);
+ EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry(domainURI, domainName);
+ return new NodeImpl(domainName, deployer, compositeActivator, endpointRegistry, extensionPointRegistry, null);
+ }
+
+ public void stop() {
+ deployer.stop();
+ extensionPointRegistry.stop();
+ }
+
+ protected void init(Properties config) {
+ if (config == null) {
+ config = new Properties();
+ config.setProperty("defaultScheme", "vm");
+ config.setProperty("defaultDomainName", "default");
+ }
+ this.extensionPointRegistry = new DefaultExtensionPointRegistry();
+ extensionPointRegistry.start();
+
+ FactoryExtensionPoint modelFactories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = new RuntimeAssemblyFactory(extensionPointRegistry);
+ modelFactories.addFactory(assemblyFactory);
+
+ UtilityExtensionPoint utilities = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.compositeActivator = utilities.getUtility(CompositeActivator.class);
+ this.deployer = utilities.getUtility(Deployer.class);
+ utilities.getUtility(RuntimeProperties.class).setProperties(config);
+ utilities.getUtility(WorkScheduler.class);
+
+ // Initialize the Tuscany module activators
+ // The module activators will be started
+ extensionPointRegistry.getExtensionPoint(ModuleActivatorExtensionPoint.class);
+
+ this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
+
+ }
+ /**
+ * Get the Deployer. The Deployer can be used to create contribution artifacts
+ * when configuring a Node programatically.
+ * @return the Deployer
+ */
+ public Deployer getDeployer() {
+ return deployer;
+ }
+
+ /**
+ * Get the AssemblyFactory. The AssemblyFactory can be used to create contribution
+ * artifact contents when configuring a Node programatically.
+ * @return the AssemblyFactory
+ */
+ public AssemblyFactory getAssemblyFactory() {
+ return assemblyFactory;
+ }
+
+ private String getDomainName(String domainURI) {
+ int scheme = domainURI.indexOf(':');
+ int qm = domainURI.indexOf('?');
+ if (qm == -1) {
+ return domainURI.substring(scheme+1);
+ } else {
+ return domainURI.substring(scheme+1, qm);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java
new file mode 100644
index 0000000000..98c90d5bbc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node2.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+public class DeployedComposite {
+
+ private String uri;
+ private Composite composite;
+ private InstalledContribution installedContribution;
+ private List<Contribution> dependedOnContributions;
+ private Composite domainComposite; // TODO: this is misleadingly named
+
+ private CompositeActivator compositeActivator;
+ private CompositeContext compositeContext;
+ private Deployer deployer;
+ private EndpointRegistry endpointRegistry;
+ private ExtensionPointRegistry extensionPointRegistry;
+
+ public DeployedComposite(Composite composite,
+ InstalledContribution ic,
+ List<Contribution> dependedOnContributions,
+ Deployer deployer,
+ CompositeActivator compositeActivator,
+ EndpointRegistry endpointRegistry,
+ ExtensionPointRegistry extensionPointRegistry) throws ValidationException, ActivationException {
+ this.composite = composite;
+ this.installedContribution = ic;
+ this.dependedOnContributions = dependedOnContributions;
+ this.deployer = deployer;
+ this.compositeActivator = compositeActivator;
+ this.endpointRegistry = endpointRegistry;
+ this.extensionPointRegistry = extensionPointRegistry;
+ try {
+ init();
+ } catch (ContributionResolveException e) {
+ throw new ActivationException(e);
+ } catch (CompositeBuilderException e) {
+ throw new ActivationException(e);
+ }
+ }
+
+ protected void init() throws ValidationException, ActivationException, ContributionResolveException, CompositeBuilderException {
+
+ List<Contribution> contribution = new ArrayList<Contribution>();
+ contribution.add(installedContribution.getContribution());
+ contribution.get(0).getDeployables().clear();
+ contribution.get(0).getDeployables().add(composite);
+
+ Monitor monitor = deployer.createMonitor();
+// TODO: is the ContextMonitor neccessary here?
+// Monitor tcm = monitorFactory.setContextMonitor(monitor);
+// try {
+
+ domainComposite = deployer.build(contribution, dependedOnContributions, new HashMap<QName, List<String>>(), monitor);
+ monitor.analyzeProblems();
+
+// } finally {
+// monitorFactory.setContextMonitor(tcm);
+// }
+
+ compositeContext = new CompositeContext(extensionPointRegistry,
+ endpointRegistry,
+ domainComposite,
+ null, // nothing appears to use the domain name in CompositeContext
+ null, // don't need node uri
+ deployer.getSystemDefinitions());
+
+ CompositeContext.setThreadCompositeContext(compositeContext); // TODO: what is this doing?
+
+ compositeActivator.activate(compositeContext, domainComposite);
+ compositeActivator.start(compositeContext, domainComposite);
+
+ this.uri = getCompositeURI(composite, installedContribution);
+ }
+
+ public void unDeploy() throws ActivationException {
+ compositeActivator.stop(compositeContext, domainComposite);
+ compositeActivator.deactivate(domainComposite);
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Deployable composites don't have the uri set so get it from the artifact in the contribution
+ * // TODO: fix the Tuscany code so this uri is correctly set and this method isn't needed
+ */
+ protected String getCompositeURI(Composite c, InstalledContribution ic) {
+ for (Artifact a : ic.getContribution().getArtifacts()) {
+ if (a.getModel() != null) {
+ if (a.getModel() instanceof Composite) {
+ Composite cm = a.getModel();
+ if (c.getName().equals(cm.getName())) {
+ return cm.getURI();
+ }
+ }
+ }
+ }
+ // shouldn't ever happen
+ throw new IllegalStateException("can't determine composte uri");
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/InstalledContribution.java b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/InstalledContribution.java
new file mode 100644
index 0000000000..d306e52121
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/InstalledContribution.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.sca.node2.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+
+public class InstalledContribution {
+
+ private String uri;
+ private String url;
+ private Contribution contribution;
+ private List<Composite> defaultDeployables = new ArrayList<Composite>();
+ private List<DeployedComposite> deployedComposites = new ArrayList<DeployedComposite>();
+ private List<String> dependentContributionURIs;
+
+ public InstalledContribution(String uri, String url, Contribution contribution, List<String> dependentContributionURIs) {
+ this.uri = uri;
+ this.url = url;
+ this.contribution = contribution;
+ this.defaultDeployables = contribution.getDeployables();
+ this.dependentContributionURIs = dependentContributionURIs;
+ }
+ public Contribution getContribution() {
+ return contribution;
+ }
+ public void setContribution(Contribution contribution) {
+ this.contribution = contribution;
+ }
+ public String getURI() {
+ return uri;
+ }
+ public String getURL() {
+ return url;
+ }
+ public List<Composite> getDefaultDeployables() {
+ return defaultDeployables;
+ }
+ public List<DeployedComposite> getDeployedComposites() {
+ return deployedComposites;
+ }
+ public List<String> getDependentContributionURIs() {
+ return dependentContributionURIs;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java
new file mode 100644
index 0000000000..19159e96b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java
@@ -0,0 +1,358 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node2.impl;
+
+import java.io.File;
+import java.io.Reader;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.node2.Node;
+import org.apache.tuscany.sca.node2.NodeFactory;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+public class NodeImpl implements Node {
+
+ private String domainName;
+ private Deployer deployer;
+ private Map<String, InstalledContribution> installedContributions = new HashMap<String, InstalledContribution>();
+ private CompositeActivator compositeActivator;
+ private EndpointRegistry endpointRegistry;
+ private ExtensionPointRegistry extensionPointRegistry;
+ private NodeFactory nodeFactory;
+
+ public NodeImpl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry, NodeFactory nodeFactory) {
+ this.domainName = domainName;
+ this.deployer = deployer;
+ this.compositeActivator = compositeActivator;
+ this.endpointRegistry = endpointRegistry;
+ this.extensionPointRegistry = extensionPointRegistry;
+ this.nodeFactory = nodeFactory;
+ }
+
+ public String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException {
+ return installContribution(null, contributionURL, null, null, true);
+ }
+
+ public String installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException {
+ if (uri == null) {
+ uri = getDefaultContributionURI(contributionURL);
+ }
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(IOHelper.createURI(uri), IOHelper.getLocationAsURL(contributionURL), monitor);
+ monitor.analyzeProblems();
+ if (metaDataURL != null) {
+ mergeContributionMetaData(metaDataURL, contribution);
+ }
+ installContribution(contribution, dependentContributionURIs, runDeployables);
+ return uri;
+ }
+
+ private void mergeContributionMetaData(String metaDataURL, Contribution contribution) throws ValidationException {
+ ContributionMetadata metaData;
+ Monitor monitor = deployer.createMonitor();
+ try {
+ metaData = deployer.loadXMLDocument(IOHelper.getLocationAsURL(metaDataURL), monitor);
+ } catch (Exception e) {
+ throw new ValidationException(e);
+ }
+ monitor.analyzeProblems();
+ contribution.getDeployables().addAll(metaData.getDeployables());
+ contribution.getImports().addAll(metaData.getImports());
+ contribution.getExports().addAll(metaData.getExports());
+ }
+
+ public String installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean runDeployables) throws ContributionReadException, ActivationException, ValidationException {
+ InstalledContribution ic = new InstalledContribution(contribution.getURI(), contribution.getLocation(), contribution, dependentContributionURIs);
+ installedContributions.put(contribution.getURI(), ic);
+ if (runDeployables) {
+ for (Composite c : ic.getDefaultDeployables()) {
+ runComposite(c, ic);
+ }
+ } else {
+ contribution.getDeployables().clear();
+
+ List<Contribution> dependentContributions = calculateDependentContributions(ic);
+
+ Monitor monitor = deployer.createMonitor();
+ try {
+ deployer.resolve(contribution, dependentContributions, monitor);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ monitor.analyzeProblems();
+ }
+ return ic.getURI();
+ }
+
+ protected List<Contribution> calculateDependentContributions(InstalledContribution ic) {
+ List<Contribution> dependentContributions = new ArrayList<Contribution>();
+ if (ic.getDependentContributionURIs() != null) {
+ // if the install specified dependent uris use just those contributions
+ for (String uri : ic.getDependentContributionURIs()) {
+ InstalledContribution dependee = installedContributions.get(uri);
+ if (dependee != null) {
+ dependentContributions.add(dependee.getContribution());
+ }
+ }
+ } else {
+ // otherwise use all available contributions for dependents
+ for (InstalledContribution ics : installedContributions.values()) {
+ dependentContributions.add(ics.getContribution());
+ }
+ }
+ return dependentContributions;
+ }
+
+ public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException {
+ Monitor monitor = deployer.createMonitor();
+ Composite composite = deployer.loadXMLDocument(compositeXML, monitor);
+ monitor.analyzeProblems();
+ return addDeploymentComposite(contributionURI, composite);
+ }
+
+ public String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException, ValidationException {
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("contribution not installed: " + contributionURI);
+ }
+ String compositeArtifcatURI = deployer.attachDeploymentComposite(ic.getContribution(), composite, true);
+ runComposite(composite, ic);
+ return compositeArtifcatURI;
+ }
+
+ @Override
+ public void addToDomainLevelComposite(String contributionURI, String compositeURI) throws ActivationException, ValidationException {
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ }
+ for (Artifact a : ic.getContribution().getArtifacts()) {
+ if (a.getURI().equals(compositeURI)) {
+ runComposite((Composite) a.getModel(), ic);
+ return;
+ }
+ }
+ throw new IllegalArgumentException("composite not found: " + compositeURI);
+ }
+
+ @Override
+ public void removeFromDomainLevelComposite(String contributionURI, String compositeURI) throws ActivationException {
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ }
+ for (DeployedComposite dc : ic.getDeployedComposites()) {
+ if (compositeURI.equals(dc.getURI())) {
+ ic.getDeployedComposites().remove(dc);
+ dc.unDeploy();
+ return;
+ }
+ }
+ throw new IllegalStateException("composite not deployed: " + compositeURI);
+ }
+
+ public Composite getDomainLevelComposite() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getDomainLevelCompositeAsString() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> removeContribution(String contributionURI) throws ActivationException {
+ List<String> removedContributionURIs = new ArrayList<String>();
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic != null) {
+ removedContributionURIs.add(ic.getURI());
+ for (String dependent : getDependentContributions(contributionURI)) {
+ removedContributionURIs.addAll(removeContribution(dependent));
+ }
+ installedContributions.remove(contributionURI);
+ for (DeployedComposite dc : ic.getDeployedComposites()) {
+ dc.unDeploy();
+ }
+ ic.getDeployedComposites().clear();
+ }
+ return removedContributionURIs;
+ }
+
+ public void updateContribution(String uri, String contributionURL) {
+ // TODO Auto-generated method stub
+ // is this just removeContribution/installContribution?
+ }
+ public void updateContribution(Contribution contribution) {
+ // TODO Auto-generated method stub
+ }
+
+ public String updateDeploymentComposite(String uri, Reader compositeXML) {
+ // TODO Auto-generated method stub
+ // is this removeFromDomainLevelComposite/addDeploymentComposite
+ return null;
+ }
+ public String updateDeploymentComposite(String uri, Composite composite) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void stop() {
+ ArrayList<String> ics = new ArrayList<String>(installedContributions.keySet());
+ for (String uri : ics) {
+ try {
+ removeContribution(uri);
+ } catch (Exception e) {
+ // TODO: log
+ e.printStackTrace();
+ }
+ }
+ if (nodeFactory != null) {
+ nodeFactory.stop();
+ }
+ }
+
+ public <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException {
+ try {
+ return SCAClientFactory.newInstance(URI.create(getDomainName())).getService(interfaze, serviceURI);
+ } catch (NoSuchDomainException e) {
+ // shouldn't ever happen as we know this is the domain so it must exist
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public List<String> getDeployedCompostes(String contributionURI) {
+ ArrayList<String> compositeURIs = new ArrayList<String>();
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("no contribution found for: " + contributionURI);
+ }
+ for (DeployedComposite dc : ic.getDeployedComposites()) {
+ compositeURIs.add(dc.getURI());
+ }
+ return compositeURIs;
+ }
+
+ public List<String> getInstalledContributions() {
+ return new ArrayList<String>(installedContributions.keySet());
+ }
+
+ public Contribution getInstalledContribution(String uri) {
+ if (installedContributions.containsKey(uri)) {
+ return installedContributions.get(uri).getContribution();
+ }
+ throw new IllegalArgumentException("no contribution found for: " + uri);
+ }
+
+ protected String getContributionUriForArtifact(String artifactURI) {
+ String contributionURI = null;
+ for (String uri : installedContributions.keySet()) {
+ if (artifactURI.startsWith(uri)) {
+ contributionURI = uri;
+ break;
+ }
+ }
+ if (contributionURI == null) {
+ throw new IllegalArgumentException("no contribution found for: " + artifactURI);
+ }
+ return contributionURI;
+ }
+
+ protected void runComposite(Composite c, InstalledContribution ic) throws ActivationException, ValidationException {
+ List<Contribution> dependentContributions = calculateDependentContributions(ic);
+
+ DeployedComposite dc = new DeployedComposite(c, ic, dependentContributions, deployer, compositeActivator, endpointRegistry, extensionPointRegistry);
+ ic.getDeployedComposites().add(dc);
+ }
+
+ public Set<String> getDependentContributions(String contributionURI) {
+ InstalledContribution ic = installedContributions.get(contributionURI);
+ if (ic == null) {
+ throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ }
+ Set<String> dependentContributionURIs = new HashSet<String>();
+ for (InstalledContribution icx : installedContributions.values()) {
+ if (ic != icx) {
+ List<Contribution> dependencies = icx.getContribution().getDependencies();
+ if (dependencies != null && dependencies.contains(ic.getContribution())) {
+ dependentContributionURIs.addAll(getDependentContributions(icx.getURI()));
+ }
+ }
+ }
+ return dependentContributionURIs;
+ }
+
+ /**
+ * Returns a default URI for a contribution based on the contribution URL
+ */
+ protected String getDefaultContributionURI(String contributionURL) {
+ String uri = null;
+ try {
+ File f = new File(contributionURL);
+ if ("classes".equals(f.getName()) && "target".equals(f.getParentFile().getName())) {
+ uri = f.getParentFile().getParentFile().getName();
+ } else {
+ uri = f.getName();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ if (uri == null) {
+ uri = contributionURL;
+ }
+ if (uri.endsWith(".zip") || uri.endsWith(".jar")) {
+ uri = uri.substring(0, uri.length()-4);
+ }
+ return uri;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/itest/nodes/Helloworld.java b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
new file mode 100644
index 0000000000..76f8d4400d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 itest.nodes;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
new file mode 100644
index 0000000000..0a5d99ae7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+@Ignore("TUSCANY-3391")
+public class GetServiceTestCase{
+
+ private static DomainNode clientNode;
+ private static DomainNode serviceNode;
+
+ @Test
+ public void testTwoNodesSameDomain() throws Exception {
+ serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testTwoNodesDifferentDomains() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ clientNode = new DomainNode("vm://barDomain", new String[] {"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (ServiceRuntimeException e) {
+ // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException?
+ // expected
+ }
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
new file mode 100644
index 0000000000..617876586b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+@Ignore("TUSCANY-3391")
+public class MultipleNodesPerJVMTestCase{
+
+ private static DomainNode clientNode;
+ private static DomainNode serviceNode;
+
+ @Test
+ public void testTwoNodesSameDomain() throws Exception {
+ serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testTwoNodesDifferentDomains() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ clientNode = new DomainNode("vm://barDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://barDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (ServiceRuntimeException e) {
+ // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException?
+ // expected
+ }
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
new file mode 100644
index 0000000000..10803cd880
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+@Ignore("TUSCANY-3391")
+public class OneNodeTestCase{
+
+ private static DomainNode domain;
+ private static String serviceContributionUri;
+
+ @Before
+ public void setUpBeforeClass() throws Exception {
+ domain = new DomainNode();
+ serviceContributionUri = domain.addContribution("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ domain.addContribution("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ }
+
+ @Test
+ public void testService() throws Exception {
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testRemovingServiceContribution() throws Exception {
+ domain.removeContribution(serviceContributionUri);
+ try {
+ SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService");
+ // FIXME: should this be NoSuchServiceException or ServiceNotFoundException?
+ } catch (NoSuchServiceException e) {
+ // expected
+ }
+
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (Exception e) {
+ // FIXME: this gives an NPE, would be better to be something like ServiceNotFoundException
+ // expected
+ }
+ }
+
+ @Test
+ public void testStoppingDomainNode() throws Exception {
+ domain.stop();
+ try {
+ SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient");
+ fail();
+ } catch (NoSuchDomainException e) {
+ // expected
+ }
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (domain != null) {
+ domain.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
new file mode 100644
index 0000000000..4a29822069
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.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.sca.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import java.net.URI;
+
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+@Ignore("TUSCANY-3391")
+public class StopStartNodesTestCase{
+
+ private static DomainNode clientNode;
+ private static DomainNode serviceNode;
+
+ @Test
+ public void testTwoNodesSameDomain() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ clientNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
+
+ Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ serviceNode.stop();
+
+ client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (Exception e) {
+ // expected
+ }
+
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java
new file mode 100644
index 0000000000..450e5a8b3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.node2;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class DeployerTestCase {
+
+ @Test
+ public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ Node node = nodeFactory.createNode("myDomain");
+
+ Deployer deployer = nodeFactory.getDeployer();
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor);
+ monitor.analyzeProblems();
+
+ node.installContribution(contribution, null, true);
+ List<String> ics = node.getInstalledContributions();
+ Assert.assertEquals(1, ics.size());
+ Assert.assertEquals("foo", ics.get(0));
+ }
+
+ @Test
+ public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ Node node = nodeFactory.createNode("myDomain");
+
+ node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+
+ Deployer deployer = nodeFactory.getDeployer();
+ Monitor monitor = deployer.createMonitor();
+ Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor);
+ monitor.analyzeProblems();
+ composite.setURI("helloworld2.composite");
+ node.addDeploymentComposite("foo", composite);
+ List<String> dcs = node.getDeployedCompostes("foo");
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld2.composite", dcs.get(0));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java
new file mode 100644
index 0000000000..0792a25454
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.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.sca.node2;
+
+import java.net.MalformedURLException;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.node2.impl.NodeImpl;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class NodeTestCase {
+
+ @Test
+ public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = NodeFactory.newInstance().createNode("default");
+ node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
+
+// Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ @Ignore("Depdends on itest/T3558 which isn't in the build?")
+ public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException, ActivationException, ValidationException {
+ Node node = NodeFactory.newInstance().createNode("default");
+ node.installContribution("store", "../../itest/T3558/src/test/resources/sample-store.jar", null, null, true);
+ node.installContribution("store-client", "../../itest/T3558/src/test/resources/sample-store-client.jar", null, null, true);
+
+// Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = NodeFactory.newInstance().createNode("default");
+ node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+
+// SCAClientFactory scaClientFactory = node.getSCAClientFactory();
+// try {
+// scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+// Assert.fail();
+// } catch (NoSuchServiceException e) {
+// // expected as there is no deployables
+// }
+
+ node.addToDomainLevelComposite("helloworld", "helloworld.composite");
+// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = NodeFactory.newInstance().createNode("default");
+ node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+ List<String> ics = node.getInstalledContributions();
+ Assert.assertEquals(1, ics.size());
+ Assert.assertEquals("foo", ics.get(0));
+ }
+
+ @Test
+ public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
+ Node node = NodeFactory.newInstance().createNode("default");
+ node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
+ List<String> dcs = node.getDeployedCompostes("foo");
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld.composite", dcs.get(0));
+ }
+
+ @Test
+ public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
+ Node node = NodeFactory.newInstance().createNode("default");
+ node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
+ node.removeFromDomainLevelComposite("foo", "helloworld.composite");
+ List<String> dcs = node.getDeployedCompostes("foo");
+ Assert.assertEquals(0, dcs.size());
+ }
+
+ @Test
+ public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException {
+ Node node = NodeFactory.newInstance().createNode("default");
+ ((NodeImpl)node).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true);
+
+ List<String> dcs = node.getDeployedCompostes("helloworld");
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld.composite", dcs.get(0));
+
+// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testURI() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = NodeFactory.newInstance().createNode("default");
+ String uri = node.installContribution("src/test/resources/sample-helloworld.jar");
+ Assert.assertEquals("sample-helloworld", uri);
+ }
+
+ @Test
+ public void testStaticCreate() {
+ Node node = NodeFactory.newStandaloneNode("helloworld.composite", "src/test/resources/sample-helloworld.jar");
+ List<String> cs = node.getInstalledContributions();
+ Assert.assertEquals(1, cs.size());
+ List<String> dcs = node.getDeployedCompostes(cs.get(0));
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld.composite", dcs.get(0));
+ }
+
+ @Test
+ public void testStaticCreateWithNullComposite() {
+ Node node = NodeFactory.newStandaloneNode(null, "src/test/resources/sample-helloworld.jar");
+ List<String> cs = node.getInstalledContributions();
+ Assert.assertEquals(1, cs.size());
+ List<String> dcs = node.getDeployedCompostes(cs.get(0));
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld.composite", dcs.get(0));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/sample/Helloworld.java b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/sample/Helloworld.java
new file mode 100644
index 0000000000..ea65a1e58c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/java/sample/Helloworld.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample;
+
+public interface Helloworld {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/helloworld2.composite b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/helloworld2.composite
new file mode 100644
index 0000000000..8c7a789380
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/helloworld2.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld2">
+
+ <component name="Helloworld2Component">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar
new file mode 100644
index 0000000000..3e9ae79a41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar
new file mode 100644
index 0000000000..40333cab75
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar
new file mode 100644
index 0000000000..16dde03858
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sample-helloworld.jar b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sample-helloworld.jar
new file mode 100644
index 0000000000..50e732d50b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sample-helloworld.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sca-contribution-generated.xml b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sca-contribution-generated.xml
new file mode 100644
index 0000000000..8e20561dc3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/domain-node/src/test/resources/sca-contribution-generated.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:helloworld"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ea13b89d17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Hazelcast Client Based EndPoint Registry
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Hazelcast Client Endpoint Regsitry
+Bundle-SymbolicName: org.apache.tuscany.sca.endpoint.hazelcast.client
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: com.hazelcast.client,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.endpoint.hazelcast;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0"
+Export-Package: org.apache.tuscany.sca.endpoint.hazelcast.client;version="2.0.0";
+ uses:="org.apache.tuscany.sca.runtime,org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.core,org.apache.tuscany.sca.endpoint.hazelcast"
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/pom.xml b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/pom.xml
new file mode 100644
index 0000000000..7553c09045
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/pom.xml
@@ -0,0 +1,45 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-endpoint-hazelcast-client</artifactId>
+ <name>Apache Tuscany SCA EndPoint Registry using Hazelcast Native Client</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast-client</artifactId>
+ <version>1.8.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientDomainRegistryFactory.java b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientDomainRegistryFactory.java
new file mode 100644
index 0000000000..ad4d6d9e64
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientDomainRegistryFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.hazelcast.client;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.runtime.BaseDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the
+ * given domain
+ */
+public class HazelcastClientDomainRegistryFactory extends BaseDomainRegistryFactory {
+ private final static String[] schemes = new String[] {"hazelcastclient", "tuscanyclient"};
+
+ /**
+ * @param extensionRegistry
+ */
+ public HazelcastClientDomainRegistryFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ protected EndpointRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI) {
+ EndpointRegistry endpointRegistry =
+ new HazelcastClientEndpointRegistry(registry, null, endpointRegistryURI, domainURI);
+ return endpointRegistry;
+ }
+
+ public String[] getSupportedSchemes() {
+ return schemes;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java
new file mode 100644
index 0000000000..8b9e49ecd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/client/HazelcastClientEndpointRegistry.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.endpoint.hazelcast.client;
+
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.ServerSocket;
+import java.util.Enumeration;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.endpoint.hazelcast.HazelcastEndpointRegistry;
+import org.apache.tuscany.sca.endpoint.hazelcast.RegistryConfig;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+import com.hazelcast.client.HazelcastClient;
+import com.hazelcast.core.HazelcastInstance;
+
+/**
+ * An EndpointRegistry using a Hazelcast Native Client
+ */
+public class HazelcastClientEndpointRegistry extends HazelcastEndpointRegistry {
+
+ HazelcastClient hazelcastClient;
+
+ public HazelcastClientEndpointRegistry(ExtensionPointRegistry registry,
+ Map<String, String> attributes,
+ String domainRegistryURI,
+ String domainURI) {
+ super(registry, attributes, domainRegistryURI, domainURI);
+ }
+
+ @Override
+ public void start() {
+ if (endpointMap != null) {
+ throw new IllegalStateException("The registry has already been started");
+ }
+ initHazelcastClientInstance();
+ endpointMap = hazelcastClient.getMap(domainURI + "/Endpoints");
+ endpointOwners = hazelcastClient.getMultiMap(domainURI + "/EndpointOwners");
+ }
+
+ @Override
+ public void stop() {
+ if (hazelcastClient != null) {
+ hazelcastClient.shutdown();
+ hazelcastClient = null;
+ endpointMap = null;
+ }
+ }
+
+ private void initHazelcastClientInstance() {
+ this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ RegistryConfig rc = new RegistryConfig(properties);
+ if (rc.getWKAs().size() < 1) {
+ String ip = getDefaultWKA();
+ if (ip != null) {
+ rc.getWKAs().add(ip);
+ }
+ }
+ if (rc.getWKAs().size() < 1) {
+ throw new IllegalArgumentException("Must specify remote IP address(es) for domain");
+ }
+ this.domainURI = properties.getProperty("defaultDomainName", "default");
+ this.hazelcastClient = HazelcastClient.newHazelcastClient(rc.getUserid(), rc.getPassword(), rc.getWKAs().toArray(new String[0]));
+ }
+
+ @Override
+ public HazelcastInstance getHazelcastInstance() {
+ return hazelcastClient;
+ }
+
+ /**
+ * See if there's a local IP listening on port 14820
+ */
+ protected static String getDefaultWKA() {
+ try {
+ Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
+ while (nis.hasMoreElements()) {
+ NetworkInterface ni = nis.nextElement();
+ Enumeration<InetAddress> ips = ni.getInetAddresses();
+ while (ips.hasMoreElements()) {
+ InetAddress addr = ips.nextElement();
+ ServerSocket ss = null;
+ try {
+ ss = new ServerSocket(14820, 0, addr);
+ } catch (BindException e) {
+ return addr.getHostAddress() + ":14820";
+ } finally {
+ if (ss != null) {
+ ss.close();
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
new file mode 100644
index 0000000000..b15ea6a58f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.endpoint.hazelcast.client.HazelcastClientDomainRegistryFactory;ranking=100
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9680bb9038
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Hazelcast Based EndPoint Registry
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Hazelcast Endpoint Regsitry
+Bundle-SymbolicName: org.apache.tuscany.sca.endpoint.hazelcast
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: com.hazelcast.config,
+ com.hazelcast.core,
+ com.hazelcast.nio,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0"
+Export-Package: org.apache.tuscany.sca.endpoint.hazelcast;version="2.0.0";
+ uses:="org.apache.tuscany.sca.runtime,org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.core"
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/pom.xml b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/pom.xml
new file mode 100644
index 0000000000..0b7857afa5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/pom.xml
@@ -0,0 +1,63 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <name>Apache Tuscany SCA EndPoint Registry using Hazelcast</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ <version>1.8.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-deployment</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java
new file mode 100644
index 0000000000..87c60e4b38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.hazelcast;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.runtime.BaseDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+/**
+ * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the
+ * given domain
+ */
+public class HazelcastDomainRegistryFactory extends BaseDomainRegistryFactory {
+ private final static String[] schemes = new String[] {"multicast", "wka", "tuscany", "hazelcast", "uri"};
+
+ public HazelcastDomainRegistryFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ protected EndpointRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI) {
+ Properties properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ return new HazelcastEndpointRegistry(registry, properties, domainURI);
+ }
+
+ public String[] getSupportedSchemes() {
+ return schemes;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
new file mode 100644
index 0000000000..c041914de8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
@@ -0,0 +1,370 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.hazelcast;
+
+import java.io.FileNotFoundException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.runtime.BaseEndpointRegistry;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.config.NearCacheConfig;
+import com.hazelcast.config.TcpIpConfig;
+import com.hazelcast.config.XmlConfigBuilder;
+import com.hazelcast.core.EntryEvent;
+import com.hazelcast.core.EntryListener;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.core.ILock;
+import com.hazelcast.core.IMap;
+import com.hazelcast.core.Member;
+import com.hazelcast.core.MembershipEvent;
+import com.hazelcast.core.MembershipListener;
+import com.hazelcast.core.MultiMap;
+import com.hazelcast.core.Transaction;
+import com.hazelcast.nio.Address;
+
+/**
+ * An EndpointRegistry using a Hazelcast
+ */
+public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements EndpointRegistry, LifeCycleListener, EntryListener<String, Endpoint>, MembershipListener {
+ private final static Logger logger = Logger.getLogger(HazelcastEndpointRegistry.class.getName());
+
+ private HazelcastInstance hazelcastInstance;
+ protected Map<Object, Object> endpointMap;
+ protected Map<String, Endpoint> localEndpoints = new ConcurrentHashMap<String, Endpoint>();
+ protected MultiMap<String, String> endpointOwners;
+ protected AssemblyFactory assemblyFactory;
+ protected Object shutdownMutex = new Object();
+ protected Properties properties;
+
+ public HazelcastEndpointRegistry(ExtensionPointRegistry registry, Properties properties, String domainURI) {
+ super(registry, null, null, domainURI);
+ this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class);
+ this.properties = properties;
+ }
+
+ public HazelcastEndpointRegistry(ExtensionPointRegistry registry,
+ Map<String, String> attributes,
+ String domainRegistryURI,
+ String domainURI) {
+ super(registry, attributes, domainRegistryURI, domainURI);
+ this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class);
+ this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ }
+
+ public HazelcastInstance getHazelcastInstance() {
+ return hazelcastInstance;
+ }
+
+ public void start() {
+ if (endpointMap != null) {
+ throw new IllegalStateException("The registry has already been started");
+ }
+// if (configURI.toString().startsWith("tuscany:vm:")) {
+// endpointMap = new HashMap<Object, Object>();
+// } else {
+ initHazelcastInstance();
+ IMap imap = hazelcastInstance.getMap(domainURI + "/Endpoints");
+ imap.addEntryListener(this, true);
+ endpointMap = imap;
+
+ endpointOwners = hazelcastInstance.getMultiMap(domainURI + "/EndpointOwners");
+
+ hazelcastInstance.getCluster().addMembershipListener(this);
+// }
+ }
+
+ public void stop() {
+ if (hazelcastInstance != null) {
+ synchronized (shutdownMutex) {
+ hazelcastInstance.shutdown();
+ hazelcastInstance = null;
+ endpointMap = null;
+ endpointOwners = null;
+ }
+ }
+ }
+
+ private void initHazelcastInstance() {
+ Config config = getHazelcastConfig();
+
+ // do this when theres a way to have adders be the key owners
+ // config.getMapConfig(configURI.getDomainName() + "/Endpoints").setBackupCount(0);
+
+ // this caches reads locally
+ config.getMapConfig("default").setNearCacheConfig(new NearCacheConfig(0, 0, "NONE", 0, true));
+
+ // Disable the Hazelcast shutdown hook as Tuscany has its own and with both there are race conditions
+ config.setProperty("hazelcast.shutdownhook.enabled",
+ // GroupProperties.PROP_SHUTDOWNHOOK_ENABLED,
+ "false");
+
+ // By default this is 5 seconds, not sure what the implications are but dropping it down to 1 makes
+ // things like the samples look much faster
+ config.setProperty("hazelcast.wait.seconds.before.join",
+ // GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN,
+ "1");
+
+ this.hazelcastInstance = Hazelcast.newHazelcastInstance(config);
+ }
+
+ protected Config getHazelcastConfig() {
+ Config config;
+ this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ String configFile = properties.getProperty("hazelcastConfig");
+ if (configFile != null) {
+ try {
+ config = new XmlConfigBuilder(configFile).build();
+ } catch (FileNotFoundException e) {
+ throw new IllegalArgumentException(configFile, e);
+ }
+ } else {
+ config = new XmlConfigBuilder().build();
+ RegistryConfig rc = new RegistryConfig(properties);
+ config.setPort(rc.getBindPort());
+ //config.setPortAutoIncrement(false);
+
+ if (!rc.getBindAddress().equals("*")) {
+ config.getNetworkConfig().getInterfaces().setEnabled(true);
+ config.getNetworkConfig().getInterfaces().clear();
+ config.getNetworkConfig().getInterfaces().addInterface(rc.getBindAddress());
+ }
+
+ config.getGroupConfig().setName(rc.getUserid());
+ config.getGroupConfig().setPassword(rc.getPassword());
+
+ if (rc.isMulticastDisabled()) {
+ config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
+ } else {
+ config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);
+ config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(rc.getMulticastPort());
+ config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastGroup(rc.getMulticastAddress());
+ }
+
+ if (rc.getWKAs().size() > 0) {
+ TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
+ tcpconfig.setEnabled(true);
+ List<Address> lsMembers = tcpconfig.getAddresses();
+ lsMembers.clear();
+ for (String addr : rc.getWKAs()) {
+ String[] ipNPort = addr.split(":");
+ try {
+ lsMembers.add(new Address(ipNPort[0], Integer.parseInt(ipNPort[1])));
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+ return config;
+ }
+
+ public void addEndpoint(Endpoint endpoint) {
+ if (findEndpoint(endpoint.getURI()).size() > 0) {
+ Member m = getOwningMember(endpoint.getURI());
+ throw new IllegalStateException("Endpoint " + endpoint.getURI() + " already exists in domain " + domainURI + " at " + m.getInetSocketAddress());
+ }
+
+ String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
+ String endpointURI = endpoint.getURI();
+ Transaction txn = hazelcastInstance.getTransaction();
+ txn.begin();
+ try {
+ endpointMap.put(endpointURI, endpoint);
+ endpointOwners.put(localMemberAddr, endpointURI);
+ txn.commit();
+ } catch (Throwable e) {
+ txn.rollback();
+ throw new ServiceRuntimeException(e);
+ }
+ localEndpoints.put(endpointURI, endpoint);
+ logger.info("Add endpoint - " + endpoint);
+ }
+
+ public List<Endpoint> findEndpoint(String uri) {
+ List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
+ for (Object v : endpointMap.values()) {
+ Endpoint endpoint = (Endpoint)v;
+ logger.fine("Matching against - " + endpoint);
+ if (endpoint.matches(uri)) {
+ if (!isLocal(endpoint)) {
+ endpoint.setRemote(true);
+ ((RuntimeEndpoint)endpoint).bind(registry, this);
+ } else {
+ // get the local version of the endpoint
+ // this local version won't have been serialized
+ // won't be marked as remote and will have the
+ // full interface contract information
+ endpoint = localEndpoints.get(endpoint.getURI());
+ }
+
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
+ }
+ }
+ return foundEndpoints;
+ }
+
+
+ private boolean isLocal(Endpoint endpoint) {
+ return localEndpoints.containsKey(endpoint.getURI());
+ }
+
+ public Endpoint getEndpoint(String uri) {
+ return (Endpoint)endpointMap.get(uri);
+ }
+
+ public List<Endpoint> getEndpoints() {
+ return new ArrayList(endpointMap.values());
+ }
+
+ public void removeEndpoint(Endpoint endpoint) {
+ if (hazelcastInstance == null) {
+ return;
+ }
+ synchronized (shutdownMutex) {
+ String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
+ String endpointURI = endpoint.getURI();
+
+// TODO: seems to be a txn bug in Hazelcast, see http://code.google.com/p/hazelcast/issues/detail?id=258
+// Transaction txn = hazelcastInstance.getTransaction();
+// txn.begin();
+// try {
+ endpointOwners.remove(localMemberAddr, endpointURI);
+ endpointMap.remove(endpointURI);
+// txn.commit();
+// } catch (Throwable e) {
+// txn.rollback();
+// throw new ServiceRuntimeException(e);
+// }
+ localEndpoints.remove(endpointURI);
+ logger.info("Removed endpoint - " + endpoint);
+ }
+ }
+
+
+ public void entryAdded(EntryEvent<String, Endpoint> event) {
+ entryAdded(event.getKey(), event.getValue());
+ }
+
+ public void entryEvicted(EntryEvent<String, Endpoint> event) {
+ // Should not happen
+ }
+
+ public void entryRemoved(EntryEvent<String, Endpoint> event) {
+ entryRemoved(event.getKey(), event.getValue());
+ }
+
+ public void entryUpdated(EntryEvent<String, Endpoint> event) {
+ entryUpdated(event.getKey(), null, event.getValue());
+ }
+
+ public void entryAdded(Object key, Object value) {
+ Endpoint newEp = (Endpoint)value;
+ if (!isLocal(newEp)) {
+ logger.info(" Remote endpoint added: " + newEp);
+ }
+ endpointAdded(newEp);
+ }
+
+ public void entryRemoved(Object key, Object value) {
+ Endpoint oldEp = (Endpoint)value;
+ if (!isLocal(oldEp)) {
+ logger.info(" Remote endpoint removed: " + value);
+ }
+ endpointRemoved(oldEp);
+ }
+
+ public void entryUpdated(Object key, Object oldValue, Object newValue) {
+ Endpoint oldEp = (Endpoint)oldValue;
+ Endpoint newEp = (Endpoint)newValue;
+ if (!isLocal(newEp)) {
+ logger.info(" Remote endpoint updated: " + newEp);
+ }
+ endpointUpdated(oldEp, newEp);
+ }
+
+ public void memberAdded(MembershipEvent event) {
+ }
+
+ public void memberRemoved(MembershipEvent event) {
+ try {
+ String memberAddr = event.getMember().getInetSocketAddress().toString();
+ if (endpointOwners.containsKey(memberAddr)) {
+ synchronized (shutdownMutex) {
+ ILock lock = hazelcastInstance.getLock("EndpointOwners/" + memberAddr);
+ lock.lock();
+ try {
+ if (endpointOwners.containsKey(memberAddr)) {
+ Collection<String> keys = endpointOwners.remove(memberAddr);
+ for (Object k : keys) {
+ endpointMap.remove(k);
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+ }
+ } catch (Exception e) {
+ if (e.getCause() != null && e.getCause().getCause() != null) {
+ // ignore hazelcast already shutdown exception
+ if (!"Hazelcast Instance is not active!".equals(e.getCause().getCause().getMessage())) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ }
+ }
+
+ public Member getOwningMember(String serviceURI) {
+ for (String memberAddr : endpointOwners.keySet()) {
+ for (String service : endpointOwners.get(memberAddr)) {
+ Endpoint ep = assemblyFactory.createEndpoint();
+ ep.setURI(service);
+ if (ep.matches(serviceURI)) {
+ for (Member m : getHazelcastInstance().getCluster().getMembers()) {
+ if (memberAddr.equals(m.getInetSocketAddress().toString())) {
+ return m;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
new file mode 100644
index 0000000000..79bffd3b21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.hazelcast;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+
+
+/**
+ * Utility to parse the config properties.
+ *
+ * bind - ip[:port] - defines the local bind address and port, it defaults to the network interface with the widest
+ * class (ie class A is wider than class B) on port 14820 and if that port in use it will try
+ * incrementing by one till a free port is found.
+ *
+ * multicast - groupip:port | off - defines if multicast discovery is used and if so what multicast ip group and port is used
+ * defaults to 224.5.12.10:51482. A value of off means multicast is disabled.
+ *
+ * wka - ip[:port] - a comma separated list of ip address and port for remote nodes in the domain group. The port defaults to 14820.
+ *
+ * userid - is the userid other nodes must use to connect to this domain group. The default is the default domain name.
+ *
+ * password - is the password other nodes must use to connect to this domain group. The default is 'tuscany'.
+ *
+ * client - true means this is an SCAClient call
+ *
+ */
+public class RegistryConfig {
+
+ private String bindAddress = "*";
+ private int bindPort = 14820;
+ private boolean multicastDisabled = false;
+ private String multicastAddress = "224.5.12.10";
+ private int multicastPort = 51482;
+ private List<String> wkas = new ArrayList<String>();
+ private String userid;
+ private String password;
+ boolean client;
+
+ public RegistryConfig(Properties properties) {
+ init(properties);
+ }
+
+ private void init(Properties properties) {
+
+ String bindValue = properties.getProperty("bind");
+ if (bindValue == null) {
+ InetAddress addr = chooseLocalAddress();
+ if (addr != null) {
+ this.bindAddress = addr.getHostAddress();
+ }
+ } else {
+ if (bindValue.indexOf(":") == -1) {
+ this.bindAddress = bindValue;
+ } else {
+ String[] addr = bindValue.split(":");
+ this.bindAddress = addr[0];
+ this.bindPort = Integer.parseInt(addr[1]);
+ }
+ }
+
+ String multicastValue = properties.getProperty("multicast");
+ if (multicastValue != null) {
+ if ("off".equalsIgnoreCase(multicastValue)) {
+ this.multicastDisabled = true;
+ } else {
+ if (multicastValue.indexOf(":") == -1) {
+ this.multicastAddress = multicastValue;
+ } else {
+ String[] addr = multicastValue.split(":");
+ this.multicastAddress = addr[0];
+ this.multicastPort = Integer.parseInt(addr[1]);
+ }
+ }
+ }
+
+ String wkaValue = properties.getProperty("wka");
+ if (wkaValue != null) {
+ String[] ips = wkaValue.split(",");
+ for (String ip : ips) {
+ if (ip.indexOf(":") == -1) {
+ wkas.add(ip + ":14820");
+ } else {
+ wkas.add(ip);
+ }
+ }
+ }
+
+ this.client = Boolean.parseBoolean(properties.getProperty("client", "false"));
+ this.password = properties.getProperty("password", "tuscany");
+ this.userid = properties.getProperty("userid", properties.getProperty("defaultDomainName", "default"));
+
+ }
+
+ public String getBindAddress() {
+ return bindAddress;
+ }
+
+ public int getBindPort() {
+ return bindPort;
+ }
+
+ public boolean isMulticastDisabled() {
+ return multicastDisabled;
+ }
+
+ public String getMulticastAddress() {
+ return multicastAddress;
+ }
+
+ public int getMulticastPort() {
+ return multicastPort;
+ }
+
+ public List<String> getWKAs() {
+ return wkas;
+ }
+
+ public String getUserid() {
+ return userid;
+ }
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Use the NIC address with the widest class, ie class A instead of class B or C.
+ * Bit crude but in a lot of environments a class A address (eg 10.x.x.x) is likely
+ * a better choice than a class C address (eg 192.x.x.x). And the alternative to
+ * this is to just choose the first address of the first network interface which
+ * likely isn't a better choice than this approach.
+ */
+ protected InetAddress chooseLocalAddress() {
+ InetAddress chosen = null;
+ try {
+ Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
+ while (nis.hasMoreElements()) {
+ NetworkInterface ni = nis.nextElement();
+ Enumeration<InetAddress> ips = ni.getInetAddresses();
+ while (ips.hasMoreElements()) {
+ InetAddress addr = ips.nextElement();
+ if (!addr.isLoopbackAddress()) {
+ if (chosen == null) {
+ chosen = addr;
+ } else {
+ if (((int) addr.getAddress()[0] & 0xFF) < ((int) chosen.getAddress()[0] & 0xFF)) {
+ chosen = addr;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ return chosen;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
new file mode 100644
index 0000000000..23551701a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.endpoint.hazelcast.HazelcastDomainRegistryFactory;ranking=100
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java
new file mode 100644
index 0000000000..67ce2bb50b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.hazelcast;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MultiRegTestCase {
+ private static ExtensionPointRegistry extensionPoints;
+ private static AssemblyFactory assemblyFactory;
+ private static SCABindingFactory scaBindingFactory;
+
+ @BeforeClass
+ public static void init() {
+ extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ scaBindingFactory = factories.getFactory(SCABindingFactory.class);
+ Properties properties = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ properties.setProperty("bind", "127.0.0.1");
+ }
+
+ @Test
+ public void testReplication() throws Exception {
+
+ System.out.println("Starting reg1");
+ HazelcastEndpointRegistry reg1 = new HazelcastEndpointRegistry(extensionPoints, null, null, "bar");
+ reg1.start();
+
+ System.out.println("Adding ep1");
+ RuntimeEndpoint ep1 = createEndpoint("ep1uri");
+ ep1.bind(extensionPoints, reg1);
+ reg1.addEndpoint(ep1);
+
+ System.out.println("Starting reg3");
+ HazelcastEndpointRegistry reg2 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9877&multicast=off&remotes=127.0.0.1:9876", "bar");
+ reg2.start();
+
+ System.out.println("Starting reg2");
+ HazelcastEndpointRegistry reg3 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9878&multicast=off&remotes=127.0.0.1:9877", "bar");
+ reg3.start();
+
+ assertExists(reg1, "ep1uri");
+ assertExists(reg2, "ep1uri");
+ assertExists(reg3, "ep1uri");
+
+ System.out.println("Adding ep2");
+ RuntimeEndpoint ep2 = createEndpoint("ep2uri");
+ ep2.bind(extensionPoints, reg2);
+ reg2.addEndpoint(ep2);
+
+ assertExists(reg2, "ep2uri");
+ assertExists(reg1, "ep2uri");
+ assertExists(reg3, "ep2uri");
+
+ System.out.println("Stopping reg1");
+ reg1.stop();
+ System.out.println("Stopped reg1");
+ Thread.sleep(500);
+
+ Assert.assertNull(reg2.getEndpoint("ep1uri"));
+ Assert.assertNull(reg3.getEndpoint("ep1uri"));
+
+ assertExists(reg2, "ep2uri");
+ assertExists(reg3, "ep2uri");
+
+ System.out.println("Starting reg1");
+ reg1.start();
+ ep1.bind(extensionPoints, reg1);
+
+ System.out.println("adding ep1");
+ reg1.addEndpoint(ep1);
+ assertExists(reg1, "ep1uri");
+ assertExists(reg2, "ep1uri");
+ assertExists(reg3, "ep1uri");
+
+ System.out.println("Stopping reg1");
+ reg1.stop();
+ System.out.println("Stopping reg2");
+ reg2.stop();
+ System.out.println("Stopping reg3");
+ reg3.stop();
+ System.out.println("done");
+ }
+
+ @Test
+ public void testDuplicates() throws Exception {
+ HazelcastEndpointRegistry reg1 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9876&multicast=off", "bar");
+ reg1.start();
+ RuntimeEndpoint ep1 = createEndpoint("ep1uri");
+ ep1.bind(extensionPoints, reg1);
+ reg1.addEndpoint(ep1);
+
+ HazelcastEndpointRegistry reg2 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9877&multicast=off&remotes=127.0.0.1:9876", "bar");
+ reg2.start();
+
+ try {
+ reg2.addEndpoint(ep1);
+ Assert.fail();
+ } catch (IllegalStateException e) {
+ // expected
+ }
+
+ reg1.stop();
+
+ Thread.sleep(200);
+
+ // now it should work
+ reg2.addEndpoint(ep1);
+
+ reg2.stop();
+ }
+
+ private Endpoint assertExists(HazelcastEndpointRegistry reg, String uri) throws InterruptedException {
+ Endpoint ep = reg.getEndpoint(uri);
+ Assert.assertNotNull(ep);
+ Assert.assertEquals(uri, ep.getURI());
+ return ep;
+ }
+
+ private RuntimeEndpoint createEndpoint(String uri) {
+ RuntimeEndpoint ep = (RuntimeEndpoint) assemblyFactory.createEndpoint();
+ Component comp = assemblyFactory.createComponent();
+ ep.setComponent(comp);
+ ep.setService(assemblyFactory.createComponentService());
+ Binding b = scaBindingFactory.createSCABinding();
+ ep.setBinding(b);
+ ep.setURI(uri);
+ return ep;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java
new file mode 100644
index 0000000000..12b420f010
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryTestCase.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.hazelcast;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.config.TcpIpConfig;
+import com.hazelcast.config.XmlConfigBuilder;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.core.IMap;
+import com.hazelcast.nio.Address;
+
+@Ignore
+public class RegistryTestCase {
+
+ @Test
+ public void test1() throws UnknownHostException {
+
+ HazelcastInstance h1 = create("54327", 9001);
+
+ IMap<Object, Object> h1map = h1.getMap("mymap");
+ h1map.put("key1", "bla1");
+ Assert.assertEquals("bla1", h1map.get("key1"));
+
+ HazelcastInstance h2 = create("false", 9002, 9001);
+ IMap<Object, Object> h2map = h2.getMap("mymap");
+ Assert.assertEquals("bla1", h2map.get("key1"));
+
+ HazelcastInstance h3 = create("false", 9003, 9002);
+ IMap<Object, Object> h3map = h3.getMap("mymap");
+ Assert.assertEquals("bla1", h3map.get("key1"));
+
+ h3map.put("k3", "v3");
+ h2map.put("k2", "v2");
+
+ Assert.assertEquals("v2", h1map.get("k2"));
+ Assert.assertEquals("v3", h1map.get("k3"));
+ Assert.assertEquals("v2", h2map.get("k2"));
+ Assert.assertEquals("v3", h2map.get("k3"));
+ Assert.assertEquals("v2", h3map.get("k2"));
+ Assert.assertEquals("v3", h3map.get("k3"));
+
+ HazelcastInstance h4 = create("54328", 9004, 9001);
+ IMap<Object, Object> h4map = h4.getMap("mymap");
+// Assert.assertNull(h4map.get("k2"));
+// Assert.assertNull(h4map.get("k3"));
+ Assert.assertEquals("v2", h4map.get("k2"));
+ Assert.assertEquals("v3", h4map.get("k3"));
+
+// HazelcastInstance h5 = create("false", 9005, 9003, 9004);
+ HazelcastInstance h5 = create("54328", 9005);
+
+// Assert.assertEquals("v2", h4map.get("k2"));
+// Assert.assertEquals("v3", h4map.get("k3"));
+
+ IMap<Object, Object> h5map = h5.getMap("mymap");
+ Assert.assertEquals("v2", h5map.get("k2"));
+ Assert.assertEquals("v3", h5map.get("k3"));
+
+ h1.shutdown();
+
+ Assert.assertEquals("v2", h2map.get("k2"));
+ Assert.assertEquals("v3", h2map.get("k3"));
+ Assert.assertEquals("v2", h3map.get("k2"));
+ Assert.assertEquals("v3", h3map.get("k3"));
+ Assert.assertEquals("v2", h4map.get("k2"));
+ Assert.assertEquals("v3", h4map.get("k3"));
+
+ h3map.put("key1a", "bla1a");
+
+ Assert.assertEquals("bla1a", h2map.get("key1a"));
+ Assert.assertEquals("bla1a", h3map.get("key1a"));
+ Assert.assertEquals("bla1a", h4map.get("key1a"));
+
+// HazelcastInstance h4 = create(true, 9004, 9003);
+// HazelcastInstance h5 = create(true, 9005);
+// IMap<Object, Object> h5map = h5.getMap("mymap");
+// Assert.assertEquals("bla1", h5map.get("key1"));
+
+// HazelcastInstance h6 = create(false, 9006, 9005);
+// IMap<Object, Object> h6map = h6.getMap("mymap");
+// Assert.assertEquals("bla1", h6map.get("key1"));
+
+ }
+
+ private HazelcastInstance create(String multicast, int listenPort, int... connectPorts) throws UnknownHostException {
+ Config config = new XmlConfigBuilder().build();
+ config.setPort(listenPort);
+ config.setPortAutoIncrement(false);
+
+ // declare the interface Hazelcast should bind to
+ config.getNetworkConfig().getInterfaces().clear();
+ config.getNetworkConfig().getInterfaces().addInterface(InetAddress.getLocalHost().getHostAddress());
+ config.getNetworkConfig().getInterfaces().setEnabled(true);
+
+ if ("false".equals(multicast)) {
+ config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
+ } else {
+ config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastPort(Integer.parseInt(multicast));
+ }
+
+ if (connectPorts.length > 0) {
+ TcpIpConfig tcpconfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
+ tcpconfig.setEnabled(true);
+
+ List<Address> lsMembers = tcpconfig.getAddresses();
+ lsMembers.clear();
+ for (int p : connectPorts) {
+ lsMembers.add(new Address(InetAddress.getLocalHost(), p));
+ }
+ }
+
+ return Hazelcast.newHazelcastInstance(config);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/endpoint-tribes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..06df55ef38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.xsd.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Tomcat Tribes Based EndPoint Registry
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA XSD Model
+Bundle-SymbolicName: org.apache.tuscany.sca.endpoint.tribes
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: org.apache.catalina.tribes,
+ org.apache.catalina.tribes.group,
+ org.apache.catalina.tribes.group.interceptors,
+ org.apache.catalina.tribes.io,
+ org.apache.catalina.tribes.membership,
+ org.apache.catalina.tribes.tipis,
+ org.apache.catalina.tribes.transport,
+ org.apache.catalina.tribes.util,
+ org.apache.juli.logging;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly.impl;scope=internal;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.management;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0"
+Export-Package: org.apache.tuscany.sca.endpoint.tribes;version="2.0.0"
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/pom.xml b/sandbox/sebastien/java/embed/modules/endpoint-tribes/pom.xml
new file mode 100644
index 0000000000..973363ae84
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/pom.xml
@@ -0,0 +1,65 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <name>Apache Tuscany SCA Tomcat Tribes Based EndPoint Registry</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tribes</artifactId>
+ <!-- DO NOT upgrade to 6.0.20: https://issues.apache.org/bugzilla/show_bug.cgi?id=47419 -->
+ <version>6.0.26</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-deployment</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/AbstractReplicatedMap.java b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/AbstractReplicatedMap.java
new file mode 100644
index 0000000000..fe683af025
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/AbstractReplicatedMap.java
@@ -0,0 +1,1564 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.endpoint.tribes;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.ChannelListener;
+import org.apache.catalina.tribes.Heartbeat;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.MembershipListener;
+import org.apache.catalina.tribes.group.Response;
+import org.apache.catalina.tribes.group.RpcCallback;
+import org.apache.catalina.tribes.group.RpcChannel;
+import org.apache.catalina.tribes.io.XByteBuffer;
+import org.apache.catalina.tribes.membership.MemberImpl;
+import org.apache.catalina.tribes.tipis.ReplicatedMapEntry;
+import org.apache.catalina.tribes.util.Arrays;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+/**
+ * This file is copied from:
+ * https://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_20/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
+ *
+ * We need to intercept the put/remove calls on the base Map to fire events
+ */
+public abstract class AbstractReplicatedMap extends MapStore implements RpcCallback, ChannelListener,
+ MembershipListener, Heartbeat {
+ private static final long serialVersionUID = -2703358020113899074L;
+
+ protected static Log log = LogFactory.getLog(AbstractReplicatedMap.class);
+
+ /**
+ * The default initial capacity - MUST be a power of two.
+ */
+ public static final int DEFAULT_INITIAL_CAPACITY = 16;
+
+ /**
+ * The load factor used when none specified in constructor.
+ **/
+ public static final float DEFAULT_LOAD_FACTOR = 0.75f;
+
+ /**
+ * Used to identify the map
+ */
+ final String chset = "ISO-8859-1";
+
+ //------------------------------------------------------------------------------
+ // INSTANCE VARIABLES
+ //------------------------------------------------------------------------------
+ protected abstract int getStateMessageType();
+
+ /**
+ * Timeout for RPC messages, how long we will wait for a reply
+ */
+ protected transient long rpcTimeout = 5000;
+ /**
+ * Reference to the channel for sending messages
+ */
+ protected transient Channel channel;
+ /**
+ * The RpcChannel to send RPC messages through
+ */
+ protected transient RpcChannel rpcChannel;
+ /**
+ * The Map context name makes this map unique, this
+ * allows us to have more than one map shared
+ * through one channel
+ */
+ protected transient byte[] mapContextName;
+ /**
+ * Has the state been transferred
+ */
+ protected transient boolean stateTransferred = false;
+ /**
+ * Simple lock object for transfers
+ */
+ protected transient Object stateMutex = new Object();
+ /**
+ * A list of members in our map
+ */
+ protected transient Map<Member, Long> mapMembers = new HashMap<Member, Long>();
+ /**
+ * Our default send options
+ */
+ protected transient int channelSendOptions = Channel.SEND_OPTIONS_DEFAULT;
+ /**
+ * The owner of this map, ala a SessionManager for example
+ */
+ protected transient MapOwner mapOwner;
+ /**
+ * External class loaders if serialization and deserialization is to be performed successfully.
+ */
+ protected transient ClassLoader[] externalLoaders;
+
+ /**
+ * The node we are currently backing up data to, this index will rotate
+ * on a round robin basis
+ */
+ protected transient int currentNode = 0;
+
+ /**
+ * Since the map keeps internal membership
+ * this is the timeout for a ping message to be responded to
+ * If a remote map doesn't respond within this timeframe,
+ * its considered dead.
+ */
+ protected transient long accessTimeout = 5000;
+
+ /**
+ * Readable string of the mapContextName value
+ */
+ protected transient String mapname = "";
+
+ //------------------------------------------------------------------------------
+ // map owner interface
+ //------------------------------------------------------------------------------
+
+ public static interface MapOwner {
+ public void objectMadePrimay(Object key, Object value);
+ }
+
+ //------------------------------------------------------------------------------
+ // CONSTRUCTORS
+ //------------------------------------------------------------------------------
+
+ /**
+ * Creates a new map
+ * @param channel The channel to use for communication
+ * @param timeout long - timeout for RPC messags
+ * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+ * @param initialCapacity int - the size of this map, see HashMap
+ * @param loadFactor float - load factor, see HashMap
+ * @param cls - a list of classloaders to be used for deserialization of objects.
+ */
+ public AbstractReplicatedMap(MapOwner owner,
+ Channel channel,
+ long timeout,
+ String mapContextName,
+ int initialCapacity,
+ float loadFactor,
+ int channelSendOptions,
+ ClassLoader[] cls) {
+ super(initialCapacity, loadFactor, 15);
+ init(owner, channel, mapContextName, timeout, channelSendOptions, cls);
+
+ }
+
+ /**
+ * Helper methods, wraps a single member in an array
+ * @param m Member
+ * @return Member[]
+ */
+ protected Member[] wrap(Member m) {
+ if (m == null)
+ return new Member[0];
+ else
+ return new Member[] {m};
+ }
+
+ /**
+ * Initializes the map by creating the RPC channel, registering itself as a channel listener
+ * This method is also responsible for initiating the state transfer
+ * @param owner Object
+ * @param channel Channel
+ * @param mapContextName String
+ * @param timeout long
+ * @param channelSendOptions int
+ * @param cls ClassLoader[]
+ */
+ protected void init(MapOwner owner,
+ Channel channel,
+ String mapContextName,
+ long timeout,
+ int channelSendOptions,
+ ClassLoader[] cls) {
+ log.info("Initializing AbstractReplicatedMap with context name:" + mapContextName);
+ this.mapOwner = owner;
+ this.externalLoaders = cls;
+ this.channelSendOptions = channelSendOptions;
+ this.channel = channel;
+ this.rpcTimeout = timeout;
+
+ try {
+ this.mapname = mapContextName;
+ //unique context is more efficient if it is stored as bytes
+ this.mapContextName = mapContextName.getBytes(chset);
+ } catch (UnsupportedEncodingException x) {
+ log.warn("Unable to encode mapContextName[" + mapContextName
+ + "] using getBytes("
+ + chset
+ + ") using default getBytes()", x);
+ this.mapContextName = mapContextName.getBytes();
+ }
+ if (log.isTraceEnabled())
+ log.trace("Created Lazy Map with name:" + mapContextName
+ + ", bytes:"
+ + Arrays.toString(this.mapContextName));
+
+ //create an rpc channel and add the map as a listener
+ this.rpcChannel = new RpcChannel(this.mapContextName, channel, this);
+ //add this map as a message listener
+ this.channel.addChannelListener(this);
+ //listen for membership notifications
+ this.channel.addMembershipListener(this);
+
+ try {
+ //broadcast our map, this just notifies other members of our existence
+ broadcast(MapMessage.MSG_INIT, true);
+ //transfer state from another map
+ transferState();
+ //state is transferred, we are ready for messaging
+ broadcast(MapMessage.MSG_START, true);
+ } catch (ChannelException x) {
+ log.warn("Unable to send map start message.");
+ throw new RuntimeException("Unable to start replicated map.", x);
+ }
+ }
+
+ /**
+ * Sends a ping out to all the members in the cluster, not just map members
+ * that this map is alive.
+ * @param timeout long
+ * @throws ChannelException
+ */
+ protected void ping(long timeout) throws ChannelException {
+ //send out a map membership message, only wait for the first reply
+ MapMessage msg =
+ new MapMessage(this.mapContextName, MapMessage.MSG_INIT, false, null, null, null, channel
+ .getLocalMember(false), null);
+ if (channel.getMembers().length > 0) {
+ //send a ping, wait for all nodes to reply
+ Response[] resp =
+ rpcChannel.send(channel.getMembers(),
+ msg,
+ RpcChannel.ALL_REPLY,
+ (channelSendOptions),
+ (int)accessTimeout);
+ for (int i = 0; i < resp.length; i++) {
+ memberAlive(resp[i].getSource());
+ } //for
+ }
+ //update our map of members, expire some if we didn't receive a ping back
+ synchronized (mapMembers) {
+ Iterator it = mapMembers.entrySet().iterator();
+ long now = System.currentTimeMillis();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry)it.next();
+ long access = ((Long)entry.getValue()).longValue();
+ if ((now - access) > timeout) {
+ it.remove();
+ memberDisappeared((Member)entry.getKey());
+ }
+ }
+ }//synch
+ }
+
+ /**
+ * We have received a member alive notification
+ * @param member Member
+ */
+ protected void memberAlive(Member member) {
+ synchronized (mapMembers) {
+ if (!mapMembers.containsKey(member)) {
+ mapMemberAdded(member);
+ } //end if
+ mapMembers.put(member, new Long(System.currentTimeMillis()));
+ }
+ }
+
+ /**
+ * Helper method to broadcast a message to all members in a channel
+ * @param msgtype int
+ * @param rpc boolean
+ * @throws ChannelException
+ */
+ protected void broadcast(int msgtype, boolean rpc) throws ChannelException {
+ //send out a map membership message, only wait for the first reply
+ MapMessage msg =
+ new MapMessage(this.mapContextName, msgtype, false, null, null, null, channel.getLocalMember(false), null);
+ if (rpc) {
+ Response[] resp =
+ rpcChannel.send(channel.getMembers(), msg, RpcChannel.FIRST_REPLY, (channelSendOptions), rpcTimeout);
+ for (int i = 0; i < resp.length; i++) {
+ mapMemberAdded(resp[i].getSource());
+ messageReceived(resp[i].getMessage(), resp[i].getSource());
+ }
+ } else {
+ channel.send(channel.getMembers(), msg, channelSendOptions);
+ }
+ }
+
+ public void breakdown() {
+ finalize();
+ }
+
+ public void finalize() {
+ try {
+ broadcast(MapMessage.MSG_STOP, false);
+ } catch (Exception ignore) {
+ }
+ //cleanup
+ if (this.rpcChannel != null) {
+ this.rpcChannel.breakdown();
+ }
+ if (this.channel != null) {
+ this.channel.removeChannelListener(this);
+ this.channel.removeMembershipListener(this);
+ }
+ this.rpcChannel = null;
+ this.channel = null;
+ this.mapMembers.clear();
+ super.clear();
+ this.stateTransferred = false;
+ this.externalLoaders = null;
+ }
+
+ public int hashCode() {
+ return Arrays.hashCode(this.mapContextName);
+ }
+
+ public boolean equals(Object o) {
+ if (o == null)
+ return false;
+ if (!(o instanceof AbstractReplicatedMap))
+ return false;
+ if (!(o.getClass().equals(this.getClass())))
+ return false;
+ AbstractReplicatedMap other = (AbstractReplicatedMap)o;
+ return Arrays.equals(mapContextName, other.mapContextName);
+ }
+
+ //------------------------------------------------------------------------------
+ // GROUP COM INTERFACES
+ //------------------------------------------------------------------------------
+ public Member[] getMapMembers(Map<Member, Long> members) {
+ synchronized (members) {
+ Member[] result = new Member[members.size()];
+ members.keySet().toArray(result);
+ return result;
+ }
+ }
+
+ public Member[] getMapMembers() {
+ return getMapMembers(this.mapMembers);
+ }
+
+ public Member[] getMapMembersExcl(Member[] exclude) {
+ synchronized (mapMembers) {
+ Map<Member, Long> list = (Map<Member, Long>)((HashMap<Member, Long>)mapMembers).clone();
+ for (int i = 0; i < exclude.length; i++)
+ list.remove(exclude[i]);
+ return getMapMembers(list);
+ }
+ }
+
+ /**
+ * Replicates any changes to the object since the last time
+ * The object has to be primary, ie, if the object is a proxy or a backup, it will not be replicated<br>
+ * @param complete - if set to true, the object is replicated to its backup
+ * if set to false, only objects that implement ReplicatedMapEntry and the isDirty() returns true will
+ * be replicated
+ */
+ public void replicate(Object key, boolean complete) {
+ if (log.isTraceEnabled())
+ log.trace("Replicate invoked on key:" + key);
+ MapEntry entry = (MapEntry)super.get(key);
+ if (entry == null)
+ return;
+ if (!entry.isSerializable())
+ return;
+ if (entry != null && entry.isPrimary() && entry.getBackupNodes() != null && entry.getBackupNodes().length > 0) {
+ Object value = entry.getValue();
+ //check to see if we need to replicate this object isDirty()||complete
+ boolean repl = complete || ((value instanceof ReplicatedMapEntry) && ((ReplicatedMapEntry)value).isDirty());
+
+ if (!repl) {
+ if (log.isTraceEnabled())
+ log.trace("Not replicating:" + key + ", no change made");
+
+ return;
+ }
+ //check to see if the message is diffable
+ boolean diff = ((value instanceof ReplicatedMapEntry) && ((ReplicatedMapEntry)value).isDiffable());
+ MapMessage msg = null;
+ if (diff) {
+ ReplicatedMapEntry rentry = (ReplicatedMapEntry)entry.getValue();
+ try {
+ rentry.lock();
+ //construct a diff message
+ msg =
+ new MapMessage(mapContextName, MapMessage.MSG_BACKUP, true, (Serializable)entry.getKey(), null,
+ rentry.getDiff(), entry.getPrimary(), entry.getBackupNodes());
+ } catch (IOException x) {
+ log.error("Unable to diff object. Will replicate the entire object instead.", x);
+ } finally {
+ rentry.unlock();
+ }
+
+ }
+ if (msg == null) {
+ //construct a complete
+ msg =
+ new MapMessage(mapContextName, MapMessage.MSG_BACKUP, false, (Serializable)entry.getKey(),
+ (Serializable)entry.getValue(), null, entry.getPrimary(), entry.getBackupNodes());
+
+ }
+ try {
+ if (channel != null && entry.getBackupNodes() != null && entry.getBackupNodes().length > 0) {
+ channel.send(entry.getBackupNodes(), msg, channelSendOptions);
+ }
+ } catch (ChannelException x) {
+ log.error("Unable to replicate data.", x);
+ }
+ } //end if
+
+ }
+
+ /**
+ * This can be invoked by a periodic thread to replicate out any changes.
+ * For maps that don't store objects that implement ReplicatedMapEntry, this
+ * method should be used infrequently to avoid large amounts of data transfer
+ * @param complete boolean
+ */
+ public void replicate(boolean complete) {
+ Iterator<Map.Entry<Object, Object>> i = super.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ replicate(e.getKey(), complete);
+ } //while
+
+ }
+
+ public void transferState() {
+ try {
+ Member[] members = getMapMembers();
+ Member backup = members.length > 0 ? (Member)members[0] : null;
+ if (backup != null) {
+ MapMessage msg =
+ new MapMessage(mapContextName, getStateMessageType(), false, null, null, null, null, null);
+ Response[] resp =
+ rpcChannel.send(new Member[] {backup}, msg, RpcChannel.FIRST_REPLY, channelSendOptions, rpcTimeout);
+ if (resp.length > 0) {
+ synchronized (stateMutex) {
+ msg = (MapMessage)resp[0].getMessage();
+ msg.deserialize(getExternalLoaders());
+ List list = (List)msg.getValue();
+ for (int i = 0; i < list.size(); i++) {
+ messageReceived((Serializable)list.get(i), resp[0].getSource());
+ } //for
+ }
+ } else {
+ log.warn("Transfer state, 0 replies, probably a timeout.");
+ }
+ }
+ } catch (ChannelException x) {
+ log.error("Unable to transfer LazyReplicatedMap state.", x);
+ } catch (IOException x) {
+ log.error("Unable to transfer LazyReplicatedMap state.", x);
+ } catch (ClassNotFoundException x) {
+ log.error("Unable to transfer LazyReplicatedMap state.", x);
+ }
+ stateTransferred = true;
+ }
+
+ /**
+ * @todo implement state transfer
+ * @param msg Serializable
+ * @return Serializable - null if no reply should be sent
+ */
+ public Serializable replyRequest(Serializable msg, final Member sender) {
+ if (!(msg instanceof MapMessage))
+ return null;
+ MapMessage mapmsg = (MapMessage)msg;
+
+ //map init request
+ if (mapmsg.getMsgType() == MapMessage.MSG_INIT) {
+ mapmsg.setPrimary(channel.getLocalMember(false));
+ return mapmsg;
+ }
+
+ //map start request
+ if (mapmsg.getMsgType() == MapMessage.MSG_START) {
+ mapmsg.setPrimary(channel.getLocalMember(false));
+ mapMemberAdded(sender);
+ return mapmsg;
+ }
+
+ //backup request
+ if (mapmsg.getMsgType() == MapMessage.MSG_RETRIEVE_BACKUP) {
+ MapEntry entry = (MapEntry)super.get(mapmsg.getKey());
+ if (entry == null || (!entry.isSerializable()))
+ return null;
+ mapmsg.setValue((Serializable)entry.getValue());
+ return mapmsg;
+ }
+
+ //state transfer request
+ if (mapmsg.getMsgType() == MapMessage.MSG_STATE || mapmsg.getMsgType() == MapMessage.MSG_STATE_COPY) {
+ synchronized (stateMutex) { //make sure we dont do two things at the same time
+ ArrayList<MapMessage> list = new ArrayList<MapMessage>();
+ Iterator<Map.Entry<Object, Object>> i = super.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ MapEntry entry = (MapEntry)super.get(e.getKey());
+ if (entry != null && entry.isSerializable()) {
+ boolean copy = (mapmsg.getMsgType() == MapMessage.MSG_STATE_COPY);
+ MapMessage me =
+ new MapMessage(mapContextName, copy ? MapMessage.MSG_COPY : MapMessage.MSG_PROXY, false,
+ (Serializable)entry.getKey(), copy ? (Serializable)entry.getValue() : null,
+ null, entry.getPrimary(), entry.getBackupNodes());
+ list.add(me);
+ }
+ }
+ mapmsg.setValue(list);
+ return mapmsg;
+
+ } //synchronized
+ }
+
+ return null;
+
+ }
+
+ /**
+ * If the reply has already been sent to the requesting thread,
+ * the rpc callback can handle any data that comes in after the fact.
+ * @param msg Serializable
+ * @param sender Member
+ */
+ public void leftOver(Serializable msg, Member sender) {
+ //left over membership messages
+ if (!(msg instanceof MapMessage))
+ return;
+
+ MapMessage mapmsg = (MapMessage)msg;
+ try {
+ mapmsg.deserialize(getExternalLoaders());
+ if (mapmsg.getMsgType() == MapMessage.MSG_START) {
+ mapMemberAdded(mapmsg.getPrimary());
+ } else if (mapmsg.getMsgType() == MapMessage.MSG_INIT) {
+ memberAlive(mapmsg.getPrimary());
+ }
+ } catch (IOException x) {
+ log.error("Unable to deserialize MapMessage.", x);
+ } catch (ClassNotFoundException x) {
+ log.error("Unable to deserialize MapMessage.", x);
+ }
+ }
+
+ public void messageReceived(Serializable msg, Member sender) {
+ if (!(msg instanceof MapMessage))
+ return;
+
+ MapMessage mapmsg = (MapMessage)msg;
+ if (log.isTraceEnabled()) {
+ log.trace("Map[" + mapname + "] received message:" + mapmsg);
+ }
+
+ try {
+ mapmsg.deserialize(getExternalLoaders());
+ } catch (IOException x) {
+ log.error("Unable to deserialize MapMessage.", x);
+ return;
+ } catch (ClassNotFoundException x) {
+ log.error("Unable to deserialize MapMessage.", x);
+ return;
+ }
+ if (log.isTraceEnabled())
+ log.trace("Map message received from:" + sender.getName() + " msg:" + mapmsg);
+ if (mapmsg.getMsgType() == MapMessage.MSG_START) {
+ mapMemberAdded(mapmsg.getPrimary());
+ }
+
+ if (mapmsg.getMsgType() == MapMessage.MSG_STOP) {
+ memberDisappeared(mapmsg.getPrimary());
+ }
+
+ if (mapmsg.getMsgType() == MapMessage.MSG_PROXY) {
+ MapEntry entry = (MapEntry)super.get(mapmsg.getKey());
+ if (entry == null) {
+ entry = new MapEntry(mapmsg.getKey(), mapmsg.getValue());
+ entry.setBackup(false);
+ entry.setProxy(true);
+ entry.setBackupNodes(mapmsg.getBackupNodes());
+ entry.setPrimary(mapmsg.getPrimary());
+ super.put(entry.getKey(), entry);
+ } else {
+ entry.setProxy(true);
+ entry.setBackup(false);
+ entry.setBackupNodes(mapmsg.getBackupNodes());
+ entry.setPrimary(mapmsg.getPrimary());
+ }
+ }
+
+ if (mapmsg.getMsgType() == MapMessage.MSG_REMOVE) {
+ super.remove(mapmsg.getKey());
+ }
+
+ if (mapmsg.getMsgType() == MapMessage.MSG_BACKUP || mapmsg.getMsgType() == MapMessage.MSG_COPY) {
+ MapEntry entry = (MapEntry)super.get(mapmsg.getKey());
+ if (entry == null) {
+ entry = new MapEntry(mapmsg.getKey(), mapmsg.getValue());
+ entry.setBackup(mapmsg.getMsgType() == MapMessage.MSG_BACKUP);
+ entry.setProxy(false);
+ entry.setBackupNodes(mapmsg.getBackupNodes());
+ entry.setPrimary(mapmsg.getPrimary());
+ if (mapmsg.getValue() != null && mapmsg.getValue() instanceof ReplicatedMapEntry) {
+ ((ReplicatedMapEntry)mapmsg.getValue()).setOwner(getMapOwner());
+ }
+ } else {
+ entry.setBackup(mapmsg.getMsgType() == MapMessage.MSG_BACKUP);
+ entry.setProxy(false);
+ entry.setBackupNodes(mapmsg.getBackupNodes());
+ entry.setPrimary(mapmsg.getPrimary());
+ if (entry.getValue() instanceof ReplicatedMapEntry) {
+ ReplicatedMapEntry diff = (ReplicatedMapEntry)entry.getValue();
+ if (mapmsg.isDiff()) {
+ try {
+ diff.lock();
+ diff.applyDiff(mapmsg.getDiffValue(), 0, mapmsg.getDiffValue().length);
+ } catch (Exception x) {
+ log.error("Unable to apply diff to key:" + entry.getKey(), x);
+ } finally {
+ diff.unlock();
+ }
+ } else {
+ if (mapmsg.getValue() != null)
+ entry.setValue(mapmsg.getValue());
+ ((ReplicatedMapEntry)entry.getValue()).setOwner(getMapOwner());
+ } //end if
+ } else if (mapmsg.getValue() instanceof ReplicatedMapEntry) {
+ ReplicatedMapEntry re = (ReplicatedMapEntry)mapmsg.getValue();
+ re.setOwner(getMapOwner());
+ entry.setValue(re);
+ } else {
+ if (mapmsg.getValue() != null)
+ entry.setValue(mapmsg.getValue());
+ } //end if
+ } //end if
+ super.put(entry.getKey(), entry);
+ } //end if
+ }
+
+ public boolean accept(Serializable msg, Member sender) {
+ boolean result = false;
+ if (msg instanceof MapMessage) {
+ if (log.isTraceEnabled())
+ log.trace("Map[" + mapname + "] accepting...." + msg);
+ result = Arrays.equals(mapContextName, ((MapMessage)msg).getMapId());
+ if (log.isTraceEnabled())
+ log.trace("Msg[" + mapname + "] accepted[" + result + "]...." + msg);
+ }
+ return result;
+ }
+
+ public void mapMemberAdded(Member member) {
+ Member self = getChannel().getLocalMember(false);
+ if (member.equals(self))
+ return;
+ boolean memberAdded = false;
+ //select a backup node if we don't have one
+ synchronized (mapMembers) {
+ if (!mapMembers.containsKey(member)) {
+ mapMembers.put(member, new Long(System.currentTimeMillis()));
+ memberAdded = true;
+ }
+ }
+ if (memberAdded) {
+ synchronized (stateMutex) {
+ Iterator<Map.Entry<Object, Object>> i = super.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ MapEntry entry = (MapEntry)super.get(e.getKey());
+ if (entry == null)
+ continue;
+ // if (entry.isPrimary() && (entry.getBackupNodes() == null || entry.getBackupNodes().length == 0)) {
+ // [rfeng] Change the behavior to replicate to all nodes
+ if (entry.isPrimary() && self.equals(entry.getPrimary())) {
+ try {
+ Member[] backup = publishEntryInfo(entry.getKey(), entry.getValue());
+ entry.setBackupNodes(backup);
+ entry.setPrimary(self);
+ } catch (ChannelException x) {
+ log.error("Unable to select backup node.", x);
+ } //catch
+ } //end if
+ } //while
+ } //synchronized
+ }//end if
+ }
+
+ public boolean inSet(Member m, Member[] set) {
+ if (set == null)
+ return false;
+ boolean result = false;
+ for (int i = 0; i < set.length && (!result); i++)
+ if (m.equals(set[i]))
+ result = true;
+ return result;
+ }
+
+ public Member[] excludeFromSet(Member[] mbrs, Member[] set) {
+ List<Member> result = new ArrayList<Member>();
+ for (int i = 0; i < set.length; i++) {
+ boolean include = true;
+ for (int j = 0; j < mbrs.length; j++)
+ if (mbrs[j].equals(set[i]))
+ include = false;
+ if (include)
+ result.add(set[i]);
+ }
+ return (Member[])result.toArray(new Member[result.size()]);
+ }
+
+ public void memberAdded(Member member) {
+ //do nothing
+ }
+
+ public void memberDisappeared(Member member) {
+ boolean removed = false;
+ synchronized (mapMembers) {
+ removed = (mapMembers.remove(member) != null);
+ if (!removed) {
+ if (log.isDebugEnabled())
+ log.debug("Member[" + member + "] disappeared, but was not present in the map.");
+ return; //the member was not part of our map.
+ }
+ }
+
+ Iterator<Map.Entry<Object, Object>> i = super.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ MapEntry entry = (MapEntry)super.get(e.getKey());
+ if (entry == null)
+ continue;
+ if (entry.isPrimary() && inSet(member, entry.getBackupNodes())) {
+ if (log.isDebugEnabled())
+ log.debug("[1] Primary choosing a new backup");
+ try {
+ Member[] backup = publishEntryInfo(entry.getKey(), entry.getValue());
+ entry.setBackupNodes(backup);
+ entry.setPrimary(channel.getLocalMember(false));
+ } catch (ChannelException x) {
+ log.error("Unable to relocate[" + entry.getKey() + "] to a new backup node", x);
+ }
+ } else if (member.equals(entry.getPrimary())) {
+ if (log.isDebugEnabled())
+ log.debug("[2] Primary disappeared");
+ entry.setPrimary(null);
+ } //end if
+
+ if (entry.isProxy() && entry.getPrimary() == null
+ && entry.getBackupNodes() != null
+ && entry.getBackupNodes().length == 1
+ && entry.getBackupNodes()[0].equals(member)) {
+ //remove proxies that have no backup nor primaries
+ if (log.isDebugEnabled())
+ log.debug("[3] Removing orphaned proxy");
+ i.remove();
+ } else if (entry.getPrimary() == null && entry.isBackup()
+ && entry.getBackupNodes() != null
+ && entry.getBackupNodes().length == 1
+ && entry.getBackupNodes()[0].equals(channel.getLocalMember(false))) {
+ try {
+ if (log.isDebugEnabled())
+ log.debug("[4] Backup becoming primary");
+ entry.setPrimary(channel.getLocalMember(false));
+ entry.setBackup(false);
+ entry.setProxy(false);
+ Member[] backup = publishEntryInfo(entry.getKey(), entry.getValue());
+ entry.setBackupNodes(backup);
+ if (mapOwner != null)
+ mapOwner.objectMadePrimay(entry.getKey(), entry.getValue());
+
+ } catch (ChannelException x) {
+ log.error("Unable to relocate[" + entry.getKey() + "] to a new backup node", x);
+ }
+ }
+
+ } //while
+ }
+
+ public int getNextBackupIndex() {
+ int size = mapMembers.size();
+ if (mapMembers.size() == 0)
+ return -1;
+ int node = currentNode++;
+ if (node >= size) {
+ node = 0;
+ currentNode = 0;
+ }
+ return node;
+ }
+
+ public Member getNextBackupNode() {
+ Member[] members = getMapMembers();
+ int node = getNextBackupIndex();
+ if (members.length == 0 || node == -1)
+ return null;
+ if (node >= members.length)
+ node = 0;
+ return members[node];
+ }
+
+ protected abstract Member[] publishEntryInfo(Object key, Object value) throws ChannelException;
+
+ public void heartbeat() {
+ try {
+ ping(accessTimeout);
+ } catch (Exception x) {
+ log.error("Unable to send AbstractReplicatedMap.ping message", x);
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ // METHODS TO OVERRIDE
+ //------------------------------------------------------------------------------
+
+ /**
+ * Removes an object from this map, it will also remove it from
+ *
+ * @param key Object
+ * @return Object
+ */
+ public Object remove(Object key) {
+ return remove(key, true);
+ }
+
+ public Object remove(Object key, boolean notify) {
+ MapEntry entry = (MapEntry)super.remove(key);
+
+ try {
+ if (getMapMembers().length > 0 && notify) {
+ MapMessage msg =
+ new MapMessage(getMapContextName(), MapMessage.MSG_REMOVE, false, (Serializable)key, null, null,
+ null, null);
+ getChannel().send(getMapMembers(), msg, getChannelSendOptions());
+ }
+ } catch (ChannelException x) {
+ log.error("Unable to replicate out data for a LazyReplicatedMap.remove operation", x);
+ }
+ return entry != null ? entry.getValue() : null;
+ }
+
+ public MapEntry getInternal(Object key) {
+ return (MapEntry)super.get(key);
+ }
+
+ public Object get(Object key) {
+ MapEntry entry = (MapEntry)super.get(key);
+ if (log.isTraceEnabled())
+ log.trace("Requesting id:" + key + " entry:" + entry);
+ if (entry == null)
+ return null;
+ if (!entry.isPrimary()) {
+ //if the message is not primary, we need to retrieve the latest value
+ try {
+ Member[] backup = null;
+ MapMessage msg = null;
+ if (!entry.isBackup()) {
+ //make sure we don't retrieve from ourselves
+ msg =
+ new MapMessage(getMapContextName(), MapMessage.MSG_RETRIEVE_BACKUP, false, (Serializable)key,
+ null, null, null, null);
+ Response[] resp =
+ getRpcChannel().send(entry.getBackupNodes(),
+ msg,
+ RpcChannel.FIRST_REPLY,
+ Channel.SEND_OPTIONS_DEFAULT,
+ getRpcTimeout());
+ if (resp == null || resp.length == 0) {
+ //no responses
+ log.warn("Unable to retrieve remote object for key:" + key);
+ return null;
+ }
+ msg = (MapMessage)resp[0].getMessage();
+ msg.deserialize(getExternalLoaders());
+ backup = entry.getBackupNodes();
+ if (entry.getValue() instanceof ReplicatedMapEntry) {
+ ReplicatedMapEntry val = (ReplicatedMapEntry)entry.getValue();
+ val.setOwner(getMapOwner());
+ }
+ if (msg.getValue() != null)
+ entry.setValue(msg.getValue());
+ }
+ if (entry.isBackup()) {
+ //select a new backup node
+ backup = publishEntryInfo(key, entry.getValue());
+ } else if (entry.isProxy()) {
+ //invalidate the previous primary
+ msg =
+ new MapMessage(getMapContextName(), MapMessage.MSG_PROXY, false, (Serializable)key, null, null,
+ channel.getLocalMember(false), backup);
+ Member[] dest = getMapMembersExcl(backup);
+ if (dest != null && dest.length > 0) {
+ getChannel().send(dest, msg, getChannelSendOptions());
+ }
+ }
+ entry.setPrimary(channel.getLocalMember(false));
+ entry.setBackupNodes(backup);
+ entry.setBackup(false);
+ entry.setProxy(false);
+
+ } catch (Exception x) {
+ log.error("Unable to replicate out data for a LazyReplicatedMap.get operation", x);
+ return null;
+ }
+ }
+ if (log.isTraceEnabled())
+ log.trace("Requesting id:" + key + " result:" + entry.getValue());
+ if (entry.getValue() != null && entry.getValue() instanceof ReplicatedMapEntry) {
+ ReplicatedMapEntry val = (ReplicatedMapEntry)entry.getValue();
+ //hack, somehow this is not being set above
+ val.setOwner(getMapOwner());
+
+ }
+ return entry.getValue();
+ }
+
+ protected void printMap(String header) {
+ try {
+ System.out.println("\nDEBUG MAP:" + header);
+ System.out.println("Map[" + new String(mapContextName, chset) + ", Map Size:" + super.size());
+ Member[] mbrs = getMapMembers();
+ for (int i = 0; i < mbrs.length; i++) {
+ System.out.println("Mbr[" + (i + 1) + "=" + mbrs[i].getName());
+ }
+ Iterator i = super.entrySet().iterator();
+ int cnt = 0;
+
+ while (i.hasNext()) {
+ Map.Entry e = (Map.Entry)i.next();
+ System.out.println((++cnt) + ". " + super.get(e.getKey()));
+ }
+ System.out.println("EndMap]\n\n");
+ } catch (Exception ignore) {
+ ignore.printStackTrace();
+ }
+ }
+
+ /**
+ * Returns true if the key has an entry in the map.
+ * The entry can be a proxy or a backup entry, invoking <code>get(key)</code>
+ * will make this entry primary for the group
+ * @param key Object
+ * @return boolean
+ */
+ public boolean containsKey(Object key) {
+ return super.containsKey(key);
+ }
+
+ public Object put(Object key, Object value) {
+ return put(key, value, true);
+ }
+
+ public Object put(Object key, Object value, boolean notify) {
+ MapEntry entry = new MapEntry(key, value);
+ entry.setBackup(false);
+ entry.setProxy(false);
+ entry.setPrimary(channel.getLocalMember(false));
+
+ Object old = null;
+
+ //make sure that any old values get removed
+ if (containsKey(key))
+ old = remove(key);
+ try {
+ if (notify) {
+ Member[] backup = publishEntryInfo(key, value);
+ entry.setBackupNodes(backup);
+ }
+ } catch (ChannelException x) {
+ log.error("Unable to replicate out data for a LazyReplicatedMap.put operation", x);
+ }
+ super.put(key, entry);
+ return old;
+ }
+
+ /**
+ * Copies all values from one map to this instance
+ * @param m Map
+ */
+ public void putAll(Map m) {
+ Iterator i = m.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry)i.next();
+ put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ public void clear() {
+ clear(true);
+ }
+
+ public void clear(boolean notify) {
+ if (notify) {
+ //only delete active keys
+ Iterator<Object> keys = keySet().iterator();
+ while (keys.hasNext())
+ remove(keys.next());
+ } else {
+ super.clear();
+ }
+ }
+
+ public boolean containsValue(Object value) {
+ if (value == null) {
+ return super.containsValue(value);
+ } else {
+ Iterator<Map.Entry<Object, Object>> i = super.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ MapEntry entry = (MapEntry)super.get(e.getKey());
+ if (entry != null && entry.isPrimary() && value.equals(entry.getValue()))
+ return true;
+ }//while
+ return false;
+ }//end if
+ }
+
+ public Object clone() {
+ throw new UnsupportedOperationException("This operation is not valid on a replicated map");
+ }
+
+ /**
+ * Returns the entire contents of the map
+ * Map.Entry.getValue() will return a LazyReplicatedMap.MapEntry object containing all the information
+ * about the object.
+ * @return Set
+ */
+ public Set<Map.Entry<Object, Object>> entrySetFull() {
+ return super.entrySet();
+ }
+
+ public Set<Object> keySetFull() {
+ return super.keySet();
+ }
+
+ public int sizeFull() {
+ return super.size();
+ }
+
+ public Set<Map.Entry<Object, Object>> entrySet() {
+ Set<Map.Entry<Object, Object>> set = new LinkedHashSet<Map.Entry<Object, Object>>(super.size());
+ Iterator<Map.Entry<Object, Object>> i = super.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ Object key = e.getKey();
+ MapEntry entry = (MapEntry)super.get(key);
+ if (entry != null && entry.isPrimary()) {
+ set.add(new MapEntry(key, entry.getValue()));
+ }
+ }
+ return Collections.unmodifiableSet(set);
+ }
+
+ public Set<Object> keySet() {
+ //todo implement
+ //should only return keys where this is active.
+ LinkedHashSet<Object> set = new LinkedHashSet<Object>(super.size());
+ Iterator<Map.Entry<Object, Object>> i = super.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ Object key = e.getKey();
+ MapEntry entry = (MapEntry)super.get(key);
+ if (entry != null && entry.isPrimary())
+ set.add(key);
+ }
+ return Collections.unmodifiableSet(set);
+
+ }
+
+ public int size() {
+ //todo, implement a counter variable instead
+ //only count active members in this node
+ int counter = 0;
+ Iterator<Map.Entry<Object, Object>> it = super.entrySet().iterator();
+ while (it != null && it.hasNext()) {
+ Map.Entry<Object, Object> e = it.next();
+ if (e != null) {
+ MapEntry entry = (MapEntry)super.get(e.getKey());
+ if (entry != null && entry.isPrimary() && entry.getValue() != null)
+ counter++;
+ }
+ }
+ return counter;
+ }
+
+ protected boolean removeEldestEntry(Map.Entry<Object, Object> eldest) {
+ return false;
+ }
+
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ public Collection<Object> values() {
+ ArrayList<Object> values = new ArrayList<Object>();
+ Iterator<Map.Entry<Object, Object>> i = super.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ MapEntry entry = (MapEntry)super.get(e.getKey());
+ if (entry != null && entry.isPrimary() && entry.getValue() != null)
+ values.add(entry.getValue());
+ }
+ return Collections.unmodifiableCollection(values);
+ }
+
+ //------------------------------------------------------------------------------
+ // Map Entry class
+ //------------------------------------------------------------------------------
+ public static class MapEntry implements Map.Entry<Object, Object> {
+ private boolean backup;
+ private boolean proxy;
+ private Member[] backupNodes;
+ private Member primary;
+ private Object key;
+ private Object value;
+
+ public MapEntry(Object key, Object value) {
+ setKey(key);
+ setValue(value);
+
+ }
+
+ public boolean isKeySerializable() {
+ return (key == null) || (key instanceof Serializable);
+ }
+
+ public boolean isValueSerializable() {
+ return (value == null) || (value instanceof Serializable);
+ }
+
+ public boolean isSerializable() {
+ return isKeySerializable() && isValueSerializable();
+ }
+
+ public boolean isBackup() {
+ return backup;
+ }
+
+ public void setBackup(boolean backup) {
+ this.backup = backup;
+ }
+
+ public boolean isProxy() {
+ return proxy;
+ }
+
+ public boolean isPrimary() {
+ return ((!proxy) && (!backup));
+ }
+
+ public void setProxy(boolean proxy) {
+ this.proxy = proxy;
+ }
+
+ public boolean isDiffable() {
+ return (value instanceof ReplicatedMapEntry) && ((ReplicatedMapEntry)value).isDiffable();
+ }
+
+ public void setBackupNodes(Member[] nodes) {
+ this.backupNodes = nodes;
+ }
+
+ public Member[] getBackupNodes() {
+ return backupNodes;
+ }
+
+ public void setPrimary(Member m) {
+ primary = m;
+ }
+
+ public Member getPrimary() {
+ return primary;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object setValue(Object value) {
+ Object old = this.value;
+ this.value = value;
+ return old;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public Object setKey(Object key) {
+ Object old = this.key;
+ this.key = key;
+ return old;
+ }
+
+ public int hashCode() {
+ return key.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ return key.equals(o);
+ }
+
+ /**
+ * apply a diff, or an entire object
+ * @param data byte[]
+ * @param offset int
+ * @param length int
+ * @param diff boolean
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ public void apply(byte[] data, int offset, int length, boolean diff) throws IOException, ClassNotFoundException {
+ if (isDiffable() && diff) {
+ ReplicatedMapEntry rentry = (ReplicatedMapEntry)value;
+ try {
+ rentry.lock();
+ rentry.applyDiff(data, offset, length);
+ } finally {
+ rentry.unlock();
+ }
+ } else if (length == 0) {
+ value = null;
+ proxy = true;
+ } else {
+ value = XByteBuffer.deserialize(data, offset, length);
+ }
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("MapEntry[key:");
+ buf.append(getKey()).append("; ");
+ buf.append("value:").append(getValue()).append("; ");
+ buf.append("primary:").append(isPrimary()).append("; ");
+ buf.append("backup:").append(isBackup()).append("; ");
+ buf.append("proxy:").append(isProxy()).append(";]");
+ return buf.toString();
+ }
+
+ }
+
+ //------------------------------------------------------------------------------
+ // map message to send to and from other maps
+ //------------------------------------------------------------------------------
+
+ public static class MapMessage implements Serializable {
+ private static final long serialVersionUID = -7847288807489375686L;
+ public static final int MSG_BACKUP = 1;
+ public static final int MSG_RETRIEVE_BACKUP = 2;
+ public static final int MSG_PROXY = 3;
+ public static final int MSG_REMOVE = 4;
+ public static final int MSG_STATE = 5;
+ public static final int MSG_START = 6;
+ public static final int MSG_STOP = 7;
+ public static final int MSG_INIT = 8;
+ public static final int MSG_COPY = 9;
+ public static final int MSG_STATE_COPY = 10;
+
+ private byte[] mapId;
+ private int msgtype;
+ private boolean diff;
+ private transient Serializable key;
+ private transient Serializable value;
+ private byte[] valuedata;
+ private byte[] keydata;
+ private byte[] diffvalue;
+ private Member[] nodes;
+ private Member primary;
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("MapMessage[context=");
+ buf.append(new String(mapId));
+ buf.append("; type=");
+ buf.append(getTypeDesc());
+ buf.append("; key=");
+ buf.append(key);
+ buf.append("; value=");
+ buf.append(value);
+ return buf.toString();
+ }
+
+ public String getTypeDesc() {
+ switch (msgtype) {
+ case MSG_BACKUP:
+ return "MSG_BACKUP";
+ case MSG_RETRIEVE_BACKUP:
+ return "MSG_RETRIEVE_BACKUP";
+ case MSG_PROXY:
+ return "MSG_PROXY";
+ case MSG_REMOVE:
+ return "MSG_REMOVE";
+ case MSG_STATE:
+ return "MSG_STATE";
+ case MSG_START:
+ return "MSG_START";
+ case MSG_STOP:
+ return "MSG_STOP";
+ case MSG_INIT:
+ return "MSG_INIT";
+ case MSG_STATE_COPY:
+ return "MSG_STATE_COPY";
+ case MSG_COPY:
+ return "MSG_COPY";
+ default:
+ return "UNKNOWN";
+ }
+ }
+
+ public MapMessage() {
+ }
+
+ public MapMessage(byte[] mapId,
+ int msgtype,
+ boolean diff,
+ Serializable key,
+ Serializable value,
+ byte[] diffvalue,
+ Member primary,
+ Member[] nodes) {
+ this.mapId = mapId;
+ this.msgtype = msgtype;
+ this.diff = diff;
+ this.key = key;
+ this.value = value;
+ this.diffvalue = diffvalue;
+ this.nodes = nodes;
+ this.primary = primary;
+ setValue(value);
+ setKey(key);
+ }
+
+ public void deserialize(ClassLoader[] cls) throws IOException, ClassNotFoundException {
+ key(cls);
+ value(cls);
+ }
+
+ public int getMsgType() {
+ return msgtype;
+ }
+
+ public boolean isDiff() {
+ return diff;
+ }
+
+ public Serializable getKey() {
+ try {
+ return key(null);
+ } catch (Exception x) {
+ log.error("Deserialization error of the MapMessage.key", x);
+ return null;
+ }
+ }
+
+ public Serializable key(ClassLoader[] cls) throws IOException, ClassNotFoundException {
+ if (key != null)
+ return key;
+ if (keydata == null || keydata.length == 0)
+ return null;
+ key = XByteBuffer.deserialize(keydata, 0, keydata.length, cls);
+ keydata = null;
+ return key;
+ }
+
+ public byte[] getKeyData() {
+ return keydata;
+ }
+
+ public Serializable getValue() {
+ try {
+ return value(null);
+ } catch (Exception x) {
+ log.error("Deserialization error of the MapMessage.value", x);
+ return null;
+ }
+ }
+
+ public Serializable value(ClassLoader[] cls) throws IOException, ClassNotFoundException {
+ if (value != null)
+ return value;
+ if (valuedata == null || valuedata.length == 0)
+ return null;
+ value = XByteBuffer.deserialize(valuedata, 0, valuedata.length, cls);
+ valuedata = null;
+ ;
+ return value;
+ }
+
+ public byte[] getValueData() {
+ return valuedata;
+ }
+
+ public byte[] getDiffValue() {
+ return diffvalue;
+ }
+
+ public Member[] getBackupNodes() {
+ return nodes;
+ }
+
+ private void setBackUpNodes(Member[] nodes) {
+ this.nodes = nodes;
+ }
+
+ public Member getPrimary() {
+ return primary;
+ }
+
+ private void setPrimary(Member m) {
+ primary = m;
+ }
+
+ public byte[] getMapId() {
+ return mapId;
+ }
+
+ public void setValue(Serializable value) {
+ try {
+ if (value != null)
+ valuedata = XByteBuffer.serialize(value);
+ this.value = value;
+ } catch (IOException x) {
+ throw new RuntimeException(x);
+ }
+ }
+
+ public void setKey(Serializable key) {
+ try {
+ if (key != null)
+ keydata = XByteBuffer.serialize(key);
+ this.key = key;
+ } catch (IOException x) {
+ throw new RuntimeException(x);
+ }
+ }
+
+ protected Member[] readMembers(ObjectInput in) throws IOException, ClassNotFoundException {
+ int nodecount = in.readInt();
+ Member[] members = new Member[nodecount];
+ for (int i = 0; i < members.length; i++) {
+ byte[] d = new byte[in.readInt()];
+ in.read(d);
+ if (d.length > 0)
+ members[i] = MemberImpl.getMember(d);
+ }
+ return members;
+ }
+
+ protected void writeMembers(ObjectOutput out, Member[] members) throws IOException {
+ if (members == null)
+ members = new Member[0];
+ out.writeInt(members.length);
+ for (int i = 0; i < members.length; i++) {
+ if (members[i] != null) {
+ byte[] d = members[i] != null ? ((MemberImpl)members[i]).getData(false) : new byte[0];
+ out.writeInt(d.length);
+ out.write(d);
+ }
+ }
+ }
+
+ /**
+ * shallow clone
+ * @return Object
+ */
+ public Object clone() {
+ MapMessage msg =
+ new MapMessage(this.mapId, this.msgtype, this.diff, this.key, this.value, this.diffvalue, this.primary,
+ this.nodes);
+ msg.keydata = this.keydata;
+ msg.valuedata = this.valuedata;
+ return msg;
+ }
+ } //MapMessage
+
+ public Channel getChannel() {
+ return channel;
+ }
+
+ public byte[] getMapContextName() {
+ return mapContextName;
+ }
+
+ public RpcChannel getRpcChannel() {
+ return rpcChannel;
+ }
+
+ public long getRpcTimeout() {
+ return rpcTimeout;
+ }
+
+ public Object getStateMutex() {
+ return stateMutex;
+ }
+
+ public boolean isStateTransferred() {
+ return stateTransferred;
+ }
+
+ public MapOwner getMapOwner() {
+ return mapOwner;
+ }
+
+ public ClassLoader[] getExternalLoaders() {
+ return externalLoaders;
+ }
+
+ public int getChannelSendOptions() {
+ return channelSendOptions;
+ }
+
+ public long getAccessTimeout() {
+ return accessTimeout;
+ }
+
+ public void setMapOwner(MapOwner mapOwner) {
+ this.mapOwner = mapOwner;
+ }
+
+ public void setExternalLoaders(ClassLoader[] externalLoaders) {
+ this.externalLoaders = externalLoaders;
+ }
+
+ public void setChannelSendOptions(int channelSendOptions) {
+ this.channelSendOptions = channelSendOptions;
+ }
+
+ public void setAccessTimeout(long accessTimeout) {
+ this.accessTimeout = accessTimeout;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.java b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.java
new file mode 100644
index 0000000000..1e4d3af50d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/DisableMcastInterceptor.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.endpoint.tribes;
+
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.group.ChannelInterceptorBase;
+
+/**
+ * A static interceptor to disables multicast.
+ * Can be removed when/if the function gets added to Tribes.
+ * See Tomcat email http://markmail.org/message/doqu7pfl2hvvdfcl
+ */
+public class DisableMcastInterceptor extends ChannelInterceptorBase {
+
+ public DisableMcastInterceptor() {
+ super();
+ }
+
+ public void start(int svc) throws ChannelException {
+ svc = (svc & (~Channel.MBR_TX_SEQ));
+ super.start(svc);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/MapStore.java b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/MapStore.java
new file mode 100644
index 0000000000..9e540743bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/MapStore.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.endpoint.tribes;
+
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * The Map that can fire events on put/remove of entries
+ */
+public abstract class MapStore extends ConcurrentHashMap<Object, Object> {
+ private static final long serialVersionUID = -2127235547082144368L;
+ private List<MapListener> listeners = new CopyOnWriteArrayList<MapListener>();
+
+ protected MapStore(int initialCapacity, float loadFactor, int concurrencyLevel) {
+ super(initialCapacity, loadFactor, concurrencyLevel);
+ }
+
+ @Override
+ public Object put(Object key, Object value) {
+ Object old = super.put(key, value);
+ if (old != null) {
+ for (MapListener listener : listeners) {
+ listener.entryUpdated(key, old, value);
+ }
+ } else {
+ for (MapListener listener : listeners) {
+ listener.entryAdded(key, value);
+ }
+
+ }
+ return old;
+ }
+
+ @Override
+ public Object remove(Object key) {
+ Object old = super.remove(key);
+ if (old != null) {
+ for (MapListener listener : listeners) {
+ listener.entryRemoved(key, old);
+ }
+ }
+ return old;
+ }
+
+ public void addListener(MapListener listener) {
+ listeners.add(listener);
+ }
+
+ public List<MapListener> getListeners() {
+ return listeners;
+ }
+
+ public boolean removeListener(MapListener listener) {
+ return listeners.remove(listener);
+ }
+
+ public static interface MapListener {
+ void entryAdded(Object key, Object value);
+
+ void entryUpdated(Object key, Object oldValue, Object newValue);
+
+ void entryRemoved(Object key, Object value);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
new file mode 100644
index 0000000000..5dc627d88d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
@@ -0,0 +1,420 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.tribes;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.URI;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.ChannelReceiver;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.group.GroupChannel;
+import org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor;
+import org.apache.catalina.tribes.membership.McastService;
+import org.apache.catalina.tribes.membership.StaticMember;
+import org.apache.catalina.tribes.transport.ReceiverBase;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.endpoint.tribes.AbstractReplicatedMap.MapEntry;
+import org.apache.tuscany.sca.endpoint.tribes.MapStore.MapListener;
+import org.apache.tuscany.sca.runtime.BaseEndpointRegistry;
+import org.apache.tuscany.sca.runtime.DomainRegistryURI;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * A replicated EndpointRegistry based on Apache Tomcat Tribes
+ */
+public class ReplicatedEndpointRegistry extends BaseEndpointRegistry implements EndpointRegistry, LifeCycleListener,
+ MapListener {
+ private final static Logger logger = Logger.getLogger(ReplicatedEndpointRegistry.class.getName());
+ private static final String MULTICAST_ADDRESS = "228.0.0.100";
+ private static final int MULTICAST_PORT = 50000;
+
+ private static final int FIND_REPEAT_COUNT = 10;
+
+ private int port = MULTICAST_PORT;
+ private String address = MULTICAST_ADDRESS;
+ private String bind = null;
+ private int timeout = 50;
+ private String receiverAddress;
+ private int receiverPort = 4000;
+ private int receiverAutoBind = 100;
+ private List<URI> staticRoutes;
+
+ private ReplicatedMap map;
+
+ private String id;
+ private boolean noMultiCast;
+
+ private static final GroupChannel createChannel(String address, int port, String bindAddress) {
+
+ //create a channel
+ GroupChannel channel = new GroupChannel();
+ McastService mcastService = (McastService)channel.getMembershipService();
+ mcastService.setPort(port);
+ mcastService.setAddress(address);
+
+ // REVIEW: In my case, there are multiple IP addresses
+ // One for the WIFI and the other one for VPN. For some reason the VPN one doesn't support
+ // Multicast
+
+ if (bindAddress != null) {
+ mcastService.setBind(bindAddress);
+ } else {
+ mcastService.setBind(getBindAddress());
+ }
+
+ return channel;
+ }
+
+ public ReplicatedEndpointRegistry(ExtensionPointRegistry registry,
+ Map<String, String> attributes,
+ String domainRegistryURI,
+ String domainURI) {
+ super(registry, attributes, domainRegistryURI, domainURI);
+ getParameters(attributes, domainRegistryURI);
+ }
+
+ private Map<String, String> getParameters(Map<String, String> attributes, String domainRegistryURI) {
+ Map<String, String> map = new HashMap<String, String>();
+ if (attributes != null) {
+ map.putAll(attributes);
+ }
+ URI uri = URI.create(domainRegistryURI);
+ if (uri.getHost() != null) {
+ map.put("address", uri.getHost());
+ }
+ if (uri.getPort() != -1) {
+ map.put("port", String.valueOf(uri.getPort()));
+ }
+
+ if (domainRegistryURI.startsWith("tuscany")) {
+ setTuscanyConfig(map, domainRegistryURI);
+ setConfig(map);
+ return map;
+ }
+
+ int index = domainRegistryURI.indexOf('?');
+ if (index == -1) {
+ setConfig(map);
+ return map;
+ }
+ String query = domainRegistryURI.substring(index + 1);
+ try {
+ query = URLDecoder.decode(query, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException(e);
+ }
+ String[] params = query.split("&");
+ for (String param : params) {
+ index = param.indexOf('=');
+ if (index != -1) {
+ map.put(param.substring(0, index), param.substring(index + 1));
+ }
+ }
+ setConfig(map);
+ return map;
+ }
+
+ private void setTuscanyConfig(Map<String, String> map, String domainRegistryURI) {
+ DomainRegistryURI tuscanyURI = new DomainRegistryURI(domainRegistryURI);
+ map.put("address", tuscanyURI.getMulticastAddress());
+ map.put("port", Integer.toString(tuscanyURI.getMulticastPort()));
+ map.put("bind", tuscanyURI.getBindAddress());
+ map.put("receiverPort", Integer.toString(tuscanyURI.getListenPort()));
+ if (tuscanyURI.isMulticastDisabled()) {
+ map.put("nomcast", "true");
+ }
+ if (tuscanyURI.getRemotes().size() > 0) {
+ String routes = "";
+ for (int i=0; i<tuscanyURI.getRemotes().size(); i++) {
+ routes += tuscanyURI.getRemotes().get(i);
+ if (i < tuscanyURI.getRemotes().size()) {
+ routes += ",";
+ }
+ }
+ map.put("routes", routes);
+ }
+ }
+
+ private void setConfig(Map<String, String> attributes) {
+ String portStr = attributes.get("port");
+ if (portStr != null) {
+ port = Integer.parseInt(portStr);
+ if (port == -1) {
+ port = MULTICAST_PORT;
+ }
+ }
+ String address = attributes.get("address");
+ if (address == null) {
+ address = MULTICAST_ADDRESS;
+ }
+ bind = attributes.get("bind");
+ String timeoutStr = attributes.get("timeout");
+ if (timeoutStr != null) {
+ timeout = Integer.parseInt(timeoutStr);
+ }
+
+ String routesStr = attributes.get("routes");
+ if (routesStr != null) {
+ StringTokenizer st = new StringTokenizer(routesStr);
+ staticRoutes = new ArrayList<URI>();
+ while (st.hasMoreElements()) {
+ staticRoutes.add(URI.create("tcp://" + st.nextToken()));
+ }
+ }
+ String mcast = attributes.get("nomcast");
+ if (mcast != null) {
+ noMultiCast = Boolean.valueOf(mcast);
+ }
+ receiverAddress = attributes.get("receiverAddress");
+ String recvPort = attributes.get("receiverPort");
+ if (recvPort != null) {
+ receiverPort = Integer.parseInt(recvPort);
+ }
+ String recvAutoBind = attributes.get("receiverAutoBind");
+ if (recvAutoBind != null) {
+ receiverAutoBind = Integer.parseInt(recvAutoBind);
+ }
+ }
+
+ public void start() {
+ if (map != null) {
+ throw new IllegalStateException("The registry has already been started");
+ }
+ GroupChannel channel = createChannel(address, port, bind);
+ map =
+ new ReplicatedMap(null, channel, timeout, this.domainURI,
+ new ClassLoader[] {ReplicatedEndpointRegistry.class.getClassLoader()});
+ map.addListener(this);
+
+ if (noMultiCast) {
+ map.getChannel().addInterceptor(new DisableMcastInterceptor());
+ }
+
+ // Configure the receiver ports
+ ChannelReceiver receiver = channel.getChannelReceiver();
+ if (receiver instanceof ReceiverBase) {
+ if (receiverAddress != null) {
+ ((ReceiverBase)receiver).setAddress(receiverAddress);
+ }
+ ((ReceiverBase)receiver).setPort(receiverPort);
+ ((ReceiverBase)receiver).setAutoBind(receiverAutoBind);
+ }
+
+ /*
+ Object sender = channel.getChannelSender();
+ if (sender instanceof ReplicationTransmitter) {
+ sender = ((ReplicationTransmitter)sender).getTransport();
+ }
+ if (sender instanceof AbstractSender) {
+ ((AbstractSender)sender).setKeepAliveCount(0);
+ ((AbstractSender)sender).setMaxRetryAttempts(5);
+ }
+ */
+
+ if (staticRoutes != null) {
+ StaticMembershipInterceptor smi = new StaticMembershipInterceptor();
+ for (URI staticRoute : staticRoutes) {
+ Member member;
+ try {
+ // The port has to match the receiver port
+ member = new StaticMember(staticRoute.getHost(), staticRoute.getPort(), 5000);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ smi.addStaticMember(member);
+ logger.info("Added static route: " + staticRoute.getHost() + ":" + staticRoute.getPort());
+ }
+ smi.setLocalMember(map.getChannel().getLocalMember(false));
+ map.getChannel().addInterceptor(smi);
+ }
+
+ try {
+ map.getChannel().start(Channel.DEFAULT);
+ } catch (ChannelException e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ public void stop() {
+ if (map != null) {
+ map.removeListener(this);
+ Channel channel = map.getChannel();
+ map.breakdown();
+ try {
+ channel.stop(Channel.DEFAULT);
+ } catch (ChannelException e) {
+ logger.log(Level.WARNING, e.getMessage(), e);
+ }
+ map = null;
+ }
+ }
+
+ public void addEndpoint(Endpoint endpoint) {
+ map.put(endpoint.getURI(), endpoint);
+ logger.info("Add endpoint - " + endpoint);
+ }
+
+ public List<Endpoint> findEndpoint(String uri) {
+ List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
+
+ // in the failure case we repeat the look up after a short
+ // delay to take account of tribes replication delays
+ int repeat = FIND_REPEAT_COUNT;
+
+ while (repeat > 0) {
+ for (Object v : map.values()) {
+ Endpoint endpoint = (Endpoint)v;
+ // TODO: implement more complete matching
+ logger.fine("Matching against - " + endpoint);
+ if (endpoint.matches(uri)) {
+ MapEntry entry = map.getInternal(endpoint.getURI());
+ // if (!entry.isPrimary()) {
+ ((RuntimeEndpoint)endpoint).bind(registry, this);
+ // }
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
+ repeat = 0;
+ }
+ // else the service name doesn't match
+ }
+
+ if (foundEndpoints.size() == 0) {
+ // the service name doesn't match any endpoints so wait a little and try
+ // again in case this is caused by tribes synch delays
+ logger.info("Repeating endpoint reference match - " + uri);
+ repeat--;
+ try {
+ Thread.sleep(1000);
+ } catch (Exception ex) {
+ // do nothing
+ repeat = 0;
+ }
+ }
+ }
+
+ return foundEndpoints;
+ }
+
+ private boolean isLocal(MapEntry entry) {
+ return entry.getPrimary().equals(map.getChannel().getLocalMember(false));
+ }
+
+ public Endpoint getEndpoint(String uri) {
+ return (Endpoint)map.get(uri);
+ }
+
+ public List<Endpoint> getEndpoints() {
+ return new ArrayList(map.values());
+ }
+
+ public void removeEndpoint(Endpoint endpoint) {
+ map.remove(endpoint.getURI());
+ logger.info("Remove endpoint - " + endpoint);
+ }
+
+ public void replicate(boolean complete) {
+ map.replicate(complete);
+ }
+
+ public void updateEndpoint(String uri, Endpoint endpoint) {
+ Endpoint oldEndpoint = getEndpoint(uri);
+ if (oldEndpoint == null) {
+ throw new IllegalArgumentException("Endpoint is not found: " + uri);
+ }
+ map.put(endpoint.getURI(), endpoint);
+ }
+
+ public void entryAdded(Object key, Object value) {
+ MapEntry entry = (MapEntry)value;
+ Endpoint newEp = (Endpoint)entry.getValue();
+ if (!isLocal(entry)) {
+ logger.info(id + " Remote endpoint added: " + entry.getValue());
+ }
+ endpointAdded(newEp);
+ }
+
+ public void entryRemoved(Object key, Object value) {
+ MapEntry entry = (MapEntry)value;
+ if (!isLocal(entry)) {
+ logger.info(id + " Remote endpoint removed: " + entry.getValue());
+ }
+ endpointRemoved((Endpoint)entry.getValue());
+ }
+
+ public void entryUpdated(Object key, Object oldValue, Object newValue) {
+ MapEntry oldEntry = (MapEntry)oldValue;
+ MapEntry newEntry = (MapEntry)newValue;
+ if (!isLocal(newEntry)) {
+ logger.info(id + " Remote endpoint updated: " + newEntry.getValue());
+ }
+ Endpoint oldEp = (Endpoint)oldEntry.getValue();
+ Endpoint newEp = (Endpoint)newEntry.getValue();
+ endpointUpdated(oldEp, newEp);
+ }
+
+ private static String getBindAddress() {
+ try {
+ Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
+ while (nis.hasMoreElements()) {
+ NetworkInterface ni = nis.nextElement();
+ // The following APIs require JDK 1.6
+ /*
+ if (ni.isLoopback() || !ni.isUp() || !ni.supportsMulticast()) {
+ continue;
+ }
+ */
+ Enumeration<InetAddress> ips = ni.getInetAddresses();
+ if (!ips.hasMoreElements()) {
+ continue;
+ }
+ while (ips.hasMoreElements()) {
+ InetAddress addr = ips.nextElement();
+ if (addr.isLoopbackAddress()) {
+ continue;
+ }
+ return addr.getHostAddress();
+ }
+ }
+ return InetAddress.getLocalHost().getHostAddress();
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ return null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.java b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.java
new file mode 100644
index 0000000000..669ad82192
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.endpoint.tribes;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.ChannelListener;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.MembershipListener;
+import org.apache.catalina.tribes.group.RpcCallback;
+
+/**
+ * This file is copied from:
+ * https://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_20/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
+ *
+ */
+public class ReplicatedMap extends AbstractReplicatedMap implements RpcCallback, ChannelListener, MembershipListener {
+ private static final long serialVersionUID = -6318779627600581121L;
+ protected static org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory.getLog(ReplicatedMap.class);
+
+ //------------------------------------------------------------------------------
+ // CONSTRUCTORS / DESTRUCTORS
+ //------------------------------------------------------------------------------
+ /**
+ * Creates a new map
+ * @param channel The channel to use for communication
+ * @param timeout long - timeout for RPC messags
+ * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+ * @param initialCapacity int - the size of this map, see HashMap
+ * @param loadFactor float - load factor, see HashMap
+ */
+ public ReplicatedMap(MapOwner owner,
+ Channel channel,
+ long timeout,
+ String mapContextName,
+ int initialCapacity,
+ float loadFactor,
+ ClassLoader[] cls) {
+ super(owner, channel, timeout, mapContextName, initialCapacity, loadFactor, Channel.SEND_OPTIONS_DEFAULT, cls);
+ }
+
+ /**
+ * Creates a new map
+ * @param channel The channel to use for communication
+ * @param timeout long - timeout for RPC messags
+ * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+ * @param initialCapacity int - the size of this map, see HashMap
+ */
+ public ReplicatedMap(MapOwner owner,
+ Channel channel,
+ long timeout,
+ String mapContextName,
+ int initialCapacity,
+ ClassLoader[] cls) {
+ super(owner, channel, timeout, mapContextName, initialCapacity, AbstractReplicatedMap.DEFAULT_LOAD_FACTOR,
+ Channel.SEND_OPTIONS_DEFAULT, cls);
+ }
+
+ /**
+ * Creates a new map
+ * @param channel The channel to use for communication
+ * @param timeout long - timeout for RPC messags
+ * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+ */
+ public ReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls) {
+ super(owner, channel, timeout, mapContextName, AbstractReplicatedMap.DEFAULT_INITIAL_CAPACITY,
+ AbstractReplicatedMap.DEFAULT_LOAD_FACTOR, Channel.SEND_OPTIONS_DEFAULT, cls);
+ }
+
+ //------------------------------------------------------------------------------
+ // METHODS TO OVERRIDE
+ //------------------------------------------------------------------------------
+ protected int getStateMessageType() {
+ return AbstractReplicatedMap.MapMessage.MSG_STATE_COPY;
+ }
+
+ /**
+ * publish info about a map pair (key/value) to other nodes in the cluster
+ * @param key Object
+ * @param value Object
+ * @return Member - the backup node
+ * @throws ChannelException
+ */
+ protected Member[] publishEntryInfo(Object key, Object value) throws ChannelException {
+ if (!(key instanceof Serializable && value instanceof Serializable))
+ return new Member[0];
+ //select a backup node
+ Member[] members = getMapMembers();
+
+ if (members == null || members.length == 0) {
+ return new Member[0];
+ }
+
+ //publish the data out to all nodes
+ MapMessage msg =
+ new MapMessage(getMapContextName(), MapMessage.MSG_COPY, false, (Serializable)key, (Serializable)value,
+ null, channel.getLocalMember(false), members);
+
+ getChannel().send(members, msg, getChannelSendOptions());
+
+ return members;
+ }
+
+ /**
+ * Override the base method to look up existing entries only
+ */
+ public Object get(Object key) {
+ MapEntry entry = super.getInternal(key);
+ if (log.isTraceEnabled())
+ log.trace("Requesting id:" + key + " entry:" + entry);
+ if (entry == null) {
+ return null;
+ }
+ return entry.getValue();
+ }
+
+ /**
+ * Override the base method to remove all entries owned by the member that disappeared
+ */
+ public void memberDisappeared(Member member) {
+ boolean removed = false;
+ synchronized (mapMembers) {
+ removed = (mapMembers.remove(member) != null);
+ if (!removed) {
+ if (log.isDebugEnabled())
+ log.debug("Member[" + member + "] disappeared, but was not present in the map.");
+ return; //the member was not part of our map.
+ }
+ }
+
+ Iterator<Map.Entry<Object, Object>> i = super.entrySetFull().iterator();
+ while (i.hasNext()) {
+ Map.Entry<Object, Object> e = i.next();
+ MapEntry entry = (MapEntry)super.getInternal(e.getKey());
+ if (entry == null) {
+ continue;
+ }
+ if (member.equals(entry.getPrimary())) {
+ if (log.isDebugEnabled())
+ log.debug("[2] Primary disappeared");
+ i.remove();
+ } //end if
+ } //while
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/TribesDomainRegistryFactory.java b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/TribesDomainRegistryFactory.java
new file mode 100644
index 0000000000..91314b4c37
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/TribesDomainRegistryFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.tribes;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.runtime.BaseDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the
+ * given domain
+ */
+public class TribesDomainRegistryFactory extends BaseDomainRegistryFactory {
+ private final static String[] schemes = new String[] {"multicast", "tribes", "tuscany"};
+
+ /**
+ * @param extensionRegistry
+ */
+ public TribesDomainRegistryFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ protected EndpointRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI) {
+ EndpointRegistry endpointRegistry =
+ new ReplicatedEndpointRegistry(registry, null, endpointRegistryURI, domainURI);
+ return endpointRegistry;
+ }
+
+ public String[] getSupportedSchemes() {
+ return schemes;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
new file mode 100644
index 0000000000..734afb2ac5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.endpoint.tribes.TribesDomainRegistryFactory;ranking=50 \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java
new file mode 100644
index 0000000000..9c9b041aa2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/MultiRegTestCase.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.endpoint.tribes;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+// Ignore so its not run in the build yet till its working
+public class MultiRegTestCase implements EndpointListener {
+ private static ExtensionPointRegistry extensionPoints;
+ private static AssemblyFactory assemblyFactory;
+ private static SCABindingFactory scaBindingFactory;
+
+ @BeforeClass
+ public static void init() {
+ extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ scaBindingFactory = factories.getFactory(SCABindingFactory.class);
+ }
+
+ @Test
+ public void testReplication() throws Exception {
+ RuntimeEndpoint ep1 = createEndpoint("ep1uri");
+
+ // String host = InetAddress.getLocalHost().getHostAddress();
+ String bind = "127.0.0.1"; // "9.65.158.31";
+ String port1 = "8085";
+ String port2 = "8086";
+ String port3 = "8087";
+ String range = "1";
+
+ Map<String, String> attrs1 = new HashMap<String, String>();
+ // attrs1.put("nomcast", "true");
+ attrs1.put("bind", bind);
+ attrs1.put("receiverPort", port1);
+ attrs1.put("receiverAutoBind", range);
+ // attrs1.put("routes", host + ":" + port2 + " " + host + ":" + port3);
+ ReplicatedEndpointRegistry reg1 = new ReplicatedEndpointRegistry(extensionPoints, attrs1, "foo", "bar");
+ reg1.addListener(this);
+ reg1.start();
+
+ Map<String, String> attrs2 = new HashMap<String, String>();
+ // attrs2.put("nomcast", "true");
+ attrs2.put("bind", bind);
+ attrs2.put("receiverPort", port2);
+ attrs2.put("receiverAutoBind", range);
+ // attrs2.put("routes", host + ":"+port1);
+ ReplicatedEndpointRegistry reg2 = new ReplicatedEndpointRegistry(extensionPoints, attrs2, "foo", "bar");
+ reg2.addListener(this);
+ reg2.start();
+
+ Map<String, String> attrs3 = new HashMap<String, String>();
+ // attrs3.put("nomcast", "true");
+ attrs3.put("bind", bind);
+ attrs3.put("receiverPort", port3);
+ attrs3.put("receiverAutoBind", range);
+ // attrs3.put("routes", host + ":"+port1);
+ ReplicatedEndpointRegistry reg3 = new ReplicatedEndpointRegistry(extensionPoints, attrs3, "foo", "bar");
+ reg3.addListener(this);
+ reg3.start();
+
+ ep1.bind(extensionPoints, reg1);
+ reg1.addEndpoint(ep1);
+ assertExists(reg1, "ep1uri");
+ assertExists(reg2, "ep1uri");
+ assertExists(reg3, "ep1uri");
+
+ RuntimeEndpoint ep2 = createEndpoint("ep2uri");
+ ep2.bind(extensionPoints, reg2);
+ reg2.addEndpoint(ep2);
+ assertExists(reg2, "ep2uri");
+ assertExists(reg1, "ep2uri");
+ assertExists(reg3, "ep2uri");
+
+ reg1.stop();
+ Thread.sleep(6000);
+ Assert.assertNull(reg2.getEndpoint("ep1uri"));
+ Assert.assertNull(reg3.getEndpoint("ep1uri"));
+ assertExists(reg2, "ep2uri");
+ assertExists(reg3, "ep2uri");
+
+ reg1.start();
+ ep1.bind(extensionPoints, reg1);
+ reg1.addEndpoint(ep1);
+ assertExists(reg1, "ep1uri");
+ assertExists(reg2, "ep1uri");
+ assertExists(reg3, "ep1uri");
+
+ reg1.stop();
+ reg2.stop();
+ reg3.stop();
+ System.out.println(); // closed
+ }
+
+ private Endpoint assertExists(ReplicatedEndpointRegistry reg, String uri) throws InterruptedException {
+ Endpoint ep = null;
+ int count = 0;
+ while (ep == null && count < 15) {
+ ep = reg.getEndpoint(uri);
+ Thread.sleep(1000);
+ count++;
+ System.out.println(reg + ": tries=" + count);
+ }
+ Assert.assertNotNull(ep);
+ Assert.assertEquals(uri, ep.getURI());
+ return ep;
+ }
+
+ private RuntimeEndpoint createEndpoint(String uri) {
+ RuntimeEndpoint ep = (RuntimeEndpoint) assemblyFactory.createEndpoint();
+ Component comp = assemblyFactory.createComponent();
+ ep.setComponent(comp);
+ ep.setService(assemblyFactory.createComponentService());
+ Binding b = scaBindingFactory.createSCABinding();
+ ep.setBinding(b);
+ ep.setURI(uri);
+ return ep;
+ }
+
+ private void print(String prefix, Endpoint ep) {
+ System.out.println(prefix + ": "+ep);
+ }
+
+ public void endpointAdded(Endpoint endpoint) {
+ print("Added", endpoint);
+ }
+
+ public void endpointRemoved(Endpoint endpoint) {
+ print("Removed", endpoint);
+ }
+
+ public void endpointUpdated(Endpoint oldEndpoint, Endpoint newEndpoint) {
+ print("Updated", newEndpoint);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java
new file mode 100644
index 0000000000..173d2126ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.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.endpoint.tribes;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ReplicatedEndpointRegistryTestCase {
+
+ @Test
+ // @Ignore("Ignore this test case for now as it might be sensitive to the multicast settings for a multi-homed machine")
+ public void testReplicate() throws InterruptedException {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+ Map<String, String> attrs = new HashMap<String, String>();
+ attrs.put("bind", "127.0.0.1");
+ ReplicatedEndpointRegistry ep1 = new ReplicatedEndpointRegistry(extensionPoints, attrs, "foo", "bar");
+ System.out.println("ep1 is: " + ep1);
+ ep1.start();
+
+ Endpoint e1 = assemblyFactory.createEndpoint();
+ e1.setURI("e1uri");
+ ((RuntimeEndpoint) e1).bind(extensionPoints, ep1);
+ ep1.addEndpoint(e1);
+
+ Endpoint e1p = ep1.getEndpoint("e1uri");
+ System.out.println("EP1 in Registry 1: " + e1p);
+ Assert.assertNotNull(e1p);
+
+ ReplicatedEndpointRegistry ep2 = new ReplicatedEndpointRegistry(extensionPoints, attrs, "foo", "bar");
+ System.out.println("ep2 is: " + ep2);
+ ep2.start();
+ Thread.sleep(5000);
+
+ Endpoint e1p2 = ep2.getEndpoint("e1uri");
+ System.out.println("EP1 in Registry 2: " + e1p2);
+ Assert.assertNotNull(e1p2);
+
+ ReplicatedEndpointRegistry ep3 = new ReplicatedEndpointRegistry(extensionPoints, attrs, "foo", "bar");
+ System.out.println("ep3 is: " + ep3);
+ ep3.start();
+ Thread.sleep(5000);
+
+ Endpoint e1p3 = ep3.getEndpoint("e1uri");
+ System.out.println("EP1 in Registry 3: " + e1p3);
+ Assert.assertNotNull(e1p3);
+
+ ep1.stop();
+ ep2.stop();
+ ep3.stop();
+ }
+
+ public static void main(String[] args) throws Exception {
+ new ReplicatedEndpointRegistryTestCase().testReplicate();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/LICENSE b/sandbox/sebastien/java/embed/modules/extensibility-equinox/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/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/sebastien/java/embed/modules/extensibility-equinox/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/extensibility-equinox/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..7ece048182
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.extensibility.equinox;version=
+ "2.0.0"
+Bundle-ActivationPolicy: lazy
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Extensibility for Eclipse Equinox
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: true
+Bundle-Version: 2.0.0
+Bundle-Activator: org.apache.tuscany.sca.extensibility.equinox.Equinox
+ ServiceDiscoveryActivator
+Bundle-ManifestVersion: 2
+Bundle-Description: Apache Tuscany SCA Extensibility for Eclipse Equin
+ ox
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Import-Package: org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.osgi.framework;version="1.4",
+ org.osgi.framework.launch;version="1.0.0";resolution:=optional,
+ org.osgi.util.tracker;version="1.4.2"
+Tuscany-Comment2: The system bundle exports javax.transaction* packages that only
+ contains a subset of the classes
+DynamicImport-Package: org.apache.tuscany.sca.extensibility.equinox,
+ javax.transaction;version="1.1",
+ javax.transaction.xa;version="1.1",
+ *
+Bundle-SymbolicName: org.apache.tuscany.sca.extensibility.equinox
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.extensibility.equinox;version="2.0.0"
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/NOTICE b/sandbox/sebastien/java/embed/modules/extensibility-equinox/NOTICE
new file mode 100644
index 0000000000..a67cd7c175
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/NOTICE
@@ -0,0 +1,5 @@
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/pom.xml b/sandbox/sebastien/java/embed/modules/extensibility-equinox/pom.xml
new file mode 100644
index 0000000000..6643dd01d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/pom.xml
@@ -0,0 +1,66 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <name>Apache Tuscany SCA Extensibility for Eclipse Equinox</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/bundles</outputDirectory>
+ <excludeArtifactIds>osgi,junit,easymock,tuscany-extensibility</excludeArtifactIds>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
new file mode 100644
index 0000000000..6736f9cfb4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
@@ -0,0 +1,326 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility.equinox;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDeclarationParser;
+import org.apache.tuscany.sca.extensibility.ServiceDiscoverer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+import org.osgi.util.tracker.BundleTracker;
+
+/**
+ * A ServiceDiscoverer that find META-INF/services/... in installed bundles
+ *
+ * @version $Rev$ $Date$
+ */
+public class EquinoxServiceDiscoverer implements ServiceDiscoverer {
+ private static final Logger logger = Logger.getLogger(EquinoxServiceDiscoverer.class.getName());
+
+ private BundleContext context;
+ private Version version;
+ private BundleTracker bundleTracker;
+
+ public EquinoxServiceDiscoverer(BundleContext context) {
+ this.context = context;
+ Bundle bundle = context.getBundle();
+ this.version = getSCAVersion(bundle);
+ if (this.version.equals(Version.emptyVersion)) {
+ this.version = Version.parseVersion("1.1");
+ }
+ bundleTracker = new ActiveBundleTracker(context);
+ bundleTracker.open();
+ }
+
+ public void stop() {
+ bundleTracker.close();
+ }
+
+ private Version getSCAVersion(Bundle bundle) {
+ String header = (String)bundle.getHeaders().get("SCA-Version");
+ return Version.parseVersion(header);
+ }
+
+ public static class ActiveBundleTracker extends BundleTracker {
+
+ /**
+ * @param context
+ * @param stateMask
+ * @param customizer
+ */
+ public ActiveBundleTracker(BundleContext context) {
+ super(context, Bundle.RESOLVED | Bundle.ACTIVE | Bundle.STARTING, null);
+ }
+
+ @Override
+ public Object addingBundle(Bundle bundle, BundleEvent event) {
+ if (event != null && event.getType() == BundleEvent.STOPPED) {
+ return null;
+ }
+ return super.addingBundle(bundle, event);
+ }
+
+ }
+
+
+ public static class ServiceDeclarationImpl implements ServiceDeclaration {
+ private Bundle bundle;
+ private URL url;
+ private String className;
+ private Class<?> javaClass;
+ private Map<String, String> attributes;
+
+ public ServiceDeclarationImpl(Bundle bundle, URL url, String className, Map<String, String> attributes) {
+ super();
+ this.bundle = bundle;
+ this.url = url;
+ this.className = className;
+ this.attributes = attributes;
+ }
+
+ public Map<String, String> getAttributes() {
+ return attributes;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public Class<?> loadClass() throws ClassNotFoundException {
+ if (className == null) {
+ return null;
+ }
+ if (javaClass == null) {
+ javaClass = loadClass(className);
+ }
+ return javaClass;
+ }
+
+ public Class<?> loadClass(String className) throws ClassNotFoundException {
+ return bundle.loadClass(className);
+ }
+
+ public URL getLocation() {
+ return url;
+ }
+
+ public URL getResource(final String name) {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return bundle.getResource(name);
+ }
+ });
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Bundle: ").append(EquinoxServiceDiscoverer.toString(bundle));
+ sb.append(" Resource: ").append(url);
+ sb.append(" Attributes: ").append(attributes);
+ return sb.toString();
+ }
+
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ public boolean isAssignableTo(Class<?> serviceType) {
+ try {
+ loadClass();
+ } catch (ClassNotFoundException e) {
+ // Ignore
+ }
+ return (javaClass != null && serviceType.isAssignableFrom(javaClass));
+ }
+
+ }
+
+ /**
+ * Empty static method to trigger the activation of this bundle.
+ */
+ public static void init() {
+ }
+
+ private static String toString(Bundle b) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(b.getBundleId()).append(" ").append(b.getSymbolicName());
+ int s = b.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+ return sb.toString();
+
+ }
+
+
+ public ServiceDeclaration getServiceDeclaration(String name) throws IOException {
+ Collection<ServiceDeclaration> declarations = getServiceDeclarations(name);
+ if (declarations.isEmpty()) {
+ return null;
+ } else {
+ return declarations.iterator().next();
+ }
+ }
+
+ private boolean isProviderBundle(Bundle bundle, boolean isTuscanyService) {
+ if (bundle.getBundleId() == 0 || bundle.getSymbolicName().startsWith("1.x-osgi-bundle")
+ || bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null) {
+ // Skip system bundle as it has access to the application classloader
+ // Skip the 1.x runtime bundle as this has 1.x services in it
+ // For testing running 1.x and 2.x in same VM.
+ // Don't know what final form will be yet.
+ // Skip bundle fragments too
+ return false;
+ }
+ // FIXME: [rfeng] What bundles should be searched? ACTIVE and STARTING?
+ if ((bundle.getState() & Bundle.UNINSTALLED) != 0) {
+ return false;
+ }
+ if (isTuscanyService) {
+ Version scaVersion = getSCAVersion(bundle);
+ return scaVersion.compareTo(version) == 0;
+ }
+ return true;
+ }
+
+ protected Collection<Bundle> getBundles(boolean isTuscanyService) {
+ // return bundles.keySet();
+ Set<Bundle> set = new HashSet<Bundle>();
+ for (Bundle b : context.getBundles()) {
+ if (isProviderBundle(b, isTuscanyService)) {
+ set.add(b);
+ }
+ /*
+ else {
+ if (b.getBundleId() != 0 && isTuscanyService) {
+ logger.warning("Bundle is skipped for service discovery: " + toString(b));
+ }
+ }
+ */
+ }
+ return set;
+ }
+
+ public Collection<ServiceDeclaration> getServiceDeclarations(String serviceName) throws IOException {
+ boolean debug = logger.isLoggable(Level.FINE);
+ Collection<ServiceDeclaration> descriptors = new HashSet<ServiceDeclaration>();
+
+ // http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/xpath/XPathFactory.html
+ boolean isPropertyFile = "javax.xml.xpath.XPathFactory".equals(serviceName);
+ boolean isTuscanyService = serviceName.startsWith("org.apache.tuscany.sca.");
+ serviceName = "META-INF/services/" + serviceName;
+
+ Set<URL> visited = new HashSet<URL>();
+ //System.out.println(">>>> getServiceDeclarations()");
+ for (Bundle bundle : getBundles(isTuscanyService)) {
+// if (!isProviderBundle(bundle)) {
+// continue;
+// }
+ Enumeration<URL> urls = null;
+ try {
+ // Use getResources to find resources on the classpath of the bundle
+ // Please note there are cases that getResources will return null even
+ // the bundle containing such entries:
+ // 1. There is a match on Import-Package or DynamicImport-Package, and another
+ // bundle exports the resource package, there is a possiblity that it doesn't
+ // find the containing entry
+ // 2. The bundle cannot be resolved, then getResources will return null
+ urls = bundle.getResources(serviceName);
+ if (urls == null) {
+ URL entry = bundle.getEntry(serviceName);
+ if (entry != null) {
+ logger.warning("Unresolved resource " + serviceName + " found in " + toString(bundle));
+ try {
+ bundle.start();
+ } catch (BundleException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ // urls = Collections.enumeration(Arrays.asList(entry));
+ }
+ }
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ if (urls == null) {
+ continue;
+ }
+ while (urls.hasMoreElements()) {
+ final URL url = urls.nextElement();
+
+ if (!visited.add(url)) {
+ // The URL has already been processed
+ continue;
+ }
+
+ if (debug) {
+ logger.fine("Reading service provider file: " + url.toExternalForm());
+ }
+ try {
+ for (Map<String, String> attributes : ServiceDeclarationParser.load(url, isPropertyFile)) {
+ String className = attributes.get("class");
+ ServiceDeclarationImpl descriptor = new ServiceDeclarationImpl(bundle, url, className, attributes);
+ descriptors.add(descriptor);
+ }
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ }
+ return descriptors;
+ }
+
+ public ClassLoader getContextClassLoader() {
+ // Get the bundle classloader for the extensibility bundle that has DynamicImport-Package *
+ return getClass().getClassLoader();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java
new file mode 100644
index 0000000000..14ad6670a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility.equinox;
+
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The Bundle Activator that creates the Equinox-based service discoverer
+ *
+ * @version $Rev$ $Date$
+ */
+public class EquinoxServiceDiscoveryActivator implements BundleActivator {
+ // private static final Logger logger = Logger.getLogger(EquinoxServiceDiscoveryActivator.class.getName());
+ private EquinoxServiceDiscoverer discoverer;
+
+ public void start(BundleContext context) throws Exception {
+ discoverer = new EquinoxServiceDiscoverer(context);
+ ServiceDiscovery.getInstance().setServiceDiscoverer(discoverer);
+ // logger.info("Equinox-based service discoverer is now configured.");
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ ServiceDiscovery.getInstance().setServiceDiscoverer(null);
+ if (discoverer != null) {
+ discoverer.stop();
+ discoverer = null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
new file mode 100644
index 0000000000..4b5fffff01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility.equinox;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * OSGi ServiceRegistry based extension point registry
+ */
+public class OSGiExtensionPointRegistry extends DefaultExtensionPointRegistry {
+ private Map<Class<?>, ServiceRegistration> registrations = new ConcurrentHashMap<Class<?>, ServiceRegistration>();
+ private BundleContext bundleContext;
+
+ public OSGiExtensionPointRegistry(BundleContext bundleContext) {
+ super(ServiceDiscovery.getInstance(new EquinoxServiceDiscoverer(bundleContext)));
+ this.bundleContext = bundleContext;
+ }
+
+ @Override
+ protected void registerExtensionPoint(Class<?> extensionPointType,
+ Object extensionPoint,
+ ServiceDeclaration declaration) {
+ BundleContext context = bundleContext;
+ if (declaration instanceof EquinoxServiceDiscoverer.ServiceDeclarationImpl) {
+ EquinoxServiceDiscoverer.ServiceDeclarationImpl declarationImpl =
+ (EquinoxServiceDiscoverer.ServiceDeclarationImpl)declaration;
+ Bundle bundle = declarationImpl.getBundle();
+ /**
+ * If this bundle is not in the STARTING, ACTIVE, or STOPPING states or this bundle
+ * is a fragment bundle, then this bundle has no valid BundleContext. This method will
+ * return null if this bundle has no valid BundleContext
+ */
+ if ((bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING)) == 0) {
+ try {
+ bundle.start();
+ } catch (BundleException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ context = bundle.getBundleContext();
+ }
+ Dictionary<Object, Object> props = new Hashtable<Object, Object>();
+ ServiceRegistration registration = context.registerService(extensionPointType.getName(), extensionPoint, props);
+ registrations.put(extensionPointType, registration);
+ super.registerExtensionPoint(extensionPointType, extensionPoint, declaration);
+ }
+
+ @Override
+ protected void unregisterExtensionPoint(Class<?> i) {
+ ServiceRegistration registration = registrations.remove(i);
+ if (registration != null) {
+ try {
+ registration.unregister();
+ } catch (IllegalStateException e) {
+ // The service has been unregistered, ignore it
+ }
+ }
+ super.unregisterExtensionPoint(i);
+ }
+
+ @Override
+ public synchronized void stop() {
+ for (ServiceRegistration reg : registrations.values()) {
+ try {
+ ServiceReference ref = reg.getReference();
+ if (ref != null) {
+ reg.unregister();
+ }
+ } catch (IllegalStateException e) {
+ // Ignore it, the service has been unregistered when the owning bundle stops
+ }
+ }
+ registrations.clear();
+ super.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxHostTestCase.java b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxHostTestCase.java
new file mode 100644
index 0000000000..aa9cd50abc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxHostTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.extensibility.equinox;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Test start/stop the Equinox runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EquinoxHostTestCase {
+ @Test
+ public void testStartThenStop() {
+ TestEquinoxHost host = new TestEquinoxHost();
+ BundleContext context = host.start();
+ Assert.assertNotNull(context);
+ for (Bundle b : context.getBundles()) {
+ System.out.println(toString(b, false));
+ }
+ host.stop();
+ }
+
+ @Test
+ public void testStartTwice() {
+ TestEquinoxHost host = new TestEquinoxHost();
+ host.start();
+ try {
+ host.start();
+ Assert.fail();
+ } catch (IllegalStateException e) {
+ Assert.assertTrue(IllegalStateException.class.isInstance(e.getCause()));
+ } finally {
+ host.stop();
+ }
+ }
+
+ public static String toString(Bundle b, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(b.getBundleId()).append(" ").append(b.getSymbolicName());
+ int s = b.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ sb.append(" ").append(b.getLocation());
+ if (verbose) {
+ Dictionary<Object, Object> dict = b.getHeaders();
+ Enumeration<Object> keys = dict.keys();
+ while (keys.hasMoreElements()) {
+ Object key = keys.nextElement();
+ sb.append(" ").append(key).append("=").append(dict.get(key));
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java
new file mode 100644
index 0000000000..0b0e46fd15
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.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.sca.extensibility.equinox;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Test the Equinox service discoverer.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EquinoxServiceDiscovererTestCase {
+ private static EquinoxServiceDiscoverer discoverer;
+ private static Bundle testBundle1;
+ private static Bundle testBundle2;
+ private static TestEquinoxHost host;
+
+ private static String getState(Bundle b) {
+ StringBuffer sb = new StringBuffer();
+ int s = b.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append("UNINSTALLED ");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append("INSTALLED ");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append("RESOLVED ");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append("STARTING ");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append("STOPPING ");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append("ACTIVE ");
+ }
+ return sb.toString();
+
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ host = new TestEquinoxHost();
+ BundleContext context = host.start();
+
+ InputStream is = EquinoxServiceDiscovererTestCase.class.getResourceAsStream("/test-bundle-v1.jar");
+ testBundle1 = context.installBundle("test-bundle-v1", is);
+ is.close();
+
+ is = EquinoxServiceDiscovererTestCase.class.getResourceAsStream("/test-bundle-v2.jar");
+ testBundle2 = context.installBundle("test-bundle-v2", is);
+ is.close();
+
+ discoverer = new EquinoxServiceDiscoverer(context);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (testBundle1 != null) {
+ // Uninstall the bundle to clean up the cache
+ testBundle1.uninstall();
+ }
+ if (testBundle2 != null) {
+ // Uninstall the bundle to clean up the cache
+ testBundle2.uninstall();
+ }
+ host.stop();
+ System.out.println("Done");
+ }
+
+ @Test
+ public void testDiscovery() throws IOException {
+ // Both version 1 and 2 should be found because test.TestService is not a Tuscany service
+ Collection<ServiceDeclaration> descriptors = discoverer.getServiceDeclarations("test.TestService");
+ Assert.assertEquals(2, descriptors.size());
+ descriptors = discoverer.getServiceDeclarations("notthere");
+ Assert.assertEquals(0, descriptors.size());
+ }
+
+ @Test
+ public void testDiscoveryFirst() throws IOException {
+ ServiceDeclaration descriptor = discoverer.getServiceDeclaration("test.TestService");
+ Assert.assertNotNull(descriptor);
+ descriptor = discoverer.getServiceDeclaration("notthere");
+ Assert.assertNull(descriptor);
+ }
+
+ @Test
+ public void testTuscanyDiscovery() throws IOException {
+ Collection<ServiceDeclaration> descriptors = discoverer.getServiceDeclarations("org.apache.tuscany.sca.test.TestService");
+ // Only the version 2 should be found
+ Assert.assertEquals(1, descriptors.size());
+ ServiceDeclaration sd = descriptors.iterator().next();
+ Assert.assertEquals("2", sd.getAttributes().get("version"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/TestEquinoxHost.java b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/TestEquinoxHost.java
new file mode 100644
index 0000000000..566cd6e1a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/TestEquinoxHost.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.extensibility.equinox;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A test host that starts/stops Equinox.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestEquinoxHost {
+ private Framework framework;
+
+ private BundleContext init() throws Exception {
+ if (framework != null) {
+ throw new IllegalStateException("The framework is started already");
+ }
+ ServiceDeclaration sd = ServiceDiscovery.getInstance().getServiceDeclaration(FrameworkFactory.class.getName());
+ Class<?> factoryCls = sd.loadClass();
+ FrameworkFactory factory = (FrameworkFactory)factoryCls.newInstance();
+ Map<Object, Object> props = new HashMap<Object, Object>();
+ props.put("osgi.clean", "true");
+ props.put("osgi.instance.area", new File("target/workspace").toURI().toString());
+ props.put("osgi.install.area", new File("target/eclipse").toURI().toString());
+ props.put("osgi.configuration.area", new File("target/eclipse").toURI().toString());
+ framework = factory.newFramework(props);
+ framework.start();
+ return framework.getBundleContext();
+ }
+
+ public BundleContext start() {
+ try {
+ return init();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public void stop() {
+ try {
+ if (framework != null) {
+ framework.stop();
+ framework.waitForStop(2000);
+ framework = null;
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/resources/test-bundle-v1.jar b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/resources/test-bundle-v1.jar
new file mode 100644
index 0000000000..61c7b5a49e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/resources/test-bundle-v1.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/resources/test-bundle-v2.jar b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/resources/test-bundle-v2.jar
new file mode 100644
index 0000000000..b02c368c58
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility-equinox/src/test/resources/test-bundle-v2.jar
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/LICENSE b/sandbox/sebastien/java/embed/modules/extensibility/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/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/sebastien/java/embed/modules/extensibility/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/extensibility/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9bead3ab7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.core;version="2.0.0";
+ uses:="org.apache.tuscany.sca.extensibility",
+ org.apache.tuscany.sca.extensibility;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Extensibility
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Extensibility
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0"
+DynamicImport-Package: org.apache.tuscany.sca.extensibility.equinox
+Bundle-SymbolicName: org.apache.tuscany.sca.extensibility
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/NOTICE b/sandbox/sebastien/java/embed/modules/extensibility/NOTICE
new file mode 100644
index 0000000000..1fda3f942e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/NOTICE
@@ -0,0 +1,10 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes software developed at
+the OSGi Alliance (http://www.osgi.org/).
+
+
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/pom.xml b/sandbox/sebastien/java/embed/modules/extensibility/pom.xml
new file mode 100644
index 0000000000..23a4b6a971
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-extensibility</artifactId>
+ <name>Apache Tuscany SCA Extensibility</name>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
new file mode 100644
index 0000000000..e1f9ac6ddd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core;
+
+import static org.apache.tuscany.sca.extensibility.ServiceHelper.newInstance;
+
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.extensibility.ServiceHelper;
+
+/**
+ * Default implementation of a registry to hold all the Tuscany core extension
+ * points. As the point of contact for all extension artifacts this registry
+ * allows loaded extensions to find all other parts of the system and register
+ * themselves appropriately.
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
+ protected Map<Class<?>, Object> extensionPoints = new HashMap<Class<?>, Object>();
+ private ServiceDiscovery discovery;
+ /**
+ * Constructs a new registry.
+ */
+ public DefaultExtensionPointRegistry() {
+ this.discovery = ServiceDiscovery.getInstance();
+ }
+
+ public DefaultExtensionPointRegistry(ServiceDiscovery discovery) {
+ this.discovery = discovery;
+ }
+
+ /**
+ * Add an extension point to the registry. This default implementation
+ * stores extensions against the interfaces that they implement.
+ *
+ * @param extensionPoint The instance of the extension point
+ *
+ * @throws IllegalArgumentException if extensionPoint is null
+ */
+ public synchronized void addExtensionPoint(Object extensionPoint) {
+ addExtensionPoint(extensionPoint, null);
+ }
+
+ public synchronized void addExtensionPoint(Object extensionPoint, ServiceDeclaration declaration) {
+ if (extensionPoint == null) {
+ throw new IllegalArgumentException("Cannot register null as an ExtensionPoint");
+ }
+ ServiceHelper.start(extensionPoint);
+
+ Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass());
+ for (Class<?> i : interfaces) {
+ registerExtensionPoint(i, extensionPoint, declaration);
+ }
+ }
+
+ protected void registerExtensionPoint(Class<?> i, Object extensionPoint, ServiceDeclaration declaration) {
+ extensionPoints.put(i, extensionPoint);
+ }
+
+ /**
+ * Get the extension point by the interface that it implements
+ *
+ * @param extensionPointType The lookup key (extension point interface)
+ * @return The instance of the extension point
+ *
+ * @throws IllegalArgumentException if extensionPointType is null
+ */
+ public synchronized <T> T getExtensionPoint(Class<T> extensionPointType) {
+ if (extensionPointType == null) {
+ throw new IllegalArgumentException("Cannot lookup ExtensionPoint of type null");
+ }
+
+ Object extensionPoint = findExtensionPoint(extensionPointType);
+ if (extensionPoint == null) {
+
+ // Dynamically load an extension point class declared under META-INF/services
+ try {
+ ServiceDeclaration extensionPointDeclaration =
+ getServiceDiscovery().getServiceDeclaration(extensionPointType);
+ if (extensionPointDeclaration != null) {
+ extensionPoint = newInstance(this, extensionPointDeclaration);
+ // Cache the loaded extension point
+ addExtensionPoint(extensionPoint, extensionPointDeclaration);
+ }
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return extensionPointType.cast(extensionPoint);
+ }
+
+ protected <T> Object findExtensionPoint(Class<T> extensionPointType) {
+ return extensionPoints.get(extensionPointType);
+ }
+
+ /**
+ * Remove an extension point based on the interface that it implements
+ *
+ * @param extensionPoint The extension point to remove
+ *
+ * @throws IllegalArgumentException if extensionPoint is null
+ */
+ public synchronized void removeExtensionPoint(Object extensionPoint) {
+ if (extensionPoint == null) {
+ throw new IllegalArgumentException("Cannot remove null as an ExtensionPoint");
+ }
+
+ ServiceHelper.stop(extensionPoint);
+
+ Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass());
+ for (Class<?> i : interfaces) {
+ unregisterExtensionPoint(i);
+ }
+ }
+
+ protected void unregisterExtensionPoint(Class<?> i) {
+ extensionPoints.remove(i);
+ }
+
+ /**
+ * Returns the set of interfaces implemented by the given class and its
+ * ancestors or a blank set if none
+ */
+ private static Set<Class<?>> getAllInterfaces(Class<?> clazz) {
+ Set<Class<?>> implemented = new HashSet<Class<?>>();
+ getAllInterfaces(clazz, implemented);
+ implemented.remove(LifeCycleListener.class);
+ return implemented;
+ }
+
+ private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) {
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for (Class<?> interfaze : interfaces) {
+ if (Modifier.isPublic(interfaze.getModifiers())) {
+ implemented.add(interfaze);
+ }
+ }
+ Class<?> superClass = clazz.getSuperclass();
+ // Object has no superclass so check for null
+ if (superClass != null && !superClass.equals(Object.class)) {
+ getAllInterfaces(superClass, implemented);
+ }
+ }
+
+ public synchronized void start() {
+ // Do nothing
+ }
+
+ public synchronized void stop() {
+ // Get a unique map as an extension point may exist in the map by different keys
+ Map<LifeCycleListener, LifeCycleListener> map = new IdentityHashMap<LifeCycleListener, LifeCycleListener>();
+ for (Object extp : extensionPoints.values()) {
+ if (extp instanceof LifeCycleListener) {
+ LifeCycleListener listener = (LifeCycleListener)extp;
+ map.put(listener, listener);
+ }
+ }
+ ServiceHelper.stop(map.values());
+ extensionPoints.clear();
+ }
+
+ public ServiceDiscovery getServiceDiscovery() {
+ return discovery;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
new file mode 100644
index 0000000000..1c49ea4ee4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core;
+
+import static org.apache.tuscany.sca.extensibility.ServiceHelper.newInstance;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+
+
+/**
+ * Default implementation of a model factory extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint {
+ private ExtensionPointRegistry registry;
+ private Map<Class<?>, Object> factories = new ConcurrentHashMap<Class<?>, Object>();
+
+ /**
+ * Constructs a new DefaultModelFactoryExtensionPoint.
+ */
+ public DefaultFactoryExtensionPoint(ExtensionPointRegistry extensionPointRegistry) {
+ this.registry = extensionPointRegistry;
+ }
+
+ /**
+ * Add a model factory extension.
+ *
+ * @param factory The factory to add
+ */
+ public void addFactory(Object factory) {
+ Class<?>[] interfaces = factory.getClass().getInterfaces();
+ if (interfaces.length == 0) {
+ Class<?> sc = factory.getClass().getSuperclass();
+ if (sc != Object.class) {
+ factories.put(sc, factory);
+ }
+ } else {
+ for (int i = 0; i<interfaces.length; i++) {
+ factories.put(interfaces[i], factory);
+ }
+ }
+ }
+
+ /**
+ * Remove a model factory.
+ *
+ * @param factory The factory to remove
+ */
+ public void removeFactory(Object factory) {
+ Class<?>[] interfaces = factory.getClass().getInterfaces();
+ if (interfaces.length == 0) {
+ Class<?> sc = factory.getClass().getSuperclass();
+ if (sc != Object.class) {
+ factories.remove(sc);
+ }
+ } else {
+ for (int i = 0; i<interfaces.length; i++) {
+ factories.remove(interfaces[i]);
+ }
+ }
+ }
+
+ private ClassLoader setContextClassLoader(final ClassLoader classLoader) {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ if (classLoader != null) {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ return tccl;
+ }
+ });
+ }
+
+ /**
+ * Get a factory implementing the given interface.
+ * @param factoryInterface The lookup key (factory interface)
+ * @return The factory
+ */
+ public <T> T getFactory(Class<T> factoryInterface) {
+ Object factory = factories.get(factoryInterface);
+ if (factory == null) {
+
+ // Dynamically load a factory class declared under META-INF/services
+ try {
+ ServiceDeclaration factoryDeclaration =
+ registry.getServiceDiscovery().getServiceDeclaration(factoryInterface);
+ if (factoryDeclaration != null) {
+ try {
+ // Constructor taking the extension point registry
+ factory = newInstance(registry, factoryDeclaration);
+ } catch (NoSuchMethodException e) {
+ factory = newInstance(factoryDeclaration.loadClass(), FactoryExtensionPoint.class, this);
+ }
+
+ // Cache the loaded factory
+ factories.put(factoryInterface, factory);
+
+ return factoryInterface.cast(factory);
+
+ } else {
+
+ // If the input interface is an abstract class
+ if (!factoryInterface.isInterface() && Modifier.isAbstract(factoryInterface.getModifiers())) {
+ Method newInstanceMethod = factoryInterface.getDeclaredMethod("newInstance");
+ ClassLoader tccl = setContextClassLoader(factoryInterface.getClassLoader());
+ try {
+
+ // Create a new instance
+ factory = newInstanceMethod.invoke(null);
+
+ // Cache the factory
+ factories.put(factoryInterface, factory);
+
+ return factoryInterface.cast(factory);
+ } catch (Exception e) {
+ // Sorry no factory found
+ return null;
+ } finally {
+ setContextClassLoader(tccl);
+ }
+ } else {
+
+ // Sorry no factory found
+ return null;
+ }
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ return factoryInterface.cast(factory);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
new file mode 100644
index 0000000000..99792d0215
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core;
+
+import static org.apache.tuscany.sca.extensibility.ServiceHelper.newInstance;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+/**
+ * Default implementation of an extension point to hold Tuscany module activators.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultModuleActivatorExtensionPoint implements ModuleActivatorExtensionPoint {
+ private final static Logger logger = Logger.getLogger(DefaultModuleActivatorExtensionPoint.class.getName());
+ private List<ModuleActivator> activators = new ArrayList<ModuleActivator>();
+ private boolean loadedActivators;
+ private boolean started;
+ private ExtensionPointRegistry registry;
+
+ /**
+ * Constructs a new extension point.
+ */
+ public DefaultModuleActivatorExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public void addModuleActivator(ModuleActivator activator) {
+ activators.add(activator);
+ }
+
+ public List<ModuleActivator> getModuleActivators() {
+ loadModuleActivators();
+ return activators;
+ }
+
+ public void removeModuleActivator(ModuleActivator activator) {
+ if (activators.remove(activator)) {
+ activator.stop();
+ }
+ }
+
+ /**
+ * Dynamically load module activators declared under META-INF/services
+ */
+ private synchronized void loadModuleActivators() {
+ if (loadedActivators)
+ return;
+
+ // Get the activator service declarations
+ Collection<ServiceDeclaration> activatorDeclarations;
+ try {
+ // Load the module activators by ranking
+ activatorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ModuleActivator.class.getName(), true);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Load and instantiate module activators
+ for (ServiceDeclaration activatorDeclaration : activatorDeclarations) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Loading " + activatorDeclaration.getClassName());
+ }
+ ModuleActivator activator = null;
+ try {
+ Class<ModuleActivator> activatorClass = (Class<ModuleActivator>)activatorDeclaration.loadClass();
+ try {
+ activator = newInstance(activatorClass, ExtensionPointRegistry.class, registry);
+ } catch (NoSuchMethodException e) {
+ try {
+ activator =
+ newInstance(activatorClass,
+ new Class<?>[] {ExtensionPointRegistry.class, Map.class},
+ registry,
+ activatorDeclaration.getAttributes());
+
+ } catch (NoSuchMethodException e1) {
+ activator = newInstance(activatorClass);
+
+ }
+ }
+ } catch (Throwable e) {
+ String optional = activatorDeclaration.getAttributes().get("optional");
+ if ("true".equalsIgnoreCase(optional)) {
+ // If the optional flag is true, just log the error
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ continue;
+ } else {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ addModuleActivator(activator);
+ }
+
+ loadedActivators = true;
+ }
+
+ public void start() {
+ if (started) {
+ return;
+ }
+ getModuleActivators();
+ for (ModuleActivator activator : activators) {
+ try {
+ activator.start();
+ } catch (Throwable e) {
+ // Ignore the failing module for now
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ started = true;
+ }
+
+ public void stop() {
+ if (!started) {
+ return;
+ }
+ for (int i = activators.size() - 1; i >= 0; i--) {
+ try {
+ activators.get(i).stop();
+ } catch (Throwable e) {
+ // Ignore the failing module for now
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ started = false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
new file mode 100644
index 0000000000..40e4635d77
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core;
+
+import static org.apache.tuscany.sca.extensibility.ServiceHelper.newInstance;
+
+import java.lang.reflect.Modifier;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+/**
+ * Default implementation of an extension point to hold Tuscany utility utilities.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
+ private Map<Object, Object> utilities = new ConcurrentHashMap<Object, Object>();
+
+ private ExtensionPointRegistry registry;
+ /**
+ * Constructs a new extension point.
+ */
+ public DefaultUtilityExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ this.registry = extensionPoints;
+ }
+
+ /**
+ * Add a utility to the extension point. This default implementation
+ * stores utilities against the interfaces that they implement.
+ *
+ * @param utility The instance of the utility
+ *
+ * @throws IllegalArgumentException if utility is null
+ */
+ public void addUtility(Object utility) {
+ addUtility(null, utility);
+ }
+
+ public void addUtility(Object key, Object utility) {
+ if (utility == null) {
+ throw new IllegalArgumentException("Cannot register null as a Service");
+ }
+
+ if (utility instanceof LifeCycleListener) {
+ ((LifeCycleListener)utility).start();
+ }
+
+ if (key == null) {
+ Class<?> cls = utility.getClass();
+ Set<Class<?>> interfaces = getAllInterfaces(cls);
+ for (Class<?> i : interfaces) {
+ utilities.put(i, utility);
+ }
+ if (interfaces.isEmpty() || isConcreteClass(cls)) {
+ utilities.put(cls, utility);
+ }
+ } else {
+ utilities.put(key, utility);
+ }
+ }
+
+ /**
+ * Get the utility by the interface that it implements
+ *
+ * @param utilityType The lookup key (utility interface)
+ * @return The instance of the utility
+ *
+ * @throws IllegalArgumentException if utilityType is null
+ */
+ public <T> T getUtility(Class<T> utilityType) {
+ return getUtility(utilityType, null);
+ }
+
+ /**
+ * Remove a utility based on the interface that it implements
+ *
+ * @param utility The utility to remove
+ *
+ * @throws IllegalArgumentException if utility is null
+ */
+ public void removeUtility(Object utility) {
+ if (utility == null) {
+ throw new IllegalArgumentException("Cannot remove null as a Service");
+ }
+
+ if(utility instanceof LifeCycleListener) {
+ ((LifeCycleListener) utility).stop();
+ }
+
+ for (Iterator<Map.Entry<Object, Object>> i = utilities.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<Object, Object> entry = i.next();
+ if (entry.getValue() == utility) {
+ i.remove();
+ }
+ }
+ }
+
+ /**
+ * Returns the set of interfaces implemented by the given class and its
+ * ancestors or a blank set if none
+ */
+ private static Set<Class<?>> getAllInterfaces(Class<?> clazz) {
+ Set<Class<?>> implemented = new HashSet<Class<?>>();
+ getAllInterfaces(clazz, implemented);
+ implemented.remove(LifeCycleListener.class);
+ return implemented;
+ }
+
+ private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) {
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for (Class<?> interfaze : interfaces) {
+ if (Modifier.isPublic(interfaze.getModifiers())) {
+ implemented.add(interfaze);
+ }
+ }
+ Class<?> superClass = clazz.getSuperclass();
+ // Object has no superclass so check for null
+ if (superClass != null && !superClass.equals(Object.class)) {
+ getAllInterfaces(superClass, implemented);
+ }
+ }
+
+ public <T> T getUtility(Class<T> utilityType, Object key) {
+ if (utilityType == null) {
+ throw new IllegalArgumentException("Cannot lookup Service of type null");
+ }
+
+ if (key == null) {
+ key = utilityType;
+ }
+
+ Object utility = utilities.get(key);
+
+ if (utility == null) {
+
+ // Dynamically load a utility class declared under META-INF/services/"utilityType"
+ try {
+ ServiceDeclaration utilityDeclaration =
+ registry.getServiceDiscovery().getServiceDeclaration(utilityType.getName());
+ Class<?> utilityClass = null;
+ if (utilityDeclaration != null) {
+ utilityClass = utilityDeclaration.loadClass();
+ } else if (isConcreteClass(utilityType)) {
+ utilityClass = utilityType;
+ key = utilityType;
+ }
+ if (utilityClass != null) {
+ // Construct the utility
+ if (utilityDeclaration != null) {
+ utility = newInstance(registry, utilityDeclaration);
+ } else {
+ try {
+ utility = newInstance(utilityClass, ExtensionPointRegistry.class, registry);
+ } catch (NoSuchMethodException e) {
+ utility = newInstance(utilityClass);
+ }
+ }
+ // Cache the loaded utility
+ if (key == utilityType) {
+ addUtility(utility);
+ } else {
+ addUtility(key, utility);
+ }
+ }
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return utilityType.cast(utility);
+ }
+
+ private boolean isConcreteClass(Class<?> utilityType) {
+ int modifiers = utilityType.getModifiers();
+ return !utilityType.isInterface() && Modifier.isPublic(modifiers) && !Modifier.isAbstract(modifiers);
+ }
+
+ public void start() {
+ // NOOP
+ }
+
+ public synchronized void stop() {
+ // Get a unique map as an extension point may exist in the map by different keys
+ Map<LifeCycleListener, LifeCycleListener> map = new IdentityHashMap<LifeCycleListener, LifeCycleListener>();
+ for (Object util : utilities.values()) {
+ if (util instanceof LifeCycleListener) {
+ LifeCycleListener listener = (LifeCycleListener)util;
+ map.put(listener, listener);
+ }
+ }
+ for (LifeCycleListener listener : map.values()) {
+ listener.stop();
+ }
+ utilities.clear();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java
new file mode 100644
index 0000000000..8f9ab7ed3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.core;
+
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+
+
+/**
+ * The registry for the Tuscany core extension points. As the point of contact
+ * for all extension artifacts this registry allows loaded extensions to find
+ * all other parts of the system and register themselves appropriately.
+ *
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ExtensionPointRegistry extends LifeCycleListener {
+
+ /**
+ * Add an extension point to the registry
+ * @param extensionPoint The instance of the extension point
+ *
+ * @throws IllegalArgumentException if extensionPoint is null
+ */
+ void addExtensionPoint(Object extensionPoint);
+
+ /**
+ * Get the extension point by the interface
+ * @param extensionPointType The lookup key (extension point interface)
+ * @return The instance of the extension point
+ *
+ * @throws IllegalArgumentException if extensionPointType is null
+ */
+ <T> T getExtensionPoint(Class<T> extensionPointType);
+
+ /**
+ * Remove an extension point
+ * @param extensionPoint The extension point to remove
+ *
+ * @throws IllegalArgumentException if extensionPoint is null
+ */
+ void removeExtensionPoint(Object extensionPoint);
+
+ /**
+ * Get an instance of the ServiceDiscovery
+ * @return an instance of the ServiceDiscovery associated with the environment
+ */
+ ServiceDiscovery getServiceDiscovery();
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.java
new file mode 100644
index 0000000000..c3d2fd282a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core;
+
+/**
+ * An extension point for model factories. Model factories are provided to
+ * abstract the classes that represent artifacts in the assembly model away
+ * from their creation mechanism. When the runtime needs to extend the model
+ * as it reads in contributed artifacts it looks up the factory for the
+ * artifact required in this registry
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface FactoryExtensionPoint {
+
+ /**
+ * Add a model factory extension.
+ *
+ * @param factory The factory to add
+ */
+ void addFactory(Object factory);
+
+ /**
+ * Remove a model factory extension.
+ *
+ * @param factory The factory to remove
+ */
+ void removeFactory(Object factory);
+
+ /**
+ * Get a factory implementing the given interface.
+ * @param factoryInterface the lookup key (factory interface)
+ * @return The factory
+ */
+ <T> T getFactory(Class<T> factoryInterface);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.java
new file mode 100644
index 0000000000..ca92cb8129
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.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.sca.core;
+
+/**
+ * A listener that responds to the start/stop event of the ExtensionPointRegistry. Tuscany extension
+ * points or extensions can implement this interface to receive callbacks when the registry is started
+ * or stopped
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface LifeCycleListener {
+ /**
+ * The method will be invoked when the extension point registry is started
+ */
+ void start();
+ /**
+ * The method will be invoked when the extension point registry is stopped
+ */
+ void stop();
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java
new file mode 100644
index 0000000000..ddc9a6981c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core;
+
+
+/**
+ * ModuleActivator represents a module that plugs into the Tuscany system. Each
+ * module should provide an implementation of this interface and register the
+ * ModuleActivator implementation class by defining a file named
+ *
+ * "META-INF/services/org.apache.tuscany.core.ModuleActivator"
+ *
+ * The content of the file is the class name of the ModuleActivator implementation.
+ * The implementation class can have different flavors of constructors. The following
+ * order will be searched:
+ * <ul>
+ * <li>(ExtensionRegistry.class)
+ * <li>(ExtensionRegistry.class, Map.class)
+ * <li>()
+ * </ul>
+ *
+ *
+ *
+ *
+ * The same instance
+ * will be used to invoke all the methods during different phases of the module
+ * activation. Note that the start and stop methods defined by this interface
+ * take a reference to the Tuscany SCA runtime ExtensionPointRegistry. This
+ * gives the ModuleActivator the opportunity to add extension points to the
+ * registry as it is requested to start up and remove them when it is requested
+ * to shut down.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ModuleActivator extends LifeCycleListener {
+
+ /**
+ * This method is invoked when the module is started by the Tuscany runtime.
+ * It can be used by this module to register extensions against extension
+ * points.
+ *
+ * @param registry The extension point registry
+ */
+ void start();
+
+ /**
+ * This method is invoked when the module is stopped by the Tuscany runtime.
+ * It can be used by this module to unregister extensions against the
+ * extension points.
+ *
+ * @param registry The extension point registry
+ */
+ void stop();
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivatorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivatorExtensionPoint.java
new file mode 100644
index 0000000000..7070d33f2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivatorExtensionPoint.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.sca.core;
+
+import java.util.List;
+
+
+/**
+ * The extension point for the Tuscany module activator extensions.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ModuleActivatorExtensionPoint extends LifeCycleListener {
+
+ /**
+ * Add a module activator extension to the extension point
+ * @param activator The instance of the module activator
+ *
+ * @throws IllegalArgumentException if activator is null
+ */
+ void addModuleActivator(ModuleActivator activator);
+
+ /**
+ * Returns the module activator extensions.
+ * @return The module activator extensions
+ */
+ List<ModuleActivator> getModuleActivators();
+
+ /**
+ * Remove a module activator
+ * @param activator The module activator to remove
+ *
+ * @throws IllegalArgumentException if activator is null
+ */
+ void removeModuleActivator(ModuleActivator activator);
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java
new file mode 100644
index 0000000000..7acc7fc409
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.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.sca.core;
+
+
+/**
+ * The extension point for the Tuscany core utility extensions.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface UtilityExtensionPoint extends LifeCycleListener {
+
+ /**
+ * Add a utility to the extension point
+ * @param utility The instance of the utility
+ *
+ * @throws IllegalArgumentException if utility is null
+ */
+ void addUtility(Object utility);
+
+ /**
+ * Add a utility to the extension point for a given key
+ * @param utility The instance of the utility
+ *
+ * @throws IllegalArgumentException if utility is null
+ */
+ void addUtility(Object key, Object utility);
+
+ /**
+ * Get the utility by the interface
+ * @param utilityType The lookup key (utility interface)
+ * @return The instance of the utility
+ *
+ * @throws IllegalArgumentException if utilityType is null
+ */
+ <T> T getUtility(Class<T> utilityType);
+
+ /**
+ * Get an instance of the utility by the interface and key
+ * @param utilityType The lookup key (utility interface)
+ * @param key A key associated with the utility, if it is null,
+ * then the utilityType is used as the key
+ * @return The instance of the utility
+ *
+ * @throws IllegalArgumentException if utilityType is null
+ */
+ <T> T getUtility(Class<T> utilityType, Object key);
+
+ /**
+ * Remove a utility
+ * @param utility The utility to remove
+ *
+ * @throws IllegalArgumentException if utility is null
+ */
+ void removeUtility(Object utility);
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderContext.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderContext.java
new file mode 100644
index 0000000000..f15e89767c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderContext.java
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility;
+
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.tuscany.sca.extensibility.impl.ClassLoaderDelegate;
+
+/**
+ * A utility that controls context class loaders
+ * @tuscany.spi.extension.asclient
+ */
+public class ClassLoaderContext {
+ private ClassLoader classLoader;
+
+ /**
+ * Create a context with the parent classloader and a list of service types that can be discovered
+ * by the {@link ServiceDiscovery}
+ * @param parent
+ * @param discovery
+ * @param serviceTypes
+ */
+ public ClassLoaderContext(ClassLoader parent, ServiceDiscovery discovery, Class<?>... serviceTypes) {
+ this(parent, getClassLoaders(discovery, serviceTypes));
+ }
+
+ private ClassLoaderContext(ClassLoader parent, List<ClassLoader> delegates) {
+ List<ClassLoader> loaders = new ArrayList<ClassLoader>(delegates);
+ loaders.remove(parent);
+ if (delegates.isEmpty()) {
+ classLoader = parent;
+ } else {
+ classLoader = new ClassLoaderDelegate(parent, loaders);
+ }
+ }
+
+ /**
+ * Create a context that is visible to the parent classloader as well as the list of classloaders
+ * @param parent
+ * @param delegates
+ */
+ public ClassLoaderContext(ClassLoader parent, ClassLoader... delegates) {
+ this(parent, Arrays.asList(delegates));
+ }
+
+ /**
+ * Create a context with the parent classloader and a list of service types that can be discovered
+ * by the {@link ServiceDiscovery}
+ * @param parent
+ * @param discovery
+ * @param serviceTypes
+ */
+ public ClassLoaderContext(ClassLoader parent, ServiceDiscovery discovery, String... serviceTypes) {
+ this(parent, getClassLoaders(discovery, serviceTypes));
+ }
+
+ public <T> T doPrivileged(PrivilegedAction<T> action) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ if (tccl != classLoader) {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ try {
+ return action.run();
+ } finally {
+ if (tccl != classLoader) {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+ }
+
+ public <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ if (tccl != classLoader) {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ try {
+ return action.run();
+ } catch (Exception e) {
+ throw new PrivilegedActionException(e);
+ } finally {
+ if (tccl != classLoader) {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+ }
+
+ /**
+ * Set the thread context classloader (TCCL) to a classloader that delegates to a collection
+ * of classloaders
+ * @param parent The parent classloader
+ * @param delegates A list of classloaders to try
+ * @return The existing TCCL
+ */
+ public static ClassLoader setContextClassLoader(ClassLoader parent, ClassLoader... delegates) {
+ ClassLoaderContext context = new ClassLoaderContext(parent, delegates);
+ return context.setContextClassLoader();
+ }
+
+ /**
+ * Set the context classloader so that it can access the list of service providers
+ * @param parent The parent classloader
+ * @param serviceNames A list of service provider names
+ * @return The old TCCL if a new one is set, otherwise null
+ */
+ public static ClassLoader setContextClassLoader(ClassLoader parent, ServiceDiscovery discovery, String... serviceNames) {
+ ClassLoaderContext context = new ClassLoaderContext(parent, discovery, serviceNames);
+ return context.setContextClassLoader();
+ }
+
+ /**
+ * Set the context classloader so that it can access the list of service providers
+ * @param parent The parent classloader
+ * @param serviceNames A list of service provider names
+ * @return The old TCCL if a new one is set, otherwise null
+ */
+ public static ClassLoader setContextClassLoader(ClassLoader parent, ServiceDiscovery discovery, Class<?>... serviceTypes) {
+ ClassLoaderContext context = new ClassLoaderContext(parent, discovery, serviceTypes);
+ return context.setContextClassLoader();
+ }
+
+ public ClassLoader setContextClassLoader() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ if (tccl != classLoader) {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return tccl;
+ } else {
+ return null;
+ }
+ }
+
+ private static ClassLoader getClassLoader(ServiceDiscovery discovery, String serviceProvider) {
+ try {
+ ServiceDeclaration sd = discovery.getServiceDeclaration(serviceProvider);
+ if (sd != null) {
+ return sd.loadClass().getClassLoader();
+ }
+ } catch (Exception e) {
+ // Ignore
+ }
+ return null;
+ }
+
+ private static List<ClassLoader> getClassLoaders(ServiceDiscovery discovery, String... serviceNames) {
+ List<ClassLoader> loaders = new ArrayList<ClassLoader>();
+ for (String sp : serviceNames) {
+ ClassLoader loader = getClassLoader(discovery, sp);
+ if (loader != null) {
+ if (!loaders.contains(loader)) {
+ loaders.add(loader);
+ }
+ }
+ }
+ ClassLoader tccl = discovery.getContextClassLoader();
+ if (!loaders.contains(tccl)) {
+ loaders.add(tccl);
+ }
+ return loaders;
+ }
+
+ private static ClassLoader getClassLoader(ServiceDiscovery discovery, Class<?> serviceType) {
+ try {
+ ServiceDeclaration sd = discovery.getServiceDeclaration(serviceType);
+ if (sd != null) {
+ return sd.loadClass().getClassLoader();
+ }
+ } catch (Exception e) {
+ // Ignore
+ }
+ return null;
+ }
+
+ private static List<ClassLoader> getClassLoaders(ServiceDiscovery discovery, Class<?>... serviceTypes) {
+ List<ClassLoader> loaders = new ArrayList<ClassLoader>();
+ for (Class<?> serviceType : serviceTypes) {
+ ClassLoader classLoader = getClassLoader(discovery, serviceType);
+ if (classLoader != null && loaders.contains(classLoader)) {
+ loaders.add(classLoader);
+ }
+ }
+ ClassLoader tccl = discovery.getContextClassLoader();
+ if (!loaders.contains(tccl)) {
+ loaders.add(tccl);
+ }
+ return loaders;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
new file mode 100644
index 0000000000..eec4ff1734
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility;
+
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * A ServiceDiscoverer that find META-INF/services/... using the Context ClassLoader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContextClassLoaderServiceDiscoverer implements ServiceDiscoverer {
+ private static final Logger logger = Logger.getLogger(ContextClassLoaderServiceDiscoverer.class.getName());
+
+ public class ServiceDeclarationImpl implements ServiceDeclaration {
+ private URL url;
+ private String className;
+ private Class<?> javaClass;
+ private Map<String, String> attributes;
+
+ public ServiceDeclarationImpl(URL url, String className, Map<String, String> attributes) {
+ super();
+ this.url = url;
+ this.className = className;
+ this.attributes = attributes;
+ }
+
+ public Map<String, String> getAttributes() {
+ return attributes;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public URL getLocation() {
+ return url;
+ }
+
+ public Class<?> loadClass() throws ClassNotFoundException {
+ if (className == null) {
+ return null;
+ }
+ if (javaClass == null) {
+ javaClass = loadClass(className);
+ }
+ return javaClass;
+ }
+
+ public Class<?> loadClass(String className) throws ClassNotFoundException {
+ return Class.forName(className, false, classLoaderReference.get());
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Location: ").append(url);
+ sb.append(" ClassLoader: ").append(classLoaderReference.get());
+ sb.append(" Attributes: ").append(attributes);
+ return sb.toString();
+ }
+
+ public URL getResource(final String name) {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return classLoaderReference.get().getResource(name);
+ }
+ });
+ }
+
+ public boolean isAssignableTo(Class<?> serviceType) {
+ try {
+ loadClass();
+ } catch (ClassNotFoundException e) {
+ // Ignore
+ }
+ return (javaClass != null && serviceType.isAssignableFrom(javaClass));
+ }
+ }
+
+ private WeakReference<ClassLoader> classLoaderReference;
+
+ public ContextClassLoaderServiceDiscoverer() {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ this.classLoaderReference = new WeakReference<ClassLoader>(classLoader);
+ }
+
+ public ContextClassLoaderServiceDiscoverer(ClassLoader classLoader) {
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ this.classLoaderReference = new WeakReference<ClassLoader>(classLoader);
+ }
+
+ public ClassLoader getContextClassLoader() {
+ //return classLoaderReference.get();
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ private Collection<URL> getResources(final String name) throws IOException {
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Collection<URL>>() {
+ public Collection<URL> run() throws IOException {
+ List<URL> urls = Collections.list(classLoaderReference.get().getResources(name));
+ // Eliminate the duplicate URLs (which can be found from child/parent classloaders)
+ return new HashSet<URL>(urls);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (IOException)e.getException();
+ }
+ }
+
+ public ServiceDeclaration getServiceDeclaration(String name) throws IOException {
+ Collection<ServiceDeclaration> declarations = getServiceDeclarations(name);
+ if (declarations.isEmpty()) {
+ return null;
+ } else {
+ return declarations.iterator().next();
+ }
+ }
+
+ public Collection<ServiceDeclaration> getServiceDeclarations(String serviceName) {
+ Collection<ServiceDeclaration> descriptors = new HashSet<ServiceDeclaration>();
+
+ // http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/xpath/XPathFactory.html
+ boolean isPropertyFile = "javax.xml.xpath.XPathFactory".equals(serviceName);
+ String name = "META-INF/services/" + serviceName;
+ boolean debug = logger.isLoggable(Level.FINE);
+ try {
+ for (final URL url : getResources(name)) {
+ if (debug) {
+ logger.fine("Reading service provider file: " + url.toExternalForm());
+ }
+
+ for (Map<String, String> attributes : ServiceDeclarationParser.load(url, isPropertyFile)) {
+ String className = attributes.get("class");
+ ServiceDeclarationImpl descriptor = new ServiceDeclarationImpl(url, className, attributes);
+ descriptors.add(descriptor);
+ }
+ }
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ return descriptors;
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java
new file mode 100644
index 0000000000..47a91aabfe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.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.sca.extensibility;
+
+import java.net.URL;
+import java.util.Map;
+
+/**
+ * Service declaration using J2SE Jar service provider spec Classes specified
+ * inside this declaration are loaded using the ClassLoader used to read the
+ * configuration file corresponding to this declaration.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ServiceDeclaration {
+ /**
+ * Load a java class in the same context as the service definition
+ * @param className The class name
+ * @return The loaded class
+ * @throws ClassNotFoundException
+ */
+ Class<?> loadClass(String className) throws ClassNotFoundException;
+
+ /**
+ * Get the java class for the service impl
+ * @return The java class
+ */
+ Class<?> loadClass() throws ClassNotFoundException;
+
+ /**
+ * Get all attributes (name=value pairs) defined for the given entry
+ * @return All attributes keyed by name
+ */
+ Map<String, String> getAttributes();
+
+ /**
+ * Check if the service implementation class is a type of the service
+ * @param serviceType The java class of the service SPI
+ * @return true if the implementation class is a type of the service
+ */
+ boolean isAssignableTo(Class<?> serviceType);
+
+ URL getLocation();
+
+ /**
+ * Return the class name for the service provider
+ * @return
+ */
+ String getClassName();
+
+ URL getResource(String name);
+
+ /**
+ * The service descriptor might be hashed
+ * @param obj Another object
+ * @return
+ */
+ boolean equals(Object obj);
+ /**
+ * The service descriptor might be hashed
+ * @return
+ */
+ int hashCode();
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.java
new file mode 100644
index 0000000000..f546e44dfb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.java
@@ -0,0 +1,375 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Parser for the service descriptors. The syntax of the service declaration is similar with the OSGi
+ * headers with the following exceptions:
+ * <ul>
+ * <li>Tuscany uses , and ; as the separator for attibutes
+ * <li>Tuscany
+ */
+public class ServiceDeclarationParser {
+
+ // private static final String PATH_SEPARATOR = ","; // OSGi style
+ private static final String PATH_SEPARATOR = "|";
+
+ // private static final String SEGMENT_SEPARATOR = ";"; // OSGi style
+ private static final String SEGMENT_SEPARATOR = ";,";
+
+ private static final String ATTRIBUTE_SEPARATOR = "=";
+ private static final String DIRECTIVE_SEPARATOR = ":=";
+
+ private static final char QUOTE_CHAR = '"';
+ private static final String QUOTE = "\"";
+
+ // Like this: path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2,
+ // path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2
+ public static List<Descriptor> parse(String header) {
+
+ if (header != null) {
+ if (header.length() == 0) {
+ throw new IllegalArgumentException("A header cannot be an empty string.");
+ }
+
+ String[] clauseStrings = parseDelimitedString(header, PATH_SEPARATOR);
+
+ List<Descriptor> completeList = new ArrayList<Descriptor>();
+ for (int i = 0; (clauseStrings != null) && (i < clauseStrings.length); i++) {
+ completeList.add(parseClause(clauseStrings[i]));
+ }
+
+ return completeList;
+ }
+
+ return null;
+
+ }
+
+ /**
+ * Parse the declaration into a map of name/value pairs. The class name is added under "class"
+ * and directives are added using @<directiveName> as the key.
+ * @param declaration
+ * @return A map of attributes
+ */
+ public static Map<String, String> parseDeclaration(String declaration) {
+ List<Descriptor> descriptors = parse(declaration);
+ Descriptor descriptor = descriptors.get(0);
+ Map<String, String> map = new HashMap<String, String>();
+ map.putAll(descriptor.getAttributes());
+ map.put("class", descriptor.getValue());
+ for (Map.Entry<String, String> e : descriptor.getDirectives().entrySet()) {
+ // For directives, add @ as the prefix for the key
+ map.put("@" + e.getKey(), e.getValue());
+ }
+ return map;
+ }
+
+ // Like this: path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2
+ private static Descriptor parseClause(String clauseString) throws IllegalArgumentException {
+ // Break string into semi-colon delimited pieces.
+ String[] pieces = parseDelimitedString(clauseString, SEGMENT_SEPARATOR);
+
+ // Count the number of different paths; paths
+ // will not have an '=' in their string. This assumes
+ // that paths come first, before directives and
+ // attributes.
+ int pathCount = 0;
+ for (int pieceIdx = 0; pieceIdx < pieces.length; pieceIdx++) {
+ if (pieces[pieceIdx].indexOf('=') >= 0) {
+ break;
+ }
+ pathCount++;
+ }
+
+ // Create an array of paths.
+ String[] paths = new String[pathCount];
+ System.arraycopy(pieces, 0, paths, 0, pathCount);
+
+ // Parse the directives/attributes.
+ Map<String, String> dirsMap = new HashMap<String, String>();
+ Map<String, String> attrsMap = new HashMap<String, String>();
+ int idx = -1;
+ String sep = null;
+ for (int pieceIdx = pathCount; pieceIdx < pieces.length; pieceIdx++) {
+ // Check if it is a directive.
+ if ((idx = pieces[pieceIdx].indexOf(DIRECTIVE_SEPARATOR)) >= 0) {
+ sep = DIRECTIVE_SEPARATOR;
+ }
+ // Check if it is an attribute.
+ else if ((idx = pieces[pieceIdx].indexOf(ATTRIBUTE_SEPARATOR)) >= 0) {
+ sep = ATTRIBUTE_SEPARATOR;
+ }
+ // It is an error.
+ else {
+ throw new IllegalArgumentException("Not a directive/attribute: " + clauseString);
+ }
+
+ String key = pieces[pieceIdx].substring(0, idx).trim();
+ String value = pieces[pieceIdx].substring(idx + sep.length()).trim();
+
+ // Remove quotes, if value is quoted.
+ if (value.startsWith(QUOTE) && value.endsWith(QUOTE)) {
+ value = value.substring(1, value.length() - 1);
+ }
+
+ // Save the directive/attribute in the appropriate array.
+ if (sep.equals(DIRECTIVE_SEPARATOR)) {
+ // Check for duplicates.
+ if (dirsMap.get(key) != null) {
+ throw new IllegalArgumentException("Duplicate directive: " + key);
+ }
+ dirsMap.put(key, value);
+ } else {
+ // Check for duplicates.
+ if (attrsMap.get(key) != null) {
+ throw new IllegalArgumentException("Duplicate attribute: " + key);
+ }
+ attrsMap.put(key, value);
+ }
+ }
+
+ StringBuffer path = new StringBuffer();
+ for (int i = 0; i < paths.length; i++) {
+ path.append(paths[i]);
+ if (i != paths.length - 1) {
+ path.append(';');
+ }
+ }
+
+ Descriptor descriptor = new Descriptor();
+ descriptor.text = clauseString;
+ descriptor.value = path.toString();
+ descriptor.valueComponents = paths;
+ descriptor.attributes = attrsMap;
+ descriptor.directives = dirsMap;
+
+ return descriptor;
+ }
+
+ /**
+ * Parses delimited string and returns an array containing the tokens. This
+ * parser obeys quotes, so the delimiter character will be ignored if it is
+ * inside of a quote. This method assumes that the quote character is not
+ * included in the set of delimiter characters.
+ * @param value the delimited string to parse.
+ * @param delim the characters delimiting the tokens.
+ * @return an array of string tokens or null if there were no tokens.
+ **/
+ private static String[] parseDelimitedString(String value, String delim) {
+ if (value == null) {
+ value = "";
+ }
+
+ List<String> list = new ArrayList<String>();
+
+ int CHAR = 1;
+ int DELIMITER = 2;
+ int STARTQUOTE = 4;
+ int ENDQUOTE = 8;
+
+ StringBuffer sb = new StringBuffer();
+
+ int expecting = (CHAR | DELIMITER | STARTQUOTE);
+
+ for (int i = 0; i < value.length(); i++) {
+ char c = value.charAt(i);
+
+ boolean isDelimiter = (delim.indexOf(c) >= 0);
+ boolean isQuote = (c == QUOTE_CHAR);
+
+ if (isDelimiter && ((expecting & DELIMITER) > 0)) {
+ list.add(sb.toString().trim());
+ sb.delete(0, sb.length());
+ expecting = (CHAR | DELIMITER | STARTQUOTE);
+ } else if (isQuote && ((expecting & STARTQUOTE) > 0)) {
+ sb.append(c);
+ expecting = CHAR | ENDQUOTE;
+ } else if (isQuote && ((expecting & ENDQUOTE) > 0)) {
+ sb.append(c);
+ expecting = (CHAR | STARTQUOTE | DELIMITER);
+ } else if ((expecting & CHAR) > 0) {
+ sb.append(c);
+ } else {
+ throw new IllegalArgumentException("Invalid delimited string: " + value);
+ }
+ }
+
+ if (sb.length() > 0) {
+ list.add(sb.toString().trim());
+ }
+
+ return (String[])list.toArray(new String[list.size()]);
+ }
+
+ public static class Descriptor {
+ private String text;
+ private String value;
+ private String[] valueComponents;
+ private Map<String, String> attributes;
+ private Map<String, String> directives;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String[] getValueComponents() {
+ return valueComponents;
+ }
+
+ public void setValueComponents(String[] valueComponents) {
+ this.valueComponents = valueComponents;
+ }
+
+ public Map<String, String> getAttributes() {
+ return attributes;
+ }
+
+ public Map<String, String> getDirectives() {
+ return directives;
+ }
+
+ public String toString() {
+ return text;
+ }
+
+ }
+
+ /**
+ * Returns a QName object from a QName expressed as {ns}name
+ * or ns#name.
+ *
+ * @param qname
+ * @return
+ */
+ public static QName getQName(String qname) {
+ if (qname == null) {
+ return null;
+ }
+ qname = qname.trim();
+ if (qname.startsWith("{")) {
+ int h = qname.indexOf('}');
+ if (h != -1) {
+ return new QName(qname.substring(1, h), qname.substring(h + 1));
+ }
+ } else {
+ int h = qname.indexOf('#');
+ if (h != -1) {
+ return new QName(qname.substring(0, h), qname.substring(h + 1));
+ }
+ }
+ return new QName(qname);
+ }
+
+ public static Collection<Map<String, String>> load(final URL url, boolean isPropertyFile) throws IOException {
+ Collection<Map<String, String>> descriptors = new ArrayList<Map<String, String>>();
+
+ // Allow privileged access to open URL stream. Add FilePermission to added to security
+ // policy file.
+ InputStream is;
+ try {
+ is = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() {
+ public InputStream run() throws IOException {
+ URLConnection connection = url.openConnection();
+ // TUSCANY-2539
+ // Don't cache connections by default to stop Tuscany locking contribution jar files
+ // done here as this is one of the first places we open a stream and the only way to
+ // set the default is to set it on an instance of URLConnection
+ connection.setDefaultUseCaches(false);
+ connection.setUseCaches(false);
+ return url.openStream();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (IOException)e.getException();
+ }
+ if (isPropertyFile) {
+ // Load as a property file
+ Properties props = new Properties();
+ props.load(is);
+ is.close();
+ for (Map.Entry<Object, Object> e : props.entrySet()) {
+ Map<String, String> attributes = new HashMap<String, String>();
+ String key = (String)e.getKey();
+ String value = (String)e.getValue();
+ // Unfortunately, the xalan file only has the classname
+ if (value == null || "".equals(value)) {
+ value = key;
+ key = "";
+ }
+ if (!"".equals(key)) {
+ attributes.put(key, value);
+ attributes.put("uri", key);
+ }
+ attributes.putAll(parseDeclaration(value));
+ descriptors.add(attributes);
+ }
+ return descriptors;
+ }
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ while (true) {
+ String line = reader.readLine();
+ if (line == null)
+ break;
+ line = line.trim();
+ if (!line.startsWith("#") && !"".equals(line)) {
+ String reg = line.trim();
+
+ Map<String, String> attributes = parseDeclaration(reg);
+ descriptors.add(attributes);
+ }
+ }
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ return descriptors;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java
new file mode 100644
index 0000000000..aebd6cd3de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.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.sca.extensibility;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * A SPI that allows different implementations of discovering service declarations
+ */
+public interface ServiceDiscoverer {
+
+ /**
+ * Get all service declarations for this interface
+ *
+ * @param name
+ * @return set of service declarations
+ * @throws IOException
+ */
+ public Collection<ServiceDeclaration> getServiceDeclarations(String name) throws IOException;
+
+ /**
+ * Get first service declaration class for the given interface
+ *
+ * @param name
+ * @return service implementation class
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ public ServiceDeclaration getServiceDeclaration(String name) throws IOException;
+
+ /**
+ * Get a classloader that can be used for thread context loader
+ * @return A classloader that can provide access to public classes and resources
+ */
+ public ClassLoader getContextClassLoader();
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
new file mode 100644
index 0000000000..f99f682e07
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
@@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.extensibility.impl.LDAPFilter;
+
+/**
+ * Service discovery for Tuscany based on J2SE Jar service provider spec.
+ * Services are described using configuration files in META-INF/services.
+ * Service description specifies a class name followed by optional properties.
+ *
+ * TODO: this is broken as it uses a static INSTANCE but non-static serviceAttributes
+ * and discoverer so the same INSTANCE gets used across NodeFactories and picks up
+ * old values
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public final class ServiceDiscovery implements ServiceDiscoverer {
+ private final static Logger logger = Logger.getLogger(ServiceDiscovery.class.getName());
+ private final static ServiceDiscovery INSTANCE = new ServiceDiscovery();
+
+ private final Map<String, Map<String, String>> serviceAttributes = new HashMap<String, Map<String, String>>();
+ private ServiceDiscoverer discoverer;
+
+ private ServiceDiscovery() {
+ super();
+ }
+
+ private ServiceDiscovery(ServiceDiscoverer discoverer) {
+ super();
+ this.discoverer = discoverer;
+ }
+
+ /**
+ * Get an instance of Service discovery, one instance is created per
+ * ClassLoader that this class is loaded from
+ *
+ * @return
+ */
+ public static ServiceDiscovery getInstance() {
+ return INSTANCE;
+ }
+
+ public static ServiceDiscovery getInstance(ServiceDiscoverer discoverer) {
+ return new ServiceDiscovery(discoverer);
+ }
+
+ public ServiceDiscoverer getServiceDiscoverer() {
+ if (discoverer != null) {
+ return discoverer;
+ }
+ try {
+ // FIXME: This is a hack to trigger the activation of the extensibility-equinox bundle in OSGi
+ Class.forName("org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoverer");
+ if (discoverer != null) {
+ return discoverer;
+ }
+ } catch (Throwable e) {
+ }
+ discoverer = new ContextClassLoaderServiceDiscoverer(getClass().getClassLoader());
+ return discoverer;
+ }
+
+ public void setServiceDiscoverer(ServiceDiscoverer sd) {
+ if (discoverer != null && sd != null) {
+ logger.warning("ServiceDiscoverer is reset to " + sd);
+ }
+ discoverer = sd;
+ }
+
+ public Collection<ServiceDeclaration> getServiceDeclarations(String name) throws IOException {
+ return getServiceDeclarations(name, false);
+ }
+
+ public Collection<ServiceDeclaration> getServiceDeclarations(String name, boolean byRanking) throws IOException {
+ Collection<ServiceDeclaration> declarations = getServiceDiscoverer().getServiceDeclarations(name);
+ // Check if any of the service declarations has attributes that are overrided
+ if (!serviceAttributes.isEmpty()) {
+ for (ServiceDeclaration declaration : declarations) {
+ Map<String, String> attrs = getAttributes(name);
+ if (attrs != null) {
+ declaration.getAttributes().putAll(attrs);
+ }
+ }
+ }
+ if (!byRanking) {
+ return declarations;
+ }
+ if (!declarations.isEmpty()) {
+ List<ServiceDeclaration> declarationList = new ArrayList<ServiceDeclaration>(declarations);
+ /*
+ for (ServiceDeclaration sd1 : declarations) {
+ for (Iterator<ServiceDeclaration> i = declarationList.iterator(); i.hasNext();) {
+ ServiceDeclaration sd2 = i.next();
+ if (sd1 != sd2 && sd1.getAttributes().equals(sd2.getAttributes())) {
+ logger
+ .warning("Duplicate service declarations: " + sd1.getLocation() + "," + sd2.getLocation());
+ i.remove();
+ }
+ }
+ }
+ */
+ Collections.sort(declarationList, ServiceComparator.DESCENDING_ORDER);
+ return declarationList;
+ } else {
+ return Collections.emptyList();
+ }
+ }
+
+ /**
+ * Get the service declaration. If there are more than one services, the one with highest ranking will
+ * be returned.
+ */
+ public ServiceDeclaration getServiceDeclaration(final String name) throws IOException {
+ Collection<ServiceDeclaration> declarations = getServiceDeclarations(name, true);
+ if (!declarations.isEmpty()) {
+ // List<ServiceDeclaration> declarationList = new ArrayList<ServiceDeclaration>(declarations);
+ // Collections.sort(declarationList, ServiceComparator.DESCENDING_ORDER);
+ return declarations.iterator().next();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Get service declarations that are filtered by the service type. In an OSGi runtime, there
+ * might be different versions of the services
+ * @param serviceType
+ * @return
+ * @throws IOException
+ */
+ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType, boolean byRanking)
+ throws IOException {
+ Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType.getName(), byRanking);
+ for (Iterator<ServiceDeclaration> i = sds.iterator(); i.hasNext();) {
+ ServiceDeclaration sd = i.next();
+ if (!sd.isAssignableTo(serviceType)) {
+ logger.log(Level.WARNING, "Service provider {0} is not a type of {1}", new Object[] {sd,serviceType.getName()});
+ i.remove();
+ }
+ }
+ return sds;
+ }
+
+ /**
+ * Discover all service providers that are compatible with the service type
+ * @param serviceType
+ * @return
+ * @throws IOException
+ */
+ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType) throws IOException {
+ return getServiceDeclarations(serviceType, false);
+ }
+
+ /**
+ * Discover all service providers that are compatible with the service type and match the filter
+ * @param serviceType
+ * @param filter
+ * @return
+ * @throws IOException
+ */
+ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType, String filter) throws IOException {
+ Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType, false);
+ Collection<ServiceDeclaration> filtered = new ArrayList<ServiceDeclaration>();
+ LDAPFilter filterImpl = LDAPFilter.newInstance(filter);
+ for(ServiceDeclaration sd: sds) {
+ if(filterImpl.match(sd.getAttributes())) {
+ filtered.add(sd);
+ }
+ }
+ return filtered;
+ }
+
+ /**
+ * @param serviceName
+ * @param filter
+ * @return
+ * @throws IOException
+ */
+ public Collection<ServiceDeclaration> getServiceDeclarations(String serviceName, String filter) throws IOException {
+ Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceName, false);
+ Collection<ServiceDeclaration> filtered = new ArrayList<ServiceDeclaration>();
+ LDAPFilter filterImpl = LDAPFilter.newInstance(filter);
+ for(ServiceDeclaration sd: sds) {
+ if(filterImpl.match(sd.getAttributes())) {
+ filtered.add(sd);
+ }
+ }
+ return filtered;
+ }
+
+ public ServiceDeclaration getServiceDeclaration(Class<?> serviceType) throws IOException {
+ Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType, true);
+ if (sds.isEmpty()) {
+ return null;
+ } else {
+ return sds.iterator().next();
+ }
+ }
+
+ /**
+ * Compare service declarations by ranking
+ */
+ private static class ServiceComparator implements Comparator<ServiceDeclaration> {
+ private final static Comparator<ServiceDeclaration> DESCENDING_ORDER = new ServiceComparator();
+
+ public int compare(ServiceDeclaration o1, ServiceDeclaration o2) {
+ int rank1 = 0;
+ String r1 = o1.getAttributes().get("ranking");
+ if (r1 != null) {
+ rank1 = Integer.parseInt(r1);
+ }
+ int rank2 = 0;
+ String r2 = o2.getAttributes().get("ranking");
+ if (r2 != null) {
+ rank2 = Integer.parseInt(r2);
+ }
+ return rank2 - rank1; // descending
+ }
+ }
+
+ public ClassLoader getContextClassLoader() {
+ return discoverer.getContextClassLoader();
+ }
+
+ /**
+ * Set the attributes for a given service type
+ * @param serviceType
+ * @param attributes
+ */
+ public void setAttribute(String serviceType, Map<String, String> attributes) {
+ serviceAttributes.put(serviceType, attributes);
+ }
+
+ /**
+ * Set an attribute to the given value for a service type
+ * @param serviceType The service type
+ * @param attribute The attribute name
+ * @param value The attribute value
+ */
+ public void setAttribute(String serviceType, String attribute, String value) {
+ Map<String, String> attributes = serviceAttributes.get(serviceType);
+ if (attributes == null) {
+ attributes = new HashMap<String, String>();
+ serviceAttributes.put(serviceType, attributes);
+ }
+ attributes.put(attribute, value);
+ }
+
+ /**
+ * Return a map of attributes for a given service type
+ * @param serviceType
+ * @return
+ */
+ public Map<String, String> getAttributes(String serviceType) {
+ return serviceAttributes.get(serviceType);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java
new file mode 100644
index 0000000000..7f38aa6d06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.extensibility;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+
+/**
+ * A helper for handling service lifecycle and instantiations
+ * @tuscany.spi.extension.asclient
+ */
+public class ServiceHelper {
+ private ServiceHelper() {
+ }
+
+ /**
+ * Start the service instance
+ * @param instance
+ */
+ public static boolean start(Object instance) {
+ if (instance instanceof LifeCycleListener) {
+ ((LifeCycleListener)instance).start();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Stop the service instance
+ * @param instance
+ */
+ public static boolean stop(Object instance) {
+ if (instance instanceof LifeCycleListener) {
+ ((LifeCycleListener)instance).stop();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Stop a collection of service instances
+ * @param instances
+ */
+ public static void stop(Collection<? extends Object> instances) {
+ if (instances == null) {
+ return;
+ }
+ for (Object instance : instances) {
+ if (instance instanceof LifeCycleListener) {
+ ((LifeCycleListener)instance).stop();
+ }
+ }
+ }
+
+ /**
+ * Create a service instance with one parameter
+ * @param cls The service type
+ * @param parameterType The parameter type
+ * @param parameter The parameter value
+ * @return The newly created service instance
+ * @throws Exception
+ */
+ public static <T> T newInstance(Class<T> cls, Class<?> parameterType, Object parameter) throws Exception {
+ Constructor<T> constructor = cls.getConstructor(parameterType);
+ return constructor.newInstance(parameter);
+ }
+
+ /**
+ * Create a service instance with an array of parameters
+ * @param cls The service type
+ * @param parameterTypes An array of parameter types
+ * @param parameters An array of parameter values
+ * @return The newly created service instance
+ * @throws Exception
+ */
+ public static <T> T newInstance(Class<T> cls, Class<?> parameterTypes[], Object... parameters) throws Exception {
+ Constructor<T> constructor = cls.getConstructor(parameterTypes);
+ return constructor.newInstance(parameters);
+ }
+
+ /**
+ * Create a service instance with the default no-arg constructor
+ * @param cls The service type
+ * @return The newly created service instance
+ * @throws Exception
+ */
+ public static <T> T newInstance(Class<T> cls) throws Exception {
+ Constructor<T> constructor = cls.getConstructor();
+ return constructor.newInstance();
+ }
+
+ private final static Class<?>[] ARG_TYPES = new Class<?>[] {ExtensionPointRegistry.class, Map.class};
+
+ /**
+ * Create a service instance from the service declaration
+ * @param <T>
+ * @param registry The extension point registry
+ * @param sd The service declaration
+ * @return The newly created service instance
+ * @throws Exception
+ */
+ public static <T> T newInstance(ExtensionPointRegistry registry, ServiceDeclaration sd) throws Exception {
+ Class<T> cls = (Class<T>)sd.loadClass();
+ T instance = null;
+ try {
+ // Try constructor(ExtensionPointRegistry.class)
+ instance = newInstance(cls, ExtensionPointRegistry.class, registry);
+ } catch (NoSuchMethodException e) {
+ try {
+ // Try Try constructor(ExtensionPointRegistry.class, Map.class)
+ instance = newInstance(cls, ARG_TYPES, registry, sd.getAttributes());
+ } catch (NoSuchMethodException e1) {
+ // Try constructor()
+ instance = newInstance(cls);
+ }
+ }
+ return instance;
+ }
+
+ public static <T> T newLazyInstance(ExtensionPointRegistry registry, ServiceDeclaration sd, Class<T> serviceType) {
+ return serviceType.cast(Proxy.newProxyInstance(serviceType.getClassLoader(),
+ new Class<?>[] {serviceType, LifeCycleListener.class},
+ new InvocationHandlerImpl(registry, serviceType, sd)));
+ }
+
+ private static class InvocationHandlerImpl implements InvocationHandler {
+ private ExtensionPointRegistry registry;
+ private Class<?> type;
+ private ServiceDeclaration sd;
+ private Object instance;
+
+ private final static Method STOP_METHOD = getMethod(LifeCycleListener.class, "stop");
+ private final static Method START_METHOD = getMethod(LifeCycleListener.class, "start");
+ private final static Method EQUALS_METHOD = getMethod(Object.class, "equals");
+ private final static Method HASHCODE_METHOD = getMethod(Object.class, "hashCode");
+ private final static Method TOSTRING_METHOD = getMethod(Object.class, "toString");
+
+ private static Method getMethod(Class<?> type, String name) {
+ Method[] methods = type.getMethods();
+ for (Method method : methods) {
+ if (name.equals(method.getName())) {
+ return method;
+ }
+ }
+ return null;
+ }
+
+ public InvocationHandlerImpl(ExtensionPointRegistry registry, Class<?> type, ServiceDeclaration sd) {
+ super();
+ this.registry = registry;
+ this.sd = sd;
+ this.type = type;
+ }
+
+ private Object getAttribute(Method method) throws Exception {
+ if (method.getParameterTypes().length != 0) {
+ return null;
+ }
+ String name = method.getName();
+ if (name.equals("getModelType") && method.getReturnType() == Class.class) {
+ return sd.loadClass(sd.getAttributes().get("model"));
+ } else if (name.equals("getArtifactType")) {
+ return ServiceDeclarationParser.getQName(sd.getAttributes().get("qname"));
+ }
+ return null;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ synchronized (this) {
+ // Check if the method is to get the qname/model attribute
+ Object value = getAttribute(method);
+ if (value != null) {
+ return value;
+ }
+ if (instance == null && method.getDeclaringClass() == type) {
+ // Only initialize the instance when a method on the service type is invoked
+ instance = newInstance(registry, sd);
+ start(instance);
+ }
+ if (method.equals(EQUALS_METHOD)) {
+ return proxy == args[0];
+ } else if (method.equals(HASHCODE_METHOD)) {
+ return System.identityHashCode(proxy);
+ } else if (method.equals(TOSTRING_METHOD)) {
+ return "Proxy: " + sd.toString();
+ }
+ if (instance == null) {
+ return null;
+ }
+ }
+ if (method.equals(STOP_METHOD)) {
+ stop(instance);
+ return null;
+ } else if (method.equals(START_METHOD)) {
+ // Skip the start()
+ return null;
+ } else {
+ return method.invoke(instance, args);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/ClassLoaderDelegate.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/ClassLoaderDelegate.java
new file mode 100644
index 0000000000..d052d6b10f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/ClassLoaderDelegate.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.sca.extensibility.impl;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A classloader that can delegate to a list of other classloaders
+ */
+public class ClassLoaderDelegate extends ClassLoader {
+ private final List<ClassLoader> classLoaders = new ArrayList<ClassLoader>();
+
+ /**
+ * @param parent The parent classloaders
+ * @param loaders A list of classloaders to be used to load classes or resources
+ */
+ public ClassLoaderDelegate(ClassLoader parent, Collection<ClassLoader> loaders) {
+ super(parent);
+ if (loaders != null) {
+ for (ClassLoader cl : loaders) {
+ if (cl != null && cl != parent && !classLoaders.contains(cl)) {
+ this.classLoaders.add(cl);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected Class<?> findClass(String className) throws ClassNotFoundException {
+ for (ClassLoader delegate : classLoaders) {
+ try {
+ return delegate.loadClass(className);
+ } catch (ClassNotFoundException e) {
+ continue;
+ }
+ }
+ throw new ClassNotFoundException(className);
+ }
+
+ @Override
+ protected URL findResource(String resName) {
+ for (ClassLoader delegate : classLoaders) {
+ URL url = delegate.getResource(resName);
+ if (url != null) {
+ return url;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(String resName) throws IOException {
+ Set<URL> urlSet = new HashSet<URL>();
+ for (ClassLoader delegate : classLoaders) {
+ Enumeration<URL> urls = delegate.getResources(resName);
+ if (urls != null) {
+ while (urls.hasMoreElements()) {
+ urlSet.add(urls.nextElement());
+ }
+ }
+ }
+ return Collections.enumeration(urlSet);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java
new file mode 100644
index 0000000000..77f6f3e8db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility.impl;
+
+/**
+ * A Framework exception used to indicate that a filter string has an invalid
+ * syntax.
+ *
+ * <p>
+ * An <code>InvalidSyntaxException</code> object indicates that a filter
+ * string parameter has an invalid syntax and cannot be parsed.
+ *
+ * <p>
+ * This exception conforms to the general purpose exception chaining mechanism.
+ *
+ */
+
+public class InvalidSyntaxException extends RuntimeException {
+ static final long serialVersionUID = -4295194420816491875L;
+ /**
+ * The invalid filter string.
+ */
+ private final String filter;
+
+ /**
+ * Creates an exception of type <code>InvalidSyntaxException</code>.
+ *
+ * <p>
+ * This method creates an <code>InvalidSyntaxException</code> object with
+ * the specified message and the filter string which generated the
+ * exception.
+ *
+ * @param msg The message.
+ * @param filter The invalid filter string.
+ */
+ public InvalidSyntaxException(String msg, String filter) {
+ super(msg);
+ this.filter = filter;
+ }
+
+ /**
+ * Creates an exception of type <code>InvalidSyntaxException</code>.
+ *
+ * <p>
+ * This method creates an <code>InvalidSyntaxException</code> object with
+ * the specified message and the filter string which generated the
+ * exception.
+ *
+ * @param msg The message.
+ * @param filter The invalid filter string.
+ * @param cause The cause of this exception.
+ * @since 1.3
+ */
+ public InvalidSyntaxException(String msg, String filter, Throwable cause) {
+ super(msg, cause);
+ this.filter = filter;
+ }
+
+ /**
+ * Returns the filter string that generated the
+ * <code>InvalidSyntaxException</code> object.
+ *
+ * @return The invalid filter string.
+ * @see BundleContext#getServiceReferences
+ * @see BundleContext#addServiceListener(ServiceListener,String)
+ */
+ public String getFilter() {
+ return filter;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java
new file mode 100644
index 0000000000..8d3630baa4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java
@@ -0,0 +1,1373 @@
+/*
+ * Copyright (c) OSGi Alliance (2005, 2009). All Rights Reserved.
+ *
+ * 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.extensibility.impl;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+
+
+/**
+ * This code is derived from <a href="http://svn.apache.org/repos/asf/felix/releases/org.osgi.core-1.4.0/src/main/java/org/osgi/framework/FrameworkUtil.java">FrameworkUtil</a>
+ * <p>
+ * RFC 1960-based Filter. Filter objects can be created by calling the
+ * constructor with the desired filter string. A Filter object can be called
+ * numerous times to determine if the match argument matches the filter
+ * string that was used to create the Filter object.
+ *
+ * <p>
+ * The syntax of a filter string is the string representation of LDAP search
+ * filters as defined in RFC 1960: <i>A String Representation of LDAP Search
+ * Filters</i> (available at http://www.ietf.org/rfc/rfc1960.txt). It should
+ * be noted that RFC 2254: <i>A String Representation of LDAP Search
+ * Filters</i> (available at http://www.ietf.org/rfc/rfc2254.txt) supersedes
+ * RFC 1960 but only adds extensible matching and is not applicable for this
+ * API.
+ *
+ * <p>
+ * The string representation of an LDAP search filter is defined by the
+ * following grammar. It uses a prefix format.
+ *
+ * <pre>
+ * &lt;filter&gt; ::= '(' &lt;filtercomp&gt; ')'
+ * &lt;filtercomp&gt; ::= &lt;and&gt; | &lt;or&gt; | &lt;not&gt; | &lt;item&gt;
+ * &lt;and&gt; ::= '&amp;' &lt;filterlist&gt;
+ * &lt;or&gt; ::= '|' &lt;filterlist&gt;
+ * &lt;not&gt; ::= '!' &lt;filter&gt;
+ * &lt;filterlist&gt; ::= &lt;filter&gt; | &lt;filter&gt; &lt;filterlist&gt;
+ * &lt;item&gt; ::= &lt;simple&gt; | &lt;present&gt; | &lt;substring&gt;
+ * &lt;simple&gt; ::= &lt;attr&gt; &lt;filtertype&gt; &lt;value&gt;
+ * &lt;filtertype&gt; ::= &lt;equal&gt; | &lt;approx&gt; | &lt;greater&gt; | &lt;less&gt;
+ * &lt;equal&gt; ::= '='
+ * &lt;approx&gt; ::= '&tilde;='
+ * &lt;greater&gt; ::= '&gt;='
+ * &lt;less&gt; ::= '&lt;='
+ * &lt;present&gt; ::= &lt;attr&gt; '=*'
+ * &lt;substring&gt; ::= &lt;attr&gt; '=' &lt;initial&gt; &lt;any&gt; &lt;final&gt;
+ * &lt;initial&gt; ::= NULL | &lt;value&gt;
+ * &lt;any&gt; ::= '*' &lt;starval&gt;
+ * &lt;starval&gt; ::= NULL | &lt;value&gt; '*' &lt;starval&gt;
+ * &lt;final&gt; ::= NULL | &lt;value&gt;
+ * </pre>
+ *
+ * <code>&lt;attr&gt;</code> is a string representing an attribute, or key,
+ * in the properties objects of the registered services. Attribute names are
+ * not case sensitive; that is cn and CN both refer to the same attribute.
+ * <code>&lt;value&gt;</code> is a string representing the value, or part of
+ * one, of a key in the properties objects of the registered services. If a
+ * <code>&lt;value&gt;</code> must contain one of the characters '
+ * <code>*</code>' or '<code>(</code>' or '<code>)</code>', these characters
+ * should be escaped by preceding them with the backslash '<code>\</code>'
+ * character. Note that although both the <code>&lt;substring&gt;</code> and
+ * <code>&lt;present&gt;</code> productions can produce the <code>'attr=*'</code>
+ * construct, this construct is used only to denote a presence filter.
+ *
+ * <p>
+ * Examples of LDAP filters are:
+ *
+ * <pre>
+ * &quot;(cn=Babs Jensen)&quot;
+ * &quot;(!(cn=Tim Howes))&quot;
+ * &quot;(&amp;(&quot; + Constants.OBJECTCLASS + &quot;=Person)(|(sn=Jensen)(cn=Babs J*)))&quot;
+ * &quot;(o=univ*of*mich*)&quot;
+ * </pre>
+ *
+ * <p>
+ * The approximate match (<code>~=</code>) is implementation specific but
+ * should at least ignore case and white space differences. Optional are
+ * codes like soundex or other smart "closeness" comparisons.
+ *
+ * <p>
+ * Comparison of values is not straightforward. Strings are compared
+ * differently than numbers and it is possible for a key to have multiple
+ * values. Note that that keys in the match argument must always be strings.
+ * The comparison is defined by the object type of the key's value. The
+ * following rules apply for comparison:
+ *
+ * <blockquote>
+ * <TABLE BORDER=0>
+ * <TR>
+ * <TD><b>Property Value Type </b></TD>
+ * <TD><b>Comparison Type</b></TD>
+ * </TR>
+ * <TR>
+ * <TD>String</TD>
+ * <TD>String comparison</TD>
+ * </TR>
+ * <TR valign=top>
+ * <TD>Integer, Long, Float, Double, Byte, Short, BigInteger, BigDecimal</TD>
+ * <TD>numerical comparison</TD>
+ * </TR>
+ * <TR>
+ * <TD>Character</TD>
+ * <TD>character comparison</TD>
+ * </TR>
+ * <TR>
+ * <TD>Boolean</TD>
+ * <TD>equality comparisons only</TD>
+ * </TR>
+ * <TR>
+ * <TD>[] (array)</TD>
+ * <TD>recursively applied to values</TD>
+ * </TR>
+ * <TR>
+ * <TD>Collection</TD>
+ * <TD>recursively applied to values</TD>
+ * </TR>
+ * </TABLE>
+ * Note: arrays of primitives are also supported. </blockquote>
+ *
+ * A filter matches a key that has multiple values if it matches at least
+ * one of those values. For example,
+ *
+ * <pre>
+ * Dictionary d = new Hashtable();
+ * d.put(&quot;cn&quot;, new String[] {&quot;a&quot;, &quot;b&quot;, &quot;c&quot;});
+ * </pre>
+ *
+ * d will match <code>(cn=a)</code> and also <code>(cn=b)</code>
+ *
+ * <p>
+ * A filter component that references a key having an unrecognizable data
+ * type will evaluate to <code>false</code> .
+ */
+public class LDAPFilter {
+ /* filter operators */
+ private static final int EQUAL = 1;
+ private static final int APPROX = 2;
+ private static final int GREATER = 3;
+ private static final int LESS = 4;
+ private static final int PRESENT = 5;
+ private static final int SUBSTRING = 6;
+ private static final int AND = 7;
+ private static final int OR = 8;
+ private static final int NOT = 9;
+
+ /** filter operation */
+ private final int op;
+ /** filter attribute or null if operation AND, OR or NOT */
+ private final String attr;
+ /** filter operands */
+ private final Object value;
+
+ /* normalized filter string for Filter object */
+ private transient volatile String filterString;
+
+ /**
+ * Constructs a {@link LDAPFilter} object. This filter object may be
+ * used to match a {@link ServiceReference} or a Dictionary.
+ *
+ * <p>
+ * If the filter cannot be parsed, an {@link InvalidSyntaxException}
+ * will be thrown with a human readable message where the filter became
+ * unparsable.
+ *
+ * @param filterString the filter string.
+ * @exception InvalidSyntaxException If the filter parameter contains an
+ * invalid filter string that cannot be parsed.
+ */
+ public static LDAPFilter newInstance(String filterString) throws InvalidSyntaxException {
+ return new Parser(filterString).parse();
+ }
+
+ LDAPFilter(int operation, String attr, Object value) {
+ this.op = operation;
+ this.attr = attr;
+ this.value = value;
+ }
+
+ /**
+ * Filter using a <code>Dictionary</code>. This <code>Filter</code> is
+ * executed using the specified <code>Dictionary</code>'s keys and
+ * values. The keys are case insensitively matched with this
+ * <code>Filter</code>.
+ *
+ * @param dictionary The <code>Dictionary</code> whose keys are used in
+ * the match.
+ * @return <code>true</code> if the <code>Dictionary</code>'s keys and
+ * values match this filter; <code>false</code> otherwise.
+ * @throws IllegalArgumentException If <code>dictionary</code> contains
+ * case variants of the same key name.
+ */
+ public boolean match(Dictionary dictionary) {
+ return match0(new CaseInsensitiveDictionary(dictionary));
+ }
+
+ public boolean match(Map map) {
+ Properties props = new Properties();
+ props.putAll(map);
+ return match0(new CaseInsensitiveDictionary(props));
+ }
+
+ public static boolean matches(ServiceDeclaration declaration, String filter) {
+ if (filter == null) {
+ return true;
+ }
+ LDAPFilter filterImpl = newInstance(filter);
+ return filterImpl.match(declaration.getAttributes());
+ }
+
+ /**
+ * Filter with case sensitivity using a <code>Dictionary</code>. This
+ * <code>Filter</code> is executed using the specified
+ * <code>Dictionary</code>'s keys and values. The keys are case
+ * sensitively matched with this <code>Filter</code>.
+ *
+ * @param dictionary The <code>Dictionary</code> whose keys are used in
+ * the match.
+ * @return <code>true</code> if the <code>Dictionary</code>'s keys and
+ * values match this filter; <code>false</code> otherwise.
+ * @since 1.3
+ */
+ public boolean matchCase(Dictionary dictionary) {
+ return match0(dictionary);
+ }
+
+ /**
+ * Returns this <code>Filter</code>'s filter string.
+ * <p>
+ * The filter string is normalized by removing whitespace which does not
+ * affect the meaning of the filter.
+ *
+ * @return This <code>Filter</code>'s filter string.
+ */
+ public String toString() {
+ String result = filterString;
+ if (result == null) {
+ filterString = result = normalize();
+ }
+ return result;
+ }
+
+ /**
+ * Returns this <code>Filter</code>'s normalized filter string.
+ * <p>
+ * The filter string is normalized by removing whitespace which does not
+ * affect the meaning of the filter.
+ *
+ * @return This <code>Filter</code>'s filter string.
+ */
+ private String normalize() {
+ StringBuffer sb = new StringBuffer();
+ sb.append('(');
+
+ switch (op) {
+ case AND: {
+ sb.append('&');
+
+ LDAPFilter[] filters = (LDAPFilter[])value;
+ for (int i = 0, size = filters.length; i < size; i++) {
+ sb.append(filters[i].normalize());
+ }
+
+ break;
+ }
+
+ case OR: {
+ sb.append('|');
+
+ LDAPFilter[] filters = (LDAPFilter[])value;
+ for (int i = 0, size = filters.length; i < size; i++) {
+ sb.append(filters[i].normalize());
+ }
+
+ break;
+ }
+
+ case NOT: {
+ sb.append('!');
+ LDAPFilter filter = (LDAPFilter)value;
+ sb.append(filter.normalize());
+
+ break;
+ }
+
+ case SUBSTRING: {
+ sb.append(attr);
+ sb.append('=');
+
+ String[] substrings = (String[])value;
+
+ for (int i = 0, size = substrings.length; i < size; i++) {
+ String substr = substrings[i];
+
+ if (substr == null) /* * */{
+ sb.append('*');
+ } else /* xxx */{
+ sb.append(encodeValue(substr));
+ }
+ }
+
+ break;
+ }
+ case EQUAL: {
+ sb.append(attr);
+ sb.append('=');
+ sb.append(encodeValue((String)value));
+
+ break;
+ }
+ case GREATER: {
+ sb.append(attr);
+ sb.append(">=");
+ sb.append(encodeValue((String)value));
+
+ break;
+ }
+ case LESS: {
+ sb.append(attr);
+ sb.append("<=");
+ sb.append(encodeValue((String)value));
+
+ break;
+ }
+ case APPROX: {
+ sb.append(attr);
+ sb.append("~=");
+ sb.append(encodeValue(approxString((String)value)));
+
+ break;
+ }
+
+ case PRESENT: {
+ sb.append(attr);
+ sb.append("=*");
+
+ break;
+ }
+ }
+
+ sb.append(')');
+
+ return sb.toString();
+ }
+
+ /**
+ * Compares this <code>Filter</code> to another <code>Filter</code>.
+ *
+ * <p>
+ * This implementation returns the result of calling
+ * <code>this.toString().equals(obj.toString()</code>.
+ *
+ * @param obj The object to compare against this <code>Filter</code>.
+ * @return If the other object is a <code>Filter</code> object, then
+ * returns the result of calling
+ * <code>this.toString().equals(obj.toString()</code>;
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof LDAPFilter)) {
+ return false;
+ }
+
+ return this.toString().equals(obj.toString());
+ }
+
+ /**
+ * Returns the hashCode for this <code>Filter</code>.
+ *
+ * <p>
+ * This implementation returns the result of calling
+ * <code>this.toString().hashCode()</code>.
+ *
+ * @return The hashCode of this <code>Filter</code>.
+ */
+ public int hashCode() {
+ return this.toString().hashCode();
+ }
+
+ /**
+ * Internal match routine. Dictionary parameter must support
+ * case-insensitive get.
+ *
+ * @param properties A dictionary whose keys are used in the match.
+ * @return If the Dictionary's keys match the filter, return
+ * <code>true</code>. Otherwise, return <code>false</code>.
+ */
+ private boolean match0(Dictionary properties) {
+ switch (op) {
+ case AND: {
+ LDAPFilter[] filters = (LDAPFilter[])value;
+ for (int i = 0, size = filters.length; i < size; i++) {
+ if (!filters[i].match0(properties)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ case OR: {
+ LDAPFilter[] filters = (LDAPFilter[])value;
+ for (int i = 0, size = filters.length; i < size; i++) {
+ if (filters[i].match0(properties)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ case NOT: {
+ LDAPFilter filter = (LDAPFilter)value;
+
+ return !filter.match0(properties);
+ }
+
+ case SUBSTRING:
+ case EQUAL:
+ case GREATER:
+ case LESS:
+ case APPROX: {
+ Object prop = (properties == null) ? null : properties.get(attr);
+
+ return compare(op, prop, value);
+ }
+
+ case PRESENT: {
+ Object prop = (properties == null) ? null : properties.get(attr);
+
+ return prop != null;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Encode the value string such that '(', '*', ')' and '\' are escaped.
+ *
+ * @param value unencoded value string.
+ * @return encoded value string.
+ */
+ private static String encodeValue(String value) {
+ boolean encoded = false;
+ int inlen = value.length();
+ int outlen = inlen << 1; /* inlen 2 */
+
+ char[] output = new char[outlen];
+ value.getChars(0, inlen, output, inlen);
+
+ int cursor = 0;
+ for (int i = inlen; i < outlen; i++) {
+ char c = output[i];
+
+ switch (c) {
+ case '(':
+ case '*':
+ case ')':
+ case '\\': {
+ output[cursor] = '\\';
+ cursor++;
+ encoded = true;
+
+ break;
+ }
+ }
+
+ output[cursor] = c;
+ cursor++;
+ }
+
+ return encoded ? new String(output, 0, cursor) : value;
+ }
+
+ private boolean compare(int operation, Object value1, Object value2) {
+ if (value1 == null) {
+ return false;
+ }
+ if (value1 instanceof String) {
+ return compare_String(operation, (String)value1, value2);
+ }
+
+ Class clazz = value1.getClass();
+ if (clazz.isArray()) {
+ Class type = clazz.getComponentType();
+ if (type.isPrimitive()) {
+ return compare_PrimitiveArray(operation, type, value1, value2);
+ }
+ return compare_ObjectArray(operation, (Object[])value1, value2);
+ }
+ if (value1 instanceof Collection) {
+ return compare_Collection(operation, (Collection)value1, value2);
+ }
+ if (value1 instanceof Integer) {
+ return compare_Integer(operation, ((Integer)value1).intValue(), value2);
+ }
+ if (value1 instanceof Long) {
+ return compare_Long(operation, ((Long)value1).longValue(), value2);
+ }
+ if (value1 instanceof Byte) {
+ return compare_Byte(operation, ((Byte)value1).byteValue(), value2);
+ }
+ if (value1 instanceof Short) {
+ return compare_Short(operation, ((Short)value1).shortValue(), value2);
+ }
+ if (value1 instanceof Character) {
+ return compare_Character(operation, ((Character)value1).charValue(), value2);
+ }
+ if (value1 instanceof Float) {
+ return compare_Float(operation, ((Float)value1).floatValue(), value2);
+ }
+ if (value1 instanceof Double) {
+ return compare_Double(operation, ((Double)value1).doubleValue(), value2);
+ }
+ if (value1 instanceof Boolean) {
+ return compare_Boolean(operation, ((Boolean)value1).booleanValue(), value2);
+ }
+ if (value1 instanceof Comparable) {
+ return compare_Comparable(operation, (Comparable)value1, value2);
+ }
+ return compare_Unknown(operation, value1, value2); // RFC 59
+ }
+
+ private boolean compare_Collection(int operation, Collection collection, Object value2) {
+ for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
+ if (compare(operation, iterator.next(), value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_ObjectArray(int operation, Object[] array, Object value2) {
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_PrimitiveArray(int operation, Class type, Object primarray, Object value2) {
+ if (Integer.TYPE.isAssignableFrom(type)) {
+ int[] array = (int[])primarray;
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare_Integer(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (Long.TYPE.isAssignableFrom(type)) {
+ long[] array = (long[])primarray;
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare_Long(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (Byte.TYPE.isAssignableFrom(type)) {
+ byte[] array = (byte[])primarray;
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare_Byte(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (Short.TYPE.isAssignableFrom(type)) {
+ short[] array = (short[])primarray;
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare_Short(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (Character.TYPE.isAssignableFrom(type)) {
+ char[] array = (char[])primarray;
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare_Character(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (Float.TYPE.isAssignableFrom(type)) {
+ float[] array = (float[])primarray;
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare_Float(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (Double.TYPE.isAssignableFrom(type)) {
+ double[] array = (double[])primarray;
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare_Double(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (Boolean.TYPE.isAssignableFrom(type)) {
+ boolean[] array = (boolean[])primarray;
+ for (int i = 0, size = array.length; i < size; i++) {
+ if (compare_Boolean(operation, array[i], value2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return false;
+ }
+
+ private boolean compare_String(int operation, String string, Object value2) {
+ switch (operation) {
+ case SUBSTRING: {
+ String[] substrings = (String[])value2;
+ int pos = 0;
+ for (int i = 0, size = substrings.length; i < size; i++) {
+ String substr = substrings[i];
+
+ if (i + 1 < size) /* if this is not that last substr */{
+ if (substr == null) /* * */{
+ String substr2 = substrings[i + 1];
+
+ if (substr2 == null) /* ** */
+ continue; /* ignore first star */
+ /* xxx */
+ int index = string.indexOf(substr2, pos);
+ if (index == -1) {
+ return false;
+ }
+
+ pos = index + substr2.length();
+ if (i + 2 < size) // if there are more
+ // substrings, increment
+ // over the string we just
+ // matched; otherwise need
+ // to do the last substr
+ // check
+ i++;
+ } else /* xxx */{
+ int len = substr.length();
+ if (string.regionMatches(pos, substr, 0, len)) {
+ pos += len;
+ } else {
+ return false;
+ }
+ }
+ } else /* last substr */{
+ if (substr == null) /* * */{
+ return true;
+ }
+ /* xxx */
+ return string.endsWith(substr);
+ }
+ }
+
+ return true;
+ }
+ case EQUAL: {
+ return string.equals(value2);
+ }
+ case APPROX: {
+ string = approxString(string);
+ String string2 = approxString((String)value2);
+
+ return string.equalsIgnoreCase(string2);
+ }
+ case GREATER: {
+ return string.compareTo((String)value2) >= 0;
+ }
+ case LESS: {
+ return string.compareTo((String)value2) <= 0;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Integer(int operation, int intval, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ int intval2 = Integer.parseInt(((String)value2).trim());
+ switch (operation) {
+ case APPROX:
+ case EQUAL: {
+ return intval == intval2;
+ }
+ case GREATER: {
+ return intval >= intval2;
+ }
+ case LESS: {
+ return intval <= intval2;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Long(int operation, long longval, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ long longval2 = Long.parseLong(((String)value2).trim());
+ switch (operation) {
+ case APPROX:
+ case EQUAL: {
+ return longval == longval2;
+ }
+ case GREATER: {
+ return longval >= longval2;
+ }
+ case LESS: {
+ return longval <= longval2;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Byte(int operation, byte byteval, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ byte byteval2 = Byte.parseByte(((String)value2).trim());
+ switch (operation) {
+ case APPROX:
+ case EQUAL: {
+ return byteval == byteval2;
+ }
+ case GREATER: {
+ return byteval >= byteval2;
+ }
+ case LESS: {
+ return byteval <= byteval2;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Short(int operation, short shortval, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ short shortval2 = Short.parseShort(((String)value2).trim());
+ switch (operation) {
+ case APPROX:
+ case EQUAL: {
+ return shortval == shortval2;
+ }
+ case GREATER: {
+ return shortval >= shortval2;
+ }
+ case LESS: {
+ return shortval <= shortval2;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Character(int operation, char charval, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ char charval2 = (((String)value2).trim()).charAt(0);
+ switch (operation) {
+ case EQUAL: {
+ return charval == charval2;
+ }
+ case APPROX: {
+ return (charval == charval2) || (Character.toUpperCase(charval) == Character.toUpperCase(charval2))
+ || (Character.toLowerCase(charval) == Character.toLowerCase(charval2));
+ }
+ case GREATER: {
+ return charval >= charval2;
+ }
+ case LESS: {
+ return charval <= charval2;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Boolean(int operation, boolean boolval, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ boolean boolval2 = Boolean.valueOf(((String)value2).trim()).booleanValue();
+ switch (operation) {
+ case APPROX:
+ case EQUAL:
+ case GREATER:
+ case LESS: {
+ return boolval == boolval2;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Float(int operation, float floatval, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ float floatval2 = Float.parseFloat(((String)value2).trim());
+ switch (operation) {
+ case APPROX:
+ case EQUAL: {
+ return Float.compare(floatval, floatval2) == 0;
+ }
+ case GREATER: {
+ return Float.compare(floatval, floatval2) >= 0;
+ }
+ case LESS: {
+ return Float.compare(floatval, floatval2) <= 0;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Double(int operation, double doubleval, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ double doubleval2 = Double.parseDouble(((String)value2).trim());
+ switch (operation) {
+ case APPROX:
+ case EQUAL: {
+ return Double.compare(doubleval, doubleval2) == 0;
+ }
+ case GREATER: {
+ return Double.compare(doubleval, doubleval2) >= 0;
+ }
+ case LESS: {
+ return Double.compare(doubleval, doubleval2) <= 0;
+ }
+ }
+ return false;
+ }
+
+ private static final Class[] constructorType = new Class[] {String.class};
+
+ private boolean compare_Comparable(int operation, Comparable value1, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ Constructor constructor;
+ try {
+ constructor = value1.getClass().getConstructor(constructorType);
+ } catch (NoSuchMethodException e) {
+ return false;
+ }
+ try {
+ if (!constructor.isAccessible())
+ AccessController.doPrivileged(new SetAccessibleAction(constructor));
+ value2 = constructor.newInstance(new Object[] {((String)value2).trim()});
+ } catch (IllegalAccessException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ return false;
+ } catch (InstantiationException e) {
+ return false;
+ }
+
+ switch (operation) {
+ case APPROX:
+ case EQUAL: {
+ return value1.compareTo(value2) == 0;
+ }
+ case GREATER: {
+ return value1.compareTo(value2) >= 0;
+ }
+ case LESS: {
+ return value1.compareTo(value2) <= 0;
+ }
+ }
+ return false;
+ }
+
+ private boolean compare_Unknown(int operation, Object value1, Object value2) {
+ if (operation == SUBSTRING) {
+ return false;
+ }
+ Constructor constructor;
+ try {
+ constructor = value1.getClass().getConstructor(constructorType);
+ } catch (NoSuchMethodException e) {
+ return false;
+ }
+ try {
+ if (!constructor.isAccessible())
+ AccessController.doPrivileged(new SetAccessibleAction(constructor));
+ value2 = constructor.newInstance(new Object[] {((String)value2).trim()});
+ } catch (IllegalAccessException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ return false;
+ } catch (InstantiationException e) {
+ return false;
+ }
+
+ switch (operation) {
+ case APPROX:
+ case EQUAL:
+ case GREATER:
+ case LESS: {
+ return value1.equals(value2);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Map a string for an APPROX (~=) comparison.
+ *
+ * This implementation removes white spaces. This is the minimum
+ * implementation allowed by the OSGi spec.
+ *
+ * @param input Input string.
+ * @return String ready for APPROX comparison.
+ */
+ private static String approxString(String input) {
+ boolean changed = false;
+ char[] output = input.toCharArray();
+ int cursor = 0;
+ for (int i = 0, length = output.length; i < length; i++) {
+ char c = output[i];
+
+ if (Character.isWhitespace(c)) {
+ changed = true;
+ continue;
+ }
+
+ output[cursor] = c;
+ cursor++;
+ }
+
+ return changed ? new String(output, 0, cursor) : input;
+ }
+
+ /**
+ * Parser class for OSGi filter strings. This class parses the complete
+ * filter string and builds a tree of Filter objects rooted at the
+ * parent.
+ */
+ private static class Parser {
+ private final String filterstring;
+ private final char[] filterChars;
+ private int pos;
+
+ Parser(String filterstring) {
+ this.filterstring = filterstring;
+ filterChars = filterstring.toCharArray();
+ pos = 0;
+ }
+
+ LDAPFilter parse() throws InvalidSyntaxException {
+ LDAPFilter filter;
+ try {
+ filter = parse_filter();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new InvalidSyntaxException("Filter ended abruptly", filterstring);
+ }
+
+ if (pos != filterChars.length) {
+ throw new InvalidSyntaxException("Extraneous trailing characters: " + filterstring.substring(pos),
+ filterstring);
+ }
+ return filter;
+ }
+
+ private LDAPFilter parse_filter() throws InvalidSyntaxException {
+ LDAPFilter filter;
+ skipWhiteSpace();
+
+ if (filterChars[pos] != '(') {
+ throw new InvalidSyntaxException("Missing '(': " + filterstring.substring(pos), filterstring);
+ }
+
+ pos++;
+
+ filter = parse_filtercomp();
+
+ skipWhiteSpace();
+
+ if (filterChars[pos] != ')') {
+ throw new InvalidSyntaxException("Missing ')': " + filterstring.substring(pos), filterstring);
+ }
+
+ pos++;
+
+ skipWhiteSpace();
+
+ return filter;
+ }
+
+ private LDAPFilter parse_filtercomp() throws InvalidSyntaxException {
+ skipWhiteSpace();
+
+ char c = filterChars[pos];
+
+ switch (c) {
+ case '&': {
+ pos++;
+ return parse_and();
+ }
+ case '|': {
+ pos++;
+ return parse_or();
+ }
+ case '!': {
+ pos++;
+ return parse_not();
+ }
+ }
+ return parse_item();
+ }
+
+ private LDAPFilter parse_and() throws InvalidSyntaxException {
+ skipWhiteSpace();
+
+ if (filterChars[pos] != '(') {
+ throw new InvalidSyntaxException("Missing '(': " + filterstring.substring(pos), filterstring);
+ }
+
+ List operands = new ArrayList(10);
+
+ while (filterChars[pos] == '(') {
+ LDAPFilter child = parse_filter();
+ operands.add(child);
+ }
+
+ return new LDAPFilter(LDAPFilter.AND, null, operands.toArray(new LDAPFilter[operands.size()]));
+ }
+
+ private LDAPFilter parse_or() throws InvalidSyntaxException {
+ skipWhiteSpace();
+
+ if (filterChars[pos] != '(') {
+ throw new InvalidSyntaxException("Missing '(': " + filterstring.substring(pos), filterstring);
+ }
+
+ List operands = new ArrayList(10);
+
+ while (filterChars[pos] == '(') {
+ LDAPFilter child = parse_filter();
+ operands.add(child);
+ }
+
+ return new LDAPFilter(LDAPFilter.OR, null, operands.toArray(new LDAPFilter[operands.size()]));
+ }
+
+ private LDAPFilter parse_not() throws InvalidSyntaxException {
+ skipWhiteSpace();
+
+ if (filterChars[pos] != '(') {
+ throw new InvalidSyntaxException("Missing '(': " + filterstring.substring(pos), filterstring);
+ }
+
+ LDAPFilter child = parse_filter();
+
+ return new LDAPFilter(LDAPFilter.NOT, null, child);
+ }
+
+ private LDAPFilter parse_item() throws InvalidSyntaxException {
+ String attr = parse_attr();
+
+ skipWhiteSpace();
+
+ switch (filterChars[pos]) {
+ case '~': {
+ if (filterChars[pos + 1] == '=') {
+ pos += 2;
+ return new LDAPFilter(LDAPFilter.APPROX, attr, parse_value());
+ }
+ break;
+ }
+ case '>': {
+ if (filterChars[pos + 1] == '=') {
+ pos += 2;
+ return new LDAPFilter(LDAPFilter.GREATER, attr, parse_value());
+ }
+ break;
+ }
+ case '<': {
+ if (filterChars[pos + 1] == '=') {
+ pos += 2;
+ return new LDAPFilter(LDAPFilter.LESS, attr, parse_value());
+ }
+ break;
+ }
+ case '=': {
+ if (filterChars[pos + 1] == '*') {
+ int oldpos = pos;
+ pos += 2;
+ skipWhiteSpace();
+ if (filterChars[pos] == ')') {
+ return new LDAPFilter(LDAPFilter.PRESENT, attr, null);
+ }
+ pos = oldpos;
+ }
+
+ pos++;
+ Object string = parse_substring();
+
+ if (string instanceof String) {
+ return new LDAPFilter(LDAPFilter.EQUAL, attr, string);
+ }
+ return new LDAPFilter(LDAPFilter.SUBSTRING, attr, string);
+ }
+ }
+
+ throw new InvalidSyntaxException("Invalid operator: " + filterstring.substring(pos), filterstring);
+ }
+
+ private String parse_attr() throws InvalidSyntaxException {
+ skipWhiteSpace();
+
+ int begin = pos;
+ int end = pos;
+
+ char c = filterChars[pos];
+
+ while (c != '~' && c != '<' && c != '>' && c != '=' && c != '(' && c != ')') {
+ pos++;
+
+ if (!Character.isWhitespace(c)) {
+ end = pos;
+ }
+
+ c = filterChars[pos];
+ }
+
+ int length = end - begin;
+
+ if (length == 0) {
+ throw new InvalidSyntaxException("Missing attr: " + filterstring.substring(pos), filterstring);
+ }
+
+ return new String(filterChars, begin, length);
+ }
+
+ private String parse_value() throws InvalidSyntaxException {
+ StringBuffer sb = new StringBuffer(filterChars.length - pos);
+
+ parseloop: while (true) {
+ char c = filterChars[pos];
+
+ switch (c) {
+ case ')': {
+ break parseloop;
+ }
+
+ case '(': {
+ throw new InvalidSyntaxException("Invalid value: " + filterstring.substring(pos),
+ filterstring);
+ }
+
+ case '\\': {
+ pos++;
+ c = filterChars[pos];
+ /* fall through into default */
+ }
+
+ default: {
+ sb.append(c);
+ pos++;
+ break;
+ }
+ }
+ }
+
+ if (sb.length() == 0) {
+ throw new InvalidSyntaxException("Missing value: " + filterstring.substring(pos), filterstring);
+ }
+
+ return sb.toString();
+ }
+
+ private Object parse_substring() throws InvalidSyntaxException {
+ StringBuffer sb = new StringBuffer(filterChars.length - pos);
+
+ List operands = new ArrayList(10);
+
+ parseloop: while (true) {
+ char c = filterChars[pos];
+
+ switch (c) {
+ case ')': {
+ if (sb.length() > 0) {
+ operands.add(sb.toString());
+ }
+
+ break parseloop;
+ }
+
+ case '(': {
+ throw new InvalidSyntaxException("Invalid value: " + filterstring.substring(pos),
+ filterstring);
+ }
+
+ case '*': {
+ if (sb.length() > 0) {
+ operands.add(sb.toString());
+ }
+
+ sb.setLength(0);
+
+ operands.add(null);
+ pos++;
+
+ break;
+ }
+
+ case '\\': {
+ pos++;
+ c = filterChars[pos];
+ /* fall through into default */
+ }
+
+ default: {
+ sb.append(c);
+ pos++;
+ break;
+ }
+ }
+ }
+
+ int size = operands.size();
+
+ if (size == 0) {
+ throw new InvalidSyntaxException("Missing value: " + filterstring.substring(pos), filterstring);
+ }
+
+ if (size == 1) {
+ Object single = operands.get(0);
+
+ if (single != null) {
+ return single;
+ }
+ }
+
+ return operands.toArray(new String[size]);
+ }
+
+ private void skipWhiteSpace() {
+ for (int length = filterChars.length; (pos < length) && Character.isWhitespace(filterChars[pos]);) {
+ pos++;
+ }
+ }
+ }
+
+ /**
+ * This Dictionary is used for case-insensitive key lookup during filter
+ * evaluation. This Dictionary implementation only supports the get
+ * operation using a String key as no other operations are used by the
+ * Filter implementation.
+ */
+ static class CaseInsensitiveDictionary extends Dictionary {
+ private final Dictionary dictionary;
+ private final String[] keys;
+
+ /**
+ * Create a case insensitive dictionary from the specified dictionary.
+ *
+ * @param dictionary
+ * @throws IllegalArgumentException If <code>dictionary</code> contains
+ * case variants of the same key name.
+ */
+ CaseInsensitiveDictionary(Dictionary dictionary) {
+ if (dictionary == null) {
+ this.dictionary = null;
+ this.keys = new String[0];
+ return;
+ }
+ this.dictionary = dictionary;
+ List keyList = new ArrayList(dictionary.size());
+ for (Enumeration e = dictionary.keys(); e.hasMoreElements();) {
+ Object k = e.nextElement();
+ if (k instanceof String) {
+ String key = (String)k;
+ for (Iterator i = keyList.iterator(); i.hasNext();) {
+ if (key.equalsIgnoreCase((String)i.next())) {
+ throw new IllegalArgumentException();
+ }
+ }
+ keyList.add(key);
+ }
+ }
+ this.keys = (String[])keyList.toArray(new String[keyList.size()]);
+ }
+
+ public Object get(Object o) {
+ String k = (String)o;
+ for (int i = 0, length = keys.length; i < length; i++) {
+ String key = keys[i];
+ if (key.equalsIgnoreCase(k)) {
+ return dictionary.get(key);
+ }
+ }
+ return null;
+ }
+
+ public boolean isEmpty() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Enumeration keys() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Enumeration elements() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int size() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ static class SetAccessibleAction implements PrivilegedAction {
+ private final AccessibleObject accessible;
+
+ SetAccessibleAction(AccessibleObject accessible) {
+ this.accessible = accessible;
+ }
+
+ public Object run() {
+ accessible.setAccessible(true);
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.FactoryExtensionPoint b/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.FactoryExtensionPoint
new file mode 100644
index 0000000000..be22b6fb13
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.FactoryExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint b/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint
new file mode 100644
index 0000000000..4e5a05d522
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.core.DefaultModuleActivatorExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.UtilityExtensionPoint b/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.UtilityExtensionPoint
new file mode 100644
index 0000000000..52d7cb59b2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.UtilityExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.core.DefaultUtilityExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
new file mode 100644
index 0000000000..c0aac21596
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.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.sca.extensibility;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Case for ClasspathServiceDiscover
+ */
+public class ContextClassLoaderServiceDiscovererTestCase {
+ private static ContextClassLoaderServiceDiscoverer discover;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ discover = new ContextClassLoaderServiceDiscoverer();
+ }
+
+ @Test
+ public void testDiscovery() {
+ Collection<ServiceDeclaration> discriptors =
+ discover.getServiceDeclarations("org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint");
+ Assert.assertEquals(1, discriptors.size());
+ discriptors =
+ discover.getServiceDeclarations("notthere");
+ Assert.assertEquals(0, discriptors.size());
+ }
+
+ @Test
+ public void testDiscoveryFirst() throws IOException {
+ ServiceDeclaration descriptor =
+ discover.getServiceDeclaration("org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint");
+ Assert.assertNotNull(descriptor);
+ descriptor = discover.getServiceDeclaration("notthere");
+ Assert.assertNull(descriptor);
+ }
+
+ @Test
+ public void testXPathFactory() {
+ Collection<ServiceDeclaration> discriptors = discover.getServiceDeclarations("javax.xml.xpath.XPathFactory");
+ if (!discriptors.isEmpty()) {
+ ServiceDeclaration d = discriptors.iterator().next();
+ Assert.assertNotNull(d.getClassName());
+ Assert.assertTrue(d.getAttributes().containsKey("class"));
+ }
+ }
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java
new file mode 100644
index 0000000000..9758cba3b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DefaultExtensionPointRegistryTestCase {
+ private ExtensionPointRegistry registry;
+
+ @Before
+ public void setUp() throws Exception {
+ registry = new DefaultExtensionPointRegistry();
+ }
+
+ @Test
+ public void testRegistry() {
+ MyExtensionPoint service = new MyExtensionPointImpl();
+ registry.addExtensionPoint(service);
+ assertSame(service, registry.getExtensionPoint(MyExtensionPoint.class));
+ registry.removeExtensionPoint(service);
+ assertNull(registry.getExtensionPoint(MyExtensionPoint.class));
+ }
+
+ public static interface MyExtensionPoint {
+ void doSomething();
+ }
+
+ private static class MyExtensionPointImpl implements MyExtensionPoint {
+
+ public void doSomething() {
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
new file mode 100644
index 0000000000..0a5f4d6442
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility;
+
+
+import java.io.Serializable;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultUtilityExtensionPoint;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class DefaultUtilityExtensionPointTestCase {
+ private static UtilityExtensionPoint ep;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ ep = new DefaultUtilityExtensionPoint(new DefaultExtensionPointRegistry());
+ ep.start();
+ }
+
+ @Test
+ public void testGet() {
+ MyUtilityImpl my = new MyUtilityImpl();
+ ep.addUtility(my);
+ Assert.assertTrue(my.started);
+ Utility1 u1 = ep.getUtility(Utility1.class);
+ Assert.assertSame(my, u1);
+ Utility2 u2 = ep.getUtility(Utility2.class);
+ Assert.assertSame(my, u2);
+ ep.removeUtility(my);
+ Assert.assertFalse(my.started);
+ u1 = ep.getUtility(Utility1.class);
+ Assert.assertNull(u1);
+
+ ep.addUtility("1", my);
+ u1= ep.getUtility(Utility1.class);
+ Assert.assertNull(u1);
+ u1= ep.getUtility(Utility1.class, "1");
+ Assert.assertNotNull(u1);
+ ep.removeUtility(my);
+ u1= ep.getUtility(Utility1.class, "1");
+ Assert.assertNull(u1);
+
+ u1 = ep.getUtility(MyUtilityImpl.class);
+ Assert.assertNotNull(u1);
+ u2 = ep.getUtility(Utility2.class);
+ Assert.assertSame(u1, u2);
+ ep.removeUtility(u1);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ ep.stop();
+ }
+
+ public static interface Utility1 extends Serializable {
+ void op1();
+ }
+
+ public static interface Utility2 extends Serializable {
+ void op2();
+ }
+
+ public static class MyUtilityImpl implements Utility1, Utility2, LifeCycleListener {
+ public boolean started;
+
+ public void start() {
+ System.out.println("start");
+ started = true;
+ }
+
+ public void stop() {
+ System.out.println("stop");
+ started = false;
+ }
+
+ public void op1() {
+ System.out.println("op1");
+ }
+
+ public void op2() {
+ System.out.println("op2");
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java
new file mode 100644
index 0000000000..e13a47cc1b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.extensibility;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.tuscany.sca.extensibility.test.TestInterface;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class ServiceDiscoveryTestCase {
+ private static final String NAME = "org.apache.tuscany.sca.extensibility.test.TestInterface";
+
+ @Test
+ public void testRanking() throws Exception {
+ ServiceDeclaration sd = ServiceDiscovery.getInstance().getServiceDeclaration(NAME);
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd.getClassName());
+
+ Collection<ServiceDeclaration> sds = ServiceDiscovery.getInstance().getServiceDeclarations(NAME);
+ Assert.assertEquals(3, sds.size());
+
+ sds = ServiceDiscovery.getInstance().getServiceDeclarations(NAME, true);
+ Assert.assertEquals(3, sds.size());
+ Iterator<ServiceDeclaration> it = sds.iterator();
+ ServiceDeclaration sd1 = it.next();
+ ServiceDeclaration sd2 = it.next();
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd1.getClassName());
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.TestImpl", sd2.getClassName());
+ }
+
+ @Test
+ public void testServiceType() throws Exception {
+ ServiceDeclaration sd = ServiceDiscovery.getInstance().getServiceDeclaration(TestInterface.class);
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd.getClassName());
+
+ Collection<ServiceDeclaration> sds = ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class);
+ Assert.assertEquals(2, sds.size());
+
+ sds = ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, true);
+ Assert.assertEquals(2, sds.size());
+ Iterator<ServiceDeclaration> it = sds.iterator();
+ ServiceDeclaration sd1 = it.next();
+ ServiceDeclaration sd2 = it.next();
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd1.getClassName());
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.TestImpl", sd2.getClassName());
+ }
+
+ @Test
+ /**
+ * Test if the external attributes override the one in the META-INF/services/<SPI>
+ */
+ public void testAttributes() throws Exception {
+ ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance(new ContextClassLoaderServiceDiscoverer());
+ serviceDiscovery.setAttribute(TestInterface.class.getName(), "attr", "value");
+ serviceDiscovery.setAttribute(TestInterface.class.getName(), "attr1", "value1");
+ for (ServiceDeclaration sd : serviceDiscovery.getServiceDeclarations(TestInterface.class)) {
+ Assert.assertEquals("value1", sd.getAttributes().get("attr1"));
+ Assert.assertEquals("value", sd.getAttributes().get("attr"));
+ }
+ }
+
+ @Test
+ public void testFilter() throws Exception {
+ Collection<ServiceDeclaration> sds =
+ ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, "(attr=abc)");
+
+ Assert.assertEquals(1, sds.size());
+
+ Iterator<ServiceDeclaration> it = sds.iterator();
+ ServiceDeclaration sd1 = it.next();
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd1.getClassName());
+
+ sds = ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, "(attr=1*)");
+ Assert.assertEquals(1, sds.size());
+ it = sds.iterator();
+ sd1 = it.next();
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.TestImpl", sd1.getClassName());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java
new file mode 100644
index 0000000000..7920fdf4f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.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.extensibility;
+
+import java.lang.reflect.Proxy;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.extensibility.test.Test2Impl;
+import org.apache.tuscany.sca.extensibility.test.TestImpl;
+import org.apache.tuscany.sca.extensibility.test.TestInterface;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ServiceHelperTestCase {
+ @Test
+ public void testNewInstance() throws Exception {
+ Test2Impl implA = ServiceHelper.newInstance(Test2Impl.class);
+ Assert.assertNull(implA.getRegistry());
+
+ TestImpl impl1 = ServiceHelper.newInstance(TestImpl.class);
+ Assert.assertNotNull(impl1);
+ }
+
+ @Test
+ public void testNewInstance2() throws Exception {
+ Collection<ServiceDeclaration> sds =
+ ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, true);
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ Iterator<ServiceDeclaration> iterator = sds.iterator();
+ Test2Impl implA = ServiceHelper.newInstance(registry, iterator.next());
+ Assert.assertSame(registry, implA.getRegistry());
+
+ TestImpl impl1 = ServiceHelper.newInstance(registry, iterator.next());
+ Assert.assertNotNull(impl1);
+ }
+
+ @Test
+ public void testNewLazyInstance() throws Exception {
+ Collection<ServiceDeclaration> sds =
+ ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, true);
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ Iterator<ServiceDeclaration> iterator = sds.iterator();
+ TestInterface ti = ServiceHelper.newLazyInstance(registry, iterator.next(), TestInterface.class);
+ Assert.assertTrue(Proxy.isProxyClass(ti.getClass()));
+ Assert.assertTrue(ti instanceof LifeCycleListener);
+ Assert.assertTrue(ti.toString().startsWith("Proxy"));
+ Assert.assertEquals(System.identityHashCode(ti), ti.hashCode());
+ ServiceHelper.start(ti);
+ ServiceHelper.stop(ti);
+ QName name = ti.getArtifactType();
+ Assert.assertEquals(new QName("http://sample", "Test2"), name);
+ String str = ti.test("ABC");
+ Assert.assertEquals("Test 2: ABC", str);
+ ServiceHelper.stop(ti);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java
new file mode 100644
index 0000000000..f1ed50c5f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.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.sca.extensibility.test;
+
+/**
+ *
+ */
+public class DummyImpl {
+
+ public void test(String str) {
+ System.out.println("Test: " + str);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java
new file mode 100644
index 0000000000..6a1ba4d7ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.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.sca.extensibility.test;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+
+/**
+ *
+ */
+public class Test2Impl implements TestInterface, LifeCycleListener {
+ private ExtensionPointRegistry registry;
+ public int state = 0;
+
+ public Test2Impl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public Test2Impl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.extensibility.test.TestInterface#test(java.lang.String)
+ */
+ public String test(String str) {
+ System.out.println("Test 2: " + str);
+ return "Test 2: " + str;
+ }
+
+ public ExtensionPointRegistry getRegistry() {
+ return registry;
+ }
+
+ public void start() {
+ state = 1;
+ }
+
+ public void stop() {
+ state = -1;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((registry == null) ? 0 : registry.hashCode());
+ result = prime * result + state;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Test2Impl other = (Test2Impl)obj;
+ if (registry == null) {
+ if (other.registry != null)
+ return false;
+ } else if (!registry.equals(other.registry))
+ return false;
+ if (state != other.state)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Test2Impl [state=" + state + "]";
+ }
+
+ public QName getArtifactType() {
+ // TODO Auto-generated method stub
+ return new QName("http://sample", "Test2");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java
new file mode 100644
index 0000000000..4def8a5227
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.extensibility.test;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ */
+public class TestImpl implements TestInterface {
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.extensibility.test.TestInterface#test(java.lang.String)
+ */
+ public String test(String str) {
+ System.out.println("Test: " + str);
+ return "Test: " + str;
+ }
+
+ public QName getArtifactType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java
new file mode 100644
index 0000000000..2f0c34df7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.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.extensibility.test;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ */
+public interface TestInterface {
+ String test(String str);
+ QName getArtifactType();
+}
diff --git a/sandbox/sebastien/java/embed/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface b/sandbox/sebastien/java/embed/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface
new file mode 100644
index 0000000000..12991071e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface
@@ -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.
+org.apache.tuscany.sca.extensibility.test.TestImpl;ranking=10;attr=123
+org.apache.tuscany.sca.extensibility.test.Test2Impl;ranking=20,attr=abc,qname=http://sample#Test2,model=org.apache.tuscany.sca.extensibility.test.TestInterface
+org.apache.tuscany.sca.extensibility.test.DummyImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/LICENSE b/sandbox/sebastien/java/embed/modules/host-corba-jee/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/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/sebastien/java/embed/modules/host-corba-jee/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/host-corba-jee/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..71fbb7e6a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.host.corba.jee;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JEE environment CORBA Host
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397427890
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JEE environment CORBA Host
+Import-Package: javax.naming,
+ javax.naming.spi;resolution:=optional,
+ javax.rmi,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.corba;version="2.0.0",
+ org.omg.CORBA,
+ org.omg.CORBA.portable;resolution:=optional,
+ org.omg.CosNaming,
+ org.omg.CosNaming.NamingContextPackage
+Bundle-SymbolicName: org.apache.tuscany.sca.host.corba.jee
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/NOTICE b/sandbox/sebastien/java/embed/modules/host-corba-jee/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/pom.xml b/sandbox/sebastien/java/embed/modules/host-corba-jee/pom.xml
new file mode 100644
index 0000000000..29cd6209ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>tuscany-host-corba-jee</artifactId>
+ <name>Apache Tuscany SCA JEE environment CORBA Host</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java
new file mode 100644
index 0000000000..4d86a08eaa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.jee;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.host.corba.CorbaHostException;
+import org.apache.tuscany.sca.host.corba.CorbaHostUtils;
+import org.apache.tuscany.sca.host.corba.CorbanameURL;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExt;
+import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * @version $Rev$ $Date$
+ * Implementation of JEE CORBA host
+ */
+public class JEECorbaHost implements CorbaHost, LifeCycleListener {
+
+ public static final String ORB_NAME = "java:comp/ORB";
+
+ private List<String> registeredServants = Collections.synchronizedList(new ArrayList<String>());
+ private ORB orb;
+
+ private void registerURI(String uri) {
+ registeredServants.add(uri);
+ }
+
+ private void removeURI(String uri) {
+ registeredServants.remove(uri);
+ }
+
+ private NamingContextExt getNamingContext(String nameService) throws Exception {
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references(nameService);
+ return NamingContextExtHelper.narrow(objRef);
+ }
+
+ private void handleException(Exception e) throws CorbaHostException {
+ // The cause of the Exception is JDK specific
+ if (e instanceof NotFound) {
+ throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT, e);
+ } else if (e instanceof InvalidName) {
+ throw new CorbaHostException(e);
+ } else {
+ throw new CorbaHostException(e);
+ }
+ }
+
+ public void registerServant(String uri, Object servantObject) throws CorbaHostException {
+ CorbanameURL details = CorbaHostUtils.getServiceDetails(uri);
+ try {
+ NamingContext namingCtx = getNamingContext(details.getNameService());
+ for (int i = 0; i < details.getNamePath().size() - 1; i++) {
+ NameComponent nc = new NameComponent(details.getNamePath().get(i), "");
+ NameComponent[] path = new NameComponent[] {nc};
+ try {
+ namingCtx = NamingContextHelper.narrow(namingCtx.resolve(path));
+ } catch (Exception e) {
+ namingCtx = namingCtx.bind_new_context(path);
+ }
+ }
+ NameComponent finalName =
+ new NameComponent(details.getNamePath().get(details.getNamePath().size() - 1), "");
+ try {
+ namingCtx.resolve(new NameComponent[] {finalName});
+ // no exception means that some object is already registered
+ // under this name, we need to crash here
+ throw new CorbaHostException(CorbaHostException.BINDING_IN_USE);
+ } catch (NotFound e) {
+ namingCtx.bind(new NameComponent[] {finalName}, servantObject);
+ registerURI(uri);
+ }
+ } catch (CorbaHostException e) {
+ throw e;
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ public void unregisterServant(String uri) throws CorbaHostException {
+ CorbanameURL details = CorbaHostUtils.getServiceDetails(uri);
+ try {
+ NamingContextExt namingCtx = getNamingContext(details.getNameService());
+ namingCtx.unbind(namingCtx.to_name(details.getName()));
+ removeURI(uri);
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ public Object lookup(String uri) throws CorbaHostException {
+ Object result = null;
+ try {
+ CorbanameURL url = new CorbanameURL(uri);
+ NamingContextExt context = getNamingContext(url.getNameService());
+ result = context.resolve_str(url.getName());
+ } catch (Exception e) {
+ // e.printStackTrace();
+ handleException(e);
+ }
+ if (result == null) {
+ throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT);
+ }
+ return result;
+ }
+
+ // obtain ORB from environment
+ public void start() {
+ Context ctx;
+ try {
+ ctx = new InitialContext();
+ orb = (ORB)PortableRemoteObject.narrow(ctx.lookup(ORB_NAME), org.omg.CORBA.ORB.class);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ // unregister registered servants
+ public void stop() {
+ // use copy because unregisterServant(...) method removes from
+ // registeredServants collection
+ List<String> rsCopy = new ArrayList<String>(registeredServants);
+ for (String servantURI : rsCopy) {
+ try {
+ unregisterServant(servantURI);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost
new file mode 100644
index 0000000000..45da924da6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.host.corba.jee.JEECorbaHost;ranking=100
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java
new file mode 100644
index 0000000000..fd952a02c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.jee.testing;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import javax.naming.Context;
+
+import org.apache.tuscany.sca.host.corba.CorbaHostException;
+import org.apache.tuscany.sca.host.corba.jee.JEECorbaHost;
+import org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface;
+import org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper;
+import org.apache.tuscany.sca.host.corba.jee.testing.servants.TestInterfaceServant;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * General tests for JEECorbaHost. Uses host-corba-jdk as mock for JEE
+ * environment ORB.
+ */
+public class JEECorbaHostTestCase {
+
+ public static final String LOCALHOST = "localhost";
+ public static final int DEFAULT_PORT = 11100;
+ private static JEECorbaHost host;
+ private static TransientNameServer server;
+ private static String factoryClassName;
+
+ private String createCorbanameURI(String name) {
+ return "corbaname:#" + name;
+ }
+
+ @BeforeClass
+ public static void start() {
+ try {
+ server = new TransientNameServer(LOCALHOST, DEFAULT_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ fail("The naming server cannot be started");
+ }
+ factoryClassName = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, TestInitialContextFactory.class.getName());
+ host = new JEECorbaHost();
+ host.start();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void stop() {
+ server.stop();
+ if (factoryClassName != null) {
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, factoryClassName);
+ } else {
+ System.clearProperty(Context.INITIAL_CONTEXT_FACTORY);
+ }
+ }
+
+ /**
+ * Tests registering and lookup CORBA services
+ */
+ @Test
+ public void test_registerServant() {
+ try {
+ String uri = createCorbanameURI("Nested/Test");
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(uri, servant);
+ TestInterface ref = TestInterfaceHelper.narrow(host.lookup(uri));
+ assertEquals(2, ref.getInt(2));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests unregistering servants
+ */
+ @Test
+ public void test_unregisterServant() {
+ try {
+ String uri = createCorbanameURI("Unregistering/Test");
+ TestInterface servant = new TestInterfaceServant();
+
+ // creating and releasing using corbaname URI
+ host.registerServant(uri, servant);
+ host.unregisterServant(uri);
+ host.registerServant(uri, servant);
+ host.unregisterServant(uri);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests situation when name is already registered
+ */
+ @Test
+ public void test_nameAlreadyRegistered() {
+ // test using URI
+ try {
+ TestInterface servant = new TestInterfaceServant();
+ String uri = createCorbanameURI("AlreadyRegisteredTest2");
+ host.registerServant(uri, servant);
+ host.registerServant(uri, servant);
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.BINDING_IN_USE));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests getting non existing reference
+ */
+ @Test
+ public void test_getNonExistingObject() {
+ // try to fetch object with corbaname URI
+ try {
+ host.lookup(createCorbanameURI("NonExistingOne"));
+ fail();
+ } catch (CorbaHostException e) {
+ // The message is JDK-specific
+ // assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT));
+ } catch (Exception e) {
+ // e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests unregistering non existing reference
+ */
+ @Test
+ public void test_unregisterNonExistentObject() {
+ // test using URI
+ try {
+ String uri = createCorbanameURI("NonExistingReference1");
+ host.unregisterServant(uri);
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests unregistering servants on host stop
+ */
+ @Test
+ public void test_unregisterOnStop() {
+ try {
+ String uri1 = createCorbanameURI("TempService1");
+ String uri2 = createCorbanameURI("TempService2");
+ JEECorbaHost innerHost = new JEECorbaHost();
+ innerHost.start();
+ TestInterfaceServant servant = new TestInterfaceServant();
+ innerHost.registerServant(uri1, servant);
+ innerHost.registerServant(uri2, servant);
+ innerHost.stop();
+ try {
+ innerHost.lookup(uri1);
+ fail();
+ } catch (CorbaHostException e) {
+ assertEquals(CorbaHostException.NO_SUCH_OBJECT, e.getMessage());
+ }
+ try {
+ innerHost.lookup(uri2);
+ fail();
+ } catch (CorbaHostException e) {
+ assertEquals(CorbaHostException.NO_SUCH_OBJECT, e.getMessage());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java
new file mode 100644
index 0000000000..a0b9b7c514
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.jee.testing;
+
+import java.util.Hashtable;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.host.corba.jee.JEECorbaHost;
+import org.omg.CORBA.ORB;
+
+/**
+ * Mock implementation of javax.naming.Context interface.
+ */
+public class TestContext implements Context {
+
+ private ORB orb;
+
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+ return null;
+ }
+
+ public void bind(Name name, Object obj) throws NamingException {
+
+ }
+
+ public void bind(String name, Object obj) throws NamingException {
+
+ }
+
+ public void close() throws NamingException {
+
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException {
+ return null;
+ }
+
+ public String composeName(String name, String prefix) throws NamingException {
+ return null;
+ }
+
+ public Context createSubcontext(Name name) throws NamingException {
+ return null;
+ }
+
+ public Context createSubcontext(String name) throws NamingException {
+ return null;
+ }
+
+ public void destroySubcontext(Name name) throws NamingException {
+
+ }
+
+ public void destroySubcontext(String name) throws NamingException {
+
+ }
+
+ public Hashtable<?, ?> getEnvironment() throws NamingException {
+ return null;
+ }
+
+ public String getNameInNamespace() throws NamingException {
+ return null;
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException {
+ return null;
+ }
+
+ public NameParser getNameParser(String name) throws NamingException {
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+ return null;
+ }
+
+ public Object lookup(Name name) throws NamingException {
+ return null;
+ }
+
+ public Object lookup(String name) throws NamingException {
+ try {
+ if (name.equals(JEECorbaHost.ORB_NAME)) {
+ if (orb == null) {
+ // get ORB which was spawned under host and port declared in
+ // test class
+ String[] args =
+ {"-ORBInitialHost", JEECorbaHostTestCase.LOCALHOST, "-ORBInitialPort",
+ "" + JEECorbaHostTestCase.DEFAULT_PORT};
+ orb = ORB.init(args, null);
+ }
+ } else {
+ throw new NamingException("Unknown name: " + name);
+ }
+ } catch (Exception e) {
+ throw new NamingException(e.getMessage());
+ }
+ return orb;
+ }
+
+ public Object lookupLink(Name name) throws NamingException {
+ return null;
+ }
+
+ public Object lookupLink(String name) throws NamingException {
+ return null;
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException {
+
+ }
+
+ public void rebind(String name, Object obj) throws NamingException {
+
+ }
+
+ public Object removeFromEnvironment(String propName) throws NamingException {
+ return null;
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException {
+
+ }
+
+ public void rename(String oldName, String newName) throws NamingException {
+
+ }
+
+ public void unbind(Name name) throws NamingException {
+
+ }
+
+ public void unbind(String name) throws NamingException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java
new file mode 100644
index 0000000000..f480235fa8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.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.sca.host.corba.jee.testing;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+/**
+ * Factory for mock implementation of javax.naming.Context interface.
+ */
+public class TestInitialContextFactory implements InitialContextFactory {
+
+ public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
+ return new TestContext();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java
new file mode 100644
index 0000000000..c868329f10
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.jee.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public interface TestInterface extends TestInterfaceOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface TestInterface
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java
new file mode 100644
index 0000000000..e00b2429da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.jee.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+abstract public class TestInterfaceHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0";
+
+ public static void insert(org.omg.CORBA.Any a,
+ org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB
+ .init()
+ .create_interface_tc(org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper.id(),
+ "TestInterface");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_TestInterfaceStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface)
+ return (org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.host.corba.jee.testing.general._TestInterfaceStub stub =
+ new org.apache.tuscany.sca.host.corba.jee.testing.general._TestInterfaceStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface)
+ return (org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.host.corba.jee.testing.general._TestInterfaceStub stub =
+ new org.apache.tuscany.sca.host.corba.jee.testing.general._TestInterfaceStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.java
new file mode 100644
index 0000000000..292e1d09ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.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.host.corba.jee.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public final class TestInterfaceHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface value = null;
+
+ public TestInterfaceHolder() {
+ }
+
+ public TestInterfaceHolder(org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.java
new file mode 100644
index 0000000000..8d66535eb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.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.host.corba.jee.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public interface TestInterfaceOperations {
+ int getInt(int arg);
+} // interface TestInterfaceOperations
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.java
new file mode 100644
index 0000000000..4f75c045ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.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.host.corba.jee.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public abstract class _TestInterfaceImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _TestInterfaceImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("getInt", new java.lang.Integer(0));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/host/corba/testing/general/TestInterface/getInt
+ {
+ int arg = in.read_long();
+ int $result = (int)0;
+ $result = this.getInt(arg);
+ out = $rh.createReply();
+ out.write_long($result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"};
+
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _TestInterfaceImplBase
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java
new file mode 100644
index 0000000000..cc6d137109
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.host.corba.jee.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public class _TestInterfaceStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface {
+
+ public int getInt(int arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("getInt", true);
+ $out.write_long(arg);
+ $in = _invoke($out);
+ int $result = $in.read_long();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return getInt(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // getInt
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"};
+
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _TestInterfaceStub
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.java b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.java
new file mode 100644
index 0000000000..6195f3af9c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.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 org.apache.tuscany.sca.host.corba.jee.testing.servants;
+
+import org.apache.tuscany.sca.host.corba.jee.testing.general._TestInterfaceImplBase;
+
+/**
+ * Testing servant
+ */
+public class TestInterfaceServant extends _TestInterfaceImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public int getInt(int arg) {
+ return arg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/resources/general.idl b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/resources/general.idl
new file mode 100644
index 0000000000..9194a37334
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jee/src/test/resources/general.idl
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase general.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module host {
+ module corba {
+ module jee {
+ module testing {
+ module general {
+ interface TestInterface {
+ long getInt(in long arg);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/LICENSE b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/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/sebastien/java/embed/modules/host-corba-jse-tns/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..8edf701bf7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.host.corba.jse.tns;version="1.
+ 4"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Transient Name Server CORBA Host
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397430015
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Transient Name Server CORBA Hos
+ t
+Import-Package: org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.corba;version="2.0.0",
+ org.apache.tuscany.sca.host.corba.jse;version="2.0.0",
+ org.apache.tuscany.sca.host.corba.naming;version="2.0.0",
+ org.omg.CORBA
+Bundle-SymbolicName: org.apache.tuscany.sca.host.corba.jse.tns
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/NOTICE b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/pom.xml b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/pom.xml
new file mode 100644
index 0000000000..5014507384
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/pom.xml
@@ -0,0 +1,53 @@
+<?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>2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>tuscany-host-corba-jse-tns</artifactId>
+ <name>Apache Tuscany SCA Transient Name Server CORBA Host</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-corba-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java
new file mode 100644
index 0000000000..4a395631b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.host.corba.jse.tns;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.host.corba.CorbaHostException;
+import org.apache.tuscany.sca.host.corba.CorbanameURL;
+import org.apache.tuscany.sca.host.corba.SocketUtil;
+import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.omg.CORBA.Object;
+
+/**
+ * @version $Rev$ $Date$
+ * Default implementation of CORBA host
+ */
+public class TnsDefaultCorbaHost implements CorbaHost, LifeCycleListener {
+
+ private static final Logger logger = Logger.getLogger(TnsDefaultCorbaHost.class.getName());
+ private Map<Integer, TransientNameServer> localServers = new ConcurrentHashMap<Integer, TransientNameServer>();
+ private Map<Integer, Integer> clientsCount = new ConcurrentHashMap<Integer, Integer>();
+ private CorbaHost targetHost = new DefaultCorbaHost();
+
+ public void registerServant(String uri, Object servantObject) throws CorbaHostException {
+ CorbanameURL details = new CorbanameURL(uri);
+ if (SocketUtil.isLocalhost(details.getHost())) {
+ createLocalNameServer(details.getPort());
+ }
+ targetHost.registerServant(uri, servantObject);
+ }
+
+ public void unregisterServant(String uri) throws CorbaHostException {
+ targetHost.unregisterServant(uri);
+ CorbanameURL details = new CorbanameURL(uri);
+ if (SocketUtil.isLocalhost(details.getHost())) {
+ releaseLocalNameServer(details.getPort());
+ }
+ }
+
+ public Object lookup(String uri) throws CorbaHostException {
+ return targetHost.lookup(uri);
+ }
+
+ /**
+ * Starts transient name server under given port. If TNS was previously
+ * spawned it increments clients counter.
+ */
+ synchronized private void createLocalNameServer(int port) throws CorbaHostException {
+ int useCount = clientsCount.containsKey(port) ? clientsCount.get(port) : 0;
+ // no server previously spawned
+ if (useCount == 0) {
+ TransientNameServer server =
+ new TransientNameServer("localhost", port, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread thread = server.start();
+ if (thread == null) {
+ throw new CorbaHostException("TransientNameServer couldn't be started");
+ } else {
+ localServers.put(port, server);
+ }
+ }
+ clientsCount.put(port, ++useCount);
+ }
+
+ /**
+ * Stops transient name server if there is only one client left using such
+ * TNS. Decrements clients counter if TNS is used by 2 or more clients.
+ */
+ synchronized private void releaseLocalNameServer(int port) throws CorbaHostException {
+ int useCount = clientsCount.containsKey(port) ? clientsCount.get(port) : 0;
+ if (useCount == 1) {
+ // last client executed stop, cleaning up
+ TransientNameServer server = localServers.get(port);
+ if (server != null) {
+ server.stop();
+ clientsCount.remove(port);
+ localServers.remove(port);
+ } else {
+ logger.warning("Local name server on port " + port + " was null!");
+ }
+ } else if (useCount > 1) {
+ clientsCount.put(port, --useCount);
+ } else {
+ logger.warning("Tried to release non existing local name server on port " + port);
+ }
+
+ }
+
+ public void stop() {
+ for (TransientNameServer tns : localServers.values()) {
+ tns.stop();
+ }
+ }
+
+ public void start() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost
new file mode 100644
index 0000000000..5706b13a42
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.host.corba.jse.tns.TnsDefaultCorbaHost;ranking=10
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java
new file mode 100644
index 0000000000..85ac98cfef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.testing;
+
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import java.net.Socket;
+import java.net.SocketException;
+
+import org.apache.tuscany.sca.binding.corba.provider.service.DynaCorbaServant;
+import org.apache.tuscany.sca.host.corba.jse.tns.TnsDefaultCorbaHost;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ * General tests
+ */
+public class TnsDefaultCorbaHostTestCase {
+
+ private static TnsDefaultCorbaHost host;
+
+ @BeforeClass
+ public static void start() {
+ try {
+ host = new TnsDefaultCorbaHost();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void stop() {
+ host.stop();
+ }
+
+ /**
+ * Test for creating and releasing local name server
+ */
+ @Test
+ @Ignore
+ public void test_localNameServer() {
+ int testPort = 5070;
+ try {
+ String testUri1 = "corbaname::localhost:" + testPort + "#Test1";
+ String testUri2 = "corbaname::localhost:" + testPort + "#Test2";
+ String testUri3 = "corbaname::localhost:" + testPort + "#Test3";
+ DynaCorbaServant servant = new DynaCorbaServant(null, "IDL:org/apache/tuscany:1.0");
+ host.registerServant(testUri1, servant);
+ host.registerServant(testUri2, servant);
+ host.registerServant(testUri3, servant);
+ Thread.sleep(1000);
+ // make test connection to name server
+ Socket socket = new Socket("localhost", testPort);
+ socket.close();
+ // and stop server
+ host.unregisterServant(testUri1);
+ host.unregisterServant(testUri2);
+ // after releasing 2 clients 3rd should still hold the server
+ socket = new Socket("localhost", testPort);
+ socket.close();
+ host.unregisterServant(testUri3);
+ Thread.sleep(1000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ try {
+ // previously made 3rd stop so there should be no name server under
+ // this port
+ new Socket("localhost", testPort);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof SocketException);
+ }
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/LICENSE b/sandbox/sebastien/java/embed/modules/host-corba-jse/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/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/sebastien/java/embed/modules/host-corba-jse/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/host-corba-jse/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..701f471038
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/META-INF/MANIFEST.MF
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.corba.jse;version="2.0.0";
+ uses:="org.omg.CosNaming.NamingContextPackage,
+ org.omg.CosNaming,
+ org.apache.tuscany.sca.host.corba,
+ org.omg.CORBA,
+ org.apache.tuscany.sca.core",
+ org.apache.tuscany.sca.host.corba.naming;version="2.0.0";
+ uses:="org.omg.CosNaming.NamingContextPackage,
+ org.omg.CosNaming,
+ org.omg.CosNaming.NamingContextExtPackage,
+ org.omg.CORBA,
+ org.omg.PortableServer"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JSE built-in CORBA Host
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397133187
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JSE built-in CORBA Host
+Import-Package: org.apache.tuscany.sca.core;version="2.0.0",org.apache.t
+ uscany.sca.host.corba;version="2.0.0",org.apache.tuscany.sca.host.corba
+ .jse;version="2.0.0",org.apache.tuscany.sca.host.corba.naming;version="
+ 1.4",org.omg.CORBA,org.omg.CosNaming,org.omg.CosNaming.NamingContextE
+ xtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.PortableServ
+ er,org.omg.CORBA.portable;resolu
+ tion:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.host.corba.jse
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/NOTICE b/sandbox/sebastien/java/embed/modules/host-corba-jse/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/pom.xml b/sandbox/sebastien/java/embed/modules/host-corba-jse/pom.xml
new file mode 100644
index 0000000000..72cb65f5b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/pom.xml
@@ -0,0 +1,38 @@
+<?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>2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>tuscany-host-corba-jse</artifactId>
+ <name>Apache Tuscany SCA JSE built-in CORBA Host</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java
new file mode 100644
index 0000000000..9bdcd12988
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.jse;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.host.corba.CorbaHostException;
+import org.apache.tuscany.sca.host.corba.CorbaHostUtils;
+import org.apache.tuscany.sca.host.corba.CorbanameURL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExt;
+import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * @version $Rev$ $Date$
+ * Default implementation of JSE CORBA host
+ */
+public class DefaultCorbaHost implements CorbaHost, LifeCycleListener {
+ private static final Logger logger = Logger.getLogger(DefaultCorbaHost.class.getName());
+
+ private Map<String, ORB> orbs = new ConcurrentHashMap<String, ORB>();
+
+ private void validatePort(int port) throws IllegalArgumentException {
+ if (port < 1) {
+ throw new IllegalArgumentException("Port value should be > 0");
+ }
+ }
+
+ private NamingContextExt getNamingContext(ORB orb, String nameService) throws Exception {
+ org.omg.CORBA.Object objRef = orb.resolve_initial_references(nameService);
+ return NamingContextExtHelper.narrow(objRef);
+ }
+
+ private void handleException(Exception e) throws CorbaHostException {
+ // The cause of the Exception is JDK specific
+ if (e instanceof NotFound) {
+ throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT, e);
+ } else if (e instanceof InvalidName) {
+ throw new CorbaHostException(e);
+ } else {
+ throw new CorbaHostException(e);
+ }
+ }
+
+ public void registerServant(String uri, Object servantObject) throws CorbaHostException {
+ CorbanameURL details = CorbaHostUtils.getServiceDetails(uri);
+ ORB orb = createORB(details.getHost(), details.getPort(), false);
+ try {
+ NamingContext namingCtx = getNamingContext(orb, details.getNameService());
+ for (int i = 0; i < details.getNamePath().size() - 1; i++) {
+ NameComponent nc = new NameComponent(details.getNamePath().get(i), "");
+ NameComponent[] path = new NameComponent[] {nc};
+ try {
+ namingCtx = NamingContextHelper.narrow(namingCtx.resolve(path));
+ } catch (Exception e) {
+ namingCtx = namingCtx.bind_new_context(path);
+ }
+ }
+ NameComponent finalName =
+ new NameComponent(details.getNamePath().get(details.getNamePath().size() - 1), "");
+ try {
+ namingCtx.resolve(new NameComponent[] {finalName});
+ // no exception means that some object is already registered
+ // under this name, we need to crash here
+ throw new CorbaHostException(CorbaHostException.BINDING_IN_USE);
+ } catch (NotFound e) {
+ namingCtx.bind(new NameComponent[] {finalName}, servantObject);
+ }
+ } catch (CorbaHostException e) {
+ throw e;
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ public void unregisterServant(String uri) throws CorbaHostException {
+ CorbanameURL details = CorbaHostUtils.getServiceDetails(uri);
+ ORB orb = createORB(details.getHost(), details.getPort(), false);
+ try {
+ NamingContextExt namingCtx = getNamingContext(orb, details.getNameService());
+ namingCtx.unbind(namingCtx.to_name(details.getName()));
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ public Object lookup(String uri) throws CorbaHostException {
+ Object result = null;
+ try {
+ CorbanameURL url = new CorbanameURL(uri);
+ ORB orb = createORB(url.getHost(), url.getPort(), false);
+ NamingContextExt context = getNamingContext(orb, url.getNameService());
+ result = context.resolve_str(url.getName());
+ } catch (Exception e) {
+ handleException(e);
+ }
+ if (result == null) {
+ throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT);
+ }
+ return result;
+ }
+
+ public ORB createORB(String host, int port, boolean server) throws CorbaHostException {
+ validatePort(port);
+
+ String key = host + ":" + port;
+ ORB orb = orbs.get(key);
+ if (orb != null) {
+ return orb;
+ }
+ // Create an ORB object
+ Properties props = new Properties();
+ props.putAll(System.getProperties());
+
+ String portStr = String.valueOf(port);
+ props.put("org.omg.CORBA.ORBServerId", "1000000");
+ props.put("org.omg.CORBA.ORBInitialHost", host);
+ props.put("org.omg.CORBA.ORBInitialPort", portStr);
+
+ // STEP 1: Set ORBPeristentServerPort property
+ // Set the proprietary property to open up a port to listen to
+ // INS requests.
+
+ if (server) {
+ props.put("com.sun.CORBA.POA.ORBPersistentServerPort", portStr);
+ props.put("com.ibm.CORBA.ListenerPort", portStr);
+ props.put("gnu.CORBA.ListenerPort", portStr);
+ // props.put("org.omg.CORBA.ORBClass",
+ // "org.apache.yoko.orb.CORBA.ORB");
+ // props.put("org.omg.CORBA.ORBSingletonClass",
+ // "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.oa.endpoint", "iiop --host " + host + " --port " + port);
+ props.put("yoko.orb.poamanager.TNameService.endpoint", "iiop --host " + host);
+ }
+
+ String[] args = {"-ORBInitialHost", host, "-ORBInitialPort", "" + port};
+ orb = ORB.init(args, props);
+ orbs.put(key, orb);
+ return orb;
+ }
+
+ public void start() {
+
+ }
+ public void stop() {
+ for (ORB orb : orbs.values()) {
+ try {
+ orb.shutdown(true);
+ orb.destroy();
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java
new file mode 100644
index 0000000000..59f0ce9a53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java
@@ -0,0 +1,863 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * @version $Rev$ $Date$
+ */
+
+package org.apache.tuscany.sca.host.corba.naming;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CosNaming.BindingType;
+import org.omg.CosNaming.BindingTypeHolder;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExtPOA;
+import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+import org.omg.CosNaming.NamingContextPackage.NotFoundReason;
+import org.omg.PortableServer.POA;
+
+public abstract class NamingContextBase extends NamingContextExtPOA {
+ // the real logger backing instance. We use the interface class as the locator
+ protected static final Logger logger = Logger.getLogger(NamingContext.class.getName());
+
+ // set of URL characters that don't require escaping when encoded.
+ protected final String nonEscaped = ";/?:@&=+$;-_.!~* ()";
+ // the orb we're attached to
+ protected ORB orb;
+ // the poa we're associated with
+ protected POA poa;
+
+ /**
+ * Create a new base NamingContext (super class constructor
+ * for the derived classes).
+ *
+ * @param orb The ORB this is hosted on.
+ *
+ * @exception java.lang.Exception
+ */
+ public NamingContextBase(ORB orb, POA poa) throws java.lang.Exception {
+ super();
+ this.orb = orb;
+ this.poa = poa;
+ }
+
+ /**
+ * Bind an object to a given name.
+ *
+ * @param n An array of NameComponents that are the target name.
+ * The last element in the array is binding name for the
+ * object. The remainder of the array is the path
+ * for resolving the naming context, relative to the
+ * current context. All path contexts must already be
+ * bound in the context tree.
+ * @param obj The object to be bound.
+ *
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+ */
+ public void bind(org.omg.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj)
+ throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+ org.omg.CosNaming.NamingContextPackage.InvalidName, org.omg.CosNaming.NamingContextPackage.AlreadyBound {
+ // perform various name validations
+ validateName(n);
+
+ logNameComponent("bind() name", n);
+
+ // do we need to push through to a deeper naming context first?
+ if (n.length > 1) {
+ // resolve the top level name to a context, and have that context
+ // resolve the rest.
+ NamingContext context = resolveContext(n[0]);
+ NameComponent[] subName = extractSubName(n);
+
+ // now pass this along to the next context for the real bind operation.
+ context.bind(subName, obj);
+ } else {
+ NameComponent name = n[0];
+ // we need the resolveObject() and bindObject() calls to be consistent, so
+ // synchronize on this
+ synchronized (this) {
+ // see if we have this bound already...can't replace these.
+ BindingTypeHolder type = new BindingTypeHolder();
+ if (resolveObject(name, type) != null) {
+ throw new AlreadyBound();
+ }
+ type.value = BindingType.nobject;
+ // ok, this is a new binding, go do it.
+ bindObject(name, obj, type);
+ }
+ }
+ }
+
+ /**
+ * Rebind an object to a given name. If an object is
+ * already bound with this name, the new object replaces
+ * the bound object's value. If no object has been
+ * bound already, this is the same as a bind operation.
+ *
+ * @param n An array of NameComponents that are the target name.
+ * The last element in the array is binding name for the
+ * object. The remainder of the array is the path
+ * for resolving the naming context, relative to the
+ * current context. All path contexts must already be
+ * bound in the context tree.
+ * @param obj The new value for this binding.
+ *
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+ */
+ public void rebind(org.omg.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj)
+ throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+ org.omg.CosNaming.NamingContextPackage.InvalidName {
+ // perform various name validations
+ validateName(n);
+
+ logNameComponent("rebind() name", n);
+
+ // do we need to push through to a deeper naming context first?
+ if (n.length > 1) {
+ // resolve the top level name to a context, and have that context
+ // resolve the rest.
+ NamingContext context = resolveContext(n[0]);
+ NameComponent[] subName = extractSubName(n);
+
+ // now pass this along to the next context for the real bind operation.
+ context.rebind(subName, obj);
+ } else {
+ NameComponent name = n[0];
+ // we need the resolveObject() and bindObject() calls to be consistent, so
+ // synchronize on this
+ synchronized (this) {
+ // see if we have this bound already...can't replace these.
+ BindingTypeHolder type = new BindingTypeHolder();
+ // for a rebind, we must have an object, and it must be a real object
+ if (resolveObject(name, type) != null) {
+ // it has to resolve to a real object. If it is a naming context,
+ // then this is the wrong binding operation.
+ if (type.value.value() == BindingType._ncontext) {
+ throw new NotFound(NotFoundReason.not_object, n);
+ }
+ // safe to unbind
+ unbindObject(name);
+ }
+ type.value = BindingType.nobject;
+ // now bind this object
+ bindObject(name, obj, type);
+ }
+ }
+ }
+
+ /**
+ * Bind a new context to a given name.
+ *
+ * @param n An array of NameComponents that are the target name.
+ * The last element in the array is binding name for the
+ * object. The remainder of the array is the path
+ * for resolving the naming context, relative to the
+ * current context. All path contexts must already be
+ * bound in the context tree.
+ * @param nc The new naming context added to the tree.
+ *
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+ */
+ public void bind_context(org.omg.CosNaming.NameComponent[] n, org.omg.CosNaming.NamingContext nc)
+ throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+ org.omg.CosNaming.NamingContextPackage.InvalidName, org.omg.CosNaming.NamingContextPackage.AlreadyBound {
+ // perform various name validations
+ validateName(n);
+
+ logNameComponent("bind_context() name", n);
+
+ // do we need to push through to a deeper naming context first?
+ if (n.length > 1) {
+ // resolve the top level name to a context, and have that context
+ // resolve the rest.
+ NamingContext context = resolveContext(n[0]);
+ NameComponent[] subName = extractSubName(n);
+
+ // now pass this along to the next context for the real bind operation.
+ context.bind_context(subName, nc);
+ } else {
+ NameComponent name = n[0];
+ // we need the resolveObject() and bindObject() calls to be consistent, so
+ // synchronize on this
+ synchronized (this) {
+ // see if we have this bound already...can't replace these.
+ BindingTypeHolder type = new BindingTypeHolder();
+ if (resolveObject(name, type) != null) {
+ throw new AlreadyBound();
+ }
+ type.value = BindingType.ncontext;
+ // ok, this is a new binding, go do it.
+ bindObject(name, nc, type);
+ }
+ }
+ }
+
+ /**
+ * Rebind a context to a given name. If a context is
+ * already bound with this name, the new context replaces
+ * the existing context. If no context has been
+ * bound already, this is the same as a bind operation.
+ *
+ * @param n An array of NameComponents that are the target name.
+ * The last element in the array is binding name for the
+ * object. The remainder of the array is the path
+ * for resolving the naming context, relative to the
+ * current context. All path contexts must already be
+ * bound in the context tree.
+ * @param nc The new context to be bound with the name.
+ *
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+ */
+ public void rebind_context(org.omg.CosNaming.NameComponent[] n, org.omg.CosNaming.NamingContext nc)
+ throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+ org.omg.CosNaming.NamingContextPackage.InvalidName {
+ // perform various name validations
+ validateName(n);
+
+ logNameComponent("rebind_context() name", n);
+
+ // do we need to push through to a deeper naming context first?
+ if (n.length > 1) {
+ // resolve the top level name to a context, and have that context
+ // resolve the rest.
+ NamingContext context = resolveContext(n[0]);
+ NameComponent[] subName = extractSubName(n);
+
+ // now pass this along to the next context for the real bind operation.
+ context.rebind_context(subName, nc);
+ } else {
+ NameComponent name = n[0];
+ // we need the resolveObject() and bindObject() calls to be consistent, so
+ // synchronize on this
+ synchronized (this) {
+ // see if we have this bound already...can't replace these.
+ BindingTypeHolder type = new BindingTypeHolder();
+ // for a rebind, we must have an object, and it must be a real object
+ if (resolveObject(name, type) != null) {
+ // it has to resolve to a real object. If it is a naming context,
+ // then this is the wrong binding operation.
+ if (type.value.value() != BindingType._ncontext) {
+ throw new NotFound(NotFoundReason.not_context, n);
+ }
+ // safe to unbind
+ unbindObject(name);
+ }
+ type.value = BindingType.ncontext;
+ // now bind this object
+ bindObject(name, nc, type);
+ }
+ }
+ }
+
+ /**
+ * Resolve an an entry in the context tree. The
+ * resolved object may be a bound object or another
+ * NamingContext. If the named entry is not found,
+ * a NotFound exception is thrown.
+ *
+ * @param n An array of NameComponents that are the target name.
+ * The last element in the array is binding name for the
+ * object. The remainder of the array is the path
+ * for resolving the naming context, relative to the
+ * current context. All path contexts must already be
+ * bound in the context tree.
+ *
+ * @return The object bound at the indicated location.
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+ */
+ public org.omg.CORBA.Object resolve(org.omg.CosNaming.NameComponent[] n)
+ throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed,
+ org.omg.CosNaming.NamingContextPackage.InvalidName {
+ // perform various name validations
+ validateName(n);
+
+ logNameComponent("resolve() name", n);
+
+ // do we need to push through to a deeper naming context first?
+ if (n.length > 1) {
+ // resolve the top level name to a context, and have that context
+ // resolve the rest.
+ NamingContext context = resolveContext(n[0]);
+ NameComponent[] subName = extractSubName(n);
+
+ // now pass this along to the next context for the real bind operation.
+ return context.resolve(subName);
+ } else {
+ NameComponent name = n[0];
+ // see if we have this bound already...can't replace these.
+ BindingTypeHolder type = new BindingTypeHolder();
+ org.omg.CORBA.Object obj = resolveObject(name, type);
+ if (obj == null) {
+ // Object was not found
+ throw new NotFound(NotFoundReason.missing_node, n);
+ }
+ return obj;
+ }
+ }
+
+ /**
+ * Remove an entry from the context tree. The
+ * target object may be a bound object or another
+ * NamingContext. If the named entry is not found,
+ * a NotFound exception is thrown.
+ *
+ * @param n An array of NameComponents that are the target name.
+ * The last element in the array is binding name for the
+ * object. The remainder of the array is the path
+ * for resolving the naming context, relative to the
+ * current context. All path contexts must already be
+ * bound in the context tree.
+ *
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+ */
+ public void unbind(org.omg.CosNaming.NameComponent[] n) throws org.omg.CosNaming.NamingContextPackage.NotFound,
+ org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName {
+ // perform various name validations
+ validateName(n);
+
+ logNameComponent("unbind() name", n);
+
+ // do we need to push through to a deeper naming context first?
+ if (n.length > 1) {
+ // resolve the top level name to a context, and have that context
+ // resolve the rest.
+ NamingContext context = resolveContext(n[0]);
+ NameComponent[] subName = extractSubName(n);
+
+ // now pass this along to the next context for the real bind operation.
+ context.unbind(subName);
+ } else {
+ NameComponent name = n[0];
+ synchronized (this) {
+ // see if we have this bound already...can't replace these.
+ BindingTypeHolder type = new BindingTypeHolder();
+ org.omg.CORBA.Object obj = unbindObject(name);
+ if (obj == null) {
+ // Object was not found
+ throw new NotFound(NotFoundReason.missing_node, n);
+ }
+ }
+ }
+ }
+
+ /**
+ * Create a new context and bind it in at the target
+ * location.
+ *
+ * @param n An array of NameComponents that are the target name.
+ * The last element in the array is binding name for the
+ * object. The remainder of the array is the path
+ * for resolving the naming context, relative to the
+ * current context. All path contexts must already be
+ * bound in the context tree.
+ *
+ * @return The newly created context.
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
+ */
+ public synchronized org.omg.CosNaming.NamingContext bind_new_context(org.omg.CosNaming.NameComponent[] n)
+ throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.AlreadyBound,
+ org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName {
+ logNameComponent("bind_new_context() name", n);
+
+ NamingContext context = new_context();
+ try {
+ bind_context(n, context);
+ NamingContext returnContext = context;
+ // transfer this to another variable so the finally block doesn't try to destroy this.
+ context = null;
+ return returnContext;
+ } finally {
+ // if there is a bind failure on this, we need to ensure the context has
+ // an opportunity to clean up any of its resources.
+ if (context != null) {
+ try {
+ context.destroy();
+ } catch (org.omg.CosNaming.NamingContextPackage.NotEmpty e) {
+ // new contexts should be empty.
+ }
+ }
+ }
+ }
+
+ /**
+ * Convert an array of NameComponents into the string
+ * form of a context name.
+ *
+ * @param n The array of NameComponents to convert.
+ *
+ * @return The context name, in string form.
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ */
+ public String to_string(org.omg.CosNaming.NameComponent[] n)
+ throws org.omg.CosNaming.NamingContextPackage.InvalidName {
+ validateName(n);
+
+ logNameComponent("to_string() name", n);
+
+ // convert the first part of the name
+ StringBuffer value = new StringBuffer();
+ ;
+ // convert the first component, then build up from there.
+ nameToString(n[0], value);
+
+ // the remainder need to get a separator
+ for (int i = 1; i < n.length; i++) {
+ value.append('/');
+ nameToString(n[i], value);
+ }
+ return value.toString();
+ }
+
+ /**
+ * Perform the reverse operation of the to_string() method,
+ * parsing a String context name into an array of
+ * NameComponents.
+ *
+ * @param sn The string form of the name.
+ *
+ * @return An array of NameComponents parsed from the String name.
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ */
+ public org.omg.CosNaming.NameComponent[] to_name(String sn)
+ throws org.omg.CosNaming.NamingContextPackage.InvalidName {
+ // must have a argument to parse
+ if (sn == null || sn.length() == 0) {
+ throw new InvalidName();
+ }
+
+ List components = new ArrayList();
+
+ StringBuffer component = new StringBuffer();
+
+ int index = 0;
+ String id = null;
+ String kind = null;
+ while (index < sn.length()) {
+ char ch = sn.charAt(index++);
+
+ // found an escape character or a delimiter?
+ if (ch == '\\') {
+ // nothing after the escape? Trouble
+ if (index >= sn.length()) {
+ throw new InvalidName();
+ }
+ // get the next character
+ ch = sn.charAt(index++);
+ component.append(ch);
+ }
+ // we need to process the periods here, to avoid getting
+ // mixed up with unescaped periods.
+ else if (ch == '.') {
+ // already seen a period while scanning? That's not allowed
+ if (id != null) {
+ throw new InvalidName();
+ }
+ // pull off the id piece and reset the buffer
+ id = component.toString();
+ component.setLength(0);
+ }
+ // found a component delimiter?
+ else if (ch == '/') {
+ // not seen a id/kind separator yet? This is an id with no kind
+ if (id == null) {
+ id = component.toString();
+ kind = "";
+ } else {
+ // we have an id already, pull off the kind
+ kind = component.toString();
+ }
+ // add the parsed name component
+ components.add(new NameComponent(id, kind));
+ // make sure these are all reset after pulling off a component
+ component.setLength(0);
+ id = null;
+ kind = null;
+ } else {
+ component.append(ch);
+ }
+ }
+
+ // parse the last section
+ // not seen a id/kind separator yet? This is an id with no kind
+ if (id == null) {
+ id = component.toString();
+ kind = "";
+ } else {
+ // we have an id already, pull off the kind
+ kind = component.toString();
+ }
+ // add the parsed name component
+ components.add(new NameComponent(id, kind));
+
+ // and turn this into a component array
+ return (NameComponent[])components.toArray(new NameComponent[components.size()]);
+ }
+
+ /**
+ * Create a URL name for accessing a component by name. The
+ * URL will have a corbaname: protocol.
+ *
+ * @param addr The address location for the naming service used
+ * to resolve the object. This is in "host:port" form,
+ * just line a corbaloc: URL.
+ * @param sn The string mae of the target object.
+ *
+ * @return A URL for accessing this object, in String form.
+ * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidAddress
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ */
+ public String to_url(String addr, String sn) throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress,
+ org.omg.CosNaming.NamingContextPackage.InvalidName {
+ // basic validation
+ if (addr == null || addr.length() == 0) {
+ throw new InvalidAddress();
+ }
+
+ if (sn == null || sn.length() == 0) {
+ throw new InvalidName();
+ }
+
+ // TODO: What validation, if any, needs to be done here?
+ return "corbaname:" + addr + "#" + encodeRFC2396Name(sn);
+ }
+
+ /**
+ * Resolve a bound object or context using a name
+ * in String form.
+ *
+ * @param n The string name of the object context. This must
+ * be a form parseable by to_name().
+ *
+ * @return The bound object or context.
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
+ */
+ public org.omg.CORBA.Object resolve_str(String n) throws org.omg.CosNaming.NamingContextPackage.NotFound,
+ org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName {
+ // this is just a simple convenience method
+ return resolve(to_name(n));
+ }
+
+ // abstract methods that are part of the NamingContext interface that need to be
+ // implemented by the subclasses.
+
+ /**
+ * Create a new context of the same type as the
+ * calling context.
+ *
+ * @return A new NamingContext item.
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception SystemException
+ */
+ public abstract org.omg.CosNaming.NamingContext new_context() throws SystemException;
+
+ /**
+ * Destroy a context. This method should clean up
+ * any backing resources associated with the context.
+ *
+ * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty
+ */
+ public abstract void destroy() throws org.omg.CosNaming.NamingContextPackage.NotEmpty;
+
+ /**
+ * Create a list of bound objects an contexts contained
+ * within this context.
+ *
+ * @param how_many The count of elements to return as a BindingList.
+ * @param bl A holder element for returning the source binding list.
+ * @param bi A holder for returning a BindingIterator. Any extra
+ * elements not returned in the BindingList are returned
+ * in the BindingIterator.
+ *
+ * @exception SystemException
+ */
+ public abstract void list(int how_many,
+ org.omg.CosNaming.BindingListHolder bl,
+ org.omg.CosNaming.BindingIteratorHolder bi) throws SystemException;
+
+ // abstract methods for the sub class to implement
+
+ /**
+ * Resolve an object in this context (single level
+ * resolution).
+ *
+ * @param n The name of the target object.
+ * @param type A type holder for returning the bound object type
+ * information.
+ *
+ * @return The bound object. Returns null if the object does not
+ * exist in the context.
+ * @exception SystemException
+ */
+ protected abstract org.omg.CORBA.Object resolveObject(NameComponent n, BindingTypeHolder type)
+ throws SystemException;
+
+ /**
+ * Bind an object into the current context. This can
+ * be either an object or a naming context.
+ *
+ * @param n The single-level name of the target object.
+ * @param obj The object or context to be bound.
+ * @param type
+ *
+ * @exception SystemException
+ */
+ protected abstract void bindObject(NameComponent n, org.omg.CORBA.Object obj, BindingTypeHolder type)
+ throws SystemException;
+
+ /**
+ * Unbind an object from the current context.
+ *
+ * @param n The name of the target object (single level).
+ *
+ * @return The object associated with the binding. Returns null
+ * if there was no binding currently associated with this
+ * name.
+ * @exception SystemException
+ */
+ protected abstract org.omg.CORBA.Object unbindObject(NameComponent n) throws SystemException;
+
+ // implementation specific routines
+
+ /**
+ * Resolve a name to a context object stored that has
+ * already been stored in this context. Throws an exception
+ * if the name cannot be resolved or if the resolved
+ * object is not a naming context.
+ *
+ * @param name The target name.
+ *
+ * @return The resolved NamingContext object.
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ */
+ protected synchronized NamingContext resolveContext(NameComponent name)
+ throws org.omg.CosNaming.NamingContextPackage.NotFound {
+ BindingTypeHolder type = new BindingTypeHolder();
+ // Resolve this to an object. We must be able to resolve this.
+ org.omg.CORBA.Object resolvedReference = resolveObject(name, type);
+ if (resolvedReference == null) {
+ throw new NotFound(NotFoundReason.missing_node, new NameComponent[] {name});
+ }
+
+ // it has to resolve to a naming context
+ if (type.value.value() != BindingType._ncontext) {
+ throw new NotFound(NotFoundReason.not_context, new NameComponent[] {name});
+ }
+
+ // in theory, this is a naming context. Narrow it an return. Any
+ // errors just become a NotFound exception
+ try {
+ return NamingContextHelper.narrow(resolvedReference);
+ } catch (org.omg.CORBA.BAD_PARAM ex) {
+ throw new NotFound(NotFoundReason.not_context, new NameComponent[] {name});
+ }
+ }
+
+ /**
+ * Extract the tail portion of a name. This is used
+ * to strip off the first name element so we can recurse
+ * on the name resolutions with a resolved context.
+ *
+ * @param name The current name array (this MUST have 2 or more
+ * elements).
+ *
+ * @return An array of NameComponent items that is one element
+ * smaller than the argument array, with the elements
+ * shifted over.
+ */
+ protected NameComponent[] extractSubName(NameComponent[] name) {
+ NameComponent[] subName = new NameComponent[name.length - 1];
+ System.arraycopy(name, 1, subName, 0, name.length - 1);
+ return subName;
+ }
+
+ /**
+ * Perform common name validity checking.
+ *
+ * @param n The NameComponent array to check.
+ *
+ * @exception InvalidName
+ */
+ protected void validateName(NameComponent[] n) throws InvalidName {
+ // perform various name validations
+ if (n == null) {
+ throw new BAD_PARAM(27 | org.omg.CORBA.OMGVMCID.value, CompletionStatus.COMPLETED_NO);
+ }
+
+ // Valid name?
+ if (n.length < 1) {
+ throw new InvalidName();
+ }
+
+ // we have at least one name, so validate the toplevel item
+ NameComponent name = n[0];
+
+ // more name validation
+ if (name.id.length() == 0 && name.kind.length() == 0) {
+ throw new InvalidName();
+ }
+ }
+
+ /**
+ * Convert a NameComponent item into a string form,
+ * appending it to a StringBuffer.
+ *
+ * @param name The source NameComponent.
+ * @param out The StringBuffer location used to store the name
+ * value (appended to the end).
+ */
+ protected void nameToString(NameComponent name, StringBuffer out) {
+ // if the id is null, then we base off of the kind.
+ if (name.id == null || name.id.length() == 0) {
+ out.append(".");
+ // true null name element? That displays as a "."
+ if (name.kind != null && name.kind.length() != 0) {
+ escapeName(name.kind, out);
+ }
+ } else {
+ // escape the name
+ escapeName(name.id, out);
+ // have a kind qualifier to add on?
+ if (name.kind != null && name.kind.length() != 0) {
+ out.append(".");
+ escapeName(name.kind, out);
+ }
+ }
+ }
+
+ /**
+ * Process a name or kind element of a NameComponent,
+ * adding escape characters for '.' or '/' characters
+ * that might appear in the name.
+ *
+ * @param name The name element to process.
+ * @param out The StringBuffer to copy the escaped name into.
+ */
+ protected void escapeName(String name, StringBuffer out) {
+ // no characters requiring escapes (common)?
+ // use this directly
+ if (name.indexOf('.') == -1 && name.indexOf('/') == -1) {
+ out.append(name);
+ } else {
+ // scan the string adding the escapes
+ for (int i = 0; i < name.length(); i++) {
+ char ch = name.charAt(i);
+ if (ch == '.' || ch == '/') {
+ out.append('/');
+ }
+ out.append(ch);
+ }
+ }
+ }
+
+ /**
+ * Perform RFC 2396 escape encoding of a name value.
+ *
+ * @param name The input name value.
+ *
+ * @return An encoded name, with special characters converted
+ * into a hex encoded value.
+ */
+ protected String encodeRFC2396Name(String name) {
+ StringBuffer value = new StringBuffer();
+
+ for (int i = 0; i < name.length(); i++) {
+ char ch = name.charAt(i);
+
+ // Alphanumerics and the "acceptable" set of special characters just get copied
+ // without encoding.
+ if (Character.isLetterOrDigit(ch) || nonEscaped.indexOf(ch) != -1) {
+ value.append(ch);
+ } else {
+ // this gets converted into a hex value, marked by "%".
+ value.append('%');
+ value.append(Integer.toHexString((int)ch));
+ }
+ }
+ return value.toString();
+ }
+
+ /**
+ * Test if debug logging is currently available.
+ *
+ * @return True if debug level (FINE) logging is currently turned on.
+ */
+ protected boolean isDebugEnabled() {
+ return logger.isLoggable(Level.FINE);
+ }
+
+ /**
+ * Log a line of debug output
+ *
+ * @param message The message to log
+ */
+ protected void debug(String message) {
+ logger.fine(message);
+ }
+
+ /**
+ * Log the name components passed in for a request.
+ *
+ * @param message A message describing the request context.
+ * @param n The array of name components.
+ */
+ protected void logNameComponent(String message, NameComponent[] n) {
+ if (isDebugEnabled()) {
+ debug(message);
+ for (int i = 0; i < n.length; i++) {
+ debug(" NameComponent " + i + " id=" + n[i].id + " kind=" + n[i].kind);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java
new file mode 100644
index 0000000000..087b2e4357
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @version $Rev$ $Date$
+ */
+package org.apache.tuscany.sca.host.corba.naming;
+
+import org.omg.CORBA.ORB;
+
+/**
+ * A stand-alone naming service launchable from a command line.
+ */
+public class TransientNameServer {
+ private final TransientNameService service;
+ private final Object flag = new Object();
+ private Boolean started;
+
+ public TransientNameServer(String host, int port, String serviceName) {
+ this.service = new TransientNameService(host, port, serviceName);
+ }
+
+ public ORB getORB() {
+ return service.getORB();
+ }
+
+ public Thread start() {
+ Thread t = new Thread() {
+ public void run() {
+ ORB orb = null;
+ synchronized (flag) {
+ try {
+ service.run();
+ orb = service.getORB();
+ started = Boolean.TRUE;
+ } catch (Throwable e) {
+ started = Boolean.FALSE;
+ throw new IllegalStateException(e);
+ } finally {
+ flag.notifyAll();
+ }
+ }
+ // Wait for requests
+ orb.run();
+ }
+ };
+ t.setDaemon(true);
+ t.start();
+ checkState();
+ return t.isAlive() ? t : null;
+ }
+
+ private Boolean checkState() {
+ synchronized (flag) {
+ while (started == null) {
+ try {
+ flag.wait();
+ } catch (InterruptedException e) {
+ return null;
+ }
+ }
+ return started;
+ }
+ }
+
+ public void stop() {
+ if (Boolean.TRUE.equals(started)) {
+ service.destroy();
+ started = Boolean.FALSE;
+ }
+ }
+
+ /**
+ * Launch a name service as a stand alone process. The
+ * Host, port, and service name are controlled using
+ * program arguments.
+ *
+ * @param args The array of arguments for tailoring the service.
+ *
+ * @exception Exception
+ */
+ public static void main(String args[]) throws Exception {
+ int port = TransientNameService.DEFAULT_SERVICE_PORT;
+ String host = TransientNameService.DEFAULT_SERVICE_HOST;
+ String serviceName = TransientNameService.DEFAULT_SERVICE_NAME;
+
+ // see if we have
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("-ORBInitialPort")) {
+ i++;
+ if (i < args.length) {
+ port = java.lang.Integer.parseInt(args[i]);
+ } else {
+ throw new IllegalArgumentException("Invalid -ORBInitialPort option");
+ }
+ } else if (args[i].equals("-ORBInitialHost")) {
+ i++;
+ if (i < args.length) {
+ host = args[i];
+ } else {
+ throw new IllegalArgumentException("Invalid -ORBInitialHost option");
+ }
+ } else if (args[i].equals("-ORBServiceName")) {
+ i++;
+ if (i < args.length) {
+ serviceName = args[i];
+ } else {
+ throw new IllegalArgumentException("Invalid -ORBServiceName option");
+ }
+ }
+
+ }
+ // create a services, and just spin it off. We wait forever after that.
+ TransientNameServer server = new TransientNameServer(host, port, serviceName);
+ server.start().join();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java
new file mode 100644
index 0000000000..77617a6c5c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @version $Rev$ $Date$
+ */
+package org.apache.tuscany.sca.host.corba.naming;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Properties;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Policy;
+import org.omg.PortableServer.IdAssignmentPolicyValue;
+import org.omg.PortableServer.LifespanPolicyValue;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.ServantRetentionPolicyValue;
+
+/**
+ * A transient name service attached to an ORB. This
+ * class manages all of the housekeeping for creating a
+ * TransientNamingContext and a exposing it using an
+ * ORB.
+ */
+public class TransientNameService {
+ // the default registered name service
+ static public final String DEFAULT_SERVICE_NAME = "TNameService";
+ // the default listening port
+ static public final int DEFAULT_SERVICE_PORT = 900;
+ // the default host name
+ static public final String DEFAULT_SERVICE_HOST = "localhost";
+
+ // the service root context
+ protected TransientNamingContext initialContext;
+ // initial listening port
+ protected int port;
+ // initial listening host
+ protected String host;
+ // the service name (used for registing for the corbaloc:: URL name
+ protected String serviceName;
+ // the orb instance we're running on
+ protected ORB createdOrb;
+
+ /**
+ * Create a new TransientNameService, using all default
+ * attributes.
+ */
+ public TransientNameService() {
+ this(DEFAULT_SERVICE_HOST, DEFAULT_SERVICE_PORT, DEFAULT_SERVICE_NAME);
+ }
+
+ /**
+ * Create a default-named name service using the specified
+ * host and port parameters.
+ *
+ * @param host The host to expose this under.
+ * @param port The initial listening port.
+ */
+ public TransientNameService(String host, int port) {
+ this(host, port, DEFAULT_SERVICE_NAME);
+ }
+
+ /**
+ * Create a specifically-named name service using the specified
+ * host and port parameters.
+ *
+ * @param host The host to expose this under.
+ * @param port The initial listening port.
+ * @param name The name to register this service under using the
+ * BootManager.
+ */
+ public TransientNameService(String host, int port, String name) {
+ this.port = port;
+ this.host = host;
+ this.serviceName = name;
+ }
+
+ /**
+ * Start up the name service, including creating an
+ * ORB instance to expose it under.
+ *
+ * @exception TransientServiceException
+ */
+ public void run() throws TransientServiceException {
+ // Create an ORB object
+ Properties props = new Properties();
+ props.putAll(System.getProperties());
+
+ String portStr = String.valueOf(port);
+ props.put("org.omg.CORBA.ORBServerId", "1000000");
+ props.put("org.omg.CORBA.ORBInitialHost", host);
+ props.put("org.omg.CORBA.ORBInitialPort", portStr);
+
+ // STEP 1: Set ORBPeristentServerPort property
+ // Set the proprietary property to open up a port to listen to
+ // INS requests.
+
+ props.put("com.sun.CORBA.POA.ORBPersistentServerPort", portStr);
+ props.put("com.ibm.CORBA.ListenerPort", portStr);
+ props.put("gnu.CORBA.ListenerPort", portStr);
+ // props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ // props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.oa.endpoint", "iiop --host " + host + " --port " + port);
+ props.put("yoko.orb.poamanager.TNameService.endpoint", "iiop --host " + host);
+
+ String[] args = {"-ORBInitialHost", host, "-ORBInitialPort", "" + port};
+ createdOrb = ORB.init(args, props);
+
+ // now initialize the service
+ initialize(createdOrb);
+
+ }
+
+ /**
+ * Initialize a transient name service on a specific
+ * ORB.
+ *
+ * @param orb The ORB hosting the service.
+ *
+ * @exception TransientServiceException
+ */
+ public void initialize(ORB orb) throws TransientServiceException {
+ try {
+ // get the root POA. We're going to re
+ POA rootPOA = (POA)orb.resolve_initial_references("RootPOA");
+ rootPOA.the_POAManager().activate();
+
+ // we need to create a POA to manage this named instance, and then activate
+ // a context on it.
+ Policy[] policy = new Policy[3];
+ policy[0] = rootPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
+ policy[1] = rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
+ policy[2] = rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
+
+ POA nameServicePOA = rootPOA.create_POA("TNameService", null, policy);
+ nameServicePOA.the_POAManager().activate();
+
+ // create our initial context, and register that with the ORB as the name service
+ initialContext = new TransientNamingContext(orb, nameServicePOA);
+ org.omg.CORBA.Object context = initialContext.getRootContext();
+ Method method =
+ orb.getClass().getMethod("register_initial_reference", String.class, org.omg.CORBA.Object.class);
+ method.invoke(orb, serviceName, context);
+ method.invoke(orb, "NamingService", context);
+ method.invoke(orb, "NameService", context);
+ } catch (Exception e) {
+ throw new TransientServiceException("Unable to initialize name service", e);
+ }
+ }
+
+ /**
+ * Destroy the created service.
+ */
+ public void destroy() {
+ // only destroy this if we created the orb instance.
+ if (createdOrb != null) {
+ createdOrb.shutdown(false);
+ createdOrb.destroy();
+
+ try {
+ // This is a workaround to close the sockets for SUN ORB
+ Method m = createdOrb.getClass().getMethod("getTransportManager");
+ Object tm = m.invoke(createdOrb);
+ m = tm.getClass().getMethod("close");
+ m.invoke(tm);
+ m = tm.getClass().getMethod("getAcceptors");
+ Collection acceptors = (Collection) m.invoke(tm);
+ for(Object a: acceptors) {
+ m = a.getClass().getMethod("close");
+ m.invoke(a);
+ }
+ } catch (Throwable e) {
+ // Ignore
+ }
+ createdOrb = null;
+ }
+ }
+
+ public ORB getORB() {
+ return createdOrb;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java
new file mode 100644
index 0000000000..a7164e9ef3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java
@@ -0,0 +1,440 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * @version $Rev$ $Date$
+ */
+
+package org.apache.tuscany.sca.host.corba.naming;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.omg.CORBA.INTERNAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CosNaming.Binding;
+import org.omg.CosNaming.BindingHolder;
+import org.omg.CosNaming.BindingIteratorHelper;
+import org.omg.CosNaming.BindingIteratorPOA;
+import org.omg.CosNaming.BindingType;
+import org.omg.CosNaming.BindingTypeHolder;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
+import org.omg.PortableServer.POA;
+
+public class TransientNamingContext extends NamingContextBase {
+ // the bindings maintained by this context
+ protected HashMap bindings = new HashMap();
+ // the root context object
+ protected org.omg.CORBA.Object rootContext = null;
+
+ /**
+ * Create a top-level naming context.
+ *
+ * @param orb The orb hosting this context.
+ * @param poa The POA used to activate the object.
+ *
+ * @exception Exception
+ */
+ public TransientNamingContext(ORB orb, POA poa) throws Exception {
+ this(orb, poa, null);
+ // now get the initial root context as a corba object.
+
+ byte[] objectId = poa.activate_object(this);
+ rootContext = poa.id_to_reference(objectId);
+
+ }
+
+ /**
+ * Construct a TransientNamingContext subcontext.
+ *
+ * @param orb The orb this context is associated with.
+ * @param poa The POA the root context is activated under.
+ * @param root The root context.
+ *
+ * @exception Exception
+ */
+ public TransientNamingContext(ORB orb, POA poa, org.omg.CORBA.Object root) throws Exception {
+ super(orb, poa);
+ // save the root context link.
+ rootContext = root;
+ }
+
+ // abstract methods part of the interface contract that the implementation is required
+ // to supply.
+
+ /**
+ * Create a new context of the same type as the
+ * calling context.
+ *
+ * @return A new NamingContext item.
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound
+ * @exception SystemException
+ */
+ public NamingContext new_context() throws SystemException {
+ try {
+ // create a new context. Then we need to register this with the POA and activate it.
+ TransientNamingContext newContext = new TransientNamingContext(orb, poa, rootContext);
+
+ byte[] objectId = poa.activate_object(newContext);
+ org.omg.CORBA.Object obj = poa.id_to_reference(objectId);
+ return NamingContextHelper.narrow(obj);
+ } catch (SystemException e) {
+ // just propagate system exceptions
+ throw e;
+ } catch (Exception e) {
+ throw (INTERNAL)(new INTERNAL("Unable to create new naming context").initCause(e));
+ }
+ }
+
+ /**
+ * Destroy a context. This method should clean up
+ * any backing resources associated with the context.
+ *
+ * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty
+ */
+ public synchronized void destroy() throws org.omg.CosNaming.NamingContextPackage.NotEmpty {
+ // still holding bound objects? Not allowed to destroy
+ if (!bindings.isEmpty()) {
+ throw new NotEmpty();
+ }
+
+ try {
+ // now detach ourselves from the POA
+ byte[] objectId = poa.servant_to_id(this);
+ if (objectId != null) {
+ poa.deactivate_object(objectId);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ /**
+ * Create a list of bound objects an contexts contained
+ * within this context.
+ *
+ * @param how_many The count of elements to return as a BindingList.
+ * @param bl A holder element for returning the source binding list.
+ * @param bi A holder for returning a BindingIterator. Any extra
+ * elements not returned in the BindingList are returned
+ * in the BindingIterator.
+ *
+ * @exception SystemException
+ */
+ public synchronized void list(int how_many,
+ org.omg.CosNaming.BindingListHolder bl,
+ org.omg.CosNaming.BindingIteratorHolder bi) throws SystemException {
+ TransientBindingIterator iterator = new TransientBindingIterator(poa, (HashMap)bindings.clone());
+ // have the iterator fill in the entries here
+ iterator.next_n(how_many, bl);
+
+ // now it's necessary to activate this iterator with the poa. The value we pass
+ // back is the narrowed activated object
+ try {
+ byte[] objectId = poa.activate_object(iterator);
+ org.omg.CORBA.Object obj = poa.id_to_reference(objectId);
+
+ bi.value = BindingIteratorHelper.narrow(obj);
+ } catch (SystemException e) {
+ // just propagate system exceptions
+ throw e;
+ } catch (Exception e) {
+ throw (INTERNAL)(new INTERNAL("Unable to activate BindingIterator").initCause(e));
+ }
+ }
+
+ // lower level functions that are used by the base class
+
+ /**
+ * Resolve an object in this context (single level
+ * resolution).
+ *
+ * @param n The name of the target object.
+ * @param type A type holder for returning the bound object type
+ * information.
+ *
+ * @return The bound object. Returns null if the object does not
+ * exist in the context.
+ * @exception SystemException
+ */
+ protected org.omg.CORBA.Object resolveObject(NameComponent n, BindingTypeHolder type) throws SystemException {
+ // special call to resolve the root context. This is the only one that goes backwards.
+ if (n.id.length() == 0 && n.kind.length() == 0) {
+ // this is a name context item, so set it properly.
+ type.value = BindingType.ncontext;
+ return rootContext;
+ }
+
+ BindingKey key = new BindingKey(n);
+ BoundObject obj = (BoundObject)bindings.get(key);
+ // if not in the table, just return null
+ if (obj == null) {
+ return null;
+ }
+ // update the type information and return the bound object reference.
+ type.value = obj.type;
+ return obj.boundObject;
+ }
+
+ /**
+ * Bind an object into the current context. This can
+ * be either an object or a naming context.
+ *
+ * @param n The single-level name of the target object.
+ * @param obj The object or context to be bound.
+ * @param type
+ *
+ * @exception SystemException
+ */
+ protected void bindObject(NameComponent n, org.omg.CORBA.Object obj, BindingTypeHolder type) throws SystemException {
+ // fairly simple table put...
+ bindings.put(new BindingKey(n), new BoundObject(n, obj, type.value));
+ }
+
+ /**
+ * Unbind an object from the current context.
+ *
+ * @param n The name of the target object (single level).
+ *
+ * @return The object associated with the binding. Returns null
+ * if there was no binding currently associated with this
+ * name.
+ * @exception SystemException
+ */
+ protected org.omg.CORBA.Object unbindObject(NameComponent n) throws SystemException {
+ //remove the object from the hash table, returning the bound object if it exists.
+ BindingKey key = new BindingKey(n);
+ BoundObject obj = (BoundObject)bindings.remove(key);
+
+ if (obj != null) {
+ return obj.boundObject;
+ }
+ return null;
+ }
+
+ /**
+ * Retrieve the rootContext for this NamingContext.
+ *
+ * @return The rootContext CORBA object associated with this context.
+ */
+ public org.omg.CORBA.Object getRootContext() {
+ return rootContext;
+ }
+
+ /**
+ * Internal class used for HashMap lookup keys.
+ */
+ class BindingKey {
+ // the name component this is a HashMap key for.
+ public NameComponent name;
+ private int hashval = 0;
+
+ /**
+ * Create a new BindingKey for a NameComponent.
+ *
+ * @param n The lookup name.
+ */
+ public BindingKey(NameComponent n) {
+ name = n;
+ // create a hash value used for lookups
+ if (name.id != null) {
+ hashval += name.id.hashCode();
+ }
+ if (name.kind != null) {
+ hashval += name.kind.hashCode();
+ }
+ }
+
+ /**
+ * Return the hashcode associated with this binding key. The
+ * hashcode is created using the NameComponent id and
+ * kind fields.
+ *
+ * @return The lookup hashvalue associated with this key.
+ */
+ public int hashCode() {
+ return hashval;
+ }
+
+ /**
+ * Compare two BindingKeys for equality (used for HashMap
+ * lookups).
+ *
+ * @param other The comparison partner.
+ *
+ * @return True if the keys are equivalent, false otherwise.
+ */
+ public boolean equals(Object other) {
+ // if not given or the wrong type, this is false.
+ if (other == null || !(other instanceof BindingKey)) {
+ return false;
+ }
+
+ BindingKey otherKey = (BindingKey)other;
+
+ // verify first on the id name.
+ if (name.id != null) {
+ if (otherKey.name.id == null) {
+ return false;
+ }
+ if (!name.id.equals(otherKey.name.id)) {
+ return false;
+ }
+ } else {
+ if (otherKey.name.id != null) {
+ return false;
+ }
+ }
+ // this is a match so far...now compare the kinds
+ if (name.kind != null) {
+ if (otherKey.name.kind == null) {
+ return false;
+ }
+ if (!name.kind.equals(otherKey.name.kind)) {
+ return false;
+ }
+ } else {
+ if (otherKey.name.kind != null) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Internal class used to store bound objects in the HashMap.
+ */
+ public class BoundObject {
+ // the name this object is bound under.
+ public NameComponent name;
+ // the type of binding (either nobject or ncontext).
+ public BindingType type;
+ // the actual bound object.
+ public org.omg.CORBA.Object boundObject;
+
+ /**
+ * Create a new object binding for our HashMap.
+ *
+ * @param name The bound object's name.
+ * @param boundObject
+ * The bound object (real object or NamingContext).
+ * @param type The type information associated with this binding.
+ */
+ public BoundObject(NameComponent name, org.omg.CORBA.Object boundObject, BindingType type) {
+ this.name = name;
+ this.boundObject = boundObject;
+ this.type = type;
+ }
+ }
+
+ /**
+ * Context implementation version of the BindingIterator
+ * object used to return list items.
+ */
+ public class TransientBindingIterator extends BindingIteratorPOA {
+ // the POA used to activate this object (required for destroy();
+ private POA poa;
+ // the binding set we're iterating over (this must be a snapshot copy)
+ private HashMap bindings;
+ // the iterator use to access the bindings
+ private Iterator iterator;
+
+ /**
+ * Create a new BindingIterator hosted by the given POA and
+ * iterating over the map of items.
+ *
+ * @param poa The hosting POA.
+ * @param bindings The HashMap of bound objects.
+ */
+ public TransientBindingIterator(POA poa, HashMap bindings) {
+ this.poa = poa;
+ this.bindings = bindings;
+ this.iterator = bindings.values().iterator();
+ }
+
+ /**
+ * Return the next object in the iteration sequence.
+ *
+ * @param b The BindingHolder used to return the next item. If
+ * we've reached the end of the sequence, an item
+ * with an empty name is returned.
+ *
+ * @return true if there is another item, false otherwise.
+ */
+ public boolean next_one(org.omg.CosNaming.BindingHolder b) {
+ if (iterator.hasNext()) {
+ // return this as a Binding value.
+ BoundObject obj = (BoundObject)iterator.next();
+ b.value = new Binding(new NameComponent[] {obj.name}, obj.type);
+ return true;
+ } else {
+ // return an empty element
+ b.value = new Binding(new NameComponent[0], BindingType.nobject);
+ return false;
+ }
+ }
+
+ /**
+ * Retrieve the next "n" items from the list, returned
+ * as a BindingList.
+ *
+ * @param how_many The count of items to retrieve.
+ * @param bl A holder for returning an array of Bindings for
+ * the returned items.
+ *
+ * @return true if any items were returned, false if there's
+ * nothing left to return.
+ */
+ public boolean next_n(int how_many, org.omg.CosNaming.BindingListHolder bl) {
+ List accum = new ArrayList();
+ BindingHolder holder = new BindingHolder();
+ int i = 0;
+ // Keep iterating as long as there are entries
+ while (i < how_many && next_one(holder)) {
+ accum.add(holder.value);
+ i++;
+ }
+
+ // convert to an array and return whether we found anything.
+ bl.value = (Binding[])accum.toArray(new Binding[accum.size()]);
+ return accum.isEmpty();
+ }
+
+ /**
+ * Destory this BindingIterator instance, which deativates
+ * it from the hosting POA.
+ */
+ public void destroy() {
+ try {
+ // we need to deactivate this from the POA.
+ byte[] objectId = poa.servant_to_id(this);
+ if (objectId != null) {
+ poa.deactivate_object(objectId);
+ }
+ } catch (Exception e) {
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java
new file mode 100644
index 0000000000..444143f173
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.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.
+ */
+
+/**
+ * @version $Rev$ $Date$
+ */
+package org.apache.tuscany.sca.host.corba.naming;
+
+public class TransientServiceException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2611596914331994827L;
+
+ public TransientServiceException() {
+ super();
+ }
+
+ public TransientServiceException(String reason) {
+ super(reason);
+ }
+
+ public TransientServiceException(String reason, Exception cause) {
+ super(reason, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost
new file mode 100644
index 0000000000..164988d4d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHost
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.host.corba.jse.DefaultCorbaHost
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java
new file mode 100644
index 0000000000..4a6a01bf97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.testing;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import java.net.ConnectException;
+import java.net.Socket;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.host.corba.CorbaHost;
+import org.apache.tuscany.sca.host.corba.CorbaHostException;
+import org.apache.tuscany.sca.host.corba.CorbaHostUtils;
+import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.host.corba.testing.general.TestInterface;
+import org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper;
+import org.apache.tuscany.sca.host.corba.testing.servants.TestInterfaceServant;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * General tests
+ */
+public class DefaultCorbaHostTestCase {
+
+ private static final String LOCALHOST = "localhost";
+ private static final int DEFAULT_PORT = 11100; // 1050;
+
+ private static CorbaHost host;
+
+ private static TransientNameServer server;
+
+ @BeforeClass
+ public static void start() {
+ try {
+ server = new TransientNameServer(LOCALHOST, DEFAULT_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ fail("The naming server cannot be started");
+ }
+ host = new DefaultCorbaHost();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void stop() {
+ server.stop();
+ }
+
+ /**
+ * Tests registering and lookup CORBA services
+ */
+ @Test
+ public void test_registerServant() {
+ try {
+ String uri = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT, "Nested/Test");
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(uri, servant);
+ TestInterface ref = TestInterfaceHelper.narrow(host.lookup(uri));
+ assertEquals(2, ref.getInt(2));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests unregistering servants
+ */
+ @Test
+ public void test_unregisterServant() {
+ try {
+ String objName = "Unregistering/Test";
+ String uri = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT, objName);
+ TestInterface servant = new TestInterfaceServant();
+
+ // creating and releasing using corbaname URI
+ host.registerServant(uri, servant);
+ host.unregisterServant(uri);
+ host.registerServant(uri, servant);
+ host.unregisterServant(uri);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests situation when name is already registered
+ */
+ @Test
+ public void test_nameAlreadyRegistered() {
+ // test using URI
+ try {
+ TestInterface servant = new TestInterfaceServant();
+ String uri = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT, "AlreadyRegisteredTest2");
+ host.registerServant(uri, servant);
+ host.registerServant(uri, servant);
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.BINDING_IN_USE));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests getting non existing reference
+ */
+ @Test
+ public void test_getNonExistingObject() {
+ // try to fetch object with corbaname URI
+ try {
+ host.lookup(CorbaHostUtils.createCorbanameURI("NonExistingOne", DEFAULT_PORT, LOCALHOST));
+ fail();
+ } catch (CorbaHostException e) {
+ // The message is JDK-specific
+ // assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT));
+ } catch (Exception e) {
+ // e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests unregistering non existing reference
+ */
+ @Test
+ public void test_unregisterNonExistentObject() {
+ // test using URI
+ try {
+ String uri = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT, "NonExistingReference1");
+ host.unregisterServant(uri);
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Tests registering under invalid host
+ */
+ @Test
+ public void test_invalidHost() {
+ try {
+ String url = CorbaHostUtils.createCorbanameURI("not_" + LOCALHOST, DEFAULT_PORT, "Name");
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(url, servant);
+ fail();
+ } catch (CorbaHostException e) {
+ // Expected
+ } catch (Exception e) {
+ // e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Tests registering under invalid port
+ */
+ @Test
+ public void test_invalidPort() {
+ try {
+ String url = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT + 1, "Name");
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant(url, servant);
+ fail();
+ } catch (CorbaHostException e) {
+ // Expected
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Tests registering under invalid name
+ */
+ @Test
+ @Ignore("SUN JDK 6 is happy with all kind of names")
+ public void test_invalidBindingName() {
+ try {
+ TestInterface servant = new TestInterfaceServant();
+ host.registerServant("---", servant);
+ fail();
+ } catch (CorbaHostException e) {
+ assertTrue(e.getMessage().equals(CorbaHostException.WRONG_NAME));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ *
+ */
+ @Ignore
+ @Test
+ public void test_ensureORBStopped() {
+ try {
+ int innerORBPort = 11102;
+ TransientNameServer innerServer =
+ new TransientNameServer(LOCALHOST, innerORBPort, TransientNameService.DEFAULT_SERVICE_NAME);
+ innerServer.start();
+ innerServer.stop();
+ try {
+ Thread.sleep(500);
+ } catch (Exception e) {
+ }
+ Socket socket = new Socket(LOCALHOST, innerORBPort);
+ Assert.assertFalse(socket.isConnected());
+ fail();
+ } catch (Exception e) {
+ if (e instanceof ConnectException) {
+ assertTrue(true);
+ } else {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java
new file mode 100644
index 0000000000..342d4e984e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public interface TestInterface extends TestInterfaceOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
+} // interface TestInterface
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java
new file mode 100644
index 0000000000..89fb0b6840
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+abstract public class TestInterfaceHelper {
+ private static String _id = "IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0";
+
+ public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.host.corba.testing.general.TestInterface that) {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface extract(org.omg.CORBA.Any a) {
+ return read(a.create_input_stream());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+
+ synchronized public static org.omg.CORBA.TypeCode type() {
+ if (__typeCode == null) {
+ __typeCode =
+ org.omg.CORBA.ORB.init()
+ .create_interface_tc(org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.id(),
+ "TestInterface");
+ }
+ return __typeCode;
+ }
+
+ public static String id() {
+ return _id;
+ }
+
+ public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface read(org.omg.CORBA.portable.InputStream istream) {
+ return narrow(istream.read_Object(_TestInterfaceStub.class));
+ }
+
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ org.apache.tuscany.sca.host.corba.testing.general.TestInterface value) {
+ ostream.write_Object((org.omg.CORBA.Object)value);
+ }
+
+ public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.host.corba.testing.general.TestInterface)
+ return (org.apache.tuscany.sca.host.corba.testing.general.TestInterface)obj;
+ else if (!obj._is_a(id()))
+ throw new org.omg.CORBA.BAD_PARAM();
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub stub =
+ new org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface unchecked_narrow(org.omg.CORBA.Object obj) {
+ if (obj == null)
+ return null;
+ else if (obj instanceof org.apache.tuscany.sca.host.corba.testing.general.TestInterface)
+ return (org.apache.tuscany.sca.host.corba.testing.general.TestInterface)obj;
+ else {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub stub =
+ new org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java
new file mode 100644
index 0000000000..dd7ac8f108
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public final class TestInterfaceHolder implements org.omg.CORBA.portable.Streamable {
+ public org.apache.tuscany.sca.host.corba.testing.general.TestInterface value = null;
+
+ public TestInterfaceHolder() {
+ }
+
+ public TestInterfaceHolder(org.apache.tuscany.sca.host.corba.testing.general.TestInterface initialValue) {
+ value = initialValue;
+ }
+
+ public void _read(org.omg.CORBA.portable.InputStream i) {
+ value = org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.read(i);
+ }
+
+ public void _write(org.omg.CORBA.portable.OutputStream o) {
+ org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.write(o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type() {
+ return org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.type();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java
new file mode 100644
index 0000000000..d30b2a2694
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public interface TestInterfaceOperations {
+ int getInt(int arg);
+} // interface TestInterfaceOperations
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java
new file mode 100644
index 0000000000..2122216e48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.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.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public abstract class _TestInterfaceImplBase extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.host.corba.testing.general.TestInterface, org.omg.CORBA.portable.InvokeHandler {
+
+ // Constructors
+ public _TestInterfaceImplBase() {
+ }
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable();
+ static {
+ _methods.put("getInt", new java.lang.Integer(0));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke(String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh) {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue()) {
+ case 0: // org/apache/tuscany/sca/host/corba/testing/general/TestInterface/getInt
+ {
+ int arg = in.read_long();
+ int $result = (int)0;
+ $result = this.getInt(arg);
+ out = $rh.createReply();
+ out.write_long($result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"};
+
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+} // class _TestInterfaceImplBase
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java
new file mode 100644
index 0000000000..47316edff9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.host.corba.testing.general;
+
+/**
+* org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from general_tests.idl
+*/
+
+public class _TestInterfaceStub extends org.omg.CORBA.portable.ObjectImpl implements
+ org.apache.tuscany.sca.host.corba.testing.general.TestInterface {
+
+ public int getInt(int arg) {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request("getInt", true);
+ $out.write_long(arg);
+ $in = _invoke($out);
+ int $result = $in.read_long();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream();
+ String _id = $ex.getId();
+ throw new org.omg.CORBA.MARSHAL(_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return getInt(arg);
+ } finally {
+ _releaseReply($in);
+ }
+ } // getInt
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {"IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"};
+
+ public String[] _ids() {
+ return (String[])__ids.clone();
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
+ String str = s.readUTF();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate();
+ _set_delegate(delegate);
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this);
+ s.writeUTF(str);
+ }
+} // class _TestInterfaceStub
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java
new file mode 100644
index 0000000000..0ebde8ef0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.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 org.apache.tuscany.sca.host.corba.testing.servants;
+
+import org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceImplBase;
+
+/**
+ * Testing servant
+ */
+public class TestInterfaceServant extends _TestInterfaceImplBase {
+
+ private static final long serialVersionUID = 1L;
+
+ public int getInt(int arg) {
+ return arg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/resources/general.idl b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/resources/general.idl
new file mode 100644
index 0000000000..f67566deb8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba-jse/src/test/resources/general.idl
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase genera.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module host {
+ module corba {
+ module testing {
+ module general {
+ interface TestInterface {
+ long getInt(in long arg);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/LICENSE b/sandbox/sebastien/java/embed/modules/host-corba/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/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/sebastien/java/embed/modules/host-corba/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/host-corba/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2b38d299c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.corba;uses:="org.omg.CORBA
+ ";version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA CORBA Host Extension Point
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397126578
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA CORBA Host Extension Point
+Import-Package: org.apache.tuscany.sca.host.corba;version="2.0.0",org.om
+ g.CORBA
+Bundle-SymbolicName: org.apache.tuscany.sca.host.corba
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/NOTICE b/sandbox/sebastien/java/embed/modules/host-corba/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/pom.xml b/sandbox/sebastien/java/embed/modules/host-corba/pom.xml
new file mode 100644
index 0000000000..b1e1281e17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/pom.xml
@@ -0,0 +1,38 @@
+<?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>2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>tuscany-host-corba</artifactId>
+ <name>Apache Tuscany SCA CORBA Host Extension Point</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java
new file mode 100644
index 0000000000..eb49f3f841
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.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 org.apache.tuscany.sca.host.corba;
+
+import org.omg.CORBA.Object;
+
+/**
+ * @version $Rev$ $Date$
+ * CORBA Service hosting interface
+ */
+public interface CorbaHost {
+
+ /**
+ * Registers servant in name server.
+ *
+ * @param uri corbaname URI
+ * @param serviceObject
+ * @throws CorbaHostException
+ */
+ void registerServant(String uri, Object serviceObject) throws CorbaHostException;
+
+ /**
+ * Removes servant from name server
+ *
+ * @param orb The ORB instance
+ * @param name binding name
+ * @throws CorbaHostException
+ */
+ void unregisterServant(String uri) throws CorbaHostException;
+
+ /**
+ * Gets reference to object
+ *
+ * @param name binding name
+ * @return objects reference
+ * @throws CorbaHostException
+ */
+ Object lookup(String uri) throws CorbaHostException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java
new file mode 100644
index 0000000000..049bfdb6cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.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.sca.host.corba;
+
+/**
+ * @version $Rev$ $Date$
+ * General exception for corba hosts operations
+ */
+public class CorbaHostException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String BINDING_IN_USE = "Binding name is already in use";
+ public static final String NO_SUCH_OBJECT = "There is no object under given location";
+ public static final String NO_SUCH_HOST = "Couldn't find specified host";
+ public static final String NO_SUCH_PORT = "Couldn't connect to specified port";
+ public static final String WRONG_NAME = "Characters used in binding name are illegal";
+
+ public CorbaHostException(String message) {
+ super(message);
+ }
+
+ public CorbaHostException(Exception cause) {
+ super(cause);
+ }
+
+ public CorbaHostException(String message, Exception cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java
new file mode 100644
index 0000000000..067b9193c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba;
+
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ * An extension point for CORBA hostst
+ */
+public interface CorbaHostExtensionPoint {
+
+ /**
+ * Removes CORBA host extension
+ *
+ * @param corbaHost
+ */
+ void addCorbaHost(CorbaHost corbaHost);
+
+ /**
+ * Removes CORBA host extension
+ *
+ * @param corbaHost
+ */
+ void removeCorbaHost(CorbaHost corbaHost);
+
+ /**
+ * Gets all CORBA host extensions
+ *
+ * @return
+ */
+ List<CorbaHost> getCorbaHosts();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.java b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.java
new file mode 100644
index 0000000000..b90fe9c78b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.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.sca.host.corba;
+
+
+/**
+ * @version $Rev$ $Date$
+ * Various utilities for host-corba
+ */
+public class CorbaHostUtils {
+
+ /**
+ * Tests if given URI is valid corbaname string
+ * @param uri
+ * @return
+ */
+ public static boolean isValidCorbanameURI(String uri) {
+ return uri != null && uri.startsWith("corbaname:") && uri.contains("#") && uri.indexOf('#') < uri.length() - 1;
+ }
+
+ /**
+ * Creates corbaname URI basing on given parameters
+ * @param host
+ * @param port
+ * @param name
+ *
+ * @return
+ */
+ public static String createCorbanameURI(String host, int port, String name) {
+ return new CorbanameURL(host, port, name).toString();
+ }
+
+ /**
+ * Translates corbaname URI to CorbanameDetails instances
+ *
+ * @param uri
+ * @return
+ */
+ public static CorbanameURL getServiceDetails(String uri) {
+ CorbanameURL details = new CorbanameURL(uri);
+ return details;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java
new file mode 100644
index 0000000000..a380fd6d79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ * Holds corbaname URI details
+ */
+public class CorbanameURL {
+ public static String DEFAULT_PROTOCOL = "iiop";
+ public static String DEFAULT_VERSION = "";
+ public static String DEFAULT_NAME_SERVICE = "NameService";
+ public static String DEFAULT_HOST = "localhost";
+ public static int DEFAULT_PORT = 2809;
+
+ private String protocol = "";
+ private String version = "";
+ private String host;
+ private int port;
+ private String nameService;
+ private List<String> namePath;
+
+ public CorbanameURL(String host, int port, String namePath, String nameService) {
+ super();
+ this.host = host == null ? DEFAULT_HOST : host;
+ this.port = port <= 0 ? DEFAULT_PORT : port;
+ this.namePath = parseName(namePath);
+ this.nameService = nameService == null ? DEFAULT_NAME_SERVICE : nameService;
+ }
+
+ public CorbanameURL(String host, int port, String namePath) {
+ this(host, port, namePath, DEFAULT_NAME_SERVICE);
+ }
+
+ public CorbanameURL(String url) {
+ if (url == null || (!url.startsWith("corbaname"))) {
+ throw new IllegalArgumentException("Malformed corbaname URL: " + url);
+ }
+ try {
+ url = URLDecoder.decode(url, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException(e);
+ }
+ String[] parts = url.split("#");
+ if (parts.length == 2) {
+ String serviceLocation = parts[0];
+ String servicePath = parts[1];
+ namePath = parseName(servicePath);
+
+ parts = serviceLocation.split("/");
+ if (parts.length == 2) {
+ nameService = parts[1];
+ } else {
+ nameService = DEFAULT_NAME_SERVICE;
+ }
+
+ parts = parts[0].split(":");
+
+ if (parts.length >= 2) {
+ protocol = parts[1];
+ }
+ if (parts.length >= 3) {
+ version = parts[2];
+ String[] strs = version.split("@");
+ if (strs.length == 2) {
+ version = strs[0];
+ host = strs[1];
+ } else {
+ version = "";
+ host = strs[0];
+ }
+ }
+ if (host == null || "".equals(host)) {
+ host = DEFAULT_HOST;
+ }
+ if (parts.length >= 4 && !"".equals(parts[3])) {
+ port = Integer.parseInt(parts[3]);
+ } else {
+ port = DEFAULT_PORT;
+ }
+ } else {
+ throw new IllegalArgumentException("Malformed corbaname URL: " + url);
+ }
+ }
+
+ private static List<String> parseName(String name) {
+ try {
+ name = URLDecoder.decode(name, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException(e);
+ }
+ String[] names = name.split("/");
+ return Arrays.asList(names);
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getNameService() {
+ return nameService;
+ }
+
+ public void setNameService(String nameService) {
+ this.nameService = nameService;
+ }
+
+ public List<String> getNamePath() {
+ return namePath;
+ }
+
+ public String getName() {
+ if (namePath != null) {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < namePath.size(); i++) {
+ buf.append(namePath.get(i));
+ if (i < namePath.size() - 1) {
+ buf.append("/");
+ }
+ }
+ return buf.toString();
+ }
+ return null;
+ }
+
+ public void setNamePath(List<String> namePath) {
+ this.namePath = namePath;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("corbaname:");
+ buf.append(protocol).append(":");
+ if (version != null && !"".equals(version)) {
+ buf.append(version).append("@");
+ }
+ buf.append(host).append(":").append(port);
+ buf.append("/").append(nameService);
+ buf.append("#");
+ if (namePath != null) {
+ for (int i = 0; i < namePath.size(); i++) {
+ buf.append(namePath.get(i));
+ if (i < namePath.size() - 1) {
+ buf.append("/");
+ }
+ }
+ }
+ return buf.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java
new file mode 100644
index 0000000000..6ed7f3ea83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.corba;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceHelper;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ * Default implementation of CorbaHostExtensionPoint
+ */
+public class DefaultCorbaHostExtensionPoint implements CorbaHostExtensionPoint, LifeCycleListener {
+ private ExtensionPointRegistry registry;
+ private boolean loaded;
+ private List<CorbaHost> corbaHosts = new ArrayList<CorbaHost>();
+
+ public DefaultCorbaHostExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ private synchronized void loadHosts() {
+ if (loaded) {
+ return;
+ }
+ try {
+ ServiceDeclaration sd = registry.getServiceDiscovery().getServiceDeclaration(CorbaHost.class);
+ CorbaHost host = ServiceHelper.newInstance(registry, sd);
+ ServiceHelper.start(host);
+ corbaHosts.add(host);
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public void addCorbaHost(CorbaHost host) {
+ corbaHosts.add(host);
+ }
+
+ public void removeCorbaHost(CorbaHost host) {
+ corbaHosts.remove(host);
+ }
+
+ public List<CorbaHost> getCorbaHosts() {
+ loadHosts();
+ return corbaHosts;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ ServiceHelper.stop(corbaHosts);
+ corbaHosts.clear();
+ loaded = false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java
new file mode 100644
index 0000000000..644682e106
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.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.host.corba;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.omg.CORBA.Object;
+
+/**
+ * @version $Rev$ $Date$
+ * Default implementation of extensible CORBA host
+ */
+public class ExtensibleCorbaHost implements CorbaHost {
+
+ private CorbaHostExtensionPoint hosts;
+
+ public ExtensibleCorbaHost(ExtensionPointRegistry registry) {
+ this.hosts = registry.getExtensionPoint(CorbaHostExtensionPoint.class);
+ }
+
+ public static ExtensibleCorbaHost getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilityExtensionPoint.getUtility(ExtensibleCorbaHost.class);
+ }
+
+ public Object lookup(String uri) throws CorbaHostException {
+ return getCorbaHost().lookup(uri);
+ }
+
+ public void registerServant(String uri, Object serviceObject) throws CorbaHostException {
+ getCorbaHost().registerServant(uri, serviceObject);
+ }
+
+ public void unregisterServant(String uri) throws CorbaHostException {
+ getCorbaHost().unregisterServant(uri);
+ }
+
+ protected CorbaHost getCorbaHost() throws CorbaHostException {
+ if (hosts.getCorbaHosts().isEmpty()) {
+ throw new CorbaHostException("No registered CORBA hosts");
+ }
+ return hosts.getCorbaHosts().get(0);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java
new file mode 100755
index 0000000000..6989b3ad06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.host.corba;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @version $Rev$ $Date$
+ * Class partially copied from eclipse wst project
+ * (http://repo1.maven.org/maven2/org/eclipse/wst/server/core/1.0.205-v20070829b/).
+ * Finally we should use jar from maven dependency. Problem described in
+ * http://www.fornax-platform.org/cp/display/fornax/2.+Hello+World+Tutorial+(CSC)?replyToComment=2098#comment-2098
+ * needs to be fixed.
+ */
+public class SocketUtil {
+
+ protected static final Object lock = new Object();
+
+ private static Set<String> localHostCache;
+ private static Set<String> notLocalHostCache = new HashSet<String>();
+ private static Map<String, CacheThread> threadMap = new HashMap<String, CacheThread>();
+
+ private static Set<InetAddress> addressCache;
+
+ static class CacheThread extends Thread {
+ private Set<InetAddress> currentAddresses;
+ private Set<String> addressList;
+ private String host;
+ private Set<String> nonAddressList;
+ private Map<String, CacheThread> threadMap2;
+
+ public CacheThread(String host,
+ Set<InetAddress> currentAddresses,
+ Set<String> addressList,
+ Set<String> nonAddressList,
+ Map<String, CacheThread> threadMap2) {
+ super("Caching localhost information");
+ this.host = host;
+ this.currentAddresses = currentAddresses;
+ this.addressList = addressList;
+ this.nonAddressList = nonAddressList;
+ this.threadMap2 = threadMap2;
+ }
+
+ public void run() {
+ if (currentAddresses != null) {
+ Iterator<InetAddress> iter2 = currentAddresses.iterator();
+ while (iter2.hasNext()) {
+ InetAddress addr = iter2.next();
+ String hostname = addr.getHostName();
+ String hostname2 = addr.getCanonicalHostName();
+ synchronized (lock) {
+ if (hostname != null && !addressList.contains(hostname))
+ addressList.add(hostname);
+ if (hostname2 != null && !addressList.contains(hostname2))
+ addressList.add(hostname2);
+ }
+ }
+ }
+
+ try {
+ InetAddress[] addrs = InetAddress.getAllByName(host);
+ int length = addrs.length;
+ for (int j = 0; j < length; j++) {
+ InetAddress addr = addrs[0];
+ String hostname = addr.getHostName();
+ String hostname2 = addr.getCanonicalHostName();
+ synchronized (lock) {
+ if (addr.isLoopbackAddress()) {
+ if (hostname != null && !addressList.contains(hostname))
+ addressList.add(hostname);
+ if (hostname2 != null && !addressList.contains(hostname2))
+ addressList.add(hostname2);
+ } else {
+ if (hostname != null && !nonAddressList.contains(hostname))
+ nonAddressList.add(hostname);
+ if (hostname2 != null && !nonAddressList.contains(hostname2))
+ nonAddressList.add(hostname2);
+ }
+ }
+ }
+ } catch (UnknownHostException e) {
+ synchronized (lock) {
+ if (host != null && !nonAddressList.contains(host))
+ nonAddressList.add(host);
+ }
+ }
+ synchronized (lock) {
+ threadMap2.remove(host);
+ }
+ }
+ }
+
+ public static boolean isLocalhost(final String host) {
+ if (host == null || host.equals(""))
+ return false;
+
+ if ("localhost".equals(host) || "127.0.0.1".equals(host))
+ return true;
+
+ // check simple cases
+ try {
+ InetAddress localHostaddr = InetAddress.getLocalHost();
+ if (localHostaddr.getHostName().equals(host) || host.equals(localHostaddr.getCanonicalHostName())
+ || localHostaddr.getHostAddress().equals(host))
+ return true;
+ } catch (Exception e) {
+
+ }
+
+ // check for current thread and wait if necessary
+ boolean currentThread = false;
+ try {
+ Thread t = null;
+ synchronized (lock) {
+ t = threadMap.get(host);
+ }
+ if (t != null && t.isAlive()) {
+ currentThread = true;
+ t.join(30);
+ }
+ } catch (Exception e) {
+
+ }
+
+ // check if cache is still ok
+ boolean refreshedCache = false;
+ try {
+ // get network interfaces
+ final Set<InetAddress> currentAddresses = new HashSet<InetAddress>();
+ currentAddresses.add(InetAddress.getLocalHost());
+ Enumeration<?> nis = NetworkInterface.getNetworkInterfaces();
+ while (nis.hasMoreElements()) {
+ NetworkInterface inter = (NetworkInterface)nis.nextElement();
+ Enumeration<InetAddress> ias = inter.getInetAddresses();
+ while (ias.hasMoreElements())
+ currentAddresses.add(ias.nextElement());
+ }
+
+ // check if cache is empty or old and refill it if necessary
+ if (addressCache == null || !addressCache.containsAll(currentAddresses)
+ || !currentAddresses.containsAll(addressCache)) {
+ CacheThread cacheThread = null;
+ refreshedCache = true;
+
+ synchronized (lock) {
+ addressCache = currentAddresses;
+ notLocalHostCache = new HashSet<String>();
+ localHostCache = new HashSet<String>(currentAddresses.size() * 3);
+
+ Iterator<InetAddress> iter = currentAddresses.iterator();
+ while (iter.hasNext()) {
+ InetAddress addr = iter.next();
+ String a = addr.getHostAddress();
+ if (a != null && !localHostCache.contains(a))
+ localHostCache.add(a);
+ }
+
+ cacheThread = new CacheThread(host, currentAddresses, localHostCache, notLocalHostCache, threadMap);
+ threadMap.put(host, cacheThread);
+ cacheThread.setDaemon(true);
+ cacheThread.setPriority(Thread.NORM_PRIORITY - 1);
+ cacheThread.start();
+ }
+ cacheThread.join(200);
+ }
+ } catch (Exception e) {
+ }
+
+ synchronized (lock) {
+ if (localHostCache.contains(host))
+ return true;
+ if (notLocalHostCache.contains(host))
+ return false;
+ }
+
+ // if the cache hasn't been cleared, maybe we still need to lookup the
+ // host
+ if (!refreshedCache && !currentThread) {
+ try {
+ CacheThread cacheThread = null;
+ synchronized (lock) {
+ cacheThread = new CacheThread(host, null, localHostCache, notLocalHostCache, threadMap);
+ threadMap.put(host, cacheThread);
+ cacheThread.setDaemon(true);
+ cacheThread.setPriority(Thread.NORM_PRIORITY - 1);
+ cacheThread.start();
+ }
+ cacheThread.join(75);
+
+ synchronized (lock) {
+ if (localHostCache.contains(host))
+ return true;
+ }
+ } catch (Exception e) {
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint b/sandbox/sebastien/java/embed/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint
new file mode 100644
index 0000000000..a72bed4ea8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint
@@ -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.host.corba.DefaultCorbaHostExtensionPoint
diff --git a/sandbox/sebastien/java/embed/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java b/sandbox/sebastien/java/embed/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java
new file mode 100644
index 0000000000..4e076f9342
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.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.sca.host.corba;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ * Tests for host utils
+ */
+public class UtilsTestCase {
+
+ private void assertDetailsAreOk(CorbanameURL details, String host, int port, String nameService, List<String> namePath) {
+ assertTrue(details.getHost().equals(host));
+ assertTrue(details.getNameService().equals(nameService));
+ assertTrue(details.getPort() == port);
+ assertTrue(details.getNamePath().size() == namePath.size());
+ for (int i = 0; i < namePath.size(); i++) {
+ assertTrue(details.getNamePath().get(i).equals(namePath.get(i)));
+ }
+ }
+
+ /**
+ * Tests if corbaname url is beeing processes properly
+ */
+ @Test
+ public void test_validCorbaname() {
+ String testUri = null;
+ CorbanameURL details = null;
+ List<String> namePath = null;
+
+ testUri = "corbaname:ignore:host:1234/Service#Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Reference");
+ assertDetailsAreOk(details, "host", 1234, "Service", namePath);
+
+ testUri = "corbaname:ignore:host:/Service#Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Reference");
+ assertDetailsAreOk(details, "host", CorbanameURL.DEFAULT_PORT, "Service", namePath);
+
+ testUri = "corbaname:ignore:host/Service#Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Reference");
+ assertDetailsAreOk(details, "host", CorbanameURL.DEFAULT_PORT, "Service", namePath);
+
+ testUri = "corbaname:ignore:/Service#Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Reference");
+ assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, "Service", namePath);
+
+ testUri = "corbaname:ignore/Service#Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Reference");
+ assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, "Service", namePath);
+
+ testUri = "corbaname:/Service#Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Reference");
+ assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, "Service", namePath);
+
+ testUri = "corbaname/Service#Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Reference");
+ assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, "Service", namePath);
+
+ testUri = "corbaname#Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Reference");
+ assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, CorbanameURL.DEFAULT_NAME_SERVICE, namePath);
+
+ testUri = "corbaname#Parent/Mid/Reference";
+ details = CorbaHostUtils.getServiceDetails(testUri);
+ namePath = new ArrayList<String>();
+ namePath.add("Parent");
+ namePath.add("Mid");
+ namePath.add("Reference");
+ assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, CorbanameURL.DEFAULT_NAME_SERVICE, namePath);
+ }
+
+ /**
+ * Test for invalid corbaname url
+ */
+ @Test
+ public void test_invalidCorbaname() {
+ String testUri = null;
+
+ try {
+ testUri = "this.string.should.not.appear.in.the.beggining:ignore:host:1234/Service#Reference";
+ CorbaHostUtils.getServiceDetails(testUri);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof IllegalArgumentException);
+ }
+
+ try {
+ testUri = "corbaname:ignore:host:1234/Service#";
+ CorbaHostUtils.getServiceDetails(testUri);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof IllegalArgumentException);
+ }
+ }
+
+ /**
+ * Test for creating corbaname url from host, port, name parameters
+ */
+ @Test
+ public void test_creatingCorbanameURI() {
+ String uri = CorbaHostUtils.createCorbanameURI("SomeHost", 1000, "SomeName");
+ assertEquals("corbaname::SomeHost:1000/NameService#SomeName", uri);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/LICENSE b/sandbox/sebastien/java/embed/modules/host-http/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/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/sebastien/java/embed/modules/host-http/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/host-http/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..33d1e52caf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.http;uses:="javax.servlet,
+ javax.servlet.http";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA HTTP Servlet Host Extension Point
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA HTTP Servlet Host Extension Poi
+ nt
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.host.http
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/host-http/NOTICE b/sandbox/sebastien/java/embed/modules/host-http/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/host-http/pom.xml b/sandbox/sebastien/java/embed/modules/host-http/pom.xml
new file mode 100644
index 0000000000..cc725d24d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/pom.xml
@@ -0,0 +1,46 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-host-http</artifactId>
+ <name>Apache Tuscany SCA HTTP Servlet Host Extension Point</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultResourceServlet.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultResourceServlet.java
new file mode 100644
index 0000000000..3de0b9f5a7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultResourceServlet.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.http;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLDecoder;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * A minimal implementation of a Servlet that serves documents in a document root
+ * directory.
+ *
+ * A Servlet host implementation is not required to use this implementation and can map
+ * the URI and document root to a more complete and more efficient implementation of
+ * a resource Servlet, for example the Tomcat or Jetty default Servlets.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultResourceServlet extends HttpServlet implements Servlet {
+ private static final long serialVersionUID = 2865466417329430610L;
+
+ private String documentRoot;
+
+ /**
+ * Constructs a new ResourceServlet
+ * @param documentRoot the document root
+ */
+ public DefaultResourceServlet(String documentRoot) {
+ this.documentRoot = documentRoot;
+ }
+
+ /**
+ * Returns the document root.
+ * @return the document root
+ */
+ public String getDocumentRoot() {
+ return documentRoot;
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // Determine the resource path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+ URL url = new URL(documentRoot + '/' + path);
+
+ // Write the resource
+ InputStream is = url.openStream();
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
new file mode 100644
index 0000000000..8ecb81f843
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.http;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceHelper;
+
+/**
+ * Default implementation of a Servlet host extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoint, LifeCycleListener {
+
+ private List<ServletHost> servletHosts = new ArrayList<ServletHost>();
+ private boolean loaded;
+ private boolean webApp;
+
+ private ExtensionPointRegistry registry;
+
+ public DefaultServletHostExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public void addServletHost(ServletHost servletHost) {
+ servletHosts.add(servletHost);
+ if (servletHost instanceof LifeCycleListener) {
+ ((LifeCycleListener)servletHost).start();
+ }
+ }
+
+ public void removeServletHost(ServletHost servletHost) {
+ servletHosts.remove(servletHost);
+ if (servletHost instanceof LifeCycleListener) {
+ ((LifeCycleListener)servletHost).stop();
+ }
+ }
+
+ public List<ServletHost> getServletHosts() {
+ loadServletHosts();
+ return servletHosts;
+ }
+
+ private synchronized void loadServletHosts() {
+ if (loaded)
+ return;
+
+ // Get the databinding service declarations
+ Collection<ServiceDeclaration> sds;
+ try {
+ sds = registry.getServiceDiscovery().getServiceDeclarations(ServletHost.class, true);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Load data bindings
+ for (ServiceDeclaration sd : sds) {
+ // Create a data binding wrapper and register it
+ ServletHost servletHost = new LazyServletHost(sd);
+ addServletHost(servletHost);
+ }
+
+ loaded = true;
+ }
+
+ /**
+ * A data binding facade allowing data bindings to be lazily loaded and
+ * initialized.
+ */
+ public class LazyServletHost implements ServletHost, LifeCycleListener {
+ private ServiceDeclaration sd;
+ private ServletHost host;
+
+ /**
+ * @param sd
+ */
+ public LazyServletHost(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ }
+
+ public synchronized ServletHost getServletHost() {
+ if (host == null) {
+ try {
+ host = ServiceHelper.newInstance(registry, sd);
+ ServiceHelper.start(host);
+ } catch (Throwable e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return host;
+ }
+
+ public String addServletMapping(String uri, Servlet servlet) throws ServletMappingException {
+ return getServletHost().addServletMapping(uri, servlet);
+ }
+
+ public String addServletMapping(String uri, Servlet servlet, SecurityContext securityContext) throws ServletMappingException {
+ return getServletHost().addServletMapping(uri, servlet, securityContext);
+ }
+
+ public String getContextPath() {
+ return getServletHost().getContextPath();
+ }
+
+ public int getDefaultPort() {
+ return getServletHost().getDefaultPort();
+ }
+
+ public RequestDispatcher getRequestDispatcher(String uri) throws ServletMappingException {
+ return getServletHost().getRequestDispatcher(uri);
+ }
+
+ public Servlet getServletMapping(String uri) throws ServletMappingException {
+ return getServletHost().getServletMapping(uri);
+ }
+
+ public URL getURLMapping(String uri, SecurityContext securityContext) {
+ return getServletHost().getURLMapping(uri, securityContext);
+ }
+
+ public Servlet removeServletMapping(String uri) throws ServletMappingException {
+ return getServletHost().removeServletMapping(uri);
+ }
+
+ public void setAttribute(String name, Object value) {
+ getServletHost().setAttribute(name, value);
+ }
+
+ public void setContextPath(String path) {
+ getServletHost().setContextPath(path);
+ }
+
+ public void setDefaultPort(int port) {
+ getServletHost().setDefaultPort(port);
+ }
+
+ public String getName() {
+ return sd.getAttributes().get("name");
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ ServiceHelper.stop(host);
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ return getServletHost().getServletContext();
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ ServiceHelper.stop(servletHosts);
+ servletHosts.clear();
+ registry = null;
+ }
+
+ public boolean isWebApp() {
+ return webApp;
+ }
+
+ public void setWebApp(boolean webApp) {
+ this.webApp = webApp;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
new file mode 100644
index 0000000000..107b6b3d5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.http;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+
+/**
+ * Default implementation of an extensible Servlet host.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleServletHost implements ServletHost {
+
+ private ServletHostExtensionPoint servletHosts;
+
+ public ExtensibleServletHost(ExtensionPointRegistry registry) {
+ this.servletHosts = registry.getExtensionPoint(ServletHostExtensionPoint.class);
+ }
+
+ public static ExtensibleServletHost getInstance(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ return utilityExtensionPoint.getUtility(ExtensibleServletHost.class);
+ }
+
+ public ExtensibleServletHost(ServletHostExtensionPoint servletHosts) {
+ this.servletHosts = servletHosts;
+ }
+
+ public void setDefaultPort(int port) {
+ for (ServletHost servletHost: servletHosts.getServletHosts()) {
+ servletHost.setDefaultPort(port);
+ }
+ }
+
+ public ServletHost getDefaultServletHost() {
+ List<ServletHost> hosts = servletHosts.getServletHosts();
+ if (hosts.isEmpty()) {
+ throw new ServletMappingException("No servlet host is available.");
+ }
+ if (servletHosts.isWebApp()) {
+ for (ServletHost servletHost : hosts) {
+ if (!"webapp".equals(servletHost.getName())) {
+ continue;
+ }
+ if (servletHost instanceof DefaultServletHostExtensionPoint.LazyServletHost) {
+ return ((DefaultServletHostExtensionPoint.LazyServletHost)servletHost).getServletHost();
+ } else {
+ return servletHost;
+ }
+ }
+ }
+ return hosts.get(0);
+ }
+
+ public int getDefaultPort() {
+ return getDefaultServletHost().getDefaultPort();
+ }
+
+ public String addServletMapping(String uri, Servlet servlet) throws ServletMappingException {
+ // TODO implement selection of the correct Servlet host based on the mapping
+ // For now just select the first one
+ return getDefaultServletHost().addServletMapping(uri, servlet);
+ }
+
+ public String addServletMapping(String uri, Servlet servlet, SecurityContext securityContext) throws ServletMappingException {
+ // TODO implement selection of the correct Servlet host based on the mapping
+ // For now just select the first one
+ return getDefaultServletHost().addServletMapping(uri, servlet, securityContext);
+ }
+
+ public Servlet getServletMapping(String uri) throws ServletMappingException {
+ // TODO implement selection of the correct Servlet host based on the mapping
+ // For now just select the first one
+ return getDefaultServletHost().getServletMapping(uri);
+ }
+
+ public Servlet removeServletMapping(String uri) throws ServletMappingException {
+ // TODO implement selection of the correct Servlet host based on the mapping
+ // For now just select the first one
+ return getDefaultServletHost().removeServletMapping(uri);
+ }
+
+ public RequestDispatcher getRequestDispatcher(String uri) throws ServletMappingException {
+ // TODO implement selection of the correct Servlet host based on the mapping
+ // For now just select the first one
+ return getDefaultServletHost().getRequestDispatcher(uri);
+ }
+
+ public String getContextPath() {
+ // TODO implement selection of the correct Servlet host based on the mapping
+ // For now just select the first one
+ return getDefaultServletHost().getContextPath();
+ }
+
+ public URL getURLMapping(String uri, SecurityContext securityContext) {
+ return getDefaultServletHost().getURLMapping(uri, securityContext);
+ }
+
+ public void setContextPath(String path) {
+ getDefaultServletHost().setContextPath(path);
+ }
+
+ public void setAttribute(String name, Object value) {
+ getDefaultServletHost().setAttribute(name, value);
+ }
+
+ public String getName() {
+ return getDefaultServletHost().getName();
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ return getDefaultServletHost().getServletContext();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
new file mode 100644
index 0000000000..f290bb3e59
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.http;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * A class to store policy context to enable Security QoS to
+ * HTTP binding
+ */
+public class SecurityContext {
+ private boolean isSSLEnabled = false;
+ private Properties sslProperties;
+
+ private boolean isAuthenticationEnabled = false;
+ private List<UserContext> users = new ArrayList<UserContext>();
+
+ public boolean isSSLEnabled() {
+ return isSSLEnabled;
+ }
+
+ public void setSSLEnabled(boolean value) {
+ this.isSSLEnabled = value;
+ }
+
+ public Properties getSSLProperties() {
+ return sslProperties;
+ }
+
+ public void setSSLProperties(Properties sslProperties) {
+ this.sslProperties = sslProperties;
+ }
+
+ public boolean isAuthenticationEnabled() {
+ return this.isAuthenticationEnabled;
+ }
+
+ public void setAuthenticationEnabled(boolean value) {
+ this.isAuthenticationEnabled = value;
+ }
+
+ public List<UserContext> getUsers() {
+ return this.users;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
new file mode 100644
index 0000000000..f70a6eddcc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.http;
+
+import java.net.URL;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+
+/**
+ * Interface implemented by host environments that allow Servlets to be
+ * registered.
+ * <p/>
+ * This interface allows a system service to register a Servlet
+ * to handle inbound requests.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ServletHost {
+
+ ServletContext getServletContext();
+
+ /**
+ * Sets the default port for the server.
+ *
+ * @param port the default port
+ */
+ void setDefaultPort(int port);
+
+ /**
+ * Returns the default port for the server.
+ *
+ * @return the default port
+ */
+ int getDefaultPort();
+
+ /**
+ * Add a mapping for an instance of a Servlet. This requests that the
+ * Servlet container direct all requests to the designated mapping to the
+ * supplied Servlet instance.
+ *
+ * @param uri the URI-mapping for the Servlet
+ * @param servlet the Servlet that should be invoked
+ * @return The deployed URI
+ * @throws ServletMappingException
+ */
+ String addServletMapping(String uri, Servlet servlet) throws ServletMappingException;
+
+ /**
+ * Add a mapping for an instance of a Servlet. This requests that the
+ * Servlet container direct all requests to the designated mapping to the
+ * supplied Servlet instance. SecurityContext can be passed to enable
+ * QoS services such as Confidentiality (SSL) and Authentication/Authorization
+ *
+ * @param uri the URI-mapping for the Servlet
+ * @param servlet the Servlet that should be invoked
+ * @param securityContext the SecurityContext to enable QoS services
+ * @return The deployed URI
+ * @throws ServletMappingException
+ */
+ String addServletMapping(String uri, Servlet servlet, SecurityContext securityContext) throws ServletMappingException;
+
+ /**
+ * Remove a Servlet mapping. This directs the Servlet container not to direct
+ * any more requests to a previously registered Servlet.
+ *
+ * @param uri the URI-mapping for the Servlet
+ * @return the Servlet that was registered to the mapping, null if nothing
+ * was registered to the mapping
+ * @throws ServletMappingException
+ */
+ Servlet removeServletMapping(String uri) throws ServletMappingException;
+
+ /**
+ * Returns the Servlet mapped to the given URI.
+ *
+ * @param uri the URI-mapping for the Servlet
+ * @return the Servlet registered with the mapping
+ * @throws ServletMappingException
+ */
+ Servlet getServletMapping(String uri) throws ServletMappingException;
+
+ /**
+ * Returns a Servlet request dispatcher for the Servlet mapped to the specified URI.
+ *
+ * @param uri the URI mapped to a Servlet
+ * @return a RequestDispatcher that can be used to dispatch requests to
+ * that Servlet
+ * @throws ServletMappingException
+ */
+ RequestDispatcher getRequestDispatcher(String uri) throws ServletMappingException;
+
+ /**
+ * Returns the portion of the request URI that indicates the context of the request
+ *
+ * @return a String specifying the portion of the request URI that indicates the context of the request
+ */
+ String getContextPath();
+
+ /**
+ * Sets the portion of the request URI that indicates the context of the request
+ *
+ * @param path the context path
+ */
+ void setContextPath(String path);
+
+ /**
+ * Returns the complete URL mapped to the specified URI.
+ * @return the URL mapped to the specified URI
+ */
+ URL getURLMapping(String uri, SecurityContext securityContext);
+
+ /**
+ * Set an attribute in the application ServletContext
+ * @param name the name of the attribute
+ * @param value the attribute value
+ */
+ void setAttribute(String name, Object value);
+
+ /**
+ * Returns the name that identify the server type (e.g jetty)
+ * @return
+ */
+ String getName();
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.java
new file mode 100644
index 0000000000..8ef48e4949
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.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.host.http;
+
+import java.util.List;
+
+/**
+ * An extension point for Servlet hosts.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ServletHostExtensionPoint {
+ /**
+ * Test if it's inside a web application
+ * @return
+ */
+ boolean isWebApp();
+
+ /**
+ * Set the flag to indicate it's inside a web application
+ * @param webApp
+ */
+ void setWebApp(boolean webApp);
+
+ /**
+ * Adds a Servlet host extension.
+ *
+ * @param servletHost
+ */
+ void addServletHost(ServletHost servletHost);
+
+ /**
+ * Removes a Servlet host extension.
+ *
+ * @param servletHost
+ */
+ void removeServletHost(ServletHost servletHost);
+
+ /**
+ * Returns a list of Servlet host extensions.
+ *
+ * @return
+ */
+ List<ServletHost> getServletHosts();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.java
new file mode 100644
index 0000000000..10c6d8706c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostHelper.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 org.apache.tuscany.sca.host.http;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+
+public class ServletHostHelper {
+
+ public static ServletHost getServletHost(ExtensionPointRegistry extensionPoints) {
+ ExtensibleServletHost host = ExtensibleServletHost.getInstance(extensionPoints);
+ return host.getDefaultServletHost();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletMappingException.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletMappingException.java
new file mode 100644
index 0000000000..ae66c44c3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletMappingException.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.host.http;
+
+/**
+ * Indicates an exception while registering a Servlet mapping.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServletMappingException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ public ServletMappingException() {
+ super();
+ }
+
+ public ServletMappingException(String message) {
+ super(message);
+ }
+
+ public ServletMappingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ServletMappingException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
new file mode 100644
index 0000000000..4a19eda81d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.http;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Model class used to define list of users and it's roles
+ *
+ * These info is used to configure authentication/authorization
+ * in embedded http servers
+ *
+ * @version $Rev$ $Date$
+ */
+public class UserContext {
+ private String username;
+ private String password;
+ private List<String> roles = new ArrayList<String>();
+
+
+ public UserContext() {
+
+ }
+
+ public UserContext(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public List<String> getRoles() {
+ return this.roles;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint b/sandbox/sebastien/java/embed/modules/host-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint
new file mode 100644
index 0000000000..d2d165d6f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.host.http.DefaultServletHostExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/LICENSE b/sandbox/sebastien/java/embed/modules/host-jetty/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/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/sebastien/java/embed/modules/host-jetty/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/host-jetty/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..56499b5592
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.http.jetty;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Jetty Servlet Host Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Jetty Servlet Host Extension
+Import-Package: javax.net.ssl;resolution:=optional,
+ javax.servlet,
+ javax.servlet.http;resolution:=optional,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0",
+ org.mortbay.component;version="6.1.19",
+ org.mortbay.jetty;version="6.1.19",
+ org.mortbay.jetty.handler;version="6.1.19",
+ org.mortbay.jetty.nio;version="6.1.19",
+ org.mortbay.jetty.security;version="6.1.19",
+ org.mortbay.jetty.servlet;version="6.1.19",
+ org.mortbay.log;version="6.1.19",
+ org.mortbay.resource;version="6.1.19",
+ org.mortbay.thread;version="6.1.19"
+Bundle-SymbolicName: org.apache.tuscany.sca.host.jetty
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/NOTICE b/sandbox/sebastien/java/embed/modules/host-jetty/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/pom.xml b/sandbox/sebastien/java/embed/modules/host-jetty/pom.xml
new file mode 100644
index 0000000000..b4a3a4a9d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/pom.xml
@@ -0,0 +1,69 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <name>Apache Tuscany SCA Jetty Servlet Host Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.19</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>6.1.19</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyDefaultServlet.java b/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyDefaultServlet.java
new file mode 100644
index 0000000000..4f5bfb3c62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyDefaultServlet.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.http.jetty;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.mortbay.jetty.servlet.DefaultServlet;
+import org.mortbay.resource.Resource;
+import org.mortbay.resource.URLResource;
+
+/**
+ * Customizes the Jetty default Servlet.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JettyDefaultServlet extends DefaultServlet {
+ private static final long serialVersionUID = 7000218247190209353L;
+
+ private String documentRoot;
+ private String servletPath;
+
+ public JettyDefaultServlet(String servletPath, String documentRoot) {
+ this.servletPath = servletPath + '/';
+ this.documentRoot = documentRoot;
+ }
+
+ @Override
+ public Resource getResource(String pathInContext) {
+ if (pathInContext.startsWith(servletPath)) {
+ if (pathInContext.length() > servletPath.length()) {
+ pathInContext = pathInContext.substring(servletPath.length());
+ } else {
+ pathInContext = "";
+ }
+ } else {
+ if ((pathInContext + "/").equals(servletPath)) {
+ pathInContext = "";
+ }
+ }
+
+ try {
+ URL url = new URL(documentRoot + "/" + pathInContext);
+ return new URLResource(url, url.openConnection()) {
+ private static final long serialVersionUID = 8560952113883507717L;
+
+ @Override
+ public File getFile() throws IOException {
+ return null;
+ }
+
+ };
+ } catch (MalformedURLException e) {
+ return null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public String getInitParameter(String name) {
+ if ("resourceBase".equals(name)) {
+ return documentRoot;
+ } else if ("redirectWelcome".equals(name)) {
+ return "true";
+ } else {
+ return super.getInitParameter(name);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java b/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java
new file mode 100644
index 0000000000..be56bdb682
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.jetty;
+
+import java.util.logging.Level;
+
+import org.mortbay.log.Logger;
+
+/**
+ * Replaces Jetty's logging mechanism
+ *
+ * @version $Rev$ $Date$
+ */
+public class JettyLogger implements Logger {
+ private java.util.logging.Logger jdkLogger;
+
+ public JettyLogger() {
+ this(JettyLogger.class.getName());
+ }
+
+ public JettyLogger(String name) {
+ jdkLogger = java.util.logging.Logger.getLogger(name);
+ }
+
+ /**
+ * @param jdkLogger
+ */
+ public JettyLogger(java.util.logging.Logger jdkLogger) {
+ super();
+ this.jdkLogger = jdkLogger;
+ }
+
+ public String getName() {
+ return jdkLogger.getName();
+ }
+
+ public void debug(String msg) {
+ jdkLogger.log(Level.FINE, msg);
+ }
+
+ public void debug(String msg, Throwable th) {
+ jdkLogger.log(Level.FINE, msg, th);
+ }
+
+ public void debug(String msg, Object arg0, Object arg1) {
+ jdkLogger.log(Level.FINE, format(msg, arg0, arg1));
+ }
+
+ public Logger getLogger(String name) {
+ return new JettyLogger(name);
+ }
+
+ public void info(String msg) {
+ jdkLogger.log(Level.INFO, msg);
+ }
+
+ public void info(String msg, Object arg0, Object arg1) {
+ jdkLogger.log(Level.INFO, format(msg, arg0, arg1));
+ }
+
+ public boolean isDebugEnabled() {
+ return jdkLogger.isLoggable(Level.FINE);
+ }
+
+ public void setDebugEnabled(boolean enabled) {
+ jdkLogger.setLevel(Level.FINE);
+ }
+
+ public void warn(String msg) {
+ jdkLogger.log(Level.WARNING, msg);
+ }
+
+ public void warn(String msg, Object arg0, Object arg1) {
+ jdkLogger.log(Level.WARNING, format(msg, arg0, arg1));
+ }
+
+ public void warn(String msg, Throwable th) {
+ jdkLogger.log(Level.WARNING, msg, th);
+ }
+
+ private String format(String msg, Object arg0, Object arg1) {
+ int i0 = msg.indexOf("{}");
+ int i1 = i0 < 0 ? -1 : msg.indexOf("{}", i0 + 2);
+
+ if (arg1 != null && i1 >= 0)
+ msg = msg.substring(0, i1) + arg1 + msg.substring(i1 + 2);
+ if (arg0 != null && i0 >= 0)
+ msg = msg.substring(0, i0) + arg0 + msg.substring(i0 + 2);
+ return msg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java b/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
new file mode 100644
index 0000000000..aa53815b7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
@@ -0,0 +1,596 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.jetty;
+
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.KeyStore;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
+import org.apache.tuscany.sca.host.http.SecurityContext;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ContextHandler;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
+import org.mortbay.jetty.servlet.DefaultServlet;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.ServletMapping;
+import org.mortbay.jetty.servlet.SessionHandler;
+import org.mortbay.log.Log;
+import org.mortbay.thread.ThreadPool;
+
+/**
+ * Implements an HTTP transport service using Jetty.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JettyServer implements ServletHost, LifeCycleListener {
+ private static final Logger logger = Logger.getLogger(JettyServer.class.getName());
+
+ private final Object joinLock = new Object();
+ private String trustStore;
+ private String trustStorePassword;
+ private String keyStore;
+ private String keyStorePassword;
+
+ private String keyStoreType;
+ private String trustStoreType;
+
+ private boolean sendServerVersion;
+ private WorkScheduler workScheduler;
+
+ // TODO - this static seems to be set by the JSORPC binding unit test
+ // doesn't look to be a great way of doing things
+ public static int portDefault = 8080;
+ private int defaultPort = portDefault;
+ private int defaultSSLPort = 8443;
+
+ /**
+ * Represents a port and the server that serves it.
+ */
+ private class Port {
+ private Server server;
+ private ServletHandler servletHandler;
+
+ private Port(Server server, ServletHandler servletHandler) {
+ this.server = server;
+ this.servletHandler = servletHandler;
+ }
+
+ public Server getServer() {
+ return server;
+ }
+
+ public ServletHandler getServletHandler() {
+ return servletHandler;
+ }
+ }
+
+ private Map<Integer, Port> ports = new HashMap<Integer, Port>();
+
+ private String contextPath = "/";
+ private org.mortbay.log.Logger jettyLogger;
+
+ public JettyServer(ExtensionPointRegistry registry) {
+ this(registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(WorkScheduler.class));
+ }
+
+ protected JettyServer(WorkScheduler workScheduler) {
+ this.defaultPort = portDefault;
+ this.workScheduler = workScheduler;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ trustStore = System.getProperty("javax.net.ssl.trustStore");
+ trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
+ keyStore = System.getProperty("javax.net.ssl.keyStore");
+ keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
+
+ keyStoreType = System.getProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType());
+ trustStoreType = System.getProperty("javax.net.ssl.trustStoreType", KeyStore.getDefaultType());
+
+ System.setProperty("JETTY_NO_SHUTDOWN_HOOK", "true");
+ return null;
+ }
+ });
+ }
+
+ public String getName() {
+ return "jetty";
+ }
+
+ public void setDefaultPort(int port) {
+ defaultPort = port;
+ }
+
+ public int getDefaultPort() {
+ return defaultPort;
+ }
+
+ public void setSendServerVersion(boolean sendServerVersion) {
+ this.sendServerVersion = sendServerVersion;
+ }
+
+ /**
+ * Stop all the started servers.
+ */
+ public void stop() {
+ synchronized (joinLock) {
+ joinLock.notifyAll();
+ }
+ try {
+ Set<Entry<Integer, Port>> entries = new HashSet<Entry<Integer, Port>>(ports.entrySet());
+ for (Entry<Integer, Port> entry : entries) {
+ Port port = entry.getValue();
+ Server server = port.getServer();
+ server.stop();
+ server.setStopAtShutdown(false);
+ ports.remove(entry.getKey());
+ }
+ } catch (Exception e) {
+ throw new ServletMappingException(e);
+ } finally {
+ if (jettyLogger != null) {
+ Log.setLog(jettyLogger);
+ jettyLogger = null;
+ }
+ }
+ }
+
+ private void configureSSL(SslSocketConnector connector, SecurityContext securityContext) {
+ connector.setProtocol("TLS");
+ if (securityContext != null) {
+ keyStoreType =
+ securityContext.getSSLProperties().getProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType());
+ keyStore = securityContext.getSSLProperties().getProperty("javax.net.ssl.keyStore");
+ keyStorePassword = securityContext.getSSLProperties().getProperty("javax.net.ssl.keyStorePassword");
+
+ trustStoreType =
+ securityContext.getSSLProperties().getProperty("javax.net.ssl.trustStoreType",
+ KeyStore.getDefaultType());
+ trustStore = securityContext.getSSLProperties().getProperty("javax.net.ssl.trustStore");
+ trustStorePassword = securityContext.getSSLProperties().getProperty("javax.net.ssl.trustStorePassword");
+ }
+ connector.setKeystore(keyStore);
+ connector.setKeyPassword(keyStorePassword);
+ connector.setKeystoreType(keyStoreType);
+
+ connector.setTruststore(trustStore);
+ connector.setTrustPassword(trustStorePassword);
+ connector.setTruststoreType(trustStoreType);
+
+ connector.setPassword(keyStorePassword);
+ if (trustStore != null) {
+ connector.setNeedClientAuth(true);
+ }
+
+ }
+
+ public String addServletMapping(String suri, Servlet servlet) throws ServletMappingException {
+ return addServletMapping(suri, servlet, null);
+ }
+
+ public String addServletMapping(String suri, Servlet servlet, final SecurityContext securityContext)
+ throws ServletMappingException {
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = null;
+ if (securityContext != null && securityContext.isSSLEnabled()) {
+ scheme = "https";
+ } else {
+ scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ }
+
+ String host = uri.getHost();
+ if ("0.0.0.0".equals(host)) {
+ host = null;
+ }
+
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ if ("http".equals(scheme)) {
+ portNumber = defaultPort;
+ } else {
+ portNumber = defaultSSLPort;
+ }
+ }
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+
+ // Create and start a new server
+ try {
+ Server server = new Server();
+ server.setThreadPool(new WorkSchedulerThreadPool());
+ if ("https".equals(scheme)) {
+ // Connector httpConnector = new SelectChannelConnector();
+ // httpConnector.setPort(portNumber);
+ SslSocketConnector sslConnector = new SslSocketConnector();
+ sslConnector.setPort(portNumber);
+ // FIXME: [rfeng] We should set the host to be bound but binding-ws-axis2 is passing
+ // in an absolute URI with host set to one of the ip addresses
+ sslConnector.setHost(host);
+ configureSSL(sslConnector, securityContext);
+ server.setConnectors(new Connector[] {sslConnector});
+ } else {
+ SelectChannelConnector selectConnector = new SelectChannelConnector();
+ selectConnector.setPort(portNumber);
+ // FIXME: [rfeng] We should set the host to be bound but binding-ws-axis2 is passing
+ // in an absolute URI with host set to one of the ip addresses
+ selectConnector.setHost(host);
+ server.setConnectors(new Connector[] {selectConnector});
+ }
+
+ ContextHandler contextHandler = new ContextHandler();
+ //contextHandler.setContextPath(contextPath);
+ contextHandler.setContextPath("/");
+ server.setHandler(contextHandler);
+
+ SessionHandler sessionHandler = new SessionHandler();
+ ServletHandler servletHandler = new ServletHandler();
+ sessionHandler.addHandler(servletHandler);
+
+ contextHandler.setHandler(sessionHandler);
+
+ server.setStopAtShutdown(true);
+ server.setSendServerVersion(sendServerVersion);
+ server.start();
+
+ // Keep track of the new server and Servlet handler
+ port = new Port(server, servletHandler);
+ ports.put(portNumber, port);
+
+ } catch (Exception e) {
+ throw new ServletMappingException(e);
+ }
+ }
+
+ // Register the Servlet mapping
+ ServletHandler servletHandler = port.getServletHandler();
+ ServletHolder holder;
+ if (servlet instanceof DefaultResourceServlet) {
+
+ // Optimize the handling of resource requests, use the Jetty default Servlet
+ // instead of our default resource Servlet
+ String servletPath = uri.getPath();
+ if (servletPath.endsWith("*")) {
+ servletPath = servletPath.substring(0, servletPath.length() - 1);
+ }
+ if (servletPath.endsWith("/")) {
+ servletPath = servletPath.substring(0, servletPath.length() - 1);
+ }
+ if (!servletPath.startsWith("/")) {
+ servletPath = '/' + servletPath;
+ }
+
+ DefaultResourceServlet resourceServlet = (DefaultResourceServlet)servlet;
+ DefaultServlet defaultServlet = new JettyDefaultServlet(servletPath, resourceServlet.getDocumentRoot());
+ holder = new ServletHolder(defaultServlet);
+
+ } else {
+ holder = new ServletHolder(servlet);
+ }
+ servletHandler.addServlet(holder);
+
+ ServletMapping mapping = new ServletMapping();
+ mapping.setServletName(holder.getName());
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ mapping.setPathSpec(path);
+ servletHandler.addServletMapping(mapping);
+
+ // Compute the complete URL
+ if (host == null) {
+ try {
+ host = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+ }
+ URL addedURL;
+ try {
+ addedURL = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ logger.info("Added Servlet mapping: " + addedURL);
+ return addedURL.toString();
+ }
+
+ public URL getURLMapping(String suri, SecurityContext securityContext) throws ServletMappingException {
+ return map(suri, securityContext, true);
+ }
+
+ private URL map(String suri, SecurityContext securityContext, boolean resolve) throws ServletMappingException {
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = null;
+ if (securityContext != null && securityContext.isSSLEnabled()) {
+ scheme = "https";
+ } else {
+ scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ }
+
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ if ("http".equals(scheme)) {
+ portNumber = defaultPort;
+ } else {
+ portNumber = defaultSSLPort;
+ }
+ }
+
+ // Get the host
+ String host = uri.getHost();
+ if (host == null) {
+ host = "0.0.0.0";
+ if (resolve) {
+ try {
+ host = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+ }
+ }
+
+ // Construct the URL
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ URL url;
+ try {
+ url = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ return url;
+ }
+
+ public Servlet getServletMapping(String suri) throws ServletMappingException {
+
+ if (suri == null) {
+ return null;
+ }
+
+ URI uri = URI.create(suri);
+
+ // Get the URI port
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPort;
+ }
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+ return null;
+ }
+
+ // Remove the Servlet mapping for the given Servlet
+ ServletHandler servletHandler = port.getServletHandler();
+ Servlet servlet = null;
+ List<ServletMapping> mappings =
+ new ArrayList<ServletMapping>(Arrays.asList(servletHandler.getServletMappings()));
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ for (ServletMapping mapping : mappings) {
+ if (Arrays.asList(mapping.getPathSpecs()).contains(path)) {
+ try {
+ servlet = servletHandler.getServlet(mapping.getServletName()).getServlet();
+ } catch (ServletException e) {
+ throw new IllegalStateException(e);
+ }
+ break;
+ }
+ }
+ return servlet;
+ }
+
+ public Servlet removeServletMapping(String suri) {
+ URI uri = URI.create(suri);
+
+ // Get the URI port
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPort;
+ }
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+ // TODO - EPR - SL commented out exception temporarily as the runtime is shared
+ // between multiple nodes in a VM and shutting down one node blows
+ // up any other nodes when they shut down.
+ //throw new IllegalStateException("No servlet registered at this URI: " + suri);
+ logger.warning("No servlet registered at this URI: " + suri);
+ return null;
+ }
+
+ // Remove the Servlet mapping for the given Servlet
+ ServletHandler servletHandler = port.getServletHandler();
+ Servlet removedServlet = null;
+ List<ServletMapping> mappings =
+ new ArrayList<ServletMapping>(Arrays.asList(servletHandler.getServletMappings()));
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ for (ServletMapping mapping : mappings) {
+ if (Arrays.asList(mapping.getPathSpecs()).contains(path)) {
+ try {
+ removedServlet = servletHandler.getServlet(mapping.getServletName()).getServlet();
+ } catch (ServletException e) {
+ throw new IllegalStateException(e);
+ }
+ mappings.remove(mapping);
+ logger.info("Removed Servlet mapping: " + path);
+ break;
+ }
+ }
+ if (removedServlet != null) {
+ servletHandler.setServletMappings(mappings.toArray(new ServletMapping[mappings.size()]));
+
+ // Stop the port if there are no servlet mappings on it anymore
+ if (mappings.size() == 0) {
+ try {
+ Server server = port.getServer();
+ server.stop();
+ server.setStopAtShutdown(false);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ ports.remove(portNumber);
+ }
+
+ } else {
+ logger.warning("Trying to Remove servlet mapping: " + path + " where mapping is not registered");
+ }
+
+ return removedServlet;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String suri) throws ServletMappingException {
+ //FIXME implement this later
+ return null;
+ }
+
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ public void setContextPath(String path) {
+ this.contextPath = path;
+ }
+
+ /**
+ * A wrapper to enable use of a WorkScheduler with Jetty
+ */
+ private class WorkSchedulerThreadPool implements ThreadPool {
+
+ public boolean dispatch(Runnable work) {
+ workScheduler.scheduleWork(work);
+ return true;
+ }
+
+ public void join() throws InterruptedException {
+ synchronized (joinLock) {
+ joinLock.wait();
+ }
+ }
+
+ public int getThreads() {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getIdleThreads() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLowOnThreads() {
+ return false;
+ }
+ }
+
+ public void setAttribute(String name, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void start() {
+ try {
+ jettyLogger = new JettyLogger(logger);
+ Log.setLog(jettyLogger);
+ } catch (Throwable e) {
+ // Ignore
+ }
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ if (ports.size() > 0) {
+ return ports.values().iterator().next().getServletHandler().getServletContext();
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/sandbox/sebastien/java/embed/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
new file mode 100644
index 0000000000..a93f4d5754
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
@@ -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 ServletHost
+org.apache.tuscany.sca.http.jetty.JettyServer;name=jetty,ranking=100
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java b/sandbox/sebastien/java/embed/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java
new file mode 100644
index 0000000000..a3199cf4d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java
@@ -0,0 +1,358 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.http.jetty;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.ConnectException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.URL;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
+import org.apache.tuscany.sca.work.NotificationListener;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.junit.Assert;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JettyServerTestCase extends TestCase {
+
+ private static final String REQUEST1_HEADER =
+ "GET / HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST1_CONTENT = "";
+ private static final String REQUEST1 =
+ REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT;
+
+ private static final String REQUEST2_HEADER =
+ "GET /webcontent/test.html HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST2_CONTENT = "";
+ private static final String REQUEST2 =
+ REQUEST2_HEADER + REQUEST2_CONTENT.getBytes().length + "\n\n" + REQUEST2_CONTENT;
+
+ private static final int HTTP_PORT = 8085;
+
+ private WorkScheduler workScheduler = new WorkScheduler() {
+
+ public <T extends Runnable> void scheduleWork(T work) {
+ Thread thread = new Thread(work);
+ thread.start();
+ }
+
+ public <T extends Runnable> void scheduleWork(T work, NotificationListener<T> listener) {
+ scheduleWork(work);
+ }
+
+ public void destroy() {
+ }
+ };
+
+ /**
+ * Verifies requests are properly routed according to the Servlet mapping
+ */
+ public void testRegisterServletMapping() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/", servlet);
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.stop();
+ assertTrue(servlet.invoked);
+ }
+
+ /**
+ * Verifies requests are properly routed according to the Servlet mapping
+ */
+ public void testDeployedURI() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.setDefaultPort(8085);
+ service.start();
+ TestServlet servlet = new TestServlet();
+ String host = InetAddress.getLocalHost().getHostAddress();
+ String hostName = InetAddress.getLocalHost().getHostName();
+ String url1 = service.addServletMapping("/MyService", servlet);
+ Assert.assertEquals("http://" + host + ":8085/MyService", url1);
+ String url2 = service.addServletMapping("http://localhost:8086/MyService", servlet);
+ Assert.assertEquals("http://localhost:8086/MyService", url2);
+ String url3 = service.addServletMapping("http://" + host + ":8087/MyService", servlet);
+ Assert.assertEquals("http://" + host + ":8087/MyService", url3);
+ String url4 = service.addServletMapping("http://0.0.0.0:8088/MyService", servlet);
+ Assert.assertEquals("http://" + host + ":8088/MyService", url4);
+ String url5 = service.addServletMapping("http://" + hostName + ":8089/MyService", servlet);
+ Assert.assertEquals("http://" + hostName + ":8089/MyService", url5);
+
+ service.stop();
+ }
+
+ public void testRegisterServletMappingSSL() throws Exception {
+ System.setProperty("javax.net.ssl.keyStore", "target/test-classes/tuscany.keyStore");
+ System.setProperty("javax.net.ssl.keyStorePassword", "apache");
+ System.setProperty("jetty.ssl.password", "apache");
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+ TestServlet servlet = new TestServlet();
+ try {
+ service.addServletMapping("https://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ } finally {
+ System.clearProperty("javax.net.ssl.keyStore");
+ System.clearProperty("javax.net.ssl.keyStorePassword");
+ System.clearProperty("jetty.ssl.password");
+ }
+ System.setProperty("javax.net.ssl.trustStore", "target/test-classes/tuscany.keyStore");
+ System.setProperty("javax.net.ssl.trustStorePassword", "apache");
+ URL url = new URL("https://127.0.0.1:8085/foo");
+ HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
+ conn.setHostnameVerifier(new HostnameVerifier() {
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }}
+ );
+
+ conn.connect();
+ read(conn.getInputStream());
+
+ service.stop();
+ assertTrue(servlet.invoked);
+
+ }
+
+ /**
+ * Verifies that Servlets can be registered with multiple ports
+ */
+ public void testRegisterMultiplePorts() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/", servlet);
+ TestServlet servlet2 = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + (HTTP_PORT + 1) + "/", servlet2);
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT + 1);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+
+ service.stop();
+ assertTrue(servlet.invoked);
+ assertTrue(servlet2.invoked);
+ }
+
+ public void testUnregisterMapping() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+ TestServlet servlet = new TestServlet();
+ String uri = "http://127.0.0.1:" + HTTP_PORT + "/foo";
+ service.addServletMapping(uri, servlet);
+ service.removeServletMapping(uri);
+ try {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ fail("Server still bound to port");
+ } catch (ConnectException e) {
+ }
+ service.stop();
+ assertFalse(servlet.invoked);
+ }
+
+ public void testRequestSession() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/", servlet);
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.stop();
+ assertTrue(servlet.invoked);
+ assertNotNull(servlet.sessionId);
+ }
+
+ public void testRestart() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+ service.stop();
+ service.stop();
+ }
+
+ public void testNoMappings() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+ Exception ex = null;
+ try {
+ new Socket("127.0.0.1", HTTP_PORT);
+ } catch (ConnectException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ service.stop();
+ }
+
+ public void testResourceServlet() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+
+ String documentRoot = getClass().getClassLoader().getResource("content/test.html").toString();
+ documentRoot = documentRoot.substring(0, documentRoot.lastIndexOf('/'));
+ DefaultResourceServlet resourceServlet = new DefaultResourceServlet(documentRoot);
+ TestResourceServlet servlet = new TestResourceServlet(resourceServlet);
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/webcontent/*", servlet);
+
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST2.getBytes());
+ os.flush();
+
+ String document = read(client);
+ assertTrue(document.indexOf("<body><p>hello</body>") != -1);
+
+ service.stop();
+ }
+
+ public void testDefaultServlet() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.start();
+
+ String documentRoot = getClass().getClassLoader().getResource("content/test.html").toString();
+ documentRoot = documentRoot.substring(0, documentRoot.lastIndexOf('/'));
+ DefaultResourceServlet resourceServlet = new DefaultResourceServlet(documentRoot);
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/webcontent/*", resourceServlet);
+
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST2.getBytes());
+ os.flush();
+
+ String document = read(client);
+ assertTrue(document.indexOf("<body><p>hello</body>") != -1);
+
+ service.stop();
+ }
+
+ private static String read(Socket socket) throws IOException {
+ InputStream is = socket.getInputStream();
+ return read(is);
+ }
+
+ private static String read(InputStream is) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+
+ private class TestServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ boolean invoked;
+ String sessionId;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ invoked = true;
+ sessionId = req.getSession().getId();
+ OutputStream writer = resp.getOutputStream();
+ try {
+ writer.write("result".getBytes());
+ } finally {
+ writer.close();
+ }
+ }
+
+ }
+
+ private class TestResourceServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ private HttpServlet delegate;
+
+ public TestResourceServlet(HttpServlet delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ delegate.init();
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init();
+ delegate.init(config);
+ }
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ delegate.service(req, resp);
+ }
+
+ @Override
+ public void destroy() {
+ super.destroy();
+ delegate.destroy();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/src/test/resources/content/test.html b/sandbox/sebastien/java/embed/modules/host-jetty/src/test/resources/content/test.html
new file mode 100644
index 0000000000..f4b79d7f01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/src/test/resources/content/test.html
@@ -0,0 +1,21 @@
+<html>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<body><p>hello</body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/host-jetty/src/test/resources/tuscany.keyStore b/sandbox/sebastien/java/embed/modules/host-jetty/src/test/resources/tuscany.keyStore
new file mode 100644
index 0000000000..7ea23f7ff4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-jetty/src/test/resources/tuscany.keyStore
Binary files differ
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/LICENSE b/sandbox/sebastien/java/embed/modules/host-rmi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/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/sebastien/java/embed/modules/host-rmi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/host-rmi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..567c222abe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.rmi;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA RMI Host Extension Point
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA RMI Host Extension Point
+Import-Package: javax.net,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.rmi;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.host.rmi
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/NOTICE b/sandbox/sebastien/java/embed/modules/host-rmi/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/pom.xml b/sandbox/sebastien/java/embed/modules/host-rmi/pom.xml
new file mode 100644
index 0000000000..b00e404696
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/pom.xml
@@ -0,0 +1,39 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <name>Apache Tuscany SCA RMI Host Extension Point</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java
new file mode 100644
index 0000000000..dade6ef7f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.rmi;
+
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.UnknownHostException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NoSuchObjectException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.RMISocketFactory;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+
+/**
+ * Default implementation of a RMI host.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultRMIHost implements RMIHost {
+ private final static Logger logger = Logger.getLogger(DefaultRMIHost.class.getName());
+ private static final int CONNECTION_TIMEOUT = 3000; // 3 seconds
+
+ // Map of RMI registries started and running
+ private Map<String, Registry> rmiRegistries;
+
+ private RMISocketFactory socketFactory;
+
+ public DefaultRMIHost() {
+ rmiRegistries = new ConcurrentHashMap<String, Registry>();
+ this.socketFactory = new RMISocketFactoryImpl(CONNECTION_TIMEOUT);
+ }
+
+ public String registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException {
+ RMIURI rmiURI = new RMIURI(uri);
+
+ Registry registry;
+ try {
+ registry = rmiRegistries.get(Integer.toString(rmiURI.port));
+ if (registry == null) {
+ try {
+ registry = LocateRegistry.createRegistry(rmiURI.port, socketFactory, socketFactory);
+ } catch (RemoteException e) {
+ registry = LocateRegistry.getRegistry(null, rmiURI.port, socketFactory);
+ }
+ rmiRegistries.put(Integer.toString(rmiURI.port), registry);
+ }
+ registry.bind(rmiURI.serviceName, serviceObject);
+ logger.info("RMI service registered: " + rmiURI);
+ return rmiURI.toString();
+ } catch (AlreadyBoundException e) {
+ throw new RMIHostException(e);
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ }
+
+ }
+
+ public void unregisterService(String uri) throws RMIHostException, RMIHostRuntimeException {
+ RMIURI rmiURI = new RMIURI(uri);
+
+ try {
+ Registry registry = rmiRegistries.get(Integer.toString(rmiURI.port));
+ if (registry == null) {
+ registry = LocateRegistry.getRegistry(null, rmiURI.port, socketFactory);
+ rmiRegistries.put(Integer.toString(rmiURI.port), registry);
+ }
+ registry.unbind(rmiURI.serviceName);
+ logger.info("RMI service unregistered: " + rmiURI);
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ } catch (NotBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ }
+ }
+
+ public Remote findService(String uri) throws RMIHostException, RMIHostRuntimeException {
+ RMIURI rmiURI = new RMIURI(uri);
+
+ Remote remoteService = null;
+ try {
+ // Requires permission java.net.SocketPermission "host:port", "connect,accept,resolve"
+ // in security policy.
+ Registry registry = LocateRegistry.getRegistry(rmiURI.host, rmiURI.port, socketFactory);
+
+ if (registry != null) {
+ remoteService = registry.lookup(rmiURI.serviceName);
+ }
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ } catch (NotBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ }
+ return remoteService;
+ }
+
+ /**
+ * A representation of an RMI URI.
+ *
+ * rmi://[host][:port][/[object]]
+ * rmi:[/][object]
+ */
+ private static class RMIURI {
+ private String uriStr;
+ private String host;
+ private int port;
+ private String serviceName;
+
+ private RMIURI(String uriStr) {
+ URI uri = URI.create(uriStr);
+ host = uri.getHost();
+ if (host == null) {
+ try {
+ host = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+ }
+ port = uri.getPort();
+ if (port <= 0) {
+ port = RMI_DEFAULT_PORT;
+ }
+ String path = uri.getPath();
+ if (path != null && path.charAt(0) == '/') {
+ path = path.substring(1);
+ }
+ serviceName = path;
+ this.uriStr = "rmi://" + host + ":" + port + "/" + serviceName;
+ }
+
+ public String toString() {
+ return uriStr;
+ }
+ }
+
+ public void stop() {
+ for (Registry registry : rmiRegistries.values()) {
+ try {
+ UnicastRemoteObject.unexportObject(registry, false);
+ } catch (NoSuchObjectException e) {
+ e.printStackTrace();
+ }
+ }
+ rmiRegistries.clear();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java
new file mode 100644
index 0000000000..541ee8ba06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.host.rmi;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.LifeCycleListener;
+
+/**
+ * Default implementation of an RMI host extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultRMIHostExtensionPoint implements RMIHostExtensionPoint, LifeCycleListener {
+
+ private List<RMIHost> rmiHosts = new ArrayList<RMIHost>();
+
+ public DefaultRMIHostExtensionPoint() {
+ }
+
+ public void addRMIHost(RMIHost rmiHost) {
+ rmiHosts.add(rmiHost);
+ if(rmiHost instanceof LifeCycleListener) {
+ ((LifeCycleListener) rmiHost).start();
+ }
+ }
+
+ public void removeRMIHost(RMIHost rmiHost) {
+ rmiHosts.remove(rmiHost);
+ }
+
+ public synchronized List<RMIHost> getRMIHosts() {
+ if(rmiHosts.isEmpty()) {
+ addRMIHost(new DefaultRMIHost());
+ }
+ return rmiHosts;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ for (RMIHost host : rmiHosts) {
+ if(host instanceof LifeCycleListener) {
+ ((LifeCycleListener) host).stop();
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java
new file mode 100644
index 0000000000..d1936518ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.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.host.rmi;
+
+import java.rmi.Remote;
+
+
+/**
+ * Default implementation of an extensible RMI host.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleRMIHost implements RMIHost {
+
+ private RMIHostExtensionPoint rmiHosts;
+
+ public ExtensibleRMIHost(RMIHostExtensionPoint rmiHosts) {
+ this.rmiHosts = rmiHosts;
+ }
+
+ public String registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException {
+ if (rmiHosts.getRMIHosts().isEmpty()) {
+ throw new RMIHostException("No RMI host is available");
+ }
+ return getDefaultHost().registerService(uri, serviceObject);
+ }
+
+ public void unregisterService(String uri) throws RMIHostException, RMIHostRuntimeException {
+ if (rmiHosts.getRMIHosts().isEmpty()) {
+ throw new RMIHostException("No RMI host is available");
+ }
+ getDefaultHost().unregisterService(uri);
+ }
+
+ public Remote findService(String uri) throws RMIHostException, RMIHostRuntimeException {
+ if (rmiHosts.getRMIHosts().isEmpty()) {
+ throw new RMIHostException("No RMI host available");
+ }
+ return getDefaultHost().findService(uri);
+ }
+
+ protected RMIHost getDefaultHost() {
+ return rmiHosts.getRMIHosts().get(0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java
new file mode 100644
index 0000000000..df3f074168
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.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.sca.host.rmi;
+
+import java.rmi.Remote;
+
+/**
+ * RMI Service hosting interface to be implemented by host environments that allows SCA Components
+ * to register RMI Services to handle inbound service requests over RMI to SCA Components
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RMIHost {
+ int RMI_DEFAULT_PORT = 1099;
+
+ /**
+ * Register an RMI service with the given name and port
+ *
+ * @param uri the URI against which the server is to be registered
+ * @param serviceObject the server object to be registered
+ * @return TODO
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ String registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException;
+
+ /**
+ * Unregister a service registered under the given service name and port number
+ *
+ * @param uri the URI of the server
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ void unregisterService(String uri) throws RMIHostException, RMIHostRuntimeException;
+
+ /**
+ * find a remote service hosted on the given host, port and service name
+ *
+ * @param uri the URI of the service
+ * @return the RMI server object
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ Remote findService(String uri) throws RMIHostException, RMIHostRuntimeException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostException.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostException.java
new file mode 100644
index 0000000000..5ea46b9e0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.host.rmi;
+
+
+/**
+ * This exception will relate to situations where the end applicaition's input is the cause of the exception
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIHostException extends RuntimeException {
+
+ private static final long serialVersionUID = 3378300080918544410L;
+
+ public RMIHostException() {
+ }
+
+ public RMIHostException(String message) {
+ super(message);
+ }
+
+ public RMIHostException(Throwable e) {
+ super(e);
+ }
+
+ public RMIHostException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostExtensionPoint.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostExtensionPoint.java
new file mode 100644
index 0000000000..40d6013940
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostExtensionPoint.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.rmi;
+
+import java.util.List;
+
+/**
+ * An extension point for RMI hosts.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RMIHostExtensionPoint {
+
+ /**
+ * Adds a Servlet host extension.
+ *
+ * @param rmiHost
+ */
+ void addRMIHost(RMIHost rmiHost);
+
+ /**
+ * Removes a Servlet host extension.
+ *
+ * @param rmiHost
+ */
+ void removeRMIHost(RMIHost rmiHost);
+
+ /**
+ * Returns a list of Servlet host extensions.
+ *
+ * @return
+ */
+ List<RMIHost> getRMIHosts();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostRuntimeException.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostRuntimeException.java
new file mode 100644
index 0000000000..dfbcc62939
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostRuntimeException.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.sca.host.rmi;
+
+
+/**
+ * This exception relates to cases where there is a problem with the
+ * Host runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIHostRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = -2639598547028423686L;
+
+ public RMIHostRuntimeException() {
+ }
+
+ public RMIHostRuntimeException(String message) {
+ super(message);
+ }
+
+ public RMIHostRuntimeException(Throwable e) {
+ super(e);
+ }
+
+ public RMIHostRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMISocketFactoryImpl.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMISocketFactoryImpl.java
new file mode 100644
index 0000000000..763e5c1315
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMISocketFactoryImpl.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.host.rmi;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.rmi.server.RMISocketFactory;
+
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+class RMISocketFactoryImpl extends RMISocketFactory {
+ private int clientTimeout;
+ private SocketFactory factory;
+ private ServerSocketFactory serverSocketFactory;
+
+ /**
+ * @param timeout
+ */
+ public RMISocketFactoryImpl(int clientTimeout) {
+ super();
+ this.clientTimeout = clientTimeout;
+ this.factory = SocketFactory.getDefault();
+ this.serverSocketFactory = ServerSocketFactory.getDefault();
+ }
+
+ public Socket createSocket(String host, int port) throws IOException {
+ Socket socket = factory.createSocket(host, port);
+ socket.setSoTimeout(clientTimeout);
+ return socket;
+ }
+
+ @Override
+ public ServerSocket createServerSocket(int port) throws IOException {
+ ServerSocket socket = serverSocketFactory.createServerSocket(port);
+ return socket;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint
new file mode 100644
index 0000000000..e7f8d54489
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint
@@ -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.
+
+org.apache.tuscany.sca.host.rmi.DefaultRMIHostExtensionPoint
+
diff --git a/sandbox/sebastien/java/embed/modules/host-rmi/src/test/java/org/apache/tuscany/sca/host/rmi/RMIHostImplTestCase.java b/sandbox/sebastien/java/embed/modules/host-rmi/src/test/java/org/apache/tuscany/sca/host/rmi/RMIHostImplTestCase.java
new file mode 100644
index 0000000000..1164c33a16
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-rmi/src/test/java/org/apache/tuscany/sca/host/rmi/RMIHostImplTestCase.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.host.rmi;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for the RMI Host.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIHostImplTestCase extends TestCase {
+
+ public void testInit() {
+ new DefaultRMIHost();
+ }
+
+ public void testFindServiceBadHost() throws RMIHostRuntimeException, RMIHostException {
+ try {
+ new DefaultRMIHost().findService("rmi://locahost:9994/$BAD$");
+ fail();
+ } catch (RMIHostRuntimeException e) {
+ // expected
+ }
+ }
+
+ public void testRegisterService1() throws RMIHostRuntimeException, RMIHostException {
+ DefaultRMIHost host = new DefaultRMIHost();
+ host.registerService("rmi://localhost:9996/foo1", new MockRemote());
+ host.unregisterService("rmi://localhost:9996/foo1");
+ }
+
+ public void testExistingRegistry() throws RMIHostRuntimeException, RMIHostException {
+ DefaultRMIHost host1 = new DefaultRMIHost();
+ host1.registerService("rmi://localhost:9995/foo1", new MockRemote());
+ DefaultRMIHost host2 = new DefaultRMIHost();
+ host2.registerService("rmi://localhost:9995/foo2", new MockRemote());
+ host2.unregisterService("rmi://localhost:9995/foo1");
+ host2.unregisterService("rmi://localhost:9995/foo2");
+ }
+
+ public void testRegisterService2() throws RMIHostRuntimeException, RMIHostException {
+ DefaultRMIHost host = new DefaultRMIHost();
+ host.registerService("rmi://localhost:9999/bar1", new MockRemote());
+ host.unregisterService("rmi://localhost:9999/bar1");
+ }
+
+ public void testRegisterServiceAlreadyBound() throws RMIHostRuntimeException, RMIHostException {
+ DefaultRMIHost host = new DefaultRMIHost();
+ host.registerService("rmi://localhost:9997/bar2", new MockRemote());
+ try {
+ host.registerService("rmi://localhost:9997/bar2", new MockRemote());
+ } catch (RMIHostException e) {
+ // expected
+ host.unregisterService("rmi://localhost:9997/bar2");
+ }
+ }
+
+ public void testUnRegisterService() throws RMIHostRuntimeException, RMIHostException {
+ DefaultRMIHost host = new DefaultRMIHost();
+ try {
+ host.unregisterService("rmi://localhost:9998/bar3");
+ fail();
+ } catch (RMIHostRuntimeException e) {
+ // expected
+ }
+ }
+
+ private static class MockRemote implements Remote, Serializable {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/LICENSE b/sandbox/sebastien/java/embed/modules/host-webapp/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/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/sebastien/java/embed/modules/host-webapp/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/host-webapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..871a1b160d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.webapp;version="2.0.0";
+ uses:="javax.servlet,org.apache.tuscany.sca.host.http,org.apache.tuscany.sca.core"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Webapp Host
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Webapp Host
+Import-Package: javax.naming,
+ javax.servlet,
+ javax.servlet.http,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.host.webapp;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.host.webapp
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/NOTICE b/sandbox/sebastien/java/embed/modules/host-webapp/NOTICE
new file mode 100644
index 0000000000..84e148eeef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/NOTICE
@@ -0,0 +1,7 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/pom.xml b/sandbox/sebastien/java/embed/modules/host-webapp/pom.xml
new file mode 100644
index 0000000000..95a052e299
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/pom.xml
@@ -0,0 +1,73 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-host-webapp</artifactId>
+ <name>Apache Tuscany SCA Webapp Host</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
new file mode 100644
index 0000000000..45c1bbf3da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.webapp;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * A ServletContextListener to create and close the SCADomain
+ * when the webapp is initialized or destroyed.
+ */
+public class TuscanyContextListener implements ServletContextListener {
+ private final Logger logger = Logger.getLogger(TuscanyContextListener.class.getName());
+ private boolean inited;
+
+ public void contextInitialized(ServletContextEvent event) {
+ logger.info(event.getServletContext().getServletContextName() + " is starting.");
+ try {
+ WebAppHelper.init(event.getServletContext());
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ inited = true;
+ }
+
+ public void contextDestroyed(ServletContextEvent event) {
+ logger.info(event.getServletContext().getServletContextName() + " is stopping.");
+ if (!inited) {
+ return;
+ }
+ try {
+ WebAppHelper.stop(event.getServletContext());
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ inited = false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java
new file mode 100644
index 0000000000..a12466a9fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.webapp;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.tuscany.sca.host.http.ServletHost;
+
+/**
+ * A Servlet filter that forwards service requests to the Servlets registered with
+ * the Tuscany ServletHost.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyServletFilter implements Filter {
+ private static final long serialVersionUID = 1L;
+ private Logger logger = Logger.getLogger(TuscanyServletFilter.class.getName());
+
+ private transient ServletContext context;
+ private transient ServletHost servletHost;
+
+ public TuscanyServletFilter() {
+ super();
+ }
+
+ public void init(final FilterConfig config) throws ServletException {
+ try {
+ context = config.getServletContext();
+ for (Enumeration<String> e = config.getInitParameterNames(); e.hasMoreElements();) {
+ String name = e.nextElement();
+ String value = config.getInitParameter(name);
+ context.setAttribute(name, value);
+ }
+ servletHost = WebAppHelper.init(context);
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ context.log(e.getMessage(), e);
+ throw new ServletException(e);
+ }
+ }
+
+ public void destroy() {
+ WebAppHelper.stop(context);
+ servletHost = null;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, javax.servlet.FilterChain chain)
+ throws IOException, ServletException {
+ try {
+ // Get the Servlet path
+ HttpServletRequest httpRequest = (HttpServletRequest)request;
+ String path = httpRequest.getPathInfo();
+ if (path == null) {
+ path = httpRequest.getServletPath();
+ }
+ if (path == null) {
+ path = "/";
+ }
+
+ // Get a request dispatcher for the Servlet mapped to that path
+ RequestDispatcher dispatcher = servletHost.getRequestDispatcher(path);
+ if (dispatcher != null) {
+
+ // Let the dispatcher forward the request to the Servlet
+ dispatcher.forward(request, response);
+
+ } else {
+
+ // Proceed down the filter chain
+ chain.doFilter(request, response);
+
+ }
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ context.log(e.getMessage(), e);
+ throw new ServletException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
new file mode 100644
index 0000000000..655e19c88c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
@@ -0,0 +1,247 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.webapp;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Enumeration;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+
+public class WebAppHelper {
+ private static final String ROOT = "/";
+ // The prefix for the parameters in web.xml which configure the folders that contain SCA contributions
+ private static final String CONTRIBUTIONS = "contributions";
+ // The prefix for the parameters in web.xml which configure the individual SCA contributions
+ private static final String CONTRIBUTION = "contribution";
+ private static final String NODE_CONFIGURATION = "node.configuration";
+ private static final String WEB_COMPOSITE = "/WEB-INF/web.composite";
+ private static final String DOMAIN_URI = "domain.uri";
+ private static final String NODE_URI = "node.uri";
+ public static final String DOMAIN_NAME_ATTR = "org.apache.tuscany.sca.domain.name";
+ public static final String SCA_NODE_ATTRIBUTE = Node.class.getName();
+ private static NodeFactory factory;
+ private static WebAppServletHost host;
+
+ private static URL getResource(ServletContext servletContext, String location) throws IOException {
+ URI uri = URI.create(location);
+ if (uri.isAbsolute()) {
+ return uri.toURL();
+ } else {
+ String path = location;
+ if (!path.startsWith(ROOT)) {
+ path = ROOT + path;
+ }
+ URL url = servletContext.getResource(path);
+ if (url != null && url.getProtocol().equals("jndi")) {
+ //this is Tomcat case, we should use getRealPath
+ File warRootFile = new File(servletContext.getRealPath(path));
+ return warRootFile.toURI().toURL();
+ } else {
+ //this is Jetty case
+ return url;
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static NodeConfiguration getNodeConfiguration(ServletContext servletContext) throws IOException,
+ URISyntaxException {
+ NodeConfiguration configuration = null;
+ String nodeConfigURI = (String)servletContext.getAttribute(NODE_CONFIGURATION);
+ if (nodeConfigURI != null) {
+ URL url = getResource(servletContext, nodeConfigURI);
+ configuration = factory.loadConfiguration(url.openStream(), url);
+ } else {
+ configuration = factory.createNodeConfiguration();
+ Enumeration<String> names = servletContext.getAttributeNames();
+ while (names.hasMoreElements()) {
+ String name = names.nextElement();
+ if (name.equals(CONTRIBUTION) || name.startsWith(CONTRIBUTION + ".")) {
+ // We need to have a way to select one or more folders within the webapp as the contributions
+ String contrib = (String)servletContext.getAttribute(name);
+ if (contrib != null) {
+ File f = new File(getResource(servletContext, contrib).toURI());
+ configuration.addContribution(f.toURI().toURL());
+ }
+ } else if (name.equals(CONTRIBUTIONS) || name.startsWith(CONTRIBUTIONS + ".")) {
+ String contrib = (String)servletContext.getAttribute(name);
+ if (contrib != null) {
+ File f = new File(getResource(servletContext, contrib).toURI());
+ if (f.isDirectory()) {
+ for (File n : f.listFiles()) {
+ configuration.addContribution(n.toURI().toURL());
+ }
+ } else {
+ configuration.addContribution(f.toURI().toURL());
+ }
+ }
+ }
+ }
+
+ if (configuration.getContributions().isEmpty()) {
+ // TODO: Which path should be the default root
+ configuration.addContribution(getResource(servletContext, ROOT));
+ }
+ URL composite = getResource(servletContext, WEB_COMPOSITE);
+ if (composite != null) {
+ configuration.getContributions().get(0).addDeploymentComposite(composite);
+ }
+ String nodeURI = (String)servletContext.getAttribute(NODE_URI);
+ if (nodeURI == null) {
+ nodeURI = new File(servletContext.getRealPath(ROOT)).getName();
+ }
+ configuration.setURI(nodeURI);
+ String domainURI = (String)servletContext.getAttribute(DOMAIN_URI);
+ if (domainURI != null) {
+ configuration.setDomainURI(domainURI);
+ } else {
+ domainURI = servletContext.getInitParameter("org.apache.tuscany.sca.defaultDomainURI");
+ if (domainURI != null) {
+ configuration.setDomainURI(getDomainName(domainURI));
+ configuration.setDomainRegistryURI(domainURI);
+ }
+ }
+ }
+ return configuration;
+ }
+
+ // TODO: Temp for now to get the old samples working till i clean up all the domain uri/name after the ML discussion.
+ private static String getDomainName(String configURI) {
+ String domainName;
+ if (configURI.startsWith("tuscany:vm:")) {
+ domainName = configURI.substring("tuscany:vm:".length());
+ } else if (configURI.startsWith("tuscany:")) {
+ int i = configURI.indexOf('?');
+ if (i == -1) {
+ domainName = configURI.substring("tuscany:".length());
+ } else {
+ domainName = configURI.substring("tuscany:".length(), i);
+ }
+ } else {
+ domainName = configURI;
+ }
+ return domainName;
+ }
+
+ public synchronized static ServletHost init(final ServletContext servletContext) {
+ if (host == null) {
+ try {
+
+ String configValue = servletContext.getInitParameter("org.apache.tuscany.sca.config");
+ if (configValue != null) {
+ factory = NodeFactory.newInstance(configValue);
+ } else {
+ factory = NodeFactory.newInstance();
+ }
+ ExtensionPointRegistry registry = factory.getExtensionPointRegistry();
+ ServletHostExtensionPoint servletHosts = registry.getExtensionPoint(ServletHostExtensionPoint.class);
+ servletHosts.setWebApp(true);
+
+ // TODO: why are the init parameters copied to the attributes?
+ for (Enumeration<?> e = servletContext.getInitParameterNames(); e.hasMoreElements();) {
+ String name = (String)e.nextElement();
+ String value = servletContext.getInitParameter(name);
+ servletContext.setAttribute(name, value);
+ }
+
+ host = getServletHost(servletContext);
+
+ } catch (ServletException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ Node node = (Node)servletContext.getAttribute(SCA_NODE_ATTRIBUTE);
+ if (node == null) {
+ try {
+ node = createAndStartNode(servletContext);
+ } catch (ServletException e) {
+ throw new RuntimeException(e);
+ }
+ servletContext.setAttribute(SCA_NODE_ATTRIBUTE, node);
+ }
+
+ return host;
+ }
+
+ private static WebAppServletHost getServletHost(final ServletContext servletContext) throws ServletException {
+ WebAppServletHost host = getServletHost(factory);
+ host.init(new ServletConfig() {
+ public String getInitParameter(String name) {
+ return servletContext.getInitParameter(name);
+ }
+
+ public Enumeration<?> getInitParameterNames() {
+ return servletContext.getInitParameterNames();
+ }
+
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+
+ public String getServletName() {
+ return servletContext.getServletContextName();
+ }
+ });
+ return host;
+ }
+
+ private static WebAppServletHost getServletHost(NodeFactory factory) {
+ ExtensionPointRegistry registry = factory.getExtensionPointRegistry();
+ return (WebAppServletHost)org.apache.tuscany.sca.host.http.ServletHostHelper.getServletHost(registry);
+ }
+
+ private static Node createAndStartNode(final ServletContext servletContext) throws ServletException {
+ NodeConfiguration configuration;
+ try {
+ configuration = getNodeConfiguration(servletContext);
+ } catch (IOException e) {
+ throw new ServletException(e);
+ } catch (URISyntaxException e) {
+ throw new ServletException(e);
+ }
+ Node node = factory.createNode(configuration).start();
+ return node;
+ }
+
+ public static void stop(ServletContext servletContext) {
+ Node node = (Node)servletContext.getAttribute(SCA_NODE_ATTRIBUTE);
+ if (node != null) {
+ node.stop();
+ servletContext.setAttribute(SCA_NODE_ATTRIBUTE, null);
+ }
+ }
+
+ public static NodeFactory getNodeFactory() {
+ return factory;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java
new file mode 100644
index 0000000000..76cce939ad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.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.sca.host.webapp;
+
+import java.io.IOException;
+import java.util.StringTokenizer;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+/**
+ * A Servlet request dispatcher that can be used to delegate requests to a
+ * Servlet registered with the Webapp Servlet host.
+ *
+ * @version $Rev$ $Date$
+ */
+class WebAppRequestDispatcher implements RequestDispatcher {
+ private String servletPath;
+ private Servlet servlet;
+
+ public WebAppRequestDispatcher(String mapping, Servlet servlet) {
+ if (mapping.endsWith("*")) {
+ mapping = mapping.substring(0, mapping.length()-1);
+ }
+ if (mapping.endsWith("/")) {
+ mapping = mapping.substring(0, mapping.length()-1);
+ }
+ this.servletPath = mapping;
+ this.servlet = servlet;
+ }
+
+ /**
+ * Returns a request wrapper which will return the correct Servlet path
+ * and path info.
+ *
+ * @param request
+ * @return
+ */
+ private HttpServletRequest createRequestWrapper(ServletRequest request) {
+ HttpServletRequest requestWrapper = new HttpServletRequestWrapper((HttpServletRequest)request) {
+
+ @Override
+ public String getServletPath() {
+ return servletPath;
+ }
+
+ @Override
+ public String getPathInfo() {
+ String path = super.getServletPath();
+ if (path.length() == 0) {
+ path = super.getPathInfo();
+ }
+
+ // TODO: another context path hack, revisit when context path is sorted out
+ path = fiddlePath(path, servletPath);
+
+ return path;
+ }
+ };
+ return requestWrapper;
+ }
+
+ /**
+ * Remove any path suffix thats part of the Servlet context path
+ */
+ protected String fiddlePath(String path, String servletPath) {
+ if (path.startsWith(servletPath)) {
+ return path.substring(servletPath.length());
+ }
+ StringTokenizer st = new StringTokenizer(path, "/");
+ if (st.countTokens() == 1) {
+ return path;
+ }
+ String root = "";
+ while (st.hasMoreTokens()){
+ String s = st.nextToken();
+ if (servletPath.endsWith((root + "/" + s))) {
+ root += "/" + s;
+ } else {
+ break;
+ }
+ }
+ String fiddlePath = path.substring(root.length());
+ return fiddlePath;
+ }
+
+ public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ servlet.service(createRequestWrapper(request), response);
+ }
+
+ public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ servlet.service(createRequestWrapper(request), response);
+ }
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
new file mode 100644
index 0000000000..b927ecaf4c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
@@ -0,0 +1,342 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.host.webapp;
+
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.tuscany.sca.host.http.SecurityContext;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
+import org.apache.tuscany.sca.node.Node;
+
+/**
+ * ServletHost implementation for use in a webapp environment.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebAppServletHost implements ServletHost {
+ private static final Logger logger = Logger.getLogger(WebAppServletHost.class.getName());
+
+ public static final String SCA_NODE_ATTRIBUTE = Node.class.getName();
+
+ private Map<String, Servlet> servlets;
+ private String contextPath = "/";
+ private int defaultPortNumber = 8080;
+ private String contributionRoot;
+
+ private ServletConfig servletConfig;
+ private ServletContext servletContext;
+ private Map<String, Object> tempAttributes = new HashMap<String, Object>();
+
+ public WebAppServletHost() {
+ servlets = new HashMap<String, Servlet>();
+ }
+
+ public void setDefaultPort(int port) {
+ defaultPortNumber = port;
+ }
+
+ public int getDefaultPort() {
+ return defaultPortNumber;
+ }
+
+ public String getName() {
+ return "webapp";
+ }
+
+ public String addServletMapping(String suri, Servlet servlet) throws ServletMappingException {
+ return addServletMapping(suri, servlet, null);
+ }
+
+ public String addServletMapping(String suri, Servlet servlet, SecurityContext securityContext) throws ServletMappingException {
+ URI pathURI = URI.create(suri);
+
+ // Make sure that the path starts with a /
+ suri = pathURI.getPath();
+ if (!suri.startsWith("/")) {
+ suri = '/' + suri;
+ }
+
+ // String relativeURI = suri;
+ if (!suri.startsWith(contextPath + "/")) {
+ suri = contextPath + suri;
+ }
+
+ if (!servlets.values().contains(servlet)) {
+ // The same servlet can be registred more than once
+ try {
+ servlet.init(servletConfig);
+ } catch (ServletException e) {
+ throw new ServletMappingException(e);
+ }
+ }
+
+ // In a webapp just use the given path and ignore the host and port
+ // as they are fixed by the Web container
+ servlets.put(suri, servlet);
+
+ URL url = getURLMapping(suri, securityContext);
+ logger.info("Added Servlet mapping: " + url);
+ return url.toString();
+ }
+
+ public Servlet removeServletMapping(String suri) throws ServletMappingException {
+ URI pathURI = URI.create(suri);
+
+ // Make sure that the path starts with a /
+ suri = pathURI.getPath();
+ if (!suri.startsWith("/")) {
+ suri = '/' + suri;
+ }
+
+ if (!suri.startsWith(contextPath)) {
+ suri = contextPath + suri;
+ }
+
+ // In a webapp just use the given path and ignore the host and port
+ // as they are fixed by the Web container
+ Servlet servlet = servlets.remove(suri);
+ /*
+ if (servlet != null) {
+ servlet.destroy();
+ }
+ */
+ return servlet;
+ }
+
+ public Servlet getServletMapping(String suri) throws ServletMappingException {
+ if (!suri.startsWith("/")) {
+ suri = '/' + suri;
+ }
+
+ if (!suri.startsWith(contextPath)) {
+ suri = contextPath + suri;
+ }
+
+ // Get the Servlet mapped to the given path
+ Servlet servlet = servlets.get(suri);
+ return servlet;
+ }
+
+ public URL getURLMapping(String suri, SecurityContext securityContext) throws ServletMappingException {
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPortNumber;
+ }
+
+ // Get the host
+ String host = uri.getHost();
+ if (host == null) {
+ try {
+ host = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+ }
+
+ // Construct the URL
+ String path = uri.getPath();
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (contextPath != null && !path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ URL url;
+ try {
+ url = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ return url;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String suri) throws ServletMappingException {
+
+ // Make sure that the path starts with a /
+ if (!suri.startsWith("/")) {
+ suri = '/' + suri;
+ }
+
+ if (contextPath != null && contextPath.length() > 0 && !"/".equals(contextPath)) {
+ suri = contextPath + suri;
+ }
+
+ // Get the Servlet mapped to the given path
+ Servlet servlet = servlets.get(suri);
+ if (servlet != null) {
+ return new WebAppRequestDispatcher(suri, servlet);
+ }
+
+ for (Map.Entry<String, Servlet> entry : servlets.entrySet()) {
+ String servletPath = entry.getKey();
+ if (servletPath.endsWith("*")) {
+ servletPath = servletPath.substring(0, servletPath.length() - 1);
+ if (suri.startsWith(servletPath)) {
+ // entry key is contextPath/servletPath, WebAppRequestDispatcher only wants servletPath
+ return new WebAppRequestDispatcher(entry.getKey().substring(contextPath.length()), entry.getValue());
+ } else {
+ if ((suri + "/").startsWith(servletPath)) {
+ return new WebAppRequestDispatcher(entry.getKey().substring(contextPath.length()), entry.getValue());
+ }
+ }
+ }
+ }
+
+ // No Servlet found
+ return null;
+ }
+
+ public void init(ServletConfig config) throws ServletException {
+ this.servletConfig = config;
+ servletContext = config.getServletContext();
+
+ for (String name : tempAttributes.keySet()) {
+ servletContext.setAttribute(name, tempAttributes.get(name));
+ }
+
+ // WebAppHelper.init(servletContext);
+
+ initContextPath(config);
+
+ // Initialize the registered Servlets
+ for (Servlet servlet : servlets.values()) {
+ servlet.init(config);
+ }
+
+ }
+
+ /**
+ * Initializes the contextPath
+ * The 2.5 Servlet API has a getter for this, for pre 2.5 Servlet
+ * containers use an init parameter.
+ */
+ @SuppressWarnings("unchecked")
+ public void initContextPath(ServletConfig config) {
+
+ String oldContextPath = contextPath;
+
+ if (Collections.list(config.getInitParameterNames()).contains("contextPath")) {
+ contextPath = config.getInitParameter("contextPath");
+ } else {
+ // The getContextPath() is introduced since Servlet 2.5
+ ServletContext context = config.getServletContext();
+ try {
+ // Try to get the method anyway since some ServletContext impl has this method even before 2.5
+ Method m = context.getClass().getMethod("getContextPath", new Class[] {});
+ contextPath = (String)m.invoke(context, new Object[] {});
+ } catch (Exception e) {
+ logger.warning("Servlet level is: " + context.getMajorVersion() + "." + context.getMinorVersion());
+ throw new IllegalStateException("'contextPath' init parameter must be set for pre-2.5 servlet container");
+ }
+ }
+
+ logger.info("ContextPath: " + contextPath);
+
+ // if the context path changes after some servlets have been registered then
+ // need to reregister them (this can happen if extensions start before webapp init)
+ if (!oldContextPath.endsWith(contextPath)) {
+ List<String> oldServletURIs = new ArrayList<String>();
+ for (String oldServletURI : servlets.keySet()) {
+ if (oldServletURI.startsWith(oldContextPath)) {
+ if (!oldServletURI.startsWith(contextPath)) {
+ oldServletURIs.add(oldServletURI);
+ }
+ }
+ }
+ for (String oldURI : oldServletURIs) {
+ String ns = contextPath + "/" + oldURI.substring(oldContextPath.length());
+ servlets.put(ns, servlets.remove(oldURI));
+ }
+ }
+
+ }
+
+ void destroy() {
+
+ // Destroy the registered Servlets
+ for (Servlet servlet : servlets.values()) {
+ servlet.destroy();
+ }
+
+ // Close the SCA domain
+ WebAppHelper.stop(servletContext);
+ }
+
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ public void setContextPath(String path) {
+ }
+
+ /**
+ * TODO: How context paths work is still up in the air so for now
+ * this hacks in a path that gets some samples working
+ * can't use setContextPath as NodeImpl calls that later
+ */
+ public void setContextPath2(String path) {
+ if (path != null && path.length() > 0) {
+ this.contextPath = path;
+ }
+ }
+
+ public String getContributionRoot() {
+ return contributionRoot;
+ }
+
+ public void setAttribute(String name, Object value) {
+ if (servletContext != null) {
+ servletContext.setAttribute(name, value);
+ } else {
+ tempAttributes.put(name, value);
+ }
+ }
+
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
new file mode 100644
index 0000000000..de0d15435c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
@@ -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 ServletHost
+org.apache.tuscany.sca.host.webapp.WebAppServletHost;name=webapp,ranking=0
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/LICENSE
new file mode 100644
index 0000000000..baba9ca048
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/LICENSE
@@ -0,0 +1,251 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+=================================================================================================================
+
+This module implementation-script temporarily includes one file under the following BSD license:
+
+ Copyright (c) 2006, Sun Microsystems, Inc.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither the name of the Sun Microsystems, Inc. nor the names of
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+=================================================================================================================
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..79977c6864
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,52 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.implementation.bpel.ode;versio
+ n="2.0",org.apache.tuscany.sca.implementation.bpel.ode.provider;versi
+ on="2.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA BPEL ODE Implementation Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-ClassPath: .
+Bundle-Description: Apache Tuscany SCA BPEL ODE Implementation Extensi
+ on
+Import-Package: javax.persistence;version="1.0.0",
+ javax.persistence.spi;version="1.0.0",
+ javax.resource.spi,
+ javax.transaction;version="1.1.0",
+ javax.wsdl;resolution:=optional,
+ javax.xml.namespace;resolution:=optional,
+ org.apache.commons.logging;resolution:=optional,
+ org.apache.geronimo.transaction.manager,
+ org.apache.ode.bpel.compiler;version="1.3.2",
+ org.apache.ode.bpel.dao;version="1.3.2",
+ org.apache.ode.bpel.engine;version="1.3.2",
+ org.apache.ode.bpel.evt;version="1.3.2",
+ org.apache.ode.bpel.iapi;version="1.3.2",
+ org.apache.ode.bpel.memdao;version="1.3.2",
+ org.apache.ode.dao.jpa;version="1.3.2",
+ org.apache.ode.il.config;version="1.3.2",
+ org.apache.ode.il.dbutil;version="1.3.2",
+ org.apache.ode.scheduler.simple;version="1.3.2",
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.openjpa.persistence;version="1.2.1",
+ org.apache.tuscany.sca.assembly;version="2.0",
+ org.apache.tuscany.sca.core;version="2.0",
+ org.apache.tuscany.sca.databinding;version="2.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.implementation.bpel;version="2.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0",
+ org.apache.tuscany.sca.invocation;version="2.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0",
+ org.apache.tuscany.sca.runtime;version="2.0",
+ org.eclipse.core.runtime;common=split;resolution:=optional,
+ org.oasisopen.sca.annotation;version="2.0",
+ org.w3c.dom;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.bpel.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/NOTICE
new file mode 100644
index 0000000000..a2f696be26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/NOTICE
@@ -0,0 +1,17 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+This product also includes software under the BSD license
+(see the LICENSE file contained in this distribution), with
+the following copyright:
+
+Copyright (c) 2006, Sun Microsystems, Inc.
+All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/pom.xml
new file mode 100644
index 0000000000..eedf738ddb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/pom.xml
@@ -0,0 +1,495 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <name>Apache Tuscany SCA BPEL ODE Implementation Extension</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- ODE Jars -->
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-epr</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-store</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-dao</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby</artifactId>
+ <version>1.3.2</version>
+ <type>zip</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-runtime</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-scheduler-simple</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-utils</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-compiler</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-schemas</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-obj</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-jacob</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-jacob-ap</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <!-- http://issues.apache.org/jira/browse/ODE-604 -->
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-agents</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-hibernate</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+
+ <!-- implementation-bpel non-sca dependencies -->
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>common</artifactId>
+ <version>3.5.0-v20090520-1800</version>
+ </dependency>
+
+ <!-- ODE Dependencies -->
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-kernel</artifactId>
+ <version>2.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm-commons</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>mx4j</groupId>
+ <artifactId>mx4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xstream</groupId>
+ <artifactId>xstream</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-transaction</artifactId>
+ <version>2.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_2.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ognl</groupId>
+ <artifactId>ognl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_3.0_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_3.0_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-connector</artifactId>
+ <version>2.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.4.1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>tranql</groupId>
+ <artifactId>tranql-connector</artifactId>
+ <version>1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-j2ee-connector</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-jta</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>axion</groupId>
+ <artifactId>axion</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-primitives</groupId>
+ <artifactId>commons-primitives</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!-- http://issues.apache.org/jira/browse/ODE-605 -->
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>1.2.1</version>
+
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_3.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ </exclusions>
+
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.serp</groupId>
+ <artifactId>serp</artifactId>
+ <version>1.13.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xom</groupId>
+ <artifactId>xom</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
+ <version>2.3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>9.x</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-dom</artifactId>
+ <version>9.x</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-xpath</artifactId>
+ <version>9.x</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-xqj</artifactId>
+ <version>9.x</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.15</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.sun.jdmk</groupId>
+ <artifactId>jmxtools</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jmx</groupId>
+ <artifactId>jmxri</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby</artifactId>
+ <version>1.3.2</version>
+ <type>zip</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/test-classes/
+ </outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java
new file mode 100644
index 0000000000..fe1e2d620b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.URI;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+
+/**
+ * A class that handles the deploy.xml file required for each BPEL process by the ODE runtime
+ * @author Mike Edwards
+ *
+ * An explanation of the structure of the ODE deploy file:
+ *
+ * <deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+ * xmlns:tns="http://helloworld"
+ * xmlns:tus="http://tuscany.apache.org/xmlns/sca/1.1">
+ *
+ * <process name="tns:HelloWorld">
+ * <active>true</active>
+ * <provide partnerLink="helloPartnerLink">
+ * <service name="tus:helloPartnerLink" port="HelloWorld"/>
+ * </provide>
+ * <invoke partnerLink="greetingsPartnerLink">
+ * <service name="tus:greetingsPartnerLink" port="Greetings"/>
+ * </invoke>
+ * </process>
+ * </deploy>
+ *
+ * For SCA purposes:
+ *
+ * a) Each partner link in the BPEL process is declared using either a <provide.../>
+ * (for a service) or using a <invoke.../> (for a reference).
+ *
+ * b) Each <provide/> and <invoke/> must use the partnerLink name, as declared in the
+ * BPEL process.
+ *
+ * c) The <provide/> and <invoke/> elements each have a single child <service/> element.
+ * The <service/> elements have name and port attributes. The NAME attribute MUST be set
+ * to the same name as the partnerLink and MUST be prefixed by a prefix which references
+ * the namespace "http://tuscany.apache.org" ("tus" in the example above).
+ * The port attribute can be set to any name (it must be present but it is not actually
+ * used for anything significant).
+ *
+ * When SCA loads a BPEL process to the ODE server, this file is read by the ODE server to
+ * characterize the process. When SCA interacts with ODE at later points - either when a
+ * service is being invoked or the process invokes a reference - it is the service @name
+ * attribute that identifies the service or reference involved.
+ *
+ * @version
+ */
+public class BPELODEDeployFile {
+ private final Log __log = LogFactory.getLog(getClass());
+
+ static final String DEPLOY_ELEMENT_START = "<deploy xmlns=\"http://www.apache.org/ode/schemas/dd/2007/03\"";
+ static final String DEPLOY_ENDELEMENT = "</deploy>";
+ static final String PROCESS_NAMESPACE_DECL = "xmlns:tns=";
+ static final String SERVICE_NAMESPACE = "xmlns:tus=\"http://tuscany.apache.org\"";
+ static final String PROCESS_ELEMENT_START = "<process name=\"tns:";
+ static final String PROCESS_ELEMENT_END = "\">";
+ static final String PROCESS_ENDELEMENT = "</process>";
+ static final String ACTIVE_ELEMENT = "<active>true</active>";
+ static final String PROVIDE_ELEMENT_START = "<provide partnerLink=\"";
+ static final String PROVIDE_ELEMENT_END = "\">";
+ static final String PROVIDE_ENDELEMENT = "</provide>";
+ static final String SERVICE_ELEMENT_START = "<service name=\"tus:";
+ static final String SERVICE_ELEMENT_PORT = "\" port=\"";
+ static final String SERVICE_ELEMENT_END = "Port\"/>";
+ static final String INVOKE_ELEMENT_START = "<invoke partnerLink=\"";
+ static final String INVOKE_ELEMENT_END = "\">";
+ static final String INVOKE_ENDELEMENT = "</invoke>";
+
+ static final String DEPLOY_FILENAME = "deploy.xml";
+
+ private BPELImplementation implementation;
+
+ /**
+ * Constructor - requires a BPELImplementation as a parameter
+ * The ODE deploy.xml file is for this supplied BPELImplementation
+ * @param theImplementation
+ */
+ public BPELODEDeployFile( BPELImplementation theImplementation ) {
+
+ implementation = theImplementation;
+
+ } // end BPELODEDeployFile constructor
+
+ /**
+ * Writes the deploy file into the same directory as the BPEL process file, with the name
+ * "deploy.xml"
+ */
+ public void writeDeployfile() throws IOException {
+
+ File theDirectory = getDirectory();
+
+ File deployFile = new File( theDirectory, DEPLOY_FILENAME );
+ new FileOutputStream( deployFile );
+ //if( !deployFile.canWrite() ) throw new IOException( "Unable to write to deploy file" +
+ // deployFile.getPath() );
+
+ // Create a stream for the data and write the data to the file
+ PrintStream theStream = new PrintStream( new FileOutputStream( deployFile ) );
+ try {
+ constructDeployXML( theStream );
+ if( theStream.checkError() ) throw new IOException();
+ } catch (Exception e) {
+ throw new IOException( "Unable to write data to deploy file" +
+ deployFile.getPath() );
+ } finally {
+ theStream.close();
+ } // end try
+
+ } // end writeDeployFile
+
+ /**
+ * Creates the deploy.xml data and writes it to a supplied PrintStream
+ * @param stream
+ */
+ public void constructDeployXML( PrintStream stream ) {
+
+ // <deploy + namespace...
+ stream.println( DEPLOY_ELEMENT_START );
+ // namespace of the BPEL process
+ QName process = implementation.getProcess();
+ String processNamespace = process.getNamespaceURI();
+ stream.println( PROCESS_NAMESPACE_DECL + "\"" + processNamespace + "\"" );
+ // namespace for the service name elements
+ stream.println( SERVICE_NAMESPACE + ">" );
+
+ // <process> element
+ stream.println( PROCESS_ELEMENT_START + process.getLocalPart() +
+ PROCESS_ELEMENT_END );
+
+ // <active/> element
+ stream.println( ACTIVE_ELEMENT );
+
+ ComponentType componentType = implementation.getComponentType();
+ List<Service> theServices = componentType.getServices();
+ // Loop over the <provide/> elements - one per service
+ for ( Service service : theServices ) {
+ String serviceName = service.getName();
+ // Provide element...
+ stream.println( PROVIDE_ELEMENT_START + serviceName + PROVIDE_ELEMENT_END );
+ // Child service element...
+ stream.println( SERVICE_ELEMENT_START + serviceName +
+ SERVICE_ELEMENT_PORT + serviceName + SERVICE_ELEMENT_END );
+ stream.println( PROVIDE_ENDELEMENT );
+ } // end for
+
+ // Loop over the <invoke/> elements - one per reference
+ List<Reference> theReferences = componentType.getReferences();
+ for ( Reference reference : theReferences ) {
+ String referenceName = reference.getName();
+ stream.println( INVOKE_ELEMENT_START + referenceName + INVOKE_ELEMENT_END );
+ // Child service element...
+ stream.println( SERVICE_ELEMENT_START + referenceName +
+ SERVICE_ELEMENT_PORT + referenceName + SERVICE_ELEMENT_END );
+ stream.println( INVOKE_ENDELEMENT );
+
+ } // end for
+
+ // </process> element
+ stream.println( PROCESS_ENDELEMENT );
+
+ // </deploy>
+ stream.println( DEPLOY_ENDELEMENT );
+
+ } // end constructDeployXML
+
+ /**
+ * Gets the directory containing the BPEL process
+ * @return
+ */
+ private File getDirectory() {
+ File theDir = getBPELFile().getParentFile();
+ return theDir;
+ } // end getDirectory
+
+ /**
+ * Gets the File containing the BPEL process definition
+ * @return - the File object containing the BPEL process
+ */
+ private File getBPELFile() {
+ try {
+ String location = this.implementation.getProcessDefinition().getLocation();
+ URI locationURI;
+ if (location.indexOf('%') != -1) {
+ locationURI = URI.create(location);
+ } else {
+ locationURI = new URI(null, location, null);
+ }
+
+ File theProcess = new File(locationURI);
+ return theProcess;
+ } catch( Exception e ) {
+ if(__log.isDebugEnabled()) {
+ __log.debug("Exception converting BPEL file URL to an URI: " + e );
+ }
+ } // end try
+ return null;
+ } // end getBPELFile
+
+
+
+} // end class BPELODEDeployFile
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/DeploymentWorkspace.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/DeploymentWorkspace.java
new file mode 100644
index 0000000000..8553574aa9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/DeploymentWorkspace.java
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+
+/**
+ *
+ */
+public class DeploymentWorkspace {
+ private static final Logger logger = Logger.getLogger(DeploymentWorkspace.class.getName());
+
+ static final String DEPLOY_FILENAME = "deploy.xml";
+
+ private BPELImplementation implementation;
+ private File workingDir;
+ private File bpelFile;
+
+ /**
+ * @param implementation
+ */
+ public DeploymentWorkspace(BPELImplementation implementation) {
+ super();
+ this.implementation = implementation;
+ this.workingDir = createWorkingDirectory();
+ }
+
+ /**
+ * @param implementation
+ */
+ public DeploymentWorkspace(BPELImplementation implementation, File workingDir) {
+ super();
+ this.implementation = implementation;
+ this.workingDir = workingDir;
+ if (this.workingDir == null) {
+ this.workingDir = createWorkingDirectory();
+ }
+ }
+
+ public File getCBPFile() throws IOException {
+ String name = getBPELFile().getName();
+ int index = name.lastIndexOf('.');
+ if (index != -1) {
+ name = name.substring(0, index);
+ }
+ return new File(workingDir, name + ".cbp");
+ }
+
+ public synchronized File getBPELFile() throws IOException {
+ if (bpelFile != null) {
+ String location = implementation.getProcessDefinition().getLocation();
+ String fileName = implementation.getProcessDefinition().getURI();
+ File file = new File(workingDir, fileName);
+ if (file.isFile()) {
+ bpelFile = file;
+ return file;
+ }
+ URL url = new URL(location);
+ this.bpelFile = copy(url, workingDir, fileName);
+ }
+ return bpelFile;
+ }
+
+ /**
+ * Escape the space in URL string
+ * @param uri
+ * @return
+ */
+ public static URI createURI(String uri) {
+ if (uri == null) {
+ return null;
+ }
+ if (uri.indexOf('%') != -1) {
+ // Avoid double-escaping
+ return URI.create(uri);
+ }
+ int index = uri.indexOf(':');
+ String scheme = null;
+ String ssp = uri;
+ if (index != -1) {
+ scheme = uri.substring(0, index);
+ ssp = uri.substring(index + 1);
+ }
+ try {
+ return new URI(scheme, ssp, null);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Gets the File containing the BPEL process definition
+ * @return - the File object containing the BPEL process
+ */
+ private static File getContainer(String location) {
+ try {
+ File theProcess = null;
+ URI locationURI = createURI(location);
+ String protocol = locationURI.getScheme();
+ if ("file".equals(protocol)) {
+ theProcess = new File(locationURI);
+ } else if ("jar".equals(protocol) || "wsjar".equals(protocol) || "zip".equals(protocol)) {
+ String uri = locationURI.toString();
+ // jar contribution
+ uri = uri.substring(protocol.length() + 1, uri.lastIndexOf("!/"));
+ locationURI = createURI(uri);
+ if ("file".equals(locationURI.getScheme())) {
+ theProcess = new File(locationURI);
+ }
+ }
+ return theProcess;
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Exception converting BPEL file URL to an URI: " + location, e);
+ } // end try
+ return null;
+ } // end getBPELFile
+
+ /**
+ * Gets the directory containing the BPEL process
+ * @return
+ */
+ static File getDirectory(String location) {
+ File file = getContainer(location);
+ if (file == null) {
+ return null;
+ }
+ File theDir = file.getParentFile();
+ return theDir;
+ } // end getDirectory
+
+ public File getDeployFile() {
+ return new File(workingDir, DEPLOY_FILENAME);
+ }
+
+ private static String getSystemProperty(final String name) {
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(name);
+ }
+ });
+ }
+
+ private File createWorkingDirectory() {
+ String tmpDir = getSystemProperty("java.io.tmpdir");
+ File root = new File(tmpDir);
+ // Add user name as the prefix. For multiple users on the same Lunix,
+ // there will be permission issue if one user creates the .tuscany folder
+ // first under /tmp with no write permission for others.
+ String userName = getSystemProperty("user.name");
+ if (userName != null) {
+ root = new File(root, userName);
+ }
+ root = new File(root, ".tuscany/bpel/" + UUID.randomUUID().toString());
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("BPEL working directory: " + root);
+ }
+ return root;
+ }
+
+ public static File copy(URL url, File directory, String fileName) throws IOException {
+ File file = new File(directory, fileName);
+ file.getParentFile().mkdirs();
+ FileOutputStream os = new FileOutputStream(file);
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ InputStream is = connection.getInputStream();
+ byte[] buf = new byte[8192];
+ while (true) {
+ int size = is.read(buf);
+ if (size < 0)
+ break;
+ os.write(buf, 0, size);
+ }
+ is.close();
+ os.close();
+ return file;
+ }
+
+ private static boolean deleteFiles(File file) {
+ boolean result = true;
+ if (file.isFile()) {
+ if (!file.delete()) {
+ result = false;
+ }
+ } else if (file.isDirectory()) {
+ for (File f : file.listFiles()) {
+ if (!deleteFiles(f)) {
+ result = false;
+ }
+ }
+ if (!file.delete()) {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ public boolean delete() {
+ return deleteFiles(workingDir);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java
new file mode 100644
index 0000000000..939c33c21c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java
@@ -0,0 +1,563 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import javax.transaction.TransactionManager;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.dao.BpelDAOConnectionFactoryJDBC;
+import org.apache.ode.bpel.engine.BpelServerImpl;
+import org.apache.ode.bpel.engine.CountLRUDehydrationPolicy;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.CorrelationMatchEvent;
+import org.apache.ode.bpel.evt.NewProcessInstanceEvent;
+import org.apache.ode.bpel.evt.ProcessMessageExchangeEvent;
+import org.apache.ode.bpel.iapi.BpelEventListener;
+import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl;
+import org.apache.ode.il.config.OdeConfigProperties;
+import org.apache.ode.il.dbutil.Database;
+import org.apache.ode.scheduler.simple.JdbcDelegate;
+import org.apache.ode.scheduler.simple.SimpleScheduler;
+import org.apache.ode.utils.GUID;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.eclipse.core.runtime.FileLocator;
+
+
+
+/**
+ * Embedded ODE process server
+ *
+ * @version $Rev$ $Date$
+ */
+public class EmbeddedODEServer {
+ private static final String TUSCANY_IMPL_BPEL_DBLOCATION = "TUSCANY_IMPL_BPEL_DBLOCATION";
+
+ protected final Log __log = LogFactory.getLog(getClass());
+
+ private boolean _initialized;
+
+ private OdeConfigProperties _config;
+
+ private TransactionManager _txMgr;
+
+ private Database _db;
+
+ private File _workRoot;
+
+ private BpelDAOConnectionFactoryJDBC _daoCF;
+
+ private BpelServerImpl _bpelServer;
+
+ private Scheduler _scheduler;
+
+ protected ExecutorService _executorService;
+
+ private Map<QName, RuntimeComponent> tuscanyRuntimeComponents = new ConcurrentHashMap<QName, RuntimeComponent>();
+
+ private Map<String, Long> mexToProcessMap = new ConcurrentHashMap<String, Long>();
+
+ private Map<Long, Map<String, EndpointReference>> callbackMap = new ConcurrentHashMap<Long, Map<String, EndpointReference>>();
+
+ private final Lock metadataLock = new ReentrantLock();
+ private final Condition mexAdded = metadataLock.newCondition();
+ private final Condition callbackAdded = metadataLock.newCondition();
+
+ public EmbeddedODEServer(TransactionManager txMgr) {
+ _txMgr = txMgr;
+ }
+
+ public void init() throws ODEInitializationException {
+
+ Properties p = System.getProperties();
+ p.put("derby.system.home", "target");
+
+ Properties confProps = new Properties();
+ confProps.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=false)");
+
+ _config = new OdeConfigProperties(confProps, "ode-sca");
+
+ // Setting work root as the directory containing our database
+ try {
+ _workRoot = getDatabaseLocationAsFile();
+ } catch (URISyntaxException e) {
+ throw new ODEInitializationException(e);
+ }
+
+ initTxMgr();
+ initPersistence();
+ initBpelServer();
+
+ try {
+ _bpelServer.start();
+ } catch (Exception ex) {
+ String errmsg = "An error occured during the ODE BPEL server startup.";
+ __log.error(errmsg, ex);
+ throw new ODEInitializationException(errmsg, ex);
+ }
+
+ // Start ODE scheduler
+ _scheduler.start();
+
+ __log.info("ODE BPEL server started.");
+ _initialized = true;
+
+ } // end method init()
+
+ /**
+ * Gets the location of the database used for the ODE BPEL engine as a File object for
+ * the directory containing the database
+ * @return
+ * @throws ODEInitializationException
+ * @throws URISyntaxException
+ */
+ private File getDatabaseLocationAsFile() throws ODEInitializationException, URISyntaxException {
+ File locationFile = null;
+ URL dbLocation = null;
+
+ // An environment variable to set the path to the DB
+ String dbFile = System.getenv(TUSCANY_IMPL_BPEL_DBLOCATION);
+ if( dbFile != null ) {
+ try {
+ locationFile = new File(dbFile).getParentFile();
+ } catch (Exception e ) {
+ System.out.println("Environment variable " + TUSCANY_IMPL_BPEL_DBLOCATION + " has the wrong format: " + dbFile);
+ System.out.println("Exception is: " + e.getClass().toString() + " " + e.getMessage());
+ } // end try
+ } else {
+ dbLocation = getClass().getClassLoader().getResource("jpadb");
+ if (dbLocation == null) {
+ throw new ODEInitializationException("Couldn't find database in the classpath:" +
+ " try setting the " + TUSCANY_IMPL_BPEL_DBLOCATION + " environment variable");
+ }
+ // Handle OSGI bundle case
+ if( dbLocation.getProtocol() == "bundleresource" ) {
+ try {
+ dbLocation = FileLocator.toFileURL( dbLocation );
+ } catch (Exception ce ) {
+ throw new ODEInitializationException("Couldn't find database in the OSGi bundle");
+ } // end try
+ } // end if
+ locationFile = new File(dbLocation.toURI()).getParentFile();
+ } // end if
+
+ return locationFile;
+ } // end method getDatabaseLocationAsFile
+
+ private void initTxMgr() {
+ if(_txMgr == null) {
+ try {
+ GeronimoTxFactory txFactory = new GeronimoTxFactory();
+ _txMgr = txFactory.getTransactionManager();
+ } catch (Exception e) {
+ __log.fatal("Couldn't initialize a transaction manager using Geronimo's transaction factory.", e);
+ throw new ODEInitializationException("Couldn't initialize a transaction manager using " + "Geronimo's transaction factory.", e);
+ }
+ }
+ }
+
+ private void initPersistence() {
+ _db = new Database(_config);
+ _db.setTransactionManager(_txMgr);
+ _db.setWorkRoot(_workRoot);
+
+ try {
+ _db.start();
+ _daoCF = _db.createDaoCF();
+ } catch (Exception ex) {
+ String errmsg = "Error while configuring ODE persistence.";
+ __log.error(errmsg, ex);
+ throw new ODEInitializationException(errmsg, ex);
+ }
+ }
+
+ private void initBpelServer() {
+ if (__log.isDebugEnabled()) {
+ __log.debug("ODE initializing");
+ }
+ ThreadFactory threadFactory = new ThreadFactory() {
+ int threadNumber = 0;
+ public Thread newThread(Runnable r) {
+ threadNumber += 1;
+ Thread t = new Thread(r, "ODEServer-"+threadNumber);
+ t.setDaemon(true);
+ return t;
+ }
+ };
+
+ _executorService = Executors.newCachedThreadPool(threadFactory);
+
+ // executor service for long running bulk transactions
+ ExecutorService _polledRunnableExecutorService = Executors.newCachedThreadPool(new ThreadFactory() {
+ int threadNumber = 0;
+ public Thread newThread(Runnable r) {
+ threadNumber += 1;
+ Thread t = new Thread(r, "PolledRunnable-"+threadNumber);
+ t.setDaemon(true);
+ return t;
+ }
+ });
+
+ _bpelServer = new BpelServerImpl();
+ _scheduler = createScheduler();
+ _scheduler.setJobProcessor(_bpelServer);
+
+ BpelServerImpl.PolledRunnableProcessor polledRunnableProcessor = new BpelServerImpl.PolledRunnableProcessor();
+ polledRunnableProcessor.setPolledRunnableExecutorService(_polledRunnableExecutorService);
+ polledRunnableProcessor.setContexts(_bpelServer.getContexts());
+ //_scheduler.setPolledRunnableProcesser(polledRunnableProcessor);
+
+ _bpelServer.setDaoConnectionFactory(_daoCF);
+ _bpelServer.setInMemDaoConnectionFactory(new BpelDAOConnectionFactoryImpl(_scheduler));
+
+ _bpelServer.setEndpointReferenceContext( new ODEEprContext() );
+ _bpelServer.setMessageExchangeContext(new ODEMessageExchangeContext(this));
+ _bpelServer.setBindingContext(new ODEBindingContext());
+ _bpelServer.setScheduler(_scheduler);
+ if (_config.isDehydrationEnabled()) {
+ CountLRUDehydrationPolicy dehy = new CountLRUDehydrationPolicy();
+ dehy.setProcessMaxAge(_config.getDehydrationMaximumAge());
+ dehy.setProcessMaxCount(_config.getDehydrationMaximumCount());
+ _bpelServer.setDehydrationPolicy(dehy);
+ }
+
+ _bpelServer.setConfigProperties(_config.getProperties());
+ _bpelServer.init();
+ _bpelServer.setInstanceThrottledMaximumCount(_config.getInstanceThrottledMaximumCount());
+ _bpelServer.setProcessThrottledMaximumCount(_config.getProcessThrottledMaximumCount());
+ _bpelServer.setProcessThrottledMaximumSize(_config.getProcessThrottledMaximumSize());
+ _bpelServer.setHydrationLazy(_config.isHydrationLazy());
+ _bpelServer.setHydrationLazyMinimumSize(_config.getHydrationLazyMinimumSize());
+
+ // Register event listener on the BPEL server
+ _bpelServer.registerBpelEventListener( new ODEEventListener( this, _bpelServer) );
+ } // end method initBpelLServer
+
+ public void stop() throws ODEShutdownException {
+ if(_bpelServer != null) {
+ try {
+ __log.debug("Stopping BPEL Embedded server");
+ _bpelServer.shutdown();
+ _bpelServer = null;
+ } catch (Exception ex) {
+ __log.debug("Error stopping BPEL server");
+ }
+ }
+
+ if(_scheduler != null) {
+ try {
+ __log.debug("Stopping scheduler");
+ _scheduler.shutdown();
+ _scheduler = null;
+ } catch (Exception ex) {
+ __log.debug("Error stopping scheduler");
+ }
+ }
+
+ if(_daoCF != null) {
+ try {
+ __log.debug("Stopping DAO");
+ _daoCF.shutdown();
+ _daoCF = null;
+ } catch (Exception ex) {
+ __log.debug("Error stopping DAO");
+ }
+ }
+
+ if(_db != null) {
+ try {
+ __log.debug("Stopping DB");
+ _db.shutdown();
+ _db = null;
+ } catch (Exception ex) {
+ __log.debug("Error stopping DB");
+ }
+ }
+
+ if(_txMgr != null) {
+ try {
+ __log.debug("Stopping Transaction Manager");
+ _txMgr = null;
+ } catch (Exception ex) {
+ __log.debug("Error stopping Transaction Manager");
+ }
+ }
+ }
+
+ protected Scheduler createScheduler() {
+ Properties odeProperties = new Properties();
+ // TODO Find correct values for these properties - MJE 22/06/2009
+ odeProperties.put("ode.scheduler.queueLength", "100" );
+ odeProperties.put("ode.scheduler.immediateInterval", "30000" );
+ odeProperties.put("ode.scheduler.nearFutureInterval", "600000" );
+ odeProperties.put("ode.scheduler.staleInterval", "100000" );
+
+ SimpleScheduler scheduler = new SimpleScheduler(new GUID().toString(),
+ new JdbcDelegate(_db.getDataSource()),
+ odeProperties );
+ scheduler.setExecutorService(_executorService);
+ scheduler.setTransactionManager(_txMgr);
+
+ return scheduler;
+ }
+
+ public boolean isInitialized() {
+ return _initialized;
+ }
+
+ public BpelServerImpl getBpelServer() {
+ return _bpelServer;
+ }
+
+ public Scheduler getScheduler() {
+ return _scheduler;
+ }
+
+ public ExecutorService getExecutor() {
+ return _executorService;
+ }
+
+ /**
+ * Deploy the BPEL process implementation to the ODE Engine
+ * @param d - ODEDeployment structure
+ * @param implementation - the BPEL Implementation
+ * @param component - the SCA component which uses the implementation
+ */
+ public void deploy(ODEDeployment d, BPELImplementation implementation, RuntimeComponent component ) {
+ try {
+ TuscanyProcessConfImpl processConf = new TuscanyProcessConfImpl( implementation, component );
+ _bpelServer.register(processConf);
+ d.setProcessConf(processConf);
+ __log.debug("Completed calling new Process deployment code...");
+ } catch (Exception ex) {
+ String errMsg = ">>> DEPLOY: Unexpected exception during deploy of BPEL. /n Component = "
+ + component.getName()
+ + " implementation = "
+ + implementation.getProcess()
+ + ex.getMessage();
+ __log.debug(errMsg, ex);
+ throw new ODEDeploymentException(errMsg,ex);
+ }
+ }
+
+ /**
+ * Undeploy the BPEL process implementation from the ODE Engine
+ * @param d - ODEDeployment structure
+ */
+ public void undeploy(ODEDeployment d) {
+ TuscanyProcessConfImpl processConf = d.getProcessConf();
+ if( processConf != null ) {
+ processConf.stop();
+ } // end if
+ } // end method undeploy
+
+ public void registerTuscanyRuntimeComponent(QName processName,RuntimeComponent componentContext) {
+ tuscanyRuntimeComponents.put(processName, componentContext);
+ }
+
+ public RuntimeComponent getTuscanyRuntimeComponent(QName processName) {
+ return tuscanyRuntimeComponents.get(processName);
+ }
+
+ /**
+ * Records a connection between a MessageExchange ID and a Process Instance ID
+ * @param mexID
+ * @param processID
+ */
+ public void addMexToProcessIDLink( String mexID, Long processID ) {
+ //System.out.println("Add mapping Mex - ProcessID = " + mexID + " " + processID.toString());
+ if( mexID == null ) {
+ //System.out.println("Mex ID is null !");
+ return;
+ } // end if
+ metadataLock.lock();
+ try {
+ mexToProcessMap.put(mexID, processID);
+ mexAdded.signalAll();
+ return;
+ } catch (Exception e) {
+ return;
+ } finally {
+ metadataLock.unlock();
+ } // end try
+ } // end method addMexToProcessIDLink( mexID, processID )
+
+ /**
+ * Connects from a MessageExchangeID to a Process Instance ID
+ * @param mexID - the MessageExchange ID
+ * @return - a Long which is the Process Instance ID
+ */
+ public Long getProcessIDFromMex( String mexID ) {
+ //System.out.println("Get mapping for Mex: " + mexID);
+ metadataLock.lock();
+ try {
+ Long processID = mexToProcessMap.get(mexID);
+ while( processID == null ) {
+ mexAdded.await();
+ processID = mexToProcessMap.get(mexID);
+ } // end while
+ return processID;
+ } catch (Exception e) {
+ return null;
+ } finally {
+ metadataLock.unlock();
+ } // end try
+
+ } // end method getProcessIDFromMex
+
+ /**
+ * Remove the connection between a Message Exchange ID and a Process Instance ID
+ * @param mexID - the Message Exchange ID
+ */
+ public void removeMexToProcessIDLink( String mexID ) {
+ mexToProcessMap.remove(mexID);
+ } // end method removeMexToProcessIDLink
+
+ /**
+ * Stores the metadata for a Callback
+ * @param processID - Process ID of the BPEL Process Instance for which this callback applies
+ * @param serviceName - the name of the service which has the callback
+ * @param callbackEndpoint - a Tuscany Endpoint which is the target of the callback
+ */
+ public void saveCallbackMetadata( Long processID, String serviceName, EndpointReference callbackEPR ) {
+ //System.out.println("Save callback metadata: ProcessID " + processID.toString() + " service: " + serviceName);
+ metadataLock.lock();
+ try {
+ Map<String, EndpointReference> processMap = callbackMap.get(processID);
+ if( processMap == null ) {
+ processMap = new ConcurrentHashMap<String, EndpointReference>();
+ callbackMap.put(processID, processMap);
+ } // end if
+ // Put the mapping of service name to callback endpoint - note that this overwrites any
+ // previous mapping for the same service name
+ processMap.put(serviceName, callbackEPR);
+ callbackAdded.signalAll();
+ } finally {
+ metadataLock.unlock();
+ } // end try
+ } // end saveCallbackMetadata
+
+ /**
+ * Get the metadata for a Callback, based on a BPEL Process Instance ID and a Service name
+ * @param processID - the BPEL Process Instance ID
+ * @param serviceName - the service name
+ * @return - and Endpoint which is the Callback endpoint for the service for this process instance.
+ * Returns null if there is no callback metadata for this service.
+ */
+ public EndpointReference getCallbackMetadata( Long processID, String serviceName ) {
+ EndpointReference theEPR;
+ //System.out.println("Get callback metadata: ProcessID " + processID.toString() + " service: " + serviceName);
+
+ metadataLock.lock();
+ try {
+ while(true) {
+ Map<String, EndpointReference> processMap = callbackMap.get(processID);
+ theEPR = processMap.get(serviceName);
+ if( theEPR != null ) return theEPR;
+ callbackAdded.await();
+ } // end while
+ } catch (Exception e) {
+ return null;
+ } finally {
+ metadataLock.unlock();
+ } // end try
+ } // end method getCallbackMetadata
+
+ /**
+ * Removes the metadata for a Callback
+ * @param processID - the Process Instance ID of the process instance to which the callback metadata applies
+ * @param serviceName - the service name for the service which has a callback - can be NULL, in which case ALL
+ * callback metadata for the process instance is removed
+ */
+ public void removeCallbackMetadata( Long processID, String serviceName ) {
+
+ if( serviceName == null ) {
+ callbackMap.remove(processID);
+ } else {
+ Map<String, EndpointReference> processMap = callbackMap.get(processID);
+ processMap.remove(serviceName);
+ } // end if
+
+ } // end method removeCallbackMetadata
+
+ private class ODEEventListener implements BpelEventListener {
+
+ private EmbeddedODEServer ODEServer;
+ private BpelServerImpl bpelServer;
+
+ ODEEventListener( EmbeddedODEServer ODEServer, BpelServerImpl bpelServer ) {
+ this.ODEServer = ODEServer;
+ this.bpelServer = bpelServer;
+ } // end constructor
+
+ /**
+ * Method which receives events from the ODE Engine as processing proceeds
+ */
+ public void onEvent(BpelEvent bpelEvent) {
+ if( bpelEvent instanceof ProcessMessageExchangeEvent ||
+ bpelEvent instanceof NewProcessInstanceEvent ||
+ bpelEvent instanceof CorrelationMatchEvent ) {
+ handleProcMexEvent( (ProcessMessageExchangeEvent) bpelEvent );
+ return;
+ } // end if
+
+ } // end method onEvent
+
+ /**
+ * Handle a ProcessMessageExchangeEvent
+ * - the important aspect of this event is that it establishes a connection between a MessageExchange object
+ * and the BPEL Process instance to which it relates.
+ * @param bpelEvent - the ProcessMessageExchangeEvent
+ */
+ private void handleProcMexEvent( ProcessMessageExchangeEvent bpelEvent) {
+ // Extract the message ID and the process instance ID - it is the connection between these
+ // that is vital to know
+ String mexID = bpelEvent.getMessageExchangeId();
+ Long processID = bpelEvent.getProcessInstanceId();
+ ODEServer.addMexToProcessIDLink( mexID, processID );
+ } // end method handleProcMexEvent
+
+ public void shutdown() {
+ // Intentionally left blank
+ }
+
+ public void startup(Properties configProperties) {
+ // Intentionally left blank
+ }
+
+ } // end Class BPELEventListener
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/GeronimoTxFactory.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/GeronimoTxFactory.java
new file mode 100644
index 0000000000..11af0f8b50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/GeronimoTxFactory.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.bpel.ode;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Geronimo transaction factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class GeronimoTxFactory {
+ private static final Log __log = LogFactory.getLog(GeronimoTxFactory.class);
+
+ /* Public no-arg constructor is required */
+ public GeronimoTxFactory() {
+ }
+
+ public TransactionManager getTransactionManager() {
+ __log.info("Using embedded Geronimo transaction manager");
+ try {
+ Object obj = new org.apache.geronimo.transaction.manager.GeronimoTransactionManager();
+ return (TransactionManager) obj;
+ } catch (Exception except) {
+ throw new IllegalStateException("Unable to instantiate Geronimo Transaction Manager", except);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java
new file mode 100644
index 0000000000..8e339812cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.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.sca.implementation.bpel.ode;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.BindingContext;
+import org.apache.ode.bpel.iapi.Endpoint;
+import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.bpel.iapi.PartnerRoleChannel;
+
+/**
+ * Binding Context information
+ *
+ * @version $Rev$ $Date$
+ */
+public class ODEBindingContext implements BindingContext {
+ protected final Log __log = LogFactory.getLog(getClass());
+
+ public ODEBindingContext() {
+
+ }
+
+ public EndpointReference activateMyRoleEndpoint(QName pid, Endpoint endpoint) {
+ // This will be needed when we support callBacks
+ if (__log.isDebugEnabled()) {
+ __log.debug("Activating MyRole Endpoint : " + pid + " - " + endpoint.serviceName);
+ }
+
+ QName processName = getProcessName(pid);
+
+ return new TuscanyEPR(processName, endpoint);
+ }
+
+ public void deactivateMyRoleEndpoint(Endpoint endpoint) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("Deactivate MyRole Endpoint : " + endpoint.serviceName);
+ }
+
+ }
+
+ public PartnerRoleChannel createPartnerRoleChannel(QName pid, PortType portType, Endpoint endpoint) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("Create PartnerRole channel : " + pid + " - " + portType.getQName() + " - "+ endpoint.serviceName);
+ }
+
+ QName processName = getProcessName(pid);
+ return new TuscanyPRC(processName, pid, portType, endpoint);
+ }
+
+ /**
+ * Helper method to retrieve the BPEL process name from a processID (where processID have version concatenated to it)
+ * @param pid
+ * @return QName the BPEL process name
+ */
+ private static QName getProcessName(QName pid) {
+ String processName = pid.getLocalPart().substring(0, pid.getLocalPart().lastIndexOf("-"));
+ return new QName(pid.getNamespaceURI(), processName);
+ }
+
+ /**
+ * Calculate the size of the service that this endpoint references.
+ * @param epr the endpoint reference for the service
+ * @returns the size of the service
+ */
+ public long calculateSizeofService(EndpointReference epr) {
+ // TODO It is not at all clear from the ODE code what "size" means
+ // eg number of service operations? size of the process in bytes?
+ // So for the present, return a fixed random value...
+ return 10000;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeployment.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeployment.java
new file mode 100644
index 0000000000..0eedd5d0e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeployment.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.bpel.ode;
+
+import java.io.File;
+
+/**
+ * Deployment information
+ *
+ * @version $Rev$ $Date$
+ */
+public class ODEDeployment {
+ /** The directory containing the deploy.xml and artifacts. */
+ public File deployDir;
+
+ // The Tuscany version of the ODE Process Conf implementation
+ private TuscanyProcessConfImpl conf;
+
+ /** If non-null the type of exception we expect to get when we deploy. */
+ public Class<?> expectedException = null;
+
+ public ODEDeployment(File deployDir) {
+ this.deployDir = deployDir;
+ }
+
+ @Override
+ public String toString() {
+ return "Deployment#" + deployDir;
+ }
+
+ public void setProcessConf( TuscanyProcessConfImpl conf ) {
+ this.conf = conf;
+ }
+
+ public TuscanyProcessConfImpl getProcessConf() {
+ return conf;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeploymentException.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeploymentException.java
new file mode 100644
index 0000000000..b03f69d9aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeploymentException.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.implementation.bpel.ode;
+
+/**
+ * Thrown when ODE failed to shutdown.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ODEDeploymentException extends RuntimeException {
+ private static final long serialVersionUID = -2869674556330744215L;
+
+ public ODEDeploymentException(Throwable cause) {
+ super(cause);
+ }
+
+ public ODEDeploymentException(String message) {
+ super(message);
+ }
+
+ public ODEDeploymentException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEndpointReference.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEndpointReference.java
new file mode 100644
index 0000000000..700443d9b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEndpointReference.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode;
+
+import org.apache.ode.bpel.iapi.Endpoint;
+import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.tuscany.sca.assembly.Base;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Tuscany implementation of the ODE EndpointReference interface
+ *
+ */
+public class ODEEndpointReference implements EndpointReference {
+
+
+ private Document doc = DOMUtils.newDocument();
+ private Element serviceref;
+
+ /**
+ * Private constructor for the EndpointReference
+ */
+ private ODEEndpointReference() {
+ super();
+ } // end ODEEndpointReference()
+
+ /**
+ * Add a new <service-ref/> element to the EndpointReference
+ */
+ private void addServiceRef() {
+ serviceref = doc.createElementNS(EndpointReference.SERVICE_REF_QNAME.getNamespaceURI(),
+ EndpointReference.SERVICE_REF_QNAME.getLocalPart());
+ doc.appendChild(serviceref);
+ } // end method addServiceRef()
+
+ /**
+ * Create an EndpointReference from an Endpoint object
+ * @param anEndpoint - the endpoint object
+ */
+ public ODEEndpointReference( Endpoint anEndpoint ) {
+ this();
+ addServiceRef();
+ // If there is an endpoint for this reference (ie the reference is wired)
+ // then add an element to indicate this
+ String eprCount = anEndpoint.portName;
+ if( !"0".equals(eprCount) ) {
+ Element eprElement = doc.createElementNS( Base.SCA11_TUSCANY_NS, "EPR");
+ serviceref.appendChild(eprElement);
+ } // end if
+ return;
+ } // end
+
+ /**
+ * Create a new EndpointReference from an existing endpointElement, which is assumed
+ * to be of the form:
+ * <sref:service-ref>
+ * <EPR/>
+ * </sref:service-ref>
+ *
+ * @param endpointElement the endpointElement
+ */
+ public ODEEndpointReference( Element endpointElement ) {
+ this();
+ if( endpointElement != null ) {
+ // import the service-ref element into this EndpointReference, if the
+ // root element is a <sref:service-ref/>
+ if( endpointElement.getLocalName().equals("service-ref") ) {
+ doc.appendChild( doc.importNode(endpointElement, true) );
+ } // end if
+ } // end if
+ return;
+ } // end
+
+ public Document toXML() {
+ return doc;
+ } // end toXML()
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEprContext.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEprContext.java
new file mode 100644
index 0000000000..972f77ad65
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEprContext.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.sca.implementation.bpel.ode;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.bpel.iapi.EndpointReferenceContext;
+import org.w3c.dom.Element;
+
+/**
+ * Implementation of the ODE EndpointReferenceContext interface, used by the ODE BPEL Engine
+ * to handle conversions of EndpointReferences at runtime.
+ *
+ * An ODE Endpoint reference relates to SCA Reference EndpointReferences (pointers to target
+ * services) and to BPEL PartnerLink elements and any associated BPEL process variables with
+ * type set to element="sref:service-ref"
+ *
+ */
+public class ODEEprContext implements EndpointReferenceContext {
+
+ /**
+ * Converts an endpoint reference from its XML representation to another
+ * type of endpoint reference.
+ *
+ * @param targetType
+ * @param sourceEndpoint
+ * @return converted EndpointReference, being of targetType
+ */
+ public EndpointReference convertEndpoint( QName targetType,
+ Element sourceEndpoint) {
+ // For the present, Tuscany only has one type of EndpointReference, so that the
+ // targetType parameter is of no significance.
+ return new ODEEndpointReference( sourceEndpoint );
+ } // end method convertEndpoint
+
+ public Map getConfigLookup(EndpointReference epr) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Resolve an end-point reference from its XML representation. The
+ * nature of the representation is determined by the integration
+ * layer. The BPEL engine uses this method to reconstruct
+ * {@link EndpointReference} objects that have been persisted in the
+ * database via {@link EndpointReference#toXML(javax.xml.transform.Result)}
+ * method.
+ *
+ * @param XML representation of the EPR
+ * @return reconstituted EPR object {@link EndpointReference}
+ */
+ public EndpointReference resolveEndpointReference(Element epr) {
+ return new ODEEndpointReference( epr );
+ } // end method resolveEndpointReference
+
+} // end class ODEEprContext
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java
new file mode 100644
index 0000000000..d2dbd4880d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java
@@ -0,0 +1,370 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode;
+
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Helper Class to handle invocation to Tuscany Component References
+ *
+ * @version $Rev$ $Date$
+ */
+public class ODEExternalService {
+ protected final Log __log = LogFactory.getLog(getClass());
+
+ private EmbeddedODEServer _server;
+ private Scheduler _sched;
+
+ public ODEExternalService(EmbeddedODEServer server) {
+ this._server = server;
+ this._sched = _server.getScheduler();
+ }
+
+ public void invoke(final PartnerRoleMessageExchange partnerRoleMessageExchange) {
+ boolean isTwoWay =
+ partnerRoleMessageExchange.getMessageExchangePattern() == org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern.REQUEST_RESPONSE;
+
+ if (isTwoWay) {
+ // Defer the invoke until the transaction commits.
+ _sched.registerSynchronizer(new Scheduler.Synchronizer() {
+ public void beforeCompletion() {
+
+ }
+
+ public void afterCompletion(boolean success) {
+ // If the TX is rolled back, then we don't send the request.
+ if (!success) return;
+
+ // The invocation must happen in a separate thread, holding on the afterCompletion
+ // blocks other operations that could have been listed there as well.
+ _server.getExecutor().submit(new Callable<Object>() {
+ public Object call() throws Exception {
+ try {
+ // do execution
+ if(! (partnerRoleMessageExchange.getChannel() instanceof TuscanyPRC)) {
+ throw new IllegalArgumentException("Channel should be an instance of TuscanyPRC");
+ }
+
+ TuscanyPRC channel = (TuscanyPRC) partnerRoleMessageExchange.getChannel();
+ RuntimeComponent tuscanyRuntimeComponent = _server.getTuscanyRuntimeComponent(channel.getProcessName());
+
+ // Fetching the reference based on the data held in the PRC / Endpoint
+ String refName = channel.getEndpoint().serviceName.getLocalPart();
+ RuntimeComponentReference runtimeComponentReference = getReferenceByName( tuscanyRuntimeComponent, refName );
+ RuntimeEndpointReference epr = getEndpointReference( runtimeComponentReference, partnerRoleMessageExchange );
+ // convert operations
+ Operation operation =
+ findOperation(partnerRoleMessageExchange.getOperation().getName(), epr);
+
+ /*
+ This is how a request looks like (payload is wrapped with extra info)
+ <?xml version="1.0" encoding="UTF-8"?>
+ <message>
+ <parameters>
+ <getGreetings xmlns="http://greetings">
+ <message xmlns="http://helloworld">Luciano</message>
+ </getGreetings>
+ </parameters>
+ </message>
+ */
+ Element msg = partnerRoleMessageExchange.getRequest().getMessage();
+ if (msg != null) {
+
+ if(__log.isDebugEnabled()) {
+ String xml = DOMUtils.domToString(msg);
+ String payload = DOMUtils.domToString(getPayload(partnerRoleMessageExchange.getRequest()));
+ __log.debug("Starting invocation of SCA Reference");
+ __log.debug(">>> Original message: " + xml);
+ __log.debug(">>> Payload: " + payload);
+ } // end if
+
+ Object[] args = new Object[] {getPayload(partnerRoleMessageExchange.getRequest())};
+
+ Object result = null;
+ boolean success = false;
+
+ try {
+ result = epr.invoke(operation, args);
+ success = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ partnerRoleMessageExchange.replyWithFailure(MessageExchange.FailureType.OTHER,
+ e.getMessage(),
+ null);
+ } // end try
+
+ if(__log.isDebugEnabled()) {
+ __log.debug("SCA Reference invocation finished");
+ __log.debug(">>> Result : " + DOMUtils.domToString((Element)result));
+ } // end if
+
+ if (!success) { return null; }
+
+ // two way invocation
+ // process results based on type of message invocation
+ replyTwoWayInvocation(partnerRoleMessageExchange.getMessageExchangeId(),
+ operation,
+ (Element)result);
+ } // end if
+
+ } catch (Throwable t) {
+ // some error
+ String errmsg = "Error sending message (mex=" + partnerRoleMessageExchange + "): " + t.getMessage();
+ __log.error(errmsg, t);
+ /*replyWithFailure(partnerRoleMessageExchange.getMessageExchangeId(),
+ MessageExchange.FailureType.COMMUNICATION_ERROR,
+ errmsg,
+ null);*/
+ }
+ return null;
+ }
+ });
+
+ }
+ });
+ partnerRoleMessageExchange.replyAsync();
+
+ } else {
+ /** one-way case * */
+ _server.getExecutor().submit(new Callable<Object>() {
+ public Object call() throws Exception {
+ // do reply
+ // operationClient.execute(false);
+ return null;
+ }
+ });
+ partnerRoleMessageExchange.replyOneWayOk();
+ }
+ }
+
+ /**
+ * Gets a RuntimeComponentReference of a supplied RuntimeComponent by name
+ * @param tuscanyRuntimeComponent - the runtime component
+ * @param name - the name of the reference
+ * @return - the RuntimeComponentReference with the supplied name - null if there is no reference with that name
+ */
+ private RuntimeComponentReference getReferenceByName( RuntimeComponent tuscanyRuntimeComponent, String name ) {
+ if( name == null ) return null;
+ for( ComponentReference reference : tuscanyRuntimeComponent.getReferences() ) {
+ if( name.equals(reference.getName()) ) return (RuntimeComponentReference)reference;
+ } // end for
+ return null;
+ } // end method getReferenceByName
+
+ /**
+ * Get the Runtime Wire for the supplied reference
+ * @param componentReference - the reference
+ * @return - the RuntimeWire - null if it cannot be found
+ */
+ private RuntimeEndpointReference getEndpointReference( RuntimeComponentReference componentReference,
+ PartnerRoleMessageExchange mex) {
+ if( componentReference.isForCallback() ) {
+ // Where there is a callback, it is necessary to create a specialized wire, based on callback information
+ // present on the forward call
+
+ // Get the callbackEPR for the callback using the BPEL Process ID and the Reference name
+ // - which is the same name as the service name for a callback
+ Long processID = _server.getProcessIDFromMex(mex.getMessageExchangeId());
+ org.apache.tuscany.sca.assembly.EndpointReference callbackEPR =
+ _server.getCallbackMetadata(processID, componentReference.getName());
+ RuntimeEndpointReference wire = selectCallbackWire( callbackEPR.getTargetEndpoint(), componentReference );
+ wire = clone_bind( componentReference, callbackEPR.getCallbackEndpoint() );
+ return wire;
+ } else {
+ // No callback case...
+ //TODO - fix the x..n multiplicity case, which needs to select the correct ONE of multiple
+ // EndpointReferences here
+ return (RuntimeEndpointReference) componentReference.getEndpointReferences().get(0);
+ } // end if
+ } // end method getEndpointReference
+
+ private RuntimeEndpointReference selectCallbackWire( org.apache.tuscany.sca.assembly.Endpoint endpoint,
+ RuntimeComponentReference componentReference) {
+ // Look for callback binding with same name as service binding
+ if (endpoint == null) {
+ throw new RuntimeException("Destination for forward call is not available");
+ }
+
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ if (epr.getBinding().getName().equals(endpoint.getBinding().getName())) {
+ return (RuntimeEndpointReference) epr;
+ }
+ }
+
+ // if no match, look for callback binding with same type as service binding
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ if (epr.getBinding().getType().equals(endpoint.getBinding().getType())) {
+ return (RuntimeEndpointReference) epr;
+ }
+ }
+
+ // no suitable callback wire was found
+ return null;
+ } // end method selectCallbackWire
+
+ private RuntimeEndpointReference clone_bind(RuntimeComponentReference reference,
+ org.apache.tuscany.sca.assembly.Endpoint callbackEndpoint) {
+
+ try {
+ // clone the callback reference ready to configure it for this callback endpoint
+ RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone();
+ ref.getTargets().clear();
+ ref.getBindings().clear();
+ ref.getEndpointReferences().clear();
+
+ // clone epr
+ EndpointReference callbackEndpointReference = (EndpointReference)reference.getEndpointReferences().get(0).clone();
+ callbackEndpointReference.setReference(ref);
+ callbackEndpointReference.setTargetEndpoint(callbackEndpoint);
+ callbackEndpointReference.setUnresolved(true);
+
+ // The callback endpoint will be resolved when the wire chains are created
+ ref.getEndpointReferences().add(callbackEndpointReference);
+ return (RuntimeEndpointReference) ref.getEndpointReferences().get(0);
+ } catch ( CloneNotSupportedException e ) {
+ return null;
+ } // end try clone_bind
+
+ } // end method
+
+ /**
+ * Find the SCA Reference operation
+ *
+ * @param operationName
+ * @param runtimeComponentReference
+ * @return
+ */
+ private Operation findOperation(String operationName, RuntimeEndpointReference epr) {
+ Operation reseultOperation = null;
+
+ for (Operation operation : epr.getComponentTypeReferenceInterfaceContract().getInterface().getOperations()) {
+ if (operationName.equalsIgnoreCase(operation.getName())) {
+ reseultOperation = operation;
+ break;
+ }
+ }
+ return reseultOperation;
+ }
+
+ /**
+ * Get payload from a given ODEMessage
+ * @param odeMessage - the ODE message
+ * @return the payload of the Message, as a DOM Element
+ */
+ private Element getPayload(Message odeMessage) {
+ Element payload = null;
+
+ // Get the message parts - these correspond to the message parts for the invocation
+ // as defined in the WSDL for the service operation being invoked
+ List<String> parts = odeMessage.getParts();
+ if( parts.size() == 0 ) return null;
+
+ // For the present, just deal with the ** FIRST ** part
+ // TODO Deal with operations that have messages with multiple parts
+ // - that will require returning an array of Elements, one for each part
+ Element part = odeMessage.getPart(parts.get(0));
+
+ // Get the payload which is the First child
+ if (part != null && part.hasChildNodes()) {
+ payload = (Element)part.getFirstChild();
+ }
+
+ return payload;
+ } // end getPayload
+
+
+ private void replyTwoWayInvocation(final String odeMexId, final Operation operation, final Element result) {
+ // ODE MEX needs to be invoked in a TX.
+ try {
+ _server.getScheduler().execIsolatedTransaction(new Callable<Void>() {
+ public Void call() throws Exception {
+ PartnerRoleMessageExchange odeMex = null;
+ try {
+ odeMex = (PartnerRoleMessageExchange)_server.getBpelServer().getEngine().getMessageExchange(odeMexId);
+ if (odeMex != null) {
+ Message response = createResponseMessage(odeMex, operation, (Element)result);
+ odeMex.reply(response);
+ }
+ } catch (Exception ex) {
+ String errmsg = "Unable to process response: " + ex.getMessage();
+ if (odeMex != null) {
+ odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, null);
+ }
+ }
+
+ return null;
+ }
+ });
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ private Message createResponseMessage(PartnerRoleMessageExchange partnerRoleMessageExchange,
+ Operation operation,
+ Element invocationResult) {
+ Document dom = DOMUtils.newDocument();
+
+ String operationName = operation.getName();
+ Part bpelOperationOutputPart =
+ (Part)((WSDLInterface)operation.getInterface()).getPortType().getOperation(operationName, null, null)
+ .getOutput().getMessage().getParts().values().iterator().next();
+
+ Element contentMessage = dom.createElement("message");
+ Element contentPart = dom.createElement(bpelOperationOutputPart.getName());
+
+ contentPart.appendChild(dom.importNode(invocationResult, true));
+ contentMessage.appendChild(contentPart);
+ dom.appendChild(contentMessage);
+
+ if(__log.isDebugEnabled()) {
+ __log.debug("Creating result message:");
+ __log.debug(">>>" + DOMUtils.domToString(dom.getDocumentElement()));
+ }
+
+ QName id = partnerRoleMessageExchange.getOperation().getOutput().getMessage().getQName();
+ Message response = partnerRoleMessageExchange.createMessage(id);
+ response.setMessage(dom.getDocumentElement());
+
+ return response;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEInitializationException.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEInitializationException.java
new file mode 100644
index 0000000000..2fa91e4e86
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEInitializationException.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.implementation.bpel.ode;
+
+/**
+ * Thrown when ODE failed to initialize one if its needed resources.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ODEInitializationException extends RuntimeException {
+ private static final long serialVersionUID = -2869674556330744215L;
+
+ public ODEInitializationException(Throwable cause) {
+ super(cause);
+ }
+
+ public ODEInitializationException(String message) {
+ super(message);
+ }
+
+ public ODEInitializationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java
new file mode 100644
index 0000000000..1ec82390cf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.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.bpel.ode;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.BpelEngineException;
+import org.apache.ode.bpel.iapi.ContextException;
+import org.apache.ode.bpel.iapi.MessageExchangeContext;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+
+/**
+ * Message Exchange Context information
+ *
+ * @version $Rev$ $Date$
+ */
+public class ODEMessageExchangeContext implements MessageExchangeContext {
+ private static final Log __log = LogFactory.getLog(ODEMessageExchangeContext.class);
+
+ private EmbeddedODEServer _server;
+
+ public ODEMessageExchangeContext(EmbeddedODEServer _server) {
+ this._server = _server;
+ }
+
+ public void invokePartner(PartnerRoleMessageExchange partnerRoleMessageExchange) throws ContextException {
+ if (__log.isDebugEnabled()) {
+ __log.debug("Invoking a partner operation: " + partnerRoleMessageExchange.getOperationName());
+ }
+
+ ODEExternalService scaService = new ODEExternalService(_server);
+ scaService.invoke(partnerRoleMessageExchange);
+ }
+
+ public void onAsyncReply(MyRoleMessageExchange myRoleMessageExchange) throws BpelEngineException {
+ if (__log.isDebugEnabled()) {
+ __log.debug("Processing an async reply from service " + myRoleMessageExchange.getServiceName());
+ }
+ }
+ }
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEShutdownException.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEShutdownException.java
new file mode 100644
index 0000000000..a928379ba9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEShutdownException.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.implementation.bpel.ode;
+
+/**
+ * Thrown when ODE failed to shutdown.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ODEShutdownException extends RuntimeException {
+ private static final long serialVersionUID = -2869674556330744215L;
+
+ public ODEShutdownException(Throwable cause) {
+ super(cause);
+ }
+
+ public ODEShutdownException(String message) {
+ super(message);
+ }
+
+ public ODEShutdownException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyEPR.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyEPR.java
new file mode 100644
index 0000000000..deaeaec040
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyEPR.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.iapi.Endpoint;
+import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * This should hold something that makes sense for Tuscany so that the
+ * process has an address that makes sense from the outside world perspective
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyEPR implements EndpointReference {
+ private final Document doc = DOMUtils.newDocument();
+
+ public TuscanyEPR(QName processName, Endpoint endpoint) {
+ Element serviceref = doc.createElementNS(EndpointReference.SERVICE_REF_QNAME.getNamespaceURI(),
+ EndpointReference.SERVICE_REF_QNAME.getLocalPart());
+ serviceref.setNodeValue(endpoint.serviceName + ":" + endpoint.portName);
+ doc.appendChild(serviceref);
+ }
+
+ public Document toXML() {
+ return doc;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyPRC.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyPRC.java
new file mode 100644
index 0000000000..aaa00069f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyPRC.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.bpel.ode;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.iapi.Endpoint;
+import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.bpel.iapi.PartnerRoleChannel;
+
+/**
+ * Tuscany Partner Role Channel for ODE Integration
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyPRC implements PartnerRoleChannel {
+ private final QName processName;
+ private final QName pid;
+ private final Endpoint endpoint;
+
+ public TuscanyPRC(QName processName, QName pid, PortType portType, Endpoint endpoint){
+ this.processName = processName;
+ this.pid = pid;
+ this.endpoint = endpoint;
+ }
+
+ public QName getProcessName() {
+ return this.processName;
+ }
+
+ public Endpoint getEndpoint() {
+ return this.endpoint;
+ }
+
+ public void close() {
+
+ }
+
+ public EndpointReference getInitialEndpointReference() {
+
+ return new ODEEndpointReference( this.endpoint );
+ } // end method getInitialEndpointReference
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java
new file mode 100644
index 0000000000..2c904a37f8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java
@@ -0,0 +1,823 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.compiler.BpelC;
+import org.apache.ode.bpel.evt.BpelEvent.TYPE;
+import org.apache.ode.bpel.iapi.Endpoint;
+import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.bpel.iapi.ProcessState;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A Tuscany implementation of the ODE Process Conf
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyProcessConfImpl implements ProcessConf {
+ private final Log __log = LogFactory.getLog(getClass());
+
+ private BPELImplementation implementation;
+ private RuntimeComponent component;
+ private Map<String, Endpoint> invokeEndpoints = null;
+ private Map<String, Endpoint> provideEndpoints = null;
+ private Map<QName, Node> properties = null;
+ private ProcessState processState;
+ private Date deployDate;
+
+ private File theBPELFile;
+ // Marks whether the BPEL file was rewritten (eg for initializer statements)
+ private boolean rewritten = false;
+
+ private final SimpleTypeMapper mapper = new SimpleTypeMapperImpl();
+ private final String TUSCANY_NAMESPACE = Base.SCA11_TUSCANY_NS;
+
+ /**
+ * Constructor for the ProcessConf implementation
+ * @param theImplementation the BPEL implementation for which this is the ProcessConf
+ * @param component - the SCA component which uses the implementation
+ */
+ public TuscanyProcessConfImpl( BPELImplementation theImplementation, RuntimeComponent component ) {
+ //System.out.println("New TuscanyProcessConfImpl...");
+ this.implementation = theImplementation;
+ this.component = component;
+
+ processState = ProcessState.ACTIVE;
+ deployDate = new Date();
+
+ // Compile the process
+ compile( getBPELFile() );
+ } // end TuscanyProcessConfImpl constructor
+
+ public void stop() {
+ // If the BPEL file was rewritten, destroy the rewritten version of it so that
+ // it is not used again. Also delete the related compiled cbp file
+ if( rewritten ) {
+ try {
+ String cbpName = theBPELFile.getCanonicalPath();
+ // Remove the "bpel_tmp" suffix and add "cbp"
+ if ( cbpName.endsWith("bpel_tmp") ) {
+ cbpName = cbpName.substring( 0, cbpName.length() - 8) + "cbp";
+ File cbpFile = new File( cbpName );
+ if ( cbpFile.exists() ) cbpFile.delete();
+ } // end if
+ } catch (Exception e ) {
+ // Do nothing with an exception
+ } // end try
+ theBPELFile.delete();
+ } // end if
+
+ } // end method stop
+
+ /**
+ * Returns the URI for the directory containing the BPEL process
+ */
+ public URI getBaseURI() {
+ //System.out.println("getBaseURI called");
+ File theDir = getDirectory();
+ return theDir.toURI();
+ }
+
+ /**
+ * Returns a String containing the (local) name of the file containing the BPEL process
+ */
+ public String getBpelDocument() {
+ //System.out.println("getBPELDocument called");
+ try {
+ String location = this.implementation.getProcessDefinition().getLocation();
+ URI locationURI = new URI(null, location, null);
+ File processFile = new File(locationURI);
+ return getRelativePath( getDirectory(), processFile);
+ } catch (Exception e) {
+ if(__log.isWarnEnabled()) {
+ __log.warn("Unable to resolve relative path of BPEL process" + implementation.getProcessDefinition().getLocation(), e );
+ }
+ return null;
+ } // end try
+ } // end getBpelDocument
+
+ /**
+ * Returns an InputStream containing the Compiled BPEL Process (CBP)
+ */
+ public InputStream getCBPInputStream() {
+ //System.out.println("getCBPInputStream called");
+
+ File cbpFile = getCBPFile();
+ if( cbpFile == null ) return null;
+
+ if( cbpFile.exists() ) {
+ // Create an InputStream from the cbp file...
+ try {
+ return new FileInputStream( cbpFile );
+ } catch ( Exception e ) {
+ if(__log.isDebugEnabled()) {
+ __log.debug("Unable to open the cbp file for BPEL process: " +
+ implementation.getProcessDefinition().getName(), e);
+ }
+ } // end try
+ } else {
+ // Cannot find the cbp file
+ if(__log.isWarnEnabled()){
+ __log.warn("Cannot find the cbp file for process: " +
+ implementation.getProcessDefinition().getName());
+ }
+ } // end if
+ // TODO - need better exception handling if we can't open the cbp file for any reason
+ return null;
+ } // end getCBPInputStream
+
+ /**
+ * Gets the File object for the CBP file for this BPEL Process
+ * @return - the File object for the CBP file
+ */
+ private File getCBPFile() {
+ // Find the CBP file - it has the same name as the BPEL process and lives in the same
+ // directory as the process file
+ String cbpFileName = null;
+ try {
+ String fileName = getRelativePath( getDirectory(), getBPELFile() );
+ cbpFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".cbp";
+ } catch (Exception e ) {
+ // IOException trying to fetch the BPEL file name
+ if(__log.isDebugEnabled()) {
+ __log.debug("Unable to calculate the file name for BPEL process: " +
+ implementation.getProcessDefinition().getName(), e);
+ return null;
+ } // end if
+ } // end try
+ File cbpFile = new File( getDirectory(), cbpFileName );
+ return cbpFile;
+ } // end getCBPFile
+
+ /**
+ * Return the WSDL Definition for a given PortType
+ * @param portTypeName - the QName of the PortType
+ */
+ public Definition getDefinitionForPortType( QName portTypeName ) {
+ //System.out.println("getDefinitionForPortType called for portType: " + portTypeName );
+ // Find the named PortType in the list of WSDL interfaces associated with this BPEL Process
+ Collection<WSDLInterface> theInterfaces = implementation.getProcessDefinition().getInterfaces();
+ for( WSDLInterface wsdlInterface : theInterfaces ) {
+ if ( wsdlInterface.getPortType().getQName().equals( portTypeName ) ) {
+ // Extract and return the Definition associated with the WSDLDefinition...
+ return wsdlInterface.getWsdlDefinition().getDefinition();
+ } // end if
+ } // end for
+ return null;
+ } // end getDefinitionforPortType
+
+ /**
+ * Returns a WSDL Definition for a given Service QName
+ *
+ * 22/05/2008 - it is very unclear what this service QName is really meant to be.
+ * From the handling of the deploy.xml file by the current ODE code, it seems that the key link
+ * is from the Service QName to the PartnerLink name (done in the deploy.xml file).
+ *
+ * The curious part about this is that the QName for the service is ONLY defined in deploy.xml file
+ * and does not appear to relate to anything else, except for the QName of the PartnerLink
+ *
+ * The PartnerLink name is the same as the name of the SCA service (or reference) which in turn points
+ * at the PartnerLinkType which in turn points at an (WSDL) interface definition.
+ */
+ public Definition getDefinitionForService(QName serviceQName ) {
+ //System.out.println("getDefinitionForService called for Service: " + serviceQName );
+ if(__log.isDebugEnabled()){
+ __log.debug("getDefinitionforService called for service: " + serviceQName );
+ }
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Returns the date of deployment of the process
+ * - for SCA returns the date at which this object was created
+ */
+ public Date getDeployDate() {
+ //System.out.println("getDeployDate called");
+ return deployDate;
+ }
+
+ /**
+ * Returns userid of deployer
+ * - always "SCA Tuscany" for Tuscany...
+ */
+ public String getDeployer() {
+ //System.out.println("getDeployer called");
+ return "SCA Tuscany";
+ } // end getDeployer
+
+ /**
+ * Returns a list of the files in the directory containing the BPEL Process
+ */
+ public List<File> getFiles() {
+ //System.out.println("getFiles called");
+ File theDir = getDirectory();
+ List<File> theFiles = Arrays.asList( (File[]) theDir.listFiles() );
+ // TODO recurse into subdirectories
+ return theFiles;
+ } // end getFiles
+
+ /**
+ * Returns a Map containing all the "invoke endpoints" - for which read "SCA references"
+ * The map is keyed by partnerLink name and holds Endpoint objects
+ * 0..1 multiplicity references are not included in the returned Map (it is as if the reference is not there...)
+ * TODO deal with multiplicity 0..n and 1..n
+ * TODO deal with service callbacks on bidirectional services
+ */
+ public Map<String, Endpoint> getInvokeEndpoints() {
+ if( invokeEndpoints == null ) {
+ invokeEndpoints = new HashMap<String, Endpoint>();
+ // Get a collection of the component references - note that this includes "pseudo-references" for any
+ // services that have a callback interface
+ List<ComponentReference> theReferences = component.getReferences();
+ //List<Reference> theReferences = implementation.getReferences();
+ // Create an endpoint for each reference, using the reference name combined with
+ // http://tuscany.apache.org to make a QName
+ // Note that the key used for this put operation MUST be the name of one of the partnerLinks of the
+ // BPEL process. The SCA reference MAY have an alias for the name (can be given using the sca-bpel:reference
+ // element, if present) and this alias must not be used
+ for( Reference reference : theReferences ) {
+ String partnerlinkName = implementation.getReferencePartnerlinkName( reference.getName() );
+ // Check that there is at least 1 configured SCA endpointReference for the reference, since it is
+ // possible for 0..1 multiplicity references to have no SCA endpointReferences configured
+ List<org.apache.tuscany.sca.assembly.EndpointReference> eprs = reference.getEndpointReferences();
+ String eprCount = Integer.toString( eprs.size() );
+ invokeEndpoints.put( partnerlinkName,
+ new Endpoint( new QName( TUSCANY_NAMESPACE, reference.getName() ), eprCount));
+ } // end for
+ } // end if
+ return invokeEndpoints;
+ } // end getInvokeEndpoints
+
+ /**
+ * Returns the name of the directory containing the BPEL files
+ */
+ public String getPackage() {
+ //System.out.println("getPackage called");
+ File theDir = getDirectory();
+ return theDir.getName();
+ } // end getPackage
+
+ /**
+ * Return the BPEL Process ID - which is the Process QName appended "-versionnumber"
+ */
+ public QName getProcessId() {
+ //System.out.println("getProcessId called");
+ QName processType = getType();
+ QName processID = new QName( processType.getNamespaceURI(),
+ processType.getLocalPart() + "-" + getVersion() );
+ return processID;
+ } // end getProcessID
+
+ /**
+ * TODO - What are properties?
+ */
+ public Map<QName, Node> getProperties() {
+ //System.out.println("getProperties called");
+ if ( properties == null ) {
+ properties = new HashMap<QName, Node>();
+ } // end if
+ return properties;
+ } // end getProperties
+
+ /**
+ * Returns a Map containing all the "provide endpoints" - for which read "SCA services"
+ * The map is keyed by partnerLink name and holds Endpoint objects
+ *
+ * TODO deal with reference callbacks on bidirectional references
+ */
+ public Map<String, Endpoint> getProvideEndpoints() {
+ //System.out.println("getProvideEndpoints called");
+ if( provideEndpoints == null ) {
+ provideEndpoints = new HashMap<String, Endpoint>();
+ String componentURI = component.getURI();
+ // Get a collection of the services - note that the Component services include additional
+ // "pseudo-services" for each reference that has a callback...
+
+ List<ComponentService> theServices = component.getServices();
+ // Create an endpoint for each service, using the service name combined with
+ // http://tuscany.apache.org to make a QName
+ // Note that the key used for this put operation MUST be the name of one of the partnerLinks of the
+ // BPEL process. The SCA service MAY have an alias for the name (can be given using the sca-bpel:service
+ // element, if present) and this alias must not be used
+ for( ComponentService service : theServices ) {
+ String partnerlinkName = implementation.getServicePartnerlinkName( service.getName() );
+ // MJE 14/07/2009 - added componentURI to the service name to get unique service name
+ provideEndpoints.put( partnerlinkName,
+ new Endpoint( new QName( TUSCANY_NAMESPACE, componentURI + service.getName() ),
+ "ServicePort"));
+ } // end for
+ } // end if
+ return provideEndpoints;
+ } // end getProvideEndpoints
+
+ /**
+ * Return the process state
+ */
+ public ProcessState getState() {
+ //System.out.println("getState called");
+ return processState;
+ }
+
+ /**
+ * Returns the QName of the BPEL process
+ */
+ public QName getType() {
+ //System.out.println("getType called");
+ return implementation.getProcess();
+ }
+
+ /**
+ * Gets the process Version number
+ * - current code does not have versions for BPEL processes and always returns "1"
+ */
+ public long getVersion() {
+ //System.out.println("getVersion called");
+ return 1;
+ }
+
+ /**
+ * Returns true if the supplied event type is enabled for any of the scopes in the provided
+ * List. These events are "ODE Execution Events" and there is a definition of them on this
+ * page: http://ode.apache.org/user-guide.html#UserGuide-ProcessDeployment
+ *
+ * Tuscany currently uses:
+ * - instanceLifecycle events in order to establish the relationship of MessageExchange objects
+ * to the BPEL Process instances
+ * @param scopeNames - list of BPEL process Scope names
+ * @param type - the event type
+ */
+ public boolean isEventEnabled(List<String> scopeNames, TYPE type) {
+ if( type == TYPE.dataHandling ) return false;
+ if( type == TYPE.activityLifecycle ) return false;
+ if( type == TYPE.scopeHandling ) return true;
+ if( type == TYPE.instanceLifecycle ) return true;
+ if( type == TYPE.correlation ) return true;
+ return false;
+ } // end isEventEnabled
+
+ /**
+ * Returns whether the process is persisted in the store
+ *
+ * Returns false for SCA configuration
+ * - returning true causes problems in communicating with the BPEL process
+ */
+ public boolean isTransient() {
+ return false;
+ } // end isTransient
+
+ /**
+ * Compiles a BPEL process file into a compiled form CBP file in the main directory
+ * (ie same directory as the BPEL process file)
+ * @param bpelFile - the BPEL process file
+ */
+ private void compile( File bpelFile ) {
+ // Set up the compiler
+ BpelC compiler = BpelC.newBpelCompiler();
+ // Provide a null set of initial properties for now
+ Map<QName, Node> processProps = new HashMap<QName, Node>();
+ Map<String, Object> compileProps = new HashMap<String, Object>();
+ compileProps.put( BpelC.PROCESS_CUSTOM_PROPERTIES, processProps );
+ compiler.setCompileProperties( compileProps );
+ compiler.setBaseDirectory( getDirectory() );
+
+ // Inject any property values
+ bpelFile = injectPropertyValues( bpelFile );
+
+ // Run the compiler and generate the CBP file into the given directory
+ try {
+ compiler.compile( bpelFile );
+ } catch (IOException e) {
+ if(__log.isDebugEnabled()) {
+ __log.debug("Compile error in " + bpelFile, e);
+ }
+ // TODO - need better exception handling here
+ } // end try
+ } // end compile
+
+ /**
+ * Adds the values for SCA declared properties to the BPEL process.
+ * The values for the properties are held in the SCA RuntimeComponent supplied to this
+ * TuscanyProcessConfImpl.
+ * The properties map to <variable/> declarations in the BPEL process that are specifically
+ * marked with @sca-bpel:property="yes"
+ * @param bpelFile the file containing the BPEL process
+ * @return the (updated) file containing the BPEL process
+ */
+ private File injectPropertyValues( File bpelFile ) {
+ // Get the properties
+ List<ComponentProperty> properties = component.getProperties();
+
+ // If there are no properties, we're done!
+ if( properties.size() == 0 ) return bpelFile;
+
+ Document bpelDOM = readDOMFromProcess( bpelFile );
+
+ for( ComponentProperty property : properties ) {
+ //System.out.println("BPEL: Property - name = " + property.getName() );
+ insertSCAPropertyInitializer( bpelDOM, property );
+ } // end for
+
+ File bpelFile2 = writeProcessFromDOM( bpelDOM,
+ getTransformedBPELFile( bpelFile) );
+ if( bpelFile2 != null ) {
+ theBPELFile = bpelFile2;
+ rewritten = true;
+ return bpelFile2;
+ } // end if
+
+ return bpelFile;
+ } // end injectPropertyValues
+
+ /**
+ * Insert an initializer which supplies the value of an SCA property as specified by the
+ * SCA Component using the BPEL process
+ * @param bpelDOM - a DOM model representation of the BPEL process
+ * @param property - an SCA ComponentProperty element for the property
+ * This DOM model is updated, with an initializer being added for the BPEL variable
+ * corresponding to the SCA property
+ */
+ private void insertSCAPropertyInitializer( Document bpelDOM, ComponentProperty property ) {
+ // Only insert a Property initializer where there is a value for the Property
+ if( property.getValue() == null ) return;
+
+ Element insertionElement = findInitializerInsertionPoint( bpelDOM );
+ if( insertionElement == null ) return;
+
+ Element initializer = getInitializerSequence( bpelDOM, property );
+ if( initializer == null ) return;
+
+ // Insert the initializer sequence as the next sibling element of the insertion point
+ Element parent = (Element)insertionElement.getParentNode();
+ // Get the next sibling element, if there is one
+ Node sibling = insertionElement.getNextSibling();
+ while( sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE ) {
+ sibling = sibling.getNextSibling();
+ } // end while
+ // Either insert at the end or before the next element
+ if ( sibling == null ) {
+ parent.appendChild( initializer );
+ } else {
+ parent.insertBefore( initializer, sibling );
+ } // end if
+
+ } // end insertSCAPropertyInitializer
+
+ /**
+ * Gets the variable initializer DOM sequence for a given property, in the context of a supplied
+ * DOM model of the BPEL process
+ * @param bpelDOM - DOM representation of the BPEL process
+ * @param property - SCA Property which relates to one of the variables in the BPEL process
+ * @return - a DOM model representation of the XML statements required to initialize the
+ * BPEL variable with the value of the SCA property.
+ */
+ private Element getInitializerSequence( Document bpelDOM, ComponentProperty property ) {
+ // For an XML simple type (string, int, etc), the BPEL initializer sequence is:
+ // <assign><copy><from><literal>value</literal></from><to variable="variableName"/></copy></assign>
+ QName type = property.getXSDType();
+ if( type != null ) {
+ if( mapper.isSimpleXSDType( type ) ) {
+ // Simple types
+ String NS_URI = bpelDOM.getDocumentElement().getNamespaceURI();
+ String valueText = getPropertyValueText( property.getValue() );
+ Element literalElement = bpelDOM.createElementNS(NS_URI, "literal");
+ literalElement.setTextContent(valueText);
+ Element fromElement = bpelDOM.createElementNS(NS_URI, "from");
+ fromElement.appendChild(literalElement);
+ Element toElement = bpelDOM.createElementNS(NS_URI, "to");
+ Attr variableAttribute = bpelDOM.createAttribute("variable");
+ variableAttribute.setValue( property.getName() );
+ toElement.setAttributeNode( variableAttribute );
+ Element copyElement = bpelDOM.createElementNS(NS_URI, "copy");
+ copyElement.appendChild(fromElement);
+ copyElement.appendChild(toElement);
+ Element assignElement = bpelDOM.createElementNS(NS_URI, "assign");
+ assignElement.appendChild(copyElement);
+ return assignElement;
+ } // end if
+ // TODO Deal with Properties which have a non-simple type
+ } else {
+ // TODO Deal with Properties which have an element as the type
+ } // end if
+
+ return null;
+ } // end method getInitializerSequence
+
+ /**
+ * Gets the text value of a property that is a simple type
+ * @param propValue - the SCA Property value
+ * @return - the text content of the Property value, as a String
+ */
+ private String getPropertyValueText( Object propValue ) {
+ String text = null;
+ if( propValue instanceof Document ) {
+ Element docElement = ((Document)propValue).getDocumentElement();
+ if( docElement != null ){
+ Element valueElement = (Element)docElement.getFirstChild();
+ if( valueElement != null ) {
+ text = valueElement.getTextContent();
+ } // end if
+ } // end if
+ } // end if
+
+ return text;
+ } // end method getPropertyValueText
+
+ private Element findInitializerInsertionPoint( Document bpelDOM ) {
+ // The concept is to find the first Activity child element of the BPEL process document
+ Element docElement = bpelDOM.getDocumentElement();
+ NodeList elements = docElement.getElementsByTagName("*");
+
+ Element element;
+ for ( int i = 0 ; i < elements.getLength() ; i++ ) {
+ element = (Element)elements.item(i);
+ if( isInsertableActivityElement( element ) ) {
+ return element;
+ } // end if
+ } // end for
+
+ return null;
+ } // end method findInitializerInsertionPoint
+
+ /**
+ * A WS-BPEL activity can be any of the following:
+ * <receive>
+ * <reply>
+ * <invoke>
+ * <assign>
+ * <throw>
+ * <exit>
+ * <wait>
+ * <empty>
+ * <sequence>
+ * <if>
+ * <while>
+ * <repeatUntil>
+ * <forEach>
+ * <pick>
+ * <flow>
+ * <scope>
+ * <compensate>
+ * <compensateScope>
+ * <rethrow>
+ * <validate>
+ * <extensionActivity>
+ * A WS-BPEL start activity is a <receive> or <pick> with @create_instance="yes"
+ */
+ private static String SEQUENCE_ELEMENT = "sequence";
+ private static String REPLY_ELEMENT = "reply";
+ private static String INVOKE_ELEMENT = "invoke";
+ private static String ASSIGN_ELEMENT = "assign";
+ private static String PICK_ELEMENT = "pick";
+ private static String RECEIVE_ELEMENT = "receive";
+ private static String FLOW_ELEMENT = "flow";
+ private static String SCOPE_ELEMENT = "scope";
+ /**
+ * Determine if an Element is a BPEL start activity element which can have an Assign
+ * inserted following it
+ * @param element - a DOM Element containing the BPEL activity
+ * @return - true if the Element is a BPEL Activity element, false otherwise
+ */
+ private boolean isInsertableActivityElement( Element element ) {
+ String name = element.getTagName();
+ // For the present, only <receive/> and <pick/> elements with create_instance="yes" count
+ // if( SEQUENCE_ELEMENT.equalsIgnoreCase(name) ) return true;
+ String start = element.getAttribute("createInstance");
+ if( start == null ) return false;
+ if( !"yes".equals(start) ) return false;
+ if( RECEIVE_ELEMENT.equalsIgnoreCase(name) ) return true;
+ if( PICK_ELEMENT.equalsIgnoreCase(name) ) return true;
+ return false;
+ } // end method isActivityElement
+
+ /**
+ * Reads a BPEL Process file into a DOM Document structure
+ * @param bpelFile - a File object referencing the BPEL process document
+ * @return - a DOM Document structure representing the same BPEL process
+ */
+ private Document readDOMFromProcess( File bpelFile ) {
+ try {
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ docFactory.setNamespaceAware(true);
+ docFactory.setXIncludeAware(true);
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+
+ Document bpelDOM = docBuilder.parse( bpelFile );
+ return bpelDOM;
+ } catch (Exception e) {
+ return null;
+ } // end try
+ } // end method
+
+ /**
+ * Writes a BPEL Process file from a DOM Document structure representing the Process
+ * @param bpelDOM - the DOM Document representation of the BPEL process
+ * @param file - a File object to which the BPEL Process is to be written
+ * @return
+ */
+ private File writeProcessFromDOM( Document bpelDOM, File file ) {
+ try {
+ // Prepare the DOM document for writing
+ Source source = new DOMSource( bpelDOM );
+
+ // Prepare the output file
+ Result result = new StreamResult(file);
+
+ // Write the DOM document to the file
+ Transformer xformer = TransformerFactory.newInstance().newTransformer();
+ xformer.transform(source, result);
+ } catch (TransformerConfigurationException e) {
+ } catch (TransformerException e) {
+ return null;
+ }
+ return file;
+ } // end writeProcessFromDOM
+
+ private File getTransformedBPELFile( File bpelFile ) {
+ String name = bpelFile.getName();
+ File parent = bpelFile.getParentFile();
+ File bpelFile2 = null;
+ try {
+ bpelFile2 = File.createTempFile(name, ".bpel_tmp", parent);
+ } catch (Exception e ){
+
+ } // end try
+ return bpelFile2;
+ } // end getTransformedBPELFile
+
+ /**
+ * Gets the directory containing the BPEL process
+ * @return
+ */
+ private File getDirectory() {
+ File theDir = getBPELFile().getParentFile();
+ return theDir;
+ } // end getDirectory
+
+ /**
+ * Gets the File containing the BPEL process definition
+ * @return - the File object containing the BPEL process
+ */
+ private File getBPELFile() {
+ if( theBPELFile != null ) return theBPELFile;
+ try {
+ String location = this.implementation.getProcessDefinition().getLocation();
+ URI locationURI;
+ if (location.indexOf('%') != -1) {
+ locationURI = URI.create(location);
+ } else {
+ locationURI = new URI(null, location, null);
+ }
+ File theProcess = new File(locationURI);
+ theBPELFile = theProcess;
+ return theProcess;
+ } catch( Exception e ) {
+ if(__log.isDebugEnabled()) {
+ __log.debug("Exception converting BPEL file URL to an URI: " + e );
+ }
+ } // end try
+ return null;
+ } // end getBPELFile
+
+ /**
+ * Gets the relative path of a file against a directory in its hierarchy
+ * @param base - the base directory
+ * @param path - the file
+ * @return
+ * @throws IOException
+ */
+ private String getRelativePath(File base, File path) throws IOException {
+ String basePath = base.getCanonicalPath();
+ String filePath = path.getCanonicalPath();
+ if (!filePath.startsWith(basePath)) {
+ throw new IOException("Invalid relative path: base=" + base + " path=" + path);
+ }
+ String relative = filePath.substring(basePath.length());
+ if (relative.startsWith(File.separator)) {
+ relative = relative.substring(1);
+ }
+ return relative;
+ } // end getRelativePath
+
+ //-----------------------------------------------------------------------------
+ // other public APIs which ProcessConfImpl displays which are not in ProcessConf interface
+
+ public List<String> getMexInterceptors(QName processId) {
+// System.out.println("getMexInterceptors for processID: " + processId );
+ return null;
+ }
+
+ public void setTransient(boolean t) {
+// System.out.println("setTransient called with boolean: " + t );
+ }
+
+ public List<Element> getExtensionElement(QName arg0) {
+ return Collections.emptyList();
+ }
+ // end of other public APIs
+ //-----------------------------------------------------------------------------
+
+ /**
+ * Get the size in bytes of the CBP file
+ * @return - this size in bytes of the CBP file, 0 if the file cannot be found
+ */
+ public long getCBPFileSize() {
+ File cbpFile = getCBPFile();
+ if( cbpFile == null ) return 0;
+
+ return cbpFile.length();
+ } // end getCBPFileSize
+
+ private final Set<CLEANUP_CATEGORY> successCategories = EnumSet.noneOf(CLEANUP_CATEGORY.class);
+ private final Set<CLEANUP_CATEGORY> failureCategories = EnumSet.noneOf(CLEANUP_CATEGORY.class);
+
+ public Set<CLEANUP_CATEGORY> getCleanupCategories(boolean instanceSucceeded) {
+ if( instanceSucceeded ) return successCategories;
+ else return failureCategories;
+ }
+
+ private final Map<String, String> emptyPropertyMap = new Hashtable<String, String>();
+ public Map<String, String> getEndpointProperties(EndpointReference epr) {
+ return emptyPropertyMap;
+ }
+
+ private final Map<QName, Node> emptyProcessProperties = new Hashtable<QName, Node>();
+ public Map<QName, Node> getProcessProperties() {
+ return emptyProcessProperties;
+ }
+
+ public boolean isCleanupCategoryEnabled(boolean instanceSucceeded,
+ CLEANUP_CATEGORY category) {
+ // TODO Currently returns false - should this be changed for some categories?
+ return false;
+ }
+
+ public boolean isSharedService(QName serviceName) {
+ // Tuscany does not share the service
+ return false;
+ }
+
+} // end class TuscanyProcessConfImpl
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java
new file mode 100644
index 0000000000..b3824bffe1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode.provider;
+
+import java.io.File;
+import java.net.URI;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.dao.jpa.ProcessDAOImpl;
+import org.apache.openjpa.persistence.PersistenceProviderImpl;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer;
+import org.apache.tuscany.sca.implementation.bpel.ode.ODEDeployment;
+import org.apache.tuscany.sca.implementation.bpel.ode.ODEInitializationException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * BPEL Implementation provider
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELImplementationProvider implements ImplementationProvider {
+ private final Log __log = LogFactory.getLog(getClass());
+
+ private RuntimeComponent component;
+ private BPELImplementation implementation;
+
+ private EmbeddedODEServer odeServer;
+ private TransactionManager txMgr;
+
+ private ODEDeployment deployment;
+
+ /**
+ * Constructs a new BPEL Implementation.
+ */
+ public BPELImplementationProvider(RuntimeComponent component,
+ BPELImplementation implementation,
+ EmbeddedODEServer odeServer,
+ TransactionManager txMgr) {
+ this.component = component;
+ this.implementation = implementation;
+ this.odeServer = odeServer;
+ this.txMgr = txMgr;
+
+ // Configure the service and reference interfaces to use a DOM databinding
+ // as it's what ODE expects
+ for(Service service: implementation.getServices() ){
+ service.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ } // end for
+
+ for(Reference reference: implementation.getReferences() ) {
+ reference.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ } // end for
+
+ for (Service service: component.getServices()) {
+ //TODO - MJE, 06/06/2009 - we can eventually remove the reset of the service interface
+ // contract and leave it to the Endpoints only
+ service.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ for( Endpoint endpoint : service.getEndpoints() ) {
+ RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
+ if (ep.getComponentTypeServiceInterfaceContract() != null) {
+ ep.getComponentTypeServiceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ }
+ } // end for
+ } // end for
+
+ for (Reference reference : component.getReferences()) {
+ reference.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ for (EndpointReference endpointReference : reference.getEndpointReferences()) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference;
+ if (epr.getComponentTypeReferenceInterfaceContract() != null) {
+ epr.getComponentTypeReferenceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ }
+ } // end for */
+ } // end for
+
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ BPELInvoker invoker = new BPELInvoker(component, service, operation, odeServer, txMgr);
+ return invoker;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ if(__log.isInfoEnabled()) {
+ __log.info("Starting " + component.getName());
+ } // end if
+
+ // Switch TCCL - use a classloader that can find classes related to the non-OSGi services
+ // referenced from the implementation-bpel module which include the Persistence provider (OpenJPA) and
+ // the JPA DAO implementation contained in the ODE project
+ ClassLoader tccl = ClassLoaderContext.setContextClassLoader(EmbeddedODEServer.class.getClassLoader(),
+ PersistenceProviderImpl.class.getClassLoader(),
+ ProcessDAOImpl.class.getClassLoader() );
+
+ try {
+ if (!odeServer.isInitialized()) {
+ // start ode server
+ odeServer.init();
+ }
+
+ String location = this.implementation.getProcessDefinition().getLocation();
+ URI deployURI = new URI(null, location, null);
+
+ File deploymentDir = new File(deployURI).getParentFile();
+
+ if(__log.isInfoEnabled()) {
+ __log.info(">>> Deploying : " + deploymentDir.toString());
+ }
+
+ // Deploy the BPEL process
+ if (odeServer.isInitialized()) {
+ deployment = new ODEDeployment( deploymentDir );
+ try {
+ odeServer.registerTuscanyRuntimeComponent(implementation.getProcess(), component);
+
+ odeServer.deploy(deployment, implementation, component );
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ } catch (ODEInitializationException inite) {
+ throw new RuntimeException("BPEL Component Type Implementation : Error initializing embedded ODE server " + inite.getMessage(), inite);
+ } catch(Exception e) {
+ throw new RuntimeException("BPEL Component Type Implementation initialization failure : " + e.getMessage(), e);
+ } finally {
+ // Restore the TCCL if we changed it
+ if( tccl != null ) Thread.currentThread().setContextClassLoader(tccl);
+ } // end try
+ } // end method start()
+
+ public void stop() {
+ if(__log.isInfoEnabled()) {
+ __log.info("Stopping " + component.getName());
+ }
+
+ odeServer.undeploy(deployment);
+
+ if (odeServer.isInitialized()) {
+ // stop ode server
+ odeServer.stop();
+ }
+
+ txMgr = null;
+
+ if(__log.isInfoEnabled()) {
+ __log.info("Stopped !!!");
+ }
+ } // end method stop()
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProviderFactory.java
new file mode 100644
index 0000000000..ed327e237b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProviderFactory.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode.provider;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer;
+import org.apache.tuscany.sca.implementation.bpel.ode.GeronimoTxFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.annotation.Destroy;
+
+/**
+ * BPEL Implementation provider factory
+ *
+ * We use the provider factory to instantiate a ODE server that is going to be injected in all BPEL components
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELImplementationProviderFactory implements ImplementationProviderFactory<BPELImplementation> {
+
+ private EmbeddedODEServer odeServer;
+ private TransactionManager txMgr;
+
+ /**
+ * Default constructor receiving an extension point
+ * @param extensionPoints
+ */
+ public BPELImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ GeronimoTxFactory txFactory = new GeronimoTxFactory();
+ txMgr = txFactory.getTransactionManager();
+ this.odeServer = new EmbeddedODEServer(txMgr);
+ }
+
+ /**
+ * Creates a new BPEL Implementation and inject the EmbeddedODEServer
+ */
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, BPELImplementation implementation) {
+ return new BPELImplementationProvider(component, implementation, odeServer, txMgr);
+ }
+
+ public Class<BPELImplementation> getModelType() {
+ return BPELImplementation.class;
+ }
+
+ @Destroy
+ public void destroy() {
+ txMgr = null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java
new file mode 100644
index 0000000000..4a99fe705c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.apache.ode.bpel.iapi.MessageExchange.Status;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.GUID;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Implements a target invoker for BPEL component implementations.
+ *
+ * The target invoker is responsible for dispatching invocations to the particular
+ * component implementation logic. In this example we are simply delegating the
+ * CRUD operation invocations to the corresponding methods on our fake
+ * resource manager.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELInvoker implements Invoker {
+ private final static long TIME_OUT = 10000L;
+
+ protected final Log __log = LogFactory.getLog(getClass());
+
+ private EmbeddedODEServer odeServer;
+ private TransactionManager txMgr;
+
+ private RuntimeComponentService service;
+ private Operation operation;
+ private QName bpelServiceName;
+ private String bpelOperationName;
+ private Part bpelOperationInputPart;
+ private Part bpelOperationOutputPart;
+ private RuntimeComponent component;
+ // Marks if this service has a callback interface
+ private Boolean isCallback = false;
+ private EndpointReference callbackEPR;
+
+ public BPELInvoker(RuntimeComponent component, RuntimeComponentService service, Operation operation,
+ EmbeddedODEServer odeServer, TransactionManager txMgr) {
+ this.service = service;
+ this.component = component;
+ this.operation = operation;
+ this.bpelOperationName = operation.getName();
+ this.odeServer = odeServer;
+ this.txMgr = txMgr;
+ this.isCallback = serviceHasCallback( service );
+
+ initializeInvocation();
+ } // end method BPELInvoker
+
+ private boolean serviceHasCallback( RuntimeComponentService service ) {
+ if(service.getInterfaceContract().getCallbackInterface() != null) return true;
+ return false;
+ } // end method serviceHasCallback
+
+ private void initializeInvocation() {
+
+ __log.debug("Initializing BPELInvoker");
+
+ Interface interfaze = operation.getInterface();
+ if(interfaze instanceof WSDLInterface){
+ WSDLInterface wsdlInterface = null;
+ wsdlInterface = (WSDLInterface) interfaze;
+
+ // Fetch the service name from the service object - including the componentURI guarantees a unique service name
+ String componentURI = component.getURI();
+ bpelServiceName = new QName( Base.SCA11_TUSCANY_NS, componentURI + service.getName() );
+
+ bpelOperationInputPart = (Part) wsdlInterface.getPortType().getOperation(bpelOperationName,null,null).getInput().getMessage().getParts().values().iterator().next();
+ bpelOperationOutputPart = (Part) wsdlInterface.getPortType().getOperation(bpelOperationName,null,null).getOutput().getMessage().getParts().values().iterator().next();
+ }
+ } // end method initializeInvocation
+
+ public Message invoke(Message msg) {
+ try {
+ if( isCallback ) {
+ // Extract the callback endpoint metadata
+ callbackEPR = msg.getFrom();
+ } // end if
+ Object[] args = msg.getBody();
+ Object resp = doTheWork(args);
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+
+ public Object doTheWork(Object[] args) throws InvocationTargetException {
+ Element response = null;
+
+ if(! (operation.getInterface() instanceof WSDLInterface)) {
+ throw new InvocationTargetException(null,"Unsupported service contract");
+ }
+
+ org.apache.ode.bpel.iapi.MyRoleMessageExchange mex = null;
+ Future<?> onhold = null;
+
+ //Process the BPEL process invocation
+ Long processID = 0L;
+ try {
+ txMgr.begin();
+ mex = odeServer.getBpelServer().getEngine().createMessageExchange(new GUID().toString(),
+ bpelServiceName,
+ bpelOperationName);
+ //TODO - this will not be true for OneWay operations - need to handle those
+ mex.setProperty("isTwoWay", "true");
+ onhold = mex.invoke(createInvocationMessage(mex, args));
+
+ txMgr.commit();
+ // Deal with callback cases - store the callback metadata by process instance ID
+ if( isCallback ) {
+ processID = odeServer.getProcessIDFromMex(mex.getMessageExchangeId());
+ // Store the callback metadata for this invocation
+ odeServer.saveCallbackMetadata( processID, service.getName(), callbackEPR );
+ } // end if
+ } catch (Exception e) {
+ try {
+ txMgr.rollback();
+ } catch (SystemException se) {
+
+ }
+ throw new InvocationTargetException(e, "Error invoking BPEL process : " + e.getMessage());
+ } // end try
+
+ // Waiting until the reply is ready in case the engine needs to continue in a different thread
+ if (onhold != null) {
+ try {
+ //add timeout to avoid blocking when there is a exception/failure
+ onhold.get(TIME_OUT, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ throw new InvocationTargetException(e,"Error invoking BPEL process : " + e.getMessage());
+ } // end try
+ } // end if
+
+ //Process the BPEL invocation response
+ try {
+ txMgr.begin();
+ // Reloading the mex in the current transaction, otherwise we can't
+ // be sure we have the "freshest" one.
+ mex = (MyRoleMessageExchange)odeServer.getBpelServer().getEngine().getMessageExchange(mex.getMessageExchangeId());
+
+ Status status = mex.getStatus();
+
+ switch (status) {
+ case FAULT:
+ if (__log.isDebugEnabled())
+ __log.debug("Fault response message: " + mex.getFault());
+ throw new ODEInvocationException("FAULT received from BPEL process : " + mex.getFault()
+ + " "
+ + mex.getFaultExplanation());
+ case ASYNC:
+ case RESPONSE:
+ //process the method invocation result
+ response = processResponse(mex.getResponse().getMessage());
+ if (__log.isDebugEnabled())
+ __log.debug("Response message " + response);
+ break;
+ case FAILURE:
+ if (__log.isDebugEnabled())
+ __log.debug("Failure response message: " + mex.getFault());
+ break;
+ default:
+ throw new ODEInvocationException("FAILURE received from BPEL process : " + mex.getStatus() + " - " + mex.getFault());
+ } // end switch
+
+ txMgr.commit();
+ // end of transaction two
+ } catch (Exception e) {
+ try {
+ txMgr.rollback();
+ } catch (SystemException se) {
+
+ }
+ throw new InvocationTargetException(e, "Error retrieving BPEL process invocation status : " + e.getMessage());
+ } // end try
+
+ // Cleanup the ODE MessageExchange object
+ //mex.release();
+
+ return response;
+ }
+
+ /**
+ * Create BPEL Invocation message
+ *
+ * BPEL invocation message like :
+ * <message>
+ * <TestPart>
+ * <hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl">Hello</hello>
+ * </TestPart>
+ * </message>
+ * @param args
+ * @return
+ */
+ private org.apache.ode.bpel.iapi.Message createInvocationMessage(org.apache.ode.bpel.iapi.MyRoleMessageExchange mex, Object[] args) {
+ Document dom = DOMUtils.newDocument();
+
+ Element contentMessage = dom.createElement("message");
+ Element contentPart = dom.createElement(bpelOperationInputPart.getName());
+ Element payload = null;
+
+ // TODO handle WSDL input messages with multiple Parts...
+ //TUSCANY-2321 - Properly handling Document or Element types
+ if(args[0] instanceof Document) {
+ payload = (Element) ((Document) args[0]).getFirstChild();
+ } else {
+ payload = (Element) args[0];
+ }
+
+ contentPart.appendChild(dom.importNode(payload, true));
+ contentMessage.appendChild(contentPart);
+ dom.appendChild(contentMessage);
+
+ if (__log.isDebugEnabled()) {
+ __log.debug("Creating invocation message:");
+ __log.debug(">> args.....: " + DOMUtils.domToString(payload));
+ __log.debug(">> message..:" + DOMUtils.domToString(dom.getDocumentElement()));
+ }
+
+ org.apache.ode.bpel.iapi.Message request = mex.createMessage(new QName("", ""));
+ request.setMessage(dom.getDocumentElement());
+
+ return request;
+ }
+
+ /**
+ * Process BPEL response
+ *
+ * <message>
+ * <TestPart>
+ * <hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl">World</hello>
+ * </TestPart>
+ * </message>
+ *
+ * @param response
+ * @return
+ */
+ private Element processResponse(Element response) {
+ return (Element) DOMUtils.findChildByName(response, new QName("",bpelOperationOutputPart.getName())).getFirstChild();
+
+ // MJE, 12/06/2009 - changed to return the message without the PART wrapper element, since this element is not
+ // transmitted in the SOAP messages on the wire
+ } // end method processResponse
+} // end class BPELInvoker
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/ODEInvocationException.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/ODEInvocationException.java
new file mode 100644
index 0000000000..7b6f9ceafa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/ODEInvocationException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.bpel.ode.provider;
+
+public class ODEInvocationException extends Exception {
+
+ /**
+ * Thrown when the result of the invocation of a BPEL Process operation
+ * returns a Fault or Failure code
+ */
+ private static final long serialVersionUID = 5096941965798566018L;
+
+ public ODEInvocationException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..763f8a601b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.bpel.ode.provider.BPELImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.bpel.BPELImplementation
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServerTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServerTestCase.java
new file mode 100644
index 0000000000..0f59990377
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServerTestCase.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.ode;
+
+import javax.transaction.TransactionManager;
+
+import junit.framework.TestCase;
+
+/**
+ * Test to Deploy and Invoke a HelloWorld BPEL process using EmbeddedODEServer
+ *
+ * Major changes introduced to this testcase on 27/05/2008 associated with changes in the
+ * implementation of EmbeddedODEServer which remove the need for the ODE deploy.xml file -
+ * instead a Tuscany BPELImplementation object is passed to the EmbeddedODEServer and this is
+ * introspected to get all the necessary information about the BPEL process
+ *
+ * @version $Rev$ $Date$
+ */
+public class EmbeddedODEServerTestCase extends TestCase {
+
+ private EmbeddedODEServer odeServer;
+
+ private TransactionManager txMgr;
+
+ @Override
+ protected void setUp() throws Exception {
+ // Set up the ODE BPEL server...
+ GeronimoTxFactory txFactory = new GeronimoTxFactory();
+ txMgr = txFactory.getTransactionManager();
+
+ this.odeServer = new EmbeddedODEServer(txMgr);
+ odeServer.init();
+
+ } // end setUp
+
+ @Override
+ protected void tearDown() throws Exception {
+ odeServer.stop();
+ }
+
+ public void testProcessInvocation() throws Exception {
+ if (!odeServer.isInitialized()) {
+ fail("Server did not start !");
+ }
+// TODO - write effective testcase - made problematic by the need to supply a resolved
+// BPELImplementation
+/*
+ URL deployURL = getClass().getClassLoader().getResource("helloworld/deploy.xml");
+ File deploymentDir = new File(deployURL.toURI().getPath()).getParentFile();
+ System.out.println("Deploying : " + deploymentDir.toString());
+ System.out.println(deploymentDir);
+
+ if (odeServer.isInitialized()) {
+ try {
+ txMgr.begin();
+ odeServer.deploy(new ODEDeployment(deploymentDir), implementation);
+ txMgr.commit();
+ } catch (Exception e) {
+ e.printStackTrace();
+ txMgr.rollback();
+ }
+
+ // transaction one
+ MyRoleMessageExchange mex = null;
+ Future onhold = null;
+ try {
+ // invoke the process
+ txMgr.begin();
+ mex = odeServer.getBpelServer().getEngine().createMessageExchange(new GUID().toString(),
+ new QName("http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl", "HelloService"), "hello");
+
+ Message request = mex.createMessage(new QName("", ""));
+ request.setMessage(DOMUtils.stringToDOM("<message><TestPart><hello xmlns=\"http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl\">Hello</hello></TestPart></message>"));
+ onhold = mex.invoke(request);
+ txMgr.commit();
+ } catch (Exception e) {
+ e.printStackTrace();
+ txMgr.rollback();
+ }
+ // - end of transaction one
+
+ // Waiting until the reply is ready in case the engine needs to continue in a different thread
+ if (onhold != null)
+ onhold.get();
+
+ // transaction two
+ try {
+ txMgr.begin();
+ // Reloading the mex in the current transaction, otherwise we can't be sure we have
+ // the "freshest" one.
+ mex = (MyRoleMessageExchange) odeServer.getBpelServer().getEngine().getMessageExchange(mex.getMessageExchangeId());
+
+ Status status = mex.getStatus();
+ System.out.println("Status: " + status.name());
+ Element response = mex.getResponse().getMessage();
+ System.out.println("Response: " + DOMUtils.domToString(response));
+ txMgr.commit();
+ // end of transaction two
+ } catch (Exception e) {
+ e.printStackTrace();
+ txMgr.rollback();
+ } // end try
+ } // end if
+*/
+ } // end testProcessInvocation
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/deploy.xml b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/deploy.xml
new file mode 100644
index 0000000000..571aa37d58
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/deploy.xml
@@ -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.
+ -->
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:wns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl">
+
+
+ <process name="tns:HelloWorld">
+ <active>true</active>
+ <provide partnerLink="helloPartnerLink">
+ <service name="wns:HelloService" port="HelloPort"/>
+ </provide>
+ </process>
+</deploy>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/greetings.wsdl b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/greetings.wsdl
new file mode 100644
index 0000000000..e768707ccd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/greetings.wsdl
@@ -0,0 +1,87 @@
+<?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 name="greetings"
+ targetNamespace="http://greetings"
+ xmlns:tns="http://greetings"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://greetings" 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="Greetings">
+ <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="GreetingsSoapBinding" type="tns:Greetings">
+ <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="GreetingsService">
+ <wsdl:port name="GreetingsSoapPort" binding="tns:GreetingsSoapBinding">
+ <wsdlsoap:address location="http://localhost:8085/GreetingsServiceComponent"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="GreetingsPartnerLinkType">
+ <plnk:role name="Provider" portType="tns:Greetings"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.bpel b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..1799a5ebd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.bpel
@@ -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.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="helloworld.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"/>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink" partnerLinkType="test:HelloPartnerLinkType" myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="helloMessage" messageType="test:HelloMessage"/>
+ <variable name="tmpVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessage"
+ createInstance="yes"/>
+
+ <variables>
+ <variable name="myVar" messageType="test:HelloMessage"/>
+ <variable name="tmpVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="myVar"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from>concat($myVar.TestPart/test:message/text(), ' World')</from>
+ <to variable="tmpVar"/>
+ </copy>
+ <copy>
+ <from>$tmpVar</from>
+ <to>$myVar.TestPart/test:message</to>
+ </copy>
+ </assign>
+
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessage"/>
+ </sequence>
+</process>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..610bda3cc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.wsdl
@@ -0,0 +1,82 @@
+<?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 name="helloworld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="message" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part element="tns:hello" name="TestPart"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="TestIn">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="TestOut">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8085/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/log4j.properties b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..82b3c09723
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel-runtime/src/test/resources/log4j.properties
@@ -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.
+#
+
+# Set root logger level to WARN and its only appender to CONSOLE
+log4j.rootLogger=OFF, CONSOLE
+
+# log4j properties to work with commandline tools.
+log4j.category.org.mortbay=OFF
+log4j.category.org.hibernate.type=OFF
+log4j.category.org.objectweb=OFF
+log4j.category.org.apache.ode.axis2=OFF
+log4j.category.org.apache.ode.bpel.engine=OFF
+log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF
+log4j.category.org.apache.ode.bpel.epr=OFF
+log4j.category.org.apache.tuscany.sca.implementation.bpel=OFF
+log4j.category.org.apache.tuscany.sca.implementation.bpel.ode=OFF
+log4j.category.org.apache.tuscany.sca.implementation.bpel.ode.provider=OFF
+
+# Console appender
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=[%p] - %C{1}.%M(%L) | %m%n
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-bpel/LICENSE
new file mode 100644
index 0000000000..baba9ca048
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/LICENSE
@@ -0,0 +1,251 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+=================================================================================================================
+
+This module implementation-script temporarily includes one file under the following BSD license:
+
+ Copyright (c) 2006, Sun Microsystems, Inc.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither the name of the Sun Microsystems, Inc. nor the names of
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+=================================================================================================================
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-bpel/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..dce7e9e25f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/META-INF/MANIFEST.MF
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.bpel;version="2.0.0"
+ ;uses:="org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.contribution.
+ resolver,javax.xml.namespace"
+Private-Package: org.apache.tuscany.sca.implementation.bpel.impl;versi
+ on="2.0.0",org.apache.tuscany.sca.implementation.bpel.xml;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA BPEL Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA BPEL Implementation Model
+Import-Package: javax.wsdl,
+ javax.wsdl.extensions,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.implementation.bpel;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.bpel
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-bpel/NOTICE
new file mode 100644
index 0000000000..a2f696be26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/NOTICE
@@ -0,0 +1,17 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+This product also includes software under the BSD license
+(see the LICENSE file contained in this distribution), with
+the following copyright:
+
+Copyright (c) 2006, Sun Microsystems, Inc.
+All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-bpel/pom.xml
new file mode 100644
index 0000000000..d6d2afe92c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/pom.xml
@@ -0,0 +1,64 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-bpel</artifactId>
+ <name>Apache Tuscany SCA BPEL Implementation Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELFactory.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELFactory.java
new file mode 100644
index 0000000000..9f8f9c0e9a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel;
+
+/**
+ * A factory for the BPEL implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BPELFactory {
+
+ /**
+ * Creates a new BPEL implementation.
+ *
+ * @return
+ */
+ BPELImplementation createBPELImplementation();
+
+ /**
+ * Creates a new BPEL Process Definition
+ *
+ * @return
+ */
+ BPELProcessDefinition createBPELProcessDefinition();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java
new file mode 100644
index 0000000000..db5d808f7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ * The model representing the BPEL implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BPELImplementation extends Implementation {
+ QName TYPE = new QName(SCA11_NS, "implementation.bpel");
+ /**
+ * Get the BPEL process Name
+ *
+ * @return
+ */
+ QName getProcess();
+
+ /**
+ * Set the BPEL process Name
+ *
+ * @param processName process QName
+ */
+ void setProcess(QName processName);
+
+ /**
+ * Get the BPEL process definition
+ *
+ * @return
+ */
+ BPELProcessDefinition getProcessDefinition();
+
+ /**
+ * Set the BPEL process definition
+ *
+ * @param processDefinition
+ */
+ void setProcessDefinition(BPELProcessDefinition processDefinition);
+
+ /**
+ * Returns the componentType for this implementation.
+ *
+ * @return
+ */
+ public ComponentType getComponentType();
+
+ /**
+ * Sets the componentType for this implementation
+ *
+ * @param componentType the component type to set
+ */
+ public void setComponentType(ComponentType componentType);
+
+ /**
+ * Returns the model resolver that can be used to resolve WSDLs and XSDs
+ * referenced by the BPEL process.
+ *
+ * @return
+ */
+ ModelResolver getModelResolver();
+
+ /**
+ * Sets the model resolver that can be used to resolve WSDLs and XSDs referenced
+ * by the BPEL process.
+ *
+ * @param modelResolver
+ */
+ void setModelResolver(ModelResolver modelResolver);
+
+ /**
+ * Gets the name of the partnerLink which corresponds to the SCA service with the supplied name
+ * This deals in particular with cases where the SCA service name is an alias which is not the
+ * same as the partnerLink name
+ * @param serviceName - the name of the SCA service
+ * @return
+ */
+ String getServicePartnerlinkName( String serviceName );
+
+ /**
+ * Gets the name of the partnerLink which corresponds to the SCA reference with the supplied name
+ * This deals in particular with cases where the SCA reference name is an alias which is not the
+ * same as the partnerLink name
+ * @param referenceName - the name of the SCA reference
+ * @return
+ */
+ String getReferencePartnerlinkName( String referenceName );
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java
new file mode 100644
index 0000000000..2ad088719b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel;
+
+import java.util.List;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELImportElement;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELPartnerLinkElement;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+
+
+/**
+ * The model representing a BPEL process definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BPELProcessDefinition extends Base {
+
+ /**
+ * Get the BPEL process Name
+ *
+ * @return
+ */
+ QName getName();
+
+ /**
+ * Set the BPEL process Name
+ *
+ * @param processName process QName
+ */
+ void setName(QName name);
+
+ /**
+ * Get BPEL process URI
+ *
+ * @return URI for the process
+ */
+ String getURI();
+
+ /**
+ * Set the BPEL process URI
+ *
+ * @param uri for the process
+ */
+ void setURI(String uri);
+
+ /**
+ * Get the URL for the process location
+ *
+ * @return
+ */
+ String getLocation();
+
+ /**
+ * Set the URL for the process location
+ *
+ * @param url
+ */
+ void setLocation(String location);
+
+ /**
+ * Return the list of PartnerLinks for this process
+ *
+ * @return
+ */
+ List<BPELPartnerLinkElement> getPartnerLinks();
+
+ /**
+ * Return the list of imports for this process
+ *
+ * @return
+ */
+ List<BPELImportElement> getImports();
+
+ /**
+ * Return the collection of associated port types
+ *
+ * @return
+ */
+ public List<PortType> getPortTypes() ;
+
+ /**
+ * Return the collection of associated WSDL interfaces
+ * @return
+ */
+ public List<WSDLInterface> getInterfaces() ;
+
+ /**
+ * Return a collection of (SCA) Properties associated with this process
+ * @return - a List of SCA Property objects
+ */
+ public List<Property> getProperties();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java
new file mode 100644
index 0000000000..bd98a4af95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.bpel.impl;
+
+import org.apache.tuscany.sca.implementation.bpel.BPELFactory;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
+
+/**
+ * A factory for the BPEL implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELFactoryImpl implements BPELFactory {
+
+ public BPELFactoryImpl() {
+ }
+
+ public BPELImplementation createBPELImplementation() {
+ return new BPELImplementationImpl();
+ }
+
+ public BPELProcessDefinition createBPELProcessDefinition() {
+ return new BPELProcessDefinitionImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java
new file mode 100644
index 0000000000..67eb9bd047
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELPartnerLinkElement;
+
+/**
+ * The model representing a BPEL implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+class BPELImplementationImpl extends ImplementationImpl implements BPELImplementation {
+
+ private QName processName;
+ private BPELProcessDefinition processDefinition;
+ private ComponentType componentType;
+ private ModelResolver modelResolver;
+
+ protected BPELImplementationImpl() {
+ super(TYPE);
+ }
+
+ public QName getProcess() {
+ return processName;
+ }
+
+ public void setProcess(QName processName) {
+ this.processName = processName;
+ }
+
+ public BPELProcessDefinition getProcessDefinition() {
+ return this.processDefinition;
+ }
+
+ public void setProcessDefinition(BPELProcessDefinition processDefinition) {
+ this.processDefinition = processDefinition;
+ }
+
+ @Override
+ public String getURI() {
+ // The BPEL implementation does not have a URI
+ return null;
+ }
+
+ @Override
+ public void setURI(String uri) {
+ // The BPEL implementation does not have a URI
+ }
+
+ @Override
+ public List<Property> getProperties() {
+ return componentType.getProperties();
+ }
+
+ public ComponentType getComponentType() {
+ return componentType;
+ }
+
+ public void setComponentType(ComponentType componentType) {
+ this.componentType = componentType;
+ }
+
+ public ModelResolver getModelResolver() {
+ return modelResolver;
+ }
+
+ public void setModelResolver(ModelResolver modelResolver) {
+ this.modelResolver = modelResolver;
+ }
+
+ @Override
+ public List<Service> getServices() {
+ return componentType.getServices();
+ }
+
+ @Override
+ public List<Reference> getReferences() {
+ return componentType.getReferences();
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(this.getProcess()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof BPELImplementation) {
+ if (getProcess() != null) {
+ return getProcess().equals(((BPELImplementation)obj).getProcess());
+ } else {
+ return ((BPELImplementation)obj).getProcess() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public String getReferencePartnerlinkName(String referenceName) {
+ if( referenceName == null ) return null;
+ // Find the partnerLink which has its SCAName set to the supplied name
+ List<BPELPartnerLinkElement> partnerLinks = processDefinition.getPartnerLinks();
+ for( BPELPartnerLinkElement partnerLink : partnerLinks ) {
+ if( referenceName.equals(partnerLink.getSCAName()) ) {
+ return partnerLink.getName();
+ } // end if
+ } // end for
+ return null;
+ } // end method getReferencePartnerlinkName
+
+ public String getServicePartnerlinkName(String serviceName) {
+ if( serviceName == null ) return null;
+ // Find the partnerLink which has its SCAName set to the supplied name
+ List<BPELPartnerLinkElement> partnerLinks = processDefinition.getPartnerLinks();
+ for( BPELPartnerLinkElement partnerLink : partnerLinks ) {
+ if( serviceName.equals(partnerLink.getSCAName()) ) {
+ return partnerLink.getName();
+ } // end if
+ } // end for
+ return null;
+ } // end method getServicePartnerlinkName
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java
new file mode 100644
index 0000000000..5ef4a4c113
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELImportElement;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELPartnerLinkElement;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+
+/**
+ * The BPEL process definition implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+class BPELProcessDefinitionImpl implements BPELProcessDefinition {
+ private QName name;
+ private String uri;
+ private String location;
+ private boolean unresolved;
+ private List<BPELPartnerLinkElement> partnerLinks = new ArrayList<BPELPartnerLinkElement>();
+ private List<BPELImportElement> imports = new ArrayList<BPELImportElement>();
+ private List<PortType> thePortTypes = new ArrayList<PortType>();
+ private List<WSDLInterface> theInterfaces = new ArrayList<WSDLInterface>();
+ private List<Property> theProperties = new ArrayList<Property>();
+
+ public QName getName() {
+ return name;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ public List<BPELPartnerLinkElement> getPartnerLinks() {
+ return partnerLinks;
+ }
+
+ public List<BPELImportElement> getImports() {
+ return imports;
+ }
+
+ public List<PortType> getPortTypes() {
+ return thePortTypes;
+ }
+
+ public List<WSDLInterface> getInterfaces() {
+ return theInterfaces;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getName()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof BPELProcessDefinition) {
+ if (getName() != null) {
+ return getName().equals(((BPELProcessDefinition)obj).getName());
+ } else {
+ return ((BPELProcessDefinition)obj).getName() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public List<Property> getProperties() {
+ return theProperties;
+ } // end method getProperties
+
+ /**
+ * toString() method to produce a useful String to characterize this BPEL Process implementation during debugging
+ */
+ public String toString() {
+ return "BPEL Process: " + name.toString();
+ }
+} // end class BPELProcessDefinitionImpl
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentModelResolver.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentModelResolver.java
new file mode 100644
index 0000000000..83860f59e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentModelResolver.java
@@ -0,0 +1,401 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.xml;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.wsdl.BPELPartnerLinkTypeExt;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * A Model Resolver for BPEL process models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELDocumentModelResolver implements ModelResolver {
+
+ private WSDLFactory wsdlFactory;
+ private Contribution contribution;
+ private Map<QName, BPELProcessDefinition> map = new HashMap<QName, BPELProcessDefinition>();
+
+ public BPELDocumentModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ BPELProcessDefinition process = (BPELProcessDefinition)resolved;
+ map.put(process.getName(), process);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(((BPELProcessDefinition)resolved).getName());
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ BPELProcessDefinition resolved = null;
+ QName qname = ((BPELProcessDefinition)unresolved).getName();
+
+ // Lookup a definition for the given namespace, from imports
+ List<String> locations = new ArrayList<String>();
+ // Collection of namespace imports with location
+ Map<String, NamespaceImport> locationMap = new HashMap<String, NamespaceImport>();
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof NamespaceImport) {
+ NamespaceImport namespaceImport = (NamespaceImport)import_;
+ if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
+ if (namespaceImport.getLocation() == null) {
+ // Delegate the resolution to the import resolver
+ resolved = namespaceImport.getModelResolver().resolveModel(BPELProcessDefinition.class, (BPELProcessDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ } else {
+ // We might have multiple imports for the same namespace,
+ // need to search them in lexical order.
+ locations.add(namespaceImport.getLocation());
+ }
+ }
+ }
+ }
+ // Search namespace imports with locations in lexical order
+ Collections.sort(locations);
+ for (String location : locations) {
+ NamespaceImport namespaceImport = (NamespaceImport)locationMap.get(location);
+ // Delegate the resolution to the namespace import resolver
+ resolved = namespaceImport.getModelResolver().resolveModel(BPELProcessDefinition.class, (BPELProcessDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+
+
+ // Not found, Lookup a definition for the given namespace, within contribution
+ resolved = (BPELProcessDefinition) map.get(qname);
+
+ if(resolved.isUnresolved()) {
+ try {
+ resolve(resolved, context);
+ } catch(Exception e) {
+ //FIXME
+ }
+ }
+
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ return (T)unresolved;
+ }
+
+ public void resolve(BPELProcessDefinition unresolved, ProcessorContext context) throws ContributionResolveException {
+ // FIXME - serious resolving needs to happen here
+
+ // Step 1 is to resolve the WSDL files referenced from this BPEL process
+ // - one complexity here is that the WSDL definitions hold BPEL extension elements for
+ // the partnerLinkType declarations - and these must be used in later steps
+ //
+ // Step 2 is to take all the partnerLink definitions and establish the PortType being
+ // used, by tracing through the related partnerLinkType declarations - the PortType is
+ // effectively a definition of the interface used by the partnerLink.
+ // - another consideration here is that each partnerLink can involve 2 interfaces, one
+ // for the forward calls to the process, the other for calls from the process - depending
+ // on whether the partnerLink is a reference or a service, one of these interfaces is a
+ // callback interface.
+
+ List<BPELImportElement> theImports = unresolved.getImports();
+ Set<Definition> wsdlDefinitions = getImportedWSDLDefinitions( theImports, contribution.getModelResolver(), context );
+
+ // Fetch the sets of partner links, port types and interfaces
+ List<BPELPartnerLinkTypeElement> thePLinkTypes = getPartnerLinkTypes( wsdlDefinitions, context.getMonitor() );
+ Collection<WSDLInterface> theInterfaces = (Collection<WSDLInterface>)new ArrayList<WSDLInterface>();
+ Collection<PortType> thePortTypes = getAllPortTypes( theImports, theInterfaces, contribution.getModelResolver(), context );
+
+ // Store the Port Types and the Interfaces for later calculation of the component type...
+ unresolved.getPortTypes().addAll(thePortTypes);
+ unresolved.getInterfaces().addAll(theInterfaces);
+
+ // Now, for each partnerLink in the BPEL process, find the related partnerLinkType element
+ List<BPELPartnerLinkElement> thePartnerLinks = unresolved.getPartnerLinks();
+ for (BPELPartnerLinkElement thePartnerLink : thePartnerLinks) {
+ QName partnerLinkType = thePartnerLink.getPartnerLinkType();
+ BPELPartnerLinkTypeElement pLinkType = findPartnerLinkType(partnerLinkType, thePLinkTypes);
+ if (pLinkType == null) {
+ error(context.getMonitor(), "PartnerLinkNoMatchingType", thePartnerLink, thePartnerLink.getName());
+ } else {
+ thePartnerLink.setPartnerLinkType(pLinkType);
+ }
+ } // end for
+
+ unresolved.setUnresolved(false);
+
+ } // end resolve
+
+ /**
+ * Get all the WSDL definitions referenced through the import statements of the BPEL process
+ * @param theImports - a list of the import statements
+ * @return - a Set containing all the referenced WSDL definitions
+ */
+ private Set<Definition> getImportedWSDLDefinitions( List<BPELImportElement> theImports, ModelResolver resolver, ProcessorContext context ) {
+ Set<Definition> wsdlDefinitions = null;
+ for (BPELImportElement theImport : theImports) {
+ if (theImport.getImportType().equals(BPELProcessorConstants.WSDL_NS)) {
+ // If the Import is a WSDL import, resolve the WSDL
+ WSDLDefinition theWSDL = resolveWSDLDefinition( theImport.getLocation(),
+ theImport.getNamespace(), resolver, context );
+ if( theWSDL != null ) {
+ theImport.setWSDLDefinition( theWSDL );
+
+ // Find all the WSDL definitions matching the imported namespace
+ if( wsdlDefinitions == null ) {
+ wsdlDefinitions = new HashSet<Definition>();
+ } // end if
+
+ wsdlDefinitions.add(theWSDL.getDefinition());
+ } // end if
+ } // end if
+ } // end for
+
+ return wsdlDefinitions;
+ } // end getImportedWSDLDefinitions
+
+ /**
+ * Resolve a reference to a WSDL, given by a namespace and a location
+ * @param wsdlLocation - a string containing the WSDL location
+ * @param wsdlNamespace - a string containing the WSDL namespace
+ * @param resolver - a model resolver
+ * @param context
+ * @return - a WSDLDefinition object for the referenced WSDL, or null if the WSDL cannot be resolved
+ */
+ private WSDLDefinition resolveWSDLDefinition( String wsdlLocation, String wsdlNamespace, ModelResolver resolver, ProcessorContext context ) {
+
+ // Resolve the WSDL definition
+ WSDLDefinition proxy = wsdlFactory.createWSDLDefinition();
+ proxy.setUnresolved(true);
+ proxy.setNamespace(wsdlNamespace);
+ if (wsdlLocation != null) {
+ proxy.setLocation(URI.create(wsdlLocation));
+ }
+ WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, proxy, context);
+ if (resolved != null && !resolved.isUnresolved()) {
+ return resolved;
+ } else {
+ error(context.getMonitor(), "CannotResolveWSDLReference", resolver, wsdlLocation, wsdlNamespace);
+ return null;
+ } // end if
+ } // end resolveWSDLDefinition
+
+
+ /**
+ * Retrieve all the Partner Link types defined in the imported WSDL files
+ *
+ * @param wsdlDefinitions - the set of imported WSDL definitions
+ * @return - a List of PartnerLinkType elements
+ */
+ @SuppressWarnings("unchecked")
+ private List<BPELPartnerLinkTypeElement> getPartnerLinkTypes( Set<Definition> wsdlDefinitions, Monitor monitor ) throws ContributionResolveException {
+
+ List<BPELPartnerLinkTypeElement> thePLinks = new ArrayList<BPELPartnerLinkTypeElement>();
+
+ // The BPEL partnerLinkType elements are extension elements within the WSDL definitions
+ for (Definition wsdlDefinition: wsdlDefinitions) {
+ for (ExtensibilityElement theElement : (List<ExtensibilityElement>)wsdlDefinition.getExtensibilityElements()) {
+ QName elementType = theElement.getElementType();
+ if (elementType.equals(BPELProcessorConstants.LINKTYPE_ELEMENT) || elementType.equals(BPELProcessorConstants.LINKTYPE_ELEMENT_20)) {
+ BPELPartnerLinkTypeExt pLinkExt = (BPELPartnerLinkTypeExt)theElement;
+
+ // Fetch the name of the partnerLinkType
+ QName qName = new QName(wsdlDefinition.getTargetNamespace(), pLinkExt.getName());
+ BPELPartnerLinkTypeElement pLinkElement = new BPELPartnerLinkTypeElement(qName);
+
+ // The partnerLinkType must have one and may have 2 role child elements
+ int count = 0;
+ for (int i = 0; i < 2; i++) {
+ if( count > 1 ) break;
+ if (pLinkExt.getRoleName(i) == null) continue;
+ PortType pType = wsdlDefinition.getPortType(pLinkExt.getRolePortType(i));
+ if (count == 0) {
+ pLinkElement.setRole1(pLinkExt.getRoleName(i), pLinkExt.getRolePortType(i), pType);
+ } else {
+ pLinkElement.setRole2(pLinkExt.getRoleName(i), pLinkExt.getRolePortType(i), pType);
+ } // end if
+ count++;
+ } // end for
+
+ if (count == 0) {
+ error(monitor, "PartnerLinkTypeNoRoles", theElement, pLinkElement.getName());
+ throw new ContributionResolveException("partnerLinkType " + pLinkElement.getName() + " has no Roles defined");
+ } else
+ thePLinks.add(pLinkElement);
+ } // end if
+ } // end for
+ } // end for
+ return thePLinks;
+ } // end getPartnerLinkTypes
+
+
+ /**
+ * Finds a partnerLinkType definition within the WSDLs imported by the BPEL
+ * process.
+ *
+ * @param partnerLinkTypeName - the name of the partnerLinkType
+ * @param theImports a list of the WSDL import declarations
+ * @return a BPELPartnerLinkTypeElement for the partnerLinkType or null if it cannot be
+ * found
+ */
+ private BPELPartnerLinkTypeElement findPartnerLinkType( QName partnerLinkTypeName, List<BPELPartnerLinkTypeElement> thePLinkTypes) {
+ // We must find the partner link type element from amongst the imported WSDLs
+ for ( BPELPartnerLinkTypeElement thePLinkType : thePLinkTypes ){
+ if( thePLinkType.getName().equals(partnerLinkTypeName) ) return thePLinkType;
+ } // end for
+ return null;
+ } // end findPartnerLinkType
+
+
+ /**
+ * Returns all the portTypes referenced by the process.
+ *
+ * @param theImports
+ * @param theInterfaces
+ * @param resolver
+ * @return
+ * @throws ContributionResolveException
+ */
+ @SuppressWarnings("unchecked")
+ private Collection<PortType> getAllPortTypes(List<BPELImportElement> theImports,
+ Collection<WSDLInterface> theInterfaces,
+ ModelResolver resolver,
+ ProcessorContext context) throws ContributionResolveException {
+
+ Set<PortType> thePortTypes = new HashSet<PortType>();
+ for (BPELImportElement theImport : theImports) {
+ if (theImport.getImportType().equals(BPELProcessorConstants.WSDL_NS)) {
+
+ // Find all the WSDL definitions matching the imported namespace
+ List<Definition> wsdlDefinitions = new ArrayList<Definition>();
+ WSDLDefinition theWSDL = theImport.getWSDLDefinition();
+ wsdlDefinitions.add(theWSDL.getDefinition());
+ for (WSDLDefinition importedWSDL: theWSDL.getImportedDefinitions()) {
+ wsdlDefinitions.add(importedWSDL.getDefinition());
+ }
+ for (Definition wsdlDefinition: wsdlDefinitions) {
+
+ Collection<PortType> portTypes = (Collection<PortType>)wsdlDefinition.getPortTypes().values();
+
+ // Create WSDLInterface elements for each unique PortType found
+ for (PortType portType : portTypes) {
+ if( thePortTypes.contains(portType) ) continue;
+ thePortTypes.add( portType );
+
+ WSDLObject<PortType> wsdlPortType = theWSDL.getWSDLObject(PortType.class, portType.getQName());
+ WSDLInterface wsdlInterface;
+ if (wsdlPortType != null) {
+ // Introspect the WSDL portType and add the resulting WSDLInterface to the resolver
+ try {
+ wsdlInterface = wsdlFactory.createWSDLInterface(wsdlPortType.getElement(), theWSDL, resolver, context.getMonitor());
+ wsdlInterface.setWsdlDefinition(theWSDL);
+ } catch (InvalidInterfaceException e) {
+ ContributionResolveException ce =
+ new ContributionResolveException("Unable to create WSDLInterface for portType " + portType.getQName(),e);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
+ throw ce;
+ } // end try
+ resolver.addModel(wsdlInterface, context);
+ theInterfaces.add(wsdlInterface);
+ } // end if
+ } // end for
+ }
+ }
+ } // end for
+
+ return thePortTypes;
+ } // end getAllPortTypes
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "impl-bpel-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "impl-bpel-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "impl-bpel-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java
new file mode 100644
index 0000000000..2c50ae98c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java
@@ -0,0 +1,355 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.bpel.BPELFactory;
+import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * BPEL document processor responsible for reading a BPEL file and producing necessary model info about it
+ *
+ * Handles both BPEL 1.1 documents and BPEL 2.0 documents
+ * @version $Rev$ $Date$
+ */
+public class BPELDocumentProcessor extends BaseStAXArtifactProcessor implements URLArtifactProcessor<BPELProcessDefinition> {
+
+ private final static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ private final BPELFactory factory;
+ private WSDLFactory WSDLfactory;
+ private AssemblyFactory assemblyFactory;
+
+ public BPELDocumentProcessor(FactoryExtensionPoint modelFactories) {
+ this.factory = modelFactories.getFactory(BPELFactory.class);
+ this.WSDLfactory = modelFactories.getFactory(WSDLFactory.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ }
+
+ public String getArtifactType() {
+ return "*.bpel";
+ }
+
+ public Class<BPELProcessDefinition> getModelType() {
+ return BPELProcessDefinition.class;
+ }
+
+ /**
+ * Read the BPEL Process definition file from the location identified by an artifact URL
+ * @param contributionURL - URL of the Contribution containing the Process definition
+ * @param artifactURI - URI of the artifact containing the BPEL Process definition
+ * @param artifactURL - URL of the artifact containing the BPEL Process definition
+ * @return BPELProcessDefinition - SCA model of the BPEL Process
+ */
+ public BPELProcessDefinition read(URL contributionURL, URI artifactURI, URL artifactURL, ProcessorContext context) throws ContributionReadException {
+ BPELProcessDefinition processDefinition = null;
+ try {
+ processDefinition = readProcessDefinition(artifactURL, context.getMonitor());
+ processDefinition.setURI(artifactURI.toString());
+ processDefinition.setUnresolved(true);
+ } catch (Exception e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(context.getMonitor(), "ContributionReadException", artifactURL, ce);
+ }
+
+ return processDefinition;
+ }
+
+ public void resolve(BPELProcessDefinition model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // Delegate resolving to model resolver
+ if (model != null || model.isUnresolved()) {
+ resolver.resolveModel(BPELProcessDefinition.class, model, context);
+ }
+
+ } // end resolve
+
+ /**
+ * Read a process definition.
+ *
+ * @param doc
+ * @return
+ * @throws Exception
+ */
+ private BPELProcessDefinition readProcessDefinition(URL doc, Monitor monitor) throws Exception {
+ BPELProcessDefinition processDefinition = factory.createBPELProcessDefinition();
+ processDefinition.setUnresolved(true);
+ processDefinition.setLocation(doc.toString());
+
+ InputStream is = doc.openStream();
+ XMLStreamReader reader = null;
+ try {
+ reader = inputFactory.createXMLStreamReader(is);
+
+ /*
+ * The principle here is to look for partnerLink elements, which
+ * form either services or references. A partnerLink can be EITHER -
+ * the algorithm for deciding is:
+ * 1) Explicit marking with sca:reference or sca:service attribute
+ * 2) "first use" of the partnerLink by specific BPEL activity elements:
+ * <onEvent../>, <receive../> or <pick../> elements imply a service
+ * <invoke../> implies a reference
+ */
+
+ // TODO - need to handle <scope../> elements as kind of "nested" processes
+ // - and scopes introduce the possibility of partnerLinks with the
+ // same name at different levels of scope.... (yuk!!)
+ boolean completed = false;
+ while (!completed) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ QName qname = reader.getName();
+ if (BPELProcessorConstants.PROCESS_ELEMENT.equals(qname) || BPELProcessorConstants.PROCESS_ELEMENT_20.equals(qname)) {
+ QName processName = new QName(getString(reader, BPELProcessorConstants.TARGET_NAMESPACE), getString(reader, BPELProcessorConstants.NAME_ELEMENT));
+ processDefinition.setName(processName);
+ } else if (BPELProcessorConstants.PARTNERLINK_ELEMENT.equals(qname) || BPELProcessorConstants.PARTNERLINK_ELEMENT_20.equals(qname)) {
+ processDefinition.getPartnerLinks().add(processPartnerLinkElement(reader, monitor));
+ } else if (BPELProcessorConstants.ONEVENT_ELEMENT.equals(qname) || BPELProcessorConstants.RECEIVE_ELEMENT.equals(qname) || BPELProcessorConstants.ONMESSAGE_ELEMENT.equals(qname) ||
+ BPELProcessorConstants.ONEVENT_ELEMENT_20.equals(qname) || BPELProcessorConstants.RECEIVE_ELEMENT_20.equals(qname) || BPELProcessorConstants.ONMESSAGE_ELEMENT_20.equals(qname)) {
+ processPartnerLinkAsService(reader.getAttributeValue(null, "partnerLink"), processDefinition.getPartnerLinks(), monitor);
+ } else if (BPELProcessorConstants.INVOKE_ELEMENT.equals(qname) || BPELProcessorConstants.INVOKE_ELEMENT_20.equals(qname)) {
+ processPartnerLinkAsReference(reader.getAttributeValue(null, "partnerLink"), processDefinition.getPartnerLinks(), monitor);
+ } else if (BPELProcessorConstants.IMPORT_ELEMENT.equals(qname) || BPELProcessorConstants.IMPORT_ELEMENT_20.equals(qname)) {
+ processDefinition.getImports().add(processImportElement(reader));
+ } else if (BPELProcessorConstants.VARIABLE_ELEMENT.equals(qname) || BPELProcessorConstants.VARIABLE_ELEMENT_20.equals(qname)) {
+ // deal with variables that are SCA properties through the presence of a sca-bpel:property="yes" attribute
+ Property aProperty = processVariableElement(reader);
+ if( aProperty != null ) {
+ processDefinition.getProperties().add( aProperty );
+ } // end if
+ } // end if
+ break;
+ case END_ELEMENT:
+ qname = reader.getName();
+ if (BPELProcessorConstants.PROCESS_ELEMENT.equals(qname) || BPELProcessorConstants.PROCESS_ELEMENT_20.equals(qname)) {
+ completed = true;
+ break;
+ } // end if
+ } // end switch
+ } // end while
+ } finally {
+ if (reader != null)
+ reader.close();
+ is.close();
+ } // end try
+
+ return processDefinition;
+ } // end readProcessDefinition
+
+ /**
+ * Processes a BPEL <variable/> element and creates an SCA <property/> element if the variable is
+ * marked with sca-bpel:property="yes"
+ * A BPEL <variable/> element can declare its type in one of 3 ways:
+ * 1. using @type attribute, which must reference an XSD declared type
+ * 2. using @element attribute, which must reference an XSD global element
+ * 3. using @message attribute, which must reference a WSDL defined message type
+ * @param reader - XMLStreamReader reading the BPEL process
+ * @throws ContributionReadException
+ */
+ private Property processVariableElement( XMLStreamReader reader) throws ContributionReadException {
+ String scaProperty = reader.getAttributeValue(BPELProcessorConstants.SCA_BPEL_NS, "property");
+ if( "yes".equals(scaProperty)) {
+ String varName = reader.getAttributeValue(null ,"name");
+ String varType = reader.getAttributeValue(null, "type");
+ String varElement = reader.getAttributeValue(null, "element");
+ String varMessage = reader.getAttributeValue(null, "message");
+ // Pass over this variable if there is no name, or if there is no type information
+ if( varName == null ) return null;
+ if( varType == null && varElement == null && varMessage == null ) return null;
+ QName typeQName = getQNameValue( reader, varType );
+ QName elementQName = getQNameValue( reader, varElement );
+ // TODO deal with properties declared with @message for typing
+ Property theProperty = assemblyFactory.createProperty();
+ theProperty.setName(varName);
+ theProperty.setXSDType(typeQName);
+ theProperty.setXSDElement(elementQName);
+ return theProperty;
+ } // end if
+ return null;
+
+ } // end processVariableElement
+
+ /**
+ * Processes a partnerLink element from the BPEL process and creates a
+ * BPELPartnerLink object
+ *
+ * @param reader
+ */
+ private BPELPartnerLinkElement processPartnerLinkElement(XMLStreamReader reader, Monitor monitor) throws ContributionReadException {
+ BPELPartnerLinkElement partnerLink = new BPELPartnerLinkElement( reader.getAttributeValue(null, "name"),
+ getQNameValue(reader, reader.getAttributeValue(null, "partnerLinkType")),
+ reader.getAttributeValue(null, "myRole"),
+ reader.getAttributeValue(null, "partnerRole"));
+
+ // See if there are any SCA extension attributes
+ String scaService = reader.getAttributeValue(BPELProcessorConstants.SCA_BPEL_NS, "service");
+ String scaReference = reader.getAttributeValue(BPELProcessorConstants.SCA_BPEL_NS, "reference");
+ if ((scaService != null) && (scaReference != null)) {
+ // It is incorrect to set both service & reference attributes
+ error(monitor, "PartnerLinkHasBothAttr", partnerLink, reader.getAttributeValue(null, "name"));
+ throw new ContributionReadException("BPEL PartnerLink " + reader.getAttributeValue(null, "name") +
+ " has both sca:reference and sca:service attributes set");
+ } // end if
+
+ // Set the SCA type and the related name, if present
+ if (scaService != null)
+ partnerLink.setAsService(scaService);
+ else if (scaReference != null)
+ partnerLink.setAsReference(scaReference);
+ return partnerLink;
+
+ } // end processPartnerLinkElement
+
+ /**
+ * Processes an <import../> element from the BPEL process and creates a
+ * BPELImportElement object
+ *
+ * @param reader
+ */
+ private BPELImportElement processImportElement(XMLStreamReader reader) {
+ return (new BPELImportElement(reader.getAttributeValue(null, "location"),
+ reader.getAttributeValue(null, "importType"),
+ reader.getAttributeValue(null, "namespace")));
+
+ } // end processImportElement
+
+ /**
+ * Mark a named partnerLink as a Service, unless it is already marked as a
+ * Reference
+ *
+ * @param partnerLinkName
+ * @param partnerLinks
+ */
+ private void processPartnerLinkAsService(String partnerLinkName, List<BPELPartnerLinkElement> partnerLinks, Monitor monitor) {
+ BPELPartnerLinkElement partnerLink = findPartnerLinkByName(partnerLinks, partnerLinkName);
+ if (partnerLink == null) {
+ warning(monitor, "ReferencePartnerLinkNotInList", partnerLinkName, partnerLinkName);
+ } else {
+ // Set the type of the partnerLink to "service" if not already
+ // set...
+ if (!partnerLink.isSCATyped())
+ partnerLink.setAsService(partnerLinkName);
+ } // endif
+ } // end processPartnerLinkAsReference
+
+ /**
+ * Mark a named partnerLink as a Reference, unless it is already marked as a
+ * Service
+ *
+ * @param partnerLinkName
+ * @param partnerLinks
+ */
+ private void processPartnerLinkAsReference(String partnerLinkName, List<BPELPartnerLinkElement> partnerLinks, Monitor monitor) {
+ BPELPartnerLinkElement partnerLink = findPartnerLinkByName(partnerLinks, partnerLinkName);
+ if (partnerLink == null) {
+ warning(monitor, "ReferencePartnerLinkNotInList", partnerLinkName, partnerLinkName);
+ } else {
+ // Set the type of the partnerLink to "service" if not already
+ // set...
+ if (!partnerLink.isSCATyped())
+ partnerLink.setAsReference(partnerLinkName);
+ } // endif
+ } // end processPartnerLinkAsReference
+
+ /**
+ * Finds a PartnerLink by name from a List of PartnerLinks returns null if
+ * there is no partnerLink with a matching name - returns the PartnerLink
+ * with a matching name
+ *
+ * @param partnerLinks
+ * @param partnerLinkName
+ */
+ private BPELPartnerLinkElement findPartnerLinkByName(List<BPELPartnerLinkElement> partnerLinks, String partnerLinkName) {
+ // Scan the list looking for a partner link with the supplied name
+ Iterator<BPELPartnerLinkElement> it = partnerLinks.iterator();
+ while (it.hasNext()) {
+ BPELPartnerLinkElement thePartnerLink = it.next();
+ if (thePartnerLink.getName().equals(partnerLinkName))
+ return thePartnerLink;
+ }
+ return null;
+ } // end method findPartnerLinkByName
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "impl-bpel-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "impl-bpel-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "impl-bpel-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java
new file mode 100644
index 0000000000..c149d228c6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java
@@ -0,0 +1,452 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.List;
+
+import javax.wsdl.PortType;
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.bpel.BPELFactory;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Implements a StAX artifact processor for BPEL implementations.
+ *
+ * The artifact processor is responsible for processing <implementation.bpel>
+ * elements in SCA assembly XML composite files and populating the BPEL
+ * implementation model, resolving its references to other artifacts in the SCA
+ * contribution, and optionally write the model back to SCA assembly XML.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<BPELImplementation> {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static final String PROCESS = "process";
+ private static final String IMPLEMENTATION_BPEL = "implementation.bpel";
+ private static final QName IMPLEMENTATION_BPEL_QNAME = new QName(SCA11_NS, IMPLEMENTATION_BPEL);
+
+ private AssemblyFactory assemblyFactory;
+ private BPELFactory bpelFactory;
+ private WSDLFactory wsdlFactory;
+
+
+ public BPELImplementationProcessor(FactoryExtensionPoint modelFactories) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ this.bpelFactory = modelFactories.getFactory(BPELFactory.class);
+ }
+
+ public QName getArtifactType() {
+ // Returns the QName of the XML element processed by this processor
+ return IMPLEMENTATION_BPEL_QNAME;
+ }
+
+ public Class<BPELImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return BPELImplementation.class;
+ }
+
+ public BPELImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ assert IMPLEMENTATION_BPEL_QNAME.equals(reader.getName());
+
+ // Read an <implementation.bpel> element
+ BPELImplementation implementation = null;
+
+ // Read the process attribute.
+ QName process = getAttributeValueNS(reader, PROCESS, context.getMonitor());
+ if (process == null) {
+ return implementation;
+ }
+
+ // Create and initialize the BPEL implementation model
+ implementation = bpelFactory.createBPELImplementation();
+ implementation.setProcess(process);
+ implementation.setUnresolved(true);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_BPEL_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return implementation;
+ }
+
+ public void resolve(BPELImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if( implementation != null && implementation.isUnresolved())
+ {
+ implementation.setModelResolver(resolver);
+
+ BPELProcessDefinition processDefinition = resolveBPELProcessDefinition(implementation, resolver, context);
+ //resolveBPELImports(processDefinition, resolver);
+ if(processDefinition.isUnresolved()) {
+ error(context.getMonitor(), "BPELProcessNotFound", implementation, processDefinition.getName());
+ } else {
+ implementation.setProcessDefinition(processDefinition);
+
+ // Get the component type from the process definition
+ generateComponentType( implementation, context.getMonitor() );
+
+ //set current implementation resolved
+ implementation.setUnresolved(false);
+ }
+ }
+
+ } // end resolve
+
+ public void write( BPELImplementation bpelImplementation,
+ XMLStreamWriter writer, ProcessorContext context ) throws ContributionWriteException, XMLStreamException {
+ //FIXME Deal with policy processing...
+ // Write <implementation.bpel process="..."/>
+ // policyProcessor.writePolicyPrefixes(bpelImplementation, writer);
+ writer.writeStartElement(SCA11_NS, IMPLEMENTATION_BPEL);
+ // policyProcessor.writePolicyAttributes(bpelImplementation, writer);
+
+ if (bpelImplementation.getProcess() != null) {
+ writer.writeAttribute(PROCESS, bpelImplementation.getProcess().toString() );
+ }
+
+ writer.writeEndElement();
+
+ } // end write
+
+ private BPELProcessDefinition resolveBPELProcessDefinition(BPELImplementation impl, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ QName processName = impl.getProcess();
+ BPELProcessDefinition processDefinition = this.bpelFactory.createBPELProcessDefinition();
+ processDefinition.setName(processName);
+ processDefinition.setUnresolved(true);
+
+ return resolver.resolveModel(BPELProcessDefinition.class, processDefinition, context);
+ } // end resolveBPELProcessDefinition
+
+ private void resolveBPELImports(BPELProcessDefinition processDefinition, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ for (BPELImportElement bpelImport : processDefinition.getImports()) {
+ String namespace = bpelImport.getNamespace();
+ String location = bpelImport.getLocation();
+
+ WSDLDefinition wsdl = bpelImport.getWSDLDefinition();
+ if (wsdl == null) {
+ try {
+ wsdl = wsdlFactory.createWSDLDefinition();
+ wsdl.setUnresolved(true);
+ wsdl.setNamespace(bpelImport.getNamespace());
+ wsdl.setLocation(new URI(null, bpelImport.getLocation(), null));
+ wsdl = resolver.resolveModel(WSDLDefinition.class, wsdl, context);
+
+ if(! wsdl.isUnresolved()) {
+ bpelImport.setWSDLDefinition(wsdl);
+ } else {
+ //error("BPELProcessNotFound", implementation, processDefinition.getName());
+ }
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ }
+ }
+
+
+ /**
+ * Calculates the component type of the supplied implementation and attaches it to the
+ * implementation.
+ *
+ * @param impl
+ * @throws ContributionResolveException
+ */
+ private void generateComponentType(BPELImplementation impl, Monitor monitor) throws ContributionResolveException {
+
+ // Create a ComponentType and mark it unresolved
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setUnresolved(true);
+ impl.setComponentType(componentType);
+
+ // Each partner link in the process represents either a service or a reference
+ // - or both, in the sense of involving a callback
+ BPELProcessDefinition theProcess = impl.getProcessDefinition();
+ List<BPELPartnerLinkElement> partnerLinks = theProcess.getPartnerLinks();
+
+ for (BPELPartnerLinkElement pLink : partnerLinks) {
+
+ // check that the partner link has been designated as service or
+ // reference in SCA terms
+ if (pLink.isSCATyped()) {
+ String scaName = pLink.getSCAName();
+ if (pLink.querySCAType().equals("reference")) {
+ componentType.getReferences().add(generateReference(scaName, pLink.getMyRolePortType(), pLink.getPartnerRolePortType(), theProcess.getInterfaces(), monitor));
+ } else {
+ componentType.getServices().add(generateService(scaName, pLink.getMyRolePortType(), pLink.getPartnerRolePortType(), theProcess.getInterfaces(), monitor));
+ } // end if
+ } // end if
+ } // end for
+
+ // Each SCA Property in the process becomes a Property in the ComponentType
+ for( Property property : theProcess.getProperties() ) {
+ componentType.getProperties().add(property);
+ } // end for
+
+ } // end getComponentType
+
+ /**
+ * Create an SCA reference for a partnerLink
+ * @param name - name of the reference
+ * @param myRolePT - partner link type of myRole
+ * @param partnerRolePT - partner link type of partnerRole
+ * @param theInterfaces - list of WSDL interfaces associated with the BPEL process
+ * @return
+ */
+ private Reference generateReference( String name, PortType myRolePT,
+ PortType partnerRolePT, Collection<WSDLInterface> theInterfaces, Monitor monitor) throws ContributionResolveException {
+
+ Reference reference = assemblyFactory.createReference();
+ WSDLInterfaceContract interfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ reference.setInterfaceContract(interfaceContract);
+
+ // Establish whether there is just a call interface or a call + callback interface
+ PortType callPT = null;
+ PortType callbackPT = null;
+ if (partnerRolePT != null) {
+ callPT = partnerRolePT;
+ // If the 2 port types are not the same one, there is a callback...
+ if (myRolePT != null) {
+ if (!myRolePT.getQName().equals(partnerRolePT.getQName())) {
+ callbackPT = myRolePT;
+ } // end if
+ } // end if
+ } else if (myRolePT != null) {
+ callPT = myRolePT;
+ } // end if
+
+ // No interfaces mean an error
+ if (callPT == null && callbackPT == null) {
+ error(monitor, "MyRolePartnerRoleNull", theInterfaces);
+ } // end if
+
+ // Set the name of the reference to the supplied name and the
+ // multiplicity of the reference to 1..1
+ // TODO: support other multiplicities
+ reference.setName(name);
+ reference.setMultiplicity(Multiplicity.ONE_ONE);
+
+ if (callPT != null) {
+ // Set the call interface and, if present, the callback interface
+ WSDLInterface callInterface = null;
+ for (WSDLInterface anInterface : theInterfaces) {
+ if (anInterface.getPortType().getQName().equals(callPT.getQName()))
+ callInterface = anInterface;
+ } // end for
+ if (callInterface == null) {
+ error(monitor, "NoInterfaceForPortType", theInterfaces, callPT.getQName().toString());
+ } else
+ reference.getInterfaceContract().setInterface(callInterface);
+ } // end if
+
+ // There is a callback if the partner role is not null and if the
+ // partner role port type is not the same as the port type for my role
+ if (callbackPT != null) {
+ WSDLInterface callbackInterface = null;
+ for (WSDLInterface anInterface : theInterfaces) {
+ if (anInterface.getPortType().getQName().equals(callbackPT.getQName()))
+ callbackInterface = anInterface;
+ } // end for
+ if (callbackInterface == null) {
+ error(monitor, "NoInterfaceForPortType", theInterfaces, callbackPT.getQName().toString());
+ } else
+ reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+ } // end if
+
+ return reference;
+ } // end generateReference
+
+ /**
+ * Create an SCA service for a partnerLink
+ * @param name - name of the service
+ * @param myRolePT - partner link type of myRole
+ * @param partnerRolePT - partner link type of partnerRole
+ * @param theInterfaces - list of WSDL interfaces associated with the BPEL process
+ * @return
+ */
+ private Service generateService( String name, PortType myRolePT,
+ PortType partnerRolePT, Collection<WSDLInterface> theInterfaces, Monitor monitor )
+ throws ContributionResolveException {
+ Service service = assemblyFactory.createService();
+ WSDLInterfaceContract interfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ service.setInterfaceContract(interfaceContract);
+
+ // Set the name of the service to the supplied name
+ service.setName(name);
+
+ // Establish whether there is just a call interface or a call + callback
+ // interface
+ PortType callPT = null;
+ PortType callbackPT = null;
+ if (myRolePT != null) {
+ callPT = myRolePT;
+ // If the 2 port types are not the same one, there is a callback...
+ if (partnerRolePT != null) {
+ if (!myRolePT.getQName().equals(partnerRolePT.getQName())) {
+ callbackPT = partnerRolePT;
+ } // end if
+ } // end if
+ } else if (partnerRolePT != null) {
+ callPT = partnerRolePT;
+ } // end if
+
+ // No interfaces mean an error
+ if (callPT == null && callbackPT == null) {
+ error(monitor, "MyRolePartnerRoleNull", theInterfaces);
+ } // end if
+
+ if (callPT != null) {
+ // Set the call interface and, if present, the callback interface
+ WSDLInterface callInterface = null;
+ for (WSDLInterface anInterface : theInterfaces) {
+ if (anInterface.getPortType().getQName().equals(callPT.getQName()))
+ callInterface = anInterface;
+ } // end for
+ if (callInterface == null) {
+ error(monitor, "NoInterfaceForPortType", theInterfaces, callPT.getQName().toString());
+ } else
+ service.getInterfaceContract().setInterface(callInterface);
+ } // end if
+
+ // There is a callback if the partner role is not null and if the
+ // partner role port type is not the same as the port type for my role
+ if (callbackPT != null) {
+ WSDLInterface callbackInterface = null;
+ for (WSDLInterface anInterface : theInterfaces) {
+ if (anInterface.getPortType().getQName().equals(callbackPT.getQName()))
+ callbackInterface = anInterface;
+ } // end for
+ if (callbackInterface == null) {
+ error(monitor, "NoInterfaceForPortType", theInterfaces, callbackPT.getQName().toString());
+ } else
+ service.getInterfaceContract().setCallbackInterface(callbackInterface);
+ } // end if
+
+ return service;
+ } // end generateService
+
+ /**
+ * Returns a QName from its string representation in a named attribute of an XML element
+ * supplied in an XMLStreamReader
+ *
+ * QName attributes of an XML element (such as BPEL process) is presented in one of
+ * two alternative formats:
+ * 1) In the form of a local name with a prefix, with the prefix referencing a namespace
+ * URI declaration elsewhere in the composite (typically on the composite element)
+ *
+ * ie: nms:SomeName
+ * xmlns:nms="http://example.com/somenamespace"
+ *
+ * 2) In the XML Namespaces recommendation format (see http://jclark.com/xml/xmlns.htm )
+ * where the namespace URI and the local name are encoded into a single string, with the
+ * namespace URI enclosed between a pair of braces {...}
+ *
+ * ie: {http://example.com/somenamespace}SomeName
+ */
+ private QName getAttributeValueNS(XMLStreamReader reader, String attribute, Monitor monitor) {
+ String fullValue = reader.getAttributeValue(null, attribute);
+ if (fullValue == null) {
+ error(monitor, "AttributeProcessMissing", reader);
+ return null;
+ }
+
+ // Deal with the attribute in the XML Namespaces recommendation format
+ // - trim off any leading/trailing spaces and check that the first
+ // character is '{'
+ if (fullValue.trim().charAt(0) == '{') {
+ try {
+ // Attempt conversion to a QName object
+ QName theProcess = QName.valueOf(fullValue);
+ return theProcess;
+ } catch (IllegalArgumentException e) {
+ // This exception happens if the attribute begins with '{' but
+ // doesn't conform
+ // to the XML Namespaces recommendation format
+ error(monitor, "AttributeWithoutNamespace", reader, attribute, fullValue);
+ return null;
+ }
+ } // endif
+
+ // Deal with the attribute in the local name + prefix format
+ if (fullValue.indexOf(":") < 0) {
+ error(monitor, "AttributeWithoutPrefix", reader, attribute, fullValue);
+ return null;
+ }
+ String prefix = fullValue.substring(0, fullValue.indexOf(":"));
+ String name = fullValue.substring(fullValue.indexOf(":") + 1);
+ String nsUri = reader.getNamespaceContext().getNamespaceURI(prefix);
+ if (nsUri == null) {
+ error(monitor, "AttributeUnrecognizedNamespace", reader, attribute, fullValue);
+ return null;
+ }
+ return new QName(nsUri, name, prefix);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "impl-bpel-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java
new file mode 100644
index 0000000000..959d1ec5d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.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.sca.implementation.bpel.xml;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+
+/**
+ * Represents an <import.../> element in a BPEL process
+ * - this has attributes:
+ * location
+ * importType
+ * namespace
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELImportElement {
+
+ private String location;
+ private String importType;
+ private String namespace;
+ private WSDLDefinition theWSDL = null;
+
+ public BPELImportElement(String location, String importType, String namespace) {
+ this.location = location;
+ this.importType = importType;
+ this.namespace = namespace;
+ }
+
+ public String getImportType() {
+ return importType;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setWSDLDefinition(WSDLDefinition theDefinition) {
+ theWSDL = theDefinition;
+ }
+
+ public WSDLDefinition getWSDLDefinition() {
+ return theWSDL;
+ }
+
+} // end class BPELImportElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java
new file mode 100644
index 0000000000..ea645e1304
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.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.sca.implementation.bpel.xml;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a <partnerLink.../> element in a BPEL process
+ * - this has attributes:
+ * name
+ * partnerLinkType
+ * myRole
+ * partnerRole
+ * - plus zero or more property elements as children
+ *
+ * The partnerlink may also be given an SCA Type - either of service or of reference - this must
+ * generally be calculated and set on the partnerLink by inspecting the BPEL process
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELPartnerLinkElement {
+
+ private String REFERENCE_TYPE = "reference";
+ private String SERVICE_TYPE = "service";
+ private String name;
+ private QName partnerLinkType;
+ private BPELPartnerLinkTypeElement pLinkType = null;
+ private String myRole;
+ private String partnerRole;
+ private String scaName; // Holds the SCA reference or service name
+ private String scaType = null; // Holds the SCA type = null | service | reference
+
+ public BPELPartnerLinkElement(String name,
+ QName partnerLinkType,
+ String myRole,
+ String partnerRole ) {
+ this.name = name;
+ this.partnerLinkType = partnerLinkType;
+ this.myRole = myRole;
+ this.partnerRole = partnerRole;
+
+ scaName = null;
+ }
+
+ public QName getPartnerLinkType() {
+ return partnerLinkType;
+ }
+
+ public void setPartnerLinkType( BPELPartnerLinkTypeElement pLinkType ) {
+ this.pLinkType = pLinkType;
+ }
+
+
+ public PortType getMyRolePortType() {
+ return getRolePortType( myRole );
+ }
+
+ public PortType getPartnerRolePortType() {
+ return getRolePortType( partnerRole );
+ }
+
+ private PortType getRolePortType( String theRole ) {
+ if (theRole == null || theRole.length() == 0) {
+ return null;
+ } // end if
+ if( pLinkType == null ) {
+ throw new IllegalStateException("BPELPartnerLinkElement: " + this.name + " has no Partner Link type object set");
+ } // end if
+ if (theRole.equals(pLinkType.getRole1Name())) {
+ return pLinkType.getRole1pType();
+ } else if (theRole.equals(pLinkType.getRole2Name())) {
+ return pLinkType.getRole2pType();
+ } // end if
+ return null;
+ } // end getRolePortType
+
+ public String getName() {
+ return name;
+ }
+
+ public String getMyRole() {
+ return myRole;
+ }
+
+ public String getPartnerRole() {
+ return partnerRole;
+ }
+
+ public void setSCAName( String name ) {
+ scaName = name;
+ }
+
+ public String getSCAName() {
+ return scaName;
+ }
+
+ public boolean isSCATyped() {
+ return ( !(scaType == null) );
+ }
+
+ public void setAsReference( String name ) {
+ scaType = REFERENCE_TYPE;
+ scaName = name;
+ }
+
+ public void setAsService( String name ) {
+ scaType = SERVICE_TYPE;
+ scaName = name;
+ }
+
+ public String querySCAType() {
+ return scaType;
+ }
+
+} // end class BPELPartnerLinkElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java
new file mode 100644
index 0000000000..8786837e97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.bpel.xml;
+
+ import javax.wsdl.PortType;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a <partnerLinkType.../> element related to a BPEL process
+ * - this has attributes:
+ * name
+ * Role1 name
+ * Role1 portType
+ * Role2 name
+ * Role2 portType
+ *
+ * - in the XML the 2 roles are child elements of the partnerLinkType element, but there
+ * seems little point in reflecting this back into this model - it is simpler to include
+ * both roles within the representation of the partnerLinkType itself
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELPartnerLinkTypeElement implements ExtensibilityElement {
+
+ private QName name;
+ private String Role1name = null;
+ private QName Role1porttype = null;
+ private PortType Role1pType = null;
+ private String Role2name = null;
+ private QName Role2porttype = null;
+ private PortType Role2pType = null;
+ private QName elementType = null;
+ private Boolean required = false;
+
+ public BPELPartnerLinkTypeElement(QName name) {
+ this.name = name;
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ public void setRole1(String name, QName portType, PortType pType) {
+ Role1name = name;
+ Role1porttype = portType;
+ Role1pType = pType;
+ }
+
+ public void setRole2(String name, QName portType, PortType pType) {
+ Role2name = name;
+ Role2porttype = portType;
+ Role2pType = pType;
+ }
+
+ public String getRole1Name() {
+ return Role1name;
+ }
+
+ public String getRole2Name() {
+ return Role2name;
+ }
+
+ public QName getRole1PortType() {
+ return Role1porttype;
+ }
+
+ public QName getRole2PortType() {
+ return Role2porttype;
+ }
+
+ public PortType getRole1pType() {
+ return Role1pType;
+ }
+
+ public PortType getRole2pType() {
+ return Role2pType;
+ }
+
+ public QName getElementType() {
+ return elementType;
+ }
+
+ public Boolean getRequired() {
+ return required;
+ }
+
+ public void setElementType(QName elementType) {
+ this.elementType = elementType;
+ }
+
+ public void setRequired(java.lang.Boolean required) {
+ this.required = required;
+ }
+
+ /**
+ * toString method to return a description of this BPELPartnerLinkType useful for debugging
+ */
+ public String toString() {
+ return "BPELPartnerLinkType: " + name.toString();
+ } // end method toString
+
+} // end BPELPartnerLinkType
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELProcessorConstants.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELProcessorConstants.java
new file mode 100644
index 0000000000..952ba9fe78
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELProcessorConstants.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.sca.implementation.bpel.xml;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * BPEL Constants
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELProcessorConstants {
+ static final String SCA_BPEL_NS = "http://docs.oasis-open.org/ns/opencsa/sca-bpel/200801";
+ static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/";
+
+ // BPEL 1.1
+ static final String BPEL_NS = "http://schemas.xmlsoap.org/ws/2004/03/business-process/";
+ static final String BPEL_PLINK_NS = "http://schemas.xmlsoap.org/ws/2004/03/partner-link/";
+ final static String NAME_ELEMENT = "name";
+ static final String LINKTYPE_NAME = "partnerLinkType";
+ final static String TARGET_NAMESPACE = "targetNamespace";
+ static final QName PROCESS_ELEMENT = new QName(BPEL_NS, "process");
+ static final QName PARTNERLINK_ELEMENT = new QName(BPEL_NS, "partnerLink");
+ static final QName ONEVENT_ELEMENT = new QName(BPEL_NS, "onEvent");
+ static final QName RECEIVE_ELEMENT = new QName(BPEL_NS, "receive");
+ static final QName ONMESSAGE_ELEMENT = new QName(BPEL_NS, "onMessage");
+ static final QName INVOKE_ELEMENT = new QName(BPEL_NS, "invoke");
+ static final QName IMPORT_ELEMENT = new QName(BPEL_NS, "import");
+ static final QName VARIABLE_ELEMENT = new QName(BPEL_NS, "variable");
+ static final QName LINKTYPE_ELEMENT = new QName(BPEL_PLINK_NS, LINKTYPE_NAME);
+
+ // BPEL 2.0
+ static final String BPEL_NS_20 = "http://docs.oasis-open.org/wsbpel/2.0/process/executable";
+ static final String BPEL_PLINK_NS_20 = "http://docs.oasis-open.org/wsbpel/2.0/plnktype";
+ static final QName PROCESS_ELEMENT_20 = new QName(BPEL_NS_20, "process");
+ static final QName PARTNERLINK_ELEMENT_20 = new QName(BPEL_NS_20, "partnerLink");
+ static final QName ONEVENT_ELEMENT_20 = new QName(BPEL_NS_20, "onEvent");
+ static final QName RECEIVE_ELEMENT_20 = new QName(BPEL_NS_20, "receive");
+ static final QName ONMESSAGE_ELEMENT_20 = new QName(BPEL_NS_20, "onMessage");
+ static final QName INVOKE_ELEMENT_20 = new QName(BPEL_NS_20, "invoke");
+ static final QName IMPORT_ELEMENT_20 = new QName(BPEL_NS_20, "import");
+ static final QName VARIABLE_ELEMENT_20 = new QName(BPEL_NS_20, "variable");
+ static final QName LINKTYPE_ELEMENT_20 = new QName(BPEL_PLINK_NS_20, LINKTYPE_NAME);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..ffb781d3b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.implementation.bpel.xml.BPELImplementationProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.bpel,model=org.apache.tuscany.sca.implementation.bpel.BPELImplementation
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..1e11d2fc0c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/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.implementation.bpel.xml.BPELDocumentProcessor;type=.bpel,model=org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..d5b5b15984
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -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.
+
+org.apache.tuscany.sca.implementation.bpel.xml.BPELDocumentModelResolver;model=org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.bpel.BPELFactory b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.bpel.BPELFactory
new file mode 100644
index 0000000000..34af3316d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.bpel.BPELFactory
@@ -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.
+
+org.apache.tuscany.sca.implementation.bpel.impl.BPELFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/impl-bpel-validation-messages.properties b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/impl-bpel-validation-messages.properties
new file mode 100644
index 0000000000..b6d8bdc0f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/main/resources/impl-bpel-validation-messages.properties
@@ -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.
+#
+#
+CannotResolveWSDLReference = BPELDocumentProcessor:resolve - unable to resolve WSDL referenced by BPEL import WSDL location: {0} WSDLNamespace: {1}
+ContributionReadException = ContributionReadException occured due to :
+PartnerLinkNoMatchingType = PartnerLink {0} has no matching partner link type
+PartnerLinkTypeNoRoles = PartnerLinkType {0} has no Roles defined
+ContributionResolveException = ContributionResolveException occured due to :
+PartnerLinkHasBothAttr = BPEL PartnerLink {0} has both sca:reference and sca:service attributes set
+ReferencePartnerLinkNotInList = BPEL TypeLoader - element references partnerLink {0} not in the list
+MyRolePartnerRoleNull = Error: myRole and partnerRole port types are both null
+NoInterfaceForPortType = Interface not found for port type {0}
+AttributeProcessMissing = Attribute 'process' is missing.
+AttributeWithoutNamespace = Attribute {0} with value {1} in your composite should be of the form {namespaceURI}localname
+AttributeWithoutPrefix = Attribute {0} with value {1} in your composite should be prefixed (process=\"prefix:name\").
+AttributeUnrecognizedNamespace = Attribute {0} with value {1} in your composite has un unrecognized namespace prefix.
+BPELProcessNotFound = Can't find BPEL Process : {0} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELDocumentProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELDocumentProcessorTestCase.java
new file mode 100644
index 0000000000..1ef972342a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELDocumentProcessorTestCase.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.bpel;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BPELDocumentProcessorTestCase extends TestCase {
+
+ protected static final String BPEL_PROCESS_FILE = "helloworld/helloworld.bpel";
+
+ private URLArtifactProcessor<Object> documentProcessor;
+ private ProcessorContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+ }
+
+ public void testLoadBPELProcessDefinition() throws Exception {
+ URI processURI = getClass().getClassLoader().getResource(BPEL_PROCESS_FILE).toURI();
+ URL processLocation = getClass().getClassLoader().getResource(BPEL_PROCESS_FILE);
+ BPELProcessDefinition bpelProcessDefinition = (BPELProcessDefinition)documentProcessor.read(null, processURI, processLocation, context);
+
+ assertNotNull(bpelProcessDefinition);
+ assertEquals(new QName("http://tuscany.apache.org/implementation/bpel/example/helloworld", "HelloWorld"), bpelProcessDefinition.getName());
+ assertEquals(processLocation.toString(), bpelProcessDefinition.getLocation());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementationProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementationProcessorTestCase.java
new file mode 100644
index 0000000000..37e5660636
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementationProcessorTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.bpel;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.monitor.Problem;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BPELImplementationProcessorTestCase extends TestCase {
+
+ private static final String COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:hns=\"http://tuscany.apache.org/implementation/bpel/example/helloworld\" targetNamespace=\"http://bpel\" name=\"bpel\">"
+ + " <component name=\"BPELHelloWorldComponent\">"
+ + " <implementation.bpel process=\"hns:HelloWorld\" />"
+ + " </component>"
+ + "</composite>";
+
+ private static final String COMPOSITE_INVALID =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:hns=\"http://tuscany.apache.org/implementation/bpel/example/helloworld\" targetNamespace=\"http://bpel\" name=\"bpel\">"
+ + " <component name=\"BPELHelloWorldComponent\">"
+ + " <implementation.bpel/>"
+ + " </component>"
+ + "</composite>";
+
+ private XMLInputFactory inputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ @Override
+ protected void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ // Create a monitor
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ /**
+ * Test parsing valid composite definition. Valid composite populated with correct values expected.
+ * @throws Exception
+ */
+ public void testLoadValidComposite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ BPELImplementation implementation = (BPELImplementation)composite.getComponents().get(0).getImplementation();
+
+ assertNotNull(implementation);
+ assertEquals(new QName("http://tuscany.apache.org/implementation/bpel/example/helloworld", "HelloWorld"), implementation.getProcess());
+ }
+
+ /**
+ * Test parsing invalid composite definition. Exception should be thrown
+ * @throws Exception
+ */
+ public void testLoadInvalidComposite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID));
+ staxProcessor.read(reader, context);
+ Problem problem = context.getMonitor().getLastProblem();
+ assertNotNull(problem);
+ assertEquals("AttributeProcessMissing", problem.getMessageId());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/resources/helloworld/helloworld.bpel b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..8cf91adc2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/resources/helloworld/helloworld.bpel
@@ -0,0 +1,66 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="helloworld.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"/>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink" partnerLinkType="test:HelloPartnerLinkType" myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="helloMessage" messageType="test:HelloMessage"/>
+ <variable name="tmpVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessage"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from variable="helloMessage" part="TestPart"/>
+ <to variable="tmpVar"/>
+ </copy>
+ <copy>
+ <from>concat($tmpVar,' World')</from>
+ <to variable="helloMessage" part="TestPart"/>
+ </copy>
+ </assign>
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessage"/>
+ </sequence>
+</process>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/resources/helloworld/helloworld.wsdl b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..610bda3cc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-bpel/src/test/resources/helloworld/helloworld.wsdl
@@ -0,0 +1,82 @@
+<?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 name="helloworld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="message" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part element="tns:hello" name="TestPart"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="TestIn">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="TestOut">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8085/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/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/sebastien/java/embed/modules/implementation-java-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..af05a6b540
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,60 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.java.context;use
+ s:="org.apache.tuscany.sca.core.context,org.apache.tuscany.sca.core.f
+ actory,org.apache.tuscany.sca.implementation.java,org.apache.tuscany.
+ sca.core.scope,org.apache.tuscany.sca.implementation.java.injection";
+ version="2.0.0",org.apache.tuscany.sca.implementation.java.injection;us
+ es:="org.apache.tuscany.sca.databinding,org.apache.tuscany.sca.databi
+ nding.xml,org.apache.tuscany.sca.runtime,org.apache.tuscany.sca.inter
+ facedef.util,org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.c
+ ontext,org.apache.tuscany.sca.databinding.impl,org.apache.tuscany.sca
+ .core.context,org.apache.tuscany.sca.implementation.java.introspect,o
+ rg.apache.tuscany.sca.implementation.java,org.apache.tuscany.sca.inte
+ rfacedef,org.w3c.dom,javax.xml.namespace,org.apache.tuscany.sca.invoc
+ ation,org.apache.tuscany.sca.core.factory,org.apache.tuscany.sca.inte
+ rfacedef.impl,org.oasisopen.sca,org.apache.tuscany.sca.core.invocation";ve
+ rsion="2.0.0"
+Private-Package: org.apache.tuscany.sca.implementation.java.invocation
+ ;version="2.0.0",org.apache.tuscany.sca.implementation.java.module;vers
+ ion="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Java Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Java Implementation Model
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.context;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.core.scope;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.context;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.injection;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.invocation;resolution:=optional,
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.java.runtim
+ e
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/pom.xml
new file mode 100644
index 0000000000..e6c5af42ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/pom.xml
@@ -0,0 +1,57 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <name>Apache Tuscany SCA Implementation Java Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java
new file mode 100644
index 0000000000..e2d99852d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+
+/**
+ * Interface for a factory that returns an injected component instance.
+ * This is used by a Component implementation to create new instances of
+ * application implementation objects as determined by the component scope's
+ * lifecycle.
+ * <p/>
+ * The implementation of this interface may be supplied by the user,
+ * may be generated during deployment, or may be dynamic.
+ *
+ * @version $Rev$ $Date$
+ * @param <T> Type of the instance generated by the factory.
+ */
+public interface InstanceFactory<T> {
+ /**
+ * Creates a new instance of the component.
+ * All injected values must be set but any @Init methods must not have been invoked.
+ *
+ * @return A wrapper for the created component instance.
+ */
+ InstanceWrapper<T> newInstance();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java
new file mode 100644
index 0000000000..df21e013f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.context;
+
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface InstanceFactoryProvider<T> {
+ /**
+ * Return the implementation class.
+ *
+ * @return the implementation class.
+ */
+ Class<T> getImplementationClass();
+
+ /**
+ * Sets an object factory for an injection site
+ *
+ * @param element the injection site name
+ * @param objectFactory the object factory
+ */
+ void setObjectFactory(JavaElementImpl element, ObjectFactory<?> objectFactory);
+
+ /**
+ * Create an instance factory that can be used to create component instances.
+ *
+ * @return a new instance factory
+ */
+ InstanceFactory<T> createFactory();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
new file mode 100644
index 0000000000..f5d9860130
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.context;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReflectiveInstanceFactory<T> implements InstanceFactory<T> {
+ private final Constructor<T> ctr;
+ private final ObjectFactory<?>[] ctrArgs;
+ private final Injector<T>[] injectors;
+ private final EventInvoker<T> initInvoker;
+ private final EventInvoker<T> destroyInvoker;
+ private final Injector<T>[] callbackInjectors;
+
+ public ReflectiveInstanceFactory(Constructor<T> ctr,
+ ObjectFactory<?>[] ctrArgs,
+ Injector<T>[] injectors,
+ Injector<T>[] callbackInjectors,
+ EventInvoker<T> initInvoker,
+ EventInvoker<T> destroyInvoker) {
+ this.ctr = ctr;
+ this.ctrArgs = ctrArgs;
+ this.injectors = injectors;
+ this.callbackInjectors = callbackInjectors;
+ this.initInvoker = initInvoker;
+ this.destroyInvoker = destroyInvoker;
+ }
+
+ public InstanceWrapper<T> newInstance() {
+ T instance;
+ try {
+ if (ctrArgs != null) {
+ Object[] args = new Object[ctrArgs.length];
+ for (int i = 0; i < args.length; i++) {
+ args[i] = ctrArgs[i].getInstance();
+ }
+ instance = ctr.newInstance(args);
+ } else {
+ instance = ctr.newInstance();
+ }
+ } catch (InstantiationException e) {
+ String name = ctr.getDeclaringClass().getName();
+ throw new AssertionError("Class is not instantiable [" + name + "]");
+ } catch (IllegalAccessException e) {
+ String name = ctr.getName();
+ throw new AssertionError("Constructor is not accessible [" + name + "]");
+ } catch (
+ InvocationTargetException e) {
+ String name = ctr.getName();
+ throw new ObjectCreationException("Exception thrown by constructor: " + name, e);
+ }
+
+ if (injectors != null) {
+ for (Injector<T> injector : injectors) {
+ //FIXME Injectors should never be null
+ if (injector != null)
+ try {
+ injector.inject(instance);
+ } catch (Exception e) {
+ if (destroyInvoker != null) {
+ destroyInvoker.invokeEvent(instance);
+ }
+ throw new ObjectCreationException("Exception invoking injector - " + e.getMessage(), e);
+ }
+ }
+ }
+
+ return new ReflectiveInstanceWrapper<T>(instance, initInvoker, destroyInvoker, callbackInjectors);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java
new file mode 100644
index 0000000000..a3ed16dde5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.core.scope.TargetDestructionException;
+import org.apache.tuscany.sca.core.scope.TargetInitializationException;
+import org.apache.tuscany.sca.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReflectiveInstanceWrapper<T> implements InstanceWrapper<T> {
+ private final EventInvoker<T> initInvoker;
+ private final EventInvoker<T> destroyInvoker;
+ private final T instance;
+ private final Injector<T>[] callbackInjectors;
+
+ public ReflectiveInstanceWrapper(T instance, EventInvoker<T> initInvoker, EventInvoker<T> destroyInvoker, Injector<T>[] callbackInjectors) {
+ this.instance = instance;
+ this.initInvoker = initInvoker;
+ this.destroyInvoker = destroyInvoker;
+ this.callbackInjectors = callbackInjectors;
+ }
+
+ public T getInstance() {
+ return instance;
+ }
+
+ public void start() throws TargetInitializationException {
+ if (initInvoker != null) {
+ try {
+ initInvoker.invokeEvent(instance);
+ } catch (Exception e) {
+ try {
+ stop();
+ } catch (TargetDestructionException e1) {
+ throw new TargetInitializationException("TargetDestructionException while handling init exception", e);
+ }
+ throw new TargetInitializationException(e);
+ }
+ }
+ }
+
+ public void stop() throws TargetDestructionException {
+ if (destroyInvoker != null) {
+ destroyInvoker.invokeEvent(instance);
+ }
+ }
+
+ public Injector<T>[] getCallbackInjectors() {
+ return this.callbackInjectors;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/databinding/PropertyDataTypeProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/databinding/PropertyDataTypeProcessor.java
new file mode 100644
index 0000000000..16de5bbefb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/databinding/PropertyDataTypeProcessor.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.databinding;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ *
+ */
+public class PropertyDataTypeProcessor extends BaseJavaClassVisitor {
+ private Mediator mediator;
+
+ /**
+ * @param registry
+ */
+ public PropertyDataTypeProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.mediator = utilityExtensionPoint.getUtility(Mediator.class);
+ }
+
+ /**
+ * Introspect the property
+ * @param javaElement
+ * @return
+ */
+ private void introspect(Property property, JavaElementImpl javaElement) {
+ // XMLType xmlType = new XMLType(property.getXSDElement(), property.getXSDType());
+ // property.getDataType().setLogical(xmlType);
+ mediator.getDataBindings().introspectType(property.getDataType(), null);
+ }
+
+ @Override
+ public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ for (Property property : type.getProperties()) {
+ String name = property.getName();
+ JavaElementImpl element = type.getPropertyMembers().get(name);
+ introspect(property, element);
+ DataType dt = property.getDataType();
+ if (dt.getLogical() instanceof XMLType) {
+ XMLType xmlType = (XMLType)dt.getLogical();
+ property.setXSDType(xmlType.getTypeName());
+ property.setXSDElement(xmlType.getElementName());
+ } else {
+ Class<?> baseType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+ property.setXSDType(JavaXMLMapper.getXMLType(baseType));
+ }
+ }
+ super.visitEnd(clazz, type);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java
new file mode 100644
index 0000000000..2513c63e38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.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.sca.implementation.java.injection;
+
+import java.lang.reflect.Array;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Resolves targets configured in a multiplicity by delegating to object factories and returning an <code>Array</code>
+ * containing object instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class ArrayMultiplicityObjectFactory implements ObjectFactory<Object> {
+
+ private ObjectFactory[] factories;
+
+ private Class interfaceType;
+
+ public ArrayMultiplicityObjectFactory(Class interfaceType, List<ObjectFactory<?>> factories) {
+ assert interfaceType != null : "Interface type was null";
+ assert factories != null : "Object factories were null";
+ this.interfaceType = interfaceType;
+ this.factories = factories.toArray(new ObjectFactory[factories.size()]);
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ Object array = Array.newInstance(interfaceType, factories.length);
+ for (int i = 0; i < factories.length; i++) {
+ Array.set(array, i, factories[i].getInstance());
+ }
+ return array;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java
new file mode 100644
index 0000000000..d8eef18c74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.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.java.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+
+/**
+ * Implementations inject a pre-configured context type (interface) on an instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContextInjector<S, T> extends Injector<T> {
+
+ void setContext(S context) throws ObjectCreationException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java
new file mode 100644
index 0000000000..4d97e72bd0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.injection;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link org.apache.tuscany.sca.core.factory.ObjectFactory} on a given field
+ *
+ * @version $Rev$ $Date$
+ */
+public class FieldInjector<T> implements Injector<T> {
+
+ private final Field field;
+
+ private final ObjectFactory<?> objectFactory;
+
+ /**
+ * Create an injector and have it use the given <code>ObjectFactory</code> to inject a value on the instance using
+ * the reflected <code>Field</code>
+ */
+ public FieldInjector(Field pField, ObjectFactory<?> objectFactory) {
+ field = pField;
+ // Allow privileged access to set accessibility. Requires ReflectPermission
+ // in security policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ field.setAccessible(true); // ignore Java accessibility
+ return null;
+ }
+ });
+
+ this.objectFactory = objectFactory;
+ }
+
+ /**
+ * Inject a new value on the given instance
+ */
+ public void inject(T instance) throws ObjectCreationException {
+ inject(instance, objectFactory.getInstance());
+ }
+
+ public void inject(T instance, Object value) {
+ try {
+ field.set(instance, value);
+ } catch (IllegalAccessException e) {
+ throw new ObjectCreationException("Field is not accessible [" + field + "]", e);
+ }
+ }
+
+ public Class<?> getType() {
+ return field.getType();
+ }
+
+ public Type getGenericType() {
+ return field.getGenericType();
+ }
+
+ public void injectNull(T instance) throws ObjectCreationException {
+ inject(instance, null);
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java
new file mode 100644
index 0000000000..8bc2dce76c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.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.sca.implementation.java.injection;
+
+
+/**
+ * Root unchecked exception for the injection package
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class InjectionRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = -2264137603099898773L;
+
+ public InjectionRuntimeException() {
+ super();
+ }
+
+ public InjectionRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InjectionRuntimeException(String message) {
+ super(message);
+ }
+
+ public InjectionRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java
new file mode 100644
index 0000000000..f0208c4e71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+
+/**
+ * Implementations inject a pre-configured value on an instance
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Injector<T> {
+
+ /**
+ * Inject a value on the given instance
+ */
+ void inject(T instance) throws ObjectCreationException;
+ void injectNull(T instance) throws ObjectCreationException;
+ Class<?> getType();
+ Type getGenericType();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java
new file mode 100644
index 0000000000..5aeebcca36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidAccessorException extends InjectionRuntimeException {
+ private static final long serialVersionUID = 9196299279363310978L;
+
+ public InvalidAccessorException() {
+ super();
+ }
+
+ public InvalidAccessorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidAccessorException(String message) {
+ super(message);
+ }
+
+ public InvalidAccessorException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java
new file mode 100644
index 0000000000..a190b761e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.injection;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
+ private Mediator mediator = null;
+ private SimpleTypeMapper simpleTypeMapper;
+ private boolean isSimpleType;
+
+ public JavaPropertyValueObjectFactory(ExtensionPointRegistry registry) {
+ UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.mediator = utilityExtensionPoint.getUtility(Mediator.class);
+ this.simpleTypeMapper = utilityExtensionPoint.getUtility(SimpleTypeMapper.class);
+ }
+
+ public JavaPropertyValueObjectFactory(Mediator mediator) {
+ this.mediator = mediator;
+ }
+
+ public ObjectFactory createValueFactory(Property property, Object propertyValue, JavaElementImpl javaElement) {
+ Document doc = (Document)propertyValue;
+ List<Node> nodes = getValues(doc);
+ Class<?> javaType = JavaIntrospectionHelper.getBaseType(javaElement.getType(), javaElement.getGenericType());
+ if (property.isMany()) {
+ if (javaElement.getType().isArray()) {
+ return new ArrayObjectFactoryImpl(property, nodes, javaType);
+ } else {
+ return new ListObjectFactoryImpl(property, nodes, javaType);
+ }
+ } else {
+ Object value = null;
+ if (!nodes.isEmpty()) {
+ value = nodes.get(0);
+ }
+ return new ObjectFactoryImpl(property, value, javaType);
+
+ }
+ }
+
+ public ObjectFactory createValueFactory(Property property, Object propertyValue, Class<?> javaType) {
+ Document doc = (Document)propertyValue;
+ List<Node> nodes = getValues(doc);
+ if (property.isMany()) {
+ return new ListObjectFactoryImpl(property, nodes, javaType);
+ } else {
+ Object value = null;
+ if (!nodes.isEmpty()) {
+ value = nodes.get(0);
+ }
+ return new ObjectFactoryImpl(property, value, javaType);
+ }
+ }
+
+ public <B> B createPropertyValue(ComponentProperty property, Class<B> type) {
+
+ validateTypes(property, type);
+
+ ObjectFactory<B> factory = this.createValueFactory(property, property.getValue(), type);
+ return factory.getInstance();
+ }
+
+ private <B> void validateTypes(ComponentProperty property, Class<B> type) {
+ // JAXB seems to do some strange things with conversions, so
+ // we can't rely on the databinding conversion from Node->Java to catch
+ // incompatible types.
+
+ DataType prop1 = property.getProperty().getDataType();
+
+ if ( (prop1 != null) && (type.isAssignableFrom(prop1.getPhysical())) ) {
+ return;
+ } else if ( simpleTypeMapper.getXMLType(type) != null ) {
+ if ( simpleTypeMapper.getXMLType(type).getQName().equals(property.getXSDType()))
+ return;
+ } else if ( isSimpleType(property) ) {
+ if ( type.isAssignableFrom(simpleTypeMapper.getJavaType(property.getXSDType())))
+ return;
+ }
+
+ throw new IllegalArgumentException("Property type " + prop1.getPhysical().getName() + " is not compatible with " + type.getName());
+
+ }
+
+ abstract class ObjectFactoryImplBase implements ObjectFactory {
+ protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl();
+ protected Property property;
+ protected Object propertyValue;
+ protected Class<?> javaType;
+ protected DataType<XMLType> sourceDataType;
+ protected DataType<?> targetDataType;
+
+ public ObjectFactoryImplBase(Property property, Object propertyValue, Class<?> javaType) {
+ this.property = property;
+ this.propertyValue = propertyValue;
+ this.javaType = javaType;
+ sourceDataType =
+ new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class,
+ new XMLType(null, this.property.getXSDType()));
+
+ targetDataType = property.getDataType();
+ if (targetDataType == null) {
+ TypeInfo typeInfo = null;
+ if (this.property.getXSDType() != null) {
+ if (simpleTypeMapper.isSimpleXSDType(this.property.getXSDType())) {
+ typeInfo = new TypeInfo(property.getXSDType(), true, null);
+ } else {
+ typeInfo = new TypeInfo(property.getXSDType(), false, null);
+ }
+ } else {
+ typeInfo = new TypeInfo(property.getXSDType(), false, null);
+ }
+
+ XMLType xmlType = new XMLType(typeInfo);
+ String dataBinding = null; // (String)property.getExtensions().get(DataBinding.class.getName());
+ if (dataBinding != null) {
+ targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+ } else {
+ targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+ mediator.getDataBindings().introspectType(targetDataType, null);
+ }
+ }
+ }
+ }
+
+ class ObjectFactoryImpl extends ObjectFactoryImplBase {
+ public ObjectFactoryImpl(Property property, Object propertyValue, Class<?> javaType) {
+ super(property, propertyValue, javaType);
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ if (isSimpleType) {
+ try {
+ return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
+ } catch (NumberFormatException ex) {
+ throw new ObjectCreationException("Failed to create instance for property " + property.getName()
+ + " with value "
+ + propertyValue, ex);
+ } catch (IllegalArgumentException ex) {
+ throw new ObjectCreationException("Failed to create instance for property " + property.getName()
+ + " with value "
+ + propertyValue, ex);
+ }
+ } else {
+ return mediator.mediate(propertyValue, sourceDataType, targetDataType, null);
+ // return null;
+ }
+ }
+ }
+
+ class ListObjectFactoryImpl extends ObjectFactoryImplBase {
+ public ListObjectFactoryImpl(Property property, List<?> propertyValues, Class<?> javaType) {
+ super(property, propertyValues, javaType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<?> getInstance() throws ObjectCreationException {
+ if (isSimpleType) {
+ List<Object> values = new ArrayList<Object>();
+ for (String aValue : (List<String>)propertyValue) {
+ try {
+ values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+ } catch (NumberFormatException ex) {
+ throw new ObjectCreationException("Failed to create instance for property " + property
+ .getName()
+ + " with value "
+ + aValue
+ + " from value list of "
+ + propertyValue, ex);
+ } catch (IllegalArgumentException ex) {
+ throw new ObjectCreationException("Failed to create instance for property " + property
+ .getName()
+ + " with value "
+ + aValue
+ + " from value list of "
+ + propertyValue, ex);
+ }
+ }
+ return values;
+ } else {
+ List instances = new ArrayList();
+ for (Node aValue : (List<Node>)propertyValue) {
+ instances.add(mediator.mediate(aValue, sourceDataType, targetDataType, null));
+ }
+ return instances;
+ }
+ }
+ }
+
+ class ArrayObjectFactoryImpl extends ObjectFactoryImplBase {
+ public ArrayObjectFactoryImpl(Property property, List<?> propertyValues, Class<?> javaType) {
+ super(property, propertyValues, javaType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getInstance() throws ObjectCreationException {
+ if (isSimpleType) {
+ int count = 0;
+ Object values = Array.newInstance(javaType, ((List<Object>)propertyValue).size());
+ for (String aValue : (List<String>)propertyValue) {
+ try {
+ Array.set(values, count++, simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+ } catch (NumberFormatException ex) {
+ throw new ObjectCreationException("Failed to create instance for property " + property
+ .getName()
+ + " with value "
+ + aValue
+ + " from value list of "
+ + propertyValue, ex);
+ } catch (IllegalArgumentException ex) {
+ throw new ObjectCreationException("Failed to create instance for property " + property
+ .getName()
+ + " with value "
+ + aValue
+ + " from value list of "
+ + propertyValue, ex);
+ }
+ }
+ return values;
+ } else {
+ Object instances = Array.newInstance(javaType, ((List<Object>)propertyValue).size());
+ int count = 0;
+ for (Node aValue : (List<Node>)propertyValue) {
+ Array.set(instances, count++, mediator.mediate(aValue, sourceDataType, targetDataType, null));
+ }
+ return instances;
+ }
+ }
+ }
+
+ /**
+ * Utility methods
+ */
+
+ /**
+ *
+ * @param property
+ * @return
+ */
+ private boolean isSimpleType(Property property) {
+ if (property.getXSDType() != null) {
+ return simpleTypeMapper.isSimpleXSDType(property.getXSDType());
+ } else {
+ if (property instanceof Document) {
+ Document doc = (Document)property;
+ Element element = doc.getDocumentElement();
+ if (element.getChildNodes().getLength() == 1 && element.getChildNodes().item(0).getNodeType() == Element.TEXT_NODE) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Retrieve list of simple property values
+ * @param concatenatedValue
+ * @param javaType
+ * @return
+ */
+ private static List<String> getSimplePropertyValues(String concatenatedValue, Class<?> javaType) {
+ List<String> propValues = new ArrayList<String>();
+ StringTokenizer st = null;
+ if (javaType.getName().equals("java.lang.String")) {
+ st = new StringTokenizer(concatenatedValue, "\"");
+ } else {
+ st = new StringTokenizer(concatenatedValue);
+ }
+ String aToken = null;
+ while (st.hasMoreTokens()) {
+ aToken = st.nextToken();
+ if (aToken.trim().length() > 0) {
+ propValues.add(aToken);
+ }
+ }
+ return propValues;
+ }
+
+ /**
+ * Retrieve the list of complex property values
+ * @param document
+ * @return
+ */
+ private static List<Node> getValues(Document document) {
+ List<Node> propValues = new ArrayList<Node>();
+ if ( document == null )
+ return propValues;
+ // The root is the property element
+ Element rootElement = document.getDocumentElement();
+
+ NodeList nodes = rootElement.getChildNodes();
+ for (int count = 0; count < nodes.getLength(); ++count) {
+ Node node = nodes.item(count);
+ if (node.getNodeType() == Document.ELEMENT_NODE) {
+ propValues.add(DOMHelper.promote(node));
+ }
+ }
+ return propValues;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java
new file mode 100644
index 0000000000..2906897e96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.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.java.injection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Resolves targets configured in a multiplicity by delegating to object factories and returning an <code>List</code>
+ * containing object instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class ListMultiplicityObjectFactory implements ObjectFactory<List<?>> {
+
+ private ObjectFactory[] factories;
+
+ public ListMultiplicityObjectFactory(List<ObjectFactory<?>> factories) {
+ assert factories != null : "Object factories were null";
+ this.factories = factories.toArray(new ObjectFactory[factories.size()]);
+ }
+
+ public List<?> getInstance() throws ObjectCreationException {
+ List<Object> list = new ArrayList<Object>();
+ for (ObjectFactory factory : factories) {
+ list.add(factory.getInstance());
+ }
+ return list;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java
new file mode 100644
index 0000000000..cd43a60ab6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.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.implementation.java.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link org.apache.tuscany.sca.core.factory.ObjectFactory} using a given method
+ *
+ * @version $Rev$ $Date$
+ */
+public class MethodInjector<T> implements Injector<T> {
+ private final Method method;
+ private final ObjectFactory<?> objectFactory;
+
+ public MethodInjector(Method aMethod, ObjectFactory<?> objectFactory) {
+ assert aMethod != null;
+ assert objectFactory != null;
+ this.method = aMethod;
+ // Allow privileged access to set accessibility. Requires ReflectPermission in security
+ // policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ method.setAccessible(true);
+ return null;
+ }
+ });
+ this.objectFactory = objectFactory;
+ }
+
+ public void inject(T instance) throws ObjectCreationException {
+ inject(instance, objectFactory.getInstance());
+ }
+
+ private void inject(T instance, Object value) {
+ try {
+ method.invoke(instance, value);
+ } catch (IllegalAccessException e) {
+ throw new ObjectCreationException("Method is not accessible [" + method + "]", e);
+ } catch (IllegalArgumentException e) {
+ throw new ObjectCreationException("Exception thrown by setter: " + method.getName(), e);
+ } catch (InvocationTargetException e) {
+ throw new ObjectCreationException("Exception thrown by setter: " + method.getName(), e);
+ }
+ }
+
+ public Class<?> getType() {
+ return method.getParameterTypes()[0];
+ }
+
+ public Type getGenericType() {
+ return method.getGenericParameterTypes()[0];
+ }
+
+ public void injectNull(T instance) throws ObjectCreationException {
+ inject(instance, null);
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
new file mode 100644
index 0000000000..43fb5d6170
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.RequestContext;
+
+/**
+ * Creates instances of RequestContext for injection on component implementation instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestContextObjectFactory implements ObjectFactory<RequestContext> {
+ private RequestContextFactory factory;
+ private RuntimeComponent component;
+
+ public RequestContextObjectFactory(RequestContextFactory factory, RuntimeComponent component) {
+ this.factory = factory;
+ this.component = component;
+ }
+
+ public RequestContext getInstance() throws ObjectCreationException {
+ return factory.createRequestContext(component);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java
new file mode 100644
index 0000000000..70c368a0e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.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.sca.implementation.java.injection;
+
+/**
+ * Interface implemented by host environments that allow for resolution of component implementation resources, e.g.
+ * items bound in a JNDI tree.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ResourceHost {
+
+ /**
+ * Resolve a resource matching the given type
+ *
+ * @param type the type of the resources
+ * @throws ResourceResolutionException if an error is encountered during resolution
+ */
+ <T> T resolveResource(Class<T> type) throws ResourceResolutionException;
+
+ /**
+ * Resolve a resource matching the given type and name
+ *
+ * @param type the type of the resources
+ * @param mappedName the mapped name of the resource
+ * @throws ResourceResolutionException if an error is encountered during resolution
+ */
+ <T> T resolveResource(Class<T> type, String mappedName) throws ResourceResolutionException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java
new file mode 100644
index 0000000000..d5c1c7b69e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.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.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+
+/**
+ * Denotes an exception thrown when a runtime resource is not found
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResourceNotFoundException extends ObjectCreationException {
+ private static final long serialVersionUID = 1L;
+
+ public ResourceNotFoundException() {
+ super();
+ }
+
+ public ResourceNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ResourceNotFoundException(String message) {
+ super(message);
+ }
+
+ public ResourceNotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java
new file mode 100644
index 0000000000..8f55eb18bc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Resolves a runtime resource to be injected on a field or method of a Java component type marked with {@link
+ * javax.annotation.Resource}. If the mapped name of the resource is an absolute URI such as
+ * <code>sca://localhost</code> or <code>jndi://localhost</code> the host container namespace is searched; otherwise the
+ * URI is assumed to be relative and the parent composite is searched. If a mapped name is not provided, i.e. resolution
+ * is by type, the parent composite is first searched followed by the host namespace.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResourceObjectFactory<T> implements ObjectFactory<T> {
+
+ private Class<T> type;
+ private String mappedName;
+ private ResourceHost host;
+ private boolean optional;
+
+ /**
+ * Instantiates a factory that resolves resources by type
+ *
+ * @param type the type of the resource to inject
+ * @param optional true if an error should be thrown if the resource is not found
+ * @param host the runtime resource provider
+ */
+ public ResourceObjectFactory(Class<T> type, boolean optional, ResourceHost host) {
+ this(type, null, optional, host);
+ }
+
+ /**
+ * Instantiates a factory that resolves resources by mapped name
+ *
+ * @param type the type of the resource to inject
+ * @param mappedName the resource name
+ * @param optional true if an error should be thrown if the resource is not found
+ * @param host the runtime resource provider
+ */
+ public ResourceObjectFactory(Class<T> type, String mappedName, boolean optional, ResourceHost host) {
+ this.type = type;
+ this.host = host;
+ this.mappedName = mappedName;
+ this.optional = optional;
+ }
+
+ public T getInstance() throws ObjectCreationException {
+ try {
+ T resource;
+ if (mappedName == null) {
+ resource = host.resolveResource(type);
+ if (!optional && resource == null) {
+ throw new ResourceNotFoundException("Resource not found: " + type.getName());
+ }
+ } else {
+ resource = host.resolveResource(type, mappedName);
+ if (!optional && resource == null) {
+ throw new ResourceNotFoundException("Resource not found: " + mappedName);
+ }
+ }
+ return resource;
+ } catch (ResourceResolutionException e) {
+ throw new ObjectCreationException(e);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java
new file mode 100644
index 0000000000..f94b24762a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceResolutionException extends Exception {
+ private static final long serialVersionUID = 13421352711315479L;
+
+ public ResourceResolutionException() {
+ super();
+ }
+
+ public ResourceResolutionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ResourceResolutionException(String message) {
+ super(message);
+ }
+
+ public ResourceResolutionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.java
new file mode 100644
index 0000000000..25c09231c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.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.sca.implementation.java.invocation;
+
+import org.apache.tuscany.sca.implementation.java.injection.InjectionRuntimeException;
+
+/**
+ * Denotes an error when invoking an event on an object
+ *
+ * @version $Rev$ $Date$
+ */
+public class EventInvocationException extends InjectionRuntimeException {
+ private static final long serialVersionUID = 1480018831708211581L;
+
+ public EventInvocationException() {
+ super();
+ }
+
+ public EventInvocationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EventInvocationException(String message) {
+ super(message);
+ }
+
+ public EventInvocationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.java
new file mode 100644
index 0000000000..e6ebb5abc3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+/**
+ * Performs an invocation on an instance
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EventInvoker<T> {
+
+ /**
+ * Performs the invocation on a given instance
+ *
+ * @throws EventInvocationException
+ */
+ void invokeEvent(T instance) throws EventInvocationException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java
new file mode 100644
index 0000000000..1c330ea913
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+
+/**
+ * Denotes an unknown operation sequence in a conversation
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConversationSequenceException extends Exception {
+ private static final long serialVersionUID = -5744028391493899147L;
+
+ public InvalidConversationSequenceException() {
+ super();
+ }
+
+ public InvalidConversationSequenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidConversationSequenceException(String message) {
+ super(message);
+ }
+
+ public InvalidConversationSequenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaAsyncImplementationInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaAsyncImplementationInvoker.java
new file mode 100644
index 0000000000..97b7570faa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaAsyncImplementationInvoker.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.invocation.AsyncResponseException;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ResponseDispatch;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Responsible for asynchronously dispatching an invocation to a Java component
+ * implementation instance
+ *
+ */
+public class JavaAsyncImplementationInvoker extends JavaImplementationInvoker {
+
+ public JavaAsyncImplementationInvoker(Operation operation, Method method, RuntimeComponent component,
+ InterfaceContract interfaceContract) {
+ super( operation, method, component, interfaceContract);
+ assert method != null : "Operation method cannot be null";
+ assert ((JavaOperation) operation).isAsyncServer() : "Operation must be async";
+ } // end constructor
+
+ public Message invoke(Message msg) {
+ Operation op = this.operation;
+
+ Object payload = msg.getBody();
+
+ Object contextId = null;
+
+ // store the current thread context classloader
+ // - replace it with the class loader used to load the java class as per SCA Spec
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+
+ try {
+ // The following call might create a new conversation, as a result, the msg.getConversationID() might
+ // return a new value
+ InstanceWrapper wrapper = scopeContainer.getWrapper(contextId);
+
+ Object instance = wrapper.getInstance();
+
+ // Set the TCCL to the classloader used to load the implementation class
+ Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
+
+ // For an async server method, there is an extra input parameter, which is a DispatchResponse instance
+ // which is typed by the type of the response
+ Class<?> responseType = op.getOutputType().getPhysical();
+ ResponseDispatch<?> dispatch = ResponseDispatchImpl.newInstance(responseType, msg );
+
+ Object ret;
+ Object[] payload2;
+ if (payload != null && !payload.getClass().isArray()) {
+ payload2 = new Object[2];
+ payload2[0] = payload;
+ } else {
+ payload2 = new Object[ ((Object[])payload).length + 1 ];
+ for( int i = 0; i < ((Object[])payload).length; i++) {
+ payload2[i] = ((Object[])payload)[i];
+ } // end for
+ }
+ payload2[ payload2.length - 1 ] = dispatch;
+
+ ret = method.invoke(instance, (Object[])payload2);
+
+ //ret = ((ResponseDispatchImpl<?>)dispatch).get(50, TimeUnit.SECONDS);
+ throw new InvocationTargetException( new AsyncResponseException("AsyncResponse") );
+
+ //scopeContainer.returnWrapper(wrapper, contextId);
+
+ //msg.setBody(ret);
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getTargetException();
+ boolean isChecked = false;
+ for (DataType<?> d : operation.getFaultTypes()) {
+ if (d.getPhysical().isInstance(cause)) {
+ isChecked = true;
+ msg.setFaultBody(cause);
+ break;
+ }
+ }
+
+ if (!isChecked) {
+ if (cause instanceof RuntimeException) {
+ throw (RuntimeException)cause;
+ }
+ if (cause instanceof Error) {
+ throw (Error)cause;
+ } else {
+ throw new ServiceRuntimeException(cause.getMessage(), cause);
+ }
+ }
+
+ } catch (ObjectCreationException e) {
+ throw new ServiceRuntimeException(e.getMessage(), e);
+ } catch (Exception e) {
+ msg.setFaultBody(e);
+ } finally {
+ // set the tccl
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ return msg;
+ } // end method invoke
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java
new file mode 100644
index 0000000000..6cd16202ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.invocation;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.CallbackInterfaceInterceptor;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaCallbackRuntimeWireProcessor implements RuntimeWireProcessor {
+ private static final Logger logger = Logger.getLogger(JavaCallbackRuntimeWireProcessor.class.getName());
+ private InterfaceContractMapper interfaceContractMapper;
+ private JavaInterfaceFactory javaInterfaceFactory;
+
+ public JavaCallbackRuntimeWireProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ }
+
+ /**
+ * @param interfaceContractMapper
+ * @param javaInterfaceFactory
+ */
+ protected JavaCallbackRuntimeWireProcessor(InterfaceContractMapper interfaceContractMapper,
+ JavaInterfaceFactory javaInterfaceFactory) {
+ super();
+ this.interfaceContractMapper = interfaceContractMapper;
+ this.javaInterfaceFactory = javaInterfaceFactory;
+ }
+
+
+ private boolean supportsCallbackInterface(Interface iface, JavaImplementation impl) {
+ if (iface instanceof JavaInterface) {
+ Class<?> ifaceClass = ((JavaInterface)iface).getJavaClass();
+ if (ifaceClass.isAssignableFrom(impl.getJavaClass())) {
+ return true;
+ }
+ }
+ try {
+ Interface implType = javaInterfaceFactory.createJavaInterface(impl.getJavaClass());
+ // Ignore the remotable/conversational testing
+ implType.setRemotable(iface.isRemotable());
+ return interfaceContractMapper.isCompatibleSubset(iface, implType);
+ } catch (InvalidInterfaceException e) {
+ logger.log(Level.WARNING, e.getMessage(), e);
+ return false;
+ }
+ }
+
+ public void process(RuntimeEndpoint endpoint) {
+ // No operation
+ }
+
+ public void process(RuntimeEndpointReference endpointReference) {
+ if(!(endpointReference instanceof RuntimeEndpointReference)) {
+ return;
+ }
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
+ Contract contract = epr.getReference();
+ if (!(contract instanceof RuntimeComponentReference)) {
+ return;
+ }
+ RuntimeComponent component = (RuntimeComponent) epr.getComponent();
+ if (component == null) {
+ return;
+ }
+ Implementation implementation = component.getImplementation();
+ if (!(implementation instanceof JavaImplementation)) {
+ return;
+ }
+ JavaImplementation javaImpl = (JavaImplementation)implementation;
+ Endpoint callbackEndpoint = epr.getCallbackEndpoint();
+ if (callbackEndpoint != null) {
+ Interface iface = callbackEndpoint.getService().getInterfaceContract().getInterface();
+ if (!supportsCallbackInterface(iface, javaImpl)) {
+ // callback to this impl is not possible, so ensure a callback object is set
+ for (InvocationChain chain : epr.getInvocationChains()) {
+ chain.addInterceptor(Phase.REFERENCE, new CallbackInterfaceInterceptor());
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.java
new file mode 100644
index 0000000000..f2a0d576db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.oasisopen.sca.ComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentContextFactory implements ObjectFactory<ComponentContext> {
+ private final JavaComponentContextProvider component;
+
+
+ public JavaComponentContextFactory(JavaComponentContextProvider component) {
+ this.component = component;
+ }
+
+
+ public ComponentContext getInstance() throws ObjectCreationException {
+ return component.getComponent().getComponentContext();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
new file mode 100644
index 0000000000..1fa51315c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
@@ -0,0 +1,399 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.invocation;
+
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.CallableReferenceObjectFactory;
+import org.apache.tuscany.sca.core.invocation.CallbackReferenceObjectFactory;
+import org.apache.tuscany.sca.core.invocation.CallbackWireObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.WireObjectFactory;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.TargetResolutionException;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.JavaScopeImpl;
+import org.apache.tuscany.sca.implementation.java.context.InstanceFactory;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * The runtime instantiation of Java component implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentContextProvider {
+ private JavaPropertyValueObjectFactory propertyValueFactory;
+ private RuntimeComponent component;
+ private JavaInstanceFactoryProvider<?> instanceFactoryProvider;
+ private ProxyFactory proxyFactory;
+ private InstanceFactory instanceFactory;
+ private JavaScopeImpl scope;
+
+ public JavaComponentContextProvider(RuntimeComponent component,
+ JavaInstanceFactoryProvider configuration,
+ DataBindingExtensionPoint dataBindingExtensionPoint,
+ PropertyValueFactory propertyValueObjectFactory,
+ ComponentContextFactory componentContextFactory,
+ RequestContextFactory requestContextFactory) {
+ super();
+ this.instanceFactoryProvider = configuration;
+ this.proxyFactory = configuration.getProxyFactory();
+ // if (componentContextFactory != null) {
+ // this.componentContext = componentContextFactory.createComponentContext(component, requestContextFactory);
+ // } else {
+ // this.componentContext = new ComponentContextImpl(this, requestContextFactory, this.proxyService);
+ // }
+ this.component = component;
+ this.propertyValueFactory = (JavaPropertyValueObjectFactory) propertyValueObjectFactory;
+ this.scope = ((JavaImplementation)component.getImplementation()).getJavaScope();
+ }
+
+ InstanceWrapper<?> createInstanceWrapper() throws ObjectCreationException {
+ if (instanceFactory == null) {
+ start();
+ }
+ return instanceFactory.newInstance();
+ }
+
+ void configureProperties(List<ComponentProperty> definedProperties) {
+ for (ComponentProperty p : definedProperties) {
+ configureProperty(p);
+ }
+ }
+
+ private void configureProperty(ComponentProperty configuredProperty) {
+ JavaElementImpl element =
+ instanceFactoryProvider.getImplementation().getPropertyMembers().get(configuredProperty.getName());
+
+ if (element != null && configuredProperty.getValue() != null) {
+ if (!(element.getAnchor() instanceof Constructor)) {
+ if(element.getElementType() == ElementType.FIELD) {
+ // Field field = (Field)element.getAnchor();
+ instanceFactoryProvider.getInjectionSites().add(element);
+ /*
+ if(Modifier.isPublic(field.getModifiers())) {
+ instanceFactoryProvider.getInjectionSites().add(element);
+ } else if(field.getAnnotation(org.oasisopen.sca.annotation.Property.class) != null) {
+ instanceFactoryProvider.getInjectionSites().add(element);
+ }
+ */
+ } else {
+ instanceFactoryProvider.getInjectionSites().add(element);
+ }
+ }
+
+ //Class propertyJavaType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+ ObjectFactory<?> propertyObjectFactory =
+ createPropertyValueFactory(configuredProperty, configuredProperty.getValue(), element);
+ instanceFactoryProvider.setObjectFactory(element, propertyObjectFactory);
+
+ JavaConstructorImpl<?> constructor = instanceFactoryProvider.getImplementation().getConstructor();
+ for(JavaElementImpl p: constructor.getParameters()){
+ if(element.getName().equals(p.getName())) {
+ instanceFactoryProvider.setObjectFactory(p, propertyObjectFactory);
+ }
+ }
+ }
+ }
+
+ void start() {
+ List<JavaElementImpl> callbackInjectionList = null;
+
+ // If the component implementation is stateless, we need to inject the callbacks on service invocation
+ // rather than doing it once at the component level.
+ if ( scope.equals(JavaScopeImpl.STATELESS)) {
+ callbackInjectionList = instanceFactoryProvider.getCallbackInjectionSites();
+ } else {
+ callbackInjectionList = instanceFactoryProvider.getInjectionSites();
+ }
+
+ if (!instanceFactoryProvider.getImplementation().getCallbackMembers().isEmpty()) {
+ Map<String, List<EndpointReference>> callbackWires = new HashMap<String, List<EndpointReference>>();
+ for (ComponentService service : component.getServices()) {
+
+ RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
+ if (callbackReference != null) {
+ List<EndpointReference> wires = callbackReference.getEndpointReferences();
+ if (!wires.isEmpty()) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) wires.get(0);
+ callbackWires.put(epr.getComponentTypeReferenceInterfaceContract().getInterface().toString(),
+ wires);
+ }
+ }
+ }
+
+ for (Map.Entry<String, Collection<JavaElementImpl>> entry : instanceFactoryProvider.getImplementation()
+ .getCallbackMembers().entrySet()) {
+ List<EndpointReference> wires = callbackWires.get(entry.getKey());
+ if (wires == null) {
+ // this can happen when there are no client wires to a
+ // component that has a callback
+ continue;
+ }
+ for(JavaElementImpl element : entry.getValue()) {
+ Class<?> businessInterface = element.getType();
+ ObjectFactory<?> factory = null;
+ if (ServiceReference.class.isAssignableFrom(element.getType())) {
+ businessInterface =
+ JavaIntrospectionHelper.getBusinessInterface(element.getType(), element.getGenericType());
+ factory =
+ new CallbackReferenceObjectFactory(businessInterface, proxyFactory, wires);
+ } else {
+ factory = new CallbackWireObjectFactory(businessInterface, proxyFactory, wires);
+ }
+ if (!(element.getAnchor() instanceof Constructor)) {
+ callbackInjectionList.add(element);
+ }
+ instanceFactoryProvider.setObjectFactory(element, factory);
+ }
+ }
+ }
+ for (Reference ref : instanceFactoryProvider.getImplementation().getReferences()) {
+ JavaElementImpl element =
+ instanceFactoryProvider.getImplementation().getReferenceMembers().get(ref.getName());
+ if (element != null) {
+ if (!(element.getAnchor() instanceof Constructor)) {
+ if(element.getElementType() == ElementType.FIELD) {
+ Field field = (Field)element.getAnchor();
+ if(Modifier.isPublic(field.getModifiers())) {
+ instanceFactoryProvider.getInjectionSites().add(element);
+ } else if(field.getAnnotation(org.oasisopen.sca.annotation.Reference.class) != null) {
+ instanceFactoryProvider.getInjectionSites().add(element);
+ }
+ } else {
+ instanceFactoryProvider.getInjectionSites().add(element);
+ }
+ }
+ ComponentReference componentReference = null;
+ List<EndpointReference> wireList = null;
+ for (ComponentReference reference : component.getReferences()) {
+ if (reference.getName().equals(ref.getName())) {
+ wireList = ((RuntimeComponentReference)reference).getEndpointReferences();
+ componentReference = reference;
+ break;
+ }
+ }
+ if (ref.getMultiplicity() == Multiplicity.ONE_N || ref.getMultiplicity() == Multiplicity.ZERO_N) {
+ List<ObjectFactory<?>> factories = new ArrayList<ObjectFactory<?>>();
+ Class<?> baseType =
+ JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+ for (int i = 0; i < wireList.size(); i++) {
+ ObjectFactory<?> factory = null;
+ if (ServiceReference.class.isAssignableFrom(baseType)) {
+ Type callableRefType = JavaIntrospectionHelper.getParameterType(element.getGenericType());
+ // Type businessType = JavaIntrospectionHelper.getParameterType(callableRefType);
+ Class<?> businessInterface =
+ JavaIntrospectionHelper.getBusinessInterface(baseType, callableRefType);
+ factory = new CallableReferenceObjectFactory(businessInterface, (RuntimeEndpointReference) wireList.get(i));
+ } else {
+ factory = createObjectFactory(baseType, wireList.get(i));
+ }
+ factories.add(factory);
+ }
+ instanceFactoryProvider.setObjectFactories(element, factories);
+ JavaConstructorImpl<?> constructor = instanceFactoryProvider.getImplementation().getConstructor();
+ for(JavaElementImpl p: constructor.getParameters()){
+ if(element.getName().equals(p.getName())) {
+ instanceFactoryProvider.setObjectFactories(p, factories);
+ }
+ }
+ } else {
+ if (wireList == null && ref.getMultiplicity() == Multiplicity.ONE_ONE) {
+ throw new IllegalStateException("Required reference is missing: " + ref.getName());
+ }
+ if (wireList != null && !wireList.isEmpty()) {
+ ObjectFactory<?> factory = null;
+ if (ServiceReference.class.isAssignableFrom(element.getType())) {
+ Class<?> businessInterface =
+ JavaIntrospectionHelper.getBusinessInterface(element.getType(), element
+ .getGenericType());
+ factory =
+ new CallableReferenceObjectFactory(businessInterface, (RuntimeEndpointReference) wireList.get(0));
+ } else {
+ factory = createObjectFactory(element.getType(), wireList.get(0));
+ }
+ instanceFactoryProvider.setObjectFactory(element, factory);
+ JavaConstructorImpl<?> constructor = instanceFactoryProvider.getImplementation().getConstructor();
+ for(JavaElementImpl p: constructor.getParameters()){
+ if(element.getName().equals(p.getName())) {
+ instanceFactoryProvider.setObjectFactory(p, factory);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //setUpPolicyHandlers();
+ this.instanceFactory = instanceFactoryProvider.createFactory();
+
+ }
+
+ void addResourceFactory(String name, ObjectFactory<?> factory) {
+ JavaResourceImpl resource = instanceFactoryProvider.getImplementation().getResources().get(name);
+
+ if (resource != null && !(resource.getElement().getAnchor() instanceof Constructor)) {
+ instanceFactoryProvider.getInjectionSites().add(resource.getElement());
+ }
+
+ instanceFactoryProvider.setObjectFactory(resource.getElement(), factory);
+ }
+
+ Object createInstance() throws ObjectCreationException {
+ return createInstanceWrapper().getInstance();
+ }
+
+ JavaInstanceFactoryProvider<?> getInstanceFactoryProvider() {
+ return instanceFactoryProvider;
+ }
+
+ void stop() {
+ //cleanUpPolicyHandlers();
+ }
+
+ Invoker createInvoker(Operation operation, InterfaceContract interfaceContract) throws NoSuchMethodException {
+ Class<?> implClass = instanceFactoryProvider.getImplementationClass();
+
+ Method method = JavaInterfaceUtil.findMethod(implClass, operation);
+ if (operation instanceof JavaOperation &&
+ ((JavaOperation) operation).isAsyncServer() ) {
+ return new JavaAsyncImplementationInvoker(operation, method, component, interfaceContract);
+ } else {
+ return new JavaImplementationInvoker(operation, method, component, interfaceContract);
+ } // end if
+ } // end
+
+ private static class OptimizedObjectFactory<T> implements ObjectFactory<T> {
+ private ScopeContainer scopeContainer;
+
+ public OptimizedObjectFactory(ScopeContainer scopeContainer) {
+ super();
+ this.scopeContainer = scopeContainer;
+ }
+
+ public T getInstance() throws ObjectCreationException {
+ try {
+ return (T)scopeContainer.getWrapper(null).getInstance();
+ } catch (TargetResolutionException e) {
+ throw new ObjectCreationException(e);
+ }
+ }
+
+ }
+
+ private <B> ObjectFactory<B> createObjectFactory(Class<B> interfaze, EndpointReference wire) {
+ // FIXME: [rfeng] Disable the optimization for new as it needs more discussions
+ /*
+ boolean conversational = wire.getSource().getInterfaceContract().getInterface().isConversational();
+ Binding binding = wire.getSource().getBinding();
+ // Check if it's wireable binding for optimization
+ if (!conversational && binding instanceof OptimizableBinding) {
+ OptimizableBinding optimizableBinding = (OptimizableBinding)binding;
+ Component component = optimizableBinding.getTargetComponent();
+ if (component != null) {
+ Implementation implementation = component.getImplementation();
+ // Check if the target component is java component
+ if (implementation instanceof JavaImplementation) {
+ JavaImplementation javaImplementation = (JavaImplementation)implementation;
+ if (interfaze.isAssignableFrom(javaImplementation.getJavaClass())) {
+ ScopedRuntimeComponent scopedComponent = (ScopedRuntimeComponent)component;
+ ScopeContainer scopeContainer = scopedComponent.getScopeContainer();
+ Scope scope = scopeContainer.getScope();
+ if (scope == Scope.COMPOSITE || scope == Scope.STATELESS || scope == Scope.SYSTEM) {
+ boolean optimizable = true;
+ for (InvocationChain chain : wire.getInvocationChains()) {
+ if (chain.getHeadInvoker() != chain.getTailInvoker()) {
+ optimizable = false;
+ break;
+ }
+ }
+ if (optimizable) {
+ return new OptimizedObjectFactory<B>(scopeContainer);
+ }
+ }
+ }
+ }
+ }
+ }
+ */
+ return new WireObjectFactory<B>(interfaze, (RuntimeEndpointReference) wire, proxyFactory);
+ }
+
+ private ObjectFactory<?> createPropertyValueFactory(ComponentProperty property,
+ Object propertyValue,
+ JavaElementImpl javaElement) {
+ return propertyValueFactory.createValueFactory(property, propertyValue, javaElement);
+ }
+
+ /**
+ * @return the component
+ */
+ RuntimeComponent getComponent() {
+ return component;
+ }
+
+ /*private void setUpPolicyHandlers() {
+ for (PolicyHandler policyHandler : policyHandlers.values()) {
+ policyHandler.setUp(component.getImplementation());
+ }
+ }
+
+ private void cleanUpPolicyHandlers() {
+ for (PolicyHandler policyHandler : policyHandlers.values() ) {
+ policyHandler.cleanUp(this);
+ }
+ }*/
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java
new file mode 100644
index 0000000000..4a5ad98e5b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentNameFactory implements ObjectFactory<String> {
+ private final JavaComponentContextProvider componentContextProvider;
+
+
+ public JavaComponentNameFactory(JavaComponentContextProvider component) {
+ this.componentContextProvider = component;
+ }
+
+
+ public String getInstance() throws ObjectCreationException {
+ String uri = componentContextProvider.getComponent().getURI();
+ return uri.substring(uri.lastIndexOf('/')+1);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
new file mode 100644
index 0000000000..13fcfbf413
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.context.ReflectiveInstanceWrapper;
+import org.apache.tuscany.sca.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Responsible for synchronously dispatching an invocation to a Java component
+ * implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationInvoker implements Invoker {
+ protected Operation operation;
+ protected Method method;
+ protected boolean allowsPBR;
+
+ @SuppressWarnings("unchecked")
+ protected final ScopeContainer scopeContainer;
+ private final InterfaceContract interfaze;
+
+ public JavaImplementationInvoker(Operation operation, Method method, RuntimeComponent component, InterfaceContract intf) {
+ assert method != null : "Operation method cannot be null";
+ this.method = method;
+ this.operation = operation;
+ this.scopeContainer = ((ScopedRuntimeComponent)component).getScopeContainer();
+ this.allowsPBR = ((JavaImplementation)component.getImplementation()).isAllowsPassByReference(method);
+ this.interfaze = intf;
+ }
+
+ public JavaImplementationInvoker(Operation operation, RuntimeComponent component, InterfaceContract intf) {
+ // used if the method can't be computed statically in advance
+ this.operation = operation;
+ this.scopeContainer = ((ScopedRuntimeComponent)component).getScopeContainer();
+ this.interfaze = intf;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Message invoke(Message msg) {
+ Operation op = msg.getOperation();
+ if (op == null) {
+ op = this.operation;
+ }
+ Object payload = msg.getBody();
+
+ Object contextId = null;
+
+ EndpointReference from = msg.getFrom();
+
+ // store the current thread context classloader
+ // as we need to replace it with the class loader
+ // used to load the java class as per SCA Spec
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+
+ try {
+ // The following call might create a new conversation, as a result, the msg.getConversationID() might
+ // return a new value
+ ReflectiveInstanceWrapper wrapper = (ReflectiveInstanceWrapper) scopeContainer.getWrapper(contextId);
+
+ // If there is a callback interface and the implementation is stateless, we need to
+ // inject callbacks at invocation time. For Composite scope, this has already been done.
+ if (( interfaze.getCallbackInterface() != null ) && (scopeContainer.getScope().equals(Scope.STATELESS))){
+ injectCallbacks(wrapper, (JavaInterface)interfaze.getCallbackInterface());
+ }
+
+ Object instance = wrapper.getInstance();
+
+ // If the method couldn't be computed statically, or the instance being
+ // invoked is a user-specified callback object that doesn't implement
+ // the service interface from which the reflective method was obtained,
+ // compute the method object dynamically for this invocation.
+ Method imethod = method;
+ if (imethod == null || !imethod.getDeclaringClass().isInstance(instance)) {
+ try {
+ imethod = JavaInterfaceUtil.findMethod(instance.getClass(), operation);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException("Callback object does not provide method " + e.getMessage());
+ }
+ }
+
+ // Set the thread context classloader of the thread used to invoke an operation
+ // of a Java POJO component implementation is the class loader of the contribution
+ // that contains the POJO implementation class.
+
+ Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
+
+ Object ret;
+ if (payload != null && !payload.getClass().isArray()) {
+ ret = imethod.invoke(instance, payload);
+ } else {
+ ret = imethod.invoke(instance, (Object[])payload);
+ }
+
+ scopeContainer.returnWrapper(wrapper, contextId);
+
+ msg.setBody(ret);
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getTargetException();
+ boolean isChecked = false;
+ for (DataType<?> d : operation.getFaultTypes()) {
+ if (d.getPhysical().isInstance(cause)) {
+ isChecked = true;
+ msg.setFaultBody(cause);
+ break;
+ }
+ }
+
+ if (!isChecked) {
+ if (cause instanceof RuntimeException) {
+ throw (RuntimeException)cause;
+ }
+ if (cause instanceof Error) {
+ throw (Error)cause;
+ } else {
+ throw new ServiceRuntimeException(cause.getMessage(), cause);
+ }
+ }
+
+ } catch (ObjectCreationException e) {
+ throw new ServiceRuntimeException(e.getMessage(), e);
+ } catch (Exception e) {
+ msg.setFaultBody(e);
+ } finally {
+ // set the tccl
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ return msg;
+ }
+
+ private void injectCallbacks(ReflectiveInstanceWrapper wrapper,
+ JavaInterface callbackInterface) {
+
+ for (Injector injector : wrapper.getCallbackInjectors()) {
+ if (injector != null) {
+ try {
+ if (ServiceReference.class.isAssignableFrom(injector.getType())) {
+ Class<?> intf = JavaIntrospectionHelper.getBusinessInterface(injector.getType(), injector.getGenericType());
+ if ( intf.isAssignableFrom(callbackInterface.getJavaClass())) {
+ injector.inject(wrapper.getInstance());
+ }
+ } else if (injector.getType().isAssignableFrom(callbackInterface.getJavaClass())) {
+ injector.inject(wrapper.getInstance());
+ } else {
+ injector.injectNull(wrapper.getInstance());
+ }
+ } catch (Exception e) {
+ throw new ObjectCreationException("Exception invoking injector - " + e.getMessage(), e);
+ }
+ }
+ }
+
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
new file mode 100644
index 0000000000..d7abd021f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.invocation;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.ScopedImplementationProvider;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.injection.RequestContextObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.ResourceHost;
+import org.apache.tuscany.sca.implementation.java.injection.ResourceObjectFactory;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.RequestContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationProvider implements ScopedImplementationProvider {
+ private JavaImplementation implementation;
+ private JavaComponentContextProvider componentContextProvider;
+ private RequestContextFactory requestContextFactory;
+
+ public JavaImplementationProvider(RuntimeComponent component,
+ JavaImplementation implementation,
+ ProxyFactory proxyService,
+ DataBindingExtensionPoint dataBindingRegistry,
+ PropertyValueFactory propertyValueObjectFactory,
+ ComponentContextFactory componentContextFactory,
+ RequestContextFactory requestContextFactory) {
+ super();
+ this.implementation = implementation;
+ this.requestContextFactory = requestContextFactory;
+
+ try {
+ JavaInstanceFactoryProvider configuration = new JavaInstanceFactoryProvider(implementation);
+ configuration.setProxyFactory(proxyService);
+ componentContextProvider =
+ new JavaComponentContextProvider(component,
+ configuration,
+ dataBindingRegistry,
+ propertyValueObjectFactory,
+ componentContextFactory,
+ requestContextFactory);
+
+ Scope scope = getScope();
+
+ componentContextProvider.configureProperties(component.getProperties());
+ handleResources(implementation, proxyService);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ private void handleResources(JavaImplementation componentType, ProxyFactory proxyService) {
+ for (JavaResourceImpl resource : componentType.getResources().values()) {
+ String name = resource.getName();
+
+ ObjectFactory<?> objectFactory =
+ (ObjectFactory<?>)componentContextProvider.getInstanceFactoryProvider().getFactories().get(resource.getElement());
+ if (objectFactory == null) {
+ Class<?> type = resource.getElement().getType();
+ if (ComponentContext.class.equals(type)) {
+ objectFactory = new JavaComponentContextFactory(componentContextProvider);
+ } else if (RequestContext.class.equals(type)) {
+ objectFactory = new RequestContextObjectFactory(requestContextFactory, componentContextProvider.getComponent());
+ } else if (String.class.equals(type)) {
+ objectFactory = new JavaComponentNameFactory(componentContextProvider);
+ } else {
+ boolean optional = resource.isOptional();
+ String mappedName = resource.getMappedName();
+ objectFactory = createResourceObjectFactory(type, mappedName, optional, null);
+ }
+ }
+ componentContextProvider.addResourceFactory(name, objectFactory);
+ }
+ }
+
+ private <T> ResourceObjectFactory<T> createResourceObjectFactory(Class<T> type,
+ String mappedName,
+ boolean optional,
+ ResourceHost host) {
+ return new ResourceObjectFactory<T>(type, mappedName, optional, host);
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ try {
+ return componentContextProvider.createInvoker(operation, service.getInterfaceContract());
+ } catch (NoSuchMethodException e) {
+ // It's possible that the instance being invoked is a user-specified
+ // callback object that isn't an instance of the component implementation
+ // class. As an attempt to deal with this, look up a method object from
+ // the service interface. This isn't foolproof, as it's possible that
+ // the service interface isn't a Java interface, or that the callback
+ // object has the right method signature without implementing the
+ // callback interface. There is code in JavaImplementationInvoker
+ // to deal with these possibilities.
+ Interface iface = service.getInterfaceContract().getInterface();
+ if (iface instanceof JavaInterface) {
+ try {
+ Method method = JavaInterfaceUtil.findMethod(((JavaInterface)iface).getJavaClass(), operation);
+ return new JavaImplementationInvoker(operation, method, componentContextProvider.getComponent(), service.getInterfaceContract());
+ } catch (NoSuchMethodException e1) {
+ throw new IllegalArgumentException(e1);
+ }
+ } else {
+ return new JavaImplementationInvoker(operation, componentContextProvider.getComponent(), service.getInterfaceContract());
+ }
+ }
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public Scope getScope() {
+ return new Scope(implementation.getJavaScope().getScope());
+ }
+
+ public void start() {
+ componentContextProvider.start();
+ }
+
+ public void stop() {
+ componentContextProvider.stop();
+ }
+
+ public InstanceWrapper<?> createInstanceWrapper() {
+ return componentContextProvider.createInstanceWrapper();
+ }
+
+ public boolean isEagerInit() {
+ return implementation.isEagerInit();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
new file mode 100644
index 0000000000..b59966a39e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.invocation;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.CglibProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationProviderFactory implements ImplementationProviderFactory<JavaImplementation> {
+ private static final Logger logger = Logger.getLogger(JavaImplementationProviderFactory.class.getName());
+ private PropertyValueFactory propertyValueFactory;
+ private DataBindingExtensionPoint databindings;
+ private ProxyFactory proxyFactory;
+ private ComponentContextFactory componentContextFactory;
+ private RequestContextFactory requestContextFactory;
+
+ public JavaImplementationProviderFactory(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ MessageFactory messageFactory = factories.getFactory(MessageFactory.class);
+
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ ProxyFactoryExtensionPoint proxyFactories = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ try {
+ proxyFactories.setClassProxyFactory(new CglibProxyFactory(messageFactory, interfaceContractMapper));
+ } catch (NoClassDefFoundError e) {
+ logger.log(Level.WARNING, "Class-based proxy is not supported", e);
+ }
+
+ databindings = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ propertyValueFactory = factories.getFactory(PropertyValueFactory.class);
+
+ ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class);
+ componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class);
+ requestContextFactory = contextFactories.getFactory(RequestContextFactory.class);
+
+ proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ }
+
+ /*
+ public JavaImplementationProviderFactory(ProxyFactory proxyService,
+ DataBindingExtensionPoint dataBindingRegistry,
+ PropertyValueFactory propertyValueObjectFactory,
+ ComponentContextFactory componentContextFactory,
+ RequestContextFactory requestContextFactory) {
+ super();
+ this.proxyFactory = proxyService;
+ this.databindings = dataBindingRegistry;
+ this.propertyValueFactory = propertyValueObjectFactory;
+ this.componentContextFactory = componentContextFactory;
+ this.requestContextFactory = requestContextFactory;
+ }
+ */
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ JavaImplementation implementation) {
+ return new JavaImplementationProvider(component,
+ implementation,
+ proxyFactory,
+ databindings,
+ propertyValueFactory,
+ componentContextFactory,
+ requestContextFactory);
+ }
+
+ public Class<JavaImplementation> getModelType() {
+ return JavaImplementation.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java
new file mode 100644
index 0000000000..1f1f1eefdc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.invocation;
+
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.context.InstanceFactory;
+import org.apache.tuscany.sca.implementation.java.context.InstanceFactoryProvider;
+import org.apache.tuscany.sca.implementation.java.context.ReflectiveInstanceFactory;
+import org.apache.tuscany.sca.implementation.java.injection.ArrayMultiplicityObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.FieldInjector;
+import org.apache.tuscany.sca.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.implementation.java.injection.InvalidAccessorException;
+import org.apache.tuscany.sca.implementation.java.injection.ListMultiplicityObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.MethodInjector;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+
+/**
+ * Encapsulates configuration for a Java-based atomic component
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaInstanceFactoryProvider<T> implements InstanceFactoryProvider<T> {
+ private JavaImplementation definition;
+ private ProxyFactory proxyService;
+
+ private final List<JavaElementImpl> injectionSites;
+ private final EventInvoker<T> initInvoker;
+ private final EventInvoker<T> destroyInvoker;
+ private final Map<JavaElementImpl, Object> factories = new HashMap<JavaElementImpl, Object>();
+ private final List<JavaElementImpl> callbackInjectionSites;
+
+ public JavaInstanceFactoryProvider(JavaImplementation definition) {
+ this.definition = definition;
+ this.initInvoker = definition.getInitMethod() == null ? null : new MethodEventInvoker<T>(definition
+ .getInitMethod());
+ this.destroyInvoker = definition.getDestroyMethod() == null ? null : new MethodEventInvoker<T>(definition
+ .getDestroyMethod());
+ injectionSites = new ArrayList<JavaElementImpl>();
+ callbackInjectionSites = new ArrayList<JavaElementImpl>();
+ }
+
+ ProxyFactory getProxyFactory() {
+ return proxyService;
+ }
+
+ void setProxyFactory(ProxyFactory proxyService) {
+ this.proxyService = proxyService;
+ }
+
+ /**
+ * @return the definition
+ */
+ JavaImplementation getImplementation() {
+ return definition;
+ }
+
+ @SuppressWarnings("unchecked")
+ public InstanceFactory<T> createFactory() {
+ ObjectFactory<?>[] initArgs = getConstructorArgs();
+ Injector<T>[] injectors = getInjectors(false);
+ Injector<T>[] callbackInjectors = getInjectors(true);
+ return new ReflectiveInstanceFactory<T>((Constructor<T>)definition.getConstructor().getConstructor(),
+ initArgs, injectors, callbackInjectors, initInvoker, destroyInvoker);
+ }
+
+
+
+ private ObjectFactory<?>[] getConstructorArgs() {
+ JavaConstructorImpl<?> constructor = definition.getConstructor();
+ ObjectFactory<?>[] initArgs = new ObjectFactory<?>[constructor.getParameters().length];
+ for (int i = 0; i < initArgs.length; i++) {
+ ObjectFactory<?> factory = (ObjectFactory<?>)factories.get(constructor.getParameters()[i]);
+ assert factory != null;
+ initArgs[i] = factory;
+ }
+ return initArgs;
+ }
+
+
+
+ @SuppressWarnings("unchecked")
+ private Injector<T>[] getInjectors(boolean callback) {
+ List<JavaElementImpl> sites = null;
+ if ( callback )
+ sites = callbackInjectionSites;
+ else
+ sites = injectionSites;
+
+ // work around JDK1.5 issue with allocating generic arrays
+ Injector<T>[] injectors = new Injector[sites.size()];
+
+ int i = 0;
+ for (JavaElementImpl element : sites) {
+ Object obj = factories.get(element);
+ if (obj != null) {
+ if (obj instanceof ObjectFactory) {
+ ObjectFactory<?> factory = (ObjectFactory<?>)obj;
+ Member member = (Member)element.getAnchor();
+ if (element.getElementType() == ElementType.FIELD) {
+ injectors[i++] = new FieldInjector<T>((Field)member, factory);
+ } else if (element.getElementType() == ElementType.PARAMETER && member instanceof Method) {
+ injectors[i++] = new MethodInjector<T>((Method)member, factory);
+ } else if (member instanceof Constructor) {
+ // Ignore
+ } else {
+ throw new AssertionError(String.valueOf(element));
+ }
+ } else {
+ injectors[i++] = createMultiplicityInjector(element, (List<ObjectFactory<?>>)obj);
+ }
+ }
+ }
+ return injectors;
+ }
+
+ private Injector<T> createMultiplicityInjector(JavaElementImpl element, List<ObjectFactory<?>> factories) {
+ Class<?> interfaceType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+
+ if (element.getAnchor() instanceof Field) {
+ Field field = (Field)element.getAnchor();
+ if (field.getType().isArray()) {
+ return new FieldInjector<T>(field, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+ } else {
+ return new FieldInjector<T>(field, new ListMultiplicityObjectFactory(factories));
+ }
+ } else if (element.getAnchor() instanceof Method) {
+ Method method = (Method)element.getAnchor();
+ if (method.getParameterTypes()[0].isArray()) {
+ return new MethodInjector<T>(method, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+ } else {
+ return new MethodInjector<T>(method, new ListMultiplicityObjectFactory(factories));
+ }
+ } else {
+ throw new InvalidAccessorException("Member must be a field or method: " + element.getName());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class<T> getImplementationClass() {
+ return (Class<T>)definition.getJavaClass();
+ }
+
+ public void setObjectFactory(JavaElementImpl element, ObjectFactory<?> objectFactory) {
+ factories.put(element, objectFactory);
+ }
+
+ public void setObjectFactories(JavaElementImpl element, List<ObjectFactory<?>> objectFactory) {
+ factories.put(element, objectFactory);
+ }
+
+ /**
+ * @return the injectionSites
+ */
+ List<JavaElementImpl> getInjectionSites() {
+ return injectionSites;
+ }
+
+ /**
+ * @return the callbackInjectionSites
+ */
+ public List<JavaElementImpl> getCallbackInjectionSites() {
+ return callbackInjectionSites;
+ }
+
+ /**
+ * @return the factories
+ */
+ Map<JavaElementImpl, Object> getFactories() {
+ return factories;
+ }
+
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java
new file mode 100644
index 0000000000..515a7c8a43
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.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 org.apache.tuscany.sca.implementation.java.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+
+/**
+ * Performs an wire on a method of a given instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class MethodEventInvoker<T> implements EventInvoker<T> {
+ private final Method method;
+
+ /**
+ * Instantiates an invoker for the given method
+ */
+ public MethodEventInvoker(Method method) {
+ assert method != null;
+ this.method = method;
+ }
+
+ public void invokeEvent(T instance) throws EventInvocationException {
+ try {
+ method.invoke(instance, (Object[]) null);
+ } catch (IllegalArgumentException e) {
+ String name = method.getName();
+ throw new EventInvocationException("Exception thrown by event method [" + name + "]", e.getCause());
+ } catch (IllegalAccessException e) {
+ String name = method.getName();
+ throw new EventInvocationException("Method is not accessible [" + name + "]");
+ } catch (InvocationTargetException e) {
+ String name = method.getName();
+ throw new EventInvocationException("Exception thrown by event method [" + name + "]", e.getCause());
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java
new file mode 100644
index 0000000000..dbc5c6b640
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+
+/**
+ * Raised when a component has conversational scope but no conversational contract
+ *
+ * @version $Rev$ $Date$
+ */
+public class NoConversationalContractException extends Exception {
+ private static final long serialVersionUID = -1157790036638157539L;
+
+ public NoConversationalContractException(String message) {
+ super(message);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/ResponseDispatchImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/ResponseDispatchImpl.java
new file mode 100644
index 0000000000..dc0bb94bde
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/ResponseDispatchImpl.java
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.invocation;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.AsyncFaultWrapper;
+import org.apache.tuscany.sca.core.invocation.AsyncResponseHandler;
+import org.apache.tuscany.sca.core.invocation.CallbackReferenceObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ResponseDispatch;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Implementation of the ResponseDispatch interface of the OASIS SCA Java API
+ *
+ * This is used for invocations of asynchronous services, where it is passed as a parameter on async service operations
+ * and it provides the path by which the service implementation returns the response to the request, or a Fault
+ *
+ * Note that this class is serializable and can be serialized, stored and deserialized by the service implementation
+ *
+ * @param <T> - type of the response message
+ */
+public class ResponseDispatchImpl<T> implements ResponseDispatch<T>, Serializable {
+
+ /**
+ * Generated serialVersionUID value
+ */
+ private static final long serialVersionUID = 300158355992568592L;
+ private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ private static String MESSAGE_ID = "MESSAGE_ID";
+
+ // A latch used to ensure that the sendResponse() and sendFault() operations are used at most once
+ // The latch is initialized with the value "false"
+ private AtomicBoolean latch = new AtomicBoolean();
+
+ private final Lock lock = new ReentrantLock();
+ private final Condition completed = lock.newCondition();
+
+ // The result
+ private volatile T response = null;
+ private volatile Throwable fault = null;
+
+ private ExtensionPointRegistry registry;
+
+ // Service Reference used for the callback
+ private ServiceReference<AsyncResponseHandler<?>> callbackRef;
+ private String callbackAddress;
+ private String messageID;
+
+ public ResponseDispatchImpl( Message msg ) {
+ super();
+ callbackRef = getAsyncCallbackRef( msg );
+
+ callbackAddress = msg.getFrom().getCallbackEndpoint().getURI();
+
+ // TODO - why is WS stuff bleeding into general code?
+ messageID = (String) msg.getHeaders().get(MESSAGE_ID);
+ if (messageID == null){
+ messageID = (String) msg.getHeaders().get(WS_MESSAGE_ID);
+ }
+
+ } // end constructor
+
+ public static <T> ResponseDispatchImpl<T> newInstance( Class<T> type, Message msg ) {
+ return new ResponseDispatchImpl<T>( msg );
+ }
+
+ /**
+ * Provide Context data for this ResponseDispatch that the service implementation can use
+ */
+ public Map<String, Object> getContext() {
+ return null;
+ }
+
+ /**
+ * Send a Fault. Must only be invoked once for this ResponseDispatch object
+ * @param e - the Fault to send
+ * @throws IllegalStateException if either the sendResponse method or the sendFault method have been called previously
+ */
+ public void sendFault(Throwable e) {
+ if( sendOK() ) {
+ lock.lock();
+ try {
+ fault = e;
+ completed.signalAll();
+ } finally {
+ lock.unlock();
+ } // end try
+ } else {
+ throw new IllegalStateException("sendResponse() or sendFault() has been called previously");
+ } // end if
+ // Now dispatch the response to the callback...
+ AsyncResponseHandler<T> handler = (AsyncResponseHandler<T>) callbackRef.getService();
+ setResponseHeaders();
+ handler.setFault(new AsyncFaultWrapper(e));
+ } // end method sendFault
+
+ /**
+ * Send the response message. Must only be invoked once for this ResponseDispatch object
+ * @throws IllegalStateException if either the sendResponse method or the sendFault method have been called previously
+ * @param res - the response message, which is of type T
+ */
+ public void sendResponse(T res) {
+ if( sendOK() ) {
+ lock.lock();
+ try {
+ response = res;
+ completed.signalAll();
+ } finally {
+ lock.unlock();
+ } // end try
+ } else {
+ throw new IllegalStateException("sendResponse() or sendFault() has been called previously");
+ } // end if
+ // Now dispatch the response to the callback...
+ AsyncResponseHandler<T> handler = (AsyncResponseHandler<T>) callbackRef.getService();
+ setResponseHeaders();
+ handler.setResponse(res);
+ } // end method sendResponse
+
+ public T get(long timeout, TimeUnit unit) throws Throwable {
+ lock.lock();
+ try {
+ // wait for result to be available
+ if( response == null && fault == null ) completed.await( timeout, unit);
+ if( response != null ) return response;
+ if( fault != null ) throw fault;
+ } finally {
+ lock.unlock();
+ } // end try
+
+ return null;
+ } // end method get
+
+ /**
+ * Indicates that sending a response is OK - this is a transactional
+ * query in that it also updates the state of this ResponseDispatch, so
+ * that it will return true once and once only
+ * @return - true if it is OK to send the response, false otherwise
+ */
+ private boolean sendOK() {
+ return latch.compareAndSet(false, true);
+ }
+
+ /**
+ * Creates a service reference for the async callback, based on information contained in the supplied message
+ * @param msg - the incoming message
+ * @return - a CallBackServiceReference
+ */
+ @SuppressWarnings("unchecked")
+ private ServiceReference<AsyncResponseHandler<?>> getAsyncCallbackRef( Message msg ) {
+ RuntimeEndpointReference callbackEPR = (RuntimeEndpointReference) msg.getHeaders().get("ASYNC_CALLBACK");
+ if( callbackEPR == null ) return null;
+
+ CompositeContext compositeContext = callbackEPR.getCompositeContext();
+ registry = compositeContext.getExtensionPointRegistry();
+ ProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ List<EndpointReference> eprList = new ArrayList<EndpointReference>();
+ eprList.add(callbackEPR);
+ ObjectFactory<?> factory = new CallbackReferenceObjectFactory(AsyncResponseHandler.class, proxyFactory, eprList);
+
+ return (ServiceReference<AsyncResponseHandler<?>>) factory.getInstance();
+
+ } // end method getAsyncCallbackEPR
+
+ /**
+ * Sets the values of various headers in the response message
+ */
+ private void setResponseHeaders() {
+ // Is there an existing message context?
+ Message msgContext = ThreadMessageContext.getMessageContext();
+ if( msgContext == null ) {
+ // Create a message context
+ msgContext = getMessageFactory().createMessage();
+ } // end if
+
+ // Add in the header for the RelatesTo Message ID
+ msgContext.getHeaders().put(WS_MESSAGE_ID, messageID);
+ msgContext.getHeaders().put(MESSAGE_ID, messageID);
+
+ ThreadMessageContext.setMessageContext(msgContext);
+ } // end method setResponseHeaders
+
+ private MessageFactory getMessageFactory() {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ return modelFactories.getFactory(MessageFactory.class);
+ } // end method getMessageFactory
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.PropertyValueFactory b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.PropertyValueFactory
new file mode 100644
index 0000000000..9d5f943f46
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.PropertyValueFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.implementation.java.injection.JavaPropertyValueObjectFactory
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..2b67aa59ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/implementation/java/definitions/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
new file mode 100644
index 0000000000..e649b68466
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# NOTE: The ranking attribute is important for the JavaClassVistors
+# Some visitors need to be called after the others
+org.apache.tuscany.sca.implementation.java.databinding.PropertyDataTypeProcessor;ranking=750
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..1c2626706b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.java.JavaImplementation
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor
new file mode 100644
index 0000000000..07008049e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.implementation.java.invocation.JavaCallbackRuntimeWireProcessor
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/definitions/definitions.xml b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/definitions/definitions.xml
new file mode 100644
index 0000000000..e790317458
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/definitions/definitions.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:implementationType type="sca:implementation.java" mayProvide="" alwaysProvides=""/>
+
+ </sca:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java
new file mode 100644
index 0000000000..629ba8b321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.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 org.apache.tuscany.sca.implementation.java.context;
+
+import org.junit.Test;
+
+
+
+/**
+ * Tests wires that are configured with a multiplicity
+ *
+ * @version $Rev$ $Date$
+ */
+public class MultiplicityTestCase {
+
+ @Test
+ public void testMultiplicity() throws Exception {
+ // TODO implement
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java.fixme b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java.fixme
new file mode 100644
index 0000000000..628a308c86
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java.fixme
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.context;
+
+import static org.easymock.EasyMock.createMock;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.scope.TargetDestructionException;
+import org.apache.tuscany.sca.core.scope.TargetInitializationException;
+import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReflectiveInstanceWrapperTestCase extends TestCase {
+ private ReflectiveInstanceWrapper<Object> wrapper;
+ private Object instance;
+ private EventInvoker<Object> initInvoker;
+ private EventInvoker<Object> destroyInvoker;
+
+ public void testWithNoCallbacks() {
+ wrapper = new ReflectiveInstanceWrapper<Object>(instance, null, null);
+ try {
+ wrapper.start();
+ } catch (TargetInitializationException e) {
+ fail();
+ }
+ try {
+ wrapper.stop();
+ } catch (TargetDestructionException e) {
+ fail();
+ }
+ }
+
+ public void testWithStartCallback() {
+ initInvoker.invokeEvent(instance);
+ EasyMock.replay(initInvoker);
+ wrapper = new ReflectiveInstanceWrapper<Object>(instance, initInvoker, null);
+ try {
+ wrapper.start();
+ } catch (TargetInitializationException e) {
+ fail();
+ }
+ EasyMock.verify(initInvoker);
+ }
+
+ public void testWithStopCallback() {
+ destroyInvoker.invokeEvent(instance);
+ EasyMock.replay(destroyInvoker);
+ wrapper = new ReflectiveInstanceWrapper<Object>(instance, null, destroyInvoker);
+ try {
+ wrapper.stop();
+ } catch (TargetDestructionException e) {
+ fail();
+ }
+ EasyMock.verify(destroyInvoker);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ instance = new Object();
+ initInvoker = createMock(EventInvoker.class);
+ destroyInvoker = createMock(EventInvoker.class);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java.fixme b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java.fixme
new file mode 100644
index 0000000000..29dcfa8169
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java.fixme
@@ -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.sca.implementation.java.injection;
+
+import static org.easymock.EasyMock.createMock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.invocation.CallbackWireObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CallbackWireObjectFactoryTestCase extends TestCase {
+
+ @SuppressWarnings({"unchecked"})
+ public void testCreateInstance() throws Exception {
+ ProxyFactory service = createMock(ProxyFactory.class);
+ Foo foo = new Foo() {
+ };
+ EasyMock.expect(service.createCallbackProxy(EasyMock.eq(Foo.class), EasyMock.isA(List.class))).andReturn(foo);
+ EasyMock.replay(service);
+ List<RuntimeWire> wires = new ArrayList<RuntimeWire>();
+ CallbackWireObjectFactory factory = new CallbackWireObjectFactory(Foo.class, service, wires);
+ assertEquals(foo, factory.getInstance());
+ EasyMock.verify(service);
+ }
+
+ private interface Foo {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java
new file mode 100644
index 0000000000..098789f495
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.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.java.injection;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Field;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FieldInjectorTestCase {
+
+ protected Field protectedField;
+
+ @Test
+ public void testIllegalAccess() throws Exception {
+ FieldInjector<Foo> injector = new FieldInjector<Foo>(protectedField, new SingletonObjectFactory<String>("foo"));
+ Foo foo = new Foo();
+ injector.inject(foo);
+ assertEquals("foo", foo.hidden);
+ }
+
+
+ @Before
+ public void setUp() throws Exception {
+ protectedField = Foo.class.getDeclaredField("hidden");
+ }
+
+ private class Foo {
+ private String hidden;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactoryTestCase.java.fixme b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactoryTestCase.java.fixme
new file mode 100644
index 0000000000..366f21d9f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactoryTestCase.java.fixme
@@ -0,0 +1,449 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.injection;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * This test case will test the JavaPropertyValueObjectFactory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaPropertyValueObjectFactoryTestCase {
+
+ /**
+ * The factory we should use for testing.
+ */
+ private static JavaPropertyValueObjectFactory factory;
+
+ /**
+ * The assembly factory used to create Properties.
+ */
+ private static AssemblyFactory assemblyFactory;
+
+ /**
+ * Test Setup.
+ */
+ @BeforeClass
+ public static void setup() {
+ // Create the factory
+ Mediator mediator = EasyMock.createNiceMock(Mediator.class);
+ DataBindingExtensionPoint dpep = new DefaultDataBindingExtensionPoint();
+ EasyMock.expect(mediator.getDataBindings()).andReturn(dpep).anyTimes();
+ EasyMock.replay(mediator);
+ factory = new JavaPropertyValueObjectFactory(mediator);
+
+ // Create the AssemblyFactory we should use
+ assemblyFactory = new DefaultAssemblyFactory();
+ }
+
+ /**
+ * A test that will attempt to inject positive, negative and zero into an
+ * int property.
+ */
+ @Test
+ public void testIntegerInjectionValid() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.expectedType = Integer.TYPE;
+
+ for (int i = -5; i <= 5; i++) {
+ params.propertyValue = Integer.toString(i);
+ params.expectedValueFromFactory = i;
+ doInjection(params);
+ }
+ }
+
+ /**
+ * A test that will attempt to inject positive, negative and zero into an
+ * int property using a JavaElement.
+ */
+ @Test
+ public void testIntegerInjectionValidWithJavaElement() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.expectedJavaElement = new JavaElementImpl(int.class);
+
+ for (int i = -5; i <= 5; i++) {
+ params.propertyValue = Integer.toString(i);
+ params.expectedValueFromFactory = i;
+ doInjection(params);
+ }
+ }
+
+ /**
+ * A test that will attempt to inject multiple int values into an
+ * int property.
+ */
+ @Test
+ public void testIntegerArrayInjectionValid() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.isMany = true;
+ params.expectedType = int.class;
+ params.propertyValue = "1 2 3 4 5";
+ params.expectedValueFromFactory = Arrays.asList(1, 2, 3, 4, 5);
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject multiple int values into an
+ * int property using a JavaElement.
+ */
+ @Test
+ public void testIntegerArrayInjectionValidWithJavaElement() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.isMany = true;
+ params.expectedJavaElement = new JavaElementImpl(int[].class);
+ params.propertyValue = "1 2 3 4 5";
+ int[] expected = { 1, 2, 3, 4, 5 };
+ params.expectedValueFromFactory = expected;
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject a non-number into an
+ * int property.
+ */
+ @Test
+ public void testIntegerInjectionBadNumberInvalid() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.expectedType = Integer.TYPE;
+ params.propertyValue = "a";
+ params.exceptionExpected = true;
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject a non-number into an
+ * int property using a JavaElement.
+ */
+ @Test
+ public void testIntegerInjectionBadNumberInvalidWithJavaElement() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.expectedJavaElement = new JavaElementImpl(Integer.TYPE);
+ params.propertyValue = "a";
+ params.exceptionExpected = true;
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject multiple int values into an
+ * int property where one of the property values is not a number.
+ * The injection should throw ObjectCreationException
+ */
+ @Test
+ public void testIntegerArrayInjectionBadNumberInvalid() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.isMany = true;
+ params.expectedType = int.class;
+ params.propertyValue = "1 2 aa 4 5";
+ params.exceptionExpected = true;
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject multiple int values into an
+ * int property using a JavaElement where one of the property
+ * values is not a number.
+ * The injection should throw ObjectCreationException
+ */
+ @Test
+ public void testIntegerArrayInjectionBadNumberInvalidWithJavaElement() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.isMany = true;
+ params.expectedJavaElement = new JavaElementImpl(int[].class);
+ params.propertyValue = "1 2 aa 4 5";
+ params.exceptionExpected = true;
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject an empty string into an int property.
+ * The injection should throw ObjectCreationException
+ */
+ @Test
+ public void testIntegerInjectionEmptyStringInvalid() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.expectedType = Integer.TYPE;
+ params.propertyValue = "";
+ params.exceptionExpected = true;
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject an empty string into an int property
+ * using a JavaElement.
+ * The injection should throw ObjectCreationException
+ */
+ @Test
+ public void testIntegerInjectionEmptyStringInvalidWithJavaElement() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "intField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_INT;
+ params.expectedJavaElement = new JavaElementImpl(Integer.TYPE);
+ params.propertyValue = "";
+ params.exceptionExpected = true;
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject a String into a String
+ * property.
+ */
+ @Test
+ public void testStringInjectionValid() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "StringField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_STRING;
+ params.expectedType = String.class;
+
+ params.propertyValue = "Some Test String";
+ params.expectedValueFromFactory = "Some Test String";
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject a String into a String
+ * property using a JavaElement.
+ */
+ @Test
+ public void testStringInjectionValidWithJavaElement() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "StringField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_STRING;
+ params.expectedJavaElement = new JavaElementImpl(String.class);
+
+ params.propertyValue = "Some Test String";
+ params.expectedValueFromFactory = "Some Test String";
+ doInjection(params);
+ }
+
+ /**
+ * This class defines all the parameters for the Property Injection test.
+ */
+ private class InjectionTestParams {
+ // Input parameters for the test
+ public boolean isMany = false;
+ public String propertyName;
+ public String propertyValue;
+ public QName xsdType;
+
+ // Expected result for test
+ public Object expectedValueFromFactory;
+ public Class<?> expectedType;
+ public JavaElementImpl expectedJavaElement;
+ public boolean exceptionExpected = false;
+ }
+
+ /**
+ * A test that will attempt to inject multiple String values into an
+ * String property.
+ */
+ @Test
+ public void testStringArrayInjectionValid() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "StringField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_STRING;
+ params.isMany = true;
+ params.expectedType = String.class;
+ params.propertyValue = "\"String1\" \"String2\" \"String3\" \"String4\" \"String5\"";
+ params.expectedValueFromFactory = Arrays.asList(
+ "String1", "String2", "String3", "String4", "String5");
+ doInjection(params);
+ }
+
+ /**
+ * A test that will attempt to inject multiple String values into an
+ * String property using a JavaElement.
+ */
+ @Test
+ public void testStringArrayInjectionValidWithJavaElement() {
+ InjectionTestParams params = new InjectionTestParams();
+ params.propertyName = "StringField";
+ params.xsdType = SimpleTypeMapperImpl.XSD_STRING;
+ params.isMany = true;
+ params.expectedJavaElement = new JavaElementImpl(String.class);
+ params.propertyValue = "\"String1\" \"String2\" \"String3\" \"String4\" \"String5\"";
+ params.expectedValueFromFactory = Arrays.asList(
+ "String1", "String2", "String3", "String4", "String5");
+ doInjection(params);
+ }
+
+ /**
+ * Utility method for testing creating properties with the
+ * JavaPropertyValueObjectFactory.
+ *
+ * @param testParams The parameters for the test
+ */
+ private void doInjection(final InjectionTestParams testParams) {
+ // Create the property
+ Property prop = assemblyFactory.createProperty();
+ prop.setMany(testParams.isMany);
+ prop.setName(testParams.propertyName);
+ prop.setXSDType(testParams.xsdType);
+
+ // Mock up the XML that will contain the Property details
+ Document doc = EasyMock.createNiceMock(Document.class);
+ Element rootElement = EasyMock.createMock(Element.class);
+ EasyMock.expect(doc.getDocumentElement()).andReturn(rootElement);
+ NodeList nodeList = EasyMock.createMock(NodeList.class);
+ EasyMock.expect(rootElement.getChildNodes()).andReturn(nodeList).anyTimes();
+ EasyMock.expect(nodeList.getLength()).andReturn(1);
+ Node node = EasyMock.createMock(Node.class);
+ EasyMock.expect(nodeList.item(0)).andReturn(node);
+ EasyMock.expect(node.getTextContent()).andReturn(testParams.propertyValue);
+ EasyMock.replay(doc, rootElement, nodeList, node);
+
+ // Create a factory either using the Class or JavaElementImpl constructor
+ ObjectFactory<?> objectFactory;
+ if (testParams.expectedJavaElement != null) {
+ objectFactory = factory.createValueFactory(prop, doc, testParams.expectedJavaElement);
+ } else {
+ objectFactory = factory.createValueFactory(prop, doc, testParams.expectedType);
+ }
+ Assert.assertNotNull(objectFactory);
+
+ // Lets test the factory
+ try {
+ // Create a new instance with the factory
+ Object value = objectFactory.getInstance();
+
+ // Did we expect an exception to be thrown?
+ if (testParams.exceptionExpected) {
+ Assert.fail("Test should have thrown ObjectCreationException");
+ }
+
+ // Make sure the result is of the correct type
+ if (testParams.expectedValueFromFactory instanceof Collection<?>) {
+ // Make sure the Collections contain the same type
+ Assert.assertTrue(value instanceof Collection<?>);
+ Iterator<?> iter1 = ((Collection<?>) testParams.expectedValueFromFactory).iterator();
+ Iterator<?> iter2 = ((Collection<?>) value).iterator();
+ Assert.assertEquals(iter1.next().getClass(), iter2.next().getClass());
+ } else {
+ Assert.assertEquals(testParams.expectedValueFromFactory.getClass(), value.getClass());
+ }
+
+ // Validate the result
+ Assert.assertNotNull(value);
+ if (testParams.expectedValueFromFactory.getClass().isArray()) {
+ Assert.assertTrue(compareArrays(testParams.expectedValueFromFactory, value));
+ } else {
+ Assert.assertEquals(testParams.expectedValueFromFactory, value);
+ }
+ } catch (ObjectCreationException ex) {
+ // Is this an expected exception?
+ if (testParams.exceptionExpected) {
+ // Make sure the exception error message contains the property name
+ Assert.assertTrue(ex.toString().indexOf(testParams.propertyName) != -1);
+
+ // Make sure the exception error message contains the property value
+ if (testParams.propertyValue != null) {
+ if (testParams.isMany) {
+ // FIXME: No simple way to do this for multi-value properties
+ } else {
+ Assert.assertTrue(ex.toString().indexOf(testParams.propertyValue) != -1);
+ }
+ }
+ } else {
+ // Test failure. We were not expecting an exception
+ ex.printStackTrace();
+ Assert.fail("Unexpected exception " + ex);
+ }
+ }
+ }
+
+ /**
+ * Compares two Objects that are actually arrays to make sure that they are
+ * equal.
+ *
+ * @param array1 The first array
+ * @param array2 The second array
+ * @return True if they are equal. False if they are not
+ */
+ private boolean compareArrays(final Object array1, final Object array2) {
+ // Check for primitive array types
+ if (array1 instanceof boolean[]) {
+ return Arrays.equals((boolean[]) array1, (boolean[]) array2);
+ }
+ if (array1 instanceof byte[]) {
+ return Arrays.equals((byte[]) array1, (byte[]) array2);
+ }
+ if (array1 instanceof char[]) {
+ return Arrays.equals((char[]) array1, (char[]) array2);
+ }
+ if (array1 instanceof double[]) {
+ return Arrays.equals((double[]) array1, (double[]) array2);
+ }
+ if (array1 instanceof float[]) {
+ return Arrays.equals((float[]) array1, (float[]) array2);
+ }
+ if (array1 instanceof int[]) {
+ return Arrays.equals((int[]) array1, (int[]) array2);
+ }
+ if (array1 instanceof long[]) {
+ return Arrays.equals((long[]) array1, (long[]) array2);
+ }
+ if (array1 instanceof short[]) {
+ return Arrays.equals((short[]) array1, (short[]) array2);
+ }
+
+ // Not a primitive so must be an Object[]
+ return Arrays.equals((Object[]) array1, (Object[]) array2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java
new file mode 100644
index 0000000000..e9cbce4390
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.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.implementation.java.injection;
+
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.implementation.java.invocation.EventInvocationException;
+import org.apache.tuscany.sca.implementation.java.invocation.MethodEventInvoker;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MethodEventInvokerTestCase {
+ private Method privateMethod;
+ private Method exceptionMethod;
+
+ @Test
+ public void testIllegalAccess() throws Exception {
+ MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(privateMethod);
+ try {
+ injector.invokeEvent(new Foo());
+ fail();
+ } catch (EventInvocationException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testException() throws Exception {
+ MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(exceptionMethod);
+ try {
+ injector.invokeEvent(new Foo());
+ fail();
+ } catch (RuntimeException e) {
+ // expected
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ privateMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("hidden");
+ exceptionMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("exception");
+
+ }
+
+ public class Foo {
+
+ public void foo() {
+ }
+
+ private void hidden() {
+ }
+
+ public void exception() {
+ throw new RuntimeException();
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java
new file mode 100644
index 0000000000..19184d5204
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.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.implementation.java.injection;
+
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MethodInjectorTestCase {
+ private Method fooMethod;
+ private Method privateMethod;
+ private Method exceptionMethod;
+
+ @Test
+ public void testIllegalArgument() throws Exception {
+ ObjectFactory<Object> factory = new SingletonObjectFactory<Object>(new Object());
+ MethodInjector<Foo> injector = new MethodInjector<Foo>(fooMethod, factory);
+ try {
+ injector.inject(new Foo());
+ fail();
+ } catch (ObjectCreationException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testException() throws Exception {
+ ObjectFactory<Object> factory = new SingletonObjectFactory<Object>("foo");
+ MethodInjector<Foo> injector = new MethodInjector<Foo>(exceptionMethod, factory);
+ try {
+ injector.inject(new Foo());
+ fail();
+ } catch (RuntimeException e) {
+ // expected
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ fooMethod = Foo.class.getMethod("foo", String.class);
+ privateMethod = Foo.class.getDeclaredMethod("hidden", String.class);
+ exceptionMethod = Foo.class.getDeclaredMethod("exception", String.class);
+
+ }
+
+ private class Foo {
+
+ public void foo(String bar) {
+ }
+
+ private void hidden(String bar) {
+ }
+
+ public void exception(String bar) {
+ throw new RuntimeException();
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java.fixme b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java.fixme
new file mode 100644
index 0000000000..ed7a0e7d03
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java.fixme
@@ -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.sca.implementation.java.injection;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceObjectFactoryTestCase extends TestCase {
+
+ public void testResolveFromHostByType() throws Exception {
+ ResourceHost host = EasyMock.createMock(ResourceHost.class);
+ EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn("foo");
+ EasyMock.replay(host);
+ ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, false, host);
+ assertEquals("foo", factory.getInstance());
+ EasyMock.verify(host);
+ }
+
+ public void testResolveFromHostByName() throws Exception {
+ ResourceHost host = EasyMock.createMock(ResourceHost.class);
+ EasyMock.expect(host.resolveResource(EasyMock.eq(String.class),
+ EasyMock.eq("sca://localhost/bar"))).andReturn("foo");
+ EasyMock.replay(host);
+ ResourceObjectFactory<String> factory =
+ new ResourceObjectFactory<String>(String.class, "sca://localhost/bar", false, host);
+ assertEquals("foo", factory.getInstance());
+ EasyMock.verify(host);
+ }
+
+
+ public void testResolveFromParentThenResolveFromHostNotFound() throws Exception {
+ ResourceHost host = EasyMock.createMock(ResourceHost.class);
+ EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null);
+ EasyMock.replay(host);
+ ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, true, host);
+ assertNull(factory.getInstance());
+ EasyMock.verify(host);
+ }
+
+ public void testResolveByTypeNotFound() throws Exception {
+// ResourceHost host = EasyMock.createMock(ResourceHost.class);
+// EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null);
+// EasyMock.replay(host);
+//
+// RuntimeWire wire = EasyMock.createMock(RuntimeWire.class);
+// EasyMock.expect(wire.getTargetInstance()).andReturn(null);
+// EasyMock.replay(wire);
+//
+// ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, false, host);
+// try {
+// factory.getInstance();
+// fail();
+// } catch (ResourceNotFoundException e) {
+// //expected
+// }
+// EasyMock.verify(host);
+ }
+
+ public void testResolveByTypeNotFoundOptional() throws Exception {
+ ResourceHost host = EasyMock.createMock(ResourceHost.class);
+ EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null);
+ EasyMock.replay(host);
+ ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, true, host);
+ assertNull(factory.getInstance());
+ EasyMock.verify(host);
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java
new file mode 100644
index 0000000000..c1650c3a83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.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.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Implementation of ObjectFactory that returns a single instance, typically an immutable type.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SingletonObjectFactory<T> implements ObjectFactory<T> {
+ private final T instance;
+
+ public SingletonObjectFactory(T instance) {
+ this.instance = instance;
+ }
+
+ public T getInstance() {
+ return instance;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java
new file mode 100644
index 0000000000..0bb222bad4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.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 org.apache.tuscany.sca.implementation.java.injection;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SingletonObjectFactoryTestCase {
+
+ @Test
+ public void testSingleton() throws Exception {
+ Object o = new Object();
+ SingletonObjectFactory<Object> factory = new SingletonObjectFactory<Object>(o);
+ assertEquals(o, factory.getInstance());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactory.java
new file mode 100644
index 0000000000..de371e09bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactory.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Creates new instances of a Java class
+ *
+ * @version $Rev$ $Date$
+ * @see org.apache.tuscany.sca.implementation.java.injection.Injector
+ */
+public class TestObjectFactory<T> implements ObjectFactory<T> {
+
+ private final Constructor<T> ctr;
+ private ObjectFactory[] initializerFactories;
+
+ /**
+ * Creates the object factory
+ *
+ * @param ctr the constructor to use when instantiating a new object
+ */
+ public TestObjectFactory(Constructor<T> ctr) {
+ assert ctr != null;
+ this.ctr = ctr;
+ initializerFactories = new ObjectFactory[ctr.getParameterTypes().length];
+ }
+
+ /**
+ * Creates the object factory
+ *
+ * @param ctr the constructor to use when instantiating a new object
+ * @param factories an ordered list of <code>ObjectFactory</code>s to use for returning constructor parameters
+ */
+ public TestObjectFactory(Constructor<T> ctr, List<ObjectFactory> factories) {
+ assert ctr != null;
+ int params = ctr.getParameterTypes().length;
+ assert params == factories.size();
+ this.ctr = ctr;
+ initializerFactories = new ObjectFactory[params];
+ int i = 0;
+ for (ObjectFactory factory : factories) {
+ initializerFactories[i] = factory;
+ i++;
+ }
+ }
+
+ /**
+ * Returns the ordered array of <code>ObjectFactory</code>s use in creating constructor parameters
+ */
+ public ObjectFactory[] getInitializerFactories() {
+ return initializerFactories;
+ }
+
+ /**
+ * Sets an <code>ObjectFactory</code>s to use in creating constructor parameter
+ *
+ * @param pos the constructor parameter position
+ * @param factory the object factory
+ */
+ public void setInitializerFactory(int pos, ObjectFactory factory) {
+ assert pos < initializerFactories.length;
+ initializerFactories[pos] = factory;
+ }
+
+ /**
+ * Creates a new instance of an object
+ */
+ public T getInstance() throws ObjectCreationException {
+ int size = initializerFactories.length;
+ Object[] initargs = new Object[size];
+ // create the constructor arg array
+ for (int i = 0; i < size; i++) {
+ ObjectFactory<?> objectFactory = initializerFactories[i];
+ if (objectFactory == null) {
+ // this can happen if a reference is optional
+ initargs[i] = null;
+ } else {
+ initargs[i] = objectFactory.getInstance();
+ }
+ }
+ try {
+ ctr.setAccessible(true);
+ return ctr.newInstance(initargs);
+ } catch (IllegalArgumentException e) {
+ String name = ctr.getName();
+ throw new ObjectCreationException("Exception thrown by constructor: " + name, e);
+ } catch (InstantiationException e) {
+ String name = ctr.getDeclaringClass().getName();
+ throw new AssertionError("Class is not instantiable [" + name + "]");
+ } catch (IllegalAccessException e) {
+ String name = ctr.getName();
+ throw new AssertionError("Constructor is not accessible [" + name + "]");
+ } catch (InvocationTargetException e) {
+ String name = ctr.getName();
+ throw new ObjectCreationException("Exception thrown by constructor: " + name, e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java
new file mode 100644
index 0000000000..ea9d15b3f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.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.sca.implementation.java.injection;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestObjectFactoryTestCase {
+
+ private Constructor<Foo> ctor;
+
+ @Test
+ public void testConstructorInjection() throws Exception {
+ List<ObjectFactory> initializers = new ArrayList<ObjectFactory>();
+ initializers.add(new SingletonObjectFactory<String>("foo"));
+ TestObjectFactory<Foo> factory = new TestObjectFactory<Foo>(ctor, initializers);
+ Foo foo = factory.getInstance();
+ assertEquals("foo", foo.foo);
+ }
+
+ /**
+ * Verifies null parameters can be passed to a constructor. This is valid when a reference is optional during
+ * constructor injection
+ */
+ @Test
+ public void testConstructorInjectionOptionalParam() throws Exception {
+ List<ObjectFactory> initializers = new ArrayList<ObjectFactory>();
+ initializers.add(null);
+ TestObjectFactory<Foo> factory = new TestObjectFactory<Foo>(ctor, initializers);
+ Foo foo = factory.getInstance();
+ assertNull(foo.foo);
+ }
+
+ @Test
+ public void testConstructorInitializerInjection() throws Exception {
+ TestObjectFactory<Foo> factory = new TestObjectFactory<Foo>(ctor);
+ factory.setInitializerFactory(0, new SingletonObjectFactory<String>("foo"));
+ Foo foo = factory.getInstance();
+ assertEquals("foo", foo.foo);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ ctor = Foo.class.getConstructor(String.class);
+ }
+
+ private static class Foo {
+
+ private String foo;
+
+ public Foo(String foo) {
+ this.foo = foo;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java
new file mode 100644
index 0000000000..e993cdd382
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.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.java.util;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Bean1 extends SuperBean {
+
+ public static final int ALL_BEAN1_FIELDS = 6 + ALL_SUPER_FIELDS;
+ public static final int ALL_BEAN1_PUBLIC_PROTECTED_FIELDS = 5 + ALL_SUPER_PUBLIC_PROTECTED_FIELDS;
+ public static final int ALL_BEAN1_METHODS = 4 + ALL_SUPER_METHODS - 1;
+ public String field3;
+ protected String field2;
+ private String field1;
+
+ public void setMethod1(String param) {
+ }
+
+ public void setMethod1(int param) {
+ }
+
+ @Override
+ public void override(String param) throws Exception {
+ }
+
+
+ public void noOverride(String param) throws Exception {
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java
new file mode 100644
index 0000000000..f5128f6a6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.util;
+
+import java.util.List;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Bean2 {
+
+ private List methodList;
+ private List fieldList;
+
+ public List getMethodList() {
+ return methodList;
+ }
+
+ public void setMethodList(List list) {
+ methodList = list;
+ }
+
+ public List getfieldList() {
+ return fieldList;
+ }
+
+ public void setfieldList(List list) {
+ throw new RuntimeException("setter inadvertantly called");
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Entry.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Entry.java
new file mode 100644
index 0000000000..a5e12d181c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Entry.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.java.util;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Entry {
+
+ String getString();
+
+ void setString(String val);
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
new file mode 100644
index 0000000000..9624865dcc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.junit.Test;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaIntrospectionHelperTestCase {
+
+ private List testNoGenericsList;
+ private List<String> testList;
+ private Map<String, Bean1> testMap;
+ private Entry[] testArray;
+ private String[] testStringArray;
+
+ @Test
+ public void testBean1AllPublicProtectedFields() throws Exception {
+ Set<Field> beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class, true);
+ assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS
+ }
+
+ @Test
+ public void testGetSuperAllMethods() throws Exception {
+ Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class, true);
+ assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size());
+ }
+
+ @Test
+ public void testGetBean1AllMethods() throws Exception {
+ Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class, true);
+ assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size());
+ }
+
+ @Test
+ public void testOverrideMethod() throws Exception {
+ Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class, true);
+ boolean invoked = false;
+ for (Method method : beanFields) {
+ if (method.getName().equals("override")) {
+ method.invoke(new Bean1(), "foo");
+ invoked = true;
+ }
+ }
+ if (!invoked) {
+ throw new Exception("Override never invoked");
+ }
+ }
+
+ @Test
+ public void testNoOverrideMethod() throws Exception {
+ Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class, true);
+ boolean found = false;
+ for (Method method : beanFields) {
+ if (method.getName().equals("noOverride") && method.getParameterTypes().length == 0) {
+ found = true;
+ }
+ }
+ if (!found) {
+ throw new Exception("No override not found");
+ }
+ }
+
+ @Test
+ public void testDefaultConstructor() throws Exception {
+ Constructor<Bean2> ctr = JavaIntrospectionHelper.getDefaultConstructor(Bean2.class);
+ assertEquals(ctr, Bean2.class.getConstructor());
+ assertTrue(Bean2.class == ctr.newInstance((Object[]) null).getClass());
+ }
+
+
+ @Test
+ public void testGetAllInterfaces() {
+ Set<Class<?>> interfaces = JavaIntrospectionHelper.getAllInterfaces(Z.class);
+ assertEquals(2, interfaces.size());
+ assertTrue(interfaces.contains(W.class));
+ assertTrue(interfaces.contains(W2.class));
+ }
+
+
+ @Test
+ public void testGetAllInterfacesObject() {
+ Set<Class<?>> interfaces = JavaIntrospectionHelper.getAllInterfaces(Object.class);
+ assertEquals(0, interfaces.size());
+ }
+
+ @Test
+ public void testGetAllInterfacesNoInterfaces() {
+ Set<Class<?>> interfaces = JavaIntrospectionHelper.getAllInterfaces(NoInterface.class);
+ assertEquals(0, interfaces.size());
+ }
+
+ /**
+ * Tests generics introspection capabilities
+ */
+ @Test
+ public void testGenerics() throws Exception {
+
+ List classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testList").getGenericType());
+ assertEquals(1, classes.size());
+ assertEquals(String.class, classes.get(0));
+
+ classes =
+ JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testNoGenericsList").getGenericType());
+ assertEquals(0, classes.size());
+
+ classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testMap").getGenericType());
+ assertEquals(2, classes.size());
+ assertEquals(String.class, classes.get(0));
+ assertEquals(Bean1.class, classes.get(1));
+
+ classes = JavaIntrospectionHelper
+ .getGenerics(getClass().getDeclaredMethod("fooMethod", Map.class).getGenericParameterTypes()[0]);
+ assertEquals(2, classes.size());
+ assertEquals(String.class, classes.get(0));
+ assertEquals(Bean1.class, classes.get(1));
+
+ classes = JavaIntrospectionHelper
+ .getGenerics(getClass().getDeclaredMethod("fooMethod", List.class).getGenericParameterTypes()[0]);
+ assertEquals(1, classes.size());
+ assertEquals(String.class, classes.get(0));
+
+ }
+
+ private void fooMethod(List<String> foo) {
+
+ }
+
+ private void fooMethod(Map<String, Bean1> foo) {
+
+ }
+
+ public void setTestArray(Entry[] array) {
+ }
+
+ private interface W {
+
+ }
+
+ private interface W2 {
+
+ }
+
+ private class X implements W {
+
+ }
+
+ private class Y extends X implements W, W2 {
+
+ }
+
+ private class Z extends Y {
+
+ }
+
+ private class NoInterface {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java
new file mode 100644
index 0000000000..408cedb8be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.util;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SuperBean {
+
+ public static final int ALL_SUPER_FIELDS = 6;
+ public static final int ALL_SUPER_PUBLIC_PROTECTED_FIELDS = 5;
+ public static final int ALL_SUPER_METHODS = 4;
+ public String superField2;
+
+ protected String superField3;
+
+ private String superField1;
+
+ public void setSuperMethod1(String param) {
+ }
+
+ public void setSuperMethod1(int param) {
+ }
+
+ public void override(String param) throws Exception {
+ throw new Exception("Override not handled");
+ }
+
+ public void noOverride() throws Exception {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-java/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/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/sebastien/java/embed/modules/implementation-java/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2d005103c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/META-INF/MANIFEST.MF
@@ -0,0 +1,49 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.java;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.implementation.java.introspect,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef.java",
+ org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.implementation.java,org.oasisopen.sca",
+ org.apache.tuscany.sca.implementation.java.introspect.impl;version="2.0.0"
+Private-Package: org.apache.tuscany.sca.implementation.java.impl;versi
+ on="2.0.0",org.apache.tuscany.sca.implementation.java.introspect.impl;v
+ ersion="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Java Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Java Implementation Model
+Import-Package: javax.jws,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.xml,
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.java
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-java/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-java/pom.xml
new file mode 100644
index 0000000000..0922650a18
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/pom.xml
@@ -0,0 +1,124 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <name>Apache Tuscany SCA Implementation Java Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-builder</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency-->
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.java
new file mode 100644
index 0000000000..a3b0343d51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * Represents a Java implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BaseJavaImplementation extends Implementation, Extensible {
+
+ /**
+ * Returns the name of the Java implementation class.
+ *
+ * @return the name of the Java implementation class
+ */
+ String getName();
+
+ /**
+ * Sets the name of the Java implementation class.
+ *
+ * @param className the name of the Java implementation class
+ */
+ void setName(String className);
+
+ /**
+ * Returns the Java implementation class.
+ *
+ * @return the Java implementation class
+ */
+ Class<?> getJavaClass();
+
+ /**
+ * Sets the Java implementation class.
+ *
+ * @param javaClass the Java implementation class
+ */
+ void setJavaClass(Class<?> javaClass);
+
+ /**
+ * Customize the implementation type so that components are implemented using Java based framework such as
+ * implementation.spring or implementation.jaxrs can leverage the introspection
+ * @param type
+ */
+ void setType(QName type);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java
new file mode 100644
index 0000000000..f98a617925
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java;
+
+/**
+ * A factory for the Java model.
+ *
+ * @version $Rev$ $Date$
+ */
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.impl.JavaImplementationFactoryImpl;
+
+public class DefaultJavaImplementationFactory extends JavaImplementationFactoryImpl implements JavaImplementationFactory {
+
+ public DefaultJavaImplementationFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ // For UNIT test only
+ public DefaultJavaImplementationFactory() {
+ super(new DefaultExtensionPointRegistry());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/IntrospectionException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/IntrospectionException.java
new file mode 100644
index 0000000000..2198a632c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/IntrospectionException.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.java;
+
+import java.lang.reflect.Member;
+
+/**
+ * Denotes a problem processing annotations on a POJO implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntrospectionException extends Exception {
+ private static final long serialVersionUID = -361025119035104470L;
+ private Member member;
+
+ public IntrospectionException() {
+ }
+
+ public IntrospectionException(String message) {
+ super(message);
+ }
+
+ public IntrospectionException(String message, Member member) {
+ super(message);
+ this.member = member;
+ }
+
+ public IntrospectionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IntrospectionException(Throwable cause) {
+ super(cause);
+ }
+
+ public Member getMember() {
+ return member;
+ }
+
+ public void setMember(Member member) {
+ this.member = member;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaConstructorImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaConstructorImpl.java
new file mode 100644
index 0000000000..df76d3ea4e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaConstructorImpl.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 org.apache.tuscany.sca.implementation.java;
+
+import java.lang.reflect.Constructor;
+
+
+/**
+ * Hold injection information for the constructor used to instantiate a
+ * component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaConstructorImpl<T> {
+ private Constructor<T> constructor;
+ private JavaParameterImpl[] parameters;
+
+ public JavaConstructorImpl(Constructor<T> constructor) {
+ this.constructor = constructor;
+ int size = constructor.getParameterTypes().length;
+ parameters = new JavaParameterImpl[size];
+ for (int i = 0; i < size; i++) {
+ parameters[i] = new JavaParameterImpl(constructor, i);
+ }
+ }
+
+ /**
+ * @return the constructor
+ */
+ public Constructor<T> getConstructor() {
+ return constructor;
+ }
+
+ /**
+ * @return the parameters
+ */
+ public JavaParameterImpl[] getParameters() {
+ return parameters;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java
new file mode 100644
index 0000000000..e748a5f6fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+/**
+ * This class represents a java element such as a Package, Class, Constructor,
+ * Field, Method or Parameter.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaElementImpl {
+ private AnnotatedElement anchor;
+ private ElementType elementType;
+ private Class<?> type;
+ private Type genericType;
+ private int index = -1;
+ private String name;
+ private Class<? extends Annotation> classifer;
+
+ public JavaElementImpl(Class<?> cls) {
+ this.anchor = cls;
+ this.elementType = ElementType.TYPE;
+ this.type = cls;
+ this.genericType = cls;
+ this.name = cls.getName();
+ }
+
+ public JavaElementImpl(Field field) {
+ this.anchor = field;
+ this.elementType = ElementType.FIELD;
+ this.type = field.getType();
+ this.genericType = field.getGenericType();
+ this.name = field.getName();
+ }
+
+ public JavaElementImpl(Constructor<?> constructor, int index) {
+ this.anchor = constructor;
+ this.elementType = ElementType.PARAMETER;
+ this.type = constructor.getParameterTypes()[index];
+ this.genericType = constructor.getGenericParameterTypes()[index];
+ this.index = index;
+ this.name = "";
+ }
+
+ public JavaElementImpl(Method method, int index) {
+ this.anchor = method;
+ this.elementType = ElementType.PARAMETER;
+ this.type = method.getParameterTypes()[index];
+ this.genericType = method.getGenericParameterTypes()[index];
+ this.index = index;
+ this.name = "";
+ }
+
+ /**
+ * For testing purpose
+ *
+ * @param name
+ * @param type
+ * @param classifer TODO
+ * @param elementType
+ */
+ public JavaElementImpl(String name, Class<?> type, Class<? extends Annotation> classifer) {
+ super();
+ this.type = type;
+ this.name = name;
+ this.classifer = classifer;
+ }
+
+ /**
+ * @return the anchor
+ */
+ public AnnotatedElement getAnchor() {
+ return anchor;
+ }
+
+ /**
+ * @return the elementType
+ */
+ public ElementType getElementType() {
+ return elementType;
+ }
+
+ /**
+ * @return the genericType
+ */
+ public Type getGenericType() {
+ return genericType;
+ }
+
+ /**
+ * @return the index
+ */
+ public int getIndex() {
+ return index;
+ }
+
+ /**
+ * @return the type
+ */
+ public Class<?> getType() {
+ return type;
+ }
+
+ /**
+ * @return the annotations
+ */
+ public Annotation[] getAnnotations() {
+ if (elementType == ElementType.PARAMETER) {
+ if (anchor instanceof Method) {
+ // We only care about the method-level annotations
+ return ((Method)anchor).getAnnotations();
+ }
+ if (anchor instanceof Constructor) {
+ return ((Constructor<?>)anchor).getParameterAnnotations()[index];
+ }
+ }
+ return anchor.getAnnotations();
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+ for (Annotation a : getAnnotations()) {
+ if (a.annotationType() == annotationType) {
+ return annotationType.cast(a);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the classifier
+ */
+ public Class<? extends Annotation> getClassifer() {
+ return classifer;
+ }
+
+ /**
+ * @param classifer the classifier to set
+ */
+ public void setClassifer(Class<? extends Annotation> classifer) {
+ this.classifer = classifer;
+ }
+
+
+ @Override
+ public String toString() {
+ return anchor.toString() + (elementType == ElementType.PARAMETER ? "[" + index + "]" : "");
+ }
+
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((anchor == null) ? 0 : anchor.hashCode());
+ result = PRIME * result + index;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final JavaElementImpl other = (JavaElementImpl)obj;
+ if (anchor == null) {
+ if (other.anchor != null) {
+ return false;
+ }
+ } else if (!anchor.equals(other.anchor)) {
+ return false;
+ }
+ if (index != other.index) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
new file mode 100644
index 0000000000..60649eb5d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a Java implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaImplementation extends BaseJavaImplementation {
+ QName TYPE = new QName(SCA11_NS, "implementation.java");
+ /**
+ * Returns the constructor used to instantiate implementation instances.
+ *
+ * @return the constructor used to instantiate implementation instances
+ */
+ JavaConstructorImpl<?> getConstructor();
+
+ /**
+ * Sets the constructor used to instantiate implementation instances
+ *
+ * @param definition the constructor used to instantiate implementation instances
+ */
+ void setConstructor(JavaConstructorImpl<?> definition);
+
+ /**
+ * Returns the component initializer method.
+ *
+ * @return the component initializer method
+ */
+ Method getInitMethod();
+
+ /**
+ * Sets the component initializer method.
+ *
+ * @param initMethod the component initializer method
+ */
+ void setInitMethod(Method initMethod);
+
+ /**
+ * Returns the component destructor method.
+ *
+ * @return the component destructor method
+ */
+ Method getDestroyMethod();
+
+ /**
+ * Sets the component destructor method.
+ *
+ * @param destroyMethod the component destructor method
+ */
+ void setDestroyMethod(Method destroyMethod);
+
+ /**
+ * Returns the resources injected into this implementation.
+ *
+ * @return
+ */
+ Map<String, JavaResourceImpl> getResources();
+
+ /**
+ * Returns the Java member used to inject a conversation ID.
+ *
+ * @return
+ */
+ List<Member> getConversationIDMembers();
+
+ /**
+ * Sets the Java member used to inject a conversation ID.
+ *
+ * @param conversationIDMember
+ */
+ void addConversationIDMember(Member conversationIDMember);
+
+ /**
+ * Returns true if AllowsPassReference is set.
+ *
+ * @return true if AllowsPassByReference is set
+ */
+ boolean isAllowsPassByReference();
+
+ /**
+ * @param allowsPassByReference the allowsPassByReference to set
+ */
+ void setAllowsPassByReference(boolean allowsPassByReference);
+
+ /**
+ * @return the allowsPassByReferenceMethods
+ */
+ List<Method> getAllowsPassByReferenceMethods();
+
+ /**
+ * @param method
+ * @return
+ */
+ boolean isAllowsPassByReference(Method method);
+
+ /**
+ * @return the constructors
+ */
+ Map<Constructor, JavaConstructorImpl> getConstructors();
+
+ /**
+ * @return the eagerInit
+ */
+ boolean isEagerInit();
+
+ /**
+ * @param eagerInit the eagerInit to set
+ */
+ void setEagerInit(boolean eagerInit);
+
+ /**
+ * @return the callbacks
+ */
+ Map<String, Collection<JavaElementImpl>> getCallbackMembers();
+
+ /**
+ * @return the properties
+ */
+ Map<String, JavaElementImpl> getPropertyMembers();
+
+ /**
+ * @return the references
+ */
+ Map<String, JavaElementImpl> getReferenceMembers();
+
+ /**
+ * @return the scope
+ */
+ JavaScopeImpl getJavaScope();
+
+ /**
+ * @param scope the scope to set
+ */
+ void setJavaScope(JavaScopeImpl scope);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationFactory.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationFactory.java
new file mode 100644
index 0000000000..8228c80372
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationFactory.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.sca.implementation.java;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+
+
+/**
+ * Factory for the Java model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaImplementationFactory {
+
+ /**
+ * Creates a new Java implementation model.
+ *
+ * @return
+ */
+ JavaImplementation createJavaImplementation();
+
+ /**
+ * Creates a new Java implementation model from an implementation class.
+ *
+ * @param implementationClass The implementation class to introspect.
+ * @return
+ */
+ JavaImplementation createJavaImplementation(Class<?> implementationClass) throws IntrospectionException;
+
+ /**
+ * Creates the contents of a Java implementation model from an implementation class.
+ *
+ * @param implementationClass The implementation class to introspect.
+ * @return
+ */
+ void createJavaImplementation(JavaImplementation javaImplementation, Class<?> implementationClass) throws IntrospectionException;
+
+ /**
+ * Registers the given visitor.
+ *
+ * @param visitor
+ */
+ void addClassVisitor(JavaClassVisitor visitor);
+
+ /**
+ * Deregisters the given visitor.
+ */
+ void removeClassVisitor(JavaClassVisitor visitor);
+
+ /**
+ * Returns the list of visitors.
+ *
+ * @return
+ */
+ List<JavaClassVisitor> getClassVisitors();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaParameterImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaParameterImpl.java
new file mode 100644
index 0000000000..80911a9552
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaParameterImpl.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 org.apache.tuscany.sca.implementation.java;
+
+import java.lang.reflect.Constructor;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaParameterImpl extends JavaElementImpl {
+ /**
+ * @param constructor
+ * @param index
+ */
+ public JavaParameterImpl(Constructor<?> constructor, int index) {
+ super(constructor, index);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaResourceImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaResourceImpl.java
new file mode 100644
index 0000000000..19a9f38549
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaResourceImpl.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java;
+
+
+
+/**
+ * A resource dependency declared by a Java component implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaResourceImpl {
+ private JavaElementImpl element;
+ private String mappedName;
+ private boolean optional;
+
+ public JavaResourceImpl(JavaElementImpl element) {
+ this.element = element;
+ }
+
+ /**
+ * The name of the resource
+ *
+ * @return the name of the resource
+ */
+ public String getName() {
+ return element.getName();
+ }
+
+ /**
+ * Returns the URI of the resource
+ *
+ * @return the URI of the resource
+ */
+ public String getMappedName() {
+ return mappedName;
+ }
+
+ /**
+ * Sets the resource URI
+ */
+ public void setMappedName(String mappedName) {
+ this.mappedName = mappedName;
+ }
+
+ /**
+ * If true, the resource is optional
+ *
+ * @return true if the resource is optional
+ */
+ public boolean isOptional() {
+ return optional;
+ }
+
+ /**
+ * Sets whether the resource is optional
+ */
+ public void setOptional(boolean optional) {
+ this.optional = optional;
+ }
+
+ /**
+ * @return the element
+ */
+ public JavaElementImpl getElement() {
+ return element;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java
new file mode 100644
index 0000000000..c977736630
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.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.java;
+
+/**
+ * The default implementation scopes supported by assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaScopeImpl {
+ public static final JavaScopeImpl STATELESS = new JavaScopeImpl("STATELESS");
+ public static final JavaScopeImpl COMPOSITE = new JavaScopeImpl("COMPOSITE");
+ public static final JavaScopeImpl INVALID = new JavaScopeImpl("INVALID");
+
+ private String scope;
+
+ public JavaScopeImpl(String scope) {
+ this.scope = scope.toUpperCase().intern();
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ final JavaScopeImpl scope1 = (JavaScopeImpl) o;
+ return !(scope != null ? scope != scope1.scope.intern() : scope1.scope != null);
+ }
+
+ @Override
+ public int hashCode() {
+ return scope != null ? scope.hashCode() : 0;
+ }
+
+ @Override
+ public String toString() {
+ return scope;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java
new file mode 100644
index 0000000000..7cbb4d7a0c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.implementation.java.BaseJavaImplementation;
+
+/**
+ * Represents a Java implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class BaseJavaImplementationImpl extends ImplementationImpl implements BaseJavaImplementation {
+
+ private String className;
+ private Class<?> javaClass;
+
+ protected BaseJavaImplementationImpl(QName type) {
+ super(type);
+ }
+
+ public String getName() {
+ if (isUnresolved()) {
+ return className;
+ } else if (javaClass != null) {
+ return javaClass.getName();
+ } else {
+ return null;
+ }
+ }
+
+ public void setName(String className) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ }
+ this.className = className;
+ }
+
+ public Class<?> getJavaClass() {
+ return javaClass;
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ this.javaClass = javaClass;
+ if (this.className == null) {
+ this.className = javaClass.getName();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getType() + " (class=" + getName() + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getName()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof BaseJavaImplementation) {
+ if (getName() != null) {
+ return getName().equals(((BaseJavaImplementation)obj).getName());
+ } else {
+ return ((BaseJavaImplementation)obj).getName() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public void setType(QName type) {
+ this.type = type;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
new file mode 100644
index 0000000000..491408098e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+
+/**
+ * An extensible Java class introspector implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaClassIntrospectorImpl {
+
+ private List<JavaClassVisitor> visitors;
+
+ public JavaClassIntrospectorImpl(List<JavaClassVisitor> visitors) {
+ this.visitors = visitors;
+ }
+
+ /**
+ * JSR-250 PFD recommends the following guidelines for how annotations
+ * interact with inheritance in order to keep the resulting complexity in
+ * control:
+ * <ol>
+ * <li>Class-level annotations only affect the class they annotate and
+ * their members, that is, its methods and fields. They never affect a
+ * member declared by a superclass, even if it is not hidden or overridden
+ * by the class in question.
+ * <li>In addition to affecting the annotated class, class-level
+ * annotations may act as a shorthand for member-level annotations. If a
+ * member carries a specific member-level annotation, any annotations of the
+ * same type implied by a class-level annotation are ignored. In other
+ * words, explicit member-level annotations have priority over member-level
+ * annotations implied by a class-level annotation.
+ * <li>The interfaces implemented by a class never contribute annotations
+ * to the class itself or any of its members.
+ * <li>Members inherited from a superclass and which are not hidden or
+ * overridden maintain the annotations they had in the class that declared
+ * them, including member-level annotations implied by class-level ones.
+ * <li>Member-level annotations on a hidden or overridden member are always
+ * ignored.
+ * </ol>
+ */
+ public void introspectClass(JavaImplementation type, Class<?> clazz)
+ throws IntrospectionException {
+ for (JavaClassVisitor visitor : visitors) {
+ visitor.visitClass(clazz, type);
+ for (Constructor<?> constructor : clazz.getConstructors()) {
+ visitor.visitConstructor(constructor, type);
+ // Assuming the visitClass or visitConstructor will populate the
+ // type.getConstructors
+ JavaConstructorImpl<?> definition = type.getConstructors().get(constructor);
+ if (definition != null) {
+ for (JavaParameterImpl p : definition.getParameters()) {
+ visitor.visitConstructorParameter(p, type);
+ }
+ }
+ }
+
+ Set<Field> fields = JavaIntrospectionHelper.getInjectableFields(clazz, true);
+ for (Field field : fields) {
+ visitor.visitField(field, type);
+ }
+
+ Set<Method> methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz, true);
+ for (Method method : methods) {
+ visitor.visitMethod(method, type);
+ }
+
+ // Check if any private methods have illegal annotations that should be raised as errors
+ Set<Method> privateMethods = JavaIntrospectionHelper.getPrivateMethods(clazz);
+ for (Method method : privateMethods) {
+ visitor.visitMethod(method, type);
+ }
+
+ Class<?> superClass = clazz.getSuperclass();
+ if (superClass != null) {
+ visitSuperClass(superClass, type, visitor);
+ }
+
+ visitor.visitEnd(clazz, type);
+
+ }
+
+ }
+
+ private void visitSuperClass(Class<?> clazz, JavaImplementation type, JavaClassVisitor visitor)
+ throws IntrospectionException {
+ if (!Object.class.equals(clazz)) {
+ visitor.visitSuperClass(clazz, type);
+ clazz = clazz.getSuperclass();
+ if (clazz != null) {
+ visitSuperClass(clazz, type, visitor);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
new file mode 100644
index 0000000000..a579a6719c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.impl;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+
+
+/**
+ * A factory for the Java model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class JavaImplementationFactoryImpl implements JavaImplementationFactory {
+
+ private List<JavaClassVisitor> visitors = new ArrayList<JavaClassVisitor>();
+ private JavaClassIntrospectorImpl introspector;
+ private boolean loaded;
+ protected ExtensionPointRegistry registry;
+
+ public JavaImplementationFactoryImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public JavaImplementation createJavaImplementation() {
+ JavaImplementation javaImplementation = new JavaImplementationImpl();
+ return javaImplementation;
+ }
+
+ public JavaImplementation createJavaImplementation(Class<?> implementationClass) throws IntrospectionException {
+ JavaImplementation javaImplementation = createJavaImplementation();
+ getIntrospector().introspectClass(javaImplementation, implementationClass);
+ return javaImplementation;
+ }
+
+ public void createJavaImplementation(JavaImplementation javaImplementation, Class<?> implementationClass) throws IntrospectionException {
+ getIntrospector().introspectClass(javaImplementation, implementationClass);
+ }
+
+ public void addClassVisitor(JavaClassVisitor visitor) {
+ for (JavaClassVisitor tmpVisitor : visitors){
+ if (tmpVisitor.getClass() == visitor.getClass()){
+ // trying to add a duplicate visitor so
+ // ignore it
+ return;
+ }
+ }
+ visitors.add(visitor);
+ }
+
+ public void removeClassVisitor(JavaClassVisitor visitor) {
+ visitors.remove(visitor);
+ }
+
+ public List<JavaClassVisitor> getClassVisitors() {
+ loadVisitors();
+ return visitors;
+ }
+
+ /**
+ * Load visitors declared under META-INF/services
+ */
+ @SuppressWarnings("unchecked")
+ private synchronized void loadVisitors() {
+ if (loaded)
+ return;
+
+ // Get the databinding service declarations
+ Collection<ServiceDeclaration> visitorDeclarations;
+ try {
+ visitorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(JavaClassVisitor.class, true);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Load data bindings
+ for (ServiceDeclaration visitorDeclaration: visitorDeclarations) {
+ JavaClassVisitor visitor = null;
+ try {
+ Class<JavaClassVisitor> visitorClass = (Class<JavaClassVisitor>)visitorDeclaration.loadClass();
+
+ try {
+ Constructor<JavaClassVisitor> constructor = visitorClass.getConstructor(ExtensionPointRegistry.class);
+ visitor = constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ visitor = visitorClass.newInstance();
+ }
+
+
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+
+ addClassVisitor(visitor);
+ }
+
+ loaded = true;
+ }
+
+ private synchronized JavaClassIntrospectorImpl getIntrospector() {
+ if (introspector != null) {
+ return introspector;
+ }
+ introspector = new JavaClassIntrospectorImpl(getClassVisitors());
+ return introspector;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
new file mode 100644
index 0000000000..5f7885ed5d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.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.sca.implementation.java.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.JavaScopeImpl;
+
+/**
+ * A component type specialization for POJO implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationImpl extends BaseJavaImplementationImpl implements JavaImplementation {
+ private JavaConstructorImpl<?> constructorDefinition;
+ private Map<Constructor, JavaConstructorImpl> constructors = new HashMap<Constructor, JavaConstructorImpl>();
+ private Method initMethod;
+ private Method destroyMethod;
+ private final Map<String, JavaResourceImpl> resources = new HashMap<String, JavaResourceImpl>();
+ private final Map<String, JavaElementImpl> propertyMembers = new HashMap<String, JavaElementImpl>();
+ private final Map<String, JavaElementImpl> referenceMembers = new HashMap<String, JavaElementImpl>();
+ private final Map<String, Collection<JavaElementImpl>> callbackMembers = new HashMap<String, Collection<JavaElementImpl>>();
+ private List<Member> conversationIDMember = new ArrayList<Member>();
+ private boolean eagerInit;
+ private boolean allowsPassByReference;
+ private List<Method> allowsPassByReferenceMethods = new ArrayList<Method>();
+ private JavaScopeImpl scope = JavaScopeImpl.STATELESS;
+
+ protected JavaImplementationImpl() {
+ super(TYPE);
+ }
+
+ public JavaConstructorImpl<?> getConstructor() {
+ return constructorDefinition;
+ }
+
+ public void setConstructor(JavaConstructorImpl<?> definition) {
+ this.constructorDefinition = definition;
+ }
+
+ public Method getInitMethod() {
+ return initMethod;
+ }
+
+ public void setInitMethod(Method initMethod) {
+ this.initMethod = initMethod;
+ }
+
+ public Method getDestroyMethod() {
+ return destroyMethod;
+ }
+
+ public void setDestroyMethod(Method destroyMethod) {
+ this.destroyMethod = destroyMethod;
+ }
+
+ public Map<String, JavaResourceImpl> getResources() {
+ return resources;
+ }
+
+ public List<Member> getConversationIDMembers() {
+ return this.conversationIDMember;
+ }
+
+ public void addConversationIDMember(Member conversationIDMember) {
+ this.conversationIDMember.add(conversationIDMember);
+ }
+
+ public boolean isAllowsPassByReference() {
+ return allowsPassByReference;
+ }
+
+ public void setAllowsPassByReference(boolean allowsPassByReference) {
+ this.allowsPassByReference = allowsPassByReference;
+ }
+
+ public List<Method> getAllowsPassByReferenceMethods() {
+ return allowsPassByReferenceMethods;
+ }
+
+ public boolean isAllowsPassByReference(Method method) {
+ return allowsPassByReference || allowsPassByReferenceMethods.contains(method);
+ }
+
+ public Map<Constructor, JavaConstructorImpl> getConstructors() {
+ return constructors;
+ }
+
+ public boolean isEagerInit() {
+ return eagerInit;
+ }
+
+ public void setEagerInit(boolean eagerInit) {
+ this.eagerInit = eagerInit;
+ }
+
+ public Map<String, Collection<JavaElementImpl>> getCallbackMembers() {
+ return callbackMembers;
+ }
+
+ public Map<String, JavaElementImpl> getPropertyMembers() {
+ return propertyMembers;
+ }
+
+ public Map<String, JavaElementImpl> getReferenceMembers() {
+ return referenceMembers;
+ }
+
+ public JavaScopeImpl getJavaScope() {
+ return scope;
+ }
+
+ public void setJavaScope(JavaScopeImpl scope) {
+ this.scope = scope;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java
new file mode 100644
index 0000000000..26ca54df88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.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.sca.implementation.java.introspect;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+/**
+ * A convenience class for annotation processors which alleviates the need to
+ * implement unused callbacks
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseJavaClassVisitor implements JavaClassVisitor {
+ protected AssemblyFactory assemblyFactory;
+ protected JavaInterfaceFactory javaInterfaceFactory;
+
+ protected BaseJavaClassVisitor(AssemblyFactory factory) {
+ this.assemblyFactory = factory;
+ }
+
+ protected BaseJavaClassVisitor(ExtensionPointRegistry registry) {
+ super();
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ }
+
+ public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ }
+
+ public <T> void visitSuperClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ }
+
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ }
+
+ public <T> void visitConstructor(Constructor<T> constructor, JavaImplementation type) throws IntrospectionException {
+ }
+
+ public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+ }
+
+ public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ }
+
+ public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type) throws IntrospectionException {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaClassVisitor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaClassVisitor.java
new file mode 100644
index 0000000000..4b0f5bea55
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaClassVisitor.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+
+/**
+ * Implementations process class-level metadata, typically parsing annotations
+ * and updating the corresponding <code>ComponentType</code>. A processor
+ * may, for example, create a Property which is responsible for injecting a
+ * complex type on a component implementation instance when it is instantiated.
+ * <p/> Processors will receive callbacks as the implementation class is walked
+ * while evaluating an assembly. It is the responsibility of the parser to
+ * determine whether to perform an action during the callback.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaClassVisitor {
+
+ /**
+ * A callback received when the component implementation class is first
+ * loaded
+ *
+ * @param clazz the component implementation class
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws IntrospectionException if an error is encountered while processing
+ * metadata
+ */
+ <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException;
+
+ /**
+ * A callback received as the component implementation class hierarchy is
+ * evaluated
+ *
+ * @param clazz the superclass in the component implmentation's class
+ * hierarchy
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws IntrospectionException if an error is encountered while processing
+ * metadata
+ */
+ <T> void visitSuperClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException;
+
+ /**
+ * A callback received as the component implementation's public and
+ * protected methods are evaluated
+ *
+ * @param method the current public or protected method being evaluated
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws IntrospectionException if an error is encountered while processing
+ * metadata
+ */
+ void visitMethod(Method method, JavaImplementation type) throws IntrospectionException;
+
+ /**
+ * A callback received as the component implementation's constructor used
+ * for instantiation by the runtime is evaluated. If an implementation
+ * contains more than one constructor, the constructor passed to the
+ * callback will be chosen according to the algorithm described in the SCA
+ * Java Client and Implementation Model Specification.
+ *
+ * @param constructor the constructor used for instantiating component
+ * implementation instances
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws IntrospectionException if an error is encountered while processing
+ * metadata
+ */
+ <T> void visitConstructor(Constructor<T> constructor, JavaImplementation type) throws IntrospectionException;
+
+ /**
+ * @param parameter
+ * @param type
+ * @throws IntrospectionException
+ */
+ void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type) throws IntrospectionException;
+
+ /**
+ * A callback received as the component implementation's public and
+ * protected fields are evaluated
+ *
+ * @param field the current public or protected field being evaluated
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws IntrospectionException if an error is encountered while processing
+ * metadata
+ */
+ void visitField(Field field, JavaImplementation type) throws IntrospectionException;
+
+ /**
+ * The final callback received when all other callbacks during evaluation of
+ * the component implementation have been issued
+ *
+ * @param clazz the component implementation class
+ * @param type the incomplete component type associated with the
+ * implementation class
+ * @throws IntrospectionException if an error is encountered while processing
+ * metadata
+ */
+ <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java
new file mode 100644
index 0000000000..5a934b5c01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java
@@ -0,0 +1,622 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect;
+
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Implements various reflection-related operations
+ *
+ * @version $Rev$ $Date$
+ */
+public final class JavaIntrospectionHelper {
+ private static final Logger logger = Logger.getLogger(JavaIntrospectionHelper.class.getName());
+ private static final Class<?>[] EMPTY_CLASS_ARRY = new Class[0];
+
+ /**
+ * Hide the constructor
+ */
+ private JavaIntrospectionHelper() {
+ }
+
+ /**
+ * Returns a collection of public, and protected fields declared by a class
+ * or one of its supertypes
+ */
+ public static Set<Field> getAllPublicAndProtectedFields(Class<?> clazz, boolean validating) {
+ return getAllPublicAndProtectedFields(clazz, new HashSet<Field>(), validating);
+ }
+
+ private static void checkInvalidAnnotations(AnnotatedElement element) {
+ for (Annotation a : element.getAnnotations()) {
+ if (a.annotationType().getName().startsWith("org.oasisopen.sca.annotation.")) {
+ logger.warning("Invalid annotation " + a + " is found on " + element);
+ }
+ }
+ }
+
+ /**
+ * Recursively evaluates the type hierarchy to return all fields that are
+ * public or protected
+ */
+ private static Set<Field> getAllPublicAndProtectedFields(Class<?> clazz, Set<Field> fields, boolean validating) {
+ if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
+ return fields;
+ }
+ fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields, validating);
+ Field[] declaredFields = clazz.getDeclaredFields();
+ for (final Field field : declaredFields) {
+ int modifiers = field.getModifiers();
+ // The field should be non-final and non-static
+ if ((Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) && !Modifier.isStatic(modifiers) && !Modifier.isFinal(modifiers)) {
+ // Allow privileged access to set accessibility. Requires ReflectPermission
+ // in security policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ field.setAccessible(true); // ignore Java accessibility
+ return null;
+ }
+ });
+ fields.add(field);
+ } /*else {
+ if (validating) {
+ checkInvalidAnnotations(field);
+ }
+ }*/
+ }
+ return fields;
+ }
+
+ /**
+ * Returns a collection of injectable fields declared by a class
+ * or one of its supertypes
+ *
+ * For now we will include final or static fields so that validation problems can be reported
+ */
+ public static Set<Field> getInjectableFields(Class<?> clazz, boolean validating) {
+ return getInjectableFields(clazz, new HashSet<Field>(), validating);
+ }
+
+ /**
+ * Recursively evaluates the type hierarchy to return all fields
+ */
+ private static Set<Field> getInjectableFields(Class<?> clazz, Set<Field> fields, boolean validating) {
+ if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
+ return fields;
+ }
+ fields = getInjectableFields(clazz.getSuperclass(), fields, validating);
+ Field[] declaredFields = clazz.getDeclaredFields();
+ for (final Field field : declaredFields) {
+ int modifiers = field.getModifiers();
+ // The field should be non-final and non-static
+ if (!Modifier.isStatic(modifiers)
+ // && !Modifier.isFinal(modifiers)
+ ) {
+
+ // Allow privileged access to set accessibility. Requires ReflectPermission
+ // in security policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ field.setAccessible(true); // ignore Java accessibility
+ return null;
+ }
+ });
+ fields.add(field);
+ } else {
+ if (validating) {
+ checkInvalidAnnotations(field);
+ }
+ }
+ }
+ return fields;
+ }
+
+ /**
+ * Returns a collection of public and protected methods declared by a class
+ * or one of its supertypes. Note that overridden methods will not be
+ * returned in the collection (i.e. only the method override will be). <p/>
+ * This method can potentially be expensive as reflection information is not
+ * cached. It is assumed that this method will be used during a
+ * configuration phase.
+ */
+ public static Set<Method> getAllUniquePublicProtectedMethods(Class<?> clazz, boolean validating) {
+ return getAllUniqueMethods(clazz, new HashSet<Method>(), validating);
+ }
+
+ /**
+ * Recursively evaluates the type hierarchy to return all unique methods
+ */
+ private static Set<Method> getAllUniqueMethods(Class<?> pClass, Set<Method> methods, boolean validating) {
+ if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
+ return methods;
+ }
+ // we first evaluate methods of the subclass and then move to the parent
+ Method[] declaredMethods = pClass.getDeclaredMethods();
+ for (final Method declaredMethod : declaredMethods) {
+ int modifiers = declaredMethod.getModifiers();
+ if ((!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) || Modifier.isStatic(modifiers)) {
+ if (validating) {
+ checkInvalidAnnotations(declaredMethod);
+ }
+ continue;
+ }
+ if (methods.size() == 0) {
+ methods.add(declaredMethod);
+ } else {
+ List<Method> temp = new ArrayList<Method>();
+ boolean matched = false;
+ for (Method method : methods) {
+ // only add if not already in the set from a superclass (i.e.
+ // the method is not overridden)
+ if (exactMethodMatch(declaredMethod, method)) {
+ matched = true;
+ break;
+ }
+ }
+ if (!matched) {
+ // Allow privileged access to set accessibility. Requires ReflectPermission
+ // in security policy.
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ declaredMethod.setAccessible(true);
+ return null;
+ }
+ });
+ temp.add(declaredMethod);
+ }
+ methods.addAll(temp);
+ temp.clear();
+ }
+ }
+ // evaluate class hierarchy - this is done last to track inherited
+ // methods
+ methods = getAllUniqueMethods(pClass.getSuperclass(), methods, validating);
+ return methods;
+ }
+
+ /**
+ * Finds the closest matching field with the given name, that is, a field of
+ * the exact specified type or, alternately, of a supertype.
+ *
+ * @param name the name of the field
+ * @param type the field type
+ * @param fields the collection of fields to search
+ * @return the matching field or null if not found
+ */
+ public static Field findClosestMatchingField(String name, Class type, Set<Field> fields) {
+ Field candidate = null;
+ for (Field field : fields) {
+ if (field.getName().equals(name)) {
+ if (field.getType().equals(type)) {
+ return field; // exact match
+ } else if (field.getType().isAssignableFrom(type) || (field.getType().isPrimitive() && primitiveAssignable(field
+ .getType(),
+ type))) {
+ // We could have the situation where a field parameter is a
+ // primitive and the demarshalled value is
+ // an object counterpart (e.g. Integer and int)
+ // @spec issue
+ // either an interface or super class, so keep a reference
+ // until
+ // we know there are no closer types
+ candidate = field;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Finds the closest matching method with the given name, that is, a method
+ * taking the exact parameter types or, alternately, parameter supertypes.
+ *
+ * @param name the name of the method
+ * @param types the method parameter types
+ * @param methods the collection of methods to search
+ * @return the matching method or null if not found
+ */
+ public static Method findClosestMatchingMethod(String name, Class[] types, Set<Method> methods) {
+ if (types == null) {
+ types = EMPTY_CLASS_ARRY;
+ }
+ Method candidate = null;
+ for (Method method : methods) {
+ if (method.getName().equals(name) && method.getParameterTypes().length == types.length) {
+ Class<?>[] params = method.getParameterTypes();
+ boolean disqualify = false;
+ boolean exactMatch = true;
+ for (int i = 0; i < params.length; i++) {
+ if (!params[i].equals(types[i]) && !params[i].isAssignableFrom(types[i])) {
+ // no match
+ disqualify = true;
+ exactMatch = false;
+ break;
+ } else if (!params[i].equals(types[i]) && params[i].isAssignableFrom(types[i])) {
+ // not exact match
+ exactMatch = false;
+ }
+ }
+ if (disqualify) {
+ continue;
+ } else if (exactMatch) {
+ return method;
+ } else {
+ candidate = method;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Determines if two methods "match" - that is, they have the same method
+ * names and exact parameter types (one is not a supertype of the other)
+ */
+ public static boolean exactMethodMatch(Method method1, Method method2) {
+ if (!method1.getName().equals(method2.getName())) {
+ return false;
+ }
+ Class<?>[] types1 = method1.getParameterTypes();
+ Class<?>[] types2 = method2.getParameterTypes();
+ if (types1.length != types2.length) {
+ return false;
+ }
+ boolean matched = true;
+ for (int i = 0; i < types1.length; i++) {
+ if (types1[i] != types2[i]) {
+ matched = false;
+ break;
+ }
+ }
+ return matched;
+ }
+
+ public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws NoSuchMethodException {
+ return clazz.getConstructor((Class[])null);
+ }
+
+ /**
+ * Returns the simple name of a class - i.e. the class name devoid of its
+ * package qualifier
+ *
+ * @param implClass the implementation class
+ */
+ public static String getBaseName(Class<?> implClass) {
+ return implClass.getSimpleName();
+ }
+
+ public static boolean isImmutable(Class<?> clazz) {
+ return String.class == clazz || clazz.isPrimitive()
+ || Number.class.isAssignableFrom(clazz)
+ || Boolean.class.isAssignableFrom(clazz)
+ || Character.class.isAssignableFrom(clazz)
+ || Byte.class.isAssignableFrom(clazz);
+ }
+
+ /**
+ * Takes a property name and converts it to a getter method name according
+ * to JavaBean conventions. For example, property
+ * <code>foo<code> is returned as <code>getFoo</code>
+ */
+ public static String toGetter(String name) {
+ return "get" + name.toUpperCase().substring(0, 1) + name.substring(1);
+ }
+
+ /**
+ * Takes a setter or getter method name and converts it to a property name
+ * according to JavaBean conventions. For example, <code>setFoo(var)</code>
+ * is returned as property <code>foo<code>
+ */
+ public static String toPropertyName(String name) {
+ if (!name.startsWith("set")) {
+ return name;
+ }
+ return Introspector.decapitalize(name.substring(3));
+ }
+
+ public static Class<?> getErasure(Type type) {
+ if (type instanceof Class) {
+ return (Class<?>)type;
+ } else if (type instanceof GenericArrayType) {
+ // FIXME: How to deal with the []?
+ GenericArrayType arrayType = (GenericArrayType)type;
+ return getErasure(arrayType.getGenericComponentType());
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType)type;
+ return getErasure(pType.getRawType());
+ } else if (type instanceof WildcardType) {
+ WildcardType wType = (WildcardType)type;
+ Type[] types = wType.getUpperBounds();
+ return getErasure(types[0]);
+ } else if (type instanceof TypeVariable) {
+ TypeVariable var = (TypeVariable)type;
+ Type[] types = var.getBounds();
+ return getErasure(types[0]);
+ }
+ return null;
+ }
+
+ public static Class<?> getBaseType(Class<?> cls, Type genericType) {
+ if (cls.isArray()) {
+ return cls.getComponentType();
+ } else if (Collection.class.isAssignableFrom(cls)) {
+ if (genericType instanceof ParameterizedType) {
+ // Collection<BaseType>
+ ParameterizedType parameterizedType = (ParameterizedType)genericType;
+ Type baseType = parameterizedType.getActualTypeArguments()[0];
+ if (baseType instanceof GenericArrayType) {
+ // Base is array
+ return cls;
+ } else {
+ return getErasure(baseType);
+ }
+ } else {
+ return cls;
+ }
+ } else {
+ return cls;
+ }
+ }
+
+ public static Type getParameterType(Type type) {
+ if (type instanceof ParameterizedType) {
+ // Collection<BaseType>
+ ParameterizedType parameterizedType = (ParameterizedType)type;
+ Type baseType = parameterizedType.getActualTypeArguments()[0];
+ return baseType;
+ } else {
+ return Object.class;
+ }
+ }
+
+ public static Class<?> getBusinessInterface(Class<?> cls, Type callableReferenceType) {
+ if (ServiceReference.class.isAssignableFrom(cls) && callableReferenceType instanceof ParameterizedType) {
+ // Collection<BaseType>
+ ParameterizedType parameterizedType = (ParameterizedType)callableReferenceType;
+ Type baseType = parameterizedType.getActualTypeArguments()[0];
+ if (baseType instanceof GenericArrayType) {
+ // Base is array
+ return cls;
+ } else {
+ return getErasure(baseType);
+ }
+ }
+ return Object.class;
+ }
+
+ /**
+ * Takes a property name and converts it to a setter method name according
+ * to JavaBean conventions. For example, the property
+ * <code>foo<code> is returned as <code>setFoo(var)</code>
+ */
+ public static String toSetter(String name) {
+ return "set" + name.toUpperCase().substring(0, 1) + name.substring(1);
+ }
+
+ /**
+ * Compares a two types, assuming one is a primitive, to determine if the
+ * other is its object counterpart
+ */
+ private static boolean primitiveAssignable(Class<?> memberType, Class<?> param) {
+ if (memberType == Integer.class) {
+ return param == Integer.TYPE;
+ } else if (memberType == Double.class) {
+ return param == Double.TYPE;
+ } else if (memberType == Float.class) {
+ return param == Float.TYPE;
+ } else if (memberType == Short.class) {
+ return param == Short.TYPE;
+ } else if (memberType == Character.class) {
+ return param == Character.TYPE;
+ } else if (memberType == Boolean.class) {
+ return param == Boolean.TYPE;
+ } else if (memberType == Byte.class) {
+ return param == Byte.TYPE;
+ } else if (param == Integer.class) {
+ return memberType == Integer.TYPE;
+ } else if (param == Double.class) {
+ return memberType == Double.TYPE;
+ } else if (param == Float.class) {
+ return memberType == Float.TYPE;
+ } else if (param == Short.class) {
+ return memberType == Short.TYPE;
+ } else if (param == Character.class) {
+ return memberType == Character.TYPE;
+ } else if (param == Boolean.class) {
+ return memberType == Boolean.TYPE;
+ } else if (param == Byte.class) {
+ return memberType == Byte.TYPE;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the generic types represented in the given type. Usage as
+ * follows: <code>
+ * JavaIntrospectionHelper.getGenerics(field.getGenericType());
+ * <p/>
+ * JavaIntrospectionHelper.getGenerics(m.getGenericParameterTypes()[0];); </code>
+ *
+ * @return the generic types in order of declaration or an empty array if
+ * the type is not genericized
+ */
+ public static List<? extends Type> getGenerics(Type genericType) {
+ List<Type> classes = new ArrayList<Type>();
+ if (genericType instanceof ParameterizedType) {
+ ParameterizedType ptype = (ParameterizedType)genericType;
+ // get the type arguments
+ Type[] targs = ptype.getActualTypeArguments();
+ for (Type targ : targs) {
+ classes.add(targ);
+ }
+ }
+ return classes;
+ }
+
+ /**
+ * Returns the generic type specified by the class at the given position as
+ * in: <p/> <code> public class Foo<Bar,Baz>{ //.. }
+ * <p/>
+ * JavaIntrospectionHelper.introspectGeneric(Foo.class,1); <code>
+ * <p/>
+ * will return Baz.
+ */
+ public static Class introspectGeneric(Class<?> clazz, int pos) {
+ assert clazz != null : "No class specified";
+ Type type = clazz.getGenericSuperclass();
+ if (type instanceof ParameterizedType) {
+ Type[] args = ((ParameterizedType)type).getActualTypeArguments();
+ if (args.length <= pos) {
+ throw new IllegalArgumentException("Invalid index value for generic class " + clazz.getName());
+ }
+ return (Class)((ParameterizedType)type).getActualTypeArguments()[pos];
+ } else {
+ Type[] interfaces = clazz.getGenericInterfaces();
+ for (Type itype : interfaces) {
+ if (!(itype instanceof ParameterizedType)) {
+ continue;
+ }
+ ParameterizedType interfaceType = (ParameterizedType)itype;
+ return (Class)interfaceType.getActualTypeArguments()[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the set of interfaces implemented by the given class and its
+ * ancestors or a blank set if none
+ */
+ public static Set<Class<?>> getAllInterfaces(Class<?> clazz) {
+ Set<Class<?>> implemented = new HashSet<Class<?>>();
+ getAllInterfaces(clazz, implemented);
+ return implemented;
+ }
+
+ private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) {
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for (Class<?> interfaze : interfaces) {
+ implemented.add(interfaze);
+ }
+ Class<?> superClass = clazz.getSuperclass();
+ // Object has no superclass so check for null
+ if (superClass != null && !superClass.equals(Object.class)) {
+ getAllInterfaces(superClass, implemented);
+ }
+ }
+
+ public static boolean isSetter(Method method) {
+ return (void.class == method.getReturnType() && method.getParameterTypes().length == 1 && method.getName()
+ .startsWith("set"));
+ }
+
+ public static boolean isGetter(Method method) {
+ return (void.class != method.getReturnType() && method.getParameterTypes().length == 0 && method.getName()
+ .startsWith("get"));
+ }
+
+ private final static Map<Class<?>, String> signatures = new HashMap<Class<?>, String>();
+ static {
+ signatures.put(boolean.class, "Z");
+ signatures.put(byte.class, "B");
+ signatures.put(char.class, "C");
+ signatures.put(short.class, "S");
+ signatures.put(int.class, "I");
+ signatures.put(long.class, "J");
+ signatures.put(float.class, "F");
+ signatures.put(double.class, "D");
+ };
+
+ public static String getSignature(Class<?> cls) {
+ if (cls.isPrimitive()) {
+ return signatures.get(cls);
+ }
+ if (cls.isArray()) {
+ return "[" + getSignature(cls.getComponentType());
+ }
+ return "L" + cls.getName().replace('.', '/') + ";";
+ }
+
+ public static Class<?> getArrayType(Class<?> componentType, int dims) throws ClassNotFoundException {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < dims; i++) {
+ buf.append('[');
+ }
+ buf.append(getSignature(componentType));
+ return Class.forName(buf.toString(), false, componentType.getClassLoader());
+ }
+
+ public static Set<Method> getPrivateMethods(Class<?> clazz) {
+ Set<Method> methods = new HashSet<Method>();
+ Method[] declaredMethods = clazz.getDeclaredMethods();
+ for (final Method declaredMethod : declaredMethods) {
+ int modifiers = declaredMethod.getModifiers();
+ if(Modifier.isPrivate(modifiers)) {
+ methods.add(declaredMethod);
+ }
+ }
+
+ return methods;
+ }
+
+ public static Set<Field> getPrivateFields(Class<?> clazz) {
+ Set<Field> fields = new HashSet<Field>();
+ Field[] declaredFields = clazz.getDeclaredFields();
+ for (final Field declaredField : declaredFields) {
+ int modifiers = declaredField.getModifiers();
+ if(Modifier.isPrivate(modifiers)) {
+ fields.add(declaredField);
+ }
+ }
+
+ return fields;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
new file mode 100644
index 0000000000..ff70fb89eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Base class for ImplementationProcessors that handle annotations that add
+ * Properties.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractPropertyProcessor<A extends Annotation> extends BaseJavaClassVisitor {
+ private final Class<A> annotationClass;
+
+ protected AbstractPropertyProcessor(ExtensionPointRegistry registry, Class<A> annotationClass) {
+ super(registry);
+ this.annotationClass = annotationClass;
+ }
+
+ private static boolean removeProperty(JavaElementImpl prop, JavaImplementation type) {
+ if(prop==null) {
+ return false;
+ }
+ List<Property> props = type.getProperties();
+ for(int i=0;i<props.size();i++) {
+ if(props.get(i).getName().equals(prop.getName())) {
+ props.remove(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ A annotation = method.getAnnotation(annotationClass);
+ if (annotation != null) {
+
+ if (!JavaIntrospectionHelper.isSetter(method)) {
+ throw new IllegalPropertyException("Annotated method is not a setter: " + method, method);
+ }
+
+ if(Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalPropertyException("Static method " + method.getName() +" in class " + method.getDeclaringClass().getName() + " can not be annotated as a Property");
+ }
+
+ String name = getName(annotation);
+ if (name == null || "".equals(name)) {
+ name = method.getName();
+ if (name.startsWith("set")) {
+ name = JavaIntrospectionHelper.toPropertyName(method.getName());
+ }
+ }
+
+ Map<String, JavaElementImpl> properties = type.getPropertyMembers();
+ JavaElementImpl prop = properties.get(name);
+ // Setter override field
+ if (prop != null && prop.getElementType() != ElementType.FIELD) {
+ throw new DuplicatePropertyException(name);
+ }
+
+ removeProperty(prop, type);
+
+ JavaElementImpl element = new JavaElementImpl(method, 0);
+ Property property = createProperty(name, element);
+
+ // add databinding available as annotations, as extensions
+
+ initProperty(property, annotation);
+ type.getProperties().add(property);
+ properties.put(name, element);
+ }
+
+ // enforce the constraint that an ordinary method's argument can not be a Property
+ Annotation paramsAnnotations[][] = method.getParameterAnnotations();
+ for (int i = 0; i < paramsAnnotations.length; i++) {
+ Annotation argAnnotations[] = paramsAnnotations[i];
+ for (int j = 0; j < argAnnotations.length; j++) {
+ if(argAnnotations[j].annotationType() == org.oasisopen.sca.annotation.Property.class) {
+ throw new IllegalPropertyException("[JCA90001] Argument " + (i+1) + " of method " + method.getName() + " in class " + method.getDeclaringClass() + " can not be a Property");
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+
+ A annotation = field.getAnnotation(annotationClass);
+ if (annotation == null) {
+ return;
+ }
+
+ if(Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalPropertyException("Static field " + field.getName() +" in class " + field.getDeclaringClass().getName() + " can not be annotated as a Property");
+ }
+
+ if(Modifier.isFinal(field.getModifiers())) {
+ throw new IllegalPropertyException("[JCA90011] Final field " + field.getName() +" in class " + field.getDeclaringClass().getName() + " can not be annotated as a Property");
+ }
+
+ String name = getName(annotation);
+ if (name == null) {
+ name = "";
+ }
+ if ("".equals(name) || name.equals(field.getType().getName())) {
+ name = field.getName();
+ }
+
+ Map<String, JavaElementImpl> properties = type.getPropertyMembers();
+ JavaElementImpl prop = properties.get(name);
+ // Setter override field
+ if (prop != null && prop.getElementType() == ElementType.FIELD) {
+ throw new DuplicatePropertyException(name);
+ }
+
+ if (prop == null) {
+ JavaElementImpl element = new JavaElementImpl(field);
+ Property property = createProperty(name, element);
+ initProperty(property, annotation);
+ type.getProperties().add(property);
+ properties.put(name, element);
+ }
+ }
+
+ @Override
+ public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
+ throws IntrospectionException {
+
+ Map<String, JavaElementImpl> properties = type.getPropertyMembers();
+ A annotation = parameter.getAnnotation(annotationClass);
+ if (annotation != null) {
+ String name = getName(annotation);
+ if (name == null) {
+ name = parameter.getType().getName();
+ }
+ if (!"".equals(name) && !"".equals(parameter.getName()) && !name.equals(parameter.getName())) {
+ throw new InvalidConstructorException("Mismatched property name: " + parameter);
+ }
+ if ("".equals(name) && "".equals(parameter.getName())) {
+ throw new InvalidPropertyException("[JCA90013] Missing property name: " + parameter);
+ }
+ if ("".equals(name)) {
+ name = parameter.getName();
+ }
+
+ if (!getRequired(annotation)) {
+ throw new InvalidPropertyException("[JCA90014] Constructor property must not have required=false: " + type.getName());
+ }
+
+ JavaElementImpl prop = properties.get(name);
+ // Setter override field
+ if (prop != null && prop.getElementType() != ElementType.FIELD) {
+ throw new DuplicatePropertyException(name);
+ }
+ removeProperty(prop, type);
+
+ parameter.setName(name);
+ parameter.setClassifer(annotationClass);
+ Property property = createProperty(name, parameter);
+ initProperty(property, annotation);
+ type.getProperties().add(property);
+ properties.put(name, parameter);
+ }
+ }
+
+ protected Property createProperty(String name, JavaElementImpl element) throws IntrospectionException {
+
+ Type type = element.getGenericType();
+ Class<?> javaType = element.getType();
+
+ return createProperty(assemblyFactory, name, javaType, type);
+
+ }
+
+ public static Property createProperty(AssemblyFactory assemblyFactory, String name, Class<?> javaClass, Type genericType) {
+ Property property = assemblyFactory.createProperty();
+ property.setName(name);
+
+ if (javaClass.isArray() || Collection.class.isAssignableFrom(javaClass)) {
+ property.setMany(true);
+ if (javaClass.isArray()) {
+ Class<?> propType = javaClass.getComponentType();
+ Type genericPropType = propType;
+ if (genericType instanceof GenericArrayType) {
+ genericPropType = ((GenericArrayType)genericType).getGenericComponentType();
+ }
+ DataType dt = new DataTypeImpl(null, propType, genericPropType, XMLType.UNKNOWN);
+ property.setDataType(dt);
+ } else {
+ if (genericType instanceof ParameterizedType) {
+ // Collection<BaseType> property;
+ Type genericPropType = ((ParameterizedType)genericType).getActualTypeArguments()[0];
+ Class<?> propType = JavaIntrospectionHelper.getErasure(genericPropType);
+ DataType dt = new DataTypeImpl(null, propType, genericPropType, XMLType.UNKNOWN);
+ property.setDataType(dt);
+ } else {
+ // Collection property;
+ DataType dt = new DataTypeImpl(null, Object.class, Object.class, XMLType.UNKNOWN);
+ property.setDataType(dt);
+ }
+ }
+ } else {
+ DataType dt = new DataTypeImpl(null, javaClass, genericType, XMLType.UNKNOWN);
+ property.setDataType(dt);
+ }
+ return property;
+ }
+
+ protected abstract String getName(A annotation);
+ protected abstract boolean getRequired(A annotation);
+
+ protected abstract void initProperty(Property property, A annotation) throws IntrospectionException;
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
new file mode 100644
index 0000000000..4aa29d3b91
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.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.java.introspect.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+
+/**
+ * Processes {@link AllowsPassByReference} on an implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class AllowsPassByReferenceProcessor extends BaseJavaClassVisitor {
+
+ public AllowsPassByReferenceProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public AllowsPassByReferenceProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ type.setAllowsPassByReference(clazz.isAnnotationPresent(AllowsPassByReference.class));
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ boolean pbr = method.isAnnotationPresent(AllowsPassByReference.class);
+ if (pbr) {
+ type.getAllowsPassByReferenceMethods().add(method);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java
new file mode 100644
index 0000000000..c6e6b6e4d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when constructor parameters cannot be unambiguously resolved to a property or reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class AmbiguousConstructorException extends IntrospectionException {
+ private static final long serialVersionUID = 3662860753837091880L;
+
+ public AmbiguousConstructorException(String message) {
+ super(message);
+ }
+
+ public AmbiguousConstructorException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
new file mode 100644
index 0000000000..1813a177b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.oasisopen.sca.annotation.ComponentName;
+
+/**
+ * Processes {@link @ComponentName} annotations on a component implementation and adds
+ * a {@link JavaMappedProperty} to the component type which will be used to
+ * inject the appropriate component name.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentNameProcessor extends BaseJavaClassVisitor {
+
+ public ComponentNameProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public ComponentNameProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ if (method.getAnnotation(ComponentName.class) == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 1) {
+ throw new IllegalContextException("ComponentName setter must have one parameter", method);
+ }
+ Class<?> paramType = method.getParameterTypes()[0];
+ String name = JavaIntrospectionHelper.toPropertyName(method.getName());
+ if (String.class.equals(paramType)) {
+ JavaElementImpl element = new JavaElementImpl(method, 0);
+ element.setName(name);
+ element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+ JavaResourceImpl resource = new JavaResourceImpl(element);
+ type.getResources().put(resource.getName(), resource);
+ } else {
+ throw new IllegalContextException(paramType.getName());
+ }
+ }
+
+ @Override
+ public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+ if (field.getAnnotation(ComponentName.class) == null) {
+ return;
+ }
+ Class<?> paramType = field.getType();
+ if (String.class.equals(paramType)) {
+ JavaElementImpl element = new JavaElementImpl(field);
+ element.setClassifer(Resource.class);
+ JavaResourceImpl resource = new JavaResourceImpl(element);
+ type.getResources().put(resource.getName(), resource);
+ } else {
+ throw new IllegalContextException(paramType.getName());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
new file mode 100644
index 0000000000..52a3fbd89a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.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.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+
+/**
+ * Handles processing of a constructor decorated with
+ * {@link org.oasisopen.sca.annotation.Constructor}
+ *
+ * @version $Rev$ $Date$
+ */
+@SuppressWarnings("unchecked")
+public class ConstructorProcessor extends BaseJavaClassVisitor {
+
+ public ConstructorProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public ConstructorProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ Constructor[] ctors = clazz.getConstructors();
+ boolean found = false;
+ for (Constructor constructor : ctors) {
+ JavaConstructorImpl<?> definition = new JavaConstructorImpl(constructor);
+ type.getConstructors().put(constructor, definition);
+ if (constructor.getAnnotation(org.oasisopen.sca.annotation.Constructor.class) != null) {
+ if (found) {
+ throw new DuplicateConstructorException("[JCI50002] Multiple constructors marked with @Constructor", constructor);
+ }
+ found = true;
+ type.setConstructor(definition);
+ }
+ }
+ }
+
+ @Override
+ public <T> void visitConstructor(Constructor<T> constructor, JavaImplementation type)
+ throws IntrospectionException {
+ org.oasisopen.sca.annotation.Constructor annotation = constructor
+ .getAnnotation(org.oasisopen.sca.annotation.Constructor.class);
+ if (annotation == null) {
+ return;
+ }
+ JavaConstructorImpl<?> definition = type.getConstructor();
+ if (definition == null) {
+ definition = new JavaConstructorImpl(constructor);
+ type.setConstructor(definition);
+ }
+ JavaParameterImpl[] parameters = definition.getParameters();
+ String[] value = annotation.value();
+ boolean isDefault = value.length == 0 || (value.length == 1 && "".equals(value[0]));
+ if (!isDefault && value.length != parameters.length) {
+ throw new InvalidConstructorException("Invalid Number of names in @Constructor");
+ }
+
+ for (JavaParameterImpl p : parameters) {
+ if (!hasAnnotation(p)) {
+ throw new InvalidConstructorException("JCA90003 constructor parameters for class " + type.getName() + " must have @Property or @Reference annotation");
+ }
+ }
+
+ for (int i = 0; i < parameters.length; i++) {
+ parameters[i].setName(i < value.length ? value[i] : "");
+ }
+ type.setConstructor(definition);
+ }
+
+ private boolean hasAnnotation(JavaParameterImpl p) {
+ if (p.getAnnotations() != null && p.getAnnotations().length > 0) {
+ return true;
+ }
+// TODO: need to verify JCA90003 as it seems like any annotation should be ok not just SCA ref or prop
+// if (p.getAnnotation(Reference.class) != null) {
+// return true;
+// }
+// if (p.getAnnotation(Property.class) != null) {
+// return true;
+// }
+ return false;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java
new file mode 100644
index 0000000000..651ecdbd7e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.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.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.annotation.Context;
+
+/**
+ * Processes {@link @Context} annotations on a component implementation and adds
+ * a {@link JavaMappedProperty} to the component type which will be used to
+ * inject the appropriate context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContextProcessor extends BaseJavaClassVisitor {
+
+ public ContextProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public ContextProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ if (method.getAnnotation(Context.class) == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 1) {
+ throw new IllegalContextException("Context setter must have one parameter", method);
+ }
+ Class<?> paramType = method.getParameterTypes()[0];
+ String name = JavaIntrospectionHelper.toPropertyName(method.getName());
+ if (ComponentContext.class.equals(paramType) || RequestContext.class.equals(paramType)) {
+ JavaElementImpl element = new JavaElementImpl(method, 0);
+ element.setName(name);
+ element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+ JavaResourceImpl resource = new JavaResourceImpl(element);
+ type.getResources().put(resource.getName(), resource);
+ } else {
+ throw new UnknownContextTypeException(paramType.getName());
+ }
+ }
+
+ @Override
+ public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+ if (field.getAnnotation(Context.class) == null) {
+ return;
+ }
+ Class<?> paramType = field.getType();
+ if (ComponentContext.class.equals(paramType) || RequestContext.class.equals(paramType)) {
+ JavaElementImpl element = new JavaElementImpl(field);
+ element.setClassifer(Resource.class);
+ JavaResourceImpl resource = new JavaResourceImpl(element);
+ type.getResources().put(resource.getName(), resource);
+ } else {
+ throw new UnknownContextTypeException(paramType.getName());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
new file mode 100644
index 0000000000..a4b760760c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.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.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.oasisopen.sca.annotation.Destroy;
+
+/**
+ * Processes the {@link @Destroy} annotation on a component implementation and
+ * updates the component type with the decorated destructor method
+ *
+ * @version $Rev$ $Date$
+ */
+public class DestroyProcessor extends BaseJavaClassVisitor {
+
+ public DestroyProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public DestroyProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ Destroy annotation = method.getAnnotation(Destroy.class);
+ if (annotation == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 0) {
+ throw new IllegalDestructorException("[JCA90004] Destructor must not have arguments", method);
+ }
+ if(!method.getReturnType().equals(void.class)) {
+ throw new IllegalDestructorException("Destructor must return void.", method);
+ }
+ if (type.getDestroyMethod() != null) {
+ throw new DuplicateDestructorException("More than one destructor found on implementation");
+ }
+ type.setDestroyMethod(method);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java
new file mode 100644
index 0000000000..d6494e3845
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.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.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when more than one component implementation constructor is annotated with {@link
+ * org.oasisopen.sca.annotation.Constructor}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateConstructorException extends IntrospectionException {
+ private static final long serialVersionUID = -5926763756570552986L;
+
+ public DuplicateConstructorException(String message) {
+ super(message);
+ }
+
+ public DuplicateConstructorException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java
new file mode 100644
index 0000000000..8bfae89162
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.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 org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when an implementation is annotated multiple times with {@link org.oasisopen.sca.annotation.Destroy}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateDestructorException extends IntrospectionException {
+ private static final long serialVersionUID = -7474912510114895203L;
+
+ public DuplicateDestructorException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java
new file mode 100644
index 0000000000..38f6478531
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.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 org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when an implementation is annotated multiple times with {@link @org.oasisopen.sca.annotation.Init}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateInitException extends IntrospectionException {
+ private static final long serialVersionUID = -6282935288115512057L;
+
+ public DuplicateInitException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java
new file mode 100644
index 0000000000..b9e1923e73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when an implementation has more than one property injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicatePropertyException extends IntrospectionException {
+ private static final long serialVersionUID = 5536415875694904037L;
+
+ public DuplicatePropertyException(String message) {
+ super(message);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java
new file mode 100644
index 0000000000..300ad6817e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.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 org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when an implementation has more than one reference injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateReferenceException extends IntrospectionException {
+ private static final long serialVersionUID = 907910648213477158L;
+
+ public DuplicateReferenceException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java
new file mode 100644
index 0000000000..2d177b3f76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.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 org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when an implementation has more than one resource injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateResourceException extends IntrospectionException {
+
+ private static final long serialVersionUID = 1619276459330463299L;
+
+ public DuplicateResourceException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
new file mode 100644
index 0000000000..5c0e2c1397
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.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.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.oasisopen.sca.annotation.EagerInit;
+
+/**
+ * Handles processing of {@link org.oasisopen.sca.annotation.EagerInit}
+ *
+ * @version $Rev$ $Date$
+ */
+public class EagerInitProcessor extends BaseJavaClassVisitor {
+
+ public EagerInitProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public EagerInitProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public <T> void visitClass(Class<T> clazz,
+ JavaImplementation type) throws IntrospectionException {
+ super.visitClass(clazz, type);
+ EagerInit annotation = clazz.getAnnotation(EagerInit.class);
+ if (annotation == null) {
+ Class<?> superClass = clazz.getSuperclass();
+ while (superClass != null && !Object.class.equals(superClass)) {
+ annotation = superClass.getAnnotation(EagerInit.class);
+ if (annotation != null) {
+ break;
+ }
+ superClass = superClass.getSuperclass();
+ }
+ if (annotation == null) {
+ return;
+ }
+ }
+ type.setEagerInit(true);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
new file mode 100644
index 0000000000..31cee72aa4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
@@ -0,0 +1,758 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllInterfaces;
+import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
+import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
+import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getBaseType;
+import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.toPropertyName;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.ComponentName;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Heuristically evaluates an un-annotated Java implementation type to determine
+ * services, references, and properties according to the algorithm described in
+ * the SCA Java Client and Implementation Model Specification <p/> TODO
+ * Implement: <p/> When no service interface is annotated, need to calculate a
+ * single service comprising all public methods that are not reference or
+ * property injection sites. If that service can be exactly mapped to an
+ * interface implemented by the class then the service interface will be defined
+ * in terms of that interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeuristicPojoProcessor extends BaseJavaClassVisitor {
+
+ public HeuristicPojoProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
+ super(assemblyFactory);
+ this.javaInterfaceFactory = javaFactory;
+ }
+
+ public HeuristicPojoProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ List<org.apache.tuscany.sca.assembly.Service> services = type.getServices();
+ if (services.isEmpty()) {
+ // heuristically determine the service
+ /**
+ * The following is quoted from Java Specification 1.2.1.3. Introspecting services offered by a Java implementation
+ * In the cases described below, the services offered by a Java implementation class may be determined
+ * through introspection, eliding the need to specify them using @Service. The following algorithm is used
+ * to determine how services are introspected from an implementation class:
+ *
+ * If the interfaces of the SCA services are not specified with the @Service annotation on the
+ * implementation class, it is assumed that all implemented interfaces that have been annotated
+ * as @Remotable are the service interfaces provided by the component. If none of the implemented
+ * interfaces is remotable, then by default the implementation offers a single service whose type
+ * is the implementation class.
+ */
+ Set<Class<?>> interfaces = getAllInterfaces(clazz);
+ for (Class<?> i : interfaces) {
+ if (i.isAnnotationPresent(Remotable.class) || i.isAnnotationPresent(WebService.class)) {
+ addService(type, i);
+ }
+ }
+ if (services.isEmpty()) {
+ // class is the interface
+ addService(type, clazz);
+ }
+ }
+ if (!(type.getReferenceMembers().isEmpty() && type.getPropertyMembers().isEmpty())) {
+ // references and properties have been explicitly defined
+ // if (type.getServices().isEmpty()) {
+ // calculateServiceInterface(clazz, type, methods);
+ // if (type.getServices().isEmpty()) {
+ // throw new ServiceTypeNotFoundException(clazz.getName());
+ // }
+ // }
+ evaluateConstructor(type, clazz);
+ return;
+ }
+ Set<Method> methods = getAllUniquePublicProtectedMethods(clazz, false);
+
+ calcPropRefs(methods, services, type, clazz);
+ evaluateConstructor(type, clazz);
+ }
+
+ // Check if the implementation is implementation.java
+ private boolean isImplementationJava(JavaImplementation type) {
+ return JavaImplementation.TYPE.equals(type.getType());
+ }
+
+ private void addService(JavaImplementation type, Class<?> clazz) throws IntrospectionException {
+ try {
+ org.apache.tuscany.sca.assembly.Service service = createService(clazz);
+ type.getServices().add(service);
+ } catch (InvalidInterfaceException e) {
+ throw new IntrospectionException(e);
+ }
+ }
+
+ private static boolean isAnnotatedWithSCA(AnnotatedElement element) {
+ for (Annotation a : element.getAnnotations()) {
+ // JCI_8023
+ // policy annotations can be added to reference fields that
+ // don't have @Reference annotations so we need to allow
+ // for the fields to be detected as references
+ if (isSCAPolicyAnnotation(a)){
+ continue;
+ } else if (isSCAAnnotation(a)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static boolean isSCAAnnotation(Annotation a) {
+ return a.annotationType().getName().startsWith("org.oasisopen.sca.annotation.");
+ }
+
+ private static boolean isSCAPolicyAnnotation(Annotation a) {
+ if (a.annotationType().getName().startsWith("org.oasisopen.sca.annotation.PolicySets") ){
+ return true;
+ } else if (a.annotationType().getName().startsWith("org.oasisopen.sca.annotation.Intent") ){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private <T> void calcPropRefs(Set<Method> methods,
+ List<org.apache.tuscany.sca.assembly.Service> services,
+ JavaImplementation type,
+ Class<T> clazz) throws IntrospectionException {
+ // heuristically determine the properties references
+ // make a first pass through all public methods with one param
+ Set<String> setters = new HashSet<String>();
+ Set<String> others = new HashSet<String>();
+ for (Method method : methods) {
+ if (!isPublicSetter(method)) {
+ continue;
+ }
+ if (isAnnotatedWithSCA(method)) {
+ // Add the property name as others
+ others.add(toPropertyName(method.getName()));
+ continue;
+ }
+ if (!isInServiceInterface(method, services)) {
+ // Not part of the service interface
+ String name = toPropertyName(method.getName());
+ setters.add(name);
+ // avoid duplicate property or ref names
+ if (!type.getPropertyMembers().containsKey(name) && !type.getReferenceMembers().containsKey(name)) {
+ Class<?> param = method.getParameterTypes()[0];
+ Type genericType = method.getGenericParameterTypes()[0];
+ if (isReferenceType(param, genericType)) {
+ type.getReferences().add(createReference(name, param, genericType));
+ type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
+ } else {
+ type.getProperties().add(createProperty(name, param, genericType));
+ type.getPropertyMembers().put(name, new JavaElementImpl(method, 0));
+ }
+ }
+ }
+ }
+ // second pass for protected methods with one param
+ for (Method method : methods) {
+ if (!isProtectedSetter(method)) {
+ continue;
+ }
+ if (isAnnotatedWithSCA(method)) {
+ // Add the property name as others
+ others.add(toPropertyName(method.getName()));
+ continue;
+ }
+ Class<?> param = method.getParameterTypes()[0];
+ Type paramType = method.getGenericParameterTypes()[0];
+
+ String name = toPropertyName(method.getName());
+ setters.add(name);
+ // avoid duplicate property or ref names
+ if (isReferenceType(param, method.getGenericParameterTypes()[0])) {
+ if (!type.getReferenceMembers().containsKey(name)) {
+ type.getReferences().add(createReference(name, param, paramType));
+ type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
+ }
+ } else {
+ if (!type.getPropertyMembers().containsKey(name)) {
+ type.getProperties().add(createProperty(name, param, paramType));
+ type.getPropertyMembers().put(name, new JavaElementImpl(method, 0));
+ }
+ }
+ }
+
+ // Public or protected fields unless there is a public or protected
+ // setter method
+ // for the same name
+ Set<Field> fields = getAllPublicAndProtectedFields(clazz, false);
+ for (Field field : fields) {
+ if (isAnnotatedWithSCA(field)) {
+ continue;
+ }
+ if (setters.contains(field.getName()) || others.contains(field.getName())) {
+ continue;
+ }
+ String name = field.getName();
+ Class<?> paramType = field.getType();
+ Type genericType = field.getGenericType();
+ if (isReferenceType(paramType, field.getGenericType())) {
+ if (!type.getReferenceMembers().containsKey(name)) {
+ type.getReferences().add(createReference(name, paramType, genericType));
+ type.getReferenceMembers().put(name, new JavaElementImpl(field));
+ }
+ } else {
+ if (!type.getPropertyMembers().containsKey(name)) {
+ type.getProperties().add(createProperty(name, paramType, genericType));
+ type.getPropertyMembers().put(name, new JavaElementImpl(field));
+ }
+ }
+ }
+ }
+
+ /**
+ * Determines the constructor to use based on the component type's
+ * references and properties
+ *
+ * @param type the component type
+ * @param clazz the implementation class corresponding to the component type
+ * @throws NoConstructorException if no suitable constructor is found
+ * @throws AmbiguousConstructorException if the parameters of a constructor
+ * cannot be unambiguously mapped to references and properties
+ */
+ @SuppressWarnings("unchecked")
+ private <T> void evaluateConstructor(JavaImplementation type, Class<T> clazz) throws IntrospectionException {
+ // determine constructor if one is not annotated
+ JavaConstructorImpl<?> definition = type.getConstructor();
+ Constructor constructor;
+ boolean explict = false;
+ if (definition != null && definition.getConstructor()
+ .isAnnotationPresent(org.oasisopen.sca.annotation.Constructor.class)) {
+ // the constructor was already defined explicitly
+ return;
+ } else if (definition != null) {
+ explict = true;
+ constructor = definition.getConstructor();
+ } else {
+ if (!isImplementationJava(type)) {
+ // FIXME: [rfeng] Don't process the constructors for non implementation.java types
+ return;
+ }
+ // no definition, heuristically determine constructor
+ Constructor[] constructors = clazz.getConstructors();
+ if (constructors.length == 0) {
+ throw new NoConstructorException("[JCI50001] No public constructor for class");
+ } else if (constructors.length == 1) {
+ // Only one constructor, take it
+ constructor = constructors[0];
+ } else {
+ Constructor<T> selected = null;
+ for (Constructor<T> ctor : constructors) {
+ if (allArgsAnnotated(ctor)) {
+ selected = ctor;
+ for (Constructor<T> ctor2 : constructors) {
+ if (selected != ctor2 && allArgsAnnotated(ctor2)) {
+ throw new InvalidConstructorException("[JCI50005] Multiple annotated constructors");
+ }
+ }
+ }
+ }
+ if (selected == null) {
+ for (Constructor<T> ctor : constructors) {
+ if (ctor.getParameterTypes().length == 0) {
+ selected = ctor;
+ break;
+ }
+ }
+ }
+ if (selected == null) {
+ throw new NoConstructorException();
+ }
+ constructor = selected;
+ definition = type.getConstructors().get(selected);
+ type.setConstructor(definition);
+ }
+ definition = type.getConstructors().get(constructor);
+ type.setConstructor(definition);
+ }
+ JavaParameterImpl[] parameters = definition.getParameters();
+ if (parameters.length == 0) {
+ return;
+ }
+ Map<String, JavaElementImpl> props = type.getPropertyMembers();
+ Map<String, JavaElementImpl> refs = type.getReferenceMembers();
+ Annotation[][] annotations = constructor.getParameterAnnotations();
+ if (!explict) {
+ // the constructor wasn't defined by an annotation, so check to see
+ // if any of the params have an annotation
+ // which we can impute as explicitly defining the constructor, e.g.
+ // @Property, @Reference, or @Autowire
+ explict = injectionAnnotationsPresent(annotations);
+ }
+ if (explict) {
+ for (int i = 0; i < parameters.length; i++) {
+ if (isAnnotated(parameters[i])) {
+ continue;
+ } else if (!findReferenceOrProperty(parameters[i], props, refs)) {
+ throw new AmbiguousConstructorException(parameters[i].toString());
+ }
+ }
+ } else {
+ if (!areUnique(parameters)) {
+ throw new AmbiguousConstructorException("Cannot resolve non-unique parameter types, use @Constructor");
+ }
+ if (!calcPropRefUniqueness(props.values(), refs.values())) {
+ throw new AmbiguousConstructorException("Cannot resolve non-unique parameter types, use @Constructor");
+ }
+ if (!(props.isEmpty() && refs.isEmpty())) {
+ calcParamNames(parameters, props, refs);
+ } else {
+ heuristicParamNames(type, parameters);
+
+ }
+ }
+ }
+
+ private boolean allArgsAnnotated(Constructor<?> ctor) {
+ if (ctor.getParameterTypes().length < 1) {
+ return false;
+ }
+ for (Annotation[] as : ctor.getParameterAnnotations()) {
+ if (as.length < 1) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private void calcParamNames(JavaParameterImpl[] parameters,
+ Map<String, JavaElementImpl> props,
+ Map<String, JavaElementImpl> refs) throws AmbiguousConstructorException {
+ // the constructor param types must unambiguously match defined
+ // reference or property types
+ for (JavaParameterImpl param : parameters) {
+ if (!findReferenceOrProperty(param, props, refs)) {
+ throw new AmbiguousConstructorException(param.getName());
+ }
+ }
+ }
+
+ private void heuristicParamNames(JavaImplementation type, JavaParameterImpl[] parameters)
+ throws IntrospectionException {
+ // heuristically determine refs and props from the parameter types
+ for (JavaParameterImpl p : parameters) {
+ String name = p.getType().getSimpleName().toLowerCase();
+ if (isReferenceType(p.getType(), p.getGenericType())) {
+ type.getReferences().add(createReference(name, p.getType(), p.getGenericType()));
+ p.setClassifer(Reference.class);
+ type.getReferenceMembers().put(name, p);
+ } else {
+ type.getProperties().add(createProperty(name, p.getType(), p.getGenericType()));
+ p.setClassifer(Property.class);
+ type.getPropertyMembers().put(name, p);
+ }
+ p.setName(name);
+ }
+ }
+
+
+
+ /**
+ * Returns true if the union of the given collections of properties and
+ * references have unique Java types
+ */
+ private boolean calcPropRefUniqueness(Collection<JavaElementImpl> props, Collection<JavaElementImpl> refs) {
+
+ Class<?>[] classes = new Class[props.size() + refs.size()];
+ int i = 0;
+ for (JavaElementImpl property : props) {
+ classes[i] = property.getType();
+ i++;
+ }
+ for (JavaElementImpl reference : refs) {
+ classes[i] = reference.getType();
+ i++;
+ }
+ return areUnique(classes);
+ }
+
+ /**
+ * Unambiguously finds the reference or property associated with the given
+ * type
+ *
+ * @return the name of the reference or property if found, null if not
+ * @throws AmbiguousConstructorException if the constructor parameter cannot
+ * be resolved to a property or reference
+ */
+ private boolean findReferenceOrProperty(JavaParameterImpl parameter,
+ Map<String, JavaElementImpl> props,
+ Map<String, JavaElementImpl> refs) throws AmbiguousConstructorException {
+
+ boolean found = false;
+ if (!"".equals(parameter.getName())) {
+ // Match by name
+ JavaElementImpl prop = props.get(parameter.getName());
+ if (prop != null && prop.getType() == parameter.getType()) {
+ parameter.setClassifer(Property.class);
+ return true;
+ }
+ JavaElementImpl ref = refs.get(parameter.getName());
+ if (ref != null && ref.getType() == parameter.getType()) {
+ parameter.setClassifer(Reference.class);
+ return true;
+ }
+ }
+ for (JavaElementImpl property : props.values()) {
+ if (property.getType() == parameter.getType()) {
+ if (found) {
+ throw new AmbiguousConstructorException("Ambiguous property or reference for constructor type",
+ (Member)parameter.getAnchor());
+ }
+ parameter.setClassifer(Property.class);
+ parameter.setName(property.getName());
+ found = true;
+ // do not break since ambiguities must be checked, i.e. more
+ // than one prop or ref of the same type
+ }
+ }
+ for (JavaElementImpl reference : refs.values()) {
+ if (reference.getType() == parameter.getType()) {
+ if (found) {
+ throw new AmbiguousConstructorException("Ambiguous property or reference for constructor type",
+ (Member)parameter.getAnchor());
+ }
+ parameter.setClassifer(Reference.class);
+ parameter.setName(reference.getName());
+ found = true;
+ // do not break since ambiguities must be checked, i.e. more
+ // than one prop or ref of the same type
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Creates a mapped property.
+ *
+ * @param name the property name
+ * @param paramType the property type
+ */
+ private org.apache.tuscany.sca.assembly.Property createProperty(String name, Class<?> javaClass, Type genericType) {
+ return AbstractPropertyProcessor.createProperty(assemblyFactory, name, javaClass, genericType);
+ }
+
+ private org.apache.tuscany.sca.assembly.Reference createReference(String name, Class<?> paramType,
+ Type genericType )
+ throws IntrospectionException {
+ org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
+ reference.setName(name);
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ reference.setInterfaceContract(interfaceContract);
+ // Compute the interface type dealing with array/Collection types and with Generic types
+ Class<?> baseType = getBaseType(paramType, genericType);
+ if (ServiceReference.class.isAssignableFrom(baseType)) {
+ if (Collection.class.isAssignableFrom(paramType)) {
+ genericType = JavaIntrospectionHelper.getParameterType(genericType);
+ }
+ baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, genericType);
+ } // end if
+ try {
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(baseType);
+
+ reference.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+ // Multiplicity of an implicit reference is 1..1 for a simple interface type
+ // and 1..n for an array of interface or Collection of interface type
+ // as defined in the OASIS SCA Java POJO specification, section 8.1 : TUSCANY-3636
+ if( isCollectionType( paramType ) || isArrayType( paramType )) {
+ reference.setMultiplicity(Multiplicity.ONE_N);
+ } else {
+ reference.setMultiplicity(Multiplicity.ONE_ONE);
+ } // end if
+ } catch (InvalidInterfaceException e1) {
+ throw new IntrospectionException(e1);
+ } // end try
+
+ // FIXME: This part seems to have already been taken care above!!
+ try {
+ processCallback(paramType, reference);
+ } catch (InvalidServiceTypeException e) {
+ throw new IntrospectionException(e);
+ }
+ return reference;
+ }
+
+ /**
+ * Reports if a parameter type is a form of java.util.Collection
+ * @param paramType
+ * @return true if paramType is a form of java.util.Collection, false otherwise
+ */
+ private boolean isCollectionType( Class<?> paramType ) {
+ if( Collection.class.isAssignableFrom(paramType) ) return true;
+ return false;
+ }
+
+ /**
+ * Reports if a parameter type is an array
+ * @param paramType
+ * @return true if paramType is an array
+ */
+ private boolean isArrayType( Class<?> paramType ) {
+ if( paramType.isArray() ) return true;
+ return false;
+ }
+
+ private org.apache.tuscany.sca.assembly.Service createService(Class<?> interfaze) throws InvalidInterfaceException {
+ org.apache.tuscany.sca.assembly.Service service = assemblyFactory.createService();
+ service.setName(interfaze.getSimpleName());
+
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ service.setInterfaceContract(interfaceContract);
+
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
+ service.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ service.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+
+ Interface javaInterface = service.getInterfaceContract().getInterface();
+ javaInterface.setRemotable(interfaze.getAnnotation(Remotable.class) != null);
+ service.getInterfaceContract().setInterface(javaInterface);
+ return service;
+ }
+
+ private void processCallback(Class<?> interfaze, Contract contract) throws InvalidServiceTypeException {
+ Callback callback = interfaze.getAnnotation(Callback.class);
+ if (callback != null && !Void.class.equals(callback.value())) {
+ Class<?> callbackClass = callback.value();
+ JavaInterface javaInterface;
+ try {
+ javaInterface = javaInterfaceFactory.createJavaInterface(callbackClass);
+ contract.getInterfaceContract().setCallbackInterface(javaInterface);
+ } catch (InvalidInterfaceException e) {
+ throw new InvalidServiceTypeException("Invalid callback interface "+callbackClass, interfaze);
+ }
+ } else if (callback != null && Void.class.equals(callback.value())) {
+ throw new InvalidServiceTypeException("No callback interface specified on annotation", interfaze);
+ }
+ }
+
+
+ /**
+ * Utility methods
+ */
+
+
+ /**
+ * Verify if the method is a public setter
+ * @param method
+ * @return
+ */
+ private static boolean isPublicSetter(Method method) {
+ return method.getParameterTypes().length == 1 && Modifier.isPublic(method.getModifiers())
+ && method.getName().startsWith("set")
+ && method.getReturnType() == void.class;
+ }
+
+ /**
+ * Verify if the method is a protected setter
+ * @param method
+ * @return
+ */
+ private static boolean isProtectedSetter(Method method) {
+ return method.getParameterTypes().length == 1 && Modifier.isProtected(method.getModifiers())
+ && method.getName().startsWith("set")
+ && method.getReturnType() == void.class;
+ }
+
+ /**
+ * @param collection
+ * @return
+ */
+ private static boolean areUnique(Class<?>[] collection) {
+ Set<Class<?>> set = new HashSet<Class<?>>(Arrays.asList(collection));
+ return set.size() == collection.length;
+ }
+
+ /**
+ * Returns true if a given type is reference according to the SCA
+ * specification rules for determining reference types The following rules
+ * are used to determine whether an unannotated field or setter method is a
+ * property or reference:
+ * <ol>
+ * <li>If its type is simple, then it is a property.
+ * <li>If its type is complex, then if the type is an interface marked by
+ *
+ * @Remotable, then it is a reference; otherwise, it is a property.
+ * <li>Otherwise, if the type associated with the member is an
+ * array or a java.util.Collection, the basetype is the element
+ * type of the array or the parameterized type of the
+ * Collection; otherwise the basetype is the member type. If the
+ * basetype is an interface with an
+ * @Remotable or
+ * @Service annotation then the member is defined as a reference. Otherwise,
+ * it is defined as a property.
+ * </ol>
+ * <p>
+ * The name of the reference or of the property is derived from the
+ * name found on the setter method or on the field.
+ */
+ // FIXME: [rfeng] What if it's a collection of references?
+ private static boolean isReferenceType(Class<?> cls, Type genericType) {
+ Class<?> baseType = JavaIntrospectionHelper.getBaseType(cls, genericType);
+ return baseType.isInterface() && baseType.isAnnotationPresent(Remotable.class);
+ }
+
+ /**
+ * Returns true if the given operation is defined in the collection of
+ * service interfaces
+ * @param operation
+ * @param services
+ * @return
+ */
+ private static boolean isInServiceInterface(Method operation, List<org.apache.tuscany.sca.assembly.Service> services) {
+ for (org.apache.tuscany.sca.assembly.Service service : services) {
+ Interface interface1 = service.getInterfaceContract().getInterface();
+ if (interface1 instanceof JavaInterface) {
+ Class<?> clazz = ((JavaInterface)interface1).getJavaClass();
+ if (isMethodMatched(clazz, operation)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Test if the class declares a method which matches the signature of the
+ * given method
+ *
+ * @param clazz
+ * @param method
+ * @return
+ */
+ private static boolean isMethodMatched(Class<?> clazz, Method method) {
+ if (method.getDeclaringClass() == clazz) {
+ return true;
+ }
+ Method[] methods = clazz.getMethods();
+ for (Method m : methods) {
+ if (JavaIntrospectionHelper.exactMethodMatch(method, m)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Verify if there is any SCA annotation on the parameter
+ * @param parameter
+ * @return
+ */
+ private static boolean isAnnotated(JavaParameterImpl parameter) {
+ for (Annotation annotation : parameter.getAnnotations()) {
+ if (isSCAAnnotation(annotation)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Verify if the parameters are unique
+ * @param parameters
+ * @return
+ */
+ private static boolean areUnique(JavaParameterImpl[] parameters) {
+ Set<Class<?>> set = new HashSet<Class<?>>(parameters.length);
+ for (JavaParameterImpl p : parameters) {
+ if (!set.add(p.getType())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Verify if the annotations are SCA annotation
+ * @param annots
+ * @return
+ */
+ private static boolean injectionAnnotationsPresent(Annotation[][] annots) {
+ for (Annotation[] annotations : annots) {
+ for (Annotation annotation : annotations) {
+ Class<? extends Annotation> annotType = annotation.annotationType();
+ if (annotType == Property.class || annotType == Reference.class
+ || annotType == Resource.class
+ || annotType == ComponentName.class
+ || annotType == Context.class
+ || annotType == Callback.class) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java
new file mode 100644
index 0000000000..badd41fbb9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal use of {@link org.oasisopen.sca.annotation.Callback} on a reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalCallbackReferenceException extends IntrospectionException {
+ private static final long serialVersionUID = -8932525723147700591L;
+
+ public IllegalCallbackReferenceException(String message) {
+ super(message);
+ }
+
+ public IllegalCallbackReferenceException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java
new file mode 100644
index 0000000000..fa1e67a336
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal signature for a method decorated with {@link org.oasisopen.sca.annotation.Context}
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalContextException extends IntrospectionException {
+ private static final long serialVersionUID = -6946383136750117008L;
+
+ public IllegalContextException(String message) {
+ super(message);
+ }
+
+ public IllegalContextException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java
new file mode 100644
index 0000000000..0c4c3d5646
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal signature for a method decorated with {@link org.oasisopen.sca.annotation.Destroy}
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalDestructorException extends IntrospectionException {
+ private static final long serialVersionUID = 365719353107446326L;
+
+ public IllegalDestructorException(String message) {
+ super(message);
+ }
+
+ public IllegalDestructorException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java
new file mode 100644
index 0000000000..2956b60b65
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal signature for a method decorated with {@link @org.oasisopen.sca.annotation.Init}
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalInitException extends IntrospectionException {
+ private static final long serialVersionUID = -3690763271986854701L;
+
+ public IllegalInitException(String message) {
+ super(message);
+ }
+
+ public IllegalInitException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java
new file mode 100644
index 0000000000..54f7dfad1e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal property definition in a component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalPropertyException extends IntrospectionException {
+ private static final long serialVersionUID = -2836849110706758494L;
+
+ public IllegalPropertyException(String message) {
+ super(message);
+ }
+
+ public IllegalPropertyException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java
new file mode 100644
index 0000000000..25196c56e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal reference definition in a component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalReferenceException extends IntrospectionException {
+ private static final long serialVersionUID = 4612984122225271395L;
+
+ public IllegalReferenceException(String message) {
+ super(message);
+ }
+
+ public IllegalReferenceException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java
new file mode 100644
index 0000000000..ccfbaf0043
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal resource definition in a component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalResourceException extends IntrospectionException {
+ private static final long serialVersionUID = -1100936539412435579L;
+
+ public IllegalResourceException(String message) {
+ super(message);
+ }
+
+ public IllegalResourceException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java
new file mode 100644
index 0000000000..e0f90779a1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.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 org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal use of the {@link @org.oasisopen.sca.annotation.Service} annotation
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalServiceDefinitionException extends IntrospectionException {
+ private static final long serialVersionUID = -7151534258405092548L;
+
+ public IllegalServiceDefinitionException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
new file mode 100644
index 0000000000..a5227fc4f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.oasisopen.sca.annotation.Init;
+
+/**
+ * Processes the {@link @Init} annotation on a component implementation and
+ * updates the component type with the decorated initializer method
+ *
+ * @version $Rev$ $Date$
+ */
+public class InitProcessor extends BaseJavaClassVisitor {
+
+ public InitProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public InitProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ Init annotation = method.getAnnotation(Init.class);
+ if (annotation == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 0) {
+ throw new IllegalInitException("[JCA90008] Initializer must not have argments", method);
+ }
+ if(!method.getReturnType().equals(void.class)) {
+ throw new IllegalInitException("Initializer must return void.", method);
+ }
+ if (type.getInitMethod() != null) {
+ throw new DuplicateInitException("More than one initializer found on implementaton");
+ }
+ if (!Modifier.isPublic(method.getModifiers())) {
+ throw new IllegalInitException("Initializer must be a public method. Invalid annotation @Init found on "+method);
+ }
+ type.setInitMethod(method);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java
new file mode 100644
index 0000000000..c75dfdaf46
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.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 org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an invalid constructor definition, e.g. when the number of injection names specified in {@link
+ * org.oasisopen.sca.annotation.Constructor} do not match the number of actual constructor parameters
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConstructorException extends IntrospectionException {
+ private static final long serialVersionUID = 1411492435210741512L;
+
+ public InvalidConstructorException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java
new file mode 100644
index 0000000000..079495e4db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.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.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Raised when an implementation specifies improper conversational metadata
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConversationalImplementationException extends IntrospectionException {
+ private static final long serialVersionUID = -5487291552769408149L;
+
+ public InvalidConversationalImplementationException(String message) {
+ super(message);
+ }
+
+ public InvalidConversationalImplementationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java
new file mode 100644
index 0000000000..429b88aa1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.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 org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an invalid usage of {@link org.oasisopen.sca.annotation.Property}
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidPropertyException extends IntrospectionException {
+ private static final long serialVersionUID = -2682862652069727948L;
+
+ public InvalidPropertyException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java
new file mode 100644
index 0000000000..fbf3fc9ed3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an invalid usage of {@link org.oasisopen.sca.annotation.Reference}
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidReferenceException extends IntrospectionException {
+ private static final long serialVersionUID = -3285246635989254165L;
+
+ public InvalidReferenceException(String message) {
+ super(message);
+ }
+
+ public InvalidReferenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidReferenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java
new file mode 100644
index 0000000000..debb5cbacc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an invalid usage of {@link @org.apache.tuscany.api.annotation.Resource}
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidResourceException extends IntrospectionException {
+ private static final long serialVersionUID = 511728001735534934L;
+
+ public InvalidResourceException(String message) {
+ super(message);
+ }
+
+ public InvalidResourceException(String message, Member member) {
+ super(message, member);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java
new file mode 100644
index 0000000000..230c8c6fdd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when a service type specified by an {@link org.oasisopen.sca.annotation.Service} annotation is invalid, e.g. it is
+ * not an interface
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidServiceTypeException extends IntrospectionException {
+ private static final long serialVersionUID = -1076466639416644386L;
+ private Class<?> serviceType;
+
+ public InvalidServiceTypeException(String message) {
+ super(message);
+ }
+
+ public InvalidServiceTypeException(String message, Class<?> clazz) {
+ super(message);
+ this.serviceType = clazz;
+ }
+
+ /**
+ * @return the serviceType
+ */
+ public Class<?> getServiceType() {
+ return serviceType;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java
new file mode 100644
index 0000000000..d97d375a0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java
@@ -0,0 +1,309 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.xml.WebServiceConstants;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Process JAXWS annotations and updates the component type accordingly
+ *
+ */
+public class JAXWSProcessor extends BaseJavaClassVisitor {
+
+ private PolicyFactory policyFactory;
+ private WSDLFactory wsdlFactory;
+ private WebServiceBindingFactory wsBindingFactory;
+
+ public JAXWSProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.wsdlFactory = factories.getFactory(WSDLFactory.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.wsBindingFactory = factories.getFactory(WebServiceBindingFactory.class);
+ }
+
+ @Override
+ public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+
+ boolean hasJaxwsAnnotation = false;
+
+ // Process @ServiceMode annotation - JCA 11013
+ if ( clazz.getAnnotation(ServiceMode.class) != null ) {
+ addSOAPIntent(type);
+ hasJaxwsAnnotation = true;
+ }
+
+ // Process @WebService annotation - POJO_8029, POJO_8030
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ org.oasisopen.sca.annotation.Service serviceAnnotation = clazz.getAnnotation(org.oasisopen.sca.annotation.Service.class);
+
+ if (webServiceAnnotation != null &&
+ serviceAnnotation == null) {
+ String serviceName = clazz.getSimpleName();
+ serviceName = getValue(webServiceAnnotation.name(), serviceName);
+
+ String serviceInterfaceClassName = webServiceAnnotation.endpointInterface();
+
+ String wsdlLocation = webServiceAnnotation.wsdlLocation();
+
+ try {
+ createService(type, clazz, serviceName, serviceInterfaceClassName, wsdlLocation, false);
+ } catch (InvalidInterfaceException e) {
+ throw new IntrospectionException(e);
+ }
+ hasJaxwsAnnotation = true;
+ }
+
+ // Process @WebServiceProvider annotation - JCA_11015, POJO_8034
+ WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
+ if (webServiceProviderAnnotation != null) {
+ // if the implmentation already has a service set, use it's name
+ // and the new service, which uses the implementation as an interface,
+ // will be replaced
+ String serviceName = clazz.getSimpleName();
+
+ if (type.getServices().size() > 0){
+ serviceName = ((Service)type.getServices().get(0)).getName();
+ }
+
+ // the annotation may specify a service name
+ serviceName = getValue(webServiceProviderAnnotation.serviceName(), serviceName);
+
+ String wsdlLocation = webServiceProviderAnnotation.wsdlLocation();
+
+ // Make sure that there is a service with an interface
+ // based on the implementation class and have it replace
+ // any service with the same name
+ try {
+ createService(type, clazz, serviceName, null, wsdlLocation, true);
+ } catch (InvalidInterfaceException e) {
+ throw new IntrospectionException(e);
+ }
+
+ // Make sure all service references are remotable
+ for ( Service service : type.getServices() ) {
+ service.getInterfaceContract().getInterface().setRemotable(true);
+ }
+
+ hasJaxwsAnnotation = true;
+ }
+
+ // Process @WebParam and @WebResult annotations - POJO_8031, POJO_8032
+ Class<?> interfaze = clazz;
+ Method[] implMethods = interfaze.getDeclaredMethods();
+ for ( Service service : type.getServices() ) {
+ JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getInterface();
+ interfaze = javaInterface.getJavaClass();
+
+ if (interfaze == null){
+ // this interface has come from an @WebService enpointInterface annotation
+ // so hasn't been resolved. Use the implementation class as the interface
+ interfaze = clazz;
+ }
+
+ boolean hasHeaderParam = false;
+ for (Method method : interfaze.getDeclaredMethods()){
+ // find the impl method for this service method
+ for (int i = 0; i < implMethods.length; i++){
+ Method implMethod = implMethods[i];
+ if (implMethod.getName().equals(method.getName())){
+ for (int j = 0; j < implMethod.getParameterTypes().length; j++) {
+ WebParam webParamAnnotation = getParameterAnnotation(implMethod, j, WebParam.class);
+ if (webParamAnnotation != null &&
+ webParamAnnotation.header()) {
+ hasHeaderParam = true;
+ break;
+ }
+ }
+
+ WebResult webResultAnnotation = implMethod.getAnnotation(WebResult.class);
+ if (webResultAnnotation != null &&
+ webResultAnnotation.header()){
+ hasHeaderParam = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (hasHeaderParam){
+ // Add a SOAP intent to the service
+ addSOAPIntent(service);
+ hasJaxwsAnnotation = true;
+ }
+ }
+
+ // Process @SOAPBinding annotation - POJO_8033
+ if ( clazz.getAnnotation(SOAPBinding.class) != null ) {
+ // If the implementation is annotated with @SOAPBinding,
+ // give all services a SOAP intent
+ for ( Service service : type.getServices() ) {
+ addSOAPIntent(service);
+ }
+ hasJaxwsAnnotation = true;
+ }
+
+ if (hasJaxwsAnnotation == true){
+ // Note that services are based on JAXWS annotations in case
+ // we need to know later. Add a ws binding and a JAXWS annotation
+ // implies a WS binding
+ for ( Service service : type.getServices() ) {
+ service.setJAXWSService(true);
+ createWSBinding(type, service);
+ }
+ }
+ }
+
+ /**
+ * Utility methods
+ */
+
+ private static String getValue(String value, String defaultValue) {
+ return "".equals(value) ? defaultValue : value;
+ }
+
+ private Service createService(JavaImplementation type, Class<?> clazz, String serviceName, String javaInterfaceName, String wsdlFileName, boolean replace) throws InvalidInterfaceException, IntrospectionException {
+ Service service = assemblyFactory.createService();
+
+ if (serviceName != null) {
+ service.setName(serviceName);
+ } else if (javaInterfaceName != null){
+ service.setName(javaInterfaceName.substring(javaInterfaceName.lastIndexOf('.')));
+ }
+
+ // create the physical Java interface contract
+ JavaInterfaceContract javaInterfaceContract = javaInterfaceFactory.createJavaInterfaceContract();;
+ service.setInterfaceContract(javaInterfaceContract);
+
+ if (javaInterfaceName != null &&
+ javaInterfaceName.length() > 0){
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface();
+ callInterface.setName(javaInterfaceName);
+ callInterface.setRemotable(true);
+ callInterface.setUnresolved(true);
+ javaInterfaceContract.setInterface(callInterface);
+ } else {
+ // we use the bean class as the service interface
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(clazz);
+ callInterface.setRemotable(true);
+ callInterface.setUnresolved(false); // this will already be false but this makes it easy to follow the logic
+ javaInterfaceContract.setInterface(callInterface);
+ }
+
+ // create the logical WSDL interface if it's specified in
+ // the @WebService annotation
+ if (wsdlFileName != null &&
+ wsdlFileName.length() > 0){
+ WSDLInterface callInterface = wsdlFactory.createWSDLInterface();
+ callInterface.setUnresolved(true);
+ callInterface.setRemotable(true);
+
+ WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ wsdlInterfaceContract.setInterface(callInterface);
+ wsdlInterfaceContract.setLocation(wsdlFileName);
+ javaInterfaceContract.setNormailizedWSDLContract(wsdlInterfaceContract);
+ }
+
+ // add the service model into the implementation type
+ Service serviceAlreadyPresent = null;
+ for (Service typeService : type.getServices()){
+ if (typeService.getName().equals(service.getName())){
+ serviceAlreadyPresent = typeService;
+ break;
+ }
+ }
+
+ if (replace == true){
+ type.getServices().remove(serviceAlreadyPresent);
+ type.getServices().add(service);
+ } else {
+ if (serviceAlreadyPresent == null){
+ type.getServices().add(service);
+ }
+ }
+
+ return service;
+ }
+
+ private <T extends Annotation> T getParameterAnnotation(Method method, int index, Class<T> annotationType) {
+ Annotation[] annotations = method.getParameterAnnotations()[index];
+ for (Annotation annotation : annotations) {
+ if (annotation.annotationType() == annotationType) {
+ return annotationType.cast(annotation);
+ }
+ }
+ return null;
+ }
+
+ private void addSOAPIntent(PolicySubject policySubject){
+ Intent soapIntent = policyFactory.createIntent();
+ soapIntent.setName(Constants.SOAP_INTENT);
+ policySubject.getRequiredIntents().add(soapIntent);
+ }
+
+ private void createWSBinding(JavaImplementation javaImplementation, Service service){
+ if(service.getBindings().size() == 0){
+ WebServiceBinding wsBinding = wsBindingFactory.createWebServiceBinding();
+ wsBinding.setName(service.getName());
+ ExtensionType bindingType = policyFactory.createBindingType();
+ bindingType.setType(WebServiceConstants.BINDING_WS_QNAME);
+ bindingType.setUnresolved(true);
+ ((PolicySubject)wsBinding).setExtensionType(bindingType);
+ service.getBindings().add(wsBinding);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java
new file mode 100644
index 0000000000..453cfa35fe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.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.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when a suitable constructor for a component implementation cannot be found
+ *
+ * @version $Rev$ $Date$
+ */
+public class NoConstructorException extends IntrospectionException {
+ private static final long serialVersionUID = 3086706387280694424L;
+
+ public NoConstructorException() {
+ }
+
+ public NoConstructorException(String message) {
+ super(message);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
new file mode 100644
index 0000000000..15d31a5ad9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.PolicySets;
+import org.oasisopen.sca.annotation.Qualifier;
+import org.oasisopen.sca.annotation.Requires;
+
+/**
+ * Processes an {@link org.oasisopen.sca.annotation.Requires} annotation
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyProcessor extends BaseJavaClassVisitor {
+
+ private PolicyFactory policyFactory;
+
+ public PolicyProcessor(AssemblyFactory assemblyFactory,
+ PolicyFactory policyFactory,
+ JavaInterfaceFactory javaInterfaceFactory) {
+ super(assemblyFactory);
+ this.policyFactory = policyFactory;
+ this.javaInterfaceFactory = javaInterfaceFactory;
+ }
+
+ public PolicyProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ }
+
+ @Override
+ public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+
+ // Read intents on the Java implementation class
+ readPolicySetAndIntents((PolicySubject)type, clazz);
+
+ /*
+ // FIXME: [rfeng] We might want to refactor this out
+ // Find the business methods in the implementation class for all services
+ Set<Method> methods = new HashSet<Method>();
+ for (Service service : type.getServices()) {
+ for (Operation op : service.getInterfaceContract().getInterface().getOperations()) {
+ Method method;
+ try {
+ method = JavaInterfaceUtil.findMethod(clazz, op);
+ } catch (NoSuchMethodException e1) {
+ throw new IntrospectionException(e1);
+ }
+ if (method != null) {
+ methods.add(method);
+ }
+ }
+ }
+ for (Method method : methods) {
+ JavaOperation op = javaInterfaceFactory.createJavaOperation(method);
+ type.getOperations().add(op);
+ }
+
+ // Read the operation-level policy settings for the implementation
+ for (Operation op : type.getOperations()) {
+ JavaOperation operation = (JavaOperation)op;
+ PolicySubject subject = op;
+ Method method = operation.getJavaMethod();
+ if (subject != null) {
+ readPolicySetAndIntents(subject, method);
+ }
+ }
+ */
+
+ // Start to process annotations on the reference members
+ Map<String, Reference> referenceMap = new HashMap<String, Reference>();
+ for (Reference ref : type.getReferences()) {
+ referenceMap.put(ref.getName(), ref);
+ }
+ Map<String, JavaElementImpl> members = type.getReferenceMembers();
+ for (Map.Entry<String, JavaElementImpl> e : members.entrySet()) {
+ Reference reference = referenceMap.get(e.getKey());
+ readPolicySetAndIntents(reference, e.getValue().getAnchor());
+ }
+
+ }
+
+ private void readPolicySetAndIntents(PolicySubject subject, AnnotatedElement element) {
+ readIntents(element.getAnnotation(Requires.class), subject.getRequiredIntents());
+ readSpecificIntents(element.getAnnotations(), subject.getRequiredIntents());
+ readPolicySets(element.getAnnotation(PolicySets.class), subject.getPolicySets());
+ }
+
+ private void readPolicySetAndIntents(PolicySubject subject, JavaElementImpl element) {
+ readIntents(element.getAnnotation(Requires.class), subject.getRequiredIntents());
+ readSpecificIntents(element.getAnnotations(), subject.getRequiredIntents());
+ readPolicySets(element.getAnnotation(PolicySets.class), subject.getPolicySets());
+ }
+
+ private void readSpecificIntents(Annotation[] annotations, List<Intent> requiredIntents) {
+ for (Annotation a : annotations) {
+ org.oasisopen.sca.annotation.Intent intentAnnotation =
+ a.annotationType().getAnnotation(org.oasisopen.sca.annotation.Intent.class);
+ if (intentAnnotation == null) {
+ continue;
+ }
+ QName qname = null;
+ String value = intentAnnotation.value();
+ if (!value.equals("")) {
+ qname = getQName(value);
+ } else {
+ qname = new QName(intentAnnotation.targetNamespace(), intentAnnotation.localPart());
+ }
+ Set<String> qualifiers = new HashSet<String>();
+ for (Method m : a.annotationType().getMethods()) {
+ Qualifier qualifier = m.getAnnotation(Qualifier.class);
+ if (qualifier != null && m.getReturnType() == String[].class) {
+ try {
+ qualifiers.addAll(Arrays.asList((String[])m.invoke(a)));
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ qualifiers.remove("");
+ if (qualifiers.isEmpty()) {
+ Intent intent = policyFactory.createIntent();
+ intent.setUnresolved(true);
+ intent.setName(qname);
+ requiredIntents.add(intent);
+ } else {
+ for (String q : qualifiers) {
+ Intent intent = policyFactory.createIntent();
+ intent.setUnresolved(true);
+ qname = new QName(qname.getNamespaceURI(), qname.getLocalPart() + "." + q);
+ intent.setName(qname);
+ requiredIntents.add(intent);
+ }
+ }
+ }
+ }
+
+ /**
+ * Read intent annotations on the given interface or class
+ * @param intentAnnotation
+ * @param requiredIntents
+ */
+ private void readIntents(Requires intentAnnotation, List<Intent> requiredIntents) {
+ //Requires intentAnnotation = method.getAnnotation(Requires.class);
+ if (intentAnnotation != null) {
+ String[] intentNames = intentAnnotation.value();
+ if (intentNames.length != 0) {
+ //Operation operation = assemblyFactory.createOperation();
+ //operation.setName(method.getName());
+ //operation.setUnresolved(true);
+ for (String intentName : intentNames) {
+
+ // Add each intent to the list, associated with the
+ // operation corresponding to the annotated method
+ Intent intent = policyFactory.createIntent();
+ intent.setName(getQName(intentName));
+ //intent.getOperations().add(operation);
+ requiredIntents.add(intent);
+ }
+ }
+ }
+ }
+
+ /**
+ * Read policy set annotations on a given interface or class
+ * @param policySetAnnotation
+ * @param policySets
+ */
+ private void readPolicySets(PolicySets policySetAnnotation, List<PolicySet> policySets) {
+ if (policySetAnnotation != null) {
+ String[] policySetNames = policySetAnnotation.value();
+ if (policySetNames.length != 0) {
+ //Operation operation = assemblyFactory.createOperation();
+ //operation.setName(method.getName());
+ //operation.setUnresolved(true);
+ for (String policySetName : policySetNames) {
+ // Add each intent to the list, associated with the
+ // operation corresponding to the annotated method
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(getQName(policySetName));
+ //intent.getOperations().add(operation);
+ policySets.add(policySet);
+ }
+ }
+ }
+ }
+
+ /**
+ * Utility methods
+ */
+
+ /**
+ *
+ * @param intentName
+ * @return
+ */
+ private static QName getQName(String intentName) {
+ QName qname;
+ if (intentName.startsWith("{")) {
+ int i = intentName.indexOf('}');
+ if (i != -1) {
+ qname = new QName(intentName.substring(1, i), intentName.substring(i + 1));
+ } else {
+ qname = new QName("", intentName);
+ }
+ } else {
+ qname = new QName("", intentName);
+ }
+ return qname;
+ }
+
+ @Override
+ public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+ // Check if a field that is not an SCA reference has any policySet/intent annotations
+ JavaElementImpl element = new JavaElementImpl(field);
+ if (!type.getReferenceMembers().values().contains(element)) {
+ PolicySubject subject = assemblyFactory.createComponent();
+ readPolicySetAndIntents(subject, field);
+ if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
+ return;
+ }
+ throw new ServiceRuntimeException(
+ "[JCA70002,JCA70005] Field that is not an SCA reference cannot have policySet/intent annotations: " + field);
+ }
+ }
+
+ @Override
+ public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type) {
+ if (!type.getReferenceMembers().values().contains(parameter)) {
+ PolicySubject subject = assemblyFactory.createComponent();
+ readPolicySetAndIntents(subject, parameter);
+ if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
+ return;
+ }
+ throw new ServiceRuntimeException(
+ "[JCA70002,JCA70005] Constructor parameter that is not an SCA reference cannot have policySet/intent annotations: " + parameter);
+ }
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ Set<AnnotatedElement> annotatedElements = new HashSet<AnnotatedElement>();
+ for (JavaElementImpl element : type.getReferenceMembers().values()) {
+ annotatedElements.add(element.getAnchor());
+ }
+ // Check if a field that is not an SCA reference has any policySet/intent annotations
+ if (!annotatedElements.contains(method)) {
+ PolicySubject subject = assemblyFactory.createComponent();
+ readPolicySetAndIntents(subject, method);
+ if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
+ return;
+ }
+ throw new ServiceRuntimeException(
+ "[JCA70002,JCA70005] Method that is not an SCA reference cannot have policySet/intent annotations: " + method);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
new file mode 100644
index 0000000000..ed68be20b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.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.java.introspect.impl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.oasisopen.sca.annotation.Property;
+
+/**
+ * Processes an {@link @Property} annotation, updating the component type with
+ * corresponding {@link JavaMappedProperty}
+ *
+ * @version $Rev$ $Date$
+ */
+public class PropertyProcessor extends AbstractPropertyProcessor<Property> {
+
+ public PropertyProcessor(ExtensionPointRegistry registry) {
+ super(registry, Property.class);
+ }
+
+ @Override
+ protected String getName(Property annotation) {
+ return annotation.name();
+ }
+
+ @Override
+ protected void initProperty(org.apache.tuscany.sca.assembly.Property property, Property annotation) {
+ property.setMustSupply(annotation.required());
+ }
+
+ @Override
+ protected boolean getRequired(Property annotation) {
+ return annotation.required();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
new file mode 100644
index 0000000000..b5c3806166
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
@@ -0,0 +1,274 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getBaseType;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * Processes an {@link @Reference} annotation, updating the component type with
+ * corresponding {@link
+ * org.apache.tuscany.spi.implementation.java.JavaMappedReference}
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceProcessor extends BaseJavaClassVisitor {
+
+ public ReferenceProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
+ super(assemblyFactory);
+ this.javaInterfaceFactory = javaFactory;
+ }
+
+ public ReferenceProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ Reference annotation = method.getAnnotation(Reference.class);
+ if (annotation != null) {
+
+ if (!JavaIntrospectionHelper.isSetter(method)) {
+ throw new IllegalReferenceException("Annotated method is not a setter: " + method, method);
+ }
+
+ if(Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalPropertyException("Static method " + method.getName() +" in class " + method.getDeclaringClass().getName() + " can not be annotated as a Reference");
+ }
+
+ String name = annotation.name();
+ if ("".equals(name)) {
+ name = JavaIntrospectionHelper.toPropertyName(method.getName());
+ }
+ JavaElementImpl ref = type.getReferenceMembers().get(name);
+ // Setter override field
+ if (ref != null && ref.getElementType() != ElementType.FIELD) {
+ throw new DuplicateReferenceException(name);
+ }
+ removeReference(ref, type);
+
+ JavaElementImpl element = new JavaElementImpl(method, 0);
+ org.apache.tuscany.sca.assembly.Reference reference = createReference(element, name);
+ type.getReferences().add(reference);
+ type.getReferenceMembers().put(name, element);
+ }
+
+ // enforce the constraint that an ordinary method's argument can not be a reference
+ Annotation paramsAnnotations[][] = method.getParameterAnnotations();
+ for (int i = 0; i < paramsAnnotations.length; i++) {
+ Annotation argAnnotations[] = paramsAnnotations[i];
+ for (int j = 0; j < argAnnotations.length; j++) {
+ if(argAnnotations[j].annotationType() == Reference.class) {
+ throw new IllegalReferenceException("Argument " + (i+1) + " of method " + method.getName() + " in class " + method.getDeclaringClass() + " can not be a Reference");
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+ Reference annotation = field.getAnnotation(Reference.class);
+ if (annotation == null) {
+ return;
+ }
+
+ if(Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalReferenceException("Static field " + field.getName() +" in class " + field.getDeclaringClass().getName() + " can not be annotated as Reference");
+ }
+ String name = annotation.name();
+ if ("".equals(name)) {
+ name = field.getName();
+ }
+ JavaElementImpl ref = type.getReferenceMembers().get(name);
+ if (ref != null && ref.getElementType() == ElementType.FIELD) {
+ throw new DuplicateReferenceException(name);
+ }
+
+ // Setter method override field
+ if (ref == null) {
+ JavaElementImpl element = new JavaElementImpl(field);
+ org.apache.tuscany.sca.assembly.Reference reference = createReference(element, name);
+ type.getReferences().add(reference);
+ type.getReferenceMembers().put(name, element);
+ }
+ }
+
+ @Override
+ public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
+ throws IntrospectionException {
+ Reference refAnnotation = parameter.getAnnotation(Reference.class);
+ if (refAnnotation == null) {
+ return;
+ }
+
+ if (!refAnnotation.required()) {
+ throw new InvalidReferenceException("[JCA90016] Constructor has @Reference with required=false: " + type.getName());
+ }
+
+ if (refAnnotation.name() == null || refAnnotation.name().length() < 1) {
+ throw new InvalidReferenceException("[JCA90018] @Reference in a Constructor must have a name attribute" + type.getName());
+ }
+
+ String paramName = parameter.getName();
+ String name = getReferenceName(paramName, parameter.getIndex(), refAnnotation.name());
+ JavaElementImpl ref = type.getReferenceMembers().get(name);
+
+ // Setter override field
+ if (ref != null && ref.getElementType() != ElementType.FIELD) {
+ throw new DuplicateReferenceException(name);
+ }
+
+ removeReference(ref, type);
+ org.apache.tuscany.sca.assembly.Reference reference = createReference(parameter, name);
+ type.getReferences().add(reference);
+ type.getReferenceMembers().put(name, parameter);
+ parameter.setClassifer(Reference.class);
+ parameter.setName(name);
+ }
+
+ /**
+ * Create a SCA reference for a java Element
+ * @param element
+ * @param name
+ * @return
+ * @throws IntrospectionException
+ */
+ private org.apache.tuscany.sca.assembly.Reference createReference(JavaElementImpl element, String name)
+ throws IntrospectionException {
+ org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ reference.setInterfaceContract(interfaceContract);
+
+ // reference.setMember((Member)element.getAnchor());
+ boolean required = true;
+ Reference ref = element.getAnnotation(Reference.class);
+ if (ref != null) {
+ required = ref.required();
+ }
+ // reference.setRequired(required);
+ reference.setName(name);
+ Class<?> rawType = element.getType();
+ if (rawType.isArray() || Collection.class.isAssignableFrom(rawType)) {
+ if (required) {
+ reference.setMultiplicity(Multiplicity.ONE_N);
+ } else {
+ reference.setMultiplicity(Multiplicity.ZERO_N);
+ }
+ } else {
+ if (required) {
+ reference.setMultiplicity(Multiplicity.ONE_ONE);
+ } else {
+ reference.setMultiplicity(Multiplicity.ZERO_ONE);
+ }
+ }
+ Type genericType = element.getGenericType();
+ Class<?> baseType = getBaseType(rawType, genericType);
+ if (ServiceReference.class.isAssignableFrom(baseType)) {
+ if (Collection.class.isAssignableFrom(rawType)) {
+ genericType = JavaIntrospectionHelper.getParameterType(genericType);
+ }
+ baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, genericType);
+ }
+ try {
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(baseType);
+ reference.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+ } catch (InvalidInterfaceException e) {
+ throw new IntrospectionException(e);
+ }
+ return reference;
+ }
+
+
+ /**
+ * Utility methods
+ */
+
+ /**
+ *
+ * @param paramName
+ * @param pos
+ * @param name
+ * @return
+ * @throws InvalidConstructorException
+ */
+ private static String getReferenceName(String paramName, int pos, String name) throws InvalidConstructorException {
+ if ("".equals(name)) {
+ name = paramName;
+ }
+ if ("".equals(name)) {
+ return "_ref" + pos;
+ }
+ if (!"".equals(paramName) && !name.equals(paramName)) {
+ throw new InvalidConstructorException("Mismatching names specified for reference parameter " + pos);
+ } else {
+ return name;
+ }
+ }
+
+ /**
+ *
+ * @param ref
+ * @param type
+ * @return
+ */
+ private static boolean removeReference(JavaElementImpl ref, JavaImplementation type) {
+ if (ref == null) {
+ return false;
+ }
+ List<org.apache.tuscany.sca.assembly.Reference> refs = type.getReferences();
+ for (int i = 0; i < refs.size(); i++) {
+ if (refs.get(i).getName().equals(ref.getName())) {
+ refs.remove(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java
new file mode 100644
index 0000000000..3d43e39ce8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to indicate a resource should be provided to an implementation by the runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Resource {
+
+ /**
+ * Denotes the name of the resource declared by the implementation.
+ */
+ String name() default "";
+
+ /**
+ * Denotes if the resource is optional
+ */
+ boolean optional() default false;
+
+ /**
+ * Denotes the default name of the resource provided by the runtime environment.
+ */
+ String mappedName() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
new file mode 100644
index 0000000000..3abe832cb9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+
+/**
+ * Processes an {@link @Resource} annotation, updating the component type with
+ * corresponding {@link org.apache.tuscany.spi.implementation.java.JavaResourceImpl}
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResourceProcessor extends BaseJavaClassVisitor {
+
+ public ResourceProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public ResourceProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+ org.apache.tuscany.sca.implementation.java.introspect.impl.Resource annotation = method
+ .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+ if (annotation == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 1) {
+ throw new IllegalResourceException("Resource setter must have one parameter", method);
+ }
+ String name = annotation.name();
+ if (name.length() < 1) {
+ name = JavaIntrospectionHelper.toPropertyName(method.getName());
+ }
+ if (type.getResources().get(name) != null) {
+ throw new DuplicateResourceException(name);
+ }
+
+ String mappedName = annotation.mappedName();
+ JavaResourceImpl resource = createResource(name, new JavaElementImpl(method, 0));
+ resource.setOptional(annotation.optional());
+ if (mappedName.length() > 0) {
+ resource.setMappedName(mappedName);
+ }
+ type.getResources().put(resource.getName(), resource);
+ }
+
+ @Override
+ public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+
+ org.apache.tuscany.sca.implementation.java.introspect.impl.Resource annotation = field
+ .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+ if (annotation == null) {
+ return;
+ }
+ String name = annotation.name();
+ if (name.length() < 1) {
+ name = field.getName();
+ }
+ if (type.getResources().get(name) != null) {
+ throw new DuplicateResourceException(name);
+ }
+
+ String mappedName = annotation.mappedName();
+
+ JavaResourceImpl resource = createResource(name, new JavaElementImpl(field));
+ resource.setOptional(annotation.optional());
+ if (mappedName.length() > 0) {
+ resource.setMappedName(mappedName);
+ }
+ type.getResources().put(resource.getName(), resource);
+ }
+
+ @Override
+ public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
+ throws IntrospectionException {
+ org.apache.tuscany.sca.implementation.java.introspect.impl.Resource resourceAnnotation = parameter
+ .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+ if (resourceAnnotation != null) {
+ String name = resourceAnnotation.name();
+ if ("".equals(name)) {
+ name = parameter.getName();
+ }
+ if ("".equals(name)) {
+ throw new InvalidResourceException("Missing resource name", (Member)parameter.getAnchor());
+ }
+
+ if (!"".equals(parameter.getName()) && !name.equals(parameter.getName())) {
+ throw new InvalidConstructorException("Mismatched resource name: " + parameter);
+ }
+
+ if (type.getResources().get(name) != null) {
+ throw new DuplicateResourceException(name);
+ }
+
+ String mappedName = resourceAnnotation.mappedName();
+
+ JavaResourceImpl resource = createResource(name, parameter);
+ resource.setOptional(resourceAnnotation.optional());
+ if (mappedName.length() > 0) {
+ resource.setMappedName(mappedName);
+ }
+ type.getResources().put(resource.getName(), resource);
+ }
+ }
+
+
+ /**
+ * Utility methods
+ */
+
+ /**
+ *
+ * @param name
+ * @param element
+ * @return
+ */
+ private static JavaResourceImpl createResource(String name, JavaElementImpl element) {
+ element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+ element.setName(name);
+ return new JavaResourceImpl(element);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
new file mode 100644
index 0000000000..dfc122c715
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaScopeImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+
+/**
+ * Processes the {@link JavaScopeImpl} annotation and updates the component type with the corresponding implmentation scope
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeProcessor extends BaseJavaClassVisitor {
+
+ public ScopeProcessor(AssemblyFactory factory) {
+ super(factory);
+ }
+
+ public ScopeProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public <T> void visitClass(Class<T> clazz,
+ JavaImplementation type)
+ throws IntrospectionException {
+ org.oasisopen.sca.annotation.Scope annotation = clazz.getAnnotation(org.oasisopen.sca.annotation.Scope.class);
+ if (annotation == null) {
+ type.setJavaScope(JavaScopeImpl.STATELESS);
+ return;
+ }
+
+ String name = annotation.value();
+ JavaScopeImpl scope;
+ if ("COMPOSITE".equals(name)) {
+ scope = JavaScopeImpl.COMPOSITE;
+ } else if ("STATELESS".equals(name)) {
+ scope = JavaScopeImpl.STATELESS;
+ } else {
+ scope = JavaScopeImpl.INVALID;
+ }
+ type.setJavaScope(scope);
+
+ if (type.getJavaScope().equals(JavaScopeImpl.INVALID)) {
+ throw new IntrospectionException("Invalid scope :" + name + " for " + type.getName());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
new file mode 100644
index 0000000000..e30cbd08ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
@@ -0,0 +1,247 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllInterfaces;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Processes an {@link org.oasisopen.sca.annotation.Service} annotation and updates
+ * the component type with corresponding {@link Service}s. Also processes
+ * related {@link org.oasisopen.sca.annotation.Callback} annotations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceProcessor extends BaseJavaClassVisitor {
+
+ public ServiceProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
+ super(assemblyFactory);
+ this.javaInterfaceFactory = javaFactory;
+ }
+
+ public ServiceProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ org.oasisopen.sca.annotation.Service annotation = clazz.getAnnotation(org.oasisopen.sca.annotation.Service.class);
+ if (annotation == null) {
+ // scan interfaces for remotable
+ Set<Class<?>> interfaces = getAllInterfaces(clazz);
+ for (Class<?> interfaze : interfaces) {
+ if (interfaze.isAnnotationPresent(Remotable.class)
+ || interfaze.isAnnotationPresent(WebService.class)
+ || interfaze.isAnnotationPresent(Callback.class)
+ ) {
+ Service service;
+ try {
+ service = createService(clazz, interfaze, null);
+ } catch (InvalidInterfaceException e) {
+ throw new IntrospectionException(e);
+ }
+ type.getServices().add(service);
+ }
+ }
+ return;
+ }
+
+ if (annotation.value().length == 0) {
+ throw new IntrospectionException("[JCA90059] The array of interfaces or classes specified by the value attribute of the @Service annotation MUST contain at least one element");
+ }
+ Class<?>[] interfaces = annotation.value();
+ if (annotation.names().length > 0) {
+ if (annotation.names().length != interfaces.length) {
+ throw new IntrospectionException("[JCA90050] The number of Strings in the names attribute array of the @Service annotation MUST match the number of elements in the value attribute array");
+ }
+ Set<String> names = new HashSet<String>();
+ names.addAll(Arrays.asList(annotation.names()));
+ if (names.size() != annotation.names().length) {
+ throw new IntrospectionException("[JCA90060] The value of each element in the @Service names array MUST be unique amongst all the other element values in the array");
+ }
+ }
+
+ //validate no scope on servce interface
+ for (Class<?> iface : interfaces) {
+ if (iface.getAnnotation(org.oasisopen.sca.annotation.Scope.class) != null) {
+ throw new IntrospectionException("[JCA90041] @Scope annotation not allowed on service interface " + iface
+ .getName());
+ }
+ }
+
+ //validate service methods implemented
+ Method[] ms = clazz.getMethods();
+ for (Class<?> iface : interfaces) {
+ for (Method m : iface.getMethods()) {
+ if (!hasMethod(m, ms)) {
+ throw new IntrospectionException("[JCA90042,JCI20002] Implementation missing service method " + m.getName() + " service interface " + iface.getName());
+ }
+ }
+ }
+
+ for (int i=0; i < interfaces.length; i++) {
+ try {
+ String name = (annotation.names().length > 0) ? annotation.names()[i] : null;
+ Service service = createService(clazz, interfaces[i], name);
+ type.getServices().add(service);
+ } catch (InvalidInterfaceException e) {
+ throw new IntrospectionException(e);
+ }
+ }
+
+ }
+
+ protected boolean hasMethod(Method m1, Method[] ms) {
+ for (Method m2 : ms) {
+ if (JavaIntrospectionHelper.exactMethodMatch(m1, m2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+
+ Callback annotation = method.getAnnotation(Callback.class);
+ if (annotation == null) {
+ return;
+ }
+
+ if (!(annotation.value() == null || annotation.value() == Void.class)) {
+ throw new IllegalCallbackReferenceException("[JCA90046] @Callback on field of method must not have any parameters: " + type.getName() + "." + method.getName());
+ }
+
+ if(Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalCallbackReferenceException("Illegal annotation @Callback found on "+method, method);
+ }
+ if (method.getParameterTypes().length != 1) {
+ throw new IllegalCallbackReferenceException("Setter must have one parameter", method);
+ }
+ JavaElementImpl element = new JavaElementImpl(method, 0);
+ createCallback(type, element);
+ }
+
+ @Override
+ public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+
+ Callback annotation = field.getAnnotation(Callback.class);
+ if (annotation == null) {
+ return;
+ }
+ if (!(annotation.value() == null || annotation.value() == Void.class)) {
+ throw new IllegalCallbackReferenceException("[JCA90046] @Callback on field of method must not have any parameters: " + type.getName() + "." + field.getName());
+ }
+ if(Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalCallbackReferenceException("Illegal annotation @Callback found on "+field, field);
+ }
+ JavaElementImpl element = new JavaElementImpl(field);
+ createCallback(type, element);
+ }
+
+ public Service createService(Class<?> clazz, Class<?> interfaze, String name) throws InvalidInterfaceException {
+ Service service = assemblyFactory.createService();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ service.setInterfaceContract(interfaceContract);
+
+ if (name == null) {
+ service.setName(interfaze.getSimpleName());
+ } else {
+ service.setName(name);
+ }
+
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
+ boolean remotable = clazz.getAnnotation(Remotable.class) != null;
+ if (remotable){
+ callInterface.setRemotable(true);
+ }
+ service.getInterfaceContract().setInterface(callInterface);
+
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ if (remotable){
+ callbackInterface.setRemotable(true);
+ }
+ service.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+ return service;
+ }
+
+ /**
+ * Utility methods
+ */
+
+
+ /**
+ * @param type
+ * @param element
+ * @throws IllegalCallbackReferenceException
+ */
+ private static void createCallback(JavaImplementation type, JavaElementImpl element)
+ throws IllegalCallbackReferenceException {
+ Service callbackService = null;
+ Class<?> callbackClass = element.getType();
+ Type genericType = element.getGenericType();
+ Class<?> baseType = callbackClass;
+ if(ServiceReference.class.isAssignableFrom(baseType)) {
+ // @Callback protected CallableReference<MyCallback> callback;
+ // The base type will be MyCallback
+ baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, genericType);
+ }
+ for (Service service : type.getServices()) {
+ JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getCallbackInterface();
+ if (javaInterface != null && baseType == javaInterface.getJavaClass()) {
+ callbackService = service;
+ }
+ }
+ if (callbackService == null) {
+ throw new IllegalCallbackReferenceException("Callback type does not match a service callback interface: " + type.getName() );
+ }
+ if(type.getCallbackMembers().get(baseType.getName()) == null) {
+ type.getCallbackMembers().put(baseType.getName(), new ArrayList<JavaElementImpl>());
+ }
+ type.getCallbackMembers().get(baseType.getName()).add(element);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java
new file mode 100644
index 0000000000..e1ca3ea565
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.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 org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when a service interface cannot be determined based on a heuristic evaluation of an implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceTypeNotFoundException extends IntrospectionException {
+ private static final long serialVersionUID = -5124437274726947007L;
+
+ public ServiceTypeNotFoundException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java
new file mode 100644
index 0000000000..bfaa759cd2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+/**
+ * Thrown when a method or field marked with {@link org.oasisopen.sca.annotation.Context} takes an unknown type
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnknownContextTypeException extends IllegalContextException {
+ private static final long serialVersionUID = 8125863714365422419L;
+
+ public UnknownContextTypeException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/package.html b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/package.html
new file mode 100644
index 0000000000..53614a627b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/package.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+Base Package for the implementation.java extension.
+
+Whilst this package and its subpackages are not currently deemed to represent extension developers SPI, this extension has a special relationship with implementation.spring. Implementation.spring can be viewed as an extension of implementation.java.
+
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationConstants.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationConstants.java
new file mode 100644
index 0000000000..c23f5e4d39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationConstants.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 org.apache.tuscany.sca.implementation.java.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants for the Java Implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaImplementationConstants {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String IMPLEMENTATION_JAVA = "implementation.java";
+ QName IMPLEMENTATION_JAVA_QNAME = new QName(SCA11_NS, "implementation.java");
+ String CLASS = "class";
+ String OPERATION = "operation";
+ QName OPERATION_QNAME = new QName(SCA11_NS, OPERATION);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
new file mode 100644
index 0000000000..ebf905ec44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.CLASS;
+import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.IMPLEMENTATION_JAVA;
+import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.IMPLEMENTATION_JAVA_QNAME;
+import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.SCA11_NS;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaImplementation> {
+
+ private JavaImplementationFactory javaFactory;
+ private AssemblyFactory assemblyFactory;
+ private PolicyFactory policyFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private transient InterfaceContractMapper interfaceContractMapper;
+
+ public JavaImplementationProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor<?> staxProcessor) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.javaFactory = modelFactories.getFactory(JavaImplementationFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-javaxml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-javaxml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public JavaImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ // Read an <implementation.java>
+ JavaImplementation javaImplementation = javaFactory.createJavaImplementation();
+
+ ExtensionType implType = policyFactory.createImplementationType();
+ implType.setType(getArtifactType());
+ implType.setUnresolved(true);
+ javaImplementation.setExtensionType(implType);
+
+ javaImplementation.setUnresolved(true);
+ javaImplementation.setName(reader.getAttributeValue(null, CLASS));
+
+ // Read policies
+ policyProcessor.readPolicies(javaImplementation, reader);
+
+ // read operation elements if exists or skip unto end element
+ int event;
+ while (reader.hasNext()) {
+ event = reader.next();
+ if (event == END_ELEMENT && IMPLEMENTATION_JAVA_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+ return javaImplementation;
+ }
+
+ public void write(JavaImplementation javaImplementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ // Write an <implementation.java>
+ writer.writeStartElement(SCA11_NS, IMPLEMENTATION_JAVA);
+ policyProcessor.writePolicyAttributes(javaImplementation, writer);
+
+ if (javaImplementation.getName() != null) {
+ writer.writeAttribute(CLASS, javaImplementation.getName());
+ }
+
+ writer.writeEndElement();
+ }
+
+ public void resolve(JavaImplementation javaImplementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ Monitor monitor = context.getMonitor();
+ try {
+ ClassReference classReference = new ClassReference(javaImplementation.getName());
+ classReference = resolver.resolveModel(ClassReference.class, classReference, context);
+ Class<?> javaClass = classReference.getJavaClass();
+ if (javaClass == null) {
+ error(monitor, "ClassNotFoundException", resolver, javaImplementation.getName());
+ //throw new ContributionResolveException(new ClassNotFoundException(javaImplementation.getName()));
+ return;
+ }
+
+ javaImplementation.setJavaClass(javaClass);
+
+ try {
+ javaFactory.createJavaImplementation(javaImplementation, javaImplementation.getJavaClass());
+ } catch (IntrospectionException e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(monitor, "ContributionResolveException", javaFactory, ce);
+ //throw ce;
+ return;
+ }
+
+ checkNoStaticAnnotations(monitor, javaImplementation);
+
+ postJAXWSProcessorResolve(resolver, javaImplementation, context);
+
+ javaImplementation.setUnresolved(false);
+
+ mergeComponentType(resolver, javaImplementation, context);
+
+ // FIXME the introspector should always create at least one service
+ if (javaImplementation.getServices().isEmpty()) {
+ javaImplementation.getServices().add(assemblyFactory.createService());
+ }
+ } catch (Throwable e) {
+ throw new ContributionResolveException("Resolving Java implementation: " + javaImplementation.getName()
+ + ", "
+ + e.getMessage(), e);
+ } // end try
+ } // end method
+
+ private void checkNoStaticAnnotations(Monitor monitor, JavaImplementation javaImplementation) {
+ if (javaImplementation.getJavaClass() != null) {
+ Class<?> clazz = javaImplementation.getJavaClass();
+ for (Method m : clazz.getMethods()) {
+ if (Modifier.isStatic(m.getModifiers())) {
+ for (Annotation a : m.getAnnotations()) {
+ if (a.annotationType().getName().startsWith("org.oasisopen.sca.annotation")) {
+ error(monitor, "IllegalSCAAnnotation", javaFactory, javaImplementation.getName(), m.getName());
+ }
+ }
+ }
+ }
+ for (Field f : clazz.getFields()) {
+ if (Modifier.isStatic(f.getModifiers())) {
+ for (Annotation a : f.getAnnotations()) {
+ if (a.annotationType().getName().startsWith("org.oasisopen.sca.annotation")) {
+ error(monitor, "IllegalSCAAnnotation", javaFactory, javaImplementation.getName(), f.getName());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private JavaElementImpl getMemeber(JavaImplementation impl, String name, Class<?> type) {
+ String setter = JavaIntrospectionHelper.toSetter(name);
+ try {
+ Method method = impl.getJavaClass().getDeclaredMethod(setter, type);
+ int mod = method.getModifiers();
+ if ((Modifier.isPublic(mod) || Modifier.isProtected(mod)) && (!Modifier.isStatic(mod))) {
+ return new JavaElementImpl(method, 0);
+ }
+ } catch (NoSuchMethodException e) {
+ Field field;
+ try {
+ field = impl.getJavaClass().getDeclaredField(name);
+ int mod = field.getModifiers();
+ if ((Modifier.isPublic(mod) || Modifier.isProtected(mod)) && (!Modifier.isStatic(mod))) {
+ return new JavaElementImpl(field);
+ }
+ } catch (NoSuchFieldException e1) {
+ // Ignore
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Merge the componentType from introspection and external file
+ * @param resolver
+ * @param impl
+ */
+ private void mergeComponentType(ModelResolver resolver, JavaImplementation impl, ProcessorContext context) {
+ // FIXME: Need to clarify how to merge
+ ComponentType componentType = getComponentType(resolver, impl, context);
+ if (componentType != null && !componentType.isUnresolved()) {
+ Map<String, Reference> refMap = new HashMap<String, Reference>();
+ for (Reference ref : impl.getReferences()) {
+ refMap.put(ref.getName(), ref);
+ }
+ for (Reference reference : componentType.getReferences()) {
+ refMap.put(reference.getName(), reference);
+ }
+ impl.getReferences().clear();
+ impl.getReferences().addAll(refMap.values());
+
+ // Try to match references by type
+ Map<String, JavaElementImpl> refMembers = impl.getReferenceMembers();
+ for (Reference ref : impl.getReferences()) {
+ if (ref.getInterfaceContract() != null) {
+ Interface i = ref.getInterfaceContract().getInterface();
+ if (i instanceof JavaInterface) {
+ Class<?> type = ((JavaInterface)i).getJavaClass();
+ if (!refMembers.containsKey(ref.getName())) {
+ JavaElementImpl e = getMemeber(impl, ref.getName(), type);
+ if (e != null) {
+ refMembers.put(ref.getName(), e);
+ }
+ }
+ }
+ }
+ }
+
+ Map<String, Service> serviceMap = new HashMap<String, Service>();
+ for (Service svc : impl.getServices()) {
+ serviceMap.put(svc.getName(), svc);
+ }
+ for (Service service : componentType.getServices()) {
+ serviceMap.put(service.getName(), service);
+ }
+ impl.getServices().clear();
+ impl.getServices().addAll(serviceMap.values());
+
+ Map<String, Property> propMap = new HashMap<String, Property>();
+ for (Property prop : impl.getProperties()) {
+ propMap.put(prop.getName(), prop);
+ }
+ for (Property property : componentType.getProperties()) {
+ propMap.put(property.getName(), property);
+ }
+ impl.getProperties().clear();
+ impl.getProperties().addAll(propMap.values());
+
+ }
+ }
+
+ private void postJAXWSProcessorResolve(ModelResolver resolver, JavaImplementation impl, ProcessorContext context)
+ throws ContributionResolveException, IncompatibleInterfaceContractException {
+ for(Service service : impl.getServices()){
+ JavaInterfaceContract javaInterfaceContract = (JavaInterfaceContract)service.getInterfaceContract();
+
+ JavaInterface javaInterface = (JavaInterface)javaInterfaceContract.getInterface();
+ if (javaInterface.isUnresolved()){
+ extensionProcessor.resolve(javaInterfaceContract, resolver, context);
+ }
+
+ WSDLInterfaceContract wsdlInterfaceContract = (WSDLInterfaceContract)javaInterfaceContract.getNormalizedWSDLContract();
+ if(wsdlInterfaceContract != null){
+ // The user has explicitly associated a WSDL with the Java implementation
+ // using a @WebService(wsdlLocation="...") annotation
+ WSDLInterface wsdlInterface = (WSDLInterface)wsdlInterfaceContract.getInterface();
+ if (wsdlInterface.isUnresolved()){
+ //WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, wsdlInterface.getWsdlDefinition(), context);
+ extensionProcessor.resolve(wsdlInterfaceContract, resolver, context);
+
+ // check that the Java and WSDL contracts are compatible
+ interfaceContractMapper.checkCompatibility(wsdlInterfaceContract,
+ javaInterfaceContract,
+ Compatibility.SUBSET,
+ false,
+ false);
+
+ // retrieve the resolved WSDL interface
+ wsdlInterface = (WSDLInterface)wsdlInterfaceContract.getInterface();
+
+ // copy policy from the WSDL interface to the Java interface
+ javaInterface.getPolicySets().addAll(wsdlInterface.getPolicySets());
+ javaInterface.getRequiredIntents().addAll(wsdlInterface.getRequiredIntents());
+
+ // copy policy from the WSDL interface to the component type service
+ service.getPolicySets().addAll(wsdlInterface.getPolicySets());
+ service.getRequiredIntents().addAll(wsdlInterface.getRequiredIntents());
+
+ // TODO - is there anything else to be copied from the user specified WSDL?
+ }
+ }
+ }
+ }
+
+ private ComponentType getComponentType(ModelResolver resolver, JavaImplementation impl, ProcessorContext context) {
+ String className = impl.getJavaClass().getName();
+ String componentTypeURI = className.replace('.', '/') + ".componentType";
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setUnresolved(true);
+ componentType.setURI(componentTypeURI);
+ componentType = resolver.resolveModel(ComponentType.class, componentType, context);
+ if (!componentType.isUnresolved()) {
+ return componentType;
+ }
+ return null;
+ }
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_JAVA_QNAME;
+ }
+
+ public Class<JavaImplementation> getModelType() {
+ return JavaImplementation.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..2b09ee1d4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.implementation.java.xml.JavaImplementationProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.java,model=org.apache.tuscany.sca.implementation.java.JavaImplementation
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory
new file mode 100644
index 0000000000..5c1a797cf5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory
@@ -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.
+
+org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
new file mode 100644
index 0000000000..d0723f466c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# NOTE: The ranking attribute is important for the JavaClassVistors
+# Some visitors need to be called after the others
+org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor;ranking=2000
+org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByReferenceProcessor;ranking=1900
+org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor;ranking=1800
+org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor;ranking=1700
+org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor;ranking=1600
+org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor;ranking=1500
+org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor;ranking=1400
+org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor;ranking=1300
+org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor;ranking=1200
+org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor;ranking=1100
+org.apache.tuscany.sca.implementation.java.introspect.impl.ScopeProcessor;ranking=1000
+org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor;ranking=900
+org.apache.tuscany.sca.implementation.java.introspect.impl.JAXWSProcessor;ranking=850
+org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor;ranking=800
+org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor;ranking=700 \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties
new file mode 100644
index 0000000000..4976bc0e9f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+ClassNotFoundException = Class Not Found Exception: {0}
+ContributionResolveException = Contribution Resolve Exception occured due to:
+IllegalSCAAnnotation = [JCA9002] SCA annotations are not permitted on static members: {0}.{1}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/AddService.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/AddService.java
new file mode 100644
index 0000000000..9c22177684
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/AddService.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 calculator;
+
+/**
+ * Interface for the Add Service.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..64298b6275
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/AddServiceImpl.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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * An implementation of the Add service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..e0cf23dc17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/CalculatorService.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 calculator;
+
+/**
+ * The Calculator service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..9f64dc8bca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/CalculatorServiceImpl.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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * An implementation of the Calculator service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/DivideService.java
new file mode 100644
index 0000000000..9599c86292
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/DivideService.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 calculator;
+
+/**
+ * Interface for the Divide Service.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..f5b8ff5be0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/DivideServiceImpl.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 calculator;
+
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * An implementation of the Divide service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..7a3d06c15e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * Interface for the Multiply Service.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..d146d23153
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * An implementation of the Multiply service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..21af91f392
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/SubtractService.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 calculator;
+
+/**
+ * Interface for the Subtract Service.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..ffe09c3dde
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/calculator/SubtractServiceImpl.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 calculator;
+
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * An implementation of the subtract service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
new file mode 100644
index 0000000000..b77aea4c78
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+
+/**
+ * Base class to simulate the processor sequences
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractProcessorTest {
+ protected AssemblyFactory factory;
+ protected JavaInterfaceFactory javaFactory;
+ protected ConstructorProcessor constructorProcessor;
+ protected ReferenceProcessor referenceProcessor;
+ protected PropertyProcessor propertyProcessor;
+ private ResourceProcessor resourceProcessor;
+
+
+ protected AbstractProcessorTest() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ factory = new DefaultAssemblyFactory(registry);
+ javaFactory = new DefaultJavaInterfaceFactory(registry);
+ referenceProcessor = new ReferenceProcessor(factory, javaFactory);
+ propertyProcessor = new PropertyProcessor(registry);
+ resourceProcessor = new ResourceProcessor(factory);
+ constructorProcessor = new ConstructorProcessor(factory);
+ referenceProcessor = new ReferenceProcessor(factory, javaFactory);
+ propertyProcessor = new PropertyProcessor(registry);
+ }
+
+ protected <T> void visitConstructor(Constructor<T> constructor,
+ JavaImplementation type) throws IntrospectionException {
+ constructorProcessor.visitConstructor(constructor, type);
+ JavaConstructorImpl<?> definition = type.getConstructor();
+ if (definition == null) {
+ definition = new JavaConstructorImpl<T>(constructor);
+ type.getConstructors().put(constructor, definition);
+ }
+
+ JavaParameterImpl[] parameters = definition.getParameters();
+ for (int i = 0; i < parameters.length; i++) {
+ referenceProcessor.visitConstructorParameter(parameters[i], type);
+ propertyProcessor.visitConstructorParameter(parameters[i], type);
+ resourceProcessor.visitConstructorParameter(parameters[i], type);
+ // monitorProcessor.visitConstructorParameter(parameters[i], type);
+ }
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java
new file mode 100644
index 0000000000..ce79ae2045
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.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.sca.implementation.java.introspect.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AllowsPassByReferenceProcessorTestCase {
+
+ JavaImplementation type;
+ AllowsPassByReferenceProcessor processor;
+ private JavaImplementationFactory javaImplementationFactory;
+
+ @Test
+ public void testClassAnnotation() throws Exception {
+ processor.visitClass(Foo.class, type);
+ assertEquals(true, type.isAllowsPassByReference());
+
+ processor.visitClass(Bar.class, type);
+ assertEquals(false, type.isAllowsPassByReference());
+
+ Method m1 = Bar.class.getMethod("m1", new Class[] {});
+ processor.visitMethod(m1, type);
+ assertTrue(type.isAllowsPassByReference(m1));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ type = javaImplementationFactory.createJavaImplementation();
+ processor = new AllowsPassByReferenceProcessor(new DefaultAssemblyFactory());
+ }
+
+ @AllowsPassByReference
+ private class Foo {
+ }
+
+ // no annotation
+ private class Bar {
+ @AllowsPassByReference
+ public void m1() {
+
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
new file mode 100644
index 0000000000..512e34a0fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty;
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getReference;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorProcessorTestCase {
+ private ConstructorProcessor processor = new ConstructorProcessor(new DefaultAssemblyFactory());
+
+ private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+ @Test
+ public void testDuplicateConstructor() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ processor.visitClass(BadFoo.class, type);
+ fail();
+ } catch (DuplicateConstructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testConstructorAnnotation() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor1 = Foo.class.getConstructor(String.class);
+ processor.visitConstructor(ctor1, type);
+ assertEquals("foo", type.getConstructor().getParameters()[0].getName());
+ }
+
+ @Test
+ public void testNoAnnotation() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<NoAnnotation> ctor1 = NoAnnotation.class.getConstructor();
+ processor.visitConstructor(ctor1, type);
+ assertNull(type.getConstructor());
+ }
+
+ @Test
+ public void testBadAnnotation() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadAnnotation> ctor1 = BadAnnotation.class.getConstructor(String.class, Foo.class);
+ try {
+ processor.visitConstructor(ctor1, type);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testMixedParameters() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Mixed> ctor1 = Mixed.class.getConstructor(String.class, String.class, String.class);
+ processor.visitConstructor(ctor1, type);
+
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ AssemblyFactory assemblyFactory = new DefaultAssemblyFactory(registry);
+ JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory(registry);
+ ReferenceProcessor referenceProcessor = new ReferenceProcessor(assemblyFactory, javaFactory);
+ PropertyProcessor propertyProcessor = new PropertyProcessor(registry);
+ JavaParameterImpl[] parameters = type.getConstructor().getParameters();
+ for (int i = 0; i < parameters.length; i++) {
+ referenceProcessor.visitConstructorParameter(parameters[i], type);
+ propertyProcessor.visitConstructorParameter(parameters[i], type);
+ }
+
+ assertEquals("_ref0", parameters[0].getName());
+ assertEquals("foo", parameters[1].getName());
+ assertEquals("bar", parameters[2].getName());
+ }
+
+ private static class BadFoo {
+
+ @org.oasisopen.sca.annotation.Constructor("foo")
+ public BadFoo(String foo) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor( {"foo", "bar"})
+ public BadFoo(String foo, String bar) {
+
+ }
+ }
+
+ private static class Foo {
+ @org.oasisopen.sca.annotation.Constructor("foo")
+ public Foo(@Property String foo) {
+
+ }
+ }
+
+ private static class NoAnnotation {
+ public NoAnnotation() {
+ }
+ }
+
+ private static class BadAnnotation {
+ @org.oasisopen.sca.annotation.Constructor("foo")
+ public BadAnnotation(String foo, Foo ref) {
+ }
+ }
+
+ public static final class Mixed {
+ @org.oasisopen.sca.annotation.Constructor
+ public Mixed(@Reference(name="_ref0")
+ String param1, @Property(name = "foo")
+ String param2, @Reference(name = "bar")
+ String param3) {
+ }
+ }
+
+ public static final class Multiple {
+ @org.oasisopen.sca.annotation.Constructor
+ public Multiple(@Reference(name="_ref0")
+ Collection<String> param1, @Property(name = "foo")
+ String[] param2, @Reference(name = "bar", required = true)
+ List<String> param3, @Property(name = "abc")
+ Set<String> param4, @Reference(name = "xyz")
+ String[] param5) {
+ }
+ }
+
+ @Test
+ public void testMultiplicity() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Multiple> ctor1 = Multiple.class.getConstructor(Collection.class,
+ String[].class,
+ List.class,
+ Set.class,
+ String[].class);
+ processor.visitConstructor(ctor1, type);
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
+ JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory(registry);
+ ReferenceProcessor referenceProcessor = new ReferenceProcessor(assemblyFactory, javaFactory);
+ PropertyProcessor propertyProcessor = new PropertyProcessor(registry);
+ JavaParameterImpl[] parameters = type.getConstructor().getParameters();
+ for (int i = 0; i < parameters.length; i++) {
+ referenceProcessor.visitConstructorParameter(parameters[i], type);
+ propertyProcessor.visitConstructorParameter(parameters[i], type);
+ }
+
+ org.apache.tuscany.sca.assembly.Reference ref0 = getReference(type, "_ref0");
+ assertNotNull(ref0);
+ assertEquals(Multiplicity.ONE_N, ref0.getMultiplicity());
+ org.apache.tuscany.sca.assembly.Reference ref1 = getReference(type, "bar");
+ assertNotNull(ref1);
+ assertEquals(Multiplicity.ONE_N, ref1.getMultiplicity());
+ org.apache.tuscany.sca.assembly.Reference ref2 = getReference(type, "xyz");
+ assertNotNull(ref2);
+ assertEquals(Multiplicity.ONE_N, ref2.getMultiplicity());
+ org.apache.tuscany.sca.assembly.Property prop1 = getProperty(type, "foo");
+ assertNotNull(prop1);
+ assertTrue(prop1.isMany());
+ org.apache.tuscany.sca.assembly.Property prop2 = getProperty(type, "abc");
+ assertNotNull(prop2);
+ assertTrue(prop2.isMany());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java
new file mode 100644
index 0000000000..83e26dff84
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Property;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorPropertyTestCase extends AbstractProcessorTest {
+
+ private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+ @Test
+ public void testProperty() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+ visitConstructor(ctor, type);
+ org.apache.tuscany.sca.assembly.Property property = getProperty(type, "myProp");
+ assertTrue(property.isMustSupply());
+ assertEquals("myProp", property.getName());
+ }
+
+ @Test
+ public void testTwoPropertiesSameType() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+ visitConstructor(ctor, type);
+ assertNotNull(getProperty(type, "myProp1"));
+ assertNotNull(getProperty(type, "myProp2"));
+ }
+
+ @Test
+ public void testDuplicateProperty() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNoName() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNamesOnConstructor() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
+ visitConstructor(ctor, type);
+ assertNotNull(getProperty(type, "myProp"));
+ }
+
+ @Test
+ public void testInvalidNumberOfNames() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNoMatchingNames() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+// public void testMultiplicityRequired() throws Exception {
+ // TODO multiplicity
+// }
+
+
+
+ private static class Foo {
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public Foo(@Property(name = "myProp", required = true)String prop) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor("myProp")
+ public Foo(@Property Integer prop) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public Foo(@Property(name = "myProp1")String prop1, @Property(name = "myProp2")String prop2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public Foo(@Property List prop) {
+
+ }
+ }
+
+ private static class BadFoo {
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public BadFoo(@Property(name = "myProp")String prop1, @Property(name = "myProp")String prop2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public BadFoo(@Property String prop) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor("myProp")
+ public BadFoo(@Property Integer prop, @Property Integer prop2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor({"myRef", "myRef2"})
+ public BadFoo(@Property List ref, @Property(name = "myOtherRef")List ref2) {
+
+ }
+
+ }
+
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java
new file mode 100644
index 0000000000..eeeee851e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getReference;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+//import com.sun.xml.internal.ws.model.JavaMethodImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorReferenceTestCase extends AbstractProcessorTest {
+
+ private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+ @Test
+ public void testReference() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+ visitConstructor(ctor, type);
+ org.apache.tuscany.sca.assembly.Reference reference = getReference(type, "myRef");
+ assertEquals(Multiplicity.ONE_ONE, reference.getMultiplicity());
+ assertEquals("myRef", reference.getName());
+ }
+
+ @Test
+ public void testTwoReferencesSameType() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+ visitConstructor(ctor, type);
+ assertNotNull(getReference(type, "myRef1"));
+ assertNotNull(getReference(type, "myRef2"));
+ }
+
+ @Test
+ public void testDuplicateProperty() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (DuplicateReferenceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNoName() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<NoNameFoo> ctor = NoNameFoo.class.getConstructor(String.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidReferenceException e) {
+ //expected
+ }
+ }
+
+ @Test
+ public void testNamesOnConstructor() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
+ visitConstructor(ctor, type);
+ assertNotNull(getReference(type, "myRef2"));
+ }
+
+ @Test
+ public void testInvalidNumberOfNames() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNoMatchingNames() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidReferenceException e) {
+ // expected
+ }
+ }
+
+
+// public void testMultiplicityRequired() throws Exception {
+ // TODO multiplicity
+// }
+
+ private static class Foo {
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public Foo(@Reference(name = "myRef", required = true)String prop) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public Foo(@Reference(name = "myRef1")String prop1, @Reference(name = "myRef2")String prop2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor("myRef2")
+ public Foo(@Reference(name = "myRef2") Integer prop) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public Foo(@Reference(name = "myRef3") List prop) {
+
+ }
+ }
+
+ private static class NoNameFoo {
+
+ @org.oasisopen.sca.annotation.Constructor
+ public NoNameFoo(@Reference String prop) {
+
+ }
+ }
+
+ private static class BadFoo {
+
+ @org.oasisopen.sca.annotation.Constructor
+ public BadFoo(@Reference(name = "myRef")String prop1, @Reference(name = "myRef")String prop2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor
+ public BadFoo(@Reference String prop) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor("myRef")
+ public BadFoo(@Reference Integer ref, @Reference Integer ref2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor({"myRef", "myRef2"})
+ public BadFoo(@Reference List ref, @Reference(name = "myOtherRef")List ref2) {
+
+ }
+
+ }
+
+
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java
new file mode 100644
index 0000000000..e8d26f6103
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorResourceTestCase extends AbstractProcessorTest {
+
+ private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+ @Test
+ public void testResource() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+ visitConstructor(ctor, type);
+ org.apache.tuscany.sca.implementation.java.JavaResourceImpl resource = type.getResources().get("myResource");
+ assertFalse(resource.isOptional());
+ }
+
+ @Test
+ public void testTwoResourcesSameType() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+ visitConstructor(ctor, type);
+ assertNotNull(type.getResources().get("myResource1"));
+ assertNotNull(type.getResources().get("myResource2"));
+ }
+
+ @Test
+ public void testDuplicateResource() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (DuplicateResourceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNoName() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<ConstructorResourceTestCase.BadFoo> ctor =
+ ConstructorResourceTestCase.BadFoo.class.getConstructor(String.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidResourceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNamesOnConstructor() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
+ visitConstructor(ctor, type);
+ assertNotNull(type.getResources().get("myResource"));
+ }
+
+ @Test
+ public void testInvalidNumberOfNames() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<ConstructorResourceTestCase.BadFoo> ctor =
+ ConstructorResourceTestCase.BadFoo.class.getConstructor(Integer.class, Integer.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNoMatchingNames() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<ConstructorResourceTestCase.BadFoo> ctor =
+ ConstructorResourceTestCase.BadFoo.class.getConstructor(List.class, List.class);
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+ private static class Foo {
+
+ @org.oasisopen.sca.annotation.Constructor
+ public Foo(@Resource(name = "myResource") String resource) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor("myResource")
+ public Foo(@Resource Integer resource) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor
+ public Foo(@Resource(name = "myResource1") String res1, @Resource(name = "myResource2") String res2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor
+ public Foo(@Resource List res) {
+
+ }
+ }
+
+ private static class BadFoo {
+
+ @org.oasisopen.sca.annotation.Constructor
+ public BadFoo(@Resource(name = "myResource") String res1, @Resource(name = "myResource") String res2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor
+ public BadFoo(@Resource String res) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor("myProp")
+ public BadFoo(@Resource Integer res, @Resource Integer res2) {
+
+ }
+
+ @org.oasisopen.sca.annotation.Constructor({"myRes", "myRes2"})
+ public BadFoo(@Resource List res, @Resource(name = "myOtherRes") List res2) {
+
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java
new file mode 100644
index 0000000000..124c83e9e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.annotation.ComponentName;
+import org.oasisopen.sca.annotation.Context;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ContextProcessorTestCase {
+ private ContextProcessor processor;
+ private ComponentNameProcessor nameProcessor;
+ private JavaImplementationFactory javaImplementationFactory;
+
+ @Test
+ public void testComponentContextMethod() throws Exception {
+ Method method = Foo.class.getMethod("setContext", ComponentContext.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitMethod(method, type);
+ assertNotNull(type.getResources().get("context"));
+ }
+
+ @Test
+ public void testComponentContextField() throws Exception {
+ Field field = Foo.class.getDeclaredField("context");
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitField(field, type);
+ assertNotNull(type.getResources().get("context"));
+ }
+
+ @Test
+ public void testRequestContextMethod() throws Exception {
+ Method method = Foo.class.getMethod("setRequestContext", RequestContext.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitMethod(method, type);
+ assertNotNull(type.getResources().get("requestContext"));
+ }
+
+ @Test
+ public void testRequestContextField() throws Exception {
+ Field field = Foo.class.getDeclaredField("requestContext");
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitField(field, type);
+ assertNotNull(type.getResources().get("requestContext"));
+ }
+
+ @Test
+ public void testComponentNameMethod() throws Exception {
+ Method method = Foo.class.getMethod("setName", String.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ nameProcessor.visitMethod(method, type);
+ assertNotNull(type.getResources().get("name"));
+ }
+
+ @Test
+ public void testComponentNameField() throws Exception {
+ Field field = Foo.class.getDeclaredField("name");
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ nameProcessor.visitField(field, type);
+ assertNotNull(type.getResources().get("name"));
+ }
+
+ @Test
+ public void testInvalidParamType() throws Exception {
+ Method method = Foo.class.getMethod("setContext", String.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (UnknownContextTypeException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testInvalidParamTypeField() throws Exception {
+ Field field = Foo.class.getDeclaredField("badContext");
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ processor.visitField(field, type);
+ fail();
+ } catch (UnknownContextTypeException e) {
+ // expected
+ }
+ }
+
+
+ @Test
+ public void testInvalidParamNum() throws Exception {
+ Method method = Foo.class.getMethod("setContext", ComponentContext.class, String.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalContextException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testInvalidNoParams() throws Exception {
+ Method method = Foo.class.getMethod("setContext");
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalContextException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNoContext() throws Exception {
+ Method method = Foo.class.getMethod("noContext", ComponentContext.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitMethod(method, type);
+ assertEquals(0, type.getResources().size());
+ }
+
+ @Test
+ public void testNoContextField() throws Exception {
+ Field field = Foo.class.getDeclaredField("noContext");
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitField(field, type);
+ assertEquals(0, type.getResources().size());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ processor = new ContextProcessor(new DefaultAssemblyFactory());
+ nameProcessor = new ComponentNameProcessor(new DefaultAssemblyFactory());
+ }
+
+ private class Foo {
+ @Context
+ protected ComponentContext context;
+
+ @ComponentName
+ protected String name;
+
+ @Context
+ protected Object badContext;
+
+ protected ComponentContext noContext;
+
+ @Context
+ protected RequestContext requestContext;
+
+ @Context
+ public void setContext(ComponentContext context) {
+
+ }
+
+ @ComponentName
+ public void setName(String name) {
+
+ }
+
+ @Context
+ public void setContext(String context) {
+
+ }
+
+ @Context
+ public void setContext(ComponentContext context, String string) {
+
+ }
+
+ @Context
+ public void setContext() {
+
+ }
+
+ public void noContext(ComponentContext context) {
+
+ }
+
+ @Context
+ public void setRequestContext(RequestContext requestContext) {
+ this.requestContext = requestContext;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
new file mode 100644
index 0000000000..b524803062
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Destroy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DestroyProcessorTestCase {
+
+ private AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
+ private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+ @Test
+ public void testDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = Foo.class.getMethod("destroy");
+ processor.visitMethod(method, type);
+ assertNotNull(type.getDestroyMethod());
+ }
+
+ @Test
+ public void testBadDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = Bar.class.getMethod("badDestroy", String.class);
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalDestructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testTwoDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = Bar.class.getMethod("destroy");
+ Method method2 = Bar.class.getMethod("destroy2");
+ processor.visitMethod(method, type);
+ try {
+ processor.visitMethod(method2, type);
+ fail();
+ } catch (DuplicateDestructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testProtectedDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = Bar.class.getDeclaredMethod("protectedDestroy");
+ try {
+ processor.visitMethod(method, type);
+ } catch (IllegalDestructorException e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void testPrivateDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = Bar.class.getDeclaredMethod("privateDestroy");
+ try {
+ processor.visitMethod(method, type);
+ } catch (IllegalDestructorException e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void testDefaultVisibilityDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = Bar.class.getDeclaredMethod("defaultVisibilityDestroy");
+ try {
+ processor.visitMethod(method, type);
+ } catch (IllegalDestructorException e) {
+ fail();
+ }
+ }
+
+ private class Foo {
+
+ @Destroy
+ public void destroy() {
+ }
+ }
+
+
+ private class Bar {
+
+ @Destroy
+ public void destroy() {
+ }
+
+ @Destroy
+ public void destroy2() {
+ }
+
+ @Destroy
+ public void badDestroy(String foo) {
+ }
+
+ @Destroy
+ protected void protectedDestroy(){
+ }
+
+ @Destroy
+ private void privateDestroy(){
+ }
+
+ @Destroy
+ void defaultVisibilityDestroy(){
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java
new file mode 100644
index 0000000000..04d87f60fe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.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.java.introspect.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.EagerInit;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EagerInitProcessorTestCase {
+
+ private AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
+ private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+ @Test
+ public void testNoLevel() throws IntrospectionException {
+ EagerInitProcessor processor = new EagerInitProcessor(assemblyFactory);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(Level.class, type);
+ }
+
+ @Test
+ public void testSubclass() throws IntrospectionException {
+ EagerInitProcessor processor = new EagerInitProcessor(assemblyFactory);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(SubClass.class, type);
+ }
+
+ @EagerInit
+ private class Level {
+ }
+
+ private class SubClass extends Level {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java
new file mode 100644
index 0000000000..39a2980b2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Property;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HeuristicAndPropertyTestCase {
+
+ private PropertyProcessor propertyProcessor;
+ private HeuristicPojoProcessor heuristicProcessor;
+ private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+ /**
+ * Verifies the property and heuristic processors don't collide
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testPropertyProcessorWithHeuristicProcessor() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor ctor = Foo.class.getConstructor(String.class);
+ type.setConstructor(new JavaConstructorImpl(ctor));
+ propertyProcessor.visitConstructorParameter(type.getConstructor().getParameters()[0], type);
+ heuristicProcessor.visitEnd(Foo.class, type);
+ assertEquals(1, type.getProperties().size());
+ assertEquals("foo", type.getProperties().get(0).getName());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ propertyProcessor = new PropertyProcessor(registry);
+ heuristicProcessor = new HeuristicPojoProcessor(registry);
+ }
+
+ public static class Foo {
+ public Foo(@Property(name = "foo")
+ String prop) {
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java
new file mode 100644
index 0000000000..394857576d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java
@@ -0,0 +1,330 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HeuristicConstructorTestCase extends AbstractProcessorTest {
+
+ private AssemblyFactory factory;
+ private JavaInterfaceFactory javaFactory;
+ private HeuristicPojoProcessor processor;
+ private JavaImplementationFactory javaImplementationFactory;
+
+ public HeuristicConstructorTestCase() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ factory = new DefaultAssemblyFactory(registry);
+ javaFactory = new DefaultJavaInterfaceFactory(registry);
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ processor = new HeuristicPojoProcessor(factory, javaFactory);
+ }
+
+ private <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ for (Constructor<?> constructor : clazz.getConstructors()) {
+ visitConstructor(constructor, type);
+ }
+ processor.visitEnd(clazz, type);
+ }
+
+ /**
+ * Verifies a single constructor is chosen with a parameter as the type
+ */
+ @Test
+ public void testSingleConstructorWithParam() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ org.apache.tuscany.sca.assembly.Property prop = factory.createProperty();
+ prop.setName("foo");
+ type.getProperties().add(prop);
+ // Hack to add a property member
+ JavaElementImpl element = new JavaElementImpl("foo", String.class, null);
+ type.getPropertyMembers().put("foo", element);
+ visitEnd(Foo1.class, type);
+ assertNotNull(type.getConstructor().getConstructor());
+ assertEquals("foo", type.getConstructor().getParameters()[0].getName());
+ }
+
+ /**
+ * Verifies a single constructor is chosen with a reference as the type
+ */
+ @Test
+ public void testSingleConstructorWithRef() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ org.apache.tuscany.sca.assembly.Reference ref = factory.createReference();
+ ref.setName("foo");
+ type.getReferences().add(ref);
+ type.getReferenceMembers().put("foo", new JavaElementImpl("foo", String.class, null));
+ visitEnd(Foo1.class, type);
+ assertNotNull(type.getConstructor().getConstructor());
+ assertEquals("foo", type.getConstructor().getParameters()[0].getName());
+ }
+
+ /**
+ * Verifies a single constructor is chosen with a property and a reference
+ * as the type
+ */
+ @Test
+ public void testSingleConstructorWithPropRef() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+
+ org.apache.tuscany.sca.assembly.Property prop = factory.createProperty();
+ prop.setName("foo");
+ type.getProperties().add(prop);
+ // Hack to add a property member
+ JavaElementImpl element = new JavaElementImpl("foo", String.class, null);
+ type.getPropertyMembers().put("foo", element);
+
+ org.apache.tuscany.sca.assembly.Reference ref = ModelHelper.createReference(factory, javaFactory, "ref", Foo1.class);
+ type.getReferences().add(ref);
+ type.getReferenceMembers().put("ref", new JavaElementImpl("ref", Foo1.class, null));
+ visitEnd(Foo2.class, type);
+ assertNotNull(type.getConstructor().getConstructor());
+ assertEquals(2, type.getConstructor().getParameters().length);
+ }
+
+ @Test
+ public void testSingleConstructorResolvableParam() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(Foo5.class, type);
+ assertEquals(String.class, type.getPropertyMembers().get("string").getType());
+ }
+
+ @Test
+ public void testSingleConstructorResolvableRef() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(Foo6.class, type);
+ assertTrue(ModelHelper.matches(ModelHelper.getReference(type, "ref"), Ref.class));
+ }
+
+ @Test
+ public void testSingleConstructorAmbiguousRef() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ org.apache.tuscany.sca.assembly.Reference ref = ModelHelper.createReference(factory, javaFactory, "ref", Foo1.class);
+ type.getReferences().add(ref);
+ type.getReferenceMembers().put("ref", new JavaElementImpl("ref", Foo1.class, null));
+ org.apache.tuscany.sca.assembly.Reference ref2 = ModelHelper.createReference(factory, javaFactory, "ref2", Foo1.class);
+ type.getReferences().add(ref2);
+ type.getReferenceMembers().put("ref2", new JavaElementImpl("ref2", Foo1.class, null));
+ try {
+ visitEnd(Foo4.class, type);
+ fail();
+ } catch (AmbiguousConstructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testConstructorPropertyAnnotatedParamsOnly() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(Foo7.class, type);
+ assertNotNull(getProperty(type, "myProp"));
+ }
+
+ @Test
+ public void testConstructorReferenceAnnotatedParamsOnly() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(Foo8.class, type);
+ assertNotNull(ModelHelper.getReference(type, "myRef"));
+ }
+
+ @Test
+ public void testDefaultConstructor() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(Foo3.class, type);
+ assertNotNull(type.getConstructor().getConstructor());
+ }
+
+ @Test
+ public void testSameTypesButAnnotated() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(Foo12.class, type);
+ assertEquals(2, type.getProperties().size());
+ assertNotNull(getProperty(type, "prop1"));
+ assertNotNull(getProperty(type, "prop2"));
+ }
+
+ /**
+ * Verifies processing executes with additional extension annotations
+ */
+ @Test
+ public void testRandomAnnotation() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(Foo11.class, type);
+ assertEquals(1, type.getProperties().size());
+ assertNotNull(getProperty(type, "prop1"));
+ }
+
+ @Test
+ public void testPrivateConstructor() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ visitEnd(Foo14.class, type);
+ fail();
+ } catch (NoConstructorException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testMultipleConstructors() throws Exception {
+ // throw new UnsupportedOperationException("Finish heuristic multiple
+ // constructors - Foo10");
+ }
+
+ public static class Foo1 {
+ public Foo1(String val) {
+ }
+ }
+
+ public static class Foo2 {
+ public Foo2(String val, Foo1 ref) {
+ }
+ }
+
+ public static class Foo3 {
+ }
+
+ public static class Foo4 {
+ public Foo4(Foo1 ref) {
+ }
+ }
+
+ public static class Prop {
+
+ }
+
+ @Remotable
+ public static interface Ref {
+
+ }
+
+ public static class Foo5 {
+ public Foo5(String val) {
+ }
+ }
+
+ public static class Foo6 {
+ public Foo6(Ref ref) {
+ }
+ }
+
+ public static class Foo7 {
+ public Foo7(@Property(name = "myProp")
+ String prop) {
+ }
+ }
+
+ public static class Foo8 {
+ public Foo8(@Reference(name = "myRef")
+ String ref) {
+ }
+ }
+
+ public static class Foo9 {
+ public Foo9(@Reference(name = "myRef")
+ String ref) {
+ }
+ }
+
+ public static class Foo10 {
+
+ public Foo10() {
+ }
+
+ public Foo10(String prop) {
+ }
+
+ public Foo10(@Property(name = "prop1")
+ String prop1, @Property(name = "prop2")
+ String prop2) {
+
+ }
+ }
+
+ public static class Foo11 {
+
+ public Foo11(@Property(name = "prop1")
+ String prop, @Baz
+ String baz) {
+ }
+ }
+
+ public static class Foo12 {
+
+ public Foo12(@Property(name = "prop1")
+ String prop, @Property(name = "prop2")
+ String baz) {
+ }
+ }
+
+ public @interface Baz {
+
+ }
+
+ public static class Foo13 {
+ public Foo13(@Reference
+ String foo) {
+ }
+ }
+
+ public static final class Foo14 {
+ private Foo14() {
+ }
+ }
+
+ public static final class Foo15 {
+ public Foo15(@Reference
+ String param1, @Reference
+ String param2) {
+ }
+ }
+
+ public static final class Foo16 {
+ public Foo16(@Reference
+ String param1, @Property(name = "foo")
+ String param2, @Reference(name = "bar")
+ String param3) {
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java
new file mode 100644
index 0000000000..a850f86995
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java
@@ -0,0 +1,581 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.List;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Remotable;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Verifies component type information is properly introspected from an unadorned
+ * POJO according to the SCA Java Client and Implementation Model Specification
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest {
+
+ private org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor processor;
+ private JavaImplementationFactory javaImplementationFactory;
+
+ public HeuristicPojoProcessorTestCase() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ processor = new HeuristicPojoProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory(registry));
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ }
+
+ private <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ for (Constructor<?> constructor : clazz.getConstructors()) {
+ visitConstructor(constructor, type);
+ }
+ processor.visitEnd(clazz, type);
+ }
+
+ /**
+ * Verifies a single service interface is computed when only one interface
+ * is implemented
+ */
+ @Test
+ public void testSingleInterface() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<SingleInterfaceImpl> ctor = SingleInterfaceImpl.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<SingleInterfaceImpl>(ctor));
+ processor.visitEnd(SingleInterfaceImpl.class, type);
+ assertEquals(1, type.getServices().size());
+ assertTrue(ModelHelper.matches(ModelHelper.getService(type, PropertyInterface.class.getSimpleName()),
+ PropertyInterface.class));
+ assertTrue(type.getProperties().isEmpty());
+ assertTrue(type.getReferences().isEmpty());
+ }
+
+ /**
+ * Verifies property and reference setters are computed
+ */
+ @Test
+ public void testPropertyReference() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<SingleInterfaceWithPropertyReferenceImpl> ctor = SingleInterfaceWithPropertyReferenceImpl.class
+ .getConstructor();
+ type.setConstructor(new JavaConstructorImpl<SingleInterfaceWithPropertyReferenceImpl>(ctor));
+ processor.visitEnd(SingleInterfaceWithPropertyReferenceImpl.class, type);
+ assertEquals(1, type.getServices().size());
+ assertTrue(ModelHelper
+ .matches(ModelHelper.getService(type, Interface1.class.getSimpleName()), Interface1.class));
+ assertEquals(1, type.getProperties().size());
+ org.apache.tuscany.sca.assembly.Property prop = ModelHelper.getProperty(type, "property");
+ assertNotNull(prop);
+ assertEquals(ComplexProperty.class, type.getPropertyMembers().get("property").getType());
+ assertEquals(1, type.getReferences().size());
+ assertTrue(ModelHelper.matches(ModelHelper.getReference(type, "reference"), Ref.class));
+ }
+
+ /**
+ * Verifies that a property setter is not introspected if an analogous
+ * operation is in the service interface
+ */
+ @Test
+ public void testPropertySetterInInterface() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<SingleInterfaceImpl> ctor = SingleInterfaceImpl.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<SingleInterfaceImpl>(ctor));
+ processor.visitEnd(SingleInterfaceImpl.class, type);
+ assertEquals(0, type.getProperties().size());
+ }
+
+ /**
+ * Verifies that a reference setter is not introspected if an analogous
+ * operation is in the service interface
+ */
+ @Test
+ public void testReferenceSetterInInterface() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<RefInterfaceImpl> ctor = RefInterfaceImpl.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<RefInterfaceImpl>(ctor));
+ processor.visitEnd(RefInterfaceImpl.class, type);
+ assertEquals(0, type.getReferences().size());
+ }
+
+ /**
+ * Verifies collection generic types or array types are introspected as
+ * references according to specification rules
+ */
+ @Test
+ public void testReferenceCollectionType() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<ReferenceCollectionImpl> ctor = ReferenceCollectionImpl.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<ReferenceCollectionImpl>(ctor));
+ processor.visitEnd(ReferenceCollectionImpl.class, type);
+ assertEquals(1, type.getProperties().size());
+ assertEquals(3, type.getReferences().size());
+ }
+
+ /**
+ * Verifies collection generic types or array types are introspected as
+ * properties according to specification rules
+ */
+ @Test
+ public void testPropertyCollectionType() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<PropertyCollectionImpl> ctor = PropertyCollectionImpl.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<PropertyCollectionImpl>(ctor));
+ processor.visitEnd(PropertyCollectionImpl.class, type);
+ assertEquals(0, type.getReferences().size());
+ assertEquals(4, type.getProperties().size());
+ }
+
+ /**
+ * Verifies references are calculated when the type marked with is
+ *
+ * @Remotable
+ */
+ @Test
+ public void testRemotableRef() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<RemotableRefImpl> ctor = RemotableRefImpl.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<RemotableRefImpl>(ctor));
+ processor.visitEnd(RemotableRefImpl.class, type);
+ assertEquals(2, type.getReferences().size());
+ assertEquals(0, type.getProperties().size());
+ }
+
+ @Test
+ public void testParentInterface() throws IntrospectionException, NoSuchMethodException {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Child> ctor = Child.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<Child>(ctor));
+ processor.visitEnd(Child.class, type);
+ assertNotNull(ModelHelper.getService(type, Interface1.class.getSimpleName()));
+ }
+
+ /**
+ * Verifies a service interface is calculated when only props and refs are
+ * given
+ */
+ @Test
+ public void testExcludedPropertyAndReference() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ org.apache.tuscany.sca.assembly.Reference ref = factory.createReference();
+ ref.setName("reference");
+ type.getReferences().add(ref);
+ type.getReferenceMembers().put("reference", new JavaElementImpl("reference", Ref.class, null));
+ org.apache.tuscany.sca.assembly.Reference ref2 = factory.createReference();
+ ref2.setName("reference2");
+ type.getReferences().add(ref2);
+ type.getReferenceMembers().put("reference2", new JavaElementImpl("reference2", Ref.class, null));
+ org.apache.tuscany.sca.assembly.Property prop1 = factory.createProperty();
+ prop1.setName("string1");
+ type.getProperties().add(prop1);
+ type.getPropertyMembers().put("string1", new JavaElementImpl("string1", String.class, null));
+ org.apache.tuscany.sca.assembly.Property prop2 = factory.createProperty();
+ prop2.setName("string2");
+ type.getProperties().add(prop2);
+ type.getPropertyMembers().put("string2", new JavaElementImpl("string2", String.class, null));
+ visitEnd(MockService.class, type);
+ assertEquals(1, type.getServices().size());
+ }
+
+ @Test
+ public void testProtectedRemotableRefField() throws IntrospectionException, NoSuchMethodException {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<ProtectedRemotableRefFieldImpl> ctor = ProtectedRemotableRefFieldImpl.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<ProtectedRemotableRefFieldImpl>(ctor));
+ processor.visitEnd(ProtectedRemotableRefFieldImpl.class, type);
+ assertNotNull(ModelHelper.getReference(type, "otherRef"));
+ }
+
+ @Test
+ public void testProtectedRemotableRefMethod() throws IntrospectionException, NoSuchMethodException {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<ProtectedRemotableRefMethodImpl> ctor = ProtectedRemotableRefMethodImpl.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<ProtectedRemotableRefMethodImpl>(ctor));
+ processor.visitEnd(ProtectedRemotableRefMethodImpl.class, type);
+ assertNotNull(ModelHelper.getReference(type, "otherRef"));
+ }
+
+ @Test
+ public void testSetDataTypes() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<PropertyIntTypeOnConstructor> ctor = PropertyIntTypeOnConstructor.class.getConstructor();
+ type.setConstructor(new JavaConstructorImpl<PropertyIntTypeOnConstructor>(ctor));
+ processor.visitEnd(PropertyIntTypeOnConstructor.class, type);
+ org.apache.tuscany.sca.assembly.Property foo = ModelHelper.getProperty(type, "foo");
+ assertEquals(int.class, type.getPropertyMembers().get("foo").getType());
+ // assertEquals(new QName(JavaXMLMapper.URI_2001_SCHEMA_XSD, "int"), foo.getXSDType());
+ }
+
+ /**
+ * Errata for Java Component Implementation Specification v1.0 corrects the algorithm for determining
+ * references of an unannotated POJO (section 1.2.7). This test makes sure that the earlier implementation
+ * is corrected as per the errata. A notable difference is that the interfaces annotated with @Service
+ * no longer result in references.
+ */
+ @Test
+ public void testUpdatedRule() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(SomeServiceImpl.class, type);
+ assertEquals(12, type.getReferenceMembers().size());
+ assertTrue(type.getReferenceMembers().containsKey("rri1"));
+ assertTrue(type.getReferenceMembers().containsKey("rri2"));
+ assertTrue(type.getReferenceMembers().containsKey("rri3"));
+ assertTrue(type.getReferenceMembers().containsKey("rri4"));
+
+ assertTrue(type.getReferenceMembers().containsKey("rria1"));
+ assertTrue(type.getReferenceMembers().containsKey("rria2"));
+ assertTrue(type.getReferenceMembers().containsKey("rria3"));
+ assertTrue(type.getReferenceMembers().containsKey("rria4"));
+
+ assertTrue(type.getReferenceMembers().containsKey("rric1"));
+ assertTrue(type.getReferenceMembers().containsKey("rric2"));
+ assertTrue(type.getReferenceMembers().containsKey("rric3"));
+ assertTrue(type.getReferenceMembers().containsKey("rric4"));
+
+ assertEquals(16, type.getPropertyMembers().size());
+ assertTrue(type.getPropertyMembers().containsKey("pnri1"));
+ assertTrue(type.getPropertyMembers().containsKey("pnri2"));
+ assertTrue(type.getPropertyMembers().containsKey("pnri3"));
+ assertTrue(type.getPropertyMembers().containsKey("pnri4"));
+
+ assertTrue(type.getPropertyMembers().containsKey("pnria1"));
+ assertTrue(type.getPropertyMembers().containsKey("pnria2"));
+ assertTrue(type.getPropertyMembers().containsKey("pnria3"));
+ assertTrue(type.getPropertyMembers().containsKey("pnria4"));
+
+ assertTrue(type.getPropertyMembers().containsKey("pnric1"));
+ assertTrue(type.getPropertyMembers().containsKey("pnric2"));
+ assertTrue(type.getPropertyMembers().containsKey("pnric3"));
+ assertTrue(type.getPropertyMembers().containsKey("pnric4"));
+
+ assertTrue(type.getPropertyMembers().containsKey("gen1"));
+ assertTrue(type.getPropertyMembers().containsKey("gen2"));
+ assertTrue(type.getPropertyMembers().containsKey("gen3"));
+ assertTrue(type.getPropertyMembers().containsKey("gen4"));
+ }
+
+ /**
+ * Interfaces with "@WebService" annotation implemented by the class should result
+ * in a Service in the same manner as an "@Remotable" annotation would.
+ */
+ @Test
+ public void testInterfaceWithWebServiceAnnotation() throws Exception{
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(SomeWebServiceImpl.class, type);
+ assertEquals(1, type.getServices().size());
+ assertEquals("SomeWebService", type.getServices().get(0).getName());
+ }
+
+ @Remotable
+ private interface ReferenceRemotableInterface {
+ void operation1(String param1);
+ }
+
+ private interface PropertyNonRemotableInterface {
+ void operation1(String param1);
+ }
+
+ @Remotable
+ private interface SomeService {
+ void serviceOperation1();
+ }
+
+ private static class SomeServiceImpl implements SomeService {
+
+ public SomeServiceImpl() {
+ }
+
+ // References - interface with @Remotable
+ public void setRri1(ReferenceRemotableInterface rri) {
+ }
+ protected void setRri2(ReferenceRemotableInterface rri) {
+ }
+ public ReferenceRemotableInterface rri3;
+ protected ReferenceRemotableInterface rri4;
+
+ // References - array of interface with @Remotable
+ public void setRria1(ReferenceRemotableInterface[] rri) {
+ }
+ protected void setRria2(ReferenceRemotableInterface[] rri) {
+ }
+ public ReferenceRemotableInterface[] rria3;
+ protected ReferenceRemotableInterface[] rria4;
+
+ // References - parametrized Collection of interface with @Remotable
+ public void setRric1(Collection<ReferenceRemotableInterface> rri) {
+ }
+ protected void setRric2(Collection<ReferenceRemotableInterface> rri) {
+ }
+ public Collection<ReferenceRemotableInterface> rric3;
+ protected Collection<ReferenceRemotableInterface> rric4;
+
+ // Properties - interface with @Service and without @Remotable
+ public void setPnri1(PropertyNonRemotableInterface arg) {
+ }
+ protected void setPnri2(PropertyNonRemotableInterface arg) {
+ }
+ public PropertyNonRemotableInterface pnri3;
+ protected PropertyNonRemotableInterface pnri4;
+
+ // Properties - array of interface with @Service and without @Remotable
+ public void setPnria1(PropertyNonRemotableInterface[] arg) {
+ }
+ protected void setPnria2(PropertyNonRemotableInterface[] arg) {
+ }
+ public PropertyNonRemotableInterface[] pnria3;
+ protected PropertyNonRemotableInterface[] pnria4;
+
+ // Properties - parametrized Collection of interface with @Service and without @Remotable
+ public void setPnric1(Collection<PropertyNonRemotableInterface> arg) {
+ }
+ protected void setPnric2(Collection<PropertyNonRemotableInterface> arg) {
+ }
+ public Collection<PropertyNonRemotableInterface> pnric3;
+ protected Collection<PropertyNonRemotableInterface> pnric4;
+
+ // Properties - Non-parametrized Collection
+ public void setGen1(Collection arg) {
+ }
+ protected void setGen2(Collection arg) {
+ }
+ public Collection gen3;
+ protected Collection gen4;
+
+ public void serviceOperation1() {
+ }
+ }
+
+ private static class PropertyIntTypeOnConstructor {
+ protected int foo;
+
+ public PropertyIntTypeOnConstructor() {
+ }
+
+ public int getFoo() {
+ return foo;
+ }
+ }
+
+ @Remotable
+ private interface PropertyInterface {
+ void setString1(String val);
+ }
+
+ @Remotable
+ private interface Interface1 {
+ }
+
+ private static class Parent implements Interface1 {
+
+ }
+
+ private static class Child extends Parent {
+ public Child() {
+ }
+
+ }
+
+ private static class SingleInterfaceImpl implements PropertyInterface {
+ public SingleInterfaceImpl() {
+ }
+
+ public void setString1(String val) {
+ }
+
+ }
+
+ private interface HeuristicServiceInterface {
+ void fooOperation(String ref);
+
+ void setInvalid1(); // No parameter
+
+ void setInvalid2(String str, int i); // More than one parameter
+
+ String setInvalid3(String str); // return should be void
+ }
+
+ public static class MockService implements PropertyInterface, RefInterface, HeuristicServiceInterface {
+
+ @Property
+ public void setString1(String val) {
+ }
+
+ @Property
+ public void setString2(String val) {
+ }
+
+ @Reference
+ public void setReference(Ref ref) {
+ }
+
+ @Reference
+ public void setReference2(Ref ref) {
+ }
+
+ public void fooOperation(String ref) {
+
+ }
+
+ public void setInvalid1() {
+ }
+
+ public void setInvalid2(String str, int i) {
+ }
+
+ public String setInvalid3(String str) {
+ return null;
+ }
+
+ }
+
+ @Remotable
+ private interface Ref {
+ }
+
+ private class ComplexProperty {
+ }
+
+ private interface RefInterface {
+ void setReference(Ref ref);
+ }
+
+ private static class RefInterfaceImpl implements RefInterface {
+ public RefInterfaceImpl() {
+ }
+
+ public void setReference(Ref ref) {
+ }
+ }
+
+ private static class SingleInterfaceWithPropertyReferenceImpl implements Interface1 {
+ public SingleInterfaceWithPropertyReferenceImpl() {
+ }
+
+ public void setReference(Ref ref) {
+ }
+
+ public void setProperty(ComplexProperty prop) {
+ }
+ }
+
+ private static class ReferenceCollectionImpl implements Interface1 {
+ public ReferenceCollectionImpl() {
+ }
+
+ public void setCollectionReference(Collection<Ref> ref) {
+ }
+
+ public void setNonGenericCollectionReference(Collection ref) {
+ // [rfeng] By the SCA specification, this should be classified as property
+ }
+
+ public void setListReference(List<Ref> ref) {
+ }
+
+ public void setArrayReference(Ref[] ref) {
+ }
+ }
+
+ private static class PropertyCollectionImpl implements Interface1 {
+ public PropertyCollectionImpl() {
+ }
+
+ public void setCollectionProperty(Collection<ComplexProperty> prop) {
+ }
+
+ public void setCollectionProperty2(Collection<String> prop) {
+ }
+
+ public void setArrayProperty(ComplexProperty[] prop) {
+ }
+
+ public void setArrayProperty2(String[] prop) {
+ }
+ }
+
+ @Remotable
+ private interface RemotableRef {
+ }
+
+ private static class RemotableRefImpl implements Interface1 {
+ protected RemotableRef otherRef;
+
+ public RemotableRefImpl() {
+ }
+
+ public void setRef(RemotableRef ref) {
+
+ }
+ }
+
+ private static class ProtectedRemotableRefFieldImpl implements Interface1 {
+ protected RemotableRef otherRef;
+
+ public ProtectedRemotableRefFieldImpl() {
+ }
+
+ public ProtectedRemotableRefFieldImpl(RemotableRef otherRef) {
+ this.otherRef = otherRef;
+ }
+
+ }
+
+ private static class ProtectedRemotableRefMethodImpl implements Interface1 {
+ public ProtectedRemotableRefMethodImpl() {
+ }
+
+ protected void setOtherRef(RemotableRef otherRef) {
+ }
+
+ }
+
+ @WebService
+ private interface SomeWebService {
+ void serviceOperation1();
+ }
+
+ @Service(SomeWebService.class)
+ private static class SomeWebServiceImpl implements SomeWebService {
+ public SomeWebServiceImpl() {
+
+ }
+
+ public void serviceOperation1() {
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java
new file mode 100644
index 0000000000..07ab6f28c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.junit.Test;
+
+/**
+ * Verifies constructors that have extensible annotation types, i.e. that have
+ * parameters marked by annotations which are themselves processed by some other
+ * implementation processor
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeutisticExtensibleConstructorTestCase extends AbstractProcessorTest {
+
+ private org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor processor;
+ private JavaImplementationFactory javaImplementationFactory;
+
+ public HeutisticExtensibleConstructorTestCase() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ processor = new HeuristicPojoProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory(registry));
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ }
+
+ private <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ for (Constructor<?> constructor : clazz.getConstructors()) {
+ visitConstructor(constructor, type);
+ }
+ processor.visitEnd(clazz, type);
+ }
+
+ /**
+ * Verifies heuristic processing can be called prior to an extension
+ * annotation processors being called.
+ */
+ @Test
+ public void testBarAnnotationProcessedFirst() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+ JavaConstructorImpl<Foo> definition = new JavaConstructorImpl<Foo>(ctor);
+ type.setConstructor(definition);
+ Property property = factory.createProperty();
+ property.setName("myBar");
+ definition.getParameters()[0].setName("myBar");
+ type.getProperties().add(property);
+ visitEnd(Foo.class, type);
+ assertEquals(2, type.getProperties().size());
+ }
+
+ /**
+ * Verifies heuristic processing can be called before an extension
+ * annotation processors is called. <p/> For example, given:
+ *
+ * <pre>
+ * Foo(@Bar String prop, @org.oasisopen.sca.annotation.Property(name = &quot;foo&quot;) String prop2)
+ * </pre>
+ *
+ * <p/> Heuristic evaluation of
+ * @Property can occur prior to another implementation processor evaluating
+ * @Bar
+ * @throws Exception
+ */
+ @Test
+ public void testBarAnnotationProcessedLast() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ visitEnd(Foo.class, type);
+
+ // now simulate process the bar impl
+ JavaConstructorImpl<?> definition = type.getConstructor();
+ definition.getParameters()[0].setName("myBar");
+ Property property = factory.createProperty();
+ property.setName("myBar");
+ type.getProperties().add(property);
+
+ assertEquals(2, type.getProperties().size());
+ assertEquals("foo", definition.getParameters()[1].getName());
+ }
+
+ /**
+ * Verifies heuristic processing can be called before an extension
+ * annotation processors is called with the extension parameter in a middle
+ * position. Specifically, verifies that the heuristic processor updates
+ * injection names and preserves their ordering.
+ */
+ @Test
+ public void testBarAnnotationProcessedFirstInMiddle() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Constructor<Foo2> ctor = Foo2.class.getConstructor(String.class, String.class, String.class);
+ JavaConstructorImpl<Foo2> definition = new JavaConstructorImpl<Foo2>(ctor);
+ type.setConstructor(definition);
+ // insert placeholder for first param, which would be done by a
+ // processor
+ definition.getParameters()[0].setName("");
+ Property property = factory.createProperty();
+ // Hack to add a property member
+ JavaElementImpl element = new JavaElementImpl("myBar", String.class, null);
+ type.getPropertyMembers().put("myBar", element);
+ property.setName("myBar");
+ definition.getParameters()[1].setName("myBar");
+ type.getProperties().add(property);
+ visitEnd(Foo2.class, type);
+ assertEquals("baz", definition.getParameters()[0].getName());
+ assertEquals(2, type.getProperties().size());
+ assertEquals(1, type.getReferences().size());
+ }
+
+ public @interface Bar {
+
+ }
+
+ public static class Foo {
+ public Foo(@Bar
+ String prop, @org.oasisopen.sca.annotation.Property(name = "foo")
+ String prop2) {
+ }
+ }
+
+ public static class Foo2 {
+ public Foo2(@org.oasisopen.sca.annotation.Reference(name = "baz")
+ String prop1, @Bar
+ String prop2, @org.oasisopen.sca.annotation.Property(name = "foo")
+ String prop3) {
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java
new file mode 100644
index 0000000000..5df7078aa6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Init;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InitProcessorTestCase {
+
+ private JavaImplementationFactory javaImplementationFactory;
+
+ public InitProcessorTestCase() {
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ }
+
+ @Test
+ public void testInit() throws Exception {
+ InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = InitProcessorTestCase.Foo.class.getMethod("init");
+ processor.visitMethod(method, type);
+ assertNotNull(type.getInitMethod());
+ }
+
+ @Test
+ public void testBadInit() throws Exception {
+ InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = InitProcessorTestCase.Bar.class.getMethod("badInit", String.class);
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalInitException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testTwoInit() throws Exception {
+ InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = InitProcessorTestCase.Bar.class.getMethod("init");
+ Method method2 = InitProcessorTestCase.Bar.class.getMethod("init2");
+ processor.visitMethod(method, type);
+ try {
+ processor.visitMethod(method2, type);
+ fail();
+ } catch (DuplicateInitException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testProtectedInit() throws Exception {
+ InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = InitProcessorTestCase.Bar.class.getDeclaredMethod("protectedInit");
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalInitException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testPrivateInit() throws Exception {
+ InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = InitProcessorTestCase.Bar.class.getDeclaredMethod("privateInit");
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalInitException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testBadInit2() throws Exception {
+ InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ Method method = InitProcessorTestCase.Bar.class.getDeclaredMethod("badInit2");
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalInitException e) {
+ // expected
+ }
+ }
+
+ private class Foo {
+ @Init
+ public void init() {
+ }
+ }
+
+
+ private class Bar {
+ @Init
+ public void init() {
+ }
+
+ @Init
+ public void init2() {
+ }
+
+ @Init
+ public void badInit(String foo) {
+ }
+
+ @Init
+ public String badInit2() {
+ return null;
+ }
+
+ @Init
+ protected void protectedInit() {
+ }
+
+ @Init
+ private void privateInit() {
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessorTestCase.java
new file mode 100644
index 0000000000..2e6ef50996
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessorTestCase.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getService;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.InvalidCallbackException;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.policy.DefaultPolicyFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * @version $Rev: 826368 $ $Date: 2009-10-18 08:22:23 +0100 (Sun, 18 Oct 2009) $
+ */
+public class JAXWSProcessorTestCase {
+ private JAXWSProcessor processor;
+ private JavaImplementationFactory javaImplementationFactory;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ processor = new JAXWSProcessor(registry);
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ }
+
+ @Test
+ public void testWebServiceNoName() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(Foo0Impl.class, type);
+ org.apache.tuscany.sca.assembly.Service service = getService(type, "Foo0Impl");
+ assertNotNull(service);
+ }
+
+ @Test
+ public void testWebServiceName() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(Foo1Impl.class, type);
+ org.apache.tuscany.sca.assembly.Service service = getService(type, "Foo1");
+ assertNotNull(service);
+ }
+
+ @Test
+ public void testWebServiceEP() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(Foo2Impl.class, type);
+ org.apache.tuscany.sca.assembly.Service service = getService(type, "Foo2");
+ assertNotNull(service);
+ }
+
+ @Test
+ public void testWebServiceWSDL() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(Foo3Impl.class, type);
+ org.apache.tuscany.sca.assembly.Service service = getService(type, "Foo3");
+ assertNotNull(service);
+ }
+
+ @WebService()
+ private static class Foo0Impl{
+ public String doSomething(String aParam){
+ return null;
+ }
+ }
+
+ @WebService(name="Foo1")
+ private static class Foo1Impl{
+ public String doSomething(String aParam){
+ return null;
+ }
+ }
+
+ private interface Foo2 {
+ public String doSomething(String aParam);
+ }
+
+ @WebService(name="Foo2", endpointInterface="org.apache.tuscany.sca.implementation.java.introspect.impl.JAXWSProcessorTestCase.Foo2")
+ private static class Foo2Impl{
+ public String doSomething(String aParam){
+ return null;
+ }
+ }
+
+ @WebService(name="Foo3", wsdlLocation="foo3.wsdl")
+ private static class Foo3Impl{
+ public String doSomething(String aParam){
+ return null;
+ }
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ModelHelper.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ModelHelper.java
new file mode 100644
index 0000000000..aad6b96cf9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ModelHelper.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ModelHelper {
+
+ public static Property getProperty(JavaImplementation type, String name) {
+ for (Property prop : type.getProperties()) {
+ if (prop.getName().equals(name)) {
+ return prop;
+ }
+ }
+ return null;
+ }
+
+ public static Reference getReference(JavaImplementation type, String name) {
+ for (Reference ref : type.getReferences()) {
+ if (ref.getName().equals(name)) {
+ return ref;
+ }
+ }
+ return null;
+ }
+
+ public static Service getService(JavaImplementation type, String name) {
+ for (Service svc : type.getServices()) {
+ if (svc.getName().equals(name)) {
+ return svc;
+ }
+ }
+ return null;
+ }
+
+ public static boolean matches(Contract contract, Class<?> type) {
+ Interface interface1 = contract.getInterfaceContract().getInterface();
+ if (interface1 instanceof JavaInterface) {
+ return type == ((JavaInterface)interface1).getJavaClass();
+ } else {
+ return false;
+ }
+ }
+
+ public static ComponentService createService(AssemblyFactory factory,
+ JavaInterfaceFactory javaFactory, Class<?> type) {
+ org.apache.tuscany.sca.assembly.ComponentService ref = factory.createComponentService();
+ ref.setName(type.getSimpleName());
+ JavaInterface i = javaFactory.createJavaInterface();
+ i.setJavaClass(type);
+ JavaInterfaceContract ic = javaFactory.createJavaInterfaceContract();
+ ic.setInterface(i);
+ ref.setInterfaceContract(ic);
+ return ref;
+ }
+
+ public static Reference createReference(AssemblyFactory factory,
+ JavaInterfaceFactory javaFactory, String name, Class<?> type) {
+ org.apache.tuscany.sca.assembly.Reference ref = factory.createReference();
+ ref.setName(name);
+ JavaInterface i = javaFactory.createJavaInterface();
+ i.setJavaClass(type);
+ JavaInterfaceContract ic = javaFactory.createJavaInterfaceContract();
+ ic.setInterface(i);
+ ref.setInterfaceContract(ic);
+ return ref;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
new file mode 100644
index 0000000000..e3d747fc28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
@@ -0,0 +1,428 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.impl.PolicyJavaInterfaceVisitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Requires;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PolicyProcessorTestCase {
+ private ServiceProcessor serviceProcessor;
+ private PolicyProcessor policyProcessor;
+ private PolicyJavaInterfaceVisitor visitor;
+ private JavaImplementation type;
+
+ // This actually is a test for PolicyJavaInterfaceProcessor. It will get
+ // invoked via the call to ImplementationProcessorServiceImpl.createService in
+ // ServiceProcessor. Of course ServiceProcessor class has to be working.
+ @Test
+ public void testSingleInterfaceWithIntentsOnInterfaceAtInterfaceLevel() throws Exception {
+ serviceProcessor.visitClass(Service1.class, type);
+ visitor.visitInterface((JavaInterface)type.getServices().get(0).getInterfaceContract().getInterface());
+ policyProcessor.visitClass(Service1.class, type);
+ verifyIntents(Service1.class, type);
+ }
+
+ @Test
+ public void testMultipleInterfacesWithIntentsOnInterfaceAtInterfaceLevel() throws Exception {
+ serviceProcessor.visitClass(Service2.class, type);
+ visitor.visitInterface((JavaInterface)type.getServices().get(0).getInterfaceContract().getInterface());
+ visitor.visitInterface((JavaInterface)type.getServices().get(1).getInterfaceContract().getInterface());
+ policyProcessor.visitClass(Service2.class, type);
+ verifyIntents(Service2.class, type);
+ }
+
+ @Test
+ public void testSingleInterfaceWithIntentsOnImplAtClassLevel() throws Exception {
+ serviceProcessor.visitClass(Service3.class, type);
+ visitor.visitInterface((JavaInterface)type.getServices().get(0).getInterfaceContract().getInterface());
+ policyProcessor.visitClass(Service3.class, type);
+ verifyIntents(Service3.class, type);
+ }
+
+ @Test
+ public void testMultipleInterfacesWithIntentsOnImplAtClassLevel() throws Exception {
+ serviceProcessor.visitClass(Service4.class, type);
+ visitor.visitInterface((JavaInterface)type.getServices().get(0).getInterfaceContract().getInterface());
+ policyProcessor.visitClass(Service4.class, type);
+ verifyIntents(Service4.class, type);
+ }
+
+ public void stestSingleInterfaceWithIntentsOnInterfaceAtMethodLevel() throws Exception {
+ serviceProcessor.visitClass(Service5.class, type);
+ visitor.visitInterface((JavaInterface)type.getServices().get(0).getInterfaceContract().getInterface());
+ policyProcessor.visitClass(Service5.class, type);
+ verifyIntents(Service5.class, type);
+ }
+
+ @Test
+ public void testSingleInterfaceWithIntentsOnServiceAndInterfaceAtImplAndInertfaceAndMethodLevel() throws Exception {
+ serviceProcessor.visitClass(Service6.class, type);
+ visitor.visitInterface((JavaInterface)type.getServices().get(0).getInterfaceContract().getInterface());
+ policyProcessor.visitClass(Service6.class, type);
+ for (Method method : Service6.class.getDeclaredMethods()) {
+ policyProcessor.visitMethod(method, type);
+ }
+ verifyIntents(Service6.class, type);
+ }
+
+ private void verifyIntents(Class<?> serviceImplClass, JavaImplementation type) {
+ if ( !(type instanceof PolicySubject) ) {
+ fail("No Intents on the service ");
+ }
+ Requires serviceImplIntentAnnotation = (Requires)serviceImplClass.getAnnotation(Requires.class);
+ if (serviceImplIntentAnnotation != null) {
+ String[] serviceImplIntents = serviceImplIntentAnnotation.value();
+ List<Intent> requiredIntents = ((PolicySubject)type).getRequiredIntents();
+ if (serviceImplIntents.length > 0) {
+ if (requiredIntents == null || requiredIntents.size() == 0) {
+ fail("No Intents on the service ");
+ }
+ Map<String, Intent> intentMap = new HashMap<String, Intent>();
+ for (Intent intent : requiredIntents) {
+ intentMap.put(intent.getName().getLocalPart(), intent);
+ }
+ for (String intent : serviceImplIntents) {
+ assertTrue("ComponentType for Service class " + serviceImplClass.getName()
+ + " did not contain Service Implementation intent "
+ + intent, intentMap.containsKey(intent));
+ }
+ }
+ }
+
+ // This should match what was specified on @Service for a Service Implementation
+ // If we use these to get the Service names and we get a null Service
+ // name then it would seem that wrong values were put on the @Service annotation
+ // or the wrong interfaces were specified on the implements list of the class
+ // statement?
+ Map<String, org.apache.tuscany.sca.assembly.Service> serviceMap = new HashMap<String, org.apache.tuscany.sca.assembly.Service>();
+ for (org.apache.tuscany.sca.assembly.Service service: type.getServices()) {
+ serviceMap.put(service.getName(), service);
+ }
+ for (Class<?> interfaceClass : serviceImplClass.getInterfaces()) {
+ Requires interfaceIntentAnnotation = (Requires)interfaceClass.getAnnotation(Requires.class);
+ org.apache.tuscany.sca.assembly.Service service = serviceMap.get(interfaceClass.getSimpleName());
+ if (service == null) {
+ fail("No service defined for interface " + interfaceClass.getSimpleName()
+ + " on Service Implementation "
+ + serviceImplClass.getName());
+ }
+
+ if (interfaceIntentAnnotation != null) {
+ String[] interfaceIntents = interfaceIntentAnnotation.value();
+ List<Intent> requiredIntents = service.getInterfaceContract().getInterface().getRequiredIntents();
+ if (interfaceIntents.length > 0) {
+ if (requiredIntents == null || requiredIntents.size() == 0) {
+ fail("No Intents on the service " + service.getName());
+ }
+ Map<String, Intent> intentMap = new HashMap<String, Intent>();
+ for (Intent intent : requiredIntents) {
+ intentMap.put(intent.getName().getLocalPart(), intent);
+ }
+ for (String intent : interfaceIntents) {
+ assertTrue("Interface " + service.getName()
+ + " did not contain Service Interface intent "
+ + intent, intentMap.containsKey(intent));
+ }
+ }
+ }
+
+ /*
+ for (Method method : interfaceClass.getDeclaredMethods()) {
+ Requires methodIntentAnnotation = method.getAnnotation(Requires.class);
+
+ // Verify that each of the Intents on each of the Service
+ // Interface Methods exist on their associated operation.
+ if (methodIntentAnnotation != null) {
+ String[] methodIntents = methodIntentAnnotation.value();
+ if (methodIntents.length > 0) {
+ List<Intent> requiredIntents = null;
+ for ( ConfiguredOperation confOp : service.getConfiguredOperations() ) {
+ if ( confOp.getName().equals(method.getName()) &&
+ confOp.getContractName().equals(service.getName()) ) {
+ requiredIntents = confOp.getRequiredIntents();
+ }
+ }
+
+ if (requiredIntents == null || requiredIntents.size() == 0) {
+ fail("No Intents on operation " + method.getName());
+ }
+ for (String intent : methodIntents) {
+ boolean found = false;
+ for (Intent requiredIntent: requiredIntents) {
+ if (requiredIntent.getName().getLocalPart().equals(intent)) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("Operation " + method.getName()
+ + " did not contain Service Interface method intent "
+ + intent, found);
+ }
+ }
+ }
+ }
+
+ for (Method method : serviceImplClass.getDeclaredMethods()) {
+ Requires methodIntentAnnotation = method.getAnnotation(Requires.class);
+
+ // Verify that each of the Intents on each of the Service
+ // Implementation Methods exist on their associated
+ // operation.
+ if (methodIntentAnnotation != null) {
+ String[] methodIntents = methodIntentAnnotation.value();
+ if (methodIntents.length > 0) {
+ List<Intent> requiredIntents = null;
+ for ( ConfiguredOperation confOp : ((OperationsConfigurator)type).getConfiguredOperations() ) {
+ if ( confOp.getName().equals(method.getName()) ) {
+ requiredIntents = confOp.getRequiredIntents();
+ }
+ }
+
+ if (requiredIntents == null || requiredIntents.size() == 0) {
+ fail("No Intents on operation " + method.getName());
+ }
+
+ for (String intent : methodIntents) {
+ boolean found = false;
+ for (Intent requiredIntent: requiredIntents) {
+ if (requiredIntent.getName().getLocalPart().equals(intent)) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("Operation " + method.getName()
+ + " did not contain Implementation method intent "
+ + intent, found);
+ }
+ }
+ }
+ }
+ */
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ serviceProcessor = new ServiceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory(registry));
+ policyProcessor = new PolicyProcessor(registry);
+ visitor = new PolicyJavaInterfaceVisitor(registry);
+ JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ type = javaImplementationFactory.createJavaImplementation();
+ }
+
+ // @Remotable
+ @Requires( {"transaction.global"})
+ private interface Interface1 {
+ int method1();
+
+ int method2();
+
+ int method3();
+
+ int method4();
+ }
+
+ @Service(Interface1.class)
+ private class Service1 implements Interface1 {
+ public int method1() {
+ return 0;
+ }
+
+ public int method2() {
+ return 0;
+ }
+
+ public int method3() {
+ return 0;
+ }
+
+ public int method4() {
+ return 0;
+ }
+ }
+
+ // @Remotable
+ @Requires( {"transaction.local"})
+ private interface Interface2 {
+ int method5();
+
+ int method6();
+ }
+
+ @Service({Interface1.class, Interface2.class})
+ private class Service2 implements Interface1, Interface2 {
+ public int method1() {
+ return 0;
+ }
+
+ public int method2() {
+ return 0;
+ }
+
+ public int method3() {
+ return 0;
+ }
+
+ public int method4() {
+ return 0;
+ }
+
+ public int method5() {
+ return 0;
+ }
+
+ public int method6() {
+ return 0;
+ }
+ }
+
+ // @Remotable
+ private interface Interface3 {
+ int method1();
+
+ int method2();
+
+ int method3();
+
+ int method4();
+ }
+
+ @Service(Interface3.class)
+ @Requires( {"transaction.global"})
+ private class Service3 implements Interface3 {
+ public int method1() {
+ return 0;
+ }
+
+ public int method2() {
+ return 0;
+ }
+
+ public int method3() {
+ return 0;
+ }
+
+ public int method4() {
+ return 0;
+ }
+ }
+
+ // @Remotable
+ private interface Interface4 {
+ int method5();
+
+ int method6();
+ }
+
+ @Service({Interface3.class, Interface4.class})
+ @Requires( {"transaction.local"})
+ private class Service4 implements Interface3, Interface4 {
+ public int method1() {
+ return 0;
+ }
+
+ public int method2() {
+ return 0;
+ }
+
+ public int method3() {
+ return 0;
+ }
+
+ public int method4() {
+ return 0;
+ }
+
+ public int method5() {
+ return 0;
+ }
+
+ public int method6() {
+ return 0;
+ }
+ }
+
+ private interface Interface5 {
+ @Requires( {"transaction.global"})
+ int method1();
+
+ @Requires( {"transaction.local"})
+ int method2();
+ }
+
+ @Service(Interface5.class)
+ private class Service5 implements Interface5 {
+ public int method1() {
+ return 0;
+ }
+
+ public int method2() {
+ return 0;
+ }
+ }
+
+ @Requires( {"transaction.global.Interface6"})
+ private interface Interface6 {
+ @Requires( {"transaction.global.Interface6.method1"})
+ int method1();
+
+ @Requires( {"transaction.local.Interface6.method2"})
+ int method2();
+ }
+
+ @Service(Interface6.class)
+ @Requires( {"transaction.global.Service6"})
+ private class Service6 implements Interface6 {
+ // @Requires( {"transaction.global.Service6.method1"})
+ public int method1() {
+ return 0;
+ }
+
+ // @Requires( {"transaction.global.Service6.method1"})
+ public int method2() {
+ return 0;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
new file mode 100644
index 0000000000..559659cdeb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Property;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PropertyProcessorTestCase {
+
+ JavaImplementation type;
+ PropertyProcessor processor;
+
+ @Before
+ public void setUp() throws Exception {
+ JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ type = javaImplementationFactory.createJavaImplementation();
+ processor = new PropertyProcessor(new DefaultExtensionPointRegistry());
+ }
+
+ @Test
+ public void testMethodAnnotation() throws Exception {
+ processor.visitMethod(Foo.class.getMethod("setFoo", String.class), type);
+ assertNotNull(getProperty(type, "foo"));
+ }
+
+ @Test
+ public void testMethodRequired() throws Exception {
+ processor.visitMethod(Foo.class.getMethod("setFooRequired", String.class), type);
+ org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "fooRequired");
+ assertNotNull(prop);
+ assertTrue(prop.isMustSupply());
+ }
+
+ @Test
+ public void testMethodName() throws Exception {
+ processor.visitMethod(Foo.class.getMethod("setBarMethod", String.class), type);
+ assertNotNull(getProperty(type, "bar"));
+ }
+
+ @Test
+ public void testFieldAnnotation() throws Exception {
+ processor.visitField(Foo.class.getDeclaredField("baz"), type);
+ assertNotNull(getProperty(type, "baz"));
+ }
+
+ @Test
+ public void testFieldRequired() throws Exception {
+ processor.visitField(Foo.class.getDeclaredField("bazRequired"), type);
+ org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "bazRequired");
+ assertNotNull(prop);
+ assertTrue(prop.isMustSupply());
+ }
+
+ @Test
+ public void testFieldName() throws Exception {
+ processor.visitField(Foo.class.getDeclaredField("bazField"), type);
+ assertNotNull(getProperty(type, "theBaz"));
+ }
+
+ @Test
+ public void testDuplicateFields() throws Exception {
+ processor.visitField(Bar.class.getDeclaredField("dup"), type);
+ try {
+ processor.visitField(Bar.class.getDeclaredField("baz"), type);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testDuplicateMethods() throws Exception {
+ processor.visitMethod(Bar.class.getMethod("setDupMethod", String.class), type);
+ try {
+ processor.visitMethod(Bar.class.getMethod("setDupSomeMethod", String.class), type);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testInvalidProperty() throws Exception {
+ try {
+ processor.visitMethod(Bar.class.getMethod("badMethod"), type);
+ fail();
+ } catch (IllegalPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testMultiplicityCollection() throws Exception {
+ processor.visitField(Multiple.class.getDeclaredField("refs1"), type);
+ org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "refs1");
+ assertNotNull(prop);
+ assertSame(String.class, getBaseType(type.getPropertyMembers().get(prop.getName())));
+ assertTrue(prop.isMany());
+ }
+
+ @Test
+ public void testMultiplicityArray() throws Exception {
+ processor.visitField(Multiple.class.getDeclaredField("refs2"), type);
+ org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "refs2");
+ assertNotNull(prop);
+ assertSame(String.class, getBaseType(type.getPropertyMembers().get(prop.getName())));
+ assertTrue(prop.isMany());
+ }
+
+ @Test
+ public void testMultiplicityArrayMethod() throws Exception {
+ processor.visitMethod(Multiple.class.getMethod("setRefs3", String[].class), type);
+ org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "refs3");
+ assertNotNull(prop);
+ assertSame(String.class, getBaseType(type.getPropertyMembers().get(prop.getName())));
+ assertTrue(prop.isMany());
+ }
+
+ @Test
+ public void testMultiplicityCollectionMethod() throws Exception {
+ processor.visitMethod(Multiple.class.getMethod("setRefs4", Collection.class), type);
+ org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "refs4");
+ assertNotNull(prop);
+ assertSame(String.class, getBaseType(type.getPropertyMembers().get(prop.getName())));
+ assertTrue(prop.isMany());
+ }
+
+ @Test
+ public void testRejectStaticFieldProperty() throws Exception {
+ try {
+ processor.visitField(BadStaticProps.class.getDeclaredField("stint"), type);
+ fail("Processor should not accept a static field with Property annotation");
+ }
+ catch (IllegalPropertyException e) {
+ // expected
+ }
+ catch (Exception e) {
+ fail("Wrong exception detected");
+ }
+ }
+
+ @Test
+ public void testRejectStaticMethodProperty() throws Exception {
+ try {
+ processor.visitMethod(BadStaticProps.class.getDeclaredMethod("setStint",int.class), type);
+ fail("Processor should not accept a static method with Property annotation");
+ }
+ catch (IllegalPropertyException e) {
+ // expected
+ }
+ catch (Exception e) {
+ fail("Wrong exception detected");
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testClassWithBadMethodArgProperty() throws Exception {
+ Method meth = BadMethodProps.class.getMethod("BadMethod", String.class);
+
+ try {
+ processor.visitMethod(meth, type);
+
+ fail("Method with @Property annotated args should be rejected");
+ } catch (IllegalPropertyException e) {
+ // expected
+ }
+ catch (Exception e) {
+ fail("Wrong exception received");
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Private classes utilized in the tests
+ */
+
+ private class Foo {
+
+ @Property
+ protected String baz;
+
+ @Property(required = true)
+ protected String bazRequired;
+
+ @Property(name = "theBaz")
+ protected String bazField;
+
+ @Property
+ public void setFoo(String string) {
+ }
+
+ @Property(required = true)
+ public void setFooRequired(String string) {
+ }
+
+ @Property(name = "bar")
+ public void setBarMethod(String string) {
+ }
+
+ }
+
+ private class Bar {
+
+ @Property
+ protected String dup;
+
+ @Property(name = "dup")
+ protected String baz;
+
+ @Property
+ public void setDupMethod(String s) {
+ }
+
+ @Property(name = "dupMethod")
+ public void setDupSomeMethod(String s) {
+ }
+
+ @Property
+ public void badMethod() {
+ }
+ }
+
+ private class Multiple {
+ @Property
+ protected List<String> refs1;
+
+ @Property
+ protected String[] refs2;
+
+ @Property
+ public void setRefs3(String[] refs) {
+ }
+
+ @Property
+ public void setRefs4(Collection<String> refs) {
+ }
+ }
+
+ private static class BadMethodProps {
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public BadMethodProps(@Property(name = "myProp", required = true)String prop) {
+
+ }
+
+ /** Java can't tell that the @reference argument is disallowed by SCA, but the run time must reject it*/
+ public void BadMethod(@Property(name = "badMethodArgProp")String methArg) {
+
+ }
+ }
+
+ private static class BadStaticProps {
+
+ @Property(name="badstaticfield")static int stint;
+
+ @Property(name="badstaticfield")static void setStint(int theStint) {
+ stint = theStint;
+ }
+ }
+
+ private Class<?> getBaseType(JavaElementImpl element) {
+ return JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java
new file mode 100644
index 0000000000..6a7987a376
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getReference;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReferenceProcessorTestCase {
+
+ private JavaImplementation type;
+ private ReferenceProcessor processor;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ type = javaImplementationFactory.createJavaImplementation();
+ processor = new ReferenceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory(registry));
+ }
+
+ @Test
+ public void testMethodAnnotation() throws Exception {
+ processor.visitMethod(ReferenceProcessorTestCase.Foo.class.getMethod("setFoo", Ref.class), type);
+ org.apache.tuscany.sca.assembly.Reference reference = getReference(type, "foo");
+ assertNotNull(reference);
+ assertEquals(Ref.class, ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass());
+ }
+
+ @Test
+ public void testMethodRequired() throws Exception {
+ processor.visitMethod(ReferenceProcessorTestCase.Foo.class.getMethod("setFooRequired", Ref.class), type);
+ org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "fooRequired");
+ assertNotNull(ref);
+ assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity());
+ }
+
+ @Test
+ public void testMethodName() throws Exception {
+ processor.visitMethod(ReferenceProcessorTestCase.Foo.class.getMethod("setBarMethod", Ref.class), type);
+ assertNotNull(getReference(type, "bar"));
+ }
+
+ @Test
+ public void testFieldAnnotation() throws Exception {
+ processor.visitField(ReferenceProcessorTestCase.Foo.class.getDeclaredField("baz"), type);
+ org.apache.tuscany.sca.assembly.Reference reference = getReference(type, "baz");
+ assertNotNull(reference);
+ assertEquals(Ref.class, ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass());
+ }
+
+ @Test
+ public void testFieldRequired() throws Exception {
+ processor.visitField(ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazRequired"), type);
+ org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "bazRequired");
+ assertNotNull(ref);
+ assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity());
+ }
+
+ @Test
+ public void testFieldName() throws Exception {
+ processor.visitField(ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazField"), type);
+ assertNotNull(getReference(type, "theBaz"));
+ }
+
+ @Test
+ public void testDuplicateFields() throws Exception {
+ processor.visitField(ReferenceProcessorTestCase.Bar.class.getDeclaredField("dup"), type);
+ try {
+ processor.visitField(ReferenceProcessorTestCase.Bar.class.getDeclaredField("baz"), type);
+ fail();
+ } catch (DuplicateReferenceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testDuplicateMethods() throws Exception {
+ processor.visitMethod(ReferenceProcessorTestCase.Bar.class.getMethod("setDupMethod", Ref.class), type);
+ try {
+ processor.visitMethod(ReferenceProcessorTestCase.Bar.class.getMethod("setDupSomeMethod", Ref.class), type);
+ fail();
+ } catch (DuplicateReferenceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testInvalidProperty() throws Exception {
+ try {
+ processor.visitMethod(ReferenceProcessorTestCase.Bar.class.getMethod("badMethod"), type);
+ fail();
+ } catch (IllegalReferenceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testClassWithBadMethodArgReference() throws Exception {
+ Method meth = BadMethAnn.class.getMethod("BadMethod", String.class);
+
+ try {
+ processor.visitMethod(meth, type);
+
+ fail("reference annotation on ordinary method arg should be rejected");
+ } catch (IllegalReferenceException e) {
+ // expected
+ }
+ catch (Exception e) {
+ fail("Wrong exception detected");
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testMultiplicity1ToN() throws Exception {
+ processor.visitField(Multiple.class.getDeclaredField("refs1"), type);
+ org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs1");
+ assertNotNull(ref);
+ assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
+ assertEquals(Multiplicity.ONE_N, ref.getMultiplicity());
+ }
+
+ @Test
+ public void testMultiplicityTo0ToN() throws Exception {
+ processor.visitField(Multiple.class.getDeclaredField("refs2"), type);
+ org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs2");
+ assertNotNull(ref);
+ assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
+ assertEquals(Multiplicity.ZERO_N, ref.getMultiplicity());
+ }
+
+ @Test
+ public void testMultiplicity1ToNMethod() throws Exception {
+ processor.visitMethod(Multiple.class.getMethod("setRefs3", Ref[].class), type);
+ org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs3");
+ assertNotNull(ref);
+ assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
+ assertEquals(Multiplicity.ONE_N, ref.getMultiplicity());
+ }
+
+ @Test
+ public void testMultiplicity0ToNMethod() throws Exception {
+ processor.visitMethod(Multiple.class.getMethod("setRefs4", Collection.class), type);
+ org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs4");
+ assertNotNull(ref);
+ assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
+ assertEquals(Multiplicity.ZERO_N, ref.getMultiplicity());
+ }
+
+ @Test
+ public void testRejectStaticFieldReference() throws Exception {
+ try {
+ processor.visitField(BadStaticRefs.class.getDeclaredField("stint"), type);
+ fail("Processor should not accept a static field with Property annotation");
+ }
+ catch (IllegalReferenceException e) {
+ // expected
+ }
+ catch (Exception e) {
+ fail("Wrong exception detected");
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testRejectStaticMethodReference() throws Exception {
+ try {
+ processor.visitMethod(BadStaticRefs.class.getDeclaredMethod("setStint",int.class), type);
+ fail("Processor should not accept a static method with Property annotation");
+ }
+ catch (IllegalPropertyException e) {
+ // expected
+ }
+ catch (Exception e) {
+ fail("Wrong exception detected");
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Private classes utilized in the tests
+ */
+
+ private interface Ref {
+ }
+
+ private class Foo {
+ @Reference
+ protected Ref baz;
+
+ @Reference(required = true)
+ protected Ref bazRequired;
+
+ @Reference(name = "theBaz")
+ protected Ref bazField;
+
+ @Reference
+ public void setFoo(Ref ref) {
+ }
+
+ @Reference(required = true)
+ public void setFooRequired(Ref ref) {
+ }
+
+ @Reference(name = "bar")
+ public void setBarMethod(Ref ref) {
+ }
+ }
+
+ private class Bar {
+ @Reference
+ protected Ref dup;
+
+ @Reference(name = "dup")
+ protected Ref baz;
+
+ @Reference
+ public void setDupMethod(Ref s) {
+ }
+
+ @Reference(name = "dupMethod")
+ public void setDupSomeMethod(Ref s) {
+ }
+
+ @Reference
+ public void badMethod() {
+ }
+
+ }
+
+ private class Multiple {
+ @Reference(required = true)
+ protected List<Ref> refs1;
+
+ @Reference(required = false)
+ protected Ref[] refs2;
+
+ @Reference(required = true)
+ public void setRefs3(Ref[] refs) {
+ }
+
+ @Reference(required = false)
+ public void setRefs4(Collection<Ref> refs) {
+ }
+ }
+
+ private static class BadStaticRefs {
+
+ @Reference(name="badstaticfield")static int stint;
+
+ @Reference(name="badstaticfield")static void setStint(int theStint) {
+ stint = theStint;
+ }
+ }
+
+
+ private static class BadMethAnn {
+
+ @org.oasisopen.sca.annotation.Constructor()
+ public BadMethAnn(@Property(name = "myProp", required = true)String prop) {
+
+ }
+
+ /** Java can't tell that the @reference argument is disallowed by SCA, but the run time must reject it*/
+ public void BadMethod(@Reference(name = "badMethodArgRef")String methArg) {
+
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java
new file mode 100644
index 0000000000..c09b0547c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceProcessorTestCase {
+
+ JavaImplementation type;
+ ResourceProcessor processor = new ResourceProcessor(new DefaultAssemblyFactory());
+
+ @Test
+ public void testVisitField() throws Exception {
+ Field field = Foo.class.getDeclaredField("bar");
+ processor.visitField(field, type);
+ JavaResourceImpl resource = type.getResources().get("bar");
+ assertFalse(resource.isOptional());
+ assertNull(resource.getMappedName());
+ assertEquals(field.getType(), resource.getElement().getType());
+ }
+
+ @Test
+ public void testVisitMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar", Bar.class);
+ processor.visitMethod(method, type);
+ JavaResourceImpl resource = type.getResources().get("bar");
+ assertFalse(resource.isOptional());
+ assertNull(resource.getMappedName());
+ assertEquals(method.getParameterTypes()[0], resource.getElement().getType());
+ }
+
+ @Test
+ public void testVisitNamedMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar2", Bar.class);
+ processor.visitMethod(method, type);
+ JavaResourceImpl resource = type.getResources().get("someName");
+ assertFalse(resource.isOptional());
+ assertEquals("mapped", resource.getMappedName());
+ }
+
+ @Test
+ public void testVisitBadMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBad");
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalResourceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testDuplicateResources() throws Exception {
+ Field field = Foo.class.getDeclaredField("bar");
+ processor.visitField(field, type);
+ try {
+ processor.visitField(field, type);
+ fail();
+ } catch (DuplicateResourceException e) {
+ //expected
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ type = javaImplementationFactory.createJavaImplementation();
+ }
+
+ private class Foo {
+
+ @org.apache.tuscany.sca.implementation.java.introspect.impl.Resource
+ protected Bar bar;
+
+ @org.apache.tuscany.sca.implementation.java.introspect.impl.Resource(optional = true)
+ protected Bar barNotRequired;
+
+ @org.apache.tuscany.sca.implementation.java.introspect.impl.Resource
+ public void setBar(Bar bar) {
+ }
+
+ @org.apache.tuscany.sca.implementation.java.introspect.impl.Resource(name = "someName", mappedName = "mapped")
+ public void setBar2(Bar bar) {
+ }
+
+ @org.apache.tuscany.sca.implementation.java.introspect.impl.Resource
+ public void setBad() {
+ }
+
+ }
+
+ private interface Bar {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java
new file mode 100644
index 0000000000..758584221d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaScopeImpl;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ScopeProcessorTestCase {
+
+ private JavaImplementationFactory javaImplementationFactory;
+
+ @Test
+ public void testCompositeScope() throws IntrospectionException {
+ ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+
+ processor.visitClass(Composite.class, type);
+ assertEquals(JavaScopeImpl.COMPOSITE, type.getJavaScope());
+ }
+
+ @Test
+ public void testStatelessScope() throws IntrospectionException {
+ ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(Stateless.class, type);
+ assertEquals(JavaScopeImpl.STATELESS, type.getJavaScope());
+ }
+
+ @Test
+ public void testNoScope() throws IntrospectionException {
+ ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory());
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(None.class, type);
+ assertEquals(JavaScopeImpl.STATELESS, type.getJavaScope());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ }
+
+ @org.oasisopen.sca.annotation.Scope("COMPOSITE")
+ private class Composite {
+ }
+
+ @org.oasisopen.sca.annotation.Scope("STATELESS")
+ private class Stateless {
+ }
+
+ private class None {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java
new file mode 100644
index 0000000000..68f3b9e456
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getService;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.InvalidCallbackException;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceCallbackTestCase {
+ private ServiceProcessor processor;
+ private JavaImplementationFactory javaImplementationFactory;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ processor = new ServiceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory(registry));
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ }
+
+ @Test
+ public void testMethodCallbackInterface() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(FooImpl.class, type);
+ org.apache.tuscany.sca.assembly.Service service = getService(type, Foo.class.getSimpleName());
+ assertNotNull(service);
+ Method method = FooImpl.class.getMethod("setCallback", FooCallback.class);
+ processor.visitMethod(method, type);
+ assertEquals(method, type.getCallbackMembers().get(FooCallback.class.getName()).iterator().next().getAnchor());
+ }
+
+ @Test
+ public void testFieldCallbackInterface() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(FooImpl.class, type);
+ org.apache.tuscany.sca.assembly.Service service = getService(type, Foo.class.getSimpleName());
+ assertNotNull(service);
+ Field field = FooImpl.class.getDeclaredField("callback");
+ processor.visitField(field, type);
+ assertEquals(field, type.getCallbackMembers().get(FooCallback.class.getName()).iterator().next().getAnchor());
+ }
+
+ @Test
+ public void testFieldCallbackInterface1() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(FooImpl1.class, type);
+ org.apache.tuscany.sca.assembly.Service service = getService(type, Foo.class.getSimpleName());
+ assertNotNull(service);
+ Field field1 = FooImpl1.class.getDeclaredField("callbackRef");
+ processor.visitField(field1, type);
+ assertEquals(field1, type.getCallbackMembers().get(FooCallback.class.getName()).iterator().next().getAnchor());
+
+ }
+
+ @Test
+ public void testMethodDoesNotMatchCallback() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(BadBarImpl.class, type);
+ Method method = BadBarImpl.class.getMethod("setWrongInterfaceCallback", String.class);
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalCallbackReferenceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testNoParamCallback() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(BadBarImpl.class, type);
+ Method method = BadBarImpl.class.getMethod("setNoParamCallback");
+ try {
+ processor.visitMethod(method, type);
+ fail();
+ } catch (IllegalCallbackReferenceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testFieldDoesNotMatchCallback() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ processor.visitClass(BadBarImpl.class, type);
+ Field field = BadBarImpl.class.getDeclaredField("wrongInterfaceCallback");
+ try {
+ processor.visitField(field, type);
+ fail();
+ } catch (IllegalCallbackReferenceException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testBadCallbackInterfaceAnnotation() throws Exception {
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ processor.visitClass(BadFooImpl.class, type);
+ fail();
+ } catch (IntrospectionException e) {
+ // expected
+ assertTrue(e.getCause() instanceof InvalidCallbackException);
+ }
+ }
+
+ @Callback(FooCallback.class)
+ private interface Foo {
+
+ }
+
+ private interface FooCallback {
+
+ }
+
+ @Service(Foo.class)
+ private static class FooImpl implements Foo {
+
+ @Callback
+ protected FooCallback callback;
+
+ @Callback
+ public void setCallback(FooCallback cb) {
+
+ }
+ }
+
+ @Service(Foo.class)
+ private static class FooImpl1 implements Foo {
+ @Callback
+ protected ServiceReference<FooCallback> callbackRef;
+ }
+
+ private static class BadBarImpl implements Foo {
+ @Callback
+ protected String wrongInterfaceCallback;
+
+ @Callback
+ public void setWrongInterfaceCallback(String cb) {
+
+ }
+
+ @Callback
+ public void setNoParamCallback() {
+
+ }
+
+ }
+
+ @Callback
+ private interface BadFoo {
+
+ }
+
+ @Service(BadFoo.class)
+ private static class BadFooImpl implements BadFoo {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java
new file mode 100644
index 0000000000..4adf57eeeb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceProcessorTestCase {
+ private ServiceProcessor processor;
+ private JavaImplementation type;
+
+ @Test
+ public void testMultipleInterfaces() throws Exception {
+ processor.visitClass(FooMultiple.class, type);
+ assertEquals(2, type.getServices().size());
+ org.apache.tuscany.sca.assembly.Service service = ModelHelper.getService(type, Baz.class.getSimpleName());
+ assertEquals(Baz.class, ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass());
+ assertEquals(Bar.class, ((JavaInterface)service.getInterfaceContract().getCallbackInterface()).getJavaClass());
+ assertNotNull(ModelHelper.getService(type, Bar.class.getSimpleName()));
+ }
+
+ @Test
+ public void testSingleInterfaces() throws Exception {
+ processor.visitClass(FooSingle.class, type);
+ assertEquals(1, type.getServices().size());
+ assertNotNull(ModelHelper.getService(type, Baz.class.getSimpleName()));
+ }
+
+ @Test
+ public void testMultipleNoService() throws Exception {
+ processor.visitClass(FooMultipleNoService.class, type);
+ assertEquals(0, type.getServices().size());
+ }
+
+ /**
+ * Verifies a service with a callback annotation is recognized
+ */
+ @Test
+ public void testMultipleWithCallbackAnnotation() throws Exception {
+ processor.visitClass(FooMultipleWithCalback.class, type);
+ assertEquals(1, type.getServices().size());
+ }
+
+
+ @Test
+ public void testMultipleWithWebServiceAnnotation() throws Exception {
+ processor.visitClass(FooMultipleWithWebService.class, type);
+ assertEquals(2, type.getServices().size());
+ }
+
+ @Test
+ public void testRemotableNoService() throws Exception {
+ processor.visitClass(FooRemotableNoService.class, type);
+ assertEquals(1, type.getServices().size());
+ org.apache.tuscany.sca.assembly.Service service = ModelHelper.getService(type, BazRemotable.class.getSimpleName());
+ assertEquals(BazRemotable.class, ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass());
+ }
+
+ @Test
+ public void testNonInterface() throws Exception {
+ processor.visitClass(FooServiceUsingClassImpl.class, type);
+ }
+
+ @Test
+ public void testMultiplenamedInterfaces() throws Exception {
+ processor.visitClass(FooMultipleNamed.class, type);
+ assertEquals(2, type.getServices().size());
+ org.apache.tuscany.sca.assembly.Service sbaz = type.getService("BazName");
+ assertNotNull(sbaz);
+ assertEquals(Baz.class, ((JavaInterface)sbaz.getInterfaceContract().getInterface()).getJavaClass());
+ org.apache.tuscany.sca.assembly.Service sbar = type.getService("BarName");
+ assertNotNull(sbar);
+ assertEquals(Bar.class, ((JavaInterface)sbar.getInterfaceContract().getInterface()).getJavaClass());
+ }
+
+ @Test
+ public void testBadService() throws Exception {
+ try {
+ processor.visitClass(BadService.class, type);
+ fail();
+ } catch (IntrospectionException e) {
+ assertTrue(e.getMessage().startsWith("[JCA90059]"));
+ }
+ }
+
+ @Test
+ public void testBadServiceNames() throws Exception {
+ try {
+ processor.visitClass(BadServiceNames.class, type);
+ fail();
+ } catch (IntrospectionException e) {
+ assertTrue(e.getMessage().startsWith("[JCA90050]"));
+ }
+ }
+
+ @Test
+ public void testBadServiceDuplicateNames() throws Exception {
+ try {
+ processor.visitClass(BadServiceDuplicateNames.class, type);
+ fail();
+ } catch (IntrospectionException e) {
+ assertTrue(e.getMessage().startsWith("[JCA90060]"));
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ processor = new ServiceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory(registry));
+ JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ type = javaImplementationFactory.createJavaImplementation();
+ }
+
+ @Callback(Bar.class)
+ private interface Baz {
+ }
+
+ private interface Bar {
+ }
+
+ private interface Bar2 {
+ }
+
+ @WebService
+ private interface Bar3 {
+ }
+
+ @Remotable
+ private interface BazRemotable {
+ }
+
+ @Service({Baz.class, Bar.class})
+ private class FooMultiple implements Baz, Bar {
+
+ }
+
+ @Service(Baz.class)
+ private class FooSingle implements Baz, Bar {
+
+ }
+
+ private class FooMultipleNoService implements Bar, Bar2 {
+
+ }
+
+ private class FooMultipleWithCalback implements Baz, Bar {
+
+ }
+
+ private class FooMultipleWithWebService implements BazRemotable, Bar3 {
+ }
+
+ private class FooRemotableNoService implements BazRemotable, Bar {
+
+ }
+
+ @Service(FooSingle.class)
+ private class FooServiceUsingClassImpl extends FooSingle {
+
+ }
+
+ @Service(value={Baz.class, Bar.class}, names={"BazName", "BarName"})
+ private class FooMultipleNamed implements Baz, Bar {
+
+ }
+
+ @Service(value={})
+ private class BadService implements Baz {
+
+ }
+
+ @Service(value={Baz.class, Bar.class}, names={"BazName"})
+ private class BadServiceNames implements Baz, Bar {
+
+ }
+
+ @Service(value={Baz.class, Bar.class}, names={"BazName", "BazName"})
+ private class BadServiceDuplicateNames implements Baz, Bar {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
new file mode 100644
index 0000000000..a90a6d18c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspect.impl;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.lang.annotation.Retention;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestAbstractPropertyProcessorTestCase {
+
+ private JavaClassVisitor extension;
+ private JavaImplementationFactory javaImplementationFactory;
+
+ @Test
+ public void testVisitMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar", String.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ extension.visitMethod(method, type);
+ Property prop = getProperty(type, "test");
+ assertNotNull(prop);
+ }
+
+ @Test
+ public void testVisitNoParamsMethod() throws Exception {
+ Method method = Foo.class.getMethod("setNoParamsBar");
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ extension.visitMethod(method, type);
+ fail();
+ } catch (IllegalPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testVisitNonVoidMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBadBar", String.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ try {
+ extension.visitMethod(method, type);
+ fail();
+ } catch (IllegalPropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testDuplicateMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar", String.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ extension.visitMethod(method, type);
+ try {
+ extension.visitMethod(method, type);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testVisitField() throws Exception {
+ Field field = Foo.class.getDeclaredField("d");
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ extension.visitField(field, type);
+ Property prop = getProperty(type, "test");
+ assertNotNull(prop);
+ }
+
+ @Test
+ public void testVisitConstructor() throws Exception {
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+ JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+ JavaConstructorImpl<Foo> def = new JavaConstructorImpl<Foo>(ctor);
+ JavaParameterImpl parameter = def.getParameters()[0];
+ extension.visitConstructorParameter(parameter, type);
+ assertEquals("test", def.getParameters()[0].getName());
+ assertNotNull(getProperty(type, "test"));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ extension = new TestProcessor();
+ javaImplementationFactory = new DefaultJavaImplementationFactory();
+ }
+
+ @Retention(RUNTIME)
+ private @interface Bar {
+
+ }
+
+ private class TestProcessor extends AbstractPropertyProcessor<Bar> {
+
+ public TestProcessor() {
+ super(new DefaultExtensionPointRegistry(), Bar.class);
+ }
+
+ @Override
+ protected void initProperty(Property property, Bar annotation) {
+ // property.setDefaultValueFactory(EasyMock.createMock(ObjectFactory.class));
+ property.setName("test");
+ }
+
+ @Override
+ protected String getName(Bar annotation) {
+ return "test";
+ }
+
+ @Override
+ protected boolean getRequired(Bar annotation) {
+ return true;
+ }
+ }
+
+ private static class Foo {
+
+ @Bar
+ protected String d;
+
+ public Foo(String a, @Bar
+ String b) {
+ }
+
+ public Foo(@Bar
+ String d) {
+ this.d = d;
+ }
+
+ @Bar
+ public void setBar(String d) {
+ this.d = d;
+ }
+
+ @Bar
+ public void setNoParamsBar() {
+ }
+
+ @Bar
+ public String setBadBar(String d) {
+ return null;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
new file mode 100644
index 0000000000..6ea4868983
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test reading Java implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
+ private static CompositeBuilder compositeBuilder;
+ private static Monitor monitor;
+ private static ProcessorContext context;
+ private static BuilderContext builderContext;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ builderContext = new BuilderContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+
+ compositeBuilder = extensionPoints.getExtensionPoint(BuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ monitor = monitorFactory.createMonitor();
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+
+ // remove dependency on builder
+ //compositeBuilder.build(composite, builderContext);
+
+ }
+
+ @Ignore("To be fixed")
+ @Test
+ public void testPolicyIntents() throws Exception {
+ ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
+
+ URL url = getClass().getResource("definitions.xml");
+ URI uri = URI.create("definitions.xml");
+ Definitions scaDefns = policyDefinitionsProcessor.read(null, uri, url, context);
+
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+
+ staxProcessor.resolve(scaDefns, resolver, context);
+ staxProcessor.resolve(composite, resolver, context);
+
+ builderContext.setDefinitions(scaDefns);
+ compositeBuilder.build(composite, builderContext);
+
+ //intents are computed and aggregate intents from ancestor elements
+ assertEquals(((PolicySubject)composite.getComponents().get(0)).getRequiredIntents().size(), 3);
+ assertEquals(((PolicySubject)composite.getComponents().get(5)).getRequiredIntents().size(), 3);
+
+ //assertEquals(((OperationsConfigurator)composite.getComponents().get(0)).getConfiguredOperations().isEmpty(), true);
+ //assertEquals(((OperationsConfigurator)composite.getComponents().get(5)).getConfiguredOperations().isEmpty(), false);
+
+
+ //test for proper aggregation of policy intents on implementation elements
+ for ( Intent intent : ((PolicySubject)composite.getComponents().get(0).getImplementation()).getRequiredIntents() ) {
+ String intentName = intent.getName().getLocalPart();
+ if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_2") ||
+ intentName.equals("tuscanyIntent_3")) ) {
+ fail();
+ }
+ }
+
+ for ( Intent intent : ((PolicySubject)composite.getComponents().get(5)).getRequiredIntents() ) {
+ String intentName = intent.getName().getLocalPart();
+ if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_4") ||
+ intentName.equals("tuscanyIntent_5")) ) {
+ fail();
+ }
+ }
+
+ /*
+ //test for proper aggregation of policy intents and policysets on operations of implementation
+ OperationsConfigurator opConf = (OperationsConfigurator)composite.getComponents().get(5);
+ assertEquals(opConf.getConfiguredOperations().get(0).getRequiredIntents().size(), 4);
+ for ( Intent intent : opConf.getConfiguredOperations().get(0).getRequiredIntents()) {
+ String intentName = intent.getName().getLocalPart();
+ if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_4") ||
+ intentName.equals("tuscanyIntent_5") || intentName.equals("tuscanyIntent_6") ) ) {
+ fail();
+ }
+ }
+
+ opConf = (OperationsConfigurator)composite.getComponents().get(6);
+ assertEquals(opConf.getConfiguredOperations().get(0).getRequiredIntents().size(), 3);
+ for ( Intent intent : opConf.getConfiguredOperations().get(0).getRequiredIntents()) {
+ String intentName = intent.getName().getLocalPart();
+ if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_4") ||
+ intentName.equals("tuscanyIntent_6.qualified2") ) ) {
+ fail();
+ }
+ }
+ */
+ }
+
+ @Test
+ @Ignore("Broken for now in 2.0 bringup")
+ public void testPolicySets() throws Exception {
+ ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
+
+ URL url = getClass().getResource("definitions_with_policysets.xml");
+ URI uri = URI.create("definitions_with_policysets.xml");
+ Definitions policyDefinitions = policyDefinitionsProcessor.read(null, uri, url, context);
+
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+
+ for ( Component component : composite.getComponents() ) {
+ for ( PolicySet policySet : policyDefinitions.getPolicySets() ) {
+ component.getPolicySets().add(policySet);
+ }
+ }
+
+ staxProcessor.resolve(policyDefinitions, resolver, context);
+ staxProcessor.resolve(composite, resolver, context);
+
+ builderContext.setDefinitions(policyDefinitions);
+ compositeBuilder.build(composite, builderContext);
+
+ //test for determination of policysets for implementation
+ assertEquals(((PolicySubject)composite.getComponents().get(0)).getPolicySets().size(), 1);
+ for ( PolicySet policySet : ((PolicySubject)composite.getComponents().get(0).getImplementation()).getPolicySets() ) {
+ String policySetName = policySet.getName().getLocalPart();
+ if ( !(policySetName.equals("tuscanyPolicySet_1")) ) {
+ fail();
+ }
+ }
+
+ assertEquals(((PolicySubject)composite.getComponents().get(5)).getPolicySets().size(), 2);
+ for ( PolicySet policySet : ((PolicySubject)composite.getComponents().get(5).getImplementation()).getPolicySets() ) {
+ String policySetName = policySet.getName().getLocalPart();
+ if ( !(policySetName.equals("tuscanyPolicySet_1") || policySetName.equals("tuscanyPolicySet_2")) ) {
+ fail();
+ }
+ }
+
+ /*
+ //test for computation of policysets on operations of implementation
+ OperationsConfigurator opConf = (OperationsConfigurator)composite.getComponents().get(5);
+ assertEquals(opConf.getConfiguredOperations().get(0).getPolicySets().size(), 3);
+ for ( PolicySet policySet : opConf.getConfiguredOperations().get(0).getPolicySets() ) {
+ String policySetName = policySet.getName().getLocalPart();
+ if ( !(policySetName.equals("tuscanyPolicySet_1") || policySetName.equals("tuscanyPolicySet_2")
+ || policySetName.equals("tuscanyPolicySet_3")) ) {
+ fail();
+ }
+ }
+
+ opConf = (OperationsConfigurator)composite.getComponents().get(6);
+ assertEquals(opConf.getConfiguredOperations().get(0).getPolicySets().size(), 4);
+ for ( PolicySet policySet : opConf.getConfiguredOperations().get(0).getPolicySets() ) {
+ String policySetName = policySet.getName().getLocalPart();
+ if ( !(policySetName.equals("tuscanyPolicySet_1") || policySetName.equals("tuscanyPolicySet_2")
+ || policySetName.equals("tuscanyPolicySet_3")
+ || policySetName.equals("tuscanyPolicySet_4")) ) {
+ fail();
+ }
+ }
+ */
+
+ //new PrintUtil(System.out).print(composite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/TestModelResolver.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/TestModelResolver.java
new file mode 100644
index 0000000000..6be50d138f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/TestModelResolver.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.sca.implementation.java.xml;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+
+/**
+ * A default implementation of an artifact resolver, based on a map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestModelResolver implements ModelResolver {
+ private static final long serialVersionUID = -7826976465762296634L;
+
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ private WeakReference<ClassLoader> classLoader;
+
+ public TestModelResolver(ClassLoader classLoader) {
+ this.classLoader = new WeakReference<ClassLoader>(classLoader);
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+
+ // Return the resolved object
+ return modelClass.cast(resolved);
+
+ } else if (unresolved instanceof ClassReference) {
+
+ // Load a class on demand
+ ClassReference classReference = (ClassReference)unresolved;
+ Class<?> clazz;
+ try {
+ clazz = Class.forName(classReference.getClassName(), true, classLoader.get());
+ } catch (ClassNotFoundException e) {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+
+ // Store a new ClassReference wrapping the loaded class
+ resolved = new ClassReference(clazz);
+ map.put(resolved, resolved);
+
+ // Return the resolved ClassReference
+ return modelClass.cast(resolved);
+
+ } else {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(resolved);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/WriteTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/WriteTestCase.java
new file mode 100644
index 0000000000..fdd606c58e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/WriteTestCase.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.implementation.java.xml;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test writing Java implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase {
+
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ Assert.assertNotNull(composite);
+ StringWriter sw = new StringWriter();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(sw), context);
+ System.out.println(sw.toString());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/Calculator.composite b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/Calculator.composite
new file mode 100644
index 0000000000..87798357e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/Calculator.composite
@@ -0,0 +1,66 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://sample.calculator"
+ requires="cns:tuscanyIntent_1"
+ targetNamespace="http://sample.calculator"
+ xmlns:cns="http://test"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent" requires="cns:tuscanyIntent_2">
+ <implementation.java class="calculator.CalculatorServiceImpl" requires="cns:tuscanyIntent_3" />
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <component name="AnotherCalculatorServiceComponent" requires="cns:tuscanyIntent_4">
+ <implementation.java class="calculator.CalculatorServiceImpl" requires="cns:tuscanyIntent_5">
+ <operation name="add" requires="cns:tuscanyIntent_6"/>
+ </implementation.java>
+ </component>
+
+ <component name="YetAnotherCalculatorServiceComponent" requires="cns:tuscanyIntent_4">
+ <implementation.java class="calculator.CalculatorServiceImpl" requires="cns:tuscanyIntent_6.qualified1">
+ <operation name="add" requires="cns:tuscanyIntent_6.qualified2" policySets="cns:tuscanyPolicySet_4"/>
+ </implementation.java>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
new file mode 100644
index 0000000000..9ecb608816
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<sca:definitions xmlns="http://test"
+ targetNamespace="http://test"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+<!-- simple intent -->
+ <sca:intent name="tuscanyIntent_1"
+ constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_2"
+ constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_3"
+ constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_4"
+ constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+<sca:intent name="tuscanyIntent_5"
+ constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_6"
+ constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_7"
+ constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_8"
+ constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <!-- qualified intents -->
+ <sca:intent name="tuscanyIntent_1.qualified" />
+ <sca:intent name="tuscanyIntent_2.qualified" />
+ <sca:intent name="tuscanyIntent_6.qualified1" />
+ <sca:intent name="tuscanyIntent_6.qualified2" />
+
+ <sca:policySet name="tuscanyPolicySet_4"
+ provides="tuscanyIntent_6"
+ appliesTo="/sca:composite/sca:component"
+ xmlns="http://test"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <sca:intentMap provides="tuscanyIntent_6" default="qualified2">
+ <sca:qualifier name="qualified2">
+ <wsp:Policy>
+ <!-- policy expression and policy subject for "qualified2" alternative" -->
+ </wsp:Policy>
+ </sca:qualifier>
+ </sca:intentMap>
+ </sca:policySet>
+</sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml
new file mode 100644
index 0000000000..18bb3078e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<sca:definitions xmlns="http://test" targetNamespace="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- simple intent -->
+ <sca:intent name="tuscanyIntent_1" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <!-- qualified intents -->
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_2" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_3" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_4" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_5" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_6" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ <sca:qualifier name="qualified1" default="true"/>
+ <sca:qualifier name="qualified2" />
+
+
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_7" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_8" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
+ </sca:description>
+ </sca:intent>
+
+ <sca:policySet name="tuscanyPolicySet_1" provides="tuscanyIntent_1 tuscanyIntent_2 tuscanyIntent_3"
+ appliesTo="/sca:composite/sca:component" xmlns="http://test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ </sca:policySet>
+
+ <sca:policySet name="tuscanyPolicySet_2" provides="tuscanyIntent_4 tuscanyIntent_5" appliesTo="/sca:composite/sca:component"
+ xmlns="http://test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ </sca:policySet>
+
+ <sca:policySet name="tuscanyPolicySet_3" provides="tuscanyIntent_6" appliesTo="/sca:composite/sca:component"
+ xmlns="http://test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <sca:intentMap provides="tuscanyIntent_6" default="qualified1">
+ <sca:qualifier name="qualified1">
+ <wsp:Policy>
+ <!-- policy expression and policy subject for "qualified1" alternative -->
+ </wsp:Policy>
+ </sca:qualifier>
+ <sca:qualifier name="qualifed2">
+ <wsp:Policy>
+ <!-- policy expression and policy subject for "qualified2" alternative" -->
+ </wsp:Policy>
+ </sca:qualifier>
+ </sca:intentMap>
+ </sca:policySet>
+
+ <sca:policySet name="tuscanyPolicySet_4" provides="tuscanyIntent_6" appliesTo="/sca:composite/sca:component"
+ xmlns="http://test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <sca:intentMap provides="tuscanyIntent_6" default="qualified2">
+ <sca:qualifier name="qualified2">
+ <wsp:Policy>
+ <!-- policy expression and policy subject for "qualified2" alternative" -->
+ </wsp:Policy>
+ </sca:qualifier>
+ </sca:intentMap>
+ </sca:policySet>
+
+</sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/LICENSE
new file mode 100644
index 0000000000..fa1256bf99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/LICENSE
@@ -0,0 +1,241 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+This module includes files under the following license:
+
+Permission to copy, display and distribute the Service Component Architecture Specification and/or
+portions thereof, without modification, in any medium without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the Service Component Architecture Specification, or
+portions thereof, that you make:
+
+1. A link or URL to the Service Component Architecture Specification at this location:
+· http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of the copyright notice as shown in the Service Component Architecture Specification.
+
+BEA, Cape Clear, IBM, Interface21, IONA, Oracle, Primeton, Progress Software, Red Hat, Rogue Wave,
+SAP, Siemens, Software AG., Sun, Sybase, TIBCO (collectively, the "Authors") agree to grant you a
+royalty-free license, under reasonable, non-discriminatory terms and conditions to patents that they deem
+necessary to implement the Service Component Architecture Specification.
+THE Service Component Architecture SPECIFICATION IS PROVIDED "AS IS," AND THE
+AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+REGARDING THIS SPECIFICATION AND THE IMPLEMENTATION OF ITS CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR
+DISTRIBUTION OF THE Service Components Architecture SPECIFICATION.
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..90894d9bd0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JAX-RS Implementation JAXRS Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Implementation JAXRS Runtime
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.jaxrs.provider
+Bundle-DocURL: http://www.apache.org/
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ javax.ws.rs,
+ javax.ws.rs.core,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.implementation.jaxrs;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.wink.server.internal,
+ org.apache.wink.server.internal.handlers,
+ org.apache.wink.server.internal.registry,
+ org.apache.wink.server.internal.servlet,
+ org.apache.wink.server.utils,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/NOTICE
new file mode 100644
index 0000000000..5dba7efd2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/NOTICE
@@ -0,0 +1,12 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the Service Component Architecture specification license
+(see the LICENSE file contained in this distribution) with the following copyright
+
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/pom.xml
new file mode 100644
index 0000000000..36c244d8fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/pom.xml
@@ -0,0 +1,154 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-jaxrs-runtime</artifactId>
+ <name>Apache Tuscany SCA JAX-RS Implementation Runtime</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-jaxrs</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rest-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.12</version>
+ <scope>test</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-server</artifactId>
+ <version>1.1.1-incubating</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-client</artifactId>
+ <version>1.1.1-incubating</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jsp_2.1_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- provided scope doesn't pull in transitive dependencies -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-el_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProvider.java
new file mode 100644
index 0000000000..91d4607831
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProvider.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.sca.implementation.jaxrs.provider;
+
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ *
+ */
+public class JAXRSImplementationProvider implements ImplementationProvider {
+ private JAXRSImplementation implementation;
+ private ServletHost host;
+
+ /**
+ * @param host
+ */
+ public JAXRSImplementationProvider(JAXRSImplementation implementation, ServletHost host) {
+ super();
+ this.implementation = implementation;
+ this.host = host;
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ return null;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ /*
+ RestServlet restServlet = new RestServlet();
+ host.addServletMapping("/*", restServlet);
+ Application application;
+ try {
+ application = (Application)implementation.getApplicationClass().newInstance();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ RegistrationUtils.registerApplication(application, restServlet.getServletContext());
+ */
+ }
+
+ public void stop() {
+ /*
+ Servlet servlet = host.removeServletMapping("/*");
+ if (servlet != null) {
+ servlet.destroy();
+ }
+ */
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProviderFactory.java
new file mode 100644
index 0000000000..2f638240f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProviderFactory.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.sca.implementation.jaxrs.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class JAXRSImplementationProviderFactory implements ImplementationProviderFactory<JAXRSImplementation> {
+
+ private ServletHost servletHost;
+
+ public JAXRSImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ JAXRSImplementation implementation) {
+ return new JAXRSImplementationProvider(implementation, servletHost);
+ }
+
+ public Class<JAXRSImplementation> getModelType() {
+ return JAXRSImplementation.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..d945bdd048
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the implementation extension
+org.apache.tuscany.sca.implementation.jaxrs.provider.JAXRSImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementation
+
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/HelloWorld.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/HelloWorld.java
new file mode 100644
index 0000000000..3a493ea10e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/HelloWorld.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 helloworld.jaxrs;
+
+import java.util.Date;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.wink.common.model.synd.SyndEntry;
+import org.apache.wink.common.model.synd.SyndText;
+
+/**
+ * Simple example - Hello World!
+ * <p/>
+ * The SDK dispatches HTTP requests for URI
+ * <code>http://[host]:[port]/HelloWorld/rest/world</code>, where
+ * <code>HelloWorld</code> is the context root, to this class. A simple Atom
+ * entry is returned in HTTP response.
+ * <p/>
+ * The service document is available at URI
+ * <code>http://[host]:[port]/HelloWorld/rest</code> but it is empty because
+ * this simple demo doesn't contain any collection of resources.
+ * <p/>
+ * This resource must be registered within a JAX-RS application, this example
+ * uses the default usage of application /WEB-INF/application
+ */
+@Path("/world")
+public class HelloWorld {
+ public static final String ID = "helloworld:1";
+
+ /**
+ * This method is called by the SDK for HTTP GET method requests where the
+ * Accept header allows the Atom media type application/atom+xml. A
+ * SyndEntry is created with basic information. Serialization of the
+ * SyndEntry to Atom entry is performed by the SDK automatically. The
+ * default status code of 200 (OK) is returned in the response.
+ *
+ * @return SyndEntry of the requested resource
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_ATOM_XML)
+ public SyndEntry getGreeting() {
+ // create and return a syndication entry with a "Hello World!" title,
+ // some ID and the current time.
+ SyndEntry synd = new SyndEntry(new SyndText("Hello World!"), ID, new Date());
+ return synd;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/HelloWorldApp.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/HelloWorldApp.java
new file mode 100644
index 0000000000..97ff1cb13e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/HelloWorldApp.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jaxrs;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class HelloWorldApp extends Application {
+
+ /*
+ * A singletons is used to serve multiple requests.
+ * It keeps domain-model objects in memory between requests.
+ */
+ private Set<Object> instances = new HashSet<Object>();
+
+ /*
+ * Per-request service classes are instantiated for each
+ * request, and disposed of after the request is processed.
+ */
+ private Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ /**
+ * Create the singleton service implementation
+ */
+ public HelloWorldApp() {
+ instances.add(new HelloWorld());
+ // classes.add(HelloWorld.class);
+ }
+
+ /**
+ * Methods used to discover the JAX-RS service objects
+ */
+
+ // Set of singleton service objects
+ @Override
+ public Set<Object> getSingletons() {
+ return instances;
+ }
+
+ // Set of per-request service classes
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/test/HelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/test/HelloWorldTestCase.java
new file mode 100644
index 0000000000..34edff56ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/test/HelloWorldTestCase.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 helloworld.jaxrs.test;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.RestClient;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class HelloWorldTestCase {
+ private static Node node;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ node =
+ NodeFactory.getInstance().createNode("helloworld/jaxrs/HelloWorld.composite",
+ new Contribution("c1", new File("target/test-classes").toURI()
+ .toString())).start();
+ }
+
+ @Test
+ public void testDummy() {
+ RestClient client = new RestClient();
+ ClientResponse response = client.resource("http://localhost:8080/world").get();
+ String out = response.getEntity(String.class);
+ System.out.println(out);
+ Assert.assertEquals(200, response.getStatusCode());
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/resources/helloworld/jaxrs/HelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/resources/helloworld/jaxrs/HelloWorld.composite
new file mode 100644
index 0000000000..db7329ca3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs-runtime/src/test/resources/helloworld/jaxrs/HelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample/jaxrs"
+ name="HelloWorld">
+
+ <component name="HelloWorldApp">
+ <tuscany:implementation.jaxrs application="helloworld.jaxrs.HelloWorldApp"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/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/sebastien/java/embed/modules/implementation-jaxrs/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b2920bf5a6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.jaxrs;version="2.0.0";uses:="org.apache.tuscany.sca.assembly"
+Private-Package: org.apache.tuscany.sca.implementation.jaxrs.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA JAX-RS Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Implementation JAXRS Model
+Import-Package: javax.ws.rs;version="1.0.0",
+ javax.ws.rs.core;version="1.0.0",
+ javax.xml.stream;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.implementation.jaxrs;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.jaxrs
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/pom.xml
new file mode 100644
index 0000000000..23dce9ab5c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/pom.xml
@@ -0,0 +1,91 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-jaxrs</artifactId>
+ <name>Apache Tuscany SCA JAX-RS Implementation Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/JAXRSImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/JAXRSImplementation.java
new file mode 100644
index 0000000000..8180ab2849
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/JAXRSImplementation.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.sca.implementation.jaxrs;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * The model representing an Web implementation in an SCA assembly model.
+ */
+public interface JAXRSImplementation extends Implementation {
+ QName TYPE = new QName(Base.SCA11_TUSCANY_NS, "implementation.jaxrs");
+
+ String getApplication();
+
+ void setApplication(String application);
+
+ Class<?> getApplicationClass();
+
+ void setApplicationClass(Class<?> applicationClass);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/JAXRSImplementationFactory.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/JAXRSImplementationFactory.java
new file mode 100644
index 0000000000..109857741c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/JAXRSImplementationFactory.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.jaxrs;
+
+/**
+ * Factory for the JAX-RS implementation model.
+ */
+public interface JAXRSImplementationFactory {
+
+ /**
+ * Creates a new JAX-RS implementation.
+ * @return a new JAX-RS implementation
+ */
+ JAXRSImplementation createJAXRSImplementation();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationFactoryImpl.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationFactoryImpl.java
new file mode 100644
index 0000000000..46d38e4131
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationFactoryImpl.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.sca.implementation.jaxrs.impl;
+
+import org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementation;
+import org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementationFactory;
+
+/**
+ * Factory for the Web implementation model.
+ */
+public class JAXRSImplementationFactoryImpl implements JAXRSImplementationFactory {
+
+ public JAXRSImplementationFactoryImpl() {
+ }
+
+ public JAXRSImplementation createJAXRSImplementation() {
+ return new JAXRSImplementationImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationImpl.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationImpl.java
new file mode 100644
index 0000000000..4c19f1b52e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationImpl.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.sca.implementation.jaxrs.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementation;
+
+/**
+ * The model representing an Web implementation in an SCA assembly model.
+ */
+public class JAXRSImplementationImpl extends ImplementationImpl implements JAXRSImplementation {
+
+ private String application;
+ private Class<?> applicationClass;
+
+ /**
+ * Constructs a new JAXRS implementation.
+ */
+ public JAXRSImplementationImpl() {
+ super(TYPE);
+ }
+
+ public String getApplication() {
+ return application;
+ }
+
+ public void setApplication(String application) {
+ this.application = application;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((application == null) ? 0 : application.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (!(obj instanceof JAXRSImplementationImpl)) {
+ return false;
+ }
+ JAXRSImplementationImpl other = (JAXRSImplementationImpl)obj;
+ if (application == null) {
+ if (other.application != null) {
+ return false;
+ }
+ } else if (!application.equals(other.application)) {
+ return false;
+ }
+ return true;
+ }
+
+ public Class<?> getApplicationClass() {
+ return applicationClass;
+ }
+
+ public void setApplicationClass(Class<?> applicationClass) {
+ this.applicationClass = applicationClass;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/xml/JAXRSImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/xml/JAXRSImplementationProcessor.java
new file mode 100644
index 0000000000..da25b6edd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/xml/JAXRSImplementationProcessor.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jaxrs.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Application;
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.RESTBindingFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementation;
+import org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementationFactory;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Implements a StAX artifact processor for Web implementations.
+ */
+public class JAXRSImplementationProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<JAXRSImplementation> {
+ private static final QName IMPLEMENTATION_JAXRS = JAXRSImplementation.TYPE;
+
+ private AssemblyFactory assemblyFactory;
+ private JAXRSImplementationFactory implementationFactory;
+ private RESTBindingFactory restBindingFactory;
+ private JavaInterfaceFactory javaInterfaceFactory;
+
+ public JAXRSImplementationProcessor(ExtensionPointRegistry extensionPoints) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.implementationFactory = modelFactories.getFactory(JAXRSImplementationFactory.class);
+ this.restBindingFactory = modelFactories.getFactory(RESTBindingFactory.class);
+ this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ }
+
+ public QName getArtifactType() {
+ // Returns the QName of the XML element processed by this processor
+ return IMPLEMENTATION_JAXRS;
+ }
+
+ public Class<JAXRSImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return JAXRSImplementation.class;
+ }
+
+ public JAXRSImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException,
+ XMLStreamException {
+
+ // Read an <implementation.web> element
+ JAXRSImplementation implementation = implementationFactory.createJAXRSImplementation();
+ implementation.setUnresolved(true);
+
+ String application = reader.getAttributeValue(null, "application");
+ if (application != null) {
+ implementation.setApplication(application);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_JAXRS.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return implementation;
+ }
+
+ public void resolve(JAXRSImplementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+
+ ClassReference classReference = new ClassReference(implementation.getApplication());
+ classReference = resolver.resolveModel(ClassReference.class, classReference, context);
+ implementation.setApplicationClass(classReference.getJavaClass());
+ implementation.setUnresolved(false);
+
+ Application application;
+ try {
+ application = (Application) implementation.getApplicationClass().newInstance();
+ } catch (Exception e) {
+ throw new ContributionResolveException(e);
+ }
+
+ for(Class<?> rootResourceClass: application.getClasses()) {
+ addService(implementation, rootResourceClass);
+ }
+ for(Object rootResource: application.getSingletons()) {
+ addService(implementation, rootResource.getClass());
+ }
+
+ }
+
+ private void addService(JAXRSImplementation implementation, Class<?> rootResourceClass) {
+ Service service = assemblyFactory.createService();
+ JavaInterfaceContract contract = javaInterfaceFactory.createJavaInterfaceContract();
+ JavaInterface javaInterface;
+ try {
+ javaInterface = javaInterfaceFactory.createJavaInterface(rootResourceClass);
+ } catch (InvalidInterfaceException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ contract.setInterface(javaInterface);
+ service.setInterfaceContract(contract);
+ RESTBinding binding = restBindingFactory.createRESTBinding();
+ // FIXME: The @ApplicationPath is available for JAX-RS 1.1
+ // binding.setURI("/");
+ Path path = rootResourceClass.getAnnotation(Path.class);
+ if (path != null) {
+ binding.setURI(path.value());
+ }
+ service.getBindings().add(binding);
+ service.setName(rootResourceClass.getSimpleName());
+ implementation.getServices().add(service);
+ }
+
+ public void write(JAXRSImplementation implementation, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ // Write <implementation.jaxrs>
+ writeStart(writer,
+ IMPLEMENTATION_JAXRS.getNamespaceURI(),
+ IMPLEMENTATION_JAXRS.getLocalPart(),
+ new XAttr("application", implementation.getApplication()));
+
+ writeEnd(writer);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..cd6ce79744
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.implementation.jaxrs.xml.JAXRSImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.jaxrs,model=org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementation,factory=org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementationFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..67f1f8bc68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -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/implementation/jaxrs/tuscany-sca-1.1-implementation-jaxrs.xsd
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementationFactory b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementationFactory
new file mode 100644
index 0000000000..01e6f77b6a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementationFactory
@@ -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 model factory
+org.apache.tuscany.sca.implementation.jaxrs.impl.JAXRSImplementationFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/org/apache/tuscany/sca/implementation/jaxrs/tuscany-sca-1.1-implementation-jaxrs.xsd b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/org/apache/tuscany/sca/implementation/jaxrs/tuscany-sca-1.1-implementation-jaxrs.xsd
new file mode 100644
index 0000000000..8b51ca830d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/main/resources/org/apache/tuscany/sca/implementation/jaxrs/tuscany-sca-1.1-implementation-jaxrs.xsd
@@ -0,0 +1,38 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"/>
+
+ <element name="implementation.jaxrs" type="t:JAXRSImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="JAXRSImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <attribute name="application" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/java/org/apache/tuscany/sca/implementation/jaxrs/xml/ReadTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/java/org/apache/tuscany/sca/implementation/jaxrs/xml/ReadTestCase.java
new file mode 100644
index 0000000000..1de9426cbe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/java/org/apache/tuscany/sca/implementation/jaxrs/xml/ReadTestCase.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jaxrs.xml;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.jaxrs.JAXRSImplementation;
+
+/**
+ * Test reading Web implementations.
+ */
+public class ReadTestCase extends TestCase {
+
+ private XMLInputFactory inputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ @Override
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestJAXRS.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ assertTrue(((JAXRSImplementation)composite.getComponents().get(0).getImplementation()).getApplication()
+ .equals("test.MyJAXRSapp"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/java/org/apache/tuscany/sca/implementation/jaxrs/xml/WriteTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/java/org/apache/tuscany/sca/implementation/jaxrs/xml/WriteTestCase.java
new file mode 100644
index 0000000000..7dcf70c711
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/java/org/apache/tuscany/sca/implementation/jaxrs/xml/WriteTestCase.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.jaxrs.xml;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+
+/**
+ * Test reading/write JAXRS implementations.
+ */
+public class WriteTestCase extends TestCase {
+
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ @Override
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestJAXRS.composite");
+ Composite composite = (Composite) staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(composite);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ assertTrue(bos.toString().contains("application=\"test.MyJAXRSapp\""));
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/resources/org/apache/tuscany/sca/implementation/jaxrs/xml/TestJAXRS.composite b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/resources/org/apache/tuscany/sca/implementation/jaxrs/xml/TestJAXRS.composite
new file mode 100644
index 0000000000..6c4254e4b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-jaxrs/src/test/resources/org/apache/tuscany/sca/implementation/jaxrs/xml/TestJAXRS.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample/jaxrs"
+ xmlns:sc="http://sample/composite"
+ name="TestJAXRS">
+
+ <component name="TestJAXRS">
+ <tuscany:implementation.jaxrs application="test.MyJAXRSapp"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/LICENSE
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/LICENSE
@@ -0,0 +1,203 @@
+
+ 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/sebastien/java/embed/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..478d05eec4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.osgi.runtime
+Bundle-Version: 2.0.0
+Bundle-Name: Apache Tuscany SCA OSGi Implementation Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Description: Apache Tuscany SCA OSGi Implementation
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+SCA-Version: 1.1
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.implementation.osgi;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.osgi.framework;version="1.4.0",
+ org.osgi.util.tracker;version="1.3.0"
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Bundle-ActivationPolicy: lazy
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/pom.xml
new file mode 100644
index 0000000000..c80a97226f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/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>
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <name>Apache Tuscany SCA OSGi Implementation Extension Runtime</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
new file mode 100644
index 0000000000..1d5d99cd34
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
@@ -0,0 +1,336 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.runtime;
+
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.REMOTE_CONFIG_SCA;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SCA_REFERENCE;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SERVICE_IMPORTED;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SERVICE_IMPORTED_CONFIGS;
+import static org.osgi.framework.Constants.SERVICE_RANKING;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceException;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ *
+ */
+public class OSGiImplementationProvider implements ImplementationProvider {
+ private RuntimeComponent component;
+ private ProxyFactoryExtensionPoint proxyFactoryExtensionPoint;
+ private Bundle osgiBundle;
+ private boolean startedByMe;
+ private OSGiImplementation implementation;
+ private List<ServiceRegistration> registrations = new ArrayList<ServiceRegistration>();
+ private OSGiImplementationFactory implementationFactory;
+
+ public OSGiImplementationProvider(RuntimeComponent component,
+ OSGiImplementation impl,
+ ProxyFactoryExtensionPoint proxyFactoryExtensionPoint,
+ OSGiImplementationFactory implementationFactory) throws BundleException {
+ this.component = component;
+ this.proxyFactoryExtensionPoint = proxyFactoryExtensionPoint;
+ this.implementationFactory = implementationFactory;
+ this.implementation = impl;
+ this.osgiBundle = impl.getBundle();
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ return new OSGiTargetInvoker(operation, this, service);
+ }
+
+ public void start() {
+ // First try to start the osgi bundle
+ try {
+ int state = osgiBundle.getState();
+ if ((state & Bundle.STARTING) == 0 && (state & Bundle.ACTIVE) == 0) {
+ osgiBundle.start();
+ startedByMe = true;
+ }
+ } catch (BundleException e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ for (ComponentReference ref : component.getReferences()) {
+ RuntimeComponentReference reference = (RuntimeComponentReference)ref;
+ InterfaceContract interfaceContract = reference.getInterfaceContract();
+ final JavaInterface javaInterface = (JavaInterface)interfaceContract.getInterface();
+ // final Class<?> interfaceClass = javaInterface.getJavaClass();
+
+ // final Hashtable<String, Object> props = new Hashtable<String, Object>();
+ // props.put(FILTER_MATCH_CRITERIA, "");
+ // Collection<String> interfaceNames = new ArrayList<String>();
+ // props.put(INTERFACE_MATCH_CRITERIA, interfaceNames);
+ // interfaceNames.add(interfaceClass.getName());
+
+ final Hashtable<String, Object> osgiProps = getOSGiProperties(reference);
+ osgiProps.put(SERVICE_RANKING, Integer.MAX_VALUE);
+ osgiProps.put(SCA_REFERENCE, component.getURI() + "#reference(" + ref.getName() + ")");
+ osgiProps.put(SERVICE_IMPORTED, "true");
+ osgiProps.put(SERVICE_IMPORTED_CONFIGS, new String[] {REMOTE_CONFIG_SCA});
+
+ for (EndpointReference epr : reference.getEndpointReferences()) {
+ final OSGiServiceFactory serviceFactory = new OSGiServiceFactory(javaInterface.getName(), epr);
+ ServiceRegistration registration =
+ AccessController.doPrivileged(new PrivilegedAction<ServiceRegistration>() {
+ public ServiceRegistration run() {
+ // Register the proxy as OSGi service
+ BundleContext context = osgiBundle.getBundleContext();
+ ServiceRegistration registration =
+ context.registerService(javaInterface.getName(), serviceFactory, osgiProps);
+ return registration;
+ }
+ });
+ registrations.add(registration);
+ }
+ }
+
+ // Set the OSGi service reference properties into the SCA service
+ for (ComponentService service : component.getServices()) {
+ // The properties might have been set by the export service
+ boolean found = false;
+ for (Object ext : service.getExtensions()) {
+ if (ext instanceof OSGiProperty) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ continue;
+ }
+ ServiceReference serviceReference = getServiceReference(osgiBundle.getBundleContext(), service);
+ if (serviceReference != null) {
+ service.getExtensions().addAll(implementationFactory.createOSGiProperties(serviceReference));
+ }
+ }
+ }
+
+ public void stop() {
+ for (ServiceRegistration registration : registrations) {
+ try {
+ registration.unregister();
+ } catch (IllegalStateException e) {
+ // The service has been unregistered, ignore it
+ }
+ }
+ registrations.clear();
+ // [REVIEW] Shoud it take care of stopping the bundle?
+ if (startedByMe) {
+ try {
+ int state = osgiBundle.getState();
+ if ((state & Bundle.STOPPING) == 0 && (state & Bundle.ACTIVE) != 0) {
+ osgiBundle.stop();
+ }
+ } catch (BundleException e) {
+ throw new ServiceRuntimeException(e);
+ } finally {
+ startedByMe = false;
+ }
+ }
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ /**
+ * Get all the OSGi properties from the extension list
+ * @param extensible
+ * @return
+ */
+ protected Hashtable<String, Object> getOSGiProperties(Extensible extensible) {
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ for (Object ext : extensible.getExtensions()) {
+ if (ext instanceof OSGiProperty) {
+ OSGiProperty p = (OSGiProperty)ext;
+ props.put(p.getName(), p.getValue());
+ }
+ }
+ return props;
+ }
+
+ protected Object getOSGiService(ComponentService service) {
+ BundleContext bundleContext = osgiBundle.getBundleContext();
+ ServiceReference ref = getServiceReference(bundleContext, service);
+ if (ref != null) {
+ Object instance = bundleContext.getService(ref);
+ return instance;
+ } else {
+ return null;
+ }
+ }
+
+ private ServiceReference getServiceReference(BundleContext bundleContext, ComponentService service) {
+ JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getInterface();
+ // String filter = getOSGiFilter(provider.getOSGiProperties(service));
+ // FIXME: What is the filter?
+ String filter = "(!(" + SERVICE_IMPORTED + "=*))";
+ // "(sca.service=" + component.getURI() + "#service-name\\(" + service.getName() + "\\))";
+ ServiceReference ref;
+ try {
+ ref = bundleContext.getServiceReferences(javaInterface.getName(), filter)[0];
+ } catch (InvalidSyntaxException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return ref;
+ }
+
+ RuntimeComponent getComponent() {
+ return component;
+ }
+
+ OSGiImplementation getImplementation() {
+ return implementation;
+ }
+
+ /**
+ * A proxy invocation handler that wrap exceptions into OSGi ServiceException
+ */
+ private static class InvocationHandlerDelegate implements InvocationHandler {
+ private final Object instance;
+
+ public InvocationHandlerDelegate(Object instance) {
+ super();
+ this.instance = instance;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (!Proxy.isProxyClass(instance.getClass())) {
+ Method m = instance.getClass().getMethod(method.getName(), method.getParameterTypes());
+ try {
+ return m.invoke(instance, args);
+ } catch (InvocationTargetException e) {
+ wrapException(method, e.getCause());
+ return null;
+ }
+ } else {
+ InvocationHandler handler = Proxy.getInvocationHandler(instance);
+ try {
+ return handler.invoke(instance, method, args);
+ } catch (Throwable e) {
+ wrapException(method, e);
+ return null;
+ }
+ }
+ }
+
+ private void wrapException(Method method, Throwable e) throws Throwable {
+ for (Class<?> exType : method.getExceptionTypes()) {
+ if (exType.isInstance(e)) {
+ throw e;
+ }
+ }
+ throw new ServiceException(e.getMessage(), ServiceException.REMOTE, e);
+ }
+
+ /**
+ * A utility to cast the object to the given interface. If the class for the object
+ * is loaded by a different classloader, a proxy will be created.
+ *
+ * @param <T>
+ * @param obj
+ * @param cls
+ * @return
+ */
+ static <T> T cast(Object obj, Class<T> cls) {
+ if (obj == null) {
+ return null;
+ } else {
+ return cls.cast(Proxy.newProxyInstance(cls.getClassLoader(),
+ new Class<?>[] {cls},
+ new InvocationHandlerDelegate(obj)));
+ }
+ }
+ }
+
+ public class OSGiServiceFactory implements ServiceFactory {
+ private RuntimeEndpointReference epr;
+ private String interfaceName;
+
+ /**
+ * @param interfaceName
+ * @param epr
+ */
+ public OSGiServiceFactory(String interfaceName, EndpointReference epr) {
+ super();
+ this.interfaceName = interfaceName;
+ this.epr = (RuntimeEndpointReference)epr;
+ }
+
+ public Object getService(Bundle bundle, ServiceRegistration registration) {
+ try {
+ Class<?> interfaceClass = null;
+ try {
+ interfaceClass = bundle.loadClass(interfaceName);
+ } catch (ClassNotFoundException e) {
+ return null;
+ }
+ ProxyFactory proxyService = proxyFactoryExtensionPoint.getInterfaceProxyFactory();
+ if (!interfaceClass.isInterface()) {
+ proxyService = proxyFactoryExtensionPoint.getClassProxyFactory();
+ }
+ Object proxy = proxyService.createProxy(interfaceClass, epr);
+ return InvocationHandlerDelegate.cast(proxy, interfaceClass);
+ } catch (Throwable e) {
+ throw new ServiceException(e.getMessage(), ServiceException.FACTORY_EXCEPTION, e);
+ }
+ }
+
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+ // Do we need to release the proxy?
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java
new file mode 100644
index 0000000000..11b29de248
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.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.sca.implementation.osgi.runtime;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.osgi.framework.BundleException;
+
+/**
+ * Builds a OSGi-based implementation provider from a component definition
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiImplementationProviderFactory implements ImplementationProviderFactory<OSGiImplementation> {
+ private OSGiImplementationFactory implementationFactory;
+ private ProxyFactoryExtensionPoint proxyFactoryExtensionPoint;
+
+ public OSGiImplementationProviderFactory(ExtensionPointRegistry registry) {
+ proxyFactoryExtensionPoint = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.implementationFactory = factoryExtensionPoint.getFactory(OSGiImplementationFactory.class);
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ OSGiImplementation implementation) {
+ try {
+ return new OSGiImplementationProvider(component, implementation, proxyFactoryExtensionPoint,
+ implementationFactory);
+ } catch (BundleException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ public Class<OSGiImplementation> getModelType() {
+ return OSGiImplementation.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java
new file mode 100644
index 0000000000..a9a2fdbd0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.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.sca.implementation.osgi.runtime;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.osgi.framework.Constants;
+
+/**
+ * The Invoker looks up the corresponding OSGi service from the OSGi service registry
+ * and delegate the call to it.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiTargetInvoker implements Invoker {
+
+ private Operation operation;
+
+ private final OSGiImplementationProvider provider;
+ private final RuntimeComponent component;
+ private final RuntimeComponentService service;
+
+ public OSGiTargetInvoker(Operation operation, OSGiImplementationProvider provider, RuntimeComponentService service) {
+
+ this.operation = operation;
+ this.service = service;
+ this.provider = provider;
+ this.component = provider.getComponent();
+
+ }
+
+ private Object invokeTarget(Message msg) throws InvocationTargetException {
+
+ Operation op = msg.getOperation();
+ if (op == null) {
+ op = this.operation;
+ }
+
+ try {
+ Object instance = provider.getOSGiService(service);
+ Method m = findMethod(instance.getClass(), operation);
+
+ Object ret = invokeMethod(instance, m, msg);
+
+ return ret;
+ } catch (InvocationTargetException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ protected Object invokeMethod(Object instance, Method m, Message msg) throws InvocationTargetException {
+
+ try {
+
+ Object payload = msg.getBody();
+
+ if (payload != null && !payload.getClass().isArray()) {
+ return m.invoke(instance, payload);
+ } else {
+ return m.invoke(instance, (Object[])payload);
+ }
+
+ } catch (InvocationTargetException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg);
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+
+ private String getOSGiFilter(Hashtable<String, Object> props) {
+ Object serviceID = props.get(Constants.SERVICE_ID);
+ if (serviceID != null) {
+ return "(" + Constants.SERVICE_ID + "=" + serviceID + ")";
+ }
+
+ String filter = "";
+
+ if (props != null && props.size() > 0) {
+ int propCount = 0;
+ for (String propName : props.keySet()) {
+ String value = String.valueOf(props.get(propName));
+ StringBuffer buf = new StringBuffer();
+ for (char c : value.toCharArray()) {
+ if (c == '(' || c == ')') {
+ buf.append("\\" + c);
+ } else {
+ buf.append(c);
+ }
+ }
+ filter = filter + "(" + propName + "=" + buf.toString() + ")";
+ propCount++;
+ }
+
+ if (propCount > 1) {
+ filter = "(&" + filter + ")";
+ }
+ } else {
+ filter = null;
+ }
+ return filter;
+ }
+
+ /**
+ * @Deprecated
+ */
+ private static Class<?>[] getPhysicalTypes(Operation operation) {
+ DataType<List<DataType>> inputType = operation.getInputType();
+ if (inputType == null) {
+ return new Class<?>[] {};
+ }
+ List<DataType> types = inputType.getLogical();
+ Class<?>[] javaTypes = new Class<?>[types.size()];
+ for (int i = 0; i < javaTypes.length; i++) {
+ Type physical = types.get(i).getPhysical();
+ if (physical instanceof Class<?>) {
+ javaTypes[i] = (Class<?>)physical;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ return javaTypes;
+ }
+
+ /**
+ * Return the method on the implementation class that matches the operation.
+ *
+ * @param implClass the implementation class or interface
+ * @param operation the operation to match
+ * @return the method described by the operation
+ * @throws NoSuchMethodException if no such method exists
+ * @Deprecated
+ */
+ public static Method findMethod(Class<?> implClass, Operation operation) throws NoSuchMethodException {
+ String name = operation.getName();
+ if (operation instanceof JavaOperation) {
+ name = ((JavaOperation)operation).getJavaMethod().getName();
+ }
+ Interface interface1 = operation.getInterface();
+ int numParams = operation.getInputType().getLogical().size();
+ if (interface1 != null && interface1.isRemotable()) {
+ List<Method> matchingMethods = new ArrayList<Method>();
+ for (Method m : implClass.getMethods()) {
+ if (m.getName().equals(name) && m.getParameterTypes().length == numParams) {
+ matchingMethods.add(m);
+ }
+ }
+
+ // TUSCANY-2180 If there is only one method then we just match on the name
+ // (this is the same as the existing behaviour)
+ if (matchingMethods.size() == 1) {
+ return matchingMethods.get(0);
+ }
+ if (matchingMethods.size() > 1) {
+ // TUSCANY-2180 We need to check the parameter types too
+ Class<?>[] paramTypes = getPhysicalTypes(operation);
+ return implClass.getMethod(name, paramTypes);
+ }
+
+ // No matching method found
+ throw new NoSuchMethodException("No matching method for operation " + operation.getName()
+ + " is found on "
+ + implClass);
+ }
+ Class<?>[] paramTypes = getPhysicalTypes(operation);
+ return implClass.getMethod(name, paramTypes);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml
new file mode 100644
index 0000000000..8718e58d8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml
@@ -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.
+-->
+<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.osgi.org/xmlns/sca/intents/v1.0.0">
+
+ <intent name="passByReference" constrains="sca:implementation"
+ intentType="implementation">
+ <description>
+ An OSGi intent to pass data by reference
+ </description>
+ </intent>
+
+ <intent name="passByValue" constrains="sca:implementation"
+ intentType="implementation">
+ <description>
+ An OSGi intent to pass data by value
+ </description>
+ </intent>
+
+</sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..33f152ba13
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.osgi.OSGiImplementation
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties
new file mode 100644
index 0000000000..2503be0b13
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties
@@ -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.
+#
+#
+ContributionReadException = ContributionReadException occured due to:
+ContributionResolveException = ContributionResolveException occured due to:
+PropertyShouldSpecifySR = Properties in implementation.osgi should specify service or reference
+CouldNotLocateOSGiBundle = Could not locate OSGi bundle: {0}
+MissingComponentTypeFile = Missing .componentType side file: {0} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-osgi/LICENSE
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/LICENSE
@@ -0,0 +1,203 @@
+
+ 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/sebastien/java/embed/modules/implementation-osgi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-osgi/META-INF/MANIFEST.MF
new file mode 100755
index 0000000000..8108f9680a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,37 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.osgi
+Bundle-Version: 2.0.0
+Bundle-ActivationPolicy: lazy
+Bundle-Name: Apache Tuscany SCA OSGi Implementation
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: true
+Bundle-Activator: org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementationActivator
+Bundle-Description: Apache Tuscany SCA OSGi Implementation
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+SCA-Version: 1.1
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.implementation.osgi;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.osgi.framework;version="1.4.0",
+ org.osgi.service.packageadmin;version="1.2.0",
+ org.osgi.util.tracker;version="1.3.0"
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.implementation.osgi;version="2.0.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-osgi/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-osgi/pom.xml
new file mode 100644
index 0000000000..f007a637fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/pom.xml
@@ -0,0 +1,72 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-osgi</artifactId>
+ <name>Apache Tuscany SCA OSGi Implementation Extension</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
new file mode 100644
index 0000000000..20c7e8d60a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.osgi;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationFactoryImpl;
+
+/**
+ *
+ */
+public class DefaultOSGiImplementationFactory extends OSGiImplementationFactoryImpl {
+
+ public DefaultOSGiImplementationFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java
new file mode 100644
index 0000000000..d7296e24bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.osgi;
+
+import org.apache.tuscany.sca.implementation.osgi.impl.ServiceDescriptionsFactoryImpl;
+
+/**
+ *
+ */
+public class DefaultServiceDescriptionsFactory extends ServiceDescriptionsFactoryImpl {
+
+ public DefaultServiceDescriptionsFactory() {
+ super();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java
new file mode 100644
index 0000000000..ba5e5284be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * The model representing an OSGi implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface OSGiImplementation extends Implementation, Extensible {
+ String BUNDLE_SYMBOLICNAME = "bundleSymbolicName";
+ String BUNDLE_VERSION = "bundleVersion";
+ QName IMPLEMENTATION_OSGI = new QName(SCA11_TUSCANY_NS, "implementation.osgi");
+ QName TYPE = IMPLEMENTATION_OSGI;
+
+ String getBundleSymbolicName();
+
+ void setBundleSymbolicName(String name);
+
+ String getBundleVersion();
+
+ void setBundleVersion(String version);
+
+ Bundle getBundle();
+
+ void setBundle(Bundle bundle);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java
new file mode 100644
index 0000000000..23952dfee4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.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.sca.implementation.osgi;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * The factory interface to create OSGiImplementation instances
+ */
+public interface OSGiImplementationFactory {
+ /**
+ * Create a new instance of OSGiImplementation
+ * @return
+ */
+ OSGiImplementation createOSGiImplementation();
+
+ /**
+ *
+ * @return
+ */
+ OSGiProperty createOSGiProperty();
+ OSGiProperty createOSGiProperty(String name, String stringValue, String type);
+ OSGiProperty createOSGiProperty(String name, Object value);
+ Collection<OSGiProperty> createOSGiProperties(ServiceReference reference);
+ Collection<OSGiProperty> createOSGiProperties(Map<String, Object> properties);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java
new file mode 100644
index 0000000000..ff889f8577
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi;
+
+import javax.xml.namespace.QName;
+
+/**
+ * <tuscany:osgi.property>
+ */
+public interface OSGiProperty {
+ String NAME = "name";
+ String TYPE = "type";
+ String VALUE = "value";
+ QName PROPERTY_QNAME = new QName(OSGiImplementation.SCA11_TUSCANY_NS, "osgi.property");
+
+ String REMOTE_CONFIG_SCA = "org.osgi.sca";
+ String SCA_BINDINGS = "org.osgi.sca.bindings";
+ String SCA_REFERENCE = "sca.reference";
+ String SCA_SERVICE = "sca.service";
+ String SCA_REFERENCE_BINDING = "sca.reference.binding";
+ String SCA_SERVICE_BINDING = "sca.service.binding";
+
+ /**
+ * Service property identifying the configuration types supported by a
+ * distribution provider. Registered by the distribution provider on one of
+ * its services to indicate the supported configuration types.
+ * <p>
+ * The value of this property must be of type <code>String</code>,
+ * <code>String[]</code>, or <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
+
+ /**
+ * Service property identifying the intents supported by a distribution
+ * provider. Registered by the distribution provider on one of its services
+ * to indicate the vocabulary of implemented intents.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>,
+ * <code>String[]</code>, or <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
+
+ /**
+ * Service property identifying the configuration types that should be used
+ * to export the service. Each configuration type represents the
+ * configuration parameters for an endpoint. A distribution provider should
+ * create an endpoint for each configuration type that it supports.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
+
+ /**
+ * Service property identifying the intents that the distribution provider
+ * must implement to distribute the service. Intents listed in this property
+ * are reserved for intents that are critical for the code to function
+ * correctly, for example, ordering of messages. These intents should not be
+ * configurable.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
+
+ /**
+ * Service property identifying the extra intents that the distribution
+ * provider must implement to distribute the service. This property is
+ * merged with the <code>service.exported.intents</code> property before the
+ * distribution provider interprets the listed intents; it has therefore the
+ * same semantics but the property should be configurable so the
+ * administrator can choose the intents based on the topology. Bundles
+ * should therefore make this property configurable, for example through the
+ * Configuration Admin service.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
+
+ /**
+ * Service property marking the service for export. It defines the
+ * interfaces under which this service can be exported. This list must be a
+ * subset of the types under which the service was registered. The single
+ * value of an asterisk (&quot;*&quot;, &#92;u002A) indicates all the
+ * interface types under which the service was registered excluding the
+ * non-interface types. It is strongly recommended to only export interface
+ * types and not concrete classes due to the complexity of creating proxies
+ * for some type of concrete classes.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
+
+ /**
+ * Service property identifying the service as imported. This service
+ * property must be set by a distribution provider to any value when it
+ * registers the endpoint proxy as an imported service. A bundle can use
+ * this property to filter out imported services.
+ *
+ * <p>
+ * The value of this property may be of any type.
+ */
+ public static final String SERVICE_IMPORTED = "service.imported";
+
+ /**
+ * Service property identifying the configuration types used to import the
+ * service. Any associated properties for this configuration types must be
+ * properly mapped to the importing system. For example, a URL in these
+ * properties must point to a valid resource when used in the importing
+ * framework. If multiple configuration types are listed in this property,
+ * then they must be synonyms for exactly the same remote endpoint that is
+ * used to export this service.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>,
+ * <code>String[]</code>, or <code>Collection&lt;String&gt;</code>.
+ *
+ * @see #SERVICE_EXPORTED_CONFIGS
+ */
+ public static final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs";
+
+ /**
+ * Service property identifying the intents that this service implement.
+ * This property has a dual purpose:
+ * <ul>
+ * <li>A bundle can use this service property to notify the distribution
+ * provider that these intents are already implemented by the exported
+ * service object.</li>
+ * <li>A distribution provider must use this property to convey the combined
+ * intents of: The exporting service, and, the intents that the exporting
+ * distribution provider adds, and the intents that the importing
+ * distribution provider adds.</li>
+ * </ul>
+ * To export a service, a distribution provider must expand any qualified
+ * intents. Both the exporting and importing distribution providers must
+ * recognize all intents before a service can be distributed.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>,
+ * <code>String[]</code>, or <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_INTENTS = "service.intents";
+
+ /* above are from Ch 13 Remote Service spec. */
+
+ /**
+ * Endpoint property identifying the id for this endpoint. This service
+ * property must always be set.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>.
+ */
+ String ENDPOINT_ID = "endpoint.id";
+
+ /**
+ * Endpoint property identifying the service id of the exported service. Can
+ * be absent or 0 if the corresponding endpoint is not for an OSGi service.
+ *
+ * <p>
+ * The value of this property must be of type <code>Long</code>.
+ */
+ String ENDPOINT_SERVICE_ID = "endpoint.service.id";
+
+ /**
+ * Endpoint property identifying the universally unique id of the exporting
+ * framework. Can be absent if the corresponding endpoint is not for an OSGi
+ * service.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>.
+ */
+ String ENDPOINT_FRAMEWORK_UUID = "endpoint.framework.uuid";
+
+ /**
+ * Prefix for an endpoint property identifying the interface Java package
+ * version for an interface. For example, the property
+ * endpoint.package.version.com.acme=1.3 describes the version of the
+ * package for the com.acme.Foo interface. This endpoint property for an
+ * interface package does not have to be set. If not set, the value must be
+ * assumed to be 0.
+ *
+ * <p>
+ * Since endpoint properties are stored in a case insensitive map, case
+ * variants of a package name are folded together.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>.
+ */
+ String ENDPOINT_PACKAGE_VERSION_ = "endpoint.package.version.";
+
+ Object getValue();
+
+ void setValue(Object value);
+
+ String getName();
+
+ void setName(String name);
+
+ String getType();
+
+ void setType(String type);
+
+ String getStringValue();
+
+ void setStringValue(String value);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java
new file mode 100644
index 0000000000..a54324b027
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.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.sca.implementation.osgi;
+
+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;
+
+/**
+ *
+ */
+public interface SCAConfig {
+ /**
+ * Returns the target namespace for this SCA Definition
+ * @return the target namespace
+ */
+ String getTargetNamespace();
+
+ /**
+ * Sets the target names for this SCA Definition.
+ *
+ * @param ns the target namespace for this SCA Definition
+ */
+ void setTargetNamespace(String ns);
+
+ /**
+ * Returns a list of domain wide Policy Intents
+ *
+ * @return a list of domain wide Policy Intents
+ */
+ List<Intent> getIntents();
+
+ /**
+ * Returns a list of domain wide PolicySets
+ *
+ * @return a list of domain wide PolicySets
+ */
+ List<PolicySet> getPolicySets();
+
+ /**
+ * Returns a list of domain wide binding definition objects
+ *
+ * @return a list of domain wide binding definition objects
+ */
+ List<Binding> getBindings();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java
new file mode 100644
index 0000000000..119d7ed657
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.osgi;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The OSGi RFC 119 description of a remote OSGi service
+ */
+public interface ServiceDescription {
+ /**
+ * Get a list of interfaces
+ * @return
+ */
+ List<String> getInterfaces();
+
+ /**
+ * Get a list of properties
+ * @return
+ */
+ Map<String, Object> getProperties();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java
new file mode 100644
index 0000000000..a5322429ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.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 org.apache.tuscany.sca.implementation.osgi;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * OSGi RFC 119 service descriptions
+ */
+public interface ServiceDescriptions extends List<ServiceDescription> {
+
+ String REMOTE_SERVICE_FOLDER = "OSGI-INF/remote-service";
+ String OSGI_SD_NS = "http://www.osgi.org/xmlns/rsa/v1.0.0";
+ QName SERVICE_DESCRIPTIONS_QNAME = new QName(OSGI_SD_NS, "endpoint-descriptions");
+ QName SERVICE_DESCRIPTION_QNAME = new QName(OSGI_SD_NS, "endpoint-description");
+ QName PROPERTY_QNAME = new QName(OSGI_SD_NS, "property");
+ QName XML_QNAME = new QName(OSGI_SD_NS, "xml");
+ String REMOTE_SERVICE_HEADER = "Remote-Service";
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java
new file mode 100644
index 0000000000..535bef2b6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.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.sca.implementation.osgi;
+
+/**
+ * The factory interface to create OSGi RFC 119 service descriptions
+ */
+public interface ServiceDescriptionsFactory {
+ ServiceDescriptions createServiceDescriptions();
+
+ ServiceDescription createServiceDescription();
+
+ SCAConfig createSCAConfig();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
new file mode 100644
index 0000000000..17ebf12903
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.osgi.framework.ServiceReference;
+
+/**
+ *
+ */
+public class OSGiImplementationFactoryImpl implements OSGiImplementationFactory {
+ public OSGiImplementationFactoryImpl(ExtensionPointRegistry registry) {
+ super();
+ }
+
+ public OSGiImplementation createOSGiImplementation() {
+ return new OSGiImplementationImpl();
+ }
+
+ public OSGiProperty createOSGiProperty() {
+ return new OSGiPropertyImpl();
+ }
+
+ public OSGiProperty createOSGiProperty(String propName, String propValue, String propType) {
+ OSGiProperty prop = new OSGiPropertyImpl();
+ if (propType == null) {
+ propType = "String";
+ }
+ prop.setName(propName);
+ prop.setStringValue(propValue);
+ prop.setType(propType);
+
+ Object value = propValue;
+ if ("Integer".equals(propType)) {
+ value = Integer.valueOf(propValue);
+ } else if ("Long".equals(propType)) {
+ value = Long.valueOf(propValue);
+ } else if ("Float".equals(propType)) {
+ value = Float.valueOf(propValue);
+ } else if ("Double".equals(propType)) {
+ value = Double.valueOf(propValue);
+ } else if ("Short".equals(propType)) {
+ value = Short.valueOf(propValue);
+ } else if ("Character".equals(propType)) {
+ value = propValue.charAt(0);
+ } else if ("Byte".equals(propType)) {
+ value = Byte.valueOf(propValue);
+ } else if ("Boolean".equals(propType)) {
+ value = Boolean.valueOf(propValue);
+ } else if ("String+".equals(propType)) {
+ value = propValue.split(" ");
+ } else {
+ // String
+ value = propValue;
+ }
+ prop.setValue(value);
+ return prop;
+ }
+
+ public OSGiProperty createOSGiProperty(String propName, Object value) {
+ OSGiProperty prop = new OSGiPropertyImpl();
+ prop.setName(propName);
+ prop.setValue(value);
+
+ if (value instanceof String[]) {
+ StringBuffer sb = new StringBuffer();
+ for (String s : (String[])value) {
+ sb.append(s).append(' ');
+ }
+ if (sb.length() > 0) {
+ sb.deleteCharAt(sb.length() - 1);
+ }
+ prop.setStringValue(sb.toString());
+ prop.setType("String+");
+ } else if (value != null) {
+ prop.setStringValue(String.valueOf(value));
+ prop.setType(value.getClass().getSimpleName());
+ }
+ return prop;
+ }
+
+ public Collection<OSGiProperty> createOSGiProperties(ServiceReference reference) {
+ List<OSGiProperty> props = new ArrayList<OSGiProperty>();
+ for(String key: reference.getPropertyKeys()) {
+ Object value = reference.getProperty(key);
+ OSGiProperty prop = createOSGiProperty(key, value);
+ props.add(prop);
+ }
+ return props;
+ }
+
+ public Collection<OSGiProperty> createOSGiProperties(Map<String, Object> properties) {
+ List<OSGiProperty> props = new ArrayList<OSGiProperty>();
+ for (Map.Entry<String, Object> e : properties.entrySet()) {
+ OSGiProperty prop = createOSGiProperty(e.getKey(), e.getValue());
+ props.add(prop);
+ }
+ return props;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
new file mode 100644
index 0000000000..4e89cbb7d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.impl;
+
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * OSGi implementation
+ * All attributes from <implementation.osgi> have getters in this class
+ * This class implements OSGiImplementationInterface which is associated with OSGiImplementationProvider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiImplementationImpl extends ImplementationImpl implements OSGiImplementation {
+
+ private String bundleSymbolicName;
+ private String bundleVersion;
+ private Bundle osgiBundle;
+
+ protected OSGiImplementationImpl() {
+ super(TYPE);
+ }
+
+ public OSGiImplementationImpl(String bundleSymbolicName, String bundleVersion) {
+ super(TYPE);
+ this.bundleSymbolicName = bundleSymbolicName;
+ this.bundleVersion = bundleVersion;
+ }
+
+ public String getBundleSymbolicName() {
+ return bundleSymbolicName;
+ }
+
+ public String getBundleVersion() {
+ return bundleVersion;
+ }
+
+ /**
+ * Since OSGi implementation annotations may not be processed until much later, leave it to
+ * the OSGi invoker to decide whether pass-by-reference is allowed.
+ * @return
+ */
+ public boolean isAllowsPassByReference() {
+ return true;
+ }
+
+ public Bundle getBundle() {
+ return osgiBundle;
+ }
+
+ public void setBundle(Bundle osgiBundle) {
+ this.osgiBundle = osgiBundle;
+ if (osgiBundle != null) {
+ this.bundleSymbolicName = osgiBundle.getSymbolicName();
+ this.bundleVersion = (String)osgiBundle.getHeaders().get(Constants.BUNDLE_VERSION);
+ }
+ }
+
+ public void setBundleSymbolicName(String bundleSymbolicName) {
+ this.bundleSymbolicName = bundleSymbolicName;
+ }
+
+ public void setBundleVersion(String bundleVersion) {
+ this.bundleVersion = bundleVersion;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((bundleSymbolicName == null) ? 0 : bundleSymbolicName.hashCode());
+ result = prime * result + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (!(obj instanceof OSGiImplementationImpl)) {
+ return false;
+ }
+ OSGiImplementationImpl other = (OSGiImplementationImpl)obj;
+ if (bundleSymbolicName == null) {
+ if (other.bundleSymbolicName != null) {
+ return false;
+ }
+ } else if (!bundleSymbolicName.equals(other.bundleSymbolicName)) {
+ return false;
+ }
+ if (bundleVersion == null) {
+ if (other.bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java
new file mode 100644
index 0000000000..b3e934a970
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.impl;
+
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+
+/**
+ * Implementation of OSGiProperty
+ */
+public class OSGiPropertyImpl implements OSGiProperty {
+ private String name;
+ private String type;
+ private Object value;
+ private String stringValue;
+
+ public OSGiPropertyImpl() {
+ super();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java
new file mode 100644
index 0000000000..4bb1b2340f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.impl;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ *
+ */
+public class SCAConfigImpl implements SCAConfig {
+ private String targetNamespace = null;
+ private List<Intent> intents = new CopyOnWriteArrayList<Intent>();
+ private List<PolicySet> policySets = new CopyOnWriteArrayList<PolicySet>();
+ private List<Binding> bindings = new CopyOnWriteArrayList<Binding>();
+
+ public List<Intent> getIntents() {
+ return intents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String ns) {
+ this.targetNamespace = ns;
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java
new file mode 100644
index 0000000000..5bd1d17253
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.impl;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+import org.osgi.framework.Constants;
+
+/**
+ * The OSGi RFC 119 description of a remote OSGi service
+ */
+public class ServiceDescriptionImpl implements ServiceDescription {
+ private Map<String, Object> properties = new HashMap<String, Object>();
+
+ protected ServiceDescriptionImpl() {
+ super();
+ }
+
+ public List<String> getInterfaces() {
+ return Arrays.asList((String[])properties.get(Constants.OBJECTCLASS));
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public String toString() {
+ return "endpoint-description: " + properties;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java
new file mode 100644
index 0000000000..716984a13b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.osgi.impl;
+
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+
+/**
+ * The factory implementation
+ */
+public class ServiceDescriptionsFactoryImpl implements ServiceDescriptionsFactory {
+
+ protected ServiceDescriptionsFactoryImpl() {
+ super();
+ }
+
+ public ServiceDescription createServiceDescription() {
+ return new ServiceDescriptionImpl();
+ }
+
+ public ServiceDescriptions createServiceDescriptions() {
+ return new ServiceDescriptionsImpl();
+ }
+
+ public SCAConfig createSCAConfig() {
+ return new SCAConfigImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java
new file mode 100644
index 0000000000..c249c053a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.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 org.apache.tuscany.sca.implementation.osgi.impl;
+
+import java.util.ArrayList;
+
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
+
+/**
+ *
+ */
+public class ServiceDescriptionsImpl extends ArrayList<ServiceDescription> implements ServiceDescriptions {
+ private static final long serialVersionUID = 6205649013621747968L;
+
+ protected ServiceDescriptionsImpl() {
+ super();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java
new file mode 100644
index 0000000000..ca6b0b70e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.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.sca.implementation.osgi.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+/*
+<!-- A sample module-context.xml for OSGI RFC 124 (BluePrint Service) -->
+<components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <component id="CalculatorComponent" class="calculator.dosgi.impl.CalculatorServiceImpl">
+ <property name="addService" ref="AddService" />
+ <property name="subtractService" ref="SubtractService" />
+ <property name="multiplyService" ref="MultiplyService" />
+ <property name="divideService" ref="DivideService" />
+ </component>
+
+ <!-- We can derive the SCA services for the implementation.osgi -->
+ <service id="CalculatorService" ref="CalculatorComponent" interface="calculator.dosgi.CalculatorService">
+ </service>
+
+ <!-- We can derive the SCA references for the implementation.osgi -->
+ <reference id="AddService" interface="calculator.dosgi.operations.AddService">
+ </reference>
+ <reference id="SubtractService" interface="calculator.dosgi.operations.SubtractService">
+ </reference>
+ <reference id="MultiplyService" interface="calculator.dosgi.operations.MultiplyService">
+ </reference>
+ <reference id="DivideService" interface="calculator.dosgi.operations.DivideService">
+ </reference>
+
+</components>
+*/
+public class BluePrintComponentsProcessor implements StAXArtifactProcessor<ComponentType> {
+ private static final String BLUE_PRINT_NS = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
+ private static final String COMPOMENTS = "components";
+ private static final QName COMPONENTS_QNAME = new QName(BLUE_PRINT_NS, COMPOMENTS);
+
+ private AssemblyFactory factory;
+ private JavaInterfaceFactory javaInterfaceFactory;
+
+ public BluePrintComponentsProcessor(FactoryExtensionPoint modelFactories) {
+ this.factory = modelFactories.getFactory(AssemblyFactory.class);
+ this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ }
+
+ public ComponentType read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException {
+ int event = reader.getEventType();
+ ComponentType componentType = factory.createComponentType();
+ while (true) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ if (COMPONENTS_QNAME.equals(name)) {
+ //
+ } else if ("reference".equals(name.getLocalPart())) {
+ Reference ref = factory.createReference();
+ ref.setName(reader.getAttributeValue(null, "id"));
+ String interfaceName = reader.getAttributeValue(null, "interface");
+ InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ ref.setInterfaceContract(interfaceContract);
+ JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface();
+ javaInterface.setUnresolved(true);
+ javaInterface.setName(interfaceName);
+ interfaceContract.setInterface(javaInterface);
+ componentType.getReferences().add(ref);
+ } else if ("service".equals(name.getLocalPart())) {
+ Service service = factory.createService();
+ String interfaceName = reader.getAttributeValue(null, "interface");
+ InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ service.setInterfaceContract(interfaceContract);
+ JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface();
+ javaInterface.setUnresolved(true);
+ javaInterface.setName(interfaceName);
+ interfaceContract.setInterface(javaInterface);
+ componentType.getServices().add(service);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ name = reader.getName();
+ if (COMPONENTS_QNAME.equals(name)) {
+ return componentType;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return componentType;
+ }
+ }
+ }
+
+ public QName getArtifactType() {
+ return COMPONENTS_QNAME;
+ }
+
+ public void write(ComponentType model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ // TODO: To be implemented
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+
+ public void resolve(ComponentType model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // TODO: To be implemented
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java
new file mode 100644
index 0000000000..860d3f6f45
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+/*
+<scr:component name="CalculatorComponent"
+ xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.CalculatorServiceDSImpl" />
+ <service>
+ <provide interface="calculator.dosgi.CalculatorService" />
+ </service>
+
+ <reference name="addService" interface="calculator.dosgi.operations.AddService" bind="setAddService" unbind="unsetAddService"
+ policy="dynamic" />
+ <reference name="subtractService" interface="calculator.dosgi.operations.SubtractService" bind="setSubtractService"
+ unbind="unsetSubtractService" policy="dynamic" />
+ <reference name="multiplyService" interface="calculator.dosgi.operations.MultiplyService" bind="setMultiplyService"
+ unbind="unsetMultiplyService" policy="dynamic" />
+ <reference name="divideService" interface="calculator.dosgi.operations.DivideService" bind="setDivideService"
+ unbind="unsetDivideService" policy="dynamic" />
+
+</scr:component>
+*/
+public class OSGiComponentProcessor implements StAXArtifactProcessor<ComponentType> {
+ private static final String OSGI_SCR_NS = "http://www.osgi.org/xmlns/scr/v1.0.0";
+ private static final String COMPOMENT = "component";
+ private static final QName COMPONENT_QNAME = new QName(OSGI_SCR_NS, COMPOMENT);
+
+ private AssemblyFactory factory;
+ private JavaInterfaceFactory javaInterfaceFactory;
+
+
+ public OSGiComponentProcessor(FactoryExtensionPoint modelFactories) {
+ this.factory = modelFactories.getFactory(AssemblyFactory.class);
+ this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ }
+
+ public ComponentType read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException {
+ int event = reader.getEventType();
+ ComponentType componentType = factory.createComponentType();
+ while (true) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ if (COMPONENT_QNAME.equals(name)) {
+ //
+ } else if ("reference".equals(name.getLocalPart())) {
+ Reference ref = factory.createReference();
+ ref.setName(reader.getAttributeValue(null, "name"));
+ String interfaceName = reader.getAttributeValue(null, "interface");
+ InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ ref.setInterfaceContract(interfaceContract);
+ JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface();
+ javaInterface.setUnresolved(true);
+ javaInterface.setName(interfaceName);
+ interfaceContract.setInterface(javaInterface);
+ componentType.getReferences().add(ref);
+ } else if ("provide".equals(name.getLocalPart())) {
+ Service service = factory.createService();
+ String interfaceName = reader.getAttributeValue(null, "interface");
+ InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ service.setInterfaceContract(interfaceContract);
+ JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface();
+ javaInterface.setUnresolved(true);
+ javaInterface.setName(interfaceName);
+ interfaceContract.setInterface(javaInterface);
+ componentType.getServices().add(service);
+ } else if ("property".equals(name.getLocalPart())) {
+ String propName = reader.getAttributeValue(null, "name");
+ String propValue = reader.getAttributeValue(null, "value");
+ String propType = reader.getAttributeValue(null, "type");
+ if (propType == null) {
+ propType = "String";
+ }
+ if (propValue == null) {
+ propValue = reader.getElementText();
+ }
+ if (propValue != null) {
+ propValue = propValue.trim();
+ }
+ Object prop = propValue;
+ if ("Integer".equals(propType)) {
+ prop = Integer.valueOf(propValue);
+ } else if ("Long".equals(propType)) {
+ prop = Long.valueOf(propValue);
+ } else if ("Float".equals(propType)) {
+ prop = Float.valueOf(propValue);
+ } else if ("Double".equals(propType)) {
+ prop = Double.valueOf(propValue);
+ } else if ("Short".equals(propType)) {
+ prop = Short.valueOf(propValue);
+ } else if ("Character".equals(propType)) {
+ prop = propValue.charAt(0);
+ } else if ("Byte".equals(propType)) {
+ prop = Byte.valueOf(propValue);
+ } else if ("Boolean".equals(propType)) {
+ prop = Boolean.valueOf(propValue);
+ }
+ Property property = factory.createProperty();
+ property.setName(propName);
+ property.setValue(prop);
+ componentType.getProperties().add(property);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ name = reader.getName();
+ if (COMPONENT_QNAME.equals(name)) {
+ return componentType;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return componentType;
+ }
+ }
+ }
+
+ public QName getArtifactType() {
+ return COMPONENT_QNAME;
+ }
+
+ public void write(ComponentType model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ // TODO: To be implemented
+ }
+
+ public Class<ComponentType> getModelType() {
+ return ComponentType.class;
+ }
+
+ public void resolve(ComponentType model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // TODO: To be implemented
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java
new file mode 100644
index 0000000000..b604447696
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.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.sca.implementation.osgi.xml;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Bundle activator to receive the BundleContext
+ */
+public class OSGiImplementationActivator implements BundleActivator {
+ private static BundleContext bundleContext;
+
+ public void start(BundleContext context) throws Exception {
+ bundleContext = context;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ bundleContext = null;
+ }
+
+ public static BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
+ static void setBundleContext(BundleContext bundleContext) {
+ OSGiImplementationActivator.bundleContext = bundleContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
new file mode 100644
index 0000000000..d98616cbc2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
@@ -0,0 +1,342 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiImplementation.BUNDLE_SYMBOLICNAME;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiImplementation.BUNDLE_VERSION;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiImplementation.IMPLEMENTATION_OSGI;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+
+/**
+ *
+ * Process an <implementation.osgi/> element in a component definition. An instance of
+ * OSGiImplementation is created.
+ * Also associates the component type file with the implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiImplementationProcessor implements StAXArtifactProcessor<OSGiImplementation> {
+ private static final String BUNDLE_COMPONENT_TYPE = "OSGI-INF/sca/bundle.componentType";
+ private static final String COMPONENT_TYPE_HEADER = "SCA-ComponentType";
+
+ private AssemblyFactory assemblyFactory;
+ private ServiceDescriptionsFactory serviceDescriptionsFactory;
+ private OSGiImplementationFactory osgiImplementationFactory;
+ private JavaInterfaceFactory javaInterfaceFactory;
+
+ private ExtensionPointRegistry registry;
+ private StAXArtifactProcessor artifactProcessor;
+
+ protected OSGiImplementationProcessor(FactoryExtensionPoint modelFactories) {
+ this.serviceDescriptionsFactory = modelFactories.getFactory(ServiceDescriptionsFactory.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.osgiImplementationFactory = modelFactories.getFactory(OSGiImplementationFactory.class);
+ this.javaInterfaceFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ }
+
+ public OSGiImplementationProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor) {
+ this(registry.getExtensionPoint(FactoryExtensionPoint.class));
+ this.artifactProcessor = processor;
+ this.registry = registry;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-osgi-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_OSGI;
+ }
+
+ public Class<OSGiImplementation> getModelType() {
+ return OSGiImplementation.class;
+ }
+
+ public OSGiImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ assert IMPLEMENTATION_OSGI.equals(reader.getName());
+
+ String bundleSymbolicName = reader.getAttributeValue(null, BUNDLE_SYMBOLICNAME);
+ String bundleVersion = reader.getAttributeValue(null, BUNDLE_VERSION);
+
+ OSGiImplementation implementation = osgiImplementationFactory.createOSGiImplementation();
+ implementation.setBundleSymbolicName(bundleSymbolicName);
+ implementation.setBundleVersion(bundleVersion);
+
+ implementation.setUnresolved(true);
+
+ // Skip to the end of <implementation.osgi>
+ while (reader.hasNext()) {
+ int next = reader.next();
+ switch (next) {
+ case START_ELEMENT:
+ break;
+ case END_ELEMENT:
+ if (IMPLEMENTATION_OSGI.equals(reader.getName())) {
+ return implementation;
+ }
+ break;
+ }
+ }
+ return implementation;
+ }
+
+ public void resolve(OSGiImplementation impl, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (impl == null || !impl.isUnresolved())
+ return;
+ Monitor monitor = context.getMonitor();
+ impl.setUnresolved(false);
+
+ BundleContext bundleContext = OSGiImplementationActivator.getBundleContext();
+ if (bundleContext == null) {
+ // FIXME: What if the OSGi is not started
+ return;
+ }
+ Bundle bundle = null;
+ for (Bundle b : bundleContext.getBundles()) {
+ String sn = b.getSymbolicName();
+ String ver = (String)b.getHeaders().get(Constants.BUNDLE_VERSION);
+ if (!impl.getBundleSymbolicName().equals(sn)) {
+ continue;
+ }
+ Version v1 = Version.parseVersion(ver);
+ Version v2 = Version.parseVersion(impl.getBundleVersion());
+ if (v1.equals(v2)) {
+ bundle = b;
+ break;
+ }
+ }
+ if (bundle != null) {
+ impl.setBundle(bundle);
+ } else {
+ error(monitor, "CouldNotLocateOSGiBundle", impl, impl.getBundleSymbolicName());
+ //throw new ContributionResolveException("Could not locate OSGi bundle " +
+ //impl.getBundleSymbolicName());
+ return;
+ }
+
+ try {
+ if (introspect(impl, resolver, context, bundle)) {
+ return;
+ }
+ } catch (ContributionReadException e) {
+ throw new ContributionResolveException(e);
+ }
+
+ // The bundle may be different from the current contribution
+ ComponentType componentType = assemblyFactory.createComponentType();
+ // Try to find a bundle.componentType for the target bundle
+ componentType.setURI("OSGI-INF/sca/" + bundle.getSymbolicName() + "/bundle.componentType");
+ componentType.setUnresolved(true);
+ componentType = resolver.resolveModel(ComponentType.class, componentType, context);
+ if (componentType.isUnresolved()) {
+ // Create a new instance to prevent it being treated as reentry
+ // See org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver.resolveModel(Class<T>, T)
+ componentType = assemblyFactory.createComponentType();
+ // Try a generic one
+ componentType.setURI(BUNDLE_COMPONENT_TYPE);
+ componentType = resolver.resolveModel(ComponentType.class, componentType, context);
+ }
+ if (componentType.isUnresolved()) {
+ // Try to derive it from the service descriptions
+ if (!deriveFromServiceDescriptions(impl, resolver, context)) {
+ error(monitor, "MissingComponentTypeFile", impl, componentType.getURI());
+ }
+ //throw new ContributionResolveException("missing .componentType side file " + ctURI);
+ return;
+ } else {
+ mergeFromComponentType(impl, componentType, resolver, context);
+ }
+ }
+
+ private boolean deriveFromServiceDescriptions(OSGiImplementation impl, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ // FIXME: How to find the RFC 119 service descriptions in the contribution and
+ // derive the SCA component type from them?
+ ServiceDescriptions descriptions = serviceDescriptionsFactory.createServiceDescriptions();
+ descriptions = resolver.resolveModel(ServiceDescriptions.class, descriptions, context);
+ if (descriptions != null && !descriptions.isEmpty()) {
+ ComponentType ct = assemblyFactory.createComponentType();
+ int index = 0;
+ for (ServiceDescription ds : descriptions) {
+ for (String i : ds.getInterfaces()) {
+ Class<?> cls = getJavaClass(resolver, i, context);
+ JavaInterface javaInterface;
+ try {
+ javaInterface = javaInterfaceFactory.createJavaInterface(cls);
+ } catch (InvalidInterfaceException e) {
+ throw new ContributionResolveException(e);
+ }
+ Reference reference = assemblyFactory.createReference();
+ JavaInterfaceContract contract = javaInterfaceFactory.createJavaInterfaceContract();
+ contract.setInterface(javaInterface);
+ reference.setInterfaceContract(contract);
+ String refName = (String)ds.getProperties().get(OSGiProperty.SCA_REFERENCE);
+ if (refName == null) {
+ refName = "ref" + (index++);
+ }
+ reference.setName(refName);
+ reference.setUnresolved(false);
+ ct.getReferences().add(reference);
+ }
+ }
+ mergeFromComponentType(impl, ct, resolver, context);
+ return true;
+ }
+ return false;
+ }
+
+ private void mergeFromComponentType(OSGiImplementation impl, ComponentType componentType, ModelResolver resolver, ProcessorContext context) {
+ List<Service> services = componentType.getServices();
+ for (Service service : services) {
+ Interface interfaze = service.getInterfaceContract().getInterface();
+ if (interfaze instanceof JavaInterface) {
+ JavaInterface javaInterface = (JavaInterface)interfaze;
+ if (javaInterface.getJavaClass() == null) {
+ javaInterface.setJavaClass(getJavaClass(resolver, javaInterface.getName(), context));
+ }
+ if (service.getInterfaceContract().getCallbackInterface() instanceof JavaInterface) {
+ JavaInterface callbackInterface =
+ (JavaInterface)service.getInterfaceContract().getCallbackInterface();
+ if (callbackInterface.getJavaClass() == null) {
+ callbackInterface.setJavaClass(getJavaClass(resolver, callbackInterface.getName(), context));
+ }
+ }
+
+ impl.getServices().add(service);
+ }
+ }
+
+ List<Reference> references = componentType.getReferences();
+ for (Reference reference : references) {
+ Interface interfaze = reference.getInterfaceContract().getInterface();
+ if (interfaze instanceof JavaInterface) {
+ JavaInterface javaInterface = (JavaInterface)interfaze;
+ if (javaInterface.getJavaClass() == null) {
+ javaInterface.setJavaClass(getJavaClass(resolver, javaInterface.getName(), context));
+ }
+ impl.getReferences().add(reference);
+ } else
+ impl.getReferences().add(reference);
+ }
+
+ List<Property> properties = componentType.getProperties();
+ for (Property property : properties) {
+ impl.getProperties().add(property);
+ }
+ }
+
+ private Class<?> getJavaClass(ModelResolver resolver, String className, ProcessorContext context) {
+ ClassReference ref = new ClassReference(className);
+ ref = resolver.resolveModel(ClassReference.class, ref, context);
+ return ref.getJavaClass();
+ }
+
+ public void write(OSGiImplementation model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ String ns = IMPLEMENTATION_OSGI.getNamespaceURI();
+ writer.writeStartElement(ns, IMPLEMENTATION_OSGI.getLocalPart());
+ writer.writeAttribute(BUNDLE_SYMBOLICNAME, model.getBundleSymbolicName());
+ if (model.getBundleVersion() != null) {
+ writer.writeAttribute(BUNDLE_VERSION, model.getBundleVersion());
+ }
+ writer.writeEndElement();
+ }
+
+ private boolean introspect(OSGiImplementation implementation, ModelResolver resolver, ProcessorContext context, Bundle bundle)
+ throws ContributionReadException, ContributionResolveException {
+ String componentTypeFile = (String)bundle.getHeaders().get(COMPONENT_TYPE_HEADER);
+ if (componentTypeFile == null) {
+ componentTypeFile = BUNDLE_COMPONENT_TYPE;
+ }
+ URL url = bundle.getEntry(componentTypeFile);
+ if (url != null) {
+ URLArtifactProcessorExtensionPoint processors =
+ registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ URLArtifactProcessor<ComponentType> processor = processors.getProcessor(ComponentType.class);
+ ComponentType componentType = processor.read(null, URI.create(BUNDLE_COMPONENT_TYPE), url, context);
+ artifactProcessor.resolve(componentType, resolver, context);
+ mergeFromComponentType(implementation, componentType, resolver, context);
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java
new file mode 100644
index 0000000000..a0c9baf6f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.NAME;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.PROPERTY_QNAME;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.TYPE;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.VALUE;
+
+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.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+
+/**
+ * A processor for <tuscany:osgi.property>
+ */
+public class OSGiPropertyProcessor implements StAXArtifactProcessor<OSGiProperty> {
+ private OSGiImplementationFactory factory;
+
+
+ public OSGiPropertyProcessor(FactoryExtensionPoint modelFactories) {
+ this.factory = modelFactories.getFactory(OSGiImplementationFactory.class);
+ }
+
+ public OSGiProperty read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException {
+ int event = reader.getEventType();
+ OSGiProperty prop = null;
+ while (true) {
+ switch (event) {
+ case START_ELEMENT:
+ QName name = reader.getName();
+ if (PROPERTY_QNAME.equals(name)) {
+ String propName = reader.getAttributeValue(null, NAME);
+ String propValue = reader.getAttributeValue(null, VALUE);
+ String propType = reader.getAttributeValue(null, TYPE);
+
+ if (propValue == null) {
+ propValue = reader.getElementText();
+ }
+ if (propValue != null) {
+ propValue = propValue.trim();
+ }
+
+ prop = factory.createOSGiProperty(propName, propValue, propType);
+ return prop;
+ }
+ break;
+ case END_ELEMENT:
+ name = reader.getName();
+ if (PROPERTY_QNAME.equals(name)) {
+ return prop;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return prop;
+ }
+ }
+ }
+
+ public QName getArtifactType() {
+ return PROPERTY_QNAME;
+ }
+
+ public void write(OSGiProperty model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ if (model.getStringValue() != null) {
+ writer.writeStartElement(PROPERTY_QNAME.getNamespaceURI(), PROPERTY_QNAME.getLocalPart());
+ writer.writeAttribute(NAME, model.getName());
+ if (model.getType() != null) {
+ writer.writeAttribute(TYPE, model.getType());
+ }
+ writer.writeAttribute(VALUE, model.getStringValue());
+ writer.writeEndElement();
+ }
+ }
+
+ public Class<OSGiProperty> getModelType() {
+ return OSGiProperty.class;
+ }
+
+ public void resolve(OSGiProperty model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // TODO: To be implemented
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java
new file mode 100644
index 0000000000..86ff968d0e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/*
+<?xml version="1.0" encoding="UTF-8"?>
+<scact:sca-config targetNamespace="http://www.foocorp.com/definitions"
+ xmlns:scact="http://www.osgi.org/xmlns/scact/v1.0.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:foocorp="http://www.foocorp.com/definitions"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/scact/v1.0.0 http://www.osgi.org/xmlns/scact/v1.0.0/sca-config.xsd">
+
+ <sca:binding.ws name="com.foocorp.FooOrderWebServiceBinding"
+ uri="http://www.foocorp.com/FooOrderService" requires="sca:soap.1_2" />
+ <foocorp:binding.rmi name="com.foocorp.FooOrderRMIBinding"
+ host="www.foocorp.com" port="8099" serviceName="FooOrderService" />
+</scact:sca-config>
+*/
+public class SCAConfigProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SCAConfig> {
+ private static final QName SCA_CONFIG_QNAME = new QName("http://www.osgi.org/xmlns/scact/v1.0.0", "sca-config");
+ private ServiceDescriptionsFactory factory;
+ private StAXArtifactProcessor processor;
+
+ public SCAConfigProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor) {
+ this.processor = processor;
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.factory = modelFactories.getFactory(ServiceDescriptionsFactory.class);
+ }
+
+ public SCAConfig read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException,
+ ContributionReadException {
+ int event = reader.getEventType();
+ SCAConfig definitions = factory.createSCAConfig();
+ String targetNamespace = null;
+ while (true) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ if (SCA_CONFIG_QNAME.equals(name)) {
+ targetNamespace = reader.getAttributeValue(null, "targetNamespace");
+ definitions.setTargetNamespace(targetNamespace);
+ } else {
+ Object extension = processor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof Intent) {
+ Intent intent = (Intent)extension;
+ intent.setName(new QName(targetNamespace, intent.getName().getLocalPart()));
+ definitions.getIntents().add(intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(targetNamespace, i.getName().getLocalPart()));
+ }
+ } else if (extension instanceof PolicySet) {
+ PolicySet policySet = (PolicySet)extension;
+ policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart()));
+ definitions.getPolicySets().add(policySet);
+ } else if (extension instanceof Binding) {
+ Binding binding = (Binding)extension;
+ definitions.getBindings().add(binding);
+ }
+ }
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ name = reader.getName();
+ if (SCA_CONFIG_QNAME.equals(name)) {
+ return definitions;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return definitions;
+ }
+ }
+ }
+
+ public QName getArtifactType() {
+ return SCA_CONFIG_QNAME;
+ }
+
+ public void write(SCAConfig definitions, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ writeStartDocument(writer,
+ SCA_CONFIG_QNAME.getNamespaceURI(),
+ SCA_CONFIG_QNAME.getLocalPart(),
+ new XAttr("targetNamespace", definitions.getTargetNamespace()));
+
+ for (Binding binding : definitions.getBindings()) {
+ processor.write(binding, writer, context);
+ }
+
+ for (Intent policyIntent : definitions.getIntents()) {
+ processor.write(policyIntent, writer, context);
+ }
+
+ for (PolicySet policySet : definitions.getPolicySets()) {
+ processor.write(policySet, writer, context);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(SCAConfig scaDefns, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ // start by adding all of the top level artifacts into the resolver as there
+ // are many cross artifact references in a definitions file and we don't want
+ // to be dependent on the order things appear
+
+ List<Intent> intents = new ArrayList<Intent>();
+ List<PolicySet> policySets = new ArrayList<PolicySet>();
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+
+ for (Intent intent : scaDefns.getIntents()) {
+ intents.add(intent);
+ resolver.addModel(intent, context);
+ for (Intent i : intent.getQualifiedIntents()) {
+ intents.add(i);
+ resolver.addModel(i, context);
+ }
+ }
+
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ if (policySet.getReferencedPolicySets().isEmpty()) {
+ policySets.add(policySet);
+ } else {
+ referredPolicySets.add(policySet);
+ }
+
+ resolver.addModel(policySet, context);
+ }
+
+ // now resolve everything to ensure that any references between
+ // artifacts are satisfied
+
+ for (Intent policyIntent : intents)
+ processor.resolve(policyIntent, resolver, context);
+
+ for (PolicySet policySet : policySets)
+ processor.resolve(policySet, resolver, context);
+
+ for (PolicySet policySet : referredPolicySets)
+ processor.resolve(policySet, resolver, context);
+
+ }
+
+ public Class<SCAConfig> getModelType() {
+ return SCAConfig.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java
new file mode 100644
index 0000000000..ad175e009c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
+
+/**
+ * The service descriptions document processor
+ */
+public class ServiceDescriptionsDocumentProcessor implements URLArtifactProcessor<ServiceDescriptions> {
+ private XMLInputFactory inputFactory;
+ private StAXArtifactProcessor extensionProcessor;
+
+ public ServiceDescriptionsDocumentProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor staxProcessor) {
+ super();
+ this.extensionProcessor = staxProcessor;
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
+ }
+
+ public String getArtifactType() {
+ return "/OSGI-INF/remote-service/*.xml";
+ }
+
+ public ServiceDescriptions read(URL contributionURL, URI artifactURI, URL artifactURL, ProcessorContext context)
+ throws ContributionReadException {
+ InputStream is = null;
+ try {
+ URLConnection connection = artifactURL.openConnection();
+ connection.setUseCaches(false);
+ is = connection.getInputStream();
+ } catch (IOException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ throw ce;
+ }
+ try {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
+ Object result = extensionProcessor.read(reader, context);
+ return (ServiceDescriptions)result;
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ throw ce;
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ is = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+
+ }
+
+ public Class<ServiceDescriptions> getModelType() {
+ return ServiceDescriptions.class;
+ }
+
+ public void resolve(ServiceDescriptions model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java
new file mode 100644
index 0000000000..cd62d5cfaf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+
+/**
+ *
+ */
+public class ServiceDescriptionsModelResolver implements ModelResolver {
+ private ServiceDescriptions serviceDescriptions;
+
+ public ServiceDescriptionsModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ ServiceDescriptionsFactory factory = modelFactories.getFactory(ServiceDescriptionsFactory.class);
+ this.serviceDescriptions = factory.createServiceDescriptions();
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ // Merge the service descriptions
+ if (resolved instanceof ServiceDescriptions) {
+ serviceDescriptions.addAll((ServiceDescriptions)resolved);
+ }
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ // Remove the service descriptions
+ if (resolved instanceof ServiceDescriptions) {
+ serviceDescriptions.removeAll((ServiceDescriptions)resolved);
+ }
+ return resolved;
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ // Always return the aggregated service descriptions
+ return modelClass.cast(serviceDescriptions);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
new file mode 100644
index 0000000000..891fed13d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+import org.osgi.framework.Constants;
+
+/*
+<?xml version="1.0" encoding="UTF-8"?>
+<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
+ <endpoint-description>
+ <property name="service.intents">
+ <list>
+ <value>SOAP</value>
+ <value>HTTP</value>
+ </list>
+ </property>
+ <property name="endpoint.id" value="http://ws.acme.com:9000/hello"/>
+ <property name="objectClass" value="com.acme.Foo"/>
+ <property name="endpoint.package.version.com.acme" value="4.2"/>
+ <property name="service.imported.configs" value="com.acme"/>
+ <property name="com.acme.ws.xml">
+ <xml>
+ <config xmlns="http://acme.com/defs">
+ <port>1029</port>
+ <host>www.acme.com</host>
+ </config>
+ </xml>
+ </property>
+ </endpoint-description>
+</endpoint-descriptions>
+*/
+public class ServiceDescriptionsProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<ServiceDescriptions> {
+ private ServiceDescriptionsFactory factory;
+ private StAXArtifactProcessor processor;
+
+ public ServiceDescriptionsProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor) {
+ this.processor = processor;
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.factory = modelFactories.getFactory(ServiceDescriptionsFactory.class);
+ }
+
+ public ServiceDescriptions read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException,
+ ContributionReadException {
+ int event = reader.getEventType();
+ ServiceDescriptions sds = null;
+ ServiceDescription sd = null;
+ String propertyName = null;
+ String propertyType = "String";
+ Object propertyValue = null;
+ String propertyLiteral = null;
+ boolean xml = false;
+ boolean multiValued = false;
+ while (true) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ if (ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
+ sds = factory.createServiceDescriptions();
+ } else if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) {
+ sd = factory.createServiceDescription();
+ sds.add(sd);
+ } else if ("property".equals(name.getLocalPart())) {
+ multiValued = false;
+ propertyName = reader.getAttributeValue(null, "name");
+ propertyType = reader.getAttributeValue(null, "value-type");
+ if (propertyType == null) {
+ propertyType = "String";
+ }
+ propertyLiteral = reader.getAttributeValue(null, "value");
+ // if (propertyLiteral == null) {
+ // propertyLiteral = reader.getElementText();
+ // }
+ if (propertyLiteral != null) {
+ propertyLiteral = propertyLiteral.trim();
+ propertyValue = getPropertyValue(reader, propertyName, propertyLiteral, propertyType);
+ }
+ } else if ("list".equals(name.getLocalPart())) {
+ if (propertyValue != null) {
+ throw new IllegalArgumentException("@value and <list> are both present");
+ }
+ propertyValue = new ArrayList<Object>();
+ multiValued = true;
+ } else if ("array".equals(name.getLocalPart())) {
+ if (propertyValue != null) {
+ throw new IllegalArgumentException("@value and <array> are both present");
+ }
+ propertyValue = new ArrayList<Object>();
+ multiValued = true;
+ } else if ("set".equals(name.getLocalPart())) {
+ if (propertyValue != null) {
+ throw new IllegalArgumentException("@value and <set> are both present");
+ }
+ propertyValue = new HashSet<Object>();
+ multiValued = true;
+ } else if ("xml".equals(name.getLocalPart())) {
+ xml = true;
+ } else if ("value".equals(name.getLocalPart())) {
+ propertyLiteral = reader.getElementText();
+ if (propertyLiteral != null) {
+ propertyLiteral = propertyLiteral.trim();
+ Object value = getPropertyValue(reader, propertyName, propertyLiteral, propertyType);
+ if (multiValued && (propertyValue instanceof Collection)) {
+ ((Collection)propertyValue).add(value);
+ } else if (propertyValue == null) {
+ propertyValue = value;
+ }
+ }
+ } else {
+ // FIXME: [rfeng] The rsa spec says the XML should be saved as String
+ Object value = processor.read(reader, context);
+ if (xml) {
+ if (multiValued && (propertyValue instanceof Collection)) {
+ ((Collection)propertyValue).add(value);
+ } else if (propertyValue == null) {
+ propertyValue = value;
+ }
+ }
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ name = reader.getName();
+ if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) {
+ // Reset the sd
+ sd = null;
+ } else if (ServiceDescriptions.PROPERTY_QNAME.equals(name)) {
+ if (sd != null && propertyName != null) {
+ if (propertyValue == null) {
+ throw new IllegalArgumentException("No value is defined for " + propertyName);
+ }
+ sd.getProperties().put(propertyName, propertyValue);
+ }
+ propertyName = null;
+ propertyType = "String";
+ propertyValue = null;
+ multiValued = false;
+ } else if (ServiceDescriptions.XML_QNAME.equals(name)) {
+ xml = false;
+ } else if (ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
+ return sds;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return sds;
+ }
+ }
+ }
+
+ private Object getPropertyValue(XMLStreamReader reader, String propertyName, String propertyLiteral, String propType) {
+ Object propertyValue = null;
+ propertyValue = propertyLiteral;
+ if ("Integer".equals(propType) || "int".equals(propType)) {
+ propertyValue = Integer.valueOf(propertyLiteral);
+ } else if ("Long".equals(propType) || "long".equals(propType)) {
+ propertyValue = Long.valueOf(propertyLiteral);
+ } else if ("Float".equals(propType) || "float".equals(propType)) {
+ propertyValue = Float.valueOf(propertyLiteral);
+ } else if ("Double".equals(propType) || "double".equals(propType)) {
+ propertyValue = Double.valueOf(propertyLiteral);
+ } else if ("Short".equals(propType) || "short".equals(propType)) {
+ propertyValue = Short.valueOf(propertyLiteral);
+ } else if ("Character".equals(propType) || "char".equals(propType)) {
+ propertyValue = propertyLiteral.charAt(0);
+ } else if ("Byte".equals(propType) || "byte".equals(propType)) {
+ propertyValue = Byte.valueOf(propertyLiteral);
+ } else if ("Boolean".equals(propType) || "boolean".equals(propType)) {
+ propertyValue = Boolean.valueOf(propertyLiteral);
+ }
+ if (propertyName.endsWith(".intents")) {
+ propertyValue = toQNames(reader, propertyLiteral);
+ }
+ if (Constants.OBJECTCLASS.equals(propertyName)) {
+ return propertyLiteral.split("( |\t|\n|\r|\f)+");
+ }
+ return propertyValue;
+ }
+
+ /**
+ * Convert ns1:e1 ns2:e2 to {http://ns1}e1 {http://ns2}e2
+ * @param reader
+ * @param value
+ * @return
+ */
+ private String toQNames(XMLStreamReader reader, String value) {
+ if (value == null) {
+ return null;
+ }
+ StringBuffer sb = new StringBuffer();
+ for (StringTokenizer tokens = new StringTokenizer(value, " \t\n\r\f,"); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ sb.append(qname.toString()).append(' ');
+ }
+ return sb.toString().trim();
+ }
+
+ public QName getArtifactType() {
+ return ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME;
+ }
+
+ public void write(ServiceDescriptions model, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ // TODO: To be implemented
+ }
+
+ public Class<ServiceDescriptions> getModelType() {
+ return ServiceDescriptions.class;
+ }
+
+ public void resolve(ServiceDescriptions model, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
new file mode 100644
index 0000000000..8718e58d8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
@@ -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.
+-->
+<sca:definitions xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://www.osgi.org/xmlns/sca/intents/v1.0.0">
+
+ <intent name="passByReference" constrains="sca:implementation"
+ intentType="implementation">
+ <description>
+ An OSGi intent to pass data by reference
+ </description>
+ </intent>
+
+ <intent name="passByValue" constrains="sca:implementation"
+ intentType="implementation">
+ <description>
+ An OSGi intent to pass data by value
+ </description>
+ </intent>
+
+</sca:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..e8973a91db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.osgi,model=org.apache.tuscany.sca.implementation.osgi.OSGiImplementation
+org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsProcessor;qname=http://www.osgi.org/xmlns/rsa/v1.0.0#endpoint-descriptions,model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions
+org.apache.tuscany.sca.implementation.osgi.xml.OSGiPropertyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#osgi.property,model=org.apache.tuscany.sca.implementation.osgi.OSGiProperty
+org.apache.tuscany.sca.implementation.osgi.xml.SCAConfigProcessor;qname=http://www.osgi.org/xmlns/scact/v1.0.0#sca-config,model=org.apache.tuscany.sca.implementation.osgi.SCAConfig
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..7e7a20b69c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsDocumentProcessor;type=/OSGI-INF/remote-service/*.xml,model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..78e47fed7e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/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.implementation.osgi.xml.ServiceDescriptionsModelResolver;model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory
new file mode 100644
index 0000000000..7c6660980b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory
@@ -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.
+
+org.apache.tuscany.sca.implementation.osgi.DefaultOSGiImplementationFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory
new file mode 100644
index 0000000000..47193ece15
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory
@@ -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.implementation.osgi.DefaultServiceDescriptionsFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties
new file mode 100644
index 0000000000..a406ea21c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties
@@ -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.
+#
+#
+ContributionReadException = ContributionReadException occured due to:
+ContributionResolveException = ContributionResolveException occured due to:
+PropertyShouldSpecifySR = Properties in implementation.osgi should specify service or reference
+CouldNotLocateOSGiBundle = Could not locate OSGi bundle: {0}
+MissingComponentTypeFile = Missing .componentType side file: {0}
+OSGiFrameworkNotStarted = OSGi Framework is not started \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java
new file mode 100644
index 0000000000..656b78b717
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.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 calculator.dosgi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService extends Remote {
+
+ double add(double n1, double n2) throws RemoteException;
+
+ double subtract(double n1, double n2) throws RemoteException;
+
+ double multiply(double n1, double n2) throws RemoteException;
+
+ double divide(double n1, double n2) throws RemoteException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the add service
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the divide service
+ */
+@Remotable
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the multiply service
+ */
+@Remotable
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the subtract service
+ */
+@Remotable
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java
new file mode 100644
index 0000000000..224467181b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.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.sca.implementation.osgi.xml;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class BluePrintComponentsProcessorTestCase {
+ private static final String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<components xmlns=\"http://www.osgi.org/xmlns/blueprint/v1.0.0\">"
+ + "<component id=\"CalculatorComponent\" class=\"calculator.dosgi.impl.CalculatorServiceImpl\">"
+ + "<property name=\"addService\" ref=\"AddService\" />"
+ + "<property name=\"subtractService\" ref=\"SubtractService\" />"
+ + "<property name=\"multiplyService\" ref=\"MultiplyService\" />"
+ + "<property name=\"divideService\" ref=\"DivideService\" />"
+ + "</component>"
+ + "<service id=\"CalculatorService\" ref=\"CalculatorComponent\" interface=\"calculator.dosgi.CalculatorService\">"
+ + "</service>"
+ + "<reference id=\"AddService\" interface=\"calculator.dosgi.operations.AddService\">"
+ + "</reference>"
+ + "<reference id=\"SubtractService\" interface=\"calculator.dosgi.operations.SubtractService\">"
+ + "</reference>"
+ + "<reference id=\"MultiplyService\" interface=\"calculator.dosgi.operations.MultiplyService\">"
+ + "</reference>"
+ + "<reference id=\"DivideService\" interface=\"calculator.dosgi.operations.DivideService\">"
+ + "</reference>"
+ + "</components>";
+ private static XMLStreamReader reader;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ reader = factory.createXMLStreamReader(new StringReader(xml));
+ }
+
+ @Test
+ public void testLoad() throws Exception {
+ BluePrintComponentsProcessor processor =
+ new BluePrintComponentsProcessor(new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()));
+ ComponentType ct = processor.read(reader, new ProcessorContext());
+ Assert.assertEquals(1, ct.getServices().size());
+ Assert.assertEquals(4, ct.getReferences().size());
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java
new file mode 100644
index 0000000000..ef49121c2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.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.sca.implementation.osgi.xml;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class OSGiComponentProcessorTestCase {
+ private static final String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<scr:component name=\"CalculatorComponent\""
+ + " xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.0.0\">"
+ + "<implementation class=\"calculator.dosgi.CalculatorServiceDSImpl\" />"
+ + "<service>"
+ + "<provide interface=\"calculator.dosgi.CalculatorService\" />"
+ + "</service>"
+ + "<reference name=\"addService\" interface=\"calculator.dosgi.operations.AddService\""
+ + " bind=\"setAddService\" unbind=\"unsetAddService\" policy=\"dynamic\" />"
+ + "<reference name=\"subtractService\" interface=\"calculator.dosgi.operations.SubtractService\""
+ + " bind=\"setSubtractService\" unbind=\"unsetSubtractService\" policy=\"dynamic\" />"
+ + "<reference name=\"multiplyService\" interface=\"calculator.dosgi.operations.MultiplyService\""
+ + " bind=\"setMultiplyService\" unbind=\"unsetMultiplyService\" policy=\"dynamic\" />"
+ + "<reference name=\"divideService\" interface=\"calculator.dosgi.operations.DivideService\""
+ + " bind=\"setDivideService\" unbind=\"unsetDivideService\" policy=\"dynamic\" />"
+ + "</scr:component>";
+
+ private static XMLStreamReader reader;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ reader = factory.createXMLStreamReader(new StringReader(xml));
+ }
+
+ @Test
+ public void testLoad() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ OSGiComponentProcessor processor =
+ new OSGiComponentProcessor(new DefaultFactoryExtensionPoint(registry));
+ ComponentType ct = processor.read(reader, new ProcessorContext(registry));
+ Assert.assertEquals(1, ct.getServices().size());
+ Assert.assertEquals(4, ct.getReferences().size());
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
new file mode 100644
index 0000000000..614f243eb3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test reading OSGi implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiReadImplTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE);
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ reader.close();
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("OSGI-INF/sca/bundle.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ComponentType componentType = (ComponentType)staxProcessor.read(reader, context);
+ assertNotNull(componentType);
+
+ assertEquals(2, componentType.getServices().get(0).getExtensions().size());
+
+ //write composite back
+ StringWriter stringWriter = new StringWriter();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(stringWriter);
+ staxProcessor.write(componentType, writer, context);
+ stringWriter.close();
+
+ //read from the output from write
+ reader = inputFactory.createXMLStreamReader(new StringReader(stringWriter.toString()));
+ componentType = (ComponentType)staxProcessor.read(reader, context);
+ assertNotNull(componentType);
+
+ assertEquals(2, componentType.getServices().get(0).getExtensions().size());
+
+ reader.close();
+ }
+
+ @Test
+ public void testReadAndResolveComposite() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+
+ is = getClass().getClassLoader().getResourceAsStream("OSGI-INF/sca/bundle.componentType");
+ reader = inputFactory.createXMLStreamReader(is);
+ ComponentType componentType = (ComponentType)staxProcessor.read(reader, context);
+
+ assertEquals(1, componentType.getServices().size());
+ Object prop1 = componentType.getServices().get(0).getExtensions().get(0);
+ assertTrue(prop1 instanceof OSGiProperty);
+ OSGiProperty osgiProp1 = (OSGiProperty)prop1;
+ assertEquals("1", osgiProp1.getValue());
+ assertEquals("prop1", osgiProp1.getName());
+
+ assertEquals(4, componentType.getReferences().size());
+ Object prop2 = componentType.getReferences().get(0).getExtensions().get(1);
+ assertTrue(prop2 instanceof OSGiProperty);
+ OSGiProperty osgiProp2 = (OSGiProperty)prop2;
+ assertEquals("ABC", osgiProp2.getValue());
+ assertEquals("prop2", osgiProp2.getName());
+
+ ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
+ staxProcessor.resolve(componentType, resolver, context);
+ resolver.addModel(componentType, context);
+
+ staxProcessor.resolve(composite, resolver, context);
+
+ reader.close();
+ }
+
+ @Test
+ public void testReadOSGiImplementation() throws Exception {
+
+ String str =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<implementation.osgi xmlns=\"http://tuscany.apache.org/xmlns/sca/1.1\" targetNamespace=\"http://test\" "
+ + "bundleSymbolicName=\"osgi.test\" "
+ + "bundleVersion=\"1.0.0\" "
+ + "/>";
+ ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes());
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ reader.nextTag();
+
+ OSGiImplementation osgiImpl = (OSGiImplementation)staxProcessor.read(reader, context);
+
+ assertEquals(osgiImpl.getBundleSymbolicName(), "osgi.test");
+ assertEquals(osgiImpl.getBundleVersion(), "1.0.0");
+
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
+ staxProcessor.write(osgiImpl, writer, context);
+ writer.flush();
+ writer.close();
+ Assert.assertTrue(sw.toString().contains("bundleSymbolicName=\"osgi.test\" bundleVersion=\"1.0.0\""));
+
+ reader.close();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
new file mode 100644
index 0000000000..0e7acc354a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.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.sca.implementation.osgi.xml;
+
+import java.io.StringReader;
+import java.util.List;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class ServiceDescriptionsTestCase {
+ private static final String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<endpoint-descriptions xmlns=\"http://www.osgi.org/xmlns/rsa/v1.0.0\" "
+ + "xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\">"
+ + "<endpoint-description>"
+ + "<property name=\"objectClass\" value=\"calculator.operations.AddService\"/>"
+ + "<property name=\"service.intents\" value=\"sca:SOAP sca:HTTP\"/>"
+ + "<property name=\"service.imported.configs\" value=\"org.osgi.sca\"/>"
+ + "</endpoint-description>"
+ + "<endpoint-description>"
+ + "<property name=\"service.intents\">"
+ + " <list>"
+ + " <value>SOAP</value>"
+ + " <value>HTTP</value>"
+ + " </list>"
+ + "</property>"
+ + "<property name=\"endpoint.id\" value=\"http://ws.acme.com:9000/hello\"/>"
+ + "<property name=\"objectClass\" value=\"com.acme.Foo\"/>"
+ + "<property name=\"endpoint.package.version.com.acme\" value=\"4.2\"/>"
+ + "<property name=\"service.imported.configs\" value=\"com.acme\"/>"
+ + "<property name=\"com.acme.ws.xml\">"
+ + "<xml>"
+ + " <config xmlns=\"http://acme.com/defs\">"
+ + " <port>1029</port>"
+ + " <host>www.acme.com</host>"
+ + " </config>"
+ + " </xml>"
+ + " </property>"
+ + "</endpoint-description>"
+ + "</endpoint-descriptions>";
+
+ private static ServiceDescriptionsProcessor processor;
+ private static XMLStreamReader reader;
+
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, factory, null);
+
+ processor = new ServiceDescriptionsProcessor(extensionPoints, staxProcessor);
+
+ reader = factory.createXMLStreamReader(new StringReader(xml));
+ }
+
+ @Test
+ public void testLoad() throws Exception {
+ List<ServiceDescription> descriptions = processor.read(reader, context);
+ Assert.assertEquals(2, descriptions.size());
+ System.out.println(descriptions);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java
new file mode 100644
index 0000000000..17fef8a05c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.xml;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationImpl;
+
+/**
+ * A default implementation of an artifact resolver, based on a map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestModelResolver implements ModelResolver {
+ private static final long serialVersionUID = -7826976465762296634L;
+
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ private WeakReference<ClassLoader> classLoader;
+
+ public TestModelResolver(ClassLoader classLoader) {
+ this.classLoader = new WeakReference<ClassLoader>(classLoader);
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+
+ if (unresolved instanceof OSGiImplementationImpl && !(resolved instanceof OSGiImplementationImpl)) {
+
+ OSGiImplementationImpl impl = ((OSGiImplementationImpl)unresolved);
+ ComponentType componentType = (ComponentType)resolved;
+
+ List<Property> properties = componentType.getProperties();
+ for (Property property : properties) {
+ impl.getProperties().add(property);
+ }
+ impl.setUnresolved(false);
+ return unresolved;
+ }
+
+ // Return the resolved object
+ return modelClass.cast(resolved);
+
+ } else if (unresolved instanceof ClassReference) {
+
+ // Load a class on demand
+ ClassReference classReference = (ClassReference)unresolved;
+ Class clazz;
+ try {
+ clazz = Class.forName(classReference.getClassName(), true, classLoader.get());
+ } catch (ClassNotFoundException e) {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+
+ // Store a new ClassReference wrapping the loaded class
+ resolved = new ClassReference(clazz);
+ map.put(resolved, resolved);
+
+ // Return the resolved ClassReference
+ return modelClass.cast(resolved);
+
+ } else {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(resolved);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml
new file mode 100644
index 0000000000..3e537df732
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<scr:component name="CalculatorComponent"
+ xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.CalculatorServiceDSImpl" />
+ <service>
+ <provide interface="calculator.dosgi.CalculatorService" />
+ </service>
+
+ <reference name="addService" interface="calculator.dosgi.operations.AddService" bind="setAddService" unbind="unsetAddService"
+ policy="dynamic" />
+ <reference name="subtractService" interface="calculator.dosgi.operations.SubtractService" bind="setSubtractService"
+ unbind="unsetSubtractService" policy="dynamic" />
+ <reference name="multiplyService" interface="calculator.dosgi.operations.MultiplyService" bind="setMultiplyService"
+ unbind="unsetMultiplyService" policy="dynamic" />
+ <reference name="divideService" interface="calculator.dosgi.operations.DivideService" bind="setDivideService"
+ unbind="unsetDivideService" policy="dynamic" />
+
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType
new file mode 100644
index 0000000000..401809c197
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType
@@ -0,0 +1,63 @@
+<?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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
+ <!-- The service elment defines an SCA view of the OSGi service -->
+ <service name="Calculator">
+ <!-- The interface will be mapped into the OSGi service class -->
+ <interface.java interface="calculator.dosgi.CalculatorService"/>
+ <!-- The list of OSGi properties -->
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+
+ <!-- The reference elment defines an SCA proxy to a remote OSGi service -->
+ <reference name="addService">
+ <interface.java interface="calculator.dosgi.operations.AddService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="subtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="multiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="divideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+</componentType>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/osgitest.composite b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/osgitest.composite
new file mode 100644
index 0000000000..7c54e46a54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-osgi/src/test/resources/osgitest.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://test"
+ name="OSGiTestComposite">
+
+ <component name="OSGiTestServiceComponent">
+ <tuscany:implementation.osgi bundleVersion="1.0.0"
+ bundleSymbolicName="osgi.test" />
+
+ <property name="currency" type="xsd:string">USD</property>
+ <property name="exchangeRate" type="xsd:double">2.0</property>
+
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/LICENSE
new file mode 100644
index 0000000000..2c5d23a2b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/LICENSE
@@ -0,0 +1,246 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+=================================================================================================================
+
+This module includes one file under the following BSD license:
+
+Copyright (c) Django Software Foundation and individual contributors.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of Django nor the names of its contributors may be used
+ to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+
+=================================================================================================================
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..8155c1deb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Python Implementation Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Python Implementation Runtime
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.python.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/NOTICE
new file mode 100644
index 0000000000..aaa8297e5e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/NOTICE
@@ -0,0 +1,13 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the BSD license
+(see the LICENSE file contained in this distribution), with
+the following copyright:
+
+Copyright (c) Django Software Foundation and individual contributors.
+All rights reserved.
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/jython-install b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/jython-install
new file mode 100755
index 0000000000..dc89bb3ec1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/jython-install
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Install Jython 2.5.2b1 jar in the local Maven repository, as it's not
+# yet available in a central Maven repository
+mkdir -p target
+cd target
+wget http://sourceforge.net/projects/jython/files/jython-dev/2.5.2b1/jython_installer-2.5.2b1.jar/download
+java -jar jython_installer-2.5.2b1.jar -s -d jython -t standalone
+mvn install:install-file -DgroupId=org.python -DartifactId=jython -Dversion=2.5.2 -Dpackaging=jar -Dfile=jython/jython.jar
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/pom.xml
new file mode 100644
index 0000000000..9412954e28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/pom.xml
@@ -0,0 +1,100 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-python-runtime</artifactId>
+ <name>Apache Tuscany SCA Python Implementation Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-python</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython</artifactId>
+ <version>2.5.2-beta1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProvider.java
new file mode 100644
index 0000000000..7d381ac9d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProvider.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.python.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.python.PythonEval;
+import org.apache.tuscany.sca.implementation.python.PythonImplementation;
+import org.apache.tuscany.sca.implementation.python.PythonProperty;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.python.core.Py;
+import org.python.core.PyObject;
+import org.python.core.PyString;
+import org.python.core.PySystemState;
+import org.python.core.PyTuple;
+import org.python.util.PythonInterpreter;
+
+/**
+ * Implementation provider for Python component implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+class PythonImplementationProvider implements ImplementationProvider {
+ final RuntimeComponent component;
+ final PythonImplementation implementation;
+ PythonInterpreter python;
+ PyObject callable;
+ ProxyFactory pxFactory;
+
+ PythonImplementationProvider(final RuntimeComponent comp, final PythonImplementation impl, ProxyFactory pxf) {
+ component = comp;
+ implementation = impl;
+ pxFactory = pxf;
+ }
+
+ public void start() {
+ final PySystemState pss = new PySystemState();
+ pss.path.insert(0, new PyString(implementation.getLocation()));
+ pss.path.insert(0, new PyString(getClass().getProtectionDomain().getCodeSource().getLocation().getFile()));
+ python = new PythonInterpreter(null, pss);
+ python.exec("from invoker import *");
+
+ final List<PyObject> px = new ArrayList<PyObject>();
+ for(final ComponentReference r: component.getReferences()) {
+ final PythonEval pe = pxFactory.createProxy(PythonEval.class, (RuntimeEndpointReference)r.getEndpointReferences().get(0));
+ px.add(Py.java2py(new PythonEval() {
+ @Override
+ public String eval(final String args) throws Exception {
+ final String v = pe.eval(args);
+ return v;
+ }
+ }));
+ }
+ final List<PyObject> pr = new ArrayList<PyObject>();
+ for(final ComponentProperty p: component.getProperties()) {
+ final String v = String.valueOf(p.getValue());
+ pr.add(Py.java2py(new PythonProperty() {
+ @Override
+ public String eval() {
+ return v;
+ }
+ }));
+ }
+
+ PyObject mkc = python.get("mkcomponent");
+ callable = mkc.__call__(new PyString(component.getName()), new PyString(implementation.getScript()), new PyTuple(px.toArray(new PyObject[0])), new PyTuple(pr.toArray(new PyObject[0])));
+ }
+
+ public void stop() {
+ python.cleanup();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public Invoker createInvoker(final RuntimeComponentService s, final Operation op) {
+ return new PythonInvoker(python, callable, op);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProviderFactory.java
new file mode 100644
index 0000000000..752e3fd899
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProviderFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.python.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.python.PythonImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * A factory for Python implementation providers.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PythonImplementationProviderFactory implements ImplementationProviderFactory<PythonImplementation> {
+ final ProxyFactory pxFactory;
+
+ public PythonImplementationProviderFactory(final ExtensionPointRegistry ep) {
+ pxFactory = ExtensibleProxyFactory.getInstance(ep);
+ }
+
+ public ImplementationProvider createImplementationProvider(final RuntimeComponent comp, final PythonImplementation impl) {
+ return new PythonImplementationProvider(comp, impl, pxFactory);
+ }
+
+ public Class<PythonImplementation> getModelType() {
+ return PythonImplementation.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonInvoker.java
new file mode 100644
index 0000000000..a49e5e3296
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonInvoker.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.python.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.python.core.PyObject;
+import org.python.core.PyString;
+import org.python.util.PythonInterpreter;
+
+/**
+ * An invoker for Python components.
+ *
+ * @version $Rev$ $Date$
+ */
+class PythonInvoker implements Invoker {
+ final PythonInterpreter python;
+ final PyObject callable;
+ final Operation operation;
+
+ PythonInvoker(final PythonInterpreter py, final PyObject c, final Operation op) {
+ python = py;
+ callable = c;
+ operation = op;
+ }
+
+ String apply(final String req) {
+ PyObject r = callable.__call__(new PyString(req));
+ return r.toString();
+ }
+
+ public Message invoke(final Message msg) {
+ try {
+ msg.setBody(apply((String)((Object[])msg.getBody())[0]));
+ } catch(Exception e) {
+ e.printStackTrace();
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..3c1e6c4406
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 provider for Python components
+org.apache.tuscany.sca.implementation.python.provider.PythonImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.python.PythonImplementation
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/atomutil.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/atomutil.py
new file mode 100644
index 0000000000..6c0a7c9a81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/atomutil.py
@@ -0,0 +1,120 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# ATOM data conversion functions
+
+from util import *
+from elemutil import *
+from xmlutil import *
+
+# Convert a list of elements to a list of values representing an ATOM entry
+def entryElementsToValues(e):
+ lt = filter(selector((element, "'title")), e)
+ t = "" if isNil(lt) else elementValue(car(lt))
+ li = filter(selector((element, "'id")), e)
+ i = "" if isNil(li) else elementValue(car(li))
+ lc = filter(selector((element, "'content")), e)
+ return (t, i, elementValue(car(lc)))
+
+# Convert a list of elements to a list of values representing ATOM entries
+def entriesElementsToValues(e):
+ if isNil(e):
+ return e
+ return cons(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e)))
+
+# Convert a list of strings to a list of values representing an ATOM entry
+def readATOMEntry(l):
+ e = readXML(l)
+ if isNil(e):
+ return ()
+ return entryElementsToValues(car(e))
+
+# Convert a list of values representy an ATOM entry to a value
+def entryValue(e):
+ v = elementsToValues((caddr(e),))
+ return cons(car(e), (cadr(e), cdr(car(v))))
+
+# Return true if a list of strings represents an ATOM feed
+def isATOMFeed(l):
+ if isNil(l):
+ return False
+ if car(l)[0:5] != "<?xml":
+ return False
+ return contains(car(l), "<feed")
+
+# Convert a list of strings to a list of values representing an ATOM feed
+def readATOMFeed(l):
+ f = readXML(l)
+ if isNil(f):
+ return ()
+ t = filter(selector((element, "'title")), car(f))
+ i = filter(selector((element, "'id")), car(f))
+ e = filter(selector((element, "'entry")), car(f))
+ if isNil(e):
+ return (elementValue(car(t)), elementValue(car(i)))
+ return cons(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e)))
+
+# Convert an ATOM feed containing elements to an ATOM feed containing values
+def feedValuesLoop(e):
+ if (isNil(e)):
+ return e
+ return cons(entryValue(car(e)), feedValuesLoop(cdr(e)))
+
+def feedValues(e):
+ return cons(car(e), cons(cadr(e), feedValuesLoop(cddr(e))))
+
+# Convert a list of values representy an ATOM entry to a list of elements
+def entryElement(l):
+ return (element, "'entry", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
+ (element, "'title", (attribute, "'type", "text"), car(l)),
+ (element, "'id", cadr(l)),
+ (element, "'content", (attribute, "'type", ("application/xml" if isList(caddr(l)) else "text")), caddr(l)),
+ (element, "'link", (attribute, "'href", cadr(l))))
+
+# Convert a list of values representing ATOM entries to a list of elements
+def entriesElements(l):
+ if isNil(l):
+ return l
+ return cons(entryElement(car(l)), entriesElements(cdr(l)))
+
+# Convert a list of values representing an ATOM entry to an ATOM entry
+def writeATOMEntry(l):
+ return writeXML((entryElement(l),), True)
+
+# Convert a list of values representing an ATOM feed to an ATOM feed
+def writeATOMFeed(l):
+ f = (element, "'feed", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
+ (element, "'title", (attribute, "'type", "text"), car(l)),
+ (element, "'id", cadr(l)))
+ if isNil(cddr(l)):
+ return writeXML((f,), True)
+ fe = append(f, entriesElements(cddr(l)))
+ return writeXML((fe,), True)
+
+# Convert an ATOM entry containing a value to an ATOM entry containing an item element
+def entryValuesToElements(v):
+ return cons(car(v), cons(cadr(v), valuesToElements((cons("'item", caddr(v)),))))
+
+# Convert an ATOM feed containing values to an ATOM feed containing elements
+def feedValuesToElementsLoop(v):
+ if isNil(v):
+ return v
+ return cons(entryValuesToElements(car(v)), feedValuesToElementsLoop(cdr(v)))
+
+def feedValuesToElements(v):
+ return cons(car(v), cons(cadr(v), feedValuesToElementsLoop(cddr(v))))
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/__init__.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/__init__.py
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/__init__.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/__init__.py
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/__init__.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/__init__.py
new file mode 100644
index 0000000000..15b7173976
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/__init__.py
@@ -0,0 +1,252 @@
+r"""
+A simple, fast, extensible JSON encoder and decoder
+
+JSON (JavaScript Object Notation) <http://json.org> is a subset of
+JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
+interchange format.
+
+simplejson exposes an API familiar to uses of the standard library
+marshal and pickle modules.
+
+Encoding basic Python object hierarchies::
+
+ >>> import simplejson
+ >>> simplejson.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
+ '["foo", {"bar": ["baz", null, 1.0, 2]}]'
+ >>> print simplejson.dumps("\"foo\bar")
+ "\"foo\bar"
+ >>> print simplejson.dumps(u'\u1234')
+ "\u1234"
+ >>> print simplejson.dumps('\\')
+ "\\"
+ >>> print simplejson.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
+ {"a": 0, "b": 0, "c": 0}
+ >>> from StringIO import StringIO
+ >>> io = StringIO()
+ >>> simplejson.dump(['streaming API'], io)
+ >>> io.getvalue()
+ '["streaming API"]'
+
+Compact encoding::
+
+ >>> import simplejson
+ >>> simplejson.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+ '[1,2,3,{"4":5,"6":7}]'
+
+Pretty printing::
+
+ >>> import simplejson
+ >>> print simplejson.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)
+ {
+ "4": 5,
+ "6": 7
+ }
+
+Decoding JSON::
+
+ >>> import simplejson
+ >>> simplejson.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
+ [u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
+ >>> simplejson.loads('"\\"foo\\bar"')
+ u'"foo\x08ar'
+ >>> from StringIO import StringIO
+ >>> io = StringIO('["streaming API"]')
+ >>> simplejson.load(io)
+ [u'streaming API']
+
+Specializing JSON object decoding::
+
+ >>> import simplejson
+ >>> def as_complex(dct):
+ ... if '__complex__' in dct:
+ ... return complex(dct['real'], dct['imag'])
+ ... return dct
+ ...
+ >>> simplejson.loads('{"__complex__": true, "real": 1, "imag": 2}',
+ ... object_hook=as_complex)
+ (1+2j)
+
+Extending JSONEncoder::
+
+ >>> import simplejson
+ >>> class ComplexEncoder(simplejson.JSONEncoder):
+ ... def default(self, obj):
+ ... if isinstance(obj, complex):
+ ... return [obj.real, obj.imag]
+ ... return simplejson.JSONEncoder.default(self, obj)
+ ...
+ >>> dumps(2 + 1j, cls=ComplexEncoder)
+ '[2.0, 1.0]'
+ >>> ComplexEncoder().encode(2 + 1j)
+ '[2.0, 1.0]'
+ >>> list(ComplexEncoder().iterencode(2 + 1j))
+ ['[', '2.0', ', ', '1.0', ']']
+
+
+Note that the JSON produced by this module's default settings
+is a subset of YAML, so it may be used as a serializer for that as well.
+"""
+__version__ = '1.5'
+__all__ = [
+ 'dump', 'dumps', 'load', 'loads',
+ 'JSONDecoder', 'JSONEncoder',
+]
+
+from django.utils.simplejson.decoder import JSONDecoder
+from django.utils.simplejson.encoder import JSONEncoder
+
+def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
+ allow_nan=True, cls=None, indent=None, **kw):
+ """
+ Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
+ ``.write()``-supporting file-like object).
+
+ If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
+ (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
+ will be skipped instead of raising a ``TypeError``.
+
+ If ``ensure_ascii`` is ``False``, then the some chunks written to ``fp``
+ may be ``unicode`` instances, subject to normal Python ``str`` to
+ ``unicode`` coercion rules. Unless ``fp.write()`` explicitly
+ understands ``unicode`` (as in ``codecs.getwriter()``) this is likely
+ to cause an error.
+
+ If ``check_circular`` is ``False``, then the circular reference check
+ for container types will be skipped and a circular reference will
+ result in an ``OverflowError`` (or worse).
+
+ If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to
+ serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``)
+ in strict compliance of the JSON specification, instead of using the
+ JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
+
+ If ``indent`` is a non-negative integer, then JSON array elements and object
+ members will be pretty-printed with that indent level. An indent level
+ of 0 will only insert newlines. ``None`` is the most compact representation.
+
+ To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
+ ``.default()`` method to serialize additional types), specify it with
+ the ``cls`` kwarg.
+ """
+ if cls is None:
+ cls = JSONEncoder
+ iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii,
+ check_circular=check_circular, allow_nan=allow_nan, indent=indent,
+ **kw).iterencode(obj)
+ # could accelerate with writelines in some versions of Python, at
+ # a debuggability cost
+ for chunk in iterable:
+ fp.write(chunk)
+
+def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
+ allow_nan=True, cls=None, indent=None, separators=None, **kw):
+ """
+ Serialize ``obj`` to a JSON formatted ``str``.
+
+ If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
+ (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
+ will be skipped instead of raising a ``TypeError``.
+
+ If ``ensure_ascii`` is ``False``, then the return value will be a
+ ``unicode`` instance subject to normal Python ``str`` to ``unicode``
+ coercion rules instead of being escaped to an ASCII ``str``.
+
+ If ``check_circular`` is ``False``, then the circular reference check
+ for container types will be skipped and a circular reference will
+ result in an ``OverflowError`` (or worse).
+
+ If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to
+ serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
+ strict compliance of the JSON specification, instead of using the
+ JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
+
+ If ``indent`` is a non-negative integer, then JSON array elements and
+ object members will be pretty-printed with that indent level. An indent
+ level of 0 will only insert newlines. ``None`` is the most compact
+ representation.
+
+ If ``separators`` is an ``(item_separator, dict_separator)`` tuple
+ then it will be used instead of the default ``(', ', ': ')`` separators.
+ ``(',', ':')`` is the most compact JSON representation.
+
+ To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
+ ``.default()`` method to serialize additional types), specify it with
+ the ``cls`` kwarg.
+ """
+ if cls is None:
+ cls = JSONEncoder
+ return cls(
+ skipkeys=skipkeys, ensure_ascii=ensure_ascii,
+ check_circular=check_circular, allow_nan=allow_nan, indent=indent,
+ separators=separators,
+ **kw).encode(obj)
+
+def load(fp, encoding=None, cls=None, object_hook=None, **kw):
+ """
+ Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
+ a JSON document) to a Python object.
+
+ If the contents of ``fp`` is encoded with an ASCII based encoding other
+ than utf-8 (e.g. latin-1), then an appropriate ``encoding`` name must
+ be specified. Encodings that are not ASCII based (such as UCS-2) are
+ not allowed, and should be wrapped with
+ ``codecs.getreader(fp)(encoding)``, or simply decoded to a ``unicode``
+ object and passed to ``loads()``
+
+ ``object_hook`` is an optional function that will be called with the
+ result of any object literal decode (a ``dict``). The return value of
+ ``object_hook`` will be used instead of the ``dict``. This feature
+ can be used to implement custom decoders (e.g. JSON-RPC class hinting).
+
+ To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
+ kwarg.
+ """
+ if cls is None:
+ cls = JSONDecoder
+ if object_hook is not None:
+ kw['object_hook'] = object_hook
+ return cls(encoding=encoding, **kw).decode(fp.read())
+
+def loads(s, encoding=None, cls=None, object_hook=None, **kw):
+ """
+ Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON
+ document) to a Python object.
+
+ If ``s`` is a ``str`` instance and is encoded with an ASCII based encoding
+ other than utf-8 (e.g. latin-1) then an appropriate ``encoding`` name
+ must be specified. Encodings that are not ASCII based (such as UCS-2)
+ are not allowed and should be decoded to ``unicode`` first.
+
+ ``object_hook`` is an optional function that will be called with the
+ result of any object literal decode (a ``dict``). The return value of
+ ``object_hook`` will be used instead of the ``dict``. This feature
+ can be used to implement custom decoders (e.g. JSON-RPC class hinting).
+
+ To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
+ kwarg.
+ """
+ if cls is None:
+ cls = JSONDecoder
+ if object_hook is not None:
+ kw['object_hook'] = object_hook
+ return cls(encoding=encoding, **kw).decode(s)
+
+def read(s):
+ """
+ json-py API compatibility hook. Use loads(s) instead.
+ """
+ import warnings
+ warnings.warn("simplejson.loads(s) should be used instead of read(s)",
+ DeprecationWarning)
+ return loads(s)
+
+def write(obj):
+ """
+ json-py API compatibility hook. Use dumps(s) instead.
+ """
+ import warnings
+ warnings.warn("simplejson.dumps(s) should be used instead of write(s)",
+ DeprecationWarning)
+ return dumps(obj)
+
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/decoder.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/decoder.py
new file mode 100644
index 0000000000..66f68a200b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/decoder.py
@@ -0,0 +1,273 @@
+"""
+Implementation of JSONDecoder
+"""
+import re
+
+from django.utils.simplejson.scanner import Scanner, pattern
+
+FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
+
+def _floatconstants():
+ import struct
+ import sys
+ _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
+ if sys.byteorder != 'big':
+ _BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
+ nan, inf = struct.unpack('dd', _BYTES)
+ return nan, inf, -inf
+
+NaN, PosInf, NegInf = _floatconstants()
+
+def linecol(doc, pos):
+ lineno = doc.count('\n', 0, pos) + 1
+ if lineno == 1:
+ colno = pos
+ else:
+ colno = pos - doc.rindex('\n', 0, pos)
+ return lineno, colno
+
+def errmsg(msg, doc, pos, end=None):
+ lineno, colno = linecol(doc, pos)
+ if end is None:
+ return '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos)
+ endlineno, endcolno = linecol(doc, end)
+ return '%s: line %d column %d - line %d column %d (char %d - %d)' % (
+ msg, lineno, colno, endlineno, endcolno, pos, end)
+
+_CONSTANTS = {
+ '-Infinity': NegInf,
+ 'Infinity': PosInf,
+ 'NaN': NaN,
+ 'true': True,
+ 'false': False,
+ 'null': None,
+}
+
+def JSONConstant(match, context, c=_CONSTANTS):
+ return c[match.group(0)], None
+pattern('(-?Infinity|NaN|true|false|null)')(JSONConstant)
+
+def JSONNumber(match, context):
+ match = JSONNumber.regex.match(match.string, *match.span())
+ integer, frac, exp = match.groups()
+ if frac or exp:
+ res = float(integer + (frac or '') + (exp or ''))
+ else:
+ res = int(integer)
+ return res, None
+pattern(r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?')(JSONNumber)
+
+STRINGCHUNK = re.compile(r'(.*?)(["\\])', FLAGS)
+BACKSLASH = {
+ '"': u'"', '\\': u'\\', '/': u'/',
+ 'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t',
+}
+
+DEFAULT_ENCODING = "utf-8"
+
+def scanstring(s, end, encoding=None, _b=BACKSLASH, _m=STRINGCHUNK.match):
+ if encoding is None:
+ encoding = DEFAULT_ENCODING
+ chunks = []
+ _append = chunks.append
+ begin = end - 1
+ while 1:
+ chunk = _m(s, end)
+ if chunk is None:
+ raise ValueError(
+ errmsg("Unterminated string starting at", s, begin))
+ end = chunk.end()
+ content, terminator = chunk.groups()
+ if content:
+ if not isinstance(content, unicode):
+ content = unicode(content, encoding)
+ _append(content)
+ if terminator == '"':
+ break
+ try:
+ esc = s[end]
+ except IndexError:
+ raise ValueError(
+ errmsg("Unterminated string starting at", s, begin))
+ if esc != 'u':
+ try:
+ m = _b[esc]
+ except KeyError:
+ raise ValueError(
+ errmsg("Invalid \\escape: %r" % (esc,), s, end))
+ end += 1
+ else:
+ esc = s[end + 1:end + 5]
+ try:
+ m = unichr(int(esc, 16))
+ if len(esc) != 4 or not esc.isalnum():
+ raise ValueError
+ except ValueError:
+ raise ValueError(errmsg("Invalid \\uXXXX escape", s, end))
+ end += 5
+ _append(m)
+ return u''.join(chunks), end
+
+def JSONString(match, context):
+ encoding = getattr(context, 'encoding', None)
+ return scanstring(match.string, match.end(), encoding)
+pattern(r'"')(JSONString)
+
+WHITESPACE = re.compile(r'\s*', FLAGS)
+
+def JSONObject(match, context, _w=WHITESPACE.match):
+ pairs = {}
+ s = match.string
+ end = _w(s, match.end()).end()
+ nextchar = s[end:end + 1]
+ # trivial empty object
+ if nextchar == '}':
+ return pairs, end + 1
+ if nextchar != '"':
+ raise ValueError(errmsg("Expecting property name", s, end))
+ end += 1
+ encoding = getattr(context, 'encoding', None)
+ iterscan = JSONScanner.iterscan
+ while True:
+ key, end = scanstring(s, end, encoding)
+ end = _w(s, end).end()
+ if s[end:end + 1] != ':':
+ raise ValueError(errmsg("Expecting : delimiter", s, end))
+ end = _w(s, end + 1).end()
+ try:
+ value, end = iterscan(s, idx=end, context=context).next()
+ except StopIteration:
+ raise ValueError(errmsg("Expecting object", s, end))
+ pairs[key] = value
+ end = _w(s, end).end()
+ nextchar = s[end:end + 1]
+ end += 1
+ if nextchar == '}':
+ break
+ if nextchar != ',':
+ raise ValueError(errmsg("Expecting , delimiter", s, end - 1))
+ end = _w(s, end).end()
+ nextchar = s[end:end + 1]
+ end += 1
+ if nextchar != '"':
+ raise ValueError(errmsg("Expecting property name", s, end - 1))
+ object_hook = getattr(context, 'object_hook', None)
+ if object_hook is not None:
+ pairs = object_hook(pairs)
+ return pairs, end
+pattern(r'{')(JSONObject)
+
+def JSONArray(match, context, _w=WHITESPACE.match):
+ values = []
+ s = match.string
+ end = _w(s, match.end()).end()
+ # look-ahead for trivial empty array
+ nextchar = s[end:end + 1]
+ if nextchar == ']':
+ return values, end + 1
+ iterscan = JSONScanner.iterscan
+ while True:
+ try:
+ value, end = iterscan(s, idx=end, context=context).next()
+ except StopIteration:
+ raise ValueError(errmsg("Expecting object", s, end))
+ values.append(value)
+ end = _w(s, end).end()
+ nextchar = s[end:end + 1]
+ end += 1
+ if nextchar == ']':
+ break
+ if nextchar != ',':
+ raise ValueError(errmsg("Expecting , delimiter", s, end))
+ end = _w(s, end).end()
+ return values, end
+pattern(r'\[')(JSONArray)
+
+ANYTHING = [
+ JSONObject,
+ JSONArray,
+ JSONString,
+ JSONConstant,
+ JSONNumber,
+]
+
+JSONScanner = Scanner(ANYTHING)
+
+class JSONDecoder(object):
+ """
+ Simple JSON <http://json.org> decoder
+
+ Performs the following translations in decoding:
+
+ +---------------+-------------------+
+ | JSON | Python |
+ +===============+===================+
+ | object | dict |
+ +---------------+-------------------+
+ | array | list |
+ +---------------+-------------------+
+ | string | unicode |
+ +---------------+-------------------+
+ | number (int) | int, long |
+ +---------------+-------------------+
+ | number (real) | float |
+ +---------------+-------------------+
+ | true | True |
+ +---------------+-------------------+
+ | false | False |
+ +---------------+-------------------+
+ | null | None |
+ +---------------+-------------------+
+
+ It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
+ their corresponding ``float`` values, which is outside the JSON spec.
+ """
+
+ _scanner = Scanner(ANYTHING)
+ __all__ = ['__init__', 'decode', 'raw_decode']
+
+ def __init__(self, encoding=None, object_hook=None):
+ """
+ ``encoding`` determines the encoding used to interpret any ``str``
+ objects decoded by this instance (utf-8 by default). It has no
+ effect when decoding ``unicode`` objects.
+
+ Note that currently only encodings that are a superset of ASCII work,
+ strings of other encodings should be passed in as ``unicode``.
+
+ ``object_hook``, if specified, will be called with the result
+ of every JSON object decoded and its return value will be used in
+ place of the given ``dict``. This can be used to provide custom
+ deserializations (e.g. to support JSON-RPC class hinting).
+ """
+ self.encoding = encoding
+ self.object_hook = object_hook
+
+ def decode(self, s, _w=WHITESPACE.match):
+ """
+ Return the Python representation of ``s`` (a ``str`` or ``unicode``
+ instance containing a JSON document)
+ """
+ obj, end = self.raw_decode(s, idx=_w(s, 0).end())
+ end = _w(s, end).end()
+ if end != len(s):
+ raise ValueError(errmsg("Extra data", s, end, len(s)))
+ return obj
+
+ def raw_decode(self, s, **kw):
+ """
+ Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
+ with a JSON document) and return a 2-tuple of the Python
+ representation and the index in ``s`` where the document ended.
+
+ This can be used to decode a JSON document from a string that may
+ have extraneous data at the end.
+ """
+ kw.setdefault('context', self)
+ try:
+ obj, end = self._scanner.iterscan(s, **kw).next()
+ except StopIteration:
+ raise ValueError("No JSON object could be decoded")
+ return obj, end
+
+__all__ = ['JSONDecoder']
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/encoder.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/encoder.py
new file mode 100644
index 0000000000..c83c6873eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/encoder.py
@@ -0,0 +1,331 @@
+"""
+Implementation of JSONEncoder
+"""
+import re
+
+ESCAPE = re.compile(r'[\x00-\x19\\"\b\f\n\r\t]')
+ESCAPE_ASCII = re.compile(r'([\\"/]|[^\ -~])')
+ESCAPE_DCT = {
+ # escape all forward slashes to prevent </script> attack
+ '/': '\\/',
+ '\\': '\\\\',
+ '"': '\\"',
+ '\b': '\\b',
+ '\f': '\\f',
+ '\n': '\\n',
+ '\r': '\\r',
+ '\t': '\\t',
+}
+for i in range(0x20):
+ ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))
+
+# assume this produces an infinity on all machines (probably not guaranteed)
+INFINITY = float('1e66666')
+
+def floatstr(o, allow_nan=True):
+ # Check for specials. Note that this type of test is processor- and/or
+ # platform-specific, so do tests which don't depend on the internals.
+
+ if o != o:
+ text = 'NaN'
+ elif o == INFINITY:
+ text = 'Infinity'
+ elif o == -INFINITY:
+ text = '-Infinity'
+ else:
+ return str(o)
+
+ if not allow_nan:
+ raise ValueError("Out of range float values are not JSON compliant: %r"
+ % (o,))
+
+ return text
+
+
+def encode_basestring(s):
+ """
+ Return a JSON representation of a Python string
+ """
+ def replace(match):
+ return ESCAPE_DCT[match.group(0)]
+ return '"' + ESCAPE.sub(replace, s) + '"'
+
+def encode_basestring_ascii(s):
+ def replace(match):
+ s = match.group(0)
+ try:
+ return ESCAPE_DCT[s]
+ except KeyError:
+ return '\\u%04x' % (ord(s),)
+ return '"' + str(ESCAPE_ASCII.sub(replace, s)) + '"'
+
+
+class JSONEncoder(object):
+ """
+ Extensible JSON <http://json.org> encoder for Python data structures.
+
+ Supports the following objects and types by default:
+
+ +-------------------+---------------+
+ | Python | JSON |
+ +===================+===============+
+ | dict | object |
+ +-------------------+---------------+
+ | list, tuple | array |
+ +-------------------+---------------+
+ | str, unicode | string |
+ +-------------------+---------------+
+ | int, long, float | number |
+ +-------------------+---------------+
+ | True | true |
+ +-------------------+---------------+
+ | False | false |
+ +-------------------+---------------+
+ | None | null |
+ +-------------------+---------------+
+
+ To extend this to recognize other objects, subclass and implement a
+ ``.default()`` method with another method that returns a serializable
+ object for ``o`` if possible, otherwise it should call the superclass
+ implementation (to raise ``TypeError``).
+ """
+ __all__ = ['__init__', 'default', 'encode', 'iterencode']
+ item_separator = ', '
+ key_separator = ': '
+ def __init__(self, skipkeys=False, ensure_ascii=True,
+ check_circular=True, allow_nan=True, sort_keys=False,
+ indent=None, separators=None):
+ """
+ Constructor for JSONEncoder, with sensible defaults.
+
+ If skipkeys is False, then it is a TypeError to attempt
+ encoding of keys that are not str, int, long, float or None. If
+ skipkeys is True, such items are simply skipped.
+
+ If ensure_ascii is True, the output is guaranteed to be str
+ objects with all incoming unicode characters escaped. If
+ ensure_ascii is false, the output will be unicode object.
+
+ If check_circular is True, then lists, dicts, and custom encoded
+ objects will be checked for circular references during encoding to
+ prevent an infinite recursion (which would cause an OverflowError).
+ Otherwise, no such check takes place.
+
+ If allow_nan is True, then NaN, Infinity, and -Infinity will be
+ encoded as such. This behavior is not JSON specification compliant,
+ but is consistent with most JavaScript based encoders and decoders.
+ Otherwise, it will be a ValueError to encode such floats.
+
+ If sort_keys is True, then the output of dictionaries will be
+ sorted by key; this is useful for regression tests to ensure
+ that JSON serializations can be compared on a day-to-day basis.
+
+ If indent is a non-negative integer, then JSON array
+ elements and object members will be pretty-printed with that
+ indent level. An indent level of 0 will only insert newlines.
+ None is the most compact representation.
+
+ If specified, separators should be a (item_separator, key_separator)
+ tuple. The default is (', ', ': '). To get the most compact JSON
+ representation you should specify (',', ':') to eliminate whitespace.
+ """
+
+ self.skipkeys = skipkeys
+ self.ensure_ascii = ensure_ascii
+ self.check_circular = check_circular
+ self.allow_nan = allow_nan
+ self.sort_keys = sort_keys
+ self.indent = indent
+ self.current_indent_level = 0
+ if separators is not None:
+ self.item_separator, self.key_separator = separators
+
+ def _newline_indent(self):
+ return '\n' + (' ' * (self.indent * self.current_indent_level))
+
+ def _iterencode_list(self, lst, markers=None):
+ if not lst:
+ yield '[]'
+ return
+ if markers is not None:
+ markerid = id(lst)
+ if markerid in markers:
+ raise ValueError("Circular reference detected")
+ markers[markerid] = lst
+ yield '['
+ if self.indent is not None:
+ self.current_indent_level += 1
+ newline_indent = self._newline_indent()
+ separator = self.item_separator + newline_indent
+ yield newline_indent
+ else:
+ newline_indent = None
+ separator = self.item_separator
+ first = True
+ for value in lst:
+ if first:
+ first = False
+ else:
+ yield separator
+ for chunk in self._iterencode(value, markers):
+ yield chunk
+ if newline_indent is not None:
+ self.current_indent_level -= 1
+ yield self._newline_indent()
+ yield ']'
+ if markers is not None:
+ del markers[markerid]
+
+ def _iterencode_dict(self, dct, markers=None):
+ if not dct:
+ yield '{}'
+ return
+ if markers is not None:
+ markerid = id(dct)
+ if markerid in markers:
+ raise ValueError("Circular reference detected")
+ markers[markerid] = dct
+ yield '{'
+ key_separator = self.key_separator
+ if self.indent is not None:
+ self.current_indent_level += 1
+ newline_indent = self._newline_indent()
+ item_separator = self.item_separator + newline_indent
+ yield newline_indent
+ else:
+ newline_indent = None
+ item_separator = self.item_separator
+ first = True
+ if self.ensure_ascii:
+ encoder = encode_basestring_ascii
+ else:
+ encoder = encode_basestring
+ allow_nan = self.allow_nan
+ if self.sort_keys:
+ keys = dct.keys()
+ keys.sort()
+ items = [(k, dct[k]) for k in keys]
+ else:
+ items = dct.iteritems()
+ for key, value in items:
+ if isinstance(key, basestring):
+ pass
+ # JavaScript is weakly typed for these, so it makes sense to
+ # also allow them. Many encoders seem to do something like this.
+ elif isinstance(key, float):
+ key = floatstr(key, allow_nan)
+ elif isinstance(key, (int, long)):
+ key = str(key)
+ elif key is True:
+ key = 'true'
+ elif key is False:
+ key = 'false'
+ elif key is None:
+ key = 'null'
+ elif self.skipkeys:
+ continue
+ else:
+ raise TypeError("key %r is not a string" % (key,))
+ if first:
+ first = False
+ else:
+ yield item_separator
+ yield encoder(key)
+ yield key_separator
+ for chunk in self._iterencode(value, markers):
+ yield chunk
+ if newline_indent is not None:
+ self.current_indent_level -= 1
+ yield self._newline_indent()
+ yield '}'
+ if markers is not None:
+ del markers[markerid]
+
+ def _iterencode(self, o, markers=None):
+ if isinstance(o, basestring):
+ if self.ensure_ascii:
+ encoder = encode_basestring_ascii
+ else:
+ encoder = encode_basestring
+ yield encoder(o)
+ elif o is None:
+ yield 'null'
+ elif o is True:
+ yield 'true'
+ elif o is False:
+ yield 'false'
+ elif isinstance(o, (int, long)):
+ yield str(o)
+ elif isinstance(o, float):
+ yield floatstr(o, self.allow_nan)
+ elif isinstance(o, (list, tuple)):
+ for chunk in self._iterencode_list(o, markers):
+ yield chunk
+ elif isinstance(o, dict):
+ for chunk in self._iterencode_dict(o, markers):
+ yield chunk
+ else:
+ if markers is not None:
+ markerid = id(o)
+ if markerid in markers:
+ raise ValueError("Circular reference detected")
+ markers[markerid] = o
+ for chunk in self._iterencode_default(o, markers):
+ yield chunk
+ if markers is not None:
+ del markers[markerid]
+
+ def _iterencode_default(self, o, markers=None):
+ newobj = self.default(o)
+ return self._iterencode(newobj, markers)
+
+ def default(self, o):
+ """
+ Implement this method in a subclass such that it returns
+ a serializable object for ``o``, or calls the base implementation
+ (to raise a ``TypeError``).
+
+ For example, to support arbitrary iterators, you could
+ implement default like this::
+
+ def default(self, o):
+ try:
+ iterable = iter(o)
+ except TypeError:
+ pass
+ else:
+ return list(iterable)
+ return JSONEncoder.default(self, o)
+ """
+ raise TypeError("%r is not JSON serializable" % (o,))
+
+ def encode(self, o):
+ """
+ Return a JSON string representation of a Python data structure.
+
+ >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
+ '{"foo":["bar", "baz"]}'
+ """
+ # This doesn't pass the iterator directly to ''.join() because it
+ # sucks at reporting exceptions. It's going to do this internally
+ # anyway because it uses PySequence_Fast or similar.
+ chunks = list(self.iterencode(o))
+ return ''.join(chunks)
+
+ def iterencode(self, o):
+ """
+ Encode the given object and yield each string
+ representation as available.
+
+ For example::
+
+ for chunk in JSONEncoder().iterencode(bigobject):
+ mysocket.write(chunk)
+ """
+ if self.check_circular:
+ markers = {}
+ else:
+ markers = None
+ return self._iterencode(o, markers)
+
+__all__ = ['JSONEncoder']
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py
new file mode 100644
index 0000000000..d02ae2033a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py
@@ -0,0 +1,40 @@
+from django.utils import simplejson
+import cgi
+
+class JSONFilter(object):
+ def __init__(self, app, mime_type='text/x-json'):
+ self.app = app
+ self.mime_type = mime_type
+
+ def __call__(self, environ, start_response):
+ # Read JSON POST input to jsonfilter.json if matching mime type
+ response = {'status': '200 OK', 'headers': []}
+ def json_start_response(status, headers):
+ response['status'] = status
+ response['headers'].extend(headers)
+ environ['jsonfilter.mime_type'] = self.mime_type
+ if environ.get('REQUEST_METHOD', '') == 'POST':
+ if environ.get('CONTENT_TYPE', '') == self.mime_type:
+ args = [_ for _ in [environ.get('CONTENT_LENGTH')] if _]
+ data = environ['wsgi.input'].read(*map(int, args))
+ environ['jsonfilter.json'] = simplejson.loads(data)
+ res = simplejson.dumps(self.app(environ, json_start_response))
+ jsonp = cgi.parse_qs(environ.get('QUERY_STRING', '')).get('jsonp')
+ if jsonp:
+ content_type = 'text/javascript'
+ res = ''.join(jsonp + ['(', res, ')'])
+ elif 'Opera' in environ.get('HTTP_USER_AGENT', ''):
+ # Opera has bunk XMLHttpRequest support for most mime types
+ content_type = 'text/plain'
+ else:
+ content_type = self.mime_type
+ headers = [
+ ('Content-type', content_type),
+ ('Content-length', len(res)),
+ ]
+ headers.extend(response['headers'])
+ start_response(response['status'], headers)
+ return [res]
+
+def factory(app, global_conf, **kw):
+ return JSONFilter(app, **kw)
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/scanner.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/scanner.py
new file mode 100644
index 0000000000..64f4999fb5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/scanner.py
@@ -0,0 +1,63 @@
+"""
+Iterator based sre token scanner
+"""
+import sre_parse, sre_compile, sre_constants
+from sre_constants import BRANCH, SUBPATTERN
+from re import VERBOSE, MULTILINE, DOTALL
+import re
+
+__all__ = ['Scanner', 'pattern']
+
+FLAGS = (VERBOSE | MULTILINE | DOTALL)
+class Scanner(object):
+ def __init__(self, lexicon, flags=FLAGS):
+ self.actions = [None]
+ # combine phrases into a compound pattern
+ s = sre_parse.Pattern()
+ s.flags = flags
+ p = []
+ for idx, token in enumerate(lexicon):
+ phrase = token.pattern
+ try:
+ subpattern = sre_parse.SubPattern(s,
+ [(SUBPATTERN, (idx + 1, sre_parse.parse(phrase, flags)))])
+ except sre_constants.error:
+ raise
+ p.append(subpattern)
+ self.actions.append(token)
+
+ p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
+ self.scanner = sre_compile.compile(p)
+
+
+ def iterscan(self, string, idx=0, context=None):
+ """
+ Yield match, end_idx for each match
+ """
+ match = self.scanner.scanner(string, idx).match
+ actions = self.actions
+ lastend = idx
+ end = len(string)
+ while True:
+ m = match()
+ if m is None:
+ break
+ matchbegin, matchend = m.span()
+ if lastend == matchend:
+ break
+ action = actions[m.lastindex]
+ if action is not None:
+ rval, next_pos = action(m, context)
+ if next_pos is not None and next_pos != matchend:
+ # "fast forward" the scanner
+ matchend = next_pos
+ match = self.scanner.scanner(string, matchend).match
+ yield rval, matchend
+ lastend = matchend
+
+def pattern(pattern, flags=FLAGS):
+ def decorator(fn):
+ fn.pattern = pattern
+ fn.regex = re.compile(pattern, flags)
+ return fn
+ return decorator
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/elemutil.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/elemutil.py
new file mode 100644
index 0000000000..ad971ba6ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/elemutil.py
@@ -0,0 +1,168 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Functions to help represent data as lists of elements and attributes
+
+from util import *
+
+element = "'element"
+attribute = "'attribute"
+atsign = "'@"
+
+# Return true if a value is an element
+def isElement(v):
+ if not isList(v) or isNil(v) or v == None or car(v) != element:
+ return False
+ return True
+
+# Return true if a value is an attribute
+def isAttribute(v):
+ if not isList(v) or isNil(v) or v == None or car(v) != attribute:
+ return False
+ return True
+
+# Return the name of attribute
+def attributeName(l):
+ return cadr(l)
+
+# Return the value of attribute
+def attributeValue(l):
+ return caddr(l)
+
+# Return the name of an element
+def elementName(l):
+ return cadr(l)
+
+# Return true if an element has children
+def elementHasChildren(l):
+ return not isNil(cddr(l))
+
+# Return the children of an element
+def elementChildren(l):
+ return cddr(l)
+
+# Return true if an element has a value
+def elementHasValue(l):
+ r = reverse(l)
+ if isSymbol(car(r)):
+ return False
+ if isList(car(r)) and not isNil(car(r)) and isSymbol(car(car(r))):
+ return False
+ return True
+
+# Return the value of an element
+def elementValue(l):
+ return car(reverse(l))
+
+# Convert an element to a value
+def elementToValueIsList(v):
+ if not isList(v):
+ return False
+ return isNil(v) or not isSymbol(car(v))
+
+def elementToValue(t):
+ if isTaggedList(t, attribute):
+ return (atsign + attributeName(t)[1:], attributeValue(t))
+ if isTaggedList(t, element):
+ if elementHasValue(t):
+ if not elementToValueIsList(elementValue(t)):
+ return (elementName(t), elementValue(t))
+ return cons(elementName(t), (elementsToValues(elementValue(t)),))
+ return cons(elementName(t), elementsToValues(elementChildren(t)))
+ if not isList(t):
+ return t
+ return elementsToValues(t)
+
+# Convert a list of elements to a list of values
+def elementToValueIsSymbol(v):
+ if not isList(v):
+ return False
+ if (isNil(v)):
+ return False
+ if not isSymbol(car(v)):
+ return False
+ return True
+
+def elementToValueGroupValues(v, l):
+ if isNil(l) or not elementToValueIsSymbol(v) or not elementToValueIsSymbol(car(l)):
+ return cons(v, l)
+ if car(car(l)) != car(v):
+ return cons(v, l)
+ if not elementToValueIsList(cadr(car(l))):
+ g = (car(v), (cdr(v), cdr(car(l))))
+ return elementToValueGroupValues(g, cdr(l))
+ g = (car(v), cons(cdr(v), cadr(car(l))))
+ return elementToValueGroupValues(g, cdr(l))
+
+def elementsToValues(e):
+ if isNil(e):
+ return e
+ return elementToValueGroupValues(elementToValue(car(e)), elementsToValues(cdr(e)))
+
+# Convert a value to an element
+def valueToElement(t):
+ if isList(t) and not isNil(t) and isSymbol(car(t)):
+ n = car(t)
+ v = cadr(t)
+ if not isList(v):
+ if n[0:2] == atsign:
+ return (attribute, n[1:], v)
+ return (element, n, v)
+ if isNil(v) or not isSymbol(car(v)):
+ return cons(element, cons(n, (valuesToElements(v),)))
+ return cons(element, cons(n, valuesToElements(cdr(t))))
+ if not isList(t):
+ return t
+ return valuesToElements(t)
+
+# Convert a list of values to a list of elements
+def valuesToElements(l):
+ if isNil(l):
+ return l
+ return cons(valueToElement(car(l)), valuesToElements(cdr(l)))
+
+# Return a selector lambda function which can be used to filter elements
+def evalSelect(s, v):
+ if isNil(s):
+ return True
+ if isNil(v):
+ return False
+ if car(s) != car(v):
+ return False
+ return evalSelect(cdr(s), cdr(v))
+
+def selector(s):
+ return lambda v: evalSelect(s, v)
+
+# Return the value of the attribute with the given name
+def namedAttributeValue(name, l):
+ f = filter(lambda v: isAttribute(v) and attributeName(v) == name, l)
+ if isNil(f):
+ return None
+ return caddr(car(f))
+
+# Return child elements with the given name
+def namedElementChildren(name, l):
+ return filter(lambda v: isElement(v) and elementName(v) == name, l)
+
+# Return the child element with the given name
+def namedElementChild(name, l):
+ f = namedElementChildren(name, l)
+ if isNil(f):
+ return None
+ return car(f)
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/invoker.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/invoker.py
new file mode 100644
index 0000000000..48107671d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/invoker.py
@@ -0,0 +1,108 @@
+#!/usr/bin/python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Component invocation functions
+
+from sys import stderr, argv
+from util import *
+from jsonutil import *
+
+# JSON request id
+id = 1
+
+# Make a callable reference client
+class proxy:
+ def __init__(self, jpx):
+ self.jpx = jpx
+
+ def __call__(self, func, *args):
+
+ # Create a JSON-RPC request
+ global id
+ req = StringIO()
+ writeStrings(jsonRequest(id, func, args), req)
+ id = id + 1
+
+ # Eval the Java proxy
+ res = self.jpx.eval(req.getvalue())
+
+ # Extract result from JSON-RPC response
+ return jsonResultValue((res,))
+
+ def __repr__(self):
+ return repr((jpx,))
+
+def mkproxies(jpx):
+ if isNil(jpx):
+ return ()
+ return cons(proxy(car(jpx)), mkproxies(cdr(jpx)))
+
+class prop:
+ def __init__(self, jpy):
+ self.jpy = jpy
+
+ def __call__(self):
+ # Eval the property
+ res = self.jpy.eval()
+ return res
+
+def __repr__(self):
+ return repr((jpy,))
+
+def mkprops(jpy):
+ if isNil(jpy):
+ return ()
+ return cons(prop(car(jpy)), mkprops(cdr(jpy)))
+
+# Make a callable component
+class component:
+ def __init__(self, name, impl, jpx, jpy):
+ self.name = name
+ self.impl = impl[0:len(impl) - 3]
+ self.mod = __import__(self.impl)
+ self.proxies = mkproxies(jpx)
+ self.props = mkprops(jpy)
+
+ def __call__(self, func, *args):
+ return self.mod.__getattribute__(func)(*(args + self.proxies + self.props))
+
+ def __repr__(self):
+ return repr((self.name, self.impl, self.mod, self.props, self.proxies))
+
+# Converts the args received in a JSON request to a list of key value pairs
+def jsonArgs(a):
+ if isNil(a):
+ return ((),)
+ l = car(a);
+ return cons(l, jsonArgs(cdr(a)))
+
+# Apply a JSON function request to a component
+def apply(jsreq, comp):
+ json = elementsToValues(readJSON((jsreq,)))
+ args = jsonArgs(json)
+ jid = cadr(assoc("'id", args))
+ func = funcName(cadr(assoc("'method", args)))
+ params = cadr(assoc("'params", args))
+ v = comp(func, *params)
+ return jsonResult(jid, v)[0]
+
+# Make a component that can be called with a JSON function request
+def mkcomponent(name, impl, jpx, jpy):
+ comp = component(name, impl, jpx, jpy)
+ return lambda jsreq: apply(jsreq, comp)
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/jsonutil.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/jsonutil.py
new file mode 100644
index 0000000000..f69559de54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/jsonutil.py
@@ -0,0 +1,142 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# JSON data conversion functions
+
+try:
+ import json
+except:
+ from django.utils import simplejson as json
+
+from StringIO import StringIO
+from util import *
+from elemutil import *
+
+# Return true if a list represents a JS array
+def isJSArray(l):
+ if isNil(l):
+ return True
+ v = car(l)
+ if isSymbol(v):
+ return False
+ if isList(v):
+ if not isNil(v) and isSymbol(car(v)):
+ return False
+ return True
+
+# Converts JSON properties to values
+def jsPropertiesToValues(propertiesSoFar, o, i):
+ if isNil(i):
+ return propertiesSoFar
+ p = car(i)
+ jsv = o[p]
+ v = jsValToValue(jsv)
+
+ if isinstance(p, basestring):
+ n = str(p)
+ if n[0:1] == "@":
+ return jsPropertiesToValues(cons((attribute, "'" + n[1:], v), propertiesSoFar), o, cdr(i))
+ if isList(v) and not isJSArray(v):
+ return jsPropertiesToValues(cons(cons(element, cons("'" + n, v)), propertiesSoFar), o, cdr(i))
+ return jsPropertiesToValues(cons((element, "'" + n, v), propertiesSoFar), o, cdr(i))
+ return jsPropertiesToValues(cons(v, propertiesSoFar), o, cdr(i))
+
+# Converts a JSON val to a value
+def jsValToValue(jsv):
+ if isinstance(jsv, dict):
+ return jsPropertiesToValues((), jsv, tuple(jsv.keys()))
+ if isList(jsv):
+ return jsPropertiesToValues((), jsv, tuple(reversed(range(0, len(jsv)))))
+ if isinstance(jsv, basestring):
+ return str(jsv)
+ return jsv
+
+# Convert a list of strings representing a JSON document to a list of values
+def readJSON(l):
+ s = StringIO()
+ writeStrings(l, s)
+ val = json.loads(s.getvalue())
+ return jsValToValue(val)
+
+# Convert a list of values to JSON array elements
+def valuesToJSElements(a, l, i):
+ if isNil(l):
+ return a
+ pv = valueToJSVal(car(l))
+ a[i] = pv
+ return valuesToJSElements(a, cdr(l), i + 1)
+
+# Convert a value to a JSON value
+def valueToJSVal(v):
+ if not isList(v):
+ return v
+ if isJSArray(v):
+ return valuesToJSElements(list(range(0, len(v))), v, 0)
+ return valuesToJSProperties({}, v)
+
+# Convert a list of values to JSON properties
+def valuesToJSProperties(o, l):
+ if isNil(l):
+ return o
+ token = car(l)
+ if isTaggedList(token, attribute):
+ pv = valueToJSVal(attributeValue(token))
+ o["@" + attributeName(token)[1:]] = pv
+ elif isTaggedList(token, element):
+ if elementHasValue(token):
+ pv = valueToJSVal(elementValue(token))
+ o[elementName(token)[1:]] = pv
+ else:
+ child = {}
+ o[elementName(token)[1:]] = child
+ valuesToJSProperties(child, elementChildren(token))
+ return valuesToJSProperties(o, cdr(l))
+
+# Convert a list of values to a list of strings representing a JSON document
+def writeJSON(l):
+ jsv = valuesToJSProperties({}, l)
+ s = json.dumps(jsv, separators=(',',':'))
+ return (s,)
+
+# Convert a list + params to a JSON-RPC request
+def jsonRequest(id, func, params):
+ r = (("'id", id), ("'method", func), ("'params", params))
+ return writeJSON(valuesToElements(r))
+
+# Convert a value to a JSON-RPC result
+def jsonResult(id, val):
+ return writeJSON(valuesToElements((("'id", id), ("'result", val))))
+
+# Convert a JSON-RPC result to a value
+def jsonResultValue(s):
+ jsres = readJSON(s)
+ res = elementsToValues(jsres)
+ val = cadr(assoc("'result", res))
+ if isList(val) and not isJSArray(val):
+ return (val,)
+ return val
+
+# Return a portable function name from a JSON-RPC function name
+def funcName(f):
+ if f.startswith("."):
+ return f[1:]
+ if f.startswith("system."):
+ return f[7:]
+ if f.startswith("Service."):
+ return f[8:]
+ return f
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/rssutil.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/rssutil.py
new file mode 100644
index 0000000000..4f060d2321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/rssutil.py
@@ -0,0 +1,119 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# RSS data conversion functions
+
+from util import *
+from elemutil import *
+from xmlutil import *
+
+# Convert a list of elements to a list of values representing an RSS entry
+def entryElementsToValues(e):
+ lt = filter(selector((element, "'title")), e)
+ t = "" if isNil(lt) else elementValue(car(lt))
+ li = filter(selector((element, "'link")), e)
+ i = "" if isNil(li) else elementValue(car(li))
+ lc = filter(selector((element, "'description")), e)
+ return (t, i, elementValue(car(lc)))
+
+# Convert a list of elements to a list of values representing RSS entries
+def entriesElementsToValues(e):
+ if isNil(e):
+ return e
+ return cons(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e)))
+
+# Convert a list of strings to a list of values representing an RSS entry
+def readRSSEntry(l):
+ e = readXML(l)
+ if isNil(e):
+ return ()
+ return entryElementsToValues(car(e))
+
+# Convert a list of values representy an RSS entry to a value
+def entryValue(e):
+ v = elementsToValues((caddr(e),))
+ return cons(car(e), (cadr(e), cdr(car(v))))
+
+# Return true if a list of strings represents an RSS feed
+def isRSSFeed(l):
+ if isNil(l):
+ return False
+ if car(l)[0:5] != "<?xml":
+ return False
+ return contains(car(l), "<rss")
+
+# Convert a list of strings to a list of values representing an RSS feed
+def readRSSFeed(l):
+ f = readXML(l)
+ if isNil(f):
+ return ()
+ c = filter(selector((element, "'channel")), car(f))
+ t = filter(selector((element, "'title")), car(c))
+ i = filter(selector((element, "'link")), car(c))
+ e = filter(selector((element, "'item")), car(c))
+ if isNil(e):
+ return (elementValue(car(t)), elementValue(car(i)))
+ return cons(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e)))
+
+# Convert an RSS feed containing elements to an RSS feed containing values
+def feedValuesLoop(e):
+ if (isNil(e)):
+ return e
+ return cons(entryValue(car(e)), feedValuesLoop(cdr(e)))
+
+def feedValues(e):
+ return cons(car(e), cons(cadr(e), feedValuesLoop(cddr(e))))
+
+# Convert a list of values representy an RSS entry to a list of elements
+def entryElement(l):
+ return (element, "'item",
+ (element, "'title", car(l)),
+ (element, "'link", cadr(l)),
+ (element, "'description", caddr(l)))
+
+# Convert a list of values representing RSS entries to a list of elements
+def entriesElements(l):
+ if isNil(l):
+ return l
+ return cons(entryElement(car(l)), entriesElements(cdr(l)))
+
+# Convert a list of values representing an RSS entry to an RSS entry
+def writeRSSEntry(l):
+ return writeXML((entryElement(l),), True)
+
+# Convert a list of values representing an RSS feed to an RSS feed
+def writeRSSFeed(l):
+ c = ((element, "'title", car(l)),
+ (element, "'link", cadr(l)),
+ (element, "'description", car(l)))
+ ce = c if isNil(cddr(l)) else append(c, entriesElements(cddr(l)))
+ fe = (element, "'rss", (attribute, "'version", "2.0"), append((element, "'channel"), ce))
+ return writeXML((fe,), True)
+
+# Convert an RSS entry containing a value to an RSS entry containing an item element
+def entryValuesToElements(v):
+ return cons(car(v), cons(cadr(v), valuesToElements((cons("'item", caddr(v)),))))
+
+# Convert an RSS feed containing values to an RSS feed containing elements
+def feedValuesToElementsLoop(v):
+ if isNil(v):
+ return v
+ return cons(entryValuesToElements(car(v)), feedValuesToElementsLoop(cdr(v)))
+
+def feedValuesToElements(v):
+ return cons(car(v), cons(cadr(v), feedValuesToElementsLoop(cddr(v))))
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/util.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/util.py
new file mode 100644
index 0000000000..560101e32d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/util.py
@@ -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.
+
+# Simple utility functions
+from sys import maxint
+
+# Scheme-like lists
+def cons(a, b):
+ return (a,) + b
+
+def car(l):
+ return l[0]
+
+def first(l):
+ return car(l)
+
+def cdr(l):
+ return l[1:]
+
+def rest(l):
+ return cdr(l)
+
+def cadr(l):
+ return car(cdr(l))
+
+def cddr(l):
+ return cdr(cdr(l))
+
+def caddr(l):
+ return car(cddr(l))
+
+def append(a, b):
+ return a + b
+
+def reverse(l):
+ r = list(l)
+ r.reverse()
+ return tuple(r)
+
+def isNil(l):
+ if isinstance(l, streampair):
+ return l.isNil()
+ return l == ()
+
+def isSymbol(v):
+ return isinstance(v, basestring) and v[0:1] == "'"
+
+def isList(v):
+ if getattr(v, '__iter__', False) == False:
+ return False
+ if isinstance(v, basestring) or isinstance(v, dict):
+ return False
+ return True
+
+def isTaggedList(v, t):
+ return isList(v) and not isNil(v) and car(v) == t
+
+
+# Scheme-like streams
+class streampair(object):
+ def __init__(self, car, cdr):
+ self.car = car
+ self.cdr = cdr
+
+ def __repr__(self):
+ return repr(self[0:len(self)])
+
+ def isNil(self):
+ return self.cdr == ()
+
+ def __len__(self):
+ if self.cdr == ():
+ return 0
+ return 1 + len(self.cdr())
+
+ def __getitem__(self, i):
+ if i == 0:
+ return self.car
+ return self.cdr()[i - 1]
+
+ def __getslice__(self, i, j):
+ if isNil(self):
+ return ()
+ if i > 0:
+ if j == maxint:
+ return self.cdr()[i - 1: j]
+ return self.cdr()[i - 1: j - 1]
+ if j == maxint:
+ return self
+ if j == 0:
+ return (self.car,)
+ return (self.car,) + self.cdr()[: j - 1]
+
+ def __eq__(self, other):
+ sl = len(self)
+ ol = len(other)
+ if sl != ol:
+ return False
+ return self[0: sl] == other[0: ol]
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+def cons_stream(car, cdr):
+ return streampair(car, cdr)
+
+
+# Scheme-like associations
+def assoc(k, l):
+ if l == ():
+ return None
+
+ if k == car(car(l)):
+ return car(l)
+ return assoc(k, cdr(l))
+
+# Currying / partial function application
+def curry(f, *args):
+ return lambda *a: f(*(args + a))
+
+# Split a path into a list of segments
+def tokens(path):
+ return tuple(filter(lambda s: len(s) != 0, path.split("/")))
+
+# Write a list of strings to a stream
+def writeStrings(l, os):
+ if l == ():
+ return os
+ os.write(car(l))
+ return writeStrings(cdr(l), os)
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/xmlutil.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/xmlutil.py
new file mode 100644
index 0000000000..a1bc04629a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/main/resources/xmlutil.py
@@ -0,0 +1,114 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# XML handling functions
+
+from StringIO import StringIO
+from xml.parsers import expat
+import xml.etree.ElementTree as et
+from util import *
+from elemutil import *
+
+# Read a list of XML attributes
+def readAttributes(a):
+ if a == ():
+ return a
+ return cons((attribute, "'" + car(car(a)), cadr(car(a))), readAttributes(cdr(a)))
+
+# Read an XML element
+def readElement(e):
+ l = (element, "'" + e.tag) + readAttributes(tuple(e.items())) + readElements(tuple(e.getchildren()))
+ if e.text == None:
+ return l
+ return l + (e.text,)
+
+# Read a list of XML elements
+def readElements(l):
+ if l == ():
+ return l
+ return cons(readElement(car(l)), readElements(cdr(l)))
+
+# Parse a list of strings representing an XML document
+class NamespaceParser(et.XMLTreeBuilder):
+ def __init__(self):
+ et.XMLTreeBuilder.__init__(self)
+ self._parser = parser = expat.ParserCreate(None)
+ parser.DefaultHandlerExpand = self._default
+ parser.StartElementHandler = self._start
+ parser.EndElementHandler = self._end
+ parser.CharacterDataHandler = self._data
+ try:
+ parser.buffer_text = 1
+ except AttributeError:
+ pass
+ try:
+ parser.ordered_attributes = 1
+ parser.specified_attributes = 1
+ parser.StartElementHandler = self._start_list
+ except AttributeError:
+ pass
+
+def parseXML(l):
+ s = StringIO()
+ writeStrings(l, s)
+ parser = NamespaceParser()
+ parser.feed(s.getvalue())
+ return parser.close()
+
+# Read a list of values from a list of strings representing an XML document
+def readXML(l):
+ e = parseXML(l)
+ return (readElement(e),)
+
+# Write a list of XML element and attribute tokens
+def expandElementValues(n, l):
+ if isNil(l):
+ return l
+ return cons(cons(element, cons(n, car(l))), expandElementValues(n, cdr(l)))
+
+def writeList(l, xml):
+ if isNil(l):
+ return xml
+ token = car(l)
+ if isTaggedList(token, attribute):
+ xml.attrib[attributeName(token)[1:]] = str(attributeValue(token))
+ elif isTaggedList(token, element):
+ if elementHasValue(token):
+ v = elementValue(token)
+ if isList(v):
+ e = expandElementValues(elementName(token), v)
+ writeList(e, xml)
+ else:
+ child = et.Element(elementName(token)[1:])
+ writeList(elementChildren(token), child)
+ xml.append(child)
+ else:
+ child = et.Element(elementName(token)[1:])
+ writeList(elementChildren(token), child)
+ xml.append(child)
+ else:
+ xml.text = str(token)
+ writeList(cdr(l), xml)
+ return xml
+
+# Convert a list of values to a list of strings representing an XML document
+def writeXML(l, xmlTag):
+ e = writeList(l, [])
+ if not xmlTag:
+ return (et.tostring(car(e)),)
+ return (et.tostring(car(e), "UTF-8") + "\n",)
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/ClientTest.java b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/ClientTest.java
new file mode 100644
index 0000000000..f69ce3284e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/ClientTest.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 org.apache.tuscany.sca.implementation.python.provider;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * Test Java component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClientTest implements EchoTest {
+
+ @Reference
+ public EchoTest ref;
+
+ public String echo(final String s1, final String s2) {
+ return ref.echo(s1, s2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/EchoTest.java b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/EchoTest.java
new file mode 100644
index 0000000000..557bc968da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/EchoTest.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.python.provider;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Test client interface.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface EchoTest {
+
+ public String echo(String s1, String s2);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/InvokeTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/InvokeTestCase.java
new file mode 100644
index 0000000000..0d4b00d49a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/InvokeTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.python.provider;
+
+import static org.apache.tuscany.sca.node.ContributionLocationHelper.getContributionLocation;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.jabsorb.client.Client;
+import org.jabsorb.client.Session;
+import org.jabsorb.client.TransportRegistry;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests the Python implementation provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvokeTestCase {
+ static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ try {
+ final String loc = getContributionLocation("domain-test.composite");
+ node = NodeFactory.newInstance().createNode("domain-test.composite", new Contribution("c", loc));
+ node.start();
+ } catch(Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testService() throws Exception {
+ final Session s = TransportRegistry.i().createSession("http://localhost:8080/python");
+ final Client c = new Client(s);
+ final Object px = c.openProxy("", EchoTest.class);
+ final Object r = c.invoke(px, EchoTest.class.getMethod("echo", String.class, String.class), new Object[] {"Hey", "There"});
+ c.closeProxy(px);
+ s.close();
+ assertEquals("Hey There", r);
+ }
+
+ @Test
+ public void testReference() throws Exception {
+ final Session s = TransportRegistry.i().createSession("http://localhost:8080/client");
+ final Client c = new Client(s);
+ final Object px = c.openProxy("", EchoTest.class);
+ final Object r = c.invoke(px, EchoTest.class.getMethod("echo", String.class, String.class), new Object[] {"Hey", "There"});
+ c.closeProxy(px);
+ s.close();
+ assertEquals("Hey There", r);
+ }
+
+ @Test
+ public void testLocal() throws Exception {
+ final Session s = TransportRegistry.i().createSession("http://localhost:8080/java-client");
+ final Client c = new Client(s);
+ final Object px = c.openProxy("", EchoTest.class);
+ final Object r = c.invoke(px, EchoTest.class.getMethod("echo", String.class, String.class), new Object[] {"Hey", "There"});
+ c.closeProxy(px);
+ s.close();
+ assertEquals("Hey There", r);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/ServerTest.java b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/ServerTest.java
new file mode 100644
index 0000000000..b0f3b5868f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/java/org/apache/tuscany/sca/implementation/python/provider/ServerTest.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.sca.implementation.python.provider;
+
+/**
+ * Test Java component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServerTest implements EchoTest {
+
+ public String echo(final String s1, final String s2) {
+ return s1 + " " + s2;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/client_test.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/client_test.py
new file mode 100644
index 0000000000..e3cbaf077f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/client_test.py
@@ -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.
+
+# JSON-RPC test case
+
+def echo(x, y, ref):
+ return ref("echo", x, y)
+
+# ATOMPub test case
+
+def get(id, ref):
+ return ref("get", id)
+
+def post(collection, item, ref):
+ return ref("post", collection, item)
+
+def put(id, item, ref):
+ return ref("put", id, item)
+
+def delete(id, ref):
+ return ref("delete", id)
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/domain-test.composite b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/domain-test.composite
new file mode 100644
index 0000000000..dfcf4f83ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/domain-test.composite
@@ -0,0 +1,64 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://domain/test"
+ name="domain-test">
+
+ <component name="python-test">
+ <t:implementation.python script="server_test.py"/>
+ <service name="test">
+ <t:binding.jsonrpc uri="http://localhost:8080/python"/>
+ </service>
+ </component>
+
+ <component name="client-test">
+ <t:implementation.python script="client_test.py"/>
+ <service name="client">
+ <t:binding.jsonrpc uri="http://localhost:8080/client"/>
+ </service>
+ <reference name="ref" target="python-test">
+ </reference>
+ </component>
+
+ <component name="java-test">
+ <implementation.java class="org.apache.tuscany.sca.implementation.python.provider.ServerTest"/>
+ <service name="EchoTest">
+ <t:binding.jsonrpc uri="http://localhost:8080/java"/>
+ </service>
+ </component>
+
+ <component name="python-to-java-test">
+ <t:implementation.python script="client_test.py"/>
+ <service name="client">
+ <t:binding.jsonrpc uri="http://localhost:8080/python-to-java"/>
+ </service>
+ <reference name="ref" target="java-test"/>
+ </component>
+
+ <component name="java-client-test">
+ <implementation.java class="org.apache.tuscany.sca.implementation.python.provider.ClientTest"/>
+ <service name="EchoTest">
+ <t:binding.jsonrpc uri="http://localhost:8080/java-client"/>
+ </service>
+ <reference name="ref" target="python-to-java-test"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/server_test.py b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/server_test.py
new file mode 100644
index 0000000000..75f9712f95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python-runtime/src/test/resources/server_test.py
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# JSON-RPC test case
+
+def echo(x, y):
+ return x + " " + y
+
+# ATOMPub test case
+
+def get(id):
+ if id == ():
+ return ("Sample Feed", "123456789",
+ ("Item", "111", (("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99))),
+ ("Item", "222", (("'javaClass", "services.Item"), ("'name", "Orange"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 3.55))),
+ ("Item", "333", (("'javaClass", "services.Item"), ("name", "Pear"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 1.55))))
+
+ entry = (("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99))
+ return ("Item", id[0], entry)
+
+def post(collection, item):
+ return ("123456789",)
+
+def put(id, item):
+ return True
+
+def delete(id):
+ return True
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-python/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/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/sebastien/java/embed/modules/implementation-python/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-python/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..590513a698
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Python Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Python Implementation Model
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.python
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-python/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-python/pom.xml
new file mode 100644
index 0000000000..d3a678b3b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/pom.xml
@@ -0,0 +1,84 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-python</artifactId>
+ <name>Apache Tuscany SCA Python Implementation Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonEval.java b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonEval.java
new file mode 100644
index 0000000000..ae9caab7d0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonEval.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.python;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Python component generic evaluation interface.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface PythonEval {
+
+ public String eval(String args) throws Exception;
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonImplementation.java
new file mode 100644
index 0000000000..058c01a48e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonImplementation.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.python;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.assembly.impl.PropertyImpl;
+import org.apache.tuscany.sca.assembly.impl.ReferenceImpl;
+import org.apache.tuscany.sca.assembly.impl.ServiceImpl;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * The model representing a Python implementation in an SCA assembly.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PythonImplementation extends ImplementationImpl {
+ final String script;
+ final String location;
+ final InterfaceContract contract;
+ final Service service;
+
+ PythonImplementation(final QName qn, final String scr, final String loc, final InterfaceContract c) {
+ super(qn);
+ script = scr;
+ location = loc;
+ contract = c;
+
+ class DynService extends ServiceImpl {
+ public DynService() {
+ setName("default");
+ setInterfaceContract(contract);
+ }
+ }
+ ;
+ service = new DynService();
+ getServices().add(service);
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public Service getService(final String n) {
+ return service;
+ }
+
+ public Reference getReference(final String n) {
+ final Reference r = super.getReference(n);
+ if(r != null)
+ return r;
+ class DynReference extends ReferenceImpl {
+ public DynReference() {
+ setName(n);
+ setInterfaceContract(contract);
+ }
+ }
+ final Reference nr = new DynReference();
+ getReferences().add(nr);
+ return nr;
+ }
+
+ public Property getProperty(final String n) {
+ final Property p = super.getProperty(n);
+ if(p != null)
+ return p;
+ class DynProperty extends PropertyImpl {
+ public DynProperty() {
+ setName(n);
+ setDataType(new DataTypeImpl<XMLType>(null, String.class, String.class, XMLType.UNKNOWN));
+ setXSDType(new QName("http://www.w3.org/2001/XMLSchema", "string"));
+ }
+ }
+ final Property np = new DynProperty();
+ getProperties().add(np);
+ return np;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonImplementationProcessor.java
new file mode 100644
index 0000000000..b4daab34cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonImplementationProcessor.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.python;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static org.apache.tuscany.sca.assembly.Base.SCA11_TUSCANY_NS;
+
+import java.net.URI;
+
+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.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceImpl;
+
+/**
+ * Implements a StAX artifact processor for Python implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PythonImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<PythonImplementation> {
+ static QName QN = new QName(SCA11_TUSCANY_NS, "implementation.python");
+
+ final InterfaceContract contract;
+
+ public PythonImplementationProcessor(final ExtensionPointRegistry ep) throws InvalidInterfaceException {
+ final FactoryExtensionPoint fep = ep.getExtensionPoint(FactoryExtensionPoint.class);
+ final JavaInterfaceFactory jf = fep.getFactory(JavaInterfaceFactory.class);
+ final JavaInterface eval = jf.createJavaInterface(PythonEval.class);
+
+ class DynamicInterface extends JavaInterfaceImpl {
+ DynamicInterface() {
+ setJavaClass(eval.getJavaClass());
+ setName(eval.getName());
+ setRemotable(eval.isRemotable());
+ Operation op = eval.getOperations().get(0);
+ op.setDynamic(true);
+ getOperations().add(op);
+ resetDataBinding(JSONDataBinding.NAME);
+ setUnresolved(false);
+ }
+
+ @Override
+ public boolean isDynamic() {
+ return true;
+ }
+ }
+
+ contract = jf.createJavaInterfaceContract();
+ contract.setInterface(new DynamicInterface());
+ }
+
+ public QName getArtifactType() {
+ return QN;
+ }
+
+ public Class<PythonImplementation> getModelType() {
+ return PythonImplementation.class;
+ }
+
+ public PythonImplementation read(final XMLStreamReader r, final ProcessorContext ctx) throws ContributionReadException, XMLStreamException {
+ final String scr = r.getAttributeValue(null, "script");
+ while(r.hasNext() && !(r.next() == END_ELEMENT && QN.equals(r.getName())))
+ ;
+ return new PythonImplementation(QN, scr, URI.create(ctx.getContribution().getLocation()).getPath(), contract);
+ }
+
+ public void resolve(final PythonImplementation impl, final ModelResolver res, final ProcessorContext ctx) throws ContributionResolveException {
+ }
+
+ public void write(final PythonImplementation impl, final XMLStreamWriter w, final ProcessorContext ctx) throws ContributionWriteException, XMLStreamException {
+ writeStart(w, QN.getNamespaceURI(), QN.getLocalPart(), new XAttr("script", impl.getScript()));
+ writeEnd(w);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonProperty.java b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonProperty.java
new file mode 100644
index 0000000000..6efee36ab3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/java/org/apache/tuscany/sca/implementation/python/PythonProperty.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.python;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Python component property evaluation interface.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface PythonProperty {
+
+ public String eval();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..c6f60b9880
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.implementation.python.PythonImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.python,model=org.apache.tuscany.sca.implementation.python.PythonImplementation
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..2543a67897
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -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/implementation/python/tuscany-sca-1.1-implementation-python.xsd
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/org/apache/tuscany/sca/implementation/python/tuscany-sca-1.1-implementation-python.xsd b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/org/apache/tuscany/sca/implementation/python/tuscany-sca-1.1-implementation-python.xsd
new file mode 100644
index 0000000000..75e69f1ccd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/main/resources/org/apache/tuscany/sca/implementation/python/tuscany-sca-1.1-implementation-python.xsd
@@ -0,0 +1,38 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"/>
+
+ <element name="implementation.python" type="t:PythonImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="PythonImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <attribute name="script" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/test/java/org/apache/tuscany/sca/implementation/python/ReadWriteTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-python/src/test/java/org/apache/tuscany/sca/implementation/python/ReadWriteTestCase.java
new file mode 100644
index 0000000000..388df1d210
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/test/java/org/apache/tuscany/sca/implementation/python/ReadWriteTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.python;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DefaultContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading/writing Python implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteTestCase {
+ static XMLInputFactory xif;
+ static XMLOutputFactory xof;
+ static StAXArtifactProcessor<Object> xproc;
+ static ProcessorContext ctx;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final DefaultExtensionPointRegistry ep = new DefaultExtensionPointRegistry();
+ final Contribution contrib = new DefaultContributionFactory().createContribution();
+ contrib.setLocation(ReadWriteTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString());
+ final Monitor mon = new DefaultMonitorFactory().createMonitor();
+ ctx = new ProcessorContext(contrib, mon);
+ xif = XMLInputFactory.newInstance();
+ xof = XMLOutputFactory.newInstance();
+ final StAXArtifactProcessorExtensionPoint xpep = new DefaultStAXArtifactProcessorExtensionPoint(ep);
+ xproc = new ExtensibleStAXArtifactProcessor(xpep, xif, xof);
+ }
+
+ @Test
+ public void testRead() throws Exception {
+ final InputStream is = getClass().getClassLoader().getResourceAsStream("domain-test.composite");
+ final Composite c = (Composite)xproc.read(xif.createXMLStreamReader(is), ctx);
+ assertNotNull(c);
+ assertEquals("server_test.py", ((PythonImplementation)c.getComponents().get(0).getImplementation()).getScript());
+ }
+
+ @Test
+ public void testReadWrite() throws Exception {
+ final InputStream is = getClass().getClassLoader().getResourceAsStream("domain-test.composite");
+ final Composite c = (Composite)xproc.read(xif.createXMLStreamReader(is), ctx);
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ xproc.write(c, xof.createXMLStreamWriter(bos), ctx);
+ assertTrue(bos.toString().contains("script=\"server_test.py\""));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-python/src/test/resources/domain-test.composite b/sandbox/sebastien/java/embed/modules/implementation-python/src/test/resources/domain-test.composite
new file mode 100644
index 0000000000..c1e40dc676
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-python/src/test/resources/domain-test.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://domain/test"
+ name="domain-test">
+
+ <component name="python-test">
+ <t:implementation.python script="server_test.py"/>
+ <service name="test">
+ </service>
+ </component>
+
+ <component name="client-test">
+ <t:implementation.python script="client_test.py"/>
+ <service name="client">
+ </service>
+ <reference name="ref" target="python-test">
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/LICENSE
new file mode 100644
index 0000000000..4b5ab74408
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/LICENSE
@@ -0,0 +1,251 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+=================================================================================================================
+
+This module implementation-script temporarily includes one file under the following BSD license:
+
+ Copyright (c) 2006, Sun Microsystems, Inc.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither the name of the Sun Microsystems, Inc. nor the names of
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+=================================================================================================================
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..aed41dbb4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,58 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.script.provider;
+ uses:="org.apache.tuscany.sca.databinding,org.apache.tuscany.sca.runt
+ ime,org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.databindin
+ g.impl,org.apache.tuscany.sca.provider,org.apache.bsf.xml,org.apache.
+ tuscany.sca.core,org.apache.tuscany.sca.interfacedef.java,org.w3c.dom
+ ,javax.script,org.apache.tuscany.sca.interfacedef,javax.xml.namespace
+ ,org.apache.axiom.om,org.apache.tuscany.sca.implementation.script,org
+ .apache.tuscany.sca.invocation,org.apache.tuscany.sca.core.factory,or
+ g.apache.tuscany.sca.interfacedef.wsdl";version="2.0.0"
+Private-Package: org.apache.tuscany.sca.implementation.script.engines;
+ version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Script Implementation Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397459984
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Script Implementation Extension
+Import-Package: com.sun.script.jruby,
+ javax.script,
+ javax.xml.namespace,
+ org.apache.axiom.om,
+ org.apache.bsf.xml,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.implementation.script;version="2.0.0",
+ org.apache.tuscany.sca.implementation.script.provider;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.jruby,
+ org.jruby.ast,
+ org.jruby.exceptions,
+ org.jruby.internal.runtime,
+ org.jruby.javasupport,
+ org.jruby.runtime,
+ org.jruby.runtime.builtin,
+ org.jruby.runtime.load,
+ org.jruby.util,
+ org.jruby.util.io,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.script.runt
+ ime
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/NOTICE
new file mode 100644
index 0000000000..c1b42b04ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/NOTICE
@@ -0,0 +1,12 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the BSD license
+(see the LICENSE file contained in this distribution), with
+the following copyright:
+
+Copyright (c) 2006, Sun Microsystems, Inc.
+All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/pom.xml
new file mode 100644
index 0000000000..3b1ff92fba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/pom.xml
@@ -0,0 +1,189 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-script-runtime</artifactId>
+ <name>Apache Tuscany SCA Script Implementation Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.bsf</groupId>
+ <artifactId>bsf-all</artifactId>
+ <version>3.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ <version>1.2.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+<!-- TODO: big hack to add script engine dependencies till extension dependencies fixed -->
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.7R2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jruby</groupId>
+ <artifactId>jruby-complete</artifactId>
+ <version>1.4.0</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm-commons</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython</artifactId>
+ <version>2.2.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.7.1</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.fusesource.jansi</groupId>
+ <artifactId>jansi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java
new file mode 100644
index 0000000000..0938462c49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.provider;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.bsf.xml.XMLHelper;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.script.ScriptImplementation;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * An ImplementationProvider for Script implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScriptImplementationProvider implements ImplementationProvider {
+
+ private RuntimeComponent component;
+ private ScriptImplementation implementation;
+ private ScriptPropertyFactory propertyFactory;
+ private ScriptEngine scriptEngine;
+ private XMLHelper xmlHelper;
+
+ public ScriptImplementationProvider(RuntimeComponent component, ScriptImplementation implementation, ScriptPropertyFactory propertyFactory) {
+ this.component = component;
+ this.implementation = implementation;
+ this.propertyFactory = propertyFactory;
+
+ // Set the databinding and XMLHelper for WSDL interfaces
+ for (Service service : component.getServices()) {
+ InterfaceContract ic = service.getInterfaceContract();
+ if (ic instanceof WSDLInterfaceContract) {
+ ic.getInterface().resetDataBinding(OMElement.class.getName());
+ xmlHelper = XMLHelper.getArgHelper(scriptEngine);
+ }
+ }
+ }
+
+ public void start() {
+ try {
+ String language = implementation.getLanguage();
+ if (language == null) {
+ language = implementation.getScript();
+ language = language.substring(language.lastIndexOf('.') +1);
+ }
+ scriptEngine = scriptEngine(language);
+ if (scriptEngine == null) {
+ throw new ObjectCreationException("no script engine found for language: " + implementation.getLanguage());
+ }
+ if (!(scriptEngine instanceof Invocable)) {
+ throw new ObjectCreationException("script engine does not support Invocable: " + scriptEngine);
+ }
+
+ for (Reference reference : implementation.getReferences()) {
+ scriptEngine.put(reference.getName(), getProxy(reference.getName()));
+ }
+
+ for (Property property : implementation.getProperties()) {
+ ObjectFactory<?> valueFactory = propertyFactory.createValueFactory(property);
+ if (valueFactory != null) {
+ scriptEngine.put(property.getName(), valueFactory.getInstance());
+ }
+ }
+
+ URL url = new URL(implementation.getLocation());
+ InputStreamReader reader = new InputStreamReader(url.openStream());
+ scriptEngine.eval(reader);
+ reader.close();
+
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ } catch (ScriptException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public void stop() {
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ return new ScriptInvoker(scriptEngine, xmlHelper, operation);
+ }
+
+ private Object getProxy(String name) {
+ for (ComponentReference reference : component.getReferences()) {
+ if (reference.getName().equals(name)) {
+ Class<?> iface = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass();
+ return component.getComponentContext().getService(iface, name);
+ }
+ }
+ throw new IllegalArgumentException("reference " + name + " not found on component: " + component);
+ }
+
+ /**
+ * Returns the script engine for the given language.
+ *
+ * @param language
+ * @return
+ */
+ private ScriptEngine scriptEngine(String language) {
+ if ("rb".equals(language)) {
+
+ // Hack for now to work around a problem with the JRuby script engine
+ // return new TuscanyJRubyScriptEngine();
+ } else {
+ if ("py".equals(language)) {
+ pythonCachedir();
+ }
+ }
+ // Allow privileged access to run access classes. Requires RuntimePermission
+ // for accessClassInPackage.sun.misc.
+ ScriptEngineManager scriptEngineManager =
+ AccessController.doPrivileged(new PrivilegedAction<ScriptEngineManager>() {
+ public ScriptEngineManager run() {
+ return new ScriptEngineManager();
+ }
+ });
+ return scriptEngineManager.getEngineByExtension(language);
+ }
+
+ /**
+ * If the Python home isn't set then let Tuscany suppress messages other than errors
+ * See TUSCANY-1950
+ */
+ private static void pythonCachedir() {
+ if (System.getProperty("python.home") == null) {
+ System.setProperty("python.verbose", "error");
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java
new file mode 100644
index 0000000000..67d4a5493c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.implementation.script.ScriptImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * An ImplementationProviderFactory for Script implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScriptImplementationProviderFactory implements ImplementationProviderFactory<ScriptImplementation> {
+
+ private ScriptPropertyFactory propertyFactory;
+
+ public ScriptImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ Mediator mediator = utilities.getUtility(Mediator.class);
+ SimpleTypeMapper simpleTypeMapper = utilities.getUtility(SimpleTypeMapper.class);
+ propertyFactory = new ScriptPropertyFactory(mediator, simpleTypeMapper);
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, ScriptImplementation Implementation) {
+ return new ScriptImplementationProvider(component, Implementation, propertyFactory);
+ }
+
+ public Class<ScriptImplementation> getModelType() {
+ return ScriptImplementation.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptInvoker.java
new file mode 100644
index 0000000000..976eb2c0dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptInvoker.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.provider;
+
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.bsf.xml.XMLHelper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Perform the actual script invocation
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScriptInvoker implements Invoker {
+
+ private ScriptEngine scriptEngine;
+ private XMLHelper xmlHelper;
+ private Operation operation;
+
+ public ScriptInvoker(ScriptEngine scriptEngine, XMLHelper xmlHelper, Operation operation) {
+ this.scriptEngine = scriptEngine;
+ this.xmlHelper = xmlHelper;
+ this.operation = operation;
+ }
+
+ private Object doInvoke(Object[] objects, Operation op) throws ScriptException {
+ if (xmlHelper != null) {
+ objects[0] = xmlHelper.toScriptXML((OMElement)objects[0]);
+ }
+
+ Operation oper = operation; // static setting
+ if (oper.getName() == null) { // if no static setting
+ oper = op; // use dynamic setting
+ }
+ Object response;
+ try {
+ response = ((Invocable)scriptEngine).invokeFunction(oper.getName(), objects);
+ } catch (ScriptException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ScriptException(e);
+ }
+
+ if (xmlHelper != null) {
+ response = xmlHelper.toOMElement(response);
+ }
+
+ return response;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = doInvoke((Object[])msg.getBody(), msg.getOperation());
+ msg.setBody(resp);
+ } catch (ScriptException e) {
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptPropertyFactory.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptPropertyFactory.java
new file mode 100644
index 0000000000..b56af79b0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptPropertyFactory.java
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * A property factory for script properties.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScriptPropertyFactory {
+ private Mediator mediator = null;
+ private SimpleTypeMapper simpleTypeMapper;
+ boolean isSimpleType;
+
+ public ScriptPropertyFactory(Mediator mediator, SimpleTypeMapper simpleTypeMapper) {
+ this.mediator = mediator;
+ this.simpleTypeMapper = simpleTypeMapper;
+ }
+
+ public ObjectFactory createValueFactory(Property property) {
+ isSimpleType = isSimpleType(property);
+ Document doc = (Document)property.getValue();
+ Element rootElement = doc.getDocumentElement();
+
+ //FIXME : since scripts use dynamic types we need to generate a dynamic java type using the
+ //XML structure of the property value. Should this be done in the JavaBeansDataBinding...
+ Class javaType = null;
+
+ if (property.isMany()) {
+ if (isSimpleType) {
+ String value = "";
+ if (rootElement.getChildNodes().getLength() > 0) {
+ value = rootElement.getChildNodes().item(0).getTextContent();
+ }
+ List<String> values =
+ getSimplePropertyValues(value, javaType);
+ return new ListObjectFactoryImpl(property,
+ values,
+ isSimpleType,
+ javaType);
+ } else {
+ return new ListObjectFactoryImpl(property,
+ getComplexPropertyValues(doc),
+ isSimpleType,
+ javaType);
+ }
+ } else {
+ if (isSimpleType) {
+ String value = "";
+ if (rootElement.getChildNodes().getLength() > 0) {
+ value = rootElement.getChildNodes().item(0).getTextContent();
+ }
+ return new ObjectFactoryImpl(property,
+ value,
+ isSimpleType,
+ javaType);
+ } else {
+ Object value = getComplexPropertyValues(doc).get(0);
+ return new ObjectFactoryImpl(property,
+ value,
+ isSimpleType,
+ javaType);
+ }
+
+ }
+ }
+
+ private boolean isSimpleType(Property property) {
+ if (property.getXSDType() != null) {
+ return simpleTypeMapper.isSimpleXSDType(property.getXSDType());
+ } else {
+ if (property instanceof Document) {
+ Document doc = (Document)property;
+ Element element = doc.getDocumentElement();
+ if (element.getChildNodes().getLength() == 1 &&
+ element.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private List<String> getSimplePropertyValues(String concatenatedValue, Class<?> javaType) {
+ List<String> propValues = new ArrayList<String>();
+ StringTokenizer st = null;
+ if ( javaType.getName().equals("java.lang.String")) {
+ st = new StringTokenizer(concatenatedValue, "\"");
+ } else {
+ st = new StringTokenizer(concatenatedValue);
+ }
+ String aToken = null;
+ while (st.hasMoreTokens()) {
+ aToken = st.nextToken();
+ if (aToken.trim().length() > 0) {
+ propValues.add(aToken);
+ }
+ }
+ return propValues;
+ }
+
+ private List<Node> getComplexPropertyValues(Document document) {
+ Element rootElement = document.getDocumentElement();
+ List<Node> propValues = new ArrayList<Node>();
+ for (int count = 0 ; count < rootElement.getChildNodes().getLength() ; ++count) {
+ if (rootElement.getChildNodes().item(count).getNodeType() == Node.ELEMENT_NODE) {
+ propValues.add(rootElement.getChildNodes().item(count));
+ }
+ }
+ return propValues;
+ }
+
+ public abstract class ObjectFactoryImplBase implements ObjectFactory {
+ protected Property property;
+ protected Object propertyValue;
+ protected Class<?> javaType;
+ protected DataType<XMLType> sourceDataType;
+ protected DataType<?> targetDataType;
+ boolean isSimpleType;
+
+ public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class<?> javaType) {
+
+ this.isSimpleType = isSimpleType;
+ this.property = property;
+ this.propertyValue = propertyValue;
+ this.javaType = javaType;
+
+ //FIXME : fix this when we have managed to generate dynamic java types
+
+ /*sourceDataType =
+ new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class,
+ new XMLType(null, this.property.getXSDType()));
+ TypeInfo typeInfo = null;
+ if (this.property.getXSDType() != null) {
+ if (SimpleTypeMapperExtension.isSimpleXSDType(this.property.getXSDType())) {
+ typeInfo = new TypeInfo(property.getXSDType(), true, null);
+ } else {
+ typeInfo = new TypeInfo(property.getXSDType(), false, null);
+ }
+ } else {
+ typeInfo = new TypeInfo(property.getXSDType(), false, null);
+ }
+
+ XMLType xmlType = new XMLType(typeInfo);
+ String dataBinding = null; //(String)property.getExtensions().get(DataBinding.class.getName());
+ if (dataBinding != null) {
+ targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+ } else {
+ targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+ mediator.getDataBindingRegistry().introspectType(targetDataType, null);
+ }*/
+ }
+ }
+
+ public class ObjectFactoryImpl extends ObjectFactoryImplBase {
+ public ObjectFactoryImpl(Property property, Object propertyValue, boolean isSimpleType, Class<?> javaType) {
+ super(property, propertyValue, isSimpleType, javaType);
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ if (isSimpleType) {
+ return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
+ } else {
+ return mediator.mediate(propertyValue, sourceDataType, targetDataType, null);
+ }
+ }
+ }
+
+ public class ListObjectFactoryImpl extends ObjectFactoryImplBase {
+ public ListObjectFactoryImpl(Property property, List<?>propertyValues, boolean isSimpleType, Class<?> javaType) {
+ super(property, propertyValues, isSimpleType, javaType);
+ }
+
+ public List<?> getInstance() throws ObjectCreationException {
+ if (isSimpleType) {
+ List<Object> values = new ArrayList<Object>();
+ for (String aValue : (List<String>)propertyValue) {
+ values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+ }
+ return values;
+ } else {
+ List<Object> instances = new ArrayList<Object>();
+ for (Node aValue : (List<Node>)propertyValue) {
+ instances.add(mediator.mediate(aValue,
+ sourceDataType,
+ targetDataType,
+ null));
+ }
+ return instances;
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..941cfd7fd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.script.provider.ScriptImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.script.ScriptImplementation
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java
new file mode 100644
index 0000000000..d9277c3ae1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractSCATestCase<T> extends TestCase {
+
+ protected Node node;
+ protected T service;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.getInstance().createNode(getCompositeName(), new Contribution("test", contribution));
+ node.start();
+ service = (T) node.getService(getServiceClass(), "ClientComponent");
+ }
+
+ protected abstract Class<T> getServiceClass();
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+ protected String getCompositeName() {
+ String className = this.getClass().getName();
+ return className.substring(0, className.length() - 8).replace('.', '/') + ".composite";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java
new file mode 100644
index 0000000000..1af3a295a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.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 org.apache.tuscany.sca.implementation.script.itests.helloworld;
+
+import org.apache.tuscany.sca.implementation.script.itests.AbstractSCATestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase<HelloWorld> {
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @Override
+ protected Class<HelloWorld> getServiceClass() {
+ return HelloWorld.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java
new file mode 100644
index 0000000000..6a4f10dbbb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.helloworld;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class GroovyHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorld.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..f87cf104f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorld.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.helloworld;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HelloWorld {
+
+ String sayHello(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorldProxy.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorldProxy.java
new file mode 100644
index 0000000000..cffe65c27a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorldProxy.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.sca.implementation.script.itests.helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldProxy implements HelloWorld {
+
+ @Reference
+ public HelloWorld delegate;
+
+ public String sayHello(String s) {
+ return delegate.sayHello(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java
new file mode 100644
index 0000000000..ca4bd5ae6a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.helloworld;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JRubyHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java
new file mode 100644
index 0000000000..46ed9abce6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.helloworld;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaScriptHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java
new file mode 100644
index 0000000000..d694515829
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.helloworld;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JythonHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/AbstractHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/AbstractHelloWorldTestCase.java
new file mode 100644
index 0000000000..e7375253a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/AbstractHelloWorldTestCase.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 org.apache.tuscany.sca.implementation.script.itests.properties;
+
+import org.apache.tuscany.sca.implementation.script.itests.AbstractSCATestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase<HelloWorld> {
+
+ public void testCalculator() throws Exception {
+ // assertEquals("Hello petra from Tuscany", service.sayHello("petra"));
+ }
+
+ @Override
+ protected Class<HelloWorld> getServiceClass() {
+ return HelloWorld.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorldTestCase.java
new file mode 100644
index 0000000000..f93edc76d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorldTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.properties;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class GroovyHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorld.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorld.java
new file mode 100644
index 0000000000..910d22ec83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorld.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.properties;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HelloWorld {
+
+ String sayHello(String s);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorldProxy.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorldProxy.java
new file mode 100644
index 0000000000..719212e831
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorldProxy.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.sca.implementation.script.itests.properties;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldProxy implements HelloWorld {
+
+ @Reference
+ public HelloWorld delegate;
+
+ public String sayHello(String s) {
+ return delegate.sayHello(s);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorldTestCase.java
new file mode 100644
index 0000000000..60c73359c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorldTestCase.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 org.apache.tuscany.sca.implementation.script.itests.properties;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JRubyHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java
new file mode 100644
index 0000000000..cde96b4b9b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.properties;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaScriptHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorldTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorldTestCase.java
new file mode 100644
index 0000000000..0e6be74e09
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorldTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.properties;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JythonHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReferenceTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReferenceTestCase.java
new file mode 100644
index 0000000000..6116581356
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReferenceTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.script.itests.references;
+
+import org.apache.tuscany.sca.implementation.script.itests.helloworld.AbstractHelloWorldTestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class GroovyReferenceTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/HelloWorldTarget.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/HelloWorldTarget.java
new file mode 100644
index 0000000000..dfcd37c46c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/HelloWorldTarget.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.itests.references;
+
+import org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorld;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldTarget implements HelloWorld {
+
+ public String sayHello(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReferenceTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReferenceTestCase.java
new file mode 100644
index 0000000000..83c2e99469
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReferenceTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.script.itests.references;
+
+import org.apache.tuscany.sca.implementation.script.itests.helloworld.AbstractHelloWorldTestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JRubyReferenceTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReferenceTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReferenceTestCase.java
new file mode 100644
index 0000000000..392e16411c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReferenceTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.script.itests.references;
+
+import org.apache.tuscany.sca.implementation.script.itests.helloworld.AbstractHelloWorldTestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaScriptReferenceTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JythonReferenceTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JythonReferenceTestCase.java
new file mode 100644
index 0000000000..8866ae6b70
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JythonReferenceTestCase.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.script.itests.references;
+
+import org.apache.tuscany.sca.implementation.script.itests.helloworld.AbstractHelloWorldTestCase;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JythonReferenceTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorld.composite
new file mode 100644
index 0000000000..056fb5b4ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="GroovyHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorld.composite
new file mode 100644
index 0000000000..05dd2bab22
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JRubyHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite
new file mode 100644
index 0000000000..fc9c7d1055
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JavaScriptHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorld.composite
new file mode 100644
index 0000000000..3cc28fc531
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JythonHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.componentType b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.componentType
new file mode 100644
index 0000000000..f190d5ef35
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.componentType
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorld" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy
new file mode 100644
index 0000000000..9f89bd373e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def sayHello(s) {
+ return "Hello " + s
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js
new file mode 100644
index 0000000000..eac2ab283f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function sayHello(s) {
+
+ return "Hello " + s;
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py
new file mode 100644
index 0000000000..f5dd0f8fcf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+def sayHello(s):
+ return 'Hello ' + s \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb
new file mode 100644
index 0000000000..cd2d3bcaea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+def sayHello(s)
+ return "Hello " + s
+end \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorld.composite
new file mode 100644
index 0000000000..dd8279049d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="GroovyProperties">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.properties.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorld.composite
new file mode 100644
index 0000000000..40e8d18a31
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JRubyProperties">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.properties.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent" />
+ </component>
+
+ <component name="HelloWorldComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorld.composite
new file mode 100644
index 0000000000..b258d69229
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JavaScriptProperties">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.properties.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorld.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorld.composite
new file mode 100644
index 0000000000..a3e15e53b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JythonProperties">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.properties.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.componentType b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.componentType
new file mode 100644
index 0000000000..4cf7172ebc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.componentType
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorld" />
+ </service>
+
+ <property name="greeter" type="xsd:string">Tuscany</property>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy
new file mode 100644
index 0000000000..a7eb446d37
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def sayHello(s) {
+ return "Hello " + s + " from " + greeter
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js
new file mode 100644
index 0000000000..64df3ebbef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function sayHello(s) {
+
+ return "Hello " + s + " from " + greeter;
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py
new file mode 100644
index 0000000000..868cfa9eeb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+def sayHello(s):
+ return 'Hello ' + s + ' from ' + greeter \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb
new file mode 100644
index 0000000000..2844f8b8d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+def sayHello(s)
+ return "Hello " + s + " from " + $greeter
+end \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReference.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReference.composite
new file mode 100644
index 0000000000..4cfcec2f4e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReference.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="GroovyReference">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="ReferenceComponent"></reference>
+ </component>
+
+ <component name="ReferenceComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy"/>
+ <reference name="ref" target="TargetComponent" />
+ </component>
+
+ <component name="TargetComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.references.HelloWorldTarget"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReference.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReference.composite
new file mode 100644
index 0000000000..da4e721faf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReference.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JRubyReference">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="ReferenceComponent"></reference>
+ </component>
+
+ <component name="ReferenceComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/references/reference.rb"/>
+ <reference name="ref" target="TargetComponent" />
+ </component>
+
+ <component name="TargetComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.references.HelloWorldTarget"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReference.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReference.composite
new file mode 100644
index 0000000000..d741cc1c89
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReference.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JavaScriptReference">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="ReferenceComponent"></reference>
+ </component>
+
+ <component name="ReferenceComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/references/reference.js"/>
+ <reference name="ref" target="TargetComponent" />
+ </component>
+
+ <component name="TargetComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.references.HelloWorldTarget"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JythonReference.composite b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JythonReference.composite
new file mode 100644
index 0000000000..23f78ec342
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JythonReference.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://sample"
+ name="JythonReference">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="ReferenceComponent"></reference>
+ </component>
+
+ <component name="ReferenceComponent">
+ <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/references/reference.py"/>
+ <reference name="ref" target="TargetComponent" />
+ </component>
+
+ <component name="TargetComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.script.itests.references.HelloWorldTarget"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.componentType b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.componentType
new file mode 100644
index 0000000000..347e9b1c40
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.componentType
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorld" />
+ </service>
+
+ <reference name="ref">
+ <interface.java interface="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorld" />
+ </reference>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy
new file mode 100644
index 0000000000..5d2216d583
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def sayHello(s) {
+ return ref.sayHello(s)
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.js b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.js
new file mode 100644
index 0000000000..ad0a932d26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.js
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function sayHello(s) {
+ return ref.sayHello(s);
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.py b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.py
new file mode 100644
index 0000000000..aee8bf991d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.py
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+def sayHello(s):
+ return ref.sayHello(s)
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.rb b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.rb
new file mode 100644
index 0000000000..87f0f56082
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.rb
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+def sayHello(s)
+ return $ref.sayHello(s)
+end \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-script/LICENSE
new file mode 100644
index 0000000000..4b5ab74408
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/LICENSE
@@ -0,0 +1,251 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+=================================================================================================================
+
+This module implementation-script temporarily includes one file under the following BSD license:
+
+ Copyright (c) 2006, Sun Microsystems, Inc.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither the name of the Sun Microsystems, Inc. nor the names of
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+=================================================================================================================
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-script/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..4b7bb9a472
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.script;uses:="ja
+ vax.xml.stream,org.apache.tuscany.sca.assembly,org.apache.tuscany.sca
+ .contribution.resolver,org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,org.apache.tuscany.sca.contribution,org.a
+ pache.tuscany.sca.monitor,javax.xml.namespace";version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Script Implementation Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397453750
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Script Implementation Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.implementation.script;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.script
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-script/NOTICE
new file mode 100644
index 0000000000..c1b42b04ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/NOTICE
@@ -0,0 +1,12 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the BSD license
+(see the LICENSE file contained in this distribution), with
+the following copyright:
+
+Copyright (c) 2006, Sun Microsystems, Inc.
+All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-script/pom.xml
new file mode 100644
index 0000000000..0aad4c121d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/pom.xml
@@ -0,0 +1,48 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-script</artifactId>
+ <name>Apache Tuscany SCA Script Implementation Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java
new file mode 100644
index 0000000000..d34dde61eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.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.sca.implementation.script;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Implementation;
+
+/**
+ * Represents a Script implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ScriptImplementation extends Implementation {
+ QName TYPE = new QName(Base.SCA11_TUSCANY_NS, "implementation.script");
+
+ String getScript();
+
+ void setScript(String script);
+
+ String getLocation();
+
+ void setLocation(String location);
+
+ void setLanguage(String language);
+
+ String getLanguage();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationFactory.java b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationFactory.java
new file mode 100644
index 0000000000..c7a4c7fa2d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationFactory.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script;
+
+/**
+ *
+ */
+public interface ScriptImplementationFactory {
+ ScriptImplementation createScriptImplementation();
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/impl/ScriptImplementationFactoryImpl.java b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/impl/ScriptImplementationFactoryImpl.java
new file mode 100644
index 0000000000..d85d8924ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/impl/ScriptImplementationFactoryImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.impl;
+
+import org.apache.tuscany.sca.implementation.script.ScriptImplementation;
+import org.apache.tuscany.sca.implementation.script.ScriptImplementationFactory;
+
+/**
+ *
+ */
+public class ScriptImplementationFactoryImpl implements ScriptImplementationFactory {
+
+ public ScriptImplementation createScriptImplementation() {
+ return new ScriptImplementationImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/impl/ScriptImplementationImpl.java b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/impl/ScriptImplementationImpl.java
new file mode 100644
index 0000000000..a610e77147
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/impl/ScriptImplementationImpl.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.script.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.implementation.script.ScriptImplementation;
+
+/**
+ * Represents a Script implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScriptImplementationImpl extends ImplementationImpl implements ScriptImplementation {
+ public static final QName TYPE = new QName(Base.SCA11_TUSCANY_NS, "implementation.script");
+
+ private String script; // Relative URI to the script
+ private String language; // Scripting lang
+ private String location; // Resolved location of the script
+
+ public ScriptImplementationImpl() {
+ super(TYPE);
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public void setScript(String script) {
+ this.script = script;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ @Override
+ public String toString() {
+ return "Script : " + getScript();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((language == null) ? 0 : language.hashCode());
+ result = prime * result + ((script == null) ? 0 : script.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ScriptImplementationImpl other = (ScriptImplementationImpl)obj;
+ if (language == null) {
+ if (other.language != null)
+ return false;
+ } else if (!language.equals(other.language))
+ return false;
+ if (script == null) {
+ if (other.script != null)
+ return false;
+ } else if (!script.equals(other.script))
+ return false;
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java
new file mode 100644
index 0000000000..a3f302d4fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/xml/ScriptImplementationProcessor.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.script.xml;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.script.ScriptImplementation;
+import org.apache.tuscany.sca.implementation.script.ScriptImplementationFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * ScriptImplementationProcessor
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScriptImplementationProcessor implements StAXArtifactProcessor<ScriptImplementation> {
+ private static final QName IMPLEMENTATION_SCRIPT = ScriptImplementation.TYPE;
+
+ private AssemblyFactory assemblyFactory;
+ private ContributionFactory contributionFactory;
+ private ScriptImplementationFactory scriptImplementationFactory;
+
+ public ScriptImplementationProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ scriptImplementationFactory = modelFactories.getFactory(ScriptImplementationFactory.class);
+ }
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_SCRIPT;
+ }
+
+ public Class<ScriptImplementation> getModelType() {
+ return ScriptImplementation.class;
+ }
+
+ public ScriptImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ // Read an <implementation.script> element
+
+ // Create and initialize the script implementation model
+ ScriptImplementation implementation = scriptImplementationFactory.createScriptImplementation();
+ implementation.setUnresolved(true);
+
+ // Read the script attribute
+ String script = reader.getAttributeValue(null, "script");
+ if (script != null) {
+ implementation.setScript(script);
+ }
+
+ // Read the language attribute
+ String language = reader.getAttributeValue(null, "language");
+ if (language != null) {
+ implementation.setLanguage(language);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_SCRIPT.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return implementation;
+ }
+
+ public void resolve(ScriptImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Resolve the script location
+ if (implementation.getScript() != null) {
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(implementation.getScript());
+ Artifact resolved = resolver.resolveModel(Artifact.class, artifact, context);
+ if (resolved.getLocation() != null) {
+ implementation.setLocation(resolved.getLocation());
+ } else {
+ error(context.getMonitor(), "CouldNotResolveScript", resolver, implementation.getScript());
+ }
+
+ // Resolve the componentType and add the declared properties, references
+ // and services to the implementation
+ String componentTypeURI = implementation.getScript();
+ componentTypeURI = componentTypeURI.substring(0, componentTypeURI.lastIndexOf('.'));
+ componentTypeURI += ".componentType";
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setUnresolved(true);
+ componentType.setURI(componentTypeURI);
+ componentType = resolver.resolveModel(ComponentType.class, componentType, context);
+ if (!componentType.isUnresolved()) {
+ implementation.getProperties().addAll(componentType.getProperties());
+ implementation.getReferences().addAll(componentType.getReferences());
+ implementation.getServices().addAll(componentType.getServices());
+ }
+ }
+
+ implementation.setUnresolved(false);
+ }
+
+ public void write(ScriptImplementation implementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <implementation.script>
+ writer.setPrefix("script", IMPLEMENTATION_SCRIPT.getNamespaceURI());
+ writer.writeStartElement(IMPLEMENTATION_SCRIPT.getNamespaceURI(), IMPLEMENTATION_SCRIPT.getLocalPart());
+ writer.writeNamespace("script", IMPLEMENTATION_SCRIPT.getNamespaceURI());
+
+ if (implementation.getScript() != null) {
+ writer.writeAttribute("script", implementation.getScript());
+ }
+ if (implementation.getLanguage() != null) {
+ writer.writeAttribute("language", implementation.getLanguage());
+ }
+
+ writer.writeEndElement();
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "impl-script-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..c3db94d4a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.implementation.script.xml.ScriptImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.script,model=org.apache.tuscany.sca.implementation.script.ScriptImplementation \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.script.ScriptImplementationFactory b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.script.ScriptImplementationFactory
new file mode 100644
index 0000000000..5da5a817aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.script.ScriptImplementationFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.implementation.script.impl.ScriptImplementationFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/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/sebastien/java/embed/modules/implementation-spring-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b598607625
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,63 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring.xml;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.injection;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.springframework.beans;version="3.0.2.RELEASE",
+ org.springframework.beans.factory;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.annotation;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.config;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.support;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.xml;version="3.0.2.RELEASE",
+ org.springframework.context;version="3.0.2.RELEASE",
+ org.springframework.context.support;version="3.0.2.RELEASE",
+ org.springframework.core;version="3.0.2.RELEASE",
+ org.springframework.core.io;version="3.0.2.RELEASE",
+ org.springframework.util;version="3.0.2.RELEASE"
+Export-Package: org.apache.tuscany.sca.implementation.spring.context;version="2.0.0";
+ uses:="org.springframework.beans.factory.support,
+ org.springframework.context.support,
+ org.springframework.core.io,
+ org.apache.tuscany.sca.implementation.spring,
+ org.springframework.context,
+ org.apache.tuscany.sca.implementation.spring.provider,
+ org.springframework.beans.factory.config,
+ org.springframework.beans.factory"
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/pom.xml
new file mode 100644
index 0000000000..b08e1c8930
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/pom.xml
@@ -0,0 +1,81 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Runtime Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Spring dependencies... -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAGenericApplicationContext.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAGenericApplicationContext.java
new file mode 100644
index 0000000000..44a3ee2b88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAGenericApplicationContext.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.sca.implementation.spring.context;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement;
+import org.apache.tuscany.sca.implementation.spring.SpringPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.ConstructorArgumentValues;
+import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
+import org.springframework.beans.factory.config.TypedStringValue;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SCAGenericApplicationContext extends GenericApplicationContext {
+
+ private ClassLoader classloader = null;
+ private List<SpringSCAPropertyElement> propertyElements = new ArrayList<SpringSCAPropertyElement>();
+ private List<SpringSCAServiceElement> serviceElements = new ArrayList<SpringSCAServiceElement>();
+ private List<SpringSCAReferenceElement> referenceElements = new ArrayList<SpringSCAReferenceElement>();
+ private List<SpringBeanElement> beanElements;
+
+ public SCAGenericApplicationContext(DefaultListableBeanFactory beanFactory,
+ ApplicationContext parent,
+ ClassLoader classloader) {
+ super(beanFactory, parent);
+ this.classloader = classloader;
+ }
+
+ public SCAGenericApplicationContext(ApplicationContext parent, ClassLoader classloader) {
+ super(parent);
+ this.classloader = classloader;
+ }
+
+ @Override
+ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
+ beanFactory.setBeanClassLoader(classloader);
+ }
+
+ public void addSCAPropertyElement(SpringSCAPropertyElement propertyElement) {
+ propertyElements.add(propertyElement);
+ }
+
+ public void addSCAServiceElement(SpringSCAServiceElement serviceElement) {
+ serviceElements.add(serviceElement);
+ }
+
+ public void addSCAReferenceElement(SpringSCAReferenceElement referenceElement) {
+ referenceElements.add(referenceElement);
+ }
+
+ public synchronized List<SpringBeanElement> getBeanElements() {
+ if (beanElements == null) {
+ beanElements = new ArrayList<SpringBeanElement>();
+ for (String name : getBeanDefinitionNames()) {
+ BeanDefinition def = getBeanDefinition(name);
+ SpringBeanElement beanElement = new SpringBeanElement(name, def.getBeanClassName());
+ beanElements.add(beanElement);
+ beanElement.setAbstractBean(def.isAbstract());
+ beanElement.setFactoryBeanAttribute(def.getFactoryBeanName() != null);
+ beanElement.setFactoryMethodAttribute(def.getFactoryMethodName() != null);
+ beanElement.setParentAttribute(def.getParentName() != null);
+ beanElement.setInnerBean(beanElement.getId() == null);
+
+ ConstructorArgumentValues args = def.getConstructorArgumentValues();
+ for (Map.Entry<Integer, ValueHolder> e: args.getIndexedArgumentValues().entrySet()) {
+ ValueHolder holder = e.getValue();
+ SpringConstructorArgElement arg = new SpringConstructorArgElement(holder.getType());
+ arg.setIndex(e.getKey());
+ beanElement.addCustructorArgs(arg);
+ }
+
+ MutablePropertyValues values = def.getPropertyValues();
+ for (PropertyValue p : values.getPropertyValueList()) {
+ SpringPropertyElement propertyElement = new SpringPropertyElement(p.getName());
+ Object value = p.getValue();
+ configurePropertyElement(propertyElement, value);
+ beanElement.getProperties().add(propertyElement);
+ }
+ }
+ }
+ return beanElements;
+ }
+
+ public void configurePropertyElement(SpringPropertyElement propertyElement, Object value) {
+ if (value instanceof BeanReference) {
+ BeanReference beanRef = (BeanReference)value;
+ propertyElement.addRef(beanRef.getBeanName());
+ } else if (value instanceof Collection) {
+ Collection collection = (Collection)value;
+ for (Object item : collection) {
+ configurePropertyElement(propertyElement, item);
+ }
+ } else if (value instanceof TypedStringValue) {
+ TypedStringValue stringValue = (TypedStringValue)value;
+ propertyElement.addValue(stringValue.getValue());
+ } else {
+ if (value != null) {
+ propertyElement.addValue(value.toString());
+ }
+ }
+ }
+
+ public List<SpringSCAPropertyElement> getPropertyElements() {
+ return propertyElements;
+ }
+
+ public List<SpringSCAServiceElement> getServiceElements() {
+ return serviceElements;
+ }
+
+ public List<SpringSCAReferenceElement> getReferenceElements() {
+ return referenceElements;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAParentApplicationContext.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAParentApplicationContext.java
new file mode 100644
index 0000000000..cd81facc3d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SCAParentApplicationContext.java
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.spring.provider.SpringImplementationWrapper;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.MessageSourceResolvable;
+import org.springframework.context.NoSuchMessageException;
+import org.springframework.core.io.Resource;
+
+/**
+ * A Spring ParentApplicationContext for a given Spring Implementation
+ *
+ * The Parent application context is responsible for handling those entities within a Spring
+ * application context that actually belong to SCA rather than to Spring. The principal things
+ * are Properties and References. These may be present either through explicit <sca:property/>
+ * and <sca:reference/> elements in the application context or they may be implicit through
+ * unresolved Spring bean <property.../> elements. In either case, it is the Parent application
+ * context that must provide Spring beans that correspond to the property or reference, as derived
+ * from the SCA composite in which the Spring application context is an implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAParentApplicationContext implements ApplicationContext {
+
+ // The Spring implementation for which this is the parent application context
+ private SpringImplementationWrapper implementation;
+
+ private static final String[] EMPTY_ARRAY = new String[0];
+
+ public SCAParentApplicationContext(SpringImplementationWrapper implementation) {
+ this.implementation = implementation;
+ } // end constructor
+
+ public Object getBean(String name) throws BeansException {
+ return getBean(name, (Class)null);
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class requiredType) throws BeansException {
+ Object bean = implementation.getBean(name, requiredType);
+ if (bean == null && getParent() != null) {
+ bean = getParent().getBean(name, requiredType);
+ }
+ if (bean == null) {
+ throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name);
+ } else {
+ return bean;
+ }
+ } // end method getBean( String, Class )
+
+ public Object getBean(String name, Object[] args) throws BeansException {
+ return getBean(name, ((Class)null));
+ }
+
+ public <T> T getBean(Class<T> clazz) throws BeansException {
+ return clazz.cast(getBean(clazz.getName(), clazz));
+ }
+
+ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> clazz) throws BeansException {
+ return null;
+ }
+
+ public <A extends Annotation> A findAnnotationOnBean(String arg0, Class<A> clazz) {
+ return null;
+ }
+
+ public boolean containsBean(String name) {
+ // TODO
+ return false;
+ }
+
+ public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+ // TODO
+ return false;
+ }
+
+ public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class getType(String name) throws NoSuchBeanDefinitionException {
+ return null;
+ }
+
+ public String[] getAliases(String name) throws NoSuchBeanDefinitionException {
+ return EMPTY_ARRAY;
+ }
+
+ public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
+ return null;
+ }
+
+ public String getId() {
+ return this.toString();
+ }
+
+ public String getDisplayName() {
+ return implementation.getURI();
+ }
+
+ public long getStartupDate() {
+ return 0;
+ }
+
+ public boolean containsBeanDefinition(String beanName) {
+ return false;
+ }
+
+ public int getBeanDefinitionCount() {
+ return 0;
+ }
+
+ public String[] getBeanDefinitionNames() {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type) {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean includeFactoryBeans) {
+ return new String[0];
+ }
+
+ public Map getBeansOfType(Class type) throws BeansException {
+ return null;
+ }
+
+ public Map getBeansOfType(Class type, boolean includePrototypes, boolean includeFactoryBeans) throws BeansException {
+ return null;
+ }
+
+ public boolean isPrototype(String theString) {
+ return false;
+ }
+
+ public BeanFactory getParentBeanFactory() {
+ return null;
+ }
+
+ public boolean containsLocalBean(String name) {
+ return false;
+ }
+
+ public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
+ return null;
+ }
+
+ public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public void publishEvent(ApplicationEvent event) {
+
+ }
+
+ public Resource[] getResources(String locationPattern) throws IOException {
+ return new Resource[0];
+ }
+
+ public Resource getResource(String location) {
+ return null;
+ }
+
+ public ClassLoader getClassLoader() {
+ // REVIEW: this is almost certainly flawed, but it's not clear how the SCA runtime's
+ // resource loading mechanism is exposed right now.
+ return this.getClass().getClassLoader();
+ }
+
+ @Override
+ public ApplicationContext getParent() {
+ return implementation.getParentApplicationContext();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java
new file mode 100644
index 0000000000..2d18b5aa6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.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.implementation.spring.context;
+
+import org.springframework.context.ApplicationContext;
+
+/**
+ * A utility to receive the parent Spring application context
+ */
+public interface SpringApplicationContextAccessor {
+ /**
+ * Get the parent Spring application context for the hosting environment. This will be used as the parent
+ * application context for implementation.spring components
+ * @return The parent application context
+ */
+ ApplicationContext getParentApplicationContext();
+
+ /**
+ * Set the root Spring application context. This is particually useful for Spring web integration where Spring
+ * creates WebApplicationContext and keeps it in the ServletContext
+ * @param parentApplicationContext The parent application context
+ */
+ void setParentApplicationContext(ApplicationContext parentApplicationContext);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringContextWrapper.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringContextWrapper.java
new file mode 100644
index 0000000000..4b0ad72972
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringContextWrapper.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.spring.processor.ComponentNameAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.ConstructorAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.InitDestroyAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.PropertyAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.ReferenceAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.provider.ComponentWrapper;
+import org.apache.tuscany.sca.implementation.spring.provider.PropertyValueWrapper;
+import org.apache.tuscany.sca.implementation.spring.provider.SpringImplementationWrapper;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * This is the runtime side tie for the corresponding tuscany side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextStub class
+ * in the implementation-spring module for what the stub does.
+ */
+public class SpringContextWrapper {
+
+ private GenericApplicationContext springContext;
+ private SpringImplementationWrapper implementation;
+
+ public SpringContextWrapper(SpringImplementationWrapper implementation, List<URL> resource) {
+ this.implementation = implementation;
+ SCAParentApplicationContext scaParentContext = new SCAParentApplicationContext(implementation);
+ springContext = createApplicationContext(scaParentContext, resource);
+ }
+
+ public ApplicationContext getApplicationContext() {
+ return springContext;
+ }
+
+ public void start() {
+ // Do refresh here to ensure that Spring Beans are not touched before the SCA config process is complete...
+ springContext.refresh();
+ springContext.start();
+ }
+
+ public void close() {
+ springContext.close();
+ if (springContext instanceof GenericApplicationContext) {
+ springContext.stop();
+ }
+ }
+
+ /**
+ * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ */
+ private GenericApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext,
+ List<URL> resources) {
+
+ GenericApplicationContext appCtx =
+ new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader());
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+ xmlReader.setBeanClassLoader(implementation.getClassLoader());
+ includeAnnotationProcessors(appCtx.getBeanFactory());
+ return appCtx;
+
+ }
+
+ public Object getBean(String id) throws BeansException {
+ return springContext.getBean(id);
+ }
+
+ /**
+ * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ */
+ private void includeAnnotationProcessors(ConfigurableListableBeanFactory beanFactory) {
+
+ // Processor to deal with @Init and @Destroy SCA Annotations
+ BeanPostProcessor initDestroyProcessor = new InitDestroyAnnotationProcessor();
+ beanFactory.addBeanPostProcessor(initDestroyProcessor);
+
+ // Processor to deal with @Reference SCA Annotations
+ ComponentWrapper component = implementation.getComponentWrapper();
+ BeanPostProcessor referenceProcessor = new ReferenceAnnotationProcessor(component);
+ beanFactory.addBeanPostProcessor(referenceProcessor);
+
+ // Processor to deal with @Property SCA Annotations
+ PropertyValueWrapper pvs = implementation.getPropertyValueWrapper();
+ BeanPostProcessor propertyProcessor = new PropertyAnnotationProcessor(pvs);
+ beanFactory.addBeanPostProcessor(propertyProcessor);
+
+ // Processor to deal with @ComponentName SCA Annotations
+ BeanPostProcessor componentNameProcessor =
+ new ComponentNameAnnotationProcessor(implementation.getComponentName());
+ beanFactory.addBeanPostProcessor(componentNameProcessor);
+
+ // Processor to deal with @Constructor SCA Annotations
+ BeanPostProcessor constructorProcessor = new ConstructorAnnotationProcessor();
+ beanFactory.addBeanPostProcessor(constructorProcessor);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
new file mode 100644
index 0000000000..75e00007f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.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.sca.implementation.spring.namespace;
+
+import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.NamespaceHandler;
+
+/**
+ * Overrides the default Spring namespace resolver to automatically register
+ * {@link ScaNamespaceHandler} instead of requiring a value to be supplied in a
+ * Spring configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCANamespaceHandlerResolver extends DefaultNamespaceHandlerResolver {
+ private static final String SCA_NAMESPACE = "http://www.springframework.org/schema/sca";
+
+ private ScaNamespaceHandler handler;
+
+ public SCANamespaceHandlerResolver(ClassLoader classLoader) {
+ super(classLoader);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ public SCANamespaceHandlerResolver(String handlerMappingsLocation, ClassLoader classLoader) {
+ super(classLoader, handlerMappingsLocation);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ @Override
+ public NamespaceHandler resolve(String namespaceUri) {
+ if (SCA_NAMESPACE.equals(namespaceUri)) {
+ return handler;
+ }
+ return super.resolve(namespaceUri);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
new file mode 100644
index 0000000000..66cb3c76fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Handler for the &lt;sca:&gt; namespace in an application context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaNamespaceHandler extends NamespaceHandlerSupport {
+
+ public ScaNamespaceHandler() {
+ }
+
+ @Override
+ public void init() {
+ registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+ registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+ registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+ }
+
+ private static String getNamespaceURI(Element element, String prefix) {
+ if (element == null) {
+ return null;
+ }
+ String name = ("".equals(prefix)) ? "xmlns" : "xmlns:" + prefix;
+ String ns = element.getAttribute(name);
+ if (ns != null && !"".equals(ns)) {
+ return ns;
+ }
+ Node parent = element.getParentNode();
+ if (parent instanceof Element) {
+ return getNamespaceURI((Element)parent, prefix);
+ } else {
+ return null;
+ }
+ }
+
+ public static List<QName> resolve(Element element, String listOfNames) {
+ List<QName> qnames = new ArrayList<QName>();
+ StringTokenizer tokenizer = new StringTokenizer(listOfNames);
+ while (tokenizer.hasMoreTokens()) {
+ String qname = tokenizer.nextToken();
+ String prefix = "";
+ String local = qname;
+ int index = qname.indexOf(':');
+ if (index != -1) {
+ local = qname.substring(index + 1);
+ prefix = qname.substring(0, index);
+ }
+ String ns = getNamespaceURI(element, prefix);
+ if (ns != null) {
+ qnames.add(new QName(ns, local, prefix));
+ } else {
+ throw new IllegalArgumentException("Prefix " + prefix + "is not bound to a namespace");
+ }
+ }
+ return qnames;
+ }
+
+ public static String getAttribute(Element element, String name) {
+ String attr = element.getAttributeNS(null, name);
+ if ("".equals(attr)) {
+ return null;
+ } else {
+ return attr;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
new file mode 100644
index 0000000000..bff0aa84e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ * @version $Rev$ $Date$
+ */
+public class ScaPropertyBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAPropertyElement propertyElement =
+ new SpringSCAPropertyElement(element.getAttributeNS(null, "name"), element.getAttributeNS(null, "type"));
+ context.addSCAPropertyElement(propertyElement);
+ }
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
new file mode 100644
index 0000000000..ab797c1e52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace;
+
+import static org.apache.tuscany.sca.implementation.spring.namespace.ScaNamespaceHandler.getAttribute;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaReferenceBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAReferenceElement referenceElement =
+ new SpringSCAReferenceElement(getAttribute(element, "name"), getAttribute(element, "type"));
+ referenceElement.setDefaultBean(getAttribute(element, "default"));
+
+ String requires = getAttribute(element, "requires");
+ if (requires != null) {
+ List<QName> qnames = ScaNamespaceHandler.resolve(element, requires);
+ referenceElement.getIntentNames().addAll(qnames);
+ }
+
+ String policySets = getAttribute(element, "policySets");
+ if (policySets != null) {
+ List<QName> qnames = ScaNamespaceHandler.resolve(element, policySets);
+ referenceElement.getPolicySetNames().addAll(qnames);
+ }
+
+ context.addSCAReferenceElement(referenceElement);
+ }
+
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
new file mode 100644
index 0000000000..6a3beebcff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace;
+
+import static org.apache.tuscany.sca.implementation.spring.namespace.ScaNamespaceHandler.getAttribute;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:service/&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaServiceBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAServiceElement serviceElement =
+ new SpringSCAServiceElement(getAttribute(element, "name"), getAttribute(element, "target"));
+ serviceElement.setType(getAttribute(element, "type"));
+
+ String requires = getAttribute(element, "requires");
+ if (requires != null) {
+ List<QName> qnames = ScaNamespaceHandler.resolve(element, requires);
+ serviceElement.getIntentNames().addAll(qnames);
+ }
+
+ String policySets = getAttribute(element, "policySets");
+ if (policySets != null) {
+ List<QName> qnames = ScaNamespaceHandler.resolve(element, policySets);
+ serviceElement.getPolicySetNames().addAll(qnames);
+ }
+
+ context.addSCAServiceElement(serviceElement);
+ }
+ // do nothing, handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
new file mode 100644
index 0000000000..68d49bbc24
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.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.implementation.spring.processor;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.ref.Reference;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.ComponentName;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
+
+ private String componentName;
+
+ public ComponentNameAnnotationProcessor(String componentName) {
+ this.componentName = componentName;
+ }
+
+ /**
+ * Gets componentName annotation type.
+ */
+ protected Class<? extends Annotation> getComponentNameAnnotationType() {
+ return this.componentNameAnnotationType;
+ }
+
+ /**
+ * Sets componentName annotation type.
+ */
+ public void setComponentNameAnnotationType(Class<? extends Annotation> componentNameAnnotationType) {
+ Assert.notNull(componentNameAnnotationType, "'componentNameAnnotationType' type must not be null.");
+ this.componentNameAnnotationType = componentNameAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+ Annotation annotation = field.getAnnotation(getComponentNameAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on static fields");
+ }
+
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on private fields");
+ }
+
+ ReflectionUtils.makeAccessible(field);
+
+ if (field.getType().getName().equals("java.lang.String")) {
+ Object nameObj = componentName;
+ if (nameObj != null)
+ ReflectionUtils.setField(field, bean, nameObj);
+ } else {
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+ Annotation annotation = method.getAnnotation(getComponentNameAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on static methods");
+ }
+
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on private methods");
+ }
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException(
+ "ComponentName annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+
+ if (pd.getPropertyType().getName().equals("java.lang.String")) {
+ Object nameObj = componentName;
+ if (nameObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {nameObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
+ }
+ }
+ } else {
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
new file mode 100644
index 0000000000..a52a85ff3a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
+import org.springframework.util.Assert;
+
+public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostProcessorAdapter {
+
+ private Class<? extends Annotation> constructorAnnotationType = org.oasisopen.sca.annotation.Constructor.class;
+
+ private Class<? extends Annotation> autowiredAnnotationType = Autowired.class;
+
+ public ConstructorAnnotationProcessor() {
+ // Default constructor.
+ }
+
+ /**
+ * Set the 'autowired' annotation type, to be used on constructors, fields,
+ * setter methods and arbitrary config methods.
+ */
+ public void setAutowiredAnnotationType(Class<? extends Annotation> autowiredAnnotationType) {
+ Assert.notNull(autowiredAnnotationType, "'autowiredAnnotationType' must not be null");
+ this.autowiredAnnotationType = autowiredAnnotationType;
+ }
+
+ /**
+ * Return the 'autowired' annotation type.
+ */
+ protected Class<? extends Annotation> getAutowiredAnnotationType() {
+ return this.autowiredAnnotationType;
+ }
+
+ /**
+ * Return the 'constructor' annotation type.
+ */
+ protected Class<? extends Annotation> getConstructorAnnotationType() {
+ return this.constructorAnnotationType;
+ }
+
+ /**
+ * Sets the 'constructor' annotation type.
+ */
+ public void setConstructorAnnotationType(Class<? extends Annotation> constructorAnnotationType) {
+ Assert.notNull(constructorAnnotationType, "'constructorAnnotationType' type must not be null.");
+ this.constructorAnnotationType = constructorAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
+ /*Constructor[] declaredConstructors = beanClass.getDeclaredConstructors();
+ Method[] declaredMethods = beanClass.getDeclaredMethods();
+ List candidates = new ArrayList(declaredConstructors.length);
+
+ for (int i = 0; i < declaredMethods.length; i++) {
+ Method method = declaredMethods[i];
+ Annotation annotation = method.getAnnotation(getConstructorAnnotationType());
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Constructor annotation is not supported on static methods");
+ }
+
+ if (candidates.size() == 1) {
+ throw new IllegalStateException("Only one method is allowed to have constructor annotation in a bean: " + method);
+ }
+
+ candidates.add(method);
+ }
+ }
+
+ return (Constructor[]) candidates.toArray(new Constructor[candidates.size()]);*/
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
new file mode 100644
index 0000000000..477582b1d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.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.sca.implementation.spring.processor;
+
+import java.lang.annotation.Annotation;
+
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
+
+public class InitDestroyAnnotationProcessor extends InitDestroyAnnotationBeanPostProcessor {
+
+ private static final long serialVersionUID = 0;
+
+ private Class<? extends Annotation> initAnnotationType = Init.class;
+ private Class<? extends Annotation> destroyAnnotationType = Destroy.class;
+
+ /**
+ * Gets init annotation type.
+ */
+ protected Class<? extends Annotation> getInitAnnotationType() {
+ return this.initAnnotationType;
+ }
+
+ /**
+ * Sets init annotation type.
+ */
+ /*
+ * public void setInitAnnotationType(Class<? extends Annotation>
+ * initAnnotationType) { Assert.notNull(initAnnotationType,
+ * "Init annotation type must not be null."); this.initAnnotationType =
+ * initAnnotationType; }
+ */
+
+ /**
+ * Gets destroy annotation type.
+ */
+ protected Class<? extends Annotation> getDestroyAnnotationType() {
+ return this.destroyAnnotationType;
+ }
+
+ /**
+ * Sets destroy annotation type.
+ */
+ /*
+ * public void setDestroyAnnotationType(Class<? extends Annotation>
+ * destroyAnnotationType) { Assert.notNull(destroyAnnotationType,
+ * "Destroy annotation type must not be null."); this.destroyAnnotationType
+ * = destroyAnnotationType; }
+ */
+
+ public InitDestroyAnnotationProcessor() {
+ // Set the @Init annotation type
+ setInitAnnotationType(initAnnotationType);
+
+ // Set the @Destroy annotation type
+ setDestroyAnnotationType(destroyAnnotationType);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
new file mode 100644
index 0000000000..4763714a38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.sca.implementation.spring.provider.PropertyValueWrapper;
+import org.oasisopen.sca.annotation.Property;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class PropertyAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> propertyAnnotationType = Property.class;
+
+ private PropertyValueWrapper propertyValue;
+
+ public PropertyAnnotationProcessor(PropertyValueWrapper propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+ /**
+ * Gets property annotation type.
+ */
+ protected Class<? extends Annotation> getPropertyAnnotationType() {
+ return this.propertyAnnotationType;
+ }
+
+ /**
+ * Sets property annotation type.
+ */
+ public void setPropertyAnnotationType(Class<? extends Annotation> propertyAnnotationType) {
+ Assert.notNull(propertyAnnotationType, "'propertyAnnotationType' type must not be null.");
+ this.propertyAnnotationType = propertyAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Property} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+
+ Property annotation = (Property)method.getAnnotation(getPropertyAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on static methods");
+ }
+
+ /*
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on private methods");
+ }
+ */
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException("Property annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+ if (pd != null) {
+ String propName = annotation.name();
+ if ("".equals(propName)) {
+ injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), pd.getName()));
+ } else {
+ injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), propName));
+ }
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+
+ Property annotation = (Property)field.getAnnotation(getPropertyAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on static fields");
+ }
+
+ /*
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on private fields");
+ }
+ */
+
+ ReflectionUtils.makeAccessible(field);
+
+ Object propertyObj = null;
+ String propName = annotation.name();
+ if ("".equals(propName)) {
+ propertyObj = propertyValue.getPropertyObj(field.getType(), field.getName());
+ } else {
+ propertyObj = propertyValue.getPropertyObj(field.getType(), propName);
+ }
+
+ if (propertyObj != null)
+ ReflectionUtils.setField(field, bean, propertyObj);
+ }
+ }
+ });
+ }
+
+ public void injectProperty(Object bean, PropertyDescriptor pd, Object propertyObj) {
+
+ if (propertyObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {propertyObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting property: " + e.getMessage(), e);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
new file mode 100644
index 0000000000..ad79db840e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.sca.implementation.spring.provider.ComponentWrapper;
+import org.oasisopen.sca.annotation.Reference;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ReferenceAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> referenceAnnotationType = Reference.class;
+ private ComponentWrapper component;
+
+ public ReferenceAnnotationProcessor(ComponentWrapper component) {
+ this.component = component;
+ }
+
+ /**
+ * Gets referece annotation type.
+ */
+ protected Class<? extends Annotation> getReferenceAnnotationType() {
+ return this.referenceAnnotationType;
+ }
+
+ /**
+ * Sets referece annotation type.
+ */
+ public void setReferenceAnnotationType(Class<? extends Annotation> referenceAnnotationType) {
+ Assert.notNull(referenceAnnotationType, "'referenceAnnotationType' type must not be null.");
+ this.referenceAnnotationType = referenceAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+
+ Reference annotation = (Reference)method.getAnnotation(getReferenceAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on static methods");
+ }
+
+ /*
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on private methods");
+ }
+ */
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException(
+ "Reference annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+ if (pd != null) {
+ String refName = annotation.name();
+ if ("".equals(refName)) {
+ injectReference(bean, pd, pd.getName());
+ } else {
+ injectReference(bean, pd, refName);
+ }
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+
+ Reference annotation = (Reference)field.getAnnotation(getReferenceAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on static fields");
+ }
+
+ /*
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on private fields");
+ }
+ */
+
+ ReflectionUtils.makeAccessible(field);
+
+ Object referenceObj = null;
+ String refName = annotation.name();
+ if ("".equals(refName)) {
+ referenceObj = component.getService(field.getType(), field.getName());
+ } else {
+ referenceObj = component.getService(field.getType(), refName);
+ }
+
+ if (referenceObj != null)
+ ReflectionUtils.setField(field, bean, referenceObj);
+ }
+ }
+ });
+ }
+
+ /**
+ * Processes a property descriptor to inject a service.
+ */
+ public void injectReference(Object bean, PropertyDescriptor pd, String name) {
+
+ Object referenceObj = component.getService(pd.getPropertyType(), name);
+
+ if (referenceObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {referenceObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java
new file mode 100644
index 0000000000..6ba2c65ef0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.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.implementation.spring.processor;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * A tie that allows Tuscany to call Spring library to load the application context for the purpose of introspection
+ */
+public class SpringXMLBeanDefinitionLoaderImpl implements SpringXMLBeanDefinitionLoader {
+
+ private static SCAGenericApplicationContext createApplicationContext(Object scaParentContext,
+ ClassLoader classLoader,
+ List<URL> resources) {
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+
+ SCAGenericApplicationContext appCtx =
+ new SCAGenericApplicationContext((ApplicationContext)scaParentContext, classLoader);
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+
+ return appCtx;
+
+ }
+
+ @Override
+ public Object load(List<URL> resources,
+ List<SpringSCAServiceElement> serviceElements,
+ List<SpringSCAReferenceElement> referenceElements,
+ List<SpringSCAPropertyElement> propertyElements,
+ List<SpringBeanElement> beanElements,
+ ProcessorContext context) {
+ // FIXME: [rfeng] We should try to avoid parsing the Spring xml twice for the deployment and runtime
+ SCAGenericApplicationContext applicationContext = createApplicationContext(null, null, resources);
+ serviceElements.addAll(applicationContext.getServiceElements());
+ referenceElements.addAll(applicationContext.getReferenceElements());
+ propertyElements.addAll(applicationContext.getPropertyElements());
+ beanElements.addAll(applicationContext.getBeanElements());
+ return applicationContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/ComponentWrapper.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/ComponentWrapper.java
new file mode 100644
index 0000000000..5bddd8a006
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/ComponentWrapper.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 org.apache.tuscany.sca.implementation.spring.provider;
+
+/**
+ * Wrapper for the Component
+ */
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class ComponentWrapper {
+
+ private RuntimeComponent component;
+
+ public ComponentWrapper(RuntimeComponent component) {
+ this.component = component;
+ }
+
+ public Object getService(Class<?> type, String name) {
+ return component.getComponentContext().getService(type, name);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/PropertyValueWrapper.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/PropertyValueWrapper.java
new file mode 100644
index 0000000000..eca1492081
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/PropertyValueWrapper.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.spring.provider;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Wrapper for PropertyValue
+ */
+public class PropertyValueWrapper {
+
+ private RuntimeComponent component;
+ private PropertyValueFactory propertyFactory;
+
+ public PropertyValueWrapper(RuntimeComponent component, PropertyValueFactory propertyFactory) {
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ }
+
+ public Object getPropertyObj(Class<?> type, String name) {
+ List<ComponentProperty> props = component.getProperties();
+ for (ComponentProperty prop : props) {
+ if (prop.getName().equals(name)) {
+ return propertyFactory.createPropertyValue(prop, type);
+ }
+ }
+ return null; // property name not found
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java
new file mode 100644
index 0000000000..db7831322a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.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.sca.implementation.spring.provider;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.context.SpringContextWrapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * A provider class for runtime Spring implementation instances
+ * @version $Rev$ $Date$
+ */
+public class SpringImplementationProvider implements ImplementationProvider {
+ private RuntimeComponent component;
+
+ // A Spring application context object
+ private SpringContextWrapper springContext;
+
+ /**
+ * Constructor for the provider - takes a component definition and a Spring implementation
+ * description
+ * @param component - the component in the assembly
+ * @param implementation - the implementation
+ */
+ public SpringImplementationProvider(RuntimeComponent component,
+ SpringImplementationWrapper implementation,
+ ApplicationContext parentApplicationContext,
+ ProxyFactory proxyService,
+ PropertyValueFactory propertyValueObjectFactory) {
+ super();
+ this.component = component;
+
+ springContext = new SpringContextWrapper(implementation, implementation.getResource());
+
+ } // end constructor
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ return new SpringInvoker(component, springContext, service, operation);
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ /**
+ * Start this Spring implementation instance
+ */
+ public void start() {
+ springContext.start();
+ }
+
+ /**
+ * Stop this implementation instance
+ */
+ public void stop() {
+ springContext.close();
+ }
+
+} // end class SpringImplementationProvider
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java
new file mode 100644
index 0000000000..be16fb3251
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.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.implementation.spring.provider;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * ImplementationProviderFactory for Spring implementation type
+ * @version $Rev$ $Date$
+ *
+ */
+public class SpringImplementationProviderFactory implements ImplementationProviderFactory<SpringImplementation> {
+ private ProxyFactory proxyFactory;
+ private PropertyValueFactory propertyFactory;
+ private SpringApplicationContextAccessor contextAccessor;
+
+ /**
+ * Simple constructor
+ *
+ */
+ public SpringImplementationProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ contextAccessor = utilities.getUtility(SpringApplicationContextAccessor.class);
+ proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ propertyFactory = utilities.getUtility(PropertyValueFactory.class);
+ }
+
+ /**
+ * Returns a SpringImplementationProvider for a given component and Spring implementation
+ * @param component the component for which implementation instances are required
+ * @param implementation the Spring implementation with details of the component
+ * implementation
+ * @return the SpringImplementationProvider for the specified component
+ */
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ SpringImplementation implementation) {
+ ApplicationContext parentApplicationContext =
+ (contextAccessor != null) ? contextAccessor.getParentApplicationContext() : null;
+ SpringImplementationWrapper tie =
+ new SpringImplementationWrapper(implementation, parentApplicationContext, component, propertyFactory);
+ return new SpringImplementationProvider(component, tie, parentApplicationContext, proxyFactory, propertyFactory);
+ }
+
+ /**
+ * Returns the class of the Spring implementation
+ */
+ public Class<SpringImplementation> getModelType() {
+ return SpringImplementation.class;
+ }
+
+} // end class SpringImplementationProviderFactory
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java
new file mode 100644
index 0000000000..e5593f5eaa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Wrapper for SpringImplementation
+ */
+public class SpringImplementationWrapper {
+
+ private SpringImplementation implementation;
+ private ApplicationContext parentApplicationContext;
+ private RuntimeComponent component;
+ private PropertyValueFactory propertyFactory;
+
+ public SpringImplementationWrapper(SpringImplementation implementation,
+ ApplicationContext parentApplicationContext,
+ RuntimeComponent component,
+ PropertyValueFactory propertyFactory) {
+ this.implementation = implementation;
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ this.parentApplicationContext = parentApplicationContext;
+ }
+
+ public String getURI() {
+ return implementation.getURI();
+ }
+
+ public List<URL> getResource() {
+ return implementation.getResource();
+ }
+
+ public String getComponentName() {
+ return component.getName();
+ }
+
+ /**
+ * Method to create a Java Bean for a Property value
+ * @param <B> the class type of the Bean
+ * @param requiredType - a Class object for the required type
+ * @param name - the Property name
+ * @return - a Bean of the specified property, with value set
+ */
+ private <B> B getPropertyBean(Class<?> requiredType, String name) {
+ B propertyObject = null;
+ // Get the component's list of properties
+ List<ComponentProperty> props = component.getProperties();
+ for (ComponentProperty prop : props) {
+ if (prop.getName().equals(name)) {
+ // On finding the property, create a factory for it and create a Bean using
+ // the factory
+ propertyObject = (B)propertyFactory.createPropertyValue(prop, requiredType);
+ } // end if
+ } // end for
+
+ return propertyObject;
+ }
+
+ /**
+ * Creates a proxy Bean for a reference
+ * @param <B> the Business interface type for the reference
+ * @param businessInterface - the business interface as a Class
+ * @param referenceName - the name of the Reference
+ * @return an Bean of the type defined by <B>
+ */
+ private <B> B getService(Class<B> businessInterface, String referenceName) {
+ return component.getComponentContext().getService(businessInterface, referenceName);
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class<?> requiredType) {
+ // The expectation is that the requested Bean is either a reference or a property
+ // from the Spring context
+ for (Reference reference : implementation.getReferences()) {
+ if (reference.getName().equals(name)) {
+ // Extract the Java interface for the reference (it can't be any other interface type
+ // for a Spring application context)
+ if (requiredType == null) {
+ JavaInterface javaInterface = (JavaInterface)reference.getInterfaceContract().getInterface();
+ requiredType = javaInterface.getJavaClass();
+ }
+ // Create and return the proxy for the reference
+ return getService(requiredType, reference.getName());
+ } // end if
+ } // end for
+
+ // For a property, get the name and the required Java type and create a Bean
+ // of that type with the value inserted.
+ for (Property property : implementation.getProperties()) {
+ if (property.getName().equals(name)) {
+ if (requiredType == null) {
+ // The following code only deals with a subset of types and was superceded
+ // by the information from the implementation (which uses Classes as found
+ // in the Spring implementation itself.
+ //requiredType = JavaXMLMapper.getJavaType( property.getXSDType() );
+ requiredType = implementation.getPropertyClass(name);
+ }
+ return getPropertyBean(requiredType, property.getName());
+ } // end if
+ } // end for
+ // TODO: NoSuchBeanException
+ // throw new RuntimeException("Unable to find Bean with name " + name);
+ return null;
+
+ } // end method getBean( String, Class )
+
+ public ComponentWrapper getComponentWrapper() {
+ return new ComponentWrapper(component);
+ }
+
+ public PropertyValueWrapper getPropertyValueWrapper() {
+ return new PropertyValueWrapper(component, propertyFactory);
+ }
+
+ public ClassLoader getClassLoader() {
+ return implementation.getClassLoader();
+ }
+
+ public ApplicationContext getParentApplicationContext() {
+ return parentApplicationContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvocationException.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvocationException.java
new file mode 100644
index 0000000000..0e1d3f5b5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvocationException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.provider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SpringInvocationException extends Exception {
+
+ private static final long serialVersionUID = -1157790036638157513L;
+
+ public SpringInvocationException(String msg) {
+ super(msg);
+ }
+
+ public SpringInvocationException(Throwable e) {
+ super(e);
+ }
+
+ public SpringInvocationException(String msg, Throwable e) {
+ super(msg, e);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvoker.java
new file mode 100644
index 0000000000..ea1d6e6755
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringInvoker.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.context.SpringContextWrapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Initial implementation of a Spring bean invoker
+ * @version $Rev$ $Date$
+ */
+public class SpringInvoker implements Invoker {
+
+ private Method theMethod = null;
+ private Object bean;
+ private SpringBeanElement beanElement;
+ private boolean badInvoker = false;
+
+ private SpringContextWrapper springContext;
+ private Operation operation;
+
+ /**
+ * SpringInvoker constructor
+ * @param component - the Spring component to invoke
+ * @param service - the service to invoke
+ * @param operation - the operation to invoke
+ */
+ public SpringInvoker(RuntimeComponent component,
+ SpringContextWrapper springContext,
+ RuntimeComponentService service,
+ Operation operation) {
+
+ this.springContext = springContext;
+ this.operation = operation;
+
+ // From the component and the service, identify the Spring Bean which is the target
+ SpringImplementation theImplementation = (SpringImplementation)component.getImplementation();
+ beanElement = theImplementation.getBeanFromService(service.getService());
+
+ if (beanElement == null) {
+ badInvoker = true;
+ return;
+ }
+
+ } // end constructor SpringInvoker
+
+ // Lazy-load the method to avoid timing problems with the Spring Context
+ private void setupMethod() throws SpringInvocationException {
+ try {
+ bean = springContext.getBean(beanElement.getId());
+ Class<?> beanClass = bean.getClass();
+ theMethod = JavaInterfaceUtil.findMethod(beanClass, operation);
+ //System.out.println("SpringInvoker - found method " + theMethod.getName() );
+ } catch (NoSuchMethodException e) {
+ throw new SpringInvocationException(e);
+ }
+ }
+
+ private Object doInvoke(Object payload) throws SpringInvocationException {
+ if (theMethod == null)
+ setupMethod();
+
+ if (badInvoker)
+ throw new SpringInvocationException("Spring invoker incorrectly configured");
+ // Invoke the method on the Spring bean using the payload, returning the results
+ try {
+ Object ret;
+
+ if (payload != null && !payload.getClass().isArray()) {
+ ret = theMethod.invoke(bean, payload);
+ } else {
+ ret = theMethod.invoke(bean, (Object[])payload);
+ }
+ return ret;
+ } catch (InvocationTargetException e) {
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.",
+ e.getCause());
+ } catch (Exception e) {
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.", e);
+ }
+
+ } // end method doInvoke
+
+ /**
+ * @param msg the message to invoke on the target bean
+ */
+ public Message invoke(Message msg) {
+ try {
+ Object resp = doInvoke(msg.getBody());
+ msg.setBody(resp);
+ } catch (SpringInvocationException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+ //System.out.println("Spring Invoker - invoke called");
+ return msg;
+ } // end method invoke
+
+} // end class SpringInvoker
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
new file mode 100644
index 0000000000..4c8fa09951
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.implementation.spring.processor.SpringXMLBeanDefinitionLoaderImpl;ranking=100 \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..e6c8d70fe1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.spring.provider.SpringImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.spring.SpringImplementation;ranking=100
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000000..1e1f558382
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1,2 @@
+http\://www.springframework.org/schema/sca=org.apache.tuscany.sca.implementation.spring.namespace.ScaNamespaceHandler
+http\://docs.oasis-open.org/ns/opencsa/sca-j/spring/200810=org.apache.tuscany.sca.implementation.spring.namespace.ScaNamespaceHandler
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000000..249cc21c13
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd=org/springframework/sca/xml/spring-sca.xsd
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
new file mode 100644
index 0000000000..dfa0b931f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-runtime/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
@@ -0,0 +1,84 @@
+<?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.
+-->
+<xsd:schema xmlns="http://www.springframework.org/schema/sca" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ attributeFormDefault="unqualified" elementFormDefault="qualified"
+ targetNamespace="http://www.springframework.org/schema/sca">
+
+ <xsd:element name="reference">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="default" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="service">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="target" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/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/sebastien/java/embed/modules/implementation-spring-stub/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b2b2091437
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Model
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring.xml;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.stub
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/README b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/README
new file mode 100644
index 0000000000..e1b1f98fe0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/README
@@ -0,0 +1,9 @@
+Note that the implementation spring modules have a different structure from other extensions.
+
+The aim is to have the Tuscany runtime embedded in a container with the Tuscany classes hidden
+from user applications and the Spring jar's packaged with the application. That means that the
+Tuscany code has no visibilty of the Spring classes and visa-versa. To implement that the
+implementation-spring module has no dependencies on Spring and the implementation-spring-runtime
+module has no dependencies on Tuscany (other than the sca-api), and reflection is used to call
+methods between the modules.
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/pom.xml
new file mode 100644
index 0000000000..5745399cf1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/pom.xml
@@ -0,0 +1,56 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring-stub</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Runtime Stub</name>
+
+ <dependencies>
+
+ <!-- **************************************** -->
+ <!-- * * -->
+ <!-- * DONT ADD ANY SPRING DEPENDENCIES!!! * -->
+ <!-- * * -->
+ <!-- * See the README for details why not * -->
+ <!-- * * -->
+ <!-- * * -->
+ <!-- **************************************** -->
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/stub/SpringXMLBeanDefinitionLoaderStub.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/stub/SpringXMLBeanDefinitionLoaderStub.java
new file mode 100644
index 0000000000..f34dfb8ceb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/stub/SpringXMLBeanDefinitionLoaderStub.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.spring.processor.stub;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * This is the Tuscany side stub for the corresponding runtime tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextTie class
+ * in the implementation-spring-runtime module for what the tie does.
+ */
+public class SpringXMLBeanDefinitionLoaderStub implements SpringXMLBeanDefinitionLoader {
+ private final static String TIE = "org.apache.tuscany.sca.implementation.spring.processor.tie.SpringXMLLoaderTie";
+
+ private static Method createApplicationContext;
+
+ public SpringXMLBeanDefinitionLoaderStub() throws Exception {
+ synchronized (SpringXMLBeanDefinitionLoaderStub.class) {
+ if (createApplicationContext == null) {
+ Class<?> tieClass = Class.forName(TIE, false, Thread.currentThread().getContextClassLoader());
+ createApplicationContext =
+ tieClass.getMethod("createApplicationContext", Object.class, ClassLoader.class, List.class);
+ }
+ }
+ }
+
+ public Object createApplicationContext(Object scaParentContext, ClassLoader classLoader, List<URL> resources)
+ throws Exception {
+ return createApplicationContext.invoke(null, scaParentContext, classLoader, resources);
+ }
+
+ public Object load(List<URL> resources,
+ List<SpringSCAServiceElement> serviceElements,
+ List<SpringSCAReferenceElement> referenceElements,
+ List<SpringSCAPropertyElement> propertyElements,
+ List<SpringBeanElement> beanElements,
+ ProcessorContext context) {
+ try {
+ Object appContext =
+ createApplicationContext(null, Thread.currentThread().getContextClassLoader(), resources);
+ Class<?> cls = appContext.getClass();
+ Method method = cls.getMethod("getElements", Class.class);
+ SpringSCAServiceElement[] serviceArray =
+ (SpringSCAServiceElement[])method.invoke(appContext, SpringSCAServiceElement.class);
+ serviceElements.addAll(Arrays.asList(serviceArray));
+
+ SpringSCAReferenceElement[] referenceArray =
+ (SpringSCAReferenceElement[])method.invoke(appContext, SpringSCAReferenceElement.class);
+ referenceElements.addAll(Arrays.asList(referenceArray));
+
+ SpringSCAPropertyElement[] propertyArray =
+ (SpringSCAPropertyElement[])method.invoke(appContext, SpringSCAPropertyElement.class);
+ propertyElements.addAll(Arrays.asList(propertyArray));
+
+ SpringBeanElement[] beanArray = (SpringBeanElement[])method.invoke(appContext, SpringBeanElement.class);
+ beanElements.addAll(Arrays.asList(beanArray));
+
+ return appContext;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/ComponentTie.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/ComponentTie.java
new file mode 100644
index 0000000000..882aa587e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/ComponentTie.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.implementation.spring.provider.stub;
+
+/**
+ * This is the Tuscany side tie for the corresponding Spring runtime side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the ComponentStub class
+ * in the implementation-spring-runtime module for what the stub does.
+ */
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class ComponentTie {
+
+ private RuntimeComponent component;
+
+ public ComponentTie(RuntimeComponent component) {
+ this.component = component;
+ }
+
+ public Object getService(Class<?> type, String name) {
+ return component.getComponentContext().getService(type, name);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/PropertyValueTie.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/PropertyValueTie.java
new file mode 100644
index 0000000000..5e0c5263c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/PropertyValueTie.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.sca.implementation.spring.provider.stub;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * This is the Tuscany side tie for the corresponding Spring runtime side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the PropertyValueStub class
+ * in the implementation-spring-runtime module for what the stub does.
+ */
+public class PropertyValueTie {
+
+ private RuntimeComponent component;
+ private PropertyValueFactory propertyFactory;
+
+ public PropertyValueTie(RuntimeComponent component, PropertyValueFactory propertyFactory) {
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ }
+
+ public Object getPropertyObj(Class<?> type, String name) {
+ List<ComponentProperty> props = component.getProperties();
+ for (ComponentProperty prop : props) {
+ if (prop.getName().equals(name)) {
+ return propertyFactory.createPropertyValue(prop, type);
+ }
+ }
+ return null; // property name not found
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringApplicationContextAccessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringApplicationContextAccessor.java
new file mode 100644
index 0000000000..84a65bcf17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringApplicationContextAccessor.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.sca.implementation.spring.provider.stub;
+
+/**
+ * A utility to receive the parent Spring application context
+ */
+public interface SpringApplicationContextAccessor {
+ /**
+ * Get the parent Spring application context for the hosting environment. This will be used as the parent
+ * application context for implementation.spring components
+ * @return The parent application context
+ */
+ Object getParentApplicationContext();
+
+ /**
+ * Set the root Spring application context. This is particually useful for Spring web integration where Spring
+ * creates WebApplicationContext and keeps it in the ServletContext
+ * @param parentApplicationContext The parent application context
+ */
+ void setParentApplicationContext(Object parentApplicationContext);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringContextStub.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringContextStub.java
new file mode 100644
index 0000000000..062da4b2d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringContextStub.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider.stub;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * This is the Tuscany side stub for the corresponding runtime tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextTie class
+ * in the implementation-spring-runtime module for what the tie does.
+ */
+public class SpringContextStub {
+
+ private static final String SPRING_IMPLEMENTATION_STUB =
+ "org.apache.tuscany.sca.implementation.spring.context.tie.SpringImplementationStub";
+ private static final String SPRING_CONTEXT_TIE =
+ "org.apache.tuscany.sca.implementation.spring.context.tie.SpringContextTie";
+ private Object tie;
+ private Method startMethod;
+ private Method closeMethod;
+ private Method getBeanMethod;
+
+ public SpringContextStub(RuntimeComponent component,
+ SpringImplementation implementation,
+ Object parentApplicationContext,
+ ProxyFactory proxyService,
+ PropertyValueFactory propertyValueObjectFactory) {
+
+ initTie(component, implementation, parentApplicationContext, propertyValueObjectFactory);
+
+ }
+
+ private void initTie(RuntimeComponent component,
+ SpringImplementation implementation,
+ Object parentApplicationContext,
+ PropertyValueFactory propertyValueObjectFactory) {
+
+ // TODO: what class loader to use?
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ try {
+
+ Class<?> stubClass = Class.forName(SPRING_IMPLEMENTATION_STUB, true, cl);
+ Constructor<?> stubConstructor = stubClass.getConstructor(new Class<?>[] {Object.class});
+ Object stub =
+ stubConstructor.newInstance(new SpringImplementationTie(implementation, parentApplicationContext,
+ component, propertyValueObjectFactory));
+
+ Class<?> tieClass = Class.forName(SPRING_CONTEXT_TIE, true, cl);
+ Constructor<?> tieConstructor = tieClass.getConstructor(new Class<?>[] {stubClass, List.class});
+ this.tie = tieConstructor.newInstance(stub, implementation.getResource());
+
+ this.startMethod = tieClass.getMethod("start");
+ this.closeMethod = tieClass.getMethod("close");
+ this.getBeanMethod = tieClass.getMethod("getBean", String.class);
+
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void start() {
+ try {
+ startMethod.invoke(tie);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void close() {
+ try {
+ closeMethod.invoke(tie);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getBean(String id) throws SpringInvocationException {
+ try {
+
+ return getBeanMethod.invoke(tie, id);
+
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProvider.java
new file mode 100644
index 0000000000..e0207b9f12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProvider.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider.stub;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * A provider class for runtime Spring implementation instances
+ * @version $Rev$ $Date$
+ */
+public class SpringImplementationProvider implements ImplementationProvider {
+ private RuntimeComponent component;
+
+ // A Spring application context object
+ private SpringContextStub springContext;
+
+ /**
+ * Constructor for the provider - takes a component definition and a Spring implementation
+ * description
+ * @param component - the component in the assembly
+ * @param implementation - the implementation
+ */
+ public SpringImplementationProvider(RuntimeComponent component,
+ SpringImplementation implementation,
+ Object parentApplicationContext,
+ ProxyFactory proxyService,
+ PropertyValueFactory propertyValueObjectFactory) {
+ super();
+ this.component = component;
+
+ springContext = new SpringContextStub(component, implementation, parentApplicationContext, proxyService, propertyValueObjectFactory);
+
+ } // end constructor
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ return new SpringInvoker(component, springContext, service, operation);
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ /**
+ * Start this Spring implementation instance
+ */
+ public void start() {
+ springContext.start();
+ }
+
+ /**
+ * Stop this implementation instance
+ */
+ public void stop() {
+ springContext.close();
+ }
+
+} // end class SpringImplementationProvider
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProviderFactory.java
new file mode 100644
index 0000000000..d402ff2eb6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationProviderFactory.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.sca.implementation.spring.provider.stub;
+
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * ImplementationProviderFactory for Spring implementation type
+ * @version $Rev$ $Date$
+ *
+ */
+public class SpringImplementationProviderFactory implements ImplementationProviderFactory<SpringImplementation> {
+ private ProxyFactory proxyFactory;
+ private PropertyValueFactory propertyFactory;
+ private SpringApplicationContextAccessor contextAccessor;
+
+ /**
+ * Simple constructor
+ *
+ */
+ public SpringImplementationProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ contextAccessor = utilities.getUtility(SpringApplicationContextAccessor.class);
+ proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ propertyFactory = utilities.getUtility(PropertyValueFactory.class);
+ }
+
+ /**
+ * Returns a SpringImplementationProvider for a given component and Spring implementation
+ * @param component the component for which implementation instances are required
+ * @param implementation the Spring implementation with details of the component
+ * implementation
+ * @return the SpringImplementationProvider for the specified component
+ */
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ SpringImplementation implementation) {
+ Object parentApplicationContext =
+ (contextAccessor != null) ? contextAccessor.getParentApplicationContext() : null;
+ return new SpringImplementationProvider(component, implementation, parentApplicationContext, proxyFactory,
+ propertyFactory);
+ }
+
+ /**
+ * Returns the class of the Spring implementation
+ */
+ public Class<SpringImplementation> getModelType() {
+ return SpringImplementation.class;
+ }
+
+} // end class SpringImplementationProviderFactory
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationTie.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationTie.java
new file mode 100644
index 0000000000..fc75faed21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringImplementationTie.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider.stub;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * This is the Tuscany side tie for the corresponding runtime stub class.
+ * It enables the Sping code in the runtime module to invoke methods on a
+ * Tuscany SpringImplementation without the Spring runtime module
+ * needing to know about any Tuscany classes. See the SpringImplementationStub class
+ * in the implementation-spring-runtime module for what the stub does.
+ */
+public class SpringImplementationTie {
+
+ private SpringImplementation implementation;
+ private Object parentApplicationContext;
+ private RuntimeComponent component;
+ private PropertyValueFactory propertyFactory;
+
+ public SpringImplementationTie(SpringImplementation implementation,
+ Object parentApplicationContext,
+ RuntimeComponent component,
+ PropertyValueFactory propertyFactory) {
+ this.implementation = implementation;
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ this.parentApplicationContext = parentApplicationContext;
+ }
+
+ public String getURI() {
+ return implementation.getURI();
+ }
+
+ public String getComponentName() {
+ return component.getName();
+ }
+
+ /**
+ * Method to create a Java Bean for a Property value
+ * @param <B> the class type of the Bean
+ * @param requiredType - a Class object for the required type
+ * @param name - the Property name
+ * @return - a Bean of the specified property, with value set
+ */
+ private <B> B getPropertyBean(Class<?> requiredType, String name) {
+ B propertyObject = null;
+ // Get the component's list of properties
+ List<ComponentProperty> props = component.getProperties();
+ for (ComponentProperty prop : props) {
+ if (prop.getName().equals(name)) {
+ // On finding the property, create a factory for it and create a Bean using
+ // the factory
+ propertyObject = (B) propertyFactory.createPropertyValue(prop, requiredType);
+ } // end if
+ } // end for
+
+ return propertyObject;
+ }
+
+ /**
+ * Creates a proxy Bean for a reference
+ * @param <B> the Business interface type for the reference
+ * @param businessInterface - the business interface as a Class
+ * @param referenceName - the name of the Reference
+ * @return an Bean of the type defined by <B>
+ */
+ private <B> B getService(Class<B> businessInterface, String referenceName) {
+ return component.getComponentContext().getService(businessInterface, referenceName);
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class<?> requiredType) {
+ // The expectation is that the requested Bean is either a reference or a property
+ // from the Spring context
+ for (Reference reference : implementation.getReferences()) {
+ if (reference.getName().equals(name)) {
+ // Extract the Java interface for the reference (it can't be any other interface type
+ // for a Spring application context)
+ if (requiredType == null) {
+ JavaInterface javaInterface = (JavaInterface)reference.getInterfaceContract().getInterface();
+ requiredType = javaInterface.getJavaClass();
+ }
+ // Create and return the proxy for the reference
+ return getService(requiredType, reference.getName());
+ } // end if
+ } // end for
+
+ // For a property, get the name and the required Java type and create a Bean
+ // of that type with the value inserted.
+ for (Property property : implementation.getProperties()) {
+ if (property.getName().equals(name)) {
+ if (requiredType == null) {
+ // The following code only deals with a subset of types and was superceded
+ // by the information from the implementation (which uses Classes as found
+ // in the Spring implementation itself.
+ //requiredType = JavaXMLMapper.getJavaType( property.getXSDType() );
+ requiredType = implementation.getPropertyClass(name);
+ }
+ return getPropertyBean(requiredType, property.getName());
+ } // end if
+ } // end for
+ // TODO: NoSuchBeanException
+ // throw new RuntimeException("Unable to find Bean with name " + name);
+ return null;
+
+ } // end method getBean( String, Class )
+
+ public Object getComponentTie() {
+ return new ComponentTie(component);
+ }
+
+ public Object getPropertyValueTie() {
+ return new PropertyValueTie(component, propertyFactory);
+ }
+
+ public ClassLoader getClassLoader() {
+ return implementation.getClassLoader();
+ }
+
+ public Object getParentApplicationContext() {
+ return parentApplicationContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvocationException.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvocationException.java
new file mode 100644
index 0000000000..909a640563
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvocationException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.provider.stub;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SpringInvocationException extends Exception {
+
+ private static final long serialVersionUID = -1157790036638157513L;
+
+ public SpringInvocationException(String msg) {
+ super(msg);
+ }
+
+ public SpringInvocationException(Throwable e) {
+ super(e);
+ }
+
+ public SpringInvocationException(String msg, Throwable e) {
+ super(msg, e);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvoker.java
new file mode 100644
index 0000000000..7d73eb5e6a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/stub/SpringInvoker.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.provider.stub;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Initial implementation of a Spring bean invoker
+ * @version $Rev$ $Date$
+ */
+public class SpringInvoker implements Invoker {
+
+ private Method theMethod = null;
+ private Object bean;
+ private SpringBeanElement beanElement;
+ private boolean badInvoker = false;
+
+ private SpringContextStub springContext;
+ private Operation operation;
+
+ /**
+ * SpringInvoker constructor
+ * @param component - the Spring component to invoke
+ * @param service - the service to invoke
+ * @param operation - the operation to invoke
+ */
+ public SpringInvoker(RuntimeComponent component,
+ SpringContextStub springContext,
+ RuntimeComponentService service,
+ Operation operation) {
+
+ this.springContext = springContext;
+ this.operation = operation;
+
+ // From the component and the service, identify the Spring Bean which is the target
+ SpringImplementation theImplementation = (SpringImplementation)component.getImplementation();
+ beanElement = theImplementation.getBeanFromService(service.getService());
+
+ if (beanElement == null) {
+ badInvoker = true;
+ return;
+ }
+
+ } // end constructor SpringInvoker
+
+ // Lazy-load the method to avoid timing problems with the Spring Context
+ private void setupMethod() throws SpringInvocationException {
+ try {
+ bean = springContext.getBean(beanElement.getId());
+ Class<?> beanClass = bean.getClass();
+ theMethod = JavaInterfaceUtil.findMethod(beanClass, operation);
+ //System.out.println("SpringInvoker - found method " + theMethod.getName() );
+ } catch (NoSuchMethodException e) {
+ throw new SpringInvocationException(e);
+ }
+ }
+
+ private Object doInvoke(Object payload) throws SpringInvocationException {
+ if (theMethod == null)
+ setupMethod();
+
+ if (badInvoker)
+ throw new SpringInvocationException("Spring invoker incorrectly configured");
+ // Invoke the method on the Spring bean using the payload, returning the results
+ try {
+ Object ret;
+
+ if (payload != null && !payload.getClass().isArray()) {
+ ret = theMethod.invoke(bean, payload);
+ } else {
+ ret = theMethod.invoke(bean, (Object[])payload);
+ }
+ return ret;
+ } catch (InvocationTargetException e) {
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.",
+ e.getCause());
+ } catch (Exception e) {
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.", e);
+ }
+
+ } // end method doInvoke
+
+ /**
+ * @param msg the message to invoke on the target bean
+ */
+ public Message invoke(Message msg) {
+ try {
+ Object resp = doInvoke(msg.getBody());
+ msg.setBody(resp);
+ } catch (SpringInvocationException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+ //System.out.println("Spring Invoker - invoke called");
+ return msg;
+ } // end method invoke
+
+} // end class SpringInvoker
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
new file mode 100644
index 0000000000..0a46baa13b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.implementation.spring.processor.stub.SpringXMLBeanDefinitionLoaderStub;ranking=50 \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..e037ea60f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-stub/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.spring.provider.stub.SpringImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.spring.SpringImplementation;ranking=50
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/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/sebastien/java/embed/modules/implementation-spring-tie/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5d452244d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.tie
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.springframework.beans;version="3.0.2.RELEASE",
+ org.springframework.beans.factory;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.annotation;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.config;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.support;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.xml;version="3.0.2.RELEASE",
+ org.springframework.context;version="3.0.2.RELEASE",
+ org.springframework.context.support;version="3.0.2.RELEASE",
+ org.springframework.core;version="3.0.2.RELEASE",
+ org.springframework.core.io;version="3.0.2.RELEASE",
+ org.springframework.util;version="3.0.2.RELEASE"
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/README b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/README
new file mode 100644
index 0000000000..e1b1f98fe0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/README
@@ -0,0 +1,9 @@
+Note that the implementation spring modules have a different structure from other extensions.
+
+The aim is to have the Tuscany runtime embedded in a container with the Tuscany classes hidden
+from user applications and the Spring jar's packaged with the application. That means that the
+Tuscany code has no visibilty of the Spring classes and visa-versa. To implement that the
+implementation-spring module has no dependencies on Spring and the implementation-spring-runtime
+module has no dependencies on Tuscany (other than the sca-api), and reflection is used to call
+methods between the modules.
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/pom.xml
new file mode 100644
index 0000000000..a30109d442
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring-tie</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Runtime Tie</name>
+
+ <dependencies>
+
+ <!-- **************************************** -->
+ <!-- * * -->
+ <!-- * DONT ADD ANY TUSCANY DEPENDENCIES!!! * -->
+ <!-- * * -->
+ <!-- * See the README for details why not * -->
+ <!-- * * -->
+ <!-- * * -->
+ <!-- **************************************** -->
+
+ <!-- SCA API dependency -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Spring dependencies... -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAGenericApplicationContext.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAGenericApplicationContext.java
new file mode 100644
index 0000000000..69e2ee2865
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAGenericApplicationContext.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context.tie;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringConstructorArgElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringElementTie;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAServiceElement;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.ConstructorArgumentValues;
+import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
+import org.springframework.beans.factory.config.TypedStringValue;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SCAGenericApplicationContext extends GenericApplicationContext {
+
+ private ClassLoader classloader = null;
+ private List<SpringSCAPropertyElement> propertyElements = new ArrayList<SpringSCAPropertyElement>();
+ private List<SpringSCAServiceElement> serviceElements = new ArrayList<SpringSCAServiceElement>();
+ private List<SpringSCAReferenceElement> referenceElements = new ArrayList<SpringSCAReferenceElement>();
+ private List<SpringBeanElement> beanElements;
+
+ public SCAGenericApplicationContext(DefaultListableBeanFactory beanFactory,
+ ApplicationContext parent,
+ ClassLoader classloader) {
+ super(beanFactory, parent);
+ this.classloader = classloader;
+ }
+
+ public SCAGenericApplicationContext(ApplicationContext parent, ClassLoader classloader) {
+ super(parent);
+ this.classloader = classloader;
+ }
+
+ @Override
+ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
+ beanFactory.setBeanClassLoader(classloader);
+ }
+
+ public void addSCAPropertyElement(SpringSCAPropertyElement propertyElement) {
+ propertyElements.add(propertyElement);
+ }
+
+ public void addSCAServiceElement(SpringSCAServiceElement serviceElement) {
+ serviceElements.add(serviceElement);
+ }
+
+ public void addSCAReferenceElement(SpringSCAReferenceElement referenceElement) {
+ referenceElements.add(referenceElement);
+ }
+
+ public synchronized List<SpringBeanElement> getBeanElements() {
+ if (beanElements == null) {
+ beanElements = new ArrayList<SpringBeanElement>();
+ for (String name : getBeanDefinitionNames()) {
+ BeanDefinition def = getBeanDefinition(name);
+ SpringBeanElement beanElement = new SpringBeanElement(name, def.getBeanClassName());
+ beanElements.add(beanElement);
+ beanElement.setAbstractBean(def.isAbstract());
+ beanElement.setFactoryBeanAttribute(def.getFactoryBeanName() != null);
+ beanElement.setFactoryMethodAttribute(def.getFactoryMethodName() != null);
+ beanElement.setParentAttribute(def.getParentName() != null);
+ beanElement.setInnerBean(beanElement.getId() == null);
+
+ ConstructorArgumentValues args = def.getConstructorArgumentValues();
+ for (Map.Entry<Integer, ValueHolder> e: args.getIndexedArgumentValues().entrySet()) {
+ ValueHolder holder = e.getValue();
+ SpringConstructorArgElement arg = new SpringConstructorArgElement(holder.getType());
+ arg.setIndex(e.getKey());
+ beanElement.addCustructorArgs(arg);
+ }
+
+ MutablePropertyValues values = def.getPropertyValues();
+ for (PropertyValue p : values.getPropertyValueList()) {
+ SpringPropertyElement propertyElement = new SpringPropertyElement(p.getName());
+ Object value = p.getValue();
+ configurePropertyElement(propertyElement, value);
+ beanElement.getProperties().add(propertyElement);
+ }
+ }
+ }
+ return beanElements;
+ }
+
+ public void configurePropertyElement(SpringPropertyElement propertyElement, Object value) {
+ if (value instanceof BeanReference) {
+ BeanReference beanRef = (BeanReference)value;
+ propertyElement.addRef(beanRef.getBeanName());
+ } else if (value instanceof Collection) {
+ Collection collection = (Collection)value;
+ for (Object item : collection) {
+ configurePropertyElement(propertyElement, item);
+ }
+ } else if (value instanceof TypedStringValue) {
+ TypedStringValue stringValue = (TypedStringValue)value;
+ propertyElement.addValue(stringValue.getValue());
+ } else {
+ if (value != null) {
+ propertyElement.addValue(value.toString());
+ }
+ }
+ }
+
+ public List<SpringSCAPropertyElement> getPropertyElements() {
+ return propertyElements;
+ }
+
+ public List<SpringSCAServiceElement> getServiceElements() {
+ return serviceElements;
+ }
+
+ public List<SpringSCAReferenceElement> getReferenceElements() {
+ return referenceElements;
+ }
+
+ public <T> T[] getElements(Class<T> type) {
+ if (type.getSimpleName().equals(SpringSCAPropertyElement.class.getSimpleName())) {
+ T[] elements = (T[])Array.newInstance(type, getPropertyElements().size());
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = SpringElementTie.copy(getPropertyElements().get(i), type, type);
+ }
+ return elements;
+ } else if (type.getSimpleName().equals(SpringSCAReferenceElement.class.getSimpleName())) {
+ T[] elements = (T[])Array.newInstance(type, getReferenceElements().size());
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = SpringElementTie.copy(getReferenceElements().get(i), type, type);
+ }
+ return elements;
+ } else if (type.getSimpleName().equals(SpringSCAServiceElement.class.getSimpleName())) {
+ T[] elements = (T[])Array.newInstance(type, getServiceElements().size());
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = SpringElementTie.copy(getServiceElements().get(i), type, type);
+ }
+ return elements;
+ } else if (type.getSimpleName().equals(SpringBeanElement.class.getSimpleName())) {
+ T[] elements = (T[])Array.newInstance(type, getBeanElements().size());
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = SpringElementTie.copy(getBeanElements().get(i), type, type);
+ }
+ return elements;
+ } else {
+ throw new IllegalArgumentException(type + " is not supported");
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAParentApplicationContext.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAParentApplicationContext.java
new file mode 100644
index 0000000000..d2b35ce74e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SCAParentApplicationContext.java
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context.tie;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.Locale;
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.MessageSourceResolvable;
+import org.springframework.context.NoSuchMessageException;
+import org.springframework.core.io.Resource;
+
+/**
+ * A Spring ParentApplicationContext for a given Spring Implementation
+ *
+ * The Parent application context is responsible for handling those entities within a Spring
+ * application context that actually belong to SCA rather than to Spring. The principal things
+ * are Properties and References. These may be present either through explicit <sca:property/>
+ * and <sca:reference/> elements in the application context or they may be implicit through
+ * unresolved Spring bean <property.../> elements. In either case, it is the Parent application
+ * context that must provide Spring beans that correspond to the property or reference, as derived
+ * from the SCA composite in which the Spring application context is an implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAParentApplicationContext implements ApplicationContext {
+
+ // The Spring implementation for which this is the parent application context
+ private SpringImplementationStub implementation;
+
+ private static final String[] EMPTY_ARRAY = new String[0];
+
+ public SCAParentApplicationContext(SpringImplementationStub implementation) {
+ this.implementation = implementation;
+ } // end constructor
+
+ public Object getBean(String name) throws BeansException {
+ return getBean(name, (Class)null);
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class requiredType) throws BeansException {
+ Object bean = implementation.getBean(name, requiredType);
+ if (bean == null && getParent() != null) {
+ bean = getParent().getBean(name, requiredType);
+ }
+ if (bean == null) {
+ throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name);
+ } else {
+ return bean;
+ }
+ } // end method getBean( String, Class )
+
+ public Object getBean(String name, Object[] args) throws BeansException {
+ return getBean(name, ((Class)null));
+ }
+
+ public <T> T getBean(Class<T> clazz) throws BeansException {
+ return clazz.cast(getBean(clazz.getName(), clazz));
+ }
+
+ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> clazz) throws BeansException {
+ return null;
+ }
+
+ public <A extends Annotation> A findAnnotationOnBean(String arg0, Class<A> clazz) {
+ return null;
+ }
+
+ public boolean containsBean(String name) {
+ // TODO
+ return false;
+ }
+
+ public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+ // TODO
+ return false;
+ }
+
+ public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class getType(String name) throws NoSuchBeanDefinitionException {
+ return null;
+ }
+
+ public String[] getAliases(String name) throws NoSuchBeanDefinitionException {
+ return EMPTY_ARRAY;
+ }
+
+ public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
+ return null;
+ }
+
+ public String getId() {
+ return this.toString();
+ }
+
+ public String getDisplayName() {
+ return implementation.getURI();
+ }
+
+ public long getStartupDate() {
+ return 0;
+ }
+
+ public boolean containsBeanDefinition(String beanName) {
+ return false;
+ }
+
+ public int getBeanDefinitionCount() {
+ return 0;
+ }
+
+ public String[] getBeanDefinitionNames() {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type) {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean includeFactoryBeans) {
+ return new String[0];
+ }
+
+ public Map getBeansOfType(Class type) throws BeansException {
+ return null;
+ }
+
+ public Map getBeansOfType(Class type, boolean includePrototypes, boolean includeFactoryBeans) throws BeansException {
+ return null;
+ }
+
+ public boolean isPrototype(String theString) {
+ return false;
+ }
+
+ public BeanFactory getParentBeanFactory() {
+ return null;
+ }
+
+ public boolean containsLocalBean(String name) {
+ return false;
+ }
+
+ public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
+ return null;
+ }
+
+ public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public void publishEvent(ApplicationEvent event) {
+
+ }
+
+ public Resource[] getResources(String locationPattern) throws IOException {
+ return new Resource[0];
+ }
+
+ public Resource getResource(String location) {
+ return null;
+ }
+
+ public ClassLoader getClassLoader() {
+ // REVIEW: this is almost certainly flawed, but it's not clear how the SCA runtime's
+ // resource loading mechanism is exposed right now.
+ return this.getClass().getClassLoader();
+ }
+
+ @Override
+ public ApplicationContext getParent() {
+ return implementation.getParentApplicationContext();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringContextTie.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringContextTie.java
new file mode 100644
index 0000000000..8bcdc8108d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringContextTie.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context.tie;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.spring.processor.tie.ComponentNameAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.ComponentStub;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.ConstructorAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.InitDestroyAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.PropertyAnnotationProcessor;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.PropertyValueStub;
+import org.apache.tuscany.sca.implementation.spring.processor.tie.ReferenceAnnotationProcessor;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * This is the runtime side tie for the corresponding tuscany side stub class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the SpringContextStub class
+ * in the implementation-spring module for what the stub does.
+ */
+public class SpringContextTie {
+
+ private AbstractApplicationContext springContext;
+ private SpringImplementationStub implementation;
+
+ public SpringContextTie(SpringImplementationStub implementation, List<URL> resource) {
+ this.implementation = implementation;
+ SCAParentApplicationContext scaParentContext = new SCAParentApplicationContext(implementation);
+ springContext = createApplicationContext(scaParentContext, resource);
+ }
+
+ public ApplicationContext getApplicationContext() {
+ return springContext;
+ }
+
+ public void start() {
+ // Do refresh here to ensure that Spring Beans are not touched before the SCA config process is complete...
+ springContext.refresh();
+ springContext.start();
+ }
+
+ public void close() {
+ springContext.close();
+ if (springContext instanceof GenericApplicationContext) {
+ springContext.stop();
+ }
+ }
+
+ /**
+ * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ */
+ private AbstractApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext,
+ List<URL> resources) {
+
+ GenericApplicationContext appCtx =
+ new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader());
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+ xmlReader.setBeanClassLoader(implementation.getClassLoader());
+ includeAnnotationProcessors(appCtx.getBeanFactory());
+ return appCtx;
+
+ }
+
+ public Object getBean(String id) throws BeansException {
+ return springContext.getBean(id);
+ }
+
+ /**
+ * Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
+ */
+ private void includeAnnotationProcessors(ConfigurableListableBeanFactory beanFactory) {
+
+ // Processor to deal with @Init and @Destroy SCA Annotations
+ BeanPostProcessor initDestroyProcessor = new InitDestroyAnnotationProcessor();
+ beanFactory.addBeanPostProcessor(initDestroyProcessor);
+
+ // Processor to deal with @Reference SCA Annotations
+ ComponentStub component = new ComponentStub(implementation.getComponentTie());
+ BeanPostProcessor referenceProcessor = new ReferenceAnnotationProcessor(component);
+ beanFactory.addBeanPostProcessor(referenceProcessor);
+
+ // Processor to deal with @Property SCA Annotations
+ PropertyValueStub pvs = new PropertyValueStub(implementation.getPropertyValueTie());
+ BeanPostProcessor propertyProcessor = new PropertyAnnotationProcessor(pvs);
+ beanFactory.addBeanPostProcessor(propertyProcessor);
+
+ // Processor to deal with @ComponentName SCA Annotations
+ BeanPostProcessor componentNameProcessor =
+ new ComponentNameAnnotationProcessor(implementation.getComponentName());
+ beanFactory.addBeanPostProcessor(componentNameProcessor);
+
+ // Processor to deal with @Constructor SCA Annotations
+ BeanPostProcessor constructorProcessor = new ConstructorAnnotationProcessor();
+ beanFactory.addBeanPostProcessor(constructorProcessor);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringImplementationStub.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringImplementationStub.java
new file mode 100644
index 0000000000..5ce52e668c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/context/tie/SpringImplementationStub.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.context.tie;
+
+import java.lang.reflect.Method;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * This is the runtime side stub for the corresponding Tuscany-side stub class.
+ * It enables the Spring code in the runtime module to invoke methods on a
+ * Tuscany SpringImplementation without the Spring runtime module
+ * needing to know about any Tuscany classes. See the SpringImplementationTie class
+ * in the implementation-spring module for what the tie does.
+ */
+public class SpringImplementationStub {
+
+ Object tie;
+ Method getURI;
+ Method getBean;
+ Method getComponentName;
+ Method getComponentTie;
+ Method getPropertyValueTie;
+ Method getClassLoader;
+ Method getParentApplicationContext;
+
+ public SpringImplementationStub(Object tie) {
+ this.tie = tie;
+ Class<?> tieClass = tie.getClass();
+ try {
+ getURI = tieClass.getMethod("getURI", new Class<?>[] {});
+ getBean = tieClass.getMethod("getBean", new Class<?>[] {String.class, Class.class});
+ getComponentName = tieClass.getMethod("getComponentName");
+ getComponentTie = tieClass.getMethod("getComponentTie");
+ getPropertyValueTie = tieClass.getMethod("getPropertyValueTie");
+ getClassLoader = tieClass.getMethod("getClassLoader");
+ getParentApplicationContext = tieClass.getMethod("getParentApplicationContext");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getURI() {
+ try {
+
+ return (String)getURI.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Get a Bean for a reference or for a property.
+ *
+ * @param name - the name of the Bean required
+ * @param requiredType - the required type of the Bean (either a Java class or a Java interface)
+ * @return Object - a Bean which matches the requested bean
+ */
+ public Object getBean(String name, Class<?> requiredType) throws BeansException {
+ try {
+
+ Object bean = getBean.invoke(tie, new Object[] {name, requiredType});
+// if (bean == null) {
+// throw new NoSuchBeanDefinitionException("Unable to find Bean with name " + name);
+// }
+ return bean;
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getComponentName() {
+ try {
+
+ return (String)getComponentName.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getComponentTie() {
+ try {
+
+ return getComponentTie.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getPropertyValueTie() {
+ try {
+
+ return getPropertyValueTie.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public ClassLoader getClassLoader() {
+ try {
+
+ return (ClassLoader)getClassLoader.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Get the parent Spring application context set by the Tuscany runtime
+ * @return
+ */
+ public ApplicationContext getParentApplicationContext() {
+ try {
+
+ return (ApplicationContext)getParentApplicationContext.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java
new file mode 100644
index 0000000000..020e001a59
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <bean> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringBeanElement {
+
+ private String id;
+ private String className = null;
+ private boolean innerBean = false;
+ private boolean abstractBean = false;
+ private boolean parentAttribute = false;
+ private boolean factoryBeanAttribute = false;
+ private boolean factoryMethodAttribute = false;
+
+ private List<SpringPropertyElement> properties = new ArrayList<SpringPropertyElement>();
+ private List<SpringConstructorArgElement> constructorargs = new ArrayList<SpringConstructorArgElement>();
+
+ public SpringBeanElement(String id, String className) {
+ this.id = id;
+ this.className = className;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<SpringPropertyElement> getProperties() {
+ return properties;
+ }
+
+ public void addProperty(SpringPropertyElement property) {
+ properties.add(property);
+ }
+
+ public List<SpringConstructorArgElement> getCustructorArgs() {
+ return constructorargs;
+ }
+
+ public void addCustructorArgs(SpringConstructorArgElement args) {
+ constructorargs.add(args);
+ }
+
+ public boolean isInnerBean() {
+ return innerBean;
+ }
+
+ public void setInnerBean(boolean innerBean) {
+ this.innerBean = innerBean;
+ }
+
+ public boolean isAbstractBean() {
+ return abstractBean;
+ }
+
+ public void setAbstractBean(boolean abstractBean) {
+ this.abstractBean = abstractBean;
+ }
+
+ public boolean hasParentAttribute() {
+ return parentAttribute;
+ }
+
+ public void setParentAttribute(boolean parentAttribute) {
+ this.parentAttribute = parentAttribute;
+ }
+
+ public boolean hasFactoryBeanAttribute() {
+ return factoryBeanAttribute;
+ }
+
+ public void setFactoryBeanAttribute(boolean factoryBeanAttribute) {
+ this.factoryBeanAttribute = factoryBeanAttribute;
+ }
+
+ public boolean hasFactoryMethodAttribute() {
+ return factoryMethodAttribute;
+ }
+
+ public void setFactoryMethodAttribute(boolean factoryMethodAttribute) {
+ this.factoryMethodAttribute = factoryMethodAttribute;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringBeanElement [id=").append(id).append(", className=").append(className)
+ .append(", innerBean=").append(innerBean).append(", abstractBean=").append(abstractBean)
+ .append(", parentAttribute=").append(parentAttribute).append(", factoryBeanAttribute=")
+ .append(factoryBeanAttribute).append(", factoryMethodAttribute=").append(factoryMethodAttribute)
+ .append(", properties=").append(properties).append(", constructorargs=").append(constructorargs)
+ .append("]");
+ return builder.toString();
+ }
+
+} // end class SpringBeanElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java
new file mode 100644
index 0000000000..53a972b7d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <constructor-arg> element in a Spring application-context
+ * - this has ref attribute
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringConstructorArgElement {
+
+ private String type;
+ private int autoIndex = -1;
+ private int index = -1;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringConstructorArgElement(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getAutoIndex() {
+ return this.autoIndex;
+ }
+
+ public void setAutoIndex(int index) {
+ this.autoIndex = index;
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java
new file mode 100644
index 0000000000..c088e5d0f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.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.spring.elements.tie;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A hacking utility to copy beans field by field between two class loaders
+ */
+public class SpringElementTie {
+ public static <T> T copy(Object source, Class<T> cls, Type genericType) {
+ if (source == null) {
+ return null;
+ }
+ if (cls.isPrimitive()) {
+ return (T)source;
+ }
+ if (Collection.class.isAssignableFrom(cls)) {
+ ParameterizedType pType = (ParameterizedType)genericType;
+ Type itemType = pType.getActualTypeArguments()[0];
+ Collection col = (Collection)source;
+ List target = new ArrayList();
+ for (Object item : col) {
+ target.add(copy(item, (Class<?>)itemType, itemType));
+ }
+ return (T)target;
+ }
+ if (cls.isInstance(source)) {
+ return cls.cast(source);
+ }
+ try {
+ Class<?> sourceClass = source.getClass();
+ T target = cls.newInstance();
+ for (Field sourceField : sourceClass.getDeclaredFields()) {
+ sourceField.setAccessible(true);
+ Field targetField = cls.getDeclaredField(sourceField.getName());
+ targetField.setAccessible(true);
+ Object sourceFieldValue = sourceField.get(source);
+ Object targetFieldValue = copy(sourceFieldValue, targetField.getType(), targetField.getGenericType());
+ targetField.set(target, targetFieldValue);
+ }
+ return target;
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java
new file mode 100644
index 0000000000..c0a1f2129b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <property> element in a Spring application-context
+ * - this has name and ref attributes
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringPropertyElement {
+
+ private String name;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringPropertyElement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringPropertyElement [name=").append(name).append(", refs=").append(refs).append(", values=")
+ .append(values).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java
new file mode 100644
index 0000000000..3f9901abea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.elements.tie;
+
+/**
+ * Represents an <sca:property> element in a Spring application-context
+ * - this has name and type attributes
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAPropertyElement {
+
+ private String name;
+ private String type;
+
+ public SpringSCAPropertyElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAPropertyElement [name=").append(name).append(", type=").append(type).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java
new file mode 100644
index 0000000000..0bcbb73583
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.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.sca.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Represents a <sca:reference> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAReferenceElement {
+
+ private String name;
+ private String type;
+ private String defaultBean;
+
+ private List<QName> intentNames = new ArrayList<QName>();
+ private List<QName> policySetNames = new ArrayList<QName>();
+
+
+ public SpringSCAReferenceElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setDefaultBean(String defaultBean) {
+ this.defaultBean = defaultBean;
+ }
+
+ public String getDefaultBean() {
+ return defaultBean;
+ }
+
+ public List<QName> getIntentNames() {
+ return intentNames;
+ }
+
+ public List<QName> getPolicySetNames() {
+ return policySetNames;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAReferenceElement [name=").append(name).append(", type=").append(type)
+ .append(", defaultBean=").append(defaultBean).append(", intentNames=").append(intentNames)
+ .append(", policySetNames=").append(policySetNames).append("]");
+ return builder.toString();
+ }
+
+
+} // end class SpringSCAReferenceElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java
new file mode 100644
index 0000000000..2322d19e1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.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.sca.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Represents a <sca:service> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAServiceElement {
+
+ private String name;
+ private String type;
+ private String target;
+
+ private List<QName> intentNames = new ArrayList<QName>();
+ private List<QName> policySetNames = new ArrayList<QName>();
+
+
+ public SpringSCAServiceElement(String name, String target) {
+ this.name = name;
+ this.target = target;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public List<QName> getIntentNames() {
+ return intentNames;
+ }
+
+ public List<QName> getPolicySetNames() {
+ return policySetNames;
+ }
+
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAServiceElement [name=").append(name).append(", type=").append(type)
+ .append(", target=").append(target).append(", intentNames=").append(intentNames)
+ .append(", policySetNames=").append(policySetNames).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringSCAServiceElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.java
new file mode 100644
index 0000000000..07c7c6a454
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/SCANamespaceHandlerResolver.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.sca.implementation.spring.namespace.tie;
+
+import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.NamespaceHandler;
+
+/**
+ * Overrides the default Spring namespace resolver to automatically register
+ * {@link ScaNamespaceHandler} instead of requiring a value to be supplied in a
+ * Spring configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCANamespaceHandlerResolver extends DefaultNamespaceHandlerResolver {
+ private static final String SCA_NAMESPACE = "http://www.springframework.org/schema/sca";
+
+ private ScaNamespaceHandler handler;
+
+ public SCANamespaceHandlerResolver(ClassLoader classLoader) {
+ super(classLoader);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ public SCANamespaceHandlerResolver(String handlerMappingsLocation, ClassLoader classLoader) {
+ super(classLoader, handlerMappingsLocation);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ @Override
+ public NamespaceHandler resolve(String namespaceUri) {
+ if (SCA_NAMESPACE.equals(namespaceUri)) {
+ return handler;
+ }
+ return super.resolve(namespaceUri);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java
new file mode 100644
index 0000000000..27b1811b86
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaNamespaceHandler.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Handler for the &lt;sca:&gt; namespace in an application context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaNamespaceHandler extends NamespaceHandlerSupport {
+
+ public ScaNamespaceHandler() {
+ }
+
+ @Override
+ public void init() {
+ registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+ registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+ registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+ }
+
+ private static String getNamespaceURI(Element element, String prefix) {
+ if (element == null) {
+ return null;
+ }
+ String name = ("".equals(prefix)) ? "xmlns" : "xmlns:" + prefix;
+ String ns = element.getAttribute(name);
+ if (ns != null && !"".equals(ns)) {
+ return ns;
+ }
+ Node parent = element.getParentNode();
+ if (parent instanceof Element) {
+ return getNamespaceURI((Element)parent, prefix);
+ } else {
+ return null;
+ }
+ }
+
+ public static List<QName> resolve(Element element, String listOfNames) {
+ List<QName> qnames = new ArrayList<QName>();
+ StringTokenizer tokenizer = new StringTokenizer(listOfNames);
+ while (tokenizer.hasMoreTokens()) {
+ String qname = tokenizer.nextToken();
+ String prefix = "";
+ String local = qname;
+ int index = qname.indexOf(':');
+ if (index != -1) {
+ local = qname.substring(index + 1);
+ prefix = qname.substring(0, index);
+ }
+ String ns = getNamespaceURI(element, prefix);
+ if (ns != null) {
+ qnames.add(new QName(ns, local, prefix));
+ } else {
+ throw new IllegalArgumentException("Prefix " + prefix + "is not bound to a namespace");
+ }
+ }
+ return qnames;
+ }
+
+ public static String getAttribute(Element element, String name) {
+ String attr = element.getAttributeNS(null, name);
+ if ("".equals(attr)) {
+ return null;
+ } else {
+ return attr;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java
new file mode 100644
index 0000000000..ad11a300ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaPropertyBeanDefinitionParser.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace.tie;
+
+import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAPropertyElement;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ * @version $Rev$ $Date$
+ */
+public class ScaPropertyBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAPropertyElement propertyElement =
+ new SpringSCAPropertyElement(element.getAttributeNS(null, "name"), element.getAttributeNS(null, "type"));
+ context.addSCAPropertyElement(propertyElement);
+ }
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java
new file mode 100644
index 0000000000..8470d2ffd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaReferenceBeanDefinitionParser.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace.tie;
+
+import static org.apache.tuscany.sca.implementation.spring.namespace.tie.ScaNamespaceHandler.getAttribute;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAReferenceElement;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaReferenceBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAReferenceElement referenceElement =
+ new SpringSCAReferenceElement(getAttribute(element, "name"), getAttribute(element, "type"));
+ referenceElement.setDefaultBean(getAttribute(element, "default"));
+
+ String requires = getAttribute(element, "requires");
+ if (requires != null) {
+ List<QName> qnames = ScaNamespaceHandler.resolve(element, requires);
+ referenceElement.getIntentNames().addAll(qnames);
+ }
+
+ String policySets = getAttribute(element, "policySets");
+ if (policySets != null) {
+ List<QName> qnames = ScaNamespaceHandler.resolve(element, policySets);
+ referenceElement.getPolicySetNames().addAll(qnames);
+ }
+
+ context.addSCAReferenceElement(referenceElement);
+ }
+
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java
new file mode 100644
index 0000000000..900356698d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/tie/ScaServiceBeanDefinitionParser.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.implementation.spring.namespace.tie;
+
+import static org.apache.tuscany.sca.implementation.spring.namespace.tie.ScaNamespaceHandler.getAttribute;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.elements.tie.SpringSCAServiceElement;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Parser for the &lt;sca:service/&gt; element
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScaServiceBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry instanceof SCAGenericApplicationContext) {
+ SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
+ SpringSCAServiceElement serviceElement =
+ new SpringSCAServiceElement(getAttribute(element, "name"), getAttribute(element, "target"));
+ serviceElement.setType(getAttribute(element, "type"));
+
+ String requires = getAttribute(element, "requires");
+ if (requires != null) {
+ List<QName> qnames = ScaNamespaceHandler.resolve(element, requires);
+ serviceElement.getIntentNames().addAll(qnames);
+ }
+
+ String policySets = getAttribute(element, "policySets");
+ if (policySets != null) {
+ List<QName> qnames = ScaNamespaceHandler.resolve(element, policySets);
+ serviceElement.getPolicySetNames().addAll(qnames);
+ }
+
+ context.addSCAServiceElement(serviceElement);
+ }
+ // do nothing, handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentNameAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentNameAnnotationProcessor.java
new file mode 100644
index 0000000000..77f9f30bfd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentNameAnnotationProcessor.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.implementation.spring.processor.tie;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.ref.Reference;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.ComponentName;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
+
+ private String componentName;
+
+ public ComponentNameAnnotationProcessor(String componentName) {
+ this.componentName = componentName;
+ }
+
+ /**
+ * Gets componentName annotation type.
+ */
+ protected Class<? extends Annotation> getComponentNameAnnotationType() {
+ return this.componentNameAnnotationType;
+ }
+
+ /**
+ * Sets componentName annotation type.
+ */
+ public void setComponentNameAnnotationType(Class<? extends Annotation> componentNameAnnotationType) {
+ Assert.notNull(componentNameAnnotationType, "'componentNameAnnotationType' type must not be null.");
+ this.componentNameAnnotationType = componentNameAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+ Annotation annotation = field.getAnnotation(getComponentNameAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on static fields");
+ }
+
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on private fields");
+ }
+
+ ReflectionUtils.makeAccessible(field);
+
+ if (field.getType().getName().equals("java.lang.String")) {
+ Object nameObj = componentName;
+ if (nameObj != null)
+ ReflectionUtils.setField(field, bean, nameObj);
+ } else {
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+ Annotation annotation = method.getAnnotation(getComponentNameAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on static methods");
+ }
+
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("ComponentName annotation is not supported on private methods");
+ }
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException(
+ "ComponentName annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+
+ if (pd.getPropertyType().getName().equals("java.lang.String")) {
+ Object nameObj = componentName;
+ if (nameObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {nameObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
+ }
+ }
+ } else {
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentStub.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentStub.java
new file mode 100644
index 0000000000..7511ac4bd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ComponentStub.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.sca.implementation.spring.processor.tie;
+
+import java.lang.reflect.Method;
+
+/**
+ * This is the Spring runtime side stub for the corresponding Tuscany tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the ComponentTie class
+ * in the implementation-spring module for what the tie does.
+ */
+public class ComponentStub {
+
+ private Object tie;
+ private Method getService;
+
+ public ComponentStub(Object tie) {
+ this.tie = tie;
+ Class<?> tieClass = tie.getClass();
+ try {
+ getService = tieClass.getMethod("getService", new Class<?>[] {Class.class, String.class});
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getService(Class<?> type, String name) {
+ try {
+
+ return getService.invoke(tie, type, name);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ConstructorAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ConstructorAnnotationProcessor.java
new file mode 100644
index 0000000000..503307cfd9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ConstructorAnnotationProcessor.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor.tie;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
+import org.springframework.util.Assert;
+
+public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostProcessorAdapter {
+
+ private Class<? extends Annotation> constructorAnnotationType = org.oasisopen.sca.annotation.Constructor.class;
+
+ private Class<? extends Annotation> autowiredAnnotationType = Autowired.class;
+
+ public ConstructorAnnotationProcessor() {
+ // Default constructor.
+ }
+
+ /**
+ * Set the 'autowired' annotation type, to be used on constructors, fields,
+ * setter methods and arbitrary config methods.
+ */
+ public void setAutowiredAnnotationType(Class<? extends Annotation> autowiredAnnotationType) {
+ Assert.notNull(autowiredAnnotationType, "'autowiredAnnotationType' must not be null");
+ this.autowiredAnnotationType = autowiredAnnotationType;
+ }
+
+ /**
+ * Return the 'autowired' annotation type.
+ */
+ protected Class<? extends Annotation> getAutowiredAnnotationType() {
+ return this.autowiredAnnotationType;
+ }
+
+ /**
+ * Return the 'constructor' annotation type.
+ */
+ protected Class<? extends Annotation> getConstructorAnnotationType() {
+ return this.constructorAnnotationType;
+ }
+
+ /**
+ * Sets the 'constructor' annotation type.
+ */
+ public void setConstructorAnnotationType(Class<? extends Annotation> constructorAnnotationType) {
+ Assert.notNull(constructorAnnotationType, "'constructorAnnotationType' type must not be null.");
+ this.constructorAnnotationType = constructorAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
+ /*Constructor[] declaredConstructors = beanClass.getDeclaredConstructors();
+ Method[] declaredMethods = beanClass.getDeclaredMethods();
+ List candidates = new ArrayList(declaredConstructors.length);
+
+ for (int i = 0; i < declaredMethods.length; i++) {
+ Method method = declaredMethods[i];
+ Annotation annotation = method.getAnnotation(getConstructorAnnotationType());
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Constructor annotation is not supported on static methods");
+ }
+
+ if (candidates.size() == 1) {
+ throw new IllegalStateException("Only one method is allowed to have constructor annotation in a bean: " + method);
+ }
+
+ candidates.add(method);
+ }
+ }
+
+ return (Constructor[]) candidates.toArray(new Constructor[candidates.size()]);*/
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/InitDestroyAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/InitDestroyAnnotationProcessor.java
new file mode 100644
index 0000000000..390ee040f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/InitDestroyAnnotationProcessor.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.sca.implementation.spring.processor.tie;
+
+import java.lang.annotation.Annotation;
+
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
+
+public class InitDestroyAnnotationProcessor extends InitDestroyAnnotationBeanPostProcessor {
+
+ private static final long serialVersionUID = 0;
+
+ private Class<? extends Annotation> initAnnotationType = Init.class;
+ private Class<? extends Annotation> destroyAnnotationType = Destroy.class;
+
+ /**
+ * Gets init annotation type.
+ */
+ protected Class<? extends Annotation> getInitAnnotationType() {
+ return this.initAnnotationType;
+ }
+
+ /**
+ * Sets init annotation type.
+ */
+ /*
+ * public void setInitAnnotationType(Class<? extends Annotation>
+ * initAnnotationType) { Assert.notNull(initAnnotationType,
+ * "Init annotation type must not be null."); this.initAnnotationType =
+ * initAnnotationType; }
+ */
+
+ /**
+ * Gets destroy annotation type.
+ */
+ protected Class<? extends Annotation> getDestroyAnnotationType() {
+ return this.destroyAnnotationType;
+ }
+
+ /**
+ * Sets destroy annotation type.
+ */
+ /*
+ * public void setDestroyAnnotationType(Class<? extends Annotation>
+ * destroyAnnotationType) { Assert.notNull(destroyAnnotationType,
+ * "Destroy annotation type must not be null."); this.destroyAnnotationType
+ * = destroyAnnotationType; }
+ */
+
+ public InitDestroyAnnotationProcessor() {
+ // Set the @Init annotation type
+ setInitAnnotationType(initAnnotationType);
+
+ // Set the @Destroy annotation type
+ setDestroyAnnotationType(destroyAnnotationType);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyAnnotationProcessor.java
new file mode 100644
index 0000000000..ce3aafd3ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyAnnotationProcessor.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor.tie;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.Property;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class PropertyAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> propertyAnnotationType = Property.class;
+
+ private PropertyValueStub propertyValue;
+
+ public PropertyAnnotationProcessor(PropertyValueStub propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+ /**
+ * Gets property annotation type.
+ */
+ protected Class<? extends Annotation> getPropertyAnnotationType() {
+ return this.propertyAnnotationType;
+ }
+
+ /**
+ * Sets property annotation type.
+ */
+ public void setPropertyAnnotationType(Class<? extends Annotation> propertyAnnotationType) {
+ Assert.notNull(propertyAnnotationType, "'propertyAnnotationType' type must not be null.");
+ this.propertyAnnotationType = propertyAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Property} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+
+ Property annotation = (Property)method.getAnnotation(getPropertyAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on static methods");
+ }
+
+ /*
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on private methods");
+ }
+ */
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException("Property annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+ if (pd != null) {
+ String propName = annotation.name();
+ if ("".equals(propName)) {
+ injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), pd.getName()));
+ } else {
+ injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), propName));
+ }
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+
+ Property annotation = (Property)field.getAnnotation(getPropertyAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on static fields");
+ }
+
+ /*
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("Property annotation is not supported on private fields");
+ }
+ */
+
+ ReflectionUtils.makeAccessible(field);
+
+ Object propertyObj = null;
+ String propName = annotation.name();
+ if ("".equals(propName)) {
+ propertyObj = propertyValue.getPropertyObj(field.getType(), field.getName());
+ } else {
+ propertyObj = propertyValue.getPropertyObj(field.getType(), propName);
+ }
+
+ if (propertyObj != null)
+ ReflectionUtils.setField(field, bean, propertyObj);
+ }
+ }
+ });
+ }
+
+ public void injectProperty(Object bean, PropertyDescriptor pd, Object propertyObj) {
+
+ if (propertyObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {propertyObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting property: " + e.getMessage(), e);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyValueStub.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyValueStub.java
new file mode 100644
index 0000000000..5a4b57ce81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/PropertyValueStub.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.spring.processor.tie;
+
+import java.lang.reflect.Method;
+
+/**
+ * This is the Spring runtime side stub for the corresponding Tuscany tie class.
+ * It enables the Tuscany code to invoke methods on a Spring context without
+ * needing to know about any Spring classes. See the PropertyValueTie class
+ * in the implementation-spring module for what the tie does.
+ */
+public class PropertyValueStub {
+
+ private Object tie;
+ private Method getPropertyObj;
+
+ public PropertyValueStub(Object tie) {
+ this.tie = tie;
+ Class<?> tieClass = tie.getClass();
+ try {
+ getPropertyObj = tieClass.getMethod("getPropertyObj", new Class<?>[] {Class.class, String.class});
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object getPropertyObj(Class<?> propertyType, String name) {
+ try {
+
+ return getPropertyObj.invoke(tie, propertyType, name);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ReferenceAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ReferenceAnnotationProcessor.java
new file mode 100644
index 0000000000..24761d2cfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/ReferenceAnnotationProcessor.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.processor.tie;
+
+import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class ReferenceAnnotationProcessor implements BeanPostProcessor {
+
+ private Class<? extends Annotation> referenceAnnotationType = Reference.class;
+ private ComponentStub component;
+
+ public ReferenceAnnotationProcessor(ComponentStub component) {
+ this.component = component;
+ }
+
+ /**
+ * Gets referece annotation type.
+ */
+ protected Class<? extends Annotation> getReferenceAnnotationType() {
+ return this.referenceAnnotationType;
+ }
+
+ /**
+ * Sets referece annotation type.
+ */
+ public void setReferenceAnnotationType(Class<? extends Annotation> referenceAnnotationType) {
+ Assert.notNull(referenceAnnotationType, "'referenceAnnotationType' type must not be null.");
+ this.referenceAnnotationType = referenceAnnotationType;
+ }
+
+ /**
+ * This method is used to execute before a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ processAnnotation(bean);
+ return bean;
+ }
+
+ /**
+ * This method is used to execute after a bean's initialization callback.
+ *
+ * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
+ */
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ return bean;
+ }
+
+ /**
+ * <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
+ */
+ protected void processAnnotation(final Object bean) {
+
+ final Class<?> clazz = bean.getClass();
+
+ ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
+ public void doWith(Method method) {
+
+ Reference annotation = (Reference)method.getAnnotation(getReferenceAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on static methods");
+ }
+
+ /*
+ if (Modifier.isPrivate(method.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on private methods");
+ }
+ */
+
+ if (method.getParameterTypes().length == 0) {
+ throw new IllegalStateException(
+ "Reference annotation requires at least one argument: " + method);
+ }
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+ if (pd != null) {
+ String refName = annotation.name();
+ if ("".equals(refName)) {
+ injectReference(bean, pd, pd.getName());
+ } else {
+ injectReference(bean, pd, refName);
+ }
+ }
+ }
+ }
+ });
+
+ ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field field) {
+
+ Reference annotation = (Reference)field.getAnnotation(getReferenceAnnotationType());
+
+ if (annotation != null) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on static fields");
+ }
+
+ /*
+ if (Modifier.isPrivate(field.getModifiers())) {
+ throw new IllegalStateException("Reference annotation is not supported on private fields");
+ }
+ */
+
+ ReflectionUtils.makeAccessible(field);
+
+ Object referenceObj = null;
+ String refName = annotation.name();
+ if ("".equals(refName)) {
+ referenceObj = component.getService(field.getType(), field.getName());
+ } else {
+ referenceObj = component.getService(field.getType(), refName);
+ }
+
+ if (referenceObj != null)
+ ReflectionUtils.setField(field, bean, referenceObj);
+ }
+ }
+ });
+ }
+
+ /**
+ * Processes a property descriptor to inject a service.
+ */
+ public void injectReference(Object bean, PropertyDescriptor pd, String name) {
+
+ Object referenceObj = component.getService(pd.getPropertyType(), name);
+
+ if (referenceObj != null) {
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {referenceObj});
+ } catch (Throwable e) {
+ throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/SpringXMLLoaderTie.java b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/SpringXMLLoaderTie.java
new file mode 100644
index 0000000000..82aa176219
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/tie/SpringXMLLoaderTie.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.spring.processor.tie;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.spring.context.tie.SCAGenericApplicationContext;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * A tie that allows Tuscany to call Spring library to load the application context for the purpose of introspection
+ */
+public class SpringXMLLoaderTie {
+
+ public static ApplicationContext createApplicationContext(Object scaParentContext,
+ ClassLoader classLoader,
+ List<URL> resources) {
+ if (classLoader == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+
+ SCAGenericApplicationContext appCtx =
+ new SCAGenericApplicationContext((ApplicationContext)scaParentContext, classLoader);
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+
+ // REVIEW: [rfeng] How do we control the schema validation
+ xmlReader.setValidating(false);
+
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+
+ return appCtx;
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/META-INF/spring.handlers b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000000..e7b61bfe48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+http\://www.springframework.org/schema/sca=org.apache.tuscany.sca.implementation.spring.namespace.tie.ScaNamespaceHandler
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/META-INF/spring.schemas b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000000..249cc21c13
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd=org/springframework/sca/xml/spring-sca.xsd
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/org/springframework/sca/xml/spring-sca.xsd b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
new file mode 100644
index 0000000000..dfa0b931f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-tie/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
@@ -0,0 +1,84 @@
+<?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.
+-->
+<xsd:schema xmlns="http://www.springframework.org/schema/sca" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ attributeFormDefault="unqualified" elementFormDefault="qualified"
+ targetNamespace="http://www.springframework.org/schema/sca">
+
+ <xsd:element name="reference">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="default" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="service">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="target" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string" />
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/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/sebastien/java/embed/modules/implementation-spring-webapp/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..42c577b6eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation WebApp Integration
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Runtime Model
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.webapp
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: javax.servlet,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring.context;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.springframework.beans;version="3.0.2.RELEASE",
+ org.springframework.beans.factory;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.annotation;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.config;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.support;version="3.0.2.RELEASE",
+ org.springframework.beans.factory.xml;version="3.0.2.RELEASE",
+ org.springframework.context;version="3.0.2.RELEASE",
+ org.springframework.context.support;version="3.0.2.RELEASE",
+ org.springframework.core.io;version="3.0.2.RELEASE",
+ org.springframework.util;version="3.0.2.RELEASE"
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/pom.xml
new file mode 100644
index 0000000000..081af3c80d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/pom.xml
@@ -0,0 +1,60 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring-webapp</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation WebApp Integration</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Spring dependencies... -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>3.0.2.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <type>jar</type>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorBean.java b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorBean.java
new file mode 100644
index 0000000000..a54ef8df17
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorBean.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.spring.webapp;
+
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.support.ApplicationObjectSupport;
+
+/**
+ * A singleton utility class that can be added to the Spring application context to receive injection of the containing
+ * Spring application context.
+ *
+ * The Spring bean definition file is: org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml
+ */
+public class ApplicationContextAccessorBean extends ApplicationObjectSupport implements ApplicationContextAware {
+ public final static String BEAN_ID = "tuscanySpringApplicationContextAccessor";
+ private final static ApplicationContextAccessorBean INSTANCE = new ApplicationContextAccessorBean();
+
+ private ApplicationContextAccessorBean() {
+ }
+
+ // Spring static factory method to create the singleton instance
+ public static ApplicationContextAccessorBean getInstance() {
+ return INSTANCE;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java
new file mode 100644
index 0000000000..f95ba27242
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.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.implementation.spring.webapp;
+
+import java.util.logging.Logger;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.host.http.ExtensibleServletHost;
+import org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+public class SpringWebApplicationContextAccessor implements SpringApplicationContextAccessor, LifeCycleListener {
+ private static Logger log = Logger.getLogger(SpringWebApplicationContextAccessor.class.getName());
+ private ExtensionPointRegistry registry;
+ private ApplicationContext parentApplicationContext;
+
+ public SpringWebApplicationContextAccessor(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ @Override
+ public void start() {
+ ExtensibleServletHost servletHost = ExtensibleServletHost.getInstance(registry);
+
+ ServletContext servletContext = servletHost.getServletContext();
+ if (servletContext != null) {
+ parentApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
+ if (parentApplicationContext != null) {
+ log.info("Spring WebApplicationContext is now injected on Tuscany");
+ }
+ }
+
+ if (parentApplicationContext == null) {
+ parentApplicationContext = ApplicationContextAccessorBean.getInstance().getApplicationContext();
+ }
+ }
+
+ @Override
+ public void stop() {
+ parentApplicationContext = null;
+ }
+
+ public ApplicationContext getParentApplicationContext() {
+ return parentApplicationContext;
+ }
+
+ public void setParentApplicationContext(ApplicationContext parentApplicationContext) {
+ this.parentApplicationContext = parentApplicationContext;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor
new file mode 100644
index 0000000000..506b02c782
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.implementation.spring.webapp.SpringWebApplicationContextAccessor \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml
new file mode 100644
index 0000000000..b98374a88b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml
@@ -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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <bean id="tuscanySpringApplicationContextAccessor"
+ class="org.apache.tuscany.sca.implementation.spring.webapp.ApplicationContextAccessorBean"
+ scope="singleton" factory-method="getInstance">
+ </bean>
+
+</beans>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/test/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/test/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorTestCase.java
new file mode 100644
index 0000000000..6a5ae882b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring-webapp/src/test/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorTestCase.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.implementation.spring.webapp;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ApplicationContextAccessorTestCase {
+
+ @Test
+ public void testContext() {
+ ApplicationContext context =
+ new ClassPathXmlApplicationContext(
+ new String[] {"org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml"});
+ Object accessor = context.getBean(ApplicationContextAccessorBean.BEAN_ID);
+ Assert.assertSame(ApplicationContextAccessorBean.getInstance(), accessor);
+ ApplicationContextAccessorBean contextAccessor = (ApplicationContextAccessorBean)accessor;
+ Assert.assertSame(context, contextAccessor.getApplicationContext());
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-spring/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/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/sebastien/java/embed/modules/implementation-spring/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-spring/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9226b047d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/META-INF/MANIFEST.MF
@@ -0,0 +1,50 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Spring Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Spring Implementation Model
+Import-Package: javax.jws,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.injection;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.implementation.spring;version="2.0.0",
+ org.apache.tuscany.sca.implementation.spring.xml;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.implementation.spring,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ javax.xml.namespace"
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-spring/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-spring/pom.xml
new file mode 100644
index 0000000000..371bde71b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/pom.xml
@@ -0,0 +1,59 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java
new file mode 100644
index 0000000000..64b36a0a44
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.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.sca.implementation.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <bean> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringBeanElement {
+
+ private String id;
+ private String className = null;
+ private boolean innerBean = false;
+ private boolean abstractBean = false;
+ private boolean parentAttribute = false;
+ private boolean factoryBeanAttribute = false;
+ private boolean factoryMethodAttribute = false;
+
+ private List<SpringPropertyElement> properties = new ArrayList<SpringPropertyElement>();
+ private List<SpringConstructorArgElement> constructorargs = new ArrayList<SpringConstructorArgElement>();
+
+ public SpringBeanElement() {
+ }
+
+ public SpringBeanElement(String id, String className) {
+ this.id = id;
+ this.className = className;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<SpringPropertyElement> getProperties() {
+ return properties;
+ }
+
+ public void addProperty(SpringPropertyElement property) {
+ properties.add(property);
+ }
+
+ public List<SpringConstructorArgElement> getCustructorArgs() {
+ return constructorargs;
+ }
+
+ public void addCustructorArgs(SpringConstructorArgElement args) {
+ constructorargs.add(args);
+ }
+
+ public boolean isInnerBean() {
+ return innerBean;
+ }
+
+ public void setInnerBean(boolean innerBean) {
+ this.innerBean = innerBean;
+ }
+
+ public boolean isAbstractBean() {
+ return abstractBean;
+ }
+
+ public void setAbstractBean(boolean abstractBean) {
+ this.abstractBean = abstractBean;
+ }
+
+ public boolean hasParentAttribute() {
+ return parentAttribute;
+ }
+
+ public void setParentAttribute(boolean parentAttribute) {
+ this.parentAttribute = parentAttribute;
+ }
+
+ public boolean hasFactoryBeanAttribute() {
+ return factoryBeanAttribute;
+ }
+
+ public void setFactoryBeanAttribute(boolean factoryBeanAttribute) {
+ this.factoryBeanAttribute = factoryBeanAttribute;
+ }
+
+ public boolean hasFactoryMethodAttribute() {
+ return factoryMethodAttribute;
+ }
+
+ public void setFactoryMethodAttribute(boolean factoryMethodAttribute) {
+ this.factoryMethodAttribute = factoryMethodAttribute;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringBeanElement [id=").append(id).append(", className=").append(className)
+ .append(", innerBean=").append(innerBean).append(", abstractBean=").append(abstractBean)
+ .append(", parentAttribute=").append(parentAttribute).append(", factoryBeanAttribute=")
+ .append(factoryBeanAttribute).append(", factoryMethodAttribute=").append(factoryMethodAttribute)
+ .append(", properties=").append(properties).append(", constructorargs=").append(constructorargs)
+ .append("]");
+ return builder.toString();
+ }
+
+} // end class SpringBeanElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java
new file mode 100644
index 0000000000..1de0595d60
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.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.implementation.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <constructor-arg> element in a Spring application-context
+ * - this has ref attribute
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringConstructorArgElement {
+
+ private String type;
+ private int autoIndex = -1;
+ private int index = -1;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringConstructorArgElement() {
+
+ }
+
+ public SpringConstructorArgElement(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getAutoIndex() {
+ return this.autoIndex;
+ }
+
+ public void setAutoIndex(int index) {
+ this.autoIndex = index;
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringConstructorArgElement [type=").append(type).append(", autoIndex=").append(autoIndex)
+ .append(", index=").append(index).append(", refs=").append(refs).append(", values=").append(values)
+ .append("]");
+ return builder.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
new file mode 100644
index 0000000000..a5d4adb1bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a Spring implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringImplementation extends ImplementationImpl implements Implementation, Extensible {
+ public final static QName TYPE = new QName(SCA11_NS, "implementation.spring");
+ // The location attribute which points to the Spring application-context XML file
+ private String location;
+ // The application-context file as a Spring Resource
+ private List<URL> resource;
+ private ComponentType componentType;
+ // Mapping of Services to Beans
+ private Map<String, SpringBeanElement> serviceMap;
+ // Mapping of property names to Java class
+ private Map<String, Class<?>> propertyMap;
+ // List of unresolved bean property references
+ private Map<String, Reference> unresolvedBeanRef;
+ private ClassLoader classLoader;
+
+ public SpringImplementation() {
+ super(TYPE);
+ this.location = null;
+ this.resource = null;
+ setUnresolved(true);
+ serviceMap = new HashMap<String, SpringBeanElement>();
+ propertyMap = new HashMap<String, Class<?>>();
+ unresolvedBeanRef = new HashMap<String, Reference>();
+ } // end method SpringImplementation
+
+ /* Returns the location attribute for this Spring implementation */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * Sets the location attribute for this Spring implementation
+ * location - a URI to the Spring application-context file
+ */
+ public void setLocation(String location) {
+ this.location = location;
+ return;
+ }
+
+ public void setResource(List<URL> resource) {
+ this.resource = resource;
+ }
+
+ public List<URL> getResource() {
+ return resource;
+ }
+
+ /*
+ * Returns the componentType for this Spring implementation
+ */
+ public ComponentType getComponentType() {
+ return componentType;
+ }
+
+ /*
+ * Sets the componentType for this Spring implementation
+ */
+ public void setComponentType(ComponentType componentType) {
+ this.componentType = componentType;
+ }
+
+ @Override
+ public List<Service> getServices() {
+ return componentType.getServices();
+ }
+
+ @Override
+ public List<Reference> getReferences() {
+ return componentType.getReferences();
+ }
+
+ @Override
+ public List<Property> getProperties() {
+ return componentType.getProperties();
+ }
+
+ /**
+ * Returns the Spring Bean which implements a particular service
+ * @param service the service
+ * @return the bean which implements the service, as a SpringBeanElement
+ */
+ public SpringBeanElement getBeanFromService(Service service) {
+ SpringBeanElement theBean = serviceMap.get(service.getName());
+ return theBean;
+ }
+
+ /**
+ * Sets the mapping from a service to the Spring Bean that implements the service
+ * @param service the service
+ * @param theBean a SpringBeanElement for the Bean implementing the service
+ */
+ public void setBeanForService(Service service, SpringBeanElement theBean) {
+ serviceMap.put(service.getName(), theBean);
+ }
+
+ /**
+ * Add a mapping from a SCA property name to a Java class for the property
+ * @param propertyName
+ * @param propertyClass
+ */
+ public void setPropertyClass(String propertyName, Class<?> propertyClass) {
+ if (propertyName == null || propertyClass == null)
+ return;
+ propertyMap.put(propertyName, propertyClass);
+ return;
+ } // end method setPropertyClass
+
+ /**
+ * Gets the Java Class for an SCA property
+ * @param propertyName - the property name
+ * @return - a Class object for the type of the property
+ */
+ public Class<?> getPropertyClass(String propertyName) {
+ return propertyMap.get(propertyName);
+ } // end method getPropertyClass
+
+ public void setUnresolvedBeanRef(String refName, Reference reference) {
+ if (refName == null || reference == null)
+ return;
+ unresolvedBeanRef.put(refName, reference);
+ return;
+ } // end method setUnresolvedBeanRef
+
+ public Reference getUnresolvedBeanRef(String refName) {
+ return unresolvedBeanRef.get(refName);
+ } // end method getUnresolvedBeanRef
+
+ /**
+ * Use preProcess to validate and map the references and properties dynamically
+ */
+ public void build(Component component) {
+
+ for (Reference reference : component.getReferences()) {
+ if (unresolvedBeanRef.containsKey(reference.getName())) {
+ Reference ref = unresolvedBeanRef.get(reference.getName());
+ componentType.getReferences().add(createReference(reference, ref.getInterfaceContract()));
+ unresolvedBeanRef.remove(reference.getName());
+ }
+ }
+
+ for (Property property : component.getProperties()) {
+ if (unresolvedBeanRef.containsKey(property.getName())) {
+ componentType.getProperties().add(createProperty(property));
+ this.setPropertyClass(property.getName(), property.getClass());
+ unresolvedBeanRef.remove(property.getName());
+ }
+ }
+ }
+
+ protected Reference createReference(Reference reference, InterfaceContract interfaze) {
+ Reference newReference;
+ try {
+ newReference = (Reference)reference.clone();
+ if (newReference.getInterfaceContract() == null)
+ newReference.setInterfaceContract(interfaze);
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e); // should not ever happen
+ }
+ return newReference;
+ }
+
+ protected Property createProperty(Property property) {
+ Property newProperty;
+ try {
+ newProperty = (Property)property.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e); // should not ever happen
+ }
+ return newProperty;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (!(obj instanceof SpringImplementation)) {
+ return false;
+ }
+ SpringImplementation other = (SpringImplementation)obj;
+ if (location == null) {
+ if (other.location != null) {
+ return false;
+ }
+ } else if (!location.equals(other.location)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringImplementation [location=").append(location).append(", resource=").append(resource)
+ .append("]");
+ return builder.toString();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java
new file mode 100644
index 0000000000..1a246fa03a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.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.implementation.spring;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder;
+
+/**
+ *
+ */
+public class SpringImplementationBuilder implements ImplementationBuilder<SpringImplementation> {
+
+ public void build(Component component, SpringImplementation implmentation, BuilderContext context) {
+ implmentation.build(component);
+ }
+
+ public QName getImplementationType() {
+ return SpringImplementation.TYPE;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java
new file mode 100644
index 0000000000..27c09c1f18
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.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.implementation.spring;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants used in Spring Application Context XML files.
+ */
+public interface SpringImplementationConstants {
+
+ String SCA_NS = "http://www.springframework.org/schema/sca";
+ String SPRING_NS = "http://www.springframework.org/schema/beans";
+
+ String PROPERTY = "property";
+ QName SCA_PROPERTY_ELEMENT = new QName(SCA_NS, PROPERTY);
+ QName PROPERTY_ELEMENT = new QName(SPRING_NS, PROPERTY);
+
+ String SCASERVICE = "service";
+ QName SCA_SERVICE_ELEMENT = new QName(SCA_NS, SCASERVICE);
+
+ String SCAREFERENCE = "reference";
+ QName SCA_REFERENCE_ELEMENT = new QName(SCA_NS, SCAREFERENCE);
+
+ String BEANS = "beans";
+ QName BEANS_ELEMENT = new QName(SPRING_NS, BEANS);
+
+ String IMPORT = "import";
+ QName IMPORT_ELEMENT = new QName(SPRING_NS, IMPORT);
+
+ String BEAN = "bean";
+ QName BEAN_ELEMENT = new QName(SPRING_NS, BEAN);
+
+ String CONSTRUCTORARG = "constructor-arg";
+ QName CONSTRUCTORARG_ELEMENT = new QName(SPRING_NS, CONSTRUCTORARG);
+
+ String LIST = "list";
+ QName LIST_ELEMENT = new QName(SPRING_NS, LIST);
+
+ String SET = "set";
+ QName SET_ELEMENT = new QName(SPRING_NS, SET);
+
+ String MAP = "map";
+ QName MAP_ELEMENT = new QName(SPRING_NS, MAP);
+
+ String VALUE = "value";
+ QName VALUE_ELEMENT = new QName(SPRING_NS, VALUE);
+
+ String REF = "ref";
+ QName REF_ELEMENT = new QName(SPRING_NS, REF);
+
+ String ENTRY = "entry";
+ QName ENTRY_ELEMENT = new QName(SPRING_NS, ENTRY);
+
+ String APPLICATION_CONTEXT = "application-context.xml";
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java
new file mode 100644
index 0000000000..8de3a4cbe1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.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.implementation.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <property> element in a Spring application-context
+ * - this has name and ref attributes
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringPropertyElement {
+
+ private String name;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringPropertyElement() {
+ }
+
+ public SpringPropertyElement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringPropertyElement [name=").append(name).append(", refs=").append(refs).append(", values=")
+ .append(values).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java
new file mode 100644
index 0000000000..f27506f28b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.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.sca.implementation.spring;
+
+/**
+ * Represents an <sca:property> element in a Spring application-context
+ * - this has name and type attributes
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAPropertyElement {
+
+ private String name;
+ private String type;
+
+ public SpringSCAPropertyElement() {
+ super();
+ }
+
+ public SpringSCAPropertyElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAPropertyElement [name=").append(name).append(", type=").append(type).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
new file mode 100644
index 0000000000..f06f05a46a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a <sca:reference> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAReferenceElement {
+
+ private String name;
+ private String type;
+ private String defaultBean;
+ private List<Intent> intents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ private List<QName> intentNames = new ArrayList<QName>();
+ private List<QName> policySetNames = new ArrayList<QName>();
+
+ public SpringSCAReferenceElement() {
+
+ }
+
+ public SpringSCAReferenceElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setDefaultBean(String defaultBean) {
+ this.defaultBean = defaultBean;
+ }
+
+ public String getDefaultBean() {
+ return defaultBean;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return intents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<QName> getIntentNames() {
+ return intentNames;
+ }
+
+ public List<QName> getPolicySetNames() {
+ return policySetNames;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAReferenceElement [name=").append(name).append(", type=").append(type)
+ .append(", defaultBean=").append(defaultBean).append(", intents=").append(intents).append(", policySets=")
+ .append(policySets).append(", intentNames=").append(intentNames).append(", policySetNames=")
+ .append(policySetNames).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringSCAReferenceElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
new file mode 100644
index 0000000000..38c124c3b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a <sca:service> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAServiceElement {
+
+ private String name;
+ private String type;
+ private String target;
+ private List<Intent> intents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<QName> intentNames = new ArrayList<QName>();
+ private List<QName> policySetNames = new ArrayList<QName>();
+
+ public SpringSCAServiceElement() {
+
+ }
+
+ public SpringSCAServiceElement(String name, String target) {
+ this.name = name;
+ this.target = target;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return intents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<QName> getIntentNames() {
+ return intentNames;
+ }
+
+ public List<QName> getPolicySetNames() {
+ return policySetNames;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAServiceElement [name=").append(name).append(", type=").append(type)
+ .append(", target=").append(target).append(", intents=").append(intents).append(", policySets=")
+ .append(policySets).append(", intentNames=").append(intentNames).append(", policySetNames=")
+ .append(policySetNames).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringSCAServiceElement
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
new file mode 100644
index 0000000000..5eaf27ab81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.spring.introspect;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+
+/**
+ * Provides introspection functions for Spring beans
+ * This version leans heavily on the implementation-java classes
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringBeanIntrospector {
+
+ private JavaImplementationFactory javaImplementationFactory;
+
+ /**
+ * The constructor sets up the various visitor elements that will be used to introspect
+ * the Spring bean and extract SCA information.
+ *
+ * @param assemblyFactory The Assembly Factory to use
+ * @param javaFactory The Java Interface Factory to use
+ * @param policyFactory The Policy Factory to use.
+ */
+ public SpringBeanIntrospector(ExtensionPointRegistry registry, List<SpringConstructorArgElement> conArgs) {
+
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ javaImplementationFactory = factories.getFactory(JavaImplementationFactory.class);
+ } // end constructor
+
+ /**
+ * Introspect a Spring Bean and extract the features important to SCA
+ * @param beanClass the Spring Bean class to introspect
+ * @param componentType the componentType that is filled in through the introspection
+ * process (assumed empty on invocation, filled on return
+ * @return a Map of property names to JavaElementImpl
+ * @throws ContributionResolveException - if there was a problem resolving the
+ * Spring Bean or its componentType
+ *
+ */
+ public JavaImplementation introspectBean(Class<?> beanClass, ComponentType componentType)
+ throws ContributionResolveException {
+ if (componentType == null)
+ throw new ContributionResolveException("Introspect Spring bean: supplied componentType is null");
+
+ // Create a Java implementation ready for the introspection
+ JavaImplementation javaImplementation = javaImplementationFactory.createJavaImplementation();
+ // Set the type to be implementation.spring to avoid heuristic introspection
+ javaImplementation.setType(SpringImplementation.TYPE);
+
+ try {
+ // Introspect the bean...the results of the introspection are placed into the Java implementation
+ javaImplementationFactory.createJavaImplementation(javaImplementation, beanClass);
+
+ // Extract the services, references & properties found through introspection
+ // put the services, references and properties into the component type
+ componentType.getServices().addAll(javaImplementation.getServices());
+ componentType.getReferences().addAll(javaImplementation.getReferences());
+ componentType.getProperties().addAll(javaImplementation.getProperties());
+
+ } catch (IntrospectionException e) {
+ throw new ContributionResolveException(e);
+ } // end try
+
+ return javaImplementation;
+
+ } // end method introspectBean
+
+} // end class SpringBeanIntrospector
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
new file mode 100644
index 0000000000..cca7586734
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
@@ -0,0 +1,985 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.introspect;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.SpringPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Introspects a Spring XML application-context configuration file to create <implementation-spring../>
+ * component type information.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringXMLComponentTypeLoader {
+ private final static Logger log = Logger.getLogger(SpringXMLComponentTypeLoader.class.getName());
+
+ private ExtensionPointRegistry registry;
+ private ContributionFactory contributionFactory;
+ private AssemblyFactory assemblyFactory;
+ private PolicyFactory policyFactory;
+ private JavaInterfaceFactory javaFactory;
+ private SpringBeanIntrospector beanIntrospector;
+
+ private SpringXMLBeanDefinitionLoader xmlBeanDefinitionLoader;
+
+ public SpringXMLComponentTypeLoader(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ this.javaFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.contributionFactory = factories.getFactory(ContributionFactory.class);
+ this.xmlBeanDefinitionLoader =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(SpringXMLBeanDefinitionLoader.class);
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+ protected Class<SpringImplementation> getImplementationClass() {
+ return SpringImplementation.class;
+ }
+
+ /**
+ * Base method which loads the component type from the application-context attached to the
+ * Spring implementation
+ *
+ */
+ public void load(SpringImplementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionReadException {
+ //System.out.println("Spring TypeLoader - load method start");
+ ComponentType componentType = implementation.getComponentType();
+ /* Check that there is a component type object already set */
+ if (componentType == null) {
+ throw new ContributionReadException("SpringXMLLoader load: implementation has no ComponentType object");
+ }
+ if (componentType.isUnresolved()) {
+ /* Fetch the location of the application-context file from the implementation */
+ loadFromXML(implementation, resolver, context);
+ if (!componentType.isUnresolved())
+ implementation.setUnresolved(false);
+ } // end if
+ //System.out.println("Spring TypeLoader - load method complete");
+ } // end method load
+
+ private Class<?> resolveClass(ModelResolver resolver, String className, ProcessorContext context)
+ throws ClassNotFoundException {
+ ClassReference classReference = new ClassReference(className);
+ classReference = resolver.resolveModel(ClassReference.class, classReference, context);
+ if (classReference.isUnresolved()) {
+ throw new ClassNotFoundException(className);
+ }
+ Class<?> javaClass = classReference.getJavaClass();
+ return javaClass;
+ }
+
+ /**
+ * Method which fills out the component type for a Spring implementation by reading the
+ * Spring application-context.xml file.
+ *
+ * @param implementation SpringImplementation into which to load the component type information
+ * @throws ContributionReadException Failed to read the contribution
+ */
+ private void loadFromXML(SpringImplementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionReadException {
+ List<SpringBeanElement> beans = new ArrayList<SpringBeanElement>();
+ List<SpringSCAServiceElement> services = new ArrayList<SpringSCAServiceElement>();
+ List<SpringSCAReferenceElement> references = new ArrayList<SpringSCAReferenceElement>();
+ List<SpringSCAPropertyElement> scaproperties = new ArrayList<SpringSCAPropertyElement>();
+
+ URL resource;
+ List<URL> contextResources = new ArrayList<URL>();
+ String contextPath = implementation.getLocation();
+
+ try {
+ resource = resolveLocation(resolver, contextPath, context);
+ contextResources = getApplicationContextResource(resource);
+
+ implementation.setClassLoader(new ContextClassLoader(resolver, context));
+ implementation.setResource(contextResources);
+ // The URI is used to uniquely identify the Implementation
+ implementation.setURI(resource.toString());
+
+ List<SpringBeanElement> appCxtBeans = new ArrayList<SpringBeanElement>();
+ List<SpringSCAServiceElement> appCxtServices = new ArrayList<SpringSCAServiceElement>();
+ List<SpringSCAReferenceElement> appCxtReferences = new ArrayList<SpringSCAReferenceElement>();
+ List<SpringSCAPropertyElement> appCxtProperties = new ArrayList<SpringSCAPropertyElement>();
+
+ if (xmlBeanDefinitionLoader != null) {
+ xmlBeanDefinitionLoader.load(contextResources,
+ appCxtServices,
+ appCxtReferences,
+ appCxtProperties,
+ appCxtBeans,
+ context);
+ populatePolicies(appCxtServices, appCxtReferences);
+ }
+ // Validate the beans from individual application context for uniqueness
+ validateBeans(appCxtBeans, appCxtServices, appCxtReferences, appCxtProperties, context.getMonitor());
+ // Add all the validated beans to the generic list
+ beans.addAll(appCxtBeans);
+ services.addAll(appCxtServices);
+ references.addAll(appCxtReferences);
+ scaproperties.addAll(appCxtProperties);
+ } catch (Throwable e) {
+ throw new ContributionReadException(e);
+ }
+
+ /* At this point, the complete application-context.xml file has been read and its contents */
+ /* stored in the lists of beans, services, references. These are now used to generate */
+ /* the implied componentType for the application context */
+ generateComponentType(implementation, resolver, beans, services, references, scaproperties, context);
+
+ return;
+ } // end method loadFromXML
+
+ public void populatePolicies(List<SpringSCAServiceElement> appCxtServices,
+ List<SpringSCAReferenceElement> appCxtReferences) {
+ for (SpringSCAReferenceElement e : appCxtReferences) {
+ for (QName qn : e.getIntentNames()) {
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qn);
+ e.getRequiredIntents().add(intent);
+ }
+ for (QName qn : e.getPolicySetNames()) {
+ PolicySet ps = policyFactory.createPolicySet();
+ ps.setName(qn);
+ e.getPolicySets().add(ps);
+ }
+ }
+
+ for (SpringSCAServiceElement e : appCxtServices) {
+ for (QName qn : e.getIntentNames()) {
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qn);
+ e.getRequiredIntents().add(intent);
+ }
+ for (QName qn : e.getPolicySetNames()) {
+ PolicySet ps = policyFactory.createPolicySet();
+ ps.setName(qn);
+ e.getPolicySets().add(ps);
+ }
+ }
+ }
+
+ private URL resolveLocation(ModelResolver resolver, String contextPath, ProcessorContext context)
+ throws MalformedURLException, ContributionReadException {
+ URL resource = null;
+ URI uri = URI.create(contextPath);
+ if (!uri.isAbsolute()) {
+ Artifact parent = context.getArtifact();
+ if (parent != null && parent.getURI() != null) {
+ URI base = URI.create("/" + parent.getURI());
+ uri = base.resolve(uri);
+ // Remove the leading / to make artifact resolver happy
+ if (uri.toString().startsWith("/")) {
+ uri = URI.create(uri.toString().substring(1));
+ }
+ }
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setUnresolved(true);
+ artifact.setURI(uri.toString());
+ artifact = resolver.resolveModel(Artifact.class, artifact, context);
+ if (!artifact.isUnresolved()) {
+ resource = new URL(artifact.getLocation());
+ } else {
+ throw new ContributionReadException("Location cannot be resloved: " + contextPath);
+ }
+ } else {
+ resource = new URL(contextPath);
+ }
+ return resource;
+ }
+
+ /**
+ * Generates the Spring implementation component type from the configuration contained in the
+ * lists of beans, services, references and scaproperties derived from the application context
+ */
+ private void generateComponentType(SpringImplementation implementation,
+ ModelResolver resolver,
+ List<SpringBeanElement> beans,
+ List<SpringSCAServiceElement> services,
+ List<SpringSCAReferenceElement> references,
+ List<SpringSCAPropertyElement> scaproperties,
+ ProcessorContext context) throws ContributionReadException {
+ /*
+ * 1. Each sca:service becomes a service in the component type
+ * 2. Each sca:reference becomes a reference in the component type
+ * 3. Each sca:property becomes a property in the component type
+ * 4. IF there are no explicit service elements, each bean becomes a service
+ * 5. Each bean property which is a reference not pointing at another bean in the
+ * application context becomes a reference unless it is pointing at one of the references
+ * 6. Each bean property which is not a reference and which is not pointing
+ * at another bean in the application context becomes a property in the component type
+ */
+
+ JavaImplementation javaImplementation = null;
+ ComponentType componentType = implementation.getComponentType();
+
+ try {
+ // Deal with the services first....
+ Iterator<SpringSCAServiceElement> its = services.iterator();
+ while (its.hasNext()) {
+ SpringSCAServiceElement serviceElement = its.next();
+ Class<?> interfaze = resolveClass(resolver, serviceElement.getType(), context);
+ Service theService = createService(interfaze, serviceElement.getName());
+ // Spring allows duplication of bean definitions in multiple context scenario,
+ // in such cases, the latest bean definition overrides the older ones, hence
+ // we will remove any older definition and use the latest.
+ Service duplicate = null;
+ for (Service service : componentType.getServices()) {
+ if (service.getName().equals(theService.getName()))
+ duplicate = service;
+ }
+ if (duplicate != null)
+ componentType.getServices().remove(duplicate);
+
+ componentType.getServices().add(theService);
+ // Add this service to the Service / Bean map
+ String beanName = serviceElement.getTarget();
+ boolean found = false;
+ for (SpringBeanElement beanElement : beans) {
+ if (beanName.equals(beanElement.getId())) {
+ if (isValidBeanForService(beanElement)) {
+ // add the required intents and policySets for the service
+ theService.getRequiredIntents().addAll(serviceElement.getRequiredIntents());
+ theService.getPolicySets().addAll(serviceElement.getPolicySets());
+ implementation.setBeanForService(theService, beanElement);
+ found = true;
+ break;
+ }
+ }
+ } // end for
+
+ if (!found) {
+ // REVIEW: Adding a SpringBeanElement "proxy" so that the bean id can be used at runtime to look
+ // up the bean instance from the parent context
+ implementation.setBeanForService(theService,
+ new SpringBeanElement(serviceElement.getTarget(), null));
+ }
+ } // end while
+
+ // Next handle the references
+ Iterator<SpringSCAReferenceElement> itr = references.iterator();
+ while (itr.hasNext()) {
+ SpringSCAReferenceElement referenceElement = itr.next();
+ Class<?> interfaze = resolveClass(resolver, referenceElement.getType(), context);
+ Reference theReference = createReference(interfaze, referenceElement.getName());
+ // Override the older bean definition with the latest ones
+ // for the duplicate definitions found.
+ Reference duplicate = null;
+ for (Reference reference : componentType.getReferences()) {
+ if (reference.getName().equals(theReference.getName()))
+ duplicate = reference;
+ }
+ if (duplicate != null)
+ componentType.getReferences().remove(duplicate);
+
+ // add the required intents and policySets for this reference
+ theReference.getRequiredIntents().addAll(referenceElement.getRequiredIntents());
+ theReference.getPolicySets().addAll(referenceElement.getPolicySets());
+ componentType.getReferences().add(theReference);
+ } // end while
+
+ // Next handle the properties
+ Iterator<SpringSCAPropertyElement> itsp = scaproperties.iterator();
+ while (itsp.hasNext()) {
+ SpringSCAPropertyElement scaproperty = itsp.next();
+ // Create a component type property if the SCA property element has a name
+ // and a type declared...
+ if (scaproperty.getType() != null && scaproperty.getName() != null) {
+ Property theProperty = assemblyFactory.createProperty();
+ theProperty.setName(scaproperty.getName());
+ // Get the Java class and then an XSD element type for the property
+ Class<?> propType = Class.forName(scaproperty.getType());
+ theProperty.setXSDType(JavaXMLMapper.getXMLType(propType));
+ // Override the older bean definition with the latest ones
+ // for the duplicate definitions found.
+ Property duplicate = null;
+ for (Property property : componentType.getProperties()) {
+ if (property.getName().equals(theProperty.getName()))
+ duplicate = property;
+ }
+ if (duplicate != null)
+ componentType.getProperties().remove(duplicate);
+
+ componentType.getProperties().add(theProperty);
+ // Remember the Java Class (ie the type) for this property
+ implementation.setPropertyClass(theProperty.getName(), propType);
+ } // end if
+ } // end while
+
+ // Finally deal with the beans
+ Iterator<SpringBeanElement> itb;
+ // If there are no explicit service elements, then expose all the beans
+ if (services.isEmpty()) {
+ itb = beans.iterator();
+ // Loop through all the beans found
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+
+ // If its not a valid bean for service, ignore it
+ if (!isValidBeanForService(beanElement)) {
+ continue;
+ }
+ try {
+ // Load the Spring bean class
+ Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
+ // Introspect the bean
+ beanIntrospector = new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
+ ComponentType beanComponentType = assemblyFactory.createComponentType();
+ javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
+ // Set the service name as bean name
+ for (Service componentService : beanComponentType.getServices()) {
+ componentService.setName(beanElement.getId());
+ }
+ // Get the service interface defined by this Spring Bean and add to
+ // the component type of the Spring Assembly
+ List<Service> beanServices = beanComponentType.getServices();
+ componentType.getServices().addAll(beanServices);
+ // Add these services to the Service / Bean map
+ for (Service beanService : beanServices) {
+ implementation.setBeanForService(beanService, beanElement);
+ }
+ } catch (Throwable e) {
+ // [rfeng] FIXME: Some Spring beans have constructors that take pararemters injected by Spring and
+ // Tuscany is not happy with that during the introspection
+ log.log(Level.SEVERE, e.getMessage(), e);
+ }
+ } // end while
+ } // end if
+
+ itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+
+ // If its not a valid bean for service, ignore it
+ if (!isValidBeanForService(beanElement)) {
+ continue;
+ }
+ // Ignore if the bean has no properties and constructor arguments
+ if (beanElement.getProperties().isEmpty() && beanElement.getCustructorArgs().isEmpty())
+ continue;
+
+ ComponentType beanComponentType = assemblyFactory.createComponentType();
+
+ try {
+ Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
+ // Introspect the bean
+ beanIntrospector = new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
+ javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
+ } catch (Exception e) {
+ // [rfeng] FIXME: Some Spring beans have constructors that take pararemters injected by Spring and
+ // Tuscany is not happy with that during the introspection
+ log.log(Level.SEVERE, e.getMessage(), e);
+ continue;
+ }
+ Map<String, JavaElementImpl> propertyMap = javaImplementation.getPropertyMembers();
+ JavaConstructorImpl constructor = javaImplementation.getConstructor();
+ // Get the references by this Spring Bean and add the unresolved ones to
+ // the component type of the Spring Assembly
+ List<Reference> beanReferences = beanComponentType.getReferences();
+ List<Property> beanProperties = beanComponentType.getProperties();
+
+ Set<String> excludedNames = new HashSet<String>();
+ Iterator<SpringPropertyElement> itp = beanElement.getProperties().iterator();
+ while (itp.hasNext()) {
+ SpringPropertyElement propertyElement = itp.next();
+ // Exclude the reference that is also known as a spring property
+ excludedNames.add(propertyElement.getName());
+ for (String propertyRef : propertyElement.getRefs()) {
+ if (propertyRefUnresolved(propertyRef, beans, references, scaproperties)) {
+ // This means an unresolved reference from the spring bean...
+ for (Reference reference : beanReferences) {
+ if (propertyElement.getName().equals(reference.getName())) {
+ // The name of the reference in this case is the string in
+ // the @ref attribute of the Spring property element, NOT the
+ // name of the field in the Spring bean....
+ reference.setName(propertyRef);
+ componentType.getReferences().add(reference);
+ break;
+ } // end if
+ } // end for
+
+ // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
+ for (Property scaproperty : beanProperties) {
+ if (propertyElement.getName().equals(scaproperty.getName())) {
+ // The name of the reference in this case is the string in
+ // the @ref attribute of the Spring property element, NOT the
+ // name of the field in the Spring bean....
+ Class<?> interfaze =
+ resolveClass(resolver,
+ (propertyMap.get(propertyElement.getName()).getType()).getName(),
+ context);
+ Reference theReference = createReference(interfaze, propertyRef);
+ implementation.setUnresolvedBeanRef(propertyRef, theReference);
+ break;
+ } // end if
+ } // end for
+ } // end if
+ } // end for
+ } // end while
+
+ Iterator<SpringConstructorArgElement> itcr = beanElement.getCustructorArgs().iterator();
+ while (itcr.hasNext()) {
+ SpringConstructorArgElement conArgElement = itcr.next();
+ for (String constructorArgRef : conArgElement.getRefs()) {
+ if (propertyRefUnresolved(constructorArgRef, beans, references, scaproperties)) {
+ for (JavaParameterImpl parameter : constructor.getParameters()) {
+ String paramType = parameter.getType().getName();
+ Class<?> interfaze = resolveClass(resolver, paramType, context);
+ // Create a component type reference/property if the constructor-arg element has a
+ // type attribute OR index attribute declared...
+ if ((conArgElement.getType() != null && paramType.equals(conArgElement.getType())) || (conArgElement
+ .getIndex() != -1 && (conArgElement.getIndex() == parameter.getIndex()))) {
+ // [rfeng] Commenting out the following code as the constructor parameter based SCA
+ // references are added already
+ /*
+ if (parameter.getClassifer() == org.oasisopen.sca.annotation.Reference.class) {
+ Reference theReference = createReference(interfaze, constructorArgRef);
+ componentType.getReferences().add(theReference);
+ }
+ */
+ if (parameter.getClassifer() == org.oasisopen.sca.annotation.Property.class) {
+ // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
+ // we might need to verify with the component definition later.
+ Reference theReference = createReference(interfaze, constructorArgRef);
+ implementation.setUnresolvedBeanRef(constructorArgRef, theReference);
+ }
+ }
+ } // end for
+ } // end if
+ } // end for
+ } // end while
+
+ // [rfeng] Add the remaining introspected references (w/ @Reference but without Spring property ref)
+ for (Reference ref : beanReferences) {
+ if (!excludedNames.contains(ref.getName()) && componentType.getReference(ref.getName()) == null) {
+ // Only add the ones that not listed by sca:reference
+ componentType.getReferences().add(ref);
+ }
+ }
+
+ } // end while
+
+ } catch (ClassNotFoundException e) {
+ // Means that either an interface class, property class or a bean was not found
+ throw new ContributionReadException(e);
+ } catch (InvalidInterfaceException e) {
+ throw new ContributionReadException(e);
+ } // end try
+
+ // If we get here, the Spring assembly component type is resolved
+ componentType.setUnresolved(false);
+ implementation.setComponentType(componentType);
+ return;
+ } // end method generateComponentType
+
+ /*
+ * Determines whether a reference attribute of a Spring property element is resolved either
+ * by a bean in the application context or by an SCA reference element or by an SCA property
+ * element
+ * @param ref - a String containing the name of the reference - may be null
+ * @param beans - a List of SpringBean elements
+ * @param references - a List of SCA reference elements
+ * @return true if the property is not resolved, false if it is resolved
+ */
+ private boolean propertyRefUnresolved(String ref,
+ List<SpringBeanElement> beans,
+ List<SpringSCAReferenceElement> references,
+ List<SpringSCAPropertyElement> scaproperties) {
+ boolean unresolved = true;
+
+ if (ref != null) {
+ // Scan over the beans looking for a match
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ // Does the bean name match the ref?
+ if (ref.equals(beanElement.getId())) {
+ unresolved = false;
+ break;
+ } // end if
+ } // end while
+ // Scan over the SCA reference elements looking for a match
+ if (unresolved) {
+ Iterator<SpringSCAReferenceElement> itr = references.iterator();
+ while (itr.hasNext()) {
+ SpringSCAReferenceElement referenceElement = itr.next();
+ if (ref.equals(referenceElement.getName())) {
+ unresolved = false;
+ break;
+ } // end if
+ } // end while
+ } // end if
+ // Scan over the SCA property elements looking for a match
+ if (unresolved) {
+ Iterator<SpringSCAPropertyElement> itsp = scaproperties.iterator();
+ while (itsp.hasNext()) {
+ SpringSCAPropertyElement propertyElement = itsp.next();
+ if (ref.equals(propertyElement.getName())) {
+ unresolved = false;
+ break;
+ } // end if
+ } // end while
+ } // end if
+ } else {
+ // In the case where ref = null, the property is not going to be a reference of any
+ // kind and can be ignored
+ unresolved = false;
+ } // end if
+
+ return unresolved;
+
+ } // end method propertyRefUnresolved
+
+ /**
+ * Validates whether the <sca:service>, <sca:reference> and <sca:property> elements
+ * has unique names within the application context.
+ */
+ private void validateBeans(List<SpringBeanElement> beans,
+ List<SpringSCAServiceElement> services,
+ List<SpringSCAReferenceElement> references,
+ List<SpringSCAPropertyElement> scaproperties,
+ Monitor monitor) throws ContributionReadException {
+
+ // The @target attribute of a <service/> subelement of a <beans/> element
+ // MUST have the value of the @name attribute of one of the <bean/>
+ // subelements of the <beans/> element.
+ Iterator<SpringSCAServiceElement> its = services.iterator();
+ while (its.hasNext()) {
+ SpringSCAServiceElement serviceElement = its.next();
+ boolean targetBeanExists = false;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (serviceElement.getTarget().equals(beanElement.getId()))
+ targetBeanExists = true;
+ }
+ if (!targetBeanExists) {
+ // REVIEW: [rfeng] The target bean can exist in the parent Spring application context which we don't know
+ // until runtime
+ warning(monitor, "TargetBeanDoesNotExist", beans);
+ }
+ } // end while
+
+ // The value of the @name attribute of an <sca:reference/> subelement of a <beans/>
+ // element MUST be unique amongst the @name attributes of the <sca:property/>
+ // subelements and the <bean/> subelements of the <beans/> element.
+ // AND
+ // The @default attribute of a <sca:reference/> subelement of a <beans/>
+ // element MUST have the value of the @name attribute of one of the <bean/>
+ // subelements of the <beans/> element.
+ Iterator<SpringSCAReferenceElement> itr = references.iterator();
+ while (itr.hasNext()) {
+ SpringSCAReferenceElement referenceElement = itr.next();
+ boolean defaultBeanExists = true;
+ boolean isUniqueReferenceName = true;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (referenceElement.getDefaultBean() != null)
+ if (referenceElement.getDefaultBean().equals(beanElement.getId()))
+ defaultBeanExists = false;
+ if (referenceElement.getName().equals(beanElement.getId()))
+ isUniqueReferenceName = false;
+ }
+ Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
+ while (itp.hasNext()) {
+ SpringSCAPropertyElement propertyElement = itp.next();
+ if (referenceElement.getName().equals(propertyElement.getName()))
+ isUniqueReferenceName = false;
+ }
+ if (!defaultBeanExists)
+ error(monitor, "DefaultBeanDoesNotExist", beans);
+ if (!isUniqueReferenceName)
+ error(monitor, "ScaReferenceNameNotUnique", beans);
+ } // end while
+
+ // The value of the @name attribute of an <sca:property/> subelement of a <beans/>
+ // element MUST be unique amongst the @name attributes of the <sca:reference/>
+ // subelements and the <bean/> subelements of the <beans/> element.
+ Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
+ while (itp.hasNext()) {
+ SpringSCAPropertyElement propertyElement = itp.next();
+ boolean isUniquePropertyName = true;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (propertyElement.getName().equals(beanElement.getId()))
+ isUniquePropertyName = false;
+ }
+ Iterator<SpringSCAReferenceElement> itrp = references.iterator();
+ while (itrp.hasNext()) {
+ SpringSCAReferenceElement referenceElement = itrp.next();
+ if (propertyElement.getName().equals(referenceElement.getName()))
+ isUniquePropertyName = false;
+ }
+ if (!isUniquePropertyName)
+ error(monitor, "ScaPropertyNameNotUnique", beans);
+ } // end while
+ }
+
+ /**
+ * Validates whether a bean definition is valid for exposing as service.
+ */
+ private boolean isValidBeanForService(SpringBeanElement beanElement) {
+
+ if (beanElement.isInnerBean())
+ return false;
+ if (beanElement.hasParentAttribute())
+ return false;
+ if (beanElement.hasFactoryMethodAttribute())
+ return false;
+ if (beanElement.hasFactoryBeanAttribute())
+ return false;
+ if (beanElement.getClassName() == null)
+ return false;
+ if (beanElement.getClassName().startsWith("org.springframework"))
+ return false;
+ // return true otherwise
+ return true;
+ }
+
+ /**
+ * Gets hold of the application-context.xml file as a Spring resource
+ * @param locationAttr - the location attribute from the <implementation.spring../> element
+ * @param cl - the ClassLoader for the Spring implementation
+ */
+ protected List<URL> getApplicationContextResource(URL url) throws ContributionReadException {
+ File manifestFile = null;
+ File appXmlFile;
+ File appXmlFolder;
+ File locationFile = null;
+ List<URL> appCtxResources = new ArrayList<URL>();
+
+ if (url != null) {
+ String path = url.getPath();
+ locationFile = new File(path);
+ } else {
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + "unable to find resource file "
+ + url);
+ }
+
+ if (locationFile.isDirectory()) {
+ try {
+ manifestFile = new File(locationFile, "META-INF" + File.separator + "MANIFEST.MF");
+ if (manifestFile.exists()) {
+ Manifest mf = new Manifest(new FileInputStream(manifestFile));
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ appXmlFile = new File(locationFile, path.trim());
+ if (appXmlFile.exists()) {
+ appCtxResources.add(appXmlFile.toURI().toURL());
+ }
+ }
+ return appCtxResources;
+ }
+ }
+ // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
+ // xml files available in the META-INF/spring folder.
+ appXmlFolder = new File(locationFile, "META-INF" + File.separator + "spring");
+ if (appXmlFolder.exists()) {
+ File[] files = appXmlFolder.listFiles();
+ for (File appFile : files) {
+ if (appFile.getName().endsWith(".xml")) {
+ appCtxResources.add(appFile.toURI().toURL());
+ }
+ }
+ return appCtxResources;
+ }
+ } catch (IOException e) {
+ throw new ContributionReadException("Error reading manifest " + manifestFile);
+ }
+ } else {
+ if (locationFile.isFile() && locationFile.getName().endsWith(".jar")) {
+ try {
+ JarFile jf = new JarFile(locationFile);
+ JarEntry je;
+ Manifest mf = jf.getManifest();
+ if (mf != null) {
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ je = jf.getJarEntry(path.trim());
+ if (je != null)
+ appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL()
+ + "!/"
+ + appCtxPath));
+ }
+ return appCtxResources;
+ }
+ }
+ // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
+ // .xml files available in the META-INF/spring folder.
+ Enumeration<JarEntry> entries = jf.entries();
+ while (entries.hasMoreElements()) {
+ je = entries.nextElement();
+ if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
+ appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL() + "!/" + je.getName()));
+ }
+ }
+ return appCtxResources;
+ } catch (IOException e) {
+ // TODO: create a more appropriate exception type
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + " IO exception reading context file.",
+ e);
+ }
+ } else {
+ if (locationFile.getName().endsWith(".xml")) {
+ appCtxResources.add(url);
+ return appCtxResources;
+ } else {
+ // Deal with the directory inside a jar file, in case the contribution itself is a JAR file.
+ try {
+ if (locationFile.getPath().indexOf(".jar") > 0) {
+ String jarPath = url.getPath().substring(5, url.getPath().indexOf("!"));
+ JarFile jf = new JarFile(jarPath);
+ JarEntry je =
+ jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/") + 2) + "/"
+ + "META-INF"
+ + "/"
+ + "MANIFEST.MF");
+ if (je != null) {
+ Manifest mf = new Manifest(jf.getInputStream(je));
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ je =
+ jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/") + 2) + "/"
+ + path.trim());
+ if (je != null) {
+ appCtxResources.add(new URL("jar:" + url.getPath() + "/" + path.trim()));
+ }
+ }
+ return appCtxResources;
+ }
+ }
+ // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
+ // .xml files available in the META-INF/spring folder.
+ Enumeration<JarEntry> entries = jf.entries();
+ while (entries.hasMoreElements()) {
+ je = entries.nextElement();
+ if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
+ appCtxResources.add(new URL("jar:" + url.getPath() + "/" + je.getName()));
+ }
+ }
+ return appCtxResources;
+ }
+ } catch (IOException e) {
+ throw new ContributionReadException("Error reading manifest " + manifestFile);
+ }
+ }
+ }
+ }
+
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + "unable to read resource file "
+ + url);
+ } // end method getApplicationContextResource
+
+ /**
+ * Creates a Service for the component type based on its name and Java interface
+ */
+ public Service createService(Class<?> interfaze, String name) throws InvalidInterfaceException {
+ Service service = assemblyFactory.createService();
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ service.setInterfaceContract(interfaceContract);
+
+ // Set the name for the service
+ service.setName(name);
+
+ // Set the call interface and, if present, the callback interface
+ JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
+ service.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ service.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+ return service;
+ } // end method createService
+
+ /**
+ * Creates a Reference for the component type based on its name and Java interface
+ */
+ private org.apache.tuscany.sca.assembly.Reference createReference(Class<?> interfaze, String name)
+ throws InvalidInterfaceException {
+ org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ reference.setInterfaceContract(interfaceContract);
+
+ // Set the name of the reference to the supplied name and the multiplicity of the reference
+ // to 1..1 - for Spring implementations, this is the only multiplicity supported
+ reference.setName(name);
+ reference.setMultiplicity(Multiplicity.ONE_ONE);
+
+ // Set the call interface and, if present, the callback interface
+ JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
+ reference.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+
+ return reference;
+ }
+
+ private class ContextClassLoader extends ClassLoader {
+ public ContextClassLoader(ModelResolver resolver, ProcessorContext context) {
+ super();
+ this.resolver = resolver;
+ this.context = context;
+ }
+
+ private ModelResolver resolver;
+ private ProcessorContext context;
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ return SpringXMLComponentTypeLoader.this.resolveClass(resolver, name, context);
+ }
+
+ @Override
+ protected URL findResource(String name) {
+ try {
+ return resolveLocation(resolver, name, context);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(String name) throws IOException {
+ URL url = findResource(name);
+ if (url != null) {
+ return Collections.enumeration(Arrays.asList(url));
+ } else {
+ Collection<URL> urls = Collections.emptyList();
+ return Collections.enumeration(urls);
+ }
+ }
+ }
+} // end class SpringXMLComponentTypeLoader
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
new file mode 100644
index 0000000000..4b4144f0c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.spring.xml;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
+import org.apache.tuscany.sca.implementation.spring.introspect.SpringXMLComponentTypeLoader;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * SpringArtifactProcessor is responsible for processing the XML of an <implementation.spring.../>
+ * element in an SCA SCDL file.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringImplementationProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<SpringImplementation> {
+
+ private static final String LOCATION = "location";
+ private static final String IMPLEMENTATION_SPRING = "implementation.spring";
+ private static final QName IMPLEMENTATION_SPRING_QNAME = new QName(Constants.SCA11_NS, IMPLEMENTATION_SPRING);
+ private static final String MSG_LOCATION_MISSING = "Reading implementation.spring - location attribute missing";
+
+ private ExtensionPointRegistry registry;
+ private AssemblyFactory assemblyFactory;
+ private PolicySubjectProcessor policyProcessor;
+
+ private FactoryExtensionPoint factories;
+
+ public SpringImplementationProcessor(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ this.factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(registry);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /*
+ * Read the XML and parse out the attributes.
+ *
+ * <implementation.spring.../> has a single required attribute:
+ * "location" - which is the target URI of of an archive file or a directory that contains the Spring
+ * application context files.
+ * If the resource identified by the location attribute is an archive file, then the file
+ * META-INF/MANIFEST.MF is read from the archive.
+ * If the location URI identifies a directory, then META-INF/MANIFEST.MF must exist
+ * underneath that directory.
+ * If the manifest file contains a header "Spring-Context" of the format:
+ * Spring-Context ::= path ( ';' path )*
+ *
+ * Where path is a relative path with respect to the location URI, then the set of paths
+ * specified in the header identify the context configuration files.
+ * If there is no MANIFEST.MF file or no Spring-Context header within that file,
+ * then the default behaviour is to build an application context using all the *.xml files
+ * in the META-INF/spring directory.
+ */
+ public SpringImplementation read(XMLStreamReader reader, ProcessorContext context)
+ throws ContributionReadException, XMLStreamException {
+
+ // Create the Spring implementation
+ SpringImplementation springImplementation = null;
+
+ // Read the location attribute for the spring implementation
+ String springLocation = getURIString(reader, LOCATION);
+ if (springLocation != null) {
+ springImplementation = new SpringImplementation();
+ springImplementation.setLocation(springLocation);
+ springImplementation.setUnresolved(true);
+ processComponentType(springImplementation);
+ } else {
+ error(context.getMonitor(), "LocationAttributeMissing", reader);
+ //throw new ContributionReadException(MSG_LOCATION_MISSING);
+ }
+
+ // Read policies
+ policyProcessor.readPolicies(springImplementation, reader);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_SPRING_QNAME.equals(reader.getName())) {
+ break;
+ }
+ } // end while
+
+ return springImplementation;
+ } // end read
+
+ /*
+ * Handles the component type for the Spring implementation
+ * @param springImplementation - a Spring implementation. The component type information
+ * is created for this implementation
+ *
+ */
+ private void processComponentType(SpringImplementation springImplementation) {
+
+ // Create a ComponentType and mark it unresolved
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setUnresolved(true);
+ springImplementation.setComponentType(componentType);
+ } // end processComponentType
+
+ /*
+ * Write out the XML representation of the Spring implementation
+ * <implementation.spring location="..." />
+ */
+ public void write(SpringImplementation springImplementation, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ // Write <implementation.spring>
+ writer.writeStartElement(Constants.SCA11_NS, IMPLEMENTATION_SPRING);
+ policyProcessor.writePolicyAttributes(springImplementation, writer);
+
+ if (springImplementation.getLocation() != null) {
+ writer.writeAttribute(LOCATION, springImplementation.getLocation());
+ }
+
+ writer.writeEndElement();
+
+ } // end write
+
+ /**
+ * Resolves the Spring implementation - loads the Spring application-context XML and
+ * derives the spring implementation componentType from it
+ */
+ public void resolve(SpringImplementation springImplementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+
+ if (springImplementation == null)
+ return;
+
+ Monitor monitor = context.getMonitor();
+ /* Load the Spring component type by reading the Spring application context */
+ SpringXMLComponentTypeLoader springLoader = new SpringXMLComponentTypeLoader(registry);
+ try {
+ // Load the Spring Implementation information from its application context file...
+ springLoader.load(springImplementation, resolver, context);
+ } catch (ContributionReadException e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(monitor, "ContributionResolveException", resolver, ce);
+ throw ce;
+ }
+
+ ComponentType ct = springImplementation.getComponentType();
+ if (ct.isUnresolved()) {
+ // If the introspection fails to resolve, try to find a side file...
+ ComponentType componentType = resolver.resolveModel(ComponentType.class, ct, context);
+ if (componentType.isUnresolved()) {
+ error(monitor, "UnableToResolveComponentType", resolver);
+ //throw new ContributionResolveException("SpringArtifactProcessor: unable to resolve componentType for Spring component");
+ } else {
+ springImplementation.setComponentType(componentType);
+ springImplementation.setUnresolved(false);
+ }
+
+ } // end if
+
+ } // end method resolve
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_SPRING_QNAME;
+ }
+
+ public Class<SpringImplementation> getModelType() {
+ return SpringImplementation.class;
+ }
+
+} // end class SpringArtifactProcessor
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringXMLBeanDefinitionLoader.java b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringXMLBeanDefinitionLoader.java
new file mode 100644
index 0000000000..a3dc353ffc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringXMLBeanDefinitionLoader.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.spring.xml;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+
+/**
+ * The utility interface to load Spring XML bean definitions into an application context
+ */
+public interface SpringXMLBeanDefinitionLoader {
+ /**
+ * @param resources
+ * @param serviceElements
+ * @param referenceElements
+ * @param propertyElements
+ * @param beanElements
+ * @param context
+ * @return
+ */
+ Object load(List<URL> resources,
+ List<SpringSCAServiceElement> serviceElements,
+ List<SpringSCAReferenceElement> referenceElements,
+ List<SpringSCAPropertyElement> propertyElements,
+ List<SpringBeanElement> beanElements,
+ ProcessorContext context);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
new file mode 100644
index 0000000000..7ea615051e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
@@ -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.implementation.spring.SpringImplementationBuilder;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.spring
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..880d6fade0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.implementation.spring.xml.SpringImplementationProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.spring,model=org.apache.tuscany.sca.implementation.spring.SpringImplementation
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..4a9270d094
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/implementation/spring/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties
new file mode 100644
index 0000000000..28bd31ca11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties
@@ -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.
+#
+#
+LocationAttributeMissing = Reading implementation.spring - location attribute missing
+ContributionResolveException = ContributionResolveException occured due to:
+UnableToResolveComponentType = SpringArtifactProcessor: unable to resolve componentType for Spring component
+ScaServiceNameNotUnique = The value of the @name attribute of an <sca:service/> element MUST be unique amongst the <sca:service/> subelements of the <beans/> element
+ScaReferenceNameNotUnique = The value of the @name attribute of an <sca:reference/> element MUST be unique amongst the <sca:reference/> subelements of the <beans/> element
+ScaPropertyNameNotUnique = The value of the @name attribute of an <sca:property/> element MUST be unique amongst the <sca:property/> subelements of the <beans/> element
+DefaultBeanDoesNotExist = The @default attribute of a <sca:reference/> element MUST have the value of the @name attribute of one of the <bean/> subelements of the <beans/> element.
+TargetBeanDoesNotExist = The @target attribute of a <sca:service/> element MUST have the value of the @name attribute of one of the <bean/> subelements of the <beans/> element.
diff --git a/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml
new file mode 100644
index 0000000000..18e7b1e60a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:implementationType type="sca:implementation.spring" mayProvide="" alwaysProvides=""/>
+
+ </sca:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-client/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-web-client/LICENSE
new file mode 100644
index 0000000000..fa1256bf99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-client/LICENSE
@@ -0,0 +1,241 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+This module includes files under the following license:
+
+Permission to copy, display and distribute the Service Component Architecture Specification and/or
+portions thereof, without modification, in any medium without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the Service Component Architecture Specification, or
+portions thereof, that you make:
+
+1. A link or URL to the Service Component Architecture Specification at this location:
+· http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of the copyright notice as shown in the Service Component Architecture Specification.
+
+BEA, Cape Clear, IBM, Interface21, IONA, Oracle, Primeton, Progress Software, Red Hat, Rogue Wave,
+SAP, Siemens, Software AG., Sun, Sybase, TIBCO (collectively, the "Authors") agree to grant you a
+royalty-free license, under reasonable, non-discriminatory terms and conditions to patents that they deem
+necessary to implement the Service Component Architecture Specification.
+THE Service Component Architecture SPECIFICATION IS PROVIDED "AS IS," AND THE
+AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+REGARDING THIS SPECIFICATION AND THE IMPLEMENTATION OF ITS CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR
+DISTRIBUTION OF THE Service Components Architecture SPECIFICATION.
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-client/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-web-client/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..6690eac03d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-client/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Web Implementation Web Client
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Implementation Web Client
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.web.client
+Bundle-DocURL: http://www.apache.org/
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.implementation.web;version="2.0.0",
+ org.apache.tuscany.sca.implementation.web.runtime;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.directwebremoting;version="2.0.3",
+ org.directwebremoting.create;version="2.0.3",
+ org.directwebremoting.extend;version="2.0.3",
+ org.directwebremoting.servlet;version="2.0.3",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-client/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-web-client/NOTICE
new file mode 100644
index 0000000000..5dba7efd2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-client/NOTICE
@@ -0,0 +1,12 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the Service Component Architecture specification license
+(see the LICENSE file contained in this distribution) with the following copyright
+
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-client/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-web-client/pom.xml
new file mode 100644
index 0000000000..15b1a1b76b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-client/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-web-client</artifactId>
+ <name>Apache Tuscany SCA Web Implementation Client</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.directwebremoting</groupId>
+ <artifactId>dwr</artifactId>
+ <version>2.0.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java b/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
new file mode 100644
index 0000000000..f827c56241
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.client;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+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 DWR binding
+ *
+ * Handles requests for SCA services and references that use <binding.dwr>
+ */
+public class ClientServlet extends DwrServlet {
+ private static final long serialVersionUID = 1L;
+
+ private transient Map<String, RuntimeEndpointReference> serviceRefs;
+// private transient List<String> referenceNames;
+ private transient boolean initialized;
+ private transient Map<String, String> initParams;
+
+ public static final String SCRIPT_PATH = "/org.oasisopen.sca.componentContext.js";
+
+ public ClientServlet() {
+ this.serviceRefs = new HashMap<String, RuntimeEndpointReference>();
+// this.referenceNames = new ArrayList<String>();
+
+ this.initParams = new HashMap<String, String>();
+ // maybe use <binding.dwr> attributes to define the init params
+ initParams.put("activeReverseAjaxEnabled", "true");
+ }
+
+ @Override
+ public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
+ super.service(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>.
+ */
+ private 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 componentContext.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 + SCRIPT_PATH});
+ }
+ });
+ }
+
+ /**
+ * Adds the JavaScript defining SCADomain, its control functions,
+ * and functions for all the available SCA services and references.
+ */
+ private void tuscanyFooter(HttpServletRequest request, PrintWriter out) {
+ out.println("if (SCA == undefined) var SCA = new Object();");
+ out.println("if (SCA.componentContext == undefined) {");
+ out.println(" SCA.componentContext = new Object();");
+ out.println(" SCA.componentContext.serviceNames = [];");
+ out.println(" SCA.componentContext.serviceProxys = [];");
+ out.println(" SCA.componentContext.getService = function(serviceName){");
+ out.println(" var i = SCA.componentContext.serviceNames.indexOf(serviceName);");
+ out.println(" return SCA.componentContext.serviceProxys[i];");
+ out.println(" };");
+ out.println(" if (componentContext == undefined) var componentContext = SCA.componentContext;");
+ out.println("}");
+
+// out.println("/** Apache Tuscany scaDomain.js Footer */");
+// out.println();
+// out.println("function scaDomain() { }");
+// out.println();
+// out.println("// SCA services");
+
+ // Use the DWR remoter to generate the JavaScipt function for each SCA service
+ Remoter remoter = (Remoter)getContainer().getBean(Remoter.class.getName());
+
+
+ for (String serviceName : serviceRefs.keySet()) {
+ String path = request.getServletPath() + "/" + serviceName;
+ String serviceScript = remoter.generateInterfaceScript(serviceName, path);
+ out.println(serviceScript);
+ out.println("SCA.componentContext.serviceNames.push('" + serviceName + "');");
+ out.println("SCA.componentContext.serviceProxys.push(" + serviceName + ");");
+// ServiceHolder s = services.get(serviceName);
+// final Class<?> iface = ((JavaInterface)s.cr.getInterfaceContract().getInterface()).getJavaClass();
+// for (Method m : iface.getMethods()) {
+// out.println("if (" + serviceName + " == null) var " + serviceName + " = {};");
+// out.println("SCA.componentContext.serviceNames.push('" + serviceName + "');");
+//// out.println("SCA.componentContext.serviceProxys.push(new JSONRpcClient('" + serviceName + "').Service);");
+// out.println(serviceName + "." + m.getName() + " = function(p0, callback) {");
+// out.println(" dwr.engine._execute(" + serviceName + "._path, '" + serviceName + "', '" + m.getName() + "', p0, callback);");
+// out.println(" }");
+// }
+ }
+
+// 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 componentContext.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(RuntimeEndpointReference epr) {
+
+ CreatorManager creatorManager = (CreatorManager)getContainer().getBean(CreatorManager.class.getName());
+ addService(creatorManager, epr);
+ serviceRefs.put(epr.getReference().getName(), epr);
+ }
+
+ private void addService(CreatorManager creatorManager, final RuntimeEndpointReference epr) {
+ final Class<?> iface = ((JavaInterface)epr.getComponentTypeReferenceInterfaceContract().getInterface()).getJavaClass();
+
+ creatorManager.addCreator(epr.getReference().getName(), new AbstractCreator() {
+ public Class<?> getType() {
+ return iface;
+ }
+
+ public Object getInstance() throws InstantiationException {
+ ExtensionPointRegistry registry = epr.getCompositeContext().getExtensionPointRegistry();
+ ExtensibleProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+ return proxyFactory.createProxy(iface, epr);
+ }
+ });
+ }
+
+ /**
+ * Patch the ServletConfig to enable setting init params for DWR
+ * and so DWR can't see the Tuscany servlet's init params.
+ */
+ private 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;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java b/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.java
new file mode 100644
index 0000000000..9c95eaea3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/JSClientExtensionPointImpl.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.web.client;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.implementation.web.runtime.ClientExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+public class JSClientExtensionPointImpl implements ClientExtensionPoint {
+
+ private ServletHost servletHost;
+
+ public JSClientExtensionPointImpl(ExtensionPointRegistry extensionPoints) {
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation) {
+ ClientServlet clientServlet = new ClientServlet();
+ servletHost.addServletMapping(ClientServlet.SCRIPT_PATH, clientServlet);
+ servletHost.addServletMapping(ClientServlet.SCRIPT_PATH + "/" + component.getName() + "/*", clientServlet);
+
+ if (component.getReferences().size() > 0) {
+ for (ComponentReference cr : component.getReferences()) {
+ for (EndpointReference epr : cr.getEndpointReferences()) {
+ clientServlet.addService((RuntimeEndpointReference)epr);
+ }
+ }
+ }
+
+ return new ImplementationProvider() {
+ public Invoker createInvoker(RuntimeComponentService arg0, Operation arg1) {
+ return null;
+ }
+ public void start() {
+ }
+ public void stop() {
+ }
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+ };
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.runtime.ClientExtensionPoint b/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.runtime.ClientExtensionPoint
new file mode 100644
index 0000000000..d11c486a4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.runtime.ClientExtensionPoint
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the implementation extension
+org.apache.tuscany.sca.implementation.web.client.JSClientExtensionPointImpl
+
+
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/LICENSE
new file mode 100644
index 0000000000..f602cf9395
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/LICENSE
@@ -0,0 +1,241 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+This module includes files under the following license:
+
+Permission to copy, display and distribute the Service Component Architecture Specification and/or
+portions thereof, without modification, in any medium without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the Service Component Architecture Specification, or
+portions thereof, that you make:
+
+1. A link or URL to the Service Component Architecture Specification at this location:
+· http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of the copyright notice as shown in the Service Component Architecture Specification.
+
+BEA, Cape Clear, IBM, Interface21, IONA, Oracle, Primeton, Progress Software, Red Hat, Rogue Wave,
+SAP, Siemens, Software AG., Sun, Sybase, TIBCO (collectively, the "Authors") agree to grant you a
+royalty-free license, under reasonable, non-discriminatory terms and conditions to patents that they deem
+necessary to implement the Service Component Architecture Specification.
+THE Service Component Architecture SPECIFICATION IS PROVIDED "AS IS," AND THE
+AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+REGARDING THIS SPECIFICATION AND THE IMPLEMENTATION OF ITS CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR
+DISTRIBUTION OF THE Service Components Architecture SPECIFICATION.
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f89ea5b24a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.web.runtime.utils;ver
+ sion="2.0",
+ org.apache.tuscany.sca.implementation.web.runtime;version="2.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Web Implementation Web Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Implementation Web Runtime
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.web.runtime
+Bundle-DocURL: http://www.apache.org/
+Import-Package: javax.servlet,
+ javax.servlet.jsp,
+ javax.servlet.jsp.tagext,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.implementation.web;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/NOTICE
new file mode 100644
index 0000000000..954815cf00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/NOTICE
@@ -0,0 +1,12 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the Service Component Architecture specification license
+(see the LICENSE file contained in this distribution) with the following copyright
+
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/pom.xml
new file mode 100644
index 0000000000..7812f07954
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <name>Apache Tuscany SCA Web Implementation Runtime</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jsp_2.1_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- provided scope doesn't pull in transitive dependencies -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-el_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java
new file mode 100644
index 0000000000..0829cfeca5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ClientExtensionPoint.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web.runtime;
+
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public interface ClientExtensionPoint {
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java
new file mode 100644
index 0000000000..64622ee76c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.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.sca.implementation.web.runtime;
+
+import java.util.Collection;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Proxy ComponentContext wrappering a RuntimeComponent as the
+ * RuntimeComponent ComponentContext has not been created till later
+ */
+public class ComponentContextProxy implements ComponentContext {
+
+ protected RuntimeComponent runtimeComponent;
+
+ public ComponentContextProxy(RuntimeComponent runtimeComponent) {
+ this.runtimeComponent = runtimeComponent;
+ }
+
+ protected ComponentContext getComponentContext() {
+ return runtimeComponent.getComponentContext();
+ }
+
+ public <B> ServiceReference<B> cast(B target) throws IllegalArgumentException {
+ return getComponentContext().cast(target);
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
+ return getComponentContext().createSelfReference(businessInterface);
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) {
+ return getComponentContext().createSelfReference(businessInterface, serviceName);
+ }
+
+ public <B> B getProperty(Class<B> type, String propertyName) {
+ return getComponentContext().getProperty(type, propertyName);
+ }
+
+ public RequestContext getRequestContext() {
+ return getComponentContext().getRequestContext();
+ }
+
+ public <B> B getService(Class<B> businessInterface, String referenceName) {
+ return getComponentContext().getService(businessInterface, referenceName);
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
+ return getComponentContext().getServiceReference(businessInterface, referenceName);
+ }
+
+ public <B> Collection<ServiceReference<B>> getServiceReferences(Class<B> businessInterface, String referenceName) {
+ return getComponentContext().getServiceReferences(businessInterface, referenceName);
+ }
+
+ public <B> Collection<B> getServices(Class<B> businessInterface, String referenceName) {
+ return getComponentContext().getServices(businessInterface, referenceName);
+ }
+
+ public String getURI() {
+ return getComponentContext().getURI();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java
new file mode 100644
index 0000000000..d0323545ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.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.implementation.web.runtime;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public class WebImplementationProviderFactory implements ImplementationProviderFactory<WebImplementation> {
+
+ private ServletHost servletHost;
+ private ClientExtensionPoint jsClient;
+
+ public WebImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ jsClient = extensionPoints.getExtensionPoint(ClientExtensionPoint.class);
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation) {
+ servletHost.setAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent", component);
+ servletHost.setAttribute("org.oasisopen.sca.ComponentContext", new ComponentContextProxy(component));
+
+ ImplementationProvider impl;
+ if (jsClient != null && implementation.getJSClient()) {
+ impl = jsClient.createImplementationProvider(component, implementation);
+ } else {
+ impl = new ImplementationProvider() {
+
+ public Invoker createInvoker(RuntimeComponentService arg0, Operation arg1) {
+ throw new UnsupportedOperationException("Components using implementation.web have no services");
+ }
+ public void start() {
+ }
+ public void stop() {
+ }
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+ };
+ }
+ return impl;
+ }
+
+ public Class<WebImplementation> getModelType() {
+ return WebImplementation.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTEI.java b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTEI.java
new file mode 100644
index 0000000000..2ba7944326
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTEI.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web.runtime.jsp;
+
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.VariableInfo;
+
+/**
+ * TagExtraInfo class for the SCA reference tags
+ * <sca:reference name="service" type="test.MyService" scope="1" />
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTEI extends TagExtraInfo {
+
+ @Override
+ public VariableInfo[] getVariableInfo(TagData data) {
+ VariableInfo info1
+ = new VariableInfo(
+ data.getAttributeString("name"),
+ data.getAttributeString("type"),
+ true,
+ VariableInfo.AT_END);
+ VariableInfo[] info = { info1 } ;
+ return info;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java
new file mode 100644
index 0000000000..b4655e3d95
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.runtime.jsp;
+
+import javax.servlet.ServletContext;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Tag to handle SCA references
+ * <sca:reference name="service" type="test.MyService" scope="1" />
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTag extends TagSupport {
+ private static final long serialVersionUID = 1L;
+
+ protected String name;
+ protected String type;
+ protected Integer scope = PageContext.PAGE_SCOPE;
+
+ @Override
+ public int doStartTag() throws JspException {
+ return SKIP_BODY;
+ }
+
+ @Override
+ public int doEndTag() throws JspException {
+
+ ServletContext servletContext = pageContext.getServletContext();
+ RuntimeComponent component = (RuntimeComponent)servletContext.getAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent");
+ if (component == null) {
+ throw new JspException("No Web component found. Is there an <implementation.web> missing?");
+ }
+
+ Class<?> typeClass;
+ try {
+ typeClass = Class.forName(type, true, Thread.currentThread().getContextClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new JspException("Reference '" + name + "' type class not found: " + type);
+ }
+
+ ServiceReference<?> sr = component.getComponentContext().getServiceReference(typeClass, name);
+ if (sr == null) {
+ throw new JspException("Reference '" + name + "' undefined");
+ }
+
+ pageContext.setAttribute(name, sr.getService(), scope);
+
+ return EVAL_PAGE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getScope() {
+ return scope;
+ }
+
+ public void setScope(Integer scope) {
+ this.scope = scope;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/utils/ContextHelper.java b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/utils/ContextHelper.java
new file mode 100644
index 0000000000..423e906d6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/utils/ContextHelper.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.sca.implementation.web.runtime.utils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.ComponentName;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+public class ContextHelper {
+
+ public static final String COMPONENT_ATTR = "org.apache.tuscany.sca.implementation.web.RuntimeComponent";
+
+ public static ComponentContext getComponentContext(ServletContext sc) {
+ RuntimeComponent rc = (RuntimeComponent)sc.getAttribute(COMPONENT_ATTR);
+ return rc.getComponentContext();
+ }
+
+ public static <T> T getReference(String name, Class<T> type, ServletContext sc) {
+ ServiceReference<T> sr = getComponentContext(sc).getServiceReference(type, name);
+ if (sr == null) {
+ throw new ServiceRuntimeException("Reference '" + name + "' undefined");
+ }
+ return sr.getService();
+ }
+
+ public static Object getProperty(String name, ServletContext sc) {
+ RuntimeComponent rc = (RuntimeComponent)sc.getAttribute(COMPONENT_ATTR);
+ for (ComponentProperty p : rc.getProperties()) {
+ if (name.equals(p.getName())) {
+ return p.getValue();
+ }
+ }
+ return null;
+ }
+
+ public static void inject(Object instance, ServletContext sc) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+
+ Class<?> clazz = instance.getClass();
+ for (Field field : clazz.getDeclaredFields()) {
+ if (field.isAnnotationPresent(Reference.class)) {
+ Reference ref = field.getAnnotation(Reference.class);
+ String name = ref.name() != null && !ref.name().equals("") ? ref.name() : field.getName();
+ Object value = getReference(name, field.getType(), sc);
+ setField(instance, field, value);
+ } else if (field.isAnnotationPresent(Property.class)) {
+ Property prop = field.getAnnotation(Property.class);
+ String name = prop.name() != null && !prop.name().equals("") ? prop.name() : field.getName();
+ Object value = getProperty(name, sc);
+ setField(instance, field, value);
+ } else if (field.isAnnotationPresent(ComponentName.class)) {
+ RuntimeComponent rc = (RuntimeComponent)sc.getAttribute(COMPONENT_ATTR);
+ setField(instance, field, rc.getName());
+ } else if (field.isAnnotationPresent(Context.class)) {
+ setField(instance, field, getComponentContext(sc));
+ }
+ }
+
+ for (Method method : clazz.getDeclaredMethods()) {
+ if (!method.getName().startsWith("set") || method.getParameterTypes().length != 1) {
+ continue;
+ }
+ String targetName = method.getName().substring(3);
+ Class<?> type = method.getParameterTypes()[0];
+
+ if (method.isAnnotationPresent(Reference.class)) {
+ Reference ref = method.getAnnotation(Reference.class);
+ String name = ref.name() != null && !ref.name().equals("") ? ref.name() : targetName;
+ Object value = getReference(name, type, sc);
+ setMethod(instance, method, value);
+ } else if (method.isAnnotationPresent(Property.class)) {
+ Property prop = method.getAnnotation(Property.class);
+ String name = prop.name() != null && !prop.name().equals("") ? prop.name() : targetName;
+ Object value = getProperty(name, sc);
+ setMethod(instance, method, value);
+ } else if (method.isAnnotationPresent(ComponentName.class)) {
+ RuntimeComponent rc = (RuntimeComponent)sc.getAttribute(COMPONENT_ATTR);
+ setMethod(instance, method, rc.getName());
+ } else if (method.isAnnotationPresent(Context.class)) {
+ setMethod(instance, method, getComponentContext(sc));
+ }
+ }
+ }
+
+ private static void setMethod(Object instance, Method method, Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ if (method.isAccessible()) {
+ method.invoke(instance, new Object[] {value});
+ } else {
+ method.setAccessible(true);
+ method.invoke(instance, new Object[] {value});
+ method.setAccessible(false);
+ }
+ }
+
+ private static void setField(Object instance, Field field, Object value) throws IllegalArgumentException, IllegalAccessException {
+ if (field.isAccessible()) {
+ field.set(instance, value);
+ } else {
+ field.setAccessible(true);
+ field.set(instance, value);
+ field.setAccessible(false);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld
new file mode 100644
index 0000000000..8a9ce93204
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld
@@ -0,0 +1,49 @@
+<?xml version = '1.0' encoding = 'ISO-8859-1'?>
+<!--
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
+
+see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ -->
+
+<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
+
+ <tlib-version>1.0</tlib-version>
+ <short-name>SCA-JSP</short-name>
+ <uri>http://www.osoa.org/sca/sca_jsp.tld</uri>
+ <description>A tag library for integrating sca components with jsp</description>
+
+ <tag>
+
+ <name>reference</name>
+
+ <tag-class>org.apache.tuscany.sca.implementation.web.runtime.jsp.ReferenceTag</tag-class>
+ <tei-class>org.apache.tuscany.sca.implementation.web.runtime.jsp.ReferenceTEI</tei-class>
+
+ <attribute>
+ <name>name</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ </attribute>
+
+ <attribute>
+ <name>type</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ </attribute>
+
+ <attribute>
+ <name>scope</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.Integer</type>
+ </attribute>
+
+ <body-content>empty</body-content>
+
+ </tag>
+
+</taglib>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..4e26825cfe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the implementation extension
+org.apache.tuscany.sca.implementation.web.runtime.WebImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.web.WebImplementation;ranking=9876
+
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-web/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/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/sebastien/java/embed/modules/implementation-web/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-web/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..97f6ffb8e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.web;uses:="org.apache.t
+ uscany.sca.assembly";version="2.0.0"
+Private-Package: org.apache.tuscany.sca.implementation.web.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Web Implementation Web Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Implementation Web Model
+Import-Package: javax.xml.stream;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.implementation.web;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.web
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-web/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-web/pom.xml
new file mode 100644
index 0000000000..cb8a4602b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/pom.xml
@@ -0,0 +1,73 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-web</artifactId>
+ <name>Apache Tuscany SCA Web Implementation Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.java
new file mode 100644
index 0000000000..c7613a9045
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.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.sca.implementation.web;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+
+
+
+/**
+ * The model representing an Web implementation in an SCA assembly model.
+ */
+public interface WebImplementation extends Implementation {
+ QName TYPE = new QName(SCA11_NS, "implementation.web");
+
+ /**
+ * Returns the webapp URI.
+ * @return the webapp URI
+ */
+ String getWebURI();
+
+ /**
+ * Sets the Webapp URI.
+ * @param uri the webapp URI
+ */
+ void setWebURI(String webappURI);
+
+ boolean getJSClient();
+ void setJSClient(boolean jsCLient);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementationFactory.java b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementationFactory.java
new file mode 100644
index 0000000000..df2e6c5520
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementationFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web;
+
+
+/**
+ * Factory for the Web implementation model.
+ */
+public interface WebImplementationFactory {
+
+ /**
+ * Creates a new Web implementation.
+ * @return a new Web implementation
+ */
+ WebImplementation createWebImplementation();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java
new file mode 100644
index 0000000000..41adb73f61
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder;
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+
+/**
+ *
+ */
+public class WebImplementationBuilder implements ImplementationBuilder<WebImplementation> {
+
+ public void build(Component component, WebImplementation implmentation, BuilderContext context) {
+ ((WebImplementationImpl)implmentation).build(component);
+
+ }
+
+ public QName getImplementationType() {
+ return WebImplementation.TYPE;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationFactoryImpl.java b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationFactoryImpl.java
new file mode 100644
index 0000000000..daff2d23a1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationFactoryImpl.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.sca.implementation.web.impl;
+
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.implementation.web.WebImplementationFactory;
+
+/**
+ * Factory for the Web implementation model.
+ */
+public class WebImplementationFactoryImpl implements WebImplementationFactory {
+
+ public WebImplementationFactoryImpl() {
+ }
+
+ public WebImplementation createWebImplementation() {
+ return new WebImplementationImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
new file mode 100644
index 0000000000..bdf9c81909
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+
+/**
+ * The model representing an Web implementation in an SCA assembly model.
+ */
+class WebImplementationImpl extends ImplementationImpl implements WebImplementation {
+
+ private List<Property> properties = new ArrayList<Property>();
+ private List<Reference> references = new ArrayList<Reference>();
+
+ private String webURI;
+ private boolean jsClient = true;
+
+ /**
+ * Constructs a new Web implementation.
+ */
+ WebImplementationImpl() {
+ super(TYPE);
+ }
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ public List<Service> getServices() {
+ // The Web implementation does not offer services
+ return Collections.emptyList();
+ }
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public String getWebURI() {
+ return webURI;
+ }
+
+ public void setWebURI(String webURI) {
+ this.webURI = webURI;
+ }
+
+ /**
+ * Use preProcess to add any references and properties dynamically
+ * TODO: also support introspection and handle WEB-INF/web.componentType (spec line 503)
+ */
+ public void build(Component component) {
+ if (!(component instanceof RuntimeComponent)) {
+ return;
+ }
+ RuntimeComponent rtc = (RuntimeComponent) component;
+
+ for (Reference reference : rtc.getReferences()) {
+ if (getReference(reference.getName()) == null) {
+ getReferences().add(createReference(reference));
+ }
+ }
+
+ for (Property property : rtc.getProperties()) {
+ if (getProperty(property.getName()) == null) {
+ getProperties().add(createProperty(property));
+ }
+ }
+ }
+
+
+ protected Reference createReference(Reference reference) {
+ Reference newReference;
+ try {
+ newReference = (Reference)reference.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e); // should not ever happen
+ }
+ return newReference;
+ }
+
+
+ protected Property createProperty(Property property) {
+ Property newProperty;
+ try {
+ newProperty = (Property)property.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e); // should not ever happen
+ }
+ return newProperty;
+ }
+
+ public boolean getJSClient() {
+ return jsClient;
+ }
+
+ public void setJSClient(boolean jsClient) {
+ this.jsClient = jsClient;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((webURI == null) ? 0 : webURI.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (!(obj instanceof WebImplementationImpl)) {
+ return false;
+ }
+ WebImplementationImpl other = (WebImplementationImpl)obj;
+ if (webURI == null) {
+ if (other.webURI != null) {
+ return false;
+ }
+ } else if (!webURI.equals(other.webURI)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.java
new file mode 100644
index 0000000000..afcc85b58f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.xml;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.implementation.web.WebImplementationFactory;
+import org.apache.tuscany.sca.implementation.web.impl.WebImplementationFactoryImpl;
+
+/**
+ * Implements a StAX artifact processor for Web implementations.
+ */
+public class WebImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WebImplementation> {
+ private static final QName IMPLEMENTATION_WEB = new QName(Constants.SCA11_NS, "implementation.web");
+
+ private AssemblyFactory assemblyFactory;
+ private WebImplementationFactory implementationFactory;
+
+ public WebImplementationProcessor(ExtensionPointRegistry extensionPoints) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.implementationFactory = new WebImplementationFactoryImpl();
+ }
+
+ public QName getArtifactType() {
+ // Returns the QName of the XML element processed by this processor
+ return IMPLEMENTATION_WEB;
+ }
+
+ public Class<WebImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return WebImplementation.class;
+ }
+
+ public WebImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ // Read an <implementation.web> element
+ WebImplementation implementation = implementationFactory.createWebImplementation();
+ implementation.setUnresolved(true);
+
+ // Read the webapp uri attribute
+ String webURI = getString(reader, "web-uri");
+ if (webURI != null) {
+ implementation.setWebURI(webURI);
+
+ // Set the URI of the component type
+ implementation.setURI(webURI);
+ }
+
+ String jsClient = reader.getAttributeValue(Constants.SCA11_TUSCANY_NS, "jsClient");
+ if (jsClient != null) {
+ implementation.setJSClient(Boolean.parseBoolean(jsClient));
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_WEB.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return implementation;
+ }
+
+ public void resolve(WebImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ // Resolve the component type
+ String uri = implementation.getURI();
+ if (uri != null) {
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setURI("web.componentType");
+ componentType = resolver.resolveModel(ComponentType.class, componentType, context);
+ if (!componentType.isUnresolved()) {
+
+ // Initialize the implementation's services, references and properties
+ implementation.getServices().addAll(componentType.getServices());
+ implementation.getReferences().addAll(componentType.getReferences());
+ implementation.getProperties().addAll(componentType.getProperties());
+ }
+ }
+ implementation.setUnresolved(false);
+ }
+
+ public void write(WebImplementation implementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write <implementation.web>
+ writeStart(writer, IMPLEMENTATION_WEB.getNamespaceURI(), IMPLEMENTATION_WEB.getLocalPart(),
+ new XAttr("web-uri", implementation.getWebURI()));
+
+ writeEnd(writer);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
new file mode 100644
index 0000000000..7e306cb9a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
@@ -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.implementation.web.impl.WebImplementationBuilder;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.web
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..89ef50ba58
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.implementation.web.xml.WebImplementationProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.web,model=org.apache.tuscany.sca.implementation.web.WebImplementation,factory=org.apache.tuscany.sca.implementation.web.WebImplementationFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.WebImplementationFactory b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.WebImplementationFactory
new file mode 100644
index 0000000000..0487da71b1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.WebImplementationFactory
@@ -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 model factory
+org.apache.tuscany.sca.implementation.web.impl.WebImplementationFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/ReadTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/ReadTestCase.java
new file mode 100644
index 0000000000..d9460194e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/ReadTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.xml;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+
+/**
+ * Test reading Web implementations.
+ */
+public class ReadTestCase extends TestCase {
+
+ private XMLInputFactory inputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ @Override
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestWeb.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite) staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ assertTrue(((WebImplementation) composite.getComponents().get(0).getImplementation()).getWebURI().equals("MyWebapp"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/WriteTestCase.java b/sandbox/sebastien/java/embed/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/WriteTestCase.java
new file mode 100644
index 0000000000..ebad994033
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/WriteTestCase.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.xml;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+
+/**
+ * Test reading/write Web implementations.
+ */
+public class WriteTestCase extends TestCase {
+
+ private XMLInputFactory inputFactory;
+ private XMLOutputFactory outputFactory;
+ private StAXArtifactProcessor<Object> staxProcessor;
+ private ProcessorContext context;
+
+ @Override
+ public void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("TestWeb.composite");
+ Composite composite = (Composite) staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(composite);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+
+ assertTrue(bos.toString().contains("web-uri=\"MyWebapp\""));
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-web/src/test/resources/org/apache/tuscany/sca/implementation/web/xml/TestWeb.composite b/sandbox/sebastien/java/embed/modules/implementation-web/src/test/resources/org/apache/tuscany/sca/implementation/web/xml/TestWeb.composite
new file mode 100644
index 0000000000..1c5a439654
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-web/src/test/resources/org/apache/tuscany/sca/implementation/web/xml/TestWeb.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample/web"
+ xmlns:sc="http://sample/composite"
+ name="TestWeb">
+
+ <component name="TestWeb">
+ <implementation.web web-uri="MyWebapp"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/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/sebastien/java/embed/modules/implementation-widget-runtime-dojo/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c55ce4de46
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Widget Implementation Runtime (Dojo)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Widget Implementation Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream;version="1.0",
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.widget.runtime.dojo
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/pom.xml
new file mode 100644
index 0000000000..19b8803158
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/pom.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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-widget-runtime-dojo</artifactId>
+ <name>Apache Tuscany SCA Widget Implementation Runtime (Dojo)</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-widget-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-web-javascript-dojo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java
new file mode 100644
index 0000000000..d9e4e698e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java
@@ -0,0 +1,267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.widget.dojo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator;
+import org.apache.tuscany.sca.web.javascript.JavascriptProxyFactory;
+import org.apache.tuscany.sca.web.javascript.JavascriptProxyFactoryExtensionPoint;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class DojoJavaScriptComponentGeneratorImpl implements ComponentJavaScriptGenerator {
+ private static final QName NAME = new QName("http://tuscany.apache.org/xmlns/sca/1.1", "component.script.generator.dojo");
+
+ private ExtensionPointRegistry extensionPoints;
+
+ private JavascriptProxyFactoryExtensionPoint javascriptProxyFactories;
+
+ public DojoJavaScriptComponentGeneratorImpl(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ this.javascriptProxyFactories = extensionPoints.getExtensionPoint(JavascriptProxyFactoryExtensionPoint.class);
+ }
+
+ public QName getQName() {
+ return NAME;
+ }
+
+ public void generateJavaScriptCode(RuntimeComponent component, PrintWriter pw) throws IOException {
+ pw.println();
+ pw.println("/* Apache Tuscany SCA Widget header */");
+ pw.println();
+
+ Map<String, Boolean> bindingClientProcessed = new HashMap<String, Boolean>();
+
+ for(ComponentReference reference : component.getReferences()) {
+ for(EndpointReference epr : reference.getEndpointReferences()) {
+ Endpoint targetEndpoint = epr.getTargetEndpoint();
+ if (targetEndpoint.isUnresolved()) {
+ //force resolution and targetEndpoint binding calculations
+ //by calling the getInvocationChain
+ ((RuntimeEndpointReference) epr).getInvocationChains();
+ targetEndpoint = epr.getTargetEndpoint();
+ }
+
+ Binding binding = targetEndpoint.getBinding();
+ if (binding != null) {
+ JavascriptProxyFactory jsProxyFactory = javascriptProxyFactories.getProxyFactory(binding.getClass());
+
+ String bindingProxyName = jsProxyFactory.getJavascriptProxyFile();
+ //check if binding client code was already processed and inject to the generated script
+ if(bindingProxyName != null) {
+ Boolean processedFlag = bindingClientProcessed.get(bindingProxyName);
+ if( processedFlag == null || processedFlag.booleanValue() == false) {
+ generateJavaScriptBindingProxy(jsProxyFactory, pw);
+ bindingClientProcessed.put(bindingProxyName, Boolean.TRUE);
+ }
+ }
+ }
+ }
+ }
+
+ pw.println();
+ pw.println("/* Tuscany Reference/Property injection code */");
+ pw.println();
+
+ generateJavaScriptHeader(component, javascriptProxyFactories,pw);
+
+ pw.println();
+
+ //define tuscany.sca namespace
+ generateJavaScriptNamespace(pw);
+
+ pw.println();
+
+ //process properties
+ generateJavaScriptPropertyFunction(component, pw);
+
+ pw.println();
+
+ //process references
+ generateJavaScriptReferenceFunction(component, javascriptProxyFactories,pw);
+
+
+ pw.println();
+ pw.println("/** End of Apache Tuscany SCA Widget */");
+ pw.println();
+ pw.flush();
+ pw.close();
+ }
+
+
+ /**
+ * Retrieve the binding proxy based on the bind name
+ * and embedded the JavaScript into this js
+ */
+ private static void generateJavaScriptBindingProxy(JavascriptProxyFactory javascriptProxyFactory, PrintWriter pw) throws IOException {
+ InputStream is = javascriptProxyFactory.getJavascriptProxyFileAsStream();
+ if (is != null) {
+ int i;
+ while ((i = is.read()) != -1) {
+ pw.write(i);
+ }
+ }
+
+ pw.println();
+ pw.println();
+ }
+
+ /**
+ *
+ * @param pw
+ * @throws IOException
+ */
+ private static void generateJavaScriptHeader(RuntimeComponent component, JavascriptProxyFactoryExtensionPoint javascriptProxyFactories, PrintWriter pw) throws IOException {
+ Map<String, Boolean> bindingHeaderProcessed = new HashMap<String, Boolean>();
+
+ for(ComponentReference reference : component.getReferences()) {
+ for(EndpointReference epr : reference.getEndpointReferences()) {
+ Endpoint targetEndpoint = epr.getTargetEndpoint();
+ if (targetEndpoint.isUnresolved()) {
+ //force resolution and targetEndpoint binding calculations
+ //by calling the getInvocationChain
+ ((RuntimeEndpointReference) epr).getInvocationChains();
+ targetEndpoint = epr.getTargetEndpoint();
+ }
+
+ Binding binding = targetEndpoint.getBinding();
+ if (binding != null) {
+ JavascriptProxyFactory jsProxyFactory = javascriptProxyFactories.getProxyFactory(binding.getClass());
+
+ String bindingKey = binding.getClass().getName();
+ Boolean processedFlag = bindingHeaderProcessed.get(bindingKey);
+
+ //check if binding client code was already processed and inject to the generated script
+ if( processedFlag == null || processedFlag.booleanValue() == false) {
+ pw.println(jsProxyFactory.createJavascriptHeader(reference));
+ bindingHeaderProcessed.put(bindingKey, Boolean.TRUE);
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Generate the tuscany.sca namespace if not yet available
+ * @param pw
+ * @throws IOException
+ */
+ private static void generateJavaScriptNamespace(PrintWriter pw) throws IOException {
+ pw.println("if (!window.tuscany) { \n" +
+ "window.tuscany = {}; \n" +
+ "}");
+ pw.println("var __tuscany = window.tuscany;");
+
+ pw.println("if (!__tuscany.sca) { \n" +
+ "__tuscany.sca = {}; \n" +
+ "}");
+ }
+
+
+ /**
+ * Generate JavaScript code to inject SCA Properties
+ * @param pw
+ * @throws IOException
+ */
+ private static void generateJavaScriptPropertyFunction(RuntimeComponent component, PrintWriter pw) throws IOException {
+ pw.println("__tuscany.sca.propertyMap = {};");
+ for(ComponentProperty property : component.getProperties()) {
+ String propertyName = property.getName();
+
+ pw.println("__tuscany.sca.propertyMap." + propertyName + " = new String(\"" + getPropertyValue(property) + "\");");
+ }
+
+ pw.println("tuscany.sca.Property = function (name) {");
+ pw.println(" return __tuscany.sca.propertyMap[name];");
+ pw.println("}");
+ }
+
+ /**
+ * Convert property value to String
+ * @param property
+ * @return
+ */
+ private static String getPropertyValue(ComponentProperty property) {
+ Document doc = (Document)property.getValue();
+ Element rootElement = doc.getDocumentElement();
+
+ String value = null;
+
+ //FIXME : Provide support for isMany and other property types
+
+ if (rootElement.getChildNodes().getLength() > 0) {
+ value = rootElement.getChildNodes().item(0).getTextContent();
+ }
+
+ return value;
+ }
+
+
+
+ /**
+ * Generate JavaScript code to inject SCA References
+ * @param pw
+ * @throws IOException
+ */
+ private static void generateJavaScriptReferenceFunction (RuntimeComponent component, JavascriptProxyFactoryExtensionPoint javascriptProxyFactories, PrintWriter pw) throws IOException {
+
+ pw.println("__tuscany.sca.referenceMap = {};");
+ for(ComponentReference reference : component.getReferences()) {
+ for(EndpointReference epr : reference.getEndpointReferences()) {
+ Endpoint targetEndpoint = epr.getTargetEndpoint();
+ if (targetEndpoint.isUnresolved()) {
+ //force resolution and targetEndpoint binding calculations
+ //by calling the getInvocationChain
+ ((RuntimeEndpointReference) epr).getInvocationChains();
+ targetEndpoint = epr.getTargetEndpoint();
+ }
+
+ Binding binding = targetEndpoint.getBinding();
+ if (binding != null) {
+ String referenceName = reference.getName();
+ JavascriptProxyFactory jsProxyFactory = javascriptProxyFactories.getProxyFactory(binding.getClass());
+
+ pw.println("__tuscany.sca.referenceMap." + referenceName + " = new " + jsProxyFactory.createJavascriptReference(reference) + ";");
+ }
+ }
+ }
+
+ pw.println("tuscany.sca.Reference = function (name) {");
+ pw.println(" return __tuscany.sca.referenceMap[name];");
+ pw.println("}");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator
new file mode 100644
index 0000000000..3f503c24ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator
@@ -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 Javascript Generator
+org.apache.tuscany.sca.implementation.widget.dojo.DojoJavaScriptComponentGeneratorImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/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/sebastien/java/embed/modules/implementation-widget-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..fd792c336f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.widget.provider;
+ uses:="org.apache.tuscany.sca.runtime,org.apache.tuscany.sca.assembly
+ ,org.apache.tuscany.sca.web.javascript,org.w3c.dom,javax.servlet,java
+ x.servlet.http,org.apache.tuscany.sca.invocation,org.apache.tuscany.s
+ ca.provider,org.apache.tuscany.sca.interfacedef,org.apache.tuscany.sc
+ a.implementation.widget,org.apache.tuscany.sca.host.http,org.apache.t
+ uscany.sca.core";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Widget Implementation Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Widget Implementation Runtime
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.implementation.widget;version="2.0.0",
+ org.apache.tuscany.sca.implementation.widget.javascript;version="2.0.0",
+ org.apache.tuscany.sca.implementation.widget.provider;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.web.javascript;version="2.0.0",
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.widget.runt
+ ime
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/pom.xml
new file mode 100644
index 0000000000..4e22897a69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/pom.xml
@@ -0,0 +1,71 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-widget-runtime</artifactId>
+ <name>Apache Tuscany SCA Widget Implementation Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-widget</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-web-javascript</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version> <!-- to keep compatible with older servlet containers -->
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.java b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.java
new file mode 100644
index 0000000000..a28e014b2e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.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.widget.provider;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator;
+
+
+/**
+ * Servlet to handle requests for the widget component .js script.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WidgetComponentScriptServlet extends HttpServlet {
+ private static final long serialVersionUID = 2454705532282398190L;
+
+ private transient ComponentJavaScriptGenerator javaScriptgenerator;
+ private transient RuntimeComponent component;
+
+
+ /**
+ * Constructor receiving the runtimeComponent reference that is going to be used to generate the widget client js
+ * @param component
+ */
+ public WidgetComponentScriptServlet(RuntimeComponent component, ComponentJavaScriptGenerator javaScriptgenerator) {
+ this.component = component;
+ this.javaScriptgenerator = javaScriptgenerator;
+ }
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ ServletOutputStream os = response.getOutputStream();
+ PrintWriter pw = new PrintWriter(os);
+
+ javaScriptgenerator.generateJavaScriptCode(component, pw);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java
new file mode 100644
index 0000000000..28a1f6d1db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.widget.provider;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator;
+
+
+/**
+ * Implements an invoker for resource component implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+class WidgetImplementationInvoker implements Invoker {
+ private RuntimeComponent component;
+ private ComponentJavaScriptGenerator javaScriptGenerator;
+ private String widgetName;
+ private String widgetFolderURL;
+ private String widgetLocationURL;
+
+ WidgetImplementationInvoker(RuntimeComponent component, ComponentJavaScriptGenerator javaScriptGenerator, String widgetName, String widgetFolderURL, String widgetLocationURL) {
+ this.component = component;
+ this.javaScriptGenerator = javaScriptGenerator;
+ this.widgetName = widgetName + ".js";
+ this.widgetFolderURL = widgetFolderURL;
+ this.widgetLocationURL = widgetLocationURL;
+ }
+
+ public Message invoke(Message msg) {
+
+ // Get the resource id from the request message
+ String id = (String)((Object[])msg.getBody())[0];
+ try {
+
+ if (id.length() == 0) {
+
+ // Return an input stream for the widget resource
+ URL url = new URL(widgetLocationURL);
+ InputStream is = url.openStream();
+ msg.setBody(is);
+
+ } else if (id.equals(widgetName)) {
+
+ // Generate JavaScript header for use in the Widget
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(bos);
+
+ javaScriptGenerator.generateJavaScriptCode(component, pw);
+
+ InputStream is = new ByteArrayInputStream(bos.toByteArray());
+
+ msg.setBody(is);
+
+ } else {
+
+ // Return an input stream for a resource inside the
+ // widget folder
+ URL url = new URL(widgetFolderURL +'/' + id);
+ InputStream is = url.openStream();
+ msg.setBody(is);
+ }
+ } catch (MalformedURLException e) {
+
+ // Report exception as a fault
+ msg.setFaultBody(e);
+
+ } catch (IOException e) {
+
+ // Report exception as a fault
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
new file mode 100644
index 0000000000..28f041b919
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.widget.provider;
+
+import java.net.URI;
+
+import javax.servlet.Servlet;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
+import org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator;
+
+
+/**
+ * The model representing a resource implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+class WidgetImplementationProvider implements ImplementationProvider {
+ private static final QName BINDING_HTTP = new QName(Base.SCA11_TUSCANY_NS, "binding.http");
+
+ private RuntimeComponent component;
+
+ private WidgetImplementationJavascriptProvider javascriptProvider;
+ private ComponentJavaScriptGenerator javaScriptGenerator;
+ private ServletHost servletHost;
+
+ private String widgetLocationURL;
+ private String widgetFolderURL;
+ private String widgetName;
+
+ private String scriptURI;
+
+ /**
+ * Constructs a new resource implementation provider.
+ */
+ WidgetImplementationProvider(RuntimeComponent component,
+ WidgetImplementation implementation,
+ WidgetImplementationJavascriptProvider javascriptProvider,
+ ComponentJavaScriptGenerator javaScriptGenerator,
+ ServletHost servletHost) {
+
+ this.component = component;
+
+ this.javaScriptGenerator = javaScriptGenerator;
+ this.servletHost = servletHost;
+
+ widgetLocationURL = implementation.getLocationURL().toString();
+ int s = widgetLocationURL.lastIndexOf('/');
+ widgetFolderURL = widgetLocationURL.substring(0, s);
+ widgetName = widgetLocationURL.substring(s +1);
+ widgetName = widgetName.substring(0, widgetName.lastIndexOf('.'));
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ WidgetImplementationInvoker invoker = new WidgetImplementationInvoker(component, javaScriptGenerator, widgetName, widgetFolderURL, widgetLocationURL);
+ return invoker;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ String baseURI = getBaseURI();
+
+ // this uses removeServletMapping / addServletMapping as there is no getServletMapping facility
+ scriptURI = URI.create(baseURI + "/" + this.widgetName + ".js").toString();
+ Servlet servlet = servletHost.getServletMapping(scriptURI);
+ if (servlet == null /*|| servlet instanceof HTTPGetListenerServlet*/) {
+ WidgetComponentScriptServlet widgetScriptServlet;
+ widgetScriptServlet = new WidgetComponentScriptServlet(this.component, javaScriptGenerator);
+ servletHost.addServletMapping(scriptURI, widgetScriptServlet);
+ }
+
+ // If added to the class path, start dojo provider
+ if(javascriptProvider != null) {
+ javascriptProvider.start();
+ }
+
+ }
+
+ public void stop() {
+ // Unregister the component client script Servlet
+ WidgetComponentScriptServlet widgetScriptServlet = (WidgetComponentScriptServlet) servletHost.getServletMapping(scriptURI);
+ if (widgetScriptServlet != null) {
+ // Remove the Servlet mapping
+ servletHost.removeServletMapping(scriptURI);
+ }
+
+ if(javascriptProvider != null) {
+ javascriptProvider.stop();
+ }
+ }
+
+
+ /**
+ * Get the contextRoot considering the HTTP Binding URI when in a embedded environment
+ * @return
+ */
+ private String getBaseURI() {
+ String baseURI = null;
+ String contextPath = "/";
+ if (servletHost != null) {
+ contextPath = servletHost.getContextPath();
+ }
+ if (!contextPath.endsWith("/")) {
+ contextPath = contextPath + "/";
+ }
+
+ ComponentService service = component.getService("Widget");
+ if (service != null) {
+ for (Binding binding : service.getBindings()) {
+ if (binding.getType().equals(BINDING_HTTP)) {
+ String bindingURI = binding.getURI();
+ URI uri = URI.create(bindingURI);
+ if (uri.isAbsolute()) {
+ return bindingURI;
+ }
+ if (bindingURI.startsWith("/")) {
+ bindingURI = bindingURI.substring(1);
+ }
+ baseURI = contextPath + bindingURI;
+ }
+ }
+ }
+
+ return baseURI == null ? "" : baseURI;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java
new file mode 100644
index 0000000000..9c140f0913
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.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.sca.implementation.widget.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
+import org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator;
+import org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGeneratorExtensionPoint;
+
+/**
+ * The model representing a resource implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WidgetImplementationProviderFactory implements ImplementationProviderFactory<WidgetImplementation> {
+ private ServletHost servletHost;
+
+ private WidgetImplementationJavascriptProvider javascriptProvider;
+ private ComponentJavaScriptGenerator javascriptGenerator;
+
+ /**
+ * Constructs a resource implementation.
+ */
+ public WidgetImplementationProviderFactory(ExtensionPointRegistry registry) {
+ this.servletHost = ServletHostHelper.getServletHost(registry);
+
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ javascriptProvider = utilities.getUtility(WidgetImplementationJavascriptProvider.class);
+
+ ComponentJavaScriptGeneratorExtensionPoint javascriptGeneratorExtensionPoint = registry.getExtensionPoint(ComponentJavaScriptGeneratorExtensionPoint.class);
+ javascriptGenerator = javascriptGeneratorExtensionPoint.getComponentJavaScriptGenerators().get(0);
+
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, WidgetImplementation implementation) {
+ return new WidgetImplementationProvider(component, implementation, javascriptProvider, javascriptGenerator, servletHost);
+ }
+
+ public Class<WidgetImplementation> getModelType() {
+ return WidgetImplementation.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..d0f73cbdbb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 implementation extension
+org.apache.tuscany.sca.implementation.widget.provider.WidgetImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.widget.WidgetImplementation
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/atomModel.js b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/atomModel.js
new file mode 100644
index 0000000000..c64c3fc97c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/atomModel.js
@@ -0,0 +1,1590 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Class that defines a URI represented as a string,
+ */
+function Uri( value ) {
+ this.value = value;
+ this.getValue = function() {
+ return this.value;
+ };
+
+ this.setValue = function(value) {
+ this.value = value;
+ };
+
+ this.toString = function() {
+ return "Uri value=" + this.value;
+ };
+
+ /**
+ * Serialize this element to XML.
+ * atomUri = text
+ */
+ this.toXML = function() {
+ xml = "<uri>";
+ xml += this.value;
+ xml += "</uri>\n";
+ return xml;
+ };
+}
+
+/* Updated is Date */
+/* Published is Date */
+
+/**
+ * Class that defines an Email represented as a string,
+ */
+function Email( value ) {
+ this.value = value;
+ this.getValue = function() {
+ return this.value;
+ };
+
+ this.setValue = function(value) {
+ this.value = value;
+ };
+
+ this.toString = function() {
+ return "Email value=" + this.value;
+ };
+
+ /**
+ * Serialize this element to XML.
+ * atomEmailAddress = xsd:string { pattern = ".+@.+" }
+ */
+ this.toXML = function() {
+ xml = "<email>";
+ xml += this.value;
+ xml += "</email>\n";
+ return xml;
+ };
+}
+
+/**
+ * Class that defines an Id represented as a string,
+ */
+function Id( value ) {
+ this.value = value;
+ this.getValue = function() {
+ return this.value;
+ };
+
+ this.setValue = function(value) {
+ this.value = value;
+ };
+
+ this.toString = function() {
+ return "Id value=" + this.value;
+ };
+
+ /**
+ * Serialize this element to XML.
+ * atomId = element atom:id {
+ * atomCommonAttributes,
+ * (atomUri)
+ * }
+ */
+ this.toXML = function() {
+ xml = "<id";
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri + "\"";
+ }
+ if ( this.lang != null ) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ xml += ">";
+ xml += this.value;
+ xml += "</id>\n";
+ return xml;
+ };
+}
+
+
+/**
+ * Class that defines an Id represented as a string,
+ */
+function Logo( value ) {
+ this.value = value;
+ this.getValue = function() {
+ return this.value;
+ };
+
+ this.setValue = function(value) {
+ this.value = value;
+ };
+
+
+ this.toString = function() {
+ return "Logo value=" + this.value;
+ };
+
+ /**
+ * Serialize this element to XML.
+ * atomLogo = element atom:logo {
+ * atomCommonAttributes,
+ * (atomUri)
+ * }
+ */
+ this.toXML = function() {
+ xml = "<logo";
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri + "\"";
+ }
+ if ( this.lang != null ) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ xml += ">";
+ xml += this.value;
+ xml += "</logo>\n";
+ return xml;
+ };
+}
+
+/**
+ * Class that defines a Text object.
+ */
+function Text( content, /* optional */ type ) {
+ this.content = content;
+ this.type = type;
+ if (type == null) this.type = "text"; // If undefined or null, use text
+
+ this.setText = function(content) {
+ this.content = content;
+ };
+
+ this.getText = function() {
+ return this.content;
+ };
+
+ this.getValue = function() {
+ return this.content;
+ };
+
+ this.setType = function(type) {
+ if ((type != "text") && (type != "html") && (type != "xhtml")) {
+ error( "Text type must be one of text, html, or xhtml" );
+ }
+ this.type = type;
+ };
+
+ this.getType = function() {
+ return this.type;
+ };
+
+ this.setLang = function(lang) {
+ this.lang = lang;
+ };
+
+ this.getLang = function() {
+ return this.lang;
+ };
+
+ this.setUri = function(uri) {
+ this.uri = new Uri( uri );
+ };
+
+ this.getUri = function() {
+ return this.uri;
+ };
+
+ this.toString = function() {
+ return "Text type=" + this.type + ", content=" + this.content;
+ };
+
+ /** Serialize this text element to XML.
+ * atomPlainTextConstruct =
+ * atomCommonAttributes,
+ * attribute type { "text" | "html" }?,
+ * text
+ *
+ * atomXHTMLTextConstruct =
+ * atomCommonAttributes,
+ * attribute type { "xhtml" },
+ * xhtmlDiv
+ *
+ * atomTextConstruct = atomPlainTextConstruct | atomXHTMLTextConstruct
+ */
+ this.toXML = function( elementName ) {
+ if ( elementName == null ) {
+ elementName = "text";
+ }
+ xml = "<" + elementName;
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri + "\"";
+ }
+ if ( this.lang != null ) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ xml += " type=\"" + this.type + "\"";
+ xml += ">";
+ if ( this.type === "xhtml" ) {
+ xml += "<div xmlns=\"http://www.w3.org/1999/xhtml\">";
+ }
+ xml += this.content;
+ if ( this.type === "xhtml" ) {
+ xml += "</div>";
+ }
+ xml += "</" + elementName + ">";
+ return xml;
+ }
+}
+
+/**
+ * Class that defines a Person object.
+ */
+function Person( name, email ) {
+ this.name = name;
+ if ( email != null ) {
+ this.email = new Email( email );
+ }
+
+ this.setName = function( name ) {
+ this.name = name;
+ };
+
+ this.getName = function() {
+ return this.name;
+ };
+
+ this.setLang = function(lang) {
+ this.lang = lang;
+ };
+
+ this.getLang = function() {
+ return this.lang;
+ };
+
+ this.setEmail = function( email ) {
+ this.email = new Email( email );
+ };
+
+ this.getEmail = function() {
+ return this.email;
+ };
+
+ this.setUri = function( uri ) {
+ this.uri = new Uri( uri );
+ };
+
+ this.getUri = function() {
+ return this.uri;
+ };
+
+ this.toString = function() {
+ return "Person name=" + this.name + ", email=" + this.email;
+ };
+
+ /** Serialize this text element to XML.
+ * atomPersonConstruct =
+ * atomCommonAttributes,
+ * (element atom:name { text }
+ * & element atom:uri { atomUri }?
+ * & element atom:email { atomEmailAddress }?
+ * & extensionElement*)
+ */
+ this.toXML = function( elementName ) {
+ if ( elementName == null ) {
+ elementName = "person";
+ }
+ xml = "<" + elementName;
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri + "\"";
+ }
+ if ( this.lang != null ) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ xml += ">\n";
+ if ( this.name != null ) {
+ xml += "<name>" + this.name + "</name>\n";
+ }
+ if ( this.uri != null ) {
+ xml += "<uri>" + this.uri + "</uri>\n";
+ }
+ if ( this.email != null) {
+ xml += this.email.toXML();
+ }
+ xml += "</" + elementName + ">\n";
+ return xml;
+ }
+ }
+
+/**
+ * Class that defines a Generator object.
+ */
+function Generator( name, uri ) {
+ this.name = name;
+ this.uri = new Uri( uri );
+
+ this.setName = function( name ) {
+ this.name = name;
+ };
+
+ this.getName = function() {
+ return this.name;
+ };
+
+ this.setVersion = function(version) {
+ this.version = version;
+ };
+
+ this.getVersion = function() {
+ return this.version;
+ };
+
+ this.setUri = function( uri ) {
+ this.uri = new Email( uri );
+ };
+
+ this.getUri = function() {
+ return this.uri;
+ };
+
+ this.toString = function() {
+ return "Generator name=" + this.name + ", email=" + this.email;
+ };
+
+ /** Serialize this text element to XML.
+ * atomGenerator = element atom:generator {
+ * atomCommonAttributes,
+ * attribute uri { atomUri }?,
+ * attribute version { text }?,
+ * text
+ * }
+ */
+ this.toXML = function() {
+ xml = "<generator";
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri.getValue() + "\"";
+ }
+ if ( this.lang != null) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ if ( this.version != null ) {
+ xml += " version=\"" + this.version + "\"";
+ }
+ xml += ">";
+ if ( this.name != null ) {
+ xml += this.name;
+ }
+ xml += "</generator>\n";
+ return xml;
+ }
+}
+
+/**
+ * Class that defines a Category object.
+ *atomCategory =
+ * element atom:category {
+ * atomCommonAttributes,
+ * attribute term { text },
+ * attribute scheme { atomUri }?,
+ * attribute label { text }?,
+ * undefinedContent
+ * }
+ */
+function Category( label, content ) {
+ this.label = label;
+ this.content = content;
+
+ this.setLabel = function( label ) {
+ this.label = label;
+ };
+
+ this.getLabel = function() {
+ return this.label;
+ };
+
+ this.setLang = function(lang) {
+ this.lang = lang;
+ };
+
+ this.getLang = function() {
+ return this.lang;
+ };
+
+ this.setTerm = function(term) {
+ this.term = term;
+ };
+
+ this.getTerm = function() {
+ return this.term;
+ };
+
+ this.setScheme = function( scheme ) {
+ this.scheme = scheme;
+ };
+
+ this.getScheme = function() {
+ return this.scheme;
+ };
+
+ this.setContent = function( content ) {
+ this.content = content;
+ };
+
+ this.getContent = function() {
+ return this.content;
+ };
+
+ this.toString = function() {
+ return "Category label=" + this.label;
+ };
+
+ /** Serialize this text element to XML.
+ * atomCategory =
+ * element atom:category {
+ * atomCommonAttributes,
+ * attribute term { text },
+ * attribute scheme { atomUri }?,
+ * attribute label { text }?,
+ * undefinedContent
+ * }
+ */
+ this.toXML = function() {
+ xml = "<category>\n";
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri + "\"";
+ }
+ if ( this.lang != null) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ if ( this.term != null) {
+ xml += " term=\"" + this.term + "\"";
+ }
+ if ( this.scheme != null) {
+ xml += " scheme=\"" + this.scheme + "\"";
+ }
+ if ( this.label != null) {
+ xml += " label=\"" + this.label + "\"";
+ }
+ xml += ">\n";
+ if ( this.content != null ) {
+ xml += this.content + "\n";
+ }
+ xml += "</category>\n";
+ return xml;
+ }
+}
+
+/**
+ * Class that defines a Link object.
+ */
+function Link( href, relation ) {
+ this.href = new Uri( href );
+ this.relation = relation;
+
+ this.setHRef = function( uri ) {
+ this.href = new Uri( uri );
+ };
+
+ this.getHRef = function() {
+ return this.href;
+ };
+
+ this.setTitle = function( title ) {
+ this.title = title;
+ };
+
+ this.getTitle = function() {
+ return this.title;
+ };
+
+ this.setHRefLang = function(lang) {
+ this.hrefLang = lang;
+ };
+
+ this.getHRefLang = function() {
+ return this.hreflang;
+ };
+
+ this.setTitleLang = function(lang) {
+ this.titleLang = lang;
+ };
+
+ this.getTitleLang = function() {
+ return this.titleLang;
+ };
+
+ this.setLength= function( length ) {
+ this.length= length;
+ };
+
+ this.getLength = function() {
+ return this.length;
+ };
+
+/*
+<static> <final> String TYPE_ATOM
+ Link type used for Atom content.
+<static> <final> String TYPE_HTML
+ Link type used for HTML content.
+*/
+ this.setMimeType = function(mimeType) {
+ this.mimeType = mimeType;
+ };
+
+ this.getMimeType = function() {
+ return this.mimeType;
+ };
+
+ this.setContent= function( content ) {
+ this.content = content;
+ };
+
+ this.getContent = function() {
+ return this.content;
+ };
+
+/*
+<static> <final> String REL_ALTERNATE
+ Link that provides the URI of an alternate format of the entry's or feed's contents.
+<static> <final> String REL_ENTRY_EDIT
+ Link that provides the URI that can be used to edit the entry.
+<static> <final> String REL_MEDIA_EDIT
+ Link that provides the URI that can be used to edit the media associated with an entry.
+<static> <final> String REL_NEXT
+ Link that provides the URI of next page in a paged feed.
+<static> <final> String REL_PREVIOUS
+ Link that provides the URI of previous page in a paged feed.
+<static> <final> String REL_RELATED
+ Link that provides the URI of a related link to the entry.
+<static> <final> String REL_SELF
+ Link that provides the URI of the feed or entry.
+<static> <final> String REL_VIA
+ Link that provides the URI that of link that provides the data for the content in the feed.
+*/
+ this.setRelation = function( relation ) {
+ this.relation = relation;
+ };
+
+ this.getRelation = function() {
+ return this.relation;
+ };
+
+ this.toString = function() {
+ return "Link href=" + this.href + ", title=" + this.title;
+ };
+
+ /** Serialize this text element to XML.
+ * atomLink =
+ * element atom:link {
+ * atomCommonAttributes,
+ * attribute href { atomUri },
+ * attribute rel { atomNCName | atomUri }?,
+ * attribute type { atomMediaType }?,
+ * attribute hreflang { atomLanguageTag }?,
+ * attribute title { text }?,
+ * attribute length { text }?,
+ * undefinedContent
+ * }
+ */
+ this.toXML = function() {
+ xml = "<link";
+ if ( this.relation != null ) {
+ xml += " rel=\"" + this.relation + "\"";
+ }
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri.getValue() + "\"";
+ }
+ if ( this.lang != null) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ if ( this.href != null ) {
+ xml += " href=\"" + this.href.getValue() + "\"";
+ }
+ if ( this.hreflang != null ) {
+ xml += " hreflang=\"" + this.hreflang + "\"";
+ }
+ if ( this.title != null ) {
+ xml += " title=\"" + this.title + "\"";
+ }
+ if ( this.length != null ) {
+ xml += " length=\"" + this.length + "\"";
+ }
+ if ( this.content != null ) {
+ xml += this.content + "\n";
+ xml += "</link>\n";
+ } else {
+ xml += "/>\n";
+ }
+ return xml;
+ }
+
+}
+
+/**
+ * Class that defines an Entry object.
+ * atomEntry =
+ * element atom:entry {
+ * atomCommonAttributes,
+ * (atomAuthor*
+ * & atomCategory*
+ * & atomContent?
+ * & atomContributor*
+ * & atomId
+ * & atomLink*
+ * & atomPublished?
+ * & atomRights?
+ * & atomSource?
+ * & atomSummary?
+ * & atomTitle
+ * & atomUpdated
+ * & extensionElement*)
+ * }
+ */
+function Entry( init ) {
+ // Constructor code at bottom after function definition
+
+ this.authors = new Array();
+ this.contributors = new Array();
+ this.categories = new Array();
+ this.links = new Array();
+
+ this.setNamespace = function( namespace ) {
+ this.namespace = namespace;
+ };
+
+ this.getNamespace = function() {
+ return this.namespace;
+ };
+
+ this.setId = function( id ) {
+ if (!((typeof id == "object") && (id instanceof Id)))
+ this.id = new Id( id );
+ else
+ this.id = id;
+ }
+
+ this.getId = function() {
+ return this.id;
+ };
+
+ this.setPublished = function( published ) {
+ this.published = published;
+ };
+
+ this.getPublished = function() {
+ return this.published;
+ };
+
+ this.setUpdated = function( updated ) {
+ this.updated = updated;
+ };
+
+ this.getUpdated = function() {
+ return this.updated;
+ };
+
+ this.setRights = function( rights ) {
+ this.rights = rights;
+ }
+
+ this.getRights = function() {
+ return this.rights;
+ };
+
+ this.setSource = function( source ) {
+ this.source = source;
+ }
+
+ this.getSource = function() {
+ return this.source;
+ };
+
+ /* Type Text */
+ this.setTitle = function( title ) {
+ if (!((typeof title == "object") && (title instanceof Text)))
+ this.title = new Text( title, "text" );
+ else
+ this.title = title;
+ }
+
+ this.getTitle = function() {
+ return this.title;
+ };
+
+ /* Type Text */
+ this.setSummary = function( summary ) {
+ if (!((typeof summary == "object") && (summary instanceof Text)))
+ this.summary = new Text( summary, "text" );
+ else
+ this.summary = summary;
+ }
+
+ this.getSummary = function() {
+ return this.summary;
+ };
+
+ /* Type Text */
+ this.setContent = function( content ) {
+ if (!((typeof content == "object") && (content instanceof Text)))
+ this.content = new Text( content, "text" );
+ else
+ this.content = content;
+ }
+
+ this.getContent = function() {
+ return this.content;
+ };
+
+ /**
+ * Add an author.
+ * @param name Author
+ */
+ this.addAuthor = function(person) {
+ if (!((typeof person == "object") && (person instanceof Person)))
+ error( "Entry author must be of type Person" );
+ var i = this.authors.length;
+ this.authors[ i ] = person;
+ }
+
+ /**
+ * Get an author.
+ * @param name Author
+ */
+ this.getAuthor = function(name) {
+ return this.authors[ name ];
+ }
+
+ /**
+ * Set list of authors.
+ * @param name Author
+ */
+ this.setAuthors = function( authors ) {
+ return this.authors = authors;
+ }
+
+ /**
+ * Get an author"pom.xml".
+ * @param name Author
+ */
+ this.getAuthors = function() {
+ return this.authors;
+ }
+
+ /**
+ * Add an contributor.
+ * @param name Contributor
+ */
+ this.addContributor = function(person) {
+ if (!((typeof person == "object") && (person instanceof Person)))
+ error( "Entry contributor must be of type Person" );
+ var i = this.contributors.length;
+ this.contributors[ i ] = person;
+ }
+
+ /**
+ * Get an contributor.
+ * @param name Contributor
+ */
+ this.getContributor = function(name) {
+ return this.contributors[ name ];
+ }
+
+ /**
+ * Set list of contributors
+ * @param name Author
+ */
+ this.setContributors = function( contributors ) {
+ return this.contributors = contributors;
+ }
+
+ /**
+ * Get an contributor.
+ * @param name Contributor
+ */
+ this.getContributors = function() {
+ return this.contributors;
+ }
+
+ /**
+ * Add a category.
+ * @param name Category
+ */
+ this.addCategory = function(category) {
+ if (!((typeof category == "object") && (category instanceof Category)))
+ error( "Entry category must be of type Category" );
+ var i = this.categories.length
+ this.categories[ i ] = category;
+ }
+
+ /**
+ * Get a names category.
+ * @param name Category
+ */
+ this.getCategory = function(name) {
+ return this.categories[ name ];
+ }
+
+ /**
+ * Set list of categories
+ * @param name Author
+ */
+ this.setCategories = function( categories ) {
+ return this.categories = categories;
+ }
+
+ /**
+ * Get all categories.
+ * @param name Category
+ */
+ this.getCategories = function() {
+ return this.categories;
+ }
+
+ /**
+ * Add an link.
+ * @param name Link
+ */
+ this.addLink = function(link) {
+ if (!((typeof link == "object") && (link instanceof Link)))
+ error( "Entry link must be of type Link" );
+ var i = this.links.length;
+ this.links[ i ] = link;
+ }
+
+ /**
+ * Get an link.
+ * @param name Link
+ */
+ this.getLink = function(name) {
+ return links[ name ];
+ }
+
+ /**
+ * Set list of links.
+ * @param name Link
+ */
+ this.setLinks = function( links ) {
+ return this.links = links;
+ }
+
+ /**
+ * Get an link.
+ * @param name Link
+ */
+ this.getLinks = function() {
+ return links;
+ }
+
+ this.readFromXML = function( xml ) {
+ if (!((typeof xml == "object") && (xml instanceof string)))
+ error( "Entry xml must be of type string" );
+ // To Do - Read from arbutrary XML such as
+ // <entry>
+ // <title type="text">cart-item</title>
+ // <content type="text">Apple - $ 2.99</content>
+ // <id>cart-bd5323d6-1f59-4fae-a8f5-01f7654f1e77</id>
+ // <link href="cart-bd5323d6-1f59-4fae-a8f5-01f7654f1e77" rel="edit"/>
+ // <link href="cart-bd5323d6-1f59-4fae-a8f5-01f7654f1e77" rel="alternate"/>
+ // <updated>2008-09-21T23:06:43.921Z</updated>
+ // </entry>
+
+ }
+ this.readFromDoc = function( htmlDoc ) {
+ // Expect HTML collection.
+ var entryDoc = htmlDoc.getElementsByTagName("entry");
+ for (var i = 0; i < entryDoc.length; i++) {
+ this.readFromNode( entryDoc[ i ] );
+ }
+ }
+
+ this.readFromNode = function( entryNode ) {
+ // Expect entry node
+ var childNodes = entryNode.childNodes;
+ for ( var i = 0; i < childNodes.length; i++ ) {
+ var node = childNodes[ i ];
+ if (node.nodeType == 1 /*Node.ELEMENT_NODE*/) {
+ var tagName = node.tagName;
+ if (tagName == "title" ) {
+ var text = getTextContent( node );
+ var type = node.getAttribute( "type" );
+ if ( type == undefined )
+ type = "text";
+ var title = new Text( text, type );
+ this.setTitle( title );
+ } else if ( tagName == "subtitle" ) {
+ var text = getTextContent( node );
+ var type = node.getAttribute( "type" );
+ if ( type == undefined )
+ type = "text";
+ var title = new Text( text, type );
+ this.setSubtitle( title );
+ } else if ( tagName == "id" ) {
+ var id = new Id( getTextContent( node ) );
+ this.setId( id );
+ } else if ( tagName == "updated" ) {
+ var dateText = getTextContent( node );
+ var date = new Date( dateText ); // 2008-09-21T23:06:43.921Z
+ this.setUpdated( date );
+ } else if ( tagName == "link" ) {
+ // var href = node.attributes[ "href" ]; // Works on modern browsers.
+ var attrVal = node.getAttribute( "href" );
+ var link = new Link( attrVal );
+ attrVal = node.getAttribute( "rel" );
+ if ( attrVal )
+ link.setRelation( attrVal );
+ this.addLink( link );
+ } else if ( tagName == "content" ) {
+ var text = getTextContent( node );
+ var type = node.getAttribute( "type" );
+ if (type == undefined)
+ type = "text";
+ var content = new Text( text, type );
+ this.setContent( content );
+ } else {
+ // To Do - implement rest of nodes
+ error( "undefined element node" );
+ }
+ } else if (node.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
+ var attrName = node.tagName;
+ } else if (node.nodeType == 3 /*Node.TEXT_NODE*/) {
+ }
+ }
+ }
+
+ this.toString = function() {
+ return "Entry title=" + this.title + ", updated=" + this.updated;
+ };
+
+ /** Serialize this text element to XML.
+ * atomEntry =
+ * element atom:entry {
+ * atomCommonAttributes,
+ * (atomAuthor*
+ * & atomContributor*
+ * & atomCategory*
+ * & atomLink*
+ * & atomTitle
+ * & atomId
+ * & atomPublished?
+ * & atomUpdated
+ * & atomContent?
+ * & atomRights?
+ * & atomSource?
+ * & atomSummary?
+ * & extensionElement*)
+ * }
+ */
+ this.toXML = function() {
+ xml = "<entry";
+ if ( this.namespace != null ) {
+ xml += " namespace=\"" + this.namespace + "\"";
+ }
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri + "\"";
+ }
+ if ( this.lang != null ) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ xml += ">";
+ if ( this.title != null ) {
+ xml += this.title.toXML( "title" );
+ }
+ if ( this.id != null ) {
+ xml += this.id.toXML();
+ }
+ if ( this.published != null ) {
+ xml += "<published>" + this.published + "</published>\n";
+ }
+ if ( this.updated != null ) {
+ xml += "<updated>" + this.updated + "</updated>\n";
+ }
+ if ( this.authors != null ) {
+ for ( var i = 0; i < this.authors.length; i++ ) {
+ var author = this.authors[ i ];
+ xml += author.toXML( "author" );
+ }
+ }
+ if ( this.contributors != null ) {
+ for ( var i = 0; i < this.contributors.length; i++ ) {
+ var contributor = this.contributors[ i ];
+ xml += contributor.toXML( "contributor" );
+ }
+ }
+ if ( this.categories != null ) {
+ for ( var i = 0; i < this.categories.length; i++ ) {
+ var category = this.categories[ i ];
+ xml += category.toXML();
+ }
+ }
+ if ( this.links != null ) {
+ for ( var i = 0; i < this.links.length; i++ ) {
+ var link = this.links[ i ];
+ xml += link.toXML();
+ }
+ }
+ if ( this.rights != null ) {
+ xml += "<rights>" + this.rights + "</rights>\n";
+ }
+ if ( this.source != null ) {
+ xml += "<source>" + this.source + "</source>\n";
+ }
+ if ( this.summary != null ) {
+ xml += this.summary.toXML( "summary" );
+ }
+ if ( this.content != null ) {
+ xml += this.content.toXML( "content" );
+ }
+ xml += "</entry>";
+ return xml;
+ }
+
+ // Initialize from constructor
+ if (typeof init == 'object') {
+ if ( init.nodeType == 1 ) { /* Document Node.ELEMENT_NODE 1 */
+ this.readFromDoc( init );
+ } else {
+ error( "Feed init unknown type" );
+ }
+ } else if ( typeof init === 'string' ) {
+ this.setTitle( init );
+ }
+ this.namespace = "http://www.w3.org/2005/Atom";
+}
+
+/**
+ * Class that defines an Feed object.
+ * atomFeed =
+ * element atom:feed {
+ * atomCommonAttributes,
+ * (atomAuthor*
+ * & atomCategory*
+ * & atomContributor*
+ * & atomGenerator?
+ * & atomIcon?
+ * & atomId
+ * & atomLink*
+ * & atomLogo?
+ * & atomRights?
+ * & atomSubtitle?
+ * & atomTitle
+ * & atomUpdated
+ * & extensionElement*),
+ * atomEntry*
+ */
+function Feed( init ) {
+ // See init after functions have been defined.
+
+ this.authors = new Array();
+ this.contributors = new Array();
+ this.categories = new Array();
+ this.links = new Array();
+ this.entries = new Array();
+
+ this.setNamespace = function( namespace ) {
+ this.namespace = namespace;
+ };
+
+ this.getNamespace = function() {
+ return this.namespace;
+ };
+
+ this.setPublished = function( published ) {
+ this.published = published;
+ };
+
+ this.getPublished = function() {
+ return this.published;
+ };
+
+ this.setUpdated = function( updated ) {
+ this.updated = updated;
+ };
+
+ this.getUpdated = function() {
+ return this.updated;
+ };
+
+ this.setContent = function( content ) {
+ if (!((typeof content == "object") && (content instanceof Text)))
+ error( "Entry content must be of type Text" );
+
+ this.content = content;
+ }
+
+ this.getContent = function() {
+ return this.content;
+ };
+
+ this.setRights = function( rights ) {
+ if (!((typeof rights == "object") && (rights instanceof Text)))
+ this.rights = new Text( rights, "text" );
+ else
+ this.rights = rights;
+ }
+
+ this.getRights = function() {
+ return this.rights;
+ };
+
+ this.setSummary = function( summary ) {
+ if (!((typeof summary == "object") && (summary instanceof Text)))
+ error( "Feed summary must be of type Text" );
+ this.summary = summary;
+ }
+
+ this.getSummary = function() {
+ return this.summary;
+ };
+
+ this.setTitle = function( title ) {
+ if (!((typeof title == "object") && (title instanceof Text)))
+ this.title = new Text( title, "text" );
+ else
+ this.title = title;
+ }
+
+ this.getTitle = function() {
+ return this.title;
+ };
+
+ this.setSubtitle = function( subtitle ) {
+ if (!((typeof subtitle == "object") && (subtitle instanceof Text)))
+ this.subtitle = new Text( subtitle, "text" );
+ else
+ this.subtitle = subtitle;
+ }
+
+ this.getSubtitle = function() {
+ return this.subtitle;
+ };
+
+ /* Type Id */
+ this.setId = function( id ) {
+ if (!((typeof id == "object") && (id instanceof Id)))
+ this.id = new Id( id );
+ else
+ this.id = id;
+ }
+
+ this.getId = function() {
+ return this.id;
+ };
+
+ this.setGenerator = function( generator ) {
+ if (!((typeof generator == "object") && (generator instanceof Generator)))
+ error( "Feed generator must be of type Generator" );
+ this.generator = generator;
+ }
+
+ this.getGenerator = function() {
+ return this.generator;
+ };
+
+ this.setBase = function( base ) {
+ this.base = base;
+ }
+
+ this.getBase = function() {
+ return this.base;
+ };
+
+ this.setLogo = function( logo ) {
+ this.logo = logo;
+ }
+
+ this.getLogo = function() {
+ return this.logo;
+ };
+
+ /**
+ * Add an author.
+ * @param name Author
+ */
+ this.addAuthor = function(person) {
+ if (!((typeof person == "object") && (person instanceof Person)))
+ error( "Entry author must be of type Person" );
+ var i = this.authors.length;
+ this.authors[ i ] = person;
+ }
+
+ /**
+ * Get an author.
+ * @param name Author
+ */
+ this.getAuthor = function(name) {
+ return this.authors[ name ];
+ }
+
+ /**
+ * Set list of authors.
+ * @param name Author
+ */
+ this.setAuthors = function( authors ) {
+ return this.authors = authors;
+ }
+
+ /**
+ * Get an author.
+ * @param name Author
+ */
+ this.getAuthors = function() {
+ return this.authors;
+ }
+
+ /**
+ * Add an contributor.
+ * @param name Contributor
+ */
+ this.addContributor = function(person) {
+ if (!((typeof person == "object") && (person instanceof Person)))
+ error( "Entry contributor must be of type Person" );
+ var i = this.contributors.length;
+ this.contributors[ i ] = person;
+ }
+
+ /**
+ * Get an contributor.
+ * @param name Contributor
+ */
+ this.getContributor = function(name) {
+ return this.contributors[ name ];
+ }
+
+ /**
+ * Set list of contributors
+ * @param name Author
+ */
+ this.setContributors = function( contributors ) {
+ return this.contributors = contributors;
+ }
+
+ /**
+ * Get an contributor.
+ * @param name Contributor
+ */
+ this.getContributors = function() {
+ return this.contributors;
+ }
+
+ /**
+ * Add a category.
+ * @param name Category
+ */
+ this.addCategory = function(category) {
+ if (!((typeof category == "object") && (category instanceof Category)))
+ error( "Feed category must be of type Category" );
+ var i = this.categories.length;
+ this.categories[ i ] = category;
+ }
+
+ /**
+ * Get a named contributor.
+ * @param name Category
+ */
+ this.getCategory = function(name) {
+ return this.categories[ name ];
+ }
+
+ /**
+ * Set list of categories
+ * @param category
+ */
+ this.setCategories = function( categories ) {
+ return this.categories = categories;
+ }
+
+ /**
+ * Get all categories.
+ * @param name Category
+ */
+ this.getCategories = function() {
+ return this.categories;
+ }
+
+ /**
+ * Add an link.
+ * @param name Link
+ */
+ this.addLink = function(link) {
+ if (!((typeof link == "object") && (link instanceof Link)))
+ error( "Entry link must be of type Link" );
+ var i = this.links.length;
+ this.links[ i ] = link;
+ }
+
+ /**
+ * Get an link.
+ * @param name Link
+ */
+ this.getLink = function(name) {
+ return this.links[ name ];
+ }
+
+ /**
+ * Set list of links.
+ * @param name Link
+ */
+ this.setLinks = function( links ) {
+ return this.links = links;
+ }
+
+ /**
+ * Get an link.
+ * @param name Link
+ */
+ this.getLinks = function() {
+ return this.links;
+ }
+
+ /**
+ * Add an entry.
+ * @param name Entry
+ */
+ this.addEntry = function(entry) {
+ if (!((typeof entry == "object") && (entry instanceof Entry)))
+ error( "Entry entry must be of type Entry" );
+ var i = this.entries.length;
+ this.entries[ i ] = entry;
+ }
+
+ /**
+ * Get an entry by name.
+ * @param name Entry
+ */
+ this.getEntry = function(name) {
+ return this.entries[ name ];
+ }
+
+ /**
+ * Set list of entries
+ * @param name Author
+ */
+ this.setEntries = function( entries ) {
+ return this.entries = entries;
+ }
+
+ /**
+ * Get an contributor.
+ * @param name Entry
+ */
+ this.getEntries = function() {
+ return this.entries;
+ }
+
+ this.readFromXML = function( xml ) {
+ // To Do Read from arbitraty XML such as
+ // <feed xmlns="http://www.w3.org/2005/Atom">
+ // <title type="text">shopping cart</title>
+ // <subtitle type="text">Total : $4.54</subtitle>
+ // <entry>
+ // ...
+ // </entry>
+ // </feed>
+ }
+
+ this.readFromDoc = function( htmlDoc ) {
+ // Expect HTML collection.
+ var feedDoc = htmlDoc.getElementsByTagName("feed");
+ for (var i = 0; i < feedDoc.length; i++) {
+ this.readFromNode( feedDoc[ i ] );
+ }
+ }
+ this.readFromNode = function( feedNode ) {
+ // Expect feed node
+ var childNodes = feedNode.childNodes;
+ for ( var i = 0; i < childNodes.length; i++ ) {
+ var node = childNodes[ i ];
+ if (node.nodeType == 1 /*Node.ELEMENT_NODE*/) {
+ var tagName = node.tagName;
+ if (tagName == "title" ) {
+ var text = getTextContent( node );
+ var type = node.getAttribute( "type" );
+ if ( type == undefined )
+ type = "text";
+ var title = new Text( text, type );
+ this.setTitle( title );
+ } else if ( tagName == "subtitle" ) {
+ var text = getTextContent( node );
+ var type = node.getAttribute( "type" );
+ if ( type == undefined )
+ type = "text";
+ var title = new Text( text, type );
+ this.setSubtitle( title );
+ } else if ( tagName == "entry" ) {
+ var entry = new Entry();
+ entry.readFromNode( node );
+ this.addEntry( entry );
+ } else if ( tagName == "id" ) {
+ var id = new Id( getTextContent( node ) );
+ this.setId( id );
+ } else if ( tagName == "updated" ) {
+ var dateText = getTextContent( node );
+ var date = new Date( dateText ); //2008-09-21T23:06:53.750Z
+ this.setUpdated( date );
+ } else if ( tagName == "link" ) {
+ // var href = node.attributes[ "href" ]; // Works on modern browsers.
+ var attrVal = node.getAttribute( "href" );
+ var link = new Link( attrVal );
+ attrVal = node.getAttribute( "rel" );
+ if ( attrVal )
+ link.setRelation( attrVal );
+ this.addLink( link );
+ } else {
+ // To Do - implement rest of nodes
+ error( "undefined element node" );
+ }
+ } else if (node.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
+ var attrName = node.tagName;
+ } else if (node.nodeType == 3 /*Node.TEXT_NODE*/) {
+ }
+ }
+ }
+
+ this.toString = function() {
+ return "Feed title=" + this.title + ", updated=" + this.updated;
+ };
+
+ /** Serialize this text element to XML.
+ * atomFeed =
+ * element atom:feed {
+ * atomCommonAttributes,
+ * (atomAuthor*
+ * & atomContributor*
+ * & atomCategory*
+ * & atomLink*
+ * & atomTitle
+ * & atomSubtitle?
+ * & atomId
+ * & atomUpdated
+ * & atomRights?
+ * & atomGenerator?
+ * & atomIcon?
+ * & atomLogo?
+ * & extensionElement*),
+ * atomEntry*
+ */
+ this.toXML = function() {
+ xml = "<feed";
+ if ( this.namespace != null ) {
+ xml += " namespace=\"" + this.namespace + "\"";
+ }
+ if ( this.uri != null ) {
+ xml += " uri=\"" + this.uri + "\"";
+ }
+ if ( this.lang != null ) {
+ xml += " lang=\"" + this.lang + "\"";
+ }
+ xml += ">\n";
+ if ( this.title != null ) {
+ xml += this.title.toXML( "title" );
+ }
+ if ( this.subtitle != null ) {
+ xml += this.subtitle.toXML( "subtitle" );
+ }
+ if ( this.id != null ) {
+ xml += this.id.toXML();
+ }
+ if ( this.published != null ) {
+ xml += "<published>" + this.published + "</published>\n";
+ }
+ if ( this.updated != null ) {
+ xml += "<updated>" + this.updated + "</updated>\n";
+ }
+ if ( this.authors != null ) {
+ for ( var i = 0; i < this.authors.length; i++ ) {
+ var author = this.authors[ i ];
+ xml += author.toXML( "author" );
+ }
+ }
+ if ( this.contributors != null ) {
+ for ( var i = 0; i < this.contributors.length; i++ ) {
+ var contributor = this.contributors[ i ];
+ xml += contributor.toXML( "contributor" );
+ }
+ }
+ if ( this.categories != null ) {
+ for ( var i = 0; i < this.categories.length; i++ ) {
+ var category = this.categories[ i ];
+ xml += category.toXML();
+ }
+ }
+ if ( this.links != null ) {
+ for ( var i = 0; i < this.links.length; i++ ) {
+ var link = this.links[ i ];
+ xml += link.toXML();
+ }
+ }
+ if ( this.rights != null ) {
+ xml += this.rights.toXML( "rights" );
+ }
+ if ( this.source != null ) {
+ xml += "<source>" + this.source + "</source>\n";
+ }
+ if ( this.logo != null ) {
+ xml += "<logo>" + this.logo + "</logo>\n";
+ }
+ if ( this.icon != null ) {
+ xml += "<icon>" + this.icon + "</icon>\n";
+ }
+ if ( this.generator != null ) {
+ xml += this.generator.toXML( "generator" );
+ }
+ if ( this.summary != null ) {
+ xml += this.summary.toXML( "summary" );
+ }
+ if ( this.entries != null ) {
+ for ( var i = 0; i < this.entries.length; i++ ) {
+ var entry = this.entries[ i ];
+ xml += entry.toXML();
+ }
+ }
+ xml += "</feed>\n";
+ return xml;
+ }
+
+ // Initialize from constructor
+ if (typeof init == 'object') {
+ if ( init.nodeType == 9 ) { /* Document Node.DOCUMENT_NODE 9 */
+ this.readFromDoc( init );
+ } else {
+ error( "Feed init unknown type" );
+ }
+ } else if ( typeof init === 'string' ) {
+ this.setTitle( init );
+ }
+ this.namespace = "http://www.w3.org/2005/Atom";
+}
+
+function error( message ) {
+ alert( message );
+}
+
+/* Returns inner text on both IE and modern browsers. */
+function getTextContent(node) {
+ // innerText for IE, textContent for others, child text node, "" for others.
+ if ( node.innerText )
+ return node.innerText;
+ if ( node.textContent )
+ return node.textContent;
+ if ( node.hasChildNodes() ) {
+ var childNodes = node.childNodes
+ for ( var j = 0; j < childNodes.length; j++ ) {
+ var childNode = childNodes[ j ];
+ var childType = childNode.nodeType;
+ if (childNode.nodeType == 3 /*Node.TEXT_NODE*/) {
+ return childNode.nodeValue;
+ }
+ }
+ }
+ return undefined;
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/binding-http.js b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/binding-http.js
new file mode 100644
index 0000000000..60bd841679
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget-runtime/src/main/resources/binding-http.js
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 HTTPClient(uri) {
+
+ this.msxmlNames = [ "MSXML2.XMLHTTP.5.0",
+ "MSXML2.XMLHTTP.4.0",
+ "MSXML2.XMLHTTP.3.0",
+ "MSXML2.XMLHTTP",
+ "Microsoft.XMLHTTP" ];
+
+ this.uri=uri;
+
+ this.get = function(id, responseFunction) {
+ var xhr = this.createXMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4) {
+ if (xhr.status == 200) {
+ var strDocument = xhr.responseText;
+ if (responseFunction != null) responseFunction(strDocument);
+ } else {
+ alert("get - Error getting data from the server");
+ }
+ }
+ }
+ xhr.open("GET", uri + '/' + id, true);
+ xhr.send(null);
+ }
+
+ this.post = function (entry, responseFunction) {
+ var xhr = this.createXMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4) {
+ if (xhr.status == 201) {
+ var strDocument = xhr.responseText;
+ if (responseFunction != null) responseFunction(strDocument);
+ } else {
+ alert("post - Error getting data from the server");
+ }
+ }
+ }
+ xhr.open("POST", uri, true);
+ xhr.setRequestHeader("Content-Type", "text/xml");
+ xhr.send(entry);
+ }
+
+ this.put = function (id, entry, responseFunction) {
+ var xhr = this.createXMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4) {
+ if (xhr.status == 200) {
+ var strDocument = xhr.responseText;
+ if (responseFunction != null) responseFunction(strDocument);
+ } else {
+ alert("put - Error getting data from the server");
+ }
+ }
+ }
+ xhr.open("PUT", uri + '/' + id, true);
+ xhr.setRequestHeader("Content-Type", "text/xml");
+ xhr.send(entry);
+ }
+
+ this.del = function (id, responseFunction) {
+ var xhr = this.createXMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4) {
+ if (xhr.status == 200) {
+ if (responseFunction != null) responseFunction();
+ } else {
+ alert("delete - Error getting data from the server");
+ }
+ }
+ }
+ xhr.open("DELETE", uri + '/' + id, true);
+ xhr.send(null);
+ }
+ this.createXMLHttpRequest = function () {
+ /* Mozilla XMLHttpRequest */
+ try {return new XMLHttpRequest();} catch(e) {}
+
+ /* Microsoft MSXML ActiveX */
+ for (var i=0;i < this.msxmlNames.length; i++) {
+ try {return new ActiveXObject(this.msxmlNames[i]);} catch (e) {}
+ }
+ alert("XML http request not supported");
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/LICENSE b/sandbox/sebastien/java/embed/modules/implementation-widget/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/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/sebastien/java/embed/modules/implementation-widget/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/implementation-widget/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..fcc1ede5d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.widget;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.data.collection,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.implementation.widget.javascript;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Widget Implementation Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Widget Implementation Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.data.collection;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.widget
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/NOTICE b/sandbox/sebastien/java/embed/modules/implementation-widget/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/pom.xml b/sandbox/sebastien/java/embed/modules/implementation-widget/pom.xml
new file mode 100644
index 0000000000..aafefaf25e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/pom.xml
@@ -0,0 +1,64 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-implementation-widget</artifactId>
+ <name>Apache Tuscany SCA Widget Implementation Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java
new file mode 100644
index 0000000000..f1c1c36934
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.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 org.apache.tuscany.sca.implementation.widget;
+
+import java.io.InputStream;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The service interface of widget implementations. This is not an API for application
+ * developers. Application developers should use the data collection API to invoke
+ * widget components.
+ *
+ * @version $Rev$ $Date$
+ */
+
+@Remotable
+public interface Widget extends Collection<String, InputStream> {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java
new file mode 100644
index 0000000000..d032d3ca8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.widget;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+
+
+/**
+ * The model representing a widget implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WidgetImplementation extends Implementation {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "implementation.widget");
+
+ /**
+ * Returns the location of the HTML file representing the Widget
+ * @return the location
+ */
+ String getLocation();
+
+ /**
+ * Set the location of the HTML file representing the Widget
+ * @param location
+ */
+ void setLocation(String location);
+
+ /**
+ * Returns the Location URL for the HTML file representing the Widget
+ * @return the location
+ */
+ URL getLocationURL();
+
+ /**
+ * Set the Location URL for the HTML file representing the Widget
+ * @param url the location
+ */
+ void setLocationURL(URL url);
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java
new file mode 100644
index 0000000000..74addf1e39
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.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 org.apache.tuscany.sca.implementation.widget;
+
+/**
+ * Factory for the widget implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WidgetImplementationFactory {
+
+ /**
+ * Create a Widget Implementation model object
+ * @return
+ */
+ WidgetImplementation createWidgetImplementation();
+
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java
new file mode 100644
index 0000000000..9bf8c05d73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.widget;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Scanner;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A HTML Widget Introspector used to introspect references and property
+ * annotations in JavaScript code
+ *
+ * @version $Rev$ $Date$
+ */
+class WidgetImplementationIntrospector {
+ private static final String WEB_REFERENCE_ANNOTATION = "//@Reference";
+ private static final String WEB_PROPERTY_ANNOTATION = "//@Property";
+
+ private AssemblyFactory assemblyFactory;
+ private WidgetImplementation widgetImplementation;
+
+ WidgetImplementationIntrospector(ExtensionPointRegistry registry, WidgetImplementation widgetImplementation ) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.widgetImplementation = widgetImplementation;
+ }
+
+
+ /**
+ * Introspect and populate a given widget implementation
+ */
+ public void introspectImplementation() {
+ URL htmlWidget = widgetImplementation.getLocationURL();
+
+ try {
+ URLConnection connection = htmlWidget.openConnection();
+ connection.setUseCaches(false);
+ Scanner scanner = new Scanner(connection.getInputStream());
+ while(scanner.hasNextLine()) {
+ String line = scanner.nextLine();
+ if(line.contains(WEB_PROPERTY_ANNOTATION)) {
+ //process the next line, as it has the property info
+ if (scanner.hasNextLine()) {
+ Property property = processPropertyScript(scanner.nextLine());
+ if (property != null) {
+ widgetImplementation.getProperties().add(property);
+ }
+ }
+
+ } else if(line.contains(WEB_REFERENCE_ANNOTATION)) {
+ //process the next line, as it has the reference info
+ if (scanner.hasNextLine()) {
+ Reference reference = processReferenceScript(scanner.nextLine());
+ if(reference != null){
+ widgetImplementation.getReferences().add(reference);
+ }
+
+ }
+ }
+ }
+
+ } catch(Exception e) {
+
+ }
+
+
+ }
+
+
+ /**
+ * Process Property declaration in JavaScript code
+ * Supported ways:
+ * //@Property
+ * var locale = Property("locale");
+ *
+ * //@Property
+ * locale = Property("locale");
+ *
+ * @param scriptContent
+ * @return
+ */
+ private Property processPropertyScript(String scriptContent) {
+ Property property = null;
+ String propertyName = null;
+
+ String tokens[] = scriptContent.split("=");
+ tokens = tokens[0].split(" ");
+ propertyName = tokens[tokens.length -1];
+
+ if(propertyName != null) {
+ property = assemblyFactory.createProperty();
+ property.setName(propertyName);
+ }
+
+ return property;
+ }
+
+ /**
+ * Process Reference declaration in JavaScript code
+ * Supported ways :
+ * //@Reference
+ * var catalog = new Reference("catalog");
+ *
+ * //@Reference
+ * catalog = new Reference("catalog");
+ *
+ * @param scriptContent
+ * @return
+ */
+ private Reference processReferenceScript(String scriptContent) {
+ Reference reference = null;
+ String referenceName = null;
+
+ String tokens[] = scriptContent.split("=");
+
+ // find the string between the quotes
+ tokens = tokens[1].split("\"");
+ referenceName = tokens[1];
+
+ if(referenceName != null) {
+ reference = assemblyFactory.createReference();
+ reference.setName(referenceName);
+ }
+
+ return reference;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java
new file mode 100644
index 0000000000..bf84a15aa6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.widget;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.io.IOException;
+import java.net.URL;
+
+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.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ *
+ * Implements a StAX artifact processor for Widget implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WidgetImplementation> {
+ private ExtensionPointRegistry registry;
+ private ContributionFactory contributionFactory;
+ private WidgetImplementationFactory implementationFactory;
+
+ public WidgetImplementationProcessor(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ implementationFactory = modelFactories.getFactory(WidgetImplementationFactory.class);
+ }
+
+
+ public QName getArtifactType() {
+ // Returns the QName of the XML element processed by this processor
+ return WidgetImplementation.TYPE;
+ }
+
+ public Class<WidgetImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return WidgetImplementation.class;
+ }
+
+ public WidgetImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ // Read an <implementation.widget> element
+
+ // Create and initialize the resource implementation model
+ WidgetImplementation implementation = null;
+
+ // Read the location attribute specifying the location of the resources
+ String location = getURIString(reader, "location");
+ if (location != null) {
+ implementation = implementationFactory.createWidgetImplementation();
+ implementation.setLocation(location);
+ implementation.setUnresolved(true);
+ } else {
+ error(context.getMonitor(), "LocationAttributeMissing", reader);
+ //throw new ContributionReadException(MSG_LOCATION_MISSING);
+ }
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && WidgetImplementation.TYPE.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return implementation;
+ }
+
+ public void resolve(WidgetImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (implementation != null) {
+ // Resolve the resource directory location
+ Artifact artifact = contributionFactory.createArtifact();
+ artifact.setURI(implementation.getLocation());
+ Artifact resolved = resolver.resolveModel(Artifact.class, artifact, context);
+ if (resolved.getLocation() != null) {
+ try {
+ implementation.setLocationURL(new URL(resolved.getLocation()));
+
+ //introspect implementation
+ WidgetImplementationIntrospector widgetIntrospector =
+ new WidgetImplementationIntrospector(registry, implementation);
+ widgetIntrospector.introspectImplementation();
+
+ implementation.setUnresolved(false);
+ } catch (IOException e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ } else {
+ error(context.getMonitor(), "CouldNotResolveLocation", resolver, implementation.getLocation());
+ //throw new ContributionResolveException("Could not resolve implementation.widget location: " + implementation.getLocation());
+ }
+ }
+ }
+
+ public void write(WidgetImplementation implementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // Write <implementation.widget>
+ writeStart(writer, WidgetImplementation.TYPE.getNamespaceURI(), WidgetImplementation.TYPE.getLocalPart());
+
+ if (implementation.getLocation() != null) {
+ writer.writeAttribute("location", implementation.getLocation());
+ }
+
+ writeEnd(writer);
+ }
+
+ /**
+ * Utility methods
+ */
+
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-widget-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-widget-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java
new file mode 100644
index 0000000000..960a01d07e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.widget.impl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
+import org.apache.tuscany.sca.implementation.widget.WidgetImplementationFactory;
+
+/**
+ * Factory for the widget implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WidgetImplementationFactoryImpl implements WidgetImplementationFactory {
+
+ private ExtensionPointRegistry registry;
+
+ public WidgetImplementationFactoryImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public WidgetImplementation createWidgetImplementation() {
+ return new WidgetImplementationImpl(registry);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java
new file mode 100644
index 0000000000..58edfdd3ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.widget.impl;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.widget.Widget;
+import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+
+/**
+ * The model representing a widget implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WidgetImplementationImpl extends ImplementationImpl implements WidgetImplementation {
+ private Service widgetService;
+
+ private String location;
+ private URL locationUrl;
+
+ /**
+ * Constructs a new resource implementation.
+ */
+ WidgetImplementationImpl(ExtensionPointRegistry registry) {
+
+ super(TYPE);
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+
+ // Resource implementation always provide a single service exposing
+ // the Resource interface, and have no references and properties
+ widgetService = assemblyFactory.createService();
+ widgetService.setName("Widget");
+
+ // Create the Java interface contract for the Resource service
+ JavaInterface javaInterface;
+ try {
+ javaInterface = javaFactory.createJavaInterface(Widget.class);
+ } catch (InvalidInterfaceException e) {
+ throw new IllegalArgumentException(e);
+ }
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ interfaceContract.setInterface(javaInterface);
+ widgetService.setInterfaceContract(interfaceContract);
+
+ this.getServices().add(widgetService);
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public URL getLocationURL() {
+ return locationUrl;
+ }
+
+ public void setLocationURL(URL url) {
+ this.locationUrl = url;
+ }
+
+
+ @Override
+ public String toString() {
+ return "Widget : " + getLocation();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (!(obj instanceof WidgetImplementationImpl)) {
+ return false;
+ }
+ WidgetImplementationImpl other = (WidgetImplementationImpl)obj;
+ if (location == null) {
+ if (other.location != null) {
+ return false;
+ }
+ } else if (!location.equals(other.location)) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/javascript/WidgetImplementationJavascriptProvider.java b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/javascript/WidgetImplementationJavascriptProvider.java
new file mode 100644
index 0000000000..55cf7dbf0e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/javascript/WidgetImplementationJavascriptProvider.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.widget.javascript;
+
+import org.apache.tuscany.sca.core.ModuleActivator;
+
+
+/**
+ * A widget javascript provider which
+ * provides dojo and tuscany dojo extensions
+ * to an application using implementation.widget
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WidgetImplementationJavascriptProvider extends ModuleActivator {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..24d6c8b419
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.implementation.widget.WidgetImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.widget,model=org.apache.tuscany.sca.implementation.widget.WidgetImplementation
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.WidgetImplementationFactory b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.WidgetImplementationFactory
new file mode 100644
index 0000000000..633dda5675
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.WidgetImplementationFactory
@@ -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 model factory
+org.apache.tuscany.sca.implementation.widget.impl.WidgetImplementationFactoryImpl
diff --git a/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/impl-widget-validation-messages.properties b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/impl-widget-validation-messages.properties
new file mode 100644
index 0000000000..3778bd4c50
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/implementation-widget/src/main/resources/impl-widget-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+ContributionResolveException = ContributionResolveException occured due to:
+LocationAttributeMissing = Reading implementation.widget - location attribute missing
+CouldNotResolveLocation = Could not resolve implementation.widget location: {0}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/LICENSE b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/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/sebastien/java/embed/modules/interface-java-jaxrs/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f45e70ad23
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.interfacedef.java.jaxrs;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Java Interface for JAX-RS
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Java Interface for JAXWS
+Bundle-SymbolicName: org.apache.tuscany.sca.interface.java.jaxrs
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: javax.ws.rs,
+ org.apache.tuscany.sca.interfacedef,
+ org.apache.tuscany.sca.interfacedef.java,
+ org.apache.tuscany.sca.interfacedef.java.impl,
+ org.apache.tuscany.sca.interfacedef.java.introspect,
+ org.objectweb.asm;version="3.1.0"
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/NOTICE b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/pom.xml b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/pom.xml
new file mode 100644
index 0000000000..c6410c1c83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/pom.xml
@@ -0,0 +1,64 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-interface-java-jaxrs</artifactId>
+ <name>Apache Tuscany SCA Interface Java For JAX_RS</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>3.1</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java
new file mode 100644
index 0000000000..e1891e6c0b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/CodeGenerationHelper.java
@@ -0,0 +1,280 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxrs;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.asm.Opcodes;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CodeGenerationHelper {
+ /**
+ * @param type
+ * @return
+ */
+ public static Class<?> getErasure(Type type) {
+ if (type instanceof Class) {
+ return (Class<?>)type;
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType arrayType = (GenericArrayType)type;
+ Class<?> componentType = getErasure(arrayType.getGenericComponentType());
+ return Array.newInstance(componentType, 0).getClass();
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType)type;
+ return getErasure(pType.getRawType());
+ } else if (type instanceof WildcardType) {
+ WildcardType wType = (WildcardType)type;
+ Type[] types = wType.getUpperBounds();
+ if (types.length == 0) {
+ return Object.class;
+ }
+ return getErasure(types[0]);
+ } else if (type instanceof TypeVariable) {
+ TypeVariable<?> var = (TypeVariable<?>)type;
+ Type[] types = var.getBounds();
+ if (types.length == 0) {
+ return Object.class;
+ }
+ return getErasure(types[0]);
+ }
+ return null;
+ }
+
+ /**
+ * @param type
+ * @return
+ */
+ public static String getJAXWSSignature(Type type) {
+ Class<?> cls = getErasure(type);
+ if (Collection.class.isAssignableFrom(cls) && (type instanceof ParameterizedType)) {
+ ParameterizedType pType = (ParameterizedType)type;
+ Type p = pType.getActualTypeArguments()[0];
+ StringBuffer sb = new StringBuffer();
+ sb.append(getSignature(cls));
+ sb.deleteCharAt(sb.length() - 1); // Remove ;
+ sb.append('<').append(getSignature(getErasure(p))).append(">;");
+ return sb.toString();
+ } else if (Map.class.isAssignableFrom(cls) && (type instanceof ParameterizedType)) {
+ ParameterizedType pType = (ParameterizedType)type;
+ Type key = pType.getActualTypeArguments()[0];
+ Type value = pType.getActualTypeArguments()[1];
+ StringBuffer sb = new StringBuffer();
+ sb.append(getSignature(cls));
+ sb.deleteCharAt(sb.length() - 1); // Remove ;
+ sb.append('<').append(getSignature(getErasure(key))).append(getSignature(getErasure(value))).append(">;");
+ return sb.toString();
+ } else {
+ return getSignature(cls);
+ }
+ }
+
+ /**
+ * @param type
+ * @return
+ */
+ public static String getSignature(Type type) {
+ if (!(type instanceof Class)) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType)type;
+ StringBuffer sb = new StringBuffer();
+ String rawType = getSignature(pType.getRawType());
+ sb.append(rawType.substring(0, rawType.length() - 1));
+ sb.append('<');
+ for (Type t : pType.getActualTypeArguments()) {
+ String argType = getSignature(t);
+ sb.append(argType);
+ }
+ sb.append('>');
+ sb.append(rawType.substring(rawType.length() - 1));
+ return sb.toString();
+ }
+ if (type instanceof TypeVariable) {
+ return "T" + ((TypeVariable<?>)type).getName() + ";";
+ }
+ if (type instanceof GenericArrayType) {
+ GenericArrayType arrayType = (GenericArrayType)type;
+ return "[" + getSignature(arrayType.getGenericComponentType());
+ }
+ if (type instanceof WildcardType) {
+ WildcardType wType = (WildcardType)type;
+ Type[] types = wType.getUpperBounds();
+ StringBuffer sb = new StringBuffer();
+ if (types.length == 0 || !(types.length == 1 && types[0] == Object.class)) {
+ sb.append('+');
+ for (Type t : types) {
+ sb.append(getSignature(t));
+ }
+ }
+ types = wType.getLowerBounds();
+ if (types.length != 0) {
+ sb.append('-');
+ for (Type t : wType.getLowerBounds()) {
+ sb.append(getSignature(t));
+ }
+ }
+ if (sb.length() == 0) {
+ return "*";
+ }
+ return sb.toString();
+ }
+ }
+ Class<?> cls = (Class<?>)type;
+ return org.objectweb.asm.Type.getDescriptor(cls);
+ }
+
+ /**
+ * Get the actual type arguments a child class has used to extend a generic base class.
+ *
+ * @param baseClass the base class
+ * @param childClass the child class
+ * @return a list of the raw classes for the actual type arguments.
+ */
+ public static <T> List<Class<?>> resovleTypeArguments(Class<T> baseClass, Class<? extends T> childClass) {
+ Map<Type, Type> resolvedTypes = new HashMap<Type, Type>();
+ Type type = childClass;
+ // start walking up the inheritance hierarchy until we hit baseClass
+ while (!getErasure(type).equals(baseClass)) {
+ if (type instanceof Class) {
+ // there is no useful information for us in raw types, so just keep going.
+ type = ((Class<?>)type).getGenericSuperclass();
+ } else {
+ ParameterizedType parameterizedType = (ParameterizedType)type;
+ Class<?> rawType = getErasure(parameterizedType.getRawType());
+
+ Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
+ TypeVariable<?>[] typeParameters = rawType.getTypeParameters();
+ for (int i = 0; i < actualTypeArguments.length; i++) {
+ resolvedTypes.put(typeParameters[i], actualTypeArguments[i]);
+ }
+
+ if (!rawType.equals(baseClass)) {
+ type = rawType.getGenericSuperclass();
+ }
+ }
+ }
+
+ // finally, for each actual type argument provided to baseClass, determine (if possible)
+ // the raw class for that type argument.
+ Type[] actualTypeArguments;
+ if (type instanceof Class) {
+ actualTypeArguments = ((Class<?>)type).getTypeParameters();
+ } else {
+ actualTypeArguments = ((ParameterizedType)type).getActualTypeArguments();
+ }
+ List<Class<?>> typeArgumentsAsClasses = new ArrayList<Class<?>>();
+ // resolve types by chasing down type variables.
+ for (Type baseType : actualTypeArguments) {
+ while (resolvedTypes.containsKey(baseType)) {
+ baseType = resolvedTypes.get(baseType);
+ }
+ typeArgumentsAsClasses.add(getErasure(baseType));
+ }
+ return typeArgumentsAsClasses;
+ }
+
+ /*
+ signatures.put(boolean.class, "Z");
+ signatures.put(byte.class, "B");
+ signatures.put(char.class, "C");
+ signatures.put(short.class, "S");
+ signatures.put(int.class, "I");
+ signatures.put(long.class, "J");
+ signatures.put(float.class, "F");
+ signatures.put(double.class, "D");
+ */
+ public static int getLoadOPCode(String signature) {
+ if ("Z".equals(signature) || "B".equals(signature)
+ || "C".equals(signature)
+ || "S".equals(signature)
+ || "I".equals(signature)) {
+ return Opcodes.ILOAD;
+ }
+
+ if ("J".equals(signature)) {
+ return Opcodes.LLOAD;
+ }
+
+ if ("F".equals(signature)) {
+ return Opcodes.FLOAD;
+ }
+
+ if ("D".equals(signature)) {
+ return Opcodes.DLOAD;
+ }
+
+ return Opcodes.ALOAD;
+
+ }
+
+ public static int getReturnOPCode(String signature) {
+ if ("Z".equals(signature) || "B".equals(signature)
+ || "C".equals(signature)
+ || "S".equals(signature)
+ || "I".equals(signature)) {
+ return Opcodes.IRETURN;
+ }
+
+ if ("J".equals(signature)) {
+ return Opcodes.LRETURN;
+ }
+
+ if ("F".equals(signature)) {
+ return Opcodes.FRETURN;
+ }
+
+ if ("D".equals(signature)) {
+ return Opcodes.DRETURN;
+ }
+ if ("V".equals(signature)) {
+ return Opcodes.RETURN;
+ }
+
+ return Opcodes.ARETURN;
+
+ }
+
+ /**
+ * Get the package prefix for generated JAXWS artifacts
+ * @param cls
+ * @return
+ */
+ public static String getPackagePrefix(Class<?> cls) {
+ String name = cls.getName();
+ int index = name.lastIndexOf('.');
+ if (index == -1) {
+ return "jaxws.";
+ } else {
+ return name.substring(0, index) + ".jaxws.";
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/GeneratedClassLoader.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/GeneratedClassLoader.java
new file mode 100644
index 0000000000..b679f34835
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/GeneratedClassLoader.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.interfacedef.java.jaxrs;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+
+public class GeneratedClassLoader extends URLClassLoader {
+ private class GeneratedClass {
+ private String className;
+ private byte[] byteCode;
+ private Class<?> cls;
+
+ public GeneratedClass(String className, byte[] byteCode) {
+ super();
+ this.className = className;
+ this.byteCode = byteCode;
+ }
+
+ public synchronized Class<?> getGeneratedClass() {
+ if (cls == null) {
+ cls = defineClass(className, byteCode, 0, byteCode.length);
+ }
+ return cls;
+ }
+ }
+
+ private Map<String, GeneratedClass> generatedClasses = new HashMap<String, GeneratedClass>();
+
+ public GeneratedClassLoader(ClassLoader parentLoader) {
+ super(new URL[0], parentLoader);
+ }
+
+ @Override
+ protected Class<?> findClass(String className) throws ClassNotFoundException {
+ GeneratedClass cls = generatedClasses.get(className);
+ if (cls != null) {
+ return cls.getGeneratedClass();
+ }
+ return super.findClass(className);
+ }
+
+ public synchronized Class<?> getGeneratedClass(String className, byte[] byteCode) {
+ GeneratedClass cls = generatedClasses.get(className);
+ if (cls == null) {
+ cls = new GeneratedClass(className, byteCode);
+ generatedClasses.put(className, cls);
+ }
+ return cls.getGeneratedClass();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java
new file mode 100644
index 0000000000..83f88c98cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.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.sca.interfacedef.java.jaxrs;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.OPTIONS;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+
+public class JAXRSJavaInterfaceProcessor implements JavaInterfaceVisitor {
+ private static Map<String, Class<?>> mapping = new HashMap<String, Class<?>>();
+ static {
+ mapping.put(HttpMethod.GET, GET.class);
+ mapping.put(HttpMethod.POST, POST.class);
+ mapping.put(HttpMethod.PUT, PUT.class);
+ mapping.put(HttpMethod.DELETE, DELETE.class);
+ mapping.put(HttpMethod.HEAD, HEAD.class);
+ mapping.put(HttpMethod.OPTIONS, OPTIONS.class);
+ }
+
+ private boolean introspectHTTPMethod(JavaOperation operation) {
+ Method method = operation.getJavaMethod();
+
+ String methodName = null;
+
+ /**
+ * A request method designator is a runtime annotation that is annotated with the @HttpMethod annotation.
+ * JAX-RS defines a set of request method designators for the common HTTP methods: @GET, @POST, @PUT,
+ * @DELETE, @HEAD. Users may define their own custom request method designators including alternate
+ * designators for the common HTTP methods.
+ */
+ for (Annotation a : method.getAnnotations()) {
+ Class<?> annotationType = a.annotationType();
+ if (annotationType == HttpMethod.class) {
+ methodName = ((HttpMethod)a).value();
+ break;
+ }
+ // Http method related annotations such as @GET, @POST will have itself annotated with
+ // @HttpMethod
+ HttpMethod m = a.annotationType().getAnnotation(HttpMethod.class);
+ if (m != null) {
+ methodName = m.value();
+ break;
+ }
+ }
+
+ boolean jaxrs = false;
+ Class<?> type = mapping.get(methodName);
+ if (type != null) {
+ jaxrs = true;
+ operation.getAttributes().put(type, Boolean.TRUE);
+ Map<Object, Object> attrs = operation.getInterface().getAttributes();
+ List<Operation> operations = (List<Operation>)attrs.get(type);
+ if (operations == null) {
+ operations = new ArrayList<Operation>();
+ attrs.put(type, operations);
+ operations.add(operation);
+ } else {
+ operations.add(operation);
+ }
+ }
+
+ return jaxrs;
+
+ }
+
+ public void visitInterface(JavaInterface contract) throws InvalidInterfaceException {
+
+ boolean hasJAXRSAnnotarions = false;
+
+ for (Operation op : contract.getOperations()) {
+ final JavaOperation operation = (JavaOperation)op;
+ if (introspectHTTPMethod(operation)) {
+ hasJAXRSAnnotarions = true;
+ }
+ }
+
+ // Always set JAX-RS annotated interfaces as remotables
+ if (hasJAXRSAnnotarions) {
+ contract.setRemotable(true);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGenerator.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGenerator.java
new file mode 100644
index 0000000000..8ee34e79f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGenerator.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.sca.interfacedef.java.jaxrs;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+public class RootResourceClassGenerator implements Opcodes {
+
+ private static final String DELEGATE_FIELD = "delegate";
+
+ public static Class<?> generateRootResourceClass(Class<?> interfaze, String path, String consumes, String produces)
+ throws Exception {
+ if (!interfaze.isInterface()) {
+ throw new IllegalArgumentException(interfaze + " is not an interface.");
+ }
+ GeneratedClassLoader classLoader = new GeneratedClassLoader(interfaze.getClassLoader());
+ String interfaceName = interfaze.getName();
+ int index = interfaze.getName().lastIndexOf('.');
+ String className =
+ interfaceName.substring(0, index) + ".Generated" + interfaceName.substring(index + 1) + "Impl";
+
+ byte[] content = generate(interfaze, path, consumes, produces);
+ Class<?> cls = classLoader.getGeneratedClass(className, content);
+ return cls;
+ }
+
+ public static void injectProxy(Class<?> generatedResourceClass, Object proxy) throws Exception {
+ Field field = generatedResourceClass.getField("delegate");
+ field.set(null, proxy);
+ }
+
+ public static byte[] generate(Class<?> interfaze, String path, String consumes, String produces) throws Exception {
+ String interfaceName = Type.getInternalName(interfaze);
+ int index = interfaceName.lastIndexOf('/');
+ String className =
+ interfaceName.substring(0, index) + "/Generated" + interfaceName.substring(index + 1) + "Impl";
+
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+
+ declareClass(cw, interfaceName, className);
+
+ annotatePath(cw, path);
+ annotateContentTypes(cw, consumes, produces);
+ declareField(cw, interfaceName);
+ declareConstructor(cw, className);
+
+ for (Method method : interfaze.getMethods()) {
+ if (!(method.getDeclaringClass() == Object.class)) {
+ generateMethod(cw, interfaceName, className, method, consumes, produces);
+ }
+ }
+ cw.visitEnd();
+
+ return cw.toByteArray();
+ }
+
+ // public <ReturnType> method(<Type0> arg0, ..., <TypeN> argN) throws <ExpectionType0>, ..., <ExceptionTypeK>
+ private static void generateMethod(ClassWriter cw,
+ String interfaceName,
+ String className,
+ Method method,
+ String consumes,
+ String produces) {
+ String methodDescriptor = Type.getMethodDescriptor(method);
+
+ MethodVisitor mv =
+ cw.visitMethod(ACC_PUBLIC, method.getName(), methodDescriptor, null, getExceptionInternalNames(method));
+
+ mv.visitCode();
+ mv.visitFieldInsn(GETSTATIC, className, DELEGATE_FIELD, getSignature(interfaceName));
+ Class<?>[] paramTypes = method.getParameterTypes();
+ for (int i = 0; i < paramTypes.length; i++) {
+ String signature = Type.getDescriptor(paramTypes[i]);
+ mv.visitVarInsn(CodeGenerationHelper.getLoadOPCode(signature), i + 1);
+ }
+ mv.visitMethodInsn(INVOKEINTERFACE, interfaceName, method.getName(), methodDescriptor);
+
+ Class<?> returnType = method.getReturnType();
+ mv.visitInsn(CodeGenerationHelper.getReturnOPCode(Type.getDescriptor(returnType)));
+ int size = paramTypes.length + 1;
+ mv.visitMaxs(size, size);
+ mv.visitEnd();
+ }
+
+ private static String[] getExceptionInternalNames(Method method) {
+ Class<?>[] types = method.getExceptionTypes();
+ if (types.length == 0) {
+ return null;
+ }
+ String[] names = new String[types.length];
+ for (int i = 0; i < types.length; i++) {
+ names[i] = Type.getInternalName(types[i]);
+ }
+ return names;
+ }
+
+ private static String getSignature(String interfaceName) {
+ return "L" + interfaceName + ";";
+ }
+
+ private static void declareConstructor(ClassWriter cw, String className) {
+ MethodVisitor mv;
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ // mv.visitLineNumber(37, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+ mv.visitInsn(RETURN);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLocalVariable("this", getSignature(className), null, l0, l1, 0);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+
+ // public static <Interface> delegate;
+ private static void declareField(ClassWriter cw, String interfaceName) {
+ FieldVisitor fv =
+ cw.visitField(ACC_PUBLIC + ACC_STATIC, DELEGATE_FIELD, getSignature(interfaceName), null, null);
+ fv.visitEnd();
+ }
+
+ // public class _<Interface>Impl implements <Interface>
+ private static void declareClass(ClassWriter cw, String interfaceName, String className) {
+ cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, className, null, "java/lang/Object", new String[] {interfaceName});
+ }
+
+ // @Path(<path>)
+ private static void annotatePath(ClassWriter cw, String path) {
+ AnnotationVisitor av = cw.visitAnnotation("Ljavax/ws/rs/Path;", true);
+ av.visit("value", path);
+ av.visitEnd();
+ }
+
+ // @Consumes(<contentTypes>)
+ // @Provides(<contentTypes>)
+ private static void annotateContentTypes(ClassWriter cw, String consumes, String produces) {
+ AnnotationVisitor av = null;
+ if (consumes != null) {
+ av = cw.visitAnnotation("Ljavax/ws/rs/Consumes;", true);
+ AnnotationVisitor av1 = av.visitArray("value");
+ for (String s : consumes.split("(,| )")) {
+ av1.visit(null, s.trim());
+ }
+ av1.visitEnd();
+ av.visitEnd();
+ }
+ if (produces != null) {
+ av = cw.visitAnnotation("Ljavax/ws/rs/Produces;", true);
+ AnnotationVisitor av1 = av.visitArray("value");
+ for (String s : produces.split("(,| )")) {
+ av1.visit(null, s.trim());
+ }
+ av1.visitEnd();
+ av.visitEnd();
+ }
+ }
+
+ // @Consumes(<contentTypes>)
+ // @Provides(<contentTypes>)
+ private static void annotateContentTypes(MethodVisitor mv, String consumes, String produces) {
+ AnnotationVisitor av = null;
+ if (consumes != null) {
+ av = mv.visitAnnotation("Ljavax/ws/rs/Consumes;", true);
+ AnnotationVisitor av1 = av.visitArray("value");
+ for (String s : consumes.split("(,| )")) {
+ av1.visit(null, s.trim());
+ }
+ av1.visitEnd();
+ av.visitEnd();
+ }
+ if (produces != null) {
+ av = mv.visitAnnotation("Ljavax/ws/rs/Produces;", true);
+ AnnotationVisitor av1 = av.visitArray("value");
+ for (String s : produces.split("(,| )")) {
+ av1.visit(null, s.trim());
+ }
+ av1.visitEnd();
+ av.visitEnd();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
new file mode 100644
index 0000000000..9101d744b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.java.jaxrs.JAXRSJavaInterfaceProcessor;ranking=100
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/Bean.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/Bean.java
new file mode 100644
index 0000000000..20a4276b8b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/Bean.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.sca.interfacedef.java.jaxrs;
+
+import javax.ws.rs.GET;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Bean {
+
+ @GET
+ String[] get();
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSInterfaceProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSInterfaceProcessorTestCase.java
new file mode 100644
index 0000000000..b680eaa491
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSInterfaceProcessorTestCase.java
@@ -0,0 +1,66 @@
+package org.apache.tuscany.sca.interfacedef.java.jaxrs;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import javax.ws.rs.GET;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class JAXRSInterfaceProcessorTestCase {
+ private ExtensionPointRegistry registry;
+
+ @Before
+ public void setUp() throws Exception {
+ registry = new DefaultExtensionPointRegistry();
+ }
+
+ @Test
+ public final void testProcessor() throws Exception {
+ DefaultJavaInterfaceFactory iFactory = new DefaultJavaInterfaceFactory(registry);
+ JavaInterface contract = iFactory.createJavaInterface(Bean.class);
+
+ assertTrue(contract.isRemotable());
+
+ Assert.assertEquals(1,contract.getOperations().size());
+
+ List<Operation> getOperations = (List<Operation>) contract.getAttributes().get(GET.class);
+ Assert.assertEquals(1,getOperations.size());
+
+ //list operation
+ System.out.println(">>> JAX-RS Operations");
+ for(Operation o : contract.getOperations()) {
+ System.out.println(">>>>>>" + o);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/MockedResource.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/MockedResource.java
new file mode 100644
index 0000000000..46d501d4be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/MockedResource.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.java.jaxrs;
+
+public class MockedResource implements Resource {
+ private String value;
+
+ public MockedResource() {
+ super();
+ }
+
+ public String get() {
+ return value;
+ }
+
+ public void create(String value) {
+ this.value = value;
+ }
+
+ public void delete() {
+ value = null;
+ }
+
+ public void update(String value) {
+ this.value = value;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/Resource.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/Resource.java
new file mode 100644
index 0000000000..ac9fd514bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/Resource.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.java.jaxrs;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Resource {
+
+ @GET
+ String get();
+
+ @PUT
+ void update(String value);
+
+ @POST
+ void create(String value);
+
+ @DELETE
+ void delete();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/ResourceWrapper.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/ResourceWrapper.java
new file mode 100644
index 0000000000..23b674778e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/ResourceWrapper.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.sca.interfacedef.java.jaxrs;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+
+@Path("myURI")
+@Produces({"application/xml", "application/json"})
+@Consumes({"application/xml", "application/json"})
+public class ResourceWrapper implements Resource {
+ public static Resource delegate;
+
+ public ResourceWrapper() {
+ super();
+ }
+
+
+ public String get() {
+ return delegate.get();
+ }
+
+ public void create(String value) {
+ delegate.create(value);
+ }
+
+ public void delete() {
+ delegate.delete();
+ }
+
+ public void update(String value) {
+ delegate.update(value);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGeneratorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGeneratorTestCase.java
new file mode 100644
index 0000000000..aa6abcd5f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGeneratorTestCase.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxrs;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class RootResourceClassGeneratorTestCase {
+ @Test
+ public void testGenerator() throws Exception {
+ Class<?> cls = RootResourceClassGenerator.generateRootResourceClass(Resource.class, "myURI", "application/xml,application/json", "application/xml,application/json");
+ Assert.assertTrue(cls.isAnnotationPresent(Path.class));
+ Path path = cls.getAnnotation(Path.class);
+ Assert.assertEquals("myURI", path.value());
+
+ Produces produces = cls.getAnnotation(Produces.class);
+ Assert.assertEquals("application/xml", produces.value()[0]);
+
+ Consumes consumes = cls.getAnnotation(Consumes.class);
+ Assert.assertEquals("application/json", consumes.value()[1]);
+
+ Field field = cls.getField("delegate");
+ Assert.assertSame(Resource.class, field.getType());
+
+ Assert.assertTrue(Modifier.isPublic(field.getModifiers()));
+ Assert.assertTrue(Modifier.isStatic(field.getModifiers()));
+
+ Assert.assertTrue(Resource.class.isAssignableFrom(cls));
+
+ Resource resource = new MockedResource();
+ field.set(null, resource);
+
+ Resource resourceProxy = (Resource)cls.newInstance();
+ Assert.assertNull(resourceProxy.get());
+ resourceProxy.create("123");
+ Assert.assertEquals("123", resourceProxy.get());
+ resourceProxy.update("ABC");
+ Assert.assertEquals("ABC", resourceProxy.get());
+ resourceProxy.delete();
+ Assert.assertNull(resourceProxy.get());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/LICENSE b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/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/sebastien/java/embed/modules/interface-java-jaxws/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5c36422a33
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/META-INF/MANIFEST.MF
@@ -0,0 +1,49 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.interfacedef.java.jaxws;uses:="
+ org.apache.tuscany.sca.databinding,org.apache.tuscany.sca.interfacede
+ f.util,org.objectweb.asm,javax.jws,javax.xml.namespace,javax.jws.soap
+ ,org.apache.tuscany.sca.interfacedef.java.impl,org.apache.tuscany.sca
+ .databinding.annotation,org.oasisopen.sca,javax.xml.bind.annotation.adapte
+ rs,org.apache.tuscany.sca.interfacedef.java,org.apache.tuscany.sca.in
+ terfacedef,org.apache.tuscany.sca.interfacedef.java.introspect,javax.
+ xml.bind.annotation,org.apache.tuscany.sca.databinding.jaxb,org.apach
+ e.tuscany.sca.interfacedef.impl,javax.xml.ws";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Java Interface for JAXWS
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Java Interface for JAXWS
+Import-Package: javax.jws,
+ javax.jws.soap,
+ javax.xml.bind;resolution:=optional,
+ javax.xml.bind.annotation,
+ javax.xml.bind.annotation.adapters,
+ javax.xml.namespace,
+ javax.xml.stream;resolution:=optional,
+ javax.xml.transform;resolution:=optional,
+ javax.xml.transform.stream;resolution:=optional,
+ javax.xml.ws,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.annotation;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.databinding.jaxb;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.jaxws;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.objectweb.asm;version="3.1",
+ org.objectweb.asm.util;version="3.1";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.interface.java.jaxws
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/NOTICE b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/pom.xml b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/pom.xml
new file mode 100644
index 0000000000..a1e93fd077
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/pom.xml
@@ -0,0 +1,281 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <name>Apache Tuscany SCA Interface Java For JAXWS</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-util</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-analysis</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxws-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>1.12</version>
+ <!-- Explicitly add the transitive dependencies for jaxws-api
+ http://jira.codehaus.org/browse/MEV-498
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>wsimport</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>wsimport</goal>
+ </goals>
+ <configuration>
+ <packageName>com.example.stock</packageName>
+ <wsdlDirectory>${basedir}/src/test/resources/wsdl</wsdlDirectory>
+ <wsdlFiles>
+ <wsdlFile>StockExceptionTest.wsdl</wsdlFile>
+ </wsdlFiles>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ <verbose>false</verbose>
+ <xnocompile>true</xnocompile>
+ </configuration>
+ </execution>
+
+ <!--
+ <execution>
+ <id>wsgen</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>wsgen-test</goal>
+ </goals>
+ <configuration>
+ <sei>org.apache.tuscany.sca.interfacedef.java.jaxws.MyServiceImpl</sei>
+ <genWsdl>true</genWsdl>
+ <keep>true</keep>
+ <resourceDestDir>${project.build.directory}/jaxws-source</resourceDestDir>
+ <sourceDestDir>${project.build.directory}/jaxws-source</sourceDestDir>
+ </configuration>
+ </execution>
+ -->
+ </executions>
+
+ </plugin>
+
+ <!--
+ wsimport cannot handle WSDL files without a service/binding element.
+ CXF wsdl2java plugin does support that. I had to override the default
+ value of wsdlRoot/testWsdlRoot to a non-existent file to avoid NPE -->
+ <!--
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+
+ <configuration>
+ <sourceRoot>${basedir}/target/jaxws-source</sourceRoot>
+ <wsdlRoot>NONE</wsdlRoot>
+ <testWsdlRoot>NONE</testWsdlRoot>
+ <wsdlOptions>
+ <wsdlOption>
+ <wsdl>${basedir}/src/test/resources/wsdl/Stock.wsdl</wsdl>
+ <outputDir>${basedir}/target/jaxws-source</outputDir>
+ <packagenames>
+ <packagename>com.example.stock.cxf</packagename>
+ </packagenames>
+ </wsdlOption>
+ </wsdlOptions>
+ </configuration>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java
new file mode 100644
index 0000000000..6c64ad0689
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java
@@ -0,0 +1,542 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.xml.bind.annotation.XmlAttachmentRef;
+import javax.xml.bind.annotation.XmlList;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.ws.Holder;
+
+import org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+public abstract class BaseBeanGenerator implements Opcodes {
+ private static final Map<String, String> COLLECTION_CLASSES = new HashMap<String, String>();
+ static {
+ COLLECTION_CLASSES.put("Ljava/util/Collection;", "java/util/ArrayList");
+ COLLECTION_CLASSES.put("Ljava/util/List;", "java/util/ArrayList");
+ COLLECTION_CLASSES.put("Ljava/util/Set;", "java/util/HashSet");
+ COLLECTION_CLASSES.put("Ljava/util/Queue;", "java/util/LinkedList");
+ }
+ private final static Class[] KNOWN_JAXB_ANNOTATIONS =
+ {XmlAttachmentRef.class, XmlMimeType.class, XmlJavaTypeAdapter.class, XmlList.class};
+ private static final Map<String, String> JAVA_KEYWORDS = new HashMap<String, String>();
+
+ static {
+ JAVA_KEYWORDS.put("abstract", "_abstract");
+ JAVA_KEYWORDS.put("assert", "_assert");
+ JAVA_KEYWORDS.put("boolean", "_boolean");
+ JAVA_KEYWORDS.put("break", "_break");
+ JAVA_KEYWORDS.put("byte", "_byte");
+ JAVA_KEYWORDS.put("case", "_case");
+ JAVA_KEYWORDS.put("catch", "_catch");
+ JAVA_KEYWORDS.put("char", "_char");
+ JAVA_KEYWORDS.put("class", "_class");
+ JAVA_KEYWORDS.put("const", "_const");
+ JAVA_KEYWORDS.put("continue", "_continue");
+ JAVA_KEYWORDS.put("default", "_default");
+ JAVA_KEYWORDS.put("do", "_do");
+ JAVA_KEYWORDS.put("double", "_double");
+ JAVA_KEYWORDS.put("else", "_else");
+ JAVA_KEYWORDS.put("extends", "_extends");
+ JAVA_KEYWORDS.put("false", "_false");
+ JAVA_KEYWORDS.put("final", "_final");
+ JAVA_KEYWORDS.put("finally", "_finally");
+ JAVA_KEYWORDS.put("float", "_float");
+ JAVA_KEYWORDS.put("for", "_for");
+ JAVA_KEYWORDS.put("goto", "_goto");
+ JAVA_KEYWORDS.put("if", "_if");
+ JAVA_KEYWORDS.put("implements", "_implements");
+ JAVA_KEYWORDS.put("import", "_import");
+ JAVA_KEYWORDS.put("instanceof", "_instanceof");
+ JAVA_KEYWORDS.put("int", "_int");
+ JAVA_KEYWORDS.put("interface", "_interface");
+ JAVA_KEYWORDS.put("long", "_long");
+ JAVA_KEYWORDS.put("native", "_native");
+ JAVA_KEYWORDS.put("new", "_new");
+ JAVA_KEYWORDS.put("null", "_null");
+ JAVA_KEYWORDS.put("package", "_package");
+ JAVA_KEYWORDS.put("private", "_private");
+ JAVA_KEYWORDS.put("protected", "_protected");
+ JAVA_KEYWORDS.put("public", "_public");
+ JAVA_KEYWORDS.put("return", "_return");
+ JAVA_KEYWORDS.put("short", "_short");
+ JAVA_KEYWORDS.put("static", "_static");
+ JAVA_KEYWORDS.put("strictfp", "_strictfp");
+ JAVA_KEYWORDS.put("super", "_super");
+ JAVA_KEYWORDS.put("switch", "_switch");
+ JAVA_KEYWORDS.put("synchronized", "_synchronized");
+ JAVA_KEYWORDS.put("this", "_this");
+ JAVA_KEYWORDS.put("throw", "_throw");
+ JAVA_KEYWORDS.put("throws", "_throws");
+ JAVA_KEYWORDS.put("transient", "_transient");
+ JAVA_KEYWORDS.put("true", "_true");
+ JAVA_KEYWORDS.put("try", "_try");
+ JAVA_KEYWORDS.put("void", "_void");
+ JAVA_KEYWORDS.put("volatile", "_volatile");
+ JAVA_KEYWORDS.put("while", "_while");
+ JAVA_KEYWORDS.put("enum", "_enum");
+ }
+
+ protected static final Map<Object, Class<?>> generatedClasses =
+ Collections.synchronizedMap(new WeakHashMap<Object, Class<?>>());
+
+ protected XMLAdapterExtensionPoint xmlAdapters;
+
+ public byte[] defineClass(ClassWriter cw,
+ String classDescriptor,
+ String classSignature,
+ String namespace,
+ String name,
+ BeanProperty[] properties) {
+ // Declare the class
+ declareClass(cw, classDescriptor);
+
+ // Compute the propOrder
+ String[] propOrder = null;
+ if (properties != null && properties.length > 0) {
+ int size = properties.length;
+ propOrder = new String[size];
+ for (int i = 0; i < size; i++) {
+ propOrder[i] = getFieldName(properties[i].getName());
+ }
+ }
+ // Annotate the class
+ annotateClass(cw, name, namespace, propOrder);
+
+ // Decalre the default constructor
+ declareConstructor(cw, classSignature);
+ if (properties != null) {
+ for (BeanProperty p : properties) {
+ boolean isElement = p.isElement() && (!Map.class.isAssignableFrom(p.getType()));
+ String xmlAdapterClassSignature = null;
+ if (xmlAdapters != null) {
+ Class<?> adapterClass = xmlAdapters.getAdapter(p.getType());
+ if (adapterClass != null) {
+ xmlAdapterClassSignature = CodeGenerationHelper.getSignature(adapterClass);
+ }
+ }
+ declareProperty(cw, classDescriptor, classSignature, p.getName(), p.getSignature(), p
+ .getGenericSignature(), isElement, p.isNillable(), xmlAdapterClassSignature, p.getJaxbAnnotaions());
+ }
+ }
+
+ // Close the generation
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
+ protected static boolean isHolder(java.lang.reflect.Type type) {
+ if (type instanceof ParameterizedType) {
+ Class<?> cls = CodeGenerationHelper.getErasure(type);
+ return cls == Holder.class;
+ }
+ return false;
+ }
+
+ protected static java.lang.reflect.Type getHolderValueType(java.lang.reflect.Type paramType) {
+ if (paramType instanceof ParameterizedType) {
+ ParameterizedType p = (ParameterizedType)paramType;
+ Class<?> cls = CodeGenerationHelper.getErasure(p);
+ if (cls == Holder.class) {
+ return p.getActualTypeArguments()[0];
+ }
+ }
+ return paramType;
+ }
+
+ protected void declareProperty(ClassWriter cw,
+ String classDescriptor,
+ String classSignature,
+ String propName,
+ String propClassSignature,
+ String propTypeSignature,
+ boolean isElement,
+ boolean isNillable,
+ String xmlAdapterClassSignature,
+ List<Annotation> jaxbAnnotations) {
+ if (propClassSignature.equals(propTypeSignature)) {
+ propTypeSignature = null;
+ }
+ declareField(cw,
+ propName,
+ propClassSignature,
+ propTypeSignature,
+ isElement,
+ isNillable,
+ xmlAdapterClassSignature,
+ jaxbAnnotations);
+ decalreGetter(cw, classDescriptor, classSignature, propName, propClassSignature, propTypeSignature);
+ declareSetter(cw, classDescriptor, classSignature, propName, propClassSignature, propTypeSignature);
+ }
+
+ protected String getFieldName(String propName) {
+ String name = JAVA_KEYWORDS.get(propName);
+ return name != null ? name : propName;
+ }
+
+ protected void declareField(ClassWriter cw,
+ String propName,
+ String propClassSignature,
+ String propTypeSignature,
+ boolean isElement,
+ boolean isNillable,
+ String xmlAdapterClassSignature,
+ List<Annotation> jaxbAnnotations) {
+ FieldVisitor fv;
+ AnnotationVisitor av0;
+ fv = cw.visitField(ACC_PROTECTED, getFieldName(propName), propClassSignature, propTypeSignature, null);
+
+ // For Map property, we cannot have the XmlElement annotation
+ if (isElement && xmlAdapterClassSignature == null) {
+ av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
+ av0.visit("name", propName);
+ av0.visit("namespace", "");
+ if (isNillable) {
+ av0.visit("nillable", Boolean.TRUE);
+ }
+ // FIXME:
+ // av0.visit("required", Boolean.FALSE);
+ av0.visitEnd();
+ }
+
+ if (xmlAdapterClassSignature != null) {
+ av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAnyElement;", true);
+ av0.visit("lax", Boolean.TRUE);
+ av0.visitEnd();
+ av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
+ av0.visit("value", org.objectweb.asm.Type.getType(xmlAdapterClassSignature));
+ av0.visitEnd();
+ }
+
+ for (Annotation ann : jaxbAnnotations) {
+ if (ann instanceof XmlMimeType) {
+ AnnotationVisitor mime = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlMimeType;", true);
+ mime.visit("value", ((XmlMimeType)ann).value());
+ mime.visitEnd();
+ } else if (ann instanceof XmlJavaTypeAdapter) {
+ AnnotationVisitor ada = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
+ ada.visit("value", org.objectweb.asm.Type.getType(((XmlJavaTypeAdapter)ann).value()));
+ ada.visit("type", org.objectweb.asm.Type.getType(((XmlJavaTypeAdapter)ann).type()));
+ ada.visitEnd();
+ } else if (ann instanceof XmlAttachmentRef) {
+ AnnotationVisitor att = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAttachmentRef;", true);
+ att.visitEnd();
+ } else if (ann instanceof XmlList) {
+ AnnotationVisitor list = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
+ list.visitEnd();
+ }
+ }
+
+ fv.visitEnd();
+ }
+
+ protected void declareSetter(ClassWriter cw,
+ String classDescriptor,
+ String classSignature,
+ String propName,
+ String propClassSignature,
+ String propTypeSignature) {
+ if ("Ljava/util/List;".equals(propClassSignature)) {
+ return;
+ }
+ MethodVisitor mv =
+ cw.visitMethod(ACC_PUBLIC,
+ "set" + capitalize(propName),
+ "(" + propClassSignature + ")V",
+ propTypeSignature == null ? null : "(" + propTypeSignature + ")V",
+ null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ // mv.visitLineNumber(57, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(CodeGenerationHelper.getLoadOPCode(propClassSignature), 1);
+ mv.visitFieldInsn(PUTFIELD, classDescriptor, getFieldName(propName), propClassSignature);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ // mv.visitLineNumber(58, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", classSignature, null, l0, l2, 0);
+ mv.visitLocalVariable(getFieldName(propName), propClassSignature, propTypeSignature, l0, l2, 1);
+ mv.visitMaxs(3, 3);
+ mv.visitEnd();
+
+ }
+
+ protected void decalreGetter(ClassWriter cw,
+ String classDescriptor,
+ String classSignature,
+ String propName,
+ String propClassSignature,
+ String propTypeSignature) {
+ String collectionImplClass = COLLECTION_CLASSES.get(propClassSignature);
+ if (collectionImplClass != null) {
+ decalreCollectionGetter(cw,
+ classDescriptor,
+ classSignature,
+ propName,
+ propClassSignature,
+ propTypeSignature,
+ collectionImplClass);
+ return;
+ }
+
+ String getterName = ("Z".equals(propClassSignature) ? "is" : "get") + capitalize(propName);
+ MethodVisitor mv =
+ cw.visitMethod(ACC_PUBLIC, getterName, "()" + propClassSignature, propTypeSignature == null ? null
+ : "()" + propTypeSignature, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ // mv.visitLineNumber(48, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitFieldInsn(GETFIELD, classDescriptor, getFieldName(propName), propClassSignature);
+ mv.visitInsn(CodeGenerationHelper.getReturnOPCode(propClassSignature));
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLocalVariable("this", classSignature, null, l0, l1, 0);
+ mv.visitMaxs(2, 1);
+ mv.visitEnd();
+ }
+
+ protected void decalreCollectionGetter(ClassWriter cw,
+ String classDescriptor,
+ String classSignature,
+ String propName,
+ String propClassSignature,
+ String propTypeSignature,
+ String collectionImplClass) {
+ String getterName = "get" + capitalize(propName);
+ String fieldName = getFieldName(propName);
+ MethodVisitor mv =
+ cw.visitMethod(ACC_PUBLIC, getterName, "()" + propClassSignature, propTypeSignature == null ? null
+ : "()" + propTypeSignature, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(63, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitFieldInsn(GETFIELD, classDescriptor, fieldName, propClassSignature);
+ Label l1 = new Label();
+ mv.visitJumpInsn(IFNONNULL, l1);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLineNumber(64, l2);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitTypeInsn(NEW, collectionImplClass);
+ mv.visitInsn(DUP);
+ mv.visitMethodInsn(INVOKESPECIAL, collectionImplClass, "<init>", "()V");
+ mv.visitFieldInsn(PUTFIELD, classDescriptor, fieldName, propClassSignature);
+ mv.visitLabel(l1);
+ mv.visitLineNumber(66, l1);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitFieldInsn(GETFIELD, classDescriptor, fieldName, propClassSignature);
+ mv.visitInsn(ARETURN);
+ Label l3 = new Label();
+ mv.visitLabel(l3);
+ mv.visitLocalVariable("this", classSignature, null, l0, l3, 0);
+ mv.visitMaxs(3, 1);
+ mv.visitEnd();
+ }
+
+ protected static String capitalize(String name) {
+ if (name == null || name.length() == 0) {
+ return name;
+ } else {
+ return Character.toUpperCase(name.charAt(0)) + name.substring(1);
+ }
+ }
+
+ protected void declareConstructor(ClassWriter cw, String classSignature) {
+ MethodVisitor mv;
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ // mv.visitLineNumber(37, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+ mv.visitInsn(RETURN);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLocalVariable("this", classSignature, null, l0, l1, 0);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+
+ protected void declareClass(ClassWriter cw, String classDescriptor) {
+ cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, classDescriptor, null, "java/lang/Object", null);
+ }
+
+ protected void annotateClass(ClassWriter cw, String name, String namespace, String[] propOrder) {
+ AnnotationVisitor av0;
+ // @XmlRootElement
+ av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlRootElement;", true);
+ av0.visit("name", name);
+ av0.visit("namespace", namespace);
+ av0.visitEnd();
+ // @XmlAccessorType
+ av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlAccessorType;", true);
+ av0.visitEnum("value", "Ljavax/xml/bind/annotation/XmlAccessType;", "FIELD");
+ av0.visitEnd();
+ // @XmlType
+ av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlType;", true);
+ av0.visit("name", name);
+ av0.visit("namespace", namespace);
+ if (propOrder != null) {
+ AnnotationVisitor pv = av0.visitArray("propOrder");
+ for (String p : propOrder) {
+ pv.visit(null, p);
+ }
+ pv.visitEnd();
+ }
+ av0.visitEnd();
+ }
+
+ public Class<?> generate(String classDescriptor,
+ String classSignature,
+ String namespace,
+ String name,
+ BeanProperty[] properties,
+ GeneratedClassLoader classLoader) {
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+ byte[] byteCode = defineClass(cw, classDescriptor, classSignature, namespace, name, properties);
+ String className = classDescriptor.replace('/', '.');
+ Class<?> generated = classLoader.getGeneratedClass(className, byteCode);
+ return generated;
+ }
+
+ public static class BeanProperty {
+ private Class<?> type;
+ private String namespace;
+ private String name;
+ private String signature;
+ private String genericSignature;
+ private List<Annotation> jaxbAnnotaions = new ArrayList<Annotation>();
+ private boolean element;
+ private boolean nillable;
+
+ public BeanProperty(String namespace, String name, Class<?> javaClass, Type type, boolean isElement) {
+ super();
+ this.namespace = namespace;
+ this.name = name;
+ this.signature = CodeGenerationHelper.getJAXWSSignature(javaClass);
+ this.type = javaClass;
+ this.genericSignature = CodeGenerationHelper.getJAXWSSignature(type);
+ this.element = isElement;
+ // FIXME: How to test nillable?
+ // this.nillable = (type instanceof GenericArrayType) || Collection.class.isAssignableFrom(javaClass) || javaClass.isArray();
+ // TUSCANY-2389: Set the nillable consistent with what wsgen produces
+ this.nillable = javaClass.isArray();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSignature() {
+ return signature;
+ }
+
+ public String getGenericSignature() {
+ return genericSignature;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public List<Annotation> getJaxbAnnotaions() {
+ return jaxbAnnotaions;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public boolean isElement() {
+ return element;
+ }
+
+ public boolean isNillable() {
+ return nillable;
+ }
+ }
+
+ public XMLAdapterExtensionPoint getXmlAdapters() {
+ return xmlAdapters;
+ }
+
+ public void setXmlAdapters(XMLAdapterExtensionPoint xmlAdapters) {
+ this.xmlAdapters = xmlAdapters;
+ }
+
+ protected static <T extends Annotation> T findAnnotation(Annotation[] anns, Class<T> annotationClass) {
+ for (Annotation a : anns) {
+ if (a.annotationType() == annotationClass) {
+ return annotationClass.cast(a);
+ }
+ }
+ return null;
+ }
+
+ protected static List<Annotation> findJAXBAnnotations(Annotation[] anns) {
+ List<Annotation> jaxbAnnotation = new ArrayList<Annotation>();
+ for (Class<? extends Annotation> c : KNOWN_JAXB_ANNOTATIONS) {
+ Annotation a = findAnnotation(anns, c);
+ if (a != null) {
+ jaxbAnnotation.add(a);
+ }
+ }
+ return jaxbAnnotation;
+ }
+
+ protected List<Annotation> findJAXBAnnotations(Method method) {
+ List<Annotation> anns = new ArrayList<Annotation>();
+ for (Class<? extends Annotation> c : KNOWN_JAXB_ANNOTATIONS) {
+ Annotation ann = method.getAnnotation(c);
+ if (ann != null) {
+ anns.add(ann);
+ }
+ }
+ return anns;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
new file mode 100644
index 0000000000..b05715b54e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
@@ -0,0 +1,280 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.asm.Opcodes;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CodeGenerationHelper {
+ /**
+ * @param type
+ * @return
+ */
+ public static Class<?> getErasure(Type type) {
+ if (type instanceof Class) {
+ return (Class<?>)type;
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType arrayType = (GenericArrayType)type;
+ Class<?> componentType = getErasure(arrayType.getGenericComponentType());
+ return Array.newInstance(componentType, 0).getClass();
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType)type;
+ return getErasure(pType.getRawType());
+ } else if (type instanceof WildcardType) {
+ WildcardType wType = (WildcardType)type;
+ Type[] types = wType.getUpperBounds();
+ if (types.length == 0) {
+ return Object.class;
+ }
+ return getErasure(types[0]);
+ } else if (type instanceof TypeVariable) {
+ TypeVariable<?> var = (TypeVariable<?>)type;
+ Type[] types = var.getBounds();
+ if (types.length == 0) {
+ return Object.class;
+ }
+ return getErasure(types[0]);
+ }
+ return null;
+ }
+
+ /**
+ * @param type
+ * @return
+ */
+ public static String getJAXWSSignature(Type type) {
+ Class<?> cls = getErasure(type);
+ if (Collection.class.isAssignableFrom(cls) && (type instanceof ParameterizedType)) {
+ ParameterizedType pType = (ParameterizedType)type;
+ Type p = pType.getActualTypeArguments()[0];
+ StringBuffer sb = new StringBuffer();
+ sb.append(getSignature(cls));
+ sb.deleteCharAt(sb.length() - 1); // Remove ;
+ sb.append('<').append(getSignature(getErasure(p))).append(">;");
+ return sb.toString();
+ } else if (Map.class.isAssignableFrom(cls) && (type instanceof ParameterizedType)) {
+ ParameterizedType pType = (ParameterizedType)type;
+ Type key = pType.getActualTypeArguments()[0];
+ Type value = pType.getActualTypeArguments()[1];
+ StringBuffer sb = new StringBuffer();
+ sb.append(getSignature(cls));
+ sb.deleteCharAt(sb.length() - 1); // Remove ;
+ sb.append('<').append(getSignature(getErasure(key))).append(getSignature(getErasure(value))).append(">;");
+ return sb.toString();
+ } else {
+ return getSignature(cls);
+ }
+ }
+
+ /**
+ * @param type
+ * @return
+ */
+ public static String getSignature(Type type) {
+ if (!(type instanceof Class)) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pType = (ParameterizedType)type;
+ StringBuffer sb = new StringBuffer();
+ String rawType = getSignature(pType.getRawType());
+ sb.append(rawType.substring(0, rawType.length() - 1));
+ sb.append('<');
+ for (Type t : pType.getActualTypeArguments()) {
+ String argType = getSignature(t);
+ sb.append(argType);
+ }
+ sb.append('>');
+ sb.append(rawType.substring(rawType.length() - 1));
+ return sb.toString();
+ }
+ if (type instanceof TypeVariable) {
+ return "T" + ((TypeVariable<?>)type).getName() + ";";
+ }
+ if (type instanceof GenericArrayType) {
+ GenericArrayType arrayType = (GenericArrayType)type;
+ return "[" + getSignature(arrayType.getGenericComponentType());
+ }
+ if (type instanceof WildcardType) {
+ WildcardType wType = (WildcardType)type;
+ Type[] types = wType.getUpperBounds();
+ StringBuffer sb = new StringBuffer();
+ if (types.length == 0 || !(types.length == 1 && types[0] == Object.class)) {
+ sb.append('+');
+ for (Type t : types) {
+ sb.append(getSignature(t));
+ }
+ }
+ types = wType.getLowerBounds();
+ if (types.length != 0) {
+ sb.append('-');
+ for (Type t : wType.getLowerBounds()) {
+ sb.append(getSignature(t));
+ }
+ }
+ if (sb.length() == 0) {
+ return "*";
+ }
+ return sb.toString();
+ }
+ }
+ Class<?> cls = (Class<?>)type;
+ return org.objectweb.asm.Type.getDescriptor(cls);
+ }
+
+ /**
+ * Get the actual type arguments a child class has used to extend a generic base class.
+ *
+ * @param baseClass the base class
+ * @param childClass the child class
+ * @return a list of the raw classes for the actual type arguments.
+ */
+ public static <T> List<Class<?>> resovleTypeArguments(Class<T> baseClass, Class<? extends T> childClass) {
+ Map<Type, Type> resolvedTypes = new HashMap<Type, Type>();
+ Type type = childClass;
+ // start walking up the inheritance hierarchy until we hit baseClass
+ while (!getErasure(type).equals(baseClass)) {
+ if (type instanceof Class) {
+ // there is no useful information for us in raw types, so just keep going.
+ type = ((Class<?>)type).getGenericSuperclass();
+ } else {
+ ParameterizedType parameterizedType = (ParameterizedType)type;
+ Class<?> rawType = getErasure(parameterizedType.getRawType());
+
+ Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
+ TypeVariable<?>[] typeParameters = rawType.getTypeParameters();
+ for (int i = 0; i < actualTypeArguments.length; i++) {
+ resolvedTypes.put(typeParameters[i], actualTypeArguments[i]);
+ }
+
+ if (!rawType.equals(baseClass)) {
+ type = rawType.getGenericSuperclass();
+ }
+ }
+ }
+
+ // finally, for each actual type argument provided to baseClass, determine (if possible)
+ // the raw class for that type argument.
+ Type[] actualTypeArguments;
+ if (type instanceof Class) {
+ actualTypeArguments = ((Class<?>)type).getTypeParameters();
+ } else {
+ actualTypeArguments = ((ParameterizedType)type).getActualTypeArguments();
+ }
+ List<Class<?>> typeArgumentsAsClasses = new ArrayList<Class<?>>();
+ // resolve types by chasing down type variables.
+ for (Type baseType : actualTypeArguments) {
+ while (resolvedTypes.containsKey(baseType)) {
+ baseType = resolvedTypes.get(baseType);
+ }
+ typeArgumentsAsClasses.add(getErasure(baseType));
+ }
+ return typeArgumentsAsClasses;
+ }
+
+ /*
+ signatures.put(boolean.class, "Z");
+ signatures.put(byte.class, "B");
+ signatures.put(char.class, "C");
+ signatures.put(short.class, "S");
+ signatures.put(int.class, "I");
+ signatures.put(long.class, "J");
+ signatures.put(float.class, "F");
+ signatures.put(double.class, "D");
+ */
+ public static int getLoadOPCode(String signature) {
+ if ("Z".equals(signature) || "B".equals(signature)
+ || "C".equals(signature)
+ || "S".equals(signature)
+ || "I".equals(signature)) {
+ return Opcodes.ILOAD;
+ }
+
+ if ("J".equals(signature)) {
+ return Opcodes.LLOAD;
+ }
+
+ if ("F".equals(signature)) {
+ return Opcodes.FLOAD;
+ }
+
+ if ("D".equals(signature)) {
+ return Opcodes.DLOAD;
+ }
+
+ return Opcodes.ALOAD;
+
+ }
+
+ public static int getReturnOPCode(String signature) {
+ if ("Z".equals(signature) || "B".equals(signature)
+ || "C".equals(signature)
+ || "S".equals(signature)
+ || "I".equals(signature)) {
+ return Opcodes.IRETURN;
+ }
+
+ if ("J".equals(signature)) {
+ return Opcodes.LRETURN;
+ }
+
+ if ("F".equals(signature)) {
+ return Opcodes.FRETURN;
+ }
+
+ if ("D".equals(signature)) {
+ return Opcodes.DRETURN;
+ }
+ if ("V".equals(signature)) {
+ return Opcodes.RETURN;
+ }
+
+ return Opcodes.ARETURN;
+
+ }
+
+ /**
+ * Get the package prefix for generated JAXWS artifacts
+ * @param cls
+ * @return
+ */
+ public static String getPackagePrefix(Class<?> cls) {
+ String name = cls.getName();
+ int index = name.lastIndexOf('.');
+ if (index == -1) {
+ return "jaxws.";
+ } else {
+ return name.substring(0, index) + ".jaxws.";
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java
new file mode 100644
index 0000000000..40fbefa3ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebFault;
+
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.objectweb.asm.ClassWriter;
+
+public class FaultBeanGenerator extends BaseBeanGenerator {
+ public FaultBeanGenerator() {
+ super();
+ }
+
+ protected BeanProperty[] getProperties(Class<? extends Throwable> exceptionClass) {
+ BeanInfo beanInfo;
+ try {
+ beanInfo = Introspector.getBeanInfo(exceptionClass);
+ } catch (IntrospectionException e) {
+ throw new IllegalArgumentException(e);
+ }
+ List<BeanProperty> props = new ArrayList<BeanProperty>();
+ for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
+ if (pd.getReadMethod() != null) {
+ String name = pd.getReadMethod().getName();
+ if ("getClass".equals(name) || "getStackTrace".equals(name)
+ || "getCause".equals(name)
+ || "getLocalizedMessage".equals(name)) {
+ continue;
+ }
+ // Add the field
+ String field = pd.getName();
+ Method getter = pd.getReadMethod();
+ props.add(new BeanProperty("", field, getter.getReturnType(), getter.getGenericReturnType(), false));
+ }
+ }
+ Collections.sort(props, new Comparator<BeanProperty>() {
+ public int compare(BeanProperty o1, BeanProperty o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ return props.toArray(new BeanProperty[0]);
+ }
+
+ public byte[] generate(Class<? extends Throwable> exceptionClass) {
+ String className = getFaultBeanName(exceptionClass);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+ String classDescriptor = className.replace('.', '/');
+ String classSignature = "L" + classDescriptor + ";";
+ QName element = getElementName(exceptionClass);
+ String namespace = element.getNamespaceURI();
+ String name = element.getLocalPart();
+ return defineClass(cw, classDescriptor, classSignature, namespace, name, getProperties(exceptionClass));
+ }
+
+ public Class<?> generate(Class<? extends Throwable> exceptionClass, GeneratedClassLoader cl) {
+ synchronized (exceptionClass) {
+ Class<?> faultBeanClass = generatedClasses.get(exceptionClass);
+ if (faultBeanClass == null) {
+ String className = getFaultBeanName(exceptionClass);
+ String classDescriptor = className.replace('.', '/');
+ String classSignature = "L" + classDescriptor + ";";
+ QName element = getElementName(exceptionClass);
+ String namespace = element.getNamespaceURI();
+ String name = element.getLocalPart();
+ faultBeanClass =
+ generate(classDescriptor, classSignature, namespace, name, getProperties(exceptionClass), cl);
+ generatedClasses.put(exceptionClass, faultBeanClass);
+ }
+ return faultBeanClass;
+ }
+ }
+
+ private static String getFaultBeanName(Class<?> exceptionClass) {
+ String faultBeanName = null;
+ WebFault webFault = exceptionClass.getAnnotation(WebFault.class);
+ if (webFault != null) {
+ faultBeanName = webFault.faultBean();
+ if (!"".equals(faultBeanName)) {
+ return faultBeanName;
+ }
+ }
+
+ String name = exceptionClass.getName();
+ int index = name.lastIndexOf('.');
+ String pkg = name.substring(0, index);
+ String clsName = name.substring(index + 1);
+
+ // FIXME: [rfeng] This is a workaround to avoid "Prohibited package name: java.lang.jaxws"
+ if (pkg.startsWith("java.") || pkg.startsWith("javax.")) {
+ pkg = "tuscany";
+ }
+ faultBeanName = (pkg + ".jaxws." + clsName + "Bean");
+ return faultBeanName;
+ }
+
+ public static QName getElementName(Class<? extends Throwable> exceptionClass) {
+ WebFault webFault = exceptionClass.getAnnotation(WebFault.class);
+ String namespace = null;
+ String name = null;
+ if (webFault != null) {
+ namespace = webFault.targetNamespace();
+ name = webFault.name();
+ }
+ if (namespace == null) {
+ namespace = JavaInterfaceUtil.getNamespace(exceptionClass);
+ }
+ if (name == null) {
+ name = exceptionClass.getSimpleName();
+ }
+ return new QName(namespace, name);
+ }
+
+ public static Class<?> generateFaultBeanClass(Class<? extends Throwable> exceptionClass) {
+ FaultBeanGenerator generator = new FaultBeanGenerator();
+ GeneratedClassLoader cl = new GeneratedClassLoader(exceptionClass.getClassLoader());
+ return generator.generate(exceptionClass, cl);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedClassLoader.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedClassLoader.java
new file mode 100644
index 0000000000..3f035ce585
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedClassLoader.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.interfacedef.java.jaxws;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+
+public class GeneratedClassLoader extends URLClassLoader {
+ private class GeneratedClass {
+ private String className;
+ private byte[] byteCode;
+ private Class<?> cls;
+
+ public GeneratedClass(String className, byte[] byteCode) {
+ super();
+ this.className = className;
+ this.byteCode = byteCode;
+ }
+
+ public synchronized Class<?> getGeneratedClass() {
+ if (cls == null) {
+ cls = defineClass(className, byteCode, 0, byteCode.length);
+ }
+ return cls;
+ }
+ }
+
+ private Map<String, GeneratedClass> generatedClasses = new HashMap<String, GeneratedClass>();
+
+ public GeneratedClassLoader(ClassLoader parentLoader) {
+ super(new URL[0], parentLoader);
+ }
+
+ @Override
+ protected Class<?> findClass(String className) throws ClassNotFoundException {
+ GeneratedClass cls = generatedClasses.get(className);
+ if (cls != null) {
+ return cls.getGeneratedClass();
+ }
+ return super.findClass(className);
+ }
+
+ public synchronized Class<?> getGeneratedClass(String className, byte[] byteCode) {
+ GeneratedClass cls = generatedClasses.get(className);
+ if (cls == null) {
+ cls = new GeneratedClass(className, byteCode);
+ generatedClasses.put(className, cls);
+ }
+ return cls.getGeneratedClass();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedDataTypeImpl.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedDataTypeImpl.java
new file mode 100644
index 0000000000..c3f568ef48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedDataTypeImpl.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
+import org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * A special data type that generate the class on demand
+ * @version $Rev$ $Date$
+ */
+public class GeneratedDataTypeImpl implements DataType<XMLType> {
+ private XMLAdapterExtensionPoint xmlAdapters;
+
+ private Class<?> physical;
+ private XMLType logical;
+
+ private Map<Class<?>, Object> metaDataMap;
+ private Method method;
+ private String wrapperClassName;
+ private String wrapperNamespace;
+ private String wrapperName;
+ private boolean request;
+ private GeneratedClassLoader classLoader;
+
+ private Class<? extends Throwable> exceptionClass;
+
+ public GeneratedDataTypeImpl(XMLAdapterExtensionPoint xmlAdapters, Class<? extends Throwable> exceptionClass, GeneratedClassLoader cl) {
+ super();
+ this.exceptionClass = exceptionClass;
+ this.classLoader = cl;
+ QName name = FaultBeanGenerator.getElementName(exceptionClass);
+ this.logical = new XMLType(name, name);
+ this.xmlAdapters = xmlAdapters;
+ }
+
+ public GeneratedDataTypeImpl(XMLAdapterExtensionPoint xmlAdapters,
+ Method m,
+ String wrapperClassName,
+ String wrapperNamespace,
+ String wrapperName,
+ boolean request,
+ GeneratedClassLoader cl) {
+ super();
+ this.method = m;
+ this.wrapperClassName = wrapperClassName;
+ this.wrapperNamespace = wrapperNamespace;
+ this.wrapperName = wrapperName;
+ this.classLoader = cl;
+ this.request = request;
+ QName name = new QName(wrapperNamespace, wrapperName);
+ this.logical = new XMLType(name, name);
+ this.xmlAdapters = xmlAdapters;
+ }
+
+ public String getDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+
+ public Type getGenericType() {
+ return getPhysical();
+ }
+
+ public XMLType getLogical() {
+ return logical;
+ }
+
+ public synchronized Class<?> getPhysical() {
+ if (physical == null) {
+ if (method != null) {
+ WrapperBeanGenerator generator = new WrapperBeanGenerator();
+ generator.setXmlAdapters(xmlAdapters);
+ physical =
+ request ? generator.generateRequestWrapper(method, wrapperClassName, wrapperNamespace, wrapperName, classLoader)
+ : generator.generateResponseWrapper(method, wrapperClassName, wrapperNamespace, wrapperName, classLoader);
+ ;
+ } else if (exceptionClass != null) {
+ FaultBeanGenerator faultBeanGenerator = new FaultBeanGenerator();
+ faultBeanGenerator.setXmlAdapters(xmlAdapters);
+ physical = faultBeanGenerator.generate(exceptionClass, classLoader);
+ }
+ }
+ return physical;
+ }
+
+ public void setDataBinding(String dataBinding) {
+ // NOP
+ }
+
+ public void setGenericType(Type genericType) {
+ // NOP
+ }
+
+ public void setLogical(XMLType logical) {
+ this.logical = logical;
+ }
+
+ public void setPhysical(Class<?> cls) {
+ // NOP
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public <T> T getMetaData(Class<T> type) {
+ return metaDataMap == null ? null : type.cast(metaDataMap.get(type));
+ }
+
+ public <T> void setMetaData(Class<T> type, T metaData) {
+ if (metaDataMap == null) {
+ metaDataMap = new ConcurrentHashMap<Class<?>, Object>();
+ }
+ metaDataMap.put(type, metaData);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java
new file mode 100644
index 0000000000..155c89c7f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java
@@ -0,0 +1,276 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.lang.reflect.ParameterizedType;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+
+public class JAXWSAsyncInterfaceProcessor implements JavaInterfaceVisitor {
+ private static String ASYNC = "Async";
+
+ public JAXWSAsyncInterfaceProcessor(ExtensionPointRegistry registry) {
+
+ }
+
+ public void visitInterface(JavaInterface javaInterface) throws InvalidInterfaceException {
+ List<Operation> validOperations = new ArrayList<Operation>();
+ List<Operation> asyncOperations = new ArrayList<Operation>();
+
+ validOperations.addAll(javaInterface.getOperations());
+ for(Operation o : javaInterface.getOperations()) {
+ if (! o.getName().endsWith(ASYNC)) {
+ Operation op = o;
+
+ for(Operation asyncOp : getAsyncOperations(javaInterface.getOperations(), o.getName()) ) {
+ if (isJAXWSAsyncPoolingOperation(op, asyncOp) ||
+ isJAXWSAsyncCallbackOperation(op, asyncOp)) {
+ validOperations.remove(asyncOp);
+ asyncOperations.add(asyncOp);
+ }
+ }
+ }
+ }
+
+ javaInterface.getOperations().clear();
+ javaInterface.getOperations().addAll(validOperations);
+
+ javaInterface.getAttributes().put("JAXWS-ASYNC-OPERATIONS", asyncOperations);
+ }
+
+ /**
+ * The additional client-side asynchronous polling and callback methods defined by JAX-WS are recognized in a Java interface as follows:
+ * For each method M in the interface, if another method P in the interface has
+ *
+ * a) a method name that is M's method name with the characters "Async" appended, and
+ * b) the same parameter signature as M, and
+ * c)a return type of Response<R> where R is the return type of M
+ *
+ * @param operation
+ * @param asyncOperation
+ * @return
+ */
+ private static boolean isJAXWSAsyncPoolingOperation(Operation operation, Operation asyncOperation) {
+ //a method name that is M's method name with the characters "Async" appended
+ if (operation.getName().endsWith(ASYNC)) {
+ return false;
+ }
+
+ if (! asyncOperation.getName().endsWith(ASYNC)) {
+ return false;
+ }
+
+ if(! asyncOperation.getName().equals(operation.getName() + ASYNC)) {
+ return false;
+ }
+
+ //the same parameter signature as M
+ List<DataType> operationInputType = operation.getInputType().getLogical();
+ List<DataType> asyncOperationInputType = asyncOperation.getInputType().getLogical();
+ int size = operationInputType.size();
+ for (int i = 0; i < size; i++) {
+ if (!isCompatible(operationInputType.get(i), asyncOperationInputType.get(i))) {
+ return false;
+ }
+ }
+
+ //a return type of Response<R> where R is the return type of M
+ DataType<?> operationOutputType = operation.getOutputType();
+ DataType<?> asyncOperationOutputType = asyncOperation.getOutputType();
+
+ if (operationOutputType != null && asyncOperationOutputType != null) {
+ ParameterizedType asyncReturnType = (ParameterizedType) asyncOperationOutputType.getGenericType();
+ Class<?> asyncReturnTypeClass = (Class<?>)asyncReturnType.getRawType();
+ if(asyncReturnTypeClass.getName().equals("javax.xml.ws.Response")) {
+ //now check the actual type of the Response<R> with R
+ Class<?> returnType = operationOutputType.getPhysical();
+ Class<?> asyncActualReturnTypeClass = (Class<?>) asyncReturnType.getActualTypeArguments()[0];
+
+ if(returnType == asyncActualReturnTypeClass ||
+ returnType.isPrimitive() && primitiveAssignable(returnType,asyncActualReturnTypeClass)) {
+ //valid
+ } else {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * For each method M in the interface, if another method C in the interface has
+ * a) a method name that is M's method name with the characters "Async" appended, and
+ * b) a parameter signature that is M's parameter signature with an additional
+ * final parameter of type AsyncHandler<R> where R is the return type of M, and
+ * c) a return type of Future<?>
+ *
+ * then C is a JAX-WS callback method that isn't part of the SCA interface contract.
+ *
+ * @param operation
+ * @param asyncOperation
+ * @return
+ */
+ private static boolean isJAXWSAsyncCallbackOperation(Operation operation, Operation asyncOperation) {
+ //a method name that is M's method name with the characters "Async" appended
+ if (operation.getName().endsWith(ASYNC)) {
+ return false;
+ }
+
+ if (! asyncOperation.getName().endsWith(ASYNC)) {
+ return false;
+ }
+
+ if(! asyncOperation.getName().equals(operation.getName() + ASYNC)) {
+ return false;
+ }
+
+ //a parameter signature that is M's parameter signature
+ //with an additional final parameter of type AsyncHandler<R> where R is the return type of M, and
+ List<DataType> operationInputType = operation.getInputType().getLogical();
+ List<DataType> asyncOperationInputType = asyncOperation.getInputType().getLogical();
+ int size = operationInputType.size();
+ for (int i = 0; i < size; i++) {
+ if (!isCompatible(operationInputType.get(i), asyncOperationInputType.get(i))) {
+ return false;
+ }
+ }
+
+ if(asyncOperationInputType.size() == size + 1) {
+ ParameterizedType asyncLastParameterType = (ParameterizedType) asyncOperationInputType.get(size + 1).getGenericType();
+ Class<?> asyncLastParameterTypeClass = (Class<?>)asyncLastParameterType.getRawType();
+ if(asyncLastParameterTypeClass.getName().equals("javax.xml.ws.AsyncHandler")) {
+ //now check the actual type of the AsyncHandler<R> with R
+ Class<?> returnType = operation.getOutputType().getPhysical();
+ Class<?> asyncActualLastParameterTypeClass = (Class<?>) asyncLastParameterType.getActualTypeArguments()[0];
+
+ if(returnType == asyncActualLastParameterTypeClass ||
+ returnType.isPrimitive() && primitiveAssignable(returnType,asyncActualLastParameterTypeClass)) {
+ //valid
+ } else {
+ return false;
+ }
+ }
+ }
+
+ //a return type of Response<R> where R is the return type of M
+ DataType<?> operationOutputType = operation.getOutputType();
+ DataType<?> asyncOperationOutputType = asyncOperation.getOutputType();
+
+ if (operationOutputType != null && asyncOperationOutputType != null) {
+ ParameterizedType asyncReturnType = (ParameterizedType) asyncOperationOutputType.getGenericType();
+ Class<?> asyncReturnTypeClass = (Class<?>)asyncReturnType.getRawType();
+ if(asyncReturnTypeClass.getName().equals("javax.xml.ws.Response")) {
+ //now check the actual type of the Response<R> with R
+ Class<?> returnType = operationOutputType.getPhysical();
+ Class<?> asyncActualReturnTypeClass = (Class<?>) asyncReturnType.getActualTypeArguments()[0];
+
+ if(returnType == asyncActualReturnTypeClass ||
+ returnType.isPrimitive() && primitiveAssignable(returnType,asyncActualReturnTypeClass)) {
+ //valid
+ } else {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Get operation by name
+ *
+ * @param operations
+ * @param operationName
+ * @return
+ */
+ private static List<Operation> getAsyncOperations(List<Operation> operations, String operationName) {
+ List<Operation> returnOperations = new ArrayList<Operation>();
+
+ for(Operation o : operations) {
+ if(o.getName().equals(operationName + ASYNC)) {
+ returnOperations.add(o);
+ }
+ }
+
+ return returnOperations;
+ }
+
+
+ /**
+ * Check if two operation parameters are compatible
+ *
+ * @param source
+ * @param target
+ * @return
+ */
+ private static boolean isCompatible(DataType<?> source, DataType<?> target) {
+ if (source == target) {
+ return true;
+ }
+
+ return target.getPhysical().isAssignableFrom(source.getPhysical());
+ }
+
+ /**
+ * Compares a two types, assuming one is a primitive, to determine if the
+ * other is its object counterpart
+ */
+ private static boolean primitiveAssignable(Class<?> memberType, Class<?> param) {
+ if (memberType == Integer.class) {
+ return param == Integer.TYPE;
+ } else if (memberType == Double.class) {
+ return param == Double.TYPE;
+ } else if (memberType == Float.class) {
+ return param == Float.TYPE;
+ } else if (memberType == Short.class) {
+ return param == Short.TYPE;
+ } else if (memberType == Character.class) {
+ return param == Character.TYPE;
+ } else if (memberType == Boolean.class) {
+ return param == Boolean.TYPE;
+ } else if (memberType == Byte.class) {
+ return param == Byte.TYPE;
+ } else if (param == Integer.class) {
+ return memberType == Integer.TYPE;
+ } else if (param == Double.class) {
+ return memberType == Double.TYPE;
+ } else if (param == Float.class) {
+ return memberType == Float.TYPE;
+ } else if (param == Short.class) {
+ return memberType == Short.TYPE;
+ } else if (param == Character.class) {
+ return memberType == Character.TYPE;
+ } else if (param == Boolean.class) {
+ return memberType == Boolean.TYPE;
+ } else if (param == Byte.class) {
+ return memberType == Byte.TYPE;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
new file mode 100644
index 0000000000..fcf7006f16
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
@@ -0,0 +1,403 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebFault;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.FaultExceptionMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * JAX-WS ExceptionHandler
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXWSFaultExceptionMapper implements FaultExceptionMapper {
+ public static final String GETCAUSE = "getCause";
+ public static final String GETLOCALIZEDMESSAGE = "getLocalizedMessage";
+ public static final String GETSTACKTRACE = "getStackTrace";
+ public static final String GETCLASS = "getClass";
+
+ private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class[0];
+ private DataBindingExtensionPoint dataBindingExtensionPoint;
+ private XMLAdapterExtensionPoint xmlAdapterExtensionPoint;
+
+
+ public JAXWSFaultExceptionMapper(DataBindingExtensionPoint dataBindingExtensionPoint, XMLAdapterExtensionPoint xmlAdapters) {
+ super();
+ this.dataBindingExtensionPoint = dataBindingExtensionPoint;
+ this.xmlAdapterExtensionPoint = xmlAdapters;
+ }
+
+ public JAXWSFaultExceptionMapper(ExtensionPointRegistry registry) {
+ this.dataBindingExtensionPoint = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ this.xmlAdapterExtensionPoint = registry.getExtensionPoint(XMLAdapterExtensionPoint.class);
+ }
+
+ /**
+ * The following is quoted from the JAX-WS Specification v2.1
+ * <ul>
+ * <li>WrapperException(String message, FaultBean faultInfo) <br>
+ * A constructor where WrapperException is replaced with the name of the
+ * generated wrapper exception and FaultBean is replaced by the name of the
+ * generated fault bean.
+ * <li> WrapperException(String message, FaultBean faultInfo, Throwable
+ * cause) <br>
+ * A constructor where WrapperException is replaced with the name of the
+ * generated wrapper exception and FaultBean is replaced by the name of the
+ * generated fault bean. The last argument, cause, may be used to convey
+ * protocol specific fault information
+ * </ul>
+ */
+ @SuppressWarnings("unchecked")
+ public Throwable wrapFaultInfo(DataType<DataType> exceptionType, String message, Object faultInfo, Throwable cause, Operation operation) {
+ Class<?> exceptionClass = exceptionType.getPhysical();
+ if (exceptionClass.isInstance(faultInfo)) {
+ return (Throwable)faultInfo;
+ }
+ DataType<?> faultBeanType = exceptionType.getLogical();
+ Class<?> faultBeanClass = faultBeanType.getPhysical();
+ try {
+ Throwable exc =
+ newInstance((Class<? extends Throwable>)exceptionClass, message, faultBeanClass, faultInfo, cause);
+ // Include the elem name into the FaultException we build so it can be used for matching in the DataTransformationInterceptor
+ //
+ // Note this may happen even if we find a constructor above, that is the type of the non-generic fault exc may be an instance
+ // of FaultException
+ //
+ if ((exc instanceof FaultException) && (faultBeanType.getLogical() instanceof XMLType)) {
+ FaultException faultExc = (FaultException)exc;
+ DataType<XMLType> faultBeanXMLType = (DataType<XMLType>)faultBeanType;
+ XMLType faultLogical = faultBeanXMLType.getLogical();
+ faultExc.setFaultName(faultLogical.getElementName());
+ }
+ return exc;
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ private Throwable newInstance(Class<? extends Throwable> exceptionClass,
+ String message,
+ Class<?> faultBeanClass,
+ Object faultInfo,
+ Throwable cause) throws Exception {
+ Throwable ex = null;
+ Constructor<? extends Throwable> ctor = null;
+ try {
+ // Get the message property
+ Method getMessage = faultBeanClass.getMethod("getMessage");
+ message = (String)getMessage.invoke(faultInfo);
+ } catch (Throwable e) {
+ // Ignore
+ }
+ if (faultInfo == null) {
+ try {
+ ctor = exceptionClass.getConstructor(String.class, Throwable.class);
+ ex = ctor.newInstance(message, cause);
+ } catch (NoSuchMethodException e1) {
+ try {
+ ctor = exceptionClass.getConstructor(String.class);
+ ex = ctor.newInstance(message);
+ } catch (NoSuchMethodException e2) {
+ try {
+ ctor = exceptionClass.getConstructor(Throwable.class);
+ ex = ctor.newInstance(cause);
+ } catch (NoSuchMethodException e3) {
+ ctor = exceptionClass.getConstructor();
+ ex = ctor.newInstance();
+ }
+ }
+ }
+ } else {
+ try {
+ // FIXME: What about if the faultBeanClass is a subclass of the argument type?
+ ctor = exceptionClass.getConstructor(String.class, faultBeanClass, Throwable.class);
+ ex = ctor.newInstance(message, faultInfo, cause);
+ } catch (NoSuchMethodException e1) {
+ try {
+ ctor = exceptionClass.getConstructor(String.class, faultInfo.getClass());
+ ex = ctor.newInstance(message, faultInfo);
+ } catch (NoSuchMethodException e2) {
+ try {
+ ctor = exceptionClass.getConstructor(String.class, Throwable.class);
+ ex = ctor.newInstance(message, cause);
+ populateException(ex, faultInfo);
+ } catch (NoSuchMethodException e3) {
+ try {
+ ctor = exceptionClass.getConstructor(String.class);
+ ex = ctor.newInstance(message);
+ populateException(ex, faultInfo);
+ } catch (NoSuchMethodException e4) {
+ try {
+ ctor = exceptionClass.getConstructor();
+ if (ctor != null) {
+ ex = ctor.newInstance();
+ populateException(ex, faultInfo);
+ } else {
+ ex = new FaultException(message, faultInfo, cause);
+ }
+ } catch (NoSuchMethodException e5) {
+ try {
+ ctor = exceptionClass.getConstructor(Throwable.class);
+ ex = ctor.newInstance(cause);
+ populateException(ex, faultInfo);
+ } catch (NoSuchMethodException e6) {
+ ctor = exceptionClass.getConstructor();
+ ex = ctor.newInstance();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return ex;
+ }
+
+ /**
+ * Populate the java exception from the fault bean
+ * @param ex
+ * @param faultBean
+ * @throws Exception
+ */
+ private void populateException(Throwable ex, Object faultBean) throws Exception {
+ PropertyDescriptor props[] = Introspector.getBeanInfo(faultBean.getClass()).getPropertyDescriptors();
+ for (PropertyDescriptor p : props) {
+ Method getter = p.getReadMethod();
+ Method setter = p.getWriteMethod();
+ if (getter == null || setter == null) {
+ continue;
+ }
+ try {
+ Method m = ex.getClass().getMethod(setter.getName(), setter.getParameterTypes());
+ Object pv = getter.invoke(faultBean);
+ m.invoke(ex, pv);
+ } catch (Exception e) {
+ // Ignore;
+ }
+ }
+ }
+
+ public Object getFaultInfo(Throwable exception, Class<?> faultBeanClass, Operation operation) {
+ if (exception == null) {
+ return null;
+ }
+
+ // Check if it's the generic FaultException
+ if (exception instanceof FaultException) {
+ return ((FaultException)exception).getFaultInfo();
+ }
+
+ try {
+ Method method = exception.getClass().getMethod("getFaultInfo", EMPTY_CLASS_ARRAY);
+ return method.invoke(exception, (Object[])null);
+ } catch (NoSuchMethodException e) {
+ // Follow the JAX-WS v2.1 Specification section 3.7
+ return createFaultBean(exception, faultBeanClass);
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ private Object createFaultBean(Throwable exception, Class<?> faultBeanClass) {
+ /**
+ * For each getter in the exception and its superclasses, a property of the same
+ * type and name is added to the bean. The getCause, getLocalizedMessage and
+ * getStackTrace getters from java.lang.Throwable and the getClass getter from
+ * java.lang.Object are excluded from the list of getters to be mapped.
+ */
+ // Return the exception as-is if it's already the fault bean
+ if (faultBeanClass.isInstance(exception)) {
+ return exception;
+ }
+ try {
+ Object faultBean = null;
+ for (Constructor<?> ctor : faultBeanClass.getConstructors()) {
+ Class<?>[] params = ctor.getParameterTypes();
+ if (params.length == 1 && String.class == params[0]) {
+ faultBean = ctor.newInstance(exception.getMessage());
+ } else if (params.length == 2 && String.class == params[0]
+ && Throwable.class.isAssignableFrom(params[1])) {
+ faultBean = ctor.newInstance(exception.getMessage(), exception);
+ } else if (params.length == 0) {
+ faultBean = ctor.newInstance();
+ }
+ if (faultBean != null) {
+ break;
+ }
+ }
+ if (faultBean == null) {
+ return exception;
+ }
+ BeanInfo beanInfo = Introspector.getBeanInfo(exception.getClass());
+ for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
+ Method getter = pd.getReadMethod();
+ String name = getter.getName();
+ if (!isMappedGetter(name)) {
+ continue;
+ }
+ Method setter = null;
+ try {
+ setter = faultBeanClass.getMethod("set" + capitalize(pd.getName()), getter.getReturnType());
+ } catch (NoSuchMethodException e) {
+ continue;
+ }
+ Object prop = getter.invoke(exception);
+ setter.invoke(faultBean, prop);
+ }
+ return faultBean;
+ } catch (Throwable ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean introspectFaultDataType(DataType<DataType> exceptionType, final Operation operation, final boolean generatingFaultBean) {
+ QName faultName = null;
+ boolean result = false;
+
+ final Class<?> cls = exceptionType.getPhysical();
+ if (cls == FaultException.class) {
+ return true;
+ }
+ DataType faultType = (DataType)exceptionType.getLogical();
+ Class<?> faultBean = null;
+ final WebFault fault = cls.getAnnotation(WebFault.class);
+ if (fault != null) {
+ if (!"".equals(fault.name()) || !"".equals(fault.targetNamespace())) {
+ QName faultQName = ((XMLType)faultType.getLogical()).getElementName();
+ String faultNS =
+ "".equals(fault.targetNamespace()) ? faultQName.getNamespaceURI() : fault.targetNamespace();
+ String faultLocal = "".equals(fault.name()) ? faultQName.getLocalPart() : fault.name();
+ faultName = new QName(faultNS, faultLocal);
+ XMLType xmlType = new XMLType(faultName, null);
+ faultType.setLogical(xmlType);
+ }
+ if (!"".equals(fault.faultBean())) {
+ faultBean = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
+ public Class<?> run() {
+ try {
+ return Class.forName(fault.faultBean(), false, cls.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ });
+ } else {
+ Method m;
+ try {
+ m = cls.getMethod("getFaultInfo", (Class[])null);
+ faultBean = m.getReturnType();
+ } catch (NoSuchMethodException e) {
+ // Ignore
+ }
+ }
+ }
+
+ if (faultBean == null) {
+ final String faultBeanClassName = CodeGenerationHelper.getPackagePrefix(cls) + cls.getSimpleName() + "Bean";
+ final QName qname = faultName;
+ faultType = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
+ public DataType<XMLType> run() {
+ try {
+ Class<?> faultBean = Class.forName(faultBeanClassName, false, cls.getClassLoader());
+ return new DataTypeImpl<XMLType>(faultBean, new XMLType(qname, qname));
+ } catch (ClassNotFoundException e) {
+ if (generatingFaultBean) {
+ Class<? extends Throwable> t = (Class<? extends Throwable>)cls;
+ ClassLoader parent =
+ operation == null ? t.getClassLoader() : ((JavaInterface)operation.getInterface())
+ .getJavaClass().getClassLoader();
+ GeneratedClassLoader cl = new GeneratedClassLoader(parent);
+ GeneratedDataTypeImpl dt = new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, t, cl);
+ return dt;
+ } else {
+ return new DataTypeImpl<XMLType>(cls, new XMLType(qname, qname));
+ }
+ }
+ }
+ });
+ } else {
+ faultType.setDataBinding(null);
+ faultType.setGenericType(faultBean);
+ faultType.setPhysical(faultBean);
+ }
+
+ // TODO: Use the databinding framework to introspect the fault bean class
+ if (faultType.getDataBinding() == null && dataBindingExtensionPoint != null) {
+ faultBean = faultType.getPhysical();
+ result =
+ dataBindingExtensionPoint.introspectType(faultType, operation);
+ }
+ ((DataType) exceptionType).setLogical(faultType);
+
+ /*
+ The introspection of the fault DT may not have calculated the correct element name,
+ though we may have already done this in this method. Let's look at the DataType now
+ that introspection is done, and, if it has an XMLType, let's set the element to the
+ 'faultName' if we calculated one.
+ */
+ if ((faultName != null) && (faultType.getLogical() instanceof XMLType)) {
+ XMLType faultTypeXML = (XMLType)faultType.getLogical();
+ // The element name (if set) should match the fault name
+ faultTypeXML.setElementName(faultName);
+ }
+
+ return result;
+ }
+
+ public static boolean isMappedGetter(String methodName) {
+ if (GETCAUSE.equals(methodName) || GETLOCALIZEDMESSAGE.equals(methodName)
+ || GETSTACKTRACE.equals(methodName)
+ || GETCLASS.equals(methodName)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private static String capitalize(String name) {
+ if (name == null || name.length() == 0) {
+ return name;
+ } else {
+ return Character.toUpperCase(name.charAt(0)) + name.substring(1);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
new file mode 100644
index 0000000000..f18ea0118f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
@@ -0,0 +1,388 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.xml.namespace.QName;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.WebServiceProvider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.javabeans.JavaExceptionDataBinding;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
+import org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.FaultExceptionMapper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+
+/**
+ * Introspect the java class/interface with JSR-181 and JAXWS annotations
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
+ private static final String JAXB_DATABINDING = JAXBDataBinding.NAME;
+ private static final String GET = "get";
+ private DataBindingExtensionPoint dataBindingExtensionPoint;
+ private FaultExceptionMapper faultExceptionMapper;
+ private XMLAdapterExtensionPoint xmlAdapterExtensionPoint;
+ protected JavaInterfaceFactory javaInterfaceFactory;
+ private WSDLFactory wsdlFactory;
+
+
+ public JAXWSJavaInterfaceProcessor(ExtensionPointRegistry registry) {
+ dataBindingExtensionPoint = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ faultExceptionMapper = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(FaultExceptionMapper.class);
+ xmlAdapterExtensionPoint = registry.getExtensionPoint(XMLAdapterExtensionPoint.class);
+
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.wsdlFactory = factories.getFactory(WSDLFactory.class);
+ }
+
+ public JAXWSJavaInterfaceProcessor() {
+ super();
+ }
+
+ private static String capitalize(String name) {
+ if (name == null || name.length() == 0) {
+ return name;
+ } else {
+ return Character.toUpperCase(name.charAt(0)) + name.substring(1);
+ }
+ }
+
+ public void visitInterface(JavaInterface contract) throws InvalidInterfaceException {
+
+ final Class<?> clazz = contract.getJavaClass();
+
+ contract = JAXWSUtils.configureJavaInterface(contract, clazz);
+ String tns = contract.getQName().getNamespaceURI();
+
+ if (!contract.isRemotable()) {
+ return;
+ }
+
+ // SOAP binding (doc/lit/wrapped|bare or rpc/lit)
+ SOAPBinding soapBinding = clazz.getAnnotation(SOAPBinding.class);
+
+ for (Iterator<Operation> it = contract.getOperations().iterator(); it.hasNext();) {
+ final JavaOperation operation = (JavaOperation)it.next();
+ final Method method = operation.getJavaMethod();
+ introspectFaultTypes(operation);
+
+ // SOAP binding (doc/lit/wrapped|bare or rpc/lit)
+ SOAPBinding methodSOAPBinding = method.getAnnotation(SOAPBinding.class);
+ if (methodSOAPBinding == null) {
+ methodSOAPBinding = soapBinding;
+ }
+
+ boolean documentStyle = true;
+ boolean bare = false;
+ if (methodSOAPBinding != null) {
+ bare = methodSOAPBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE;
+ if(bare) {
+ // For BARE parameter style, the data won't be unwrapped
+ // The wrapper should be null
+ operation.setWrapperStyle(false);
+ }
+ documentStyle = methodSOAPBinding.style() == Style.DOCUMENT;
+ }
+
+ String operationName = operation.getName();
+ // WebMethod
+ WebMethod webMethod = method.getAnnotation(WebMethod.class);
+ if (webMethod != null) {
+ if (webMethod.exclude()) {
+ // Exclude the method
+ it.remove();
+ continue;
+ }
+ operationName = getValue(webMethod.operationName(), operationName);
+ operation.setName(operationName);
+ operation.setAction(webMethod.action());
+ }
+
+ // Is one way?
+ Oneway oneway = method.getAnnotation(Oneway.class);
+ if (oneway != null) {
+ // JSR 181
+ assert method.getReturnType() == void.class;
+ operation.setNonBlocking(true);
+ }
+
+ // Handle BARE mapping
+ if (bare) {
+ for (int i = 0; i < method.getParameterTypes().length; i++) {
+ WebParam param = getAnnotation(method, i, WebParam.class);
+ if (param != null) {
+ String ns = getValue(param.targetNamespace(), tns);
+ // Default to <operationName> for doc-bare
+ String name = getValue(param.name(), documentStyle ? operationName : "arg" + i);
+ QName element = new QName(ns, name);
+ Object logical = operation.getInputType().getLogical().get(i).getLogical();
+ if (logical instanceof XMLType) {
+ ((XMLType)logical).setElementName(element);
+ }
+ }
+ }
+ WebResult result = method.getAnnotation(WebResult.class);
+ if (result != null) {
+ String ns = getValue(result.targetNamespace(), tns);
+ // Default to <operationName>Response for doc-bare
+ String name = getValue(result.name(), documentStyle ? operationName + "Response" : "return");
+ QName element = new QName(ns, name);
+ Object logical = operation.getOutputType().getLogical();
+ if (logical instanceof XMLType) {
+ ((XMLType)logical).setElementName(element);
+ }
+ }
+ // FIXME: [rfeng] For the BARE mapping, do we need to create a Wrapper?
+ // it's null at this point
+ } else {
+
+ RequestWrapper requestWrapper = method.getAnnotation(RequestWrapper.class);
+ String ns = requestWrapper == null ? tns : getValue(requestWrapper.targetNamespace(), tns);
+ String name =
+ requestWrapper == null ? operationName : getValue(requestWrapper.localName(), operationName);
+ String wrapperBeanName = requestWrapper == null ? "" : requestWrapper.className();
+ if ("".equals(wrapperBeanName)) {
+ wrapperBeanName = CodeGenerationHelper.getPackagePrefix(clazz) + capitalize(method.getName());
+ }
+
+ DataType<XMLType> inputWrapperDT = null;
+
+ final String inputWrapperClassName = wrapperBeanName;
+ final String inputNS = ns;
+ final String inputName = name;
+ inputWrapperDT = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
+ public DataType<XMLType> run() {
+ try {
+ Class<?> wrapperClass = Class.forName(inputWrapperClassName, false, clazz.getClassLoader());
+ QName qname = new QName(inputNS, inputName);
+ DataType dt = new DataTypeImpl<XMLType>(wrapperClass, new XMLType(qname, qname));
+ dataBindingExtensionPoint.introspectType(dt, operation);
+ // TUSCANY-2505
+ if (dt.getLogical() instanceof XMLType) {
+ XMLType xmlType = (XMLType)dt.getLogical();
+ xmlType.setElementName(qname);
+ }
+ return dt;
+ } catch (ClassNotFoundException e) {
+ GeneratedClassLoader cl = new GeneratedClassLoader(clazz.getClassLoader());
+ return new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, method, inputWrapperClassName, inputNS, inputName, true,
+ cl);
+ }
+ }
+ });
+
+ QName inputWrapper = inputWrapperDT.getLogical().getElementName();
+
+ ResponseWrapper responseWrapper = method.getAnnotation(ResponseWrapper.class);
+ ns = responseWrapper == null ? tns : getValue(responseWrapper.targetNamespace(), tns);
+ name =
+ responseWrapper == null ? operationName + "Response" : getValue(responseWrapper.localName(),
+ operationName + "Response");
+ wrapperBeanName = responseWrapper == null ? "" : responseWrapper.className();
+ if ("".equals(wrapperBeanName)) {
+ wrapperBeanName =
+ CodeGenerationHelper.getPackagePrefix(clazz) + capitalize(method.getName()) + "Response";
+ }
+
+ DataType<XMLType> outputWrapperDT = null;
+ final String outputWrapperClassName = wrapperBeanName;
+ final String outputNS = ns;
+ final String outputName = name;
+
+ outputWrapperDT = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
+ public DataType<XMLType> run() {
+ try {
+ Class<?> wrapperClass =
+ Class.forName(outputWrapperClassName, false, clazz.getClassLoader());
+ QName qname = new QName(outputNS, outputName);
+ DataType dt = new DataTypeImpl<XMLType>(wrapperClass, new XMLType(qname, qname));
+ dataBindingExtensionPoint.introspectType(dt, operation);
+ // TUSCANY-2505
+ if (dt.getLogical() instanceof XMLType) {
+ XMLType xmlType = (XMLType)dt.getLogical();
+ xmlType.setElementName(qname);
+ }
+ return dt;
+ } catch (ClassNotFoundException e) {
+ GeneratedClassLoader cl = new GeneratedClassLoader(clazz.getClassLoader());
+ return new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, method, outputWrapperClassName, outputNS, outputName,
+ false, cl);
+ }
+ }
+ });
+ QName outputWrapper = outputWrapperDT.getLogical().getElementName();
+
+ List<ElementInfo> inputElements = new ArrayList<ElementInfo>();
+ for (int i = 0; i < method.getParameterTypes().length; i++) {
+ WebParam param = getAnnotation(method, i, WebParam.class);
+ ns = param != null ? param.targetNamespace() : "";
+ // Default to "" for doc-lit-wrapped && non-header
+ ns = getValue(ns, documentStyle && (param == null || !param.header()) ? "" : tns);
+ name = param != null ? param.name() : "";
+ name = getValue(name, "arg" + i);
+ QName element = new QName(ns, name);
+ Object logical = operation.getInputType().getLogical().get(i).getLogical();
+ QName type = null;
+ if (logical instanceof XMLType) {
+ ((XMLType)logical).setElementName(element);
+ type = ((XMLType)logical).getTypeName();
+ }
+ inputElements.add(new ElementInfo(element, new TypeInfo(type, false, null)));
+ }
+
+ List<ElementInfo> outputElements = new ArrayList<ElementInfo>();
+ WebResult result = method.getAnnotation(WebResult.class);
+ // Default to "" for doc-lit-wrapped && non-header
+ ns = result != null ? result.targetNamespace() : "";
+ ns = getValue(ns, documentStyle && (result == null || !result.header()) ? "" : tns);
+ name = result != null ? result.name() : "";
+ name = getValue(name, "return");
+ QName element = new QName(ns, name);
+
+ if (operation.getOutputType() != null) {
+ Object logical = operation.getOutputType().getLogical();
+ QName type = null;
+ if (logical instanceof XMLType) {
+ ((XMLType)logical).setElementName(element);
+ type = ((XMLType)logical).getTypeName();
+ }
+ outputElements.add(new ElementInfo(element, new TypeInfo(type, false, null)));
+ }
+
+ String db = inputWrapperDT != null ? inputWrapperDT.getDataBinding() : JAXB_DATABINDING;
+ WrapperInfo wrapperInfo =
+ new WrapperInfo(db, new ElementInfo(inputWrapper, null), new ElementInfo(outputWrapper, null),
+ inputElements, outputElements);
+
+ wrapperInfo.setInputWrapperType(inputWrapperDT);
+ wrapperInfo.setOutputWrapperType(outputWrapperDT);
+
+ operation.setWrapper(wrapperInfo);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void introspectFaultTypes(Operation operation) {
+ if (operation != null && operation.getFaultTypes() != null) {
+ for (DataType exceptionType : operation.getFaultTypes()) {
+ faultExceptionMapper.introspectFaultDataType(exceptionType, operation, true);
+ DataType faultType = (DataType)exceptionType.getLogical();
+ if (JavaExceptionDataBinding.NAME.equals(faultType.getDataBinding())) {
+ // The exception class doesn't have an associated bean class, so
+ // synthesize a virtual bean by introspecting the exception class.
+ createSyntheticBean(operation, exceptionType);
+ }
+ }
+ }
+ }
+
+ private void createSyntheticBean(Operation operation, DataType exceptionType) {
+ DataType faultType = (DataType)exceptionType.getLogical();
+ QName faultBeanName = ((XMLType)faultType.getLogical()).getElementName();
+ List<DataType<XMLType>> beanDataTypes = new ArrayList<DataType<XMLType>>();
+ for (Method aMethod : exceptionType.getPhysical().getMethods()) {
+ if (Modifier.isPublic(aMethod.getModifiers()) && aMethod.getName().startsWith(GET)
+ && aMethod.getParameterTypes().length == 0
+ && JAXWSFaultExceptionMapper.isMappedGetter(aMethod.getName())) {
+ String propName = resolvePropertyFromMethod(aMethod.getName());
+ QName propQName = new QName(faultBeanName.getNamespaceURI(), propName);
+ Class<?> propType = aMethod.getReturnType();
+ XMLType xmlPropType = new XMLType(propQName, null);
+ DataType<XMLType> propDT = new DataTypeImpl<XMLType>(propType, xmlPropType);
+ org.apache.tuscany.sca.databinding.annotation.DataType dt =
+ aMethod.getAnnotation(org.apache.tuscany.sca.databinding.annotation.DataType.class);
+ if (dt != null) {
+ propDT.setDataBinding(dt.value());
+ }
+ dataBindingExtensionPoint.introspectType(propDT, operation);
+
+ // sort the list lexicographically as specified in JAX-WS spec section 3.7
+ int i = 0;
+ for (; i < beanDataTypes.size(); i++) {
+ if (beanDataTypes.get(i).getLogical().getElementName().getLocalPart().compareTo(propName) > 0) {
+ break;
+ }
+ }
+ beanDataTypes.add(i, propDT);
+ }
+ }
+ operation.getFaultBeans().put(faultBeanName, beanDataTypes);
+ }
+
+ private String resolvePropertyFromMethod(String methodName) {
+ StringBuffer propName = new StringBuffer();
+ propName.append(Character.toLowerCase(methodName.charAt(GET.length())));
+ propName.append(methodName.substring(GET.length() + 1));
+ return propName.toString();
+ }
+
+ private <T extends Annotation> T getAnnotation(Method method, int index, Class<T> annotationType) {
+ Annotation[] annotations = method.getParameterAnnotations()[index];
+ for (Annotation annotation : annotations) {
+ if (annotation.annotationType() == annotationType) {
+ return annotationType.cast(annotation);
+ }
+ }
+ return null;
+ }
+
+ private static String getValue(String value, String defaultValue) {
+ return "".equals(value) ? defaultValue : value;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSUtils.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSUtils.java
new file mode 100644
index 0000000000..93e88ed650
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSUtils.java
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceProvider;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+
+
+/**
+ * A set of utility methods for processing JAXWS annotations that are
+ * shared between Java inteface and implementation processing
+ */
+public class JAXWSUtils {
+
+ /**
+ * JAXWS annotations may identify a service interface via either
+ * - an interface class name, e.g. @WebService(endpointInterface="my.service.ServiceImpl")
+ * - a wsdl file name, e.g. @WebService(wsdlLocation="some.wsdl")
+ * - a Java class/interface, e.g. @WebService
+ * This operation configures the Java interface based on these separate pieces
+ * of information. The resulting interface contract must be subsequently resolved in order that
+ * the named endpoint interface class or wsdl file is found
+ *
+ * @param javaInterface the Tuscany representation of the Java interface
+ * @param clazz the Java class that the interface refers to (may have JAXWS annotations)
+ * @return
+ */
+ public static JavaInterface configureJavaInterface(JavaInterface javaInterface,
+ Class<?> clazz){
+
+ String servineNamespace = JavaXMLMapper.getNamespace(clazz);
+ String serviceName = clazz.getSimpleName();
+ QName serviceQName = null;
+ String serviceInterfaceClassName = null;
+ String wsdlFileName = null;
+
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ if (webServiceAnnotation != null) {
+ servineNamespace = getValue(webServiceAnnotation.targetNamespace(), servineNamespace);
+ serviceName = getValue(webServiceAnnotation.name(), serviceName);
+ serviceInterfaceClassName = webServiceAnnotation.endpointInterface();
+ wsdlFileName = webServiceAnnotation.wsdlLocation();
+ javaInterface.setRemotable(true);
+ }
+
+ WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
+ if (webServiceProviderAnnotation != null) {
+ servineNamespace = getValue(webServiceProviderAnnotation.targetNamespace(), servineNamespace);
+ serviceName = getValue(webServiceProviderAnnotation.serviceName(), serviceName);
+ wsdlFileName = webServiceProviderAnnotation.wsdlLocation();
+ javaInterface.setRemotable(true);
+ }
+
+ serviceQName = new QName(servineNamespace, serviceName);
+ javaInterface.setQName(serviceQName);
+
+ // use the provided Java interface name to overwrite
+ // any Java interface created from an implemented interfaces
+ if (serviceInterfaceClassName != null &&
+ serviceInterfaceClassName.length() > 0){
+ javaInterface.setName(serviceInterfaceClassName);
+ javaInterface.setJAXWSJavaInterfaceName(serviceInterfaceClassName);
+ javaInterface.setUnresolved(true);
+ }
+
+ // Store the WSDL location if it's specified in
+ // the @WebService annotation. Later this is resolved and is attached
+ // to the Java interface contract in the normalized space so that effectively the contract
+ // has both Java and WSDL interfaces. This allows databinding to
+ // operate correctly as it still expects a Java interface for a Java implementation
+ if (wsdlFileName != null &&
+ wsdlFileName.length() > 0){
+ javaInterface.setJAXWSWSDLLocation(wsdlFileName);
+ }
+
+ return javaInterface;
+ }
+
+ /**
+ * Given a class that may have @WebService or @WebServiceProvider
+ * annotations this determines what the service QName should be.
+ *
+ * @param clazz
+ * @return
+ */
+/*
+ public static QName calculateServiceQName(JavaInterface javaInterface, Class<?> clazz){
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ String servineNamespace = JavaXMLMapper.getNamespace(clazz);
+ String serviceName = clazz.getSimpleName();
+ if (webServiceAnnotation != null) {
+ servineNamespace = getValue(webServiceAnnotation.targetNamespace(), servineNamespace);
+ serviceName = getValue(webServiceAnnotation.name(), serviceName);
+ javaInterface.setRemotable(true);
+ }
+
+ WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
+ if (webServiceProviderAnnotation != null) {
+ servineNamespace = getValue(webServiceProviderAnnotation.targetNamespace(), servineNamespace);
+ serviceName = getValue(webServiceProviderAnnotation.serviceName(), serviceName);
+ javaInterface.setRemotable(true);
+ }
+
+ QName serviceQName = new QName(servineNamespace, serviceName);
+ javaInterface.setQName(serviceQName);
+
+ return serviceQName;
+ }
+*/
+
+ /**
+ * Given a class that may have @WebService or @WebServiceProvider
+ * annotations this determines what the name of the Java class
+ * that defines the service interface should be
+ *
+ * @param clazz
+ * @return
+ */
+/*
+ public static String calculateServiceInterfaceJavaClassName(JavaInterface javaInterface, Class<?> clazz){
+ String serviceInterfaceClassName = null;
+
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ if (webServiceAnnotation != null) {
+ serviceInterfaceClassName = webServiceAnnotation.endpointInterface();
+ javaInterface.setRemotable(true);
+ }
+
+ return serviceInterfaceClassName;
+ }
+*/
+
+ /**
+ * Given a class that may have @WebService or @WebServiceProvider
+ * annotations this determines what the name of the WSDL file is
+ * that defines the service interface should be
+ *
+ * @param clazz
+ * @return
+ */
+/*
+ public static String calculateServiceInterfaceWSDLLocation(JavaInterface javaInterface, Class<?> clazz){
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ String wsdlLocation = null;
+
+ if (webServiceAnnotation != null) {
+ wsdlLocation = webServiceAnnotation.wsdlLocation();
+ javaInterface.setRemotable(true);
+ }
+
+ WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
+
+ if (webServiceProviderAnnotation != null) {
+ wsdlLocation = webServiceProviderAnnotation.wsdlLocation();
+ javaInterface.setRemotable(true);
+ }
+
+ return wsdlLocation;
+ }
+*/
+
+ /**
+ * JAXWS annotations may identify a service interface via either
+ * - an interface class name, e.g. @WebService(endpointInterface="my.service.ServiceImpl")
+ * - a wsdl file name, e.g. @WebService(wsdlLocation="some.wsdl")
+ * - a Java class/interface, e.g. @WebService
+ * This operation configures the Java interface based on these separate pieces
+ * of information. The resulting interface contract must be subsequently resolved in order that
+ * the named endpoint interface class or wsdl file is found
+ *
+ * @param javaInterface
+ * @param servicceQName
+ * @param javaInterfaceName
+ * @param wsdlFileName
+ * @return
+ */
+/*
+ public static JavaInterface configureJavaInterface(JavaInterface javaInterface,
+ QName serviceQName,
+ String javaInterfaceName,
+ String wsdlFileName) throws InvalidInterfaceException {
+
+ // use the provided Java interface name to overwrite
+ // any Java contract created from an implemented interfaces
+ if (javaInterfaceName != null &&
+ javaInterfaceName.length() > 0){
+ javaInterface.setName(javaInterfaceName);
+ javaInterface.setJAXWSJavaInterfaceName(javaInterfaceName);
+ javaInterface.setQName(serviceQName);
+ javaInterface.setUnresolved(true);
+ } else {
+ // we use the bean class as the service interface if no interface
+ // has already been set. This should have already been resolved
+ javaInterface.setQName(serviceQName);
+ }
+
+ // Store the WSDL location if it's specified in
+ // the @WebService annotation. Later this is resolved and is attached
+ // to the Java interface contract in the normalized space so that effectively the contract
+ // has both Java and WSDL interfaces. This allows databinding to
+ // operate correctly as it still expects a Java interface for a Java implementation
+ if (wsdlFileName != null &&
+ wsdlFileName.length() > 0){
+ javaInterface.setJAXWSWSDLLocation(wsdlFileName);
+ }
+
+ return javaInterface;
+ }
+*/
+
+
+ /**
+ * JAXWS annotations may identify a service interface via either
+ * - an interface class name, e.g. @WebService(endpointInterface="my.service.ServiceImpl")
+ * - a wsdl file name, e.g. @WebService(wsdlLocation="some.wsdl")
+ * - a Java class/interface, e.g. @WebService
+ * This operation creates the right sort of interface contract based on these separate pieces
+ * of information. The resulting interface contract must be subsequently resolved in order that
+ * the named endpoint interface class or wsdl file is found
+ *
+ * @param javaInterfaceFactory
+ * @param wsdlInterfaceFactory
+ * @param clazz
+ * @param javaInterfaceName
+ * @param wsdlFileName
+ * @return
+ * @throws InvalidInterfaceException
+ */
+/*
+ public static JavaInterfaceContract configureJavaInterface(JavaInterfaceFactory javaInterfaceFactory,
+ WSDLFactory wsdlFactory,
+ JavaInterfaceContract javaInterfaceContract,
+ Class<?> clazz,
+ QName serviceQName,
+ String javaInterfaceName,
+ String wsdlFileName) throws InvalidInterfaceException {
+
+ // use the provided Java interface name to overwrite
+ // any Java contract created from an implemented interfaces
+ if (javaInterfaceName != null &&
+ javaInterfaceName.length() > 0){
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface();
+ callInterface.setName(javaInterfaceName);
+ callInterface.setQName(serviceQName);
+ callInterface.setRemotable(true);
+ callInterface.setUnresolved(true);
+ javaInterfaceContract.setInterface(callInterface);
+ } else {
+ // we use the bean class as the service interface if no interface
+ // has already been set
+ if (javaInterfaceContract.getInterface() == null){
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(clazz);
+ callInterface.setQName(serviceQName);
+ callInterface.setRemotable(true);
+ callInterface.setUnresolved(false); // this will already be false but this makes it easy to follow the logic
+ javaInterfaceContract.setInterface(callInterface);
+ } else {
+ JavaInterface callInterface = (JavaInterface)javaInterfaceContract.getInterface();
+ callInterface.setRemotable(true);
+ callInterface.setQName(serviceQName);
+ }
+ }
+
+ // create the logical WSDL interface if it's specified in
+ // the @WebService annotation. This is attached to the Java interface
+ // contract in the normalized space so that effectively the contract
+ // has both Java and WSDL interfaces. This allows databinding to
+ // operate correctly as it expects a Java interface for a Java implementation
+ if (wsdlFileName != null &&
+ wsdlFileName.length() > 0){
+ WSDLInterface callInterface = wsdlFactory.createWSDLInterface();
+ callInterface.setUnresolved(true);
+ callInterface.setRemotable(true);
+
+ WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ wsdlInterfaceContract.setInterface(callInterface);
+ wsdlInterfaceContract.setLocation(wsdlFileName);
+ javaInterfaceContract.setNormailizedWSDLContract(wsdlInterfaceContract);
+ }
+
+ return javaInterfaceContract;
+ }
+*/
+
+ private static String getValue(String value, String defaultValue) {
+ return "".equals(value) ? defaultValue : value;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WebServiceInterfaceProcessor.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WebServiceInterfaceProcessor.java
new file mode 100644
index 0000000000..18eda13efb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WebServiceInterfaceProcessor.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import javax.jws.WebService;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+
+/**
+ * Introspect the java class/interface to see if it has @WebService annotation
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceInterfaceProcessor implements JavaInterfaceVisitor {
+
+ public WebServiceInterfaceProcessor() {
+ super();
+ }
+
+ public void visitInterface(JavaInterface contract) throws InvalidInterfaceException {
+
+ final Class<?> clazz = contract.getJavaClass();
+ WebService webService = clazz.getAnnotation(WebService.class);
+ if (webService != null) {
+ // Mark SEI as Remotable
+ contract.setRemotable(true);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
new file mode 100644
index 0000000000..764c10ff00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+
+public class WrapperBeanGenerator extends BaseBeanGenerator {
+
+ public List<Class<?>> generateWrapperBeans(Class<?> sei) {
+ GeneratedClassLoader cl = new GeneratedClassLoader(sei.getClassLoader());
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ for (Method m : sei.getMethods()) {
+ if (m.getDeclaringClass() == Object.class) {
+ continue;
+ }
+ classes.add(generateRequestWrapper(sei, m, cl));
+ classes.add(generateResponseWrapper(sei, m, cl));
+ }
+ return classes;
+
+ }
+
+ public Class<?> generateRequestWrapper(Class<?> sei, Method m, GeneratedClassLoader cl) {
+ String wrapperNamespace = JavaInterfaceUtil.getNamespace(sei);
+ String wrapperName = m.getName();
+ String wrapperBeanName = capitalize(wrapperName);
+ String wrapperClassName = CodeGenerationHelper.getPackagePrefix(sei) + wrapperBeanName;
+
+ return generateRequestWrapper(m, wrapperClassName, wrapperNamespace, wrapperName, cl);
+ }
+
+ public Class<?> generateRequestWrapper(Method m,
+ String wrapperClassName,
+ String wrapperNamespace,
+ String wrapperName,
+ GeneratedClassLoader cl) {
+ synchronized (m.getDeclaringClass()) {
+ MethodKey key = new MethodKey(m, true);
+ Class<?> wrapperClass = generatedClasses.get(key);
+ if (wrapperClass == null) {
+ String wrapperClassDescriptor = wrapperClassName.replace('.', '/');
+ String wrapperClassSignature = "L" + wrapperClassDescriptor + ";";
+
+ Class<?>[] paramTypes = m.getParameterTypes();
+ Type[] genericParamTypes = m.getGenericParameterTypes();
+ Annotation[][] paramAnnotations = m.getParameterAnnotations();
+ List<BeanProperty> properties = new ArrayList<BeanProperty>();
+ for (int i = 0; i < paramTypes.length; i++) {
+ String propNS = "";
+ String propName = "arg" + i;
+
+ WebParam webParam = findAnnotation(paramAnnotations[i], WebParam.class);
+ if (webParam != null && webParam.header()) {
+ continue;
+ }
+ WebParam.Mode mode = WebParam.Mode.IN;
+ if (webParam != null) {
+ mode = webParam.mode();
+ if (webParam.name().length() > 0) {
+ propName = webParam.name();
+ }
+ propNS = webParam.targetNamespace();
+ }
+ if (mode.equals(WebParam.Mode.IN) || mode.equals(WebParam.Mode.INOUT)) {
+ java.lang.reflect.Type genericParamType = getHolderValueType(genericParamTypes[i]);
+ Class<?> paramType = CodeGenerationHelper.getErasure(genericParamType);
+ BeanProperty prop = new BeanProperty(propNS, propName, paramType, genericParamType, true);
+ prop.getJaxbAnnotaions().addAll(findJAXBAnnotations(paramAnnotations[i]));
+ properties.add(prop);
+ }
+ }
+
+ wrapperClass =
+ generate(wrapperClassDescriptor, wrapperClassSignature, wrapperNamespace, wrapperName, properties
+ .toArray(new BeanProperty[properties.size()]), cl);
+ generatedClasses.put(key, wrapperClass);
+ }
+ return wrapperClass;
+
+ }
+ }
+
+ public Class<?> generateResponseWrapper(Class<?> sei, Method m, GeneratedClassLoader cl) {
+ String wrapperNamespace = JavaInterfaceUtil.getNamespace(sei);
+
+ String wrapperName = m.getName() + "Response";
+ String wrapperBeanName = capitalize(wrapperName);
+ String wrapperClassName = CodeGenerationHelper.getPackagePrefix(sei) + wrapperBeanName;
+ return generateResponseWrapper(m, wrapperClassName, wrapperNamespace, wrapperName, cl);
+
+ }
+
+ public Class<?> generateResponseWrapper(Method m,
+ String wrapperClassName,
+ String wrapperNamespace,
+ String wrapperName,
+ GeneratedClassLoader cl) {
+ synchronized (m.getDeclaringClass()) {
+ MethodKey key = new MethodKey(m, false);
+ Class<?> wrapperClass = generatedClasses.get(key);
+ if (wrapperClass == null) {
+ String wrapperClassDescriptor = wrapperClassName.replace('.', '/');
+ String wrapperClassSignature = "L" + wrapperClassDescriptor + ";";
+
+ List<BeanProperty> properties = new ArrayList<BeanProperty>();
+ // Collect all OUT, INOUT parameters as fields
+ Annotation[][] paramAnns = m.getParameterAnnotations();
+ Class<?>[] paramTypes = m.getParameterTypes();
+ java.lang.reflect.Type[] genericParamTypes = m.getGenericParameterTypes();
+ for (int i = 0; i < paramTypes.length; i++) {
+ WebParam webParam = findAnnotation(paramAnns[i], WebParam.class);
+ if (webParam != null) {
+ if (webParam.header() || webParam.mode() == WebParam.Mode.IN) {
+ continue;
+ }
+ }
+ if (!isHolder(genericParamTypes[i])) {
+ continue;
+ }
+
+ List<Annotation> jaxb = findJAXBAnnotations(paramAnns[i]);
+
+ java.lang.reflect.Type genericParamType = getHolderValueType(genericParamTypes[i]);
+ Class<?> paramType = CodeGenerationHelper.getErasure(genericParamType);
+
+ String paramNamespace = "";
+ String paramName = "arg" + i;
+
+ if (webParam != null) {
+ if (webParam.name().length() > 0)
+ paramName = webParam.name();
+ if (webParam.targetNamespace().length() > 0)
+ paramNamespace = webParam.targetNamespace();
+ }
+
+ BeanProperty prop = new BeanProperty(paramNamespace, paramName, paramType, genericParamType, true);
+ prop.getJaxbAnnotaions().addAll(jaxb);
+ properties.add(prop);
+ }
+
+ WebResult webResult = m.getAnnotation(WebResult.class);
+ Class<?> returnType = m.getReturnType();
+ if (!((webResult != null && webResult.header()) || returnType == Void.TYPE)) {
+ String propName = "return";
+ String propNS = "";
+
+ if (webResult != null) {
+ if (webResult.name().length() > 0) {
+ propName = webResult.name();
+ }
+ if (webResult.targetNamespace().length() > 1) {
+ propNS = webResult.targetNamespace();
+ }
+ }
+
+ List<Annotation> jaxb = findJAXBAnnotations(m.getAnnotations());
+
+ Type genericReturnType = m.getGenericReturnType();
+ BeanProperty prop = new BeanProperty(propNS, propName, returnType, genericReturnType, true);
+ prop.getJaxbAnnotaions().addAll(jaxb);
+ properties.add(prop);
+ }
+ wrapperClass =
+ generate(wrapperClassDescriptor, wrapperClassSignature, wrapperNamespace, wrapperName, properties
+ .toArray(new BeanProperty[properties.size()]), cl);
+ generatedClasses.put(key, wrapperClass);
+ }
+ return wrapperClass;
+
+ }
+ }
+
+ private static class MethodKey {
+ private Method m;
+ private boolean request;
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((m == null) ? 0 : m.hashCode());
+ result = prime * result + (request ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final MethodKey other = (MethodKey)obj;
+ if (m == null) {
+ if (other.m != null)
+ return false;
+ } else if (!m.equals(other.m))
+ return false;
+ if (request != other.request)
+ return false;
+ return true;
+ }
+
+ public MethodKey(Method m, boolean request) {
+ super();
+ this.m = m;
+ this.request = request;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.FaultExceptionMapper b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.FaultExceptionMapper
new file mode 100644
index 0000000000..6a968e11d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.FaultExceptionMapper
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.java.jaxws.JAXWSFaultExceptionMapper
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
new file mode 100644
index 0000000000..86255f4fef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
@@ -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.
+org.apache.tuscany.sca.interfacedef.java.jaxws.WebServiceInterfaceProcessor;ranking=400
+org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor;ranking=100
+org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSAsyncInterfaceProcessor;ranking=900
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean.java
new file mode 100644
index 0000000000..1b07e25bad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.java.jaxws;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Bean<T> {
+ T getP1();
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean1.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean1.java
new file mode 100644
index 0000000000..d38a21ba52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean1.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.java.jaxws;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Bean1 {
+ private String p1;
+ private int p2;
+ public String getP1() {
+ return p1;
+ }
+ public void setP1(String p1) {
+ this.p1 = p1;
+ }
+ public int getP2() {
+ return p2;
+ }
+ public void setP2(int p2) {
+ this.p2 = p2;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean2.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean2.java
new file mode 100644
index 0000000000..7b9375063d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean2.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.java.jaxws;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Bean2 implements Bean<String>{
+ private String p1;
+ private int p2;
+ public String getP1() {
+ return p1;
+ }
+ public void setP1(String p1) {
+ this.p1 = p1;
+ }
+ public int getP2() {
+ return p2;
+ }
+ public void setP2(int p2) {
+ this.p2 = p2;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java
new file mode 100644
index 0000000000..67b9c84399
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.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 org.apache.tuscany.sca.interfacedef.java.jaxws;
+
+/**
+ * Bean Interface
+ */
+public interface BeanInterface {
+ String getAttr();
+ void setAttr(String attr);
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java
new file mode 100644
index 0000000000..f964ea374b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.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 org.apache.tuscany.sca.interfacedef.java.jaxws;
+
+/**
+ * Impl of BeanInterface
+ */
+public class BeanInterfaceImpl implements BeanInterface {
+ private String attr;
+
+ public String getAttr() {
+ return attr;
+ }
+
+ public void setAttr(String attr) {
+ this.attr = attr;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java
new file mode 100644
index 0000000000..3ea1427494
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.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.sca.interfacedef.java.jaxws;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.annotation.Annotation;
+
+import javax.xml.bind.JAXBContext;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.util.CheckClassAdapter;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FaultBeanGeneratorTestCase {
+
+ @Test
+ public void testGenerate() throws IOException {
+ byte[] content = new FaultBeanGenerator().generate(MyException.class);
+ ClassReader cr = new ClassReader(content);
+ PrintWriter pw = new PrintWriter(System.out);
+ CheckClassAdapter.verify(cr, false, pw);
+ }
+
+ @Test
+ public void testGenerateClass() throws Exception {
+ Class<?> cls = FaultBeanGenerator.generateFaultBeanClass(MyException.class);
+ Assert.assertEquals("org.apache.tuscany.sca.interfacedef.java.jaxws.jaxws.MyExceptionBean", cls.getName());
+ for (Annotation a : cls.getAnnotations()) {
+ System.out.println(a);
+ }
+ // XmlType xmlType = cls.getAnnotation(XmlType.class);
+ // System.out.println(xmlType);
+ Object bean = cls.newInstance();
+ JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(cls);
+ StringWriter sw = new StringWriter();
+ context.createMarshaller().marshal(bean, sw);
+ System.out.println(sw.toString());
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessorTestCase.java
new file mode 100644
index 0000000000..ec73ad4218
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessorTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.java.jaxws;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JAXWSAsyncInterfaceProcessorTestCase {
+ private ExtensionPointRegistry registry;
+
+ @Before
+ public void setUp() throws Exception {
+ registry = new DefaultExtensionPointRegistry();
+ }
+
+ /**
+ * Test method for
+ * {@link org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSAsyncInterfaceProcessor#visitInterface(JavaInterface)}.
+ */
+ @Test
+ public final void testProcessor() throws Exception {
+ DefaultJavaInterfaceFactory iFactory = new DefaultJavaInterfaceFactory(registry);
+ JavaInterface contract = iFactory.createJavaInterface(StockQuote.class);
+
+ assertTrue(contract.isRemotable());
+
+ Assert.assertEquals(1,contract.getOperations().size());
+
+ List<Operation> asyncOperations = (List<Operation>) contract.getAttributes().get("JAXWS-ASYNC-OPERATIONS");
+ Assert.assertEquals(2,asyncOperations.size());
+
+ //list operation
+ System.out.println(">>> Filtered Operations");
+ for(Operation o : contract.getOperations()) {
+ System.out.println(">>>>>>" + o);
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java
new file mode 100644
index 0000000000..5f3114a67c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.example.stock.StockExceptionTest;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXWSJavaInterfaceProcessorTestCase {
+ private ExtensionPointRegistry registry;
+ // private JAXWSJavaInterfaceProcessor interfaceProcessor;
+
+ @Before
+ public void setUp() throws Exception {
+ registry = new DefaultExtensionPointRegistry();
+// DataBindingExtensionPoint db = new DefaultDataBindingExtensionPoint(registry);
+// XMLAdapterExtensionPoint xa = new DefaultXMLAdapterExtensionPoint();
+ // interfaceProcessor = new JAXWSJavaInterfaceProcessor(db, new JAXWSFaultExceptionMapper(db, xa), xa);
+ }
+
+ @Test
+ public void testWrapper() throws Exception {
+ DefaultJavaInterfaceFactory iFactory = new DefaultJavaInterfaceFactory(registry);
+ JavaInterface contract = iFactory.createJavaInterface(StockExceptionTest.class);
+
+ // interfaceProcessor.visitInterface(contract);
+ Operation op = contract.getOperations().get(0);
+ Assert.assertTrue(!op.isWrapperStyle());
+ Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOffer"), op.getWrapper().getInputWrapperElement().getQName());
+ Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOfferResponse"), op.getWrapper().getOutputWrapperElement().getQName());
+ }
+
+ /**
+ * Test method for
+ * {@link org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor#visitInterface(JavaInterface)}.
+ */
+ @Test
+ public final void testProcessor() throws Exception {
+ DefaultJavaInterfaceFactory iFactory = new DefaultJavaInterfaceFactory(registry);
+ JavaInterface contract = iFactory.createJavaInterface(WebServiceInterfaceWithoutAnnotation.class);
+
+ // interfaceProcessor.visitInterface(contract);
+ assertFalse(contract.isRemotable());
+
+ contract = iFactory.createJavaInterface(WebServiceInterfaceWithAnnotation.class);
+ // interfaceProcessor.visitInterface(contract);
+ assertTrue(contract.isRemotable());
+
+ Operation op1 = contract.getOperations().get(0);
+ Operation op2 = contract.getOperations().get(1);
+
+ Operation op = null;
+ if ("m1".equals(op1.getName())) {
+ op = op1;
+ } else {
+ op = op2;
+ }
+
+ assertTrue(!op.isWrapperStyle() && op.getWrapper() == null);
+
+ if ("M2".equals(op2.getName())) {
+ op = op2;
+ } else {
+ op = op1;
+ }
+ assertTrue(!op.isWrapperStyle() && op.getWrapper() != null);
+
+ }
+
+ @WebService
+ private static interface WebServiceInterfaceWithAnnotation {
+
+ @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+ @WebMethod(operationName = "m1")
+ String m1(String str);
+
+ @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
+ @WebMethod(operationName = "M2")
+ String m2(String str, int i);
+ }
+
+ private static interface WebServiceInterfaceWithoutAnnotation {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JavaReflectionHelperTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JavaReflectionHelperTestCase.java
new file mode 100644
index 0000000000..6315e12ff8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JavaReflectionHelperTestCase.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.sca.interfacedef.java.jaxws;
+
+import java.lang.reflect.Field;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaReflectionHelperTestCase {
+ @Test
+ public void testErasure() throws Exception {
+ for (Field f : TestGenericClass.class.getDeclaredFields()) {
+ Class<?> cls = CodeGenerationHelper.getErasure(f.getGenericType());
+ System.out.println(cls.getName());
+ Assert.assertSame(f.getType(), cls);
+ }
+ }
+
+ @Test
+ public void testSignature() throws Exception {
+ for (Field f : TestGenericClass.class.getDeclaredFields()) {
+ String sig = CodeGenerationHelper.getSignature(f.getGenericType());
+ System.out.println(sig);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyException.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyException.java
new file mode 100644
index 0000000000..4df0517de6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyException.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.interfacedef.java.jaxws;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class MyException extends Exception {
+ private String error;
+ private int code;
+
+ public MyException() {
+ super();
+ }
+
+ public MyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MyException(String message) {
+ super(message);
+ }
+
+ public MyException(Throwable cause) {
+ super(cause);
+ }
+
+ public String getError() {
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyServiceImpl.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyServiceImpl.java
new file mode 100644
index 0000000000..78527193d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyServiceImpl.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.interfacedef.java.jaxws;
+
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@WebService
+public class MyServiceImpl {
+
+ public MyServiceImpl() {
+ super();
+ }
+
+ @WebMethod
+ public <T extends Bean1> T getBean(T b, Bean2 b2) {
+ return null;
+ }
+
+ @WebMethod
+ public List<? extends Bean1> getBeans() {
+ return null;
+ }
+
+ @WebMethod
+ public String convert(String str, int i) throws MyException {
+ return "ME";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/StockQuote.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/StockQuote.java
new file mode 100644
index 0000000000..d1259e9120
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/StockQuote.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.java.jaxws;
+
+import java.util.concurrent.Future;
+
+import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+/**
+ * JAX-WS Async style interface
+ *
+ * @version $Rev$ $Date$
+ */
+
+@WebService
+public interface StockQuote {
+
+ float getPrice(String ticker);
+
+ Response<Float> getPriceAsync(String ticker);
+
+ Future<?> getPriceAsync(String ticker, AsyncHandler<Float> callback);
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java
new file mode 100644
index 0000000000..fb319a3b0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.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.sca.interfacedef.java.jaxws;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * Test XML Adapter
+ */
+public class TestAdapter extends XmlAdapter<BeanInterfaceImpl, BeanInterface> {
+
+ @Override
+ public BeanInterfaceImpl marshal(BeanInterface v) throws Exception {
+ return (BeanInterfaceImpl)v;
+ }
+
+ @Override
+ public BeanInterface unmarshal(BeanInterfaceImpl v) throws Exception {
+ return v;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestGenericClass.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestGenericClass.java
new file mode 100644
index 0000000000..2ecf822904
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestGenericClass.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.java.jaxws;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestGenericClass <T extends Serializable & List<String>, S> {
+ public TestGenericClass<?, S> i;
+ public T f1;
+ public T[] f2;
+ public S f3;
+ public List<? extends T> list1;
+ public List<?> list2;
+ public List<? extends Serializable> list3;
+ public int f4;
+ public int[] f5;
+ public Map<? super T, S> map;
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java
new file mode 100644
index 0000000000..1f8e6cb445
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.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.interfacedef.java.jaxws;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.ws.Holder;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface TestInterface {
+ int convert(String currency1, String currency2);
+
+ List<Double> getRates(String currency);
+
+ void check(boolean flag);
+
+ String[] list(int[] list);
+
+ int[][] map(String[][] strs);
+
+ String getGreetings(String name);
+
+ String[] getGreetingsArray(String[] names);
+
+ List<String> getGreetingsList(List<String> names);
+
+ ArrayList<String> getGreetingsArrayList(ArrayList<String> names);
+
+ Map<String, String> getGreetingsMap(Map<String, String> namesMap);
+
+ HashMap<String, String> getGreetingsHashMap(HashMap<String, String> namesMap);
+
+ @WebMethod
+ @WebResult(name = "output")
+ String webMethod(@WebParam(name = "input", mode = WebParam.Mode.IN) String in,
+ @WebParam(name = "holder", mode = WebParam.Mode.INOUT) Holder<String> holder);
+
+ @XmlJavaTypeAdapter(type = BeanInterface.class, value = TestAdapter.class)
+ BeanInterface beanMethod(@XmlJavaTypeAdapter(type = BeanInterface.class, value = TestAdapter.class) BeanInterface in,
+ String str);
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java
new file mode 100644
index 0000000000..f83c27e10a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.jaxws;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBTypeHelper;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WrapperBeanGeneratorTestCase {
+ @Test
+ public void testGenerate() throws Exception {
+ List<Class<?>> classes = new WrapperBeanGenerator().generateWrapperBeans(TestInterface.class);
+ for (Class<?> cls : classes) {
+ for (Field f : cls.getDeclaredFields()) {
+ System.out.println(f.getName());
+ System.out.println(f.getGenericType());
+ for (Annotation a : f.getAnnotations()) {
+ System.out.println(a);
+ }
+ }
+ for (Method m : cls.getDeclaredMethods()) {
+ System.out.println(m);
+ for (Annotation a : m.getAnnotations()) {
+ System.out.println(a);
+ }
+ }
+ }
+ JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
+ for (Class<?> cls : classes) {
+ Object obj = cls.newInstance();
+ StringWriter sw = new StringWriter();
+ context.createMarshaller().marshal(obj, sw);
+ // System.out.println(sw.toString());
+ StringReader sr = new StringReader(sw.toString());
+ context.createUnmarshaller().unmarshal(new StreamSource(sr), cls);
+ }
+ }
+
+ @Test
+ public void testGenerateSchema() throws Exception {
+ List<Class<?>> classes = new WrapperBeanGenerator().generateWrapperBeans(TestInterface.class);
+ JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
+ Map<String, String> results = JAXBTypeHelper.generateSchema(context);
+ for (String xsd : results.values()) {
+ System.out.println(xsd);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/resources/wsdl/Stock.wsdl b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/resources/wsdl/Stock.wsdl
new file mode 100644
index 0000000000..56a753f4ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/resources/wsdl/Stock.wsdl
@@ -0,0 +1,142 @@
+<?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://www.example.com/stock" xmlns:impl="http://www.example.com/stock"
+ xmlns:tns="http://www.example.com/stock" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="StockExceptionTest">
+ <wsdl:types>
+ <schema targetNamespace="http://www.example.com/stock" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <complexType name="StockOffer">
+ <sequence>
+ <element name="symbol" minOccurs="1" type="xsd:string" />
+ <element name="price" minOccurs="1" type="xsd:float" nillable="true" /><!-- max price reqested, actual response -->
+ <element name="name" minOccurs="0" type="xsd:string" />
+ <element name="list" minOccurs="0" maxOccurs="unbounded" type="xsd:string" />
+ </sequence>
+ </complexType>
+
+ <element name="stockQuoteOffer">
+ <complexType>
+ <sequence>
+ <element name="input" minOccurs="0" maxOccurs="unbounded" type="tns:StockOffer" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="stockQuoteOfferResponse">
+ <complexType>
+ <sequence>
+ <element name="stockQuoteOfferReturn" minOccurs="0" type="tns:StockOffer" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Faults -->
+ <element name="InvalidSymbolFault">
+ <complexType>
+ <sequence>
+ <element name="message" minOccurs="1" type="xsd:string" />
+ <element name="offer" minOccurs="1" type="tns:StockOffer" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="MarketClosedFault" type="xsd:int" />
+
+ <element name="TestNotDeclaredAtSourceFault" type="xsd:string" />
+
+ </schema>
+ </wsdl:types>
+
+
+ <wsdl:message name="stockQuoteOfferRequest">
+ <wsdl:part element="tns:stockQuoteOffer" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="stockQuoteOfferResponse">
+ <wsdl:part element="tns:stockQuoteOfferResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="InvalidSymbolFault">
+ <wsdl:part element="tns:InvalidSymbolFault" name="fault" />
+ </wsdl:message>
+
+ <wsdl:message name="MarketClosedFault">
+ <wsdl:part element="tns:MarketClosedFault" name="fault" />
+ </wsdl:message>
+
+ <wsdl:message name="TestNotDeclaredAtSourceFault">
+ <wsdl:part element="tns:TestNotDeclaredAtSourceFault" name="fault" />
+ </wsdl:message>
+
+
+ <wsdl:portType name="StockExceptionTest">
+ <wsdl:operation name="stockQuoteOffer">
+ <wsdl:input message="tns:stockQuoteOfferRequest" name="stockQuoteOfferRequest" />
+
+ <wsdl:output message="tns:stockQuoteOfferResponse" name="stockQuoteOfferResponse" />
+
+ <wsdl:fault message="tns:InvalidSymbolFault" name="InvalidSymbolException" />
+
+ <wsdl:fault message="tns:MarketClosedFault" name="MarketClosedException" />
+
+ <wsdl:fault message="tns:TestNotDeclaredAtSourceFault" name="TestNotDeclaredAtSourceException" />
+ </wsdl:operation>
+
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockExceptionTestServiceSoapBinding" type="tns:StockExceptionTest">
+ <!-- <wsaw:UsingAddressing wsdl:required="false" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"/> -->
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+
+ <wsdl:operation name="stockQuoteOffer">
+ <wsdlsoap:operation soapAction="" />
+
+ <wsdl:input name="stockQuoteOfferRequest">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+
+ <wsdl:output name="stockQuoteOfferResponse">
+ <wsdlsoap:body use="literal" />
+ </wsdl:output>
+
+ <wsdl:fault name="InvalidSymbolException">
+ <wsdlsoap:fault name="InvalidSymbolException" use="literal" />
+ </wsdl:fault>
+
+ <wsdl:fault name="MarketClosedException">
+ <wsdlsoap:fault name="MarketClosedException" use="literal" />
+ </wsdl:fault>
+
+ <wsdl:fault name="TestNotDeclaredAtSourceException">
+ <wsdlsoap:fault name="TestNotDeclaredAtSourceException" use="literal" />
+ </wsdl:fault>
+
+
+
+ </wsdl:operation>
+
+
+ </wsdl:binding>
+
+
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/resources/wsdl/StockExceptionTest.wsdl b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/resources/wsdl/StockExceptionTest.wsdl
new file mode 100644
index 0000000000..494617f988
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java-jaxws/src/test/resources/wsdl/StockExceptionTest.wsdl
@@ -0,0 +1,171 @@
+<?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://www.example.com/stock" xmlns:impl="http://www.example.com/stock"
+ xmlns:tns="http://www.example.com/stock" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="StockExceptionTest">
+ <wsdl:types>
+ <schema targetNamespace="http://www.example.com/stock" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0">
+ <complexType name="StockOffer">
+ <sequence>
+ <element name="symbol" minOccurs="1" type="xsd:string" />
+ <element name="price" minOccurs="1" type="xsd:float" nillable="true" /> <!-- max price reqested, actual response -->
+ <element name="name" minOccurs="0" type="xsd:string" />
+ <element name="list" minOccurs="0" maxOccurs="unbounded" type="xsd:string" />
+ </sequence>
+ </complexType>
+
+ <element name="stockQuoteOffer">
+ <complexType>
+ <sequence>
+ <element name="input" minOccurs="0" maxOccurs="unbounded" type="tns:StockOffer" />
+ </sequence>
+ </complexType>
+ </element>
+ <!-- TUSCANY 2505, make the responseWrapper non-anonymous -->
+ <element name="stockQuoteOfferResponse" type="tns:StockQuoteOfferResponseType">
+ </element>
+ <complexType name="StockQuoteOfferResponseType">
+ <sequence>
+ <element name="stockQuoteOfferReturn" minOccurs="0" type="tns:StockOffer" />
+ </sequence>
+ </complexType>
+ <!-- Faults -->
+ <element name="InvalidSymbolFault">
+ <complexType>
+ <sequence>
+ <element name="message" minOccurs="1" type="xsd:string" />
+ <element name="offer" minOccurs="1" type="tns:StockOffer" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="MarketClosedFault" type="xsd:int" />
+
+ <element name="TestNotDeclaredAtSourceFault" type="xsd:string" />
+
+ <element name="anyElement">
+ <complexType>
+ <sequence>
+ <element name="first" type="anyType">
+ <annotation>
+ <appinfo>
+ <jaxb:dom />
+ </appinfo>
+ </annotation>
+ </element>
+ <any maxOccurs="unbounded" processContents="skip">
+ <annotation>
+ <appinfo>
+ <jaxb:dom />
+ </appinfo>
+ </annotation>
+ </any>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+
+ <wsdl:message name="stockQuoteOfferRequest">
+ <wsdl:part element="tns:stockQuoteOffer" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="stockQuoteOfferResponse">
+ <wsdl:part element="tns:stockQuoteOfferResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="InvalidSymbolFault">
+ <wsdl:part element="tns:InvalidSymbolFault" name="fault" />
+ </wsdl:message>
+
+ <wsdl:message name="MarketClosedFault">
+ <wsdl:part element="tns:MarketClosedFault" name="fault" />
+ </wsdl:message>
+
+ <wsdl:message name="TestNotDeclaredAtSourceFault">
+ <wsdl:part element="tns:TestNotDeclaredAtSourceFault" name="fault" />
+ </wsdl:message>
+
+
+ <wsdl:portType name="StockExceptionTest">
+ <wsdl:operation name="stockQuoteOffer">
+ <wsdl:input message="tns:stockQuoteOfferRequest" name="stockQuoteOfferRequest" />
+
+ <wsdl:output message="tns:stockQuoteOfferResponse" name="stockQuoteOfferResponse" />
+
+ <wsdl:fault message="tns:InvalidSymbolFault" name="InvalidSymbolException" />
+
+ <wsdl:fault message="tns:MarketClosedFault" name="MarketClosedException" />
+
+ <wsdl:fault message="tns:TestNotDeclaredAtSourceFault" name="TestNotDeclaredAtSourceException" />
+ </wsdl:operation>
+
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockExceptionTestServiceSoapBinding" type="tns:StockExceptionTest">
+ <!-- <wsaw:UsingAddressing wsdl:required="false" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"/> -->
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+
+ <wsdl:operation name="stockQuoteOffer">
+ <wsdlsoap:operation soapAction="" />
+
+ <wsdl:input name="stockQuoteOfferRequest">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+
+ <wsdl:output name="stockQuoteOfferResponse">
+ <wsdlsoap:body use="literal" />
+ </wsdl:output>
+
+ <wsdl:fault name="InvalidSymbolException">
+ <wsdlsoap:fault name="InvalidSymbolException" use="literal" />
+ </wsdl:fault>
+
+ <wsdl:fault name="MarketClosedException">
+ <wsdlsoap:fault name="MarketClosedException" use="literal" />
+ </wsdl:fault>
+
+ <wsdl:fault name="TestNotDeclaredAtSourceException">
+ <wsdlsoap:fault name="TestNotDeclaredAtSourceException" use="literal" />
+ </wsdl:fault>
+
+
+
+ </wsdl:operation>
+
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockExceptionTestService">
+ <wsdl:port binding="tns:StockExceptionTestServiceSoapBinding" name="StockExceptionTestServiceSoapPort">
+ <wsdlsoap:address location="http://localhost:8085/services/exchangeJaxbService" />
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/LICENSE b/sandbox/sebastien/java/embed/modules/interface-java/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/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/sebastien/java/embed/modules/interface-java/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/interface-java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..da6bb50c73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/META-INF/MANIFEST.MF
@@ -0,0 +1,45 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.interfacedef.java.impl;uses:="o
+ rg.osoa.sca.annotations,org.apache.tuscany.sca.interfacedef.util,org.
+ apache.tuscany.sca.policy,org.apache.tuscany.sca.interfacedef.java,or
+ g.apache.tuscany.sca.interfacedef,javax.xml.namespace,org.apache.tusc
+ any.sca.interfacedef.java.introspect,org.apache.tuscany.sca.interface
+ def.impl";version="2.0.0",org.apache.tuscany.sca.interfacedef.java.intr
+ ospect;uses:="org.apache.tuscany.sca.interfacedef.java,org.apache.tus
+ cany.sca.interfacedef";version="2.0.0",org.apache.tuscany.sca.interface
+ def.java;uses:="org.apache.tuscany.sca.assembly,org.apache.tuscany.sc
+ a.interfacedef.java.impl,org.apache.tuscany.sca.interfacedef.java.int
+ rospect,org.apache.tuscany.sca.core,org.apache.tuscany.sca.policy,org
+ .apache.tuscany.sca.interfacedef,org.apache.tuscany.sca.extensibility
+ ,javax.xml.namespace";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Java Interface Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Java Interface Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.interface.java
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/NOTICE b/sandbox/sebastien/java/embed/modules/interface-java/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/pom.xml b/sandbox/sebastien/java/embed/modules/interface-java/pom.xml
new file mode 100644
index 0000000000..22f9234cd3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/pom.xml
@@ -0,0 +1,64 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-interface-java</artifactId>
+ <name>Apache Tuscany SCA Interface Java Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
new file mode 100644
index 0000000000..89b8c7193d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceFactoryImpl;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+
+/**
+ * A factory for the Java interface model.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class DefaultJavaInterfaceFactory extends JavaInterfaceFactoryImpl implements JavaInterfaceFactory {
+ private static final Logger logger = Logger.getLogger(DefaultJavaInterfaceFactory.class.getName());
+
+ private ExtensionPointRegistry registry;
+ // private Monitor monitor = null;
+ private boolean loadedVisitors;
+
+ public DefaultJavaInterfaceFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ @Override
+ public List<JavaInterfaceVisitor> getInterfaceVisitors() {
+ loadVisitors();
+ return super.getInterfaceVisitors();
+ }
+
+ /**
+ * Load visitors declared under META-INF/services
+ */
+ @SuppressWarnings("unchecked")
+ private synchronized void loadVisitors() {
+ if (loadedVisitors)
+ return;
+
+ // Get the databinding service declarations
+ Collection<ServiceDeclaration> visitorDeclarations;
+ try {
+ visitorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(JavaInterfaceVisitor.class, true);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Load data bindings
+ for (ServiceDeclaration visitorDeclaration: visitorDeclarations) {
+ JavaInterfaceVisitor visitor = null;
+ try {
+ Class<JavaInterfaceVisitor> visitorClass = (Class<JavaInterfaceVisitor>)visitorDeclaration.loadClass();
+
+ try {
+ Constructor<JavaInterfaceVisitor> constructor = visitorClass.getConstructor(ExtensionPointRegistry.class);
+ visitor = constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ visitor = visitorClass.newInstance();
+ }
+
+
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+
+ logger.fine("Adding Java Interface visitor: " + visitor.getClass().getName());
+
+ addInterfaceVisitor(visitor);
+ }
+
+ loadedVisitors = true;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.java
new file mode 100644
index 0000000000..e042d863d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.interfacedef.Interface;
+
+/**
+ * Represents a Java interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface JavaInterface extends Interface, Base {
+
+ /**
+ * Returns the name of the Java interface class.
+ *
+ * @return the name of the Java interface class
+ */
+ String getName();
+
+ /**
+ * Sets the name of the Java interface class.
+ *
+ * @param className the name of the Java interface class
+ */
+ void setName(String className);
+
+ /**
+ * Returns the QName of the JAX-WS interface.
+ *
+ * @return the QName of the JAX-WS interface
+ */
+ QName getQName();
+
+ /**
+ * Sets the QName of the JAX-WS interface.
+ *
+ * @param interfaceName the QName of the JAX-WS interface
+ */
+ void setQName(QName interfaceName);
+
+ /**
+ * Returns the Java interface class.
+ *
+ * @return the Java interface class
+ */
+ Class<?> getJavaClass();
+
+ /**
+ * Sets the Java interface class.
+ *
+ * @param javaClass the Java interface class
+ */
+ void setJavaClass(Class<?> javaClass);
+
+ /**
+ * Returns the callback class specified in an @Callback annotation.
+ *
+ * @return the callback class specified in an @Callback annotation
+ */
+ Class<?> getCallbackClass();
+
+ /**
+ * Sets the callback class specified in an @Callback annotation.
+ *
+ * @param callbackClass the callback class specified in an @Callback annotation
+ */
+ void setCallbackClass(Class<?> callbackClass);
+
+ /**
+ * A Java interface may have JAXWS annotations that refer to a
+ * a WSDL document. The resulting WSDL location is stored here
+ * so that is can be resolved after the Java interface itself
+ * has been resolved
+ *
+ * @return WSDL interface
+ */
+ String getJAXWSWSDLLocation();
+
+ /**
+ * A Java interface may have JAXWS annotations that refer to a
+ * a WSDL document. The resulting WSDL location is stored here
+ * so that is can be resolved after the Java interface itself
+ * has been resolved
+ *
+ * @param wsdlInterface
+ */
+ void setJAXWSWSDLLocation(String wsdlLocation);
+
+ /**
+ * A Java interface may have JAXWS annotations that refer to a
+ * a Java interface by name. The resulting class name is stored here
+ * so that is can be resolved after this Java interface
+ * has been resolved
+ *
+ * @return
+ */
+ String getJAXWSJavaInterfaceName();
+
+ /**
+ * A Java interface may have JAXWS annotations that refer to a
+ * a Java interface by name. The resulting class name is stored here
+ * so that is can be resolved after this Java interface
+ * has been resolved
+ *
+ * @return
+ */
+ void setJAXWSJavaInterfaceName(String javaInterfaceName);
+
+ public Contribution getContributionContainingClass();
+
+ public void setContributionContainingClass(Contribution contributionContainingClass);
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.java
new file mode 100644
index 0000000000..25875dbd6a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.java;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a Java interface contract.
+ * JavaInterfaceContract
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface JavaInterfaceContract extends InterfaceContract {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java
new file mode 100644
index 0000000000..4f4e9d8268
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.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.sca.interfacedef.java;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+
+/**
+ * Factory for the Java interface model
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface JavaInterfaceFactory {
+
+ /**
+ * Creates a new Java interface model.
+ *
+ * @return
+ */
+ JavaInterface createJavaInterface();
+
+ /**
+ * Creates a new Java interface model from an interface class.
+ * @param interfaceClass the interface class to introspect.
+ * @return
+ */
+ JavaInterface createJavaInterface(Class<?> interfaceClass) throws InvalidInterfaceException;
+
+ /**
+ * Creates the contents of a Java interface model from an interface class.
+ * @param javaInterface the Java interface model
+ * @param interfaceClass the interface class to introspect.
+ * @return
+ */
+ void createJavaInterface(JavaInterface javaInterface, Class<?> interfaceClass) throws InvalidInterfaceException;
+
+ /**
+ * Create a JavaOperation
+ * @param method
+ * @return
+ */
+ JavaOperation createJavaOperation(Method method);
+
+ /**
+ * Creates a new Java interface contract.
+ *
+ * @return
+ */
+ JavaInterfaceContract createJavaInterfaceContract();
+
+ /**
+ * Registers the given visitor.
+ *
+ * @param visitor
+ */
+ void addInterfaceVisitor(JavaInterfaceVisitor visitor);
+
+ /**
+ * Deregisters the given visitor.
+ *
+ * @param visitor
+ */
+ void removeInterfaceVisitor(JavaInterfaceVisitor visitor);
+
+ /**
+ * Returns a list of interface visitors.
+ *
+ * @return
+ */
+ List<JavaInterfaceVisitor> getInterfaceVisitors();
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.java
new file mode 100644
index 0000000000..e894ac279b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.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.interfacedef.java;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * Represents a Java operation.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface JavaOperation extends Operation {
+
+ /**
+ * Returns the Java method defining the operation.
+ * @return the Java method
+ */
+ Method getJavaMethod();
+
+ /**
+ * Sets the Java method defining the operation.
+ * @param method the Java method
+ */
+ void setJavaMethod(Method method);
+
+ /**
+ * Returns the JAX-WS @WebMethod action parameter.
+ * @return the action value
+ */
+ String getAction();
+
+ /**
+ * Sets the JAX-WS @WebMethod action parameter.
+ * @param action the action value
+ */
+ void setAction(String action);
+
+ /**
+ * Sets whether this operation has async server style
+ * @param isAsync - "true" marks this operation as async server style
+ */
+ public void setAsyncServer( boolean isAsync );
+
+ /**
+ * Indicates whether this operation is async server style
+ * @return - true if the operation is async server style
+ */
+ public boolean isAsyncServer();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java
new file mode 100644
index 0000000000..cb0d5f3b27
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.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.sca.interfacedef.java.impl;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+
+/**
+ * Represents a Java interface contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceContractImpl extends InterfaceContractImpl implements JavaInterfaceContract {
+
+ // A cached WSDL version of the Java contract use during normalized
+ // interface comparison
+ private InterfaceContract normailizedWSDLInterfaceContract;
+
+ protected JavaInterfaceContractImpl() {
+ }
+
+ @Override
+ public JavaInterfaceContractImpl clone() throws CloneNotSupportedException {
+ return (JavaInterfaceContractImpl) super.clone();
+ }
+
+ @Override
+ public InterfaceContract getNormalizedWSDLContract() {
+ return normailizedWSDLInterfaceContract;
+ }
+
+ @Override
+ public void setNormailizedWSDLContract(InterfaceContract wsdlInterfaceContract) {
+ normailizedWSDLInterfaceContract = wsdlInterfaceContract;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
new file mode 100644
index 0000000000..dbedf1d55a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.java.impl;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+
+/**
+ * A factory for the Java model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class JavaInterfaceFactoryImpl implements JavaInterfaceFactory {
+
+ private List<JavaInterfaceVisitor> visitors = new ArrayList<JavaInterfaceVisitor>();
+ private JavaInterfaceIntrospectorImpl introspector;
+ private Map<Class<?>, JavaInterface> cache = Collections.synchronizedMap(new WeakHashMap<Class<?>, JavaInterface>());
+
+ public JavaInterfaceFactoryImpl() {
+ introspector = new JavaInterfaceIntrospectorImpl(this);
+ }
+
+ public JavaInterface createJavaInterface() {
+ return new JavaInterfaceImpl();
+ }
+
+ public JavaInterface createJavaInterface(Class<?> interfaceClass) throws InvalidInterfaceException {
+ // TODO: Review if the sharing of JavaInterface is ok
+ synchronized (interfaceClass) {
+ JavaInterface javaInterface = cache.get(interfaceClass);
+ if (javaInterface == null) {
+ javaInterface = createJavaInterface();
+ introspector.introspectInterface(javaInterface, interfaceClass);
+ // Now that all introspection is complete we can mark the interface resolved
+ javaInterface.setUnresolved(false);
+ cache.put(interfaceClass, javaInterface);
+ }
+ return javaInterface;
+ }
+ }
+
+ public void createJavaInterface(JavaInterface javaInterface, Class<?> interfaceClass) throws InvalidInterfaceException {
+ introspector.introspectInterface(javaInterface, interfaceClass);
+ }
+
+ public JavaInterfaceContract createJavaInterfaceContract() {
+ return new JavaInterfaceContractImpl();
+ }
+
+ public void addInterfaceVisitor(JavaInterfaceVisitor extension) {
+ visitors.add(extension);
+ }
+
+ public void removeInterfaceVisitor(JavaInterfaceVisitor extension) {
+ visitors.remove(extension);
+ }
+
+ public List<JavaInterfaceVisitor> getInterfaceVisitors() {
+ return visitors;
+ }
+
+ public JavaOperation createJavaOperation(Method method) {
+ JavaOperation op = new JavaOperationImpl();
+ op.setJavaMethod(method);
+ op.setName(method.getName());
+ return op;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
new file mode 100644
index 0000000000..a217f3ea0c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
@@ -0,0 +1,360 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.impl;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.ArrayList;
+import java.util.List;
+import java.lang.reflect.ParameterizedType;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.Intent;
+
+import org.oasisopen.sca.ResponseDispatch;
+
+/**
+ * Represents a Java interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
+
+ private String className;
+ private WeakReference<Class<?>> javaClass;
+ private Class<?> callbackClass;
+ private QName qname;
+ private String jaxwsWSDLLocation;
+ private String jaxwsJavaInterfaceName;
+ private Contribution contributionContainingClass;
+
+ protected JavaInterfaceImpl() {
+ super();
+ // Mark the interface as unresolved until all the basic processing is complete
+ // including Intent & Policy introspection
+ this.setUnresolved(true);
+ }
+
+ public String getName() {
+ if (isUnresolved()) {
+ return className;
+ } else if (javaClass != null) {
+ return javaClass.get().getName();
+ } else {
+ return null;
+ }
+ }
+
+ public void setName(String className) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ }
+ this.className = className;
+ }
+
+ public QName getQName() {
+ return qname;
+ }
+
+ public void setQName(QName interfacename) {
+ qname = interfacename;
+ }
+
+ public Class<?> getJavaClass() {
+ if (javaClass != null){
+ return javaClass.get();
+ } else {
+ return null;
+ }
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ this.javaClass = new WeakReference<Class<?>>(javaClass);
+ if (javaClass != null) {
+ this.className = javaClass.getName();
+ }
+ }
+
+ public Class<?> getCallbackClass() {
+ return callbackClass;
+ }
+
+ public void setCallbackClass(Class<?> callbackClass) {
+ this.callbackClass = callbackClass;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((className == null) ? 0 : className.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ JavaInterfaceImpl other = (JavaInterfaceImpl)obj;
+ if (isUnresolved() || other.isUnresolved()) {
+ if (className == null) {
+ if (other.className != null)
+ return false;
+ } else if (!className.equals(other.className))
+ return false;
+ } else {
+ if (javaClass == null) {
+ if (other.javaClass != null)
+ return false;
+ } else if (!javaClass.get().equals(other.javaClass.get()))
+ return false;
+ if (callbackClass == null) {
+ if (other.callbackClass != null)
+ return false;
+ } else if (!callbackClass.equals(other.callbackClass))
+ return false;
+ }
+
+ return true;
+ }
+
+ public List<Operation> getOperations() {
+ if( !isUnresolved() && isAsyncServer() ) {
+ return equivalentSyncOperations();
+ } else {
+ return super.getOperations();
+ }
+ } // end method getOperations
+
+
+ private List<Operation> syncOperations = null;
+ private List<Operation> equivalentSyncOperations() {
+ if( syncOperations != null ) return syncOperations;
+ List<Operation> allOperations = super.getOperations();
+ syncOperations = new ArrayList<Operation>();
+ for( Operation operation: allOperations) {
+ syncOperations.add( getSyncFormOfOperation( (JavaOperation) operation ) );
+ // Store the actual async operations under the attribute "ASYNC-SERVER-OPERATIONS"
+ this.getAttributes().put("ASYNC-SERVER-OPERATIONS", allOperations);
+ } // end for
+
+ return syncOperations;
+ } // end method equivalentSyncOperations
+
+ private static final String UNKNOWN_DATABINDING = null;
+ /**
+ * Prepares the synchronous form of an asynchronous operation
+ * - async form: void someOperationAsync( FooType inputParam, DispatchResponse<BarType> )
+ * - sync form: BarType someOperation( FooType inputParam )
+ * @param operation - the operation to convert
+ * @return - the synchronous form of the operation - for an input operation that is not async server in form, this
+ * method simply returns the original operation unchanged
+ */
+ private Operation getSyncFormOfOperation( JavaOperation operation ) {
+ if( isAsyncServerOperation( operation ) ) {
+ JavaOperation syncOperation = new JavaOperationImpl();
+ String opName = operation.getName().substring(0, operation.getName().length() - 5 );
+
+ // Prepare the list of equivalent input parameters, which simply excludes the (final) DispatchResponse object
+ // and the equivalent return parameter, which is the (generic) type from the DispatchResponse object
+ DataType<List<DataType>> requestParams = operation.getInputType();
+
+ DataType<List<DataType>> inputType = prepareSyncInputParams( requestParams );
+ DataType<XMLType> returnDataType = prepareSyncReturnParam( requestParams );
+ List<DataType> faultDataTypes = prepareSyncFaults( operation );
+
+ syncOperation.setName(opName);
+ syncOperation.setAsyncServer(true);
+ syncOperation.setInputType(inputType);
+ syncOperation.setOutputType(returnDataType);
+ syncOperation.setFaultTypes(faultDataTypes);
+ syncOperation.setNonBlocking(operation.isNonBlocking());
+ syncOperation.setJavaMethod(operation.getJavaMethod());
+ syncOperation.setInterface(this);
+ return syncOperation;
+ } else {
+ // If it's not Async form, then it's a synchronous operation
+ return operation;
+ } // end if
+ } // end getSyncFormOfOperation
+
+ /**
+ * Produce the equivalent sync method input parameters from the input parameters of the async method
+ * @param requestParams - async method input parameters
+ * @return - the equivalent sync method input parameters
+ */
+ private DataType<List<DataType>> prepareSyncInputParams( DataType<List<DataType>> requestParams ) {
+ List<DataType> requestLogical = requestParams.getLogical();
+ int paramCount = requestLogical.size();
+
+ // Copy the list of async parameters, removing the final DispatchResponse
+ List<DataType> asyncParams = new ArrayList<DataType>( paramCount - 1);
+ for( int i = 0 ; i < (paramCount - 1) ; i++ ) {
+ asyncParams.add( requestLogical.get(i) );
+ } // end for
+
+ DataType<List<DataType>> inputType =
+ new DataTypeImpl<List<DataType>>(requestParams.getDataBinding(),
+ requestParams.getPhysical(), asyncParams);
+ return inputType;
+ } // end method prepareSyncInputParams
+
+ /**
+ * Prepare the return data type of the equivalent sync operation, based on the parameterization of the ResponseDispatch object
+ * of the async operation - the return data type is the Generic type of the final DispatchResponse<?>
+ * @param requestParams - - async method input parameters
+ * @return - the sync method return parameter
+ */
+ private DataType<XMLType> prepareSyncReturnParam( DataType<List<DataType>> requestParams ) {
+ List<DataType> requestLogical = requestParams.getLogical();
+ int paramCount = requestLogical.size();
+
+ DataType<?> finalParam = requestLogical.get( paramCount - 1 );
+ ParameterizedType t = (ParameterizedType)finalParam.getGenericType();
+ XMLType returnXMLType = (XMLType)finalParam.getLogical();
+
+ String namespace = null;
+ if( returnXMLType.isElement() ) {
+ namespace = returnXMLType.getElementName().getNamespaceURI();
+ } else {
+ namespace = returnXMLType.getTypeName().getNamespaceURI();
+ }
+
+ Type[] typeArgs = t.getActualTypeArguments();
+ if( typeArgs.length != 1 ) throw new IllegalArgumentException( "ResponseDispatch parameter is not parameterized correctly");
+
+ Class<?> returnType = (Class<?>)typeArgs[0];
+
+ // Set outputType to null for void
+ XMLType xmlReturnType = new XMLType(new QName(namespace, "return"), null);
+ DataType<XMLType> returnDataType =
+ returnType == void.class ? null : new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, returnType, xmlReturnType);
+
+ return returnDataType;
+ } // end method prepareSyncReturnParam
+
+ /**
+ * Prepare the set of equivalent sync faults for a given async operation
+ * @return - the list of faults
+ */
+ private List<DataType> prepareSyncFaults( JavaOperation operation ) {
+ //TODO - deal with Faults - for now just copy through whatever is associated with the async operation
+ return operation.getFaultTypes();
+ }
+
+ /**
+ * Determines if an interface operation has the form of an async server operation
+ * - async form: void someOperationAsync( FooType inputParam, ...., DispatchResponse<BarType> )
+ * @param operation - the operation to examine
+ * @return - true if the operation has the form of an async operation, false otherwise
+ */
+ private boolean isAsyncServerOperation( Operation operation ) {
+ // Async form operations have:
+ // 1) void return type
+ // 2) name ending in "Async"
+ // 3) final parameter which is of ResponseDispatch<?> type
+ DataType<?> response = operation.getOutputType();
+ if( response != null ) {
+ if ( response.getPhysical() != void.class ) return false;
+ } // end if
+
+ if ( !operation.getName().endsWith("Async") ) return false;
+
+ DataType<List<DataType>> requestParams = operation.getInputType();
+ int paramCount = requestParams.getLogical().size();
+ if( paramCount < 1 ) return false;
+ DataType<?> finalParam = requestParams.getLogical().get( paramCount - 1 );
+ if ( finalParam.getPhysical() != ResponseDispatch.class ) return false;
+
+ return true;
+ } // end method isAsyncServerOperation
+
+ static QName ASYNC_INVOCATION = new QName(Constants.SCA11_NS, "asyncInvocation");
+ /**
+ * Indicates if this interface is an Async Server interface
+ * @return true if the interface is Async Server, false otherwise
+ */
+ private boolean isAsyncServer() {
+
+ List<Intent> intents = getRequiredIntents();
+ for( Intent intent: intents ) {
+ if ( intent.getName().equals(ASYNC_INVOCATION) ) {
+ return true;
+ }
+ } // end for
+ return false;
+ } // end method isAsyncServer
+
+ public String getJAXWSWSDLLocation() {
+ return jaxwsWSDLLocation;
+ }
+
+ public void setJAXWSWSDLLocation(String wsdlLocation) {
+ this.jaxwsWSDLLocation = wsdlLocation;
+ }
+
+ public String getJAXWSJavaInterfaceName() {
+ return jaxwsJavaInterfaceName;
+ }
+
+ public void setJAXWSJavaInterfaceName(String javaInterfaceName) {
+ this.jaxwsJavaInterfaceName = javaInterfaceName;
+ }
+
+ /**
+ * A Java class may reference a WSDL file via a JAXWS annotation. We need to resolve
+ * the WSDL file location in the context of the same contribution that holds the
+ * Java file. In order to do this we need to remember the actual contribution that
+ * was used to resolve a Java class.
+ *
+ * @return
+ */
+ public Contribution getContributionContainingClass() {
+ return contributionContainingClass;
+ }
+
+ public void setContributionContainingClass(Contribution contributionContainingClass) {
+ this.contributionContainingClass = contributionContainingClass;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
new file mode 100644
index 0000000000..de32136abc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
@@ -0,0 +1,309 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Future;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidAnnotationException;
+import org.apache.tuscany.sca.interfacedef.InvalidCallbackException;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.InvalidOperationException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.OverloadedOperationException;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.oasisopen.sca.annotation.AsyncFault;
+import org.oasisopen.sca.annotation.OneWay;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Default implementation of a Java interface introspector.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceIntrospectorImpl {
+ public static final String IDL_INPUT = "idl:input";
+
+ private static final String UNKNOWN_DATABINDING = null;
+
+ private JavaInterfaceFactory javaFactory = null;
+ private List<JavaInterfaceVisitor> visitors = new ArrayList<JavaInterfaceVisitor>();
+ private boolean loadedVisitors;
+
+ public JavaInterfaceIntrospectorImpl(JavaInterfaceFactory javaFactory) {
+ this.javaFactory = javaFactory;
+ }
+
+ public void introspectInterface(JavaInterface javaInterface, Class<?> clazz) throws InvalidInterfaceException {
+
+ if(!loadedVisitors) {
+ this.visitors = javaFactory.getInterfaceVisitors();
+ }
+
+ javaInterface.setJavaClass(clazz);
+
+ boolean remotable = clazz.isAnnotationPresent(Remotable.class);
+
+ // Consider @javax.ejb.Remote, java.rmi.Remote and javax.ejb.EJBObject
+ // equivalent to @Remotable
+ if (!remotable) {
+ for (Annotation annotation : clazz.getAnnotations()) {
+ if ("javax.ejb.Remote".equals(annotation.annotationType().getName())) {
+ remotable = true;
+ break;
+ }
+ }
+ }
+ if (!remotable) {
+ for (Class<?> superInterface : clazz.getInterfaces()) {
+ if (Remote.class == superInterface || "javax.ejb.EJBObject".equals(superInterface.getName())) {
+ remotable = true;
+ break;
+ }
+ }
+ }
+
+ if (remotable) {
+ if (javaInterface.isRemotableSet() && javaInterface.isRemotable() == false) {
+ throw new InvalidAnnotationException("[JCA30005] @Remotable annotation present in a interface marked as not remotable in the SCDL", Remotable.class);
+ }
+ } else {
+ if (javaInterface.isRemotableSet()) {
+ remotable = javaInterface.isRemotable();
+ }
+ }
+
+ javaInterface.setRemotable(remotable);
+
+ Class<?> callbackClass = null;
+ org.oasisopen.sca.annotation.Callback callback = clazz.getAnnotation(org.oasisopen.sca.annotation.Callback.class);
+ if (callback != null && !Void.class.equals(callback.value())) {
+ callbackClass = callback.value();
+ if (remotable && !callbackClass.isAnnotationPresent(Remotable.class)) {
+ throw new InvalidCallbackException("Callback " + callbackClass.getName() +
+ " must be remotable on remotable interface " + clazz.getName());
+ }
+ if (!remotable && callbackClass.isAnnotationPresent(Remotable.class)) {
+ throw new InvalidCallbackException("Callback" + callbackClass.getName() +
+ " must not be remotable on local interface " + clazz.getName());
+ }
+ } else if (callback != null && Void.class.equals(callback.value())) {
+ throw new InvalidCallbackException("No callback interface specified on callback annotation in " + clazz.getName());
+ }
+
+ javaInterface.setCallbackClass(callbackClass);
+
+ String ns = JavaXMLMapper.getNamespace(clazz);
+ javaInterface.getOperations().addAll(getOperations(clazz, remotable, ns));
+
+ for (JavaInterfaceVisitor extension : visitors) {
+ extension.visitInterface(javaInterface);
+ }
+ }
+
+ private Class<?>[] getActualTypes(Type[] types, Class<?>[] rawTypes, Map<String, Type> typeBindings) {
+ Class<?>[] actualTypes = new Class<?>[types.length];
+ for (int i = 0; i < actualTypes.length; i++) {
+ actualTypes[i] = getActualType(types[i], rawTypes[i], typeBindings);
+ }
+ return actualTypes;
+ }
+
+ private Class<?> getActualType(Type type, Class<?> rawType, Map<String, Type> typeBindings) {
+ if (type instanceof TypeVariable<?>) {
+ TypeVariable<?> typeVariable = (TypeVariable<?>)type;
+ type = typeBindings.get(typeVariable.getName());
+ if (type instanceof Class<?>) {
+ return (Class<?>)type;
+ }
+ }
+ return rawType;
+ }
+
+ private <T> List<Operation> getOperations(Class<T> clazz,
+ boolean remotable,
+ String ns) throws InvalidInterfaceException {
+
+ Set<Type> genericInterfaces = new HashSet<Type>();
+ for (Type t : clazz.getGenericInterfaces()) {
+ genericInterfaces.add(t);
+ }
+ Map<String, Type> typeBindings = new HashMap<String, Type>();
+ for (Type genericInterface : genericInterfaces) {
+ if (genericInterface instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType)genericInterface;
+ TypeVariable<?>[] typeVariables = ((Class<?>)parameterizedType.getRawType()).getTypeParameters();
+ Type[] typeArguments = parameterizedType.getActualTypeArguments();
+ for (int i = 0; i < typeArguments.length; i++) {
+ typeBindings.put(typeVariables[i].getName(), typeArguments[i]);
+ }
+ }
+ }
+
+ Method[] methods = clazz.getMethods();
+ List<Operation> operations = new ArrayList<Operation>(methods.length);
+ Set<String> names = remotable ? new HashSet<String>() : null;
+ for (Method method : methods) {
+ if (method.getDeclaringClass() == Object.class) {
+ // Skip the methods on the Object.class
+ continue;
+ }
+ String name = method.getName();
+ if (remotable && names.contains(name)) {
+ throw new OverloadedOperationException(method);
+ }
+ if (remotable && !jaxwsAsyncMethod(method)) {
+ names.add(name);
+ }
+
+ Class<?> returnType = getActualType(method.getGenericReturnType(), method.getReturnType(), typeBindings);
+ Class<?>[] parameterTypes =
+ getActualTypes(method.getGenericParameterTypes(), method.getParameterTypes(), typeBindings);
+ Class<?>[] faultTypes =
+ getActualTypes(method.getGenericExceptionTypes(), method.getExceptionTypes(), typeBindings);
+
+ // For async server interfaces, faults are described using the @AsyncFaults annotation
+ if( method.isAnnotationPresent(AsyncFault.class) ) {
+ faultTypes = readAsyncFaultTypes( method );
+ } // end if
+
+ boolean nonBlocking = method.isAnnotationPresent(OneWay.class);
+ if (nonBlocking) {
+ if (!(returnType == void.class)) {
+ throw new InvalidOperationException(
+ "Method should return 'void' when declared with an @OneWay annotation. " + method,
+ method);
+ }
+ if (!(faultTypes.length == 0)) {
+ throw new InvalidOperationException(
+ "Method should not declare exceptions with an @OneWay annotation. " + method,
+ method);
+ }
+ }
+
+ // Set outputType to null for void
+ XMLType xmlReturnType = new XMLType(new QName(ns, "return"), null);
+ DataType<XMLType> returnDataType =
+ returnType == void.class ? null : new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, returnType, method
+ .getGenericReturnType(), xmlReturnType);
+ List<DataType> paramDataTypes = new ArrayList<DataType>(parameterTypes.length);
+ Type[] genericParamTypes = method.getGenericParameterTypes();
+ for (int i = 0; i < parameterTypes.length; i++) {
+ Class<?> paramType = parameterTypes[i];
+ XMLType xmlParamType = new XMLType(new QName(ns, "arg" + i), null);
+ paramDataTypes.add(new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, paramType, genericParamTypes[i],
+ xmlParamType));
+ }
+ List<DataType> faultDataTypes = new ArrayList<DataType>(faultTypes.length);
+ Type[] genericFaultTypes = method.getGenericExceptionTypes();
+ if( method.isAnnotationPresent(AsyncFault.class) ) {
+ genericFaultTypes = readAsyncGenericFaultTypes( method );
+ } // end if
+ for (int i = 0; i < faultTypes.length; i++) {
+ Class<?> faultType = faultTypes[i];
+ // Only add checked exceptions
+ // JAXWS Specification v2.1 section 3.7 says RemoteException should not be mapped
+ if (Exception.class.isAssignableFrom(faultType) && (!RuntimeException.class.isAssignableFrom(faultType))
+ && (!RemoteException.class.isAssignableFrom(faultType))) {
+ XMLType xmlFaultType = new XMLType(new QName(ns, faultType.getSimpleName()), null);
+ DataType<XMLType> faultDataType =
+ new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, faultType, genericFaultTypes[i], xmlFaultType);
+ faultDataTypes.add(new DataTypeImpl<DataType>(UNKNOWN_DATABINDING, faultType, genericFaultTypes[i],
+ faultDataType));
+ }
+ }
+
+ DataType<List<DataType>> inputType =
+ new DataTypeImpl<List<DataType>>(IDL_INPUT, Object[].class, paramDataTypes);
+ JavaOperation operation = new JavaOperationImpl();
+ operation.setName(name);
+ operation.setInputType(inputType);
+ operation.setOutputType(returnDataType);
+ operation.setFaultTypes(faultDataTypes);
+ operation.setNonBlocking(nonBlocking);
+ operation.setJavaMethod(method);
+ operations.add(operation);
+ }
+ return operations;
+ }
+
+ /**
+ * Reads the fault types declared in an @AsyncFault annotation on an async server method
+ * @param method - the Method
+ * @return - an array of fault/exception classes
+ */
+ private Class<?>[] readAsyncFaultTypes( Method method ) {
+ AsyncFault theFaults = method.getAnnotation(AsyncFault.class);
+ if ( theFaults == null ) return null;
+ return theFaults.value();
+ } // end method readAsyncFaultTypes
+
+ /**
+ * Reads the generic fault types declared in an @AsyncFault annotation on an async server method
+ * @param method - the Method
+ * @return - an array of fault/exception classes
+ */
+ private Type[] readAsyncGenericFaultTypes( Method method ) {
+ AsyncFault theFaults = method.getAnnotation(AsyncFault.class);
+ if ( theFaults == null ) return null;
+ return theFaults.value();
+ } // end method readAsyncFaultTypes
+
+ private boolean jaxwsAsyncMethod(Method method) {
+ if (method.getName().endsWith("Async")) {
+ if (method.getName().endsWith("Async")) {
+ if (method.getReturnType().isAssignableFrom(Future.class)) {
+ if (method.getParameterTypes().length > 0) {
+ if (method.getParameterTypes()[method.getParameterTypes().length-1].isAssignableFrom(AsyncHandler.class)) {
+ return true;
+ }
+ }
+ }
+ if (method.getReturnType().isAssignableFrom(Response.class)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
new file mode 100644
index 0000000000..352cffeef2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.impl;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+
+/**
+ * Contains methods for mapping between an operation in a
+ * {@link org.apache.tuscany.spi.model.ServiceContract} and a method defined by
+ * a Java interface
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public final class JavaInterfaceUtil {
+
+ private JavaInterfaceUtil() {
+ }
+
+ /**
+ * Return the method on the implementation class that matches the operation.
+ *
+ * @param implClass the implementation class or interface
+ * @param operation the operation to match
+ * @return the method described by the operation
+ * @throws NoSuchMethodException if no such method exists
+ * @Deprecated
+ */
+ public static Method findMethod(Class<?> implClass, Operation operation) throws NoSuchMethodException {
+ String name = operation.getName();
+ if (operation instanceof JavaOperation) {
+ if( ((JavaOperation)operation).isAsyncServer() ) {
+ // In this case, the operation is a mapped async server style method and needs special handling
+ return findAsyncServerMethod( implClass, (JavaOperation)operation );
+ } else {
+ name = ((JavaOperation)operation).getJavaMethod().getName();
+ } // end if
+ }
+ Interface interface1 = operation.getInterface();
+ int numParams = operation.getInputType().getLogical().size();
+ if (interface1 != null && interface1.isRemotable()) {
+ List<Method> matchingMethods = new ArrayList<Method>();
+ for (Method m : implClass.getMethods()) {
+ if (m.getName().equals(name) && m.getParameterTypes().length == numParams) {
+ matchingMethods.add(m);
+ }
+ }
+
+ // TUSCANY-2180 If there is only one method then we just match on the name
+ // (this is the same as the existing behaviour)
+ if (matchingMethods.size() == 1) {
+ return matchingMethods.get(0);
+ }
+ if (matchingMethods.size() > 1) {
+ // TUSCANY-2180 We need to check the parameter types too
+ Class<?>[] paramTypes = getPhysicalTypes(operation);
+ return implClass.getMethod(name, paramTypes);
+ }
+
+ // No matching method found
+ throw new NoSuchMethodException("No matching method for operation " + operation.getName()
+ + " is found on "
+ + implClass);
+ }
+ Class<?>[] paramTypes = getPhysicalTypes(operation);
+ return implClass.getMethod(name, paramTypes);
+ }
+
+ /**
+ * Return the method on the implementation class that matches the async server version of the operation.
+ *
+ * @param implClass the implementation class or interface
+ * @param operation the operation to match - this is the sync equivalent of an async server operation
+ * @return the method described by the operation
+ * @throws NoSuchMethodException if no such method exists
+ */
+ public static Method findAsyncServerMethod(Class<?> implClass, JavaOperation operation) throws NoSuchMethodException {
+ String name = operation.getJavaMethod().getName();
+ List<Operation> actualOps = (List<Operation>) operation.getInterface().getAttributes().get("ASYNC-SERVER-OPERATIONS");
+ Operation matchingOp = null;
+ for( Operation op: actualOps ) {
+ if( op.getName().equals(name) ) {
+ matchingOp = op;
+ break;
+ }
+ } // end for
+ if( matchingOp == null ) throw new NoSuchMethodException("No matching async method for operation " + operation.getName());
+
+ int numParams = matchingOp.getInputType().getLogical().size();
+
+ List<Method> matchingMethods = new ArrayList<Method>();
+ for (Method m : implClass.getMethods()) {
+ if (m.getName().equals(name) && m.getParameterTypes().length == (numParams) ) {
+ matchingMethods.add(m);
+ }
+ }
+
+ if (matchingMethods.size() == 1) {
+ return matchingMethods.get(0);
+ }
+ if (matchingMethods.size() > 1) {
+ Class<?>[] paramTypes = getPhysicalTypes(matchingOp);
+ return implClass.getMethod(name, paramTypes);
+ }
+
+ // No matching method found
+ throw new NoSuchMethodException("No matching method for operation " + operation.getName()
+ + " is found on " + implClass);
+
+ } // end method findAsyncServerMethod
+
+ /**
+ * @Deprecated
+ */
+ private static Class<?>[] getPhysicalTypes(Operation operation) {
+ DataType<List<DataType>> inputType = operation.getInputType();
+ if (inputType == null) {
+ return new Class<?>[] {};
+ }
+ List<DataType> types = inputType.getLogical();
+ Class<?>[] javaTypes = new Class<?>[types.size()];
+ for (int i = 0; i < javaTypes.length; i++) {
+ Type physical = types.get(i).getPhysical();
+ if (physical instanceof Class<?>) {
+ javaTypes[i] = (Class<?>)physical;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ return javaTypes;
+ }
+
+ /**
+ * Searches a collection of operations for a match against the given method
+ *
+ * @param method the method to match
+ * @param operations the operations to match against
+ * @return a matching operation or null
+ * @Deprecated
+ */
+ public static Operation findOperation(Method method, Collection<Operation> operations) {
+ for (Operation operation : operations) {
+ if (match(operation, method)) {
+ return operation;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Determines if the given operation matches the given method
+ *
+ * @return true if the operation matches, false if does not
+ */
+ private static boolean match(Operation operation, Method method) {
+ Class<?>[] params = method.getParameterTypes();
+ DataType<List<DataType>> inputType = operation.getInputType();
+ List<DataType> types = inputType.getLogical();
+ boolean found = true;
+ if (types.size() == params.length && method.getName().equals(operation.getName())) {
+ for (int i = 0; i < params.length; i++) {
+ Class<?> clazz = params[i];
+ if (!clazz.equals(operation.getInputType().getLogical().get(i).getPhysical())) {
+ found = false;
+ }
+ }
+ } else {
+ found = false;
+ }
+ return found;
+
+ }
+
+ private static String getPackageName(Class<?> cls) {
+ String name = cls.getName();
+ int index = name.lastIndexOf('.');
+ return index == -1 ? "" : name.substring(0, index);
+ }
+
+ public static String getNamespace(Class<?> cls) {
+ String packageName = getPackageName(cls);
+ if ("".equals(packageName)) {
+ return "";
+ }
+ StringBuffer ns = new StringBuffer("http://");
+ String[] names = packageName.split("\\.");
+ for (int i = names.length - 1; i >= 0; i--) {
+ ns.append(names[i]);
+ if (i != 0) {
+ ns.append('.');
+ }
+ }
+ ns.append('/');
+ return ns.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.java
new file mode 100644
index 0000000000..7169cc164d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+
+/**
+ * Represents a Java operation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaOperationImpl extends OperationImpl implements JavaOperation {
+
+ private Method method;
+ private String action;
+ private boolean isAsyncServer = false;
+
+ public Method getJavaMethod() {
+ return method;
+ }
+
+ public void setJavaMethod(Method method) {
+ this.method = method;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((method == null) ? 0 : method.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final JavaOperationImpl other = (JavaOperationImpl)obj;
+ if (method == null) {
+ if (other.method != null)
+ return false;
+ } else if (!method.equals(other.method))
+ return false;
+ return true;
+ }
+
+ /**
+ * Sets whether this operation has async server style
+ * @param isAsync - "true" marks this operation as async server style
+ */
+ public void setAsyncServer( boolean isAsync ) {
+ isAsyncServer = isAsync;
+ }
+
+ /**
+ * Indicates whether this operation is async server style
+ * @return - true if the operation is async server style
+ */
+ public boolean isAsyncServer() {
+ return isAsyncServer;
+ }
+
+ @Override
+ public String toString() {
+ return method == null ? "null" : method.toGenericString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java
new file mode 100644
index 0000000000..1c0333f833
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java
@@ -0,0 +1,278 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.oasisopen.sca.annotation.PolicySets;
+import org.oasisopen.sca.annotation.Qualifier;
+import org.oasisopen.sca.annotation.Requires;
+
+/**
+ * Processes an {@link org.oasisopen.sca.annotation.Requires} annotation
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyJavaInterfaceVisitor implements JavaInterfaceVisitor {
+ private PolicyFactory policyFactory;
+
+ public PolicyJavaInterfaceVisitor(ExtensionPointRegistry registry) {
+ super();
+ this.policyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(PolicyFactory.class);
+ }
+
+ private QName getQName(String intentName) {
+ QName qname;
+ if (intentName.startsWith("{")) {
+ int i = intentName.indexOf('}');
+ if (i != -1) {
+ qname = new QName(intentName.substring(1, i), intentName.substring(i + 1));
+ } else {
+ qname = new QName("", intentName);
+ }
+ } else {
+ qname = new QName("", intentName);
+ }
+ return qname;
+ }
+
+ /**
+ * Read policy intents on the given interface or class
+ * @param clazz
+ * @param requiredIntents
+ */
+ private void readIntentsAndPolicySets(Class<?> clazz, PolicySubject subject) {
+ Requires intentAnnotation = clazz.getAnnotation(Requires.class);
+ if (intentAnnotation != null) {
+ String[] intentNames = intentAnnotation.value();
+ if (intentNames.length != 0) {
+ for (String intentName : intentNames) {
+
+ // Add each intent to the list
+ Intent intent = policyFactory.createIntent();
+ intent.setName(getQName(intentName));
+ subject.getRequiredIntents().add(intent);
+ }
+ }
+ }
+
+ readSpecificIntents(clazz.getAnnotations(), subject.getRequiredIntents());
+
+ PolicySets policySetAnnotation = clazz.getAnnotation(PolicySets.class);
+ if (policySetAnnotation != null) {
+ String[] policySetNames = policySetAnnotation.value();
+ if (policySetNames.length != 0) {
+ for (String policySetName : policySetNames) {
+
+ // Add each intent to the list
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(getQName(policySetName));
+ subject.getPolicySets().add(policySet);
+ }
+ }
+ }
+
+ if ( clazz.isAnnotationPresent(SOAPBinding.class) ) {
+ // add soap intent
+ Intent intent = policyFactory.createIntent();
+ intent.setName(Constants.SOAP_INTENT);
+ subject.getRequiredIntents().add(intent);
+ }
+
+
+ }
+
+ private void readIntents(Requires intentAnnotation, List<Intent> requiredIntents) {
+ //Requires intentAnnotation = method.getAnnotation(Requires.class);
+ if (intentAnnotation != null) {
+ String[] intentNames = intentAnnotation.value();
+ if (intentNames.length != 0) {
+ //Operation operation = assemblyFactory.createOperation();
+ //operation.setName(method.getName());
+ //operation.setUnresolved(true);
+ for (String intentName : intentNames) {
+
+ // Add each intent to the list, associated with the
+ // operation corresponding to the annotated method
+ Intent intent = policyFactory.createIntent();
+ intent.setName(getQName(intentName));
+ //intent.getOperations().add(operation);
+ requiredIntents.add(intent);
+ }
+ }
+ }
+ }
+
+ private void readPolicySets(PolicySets policySetAnnotation, List<PolicySet> policySets) {
+ if (policySetAnnotation != null) {
+ String[] policySetNames = policySetAnnotation.value();
+ if (policySetNames.length != 0) {
+ //Operation operation = assemblyFactory.createOperation();
+ //operation.setName(method.getName());
+ //operation.setUnresolved(true);
+ for (String policySetName : policySetNames) {
+ // Add each intent to the list, associated with the
+ // operation corresponding to the annotated method
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(getQName(policySetName));
+ //intent.getOperations().add(operation);
+ policySets.add(policySet);
+ }
+ }
+ }
+ }
+
+ public void readWebServicesAnnotations(Method m, Class<?> clazz, List<Intent> requiredIntents) {
+
+ WebResult webResultAnnotation = m.getAnnotation(WebResult.class);
+ if (webResultAnnotation != null) {
+ if (webResultAnnotation.header()) {
+ // Add SOAP intent
+ Intent intent = policyFactory.createIntent();
+ intent.setName(Constants.SOAP_INTENT);
+ requiredIntents.add(intent);
+ return;
+ }
+ }
+
+ Annotation[][] parameterAnnotations = m.getParameterAnnotations();
+ for ( int i=0; i < parameterAnnotations.length; i++ ) {
+ for ( int j=0; j < parameterAnnotations[i].length; j++) {
+ if ( parameterAnnotations[i][j] instanceof WebParam ) {
+ WebParam webParam = (WebParam)parameterAnnotations[i][j];
+ if ( webParam.header() ) {
+ // Add SOAP intent
+ Intent intent = policyFactory.createIntent();
+ intent.setName(Constants.SOAP_INTENT);
+ requiredIntents.add(intent);
+ return;
+ }
+ }
+ }
+ }
+
+ }
+ public void visitInterface(JavaInterface javaInterface) throws InvalidInterfaceException {
+
+ if (javaInterface.getJavaClass() != null) {
+ readIntentsAndPolicySets(javaInterface.getJavaClass(), javaInterface);
+
+ // Read intents on the service interface methods
+ List<Operation> operations = javaInterface.getOperations();
+ for (Operation op : operations) {
+ JavaOperation operation = (JavaOperation)op;
+ Method method = operation.getJavaMethod();
+
+ readIntents(method.getAnnotation(Requires.class), op.getRequiredIntents());
+ readSpecificIntents(method.getAnnotations(), op.getRequiredIntents());
+ readPolicySets(method.getAnnotation(PolicySets.class), op.getPolicySets());
+ readWebServicesAnnotations(method, javaInterface.getJavaClass(), javaInterface.getRequiredIntents());
+ inherit(javaInterface, op);
+ }
+ }
+
+
+
+
+ }
+
+ private void inherit(JavaInterface javaInterface, Operation op) {
+ List<Intent> interfaceIntents = new ArrayList<Intent>(javaInterface.getRequiredIntents());
+ for ( Intent intent : javaInterface.getRequiredIntents() ) {
+
+ for ( Intent operationIntent : op.getRequiredIntents() ) {
+ if ( intent.getExcludedIntents().contains(operationIntent) ||
+ operationIntent.getExcludedIntents().contains(intent) ) {
+ interfaceIntents.remove(intent);
+ continue;
+ }
+ }
+ }
+ op.getRequiredIntents().addAll(interfaceIntents);
+
+ op.getPolicySets().addAll(javaInterface.getPolicySets());
+ }
+
+ private void readSpecificIntents(Annotation[] annotations, List<Intent> requiredIntents) {
+ for (Annotation a : annotations) {
+ org.oasisopen.sca.annotation.Intent intentAnnotation =
+ a.annotationType().getAnnotation(org.oasisopen.sca.annotation.Intent.class);
+ if (intentAnnotation == null) {
+ continue;
+ }
+ QName qname = null;
+ String value = intentAnnotation.value();
+ if (!value.equals("")) {
+ qname = getQName(value);
+ } else {
+ qname = new QName(intentAnnotation.targetNamespace(), intentAnnotation.localPart());
+ }
+ Set<String> qualifiers = new HashSet<String>();
+ for(Method m: a.annotationType().getMethods()) {
+ Qualifier qualifier = m.getAnnotation(Qualifier.class);
+ if (qualifier != null && m.getReturnType() == String[].class) {
+ try {
+ qualifiers.addAll(Arrays.asList((String[]) m.invoke(a)));
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ qualifiers.remove("");
+ if (qualifiers.isEmpty()) {
+ Intent intent = policyFactory.createIntent();
+ intent.setUnresolved(true);
+ intent.setName(qname);
+ requiredIntents.add(intent);
+ } else {
+ for (String q : qualifiers) {
+ Intent intent = policyFactory.createIntent();
+ intent.setUnresolved(true);
+ qname = new QName(qname.getNamespaceURI(), qname.getLocalPart() + "." + q);
+ intent.setName(qname);
+ requiredIntents.add(intent);
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/introspect/JavaInterfaceVisitor.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/introspect/JavaInterfaceVisitor.java
new file mode 100644
index 0000000000..3bc03a528e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/introspect/JavaInterfaceVisitor.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.sca.interfacedef.java.introspect;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+
+/**
+ * Implementations introspect metadata on a Java interface, populating the
+ * corresponding {@link JavaInterface}
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaInterfaceVisitor {
+
+ /**
+ * Visit a java interface
+ * @param javaInterface
+ * @throws InvalidInterfaceException
+ */
+ void visitInterface(JavaInterface javaInterface) throws InvalidInterfaceException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/package.html b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/package.html
new file mode 100644
index 0000000000..828c112479
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/package.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+The Tuscany Java Interface Extension
+
+@tuscany.spi.extension
+
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java
new file mode 100644
index 0000000000..2db916e2d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.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 org.apache.tuscany.sca.interfacedef.java.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Interface Java XML Constants.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaConstants {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String INTERFACE_JAVA = "interface.java";
+ QName INTERFACE_JAVA_QNAME = new QName(SCA11_NS, "interface.java");
+ String INTERFACE = "interface";
+ String CALLBACK_INTERFACE = "callbackInterface";
+ String REMOTABLE = "remotable";
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
new file mode 100644
index 0000000000..9e013746ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
@@ -0,0 +1,445 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.ws.WebServiceClient;
+
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.ComponentName;
+import org.oasisopen.sca.annotation.Constructor;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Destroy;
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Intent;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Qualifier;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfaceContract>, JavaConstants {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ private JavaInterfaceFactory javaFactory;
+ private ExtensionPointRegistry extensionPoints;
+ private PolicyFactory policyFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private WSDLFactory wsdlFactory;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private transient InterfaceContractMapper interfaceContractMapper;
+
+ public JavaInterfaceProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<?> staxProcessor) {
+ this.extensionPoints = extensionPoints;
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "interface-javaxml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "interface-javaxml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ private JavaInterface createJavaInterface(String interfaceName) {
+ JavaInterface javaInterface = javaFactory.createJavaInterface();
+ javaInterface.setUnresolved(true);
+ javaInterface.setName(interfaceName);
+ return javaInterface;
+ }
+
+ public JavaInterfaceContract read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ // Read an <interface.java>
+ JavaInterfaceContract javaInterfaceContract = javaFactory.createJavaInterfaceContract();
+ String interfaceName = reader.getAttributeValue(null, INTERFACE);
+ if (interfaceName != null) {
+ JavaInterface javaInterface = createJavaInterface(interfaceName);
+ javaInterfaceContract.setInterface(javaInterface);
+ }
+
+ String callbackInterfaceName = reader.getAttributeValue(null, CALLBACK_INTERFACE);
+ if (callbackInterfaceName != null) {
+ JavaInterface javaCallbackInterface = createJavaInterface(callbackInterfaceName);
+ javaInterfaceContract.setCallbackInterface(javaCallbackInterface);
+ }
+
+ String remotable = reader.getAttributeValue(null, REMOTABLE);
+ if (remotable != null) {
+ javaInterfaceContract.getInterface().setRemotable(Boolean.parseBoolean(remotable));
+ }
+
+ // Read intents and policy sets
+ policyProcessor.readPolicies(javaInterfaceContract.getInterface(), reader);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && INTERFACE_JAVA_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+ return javaInterfaceContract;
+ }
+
+ public void write(JavaInterfaceContract javaInterfaceContract, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write an <interface.java>
+ writer.writeStartElement(SCA11_NS, INTERFACE_JAVA);
+ JavaInterface javaInterface = (JavaInterface)javaInterfaceContract.getInterface();
+
+ if (javaInterface != null && javaInterface.getName() != null) {
+ writer.writeAttribute(INTERFACE, javaInterface.getName());
+ }
+
+ if(javaInterface != null && javaInterface.isRemotableSet()) {
+ writer.writeAttribute(REMOTABLE, String.valueOf(javaInterface.isRemotable()));
+ }
+
+ JavaInterface javaCallbackInterface = (JavaInterface)javaInterfaceContract.getCallbackInterface();
+ if (javaCallbackInterface != null && javaCallbackInterface.getName() != null) {
+ writer.writeAttribute(CALLBACK_INTERFACE, javaCallbackInterface.getName());
+ }
+
+ policyProcessor.writePolicyAttributes(javaInterface, writer);
+
+ writer.writeEndElement();
+ }
+
+ private JavaInterface resolveJavaInterface(JavaInterface javaInterface, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (javaInterface != null && javaInterface.isUnresolved()) {
+ Monitor monitor = context.getMonitor();
+ // Resolve the Java interface
+ javaInterface = resolver.resolveModel(JavaInterface.class, javaInterface, context);
+ if (javaInterface.isUnresolved()) {
+
+ // If the Java interface has never been resolved yet, do it now
+ ClassReference classReference = new ClassReference(javaInterface.getName());
+ classReference = resolver.resolveModel(ClassReference.class, classReference, context);
+ Class<?> javaClass = classReference.getJavaClass();
+ if (javaClass == null) {
+ error(monitor, "ClassNotFoundException", resolver, javaInterface.getName());
+ return javaInterface;
+ //throw new ContributionResolveException(new ClassNotFoundException(javaInterface.getName()));
+ }
+
+ try {
+ // Introspect the Java interface and populate the interface and
+ // operations
+ javaFactory.createJavaInterface(javaInterface, javaClass);
+
+ // cache the contribution that was used to resolve the Java interface
+ // in case we need it to reolve a referenced WSDL file
+ javaInterface.setContributionContainingClass(classReference.getContributionContainingClass());
+
+ } catch (InvalidInterfaceException e) {
+ ContributionResolveException ce = new ContributionResolveException("Resolving Java interface " + javaInterface.getName(), e);
+ //error("ContributionResolveException", javaFactory, ce);
+ error(monitor, "InvalidInterfaceException", javaFactory, e);
+ return javaInterface;
+ //throw ce;
+ } catch ( Exception e ) {
+ throw new ContributionResolveException( "Resolving Java interface " + javaInterface.getName(), e );
+ } // end try
+
+ // Cache the resolved interface
+ javaInterface.setUnresolved(false);
+ resolver.addModel(javaInterface, context);
+ }
+ }
+ return javaInterface;
+ }
+
+ public void resolve(JavaInterfaceContract javaInterfaceContract, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ try {
+ Monitor monitor = context.getMonitor();
+ // Resolve the interface and callback interface
+ JavaInterface javaInterface =
+ resolveJavaInterface((JavaInterface)javaInterfaceContract.getInterface(), resolver, context);
+ javaInterfaceContract.setInterface(javaInterface);
+
+ JavaInterface javaCallbackInterface =
+ resolveJavaInterface((JavaInterface)javaInterfaceContract.getCallbackInterface(), resolver, context);
+ javaInterfaceContract.setCallbackInterface(javaCallbackInterface);
+
+ postJAXWSProcessorResolve(javaInterfaceContract, resolver, context);
+
+ checkForbiddenAnnotations(monitor, javaInterfaceContract);
+
+ } catch (Exception e) {
+ throw new ContributionResolveException("Resolving Java Interface " + javaInterfaceContract.getInterface()
+ .toString(), e);
+ } // end try
+ }
+
+ private static List<Class<?>> JCA30006_ANNOTATIONS =
+ Arrays.asList(new Class<?>[] {AllowsPassByReference.class, ComponentName.class, Constructor.class, Context.class,
+ Destroy.class, EagerInit.class, Init.class, Intent.class, Property.class, Qualifier.class,
+ Reference.class, Scope.class, Service.class});
+ private static List<Class<?>> JCA30007_ANNOTATIONS =
+ Arrays.asList(new Class<?>[] {AllowsPassByReference.class, Callback.class, ComponentName.class, Constructor.class,
+ Context.class, Destroy.class, EagerInit.class, Init.class, Intent.class,
+ Property.class, Qualifier.class, Reference.class, Scope.class, Service.class});
+ private static List<Class<?>> JCA30008_ANNOTATIONS = Arrays.asList(new Class<?>[] {Intent.class, Qualifier.class});
+
+ private void checkForbiddenAnnotations(Monitor monitor, JavaInterfaceContract javaInterfaceContract) {
+ if (javaInterfaceContract.getInterface() == null) {
+ return;
+ }
+ Class<?> ifc = ((JavaInterface) javaInterfaceContract.getInterface()).getJavaClass();
+ if (ifc == null) {
+ return;
+ }
+ for (Annotation a : ifc.getAnnotations()) {
+ if (ifc.isInterface()) {
+ if (JCA30006_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30006", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ } else {
+ if (JCA30008_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30008", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ }
+
+ if ( a.annotationType().equals(WebServiceClient.class) ) {
+ error(monitor, "ForbiddenAnnotationJCA100018", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+
+ }
+ for (Method m : ifc.getMethods()) {
+ for (Annotation a : m.getAnnotations()) {
+ if (ifc.isInterface()) {
+ if (JCA30006_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30006", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ } else {
+ if (JCA30008_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30008", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ }
+ }
+ }
+ for (Field f : ifc.getFields()) {
+ for (Annotation a : f.getAnnotations()) {
+ if (ifc.isInterface()) {
+ if (JCA30006_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30006", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ } else {
+ if (JCA30008_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30008", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ }
+ }
+ }
+
+ if (javaInterfaceContract.getCallbackInterface() == null) {
+ return;
+ }
+ ifc = ((JavaInterface) javaInterfaceContract.getCallbackInterface()).getJavaClass();
+ if (ifc == null) {
+ return;
+ }
+
+ for (Annotation a : ifc.getAnnotations()) {
+ if (ifc.isInterface()) {
+ if (JCA30007_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30007", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ } else {
+ if (JCA30008_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30008", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ }
+ }
+ for (Method m : ifc.getMethods()) {
+ for (Annotation a : m.getAnnotations()) {
+ if (ifc.isInterface()) {
+ if (JCA30007_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30007", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ } else {
+ if (JCA30008_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30008", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ }
+ }
+ }
+ for (Field f : ifc.getFields()) {
+ for (Annotation a : f.getAnnotations()) {
+ if (ifc.isInterface()) {
+ if (JCA30007_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30007", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ } else {
+ if (JCA30008_ANNOTATIONS.contains(a.annotationType())) {
+ error(monitor, "ForbiddenAnnotationJCA30008", javaInterfaceContract, a.annotationType(), ifc.getName());
+ }
+ }
+ }
+ }
+ }
+
+ public QName getArtifactType() {
+ return INTERFACE_JAVA_QNAME;
+ }
+
+ public Class<JavaInterfaceContract> getModelType() {
+ return JavaInterfaceContract.class;
+ }
+
+ private void postJAXWSProcessorResolve(JavaInterfaceContract javaInterfaceContract, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException, IncompatibleInterfaceContractException {
+
+ JavaInterface javaInterface = (JavaInterface)javaInterfaceContract.getInterface();
+
+ // the Java interface may now be marked as unresolved due to a new Java interface
+ // name retrieved from JAXWS annotations. Resolve it again if it is.
+ if (javaInterface != null && javaInterface.isUnresolved()){
+ javaInterface = resolveJavaInterface(javaInterface, resolver, context);
+ javaInterfaceContract.setInterface(javaInterface);
+ }
+
+ JavaInterface javaCallbackInterface = (JavaInterface)javaInterfaceContract.getCallbackInterface();
+ // the Java callback interface may now be marked as unresolved due to a new Java interface
+ // name retrieved from JAXWS annotations. Resolve it again if it is.
+ if (javaCallbackInterface != null && javaCallbackInterface.isUnresolved()){
+ javaCallbackInterface = resolveJavaInterface(javaCallbackInterface, resolver, context);
+ javaInterfaceContract.setCallbackInterface(javaCallbackInterface);
+ }
+
+ // the Java interface may be replaced by a WSDL contract picked up from JAXWS annotation
+ // if so we need to fluff up a WSDL contract and set it to be the normalized contract
+ // for the Java interface so it's used during contract mapping
+ if (javaInterface != null && javaInterface.getJAXWSWSDLLocation() != null){
+ WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface();
+ wsdlInterface.setUnresolved(true);
+ wsdlInterface.setRemotable(true);
+
+ WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ wsdlInterfaceContract.setInterface(wsdlInterface);
+ wsdlInterfaceContract.setLocation(javaInterface.getJAXWSWSDLLocation());
+ javaInterfaceContract.setNormailizedWSDLContract(wsdlInterfaceContract);
+
+ ProcessorContext wsdlContext = new ProcessorContext(javaInterface.getContributionContainingClass(),
+ context.getMonitor());
+ extensionProcessor.resolve(wsdlInterfaceContract, resolver, wsdlContext);
+
+ // check that the Java and WSDL contracts are compatible
+ interfaceContractMapper.checkCompatibility(wsdlInterfaceContract,
+ javaInterfaceContract,
+ Compatibility.SUBSET,
+ false,
+ false);
+
+ // copy policy from the WSDL interface to the Java interface
+ javaInterface.getPolicySets().addAll(wsdlInterface.getPolicySets());
+ javaInterface.getRequiredIntents().addAll(wsdlInterface.getRequiredIntents());
+
+ // TODO - is there anything else to be copied from the user specified WSDL?
+
+ }
+
+ // TODO - how to handle callbacks as the location is stored at the contract level?
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..2cbda24dd8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.interfacedef.java.xml.JavaInterfaceProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#interface.java,model=org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory b/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory
new file mode 100644
index 0000000000..82972f856a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory
@@ -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.java.DefaultJavaInterfaceFactory
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
new file mode 100644
index 0000000000..ef73adb3e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
@@ -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.java.impl.PolicyJavaInterfaceVisitor;ranking=1000
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
new file mode 100644
index 0000000000..329f55e0a7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
@@ -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.
+#
+#
+ClassNotFoundException = Class Not Found Exception: {0}
+ContributionResolveException = ContributionResolveException occurred due to: {0}
+InvalidInterfaceException = InvalidInterfaceException due to: {0}
+ForbiddenAnnotationJCA30006 = [JCA30006] Forbidden annotation {0} found on service interface in class {1}
+ForbiddenAnnotationJCA30007 = [JCA30007] Forbidden annotation {0} found on callback interface in class {1}
+ForbiddenAnnotationJCA30008 = [JCA30008] Forbidden annotation {0} found in class {1}
+ForbiddenAnnotationJCA100018 = [JCA100018] Forbidden annotation {0} found in class {1}
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilDuplicateRemotableTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilDuplicateRemotableTestCase.java
new file mode 100644
index 0000000000..c70bdcaf47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilDuplicateRemotableTestCase.java
@@ -0,0 +1,317 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.OverloadedOperationException;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.junit.Assert;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This test case will test that a Component that has multiple Remotable interfaces
+ * that contain methods with the same name will correctly select the right method.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceUtilDuplicateRemotableTestCase {
+
+ /**
+ * Test to get the getTime() method from the LocalTimeService
+ *
+ * @throws Exception Test failed
+ */
+ @Test
+ public void testLocalTimeServiceGetTime() throws Exception {
+ doTestLocalTimeServiceGetTime(LocalTimeService.class);
+ }
+
+ /**
+ * Test to get the getTime() method from the LocalTimeService interface from
+ * the specified class
+ *
+ * @param timeServiceClass The class that implements the LocalTimeService
+ * @throws Exception Test failed
+ */
+ private void doTestLocalTimeServiceGetTime(Class<?> timeServiceClass) throws Exception {
+ // Add a getTime() method
+ Operation operation = newOperation("getTime", LocalTimeService.class);
+
+ Method method = JavaInterfaceUtil.findMethod(timeServiceClass, operation);
+ assertEquals("getTime", method.getName());
+ assertEquals(0, method.getParameterTypes().length);
+ }
+
+ /**
+ * Test to get the getTime(String) method from the WorldTimeService
+ *
+ * @throws Exception Test failed
+ */
+ @Test
+ public void testWorldTimeServiceGetTime() throws Exception {
+ doTestWorldTimeServiceGetTime(WorldTimeService.class);
+ }
+
+ /**
+ * Test to get the getTime(String) method from the WorldTimeService interface from
+ * the specified class
+ *
+ * @param timeServiceClass The class that implements the WorldTimeService
+ * @throws Exception Test failed
+ */
+ private void doTestWorldTimeServiceGetTime(Class<?> timeServiceClass) throws Exception {
+ // Add a getTime(String) method
+ Operation operation = newOperation("getTime", WorldTimeService.class, String.class);
+
+ Method method = JavaInterfaceUtil.findMethod(timeServiceClass, operation);
+ assertEquals("getTime", method.getName());
+ assertEquals(1, method.getParameterTypes().length);
+ assertEquals(String.class, method.getParameterTypes()[0]);
+ }
+
+ /**
+ * Test to get the getTime(int) method from the GMTTimeService
+ *
+ * @throws Exception Test failed
+ */
+ @Test
+ public void testGMTTimeServiceGetTime() throws Exception {
+ doTestGMTTimeServiceGetTime(GMTTimeService.class);
+ }
+
+ /**
+ * Test to get the getTime(int) method from the GMTTimeService interface from
+ * the specified class
+ *
+ * @param timeServiceClass The class that implements the WorldTimeService
+ * @throws Exception Test failed
+ */
+ private void doTestGMTTimeServiceGetTime(Class<?> timeServiceClass) throws Exception {
+ // Add a getTime(String) method
+ Operation operation = newOperation("getTime", GMTTimeService.class, Integer.TYPE);
+
+ Method method = JavaInterfaceUtil.findMethod(timeServiceClass, operation);
+ assertEquals("getTime", method.getName());
+ assertEquals(1, method.getParameterTypes().length);
+ assertEquals(Integer.TYPE, method.getParameterTypes()[0]);
+ }
+
+ /**
+ * Test to get the getTime() method from the LocalTimeService on the
+ * TimeServiceImpl class
+ *
+ * @throws Exception Test failed
+ */
+ @Test
+ public void testLocalTimeServiceGetTimeFromTimeServiceImpl() throws Exception {
+ doTestLocalTimeServiceGetTime(TimeServiceImpl.class);
+ }
+
+ /**
+ * Test to get the getTime(String) method from the WorldTimeService on the
+ * TimeServiceImpl class
+ *
+ * @throws Exception Test failed
+ */
+ @Test
+ public void testWorldTimeServiceGetTimeFromTimeServiceImpl() throws Exception {
+ doTestWorldTimeServiceGetTime(TimeServiceImpl.class);
+ }
+
+ /**
+ * Test to get the getTime(int) method from the GMTTimeService
+ *
+ * @throws Exception Test failed
+ */
+ @Test
+ public void testGMTTimeServiceGetTimeFromTimeServiceImpl() throws Exception {
+ doTestGMTTimeServiceGetTime(TimeServiceImpl.class);
+ }
+
+ /**
+ * Test case that validates that a @Remotable interface with Overloaded operations
+ * is detected.
+ *
+ * This test case is for TUSCANY-2194
+ */
+ @Test
+ public void testDuplicateOpeartionOnRemotableInterface()
+ {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory(registry);
+ JavaInterfaceIntrospectorImpl introspector = new JavaInterfaceIntrospectorImpl(javaFactory);
+ JavaInterfaceImpl javaInterface = new JavaInterfaceImpl();
+
+ try {
+ introspector.introspectInterface(javaInterface, DuplicateMethodOnRemotableInterface.class);
+ Assert.fail("Should have thrown an exception as @Remotable interface has overloaded methods");
+ } catch (OverloadedOperationException ex) {
+ // As expected
+ // Make sure that the class and method names are in the exception
+ String exMsg = ex.toString();
+ Assert.assertTrue("Method name missing from exception", exMsg.indexOf("aDuplicateMethod") != -1);
+ Assert.assertTrue("Class name missing from exception",
+ exMsg.indexOf(DuplicateMethodOnRemotableInterface.class.getName()) != -1);
+ } catch (InvalidInterfaceException ex) {
+ // Should have thrown OverloadedOperationException
+ Assert.fail("Should have thrown an OverloadedOperationException but threw " + ex);
+ }
+ }
+
+ /**
+ * Creates a new operation with the specified name and parameter types
+ *
+ * @param name The name of the operation
+ * @param operationInterface The interface to which the operation belongs
+ * @param parameterTypes The types of the parameters for this operation
+ * @return An operation with the specified name and parameter types
+ */
+ private static Operation newOperation(String name, Class<?> operationInterface, Class<?>... parameterTypes) {
+ // Create and set the operation name
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+
+ // Make the operation remotable
+ Interface iface = new InterfaceImpl();
+ iface.setRemotable(true);
+ operation.setInterface(iface);
+
+ // Construct the parameters
+ List<DataType> types = new ArrayList<DataType>();
+ DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>(Object[].class, types);
+ for (Class<?> parameterType : parameterTypes) {
+ DataType type = new DataTypeImpl<Class>(parameterType, Object.class);
+ types.add(type);
+ }
+ operation.setInputType(inputType);
+
+ // Return the created operation
+ return operation;
+ }
+
+ /**
+ * Sample @Remotable interface that has an overloaded operation which is not
+ * allowed according to the SCA Assembly Specification.
+ */
+ @Remotable
+ private interface DuplicateMethodOnRemotableInterface {
+ void aNonDuplicateMethod();
+ void aDuplicateMethod();
+ void aDuplicateMethod(String aParam);
+ }
+
+
+ /**
+ * Sample interface needed for the unit tests
+ */
+ @Remotable
+ private interface LocalTimeService {
+
+ /**
+ * Gets the local time
+ *
+ * @return The Local Time
+ */
+ String getTime();
+ }
+
+ /**
+ * Sample interface needed for the unit tests
+ */
+ @Remotable
+ private interface WorldTimeService {
+
+ /**
+ * Gets the time in the specified TimeZone
+ *
+ * @param timeZone A Time Zone
+ *
+ * @return The time in the specified TimeZone
+ */
+ String getTime(String timeZone);
+ }
+
+ /**
+ * Sample interface needed for the unit tests
+ */
+ @Remotable
+ private interface GMTTimeService {
+
+ /**
+ * Gets the time with the specified GMT offset
+ *
+ * @param gmtOffset A GMT offset in hours
+ *
+ * @return The time with the specified GMT offset
+ */
+ String getTime(int gmtOffset);
+ }
+
+ /**
+ * Sample implementation class that implements the three @Remotable interfaces
+ */
+ private class TimeServiceImpl implements LocalTimeService, WorldTimeService, GMTTimeService {
+ /**
+ * Gets the local time
+ *
+ * @return The Local Time
+ */
+ public String getTime() {
+ return "The current local time";
+ }
+
+ /**
+ * Gets the time in the specified TimeZone
+ *
+ * @param timeZone A Time Zone
+ *
+ * @return The time in the specified TimeZone
+ */
+ public String getTime(String timeZone) {
+ return "The current time in TimeZone " + timeZone;
+ }
+
+ /**
+ * Gets the time with the specified GMT offset
+ *
+ * @param gmtOffset A GMT offset in hours
+ *
+ * @return The time with the specified GMT offset
+ */
+ public String getTime(int gmtOffset) {
+ return "The current time with GMT offset of " + gmtOffset;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilTestCase.java
new file mode 100644
index 0000000000..86a38fa0c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilTestCase.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.sca.interfacedef.java.impl;
+
+import static org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil.findOperation;
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceUtilTestCase {
+ private List<Operation> operations;
+
+ @Test
+ public void testNoParamsFindOperation() throws Exception {
+ Method method = Foo.class.getMethod("foo");
+ Operation ret = findOperation(method, operations);
+ assertEquals("foo", ret.getName());
+ assertEquals(0, method.getParameterTypes().length);
+ }
+
+ @Test
+ public void testParamsFindOperation() throws Exception {
+ Method method = Foo.class.getMethod("foo", String.class);
+ Operation ret = findOperation(method, operations);
+ assertEquals("foo", ret.getName());
+ assertEquals(String.class, method.getParameterTypes()[0]);
+ }
+
+ @Test
+ public void testPrimitiveParamFindOperation() throws NoSuchMethodException {
+ Method method = Foo.class.getMethod("foo", Integer.TYPE);
+ Operation operation = findOperation(method, operations);
+ assertEquals(Integer.TYPE, operation.getInputType().getLogical().get(0).getPhysical());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ Operation operation = newOperation("foo");
+ List<DataType> types = new ArrayList<DataType>();
+ DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>(Object[].class, types);
+ operation.setInputType(inputType);
+
+ operations = new ArrayList<Operation>();
+ operations.add(operation);
+
+ types = new ArrayList<DataType>();
+ inputType = new DataTypeImpl<List<DataType>>(Object[].class, types);
+ DataType type = new DataTypeImpl<Class>(String.class, Object.class);
+ types.add(type);
+ operation = newOperation("foo");
+ operation.setInputType(inputType);
+ operations.add(operation);
+
+ types = new ArrayList<DataType>();
+ type = new DataTypeImpl<Class>(String.class, Object.class);
+ DataType type2 = new DataTypeImpl<Class>(String.class, Object.class);
+ types.add(type);
+ types.add(type2);
+ inputType = new DataTypeImpl<List<DataType>>(Object[].class, types);
+ operation = newOperation("foo");
+ operation.setInputType(inputType);
+ operations.add(operation);
+
+ types = new ArrayList<DataType>();
+ type = new DataTypeImpl<Class>(Integer.class, Object.class);
+ types.add(type);
+ inputType = new DataTypeImpl<List<DataType>>(Object[].class, types);
+ operation = newOperation("foo");
+ operation.setInputType(inputType);
+ operations.add(operation);
+
+ types = new ArrayList<DataType>();
+ type = new DataTypeImpl<Class>(Integer.TYPE, Object.class);
+ types.add(type);
+ inputType = new DataTypeImpl<List<DataType>>(Object[].class, types);
+ operation = newOperation("foo");
+ operation.setInputType(inputType);
+ operations.add(operation);
+
+ }
+
+ private interface Foo {
+ void foo();
+
+ void foo(String foo);
+
+ void foo(int b);
+ }
+
+ private static Operation newOperation(String name) {
+ Operation operation = new OperationImpl();
+ operation.setName(name);
+ return operation;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java.fixme b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java.fixme
new file mode 100644
index 0000000000..14ac8b0134
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java.fixme
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.introspection.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceProcessorRegistryImplTestCase extends TestCase {
+ private JavaInterfaceFactory factory;
+
+ @SuppressWarnings("unchecked")
+ public void testSimpleInterface() throws InvalidInterfaceException {
+ JavaInterface intf = factory.createJavaInterface(Simple.class);
+
+ assertEquals(Simple.class, intf.getJavaClass());
+ List<Operation> operations = intf.getOperations();
+ assertEquals(1, operations.size());
+ Operation baseInt = operations.get(0);
+ assertEquals("baseInt", baseInt.getName());
+
+ QName element = new QName("http://impl.introspection.java.interfacedef.sca.tuscany.apache.org/", "return");
+
+ DataType<XMLType> returnType = baseInt.getOutputType();
+ assertEquals(Integer.TYPE, returnType.getPhysical());
+ assertEquals(element, returnType.getLogical().getElementName());
+
+ List<DataType> parameterTypes = baseInt.getInputType().getLogical();
+ assertEquals(1, parameterTypes.size());
+ DataType<XMLType> arg0 = parameterTypes.get(0);
+ assertEquals(Integer.TYPE, arg0.getPhysical());
+
+ element = new QName("http://impl.introspection.java.interfacedef.sca.tuscany.apache.org/", "arg0");
+ assertEquals(element, arg0.getLogical().getElementName());
+
+ List<DataType> faultTypes = baseInt.getFaultTypes();
+ assertEquals(1, faultTypes.size());
+ DataType<DataType<XMLType>> fault0 = faultTypes.get(0);
+ assertEquals(IOException.class, fault0.getPhysical());
+ element = new QName("http://impl.introspection.java.interfacedef.sca.tuscany.apache.org/", "IOException");
+ assertEquals(element, fault0.getLogical().getLogical().getElementName());
+ }
+
+ public void testUnregister() throws Exception {
+ JavaInterfaceVisitor extension = createMock(JavaInterfaceVisitor.class);
+ extension.visitInterface(EasyMock.isA(JavaInterface.class));
+ expectLastCall().once();
+ replay(extension);
+ factory.addInterfaceVisitor(extension);
+ factory.createJavaInterface(Base.class);
+ factory.removeInterfaceVisitor(extension);
+ factory.createJavaInterface(Base.class);
+ verify(extension);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ factory = new DefaultJavaInterfaceFactory();
+
+ }
+
+ private static interface Base {
+ int baseInt(int param) throws IllegalArgumentException, IOException;
+ }
+
+ private static interface Simple extends Base {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/PolicyProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/PolicyProcessorTestCase.java
new file mode 100644
index 0000000000..41facdb3e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/PolicyProcessorTestCase.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.java.introspection.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.annotation.Authentication;
+import org.oasisopen.sca.annotation.Confidentiality;
+import org.oasisopen.sca.annotation.PolicySets;
+import org.oasisopen.sca.annotation.Requires;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PolicyProcessorTestCase {
+ private JavaInterfaceFactory factory;
+ // private PolicyJavaInterfaceVisitor policyProcessor;
+
+ @Test
+ public void testInterfaceLevel() throws Exception {
+ JavaInterface type = factory.createJavaInterface(Interface1.class);
+ // policyProcessor.visitInterface(type);
+ assertEquals(2, type.getRequiredIntents().size());
+ assertEquals(1, type.getPolicySets().size());
+ }
+
+ @Test
+ public void testMethodLevel() throws Exception {
+ JavaInterface type = factory.createJavaInterface(Interface2.class);
+ // policyProcessor.visitInterface(type);
+ assertEquals(0, type.getRequiredIntents().size());
+ assertEquals(3, type.getOperations().get(0).getRequiredIntents().size());
+ assertEquals(1, type.getOperations().get(1).getRequiredIntents().size());
+ assertEquals(0, type.getPolicySets().size());
+ assertEquals(1, type.getOperations().get(0).getPolicySets().size());
+ assertEquals(1, type.getOperations().get(1).getPolicySets().size());
+ }
+
+ @Test
+ public void testInterfaceAndMethodLevel() throws Exception {
+ JavaInterface type = factory.createJavaInterface(Interface3.class);
+ // policyProcessor.visitInterface(type);
+ assertEquals(2, type.getRequiredIntents().size());
+ assertEquals(3, type.getOperations().get(0).getRequiredIntents().size());
+ assertEquals(3, type.getOperations().get(1).getRequiredIntents().size());
+ assertEquals(1, type.getPolicySets().size());
+ assertEquals(2, type.getOperations().get(0).getPolicySets().size());
+ assertEquals(2, type.getOperations().get(1).getPolicySets().size());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ factory = new DefaultJavaInterfaceFactory(registry);
+ // policyProcessor = new PolicyJavaInterfaceVisitor(registry);
+ }
+
+ // @Remotable
+ @Requires( {"transaction.global"})
+ @PolicySets( {"{http://ns1}PS1"})
+ @Authentication
+ private interface Interface1 {
+ int method1();
+
+ int method2();
+
+ int method3();
+
+ int method4();
+ }
+
+ private interface Interface2 {
+ @Requires( {"transaction.global"})
+ @Confidentiality({"message", "transport"})
+ @PolicySets( {"{http://ns1}PS1"})
+ int method1();
+
+ @Requires( {"transaction.local"})
+ @PolicySets( {"{http://ns1}PS2"})
+ int method2();
+ }
+
+ @Requires( {"transaction.global.Interface6"})
+ @PolicySets( {"{http://ns1}PS1"})
+ @Authentication
+ private interface Interface3 {
+ @Requires( {"transaction.global.Interface6.method1"})
+ @PolicySets( {"{http://ns1}PS2"})
+ int method1();
+
+ @Requires( {"transaction.local.Interface6.method2"})
+ @PolicySets( {"{http://ns1}PS3"})
+ int method2();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/ReadTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/ReadTestCase.java
new file mode 100644
index 0000000000..7cacf06abd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/ReadTestCase.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.sca.interfacedef.java.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test reading Java interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ComponentType componentType = (ComponentType)staxProcessor.read(reader, context);
+ assertNotNull(componentType);
+ }
+
+ @Test
+ @Ignore
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/WriteTestCase.java b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/WriteTestCase.java
new file mode 100644
index 0000000000..615fb15fc6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/WriteTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.java.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test writing Java interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase {
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentType componentType = (ComponentType)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(componentType);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos), context);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(composite);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite b/sandbox/sebastien/java/embed/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite
new file mode 100644
index 0000000000..e5455dc970
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite
@@ -0,0 +1,53 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://sample.calculator"
+ targetNamespace="http://calc"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService" requires="calc:intent1" policySets="calc:policySet1" />
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/CalculatorImpl.componentType b/sandbox/sebastien/java/embed/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..68793041e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/CalculatorImpl.componentType
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java interface="calculator.DivideService" />
+ </reference>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/LICENSE b/sandbox/sebastien/java/embed/modules/interface-wsdl/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/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/sebastien/java/embed/modules/interface-wsdl/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/interface-wsdl/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..75ad6812be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/META-INF/MANIFEST.MF
@@ -0,0 +1,47 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.interfacedef.wsdl;uses:="org.ap
+ ache.ws.commons.schema,org.apache.tuscany.sca.assembly,org.apache.tus
+ cany.sca.contribution.resolver,javax.wsdl.extensions,org.apache.tusca
+ ny.sca.core,org.apache.tuscany.sca.interfacedef,javax.wsdl,javax.xml.
+ namespace";version="2.0.0"
+Private-Package: org.apache.tuscany.sca.interfacedef.wsdl.impl;version
+ ="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA WSDL Interface Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA WSDL Interface Model
+Import-Package: javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.schema,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.tuscany.sca.xsd.xml;version="2.0.0",
+ org.apache.ws.commons.schema,
+ org.w3c.dom,
+ org.xml.sax
+Bundle-SymbolicName: org.apache.tuscany.sca.interface.wsdl
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/NOTICE b/sandbox/sebastien/java/embed/modules/interface-wsdl/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/pom.xml b/sandbox/sebastien/java/embed/modules/interface-wsdl/pom.xml
new file mode 100644
index 0000000000..2dfd55644d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/pom.xml
@@ -0,0 +1,86 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <name>Apache Tuscany SCA WSDL Interface Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.4.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency-->
+
+ </dependencies>
+
+ <repositories>
+ <!-- Apache repository for Web Services artifacts -->
+ <repository>
+ <id>apache.ws.zone</id>
+ <name>Apache WS Zone Repository</name>
+ <url>http://ws.zones.apache.org/repository2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/BPELPartnerLinkTypeExt.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/BPELPartnerLinkTypeExt.java
new file mode 100644
index 0000000000..26404958e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/BPELPartnerLinkTypeExt.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.interfacedef.wsdl;
+
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.xml.namespace.QName;
+
+/**
+ * A class to serve as the extensibility element for BPEL partnerLinkType elements
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELPartnerLinkTypeExt implements ExtensibilityElement {
+
+ private QName elementType = null;
+ private String linkTypeName = null;
+ private String[] roleNames = new String[2];
+ private QName[] rolePortTypes = new QName[2];
+
+ // -- methods required by the Extensibility Element interface
+ public QName getElementType() {
+ return elementType;
+ }
+
+ public Boolean getRequired() {
+ return true;
+ }
+
+ public void setElementType(QName theName ) {
+ elementType = theName;
+ }
+
+ public void setRequired(Boolean required) {
+ // intentionally left blank
+ }
+
+ // -- other methods
+
+ public void setName( String theName ) {
+ linkTypeName = theName;
+ }
+
+ public String getName() {
+ return linkTypeName;
+ }
+
+ public void setRole( int i, String name, QName portType ) {
+ if( i > 1 ) return;
+ roleNames[i] = name;
+ rolePortTypes[i] = portType;
+ }
+
+ public String getRoleName( int i ) {
+ if( i > 1 ) return null;
+ return roleNames[i];
+ }
+
+ public QName getRolePortType( int i ) {
+ if( i > 1 ) return null;
+ return rolePortTypes[i];
+ }
+
+} // end BPELPartnerLinkTypeExt
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/DefaultWSDLFactory.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/DefaultWSDLFactory.java
new file mode 100644
index 0000000000..037dffeadc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/DefaultWSDLFactory.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 org.apache.tuscany.sca.interfacedef.wsdl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLFactoryImpl;
+
+/**
+ * A factory for the WSDL model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultWSDLFactory extends WSDLFactoryImpl implements WSDLFactory {
+
+ public DefaultWSDLFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
new file mode 100644
index 0000000000..9fd4313af0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLElement;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * Represents a WSDL definition.
+ * WSDLDefinition
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WSDLDefinition extends Base {
+
+ /**
+ * Returns the WSDL definition model, if there are more than one WSDL definition under the
+ * same namespace, the definition will be a facade which imports all the physical WSDL
+ * definitions
+ *
+ * @return the WSDL definition model
+ */
+ Definition getDefinition();
+
+ /**
+ * Sets the WSDL definition model
+ * @param definition the WSDL definition model
+ */
+ void setDefinition(Definition definition);
+
+ /**
+ * Returns the namespace of this WSDL definition.
+ * @return the namespace of this WSDL definition
+ */
+ String getNamespace();
+
+ /**
+ * Sets the namespace of this WSDL definition.
+ * @param namespace the namespace of this WSDL definition
+ */
+ void setNamespace(String namespace);
+
+ /**
+ * Get a list of inline XML schema definitions
+ * @return A list of inline XML schema definitions
+ */
+ List<XSDefinition> getXmlSchemas();
+
+ /**
+ * Get the location of the WSDL file
+ * @return The location of the WSDL file
+ */
+ URI getLocation();
+
+ /**
+ * Set the location of the WSDL file
+ * @param url
+ */
+ void setLocation(URI url);
+
+ /**
+ * Get the contribution artifact URI of the WSDL document
+ * @return The URI of the WSDL document
+ */
+ URI getURI();
+
+ /**
+ * Set the contribution artifact URI of the WSDL document
+ * @param uri
+ */
+ void setURI(URI uri);
+
+ /**
+ * Get the WSDL definitions imported by this definition
+ * @return A list of imported WSDL definitions
+ */
+ List<WSDLDefinition> getImportedDefinitions();
+
+ /**
+ * Get an XSD element by QName
+ * @param name
+ * @return
+ */
+ XmlSchemaElement getXmlSchemaElement(QName name);
+
+ /**
+ * Get an XSD type by QName
+ * @param name
+ * @return
+ */
+ XmlSchemaType getXmlSchemaType(QName name);
+
+ /**
+ * Get the WSDL object by type and name
+ * @param <T>
+ * @param type javax.wsdl.Service/PortType/Binding/Message.class
+ * @param name The QName of the object
+ * @return WSDLObject
+ */
+ <T extends WSDLElement> WSDLObject<T> getWSDLObject(Class<T> type, QName name);
+
+ /**
+ * Get the generated binding for a WSDLDefinition
+ * @return the WSDL binding
+ */
+ Binding getBinding();
+
+ /**
+ * Set the generated binding for a WSDLDefinition
+ * @param binding the WSDL binding
+ */
+ void setBinding(Binding binding);
+
+ /**
+ * Retrieves the name of the required port type used during the WSDL resolve process
+ *
+ * @return WSDL port type name
+ */
+ QName getNameOfPortTypeToResolve();
+
+ /**
+ * Sets the name of the required port type used during the WSDL resolve process
+ *
+ * @param nameOfPortTypeToResolve
+ */
+ void setNameOfPortTypeToResolve(QName nameOfPortTypeToResolve);
+
+ /**
+ * Retrieves the name of the required binding used during the WSDL resolve process
+ *
+ * @return WSDL binding name
+ */
+ QName getNameOfBindingToResolve();
+
+ /**
+ * Sets the name of the required binding used during the WSDL resolve process
+ *
+ * @param nameOfBindingToResolve
+ */
+ void setNameOfBindingToResolve(QName nameOfBindingToResolve);
+
+ /**
+ * Retrieves the name of the required service used during the WSDL resolve process
+ *
+ * @return WSDL service name
+ */
+ QName getNameOfServiceToResolve();
+
+ /**
+ * Sets the name of the required service used during the WSDL resolve process
+ *
+ * @param nameOfBindingToResolve
+ */
+ void setNameOfServiceToResolve(QName nameOfServiceToResolve);
+
+ /**
+ * Gets the wsdli:location attribute namespace mappings
+ * @return a Map with key being namespace and value the location
+ */
+ Map<String, String> getWsdliLocations();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLFactory.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLFactory.java
new file mode 100644
index 0000000000..4e331c1fa4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLFactory.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.interfacedef.wsdl;
+
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * Factory for the WSDL model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WSDLFactory {
+
+ /**
+ * Creates a new WSDL interface.
+ *
+ * @return a new WSDL interface
+ */
+ WSDLInterface createWSDLInterface();
+
+ /**
+ * Creates a new WSDL interface from a WSDL portType.
+ *
+ * @param portType the portType to inspect
+ * @return a WSDLInterface corresponding to the WSDL portType
+ */
+ WSDLInterface createWSDLInterface(PortType portType, WSDLDefinition wsdlDefinition, ModelResolver resolver, Monitor monitor) throws InvalidInterfaceException;
+
+ /**
+ * Creates the contents of a WSDL interface from a WSDL portType.
+ *
+ * @param portType the portType to inspect
+ * @return a WSDLInterface corresponding to the WSDL portType
+ */
+ void createWSDLInterface(WSDLInterface wsdlInterface, PortType portType, WSDLDefinition wsdlDefinition, ModelResolver resolver, Monitor monitor) throws InvalidInterfaceException;
+
+ /**
+ * Creates a new WSDL definition.
+ *
+ * @return a new WSDL definition
+ */
+ WSDLDefinition createWSDLDefinition();
+
+ /**
+ * Creates a new WSDL interface contract.
+ *
+ * @return
+ */
+ WSDLInterfaceContract createWSDLInterfaceContract();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.java
new file mode 100644
index 0000000000..8c3cc10792
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.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.sca.interfacedef.wsdl;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.interfacedef.Interface;
+
+
+/**
+ * Represents a WSDL interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ * TODO check this spi tag is valid (indicated by access from implementation.bpel)
+ */
+public interface WSDLInterface extends Interface, Base {
+
+ /**
+ * Returns the name of the WSDL interface.
+ *
+ * @return the name of the WSDL interface
+ */
+ QName getName();
+
+ /**
+ * Sets the name of the WSDL interface.
+ *
+ * @param interfaceName the name of the WSDL interface
+ */
+ void setName(QName interfaceName);
+
+ /**
+ * Returns the WSDL interface portType.
+ *
+ * @return the WSDL interface portType
+ */
+ PortType getPortType();
+
+ /**
+ * Sets the WSDL interface portType
+ *
+ * @param portType the WSDL interface portType
+ */
+ void setPortType(PortType portType);
+
+ /**
+ * Gets the Interface of the Callback for this WSDL interface
+ * @return the WSDLInterface of the Callback, null if there is no Callback
+ */
+ WSDLInterface getCallbackInterface();
+
+ /**
+ * Sets the interface of the Callback for this WSDL interface
+ * @param callback - the WSDLInterface of the Callback
+ */
+ void setCallbackInterface(WSDLInterface callback);
+
+ WSDLDefinition getWsdlDefinition();
+
+ void setWsdlDefinition(WSDLDefinition wsdlDefinition);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java
new file mode 100644
index 0000000000..59db17116b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.wsdl;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+
+/**
+ * Represents a WSDL interface contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WSDLInterfaceContract extends InterfaceContract {
+
+ /**
+ * Sets the WSDL location.
+ * @param location the WSDL location
+ */
+ void setLocation(String location);
+
+ /**
+ * Returns the WSDL location
+ * @return the WSDL location
+ */
+ String getLocation();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLObject.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLObject.java
new file mode 100644
index 0000000000..0b707163da
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLObject.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.sca.interfacedef.wsdl;
+
+import java.io.Serializable;
+
+import javax.wsdl.Definition;
+
+/**
+ * Model for objects in a WSDL definition
+ * @version $Rev$ $Date$
+ */
+public interface WSDLObject<T extends Serializable> {
+ /**
+ * Get the owning definition where the element is declared
+ * @return The owning definition
+ */
+ Definition getDefinition();
+
+ /**
+ * Set the owning definition
+ * @param definition
+ */
+ void setDefinition(Definition definition);
+
+ /**
+ * Get the WSDL element such as Service, PortType, Binding or Message
+ * @return The WSDL element
+ */
+ T getElement();
+
+ /**
+ * Set the WSDL element
+ * @param element
+ */
+ void setElement(T element);
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
new file mode 100644
index 0000000000..d73cccb714
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.wsdl;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * WSDL 1.1 Operation
+ * @version $Rev$ $Date$
+ */
+public interface WSDLOperation extends Operation {
+ /**
+ * Get the underlying WSDL operation
+ * @return
+ */
+ javax.wsdl.Operation getWsdlOperation();
+
+ /**
+ * Set the underlying WSDL operation
+ * @param operation
+ */
+ void setWsdlOperation(javax.wsdl.Operation operation);
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/InvalidWSDLException.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/InvalidWSDLException.java
new file mode 100644
index 0000000000..1e7b4faa32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/InvalidWSDLException.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 org.apache.tuscany.sca.interfacedef.wsdl.impl;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+
+/**
+ * An exception to indicate the WSDL definition is invalid
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidWSDLException extends InvalidInterfaceException {
+ private static final long serialVersionUID = 3742887584293256519L;
+
+ public InvalidWSDLException(String message) {
+ super(message);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
new file mode 100644
index 0000000000..5b3ad74229
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
@@ -0,0 +1,321 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.impl;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Message;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLElement;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * Represents a WSDL definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLDefinitionImpl implements WSDLDefinition {
+
+ private Definition definition;
+ private String namespace;
+ private URI location;
+ private URI uri;
+ private List<WSDLDefinition> imported = new ArrayList<WSDLDefinition>();
+ private List<XSDefinition> schemas = new ArrayList<XSDefinition>();
+ private boolean unresolved;
+ private Binding binding;
+
+ // WSDL in the same namespace can appear in multiple contributions
+ // so we need to know which port type, binding and/or service we're looking for,
+ // as well as which namespace, when we're resolving WSDL
+ private QName nameOfPortTypeToResolve;
+ private QName nameOfBindingToResolve;
+ private QName nameOfServiceToResolve;
+ private Map<String, String> wsdliLocations = new HashMap<String, String>();
+
+ protected WSDLDefinitionImpl() {
+ }
+
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(Definition definition) {
+ this.definition = definition;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ public String getNamespace() {
+ if (isUnresolved()) {
+ return namespace;
+ } else if (definition != null) {
+ return definition.getTargetNamespace();
+ } else {
+ return namespace;
+ }
+ }
+
+ public void setNamespace(String namespace) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ } else {
+ this.namespace = namespace;
+ }
+ }
+
+ /*
+ @Override
+ public int hashCode() {
+ return String.valueOf(getNamespace()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof WSDLDefinition) {
+ WSDLDefinition def = (WSDLDefinition)obj;
+ if (getNamespace() != null) {
+ return getNamespace().equals(def.getNamespace());
+ } else {
+ return def.getNamespace() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+ */
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition#getXmlSchemas()
+ */
+ public List<XSDefinition> getXmlSchemas() {
+ return schemas;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition#getLocation()
+ */
+ public URI getLocation() {
+ return location;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition#setLocation(java.net.URI)
+ */
+ public void setLocation(URI url) {
+ this.location = url;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition#getURI()
+ */
+ public URI getURI() {
+ return uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition#setURI(java.net.URI)
+ */
+ public void setURI(URI uri) {
+ this.uri = uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition#getImportedDefinitions()
+ */
+ public List<WSDLDefinition> getImportedDefinitions() {
+ return imported;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof WSDLDefinitionImpl))
+ return false;
+ final WSDLDefinitionImpl other = (WSDLDefinitionImpl)obj;
+ if (location == null) {
+ if (other.location != null)
+ return false;
+ } else if (!location.equals(other.location))
+ return false;
+ if (namespace == null) {
+ if (other.namespace != null)
+ return false;
+ } else if (!namespace.equals(other.namespace))
+ return false;
+ return true;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition#getXmlSchemaElement(javax.xml.namespace.QName)
+ */
+ public XmlSchemaElement getXmlSchemaElement(QName name) {
+ XmlSchemaCollection schemaCollection = null;
+ for (XSDefinition xsd : schemas) {
+ if (schemaCollection == null && xsd.getSchemaCollection() != null) {
+ schemaCollection = xsd.getSchemaCollection();
+ }
+ XmlSchemaElement element = xsd.getXmlSchemaElement(name);
+ if (element != null) {
+ return element;
+ }
+ }
+ if (schemaCollection != null) {
+ return schemaCollection.getElementByQName(name);
+ }
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition#getXmlSchemaType(javax.xml.namespace.QName)
+ */
+ public XmlSchemaType getXmlSchemaType(QName name) {
+ XmlSchemaCollection schemaCollection = null;
+ for (XSDefinition xsd : schemas) {
+ if (xsd.getSchemaCollection() != null) {
+ schemaCollection = xsd.getSchemaCollection();
+ }
+ XmlSchemaType type = xsd.getXmlSchemaType(name);
+ if (type != null) {
+ return type;
+ }
+ }
+ if (schemaCollection != null) {
+ return schemaCollection.getTypeByQName(name);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T extends WSDLElement> WSDLObject<T> getWSDLObject(Definition definition, Class<T> type, QName name) {
+ if (definition == null) {
+ return null;
+ }
+ Map<QName, WSDLElement> map = null;
+ if (type == PortType.class) {
+ map = definition.getPortTypes();
+ } else if (type == Service.class) {
+ map = definition.getServices();
+ } else if (type == Binding.class) {
+ map = definition.getBindings();
+ } else if (type == Message.class) {
+ map = definition.getMessages();
+ } else {
+ throw new IllegalArgumentException("Invalid type: " + type.getName());
+ }
+ if (map.containsKey(name)) {
+ return (WSDLObject<T>)new WSDLObjectImpl(definition, map.get(name));
+ } else {
+ for (Object imports : definition.getImports().values()) {
+ List<Import> importList = (List<Import>)imports;
+ for (Import i : importList) {
+ definition = i.getDefinition();
+ WSDLObject<T> element = getWSDLObject(definition, type, name);
+ if (element != null) {
+ return element;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public <T extends WSDLElement> WSDLObject<T> getWSDLObject(Class<T> type, QName name) {
+ return getWSDLObject(definition, type, name);
+ }
+
+ public Binding getBinding() {
+ return binding;
+ }
+
+ public void setBinding(Binding binding) {
+ this.binding = binding;
+ }
+
+ public QName getNameOfPortTypeToResolve() {
+ return nameOfPortTypeToResolve;
+ }
+
+ public void setNameOfPortTypeToResolve(QName nameOfPortTypeToResolve) {
+ this.nameOfPortTypeToResolve = nameOfPortTypeToResolve;
+ }
+
+ public QName getNameOfBindingToResolve() {
+ return nameOfBindingToResolve;
+ }
+
+ public void setNameOfBindingToResolve(QName nameOfBindingToResolve) {
+ this.nameOfBindingToResolve = nameOfBindingToResolve;
+ }
+
+ public QName getNameOfServiceToResolve() {
+ return nameOfServiceToResolve;
+ }
+
+ public void setNameOfServiceToResolve(QName nameOfServiceToResolve) {
+ this.nameOfServiceToResolve = nameOfServiceToResolve;
+ }
+
+ @Override
+ public Map<String, String> getWsdliLocations() {
+ return wsdliLocations ;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLFactoryImpl.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLFactoryImpl.java
new file mode 100644
index 0000000000..52c9984831
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLFactoryImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.impl;
+
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ * A factory for the WSDL model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class WSDLFactoryImpl implements WSDLFactory {
+
+ private WSDLInterfaceIntrospectorImpl introspector;
+
+ public WSDLFactoryImpl(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ introspector = new WSDLInterfaceIntrospectorImpl(modelFactories, this);
+ } // end constructor WSDLFactoryImpl(ExtensionPointRegistry registry)
+
+ public WSDLInterface createWSDLInterface() {
+ return new WSDLInterfaceImpl();
+ }
+
+ public WSDLInterface createWSDLInterface(PortType portType,
+ WSDLDefinition wsdlDefinition,
+ ModelResolver resolver,
+ Monitor monitor) throws InvalidInterfaceException {
+ WSDLInterface wsdlInterface = createWSDLInterface();
+ introspector.introspectPortType(wsdlInterface, portType, wsdlDefinition, resolver, monitor);
+ return wsdlInterface;
+ }
+
+ public void createWSDLInterface(WSDLInterface wsdlInterface,
+ PortType portType,
+ WSDLDefinition wsdlDefinition,
+ ModelResolver resolver,
+ Monitor monitor) throws InvalidInterfaceException {
+ introspector.introspectPortType(wsdlInterface, portType, wsdlDefinition, resolver, monitor);
+ }
+
+ public WSDLDefinition createWSDLDefinition() {
+ return new WSDLDefinitionImpl();
+ }
+
+ public WSDLInterfaceContract createWSDLInterfaceContract() {
+ return new WSDLInterfaceContractImpl();
+ }
+
+ public WSDLInterfaceIntrospectorImpl getWSDLInterfaceIntrospector() {
+ return introspector;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java
new file mode 100644
index 0000000000..201aecca40
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.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 org.apache.tuscany.sca.interfacedef.wsdl.impl;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractImpl;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+
+/**
+ * Represents a WSDL interface contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLInterfaceContractImpl extends InterfaceContractImpl implements WSDLInterfaceContract {
+ private String location;
+
+ protected WSDLInterfaceContractImpl() {
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ @Override
+ public WSDLInterfaceContractImpl clone() throws CloneNotSupportedException {
+ return (WSDLInterfaceContractImpl) super.clone();
+ }
+
+ public InterfaceContract getNormalizedWSDLContract() {
+ return this;
+ }
+
+ public void setNormailizedWSDLContract(InterfaceContract wsdlInterfaceContract) {
+ // do nothing as this already is a WSDL contract
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java
new file mode 100644
index 0000000000..95906f4a56
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.impl;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+
+/**
+ * Represents a WSDL interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLInterfaceImpl extends InterfaceImpl implements WSDLInterface {
+
+ private QName name;
+ private PortType portType;
+ private WSDLInterface callbackInterface = null;
+ private WSDLDefinition wsdlDefinition;
+
+ protected WSDLInterfaceImpl() {
+ setRemotable(true);
+ }
+
+ public QName getName() {
+ if (isUnresolved()) {
+ return name;
+ } else {
+ return portType.getQName();
+ }
+ }
+
+ public void setName(QName interfaceName) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ }
+ this.name = interfaceName;
+ }
+
+ public PortType getPortType() {
+ return portType;
+ }
+
+ public void setPortType(PortType portType) {
+ this.portType = portType;
+ if (portType != null) {
+ this.name = portType.getQName();
+ }
+ }
+
+ public WSDLDefinition getWsdlDefinition() {
+ return wsdlDefinition;
+ }
+
+ public void setWsdlDefinition(WSDLDefinition wsdlDefinition) {
+ this.wsdlDefinition = wsdlDefinition;
+ }
+
+ @Override
+ public WSDLInterfaceImpl clone() throws CloneNotSupportedException {
+ return (WSDLInterfaceImpl) super.clone();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ WSDLInterfaceImpl other = (WSDLInterfaceImpl)obj;
+ if (isUnresolved() || other.isUnresolved()) {
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ } else {
+ if (portType == null) {
+ if (other.portType != null)
+ return false;
+ } else if (!portType.equals(other.portType))
+ return false;
+ }
+ return true;
+ }
+
+ public WSDLInterface getCallbackInterface() {
+ return callbackInterface;
+ }
+
+ public void setCallbackInterface(WSDLInterface theInterface) {
+ callbackInterface = theInterface;
+ }
+
+} // end class WSDLInterfaceImpl
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.java
new file mode 100644
index 0000000000..dd19407abe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.wsdl.impl;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Vector;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLInterfaceProcessor;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+
+/**
+ * Introspector for creating WSDLInterface definitions from WSDL PortTypes.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLInterfaceIntrospectorImpl {
+ private static final QName POLICY_REQUIRES = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "requires");
+
+ private static final QName CALLBACK_ATTRIBUTE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "callback" );
+
+ private WSDLFactory wsdlFactory;
+ private XSDFactory xsdFactory;
+ private PolicyFactory policyFactory;
+
+ public WSDLInterfaceIntrospectorImpl(FactoryExtensionPoint modelFactories, WSDLFactory wsdlFactory) {
+ this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.wsdlFactory = wsdlFactory;
+ }
+
+ // FIXME: Do we want to deal with document-literal wrapped style based on the JAX-WS Specification?
+ private List<Operation> introspectOperations(PortType portType, WSDLDefinition wsdlDefinition, ModelResolver resolver, Monitor monitor) throws InvalidWSDLException {
+ List<Operation> operations = new ArrayList<Operation>();
+ for (Object o : portType.getOperations()) {
+ javax.wsdl.Operation wsdlOp = (javax.wsdl.Operation)o;
+ Operation operation = getOperation(wsdlOp, wsdlDefinition, resolver, xsdFactory, monitor);
+ operations.add(operation);
+ }
+ return operations;
+ }
+
+ public void introspectPortType(WSDLInterface wsdlInterface, PortType portType, WSDLDefinition wsdlDefinition, ModelResolver resolver, Monitor monitor) throws InvalidWSDLException {
+ processIntents(wsdlInterface, portType);
+ WSDLInterface callback = processCallbackAttribute( portType, resolver, monitor );
+ wsdlInterface.setPortType(portType);
+ wsdlInterface.setCallbackInterface(callback);
+ wsdlInterface.getOperations().addAll(introspectOperations(portType, wsdlDefinition, resolver, monitor));
+ }
+
+ public static Operation getOperation(javax.wsdl.Operation wsdlOp,
+ WSDLDefinition wsdlDefinition,
+ ModelResolver resolver,
+ XSDFactory xsdFactory,
+ Monitor monitor) throws InvalidWSDLException {
+ WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(xsdFactory, wsdlOp, wsdlDefinition, null, resolver, monitor);
+ return op.getOperation();
+ }
+
+ /**
+ * Process an extension @callback attribute on a WSDL portType declaration
+ * - the callback attribute must contain the QName of another portType
+ * @param portType the portType
+ * @return
+ */
+ private WSDLInterface processCallbackAttribute( PortType portType, ModelResolver resolver, Monitor monitor ) {
+ Object o = portType.getExtensionAttribute(CALLBACK_ATTRIBUTE);
+ if(o != null && o instanceof QName) {
+ WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface();
+ wsdlInterface.setUnresolved(true);
+ wsdlInterface.setName( (QName)o );
+ wsdlInterface = WSDLInterfaceProcessor.resolveWSDLInterface( wsdlInterface, resolver, monitor, wsdlFactory );
+
+ return wsdlInterface;
+ } else {
+ return null;
+ } // end if
+ } // end method processCallbackAttribute
+
+ private void processIntents(WSDLInterface wsdlInterface, PortType portType) {
+ Object o;
+ try {
+ o = portType.getExtensionAttribute(POLICY_REQUIRES);
+ } catch (NoSuchMethodError e) {
+ // That method does not exist on older WSDL4J levels
+ o = null;
+ }
+ if(o != null && o instanceof Vector) {
+ Vector<QName> policyAttributes = (Vector<QName>) o;
+
+ Enumeration<QName> policyItents = policyAttributes.elements();
+ while (policyItents.hasMoreElements()) {
+ QName intentName = policyItents.nextElement();
+
+ // Add each intent to the list
+ Intent intent = policyFactory.createIntent();
+ intent.setName(intentName);
+
+ wsdlInterface.getRequiredIntents().add(intent);
+ }
+
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLObjectImpl.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLObjectImpl.java
new file mode 100644
index 0000000000..f18eaef27b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLObjectImpl.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.sca.interfacedef.wsdl.impl;
+
+import java.io.Serializable;
+
+import javax.wsdl.Definition;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WSDLObjectImpl<T extends Serializable> implements WSDLObject<T> {
+ private Definition definition;
+ private T element;
+
+ public WSDLObjectImpl() {
+ super();
+ }
+
+ public WSDLObjectImpl(Definition definition, T element) {
+ super();
+ this.definition = definition;
+ this.element = element;
+ }
+
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(Definition definition) {
+ this.definition = definition;
+ }
+
+ public T getElement() {
+ return element;
+ }
+
+ public void setElement(T element) {
+ this.element = element;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java
new file mode 100644
index 0000000000..317b9cce81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.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.sca.interfacedef.wsdl.impl;
+
+import javax.wsdl.Operation;
+
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WSDLOperationImpl extends OperationImpl implements WSDLOperation {
+ private Operation operation;
+
+ public WSDLOperationImpl() {
+ super();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation#getWsdlOperation()
+ */
+ public Operation getWsdlOperation() {
+ return operation;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation#setWsdlOperation(javax.wsdl.Operation)
+ */
+ public void setWsdlOperation(Operation operation) {
+ this.operation = operation;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((operation == null) ? 0 : operation.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final WSDLOperationImpl other = (WSDLOperationImpl)obj;
+ if (operation == null) {
+ if (other.operation != null)
+ return false;
+ } else if (!operation.equals(other.operation))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return operation == null ? null : operation.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
new file mode 100644
index 0000000000..3fd476c46f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
@@ -0,0 +1,605 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * Metadata for a WSDL operation
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLOperationIntrospectorImpl {
+ private static final Logger logger = Logger.getLogger(WSDLOperationIntrospectorImpl.class.getName());
+ private static final QName ANY = new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "any");
+
+ private XSDFactory xsdFactory;
+ private ModelResolver resolver;
+ private ProcessorContext context;
+ private WSDLDefinition wsdlDefinition;
+ private javax.wsdl.Operation operation;
+ private WSDLOperation operationModel;
+ private DataType<List<DataType>> inputType;
+ private DataType outputType;
+ private List<DataType> faultTypes;
+ private String dataBinding;
+
+ /**
+ * @param wsdlFactory The WSDLFactory to use
+ * @param operation The WSDL4J operation
+ * @param wsdlDefinition The WSDL Definition
+ * @param dataBinding The default databinding
+ * @param resolver The ModelResolver to use
+ */
+ public WSDLOperationIntrospectorImpl(XSDFactory xsdFactory,
+ javax.wsdl.Operation operation,
+ WSDLDefinition wsdlDefinition,
+ String dataBinding,
+ ModelResolver resolver,
+ Monitor monitor) {
+ super();
+ this.xsdFactory = xsdFactory;
+ this.operation = operation;
+ this.wsdlDefinition = wsdlDefinition;
+ this.resolver = resolver;
+ this.dataBinding = dataBinding;
+ this.wrapper = new Wrapper();
+ this.context = new ProcessorContext(monitor);
+ }
+
+ private Wrapper wrapper;
+
+ private Boolean wrapperStyle;
+
+ /**
+ * Test if the operation qualifies wrapper style as defined by the JAX-WS
+ * 2.0 Specification
+ *
+ * @return true if the operation qualifies wrapper style, otherwise false
+ */
+ public boolean isWrapperStyle() throws InvalidWSDLException {
+ if (wrapperStyle == null) {
+ wrapperStyle =
+ (operation.getInput() == null || operation.getInput().getMessage() == null
+ || operation.getInput().getMessage().getParts().size() == 0 || wrapper.getInputChildElements() != null) && (operation
+ .getOutput() == null || operation.getOutput().getMessage() == null
+ || operation.getOutput().getMessage().getParts().size() == 0 || wrapper.getOutputChildElements() != null);
+ }
+ return wrapperStyle;
+ }
+
+ public Wrapper getWrapper() throws InvalidWSDLException {
+ if (!isWrapperStyle()) {
+ throw new IllegalStateException("The operation is not wrapper style.");
+ } else {
+ return wrapper;
+ }
+ }
+
+ /**
+ * @return
+ * @throws InvalidServiceContractException
+ */
+ public DataType<List<DataType>> getInputType() throws InvalidWSDLException {
+ if (inputType == null) {
+ Input input = operation.getInput();
+ Message message = (input == null) ? null : input.getMessage();
+ inputType = getMessageType(message);
+ inputType.setDataBinding("idl:input");
+ }
+ return inputType;
+ }
+
+ /**
+ * @return
+ * @throws NotSupportedWSDLException
+ */
+ @SuppressWarnings("unchecked")
+ public DataType<XMLType> getOutputType() throws InvalidWSDLException {
+ if (outputType == null) {
+ Output output = operation.getOutput();
+ Message outputMsg = (output == null) ? null : output.getMessage();
+
+ List outputParts = (outputMsg == null) ? null : outputMsg.getOrderedParts(null);
+ if (outputParts != null && outputParts.size() > 0) {
+ if (outputParts.size() > 1) {
+ // We don't support output with multiple parts
+ if (logger.isLoggable(Level.WARNING)) {
+ logger.warning("Multi-part output is not supported, please use BARE parameter style.");
+ }
+ // throw new InvalidWSDLException("Multi-part output is not supported");
+ }
+ Part part = (Part)outputParts.get(0);
+ outputType = new WSDLPart(part, Object.class).getDataType();
+ // outputType.setMetadata(WSDLOperation.class.getName(), this);
+ }
+ }
+ return outputType;
+ }
+
+ /**
+ * @return
+ * @throws NotSupportedWSDLException
+ */
+ public List<DataType> getFaultTypes() throws InvalidWSDLException {
+ if (faultTypes == null) {
+ Collection faults = operation.getFaults().values();
+ faultTypes = new ArrayList<DataType>();
+ for (Object f : faults) {
+ Fault fault = (Fault)f;
+ Message faultMsg = fault.getMessage();
+ List faultParts = faultMsg.getOrderedParts(null);
+ if (faultParts.size() != 1) {
+ throw new InvalidWSDLException("The fault message MUST have a single part");
+ }
+ Part part = (Part)faultParts.get(0);
+ WSDLPart wsdlPart = new WSDLPart(part, Object.class);
+ faultTypes.add(new DataTypeImpl<DataType>(FaultException.class, wsdlPart.getDataType()));
+ }
+ }
+ return faultTypes;
+ }
+
+ private DataType<List<DataType>> getMessageType(Message message) throws InvalidWSDLException {
+ List<DataType> partTypes = new ArrayList<DataType>();
+ if (message != null) {
+ Collection parts = message.getOrderedParts(null);
+ for (Object p : parts) {
+ WSDLPart part = new WSDLPart((Part)p, Object.class);
+ DataType<XMLType> partType = part.getDataType();
+ partTypes.add(partType);
+ }
+ }
+ return new DataTypeImpl<List<DataType>>(dataBinding, Object[].class, partTypes);
+ }
+
+ /**
+ * @return
+ * @throws NotSupportedWSDLException
+ */
+ public Operation getOperation() throws InvalidWSDLException {
+ if (operationModel == null) {
+ boolean oneway = (operation.getOutput() == null);
+ operationModel = new WSDLOperationImpl();
+ operationModel.setWsdlOperation(operation);
+ operationModel.setName(operation.getName());
+ operationModel.setFaultTypes(getFaultTypes());
+ operationModel.setNonBlocking(oneway);
+ operationModel.setInputType(getInputType());
+ operationModel.setOutputType(getOutputType());
+
+ operationModel.setWrapperStyle(isWrapperStyle());
+ if (isWrapperStyle()) {
+ WrapperInfo wrapperInfo = getWrapper().getWrapperInfo();
+ operationModel.setWrapper(wrapperInfo);
+ }
+ }
+ return operationModel;
+ }
+
+ private XmlSchemaElement getElement(QName elementName) {
+
+ XmlSchemaElement element = wsdlDefinition.getXmlSchemaElement(elementName);
+ if (element == null) {
+ XSDefinition definition = xsdFactory.createXSDefinition();
+ definition.setUnresolved(true);
+ definition.setNamespace(elementName.getNamespaceURI());
+ definition = resolver.resolveModel(XSDefinition.class, definition, context);
+ if (definition.getSchema() != null) {
+ element = definition.getSchema().getElementByName(elementName);
+ }
+ }
+ return element;
+ }
+
+ private XmlSchemaType getType(QName typeName) {
+ XmlSchemaType type = wsdlDefinition.getXmlSchemaType(typeName);
+ if (type == null) {
+ XSDefinition definition = xsdFactory.createXSDefinition();
+ definition.setUnresolved(true);
+ definition.setNamespace(typeName.getNamespaceURI());
+ definition = resolver.resolveModel(XSDefinition.class, definition, context);
+ if (definition.getSchema() != null) {
+ type = definition.getSchema().getTypeByName(typeName);
+ }
+ }
+ return type;
+ }
+
+ /**
+ * Metadata for a WSDL part
+ */
+ public class WSDLPart {
+ private Part part;
+
+ private XmlSchemaElement element;
+
+ private DataType dataType;
+
+ public WSDLPart(Part part, Class javaType) throws InvalidWSDLException {
+ this.part = part;
+ QName elementName = part.getElementName();
+ if (elementName != null) {
+ element = WSDLOperationIntrospectorImpl.this.getElement(elementName);
+ if (element == null) {
+ throw new InvalidWSDLException("Element cannot be resolved: " + elementName.toString());
+ }
+ } else {
+ // Create an faked XSD element to host the metadata
+ element = new XmlSchemaElement();
+ element.setName(part.getName());
+ element.setQName(new QName(null, part.getName()));
+ QName typeName = part.getTypeName();
+ if (typeName != null) {
+ XmlSchemaType type = WSDLOperationIntrospectorImpl.this.getType(typeName);
+ if (type == null) {
+ throw new InvalidWSDLException("Type cannot be resolved: " + typeName.toString());
+ }
+ element.setSchemaType(type);
+ element.setSchemaTypeName(type.getQName());
+ }
+ }
+ XMLType xmlType = new XMLType(getElementInfo(element));
+ xmlType.setNillable(element.isNillable());
+ xmlType.setMany(element.getMaxOccurs() > 1);
+ dataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+ }
+
+ /**
+ * @return the element
+ */
+ public XmlSchemaElement getElement() {
+ return element;
+ }
+
+ /**
+ * @return the part
+ */
+ public Part getPart() {
+ return part;
+ }
+
+ /**
+ * @return the dataType
+ */
+ public DataType<XMLType> getDataType() {
+ return dataType;
+ }
+ }
+
+ /**
+ * The "Wrapper Style" WSDL operation is defined by The Java API for
+ * XML-Based Web Services (JAX-WS) 2.0 specification, section 2.3.1.2
+ * Wrapper Style. <p/> A WSDL operation qualifies for wrapper style mapping
+ * only if the following criteria are met:
+ * <ul>
+ * <li>(i) The operation�s input and output messages (if present) each
+ * contain only a single part
+ * <li>(ii) The input message part refers to a global element declaration
+ * whose localname is equal to the operation name
+ * <li>(iii) The output message part refers to a global element declaration
+ * <li>(iv) The elements referred to by the input and output message parts
+ * (henceforth referred to as wrapper elements) are both complex types
+ * defined using the xsd:sequence compositor
+ * <li>(v) The wrapper elements only contain child elements, they must not
+ * contain other structures such as wildcards (element or attribute),
+ * xsd:choice, substitution groups (element references are not permitted) or
+ * attributes; furthermore, they must not be nillable.
+ * </ul>
+ */
+ public class Wrapper {
+ private XmlSchemaElement inputWrapperElement;
+
+ private XmlSchemaElement outputWrapperElement;
+
+ private List<XmlSchemaElement> inputElements;
+
+ private List<XmlSchemaElement> outputElements;
+
+ // private DataType<List<DataType<XMLType>>> unwrappedInputType;
+ //
+ // private DataType<XMLType> unwrappedOutputType;
+
+ private transient WrapperInfo wrapperInfo;
+
+ private List<XmlSchemaElement> getChildElements(XmlSchemaElement element) throws InvalidWSDLException {
+ if (element == null) {
+ return null;
+ }
+ if (element.isNillable()) {
+ // Wrapper element cannot be nillable
+ // return null;
+ }
+ XmlSchemaType type = element.getSchemaType();
+ if (type == null) {
+ String qName = element.getQName().toString();
+ throw new InvalidWSDLException("The XML schema element does not have a type: " + qName);
+ }
+ if (!(type instanceof XmlSchemaComplexType)) {
+ // Has to be a complexType
+ return null;
+ }
+ XmlSchemaComplexType complexType = (XmlSchemaComplexType)type;
+ if (complexType.getAttributes().getCount() != 0 || complexType.getAnyAttribute() != null) {
+ // No attributes
+ return null;
+ }
+ XmlSchemaParticle particle = complexType.getParticle();
+ if (particle == null) {
+ // No particle
+ return Collections.emptyList();
+ }
+ if (!(particle instanceof XmlSchemaSequence)) {
+ return null;
+ }
+ XmlSchemaSequence sequence = (XmlSchemaSequence)complexType.getParticle();
+ XmlSchemaObjectCollection items = sequence.getItems();
+ List<XmlSchemaElement> childElements = new ArrayList<XmlSchemaElement>();
+ for (int i = 0; i < items.getCount(); i++) {
+ XmlSchemaObject schemaObject = items.getItem(i);
+ if (!(schemaObject instanceof XmlSchemaElement)) {
+ // Should contain elements only
+ return null;
+ }
+ XmlSchemaElement childElement = (XmlSchemaElement)schemaObject;
+ /*
+ if (childElement.getSubstitutionGroup() != null) {
+ return null;
+ }
+ */
+ if (childElement.getName() == null || childElement.getRefName() != null) {
+ XmlSchemaElement ref = getElement(childElement.getRefName());
+ if (ref == null) {
+ throw new InvalidWSDLException("XML schema element ref cannot be resolved: " + childElement);
+ }
+ childElement = ref;
+ }
+ if (ANY.equals(childElement.getQName())) {
+ // Wildcard is not allowed
+ return null;
+ }
+ // TODO: Do we support maxOccurs >1 ?
+ if (childElement.getMaxOccurs() > 1) {
+ // TODO: [rfeng] To be implemented
+ /*
+ if(logger.isLoggable(Level.WARNING)) {
+ logger.warning("Support for elements with maxOccurs>1 is not implemented.");
+ }
+ */
+ // return null;
+ }
+ childElements.add(childElement);
+ }
+ return childElements;
+ }
+
+ /**
+ * Return a list of child XSD elements under the wrapped request element
+ *
+ * @return a list of child XSD elements or null if if the request
+ * element is not wrapped
+ */
+ public List<XmlSchemaElement> getInputChildElements() throws InvalidWSDLException {
+ if (inputElements != null) {
+ return inputElements;
+ }
+ Input input = operation.getInput();
+ if (input != null) {
+ Message inputMsg = input.getMessage();
+ Collection parts = inputMsg.getParts().values();
+ if (parts.size() != 1) {
+ return null;
+ }
+ Part part = (Part)parts.iterator().next();
+ QName elementName = part.getElementName();
+ if (elementName == null) {
+ return null;
+ }
+ if (!operation.getName().equals(elementName.getLocalPart())) {
+ return null;
+ }
+ inputWrapperElement = getElement(elementName);
+ if (inputWrapperElement == null) {
+ throw new InvalidWSDLException("The element is not declared in a XML schema: " + elementName
+ .toString());
+ }
+ if (inputWrapperElement.isNillable()) {
+ // The wrapper element cannot be nilable
+ // FIXME: Java2WSDL create nillable
+ // return null;
+ }
+ inputElements = getChildElements(inputWrapperElement);
+ return inputElements;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Return a list of child XSD elements under the wrapped response
+ * element
+ *
+ * @return a list of child XSD elements or null if if the response
+ * element is not wrapped
+ */
+ public List<XmlSchemaElement> getOutputChildElements() throws InvalidWSDLException {
+ if (outputElements != null) {
+ return outputElements;
+ }
+ Output output = operation.getOutput();
+ if (output != null) {
+ Message outputMsg = output.getMessage();
+ Collection parts = outputMsg.getParts().values();
+ if (parts.size() != 1) {
+ return null;
+ }
+ Part part = (Part)parts.iterator().next();
+ QName elementName = part.getElementName();
+ if (elementName == null) {
+ throw new InvalidWSDLException("The element is not declared in the XML schema: " + part.getName());
+ }
+ outputWrapperElement = WSDLOperationIntrospectorImpl.this.getElement(elementName);
+ if (outputWrapperElement == null) {
+ return null;
+ }
+ if (outputWrapperElement.isNillable()) {
+ // The wrapper element cannot be nilable
+ // return null;
+ }
+ outputElements = getChildElements(outputWrapperElement);
+ // FIXME: Do we support multiple child elements for the response?
+ return outputElements;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the inputWrapperElement
+ */
+ public XmlSchemaElement getInputWrapperElement() {
+ return inputWrapperElement;
+ }
+
+ /**
+ * @return the outputWrapperElement
+ */
+ public XmlSchemaElement getOutputWrapperElement() {
+ return outputWrapperElement;
+ }
+
+ /*
+ public DataType<List<DataType<XMLType>>> getUnwrappedInputType() throws InvalidWSDLException {
+ if (unwrappedInputType == null) {
+ List<DataType<XMLType>> childTypes = new ArrayList<DataType<XMLType>>();
+ for (XmlSchemaElement element : getInputChildElements()) {
+ DataType<XMLType> type =
+ new DataType<XMLType>(dataBinding, Object.class, new XMLType(getElementInfo(element)));
+ // type.setMetadata(ElementInfo.class.getName(), getElementInfo(element));
+ childTypes.add(type);
+ }
+ unwrappedInputType =
+ new DataType<List<DataType<XMLType>>>("idl:unwrapped.input", Object[].class, childTypes);
+ }
+ return unwrappedInputType;
+ }
+
+ public DataType<XMLType> getUnwrappedOutputType() throws InvalidServiceContractException {
+ if (unwrappedOutputType == null) {
+ List<XmlSchemaElement> elements = getOutputChildElements();
+ if (elements != null && elements.size() > 0) {
+ if (elements.size() > 1) {
+ // We don't support output with multiple parts
+ throw new NotSupportedWSDLException("Multi-part output is not supported");
+ }
+ XmlSchemaElement element = elements.get(0);
+ unwrappedOutputType =
+ new DataType<XMLType>(dataBinding, Object.class, new XMLType(getElementInfo(element)));
+ // unwrappedOutputType.setMetadata(ElementInfo.class.getName(), getElementInfo(element));
+ }
+ }
+ return unwrappedOutputType;
+ }
+ */
+
+ public WrapperInfo getWrapperInfo() throws InvalidWSDLException {
+ if (wrapperInfo == null) {
+ ElementInfo in = getElementInfo(getInputWrapperElement());
+ ElementInfo out = getElementInfo(getOutputWrapperElement());
+ List<ElementInfo> inChildren = new ArrayList<ElementInfo>();
+ if (in != null) {
+ for (XmlSchemaElement e : getInputChildElements()) {
+ inChildren.add(getElementInfo(e));
+ }
+ }
+ List<ElementInfo> outChildren = new ArrayList<ElementInfo>();
+ if (out != null) {
+ for (XmlSchemaElement e : getOutputChildElements()) {
+ outChildren.add(getElementInfo(e));
+ }
+ }
+ wrapperInfo = new WrapperInfo(dataBinding, in, out, inChildren, outChildren);
+ }
+ return wrapperInfo;
+ }
+ }
+
+ private static ElementInfo getElementInfo(XmlSchemaElement element) {
+ if (element == null) {
+ return null;
+ }
+ ElementInfo elementInfo = new ElementInfo(element.getQName(), getTypeInfo(element.getSchemaType()));
+ elementInfo.setMany(element.getMaxOccurs() > 1);
+ elementInfo.setNillable(element.isNillable());
+ return elementInfo;
+ }
+
+ private static TypeInfo getTypeInfo(XmlSchemaType type) {
+ if (type == null) {
+ return null;
+ }
+ XmlSchemaType baseType = (XmlSchemaType)type.getBaseSchemaType();
+ QName name = type.getQName();
+ boolean simple = (type instanceof XmlSchemaSimpleType);
+ if (baseType == null) {
+ return new TypeInfo(name, simple, null);
+ } else {
+ return new TypeInfo(name, simple, getTypeInfo(baseType));
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/package.html b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/package.html
new file mode 100644
index 0000000000..e929b86a80
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/package.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+The Service Component Architecture WSDL Interface extension.
+
+
+@tuscany.spi.extension
+
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java
new file mode 100644
index 0000000000..6007989321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.xml;
+
+import java.io.PrintWriter;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.ExtensionDeserializer;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.extensions.ExtensionSerializer;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.BPELPartnerLinkTypeExt;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A WSDL extension processor for extension elements introduced by BPEL - in particular
+ * the <partnerLinkType.../> elements
+ *
+ * Handles both BPEL 1.1 and BPEL 2.0 version of the <partnerLinkType/>
+ * @version $Rev$ $Date$
+ */
+public class BPELExtensionHandler implements ExtensionSerializer, ExtensionDeserializer {
+
+ private final String localName = "partnerLinkType";
+ private final String roleName = "role";
+
+ /**
+ * Marshals the BPEL partner link type extension element to XML
+ * See (@link javax.wsdl.extensions.ExtensionSerializer)
+ */
+ @SuppressWarnings("unchecked")
+ public void marshall(Class parentType, QName elementType, ExtensibilityElement theElement,
+ PrintWriter writer, Definition def, ExtensionRegistry extReg)
+ throws WSDLException {
+ // The format of the Partner Link Type in XML is as follows:
+ // <foo:partnerLinkType name="bar">
+ // <foo:role name="somename" portType="xyz:portTypeName"/>
+ // <foo:role name="othername" portType="xyz:portTypeName2"/>
+ // <foo:partnerLinkType>
+ BPELPartnerLinkTypeExt thePLinkType = (BPELPartnerLinkTypeExt) theElement;
+ QName theType = thePLinkType.getElementType();
+
+ writer.println("<" + theType.toString() +
+ " name=\"" + thePLinkType.getName() + "\">");
+ for( int i = 0; i < 2; i++ ) {
+ if( thePLinkType.getRoleName( i ) != null ) {
+ writer.println( "<" + theType.getPrefix() + ":role"
+ + " name=\"" + thePLinkType.getRoleName(i) + "\" portType=\""
+ + thePLinkType.getRolePortType(i) + "\">");
+ } // end if
+ } // end for
+ writer.println("</" + theType.toString() + ">");
+ } // end marshall
+
+ /**
+ * Unmarshals the BPEL partner link type element from XML
+ * See (@link javax.wsdl.extensions.ExtensionDeserializer)
+ * The format of the Partner Link Type in XML is as follows:
+ * <foo:partnerLinkType name="bar">
+ * <foo:role name="somename" portType="xyz:portTypeName"/>
+ * <foo:role name="othername" portType="xyz:portTypeName2"/>
+ * <foo:partnerLinkType>
+ *
+ * One role is mandatory, the second is optional.
+ */
+ @SuppressWarnings("unchecked")
+ public ExtensibilityElement unmarshall(Class theClass, QName elementType,
+ Element theElement, Definition def, ExtensionRegistry extReg)
+ throws WSDLException {
+
+ // Check that this elementType really is a partnerLinkType element
+ if( !elementType.getLocalPart().equals(localName) ) return null;
+ BPELPartnerLinkTypeExt theExtension = new BPELPartnerLinkTypeExt();
+ theExtension.setElementType(elementType);
+ theExtension.setName( theElement.getAttribute("name") );
+
+ // Fetch the child "role" elements
+ NodeList theRoles = theElement.getElementsByTagNameNS("*", roleName);
+ for ( int i=0; i < theRoles.getLength(); i++ ) {
+ if( i > 1 ) break;
+ Element roleNode = (Element)theRoles.item(i);
+ String roleName = roleNode.getAttribute("name");
+ String portType = roleNode.getAttribute("portType");
+ if (portType == null || portType.length() == 0) {
+ // Fetch the child "portType" element
+ NodeList portTypesNodes = roleNode.getElementsByTagNameNS("*", "portType");
+ for (int p = 0; p < portTypesNodes.getLength(); p++) {
+ Element portTypeNode = (Element)portTypesNodes.item(p);
+ portType = portTypeNode.getAttribute("name");
+ break;
+ }
+ }
+ // The PortType attribute is a QName in prefix:localName format - convert to a QName
+ QName rolePortType = getQNameValue( def, portType );
+ theExtension.setRole( i, roleName, rolePortType );
+ } // end for
+ return theExtension;
+ } // end unmarshall
+
+
+ /**
+ * Returns a QName from a string.
+ * @param definition - a WSDL Definition
+ * @param value - the String from which to form the QName in the form "pref:localName"
+ * @return
+ */
+ protected QName getQNameValue(Definition definition, String value) {
+ if (value != null && definition != null) {
+ int index = value.indexOf(':');
+ String prefix = index == -1 ? "" : value.substring(0, index);
+ String localName = index == -1 ? value : value.substring(index + 1);
+ String ns = definition.getNamespace(prefix);
+ if (ns == null) {
+ ns = "";
+ }
+ return new QName(ns, localName, prefix);
+ } else {
+ return null;
+ }
+ } // end getQNameValue
+
+} // end BPELExtensionHandler
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java
new file mode 100644
index 0000000000..ba9bff164c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.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.sca.interfacedef.wsdl.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Constants for WSDL.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WSDLConstants {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ String INTERFACE_WSDL = "interface.wsdl";
+ QName INTERFACE_WSDL_QNAME = new QName(SCA11_NS, "interface.wsdl");
+ String INTERFACE = "interface";
+ String CALLBACK_INTERFACE = "callbackInterface";
+ String REMOTABLE = "remotable";
+ String WSDL_LOCATION = "wsdlLocation";
+ String WSDLI_NS = "http://www.w3.org/2004/08/wsdl-instance";
+ QName WSDL_LOCATION_QNAME = new QName(WSDLI_NS, WSDL_LOCATION);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
new file mode 100644
index 0000000000..d2655bd88e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.xml;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper.Attribute;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+
+/**
+ * An ArtifactProcessor for WSDL documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLDocumentProcessor implements URLArtifactProcessor<WSDLDefinition> {
+
+ public static final QName WSDL11 = new QName("http://schemas.xmlsoap.org/wsdl/", "definitions");
+ public static final QName WSDL11_IMPORT = new QName("http://schemas.xmlsoap.org/wsdl/", "import");
+ public static final QName XSD = new QName("http://www.w3.org/2001/XMLSchema", "schema");
+
+ private XMLInputFactory inputFactory;
+ private StAXHelper helper;
+ private WSDLFactory factory;
+ private XSDFactory xsdFactory;
+
+
+ public WSDLDocumentProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.factory = modelFactories.getFactory(WSDLFactory.class);
+ this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
+ this.inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ this.helper = StAXHelper.getInstance(registry);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "interface-wsdlxml-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public WSDLDefinition read(URL contributionURL, URI artifactURI, URL artifactURL, ProcessorContext context) throws ContributionReadException {
+ try {
+ WSDLDefinition definition = indexRead(artifactURL);
+ definition.setURI(artifactURI);
+ return definition;
+ } catch (Exception e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(context.getMonitor(), "ContributionReadException", artifactURL, ce);
+ //throw ce;
+ return null;
+ }
+ }
+
+ public void resolve(WSDLDefinition model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ if (model == null) return;
+ Monitor monitor = context.getMonitor();
+ Definition definition = model.getDefinition();
+ if (definition != null) {
+ for (Object imports : definition.getImports().values()) {
+ List importList = (List)imports;
+ for (Object i : importList) {
+ Import imp = (Import)i;
+ if (imp.getDefinition() != null) {
+ continue;
+ }
+ if (imp.getLocationURI() == null) {
+ // FIXME: [rfeng] By the WSDL 1.1 Specification, the location attribute is required
+ // We need to resolve it by QName
+ WSDLDefinition proxy = factory.createWSDLDefinition();
+ proxy.setUnresolved(true);
+ proxy.setNamespace(imp.getNamespaceURI());
+ WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, proxy, context);
+ if (resolved != null && !resolved.isUnresolved()) {
+ imp.setDefinition(resolved.getDefinition());
+ if (!model.getImportedDefinitions().contains(resolved)) {
+ model.getImportedDefinitions().add(resolved);
+ }
+ }
+ } else {
+ String location = imp.getLocationURI();
+ if (location.indexOf(' ') != -1) {
+ location = location.replace(" ", "%20");
+ }
+ URI uri = URI.create(location);
+ if (uri.isAbsolute()) {
+ WSDLDefinition resolved;
+ try {
+ resolved = read(null, uri, uri.toURL(), context);
+ imp.setDefinition(resolved.getDefinition());
+ if (!model.getImportedDefinitions().contains(resolved)) {
+ model.getImportedDefinitions().add(resolved);
+ }
+ } catch (Exception e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(monitor, "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ } else {
+ if (location.startsWith("/")) {
+ // This is a relative URI against a contribution
+ location = location.substring(1);
+ // TODO: Need to resolve it against the contribution
+ } else {
+ // This is a relative URI against the WSDL document
+ URI baseURI = URI.create(model.getDefinition().getDocumentBaseURI());
+ URI locationURI = baseURI.resolve(location);
+ WSDLDefinition resolved;
+ try {
+ resolved = read(null, locationURI, locationURI.toURL(), context);
+ imp.setDefinition(resolved.getDefinition());
+ if (!model.getImportedDefinitions().contains(resolved)) {
+ model.getImportedDefinitions().add(resolved);
+ }
+ } catch (Exception e) {
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(monitor, "ContributionResolveException", resolver, ce);
+ //throw ce;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public String getArtifactType() {
+ return ".wsdl";
+ }
+
+ public Class<WSDLDefinition> getModelType() {
+ return WSDLDefinition.class;
+ }
+
+ /**
+ * Read the namespace for the WSDL definition and inline schemas
+ *
+ * @param doc
+ * @return
+ * @throws IOException
+ * @throws XMLStreamException
+ */
+ protected WSDLDefinition indexRead(URL doc) throws Exception {
+ WSDLDefinition wsdlDefinition = factory.createWSDLDefinition();
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition.setLocation(doc.toURI());
+
+ Attribute attr1 = new Attribute(WSDL11, "targetNamespace");
+ Attribute attr2 = new Attribute(XSD, "targetNamespace");
+ Attribute[] attrs = helper.readAttributes(doc, attr1, attr2);
+
+ wsdlDefinition.setNamespace(attr1.getValues().get(0));
+ // The definition is marked as resolved but not loaded
+ wsdlDefinition.setUnresolved(false);
+ wsdlDefinition.setDefinition(null);
+
+ int index = 0;
+ for (String tns : attr2.getValues()) {
+ XSDefinition xsd = xsdFactory.createXSDefinition();
+ xsd.setUnresolved(true);
+ xsd.setNamespace(tns);
+ xsd.setLocation(URI.create(doc.toURI() + "#" + index));
+ index++;
+ // The definition is marked as resolved but not loaded
+ xsd.setUnresolved(false);
+ xsd.setSchema(null);
+ wsdlDefinition.getXmlSchemas().add(xsd);
+ }
+
+ if (attr2.getValues().size() == 0){
+ // if there are no schema defined add in the XSD schema
+ // so this at least gets resolved otherwise we'll get
+ // errors when trying to resolve part types that
+ // use primitive types
+ XSDefinition xsd = xsdFactory.createXSDefinition();
+ xsd.setUnresolved(true);
+ xsd.setNamespace("http://www.w3.org/2001/XMLSchema");
+ xsd.setUnresolved(false);
+ xsd.setSchema(null);
+ wsdlDefinition.getXmlSchemas().add(xsd);
+ }
+
+ return wsdlDefinition;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
new file mode 100644
index 0000000000..3c550d9781
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
@@ -0,0 +1,494 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.net.URI;
+import java.util.List;
+
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLElement;
+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.PolicySubjectProcessor;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * Handles a <interface.wsdl ... /> element in a SCDL file
+ * @version $Rev$ $Date$
+ */
+public class WSDLInterfaceProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WSDLInterfaceContract>, WSDLConstants {
+
+ private WSDLFactory wsdlFactory;
+ private InterfaceContractMapper interfaceContractMapper;
+ private PolicyFactory policyFactory;
+ private PolicySubjectProcessor policyProcessor;
+
+ public WSDLInterfaceProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.interfaceContractMapper =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(InterfaceContractMapper.class);
+
+ this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ }
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "interface-wsdlxml-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "interface-wsdlxml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "interface-wsdlxml-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Create a WSDL interface from a URI.
+ * @param uri - the URI in the form nameSpace#wsdl.interface(porttypeName) or nameSpace#wsdl.porttype(porttypeName)
+ * @return a WSDLInterface object
+ * @throws ContributionReadException
+ */
+ private static String FRAGMENT_INTERFACE = "wsdl.interface";
+ private static String FRAGMENT_PORTTYPE = "wsdl.porttype";
+ private WSDLInterface createWSDLInterface(String uri, Monitor monitor) throws ContributionReadException {
+
+ WSDLInterface wsdlInterface = null;
+
+ // Read a QName in the form:
+ // namespace#wsdl.interface(name)
+ int index = uri.indexOf('#');
+ if (index == -1) {
+ error(monitor, "InvalidWSDLInterfaceAttr", wsdlFactory, uri);
+ //throw new ContributionReadException("Invalid WSDL interface attribute: " + uri);
+ } else {
+ // Read the URI and extract namespace and fragment
+ String namespace = uri.substring(0, index);
+ String name = uri.substring(index + 1);
+ String porttype = null;
+ if( name.contains(FRAGMENT_INTERFACE)) {
+ // Deal with the case where #wsdl.interface is used
+ porttype = name.substring("wsdl.interface(".length(), name.length() - 1);
+ } // end if
+ if( name.contains(FRAGMENT_PORTTYPE)) {
+ // Deal with the case where #wsdl.porttype is used
+ porttype = name.substring("wsdl.porttype(".length(), name.length() - 1);
+ } // end if
+ if( porttype == null ) {
+ error(monitor, "InvalidWSDLInterfaceAttr", wsdlFactory, uri);
+ return null;
+ } // end if
+ wsdlInterface = wsdlFactory.createWSDLInterface();
+ wsdlInterface.setUnresolved(true);
+ wsdlInterface.setName(new QName(namespace, porttype));
+ } // end if
+
+ return wsdlInterface;
+ } // end method createWSDLInterface
+
+ /**
+ * Creates a WSDLInterfaceContract from a <interface.wsdl/> element in a SCDL file
+ *
+ * The form of the <interface.wsdl/> element is as follows:
+ *
+ * <interface.wsdl interface="http://sampleNamespace#wsdl.interface(porttypeName)"
+ * callbackInterface="http://sampleNamespace#wsdl.porttype(callbackPorttypeName)"/>
+ * where interface = URI pointing to the WSDL document containing a WSDL interface or porttype for the forward call interface
+ * callbackInterface = URI pointing to the WSDL document containing a WSDL interface or porttype for the callback interface
+ *
+ * @param reader - XMLStreamReader holding the <interface.wsdl/> element
+ * @return - the WSDLInterfaceContract
+ */
+ public WSDLInterfaceContract read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ // Read an <interface.wsdl>
+ WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ Monitor monitor = context.getMonitor();
+
+ // Read wsdlLocation
+ String location = reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION);
+ wsdlInterfaceContract.setLocation(location);
+
+ String uri = getURIString(reader, INTERFACE);
+ if (uri != null) {
+ WSDLInterface wsdlInterface = createWSDLInterface(uri, monitor);
+ if (wsdlInterface != null)
+ wsdlInterfaceContract.setInterface(wsdlInterface);
+ }
+
+ uri = getURIString(reader, CALLBACK_INTERFACE);
+ if (uri != null) {
+ WSDLInterface wsdlCallbackInterface = createWSDLInterface(uri, monitor);
+ if (wsdlCallbackInterface != null)
+ wsdlInterfaceContract.setCallbackInterface(wsdlCallbackInterface);
+ }
+
+ String remotable = reader.getAttributeValue(null, REMOTABLE);
+ if (remotable != null &&
+ !remotable.equals("true")){
+ Monitor.error(monitor,
+ this,
+ "interface-wsdlxml-validation-messages",
+ "InvalidRemotableValue",
+ ((WSDLInterface)wsdlInterfaceContract.getInterface()).getName().toString(),
+ remotable);
+ }
+
+ // Read intents and policy sets
+ policyProcessor.readPolicies(wsdlInterfaceContract.getInterface(), reader);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && INTERFACE_WSDL_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+ return wsdlInterfaceContract;
+ }
+
+ public void write(WSDLInterfaceContract wsdlInterfaceContract, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // Write an <interface.wsdl>
+ writer.writeStartElement(WSDLConstants.SCA11_NS, INTERFACE_WSDL);
+
+ // Write interface name
+ WSDLInterface wsdlInterface = (WSDLInterface)wsdlInterfaceContract.getInterface();
+ if (wsdlInterface != null) {
+ QName qname = wsdlInterface.getName();
+ String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")";
+ writer.writeAttribute(INTERFACE, uri);
+ }
+
+ WSDLInterface wsdlCallbackInterface = (WSDLInterface)wsdlInterfaceContract.getCallbackInterface();
+ if (wsdlCallbackInterface != null) {
+ QName qname = wsdlCallbackInterface.getName();
+ String uri = qname.getNamespaceURI() + "#wsdl.interface(" + qname.getLocalPart() + ")";
+ writer.writeAttribute(CALLBACK_INTERFACE, uri);
+ }
+
+ // Write location
+ if (wsdlInterfaceContract.getLocation() != null) {
+ writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsdlInterfaceContract.getLocation());
+ }
+
+ policyProcessor.writePolicyAttributes(wsdlInterface, writer);
+
+ writer.writeEndElement();
+ }
+
+ private WSDLInterface resolveWSDLInterface(WSDLInterface wsdlInterface, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (wsdlInterface != null && wsdlInterface.isUnresolved()) {
+ Monitor monitor = context.getMonitor();
+ // Resolve the WSDL interface
+ wsdlInterface = resolver.resolveModel(WSDLInterface.class, wsdlInterface, context);
+ if (wsdlInterface.isUnresolved()) {
+
+ // If the WSDL interface has never been resolved yet, do it now
+ // First, resolve the WSDL definition for the given namespace
+ WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition.setNamespace(wsdlInterface.getName().getNamespaceURI());
+ wsdlDefinition.setNameOfPortTypeToResolve(wsdlInterface.getName());
+ WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition, context);
+ if (!resolved.isUnresolved()) {
+ wsdlDefinition.setDefinition(resolved.getDefinition());
+ wsdlDefinition.setLocation(resolved.getLocation());
+ wsdlDefinition.setURI(resolved.getURI());
+ wsdlDefinition.getImportedDefinitions().addAll(resolved.getImportedDefinitions());
+ wsdlDefinition.getXmlSchemas().addAll(resolved.getXmlSchemas());
+ wsdlDefinition.setUnresolved(false);
+ WSDLObject<PortType> portType = wsdlDefinition.getWSDLObject(PortType.class, wsdlInterface.getName());
+ if (portType != null) {
+ // Introspect the WSDL portType and add the resulting
+ // WSDLInterface to the resolver
+ try {
+ wsdlDefinition.setDefinition(portType.getDefinition());
+ WSDLInterface newWSDLInterface = wsdlFactory.createWSDLInterface(portType.getElement(), wsdlDefinition, resolver, monitor);
+ newWSDLInterface.setWsdlDefinition(wsdlDefinition);
+ newWSDLInterface.getRequiredIntents().addAll(wsdlInterface.getRequiredIntents());
+ newWSDLInterface.getPolicySets().addAll(wsdlInterface.getPolicySets());
+ resolver.addModel(newWSDLInterface, context);
+ wsdlInterface = newWSDLInterface;
+ } catch (InvalidInterfaceException e) {
+ ContributionResolveException ce = new ContributionResolveException("Invalid interface when resolving " +
+ portType.toString(), e);
+ error(monitor, "ContributionResolveException", wsdlFactory, ce);
+ //throw ce;
+ } // end try
+ }
+ else {
+ warning(monitor, "WsdlInterfaceDoesNotMatch", wsdlDefinition, wsdlInterface.getName());
+ } // end if
+ } else {
+ // If we get here, the WSDLDefinition is unresolved...
+ ContributionResolveException ce = new ContributionResolveException("WSDLDefinition unresolved " +
+ wsdlInterface.getName() );
+ error(monitor, "ContributionResolveException", wsdlFactory, ce);
+ } // end if
+ } // end if
+ } // end if
+ return wsdlInterface;
+ }
+
+ public static WSDLInterface resolveWSDLInterface( WSDLInterface wsdlInterface, ModelResolver resolver,
+ Monitor monitor, WSDLFactory wsdlFactory) {
+ if (wsdlInterface != null && wsdlInterface.isUnresolved()) {
+
+ ProcessorContext context = new ProcessorContext(monitor);
+ // Resolve the WSDL interface
+ wsdlInterface = resolver.resolveModel(WSDLInterface.class, wsdlInterface, context);
+ if (wsdlInterface.isUnresolved()) {
+
+ // If the WSDL interface has never been resolved yet, do it now
+ // First, resolve the WSDL definition for the given namespace
+ WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition.setNamespace(wsdlInterface.getName().getNamespaceURI());
+ WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition, context);
+ if (!resolved.isUnresolved()) {
+ wsdlDefinition.setDefinition(resolved.getDefinition());
+ wsdlDefinition.setLocation(resolved.getLocation());
+ wsdlDefinition.setURI(resolved.getURI());
+ wsdlDefinition.getImportedDefinitions().addAll(resolved.getImportedDefinitions());
+ wsdlDefinition.getXmlSchemas().addAll(resolved.getXmlSchemas());
+ wsdlDefinition.setUnresolved(false);
+ WSDLObject<PortType> portType = wsdlDefinition.getWSDLObject(PortType.class, wsdlInterface.getName());
+ if (portType != null) {
+ // Introspect the WSDL portType and add the resulting
+ // WSDLInterface to the resolver
+ try {
+ wsdlDefinition.setDefinition(portType.getDefinition());
+ wsdlInterface = wsdlFactory.createWSDLInterface(portType.getElement(), wsdlDefinition, resolver, monitor);
+ wsdlInterface.setWsdlDefinition(wsdlDefinition);
+ resolver.addModel(wsdlInterface, context);
+ } catch (InvalidInterfaceException e) {
+ ContributionResolveException ce = new ContributionResolveException("Invalid interface when resolving " +
+ portType.toString(), e);
+ Monitor.error(monitor, WSDLInterfaceProcessor.class.getName(),
+ "interface-wsdlxml-validation-messages", "ContributionResolveException",
+ wsdlFactory.getClass().getName(), ce.getMessage());
+ //throw ce;
+ } // end try
+ }
+ else {
+ Monitor.warning(monitor, WSDLInterfaceProcessor.class.getName(),
+ "interface-wsdlxml-validation-messages", "WsdlInterfaceDoesNotMatch",
+ wsdlDefinition.getNamespace(), wsdlInterface.getName().toString() );
+ } // end if
+ } else {
+ // If we get here, the WSDLDefinition is unresolved...
+ ContributionResolveException ce = new ContributionResolveException("WSDLDefinition unresolved " +
+ wsdlInterface.getName() );
+ Monitor.error(monitor, WSDLInterfaceProcessor.class.getName(),
+ "interface-wsdlxml-validation-messages", "ContributionResolveException",
+ wsdlFactory.getClass().getName(), ce.getMessage());
+ } // end if
+ } // end if
+ } // end if
+ return wsdlInterface;
+ } // end method resolveWSDLInterface
+
+ /**
+ * Resolve a WSDLInterfaceContract
+ */
+ public void resolve(WSDLInterfaceContract wsdlInterfaceContract, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ Monitor monitor = context.getMonitor();
+
+ WSDLInterface wsdlInterface = (WSDLInterface)wsdlInterfaceContract.getInterface();
+
+ // if the contract has a location but no WSDL definition yet we need to read the WSDL
+ // from the specified location and create an interface based on the first port type
+ // this is required if the user uses the @WebService(wsdlLocation="") or
+ // @WebServiceProvider(wsdlLocation="") annotation in a Java component implementation.
+ if (wsdlInterfaceContract.getLocation() != null &&
+ wsdlInterface.getWsdlDefinition() == null){
+
+ WSDLDefinition wsdlDefinition = null;
+
+ URI wsdlFileURI = null;
+
+ try {
+ wsdlFileURI = new URI(wsdlInterfaceContract.getLocation());
+ } catch (Exception ex) {
+ Monitor.error(context.getMonitor(),
+ WSDLInterfaceProcessor.class.getName(),
+ "interface-wsdlxml-validation-messages",
+ "wsdliLocationException",
+ ex.getMessage() );
+ return;
+ }
+
+ // We need to find a portType from the user specified WSDL (the first one?) from which to defined
+ // the service interface. We can't just use the Tuscany resolution mechanism to find the WSDL file
+ // as that lumps together all WSDL in the same namespace. That's fine if you already know what portType
+ // your after. In this case we don't so we have to get the WSDL specified, find out what it's first portType
+ // is and then go from there with the usual Tuscany resolution mechanism
+ try {
+ if (wsdlFileURI.isAbsolute()){
+ // use the wsdli:wsdlLocation mechanism in the WSDLModelResolver to
+ // load the WSDL from an absolute location
+ wsdlDefinition = wsdlFactory.createWSDLDefinition();
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition.setNamespace("nonamespace");
+ wsdlDefinition.getWsdliLocations().put("nonamespace", wsdlInterfaceContract.getLocation());
+ wsdlDefinition.setLocation(new URI(wsdlInterfaceContract.getLocation()));
+ } else {
+ // Find the wsdl in the contribution ready for further resolution
+ for (Artifact artifact : context.getContribution().getArtifacts()) {
+ if (artifact.getLocation().endsWith(wsdlInterfaceContract.getLocation())){
+ WSDLDefinition artifactWSDLDefinition = artifact.getModel();
+ wsdlDefinition = wsdlFactory.createWSDLDefinition();
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition.setNamespace(artifactWSDLDefinition.getNamespace());
+ wsdlDefinition.getWsdliLocations().put(artifactWSDLDefinition.getNamespace(),
+ artifact.getLocation());
+ wsdlDefinition.setLocation(new URI(artifact.getLocation()));
+ break;
+ }
+ }
+
+ if (wsdlDefinition == null){
+ Monitor.error(context.getMonitor(),
+ WSDLInterfaceProcessor.class.getName(),
+ "interface-wsdlxml-validation-messages",
+ "wsdliLocationException",
+ "WSDL not found inside contribution at relative URI " + wsdlFileURI );
+ return;
+ }
+ }
+ } catch (Exception ex) {
+ Monitor.error(context.getMonitor(),
+ WSDLInterfaceProcessor.class.getName(),
+ "interface-wsdlxml-validation-messages",
+ "wsdliLocationException",
+ ex.getMessage() );
+ return;
+ }
+
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition, context);
+ // create the interface based on the first port type
+ PortType portType = (PortType)wsdlDefinition.getDefinition().getAllPortTypes().values().iterator().next();
+ try {
+ WSDLInterface newWSDLInterface = wsdlFactory.createWSDLInterface(portType, wsdlDefinition, resolver, monitor);
+ newWSDLInterface.getRequiredIntents().addAll(wsdlInterface.getRequiredIntents());
+ newWSDLInterface.getPolicySets().addAll(wsdlInterface.getPolicySets());
+ wsdlInterface = newWSDLInterface;
+ } catch (InvalidInterfaceException e) {
+ ContributionResolveException ce = new ContributionResolveException("Invalid interface when resolving " +
+ portType.toString(), e);
+ error(monitor, "ContributionResolveException", wsdlFactory, ce);
+ }
+
+ wsdlInterface.setWsdlDefinition(wsdlDefinition);
+ wsdlInterfaceContract.setInterface(wsdlInterface);
+ }
+
+ // Resolve the interface and callback interface
+ wsdlInterface = resolveWSDLInterface(wsdlInterface, resolver, context);
+ wsdlInterfaceContract.setInterface(wsdlInterface);
+
+ // The forward interface (portType) may have a callback interface declared on it using an sca:callback attribute
+ WSDLInterface intrinsicWSDLCallbackInterface = wsdlInterface.getCallbackInterface();
+
+ // There may be a callback interface explicitly declared on the <interface.wsdl .../> element
+ WSDLInterface wsdlCallbackInterface = resolveWSDLInterface((WSDLInterface)wsdlInterfaceContract.getCallbackInterface(), resolver, context);
+ if( intrinsicWSDLCallbackInterface != null ) {
+ if( wsdlCallbackInterface != null ) {
+ // If there is both a callback interface declared on the forward interface and also one declared on the
+ // interface.wsdl element, then the two interfaces must match [ASM80011]
+ if( !interfaceContractMapper.isMutuallyCompatible(intrinsicWSDLCallbackInterface, wsdlCallbackInterface) ) {
+ Monitor.error(context.getMonitor(), WSDLInterfaceProcessor.class.getName(),
+ "interface-wsdlxml-validation-messages", "IncompatibleCallbacks",
+ intrinsicWSDLCallbackInterface.getName().toString(),
+ wsdlCallbackInterface.getName().toString() );
+ } // end if
+ } // end if
+ wsdlInterfaceContract.setCallbackInterface(intrinsicWSDLCallbackInterface);
+ } else {
+ wsdlInterfaceContract.setCallbackInterface(wsdlCallbackInterface);
+ } // end if
+ } // end method resolve( WSDLInterfaceContract, ModelResolver)
+
+ public QName getArtifactType() {
+ return WSDLConstants.INTERFACE_WSDL_QNAME;
+ }
+
+ public Class<WSDLInterfaceContract> getModelType() {
+ return WSDLInterfaceContract.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
new file mode 100644
index 0000000000..6afa43b905
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
@@ -0,0 +1,675 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.AttributeExtensible;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.ExtensionDeserializer;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.extensions.ExtensionSerializer;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.UnknownExtensionDeserializer;
+import javax.wsdl.extensions.UnknownExtensionSerializer;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.xml.WSDLLocator;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.common.xml.XMLDocumentHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.DefaultImport;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionRuntimeException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLDefinitionImpl;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.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;
+import org.xml.sax.InputSource;
+
+/**
+ * A Model Resolver for WSDL models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLModelResolver implements ModelResolver {
+ //Schema element names
+ public static final String ELEM_SCHEMA = "schema";
+ public static final QName WSDL11_IMPORT = new QName("http://schemas.xmlsoap.org/wsdl/", "import");
+
+ //Schema URI
+ public static final String NS_URI_XSD_1999 = "http://www.w3.org/1999/XMLSchema";
+ public static final String NS_URI_XSD_2000 = "http://www.w3.org/2000/10/XMLSchema";
+ public static final String NS_URI_XSD_2001 = "http://www.w3.org/2001/XMLSchema";
+
+ //Schema QNames
+ public static final QName Q_ELEM_XSD_1999 = new QName(NS_URI_XSD_1999, ELEM_SCHEMA);
+ public static final QName Q_ELEM_XSD_2000 = new QName(NS_URI_XSD_2000, ELEM_SCHEMA);
+ public static final QName Q_ELEM_XSD_2001 = new QName(NS_URI_XSD_2001, ELEM_SCHEMA);
+ public static final List<QName> XSD_QNAME_LIST =
+ Arrays.asList(new QName[] {Q_ELEM_XSD_1999, Q_ELEM_XSD_2000, Q_ELEM_XSD_2001});
+
+ // ---- SCA Policy WSDL Attachments
+ public static final QName Q_POLICY_ATTRIBUTE_EXTENSION = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "requires");
+ public static final QName Q_POLICY_END_CONVERSATION_ATTRIBUTE_EXTENSION = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "endsConversation");
+ // ---- SCA Callback WSDL Extension
+ public static final QName Q_CALLBACK_ATTRIBUTE_EXTENSION = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200912", "callback" );
+
+ // ---- BPEL extension elements --- Mike Edwards 01/05/2008
+ public static final String ELEM_PLINKTYPE = "partnerLinkType";
+ public static final String NS_BPEL_1_1 = "http://schemas.xmlsoap.org/ws/2004/03/partner-link/";
+ public static final QName BPEL_PLINKTYPE = new QName( NS_BPEL_1_1, ELEM_PLINKTYPE );
+ public static final String NS_BPEL_2_0 = "http://docs.oasis-open.org/wsbpel/2.0/plnktype";
+ public static final QName BPEL_PLINKTYPE_2_0 = new QName( NS_BPEL_2_0, ELEM_PLINKTYPE );
+ // ---- end of BPEL extension elements
+
+ private Contribution contribution;
+ private Map<String, List<WSDLDefinition>> map = new HashMap<String, List<WSDLDefinition>>();
+
+ private ExtensionRegistry wsdlExtensionRegistry;
+
+ private WSDLFactory wsdlFactory;
+ private javax.wsdl.factory.WSDLFactory wsdl4jFactory;
+ private ContributionFactory contributionFactory;
+ private XSDFactory xsdFactory;
+
+ public WSDLModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+
+ this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ this.wsdl4jFactory = modelFactories.getFactory(javax.wsdl.factory.WSDLFactory.class);
+ this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
+
+ wsdlExtensionRegistry = this.wsdl4jFactory.newPopulatedExtensionRegistry();
+ // REVIEW: [rfeng] Disable the schema extension for WSDL4J to avoid aggressive loading
+ ExtensionDeserializer deserializer = new UnknownExtensionDeserializer();
+ ExtensionSerializer serializer = new UnknownExtensionSerializer();
+ for (QName schema : XSD_QNAME_LIST) {
+ wsdlExtensionRegistry.registerSerializer(Types.class, schema, serializer);
+ wsdlExtensionRegistry.registerDeserializer(Types.class, schema, deserializer);
+ }
+ // ---- Policy WSDL Extensions
+ try {
+ wsdlExtensionRegistry.registerExtensionAttributeType(PortType.class, Q_POLICY_ATTRIBUTE_EXTENSION, AttributeExtensible.LIST_OF_QNAMES_TYPE);
+ wsdlExtensionRegistry.registerExtensionAttributeType(Operation.class, Q_POLICY_END_CONVERSATION_ATTRIBUTE_EXTENSION, AttributeExtensible.STRING_TYPE);
+ wsdlExtensionRegistry.registerExtensionAttributeType(PortType.class, Q_CALLBACK_ATTRIBUTE_EXTENSION, AttributeExtensible.QNAME_TYPE);
+ } catch (NoSuchMethodError e) {
+ // That method does not exist on older WSDL4J levels
+ }
+
+ // ---- BPEL additions
+ serializer = new BPELExtensionHandler();
+ deserializer = new BPELExtensionHandler();
+ wsdlExtensionRegistry.registerSerializer(Definition.class, BPEL_PLINKTYPE, serializer);
+ wsdlExtensionRegistry.registerDeserializer(Definition.class, BPEL_PLINKTYPE, deserializer);
+ wsdlExtensionRegistry.registerSerializer(Definition.class, BPEL_PLINKTYPE_2_0, serializer);
+ wsdlExtensionRegistry.registerDeserializer(Definition.class, BPEL_PLINKTYPE_2_0, deserializer);
+ // ---- end of BPEL additions
+ }
+
+ /**
+ * Implementation of a WSDL locator.
+ */
+ private class WSDLLocatorImpl implements WSDLLocator {
+ private ProcessorContext context;
+ private InputStream inputStream;
+ private URL base;
+ private String latestImportURI;
+ private Map<String, String> wsdlImports;
+
+ public WSDLLocatorImpl(ProcessorContext context, URL base, InputStream is, Map<String, String> imports) {
+ this.context = context;
+ this.base = base;
+ this.inputStream = is;
+ this.wsdlImports = imports;
+ }
+
+ public void close() {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+
+ public InputSource getBaseInputSource() {
+ try {
+ return XMLDocumentHelper.getInputSource(base, inputStream);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public String getBaseURI() {
+ return base.toString();
+ }
+
+ public InputSource getImportInputSource(String parentLocation, String importLocation) {
+ try {
+ if (importLocation == null) {
+ throw new IllegalArgumentException("Required attribute 'location' is missing.");
+ }
+ if (importLocation.trim().equals(""))
+ throw new IllegalArgumentException("Required attribute 'location' is empty.");
+
+ URL url = null;
+ if (importLocation.startsWith("/")) {
+ // The URI is relative to the contribution
+ String uri = importLocation.substring(1);
+
+ Artifact proxyArtifact = contributionFactory.createArtifact();
+ proxyArtifact.setURI(uri);
+
+ //use contribution resolution (this supports import/export)
+ Artifact importedArtifact =
+ contribution.getModelResolver().resolveModel(Artifact.class, proxyArtifact, context);
+ if (importedArtifact.getLocation() != null) {
+ //get the artifact URL
+ url = new URL(importedArtifact.getLocation());
+ }
+ } else {
+ url = new URL(new URL(parentLocation), importLocation);
+ }
+ if (url == null) {
+ return null;
+ }
+ latestImportURI = url.toString();
+ return XMLDocumentHelper.getInputSource(url);
+ } catch (IOException e) {
+ // If we are not able to resolve the imports using location, then
+ // try resolving them using the namespace.
+ try {
+ if (! wsdlImports.isEmpty()) {
+ for (Artifact artifact : contribution.getArtifacts()) {
+ if (artifact.getModel() instanceof WSDLDefinitionImpl) {
+ String namespace = ((WSDLDefinitionImpl)artifact.getModel()).getNamespace();
+ for (Map.Entry<String, String> entry : ((Map<String, String>)wsdlImports).entrySet()) {
+ if (entry.getKey().equals(namespace)) {
+ URL url = ((WSDLDefinitionImpl)artifact.getModel()).getLocation().toURL();
+ return XMLDocumentHelper.getInputSource(url);
+ }
+ }
+ }
+ }
+ }
+ } catch (IOException ex) {
+ throw new ContributionRuntimeException(ex);
+ }
+ throw new ContributionRuntimeException(e);
+ }
+ }
+
+ public String getLatestImportURI() {
+ return latestImportURI;
+ }
+
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ WSDLDefinition definition = (WSDLDefinition)resolved;
+ for (XSDefinition d : definition.getXmlSchemas()) {
+ if (contribution != null) {
+ contribution.getModelResolver().addModel(d, context);
+ }
+ }
+ List<WSDLDefinition> list = map.get(definition.getNamespace());
+ if (list == null) {
+ list = new ArrayList<WSDLDefinition>();
+ map.put(definition.getNamespace(), list);
+ }
+ list.add(definition);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ WSDLDefinition definition = (WSDLDefinition)resolved;
+ List<WSDLDefinition> list = map.get(definition.getNamespace());
+ if (list == null) {
+ return null;
+ } else {
+ return list.remove(definition);
+ }
+ }
+
+ /**
+ * Create a facade Definition which imports all the definitions
+ *
+ * @param definitions A list of the WSDL definitions under the same target namespace
+ * @param context
+ * @return The aggregated WSDL definition
+ */
+ @SuppressWarnings("unchecked")
+ private WSDLDefinition aggregate(List<WSDLDefinition> definitions, ProcessorContext context) throws ContributionReadException {
+ if (definitions == null || definitions.size() == 0) {
+ return null;
+ }
+ if (definitions.size() == 1) {
+ WSDLDefinition d = definitions.get(0);
+ loadDefinition(d, context);
+ return d;
+ }
+ WSDLDefinition aggregated = wsdlFactory.createWSDLDefinition();
+ for (WSDLDefinition d : definitions) {
+ loadDefinition(d, context);
+ }
+ Definition facade = wsdl4jFactory.newDefinition();
+ String ns = definitions.get(0).getNamespace();
+ facade.setQName(new QName(ns, "$aggregated$"));
+ facade.setTargetNamespace(ns);
+
+ for (WSDLDefinition d : definitions) {
+ if (d.getDefinition() != null) {
+ javax.wsdl.Import imp = facade.createImport();
+ imp.setNamespaceURI(d.getNamespace());
+ imp.setDefinition(d.getDefinition());
+ imp.setLocationURI(d.getDefinition().getDocumentBaseURI());
+ facade.addImport(imp);
+ aggregated.getXmlSchemas().addAll(d.getXmlSchemas());
+ aggregated.getImportedDefinitions().add(d);
+ // Deal with extensibility elements in the imported Definitions...
+ List<ExtensibilityElement> extElements = (List<ExtensibilityElement>) d.getDefinition().getExtensibilityElements();
+ for( ExtensibilityElement extElement : extElements ) {
+ facade.addExtensibilityElement(extElement);
+ } // end for
+ }
+ }
+ aggregated.setDefinition(facade);
+ definitions.clear();
+ definitions.add(aggregated);
+ return aggregated;
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+
+ WSDLDefinition resolved = null;
+ String namespace = ((WSDLDefinition)unresolved).getNamespace();
+ if (namespace == null) {
+ return modelClass.cast(unresolved);
+ }
+
+ // Lookup based on wsdli:location
+ if (((WSDLDefinition)unresolved).getWsdliLocations().containsKey(namespace)) {
+ try {
+ loadDefinition(((WSDLDefinition)unresolved), context);
+ } catch (ContributionReadException e) {
+ context.getMonitor().error(context.getMonitor(), this, "interface-wsdlxml-validation-messages", "wsdliLocationException", e, ((WSDLDefinition)unresolved).getNamespace());
+ }
+ return modelClass.cast((WSDLDefinition)unresolved);
+ }
+
+
+ // Lookup a definition for the given namespace, from imports
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof NamespaceImport) {
+ NamespaceImport namespaceImport = (NamespaceImport)import_;
+ if (namespaceImport.getNamespace().equals(namespace)) {
+ // Delegate the resolution to the namespace import resolver
+ resolved =
+ namespaceImport.getModelResolver().resolveModel(WSDLDefinition.class,
+ (WSDLDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ } else if (import_ instanceof DefaultImport) {
+ // Delegate the resolution to the default import resolver
+ resolved =
+ import_.getModelResolver().resolveModel(WSDLDefinition.class,
+ (WSDLDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+
+
+ // Not found, lookup a definition for the given namespace, within contribution
+ List<WSDLDefinition> list = map.get(namespace);
+ try {
+ resolved = aggregate(list, context);
+ } catch (ContributionReadException e) {
+ throw new RuntimeException(e);
+ }
+ if (resolved != null && !resolved.isUnresolved()) {
+ // check that the WSDL we just found has the requisite
+ // port type, binding and/or service. If not return
+ // the input WSDL to force the resolution process to continue
+ WSDLDefinition inputWSDL = (WSDLDefinition)unresolved;
+ WSDLDefinition outputWSDL = (WSDLDefinition)resolved;
+
+ if (inputWSDL.getNameOfPortTypeToResolve() != null){
+ if (outputWSDL.getWSDLObject(PortType.class, inputWSDL.getNameOfPortTypeToResolve()) == null){
+ return modelClass.cast(unresolved);
+ }
+ }
+
+ if (inputWSDL.getNameOfBindingToResolve() != null){
+ if (outputWSDL.getWSDLObject(Binding.class, inputWSDL.getNameOfBindingToResolve()) == null){
+ return modelClass.cast(unresolved);
+ }
+ }
+
+ if (inputWSDL.getNameOfServiceToResolve() != null){
+ if (outputWSDL.getWSDLObject(Service.class, inputWSDL.getNameOfServiceToResolve()) == null){
+ return modelClass.cast(unresolved);
+ }
+ }
+
+ return modelClass.cast(resolved);
+ }
+
+ return modelClass.cast(unresolved);
+ }
+
+ /**
+ * Use non-sca mechanism to resolve the import location,
+ * if not found then use the sca mechanism
+ *
+ * @param modelClass
+ * @param unresolved
+ * @param context
+ * @throws ContributionReadException
+ */
+ private <T> T resolveImports (Class<T> modelClass, WSDLDefinition unresolved, ProcessorContext context) throws ContributionReadException {
+
+ WSDLDefinition resolved = null;
+ if (unresolved.getDefinition() == null && unresolved.getLocation() != null) {
+ try {
+ // Load the definition using non-sca mechanism.
+ List<WSDLDefinition> list = new ArrayList<WSDLDefinition>();
+ list.add(unresolved);
+ map.put(unresolved.getNamespace(), list);
+ resolved = aggregate(list, context);
+ // if no exception then its resolved.
+ if (unresolved.getNamespace().equals(resolved.getDefinition().getTargetNamespace())) {
+ resolved.setNamespace(resolved.getDefinition().getTargetNamespace());
+ resolved.setUnresolved(false);
+ resolved.setURI(resolved.getLocation());
+ return modelClass.cast(resolved);
+ }
+ } catch (ContributionReadException e) {
+ // Resolve the wsdl definition using the namespace, by searching the
+ // contribution artifacts for wsdl definition for the given namespace.
+ for (Artifact artifact : contribution.getArtifacts()) {
+ if (artifact.getModel() instanceof WSDLDefinitionImpl) {
+ String namespace = ((WSDLDefinitionImpl)artifact.getModel()).getNamespace();
+ if (unresolved.getNamespace().equals(namespace)) {
+ WSDLDefinition wsdlDefinition = (WSDLDefinition)artifact.getModel();
+ if (wsdlDefinition.getDefinition() == null) {
+ loadDefinition(wsdlDefinition, context);
+ }
+ return modelClass.cast(wsdlDefinition);
+ }
+ }
+ }
+ }
+ }
+
+ return modelClass.cast(unresolved);
+ }
+
+
+ /**
+ * Load the WSDL definition and inline schemas
+ *
+ * @param wsdlDef
+ * @param context
+ * @throws ContributionReadException
+ */
+ private void loadDefinition(WSDLDefinition wsdlDef, ProcessorContext context) throws ContributionReadException {
+ if (wsdlDef.getDefinition() != null) {
+ return;
+ }
+ try {
+ URL artifactURL;
+ String loc = wsdlDef.getWsdliLocations().get(wsdlDef.getNamespace());
+ if (loc != null) {
+ artifactURL = new URL(loc);
+ } else {
+ if (wsdlDef.getLocation() == null) {
+ return;
+ }
+ artifactURL = wsdlDef.getLocation().toURL();
+ }
+ // Read a WSDL document
+ InputStream is = IOHelper.openStream(artifactURL);
+ WSDLReader reader = wsdl4jFactory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ reader.setFeature("javax.wsdl.importDocuments", true);
+ // FIXME: We need to decide if we should disable the import processing by WSDL4J
+ // reader.setFeature("javax.wsdl.importDocuments", false);
+ reader.setExtensionRegistry(wsdlExtensionRegistry); // use a custom registry
+
+ // Collection of namespace,location for wsdl:import definition
+ Map<String, String> wsdlImports = indexRead(wsdlDef.getLocation().toURL());
+ wsdlImports.putAll(wsdlDef.getWsdliLocations());
+ WSDLLocatorImpl locator = new WSDLLocatorImpl(context, artifactURL, is, wsdlImports);
+ Definition definition = reader.readWSDL(locator);
+ wsdlDef.setDefinition(definition);
+
+ // If this definition imports any definitions from other namespaces,
+ // set the correct WSDLDefinition import relationships.
+ for (Map.Entry<String, List<javax.wsdl.Import>> entry :
+ ((Map<String, List<javax.wsdl.Import>>)definition.getImports()).entrySet()) {
+ if (!entry.getKey().equals(definition.getTargetNamespace())) {
+ WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition.setNamespace(entry.getKey());
+ WSDLDefinition resolved = null;
+ for (javax.wsdl.Import imp : entry.getValue()) {
+ if (imp.getDefinition() == null)
+ throw new IllegalArgumentException("Required attribute 'location' is missing.");
+
+ try {
+ wsdlDefinition.setLocation(new URI(imp.getDefinition().getDocumentBaseURI()));
+ resolved = resolveImports(WSDLDefinition.class, wsdlDefinition, context);
+ if (!resolved.isUnresolved()) {
+ if (resolved.getImportedDefinitions().isEmpty()) {
+ if (resolved.getDefinition().getTargetNamespace().equals(imp.getDefinition().getTargetNamespace())) {
+ // this WSDLDefinition contains the imported document
+ wsdlDef.getImportedDefinitions().add(resolved);
+ imp.setLocationURI(resolved.getURI().toString());
+ }
+ } else {
+ // this is a facade, so look in its imported definitions
+ for (WSDLDefinition def : resolved.getImportedDefinitions()) {
+ if (def.getDefinition().getTargetNamespace().equals(imp.getDefinition().getTargetNamespace())) {
+ wsdlDef.getImportedDefinitions().add(def);
+ imp.setLocationURI(def.getURI().toString());
+ break;
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new ContributionReadException(e);
+ }
+ }
+ }
+ }
+ //Read inline schemas
+ readInlineSchemas(wsdlDef, definition, context);
+ } catch (WSDLException e) {
+ throw new ContributionReadException(e);
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ } catch (IOException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ 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();
+ if (nodeMap != null) {
+ 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;
+ }
+
+ /**
+ * Populate the inline schemas including those from the imported definitions
+ *
+ * @param definition
+ * @param context
+ * @param schemaCollection
+ */
+ private void readInlineSchemas(WSDLDefinition wsdlDefinition, Definition definition, ProcessorContext context) {
+ 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 = xsdFactory.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, context);
+ if (resolved != null && !resolved.isUnresolved()) {
+ if (!wsdlDefinition.getXmlSchemas().contains(resolved)) {
+ // Don't add resolved because it may be an aggregate that
+ // contains more than we need. The resolver will have
+ // set the specific schema we need into unresolved.
+ 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(), context);
+ }
+ }
+ }
+ }
+
+ /**
+ * Read the namespace and location for the WSDL imports
+ *
+ * @param doc
+ * @return
+ * @throws IOException
+ * @throws XMLStreamException
+ */
+ protected Map<String, String> indexRead(URL doc) throws IOException, XMLStreamException {
+
+ Map<String, String> wsdlImports = new HashMap<String, String>();
+ InputStream is = doc.openStream();
+ try {
+ // Set up a StreamSource for the composite file, since this has an associated URL that
+ // can be used by the parser to find references to other files such as DTDs
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ StreamSource wsdlSource = new StreamSource(is, doc.toString());
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(wsdlSource);
+
+ int eventType = reader.getEventType();
+ while (true) {
+ if (eventType == XMLStreamConstants.START_ELEMENT) {
+ if (WSDL11_IMPORT.equals(reader.getName())) {
+ String ns = reader.getAttributeValue(null, "namespace");
+ String loc = reader.getAttributeValue(null, "location");
+ wsdlImports.put(ns, loc);
+ }
+ }
+ if (reader.hasNext()) {
+ eventType = reader.next();
+ } else {
+ break;
+ }
+ }
+ return wsdlImports;
+ } finally {
+ is.close();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..68da288a8c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLInterfaceProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#interface.wsdl,model=org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..c3c5638776
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor;type=.wsdl,model=org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..d37b50227e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -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.
+
+org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver;model=org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory
new file mode 100644
index 0000000000..4f61700af7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory
@@ -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.wsdl.DefaultWSDLFactory
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties
new file mode 100644
index 0000000000..101d9de60c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties
@@ -0,0 +1,27 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+ContributionReadException = ContributionReadException occured due to : {0}
+ContributionResolveException = ContributionResolveException occured due to : {0}
+InvalidWSDLInterfaceAttr = Invalid WSDL interface attribute: {0}
+WsdlInterfaceDoesNotMatch = The WSDL referenced by the interface.wsdl interface as ({0}) cannot be found in this contribution or in any imports that this contribution makes
+InvalidRemotableValue = The interface.wsdl interface {0} element can only have a remotable attribute with the value "true" as WSDL interface are assumed to be remotable by default. The value that was found is: {1}.
+IncompatibleCallbacks = The interface.wsdl element has a forward interface with a callback declared in the WSDL {0} and a callback interface also declared using the callbackInterface attribute {1} but the callback interfaces are not equal.
+wsdliLocationException = Exception locating wsdli:location resource: {0} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java
new file mode 100644
index 0000000000..1e66f7c4e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.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.sca.interfacedef.wsdl.introspect;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.AbstractWSDLTestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test case for InterfaceWSDLIntrospectorImpl.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLInterfaceIntrospectorTestCase extends AbstractWSDLTestCase {
+ private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+ private PortType portType;
+ private WSDLDefinition definition;
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ URL url = getClass().getResource("../xml/stockquote.wsdl");
+ ProcessorContext context = new ProcessorContext();
+ definition = (WSDLDefinition)documentProcessor.read(null, new URI("stockquote.wsdl"), url, context);
+ resolver.addModel(definition, context);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition, context);
+ portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public final void testIntrospectPortType() throws InvalidInterfaceException {
+ WSDLInterface contract = wsdlFactory.createWSDLInterface(portType, definition, resolver, null);
+ Assert.assertEquals(contract.getName().getLocalPart(), "StockQuotePortType");
+ List<Operation> operations = contract.getOperations();
+ Assert.assertEquals(1, operations.size());
+ Operation operation = operations.get(0);
+ Assert.assertEquals("getLastTradePrice", operation.getName());
+ DataType<List<DataType>> inputType = operation.getInputType();
+ Assert.assertEquals(1, inputType.getLogical().size());
+ DataType<XMLType> returnType = operation.getOutputType();
+ Assert.assertNotNull(returnType);
+ Assert.assertEquals(0, operation.getFaultTypes().size());
+ // Assert.assertEquals(1,
+ // operation.getWrapper().getInputChildElements().size());
+ // Assert.assertEquals(1,
+ // operation.getWrapper().getOutputChildElements().size());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
new file mode 100644
index 0000000000..c4549f8180
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.introspect;
+
+import static org.junit.Assert.fail;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.AbstractWSDLTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test case for WSDLOperation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLOperationIntrospectorTestCase extends AbstractWSDLTestCase {
+ private static final QName PORTTYPE_NAME =
+ new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public final void testWrappedOperation() throws Exception {
+ URL url = getClass().getResource("../xml/stockquote.wsdl");
+ ProcessorContext context = new ProcessorContext();
+ WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("stockquote.wsdl"), url, context);
+ resolver.addModel(definition, context);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition, context);
+ PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+
+ WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor());
+ WSDLOperation op = (WSDLOperation) wi.getOperations().get(0);
+
+ DataType<List<DataType>> inputType = op.getInputType();
+ Assert.assertEquals(1, inputType.getLogical().size());
+ DataType<XMLType> type = inputType.getLogical().get(0);
+ Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePrice"), type.getLogical().getElementName());
+
+ DataType<XMLType> outputType = op.getOutputType();
+ Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePriceResponse"),
+ outputType.getLogical().getElementName());
+ Assert.assertTrue(op.isWrapperStyle());
+
+ DataType<List<DataType>> unwrappedInputType = op.getWrapper().getUnwrappedInputType();
+ List<DataType> childTypes = unwrappedInputType.getLogical();
+ Assert.assertEquals(1, childTypes.size());
+ DataType<XMLType> childType = childTypes.get(0);
+ Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical().getElementName());
+
+ childType = op.getWrapper().getUnwrappedOutputType();
+ Assert.assertEquals(new QName(null, "price"), childType.getLogical().getElementName());
+ }
+
+ @Test
+ public final void testUnwrappedOperation() throws Exception {
+ ProcessorContext context = new ProcessorContext();
+ URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl");
+ WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("unwrapped-stockquote.wsdl"), url, context);
+ resolver.addModel(definition, context);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition, context);
+ PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+
+ WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor());
+ WSDLOperation op = (WSDLOperation) wi.getOperations().get(1);
+ Assert.assertFalse(op.isWrapperStyle());
+ Assert.assertEquals(1, op.getInputType().getLogical().size());
+
+ op = (WSDLOperation) wi.getOperations().get(2);
+ Assert.assertFalse(op.isWrapperStyle());
+ Assert.assertEquals(2, op.getInputType().getLogical().size());
+ }
+
+ @Test
+ public final void testInvalidWSDL() throws Exception {
+ ProcessorContext context = new ProcessorContext();
+ URL url = getClass().getResource("../xml/invalid-stockquote.wsdl");
+ WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("invalid-stockquote.wsdl"), url, context);
+ resolver.addModel(definition, context);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition, context);
+ PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+
+ try {
+ WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor());
+ WSDLOperation op = (WSDLOperation) wi.getOperations().get(0);
+
+ op.isWrapperStyle();
+ fail("InvalidWSDLException should have been thrown");
+ } catch (InvalidInterfaceException e) {
+ // Expected
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java
new file mode 100644
index 0000000000..45f4fa78f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.introspect;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.AbstractWSDLTestCase;
+import org.apache.tuscany.sca.policy.Intent;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test case for InterfaceWSDLIntrospectorImpl.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLPolicyAnnotatedInterfaceIntrospectorTestCase extends AbstractWSDLTestCase {
+ private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+ private static final QName INTENT = new QName("http://example.com/stockquote.wsdl", "PolicyIntent");
+
+ private PortType portType;
+ private WSDLDefinition definition;
+ private ProcessorContext context;
+
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ context = new ProcessorContext();
+ URL url = getClass().getResource("/policy/stockquote_policy.wsdl");
+ definition = (WSDLDefinition)documentProcessor.read(null, new URI("stockquote.wsdl"), url, context);
+ resolver.addModel(definition, context);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition, context);
+ portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+ }
+
+ @Test
+ public final void testIntrospectPortType() throws InvalidInterfaceException {
+ WSDLInterface contract = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor());
+ Assert.assertEquals(contract.getName().getLocalPart(), "StockQuotePortType");
+
+ boolean foundIntent = false;
+
+ for(Intent intent : contract.getRequiredIntents()) {
+ if(INTENT.equals(intent.getName())) {
+ foundIntent = true;
+ }
+ }
+
+ Assert.assertTrue(foundIntent);
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
new file mode 100644
index 0000000000..ea02d8c3d6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.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.sca.interfacedef.wsdl.introspect;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.AbstractWSDLTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test case for WSDLOperation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WrapperStyleOperationTestCase extends AbstractWSDLTestCase {
+ private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+ @Test
+ public final void testWrappedOperation() throws Exception {
+ ProcessorContext context = new ProcessorContext();
+ URL url = getClass().getResource("../xml/stockquote.wsdl");
+ WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("stockquote.wsdl"), url, context);
+ resolver.addModel(definition, context);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition, context);
+ PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+ WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor());
+ WSDLOperation op = (WSDLOperation) wi.getOperations().get(0);
+ Assert.assertTrue(op.isWrapperStyle());
+ Assert.assertEquals(1, op.getWrapper().getInputChildElements().size());
+ Assert.assertEquals(1, op.getWrapper().getOutputChildElements().size());
+ }
+
+ @Test
+ public final void testUnwrappedOperation() throws Exception {
+ ProcessorContext context = new ProcessorContext();
+ URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl");
+ WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, new URI("unwrapped-stockquote.wsdl"), url, context);
+ resolver.addModel(definition, context);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition, context);
+ PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+ WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor());
+ WSDLOperation op = (WSDLOperation) wi.getOperations().get(1);
+ Assert.assertFalse(op.isWrapperStyle());
+ op = (WSDLOperation) wi.getOperations().get(2);
+ Assert.assertFalse(op.isWrapperStyle());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/AbstractWSDLTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/AbstractWSDLTestCase.java
new file mode 100644
index 0000000000..143aa47d49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/AbstractWSDLTestCase.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.sca.interfacedef.wsdl.xml;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.junit.Before;
+
+/**
+ * Test case for WSDLOperation.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractWSDLTestCase {
+ protected URLArtifactProcessor<Object> documentProcessor;
+ protected ModelResolver resolver;
+ protected WSDLFactory wsdlFactory;
+ protected XSDFactory xsdFactory;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ xsdFactory = modelFactories.getFactory(XSDFactory.class);
+
+ ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ Contribution contribution = contributionFactory.createContribution();
+ ModelResolverExtensionPoint modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
+ resolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
+ contribution.setModelResolver(resolver);
+
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java
new file mode 100644
index 0000000000..df06553931
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.wsdl.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ @Test
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ComponentType componentType = (ComponentType)staxProcessor.read(reader, context);
+ assertNotNull(componentType);
+ }
+
+ @Test
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ assertNotNull(composite);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java
new file mode 100644
index 0000000000..513cb383e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Import;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WSDLDocumentProcessorTestCase extends AbstractWSDLTestCase {
+
+ @Test
+ public void testWSDL() throws Exception {
+ ProcessorContext context = new ProcessorContext();
+ URL url = getClass().getResource("/wsdl/helloworld-service.wsdl");
+ WSDLDefinition definition = (WSDLDefinition)documentProcessor.read(null, URI.create("wsdl/helloworld-service.wsdl"), url, context);
+
+ Assert.assertNull(definition.getDefinition());
+ Assert.assertEquals("http://helloworld", definition.getNamespace());
+ URL url1 = getClass().getResource("/wsdl/helloworld-interface.wsdl");
+ WSDLDefinition definition1 = (WSDLDefinition)documentProcessor.read(null, URI.create("wsdl/helloworld-interface.wsdl"), url1, context);
+ Assert.assertNull(definition1.getDefinition());
+ Assert.assertEquals("http://helloworld", definition1.getNamespace());
+
+ resolver.addModel(definition, context);
+ resolver.addModel(definition1, context);
+ resolver.resolveModel(WSDLDefinition.class, definition, context);
+ resolver.resolveModel(WSDLDefinition.class, definition1, context);
+ WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, definition, context);
+ List imports = (List)definition.getDefinition().getImports().get("http://helloworld");
+ Assert.assertNotNull(imports);
+ Assert.assertNotNull(((Import)imports.get(0)).getDefinition());
+ Assert.assertNotNull(resolved.getDefinition().getPortType(new QName("http://helloworld", "HelloWorld")));
+ Assert.assertNotNull(resolved.getDefinition().getService(new QName("http://helloworld", "HelloWorldService")));
+
+ assertNotNull(resolved.getXmlSchemaType(new QName("http://greeting", "Name")));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java
new file mode 100644
index 0000000000..90054230ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wsdl.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test reading WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLTestCase {
+
+ private ExtensibleURLArtifactProcessor documentProcessor;
+ private ContributionFactory contributionFactory;
+ private WSDLModelResolver wsdlResolver;
+ private ModelResolver resolver;
+
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ Contribution contribution = contributionFactory.createContribution();
+ ModelResolverExtensionPoint modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
+ resolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
+ contribution.setModelResolver(resolver);
+ wsdlResolver = new WSDLModelResolver(contribution, modelFactories);
+ }
+
+ @Test
+ public void testReadWSDLDocument() throws Exception {
+ URL url = getClass().getResource("example.wsdl");
+ WSDLDefinition definition = documentProcessor.read(null, new URI("example.wsdl"), url, null, WSDLDefinition.class);
+ assertNotNull(definition);
+ assertNull(definition.getDefinition());
+ assertEquals(definition.getNamespace(), "http://www.example.org");
+ }
+
+ @Test
+ public void testReadWSDLImports() throws Exception {
+ QName aBinding = new QName("http://helloworld", "HelloWorldSoapBinding");
+ QName aPortType = new QName("http://helloworld", "HelloWorld");
+
+ URL url = getClass().getResource("test1.wsdl");
+ WSDLDefinition test1Defn = documentProcessor.read(null, new URI("test1.wsdl"), url, null, WSDLDefinition.class);
+ assertNotNull(test1Defn);
+ ProcessorContext context = new ProcessorContext();
+ wsdlResolver.addModel(test1Defn, context);
+ test1Defn = wsdlResolver.resolveModel(WSDLDefinition.class, test1Defn, context);
+ //binding is a part of test1.wsdl
+ assertNotNull(test1Defn.getDefinition().getBinding(aBinding));
+ //porttype is part of test2.wsdl
+ assertNotNull(test1Defn.getDefinition().getPortType(aPortType));
+ }
+
+ @Test
+ public void testReadSameNamespaceWSDLDocument() throws Exception {
+ QName aBinding = new QName("http://helloworld", "HelloWorldSoapBinding");
+ QName aPortType = new QName("http://helloworld", "HelloWorld");
+
+ ProcessorContext context = new ProcessorContext();
+ URL url = getClass().getResource("test2.wsdl");
+ WSDLDefinition test2Defn = documentProcessor.read(null, new URI("test2.wsdl"), url, null, WSDLDefinition.class);
+ assertNotNull(test2Defn);
+ wsdlResolver.addModel(test2Defn, context);
+ test2Defn = wsdlResolver.resolveModel(WSDLDefinition.class, test2Defn, context);
+
+ //bindings are a part of test1.wsdl so should not be found
+ assertNull(test2Defn.getDefinition().getBinding(aBinding));
+ assertNotNull(test2Defn.getDefinition().getPortType(aPortType));
+
+ url = getClass().getResource("test1.wsdl");
+ WSDLDefinition test1Defn = documentProcessor.read(null, new URI("test1.wsdl"), url, null, WSDLDefinition.class);
+ assertNotNull(test1Defn);
+ wsdlResolver.addModel(test1Defn, context);
+
+ test1Defn = wsdlResolver.resolveModel(WSDLDefinition.class, test1Defn, context);
+
+ assertNotNull(test1Defn.getDefinition().getPortType(aPortType));
+ assertNotNull(test1Defn.getDefinition().getBinding(aBinding));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java
new file mode 100644
index 0000000000..118f44f1a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.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.sca.interfacedef.wsdl.xml;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading/write WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WriteTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+ }
+
+ @Test
+ public void testReadWriteComponentType() throws Exception {
+ InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentType componentType = (ComponentType)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(componentType);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos), context);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is), context);
+ assertNotNull(composite);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite
new file mode 100644
index 0000000000..9d714e8169
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite
@@ -0,0 +1,55 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:calc="http://sample.calculator"
+ targetNamespace="http://calc"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
+ name="Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"
+ wsdli:wsdlLocation="http://tempuri.org" requires="calc:intent1" policySets="calc:policySet1"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..eaf8d1b8ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance">
+
+ <service name="CalculatorService">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"
+ wsdli:wsdlLocation="http://tempuri.org"/>
+ </service>
+
+ <reference name="divideService">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Divide)"/>
+ </reference>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl
new file mode 100644
index 0000000000..5e8e5dad0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl
@@ -0,0 +1,26 @@
+<?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://www.example.org"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="example">
+
+ <wsdl:portType name="HelloWorld">
+ </wsdl:portType>
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl
new file mode 100644
index 0000000000..ad81fc7867
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice1">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput" />
+ <output message="tns:GetLastTradePriceOutput" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd
new file mode 100644
index 0000000000..241ec15d36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl
new file mode 100644
index 0000000000..39cd5547d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput" />
+ <output message="tns:GetLastTradePriceOutput" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl
new file mode 100644
index 0000000000..8e26f7b4b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl
@@ -0,0 +1,45 @@
+<?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:import location="test2.wsdl" namespace="http://helloworld"></wsdl:import>
+
+ <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:8085/sample-helloworldws-1.0-SNAPSHOT/services/HelloWorldWebService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd
new file mode 100644
index 0000000000..c2210f4a94
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd
@@ -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.
+-->
+<schema targetNamespace="http://www.example.com/Customer" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO" xmlns:tns="http://www.example.com/Customer">
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd" />
+
+ <complexType name="Customer">
+ <sequence>
+ <element name="customerID" type="string"></element>
+ <element name="name" type="string"></element>
+ <element name="order" type="ipo:PurchaseOrderType" />
+ </sequence>
+ </complexType>
+ <element name="customer" type="tns:Customer"></element>
+
+</schema>
+
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl
new file mode 100644
index 0000000000..529b395fd5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl
@@ -0,0 +1,63 @@
+<?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">
+
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd" />
+
+ <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:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl
new file mode 100644
index 0000000000..666a7e4069
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput1">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput1">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <message name="GetLastTradePriceInput2">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ <part name="other" type="xsd:string"/>
+ </message>
+
+ <message name="GetLastTradePriceOutput2">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput1" />
+ <output message="tns:GetLastTradePriceOutput1" />
+ </operation>
+ <operation name="getLastTradePrice1">
+ <input message="tns:GetLastTradePriceInput1" />
+ <output message="tns:GetLastTradePriceOutput1" />
+ </operation>
+ <operation name="getLastTradePrice2">
+ <input message="tns:GetLastTradePriceInput2" />
+ <output message="tns:GetLastTradePriceOutput2" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/policy/stockquote_policy.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/policy/stockquote_policy.wsdl
new file mode 100644
index 0000000000..86cbe39af9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/policy/stockquote_policy.wsdl
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote"
+ targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl"
+ xmlns:xsd="http://example.com/stockquote.xsd"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput">
+ <part name="body" element="xsd:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput">
+ <part name="body" element="xsd:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType" sca:requires="sca:conversational tns:PolicyIntent">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput" />
+ <output message="tns:GetLastTradePriceOutput" />
+ </operation>
+ <operation name="cancel" sca:endsConversation="true"/>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/wsdl/helloworld-interface.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/wsdl/helloworld-interface.wsdl
new file mode 100644
index 0000000000..9d9376ad6c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/wsdl/helloworld-interface.wsdl
@@ -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.
+-->
+<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" xmlns:g="http://greeting">
+
+ <!--
+ <import namespace="http://greeting" schemaLocation="../xsd/greeting.xsd" />
+ -->
+ <include schemaLocation="../xsd/helloworld.xsd" />
+
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="g:Name" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="g:Greeting" />
+ </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:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/wsdl/helloworld-service.wsdl b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/wsdl/helloworld-service.wsdl
new file mode 100644
index 0000000000..3885357625
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/wsdl/helloworld-service.wsdl
@@ -0,0 +1,49 @@
+<?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:import location="helloworld-interface.wsdl" namespace="http://helloworld"></wsdl:import>
+ <!--
+ <wsdl:import namespace="http://helloworld"></wsdl:import>
+ -->
+
+ <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:8085/sample-helloworldws-1.0-SNAPSHOT/services/HelloWorldWebService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/greeting.xsd b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/greeting.xsd
new file mode 100644
index 0000000000..635ca25bfc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/greeting.xsd
@@ -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.
+-->
+<schema targetNamespace="http://greeting" xmlns="http://www.w3.org/2001/XMLSchema">
+ <include schemaLocation="name.xsd" />
+ <complexType name="Greeting">
+ <sequence>
+ <element name="message" type="string" />
+ <element name="name" type="Name" />
+ </sequence>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/helloworld.xsd b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/helloworld.xsd
new file mode 100644
index 0000000000..bb0c9bc7b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/helloworld.xsd
@@ -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.
+-->
+<schema targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://greeting" schemaLocation="greeting.xsd" />
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/name.xsd b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/name.xsd
new file mode 100644
index 0000000000..300de931ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/interface-wsdl/src/test/resources/xsd/name.xsd
@@ -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.
+-->
+<schema targetNamespace="http://greeting" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <complexType name="Name">
+ <sequence>
+ <element name="firstName" type="string" />
+ <element name="lastName" type="string" />
+ </sequence>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/launcher/LICENSE b/sandbox/sebastien/java/embed/modules/launcher/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/launcher/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/sebastien/java/embed/modules/launcher/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/launcher/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..edcc065b69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/launcher/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-Version: 2.0.0
+Bundle-DocURL: http://www.apache.org/
+Bundle-SymbolicName: org.apache.tuscany.sca.launcher
+Bundle-Description: Apache Tuscany Launcher
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Name: Apache Tuscany Launcher
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+SCA-Version: 1.1
+Bundle-ManifestVersion: 2
+Import-Package: org.apache.tuscany.sca.launcher;version="2.0"
+Export-Package: org.apache.tuscany.sca.launcher;version="2.0"
+Main-Class: org.apache.tuscany.sca.launcher.LauncherMain
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/launcher/NOTICE b/sandbox/sebastien/java/embed/modules/launcher/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/launcher/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/launcher/pom.xml b/sandbox/sebastien/java/embed/modules/launcher/pom.xml
new file mode 100644
index 0000000000..9dec07661d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/launcher/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-launcher</artifactId>
+ <name>Apache Tuscany SCA Launcher</name>
+
+ <dependencies>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java b/sandbox/sebastien/java/embed/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java
new file mode 100644
index 0000000000..275e0a75c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.launcher;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+public class LauncherMain {
+
+ private static final String DEFAULT_PROPERTY_FILENAME = "default.config";
+ private static final String CONFIG_CLASSPATH = "classpath";
+ private static final String CONFIG_MAIN_CLASS = "mainClass";
+ private static final String CONFIG_ARG_JAR_MAIN = "[firstArgJarManifestMainClass]";
+ private static final String LAUNCHER_ARGS = "launcherArgs";
+
+ public static void main(String[] args) throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, URISyntaxException, IOException {
+ Properties launcherProperties = getLauncherProperties(args);
+ setSystemProperties(launcherProperties);
+ ClassLoader classLoader = getClassLoader(launcherProperties);
+ String mainClassName = getMainClass(launcherProperties, classLoader);
+ String[] mainArgs = getMainArgs(launcherProperties);
+ invokeMainMethod(mainClassName, classLoader, mainArgs);
+ }
+
+ private static void setSystemProperties(Properties launcherProperties) throws URISyntaxException {
+ for (Enumeration<?> e = launcherProperties.propertyNames(); e.hasMoreElements();) {
+ String pn = (String) e.nextElement();
+ if (pn.startsWith("-D")) {
+ System.setProperty(pn.substring(2), keywordExpand(launcherProperties.getProperty(pn)));
+ }
+ }
+ }
+
+ private static String keywordExpand(String property) throws URISyntaxException {
+ if (property.contains("{TUSCANY_HOME}")) {
+ property = property.replace("{TUSCANY_HOME}", getLauncherFolder().getParentFile().getAbsolutePath());
+ }
+ return property;
+ }
+
+ private static String[] getMainArgs(Properties launcherProperties) {
+ String[] mainArgs = (String[])launcherProperties.get(LAUNCHER_ARGS);
+ if (mainArgs == null) {
+ mainArgs = new String[0];
+ }
+ return mainArgs;
+ }
+
+ private static String getMainClass(Properties launcherProperties, ClassLoader classLoader) {
+ String mainClassName;
+ String[] args = getMainArgs(launcherProperties);
+ if (args.length > 0) {
+ try {
+ Class.forName(args[0], true, classLoader);
+ mainClassName = args[0];
+ String[] args2 = new String[args.length-1];
+ System.arraycopy(args, 1, args2, 0, args.length-1);
+ launcherProperties.put(LAUNCHER_ARGS, args2);
+ } catch (ClassNotFoundException e) {
+ mainClassName = launcherProperties.getProperty(CONFIG_MAIN_CLASS);
+ }
+ } else {
+ mainClassName = launcherProperties.getProperty(CONFIG_MAIN_CLASS);
+ }
+
+ if (mainClassName.startsWith(CONFIG_ARG_JAR_MAIN + "|")) {
+ mainClassName = mainClassName.substring(CONFIG_ARG_JAR_MAIN.length()+1);
+ }
+
+ return mainClassName;
+ }
+
+ private static void invokeMainMethod(String className, ClassLoader classLoader, String[] args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+
+ Thread.currentThread().setContextClassLoader(classLoader);
+ Class mainClass = Class.forName(className, true, classLoader);
+ Method m = mainClass.getMethod("main", new Class[]{ args.getClass() });
+
+ m.invoke(null, new Object[]{args});
+
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ private static ClassLoader getClassLoader(Properties launcherProperties) throws URISyntaxException, IOException {
+ Set<URL> jarURLs = new HashSet<URL>();
+ for (Enumeration<?> e = launcherProperties.propertyNames(); e.hasMoreElements();) {
+ String pn = (String) e.nextElement();
+ if (pn.startsWith(CONFIG_CLASSPATH)) {
+ jarURLs.addAll(getJARs(launcherProperties.getProperty(pn), launcherProperties));
+ } else if (pn.equals(CONFIG_MAIN_CLASS) && launcherProperties.getProperty(pn).startsWith(CONFIG_ARG_JAR_MAIN)) {
+ if (firstArgJarHasManifestMainClass(launcherProperties)) {
+ jarURLs.add(firstArgJarManifestMainClass(launcherProperties));
+ }
+ }
+ }
+ ClassLoader parentCL = Thread.currentThread().getContextClassLoader();
+ if (parentCL == null) {
+ parentCL = LauncherMain.class.getClassLoader();
+ }
+ return new URLClassLoader(jarURLs.toArray(new URL[]{}), parentCL);
+ }
+
+ private static void argJars(Set<URL> jarURLs, Properties launcherProperties) throws IOException {
+ String[] args = (String[])launcherProperties.get(LAUNCHER_ARGS);
+ if (args != null && args.length > 0) {
+ for (String a : args) {
+ File f = new File(a);
+ if (!f.exists()) {
+ throw new FileNotFoundException(args[0]);
+ }
+ jarURLs.add(f.toURI().toURL());
+ }
+ }
+ launcherProperties.put(LAUNCHER_ARGS, new String[]{});
+ }
+
+ private static URL firstArgJarManifestMainClass(Properties launcherProperties) throws IOException {
+ String[] args = (String[])launcherProperties.get(LAUNCHER_ARGS);
+ if (args.length < 1) {
+ throw new IllegalArgumentException("must specifiy a jar file");
+ }
+ File f = new File(args[0]);
+ if (!f.exists()) {
+ throw new FileNotFoundException(args[0]);
+ }
+ JarFile jar = new JarFile(f);
+ String mfc = jar.getManifest().getMainAttributes().getValue("Main-Class");
+ if (mfc == null || mfc.length() < 1) {
+ throw new IllegalArgumentException("first jar file missing manifest Main-Class attribute");
+ }
+ launcherProperties.setProperty(CONFIG_MAIN_CLASS, mfc);
+
+ return f.toURL();
+ }
+
+ private static boolean firstArgJarHasManifestMainClass(Properties launcherProperties) throws IOException {
+ String[] args = (String[])launcherProperties.get(LAUNCHER_ARGS);
+ if (args.length < 1) {
+ return false;
+ }
+ File f = new File(args[0]);
+ if (!f.exists() || f.isDirectory()) {
+ return false;
+ }
+ JarFile jar = new JarFile(f);
+ Manifest mf = jar.getManifest();
+ if (mf != null) {
+ String mfc = jar.getManifest().getMainAttributes().getValue("Main-Class");
+ return mfc != null && mfc.length() > 0;
+ } else {
+ return false;
+ }
+ }
+ /**
+ * Gets the jars matching a config classpath property
+ * property values may be an explicit jar name or use an asterix wildcard for
+ * all jars in a folder, or a double asterix '**' for all jars in a folder and its subfolders
+ * @throws URISyntaxException
+ */
+ private static Set<URL> getJARs(String classpathValue, Properties launcherProperties) throws URISyntaxException {
+ Set<URL> jarURLs = new HashSet<URL>();
+
+ if (classpathValue.endsWith("**")) {
+ File folder = new File(classpathValue.substring(0, classpathValue.length()-2));
+ if (!folder.isAbsolute()) {
+ folder = new File(getLauncherFolder().getParent(), folder.getName());
+ }
+ jarURLs.addAll(getFolderJars(folder));
+ jarURLs.addAll(getSubFolderJars(folder));
+ } else if (classpathValue.endsWith("*")) {
+ File folder = new File(classpathValue.substring(0, classpathValue.length()-1));
+ if (!folder.isAbsolute()) {
+ folder = new File(getLauncherFolder(), folder.getName());
+ }
+ jarURLs.addAll(getFolderJars(folder));
+ } else {
+ File f = new File(classpathValue);
+ if (!f.isAbsolute()) {
+ f = new File(getLauncherFolder(), classpathValue);
+ }
+ try {
+ jarURLs.add(f.toURI().toURL());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Exception getting JAR URL", e);
+ }
+ }
+ return jarURLs;
+ }
+
+ /**
+ * Gets all the jars in a folder
+ */
+ private static Set<URL> getFolderJars(File folder) {
+ Set<URL> jarURLs = new HashSet<URL>();
+ if (folder.exists() && folder.isDirectory()) {
+ File[] files = folder.listFiles(new FilenameFilter(){
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
+ }});
+ for (File f : files) {
+ try {
+ jarURLs.add(f.toURI().toURL());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Exception getting JAR URL", e);
+ }
+ }
+ }
+ return jarURLs;
+ }
+
+ /**
+ * Recursively gets all the jars in a folder and its subfolders
+ */
+ private static Set<URL> getSubFolderJars(File folder) {
+ Set<URL> jarURLs = new HashSet<URL>();
+ if (folder.exists() && folder.isDirectory()) {
+ File[] files = folder.listFiles(new FileFilter(){
+ public boolean accept(File pathname) {
+ return pathname.isDirectory();
+ }});
+ for (File f : files) {
+ jarURLs.addAll(getFolderJars(f));
+ jarURLs.addAll(getSubFolderJars(f));
+ }
+ }
+ return jarURLs;
+ }
+
+ /**
+ * Read the config properties for this launcher invocation
+ * (Either default.config or the 1st cmd line argument suffixed with ".config" if that file exists
+ */
+ private static Properties getLauncherProperties(String[] args) throws URISyntaxException, FileNotFoundException {
+
+ Properties properties = new Properties();
+
+ File f;
+ if (args.length > 0) {
+ f = new File(getLauncherFolder(), args[0] + ".config");
+ if (f.exists()) {
+ String[] args2 = new String[args.length-1];
+ System.arraycopy(args, 1, args2, 0, args.length-1);
+ args = args2;
+ } else {
+ f = new File(getLauncherFolder(), DEFAULT_PROPERTY_FILENAME);
+ }
+ } else {
+ f = new File(getLauncherFolder(), DEFAULT_PROPERTY_FILENAME);
+ }
+
+ if (!f.exists()) {
+// throw new FileNotFoundException(f.getName());
+ if (args.length > 0 && "client".equals(args[0])) {
+ properties.put("mainClass", "org.apache.tuscany.sca.client.javascript.TuscanyShell");
+ String[] args2 = new String[args.length-1];
+ System.arraycopy(args, 1, args2, 0, args.length-1);
+ args = args2;
+ } else {
+ properties.put("mainClass", "[firstArgJarManifestMainClass]|org.apache.tuscany.sca.domain.node.DomainNodeMain");
+ }
+ } else {
+ try {
+ FileInputStream fis = new FileInputStream(f);
+ properties.load(fis);
+ fis.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ properties.put(LAUNCHER_ARGS, args);
+
+ return properties;
+ }
+
+ /**
+ * Find the folder that contains the launcher jar
+ */
+ private static File getLauncherFolder() throws URISyntaxException {
+
+ File folder = null;
+
+ String resource = LauncherMain.class.getName().replace('.', '/') + ".class";
+ URL url = LauncherMain.class.getClassLoader().getResource(resource);
+ if (url != null) {
+ URI uri = url.toURI();
+ String scheme = uri.getScheme();
+ if (uri.getScheme().equals("jar")) {
+ String path = uri.toString().substring(4);
+ int i = path.indexOf("!/");
+ if (i != -1) {
+ path = path.substring(0, i);
+ uri = URI.create(path);
+ }
+
+ File file = new File(uri);
+ if (file.exists()) {
+ File jarDirectory = file.getParentFile();
+ if (jarDirectory != null && jarDirectory.exists()) {
+ folder = file;
+ }
+ }
+ }
+ }
+ folder = folder.getParentFile();
+ return folder;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/LICENSE b/sandbox/sebastien/java/embed/modules/monitor/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/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/sebastien/java/embed/modules/monitor/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/monitor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c9613cb52c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-Name: Apache Tuscany SCA Monitor
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Monitor
+Import-Package: org.apache.tuscany.sca.monitor;version="2.0.0"
+DynamicImport-Package: org.apache.tuscany.sca.*;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.monitor
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/monitor/NOTICE b/sandbox/sebastien/java/embed/modules/monitor/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/monitor/pom.xml b/sandbox/sebastien/java/embed/modules/monitor/pom.xml
new file mode 100644
index 0000000000..e7e9ca9c15
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/pom.xml
@@ -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.
+-->
+<project>
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-monitor</artifactId>
+ <name>Apache Tuscany SCA Monitor</name>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.java b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.java
new file mode 100644
index 0000000000..8a99fa4c7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.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.monitor;
+
+import org.apache.tuscany.sca.monitor.impl.MonitorImpl;
+
+/**
+ * A factory for creating validation monitors
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultMonitorFactory implements MonitorFactory {
+ private ThreadLocal<Monitor> contextMonitor = new InheritableThreadLocal<Monitor>();
+
+ public Monitor createMonitor() {
+ return new MonitorImpl();
+ }
+
+ public Monitor getContextMonitor() {
+ return contextMonitor.get();
+ }
+
+ public Monitor getContextMonitor(boolean create) {
+ Monitor monitor = contextMonitor.get();
+ if (monitor == null) {
+ monitor = new MonitorImpl();
+ setContextMonitor(monitor);
+ }
+ return monitor;
+ }
+
+ public Monitor removeContextMonitor() {
+ Monitor old = contextMonitor.get();
+ contextMonitor.remove();
+ return old;
+ }
+
+ public Monitor setContextMonitor(Monitor value) {
+ Monitor old = contextMonitor.get();
+ contextMonitor.set(value);
+ return old;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
new file mode 100644
index 0000000000..3eda98ee23
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.monitor;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * A monitor for the watching for validation problems
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class Monitor {
+ private static class ContextFinder extends SecurityManager {
+ private final static ContextFinder instance = new ContextFinder();
+
+ // This is sensitive to the calling stack
+ private static Class<?> getContextClass() {
+ Class[] classes = instance.getClassContext();
+ // 0: ContextFinder (getClassContext)
+ // 1: ContextFinder (getContextClass)
+ // 2: Monitor (getSourceClassName)
+ // 3: Monitor (error/warning)
+ return classes[4];
+ }
+
+ }
+ private final static Logger logger = Logger.getLogger(Monitor.class.getName());
+
+ /**
+ * A utility function for raising an error. It creates the problem and
+ * adds it to the monitor
+ *
+ * @param monitor
+ * @param reportingObject
+ * @param messageBundle
+ * @param messageId
+ * @param messageParameters
+ */
+ public static void error (Monitor monitor,
+ Object reportingObject,
+ String messageBundle,
+ String messageId,
+ Object... messageParameters){
+ String contextClassName = getSourceClassName(reportingObject);
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(contextClassName,
+ messageBundle,
+ Severity.ERROR,
+ reportingObject,
+ messageId,
+ messageParameters);
+ monitor.problem(problem);
+ } else {
+ logNullMonitor(messageId, contextClassName);
+ }
+ }
+
+ /**
+ * A utility function for raising an error. It creates the problem and
+ * adds it to the monitor
+ *
+ * @param monitor
+ * @param reportingObject
+ * @param messageBundle
+ * @param messageId
+ * @param exception
+ */
+ public static void error (Monitor monitor,
+ Object reportingObject,
+ String messageBundle,
+ String messageId,
+ Throwable cause){
+ String contextClassName = getSourceClassName(reportingObject);
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(contextClassName,
+ messageBundle,
+ Severity.ERROR,
+ reportingObject,
+ messageId,
+ cause);
+ monitor.problem(problem);
+ } else {
+ logNullMonitor(messageId, contextClassName);
+ }
+ }
+
+ /**
+ * A utility function for raising an error. It creates the problem and
+ * adds it to the monitor
+ *
+ * @param monitor
+ * @param reportingObject
+ * @param messageBundle
+ * @param messageId
+ * @param exception
+ */
+ public static void error (Monitor monitor,
+ Object reportingObject,
+ String messageBundle,
+ String messageId,
+ Throwable cause,
+ Object... messageParameters) {
+ String contextClassName = getSourceClassName(reportingObject);
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(contextClassName,
+ messageBundle,
+ Severity.ERROR,
+ reportingObject,
+ messageId,
+ cause,
+ messageParameters);
+ monitor.problem(problem);
+ } else {
+ logNullMonitor(messageId, contextClassName);
+ }
+ }
+
+ private static String getSourceClassName(Object reportingObject) {
+ String contextClassName = null;
+ if (reportingObject != null) {
+ contextClassName = reportingObject.getClass().getName();
+ } else {
+ contextClassName = ContextFinder.getContextClass().getName();
+ }
+ return contextClassName;
+ }
+
+ private static void logNullMonitor(String messageId, String contextClassName) {
+ logger.warning("Attempt to report error with id " +
+ messageId +
+ " from class " +
+ contextClassName +
+ " but the monitor object was null");
+ }
+
+ /**
+ * A utility function for raising a warning. It creates the problem and
+ * adds it to the monitor
+ *
+ * @param monitor
+ * @param reportingObject
+ * @param messageBundle
+ * @param messageId
+ * @param messageParameters
+ */
+ public static void warning (Monitor monitor,
+ Object reportingObject,
+ String messageBundle,
+ String messageId,
+ Object... messageParameters){
+ String contextClassName = getSourceClassName(reportingObject);
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(contextClassName,
+ messageBundle,
+ Severity.WARNING,
+ reportingObject,
+ messageId,
+ messageParameters);
+ monitor.problem(problem);
+ } else {
+ logNullMonitor(messageId, contextClassName);
+ }
+ }
+
+ // =====================================================
+ // TUSCANY-3132 - new approach to monitoring errors
+ //
+
+ /**
+ * A utility function for raising an error. It creates the problem and
+ * adds it to the monitor
+ *
+ * @param monitor
+ * @param reportingObject
+ * @param messageBundle
+ * @param messageId
+ * @param exception
+ */
+ public static void warning (Monitor monitor,
+ Object reportingObject,
+ String messageBundle,
+ String messageId,
+ Throwable cause){
+ String contextClassName = getSourceClassName(reportingObject);
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(contextClassName,
+ messageBundle,
+ Severity.WARNING,
+ reportingObject,
+ messageId,
+ cause);
+ monitor.problem(problem);
+ } else {
+ logNullMonitor(messageId, contextClassName);
+ }
+ }
+
+ /**
+ * A utility function for raising an error. It creates the problem and
+ * adds it to the monitor
+ *
+ * @param monitor
+ * @param reportingObject
+ * @param messageBundle
+ * @param messageId
+ * @param exception
+ */
+ public static void warning (Monitor monitor,
+ Object reportingObject,
+ String messageBundle,
+ String messageId,
+ Throwable cause,
+ Object... messageParameters) {
+ String contextClassName = getSourceClassName(reportingObject);
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(contextClassName,
+ messageBundle,
+ Severity.WARNING,
+ reportingObject,
+ messageId,
+ cause,
+ messageParameters);
+ monitor.problem(problem);
+ } else {
+ logNullMonitor(messageId, contextClassName);
+ }
+ }
+
+ /**
+ * Create a new problem.
+ *
+ * @param sourceClassName the class name reporting the problem
+ * @param bundleName the name of the message bundle to use
+ * @param severity the severity of the problem
+ * @param problemObject the model object for which the problem is being reported
+ * @param messageId the id of the problem message
+ * @param messageParams the parameters of the problem message
+ * @return
+ */
+ public abstract Problem createProblem(String sourceClassName,
+ String bundleName,
+ Severity severity,
+ Object problemObject,
+ String messageId,
+ Object... messageParams);
+
+ /**
+ * Create a new problem.
+ *
+ * @param sourceClassName the class name reporting the problem
+ * @param bundleName the name of the message bundle to use
+ * @param severity the severity of the problem
+ * @param problemObject the model object for which the problem is being reported
+ * @param messageId the id of the problem message
+ * @param cause the exception which caused the problem
+ * @return
+ */
+ public abstract Problem createProblem(String sourceClassName,
+ String bundleName,
+ Severity severity,
+ Object problemObject,
+ String messageId,
+ Throwable cause);
+
+ /**
+ * Get the name of the artifact for which errors are Monitored
+ * @return the name of the Artifact or null if no artifact name has been set
+ */
+ public abstract String getArtifactName();
+
+ /**
+ * Returns the last logged problem.
+ *
+ * @return
+ */
+ public abstract Problem getLastProblem();
+
+ /**
+ * Returns a list of reported problems.
+ *
+ * @return the list of problems. The list may be empty
+ */
+ public abstract List<Problem> getProblems();
+
+ /**
+ * Remove the most recent context string from the
+ * context stack
+ * @return The object popped
+ */
+ public abstract Object popContext();
+
+ /**
+ * Reports a build problem.
+ *
+ * @param problem
+ */
+ public abstract void problem(Problem problem);
+
+ /**
+ * Add a context string to the context stack
+ * @param context the context string to add
+ */
+ public abstract void pushContext(Object context);
+
+ /**
+ * Clear context and problems
+ */
+ public abstract void reset();
+ /**
+ * Set the name of an artifact for which errors are Monitored
+ * @param artifactName the artifact name
+ */
+ public abstract void setArtifactName(String artifactName);
+
+ // =====================================================
+
+ /**
+ * Checks the Monitor for any Problems with s severity of ERROR and
+ * if one is found then throw a ValidationException.
+ * This will also call reset() on this Monitor.
+ */
+ public void analyzeProblems() throws ValidationException {
+ try {
+ for (Problem problem : getProblems()) {
+ if ((problem.getSeverity() == Severity.ERROR)) {
+ if (problem.getCause() != null) {
+ throw new ValidationException(problem.getCause());
+ } else {
+ throw new ValidationException(problem.toString());
+ }
+ }
+ }
+ } finally {
+ reset();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java
new file mode 100644
index 0000000000..12ac7eba7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.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.sca.monitor;
+
+
+/**
+ * A factory for validation monitors
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MonitorFactory {
+
+ /**
+ * Create a new monitor.
+ *
+ * @return a new monitor
+ */
+ Monitor createMonitor();
+
+ /**
+ * Get the monitor instance on the thread
+ * @return the monitor instance on the thread
+ */
+ Monitor getContextMonitor();
+
+ /**
+ * Get the monitor instance on the thread
+ * @param create if it true, then create a new instance if no monitor is on the thread
+ * @return the monitor instance on the thread
+ */
+ Monitor getContextMonitor(boolean create);
+
+ /**
+ * Remove the monitor on the thread
+ * @return The existing instance
+ */
+ Monitor removeContextMonitor();
+
+ /**
+ * Set the monitor onto the thread
+ * @param value The new instance
+ * @return The old instance
+ */
+ Monitor setContextMonitor(Monitor monitor);
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java
new file mode 100644
index 0000000000..c05fa632fb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.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.sca.monitor;
+
+/**
+ * Records an validation problem.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Problem {
+
+ /**
+ *
+ * @tuscany.spi.extension
+ *
+ */
+ public enum Severity {
+ INFO, WARNING, ERROR
+ }
+
+ String getSourceClassName();
+
+ String getResourceBundleName();
+
+ Severity getSeverity();
+
+ String getContext();
+
+ Object getProblemObject();
+
+ String getMessageId();
+
+ Throwable getCause();
+
+ Object[] getMessageParams();
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java
new file mode 100644
index 0000000000..368893dd68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/ValidationException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.monitor;
+
+public class ValidationException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public ValidationException() {
+ super();
+ }
+
+ public ValidationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ValidationException(String message) {
+ super(message);
+ }
+
+ public ValidationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
new file mode 100644
index 0000000000..c81581aae0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.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.sca.monitor.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * A monitor for the watching for validation problems
+ *
+ * @version $Rev$ $Date$
+ */
+public class MonitorImpl extends Monitor {
+ private static final Logger logger = Logger.getLogger(MonitorImpl.class.getName());
+
+ // stack of context information that is printed alongside each problem
+ private Stack<Object> contextStack = new Stack<Object>();
+
+ // Cache all the problem reported to monitor for further analysis
+ private List<Problem> problemCache = new ArrayList<Problem>();
+
+ // Name of an artifact for which problems are being Monitored
+ private String artifactName = null;
+
+ public void problem(Problem problem) {
+
+ Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getResourceBundleName());
+
+ if (problemLogger == null) {
+ logger.severe("Can't get logger " + problem.getSourceClassName()
+ + " with bundle "
+ + problem.getResourceBundleName());
+ }
+
+ if (problem.getSeverity() == Severity.INFO) {
+ problemCache.add(problem);
+ problemLogger.logp(Level.INFO, problem.getSourceClassName(), problem.getContext(), problem.getMessageId(), problem
+ .getMessageParams());
+ } else if (problem.getSeverity() == Severity.WARNING) {
+ problemCache.add(problem);
+ problemLogger.logp(Level.WARNING, problem.getSourceClassName(), problem.getContext(), problem.getMessageId(), problem
+ .getMessageParams());
+ } else if (problem.getSeverity() == Severity.ERROR) {
+ if (problem.getCause() != null) {
+ problemCache.add(problem);
+ problemLogger.logp(Level.SEVERE, problem.getSourceClassName(), problem.getContext(), problem.getMessageId(), problem
+ .getCause());
+
+ } else {
+ problemCache.add(problem);
+ problemLogger.logp(Level.SEVERE, problem.getSourceClassName(), problem.getContext(), problem.getMessageId(), problem
+ .getMessageParams());
+ }
+ }
+ }
+
+ public List<Problem> getProblems() {
+ return problemCache;
+ }
+
+ public Problem getLastProblem() {
+ if (problemCache.isEmpty()) {
+ return null;
+ }
+ return problemCache.get(problemCache.size() - 1);
+ }
+
+ public Problem createProblem(String sourceClassName,
+ String bundleName,
+ Severity severity,
+ Object problemObject,
+ String messageId,
+ Throwable cause) {
+ return new ProblemImpl(sourceClassName, bundleName, severity, contextStack.toString(), problemObject, messageId, cause);
+ }
+
+ public Problem createProblem(String sourceClassName,
+ String bundleName,
+ Severity severity,
+ Object problemObject,
+ String messageId,
+ Object... messageParams) {
+ return new ProblemImpl(sourceClassName, bundleName, severity, contextStack.toString(), problemObject, messageId, messageParams);
+ }
+
+ public Problem createProblem(String sourceClassName,
+ String bundleName,
+ Severity severity,
+ Object problemObject,
+ String messageId,
+ Throwable cause,
+ Object... messageParams) {
+ return new ProblemImpl(sourceClassName, bundleName, severity, contextStack.toString(), problemObject, messageId, cause, messageParams);
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ @Override
+ public void pushContext(Object context) {
+ contextStack.push(context);
+ }
+
+ @Override
+ public Object popContext() {
+ return contextStack.pop();
+ }
+
+ @Override
+ public void reset() {
+ contextStack.clear();
+ problemCache.clear();
+ artifactName = null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/ProblemImpl.java b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/ProblemImpl.java
new file mode 100644
index 0000000000..acfc409856
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/ProblemImpl.java
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.monitor.impl;
+
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import java.util.logging.SimpleFormatter;
+
+import org.apache.tuscany.sca.monitor.Problem;
+
+/**
+ * Reports a composite assembly problem.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProblemImpl implements Problem {
+
+ private String sourceClassName;
+ private String bundleName;
+ private Severity severity;
+ private String context;
+ private Object problemObject;
+ private String messageId;
+ private Object[] messageParams;
+ private Throwable cause;
+
+ /**
+ * Construct a new problem
+ *
+ * @param sourceClassName the class name reporting the problem
+ * @param bundleName the name of the message bundle to use
+ * @param severity the severity of the problem
+ * @param context the string indicating where the error occurred
+ * @param problemObject the model object for which the problem is being reported
+ * @param messageId the id of the problem message
+ * @param messageParams the parameters of the problem message
+ */
+ public ProblemImpl(String sourceClassName,
+ String bundleName,
+ Severity severity,
+ String context,
+ Object problemObject,
+ String messageId,
+ Object... messageParams) {
+ this.sourceClassName = sourceClassName;
+ this.bundleName = bundleName;
+ this.severity = severity;
+ this.context = context;
+ this.problemObject = problemObject;
+ this.messageId = messageId;
+ this.messageParams = messageParams;
+ }
+
+ /**
+ * Construct a new problem
+ *
+ * @param sourceClassName the class name reporting the problem
+ * @param bundleName the name of the message bundle to use
+ * @param severity the severity of the problem
+ * @param context the string indicating where the error occurred
+ * @param problemObject the model object for which the problem is being reported
+ * @param messageId the id of the problem message
+ * @param messageParams the parameters of the problem message
+ */
+ public ProblemImpl(String sourceClassName,
+ String bundleName,
+ Severity severity,
+ String context,
+ Object problemObject,
+ String messageId,
+ Throwable cause,
+ Object... messageParams) {
+ this.sourceClassName = sourceClassName;
+ this.bundleName = bundleName;
+ this.severity = severity;
+ this.context = context;
+ this.problemObject = problemObject;
+ this.messageId = messageId;
+ this.cause = cause;
+ this.messageParams = messageParams;
+ }
+ /**
+ * Construct a new problem
+ *
+ * @param sourceClassName the class name reporting the problem
+ * @param bundleName the name of the message bundle to use
+ * @param severity the severity of the problem
+ * @param context the string indicating where the error occurred
+ * @param problemObject the model object for which the problem is being reported
+ * @param messageId the id of the problem message
+ * @param cause the exception which caused the problem
+ */
+ public ProblemImpl(String sourceClassName,
+ String bundleName,
+ Severity severity,
+ String context,
+ Object problemObject,
+ String messageId,
+ Throwable cause) {
+ this.sourceClassName = sourceClassName;
+ this.bundleName = bundleName;
+ this.severity = severity;
+ this.context = context;
+ this.problemObject = problemObject;
+ this.messageId = messageId;
+ this.cause = cause;
+ }
+
+ public String getSourceClassName() {
+ return sourceClassName;
+ }
+
+ public String getResourceBundleName() {
+ return bundleName;
+ }
+
+ public Severity getSeverity() {
+ return severity;
+ }
+
+ public String getContext() {
+ return context + " (" + messageId + ")";
+ }
+
+ public Object getProblemObject() {
+ return problemObject;
+ }
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public Object[] getMessageParams() {
+ return messageParams;
+ }
+
+ public Throwable getCause() {
+ return cause;
+ }
+
+ @Override
+ public String toString() {
+ Logger logger = Logger.getLogger(sourceClassName, bundleName);
+
+ LogRecord record = new LogRecord(Level.INFO, messageId);
+
+ if (cause == null) {
+ record.setParameters(messageParams);
+
+ } else {
+ Object[] params = new String[1];
+ params[0] = cause.toString();
+ record.setParameters(params);
+ }
+ record.setResourceBundle(logger.getResourceBundle());
+ record.setSourceClassName(sourceClassName);
+
+ Formatter formatter = new SimpleFormatter();
+
+ return context + " - " + formatter.formatMessage(record);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory b/sandbox/sebastien/java/embed/modules/monitor/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory
new file mode 100644
index 0000000000..f2c2a52e78
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory
@@ -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.
+
+org.apache.tuscany.sca.monitor.DefaultMonitorFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java b/sandbox/sebastien/java/embed/modules/monitor/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java
new file mode 100644
index 0000000000..6e44b2d5d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.monitor;
+
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Loads a monitor and adds some problems to it.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MonitorTestCase {
+
+ private static final String MESSAGES = "org.apache.tuscany.sca.monitor.tuscany-monitor-test-messages";
+ private static MonitorFactory monitorFactory;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ monitorFactory = new DefaultMonitorFactory();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ monitorFactory = null;
+ }
+
+ @Test
+ public void testCreateProblem() throws Exception {
+ String dummyModelObject = "DUMMY MODEL OBJECT";
+
+ Monitor monitor = monitorFactory.createMonitor();
+
+ Problem problem = null;
+
+ problem =
+ monitor.createProblem(this.getClass().getName(),
+ MESSAGES,
+ Severity.WARNING,
+ dummyModelObject,
+ "MESSAGE1");
+ monitor.problem(problem);
+
+ String param = "Some Parameter";
+
+ problem =
+ monitor.createProblem(this.getClass().getName(),
+ MESSAGES,
+ Severity.WARNING,
+ dummyModelObject,
+ "MESSAGE2",
+ param);
+ monitor.problem(problem);
+
+ problem =
+ monitor.createProblem(this.getClass().getName(),
+ MESSAGES,
+ Severity.WARNING,
+ dummyModelObject,
+ "MESSAGE3",
+ 8,
+ 9,
+ 4);
+ monitor.problem(problem);
+
+ Exception ex = new IllegalStateException("TEST_MESSAGE");
+
+ problem =
+ monitor.createProblem(this.getClass().getName(),
+ MESSAGES,
+ Severity.ERROR,
+ dummyModelObject,
+ "MESSAGE4",
+ ex);
+ monitor.problem(problem);
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages.properties b/sandbox/sebastien/java/embed/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages.properties
new file mode 100644
index 0000000000..523263da40
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages.properties
@@ -0,0 +1,24 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+MESSAGE1 = This is a test message with no params
+MESSAGE2 = This is a test message with a string param {0}
+MESSAGE3 = This is a test message with numbers {0}, {1}, {2}
+MESSAGE4 = This is a test message with exception
diff --git a/sandbox/sebastien/java/embed/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages_it.properties b/sandbox/sebastien/java/embed/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages_it.properties
new file mode 100644
index 0000000000..523263da40
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages_it.properties
@@ -0,0 +1,24 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+MESSAGE1 = This is a test message with no params
+MESSAGE2 = This is a test message with a string param {0}
+MESSAGE3 = This is a test message with numbers {0}, {1}, {2}
+MESSAGE4 = This is a test message with exception
diff --git a/sandbox/sebastien/java/embed/modules/myfaces/LICENSE b/sandbox/sebastien/java/embed/modules/myfaces/LICENSE
new file mode 100644
index 0000000000..c77d3fe856
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/myfaces/LICENSE
@@ -0,0 +1,241 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+The module host-webapp includes files under the following license:
+
+Permission to copy, display and distribute the Service Component Architecture Specification and/or
+portions thereof, without modification, in any medium without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the Service Component Architecture Specification, or
+portions thereof, that you make:
+
+1. A link or URL to the Service Component Architecture Specification at this location:
+· http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of the copyright notice as shown in the Service Component Architecture Specification.
+
+BEA, Cape Clear, IBM, Interface21, IONA, Oracle, Primeton, Progress Software, Red Hat, Rogue Wave,
+SAP, Siemens, Software AG., Sun, Sybase, TIBCO (collectively, the "Authors") agree to grant you a
+royalty-free license, under reasonable, non-discriminatory terms and conditions to patents that they deem
+necessary to implement the Service Component Architecture Specification.
+THE Service Component Architecture SPECIFICATION IS PROVIDED "AS IS," AND THE
+AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+REGARDING THIS SPECIFICATION AND THE IMPLEMENTATION OF ITS CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR
+DISTRIBUTION OF THE Service Components Architecture SPECIFICATION.
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+
diff --git a/sandbox/sebastien/java/embed/modules/myfaces/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/myfaces/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..61618e7c8f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/myfaces/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany MyFaces JSF Integration
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA MyFaces JSF Integration
+Import-Package: javax.naming,
+ javax.servlet,
+ javax.faces.context;version="1.2.2",
+ org.apache.myfaces.config.annotation;version="1.2.2",
+ org.apache.myfaces.shared_impl.util;version="1.2.2",
+ org.apache.tuscany.sca.node.impl;version="2.0",
+ org.apache.tuscany.sca.implementation.web.runtime.utils;version="2.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.myfaces
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/myfaces/NOTICE b/sandbox/sebastien/java/embed/modules/myfaces/NOTICE
new file mode 100644
index 0000000000..dfde08644b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/myfaces/NOTICE
@@ -0,0 +1,12 @@
+${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 also includes software under the Service Component Architecture specification license
+(see the LICENSE file contained in this distribution) with the following copyright
+
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/myfaces/pom.xml b/sandbox/sebastien/java/embed/modules/myfaces/pom.xml
new file mode 100644
index 0000000000..9e6f742ce3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/myfaces/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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-myfaces</artifactId>
+ <name>Apache Tuscany SCA MyFaces JSF Integration</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>1.2.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>1.2.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationLifecycleProvider.java b/sandbox/sebastien/java/embed/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationLifecycleProvider.java
new file mode 100644
index 0000000000..b1ef8eb3ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationLifecycleProvider.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.myfaces;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Logger;
+
+import javax.faces.context.ExternalContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletContext;
+
+import org.apache.myfaces.config.annotation.DiscoverableLifecycleProvider;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
+
+public class TuscanyAnnotationLifecycleProvider implements DiscoverableLifecycleProvider {
+ private static final Logger logger = Logger.getLogger(TuscanyAnnotationLifecycleProvider.class.getName());
+
+ private TuscanyAnnotationProcessor annotationProcessor;
+ private ServletContext servletContext;
+
+
+ public TuscanyAnnotationLifecycleProvider(ExternalContext externalContext) {
+ this.servletContext = (ServletContext)externalContext.getContext();
+
+ // TODO: Should this use any existing AnnotationProcessor?
+ // Tomcat based runtimes may use an org.apache.AnnotationProcessor which
+ // if exists this could delegate to so as to support both SCA and other annotations
+ // AnnotationProcessor existingAnnotationProcessor = (AnnotationProcessor)
+ // servletContext.getAttribute(org.apache.AnnotationProcessor.class.getName());
+ // annotationProcessor = new TuscanyAnnotationProcessor(existingAnnotationProcessor);
+ annotationProcessor = new TuscanyAnnotationProcessor();
+ }
+
+ public Object newInstance(String className) throws InstantiationException, IllegalAccessException, InvocationTargetException, NamingException, ClassNotFoundException {
+ logger.info("Creating instance of " + className);
+ Class<?> clazz = ClassUtils.classForName(className);
+ Object object = clazz.newInstance();
+ annotationProcessor.processAnnotations(object, servletContext);
+ annotationProcessor.postConstruct(object);
+ return object;
+ }
+
+ public boolean isAvailable() {
+ return true;
+ }
+
+ public void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException {
+ logger.info("Destroy instance of " + o.getClass().getName());
+ annotationProcessor.preDestroy(o);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationProcessor.java b/sandbox/sebastien/java/embed/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationProcessor.java
new file mode 100644
index 0000000000..4a05fa5856
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationProcessor.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.sca.myfaces;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.naming.NamingException;
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
+
+//public class TuscanyAnnotationProcessor implements org.apache.AnnotationProcessor {
+public class TuscanyAnnotationProcessor {
+
+// private AnnotationProcessor annotationProcessor;
+
+ public TuscanyAnnotationProcessor() {
+ }
+
+ public void postConstruct(Object arg0) throws IllegalAccessException, InvocationTargetException {
+// annotationProcessor.postConstruct(arg0);
+ }
+
+ public void preDestroy(Object arg0) throws IllegalAccessException, InvocationTargetException {
+// annotationProcessor.preDestroy(arg0);
+ }
+
+ public void processAnnotations(Object arg0, ServletContext servletContext) throws IllegalAccessException, InvocationTargetException, NamingException {
+ ContextHelper.inject(arg0, servletContext);
+// annotationProcessor.processAnnotations(arg0);
+ }
+
+ public void processAnnotations(Object arg0) throws IllegalAccessException, InvocationTargetException, NamingException {
+// annotationProcessor.processAnnotations(arg0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/LICENSE b/sandbox/sebastien/java/embed/modules/node-api/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/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/sebastien/java/embed/modules/node-api/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/node-api/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ac89f5383a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.node;version="2.0.0";uses:="org.oasisopen.sca",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Node API
+DynamicImport-Package: org.apache.tuscany.sca.node.impl,org.apache.tus
+ cany.sca.extensibility
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Node API
+Import-Package: org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.node.api
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/node-api/NOTICE b/sandbox/sebastien/java/embed/modules/node-api/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/node-api/pom.xml b/sandbox/sebastien/java/embed/modules/node-api/pom.xml
new file mode 100644
index 0000000000..2de9c088a6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/pom.xml
@@ -0,0 +1,41 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-node-api</artifactId>
+ <name>Apache Tuscany SCA Node API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java
new file mode 100644
index 0000000000..f69e18dc63
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.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.sca.node;
+
+/**
+ * Represents an SCA contribution uri + location.
+ */
+public final class Contribution {
+ private String uri;
+ private String location;
+
+ /**
+ * Constructs a new SCA contribution.
+ *
+ * @param uri The URI that uniquely identifies the contribution in the SCA domain
+ * @param location The URL of the contribution archive
+ */
+ public Contribution(String uri, String location) {
+ this.uri = uri;
+ this.location = location;
+ }
+
+ /**
+ * Get the URI of the contribution
+ * @return The URI that uniquely identifies the contribution in the SCA domain
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * The location of the contribution
+ * @return The URL of the contribution archive
+ */
+ public String getLocation() {
+ return location;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java
new file mode 100644
index 0000000000..2e73322917
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.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.sca.node;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * ContributionLocationHelper
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionLocationHelper {
+
+ /**
+ * Returns the location of the SCA contribution containing the given class.
+ *
+ * @param anchorClass
+ * @return
+ */
+ public static String getContributionLocation(final Class<?> anchorClass) {
+ URL url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return anchorClass.getProtectionDomain().getCodeSource().getLocation();
+ }
+ });
+ String uri = url.toString();
+ return uri;
+ }
+
+ /**
+ * Find the contribution location by seraching a resource on the classpath
+ * @param resourceName
+ * @return
+ */
+ public static String getContributionLocation(String resourceName) {
+ return getContributionLocation(null, resourceName);
+ }
+
+ /**
+ * Find the contribution locations by seraching a resource on the classpath
+ * @param resourceName
+ * @return
+ */
+ public static List<String> getContributionLocations(String resourceName) {
+ return getContributionLocations(null, resourceName);
+
+ }
+
+ /**
+ * Find the contribution location by seraching a resource using the given classloader
+ * @param classLoader
+ * @param resourceName
+ * @return
+ */
+ public static String getContributionLocation(ClassLoader classLoader, String resourceName) {
+ if (classLoader == null) {
+ classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ URL resourceURL = getResource(classLoader, resourceName);
+ if (resourceURL == null) {
+ return null;
+ }
+ return getRootLocation(resourceURL, resourceName);
+ }
+
+ /**
+ * Find the contribution locations by seraching a resource using the given classloader
+ * @param classLoader The classloader that is used to call getResources()
+ * @param resourceName The name of the resource
+ * @return A list of locations that contain the resource
+ */
+ public static List<String> getContributionLocations(ClassLoader classLoader, String resourceName) {
+ if (classLoader == null) {
+ classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ Enumeration<URL> resourceURLs = getResources(classLoader, resourceName);
+ List<String> locations = new ArrayList<String>();
+ while (resourceURLs != null && resourceURLs.hasMoreElements()) {
+ locations.add(getRootLocation(resourceURLs.nextElement(), resourceName));
+ }
+ return locations;
+ }
+
+ private static String getRootLocation(URL resourceURL, String resourceName) {
+ String location = null;
+ // "jar:file://....../something.jar!/a/b/c/app.composite"
+ String url = resourceURL.toExternalForm();
+ String protocol = resourceURL.getProtocol();
+ if ("file".equals(protocol)) {
+ // directory contribution
+ if (url.endsWith(resourceName)) {
+ location = url.substring(0, url.lastIndexOf(resourceName));
+ }
+ } else if ("jar".equals(protocol) || "wsjar".equals(protocol) || "zip".equals(protocol)) {
+ // jar contribution
+ location = url.substring(protocol.length() + 1, url.lastIndexOf("!/"));
+ } else if (url.endsWith(resourceName)) {
+ location = url.substring(0, url.lastIndexOf(resourceName));
+ } else {
+ throw new IllegalArgumentException("The root of the resource cannot be determined: " + resourceURL
+ + ","
+ + resourceName);
+ }
+ return location;
+ }
+
+ private static URL getResource(final ClassLoader classLoader, final String compositeURI) {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return classLoader.getResource(compositeURI);
+ }
+ });
+ }
+
+ private static Enumeration<URL> getResources(final ClassLoader classLoader, final String compositeURI) {
+ return AccessController.doPrivileged(new PrivilegedAction<Enumeration<URL>>() {
+ public Enumeration<URL> run() {
+ try {
+ return classLoader.getResources(compositeURI);
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ });
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
new file mode 100644
index 0000000000..502b2f854c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node;
+
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.oasisopen.sca.ServiceReference;
+
+
+
+
+/**
+ * Represents an SCA processing node.
+ * A node is loaded with an SCA composites. It can start and stop that composite.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface Node {
+ String DEFAULT_DOMAIN_URI = NodeConfiguration.DEFAULT_DOMAIN_URI;
+ String DEFAULT_NODE_URI = NodeConfiguration.DEFAULT_NODE_URI;
+ /**
+ * Start the composite loaded in the node.
+ * @return Return the node itself so that we can call NodeFactory.newInstance().createNode(...).start()
+ */
+ Node start();
+
+ /**
+ * Stop the composite loaded in the node.
+ */
+ void stop();
+
+ /**
+ * Cast a type-safe reference to a CallableReference. Converts a type-safe
+ * reference to an equivalent CallableReference; if the target refers to a
+ * service then a ServiceReference will be returned, if the target refers to
+ * a callback then a CallableReference will be returned.
+ *
+ * @param target a reference proxy provided by the SCA runtime
+ * @param <B> the Java type of the business interface for the reference
+ * @param <R> the type of reference to be returned
+ * @return a CallableReference equivalent for the proxy
+ * @throws IllegalArgumentException if the supplied instance is not a
+ * reference supplied by the SCA runtime
+ */
+ <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException;
+
+ /**
+ * Returns a proxy for a service provided by a component in the SCA domain.
+ *
+ * @param businessInterface the interface that will be used to invoke the
+ * service
+ * @param serviceName the name of the service
+ * @param <B> the Java type of the business interface for the service
+ * @return an object that implements the business interface
+ */
+ <B> B getService(Class<B> businessInterface, String serviceName);
+
+ /**
+ * Returns a ServiceReference for a service provided by a component in the
+ * SCA domain.
+ *
+ * @param businessInterface the interface that will be used to invoke the
+ * service
+ * @param serviceName the name of the service
+ * @param <B> the Java type of the business interface for the service
+ * @return a ServiceReference for the designated service
+ */
+ <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String serviceName);
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
new file mode 100644
index 0000000000..2d2df84f42
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
@@ -0,0 +1,623 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node;
+
+import static org.apache.tuscany.sca.node.ContributionLocationHelper.getContributionLocations;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.node.configuration.DefaultNodeConfigurationFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * A factory for SCA processing nodes. An SCA processing node can be loaded
+ * with an SCA composite and the SCA contributions required by the composite.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public abstract class NodeFactory extends DefaultNodeConfigurationFactory {
+ /**
+ * Default location of contribution metadata in an SCA contribution.
+ */
+ private static final String SCA_CONTRIBUTION_META = "META-INF/sca-contribution.xml";
+
+ /**
+ * Default location of a generated contribution metadata in an SCA contribution.
+ */
+ private static final String SCA_CONTRIBUTION_GENERATED_META = "META-INF/sca-contribution-generated.xml";
+
+ protected static NodeFactory instance;
+ protected static Class<?> factoryImplClass;
+
+ protected static List<NodeFactory> factories = new ArrayList<NodeFactory>();
+
+ protected static void setNodeFactory(NodeFactory factory) {
+ instance = factory;
+ }
+
+ public static class NodeProxy implements Node {
+ private Object node;
+
+ private NodeProxy(Object node) {
+ super();
+ this.node = node;
+ }
+
+ public static <T> T createProxy(Class<T> type, Object node) {
+ try {
+ return type.getDeclaredConstructor(Object.class).newInstance(node);
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
+ try {
+ return (R)node.getClass().getMethod("cast", Object.class).invoke(node, target);
+ } catch (Throwable e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ try {
+ return (B)node.getClass().getMethod("getService", Class.class, String.class).invoke(node, businessInterface, serviceName);
+ } catch (Throwable e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String serviceName) {
+ try {
+ return (ServiceReference<B>)node.getClass().getMethod("getServiceReference", Class.class, String.class).invoke(node, businessInterface, serviceName);
+ } catch (Throwable e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public Node start() {
+ try {
+ return new NodeProxy(node.getClass().getMethod("start").invoke(node));
+ } catch (Throwable e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public void stop() {
+ try {
+ node.getClass().getMethod("stop").invoke(node);
+ } catch (Throwable e) {
+ handleException(e);
+ }
+ }
+
+ public void destroy() {
+ try {
+ node.getClass().getMethod("destroy").invoke(node);
+ } catch (Throwable e) {
+ handleException(e);
+ }
+ }
+
+ private static void handleException(Throwable ex) {
+ if (ex instanceof InvocationTargetException) {
+ ex = ((InvocationTargetException)ex).getTargetException();
+ }
+ if (ex instanceof RuntimeException) {
+ throw (RuntimeException)ex;
+ }
+ if (ex instanceof Error) {
+ throw (Error)ex;
+ } else {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ }
+
+ /**
+ * Returns the SCA node factory instance.
+ *
+ * @return the SCA node factory
+ */
+ public synchronized static NodeFactory getInstance() {
+ if (instance == null) {
+ instance = newInstance();
+ }
+ return instance;
+ }
+
+ /**
+ * Returns a new SCA node factory instance.
+ *
+ * @return a new SCA node factory
+ */
+ public static NodeFactory newInstance() {
+ NodeFactory nodeFactory = null;
+ try {
+ Class<?> factoryClass = getFactoryImplClass();
+ nodeFactory = (NodeFactory)factoryClass.newInstance();
+
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ factories.add(nodeFactory);
+ return nodeFactory;
+ }
+
+ public static NodeFactory newInstance(Map<String, Map<String, String>> attributes) {
+ NodeFactory nodeFactory = null;
+ try {
+ Class<?> factoryClass = getFactoryImplClass();
+ nodeFactory = (NodeFactory)factoryClass.newInstance();
+ nodeFactory.configure(attributes);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ factories.add(nodeFactory);
+ return nodeFactory;
+ }
+
+ protected Properties properties;
+
+ protected NodeFactory() {
+ this.properties = new Properties();
+ properties.setProperty("defaultScheme", "vm");
+ properties.setProperty("defaultDomainName", "default");
+ }
+
+ public static NodeFactory newInstance(Properties configProperties) {
+ NodeFactory nodeFactory = null;
+ try {
+ Class<?> factoryClass = getFactoryImplClass();
+ nodeFactory = (NodeFactory)factoryClass.newInstance();
+ nodeFactory.properties = configProperties;
+ nodeFactory.configure(new HashMap<String, Map<String,String>>());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ factories.add(nodeFactory);
+ return nodeFactory;
+ }
+
+ public static NodeFactory newInstance(String configURI) {
+ Properties properties;
+ if (configURI == null || configURI.length() < 1) {
+ return newInstance();
+ } else if (configURI.startsWith("properties:")) {
+ try {
+ properties = loadProperties(configURI.substring("properties:".length()));
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ } else if (configURI.startsWith("uri:")) {
+ properties = parseConfigURI(configURI.substring("uri:".length()));
+ } else {
+ properties = new Properties();
+ properties.setProperty("defaultDomainName", configURI);
+ }
+ return newInstance(properties);
+ }
+
+ /**
+ * Parse the config string into a Properties object.
+ * The config URI has the following format:
+ * uri:<domainName>?name=value&...
+ */
+ private static Properties parseConfigURI(String configURI) {
+ Properties properties = new Properties();
+ int qm = configURI.indexOf('?');
+ if (qm < 0) {
+ properties.setProperty("defaultDomainName", configURI);
+ } else {
+ if (qm == 0) {
+ properties.setProperty("defaultDomainName", "default");
+ } else {
+ properties.setProperty("defaultDomainName", configURI.substring(0, qm));
+ }
+ if (configURI.length() > qm+1) {
+ Map<String, String> params = new HashMap<String, String>();
+ for (String param : configURI.substring(qm+1).split("&")) {
+ String[] px = param.split("=");
+ if (px.length == 2) {
+ params.put(px[0], px[1]);
+ } else {
+ params.put(px[0], "");
+ }
+ }
+ for (String name : params.keySet()) {
+ properties.setProperty(name, params.get(name));
+ }
+ }
+ }
+ return properties;
+ }
+
+ /**
+ * load the properties from external URL or a relative file
+ * properties:<url to properties file>
+ */
+ private static Properties loadProperties(String propsURL) throws IOException {
+
+ Properties properties = new Properties();
+ File file = new File(propsURL);
+
+ InputStream inputStream = null;
+ if (file.exists()) {
+ inputStream = new FileInputStream(file);
+ } else {
+ URL url = null;
+ try {
+ url = new URL(propsURL);
+ } catch (MalformedURLException e) {
+ inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(propsURL);
+ if (inputStream == null) {
+ throw new IOException("File does not exist: " + propsURL + ", could not be found on the classpath and is not a valid URL: " + e);
+ }
+ }
+ if (inputStream == null && url != null) {
+ inputStream = url.openStream();
+ }
+ }
+ if (inputStream != null) {
+ properties.load(inputStream);
+ inputStream.close();
+ }
+
+ return properties;
+ }
+
+ /**
+ * Configure the NodeFactory instance
+ * @param attributes
+ */
+ public void configure(Map<String, Map<String, String>> attributes) {
+ }
+
+ private synchronized static Class<?> getFactoryImplClass() throws Exception {
+ if (factoryImplClass == null) {
+ // Use reflection APIs to call ServiceDiscovery to avoid hard dependency to tuscany-extensibility
+ try {
+ Class<?> discoveryClass = Class.forName("org.apache.tuscany.sca.extensibility.ServiceDiscovery");
+ Object instance = discoveryClass.getMethod("getInstance").invoke(null);
+ Object factoryDeclaration =
+ discoveryClass.getMethod("getServiceDeclaration", Class.class).invoke(instance, NodeFactory.class);
+ if (factoryDeclaration != null) {
+ factoryImplClass =
+ (Class<?>)factoryDeclaration.getClass().getMethod("loadClass").invoke(factoryDeclaration);
+ }
+ } catch (ClassNotFoundException e) {
+ // Ignore
+ }
+
+ if (factoryImplClass == null) {
+ // Fail back to default impl
+ String className = "org.apache.tuscany.sca.node.impl.NodeFactoryImpl";
+
+ factoryImplClass = Class.forName(className);
+ }
+ }
+ return factoryImplClass;
+ }
+
+ /**
+ * Open a URL connection without cache
+ * @param url
+ * @return
+ * @throws IOException
+ */
+ private static InputStream openStream(URL url) throws IOException {
+ InputStream is = null;
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ is = connection.getInputStream();
+ return is;
+ }
+
+ /**
+ * Escape the space in URL string
+ * @param uri
+ * @return
+ */
+ private static URI createURI(String uri) {
+ int index = uri.indexOf(':');
+ String scheme = null;
+ String ssp = uri;
+ if (index != -1) {
+ scheme = uri.substring(0, index);
+ ssp = uri.substring(index + 1);
+ }
+ try {
+ return new URI(scheme, ssp, null);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Creates a new SCA node from the configuration URL
+ *
+ * @param configurationURL the URL of the node configuration which is the XML document
+ * that contains the URI of the composite and a collection of URLs for the contributions
+ *
+ * @return a new SCA node.
+ */
+ public Node createNode(URL configurationURL) {
+ try {
+ InputStream is = openStream(configurationURL);
+ NodeConfiguration configuration = loadConfiguration(is, configurationURL);
+ return createNode(configuration);
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Creates a new SCA node from the XML configuration of the node
+ * @param is The input stream that the XML configuration can be read. The stream will be closed
+ * after this call.
+ * @return a new SCA node
+ */
+ public Node createNode(InputStream is) {
+ NodeConfiguration configuration = loadConfiguration(is, null);
+ return createNode(configuration);
+ }
+
+ /**
+ * Creates a new SCA node.
+ *
+ * @param deploymentCompositeURI the URI of the deployment composite. If the URI is relative, it should
+ * be resolved against the first contribution. Otherwise, the absolute URI is used to load the XML
+ * description of the composite. The deployment composite will be attached to the first contribution.
+ *
+ * @param contributions the URI of the contributions that provides the composites and related
+ * artifacts. If the list is empty, then we will use the thread context classloader to discover
+ * the contribution on the classpath
+ *
+ * @return a new SCA node.
+ */
+ public Node createNode(String deploymentCompositeURI, Contribution... contributions) {
+ if (contributions == null || contributions.length == 0) {
+ if (deploymentCompositeURI == null || deploymentCompositeURI.indexOf(':') != -1) {
+ throw new ServiceRuntimeException("No SCA contribution is provided or discovered");
+ }
+ // Try to find contributions on the classpath by the composite URI
+ List<String> locations = getContributionLocations(null, deploymentCompositeURI);
+ if (locations.isEmpty()) {
+ throw new ServiceRuntimeException("No SCA contributions are found on the classpath");
+ }
+ contributions = getContributions(locations);
+ }
+ NodeConfiguration configuration = createConfiguration(contributions);
+ if (deploymentCompositeURI != null && configuration.getContributions().size() > 0) {
+ configuration.getContributions().get(0).addDeploymentComposite(createURI(deploymentCompositeURI));
+ }
+ return createNode(configuration);
+ }
+
+ public final Node createNode(URI domainRegistryURI, String... locations) {
+ return createNode(domainRegistryURI, null, locations);
+ }
+
+ public final Node createNode(URI domainRegistryURI, String deploymentCompositeURI, String[] locations) {
+ Contribution[] contributions = getContributions(Arrays.asList(locations));
+ NodeConfiguration configuration = createConfiguration(contributions);
+ if (deploymentCompositeURI != null && configuration.getContributions().size() > 0) {
+ configuration.getContributions().get(0).addDeploymentComposite(createURI(deploymentCompositeURI));
+ }
+ configuration.setDomainRegistryURI(domainRegistryURI.toString());
+ configuration.setDomainURI(getDomainURI(domainRegistryURI));
+ return createNode(configuration);
+ }
+
+ /**
+ * TODO: cleanup node use of registry uri, domain uri, and domain name
+ * so that its consistent across the code base
+ */
+ public static String getDomainURI(URI configURI) {
+ String s = configURI.getHost();
+ if (s == null) {
+ s = configURI.getSchemeSpecificPart();
+ if (s != null) {
+ if (s.indexOf('?') > -1) {
+ s = s.substring(0, s.indexOf('?'));
+ }
+ }
+ }
+ return s;
+ }
+
+ /**
+ * The following methods are used by the node launcher
+ */
+ public final Node createNode(String deploymentCompositeURI, String[] uris, String locations[]) {
+ return createNode(deploymentCompositeURI, getContributions(Arrays.asList(uris), Arrays.asList(locations)));
+ }
+
+ public final Node createNode(String deploymentCompositeURI, String locations[]) {
+ return createNode(deploymentCompositeURI, getContributions(Arrays.asList(locations)));
+ }
+
+ public final Node createNode(Reader deploymentCompositeContent, String[] uris, String locations[]) {
+ return createNode(deploymentCompositeContent, getContributions(Arrays.asList(uris), Arrays.asList(locations)));
+ }
+
+ public final Node createNode(String compositeURI, ClassLoader classLoader) {
+ List<String> locations = ContributionLocationHelper.getContributionLocations(classLoader, compositeURI);
+ return createNode(compositeURI, locations.toArray(new String[locations.size()]));
+ }
+ /**
+ * ------------------- end of methods -----------------
+ */
+
+ /**
+ * Create a new SCA node using the list of SCA contributions
+ * @param contributions
+ * @return
+ */
+ public Node createNode(Contribution... contributions) {
+ NodeConfiguration configuration = createConfiguration(contributions);
+ return createNode(configuration);
+ }
+
+
+ /**
+ * Creates a new SCA node.
+ *
+ * @param compositeContent the XML content of the deployment composite
+ * @param contributions the URI of the contributions that provides the composites and related artifacts
+ * @return a new SCA node.
+ */
+ public Node createNode(InputStream compositeContent, Contribution... contributions) {
+ NodeConfiguration configuration = createConfiguration(contributions);
+ if (compositeContent != null && configuration.getContributions().size() > 0) {
+ configuration.getContributions().get(0).addDeploymentComposite(compositeContent);
+ }
+ return createNode(configuration);
+ }
+
+ /**
+ * Creates a new SCA node.
+ *
+ * @param compositeContent the XML content of the deployment composite
+ * @param contributions the URI of the contributions that provides the composites and related artifacts
+ * @return a new SCA node.
+ */
+ public Node createNode(Reader compositeContent, Contribution... contributions) {
+ NodeConfiguration configuration = createConfiguration(contributions);
+ if (compositeContent != null && configuration.getContributions().size() > 0) {
+ configuration.getContributions().get(0).addDeploymentComposite(compositeContent);
+ }
+ return createNode(configuration);
+ }
+
+ /**
+ * Creates a new SCA node using defaults for the contribution location and deployable composites.
+ * By default, it uses the Thread context classloader to find META-INF/sca-contribution.xml or
+ * META-INF/sca-contribution-generated.xml on the classpath. The locations that contain such resources
+ * are taken as the SCA contributions.
+ *
+ * @return a new SCA node.
+ */
+ public Node createNode() {
+ List<String> locations = new ArrayList<String>();
+ locations.addAll(getContributionLocations(null, SCA_CONTRIBUTION_META));
+ locations.addAll(getContributionLocations(null, SCA_CONTRIBUTION_GENERATED_META));
+ if (locations.isEmpty()) {
+ throw new ServiceRuntimeException("No SCA contributions are found on the classpath");
+ }
+ Contribution[] contributions = getContributions(locations);
+ return createNode(contributions);
+ }
+
+ private NodeConfiguration createConfiguration(Contribution... contributions) {
+ NodeConfigurationFactory factory = this;
+ NodeConfiguration configuration = factory.createNodeConfiguration();
+ if (properties.getProperty("defaultDomainName") != null) {
+ configuration.setDomainURI(properties.getProperty("defaultDomainName"));
+ }
+ // Make sure a unique node URI is created for the same node factory
+ configuration.setURI(generateNodeURI());
+ if (contributions != null) {
+ for (Contribution c : contributions) {
+ configuration.addContribution(c.getURI(), c.getLocation());
+ }
+ }
+ return configuration;
+ }
+
+ private static int count = 0;
+
+ protected synchronized String generateNodeURI() {
+ return Node.DEFAULT_NODE_URI + (count++);
+ }
+
+ private Contribution[] getContributions(List<String> locations) {
+ Contribution[] contributions = new Contribution[locations.size()];
+ int index = 0;
+ for (String location : locations) {
+ contributions[index++] = new Contribution(location, location);
+ }
+ return contributions;
+ }
+
+ private Contribution[] getContributions(List<String> uris, List<String> locations) {
+ if (uris.size() != locations.size()) {
+ throw new IllegalArgumentException("The number of URIs does not match the number of locations");
+ }
+ Contribution[] contributions = new Contribution[locations.size()];
+ for (int i = 0, n = locations.size(); i < n; i++) {
+ contributions[i] = new Contribution(uris.get(i), locations.get(i));
+ }
+ return contributions;
+ }
+
+ public void destroy() {
+ count = 0;
+ instance = null;
+ factories.remove(this);
+ }
+
+ public static List<NodeFactory> getNodeFactories() {
+ return factories;
+ }
+
+ /**
+ * Create a new SCA node based on the configuration
+ * @param configuration The configuration of a node
+ * @return The SCA node
+ */
+ public abstract Node createNode(NodeConfiguration configuration);
+
+ /**
+ * Create the node configuration from the XML document
+ * @param configuration The input stream of the XML document
+ * @return The node configuration
+ */
+ public abstract NodeConfiguration loadConfiguration(InputStream xml, URL base);
+
+ public abstract <T> T getExtensionPointRegistry();
+
+ public abstract void init();
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.java
new file mode 100644
index 0000000000..c42bacdd00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+import java.io.File;
+
+public class NodeMain2 {
+
+ /**
+ * Start an SCA node
+ * @param args a list of contribution jars for the node to run
+ */
+ public static void main(String[] args) throws Exception {
+
+ Contribution[] contributions = new Contribution[args.length];
+ for (int i = 0; i < args.length; i++) {
+ File f = new File(args[i]);
+ if (!f.exists()) {
+ System.err.println("contribution not found: " + f);
+ System.exit(1);
+ }
+ contributions[i] = new Contribution(f.toURI().toString(), f.toURI().toString());
+ }
+
+ Node node = NodeFactory.newInstance().createNode(contributions).start();
+
+ System.out.println("Hit enter to stop node...");
+ if (System.in.read() == -1) {
+ // no sysin so wait for ever letting caller do the terminate
+ Object lock = new Object();
+ synchronized (lock) {
+ lock.wait();
+ }
+ }
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
new file mode 100644
index 0000000000..a6dab059a3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.configuration;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Configuration for bindings used by an SCA node
+ */
+public interface BindingConfiguration {
+ /**
+ * Get the QName of the binding type
+ * @return the QName of the binding type
+ */
+ QName getBindingType();
+
+ /**
+ * Set the type of the binding
+ * @param type The QName of the binding type
+ */
+ BindingConfiguration setBindingType(QName type);
+
+ /**
+ * Get a list of base URIs for the binding. For each protocol supported by the binding,
+ * one base URI can be configured
+ * @return A list of base URIs
+ */
+ List<String> getBaseURIs();
+
+ /**
+ * Add a base URI
+ * @param baseURI
+ * @return
+ */
+ BindingConfiguration addBaseURI(String baseURI);
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
new file mode 100644
index 0000000000..05c718dbd0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.configuration;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * Configuration for an SCA contribution used by the SCA node
+ */
+public interface ContributionConfiguration {
+ /**
+ * Get the URI of the contribution
+ * @return The URI of the contribution
+ */
+ String getURI();
+
+ /**
+ * Set the URI of the contribution
+ * @param uri The URI of the contribution
+ */
+ ContributionConfiguration setURI(String uri);
+
+ /**
+ * Get the location of the contribution
+ * @return The location of the contribution
+ */
+ String getLocation();
+
+ /**
+ * Set the location of the contribution
+ * @param location The location of the contribution
+ */
+ ContributionConfiguration setLocation(String location);
+
+ /**
+ * Get the list of deployment composites that are attached to the contribution
+ * @return A list of deployment composites
+ */
+ List<DeploymentComposite> getDeploymentComposites();
+
+ /**
+ * Add a deployment composite to this contribution
+ * @param deploymentComposite The deployment composite
+ * @return
+ */
+ ContributionConfiguration addDeploymentComposite(DeploymentComposite deploymentComposite);
+
+ /**
+ * Create a deployment composite and add it to the contribution configuration
+ * @param location The location is either relative to the contribution or
+ * @return
+ */
+ ContributionConfiguration addDeploymentComposite(URI location);
+
+ /**
+ * Attach a deployment composite to this contribution
+ * @param location
+ * @return
+ */
+ ContributionConfiguration addDeploymentComposite(URL location);
+
+ /**
+ * Attach a deployment composite to this contribution
+ * @param content The string that contains the XML description of the SCA composite
+ * @return
+ */
+ ContributionConfiguration addDeploymentComposite(String content);
+
+ /**
+ * Attach a deployment composite to this contribution
+ * @param content The XML description of the SCA composite from a reader
+ * @return
+ */
+ ContributionConfiguration addDeploymentComposite(Reader content);
+ /**
+ * Attach a deployment composite to this contribution
+ * @param content The XML description of the SCA composite from an input stream
+ * @return
+ */
+ ContributionConfiguration addDeploymentComposite(InputStream content);
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java
new file mode 100644
index 0000000000..a23cef7e81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.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.sca.node.configuration;
+
+import org.apache.tuscany.sca.node.configuration.impl.NodeConfigurationFactoryImpl;
+
+/**
+ * Default NodeConfigurationFactory
+ */
+public class DefaultNodeConfigurationFactory implements NodeConfigurationFactory {
+ private NodeConfigurationFactory factory = new NodeConfigurationFactoryImpl();
+
+ public BindingConfiguration createBindingConfiguration() {
+ return factory.createBindingConfiguration();
+ }
+
+ public ContributionConfiguration createContributionConfiguration() {
+ return factory.createContributionConfiguration();
+ }
+
+ public DeploymentComposite createDeploymentComposite() {
+ return factory.createDeploymentComposite();
+ }
+
+ public NodeConfiguration createNodeConfiguration() {
+ return factory.createNodeConfiguration();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
new file mode 100644
index 0000000000..18fecf8044
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.configuration;
+
+
+/**
+ * Configuration for a deployment composite
+ */
+public interface DeploymentComposite {
+ /**
+ * Get the location of the deployment composite, it can be relative to the owning
+ * contribution or an external resource
+ * @return
+ */
+ String getLocation();
+
+ /**
+ * Set the location of the deployment composite
+ * @param location
+ */
+ DeploymentComposite setLocation(String location);
+
+ /**
+ * Get string content of the deployment composite (XML)
+ * @return
+ */
+ String getContent();
+
+ /**
+ * Set the XML content for the composite
+ * @param compositeXML
+ */
+ DeploymentComposite setContent(String compositeXML);
+
+ /**
+ * Get the URI of the contribution that the deployment composite is attached to
+ * @return the URI of the contribution that the deployment composite is attached to
+ */
+ String getContributionURI();
+
+ /**
+ * Set the URI of the contribution that the deployment composite is attached to
+ * @param contributionURI
+ */
+ DeploymentComposite setContributionURI(String contributionURI);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
new file mode 100644
index 0000000000..12c6994dda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.configuration;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The configuration for a Node which represents the deployment of an SCA composite application
+ * @tuscany.spi.extension.asclient
+ */
+public interface NodeConfiguration {
+ String DEFAULT_DOMAIN_URI = "default";
+ String DEFAULT_NODE_URI = "http://tuscany.apache.org/sca/1.1/nodes/default";
+ String DEFAULT_DOMAIN_REGISTRY_URI = "default";
+
+ /**
+ * Get the URI of the SCA domain that manages the composite application
+ * @return The URI of the SCA domain
+ */
+ String getDomainURI();
+
+ /**
+ * Set the URI of the SCA domain
+ * @param domainURI The URI of the SCA domain
+ */
+ NodeConfiguration setDomainURI(String domainURI);
+
+ /**
+ * Return the URI of the domain registry
+ * @return
+ */
+ String getDomainRegistryURI();
+
+ /**
+ * Set the URI of the domain registry
+ * @param domainRegistryURI The URI of the domain registry. The scheme will be used
+ * by Tusany to choose the implementation of DomainRegistry interface. Examples are:
+ * <ul>
+ * <li>vm://localhost (a JVM local registry)
+ * <li>multicast://228.0.0.100:50000?timeout=50 (Tomcat Tribes multicast based registry)
+ * </ul>
+ * @return The NodeConfiguration
+ */
+ NodeConfiguration setDomainRegistryURI(String domainRegistryURI);
+
+ /**
+ * Get the URI of the node. It uniquely identifies a node within the SCA domain
+ * @return The URI of the node
+ */
+ String getURI();
+
+ /**
+ * Set the URI of the node
+ * @param uri The URI of the node
+ */
+ NodeConfiguration setURI(String uri);
+
+ /**
+ * Get a list of confiurations for SCA contributions
+ * @return A list of configurations for SCA contributions
+ */
+ List<ContributionConfiguration> getContributions();
+
+ /**
+ * Get a list of configurations for SCA bindings
+ * @return A list of configurations for SCA bindings
+ */
+ List<BindingConfiguration> getBindings();
+
+ NodeConfiguration addContribution(ContributionConfiguration contribution);
+ NodeConfiguration addContribution(String contributionURI, String location);
+ NodeConfiguration addContribution(String contributionURI, URL location);
+ NodeConfiguration addContribution(URI contributionURI, URL location);
+ NodeConfiguration addContribution(URL...location);
+
+ NodeConfiguration addDeploymentComposite(String contributionURI, String location);
+ NodeConfiguration addDeploymentComposite(String contributionURI, Reader content);
+ NodeConfiguration addDeploymentComposite(String contributionURI, InputStream content);
+
+ NodeConfiguration addBinding(BindingConfiguration binding);
+ NodeConfiguration addBinding(QName bindingType, String...baseURIs);
+ NodeConfiguration addBinding(QName bindingType, URI...baseURIs);
+
+ List<Object> getExtensions();
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
new file mode 100644
index 0000000000..71833bc7e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.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.node.configuration;
+
+
+/**
+ * The factory to create java models related to the node configuration
+ */
+public interface NodeConfigurationFactory {
+ /**
+ * Create a new instance of NodeConfiguration
+ * @return
+ */
+ NodeConfiguration createNodeConfiguration();
+
+ /**
+ * Create a new instance of ContributionConfiguration
+ * @return
+ */
+ ContributionConfiguration createContributionConfiguration();
+
+ /**
+ * Create a new instance of BindingConfiguration
+ * @return
+ */
+ BindingConfiguration createBindingConfiguration();
+
+ /**
+ * Create a new instance of DeploymentComposite
+ * @return
+ */
+ DeploymentComposite createDeploymentComposite();
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
new file mode 100644
index 0000000000..5658187c4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.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.sca.node.configuration.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+
+/**
+ * Default implementation of BindingConfiguration
+ */
+public class BindingConfigurationImpl implements BindingConfiguration {
+ private QName type;
+ private List<String> baseURIs = new ArrayList<String>();
+
+ public List<String> getBaseURIs() {
+ return baseURIs;
+ }
+
+ public QName getBindingType() {
+ return type;
+ }
+
+ public BindingConfiguration setBindingType(QName type) {
+ this.type = type;
+ return this;
+ }
+
+ public BindingConfiguration addBaseURI(String baseURI) {
+ baseURIs.add(baseURI);
+ return this;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
new file mode 100644
index 0000000000..5229801731
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.configuration.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+
+/**
+ * Configuration for an SCA contribution used by the SCA node
+ */
+public class ContributionConfigurationImpl implements ContributionConfiguration {
+ private List<DeploymentComposite> deploymentComposites = new ArrayList<DeploymentComposite>();
+ private String uri;
+ private String location;
+
+ public ContributionConfigurationImpl() {
+ super();
+ }
+
+ public ContributionConfigurationImpl(String uri, String location) {
+ super();
+ this.uri = uri;
+ this.location = location;
+ }
+
+ public ContributionConfigurationImpl(String location) {
+ super();
+ this.uri = location;
+ this.location = location;
+ }
+
+ /**
+ * Get the URI of the contribution
+ * @return The URI of the contribution
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Set the URI of the contribution
+ * @param uri The URI of the contribution
+ */
+ public ContributionConfiguration setURI(String uri) {
+ this.uri = uri;
+ return this;
+ }
+
+ /**
+ * Get the location of the contribution
+ * @return The location of the contribution
+ */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * Set the location of the contribution
+ * @param location The location of the contribution
+ */
+ public ContributionConfiguration setLocation(String location) {
+ this.location = location;
+ return this;
+ }
+
+ /**
+ * Get the list of deployment composites that are attached to the contribution
+ * @return
+ */
+ public List<DeploymentComposite> getDeploymentComposites() {
+ return deploymentComposites;
+ }
+
+ public ContributionConfiguration addDeploymentComposite(DeploymentComposite deploymentComposite) {
+ deploymentComposites.add(deploymentComposite);
+ if (uri != null) {
+ deploymentComposite.setContributionURI(uri);
+ }
+ return this;
+ }
+
+ public ContributionConfiguration addDeploymentComposite(Reader reader) {
+ try {
+ DeploymentComposite composite = new DeploymentCompositeImpl();
+ char[] buf = new char[8192];
+ StringWriter sw = new StringWriter();
+ int size = 0;
+ while (size >= 0) {
+ size = reader.read(buf);
+ if (size > 0) {
+ sw.write(buf, 0, size);
+ }
+ }
+ reader.close();
+ composite.setContent(sw.toString());
+ return addDeploymentComposite(composite);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public ContributionConfiguration addDeploymentComposite(InputStream content) {
+ try {
+ InputStreamReader reader = new InputStreamReader(content, "UTF-8");
+ return addDeploymentComposite(reader);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public ContributionConfiguration addDeploymentComposite(String content) {
+ DeploymentComposite composite = new DeploymentCompositeImpl();
+ composite.setContent(content);
+ return addDeploymentComposite(composite);
+ }
+
+ public ContributionConfiguration addDeploymentComposite(URI location) {
+ DeploymentComposite composite = new DeploymentCompositeImpl();
+ composite.setLocation(location.toString());
+ return addDeploymentComposite(composite);
+ }
+
+ public ContributionConfiguration addDeploymentComposite(URL location) {
+ DeploymentComposite composite = new DeploymentCompositeImpl();
+ composite.setLocation(location.toString());
+ return addDeploymentComposite(composite);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
new file mode 100644
index 0000000000..a161b426e7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.configuration.impl;
+
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+
+/**
+ * Configuration for a deployment composite
+ */
+public class DeploymentCompositeImpl implements DeploymentComposite {
+ private String location;
+ private String content;
+ private String contributionURI;
+
+ public String getLocation() {
+ return location;
+ }
+
+ public DeploymentComposite setLocation(String location) {
+ this.location = location;
+ return this;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public DeploymentComposite setContent(String content) {
+ this.content = content;
+ return this;
+ }
+
+ public String getContributionURI() {
+ return contributionURI;
+ }
+
+ public DeploymentComposite setContributionURI(String contributionURI) {
+ this.contributionURI = contributionURI;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "DeploymentCompositeImpl [contributionURI=" + contributionURI + ", location=" + location + "]";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
new file mode 100644
index 0000000000..86096c9aee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.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.sca.node.configuration.impl;
+
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+
+/**
+ * The factory to create java models related to the node configuration
+ */
+public class NodeConfigurationFactoryImpl implements NodeConfigurationFactory {
+ /**
+ * Create a new instance of NodeConfiguration
+ * @return
+ */
+ public NodeConfiguration createNodeConfiguration() {
+ return new NodeConfigurationImpl();
+ }
+
+ /**
+ * Create a new instance of ContributionConfiguration
+ * @return
+ */
+ public ContributionConfiguration createContributionConfiguration() {
+ return new ContributionConfigurationImpl();
+ }
+
+ /**
+ * Create a new instance of BindingConfiguration
+ * @return
+ */
+ public BindingConfiguration createBindingConfiguration() {
+ return new BindingConfigurationImpl();
+ }
+
+ /**
+ * Create a new instance of DeploymentComposite
+ * @return
+ */
+ public DeploymentComposite createDeploymentComposite() {
+ return new DeploymentCompositeImpl();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
new file mode 100644
index 0000000000..b4ec05cae5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.configuration.impl;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+
+/**
+ * Default implementation of NodeConfiguration
+ */
+public class NodeConfigurationImpl implements NodeConfiguration {
+ private String uri = DEFAULT_NODE_URI;
+ private String domainURI = DEFAULT_DOMAIN_URI;
+ private String domainRegistryURI = DEFAULT_DOMAIN_REGISTRY_URI;
+ private List<ContributionConfiguration> contributions = new ArrayList<ContributionConfiguration>();
+ private List<BindingConfiguration> bindings = new ArrayList<BindingConfiguration>();
+ private List<Object> extensions = new ArrayList<Object>();
+
+ public String getURI() {
+ return uri;
+ }
+
+ public NodeConfiguration setURI(String uri) {
+ this.uri = uri;
+ return this;
+ }
+
+ public String getDomainURI() {
+ return domainURI;
+ }
+
+ public NodeConfiguration setDomainURI(String domainURI) {
+ this.domainURI = domainURI;
+ return this;
+ }
+
+ public List<ContributionConfiguration> getContributions() {
+ return contributions;
+ }
+
+ public List<BindingConfiguration> getBindings() {
+ return bindings;
+ }
+
+ public NodeConfiguration addBinding(BindingConfiguration bindingConfiguration) {
+ for (BindingConfiguration bc : bindings) {
+ // Try to merge first by QName
+ if (bc.getBindingType().equals(bindingConfiguration.getBindingType())) {
+ bc.getBaseURIs().addAll(bindingConfiguration.getBaseURIs());
+ return this;
+ }
+ }
+ bindings.add(bindingConfiguration);
+ return this;
+ }
+
+ public NodeConfiguration addContribution(ContributionConfiguration contributionConfiguration) {
+ contributions.add(contributionConfiguration);
+ return this;
+ }
+
+ public NodeConfiguration addBinding(QName bindingType, String... baseURIs) {
+ BindingConfiguration binding = new BindingConfigurationImpl().setBindingType(bindingType);
+ for (String u : baseURIs) {
+ String[] uris = u.split("(\\s)+");
+ for (String uri : uris) {
+ if (uri.length() > 0) {
+ binding.addBaseURI(uri);
+ }
+ }
+ }
+ return addBinding(binding);
+ }
+
+ public NodeConfiguration addBinding(QName bindingType, URI... baseURIs) {
+ BindingConfiguration binding = new BindingConfigurationImpl().setBindingType(bindingType);
+ for (URI u : baseURIs) {
+ binding.addBaseURI(u.toString());
+ }
+ return addBinding(binding);
+ }
+
+ public NodeConfiguration addContribution(String contributionURI, String location) {
+ ContributionConfiguration contribution = new ContributionConfigurationImpl(contributionURI, location);
+ return addContribution(contribution);
+ }
+
+ public NodeConfiguration addContribution(String contributionURI, URL location) {
+ return addContribution(contributionURI, location.toString());
+ }
+
+ public NodeConfiguration addContribution(URI contributionURI, URL location) {
+ return addContribution(contributionURI.toString(), location.toString());
+ }
+
+ public NodeConfiguration addContribution(URL... locations) {
+ for (URL url : locations) {
+ ContributionConfiguration contribution = new ContributionConfigurationImpl(url.toString(), url.toString());
+ addContribution(contribution);
+ }
+ return this;
+ }
+
+ public NodeConfiguration addDeploymentComposite(String contributionURI, InputStream content) {
+ findContribution(contributionURI).addDeploymentComposite(content);
+ return this;
+ }
+
+ public NodeConfiguration addDeploymentComposite(String contributionURI, Reader content) {
+ findContribution(contributionURI).addDeploymentComposite(content);
+ return this;
+ }
+
+ public NodeConfiguration addDeploymentComposite(String contributionURI, String location) {
+ findContribution(contributionURI).addDeploymentComposite(URI.create(location));
+ return this;
+ }
+
+ private ContributionConfiguration findContribution(String uri) {
+ for (ContributionConfiguration c : contributions) {
+ if (c.getURI() != null && c.getURI().equals(uri)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException("Contribution is not found (uri=" + uri + ")");
+ }
+
+ public String toString() {
+ if (domainURI != null) {
+ return "{" + domainURI + "}" + uri;
+ } else {
+ return uri;
+ }
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public String getDomainRegistryURI() {
+ return domainRegistryURI;
+ }
+
+ public NodeConfiguration setDomainRegistryURI(String domainRegistryURI) {
+ this.domainRegistryURI = domainRegistryURI;
+ return this;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/LICENSE b/sandbox/sebastien/java/embed/modules/node-impl-osgi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/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/sebastien/java/embed/modules/node-impl-osgi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/node-impl-osgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..82b79149f8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,53 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA OSGi Node Implementation
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.apache.tuscany.sca.node.osgi.impl.NodeActivator
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Node Implementation
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.common.java.collection;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0",
+ org.apache.tuscany.sca.deployment;version="2.0.0",
+ org.apache.tuscany.sca.extensibility.equinox;version="2.0.0",
+ org.apache.tuscany.sca.implementation.osgi;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.osgi.framework;version="1.4.0",
+ org.osgi.framework.hooks.service;version="1.0.0";resolution:=optional,
+ org.osgi.service.cm;version="1.2.1",
+ org.osgi.service.component;version="1.1.0";resolution:=optional,
+ org.osgi.service.event;version="1.2.0",
+ org.osgi.service.packageadmin;version="1.2.0";resolution:=optional,
+ org.osgi.service.remoteserviceadmin;version="1.0.0",
+ org.osgi.util.tracker;version="1.3.0";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.node.osgi.impl
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.osgi.service.remoteserviceadmin;version="1.0.0"
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/NOTICE b/sandbox/sebastien/java/embed/modules/node-impl-osgi/NOTICE
new file mode 100644
index 0000000000..8c74c2267e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/NOTICE
@@ -0,0 +1,9 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes software developed at
+the OSGi Alliance (http://www.osgi.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/pom.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/pom.xml
new file mode 100644
index 0000000000..c5af2a491b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/pom.xml
@@ -0,0 +1,121 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <name>Apache Tuscany SCA OSGi Node Implementation</name>
+
+ <repositories>
+ <repository>
+ <id>tuscany.repo</id>
+ <name>Tuscany Maven 2.x Repository</name>
+ <url>http://svn.apache.org/repos/asf/tuscany/maven</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Equinox Declarative Services -->
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>ds</artifactId>
+ <version>1.1.0-v20090601</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>util</artifactId>
+ <version>1.0.100-v20090520-1800</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java
new file mode 100644
index 0000000000..36feb6526a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.osgi.impl;
+
+import static org.apache.tuscany.sca.node.osgi.impl.NodeManager.isSCABundle;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.RemoteServiceAdminImpl;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.TopologyManagerImpl;
+import org.apache.tuscany.sca.osgi.service.discovery.impl.DiscoveryActivator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.SynchronousBundleListener;
+
+/**
+ * Bundle activator to receive the BundleContext
+ */
+public class NodeActivator implements BundleActivator, SynchronousBundleListener {
+ private final static Logger logger = Logger.getLogger(NodeActivator.class.getName());
+ private static BundleContext bundleContext;
+ private boolean inited;
+ private NodeManager manager;
+
+ private DiscoveryActivator discoveryActivator = new DiscoveryActivator();
+ private RemoteServiceAdminImpl remoteAdmin;
+ private TopologyManagerImpl controller;
+
+ private void init() {
+ synchronized (this) {
+ if (inited) {
+ return;
+ }
+ manager = new NodeManager(bundleContext);
+ manager.start();
+ bundleContext.addBundleListener(manager);
+ inited = true;
+ }
+ }
+
+ public void start(BundleContext context) throws Exception {
+ try {
+ bundleContext = context;
+
+ // FIXME: We should try to avoid aggressive initialization
+ init();
+
+ remoteAdmin = new RemoteServiceAdminImpl(context);
+ remoteAdmin.start();
+
+ discoveryActivator.start(context);
+
+ controller = new TopologyManagerImpl(context);
+ controller.start();
+
+ boolean found = false;
+ for (Bundle b : context.getBundles()) {
+ if (isSCABundle(b)) {
+ found = true;
+ break;
+ }
+ }
+
+ if (found) {
+ init();
+ } else {
+ context.addBundleListener(this);
+ }
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ throw e;
+ }
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ if (inited) {
+ context.removeBundleListener(this);
+ controller.stop();
+ controller = null;
+
+ discoveryActivator.stop(context);
+ discoveryActivator = null;
+
+ remoteAdmin.stop();
+ remoteAdmin = null;
+
+ manager.stop();
+ bundleContext.removeBundleListener(manager);
+ manager = null;
+ bundleContext = null;
+ inited = false;
+ }
+ }
+
+ public static BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
+ public void bundleChanged(BundleEvent event) {
+ if (event.getType() == BundleEvent.STARTING) {
+ if (isSCABundle(event.getBundle())) {
+ bundleContext.removeBundleListener(this);
+ init();
+ }
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java
new file mode 100644
index 0000000000..6914e09b8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.osgi.impl;
+
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.SynchronousBundleListener;
+
+/**
+ * Managing the mapping between OSGi bundles and SCA implementation.osgi
+ */
+public class NodeManager implements SynchronousBundleListener, ServiceListener {
+ private static final Logger logger = Logger.getLogger(NodeManager.class.getName());
+ private BundleContext bundleContext;
+ OSGiNodeFactoryImpl factory;
+
+ public NodeManager(BundleContext bundleContext) {
+ super();
+ this.bundleContext = bundleContext;
+ this.factory = new OSGiNodeFactoryImpl(this.bundleContext);
+ }
+
+ public void start() {
+ for (Bundle b : bundleContext.getBundles()) {
+ if ((b.getState() & Bundle.ACTIVE) != 0) {
+ // Process the active bundles
+ bundleStarted(b);
+ }
+ }
+ }
+
+ public void stop() {
+ if (factory != null) {
+ factory.destroy();
+ }
+ }
+
+ public static boolean isSCABundle(Bundle bundle) {
+ Dictionary<?, ?> headers = bundle.getHeaders();
+ // OSGi RFC 119 SCA
+ if (headers.get("SCA-Composite") != null) {
+ return true;
+ }
+
+ URL bundleComposite = bundle.getResource("OSGI-INF/sca/bundle.composite");
+ if (bundleComposite != null) {
+ return true;
+ }
+
+ /* FIXME: What if there is a META-INF/sca-contribution.xml? There are two cases:
+ * 1. The file contains deployable elements
+ * 2. The file doesn't contain deployable elements
+ */
+
+ /*
+ * FIXME: Do we want to use all of the .composite files under OSGI-INF/sca?
+ */
+
+ /*
+ Enumeration<?> entries = bundle.findEntries("OSGI-INF/sca", "bundle.composite", false);
+ if (entries != null && entries.hasMoreElements()) {
+ return true;
+ }
+
+ // OSGi Declarative Services
+ if (headers.get("Service-Component") != null) {
+ return true;
+ }
+
+ // OSGI RFC 124: BluePrint Service
+ if (headers.get("Bundle-Blueprint") != null) {
+ return true;
+ }
+
+ entries = bundle.findEntries("OSGI-INF/blueprint", "*.xml", false);
+ if (entries != null && entries.hasMoreElements()) {
+ return true;
+ }
+ */
+ return false;
+ }
+
+ private void bundleStarted(Bundle bundle) {
+ if (!isSCABundle(bundle)) {
+ return;
+ }
+ try {
+ NodeConfiguration configuration = factory.getConfiguration(bundle, null);
+ Node node = factory.createNode(configuration);
+ node.start();
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+
+ private void bundleStopping(Bundle bundle) {
+ Node node = factory.getNodes().get(bundle);
+ if (node == null) {
+ return;
+ }
+ node.stop();
+ }
+
+ public void serviceChanged(ServiceEvent event) {
+ }
+
+ public void bundleChanged(BundleEvent event) {
+ int type = event.getType();
+ if (type == BundleEvent.STOPPING) {
+ bundleStopping(event.getBundle());
+ } else if (type == BundleEvent.STARTED) {
+ bundleStarted(event.getBundle());
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
new file mode 100644
index 0000000000..c79fc04c4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
@@ -0,0 +1,142 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT 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.node.osgi.impl;
+
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Level;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.extensibility.equinox.OSGiExtensionPointRegistry;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * The OSGi based NodeFactory
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiNodeFactoryImpl extends NodeFactoryImpl {
+ private ServiceRegistration registration;
+ private BundleContext bundleContext;
+
+ public OSGiNodeFactoryImpl() {
+ super();
+ Bundle bundle = FrameworkUtil.getBundle(OSGiNodeFactoryImpl.class);
+ if (bundle != null) {
+ this.bundleContext = bundle.getBundleContext();
+ autoDestroy = false;
+ setNodeFactory(this);
+ } else {
+ throw new IllegalStateException(OSGiNodeFactoryImpl.class + " is not loaded by OSGi");
+ }
+ }
+ /**
+ * Constructs a new Node controller
+ */
+ public OSGiNodeFactoryImpl(BundleContext bundleContext) {
+ super();
+ this.bundleContext = bundleContext;
+ autoDestroy = false;
+ setNodeFactory(this);
+ }
+
+ protected NodeConfiguration getConfiguration(Bundle bundle, String compositeContent) {
+ init();
+
+ // Create a node configuration
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ NodeConfigurationFactory configurationFactory = modelFactories.getFactory(NodeConfigurationFactory.class);
+ NodeConfiguration configuration = configurationFactory.createNodeConfiguration();
+
+ URL location = bundle.getEntry("/");
+ String uri = bundle.getSymbolicName();
+ configuration.setURI(uri).addContribution(uri, location);
+
+ if (compositeContent != null) {
+ configuration.addDeploymentComposite(uri, new StringReader(compositeContent));
+ } else {
+ String compositeURI = (String)bundle.getHeaders().get("SCA-Composite");
+ if (compositeURI == null) {
+ compositeURI = "OSGI-INF/sca/bundle.composite";
+ }
+ if (compositeURI != null) {
+ configuration.addDeploymentComposite(uri, compositeURI);
+ }
+ }
+ // Set the bundle
+ // configuration.getExtensions().add(bundle);
+ return configuration;
+ }
+
+ public synchronized void init() {
+ if (!inited) {
+ // Register the ExtensionPointRegistry as an OSGi service
+ Dictionary<Object, Object> props = new Hashtable<Object, Object>();
+ registry = createExtensionPointRegistry();
+ registry.start();
+ registration =
+ bundleContext.registerService(ExtensionPointRegistry.class.getName(), registry, props);
+
+ // Call super.init after the extension point registry is registered
+ super.init();
+ }
+ }
+
+ public synchronized void destroy() {
+ if (inited) {
+ if (registration != null) {
+ try {
+ registration.unregister();
+ } catch (IllegalStateException e) {
+ // The service has been unregistered, ignore it
+ }
+ registration = null;
+ }
+ super.destroy();
+ }
+
+ }
+
+ @Override
+ protected Object getNodeKey(NodeConfiguration configuration) {
+ // each bundle might have more than one nodes started
+ return super.getNodeKey(configuration);
+ }
+
+ @Override
+ protected ExtensionPointRegistry createExtensionPointRegistry() {
+ return new OSGiExtensionPointRegistry(bundleContext);
+ }
+
+ @Override
+ protected boolean isSchemaValidationEnabled() {
+ return logger.isLoggable(Level.FINE);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
new file mode 100644
index 0000000000..5a4b5aa836
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.osgi.service.discovery.impl.LocalDiscoveryService;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Watching and exporting OSGi services
+ */
+public class AbstractOSGiServiceHandler implements LifeCycleListener {
+ protected ExtensionPointRegistry registry;
+ protected BundleContext context;
+ protected NodeFactoryImpl nodeFactory;
+ protected EndpointIntrospector introspector;
+ protected ServiceTracker discoveryTracker;
+ protected String domainRegistry;
+ protected String domainURI;
+
+ /**
+ * @param context
+ * @param clazz
+ * @param customizer
+ */
+ protected AbstractOSGiServiceHandler(BundleContext context) {
+ this.context = context;
+ this.domainRegistry = context.getProperty("org.osgi.sca.domain.registry");
+ this.domainURI = context.getProperty("org.osgi.sca.domain.uri");
+ }
+
+ protected ExtensionPointRegistry getExtensionPointRegistry() {
+ if (registry == null) {
+ ServiceTracker tracker = new ServiceTracker(context, ExtensionPointRegistry.class.getName(), null);
+ tracker.open();
+ // tracker.waitForService(1000);
+ registry = (ExtensionPointRegistry)tracker.getService();
+ tracker.close();
+ }
+ return registry;
+ }
+
+ protected synchronized void init() {
+ if (nodeFactory == null) {
+ this.nodeFactory = (NodeFactoryImpl)NodeFactory.getInstance();
+ this.nodeFactory.init();
+ this.discoveryTracker = LocalDiscoveryService.getTracker(context);
+ discoveryTracker.open();
+ this.introspector = new EndpointIntrospector(context, getExtensionPointRegistry(), discoveryTracker);
+ }
+ }
+
+ public void start() {
+ init();
+ }
+
+ public void stop() {
+ if (nodeFactory != null) {
+ discoveryTracker.close();
+ discoveryTracker = null;
+ introspector = null;
+ nodeFactory = null;
+ registry = null;
+ context = null;
+ }
+ }
+
+ public void setDomainRegistry(String domainRegistry) {
+ this.domainRegistry = domainRegistry;
+ }
+
+ public void setDomainURI(String domainURI) {
+ this.domainURI = domainURI;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java
new file mode 100644
index 0000000000..8ecc5f7ea8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+
+/**
+ * Implementation of {@link EndpointDescription}
+ */
+public class EndpointHelper {
+ private EndpointHelper() {
+ }
+
+ public static EndpointDescription createEndpointDescription(BundleContext bundleContext, Endpoint endpoint) {
+ return new EndpointDescription(getProperties(bundleContext, endpoint));
+ }
+
+ private static List<String> getInterfaces(Endpoint endpoint) {
+ Interface intf = endpoint.getComponentServiceInterfaceContract().getInterface();
+ JavaInterface javaInterface = (JavaInterface)intf;
+ return Collections.singletonList(javaInterface.getName());
+ }
+
+ private static Map<String, Object> getProperties(BundleContext bundleContext, Endpoint endpoint) {
+ Map<String, Object> props = new HashMap<String, Object>();
+
+ if (!endpoint.isRemote()) {
+ String uuid = OSGiHelper.getFrameworkUUID(bundleContext);
+ props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, uuid);
+ }
+
+ for (Object ext : endpoint.getService().getExtensions()) {
+ if (ext instanceof OSGiProperty) {
+ OSGiProperty prop = (OSGiProperty)ext;
+ props.put(prop.getName(), prop.getStringValue());
+ }
+ }
+
+ String serviceID = (String)props.get(Constants.SERVICE_ID);
+ if (serviceID != null) {
+ props.put(RemoteConstants.ENDPOINT_SERVICE_ID, Long.parseLong(serviceID));
+ }
+
+ // FIXME: [rfeng] We need to calculate the intents supported by this endpoint
+ /*
+ QName bindingTypeName = endpoint.getBinding().getType();
+ Definitions definitions = null;
+ if(definitions!=null) {
+ for(BindingType bindingType: definitions.getBindingTypes()) {
+ if(bindingType.getType().equals(bindingTypeName)) {
+ bindingType.getAlwaysProvidedIntents();
+ }
+ }
+ */
+
+ String intents = (String)props.get(RemoteConstants.SERVICE_EXPORTED_INTENTS);
+ String extraIntents = (String)props.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA);
+ if (intents == null) {
+ intents = "";
+ }
+ if (extraIntents != null) {
+ intents = intents + " " + extraIntents;
+ }
+
+ props.put(RemoteConstants.SERVICE_INTENTS, intents.trim());
+
+ props.put(RemoteConstants.ENDPOINT_ID, endpoint.getURI());
+ // FIXME: [rfeng] How to pass in the remote service id from the endpoint XML
+ props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[] {"org.osgi.sca"});
+ props.put(Endpoint.class.getName(), endpoint);
+ List<String> interfaces = getInterfaces(endpoint);
+ props.put(Constants.OBJECTCLASS, interfaces.toArray(new String[interfaces.size()]));
+ return props;
+ }
+
+ public static Endpoint getEndpoint(EndpointDescription endpointDescription) {
+ return (Endpoint)endpointDescription.getProperties().get(Endpoint.class.getName());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
new file mode 100644
index 0000000000..d00696a822
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
@@ -0,0 +1,550 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import static org.apache.tuscany.sca.assembly.Base.SCA11_TUSCANY_NS;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SCA_BINDINGS;
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper.createOSGiProperty;
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper.getStringArray;
+import static org.osgi.framework.Constants.OBJECTCLASS;
+import static org.osgi.framework.Constants.SERVICE_ID;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.osgi.service.discovery.impl.LocalDiscoveryService;
+import org.apache.tuscany.sca.osgi.service.discovery.impl.LocalDiscoveryService.ExtenderConfiguration;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.PolicySets;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Introspect an OSGi Service to create an SCA composite that contains a single component with
+ * implementation.osgi
+ */
+public class EndpointIntrospector {
+ // private BundleContext context;
+ private AssemblyFactory assemblyFactory;
+ private ContributionFactory contributionFactory;
+ private OSGiImplementationFactory implementationFactory;
+ private PolicyFactory policyFactory;
+ private ExtensionPointRegistry registry;
+ private FactoryExtensionPoint factories;
+ private ModelResolverExtensionPoint modelResolvers;
+ // private StAXArtifactProcessor<Composite> compositeProcessor;
+ private JavaInterfaceFactory javaInterfaceFactory;
+ private Deployer deployer;
+ private ServiceTracker discoveryTracker;
+
+ /**
+ * @param name
+ * @return
+ */
+ private static QName getQName(String name) {
+ QName qname;
+ if (name.startsWith("{")) {
+ int i = name.indexOf('}');
+ if (i != -1) {
+ qname = new QName(name.substring(1, i), name.substring(i + 1));
+ } else {
+ throw new IllegalArgumentException("Invalid qname: " + name);
+ }
+ } else {
+ // Default to SCA namespace
+ qname = new QName("", name);
+ }
+ return qname;
+ }
+
+ /**
+ * @param context TODO
+ * @param registry
+ */
+ public EndpointIntrospector(BundleContext context, ExtensionPointRegistry registry, ServiceTracker discoveryTracker) {
+ super();
+ this.registry = registry;
+ // this.context = context;
+ this.discoveryTracker = discoveryTracker;
+ this.factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.modelResolvers = registry.getExtensionPoint(ModelResolverExtensionPoint.class);
+// this.compositeProcessor =
+// registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class).getProcessor(Composite.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.contributionFactory = factories.getFactory(ContributionFactory.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ this.implementationFactory = factories.getFactory(OSGiImplementationFactory.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.deployer = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Deployer.class);
+ }
+
+ private Intent getIntent(String intent) {
+ QName name = getQName(intent);
+ Intent i = policyFactory.createIntent();
+ i.setName(name);
+ return i;
+ }
+
+ private List<Intent> getIntents(String[] intents) {
+ if (intents == null || intents.length == 0) {
+ return Collections.emptyList();
+ }
+ List<Intent> intentList = new ArrayList<Intent>();
+ for (String i : intents) {
+ Intent intent = getIntent(i);
+ if (intent != null) {
+ intentList.add(intent);
+ }
+ }
+ return intentList;
+ }
+
+ /**
+ * Any property in the map overrides the service reference properties, regardless of
+ * case. That is, if the map contains a key then it will override any case variant
+ * of this key in the Service Reference.<p>
+ * If the map contains the objectClass or service. id property key in any case
+ * variant, then these properties must not override the Service References value. This
+ * implies that the map can provide the service.exported. interfaces, property allowing
+ * the Topology Manager to export any registered service, also services not specifically
+ * marked to be exported.
+ * @param reference
+ * @param props
+ * @return
+ */
+ private Map<String, Object> getProperties(ServiceReference reference, Map<String, Object> props) {
+ String[] names = reference.getPropertyKeys();
+ Map<String, Object> properties = new HashMap<String, Object>();
+ if (names != null) {
+ for (String name : names) {
+ properties.put(name, reference.getProperty(name));
+ }
+ }
+ if (props != null) {
+ // Create a map of names (key = lowcase name, value = name)
+ Map<String, String> nameMap = new HashMap<String, String>();
+ if (names != null) {
+ for (String name : names) {
+ nameMap.put(name.toLowerCase(), name);
+ }
+ }
+ for (Map.Entry<String, Object> p : props.entrySet()) {
+ if (OBJECTCLASS.equalsIgnoreCase(p.getKey())) {
+ throw new IllegalArgumentException(OBJECTCLASS + " property cannot be overridden.");
+ } else if (SERVICE_ID.equalsIgnoreCase(p.getKey())) {
+ throw new IllegalArgumentException(SERVICE_ID + " property cannot be overridden.");
+ }
+ String key = nameMap.get(p.getKey().toLowerCase());
+ if (key != null) {
+ properties.put(key, p.getValue());
+ } else {
+ properties.put(p.getKey(), p.getValue());
+ }
+ }
+ }
+ return properties;
+ }
+
+ /**
+ * Parse the Stringp[] to support values that are separated by comma
+ * @param interfaces
+ * @return
+ */
+ private String[] parse(String[] interfaces) {
+ if (interfaces == null) {
+ return null;
+ }
+ List<String> names = new ArrayList<String>();
+ for (String i : interfaces) {
+ String[] parts = i.split(",");
+ for (String p : parts) {
+ names.add(p.trim());
+ }
+ }
+ return names.toArray(new String[names.size()]);
+ }
+
+ /**
+ * Introspect a local OSGi Service represented by the ServiceReference to create
+ * an SCA service with the required intents and bindings
+ * @param reference The service reference for a local OSGi service
+ * @param props Addiontal properties
+ * @return An SCA contribution with a deployable composite for the SCA service
+ * @throws Exception
+ */
+ public Contribution introspect(ServiceReference reference, Map<String, Object> props) throws Exception {
+ Bundle bundle = reference.getBundle();
+ Map<String, Object> properties = getProperties(reference, props);
+ Collection<OSGiProperty> osgiProps = implementationFactory.createOSGiProperties(reference);
+ Long sid = (Long)reference.getProperty(SERVICE_ID);
+
+ String[] requiredIntents = getStringArray(properties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
+ List<Intent> intents = getIntents(requiredIntents);
+ String[] requiredIntentsExtra = getStringArray(properties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
+ List<Intent> extraIntents = getIntents(requiredIntentsExtra);
+ Set<Intent> allIntents = new HashSet<Intent>(intents);
+ allIntents.addAll(extraIntents);
+
+ String[] bindingNames = getStringArray(properties.get(SCA_BINDINGS));
+ Collection<Binding> bindings = loadBindings(bindingNames);
+
+ String[] remoteInterfaces = getStringArray(reference.getProperty(RemoteConstants.SERVICE_EXPORTED_INTERFACES));
+ if (remoteInterfaces == null || remoteInterfaces.length > 0 && "*".equals(remoteInterfaces[0])) {
+ remoteInterfaces = getStringArray(reference.getProperty(OBJECTCLASS));
+ } else {
+ remoteInterfaces = parse(remoteInterfaces);
+ String[] objectClasses = getStringArray(reference.getProperty(OBJECTCLASS));
+ Set<String> objectClassSet = new HashSet<String>(Arrays.asList(objectClasses));
+ if (!objectClassSet.containsAll(Arrays.asList(remoteInterfaces))) {
+ throw new IllegalArgumentException(
+ "The exported interfaces are not a subset of the types" + " listed in the objectClass service property from the Service Reference");
+ }
+ }
+
+ Contribution contribution = generateContribution(bundle, sid, remoteInterfaces, bindings, allIntents, osgiProps);
+ return contribution;
+ }
+
+ public String instrospectSCAConfig(ServiceReference reference, Map<String, Object> props, ComponentService service){
+
+ ServiceDescriptionsFactory serviceDescriptionFactory = registry.getExtensionPoint(ServiceDescriptionsFactory.class);
+ SCAConfig scaConfig = serviceDescriptionFactory.createSCAConfig();
+
+ // add the binding configurations
+ List<Binding> bindings = scaConfig.getBindings();
+ bindings.addAll(service.getBindings());
+
+ // add the intent configurations
+ List<Intent> intents = scaConfig.getIntents();
+ intents.addAll(service.getRequiredIntents());
+
+ // add the policy set configurations
+ List<PolicySet> policySets = scaConfig.getPolicySets();
+ policySets.addAll(service.getPolicySets());
+
+ // set up the target namespace
+ // TODO - there is a bug in the spec which only allow bindings from one
+ // namsepace to be included in sca-config element. Here we just
+ // the first bindings namespace
+ Map<String, Object> properties = getProperties(reference, props);
+ String[] bindingNames = getStringArray(properties.get(SCA_BINDINGS));
+ if (bindingNames.length > 0){
+ QName firstBindingQName = getQName(bindingNames[0]);
+ scaConfig.setTargetNamespace(firstBindingQName.getNamespaceURI());
+ }
+
+ // write the sca config out to XML
+ String scaConfigXMLString = "";
+
+ try {
+ Writer writer = new StringWriter();
+ deployer.saveXMLDocument(scaConfig, writer, deployer.createMonitor());
+ scaConfigXMLString = writer.toString();
+ } catch (Exception ex){
+ throw new ServiceRuntimeException(ex);
+ }
+
+ return scaConfigXMLString;
+ }
+
+ /*
+ public Contribution loadContribution(Bundle bundle, Composite composite) {
+ try {
+ URL root = bundle.getEntry("/");
+ Contribution contribution = deployer.loadContribution(root.toURI(), root, deployer.createMonitor());
+ deployer.attachDeploymentComposite(contribution, composite, false);
+ return contribution;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ */
+
+ /**
+ * Generate a contribution that contains the composite for the exported service
+ * @param bundle The OSGi bundle
+ * @param sid The service id
+ * @param remoteInterfaces
+ * @param bindings
+ * @param allIntents
+ * @return
+ * @throws ClassNotFoundException
+ * @throws InvalidInterfaceException
+ */
+ private Contribution generateContribution(Bundle bundle,
+ Long sid,
+ String[] remoteInterfaces,
+ Collection<Binding> bindings,
+ Set<Intent> allIntents,
+ Collection<OSGiProperty> osgiProps) throws ClassNotFoundException,
+ InvalidInterfaceException {
+ String id = "osgi.service." + UUID.randomUUID();
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(new QName(SCA11_TUSCANY_NS, id));
+
+ Component component = assemblyFactory.createComponent();
+ component.setName(id);
+
+ composite.getComponents().add(component);
+
+ OSGiImplementation implementation = implementationFactory.createOSGiImplementation();
+
+ implementation.setBundle(bundle);
+ component.setImplementation(implementation);
+ implementation.setUnresolved(false);
+
+ OSGiProperty serviceID = implementationFactory.createOSGiProperty();
+ serviceID.setName(SERVICE_ID);
+ // The service.id is Long
+ serviceID.setValue(String.valueOf(sid));
+
+ for (String intf : remoteInterfaces) {
+ Service service = assemblyFactory.createService();
+ JavaInterfaceContract interfaceContract = createJavaInterfaceContract(bundle, intf);
+ String name = intf.substring(intf.lastIndexOf('.') + 1);
+ service.setName(name);
+ service.setInterfaceContract(interfaceContract);
+
+ implementation.getServices().add(service);
+
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setName(service.getName());
+ componentService.getExtensions().add(serviceID);
+ componentService.getExtensions().addAll(osgiProps);
+
+ component.getServices().add(componentService);
+ componentService.setService(service);
+ }
+
+ for (ComponentService componentService : component.getServices()) {
+ componentService.getRequiredIntents().addAll(allIntents);
+ componentService.getBindings().addAll(bindings);
+ }
+
+ // FIXME: Should we scan the owning bundle to create the SCA contribution?
+ Contribution contribution = loadContribution(bundle, id, composite);
+ return contribution;
+ }
+
+ private Contribution loadContribution(Bundle bundle, String id, Composite composite) {
+ Contribution contribution = contributionFactory.createContribution();
+ contribution.setClassLoader(OSGiHelper.createBundleClassLoader(bundle));
+ contribution.setURI(id);
+ contribution.setLocation(bundle.getEntry("/").toString());
+ deployer.attachDeploymentComposite(contribution, composite, false);
+ ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, factories);
+ contribution.setModelResolver(modelResolver);
+ // compositeProcessor.resolve(composite, modelResolver, new ProcessorContext(registry));
+ contribution.setUnresolved(true);
+ return contribution;
+ }
+
+ /**
+ * @param bundle
+ * @param endpoint
+ * @return
+ * @throws Exception
+ */
+ public Contribution introspect(Bundle bundle, EndpointDescription endpoint) throws Exception {
+ Collection<Binding> bindings = Collections.emptyList();
+ Collection<String> interfaces = Collections.emptyList();
+ Collection<Intent> intents = Collections.emptyList();
+ Endpoint ep = (Endpoint)endpoint.getProperties().get(Endpoint.class.getName());
+ Collection<OSGiProperty> osgiProps = implementationFactory.createOSGiProperties(endpoint.getProperties());
+ if (ep != null) {
+ bindings = Collections.singletonList(ep.getBinding());
+ interfaces = Collections.singletonList(((JavaInterface)ep.getComponentServiceInterfaceContract().getInterface()).getName());
+ // FIXME: [rfeng] We need to build the in-memory composite so that intents are calculated at the ep level
+ intents = ep.getService().getRequiredIntents();
+ } else {
+ Map<String, Object> properties = endpoint.getProperties();
+ interfaces = endpoint.getInterfaces();
+ String[] requiredIntents = getStringArray(properties.get(RemoteConstants.SERVICE_INTENTS));
+ intents = getIntents(requiredIntents);
+
+ String[] bindingNames = getStringArray(properties.get(SCA_BINDINGS));
+ bindings = loadBindings(bindingNames);
+ }
+
+ Contribution contribution = generateContribution(bundle, interfaces, bindings, intents, osgiProps);
+ return contribution;
+ }
+
+ private Contribution generateContribution(Bundle bundle,
+ Collection<String> remoteInterfaces,
+ Collection<Binding> bindings,
+ Collection<Intent> intents,
+ Collection<OSGiProperty> osgiProps) throws ClassNotFoundException,
+ InvalidInterfaceException, ContributionResolveException {
+ String id = "osgi.reference." + UUID.randomUUID();
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(new QName(Base.SCA11_TUSCANY_NS, id));
+
+ Component component = assemblyFactory.createComponent();
+ component.setName(id);
+ // component.setAutowire(Boolean.TRUE);
+
+ composite.getComponents().add(component);
+
+ OSGiImplementation implementation = implementationFactory.createOSGiImplementation();
+
+ implementation.setBundle(bundle);
+ component.setImplementation(implementation);
+ implementation.setUnresolved(false);
+
+ int count = 0;
+ for (String intf : remoteInterfaces) {
+ Reference reference = assemblyFactory.createReference();
+ JavaInterfaceContract interfaceContract = createJavaInterfaceContract(bundle, intf);
+
+ reference.setName("ref" + (count++));
+ reference.setInterfaceContract(interfaceContract);
+
+ implementation.getReferences().add(reference);
+
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName(reference.getName());
+ componentReference.getExtensions().addAll(osgiProps);
+ component.getReferences().add(componentReference);
+ componentReference.setReference(reference);
+ componentReference.setWiredByImpl(true);
+ }
+
+ for (ComponentReference componentReference : component.getReferences()) {
+ componentReference.getRequiredIntents().addAll(intents);
+ componentReference.getBindings().addAll(bindings);
+ }
+
+ Contribution contribution = loadContribution(bundle, id, composite);
+ return contribution;
+ }
+
+ private JavaInterfaceContract createJavaInterfaceContract(Bundle bundle, String intf)
+ throws ClassNotFoundException, InvalidInterfaceException {
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ Class<?> interfaceClass = bundle.loadClass(intf);
+ JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface();
+ // [rfeng] For OSGi, the interfaces should be marked as remotable
+ javaInterface.setRemotable(true);
+ // [rfeng] We need to mark the interface to be remotable before the createJavaInterface() is called
+ javaInterfaceFactory.createJavaInterface(javaInterface, interfaceClass);
+ interfaceContract.setInterface(javaInterface);
+ if (javaInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(javaInterface.getCallbackClass());
+ callbackInterface.setRemotable(true);
+ interfaceContract.setCallbackInterface(callbackInterface);
+ }
+ return interfaceContract;
+ }
+
+ private Collection<Binding> loadBindings(String[] qnames) throws IOException, ContributionReadException,
+ XMLStreamException {
+ if (qnames == null || qnames.length == 0) {
+ return Collections.emptyList();
+ }
+ QName[] bindingNames = new QName[qnames.length];
+ int index = 0;
+ for (String name : qnames) {
+ bindingNames[index++] = getQName(name);
+ }
+
+ LocalDiscoveryService discoveryService = (LocalDiscoveryService)discoveryTracker.getService();
+
+ Map<QName, Binding> bindingMap = new HashMap<QName, Binding>();
+ if (discoveryService != null) {
+ for (ExtenderConfiguration config : discoveryService.getConfigurations()) {
+ for (SCAConfig sc : config.getSCAConfigs()) {
+ for (QName bindingName : bindingNames) {
+ if ("".equals(bindingName.getNamespaceURI()) ||
+ sc.getTargetNamespace().equals(bindingName.getNamespaceURI())) {
+ for (Binding binding : sc.getBindings()) {
+ if (bindingName.getLocalPart().equals(binding.getName())) {
+ // We need to check duplications
+ if (bindingMap.put(bindingName, binding) != null) {
+ throw new ServiceRuntimeException("Duplicate binding found: " + bindingName);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ for (QName bindingName : bindingNames) {
+ if (!bindingMap.containsKey(bindingName)) {
+ throw new ServiceRuntimeException("Binding cannot be resolved: " + bindingName);
+ }
+ }
+ return bindingMap.values();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointMatcher.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointMatcher.java
new file mode 100644
index 0000000000..f978ba658d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointMatcher.java
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.common.java.collection.CollectionMap;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.hooks.service.ListenerHook.ListenerInfo;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+
+/**
+ * Matching endpoint descriptions against the sevice listeners using OSGi filiters
+ */
+public class EndpointMatcher {
+ private static final Logger logger = Logger.getLogger(EndpointMatcher.class.getName());
+ private final EndpointMap endpointDescriptions = new EndpointMap();
+ private final ListenerMap listeners = new ListenerMap();
+ private final BundleContext context;
+ private final BlockingQueue<ImportAction> importQueue = new ArrayBlockingQueue<ImportAction>(256, true);
+
+ public EndpointMatcher(BundleContext context) {
+ super();
+ this.context = context;
+ }
+
+ public static boolean matches(String filter, EndpointDescription endpointDescription) {
+ Filter f = null;
+ try {
+ f = FrameworkUtil.createFilter(filter);
+ } catch (InvalidSyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ Hashtable<String, Object> props = new Hashtable<String, Object>(endpointDescription.getProperties());
+ return f.match(props);
+ }
+
+ private void importEndpoint(ListenerInfo listener, EndpointDescription ep) {
+ ImportAction request = new ImportAction(ImportAction.Type.Add, listener, ep);
+ try {
+ importQueue.put(request);
+ } catch (InterruptedException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ private void unimportEndpoint(ListenerInfo listener, EndpointDescription ep) {
+ ImportAction request = new ImportAction(ImportAction.Type.Remove, listener, ep);
+ try {
+ importQueue.put(request);
+ } catch (InterruptedException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public synchronized void added(ListenerInfo listener) {
+ String filter = listener.getFilter();
+ listeners.putValue(filter, listener);
+ for (EndpointDescription ep : getEndpoints(filter)) {
+ importEndpoint(listener, ep);
+ }
+ }
+
+ public synchronized Collection<String> added(Collection<ListenerInfo> listeners) {
+ for (ListenerInfo listener : listeners) {
+ if (accepts(listener)) {
+ if (!listener.isRemoved() && listener.getBundleContext().getBundle().getBundleId() != 0L) {
+ added(listener);
+ }
+ }
+ }
+ return getFilters();
+ }
+
+ private boolean accepts(ListenerInfo listener) {
+ BundleContext context = listener.getBundleContext();
+ return context != null && listener.getFilter() != null && context != this.context;
+ }
+
+ public synchronized void removed(ListenerInfo listener) {
+ String filter = listener.getFilter();
+ if (accepts(listener))
+ if (listeners.removeValue(filter, listener, true)) {
+ // Find the corresponding ImportRegistration with the listener
+ for (EndpointDescription ep : getEndpoints(filter)) {
+ unimportEndpoint(listener, ep);
+ }
+ if (getListeners(filter).isEmpty()) {
+ // No more listeners on the this filter, clean up the endpoint descriptionss
+ endpointDescriptions.remove(filter);
+ }
+
+ }
+ }
+
+ public synchronized Collection<String> removed(Collection<ListenerInfo> listeners) {
+ for (ListenerInfo listener : listeners) {
+ removed(listener);
+ }
+ return getFilters();
+ }
+
+ public synchronized void added(EndpointDescription endpointDescription) {
+ for (Map.Entry<String, Collection<ListenerInfo>> entry : listeners.entrySet()) {
+ if (matches(entry.getKey(), endpointDescription)) {
+ endpointDescriptions.putValue(entry.getKey(), endpointDescription);
+ for (ListenerInfo listener : entry.getValue()) {
+ importEndpoint(listener, endpointDescription);
+ }
+ }
+ }
+ }
+
+ public synchronized void added(EndpointDescription endpointDescription, String matchedFilter) {
+ if (endpointDescriptions.putValue(matchedFilter, endpointDescription)) {
+ Collection<ListenerInfo> listenerInfos = listeners.get(matchedFilter);
+ if (listenerInfos != null) {
+ for (ListenerInfo listener : listenerInfos) {
+ importEndpoint(listener, endpointDescription);
+ }
+ }
+ }
+ }
+
+ public synchronized void removed(EndpointDescription endpointDescription, String matchedFilter) {
+ if (endpointDescriptions.removeValue(matchedFilter, endpointDescription, true)) {
+ for (ListenerInfo listener : getListeners(matchedFilter)) {
+ unimportEndpoint(listener, endpointDescription);
+ }
+ }
+ }
+
+ public synchronized Set<String> getFilters() {
+ return new HashSet<String>(listeners.keySet());
+ }
+
+ public synchronized void clear() {
+ endpointDescriptions.clear();
+ listeners.clear();
+ importQueue.clear();
+ }
+
+ public synchronized Collection<ListenerInfo> getListeners(String filter) {
+ Collection<ListenerInfo> collection = listeners.get(filter);
+ if (collection == null) {
+ return Collections.emptySet();
+ } else {
+ return collection;
+ }
+ }
+
+ public synchronized Collection<EndpointDescription> getEndpoints(String filter) {
+ Collection<EndpointDescription> collection = endpointDescriptions.get(filter);
+ if (collection == null) {
+ return Collections.emptySet();
+ } else {
+ return collection;
+ }
+ }
+
+ public CollectionMap<Class<?>, ListenerInfo> groupListeners(EndpointDescription endpointDescription,
+ String matchedFilter) {
+ Collection<ListenerInfo> snapshot = new HashSet<ListenerInfo>(getListeners(matchedFilter));
+
+ // Try to partition the listeners by the interface classes
+ List<String> interfaceNames = endpointDescription.getInterfaces();
+ CollectionMap<Class<?>, ListenerInfo> interfaceToListeners = new CollectionMap<Class<?>, ListenerInfo>();
+ for (String i : interfaceNames) {
+ for (Iterator<ListenerInfo> it = snapshot.iterator(); it.hasNext();) {
+ try {
+ ListenerInfo listener = it.next();
+ if (listener.isRemoved()) {
+ it.remove();
+ continue;
+ }
+ if (!matchedFilter.equals(listener.getFilter())) {
+ continue;
+ }
+ try {
+ // The classloading can be synchronzed against the serviceListeners
+ Class<?> interfaceClass = listener.getBundleContext().getBundle().loadClass(i);
+ interfaceToListeners.putValue(interfaceClass, listener);
+ } catch (IllegalStateException e) {
+ logger.log(Level.WARNING, e.getMessage(), e);
+ // Ignore the exception
+ }
+ } catch (ClassNotFoundException e) {
+ // Ignore the listener as it cannot load the interface class
+ }
+ }
+ }
+ return interfaceToListeners;
+ }
+
+ public BlockingQueue<ImportAction> getImportQueue() {
+ return importQueue;
+ }
+
+ private static class ListenerMap extends CollectionMap<String, ListenerInfo> {
+ private static final long serialVersionUID = -8612202123531331219L;
+
+ @Override
+ protected Collection<ListenerInfo> createCollection() {
+ return new HashSet<ListenerInfo>();
+ }
+ }
+
+ private static class EndpointMap extends CollectionMap<String, EndpointDescription> {
+ private static final long serialVersionUID = -6261405398109798549L;
+
+ @Override
+ protected Collection<EndpointDescription> createCollection() {
+ return new HashSet<EndpointDescription>();
+ }
+ }
+
+ /**
+ * Representation of an import/unimport request
+ */
+ public static class ImportAction {
+ enum Type {
+ Add, Remove
+ };
+
+ public final Type type;
+ public final ListenerInfo listenerInfo;
+ public final EndpointDescription endpointDescription;
+
+ /**
+ * @param type
+ * @param listenerInfo
+ * @param endpointDescription
+ */
+ public ImportAction(Type type, ListenerInfo listenerInfo, EndpointDescription endpointDescription) {
+ super();
+ this.type = type;
+ this.listenerInfo = listenerInfo;
+ this.endpointDescription = endpointDescription;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportReferenceImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportReferenceImpl.java
new file mode 100644
index 0000000000..13c7dd3cf3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportReferenceImpl.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.osgi.remoteserviceadmin.impl;
+
+import org.apache.tuscany.sca.node.Node;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ExportReference;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
+
+/**
+ *
+ */
+public class ExportReferenceImpl implements ExportReference {
+ private Node node;
+ private final ServiceReference exportedService;
+ private final EndpointDescription endpointDescription;
+ private int count;
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ */
+ public ExportReferenceImpl(Node node, ServiceReference exportedService, EndpointDescription endpointDescription) {
+ super();
+ this.node = node;
+ this.exportedService = exportedService;
+ this.endpointDescription = endpointDescription;
+ }
+
+ public ServiceReference getExportedService() {
+ return exportedService;
+ }
+
+ public EndpointDescription getExportedEndpoint() {
+ return endpointDescription;
+ }
+
+ public synchronized ExportRegistration register() {
+ count++;
+ return new ExportRegistrationImpl(this);
+ }
+
+ public synchronized void unregister() {
+ if (count > 0) {
+ count--;
+ }
+ if (count == 0) {
+ if (node != null) {
+ node.stop();
+ node = null;
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java
new file mode 100644
index 0000000000..39cbd7b9e6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ExportReference;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
+
+/**
+ * Implementation of {@link ExportRegistration}
+ */
+public class ExportRegistrationImpl implements ExportRegistration {
+ private ExportReferenceImpl exportReference;
+ private Throwable exception;
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ * @param exception
+ */
+ public ExportRegistrationImpl(ExportReferenceImpl exportReference, Throwable exception) {
+ super();
+ this.exportReference = exportReference;
+ this.exception = exception;
+ }
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ */
+ public ExportRegistrationImpl(ExportReferenceImpl exportReference) {
+ this(exportReference, null);
+ }
+
+ /**
+ * @see org.osgi.remoteserviceadmin.ExportRegistration#close()
+ */
+ public void close() {
+ if (exportReference != null) {
+ exportReference.unregister();
+ }
+ exception = null;
+ exportReference = null;
+ }
+
+ public ServiceReference getExportedService() {
+ return exportReference.getExportedService();
+ }
+
+ public EndpointDescription getEndpointDescription() {
+ return exportReference.getExportedEndpoint();
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ public ExportReference getExportReference() throws IllegalStateException {
+ return exportReference;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportReferenceImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportReferenceImpl.java
new file mode 100644
index 0000000000..9c5b1818c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportReferenceImpl.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.osgi.remoteserviceadmin.impl;
+
+import org.apache.tuscany.sca.node.Node;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ImportReference;
+import org.osgi.service.remoteserviceadmin.ImportRegistration;
+
+/**
+ * Implementation of ImportReference. It keeps a reference count of ImportRegistrations
+ */
+public class ImportReferenceImpl implements ImportReference {
+ private Node node;
+ private final ServiceReference importedService;
+ private final EndpointDescription endpointDescription;
+ private int count = 0;
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ */
+ public ImportReferenceImpl(Node node, ServiceReference importedService, EndpointDescription endpointDescription) {
+ super();
+ this.node = node;
+ this.importedService = importedService;
+ this.endpointDescription = endpointDescription;
+ }
+
+ public ServiceReference getImportedService() {
+ return importedService;
+ }
+
+ public EndpointDescription getImportedEndpoint() {
+ return endpointDescription;
+ }
+
+ public synchronized ImportRegistration register() {
+ count++;
+ return new ImportRegistrationImpl(this);
+ }
+
+ public synchronized void unregister() {
+ if (count > 0) {
+ count--;
+ }
+ if (count == 0) {
+ if (node != null) {
+ node.stop();
+ node = null;
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java
new file mode 100644
index 0000000000..9506128286
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.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.osgi.remoteserviceadmin.impl;
+
+import org.osgi.service.remoteserviceadmin.ImportReference;
+import org.osgi.service.remoteserviceadmin.ImportRegistration;
+
+/**
+ *
+ */
+public class ImportRegistrationImpl implements ImportRegistration {
+ private ImportReferenceImpl importReference;
+ private Throwable exception;
+
+ /**
+ * @param importReference
+ */
+ public ImportRegistrationImpl(ImportReferenceImpl importReference) {
+ super();
+ this.importReference = importReference;
+ }
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ * @param exception
+ */
+ public ImportRegistrationImpl(ImportReferenceImpl importReference, Throwable exception) {
+ super();
+ this.importReference = importReference;
+ this.exception = exception;
+ }
+
+ /**
+ * @see org.osgi.remoteserviceadmin.ImportRegistration#close()
+ */
+ public void close() {
+ if (importReference != null) {
+ importReference.unregister();
+ }
+ exception = null;
+ importReference = null;
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ public ImportReference getImportReference() {
+ return importReference;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java
new file mode 100644
index 0000000000..460d291f53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ *
+ */
+public class OSGiHelper {
+ public final static String FRAMEWORK_UUID = "org.osgi.framework.uuid";
+
+ private OSGiHelper() {
+ }
+
+ /**
+ * In OSGi, the value of String+ can be a single String, String[] or Collection<String>
+ * @param value
+ * @return
+ */
+ public static String[] getStringArray(Object value) {
+ if (value == null) {
+ return null;
+ }
+ if (value instanceof String) {
+ return new String[] {(String)value};
+ } else if (value instanceof Collection) {
+ Collection<String> collection = (Collection)value;
+ return collection.toArray(new String[collection.size()]);
+ }
+ return (String[])value;
+
+ }
+
+ public static Collection<String> getStringCollection(Object value) {
+ String[] values = getStringArray(value);
+ if (values == null) {
+ return null;
+ } else {
+ return Arrays.asList(values);
+ }
+ }
+
+ public static String[] getStringArray(ServiceReference serviceReference, String propertyName) {
+ Object propertyValue = serviceReference.getProperty(propertyName);
+ return getStringArray(propertyValue);
+ }
+
+ public static Collection<String> getStringCollection(ServiceReference serviceReference, String propertyName) {
+ Object propertyValue = serviceReference.getProperty(propertyName);
+ return getStringCollection(propertyValue);
+ }
+
+ public static Filter createFilter(BundleContext context, String filterValue) {
+ if (filterValue == null) {
+ return null;
+ }
+ try {
+ return context.createFilter(filterValue);
+ } catch (InvalidSyntaxException ex) {
+ throw new IllegalArgumentException("Invalid Filter: " + filterValue, ex);
+ }
+ }
+
+ /**
+ * Get a collection of resources that are configured by the given header
+ * @param bundle The bundle
+ * @param header
+ * @param defaultValue
+ * @return
+ */
+ public static Collection<URL> getConfiguration(Bundle bundle, String header, String defaultValue) {
+ String value = (String)bundle.getHeaders().get(header);
+ if (value == null) {
+ return Collections.emptyList();
+ }
+ value = value.trim();
+ String paths[] = value.split("( |\t|\n|\r|\f|,)+");
+ if ("".equals(value) || paths.length == 0) {
+ if (defaultValue != null) {
+ paths = new String[] {defaultValue};
+ } else {
+ paths = new String[0];
+ }
+ }
+ Collection<URL> files = new HashSet<URL>();
+ for (String path : paths) {
+ if ("".equals(path)) {
+ // Skip empty ones
+ continue;
+ }
+ if (path.endsWith("/")) {
+ path = path + "*.xml";
+ }
+ if (!path.startsWith("/")) {
+ path = "/" + path;
+ }
+ int lastIndex = path.lastIndexOf('/');
+ String root = path.substring(0, lastIndex);
+ if ("".equals(root)) {
+ root = "/";
+ }
+ String pattern = path.substring(lastIndex + 1);
+ Enumeration<URL> entries = bundle.findEntries(root, pattern, false);
+ if (entries != null) {
+ while (entries.hasMoreElements()) {
+ files.add(entries.nextElement());
+ }
+ }
+ }
+ return files;
+ }
+
+ public static Collection<OSGiProperty> getOSGiProperties(ExtensionPointRegistry registry, ServiceReference reference) {
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ OSGiImplementationFactory implementationFactory =
+ factoryExtensionPoint.getFactory(OSGiImplementationFactory.class);
+ return implementationFactory.createOSGiProperties(reference);
+ }
+
+ public static OSGiProperty createOSGiProperty(ExtensionPointRegistry registry, String name, Object value) {
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ OSGiImplementationFactory implementationFactory =
+ factoryExtensionPoint.getFactory(OSGiImplementationFactory.class);
+ return implementationFactory.createOSGiProperty(name, value);
+ }
+
+ public synchronized static String getFrameworkUUID(BundleContext bundleContext) {
+ String uuid = null;
+ if (bundleContext != null) {
+ uuid = bundleContext.getProperty(FRAMEWORK_UUID);
+ } else {
+ uuid = System.getProperty(FRAMEWORK_UUID);
+ }
+ if (uuid == null) {
+ uuid = UUID.randomUUID().toString();
+ }
+ System.setProperty(FRAMEWORK_UUID, uuid);
+ return uuid;
+ }
+
+ public static ClassLoader createBundleClassLoader(Bundle bundle) {
+ return new BundleClassLoader(bundle);
+ }
+
+ private static class BundleClassLoader extends ClassLoader {
+ private Bundle bundle;
+
+ public BundleClassLoader(Bundle bundle) {
+ super(null);
+ this.bundle = bundle;
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ return bundle.loadClass(name);
+ }
+
+ @Override
+ protected URL findResource(String name) {
+ return bundle.getResource(name);
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(String name) throws IOException {
+ Enumeration<URL> urls = bundle.getResources(name);
+ if (urls == null) {
+ List<URL> list = Collections.emptyList();
+ return Collections.enumeration(list);
+ } else {
+ return urls;
+ }
+ }
+ }
+
+ /**
+ * Find out what elements are added between the oldValues and newValues
+ * @param oldValues
+ * @param newValues
+ * @return
+ */
+ public static Collection<String> getAddedItems(Collection<String> oldValues, Collection<String> newValues) {
+ if (newValues == null) {
+ newValues = Collections.emptySet();
+ }
+
+ Collection<String> deltaInterest = new HashSet<String>(newValues);
+ if (oldValues == null) {
+ oldValues = Collections.emptySet();
+ }
+ deltaInterest.removeAll(oldValues);
+ return deltaInterest;
+ }
+
+ public static Collection<String> getRemovedItems(Collection<String> oldValues, Collection<String> newValues) {
+ return getAddedItems(newValues, oldValues);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
new file mode 100644
index 0000000000..081a3a60c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.EndpointHelper.createEndpointDescription;
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper.createOSGiProperty;
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper.getFrameworkUUID;
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper.getOSGiProperties;
+import static org.osgi.framework.Constants.SERVICE_ID;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * Watching and exporting OSGi services
+ */
+public class OSGiServiceExporter extends AbstractOSGiServiceHandler implements ServiceTrackerCustomizer {
+ private final static Logger logger = Logger.getLogger(OSGiServiceExporter.class.getName());
+
+ private Map<EndpointDescription, ExportReferenceImpl> exportReferences =
+ new ConcurrentHashMap<EndpointDescription, ExportReferenceImpl>();
+
+ /**
+ * @param context
+ * @param clazz
+ * @param customizer
+ */
+ public OSGiServiceExporter(BundleContext context) {
+ super(context);
+ }
+
+ public void start() {
+ init();
+ }
+
+ public void stop() {
+ exportReferences.clear();
+ super.stop();
+ }
+
+ public Object addingService(ServiceReference reference) {
+ return exportService(reference, null);
+ }
+
+ public List<ExportRegistration> exportService(ServiceReference reference, Map<String, Object> properties) {
+ // FIXME: [rfeng] We need to check if a corresponding endpoint has been exported
+ try {
+ Contribution contribution = introspector.introspect(reference, properties);
+ if (contribution != null) {
+
+ NodeConfiguration configuration = nodeFactory.createNodeConfiguration();
+ if (domainRegistry != null) {
+ configuration.setDomainRegistryURI(domainRegistry);
+ }
+ if (domainURI != null) {
+ configuration.setDomainURI(domainURI);
+ }
+ configuration.setURI(contribution.getURI());
+ // configuration.getExtensions().add(reference.getBundle());
+ Component component = contribution.getDeployables().get(0).getComponents().get(0);
+ ComponentService service = component.getServices().get(0);
+ service.getExtensions().addAll(getOSGiProperties(registry, reference));
+ service.getExtensions().add(createOSGiProperty(registry,
+ ENDPOINT_FRAMEWORK_UUID,
+ getFrameworkUUID(reference.getBundle()
+ .getBundleContext())));
+ service.getExtensions().add(createOSGiProperty(registry, ENDPOINT_SERVICE_ID, reference
+ .getProperty(SERVICE_ID)));
+
+ // create the org.osgi.sca.config.xml property
+ service.getExtensions().add(createSCAConfigXMLProperty(reference, properties, service));
+
+ // FIXME: Configure the domain and node URI
+ NodeImpl node = new NodeImpl(nodeFactory, configuration, Collections.singletonList(contribution));
+ node.start();
+ List<ExportRegistration> exportedServices = new ArrayList<ExportRegistration>();
+ for (Endpoint endpoint : service.getEndpoints()) {
+ EndpointDescription endpointDescription = createEndpointDescription(context, endpoint);
+ synchronized (this) {
+ ExportReferenceImpl exportReference = exportReferences.get(endpointDescription);
+ if (exportReference == null) {
+ exportReference = new ExportReferenceImpl(node, reference, endpointDescription);
+ }
+ ExportRegistration exportRegistration = exportReference.register();
+ exportedServices.add(exportRegistration);
+ }
+ }
+ return exportedServices;
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ ExportRegistration exportRegistration = new ExportRegistrationImpl(null, e);
+ return Collections.singletonList(exportRegistration);
+ }
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ removedService(reference, service);
+ exportService(reference, null);
+ }
+
+ public void removedService(ServiceReference reference, Object service) {
+ List<ExportRegistration> exportedServices = (List<ExportRegistration>)service;
+ for (ExportRegistration exportRegistration : exportedServices) {
+ exportRegistration.close();
+ }
+ }
+
+ private OSGiProperty createSCAConfigXMLProperty(ServiceReference reference, Map<String, Object> props, ComponentService service){
+
+ // create the <sca-config> element
+ String scaConfigXMLString = introspector.instrospectSCAConfig(reference, props, service);
+
+ // wrap the <sca-config> element in an <xml> element
+ String scaConfigXMLStringWithoutXMLHeader = scaConfigXMLString.substring(scaConfigXMLString.indexOf("><") + 1);
+ scaConfigXMLString = "<xml>" + scaConfigXMLStringWithoutXMLHeader + "</xml>";
+
+ // create and return the OSGI property
+ return createOSGiProperty(registry, "org.osgi.sca.config.xml", scaConfigXMLString);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
new file mode 100644
index 0000000000..f24e9af7c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ImportRegistration;
+
+/**
+ * Watching and exporting OSGi services
+ */
+public class OSGiServiceImporter extends AbstractOSGiServiceHandler {
+ private final static Logger logger = Logger.getLogger(OSGiServiceImporter.class.getName());
+ private Map<EndpointDescription, ImportReferenceImpl> importReferences =
+ new ConcurrentHashMap<EndpointDescription, ImportReferenceImpl>();
+
+ /**
+ * @param context
+ * @param clazz
+ * @param customizer
+ */
+ public OSGiServiceImporter(BundleContext context) {
+ super(context);
+ }
+
+ public void start() {
+ // Defer init() to importService()
+ }
+
+ public void stop() {
+ importReferences.clear();
+ super.stop();
+ }
+
+ public ImportRegistration importService(Bundle bundle, EndpointDescription endpointDescription) {
+ init();
+ try {
+ Contribution contribution = introspector.introspect(bundle, endpointDescription);
+ if (contribution != null) {
+
+ NodeConfiguration configuration = nodeFactory.createNodeConfiguration();
+ if (domainRegistry != null) {
+ configuration.setDomainRegistryURI(domainRegistry);
+ }
+ if (domainURI != null) {
+ configuration.setDomainURI(domainURI);
+ }
+ configuration.setURI(contribution.getURI());
+ // configuration.getExtensions().add(bundle);
+ // FIXME: Configure the domain and node URI
+ NodeImpl node = new NodeImpl(nodeFactory, configuration, Collections.singletonList(contribution));
+ node.start();
+
+ Component component = contribution.getDeployables().get(0).getComponents().get(0);
+ ComponentReference componentReference = component.getReferences().get(0);
+ ServiceReference serviceReference =
+ context.getServiceReference("(sca.reference=" + component.getURI()
+ + "#reference("
+ + componentReference.getName()
+ + ")");
+ synchronized (this) {
+ ImportReferenceImpl importReference = importReferences.get(endpointDescription);
+ if (importReference == null) {
+ importReference = new ImportReferenceImpl(node, serviceReference, endpointDescription);
+ importReferences.put(endpointDescription, importReference);
+ }
+ return importReference.register();
+ }
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ return new ImportRegistrationImpl(null, e);
+ }
+ }
+
+ public void unimportService(ImportRegistration importRegistration) {
+ if (importRegistration != null) {
+ importRegistration.close();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
new file mode 100644
index 0000000000..94955ada38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ExportReference;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
+import org.osgi.service.remoteserviceadmin.ImportReference;
+import org.osgi.service.remoteserviceadmin.ImportRegistration;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * SCA Implementation of {@link RemoteServiceAdmin}
+ */
+public class RemoteServiceAdminImpl implements RemoteServiceAdmin, ManagedService {
+ private BundleContext context;
+ private ServiceRegistration registration;
+ private ServiceRegistration managedService;
+ private ServiceTracker listeners;
+
+ private OSGiServiceExporter exporter;
+ private OSGiServiceImporter importer;
+
+ private Collection<ImportRegistration> importRegistrations = new ArrayList<ImportRegistration>();
+ private Collection<ExportRegistration> exportedRegistrations = new ArrayList<ExportRegistration>();
+
+ public RemoteServiceAdminImpl(BundleContext context) {
+ this.context = context;
+ }
+
+ public void start() {
+ this.exporter = new OSGiServiceExporter(context);
+ this.importer = new OSGiServiceImporter(context);
+ exporter.start();
+ importer.start();
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put(RemoteConstants.REMOTE_CONFIGS_SUPPORTED, new String[] {"org.osgi.sca"});
+
+ ExtensionPointRegistry registry = exporter.getExtensionPointRegistry();
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ Deployer deployer = utilities.getUtility(Deployer.class);
+ Definitions definitions = deployer.getSystemDefinitions();
+
+ String[] intents = new String[definitions.getIntents().size()];
+ int i = 0;
+ for (Intent intent : definitions.getIntents()) {
+ intents[i++] = intent.toString();
+ }
+
+ String[] bindingTypes = new String[definitions.getBindingTypes().size()];
+ i = 0;
+ for (BindingType bindingType : definitions.getBindingTypes()) {
+ bindingTypes[i++] = bindingType.getType().toString();
+ }
+
+ // FIXME: We should ask SCA domain for the supported intents
+ props.put(RemoteConstants.REMOTE_INTENTS_SUPPORTED, intents);
+ // FIXME: We should ask SCA domain for the supported binding types
+ props.put("org.osgi.sca.binding.types", bindingTypes);
+ registration = context.registerService(RemoteServiceAdmin.class.getName(), this, props);
+
+ props = new Hashtable<String, Object>();
+ props.put(Constants.SERVICE_PID, RemoteServiceAdminImpl.class.getName());
+ managedService = context.registerService(ManagedService.class.getName(), this, props);
+ listeners = new ServiceTracker(this.context, RemoteServiceAdminListener.class.getName(), null);
+ listeners.open();
+ }
+
+ public void stop() {
+ if (registration != null) {
+ try {
+ registration.unregister();
+ } catch (IllegalStateException e) {
+ // The service has been unregistered, ignore it
+ }
+ registration = null;
+ }
+ if (managedService != null) {
+ try {
+ managedService.unregister();
+ } catch (IllegalStateException e) {
+ // The service has been unregistered, ignore it
+ }
+ managedService = null;
+ }
+ if (listeners != null) {
+ listeners.close();
+ listeners = null;
+ }
+ for (ExportRegistration exportRegistration : exportedRegistrations) {
+ exportRegistration.close();
+ }
+ exportedRegistrations.clear();
+ for (ImportRegistration importRegistration : importRegistrations) {
+ importRegistration.close();
+ }
+ importRegistrations.clear();
+ if (importer != null) {
+ importer.stop();
+ importer = null;
+ }
+ if (exporter != null) {
+ exporter.stop();
+ exporter = null;
+ }
+ }
+
+ /**
+ * @see org.osgi.remoteserviceadmin.RemoteServiceAdmin#exportService(org.osgi.framework.ServiceReference,
+ * java.util.Map)
+ */
+ public List<ExportRegistration> exportService(ServiceReference ref, Map properties) {
+ List<ExportRegistration> exportRegistrations = exporter.exportService(ref, properties);
+ if (exportRegistrations != null) {
+ exportRegistrations.addAll(exportedRegistrations);
+ fireExportEvents(ref.getBundle(), exportRegistrations);
+ }
+ return exportRegistrations;
+ }
+
+ private void fireExportEvents(Bundle source, List<ExportRegistration> exportRegistrations) {
+ for (ExportRegistration registration : exportRegistrations) {
+ RemoteServiceAdminEvent rsaEvent =
+ new RemoteServiceAdminEvent(RemoteServiceAdminEvent.EXPORT_REGISTRATION, source, registration
+ .getExportReference(), registration.getException());
+ EventAdmin eventAdmin = getEventAdmin();
+ if (eventAdmin != null) {
+ eventAdmin.postEvent(wrap(rsaEvent));
+ }
+ for (Object listener : listeners.getServices()) {
+ RemoteServiceAdminListener rsaListener = (RemoteServiceAdminListener)listener;
+ rsaListener.remoteAdminEvent(rsaEvent);
+ }
+ }
+ }
+
+ private EventAdmin getEventAdmin() {
+ ServiceReference reference = context.getServiceReference(EventAdmin.class.getName());
+ if (reference == null) {
+ return null;
+ } else {
+ return (EventAdmin)context.getService(reference);
+ }
+ }
+
+ private Event wrap(RemoteServiceAdminEvent rsaEvent) {
+ int type = rsaEvent.getType();
+ String eventType = null;
+ switch (type) {
+ case RemoteServiceAdminEvent.EXPORT_ERROR:
+ eventType = "EXPORT_ERROR";
+ break;
+ case RemoteServiceAdminEvent.EXPORT_REGISTRATION:
+ eventType = "EXPORT_REGISTRATION";
+ break;
+ case RemoteServiceAdminEvent.EXPORT_UNREGISTRATION:
+ eventType = "EXPORT_UNREGISTRATION";
+ break;
+ case RemoteServiceAdminEvent.EXPORT_WARNING:
+ eventType = "EXPORT_WARNING";
+ break;
+ case RemoteServiceAdminEvent.IMPORT_ERROR:
+ eventType = "IMPORT_ERROR";
+ break;
+ case RemoteServiceAdminEvent.IMPORT_REGISTRATION:
+ eventType = "IMPORT_REGISTRATION";
+ break;
+ case RemoteServiceAdminEvent.IMPORT_UNREGISTRATION:
+ eventType = "EXPORT_ERROR";
+ break;
+ case RemoteServiceAdminEvent.IMPORT_WARNING:
+ eventType = "IMPORT_UNREGISTRATION";
+ break;
+ }
+ String topic = "org/osgi/service/remoteserviceadmin/" + eventType;
+ Map<String, Object> props = new HashMap<String, Object>();
+ /*
+ * <ul>
+ <li>bundle (Bundle) The Remote Service Admin bundle
+ <li>bundle-id (Long) The id of the Blueprint bundle.
+ <li>bundle-symbolicname (String) The Bundle Symbolic Name of the
+ Remote Service Admin bundle.
+ <li>bundle-version - (Version) The version of the Blueprint bundle.
+ <li>cause The exception, if present.
+ <li>import.registration An imported endpoint, if present
+ <li>export.registration An exported endpoint, if present
+ <li>service.remote.id Remote service UUID, if present
+ <li>service.remote.uuid Remote service UUID, if present
+ <li>service.remote.uri (String) The URI of the endpoint, if present
+ <li>objectClass (String[]) The interface names, if present
+ <li>service.imported.configs (String+) The configuration types of the
+ imported services, if present
+ <li>timestamp (Long) The time when the event occurred
+ <li>event (RemoteServiceAdminEvent) The RemoteServiceAdminEvent
+ object that caused this event.
+ </ul>
+ */
+ Bundle rsaBundle = context.getBundle();
+ props.put("bundle", rsaBundle);
+ props.put("bundle-id", rsaBundle.getBundleId());
+ props.put("bundle-symbolicname", rsaBundle.getSymbolicName());
+ props.put("bundle-version", rsaBundle.getHeaders().get(Constants.BUNDLE_VERSION));
+ props.put("cause", rsaEvent.getException());
+ props.put("import.registration", rsaEvent.getImportReference());
+ props.put("export.registration", rsaEvent.getExportReference());
+ EndpointDescription ep = null;
+ if (rsaEvent.getImportReference() != null) {
+ ep = rsaEvent.getImportReference().getImportedEndpoint();
+ }
+ if (rsaEvent.getExportReference() != null) {
+ ep = rsaEvent.getExportReference().getExportedEndpoint();
+ }
+
+ if (ep != null) {
+ props.put("endpoint.service.id", ep.getServiceId());
+ props.put("endpoint.framework.uuid", ep.getFrameworkUUID());
+ props.put("endpoint.id", ep.getId());
+ props.put("objectClass", ep.getInterfaces());
+ props.put("service.imported.configs", ep.getConfigurationTypes());
+ Object bindings = ep.getProperties().get("org.osgi.sca.bindings");
+ if (bindings != null) {
+ props.put("org.osgi.sca.bindings", bindings);
+ }
+ Object config = ep.getProperties().get("org.osgi.sca.config.url");
+ if (config != null) {
+ props.put("org.osgi.sca.config.url", config);
+ }
+ config = ep.getProperties().get("org.osgi.sca.config.xml");
+ if (config != null) {
+ props.put("org.osgi.sca.config.xml", config);
+ } }
+ props.put("timestamp", Long.valueOf(System.currentTimeMillis()));
+ props.put("event", rsaEvent);
+ return new Event(topic, props);
+ }
+
+ private void fireImportEvents(Bundle source, ImportRegistration registration) {
+ RemoteServiceAdminEvent rsaEvent =
+ new RemoteServiceAdminEvent(RemoteServiceAdminEvent.IMPORT_REGISTRATION, source, registration
+ .getImportReference(), registration.getException());
+ EventAdmin eventAdmin = getEventAdmin();
+ if (eventAdmin != null) {
+ eventAdmin.postEvent(wrap(rsaEvent));
+ }
+ for (Object listener : listeners.getServices()) {
+ RemoteServiceAdminListener rsaListener = (RemoteServiceAdminListener)listener;
+ rsaListener.remoteAdminEvent(rsaEvent);
+ }
+ }
+
+ /**
+ * @see org.osgi.remoteserviceadmin.RemoteServiceAdmin#getExportedServices()
+ */
+ public Collection<ExportReference> getExportedServices() {
+ Collection<ExportReference> exportedServices = new ArrayList<ExportReference>();
+ for (ExportRegistration registration : exportedRegistrations) {
+ exportedServices.add(registration.getExportReference());
+ }
+ return exportedServices;
+ }
+
+ /**
+ * @see org.osgi.remoteserviceadmin.RemoteServiceAdmin#getImportedEndpoints()
+ */
+ public Collection<ImportReference> getImportedEndpoints() {
+ Collection<ImportReference> importedEndpoints = new ArrayList<ImportReference>();
+ for (ImportRegistration registration : importRegistrations) {
+ importedEndpoints.add(registration.getImportReference());
+ }
+ return importedEndpoints;
+ }
+
+ /**
+ * @see org.osgi.remoteserviceadmin.RemoteServiceAdmin#importService(org.apache.tuscany.sca.dosgi.discovery.EndpointDescription)
+ */
+ public ImportRegistration importService(EndpointDescription endpoint) {
+ Bundle bundle = (Bundle)endpoint.getProperties().get(Bundle.class.getName());
+ ImportRegistration importReg = importer.importService(bundle, endpoint);
+ if (importReg != null) {
+ fireImportEvents(bundle, importReg);
+ importRegistrations.add(importReg);
+ }
+ return importReg;
+ }
+
+ public synchronized void updated(Dictionary props) throws ConfigurationException {
+ if (props == null) {
+ // It can be null in Apache Felix
+ return;
+ }
+ String domainRegistry = (String)props.get("org.osgi.sca.domain.registry");
+ String domainURI = (String)props.get("org.osgi.sca.domain.uri");
+ if (domainRegistry != null) {
+ exporter.setDomainRegistry(domainRegistry);
+ importer.setDomainRegistry(domainRegistry);
+ }
+ if (domainURI != null) {
+ exporter.setDomainURI(domainURI);
+ importer.setDomainURI(domainURI);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java
new file mode 100644
index 0000000000..a3f3636cce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java
@@ -0,0 +1,400 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.remoteserviceadmin.impl;
+
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SERVICE_EXPORTED_INTERFACES;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED;
+
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.common.java.collection.CollectionMap;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.EndpointMatcher.ImportAction;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.hooks.service.ListenerHook;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.EndpointListener;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
+import org.osgi.service.remoteserviceadmin.ImportRegistration;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * Implementation of Remote Controller
+ */
+public class TopologyManagerImpl implements ListenerHook, RemoteServiceAdminListener, EndpointListener,
+ ServiceTrackerCustomizer, LifeCycleListener /*, EventHook */{
+ private final static Logger logger = Logger.getLogger(TopologyManagerImpl.class.getName());
+ public final static String ENDPOINT_LOCAL = "service.local";
+
+ private BundleContext context;
+ private ServiceTracker remoteAdmins;
+
+ private volatile ServiceRegistration registration;
+ private ServiceRegistration endpointListener;
+
+ private ServiceTracker remotableServices;
+
+ private EndpointMatcher endpointMatcher;
+
+ private CollectionMap<ServiceReference, ExportRegistration> exportedServices =
+ new CollectionMap<ServiceReference, ExportRegistration>();
+ private CollectionMap<ImportKey, ImportRegistration> importedServices =
+ new CollectionMap<ImportKey, ImportRegistration>();
+
+ private Filter remotableServiceFilter;
+
+ public TopologyManagerImpl(BundleContext context) {
+ this.context = context;
+ this.endpointMatcher = new EndpointMatcher(context);
+ }
+
+ public void start() {
+ String filter =
+ "(& (!(" + SERVICE_IMPORTED
+ + "=*)) ("
+ + SERVICE_EXPORTED_INTERFACES
+ + "=*) ("
+ + SERVICE_EXPORTED_CONFIGS
+ + "=org.osgi.sca) )";
+ try {
+ remotableServiceFilter = context.createFilter(filter);
+ } catch (InvalidSyntaxException e) {
+ // Ignore
+ }
+
+ endpointListener = context.registerService(EndpointListener.class.getName(), this, null);
+ remoteAdmins = new ServiceTracker(this.context, RemoteServiceAdmin.class.getName(), null);
+ remoteAdmins.open();
+
+ // DO NOT register EventHook.class.getName() as it cannot report existing services
+ String interfaceNames[] =
+ new String[] {ListenerHook.class.getName(), RemoteServiceAdminListener.class.getName()};
+ // The registration will trigger the added() method before registration is assigned
+ registration = context.registerService(interfaceNames, this, null);
+
+ remotableServices = new ServiceTracker(context, remotableServiceFilter, this);
+ remotableServices.open(true);
+
+ Thread thread = new Thread(new ImportTask());
+ thread.start();
+ }
+
+ public Object addingService(ServiceReference reference) {
+ exportService(reference);
+ return reference.getBundle().getBundleContext().getService(reference);
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ unexportService(reference);
+ exportService(reference);
+ }
+
+ public void removedService(ServiceReference reference, Object service) {
+ unexportService(reference);
+ }
+
+ private void unexportService(ServiceReference reference) {
+ // Call remote admin to unexport the service
+ Collection<ExportRegistration> exportRegistrations = exportedServices.get(reference);
+ if (exportRegistrations != null) {
+ for (Iterator<ExportRegistration> i = exportRegistrations.iterator(); i.hasNext();) {
+ ExportRegistration exported = i.next();
+ exported.close();
+ i.remove();
+ }
+ }
+ }
+
+ private void exportService(ServiceReference reference) {
+ // Call remote admin to export the service
+ Object[] admins = remoteAdmins.getServices();
+ if (admins == null) {
+ // Ignore
+ logger.warning("No RemoteAdmin services are available.");
+ } else {
+ for (Object ra : admins) {
+ RemoteServiceAdmin remoteAdmin = (RemoteServiceAdmin)ra;
+ Collection<ExportRegistration> exportRegistrations = remoteAdmin.exportService(reference, null);
+ if (exportRegistrations != null && !exportRegistrations.isEmpty()) {
+ exportedServices.putValues(reference, exportRegistrations);
+ }
+ }
+ }
+ }
+
+ /**
+ * @see org.osgi.framework.hooks.service.ListenerHook#added(java.util.Collection)
+ */
+ public void added(Collection listeners) {
+ try {
+ synchronized (endpointMatcher) {
+ Collection<String> oldFilters = endpointMatcher.getFilters();
+ Collection<String> newFilters = endpointMatcher.added(listeners);
+ if (!OSGiHelper.getAddedItems(oldFilters, newFilters).isEmpty()) {
+ updateEndpointListenerScope(newFilters);
+ }
+ }
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ if (e instanceof Error) {
+ throw (Error)e;
+ } else if (e instanceof RuntimeException) {
+ throw (RuntimeException)e;
+ } else {
+ // Should not happen
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void updateEndpointListenerScope(Collection<String> filters) {
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put(ENDPOINT_LISTENER_SCOPE, filters);
+ endpointListener.setProperties(props);
+ }
+
+ /**
+ * @see org.osgi.framework.hooks.service.ListenerHook#removed(java.util.Collection)
+ */
+ public void removed(Collection listeners) {
+ try {
+ synchronized (endpointMatcher) {
+ Collection<String> oldFilters = endpointMatcher.getFilters();
+ Collection<String> newFilters = endpointMatcher.removed(listeners);
+ if (!OSGiHelper.getRemovedItems(oldFilters, newFilters).isEmpty()) {
+ updateEndpointListenerScope(newFilters);
+ }
+ }
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ if (e instanceof Error) {
+ throw (Error)e;
+ } else if (e instanceof RuntimeException) {
+ throw (RuntimeException)e;
+ } else {
+ // Should not happen
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteAdminListener#remoteAdminEvent(org.apache.tuscany.sca.osgi.service.remoteadmin.RemoteAdminEvent)
+ */
+ public void remoteAdminEvent(RemoteServiceAdminEvent event) {
+ switch (event.getType()) {
+ case RemoteServiceAdminEvent.EXPORT_ERROR:
+ case RemoteServiceAdminEvent.EXPORT_REGISTRATION:
+ case RemoteServiceAdminEvent.EXPORT_UNREGISTRATION:
+ case RemoteServiceAdminEvent.EXPORT_WARNING:
+ break;
+ case RemoteServiceAdminEvent.IMPORT_ERROR:
+ case RemoteServiceAdminEvent.IMPORT_REGISTRATION:
+ case RemoteServiceAdminEvent.IMPORT_UNREGISTRATION:
+ case RemoteServiceAdminEvent.IMPORT_WARNING:
+ break;
+ }
+ }
+
+ /**
+ * @see org.osgi.remoteserviceadmin.EndpointListener#addEndpoint(org.osgi.service.remoteserviceadmin.EndpointDescription,
+ * java.lang.String)
+ */
+ public void endpointAdded(EndpointDescription endpoint, String matchedFilter) {
+ endpointMatcher.added(endpoint, matchedFilter);
+ // importService(endpoint, matchedFilter);
+ }
+
+ /**
+ * @see org.osgi.remoteserviceadmin.EndpointListener#removeEndpoint(org.osgi.service.remoteserviceadmin.EndpointDescription)
+ */
+ public void endpointRemoved(EndpointDescription endpoint, String matchedFilter) {
+ endpointMatcher.removed(endpoint, matchedFilter);
+ // unimportService(endpoint);
+ }
+
+ private void importService(EndpointDescription endpoint, String matchedFilter) {
+ Object[] admins = remoteAdmins.getServices();
+ if (admins == null) {
+ logger.warning("No Remote Service Admin services are available.");
+ return;
+ }
+
+ CollectionMap<Class<?>, ListenerInfo> interfaceToListeners =
+ endpointMatcher.groupListeners(endpoint, matchedFilter);
+ for (Map.Entry<Class<?>, Collection<ListenerInfo>> e : interfaceToListeners.entrySet()) {
+ Class<?> interfaceClass = e.getKey();
+ Collection<ListenerInfo> listeners = e.getValue();
+ // Get a listener
+ ListenerInfo listener = listeners.iterator().next();
+ Bundle bundle = listener.getBundleContext().getBundle();
+ if (bundle.getBundleId() == 0L) {
+ // Skip system bundles
+ continue;
+ }
+ try {
+ Filter filter = listener.getBundleContext().createFilter(matchedFilter);
+ if (!filter.match(new Hashtable<String, Object>(endpoint.getProperties()))) {
+ continue;
+ }
+ } catch (InvalidSyntaxException ex) {
+ logger.log(Level.SEVERE, ex.getMessage(), ex);
+ continue;
+ }
+
+ Map<String, Object> props = new HashMap<String, Object>(endpoint.getProperties());
+ props.put(Bundle.class.getName(), bundle);
+ props.put(Constants.OBJECTCLASS, new String[] {interfaceClass.getName()});
+ EndpointDescription description = new EndpointDescription(props);
+
+ if (admins != null) {
+ for (Object ra : admins) {
+ RemoteServiceAdmin remoteAdmin = (RemoteServiceAdmin)ra;
+ ImportRegistration importRegistration = remoteAdmin.importService(description);
+ if (importRegistration != null) {
+ importedServices.putValue(new ImportKey(description, listener), importRegistration);
+ }
+ }
+ }
+ }
+ }
+
+ private void unimportService(EndpointDescription endpoint, ListenerInfo listenerInfo) {
+ // Call remote admin to unimport the service
+ Collection<ImportRegistration> importRegistrations =
+ importedServices.get(new ImportKey(endpoint, listenerInfo));
+ if (importRegistrations != null) {
+ for (Iterator<ImportRegistration> i = importRegistrations.iterator(); i.hasNext();) {
+ ImportRegistration imported = i.next();
+ imported.close();
+ i.remove();
+ }
+ }
+ }
+
+ public void stop() {
+ remotableServices.close();
+
+ if (registration != null) {
+ try {
+ registration.unregister();
+ } catch (IllegalStateException e) {
+ // The service has been unregistered, ignore it
+ }
+ registration = null;
+ }
+ if (remoteAdmins != null) {
+ remoteAdmins.close();
+ remoteAdmins = null;
+ }
+ if (endpointMatcher != null) {
+ endpointMatcher.clear();
+ }
+ }
+
+ private class ImportTask implements Runnable {
+ public void run() {
+ while (registration != null) {
+ BlockingQueue<EndpointMatcher.ImportAction> queue = endpointMatcher.getImportQueue();
+ ImportAction action = null;
+ try {
+ action = queue.poll(1, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ if (action != null) {
+ if (action.type == ImportAction.Type.Add) {
+ importService(action.endpointDescription, action.listenerInfo.getFilter());
+ } else if (action.type == ImportAction.Type.Remove) {
+ unimportService(action.endpointDescription, action.listenerInfo);
+ }
+ }
+ }
+ }
+ }
+
+ private static class ImportKey {
+ private EndpointDescription endpointDescription;
+
+ /**
+ * @param endpointDescription
+ * @param listenerInfo
+ */
+ private ImportKey(EndpointDescription endpointDescription, ListenerInfo listenerInfo) {
+ super();
+ this.endpointDescription = endpointDescription;
+ this.listenerInfo = listenerInfo;
+ }
+
+ private ListenerInfo listenerInfo;
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((endpointDescription == null) ? 0 : endpointDescription.hashCode());
+ result = prime * result + ((listenerInfo == null) ? 0 : listenerInfo.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ImportKey other = (ImportKey)obj;
+ if (endpointDescription == null) {
+ if (other.endpointDescription != null)
+ return false;
+ } else if (!endpointDescription.equals(other.endpointDescription))
+ return false;
+ if (listenerInfo == null) {
+ if (other.listenerInfo != null)
+ return false;
+ } else if (!listenerInfo.equals(other.listenerInfo))
+ return false;
+ return true;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.java
new file mode 100644
index 0000000000..fd57dbded8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.java
@@ -0,0 +1,265 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.service.discovery.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.EndpointListener;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ *
+ */
+public abstract class AbstractDiscoveryService implements Discovery, LifeCycleListener {
+ protected final static int ADDED = 0x1;
+ protected final static int REMOVED = 0x2;
+ protected final static int MODIFIED = 0x4;
+
+ protected final static Logger logger = Logger.getLogger(AbstractDiscoveryService.class.getName());
+
+ protected BundleContext context;
+ protected ExtensionPointRegistry registry;
+ // private WorkScheduler workScheduler;
+
+ private Map<EndpointListener, Collection<String>> listenersToFilters =
+ new ConcurrentHashMap<EndpointListener, Collection<String>>();
+
+ protected Map<EndpointDescription, Bundle> endpointDescriptions =
+ new ConcurrentHashMap<EndpointDescription, Bundle>();
+ private ServiceTracker trackerTracker;
+
+ public AbstractDiscoveryService(BundleContext context) {
+ super();
+ this.context = context;
+ }
+
+ public void start() {
+ getExtensionPointRegistry();
+ // UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ // this.workScheduler = utilityExtensionPoint.getUtility(WorkScheduler.class);
+
+ // track the registration of EndpointListener
+ trackerTracker = new ServiceTracker(this.context, EndpointListener.class.getName(), null) {
+ public Object addingService(ServiceReference reference) {
+ Object result = super.addingService(reference);
+ cacheTracker(reference, result);
+ return result;
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ super.modifiedService(reference, service);
+ updateTracker(reference, service);
+ }
+
+ public void removedService(ServiceReference reference, Object service) {
+ super.removedService(reference, service);
+ clearTracker(service);
+ }
+ };
+
+ trackerTracker.open();
+ }
+
+ public void stop() {
+ trackerTracker.close();
+ }
+
+ protected ExtensionPointRegistry getExtensionPointRegistry() {
+ NodeFactoryImpl factory = (NodeFactoryImpl)NodeFactory.getInstance();
+ factory.init();
+ ServiceTracker tracker = new ServiceTracker(context, ExtensionPointRegistry.class.getName(), null);
+ tracker.open();
+ // tracker.waitForService(1000);
+ registry = (ExtensionPointRegistry)tracker.getService();
+ tracker.close();
+ return registry;
+ }
+
+ protected Dictionary<String, Object> getProperties() {
+ Dictionary headers = context.getBundle().getHeaders();
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put(PRODUCT_NAME, "Apache Tuscany SCA");
+ props.put(PRODUCT_VERSION, headers.get(Constants.BUNDLE_VERSION));
+ props.put(VENDOR_NAME, headers.get(Constants.BUNDLE_VENDOR));
+ // props.put(SUPPORTED_PROTOCOLS, new String[] {"local", "org.osgi.sca"});
+ return props;
+ }
+
+ private void cacheTracker(ServiceReference reference, Object service) {
+ if (service instanceof EndpointListener) {
+ EndpointListener listener = (EndpointListener)service;
+ Collection<String> filters = null;
+ synchronized (this) {
+ filters = addTracker(reference, listener, EndpointListener.ENDPOINT_LISTENER_SCOPE);
+ // Take a snapshot of the endpoints
+ triggerCallbacks(null, filters, listener);
+ }
+ }
+ }
+
+ private void clearTracker(Object service) {
+ if (service instanceof EndpointListener) {
+ synchronized (this) {
+ removeTracker((EndpointListener)service);
+ }
+ }
+ }
+
+ private void updateTracker(ServiceReference reference, Object service) {
+ if (service instanceof EndpointListener) {
+ EndpointListener listener = (EndpointListener)service;
+ Collection<String> oldFilters = null;
+ Collection<String> newFilters = null;
+ synchronized (this) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("updating listener: " + listener);
+ }
+ oldFilters = removeTracker(listener);
+ newFilters = addTracker(reference, listener, EndpointListener.ENDPOINT_LISTENER_SCOPE);
+ triggerCallbacks(oldFilters, newFilters, listener);
+ }
+ }
+ }
+
+ private void triggerCallbacks(Collection<String> oldInterest,
+ Collection<String> newInterest,
+ EndpointListener listener) {
+ // compute delta between old & new interfaces/filters and
+ // trigger callbacks for any entries in servicesInfo that
+ // match any *additional* interface/filters
+ Collection<String> deltaInterest = getDelta(oldInterest, newInterest);
+
+ Iterator<String> i = deltaInterest.iterator();
+ while (i.hasNext()) {
+ String next = i.next();
+ for (EndpointDescription sd : endpointDescriptions.keySet()) {
+ triggerCallbacks(listener, next, sd, ADDED);
+ }
+ }
+ // Find removed filters
+ deltaInterest = getDelta(newInterest, oldInterest);
+
+ i = deltaInterest.iterator();
+ while (i.hasNext()) {
+ String next = i.next();
+ for (EndpointDescription sd : endpointDescriptions.keySet()) {
+ triggerCallbacks(listener, next, sd, REMOVED);
+ }
+ }
+ }
+
+ private Collection<String> getDelta(Collection<String> oldInterest, Collection<String> newInterest) {
+ if (newInterest == null) {
+ newInterest = Collections.emptySet();
+ }
+
+ Collection<String> deltaInterest = new ArrayList<String>(newInterest);
+ if (oldInterest == null) {
+ oldInterest = Collections.emptySet();
+ }
+ deltaInterest.removeAll(oldInterest);
+ return deltaInterest;
+ }
+
+ /**
+ * Notify the endpoint listener
+ * @param listener
+ * @param matchedFilter
+ * @param endpoint
+ * @param type
+ */
+ private static void notify(EndpointListener listener, String matchedFilter, EndpointDescription endpoint, int type) {
+ switch (type) {
+ case ADDED:
+ listener.endpointAdded(endpoint, matchedFilter);
+ break;
+ case REMOVED:
+ listener.endpointRemoved(endpoint, matchedFilter);
+ break;
+ case MODIFIED:
+ listener.endpointRemoved(endpoint, matchedFilter);
+ listener.endpointAdded(endpoint, matchedFilter);
+ break;
+ }
+ }
+
+ private void triggerCallbacks(EndpointListener listener,
+ String matchedFilter,
+ EndpointDescription endpoint,
+ int type) {
+ // workScheduler.scheduleWork(new Notifier(listener, matchedFilter, endpoint, type));
+ notify(listener, matchedFilter, endpoint, type);
+ }
+
+ private boolean filterMatches(String filterValue, EndpointDescription sd) {
+ Filter filter = OSGiHelper.createFilter(context, filterValue);
+ Hashtable<String, Object> props = new Hashtable<String, Object>(sd.getProperties());
+ // Add two faked properties to make the filter match
+ props.put(Constants.OBJECTCLASS, sd.getInterfaces());
+ props.put(RemoteConstants.SERVICE_IMPORTED, "true");
+ return filter != null ? filter.match(props) : false;
+ }
+
+ private Collection<String> removeTracker(EndpointListener listener) {
+ return listenersToFilters.remove(listener);
+ }
+
+ private Collection<String> addTracker(ServiceReference reference, EndpointListener listener, String property) {
+ Collection<String> collection = OSGiHelper.getStringCollection(reference, property);
+ if (collection != null && !collection.isEmpty()) {
+ listenersToFilters.put(listener, new ArrayList<String>(collection));
+ }
+ return collection;
+ }
+
+ protected void endpointChanged(EndpointDescription sd, int type) {
+ synchronized (this) {
+ for (Map.Entry<EndpointListener, Collection<String>> entry : listenersToFilters.entrySet()) {
+ for (String filter : entry.getValue()) {
+ if (filterMatches(filter, sd)) {
+ triggerCallbacks(entry.getKey(), filter, sd, type);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/Discovery.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/Discovery.java
new file mode 100644
index 0000000000..3ad1e53fee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/Discovery.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.service.discovery.impl;
+
+/**
+ * Every Discovery Provider registers a service implementing this interface.
+ * This service is registered with extra properties identified at the beginning
+ * of this interface to denote the name of the product providing Discovery
+ * functionality, its version, vendor, used protocols etc..
+ * <p>
+ * Discovery allows to publish services exposed for remote access as well as to
+ * search for remote services.
+ * <p>
+ * Discovery service implementations usually rely on some discovery protocols or
+ * other information distribution means.
+ *
+ * @ThreadSafe
+ */
+public interface Discovery {
+
+ /**
+ * ServiceRegistration property for the name of the Discovery product.
+ * <p>
+ * Value of this property is of type <code>String</code>.
+ */
+ String PRODUCT_NAME = "osgi.remote.discovery.product";
+
+ /**
+ * ServiceRegistration property for the version of the Discovery product.
+ * <p>
+ * Value of this property is of type <code>String</code>.
+ */
+ String PRODUCT_VERSION = "osgi.remote.discovery.product.version";
+
+ /**
+ * ServiceRegistration property for the Discovery product vendor name.
+ * <p>
+ * Value of this property is of type <code>String</code>.
+ */
+ String VENDOR_NAME = "osgi.remote.discovery.vendor";
+
+ /**
+ * ServiceRegistration property that lists the discovery protocols used by
+ * this Discovery service.
+ * <p>
+ * Value of this property is of type
+ * <code>Collection (&lt;? extends String&gt;)</code>.
+ */
+ String SUPPORTED_PROTOCOLS = "osgi.remote.discovery.supported_protocols";
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DiscoveryActivator.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DiscoveryActivator.java
new file mode 100644
index 0000000000..32bd10b77b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DiscoveryActivator.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.osgi.service.discovery.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class DiscoveryActivator implements BundleActivator {
+ private List<AbstractDiscoveryService> discoveryServices = new ArrayList<AbstractDiscoveryService>();
+ private List<ServiceRegistration> discoveryServiceRegistrations = new ArrayList<ServiceRegistration>();
+
+ public void start(BundleContext context) {
+ discoveryServices.add(new LocalDiscoveryService(context));
+
+ discoveryServices.add(new DomainDiscoveryService(context));
+
+ for (AbstractDiscoveryService service : discoveryServices) {
+ service.start();
+ ServiceRegistration registration =
+ context.registerService(Discovery.class.getName(), service, service.getProperties());
+ discoveryServiceRegistrations.add(registration);
+ }
+ }
+
+ public void stop(BundleContext context) {
+ for (ServiceRegistration registration : discoveryServiceRegistrations) {
+ try {
+ registration.unregister();
+ } catch (IllegalStateException e) {
+ // The service has been unregistered, ignore it
+ }
+ }
+ for (AbstractDiscoveryService service : discoveryServices) {
+ service.stop();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
new file mode 100644
index 0000000000..0cbdda7b56
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.service.discovery.impl;
+
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.EndpointHelper.createEndpointDescription;
+
+import java.util.Dictionary;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+
+/**
+ * Discovery service based on the distributed SCA domain
+ */
+public class DomainDiscoveryService extends AbstractDiscoveryService implements EndpointListener {
+ private DomainRegistryFactory domainRegistryFactory;
+ private EndpointRegistry endpointRegistry;
+
+ public DomainDiscoveryService(BundleContext context) {
+ super(context);
+ }
+
+ public void start() {
+ super.start();
+ this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(registry);
+ domainRegistryFactory.addListener(this);
+
+ // [rfeng] Starting of the endpoint registry takes a long time and it leaves the bundle
+ // state to be starting. When the registry is started, remote endpoints come in and that
+ // triggers the classloading from this bundle.
+ Thread thread = new Thread() {
+ public void run() {
+ startEndpointRegistry();
+ }
+ };
+ thread.start();
+ }
+
+ private synchronized void startEndpointRegistry() {
+ // The following code forced the start() of the domain registry in absense of services
+ String domainRegistry = context.getProperty("org.osgi.sca.domain.registry");
+ if (domainRegistry == null) {
+ domainRegistry = NodeConfiguration.DEFAULT_DOMAIN_REGISTRY_URI;
+ }
+ String domainURI = context.getProperty("org.osgi.sca.domain.uri");
+ if (domainURI == null) {
+ domainURI = NodeConfiguration.DEFAULT_DOMAIN_URI;
+ }
+ if (domainRegistry != null) {
+ endpointRegistry = domainRegistryFactory.getEndpointRegistry(domainRegistry, domainURI);
+ }
+ }
+
+ public void endpointAdded(Endpoint endpoint) {
+ Implementation impl = endpoint.getComponent().getImplementation();
+
+ /*
+ if (!(impl instanceof OSGiImplementation)) {
+ return;
+ }
+ */
+
+ BundleContext bundleContext = null;
+ // Remote endpoint doesn't have a bundle
+ if (!endpoint.isRemote()) {
+ OSGiImplementation osgiImpl = (OSGiImplementation)impl;
+ Bundle bundle = osgiImpl.getBundle();
+ bundleContext = bundle != null ? bundle.getBundleContext() : null;
+ }
+
+ // Notify the endpoint listeners
+ EndpointDescription description = createEndpointDescription(bundleContext, endpoint);
+ // Set the owning bundle to runtime bundle to avoid NPE
+ synchronized (this) {
+ endpointDescriptions.put(description, context.getBundle());
+ endpointChanged(description, ADDED);
+ }
+ }
+
+ public void endpointRemoved(Endpoint endpoint) {
+ EndpointDescription description = createEndpointDescription(context, endpoint);
+ synchronized (this) {
+ endpointDescriptions.remove(description);
+ endpointChanged(description, REMOVED);
+ }
+ }
+
+ public void endpointUpdated(Endpoint oldEndpoint, Endpoint newEndpoint) {
+ // FIXME: This is a quick and dirty way for the update
+ endpointRemoved(oldEndpoint);
+ endpointAdded(newEndpoint);
+ }
+
+ public void stop() {
+ if (domainRegistryFactory != null) {
+ domainRegistryFactory.removeListener(this);
+ if (endpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)endpointRegistry).stop();
+ }
+ domainRegistryFactory = null;
+ endpointRegistry = null;
+ super.stop();
+ }
+ }
+
+ @Override
+ protected Dictionary<String, Object> getProperties() {
+ Dictionary<String, Object> props = super.getProperties();
+ props.put(SUPPORTED_PROTOCOLS, new String[] {"org.osgi.sca"});
+ return props;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
new file mode 100644
index 0000000000..dc9ae096dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
@@ -0,0 +1,262 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.osgi.service.discovery.impl;
+
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper.getConfiguration;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class LocalDiscoveryService extends AbstractDiscoveryService implements BundleTrackerCustomizer {
+ private Deployer deployer;
+ private BundleTracker bundleTracker;
+ private Collection<ExtenderConfiguration> extenders = new ArrayList<ExtenderConfiguration>();
+
+ public LocalDiscoveryService(BundleContext context) {
+ super(context);
+ }
+
+ public void start() {
+ super.start();
+
+ UtilityExtensionPoint utilities = this.registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.deployer = utilities.getUtility(Deployer.class);
+ bundleTracker = new BundleTracker(context, Bundle.ACTIVE | Bundle.STARTING, this);
+ bundleTracker.open();
+ }
+
+ public static ServiceTracker getTracker(BundleContext context) {
+ Filter filter = null;
+ try {
+ filter =
+ context.createFilter("(& (" + Discovery.SUPPORTED_PROTOCOLS
+ + "=local) ("
+ + Constants.OBJECTCLASS
+ + "="
+ + Discovery.class.getName()
+ + "))");
+ } catch (InvalidSyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ return new ServiceTracker(context, filter, null);
+ }
+
+ private EndpointDescription createEndpointDescription(ServiceDescription sd) {
+ Map<String, Object> props = new HashMap<String, Object>(sd.getProperties());
+ props.put(Constants.OBJECTCLASS, sd.getInterfaces().toArray(new String[sd.getInterfaces().size()]));
+ if (!props.containsKey(ENDPOINT_SERVICE_ID)) {
+ props.put(ENDPOINT_SERVICE_ID, Long.valueOf(System.currentTimeMillis()));
+ }
+ if (!props.containsKey(ENDPOINT_FRAMEWORK_UUID)) {
+ props.put(ENDPOINT_FRAMEWORK_UUID, OSGiHelper.getFrameworkUUID(context));
+ }
+ if (!props.containsKey(ENDPOINT_ID)) {
+ props.put(ENDPOINT_ID, UUID.randomUUID().toString());
+ }
+
+ EndpointDescription sed = new EndpointDescription(props);
+ return sed;
+ }
+
+ private void removeServicesDeclaredInBundle(Bundle bundle) {
+ for (Iterator<Map.Entry<EndpointDescription, Bundle>> i = endpointDescriptions.entrySet().iterator(); i.hasNext();) {
+ Entry<EndpointDescription, Bundle> entry = i.next();
+ if (entry.getValue().equals(bundle)) {
+ serviceDescriptionRemoved(entry.getKey());
+ i.remove();
+ }
+ }
+ }
+
+ private void serviceDescriptionAdded(EndpointDescription endpointDescription) {
+ endpointChanged(endpointDescription, ADDED);
+ }
+
+ private void serviceDescriptionRemoved(EndpointDescription endpointDescription) {
+ endpointChanged(endpointDescription, REMOVED);
+ }
+
+ public void stop() {
+ if (bundleTracker != null) {
+ bundleTracker.close();
+ }
+ super.stop();
+ }
+
+ public Object addingBundle(Bundle bundle, BundleEvent event) {
+ if (bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null || bundle.getBundleId() == 0) {
+ // Ignore fragments
+ return null;
+ }
+ Collection<URL> scaConfigs = getConfiguration(bundle, "SCA-Configuration", "OSGI-INF/sca-config/*.xml");
+ Collection<URL> descriptions = getConfiguration(bundle, "Remote-Service", null);
+ if (scaConfigs.isEmpty() && descriptions.isEmpty()) {
+ return null;
+ }
+ ExtenderConfiguration extender = new ExtenderConfiguration();
+ for (URL url : scaConfigs) {
+ try {
+ SCAConfig scaConfig = deployer.loadXMLDocument(url, deployer.createMonitor());
+ extender.scaConfigs.add(scaConfig);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ for (URL url : descriptions) {
+ try {
+ ServiceDescriptions sds = deployer.loadXMLDocument(url, deployer.createMonitor());
+ extender.remoteServiceDescriptions.add(sds);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ // throw new ServiceRuntimeException(e);
+ }
+ }
+
+ // Add to the extenders before notifying the listeners (the endpoints may references to the config)
+ ExtenderConfiguration.validate(extenders, extender);
+ this.extenders.add(extender);
+
+ // Notify
+ for (ServiceDescriptions sds : extender.getRemoteServiceDescriptions()) {
+ for (ServiceDescription sd : sds) {
+ EndpointDescription sed = createEndpointDescription(sd);
+ endpointDescriptions.put(sed, bundle);
+ serviceDescriptionAdded(sed);
+ }
+ }
+
+ return extender;
+ }
+
+ public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
+ // STARTING --> ACTIVE
+ }
+
+ public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
+ if (object instanceof ExtenderConfiguration) {
+ extenders.remove((ExtenderConfiguration)object);
+ removeServicesDeclaredInBundle(bundle);
+ }
+ }
+
+ public Collection<ExtenderConfiguration> getConfigurations() {
+ return extenders;
+ }
+
+ public static class ExtenderConfiguration {
+ private Collection<SCAConfig> scaConfigs = new ArrayList<SCAConfig>();
+ private Collection<ServiceDescriptions> remoteServiceDescriptions = new ArrayList<ServiceDescriptions>();
+
+ public Collection<ServiceDescriptions> getRemoteServiceDescriptions() {
+ return remoteServiceDescriptions;
+ }
+
+ public Collection<SCAConfig> getSCAConfigs() {
+ return scaConfigs;
+ }
+
+ public static void validate(Collection<ExtenderConfiguration> configs, ExtenderConfiguration newConfig) {
+ Map<QName, Binding> bindings = new HashMap<QName, Binding>();
+ Map<QName, Intent> intents = new HashMap<QName, Intent>();
+ Map<QName, PolicySet> policySets = new HashMap<QName, PolicySet>();
+
+ for (ExtenderConfiguration config : configs) {
+ for (SCAConfig c : config.getSCAConfigs()) {
+ addBindings(bindings, c);
+ addIntents(intents, c);
+ addPolicySets(policySets, c);
+ }
+ }
+ for (SCAConfig c : newConfig.getSCAConfigs()) {
+ addBindings(bindings, c);
+ addIntents(intents, c);
+ addPolicySets(policySets, c);
+ }
+ }
+
+ private static void addIntents(Map<QName, Intent> intents, SCAConfig c) {
+ for (Intent i: c.getIntents()) {
+ if (intents.put(i.getName(), i) != null) {
+ throw new ServiceRuntimeException("Duplicate intent: " + i.getName());
+ }
+ }
+ }
+
+ private static void addPolicySets(Map<QName, PolicySet> policySets, SCAConfig c) {
+ for (PolicySet ps: c.getPolicySets()) {
+ if (policySets.put(ps.getName(), ps) != null) {
+ throw new ServiceRuntimeException("Duplicate policySet: " + ps.getName());
+ }
+ }
+ }
+
+ private static void addBindings(Map<QName, Binding> bindings, SCAConfig c) {
+ for (Binding b : c.getBindings()) {
+ QName name = new QName(c.getTargetNamespace(), b.getName());
+ if (bindings.put(name, b) != null) {
+ throw new ServiceRuntimeException("Duplicate binding: " + name);
+ }
+ }
+ }
+
+ }
+
+ @Override
+ protected Dictionary<String, Object> getProperties() {
+ Dictionary<String, Object> props = super.getProperties();
+ props.put(SUPPORTED_PROTOCOLS, new String[] {"local"});
+ return props;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java
new file mode 100644
index 0000000000..ee7e5ba1bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java
@@ -0,0 +1,682 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2010). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.*;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+
+/**
+ * A description of an endpoint that provides sufficient information for a
+ * compatible distribution provider to create a connection to this endpoint
+ *
+ * An Endpoint Description is easy to transfer between different systems because
+ * it is property based where the property keys are strings and the values are
+ * simple types. This allows it to be used as a communications device to convey
+ * available endpoint information to nodes in a network.
+ *
+ * An Endpoint Description reflects the perspective of an <i>importer</i>. That
+ * is, the property keys have been chosen to match filters that are created by
+ * client bundles that need a service. Therefore the map must not contain any
+ * <code>service.exported.*</code> property and must contain the corresponding
+ * <code>service.imported.*</code> ones.
+ *
+ * The <code>service.intents</code> property must contain the intents provided
+ * by the service itself combined with the intents added by the exporting
+ * distribution provider. Qualified intents appear fully expanded on this
+ * property.
+ *
+ * @Immutable
+ * @version $Revision$
+ */
+
+public class EndpointDescription {
+ private final Map<String, Object> properties;
+ private final List<String> interfaces;
+ private final long serviceId;
+ private final String frameworkUUID;
+ private final String id;
+
+ /**
+ * Create an Endpoint Description from a Map.
+ *
+ * <p>
+ * The {@link RemoteConstants#ENDPOINT_ID endpoint.id},
+ * {@link RemoteConstants#SERVICE_IMPORTED_CONFIGS service.imported.configs}
+ * and <code>objectClass</code> properties must be set.
+ *
+ * @param properties The map from which to create the Endpoint Description.
+ * The keys in the map must be type <code>String</code> and, since
+ * the keys are case insensitive, there must be no duplicates with
+ * case variation.
+ * @throws IllegalArgumentException When the properties are not proper for
+ * an Endpoint Description.
+ */
+
+ public EndpointDescription(Map<String, Object> properties) {
+ Map<String, Object> props = new TreeMap<String, Object>(
+ String.CASE_INSENSITIVE_ORDER);
+ try {
+ props.putAll(properties);
+ }
+ catch (ClassCastException e) {
+ IllegalArgumentException iae = new IllegalArgumentException(
+ "non-String key in properties");
+ iae.initCause(e);
+ throw iae;
+ }
+ if (props.size() < properties.size()) {
+ throw new IllegalArgumentException(
+ "duplicate keys with different cases in properties: "
+ + new ArrayList<String>(props.keySet())
+ .removeAll(properties.keySet()));
+ }
+
+ if (!props.containsKey(SERVICE_IMPORTED)) {
+ props.put(SERVICE_IMPORTED, Boolean.toString(true));
+ }
+ this.properties = Collections.unmodifiableMap(props);
+ /* properties must be initialized before calling the following methods */
+ interfaces = verifyObjectClassProperty();
+ serviceId = verifyLongProperty(ENDPOINT_SERVICE_ID);
+ frameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID);
+ id = verifyStringProperty(ENDPOINT_ID);
+ if (id == null) {
+ throw new IllegalArgumentException(ENDPOINT_ID
+ + " property must be set");
+ }
+ if (getConfigurationTypes().isEmpty()) {
+ throw new IllegalArgumentException(SERVICE_IMPORTED_CONFIGS
+ + " property must be set and non-empty");
+ }
+ }
+
+ /**
+ * Create an Endpoint Description based on a Service Reference and a Map of
+ * properties. The properties in the map take precedence over the properties
+ * in the Service Reference.
+ *
+ * <p>
+ * This method will automatically set the
+ * {@link RemoteConstants#ENDPOINT_FRAMEWORK_UUID endpoint.framework.uuid}
+ * and {@link RemoteConstants#ENDPOINT_SERVICE_ID endpoint.service.id}
+ * properties based on the specified Service Reference as well as the
+ * {@link RemoteConstants#SERVICE_IMPORTED service.imported} property if
+ * they are not specified as properties.
+ * <p>
+ * The {@link RemoteConstants#ENDPOINT_ID endpoint.id},
+ * {@link RemoteConstants#SERVICE_IMPORTED_CONFIGS service.imported.configs}
+ * and <code>objectClass</code> properties must be set.
+ *
+ * @param reference A service reference that can be exported.
+ * @param properties Map of properties. This argument can be
+ * <code>null</code>. The keys in the map must be type
+ * <code>String</code> and, since the keys are case insensitive,
+ * there must be no duplicates with case variation.
+ * @throws IllegalArgumentException When the properties are not proper for
+ * an Endpoint Description
+ */
+ public EndpointDescription(final ServiceReference reference,
+ final Map<String, Object> properties) {
+ Map<String, Object> props = new TreeMap<String, Object>(
+ String.CASE_INSENSITIVE_ORDER);
+
+ if (properties != null) {
+ try {
+ props.putAll(properties);
+ }
+ catch (ClassCastException e) {
+ IllegalArgumentException iae = new IllegalArgumentException(
+ "non-String key in properties");
+ iae.initCause(e);
+ throw iae;
+ }
+ if (props.size() < properties.size()) {
+ throw new IllegalArgumentException(
+ "duplicate keys with different cases in properties: "
+ + new ArrayList<String>(props.keySet())
+ .removeAll(properties.keySet()));
+ }
+ }
+
+ for (String key : reference.getPropertyKeys()) {
+ if (!props.containsKey(key)) {
+ props.put(key, reference.getProperty(key));
+ }
+ }
+
+ if (!props.containsKey(ENDPOINT_SERVICE_ID)) {
+ props.put(ENDPOINT_SERVICE_ID, reference.getProperty(Constants.SERVICE_ID));
+ }
+ if (!props.containsKey(ENDPOINT_FRAMEWORK_UUID)) {
+ String uuid = null;
+ try {
+ uuid = AccessController
+ .doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return reference.getBundle().getBundleContext()
+ .getProperty("org.osgi.framework.uuid");
+ }
+ });
+ }
+ catch (SecurityException e) {
+ // if we don't have permission, we can't get the property
+ }
+ if (uuid != null) {
+ props.put(ENDPOINT_FRAMEWORK_UUID, uuid);
+ }
+ }
+ if (!props.containsKey(SERVICE_IMPORTED)) {
+ props.put(SERVICE_IMPORTED, Boolean.toString(true));
+ }
+ this.properties = Collections.unmodifiableMap(props);
+ /* properties must be initialized before calling the following methods */
+ interfaces = verifyObjectClassProperty();
+ serviceId = verifyLongProperty(ENDPOINT_SERVICE_ID);
+ frameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID);
+ id = verifyStringProperty(ENDPOINT_ID);
+ if (id == null) {
+ throw new IllegalArgumentException(ENDPOINT_ID
+ + " property must be set");
+ }
+ if (getConfigurationTypes().isEmpty()) {
+ throw new IllegalArgumentException(SERVICE_IMPORTED_CONFIGS
+ + " property must be set and non-empty");
+ }
+ }
+
+ /**
+ * Verify and obtain the interface list from the properties.
+ *
+ * @return A list with the interface names.
+ * @throws IllegalArgumentException If the objectClass property is not set
+ * or is empty or if the package version property values are
+ * malformed.
+ */
+ private List<String> verifyObjectClassProperty() {
+ Object o = properties.get(Constants.OBJECTCLASS);
+ if (!(o instanceof String[])) {
+ throw new IllegalArgumentException(
+ "objectClass value must be of type String[]");
+ }
+ String[] objectClass = (String[]) o;
+ if (objectClass.length < 1) {
+ throw new IllegalArgumentException("objectClass is empty");
+ }
+ for (String interf : objectClass) {
+ int index = interf.lastIndexOf('.');
+ if (index == -1) {
+ continue;
+ }
+ String packageName = interf.substring(0, index);
+ try {
+ /* Make sure any package version properties are well formed */
+ getPackageVersion(packageName);
+ }
+ catch (IllegalArgumentException e) {
+ IllegalArgumentException iae = new IllegalArgumentException(
+ "Improper version for package " + packageName);
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+ return Collections.unmodifiableList(Arrays.asList(objectClass));
+ }
+
+ /**
+ * Verify and obtain a required String property.
+ *
+ * @param propName The name of the property
+ * @return The value of the property or null if the property is not set.
+ * @throws IllegalArgumentException when the property doesn't have the
+ * correct data type.
+ */
+ private String verifyStringProperty(String propName) {
+ Object r = properties.get(propName);
+ try {
+ return (String) r;
+ }
+ catch (ClassCastException e) {
+ IllegalArgumentException iae = new IllegalArgumentException(
+ "property value is not a String: " + propName);
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+
+ /**
+ * Verify and obtain a required long property.
+ *
+ * @param propName The name of the property
+ * @return The value of the property or 0 if the property is not set.
+ * @throws IllegalArgumentException when the property doesn't have the
+ * correct data type.
+ */
+ private long verifyLongProperty(String propName) {
+ Object r = properties.get(propName);
+ if (r == null) {
+ return 0l;
+ }
+ try {
+ return ((Long) r).longValue();
+ }
+ catch (ClassCastException e) {
+ IllegalArgumentException iae = new IllegalArgumentException(
+ "property value is not a Long: " + propName);
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+
+ /**
+ * Returns the endpoint's id.
+ *
+ * The id is an opaque id for an endpoint. No two different endpoints must
+ * have the same id. Two Endpoint Descriptions with the same id must
+ * represent the same endpoint.
+ *
+ * The value of the id is stored in the
+ * {@link RemoteConstants#ENDPOINT_ID} property.
+ *
+ * @return The id of the endpoint, never <code>null</code>.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Provide the list of interfaces implemented by the exported service.
+ *
+ * The value of the interfaces is derived from the <code>objectClass</code>
+ * property.
+ *
+ * @return An unmodifiable list of Java interface names implemented by this
+ * endpoint.
+ */
+ public List<String> getInterfaces() {
+ return interfaces;
+ }
+
+ /**
+ * Provide the version of the given package name.
+ *
+ * The version is encoded by prefixing the given package name with
+ * {@link RemoteConstants#ENDPOINT_PACKAGE_VERSION_
+ * endpoint.package.version.}, and then using this as an endpoint property
+ * key. For example:
+ *
+ * <pre>
+ * endpoint.package.version.com.acme
+ * </pre>
+ *
+ * The value of this property is in String format and will be converted to a
+ * <code>Version</code> object by this method.
+ *
+ * @param packageName The name of the package for which a version is
+ * requested.
+ * @return The version of the specified package or
+ * <code>Version.emptyVersion</code> if the package has no version
+ * in this Endpoint Description.
+ * @throws IllegalArgumentException If the version property value is not
+ * String.
+ */
+ public Version getPackageVersion(String packageName) {
+ String key = ENDPOINT_PACKAGE_VERSION_ + packageName;
+ Object value = properties.get(key);
+ String version;
+ try {
+ version = (String) value;
+ }
+ catch (ClassCastException e) {
+ IllegalArgumentException iae = new IllegalArgumentException(key
+ + " property value is not a String");
+ iae.initCause(e);
+ throw iae;
+ }
+ return Version.parseVersion(version);
+ }
+
+ /**
+ * Returns the service id for the service exported through this endpoint.
+ *
+ * This is the service id under which the framework has registered the
+ * service. This field together with the Framework UUID is a globally unique
+ * id for a service.
+ *
+ * The value of the remote service id is stored in the
+ * {@link RemoteConstants#ENDPOINT_SERVICE_ID} endpoint property.
+ *
+ * @return Service id of a service or 0 if this Endpoint Description does
+ * not relate to an OSGi service.
+ *
+ */
+ public long getServiceId() {
+ return serviceId;
+ }
+
+ /**
+ * Returns the configuration types.
+ *
+ * A distribution provider exports a service with an endpoint. This endpoint
+ * uses some kind of communications protocol with a set of configuration
+ * parameters. There are many different types but each endpoint is
+ * configured by only one configuration type. However, a distribution
+ * provider can be aware of different configuration types and provide
+ * synonyms to increase the change a receiving distribution provider can
+ * create a connection to this endpoint.
+ *
+ * This value of the configuration types is stored in the
+ * {@link RemoteConstants#SERVICE_IMPORTED_CONFIGS} service property.
+ *
+ * @return An unmodifiable list of the configuration types used for the
+ * associated endpoint and optionally synonyms.
+ */
+ public List<String> getConfigurationTypes() {
+ return getStringPlusProperty(SERVICE_IMPORTED_CONFIGS);
+ }
+
+ /**
+ * Return the list of intents implemented by this endpoint.
+ *
+ * The intents are based on the service.intents on an imported service,
+ * except for any intents that are additionally provided by the importing
+ * distribution provider. All qualified intents must have been expanded.
+ *
+ * This value of the intents is stored in the
+ * {@link RemoteConstants#SERVICE_INTENTS} service property.
+ *
+ * @return An unmodifiable list of expanded intents that are provided by
+ * this endpoint.
+ */
+ public List<String> getIntents() {
+ return getStringPlusProperty(SERVICE_INTENTS);
+ }
+
+ /**
+ * Reads a 'String+' property from the properties map, which may be of type
+ * String, String[] or Collection<String> and returns it as an unmodifiable
+ * List.
+ *
+ * @param key The property
+ * @return An unmodifiable list
+ */
+ private List<String> getStringPlusProperty(String key) {
+ Object value = properties.get(key);
+ if (value == null) {
+ return Collections.EMPTY_LIST;
+ }
+
+ if (value instanceof String) {
+ return Collections.singletonList((String) value);
+ }
+
+ if (value instanceof String[]) {
+ String[] values = (String[]) value;
+ List<String> result = new ArrayList<String>(values.length);
+ for (String v : values) {
+ if (v != null) {
+ result.add(v);
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ if (value instanceof Collection< ? >) {
+ Collection< ? > values = (Collection< ? >) value;
+ List<String> result = new ArrayList<String>(values.size());
+ for (Iterator< ? > iter = values.iterator(); iter.hasNext();) {
+ Object v = iter.next();
+ if (v instanceof String) {
+ result.add((String) v);
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * Return the framework UUID for the remote service, if present.
+ *
+ * The value of the remote framework uuid is stored in the
+ * {@link RemoteConstants#ENDPOINT_FRAMEWORK_UUID} endpoint property.
+ *
+ * @return Remote Framework UUID, or null if this endpoint is not associated
+ * with an OSGi framework having a framework uuid.
+ */
+ public String getFrameworkUUID() {
+ return frameworkUUID;
+ }
+
+ /**
+ * Returns all endpoint properties.
+ *
+ * @return An unmodifiable map referring to the properties of this Endpoint
+ * Description.
+ */
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ /**
+ * Answers if this Endpoint Description refers to the same service instance
+ * as the given Endpoint Description.
+ *
+ * Two Endpoint Descriptions point to the same service if they have the same
+ * id or their framework UUIDs and remote service ids are equal.
+ *
+ * @param other The Endpoint Description to look at
+ * @return True if this endpoint description points to the same service as
+ * the other
+ */
+ public boolean isSameService(EndpointDescription other) {
+ if (this.equals(other)) {
+ return true;
+ }
+
+ if (this.getFrameworkUUID() == null) {
+ return false;
+ }
+
+ return (this.getServiceId() == other.getServiceId())
+ && this.getFrameworkUUID().equals(
+ other.getFrameworkUUID());
+ }
+
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return An integer which is a hash code value for this object.
+ */
+ public int hashCode() {
+ return getId().hashCode();
+ }
+
+ /**
+ * Compares this <code>EndpointDescription</code> object to another object.
+ *
+ * <p>
+ * An Endpoint Description is considered to be <b>equal to</b> another
+ * Endpoint Description if their ids are equal.
+ *
+ * @param other The <code>EndpointDescription</code> object to be compared.
+ * @return <code>true</code> if <code>object</code> is a
+ * <code>EndpointDescription</code> and is equal to this object;
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof EndpointDescription)) {
+ return false;
+ }
+ return getId().equals(
+ ((EndpointDescription) other).getId());
+ }
+
+ /**
+ * Tests the properties of this <code>EndpointDescription</code> against
+ * the given filter using a case insensitive match.
+ *
+ * @param filter The filter to test.
+ * @return <code>true</code> If the properties of this
+ * <code>EndpointDescription</code> match the filter,
+ * <code>false</code> otherwise.
+ * @throws IllegalArgumentException If <code>filter</code> contains an
+ * invalid filter string that cannot be parsed.
+ */
+ public boolean matches(String filter) {
+ Filter f;
+ try {
+ f = FrameworkUtil.createFilter(filter);
+ }
+ catch (InvalidSyntaxException e) {
+ IllegalArgumentException iae = new IllegalArgumentException(e
+ .getMessage());
+ iae.initCause(e);
+ throw iae;
+ }
+ Dictionary<String, Object> d = new UnmodifiableDictionary<String, Object>(
+ properties);
+ /*
+ * we can use matchCase here since properties already supports case
+ * insensitive key lookup.
+ */
+ return f.matchCase(d);
+ }
+
+ /**
+ * Returns the string representation of this EndpointDescription.
+ *
+ * @return String form of this EndpointDescription.
+ */
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append('{');
+ Iterator<Map.Entry<String, Object>> iter = properties.entrySet()
+ .iterator();
+ boolean comma = false;
+ while (iter.hasNext()) {
+ Map.Entry<String, Object> entry = iter.next();
+ if (comma) {
+ sb.append(", ");
+ }
+ else {
+ comma = true;
+ }
+ sb.append(entry.getKey());
+ sb.append('=');
+ Object value = entry.getValue();
+ if (value != null) {
+ Class< ? > valueType = value.getClass();
+ if (Object[].class.isAssignableFrom(valueType)) {
+ append(sb, (Object[]) value);
+ continue;
+ }
+ }
+ sb.append(value);
+ }
+ sb.append('}');
+ return sb.toString();
+ }
+
+ /**
+ * Append the specified Object array to the specified StringBuffer.
+ *
+ * @param sb Receiving StringBuffer.
+ * @param value Object array to append to the specified StringBuffer.
+ */
+ private static void append(StringBuffer sb, Object[] value) {
+ sb.append('[');
+ boolean comma = false;
+ final int length = value.length;
+ for (int i = 0; i < length; i++) {
+ if (comma) {
+ sb.append(", ");
+ }
+ else {
+ comma = true;
+ }
+ sb.append(String.valueOf(value[i]));
+ }
+ sb.append(']');
+ }
+
+ /**
+ * Unmodifiable Dictionary wrapper for a Map. This class is also used by
+ * EndpointPermission.
+ */
+ static class UnmodifiableDictionary<K, V> extends Dictionary<K, V> {
+ private final Map<K, V> wrapped;
+
+ UnmodifiableDictionary(Map<K, V> wrapped) {
+ this.wrapped = wrapped;
+ }
+
+ public Enumeration<V> elements() {
+ return Collections.enumeration(wrapped.values());
+ }
+
+ public V get(Object key) {
+ return wrapped.get(key);
+ }
+
+ public boolean isEmpty() {
+ return wrapped.isEmpty();
+ }
+
+ public Enumeration<K> keys() {
+ return Collections.enumeration(wrapped.keySet());
+ }
+
+ public V put(K key, V value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public V remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int size() {
+ return wrapped.size();
+ }
+
+ public String toString() {
+ return wrapped.toString();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointListener.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointListener.java
new file mode 100644
index 0000000000..941b899fbb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointListener.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+/**
+ * A white board service that represents a listener for endpoints.
+ *
+ * An Endpoint Listener represents a participant in the distributed model that
+ * is interested in Endpoint Descriptions.
+ *
+ * This white board service can be used in many different scenarios. However,
+ * the primary use case is to allow a remote manager to be informed of Endpoint
+ * Descriptions available in the network and inform the network about available
+ * Endpoint Descriptions.
+ *
+ * Both the network bundle and the manager bundle register an Endpoint Listener
+ * service. The manager informs the network bundle about Endpoints that it
+ * creates. The network bundles then uses a protocol like SLP to announce these
+ * local end-points to the network.
+ *
+ * If the network bundle discovers a new Endpoint through its discovery
+ * protocol, then it sends an Endpoint Description to all the Endpoint
+ * Listener services that are registered (except its own) that have specified an
+ * interest in that endpoint.
+ *
+ * Endpoint Listener services can express their <i>scope</i> with the service
+ * property {@link #ENDPOINT_LISTENER_SCOPE}. This service property is a list of
+ * filters. An Endpoint Description should only be given to a Endpoint Listener
+ * when there is at least one filter that matches the Endpoint Description
+ * properties. given to it.
+ *
+ * This filter model is quite flexible. For example, a discovery bundle is only
+ * interested in locally originating Endpoint Descriptions. The following filter
+ * ensure that it only sees local endpoints.
+ *
+ * <pre>
+ * (org.osgi.framework.uuid=72dc5fd9-5f8f-4f8f-9821-9ebb433a5b72)
+ * </pre>
+ *
+ * In the same vein, a manager that is only interested in remote Endpoint
+ * Descriptions can use a filter like:
+ *
+ * <pre>
+ * (!(org.osgi.framework.uuid=72dc5fd9-5f8f-4f8f-9821-9ebb433a5b72))
+ * </pre>
+ *
+ * Where in both cases, the given UUID is the UUID of the local framework that
+ * can be found in the Framework properties.
+ *
+ * The Endpoint Listener's scope maps very well to the service hooks. A manager
+ * can just register all filters found from the Listener Hook as its scope. This
+ * will automatically provide it with all known endpoints that match the given
+ * scope, without having to inspect the filter string.
+ *
+ * In general, when an Endpoint Description is discovered, it should be
+ * dispatched to all registered Endpoint Listener services. If a new Endpoint
+ * Listener is registered, it should be informed about all currently known
+ * Endpoints that match its scope. If a getter of the Endpoint Listener service
+ * is unregistered, then all its registered Endpoint Description objects must be
+ * removed.
+ *
+ * The Endpoint Listener models a <i>best effort</i> approach. Participating
+ * bundles should do their utmost to keep the listeners up to date, but
+ * implementers should realize that many endpoints come through unreliable
+ * discovery processes.
+ *
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+public interface EndpointListener {
+ /**
+ * Specifies the interest of this listener with filters. This listener is
+ * only interested in Endpoint Descriptions where its properties match the
+ * given filter. The type of this property must be <code>String+</code>.
+ */
+ String ENDPOINT_LISTENER_SCOPE = "endpoint.listener.scope";
+
+ /**
+ * Register an endpoint with this listener.
+ *
+ * If the endpoint matches one of the filters registered with the
+ * {@link #ENDPOINT_LISTENER_SCOPE} service property then this filter should
+ * be given as the <code>matchedFilter</code> parameter.
+ *
+ * When this service is first registered or it is modified, it should
+ * receive all known endpoints matching the filter.
+ *
+ * @param endpoint The Endpoint Description to be published
+ * @param matchedFilter The filter from the {@link #ENDPOINT_LISTENER_SCOPE}
+ * that matched the endpoint, must not be <code>null</code>.
+ */
+ void endpointAdded(EndpointDescription endpoint, String matchedFilter);
+
+ /**
+ * Remove the registration of an endpoint.
+ *
+ * If an endpoint that was registered with the
+ * {@link #endpointAdded(EndpointDescription, String)} method is no longer
+ * available then this method should be called. This will remove the
+ * endpoint from the listener.
+ *
+ * It is not necessary to remove endpoints when the service is unregistered
+ * or modified in such a way that not all endpoints match the interest
+ * filter anymore.
+ *
+ * @param endpoint The Endpoint Description that is no longer valid.
+ * @param matchedFilter The filter from the {@link #ENDPOINT_LISTENER_SCOPE}
+ * that matched the endpoint, must not be <code>null</code>.
+ */
+ void endpointRemoved(EndpointDescription endpoint, String matchedFilter);
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java
new file mode 100644
index 0000000000..433e22e543
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java
@@ -0,0 +1,693 @@
+/*
+ * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.*;
+
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * A bundle's authority to export, import or read an Endpoint.
+ * <ul>
+ * <li>The <code>export</code> action allows a bundle to export a service as an
+ * Endpoint.</li>
+ * <li>The <code>import</code> action allows a bundle to import a service from
+ * an Endpoint.</li>
+ * <li>The <code>read</code> action allows a bundle to read references to an
+ * Endpoint.</li>
+ * </ul>
+ * Permission to read an Endpoint is required in order to detect events
+ * regarding an Endpoint. Untrusted bundles should not be able to detect the
+ * presence of certain Endpoints unless they have the appropriate
+ * <code>EndpointPermission</code> to read the specific service.
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+
+public final class EndpointPermission extends Permission {
+ static final long serialVersionUID = -7662148639076511574L;
+ /**
+ * The action string <code>read</code>.
+ */
+ public final static String READ = "read";
+ /**
+ * The action string <code>import</code>. The <code>import</code> action
+ * implies the <code>read</code> action.
+ */
+ public final static String IMPORT = "import";
+ /**
+ * The action string <code>export</code>. The <code>export</code> action
+ * implies the <code>read</code> action.
+ */
+ public final static String EXPORT = "export";
+
+ private final static int ACTION_READ = 0x00000001;
+ private final static int ACTION_IMPORT = 0x00000002;
+ private final static int ACTION_EXPORT = 0x00000004;
+ private final static int ACTION_ALL = ACTION_EXPORT
+ | ACTION_IMPORT
+ | ACTION_READ;
+ final static int ACTION_NONE = 0;
+
+ /**
+ * The actions mask.
+ */
+ transient int action_mask;
+
+ /**
+ * The actions in canonical form.
+ *
+ * @serial
+ */
+ private volatile String actions = null;
+
+ /**
+ * The endpoint used by this EndpointPermission. Must be null if not
+ * constructed with a endpoint.
+ */
+ transient final EndpointDescription endpoint;
+
+ /**
+ * This dictionary holds the properties of the permission, used to match a
+ * filter in implies.
+ */
+ private transient final Dictionary<String, Object> properties;
+
+ /**
+ * If this EndpointPermission was not constructed with an
+ * EndpointDescription, this holds a Filter matching object used to evaluate
+ * the filter in implies or null for wildcard.
+ */
+ transient Filter filter;
+
+ /**
+ * Create a new EndpointPermission with the specified filter.
+ *
+ * <p>
+ * The filter will be evaluated against the endpoint properties of a
+ * requested EndpointPermission.
+ *
+ * <p>
+ * There are three possible actions: <code>read</code>, <code>import</code>
+ * and <code>export</code>. The <code>read</code> action allows the owner of
+ * this permission to see the presence of distributed services. The
+ * <code>import</code> action allows the owner of this permission to import
+ * an endpoint. The <code>export</code> action allows the owner of this
+ * permission to export a service.
+ *
+ * @param filterString The filter string or &quot;*&quot; to match all
+ * endpoints.
+ * @param actions The actions <code>read</code>, <code>import</code>, or
+ * <code>export</code>.
+ * @throws IllegalArgumentException If the filter has an invalid syntax or
+ * the actions are not valid.
+ */
+ public EndpointPermission(String filterString, String actions) {
+ this(filterString, parseActions(actions));
+ }
+
+ /**
+ * Creates a new requested <code>EndpointPermission</code> object to be used
+ * by code that must perform <code>checkPermission</code>.
+ * <code>EndpointPermission</code> objects created with this constructor
+ * cannot be added to an <code>EndpointPermission</code> permission
+ * collection.
+ *
+ * @param endpoint The requested endpoint.
+ * @param localFrameworkUUID The UUID of the local framework. This is used
+ * to support matching the
+ * {@link RemoteConstants#ENDPOINT_FRAMEWORK_UUID
+ * endpoint.framework.uuid} endpoint property to the
+ * <code>&lt;&lt;LOCAL&gt;&gt;</code> value in the filter expression.
+ * @param actions The actions <code>read</code>, <code>import</code>, or
+ * <code>export</code>.
+ * @throws IllegalArgumentException If the endpoint is <code>null</code> or
+ * the actions are not valid.
+ */
+ public EndpointPermission(EndpointDescription endpoint,
+ String localFrameworkUUID, String actions) {
+ super(createName(endpoint));
+ setTransients(null, parseActions(actions));
+ Map<String, Object> props;
+ if ((localFrameworkUUID != null)
+ && localFrameworkUUID.equals(endpoint.getFrameworkUUID())) {
+ props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
+ props.putAll(endpoint.getProperties());
+ props.put(ENDPOINT_FRAMEWORK_UUID, new String[] {
+ endpoint.getFrameworkUUID(), "<<LOCAL>>"});
+ }
+ else {
+ props = endpoint.getProperties();
+ }
+ this.endpoint = endpoint;
+ this.properties = new EndpointDescription.UnmodifiableDictionary<String, Object>(
+ props);
+ }
+
+ /**
+ * Create a permission name from a EndpointDescription.
+ *
+ * @param endpoint EndpointDescription to use to create permission name.
+ * @return permission name.
+ */
+ private static String createName(EndpointDescription endpoint) {
+ if (endpoint == null) {
+ throw new IllegalArgumentException("invalid endpoint: null");
+ }
+ StringBuffer sb = new StringBuffer("(" + ENDPOINT_ID + "=");
+ sb.append(endpoint.getId());
+ sb.append(")");
+ return sb.toString();
+ }
+
+ /**
+ * Package private constructor used by EndpointPermissionCollection.
+ *
+ * @param name class name
+ * @param mask action mask
+ */
+ EndpointPermission(String name, int mask) {
+ super(name);
+ setTransients(parseFilter(name), mask);
+ this.endpoint = null;
+ this.properties = null;
+ }
+
+ /**
+ * Called by constructors and when deserialized.
+ *
+ * @param mask action mask
+ */
+ private void setTransients(Filter f, int mask) {
+ if ((mask == ACTION_NONE) || ((mask & ACTION_ALL) != mask)) {
+ throw new IllegalArgumentException("invalid action string");
+ }
+ action_mask = mask;
+ filter = f;
+ }
+
+ /**
+ * Parse action string into action mask.
+ *
+ * @param actions Action string.
+ * @return action mask.
+ */
+ private static int parseActions(String actions) {
+ boolean seencomma = false;
+
+ int mask = ACTION_NONE;
+
+ if (actions == null) {
+ return mask;
+ }
+
+ char[] a = actions.toCharArray();
+
+ int i = a.length - 1;
+ if (i < 0)
+ return mask;
+
+ while (i != -1) {
+ char c;
+
+ // skip whitespace
+ while ((i != -1)
+ && ((c = a[i]) == ' ' || c == '\r' || c == '\n'
+ || c == '\f' || c == '\t'))
+ i--;
+
+ // check for the known strings
+ int matchlen;
+
+ if (i >= 5 && (a[i - 5] == 'i' || a[i - 5] == 'I')
+ && (a[i - 4] == 'm' || a[i - 4] == 'M')
+ && (a[i - 3] == 'p' || a[i - 3] == 'P')
+ && (a[i - 2] == 'o' || a[i - 2] == 'O')
+ && (a[i - 1] == 'r' || a[i - 1] == 'R')
+ && (a[i] == 't' || a[i] == 'T')) {
+ matchlen = 6;
+ mask |= ACTION_IMPORT | ACTION_READ;
+
+ }
+ else
+ if (i >= 5 && (a[i - 5] == 'e' || a[i - 5] == 'E')
+ && (a[i - 4] == 'x' || a[i - 4] == 'X')
+ && (a[i - 3] == 'p' || a[i - 3] == 'P')
+ && (a[i - 2] == 'o' || a[i - 2] == 'O')
+ && (a[i - 1] == 'r' || a[i - 1] == 'R')
+ && (a[i] == 't' || a[i] == 'T')) {
+ matchlen = 6;
+ mask |= ACTION_EXPORT | ACTION_READ;
+
+ }
+ else {
+ if (i >= 3 && (a[i - 3] == 'r' || a[i - 3] == 'R')
+ && (a[i - 2] == 'e' || a[i - 2] == 'E')
+ && (a[i - 1] == 'a' || a[i - 1] == 'A')
+ && (a[i] == 'd' || a[i] == 'D')) {
+ matchlen = 4;
+ mask |= ACTION_READ;
+
+ }
+ else {
+ // parse error
+ throw new IllegalArgumentException(
+ "invalid permission: " + actions);
+ }
+ }
+
+ // make sure we didn't just match the tail of a word
+ // like "ackbarfread". Also, skip to the comma.
+ seencomma = false;
+ while (i >= matchlen && !seencomma) {
+ switch (a[i - matchlen]) {
+ case ',' :
+ seencomma = true;
+ /* FALLTHROUGH */
+ case ' ' :
+ case '\r' :
+ case '\n' :
+ case '\f' :
+ case '\t' :
+ break;
+ default :
+ throw new IllegalArgumentException(
+ "invalid permission: " + actions);
+ }
+ i--;
+ }
+
+ // point i at the location of the comma minus one (or -1).
+ i -= matchlen;
+ }
+
+ if (seencomma) {
+ throw new IllegalArgumentException("invalid permission: " + actions);
+ }
+
+ return mask;
+ }
+
+ /**
+ * Parse filter string into a Filter object.
+ *
+ * @param filterString The filter string to parse.
+ * @return a Filter for this bundle.
+ * @throws IllegalArgumentException If the filter syntax is invalid.
+ */
+ private static Filter parseFilter(String filterString) {
+ if (filterString == null) {
+ throw new IllegalArgumentException("invalid filter: null");
+ }
+ filterString = filterString.trim();
+ if (filterString.equals("*")) {
+ return null; // wildcard
+ }
+ try {
+ return FrameworkUtil.createFilter(filterString);
+ }
+ catch (InvalidSyntaxException e) {
+ IllegalArgumentException iae = new IllegalArgumentException(
+ "invalid filter");
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+
+ /**
+ * Determines if a <code>EndpointPermission</code> object "implies" the
+ * specified permission.
+ *
+ * @param p The target permission to check.
+ * @return <code>true</code> if the specified permission is implied by this
+ * object; <code>false</code> otherwise.
+ */
+ public boolean implies(Permission p) {
+ if (!(p instanceof EndpointPermission)) {
+ return false;
+ }
+ EndpointPermission requested = (EndpointPermission) p;
+ if (endpoint != null) {
+ return false;
+ }
+ // if requested permission has a filter, then it is an invalid argument
+ if (requested.filter != null) {
+ return false;
+ }
+ return implies0(requested, ACTION_NONE);
+ }
+
+ /**
+ * Internal implies method. Used by the implies and the permission
+ * collection implies methods.
+ *
+ * @param requested The requested EndpointPermission which has already be
+ * validated as a proper argument. The requested EndpointPermission
+ * must not have a filter expression.
+ * @param effective The effective actions with which to start.
+ * @return <code>true</code> if the specified permission is implied by this
+ * object; <code>false</code> otherwise.
+ */
+ boolean implies0(EndpointPermission requested, int effective) {
+ /* check actions first - much faster */
+ effective |= action_mask;
+ final int desired = requested.action_mask;
+ if ((effective & desired) != desired) {
+ return false;
+ }
+ /* if we have no filter */
+ Filter f = filter;
+ if (f == null) {
+ // it's "*"
+ return true;
+ }
+ return f.matchCase(requested.getProperties());
+ }
+
+ /**
+ * Returns the canonical string representation of the actions. Always
+ * returns present actions in the following canonical order:
+ * <code>read</code>, <code>import</code>, <code>export</code>.
+ *
+ * @return The canonical string representation of the actions.
+ */
+ public String getActions() {
+ String result = actions;
+ if (result == null) {
+ StringBuffer sb = new StringBuffer();
+ boolean comma = false;
+
+ int mask = action_mask;
+ if ((mask & ACTION_READ) == ACTION_READ) {
+ sb.append(READ);
+ comma = true;
+ }
+
+ if ((mask & ACTION_IMPORT) == ACTION_IMPORT) {
+ if (comma)
+ sb.append(',');
+ sb.append(IMPORT);
+ }
+
+ if ((mask & ACTION_EXPORT) == ACTION_EXPORT) {
+ if (comma)
+ sb.append(',');
+ sb.append(EXPORT);
+ }
+
+ actions = result = sb.toString();
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns a new <code>PermissionCollection</code> object for storing
+ * <code>EndpointPermission<code> objects.
+ *
+ * @return A new <code>PermissionCollection</code> object suitable for
+ * storing <code>EndpointPermission</code> objects.
+ */
+ public PermissionCollection newPermissionCollection() {
+ return new EndpointPermissionCollection();
+ }
+
+ /**
+ * Determines the equality of two EndpointPermission objects.
+ *
+ * Checks that specified object has the same name, actions and endpoint as
+ * this <code>EndpointPermission</code>.
+ *
+ * @param obj The object to test for equality.
+ * @return true if obj is a <code>EndpointPermission</code>, and has the
+ * same name, actions and endpoint as this
+ * <code>EndpointPermission</code> object; <code>false</code>
+ * otherwise.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof EndpointPermission)) {
+ return false;
+ }
+
+ EndpointPermission ep = (EndpointPermission) obj;
+
+ return (action_mask == ep.action_mask)
+ && getName().equals(ep.getName())
+ && ((endpoint == ep.endpoint) || ((endpoint != null)
+ && (ep.endpoint != null) && endpoint
+ .equals(ep.endpoint)));
+ }
+
+ /**
+ * Returns the hash code value for this object.
+ *
+ * @return Hash code value for this object.
+ */
+ public int hashCode() {
+ int h = 31 * 17 + getName().hashCode();
+ h = 31 * h + getActions().hashCode();
+ if (endpoint != null) {
+ h = 31 * h + endpoint.hashCode();
+ }
+ return h;
+ }
+
+ /**
+ * WriteObject is called to save the state of this permission to a stream.
+ * The actions are serialized, and the superclass takes care of the name.
+ */
+ private synchronized void writeObject(java.io.ObjectOutputStream s)
+ throws IOException {
+ if (endpoint != null) {
+ throw new NotSerializableException("cannot serialize");
+ }
+ // Write out the actions. The superclass takes care of the name
+ // call getActions to make sure actions field is initialized
+ if (actions == null) {
+ getActions();
+ }
+ s.defaultWriteObject();
+ }
+
+ /**
+ * readObject is called to restore the state of this permission from a
+ * stream.
+ */
+ private synchronized void readObject(java.io.ObjectInputStream s)
+ throws IOException, ClassNotFoundException {
+ // Read in the action, then initialize the rest
+ s.defaultReadObject();
+ setTransients(parseFilter(getName()), parseActions(actions));
+ }
+
+ /**
+ * Called by <code><@link EndpointPermission#implies(Permission)></code>.
+ *
+ * @return a dictionary of properties for this permission.
+ */
+ private Dictionary<String, Object> getProperties() {
+ return properties;
+ }
+}
+
+/**
+ * Stores a set of EndpointPermission permissions.
+ *
+ * @see java.security.Permission
+ * @see java.security.Permissions
+ * @see java.security.PermissionCollection
+ */
+final class EndpointPermissionCollection extends PermissionCollection {
+ static final long serialVersionUID = 662615640374640621L;
+ /**
+ * Table of permissions.
+ *
+ * @serial
+ * @GuardedBy this
+ */
+ private Map<String, EndpointPermission> permissions;
+
+ /**
+ * Boolean saying if "*" is in the collection.
+ *
+ * @serial
+ * @GuardedBy this
+ */
+ private boolean all_allowed;
+
+ /**
+ * Creates an empty EndpointPermissions object.
+ */
+ public EndpointPermissionCollection() {
+ permissions = new HashMap<String, EndpointPermission>();
+ all_allowed = false;
+ }
+
+ /**
+ * Adds a permission to this permission collection.
+ *
+ * @param permission The Permission object to add.
+ * @throws IllegalArgumentException If the specified permission is not a
+ * EndpointPermission object.
+ * @throws SecurityException If this
+ * <code>EndpointPermissionCollection</code> object has been marked
+ * read-only.
+ */
+ public void add(final Permission permission) {
+ if (!(permission instanceof EndpointPermission)) {
+ throw new IllegalArgumentException("invalid permission: "
+ + permission);
+ }
+ if (isReadOnly()) {
+ throw new SecurityException("attempt to add a Permission to a "
+ + "readonly PermissionCollection");
+ }
+
+ final EndpointPermission ep = (EndpointPermission) permission;
+ if (ep.endpoint != null) {
+ throw new IllegalArgumentException("cannot add to collection: "
+ + ep);
+ }
+
+ final String name = ep.getName();
+ synchronized (this) {
+ /* select the bucket for the permission */
+ Map<String, EndpointPermission> pc = permissions;
+ final EndpointPermission existing = (EndpointPermission) pc
+ .get(name);
+
+ if (existing != null) {
+ final int oldMask = existing.action_mask;
+ final int newMask = ep.action_mask;
+ if (oldMask != newMask) {
+ pc.put(name,
+ new EndpointPermission(name, oldMask | newMask));
+ }
+ }
+ else {
+ pc.put(name, ep);
+ }
+
+ if (!all_allowed) {
+ if (name.equals("*")) {
+ all_allowed = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * Determines if a set of permissions implies the permissions expressed in
+ * <code>permission</code>.
+ *
+ * @param permission The Permission object to compare.
+ * @return <code>true</code> if <code>permission</code> is a proper subset
+ * of a permission in the set; <code>false</code> otherwise.
+ */
+ public boolean implies(final Permission permission) {
+ if (!(permission instanceof EndpointPermission)) {
+ return false;
+ }
+ final EndpointPermission requested = (EndpointPermission) permission;
+ /* if requested permission has a filter, then it is an invalid argument */
+ if (requested.filter != null) {
+ return false;
+ }
+ int effective = EndpointPermission.ACTION_NONE;
+ Collection<EndpointPermission> perms;
+ synchronized (this) {
+ final int desired = requested.action_mask;
+ /* short circuit if the "*" Permission was added */
+ if (all_allowed) {
+ EndpointPermission ep = permissions.get("*");
+ if (ep != null) {
+ effective |= ep.action_mask;
+ if ((effective & desired) == desired) {
+ return true;
+ }
+ }
+ }
+ perms = permissions.values();
+ }
+
+ /* iterate one by one over permissions */
+ for (Iterator<EndpointPermission> iter = perms.iterator(); iter
+ .hasNext();) {
+ if (iter.next().implies0(requested, effective)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns an enumeration of all the <code>EndpointPermission</code> objects
+ * in the container.
+ *
+ * @return Enumeration of all the EndpointPermission objects.
+ */
+ public synchronized Enumeration<Permission> elements() {
+ List<Permission> all = new ArrayList<Permission>(permissions.values());
+ return Collections.enumeration(all);
+ }
+
+ /* serialization logic */
+ private static final ObjectStreamField[] serialPersistentFields = {
+ new ObjectStreamField("permissions", HashMap.class),
+ new ObjectStreamField("all_allowed", Boolean.TYPE) };
+
+ private synchronized void writeObject(ObjectOutputStream out)
+ throws IOException {
+ ObjectOutputStream.PutField pfields = out.putFields();
+ pfields.put("permissions", permissions);
+ pfields.put("all_allowed", all_allowed);
+ out.writeFields();
+ }
+
+ private synchronized void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gfields = in.readFields();
+ permissions = (HashMap<String, EndpointPermission>) gfields.get(
+ "permissions", new HashMap<String, EndpointPermission>());
+ all_allowed = gfields.get("all_allowed", false);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ExportReference.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ExportReference.java
new file mode 100644
index 0000000000..03b3235c59
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ExportReference.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * An Export Reference associates a service with a local endpoint.
+ *
+ * The Export Reference can be used to reference an exported service. When the
+ * service is no longer exported, all methods must return <code>null</code>;
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+public interface ExportReference {
+ /**
+ * Return the service being exported.
+ *
+ * @return The service being exported, must be <code>null</code> when this
+ * registration is unregistered.
+ */
+ ServiceReference getExportedService();
+
+ /**
+ * Return the Endpoint Description that is created for this registration.
+ *
+ * @return the local Endpoint Description
+ */
+ EndpointDescription getExportedEndpoint();
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ExportRegistration.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ExportRegistration.java
new file mode 100644
index 0000000000..e8c6c66cbf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ExportRegistration.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * An Export Registration associates a service to a local endpoint.
+ *
+ * The Export Registration can be used to delete the endpoint associated with an
+ * this registration. It is created with the
+ * {@link RemoteServiceAdmin#exportService(ServiceReference,java.util.Map)}
+ * method.
+ *
+ * When this Export Registration has been unregistered, the methods must all
+ * return <code>null</code>.
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+public interface ExportRegistration {
+ /**
+ * Return the Export Reference for the exported service.
+ *
+ * @return An Export Reference for this registration
+ * @throws IllegalStateException Thrown when this object was not properly
+ * initialized, see {@link #getException()}
+ */
+ ExportReference getExportReference();
+
+ /**
+ * Delete the local endpoint and disconnect any remote distribution
+ * providers. After this method returns, all the methods must return
+ * <code>null</code>.
+ *
+ * This method has no effect when the endpoint is already destroyed or being
+ * destroyed.
+ */
+ void close();
+
+ /**
+ * Exception for any error during the import process.
+ *
+ * If the Remote Admin for some reasons is unable to create a registration,
+ * then it must return a <code>Throwable</code> from this method. In this
+ * case, all other methods must return on this interface must throw an
+ * Illegal State Exception. If no error occurred, this method must return
+ * <code>null</code>.
+ *
+ * The error must be set before this Import Registration is returned.
+ * Asynchronously occurring errors must be reported to the log.
+ *
+ * @return The exception that occurred during the creation of the
+ * registration or <code>null</code> if no exception occurred.
+ */
+ Throwable getException();
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ImportReference.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ImportReference.java
new file mode 100644
index 0000000000..5fa5673341
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ImportReference.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * An Import Reference associates an active proxy service to a remote endpoint.
+ *
+ * The Import Reference can be used to reference an imported service. When the
+ * service is no longer imported, all methods must return <code>null</code>;
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+public interface ImportReference {
+ /**
+ * Answer the associated Service Reference for the proxy to the endpoint.
+ *
+ * @return A Service Reference to the proxy for the endpoint.
+ */
+ ServiceReference getImportedService();
+
+ /**
+ * Answer the associated remote Endpoint Description.
+ *
+ * @return A Endpoint Description for the remote endpoint.
+ */
+ EndpointDescription getImportedEndpoint();
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ImportRegistration.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ImportRegistration.java
new file mode 100644
index 0000000000..1fc1c6f6ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/ImportRegistration.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+/**
+ * An Import Registration associates an active proxy service to a remote
+ * endpoint.
+ *
+ * The Import Registration can be used to delete the proxy associated with an
+ * endpoint. It is created with the{@link RemoteServiceAdmin#importService}
+ * method.
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+public interface ImportRegistration {
+ /**
+ * Answer the associated Export Reference.
+ *
+ * @return An Import Reference for this registration
+ * @throws IllegalStateException Thrown when this object was not properly
+ * initialized, see {@link #getException()}
+ */
+ ImportReference getImportReference();
+
+ /**
+ * Unregister this Import Registration. This must close the connection to
+ * the end endpoint unregister the proxy. After this method returns, all
+ * other methods must return null.
+ *
+ * This method has no effect when the service is already unregistered or in
+ * the process off.
+ */
+ void close();
+
+ /**
+ * Exception for any error during the import process.
+ *
+ * If the Remote Admin for some reasons is unable to create a registration,
+ * then it must return a <code>Throwable</code> from this method. In this
+ * case, all other methods must return on this interface must thrown an
+ * Illegal State Exception. If no error occurred, this method must return
+ * <code>null</code>.
+ *
+ * The error must be set before this Import Registration is returned.
+ * Asynchronously occurring errors must be reported to the log.
+ *
+ * @return The exception that occurred during the creation of the
+ * registration or <code>null</code> if no exception occurred.
+ */
+ Throwable getException();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteConstants.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteConstants.java
new file mode 100644
index 0000000000..cf2194ec12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteConstants.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) OSGi Alliance (2009, 2010). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+/**
+ * Provide the definition of the constants used in the Remote Services API.
+ *
+ * @Immutable
+ * @version $Revision$
+ */
+public class RemoteConstants {
+ private RemoteConstants() {
+ }
+
+ /**
+ * Service property identifying the configuration types supported by a
+ * distribution provider. Registered by the distribution provider on one of
+ * its services to indicate the supported configuration types.
+ * <p>
+ * The value of this property must be of type <code>String</code>,
+ * <code>String[]</code>, or <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
+
+ /**
+ * Service property identifying the intents supported by a distribution
+ * provider. Registered by the distribution provider on one of its services
+ * to indicate the vocabulary of implemented intents.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>,
+ * <code>String[]</code>, or <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
+
+ /**
+ * Service property identifying the configuration types that should be used
+ * to export the service. Each configuration type represents the
+ * configuration parameters for an endpoint. A distribution provider should
+ * create an endpoint for each configuration type that it supports.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
+
+ /**
+ * Service property identifying the intents that the distribution provider
+ * must implement to distribute the service. Intents listed in this property
+ * are reserved for intents that are critical for the code to function
+ * correctly, for example, ordering of messages. These intents should not be
+ * configurable.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
+
+ /**
+ * Service property identifying the extra intents that the distribution
+ * provider must implement to distribute the service. This property is
+ * merged with the <code>service.exported.intents</code> property before the
+ * distribution provider interprets the listed intents; it has therefore the
+ * same semantics but the property should be configurable so the
+ * administrator can choose the intents based on the topology. Bundles
+ * should therefore make this property configurable, for example through the
+ * Configuration Admin service.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
+
+ /**
+ * Service property marking the service for export. It defines the
+ * interfaces under which this service can be exported. This list must be a
+ * subset of the types under which the service was registered. The single
+ * value of an asterisk (&quot;*&quot;, &#92;u002A) indicates all the
+ * interface types under which the service was registered excluding the
+ * non-interface types. It is strongly recommended to only export interface
+ * types and not concrete classes due to the complexity of creating proxies
+ * for some type of concrete classes.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
+
+ /**
+ * Service property identifying the service as imported. This service
+ * property must be set by a distribution provider to any value when it
+ * registers the endpoint proxy as an imported service. A bundle can use
+ * this property to filter out imported services.
+ *
+ * <p>
+ * The value of this property may be of any type.
+ */
+ public static final String SERVICE_IMPORTED = "service.imported";
+
+ /**
+ * Service property identifying the configuration types used to import the
+ * service. Any associated properties for this configuration types must be
+ * properly mapped to the importing system. For example, a URL in these
+ * properties must point to a valid resource when used in the importing
+ * framework. If multiple configuration types are listed in this property,
+ * then they must be synonyms for exactly the same remote endpoint that is
+ * used to export this service.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>,
+ * <code>String[]</code>, or <code>Collection&lt;String&gt;</code>.
+ *
+ * @see #SERVICE_EXPORTED_CONFIGS
+ */
+ public static final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs";
+
+ /**
+ * Service property identifying the intents that this service implement.
+ * This property has a dual purpose:
+ * <ul>
+ * <li>A bundle can use this service property to notify the distribution
+ * provider that these intents are already implemented by the exported
+ * service object.</li>
+ * <li>A distribution provider must use this property to convey the combined
+ * intents of: The exporting service, and, the intents that the exporting
+ * distribution provider adds, and the intents that the importing
+ * distribution provider adds.</li>
+ * </ul>
+ * To export a service, a distribution provider must expand any qualified
+ * intents. Both the exporting and importing distribution providers must
+ * recognize all intents before a service can be distributed.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>,
+ * <code>String[]</code>, or <code>Collection&lt;String&gt;</code>.
+ */
+ public static final String SERVICE_INTENTS = "service.intents";
+
+ /* above are from Ch 13 Remote Service spec. */
+
+ /**
+ * Endpoint property identifying the id for this endpoint. This service
+ * property must always be set.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>.
+ */
+ public final static String ENDPOINT_ID = "endpoint.id";
+
+ /**
+ * Endpoint property identifying the service id of the exported service. Can
+ * be absent or 0 if the corresponding endpoint is not for an OSGi service.
+ *
+ * <p>
+ * The value of this property must be of type <code>Long</code>.
+ */
+ public final static String ENDPOINT_SERVICE_ID = "endpoint.service.id";
+
+ /**
+ * Endpoint property identifying the universally unique id of the exporting
+ * framework. Can be absent if the corresponding endpoint is not for an OSGi
+ * service.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>.
+ */
+ public final static String ENDPOINT_FRAMEWORK_UUID = "endpoint.framework.uuid";
+
+ /**
+ * Prefix for an endpoint property identifying the interface Java package
+ * version for an interface. For example, the property
+ * endpoint.package.version.com.acme=1.3 describes the version of the
+ * package for the com.acme.Foo interface. This endpoint property for an
+ * interface package does not have to be set. If not set, the value must be
+ * assumed to be 0.
+ *
+ * <p>
+ * Since endpoint properties are stored in a case insensitive map, case
+ * variants of a package name are folded together.
+ *
+ * <p>
+ * The value of this property must be of type <code>String</code>.
+ */
+ public final static String ENDPOINT_PACKAGE_VERSION_ = "endpoint.package.version.";
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdmin.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdmin.java
new file mode 100644
index 0000000000..98f56a07ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdmin.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A Remote Service Admin manages the import and export of services.
+ *
+ * A Distribution Provider can expose a control interface. This interface allows
+ * the a remote manager to control the export and import of services.
+ *
+ * The API allows a remote manager to export a service, to import a service, and
+ * find out about the current imports and exports.
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+public interface RemoteServiceAdmin {
+
+ /**
+ * Export a service to a given Endpoint. The Remote Service Admin must
+ * create an Endpoint from the given description that can be used by other
+ * Distrbution Providers to connect to this Remote Service Admin and use the
+ * exported service. This method can return null if the service could not be
+ * exported because the Endpoint could not be implemented by this Remote
+ * Service Admin.
+ *
+ * The properties on a Service Reference are case insensitive while the
+ * properties on a <code>properties</code> are case sensitive. A value in
+ * the <code>properties</code> must therefore override any case variant in
+ * the properties of the Service Reference.
+ *
+ * <p>
+ * If the caller does not have the appropriate
+ * <code>EndpointPermission[endpoint,EXPORT]</code> for an Endpoint, and the
+ * Java Runtime Environment supports permissions, then the
+ * {@link ExportRegistration#getException() getException} method on the
+ * corresponding returned {@link ExportRegistration} will return a
+ * <code>SecurityException</code>.
+ *
+ * @param reference The Service Reference to export.
+ * @param properties The properties to create a local Endpoint that can be
+ * implemented by this Remote Service Admin. If this is null, the
+ * Endpoint will be determined by the properties on the service. The
+ * properties are the same as given for an exported service. They are
+ * overlaid over any properties the service defines (case
+ * insensitive). This parameter can be <code>null</code>, this should
+ * be treated as an empty map.
+ *
+ * @return An Export Registration that combines the Endpoint Description and
+ * the Service Reference. Is never <code>null</code>.
+ * @throws IllegalArgumentException If any of the properties has a value
+ * that is not syntactically correct or if the service properties
+ * and the overlaid properties do not contain a
+ * {@link RemoteConstants#SERVICE_EXPORTED_INTERFACES} entry.
+ * @throws UnsupportedOperationException If any of the intents expressed
+ * through the properties is not supported by the distribution
+ * provider.
+ */
+ Collection<ExportRegistration> exportService(ServiceReference reference,
+ Map<String, Object> properties);
+
+ /**
+ * Import a service from an Endpoint. The Remote Service Admin must use the
+ * given Endpoint to create a proxy. This method can return null if the
+ * service could not be imported.
+ *
+ * @param endpoint The Endpoint Description to be used for import.
+ * @return An Import Registration that combines the Endpoint Description and
+ * the Service Reference or <code>null</code> if the Endpoint could
+ * not be imported.
+ * @throws SecurityException If the caller does not have the appropriate
+ * <code>EndpointPermission[endpoint,IMPORT]</code> for the
+ * Endpoint, and the Java Runtime Environment supports permissions.
+ */
+ ImportRegistration importService(EndpointDescription endpoint);
+
+ /**
+ * Return the currently active Export References.
+ *
+ * <p>
+ * If the caller does not have the appropriate
+ * <code>EndpointPermission[endpoint,READ]</code> for an Endpoint, and the
+ * Java Runtime Environment supports permissions, then returned collection
+ * will not contain a reference to the exported Endpoint.
+ *
+ * @return A <code>Collection</code> of {@link ExportReference}s that are
+ * currently active.
+ */
+ Collection<ExportReference> getExportedServices();
+
+ /**
+ * Return the currently active Import References.
+ *
+ * <p>
+ * If the caller does not have the appropriate
+ * <code>EndpointPermission[endpoint,READ]</code> for an Endpoint, and the
+ * Java Runtime Environment supports permissions, then returned collection
+ * will not contain a reference to the imported Endpoint.
+ *
+ * @return A <code>Collection</code> of {@link ImportReference}s that are
+ * currently active.
+ */
+ Collection<ImportReference> getImportedEndpoints();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminEvent.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminEvent.java
new file mode 100644
index 0000000000..8f4ac717c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminEvent.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * Provides the event information for a Remote Admin event.
+ *
+ * @Immutable
+ * @version $Revision$
+ */
+public class RemoteServiceAdminEvent {
+ /**
+ * Add an import registration. The Remote Services Admin will call this
+ * method when it imports a service. When this service is registered, the
+ * Remote Service Admin must notify the listener of all existing Import
+ * Registrations.
+ *
+ */
+ public static final int IMPORT_REGISTRATION = 1;
+
+ /**
+ * Add an export registration. The Remote Services Admin will call this
+ * method when it exports a service. When this service is registered, the
+ * Remote Service Admin must notify the listener of all existing Export
+ * Registrations.
+ */
+ public static final int EXPORT_REGISTRATION = 2;
+
+ /**
+ * Remove an export registration. The Remote Services Admin will call this
+ * method when it removes the export of a service.
+ *
+ */
+ public static final int EXPORT_UNREGISTRATION = 3;
+
+ /**
+ * Remove an import registration. The Remote Services Admin will call this
+ * method when it removes the import of a service.
+ *
+ */
+ public static final int IMPORT_UNREGISTRATION = 4;
+
+ /**
+ * A fatal importing error occurred. The Import Registration has been
+ * closed.
+ */
+ public static final int IMPORT_ERROR = 5;
+
+ /**
+ * A fatal exporting error occurred. The Export Registration has been
+ * closed.
+ */
+ public static final int EXPORT_ERROR = 6;
+
+ /**
+ * A problematic situation occurred, the export is still active.
+ */
+ public static final int EXPORT_WARNING = 7;
+ /**
+ * A problematic situation occurred, the import is still active.
+ */
+ public static final int IMPORT_WARNING = 8;
+
+ private final ImportReference importReference;
+ private final ExportReference exportReference;
+ private final Throwable exception;
+ private final int type;
+ private final Bundle source;
+
+ /**
+ * Private constructor.
+ *
+ * @param type The event type
+ * @param source The source bundle, must not be <code>null</code>.
+ * @param importReference The importReference, can be <code>null</code>.
+ * @param exportReference The exportReference, can be <code>null</code>.
+ * @param exception Any exceptions encountered, can be <code>null</code>
+ */
+ private RemoteServiceAdminEvent(int type, Bundle source,
+ ImportReference importReference, ExportReference exportReference,
+ Throwable exception) {
+ if (source == null) {
+ throw new NullPointerException("source must not be null");
+ }
+ this.type = type;
+ this.source = source;
+ this.importReference = importReference;
+ this.exportReference = exportReference;
+ this.exception = exception;
+ }
+
+ /**
+ * Create a Remote Service Admin Event for an export notification.
+ *
+ * @param type The event type.
+ * @param source The source bundle, must not be <code>null</code>.
+ * @param exportReference The exportReference, can not be <code>null</code>.
+ * @param exception Any exceptions encountered, can be <code>null</code>.
+ */
+ public RemoteServiceAdminEvent(int type, Bundle source,
+ ExportReference exportReference, Throwable exception) {
+ this(type, source, null, exportReference, exception);
+ }
+
+ /**
+ * Create a Remote Service Admin Event for an import notification.
+ *
+ * @param type The event type.
+ * @param source The source bundle, must not be <code>null</code>.
+ * @param importReference The importReference, can not be <code>null</code>.
+ * @param exception Any exceptions encountered, can be <code>null</code>.
+ */
+ public RemoteServiceAdminEvent(int type, Bundle source,
+ ImportReference importReference, Throwable exception) {
+ this(type, source, importReference, null, exception);
+ }
+
+ /**
+ * Return the Import Reference for this event.
+ *
+ * @return The Import Reference or <code>null</code>.
+ */
+ public ImportReference getImportReference() {
+ return importReference;
+ }
+
+ /**
+ * Return the Export Reference for this event.
+ *
+ * @return The Export Reference or <code>null</code>.
+ */
+ public ExportReference getExportReference() {
+ return exportReference;
+ }
+
+ /**
+ * Return the exception for this event.
+ *
+ * @return The exception or <code>null</code>.
+ */
+ public Throwable getException() {
+ return exception;
+ }
+
+ /**
+ * Return the type of this event.
+ *
+ * @return The type of this event.
+ */
+ public int getType() {
+ return type;
+ }
+
+ /**
+ * Return the bundle source of this event.
+ *
+ * @return The bundle source of this event.
+ */
+ public Bundle getSource() {
+ return source;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminListener.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminListener.java
new file mode 100644
index 0000000000..2941f8b117
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminListener.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ *
+ * 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.osgi.service.remoteserviceadmin;
+
+/**
+ * A {@link RemoteServiceAdminEvent} listener is notified synchronously of any
+ * export or import registrations and unregistrations.
+ *
+ * <p>
+ * If the Java Runtime Environment supports permissions, then filtering is done.
+ * <code>RemoteServiceAdminEvent</code> objects are only delivered to the
+ * listener if the bundle which defines the listener object's class has the
+ * appropriate <code>EndpointPermission[endpoint,READ]</code> for the endpoint
+ * referenced by the event.
+ *
+ *
+ * @see RemoteServiceAdminEvent
+ * @ThreadSafe
+ * @version $Revision$
+ */
+
+public interface RemoteServiceAdminListener {
+ /**
+ * Receive notification of any export or import registrations and
+ * unregistrations as well as errors and warnings.
+ *
+ * @param event The {@link RemoteServiceAdminEvent} object.
+ */
+ void remoteAdminEvent(RemoteServiceAdminEvent event);
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..1991eba409
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -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/osgi/service/remoteserviceadmin/osgi-remoteserviceadmin.xsd
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory
new file mode 100644
index 0000000000..e44fce66a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.node.osgi.impl.OSGiNodeFactoryImpl;ranking=100
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/org/osgi/service/remoteserviceadmin/osgi-remoteserviceadmin.xsd b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/org/osgi/service/remoteserviceadmin/osgi-remoteserviceadmin.xsd
new file mode 100644
index 0000000000..dc88df965c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/main/resources/org/osgi/service/remoteserviceadmin/osgi-remoteserviceadmin.xsd
@@ -0,0 +1,92 @@
+<!--
+ *
+ * Copyright (c) OSGi Alliance (2008, 2010). All Rights Reserved.
+ *
+ * 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:rsa="http://www.osgi.org/xmlns/rsa/v1.0.0"
+ targetNamespace="http://www.osgi.org/xmlns/rsa/v1.0.0" elementFormDefault="qualified" version="1.0.0">
+ <element name="endpoint-descriptions" type="rsa:Tendpoint-descriptions" />
+ <complexType name="Tendpoint-descriptions">
+ <sequence>
+ <element name="endpoint-description" type="rsa:Tendpoint-description" minOccurs="1" maxOccurs="unbounded" />
+ <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+ </sequence>
+ <anyAttribute />
+ </complexType>
+ <complexType name="Tendpoint-description">
+ <sequence>
+ <element name="property" type="rsa:Tproperty" minOccurs="1" maxOccurs="unbounded" />
+ <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+ </sequence>
+ <anyAttribute />
+ </complexType>
+ <complexType name="Tproperty" mixed="true">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="1">
+ <element name="array" type="rsa:Tmulti-value" />
+ <element name="list" type="rsa:Tmulti-value" />
+ <element name="set" type="rsa:Tmulti-value" />
+ <element name="xml" type="rsa:Txml" />
+ </choice>
+ <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+ </sequence>
+ <attribute name="name" type="string" use="required" />
+ <attribute name="value" type="string" use="optional" />
+ <attribute name="value-type" type="rsa:Tvalue-types" default="String" use="optional" />
+ <anyAttribute />
+ </complexType>
+ <complexType name="Tmulti-value">
+ <sequence>
+ <element name="value" minOccurs="0" maxOccurs="unbounded" type="rsa:Tvalue" />
+ <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+ </sequence>
+ <anyAttribute />
+ </complexType>
+ <complexType name="Tvalue" mixed="true">
+ <sequence>
+ <element name="xml" minOccurs="0" maxOccurs="1" type="rsa:Txml" />
+ <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+ </sequence>
+ <anyAttribute />
+ </complexType>
+ <simpleType name="Tvalue-types">
+ <restriction base="string">
+ <enumeration value="String" />
+ <enumeration value="long" />
+ <enumeration value="Long" />
+ <enumeration value="double" />
+ <enumeration value="Double" />
+ <enumeration value="float" />
+ <enumeration value="Float" />
+ <enumeration value="int" />
+ <enumeration value="Integer" />
+ <enumeration value="byte" />
+ <enumeration value="Byte" />
+ <enumeration value="char" />
+ <enumeration value="Character" />
+ <enumeration value="boolean" />
+ <enumeration value="Boolean" />
+ <enumeration value="short" />
+ <enumeration value="Short" />
+ </restriction>
+ </simpleType>
+ <complexType name="Txml">
+ <sequence>
+ <any namespace="##other" minOccurs="1" maxOccurs="1" processContents="lax" />
+ </sequence>
+ <anyAttribute />
+ </complexType>
+ <attribute name="must-understand" type="boolean" default="false" />
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorService.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorService.java
new file mode 100644
index 0000000000..cc562b7c2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorService.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 calculator.dosgi;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorActivator.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorActivator.java
new file mode 100644
index 0000000000..cf1b78931a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorActivator.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 calculator.dosgi.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+
+/**
+ *
+ */
+public class CalculatorActivator implements BundleActivator {
+ private Logger logger = Logger.getLogger(CalculatorActivator.class.getName());
+
+ private Bundle getBundle(BundleContext bundleContext, Class<?> cls) {
+ PackageAdmin packageAdmin = null;
+ // PackageAdmin is used to resolve bundles
+ ServiceReference ref = bundleContext.getServiceReference("org.osgi.service.packageadmin.PackageAdmin");
+ if (ref != null) {
+ packageAdmin = (PackageAdmin)bundleContext.getService(ref);
+ Bundle bundle = packageAdmin.getBundle(cls);
+ if (bundle != null) {
+ logger.info(cls.getName() + " is loaded by bundle: " + bundle.getSymbolicName());
+ }
+ bundleContext.ungetService(ref);
+ return bundle;
+ }
+ return null;
+ }
+
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting " + context.getBundle());
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put("sca.service", "CalculatorComponent#service-name(Calculator)");
+ props.put("calculator", "Calculator");
+ logger.info("Registering " + CalculatorService.class.getName());
+ CalculatorService calculator = new CalculatorServiceImpl(context);
+ context.registerService(CalculatorService.class.getName(), calculator, props);
+
+ getBundle(context, AddService.class);
+
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping " + context.getBundle());
+ // Registered services will be automatically unregistered
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
new file mode 100644
index 0000000000..5f9db16ca9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.impl;
+
+import org.osgi.service.component.ComponentContext;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceDSImpl implements CalculatorService {
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ public CalculatorServiceDSImpl() {
+ super();
+ System.out.println("CalculatorServiceDSImpl()");
+ }
+
+ protected void activate(ComponentContext context) {
+ System.out.println("Activating " + context);
+ }
+
+ protected void deactivate(ComponentContext context) {
+ System.out.println("Deactivating " + context);
+ }
+
+ /*
+ * The following setters can be used for DS injection
+ */
+ public void setAddService(AddService addService) {
+ System.out.println("setAddService()");
+ this.addService = addService;
+ }
+
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ /*
+ * The following setters can be used for DS injection
+ */
+ public void unsetAddService(AddService addService) {
+ System.out.println("unsetAddService()");
+ this.addService = null;
+ }
+
+ public void unsetSubtractService(SubtractService subtractService) {
+ this.subtractService = null;
+ }
+
+ public void unsetDivideService(DivideService divideService) {
+ this.divideService = null;
+ }
+
+ public void unsetMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = null;
+ }
+ private <T> T getService(Class<T> cls) {
+ for (Object s : new Object[] {addService, subtractService, multiplyService, divideService}) {
+ if (cls.isInstance(s)) {
+ return cls.cast(s);
+ }
+ }
+ throw new IllegalStateException(cls.getSimpleName() + " is not available");
+ }
+
+ public double add(double n1, double n2) {
+ return getService(AddService.class).add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return getService(SubtractService.class).subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return getService(MultiplyService.class).multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return getService(DivideService.class).divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..0960938086
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceImpl.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.impl;
+
+import static org.osgi.framework.Constants.OBJECTCLASS;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.util.tracker.ServiceTracker;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+ private ServiceTracker remoteServices;
+ private ServiceTracker localServices;
+
+ public CalculatorServiceImpl() {
+ super();
+ }
+
+ public CalculatorServiceImpl(BundleContext context) {
+ super();
+ Filter remoteFilter = null, localFilter = null;
+ try {
+ remoteFilter =
+ context.createFilter("(&(" + OBJECTCLASS + "=calculator.dosgi.operations.*) (sca.reference=*))");
+ localFilter =
+ context.createFilter("(&(" + OBJECTCLASS + "=calculator.dosgi.operations.*) (!(sca.reference=*)))");
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ this.remoteServices = new ServiceTracker(context, remoteFilter, null);
+ remoteServices.open();
+ this.localServices = new ServiceTracker(context, localFilter, null);
+ localServices.open();
+ }
+
+ private <T> T getService(Class<T> cls) {
+ Object[] remoteObjects = remoteServices.getServices();
+ if (remoteObjects != null) {
+ for (Object s : remoteObjects) {
+ if (cls.isInstance(s)) {
+ System.out.println("Remote service: " + s);
+ return cls.cast(s);
+ }
+ }
+ }
+ for (Object s : localServices.getServices()) {
+ if (cls.isInstance(s)) {
+ System.out.println("Local service: " + s);
+ return cls.cast(s);
+ }
+ }
+ throw new IllegalStateException(cls.getSimpleName() + " is not available");
+ }
+
+ public double add(double n1, double n2) {
+ return getService(AddService.class).add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return getService(SubtractService.class).subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return getService(MultiplyService.class).multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return getService(DivideService.class).divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/AddService.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/AddService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the add service
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/DivideService.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/DivideService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the divide service
+ */
+@Remotable
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the multiply service
+ */
+@Remotable
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/SubtractService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the subtract service
+ */
+@Remotable
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/AddServiceImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/AddServiceImpl.java
new file mode 100644
index 0000000000..66b2977241
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/AddServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.AddService;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/DivideServiceImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/DivideServiceImpl.java
new file mode 100644
index 0000000000..a3c21b2b96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/DivideServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.DivideService;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..7922d2d392
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.MultiplyService;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/OperationsActivator.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/OperationsActivator.java
new file mode 100644
index 0000000000..5348d19f34
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/OperationsActivator.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 calculator.dosgi.operations.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ *
+ */
+public class OperationsActivator implements BundleActivator {
+ private Logger logger = Logger.getLogger(OperationsActivator.class.getName());
+
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting " + context.getBundle());
+
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+
+ logger.info("Registering " + AddService.class.getName());
+ props.put("sca.service", "AddComponent#service-name(Add)");
+ context.registerService(AddService.class.getName(), new AddServiceImpl(), props);
+
+ logger.info("Registering " + SubtractService.class.getName());
+ props.put("sca.service", "SubtractComponent#service-name(Subtract)");
+ context.registerService(SubtractService.class.getName(), new SubtractServiceImpl(), props);
+
+ logger.info("Registering " + MultiplyService.class.getName());
+ props.put("sca.service", "MultiplyComponent#service-name(Multiply)");
+ context.registerService(MultiplyService.class.getName(), new MultiplyServiceImpl(), props);
+
+ logger.info("Registering " + DivideService.class.getName());
+ props.put("sca.service", "DivideComponent#service-name(Divide)");
+ context.registerService(DivideService.class.getName(), new DivideServiceImpl(), props);
+
+ getBundle(context, AddService.class);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping " + context.getBundle());
+ // Registered services will be automatically unregistered
+ }
+
+ private Bundle getBundle(BundleContext bundleContext, Class<?> cls) {
+ PackageAdmin packageAdmin = null;
+ // PackageAdmin is used to resolve bundles
+ ServiceReference ref = bundleContext.getServiceReference("org.osgi.service.packageadmin.PackageAdmin");
+ if (ref != null) {
+ packageAdmin = (PackageAdmin)bundleContext.getService(ref);
+ Bundle bundle = packageAdmin.getBundle(cls);
+ if (bundle != null) {
+ logger.info(cls.getName() + " is loaded by bundle: " + bundle.getSymbolicName());
+ }
+ bundleContext.ungetService(ref);
+ return bundle;
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java
new file mode 100644
index 0000000000..4bbe83b14f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/SubtractServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
new file mode 100644
index 0000000000..268f16bc9f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.test;
+
+import static calculator.dosgi.test.OSGiTestBundles.bundleStatus;
+import static calculator.dosgi.test.OSGiTestBundles.generateCalculatorBundle;
+import static calculator.dosgi.test.OSGiTestBundles.generateCalculatorSCABundle;
+import static calculator.dosgi.test.OSGiTestBundles.generateOperationsBundle;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+import calculator.dosgi.CalculatorService;
+
+/**
+ *
+ */
+public class CalculatorOSGiNodeTestCase {
+ private static EquinoxHost host;
+ private static BundleContext context;
+ private static Bundle calculatorBundle;
+ private static Bundle operationsBundle;
+ private static Bundle scaBundle;
+ private static Boolean client;
+
+ public static URL getCodeLocation(final Class<?> anchorClass) {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return anchorClass.getProtectionDomain().getCodeSource().getLocation();
+ }
+ });
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ try {
+ host = new EquinoxHost();
+ context = host.start();
+ String prop = System.getProperty("client");
+ if (prop != null) {
+ client = Boolean.valueOf(prop);
+ }
+
+ if (client == null || client.booleanValue()) {
+ System.out.println("Generating calculator.dosgi bundle...");
+ calculatorBundle = context.installBundle("reference:" + generateCalculatorBundle().toString());
+ }
+
+ if (client == null || !client.booleanValue()) {
+ System.out.println("Generating calculator.dosgi.operations bundle...");
+ operationsBundle = context.installBundle("reference:" + generateOperationsBundle().toString());
+ }
+
+ scaBundle = context.installBundle("reference:" + generateCalculatorSCABundle().toString());
+
+ for (Bundle b : context.getBundles()) {
+ if (b.getSymbolicName().equals("org.eclipse.equinox.ds") || b.getSymbolicName()
+ .startsWith("org.apache.tuscany.sca.")) {
+ try {
+ if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) {
+ b.start();
+ }
+ } catch (Exception e) {
+ System.out.println(bundleStatus(b, false));
+ e.printStackTrace();
+ }
+ System.out.println(bundleStatus(b, false));
+ }
+ }
+
+ if (scaBundle != null) {
+ scaBundle.start();
+ }
+
+ if (calculatorBundle != null) {
+ calculatorBundle.start();
+ System.out.println(bundleStatus(calculatorBundle, false));
+ }
+
+ if (operationsBundle != null) {
+ operationsBundle.start();
+ System.out.println(bundleStatus(operationsBundle, false));
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
+ public void testOSGi() {
+ if (client == null || client.booleanValue()) {
+ ServiceReference ref =
+ calculatorBundle.getBundleContext().getServiceReference(CalculatorService.class.getName());
+ Assert.assertNotNull(ref);
+ Object service = context.getService(ref);
+ Assert.assertNotNull(service);
+ CalculatorService calculator = OSGiTestBundles.cast(service, CalculatorService.class);
+ System.out.println("2.0 + 1.0 = " + calculator.add(2.0, 1.0));
+ System.out.println("2.0 - 1.0 = " + calculator.subtract(2.0, 1.0));
+ System.out.println("2.0 * 1.0 = " + calculator.multiply(2.0, 1.0));
+ System.out.println("2.0 / 1.0 = " + calculator.divide(2.0, 1.0));
+ }
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (host != null) {
+ if (scaBundle != null) {
+ scaBundle.stop();
+ }
+ if (client != null && !client.booleanValue()) {
+ System.out.println("Press Enter to stop the node...");
+ System.in.read();
+ }
+ host.stop();
+ context = null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java
new file mode 100644
index 0000000000..2af5552279
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.test;
+
+import static calculator.dosgi.test.OSGiTestBundles.bundleStatus;
+import static calculator.dosgi.test.OSGiTestBundles.generateCalculatorBundle;
+import static calculator.dosgi.test.OSGiTestBundles.generateOperationsBundle;
+
+import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import calculator.dosgi.CalculatorService;
+
+/**
+ *
+ */
+public class CalculatorOSGiTestCase {
+ private static EquinoxHost host;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ try {
+ host = new EquinoxHost();
+ BundleContext context = host.start();
+ Bundle calculatorBundle = context.installBundle("reference:" + generateCalculatorBundle().toString());
+ Bundle operationsBundle = context.installBundle("reference:" + generateOperationsBundle().toString());
+
+ for (Bundle b : context.getBundles()) {
+ if (b.getSymbolicName().equals("org.eclipse.equinox.ds")) {
+ System.out.println(bundleStatus(b, false));
+ b.start();
+ System.out.println(bundleStatus(b, false));
+ }
+ }
+
+ calculatorBundle.start();
+ System.out.println(bundleStatus(calculatorBundle, false));
+ operationsBundle.start();
+ System.out.println(bundleStatus(operationsBundle, false));
+
+ // Sleep for 1 sec so that the DS is available
+ Thread.sleep(1000);
+ // Use the DS version
+ String filter = "(component.name=CalculatorComponent)";
+ System.out.println(filter);
+ ServiceReference ref =
+ calculatorBundle.getBundleContext().getServiceReferences(CalculatorService.class.getName(), filter)[0];
+ CalculatorService calculator = OSGiTestBundles.cast(context.getService(ref), CalculatorService.class);
+ System.out.println("2.0 + 1.0 = " + calculator.add(2.0, 1.0));
+ System.out.println("2.0 - 1.0 = " + calculator.subtract(2.0, 1.0));
+ System.out.println("2.0 * 1.0 = " + calculator.multiply(2.0, 1.0));
+ System.out.println("2.0 / 1.0 = " + calculator.divide(2.0, 1.0));
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
+ public void testOSGi() {
+
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (host != null) {
+ host.stop();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
new file mode 100644
index 0000000000..bdb484e6bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
@@ -0,0 +1,362 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.Constants;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.impl.CalculatorActivator;
+import calculator.dosgi.impl.CalculatorServiceDSImpl;
+import calculator.dosgi.impl.CalculatorServiceImpl;
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+import calculator.dosgi.operations.impl.AddServiceImpl;
+import calculator.dosgi.operations.impl.DivideServiceImpl;
+import calculator.dosgi.operations.impl.MultiplyServiceImpl;
+import calculator.dosgi.operations.impl.OperationsActivator;
+import calculator.dosgi.operations.impl.SubtractServiceImpl;
+
+/**
+ *
+ * Utility class to create OSGi bundles
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiTestBundles {
+ private static class InvocationHandlerImpl implements InvocationHandler {
+ private Object instance;
+
+ public InvocationHandlerImpl(Object instance) {
+ super();
+ this.instance = instance;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ Method m = instance.getClass().getMethod(method.getName(), method.getParameterTypes());
+ return m.invoke(instance, args);
+ }
+
+ }
+
+ private static String getPackageName(Class<?> cls) {
+ String name = cls.getName();
+ int index = name.lastIndexOf('.');
+ return index == -1 ? "" : name.substring(0, index);
+ }
+
+ public static URL createBundle(String jarName, String mfFile, String[][] resources, Class<?>... classes)
+ throws IOException {
+ InputStream is = OSGiTestBundles.class.getClassLoader().getResourceAsStream(mfFile);
+ Manifest manifest = new Manifest(is);
+ is.close();
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ JarOutputStream jarOut = new JarOutputStream(out, manifest);
+
+ for (Class<?> cls : classes) {
+ addClass(jarOut, cls);
+ }
+
+ if (resources != null) {
+ for (String resource[] : resources) {
+ if (resource.length >= 1) {
+ String r1 = resource[0];
+ String r2 = resource.length > 1 ? resource[1] : r1;
+ addResource(jarOut, OSGiTestBundles.class.getClassLoader(), r1, r2);
+ }
+ }
+ }
+
+ jarOut.close();
+ out.close();
+
+ File jar = new File(jarName);
+ FileOutputStream fileOut = new FileOutputStream(jar);
+ fileOut.write(out.toByteArray());
+ fileOut.close();
+
+ return jar.toURI().toURL();
+ }
+
+ public static URL createBundle(String jarName,
+ String bundleName,
+ String exports,
+ String imports,
+ String[] resources,
+ Class<?>... classes) throws IOException {
+
+ Class<?> activator = null;
+ Set<String> packages = new HashSet<String>();
+ StringBuffer exportPackages = new StringBuffer();
+ if (exports != null) {
+ exportPackages.append(exports);
+ }
+ for (Class<?> cls : classes) {
+ if (BundleActivator.class.isAssignableFrom(cls)) {
+ activator = cls;
+ }
+ if (exports == null && cls.isInterface()) {
+ String pkg = getPackageName(cls);
+ if (packages.add(pkg)) {
+ exportPackages.append(pkg).append(",");
+ }
+ }
+ }
+ int len = exportPackages.length();
+ if (len > 0 && exportPackages.charAt(len - 1) == ',') {
+ exportPackages.deleteCharAt(len - 1);
+ }
+
+ Manifest manifest = new Manifest();
+ // This attribute Manifest-Version is required so that the MF will be added to the jar
+ manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
+ manifest.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, bundleName);
+ manifest.getMainAttributes().putValue(Constants.BUNDLE_VERSION, "1.0.0");
+ manifest.getMainAttributes().putValue(Constants.BUNDLE_NAME, bundleName);
+ manifest.getMainAttributes().putValue(Constants.EXPORT_PACKAGE, exportPackages.toString());
+ StringBuffer importPackages = new StringBuffer();
+ if (imports != null) {
+ importPackages.append(imports).append(",org.osgi.framework");
+ } else {
+ importPackages.append("org.osgi.framework");
+ }
+ manifest.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, importPackages.toString());
+
+ if (activator != null) {
+ manifest.getMainAttributes().putValue(Constants.BUNDLE_ACTIVATOR, activator.getName());
+ }
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ JarOutputStream jarOut = new JarOutputStream(out, manifest);
+
+ for (Class<?> cls : classes) {
+ addClass(jarOut, cls);
+ }
+
+ if (resources != null) {
+ for (String resource : resources) {
+ addResource(jarOut, OSGiTestBundles.class.getClassLoader(), resource, null);
+ }
+ }
+
+ jarOut.close();
+ out.close();
+
+ File jar = new File(jarName);
+ FileOutputStream fileOut = new FileOutputStream(jar);
+ fileOut.write(out.toByteArray());
+ fileOut.close();
+
+ return jar.toURI().toURL();
+ }
+
+ private static void addClass(JarOutputStream jarOut, Class<?> javaClass) throws IOException, FileNotFoundException {
+ String classFile = javaClass.getName().replace('.', '/') + ".class";
+ URL url = javaClass.getResource(javaClass.getSimpleName() + ".class");
+ addEntry(jarOut, url, classFile);
+ }
+
+ private static void addResource(JarOutputStream jarOut, ClassLoader cl, String resourceName, String entryName)
+ throws IOException, FileNotFoundException {
+ URL url = cl.getResource(resourceName);
+ if (entryName == null) {
+ entryName = resourceName;
+ }
+ addEntry(jarOut, url, entryName);
+ }
+
+ private static void addEntry(JarOutputStream jarOut, URL url, String resourceName) throws IOException,
+ FileNotFoundException {
+ String path = url.getPath();
+
+ ZipEntry ze = new ZipEntry(resourceName);
+
+ jarOut.putNextEntry(ze);
+ FileInputStream file = new FileInputStream(path);
+ byte[] fileContents = new byte[file.available()];
+ file.read(fileContents);
+ jarOut.write(fileContents);
+ jarOut.closeEntry();
+ file.close();
+ }
+
+ static URL generateCalculatorBundle() throws IOException {
+ return createBundle("target/test-classes/calculator-bundle.jar",
+ "calculator/dosgi/META-INF/MANIFEST.MF",
+ new String[][] {
+ {
+ "calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml",
+ "OSGI-INF/remote-service/calculator-service-descriptions.xml"},
+ {"calculator/dosgi/OSGI-INF/calculator-component.xml",
+ "OSGI-INF/calculator-component.xml"},
+ /*
+ {"calculator/dosgi/bundle.componentType",
+ "OSGI-INF/sca/bundle.componentType"},
+ {"calculator/dosgi/calculator.composite", "OSGI-INF/sca/bundle.composite"},
+ {"calculator/dosgi/META-INF/sca-contribution.xml",
+ "META-INF/sca-contribution.xml"}
+ */
+ },
+ CalculatorService.class,
+ // Package the interfaces so that the operations bundle can be remote
+ AddService.class,
+ SubtractService.class,
+ MultiplyService.class,
+ DivideService.class,
+ CalculatorServiceImpl.class,
+ CalculatorServiceDSImpl.class,
+ CalculatorActivator.class);
+ }
+
+ /**
+ * Create the OSGi bundle for calculator SCA
+ * @return
+ * @throws IOException
+ */
+ static URL generateCalculatorSCABundle() throws IOException {
+ return createBundle("target/test-classes/calculator-sca-bundle.jar",
+ "calculator/dosgi/sca/META-INF/MANIFEST.MF",
+ new String[][] {
+ {"calculator/dosgi/sca/OSGI-INF/sca/calculator.composite",
+ "OSGI-INF/sca/bundle.composite"},
+ {"calculator/dosgi/sca/META-INF/sca-contribution.xml",
+ "META-INF/sca-contribution.xml"},
+ {"calculator/dosgi/bundle.componentType",
+ "OSGI-INF/sca/calculator.dosgi/bundle.componentType"},
+ {"calculator/dosgi/operations/bundle.componentType",
+ "OSGI-INF/sca/calculator.dosgi.operations/bundle.componentType"},
+ });
+ }
+
+ /**
+ * Create the OSGi bundle for calculator operations
+ * @return
+ * @throws IOException
+ */
+ static URL generateOperationsBundle() throws IOException {
+ return createBundle("target/test-classes/operations-bundle.jar",
+ "calculator/dosgi/operations/META-INF/MANIFEST.MF",
+ new String[][] {
+ {"calculator/dosgi/operations/OSGI-INF/add-component.xml",
+ "OSGI-INF/add-component.xml"},
+ {"calculator/dosgi/operations/OSGI-INF/subtract-component.xml",
+ "OSGI-INF/subtract-component.xml"},
+ {"calculator/dosgi/operations/OSGI-INF/multiply-component.xml",
+ "OSGI-INF/multiply-component.xml"},
+ {"calculator/dosgi/operations/OSGI-INF/divide-component.xml",
+ "OSGI-INF/divide-component.xml"},
+ /*
+ {"calculator/dosgi/operations/bundle.componentType",
+ "OSGI-INF/sca/bundle.componentType"},
+ {"calculator/dosgi/operations/operations.composite",
+ "OSGI-INF/sca/bundle.composite"},
+ {"calculator/dosgi/operations/META-INF/sca-contribution.xml",
+ "META-INF/sca-contribution.xml"}
+ */
+ },
+ OperationsActivator.class,
+ AddService.class,
+ AddServiceImpl.class,
+ SubtractService.class,
+ SubtractServiceImpl.class,
+ MultiplyService.class,
+ MultiplyServiceImpl.class,
+ DivideService.class,
+ DivideServiceImpl.class);
+ }
+
+ /**
+ * Returns a string representation of the given bundle.
+ *
+ * @param b
+ * @param verbose
+ * @return
+ */
+ public static String bundleStatus(Bundle bundle, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(bundle.getBundleId()).append(" ").append(bundle.getSymbolicName());
+ int s = bundle.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ if (verbose) {
+ sb.append(" ").append(bundle.getLocation());
+ sb.append(" ").append(bundle.getHeaders());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * A utility to cast the object to the given interface. If the class for the object
+ * is loaded by a different classloader, a proxy will be created.
+ *
+ * @param <T>
+ * @param obj
+ * @param cls
+ * @return
+ */
+ public static <T> T cast(Object obj, Class<T> cls) {
+ if (cls.isInstance(obj)) {
+ return cls.cast(obj);
+ } else {
+ return cls.cast(Proxy.newProxyInstance(cls.getClassLoader(),
+ new Class<?>[] {cls},
+ new InvocationHandlerImpl(obj)));
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..4b7b7ec71b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Export-Package: calculator.dosgi;version="1.0.0",
+ calculator.dosgi.operations;version="1.0.0"
+Bundle-Version: 1.0.0
+Bundle-Name: calculator.dosgi
+Bundle-Activator: calculator.dosgi.impl.CalculatorActivator
+Bundle-ManifestVersion: 2
+Import-Package: org.oasisopen.sca.annotation;version="2.0.0",
+ org.osgi.framework,
+ org.osgi.service.component;resolution:=optional,
+ org.osgi.service.packageadmin,
+ org.osgi.util.tracker
+Bundle-SymbolicName: calculator.dosgi
+Bundle-Vendor: The Apache Software Foundation
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Service-Component: OSGI-INF/calculator-component.xml
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b48c048000
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:CalculatorComposite" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/blueprint/calculator-module.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/blueprint/calculator-module.xml
new file mode 100644
index 0000000000..fd834e12ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/blueprint/calculator-module.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.
+-->
+<!-- A sample module-context.xml for OSGI RFC 124 (BluePrint Service) -->
+<components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <component id="CalculatorComponent" class="calculator.dosgi.impl.CalculatorServiceImpl">
+ <property name="addService" ref="AddService" />
+ <property name="subtractService" ref="SubtractService" />
+ <property name="multiplyService" ref="MultiplyService" />
+ <property name="divideService" ref="DivideService" />
+ </component>
+
+ <!-- We can derive the SCA services for the implementation.osgi -->
+ <service id="CalculatorService" ref="CalculatorComponent" interface="calculator.dosgi.CalculatorService">
+ </service>
+
+ <!-- We can derive the SCA references for the implementation.osgi -->
+ <reference id="AddService" interface="calculator.dosgi.operations.AddService">
+ </reference>
+ <reference id="SubtractService" interface="calculator.dosgi.operations.SubtractService">
+ </reference>
+ <reference id="MultiplyService" interface="calculator.dosgi.operations.MultiplyService">
+ </reference>
+ <reference id="DivideService" interface="calculator.dosgi.operations.DivideService">
+ </reference>
+
+</components> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/calculator-component.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/calculator-component.xml
new file mode 100644
index 0000000000..5daaa59aae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/calculator-component.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<scr:component name="CalculatorComponent"
+ xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.impl.CalculatorServiceDSImpl" />
+ <service>
+ <provide interface="calculator.dosgi.CalculatorService" />
+ </service>
+
+ <reference name="addService" interface="calculator.dosgi.operations.AddService" bind="setAddService" unbind="unsetAddService"
+ policy="dynamic" />
+ <reference name="subtractService" interface="calculator.dosgi.operations.SubtractService" bind="setSubtractService"
+ unbind="unsetSubtractService" policy="dynamic" />
+ <reference name="multiplyService" interface="calculator.dosgi.operations.MultiplyService" bind="setMultiplyService"
+ unbind="unsetMultiplyService" policy="dynamic" />
+ <reference name="divideService" interface="calculator.dosgi.operations.DivideService" bind="setDivideService"
+ unbind="unsetDivideService" policy="dynamic" />
+
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml
new file mode 100644
index 0000000000..8306fa9834
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml
@@ -0,0 +1,55 @@
+<?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.
+-->
+<!-- A consumer-side service description file for OSGi Remote Service Admin -->
+<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+ <!-- Describe a remote OSGi service -->
+ <endpoint-description>
+ <property name="objectClass" value="calculator.dosgi.operations.AddService" />
+ <property name="service.intents" value="sca:SOAP sca:HTTP" />
+ <property name="service.imported.configs" value="org.osgi.sca"/>
+ <property name="osgi.remote.configuration.type" value="org.osgi.sca" />
+ <property name="osgi.remote.configuration.sca.componentType" value="OSGI-INF/sca/bundle.componentType" />
+ <property name="osgi.remote.configuration.sca.reference" value="addService" />
+ </endpoint-description>
+ <endpoint-description>
+ <property name="objectClass" value="calculator.dosgi.operations.SubtractService" />
+ <property name="service.imported.configs" value="org.osgi.sca"/>
+ <property name="service.intents" value="sca:SOAP sca:HTTP" />
+ <property name="osgi.remote.configuration.type" value="org.osgi.sca" />
+ <property name="osgi.remote.configuration.sca.componentType" value="OSGI-INF/sca/bundle.componentType" />
+ <property name="osgi.remote.configuration.sca.reference" value="subtractService" />
+ </endpoint-description>
+ <endpoint-description>
+ <property name="objectClass" value="calculator.dosgi.operations.MultiplyService" />
+ <property name="service.intents" value="sca:SOAP sca:HTTP" />
+ <property name="service.imported.configs" value="org.osgi.sca"/>
+ <property name="osgi.remote.configuration.type" value="org.osgi.sca" />
+ <property name="osgi.remote.configuration.sca.componentType" value="OSGI-INF/sca/bundle.componentType" />
+ <property name="osgi.remote.configuration.sca.reference" value="multiplyService" />
+ </endpoint-description>
+ <endpoint-description>
+ <property name="objectClass" value="calculator.dosgi.operations.DivideService" />
+ <property name="service.imported.configs" value="org.osgi.sca"/>
+ <property name="service.intents" value="sca:SOAP sca:HTTP" />
+ <property name="osgi.remote.configuration.type" value="org.osgi.sca" />
+ <property name="osgi.remote.configuration.sca.componentType" value="OSGI-INF/sca/bundle.componentType" />
+ <property name="osgi.remote.configuration.sca.reference" value="divideService" />
+ </endpoint-description>
+</endpoint-descriptions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/bundle.componentType b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/bundle.componentType
new file mode 100644
index 0000000000..401809c197
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/bundle.componentType
@@ -0,0 +1,63 @@
+<?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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
+ <!-- The service elment defines an SCA view of the OSGi service -->
+ <service name="Calculator">
+ <!-- The interface will be mapped into the OSGi service class -->
+ <interface.java interface="calculator.dosgi.CalculatorService"/>
+ <!-- The list of OSGi properties -->
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+
+ <!-- The reference elment defines an SCA proxy to a remote OSGi service -->
+ <reference name="addService">
+ <interface.java interface="calculator.dosgi.operations.AddService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="subtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="multiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="divideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+</componentType>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite
new file mode 100644
index 0000000000..830c6867ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite
@@ -0,0 +1,53 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://calculator.dosgi"
+ name="CalculatorComposite">
+
+ <component name="CalculatorComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi" bundleVersion="1.0.0" />
+ <reference name="addService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
+ </reference>
+ <reference name="subtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
+ </reference>
+ <reference name="multiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
+ </reference>
+ <reference name="divideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
+ </reference>
+
+ <!--
+ <reference name="addService" target="OperationsComponent/AddService">
+ </reference>
+ <reference name="subtractService" target="OperationsComponent/SubtractService">
+ </reference>
+ <reference name="multiplyService" target="OperationsComponent/MultiplyService">
+ </reference>
+ <reference name="divideService" target="OperationsComponent/DivideService">
+ </reference>
+ -->
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2345c785a7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Export-Package: calculator.dosgi.operations;version="1.0.0"
+Bundle-Version: 1.0.0
+Bundle-Name: calculator.dosgi.operations
+Bundle-Activator: calculator.dosgi.operations.impl.OperationsActivator
+Bundle-ManifestVersion: 2
+Import-Package: calculator.dosgi.operations;version="1.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.osgi.framework,
+ org.osgi.service.component;resolution:=optional,
+ org.osgi.service.packageadmin
+Bundle-SymbolicName: calculator.dosgi.operations
+Bundle-Vendor: The Apache Software Foundation
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Service-Component: OSGI-INF/add-component.xml,
+ OSGI-INF/subtract-component.xml,
+ OSGI-INF/multiply-component.xml,
+ OSGI-INF/divide-component.xml
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..d24999ab3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:OperationsComposite" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/add-component.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/add-component.xml
new file mode 100644
index 0000000000..99845257ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/add-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="AddComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.AddServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.AddService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/blueprint/operations-module.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/blueprint/operations-module.xml
new file mode 100644
index 0000000000..f6b5f4690e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/blueprint/operations-module.xml
@@ -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.
+-->
+<!-- A sample module-context.xml for OSGI RFC 124 (BluePrint Service) -->
+<components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <component id="AddComponent" class="calculator.dosgi.operations.impl.AddServiceImpl">
+ </component>
+ <component id="SubtractComponent" class="calculator.dosgi.operations.impl.SubtractServiceImpl">
+ </component>
+ <component id="MultiplyComponent" class="calculator.dosgi.operations.impl.MultiplyServiceImpl">
+ </component>
+ <component id="DivideComponent" class="calculator.dosgi.operations.impl.DivideServiceImpl">
+ </component>
+
+ <!-- We can derive the SCA services for the implementation.osgi -->
+ <service id="AddService" ref="AddComponent" interface="calculator.dosgi.operations.AddService">
+ </service>
+ <service id="SubtractService" ref="SubtractComponent" interface="calculator.dosgi.operations.SubtractService">
+ </service>
+ <service id="MultiplyService" ref="MultiplyComponent" interface="calculator.dosgi.operations.MultiplyService">
+ </service>
+ <service id="DivideService" ref="DivideComponent" interface="calculator.dosgi.operations.DivideService">
+ </service>
+</components> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/divide-component.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/divide-component.xml
new file mode 100644
index 0000000000..322d4daf2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/divide-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="DivideComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.DivideServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.DivideService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/multiply-component.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/multiply-component.xml
new file mode 100644
index 0000000000..b9ca777bd8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/multiply-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="MultiplyComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.MultiplyServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.MultiplyService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/subtract-component.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/subtract-component.xml
new file mode 100644
index 0000000000..1472f5a976
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/subtract-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="SubtractComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.SubtractServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.SubtractService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType
new file mode 100644
index 0000000000..fced5b7840
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType
@@ -0,0 +1,54 @@
+<?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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
+
+
+ <!-- The service elment defines an SCA proxy to a remote OSGi service -->
+ <service name="AddService">
+ <interface.java interface="calculator.dosgi.operations.AddService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+ <service name="SubtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+ <service name="MultiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+ <service name="DivideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+</componentType>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/operations.composite b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/operations.composite
new file mode 100644
index 0000000000..c7250912b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/operations.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://calculator.dosgi"
+ name="OperationsComposite">
+
+ <component name="OperationsComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi.operations" bundleVersion="1.0.0" />
+ <service name="AddService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
+ </service>
+ <service name="SubtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
+ </service>
+ <service name="MultiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
+ </service>
+ <service name="DivideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
+ </service>
+
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..60dc54014a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0
+Bundle-Name: calculator.dosgi.sca
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: calculator.dosgi.sca
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: false
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: calculator.dosgi;version="1.0.0",
+ calculator.dosgi.operations;version="1.0.0"
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b48c048000
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:CalculatorComposite" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite
new file mode 100644
index 0000000000..1be863568c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://calculator.dosgi"
+ name="CalculatorComposite">
+
+ <component name="CalculatorComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi" bundleVersion="1.0.0" />
+ <reference name="addService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
+ </reference>
+ <reference name="subtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
+ </reference>
+ <reference name="multiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
+ </reference>
+ <reference name="divideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
+ </reference>
+
+ <!--
+ <reference name="addService" target="OperationsComponent/AddService">
+ </reference>
+ <reference name="subtractService" target="OperationsComponent/SubtractService">
+ </reference>
+ <reference name="multiplyService" target="OperationsComponent/MultiplyService">
+ </reference>
+ <reference name="divideService" target="OperationsComponent/DivideService">
+ </reference>
+ -->
+ </component>
+
+ <component name="OperationsComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi.operations" bundleVersion="1.0.0" />
+ <service name="AddService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
+ </service>
+ <service name="SubtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
+ </service>
+ <service name="MultiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
+ </service>
+ <service name="DivideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
+ </service>
+
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/LICENSE b/sandbox/sebastien/java/embed/modules/node-impl/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/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/sebastien/java/embed/modules/node-impl/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/node-impl/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..15eeb4cf15
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/META-INF/MANIFEST.MF
@@ -0,0 +1,40 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.node.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Node Implementation
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Node Implementation
+Import-Package: javax.management;resolution:=optional,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0",
+ org.apache.tuscany.sca.deployment;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.management;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.node.impl
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/NOTICE b/sandbox/sebastien/java/embed/modules/node-impl/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/pom.xml b/sandbox/sebastien/java/embed/modules/node-impl/pom.xml
new file mode 100644
index 0000000000..5d55b13fc8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/pom.xml
@@ -0,0 +1,115 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-node-impl</artifactId>
+ <name>Apache Tuscany SCA Node Implementation</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-deployment</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-builder</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java
new file mode 100644
index 0000000000..d11eb317cf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.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.sca.node.configuration.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+
+/**
+ * Implements a StAX artifact processor for configured node implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeConfigurationATOMProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<NodeConfiguration> {
+
+ private static final String ATOM_NS = "http://www.w3.org/2005/Atom";
+ private static final QName FEED_QNAME = new QName(ATOM_NS, "feed");
+ private static final QName ENTRY_QNAME = new QName(ATOM_NS, "entry");
+ private static final QName ID_QNAME = new QName(ATOM_NS, "id");
+ private static final QName LINK_QNAME = new QName(ATOM_NS, "link");
+ private static final QName CONTENT_QNAME = new QName(ATOM_NS, "content");
+ private static final String HREF = "href";
+
+ private NodeConfigurationFactory factory;
+
+ public NodeConfigurationATOMProcessor(FactoryExtensionPoint modelFactories) {
+ this.factory = modelFactories.getFactory(NodeConfigurationFactory.class);
+ }
+
+ public QName getArtifactType() {
+ return null;
+ }
+
+ public Class<NodeConfiguration> getModelType() {
+ // Returns the type of model processed by this processor
+ return NodeConfiguration.class;
+ }
+
+ public NodeConfiguration read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ NodeConfiguration config = factory.createNodeConfiguration();
+
+ // Read a feed containing links to the composite and the contributions assigned to
+ // the node
+ ContributionConfiguration contribution = null;
+ boolean id = false;
+ QName name = null;
+
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+
+ case START_ELEMENT:
+ name = reader.getName();
+
+ if (ENTRY_QNAME.equals(name)) {
+
+ // Read an <entry>
+ contribution = factory.createContributionConfiguration();
+ } else if (ID_QNAME.equals(name)) {
+
+ // Read an <id>
+ id = true;
+
+ } else if (LINK_QNAME.equals(name)) {
+
+ // Read a <link>
+ String href = getString(reader, HREF);
+
+ if (contribution != null) {
+ contribution.setLocation(href);
+ }
+ } else if (CONTENT_QNAME.equals(name)) {
+ // Read a <content>
+ } else if (FEED_QNAME.equals(name)) {
+ // Read a <feed>
+ }
+ break;
+
+ case XMLStreamConstants.CHARACTERS:
+
+ // Read characters inside an <id> element
+ if (id) {
+ if (contribution != null) {
+ contribution.setURI(reader.getText());
+ }
+ }
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+
+ // Clear current state when reading reaching end element
+ if (ENTRY_QNAME.equals(name)) {
+ if (contribution != null) {
+ config.getContributions().add(contribution);
+ }
+
+ contribution = null;
+
+ } else if (ID_QNAME.equals(name)) {
+ id = false;
+
+ } else if (FEED_QNAME.equals(name)) {
+
+ // We've reached the end of the feed
+ return config;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return config;
+ }
+
+ public void resolve(NodeConfiguration implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+
+ public void write(NodeConfiguration implementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
new file mode 100644
index 0000000000..46f46a3757
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.configuration.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+
+/**
+ * Implements a StAX artifact processor for node implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<NodeConfiguration> {
+ private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ private static final QName NODE = new QName(SCA11_TUSCANY_NS, "node");
+ private static final QName CONTRIBUTION = new QName(SCA11_TUSCANY_NS, "contribution");
+ private static final QName BINDING = new QName(SCA11_TUSCANY_NS, "binding");
+ private static final QName BASE_URI = new QName(SCA11_TUSCANY_NS, "baseURI");
+ private static final QName DEPLOYMENT_COMPOSITE = new QName(SCA11_TUSCANY_NS, "deploymentComposite");
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private static final QName COMPOSITE = new QName(SCA11_NS, "composite");
+
+ private StAXArtifactProcessor processor;
+ private NodeConfigurationFactory nodeConfigurationFactory;
+ private StAXHelper helper;
+
+ public NodeConfigurationProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor processor) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.nodeConfigurationFactory = modelFactories.getFactory(NodeConfigurationFactory.class);
+ this.processor = processor;
+ this.helper = StAXHelper.getInstance(registry);
+ }
+
+ public QName getArtifactType() {
+ // Returns the QName of the XML element processed by this processor
+ return NODE;
+ }
+
+ public Class<NodeConfiguration> getModelType() {
+ // Returns the type of model processed by this processor
+ return NodeConfiguration.class;
+ }
+
+ public NodeConfiguration read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+
+ NodeConfiguration node = null;
+ ContributionConfiguration contribution = null;
+ DeploymentComposite composite = null;
+ BindingConfiguration binding = null;
+
+ // Skip to end element
+ while (true) {
+ int event = reader.getEventType();
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ if (NODE.equals(name)) {
+ node = nodeConfigurationFactory.createNodeConfiguration();
+ node.setURI(reader.getAttributeValue(null, "uri"));
+ node.setDomainURI(reader.getAttributeValue(null, "domain"));
+ node.setDomainRegistryURI(reader.getAttributeValue(null, "domainRegistry"));
+ } else if (CONTRIBUTION.equals(name)) {
+ contribution = nodeConfigurationFactory.createContributionConfiguration();
+ contribution.setURI(reader.getAttributeValue(null, "uri"));
+ contribution.setLocation(reader.getAttributeValue(null, "location"));
+ node.getContributions().add(contribution);
+ } else if (BINDING.equals(name)) {
+ binding = nodeConfigurationFactory.createBindingConfiguration();
+ binding.setBindingType(getQName(reader, "name"));
+ String baseURIs = reader.getAttributeValue(null, "baseURIs");
+ if (baseURIs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(baseURIs);
+ while (tokenizer.hasMoreTokens()) {
+ binding.getBaseURIs().add(tokenizer.nextToken());
+ }
+ }
+ node.getBindings().add(binding);
+ } else if (DEPLOYMENT_COMPOSITE.equals(name)) {
+ composite = nodeConfigurationFactory.createDeploymentComposite();
+ composite.setLocation(reader.getAttributeValue(null, "location"));
+ if (contribution != null) {
+ contribution.getDeploymentComposites().add(composite);
+ }
+ } else if(BASE_URI.equals(name)) {
+ // We also support <baseURI> element
+ String baseURI = reader.getElementText();
+ if (baseURI != null && binding != null) {
+ baseURI = baseURI.trim();
+ binding.addBaseURI(baseURI);
+ }
+ // getElementText() moves the event to END_ELEMENT
+ continue;
+ } else if (COMPOSITE.equals(name)) {
+ /*
+ Object model = processor.read(reader);
+ if (model instanceof Composite) {
+ // FIXME: We need to capture the text here
+ // composite.setComposite((Composite)model);
+ }
+ */
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter writer = helper.createXMLStreamWriter(sw);
+ helper.save(reader, writer);
+ composite.setContent(sw.toString());
+ } else {
+ node.getExtensions().add(processor.read(reader, context));
+ }
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+ if (NODE.equals(name)) {
+ return node;
+ } else if (CONTRIBUTION.equals(name)) {
+ contribution = null;
+ } else if (DEPLOYMENT_COMPOSITE.equals(name)) {
+ composite = null;
+ } else if (BINDING.equals(name)) {
+ binding = null;
+ }
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+
+ return node;
+ }
+
+ public void resolve(NodeConfiguration node, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+
+ public void write(NodeConfiguration node, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+
+ writeStart(writer,
+ NODE.getNamespaceURI(),
+ NODE.getLocalPart(),
+ new XAttr("uri", node.getURI()),
+ new XAttr("domainRegistry", node.getDomainRegistryURI()),
+ new XAttr("domain", node.getDomainURI()));
+
+ for (ContributionConfiguration c : node.getContributions()) {
+ writeStart(writer,
+ CONTRIBUTION.getNamespaceURI(),
+ CONTRIBUTION.getLocalPart(),
+ new XAttr("uri", c.getURI()),
+ new XAttr("location", c.getLocation()));
+ for (DeploymentComposite dc : c.getDeploymentComposites()) {
+ writeStart(writer,
+ DEPLOYMENT_COMPOSITE.getNamespaceURI(),
+ DEPLOYMENT_COMPOSITE.getLocalPart(),
+ new XAttr("location", dc.getLocation()),
+ new XAttr("contribution", dc.getContributionURI()));
+ if (dc.getContent() != null) {
+ XMLStreamReader reader = helper.createXMLStreamReader(new StringReader(dc.getContent()));
+ reader.nextTag(); // Move to the first element
+ helper.save(reader, writer);
+ reader.close();
+ }
+ writeEnd(writer);
+ }
+ writeEnd(writer);
+ }
+
+ for (BindingConfiguration b : node.getBindings()) {
+ StringBuffer uris = new StringBuffer();
+ for (String uri : b.getBaseURIs()) {
+ uris.append(uri).append(' ');
+ }
+ if (uris.length() > 0) {
+ uris.deleteCharAt(uris.length() - 1); // Remove the trailing space
+ } else {
+ uris = null;
+ }
+ String baseURIs = (uris == null) ? null : uris.toString();
+ writeStart(writer,
+ BINDING.getNamespaceURI(),
+ BINDING.getLocalPart(),
+ new XAttr("name", b.getBindingType()),
+ new XAttr("baseURIs", baseURIs));
+ writeEnd(writer);
+ }
+
+ for(Object o: node.getExtensions()) {
+ processor.write(o, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
new file mode 100644
index 0000000000..fc975c0072
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
@@ -0,0 +1,524 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.impl;
+
+import static java.lang.System.currentTimeMillis;
+import static org.apache.tuscany.sca.common.java.io.IOHelper.createURI;
+import static org.apache.tuscany.sca.common.java.io.IOHelper.openStream;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * This class provides a node factory that can create multiple nodes that share the same
+ * extension point registry
+ */
+public class NodeFactoryImpl extends NodeFactory {
+ protected static final Logger logger = Logger.getLogger(NodeImpl.class.getName());
+
+ protected boolean inited;
+ protected Map<Object, Node> nodes = new ConcurrentHashMap<Object, Node>();
+
+ protected Deployer deployer;
+ protected ExtensionPointRegistry registry;
+ protected ProxyFactory proxyFactory;
+ protected MonitorFactory monitorFactory;
+
+ /**
+ * Automatically destroy the factory when last node is stopped. Subclasses
+ * can set this flag.
+ */
+ protected boolean autoDestroy = true;
+
+ @Override
+ public Node createNode(NodeConfiguration configuration) {
+ if (configuration.getURI() == null) {
+ // Make sure a unique node URI is created for the same node factory
+ configuration.setURI(generateNodeURI());
+ }
+ return new NodeImpl(this, configuration);
+ }
+
+ protected Node removeNode(NodeConfiguration configuration) {
+ Node node = nodes.remove(getNodeKey(configuration));
+ if (autoDestroy && nodes.isEmpty()) {
+ destroy();
+ }
+ return node;
+ }
+
+ protected void addNode(NodeConfiguration configuration, Node node) {
+ nodes.put(getNodeKey(configuration), node);
+ }
+
+ @Override
+ public NodeConfiguration loadConfiguration(InputStream xml, URL base) {
+ try {
+ init();
+ InputStreamReader reader = new InputStreamReader(xml, "UTF-8");
+ ProcessorContext context = deployer.createProcessorContext();
+ NodeConfiguration config = deployer.loadXMLDocument(reader, context.getMonitor());
+ if (base != null && config != null) {
+ // Resolve the contribution location against the node.xml
+ for (ContributionConfiguration c : config.getContributions()) {
+ String location = c.getLocation();
+ if (location != null) {
+ URL url = new URL(base, location);
+ url = IOHelper.normalize(url);
+ c.setLocation(url.toString());
+ }
+ }
+ }
+ return config;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public Map<Object, Node> getNodes() {
+ return nodes;
+ }
+
+ public List<Node> getNodesInDomain(String domainName) {
+ List<Node> domainNodes = new ArrayList<Node>();
+ if (nodes != null) {
+ for (Node n : nodes.values()) {
+ if (domainName.equals(((NodeImpl)n).getConfiguration().getDomainURI())) {
+ domainNodes.add(n);
+ }
+ }
+ }
+ return domainNodes;
+ }
+
+ protected Object getNodeKey(NodeConfiguration configuration) {
+ return new NodeKey(configuration);
+ }
+
+ public synchronized void destroy() {
+ if (inited) {
+ for (Node node : nodes.values()) {
+ node.stop();
+ }
+ nodes.clear();
+ deployer.stop();
+ registry.stop();
+ super.destroy();
+ inited = false;
+ }
+ }
+
+ /**
+ * Analyze problems reported by the artifact processors and builders.
+ *
+ * @throws Exception
+ */
+ private void analyzeProblems(Monitor monitor) throws Throwable {
+ try {
+ for (Problem problem : monitor.getProblems()) {
+ if ((problem.getSeverity() == Severity.ERROR)) {
+ if (problem.getCause() != null) {
+ throw problem.getCause();
+ } else {
+ throw new ServiceRuntimeException(problem.toString());
+ }
+ }
+ }
+ } finally {
+ // FIXME: Clear problems so that the monitor is clean again
+ monitor.reset();
+ }
+ }
+
+ private boolean attachDeploymentComposite(Contribution contribution, Reader xml, String location, boolean attached, ProcessorContext context)
+ throws XMLStreamException, ContributionReadException {
+
+ // Read the composite model
+ Composite composite = deployer.loadXMLDocument(xml, context.getMonitor());
+
+ // Replace the deployable composites with the deployment composites
+ // Clear the deployable composites if it's the first deployment composite
+ deployer.attachDeploymentComposite(contribution, composite, attached);
+ if (!attached) {
+ attached = true;
+ }
+ return attached;
+ }
+
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ if (registry == null) {
+ // Create extension point registry
+ registry = createExtensionPointRegistry();
+ registry.start();
+ }
+ return registry;
+ }
+
+ public synchronized void init() {
+ if (inited) {
+ return;
+ }
+ long start = currentTimeMillis();
+
+ getExtensionPointRegistry();
+
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ monitorFactory = utilities.getUtility(MonitorFactory.class);
+
+ utilities.getUtility(RuntimeProperties.class).setProperties(properties);
+
+ // Use the runtime-enabled assembly factory
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = new RuntimeAssemblyFactory(registry);
+ modelFactories.addFactory(assemblyFactory);
+
+ // Load the Deployer
+ deployer = utilities.getUtility(Deployer.class);
+
+ // Enable schema validation only of the logger level is FINE or higher
+ deployer.setSchemaValidationEnabled(isSchemaValidationEnabled());
+
+ // Initialize the Tuscany module activators
+ // The module activators will be started
+ registry.getExtensionPoint(ModuleActivatorExtensionPoint.class);
+
+ // Initialize runtime
+
+ // Get proxy factory
+ proxyFactory = ExtensibleProxyFactory.getInstance(registry);
+
+ utilities.getUtility(WorkScheduler.class);
+
+ inited = true;
+
+ if (logger.isLoggable(Level.FINE)) {
+ long end = currentTimeMillis();
+ logger.fine("The tuscany runtime started in " + (end - start) + " ms.");
+ }
+ }
+
+ public void start() {
+ init();
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(registry);
+ domainRegistryFactory.getEndpointRegistry(properties.getProperty("reguri"), properties.getProperty("defaultDomainName"));
+ }
+
+ protected ExtensionPointRegistry createExtensionPointRegistry() {
+ return new DefaultExtensionPointRegistry();
+ }
+
+ protected boolean isSchemaValidationEnabled() {
+ String enabled = getSystemProperty(ValidationSchemaExtensionPoint.class.getName() + ".enabled");
+ if (enabled == null) {
+ enabled = "true";
+ }
+ boolean debug = logger.isLoggable(Level.FINE);
+ return "true".equals(enabled) || debug;
+ }
+
+ protected Composite configureNode(NodeConfiguration configuration, List<Contribution> contributions, ProcessorContext context)
+ throws Throwable {
+ if (contributions == null) {
+ // Load contributions
+ contributions = loadContributions(configuration, context);
+ }
+
+ Monitor monitor = context.getMonitor();
+ Map<QName, List<String>> bindingBaseURIs = new HashMap<QName, List<String>>();
+ for (BindingConfiguration config : configuration.getBindings()) {
+ bindingBaseURIs.put(config.getBindingType(), config.getBaseURIs());
+ }
+ List<Contribution> allContributions = getAllContributions(configuration.getDomainURI());
+
+ Composite domainComposite = deployer.build(contributions, allContributions, bindingBaseURIs, monitor);
+ analyzeProblems(monitor);
+
+ // postBuildEndpointReferenceMatching(domainComposite);
+
+ return domainComposite;
+ }
+
+ private List<Contribution> getAllContributions(String domainName) {
+ List<Contribution> contributions = new ArrayList<Contribution>();
+ for (NodeFactory f : getNodeFactories()) {
+ for (Node node : ((NodeFactoryImpl)f).getNodesInDomain(domainName)) {
+ contributions.addAll(((NodeImpl)node).getContributions());
+ }
+ }
+ return contributions;
+ }
+
+ // =============================================
+ // TODO - TUSCANY-3425
+ // post build endpoint reference matching. Give the matching algorithm
+ // a chance to run and report any errors for local references prior to
+ // runtime start. Not in use at the moment as we are getting away with
+ // runtime matching. Leaving here for when we come to sorting out
+ // autowire which still relies on matching in the builder
+ private void postBuildEndpointReferenceMatching(Composite composite){
+ EndpointReferenceBinder endpointReferenceBinder = registry.getExtensionPoint(EndpointReferenceBinder.class);
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(registry);
+
+ // create temporary local registry for all available local endpoints
+ // TODO - need a better way of getting a local registry
+ EndpointRegistry registry = domainRegistryFactory.getEndpointRegistry("vm://tmp", "local");
+
+ // populate the registry with all the endpoints that are currently present in the model
+ populateLocalRegistry(composite, registry);
+
+ // look at all the endpoint references and try to match them to
+ // any local endpoints
+ for (EndpointReference endpointReference : registry.getEndpointReferences()){
+ endpointReferenceBinder.bindBuildTime(registry, endpointReference);
+ }
+
+ // remove the local registry
+ domainRegistryFactory.getEndpointRegistries().remove(registry);
+ }
+
+ private void populateLocalRegistry(Composite composite, EndpointRegistry registry){
+ for (Component component : composite.getComponents()) {
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ populateLocalRegistry((Composite)implementation, registry);
+ }
+
+ for (ComponentService service : component.getServices()) {
+ for (Endpoint endpoint : service.getEndpoints()){
+ registry.addEndpoint(endpoint);
+ }
+ }
+
+ for (ComponentReference reference : component.getReferences()) {
+ for (EndpointReference endpointReference : reference.getEndpointReferences()){
+ registry.addEndpointReference(endpointReference);
+ }
+ }
+ }
+ }
+
+ // =============================================
+
+ protected List<Contribution> loadContributions(NodeConfiguration configuration, ProcessorContext context) throws Throwable {
+ List<Contribution> contributions = new ArrayList<Contribution>();
+
+ // Load the specified contributions
+ for (ContributionConfiguration contrib : configuration.getContributions()) {
+ URI contributionURI = createURI(contrib.getURI());
+
+ URI uri = createURI(contrib.getLocation());
+ if (uri.getScheme() == null) {
+ uri = new File(contrib.getLocation()).toURI();
+ }
+ URL contributionURL = uri.toURL();
+
+ // Load the contribution
+ logger.log(Level.INFO, "Loading contribution: " + contributionURL);
+ Contribution contribution = deployer.loadContribution(contributionURI, contributionURL, context.getMonitor());
+ contributions.add(contribution);
+
+ boolean attached = false;
+ for (DeploymentComposite dc : contrib.getDeploymentComposites()) {
+ if (dc.getContent() != null) {
+ Reader xml = new StringReader(dc.getContent());
+ attached = attachDeploymentComposite(contribution, xml, null, attached, context);
+ } else if (dc.getLocation() != null) {
+ URI dcURI = createURI(dc.getLocation());
+ if (!dcURI.isAbsolute()) {
+ Composite composite = null;
+ // The location is pointing to an artifact within the contribution
+ for (Artifact a : contribution.getArtifacts()) {
+ if (dcURI.toString().equals(a.getURI())) {
+ composite = (Composite)a.getModel();
+ if (!attached) {
+ contribution.getDeployables().clear();
+ attached = true;
+ }
+ contribution.getDeployables().add(composite);
+ break;
+ }
+ }
+ if (composite == null) {
+ // Not found
+ throw new ServiceRuntimeException("Deployment composite " + dcURI
+ + " cannot be found within contribution "
+ + contribution.getLocation());
+ }
+ } else {
+ URL url = dcURI.toURL();
+ InputStream is = openStream(url);
+ Reader xml = new InputStreamReader(is, "UTF-8");
+ attached = attachDeploymentComposite(contribution, xml, url.toString(), attached, context);
+ }
+ }
+ }
+ analyzeProblems(context.getMonitor());
+ }
+ return contributions;
+ }
+
+ protected static String getSystemProperty(final String name) {
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(name);
+ }
+ });
+ }
+
+ protected static class NodeKey {
+ private String domainURI;
+ private String nodeURI;
+
+ public NodeKey(NodeConfiguration configuration) {
+ this.domainURI = configuration.getDomainURI();
+ this.nodeURI = configuration.getURI();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((domainURI == null) ? 0 : domainURI.hashCode());
+ result = prime * result + ((nodeURI == null) ? 0 : nodeURI.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ NodeKey other = (NodeKey)obj;
+ if (domainURI == null) {
+ if (other.domainURI != null)
+ return false;
+ } else if (!domainURI.equals(other.domainURI))
+ return false;
+ if (nodeURI == null) {
+ if (other.nodeURI != null)
+ return false;
+ } else if (!nodeURI.equals(other.nodeURI))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ if (domainURI != null) {
+ buf.append("{").append(domainURI).append("}");
+ }
+ if (nodeURI != null) {
+ buf.append(nodeURI);
+ }
+ return buf.toString();
+ }
+ }
+
+ @Override
+ public void configure(Map<String, Map<String, String>> attributes) {
+ ServiceDiscovery discovery = getExtensionPointRegistry().getServiceDiscovery();
+ for (Map.Entry<String, Map<String, String>> e : attributes.entrySet()) {
+ discovery.setAttribute(e.getKey(), e.getValue());
+ }
+ for (Object o : properties.keySet()) {
+ String p = (String) o;
+ if (p.indexOf('.') > -1) {
+ String serviceType = p.substring(0, p.lastIndexOf('.'));
+ String attribute = p.substring(p.lastIndexOf('.')+1);
+ discovery.setAttribute(serviceType, attribute, properties.getProperty(p));
+ }
+ }
+ super.configure(attributes);
+ }
+
+ /**
+ * Added to allow the node access to the deployer in order to get
+ * to the systemContribution and hence set up the CompositeContext so that
+ * the runtime epr matching algorithm can get at the binding types
+ * @return
+ */
+ public Deployer getDeployer() {
+ return deployer;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
new file mode 100644
index 0000000000..c767c94452
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -0,0 +1,382 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+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.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.ServiceUnavailableException;
+
+/**
+ * An SCA Node that is managed by the NodeManager
+ */
+public class NodeImpl implements Node {
+ private static final Logger logger = Logger.getLogger(NodeImpl.class.getName());
+ private ProxyFactory proxyFactory;
+ private CompositeActivator compositeActivator;
+ private CompositeContext compositeContext;
+ private Composite domainComposite;
+ private NodeConfiguration configuration;
+ private NodeFactoryImpl nodeFactory;
+ private List<Contribution> contributions;
+ // private NodeManager mbean;
+
+ /**
+ * Create a node from the configuration
+ * @param manager
+ * @param configuration
+ */
+ public NodeImpl(NodeFactoryImpl nodeFactory, NodeConfiguration configuration) {
+ super();
+ this.configuration = configuration;
+ this.nodeFactory = nodeFactory;
+ }
+
+ /**
+ * Create a node from the configuration and loaded contributions
+ * @param manager
+ * @param configuration
+ * @param contributions
+ */
+ public NodeImpl(NodeFactoryImpl manager, NodeConfiguration configuration, List<Contribution> contributions) {
+ super();
+ this.configuration = configuration;
+ this.nodeFactory = manager;
+ this.contributions = new ArrayList<Contribution>(contributions);
+ }
+
+ public String getURI() {
+ return getConfiguration().getURI();
+ }
+
+ public Node start() {
+ logger.log(Level.INFO, "Starting node: " + configuration.getURI() + " domain: " + configuration.getDomainURI());
+
+ nodeFactory.init();
+ nodeFactory.addNode(configuration, this);
+ this.proxyFactory = nodeFactory.proxyFactory;
+
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(nodeFactory.registry);
+ EndpointRegistry endpointRegistry =
+ domainRegistryFactory.getEndpointRegistry(configuration.getDomainRegistryURI(), configuration
+ .getDomainURI());
+
+ UtilityExtensionPoint utilities = nodeFactory.registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.compositeActivator = utilities.getUtility(CompositeActivator.class);
+ try {
+ Monitor monitor = nodeFactory.monitorFactory.createMonitor();
+ ProcessorContext context = new ProcessorContext(monitor);
+
+ // Set up the thead context monitor
+ Monitor tcm = nodeFactory.monitorFactory.setContextMonitor(monitor);
+ try {
+ if (contributions == null) {
+ contributions = nodeFactory.loadContributions(configuration, context);
+ }
+ domainComposite = nodeFactory.configureNode(configuration, contributions, context);
+
+ this.compositeContext =
+ new CompositeContext(nodeFactory.registry,
+ endpointRegistry,
+ domainComposite,
+ configuration.getDomainURI(),
+ configuration.getURI(),
+ nodeFactory.getDeployer().getSystemDefinitions());
+
+ CompositeContext.setThreadCompositeContext(compositeContext);
+ } finally {
+ // Reset the thread context monitor
+ nodeFactory.monitorFactory.setContextMonitor(tcm);
+ }
+
+ // Activate the composite
+ compositeActivator.activate(compositeContext, domainComposite);
+
+ // Start the composite
+ compositeActivator.start(compositeContext, domainComposite);
+
+ // FIXME: [rfeng] We should turn the management capability into a system utility.
+ // In certain environment such as Google App Engine, the JMX API is not allowed
+ try {
+ /*
+ MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+ mbean = new NodeManager(this);
+ mBeanServer.registerMBean(mbean, mbean.getName());
+ */
+ /*
+ LocateRegistry.createRegistry(9999);
+ JMXServiceURL url =
+ new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server");
+ JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mBeanServer);
+ connectorServer.start();
+ */
+ } catch (Throwable e) {
+ // Ignore the error for now
+ // mbean = null;
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+
+ return this;
+
+ } catch (Throwable e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ public void stop() {
+ logger.log(Level.INFO, "Stopping node: " + configuration.getURI());
+
+ try {
+ if (compositeActivator == null) {
+ return;
+ }
+
+ /*
+ if (mbean != null) {
+ try {
+ MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+ mBeanServer.unregisterMBean(mbean.getName());
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ } finally {
+ mbean = null;
+ }
+ }
+ */
+
+ if( domainComposite != null ) {
+
+ // Stop the composite
+ compositeActivator.stop(compositeContext, domainComposite);
+
+ // Deactivate the composite
+ compositeActivator.deactivate(domainComposite);
+
+ } // end if
+
+ nodeFactory.removeNode(configuration);
+ this.compositeActivator = null;
+ this.proxyFactory = null;
+ this.domainComposite = null;
+ this.compositeContext = null;
+
+ ThreadMessageContext.removeMessageContext();
+ CompositeContext.removeCompositeContext();
+
+ } catch (ActivationException e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
+ return (R)proxyFactory.cast(target);
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+
+ ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
+ if (serviceReference == null) {
+ throw new ServiceRuntimeException("Service not found: " + serviceName);
+ }
+ return serviceReference.getService();
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) {
+
+ // Extract the component name
+ String componentName;
+ String serviceName;
+ int i = name.indexOf('/');
+ if (i != -1) {
+ componentName = name.substring(0, i);
+ serviceName = name.substring(i + 1);
+
+ } else {
+ componentName = name;
+ serviceName = null;
+ }
+
+ // Lookup the component
+ Component component = null;
+
+ for (Component compositeComponent : domainComposite.getComponents()) {
+ if (compositeComponent.getName().equals(componentName)) {
+ component = compositeComponent;
+ break;
+ }
+ }
+
+ if (component == null) {
+ throw new ServiceUnavailableException("The service " + name + " has not been contributed to the domain");
+ }
+ RuntimeComponentContext componentContext = null;
+
+ // If the component is a composite, then we need to find the
+ // non-composite component that provides the requested service
+ if (component.getImplementation() instanceof Composite) {
+ for (ComponentService componentService : component.getServices()) {
+ String bindingName = null;
+ if (serviceName != null) {
+ int index = serviceName.indexOf('/');
+ if (index != -1) {
+ bindingName = serviceName.substring(index + 1);
+ serviceName = serviceName.substring(0, index);
+ }
+ }
+ if (serviceName == null || serviceName.equals(componentService.getName())) {
+ CompositeService compositeService = (CompositeService)componentService.getService();
+ if (compositeService != null) {
+ componentContext =
+ ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
+ serviceName = compositeService.getPromotedService().getName();
+ if (bindingName != null) {
+ serviceName = serviceName + "/" + bindingName;
+ }
+ return componentContext.createSelfReference(businessInterface, serviceName);
+ }
+ break;
+ }
+ }
+ // No matching service found
+ throw new ServiceRuntimeException("Composite service not found: " + name);
+ } else {
+ componentContext = ((RuntimeComponent)component).getComponentContext();
+ if (serviceName != null) {
+ return componentContext.createSelfReference(businessInterface, serviceName);
+ } else {
+ return componentContext.createSelfReference(businessInterface);
+ }
+ }
+ }
+
+ public NodeConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ return nodeFactory.getExtensionPointRegistry();
+ }
+
+ /**
+ * Get the service endpoints in this Node
+ * TODO: needs review, works for the very simple testcase but i expect there are
+ * other endpoints to be included
+ */
+ public List<Endpoint> getServiceEndpoints() {
+ List<Endpoint> endpoints = new ArrayList<Endpoint>();
+ if (compositeActivator != null) {
+ if (domainComposite != null) {
+ for (Component component : domainComposite.getComponents()) {
+ for (Service service : component.getServices()) {
+ // MJE 28/05/2009 - changed to RuntimeComponentService from RuntimeComponentServiceImpl
+ // - no need to access the Impl directly here
+ if (service instanceof RuntimeComponentService) {
+ endpoints.addAll(((RuntimeComponentService)service).getEndpoints());
+ }
+ }
+ }
+ }
+ }
+ return endpoints;
+ }
+
+ public Composite getDomainComposite() {
+ return domainComposite;
+ }
+
+ public String dumpDomainComposite() {
+
+ StAXArtifactProcessorExtensionPoint xmlProcessors =
+ getExtensionPointRegistry().getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<Composite> compositeProcessor =
+ xmlProcessors.getProcessor(Composite.class);
+
+ return writeComposite(getDomainComposite(), compositeProcessor);
+ }
+
+ private String writeComposite(Composite composite, StAXArtifactProcessor<Composite> compositeProcessor){
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLOutputFactory outputFactory =
+ nodeFactory.getExtensionPointRegistry().getExtensionPoint(FactoryExtensionPoint.class)
+ .getFactory(XMLOutputFactory.class);
+
+ try {
+ compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(nodeFactory.registry));
+ } catch(Exception ex) {
+ return ex.toString();
+ }
+
+ String result = bos.toString();
+
+ // write out and nested composites
+ for (Component component : composite.getComponents()) {
+ if (component.getImplementation() instanceof Composite) {
+ result +=
+ "\n<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->\n" + writeComposite((Composite)component
+ .getImplementation(),
+ compositeProcessor);
+ }
+ }
+
+ return result;
+ }
+
+ List<Contribution> getContributions() {
+ return contributions;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java
new file mode 100644
index 0000000000..4da41442f5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.impl;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+
+/**
+ * NodeUtil
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeUtil {
+
+ private NodeUtil() {
+ }
+
+ static Contribution contribution(ContributionFactory contributionFactory, org.apache.tuscany.sca.node.Contribution c) {
+ Contribution contribution = contributionFactory.createContribution();
+ contribution.setURI(c.getURI());
+ contribution.setLocation(c.getLocation());
+ contribution.setUnresolved(true);
+ return contribution;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java
new file mode 100644
index 0000000000..12704a3ee5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.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.sca.node.management;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+
+/**
+ * MBean implementation for the node
+ */
+public class NodeManager implements NodeManagerMBean {
+ private NodeImpl node;
+ private ObjectName name;
+
+ public NodeManager(NodeImpl node) {
+ this.node = node;
+ try {
+ this.name = getName(node);
+ } catch (MalformedObjectNameException e) {
+ // Ignore
+ }
+ }
+
+ public String getURI() {
+ return node.getURI();
+ }
+
+ public String getDomainURI() {
+ return node.getConfiguration().getDomainURI();
+ }
+
+ public ObjectName getName() {
+ return name;
+ }
+
+ private static ObjectName getName(NodeImpl node) throws MalformedObjectNameException {
+ String name =
+ Node.class.getPackage().getName() + ":type="
+ + Node.class.getSimpleName()
+ + ",uri="
+ + ObjectName.quote(node.getURI());
+ return ObjectName.getInstance(name);
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java
new file mode 100644
index 0000000000..3133142c2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.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.node.management;
+
+
+
+/**
+ * MBean for NodeImpl
+ */
+public interface NodeManagerMBean {
+ String getURI();
+ String getDomainURI();
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..a9d0f5ef52
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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.node.configuration.xml.NodeConfigurationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#node,model=org.apache.tuscany.sca.node.configuration.NodeConfiguration
+
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory b/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory
new file mode 100644
index 0000000000..a349dd7c26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory
@@ -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.node.impl.NodeFactoryImpl
+
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory b/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory
new file mode 100644
index 0000000000..9b26d0c7c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory
@@ -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.node.configuration.DefaultNodeConfigurationFactory
+
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties b/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties
new file mode 100644
index 0000000000..0c07a3a30f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties
@@ -0,0 +1,22 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+UnresolvedImport = Unresolved import: Import = {0}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/hello/HelloWorld.java b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/hello/HelloWorld.java
new file mode 100644
index 0000000000..e3fcdfd25f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/hello/HelloWorld.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 hello;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * HelloWorld interface
+ */
+@Remotable
+public interface HelloWorld {
+ String hello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/hello/HelloWorldImpl.java b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/hello/HelloWorldImpl.java
new file mode 100644
index 0000000000..c9a7560b12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/hello/HelloWorldImpl.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 hello;
+
+/**
+ * HelloWorldImpl
+ */
+public class HelloWorldImpl implements HelloWorld {
+ public String hello(String name) {
+ System.out.println("Hello: " + name);
+ return "Hello, " + name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java
new file mode 100644
index 0000000000..a10f2cccd4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.configuration.xml;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class NodeConfigurationProcessorTestCase {
+ private static FactoryExtensionPoint factories;
+ private static StAXArtifactProcessor processor;
+
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(registry);
+
+ factories = new DefaultFactoryExtensionPoint(registry);
+ StAXArtifactProcessorExtensionPoint processors =
+ registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ processor = processors.getProcessor(NodeConfiguration.class);
+ }
+
+ @Test
+ public void testRead() throws Exception {
+ InputStream is = getClass().getResourceAsStream("/org/apache/tuscany/sca/node/configuration/node1.xml");
+ XMLInputFactory xmlInputFactory = factories.getFactory(XMLInputFactory.class);
+ XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(is);
+ is.close();
+ reader.nextTag();
+ NodeConfiguration config = (NodeConfiguration) processor.read(reader, context);
+ StringWriter sw = new StringWriter();
+ XMLOutputFactory xmlOutputFactory = factories.getFactory(XMLOutputFactory.class);
+ xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(sw);
+ processor.write(config, writer, context);
+ writer.flush();
+ System.out.println(sw.toString());
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
new file mode 100644
index 0000000000..3133931210
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * \"License\"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * \"AS IS\" BASIS, WITHOUT 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.node.impl;
+
+import hello.HelloWorld;
+
+import java.io.File;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclarationParser;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test case for NodeImpl
+ */
+public class NodeImplTestCase {
+ private static String composite =
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\"" + " xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
+ + " targetNamespace=\"http://sample/composite\""
+ + " xmlns:sc=\"http://sample/composite\""
+ + " name=\"HelloWorld2\">"
+ + " <component name=\"HelloWorld2\">"
+ + " <implementation.java class=\"hello.HelloWorldImpl\"/>"
+ + " </component>"
+ + " </composite>";
+
+ @Test
+ public void testNodeWithCompositeContent() {
+ NodeFactory factory = new NodeFactoryImpl();
+ Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString());
+ Node node = factory.createNode(new StringReader(composite), contribution);
+ testNode2(node);
+ }
+
+ @Test
+ public void testNodeWithRelativeCompositeURI() {
+ NodeFactory factory = new NodeFactoryImpl();
+ Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString());
+ String compositeURI = "HelloWorld.composite";
+ Node node = factory.createNode(compositeURI, contribution);
+ testNode(node);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testNodeWithAbsoluteCompositeURI() throws MalformedURLException {
+ NodeFactory factory = new NodeFactoryImpl();
+ Contribution contribution = new Contribution("c1", new File("target/test-classes").toURL().toString());
+ String compositeURI = new File("target/test-classes/HelloWorld.composite").toURL().toString();
+ Node node = factory.createNode(compositeURI, contribution);
+ testNode(node);
+ }
+
+ @Test
+ public void testDefaultNode() {
+ testNode(new NodeFactoryImpl().createNode());
+ }
+
+ @Test
+ public void testNodeWithURI() {
+ testNode(new NodeFactoryImpl().createNode(URI.create("foo"),"target/test-classes"));
+ }
+ @Test
+ public void testNodeWithURIandComposite() throws MalformedURLException {
+ String compositeURI = new File("target/test-classes/HelloWorld.composite").toURI().toString();
+ testNode(new NodeFactoryImpl().createNode(URI.create("foo"), compositeURI, new String[]{"target/test-classes"}));
+ }
+
+ @Test
+ public void testGetServiceEndpoints() {
+ NodeFactory factory = new NodeFactoryImpl();
+ Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString());
+ NodeImpl node = (NodeImpl)factory.createNode(new StringReader(composite), contribution);
+ node.start();
+ List<Endpoint> es = node.getServiceEndpoints();
+ Assert.assertEquals(1, es.size());
+ Assert.assertEquals("HelloWorld2", es.get(0).getComponent().getName());
+ node.stop();
+ }
+
+ private void testNode(Node node) {
+ node.start();
+ HelloWorld hw = node.getService(HelloWorld.class, "HelloWorld");
+ Assert.assertEquals("Hello, Node", hw.hello("Node"));
+ node.stop();
+ }
+
+ private void testNode2(Node node) {
+ node.start();
+ HelloWorld hw = node.getService(HelloWorld.class, "HelloWorld2");
+ Assert.assertEquals("Hello, Node", hw.hello("Node"));
+ node.stop();
+ }
+
+ @Test
+ public void testNodeFactoryAttributes() {
+ Map<String, Map<String, String>> attrs = new HashMap<String, Map<String, String>>();
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("enabled", "false");
+ attrs.put(ValidationSchemaExtensionPoint.class.getName(), map);
+
+ Map<String, String> map2 = new HashMap<String, String>();
+ map2.put("urn:MyDomain", "multicast://200.0.0.100:50000/MyDomain");
+ attrs.put(DomainRegistryFactoryExtensionPoint.class.getName(), map2);
+
+ NodeFactoryImpl factory = (NodeFactoryImpl)NodeFactory.newInstance(attrs);
+ Assert.assertFalse(factory.getExtensionPointRegistry().getExtensionPoint(ValidationSchemaExtensionPoint.class)
+ .isEnabled());
+
+ DomainRegistryFactoryExtensionPoint domainRegistryFactoryExtensionPoint =
+ factory.getExtensionPointRegistry().getExtensionPoint(DomainRegistryFactoryExtensionPoint.class);
+ Map<String, String> mapping = domainRegistryFactoryExtensionPoint.getDomainRegistryMapping();
+ Assert.assertEquals(1, mapping.size());
+ Assert.assertEquals("multicast://200.0.0.100:50000/MyDomain", mapping.get("urn:MyDomain"));
+ }
+
+ @Test
+ public void testNodeFactoryProperties() throws Exception {
+ NodeFactoryImpl factory = (NodeFactoryImpl)NodeFactory.newInstance();
+ factory.init();
+ UtilityExtensionPoint utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
+ Properties ps = utilities.getUtility(RuntimeProperties.class).getProperties();
+ Assert.assertEquals(2, ps.size());
+ Assert.assertEquals("vm", ps.getProperty("defaultScheme"));
+
+ Properties properties = new Properties();
+ properties.setProperty("defaultScheme", "vm");
+ properties.setProperty("foo.bla", "some value");
+ factory = (NodeFactoryImpl)NodeFactory.newInstance(properties);
+ factory.init();
+ utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
+ ps = utilities.getUtility(RuntimeProperties.class).getProperties();
+ Assert.assertEquals(2, ps.size());
+ Assert.assertEquals("some value", ps.getProperty("foo.bla"));
+
+ factory = (NodeFactoryImpl)NodeFactory.newInstance("properties:test.properties");
+ factory.init();
+ utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
+ ps = utilities.getUtility(RuntimeProperties.class).getProperties();
+ Assert.assertEquals(2, ps.size());
+ Assert.assertEquals("xyz", ps.getProperty("foo.bla"));
+
+ factory = (NodeFactoryImpl)NodeFactory.newInstance("uri:foo?k1=v1&k2=v2&defaultScheme=vm");
+ factory.init();
+ utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
+ ps = utilities.getUtility(RuntimeProperties.class).getProperties();
+ Assert.assertEquals(4, ps.size());
+ Assert.assertEquals("vm", ps.getProperty("defaultScheme"));
+ Assert.assertEquals("foo", ps.getProperty("defaultDomainName"));
+ Assert.assertEquals("v1", ps.getProperty("k1"));
+ Assert.assertEquals("v2", ps.getProperty("k2"));
+
+ factory = (NodeFactoryImpl)NodeFactory.newInstance("uri:");
+ factory.init();
+ utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
+ ps = utilities.getUtility(RuntimeProperties.class).getProperties();
+ Assert.assertEquals(1, ps.size());
+ Assert.assertEquals("", ps.getProperty("defaultDomainName"));
+
+ factory = (NodeFactoryImpl)NodeFactory.newInstance("uri:?");
+ factory.init();
+ utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
+ ps = utilities.getUtility(RuntimeProperties.class).getProperties();
+ Assert.assertEquals(1, ps.size());
+ Assert.assertEquals("default", ps.getProperty("defaultDomainName"));
+
+ factory = (NodeFactoryImpl)NodeFactory.newInstance("uri:?foo");
+ factory.init();
+ utilities = factory.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
+ ps = utilities.getUtility(RuntimeProperties.class).getProperties();
+ Assert.assertEquals(2, ps.size());
+ Assert.assertEquals("default", ps.getProperty("defaultDomainName"));
+ Assert.assertEquals("", ps.getProperty("foo"));
+ }
+
+ @Test
+ public void testLoadNodeFactoryProperties() throws Exception {
+ URL url = getClass().getResource("/org/apache/tuscany/sca/node/configuration/test-node-factory.config");
+ Collection<Map<String, String>> items = ServiceDeclarationParser.load(url, false);
+ for (Map<String, String> attrs : items) {
+ System.out.println(attrs);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java
new file mode 100644
index 0000000000..4b9dda4a71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.impl;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+/**
+ *
+ */
+public class NodeUtilTestCase {
+ @Test
+ public void testCreateURI() {
+ Assert.assertEquals("/a/b", IOHelper.createURI("/a/b").toString());
+ Assert.assertEquals("/a%20b", IOHelper.createURI("/a b").toString());
+ Assert.assertEquals("file:/a/b", IOHelper.createURI("file:/a/b").toString());
+ Assert.assertEquals("file:/a%20b", IOHelper.createURI("file:/a b").toString());
+ Assert.assertEquals("file:/a%20b", IOHelper.createURI("file:/a%20b").toString());
+ }
+
+ @Test
+ public void testDomainURI() {
+ Assert.assertEquals("foo", NodeFactoryImpl.getDomainURI(URI.create("tuscany:foo")));
+ Assert.assertEquals("foo", NodeFactoryImpl.getDomainURI(URI.create("vm:foo")));
+ Assert.assertEquals("foo", NodeFactoryImpl.getDomainURI(URI.create("bla://foo")));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/HelloWorld.composite b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/HelloWorld.composite
new file mode 100644
index 0000000000..ca3c3eda7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/HelloWorld.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample/composite"
+ xmlns:sc="http://sample/composite"
+ name="HelloWorld">
+
+ <component name="HelloWorld">
+ <implementation.java class="hello.HelloWorldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..20627c3d2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sc="http://sample/composite">
+ <deployable composite="sc:HelloWorld" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
new file mode 100644
index 0000000000..4afc52d73b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
@@ -0,0 +1,58 @@
+<?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.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ uri="http://sample/nodes/TestNode1"
+ domainRegistry = "vm://localhost"
+ domain="http://domain1">
+
+ <!-- Configure the base URIs for a given binding -->
+ <!-- Each base URI is for a protocol supported by the binding -->
+ <binding name="sca:binding.ws" baseURIs="http://localhost:8080/ws https://localhost:8081/ws"/>
+ <binding name="tuscany:binding.rmi" baseURIs="rmi://localhost:8080/rmi"/>
+ <binding name="tuscany:binding.jsonrpc">
+ <baseURI>http://localhost:8080/jsonrpc</baseURI>
+ </binding>
+
+ <!-- Configure a list of contributions -->
+ <contribution uri="http://c1" location="file:///a.jar"/>
+ <contribution uri="http://c2" location="http://locahost/repo/b.jar">
+ <!-- The deployment composite is optional -->
+ <!-- The deployment composite can be defined inline or referenced using a URI -->
+ <!-- Can we have more than one deployment composites -->
+ <deploymentComposite>
+ <sca:composite>
+ <sca:component name="Component1"> <!-- first component -->
+ <sca:implementation.java class="a.b.Component1Impl"/>
+ <sca:reference name="ref1">
+ <tuscany:binding.rmi/>
+ </sca:reference>
+ </sca:component>
+ </sca:composite>
+ </deploymentComposite>
+ </contribution>
+ <contribution uri="http://c3" location="http://locahost/repo/c.jar">
+ <deploymentComposite location="test/Test.composite">
+ </deploymentComposite>
+ </contribution>
+ <option name="debug" value="true"/>
+ <option name="validation">true</option>
+</node> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/test-node-factory.config b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/test-node-factory.config
new file mode 100644
index 0000000000..ec87f6a3e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/test-node-factory.config
@@ -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.
+# Configuration properties for NodeFactory
+org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;enabled=true,attr="value"
+org.apache.tuscany.sca.runtime.DomainRegistryFactoryExtensionPoint;urn:MyDomain="multicast://200.0.0.100:50000/MyDomain" \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/test.properties b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/test.properties
new file mode 100644
index 0000000000..df9d47b4eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-impl/src/test/resources/test.properties
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+defaultScheme = vm
+foo.bla = xyz
+
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/LICENSE b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/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/sebastien/java/embed/modules/node-launcher-equinox/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b76c9c66cd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.node.equinox.launcher;uses:="or
+ g.osgi.framework,org.eclipse.core.runtime.adaptor";version="2.0.0"
+Eclipse-AutoStart: true
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Node Equinox OSGi Launcher
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Node Equinox OSGi Launcher
+Import-Package: org.apache.commons.cli;resolution:=optional,
+ org.apache.tuscany.sca.node.equinox.launcher;version="2.0.0",
+ org.eclipse.core.runtime.adaptor;resolution:=optional,
+ org.eclipse.osgi.framework.console;resolution:=optional,
+ org.osgi.framework;version="[1.4, 2.0)",
+ org.osgi.framework.launch;version="[1.0.0, 2.0.0)"
+Bundle-Activator: org.apache.tuscany.sca.node.equinox.launcher.FrameworkLauncher
+Bundle-SymbolicName: org.apache.tuscany.sca.node.launcher.equinox
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/NOTICE b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/pom.xml b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/pom.xml
new file mode 100644
index 0000000000..b26ca52daa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/pom.xml
@@ -0,0 +1,126 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <name>Apache Tuscany SCA Node Equinox OSGi Launcher</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+
+<!--
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>runtime</artifactId>
+ <version>3.3.100-v20070530</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>app</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>app</artifactId>
+ <version>1.2.0-v20090520-1800</version>
+ <scope>runtime</scope>
+ </dependency>
+-->
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-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>org.apache.tuscany.sca.node.equinox.launcher.NodeMain</mainClass>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java
new file mode 100644
index 0000000000..892412b395
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.node.equinox.launcher;
+
+/**
+ * Represents an SCA contribution uri + location.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class Contribution {
+ private String uri;
+ private String location;
+
+ /**
+ * Constructs a new SCA contribution.
+ *
+ * @param uri
+ * @param location
+ */
+ public Contribution(String uri, String location) {
+ this.uri = uri;
+ this.location = location;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java
new file mode 100644
index 0000000000..056ec080ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.equinox.launcher;
+
+import java.io.File;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * ContributionLocationHelper
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionLocationHelper {
+
+ /**
+ * Returns the location of the SCA contribution containing the given class.
+ *
+ * @param anchorClass
+ * @return
+ */
+ public static String getContributionLocation(final Class<?> anchorClass) {
+ URL url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return anchorClass.getProtectionDomain().getCodeSource().getLocation();
+ }
+ });
+ String uri = url.toString();
+ return uri;
+ }
+
+ /**
+ * Returns the location of the SCA contribution represented by the given bundle.
+ *
+ * @param anchorClass
+ * @return
+ */
+ public static String getContributionLocation(final Bundle bundle) {
+ String uri = bundle.getLocation();
+ uri = uri.substring(uri.indexOf("file:") + 5);
+ File file = new File(uri);
+ uri = file.toURI().toString();
+ return uri;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java
new file mode 100644
index 0000000000..e6f59e1b07
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.equinox.launcher;
+
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.domainManager;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Simple launcher for the SCA domain manager.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DomainManagerLauncher {
+
+ static final Logger logger = Logger.getLogger(DomainManagerLauncher.class.getName());
+
+ /**
+ * Constructs a new DomainManagerLauncher.
+ */
+ private DomainManagerLauncher() {
+ }
+
+ /**
+ * Returns a new launcher instance.
+ *
+ * @return a new launcher instance
+ */
+ public static DomainManagerLauncher newInstance() {
+ return new DomainManagerLauncher();
+ }
+
+ /**
+ * Creates a new DomainManager.
+ *
+ * @return a new DomainManager
+ * @throws LauncherException
+ */
+ public <T> T createDomainManager() throws LauncherException {
+ return (T)domainManager(".");
+ }
+
+ /**
+ * Creates a new DomainManager.
+ *
+ * @param rootDirectory the domain's root configuration directory
+ *
+ * @return a new DomainManager
+ * @throws LauncherException
+ */
+ public <T> T createDomainManager(String rootDirectory) throws LauncherException {
+ return (T)domainManager(rootDirectory);
+ }
+
+ public static void main(String[] args) throws Exception {
+ logger.info("Apache Tuscany SCA Domain Manager is starting...");
+
+ // Create a launcher
+ DomainManagerLauncher launcher = newInstance();
+
+ EquinoxHost equinox = null;
+ Object domainManager = null;
+ ShutdownThread shutdown = null;
+ try {
+
+ // Start the OSGi host
+ equinox = new EquinoxHost();
+ equinox.start();
+
+ // Start the domain manager
+ domainManager = launcher.createDomainManager();
+ try {
+ domainManager.getClass().getMethod("start").invoke(domainManager);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Domain Manager could not be started", e);
+ throw e;
+ }
+ logger.info("SCA Domain Manager is now started.");
+
+ // Install a shutdown hook
+ ShutdownThread hook = new ShutdownThread(domainManager, equinox);
+ Runtime.getRuntime().addShutdownHook(hook);
+
+ logger.info("Press enter to shutdown.");
+ try {
+ System.in.read();
+ } catch (IOException e) {
+
+ // Wait forever
+ Object lock = new Object();
+ synchronized(lock) {
+ lock.wait();
+ }
+ }
+
+ } finally {
+
+ // Remove the shutdown hook
+ if (shutdown != null) {
+ Runtime.getRuntime().removeShutdownHook(shutdown);
+ }
+
+ // Stop the domain manager and OSGi host
+ if (domainManager != null) {
+ stopDomainManager(domainManager);
+ }
+ if (equinox != null) {
+ equinox.stop();
+ }
+ }
+ }
+
+
+ /**
+ * Stop the given domain manager.
+ *
+ * @param domainManager
+ * @throws Exception
+ */
+ private static void stopDomainManager(Object domainManager) throws Exception {
+ try {
+ domainManager.getClass().getMethod("stop").invoke(domainManager);
+ logger.info("SCA Domain Manager is now stopped.");
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Domain Manager could not be stopped", e);
+ throw e;
+ }
+ }
+
+ private static class ShutdownThread extends Thread {
+ private Object domainManager;
+ private EquinoxHost equinox;
+
+ public ShutdownThread(Object domainManager, EquinoxHost equinox) {
+ super();
+ this.domainManager = domainManager;
+ this.equinox = equinox;
+ }
+
+ @Override
+ public void run() {
+ try {
+ stopDomainManager(domainManager);
+ } catch (Exception e) {
+ // Ignore
+ }
+ try {
+ equinox.stop();
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
new file mode 100644
index 0000000000..f82e855abb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
@@ -0,0 +1,658 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.equinox.launcher;
+
+import static java.lang.System.currentTimeMillis;
+import static java.lang.System.setProperty;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.GATEWAY_BUNDLE;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.LAUNCHER_EQUINOX_LIBRARIES;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.artifactId;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.bundleName;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.file;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.fixupBundle;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.jarVersion;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.runtimeClasspathEntries;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.string;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.thirdPartyLibraryBundle;
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.thisBundleLocation;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.UUID;
+import java.util.jar.Manifest;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * Wraps the Equinox runtime.
+ */
+public class EquinoxHost {
+ static final String PROP_OSGI_CONTEXT_CLASS_LOADER_PARENT = "osgi.contextClassLoaderParent";
+
+ static final String PROP_OSGI_CLEAN = "osgi.clean";
+
+ static final String PROP_USER_NAME = "user.name";
+
+ private static Logger logger = Logger.getLogger(EquinoxHost.class.getName());
+
+ static final String PROP_INSTALL_AREA = "osgi.install.area";
+ static final String PROP_CONFIG_AREA = "osgi.configuration.area";
+ static final String PROP_CONFIG_AREA_DEFAULT = "osgi.configuration.area.default";
+ static final String PROP_SHARED_CONFIG_AREA = "osgi.sharedConfiguration.area";
+ static final String PROP_INSTANCE_AREA = "osgi.instance.area";
+ static final String PROP_INSTANCE_AREA_DEFAULT = "osgi.instance.area.default";
+ static final String PROP_USER_AREA = "osgi.user.area";
+ static final String PROP_USER_AREA_DEFAULT = "osgi.user.area.default";
+
+ /**
+ * If the class is loaded inside OSGi, then the bundle context will be injected by the activator
+ */
+ static BundleContext injectedBundleContext;
+
+ static {
+ if (getSystemProperty("osgi.debug") != null) {
+ logger.setLevel(Level.FINE);
+ }
+ }
+
+ private BundleContext bundleContext;
+ private Bundle launcherBundle;
+ private List<URL> bundleFiles = new ArrayList<URL>();
+ private List<String> bundleNames = new ArrayList<String>();
+ private Map<URL, Manifest> jarFiles = new HashMap<URL, Manifest>();
+ private Map<String, Bundle> allBundles = new HashMap<String, Bundle>();
+ private List<Bundle> installedBundles = new ArrayList<Bundle>();
+
+ private Set<URL> bundleLocations;
+ private boolean aggregateThirdPartyJars = false;
+
+ private FrameworkLauncher frameworkLauncher = new FrameworkLauncher();
+ private Framework framework;
+
+ public EquinoxHost() {
+ super();
+ }
+
+ public EquinoxHost(Set<URL> urls) {
+ super();
+ this.bundleLocations = urls;
+ }
+
+ private static String getSystemProperty(final String name) {
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(name);
+ }
+ });
+ }
+
+ private static Properties getSystemProperties() {
+ return AccessController.doPrivileged(new PrivilegedAction<Properties>() {
+ public Properties run() {
+ Properties props = new Properties();
+ for (Map.Entry<Object, Object> e : System.getProperties().entrySet()) {
+ if (e.getKey() instanceof String) {
+ String prop = (String)e.getKey();
+ if (prop.startsWith("osgi.") || prop.startsWith("eclipse.")) {
+ props.put(prop, e.getValue());
+ }
+ }
+ }
+ return props;
+ }
+ });
+ }
+
+ private static void put(Properties props, String key, String value) {
+ if (!props.contains(key)) {
+ props.put(key, value);
+ }
+ }
+
+
+ /**
+ * Search for org/apache/tuscany/sca/node/equinox/launcher for customized MANIFEST.MF
+ * for a given artifact. For example, a-1.0.MF for a-1.0.jar.
+ *
+ * @param fileName
+ * @return
+ * @throws IOException
+ */
+ private Manifest getCustomizedMF(String fileName) throws IOException {
+ int index = fileName.lastIndexOf('.');
+ if (index == -1) {
+ return null;
+ }
+ String mf = fileName.substring(0, index) + ".MF";
+ InputStream is = getClass().getResourceAsStream(mf);
+ if (is == null) {
+ return null;
+ } else {
+ try {
+ Manifest manifest = new Manifest(is);
+ return manifest;
+ } finally {
+ is.close();
+ }
+ }
+ }
+
+ /**
+ * Start the Equinox host.
+ *
+ * @return
+ */
+ public BundleContext start() {
+ try {
+ if (injectedBundleContext == null) {
+
+ Properties props = configureProperties();
+ startFramework(props);
+
+ } else {
+
+ // Get bundle context from the running Eclipse instance
+ bundleContext = injectedBundleContext;
+ }
+
+ // Determine the runtime classpath entries
+ Set<URL> urls;
+ urls = findBundleLocations();
+
+ // Sort out which are bundles (and not already installed) and which are just
+ // regular JARs
+ for (URL url : urls) {
+ File file = file(url);
+
+ Manifest manifest = getCustomizedMF(file.getName());
+ String bundleName = null;
+ if (manifest == null) {
+ bundleName = bundleName(file);
+ } else {
+ if (manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME) == null) {
+ manifest = null;
+ }
+ }
+ if (bundleName != null) {
+ bundleFiles.add(url);
+ bundleNames.add(bundleName);
+ } else {
+ if (file.isFile()) {
+ jarFiles.put(url, manifest);
+ }
+ }
+ }
+
+ // Get the already installed bundles
+ for (Bundle bundle : bundleContext.getBundles()) {
+ allBundles.put(bundle.getSymbolicName(), bundle);
+ }
+
+ // Install the launcher bundle if necessary
+ String launcherBundleName = "org.apache.tuscany.sca.node.launcher.equinox";
+ String launcherBundleLocation;
+ launcherBundle = allBundles.get(launcherBundleName);
+ if (launcherBundle == null) {
+ launcherBundleLocation = thisBundleLocation();
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Installing launcher bundle: " + launcherBundleLocation);
+ }
+ fixupBundle(launcherBundleLocation);
+ launcherBundle = bundleContext.installBundle(launcherBundleLocation);
+ allBundles.put(launcherBundleName, launcherBundle);
+ installedBundles.add(launcherBundle);
+ } else {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Launcher bundle is already installed: " + string(launcherBundle, false));
+ }
+ // launcherBundleLocation = thisBundleLocation(launcherBundle);
+ }
+
+ // FIXME: SDO bundles dont have the correct dependencies
+ setProperty("commonj.sdo.impl.HelperProvider", "org.apache.tuscany.sdo.helper.HelperProviderImpl");
+
+ // Install the Tuscany bundles
+ long start = currentTimeMillis();
+
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Generating third-party library bundle.");
+ }
+
+ logger.info("Checking for manfiests customized by Tuscany in node-launcher-equinox/resources");
+
+ long libraryStart = currentTimeMillis();
+
+ Set<String> serviceProviders = new HashSet<String>();
+ if (!aggregateThirdPartyJars) {
+ for (Map.Entry<URL, Manifest> entry : jarFiles.entrySet()) {
+ URL jarFile = entry.getKey();
+ Manifest manifest = entry.getValue();
+ Bundle bundle = null;
+ if (manifest == null) {
+ bundle = installAsBundle(jarFile, null);
+ } else {
+ bundle = installAsBundle(Collections.singleton(jarFile), manifest);
+ }
+ isServiceProvider(bundle, serviceProviders);
+ }
+ } else {
+ Bundle bundle = installAsBundle(jarFiles.keySet(), LAUNCHER_EQUINOX_LIBRARIES);
+ isServiceProvider(bundle, serviceProviders);
+ }
+
+ installGatewayBundle(serviceProviders);
+
+ if (logger.isLoggable(Level.FINE)) {
+ logger
+ .fine("Third-party library bundle installed in " + (currentTimeMillis() - libraryStart) + " ms: ");
+ }
+
+ // Install all the other bundles that are not already installed
+ for (URL bundleFile : bundleFiles) {
+ fixupBundle(bundleFile.toString());
+ }
+ for (int i = 0, n = bundleFiles.size(); i < n; i++) {
+ URL bundleFile = bundleFiles.get(i);
+ String bundleName = bundleNames.get(i);
+ if (bundleName.contains("org.eclipse.jdt.junit") || bundleName.contains("org.apache.tuscany.sca.base")) {
+ continue;
+ }
+ installBundle(bundleFile, bundleName);
+ }
+
+ long end = currentTimeMillis();
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Tuscany bundles are installed in " + (end - start) + " ms.");
+ }
+
+ // Start the extensiblity and launcher bundles
+ String extensibilityBundleName = "org.apache.tuscany.sca.extensibility.equinox";
+ Bundle extensibilityBundle = allBundles.get(extensibilityBundleName);
+ if (extensibilityBundle != null) {
+ if ((extensibilityBundle.getState() & Bundle.ACTIVE) == 0) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Starting bundle: " + string(extensibilityBundle, false));
+ }
+ extensibilityBundle.start();
+ } else if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Bundle is already started: " + string(extensibilityBundle, false));
+ }
+ }
+ if ((launcherBundle.getState() & Bundle.ACTIVE) == 0) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Starting bundle: " + string(launcherBundle, false));
+ }
+ launcherBundle.start();
+ } else if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Bundle is already started: " + string(launcherBundle, false));
+ }
+
+ // Start all our bundles for now to help diagnose any class loading issues
+ // startBundles( bundleContext );
+ return bundleContext;
+
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ protected Properties configureProperties() throws IOException, FileNotFoundException {
+ String version = getSystemProperty("java.specification.version");
+
+ /**
+ * [rfeng] I have to remove javax.transaction.* packages from the system bundle
+ * See: http://www.mail-archive.com/dev@geronimo.apache.org/msg70761.html
+ */
+ String profile = "J2SE-1.5.profile";
+ if (version.startsWith("1.6")) {
+ profile = "JavaSE-1.6.profile";
+ }
+ Properties props = new Properties();
+ InputStream is = getClass().getResourceAsStream(profile);
+ if (is != null) {
+ props.load(is);
+ is.close();
+ }
+
+ props.putAll(getSystemProperties());
+
+ // Configure Eclipse properties
+
+ // Use the boot classloader as the parent classloader
+ put(props, PROP_OSGI_CONTEXT_CLASS_LOADER_PARENT, "app");
+
+ // Set startup properties
+ put(props, PROP_OSGI_CLEAN, "true");
+
+ // Set location properties
+ // FIXME Use proper locations
+ String tmpDir = getSystemProperty("java.io.tmpdir");
+ File root = new File(tmpDir);
+ // Add user name as the prefix. For multiple users on the same Lunix,
+ // there will be permission issue if one user creates the .tuscany folder
+ // first under /tmp with no write permission for others.
+ String userName = getSystemProperty(PROP_USER_NAME);
+ if (userName != null) {
+ root = new File(root, userName);
+ }
+ root = new File(root, ".tuscany/equinox/" + UUID.randomUUID().toString());
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Equinox location: " + root);
+ }
+
+ put(props, PROP_INSTANCE_AREA_DEFAULT, new File(root, "workspace").toURI().toString());
+ put(props, PROP_INSTALL_AREA, new File(root, "install").toURI().toString());
+ put(props, PROP_CONFIG_AREA_DEFAULT, new File(root, "config").toURI().toString());
+ put(props, PROP_USER_AREA_DEFAULT, new File(root, "user").toURI().toString());
+
+ // Test if the configuration/config.ini or osgi.bundles has been set
+ // If yes, try to avoid discovery of bundles
+ if (bundleLocations == null) {
+ if (props.getProperty("osgi.bundles") != null) {
+ bundleLocations = Collections.emptySet();
+ } else {
+ String config = props.getProperty(PROP_CONFIG_AREA);
+ File ini = new File(config, "config.ini");
+ if (ini.isFile()) {
+ Properties iniProps = new Properties();
+ iniProps.load(new FileInputStream(ini));
+ if (iniProps.getProperty("osgi.bundles") != null) {
+ bundleLocations = Collections.emptySet();
+ }
+ }
+ }
+ }
+ return props;
+ }
+
+ private boolean isServiceProvider(Bundle bundle, Set<String> serviceProviders) {
+ if (bundle != null) {
+ String export = (String)bundle.getHeaders().get(Constants.EXPORT_PACKAGE);
+ if (export != null && export.contains(NodeLauncherUtil.META_INF_SERVICES)) {
+ serviceProviders.add(bundle.getSymbolicName());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void installGatewayBundle(Set<String> bundles) throws IOException, BundleException {
+ if (allBundles.containsKey(GATEWAY_BUNDLE)) {
+ return;
+ }
+ if (bundles == null) {
+ bundles = allBundles.keySet();
+ }
+ InputStream gateway = NodeLauncherUtil.generateGatewayBundle(bundles, null, false);
+ if (gateway != null) {
+ Bundle gatewayBundle = bundleContext.installBundle(GATEWAY_BUNDLE, gateway);
+ allBundles.put(NodeLauncherUtil.GATEWAY_BUNDLE, gatewayBundle);
+ installedBundles.add(gatewayBundle);
+ }
+ }
+
+ /**
+ * Start all the bundles as a check for class loading issues
+ * @param bundleContext - the bundle context
+ */
+ private void startBundles(BundleContext bundleContext) {
+
+ for (Bundle bundle : bundleContext.getBundles()) {
+ // if (bundle.getSymbolicName().startsWith("org.apache.tuscany.sca")) {
+ if ((bundle.getState() & Bundle.ACTIVE) == 0) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Starting bundle: " + string(bundle, false));
+ } // end if
+ try {
+ bundle.start();
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ // throw e;
+ } // end try
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Bundle: " + string(bundle, false));
+ } // end if
+ } // end if
+ // } // end if
+ } // end for
+ logger.fine("Tuscany bundles are started.");
+ return;
+ } // end startBundles
+
+ public Bundle installAsBundle(Collection<URL> jarFiles, String libraryBundleName) throws IOException,
+ BundleException {
+ // Install a single 'library' bundle for the third-party JAR files
+ Bundle libraryBundle = allBundles.get(libraryBundleName);
+ if (libraryBundle == null) {
+ InputStream library = thirdPartyLibraryBundle(jarFiles, libraryBundleName, null);
+ libraryBundle = bundleContext.installBundle(libraryBundleName, library);
+ allBundles.put(libraryBundleName, libraryBundle);
+ installedBundles.add(libraryBundle);
+ } else {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Third-party library bundle is already installed: " + string(libraryBundle, false));
+ }
+ }
+ return libraryBundle;
+ }
+
+ public Bundle installAsBundle(Collection<URL> jarFiles, Manifest manifest) throws IOException, BundleException {
+ String bundleName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+
+ // Install a single 'library' bundle for the third-party JAR files
+ Bundle libraryBundle = allBundles.get(bundleName);
+ if (libraryBundle == null) {
+ InputStream library = thirdPartyLibraryBundle(jarFiles, manifest);
+ libraryBundle = bundleContext.installBundle(bundleName, library);
+ allBundles.put(bundleName, libraryBundle);
+ installedBundles.add(libraryBundle);
+ } else {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Third-party library bundle is already installed: " + string(libraryBundle, false));
+ }
+ }
+ return libraryBundle;
+ }
+
+ public Bundle installBundle(URL bundleFile, String bundleName) throws MalformedURLException, BundleException {
+ if (bundleName == null) {
+ try {
+ bundleName = bundleName(file(bundleFile));
+ } catch (IOException e) {
+ bundleName = null;
+ }
+ }
+ Bundle bundle = allBundles.get(bundleName);
+ if (bundle == null) {
+ long installStart = currentTimeMillis();
+ String location = bundleFile.toString();
+ if (frameworkLauncher.isEquinox() && "file".equals(bundleFile.getProtocol())) {
+ File target = file(bundleFile);
+ // Use a special "reference" scheme to install the bundle as a reference
+ // instead of copying the bundle
+ location = "reference:file:/" + target.getPath();
+ }
+ bundle = bundleContext.installBundle(location);
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Bundle installed in " + (currentTimeMillis() - installStart)
+ + " ms: "
+ + string(bundle, false));
+ }
+ allBundles.put(bundleName, bundle);
+ installedBundles.add(bundle);
+ }
+ return bundle;
+ }
+
+ public Bundle installAsBundle(URL jarFile, String symbolicName) throws IOException, BundleException {
+ if (symbolicName == null) {
+ symbolicName = LAUNCHER_EQUINOX_LIBRARIES + "." + artifactId(jarFile);
+ }
+ Bundle bundle = allBundles.get(symbolicName);
+ if (bundle == null) {
+ String version = jarVersion(jarFile);
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Installing third-party jar as bundle: " + jarFile);
+ }
+ InputStream is = thirdPartyLibraryBundle(Collections.singleton(jarFile), symbolicName, version);
+ // try/catch and output message added 10/04/2009 Mike Edwards
+ try {
+ bundle = bundleContext.installBundle(symbolicName, is);
+ allBundles.put(symbolicName, bundle);
+ installedBundles.add(bundle);
+ } catch (BundleException e) {
+ System.out
+ .println("EquinoxHost:installAsBundle - BundleException raised when dealing with jar " + symbolicName);
+ throw (e);
+ } // end try
+ // end of addition
+ }
+ return bundle;
+ }
+
+ private Set<URL> findBundleLocations() throws FileNotFoundException, URISyntaxException, MalformedURLException {
+ if (bundleLocations == null ||
+ (bundleLocations != null && bundleLocations.size() == 0)) {
+ if (injectedBundleContext != null) {
+ // Use classpath entries from a distribution if there is one and the modules
+ // directories available in a dev environment for example
+ bundleLocations = runtimeClasspathEntries(true, false, true);
+ } else {
+ // Use classpath entries from a distribution if there is one and the classpath
+ // entries on the current application's classloader
+ // *** Changed by Mike Edwards, 9th April 2009 ***
+ // -- this place is reached when starting from within Eclipse so why use the classpath??
+ // bundleLocations = runtimeClasspathEntries(true, true, false);
+ // Instead search the modules directory
+ bundleLocations = runtimeClasspathEntries(true, true, true);
+ }
+ }
+ return bundleLocations;
+ }
+
+ /**
+ * Stop the Equinox host.
+ */
+ public void stop() {
+ try {
+
+ // Uninstall all the bundles we've installed
+ for (int i = installedBundles.size() - 1; i >= 0; i--) {
+ Bundle bundle = installedBundles.get(i);
+ try {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Uninstalling bundle: " + string(bundle, false));
+ }
+ bundle.uninstall();
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ installedBundles.clear();
+
+ stopFramework();
+
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /*
+ private void startFramework(Properties props) throws Exception {
+ EclipseStarter.setInitialProperties(props);
+
+ // Test if the configuration/config.ini or osgi.bundles has been set
+ // If yes, try to avoid discovery of bundles
+ if (bundleLocations == null) {
+ if (props.getProperty("osgi.bundles") != null) {
+ bundleLocations = Collections.emptySet();
+ } else {
+ String config = props.getProperty(PROP_CONFIG_AREA);
+ File ini = new File(config, "config.ini");
+ if (ini.isFile()) {
+ Properties iniProps = new Properties();
+ iniProps.load(new FileInputStream(ini));
+ if (iniProps.getProperty("osgi.bundles") != null) {
+ bundleLocations = Collections.emptySet();
+ }
+ }
+ }
+ }
+
+ // Start Eclipse
+ bundleContext = EclipseStarter.startup(new String[] {}, null);
+ }
+
+ private void stopFramework() throws Exception {
+ // Shutdown Eclipse if we started it ourselves
+ if (injectedBundleContext == null) {
+ EclipseStarter.shutdown();
+ }
+ }
+ */
+
+ private void startFramework(Map configuration) throws Exception {
+ if (framework != null) {
+ throw new IllegalStateException("The OSGi framework has been started");
+ }
+ framework = frameworkLauncher.newFramework(configuration);
+ framework.start();
+ this.bundleContext = framework.getBundleContext();
+ }
+
+ private void stopFramework() throws Exception {
+ // Shutdown Eclipse if we started it ourselves
+ if (injectedBundleContext == null) {
+ framework.stop();
+ framework.waitForStop(5000);
+ framework = null;
+ bundleContext = null;
+ }
+ }
+
+
+ public void setBundleLocations(Set<URL> bundleLocations) {
+ this.bundleLocations = bundleLocations;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/FrameworkLauncher.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/FrameworkLauncher.java
new file mode 100644
index 0000000000..414f3aae63
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/FrameworkLauncher.java
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.equinox.launcher;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Launcher for the OSGi framework using the framework launch APIs
+ */
+public class FrameworkLauncher implements BundleActivator {
+ private static final String FACTORY_RESOURCE = "META-INF/services/" + FrameworkFactory.class.getName();
+
+ private static final Logger logger = Logger.getLogger(FrameworkLauncher.class.getName());
+
+ private FrameworkFactory factory;
+ private boolean isEquinox;
+
+ @SuppressWarnings("unchecked")
+ private synchronized FrameworkFactory loadFrameworkFactory() {
+ if (factory == null) {
+ try {
+ ClassLoader classLoader = FrameworkFactory.class.getClassLoader();
+ InputStream is = classLoader.getResourceAsStream(FACTORY_RESOURCE);
+ if (is == null) {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ is = classLoader.getResourceAsStream(FACTORY_RESOURCE);
+ }
+ if (is == null) {
+ return null;
+ }
+ BufferedReader reader = null;
+ String line = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ while (true) {
+ line = reader.readLine();
+ if (line == null)
+ break;
+ line = line.trim();
+ if (!line.startsWith("#") && !"".equals(line)) {
+ break;
+ }
+ }
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ if (line != null) {
+ Class<? extends FrameworkFactory> factoryImplClass =
+ (Class<? extends FrameworkFactory>)Class.forName(line, false, classLoader);
+ factory = factoryImplClass.newInstance();
+ if (factory != null && factory.getClass().getName().startsWith("org.eclipse.osgi.")) {
+ isEquinox = true;
+ }
+
+ }
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ return factory;
+ }
+
+ public Framework newFramework(Map properties) {
+ FrameworkFactory factory = loadFrameworkFactory();
+ if (factory == null) {
+ return null;
+ }
+ String propertyFile = null;
+ String factoryName = factory.getClass().getName();
+ if (factoryName.startsWith("org.eclipse.osgi.")) {
+ propertyFile = "equinox.properties";
+ } else if (factoryName.startsWith("org.apache.felix.")) {
+ propertyFile = "felix.properties";
+ }
+ Map propMap = new HashMap();
+ if (propertyFile != null) {
+ InputStream is = getClass().getResourceAsStream(propertyFile);
+ if (is != null) {
+ Properties props = new Properties();
+ try {
+ props.load(is);
+ } catch (IOException e) {
+ logger.log(Level.WARNING, e.getMessage(), e);
+ }
+ propMap.putAll(props);
+ }
+ }
+ propMap.putAll(properties);
+ return factory.newFramework(propMap);
+ }
+
+ public boolean isEquinox() {
+ return isEquinox;
+ }
+
+ public void start(BundleContext context) throws Exception {
+ EquinoxHost.injectedBundleContext = context;
+ if (context.getClass().getName().startsWith("org.eclipse.osgi.")) {
+ isEquinox = true;
+ try {
+ context.registerService(CommandProvider.class.getName(), new NodeLauncherCommand(), new Hashtable());
+ } catch (NoClassDefFoundError e) {
+ // Ignore it
+ }
+ }
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ EquinoxHost.injectedBundleContext = null;
+ }
+
+ private static final String DELIM_START = "${";
+ private static final String DELIM_STOP = "}";
+
+ /**
+ * <p>
+ * This method performs property variable substitution on the
+ * specified value. If the specified value contains the syntax
+ * <tt>${&lt;prop-name&gt;}</tt>, where <tt>&lt;prop-name&gt;</tt>
+ * refers to either a configuration property or a system property,
+ * then the corresponding property value is substituted for the variable
+ * placeholder. Multiple variable placeholders may exist in the
+ * specified value as well as nested variable placeholders, which
+ * are substituted from inner most to outer most. Configuration
+ * properties override system properties.
+ * </p>
+ * @param val The string on which to perform property substitution.
+ * @param currentKey The key of the property being evaluated used to
+ * detect cycles.
+ * @param cycleMap Map of variable references used to detect nested cycles.
+ * @param configProps Set of configuration properties.
+ * @return The value of the specified string after system property substitution.
+ * @throws IllegalArgumentException If there was a syntax error in the
+ * property placeholder syntax or a recursive variable reference.
+ **/
+ public static String substVars(String val, String currentKey, Map cycleMap, Properties configProps)
+ throws IllegalArgumentException {
+ // If there is currently no cycle map, then create
+ // one for detecting cycles for this invocation.
+ if (cycleMap == null) {
+ cycleMap = new HashMap();
+ }
+
+ // Put the current key in the cycle map.
+ cycleMap.put(currentKey, currentKey);
+
+ // Assume we have a value that is something like:
+ // "leading ${foo.${bar}} middle ${baz} trailing"
+
+ // Find the first ending '}' variable delimiter, which
+ // will correspond to the first deepest nested variable
+ // placeholder.
+ int stopDelim = val.indexOf(DELIM_STOP);
+
+ // Find the matching starting "${" variable delimiter
+ // by looping until we find a start delimiter that is
+ // greater than the stop delimiter we have found.
+ int startDelim = val.indexOf(DELIM_START);
+ while (stopDelim >= 0) {
+ int idx = val.indexOf(DELIM_START, startDelim + DELIM_START.length());
+ if ((idx < 0) || (idx > stopDelim)) {
+ break;
+ } else if (idx < stopDelim) {
+ startDelim = idx;
+ }
+ }
+
+ // If we do not have a start or stop delimiter, then just
+ // return the existing value.
+ if ((startDelim < 0) && (stopDelim < 0)) {
+ return val;
+ }
+ // At this point, we found a stop delimiter without a start,
+ // so throw an exception.
+ else if (((startDelim < 0) || (startDelim > stopDelim)) && (stopDelim >= 0)) {
+ throw new IllegalArgumentException("stop delimiter with no start delimiter: " + val);
+ }
+
+ // At this point, we have found a variable placeholder so
+ // we must perform a variable substitution on it.
+ // Using the start and stop delimiter indices, extract
+ // the first, deepest nested variable placeholder.
+ String variable = val.substring(startDelim + DELIM_START.length(), stopDelim);
+
+ // Verify that this is not a recursive variable reference.
+ if (cycleMap.get(variable) != null) {
+ throw new IllegalArgumentException("recursive variable reference: " + variable);
+ }
+
+ // Get the value of the deepest nested variable placeholder.
+ // Try to configuration properties first.
+ String substValue = (configProps != null) ? configProps.getProperty(variable, null) : null;
+ if (substValue == null) {
+ // Ignore unknown property values.
+ substValue = System.getProperty(variable, "");
+ }
+
+ // Remove the found variable from the cycle map, since
+ // it may appear more than once in the value and we don't
+ // want such situations to appear as a recursive reference.
+ cycleMap.remove(variable);
+
+ // Append the leading characters, the substituted value of
+ // the variable, and the trailing characters to get the new
+ // value.
+ val = val.substring(0, startDelim) + substValue + val.substring(stopDelim + DELIM_STOP.length(), val.length());
+
+ // Now perform substitution again, since there could still
+ // be substitutions to make.
+ val = substVars(val, currentKey, cycleMap, configProps);
+
+ // Return the value.
+ return val;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java
new file mode 100644
index 0000000000..b9bb70b5d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.node.equinox.launcher;
+
+
+/**
+ * Denotes an error launching an SCA domain manager or node.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LauncherException extends Exception {
+ private static final long serialVersionUID = 4581189418849190567L;
+
+ public LauncherException() {
+ super();
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public LauncherException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ */
+ public LauncherException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public LauncherException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java
new file mode 100644
index 0000000000..aeb29c0789
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.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.sca.node.equinox.launcher;
+
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.nodeDaemon;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * A launcher for the SCA Node daemon.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeDaemonLauncher {
+
+ static final Logger logger = Logger.getLogger(NodeDaemonLauncher.class.getName());
+
+ /**
+ * Constructs a new node daemon launcher.
+ */
+ private NodeDaemonLauncher() {
+ }
+
+ /**
+ * Returns a new launcher instance.
+ *
+ * @return a new launcher instance
+ */
+ public static NodeDaemonLauncher newInstance() {
+ return new NodeDaemonLauncher();
+ }
+
+ /**
+ * Creates a new node daemon.
+ *
+ * @param
+ * @return a new node daemon
+ * @throws LauncherException
+ */
+ public <T> T createNodeDaemon() throws LauncherException {
+ return (T)nodeDaemon();
+ }
+
+ public static void main(String[] args) throws Exception {
+ logger.info("Apache Tuscany SCA Node Daemon is starting...");
+
+ // Create a node launcher
+ NodeDaemonLauncher launcher = newInstance();
+
+ EquinoxHost equinox = null;
+ Object node = null;
+ ShutdownThread shutdown = null;
+ try {
+
+ // Start the OSGi host
+ equinox = new EquinoxHost();
+ equinox.start();
+
+ // Start the node
+ node = launcher.createNodeDaemon();
+ try {
+ node.getClass().getMethod("start").invoke(node);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node Daemon could not be started", e);
+ throw e;
+ }
+ logger.info("SCA Node Daemon is now started.");
+
+ // Install a shutdown hook
+ shutdown = new ShutdownThread(node, equinox);
+ Runtime.getRuntime().addShutdownHook(shutdown);
+
+ logger.info("Press enter to shutdown.");
+ try {
+ System.in.read();
+ } catch (IOException e) {
+
+ // Wait forever
+ Object lock = new Object();
+ synchronized(lock) {
+ lock.wait();
+ }
+ }
+ } finally {
+
+ // Remove the shutdown hook
+ if (shutdown != null) {
+ Runtime.getRuntime().removeShutdownHook(shutdown);
+ }
+
+ // Stop the node
+ if (node != null) {
+ stopNode(node);
+ }
+ if (equinox != null) {
+ equinox.stop();
+ }
+ }
+ }
+
+ /**
+ * Stop the given node.
+ *
+ * @param node
+ * @throws Exception
+ */
+ private static void stopNode(Object node) throws Exception {
+ try {
+ node.getClass().getMethod("stop").invoke(node);
+ logger.info("SCA Node Daemon is now stopped.");
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node Daemon could not be stopped", e);
+ throw e;
+ }
+ }
+
+ private static class ShutdownThread extends Thread {
+ private Object node;
+ private EquinoxHost equinox;
+
+ public ShutdownThread(Object node, EquinoxHost equinox) {
+ super();
+ this.node = node;
+ this.equinox = equinox;
+ }
+
+ @Override
+ public void run() {
+ try {
+ stopNode(node);
+ } catch (Exception e) {
+ // Ignore
+ }
+ try {
+ equinox.stop();
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
new file mode 100644
index 0000000000..678d88dab7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
@@ -0,0 +1,375 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.equinox.launcher;
+
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.node;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A launcher for SCA nodes.
+ *
+ * Agruments:
+ * [-config <equinoxConfiguration>]: The configuration folder for Equinox
+ * [-bundles <osgiBundles>]: A list of bundles to be installed
+ * [-c <compositeURI>]: The composite URI
+ * [-t <ttl>]: Time to live in milliseconds before the node is started
+ * contribution1 ... contributionN: A list of contribution files or URLs
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeLauncher {
+
+ static final Logger logger = Logger.getLogger(NodeLauncher.class.getName());
+ private EquinoxHost equinoxHost;
+ private BundleContext bundleContext;
+
+ /**
+ * Constructs a new node launcher.
+ */
+ private NodeLauncher() {
+ equinoxHost = new EquinoxHost();
+ bundleContext = equinoxHost.start();
+ }
+
+ /**
+ * Returns a new launcher instance.
+ *
+ * @return a new launcher instance
+ */
+ public static NodeLauncher newInstance() {
+ return new NodeLauncher();
+ }
+
+ /**
+ * Creates a new SCA node from the configuration URL
+ *
+ * @param configurationURL the URL of the node configuration which is the ATOM feed
+ * that contains the URI of the composite and a collection of URLs for the contributions
+ *
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNode(String configurationURL) throws LauncherException {
+ return (T)node(configurationURL, null, null, null, bundleContext);
+ }
+
+ /**
+ * Creates a new SCA OSGi Node.
+ *
+ * @param compositeURI the URI of the composite to use
+ * @param contributions the URI of the contributions that provides the composites and related
+ * artifacts. If the list is empty, then we will use the thread context classloader to discover
+ * the contribution on the classpath
+ *
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNode(String compositeURI, Contribution... contributions) throws LauncherException {
+ return (T)node(null, compositeURI, null, contributions, bundleContext);
+ }
+
+ /**
+ * Creates a new SCA OSGi Node.
+ *
+ * @param compositeURI the URI of the composite to use
+ * @param compositeContent the XML content of the composite to use
+ * @param contributions the URI of the contributions that provides the composites and related artifacts
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNode(String compositeURI, String compositeContent, Contribution... contributions)
+ throws LauncherException {
+ return (T)node(null, compositeURI, compositeContent, contributions, bundleContext);
+ }
+
+ public static void main(String[] args) throws Exception {
+ CommandLineParser parser = new PosixParser();
+ Options options = getCommandLineOptions();
+ CommandLine cli = parser.parse(options, args);
+
+ Object node = null;
+ ShutdownThread shutdown = null;
+ EquinoxHost equinox = null;
+ try {
+
+ if (cli.hasOption("config")) {
+ System.setProperty("osgi.configuration.area", cli.getOptionValue("config"));
+ }
+
+ while (true) {
+ if (cli.hasOption("node")) {
+ // Create a node from a configuration URI
+ String configurationURI = cli.getOptionValue("node");
+ logger.info("SCA Node configuration: " + configurationURI);
+
+ // Create a node launcher
+ NodeLauncher launcher = newInstance();
+ equinox = launcher.equinoxHost;
+
+ node = launcher.createNode(configurationURI);
+ }
+ else if (cli.hasOption("bundles")) {
+ /**
+ * osgi.bundles
+ * The comma-separated list of bundles which are automatically installed and optionally started once the system is up
+ * and running. Each entry is of the form:
+ * <URL | simple bundle location>[@ [<start-level>] [":start"]]
+ * If the start-level (>0 integer) is omitted then the framework will use the default start level for the bundle.
+ * If the "start" tag is added then the bundle will be marked as started after being installed. Simple bundle locations are
+ * interepreted as relative to the framework's parent directory. The start-level indicates the OSGi start level at which the
+ * bundle should run. If this value is not set, the system computes an appropriate default.
+ */
+ String bundles = cli.getOptionValue("bundles");
+ if (bundles != null) {
+ System.setProperty("osgi.bundles", cli.getOptionValue("bundles"));
+ }
+
+ // Create a node launcher
+ NodeLauncher launcher = newInstance();
+ equinox = launcher.equinoxHost;
+
+ /*
+ List<String> bundleFiles = cli.getArgList();
+ for (String bf : bundleFiles) {
+ File f = new File(bf);
+ equinox.installBundle(f.toURI().toURL(), null);
+ }
+ for (Bundle b : launcher.bundleContext.getBundles()) {
+ try {
+ if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) {
+ // Start the non-fragment bundle
+ b.start();
+ }
+ } catch (Exception e) {
+ logger.severe(NodeLauncherUtil.string(b, false) + " " + e.getMessage());
+ // logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ */
+
+ }
+ else {
+ // Create a node from a composite URI and a contribution location
+ String compositeURI = cli.getOptionValue("composite");
+ List<String> contribs = cli.getArgList();
+ Contribution[] contributions = null;
+ if (!contribs.isEmpty()) {
+ contributions = new Contribution[contribs.size()];
+ int index = 0;
+ for (String contrib : contribs) {
+ logger.info("SCA contribution: " + contrib);
+ URL url = null;
+ try {
+ url = new URL(contrib);
+ } catch (MalformedURLException e) {
+ url = new File(contrib).toURI().toURL();
+ }
+ contributions[index] = new Contribution("contribution-" + index, url.toString());
+ index++;
+ }
+ } else {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.setSyntaxPrefix("Usage: ");
+ formatter.printHelp("java " + NodeLauncher.class.getName()
+ + " [-config <equinoxConfiguration>]"
+ + " [-c <compositeURI>]"
+ + " [-b <bundles>]"
+ + " [-t <ttl>]"
+ + " contribution1 ... contributionN", options);
+ return;
+ }
+ // Create a node launcher
+ logger.info("SCA composite: " + compositeURI);
+ NodeLauncher launcher = newInstance();
+ equinox = launcher.equinoxHost;
+ node = launcher.createNode(compositeURI, contributions);
+ }
+
+ if (node != null) {
+ logger.info("Apache Tuscany SCA Node is starting...");
+
+ // Start the node
+ try {
+ node.getClass().getMethod("start").invoke(node);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node could not be started", e);
+ throw e;
+ }
+ logger.info("SCA Node is now started.");
+ }
+ // Install a shutdown hook
+ shutdown = new ShutdownThread(node, equinox);
+ Runtime.getRuntime().addShutdownHook(shutdown);
+
+ long ttl = Long.parseLong(cli.getOptionValue("ttl", "-1"));
+ if (ttl >= 0) {
+ logger.info("Waiting for " + ttl + " milliseconds ...");
+ Thread.sleep(ttl);
+ break; // Exit
+ }
+
+ // Wait until the "Enter" is pressed
+ logger.info("Press 'q' to quit, 'r' to restart.");
+ int k = 0;
+ try {
+ while ((k != 'q') && (k != 'r')) {
+ k = System.in.read();
+ }
+ } catch (IOException e) {
+
+ // Wait forever
+ Object lock = new Object();
+ synchronized (lock) {
+ lock.wait();
+ }
+ }
+
+ // Stop the node
+ if (node != null) {
+ Object n = node;
+ node = null;
+ stopNode(n);
+ }
+
+ // Quit
+ if (k == 'q') {
+ break;
+ }
+
+ }
+ } finally {
+
+ // Remove the shutdown hook
+ if (shutdown != null) {
+ Runtime.getRuntime().removeShutdownHook(shutdown);
+ }
+
+ // Stop the node
+ if (node != null) {
+ destroyNode(node);
+ }
+ if (equinox != null) {
+ equinox.stop();
+ }
+ }
+ }
+
+ static Options getCommandLineOptions() {
+ Options options = new Options();
+ Option opt1 = new Option("c", "composite", true, "URI for the composite");
+ opt1.setArgName("compositeURI");
+ options.addOption(opt1);
+ Option opt2 = new Option("n", "node", true, "URI for the node configuration");
+ opt2.setArgName("nodeConfigurationURI");
+ options.addOption(opt2);
+ Option opt3 = new Option("config", "configuration", true, "Configuration");
+ opt3.setArgName("equinoxConfiguration");
+ options.addOption(opt3);
+ Option opt4 = new Option("t", "ttl", true, "Time to live");
+ opt4.setArgName("timeToLiveInMilliseconds");
+ // opt4.setType(long.class);
+ options.addOption(opt4);
+
+ Option opt5 = new Option("b", "bundles", false, "OSGi bundles");
+ opt4.setArgName("osgiBundles");
+ options.addOption(opt5);
+
+ return options;
+ }
+
+ public void destroy() {
+ if (equinoxHost != null) {
+ equinoxHost.stop();
+ bundleContext = null;
+ }
+ }
+
+ /**
+ * Stop the given node.
+ *
+ * @param node
+ * @throws Exception
+ */
+ private static void destroyNode(Object node) throws Exception {
+ try {
+ node.getClass().getMethod("stop").invoke(node);
+ logger.info("SCA Node is now stopped.");
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node could not be stopped", e);
+ throw e;
+ }
+ }
+
+ private static class ShutdownThread extends Thread {
+ private Object node;
+ private EquinoxHost equinox;
+
+ public ShutdownThread(Object node, EquinoxHost equinox) {
+ super();
+ this.node = node;
+ this.equinox = equinox;
+ }
+
+ @Override
+ public void run() {
+ try {
+ destroyNode(node);
+ } catch (Exception e) {
+ // Ignore
+ }
+ try {
+ equinox.stop();
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ }
+
+ /**
+ * Stop the given node.
+ *
+ * @param node
+ * @throws Exception
+ */
+ private static void stopNode(Object node) throws Exception {
+ try {
+ node.getClass().getMethod("stop").invoke(node);
+ logger.info("SCA Node is now stopped.");
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node could not be stopped", e);
+ throw e;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher2.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher2.java
new file mode 100644
index 0000000000..14018a7af5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher2.java
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.equinox.launcher;
+
+import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.node;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * A launcher for SCA nodes.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeLauncher2 {
+
+ static final Logger logger = Logger.getLogger(NodeLauncher2.class.getName());
+ private EquinoxHost equinoxHost;
+ private BundleContext bundleContext;
+
+ /**
+ * Constructs a new node launcher.
+ */
+ private NodeLauncher2() {
+ equinoxHost = new EquinoxHost();
+ bundleContext = equinoxHost.start();
+ }
+
+ /**
+ * Returns a new launcher instance.
+ *
+ * @return a new launcher instance
+ */
+ public static NodeLauncher2 newInstance() {
+ return new NodeLauncher2();
+ }
+
+ /**
+ * Creates a new SCA node from the configuration URL
+ *
+ * @param configurationURL the URL of the node configuration which is the ATOM feed
+ * that contains the URI of the composite and a collection of URLs for the contributions
+ *
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNode(String configurationURL) throws LauncherException {
+ return (T)node(configurationURL, null, null, null, bundleContext);
+ }
+
+ /**
+ * Creates a new SCA OSGi Node.
+ *
+ * @param compositeURI the URI of the composite to use
+ * @param contributions the URI of the contributions that provides the composites and related
+ * artifacts. If the list is empty, then we will use the thread context classloader to discover
+ * the contribution on the classpath
+ *
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNode(String compositeURI, Contribution... contributions) throws LauncherException {
+ return (T)node(null, compositeURI, null, contributions, bundleContext);
+ }
+
+ /**
+ * Creates a new SCA OSGi Node.
+ *
+ * @param compositeURI the URI of the composite to use
+ * @param compositeContent the XML content of the composite to use
+ * @param contributions the URI of the contributions that provides the composites and related artifacts
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNode(String compositeURI, String compositeContent, Contribution... contributions)
+ throws LauncherException {
+ return (T)node(null, compositeURI, compositeContent, contributions, bundleContext);
+ }
+
+ public static void main(String[] args) throws Exception {
+ logger.info("Apache Tuscany SCA Node is starting...");
+
+ // Create a node launcher
+ NodeLauncher2 launcher = newInstance();
+
+ EquinoxHost equinox = launcher.equinoxHost;
+ Object node = null;
+ ShutdownThread shutdown = null;
+ try {
+
+ Contribution[] contributions = new Contribution[args.length];
+ for (int i=0; i<args.length; i++) {
+ File f = new File(args[i]);
+ if (!f.exists()) {
+ System.err.println("contribution not found: " + f);
+ System.exit(1);
+ }
+ contributions[i] = new Contribution(f.toURI().toString(), f.toURI().toString());
+ }
+
+ // Create a node from a composite URI and a contribution location
+// String contributionLocation = args[1];
+// logger.info("SCA composite: " + null);
+// logger.info("SCA contribution: " + contributionLocation);
+ node = launcher.createNode(null, contributions);
+
+ // Start the node
+ try {
+ node.getClass().getMethod("start").invoke(node);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node could not be started", e);
+ throw e;
+ }
+ logger.info("SCA Node is now started.");
+
+ // Install a shutdown hook
+ shutdown = new ShutdownThread(node, equinox);
+ Runtime.getRuntime().addShutdownHook(shutdown);
+
+ logger.info("Press enter to shutdown.");
+ try {
+ System.in.read();
+ } catch (IOException e) {
+
+ // Wait forever
+ Object lock = new Object();
+ synchronized(lock) {
+ lock.wait();
+ }
+ }
+ } finally {
+
+ // Remove the shutdown hook
+ if (shutdown != null) {
+ Runtime.getRuntime().removeShutdownHook(shutdown);
+ }
+
+ // Stop the node
+ if (node != null) {
+ destroyNode(node);
+ }
+ if (equinox != null) {
+ equinox.stop();
+ }
+ }
+ }
+
+ public void destroy() {
+ if (equinoxHost != null) {
+ equinoxHost.stop();
+ bundleContext = null;
+ }
+ }
+
+ /**
+ * Stop the given node.
+ *
+ * @param node
+ * @throws Exception
+ */
+ private static void destroyNode(Object node) throws Exception {
+ try {
+ node.getClass().getMethod("stop").invoke(node);
+ node.getClass().getMethod("destroy").invoke(node);
+ logger.info("SCA Node is now stopped.");
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node could not be stopped", e);
+ throw e;
+ }
+ }
+
+ private static class ShutdownThread extends Thread {
+ private Object node;
+ private EquinoxHost equinox;
+
+ public ShutdownThread(Object node, EquinoxHost equinox) {
+ super();
+ this.node = node;
+ this.equinox = equinox;
+ }
+
+ @Override
+ public void run() {
+ try {
+ destroyNode(node);
+ } catch (Exception e) {
+ // Ignore
+ }
+ try {
+ equinox.stop();
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherCommand.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherCommand.java
new file mode 100644
index 0000000000..f3ddbe0f80
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherCommand.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.node.equinox.launcher;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.osgi.framework.console.CommandInterpreter;
+import org.eclipse.osgi.framework.console.CommandProvider;
+
+/**
+ * An Equinox console command extension for Tuscany
+ * http://www.ibm.com/developerworks/library/os-ecl-osgiconsole/index.html
+ */
+public class NodeLauncherCommand implements CommandProvider {
+
+ public String getHelp() {
+ return "---Apache Tuscany Commands for Equinox---\n"
+ + "\ttuscany - Launch an SCA node\n"
+ + "\tAgruments:\n"
+ // + " [-config <equinoxConfiguration>]: The configuration folder for Equinox\n"
+ // + " [-bundles <osgiBundles>]: A list of bundles to be installed\n"
+ + "\t[-c <compositeURI>]: The composite URI\n"
+ + "\t[-t <ttl>]: Time to live in milliseconds before the node is stopped\n"
+ + "\tcontribution1 ... contributionN: A list of contribution files or URLs\n";
+ }
+
+ public void _tuscany(CommandInterpreter ci) throws Exception {
+ List<String> args = new ArrayList<String>();
+ while (true) {
+ String arg = ci.nextArgument();
+ if (arg == null) {
+ break;
+ }
+ args.add(arg);
+ }
+ NodeLauncher.main(args.toArray(new String[args.size()]));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
new file mode 100644
index 0000000000..cae4b6728e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
@@ -0,0 +1,1362 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.equinox.launcher;
+
+import static org.osgi.framework.Constants.ACTIVATION_LAZY;
+import static org.osgi.framework.Constants.BUNDLE_ACTIVATIONPOLICY;
+import static org.osgi.framework.Constants.BUNDLE_CLASSPATH;
+import static org.osgi.framework.Constants.BUNDLE_MANIFESTVERSION;
+import static org.osgi.framework.Constants.BUNDLE_NAME;
+import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME;
+import static org.osgi.framework.Constants.BUNDLE_VENDOR;
+import static org.osgi.framework.Constants.BUNDLE_VERSION;
+import static org.osgi.framework.Constants.DYNAMICIMPORT_PACKAGE;
+import static org.osgi.framework.Constants.EXPORT_PACKAGE;
+import static org.osgi.framework.Constants.REQUIRE_BUNDLE;
+import static org.osgi.framework.Constants.RESOLUTION_DIRECTIVE;
+import static org.osgi.framework.Constants.RESOLUTION_OPTIONAL;
+import static org.osgi.framework.Constants.VISIBILITY_DIRECTIVE;
+import static org.osgi.framework.Constants.VISIBILITY_REEXPORT;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * Common functions and constants used by the admin components.
+ *
+ * @version $Rev$ $Date$
+ */
+final class NodeLauncherUtil {
+ private static final String NODE_API_BUNDLE = "org.apache.tuscany.sca.node.api";
+ private static final String BASE_BUNDLE = "org.apache.tuscany.sca.base";
+
+ private static final Logger logger = Logger.getLogger(NodeLauncherUtil.class.getName());
+
+ static final String META_INF_SERVICES = "META-INF.services;partial=true;mandatory:=partial";
+ static final String LAUNCHER_EQUINOX_LIBRARIES = "org.apache.tuscany.sca.node.launcher.equinox.libraries";
+ static final String GATEWAY_BUNDLE = "org.apache.tuscany.sca.gateway";
+
+ private static final String NODE_FACTORY = "org.apache.tuscany.sca.node.NodeFactory";
+
+ private static final String DOMAIN_MANAGER_LAUNCHER_BOOTSTRAP =
+ "org.apache.tuscany.sca.domain.manager.launcher.DomainManagerLauncherBootstrap";
+
+ private static final String NODE_IMPLEMENTATION_DAEMON_BOOTSTRAP =
+ "org.apache.tuscany.sca.implementation.node.launcher.NodeImplementationDaemonBootstrap";
+
+ private static final String TUSCANY_HOME = "TUSCANY_HOME";
+ private static final String TUSCANY_PATH = "TUSCANY_PATH";
+
+ /**
+ * Creates a new node.
+ *
+ * @param configurationURI
+ * @param compositeURI
+ * @param compositeContent
+ * @param contributions
+ * @param contributionClassLoader
+ * @param bundleContext
+ * @throws LauncherException
+ */
+ static Object node(String configurationURI,
+ String compositeURI,
+ String compositeContent,
+ Contribution[] contributions,
+ BundleContext bundleContext) throws LauncherException {
+ try {
+
+ // Get the node runtime bundle.
+ Bundle bundle = null;
+ for (Bundle b : bundleContext.getBundles()) {
+ if (NODE_API_BUNDLE.equals(b.getSymbolicName())) {
+ bundle = b;
+ break;
+ }
+ if (b.getSymbolicName().contains(BASE_BUNDLE)) {
+ bundle = b;
+ break;
+ }
+ }
+ if (bundle == null) {
+ throw new IllegalStateException("Bundle " + NODE_API_BUNDLE + " is not installed");
+ }
+
+ // Use Java reflection to create the node as only the runtime class
+ // loader knows the runtime classes required by the node
+ Class<?> bootstrapClass = bundle.loadClass(NODE_FACTORY);
+
+ Object node = createNode(bootstrapClass, configurationURI, compositeURI, compositeContent, contributions);
+
+ // If the SCANodeFactory interface is available in the current classloader, create
+ // an SCANode proxy around the node we've just create
+ try {
+ Class<?> type = Class.forName(NODE_FACTORY);
+ type = type.getDeclaredClasses()[0];
+ return type.getMethod("createProxy", Class.class, Object.class).invoke(null, type, node);
+ } catch (ClassNotFoundException e) {
+ // Ignore
+ }
+ return node;
+
+ } catch (Exception e) {
+ NodeLauncher.logger.log(Level.SEVERE, "SCA Node could not be created", e);
+ throw new LauncherException(e);
+ }
+ }
+
+ private static Object createNode(Class<?> bootstrapClass,
+ String configurationURI,
+ String compositeURI,
+ String compositeContent,
+ Contribution[] contributions) throws NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException, MalformedURLException {
+ Method newInstance = bootstrapClass.getMethod("newInstance");
+ Object nodeFactory = newInstance.invoke(null);
+
+ Object node;
+ if (configurationURI != null) {
+
+ // NodeFactory.createNode(URL)
+ Method create = bootstrapClass.getMethod("createNode", URL.class);
+ node = create.invoke(nodeFactory, new URL(configurationURI));
+
+ } else if (compositeContent != null) {
+
+ // NodeFactory.createNode(Reader, Stringp[], String[])
+ Method create = bootstrapClass.getMethod("createNode", Reader.class, String[].class, String[].class);
+ String[] uris = new String[contributions.length];
+ String[] locations = new String[contributions.length];
+ for (int i = 0; i < contributions.length; i++) {
+ uris[i] = contributions[i].getURI();
+ locations[i] = contributions[i].getLocation();
+ }
+ node = create.invoke(nodeFactory, compositeContent, uris, locations);
+
+ } else {
+
+ // NodeFactory.createNode(String, Stringp[], String[])
+ Method create = bootstrapClass.getMethod("createNode", String.class, String[].class, String[].class);
+ String[] uris = new String[contributions.length];
+ String[] locations = new String[contributions.length];
+ for (int i = 0; i < contributions.length; i++) {
+ uris[i] = contributions[i].getURI();
+ locations[i] = contributions[i].getLocation();
+ }
+ node = create.invoke(nodeFactory, compositeURI, uris, locations);
+ }
+ return node;
+ }
+
+ /**
+ * Creates a new node daemon.
+ *
+ * @throws LauncherException
+ */
+ static Object nodeDaemon() throws LauncherException {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+
+ // Use Java reflection to create the node daemon as only the runtime class
+ // loader knows the runtime classes required by the node
+ String className = NODE_IMPLEMENTATION_DAEMON_BOOTSTRAP;
+ Class<?> bootstrapClass;
+ bootstrapClass = Class.forName(className, false, tccl);
+ Object bootstrap = bootstrapClass.getConstructor().newInstance();
+
+ Object nodeDaemon = bootstrapClass.getMethod("getNode").invoke(bootstrap);
+ return nodeDaemon;
+
+ } catch (Exception e) {
+ NodeDaemonLauncher.logger.log(Level.SEVERE, "SCA Node Daemon could not be created", e);
+ throw new LauncherException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ /**
+ * Creates a new domain manager.
+ *
+ * @throws LauncherException
+ */
+ static Object domainManager(String rootDirectory) throws LauncherException {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+
+ // Use Java reflection to create the node daemon as only the runtime class
+ // loader knows the runtime classes required by the node
+ String className = DOMAIN_MANAGER_LAUNCHER_BOOTSTRAP;
+ Class<?> bootstrapClass;
+ bootstrapClass = Class.forName(className, false, tccl);
+ Constructor<?> constructor = bootstrapClass.getConstructor(String.class);
+ Object bootstrap = constructor.newInstance(rootDirectory);
+
+ Object domainManager = bootstrapClass.getMethod("getNode").invoke(bootstrap);
+ return domainManager;
+
+ } catch (Exception e) {
+ DomainManagerLauncher.logger.log(Level.SEVERE, "SCA Domain Manager could not be created", e);
+ throw new LauncherException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ /**
+ * starting with -, then some digits, then . or - or _, then some digits again
+ *
+ */
+ // Mike Edwards 13/04/2009 - this original pattern allows for any number of repeated
+ // groups of digits, so that 1.2.3.4 is legal, for example. The problem with this is
+ // that OSGi only deals with a maximum of 3 groups of digits...
+ // private static Pattern pattern = Pattern.compile("-(\\d)+((\\.|-|_)(\\d)+)*");
+ //
+ // This updated version restricts the allowed patterns to a maximum of 3 groups of
+ // digits so that "1", "1.2" and "1.2.3" are allowed but not "1.2.3.4" etc
+ private static Pattern pattern = Pattern.compile("-(\\d)+((\\.|-|_)(\\d)+){0,2}");
+
+ /**
+ * Returns the version number to use for the given JAR file.
+ *
+ * @param jarFile
+ * @return
+ */
+ static String jarVersion(URL jarFile) {
+ String name = jarFile.getFile();
+ int index = name.lastIndexOf('/');
+ if (index != -1) {
+ // Find the last segment
+ name = name.substring(index + 1);
+ }
+ index = name.lastIndexOf('.');
+ if (index != -1) {
+ // Trim the extension
+ name = name.substring(0, index);
+ }
+
+ Matcher matcher = pattern.matcher(name);
+ String version = "0.0.0";
+ if (matcher.find()) {
+ version = matcher.group();
+ // Remove the leading "-" character
+ version = version.substring(1);
+ // The Pattern above allows the version string to contain "-" and "_" as digit separators.
+ // OSGi only allows for "." as a separator thus any "-" and "_" characters in the version string must be replaced by "."
+ version = version.replace('-', '.');
+ version = version.replace('_', '.');
+ }
+ return version;
+ }
+
+ static String artifactId(URL jarFile) {
+ String name = jarFile.getFile();
+ int index = name.lastIndexOf('/');
+ if (index != -1) {
+ // Find the last segment
+ name = name.substring(index + 1);
+ }
+ index = name.lastIndexOf('.');
+ if (index != -1) {
+ // Trim the extension
+ name = name.substring(0, index);
+ }
+
+ Matcher matcher = pattern.matcher(name);
+ if (matcher.find()) {
+ return name.substring(0, matcher.start());
+ } else {
+ return name;
+ }
+ }
+
+ /**
+ * Add the packages found in the given JAR to a set.
+ *
+ * @param jarFile
+ * @param packages
+ * @throws IOException
+ */
+ private static void addPackages(URL jarFile, Set<String> packages, String version) throws IOException {
+ if (version == null) {
+ version = ";version=" + jarVersion(jarFile);
+ } else {
+ version = ";version=" + version;
+ }
+ File file = file(jarFile);
+ if (file.isDirectory()) {
+ List<String> classFiles = listClassFiles(file);
+ for (String cls : classFiles) {
+ int index = cls.lastIndexOf('/');
+ if (index == -1) {
+ // Default package cannot be exported
+ continue;
+ }
+ String pkg = cls.substring(0, index);
+ pkg = pkg.replace('/', '.') + version;
+ // Export META-INF.services
+ if ("META-INF.services".equals(pkg)) {
+ packages.add(META_INF_SERVICES);
+ } else {
+ packages.add(pkg);
+ }
+ }
+ } else if (file.isFile()) {
+ ZipInputStream is = new ZipInputStream(new FileInputStream(file));
+ ZipEntry entry;
+ while ((entry = is.getNextEntry()) != null) {
+ String entryName = entry.getName();
+ // Export split packages for META-INF/services
+ if(entryName.startsWith("META-INF/services/")) {
+ packages.add("META-INF.services" + ";partial=true;mandatory:=partial");
+ }
+ if (!entry.isDirectory() && entryName != null
+ && entryName.length() > 0
+ && !entryName.startsWith(".")
+ && entryName.endsWith(".class") // Exclude resources from Export-Package
+ && entryName.lastIndexOf("/") > 0) {
+ String pkg = entryName.substring(0, entryName.lastIndexOf("/")).replace('/', '.') + version;
+ packages.add(pkg);
+ }
+ }
+ is.close();
+ }
+ }
+
+ private static List<String> listClassFiles(File directory) {
+ List<String> artifacts = new ArrayList<String>();
+ traverse(artifacts, directory, directory);
+ // Add META-INF/services to be exported
+ if (new File(directory, "META-INF/services").isDirectory()) {
+ artifacts.add("META-INF/services/");
+ }
+ return artifacts;
+ }
+
+ /**
+ * Recursively traverse a root directory
+ *
+ * @param fileList
+ * @param file
+ * @param root
+ * @throws IOException
+ */
+ private static void traverse(List<String> fileList, File file, File root) {
+ if (file.isFile() && file.getName().endsWith(".class")) {
+ fileList.add(root.toURI().relativize(file.toURI()).toString());
+ } else if (file.isDirectory()) {
+ String uri = root.toURI().relativize(file.toURI()).toString();
+ if (uri.endsWith("/")) {
+ uri = uri.substring(0, uri.length() - 1);
+ }
+ fileList.add(uri);
+
+ File[] files = file.listFiles();
+ for (File f : files) {
+ if (!f.getName().startsWith(".")) {
+ traverse(fileList, f, root);
+ }
+ }
+ }
+ }
+
+ /**
+ * Finds the OSGi manifest file for a JAR file, where the manifest file is held in a META-INF directory
+ * alongside the JAR
+ * @param jarURL - The URL of the JAR file
+ * @return - a Manifest object corresponding to the manifest file, or NULL if there is no OSGi manifest
+ */
+ static private Manifest findOSGiManifest(URL jarURL) {
+ try {
+ File jarFile = new File(jarURL.toURI());
+ File theManifestFile = new File(jarFile.getParent(), "META-INF/MANIFEST.MF");
+ if (theManifestFile.exists()) {
+ // Create manifest object by reading the manifest file
+ Manifest manifest = new Manifest(new FileInputStream(theManifestFile));
+ // Check that this manifest file has the necessary OSGi metadata
+ String bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+ if (bundleName != null) {
+ return manifest;
+ } // end if
+ } // end if
+ } catch (Exception e) {
+ // Could not read the manifest - continue
+ }
+ return null;
+ } // end findOSGiManifest
+
+ /**
+ * Generate a manifest from a list of third-party JAR files.
+ *
+ * @param jarFiles
+ * @param bundleSymbolicName The Bundle-SymbolicName
+ * @param bundleVersion The Bundle-Version
+ * @return
+ * @throws IllegalStateException
+ */
+ static private Manifest thirdPartyLibraryBundleManifest(Collection<URL> jarFiles,
+ String bundleSymbolicName,
+ String bundleVersion) throws IllegalStateException {
+ try {
+
+ // List exported packages and bundle classpath entries
+ StringBuffer classpath = new StringBuffer();
+ StringBuffer exports = new StringBuffer();
+ StringBuffer imports = new StringBuffer();
+ Set<String> packages = new HashSet<String>();
+
+ for (URL jarFile : jarFiles) {
+ addPackages(jarFile, packages, bundleVersion);
+ classpath.append("\"external:");
+ classpath.append(file(jarFile).getPath().replace(File.separatorChar, '/'));
+ classpath.append("\",");
+ }
+
+ Set<String> importPackages = new HashSet<String>();
+ for (String pkg : packages) {
+
+ String importPackage = pkg;
+ int index = pkg.indexOf(';');
+ if (index != -1) {
+ importPackage = pkg.substring(0, index);
+ }
+ if (!importPackages.contains(importPackage)) {
+ // Exclude META-INF.services
+ if (!"META-INF.services".equals(importPackage)) {
+ imports.append(pkg);
+ imports.append(',');
+ }
+ importPackages.add(importPackage);
+ exports.append(pkg);
+ exports.append(',');
+ } else {
+ logger.warning("Duplicate package skipped: " + pkg);
+ }
+ }
+
+ // Create a manifest
+ Manifest manifest = new Manifest();
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.putValue("Manifest-Version", "1.0");
+ attributes.putValue(BUNDLE_MANIFESTVERSION, "2");
+
+ if (bundleVersion == null) {
+ bundleVersion = "0.0.0";
+ }
+ attributes.putValue(Constants.BUNDLE_VERSION, bundleVersion);
+ if (bundleSymbolicName == null) {
+ bundleSymbolicName = LAUNCHER_EQUINOX_LIBRARIES;
+ }
+ attributes.putValue(BUNDLE_SYMBOLICNAME, bundleSymbolicName);
+ if (exports.length() > 0) {
+ attributes.putValue(EXPORT_PACKAGE, exports.substring(0, exports.length() - 1));
+ }
+ /*
+ if (imports.length() > 0) {
+ attributes.putValue(IMPORT_PACKAGE, imports.substring(0, imports.length() - 1));
+ }
+ */
+ if (classpath.length() > 0) {
+ attributes.putValue(BUNDLE_CLASSPATH, classpath.substring(0, classpath.length() - 1));
+ }
+ // The system bundle has incomplete javax.transaction* packages exported
+ attributes.putValue(DYNAMICIMPORT_PACKAGE, "javax.transaction;version=\"1.1\",javax.transaction.xa;version=\"1.1\",*");
+
+ return manifest;
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * Generates a library bundle from a list of third-party JARs.
+ *
+ * @param jarFiles
+ * @param bundleSymbolicName The Bundle-SymbolicName
+ * @param bundleVersion The Bundle-Version
+ * @return
+ * @throws IOException
+ */
+ static InputStream thirdPartyLibraryBundle(Collection<URL> jarFiles, String bundleSymbolicName, String bundleVersion)
+ throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ Manifest mf = thirdPartyLibraryBundleManifest(jarFiles, bundleSymbolicName, bundleVersion);
+ JarOutputStream jos = new JarOutputStream(bos, mf);
+ jos.close();
+ return new ByteArrayInputStream(bos.toByteArray());
+ }
+
+ static InputStream thirdPartyLibraryBundle(Collection<URL> jarFiles, Manifest manifest) throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ StringBuffer classpath = new StringBuffer();
+ for (URL jarFile : jarFiles) {
+ classpath.append("\"external:");
+ classpath.append(file(jarFile).getPath().replace(File.separatorChar, '/'));
+ classpath.append("\",");
+ }
+
+ if (classpath.length() > 0) {
+ manifest.getMainAttributes().putValue(BUNDLE_CLASSPATH, classpath.substring(0, classpath.length() - 1));
+ }
+
+ JarOutputStream jos = new JarOutputStream(bos, manifest);
+ jos.close();
+ return new ByteArrayInputStream(bos.toByteArray());
+ }
+
+ /**
+ * Returns the location of this bundle.
+ *
+ * @return
+ * @throws IOException
+ */
+ static String thisBundleLocation() throws IOException, URISyntaxException {
+ String resource = NodeLauncherUtil.class.getName().replace('.', '/') + ".class";
+ URL url = NodeLauncherUtil.class.getClassLoader().getResource(resource);
+ if (url == null) {
+ throw new FileNotFoundException(resource);
+ }
+ URI uri = toURI(url);
+
+ String scheme = uri.getScheme();
+ if (scheme.equals("jar")) {
+ String path = uri.toString().substring(4);
+ int i = path.indexOf("!/");
+ path = path.substring(0, i);
+ return path;
+ } else {
+ String path = uri.toString();
+ path = path.substring(0, path.length() - resource.length());
+ return path;
+ }
+ }
+
+ static URI toURI(URL url) {
+ File file = file(url);
+ if (file != null) {
+ return file.toURI();
+ } else {
+ return createURI(url.toString());
+ }
+ }
+
+ /**
+ * Escape the space in URL string
+ * @param uri
+ * @return
+ */
+ static URI createURI(String uri) {
+ if (uri == null) {
+ return null;
+ }
+ if (uri.indexOf('%') != -1) {
+ // Avoid double-escaping
+ return URI.create(uri);
+ }
+ int index = uri.indexOf(':');
+ String scheme = null;
+ String ssp = uri;
+ if (index != -1) {
+ scheme = uri.substring(0, index);
+ ssp = uri.substring(index + 1);
+ }
+ try {
+ return new URI(scheme, ssp, null);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Returns the location of this bundle.
+ *
+ * @param bundle
+ * @return
+ * @throws IOException
+ */
+ static String thisBundleLocation(Bundle bundle) throws IOException, URISyntaxException, ClassNotFoundException {
+ String resource = NodeLauncherUtil.class.getName();
+ Class<?> clazz = bundle.loadClass(NodeLauncherUtil.class.getName());
+ URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
+ if (url == null) {
+ throw new FileNotFoundException(resource);
+ }
+ URI uri = toURI(url);
+
+ String scheme = uri.getScheme();
+ if (scheme.equals("jar")) {
+ String path = uri.toString().substring(4);
+ int i = path.indexOf("!/");
+ path = path.substring(0, i);
+ return path;
+ } else {
+ String path = uri.toString();
+ //path = path.substring(0, path.length() - resource.length());
+ return path;
+ }
+ }
+
+ /**
+ * Install the given bundle.
+ *
+ * @param bundleContext
+ * @param location
+ * @throws BundleException
+ * @throws IOException
+ */
+ static void fixupBundle(String location) throws BundleException, IOException {
+ File target = file(new URL(location));
+ if (!target.exists()) {
+ return;
+ }
+ location = target.toURI().toString();
+
+ // For development mode, copy the MANIFEST.MF file to the bundle location as it's
+ // initially outside of target/classes, at the root of the project.
+ if (location.endsWith("/target/classes/")) {
+ File targetManifest = new File(target, "META-INF/MANIFEST.MF");
+ File sourceManifest = new File(target.getParentFile().getParentFile(), "META-INF/MANIFEST.MF");
+ if (!sourceManifest.isFile()) {
+ return;
+ }
+ targetManifest.getParentFile().mkdirs();
+ OutputStream os = new FileOutputStream(targetManifest);
+ InputStream is = new FileInputStream(sourceManifest);
+ byte[] buf = new byte[2048];
+ for (;;) {
+ int l = is.read(buf);
+ if (l == -1) {
+ break;
+ }
+ os.write(buf, 0, l);
+ }
+ is.close();
+ os.close();
+ }
+ }
+
+ /**
+ * Returns a string representation of the given bundle.
+ *
+ * @param b
+ * @param verbose
+ * @return
+ */
+ static String string(Bundle bundle, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(bundle.getBundleId()).append(" ").append(bundle.getSymbolicName());
+ int s = bundle.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ if (verbose) {
+ sb.append(" ").append(bundle.getLocation());
+ sb.append(" ").append(bundle.getHeaders());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Returns the name of a bundle, or null if the given file is not a bundle.
+ *
+ * @param file
+ * @return
+ * @throws IOException
+ */
+ static String bundleName(File file) throws IOException {
+ if (!file.exists()) {
+ return null;
+ }
+ String bundleName = null;
+ if (file.isDirectory()) {
+ File mf = new File(file, "META-INF/MANIFEST.MF");
+ if (mf.isFile()) {
+ Manifest manifest = new Manifest(new FileInputStream(mf));
+ bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+ } else {
+ if (file.toURI().getPath().endsWith("/target/classes/")) {
+ // Development mode, MANIFEST.MF is outside the bundle location
+ mf = new File(file.getParentFile().getParentFile(), "META-INF/MANIFEST.MF");
+ if (mf.isFile()) {
+ Manifest manifest = new Manifest(new FileInputStream(mf));
+ bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+ }
+ }
+ }
+ } else {
+ JarFile jar = new JarFile(file, false);
+ Manifest manifest = jar.getManifest();
+ if (manifest != null) {
+ bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+ }
+ jar.close();
+ }
+ if (bundleName == null) {
+ return bundleName;
+ }
+ int sc = bundleName.indexOf(';');
+ if (sc != -1) {
+ bundleName = bundleName.substring(0, sc);
+ }
+ return bundleName;
+ }
+
+ /**
+ * Collect JAR files in the given directory.
+ *
+ * @param directory
+ * @param urls
+ * @param filter
+ * @throws MalformedURLException
+ */
+ private static void collectClasspathEntries(File directory, Set<URL> urls, FilenameFilter filter, boolean recursive)
+ throws MalformedURLException {
+ File[] files = directory.listFiles(filter);
+ if (files != null) {
+ int count = 0;
+ for (File file : files) {
+ if (recursive && file.isDirectory()) {
+ collectClasspathEntries(file, urls, filter, recursive);
+ } else {
+ urls.add(file.toURI().toURL());
+ count++;
+ }
+ }
+ if (count != 0) {
+ logger.fine("Runtime classpath: " + count
+ + " JAR"
+ + (count > 1 ? "s" : "")
+ + " from "
+ + directory.toString());
+ }
+ }
+ }
+
+ /**
+ * Collect development .../ target/classes directories in the given directory.
+ *
+ * @param directory
+ * @param urls
+ * @param filter
+ * @throws MalformedURLException
+ */
+ private static void collectTargetClassesClasspathEntries(File directory, Set<URL> urls, FilenameFilter filter)
+ throws MalformedURLException {
+ File[] files = directory.listFiles();
+ if (files != null) {
+ int count = 0;
+ for (File file : files) {
+ if (!file.isDirectory()) {
+ continue;
+ }
+ File target = new File(file, "target");
+ if (!target.isDirectory()) {
+ continue;
+ }
+ File classes = new File(target, "classes");
+ if (classes.isDirectory() && filter.accept(target, "classes")) {
+ urls.add(classes.toURI().toURL());
+ count++;
+ }
+ }
+ if (count != 0 && logger.isLoggable(Level.FINE)) {
+ logger.fine("Runtime classpath: " + count
+ + " classes folder"
+ + (count > 1 ? "s" : "")
+ + " from "
+ + directory.toString());
+ }
+ }
+ }
+
+ /**
+ * Collect JAR files under the given distribution directory.
+ *
+ * @param directory
+ * @param jarDirectoryURLs
+ * @param jarURLs
+ * @param filter
+ * @throws MalformedURLException
+ */
+ private static void collectDistributionClasspathEntries(String directory,
+ Set<URL> jarDirectoryURLs,
+ Set<URL> jarURLs,
+ FilenameFilter filter) throws MalformedURLException {
+ File directoryFile = new File(directory);
+ URL directoryURL = directoryFile.toURI().toURL();
+ if (!jarDirectoryURLs.contains(directoryURL) && directoryFile.exists()) {
+
+ // Collect files under the given directory
+ jarDirectoryURLs.add(directoryURL);
+ collectClasspathEntries(directoryFile, jarURLs, filter, false);
+
+ // Collect files under <directory>/modules
+ File modulesDirectory = new File(directoryFile, "modules");
+ URL modulesDirectoryURL = modulesDirectory.toURI().toURL();
+ if (!jarDirectoryURLs.contains(modulesDirectoryURL) && modulesDirectory.exists()) {
+ jarDirectoryURLs.add(modulesDirectoryURL);
+ collectClasspathEntries(modulesDirectory, jarURLs, filter, true);
+ }
+
+ // Collect files under <directory>/lib
+/* SL - this is commented out to prevent the jars in the lib dir being installed as
+ * OSGi bundles. There must have been a time (1.x?) when lib jars would have been
+ * installed but now the shaded jars live in lib and we don't want to install them
+ *
+ File libDirectory = new File(directoryFile, "lib");
+ URL libDirectoryURL = libDirectory.toURI().toURL();
+ if (!jarDirectoryURLs.contains(libDirectoryURL) && libDirectory.exists()) {
+ jarDirectoryURLs.add(libDirectoryURL);
+ collectClasspathEntries(libDirectory, jarURLs, filter, true);
+ }
+*/
+ }
+ }
+
+ private static boolean isMavenTestMode() {
+ return getProperty("surefire.test.class.path") != null || getProperty("surefire.real.class.path") != null
+ || getProperty("localRepository") != null;
+ }
+
+ /**
+ * Determine the Tuscany runtime classpath entries.
+ *
+ * @param useDistribution
+ * @param useAppClasspath
+ * @param useModulesDirectory
+ * @return
+ */
+ static Set<URL> runtimeClasspathEntries(boolean useDistribution,
+ boolean useAppClasspath,
+ boolean useModulesDirectory) throws FileNotFoundException,
+ URISyntaxException, MalformedURLException {
+
+ // Build list of runtime JARs
+ Set<URL> jarDirectoryURLs = new HashSet<URL>();
+ Set<URL> jarURLs = new HashSet<URL>();
+
+ // Determine the path to the launcher class
+ URI uri;
+ try {
+ uri = codeLocation(NodeLauncherUtil.class);
+ } catch (Exception e) {
+ uri = URI.create("");
+ }
+
+ // If the launcher class is in a JAR, add all runtime JARs from directory containing
+ // that JAR (e.g. the Tuscany modules directory) as well as the ../modules and
+ // ../lib directories
+ if (uri.getPath().endsWith(".jar")) {
+ if (useDistribution) {
+
+ File file = new File(uri);
+ if (file.exists()) {
+ File jarDirectory = file.getParentFile();
+ if (jarDirectory != null && jarDirectory.exists()) {
+
+ // Collect JAR files from the directory containing the input JAR
+ // (e.g. the Tuscany modules directory)
+ URL jarDirectoryURL = jarDirectory.toURI().toURL();
+ jarDirectoryURLs.add(jarDirectoryURL);
+ collectClasspathEntries(jarDirectory, jarURLs, new StandAloneJARFileNameFilter(), true);
+
+ File homeDirectory = jarDirectory.getParentFile();
+ if (homeDirectory != null && homeDirectory.exists()) {
+ collectDistributionClasspathEntries(homeDirectory.getAbsolutePath(),
+ jarDirectoryURLs,
+ jarURLs,
+ new StandAloneJARFileNameFilter());
+ }
+ }
+ }
+ }
+ } else if (uri.getPath().endsWith("/target/classes/")) {
+
+ // Development mode, we're running off classes in a workspace
+ // and not from Maven surefire, collect all bundles in the workspace
+ if (useModulesDirectory) {
+ if (!isMavenTestMode()) {
+ File file = new File(uri);
+ if (file.exists()) {
+ File moduleDirectory = file.getParentFile().getParentFile();
+ if (moduleDirectory != null) {
+ File modulesDirectory = moduleDirectory.getParentFile();
+ if (modulesDirectory != null && modulesDirectory.exists()
+ && modulesDirectory.getName().equals("modules")) {
+ collectDevelopmentClasspathEntries(modulesDirectory.getAbsolutePath(),
+ jarDirectoryURLs,
+ jarURLs,
+ new StandAloneDevelopmentClassesFileNameFilter());
+ // Added Mike Edwards, 09/04/2009
+ // Get hold of the Libraries that are used by the Tuscany modules
+ collectDevelopmentLibraryEntries(modulesDirectory, jarDirectoryURLs, jarURLs);
+ } // end if
+ }
+ }
+ }
+ }
+ }
+
+ // Look for a TUSCANY_HOME system property or environment variable
+ // Add all the JARs found under $TUSCANY_HOME, $TUSCANY_HOME/modules
+ // and $TUSCANY_HOME/lib
+ if (useDistribution) {
+ String home = getProperty(TUSCANY_HOME);
+ if (home != null && home.length() != 0) {
+ logger.info(TUSCANY_HOME + ": " + home);
+ collectDistributionClasspathEntries(home, jarDirectoryURLs, jarURLs, new StandAloneJARFileNameFilter());
+ }
+
+ // Look for a TUSCANY_PATH system property or environment variable
+ // Add all the JARs found under $TUSCANY_PATH, $TUSCANY_PATH/modules
+ // and $TUSCANY_PATH/lib
+ String ext = getProperty(TUSCANY_PATH);
+ if (ext != null && ext.length() != 0) {
+ logger.info(TUSCANY_PATH + ": " + ext);
+ String separator = getProperty("path.separator");
+ for (StringTokenizer tokens = new StringTokenizer(ext, separator); tokens.hasMoreTokens();) {
+ collectDistributionClasspathEntries(tokens.nextToken(),
+ jarDirectoryURLs,
+ jarURLs,
+ new StandAloneJARFileNameFilter());
+ }
+ }
+ }
+
+ // Add the classpath entries from the current classloader
+ if (useAppClasspath) {
+ collectClassLoaderClasspathEntries(jarURLs, NodeLauncherUtil.class.getClassLoader());
+ }
+
+ return jarURLs;
+
+ }
+
+ /**
+ * Returns the JAR files on the classpath used by the given classloader.
+ *
+ * @param classLoader
+ * @return
+ */
+ static List<URL> jarFilesOnClasspath(ClassLoader classLoader) {
+ Set<URL> entries = new HashSet<URL>();
+ collectClassLoaderClasspathEntries(entries, classLoader);
+ return new ArrayList<URL>(entries);
+ }
+
+ private static String getProperty(final String prop) {
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ String value = System.getProperty(prop);
+ if (value == null || value.length() == 0) {
+ return System.getenv(prop);
+ } else {
+ return value;
+ }
+ }
+ });
+ }
+
+ /**
+ * Collect JARs on the classpath of a URLClassLoader.
+ *
+ * @param urls
+ * @param cl
+ */
+ private static void collectClassLoaderClasspathEntries(Set<URL> urls, ClassLoader cl) {
+ if (cl == null) {
+ return;
+ }
+
+ int count = urls.size();
+ // Collect JARs from the URLClassLoader's classpath
+ if (cl instanceof URLClassLoader) {
+ URL[] jarURLs = ((URLClassLoader)cl).getURLs();
+ if (jarURLs != null) {
+ for (URL jarURL : jarURLs) {
+ urls.add(jarURL);
+ try {
+ urls.addAll(manifestClassPath(jarURL));
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+ count = urls.size() - count;
+
+ if (count != 0 && logger.isLoggable(Level.FINE)) {
+ logger.fine("Runtime classpath: " + count
+ + " JAR"
+ + (count > 1 ? "s" : "")
+ + " from application classpath.");
+ }
+ }
+ }
+ }
+
+ static Set<URL> manifestClassPath(URL jarFile) throws Exception {
+ Set<URL> urls = new HashSet<URL>();
+ if (jarFile != null) {
+ Manifest mf = null;
+ if ("file".equals(jarFile.getProtocol())) {
+ File f = file(jarFile);
+ if (f.isDirectory()) {
+ File mfFile = new File(f, "META-INF/MANIFEST.MF");
+ if (mfFile.isFile()) {
+ FileInputStream is = new FileInputStream(mfFile);
+ mf = new Manifest(is);
+ is.close();
+ }
+ } else if (f.isFile()) {
+ JarInputStream jar = new JarInputStream(jarFile.openStream());
+ mf = jar.getManifest();
+ jar.close();
+ }
+ }
+ if (mf != null) {
+ String cp = mf.getMainAttributes().getValue("Class-Path");
+ if (cp != null) {
+ StringTokenizer st = new StringTokenizer(cp);
+ while (st.hasMoreTokens()) {
+ URL entry = new URL(jarFile.toURI().toURL(), st.nextToken()).toURI().toURL();
+ urls.add(entry);
+ }
+ }
+ }
+ }
+ return urls;
+ }
+
+ /**
+ * A file name filter used to filter JAR files.
+ */
+ private static class StandAloneJARFileNameFilter implements FilenameFilter {
+
+ public boolean accept(File dir, String name) {
+ name = name.toLowerCase();
+
+ if (new File(dir, name).isDirectory()) {
+ return true;
+ }
+
+ // Filter out the Tomcat and Webapp hosts
+ if (name.startsWith("tuscany-host-tomcat") || name.startsWith("tuscany-host-webapp")) {
+ //FIXME This is temporary
+ return false;
+ }
+
+ // Don't include the sources jar files
+ if (name.endsWith("-sources.jar")) {
+ return false;
+ }
+
+ // Include JAR and MAR files
+ if (name.endsWith(".jar")) {
+ return true;
+ }
+ if (name.endsWith(".mar")) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * A file name filter used to filter target/classes directories.
+ */
+ private static class StandAloneDevelopmentClassesFileNameFilter implements FilenameFilter {
+
+ public boolean accept(File dir, String name) {
+ name = name.toLowerCase();
+ if (dir.getName().equals("target") && name.equals("classes")) {
+
+ // Filter out the Tomcat and Webapp hosts
+ String dirPath = dir.getAbsolutePath();
+ if (dirPath.endsWith("host-tomcat/target") || dirPath.endsWith("host-webapp/target")) {
+ //FIXME This is temporary
+ return false;
+ }
+ return true;
+ }
+
+ // Filter out the Tomcat and Webapp hosts
+ if (name.startsWith("tuscany-host-tomcat") || name.startsWith("tuscany-host-webapp")) {
+ //FIXME This is temporary
+ return false;
+ }
+
+ // Include JAR and MAR files
+ if (name.endsWith(".jar")) {
+ return true;
+ }
+ if (name.endsWith(".mar")) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * A file name filter used to filter JAR files.
+ */
+ private static class WebAppJARFileNameFilter extends StandAloneJARFileNameFilter {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ if (!super.accept(dir, name)) {
+ return false;
+ }
+ name = name.toLowerCase();
+
+ // Exclude servlet-api JARs
+ if (name.startsWith("servlet-api")) {
+ return false;
+ }
+
+ // Exclude the Tomcat and Jetty hosts
+ if (name.startsWith("tuscany-host-tomcat") || name.startsWith("tuscany-host-jetty")) {
+ //FIXME This is temporary
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ /**
+ * A file name filter used to filter the libraries in the \java\sca\distribution\all\target\modules
+ * directory
+ */
+ private static class DistributionLibsFileNameFilter implements FilenameFilter {
+
+ public boolean accept(File dir, String name) {
+ name = name.toLowerCase();
+
+ // Include subdirectories
+ if (new File(dir, name).isDirectory()) {
+ return true;
+ }
+
+ // Filter out the Tuscany SCA jars - since the development versions of these are used
+ // from the \target\classes directories...
+ if (name.startsWith("tuscany")) {
+ // tuscany-sdo jars don't form part of the SCA modules...
+ if (name.startsWith("tuscany-sdo")) return true;
+ return false;
+ }
+
+ // Include JAR and MAR files
+ if (name.endsWith(".jar")) {
+ return true;
+ }
+ if (name.endsWith(".mar")) {
+ return true;
+ }
+ return false;
+ } // end accept
+ } // end DistributionLibsFileNameFilter
+
+ /**
+ * Returns the File object representing the given URL.
+ *
+ * @param url
+ * @return
+ */
+ static File file(URL url) {
+ if (url == null || !url.getProtocol().equals("file")) {
+ return null;
+ } else {
+ String filename = url.getFile().replace('/', File.separatorChar);
+ int pos = 0;
+ while ((pos = filename.indexOf('%', pos)) >= 0) {
+ if (pos + 2 < filename.length()) {
+ String hexStr = filename.substring(pos + 1, pos + 3);
+ char ch = (char)Integer.parseInt(hexStr, 16);
+ filename = filename.substring(0, pos) + ch + filename.substring(pos + 3);
+ }
+ }
+ return new File(filename);
+ }
+ }
+
+ /**
+ * Returns the location of the classpath entry, JAR, WAR etc. containing the given class.
+ *
+ * @param clazz
+ * @return
+ */
+ static private URI codeLocation(Class<?> clazz) {
+ URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
+ return toURI(url);
+ }
+
+ /**
+ * Collect JAR files under the given distribution directory.
+ *
+ * @param directory
+ * @param jarDirectoryURLs
+ * @param jarURLs
+ * @param filter
+ * @throws MalformedURLException
+ */
+ private static void collectDevelopmentClasspathEntries(String directory,
+ Set<URL> jarDirectoryURLs,
+ Set<URL> jarURLs,
+ FilenameFilter filter) throws MalformedURLException {
+ File directoryFile = new File(directory);
+ URL directoryURL = directoryFile.toURI().toURL();
+ if (!jarDirectoryURLs.contains(directoryURL) && directoryFile.exists()) {
+
+ // Collect files under the given directory
+ jarDirectoryURLs.add(directoryURL);
+ collectTargetClassesClasspathEntries(directoryFile, jarURLs, filter);
+
+ }
+ } // end collectDevelopmentClasspathEntries
+
+ /**
+ * Collect the dependent Library JAR files for the development use of Tuscany
+ * It is assumed that these live in the \java\sca\distribution\all\target\modules
+ * directory, where the development modules live in \java\sca\modules, but that
+ * same directory also contains prebuilt versions of the Tuscany JARs, which must be
+ * filtered out so as not to clash with the development versions of the code
+ *
+ * @param directory - the \java\sca\modules directory
+ * @param jarDirectoryURLs
+ * @param jarURLs
+ * @throws MalformedURLException
+ */
+ private static void collectDevelopmentLibraryEntries(File modulesDirectory,
+ Set<URL> jarDirectoryURLs,
+ Set<URL> jarURLs) throws MalformedURLException {
+ // Get the \java\sca directory
+ File rootDirectory = modulesDirectory.getParentFile();
+ // Get the \java\sca\distribution\all\target\modules
+ String sep = File.separator;
+ File libsDirectory = new File(rootDirectory, "distribution" + sep + "all" + sep + "target" + sep + "modules");
+ URL libsURL = libsDirectory.toURI().toURL();
+ if (!jarDirectoryURLs.contains(libsURL) && libsDirectory.exists()) {
+ // Collect files under the libs module directory
+ jarDirectoryURLs.add(libsURL);
+ collectClasspathEntries(libsDirectory, jarURLs, new DistributionLibsFileNameFilter(), true);
+ } // end if
+ } // end collectDevelopmentLibraryEntries
+
+ /**
+ * Generate a gateway bundle that aggregate other bundles to handle split packages
+ * @param bundleSymbolicNames
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ static InputStream generateGatewayBundle(Collection<String> bundleSymbolicNames, String bundleVersion, boolean reexport)
+ throws IOException {
+ Manifest manifest = new Manifest();
+ Attributes attrs = manifest.getMainAttributes();
+ StringBuffer requireBundle = new StringBuffer();
+ for (String name : new HashSet<String>(bundleSymbolicNames)) {
+ requireBundle.append(name).append(";").append(RESOLUTION_DIRECTIVE).append(":=")
+ .append(RESOLUTION_OPTIONAL);
+ if (reexport) {
+ requireBundle.append(";").append(VISIBILITY_DIRECTIVE).append(":=").append(VISIBILITY_REEXPORT);
+ }
+ requireBundle.append(",");
+ }
+ int len = requireBundle.length();
+ if (len > 0 && requireBundle.charAt(len - 1) == ',') {
+ requireBundle.deleteCharAt(len - 1);
+ attrs.putValue(REQUIRE_BUNDLE, requireBundle.toString());
+ attrs.putValue("Manifest-Version", "1.0");
+ attrs.putValue("Implementation-Vendor", "The Apache Software Foundation");
+ attrs.putValue("Implementation-Vendor-Id", "org.apache");
+ if (bundleVersion != null) {
+ attrs.putValue(BUNDLE_VERSION, bundleVersion);
+ }
+ attrs.putValue(BUNDLE_MANIFESTVERSION, "2");
+ attrs.putValue(BUNDLE_SYMBOLICNAME, GATEWAY_BUNDLE);
+ attrs.putValue(BUNDLE_NAME, "Apache Tuscany SCA Gateway Bundle");
+ attrs.putValue(BUNDLE_VENDOR, "The Apache Software Foundation");
+ attrs.putValue(EXPORT_PACKAGE, "META-INF.services");
+ attrs.putValue(DYNAMICIMPORT_PACKAGE, "*");
+ attrs.putValue(BUNDLE_ACTIVATIONPOLICY, ACTIVATION_LAZY);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ JarOutputStream jos = new JarOutputStream(bos, manifest);
+ jos.close();
+ return new ByteArrayInputStream(bos.toByteArray());
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java
new file mode 100644
index 0000000000..4b4c4a8978
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.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.node.equinox.launcher;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+
+
+/**
+ * Main class for this JAR.
+ * With a "-nodeDaemon or -nd" this class launches the SCA Node Daemon.
+ * With a "-domainManager or -dm" argument it launches the SCA domain admin node.
+ * With any other argument it launches an SCA Node.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeMain {
+
+ public static void main(String[] args) throws Exception {
+ CommandLineParser parser = new PosixParser();
+ Options options = new Options();
+ OptionGroup group = new OptionGroup();
+ group.addOption(new Option("dm", "domainManager", false, "Domain Manager"));
+ group.addOption(new Option("nd", "nodeDaemon", false, "Node Domain"));
+ options.addOptionGroup(group);
+
+ // Add options from NodeLauncher to avoid UnrecognizedOptionException
+ for (Object o : NodeLauncher.getCommandLineOptions().getOptions()) {
+ options.addOption((Option)o);
+ }
+
+ CommandLine cli = parser.parse(options, args);
+ if (cli.hasOption("nd")) {
+ NodeDaemonLauncher.main(args);
+ } else if (cli.hasOption("dm")) {
+ DomainManagerLauncher.main(args);
+ } else {
+ NodeLauncher.main(args);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/J2SE-1.5.profile b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/J2SE-1.5.profile
new file mode 100644
index 0000000000..3814b42d00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/J2SE-1.5.profile
@@ -0,0 +1,150 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.osgi.framework.system.packages = \
+ javax.accessibility,\
+ javax.activity,\
+ javax.crypto,\
+ javax.crypto.interfaces,\
+ javax.crypto.spec,\
+ javax.imageio,\
+ javax.imageio.event,\
+ javax.imageio.metadata,\
+ javax.imageio.plugins.bmp,\
+ javax.imageio.plugins.jpeg,\
+ javax.imageio.spi,\
+ javax.imageio.stream,\
+ javax.management,\
+ javax.management.loading,\
+ javax.management.modelmbean,\
+ javax.management.monitor,\
+ javax.management.openmbean,\
+ javax.management.relation,\
+ javax.management.remote,\
+ javax.management.remote.rmi,\
+ javax.management.timer,\
+ javax.naming,\
+ javax.naming.directory,\
+ javax.naming.event,\
+ javax.naming.ldap,\
+ javax.naming.spi,\
+ javax.net,\
+ javax.net.ssl,\
+ javax.print,\
+ javax.print.attribute,\
+ javax.print.attribute.standard,\
+ javax.print.event,\
+ javax.rmi,\
+ javax.rmi.CORBA,\
+ javax.rmi.ssl,\
+ javax.security.auth,\
+ javax.security.auth.callback,\
+ javax.security.auth.kerberos,\
+ javax.security.auth.login,\
+ javax.security.auth.spi,\
+ javax.security.auth.x500,\
+ javax.security.cert,\
+ javax.security.sasl,\
+ javax.sound.midi,\
+ javax.sound.midi.spi,\
+ javax.sound.sampled,\
+ javax.sound.sampled.spi,\
+ javax.sql,\
+ javax.sql.rowset,\
+ javax.sql.rowset.serial,\
+ javax.sql.rowset.spi,\
+ javax.swing,\
+ javax.swing.border,\
+ javax.swing.colorchooser,\
+ javax.swing.event,\
+ javax.swing.filechooser,\
+ javax.swing.plaf,\
+ javax.swing.plaf.basic,\
+ javax.swing.plaf.metal,\
+ javax.swing.plaf.multi,\
+ javax.swing.plaf.synth,\
+ javax.swing.table,\
+ javax.swing.text,\
+ javax.swing.text.html,\
+ javax.swing.text.html.parser,\
+ javax.swing.text.rtf,\
+ javax.swing.tree,\
+ javax.swing.undo,\
+ javax.transaction,\
+ javax.transaction.xa,\
+ javax.xml,\
+ javax.xml.datatype,\
+ javax.xml.namespace,\
+ javax.xml.parsers,\
+ javax.xml.transform,\
+ javax.xml.transform.dom,\
+ javax.xml.transform.sax,\
+ javax.xml.transform.stream,\
+ javax.xml.validation,\
+ javax.xml.xpath,\
+ org.ietf.jgss,\
+ org.omg.CORBA,\
+ org.omg.CORBA_2_3,\
+ org.omg.CORBA_2_3.portable,\
+ org.omg.CORBA.DynAnyPackage,\
+ org.omg.CORBA.ORBPackage,\
+ org.omg.CORBA.portable,\
+ org.omg.CORBA.TypeCodePackage,\
+ org.omg.CosNaming,\
+ org.omg.CosNaming.NamingContextExtPackage,\
+ org.omg.CosNaming.NamingContextPackage,\
+ org.omg.Dynamic,\
+ org.omg.DynamicAny,\
+ org.omg.DynamicAny.DynAnyFactoryPackage,\
+ org.omg.DynamicAny.DynAnyPackage,\
+ org.omg.IOP,\
+ org.omg.IOP.CodecFactoryPackage,\
+ org.omg.IOP.CodecPackage,\
+ org.omg.Messaging,\
+ org.omg.PortableInterceptor,\
+ org.omg.PortableInterceptor.ORBInitInfoPackage,\
+ org.omg.PortableServer,\
+ org.omg.PortableServer.CurrentPackage,\
+ org.omg.PortableServer.POAManagerPackage,\
+ org.omg.PortableServer.POAPackage,\
+ org.omg.PortableServer.portable,\
+ org.omg.PortableServer.ServantLocatorPackage,\
+ org.omg.SendingContext,\
+ org.omg.stub.java.rmi,\
+ org.w3c.dom,\
+ org.w3c.dom.bootstrap,\
+ org.w3c.dom.events,\
+ org.w3c.dom.ls,\
+ org.xml.sax,\
+ org.xml.sax.ext,\
+ org.xml.sax.helpers
+org.osgi.framework.bootdelegation = \
+ javax.*,\
+ org.ietf.jgss,\
+ org.omg.*,\
+ org.w3c.*,\
+ org.xml.*,\
+ sun.*,\
+ com.sun.*
+org.osgi.framework.executionenvironment = \
+ OSGi/Minimum-1.0,\
+ OSGi/Minimum-1.1,\
+ JRE-1.1,\
+ J2SE-1.2,\
+ J2SE-1.3,\
+ J2SE-1.4,\
+ J2SE-1.5
+osgi.java.profile.name = J2SE-1.5
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/JavaSE-1.6.profile b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/JavaSE-1.6.profile
new file mode 100644
index 0000000000..816e7c44f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/JavaSE-1.6.profile
@@ -0,0 +1,185 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.osgi.framework.system.packages = \
+ javax.accessibility,\
+ javax.activation,\
+ javax.activity,\
+ javax.annotation,\
+ javax.annotation.processing,\
+ javax.crypto,\
+ javax.crypto.interfaces,\
+ javax.crypto.spec,\
+ javax.imageio,\
+ javax.imageio.event,\
+ javax.imageio.metadata,\
+ javax.imageio.plugins.bmp,\
+ javax.imageio.plugins.jpeg,\
+ javax.imageio.spi,\
+ javax.imageio.stream,\
+ javax.jws,\
+ javax.jws.soap,\
+ javax.lang.model,\
+ javax.lang.model.element,\
+ javax.lang.model.type,\
+ javax.lang.model.util,\
+ javax.management,\
+ javax.management.loading,\
+ javax.management.modelmbean,\
+ javax.management.monitor,\
+ javax.management.openmbean,\
+ javax.management.relation,\
+ javax.management.remote,\
+ javax.management.remote.rmi,\
+ javax.management.timer,\
+ javax.naming,\
+ javax.naming.directory,\
+ javax.naming.event,\
+ javax.naming.ldap,\
+ javax.naming.spi,\
+ javax.net,\
+ javax.net.ssl,\
+ javax.print,\
+ javax.print.attribute,\
+ javax.print.attribute.standard,\
+ javax.print.event,\
+ javax.rmi,\
+ javax.rmi.CORBA,\
+ javax.rmi.ssl,\
+ javax.script,\
+ javax.security.auth,\
+ javax.security.auth.callback,\
+ javax.security.auth.kerberos,\
+ javax.security.auth.login,\
+ javax.security.auth.spi,\
+ javax.security.auth.x500,\
+ javax.security.cert,\
+ javax.security.sasl,\
+ javax.sound.midi,\
+ javax.sound.midi.spi,\
+ javax.sound.sampled,\
+ javax.sound.sampled.spi,\
+ javax.sql,\
+ javax.sql.rowset,\
+ javax.sql.rowset.serial,\
+ javax.sql.rowset.spi,\
+ javax.swing,\
+ javax.swing.border,\
+ javax.swing.colorchooser,\
+ javax.swing.event,\
+ javax.swing.filechooser,\
+ javax.swing.plaf,\
+ javax.swing.plaf.basic,\
+ javax.swing.plaf.metal,\
+ javax.swing.plaf.multi,\
+ javax.swing.plaf.synth,\
+ javax.swing.table,\
+ javax.swing.text,\
+ javax.swing.text.html,\
+ javax.swing.text.html.parser,\
+ javax.swing.text.rtf,\
+ javax.swing.tree,\
+ javax.swing.undo,\
+ javax.tools,\
+ javax.transaction,\
+ javax.transaction.xa,\
+ javax.xml,\
+ javax.xml.bind,\
+ javax.xml.bind.annotation,\
+ javax.xml.bind.annotation.adapters,\
+ javax.xml.bind.attachment,\
+ javax.xml.bind.helpers,\
+ javax.xml.bind.util,\
+ javax.xml.crypto,\
+ javax.xml.crypto.dom,\
+ javax.xml.crypto.dsig,\
+ javax.xml.crypto.dsig.dom,\
+ javax.xml.crypto.dsig.keyinfo,\
+ javax.xml.crypto.dsig.spec,\
+ javax.xml.datatype,\
+ javax.xml.namespace,\
+ javax.xml.parsers,\
+ javax.xml.soap,\
+ javax.xml.stream,\
+ javax.xml.stream.events,\
+ javax.xml.stream.util,\
+ javax.xml.transform,\
+ javax.xml.transform.dom,\
+ javax.xml.transform.sax,\
+ javax.xml.transform.stax,\
+ javax.xml.transform.stream,\
+ javax.xml.validation,\
+ javax.xml.ws,\
+ javax.xml.ws.handler,\
+ javax.xml.ws.handler.soap,\
+ javax.xml.ws.http,\
+ javax.xml.ws.soap,\
+ javax.xml.ws.spi,\
+ javax.xml.xpath,\
+ org.ietf.jgss,\
+ org.omg.CORBA,\
+ org.omg.CORBA_2_3,\
+ org.omg.CORBA_2_3.portable,\
+ org.omg.CORBA.DynAnyPackage,\
+ org.omg.CORBA.ORBPackage,\
+ org.omg.CORBA.portable,\
+ org.omg.CORBA.TypeCodePackage,\
+ org.omg.CosNaming,\
+ org.omg.CosNaming.NamingContextExtPackage,\
+ org.omg.CosNaming.NamingContextPackage,\
+ org.omg.Dynamic,\
+ org.omg.DynamicAny,\
+ org.omg.DynamicAny.DynAnyFactoryPackage,\
+ org.omg.DynamicAny.DynAnyPackage,\
+ org.omg.IOP,\
+ org.omg.IOP.CodecFactoryPackage,\
+ org.omg.IOP.CodecPackage,\
+ org.omg.Messaging,\
+ org.omg.PortableInterceptor,\
+ org.omg.PortableInterceptor.ORBInitInfoPackage,\
+ org.omg.PortableServer,\
+ org.omg.PortableServer.CurrentPackage,\
+ org.omg.PortableServer.POAManagerPackage,\
+ org.omg.PortableServer.POAPackage,\
+ org.omg.PortableServer.portable,\
+ org.omg.PortableServer.ServantLocatorPackage,\
+ org.omg.SendingContext,\
+ org.omg.stub.java.rmi,\
+ org.w3c.dom,\
+ org.w3c.dom.bootstrap,\
+ org.w3c.dom.events,\
+ org.w3c.dom.ls,\
+ org.xml.sax,\
+ org.xml.sax.ext,\
+ org.xml.sax.helpers
+org.osgi.framework.bootdelegation = \
+ javax.*,\
+ org.ietf.jgss,\
+ org.omg.*,\
+ org.w3c.*,\
+ org.xml.*,\
+ sun.*,\
+ com.sun.*
+org.osgi.framework.executionenvironment = \
+ OSGi/Minimum-1.0,\
+ OSGi/Minimum-1.1,\
+ JRE-1.1,\
+ J2SE-1.2,\
+ J2SE-1.3,\
+ J2SE-1.4,\
+ J2SE-1.5,\
+ JavaSE-1.6
+osgi.java.profile.name = JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF
new file mode 100644
index 0000000000..41dcb9390e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF
@@ -0,0 +1,47 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Axiom API
+Bundle-SymbolicName: org.apache.ws.commons.axiom.axiom-api
+Bundle-Version: 1.2.7
+Bundle-ClassPath: axiom-api-1.2.7.jar
+Bundle-Vendor: Apache Software Foundation
+Export-Package: org.apache.axiom.attachments,
+ org.apache.axiom.attachments.impl,
+ org.apache.axiom.attachments.lifecycle,
+ org.apache.axiom.attachments.lifecycle.impl,
+ org.apache.axiom.attachments.utils,
+ org.apache.axiom.om,
+ org.apache.axiom.om.ds,
+ org.apache.axiom.om.ds.custombuilder,
+ org.apache.axiom.om.impl,
+ org.apache.axiom.om.impl.builder,
+ org.apache.axiom.om.impl.exception,
+ org.apache.axiom.om.impl.serialize,
+ org.apache.axiom.om.impl.traverse,
+ org.apache.axiom.om.impl.util,
+ org.apache.axiom.om.util,
+ org.apache.axiom.om.xpath,
+ org.apache.axiom.soap,
+ org.apache.axiom.soap.impl.builder
+Archiver-Version: Plexus Archiver
+Build-Jdk: 1.5.0_15
+Bundle-DocURL: http://www.apache.org/
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Built-By: dims
+Import-Package: javax.activation,
+ javax.mail,
+ javax.mail.internet,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.om.impl.llom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap11;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap12;resolution:=optional,
+ org.apache.commons.logging,
+ org.jaxen;resolution:=optional,
+ org.jaxen.saxpath;resolution:=optional,
+ org.jaxen.util;resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.helpers
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.8.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.8.MF
new file mode 100644
index 0000000000..671a7bff34
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.8.MF
@@ -0,0 +1,49 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Axiom API
+Bundle-SymbolicName: org.apache.ws.commons.axiom.axiom-api
+Bundle-Version: 1.2.8
+Bundle-Vendor: Apache Software Foundation
+Bundle-DocURL: http://www.apache.org/
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-ClassPath: axiom-api-1.2.8.jar
+Export-Package: org.apache.axiom.attachments,
+ org.apache.axiom.attachments.impl,
+ org.apache.axiom.attachments.lifecycle,
+ org.apache.axiom.attachments.lifecycle.impl,
+ org.apache.axiom.attachments.utils,
+ org.apache.axiom.om,
+ org.apache.axiom.om.ds,
+ org.apache.axiom.om.ds.custombuilder,
+ org.apache.axiom.om.impl,
+ org.apache.axiom.om.impl.builder,
+ org.apache.axiom.om.impl.exception,
+ org.apache.axiom.om.impl.serialize,
+ org.apache.axiom.om.impl.traverse,
+ org.apache.axiom.om.impl.util,
+ org.apache.axiom.om.util,
+ org.apache.axiom.om.xpath,
+ org.apache.axiom.soap,
+ org.apache.axiom.soap.impl.builder
+Archiver-Version: Plexus Archiver
+Build-Jdk: 1.5.0_15
+Created-By: Apache Maven
+Built-By: dims
+Import-Package: javax.activation,
+ javax.mail,
+ javax.mail.internet,
+ javax.xml.namespace,
+ javax.xml.stream,
+ javax.xml.stream.util,
+ org.apache.axiom.om.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.om.impl.llom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.dom.factory;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap11;resolution:=optional,
+ org.apache.axiom.soap.impl.llom.soap12;resolution:=optional,
+ org.apache.commons.logging,
+ org.jaxen;resolution:=optional,
+ org.jaxen.saxpath;resolution:=optional,
+ org.jaxen.util;resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.helpers
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF
new file mode 100644
index 0000000000..58630c02ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.5.1.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.5.1.MF
new file mode 100644
index 0000000000..107916e4f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.5.1.MF
@@ -0,0 +1,39 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.axis2.kernel
+Bundle-Name: org.apache.axis2.kernel
+Bundle-Version: 1.5.1
+DynamicImport-Package: javax.transaction;version="1.1",javax.transacti
+ on.xa;version="1.1",*
+Bundle-ClassPath: axis2-kernel-1.5.1.jar
+Export-Package: org.apache.axis2.dataretrieval;version=1.5.1,org.apach
+ e.axis2;version=1.5.1,org.apache.axis2.builder;version=1.5.1,org.apac
+ he.axis2.phaseresolver;version=1.5.1,org.apache.axis2.deployment.repo
+ sitory.util;version=1.5.1,org.apache.axis2.deployment;version=1.5.1,o
+ rg.apache.axis2.java.security;version=1.5.1,org.apache.axis2.engine;v
+ ersion=1.5.1,org.apache.axis2.context;version=1.5.1,org.apache.axis2.
+ addressing.i18n;version=1.5.1,org.apache.axis2.modules;version=1.5.1,
+ org.apache.axis2.addressing.metadata;version=1.5.1,org.apache.axis2.d
+ ataretrieval.client;version=1.5.1,org.apache.axis2.service;version=1.
+ 5.1,org.apache.axis2.description.java2wsdl.bytecode;version=1.5.1,org
+ .apache.axis2.i18n;version=1.5.1,org.apache.axis2.deployment.schedule
+ r;version=1.5.1,org.apache.axis2.description.java2wsdl;version=1.5.1,
+ org.apache.axis2.transport;version=1.5.1,org.apache.axis2.transport.h
+ ttp;version=1.5.1,org.apache.axis2.client;version=1.5.1,org.apache.ax
+ is2.wsdl;version=1.5.1,org.apache.axis2.util.threadpool;version=1.5.1
+ ,org.apache.axis2.client.async;version=1.5.1,org.apache.axis2.receive
+ rs;version=1.5.1,org.apache.axis2.util;version=1.5.1,org.apache.axis2
+ .namespace;version=1.5.1,org.apache.axis2.transport.http.util;version
+ =1.5.1,org.apache.axis2.context.externalize;version=1.5.1,org.apache.
+ axis2.addressing;version=1.5.1,org.apache.axis2.deployment.util;versi
+ on=1.5.1,org.apache.axis2.dispatchers;version=1.5.1,org.apache.axis2.
+ deployment.resolver;version=1.5.1,org.apache.axis2.clustering.configu
+ ration;version=1.5.1,org.apache.axis2.transaction;version=1.5.1,org.a
+ pache.axis2.clustering;version=1.5.1,org.apache.axis2.wsdl.util;versi
+ on=1.5.1,org.apache.axis2.clustering.context;version=1.5.1,org.apache
+ .axis2.builder.unknowncontent;version=1.5.1,org.apache.axis2.handlers
+ ;version=1.5.1,org.apache.axis2.addressing.wsdl;version=1.5.1,org.apa
+ che.axis2.classloader;version=1.5.1,org.apache.axis2.description;vers
+ ion=1.5.1
+Import-Package: javax.xml.ws
+Eclipse-ExtensibleAPI: true
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-transport-http-1.5.1.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-transport-http-1.5.1.MF
new file mode 100644
index 0000000000..efe4d924ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-transport-http-1.5.1.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.axis2.transport.http
+Bundle-Name: org.apache.axis2.transport.http
+Bundle-Version: 1.5.1
+DynamicImport-Package: javax.transaction;version="1.1",javax.transacti
+ on.xa;version="1.1",*
+Bundle-ClassPath: axis2-transport-http-1.5.1.jar
+Export-Package: org.apache.axis2.transport.http.server;version=1.5.1,o
+ rg.apache.axis2.transport.http;version=1.5.1,org.apache.axis2.transpo
+ rt.http.util;version=1.5.1
+Fragment-Host: org.apache.axis2.kernel;bunlde-version=1.5.1
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-agents-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-agents-1.3.2.MF
new file mode 100644
index 0000000000..17e352ad0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-agents-1.3.2.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.agents.memory;version="1.3.2"
+Bundle-Version: 1.3.2
+Bundle-Name: ode-agents
+Bundle-ManifestVersion: 2
+Premain-Class: org.apache.ode.agents.memory.SizingAgent
+Bundle-SymbolicName: ode-agents
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-api-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-api-1.3.2.MF
new file mode 100644
index 0000000000..c25ac992e1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-api-1.3.2.MF
@@ -0,0 +1,58 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.bpel.bdi.breaks;version="1.3.2",
+ org.apache.ode.bpel.common;version="1.3.2";
+ uses:="org.apache.ode.utils,
+ javax.xml.namespace,
+ org.apache.ode.utils.stl,
+ org.apache.ode.utils.msg,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.pmapi",
+ org.apache.ode.bpel.evar;version="1.3.2";
+ uses:="org.w3c.dom,javax.xml.namespace",
+ org.apache.ode.bpel.evt;version="1.3.2";
+ uses:="org.apache.ode.utils,
+ javax.xml.namespace,
+ org.apache.ode.bpel.common,
+ org.w3c.dom",
+ org.apache.ode.bpel.explang;version="1.3.2";
+ uses:="org.apache.ode.bpel.common,
+ org.apache.ode.bpel.o,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.apache.ode.utils.xsd",
+ org.apache.ode.bpel.iapi;version="1.3.2";
+ uses:="javax.wsdl,
+ javax.xml.namespace,
+ org.apache.ode.bpel.evt,
+ org.apache.ode.bpel.bdi.breaks,
+ org.apache.ode.utils,
+ org.w3c.dom",
+ org.apache.ode.bpel.jmx;version="1.3.2";
+ uses:="javax.management,org.apache.ode.bpel.evt,
+ javax.management.openmbean",
+ org.apache.ode.bpel.pmapi;version="1.3.2";
+ uses:="org.apache.ode.bpel.bdi.breaks,
+ org.apache.ode.bpel.common,
+ org.apache.ode.bpel.o,
+ javax.xml.namespace,
+ org.w3c.dom"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-bpel-api
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-bpel-api
+Import-Package: javax.management,
+ javax.management.openmbean,
+ javax.wsdl,
+ javax.xml.namespace,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.o;version="1.3.2",
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.msg;version="1.3.2",
+ org.apache.ode.utils.stl;version="1.3.2",
+ org.apache.ode.utils.xsd;version="1.3.2",
+ org.w3c.dom
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-compiler-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-compiler-1.3.2.MF
new file mode 100644
index 0000000000..2a42b9e941
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-compiler-1.3.2.MF
@@ -0,0 +1,170 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.bpel.compiler;version="1.3.2";
+ uses:="org.apache.ode.bpel.compiler.api,
+ org.apache.ode.bpel.compiler.bom,
+ org.apache.ode.bpel.o,
+ org.apache.ode.utils.msg,
+ org.apache.commons.logging,
+ org.apache.ode.utils,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.apache.ode.utils.xsl,
+ net.sf.saxon,
+ org.xml.sax,
+ javax.xml.transform,
+ org.apache.ode.utils.stl,
+ javax.wsdl,
+ org.apache.ode.utils.xsd,
+ org.apache.ode.utils.fs,
+ org.apache.xerces.xni.parser,
+ javax.xml.transform.dom,
+ org.apache.ode.bpel.compiler.wsdl,
+ javax.wsdl.xml,
+ javax.wsdl.factory,
+ org.apache.ode.bpel.elang.xpath10.compiler,
+ javax.wsdl.extensions,
+ org.apache.xerces.xni",
+ org.apache.ode.bpel.compiler.api;version="1.3.2";
+ uses:="org.apache.ode.utils.msg,
+ org.apache.ode.bpel.compiler.bom,
+ org.apache.ode.utils,
+ org.apache.ode.bpel.o,
+ javax.wsdl,
+ javax.xml.namespace",
+ org.apache.ode.bpel.compiler.bom;version="1.3.2";
+ uses:="org.w3c.dom,
+ javax.xml.namespace,
+ org.apache.ode.utils.stl,
+ org.apache.ode.bpel.compiler.api,
+ org.apache.ode.utils,
+ javax.wsdl.extensions,
+ org.apache.commons.logging,
+ org.xml.sax,
+ org.apache.xml.utils,
+ org.xml.sax.helpers",
+ org.apache.ode.bpel.compiler.wsdl;version="1.3.2";
+ uses:="org.apache.ode.utils.msg,
+ org.apache.ode.bpel.compiler.bom,
+ javax.wsdl.extensions,
+ org.apache.ode.utils,
+ com.ibm.wsdl.util.xml,
+ org.w3c.dom,
+ javax.xml.namespace,
+ javax.wsdl,
+ org.apache.ode.utils.stl,
+ javax.wsdl.xml,
+ javax.wsdl.factory,
+ com.ibm.wsdl.xml",
+ org.apache.ode.bpel.elang.xpath10.compiler;version="1.3.2";
+ uses:="org.apache.ode.bpel.compiler.api,
+ org.jaxen,
+ org.apache.ode.utils.xsl,
+ org.apache.ode.utils.msg,
+ javax.xml.namespace,
+ org.apache.ode.bpel.elang.xpath10.o,
+ org.apache.ode.utils,
+ javax.xml.transform,
+ org.apache.ode.bpel.o,
+ org.jaxen.expr,
+ org.apache.ode.bpel.compiler.bom,
+ net.sf.saxon,
+ org.jaxen.saxpath.helpers,
+ org.jaxen.saxpath,
+ org.w3c.dom,
+ org.apache.commons.logging,
+ javax.xml.transform.stream",
+ org.apache.ode.bpel.elang.xpath20.compiler;version="1.3.2";
+ uses:="org.apache.ode.utils,
+ javax.xml.xpath,
+ org.apache.ode.bpel.elang.xpath10.compiler,
+ org.apache.ode.bpel.compiler.api,
+ org.apache.ode.utils.xsl,
+ org.apache.ode.bpel.elang.xpath10.o,
+ javax.xml.transform,
+ org.apache.ode.bpel.o,
+ org.apache.ode.bpel.elang.xpath20.o,
+ javax.xml.namespace,
+ org.apache.ode.utils.msg,
+ org.w3c.dom,
+ net.sf.saxon.xpath,
+ net.sf.saxon.trans,
+ net.sf.saxon.expr,
+ net.sf.saxon.functions,
+ net.sf.saxon,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.compiler.bom,
+ net.sf.saxon.om",
+ org.apache.ode.bpel.elang.xquery10.compiler;version="1.3.2";
+ uses:="javax.xml.xpath,
+ org.apache.ode.bpel.elang.xpath20.compiler,
+ org.apache.ode.utils,
+ net.sf.saxon.dom,
+ net.sf.saxon.om,
+ net.sf.saxon.expr,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.apache.xml.utils,
+ org.apache.ode.utils.xsl,
+ org.apache.commons.logging,
+ org.apache.ode.utils.msg,
+ org.apache.ode.bpel.compiler.bom,
+ org.apache.ode.bpel.elang.xquery10.o,
+ org.apache.ode.bpel.elang.xpath20.o,
+ net.sf.saxon,
+ org.apache.ode.bpel.elang.xpath10.compiler,
+ org.apache.ode.bpel.compiler.api,
+ org.apache.ode.bpel.elang.xpath10.o,
+ javax.xml.transform,
+ org.apache.ode.bpel.o,
+ javax.xml.xquery,
+ net.sf.saxon.xqj"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-bpel-compiler
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-bpel-compiler
+Import-Package: com.ibm.wsdl.util.xml,
+ com.ibm.wsdl.xml,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.namespace,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
+ javax.xml.xpath,
+ javax.xml.xquery,
+ net.sf.saxon,
+ net.sf.saxon.dom,
+ net.sf.saxon.expr,
+ net.sf.saxon.functions,
+ net.sf.saxon.om,
+ net.sf.saxon.trans,
+ net.sf.saxon.xpath,
+ net.sf.saxon.xqj,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.elang.xpath10.o;version="1.3.2",
+ org.apache.ode.bpel.elang.xpath20.o;version="1.3.2",
+ org.apache.ode.bpel.elang.xquery10.o;version="1.3.2",
+ org.apache.ode.bpel.o;version="1.3.2",
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.fs;version="1.3.2",
+ org.apache.ode.utils.msg;version="1.3.2",
+ org.apache.ode.utils.stl;version="1.3.2",
+ org.apache.ode.utils.xsd;version="1.3.2",
+ org.apache.ode.utils.xsl;version="1.3.2",
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.apache.xml.utils,
+ org.jaxen,
+ org.jaxen.expr,
+ org.jaxen.saxpath,
+ org.jaxen.saxpath.helpers,
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.helpers
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-dao-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-dao-1.3.2.MF
new file mode 100644
index 0000000000..9e6388278b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-dao-1.3.2.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.bpel.dao;version="1.3.2";
+ uses:="org.w3c.dom,
+ org.apache.ode.bpel.common,
+ org.apache.ode.bpel.evt,
+ javax.xml.namespace,
+ javax.sql,
+ org.apache.ode.bpel.iapi"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-bpel-dao
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-bpel-dao
+Import-Package: javax.sql,
+ javax.xml.namespace,
+ org.apache.ode.bpel.common;version="1.3.2",
+ org.apache.ode.bpel.evt;version="1.3.2",
+ org.apache.ode.bpel.iapi;version="1.3.2",
+ org.w3c.dom
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-epr-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-epr-1.3.2.MF
new file mode 100644
index 0000000000..4159636f83
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-epr-1.3.2.MF
@@ -0,0 +1,79 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.bpel.common.evt;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ org.apache.ode.bpel.iapi,
+ org.apache.ode.bpel.evt,
+ org.apache.commons.lang",
+ org.apache.ode.bpel.epr;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ org.apache.ode.utils,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.apache.ode.bpel.iapi",
+ org.apache.ode.il;version="1.3.2";
+ uses:="javax.xml.stream,
+ org.apache.commons.logging,
+ org.apache.xmlbeans,
+ org.apache.ode.bpel.pmapi,
+ org.apache.axiom.om.impl.builder,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.apache.axiom.om,
+ javax.transaction,
+ org.apache.geronimo.transaction.manager,
+ org.apache.ode.bpel.iapi,
+ javax.xml.transform,
+ org.apache.ode.utils",
+ org.apache.ode.il.config;version="1.3.2";
+ uses:="org.apache.commons.logging,org.apache.ode.utils",
+ org.apache.ode.il.dbutil;version="1.3.2";
+ uses:="org.apache.ode.il.config,
+ org.apache.geronimo.connector.outbound.connectionmanagerconfig,
+ javax.naming,
+ org.apache.ode.utils.msg,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.dao,
+ org.apache.geronimo.connector.outbound.connectiontracking,
+ javax.resource.spi,
+ javax.sql,
+ org.apache.ode.utils,
+ javax.transaction,
+ org.apache.derby.jdbc,
+ org.apache.geronimo.transaction.manager,
+ org.apache.geronimo.connector.outbound,
+ org.tranql.connector.jdbc"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-bpel-epr
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-bpel-epr
+Import-Package: javax.naming,
+ javax.resource.spi,
+ javax.sql,
+ javax.transaction;version="1.1",
+ javax.xml.namespace,
+ javax.xml.stream,
+ javax.xml.transform,
+ org.apache.axiom.om,
+ org.apache.axiom.om.impl.builder,
+ org.apache.commons.lang,
+ org.apache.commons.logging,
+ org.apache.derby.jdbc,
+ org.apache.geronimo.connector.outbound,
+ org.apache.geronimo.connector.outbound.connectionmanagerconfig,
+ org.apache.geronimo.connector.outbound.connectiontracking,
+ org.apache.geronimo.transaction.manager,
+ org.apache.ode.bpel.dao;version="1.3.2",
+ org.apache.ode.dao.jpa;version="1.3.2",
+ org.apache.ode.bpel.evt;version="1.3.2",
+ org.apache.ode.bpel.iapi;version="1.3.2",
+ org.apache.ode.bpel.pmapi;version="1.3.2",
+ org.apache.ode.utils,
+ org.apache.ode.utils.msg,
+ org.apache.xmlbeans,
+ org.tranql.connector.jdbc,
+ org.w3c.dom
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-obj-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-obj-1.3.2.MF
new file mode 100644
index 0000000000..862d40c55f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-obj-1.3.2.MF
@@ -0,0 +1,40 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.bpel.elang.xpath10.o;version="1.3.2";
+ uses:="org.apache.ode.bpel.o,
+ org.apache.ode.utils,
+ javax.xml.namespace",
+ org.apache.ode.bpel.elang.xpath20.o;version="1.3.2";
+ uses:="org.apache.ode.bpel.elang.xpath10.o,
+ org.apache.ode.bpel.o,
+ net.sf.saxon.expr,
+ javax.xml.namespace",
+ org.apache.ode.bpel.elang.xquery10.o;version="1.3.2";
+ uses:="org.apache.ode.bpel.o,
+ org.apache.ode.bpel.elang.xpath20.o,
+ javax.xml.namespace",
+ org.apache.ode.bpel.o;version="1.3.2";
+ uses:="javax.xml.namespace,
+ org.apache.ode.utils,
+ org.w3c.dom,
+ org.xml.sax,
+ javax.wsdl,
+ org.apache.ode.utils.stl"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-bpel-obj
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-bpel-obj
+Import-Package: javax.wsdl,
+ javax.xml.namespace,
+ com.ibm.wsdl.util.xml,
+ com.ibm.wsdl.xml,
+ com.ibm.wsdl,
+ net.sf.saxon.expr,
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.stl;version="1.3.2",
+ org.w3c.dom,
+ org.xml.sax
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-runtime-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-runtime-1.3.2.MF
new file mode 100644
index 0000000000..15dc8ebe30
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-runtime-1.3.2.MF
@@ -0,0 +1,256 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.bpel.elang.xpath10.runtime;version="1.3.2";
+ uses:="org.jaxen.dom,
+ org.w3c.dom,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.common,
+ org.apache.ode.bpel.elang.xpath10.o,
+ org.apache.ode.bpel.explang,
+ org.jaxen,
+ org.apache.ode.bpel.o,
+ org.apache.ode.utils.xsl,
+ javax.xml.transform.dom,
+ javax.xml.namespace,
+ javax.xml.transform,
+ org.apache.ode.utils,
+ net.sf.saxon.dom,
+ org.apache.ode.utils.xsd,
+ net.sf.saxon,
+ org.apache.ode.utils.fs,
+ javax.xml.transform.stream",
+ org.apache.ode.bpel.elang.xpath20.runtime;version="1.3.2";
+ uses:="javax.xml.xpath,
+ org.apache.ode.bpel.common,
+ org.apache.ode.utils,
+ javax.xml.namespace,
+ org.w3c.dom,
+ org.apache.commons.httpclient,
+ org.apache.commons.logging,
+ net.sf.saxon.value,
+ org.apache.ode.bpel.elang.xpath20.o,
+ org.apache.ode.bpel.explang,
+ net.sf.saxon.dom,
+ org.apache.ode.bpel.o,
+ net.sf.saxon.type,
+ javax.xml.transform,
+ org.apache.ode.utils.xsl,
+ javax.xml.transform.dom,
+ org.apache.ode.bpel.elang.xpath10.o,
+ net.sf.saxon.trans,
+ org.apache.ode.utils.xsd,
+ net.sf.saxon,
+ org.apache.ode.bpel.elang.xpath20.compiler,
+ net.sf.saxon.xpath,
+ net.sf.saxon.pattern,
+ net.sf.saxon.om,
+ net.sf.saxon.expr,
+ org.apache.ode.utils.fs,
+ javax.xml.transform.stream",
+ org.apache.ode.bpel.elang.xquery10.runtime;version="1.3.2";
+ uses:="javax.xml.xpath,
+ org.apache.ode.utils,
+ net.sf.saxon.dom,
+ org.apache.ode.bpel.elang.xpath20.runtime,
+ net.sf.saxon.om,
+ net.sf.saxon.expr,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.apache.ode.utils.xsl,
+ net.sf.saxon.value,
+ org.apache.commons.logging,
+ org.apache.ode.utils.xsd,
+ org.apache.ode.bpel.common,
+ net.sf.saxon.trans,
+ org.apache.ode.bpel.elang.xquery10.o,
+ org.apache.ode.bpel.elang.xpath20.o,
+ net.sf.saxon,
+ org.apache.ode.bpel.elang.xpath10.o,
+ org.apache.ode.bpel.elang.xpath20.compiler,
+ javax.xml.transform,
+ org.apache.ode.bpel.explang,
+ org.apache.ode.bpel.o,
+ javax.xml.xquery,
+ net.sf.saxon.xqj",
+ org.apache.ode.bpel.engine;version="1.3.2";
+ uses:="org.apache.ode.bpel.dao,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.iapi,
+ javax.xml.namespace,
+ org.apache.ode.utils.msg,
+ org.apache.ode.bpel.runtime,
+ org.w3c.dom,
+ javax.wsdl,
+ org.apache.ode.utils,
+ org.apache.ode.bpel.intercept,
+ org.apache.ode.bpel.o,
+ org.apache.ode.bpel.evt,
+ org.apache.ode.bpel.common,
+ org.apache.ode.bpel.pmapi,
+ org.apache.ode.bpel.bdi.breaks,
+ org.apache.ode.bpel.runtime.breaks,
+ org.apache.ode.utils.uuid,
+ org.apache.ode.jacob.soup,
+ org.apache.ode.bpel.engine.extvar,
+ org.apache.ode.bpel.runtime.channels,
+ org.apache.ode.agents.memory,
+ org.apache.ode.bpel.explang,
+ org.apache.ode.jacob,
+ org.apache.ode.bpel.evar,
+ org.apache.ode.bpel.memdao,
+ org.apache.ode.jacob.vpu,
+ org.apache.ode.utils.stl,
+ org.apache.ode.utils.xsl,
+ org.apache.ode.bpel.engine.migration,
+ org.apache.commons.collections.comparators,
+ org.apache.xmlbeans,
+ org.apache.ode.bpel.evtproc,
+ javax.management",
+ org.apache.ode.bpel.engine.extvar;version="1.3.2";
+ uses:="org.w3c.dom,
+ javax.xml.namespace,
+ org.apache.ode.utils,
+ org.apache.ode.bpel.iapi,
+ org.apache.ode.bpel.evar,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.o",
+ org.apache.ode.bpel.engine.migration;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ org.apache.ode.bpel.dao,
+ org.apache.ode.bpel.engine,
+ org.apache.ode.bpel.common,
+ org.apache.ode.bpel.iapi,
+ org.apache.ode.bpel.o,
+ javax.xml.namespace,
+ javax.wsdl,
+ org.apache.ode.bpel.runtime,
+ org.apache.ode.jacob.soup,
+ org.apache.ode.jacob.vpu,
+ javax.sql,
+ org.apache.ode.utils",
+ org.apache.ode.bpel.evtproc;version="1.3.2";
+ uses:="org.apache.ode.bpel.pmapi,
+ org.apache.ode.bpel.iapi,
+ org.apache.ode.bpel.evt",
+ org.apache.ode.bpel.extvar.jdbc;version="1.3.2";
+ uses:="org.apache.ode.utils,
+ org.apache.ode.bpel.evar,
+ javax.xml.namespace,
+ org.w3c.dom,
+ org.apache.commons.logging,
+ javax.sql,
+ javax.naming",
+ org.apache.ode.bpel.intercept;version="1.3.2";
+ uses:="org.apache.ode.bpel.iapi,
+ javax.xml.namespace,
+ org.apache.ode.bpel.dao,
+ org.apache.ode.bpel.engine",
+ org.apache.ode.bpel.memdao;version="1.3.2";
+ uses:="org.apache.ode.bpel.dao,
+ javax.sql,
+ org.apache.ode.bpel.iapi,
+ org.apache.ode.bpel.common,
+ org.apache.ode.utils.stl,
+ org.apache.ode.bpel.evt,
+ org.apache.commons.logging,
+ javax.xml.namespace,
+ org.apache.ode.utils,
+ org.w3c.dom",
+ org.apache.ode.bpel.runtime;version="1.3.2";
+ uses:="org.apache.ode.bpel.o,
+ org.apache.ode.jacob,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.common,
+ org.apache.ode.bpel.explang,
+ org.apache.ode.bpel.evar,
+ org.apache.ode.bpel.runtime.channels,
+ org.w3c.dom,
+ org.apache.ode.bpel.evt,
+ javax.xml.namespace,
+ org.apache.ode.utils.msg,
+ org.apache.ode.utils,
+ org.apache.ode.jacob.vpu,
+ javax.wsdl,
+ org.apache.ode.utils.xsd,
+ org.apache.ode.utils.stl,
+ org.apache.ode.bpel.iapi",
+ org.apache.ode.bpel.runtime.breaks;version="1.3.2";
+ uses:="org.apache.ode.bpel.bdi.breaks,
+ org.apache.ode.bpel.evt",
+ org.apache.ode.bpel.runtime.channels;version="1.3.2";
+ uses:="org.apache.ode.jacob,
+ org.apache.commons.logging,
+ org.apache.ode.utils,
+ org.apache.ode.bpel.o,
+ org.w3c.dom,
+ javax.xml.namespace",
+ org.apache.ode.bpel.runtime.explang.konst;version="1.3.2";
+ uses:="org.apache.ode.utils.xsd,
+ org.apache.ode.bpel.common,
+ org.apache.ode.bpel.explang,
+ org.apache.ode.bpel.o,
+ org.w3c.dom",
+ org.apache.ode.bpel.runtime.monitor;version="1.3.2";
+ uses:="org.apache.ode.bpel.common,
+ org.apache.ode.bpel.o",
+ org.apache.ode.bpel.runtime.msgs;version="1.3.2";
+ uses:="org.apache.ode.utils.msg"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-bpel-runtime
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-bpel-runtime
+Import-Package: javax.management,
+ javax.naming,
+ javax.sql,
+ javax.wsdl,
+ javax.xml.namespace,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
+ javax.xml.xpath,
+ javax.xml.xquery,
+ net.sf.saxon,
+ net.sf.saxon.dom,
+ net.sf.saxon.expr,
+ net.sf.saxon.om,
+ net.sf.saxon.pattern,
+ net.sf.saxon.trans,
+ net.sf.saxon.type,
+ net.sf.saxon.value,
+ net.sf.saxon.xpath,
+ net.sf.saxon.xqj,
+ org.apache.commons.collections.comparators,
+ org.apache.commons.httpclient,
+ org.apache.commons.logging,
+ org.apache.ode.agents.memory;version="1.3.2",
+ org.apache.ode.bpel.bdi.breaks;version="1.3.2",
+ org.apache.ode.bpel.common;version="1.3.2",
+ org.apache.ode.bpel.dao;version="1.3.2",
+ org.apache.ode.bpel.elang.xpath10.o;version="1.3.2",
+ org.apache.ode.bpel.elang.xpath20.compiler;version="1.3.2",
+ org.apache.ode.bpel.elang.xpath20.o;version="1.3.2",
+ org.apache.ode.bpel.elang.xquery10.o;version="1.3.2",
+ org.apache.ode.bpel.evar;version="1.3.2",
+ org.apache.ode.bpel.evt;version="1.3.2",
+ org.apache.ode.bpel.explang;version="1.3.2",
+ org.apache.ode.bpel.iapi;version="1.3.2",
+ org.apache.ode.bpel.o;version="1.3.2",
+ org.apache.ode.bpel.pmapi;version="1.3.2",
+ org.apache.ode.jacob;version="1.3.2",
+ org.apache.ode.jacob.soup;version="1.3.2",
+ org.apache.ode.jacob.vpu;version="1.3.2",
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.fs;version="1.3.2",
+ org.apache.ode.utils.msg;version="1.3.2",
+ org.apache.ode.utils.stl;version="1.3.2",
+ org.apache.ode.utils.uuid;version="1.3.2",
+ org.apache.ode.utils.xsd;version="1.3.2",
+ org.apache.ode.utils.xsl;version="1.3.2",
+ org.apache.xmlbeans,
+ org.jaxen,
+ org.jaxen.dom,
+ org.w3c.dom
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-schemas-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-schemas-1.3.2.MF
new file mode 100644
index 0000000000..82f4a2732a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-schemas-1.3.2.MF
@@ -0,0 +1,40 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.bpel.dd;version="1.3.2";
+ uses:="javax.xml.stream,
+ org.apache.xmlbeans,
+ org.w3c.dom,
+ org.apache.xmlbeans.xml.stream,
+ javax.xml.namespace",
+ org.apache.ode.bpel.dd.impl;version="1.3.2";
+ uses:="org.apache.xmlbeans.impl.values,
+ org.apache.xmlbeans,
+ org.apache.ode.bpel.dd,
+ javax.xml.namespace",
+ org.apache.ode.bpel.pmapi;version="1.3.2";
+ uses:="javax.xml.stream,
+ org.apache.xmlbeans,
+ org.w3c.dom,
+ org.apache.xmlbeans.xml.stream,
+ javax.xml.namespace",
+ org.apache.ode.bpel.pmapi.impl;version="1.3.2";
+ uses:="org.apache.xmlbeans.impl.values,
+ org.apache.xmlbeans,
+ org.apache.ode.bpel.pmapi,
+ javax.xml.namespace"
+Private-Package: .
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-bpel-schemas
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.xmlbeans,
+ org.apache.xmlbeans.impl.values,
+ org.apache.xmlbeans.xml.stream,
+ org.w3c.dom
+Bundle-SymbolicName: ode-bpel-schemas
+Fragment-Host: ode-bpel-compiler;version="1.3.2"
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-store-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-store-1.3.2.MF
new file mode 100644
index 0000000000..5e15e872e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-bpel-store-1.3.2.MF
@@ -0,0 +1,97 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.store;version="1.3.2";
+ uses:="javax.xml.namespace,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.compiler,
+ org.apache.ode.utils,
+ javax.wsdl.factory,
+ org.apache.xmlbeans,
+ org.apache.ode.utils.fs,
+ org.apache.ode.bpel.iapi,
+ javax.wsdl,
+ org.apache.ode.bpel.compiler.wsdl,
+ javax.wsdl.xml,
+ org.apache.ode.bpel.dd,
+ org.apache.ode.bpel.o,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.xni,
+ org.apache.ode.bpel.compiler.api,
+ org.apache.ode.utils.msg,
+ org.w3c.dom,
+ org.apache.ode.bpel.evt,
+ org.hsqldb.jdbc,
+ org.apache.ode.store.hib,
+ org.apache.ode.il.config,
+ javax.sql,
+ org.apache.ode.store.jpa",
+ org.apache.ode.store.hib;version="1.3.2";
+ uses:="org.apache.ode.store,
+ org.apache.commons.logging,
+ org.hibernate,
+ javax.xml.namespace,
+ org.hibernate.connection,
+ javax.sql,
+ org.apache.ode.utils.msg,
+ org.hibernate.cfg,
+ org.apache.ode.bpel.iapi,
+ org.hibernate.dialect,
+ org.hibernate.classic,
+ org.apache.ode.daohib,
+ org.apache.ode.utils,
+ javax.transaction,
+ org.apache.ode.utils.stl",
+ org.apache.ode.store.jpa;version="1.3.2";
+ uses:="org.apache.ode.store,
+ org.apache.commons.logging,
+ javax.persistence,
+ javax.sql,
+ javax.transaction,
+ org.apache.ode.dao.jpa,
+ org.apache.ode.utils.stl,
+ javax.xml.namespace,
+ org.apache.openjpa.util,
+ org.apache.ode.bpel.iapi,
+ org.apache.openjpa.enhance"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-bpel-store
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-bpel-store
+Import-Package: javax.persistence,
+ javax.sql,
+ javax.transaction;version="1.1",
+ javax.wsdl,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.namespace,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.compiler;version="1.3.2",
+ org.apache.ode.bpel.compiler.api;version="1.3.2",
+ org.apache.ode.bpel.compiler.wsdl;version="1.3.2",
+ org.apache.ode.bpel.dd;version="1.3.2",
+ org.apache.ode.bpel.evt;version="1.3.2",
+ org.apache.ode.bpel.iapi;version="1.3.2",
+ org.apache.ode.bpel.o;version="1.3.2",
+ org.apache.ode.dao.jpa;version="1.3.2",
+ org.apache.ode.daohib;resolution:=optional,
+ org.apache.ode.il.config;version="1.3.2",
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.fs;version="1.3.2",
+ org.apache.ode.utils.msg;version="1.3.2",
+ org.apache.ode.utils.stl;version="1.3.2",
+ org.apache.openjpa.enhance,
+ org.apache.openjpa.util,
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.apache.xmlbeans,
+ org.hibernate;resolution:=optional,
+ org.hibernate.cfg;resolution:=optional,
+ org.hibernate.classic;resolution:=optional,
+ org.hibernate.connection;resolution:=optional,
+ org.hibernate.dialect;resolution:=optional,
+ org.hsqldb.jdbc;resolution:=optional,
+ org.w3c.dom
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-dao-hibernate-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-dao-hibernate-1.3.2.MF
new file mode 100644
index 0000000000..7621f3c99f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-dao-hibernate-1.3.2.MF
@@ -0,0 +1,83 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.daohib;version="1.3.2";
+ uses:="org.hibernate.connection,
+ org.hibernate,
+ org.apache.ode.utils,
+ javax.transaction,
+ org.hibernate.transaction,
+ org.hibernate.classic,
+ org.apache.commons.logging,
+ javax.sql,
+ org.hibernate.cfg,
+ org.apache.ode.utils.uuid,
+ org.apache.ode.daohib.bpel.hobj",
+ org.apache.ode.daohib.bpel;version="1.3.2";
+ uses:="org.apache.ode.bpel.dao,
+ org.apache.ode.daohib,
+ org.apache.ode.utils,
+ org.apache.ode.daohib.bpel.hobj,
+ org.w3c.dom,
+ org.xml.sax,
+ org.hibernate.dialect,
+ org.apache.commons.logging,
+ org.hibernate,
+ javax.sql,
+ javax.transaction,
+ org.apache.ode.bpel.common,
+ org.apache.ode.utils.stl,
+ org.apache.ode.bpel.evt,
+ org.apache.ode.ql.tree,
+ org.apache.ode.ql.tree.nodes,
+ javax.xml.namespace,
+ org.hibernate.criterion,
+ org.apache.ode.ql.eval.skel,
+ org.apache.ode.daohib.bpel.ql,
+ org.apache.ode.bpel.iapi,
+ org.hibernate.transform",
+ org.apache.ode.daohib.bpel.hobj;version="1.3.2";
+ uses:="javax.xml.namespace",
+ org.apache.ode.daohib.bpel.ql;version="1.3.2";
+ uses:="org.hibernate,
+ org.hibernate.criterion,
+ org.apache.ode.daohib.bpel.hobj,
+ org.apache.ode.ql.tree.nodes,
+ org.apache.ode.ql.eval.skel,
+ org.apache.commons.lang,
+ org.apache.ode.ql.tree,
+ org.apache.ode.ql,
+ org.apache.ode.utils"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-dao-hibernate
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-dao-hibernate
+Import-Package: javax.sql,
+ javax.transaction;version="1.1",
+ javax.xml.namespace,
+ org.apache.commons.lang,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.common;version="1.3.2",
+ org.apache.ode.bpel.dao;version="1.3.2",
+ org.apache.ode.bpel.evt;version="1.3.2",
+ org.apache.ode.bpel.iapi;version="1.3.2",
+ org.apache.ode.ql;version="1.3.2",
+ org.apache.ode.ql.eval.skel;version="1.3.2",
+ org.apache.ode.ql.tree;version="1.3.2",
+ org.apache.ode.ql.tree.nodes;version="1.3.2",
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.stl;version="1.3.2",
+ org.apache.ode.utils.uuid;version="1.3.2",
+ org.hibernate;resolution:=optional,
+ org.hibernate.cfg;resolution:=optional,
+ org.hibernate.classic;resolution:=optional,
+ org.hibernate.connection;resolution:=optional,
+ org.hibernate.criterion;resolution:=optional,
+ org.hibernate.dialect;resolution:=optional,
+ org.hibernate.transaction;resolution:=optional,
+ org.hibernate.transform;resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-dao-jpa-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-dao-jpa-1.3.2.MF
new file mode 100644
index 0000000000..a0cf9a138b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-dao-jpa-1.3.2.MF
@@ -0,0 +1,44 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.dao.jpa;version="1.3.2";
+ uses:="org.apache.ode.bpel.dao,
+ org.apache.ode.utils,
+ org.apache.openjpa.util,
+ org.apache.openjpa.enhance,
+ javax.persistence,
+ org.w3c.dom,
+ javax.transaction,
+ org.apache.commons.logging,
+ javax.sql,
+ org.apache.ode.bpel.common,
+ javax.xml.namespace,
+ org.apache.openjpa.persistence,
+ org.apache.ode.bpel.evt,
+ org.apache.openjpa.ee,
+ org.apache.ode.utils.uuid,
+ org.apache.ode.bpel.iapi"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-dao-jpa
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-dao-jpa
+Import-Package: javax.persistence,
+ javax.sql,
+ javax.transaction;version="1.1",
+ javax.xml.namespace,
+ org.apache.commons.logging,
+ org.apache.ode.bpel.common;version="1.3.2",
+ org.apache.ode.bpel.dao;version="1.3.2",
+ org.apache.ode.bpel.evt;version="1.3.2",
+ org.apache.ode.bpel.iapi;version="1.3.2",
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.uuid;version="1.3.2",
+ org.apache.openjpa.ee,
+ org.apache.openjpa.enhance,
+ org.apache.openjpa.persistence,
+ org.apache.openjpa.util,
+ org.w3c.dom
+Eclipse-RegisterBuddy: org.apache.openjpa.openjpa
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-jacob-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-jacob-1.3.2.MF
new file mode 100644
index 0000000000..da2344cd8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-jacob-1.3.2.MF
@@ -0,0 +1,46 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.jacob;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ org.apache.ode.jacob.vpu,org.apache.ode.utils",
+ org.apache.ode.jacob.classgen.testtypes;version="1.3.2",
+ org.apache.ode.jacob.examples.cell;version="1.3.2";
+ uses:="org.apache.ode.jacob,
+ org.apache.commons.logging",
+ org.apache.ode.jacob.examples.eratosthenes;version="1.3.2";
+ uses:="org.apache.ode.jacob,
+ org.apache.commons.logging,
+ org.apache.ode.jacob.soup,
+ org.apache.ode.jacob.vpu",
+ org.apache.ode.jacob.examples.sequence;version="1.3.2";
+ uses:="org.apache.ode.jacob",
+ org.apache.ode.jacob.examples.synch;version="1.3.2";
+ uses:="org.apache.ode.jacob,
+ org.apache.commons.logging,
+ org.apache.ode.jacob.soup,
+ org.apache.ode.jacob.vpu",
+ org.apache.ode.jacob.soup;version="1.3.2";
+ uses:="org.apache.ode.utils,
+ org.apache.ode.jacob",
+ org.apache.ode.jacob.vpu;version="1.3.2";
+ uses:="org.apache.ode.jacob,
+ org.apache.ode.jacob.soup,
+ org.apache.ode.utils,
+ org.apache.commons.logging,
+ org.apache.ode.utils.msg"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-jacob
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-jacob
+Import-Package: org.apache.commons.logging,
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.msg;version="1.3.2",
+ org.apache.ode.bpel.common;version="1.3.2",
+ org.apache.ode.bpel.o;version="1.3.2",
+ org.apache.ode.bpel.engine;version="1.3.2",
+ org.apache.ode.bpel.runtime.channels;version="1.3.2",
+ org.apache.ode.bpel.runtime;version="1.3.2"
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-jacob-ap-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-jacob-ap-1.3.2.MF
new file mode 100644
index 0000000000..5bacdc2f0f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-jacob-ap-1.3.2.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.jacob.ap;version="1.3.2";
+ uses:="com.sun.mirror.declaration,
+ com.sun.mirror.type,
+ com.sun.mirror.apt,
+ com.sun.mirror.util"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-jacob-ap
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-jacob-ap
+Import-Package: com.sun.mirror.apt;resolution:=optional,
+ com.sun.mirror.declaration;resolution:=optional,
+ com.sun.mirror.type;resolution:=optional,
+ com.sun.mirror.util;resolution:=optional
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-scheduler-simple-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-scheduler-simple-1.3.2.MF
new file mode 100644
index 0000000000..3154af5838
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-scheduler-simple-1.3.2.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.scheduler.simple;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ javax.sql,
+ org.apache.ode.utils,
+ org.apache.ode.utils.stl,
+ javax.transaction,
+ org.apache.ode.bpel.iapi"
+Private-Package: .
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-scheduler-simple
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Import-Package: javax.sql,
+ javax.transaction;version="1.1",
+ org.apache.commons.logging,
+ org.apache.ode.bpel.iapi;version="1.3.2",
+ org.apache.ode.utils;version="1.3.2",
+ org.apache.ode.utils.stl;version="1.3.2"
+Bundle-SymbolicName: ode-scheduler-simple
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-utils-1.3.2.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-utils-1.3.2.MF
new file mode 100644
index 0000000000..687d102cd9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/ode-utils-1.3.2.MF
@@ -0,0 +1,134 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.ode.utils;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ javax.xml.parsers,
+ javax.xml.transform.dom,
+ org.w3c.dom,
+ javax.xml.namespace,
+ org.xml.sax,
+ javax.xml.stream,
+ org.w3c.dom.ls,
+ javax.xml.transform,
+ javax.xml.transform.stream,
+ org.apache.xml.serialize,
+ org.apache.xerces.dom,
+ net.sf.saxon.om,
+ javax.xml.transform.sax,
+ org.apache.ode.utils.sax,
+ org.apache.commons.collections.map,
+ javax.sql,
+ org.apache.ode.utils.stl,
+ org.apache.axis2.util,
+ org.apache.axis2.transport.http,
+ org.apache.axis2.client,
+ org.apache.commons.httpclient.params,
+ org.apache.commons.httpclient,
+ org.apache.commons.httpclient.util,
+ org.apache.ode.utils.msg,
+ org.apache.xerces.jaxp,
+ org.apache.xerces.parsers",
+ org.apache.ode.utils.cli;version="1.3.2";
+ uses:="org.apache.ode.utils.fs,
+ org.apache.ode.utils.msg,
+ org.apache.log4j,
+ org.apache.ode.utils",
+ org.apache.ode.utils.fs;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ org.apache.ode.utils",
+ org.apache.ode.utils.http;version="1.3.2",
+ org.apache.ode.utils.jmx;version="1.3.2";
+ uses:="javax.management,
+ org.apache.commons.logging,
+ org.apache.ode.utils",
+ org.apache.ode.utils.msg;version="1.3.2",
+ org.apache.ode.utils.rmi;version="1.3.2";
+ uses:="org.apache.commons.logging",
+ org.apache.ode.utils.sax;version="1.3.2";
+ uses:="org.xml.sax,
+ org.apache.commons.logging,
+ org.apache.ode.utils.msg",
+ org.apache.ode.utils.stl;version="1.3.2",
+ org.apache.ode.utils.trax;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ javax.xml.transform",
+ org.apache.ode.utils.uuid;version="1.3.2";
+ uses:="org.apache.ode.utils",
+ org.apache.ode.utils.wsdl;version="1.3.2";
+ uses:="org.apache.ode.utils.msg,
+ org.w3c.dom,
+ javax.xml.namespace,
+ javax.wsdl.extensions.http,
+ org.apache.ode.utils.stl,
+ javax.wsdl.extensions.soap,
+ javax.wsdl,
+ javax.wsdl.extensions.mime,
+ javax.wsdl.extensions,
+ org.apache.ode.utils",
+ org.apache.ode.utils.xml.capture;version="1.3.2";
+ uses:="org.xml.sax,
+ org.apache.commons.logging,
+ org.apache.ode.utils",
+ org.apache.ode.utils.xsd;version="1.3.2";
+ uses:="org.apache.commons.logging,
+ org.apache.ode.utils,
+ org.apache.ode.utils.fs,
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.apache.ode.utils.msg,
+ javax.xml.namespace,
+ org.apache.xerces.xs,
+ org.w3c.dom.ls,
+ org.apache.xerces.dom,
+ org.w3c.dom,
+ org.apache.xerces.impl.xs",
+ org.apache.ode.utils.xsl;version="1.3.2";
+ uses:="org.apache.commons.collections.map,
+ javax.xml.transform,
+ javax.xml.transform.stream,
+ javax.xml.transform.dom,
+ org.w3c.dom,
+ javax.xml.namespace"
+Implementation-Title: Apache ODE
+Implementation-Version: 1.3.2
+Bundle-Name: ode-utils
+Implementation-Vendor: Apache Software Foundation
+Bundle-Version: 1.3.2
+Build-Jdk: 1.6.0_13
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: ode-utils
+Import-Package: javax.management,
+ javax.sql,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.http,
+ javax.wsdl.extensions.mime,
+ javax.wsdl.extensions.soap,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.sax,
+ javax.xml.transform.stream,
+ net.sf.saxon.om,
+ org.apache.axis2.client,
+ org.apache.axis2.transport.http,
+ org.apache.axis2.util,
+ org.apache.commons.collections.map,
+ org.apache.commons.httpclient,
+ org.apache.commons.httpclient.params,
+ org.apache.commons.httpclient.util,
+ org.apache.commons.logging,
+ org.apache.log4j,
+ org.apache.xerces.dom,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.jaxp,
+ org.apache.xerces.parsers,
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.xs,
+ org.apache.xml.serialize,
+ org.w3c.dom,
+ org.w3c.dom.ls,
+ org.xml.sax
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF
new file mode 100644
index 0000000000..c15bce67b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF
@@ -0,0 +1,226 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Built-By: dims
+Build-Jdk: 1.4.2_17
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Import-Package: com.ibm.wsdl.util,
+ com.ibm.wsdl.util.xml,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ org.apache.woden;version="1.0",
+ org.apache.woden.internal;version="1.0.0",
+ org.apache.woden.internal.resolver;version="1.0.0",
+ org.apache.woden.internal.schema;version="1.0.0",
+ org.apache.woden.internal.util;version="1.0.0",
+ org.apache.woden.internal.util.dom;version="1.0.0",
+ org.apache.woden.internal.wsdl20;version="1.0.0",
+ org.apache.woden.internal.wsdl20.assertions;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.http;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.rpc;version="1.0.0",
+ org.apache.woden.internal.wsdl20.extensions.soap;version="1.0.0",
+ org.apache.woden.internal.wsdl20.validation;version="1.0.0",
+ org.apache.woden.internal.xml;version="1.0.0",
+ org.apache.woden.internal.xpointer;version="1.0.0",
+ org.apache.woden.resolver;version="1.0",
+ org.apache.woden.schema;version="1.0",
+ org.apache.woden.tool.converter;version="1.0.0",
+ org.apache.woden.types;version="1.0",
+ org.apache.woden.wsdl20;version="1.0",
+ org.apache.woden.wsdl20.enumeration;version="1.0",
+ org.apache.woden.wsdl20.extensions;version="1.0",
+ org.apache.woden.wsdl20.extensions.http;version="1.0",
+ org.apache.woden.wsdl20.extensions.rpc;version="1.0",
+ org.apache.woden.wsdl20.extensions.soap;version="1.0",
+ org.apache.woden.wsdl20.fragids;version="1.0",
+ org.apache.woden.wsdl20.validation;version="1.0",
+ org.apache.woden.wsdl20.xml;version="1.0",
+ org.apache.woden.xml;version="1.0",
+ org.apache.woden.xpointer;version="1.0",
+ org.apache.ws.commons.schema,
+ org.apache.ws.commons.schema.resolver,
+ org.apache.ws.commons.schema.utils,
+ org.apache.xerces.parsers,
+ org.apache.xml.serialize,
+ org.w3c.dom,
+ org.xml.sax
+Export-Package: javax.xml.namespace,
+ org.apache.woden.internal;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.schema,
+ org.apache.xerces.parsers,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.resolver,
+ org.apache.woden.internal.schema,
+ javax.xml.parsers,
+ org.apache.woden.wsdl20.xml,
+ org.xml.sax,
+ org.apache.ws.commons.schema,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden.internal.xpointer,
+ org.apache.woden.internal.util.dom,
+ org.apache.ws.commons.schema.resolver,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.xpointer,
+ org.apache.woden.internal.wsdl20.validation,
+ org.apache.woden.wsdl20.enumeration,
+ org.apache.woden.types,
+ org.apache.woden.internal.resolver,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.resolver;version="1.0.0";
+ uses:="org.apache.ws.commons.schema.resolver,
+ org.xml.sax,
+ org.apache.xml.serialize,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.resolver,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.schema;version="1.0.0";
+ uses:="org.apache.woden.schema,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden",
+ org.apache.woden.internal.util;version="1.0.0",
+ org.apache.woden.internal.util.dom;version="1.0.0";
+ uses:="javax.xml.namespace,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.wsdl20;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.schema,
+ org.apache.woden.wsdl20.extensions.rpc,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.wsdl20.fragids,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.ws.commons.schema.utils,
+ org.apache.woden.internal.schema,
+ org.apache.woden.wsdl20.enumeration,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.types",
+ org.apache.woden.internal.wsdl20.assertions;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.validation,
+ javax.xml.namespace,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden,
+ org.apache.woden.resolver,
+ org.apache.woden.internal",
+ org.apache.woden.internal.wsdl20.extensions;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.woden.internal.wsdl20.extensions.soap,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal.wsdl20.extensions.rpc,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.wsdl20.extensions.soap,
+ org.apache.woden.internal.util",
+ org.apache.woden.internal.wsdl20.extensions.http;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.wsdl20.xml",
+ org.apache.woden.internal.wsdl20.extensions.rpc;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions",
+ org.apache.woden.internal.wsdl20.extensions.soap;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.internal.xml,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.internal.wsdl20,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.internal,
+ org.apache.woden.internal.wsdl20.extensions,
+ org.apache.woden.wsdl20.xml,
+ org.apache.woden.wsdl20.extensions.soap",
+ org.apache.woden.internal.wsdl20.validation;version="1.0.0";
+ uses:="org.apache.woden.wsdl20,
+ org.apache.woden.wsdl20.validation,
+ org.apache.woden.schema,
+ org.apache.woden.internal.wsdl20.assertions,
+ org.apache.ws.commons.schema,
+ javax.xml.namespace,
+ org.apache.woden,
+ org.apache.woden.wsdl20.extensions,
+ org.apache.woden.resolver,
+ org.apache.woden.internal,
+ org.apache.woden.types,
+ org.apache.woden.wsdl20.xml",
+ org.apache.woden.internal.xml;version="1.0.0";
+ uses:="org.apache.woden.wsdl20.extensions.http,
+ org.apache.woden.wsdl20.extensions.rpc,
+ javax.xml.namespace,
+ org.apache.woden.xml,
+ org.apache.woden,
+ org.apache.woden.internal.util,
+ org.apache.woden.internal",
+ org.apache.woden.internal.xpointer;version="1.0.0";
+ uses:="org.apache.woden.xpointer,
+ org.apache.woden.types,
+ org.w3c.dom,
+ org.apache.woden,
+ org.apache.woden.internal",
+ org.apache.woden.tool.converter;version="1.0.0";
+ uses:="javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.xml,
+ javax.wsdl.factory,
+ javax.xml.namespace,
+ com.ibm.wsdl.util,
+ com.ibm.wsdl.util.xml"
+Bundle-Version: 1.0.0
+Bundle-Description: The Woden project is a subproject of the Apache We
+ b Services Project to develop a Java class library for reading, ma
+ nipulating, creating and writing WSDL documents, initially to supp
+ ort WSDL 2.0 but with the longer term aim of supporting past, present
+ and future versions of WSDL. There are two main deliverables:
+ an API and an implementation. The Woden API consists of a set of J
+ ava interfaces. The WSDL 2.0-specific portion of the Woden API confor
+ ms to the W3C WSDL 2.0 specification. The implementation will be a
+ high performance implementation directly usable in other Apache p
+ rojects such as Axis2.
+Bundle-Name: Woden - DOM
+Bundle-DocURL: http://www.apache.org/
+Bundle-ManifestVersion: 2
+Bundle-Vendor: Apache Software Foundation
+Bundle-SymbolicName: org.apache.woden.woden-impl-dom
+
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/xercesImpl-2.9.0.MF b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/xercesImpl-2.9.0.MF
new file mode 100644
index 0000000000..c113563aed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/xercesImpl-2.9.0.MF
@@ -0,0 +1,421 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.html.dom;version="2.9.0";
+ uses:="org.apache.xerces.dom,
+ org.w3c.dom.html,
+ org.w3c.dom,
+ org.xml.sax",
+ org.apache.wml;version="2.9.0";
+ uses:="org.w3c.dom",
+ org.apache.wml.dom;version="2.9.0";
+ uses:="org.apache.wml,
+ org.apache.xerces.dom,org.w3c.dom",
+ org.apache.xerces.dom;version="2.9.0";
+ uses:="org.apache.xerces.parsers,
+ org.apache.xerces.dom3.as,
+ org.w3c.dom,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.xs,
+ org.apache.xerces.xni,
+ org.apache.xerces.impl.dv.xs,
+ org.apache.xerces.impl,
+ org.apache.xerces.impl.dtd,
+ org.apache.xerces.util,
+ org.w3c.dom.ls,
+ org.apache.xml.serialize,
+ org.w3c.dom.events,
+ org.apache.xerces.xni.grammars,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.impl.validation,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.impl.msg,
+ org.apache.xerces.impl.xs.util,
+ org.apache.xerces.dom.events,
+ org.w3c.dom.traversal,
+ org.w3c.dom.ranges",
+ org.apache.xerces.dom.events;version="2.9.0";
+ uses:="org.w3c.dom.events,org.w3c.dom",
+ org.apache.xerces.dom3.as;version="2.9.0";
+ uses:="org.w3c.dom,org.w3c.dom.ls",
+ org.apache.xerces.impl;version="2.9.0";
+ uses:="org.apache.xerces.xni.grammars,
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.util,
+ org.apache.xerces.impl.dtd,
+ org.apache.xerces.impl.io,
+ org.apache.xerces.impl.validation,
+ org.xml.sax",
+ org.apache.xerces.impl.dtd;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.xni,
+ org.apache.xerces.impl.validation,
+ org.apache.xerces.xni.grammars,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.impl.dtd.models,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.impl,
+ org.apache.xerces.impl.msg",
+ org.apache.xerces.impl.dtd.models;version="2.9.0";
+ uses:="org.apache.xerces.xni",
+ org.apache.xerces.impl.dv;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.xs,
+ org.apache.xerces.impl.xs.util",
+ org.apache.xerces.impl.dv.dtd;version="2.9.0";
+ uses:="org.apache.xerces.impl.dv,
+ org.apache.xerces.util",
+ org.apache.xerces.impl.dv.util;version="2.9.0";
+ uses:="org.apache.xerces.xs,
+ org.apache.xerces.xs.datatypes",
+ org.apache.xerces.impl.dv.xs;version="2.9.0";
+ uses:="org.apache.xerces.xs.datatypes,
+ javax.xml.datatype,
+ org.apache.xerces.jaxp.datatype,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.util,
+ org.apache.xerces.impl.dv.util,
+ org.apache.xerces.xs,
+ org.apache.xerces.xni,
+ javax.xml.namespace,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.impl.xs.util,
+ org.apache.xerces.impl.xpath.regex,
+ org.w3c.dom",
+ org.apache.xerces.impl.io;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.impl.msg",
+ org.apache.xerces.impl.msg;version="2.9.0";
+ uses:="org.apache.xerces.util",
+ org.apache.xerces.impl.validation;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.xni",
+ org.apache.xerces.impl.xpath;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.xni",
+ org.apache.xerces.impl.xpath.regex;version="2.9.0",
+ org.apache.xerces.impl.xs;version="2.9.0";
+ uses:="org.apache.xerces.xs,
+ org.apache.xerces.impl.xs.util,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.util,
+ org.apache.xerces.xni.grammars,
+ org.apache.xerces.parsers,
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.xml.sax,
+ org.apache.xerces.impl.xs.identity,
+ org.w3c.dom,
+ org.apache.xerces.impl.xs.opti,
+ org.apache.xerces.impl.xs.traversers,
+ org.w3c.dom.ls,
+ org.apache.xerces.impl.xs.models,
+ org.apache.xerces.dom,
+ org.apache.xerces.impl,
+ javax.xml.namespace,
+ org.apache.xerces.impl.validation,
+ org.apache.xerces.impl.dv.xs",
+ org.apache.xerces.impl.xs.identity;version="2.9.0";
+ uses:="org.apache.xerces.xs,
+ org.apache.xerces.impl.xs.util,
+ org.apache.xerces.impl.xpath,
+ org.apache.xerces.util,
+ org.apache.xerces.xni,
+ org.apache.xerces.impl.xs",
+ org.apache.xerces.impl.xs.models;version="2.9.0";
+ uses:="org.apache.xerces.xs,
+ org.apache.xerces.impl.dtd.models,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.util,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.impl,
+ org.apache.xerces.xni",
+ org.apache.xerces.impl.xs.opti;version="2.9.0";
+ uses:="org.w3c.dom,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.xni,
+ org.apache.xerces.util,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.impl,
+ org.apache.xerces.xni.grammars,
+ org.apache.xerces.parsers,
+ org.apache.xerces.impl.validation,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.impl.msg",
+ org.apache.xerces.impl.xs.traversers;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.impl.xs.opti,
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.w3c.dom,
+ org.xml.sax.helpers,
+ org.xml.sax,
+ org.apache.xerces.xs,
+ org.apache.xerces.impl.validation,
+ org.apache.xerces.impl.xs.util,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.impl.xs.identity,
+ org.apache.xerces.impl.xpath,
+ org.apache.xerces.xni.grammars,
+ org.apache.xerces.parsers,
+ org.apache.xerces.impl,
+ org.apache.xerces.impl.dv.xs",
+ org.apache.xerces.impl.xs.util;version="2.9.0";
+ uses:="org.apache.xerces.xs,
+ org.apache.xerces.xni,
+ org.apache.xerces.util,
+ org.apache.xerces.xni.grammars,
+ org.apache.xerces.impl.xs",
+ org.apache.xerces.jaxp;version="2.9.0";
+ uses:="org.xml.sax.helpers,
+ org.xml.sax,
+ org.apache.xerces.util,
+ org.apache.xerces.parsers,
+ javax.xml.parsers,
+ javax.xml.validation,
+ org.apache.xerces.jaxp.validation,
+ org.apache.xerces.xni.parser,
+ org.w3c.dom,
+ org.apache.xerces.impl.validation,
+ org.apache.xerces.dom,
+ org.apache.xerces.xni,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.impl,
+ org.w3c.dom.ls,
+ org.apache.xerces.impl.xs.opti,
+ org.apache.xerces.xs,
+ org.apache.xerces.xni.grammars",
+ org.apache.xerces.jaxp.datatype;version="2.9.0";
+ uses:="javax.xml.datatype,
+ org.apache.xerces.util,
+ javax.xml.namespace",
+ org.apache.xerces.jaxp.validation;version="2.9.0";
+ uses:="org.apache.xerces.xni.grammars,
+ javax.xml.validation,
+ org.apache.xerces.xni,
+ javax.xml.transform.dom,
+ org.w3c.dom,
+ org.apache.xerces.xs,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.dom,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.util,
+ org.apache.xerces.impl.xs.util,
+ javax.xml.parsers,
+ org.xml.sax,
+ org.apache.xerces.impl.validation,
+ javax.xml.transform,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.impl,
+ org.apache.xerces.parsers,
+ javax.xml.transform.stream,
+ org.apache.xerces.impl.msg,
+ org.w3c.dom.ls,
+ org.xml.sax.ext,
+ javax.xml.transform.sax",
+ org.apache.xerces.parsers;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.xs,
+ org.w3c.dom.ls,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.dom,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.xni,
+ org.w3c.dom,
+ org.xml.sax.helpers,
+ org.xml.sax.ext,
+ org.xml.sax,
+ org.apache.xerces.xni.grammars,
+ org.apache.xerces.impl.xs,
+ org.apache.xerces.dom3.as,
+ org.apache.xerces.impl,
+ org.apache.xerces.impl.dtd,
+ org.apache.xerces.impl.validation,
+ org.apache.xerces.impl.msg,
+ org.apache.xerces.xinclude,
+ org.apache.xerces.xpointer",
+ org.apache.xerces.util;version="2.9.0";
+ uses:="org.xml.sax.ext,
+ org.apache.xerces.xni,
+ org.xml.sax,
+ org.w3c.dom.ls,
+ org.apache.xerces.xni.grammars,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.dom,
+ org.w3c.dom,
+ org.apache.xerces.impl.xs.opti,
+ org.apache.xerces.impl,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ org.apache.xml.resolver.readers,
+ org.apache.xerces.jaxp,
+ org.apache.xml.resolver",
+ org.apache.xerces.xinclude;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.impl.io,
+ org.apache.xerces.xpointer,
+ org.apache.xerces.impl",
+ org.apache.xerces.xni;version="2.9.0";
+ uses:="org.apache.xerces.xni.parser",
+ org.apache.xerces.xni.grammars;version="2.9.0";
+ uses:="org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.xs",
+ org.apache.xerces.xni.parser;version="2.9.0";
+ uses:="org.apache.xerces.xni",
+ org.apache.xerces.xpointer;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.apache.xerces.xni,
+ org.apache.xerces.xni.parser,
+ org.apache.xerces.impl,
+ org.apache.xerces.xs,
+ org.apache.xerces.impl.dv,
+ org.apache.xerces.xinclude",
+ org.apache.xerces.xs;version="2.9.0";
+ uses:="org.w3c.dom.ls,
+ org.w3c.dom",
+ org.apache.xerces.xs.datatypes;version="2.9.0";
+ uses:="org.apache.xerces.xs,
+ javax.xml.datatype,
+ org.apache.xerces.xni,
+ javax.xml.namespace",
+ org.apache.xml.serialize;version="2.9.0";
+ uses:="org.apache.xerces.util,
+ org.w3c.dom.ls,
+ org.xml.sax.ext,
+ org.apache.xerces.dom,
+ org.w3c.dom.traversal,
+ org.w3c.dom,
+ org.xml.sax,
+ org.apache.xerces.impl,
+ sun.io,
+ org.w3c.dom.html,
+ org.apache.xerces.xni,
+ org.xml.sax.helpers",
+ org.w3c.dom.html;version="2.9.0";
+ uses:="org.w3c.dom"
+Ant-Version: Apache Ant version 1.6.5 compiled on June 2 2005
+Bundle-Version: 2.9.0
+Bundle-Name: xercesImpl
+Bundle-ManifestVersion: 2
+Import-Package: javax.xml.datatype;resolution:=optional,
+ javax.xml.namespace;resolution:=optional,
+ javax.xml.parsers;resolution:=optional,
+ javax.xml.transform;resolution:=optional,
+ javax.xml.transform.dom;resolution:=optional,
+ javax.xml.transform.sax;resolution:=optional,
+ javax.xml.transform.stream;resolution:=optional,
+ javax.xml.validation;resolution:=optional,
+ org.apache.xml.resolver;resolution:=optional,
+ org.apache.xml.resolver.readers;resolution:=optional,
+ org.w3c.dom;resolution:=optional,
+ org.w3c.dom.events;resolution:=optional,
+ org.w3c.dom.html;resolution:=optional,
+ org.w3c.dom.ls;resolution:=optional,
+ org.w3c.dom.ranges;resolution:=optional,
+ org.w3c.dom.traversal;resolution:=optional,
+ org.xml.sax;resolution:=optional,
+ org.xml.sax.ext;resolution:=optional,
+ org.xml.sax.helpers;resolution:=optional,
+ sun.io;resolution:=optional
+Bundle-SymbolicName: xercesImpl
+Name: javax/xml/datatype/
+Implementation-Vendor: Apache Software Foundation
+Implementation-Title: javax.xml.datatype
+Implementation-Version: 1.3.03
+Specification-Vendor: Sun Microsystems Inc.
+Specification-Title: Java API for XML Processing
+Implementation-URL: http://xml.apache.org/commons/
+Specification-Version: 1.3
+Comment: based on xml-commons external 1.3.03
+
+Name: org/apache/xerces/xni/
+Implementation-Vendor: Apache Software Foundation
+Implementation-Title: org.apache.xerces.xni
+Implementation-Version: 1.2
+Specification-Vendor: Apache Software Foundation
+Specification-Title: Xerces Native Interface
+Implementation-URL: http://xerces.apache.org/xerces2-j/
+Specification-Version: 1.2
+Comment: Xerces Native Interface
+
+Name: javax/xml/parsers/
+Implementation-Vendor: Apache Software Foundation
+Implementation-Title: javax.xml.parsers
+Implementation-Version: 1.3.03
+Specification-Vendor: Sun Microsystems Inc.
+Specification-Title: Java API for XML Processing
+Implementation-URL: http://xml.apache.org/commons/
+Specification-Version: 1.3
+Comment: based on xml-commons external 1.3.03
+
+Name: org/w3c/dom/ls/
+Implementation-Vendor: World Wide Web Consortium
+Implementation-Title: org.w3c.dom.ls
+Implementation-Version: 1.0
+Specification-Vendor: World Wide Web Consortium
+Specification-Title: Document Object Model, Level 3 Load and Save
+Implementation-URL: http://www.w3c.org/DOM/
+Specification-Version: 1.0
+Comment: based on xml-commons external 1.3.03
+
+Name: javax/xml/transform/
+Implementation-Vendor: Apache Software Foundation
+Implementation-Title: javax.xml.transform
+Implementation-Version: 1.3.03
+Specification-Vendor: Sun Microsystems Inc.
+Specification-Title: Java API for XML Processing
+Implementation-URL: http://xml.apache.org/commons/
+Specification-Version: 1.3
+Comment: based on xml-commons external 1.3.03
+
+Name: org/xml/sax/
+Implementation-Vendor: David Megginson
+Implementation-Title: org.xml.sax
+Implementation-Version: 2.0.2
+Specification-Vendor: David Megginson
+Specification-Title: Simple API for XML
+Implementation-URL: http://www.saxproject.org/
+Specification-Version: 2.0.2
+Comment: based on xml-commons external 1.3.03
+
+Name: org/w3c/dom/
+Implementation-Vendor: World Wide Web Consortium
+Implementation-Title: org.w3c.dom
+Implementation-Version: 1.0
+Specification-Vendor: World Wide Web Consortium
+Specification-Title: Document Object Model, Level 3 Core
+Implementation-URL: http://www.w3c.org/DOM/
+Specification-Version: 1.0
+Comment: based on xml-commons external 1.3.03
+
+Name: org/apache/xerces/impl/Version.class
+Implementation-Vendor: Apache Software Foundation
+Implementation-Title: org.apache.xerces.impl.Version
+Implementation-Version: 2.9.0
+Implementation-URL: http://xerces.apache.org/xerces2-j/
+Comment: Xerces-J 2.9.0
+
+Name: javax/xml/xpath/
+Implementation-Vendor: Apache Software Foundation
+Implementation-Title: javax.xml.xpath
+Implementation-Version: 1.3.03
+Specification-Vendor: Sun Microsystems Inc.
+Specification-Title: Java API for XML Processing
+Implementation-URL: http://xml.apache.org/commons/
+Specification-Version: 1.3
+Comment: based on xml-commons external 1.3.03
+
+Name: javax/xml/validation/
+Implementation-Vendor: Apache Software Foundation
+Implementation-Title: javax.xml.validation
+Implementation-Version: 1.3.03
+Specification-Vendor: Sun Microsystems Inc.
+Specification-Title: Java API for XML Processing
+Implementation-URL: http://xml.apache.org/commons/
+Specification-Version: 1.3
+Comment: based on xml-commons external 1.3.03
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/LICENSE b/sandbox/sebastien/java/embed/modules/node-launcher/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/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/sebastien/java/embed/modules/node-launcher/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/node-launcher/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..84d7ba01d8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.node.launcher;uses:="javax.serv
+ let";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Node Launcher
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Node Launcher
+Import-Package: javax.servlet,org.apache.tuscany.sca.node.launcher;ver
+ sion="2.0.0",org.apache.commons.cli;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.node.launcher
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/NOTICE b/sandbox/sebastien/java/embed/modules/node-launcher/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/pom.xml b/sandbox/sebastien/java/embed/modules/node-launcher/pom.xml
new file mode 100644
index 0000000000..4ae3dac803
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/pom.xml
@@ -0,0 +1,64 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-node-launcher</artifactId>
+ <name>Apache Tuscany SCA Node Launcher</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.tuscany.sca.node.launcher.NodeMain</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java
new file mode 100644
index 0000000000..4f4f861e2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.node.launcher;
+
+/**
+ * Represents an SCA contribution uri + location.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class Contribution {
+ private String uri;
+ private String location;
+
+ /**
+ * Constructs a new SCA contribution.
+ *
+ * @param uri
+ * @param location
+ */
+ public Contribution(String uri, String location) {
+ this.uri = uri;
+ this.location = location;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java
new file mode 100644
index 0000000000..ba795216a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.launcher;
+
+import static org.apache.tuscany.sca.node.launcher.NodeLauncherUtil.domainManager;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Simple launcher for the SCA domain manager.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DomainManagerLauncher {
+
+ static final Logger logger = Logger.getLogger(DomainManagerLauncher.class.getName());
+
+ /**
+ * Constructs a new DomainManagerLauncher.
+ */
+ private DomainManagerLauncher() {
+ }
+
+ /**
+ * Returns a new launcher instance.
+ *
+ * @return a new launcher instance
+ */
+ public static DomainManagerLauncher newInstance() {
+ return new DomainManagerLauncher();
+ }
+
+ /**
+ * Creates a new DomainManager.
+ *
+ * @return a new DomainManager
+ * @throws LauncherException
+ */
+ public <T> T createDomainManager() throws LauncherException {
+ return (T)domainManager(".");
+ }
+
+ /**
+ * Creates a new DomainManager.
+ *
+ * @param rootDirectory the domain's root configuration directory
+ *
+ * @return a new DomainManager
+ * @throws LauncherException
+ */
+ public <T> T createDomainManager(String rootDirectory) throws LauncherException {
+ return (T)domainManager(rootDirectory);
+ }
+
+ public static void main(String[] args) throws Exception {
+ logger.info("Apache Tuscany SCA Domain Manager is starting...");
+
+ // Create a launcher
+ DomainManagerLauncher launcher = newInstance();
+
+ Object domainManager = null;
+ ShutdownThread shutdown = null;
+ try {
+ while (true) {
+
+ // Start the domain manager
+ domainManager = launcher.createDomainManager();
+ try {
+ domainManager.getClass().getMethod("start").invoke(domainManager);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Domain Manager could not be started", e);
+ throw e;
+ }
+ logger.info("SCA Domain Manager is now started.");
+
+ // Install a shutdown hook
+ shutdown = new ShutdownThread(domainManager);
+ Runtime.getRuntime().addShutdownHook(shutdown);
+
+ logger.info("Press 'q' to quit, 'r' to restart.");
+ int k = 0;
+ try {
+ while ((k != 'q') && (k != 'r')) {
+ k = System.in.read();
+ }
+ } catch (IOException e) {
+
+ // Wait forever
+ Object lock = new Object();
+ synchronized(lock) {
+ lock.wait();
+ }
+ }
+
+ // Stop the domain manager
+ if (domainManager != null) {
+ Object dm = domainManager;
+ domainManager = null;
+ stopDomainManager(dm);
+ }
+
+ // Quit
+ if (k == 'q' ) {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ // Stop the domain manager
+ if (domainManager != null) {
+ try {
+ Object dm = domainManager;
+ domainManager = null;
+ stopDomainManager(dm);
+ } catch (Exception e2) {
+ }
+ }
+ throw e;
+
+ } finally {
+
+ // Remove the shutdown hook
+ if (shutdown != null) {
+ Runtime.getRuntime().removeShutdownHook(shutdown);
+ }
+ }
+ }
+
+ /**
+ * Stop the given domain manager.
+ *
+ * @param domainManager
+ * @throws Exception
+ */
+ private static void stopDomainManager(Object domainManager) throws Exception {
+ try {
+ domainManager.getClass().getMethod("stop").invoke(domainManager);
+ logger.info("SCA Domain Manager is now stopped.");
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Domain Manager could not be stopped", e);
+ throw e;
+ }
+ }
+
+ private static class ShutdownThread extends Thread {
+ private Object domainManager;
+
+ public ShutdownThread(Object domainManager) {
+ super();
+ this.domainManager = domainManager;
+ }
+
+ @Override
+ public void run() {
+ try {
+ stopDomainManager(domainManager);
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/LauncherException.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/LauncherException.java
new file mode 100644
index 0000000000..39e8d81139
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/LauncherException.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.node.launcher;
+
+
+/**
+ * Denotes an error launching an SCA domain manager or node.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LauncherException extends Exception {
+ private static final long serialVersionUID = 4581189418849190567L;
+
+ public LauncherException() {
+ super();
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public LauncherException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ */
+ public LauncherException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public LauncherException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeDaemonLauncher.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeDaemonLauncher.java
new file mode 100644
index 0000000000..56be9f9921
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeDaemonLauncher.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.launcher;
+
+import static org.apache.tuscany.sca.node.launcher.NodeLauncherUtil.nodeDaemon;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * A launcher for the SCA Node daemon.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeDaemonLauncher {
+
+ static final Logger logger = Logger.getLogger(NodeDaemonLauncher.class.getName());
+
+ /**
+ * Constructs a new node daemon launcher.
+ */
+ private NodeDaemonLauncher() {
+ }
+
+ /**
+ * Returns a new launcher instance.
+ *
+ * @return a new launcher instance
+ */
+ public static NodeDaemonLauncher newInstance() {
+ return new NodeDaemonLauncher();
+ }
+
+ /**
+ * Creates a new node daemon.
+ *
+ * @param
+ * @return a new node daemon
+ * @throws LauncherException
+ */
+ public <T> T createNodeDaemon() throws LauncherException {
+ return (T)nodeDaemon();
+ }
+
+ public static void main(String[] args) throws Exception {
+ logger.info("Apache Tuscany SCA Node Daemon is starting...");
+
+ // Create a node launcher
+ NodeDaemonLauncher launcher = newInstance();
+
+ Object node = null;
+ ShutdownThread shutdown = null;
+ try {
+ while (true) {
+
+ // Start the node
+ node = launcher.createNodeDaemon();
+ try {
+ node.getClass().getMethod("start").invoke(node);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node Daemon could not be started", e);
+ throw e;
+ }
+ logger.info("SCA Node Daemon is now started.");
+
+ // Install a shutdown hook
+ shutdown = new ShutdownThread(node);
+ Runtime.getRuntime().addShutdownHook(shutdown);
+
+ logger.info("Press 'q' to quit, 'r' to restart.");
+ int k = 0;
+ try {
+ while ((k != 'q') && (k != 'r')) {
+ k = System.in.read();
+ }
+ } catch (IOException e) {
+
+ // Wait forever
+ Object lock = new Object();
+ synchronized(lock) {
+ lock.wait();
+ }
+ }
+
+ // Stop the node
+ if (node != null) {
+ Object n = node;
+ node = null;
+ stopNode(n);
+ }
+
+ // Quit
+ if (k == 'q' ) {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ // Stop the node
+ if (node != null) {
+ try {
+ Object n = node;
+ node = null;
+ stopNode(n);
+ } catch (Exception e2) {
+ }
+ }
+ throw e;
+
+ } finally {
+
+ // Remove the shutdown hook
+ if (shutdown != null) {
+ Runtime.getRuntime().removeShutdownHook(shutdown);
+ }
+ }
+ }
+
+ /**
+ * Stop the given node.
+ *
+ * @param node
+ * @throws Exception
+ */
+ private static void stopNode(Object node) throws Exception {
+ try {
+ node.getClass().getMethod("stop").invoke(node);
+ logger.info("SCA Node Daemon is now stopped.");
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node Daemon could not be stopped", e);
+ throw e;
+ }
+ }
+
+ private static class ShutdownThread extends Thread {
+ private Object node;
+
+ public ShutdownThread(Object node) {
+ super();
+ this.node = node;
+ }
+
+ @Override
+ public void run() {
+ try {
+ stopNode(node);
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java
new file mode 100644
index 0000000000..36fa9e6a21
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.launcher;
+
+import static org.apache.tuscany.sca.node.launcher.NodeLauncherUtil.node;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+
+/**
+ * A launcher for SCA nodes in JSE.
+ *
+ * Agruments:
+ * [-c <compositeURI>]: The composite URI
+ * [-t <ttl>]: Time to live in milliseconds before the node is started
+ * contribution1 ... contributionN: A list of contribution files or URLs
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeLauncher {
+
+ static final Logger logger = Logger.getLogger(NodeLauncher.class.getName());
+
+ /**
+ * Constructs a new node launcher.
+ */
+ private NodeLauncher() {
+ }
+
+ /**
+ * Returns a new launcher instance.
+ *
+ * @return a new launcher instance
+ */
+ public static NodeLauncher newInstance() {
+ return new NodeLauncher();
+ }
+
+ /**
+ * Creates a new SCA node from the configuration URL
+ *
+ * @param configurationURL the URL of the node configuration which is the ATOM feed
+ * that contains the URI of the composite and a collection of URLs for the contributions
+ *
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNodeFromURL(String configurationURL) throws LauncherException {
+ return (T)node(configurationURL, null, null, null, null);
+ }
+
+ /**
+ * Creates a new SCA Node.
+ *
+ * @param compositeURI the URI of the composite to use
+ * @param contributions the URI of the contributions that provides the composites and related
+ * artifacts. If the list is empty, then we will use the thread context classloader to discover
+ * the contribution on the classpath
+ *
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNode(String compositeURI, Contribution...contributions) throws LauncherException {
+ return (T)node(null, compositeURI, null, contributions, null);
+ }
+
+ /**
+ * Creates a new SCA Node.
+ *
+ * @param compositeURI the URI of the composite to use
+ * @param compositeContent the XML content of the composite to use
+ * @param contributions the URI of the contributions that provides the composites and related artifacts
+ * @return a new SCA node.
+ * @throws LauncherException
+ */
+ public <T> T createNode(String compositeURI, String compositeContent, Contribution...contributions) throws LauncherException {
+ return (T)node(null, compositeURI, compositeContent, contributions, null);
+ }
+
+ /**
+ * Create a SCA node based on the discovery of the contribution on the classpath for the
+ * given classloader. This method should be treated a convenient shortcut with the following
+ * assumptions:
+ * <ul>
+ * <li>This is a standalone application and there is a deployable composite file on the classpath.
+ * <li>There is only one contribution which contains the deployable composite file physically in its packaging hierarchy.
+ * </ul>
+ *
+ * @param compositeURI The URI of the composite file relative to the root of the enclosing contribution
+ * @param classLoader The ClassLoader used to load the composite file as a resource. If the value is null,
+ * then thread context classloader will be used
+ * @return A newly created SCA node
+ */
+ public <T> T createNodeFromClassLoader(String compositeURI, ClassLoader classLoader) throws LauncherException {
+ return (T)node(null, compositeURI, null, null, classLoader);
+ }
+
+ static Options getCommandLineOptions() {
+ Options options = new Options();
+ Option opt1 = new Option("c", "composite", true, "URI for the composite");
+ opt1.setArgName("compositeURI");
+ options.addOption(opt1);
+ Option opt2 = new Option("n", "node", true, "URI for the node configuration");
+ opt2.setArgName("nodeConfigurationURI");
+ options.addOption(opt2);
+ Option opt3 = new Option("t", "ttl", true, "Time to live");
+ opt3.setArgName("timeToLiveInMilliseconds");
+ options.addOption(opt3);
+ Option opt4 = new Option("s", "service", true, "Service to invoke (componentName/serviceName#operation(arg0,...,argN)");
+ options.addOption(opt4);
+ return options;
+ }
+
+ public static void main(String[] args) throws Exception {
+ CommandLineParser parser = new PosixParser();
+ Options options = getCommandLineOptions();
+ CommandLine cli = parser.parse(options, args);
+
+ Object node = null;
+ ShutdownThread shutdown = null;
+ try {
+ while (true) {
+ if (cli.hasOption("node")) {
+
+ // Create a node from a configuration URI
+ String configurationURI = cli.getOptionValue("node");
+ logger.info("SCA Node configuration: " + configurationURI);
+ // Create a node launcher
+ NodeLauncher launcher = newInstance();
+ node = launcher.createNodeFromURL(configurationURI);
+ } else {
+
+ // Create a node from a composite URI and a contribution location
+ String compositeURI = cli.getOptionValue("composite");
+ List<String> contribs = cli.getArgList();
+ Contribution[] contributions = null;
+ if (!contribs.isEmpty()) {
+ contributions = new Contribution[contribs.size()];
+ int index = 0;
+ for (String contrib : contribs) {
+ logger.info("SCA contribution: " + contrib);
+ URL url = null;
+ try {
+ url = new URL(contrib);
+ } catch(MalformedURLException e) {
+ url = new File(contrib).toURI().toURL();
+ }
+ contributions[index] = new Contribution("contribution-" + index, url.toString());
+ index++;
+ }
+ } else {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.setSyntaxPrefix("Usage: ");
+ formatter.printHelp("java " + NodeLauncher.class.getName()
+ + " [-c <compositeURI>]"
+ + " [-s <service>]"
+ + " [-t <ttl>]"
+ + " contribution1 ... contributionN", options); return;
+ }
+ // Create a node launcher
+ logger.info("SCA composite: " + compositeURI);
+ NodeLauncher launcher = newInstance();
+
+ node = launcher.createNode(compositeURI, contributions);
+ }
+
+ logger.info("Apache Tuscany SCA Node is starting...");
+
+ // Start the node
+ try {
+ node.getClass().getMethod("start").invoke(node);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node could not be started", e);
+ throw e;
+ }
+ logger.info("SCA Node is now started.");
+
+ String service = cli.getOptionValue("service");
+ String regex = "(#|\\(|,|\\))";
+ if (service != null) {
+ // componentName/serviceName/bindingName#methodName(arg0, ..., agrN)
+ String tokens[] = service.split(regex);
+ String serviceName = tokens[0];
+ String operationName = tokens[1];
+ String params[] = new String[tokens.length - 2];
+ System.arraycopy(tokens, 2, params, 0, params.length);
+ logger.info("Invoking service: " + service);
+ Method method = node.getClass().getMethod("getService", Class.class, String.class);
+ Object proxy = method.invoke(node, null, serviceName);
+
+ Object result = invoke(proxy, operationName, params);
+ if (result != null) {
+ logger.info("Result is: " + result);
+ }
+ break;
+ }
+
+ // Install a shutdown hook
+ shutdown = new ShutdownThread(node);
+ Runtime.getRuntime().addShutdownHook(shutdown);
+
+ long ttl = Long.parseLong(cli.getOptionValue("ttl", "-1"));
+ if (ttl >= 0) {
+ logger.info("Waiting for " + ttl + " milliseconds ...");
+ Thread.sleep(ttl);
+ // Stop the node
+ if (node != null) {
+ Object n = node;
+ node = null;
+ stopNode(n);
+ }
+ break; // Exit
+ }
+
+ logger.info("Press 'q' to quit, 'r' to restart.");
+ int k = 0;
+ try {
+ while ((k != 'q') && (k != 'r')) {
+ k = System.in.read();
+ }
+ } catch (IOException e) {
+
+ // Wait forever
+ Object lock = new Object();
+ synchronized(lock) {
+ lock.wait();
+ }
+ }
+
+ // Stop the node
+ if (node != null) {
+ Object n = node;
+ node = null;
+ stopNode(n);
+ }
+
+ // Quit
+ if (k == 'q' ) {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ // Stop the node
+ if (node != null) {
+ try {
+ Object n = node;
+ node = null;
+ stopNode(n);
+ } catch (Exception e2) {
+ }
+ }
+ throw e;
+
+ } finally {
+
+ // Remove the shutdown hook
+ if (shutdown != null) {
+ Runtime.getRuntime().removeShutdownHook(shutdown);
+ }
+ }
+ }
+
+ static Object invoke(Object proxy, String operationName, String... params) throws IllegalAccessException,
+ InvocationTargetException {
+ for (Method m : proxy.getClass().getMethods()) {
+ if (m.getName().equals(operationName) && m.getParameterTypes().length == params.length) {
+ Object parameters[] = new Object[params.length];
+ int i = 0;
+ for (Class<?> type : m.getParameterTypes()) {
+ if (type == byte.class || type == Byte.class) {
+ parameters[i] = Byte.valueOf(params[i]);
+ } else if (type == char.class || type == Character.class) {
+ parameters[i] = params[i].charAt(0);
+ } else if (type == boolean.class || type == Boolean.class) {
+ parameters[i] = Boolean.valueOf(params[i]);
+ } else if (type == short.class || type == Short.class) {
+ parameters[i] = Short.valueOf(params[i]);
+ } else if (type == int.class || type == Integer.class) {
+ parameters[i] = Integer.valueOf(params[i]);
+ } else if (type == long.class || type == Long.class) {
+ parameters[i] = Long.valueOf(params[i]);
+ } else if (type == float.class || type == Float.class) {
+ parameters[i] = Float.valueOf(params[i]);
+ } else if (type == double.class || type == Double.class) {
+ parameters[i] = Double.valueOf(params[i]);
+ } else if (type == String.class) {
+ parameters[i] = params[i];
+ } else {
+ throw new IllegalArgumentException("Parameter type is not supported: " + type);
+ }
+ i++;
+ }
+ Object result = m.invoke(proxy, parameters);
+ return result;
+ }
+ }
+ throw new IllegalArgumentException("Invalid service operation: " + operationName);
+ }
+
+ /**
+ * Stop the given node.
+ *
+ * @param node
+ * @throws Exception
+ */
+ private static void stopNode(Object node) throws Exception {
+ try {
+ node.getClass().getMethod("stop").invoke(node);
+ logger.info("SCA Node is now stopped.");
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "SCA Node could not be stopped", e);
+ throw e;
+ }
+ }
+
+ private static class ShutdownThread extends Thread {
+ private Object node;
+
+ public ShutdownThread(Object node) {
+ super();
+ this.node = node;
+ }
+
+ @Override
+ public void run() {
+ try {
+ stopNode(node);
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
new file mode 100644
index 0000000000..38dea77eda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
@@ -0,0 +1,567 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.launcher;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.Reader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Common functions and constants used by the admin components.
+ *
+ * @version $Rev$ $Date$
+ */
+final class NodeLauncherUtil {
+ private static final String NODE_FACTORY = "org.apache.tuscany.sca.node.NodeFactory";
+
+ private static final Logger logger = Logger.getLogger(NodeLauncherUtil.class.getName());
+
+ private static final String TUSCANY_HOME = "TUSCANY_HOME";
+ private static final String TUSCANY_PATH = "TUSCANY_PATH";
+
+
+ /**
+ * Returns a ClassLoader for the Tuscany runtime JARs for use in a standalone
+ * J2SE environment.
+ *
+ * @param parentClassLoader
+ *
+ * @return
+ */
+ static ClassLoader standAloneRuntimeClassLoader(ClassLoader parentClassLoader) throws FileNotFoundException, URISyntaxException, MalformedURLException {
+ return runtimeClassLoader(parentClassLoader, new StandAloneJARFileNameFilter());
+ }
+
+ /**
+ * Returns a ClassLoader for the Tuscany runtime JARs for use in a Webapp
+ * environment.
+ *
+ * @param parentClassLoader
+ *
+ * @return
+ */
+ static ClassLoader webAppRuntimeClassLoader(ClassLoader parentClassLoader) throws FileNotFoundException, URISyntaxException, MalformedURLException {
+ return runtimeClassLoader(parentClassLoader, new WebAppJARFileNameFilter());
+ }
+
+ /**
+ * Returns a ClassLoader for the Tuscany runtime JARs.
+ *
+ * @param parentClassLoader
+ * @param filter
+ *
+ * @return
+ */
+ private static ClassLoader runtimeClassLoader(ClassLoader parentClassLoader, FilenameFilter filter) throws FileNotFoundException, URISyntaxException, MalformedURLException {
+ // First try to see if the runtime classes are already on the classpath
+ // If yes, skip the discovery to avoid duplicate jars
+ try {
+ Class.forName(NODE_FACTORY, false, parentClassLoader);
+ return parentClassLoader;
+ } catch (ClassNotFoundException e) {
+ // Ignore;
+ }
+ // Build list of runtime JARs
+ Set<URL> jarDirectoryURLs = new HashSet<URL>();
+ Set<URL> jarURLs = new HashSet<URL>();
+
+ // First determine the path to the launcher class
+ String resource = NodeLauncherUtil.class.getName().replace('.', '/') + ".class";
+ URL url = NodeLauncherUtil.class.getClassLoader().getResource(resource);
+ if (url == null) {
+ throw new FileNotFoundException(resource);
+ }
+ URI uri = url.toURI();
+
+ // If the launcher class is in a JAR, add all runtime JARs from directory containing
+ // that JAR (e.g. the Tuscany modules directory) as well as the ../modules and
+ // ../lib directories
+ String scheme = uri.getScheme();
+ if (scheme.equals("jar")) {
+ String path = uri.toString().substring(4);
+ int i = path.indexOf("!/");
+ if (i != -1) {
+ path = path.substring(0, i);
+ uri = URI.create(path);
+ }
+
+ File file = new File(uri);
+ if (file.exists()) {
+ File jarDirectory = file.getParentFile();
+ if (jarDirectory != null && jarDirectory.exists()) {
+ File homeDirectory = jarDirectory.getParentFile();
+ if (homeDirectory != null && homeDirectory.exists()) {
+ collectJARFiles(homeDirectory.getPath(), jarDirectoryURLs, jarURLs, filter);
+ }
+ }
+ }
+ }
+
+ // Look for a TUSCANY_HOME system property or environment variable
+ // Add all the JARs found under $TUSCANY_HOME, $TUSCANY_HOME/modules
+ // and $TUSCANY_HOME/lib
+ String home = System.getProperty(TUSCANY_HOME);
+ if (home == null || home.length() == 0) {
+ home = System.getenv(TUSCANY_HOME);
+ }
+ if (home != null && home.length() != 0) {
+ logger.fine(TUSCANY_HOME + ": " + home);
+ collectJARFiles(home, jarDirectoryURLs, jarURLs, filter);
+ }
+
+ // Look for a TUSCANY_PATH system property or environment variable
+ // Add all the JARs found under $TUSCANY_PATH, $TUSCANY_PATH/modules
+ // and $TUSCANY_PATH/lib
+ String ext = System.getProperty(TUSCANY_PATH);
+ if (ext == null || ext.length() == 0) {
+ ext = System.getenv(TUSCANY_PATH);
+ }
+ if (ext != null && ext.length() != 0) {
+ logger.fine(TUSCANY_PATH + ": " + ext);
+ String separator = System.getProperty("path.separator");
+ for (StringTokenizer tokens = new StringTokenizer(ext, separator); tokens.hasMoreTokens(); ) {
+ collectJARFiles(tokens.nextToken(), jarDirectoryURLs, jarURLs, filter);
+ }
+ }
+
+ // Return the runtime class loader
+ if (!jarURLs.isEmpty()) {
+ // Remove the URLs which are already in the parent classloader
+ if (parentClassLoader instanceof URLClassLoader) {
+ URLClassLoader cl = (URLClassLoader)parentClassLoader;
+ jarURLs.removeAll(Arrays.asList(cl.getURLs()));
+ }
+
+ // Return a ClassLoader configured with the runtime JARs
+ ClassLoader classLoader = new RuntimeClassLoader(jarURLs.toArray(new URL[jarURLs.size()]), parentClassLoader);
+ return classLoader;
+
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Collect JAR files under the given directory.
+ *
+ * @param directory
+ * @param jarDirectoryURLs
+ * @param jarURLs
+ * @param filter
+ * @throws MalformedURLException
+ */
+ private static void collectJARFiles(String directory, Set<URL> jarDirectoryURLs, Collection<URL> jarURLs, FilenameFilter filter)
+ throws MalformedURLException {
+ File directoryFile = new File(directory);
+ URL directoryURL = directoryFile.toURI().toURL();
+ if (!jarDirectoryURLs.contains(directoryURL) && directoryFile.exists()) {
+
+ // Collect files under $TUSCANY_HOME
+ jarDirectoryURLs.add(directoryURL);
+ collectJARFiles(directoryFile, jarURLs, filter, false);
+
+ // Collect files under $TUSCANY_HOME/modules
+ File modulesDirectory = new File(directoryFile, "modules");
+ URL modulesDirectoryURL = modulesDirectory.toURI().toURL();
+ if (!jarDirectoryURLs.contains(modulesDirectoryURL) && modulesDirectory.exists()) {
+ jarDirectoryURLs.add(modulesDirectoryURL);
+ collectJARFiles(modulesDirectory, jarURLs, filter, true);
+ }
+
+ // Collect files under $TUSCANY_HOME/lib
+ File libDirectory = new File(directoryFile, "lib");
+ URL libDirectoryURL = libDirectory.toURI().toURL();
+ if (!jarDirectoryURLs.contains(libDirectoryURL) && libDirectory.exists()) {
+ jarDirectoryURLs.add(libDirectoryURL);
+ collectJARFiles(libDirectory, jarURLs, filter, true);
+ }
+ }
+ }
+
+ /**
+ * Collect JAR files in the given directory
+ * @param directory
+ * @param urls
+ * @param filter
+ * @param recursive
+ * @throws MalformedURLException
+ */
+ private static void collectJARFiles(File directory, Collection<URL> urls, FilenameFilter filter, boolean recursive) throws MalformedURLException {
+ File[] files = directory.listFiles(filter);
+ if (files != null) {
+ int count = 0;
+ for (File file: files) {
+ if (recursive && file.isDirectory()) {
+ collectJARFiles(file, urls, filter, recursive);
+ } else if (file.isFile()) {
+ urls.add(file.toURI().toURL());
+ count++;
+ }
+ }
+ if (count != 0 && logger.isLoggable(Level.FINE)) {
+ logger.fine("Runtime classpath: "+ count + " JAR" + (count > 1? "s":"")+ " from " + directory.toString());
+ }
+ }
+ }
+
+ /**
+ * A file name filter used to filter JAR files.
+ */
+ private static class StandAloneJARFileNameFilter implements FilenameFilter {
+
+ public boolean accept(File dir, String name) {
+ if(new File(dir, name).isDirectory()) {
+ return true;
+ }
+ name = name.toLowerCase();
+
+ // Exclude tuscany-sca-all and tuscany-sca-manifest as they duplicate
+ // code in the individual runtime module JARs
+ if (name.startsWith("tuscany-sca-all")) {
+ return false;
+ }
+ if (name.startsWith("tuscany-sca-manifest")) {
+ return false;
+ }
+
+ if ("features".equals(dir.getName()) && name.startsWith("equinox-manifest")) {
+ return false;
+ }
+
+ // Filter out the Tomcat and Webapp hosts
+ if (name.startsWith("tuscany-host-tomcat") ||
+ name.startsWith("tuscany-host-webapp")) {
+ //FIXME This is temporary
+ return false;
+ }
+
+ // Include JAR and MAR files
+ if (name.endsWith(".jar")) {
+ return true;
+ }
+ if (name.endsWith(".mar")) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * A file name filter used to filter JAR files.
+ */
+ private static class WebAppJARFileNameFilter extends StandAloneJARFileNameFilter {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ if (!super.accept(dir, name)) {
+ return false;
+ }
+ name = name.toLowerCase();
+
+ // Exclude servlet-api JARs
+ if (name.startsWith("servlet-api")) {
+ return false;
+ }
+
+ // Exclude the Tomcat and Jetty hosts
+ if (name.startsWith("tuscany-host-tomcat") || name.startsWith("tuscany-host-jetty")) {
+ //FIXME This is temporary
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+
+ /**
+ * Creates a new node.
+ *
+ * @param compositeURI
+ * @param contributions
+ * @throws LauncherException
+ */
+ static Object node(String configurationURI, String compositeURI, String compositeContent, Contribution[] contributions, ClassLoader contributionClassLoader) throws LauncherException {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+
+ // Set up runtime ClassLoader
+ ClassLoader runtimeClassLoader = runtimeClassLoader(Thread.currentThread().getContextClassLoader(),
+ new StandAloneJARFileNameFilter());
+ if (runtimeClassLoader != null) {
+ Thread.currentThread().setContextClassLoader(runtimeClassLoader);
+ }
+
+ // Use Java reflection to create the node as only the runtime class
+ // loader knows the runtime classes required by the node
+ String className = NODE_FACTORY;
+ Class<?> bootstrapClass;
+ if (runtimeClassLoader != null) {
+ bootstrapClass = Class.forName(className, true, runtimeClassLoader);
+ } else {
+ bootstrapClass = Class.forName(className);
+ }
+
+ Object node =
+ createNode(bootstrapClass,
+ configurationURI,
+ compositeURI,
+ compositeContent,
+ contributions,
+ contributionClassLoader);
+
+ return node;
+
+ } catch (Exception e) {
+ NodeLauncher.logger.log(Level.SEVERE, "SCA Node could not be created", e);
+ throw new LauncherException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ private static Object createNode(Class<?> bootstrapClass,
+ String configurationURI,
+ String compositeURI,
+ String compositeContent,
+ Contribution[] contributions,
+ ClassLoader contributionClassLoader) throws NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException, MalformedURLException {
+ Method newInstance = bootstrapClass.getMethod("newInstance");
+ Object nodeFactory = newInstance.invoke(null);
+
+ Object node;
+ if (configurationURI != null) {
+
+ URL url = null;
+ URI uri = URI.create(configurationURI);
+ if (uri.getScheme() == null) {
+ uri = new File(configurationURI).toURI();
+ }
+ url = uri.toURL();
+
+ // NodeFactory.createNode(URL)
+ Method create = bootstrapClass.getMethod("createNode", URL.class);
+ node = create.invoke(nodeFactory, url);
+
+ } else if (contributionClassLoader != null) {
+
+ // NodeFactory.createNode(String, ClassLoader)
+ Method create = bootstrapClass.getMethod("createNode", String.class, ClassLoader.class);
+ node = create.invoke(nodeFactory, compositeURI, contributionClassLoader);
+
+ } else if (compositeContent != null) {
+
+ // NodeFactory.createNode(Reader, Stringp[], String[])
+ Method create = bootstrapClass.getMethod("createNode", Reader.class, String[].class, String[].class);
+ String[] uris = new String[contributions.length];
+ String[] locations = new String[contributions.length];
+ for (int i = 0; i < contributions.length; i++) {
+ uris[i] = contributions[i].getURI();
+ locations[i] = contributions[i].getLocation();
+ }
+ node = create.invoke(nodeFactory, compositeContent, uris, locations);
+
+ } else {
+
+ // NodeFactory.createNode(String, Stringp[], String[])
+ Method create = bootstrapClass.getMethod("createNode", String.class, String[].class, String[].class);
+ String[] uris = new String[contributions.length];
+ String[] locations = new String[contributions.length];
+ for (int i = 0; i < contributions.length; i++) {
+ uris[i] = contributions[i].getURI();
+ locations[i] = contributions[i].getLocation();
+ }
+ node = create.invoke(nodeFactory, compositeURI, uris, locations);
+ }
+ return node;
+ }
+
+ /**
+ * Creates a new node daemon.
+ *
+ * @throws LauncherException
+ */
+ static Object nodeDaemon() throws LauncherException {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Set up runtime ClassLoader
+ ClassLoader runtimeClassLoader = runtimeClassLoader(Thread.currentThread().getContextClassLoader(),
+ new StandAloneJARFileNameFilter());
+ if (runtimeClassLoader != null) {
+ Thread.currentThread().setContextClassLoader(runtimeClassLoader);
+ }
+
+ // Use Java reflection to create the node daemon as only the runtime class
+ // loader knows the runtime classes required by the node
+ String className = "org.apache.tuscany.sca.implementation.node.launcher.NodeImplementationDaemonBootstrap";
+ Class<?> bootstrapClass;
+ if (runtimeClassLoader != null) {
+ bootstrapClass = Class.forName(className, true, runtimeClassLoader);
+ } else {
+ bootstrapClass = Class.forName(className);
+ }
+ Object bootstrap = bootstrapClass.getConstructor().newInstance();
+
+ Object nodeDaemon = bootstrapClass.getMethod("getNode").invoke(bootstrap);
+ return nodeDaemon;
+
+ } catch (Exception e) {
+ NodeDaemonLauncher.logger.log(Level.SEVERE, "SCA Node Daemon could not be created", e);
+ throw new LauncherException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ /**
+ * Creates a new domain manager.
+ *
+ * @throws LauncherException
+ */
+ static Object domainManager(String rootDirectory) throws LauncherException {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Set up runtime ClassLoader
+ ClassLoader runtimeClassLoader = runtimeClassLoader(Thread.currentThread().getContextClassLoader(),
+ new StandAloneJARFileNameFilter());
+ if (runtimeClassLoader != null) {
+ Thread.currentThread().setContextClassLoader(runtimeClassLoader);
+ }
+
+ // Use Java reflection to create the node daemon as only the runtime class
+ // loader knows the runtime classes required by the node
+ String className = "org.apache.tuscany.sca.domain.manager.launcher.DomainManagerLauncherBootstrap";
+ Class<?> bootstrapClass;
+ if (runtimeClassLoader != null) {
+ bootstrapClass = Class.forName(className, true, runtimeClassLoader);
+ } else {
+ bootstrapClass = Class.forName(className);
+ }
+ Constructor<?> constructor = bootstrapClass.getConstructor(String.class);
+ Object bootstrap = constructor.newInstance(rootDirectory);
+
+ Object domainManager = bootstrapClass.getMethod("getNode").invoke(bootstrap);
+ return domainManager;
+
+ } catch (Exception e) {
+ DomainManagerLauncher.logger.log(Level.SEVERE, "SCA Domain Manager could not be created", e);
+ throw new LauncherException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ /**
+ * Simple URL class loader for the runtime JARs
+ */
+ private static class RuntimeClassLoader extends URLClassLoader {
+ private static final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
+ private ClassLoader parent;
+
+ /**
+ * Constructs a new class loader.
+ * @param urls
+ * @param parent
+ */
+ private RuntimeClassLoader(URL[] urls, ClassLoader parent) {
+ super(urls);
+ this.parent = parent;
+ }
+
+ @Override
+ public URL findResource(String name) {
+ URL url = super.findResource(name);
+ if (url == null) {
+ url = parent.getResource(name);
+ }
+ return url;
+ }
+
+ @Override
+ public Enumeration<URL> findResources(String name) throws IOException {
+ Enumeration<URL> resources = super.findResources(name);
+ Enumeration<URL> parentResources = parent.getResources(name);
+ List<URL> allResources = new ArrayList<URL>();
+ for (; resources.hasMoreElements(); ) {
+ allResources.add(resources.nextElement());
+ }
+ for (; parentResources.hasMoreElements(); ) {
+ allResources.add(parentResources.nextElement());
+ }
+ return Collections.enumeration(allResources);
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ Class<?> cl;
+
+ // First try to load the class using the parent classloader
+ try {
+ cl = parent.loadClass(name);
+ ClassLoader loadedBy = cl.getClassLoader();
+
+ // If the class was not loaded directly by the parent classloader
+ // or the system classloader try to load a local version of the class
+ // using our RuntimeClassloader instead
+ if (loadedBy != parent &&
+ loadedBy != systemClassLoader &&
+ loadedBy != null) {
+
+ try {
+ cl = super.findClass(name);
+ } catch (ClassNotFoundException e) {
+ // No class alternative was found in our RuntimeClassloader,
+ // use the class found in the parent classloader hierarchy
+ }
+ }
+ } catch (ClassNotFoundException e) {
+
+ // The class was not found by the parent class loader, try
+ // to load it using our RuntimeClassloader
+ cl = super.findClass(name);
+ }
+
+ return cl;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeMain.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeMain.java
new file mode 100644
index 0000000000..77751dcc47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeMain.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.node.launcher;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+
+
+/**
+ * Main class for this JAR.
+ * With a "-nodeDaemon or -nd" this class launches the SCA Node Daemon.
+ * With a "-domainManager or -dm" argument it launches the SCA domain admin node.
+ * With any other argument it launches an SCA Node.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeMain {
+
+ public static void main(String[] args) throws Exception {
+ CommandLineParser parser = new PosixParser();
+ Options options = new Options();
+ OptionGroup group = new OptionGroup();
+ group.addOption(new Option("dm", "domainManager", false, "Domain Manager"));
+ group.addOption(new Option("nd", "nodeDaemon", false, "Node Domain"));
+ options.addOptionGroup(group);
+
+ // Add options from NodeLauncher to avoid UnrecognizedOptionException
+ for (Object o : NodeLauncher.getCommandLineOptions().getOptions()) {
+ options.addOption((Option)o);
+ }
+
+ CommandLine cli = parser.parse(options, args);
+ if (cli.hasOption("nd")) {
+ NodeDaemonLauncher.main(args);
+ } else if (cli.hasOption("dm")) {
+ DomainManagerLauncher.main(args);
+ } else {
+ NodeLauncher.main(args);
+ }
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeServletFilter.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeServletFilter.java
new file mode 100644
index 0000000000..5345363031
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeServletFilter.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.node.launcher;
+
+import static org.apache.tuscany.sca.node.launcher.NodeLauncherUtil.webAppRuntimeClassLoader;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * A Servlet filter that forwards service requests to the Servlets registered with
+ * the Tuscany ServletHost.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NodeServletFilter implements Filter {
+ private static final long serialVersionUID = 1L;
+
+ private static final String NODE_WEB_APP_SERVLET_HOST = "org.apache.tuscany.sca.implementation.node.webapp.NodeWebAppServletHost";
+
+ private static final Logger logger = Logger.getLogger(NodeServletFilter.class.getName());
+
+ private ClassLoader runtimeClassLoader;
+ private Class<?> servletHostClass;
+ private Object servletHost;
+ private Filter filter;
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ logger.info("Apache Tuscany SCA WebApp Node is starting...");
+
+ try {
+ // Get the Tuscany runtime ClassLoader
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ runtimeClassLoader = webAppRuntimeClassLoader(getClass().getClassLoader());
+
+ try {
+ if (runtimeClassLoader != null) {
+ Thread.currentThread().setContextClassLoader(runtimeClassLoader);
+ }
+
+ // Load the Tuscany WebApp Servlet host and get the host instance
+ // for the current webapp
+ String className = NODE_WEB_APP_SERVLET_HOST;
+ if (runtimeClassLoader != null) {
+ servletHostClass = Class.forName(className, true, runtimeClassLoader);
+ } else {
+ servletHostClass = Class.forName(className);
+ }
+ servletHost = servletHostClass.getMethod("servletHost").invoke(null);
+
+ // Initialize the Servlet host
+ servletHostClass.getMethod("init", FilterConfig.class).invoke(servletHost, filterConfig);
+
+ // The Servlet host also implements the filter interface
+ filter = (Filter)servletHost;
+
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Error Starting SCA WebApp Node", e);
+ throw new ServletException(e);
+ }
+
+ logger.info("SCA WebApp Node started.");
+ }
+
+ public void destroy() {
+ logger.info("Apache Tuscany WebApp Node stopping...");
+ if (servletHost != null) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ if (runtimeClassLoader != null) {
+ Thread.currentThread().setContextClassLoader(runtimeClassLoader);
+ }
+
+ servletHostClass.getMethod("destroy").invoke(servletHost);
+
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Error Stopping SCA WebApp Node", e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+ logger.info("SCA WebApp Node stopped.");
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, javax.servlet.FilterChain chain)
+ throws IOException, ServletException {
+
+ // Delegate to the Servlet host filter
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ if (runtimeClassLoader != null) {
+ Thread.currentThread().setContextClassLoader(runtimeClassLoader);
+ }
+
+ filter.doFilter(request, response, chain);
+
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/node-launcher/src/test/java/org/apache/tuscany/sca/node/launcher/ServiceInvocationTestCase.java b/sandbox/sebastien/java/embed/modules/node-launcher/src/test/java/org/apache/tuscany/sca/node/launcher/ServiceInvocationTestCase.java
new file mode 100644
index 0000000000..b1fe8770b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/node-launcher/src/test/java/org/apache/tuscany/sca/node/launcher/ServiceInvocationTestCase.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node.launcher;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class ServiceInvocationTestCase {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ public float add(float x, float y) {
+ return x + y;
+ }
+
+ @Test
+ public void testInvoke() throws Exception {
+ String service = "component1/service1#add(1.0, 2.0)";
+ Object proxy = this;
+ invoke(service, proxy);
+ }
+
+ private Object invoke(String service, Object proxy) throws IllegalAccessException, InvocationTargetException {
+ String regex = "(#|\\(|,|\\))";
+ if (service != null) {
+ // componentName/serviceName/bindingName#methodName(arg0, ..., agrN)
+ String tokens[] = service.split(regex);
+ String serviceName = tokens[0];
+ Assert.assertEquals("component1/service1", serviceName);
+ String operationName = tokens[1];
+ Assert.assertEquals("add", operationName);
+ String params[] = new String[tokens.length - 2];
+ System.arraycopy(tokens, 2, params, 0, params.length);
+ Object result = NodeLauncher.invoke(proxy, operationName, params);
+ Assert.assertEquals(new Float(3.0f), result);
+ return result;
+ }
+ return null;
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/LICENSE b/sandbox/sebastien/java/embed/modules/policy-logging/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/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/sebastien/java/embed/modules/policy-logging/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/policy-logging/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1f36921225
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.policy.logging;version="2.0.0",o
+ rg.apache.tuscany.sca.policy.logging.jdk;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Logging Policy Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Logging Policy Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca.annotation
+Bundle-SymbolicName: org.apache.tuscany.sca.policy.logging
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/NOTICE b/sandbox/sebastien/java/embed/modules/policy-logging/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/pom.xml b/sandbox/sebastien/java/embed/modules/policy-logging/pom.xml
new file mode 100644
index 0000000000..e4b28fcd20
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/pom.xml
@@ -0,0 +1,53 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-logging</artifactId>
+ <name>Apache Tuscany SCA Extension Policy Logging Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java
new file mode 100644
index 0000000000..4bed9520ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.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.sca.policy.logging;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.oasisopen.sca.annotation.Intent;
+import org.oasisopen.sca.annotation.Qualifier;
+
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Logging.LOGGING)
+
+public @interface Logging {
+ String LOGGING = "{"+Base.SCA11_TUSCANY_NS + "}logging";
+
+ @Qualifier
+ String[] value() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
new file mode 100644
index 0000000000..66a0ba2b51
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.logging.jdk;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JDKLoggingImplementationPolicyProvider extends BasePolicyProvider<JDKLoggingPolicy> {
+
+ public JDKLoggingImplementationPolicyProvider(RuntimeComponent component) {
+ super(JDKLoggingPolicy.class, component);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<JDKLoggingPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(subject, getContext(), operation,
+ policies, Phase.IMPLEMENTATION_POLICY);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java
new file mode 100644
index 0000000000..6e1bad67c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.logging.jdk;
+
+import java.util.logging.Level;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKLoggingPolicy {
+ static final String SCA11_NS = Base.SCA11_NS;
+ static final String SCA11_TUSCANY_NS = Base.SCA11_TUSCANY_NS;
+ static final QName JDK_LOGGING_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "jdkLogger");
+
+ private String loggerName;
+ private String resourceBundleName;
+ private Level logLevel;
+ private boolean useParentHandlers = false;
+
+ public String getLoggerName() {
+ return loggerName;
+ }
+
+ public void setLoggerName(String loggerName) {
+ this.loggerName = loggerName;
+ }
+
+ public Level getLogLevel() {
+ return logLevel;
+ }
+
+ public void setLogLevel(Level logLevel) {
+ this.logLevel = logLevel;
+ }
+
+ public String getResourceBundleName() {
+ return resourceBundleName;
+ }
+
+ public void setResourceBundleName(String resourceBundleName) {
+ this.resourceBundleName = resourceBundleName;
+ }
+
+ public boolean isUseParentHandlers() {
+ return useParentHandlers;
+ }
+
+ public void setUseParentHandlers(boolean useParentHandlers) {
+ this.useParentHandlers = useParentHandlers;
+ }
+
+ public QName getSchemaName() {
+ return JDK_LOGGING_POLICY_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ @Override
+ public String toString() {
+ return "JDKLoggingPolicy [logLevel=" + logLevel
+ + ", loggerName="
+ + loggerName
+ + ", resourceBundleName="
+ + resourceBundleName
+ + ", useParentHandlers="
+ + useParentHandlers
+ + "]";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
new file mode 100644
index 0000000000..8a71203b70
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.logging.jdk;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ *
+ */
+public class JDKLoggingPolicyBuilder implements PolicyBuilder<JDKLoggingPolicy> {
+
+ public boolean build(Endpoint endpoint, BuilderContext context) {
+ List<JDKLoggingPolicy> polices = getPolicies(endpoint);
+ System.out.println(endpoint + ": " + polices);
+ return true;
+ }
+
+ public boolean build(EndpointReference endpointReference, BuilderContext context) {
+ List<JDKLoggingPolicy> polices = getPolicies(endpointReference);
+ System.out.println(endpointReference + ": " + polices);
+ return true;
+ }
+
+ public boolean build(Component component, Implementation implementation, BuilderContext context) {
+ List<JDKLoggingPolicy> polices = getPolicies(implementation);
+ System.out.println(implementation + ": " + polices);
+ return true;
+ }
+
+ public QName getPolicyType() {
+ return JDKLoggingPolicy.JDK_LOGGING_POLICY_QNAME;
+ }
+
+ public List<QName> getSupportedBindings() {
+ return null;
+ }
+
+ private List<JDKLoggingPolicy> getPolicies(PolicySubject subject) {
+ List<JDKLoggingPolicy> polices = new ArrayList<JDKLoggingPolicy>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ if (getPolicyType().equals(exp.getName())) {
+ polices.add((JDKLoggingPolicy)exp.getPolicy());
+ }
+ }
+ }
+ return polices;
+ }
+
+ public boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context) {
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
new file mode 100644
index 0000000000..b6c83a804a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.logging.jdk;
+
+import java.util.List;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKLoggingPolicyInterceptor implements PhasedInterceptor {
+ public static final String loggingPolicy = "JDKLoggingPolicy";
+ public static final QName policySetQName = new QName(JDKLoggingPolicy.SCA11_TUSCANY_NS, loggingPolicy);
+ private Logger logger = null;
+
+ private Invoker next;
+ private Operation operation;
+ private List<JDKLoggingPolicy> policies;
+ private PolicySubject subject;
+ private String context;
+ private String phase;
+
+ public JDKLoggingPolicyInterceptor(PolicySubject subject,
+ String context,
+ Operation operation,
+ List<JDKLoggingPolicy> policies,
+ String phase) {
+ super();
+ this.operation = operation;
+ this.policies = policies;
+ this.subject = subject;
+ this.phase = phase;
+ this.context = getContext();
+ init();
+ }
+
+ private String getContext() {
+ if (subject instanceof Endpoint) {
+ Endpoint endpoint = (Endpoint)subject;
+ return endpoint.getURI();
+ } else if (subject instanceof EndpointReference) {
+ EndpointReference endpointReference = (EndpointReference)subject;
+ return endpointReference.getURI();
+ } else if (subject instanceof Component) {
+ Component component = (Component)subject;
+ return component.getURI();
+ }
+ return null;
+ }
+
+ private void init() {
+ JDKLoggingPolicy policy = policies.get(0);
+ logger = Logger.getLogger(policy.getLoggerName());
+ logger.setLevel(policy.getLogLevel());
+ logger.setUseParentHandlers(policy.isUseParentHandlers());
+
+ boolean found = false;
+ for (Handler handler : logger.getHandlers()) {
+ if (handler instanceof ConsoleHandler) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ ConsoleHandler consoleHandler = new ConsoleHandler();
+ consoleHandler.setLevel(Level.ALL);
+ logger.addHandler(consoleHandler);
+ }
+
+ if (logger.isLoggable(Level.FINE)) {
+ logger.logp(Level.FINE, context, "", "Intents: {0}", subject.getRequiredIntents());
+ logger.logp(Level.FINE, context, "", "PolicySets: {0}", subject.getPolicySets());
+ }
+ }
+
+ public Message invoke(Message msg) {
+ if (logger == null) {
+ return getNext().invoke(msg);
+ }
+ logger.logp(Level.INFO, context, "", "Invoking operation - " + operation.getName());
+ Object msgBody = msg.getBody();
+ if (msgBody instanceof Object[]) {
+
+ if (logger.isLoggable(Level.FINE)) {
+ StringBuffer sb = new StringBuffer();
+ if (msgBody == null) {
+ sb.append("");
+ } else {
+ Object[] args = (Object[])msgBody;
+ for (int i = 0; i < args.length; i++) {
+ sb.append(args[i]);
+ if (i != args.length - 1) {
+ sb.append(", ");
+ }
+ }
+ }
+
+ Object[] logParams = new Object[] {operation.getName(), sb.toString()};
+ logger.logp(Level.FINE, context, "", "Invoking operation {0} with arguments {1}", logParams);
+ }
+ }
+
+ Message responseMsg = null;
+ try {
+ responseMsg = getNext().invoke(msg);
+ return responseMsg;
+ } catch (RuntimeException e) {
+ logger.logp(Level.SEVERE, context, "", "Exception thrown from operation - " + operation.getName(), e);
+ throw e;
+ } finally {
+ if (responseMsg != null) {
+ logger.logp(Level.INFO, context, "", "Returned from operation - " + operation.getName());
+ if (logger.isLoggable(Level.FINE)) {
+ Object[] logParams = new Object[] {operation.getName(), responseMsg.getBody()};
+ logger.logp(Level.FINE,
+ context,
+ "",
+ "Returning from operation {0} with return value {1}",
+ logParams);
+ }
+ }
+ }
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return phase;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java
new file mode 100644
index 0000000000..a79aeb0e28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.logging.jdk;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.logging.Level;
+
+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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKLoggingPolicyProcessor implements StAXArtifactProcessor<JDKLoggingPolicy> {
+ private static final QName JDK_LOGGING_POLICY_QNAME = new QName(JDKLoggingPolicy.SCA11_TUSCANY_NS, "jdkLogger");
+ private static final String LOG_LEVEL = "logLevel";
+ private static final String RESOURCE_BUNDLE = "resourceBundle";
+ private static final String USE_PARENT_HANDLERS = "useParentHandlers";
+
+ public QName getArtifactType() {
+ return JDK_LOGGING_POLICY_QNAME;
+ }
+
+ public JDKLoggingPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public JDKLoggingPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ JDKLoggingPolicy policy = new JDKLoggingPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+
+
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if ( name.equals(JDK_LOGGING_POLICY_QNAME) ) {
+ String loggerName = reader.getAttributeValue(null, "name");
+ policy.setLoggerName(loggerName);
+ } else if ( LOG_LEVEL.equals(name.getLocalPart()) ) {
+ policy.setLogLevel(Level.parse(reader.getElementText()));
+ } else if ( RESOURCE_BUNDLE.equals(name.getLocalPart()) ) {
+ policy.setResourceBundleName(reader.getElementText());
+ } else if ( USE_PARENT_HANDLERS.equals(name.getLocalPart()) ) {
+ policy.setUseParentHandlers(Boolean.parseBoolean(reader.getElementText()));
+ }
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( JDK_LOGGING_POLICY_QNAME.equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(JDKLoggingPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ JDK_LOGGING_POLICY_QNAME.getLocalPart(),
+ JDK_LOGGING_POLICY_QNAME.getNamespaceURI());
+ writer.writeNamespace("tuscany", JDKLoggingPolicy.SCA11_TUSCANY_NS);
+
+ if (policy.getLoggerName() != null) {
+ writer.writeAttribute("name", policy.getLoggerName());
+ }
+ if ( policy.getLogLevel() != null ) {
+ writer.writeStartElement(prefix,
+ LOG_LEVEL,
+ JDK_LOGGING_POLICY_QNAME.getNamespaceURI());
+ writer.writeCharacters(policy.getLogLevel().getLocalizedName());
+ writer.writeEndElement();
+ }
+
+ if ( policy.getResourceBundleName() != null ) {
+ writer.writeStartElement(prefix,
+ RESOURCE_BUNDLE,
+ JDK_LOGGING_POLICY_QNAME.getNamespaceURI());
+ writer.writeCharacters(policy.getResourceBundleName());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<JDKLoggingPolicy> getModelType() {
+ return JDKLoggingPolicy.class;
+ }
+
+ public void resolve(JDKLoggingPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
new file mode 100644
index 0000000000..62bf06475b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.logging.jdk;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JDKLoggingPolicyProviderFactory implements PolicyProviderFactory<JDKLoggingPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public JDKLoggingPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation)
+ */
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return new JDKLoggingImplementationPolicyProvider(component);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new JDKLoggingReferencePolicyProvider(endpointReference);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new JDKLoggingServicePolicyProvider(endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class<JDKLoggingPolicy> getModelType() {
+ return JDKLoggingPolicy.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
new file mode 100644
index 0000000000..80867f57de
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.logging.jdk;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JDKLoggingReferencePolicyProvider extends BasePolicyProvider<JDKLoggingPolicy> {
+
+ public JDKLoggingReferencePolicyProvider(EndpointReference endpointReference) {
+ super(JDKLoggingPolicy.class, endpointReference);
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<JDKLoggingPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(subject, getContext(), operation,
+ policies, Phase.REFERENCE_POLICY);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java
new file mode 100644
index 0000000000..99f0563603
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.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.policy.logging.jdk;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JDKLoggingServicePolicyProvider extends BasePolicyProvider<JDKLoggingPolicy> {
+
+ public JDKLoggingServicePolicyProvider(Endpoint endpoint) {
+ super(JDKLoggingPolicy.class, endpoint);
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<JDKLoggingPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(subject, getContext(), operation, policies, Phase.SERVICE_POLICY);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
new file mode 100644
index 0000000000..f1fbc54a7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.policy.logging.jdk.JDKLoggingPolicyBuilder;qname=http://tuscany.apache.org/xmlns/sca/1.1#jdkLogger
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..9d0a8fb67f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#jdkLogger,model=org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicy
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..bb7aed2087
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/policy/logging/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
new file mode 100644
index 0000000000..b9bb454550
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -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 policy extension
+org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicyProviderFactory;model=org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicy
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml
new file mode 100644
index 0000000000..84b7f94e84
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- Policy Intents Defined by the Tuscany Runtime -->
+ <intent name="logging" constrains="implementation binding">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <!-- Policy Intents Defined by the Tuscany Runtime -->
+ <intent name="noLogging" constrains="implementation binding" excludes="tuscany:logging">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java b/sandbox/sebastien/java/embed/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java
new file mode 100644
index 0000000000..0000ec8c06
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.logging.jdk;
+
+
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.logging.Level;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+
+/**
+ * Test the reading of ws config params policy.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyReadTestCase extends TestCase {
+ private ProcessorContext context = new ProcessorContext();
+
+ @Override
+ public void setUp() throws Exception {
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ }
+
+ public void testPolicyReading() throws Exception {
+ JDKLoggingPolicyProcessor processor = new JDKLoggingPolicyProcessor(null);
+
+ URL url = getClass().getResource("mock_policies.xml");
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ InputStream urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+
+
+ JDKLoggingPolicy policy = processor.read(reader, context);
+ assertEquals(policy.getLoggerName(), "test.logger");
+ assertEquals(policy.getLogLevel(), Level.INFO );
+ assertEquals(policy.getResourceBundleName(), "Trace_Messages.properties");
+ }
+
+ public void testPolicyWriting() throws Exception {
+ JDKLoggingPolicyProcessor processor = new JDKLoggingPolicyProcessor(null);
+
+ JDKLoggingPolicy policy = new JDKLoggingPolicy();
+ policy.setLoggerName("test.logger");
+ policy.setLogLevel(Level.INFO);
+ policy.setResourceBundleName("Trace_Messages.properties");
+
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
+ processor.write(policy, writer, context);
+ writer.close();
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ StringReader sr = new StringReader(sw.toString());
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(sr);
+
+ policy = processor.read(reader, context);
+ assertEquals(policy.getLoggerName(), "test.logger");
+ assertEquals(policy.getLogLevel(), Level.INFO );
+ assertEquals(policy.getResourceBundleName(), "Trace_Messages.properties");
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml b/sandbox/sebastien/java/embed/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml
new file mode 100644
index 0000000000..0f1c1f978c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<tuscany:jdkLogger xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" name="test.logger">
+ <logLevel>INFO</logLevel>
+ <resourceBundle>Trace_Messages.properties</resourceBundle>
+</tuscany:jdkLogger> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/LICENSE b/sandbox/sebastien/java/embed/modules/policy-security/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/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/sebastien/java/embed/modules/policy-security/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/policy-security/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..16d54e3fe8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/META-INF/MANIFEST.MF
@@ -0,0 +1,88 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.policy.authentication.basic;version="2.0.0";
+ uses:="org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.provider,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.interfacedef,
+ javax.xml.namespace,
+ org.apache.tuscany.sca.invocation,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor",
+ org.apache.tuscany.sca.policy.authentication.token;version="2.0.0",
+ org.apache.tuscany.sca.policy.authorization;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.policy,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.policy.identity;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.policy,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.policy.security;version="2.0.0";
+ uses:="org.apache.tuscany.sca.definitions.util,
+ org.apache.tuscany.sca.provider,
+ org.apache.tuscany.sca.definitions,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core",
+ org.apache.tuscany.sca.policy.security.http.ssl;version="2.0.0",
+ org.apache.tuscany.sca.policy.security.jaas;version="2.0.0";
+ uses:="javax.security.auth.callback,
+ org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.provider,
+ javax.security.auth.login,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef,
+ javax.xml.namespace,
+ org.apache.tuscany.sca.invocation,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.policy.util,
+ org.apache.tuscany.sca.contribution.processor,
+ org.oasisopen.sca"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Security Policy Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Security Policy Model
+Import-Package: javax.security.auth.callback,
+ javax.security.auth.login,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.authentication.basic;version="2.0.0",
+ org.apache.tuscany.sca.policy.authorization;version="2.0.0",
+ org.apache.tuscany.sca.policy.identity;version="2.0.0",
+ org.apache.tuscany.sca.policy.security;version="2.0.0",
+ org.apache.tuscany.sca.policy.security.jaas;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.policy.security
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/NOTICE b/sandbox/sebastien/java/embed/modules/policy-security/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/pom.xml b/sandbox/sebastien/java/embed/modules/policy-security/pom.xml
new file mode 100644
index 0000000000..029f605a4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/pom.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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-security</artifactId>
+ <name>Apache Tuscany SCA Policy Security Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java
new file mode 100644
index 0000000000..c735f63b7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.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.sca.policy.authentication.basic;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationPolicy {
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ public static final QName BASIC_AUTHENTICATION_POLICY_QNAME = new QName(SCA10_TUSCANY_NS, "basicAuthentication");
+ public static final String BASIC_AUTHENTICATION_USERNAME = "userName";
+ public static final String BASIC_AUTHENTICATION_PASSWORD = "password";
+
+ private String userName;
+ private String password;
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public QName getSchemaName() {
+ return BASIC_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java
new file mode 100644
index 0000000000..3df06c1e00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.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.sca.policy.authentication.basic;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationPolicyProcessor implements StAXArtifactProcessor<BasicAuthenticationPolicy> {
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ public QName getArtifactType() {
+ return BasicAuthenticationPolicy.BASIC_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public BasicAuthenticationPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public BasicAuthenticationPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ BasicAuthenticationPolicy policy = new BasicAuthenticationPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if ( name.equals(getArtifactType()) ) {
+ // no attributes at the moment
+ } else if ( BasicAuthenticationPolicy.BASIC_AUTHENTICATION_USERNAME.equals(name.getLocalPart()) ) {
+ policy.setUserName(reader.getElementText());
+ } else if ( BasicAuthenticationPolicy.BASIC_AUTHENTICATION_PASSWORD.equals(name.getLocalPart()) ) {
+ policy.setPassword(reader.getElementText());
+ }
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( getArtifactType().equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(BasicAuthenticationPolicy policy, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", SCA10_TUSCANY_NS);
+
+ if ( policy.getUserName() != null ) {
+ writer.writeStartElement(prefix,
+ BasicAuthenticationPolicy.BASIC_AUTHENTICATION_USERNAME,
+ getArtifactType().getNamespaceURI());
+ writer.writeCharacters(policy.getUserName());
+ writer.writeEndElement();
+ }
+
+ if ( policy.getPassword() != null ) {
+ writer.writeStartElement(prefix,
+ BasicAuthenticationPolicy.BASIC_AUTHENTICATION_PASSWORD,
+ getArtifactType().getNamespaceURI());
+ writer.writeCharacters(policy.getPassword());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<BasicAuthenticationPolicy> getModelType() {
+ return BasicAuthenticationPolicy.class;
+ }
+
+ public void resolve(BasicAuthenticationPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java
new file mode 100644
index 0000000000..3ab9cb656d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.authentication.basic;
+
+import java.security.Principal;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationPrincipal implements Principal {
+
+ private String name;
+ private String password;
+
+ public BasicAuthenticationPrincipal(String name, String password){
+ if (name == null) {
+ throw new IllegalArgumentException("name cannot be null");
+ }
+
+ this.name = name;
+ this.password = password;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+
+ @Override
+ public boolean equals(Object principal) {
+ if (principal == null)
+ return false;
+ if (this == principal)
+ return true;
+ if (getClass() != principal.getClass())
+ return false;
+ final BasicAuthenticationPrincipal other = (BasicAuthenticationPrincipal)principal;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name)){
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java
new file mode 100644
index 0000000000..2cc24a4974
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.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.sca.policy.authentication.token;
+
+import java.security.Principal;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class TokenPrincipal implements Principal {
+
+ private String name;
+
+ public TokenPrincipal(String name){
+ if (name == null) {
+ throw new IllegalArgumentException("name cannot be null");
+ }
+
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+
+ @Override
+ public boolean equals(Object principal) {
+ if (principal == null)
+ return false;
+ if (this == principal)
+ return true;
+ if (getClass() != principal.getClass())
+ return false;
+ final TokenPrincipal other = (TokenPrincipal)principal;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name)){
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java
new file mode 100644
index 0000000000..c970704929
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.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.policy.authorization;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Models the SCA Implementation Security Policy Assertion for Authorization.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AuthorizationPolicy {
+ private final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ // private final static String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName NAME = new QName(SCA11_NS, "authorization");
+
+ public static enum AcessControl {
+ permitAll, denyAll, allow
+ };
+
+ private List<String> roleNames = new ArrayList<String>();
+
+ public AuthorizationPolicy() {
+ }
+
+ private AcessControl accessControl;
+
+ public AcessControl getAccessControl() {
+ return accessControl;
+ }
+
+ public void setAccessControl(AcessControl accessControl) {
+ this.accessControl = accessControl;
+ }
+
+ public List<String> getRoleNames() {
+ if (accessControl == AcessControl.allow) {
+ return roleNames;
+ } else {
+ throw new IllegalArgumentException("Role names are only available for 'allow'");
+ }
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ public QName getSchemaName() {
+ return NAME;
+ }
+
+ @Override
+ public String toString() {
+ if (accessControl == AcessControl.allow) {
+ return accessControl.name() + " " + roleNames;
+ }
+ return accessControl.name();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicyProcessor.java
new file mode 100644
index 0000000000..8a65a10560
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicyProcessor.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.authorization;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.StringTokenizer;
+
+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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class AuthorizationPolicyProcessor implements StAXArtifactProcessor<AuthorizationPolicy> {
+ private static final String ROLES = "roles";
+
+ public QName getArtifactType() {
+ return AuthorizationPolicy.NAME;
+ }
+
+ public AuthorizationPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "policy-security-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public AuthorizationPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ AuthorizationPolicy policy = new AuthorizationPolicy();
+ int event = reader.getEventType();
+ QName start = reader.getName();
+ while (true) {
+ switch (event) {
+ case START_ELEMENT:
+ String ac = reader.getName().getLocalPart();
+ if ("allow".equals(ac)) {
+ policy.setAccessControl(AuthorizationPolicy.AcessControl.allow);
+ String roleNames = reader.getAttributeValue(null, ROLES);
+ if (roleNames == null) {
+ error(context.getMonitor(), "RequiredAttributeRolesMissing", reader);
+ //throw new IllegalArgumentException("Required attribute 'roles' is missing.");
+ } else {
+ StringTokenizer st = new StringTokenizer(roleNames);
+ while (st.hasMoreTokens()) {
+ policy.getRoleNames().add(st.nextToken());
+ }
+ }
+ } else if ("permitAll".equals(ac)) {
+ policy.setAccessControl(AuthorizationPolicy.AcessControl.permitAll);
+ } else if ("denyAll".endsWith(ac)) {
+ policy.setAccessControl(AuthorizationPolicy.AcessControl.denyAll);
+ }
+ break;
+ case END_ELEMENT:
+ if (start.equals(reader.getName())) {
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ return policy;
+ }
+
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return policy;
+ }
+ }
+ }
+
+ public void write(AuthorizationPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ writer.writeStartElement(AuthorizationPolicy.NAME.getLocalPart());
+
+ writer.writeStartElement(policy.getAccessControl().name());
+
+ if (policy.getAccessControl() == AuthorizationPolicy.AcessControl.allow) {
+ StringBuffer sb = new StringBuffer();
+ for (String role : policy.getRoleNames()) {
+ sb.append(role);
+ }
+
+ if (sb.length() > 0) {
+ writer.writeAttribute(ROLES, sb.toString());
+ }
+ }
+
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+
+ public Class<AuthorizationPolicy> getModelType() {
+ return AuthorizationPolicy.class;
+ }
+
+ public void resolve(AuthorizationPolicy policy, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if ((policy.getAccessControl() == AuthorizationPolicy.AcessControl.allow) &&
+ (policy.getRoleNames().isEmpty())){
+ // role names are required so leave policy unresolved
+ return;
+ }
+
+ //right now nothing to resolve
+ policy.setUnresolved(false);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java
new file mode 100644
index 0000000000..773c874a90
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.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.policy.identity;
+
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SecurityIdentityImplementationPolicyInterceptor implements PhasedInterceptor {
+ private List<SecurityIdentityPolicy> securityIdentityPolicies;
+ private Invoker next;
+
+ public SecurityIdentityImplementationPolicyInterceptor(List<SecurityIdentityPolicy> securityIdentityPolicies) {
+ super();
+ this.securityIdentityPolicies = securityIdentityPolicies;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#getNext()
+ */
+ public Invoker getNext() {
+ return next;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#setNext(org.apache.tuscany.sca.invocation.Invoker)
+ */
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.IMPLEMENTATION_POLICY;
+ }
+
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message)
+ */
+ public Message invoke(Message msg) {
+ try {
+
+ Subject subject = SecurityUtil.getSubject(msg);
+
+ // May do some selection here based on runAs settings.
+ // by default though there is nothing to do as the implementation
+ // assumes the callers user credentials
+
+
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return getNext().invoke(msg);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java
new file mode 100644
index 0000000000..ebbc2ba5ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.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.sca.policy.identity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SecurityIdentityImplementationPolicyProvider extends BasePolicyProvider<SecurityIdentityPolicy> {
+ private RuntimeComponent component;
+ private Implementation implementation;
+
+ public SecurityIdentityImplementationPolicyProvider(RuntimeComponent component) {
+ super(SecurityIdentityPolicy.class, component);
+ this.component = component;
+ this.implementation = component.getImplementation();
+ }
+
+ private List<SecurityIdentityPolicy> findPolicies(Operation op) {
+ List<SecurityIdentityPolicy> polices = new ArrayList<SecurityIdentityPolicy>();
+ /*
+ // FIXME: How do we get a list of effective policySets for a given operation?
+ if (implementation instanceof OperationsConfigurator) {
+ OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
+ for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
+ if (cop.getName().equals(op.getName())) {
+ for (PolicySet ps : cop.getPolicySets()) {
+ for (Object p : ps.getPolicies()) {
+ if (SecurityIdentityPolicy.class.isInstance(p)) {
+ polices.add((SecurityIdentityPolicy)p);
+ }
+ }
+ }
+ }
+ }
+ }
+ */
+
+ List<PolicySet> policySets = component.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (SecurityIdentityPolicy.class.isInstance(p)) {
+ polices.add((SecurityIdentityPolicy)p);
+ }
+ }
+ }
+ return polices;
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<SecurityIdentityPolicy> policies = findPolicies(operation);
+ if (policies == null || policies.isEmpty()) {
+ return null;
+ } else {
+ return new SecurityIdentityImplementationPolicyInterceptor(findPolicies(operation));
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java
new file mode 100644
index 0000000000..e4c24168c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.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.sca.policy.identity;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Models the SCA Implementation Security Policy Assertion for Security Identity.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SecurityIdentityPolicy {
+ public static final QName NAME = new QName(Constants.SCA11_TUSCANY_NS, "securityIdentity");
+
+ private boolean useCallerIdentity;
+
+ private String runAsRole;
+
+ public SecurityIdentityPolicy() {
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ public QName getSchemaName() {
+ return NAME;
+ }
+
+ public boolean isUseCallerIdentity() {
+ return useCallerIdentity;
+ }
+
+ public void setUseCallerIdentity(boolean useCallerIdentity) {
+ this.useCallerIdentity = useCallerIdentity;
+ }
+
+ public String getRunAsRole() {
+ return runAsRole;
+ }
+
+ public void setRunAsRole(String runAsRole) {
+ this.runAsRole = runAsRole;
+ }
+
+ @Override
+ public String toString() {
+ if (useCallerIdentity) {
+ return "useCallerIdentity";
+ }
+ return "runAs " + runAsRole;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java
new file mode 100644
index 0000000000..3c91b9fbcf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.identity;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class SecurityIdentityPolicyProcessor implements StAXArtifactProcessor<SecurityIdentityPolicy> {
+ private static final String ROLE = "role";
+
+ public QName getArtifactType() {
+ return SecurityIdentityPolicy.NAME;
+ }
+
+ public SecurityIdentityPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "policy-security-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public SecurityIdentityPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ SecurityIdentityPolicy policy = new SecurityIdentityPolicy();
+ int event = reader.getEventType();
+ QName start = reader.getName();
+ while (true) {
+ switch (event) {
+ case START_ELEMENT:
+ String ac = reader.getName().getLocalPart();
+ if ("runAs".equals(ac)) {
+ String roleName = reader.getAttributeValue(null, ROLE);
+ if (roleName == null) {
+ error(context.getMonitor(), "RequiredAttributeRolesMissing", reader);
+ //throw new IllegalArgumentException("Required attribute 'roles' is missing.");
+ } else {
+ policy.setRunAsRole(roleName);
+ }
+ } else if ("useCallerIdentity".equals(ac)) {
+ policy.setUseCallerIdentity(true);
+ }
+ break;
+ case END_ELEMENT:
+ if (start.equals(reader.getName())) {
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ return policy;
+ }
+
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return policy;
+ }
+ }
+ }
+
+ public void write(SecurityIdentityPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ writer.writeStartElement(SecurityIdentityPolicy.NAME.getLocalPart());
+
+ String child = policy.isUseCallerIdentity() ? "useCallerIdentity" : "runAs";
+ writer.writeStartElement(child);
+
+ if (!policy.isUseCallerIdentity()) {
+ writer.writeAttribute(ROLE, policy.getRunAsRole());
+ }
+
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+
+ public Class<SecurityIdentityPolicy> getModelType() {
+ return SecurityIdentityPolicy.class;
+ }
+
+ public void resolve(SecurityIdentityPolicy policy, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (policy.getRunAsRole() != null)
+ //right now nothing to resolve
+ policy.setUnresolved(false);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java
new file mode 100644
index 0000000000..80e1494796
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.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 org.apache.tuscany.sca.policy.identity;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SecurityIdentityPolicyProviderFactory implements PolicyProviderFactory<SecurityIdentityPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public SecurityIdentityPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return new SecurityIdentityImplementationPolicyProvider(component);
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return null;
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return null;
+ }
+
+ public Class<SecurityIdentityPolicy> getModelType() {
+ return SecurityIdentityPolicy.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.java
new file mode 100644
index 0000000000..50349cdf88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.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.sca.policy.security;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.invocation.Message;
+
+
+/**
+ * Some utilities for dealing with security information in a Tuscany message
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class SecurityUtil {
+
+ public static String SubjectString = "Subject";
+ public static String PrincipalString = "Principal";
+
+ public static Subject getSubject(Message msg){
+
+ Subject subject = (Subject)msg.getHeaders().get(SubjectString);
+
+ if (subject == null){
+ subject = new Subject();
+ msg.getHeaders().put(SubjectString, subject);
+ }
+
+ return subject;
+ }
+
+ public static <T> T getPrincipal(Subject subject, Class<T> clazz){
+ for (Principal msgPrincipal : subject.getPrincipals() ){
+ if (clazz.isInstance(msgPrincipal)){
+ return clazz.cast(msgPrincipal);
+ }
+ }
+
+ return null;
+ }
+
+ public static Principal getPrincipal(Message msg){
+
+ return (Principal)msg.getHeaders().get(PrincipalString);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/http/ssl/HTTPSPolicy.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/http/ssl/HTTPSPolicy.java
new file mode 100644
index 0000000000..cef6eebadc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/http/ssl/HTTPSPolicy.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.security.http.ssl;
+
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Models the SCA Implementation Security Policy Assertion for Confidentiality.
+ *
+ * This would map to enabling SSL communication and would require
+ * the following configuration items :
+ *
+ * - javax.net.ssl.keyStore
+ * - javax.net.ssl.keyStorePassword
+ * - javax.net.ssl.keyStoreType
+ *
+ * - javax.net.ssl.trustStoreType
+ * - javax.net.ssl.trustStore
+ * - javax.net.ssl.trustStorePassword
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPSPolicy {
+ public static final QName NAME = new QName(Constants.SCA11_TUSCANY_NS, "https");
+
+ private String trustStoreType;
+ private String trustStore;
+ private String trustStorePassword;
+
+ private String keyStoreType;
+ private String keyStore;
+ private String keyStorePassword;
+
+
+ public String getTrustStoreType() {
+ return trustStoreType;
+ }
+
+ public void setTrustStoreType(String trustStoreType) {
+ this.trustStoreType = trustStoreType;
+ }
+
+ public String getTrustStore() {
+ return trustStore;
+ }
+
+ public void setTrustStore(String trustStore) {
+ this.trustStore = trustStore;
+ }
+
+ public String getTrustStorePassword() {
+ return trustStorePassword;
+ }
+
+ public void setTrustStorePassword(String trustStorePassword) {
+ this.trustStorePassword = trustStorePassword;
+ }
+
+ public String getKeyStoreType() {
+ return keyStoreType;
+ }
+
+ public void setKeyStoreType(String keyStoreType) {
+ this.keyStoreType = keyStoreType;
+ }
+
+ public String getKeyStore() {
+ return keyStore;
+ }
+
+ public void setKeyStore(String keyStore) {
+ this.keyStore = keyStore;
+ }
+
+ public String getKeyStorePassword() {
+ return keyStorePassword;
+ }
+
+ public void setKeyStorePassword(String keyStorePassword) {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ public QName getSchemaName() {
+ return NAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+
+ }
+
+ public Properties toProperties() {
+ Properties properties = new Properties();
+
+ properties.put("javax.net.ssl.trustStoreType", trustStoreType);
+ properties.put("javax.net.ssl.trustStore", trustStore);
+ properties.put("javax.net.ssl.trustStorePassword", trustStorePassword);
+
+ properties.put("javax.net.ssl.keyStoreType", keyStoreType);
+ properties.put("javax.net.ssl.keyStore", keyStore);
+ properties.put("javax.net.ssl.keyStorePassword", keyStorePassword);
+
+ return properties;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/http/ssl/HTTPSPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/http/ssl/HTTPSPolicyProcessor.java
new file mode 100644
index 0000000000..b0d6da194c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/http/ssl/HTTPSPolicyProcessor.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.security.http.ssl;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+public class HTTPSPolicyProcessor implements StAXArtifactProcessor<HTTPSPolicy> {
+ private static final QName KEY_STORE_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "keyStore");
+ private static final QName TRUST_STORE_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "trustStore");
+
+ public HTTPSPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ public QName getArtifactType() {
+ return HTTPSPolicy.NAME;
+ }
+
+ public Class<HTTPSPolicy> getModelType() {
+ return HTTPSPolicy.class;
+ }
+
+ public HTTPSPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ HTTPSPolicy policy = new HTTPSPolicy();
+ int event = reader.getEventType();
+ QName start = reader.getName();
+ QName name = null;
+ while (true) {
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+ if(KEY_STORE_QNAME.equals(name)) {
+ //<tuscany:keyStore type="JKS" file="conf/tomcat.keystore" password="apache"/>
+ String type = reader.getAttributeValue(null, "type");
+ if(type == null) {
+ Monitor.error(context.getMonitor(),
+ this,
+ "policy-security-validation-messages",
+ "RequiredAttributeKeyStoreTypeMissing");
+ } else {
+ policy.setKeyStoreType(type);
+ }
+
+ String file = reader.getAttributeValue(null, "file");
+ if(file == null) {
+ Monitor.error(context.getMonitor(),
+ this,
+ "policy-security-validation-messages",
+ "RequiredAttributeKeyStoreFileMissing");
+ } else {
+ policy.setKeyStore(file);
+ }
+
+ String password = reader.getAttributeValue(null, "password");
+ if(file == null) {
+ Monitor.error(context.getMonitor(),
+ this,
+ "policy-security-validation-messages",
+ "RequiredAttributeKeyStorePasswordMissing");
+ } else {
+ policy.setKeyStorePassword(password);
+ }
+
+ } else if(TRUST_STORE_QNAME.equals(name)) {
+ //<tuscany:trustStore type="" file="" password=""/>
+ String type = reader.getAttributeValue(null, "type");
+ if(type == null) {
+ Monitor.error(context.getMonitor(),
+ this,
+ "policy-security-validation-messages",
+ "RequiredAttributeTrustStoreTypeMissing");
+ } else {
+ policy.setTrustStoreType(type);
+ }
+
+ String file = reader.getAttributeValue(null, "file");
+ if(file == null) {
+ Monitor.error(context.getMonitor(),
+ this,
+ "policy-security-validation-messages",
+ "RequiredAttributeTrustStoreFileMissing");
+ } else {
+ policy.setTrustStore(file);
+ }
+
+ String password = reader.getAttributeValue(null, "password");
+ if(file == null) {
+ Monitor.error(context.getMonitor(),
+ this,
+ "policy-security-validation-messages",
+ "RequiredAttributeTrustStorePasswordMissing");
+ } else {
+ policy.setTrustStorePassword(password);
+ }
+
+ }
+ break;
+ case END_ELEMENT:
+ if (start.equals(reader.getName())) {
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ return policy;
+ }
+
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return policy;
+ }
+ } }
+
+ public void write(HTTPSPolicy model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ // TODO
+
+ }
+
+ public void resolve(HTTPSPolicy model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java
new file mode 100644
index 0000000000..6425ae7fca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.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.sca.policy.security.jaas;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Policy handler to handle PolicySet containing JaasAuthenticationPolicy instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class JaasAuthenticationImplementationPolicyProvider extends BasePolicyProvider<JaasAuthenticationPolicy> {
+ private RuntimeComponent component;
+ private Implementation implementation;
+
+ public JaasAuthenticationImplementationPolicyProvider(RuntimeComponent component) {
+ super(JaasAuthenticationPolicy.class, component);
+ this.component = component;
+ this.implementation = component.getImplementation();
+ }
+
+ private List<JaasAuthenticationPolicy> findPolicies(Operation op) {
+ List<JaasAuthenticationPolicy> polices = new ArrayList<JaasAuthenticationPolicy>();
+ /*
+ // FIXME: How do we get a list of effective policySets for a given operation?
+ if (implementation instanceof OperationsConfigurator) {
+ OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
+ for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
+ if (cop.getName().equals(op.getName())) {
+ for (PolicySet ps : cop.getPolicySets()) {
+ for (Object p : ps.getPolicies()) {
+ if (JaasAuthenticationPolicy.class.isInstance(p)) {
+ polices.add((JaasAuthenticationPolicy)p);
+ }
+ }
+ }
+ }
+ }
+ }
+ */
+
+ List<PolicySet> policySets = component.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (JaasAuthenticationPolicy.class.isInstance(p)) {
+ polices.add((JaasAuthenticationPolicy)p);
+ }
+ }
+ }
+ return polices;
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<JaasAuthenticationPolicy> policies = findPolicies(operation);
+ if (policies == null || policies.isEmpty()) {
+ return null;
+ } else {
+ return new JaasAuthenticationInterceptor(findPolicies(operation));
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationInterceptor.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationInterceptor.java
new file mode 100644
index 0000000000..247243fcf8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationInterceptor.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.sca.policy.security.jaas;
+
+import java.util.List;
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginContext;
+
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JaasAuthenticationInterceptor implements PhasedInterceptor {
+ private List<JaasAuthenticationPolicy> authenticationPolicies;
+ private Invoker next;
+
+ public JaasAuthenticationInterceptor(List<JaasAuthenticationPolicy> authenticationPolicies) {
+ super();
+ this.authenticationPolicies = authenticationPolicies;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#getNext()
+ */
+ public Invoker getNext() {
+ return next;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#setNext(org.apache.tuscany.sca.invocation.Invoker)
+ */
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message)
+ */
+ public Message invoke(Message msg) {
+ try {
+ for (JaasAuthenticationPolicy policy : authenticationPolicies) {
+ CallbackHandler callbackHandler =
+ (CallbackHandler)policy.getCallbackHandlerClass().newInstance();
+ LoginContext lc = new LoginContext(policy.getConfigurationName(), callbackHandler);
+ lc.login();
+ // Subject subject = lc.getSubject();
+ }
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return getNext().invoke(msg);
+ }
+
+ public String getPhase() {
+ return Phase.IMPLEMENTATION_POLICY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java
new file mode 100644
index 0000000000..65d8b5c597
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.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.policy.security.jaas;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JaasAuthenticationPolicy {
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName NAME = new QName(SCA10_TUSCANY_NS, "jaasAuthentication");
+
+ private String configurationName = "other";
+ private String callbackHandlerClassName;
+ private Class<?> callbackHandlerClass;
+
+ public String getCallbackHandlerClassName() {
+ return callbackHandlerClassName;
+ }
+
+ public void setCallbackHandlerClassName(String callbackHandlerClassName) {
+ this.callbackHandlerClassName = callbackHandlerClassName;
+ }
+
+ public Class<?> getCallbackHandlerClass() {
+ return callbackHandlerClass;
+ }
+
+ public void setCallbackHandlerClass(Class<?> callbackHandlerClass) {
+ this.callbackHandlerClass = callbackHandlerClass;
+ }
+
+ public QName getSchemaName() {
+ return NAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ public String getConfigurationName() {
+ return configurationName;
+ }
+
+ public void setConfigurationName(String configurationName) {
+ this.configurationName = configurationName;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java
new file mode 100644
index 0000000000..16629e4c6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.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.policy.security.jaas;
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginContext;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Policy handler to handle PolicySet containing JaasAuthenticationPolicy instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class JaasAuthenticationPolicyHandler {
+ private static final String jaasPolicy = "JaasPolicy";
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, jaasPolicy);
+ private PolicySet applicablePolicySet = null;
+
+ public void setUp(Object... context) {
+ if (applicablePolicySet != null) {
+ }
+ }
+
+ public void cleanUp(Object... context) {
+ }
+
+ public void beforeInvoke(Object... context) {
+ try {
+ JaasAuthenticationPolicy policy = (JaasAuthenticationPolicy)applicablePolicySet.getPolicies().get(0);
+ CallbackHandler callbackHandler =
+ (CallbackHandler)policy.getCallbackHandlerClass().newInstance();
+ LoginContext lc = new LoginContext(policy.getConfigurationName(), callbackHandler);
+ lc.login();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ public void afterInvoke(Object... context) {
+
+ }
+
+ public PolicySet getApplicablePolicySet() {
+ return applicablePolicySet;
+ }
+
+ public void setApplicablePolicySet(PolicySet applicablePolicySet) {
+ this.applicablePolicySet = applicablePolicySet;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java
new file mode 100644
index 0000000000..b9ab68aa2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.security.jaas;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class JaasAuthenticationPolicyProcessor implements StAXArtifactProcessor<JaasAuthenticationPolicy> {
+ private static final QName JAAS_AUTHENTICATION_POLICY_QNAME = JaasAuthenticationPolicy.NAME;
+ private static final String callbackHandler = "callbackHandler";
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName CALLBACK_HANDLER_QNAME = new QName(SCA10_TUSCANY_NS, callbackHandler);
+ public static final QName CONFIGURATION_QNAME = new QName(SCA10_TUSCANY_NS, "configurationName");
+
+
+ public QName getArtifactType() {
+ return JAAS_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public JaasAuthenticationPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "policy-security-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public JaasAuthenticationPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ JaasAuthenticationPolicy policy = new JaasAuthenticationPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if (name.equals(CALLBACK_HANDLER_QNAME)) {
+ String callbackHandlerClassName = reader.getElementText();
+ if (callbackHandlerClassName != null) {
+ policy.setCallbackHandlerClassName(callbackHandlerClassName.trim());
+ }
+ }
+ if (name.equals(CONFIGURATION_QNAME)) {
+ String configurationName = reader.getElementText();
+ if (configurationName != null) {
+ policy.setConfigurationName(configurationName.trim());
+ }
+ }
+
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( JAAS_AUTHENTICATION_POLICY_QNAME.equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(JaasAuthenticationPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ JAAS_AUTHENTICATION_POLICY_QNAME.getLocalPart(),
+ JAAS_AUTHENTICATION_POLICY_QNAME.getNamespaceURI());
+ writer.writeNamespace("tuscany", SCA10_TUSCANY_NS);
+
+
+ writer.writeEndElement();
+ }
+
+ public Class<JaasAuthenticationPolicy> getModelType() {
+ return JaasAuthenticationPolicy.class;
+ }
+
+ public void resolve(JaasAuthenticationPolicy policy, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+
+ if (policy.getCallbackHandlerClassName() != null) {
+ ClassReference classReference = new ClassReference(policy.getCallbackHandlerClassName());
+ classReference = resolver.resolveModel(ClassReference.class, classReference, context);
+ Class<?> callbackClass = classReference.getJavaClass();
+ if (callbackClass == null) {
+ error(context.getMonitor(), "ClassNotFoundException", resolver, policy.getCallbackHandlerClassName());
+ //throw new ContributionResolveException(new ClassNotFoundException(policy.getCallbackHandlerClassName()));
+ } else {
+ policy.setCallbackHandlerClass(callbackClass);
+ policy.setUnresolved(false);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProviderFactory.java
new file mode 100644
index 0000000000..ab1ab1870f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProviderFactory.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.policy.security.jaas;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JaasAuthenticationPolicyProviderFactory implements PolicyProviderFactory<JaasAuthenticationPolicy> {
+
+ public JaasAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return new JaasAuthenticationImplementationPolicyProvider(component);
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class<JaasAuthenticationPolicy> getModelType() {
+ return JaasAuthenticationPolicy.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..f402c6f749
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.policy.authentication.basic.BasicAuthenticationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#basicAuthentication,model=org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy
+org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#https,model=org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicy
+
+# TODO - following processors are old and somewhat questionable for 2.x, needs reviewing
+org.apache.tuscany.sca.policy.authorization.AuthorizationPolicyProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#authorization,model=org.apache.tuscany.sca.policy.authorization.AuthorizationPolicy
+org.apache.tuscany.sca.policy.authorization.AuthorizationPolicyProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#allow,model=org.apache.tuscany.sca.policy.authorization.AuthorizationPolicy
+org.apache.tuscany.sca.policy.authorization.AuthorizationPolicyProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#permitAll,model=org.apache.tuscany.sca.policy.authorization.AuthorizationPolicy
+org.apache.tuscany.sca.policy.authorization.AuthorizationPolicyProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#denyAll,model=org.apache.tuscany.sca.policy.authorization.AuthorizationPolicy
+org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicyProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#runAs,model=org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicy
+org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#securityIdentity,model=org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicy
+org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#jaasAuthentication,model=org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicy
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..6c3579dd2e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -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/policy/security/definitions.xml
+org/apache/tuscany/sca/policy/security/tuscany_definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
new file mode 100644
index 0000000000..37c5ee9cc0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation classs for policy extensions that are neither binding nor implementation specific
+org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicy
+org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicyProviderFactory;model=org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicy
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml
new file mode 100644
index 0000000000..21923b3a3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- POLICY SETS -->
+ <policySet name="runAs" appliesTo="sca:implementation.java"/>
+ <policySet name="allow" appliesTo="sca:implementation.java"/>
+ <policySet name="rolesAllowed" appliesTo="sca:implementation.java"/>
+ <policySet name="permitAll" appliesTo="sca:implementation.java"/>
+ <policySet name="denyAll" appliesTo="sca:implementation.java"/>
+
+ <!-- see the file sca-policy-1.1-intents-definitions.xml in the -->
+ <!-- assembly-xsd module for spec defined intents -->
+
+</definitions>
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml
new file mode 100644
index 0000000000..45d4ebaf5e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <intent name="identity" constrains="sca:implementation">
+ <description>All invocations are must have an identity set</description>
+ </intent>
+
+ <intent name="jaasAuthentication" constrains="sca:implementation.java">
+ <description>All invocations to be authenticated</description>
+ </intent>
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/policy-security-validation-messages.properties b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/policy-security-validation-messages.properties
new file mode 100644
index 0000000000..d41dbc3c70
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/main/resources/policy-security-validation-messages.properties
@@ -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.
+#
+#
+RequiredAttributeRolesMissing = Required attribute 'roles' is missing.
+ClassNotFoundException = Class Not Found Exception: {0}
+RequiredAttributeKeyStoreTypeMissing = Required attribute 'type' of keyStore element is missing
+RequiredAttributeKeyStoreFileMissing = Required attribute 'file' of keyStore element is missing
+RequiredAttributeKeyStorePasswordMissing = Required attribute 'password' of keyStore element is missing
+RequiredAttributeTrustStoreTypeMissing = Required attribute 'type' of trustStore element is missing
+RequiredAttributeTrustStoreFileMissing = Required attribute 'file' of trustStore element is missing
+RequiredAttributeTrustStorePasswordMissing = Required attribute 'password' of trustStore element is missing \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/test/java/org/apache/tuscany/sca/policy/security/PolicyProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/policy-security/src/test/java/org/apache/tuscany/sca/policy/security/PolicyProcessorTestCase.java
new file mode 100644
index 0000000000..653f6d621c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/test/java/org/apache/tuscany/sca/policy/security/PolicyProcessorTestCase.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.policy.security;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.policy.authorization.AuthorizationPolicy;
+import org.apache.tuscany.sca.policy.authorization.AuthorizationPolicyProcessor;
+import org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicy;
+import org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicyProcessor;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PolicyProcessorTestCase {
+ private final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+ private final static List<String> SEQ =
+ Arrays.asList("permitAll",
+ "allow [r1, r2]",
+ "denyAll",
+ "runAs admin",
+ "useCallerIdentity",
+ "permitAll",
+ "allow [r1, r2]",
+ "denyAll",
+ "runAs admin");
+
+ @Test
+ public void testRead() throws Exception {
+ List<String> results = new ArrayList<String>();
+ Map<QName, StAXArtifactProcessor> processors = new HashMap<QName, StAXArtifactProcessor>();
+ processors.put(AuthorizationPolicy.NAME, new AuthorizationPolicyProcessor(null));
+ processors.put(SecurityIdentityPolicy.NAME, new SecurityIdentityPolicyProcessor(null));
+ processors.put(new QName(SCA11_NS, "allow"), new AuthorizationPolicyProcessor(null));
+ processors.put(new QName(SCA11_NS, "permitAll"), new AuthorizationPolicyProcessor(null));
+ processors.put(new QName(SCA11_NS, "denyAll"), new AuthorizationPolicyProcessor(null));
+ processors.put(new QName(SCA11_NS, "runAs"), new SecurityIdentityPolicyProcessor(null));
+ InputStream is = getClass().getResourceAsStream("mock_policy_definitions.xml");
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ XMLStreamReader reader = factory.createXMLStreamReader(is);
+ while (true) {
+ int event = reader.getEventType();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ if ("policySet".equals(reader.getName().getLocalPart())) {
+ reader.nextTag();
+ results.add(processors.get(reader.getName()).read(reader, new ProcessorContext()).toString());
+ }
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ Assert.assertEquals(SEQ, results);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml b/sandbox/sebastien/java/embed/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml
new file mode 100644
index 0000000000..91ab004a7e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+ <!-- POLICY SETS -->
+ <policySet name="ps1" provides="authorization" appliesTo="sca:implementation">
+ <authorization>
+ <permitAll />
+ </authorization>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps2" provides="authorization" appliesTo="sca:implementation">
+ <authorization>
+ <allow roles="r1 r2" />
+ </authorization>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps3" provides="authorization" appliesTo="sca:implementation">
+ <authorization>
+ <denyAll />
+ </authorization>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps4" provides="securityIdentity" appliesTo="sca:implementation">
+ <tuscany:securityIdentity>
+ <tuscany:runAs role="admin" />
+ </tuscany:securityIdentity>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps5" provides="securityIdentity" appliesTo="sca:implementation">
+ <tuscany:securityIdentity>
+ <tuscany:useCallerIdentity />
+ </tuscany:securityIdentity>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps6" provides="authorization" appliesTo="sca:implementation">
+ <permitAll />
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps7" provides="authorization" appliesTo="sca:implementation">
+ <allow roles="r1 r2" />
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps8" provides="authorization" appliesTo="sca:implementation">
+ <denyAll />
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps9" provides="securityIdentity" appliesTo="sca:implementation">
+ <runAs role="admin" />
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..6872cb5249
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/META-INF/MANIFEST.MF
@@ -0,0 +1,35 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Transaction Policy Runtime Geronimo
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Security Policy Model
+Import-Package: javax.security.auth.callback,
+ javax.security.auth.login,
+ javax.transaction;version="1.1.0",
+ javax.transaction.xa;version="1.1.0",
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.geronimo.transaction.log,
+ org.apache.geronimo.transaction.manager,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.transaction;version="2.0.0",
+ org.apache.tuscany.sca.policy.transaction.runtime;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.policy.transaction.runtime.geronimo
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/pom.xml b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/pom.xml
new file mode 100644
index 0000000000..2f8e9d0da0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-transaction-runtime-geronimo</artifactId>
+ <name>Apache Tuscany SCA Transaction Policy Runtime (Geronimo)</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-transaction-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-transaction</artifactId>
+ <version>2.1.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-connector</artifactId>
+ <version>2.1.3</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/GeronimoTransactionManagerHelper.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/GeronimoTransactionManagerHelper.java
new file mode 100644
index 0000000000..6ec8b34848
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/GeronimoTransactionManagerHelper.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 org.apache.tuscany.sca.policy.transaction.runtime.geronimo;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.transaction.runtime.TransactionManagerHelper;
+
+public class GeronimoTransactionManagerHelper extends TransactionManagerHelper {
+
+ public GeronimoTransactionManagerHelper(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public GeronimoTransactionManagerHelper(TransactionManager tm) {
+ super(tm);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionManagerWrapper.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionManagerWrapper.java
new file mode 100644
index 0000000000..27e777b2c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionManagerWrapper.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.policy.transaction.runtime.geronimo;
+
+import java.io.File;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.geronimo.transaction.log.HOWLLog;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.apache.geronimo.transaction.manager.XidFactory;
+import org.apache.geronimo.transaction.manager.XidFactoryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionManagerWrapper {
+ private TransactionManager transactionManager;
+ private HOWLLog howlLog;
+
+ private String logFileDir = "target/logs";
+ private String bufferClassName = "org.objectweb.howl.log.BlockLogBuffer";
+ private int bufferSizeKBytes = 32;
+ private boolean checksumEnabled = true;
+ private boolean adler32Checksum = true;
+ private int flushSleepTimeMilliseconds = 50;
+ private String logFileExt = "log";
+ private String logFileName = "transaction";
+ private int maxBlocksPerFile = -1;
+ private int maxLogFiles = 2;
+ private int maxBuffers = 0;
+ private int minBuffers = 4;
+ private int threadsWaitingForceThreshold = -1;
+ private File serverBaseDir = new File(System.getProperty("basedir", System.getProperty("user.dir")));
+
+ public TransactionManagerWrapper() {
+ super();
+ }
+
+ public void start() {
+ try {
+ XidFactory xidFactory = new XidFactoryImpl();
+ howlLog =
+ new HOWLLog(bufferClassName, bufferSizeKBytes, checksumEnabled, adler32Checksum,
+ flushSleepTimeMilliseconds, logFileDir, logFileExt, logFileName, maxBlocksPerFile,
+ maxBuffers, maxLogFiles, minBuffers, threadsWaitingForceThreshold, xidFactory,
+ serverBaseDir);
+
+ howlLog.doStart();
+ transactionManager = new GeronimoTransactionManager(1200, xidFactory, howlLog);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.ModuleActivator#stop(org.apache.tuscany.sca.core.ExtensionPointRegistry)
+ */
+ public void stop() {
+ try {
+ if (howlLog != null) {
+ howlLog.doStop();
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public TransactionManager getTransactionManager() {
+ return transactionManager;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionModuleActivator.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionModuleActivator.java
new file mode 100644
index 0000000000..3f43cac8d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionModuleActivator.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.sca.policy.transaction.runtime.geronimo;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionModuleActivator implements ModuleActivator {
+ private TransactionManagerWrapper wrapper;
+ private ExtensionPointRegistry registry;
+
+ public TransactionModuleActivator(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.ModuleActivator#start(org.apache.tuscany.sca.core.ExtensionPointRegistry)
+ */
+ public void start() {
+ if (registry != null) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ TransactionManager transactionManager = utilities.getUtility(TransactionManager.class);
+ if (transactionManager != null) {
+ // The transaction manage is provided by the hosting environment
+// RuntimeWireProcessorExtensionPoint wireProcessorExtensionPoint =
+// registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class);
+// TransactionManagerHelper helper = new TransactionManagerHelper(transactionManager);
+// wireProcessorExtensionPoint.addWireProcessor(new TransactionRuntimeWireProcessor(helper));
+ return;
+ }
+ }
+ try {
+ wrapper = new TransactionManagerWrapper();
+ wrapper.start();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ if (registry != null) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ utilities.addUtility(wrapper.getTransactionManager());
+// RuntimeWireProcessorExtensionPoint wireProcessorExtensionPoint =
+// registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class);
+// TransactionManagerHelper helper = new TransactionManagerHelper(wrapper.getTransactionManager());
+// wireProcessorExtensionPoint.addWireProcessor(new TransactionRuntimeWireProcessor(helper));
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.core.ModuleActivator#stop(org.apache.tuscany.sca.core.ExtensionPointRegistry)
+ */
+ public void stop() {
+ try {
+ if (wrapper != null) {
+ wrapper.stop();
+ wrapper = null;
+ }
+ if (registry != null && wrapper != null) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ utilities.removeUtility(wrapper.getTransactionManager());
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
new file mode 100644
index 0000000000..890ac4694b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/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 ModuleActivator
+org.apache.tuscany.sca.policy.transaction.runtime.geronimo.TransactionModuleActivator
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.runtime.TransactionManagerHelper b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.runtime.TransactionManagerHelper
new file mode 100644
index 0000000000..7d88aee19d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.runtime.TransactionManagerHelper
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.policy.transaction.runtime.geronimo.GeronimoTransactionManagerHelper \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/test/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionManagerHelperTestCaseOFF.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/test/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionManagerHelperTestCaseOFF.java
new file mode 100644
index 0000000000..07ce921ebe
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime-geronimo/src/test/java/org/apache/tuscany/sca/policy/transaction/runtime/geronimo/TransactionManagerHelperTestCaseOFF.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.transaction.runtime.geronimo;
+
+import java.util.logging.Logger;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import junit.framework.TestCase;
+
+import org.apache.geronimo.transaction.manager.NamedXAResource;
+import org.apache.tuscany.sca.policy.transaction.runtime.TransactionManagerHelper;
+import org.apache.tuscany.sca.policy.transaction.runtime.geronimo.TransactionManagerWrapper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionManagerHelperTestCaseOFF extends TestCase {
+ private static final Logger logger = Logger.getLogger(TransactionManagerHelperTestCaseOFF.class.getName());
+
+ public static class MockXAResource implements NamedXAResource {
+
+ private String rm;
+ private String id;
+ private int timeout = 1000;
+
+ public MockXAResource(String rm, String id) {
+ super();
+ this.rm = rm;
+ this.id = id;
+ }
+
+ public String getName() {
+ return rm + ":" + id;
+ }
+
+ public void commit(Xid xid, boolean onePhase) throws XAException {
+ logger.info(id + ": commit(" + xid + "," + onePhase + ")");
+ }
+
+ public void end(Xid xid, int flags) throws XAException {
+ logger.info(id + ": end(" + xid + "," + toString(flags) + ")");
+ }
+
+ public void forget(Xid xid) throws XAException {
+ logger.info(id + ": forget(" + xid + ")");
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ return timeout;
+ }
+
+ public boolean isSameRM(XAResource xares) throws XAException {
+ if (xares instanceof MockXAResource) {
+ MockXAResource res = (MockXAResource)xares;
+ return res.rm.endsWith(rm);
+ } else {
+ return false;
+ }
+ }
+
+ public int prepare(Xid xid) throws XAException {
+ logger.info(id + ": prepare(" + xid + ")");
+ return XA_OK;
+ }
+
+ public Xid[] recover(int flag) throws XAException {
+ return null;
+ }
+
+ public void rollback(Xid xid) throws XAException {
+ logger.info(id + ": rollback(" + xid + ")");
+ }
+
+ public boolean setTransactionTimeout(int seconds) throws XAException {
+ this.timeout = seconds;
+ return true;
+ }
+
+ public void start(Xid xid, int flags) throws XAException {
+ logger.info(id + ": start(" + xid + "," + toString(flags) + ")");
+ }
+
+ private String toString(int flags) {
+ StringBuffer sb = new StringBuffer();
+ if ((flags & TMENDRSCAN) != 0) {
+ sb.append("TMENDRSCAN ");
+ }
+ if ((flags & TMFAIL) != 0) {
+ sb.append("TMFAIL ");
+ }
+ if ((flags & TMJOIN) != 0) {
+ sb.append("TMJOIN ");
+ }
+ if ((flags & TMONEPHASE) != 0) {
+ sb.append("TMONEPHASE ");
+ }
+ if ((flags & TMRESUME) != 0) {
+ sb.append("TMRESUME ");
+ }
+ if ((flags & TMSTARTRSCAN) != 0) {
+ sb.append("TMSTARTRSCAN ");
+ }
+ if ((flags & TMSUCCESS) != 0) {
+ sb.append("TMSUCCESS ");
+ }
+ if ((flags & TMSUSPEND) != 0) {
+ sb.append("TMSUSPEND ");
+ }
+ if (sb.length() == 0) {
+ sb.append("TMNOFLAGS");
+ } else {
+ sb.deleteCharAt(sb.length() - 1);
+ }
+ return sb.toString();
+ }
+
+ }
+
+ public void testHelper() throws Exception {
+ TransactionManagerWrapper activator = new TransactionManagerWrapper();
+ activator.start();
+ TransactionManager tm = activator.getTransactionManager();
+ // GeronimoUserTransaction tx = new GeronimoUserTransaction(tm);
+ TransactionManagerHelper helper = new TransactionManagerHelper(tm);
+
+ // No TX yet
+ assertNull(tm.getTransaction());
+ Transaction t1 = helper.managedGlobalTransactionPreInvoke();
+ // Should create T1
+ assertNotNull(t1);
+ // The current TX should be T1
+ assertSame(t1, tm.getTransaction());
+
+ XAResource res1 = new MockXAResource("Derby", "001");
+ XAResource res2 = new MockXAResource("DB2", "002");
+ tm.getTransaction().enlistResource(res1);
+ tm.getTransaction().enlistResource(res2);
+
+ Transaction suspended = helper.suspendsTransactionPreInvoke();
+ suspended.delistResource(res1, XAResource.TMSUSPEND);
+ suspended.delistResource(res2, XAResource.TMSUSPEND);
+
+ // T1 is suspended
+ assertSame(t1, suspended);
+ // No more active TX
+ assertNull(tm.getTransaction());
+
+ Transaction t2 = helper.managedGlobalTransactionPreInvoke();
+ assertNotNull(t2);
+ // The current TX should be T2
+ assertSame(t2, tm.getTransaction());
+
+ XAResource res3 = new MockXAResource("Oracle", "003");
+ tm.getTransaction().enlistResource(res3);
+
+ tm.getTransaction().delistResource(res3, XAResource.TMSUCCESS);
+ tm.rollback();
+
+ // Skip post
+ // helper.managedGlobalTransactionPostInvoke(t2);
+
+ helper.suspendsTransactionPostInvoke(suspended);
+ suspended.enlistResource(res1);
+ suspended.enlistResource(res2);
+ // T1 is now resumed
+ assertSame(t1, tm.getTransaction());
+
+ helper.managedGlobalTransactionPostInvoke(t1, false);
+ assertNotNull(tm.getTransaction());
+ assertEquals(6, t1.getStatus());
+
+ activator.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..df084390b8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Transaction Policy Runtime
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Security Policy Model
+Import-Package: javax.security.auth.callback,
+ javax.security.auth.login,
+ javax.transaction;version="1.1.0",
+ javax.transaction.xa;version="1.1.0",
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.transaction;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.policy.transaction.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.policy.transaction.runtime;version="2.0.0"
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/pom.xml b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/pom.xml
new file mode 100644
index 0000000000..035621631e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/pom.xml
@@ -0,0 +1,63 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-transaction-runtime</artifactId>
+ <name>Apache Tuscany SCA Transaction Policy Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-transaction</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/IncompatibleIntentException.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/IncompatibleIntentException.java
new file mode 100644
index 0000000000..e3cb6fc359
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/IncompatibleIntentException.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.policy.transaction.runtime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IncompatibleIntentException extends Exception {
+ private static final long serialVersionUID = -2993825019200280397L;
+
+ public IncompatibleIntentException() {
+ super();
+ }
+
+ public IncompatibleIntentException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IncompatibleIntentException(String message) {
+ super(message);
+ }
+
+ public IncompatibleIntentException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java
new file mode 100644
index 0000000000..dc042ed5cc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionImplementationPolicyProvider.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.transaction.runtime;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionImplementationPolicyProvider extends BasePolicyProvider<TransactionPolicy> {
+ private TransactionManagerHelper helper;
+
+ public TransactionImplementationPolicyProvider(TransactionManagerHelper helper, RuntimeComponent component) {
+ super(TransactionPolicy.class, component);
+ this.helper = helper;
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<TransactionPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new TransactionInterceptor(helper, false, null, policies.get(0), getPhase());
+ }
+
+ public String getPhase() {
+ return Phase.IMPLEMENTATION_POLICY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionIntent.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionIntent.java
new file mode 100644
index 0000000000..196b9cc0a1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionIntent.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.transaction.runtime;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public enum TransactionIntent {
+ managedTransactionLocal,
+ managedTransactionGlobal,
+ noManagedTransaction,
+ propagatesTransacton,
+ suspendsTransaction,
+ transactedOneWay,
+ immediateOneWay
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionInterceptor.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionInterceptor.java
new file mode 100644
index 0000000000..f6e0e87ece
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionInterceptor.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.policy.transaction.runtime;
+
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionInterceptor implements PhasedInterceptor {
+ private static final Logger logger = Logger.getLogger(TransactionInterceptor.class.getName());
+
+ private Invoker next;
+ private TransactionManagerHelper helper;
+ private boolean outbound;
+ private TransactionPolicy interactionPolicy;
+ private TransactionPolicy implementationPolicy;
+ private String phase;
+
+ public TransactionInterceptor(TransactionManagerHelper helper,
+ boolean outbound,
+ TransactionPolicy interactionPolicy,
+ TransactionPolicy implementationPolicy,
+ String phase) {
+ super();
+ this.helper = helper;
+ this.outbound = outbound;
+ this.interactionPolicy = interactionPolicy;
+ this.implementationPolicy = implementationPolicy;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#getNext()
+ */
+ public Invoker getNext() {
+ return next;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#setNext(org.apache.tuscany.sca.invocation.Invoker)
+ */
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message)
+ */
+ public Message invoke(Message msg) {
+ //logger.info("Executing TransactionInterceptor.invoke");
+ TransactionalInvocation invocation = new TransactionalInvocation(next, msg);
+
+ Message result = null;
+ if (msg.getOperation().isNonBlocking()) {
+
+ }
+
+ // initialize default values
+ TransactionIntent interactionIntent = null; //TransactionIntent.propagatesTransacton;
+ TransactionIntent implementationIntent = TransactionIntent.managedTransactionGlobal;
+
+ if (interactionPolicy != null) {
+ if (interactionPolicy.getAction() == TransactionPolicy.Action.PROPAGATE) {
+ interactionIntent = TransactionIntent.propagatesTransacton;
+ } else if (interactionPolicy.getAction() == TransactionPolicy.Action.REQUIRE_NONE) {
+ interactionIntent = TransactionIntent.suspendsTransaction;
+ if(implementationPolicy == null) {
+ implementationIntent = TransactionIntent.noManagedTransaction;
+ }
+ } else {
+ interactionIntent = TransactionIntent.suspendsTransaction;
+ }
+ }
+
+ if (implementationPolicy != null) {
+ switch (implementationPolicy.getAction()) {
+ case REQUIRE_GLOBAL:
+ implementationIntent = TransactionIntent.managedTransactionGlobal;
+ break;
+ case REQUIRE_LOCAL:
+ implementationIntent = TransactionIntent.managedTransactionLocal;
+ break;
+ default:
+ implementationIntent = TransactionIntent.noManagedTransaction;
+ break;
+ }
+ }
+ try {
+ if (outbound) {
+ result = helper.handlesOutbound(interactionIntent, implementationIntent, invocation);
+ } else {
+ result = helper.handlesInbound(interactionIntent, implementationIntent, invocation);
+ }
+
+ } catch (Throwable e) {
+ if (e instanceof Error) {
+ throw (Error)e;
+ } else if (e instanceof RuntimeException) {
+ throw (RuntimeException)e;
+ } else {
+ result = msg;
+ msg.setFaultBody(e);
+ }
+
+ }
+ return result;
+ }
+
+ private static class TransactionalInvocation implements TransactionalAction<Message> {
+ private final Invoker invoker;
+ private final Message message;
+
+ public TransactionalInvocation(Invoker invoker, Message message) {
+ super();
+ this.invoker = invoker;
+ this.message = message;
+ }
+
+ public Message run() throws Exception {
+ return invoker.invoke(message);
+ }
+
+ }
+
+ public String getPhase() {
+ return phase;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionManagerHelper.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionManagerHelper.java
new file mode 100644
index 0000000000..6d67e51bd7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionManagerHelper.java
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.transaction.runtime;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionManagerHelper {
+ // private static final Logger logger = Logger.getLogger(TransactionManagerHelper.class.getName());
+
+ private TransactionManager tm;
+
+ public TransactionManagerHelper(ExtensionPointRegistry registry) {
+ super();
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.tm = utilities.getUtility(TransactionManager.class);
+ }
+
+ public TransactionManagerHelper(TransactionManager tm) {
+ super();
+ this.tm = tm;
+ }
+
+ public Transaction managedGlobalTransactionPreInvoke() throws SystemException, NotSupportedException {
+ int status = tm.getStatus();
+ if (status == Status.STATUS_COMMITTED || status == Status.STATUS_NO_TRANSACTION
+ || status == Status.STATUS_ROLLEDBACK) {
+ tm.begin();
+ return tm.getTransaction();
+ }
+ return null;
+ }
+
+ public void managedGlobalTransactionPostInvoke(Transaction created, boolean rollback)
+ throws InvalidTransactionException, IllegalStateException, SystemException, SecurityException,
+ HeuristicMixedException, HeuristicRollbackException, RollbackException {
+ if (created != null) {
+ int status = created.getStatus();
+ if (status == Status.STATUS_MARKED_ROLLBACK) {
+ created.rollback();
+ } else if (status == Status.STATUS_ACTIVE) {
+ if (rollback) {
+ created.rollback();
+ } else {
+ created.commit();
+ }
+ }
+ }
+ }
+
+ public Transaction suspendsTransactionPreInvoke() throws SystemException {
+ if (tm.getTransaction() != null) {
+ return tm.suspend();
+ } else {
+ return null;
+ }
+ }
+
+ public void suspendsTransactionPostInvoke(Transaction suspended) throws InvalidTransactionException,
+ IllegalStateException, SystemException {
+ if (suspended != null) {
+ tm.resume(suspended);
+ }
+ }
+
+ public TransactionManager getTransactionManager() {
+ return tm;
+ }
+
+ public void setTransactionManager(TransactionManager tm) {
+ this.tm = tm;
+ }
+
+ public void validateOneway(TransactionIntent onewayIntent, TransactionIntent implIntent)
+ throws IncompatibleIntentException {
+ if (onewayIntent == TransactionIntent.transactedOneWay) {
+ if (implIntent != TransactionIntent.managedTransactionGlobal) {
+ throw new IncompatibleIntentException(onewayIntent + "<-X->" + implIntent);
+ }
+ }
+ }
+
+ public void validateInbound(TransactionIntent serviceIntent, TransactionIntent implIntent)
+ throws IncompatibleIntentException {
+ if (serviceIntent == TransactionIntent.propagatesTransacton) {
+ if (implIntent != TransactionIntent.managedTransactionGlobal) {
+ throw new IncompatibleIntentException(serviceIntent + "<-X->" + implIntent);
+ }
+ }
+ }
+
+ public void validateOutbound(TransactionIntent referenceIntent, TransactionIntent implIntent)
+ throws IncompatibleIntentException {
+ if (referenceIntent == TransactionIntent.propagatesTransacton) {
+ if (implIntent != TransactionIntent.managedTransactionGlobal) {
+ throw new IncompatibleIntentException(referenceIntent + "<-X->" + implIntent);
+ }
+ }
+ }
+
+ public <T> T handlesOutbound(TransactionIntent referenceIntent,
+ TransactionIntent implIntent,
+ TransactionalAction<T> action) throws Exception {
+
+ if (implIntent == null) {
+ implIntent = TransactionIntent.noManagedTransaction;
+ }
+
+ if (referenceIntent == TransactionIntent.propagatesTransacton) {
+ if (implIntent != TransactionIntent.managedTransactionGlobal) {
+ throw new IncompatibleIntentException(referenceIntent + "<-X->" + implIntent);
+ } else {
+ // propagates the current TX
+ return run(action);
+ }
+ } else if (referenceIntent == TransactionIntent.suspendsTransaction) {
+ Transaction tx = suspendsTransactionPreInvoke();
+ try {
+ return run(action);
+ } finally {
+ suspendsTransactionPostInvoke(tx);
+ }
+ } else {
+ return run(action);
+ }
+ }
+
+ private <T> T run(TransactionalAction<T> action) throws Exception {
+ // Make sure a global TX is in place
+ Transaction tx = managedGlobalTransactionPreInvoke();
+ boolean rollback = false;
+ try {
+ return action.run();
+ } catch (InvocationTargetException e) {
+ throw e;
+ } catch (Throwable e) {
+ rollback = true;
+ if (e instanceof Error) {
+ throw (Error)e;
+ } else if (e instanceof RuntimeException) {
+ throw (RuntimeException)e;
+ } else {
+ throw (Exception)e;
+ }
+ } finally {
+ managedGlobalTransactionPostInvoke(tx, rollback);
+ }
+ }
+
+ public <T> T handlesInbound(TransactionIntent serviceIntent,
+ TransactionIntent implIntent,
+ TransactionalAction<T> action) throws Exception {
+ if (serviceIntent == null && implIntent == null) {
+ return run(action);
+ }
+
+ if (implIntent == null) {
+ implIntent = TransactionIntent.noManagedTransaction;
+ }
+
+ if (serviceIntent == TransactionIntent.propagatesTransacton) {
+ if (implIntent != TransactionIntent.managedTransactionGlobal) {
+ throw new IncompatibleIntentException(serviceIntent + "<-X->" + implIntent);
+ } else {
+ return run(action);
+ }
+ } else if (serviceIntent == TransactionIntent.suspendsTransaction) {
+ Transaction tx1 = suspendsTransactionPreInvoke();
+ try {
+ if (implIntent == TransactionIntent.managedTransactionGlobal) {
+ return run(action);
+ } else {
+ return action.run();
+ }
+ } finally {
+ suspendsTransactionPostInvoke(tx1);
+ }
+ } else {
+ if (implIntent == TransactionIntent.managedTransactionGlobal) {
+ // Start a new TX
+ return run(action);
+ } else {
+ return action.run();
+ }
+ }
+ }
+
+ public <T> void handlesOneWay(TransactionIntent onewayIntent,
+ TransactionIntent implIntent,
+ TransactionalAction<T> action) throws Exception {
+ if (implIntent == null) {
+ implIntent = TransactionIntent.noManagedTransaction;
+ }
+
+ if (onewayIntent == null) {
+ // Assume transactedOneWay
+ run(action);
+ return;
+ }
+
+ if (onewayIntent == TransactionIntent.transactedOneWay) {
+ if (implIntent != TransactionIntent.managedTransactionGlobal) {
+ throw new IncompatibleIntentException(onewayIntent + "<-X->" + implIntent);
+ } else {
+ run(action);
+ return;
+ }
+ } else {
+ // TransactionIntent.immediateOneWay
+ Transaction tx = suspendsTransactionPreInvoke();
+ try {
+ run(action);
+ return;
+ } finally {
+ suspendsTransactionPostInvoke(tx);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionPolicyProviderFactory.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionPolicyProviderFactory.java
new file mode 100644
index 0000000000..23c25c9b8a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionPolicyProviderFactory.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.policy.transaction.runtime;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionPolicyProviderFactory implements PolicyProviderFactory<TransactionPolicy> {
+ private TransactionManagerHelper helper;
+
+ public TransactionPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.helper = utilities.getUtility(TransactionManagerHelper.class);
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return new TransactionImplementationPolicyProvider(helper, component);
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new TransactionReferencePolicyProvider(helper, endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new TransactionServicePolicyProvider(helper, endpoint);
+ }
+
+ public Class<TransactionPolicy> getModelType() {
+ return TransactionPolicy.class;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java
new file mode 100644
index 0000000000..1dc0feb0b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionReferencePolicyProvider.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.transaction.runtime;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionReferencePolicyProvider extends BasePolicyProvider<TransactionPolicy> {
+ private TransactionManagerHelper helper;
+
+ public TransactionReferencePolicyProvider(TransactionManagerHelper helper, EndpointReference epr) {
+ super(TransactionPolicy.class, epr);
+ this.helper = helper;
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<TransactionPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new TransactionInterceptor(helper, true, policies.get(0), null, getPhase());
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_POLICY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java
new file mode 100644
index 0000000000..c2a7c1039b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionServicePolicyProvider.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.transaction.runtime;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionServicePolicyProvider extends BasePolicyProvider<TransactionPolicy> {
+ private TransactionManagerHelper helper;
+
+ public TransactionServicePolicyProvider(TransactionManagerHelper helper, Endpoint ep) {
+ super(TransactionPolicy.class, ep);
+ this.helper = helper;
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<TransactionPolicy> policies = findPolicies();
+ return policies.isEmpty() ? null : new TransactionInterceptor(helper, true, policies.get(0), null, getPhase());
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_POLICY;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionalAction.java b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionalAction.java
new file mode 100644
index 0000000000..2785177000
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/java/org/apache/tuscany/sca/policy/transaction/runtime/TransactionalAction.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.sca.policy.transaction.runtime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TransactionalAction<T> {
+ /**
+ * @return
+ * @throws Exception
+ */
+ T run() throws Exception;
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
new file mode 100644
index 0000000000..0b38a71ad4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -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 policy extension
+org.apache.tuscany.sca.policy.transaction.runtime.TransactionPolicyProviderFactory;model=org.apache.tuscany.sca.policy.transaction.TransactionPolicy
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/LICENSE b/sandbox/sebastien/java/embed/modules/policy-transaction/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/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/sebastien/java/embed/modules/policy-transaction/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/policy-transaction/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cb6c831909
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany Transaction Policy Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Security Policy Model
+Import-Package: javax.security.auth.callback,
+ javax.security.auth.login,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.transaction;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.policy.transaction
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.policy.transaction;version="2.0.0"
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/NOTICE b/sandbox/sebastien/java/embed/modules/policy-transaction/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/pom.xml b/sandbox/sebastien/java/embed/modules/policy-transaction/pom.xml
new file mode 100644
index 0000000000..bba0742181
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/pom.xml
@@ -0,0 +1,51 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-transaction</artifactId>
+ <name>Apache Tuscany SCA Transaction Policy Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicy.java b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicy.java
new file mode 100644
index 0000000000..12ef603d01
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicy.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.transaction;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * The model for Tuscany transaction policy.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TransactionPolicy {
+ QName NAME = new QName(Constants.SCA11_TUSCANY_NS, "transactionPolicy");
+
+ enum Action {
+ PROPAGATE,
+ SUSPEND,
+ REQUIRE_GLOBAL,
+ REQUIRE_LOCAL,
+ REQUIRE_NONE
+ };
+
+ int getTransactionTimeout();
+
+ void setTransactionTimeout(int seconds);
+
+ void setAction(Action action);
+
+ Action getAction();
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyFactory.java b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyFactory.java
new file mode 100644
index 0000000000..f0567f47e0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.transaction;
+
+/**
+ * Factory for Policy Transaction
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TransactionPolicyFactory {
+
+ /**
+ * Creates a new Transaction Policy
+ * @return the new Transaction policy
+ */
+ TransactionPolicy createTransactionPolicy();
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.java
new file mode 100644
index 0000000000..d6818c9b98
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/TransactionPolicyProcessor.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.sca.policy.transaction;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionPolicyProcessor implements StAXArtifactProcessor<TransactionPolicy> {
+ public static final String TIMEOUT = "transactionTimeout";
+ public static final String ACTION = "action";
+
+ TransactionPolicyFactory transactionPolicyFactory;
+
+ public QName getArtifactType() {
+ return TransactionPolicy.NAME;
+ }
+
+ public Class<TransactionPolicy> getModelType() {
+ return TransactionPolicy.class;
+ }
+
+ public TransactionPolicyProcessor(ExtensionPointRegistry extensions) {
+ FactoryExtensionPoint factories = extensions.getExtensionPoint(FactoryExtensionPoint.class);
+ transactionPolicyFactory = factories.getFactory(TransactionPolicyFactory.class);
+ }
+
+ public TransactionPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ TransactionPolicy txPolicy = transactionPolicyFactory.createTransactionPolicy();
+ int event = reader.getEventType();
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ String timeout = reader.getAttributeValue(null, TIMEOUT);
+ if (timeout != null) {
+ txPolicy.setTransactionTimeout(Integer.parseInt(timeout));
+ }
+ String action = reader.getAttributeValue(null, ACTION);
+ if (action != null) {
+ txPolicy.setAction(TransactionPolicy.Action.valueOf(action));
+ }
+ break;
+ }
+ }
+
+ if (event == END_ELEMENT) {
+ if (TransactionPolicy.NAME.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return txPolicy;
+ }
+
+ public void write(TransactionPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ // TODO
+ }
+
+ public void resolve(TransactionPolicy policy, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // TODO
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyFactoryImpl.java b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyFactoryImpl.java
new file mode 100644
index 0000000000..6a4325fa4d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyFactoryImpl.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 org.apache.tuscany.sca.policy.transaction.impl;
+
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory;
+
+/**
+ * Implementation for Transaction Policy factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransactionPolicyFactoryImpl implements TransactionPolicyFactory {
+
+ public TransactionPolicy createTransactionPolicy() {
+ return new TransactionPolicyImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyImpl.java b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyImpl.java
new file mode 100644
index 0000000000..9264dfe5ed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/java/org/apache/tuscany/sca/policy/transaction/impl/TransactionPolicyImpl.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.sca.policy.transaction.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.transaction.TransactionPolicy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransactionPolicyImpl implements TransactionPolicy {
+ private boolean unresolved;
+ private int transactionTimeout = 1200;
+ private Action action = Action.PROPAGATE;
+
+ public int getTransactionTimeout() {
+ return transactionTimeout;
+ }
+
+ public void setTransactionTimeout(int transactionTimeout) {
+ this.transactionTimeout = transactionTimeout;
+ }
+
+ public Action getAction() {
+ return action;
+ }
+
+ public void setAction(Action policy) {
+ this.action = policy;
+ }
+
+ public QName getSchemaName() {
+ return NAME;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..bb4a0f85d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.policy.transaction.TransactionPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#transactionPolicy,model=org.apache.tuscany.sca.policy.transaction.TransactionPolicy \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..77114f703d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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/policy/transaction/definitions.xml
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory
new file mode 100644
index 0000000000..5b37ba4171
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.transaction.TransactionPolicyFactory
@@ -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 model factory
+org.apache.tuscany.sca.policy.transaction.impl.TransactionPolicyFactoryImpl
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/log4j.properties b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/log4j.properties
new file mode 100644
index 0000000000..698ee41d7e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/log4j.properties
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=INFO, CONSOLE
+
+# CONSOLE is set to be a ConsoleAppender.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+
+
+# Print only messages of level WARN or above in the package com.foo.
+log4j.logger.org.apache.tuscany=INFO \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/org/apache/tuscany/sca/policy/transaction/definitions.xml b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/org/apache/tuscany/sca/policy/transaction/definitions.xml
new file mode 100644
index 0000000000..99ab300499
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/main/resources/org/apache/tuscany/sca/policy/transaction/definitions.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <policySet name="ManagedTransactionPolicySet" provides="managedTransaction" appliesTo="//*[starts-with(name(.),'implementation')]" attachTo="IntentRefs('sca:managedTransaction') | IntentRefs('sca:managedTransaction.local') | IntentRefs('sca:managedTransaction.global')">
+ <intentMap provides="managedTransaction">
+ <qualifier name="global"> <!-- default="true" -->
+ <tuscany:transactionPolicy transactionTimeout="1200" action="REQUIRE_GLOBAL" />
+ </qualifier>
+ <qualifier name="local">
+ <tuscany:transactionPolicy transactionTimeout="1200" action="REQUIRE_LOCAL" />
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="NoManagedTransactionPolicySet" provides="noManagedTransaction"
+ appliesTo="//*[starts-with(name(.),'implementation')]" attachTo="IntentRefs('sca:noManagedTransaction')">
+ <tuscany:transactionPolicy action="REQUIRE_NONE" />
+ </policySet>
+
+ <policySet name="TransactedOneWayPolicySet" provides="transactedOneWay" appliesTo="//*[starts-with(name(.),'binding')]" attachTo="IntentRefs('sca:transactedOneWay')">
+ <tuscany:transactionPolicy action="PROPAGATE" />
+ </policySet>
+
+ <policySet name="ImmediateOneWayPolicySet" provides="immediateOneWay" appliesTo="//*[starts-with(name(.),'binding')]" attachTo="IntentRefs('sca:immediateOneWay')">
+ <tuscany:transactionPolicy action="SUSPEND" />
+ </policySet>
+
+ <policySet name="PropagatesTransactionPolicySet" provides="propagatesTransaction" attachTo="IntentRefs('sca:propagatesTransaction')" appliesTo="//*[starts-with(name(.),'binding')]">
+ <tuscany:transactionPolicy action="PROPAGATE" />
+ </policySet>
+
+ <policySet name="SuspendsTransactionPolicySet" provides="suspendsTransaction" appliesTo="//*[starts-with(name(.),'binding')]" attachTo="IntentRefs('sca:suspendsTransaction')">
+ <tuscany:transactionPolicy action="SUSPEND" />
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java b/sandbox/sebastien/java/embed/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
new file mode 100644
index 0000000000..fd3e0a7968
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-transaction/src/test/java/org/apache/tuscany/sca/policy/transaction/PolicyReadTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.transaction;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the reading of ws config params policy.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyReadTestCase extends TestCase {
+
+ @Override
+ public void setUp() throws Exception {
+ }
+
+ public void testPolicyReading() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ TransactionPolicyProcessor processor = new TransactionPolicyProcessor(extensionPoints);
+
+ URL url = getClass().getResource("/org/apache/tuscany/sca/policy/transaction/definitions.xml");
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ InputStream urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+
+ TransactionPolicy policy = processor.read(reader, new ProcessorContext());
+ assertEquals(1200, policy.getTransactionTimeout());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/LICENSE b/sandbox/sebastien/java/embed/modules/policy-wspolicy/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/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/sebastien/java/embed/modules/policy-wspolicy/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/policy-wspolicy/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5dcfbd5b14
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/META-INF/MANIFEST.MF
@@ -0,0 +1,39 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Policy WSPolicy Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Policy WSPolicy model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om,
+ org.apache.axiom.om.impl.builder,
+ org.apache.neethi,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax.reader;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.policy.xml;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca.annotation
+Bundle-SymbolicName: org.apache.tuscany.sca.policy.wspolicy
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.policy.wspolicy.xml;version="2.0.0";
+ uses:="javax.xml.stream,
+ junit.framework,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.policy,
+ javax.xml.namespace"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/NOTICE b/sandbox/sebastien/java/embed/modules/policy-wspolicy/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/pom.xml b/sandbox/sebastien/java/embed/modules/policy-wspolicy/pom.xml
new file mode 100644
index 0000000000..b3fe706a7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/pom.xml
@@ -0,0 +1,136 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-wspolicy</artifactId>
+ <name>Apache Tuscany SCA Policy WS-Policy Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.8</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.neethi</groupId>
+ <artifactId>neethi</artifactId>
+ <version>2.0.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.8</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicy.java b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicy.java
new file mode 100644
index 0000000000..6938b72d82
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicy.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.sca.policy.wspolicy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.neethi.Policy;
+import org.apache.tuscany.sca.policy.PolicyContainer;
+
+/**
+ * The WS-Policy model. Currently defers to the Neethi policy model under the covers.
+ */
+public class WSPolicy implements PolicyContainer {
+
+ public final static String WS_POLICY_NS = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+ public final static String WS_POLICY = "Policy";
+
+ public final static QName WS_POLICY_QNAME = new QName(WS_POLICY_NS, WS_POLICY);
+
+ private Policy neethiPolicy;
+ private List<Object> policyAssertions = new ArrayList<Object>();
+
+ public QName getSchemaName() {
+ return WS_POLICY_QNAME;
+ }
+
+ public Policy getNeethiPolicy() {
+ return neethiPolicy;
+ }
+
+ public void setNeethiPolicy(Policy neethiPolicy) {
+ this.neethiPolicy = neethiPolicy;
+ }
+
+ public List<Object> getPolicyAssertions(){
+ return policyAssertions;
+ }
+
+ @Override
+ public String toString() {
+ return "WSPolicy [" + neethiPolicy + "]";
+ }
+
+ public <T> Object getChildPolicy(Class<T> policyType) {
+ for (Object alternative : policyAssertions){
+ for (Object policy : (List<Object>)alternative){
+ if (policyType.isInstance(policy)){
+ return policy;
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyBuilder.java b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyBuilder.java
new file mode 100644
index 0000000000..d6bd710ed9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyBuilder.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.wspolicy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.neethi.Policy;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Processing for WS-Policy objects
+ * TBD
+ */
+public class WSPolicyBuilder implements PolicyBuilder<Policy> {
+
+ public boolean build(Endpoint endpoint, BuilderContext context) {
+ List<WSPolicy> polices = getPolicies(endpoint);
+ System.out.println(endpoint + ": " + polices);
+ return true;
+ }
+
+ public boolean build(EndpointReference endpointReference, BuilderContext context) {
+ List<WSPolicy> polices = getPolicies(endpointReference);
+ System.out.println(endpointReference + ": " + polices);
+ return true;
+ }
+
+ public boolean build(Component component, Implementation implementation, BuilderContext context) {
+ List<WSPolicy> polices = getPolicies(implementation);
+ System.out.println(implementation + ": " + polices);
+ return true;
+ }
+
+ public QName getPolicyType() {
+ return WSPolicy.WS_POLICY_QNAME;
+ }
+
+ public List<QName> getSupportedBindings() {
+ return null;
+ }
+
+ public boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context) {
+
+ // TODO - neethi doesn't include code for matching ws policy
+ // cxf have the class Intersector http://svn.apache.org/repos/asf/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java
+ // but this does its work based on the cxf AssertionBuilders and extension
+ // registry mechanism. I don't want to commit to that at the moment.
+ //
+ // At the moment we do the simplest top level QName based matching
+
+ // match EPR policy sets
+ for (PolicySet eprPolicySet : endpointReference.getPolicySets()){
+ for (PolicySet epPolicySet : endpoint.getPolicySets()){
+ if (!build(eprPolicySet, epPolicySet)){
+ return false;
+ }
+ }
+ }
+
+ // match EP policy sets
+ for (PolicySet epPolicySet : endpoint.getPolicySets()){
+ for (PolicySet eprPolicySet : endpointReference.getPolicySets()){
+ if (!build(epPolicySet, eprPolicySet)){
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private boolean build(PolicySet policySet1, PolicySet policySet2){
+
+ // extract the ws policy expressions out of the policy sets
+ List<PolicyExpression> policyExpressions1 = new ArrayList<PolicyExpression>();
+ List<PolicyExpression> policyExpressions2 = new ArrayList<PolicyExpression>();
+
+ for (PolicyExpression policyExpression : policySet1.getPolicies()){
+ if (policyExpression.getName().equals(getPolicyType())){
+ policyExpressions1.add(policyExpression);
+ }
+ }
+
+ for (PolicyExpression policyExpression : policySet2.getPolicies()){
+ if (policyExpression.getName().equals(getPolicyType())){
+ policyExpressions2.add(policyExpression);
+ }
+ }
+
+ // Match the first set of expressions against the second set
+ for (PolicyExpression policyExpression1 : policyExpressions1){
+ for (PolicyExpression policyExpression2 : policyExpressions2){
+ if (!build((WSPolicy)policyExpression1.getPolicy(),
+ (WSPolicy)policyExpression2.getPolicy())){
+ return false;
+ }
+ }
+ }
+
+ // TODO set the reference policy set to include an interception of the
+ // ws policy sets discovered here
+ // Do we really need to do this?
+ // The method is called in both directions (reference to service and
+ // service to reference) so would need to fix that
+
+ return true;
+ }
+
+ private List<WSPolicy> getPolicies(PolicySubject subject) {
+ List<WSPolicy> polices = new ArrayList<WSPolicy>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ if (getPolicyType().equals(exp.getName())) {
+ polices.add((WSPolicy)exp.getPolicy());
+ }
+ }
+ }
+ return polices;
+ }
+
+ private boolean build(WSPolicy wsPolicy1, WSPolicy wsPolicy2){
+ // TODO - cheating here as we assume a flat policy structure
+ // we've read all the policy assertions into Tuscany models
+ // in the reader (without taking account of alternatives)
+ // so we just compare those here
+ // The real implementation of this comparison depends on how
+ // we decide to represent the ws policy hierarchy
+
+ for (Object policyAssertion1 : wsPolicy1.getPolicyAssertions()){
+ boolean matched = false;
+ for (Object policyAssertion2 : wsPolicy2.getPolicyAssertions()){
+ if (policyAssertion1.getClass() == policyAssertion2.getClass()){
+ matched = true;
+ break;
+ }
+ }
+ if(!matched){
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessor.java b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessor.java
new file mode 100644
index 0000000000..48bf932c27
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessor.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.wspolicy.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.neethi.Constants;
+import org.apache.neethi.PolicyComponent;
+import org.apache.neethi.PolicyEngine;
+import org.apache.neethi.PolicyOperator;
+import org.apache.tuscany.sca.common.xml.stax.reader.XMLDocumentStreamReader;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.wspolicy.WSPolicy;
+
+/**
+ * Processor for handling xml models of PolicySet definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSPolicyProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<WSPolicy> {
+
+ protected ExtensionPointRegistry registry;
+ protected StAXArtifactProcessor<Object> extensionProcessor;
+ protected StAXAttributeProcessor<Object> extensionAttributeProcessor;
+ protected XMLInputFactory inputFactory;
+ protected XMLOutputFactory outputFactory;
+
+ public WSPolicyProcessor(ExtensionPointRegistry registry,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+ this.registry = registry;
+ this.extensionProcessor = extensionProcessor;
+ this.extensionAttributeProcessor = extensionAttributeProcessor;
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ this.outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ }
+
+ public QName getArtifactType() {
+ return WSPolicy.WS_POLICY_QNAME;
+ }
+
+ public Class<WSPolicy> getModelType() {
+ return WSPolicy.class;
+ }
+
+ public WSPolicy read(XMLStreamReader reader, ProcessorContext context)
+ throws ContributionReadException, XMLStreamException {
+ org.apache.neethi.Policy neethiPolicy = null;
+ XMLDocumentStreamReader doc = new XMLDocumentStreamReader(reader);
+ StAXOMBuilder builder = new StAXOMBuilder(doc);
+ OMElement element = builder.getDocumentElement();
+ neethiPolicy = PolicyEngine.getPolicy(element);
+
+ WSPolicy wsPolicy = new WSPolicy();
+ wsPolicy.setNeethiPolicy(neethiPolicy);
+
+ // normalize the neethi tree so we can easily identify
+ // the policy alternatives
+ neethiPolicy.normalize(true);
+
+ // top-level children of ExactlyOne are policy alternatives so
+ // for each child create a policy model list and pull the
+ // policies out
+ for(Object alternative : neethiPolicy.getPolicyComponents()) {
+ List<Object> assertions = new ArrayList<Object>();
+ readPolicyAssertions(assertions, (PolicyComponent)alternative, context);
+ wsPolicy.getPolicyAssertions().add(assertions);
+ }
+
+
+ return wsPolicy;
+ }
+
+ private void readPolicyAssertions(List<Object> policyAssertions, PolicyComponent policyComponent, ProcessorContext context){
+
+ // recurse into the policy alternatives
+ // TODO - lots of todos here as this just walks down the neethi hierarchy
+ // looking for assertions to drive Tuscany processors without
+ // regard to the policy alternatives. Undecided about whether to
+ // commit to prepresenting this hierarchy in Tuscany or whether
+ // to rely on neethi
+ // Should this be in the builder? Not really as this drives the
+ // Tuscany specific readers
+ if (policyComponent.getType() != Constants.TYPE_ASSERTION){
+ PolicyOperator policyOperator = (PolicyOperator)policyComponent;
+ for(Object childComponent : policyOperator.getPolicyComponents()){
+ // TODO - create assertion hierarchy in wsPolicy model
+ // how we do this depends on if we continue to use neethi
+ readPolicyAssertions(policyAssertions, (PolicyComponent)childComponent, context);
+ }
+ } else {
+ try {
+ // TODO - not sure we should keep the neethi model but hack for the
+ // time being to get Tuscany processors to process the OMElements
+ // within the neethi model
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(outputStream);
+
+ policyComponent.serialize(writer);
+
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(inputStream);
+
+ Object neethiAssertion = policyComponent;
+ Object tuscanyAssertion = extensionProcessor.read(reader, context);
+
+ if (tuscanyAssertion != null) {
+ policyAssertions.add(tuscanyAssertion);
+ } else {
+ // add neethi assertion
+ policyAssertions.add(neethiAssertion);
+ }
+ } catch (Exception ex) {
+ // TODO - report the error properly
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ public void write(WSPolicy wsPolicy, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ // Write an <sca:policySet>
+ writer.writeStartElement(WSPolicy.WS_POLICY_NS, WSPolicy.WS_POLICY);
+
+ if (wsPolicy != null) {
+ wsPolicy.getNeethiPolicy().serialize(writer);
+ }
+
+ writer.writeEndElement();
+ }
+
+ public void resolve(WSPolicy wsPolicy, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+
+ // resolve policy assertions
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
new file mode 100644
index 0000000000..e161411be3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT 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.policy.wspolicy.WSPolicyBuilder;qname=http://schemas.xmlsoap.org/ws/2004/09/policy#Policy
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..745ad35871
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.policy.wspolicy.xml.WSPolicyProcessor;qname=http://schemas.xmlsoap.org/ws/2004/09/policy#Policy,model=org.apache.neethi.Policy
+
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TestModelResolver.java b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TestModelResolver.java
new file mode 100644
index 0000000000..593f56e7f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TestModelResolver.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.wspolicy;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+
+/**
+ * A default implementation of an artifact resolver, based on a map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestModelResolver implements ModelResolver {
+ private static final long serialVersionUID = -7826976465762296634L;
+
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ public TestModelResolver() {
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+
+ // Return the resolved object
+ return modelClass.cast(resolved);
+
+ } else {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ return map.remove(resolved);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TuscanyWSPolicyAssertion.java b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TuscanyWSPolicyAssertion.java
new file mode 100644
index 0000000000..5b4172563a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TuscanyWSPolicyAssertion.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.wspolicy;
+
+import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.assembly.Base;
+
+/**
+ * The WS-Policy model. Defers to the Neethi policy model under the covers.
+ */
+public class TuscanyWSPolicyAssertion {
+
+ static final String SCA11_TUSCANY_NS = Base.SCA11_TUSCANY_NS;
+ static final QName TUSCANY_WS_POLICY_ASSERTION_QNAME = new QName(SCA11_TUSCANY_NS, "tuscanyWSPolicyAssertion");
+
+ private String anAttribute;
+
+ public QName getSchemaName() {
+ return TUSCANY_WS_POLICY_ASSERTION_QNAME;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TuscanyWSPolicyAssertionProcessor.java b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TuscanyWSPolicyAssertionProcessor.java
new file mode 100644
index 0000000000..065feb012c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/TuscanyWSPolicyAssertionProcessor.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.policy.wspolicy;
+
+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.Base;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyWSPolicyAssertionProcessor implements StAXArtifactProcessor<TuscanyWSPolicyAssertion> {
+
+ public QName getArtifactType() {
+ return new QName(Base.SCA11_TUSCANY_NS, "tuscanyWSPolicyAssertion");
+ }
+
+ public TuscanyWSPolicyAssertion read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new TuscanyWSPolicyAssertion();
+ }
+
+ public void write(TuscanyWSPolicyAssertion arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<TuscanyWSPolicyAssertion> getModelType() {
+ // TODO Auto-generated method stub
+ return TuscanyWSPolicyAssertion.class;
+ }
+
+ public void resolve(TuscanyWSPolicyAssertion arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyTestCase.java b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyTestCase.java
new file mode 100644
index 0000000000..b4c72b5235
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/WSPolicyTestCase.java
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.wspolicy;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.wspolicy.xml.WSPolicyProcessor;
+import org.apache.tuscany.sca.policy.xml.PolicySetProcessor;
+import org.junit.Assert;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSPolicyTestCase extends TestCase {
+
+ private static final String WS_POLICY1 =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<definitions xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " targetNamespace=\"http://test\""
+ + " xmlns:test=\"http://test\""
+ + " xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\">"
+ + " "
+ + " <policySet name=\"SecureWSPolicy\""
+ + " provides=\"test:confidentiality\""
+ + " appliesTo=\"sca:binding.ws\""
+ + " xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " xmlns:sp=\"http://schemas.xmlsoap.org/ws/2002/12/secext\""
+ + " xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
+ + " xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">"
+ + " <wsp:Policy>"
+ + " <wsp:ExactlyOne>"
+ + " <wsp:All>"
+ + " <tuscany:tuscanyWSPolicyAssertion anAttribute=\"fred\"/>"
+ + " <sp:SecurityToken>"
+ + " <sp:TokenType>sp:X509v3</sp:TokenType>"
+ + " </sp:SecurityToken>"
+ + " <sp:UsernameToken />"
+ + " <sp:SignedParts />"
+ + " <sp:EncryptedParts>"
+ + " <sp:Body />"
+ + " </sp:EncryptedParts>"
+ + " <sp:TransportBinding>"
+ + " <sp:IncludeTimeStamp />"
+ + " </sp:TransportBinding>"
+ + " </wsp:All>"
+ + " </wsp:ExactlyOne>"
+ + " </wsp:Policy>"
+ + " </policySet>"
+ + " </definitions>";
+
+ private static final String WS_POLICY2 =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<definitions xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " targetNamespace=\"http://test\""
+ + " xmlns:test=\"http://test\""
+ + " xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\">"
+ + " "
+ + " <policySet name=\"SecureWSPolicy\""
+ + " provides=\"test:confidentiality\""
+ + " appliesTo=\"sca:binding.ws\""
+ + " xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " xmlns:sp=\"http://schemas.xmlsoap.org/ws/2002/12/secext\""
+ + " xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
+ + " xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">"
+ + " <wsp:Policy>"
+ + " <wsp:ExactlyOne>"
+ + " <wsp:All>"
+ + " <tuscany:tuscanyWSPolicyAssertion anAttribute=\"jim\"/>"
+ + " <sp:SecurityToken>"
+ + " <sp:TokenType>sp:X509v3</sp:TokenType>"
+ + " </sp:SecurityToken>"
+ + " <sp:UsernameToken />"
+ + " <sp:SignedParts />"
+ + " <sp:EncryptedParts>"
+ + " <sp:Body />"
+ + " </sp:EncryptedParts>"
+ + " <sp:TransportBinding>"
+ + " <sp:IncludeTimeStamp />"
+ + " </sp:TransportBinding>"
+ + " </wsp:All>"
+ + " </wsp:ExactlyOne>"
+ + " </wsp:Policy>"
+ + " </policySet>"
+ + " </definitions>";
+
+ private XMLInputFactory inputFactory;
+
+ @Override
+ public void setUp() throws Exception {
+ inputFactory = XMLInputFactory.newInstance();
+ }
+
+ public void testReadWsPolicy() throws Exception {
+ // Set up the runtime
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+
+ XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+
+ StAXArtifactProcessorExtensionPoint artifactExtensionPoint = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<Object> extensibleStAXProcessor = new ExtensibleStAXArtifactProcessor(artifactExtensionPoint, inputFactory, outputFactory);
+ artifactExtensionPoint.addArtifactProcessor(new TuscanyWSPolicyAssertionProcessor());
+
+ StAXAttributeProcessorExtensionPoint attributeExtensionPoint = registry.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ StAXAttributeProcessor<Object> extensibleStAXAttributeProcessor = new ExtensibleStAXAttributeProcessor(attributeExtensionPoint, inputFactory, outputFactory);
+
+ BuilderExtensionPoint builderExtensionPoint = registry.getExtensionPoint(BuilderExtensionPoint.class);
+
+ StAXArtifactProcessor processor = artifactExtensionPoint.getProcessor(Definitions.class);
+
+ Object artifact = null;
+
+ // Read the first definitions string
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(WS_POLICY1));
+
+ artifact = processor.read(reader, new ProcessorContext());
+ assertNotNull(artifact);
+ Assert.assertTrue(artifact instanceof Definitions);
+ Definitions definitions1 = (Definitions) artifact;
+
+ // Read the second definitions string
+
+ reader = inputFactory.createXMLStreamReader(new StringReader(WS_POLICY2));
+
+ artifact = processor.read(reader, new ProcessorContext());
+ assertNotNull(artifact);
+ Assert.assertTrue(artifact instanceof Definitions);
+ Definitions definitions2 = (Definitions) artifact;
+
+ // compare the policies using the policy builder
+
+ // create dummy endpoints and endpoint references
+ AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ EndpointReference epr = assemblyFactory.createEndpointReference();
+ Endpoint ep = assemblyFactory.createEndpoint();
+
+ // add the ws polices we've just read to the epr/ep
+ epr.getPolicySets().add(definitions1.getPolicySets().get(0));
+ ep.getPolicySets().add(definitions1.getPolicySets().get(0));
+
+ BuilderContext builderContext = new BuilderContext((Monitor)null);
+
+ for (PolicyBuilder policyBuilder : builderExtensionPoint.getPolicyBuilders()) {
+ System.out.println("PolicyBuilder: " + policyBuilder.toString());
+ assertTrue(policyBuilder.build(epr, ep, builderContext));
+ }
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessorTestCase.java
new file mode 100644
index 0000000000..1c9c9b706a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessorTestCase.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.policy.wspolicy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.wspolicy.TuscanyWSPolicyAssertionProcessor;
+import org.apache.tuscany.sca.policy.wspolicy.WSPolicy;
+import org.apache.tuscany.sca.policy.wspolicy.xml.WSPolicyProcessor;
+import org.junit.Assert;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSPolicyProcessorTestCase extends TestCase {
+
+ private static final String VALID_WS_POLICY =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<definitions xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " targetNamespace=\"http://test\""
+ + " xmlns:test=\"http://test\""
+ + " xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\">"
+ + " "
+ + " <policySet name=\"SecureWSPolicy\""
+ + " provides=\"test:confidentiality\""
+ + " appliesTo=\"sca:binding.ws\""
+ + " xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " xmlns:sp=\"http://schemas.xmlsoap.org/ws/2002/12/secext\""
+ + " xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">"
+ + " <wsp:Policy>"
+ + " <wsp:ExactlyOne>"
+ + " <wsp:All>"
+ + " <sp:SecurityToken>"
+ + " <sp:TokenType>sp:X509v3</sp:TokenType>"
+ + " </sp:SecurityToken>"
+ + " <sp:UsernameToken />"
+ + " <sp:SignedParts />"
+ + " <sp:EncryptedParts>"
+ + " <sp:Body />"
+ + " </sp:EncryptedParts>"
+ + " <sp:TransportBinding>"
+ + " <sp:IncludeTimeStamp />"
+ + " </sp:TransportBinding>"
+ + " </wsp:All>"
+ + " </wsp:ExactlyOne>"
+ + " </wsp:Policy>"
+ + " </policySet>"
+ + " </definitions>";
+
+ private XMLInputFactory inputFactory;
+
+ @Override
+ public void setUp() throws Exception {
+ inputFactory = XMLInputFactory.newInstance();
+
+ }
+
+ public void testReadWsPolicy() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_WS_POLICY));
+
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ StAXArtifactProcessorExtensionPoint artifactExtensionPoint = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<Object> extensibleStAXProcessor = new ExtensibleStAXArtifactProcessor(artifactExtensionPoint, inputFactory, outputFactory);
+ StAXAttributeProcessorExtensionPoint attributeExtensionPoint = registry.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ StAXAttributeProcessor<Object> extensibleStAXAttributeProcessor = new ExtensibleStAXAttributeProcessor(attributeExtensionPoint, inputFactory, outputFactory);
+
+ WSPolicyProcessor processor = new WSPolicyProcessor(new DefaultExtensionPointRegistry(),
+ extensibleStAXProcessor,
+ extensibleStAXAttributeProcessor);
+
+ Object artifact = null;
+
+ QName name = null;
+ reader.next();
+ while (true) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+
+ if (WSPolicy.WS_POLICY_QNAME.equals(name)) {
+ artifact = processor.read(reader, new ProcessorContext());
+ }
+
+ break;
+ }
+ }
+
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ assertNotNull(artifact);
+ Assert.assertTrue(artifact instanceof WSPolicy);
+ WSPolicy policy = (WSPolicy) artifact;
+ Assert.assertTrue(policy.getNeethiPolicy().getAlternatives().hasNext());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/resources/org/apache/tuscany/sca/policy/wspolicy/test_definitions.xml b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/resources/org/apache/tuscany/sca/policy/wspolicy/test_definitions.xml
new file mode 100644
index 0000000000..600ac8e267
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/policy-wspolicy/src/test/resources/org/apache/tuscany/sca/policy/wspolicy/test_definitions.xml
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://test"
+ xmlns:test="http://test"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912">
+
+<policySet name="SecureWSPolicy"
+ provides="test:confidentiality"
+ appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+<policySet name="WSPolicy1"
+ provides="test:confidentiality"
+ appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <policySet name="WSPolicy2"
+ provides="test:confidentiality"
+ appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <policySet name="WSPolicy3"
+ provides="test:confidentiality"
+ appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+<!-- profile intent -->
+ <intent name="reliableMessageProtection"
+ constrains="sca:binding"
+ requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection"
+ constrains="sca:binding"
+ requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+<!-- simple intent -->
+ <intent name="confidentiality"
+ constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ </intent>
+
+ <intent name="integrity"
+ constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication"
+ constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging"
+ constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing"
+ constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/pom.xml b/sandbox/sebastien/java/embed/modules/pom.xml
new file mode 100644
index 0000000000..bca4f5131d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/pom.xml
@@ -0,0 +1,207 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-modules</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Implementation Modules</name>
+
+ <modules>
+ <module>assembly</module>
+ <module>assembly-xml</module>
+ <module>assembly-xsd</module>
+ <module>binding-atom</module>
+ <module>binding-atom-js-dojo</module>
+ <module>binding-atom-runtime</module>
+ <module>binding-ejb</module>
+ <module>binding-ejb-runtime</module>
+ <module>binding-hazelcast-runtime</module>
+ <module>binding-http</module>
+ <module>binding-http-runtime</module>
+ <module>binding-jms</module>
+ <module>binding-jms-runtime</module>
+ <module>binding-jsonp</module>
+ <module>binding-jsonp-runtime</module>
+ <module>binding-jsonrpc</module>
+ <module>binding-jsonrpc-js-dojo</module>
+ <module>binding-jsonrpc-runtime</module>
+ <module>binding-rest</module>
+ <module>binding-rest-runtime</module>
+ <module>binding-rmi</module>
+ <module>binding-rmi-runtime</module>
+ <module>binding-rss</module>
+ <module>binding-rss-runtime</module>
+ <module>binding-sca-runtime</module>
+ <module>binding-ws</module>
+ <module>binding-ws-runtime-axis2</module>
+ <module>binding-ws-runtime-jaxws</module>
+ <module>binding-ws-runtime-jaxws-ri</module>
+ <module>binding-ws-wsdlgen</module>
+ <module>builder</module>
+ <module>common-http</module>
+ <module>common-java</module>
+ <module>common-xml</module>
+ <module>contribution</module>
+ <module>core</module>
+ <module>core-databinding</module>
+ <module>core-spi</module>
+ <module>data-api</module>
+ <module>databinding</module>
+ <module>databinding-axiom</module>
+ <module>databinding-jaxb</module>
+ <module>databinding-jaxb-axiom</module>
+ <module>databinding-sdo</module>
+ <module>databinding-sdo-axiom</module>
+ <module>databinding-json</module>
+ <module>deployment</module>
+ <module>domain-node</module>
+ <module>endpoint-tribes</module>
+ <module>endpoint-hazelcast</module>
+ <module>endpoint-hazelcast-client</module>
+ <module>extensibility</module>
+ <module>extensibility-equinox</module>
+ <module>host-http</module>
+ <module>host-jetty</module>
+ <module>host-rmi</module>
+ <module>host-webapp</module>
+ <module>implementation-bpel</module>
+ <module>implementation-bpel-runtime</module>
+ <module>implementation-java</module>
+ <module>implementation-java-runtime</module>
+ <module>implementation-jaxrs</module>
+ <module>implementation-jaxrs-runtime</module>
+ <module>implementation-python</module>
+ <module>implementation-python-runtime</module>
+ <module>implementation-script</module>
+ <module>implementation-script-runtime</module>
+ <module>implementation-spring</module>
+ <module>implementation-spring-runtime</module>
+ <module>implementation-spring-webapp</module>
+ <module>implementation-spring-stub</module>
+ <module>implementation-spring-tie</module>
+ <module>implementation-web</module>
+ <module>implementation-web-client</module>
+ <module>implementation-web-runtime</module>
+ <module>implementation-widget</module>
+ <module>implementation-widget-runtime</module>
+ <module>implementation-widget-runtime-dojo</module>
+ <module>interface-java</module>
+ <module>interface-java-jaxrs</module>
+ <module>interface-java-jaxws</module>
+ <module>interface-wsdl</module>
+ <module>launcher</module>
+ <module>monitor</module>
+ <module>myfaces</module>
+ <module>node-api</module>
+ <module>node-impl</module>
+ <module>node-launcher</module>
+ <module>node-launcher-equinox</module>
+ <module>policy-security</module>
+ <module>policy-wspolicy</module>
+ <!--module>policy-xml-ws</module-->
+ <module>policy-logging</module>
+ <module>policy-transaction</module>
+ <module>policy-transaction-runtime</module>
+ <module>policy-transaction-runtime-geronimo</module>
+ <module>shell</module>
+ <module>sca-api</module>
+ <module>sca-client-impl</module>
+ <!-- module>sca-client-javascript</module -->
+ <module>stripes</module>
+ <module>tracing-aspectj</module>
+ <module>xsd</module>
+ <module>web-javascript</module>
+ <module>web-javascript-dojo</module>
+ <module>wink</module>
+ <!-- OSGi Remote Services with SCA -->
+ <module>contribution-osgi</module>
+ <module>implementation-osgi</module>
+ <module>implementation-osgi-runtime</module>
+ <module>node-impl-osgi</module>
+
+ <module>host-corba</module>
+ <module>host-corba-jee</module>
+ <module>host-corba-jse</module>
+ <module>host-corba-jse-tns</module>
+ <module>binding-corba</module>
+ <module>binding-corba-runtime</module>
+ </modules>
+
+ <profiles>
+ <profile>
+ <id>eclipse</id>
+ <build>
+ <defaultGoal>org.apache.tuscany.maven.plugins:maven-bundle-plugin:eclipse</defaultGoal>
+ <!--
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.6</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-pde</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>eclipse</goal>
+ </goals>
+ <configuration>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ -->
+ </build>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/LICENSE b/sandbox/sebastien/java/embed/modules/sca-api/LICENSE
new file mode 100644
index 0000000000..97b8a2303e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/LICENSE
@@ -0,0 +1,261 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+This module includes Java files under the following OASIS license:
+
+Copyright (C) OASIS(R) 2005, 2009. All Rights Reserved.
+All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual
+Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.
+This document and translations of it may be copied and furnished to others, and derivative works that
+comment on or otherwise explain it or assist in its implementation may be prepared, copied, published,
+and distributed, in whole or in part, without restriction of any kind, provided that the above copyright
+notice and this section are included on all such copies and derivative works. However, this document
+itself may not be modified in any way, including by removing the copyright notice or references to OASIS,
+except as needed for the purpose of developing any document or deliverable produced by an OASIS
+Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR
+Policy, must be followed) or as required to translate it into languages other than English.
+The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors
+or assigns.
+This document and the information contained herein is provided on an "AS IS" basis and OASIS
+DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
+WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP
+RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.
+OASIS requests that any OASIS Party or any other party that believes it has patent claims that would
+necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard,
+to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to
+such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that
+produced this specification.
+OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of
+any patent claims that would necessarily be infringed by implementations of this specification by a patent
+holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR
+Mode of the OASIS Technical Committee that produced this specification. OASIS may include such
+claims on its website, but disclaims any obligation to do so.
+OASIS takes no position regarding the validity or scope of any intellectual property or other rights that
+might be claimed to pertain to the implementation or use of the technology described in this document or
+the extent to which any license under such rights might or might not be available; neither does it represent
+that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to
+rights in any document or deliverable produced by an OASIS Technical Committee can be found on the
+OASIS website. Copies of claims of rights made available for publication and any assurances of licenses
+to be made available, or the result of an attempt made to obtain a general license or permission for the use
+of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS
+Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any
+information or list of intellectual property rights will at any time be complete, or that any claims in such list
+are, in fact, Essential Claims.
+The names "OASIS", are trademarks of OASIS, the owner and developer of this specification, and should
+be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and
+implementation and use of, specifications, while reserving the right to enforce its marks against misleading
+uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance.
+
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/sca-api/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..4729aa7bc8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Export-Package: org.oasisopen.sca;version="2.0.0";uses:="javax.security.auth",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.oasisopen.sca.client;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA API
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: API classes for the Service Component Architecture
+Import-Package: javax.security.auth,org.oasisopen.sca;version="2.0.0",org.oas
+ isopen.sca.annotation;version="2.0.0",org.oasisopen.sca.client;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.api
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/NOTICE b/sandbox/sebastien/java/embed/modules/sca-api/NOTICE
new file mode 100644
index 0000000000..8c74c2267e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/NOTICE
@@ -0,0 +1,9 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes software developed at
+the OSGi Alliance (http://www.osgi.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/pom.xml b/sandbox/sebastien/java/embed/modules/sca-api/pom.xml
new file mode 100644
index 0000000000..edc55b17aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <name>Apache Tuscany SCA API</name>
+
+ <description>API classes for the Service Component Architecture</description>
+ <packaging>jar</packaging>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java
new file mode 100644
index 0000000000..09faf1b15e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+import java.util.Collection;
+
+/**
+ * The ComponentContext interface is used to obtain contextual information
+ * about the SCA component which is executing at the time the API is
+ * invoked.
+ *
+ * <p>Note: An SCA component can obtain a service reference either through
+ * injection or programmatically through the ComponentContext API. Using
+ * reference injection is the recommended way to access a service, since it
+ * results in code with minimal use of middleware APIs. The ComponentContext
+ * API is provided for use in cases where reference injection is not possible.
+ */
+public interface ComponentContext {
+
+ /**
+ * Returns the absolute URI of the component within the SCA domain.
+ *
+ * @return the absolute URI of the component within the SCA domain.
+ */
+ String getURI();
+
+ /**
+ * Returns a typed service proxy object for a reference defined by the
+ * current component, where the reference has multiplicity 0..1 or 1..1.
+ *
+ * @param <B> the Java type that is implemented by the returned proxy
+ * object.
+ * @param businessInterface the Class object for the Java type that
+ * is implemented by the returned proxy object.
+ * @param referenceName the name of the service reference.
+ * @return a proxy for the reference defined by the current component.
+ * Returns null if the named reference has no target service
+ * configured.
+ * @exception IllegalArgumentException if the reference has multiplicity
+ * greater than one, or the component does not have the reference
+ * named by <code>referenceName</code>, or the interface of the named
+ * reference is not compatible with the interface supplied in
+ * the <code>businessInterface</code> parameter.
+ */
+ <B> B getService(Class<B> businessInterface, String referenceName)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns a ServiceReference object for a reference defined by the current
+ * component, where the reference has multiplicity 0..1 or 1..1.
+ *
+ * @param <B> the Java type of the reference that is associated with
+ * the returned object.
+ * @param businessInterface the Class object for the Java type that
+ * is associated with the returned object.
+ * @param referenceName the name of the service reference.
+ * @return a ServiceReference object for a reference defined by the current
+ * component, where the reference has multiplicity 0..1 or 1..1.
+ * Returns null if the named reference has no target service
+ * configured.
+ * @exception IllegalArgumentException if the reference has multiplicity
+ * greater than one, or the component does not have the reference
+ * named by <code>referenceName</code>, or the interface of the named
+ * reference is not compatible with the interface supplied in
+ * the <code>businessInterface</code> parameter.
+ */
+ <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
+ String referenceName)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns a list of typed service proxies for a reference defined by the current
+ * component, where the reference has multiplicity 0..n or 1..n.
+ *
+ * @param <B> the Java type that is implemented by the returned proxy
+ * objects.
+ * @param businessInterface the Class object for the Java type that
+ * is implemented by the returned proxy objects.
+ * @param referenceName the name of the service reference.
+ * @return a collection of proxy objects for the reference, one for each target
+ * service to which the reference is wired, where each proxy object
+ * implements the interface B contained in the
+ * <code>businessInterface</code> parameter. The collection is empty if the
+ * reference is not wired to any target services.
+ * @exception IllegalArgumentException if the reference has multiplicity
+ * greater other than 0..1 or 1..1, or the component does not have the reference
+ * named by <code>referenceName</code>, or the interface of the named
+ * reference is not compatible with the interface supplied in
+ * the <code>businessInterface</code> parameter.
+ */
+ <B> Collection<B> getServices(Class<B> businessInterface,
+ String referenceName)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns a list of typed ServiceReference objects for a reference defined by the current
+ * component, where the reference has multiplicity 0..n or 1..n.
+ *
+ * @param <B> the Java type that is associated with returned proxy
+ * objects.
+ * @param <B> the Java type of the reference that is associated with
+ * the returned object.
+ * @param referenceName the name of the service reference.
+ * @return a collection of ServiceReference objects for the reference, one for each target
+ * service to which the reference is wired, where each proxy object implements
+ * the interface B contained in the <code>businessInterface</code> parameter.
+ * The collection is empty if the reference is not wired to any target services.
+ * @exception IllegalArgumentException if the reference has multiplicity
+ * greater other than 0..1 or 1..1, or the component does not have the reference
+ * named by <code>referenceName</code>, or the interface of the named
+ * reference is not compatible with the interface supplied in
+ * the <code>businessInterface</code> parameter.
+ */
+ <B> Collection<ServiceReference<B>> getServiceReferences(
+ Class<B> businessInterface, String referenceName)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns a ServiceReference that can be used to invoke this component
+ * over the designated service.
+ *
+ * @param <B> the Java type of the reference that is associated with
+ * the returned object.
+ * @param businessInterface the Class object for the Java type that
+ * is associated with the returned object.
+ * @return a ServiceReference that can be used to invoke this
+ * component over the designated service.
+ * @exception IllegalArgumentException if the component does not have a service
+ * which implements the interface identified by the <code>
+ * businessinterface</code> parameter.
+ */
+ <B> ServiceReference<B> createSelfReference(Class<B> businessInterface)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns a ServiceReference that can be used to invoke this component
+ * over the designated service. The <code>serviceName</code> parameter explicitly names
+ * the service with which the returned ServiceReference is associated.
+ *
+ * @param <B> the Java type of the reference that is associated with
+ * the returned object.
+ * @param businessInterface the Class object for the Java type that
+ * is associated with the returned object.
+ * @param serviceName the service name with which the returned ServiceReference
+ * is associated.
+ * @return a ServiceReference that can be used to invoke this component
+ * over the designated service.
+ * @exception IllegalArgumentException if the component does not have a service
+ * with the name identified by the <code>serviceName</code> parameter, or
+ * if the named service does not implement the interface identified by the
+ * <code>businessinterface</code> parameter.
+ */
+ <B> ServiceReference<B> createSelfReference(Class<B> businessInterface,
+ String serviceName)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the value of an SCA property defined by this component.
+ *
+ * @param <B> the property type.
+ * @param type the Class object for the property type.
+ * @param propertyName the property name.
+ * @return The value of an SCA property defined by this component, or null if
+ * the property is not configured.
+ * @exception IllegalArgumentException if the component does not have a property
+ * with the name identified by the <code>propertyName</code> parameter, or
+ * if the named property type is not compatible with the <code>type</code>
+ * parameter.
+ */
+ <B> B getProperty(Class<B> type, String propertyName)
+ throws IllegalArgumentException;
+
+ /**
+ * Casts a type-safe reference to a ServiceReference.
+ *
+ * @param <B> the Java type of the reference that is associated with
+ * the returned object.
+ * @param target the type-safe reference proxy that implements interface <B>.
+ * @return a type-safe reference to a ServiceReference.
+ */
+ <B> ServiceReference<B> cast(B target)
+ throws IllegalArgumentException;
+
+ /**
+ * Returns the RequestContext for the current SCA service request.
+ *
+ * @return the RequestContext for the current SCA service request when
+ * invoked during the execution of a component service method or
+ * callback method. Returns null in all other cases.
+ */
+ RequestContext getRequestContext();
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java
new file mode 100644
index 0000000000..f32289dcb1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+/**
+ * The SCA Constants interface defines a number of constant values
+ * that are used in the SCA Java APIs and Annotations.
+ *
+ * <p> The serialized QNames are used with the @Requires annotation
+ * to specify a policy intent. The policy intent strings in this
+ * interface do not have a corresponding Java annotation, so these
+ * policy intents have ot be specified through the use of the
+ * @Requires annotation.
+ */
+public interface Constants {
+
+ /**
+ * The SCA V1.1 namespace.
+ */
+ String SCA_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912";
+
+ /**
+ * The serialized form of the SCA namespace for construction of QNames.
+ */
+ String SCA_PREFIX = "{"+SCA_NS+"}";
+
+ /**
+ * The serialized QName of the serverAuthentication policy intent.
+ */
+ String SERVERAUTHENTICATION = SCA_PREFIX + "serverAuthentication";
+ /**
+ * The serialized QName of the clientAuthentication policy intent.
+ */
+ String CLIENTAUTHENTICATION = SCA_PREFIX + "clientAuthentication";
+ /**
+ * The serialized QName of the atleastOnce policy intent.
+ */
+ String ATLEASTONCE = SCA_PREFIX + "atLeastOnce";
+ /**
+ * The serialized QName of the atMostOnce policy intent.
+ */
+ String ATMOSTONCE = SCA_PREFIX + "atMostOnce";
+ /**
+ * The serialized QName of the exactlyOnce policy intent.
+ */
+ String EXACTLYONCE = SCA_PREFIX + "exactlyOnce";
+ /**
+ * The serialized QName of the ordered policy intent.
+ */
+ String ORDERED = SCA_PREFIX + "ordered";
+ /**
+ * The serialized QName of the transactedOneWay policy intent.
+ */
+ String TRANSACTEDONEWAY = SCA_PREFIX + "transactedOneWay";
+ /**
+ * The serialized QName of the immediateOneWay policy intent.
+ */
+ String IMMEDIATEONEWAY = SCA_PREFIX + "immediateOneWay";
+ /**
+ * The serialized QName of the propagatesTransaction policy intent.
+ */
+ String PROPAGATESTRANSACTION = SCA_PREFIX + "propagatesTransaction";
+ /**
+ * The serialized QName of the suspendsTransaction policy intent.
+ */
+ String SUSPENDSTRANSACTION = SCA_PREFIX + "suspendsTransaction";
+ /**
+ * The serialized QName of the asyncInvocation policy intent.
+ */
+ String ASYNCINVOCATION = SCA_PREFIX + "asyncInvocation";
+ /**
+ * The serialized QName of the SOAP policy intent.
+ */
+ String SOAP = SCA_PREFIX + "SOAP";
+ /**
+ * The serialized QName of the JMS policy intent.
+ */
+ String JMS = SCA_PREFIX + "JMS";
+ /**
+ * The serialized QName of the noListener policy intent.
+ */
+ String NOLISTENER = SCA_PREFIX + "noListener";
+ /**
+ * The serialized QName of the EJB policy intent.
+ */
+ String EJB = SCA_PREFIX + "EJB";
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java
new file mode 100644
index 0000000000..02c575c05c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+/**
+ * This exception signals that the ServiceReference is no longer valid.
+ * This can happen when the target of the reference is undeployed.
+ *
+ * This exception is not transient and therefore is unlikely to be
+ * resolved by retrying the operation and will most likely require
+ * human intervention.
+ */
+public class InvalidServiceException extends ServiceRuntimeException {
+ /**
+ * Constructs a InvalidServiceException with no detail message.
+ */
+ public InvalidServiceException() {
+ super();
+ }
+
+ /**
+ * Constructs a InvalidServiceException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public InvalidServiceException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a InvalidServiceException with the specified detail
+ * message and cause.
+ *
+ * The detail message associated with <code>cause</code> is not
+ * automatically incorporated in this exception's detail message.
+ *
+ * @param message the detail message
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public InvalidServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a InvalidServiceException with the specified cause and
+ * a detail message of <tt>(cause==null ? null : cause.toString())</tt>.
+ *
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public InvalidServiceException(Throwable cause) {
+ super(cause);
+ }
+
+ private static final long serialVersionUID = 7520492728695222145L;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java
new file mode 100644
index 0000000000..d0f8a3e24d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+/**
+ * This exception signals that the given SCA Domain does not exist.
+ */
+
+public class NoSuchDomainException extends Exception {
+ /**
+ * Constructs a NoSuchDomainException with no detail message.
+ */
+ public NoSuchDomainException() {
+ super();
+ }
+
+ /**
+ * Constructs a NoSuchDomainException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public NoSuchDomainException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a NoSuchDomainException with the specified detail
+ * message and cause.
+ *
+ * The detail message associated with <code>cause</code> is not
+ * automatically incorporated in this exception's detail message.
+ *
+ * @param message the detail message
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public NoSuchDomainException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a NoSuchDomainException with the specified cause and a
+ * detail message of <tt>(cause==null ? null : cause.toString())</tt>.
+ *
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public NoSuchDomainException(Throwable cause) {
+ super(cause);
+ }
+
+ private static final long serialVersionUID = 6761623124602414622L;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java
new file mode 100644
index 0000000000..189e713e97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+/**
+ * This exception signals that the given SCA service does not exist.
+ */
+
+public class NoSuchServiceException extends Exception {
+ /**
+ * Constructs a NoSuchServiceException with no detail message.
+ */
+ public NoSuchServiceException() {
+ super();
+ }
+
+ /**
+ * Constructs a NoSuchServiceException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public NoSuchServiceException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a NoSuchServiceException with the specified detail
+ * message and cause.
+ *
+ * The detail message associated with <code>cause</code> is not
+ * automatically incorporated in this exception's detail message.
+ *
+ * @param message the detail message
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public NoSuchServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a NoSuchServiceException with the specified cause and a
+ * detail message of <tt>(cause==null ? null : cause.toString())</tt>.
+ *
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public NoSuchServiceException(Throwable cause) {
+ super(cause);
+ }
+
+ private static final long serialVersionUID = 6761623124602414622L;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java
new file mode 100644
index 0000000000..162e8e2055
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+import javax.security.auth.Subject;
+
+/**
+ * The RequestContext interface is used to obtain information about
+ * the service invocation which is executing when one of the
+ * RequestContext methods is called.
+ */
+public interface RequestContext {
+
+ /**
+ * Returns the JAAS Subject of the current request.
+ *
+ * @return The JAAS (javax.security.auth.Subject) Subject of the
+ * current request. Returns null if there is no JAAS
+ * Subject.
+ */
+ Subject getSecuritySubject();
+
+ /**
+ * Returns the name of the service under which the current service
+ * method is executing.
+ *
+ * @return the name of the service under which the current service
+ * operation is executing, or null if called outside of the
+ * execution of a service method.
+ */
+ String getServiceName();
+
+ /**
+ * Returns a service reference for the callback for the invoked service
+ * operation, as specified by the service caller.
+ *
+ * @param <CB> the Java interface type of the callback.
+ * @return a service reference for the callback as specified by
+ * the service caller. Returns null when called for a service
+ * request whose interface is not bidirectional, or when called
+ * during execution of a callback request, or when called outside
+ * the execution of a service method.
+ */
+ <CB> ServiceReference<CB> getCallbackReference();
+
+ /**
+ * Returns a proxy for the callback for the invoked service as specified
+ * by the service client.
+ *
+ * @param <CB> the type of the callback proxy
+ * @return a proxy for the callback for the invoked service as specified
+ * by the service client. Returns null when called during the
+ * execution of a service method whose interface is not
+ * bidirectional, or when called during the execution of a
+ * callback request, or when called outside the execution of a
+ * service method.
+ */
+ <CB> CB getCallback();
+
+ /**
+ * Returns a ServiceReference object for the service that is executing.
+ *
+ * @param <B> the Java interface type associated with the service reference.
+ * @return the ServiceReference representing the service or callback
+ * that is executing. Returns null if when called outside the
+ * execution of a service method.
+ */
+ <B> ServiceReference<B> getServiceReference();
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java
new file mode 100644
index 0000000000..1192b16778
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+import java.util.Map;
+
+/**
+ *
+ * The following defines the ResponseDispatch interface, used to return a response
+ * message asynchronously from a service implementation method.
+ *
+ * @param <T> the type of the Response message returned by the service implementation method
+ */
+public interface ResponseDispatch<T> {
+
+ /**
+ * Sends the response message from an asynchronous service method.
+ * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked
+ * if sendFault has previously been invoked for the same ResponseDispatch object.
+ * @param res an instance of the response message returned by the service operation
+ * @exception InvalidStateException if this method is called more than once for the same service
+ * operation.
+ */
+ void sendResponse(T res);
+
+ /**
+ * Sends an exception as a fault from an asynchronous service method.
+ * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked
+ * if sendResponse has previously been invoked for the same ResponseDispatch object.
+ * @param e an instance of an exception returned by the service operation
+ * @exception InvalidStateException if this method is called more than once for the same service
+ * operation.
+ */
+ void sendFault(Throwable e);
+
+ /**
+ * Obtains the context object for the ResponseDispatch method
+ * @return a Map which is is the context object for the ResponseDispatch object.
+ * The invoker can update the context object with appropriate context information, prior to invoking
+ * either the sendResponse method or the sendFault method
+ */
+ Map<String, Object> getContext();
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java
new file mode 100644
index 0000000000..d2d62763fa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+/**
+ * The ServiceReference interface represents a component reference.
+ * It can be injected using the @Reference annotation
+ * on a field, a setter method, or constructor parameter taking the
+ * type ServiceReference.
+ *
+ * @param <B> the type of the service reference
+ */
+public interface ServiceReference<B> extends java.io.Serializable {
+
+ /**
+ * Returns a type-safe reference to the target of this reference.
+ * The instance returned is guaranteed to implement the business
+ * interface for this reference. The value returned is a proxy
+ * to the target that implements the business interface associated
+ * with this reference.
+ *
+ * @return a type-safe reference to the target of this reference.
+ */
+ B getService();
+
+ /**
+ * Returns the Java class for the business interface associated
+ * with this reference.
+ *
+ * @return the Java class for the business interface associated
+ * with this reference.
+ */
+ Class<B> getBusinessInterface();
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java
new file mode 100644
index 0000000000..8ebaa96500
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class ServiceRuntimeException extends RuntimeException {
+ /**
+ * Constructs a ServiceRuntimeException with no detail message.
+ */
+ public ServiceRuntimeException() {
+ super();
+ }
+
+ /**
+ * Constructs a ServiceRuntimeException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public ServiceRuntimeException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a ServiceRuntimeException with the specified detail
+ * message and cause.
+ *
+ * The detail message associated with <code>cause</code> is not
+ * automatically incorporated in this exception's detail message.
+ *
+ * @param message the detail message
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public ServiceRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a ServiceRuntimeException with the specified cause and a
+ * detail message of <tt>(cause==null ? null : cause.toString())</tt>.
+ *
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public ServiceRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ private static final long serialVersionUID = 6761623124602414622L;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java
new file mode 100644
index 0000000000..355a84a4c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca;
+
+/**
+ * This exception signals problems in the interaction with remote
+ * services.
+ *
+ * These are exceptions that can be transient, so retrying is
+ * appropriate. Any exception that is a ServiceRuntimeException
+ * that is not a ServiceUnavailableException is unlikely to be
+ * resolved by retrying the operation, since it most likely
+ * requires human intervention.
+ */
+public class ServiceUnavailableException extends ServiceRuntimeException {
+ /**
+ * Constructs a ServiceUnavailableException with no detail message.
+ */
+ public ServiceUnavailableException() {
+ super();
+ }
+
+ /**
+ * Constructs a ServiceUnavailableException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public ServiceUnavailableException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a ServiceUnavailableException with the specified detail
+ * message and cause.
+ *
+ * The detail message associated with <code>cause</code> is not
+ * automatically incorporated in this exception's detail message.
+ *
+ * @param message the detail message
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public ServiceUnavailableException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a ServiceUnavailableException with the specified cause and
+ * a detail message of <tt>(cause==null ? null : cause.toString())</tt>.
+ *
+ * @param cause the cause, or null if the cause is nonexistent
+ * or unknown
+ */
+ public ServiceUnavailableException(Throwable cause) {
+ super(cause);
+ }
+
+ private static final long serialVersionUID = 5750303470949048271L;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java
new file mode 100644
index 0000000000..3350e9413b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @AllowsPassByReference annotation is used on implementations
+ * of remotable interfaces to indicate that interactions with the
+ * service from a client within the same address space are allowed
+ * to use pass by reference data exchange semantics.
+ *
+ * The implementation promises that its by-value semantics will be
+ * maintained even if the parameters and return values are actually
+ * passed by-reference. This means that the service will not modify
+ * any operation input parameter or return value, even after returning
+ * from the operation.
+ *
+ * Either a whole class implementing a remotable service or an individual
+ * remotable service method implementation can be annotated using the
+ * {@literal @AllowsPassByReference} annotation.
+ *
+ * {@literal @AllowsPassByReference} has no attributes.
+ */
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface AllowsPassByReference {
+
+ boolean value() default true;
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java
new file mode 100644
index 0000000000..278e8ead57
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @AsyncFault annotation is used to indicate the faults/exceptions which are returned by
+ * the asynchronous service method which it annotates.
+ *
+ */
+@Inherited
+@Target({METHOD})
+@Retention(RUNTIME)
+public @interface AsyncFault {
+
+ Class<?>[] value() default {};
+
+}
+
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java
new file mode 100644
index 0000000000..c6a4147afd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @AsyncInvocation annotation is used to indicate that the operations of a Java interface
+ * uses the long-running request-response pattern as described in the SCA Assembly specification.
+ *
+ */
+@Inherited
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+@Intent(AsyncInvocation.ASYNCINVOCATION)
+public @interface AsyncInvocation {
+ String ASYNCINVOCATION = SCA_PREFIX + "asyncInvocation";
+
+ boolean value() default true;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java
new file mode 100644
index 0000000000..2b18388c8b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Authentication annotation is used to indicate that the
+ * invocation requires authentication.
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Authentication.AUTHENTICATION)
+public @interface Authentication {
+ /**
+ * The serialized QName of the authentication policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String AUTHENTICATION = SCA_PREFIX + "authentication";
+ /**
+ * The serialized QName of the authentication.message policy
+ * intent, for use with the SCA @Requires annotation.
+ */
+ String AUTHENTICATION_MESSAGE = AUTHENTICATION + ".message";
+ /**
+ * The serialized QName of the authentication.transport policy
+ * intent, for use with the SCA @Requires annotation.
+ */
+ String AUTHENTICATION_TRANSPORT = AUTHENTICATION + ".transport";
+
+ /**
+ * List of authentication qualifiers (such as "message"
+ * or "transport").
+ *
+ * @return authentication qualifiers
+ */
+ @Qualifier
+ String[] value() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java
new file mode 100644
index 0000000000..6893f6196a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Authorization annotation is used to indicate that
+ * an authorization policy is required.
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Authorization.AUTHORIZATION)
+public @interface Authorization {
+ /**
+ * The serialized QName of the authorization policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String AUTHORIZATION = SCA_PREFIX + "authorization";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java
new file mode 100644
index 0000000000..cc68baaba9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright(C) OASIS(R) 2005, 2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Callback annotation is used to annotate a service interface
+ * with a callback interface, which takes the Java Class object of
+ * the callback interface as a parameter.
+ */
+@Target({TYPE, METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Callback {
+
+ /**
+ * The name of a Java class file containing the callback interface.
+ *
+ * @return the callback interface
+ */
+ Class<?> value() default Void.class;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java
new file mode 100644
index 0000000000..5ea768a9ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @ComponentName annotation is used to denote a Java class field
+ * or setter method that is used to inject the component name.
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface ComponentName {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java
new file mode 100644
index 0000000000..df5c3c502e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Confidentiality annotation is used to indicate that the
+ * invocation requires confidentiality.
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Confidentiality.CONFIDENTIALITY)
+public @interface Confidentiality {
+ /**
+ * The serialized QName of the confidentiality policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String CONFIDENTIALITY = SCA_PREFIX + "confidentiality";
+ /**
+ * The serialized QName of the confidentiality.message policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String CONFIDENTIALITY_MESSAGE = CONFIDENTIALITY + ".message";
+ /**
+ * The serialized QName of the confidentiality.transport policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String CONFIDENTIALITY_TRANSPORT = CONFIDENTIALITY + ".transport";
+
+ /**
+ * List of confidentiality qualifiers (such as "message" or "transport").
+ *
+ * @return confidentiality qualifiers
+ */
+ @Qualifier
+ String[] value() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java
new file mode 100644
index 0000000000..c1c99de683
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Used to indicate the constructor the runtime is to use when instantiating a component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+@Target(CONSTRUCTOR)
+@Retention(RUNTIME)
+public @interface Constructor {
+ String[] value() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java
new file mode 100644
index 0000000000..90cf9b81ce
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Context annotation is used to denote a Java class field
+ * or a setter method that is used to inject a composite context
+ * for the component. The type of context to be injected is defined
+ * by the type of the Java class field or type of the setter method
+ * input argument; the type is either ComponentContext or RequestContext.
+ *
+ * The @Context annotation has no attributes.
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Context {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java
new file mode 100644
index 0000000000..b4d3cd4369
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Destroy annotation is used to denote a single Java class method
+ * that will be called when the scope defined for the implementation
+ * class ends. The method MAY have any access modifier and MUST have a
+ * void return type and no arguments.
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+public @interface Destroy {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java
new file mode 100644
index 0000000000..e4cd03ea4b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @EagerInit annotation is used to annotate the Java class of a
+ * COMPOSITE scoped implementation for eager initialization. When marked
+ * for eager initialization, the composite scoped instance is created
+ * when its containing component is started.
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface EagerInit {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java
new file mode 100644
index 0000000000..b4b420c175
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Init annotation is used to denote a single Java class method
+ * that is called when the scope defined for the implementation class
+ * starts. The method MAY have any access modifier and MUST have a
+ * void return type and no arguments.
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+public @interface Init {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java
new file mode 100644
index 0000000000..e9918533d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Integrity annotation is used to indicate that the invocation
+ * requires integrity (ie no tampering of the messages between client
+ * and service).
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Integrity.INTEGRITY)
+public @interface Integrity {
+ /**
+ * The serialized QName of the integrity policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String INTEGRITY = SCA_PREFIX + "integrity";
+ /**
+ * The serialized QName of the integrity.message policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String INTEGRITY_MESSAGE = INTEGRITY + ".message";
+ /**
+ * The serialized QName of the integrity.transport policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String INTEGRITY_TRANSPORT = INTEGRITY + ".transport";
+
+ /**
+ * List of integrity qualifiers (such as "message" or "transport").
+ *
+ * @return integrity qualifiers
+ */
+ @Qualifier
+ String[] value() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java
new file mode 100644
index 0000000000..593ae56e67
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Intent annotation is used for the creation of new annotations
+ * for specific intents. It is not expected that the @Intent annotation
+ * will be used in application code.
+ */
+@Target({ANNOTATION_TYPE})
+@Retention(RUNTIME)
+public @interface Intent {
+ /**
+ * The qualified name of the intent, in the form defined by
+ * javax.xml.namespace.QName.toString().
+ * @return the qualified name of the intent
+ */
+ String value() default "";
+
+ /**
+ * The XML namespace for the intent.
+ * @return the XML namespace for the intent
+ */
+ String targetNamespace() default "";
+
+ /**
+ * The name of the intent within its namespace.
+ * @return name of the intent within its namespace
+ */
+ String localPart() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java
new file mode 100644
index 0000000000..ba6b086756
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @ManagedSharedTransaction annotation is used to indicate that
+ * a distributed ACID transaction is required.
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(ManagedSharedTransaction.MANAGEDSHAREDTRANSACTION)
+public @interface ManagedSharedTransaction {
+ /**
+ * The serialized QName of the managedSharedTransaction policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String MANAGEDSHAREDTRANSACTION = SCA_PREFIX + "managedSharedTransaction";
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java
new file mode 100644
index 0000000000..6fca1ab5df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @ManagedTransaction annotation is used to indicate the
+ * need for an ACID transaction environment.
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(ManagedTransaction.MANAGEDTRANSACTION)
+public @interface ManagedTransaction {
+ /**
+ * The serialized QName of the managedTransaction policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String MANAGEDTRANSACTION = SCA_PREFIX + "managedTransaction";
+ /**
+ * The serialized QName of the managedTransaction.local policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String MANAGEDTRANSACTION_MESSAGE = MANAGEDTRANSACTION + ".local";
+ /**
+ * The serialized QName of the managedTransaction.global policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String MANAGEDTRANSACTION_TRANSPORT = MANAGEDTRANSACTION + ".global";
+
+ /**
+ * List of managedTransaction qualifiers (such as "global" or "local").
+ *
+ * @return managedTransaction qualifiers
+ */
+ @Qualifier
+ String[] value() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java
new file mode 100644
index 0000000000..9a4bf86053
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @MutualAuthentication annotation is used to indicate that
+ * a mutual authentication policy is needed.
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(MutualAuthentication.MUTUALAUTHENTICATION)
+public @interface MutualAuthentication {
+ /**
+ * The serialized QName of the mutualAuthentication policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String MUTUALAUTHENTICATION = SCA_PREFIX + "mutualAuthentication";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java
new file mode 100644
index 0000000000..5c31fbc99f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.oasisopen.sca.Constants.SCA_PREFIX;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @NoManagedTransaction annotation is used to indicate that
+ * a non-transactional environment is needed.
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(NoManagedTransaction.NOMANAGEDTRANSACTION)
+public @interface NoManagedTransaction {
+ /**
+ * The serialized QName of the noManagedTransaction policy intent,
+ * for use with the SCA @Requires annotation.
+ */
+ String NOMANAGEDTRANSACTION = SCA_PREFIX + "noManagedTransaction";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java
new file mode 100644
index 0000000000..1fbf83458e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @OneWay annotation is used on a Java interface or class method
+ * to indicate that invocations will be dispatched in a non-blocking
+ * fashion as described in the section on Asynchronous Programming.
+ *
+ * The @OneWay annotation has no attributes.
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+public @interface OneWay {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java
new file mode 100644
index 0000000000..2f9fe9a098
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @PolicySets annotation is used to attach one or more
+ * SCA Policy Sets to a Java implementation class or to one
+ * of its subelements.
+ */
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+public @interface PolicySets {
+ /**
+ * Returns the policy sets to be applied.
+ *
+ * @return the policy sets to be applied
+ */
+ String[] value() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java
new file mode 100644
index 0000000000..6a8c8a0e04
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Property annotation is used to denote a Java class field,
+ * a setter method, or a constructor parameter that is used to
+ * inject an SCA property value. The type of the property injected,
+ * which can be a simple Java type or a complex Java type, is defined
+ * by the type of the Java class field or the type of the input
+ * parameter of the setter method or constructor.
+ *
+ * The @Property annotation can be used on fields, on setter methods
+ * or on a constructor method parameter. However, the @Property annotation
+ * MUST NOT be used on a class field that is declared as final.
+ *
+ * Properties can also be injected via setter methods even when
+ * the @Property annotation is not present. However, the @Property
+ * annotation must be used in order to inject a property onto a
+ * non-public field. In the case where there is no @Property
+ * annotation, the name of the property is the same as the name of the
+ * field or setter.
+ *
+ * Where there is both a setter method and a field for a property, the
+ * setter method is used.
+ */
+@Target({METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface Property {
+
+ /**
+ * The name of the property. For a field annotation, the default is
+ * the name of the field of the Java class. For a setter method annotation,
+ * the default is the JavaBeans property name corresponding to the setter
+ * method name. For a constructor parameter annotation, there is no
+ * default and the name attribute MUST be present.
+ *
+ * @return the name of the property
+ */
+ String name() default "";
+
+ /**
+ * Specifies whether injection is required, defaults to true. For a
+ * constructor parameter annotation, this attribute MUST have the value true.
+ *
+ * @return true if injection is required
+ */
+ boolean required() default true;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java
new file mode 100644
index 0000000000..dd002d27c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Qualifier annotation is applied to an attribute of a
+ * specific intent annotation definition, defined using the @Intent
+ * annotation, to indicate that the attribute provides qualifiers
+ * for the intent. The @Qualifier annotation MUST be used in a
+ * specific intent annotation definition where the intent has qualifiers.
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+public @interface Qualifier {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java
new file mode 100644
index 0000000000..4dbf9412fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Reference annotation type is used to annotate a Java class field,
+ * a setter method, or a constructor parameter that is used to inject a
+ * service that resolves the reference. The interface of the service
+ * injected is defined by the type of the Java class field or the type
+ * of the input parameter of the setter method or constructor.
+ *
+ * The @Reference annotation MUST NOT be used on a class field that is
+ * declared as final.
+ *
+ * References can also be injected via setter methods even when
+ * the @Reference annotation is not present. However, the @Reference
+ * annotation must be used in order to inject a reference onto a non-public
+ * field. In the case where there is no @Reference annotation, the name
+ * of the reference is the same as the name of the field or setter.
+ *
+ * Where there is both a setter method and a field for a reference, the
+ * setter method is used.
+ */
+@Target({METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface Reference {
+
+ /**
+ * The name of the reference. For a field annotation, the default is
+ * the name of the field of the Java class. For a setter method
+ * annotation, the default is the JavaBeans property name corresponding
+ * to the setter method name. For a constructor parameter annotation,
+ * there is no default and the name attribute MUST be present.
+ *
+ * @return the name of the reference
+ */
+ String name() default "";
+
+ /**
+ * Specifies whether injection of service or services is required.
+ * Defaults to true. For a constructor parameter annotation, this
+ * attribute MUST have the value true.
+ *
+ * @return true if injection is required
+ */
+ boolean required() default true;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java
new file mode 100644
index 0000000000..50f3557bed
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Remotable annotation is used to specify a Java service
+ * interface as remotable. A remotable service can be published
+ * externally as a service and must be translatable into a WSDL portType.
+ *
+ * The @Remotable annotation has no attributes.
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface Remotable {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java
new file mode 100644
index 0000000000..b5d485e016
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Requires annotation supports general purpose intents
+ * specified as strings. Users can also define specific intent
+ * annotations using the @Intent annotation.
+ */
+@Inherited
+@Retention(RUNTIME)
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+public @interface Requires {
+ /**
+ * Returns the attached intents.
+ *
+ * @return the attached intents
+ */
+ String[] value() default "";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java
new file mode 100644
index 0000000000..087f589168
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Scope annotation MUST only be used on a service's implementation
+ * class. It is an error to use this annotation on an interface.
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface Scope {
+
+ /**
+ * The name of the scope.
+ *
+ * For 'STATELESS' implementations, a different implementation
+ * instance can be used to service each request. Implementation
+ * instances can be newly created or be drawn from a pool of instances.
+ *
+ * SCA defines the following scope names, but others can be defined
+ * by particular Java-based implementation types:
+ * STATELESS
+ * COMPOSITE
+ * The default value is STATELESS.
+ *
+ * @return the name of the scope
+ */
+ String value() default "STATELESS";
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java
new file mode 100644
index 0000000000..5c2600ff12
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.annotation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The @Service annotation is used on a component implementation
+ * class to specify the SCA services offered by the implementation.
+ *
+ * The class need not be declared as implementing all of the
+ * interfaces implied by the services, but all methods of the service
+ * interfaces must be present.
+ *
+ * A class used as the implementation of a service is not required
+ * to have a @Service annotation. If a class has no @Service annotation,
+ * then the rules determining which services are offered and what
+ * interfaces those services have are determined by the specific
+ * implementation type.
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface Service {
+
+ /**
+ * The value is an array of interface or class objects that should be
+ * exposed as services by this component.
+ *
+ * @return the services of this component
+ */
+ Class<?>[] value();
+
+ /**
+ * The value is an array of strings which are used as the service names
+ * for each of the interfaces declared in the value array.
+ *
+ * @return the service names
+ */
+ String[] names() default {};
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html
new file mode 100644
index 0000000000..b29df75b5f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html
@@ -0,0 +1,3 @@
+<body>
+Provides SCA common annotation definitions for Java.
+</body>
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java
new file mode 100644
index 0000000000..9e25d407a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.client;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactoryFinder;
+import org.oasisopen.sca.client.impl.SCAClientFactoryFinderImpl;
+
+/**
+ * The SCAClientFactory can be used by non-SCA managed code to
+ * lookup services that exist in a SCA Domain.
+ *
+ * @see SCAClientFactoryFinderImpl
+ *
+ * @author OASIS Open
+ */
+
+public abstract class SCAClientFactory {
+
+ /**
+ * The SCAClientFactoryFinder.
+ * Provides a means by which a provider of an SCAClientFactory
+ * implementation can inject a factory finder implementation into
+ * the abstract SCAClientFactory class - once this is done, future
+ * invocations of the SCAClientFactory use the injected factory
+ * finder to locate and return an instance of a subclass of
+ * SCAClientFactory.
+ */
+ protected static SCAClientFactoryFinder factoryFinder;
+ /**
+ * The Domain URI of the SCA Domain which is accessed by this
+ * SCAClientFactory
+ */
+ private URI domainURI;
+
+ /**
+ * Prevent concrete subclasses from using the no-arg constructor
+ */
+ private SCAClientFactory() {
+ }
+
+ /**
+ * Constructor used by concrete subclasses
+ * @param domainURI - The Domain URI of the Domain accessed via this
+ * SCAClientFactory
+ */
+ protected SCAClientFactory(URI domainURI)
+ throws NoSuchDomainException {
+ this.domainURI = domainURI;
+ }
+
+ /**
+ * Gets the Domain URI of the Domain accessed via this SCAClientFactory
+ * @return - the URI for the Domain
+ */
+ protected URI getDomainURI() {
+ return domainURI;
+ }
+
+
+ /**
+ * Creates a new instance of the SCAClientFactory that can be
+ * used to lookup SCA Services.
+ *
+ * @param domainURI URI of the target domain for the SCAClientFactory
+ * @return A new SCAClientFactory
+ */
+ public static SCAClientFactory newInstance( URI domainURI )
+ throws NoSuchDomainException {
+ return newInstance(null, null, domainURI);
+ }
+
+ /**
+ * Creates a new instance of the SCAClientFactory that can be
+ * used to lookup SCA Services.
+ *
+ * @param properties Properties that may be used when
+ * creating a new instance of the SCAClientFactory
+ * @param domainURI URI of the target domain for the SCAClientFactory
+ * @return A new SCAClientFactory instance
+ */
+ public static SCAClientFactory newInstance(Properties properties,
+ URI domainURI)
+ throws NoSuchDomainException {
+ return newInstance(properties, null, domainURI);
+ }
+
+ /**
+ * Creates a new instance of the SCAClientFactory that can be
+ * used to lookup SCA Services.
+ *
+ * @param classLoader ClassLoader that may be used when
+ * creating a new instance of the SCAClientFactory
+ * @param domainURI URI of the target domain for the SCAClientFactory
+ * @return A new SCAClientFactory instance
+ */
+ public static SCAClientFactory newInstance(ClassLoader classLoader,
+ URI domainURI)
+ throws NoSuchDomainException {
+ return newInstance(null, classLoader, domainURI);
+ }
+
+ /**
+ * Creates a new instance of the SCAClientFactory that can be
+ * used to lookup SCA Services.
+ *
+ * @param properties Properties that may be used when
+ * creating a new instance of the SCAClientFactory
+ * @param classLoader ClassLoader that may be used when
+ * creating a new instance of the SCAClientFactory
+ * @param domainURI URI of the target domain for the SCAClientFactory
+ * @return A new SCAClientFactory instance
+ */
+ public static SCAClientFactory newInstance(Properties properties,
+ ClassLoader classLoader,
+ URI domainURI)
+ throws NoSuchDomainException {
+ final SCAClientFactoryFinder finder =
+ factoryFinder != null ? factoryFinder :
+ new SCAClientFactoryFinderImpl();
+ final SCAClientFactory factory
+ = finder.find(properties, classLoader, domainURI);
+ return factory;
+ }
+
+ /**
+ * Returns a reference proxy that implements the business interface <T>
+ * of a service in the SCA Domain handled by this SCAClientFactory
+ *
+ * @param serviceURI the relative URI of the target service. Takes the
+ * form componentName/serviceName.
+ * Can also take the extended form componentName/serviceName/bindingName
+ * to use a specific binding of the target service
+ *
+ * @param interfaze The business interface class of the service in the
+ * domain
+ * @param <T> The business interface class of the service in the domain
+ *
+ * @return a proxy to the target service, in the specified SCA Domain
+ * that implements the business interface <B>.
+ * @throws NoSuchServiceException Service requested was not found
+ * @throws NoSuchDomainException Domain requested was not found
+ */
+ public abstract <T> T getService(Class<T> interfaze, String serviceURI)
+ throws NoSuchServiceException, NoSuchDomainException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java
new file mode 100644
index 0000000000..54a73fc023
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+
+package org.oasisopen.sca.client;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.oasisopen.sca.NoSuchDomainException;
+
+/* A Service Provider Interface representing a SCAClientFactory finder.
+ * SCA provides a default reference implementation of this interface.
+ * SCA runtime vendors can create alternative implementations of this
+ * interface that use different class loading or lookup mechanisms.
+ */
+public interface SCAClientFactoryFinder {
+
+ /**
+ * Method for finding the SCAClientFactory for a given Domain URI using
+ * a specified set of properties and a a specified ClassLoader
+ * @param properties - properties to use - may be null
+ * @param classLoader - ClassLoader to use - may be null
+ * @param domainURI - the Domain URI - must be a valid SCA Domain URI
+ * @return - the SCAClientFactory or null if the factory could not be
+ * @throws - NoSuchDomainException if the domainURI does not reference
+ * a valid SCA Domain
+ * found
+ */
+ SCAClientFactory find(Properties properties,
+ ClassLoader classLoader,
+ URI domainURI )
+ throws NoSuchDomainException ;
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java
new file mode 100644
index 0000000000..0f5eae7603
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java
@@ -0,0 +1,289 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.client.impl;
+
+import org.oasisopen.sca.client.SCAClientFactoryFinder;
+
+import java.io.BufferedReader;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.net.URI;
+import java.net.URL;
+import java.util.Properties;
+
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This is a default implementation of an SCAClientFactoryFinder which is
+ * used to find an implementation of the SCAClientFactory interface.
+ *
+ * @see SCAClientFactoryFinder
+ * @see SCAClientFactory
+ *
+ * @author OASIS Open
+ */
+public class SCAClientFactoryFinderImpl implements SCAClientFactoryFinder {
+
+ /**
+ * The name of the System Property used to determine the SPI
+ * implementation to use for the SCAClientFactory.
+ */
+ private static final String SCA_CLIENT_FACTORY_PROVIDER_KEY =
+ SCAClientFactory.class.getName();
+
+ /**
+ * The name of the file loaded from the ClassPath to determine
+ * the SPI implementation to use for the SCAClientFactory.
+ */
+ private static final String SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE
+ = "META-INF/services/" + SCA_CLIENT_FACTORY_PROVIDER_KEY;
+
+ /**
+ * Public Constructor
+ */
+ public SCAClientFactoryFinderImpl() {
+ }
+
+ /**
+ * Creates an instance of the SCAClientFactorySPI implementation.
+ * This discovers the SCAClientFactorySPI Implementation and instantiates
+ * the provider's implementation.
+ *
+ * @param properties Properties that may be used when creating a new
+ * instance of the SCAClient
+ * @param classLoader ClassLoader that may be used when creating a new
+ * instance of the SCAClient
+ * @return new instance of the SCAClientFactory
+ * @throws ServiceRuntimeException Failed to create SCAClientFactory
+ * Implementation.
+ */
+ public SCAClientFactory find(Properties properties,
+ ClassLoader classLoader,
+ URI domainURI )
+ throws NoSuchDomainException, ServiceRuntimeException {
+ if (classLoader == null) {
+ classLoader = getThreadContextClassLoader ();
+ }
+ final String factoryImplClassName =
+ discoverProviderFactoryImplClass(properties, classLoader);
+ final Class<? extends SCAClientFactory> factoryImplClass
+ = loadProviderFactoryClass(factoryImplClassName,
+ classLoader);
+ final SCAClientFactory factory =
+ instantiateSCAClientFactoryClass(factoryImplClass,
+ domainURI );
+ return factory;
+ }
+
+ /**
+ * Gets the Context ClassLoader for the current Thread.
+ *
+ * @return The Context ClassLoader for the current Thread.
+ */
+ private static ClassLoader getThreadContextClassLoader () {
+ final ClassLoader threadClassLoader =
+ Thread.currentThread().getContextClassLoader();
+ return threadClassLoader;
+ }
+
+ /**
+ * Attempts to discover the class name for the SCAClientFactorySPI
+ * implementation from the specified Properties, the System Properties
+ * or the specified ClassLoader.
+ *
+ * @return The class name of the SCAClientFactorySPI implementation
+ * @throw ServiceRuntimeException Failed to find implementation for
+ * SCAClientFactorySPI.
+ */
+ private static String
+ discoverProviderFactoryImplClass(Properties properties,
+ ClassLoader classLoader)
+ throws ServiceRuntimeException {
+ String providerClassName =
+ checkPropertiesForSPIClassName(properties);
+ if (providerClassName != null) {
+ return providerClassName;
+ }
+
+ providerClassName =
+ checkPropertiesForSPIClassName(System.getProperties());
+ if (providerClassName != null) {
+ return providerClassName;
+ }
+
+ providerClassName = checkMETAINFServicesForSPIClassName(classLoader);
+ if (providerClassName == null) {
+ throw new ServiceRuntimeException(
+ "Failed to find implementation for SCAClientFactory");
+ }
+
+ return providerClassName;
+ }
+
+ /**
+ * Attempts to find the class name for the SCAClientFactorySPI
+ * implementation from the specified Properties.
+ *
+ * @return The class name for the SCAClientFactorySPI implementation
+ * or <code>null</code> if not found.
+ */
+ private static String
+ checkPropertiesForSPIClassName(Properties properties) {
+ if (properties == null) {
+ return null;
+ }
+
+ final String providerClassName =
+ properties.getProperty(SCA_CLIENT_FACTORY_PROVIDER_KEY);
+ if (providerClassName != null && providerClassName.length() > 0) {
+ return providerClassName;
+ }
+
+ return null;
+ }
+
+ /**
+ * Attempts to find the class name for the SCAClientFactorySPI
+ * implementation from the META-INF/services directory
+ *
+ * @return The class name for the SCAClientFactorySPI implementation or
+ * <code>null</code> if not found.
+ */
+ private static String checkMETAINFServicesForSPIClassName(ClassLoader cl)
+ {
+ final URL url =
+ cl.getResource(SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE);
+ if (url == null) {
+ return null;
+ }
+
+ InputStream in = null;
+ try {
+ in = url.openStream();
+ BufferedReader reader = null;
+ try {
+ reader =
+ new BufferedReader(new InputStreamReader(in, "UTF-8"));
+
+ String line;
+ while ((line = readNextLine(reader)) != null) {
+ if (!line.startsWith("#") && line.length() > 0) {
+ return line;
+ }
+ }
+
+ return null;
+ } finally {
+ closeStream(reader);
+ }
+ } catch (IOException ex) {
+ throw new ServiceRuntimeException(
+ "Failed to discover SCAClientFactory provider", ex);
+ } finally {
+ closeStream(in);
+ }
+ }
+
+ /**
+ * Reads the next line from the reader and returns the trimmed version
+ * of that line
+ *
+ * @param reader The reader from which to read the next line
+ * @return The trimmed next line or <code>null</code> if the end of the
+ * stream has been reached
+ * @throws IOException I/O error occurred while reading from Reader
+ */
+ private static String readNextLine(BufferedReader reader)
+ throws IOException {
+
+ String line = reader.readLine();
+ if (line != null) {
+ line = line.trim();
+ }
+ return line;
+ }
+
+ /**
+ * Loads the specified SCAClientFactory Implementation class.
+ *
+ * @param factoryImplClassName The name of the SCAClientFactory
+ * Implementation class to load
+ * @return The specified SCAClientFactory Implementation class
+ * @throws ServiceRuntimeException Failed to load the SCAClientFactory
+ * Implementation class
+ */
+ private static Class<? extends SCAClientFactory>
+ loadProviderFactoryClass(String factoryImplClassName,
+ ClassLoader classLoader)
+ throws ServiceRuntimeException {
+
+ try {
+ final Class<?> providerClass =
+ classLoader.loadClass(factoryImplClassName);
+ final Class<? extends SCAClientFactory> providerFactoryClass =
+ providerClass.asSubclass(SCAClientFactory.class);
+ return providerFactoryClass;
+ } catch (ClassNotFoundException ex) {
+ throw new ServiceRuntimeException(
+ "Failed to load SCAClientFactory implementation class "
+ + factoryImplClassName, ex);
+ } catch (ClassCastException ex) {
+ throw new ServiceRuntimeException(
+ "Loaded SCAClientFactory implementation class "
+ + factoryImplClassName
+ + " is not a subclass of "
+ + SCAClientFactory.class.getName() , ex);
+ }
+ }
+
+ /**
+ * Instantiate an instance of the specified SCAClientFactorySPI
+ * Implementation class.
+ *
+ * @param factoryImplClass The SCAClientFactorySPI Implementation
+ * class to instantiate.
+ * @return An instance of the SCAClientFactorySPI Implementation class
+ * @throws ServiceRuntimeException Failed to instantiate the specified
+ * specified SCAClientFactorySPI Implementation class
+ */
+ private static SCAClientFactory instantiateSCAClientFactoryClass(
+ Class<? extends SCAClientFactory> factoryImplClass,
+ URI domainURI)
+ throws NoSuchDomainException, ServiceRuntimeException {
+
+ try {
+ Constructor<? extends SCAClientFactory> URIConstructor =
+ factoryImplClass.getConstructor(domainURI.getClass());
+ SCAClientFactory provider =
+ URIConstructor.newInstance( domainURI );
+ return provider;
+ } catch (Throwable ex) {
+ throw new ServiceRuntimeException(
+ "Failed to instantiate SCAClientFactory implementation class "
+ + factoryImplClass, ex);
+ }
+ }
+
+ /**
+ * Utility method for closing Closeable Object.
+ *
+ * @param closeable The Object to close.
+ */
+ private static void closeStream(Closeable closeable) {
+ if (closeable != null) {
+ try{
+ closeable.close();
+ } catch (IOException ex) {
+ throw new ServiceRuntimeException("Failed to close stream",
+ ex);
+ }
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/package.html b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/package.html
new file mode 100644
index 0000000000..236fc686a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-api/src/main/java/org/oasisopen/sca/package.html
@@ -0,0 +1,3 @@
+<body>
+Provides SCA common API definitions for Java.
+</body>
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/LICENSE b/sandbox/sebastien/java/embed/modules/sca-client-impl/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/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/sebastien/java/embed/modules/sca-client-impl/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/sca-client-impl/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..e96d9c6c54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Client Impl
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Client Impl
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.client;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.client.impl
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/NOTICE b/sandbox/sebastien/java/embed/modules/sca-client-impl/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/pom.xml b/sandbox/sebastien/java/embed/modules/sca-client-impl/pom.xml
new file mode 100644
index 0000000000..2657e1b466
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/pom.xml
@@ -0,0 +1,47 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <name>Apache Tuscany SCA Client Impl</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java
new file mode 100644
index 0000000000..b8830d4d60
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryFinderImpl.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.apache.tuscany.sca.client.impl;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.client.SCAClientFactory;
+import org.oasisopen.sca.client.SCAClientFactoryFinder;
+
+/**
+ * A Tuscany specific implementation of an SCAClientFactoryFinder which finds
+ * hard codes the use of the Tuscany SCAClientFactory instead of doscovering it.
+ *
+ * @see SCAClientFactoryFinder
+ * @see SCAClientFactory
+ */
+public class SCAClientFactoryFinderImpl implements SCAClientFactoryFinder {
+
+ /**
+ * Public Constructor
+ */
+ public SCAClientFactoryFinderImpl() {
+ }
+
+ /**
+ * Creates an instance of the SCAClientFactorySPI implementation.
+ * This discovers the SCAClientFactorySPI Implementation and instantiates
+ * the provider's implementation.
+ *
+ * @param properties Properties that may be used when creating a new
+ * instance of the SCAClient
+ * @param classLoader ClassLoader that may be used when creating a new
+ * instance of the SCAClient
+ * @return new instance of the SCAClientFactory
+ * @throws ServiceRuntimeException Failed to create SCAClientFactory
+ * Implementation.
+ */
+ public SCAClientFactory find(Properties properties,
+ ClassLoader classLoader,
+ URI domainURI ) throws NoSuchDomainException, ServiceRuntimeException {
+ return new SCAClientFactoryImpl2(domainURI);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
new file mode 100644
index 0000000000..d32afb2acb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.client.impl;
+
+import java.net.URI;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.client.SCAClientFactory;
+import org.oasisopen.sca.client.SCAClientFactoryFinder;
+
+public class SCAClientFactoryImpl extends SCAClientFactory {
+
+ public static void setSCAClientFactoryFinder(SCAClientFactoryFinder factoryFinder) {
+ SCAClientFactory.factoryFinder = factoryFinder;
+ }
+
+ private final ExtensionPointRegistry extensionsRegistry;
+ private final AssemblyFactory assemblyFactory;
+ private final JavaInterfaceFactory javaInterfaceFactory;
+ private final ProxyFactory proxyFactory;
+ private final EndpointRegistry endpointRegistry;
+ private final NodeFactoryImpl nodeFactory;
+ private final CompositeContext compositeContext;
+
+ public SCAClientFactoryImpl(URI domainURI) throws NoSuchDomainException {
+ super(domainURI);
+
+ this.nodeFactory = (NodeFactoryImpl)NodeFactory.getInstance();
+ this.nodeFactory.init();
+ this.extensionsRegistry = nodeFactory.getExtensionPointRegistry();
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
+
+ String registryURI = getDomainURI().toString();
+
+ this.endpointRegistry = domainRegistryFactory.getEndpointRegistry(registryURI, getDomainURI().toString()); // TODO: shouldnt use null for reg uri
+
+ // TODO: if there is not an existing endpoint registry for the domain URI the
+ // this should create an endpoint registry client for the remote domain (eg hazelcast native client)
+ // for now just throw an exception
+ if (endpointRegistry == null) {
+ throw new NoSuchDomainException(domainURI.toString());
+ }
+ FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.proxyFactory = ExtensibleProxyFactory.getInstance(extensionsRegistry);
+
+ String client = "sca.client." + UUID.randomUUID();
+
+ this.compositeContext =
+ new CompositeContext(extensionsRegistry,
+ endpointRegistry,
+ null,
+ domainURI.toString(),
+ client,
+ this.nodeFactory.getDeployer().getSystemDefinitions());
+ }
+
+ @Override
+ public <T> T getService(Class<T> serviceInterface, String serviceName) throws NoSuchServiceException, NoSuchDomainException {
+
+ List<Endpoint> eps = endpointRegistry.findEndpoint(serviceName);
+ if (eps == null || eps.size() < 1) {
+ throw new NoSuchServiceException(serviceName);
+ }
+ Endpoint endpoint = eps.get(0); // TODO: what should be done with multiple endpoints?
+
+ RuntimeEndpointReference epr;
+ try {
+ epr = createEndpointReference(endpoint, serviceInterface);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return proxyFactory.createProxy(serviceInterface, epr);
+
+ }
+
+ private RuntimeEndpointReference createEndpointReference(Endpoint endpoint, Class<?> businessInterface)
+ throws CloneNotSupportedException, InvalidInterfaceException {
+ Component component = endpoint.getComponent();
+ ComponentService service = endpoint.getService();
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName("sca.client." + service.getName());
+
+ componentReference.setCallback(service.getCallback());
+ componentReference.getTargets().add(service);
+ componentReference.getPolicySets().addAll(service.getPolicySets());
+ componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
+ componentReference.getBindings().add(endpoint.getBinding());
+
+ InterfaceContract interfaceContract = service.getInterfaceContract();
+ Service componentTypeService = service.getService();
+ if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
+ interfaceContract = componentTypeService.getInterfaceContract();
+ }
+ interfaceContract = getInterfaceContract(interfaceContract, businessInterface);
+ componentReference.setInterfaceContract(interfaceContract);
+ componentReference.setMultiplicity(Multiplicity.ONE_ONE);
+ // component.getReferences().add(componentReference);
+
+ // create endpoint reference
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setComponent(component);
+ endpointReference.setReference(componentReference);
+ endpointReference.setBinding(endpoint.getBinding());
+ endpointReference.setUnresolved(false);
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+
+ endpointReference.setTargetEndpoint(endpoint);
+
+ componentReference.getEndpointReferences().add(endpointReference);
+ ((RuntimeComponentReference)componentReference).setComponent((RuntimeComponent)component);
+ ((RuntimeEndpointReference)endpointReference).bind(compositeContext);
+
+ return (RuntimeEndpointReference) endpointReference;
+ }
+
+ /**
+ * @param interfaceContract
+ * @param businessInterface
+ * @return
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ private InterfaceContract getInterfaceContract(InterfaceContract interfaceContract, Class<?> businessInterface)
+ throws CloneNotSupportedException, InvalidInterfaceException {
+ if (businessInterface == null) {
+ return interfaceContract;
+ }
+ boolean compatible = false;
+ if (interfaceContract != null && interfaceContract.getInterface() != null) {
+ Interface interfaze = interfaceContract.getInterface();
+ if (interfaze instanceof JavaInterface) {
+ Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
+ if (cls != null && businessInterface.isAssignableFrom(cls)) {
+ compatible = true;
+ }
+ }
+ }
+
+ if (!compatible) {
+ // The interface is not assignable from the interface contract
+ interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(businessInterface);
+ interfaceContract.setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(callInterface
+ .getCallbackClass()));
+ }
+ }
+
+ return interfaceContract;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.java
new file mode 100644
index 0000000000..95e23816b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl2.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.sca.client.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+import org.oasisopen.sca.client.SCAClientFactoryFinder;
+
+public class SCAClientFactoryImpl2 extends SCAClientFactory {
+
+ public static void setSCAClientFactoryFinder(SCAClientFactoryFinder factoryFinder) {
+ SCAClientFactory.factoryFinder = factoryFinder;
+ }
+
+ public SCAClientFactoryImpl2(URI domainURI) throws NoSuchDomainException {
+ super(domainURI);
+ checkDomainURI(domainURI);
+ }
+
+ private void checkDomainURI(URI domainURI) throws NoSuchDomainException {
+ for ( NodeFactory nodeFactory : NodeFactory.getNodeFactories()) {
+ String domainName = getDomainName();
+ List<Node> nodes = ((NodeFactoryImpl)nodeFactory).getNodesInDomain(domainName);
+ if ( !nodes.isEmpty() )
+ return;
+ }
+ throw new NoSuchDomainException(getDomainName());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getService(Class<T> serviceInterface, String serviceName) throws NoSuchServiceException, NoSuchDomainException {
+
+ boolean foundDomain = false;
+ for (NodeFactory nodeFactory : NodeFactory.getNodeFactories()) {
+ for (Node node : ((NodeFactoryImpl)nodeFactory).getNodesInDomain(getDomainName())) {
+ foundDomain = true;
+ for (Endpoint ep : ((NodeImpl)node).getServiceEndpoints()) {
+ if (ep.matches(serviceName)) {
+ return node.getService(serviceInterface, serviceName);
+ }
+ }
+ }
+ }
+
+ // assume that if a local node with the looked for domain name is found then that will
+ // know about all services in the domain so if the service isn't found then it doesn't exist
+ if (foundDomain) {
+ throw new NoSuchServiceException(serviceName);
+ }
+
+ InvocationHandler handler = new SCAClientHandler(getDomainURI().toString(), serviceName, serviceInterface);
+ return (T)Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[]{serviceInterface}, handler);
+ }
+
+ private String getDomainName() {
+ // TODO: if the domain URI encodes config (eg uri:someDomain?bla=etc) then need to parse the domain name
+ String domainName = getDomainURI().toString();
+ return domainName;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.java
new file mode 100644
index 0000000000..b8cb5732fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientHandler.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.sca.client.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class SCAClientHandler implements InvocationHandler {
+
+ private String domainURI;
+ private String serviceName;
+ private Class<?> serviceInterface;
+
+ public SCAClientHandler(String domainURI, String serviceName, Class<?> serviceInterface) {
+ this.domainURI = domainURI;
+ this.serviceName = serviceName;
+ this.serviceInterface = serviceInterface;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ NodeFactoryImpl nodeFactory = (NodeFactoryImpl)NodeFactory.newInstance(domainURI);
+ try {
+ nodeFactory.init();
+
+ ExtensionPointRegistry extensionsRegistry = nodeFactory.getExtensionPointRegistry();
+ Properties props = extensionsRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties();
+ props.setProperty("client", "true");
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionsRegistry);
+
+ String registryURI = domainURI;
+
+ // TODO: theres better ways to do this but this gets things working for now
+ if (registryURI.indexOf(":") == -1) {
+ registryURI = "tuscanyclient:" + registryURI;
+ }
+ if (registryURI.startsWith("uri:")) {
+ registryURI = "tuscanyclient:" + registryURI.substring(4);
+ }
+ if (registryURI.startsWith("tuscany:")) {
+ registryURI = "tuscanyclient:" + registryURI.substring(8);
+ }
+
+ EndpointRegistry endpointRegistry;
+ try {
+ endpointRegistry = domainRegistryFactory.getEndpointRegistry(registryURI, domainURI);
+ } catch (Exception e) {
+ throw new NoSuchDomainException(domainURI, e);
+ }
+
+ FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ ProxyFactory proxyFactory = new ExtensibleProxyFactory(extensionsRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
+
+ String client = "sca.client." + UUID.randomUUID();
+ CompositeContext compositeContext =
+ new CompositeContext(extensionsRegistry, endpointRegistry, null, domainURI.toString(), client, nodeFactory.getDeployer().getSystemDefinitions());
+
+ List<Endpoint> eps = endpointRegistry.findEndpoint(serviceName);
+ if (eps == null || eps.size() < 1) {
+ throw new NoSuchServiceException(serviceName);
+ }
+ Endpoint endpoint = eps.get(0); // TODO: what should be done with multiple endpoints?
+
+ RuntimeEndpointReference epr;
+ try {
+ epr = createEndpointReference(javaInterfaceFactory, compositeContext, assemblyFactory, endpoint, serviceInterface);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ InvocationHandler handler = Proxy.getInvocationHandler(proxyFactory.createProxy(serviceInterface, epr));
+ return handler.invoke(proxy, method, args);
+
+ } finally {
+ nodeFactory.destroy();
+ }
+ }
+
+ private RuntimeEndpointReference createEndpointReference(JavaInterfaceFactory javaInterfaceFactory, CompositeContext compositeContext, AssemblyFactory assemblyFactory, Endpoint endpoint, Class<?> businessInterface) throws CloneNotSupportedException, InvalidInterfaceException {
+ Component component = endpoint.getComponent();
+ ComponentService service = endpoint.getService();
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName("sca.client." + service.getName());
+
+ componentReference.setCallback(service.getCallback());
+ componentReference.getTargets().add(service);
+ componentReference.getPolicySets().addAll(service.getPolicySets());
+ componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
+ componentReference.getBindings().add(endpoint.getBinding());
+
+ InterfaceContract interfaceContract = service.getInterfaceContract();
+ Service componentTypeService = service.getService();
+ if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
+ interfaceContract = componentTypeService.getInterfaceContract();
+ }
+ interfaceContract = getInterfaceContract(javaInterfaceFactory, interfaceContract, businessInterface);
+ componentReference.setInterfaceContract(interfaceContract);
+ componentReference.setMultiplicity(Multiplicity.ONE_ONE);
+ // component.getReferences().add(componentReference);
+
+ // create endpoint reference
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setComponent(component);
+ endpointReference.setReference(componentReference);
+ endpointReference.setBinding(endpoint.getBinding());
+ endpointReference.setUnresolved(false);
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+
+ endpointReference.setTargetEndpoint(endpoint);
+
+ componentReference.getEndpointReferences().add(endpointReference);
+ ((RuntimeComponentReference)componentReference).setComponent((RuntimeComponent)component);
+ ((RuntimeEndpointReference)endpointReference).bind(compositeContext);
+
+ return (RuntimeEndpointReference) endpointReference;
+ }
+
+ /**
+ * @param interfaceContract
+ * @param businessInterface
+ * @return
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ private InterfaceContract getInterfaceContract(JavaInterfaceFactory javaInterfaceFactory, InterfaceContract interfaceContract, Class<?> businessInterface)
+ throws CloneNotSupportedException, InvalidInterfaceException {
+ if (businessInterface == null) {
+ return interfaceContract;
+ }
+ boolean compatible = false;
+ if (interfaceContract != null && interfaceContract.getInterface() != null) {
+ Interface interfaze = interfaceContract.getInterface();
+ if (interfaze instanceof JavaInterface) {
+ Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
+ if (cls != null && businessInterface.isAssignableFrom(cls)) {
+ compatible = true;
+ }
+ }
+ }
+
+ if (!compatible) {
+ // The interface is not assignable from the interface contract
+ interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(businessInterface);
+ interfaceContract.setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(callInterface
+ .getCallbackClass()));
+ }
+ }
+
+ return interfaceContract;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientModuleActivator.java b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientModuleActivator.java
new file mode 100644
index 0000000000..64f982796c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientModuleActivator.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.sca.client.impl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+
+public class SCAClientModuleActivator implements ModuleActivator {
+
+ public SCAClientModuleActivator(ExtensionPointRegistry registry) {
+ }
+
+ public void start() {
+ SCAClientFactoryImpl.setSCAClientFactoryFinder(new SCAClientFactoryFinderImpl());
+ }
+
+ public void stop() {
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.java b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.java
new file mode 100644
index 0000000000..bc1d151d7d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientProxyHandler.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.sca.client.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.oasisopen.sca.NoSuchServiceException;
+
+/**
+ * TODO: What this wants is a way to create a generic invoker for an arbitrary binding
+ * that could mean extending the BindingProvider API to include something like a
+ * createClient method which creates an Invoker for an Endpoint
+ */
+public class SCAClientProxyHandler implements InvocationHandler {
+
+ protected EndpointRegistry endpointRegistry;
+ protected EndpointReference endpointReference;
+ protected String serviceName;
+
+ public SCAClientProxyHandler(String serviceName, ExtensionPointRegistry extensionsRegistry, EndpointRegistry endpointRegistry) {
+ this.endpointRegistry = endpointRegistry;
+ this.serviceName = serviceName;
+
+// RMIHostExtensionPoint rmiHosts = extensionsRegistry.getExtensionPoint(RMIHostExtensionPoint.class);
+// this.rmiHost = new ExtensibleRMIHost(rmiHosts);
+
+ FactoryExtensionPoint factories = extensionsRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+ this.endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setReference(assemblyFactory.createComponentReference());
+ Endpoint targetEndpoint = assemblyFactory.createEndpoint();
+ targetEndpoint.setURI(serviceName);
+ endpointReference.setTargetEndpoint(targetEndpoint);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+ if (endpoints.size() <1 ) {
+ throw new NoSuchServiceException(serviceName);
+ }
+
+ String uri = endpoints.get(0).getBinding().getURI();
+// RMIBindingInvoker invoker = new RMIBindingInvoker(rmiHost, uri, method);
+//
+// return invoker.invokeTarget(args);
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
new file mode 100644
index 0000000000..97a05b05a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/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 ModuleActivator
+org.apache.tuscany.sca.client.impl.SCAClientModuleActivator;ranking=100
diff --git a/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory
new file mode 100644
index 0000000000..bcae8b1296
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory
@@ -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 ModuleActivator
+org.apache.tuscany.sca.client.impl.SCAClientFactoryImpl2
diff --git a/sandbox/sebastien/java/embed/modules/shell/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/shell/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..0d49e4c715
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/shell/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Export-Package: org.apache.tuscany.sca.shell;version="2.0.0"
+Bundle-Name: Apache Tuscany SCA Shell
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Domain Node
+Import-Package:
+ org.apache.tuscany.sca.management;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node2;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.domain.node
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/shell/pom.xml b/sandbox/sebastien/java/embed/modules/shell/pom.xml
new file mode 100644
index 0000000000..e13b74325d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/shell/pom.xml
@@ -0,0 +1,50 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-shell</artifactId>
+ <name>Apache Tuscany SCA Shell</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>0.9.94</version>
+ <optional>true</optional>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
new file mode 100644
index 0000000000..f06a17414e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
@@ -0,0 +1,686 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.shell;
+
+import static java.lang.System.in;
+import static java.lang.System.out;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.node2.Node;
+import org.apache.tuscany.sca.node2.NodeFactory;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.Version;
+import org.apache.tuscany.sca.shell.jline.JLine;
+
+/**
+ * A little SCA command shell.
+ */
+public class Shell {
+
+ private boolean useJline;
+ final List<String> history = new ArrayList<String>();
+ private NodeFactory factory;
+ private String currentDomain = "";
+ private Map<String, Node> standaloneNodes = new HashMap<String, Node>();
+ private Map<String, Node> nodes = new HashMap<String, Node>();
+
+ public static final String[] COMMANDS = new String[] {"bye", "domain", "help", "install", "installed",
+ "printDomainLevelComposite", "remove", "start", "status",
+ "stop"};
+
+ public static void main(final String[] args) throws Exception {
+ boolean useJline = true;
+ String domainURI = "";
+ for (String s : args) {
+ if ("-nojline".equals(s)) {
+ useJline = false;
+ } else {
+ domainURI = s;
+ }
+ }
+ new Shell(domainURI, useJline).run();
+ }
+
+ public Shell(String domainURI, boolean useJLine) {
+ this.factory = NodeFactory.newInstance();
+ this.useJline = useJLine;
+ if (domainURI != null) {
+ domain(domainURI);
+ }
+ }
+
+ boolean domain(final String domainURI) {
+ if (domainURI.length() < 1) {
+ currentDomain = "";
+ } else {
+ for (Node node : nodes.values()) {
+ if (domainURI.equals(node.getDomainName())) {
+ currentDomain = node.getDomainName();
+ return true;
+ }
+ }
+ Node node = factory.createNode(domainURI);
+ currentDomain = node.getDomainName();
+ nodes.put(currentDomain, node);
+ }
+ return true;
+ }
+
+ boolean install(final List<String> toks) throws ContributionReadException, ActivationException, ValidationException {
+ if (getNode() == null) {
+ out.println("not in domain, use domain command first");
+ return true;
+ }
+ boolean runDeployables = !toks.contains("-norun");
+ String metaDataURL = null;
+ if (toks.contains("-metadata")) {
+ metaDataURL = toks.get(toks.indexOf("-metadata") + 1);
+ }
+ List<String> duris = null;
+ if (toks.contains("-duris")) {
+ duris = Arrays.asList(toks.get(toks.indexOf("-duris") + 1).split(","));
+ }
+
+ String first = null;
+ String second = null;
+ for (int i = 1; i < toks.size(); i++) {
+ if (toks.get(i).startsWith("-")) {
+ if (!toks.get(i).equals("-norun")) {
+ i++;
+ }
+ } else {
+ if (first == null) {
+ first = toks.get(i);
+ } else {
+ second = toks.get(i);
+ break;
+ }
+ }
+ }
+
+ String curi = null;
+ String curl = null;
+ if (second != null) {
+ curi = first;
+ curl = second;
+ } else {
+ curl = first;
+ }
+
+ String uri = getNode().installContribution(curi, curl, metaDataURL, duris, runDeployables);
+ out.println("installed at: " + uri);
+ return true;
+ }
+
+ boolean installed(final List<String> toks) {
+ List<String> curis;
+ if (toks.size() > 1) {
+ curis = Arrays.asList(new String[] {toks.get(1)});
+ } else {
+ if (getNode() == null) {
+ return true;
+ }
+ curis = getNode().getInstalledContributions();
+ }
+ for (String curi : curis) {
+ out.println(curi + " " + getNode().getInstalledContribution(curi).getLocation());
+ Contribution c = getNode().getInstalledContribution(curi);
+ for (Artifact a : c.getArtifacts()) {
+ if (a.getModel() instanceof Composite) {
+ Composite composite = (Composite)a.getModel();
+ out.println(" " + composite.getURI() + " " + composite.getName());
+ }
+ }
+ }
+ return true;
+ }
+
+ boolean listComposites(final String curi) {
+ if (getNode() == null) {
+ return true;
+ }
+ Contribution c = getNode().getInstalledContribution(curi);
+ for (Artifact a : c.getArtifacts()) {
+ if (a.getModel() instanceof Composite) {
+ out.println(((Composite)a.getModel()).getName());
+ }
+ }
+ return true;
+ }
+
+ boolean printDomainLevelComposite() throws ContributionReadException, ActivationException, ValidationException {
+ out.println("TODO");
+ // out.println(node.getDomainLevelCompositeAsString());
+ return true;
+ }
+
+ boolean getQNameDefinition(final String curi, String definintion, String symbolSpace)
+ throws ContributionReadException, ActivationException, ValidationException {
+ // TODO:
+ return true;
+ }
+
+ boolean remove(final String curi) throws ContributionReadException, ActivationException, ValidationException {
+ if (getNode() == null) {
+ out.println("not in domain, use domain command first");
+ return true;
+ }
+ getNode().removeContribution(curi);
+ return true;
+ }
+
+ public boolean stop(List<String> toks) throws ActivationException {
+ String curi = toks.get(1);
+ if (toks.size() > 2) {
+ getNode().removeFromDomainLevelComposite(curi, toks.get(2));
+ } else {
+ if (standaloneNodes.containsKey(curi)) {
+ standaloneNodes.remove(curi).stop();
+ } else if (nodes.containsKey(curi)) {
+ Node n = nodes.remove(curi);
+ n.stop();
+ if (n.getDomainName().equals(currentDomain)) {
+ currentDomain = "";
+ }
+ } else {
+ for (String compositeURI : getNode().getDeployedCompostes(curi)) {
+ getNode().removeFromDomainLevelComposite(curi, compositeURI);
+ }
+ }
+ }
+ return true;
+ }
+
+ public boolean bye() {
+ for (Node node : nodes.values()) {
+ node.stop();
+ }
+ factory.stop();
+ for (Node node : standaloneNodes.values()) {
+ node.stop();
+ }
+ return false;
+ }
+
+ boolean start(String curi, String compositeURI) throws ActivationException, ValidationException {
+ Contribution c = getNode().getInstalledContribution(curi);
+ for (Artifact a : c.getArtifacts()) {
+ if (compositeURI.equals(a.getURI())) {
+ getNode().addToDomainLevelComposite(curi, compositeURI);
+ return true;
+ }
+ }
+ // external composite file ('composite by value')
+ try {
+ URL url = IOHelper.getLocationAsURL(compositeURI);
+ InputStream is = IOHelper.openStream(url);
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ getNode().addDeploymentComposite(curi, br);
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+
+ return true;
+ }
+
+ boolean start(String nodeName, String compositeURI, String contributionURL, String... dependentContributionURLs)
+ throws ActivationException, ValidationException {
+ Node node = NodeFactory.newStandaloneNode(compositeURI, contributionURL, dependentContributionURLs);
+ standaloneNodes.put(nodeName, node);
+ return true;
+ }
+
+ boolean status(final List<String> toks) {
+ if (standaloneNodes.size() > 0) {
+ out.println("Standalone Nodes:");
+ for (String nodeName : standaloneNodes.keySet()) {
+ Node node = standaloneNodes.get(nodeName);
+ for (String curi : node.getInstalledContributions()) {
+ for (String dc : node.getDeployedCompostes(curi)) {
+ out.println(" " + nodeName + " " + dc);
+ }
+ }
+ }
+ out.println();
+ }
+ if (nodes.size() > 0) {
+ for (Node node : nodes.values()) {
+ out.println("Domain: " + node.getDomainName());
+ List<String> ics;
+ if (toks.size() > 1) {
+ ics = new ArrayList<String>();
+ ics.add(toks.get(1));
+ } else {
+ ics = node.getInstalledContributions();
+ }
+
+ for (String curi : ics) {
+ Contribution c = node.getInstalledContribution(curi);
+ List<String> dcs = node.getDeployedCompostes(curi);
+ if (toks.size() > 2) {
+ dcs = new ArrayList<String>();
+ dcs.add(toks.get(2));
+ } else {
+ dcs = node.getDeployedCompostes(curi);
+ }
+ for (String compositeUri : dcs) {
+ for (Artifact a : c.getArtifacts()) {
+ if (compositeUri.equals(a.getURI())) {
+ out.println(" " + curi
+ + " "
+ + compositeUri
+ + " "
+ + ((Composite)a.getModel()).getName());
+ }
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ boolean history() {
+ for (String l : history)
+ out.println(l);
+ return true;
+ }
+
+ public Node getNode() {
+ return nodes.get(currentDomain);
+ }
+
+ List<String> read(Object r) throws IOException {
+ out.print(currentDomain + "> ");
+ final String l;
+ if (useJline) {
+ l = JLine.readLine(r);
+ } else {
+ l = ((BufferedReader)r).readLine();
+ history.add(l);
+ }
+ String[] toks = l != null ? l.trim().split(" ") : "bye".split(" ");
+ List<String> toksList = new ArrayList<String>();
+ for (String s : toks) {
+ if (s != null && s.trim().length() > 0) {
+ toksList.add(s);
+ }
+ }
+ return toksList;
+ }
+
+ Callable<Boolean> eval(final List<String> toks) {
+ final String op = toks.size() > 0 ? toks.get(0) : "";
+
+ if (op.equalsIgnoreCase("domain"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return domain(toks.size() > 1 ? toks.get(1) : "");
+ }
+ };
+ if (op.equalsIgnoreCase("install"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return install(toks);
+ }
+ };
+ if (op.equalsIgnoreCase("installed"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return installed(toks);
+ }
+ };
+ if (op.equalsIgnoreCase("printDomainLevelComposite"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return printDomainLevelComposite();
+ }
+ };
+ if (op.equalsIgnoreCase("getQNameDefinition"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return getQNameDefinition(toks.get(1), toks.get(2), toks.get(3));
+ }
+ };
+ if (op.equalsIgnoreCase("remove"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return remove(toks.get(1));
+ }
+ };
+ if (op.equalsIgnoreCase("help"))
+ return new Callable<Boolean>() {
+ public Boolean call() {
+ return help(toks);
+ }
+ };
+ if (op.equalsIgnoreCase("stop"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return stop(toks);
+ }
+ };
+ if (op.equalsIgnoreCase("bye"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return bye();
+ }
+ };
+ if (op.equalsIgnoreCase("start"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ if (currentDomain.length() > 0) {
+ return start(toks.get(1), toks.get(2));
+ } else {
+ String[] duris = null;
+ if (toks.contains("-duris")) {
+ int i = toks.indexOf("-duris");
+ duris = toks.get(i + 1).split(",");
+ toks.remove(i); toks.remove(i+1);
+ }
+ String name = toks.get(1);
+ String contributionURL;
+ String compositeURI;
+ if (toks.size() > 3) {
+ compositeURI = toks.get(2);
+ contributionURL = toks.get(3);
+ } else {
+ compositeURI = null;
+ contributionURL = toks.get(2);
+ }
+ return start(name, compositeURI, contributionURL, duris);
+ }
+ }
+ };
+ if (op.equalsIgnoreCase("status"))
+ return new Callable<Boolean>() {
+ public Boolean call() {
+ return status(toks);
+ }
+ };
+ if (op.equalsIgnoreCase("history"))
+ return new Callable<Boolean>() {
+ public Boolean call() {
+ return history();
+ }
+ };
+ if (op.equalsIgnoreCase(""))
+ return new Callable<Boolean>() {
+ public Boolean call() {
+ return true;
+ }
+ };
+ return new Callable<Boolean>() {
+ public Boolean call() {
+ out.println("unknown command");
+ return true;
+ }
+ };
+ }
+
+ boolean apply(final Callable<Boolean> func) {
+ try {
+ return func.call();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return true;
+ }
+ }
+
+ public void run() throws IOException {
+ help(null);
+ Object reader;
+ if (useJline) {
+ reader = JLine.createJLineReader(this);
+ } else {
+ reader = new BufferedReader(new InputStreamReader(in));
+ }
+ while (apply(eval(read(reader))))
+ ;
+ }
+
+ boolean help(List<String> toks) {
+ String command = (toks == null || toks.size() < 2) ? null : toks.get(1);
+ if (command == null) {
+ helpOverview();
+ } else if ("help".equalsIgnoreCase(command)) {
+ helpHelp();
+ } else if ("install".equalsIgnoreCase(command)) {
+ helpInstall();
+ } else if ("installed".equalsIgnoreCase(command)) {
+ helpInstalled();
+ } else if ("remove".equalsIgnoreCase(command)) {
+ helpRemove();
+ } else if ("printDomainLevelComposite".equalsIgnoreCase(command)) {
+ helpPrintDomainLevelComposite();
+ } else if ("start".equalsIgnoreCase(command)) {
+ helpStart();
+ } else if ("status".equalsIgnoreCase(command)) {
+ helpStatus();
+ } else if ("stop".equalsIgnoreCase(command)) {
+ helpStop();
+ } else if ("startup".equalsIgnoreCase(command)) {
+ helpStartUp();
+ } else if ("bye".equalsIgnoreCase(command)) {
+ helpBye();
+ }
+ return true;
+ }
+
+ boolean helpOverview() {
+ out.println("Apache Tuscany Shell (" + Version.getVersion()
+ + " "
+ + Version.getRevsion()
+ + " "
+ + Version.getBuildTime()
+ + ")");
+ out.println("Commands:");
+ out.println();
+ out.println(" help");
+ out.println(" domain <domainURI>");
+ out.println(" install [<uri>] <contributionURL> [-norun -metadata <url> -duris <uri,uri,...>]");
+ out.println(" installed [<contributionURI>]");
+ out.println(" remove <contributionURI>");
+ out.println(" printDomainLevelComposite");
+ out.println(" start <curi> <compositeUri>|<contentURL>");
+ out.println(" start <name> [<compositeUri>] <contributionURL> [-duris <uri,uri,...>]");
+ out.println(" status [<curi> <compositeUri>]");
+ out.println(" stop [<curi> <compositeUri>]");
+ out.println(" bye");
+ out.println();
+ if (useJline)
+ out.println("Use Tab key for command and argument completion");
+ out.println("For detailed help on each command do 'help <command>', for help of startup options do 'help startup'");
+ out.println();
+ return true;
+ }
+
+ void helpHelp() {
+ out.println(" help [<command>]");
+ out.println();
+ out.println(" Outputs help on the Tuscany Shell");
+ out.println(" If the command argument is used it provides detailed help on that command otherwise");
+ out.println(" it provides an overview of available Shell commands");
+ out.println();
+ out.println(" To get help on starting the Tuscany Shell use 'help startup'");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" <command> - (optional) the command to get detailed help on");
+ }
+
+ void helpDomain() {
+ out.println(" domain [<domainURI>]");
+ out.println();
+ out.println(" Starts or connects to a domain for the given domain URI.");
+ out.println(" If no domain URI is specified switch to standalone mode.");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" <domainURI> - (optional) the domain URI of the domain");
+ }
+
+ void helpInstall() {
+ out.println(" install [<uri>] <contributionURL> [-norun -metadata <url> -duris <uri,uri,...>]");
+ out.println();
+ out.println(" Creates an installed contribution with a supplied root contribution, installed at abase URI.");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" uri - (optional) the URI (name) to use for the contribution. When no uri is specified");
+ out.println(" a default URI is used derived from the contribution URL");
+ out.println(" contributionURL - (required) the URL to the contribution to install");
+ out.println(" -norun - (optional) do not start any composites listed as deployable in the sca-contribution.xml file");
+ out.println(" -metadata <url> - (optional) the URL to an external contribution meta data document that should be");
+ out.println(" merged into any existing sca-contributions.xml file within the contribution.");
+ out.println(" -duris <uri,uri,...> - (optional) specifies the URIs of contributions that are used to resolve the");
+ out.println(" dependencies of the root contribution and other dependent contributions.");
+ out.println(" When not specified all installed contributions are used to resolve dependencies.");
+ }
+
+ void helpInstalled() {
+ out.println(" installed [<contributionURI>]");
+ out.println();
+ out.println(" Shows information about the contributions installed on this node,");
+ out.println(" including the contribution URI and location along with the URI");
+ out.println(" and QName of any composites within the contribution");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" contributionURI - (optional) the URI of an installed contribution");
+ }
+
+ void helpRemove() {
+ out.println(" remove <contributionURI>");
+ out.println();
+ out.println(" Removes an installed contribution");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" contributionURI - (required) the URI of an installed contribution");
+ }
+
+ void helpPrintDomainLevelComposite() {
+ out.println(" printDomainLevelComposite");
+ out.println();
+ out.println(" Not yet implemented");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" none");
+ }
+
+ void helpStart() {
+ out.println(" start <curi> <compositeUri>|<contentURL>");
+ out.println(" start <name> [<compositeUri>] <contributionURL> [-duris <uri,uri,...>]");
+ out.println();
+ out.println(" Starts a composite.");
+ out.println(" The composite is added to the domain composite with semantics that correspond to the domain-level");
+ out.println(" composite having an <include> statement that references the supplied composite. All of the composites");
+ out.println(" components become top-level components and the component services become externally visible");
+ out.println(" services (eg. they would be present in a WSDL description of the Domain).");
+ out.println();
+ out.println(" The second form of the start command starts in standalone mode not part of any SCA domain.");
+ out.println();
+ out.println(" Arguments (form1):");
+ out.println(" curi - (required) the URI of an installed contribution");
+ out.println(" compositeUri or contentURL - (required) either the URI of a composite within the contribution");
+ out.println(" or a URL to an external composite file.");
+ out.println(" Arguments (form2):");
+ out.println(" name - (required) a name for the started composite/contribution");
+ out.println(" compositeUri - (optional) the URI of a composite within the contribution");
+ out.println(" contributionURL - (required) the URL to the contribution");
+ out.println(" -duris <uri,uri,...> - (optional) specifies the URIs of contributions that are used to resolve the");
+ out.println(" dependencies of the root contribution and other dependent contributions.");
+ }
+
+ void helpStatus() {
+ out.println(" status [<curi> <compositeUri>]");
+ out.println();
+ out.println(" Shows the status of the Node, listing for each deployed composite its");
+ out.println(" contribution URI, the composite URI, and the composite QName.");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" curi - (optional) the URI of an installed contribution");
+ out.println(" compositeUri - (optional) the URI of a composite");
+ }
+
+ void helpStop() {
+ out.println(" stop <curi> [<compositeUri>]");
+ out.println(" stop <name>");
+ out.println();
+ out.println(" Stops a domain or standalone node or individual composites and contributions in a Domain.");
+ out.println(" If a composite URI is specified then the composite is removed from the Domain Level composite");
+ out.println(" This means that the removal of the components, wires, services and references originally added");
+ out.println(" to the domain level composite by the identified composite. If a contribution URI is specified");
+ out.println(" without a composite URI then all deployed composites composites in the contribution are stopped.");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" curi - (required) the URI of an installed contribution");
+ out.println(" compositeUri - (optional) the URI of a composite");
+ out.println(" name - (required) the name of a standalon node or domain to stop");
+ }
+
+ void helpBye() {
+ out.println(" bye");
+ out.println();
+ out.println(" All deployed composites are stopped and the Shell exists.");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" none");
+ }
+
+ void helpStartUp() {
+ out.println(" Tuscany Shell StartUp Options ");
+ out.println();
+ out.println(" When starting the Tuscany Shell there are optional arguments that can configure the Shell.");
+ out.println();
+ out.println(" Arguments:");
+ out.println(" <domainURI> (optional) the URI of the domain.");
+ out.println(" When the domainURI is a simple string then the Shell starts a standalone");
+ out.println(" Node using the string as the domain name or 'default' if no name is specified.");
+ out.println(" When the domainURI starts with 'uri:' the Shell starts a distributed Node ");
+ out.println(" and the URI can encode parameters to configure the domain as follows:");
+ out.println(" uri:<domainName?key1=value1&key2=value2&...");
+ out.println(" The keys are optional and some keys are:");
+ out.println(" bind=ip[:port] - defines the local bind address and port, if the port is not specified it");
+ out.println(" defaults 14820 and if that port in use it will try incrementing by one till a free port is found.");
+ out.println(" multicast=groupip:port | off - defines if multicast discovery is used and if so what multicast IP group and port is used.");
+ out.println(" It defaults to 224.5.12.10:51482. A value of 'off' means multicast is disabled.");
+ out.println(" wka=ip[:port] - a comma separated list of ip address and port for remote nodes in");
+ out.println(" the domain group when multicast is not available. The port defaults to 14820.");
+ out.println(" userid= is the userid other nodes must use to connect to this domain group. The default is the default domain name.");
+ out.println(" password= is the password other nodes must use to connect to this domain group. The default is 'tuscany'.");
+ out.println();
+ out.println(" -nojline (optional) use plain Java System.in/out instead of JLine");
+ out.println(" (no tab completion or advanced line editing will be available)");
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/CompositeURICompletor.java b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/CompositeURICompletor.java
new file mode 100644
index 0000000000..c07c3acaee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/CompositeURICompletor.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.shell.jline;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import jline.SimpleCompletor;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.shell.Shell;
+
+/**
+ * A Completor that uses the composite URIs within a Contribution
+ * Will only work if the argument before the composite URI is a contribution URI
+ */
+public class CompositeURICompletor extends SimpleCompletor {
+
+ private Shell shell;
+
+ public CompositeURICompletor(Shell shell) {
+ super("");
+ this.shell = shell;
+ }
+
+ @Override
+ public int complete(final String buffer, final int cursor, final List clist) {
+ if (shell.getNode() == null) {
+ return -1;
+ }
+ Contribution c = shell.getNode().getInstalledContribution(getContributionURI());
+ if (c == null) {
+ return -1;
+ }
+
+ List<String> cus = new ArrayList<String>();
+ for (Artifact a : c.getArtifacts()) {
+ if (a.getModel() instanceof Composite) {
+ cus.add(((Composite)a.getModel()).getURI());
+ }
+ }
+ setCandidateStrings(cus.toArray(new String[cus.size()]));
+ return super.complete(buffer, cursor, clist);
+ }
+
+ protected String getContributionURI() {
+ /* A little hacky to use a static but i can't see how else to get the contribution URI */
+ return TShellCompletor.lastArg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ICURICompletor.java b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ICURICompletor.java
new file mode 100644
index 0000000000..b197bc9b37
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ICURICompletor.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.shell.jline;
+
+import java.util.List;
+
+import jline.SimpleCompletor;
+
+import org.apache.tuscany.sca.shell.Shell;
+
+/**
+ * An Installed Contribution URI Completor
+ */
+public class ICURICompletor extends SimpleCompletor {
+
+ private Shell shell;
+
+ public ICURICompletor(Shell shell) {
+ super("");
+ this.shell = shell;
+ }
+
+ @Override
+ public int complete(final String buffer, final int cursor, final List clist) {
+ if (shell.getNode() != null) {
+ List<String> ics = shell.getNode().getInstalledContributions();
+ setCandidateStrings(ics.toArray(new String[ics.size()]));
+ }
+ return super.complete(buffer, cursor, clist);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/JLine.java b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/JLine.java
new file mode 100644
index 0000000000..e8fcd627e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/JLine.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.shell.jline;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.LinkedList;
+import java.util.List;
+
+import jline.Completor;
+import jline.ConsoleReader;
+
+import org.apache.tuscany.sca.shell.Shell;
+
+/**
+ * Keep all the JLine specific code out of the Shell class so that it runs ok
+ * when jline isn't on the classpath.
+ */
+public class JLine {
+
+ public static String readLine(Object r) throws IOException {
+ return ((ConsoleReader)r).readLine();
+ }
+
+ public static Object createJLineReader(final Shell shell) throws IOException {
+ ConsoleReader reader = new ConsoleReader();
+ fixCtrlC(reader);
+ // Add a Ctrl-c listener
+ reader.addTriggeredAction((char)3, new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ shell.bye();
+ System.exit(0);
+ }
+ });
+ reader.setBellEnabled(false);
+ // TODO: write a Completor specific to this that can handle the individual command arguments
+ List<Completor> completors = new LinkedList<Completor>();
+// completors.add(new SimpleCompletor(Shell.COMMANDS));
+// completors.add(new ICURICompletor(shell.node));
+// completors.add(new FileNameCompletor());
+// reader.addCompletor(new ArgumentCompletor(completors));
+ reader.addCompletor(new TShellCompletor(shell));
+ return reader;
+ }
+
+ /**
+ * The windowsbindings.properties shipped inside jline maps ctrl-c to INSERT
+ * with the comment "(frankly, I wasn't sure where to bind this)". That does not
+ * seem a great choice as it disables ctrl-c interupt so this resets that binding.
+ */
+ private static void fixCtrlC(ConsoleReader reader) {
+ try {
+ Field f = ConsoleReader.class.getDeclaredField("keybindings");
+ f.setAccessible(true);
+ short[] keybindings = (short[])f.get(reader);
+ if (keybindings[3] == -48) keybindings[3] = 3;
+ } catch (Exception e) {
+ e.printStackTrace(); // shouldnt happen
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/TShellCompletor.java b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/TShellCompletor.java
new file mode 100644
index 0000000000..64d5613cab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/TShellCompletor.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.shell.jline;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import jline.ArgumentCompletor;
+import jline.Completor;
+import jline.ConsoleReader;
+import jline.FileNameCompletor;
+import jline.NullCompletor;
+import jline.SimpleCompletor;
+
+import org.apache.tuscany.sca.shell.Shell;
+
+/**
+ * A Completor thats specific to the Tuscany Shell that knows about
+ * each command and has an argument specific Completor for each command argument.
+ */
+public class TShellCompletor extends ArgumentCompletor {
+
+ Map<String, Completor[]> completors;
+ final Completor commandCompletor = new SimpleCompletor(Shell.COMMANDS);
+ final ArgumentDelimiter delim = new WhitespaceArgumentDelimiter();
+ final Shell shell;
+
+ static String lastArg;
+
+ public TShellCompletor(Shell shell) {
+ super((Completor)null);
+ this.shell = shell;
+ completors = new HashMap<String, Completor[]>();
+ completors.put("help", new Completor[]{commandCompletor, commandCompletor, new NullCompletor()});
+// completors.put("install", new Completor[]{commandCompletor, new InstallCompletor(), new NullCompletor()});
+ completors.put("install", new Completor[]{commandCompletor, new FileNameCompletor(), new FileNameCompletor(), new NullCompletor()});
+ completors.put("installed", new Completor[]{commandCompletor, new ICURICompletor(shell), new NullCompletor()});
+ completors.put("remove", new Completor[]{commandCompletor, new ICURICompletor(shell), new NullCompletor()});
+ completors.put("addDeploymentComposite", new Completor[]{commandCompletor, new ICURICompletor(shell), new FileNameCompletor(), new NullCompletor()});
+ completors.put("printDomainLevelComposite", new Completor[]{commandCompletor, new NullCompletor()});
+ completors.put("start", new Completor[]{commandCompletor, new ICURICompletor(shell), new CompositeURICompletor(shell), new NullCompletor()});
+ completors.put("status", new Completor[]{commandCompletor, new ICURICompletor(shell), new CompositeURICompletor(shell), new NullCompletor()});
+ completors.put("stop", new Completor[]{commandCompletor, new ICURICompletor(shell), new CompositeURICompletor(shell), new NullCompletor()});
+ }
+
+ @Override
+ /**
+ * Copied from JLine ArgumentCompletor class. The only change is to
+ * get the completors by using the getCompletors method and setting the lastArg static.
+ */
+ public int complete(final String buffer, final int cursor,
+ final List candidates) {
+ ArgumentList list = delim.delimit(buffer, cursor);
+ int argpos = list.getArgumentPosition();
+ int argIndex = list.getCursorArgumentIndex();
+
+ if (argIndex < 0) {
+ return -1;
+ }
+
+ if (argIndex > 0) {
+ /* set the last argument in a static for the CompositeURICompletor */
+ lastArg = list.getArguments()[argIndex-1];
+ if (lastArg != null) lastArg = lastArg.trim();
+ }
+
+ final Completor comp;
+
+ Completor[] completors = getCompletors(buffer);
+
+ // if we are beyond the end of the completors, just use the last one
+ if (argIndex >= completors.length) {
+ comp = completors[completors.length - 1];
+ } else {
+ comp = completors[argIndex];
+ }
+
+ // ensure that all the previous completors are successful before
+ // allowing this completor to pass (only if strict is true).
+ for (int i = 0; getStrict() && (i < argIndex); i++) {
+ Completor sub =
+ completors[(i >= completors.length) ? (completors.length - 1) : i];
+ String[] args = list.getArguments();
+ String arg = ((args == null) || (i >= args.length)) ? "" : args[i];
+
+ List subCandidates = new LinkedList();
+
+ if (sub.complete(arg, arg.length(), subCandidates) == -1) {
+ return -1;
+ }
+
+ if (subCandidates.size() == 0) {
+ return -1;
+ }
+ }
+
+ int ret = comp.complete(list.getCursorArgument(), argpos, candidates);
+
+ if (ret == -1) {
+ return -1;
+ }
+
+ int pos = ret + (list.getBufferPosition() - argpos);
+
+ /**
+ * Special case: when completing in the middle of a line, and the
+ * area under the cursor is a delimiter, then trim any delimiters
+ * from the candidates, since we do not need to have an extra
+ * delimiter.
+ *
+ * E.g., if we have a completion for "foo", and we
+ * enter "f bar" into the buffer, and move to after the "f"
+ * and hit TAB, we want "foo bar" instead of "foo bar".
+ */
+ if ((cursor != buffer.length()) && delim.isDelimiter(buffer, cursor)) {
+ for (int i = 0; i < candidates.size(); i++) {
+ String val = candidates.get(i).toString();
+
+ while ((val.length() > 0)
+ && delim.isDelimiter(val, val.length() - 1)) {
+ val = val.substring(0, val.length() - 1);
+ }
+
+ candidates.set(i, val);
+ }
+ }
+
+ ConsoleReader.debug("Completing " + buffer + "(pos=" + cursor + ") "
+ + "with: " + candidates + ": offset=" + pos);
+
+ return pos;
+ }
+
+ protected Completor[] getCompletors(String buffer) {
+ StringBuilder sb = new StringBuilder();
+ for (int i=0; i<buffer.length(); i++) {
+ if (Character.isWhitespace(buffer.charAt(i))) {
+ break;
+ }
+ sb.append(buffer.charAt(i));
+ }
+ String command = sb.toString();
+ Completor[] comps = completors.get(command);
+ return comps == null ? new Completor[]{commandCompletor} : comps;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/stripes/LICENSE b/sandbox/sebastien/java/embed/modules/stripes/LICENSE
new file mode 100644
index 0000000000..c77d3fe856
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/stripes/LICENSE
@@ -0,0 +1,241 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+The module host-webapp includes files under the following license:
+
+Permission to copy, display and distribute the Service Component Architecture Specification and/or
+portions thereof, without modification, in any medium without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the Service Component Architecture Specification, or
+portions thereof, that you make:
+
+1. A link or URL to the Service Component Architecture Specification at this location:
+· http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of the copyright notice as shown in the Service Component Architecture Specification.
+
+BEA, Cape Clear, IBM, Interface21, IONA, Oracle, Primeton, Progress Software, Red Hat, Rogue Wave,
+SAP, Siemens, Software AG., Sun, Sybase, TIBCO (collectively, the "Authors") agree to grant you a
+royalty-free license, under reasonable, non-discriminatory terms and conditions to patents that they deem
+necessary to implement the Service Component Architecture Specification.
+THE Service Component Architecture SPECIFICATION IS PROVIDED "AS IS," AND THE
+AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+REGARDING THIS SPECIFICATION AND THE IMPLEMENTATION OF ITS CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR
+DISTRIBUTION OF THE Service Components Architecture SPECIFICATION.
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+
diff --git a/sandbox/sebastien/java/embed/modules/stripes/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/stripes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f77fd60d0d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/stripes/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Stripes Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Stripes
+Import-Package: javax.naming,
+ javax.servlet,
+ javax.servlet.http,
+ javax.servlet.jsp,
+ javax.servlet.jsp.tagext,
+ net.sourceforge.stripes;version="1.5.2",
+ net.sourceforge.stripes.action;version="1.5.2",
+ net.sourceforge.stripes.config;version="1.5.2",
+ net.sourceforge.stripes.controller;version="1.5.2",
+ net.sourceforge.stripes.exception;version="1.5.2",
+ net.sourceforge.stripes.util;version="1.5.2",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.host.webapp;version="2.0.0",
+ org.apache.tuscany.sca.implementation.web.runtime.utils;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.stripes
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/stripes/NOTICE b/sandbox/sebastien/java/embed/modules/stripes/NOTICE
new file mode 100644
index 0000000000..dfde08644b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/stripes/NOTICE
@@ -0,0 +1,12 @@
+${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 also includes software under the Service Component Architecture specification license
+(see the LICENSE file contained in this distribution) with the following copyright
+
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/stripes/pom.xml b/sandbox/sebastien/java/embed/modules/stripes/pom.xml
new file mode 100644
index 0000000000..114abd4721
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/stripes/pom.xml
@@ -0,0 +1,60 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-stripes</artifactId>
+ <name>Apache Tuscany SCA Stripes Web Framework Integration</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.stripes</groupId>
+ <artifactId>stripes</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyHelper.java b/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyHelper.java
new file mode 100644
index 0000000000..f4d7f48dae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyHelper.java
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.stripes;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.servlet.ServletContext;
+
+import net.sourceforge.stripes.action.ActionBeanContext;
+import net.sourceforge.stripes.controller.StripesFilter;
+import net.sourceforge.stripes.exception.StripesRuntimeException;
+import net.sourceforge.stripes.util.Log;
+import net.sourceforge.stripes.util.ReflectUtil;
+
+import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * <p>Static helper class that is used to lookup SCA references and inject them into objects
+ * (often ActionBeans). Is capable of injecting references through setter methods (property access)
+ * and also through direct field access if the security policy allows it. Methods and fields
+ * must be annotated using the SCA {@code @Reference} annotation.</p>
+ *
+ * <p>Methods and fields may be public, protected, package-access or private. If they are not
+ * public an attempt is made to call {@link Method#setAccessible(boolean)} in order to make
+ * them accessible from this class. If the attempt fails, an exception will be thrown.</p>
+ *
+ * <p>Method names can take any form. For example {@code setSomeBean(Bean b)} or
+ * {@code someBean(bean b)}. In both cases, if a specific Reference name is not supplied,
+ * the default name of {@code someBean} will be used.</p>
+ *
+ * <p>The value of the {@code @Reference} annotation should be the reference on the
+ * SCA component with an {@code <implementation.web>} componentType.
+ *
+ * <p>The first time that any of the injection methods in this class is called with a specific type
+ * of object, the object's class is examined for annotated fields and methods. The discovered
+ * fields and methods are then cached for future usage.</p>
+ *
+ * Created for Tuscany from the Stripes SpringHelper written by Dan Hayes and Tim Fennell
+ */
+public class TuscanyHelper {
+ private static final Log log = Log.getInstance(TuscanyHelper.class);
+
+ /** Lazily filled in map of Class to methods annotated with Reference. */
+ private static Map<Class<?>, Collection<Method>> methodMap =
+ new ConcurrentHashMap<Class<?>, Collection<Method>>();
+
+ /** Lazily filled in map of Class to fields annotated with Reference. */
+ private static Map<Class<?>, Collection<Field>> fieldMap =
+ new ConcurrentHashMap<Class<?>, Collection<Field>>();
+
+ /**
+ * Injects SCA References using the ComponentContext that is
+ * derived from the ServletContext, which is in turn looked up using the
+ * ActionBeanContext.
+ *
+ * @param bean the object into which to inject SCA reference
+ * @param context the ActionBeanContext represented by the current request
+ */
+ public static void injectBeans(Object bean, ActionBeanContext context) {
+ injectBeans(bean, StripesFilter.getConfiguration().getServletContext());
+ }
+
+ /**
+ * Looks for all methods and fields annotated with {@code @Reference} and attempts
+ * to lookup and inject a managed bean into the field/property. If any annotated
+ * element cannot be injected an exception is thrown.
+ *
+ * @param bean the bean into which to inject SCA reference
+ * @param ctx the SCA ComponentContext
+ */
+ public static void injectBeans(Object bean, ServletContext ctx) {
+ // First inject any values using annotated methods
+ for (Method m : getMethods(bean.getClass())) {
+ try {
+ Reference scaReference = m.getAnnotation(Reference.class);
+ boolean nameSupplied = !"".equals(scaReference.name());
+ String name = nameSupplied ? scaReference.name() : methodToPropertyName(m);
+ Class<?> beanType = m.getParameterTypes()[0];
+ Object managedBean = findReference(ctx, name, beanType, !nameSupplied);
+ m.invoke(bean, managedBean);
+ }
+ catch (Exception e) {
+ throw new StripesRuntimeException("Exception while trying to lookup and inject " +
+ "an SCA Reference into a bean of type " + bean.getClass().getSimpleName() +
+ " using method " + m.toString(), e);
+ }
+ }
+
+ // And then inject any properties that are annotated
+ for (Field f : getFields(bean.getClass())) {
+ try {
+ Reference scaReference = f.getAnnotation(Reference.class);
+ boolean nameSupplied = !"".equals(scaReference.name());
+ String name = nameSupplied ? scaReference.name() : f.getName();
+ Object managedBean = findReference(ctx, name, f.getType(), !nameSupplied);
+ f.set(bean, managedBean);
+ }
+ catch (Exception e) {
+ throw new StripesRuntimeException("Exception while trying to lookup and inject " +
+ "an SCA Referenceinto a bean of type " + bean.getClass().getSimpleName() +
+ " using field access on field " + f.toString(), e);
+ }
+ }
+ }
+
+ /**
+ * Fetches the methods on a class that are annotated with Reference. The first time it
+ * is called for a particular class it will introspect the class and cache the results.
+ * All non-overridden methods are examined, including protected and private methods.
+ * If a method is not public an attempt it made to make it accessible - if it fails
+ * it is removed from the collection and an error is logged.
+ *
+ * @param clazz the class on which to look for Reference annotated methods
+ * @return the collection of methods with the annotation
+ */
+ protected static Collection<Method> getMethods(Class<?> clazz) {
+ Collection<Method> methods = methodMap.get(clazz);
+ if (methods == null) {
+ methods = ReflectUtil.getMethods(clazz);
+ Iterator<Method> iterator = methods.iterator();
+
+ while (iterator.hasNext()) {
+ Method method = iterator.next();
+ if (!method.isAnnotationPresent(Reference.class)) {
+ iterator.remove();
+ }
+ else {
+ // If the method isn't public, try to make it accessible
+ if (!method.isAccessible()) {
+ try {
+ method.setAccessible(true);
+ }
+ catch (SecurityException se) {
+ throw new StripesRuntimeException(
+ "Method " + clazz.getName() + "." + method.getName() + "is marked " +
+ "with @Reference and is not public. An attempt to call " +
+ "setAccessible(true) resulted in a SecurityException. Please " +
+ "either make the method public or modify your JVM security " +
+ "policy to allow Stripes to setAccessible(true).", se);
+ }
+ }
+
+ // Ensure the method has only the one parameter
+ if (method.getParameterTypes().length != 1) {
+ throw new StripesRuntimeException(
+ "A method marked with @Reference must have exactly one parameter: " +
+ "the bean to be injected. Method [" + method.toGenericString() + "] has " +
+ method.getParameterTypes().length + " parameters."
+ );
+ }
+ }
+ }
+
+ methodMap.put(clazz, methods);
+ }
+
+ return methods;
+ }
+
+ /**
+ * Fetches the fields on a class that are annotated with Refernece. The first time it
+ * is called for a particular class it will introspect the class and cache the results.
+ * All non-overridden fields are examined, including protected and private fields.
+ * If a field is not public an attempt it made to make it accessible - if it fails
+ * it is removed from the collection and an error is logged.
+ *
+ * @param clazz the class on which to look for Reference annotated fields
+ * @return the collection of methods with the annotation
+ */
+ protected static Collection<Field> getFields(Class<?> clazz) {
+ Collection<Field> fields = fieldMap.get(clazz);
+ if (fields == null) {
+ fields = ReflectUtil.getFields(clazz);
+ Iterator<Field> iterator = fields.iterator();
+
+ while (iterator.hasNext()) {
+ Field field = iterator.next();
+ if (!field.isAnnotationPresent(Reference.class)) {
+ iterator.remove();
+ }
+ else if (!field.isAccessible()) {
+ // If the field isn't public, try to make it accessible
+ try {
+ field.setAccessible(true);
+ }
+ catch (SecurityException se) {
+ throw new StripesRuntimeException(
+ "Field " + clazz.getName() + "." + field.getName() + "is marked " +
+ "with @Reference and is not public. An attempt to call " +
+ "setAccessible(true) resulted in a SecurityException. Please " +
+ "either make the field public, annotate a public setter instead " +
+ "or modify your JVM security policy to allow Stripes to " +
+ "setAccessible(true).", se);
+ }
+ }
+ }
+
+ fieldMap.put(clazz, fields);
+ }
+
+ return fields;
+ }
+
+ /**
+ * Looks up an SCA Reference from a ComponentContext. First looks for a bean
+ * with name specified. If no such bean exists, looks for a bean by type. If there is
+ * only one bean of the appropriate type, it is returned. If zero or more than one bean
+ * of the correct type exists, an exception is thrown.
+ *
+ * @param ctx the SCA ComponentContext
+ * @param name the name of the reference to look for
+ * @param type the type of bean to look for
+ * @param allowFindByType true to indicate that finding a bean by type is acceptable
+ * if find by name fails.
+ * @exception RuntimeException various subclasses of RuntimeException are thrown if it
+ * is not possible to find a unique matching bean in the ComponentContext given
+ * the constraints supplied.
+ */
+ protected static Object findReference(ServletContext ctx,
+ String name,
+ Class<?> type,
+ boolean allowFindByType) {
+ // First try to lookup using the name provided
+ Object bean = ContextHelper.getReference(name, type, ctx);
+ if (bean == null) {
+ throw new StripesRuntimeException("no reference defined:" + name);
+ }
+
+ log.debug("Found sca reference with name [", name, "] and type [",
+ bean.getClass().getName(), "]");
+ return bean;
+
+// TODO: Support get by type (sca autowire?)
+
+// // If we got here then we didn't find a bean yet, try by type
+// String[] beanNames = ctx.getBeanNamesForType(type);
+// if (beanNames.length == 0) {
+// throw new StripesRuntimeException(
+// "Unable to find SpringBean with name [" + name + "] or type [" +
+// type.getName() + "] in the Spring application context.");
+// }
+// else if (beanNames.length > 1) {
+// throw new StripesRuntimeException(
+// "Unable to find SpringBean with name [" + name + "] or unique bean with type [" +
+// type.getName() + "] in the Spring application context. Found " + beanNames.length +
+// "beans of matching type.");
+// }
+// else {
+// log.warn("Found unique SpringBean with type [" + type.getName() + "]. Matching on ",
+// "type is a little risky so watch out!");
+// return ctx.getBean(beanNames[0], type);
+// }
+ }
+
+ /**
+ * A slightly unusual, and somewhat "loose" conversion of a method name to a property
+ * name. Assumes that the name is in fact a mutator for a property and will do the
+ * usual {@code setFoo} to {@code foo} conversion if the method follows the normal
+ * syntax, otherwise will just return the method name.
+ *
+ * @param m the method to determine the property name of
+ * @return a String property name
+ */
+ protected static String methodToPropertyName(Method m) {
+ String name = m.getName();
+ if (name.startsWith("set") && name.length() > 3) {
+ String ret = name.substring(3,4).toLowerCase();
+ if (name.length() > 4) ret += name.substring(4);
+ return ret;
+ }
+ else {
+ return name;
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptor.java b/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptor.java
new file mode 100644
index 0000000000..1381266c9e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptor.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.stripes;
+
+import net.sourceforge.stripes.action.Resolution;
+import net.sourceforge.stripes.controller.ExecutionContext;
+import net.sourceforge.stripes.controller.Interceptor;
+import net.sourceforge.stripes.controller.Intercepts;
+import net.sourceforge.stripes.controller.LifecycleStage;
+import net.sourceforge.stripes.util.Log;
+
+
+/**
+ * <p>An {@link Interceptor} that uses the implementation.web ComponentContext to inject reference
+ * proxies into newly created ActionBeans immediately following ActionBeanResolution. For more
+ * information on how the injection is performed see {@link TuscanyHelper#injectBeans(Object,
+ * net.sourceforge.stripes.action.ActionBeanContext)}.</p>
+ *
+ * <p>To configure the TuscanyInterceptor for use you will need to add the following to your
+ * web.xml (assuming no other interceptors are yet configured):</p>
+ *
+ * <pre>
+ * &lt;init-param&gt;
+ * &lt;param-name&gt;Interceptor.Classes&lt;/param-name&gt;
+ * &lt;param-value&gt;
+ * org.apache.tuscany.sca.stripes.TuscanyInterceptor,
+ * net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor
+ * &lt;/param-value&gt;
+ * &lt;/init-param&gt;
+ * </pre>
+ *
+ * <p>If one or more interceptors are already configured in your web.xml simply separate the
+ * fully qualified names of the interceptors with commas (additional whitespace is ok).</p>
+ *
+ * Created for Tuscany from the Stripes SpringInterceptor written by Tim Fennell
+ */
+@Intercepts(LifecycleStage.ActionBeanResolution)
+public class TuscanyInterceptor implements Interceptor {
+ private static final Log log = Log.getInstance(TuscanyInterceptor.class);
+
+ /**
+ * Allows ActionBean resolution to proceed and then once the ActionBean has been
+ * located invokes the {@link TuscanyHelper} to perform SCA reference injection.
+ *
+ * @param context the current execution context
+ * @return the Resolution produced by calling context.proceed()
+ * @throws Exception if the Tuscany injection process produced unrecoverable errors
+ */
+ public Resolution intercept(ExecutionContext context) throws Exception {
+ Resolution resolution = context.proceed();
+ log.debug("Running Tuscany dependency injection for instance of ",
+ context.getActionBean().getClass().getSimpleName());
+ TuscanyHelper.injectBeans(context.getActionBean(), context.getActionBeanContext());
+ return resolution;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptorSupport.java b/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptorSupport.java
new file mode 100644
index 0000000000..4c73f28a08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptorSupport.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.stripes;
+
+import net.sourceforge.stripes.config.ConfigurableComponent;
+import net.sourceforge.stripes.config.Configuration;
+import net.sourceforge.stripes.controller.Interceptor;
+
+import javax.servlet.ServletContext;
+
+/**
+ * <p>Base class for developing Interceptors with dependencies on SCA component references. <b>Not</b>
+ * to be confused with {@link TuscanyInterceptor} which injects SCA reference proxies into
+ * ActionBeans. For example, you may wish to subclass this class in order to write an
+ * interceptor with access to Tuscany ???.</p>
+ *
+ * TODO: does Tuscany really need this?
+ *
+ * <p>Since Interceptors are long-lived objects that are instantiated at application startup
+ * time, and not per-request, the Tuscany wiring takes place in the init() method and happens
+ * only once when the interceptor is first created and initialized.</p>
+ *
+ * Created for Tuscany from the Stripes SpringInterceptorSupport written by Tim Fennell
+ */
+public abstract class TuscanyInterceptorSupport implements Interceptor, ConfigurableComponent {
+
+ /**
+ * Fetches the ServletContext and invokes TuscanyHelper.injectBeans() to auto-wire any
+ * Tuscany dependencies prior to being placed into service.
+ *
+ * @param configuration the Stripes Configuration
+ * @throws Exception if there are problems with the Tuscany configuration/wiring
+ */
+ public void init(Configuration configuration) throws Exception {
+ ServletContext ctx = configuration.getBootstrapPropertyResolver()
+ .getFilterConfig().getServletContext();
+
+ TuscanyHelper.injectBeans(this, ctx);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/LICENSE b/sandbox/sebastien/java/embed/modules/tracing-aspectj/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/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/sebastien/java/embed/modules/tracing-aspectj/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/tracing-aspectj/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c812e3580d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA AOP-based Logging and Tracing
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA AOP-based Logging and Tracing
+Import-Package: org.aspectj.lang;version="1.6.2",
+ org.aspectj.lang.annotation;version="1.6.2"
+Bundle-SymbolicName: org.apache.tuscany.sca.aspectj
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/NOTICE b/sandbox/sebastien/java/embed/modules/tracing-aspectj/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/maven-eclipse.xml b/sandbox/sebastien/java/embed/modules/tracing-aspectj/maven-eclipse.xml
new file mode 100644
index 0000000000..4ceebd71f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/maven-eclipse.xml
@@ -0,0 +1,8 @@
+<project default="copy-resources">
+ <target name="init"/>
+ <target name="copy-resources" depends="init">
+ <copy todir="target/classes/META-INF" filtering="true">
+ <fileset dir="." includes="LICENSE|NOTICE"/>
+ </copy>
+ </target>
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/pom.xml b/sandbox/sebastien/java/embed/modules/tracing-aspectj/pom.xml
new file mode 100644
index 0000000000..0a64e869ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/pom.xml
@@ -0,0 +1,75 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-tracing-aspectj</artifactId>
+ <name>Apache Tuscany SCA AOP-based Logging and Tracing</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.6.8</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ <version>1.6.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <!-- Copy the aspectjweaver jar to avoid surefire problems for directories with space -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ <version>1.6.8</version>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/dependency</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/LoggingAspect.java b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/LoggingAspect.java
new file mode 100644
index 0000000000..2836e90e19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/LoggingAspect.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.aspectj;
+
+import java.util.Arrays;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.AfterThrowing;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+
+/**
+ * LoggingAspect performs standard logging of method signatures, arguments, and
+ * return values. All Tuscany methods, constructors, and statics are logged.
+ * @version $Rev$ $Date$
+ */
+@Aspect
+public class LoggingAspect {
+ @Pointcut("call(* org.apache.tuscany.sca..*(..)) && (!within(org.apache.tuscany.sca.aspectj.*Aspect))")
+ public void anyMethodCall() {
+ }
+
+ @Pointcut("execution(* org.apache.tuscany.sca..*(..)) && (!within(org.apache.tuscany.sca.aspectj.*Aspect))")
+ public void anyMethodExecution() {
+ }
+
+ @Pointcut("call(* java.util.logging.Logger.info(..))")
+ public void anyLogCall() {
+ }
+
+ @Pointcut("cflow(anyMethodExecution()) && anyLogCall()")
+ public void anyLog() {
+ }
+
+ @Pointcut("call(org.apache.tuscany.sca..*.new(..))")
+ public void anyConstructor() {
+ }
+
+ // e.g. org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper
+ @Pointcut("staticinitialization(org.apache.tuscany.sca.implementation..*)")
+ public void anyStatic() {
+ }
+
+ @Before("anyMethodCall()")
+ public void before(JoinPoint jp) {
+ // System.out.println("Logging anyMethodCall before jp=" + jp);
+ // System.out.println("Logging anyMethodCall before jp.getSourceLocation=" + jp.getSourceLocation());
+ // System.out.println("Logging anyMethodCall before jp.getThis=" + jp.getThis());
+ // System.out.println("Logging anyMethodCall before jp.getTarget=" + jp.getTarget());
+ System.out.println("Logging Before anyMethodCall jp.getSignature=" + jp.getSignature());
+ java.lang.Object[] args = jp.getArgs();
+ if (( args != null ) && ( args.length > 0 )) {
+ System.out.println("Logging Before anyMethodCall jp.getArgs=" + Arrays.asList(args));
+ }
+ }
+
+ @AfterReturning(pointcut = "anyMethodCall()", returning = "result")
+ public void afterReturning(JoinPoint jp, Object result) {
+ // Note that result is null for methods with void return.
+ System.out.println("Logging AfterReturning anyMethodCall jp=" + jp + ", result=" + result);
+ }
+
+ @AfterThrowing(pointcut = "anyMethodCall()", throwing = "t")
+ public void afterThrowing(JoinPoint jp, Throwable t) {
+ System.out.println("Logging AfterThrowing anyMethodCall jp=" + jp + ", t=" + t);
+ }
+
+ @Before("anyConstructor()")
+ public void beforeConstructor(JoinPoint jp) {
+ System.out.println("Logging Before anyConstructor jp.getSignature=" + jp.getSignature());
+ java.lang.Object[] args = jp.getArgs();
+ if (( args != null ) && ( args.length > 0 )) {
+ System.out.println("Logging Before anyConstructor jp.getArgs=" + Arrays.asList(args));
+ }
+ }
+
+ @Before("anyStatic()")
+ public void beforeStatic(JoinPoint jp) {
+ System.out.println("Logging Before anyStatic before jp=" + jp);
+ System.out.println("Logging anyMethodCall before jp.getSourceLocation=" + jp.getSourceLocation());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/SimpleTracingAspect.java b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/SimpleTracingAspect.java
new file mode 100644
index 0000000000..83a06a771e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/SimpleTracingAspect.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.sca.aspectj;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+/**
+ * SimpleTraceAspect performs tracing of method signatures, arguments, and
+ * return values. All Tuscany methods, constructors, and statics are traced.
+ *
+ * @version $Rev$ $Date$
+ */
+@Aspect
+public class SimpleTracingAspect extends TracingAspect {
+
+ @Pointcut("execution(public * org.apache.tuscany.sca..*.*(..))")
+ // @Pointcut("call(* org.apache.tuscany.sca..*(..))")
+ protected void entry() {
+ }
+
+ @Pointcut("within(org.apache.tuscany.sca..*) && !within(org.apache.tuscany.sca.aspectj..*Aspect)")
+ protected void withinScope() {
+ }
+
+ @Override
+ protected void startLog() {
+ System.out.println(">>> ----------------------------------------------------");
+ }
+
+ @Override
+ protected void completeLog() {
+ System.out.println("<<< ----------------------------------------------------");
+ }
+
+ @Override
+ protected void logEnter(JoinPoint jp) {
+ System.out.println("> logEnter jp.getSignature=" + jp.getSignature());
+ java.lang.Object[] args = jp.getArgs();
+ if (( args != null ) && ( args.length > 0 )) {
+ // See http://www.eclipse.org/aspectj/doc/released/progguide/pitfalls-infiniteLoops.html
+ // System.out.println("Logging anyMethodCall before jp.getArgs=" + Arrays.asList(args));
+ System.out.print(" logEnter jp.getArgs(" + args.length + ")=[" );
+ for ( int i = 0; i < args.length; i++ ){
+ if ( i > 0 ) System.out.print( ",");
+ System.out.print( args[ i ]);
+ }
+ System.out.println("]" );
+ }
+ }
+
+ @Override
+ protected void logExit(JoinPoint jp, Object result) {
+ // Note that result is null for methods with void return.
+ System.out.println("< logExit jp.getSignature=" + jp.getSignature() +", result=" + result );
+ }
+
+ @Override
+ protected void logThrowable(JoinPoint jp, Throwable throwable) {
+ while ( throwable.getCause() != null )
+ throwable = throwable.getCause();
+ System.out.println("! logThrowable jp.getSignature=" + jp.getSignature() + ", throwable=" + throwable);
+ // System.out.println("! logThowable stackTrace=" );
+ // throwable.printStackTrace( System.out );
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/TimingAspect.java b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/TimingAspect.java
new file mode 100644
index 0000000000..8bde1d4f91
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/TimingAspect.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.sca.aspectj;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+/**
+ * The TimingAspect is used to perform timing metrics on various calls.
+ * The Pointcut "timedCall" is not defined here, but rather in the aop.xml
+ * configuration file. You may provide a point cut to state which type
+ * of call you would like timed and reported in the output files.
+ *
+ * @version $Rev$ $Date$
+ */
+@Aspect
+public abstract class TimingAspect {
+ // Abstract pointcut. Pointcut is defined in aop.xml file.
+ @Pointcut
+ public void timedCall() {
+ }
+
+ @Around("timedCall()")
+ public Object timedSection(ProceedingJoinPoint jp) throws Throwable {
+ System.out.println("Timing Around timedSection jp=" + jp);
+ long start = System.currentTimeMillis();
+ try {
+ return jp.proceed();
+ } finally {
+ long end = System.currentTimeMillis();
+ System.out.println("Timing Around timedSection Roundtrip is " + (end - start) + "ms for jp.getSignature=" + jp.getSignature());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/TracingAspect.java b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/TracingAspect.java
new file mode 100644
index 0000000000..0178ebdb6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/TracingAspect.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.aspectj;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.AfterThrowing;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+
+/**
+ * @version $Rev$ $Date$
+ */
+
+@Aspect
+public abstract class TracingAspect {
+
+ @Pointcut("")
+ protected abstract void entry();
+
+ @Pointcut("")
+ protected abstract void withinScope();
+
+ @Pointcut("call(* java..*.*(..))")
+ protected void exit() {
+ }
+
+ @Pointcut("entry() && !cflowbelow(entry())")
+ void start() {
+ }
+
+ // @Pointcut("withinScope() && cflow(entry()) && !cflow(exit()) && !within(org.apache.tuscany.sca.aspectj.*Aspect) && !within(*.toString)")
+ @Pointcut("withinScope() && entry()")
+ // @Pointcut("withinScope() && entry()&& !cflow(execution(String toString())")
+ void trace() {
+ }
+
+ @Pointcut("!handler(*) && !preinitialization(new(..))")
+ protected void supportsAfterAdvice() {
+ }
+
+ @Before("start()")
+ public void beforeStart() {
+ startLog();
+ }
+
+ @Before("trace() && supportsAfterAdvice()")
+ public void beforeTrace(JoinPoint jp) {
+ logEnter(jp);
+ }
+
+ @AfterReturning(pointcut = "trace() && supportsAfterAdvice()", returning = "result")
+ public void afterReturning(JoinPoint jp, Object result) {
+ logExit(jp, result);
+ }
+
+ @AfterThrowing(pointcut = "trace() && supportsAfterAdvice()", throwing = "e")
+ public void afterThrowing(JoinPoint jp, Throwable e) {
+ logThrowable(jp, e);
+ }
+
+ @After("start()")
+ public void afterStart() {
+ completeLog();
+ }
+
+ protected abstract void logEnter(JoinPoint jp);
+ protected abstract void logExit(JoinPoint jp, Object result);
+ protected abstract void logThrowable(JoinPoint jp, Throwable throwable);
+
+ protected abstract void startLog();
+ protected abstract void completeLog();
+}
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/UserTimingAspect.java b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/UserTimingAspect.java
new file mode 100644
index 0000000000..a60bd0f883
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/java/org/apache/tuscany/sca/aspectj/UserTimingAspect.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.aspectj;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect
+public class UserTimingAspect {
+ @Pointcut
+ public void timedCall() {
+
+ }
+
+ @Around("timedCall()")
+ public Object timedSection(ProceedingJoinPoint jp) throws Throwable {
+ System.out.println("Timing Around timedSection jp=" + jp);
+ long start = System.currentTimeMillis();
+ try {
+ return jp.proceed();
+ } finally {
+ long end = System.currentTimeMillis();
+ System.out.println("Timing Around timedSection Roundtrip is " + (end - start) + "ms for jp.getSignature=" + jp.getSignature());
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/resources/META-INF/aop.xml b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/resources/META-INF/aop.xml
new file mode 100644
index 0000000000..b7f629ff4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/main/resources/META-INF/aop.xml
@@ -0,0 +1,42 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<aspectj>
+
+ <aspects>
+ <!-- Uncomment either of these two aspects to perform standard logging -->
+ <!-- or standard tracing on the Tuscany runtime. -->
+ <aspect name="org.apache.tuscany.sca.aspectj.SimpleTracingAspect" />
+ <aspect name="org.apache.tuscany.sca.aspectj.LoggingAspect" />
+
+ <!-- Following is a concrete-aspect that defines the point cut for -->
+ <!-- the TimingAspect. Which ever calls you define in this pointcut -->
+ <!-- will be timed and displayed in the logs. -->
+ <concrete-aspect name="org.apache.tuscany.sca.aspectj.UserTimingAspect"
+ extends="org.apache.tuscany.sca.aspectj.TimingAspect">
+ <pointcut name="timedCall"
+ expression="call(* java.util.logging.Logger.info(..))"/>
+ </concrete-aspect>
+ </aspects>
+
+ <!--weaver options="-verbose -debug -showWeaveInfo"-->
+ <weaver options="-verbose">
+ <include within="org.apache.tuscany.sca..*" />
+ </weaver>
+
+</aspectj>
diff --git a/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/test/java/org/apache/tuscany/sca/aspectj/TracingTestCase.java b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/test/java/org/apache/tuscany/sca/aspectj/TracingTestCase.java
new file mode 100644
index 0000000000..7b76faaf36
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/tracing-aspectj/src/test/java/org/apache/tuscany/sca/aspectj/TracingTestCase.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.aspectj;
+
+import java.util.logging.Logger;
+
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TracingTestCase {
+
+ @Test
+ public void testAOP() {
+ Logger log = Logger.getLogger(getClass().getName());
+ System.out.println("doSomething()");
+ log.info("Hello, Log");
+ }
+
+ public static void main(String[] args) {
+ new TracingTestCase().testAOP();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/LICENSE b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/LICENSE
new file mode 100644
index 0000000000..422e5f7033
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/LICENSE
@@ -0,0 +1,238 @@
+
+ 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.
+
+
+==========================================================================
+
+dojotoolkit V1.3.0:
+
+The "New" BSD License:
+**********************
+
+Copyright (c) 2005, The Dojo Foundation
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the Dojo Foundation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+================================================================================
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..11eca78a2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Web JavaScript (DOJO)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Web JavaScript
+Import-Package: javax.servlet,
+ javax.servlet.http,
+ javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.http;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.implementation.widget.javascript;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.core.web.javascript.dojo
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
+
+
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/NOTICE b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/NOTICE
new file mode 100644
index 0000000000..55cb8b86a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/NOTICE
@@ -0,0 +1,11 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes dojotoolkit files (http://dojotoolkit.org/) under the
+"New" BSD License (see the LICENSE file contained in this distribution) under the
+following copyright
+ Copyright (c) 2005, The Dojo Foundation. All rights reserved.
+
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/build-dojo.xml b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/build-dojo.xml
new file mode 100644
index 0000000000..3a0c0fd87f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/build-dojo.xml
@@ -0,0 +1,64 @@
+<?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 name="DojoZipInstaller">
+
+
+ <property name="dojo.version" value="1.3.0"/>
+ <property name="dojo.zip" value="${localRepository}/org/dojotoolkit/dojo/${dojo.version}/dojo-${dojo.version}.zip"/>
+ <property name="unpack.location" value="${basedir}/src/main/resources/dojo"/>
+
+
+ <target name="check-dojo-installed">
+ <condition property="already.installed" >
+ <available file="${localRepository}/org/dojotoolkit/dojo/${dojo.version}/dojo-${dojo.version}.zip"/>
+ </condition>
+ </target>
+
+ <target name="check-dojo-unpacked">
+ <condition property="already.unpacked" >
+ <available file="${unpack.location}"/>
+ </condition>
+ </target>
+
+ <target name="unpack-dojo-files" depends="check-dojo-installed, check-dojo-unpacked" unless="already.unpacked">
+ <fail message="dojo zip file not installed in local repository: ${localRepository}" unless="already.installed"/>
+ <mkdir dir="${basedir}/target/dojo-unpack-temp/"/>
+ <unzip src="${localRepository}/org/dojotoolkit/dojo/${dojo.version}/dojo-${dojo.version}.zip"
+ dest="${basedir}/target/dojo-unpack-temp/"
+ overwrite="false"
+ encoding="native-encoding">
+ <patternset>
+ <include name="dojo-${dojo.version}/dojo/**"/>
+ <exclude name="dojo-${dojo.version}/dojo/tests/**"/>
+ <exclude name="dojo-${dojo.version}/dijit/**"/>
+ <exclude name="dojo-${dojo.version}/dojox/**"/>
+ <exclude name="dojo-${dojo.version}/util/**"/>
+ </patternset>
+ </unzip>
+ <move file="${basedir}/target/dojo-unpack-temp/dojo-${dojo.version}"
+ tofile="${unpack.location}"
+ verbose="true"/>
+ <delete dir="${basedir}/target/dojo-unpack-temp/"/>
+ </target>
+
+ <target name="clean-dojo-files">
+ <delete dir="${unpack.location}"/>
+ </target>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/pom.xml b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/pom.xml
new file mode 100644
index 0000000000..f41739a7cb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/pom.xml
@@ -0,0 +1,120 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-web-javascript-dojo</artifactId>
+ <name>Apache Tuscany SCA Web JavaScript for DOJO</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-widget</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.dojotoolkit</groupId>
+ <artifactId>dojo</artifactId>
+ <version>1.3.0</version>
+ <type>zip</type>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version> <!-- to keep compatible with older servlet containers -->
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dojo-files</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant antfile="./build-dojo.xml" target="unpack-dojo-files">
+ <property name="localRepository" value="${settings.localRepository}"/>
+ <property name="artifactId" value="${artifactId}"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ <execution>
+ <id>clean-dojo-files</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant antfile="./build-dojo.xml" target="clean-dojo-files">
+ <property name="localRepository" value="${settings.localRepository}"/>
+ <property name="artifactId" value="${artifactId}"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoResourceServlet.java b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoResourceServlet.java
new file mode 100644
index 0000000000..dad72be5f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoResourceServlet.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.web.javascript.dojo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLDecoder;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.common.http.HTTPConstants;
+import org.apache.tuscany.sca.common.http.HTTPContentTypeMapper;
+import org.apache.tuscany.sca.common.http.HTTPUtil;
+
+
+/**
+ * A Resource servlet used to serve dojo files
+ *
+ * @version $Rev$ $Date$
+ */
+public class DojoResourceServlet extends HttpServlet {
+ private static final long serialVersionUID = -4743631858548812340L;
+
+ public DojoResourceServlet() {
+
+ }
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ String contextRoot = URLDecoder.decode(HTTPUtil.getContextRoot(request), HTTPConstants.CHARACTER_ENCODING_UTF8);
+ String path = URLDecoder.decode(request.getRequestURI(), HTTPConstants.CHARACTER_ENCODING_UTF8);
+
+ if( path.startsWith(contextRoot + "/dojo") ) {
+ if( ! path.contains("tuscany/AtomService.js")) {
+ //this is a workaround where we need to have dojo files in its own folder
+ //to avoid clean target to clean other non dojo resources
+ path = path.substring(contextRoot.length());
+ path = "/dojo" + path;
+ }
+ } else if (path.startsWith(contextRoot)) {
+ path = path.substring(contextRoot.length() + 1);
+ } else if( path.startsWith("/")) {
+ path = path.substring(1);
+ }
+
+ if(response.getContentType() == null || response.getContentType().length() == 0){
+ // Calculate content-type based on extension
+ String contentType = HTTPContentTypeMapper.getContentType(path);
+ if(contentType != null && contentType.length() >0) {
+ response.setContentType(contentType);
+ }
+ }
+
+ response.setCharacterEncoding(HTTPConstants.CHARACTER_ENCODING_UTF8);
+
+ // Write the response from the service implementation to the response
+ // output stream
+ InputStream is = this.getClass().getClassLoader().getResourceAsStream(path);
+ if (is == null) {
+ is = this.getClass().getResourceAsStream(path);
+ }
+ if(is != null) {
+ OutputStream os = response.getOutputStream();
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int n = is.read(buffer);
+ if (n <= 0)
+ break;
+ os.write(buffer, 0, n);
+ }
+ os.flush();
+ os.close();
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoWidgetJavascriptProvider.java b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoWidgetJavascriptProvider.java
new file mode 100644
index 0000000000..e69c2488ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoWidgetJavascriptProvider.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.javascript.dojo;
+
+import java.net.URI;
+import java.util.logging.Logger;
+
+import javax.servlet.Servlet;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
+import org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider;
+
+public class DojoWidgetJavascriptProvider implements WidgetImplementationJavascriptProvider {
+ private final static Logger logger = Logger.getLogger(DojoWidgetJavascriptProvider.class.getName());
+
+ private static final String dojoBaseUri = URI.create("/dojo").toString();
+ private static final String dojoUri = URI.create("/dojo/*").toString();
+
+ private static final String tuscanyBaseUri = URI.create("/tuscany").toString();
+ private static final String tuscanyUri = URI.create("/tuscany/*").toString();
+
+ private static int counter = 0;
+
+ private ServletHost servletHost;
+
+ public DojoWidgetJavascriptProvider(ExtensionPointRegistry registry) {
+ this.servletHost = ServletHostHelper.getServletHost(registry);
+ }
+
+ public void start() {
+
+ if (servletHost == null) {
+ throw new IllegalStateException("Can't find ServletHost reference !");
+ }
+
+ Servlet servlet = null;
+
+ servlet = servletHost.getServletMapping(dojoBaseUri);
+ if(servlet == null) {
+ try {
+ DojoResourceServlet baseResourceServlet = new DojoResourceServlet();
+ servletHost.addServletMapping(dojoBaseUri, baseResourceServlet);
+
+ DojoResourceServlet resourceServlet = new DojoResourceServlet();
+ servletHost.addServletMapping(dojoUri, resourceServlet);
+ } catch (ServletMappingException me ) {
+ logger.warning("Dojo already registered at :" + dojoBaseUri);
+ }
+ }
+
+ servlet = servletHost.getServletMapping(tuscanyBaseUri);
+ if(servlet == null) {
+ try {
+ DojoResourceServlet baseResourceServlet = new DojoResourceServlet();
+ servletHost.addServletMapping(tuscanyBaseUri, baseResourceServlet);
+
+ DojoResourceServlet resourceServlet = new DojoResourceServlet();
+ servletHost.addServletMapping(tuscanyUri, resourceServlet);
+ } catch (ServletMappingException me ) {
+ logger.warning("Tuscany dojo extensions already registered at :" + tuscanyBaseUri);
+ }
+ }
+
+ counter += 1;
+ logger.info("Registered Dojo and Tuscany Dojo extensions (counter=" + counter + ")");
+ }
+
+ public void stop() {
+ if(counter > 0) {
+ counter = counter -= 1;
+ logger.info("Unregistering Dojo and Tuscany Dojo extensions (counter=" + counter + ")");
+ }
+
+ Servlet servlet = servletHost.getServletMapping(dojoBaseUri);
+ if(servlet != null && counter == 0) {
+ servletHost.removeServletMapping(dojoBaseUri);
+ servletHost.removeServletMapping(dojoUri);
+
+ servletHost.removeServletMapping(tuscanyBaseUri);
+ servletHost.removeServletMapping(tuscanyUri);
+ }
+
+ servletHost = null;
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider
new file mode 100644
index 0000000000..70d29a5d86
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider
@@ -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 ModuleActivator
+org.apache.tuscany.sca.web.javascript.dojo.DojoWidgetJavascriptProvider;priority=9999
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/resources/tuscany/AtomService.js b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/resources/tuscany/AtomService.js
new file mode 100644
index 0000000000..7b8943ba3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript-dojo/src/main/resources/tuscany/AtomService.js
@@ -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.
+ */
+dojo.provide("tuscany.AtomService");
+dojo.declare("tuscany.AtomService", null, {
+ url:null,
+ contentType: "application/atom+xml" /*application/atom+json*/,
+ contentHandler: "xml" /*json*/,
+
+ constructor: function(args){
+ //summary:
+ //url : Take a string as a url that points to the atom feed
+ //contentType : Take the contentType to use when retrieving the atom feed
+
+ if(args){
+ var argUrl;
+ var argContentType;
+
+ if( dojo.isArray(args) ) {
+ argUrl = args[0];
+ argContentType = args[1];
+ } else {
+ argUrl = args;
+ }
+
+ //if the arg is a string, we assume it is a url to the atom feed
+ if( (dojo.isString(argUrl)) || (argUrl instanceof dojo._Url)){
+ if (argUrl instanceof dojo._Url){
+ this.url = argUrl + "";
+ }else{
+ this.url = argUrl;
+ }
+ }
+
+ if(argContentType) {
+ if(dojo.isString(argContentType)) {
+ if (argContentType == "application/atom+xml") {
+ this.contentType = argContentType;
+ this.contentHandler = "xml";
+ } else if (argContentType == "application/atom+json") {
+ this.contentType = argContentType;
+ this.contentHandler = "json";
+ }
+ }
+ }
+ }
+ },
+
+ get: function(id /*string*/) {
+ //The parameters to pass to xhrGet, the url, how to handle it, and the callbacks.
+ var xhrArgs = {
+ url: this.url + "/" + id,
+ handleAs: this.contentHandler,
+ headers: {"Accept": this.contentType}
+ };
+
+ //Call the asynchronous xhrGet
+ var deferred = dojo.xhrGet(xhrArgs);
+
+ deferred.addErrback(function(error){
+ alert("An unexpected error occurred: " + error);
+ });
+
+ return deferred;
+ },
+
+
+ post: function( entry /*entry object*/) {
+ //The parameters to pass to xhrGet, the url, how to handle it, and the callbacks.
+ var xhrArgs = {
+ url: this.url,
+ handleAs: this.contentHandler,
+ headers: {"Accept": this.contentType,
+ "Content-Type": this.contentType},
+ postData: entry
+ };
+
+ //Call the asynchronous xhrGet
+ var deferred = dojo.xhrPost(xhrArgs);
+
+ deferred.addErrback(function(error){
+ alert("An unexpected error occurred: " + error);
+ });
+
+ return deferred;
+ },
+
+ put: function(id /*string*/, entry /*entry object*/) {
+ //The parameters to pass to xhrGet, the url, how to handle it, and the callbacks.
+ var xhrArgs = {
+ url: this.url + "/" + id,
+ handleAs: this.contentHandler,
+ headers: {"Accept": this.contentType,
+ "Content-Type": this.contentType},
+ postData: entry
+ };
+
+ //Call the asynchronous xhrGet
+ var deferred = dojo.xhrPut(xhrArgs);
+
+ deferred.addErrback(function(error){
+ alert("An unexpected error occurred: " + error);
+ });
+
+ return deferred;
+ },
+
+ del: function(id /*string*/) {
+ //The parameters to pass to xhrGet, the url, how to handle it, and the callbacks.
+ var xhrArgs = {
+ url: this.url + "/" + id,
+ handleAs: this.contentHandler,
+ headers: {"Accept": this.contentType}
+ };
+
+ //Call the asynchronous xhrGet
+ var deferred = dojo.xhrDelete(xhrArgs);
+
+ deferred.addErrback(function(error){
+ alert("An unexpected error occurred: " + error);
+ });
+
+
+ return deferred;
+ }
+});
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/LICENSE b/sandbox/sebastien/java/embed/modules/web-javascript/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/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/sebastien/java/embed/modules/web-javascript/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/web-javascript/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1bb885ab2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Web JavaScript
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Web JavaScript
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.extensibility,
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.core.web.javascript
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.web.javascript;version="2.0.0"
+
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/NOTICE b/sandbox/sebastien/java/embed/modules/web-javascript/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/pom.xml b/sandbox/sebastien/java/embed/modules/web-javascript/pom.xml
new file mode 100644
index 0000000000..2247174726
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/pom.xml
@@ -0,0 +1,46 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-web-javascript</artifactId>
+ <name>Apache Tuscany SCA Web JavaScript</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/ComponentJavaScriptGenerator.java b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/ComponentJavaScriptGenerator.java
new file mode 100644
index 0000000000..d0576b4468
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/ComponentJavaScriptGenerator.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.web.javascript;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+
+/**
+ * Widget component script generator interface
+ * This generates the necessary JavaScript client code into a single JavaScript per component
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentJavaScriptGenerator {
+
+ /**
+ * Return the QName that identify the Component script generator
+ * This is used to identify different generators supporting different JavaScript frameworks
+ *
+ * @return The QName
+ */
+ QName getQName();
+
+ /**
+ * Generate the Java Script code for a given component
+ * - generate/append client proxyies as needed
+ * - generate tuscany namespace as needed
+ * - generate properties for JavaScript injection
+ * - generate references for JavaScript injection
+ *
+ * @param component The SCA Component to be used
+ * @param pw A Print Writer where the script should be written to
+ * @throws IOException
+ */
+ void generateJavaScriptCode(RuntimeComponent component, PrintWriter pw) throws IOException;
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/ComponentJavaScriptGeneratorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/ComponentJavaScriptGeneratorExtensionPoint.java
new file mode 100644
index 0000000000..ed42ce0e47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/ComponentJavaScriptGeneratorExtensionPoint.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.web.javascript;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Widget component script generator extension pointinterface
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface ComponentJavaScriptGeneratorExtensionPoint {
+
+ /**
+ * Add a component script generator
+ * @param componentScriptGenerator
+ */
+ void addComponentJavaScriptGenerator(ComponentJavaScriptGenerator componentScriptGenerator);
+
+ /**
+ * Remove a component script generator
+ * @param componentScriptGenerator
+ */
+ void removeComponentJavaScriptGenerator(ComponentJavaScriptGenerator componentScriptGenerator);
+
+ /**
+ * Get a component scrpt generator instance based on QName
+ * @param bindingName
+ * @return
+ */
+ ComponentJavaScriptGenerator getComponentJavaScriptGenerator(QName bindingName);
+
+ /**
+ * Get a list of component script generator instances
+ */
+ List<ComponentJavaScriptGenerator> getComponentJavaScriptGenerators();
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/DefaultComponentJavaScriptGeneratorExtensionPoint.java b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/DefaultComponentJavaScriptGeneratorExtensionPoint.java
new file mode 100644
index 0000000000..55326b539e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/DefaultComponentJavaScriptGeneratorExtensionPoint.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.javascript;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+
+
+/**
+ * Default extension point for widget component script generator
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultComponentJavaScriptGeneratorExtensionPoint implements ComponentJavaScriptGeneratorExtensionPoint {
+ private final List<ComponentJavaScriptGenerator> generators = new ArrayList<ComponentJavaScriptGenerator>();
+ private final Map<QName, ComponentJavaScriptGenerator> generatorsByQName = new HashMap<QName, ComponentJavaScriptGenerator>();
+
+ private ExtensionPointRegistry extensionPoints;
+ private Monitor monitor = null;
+
+ private boolean loaded = false;
+
+ public DefaultComponentJavaScriptGeneratorExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ if (monitorFactory != null) {
+ this.monitor = monitorFactory.createMonitor();
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Exception ex) {
+ /*
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ */
+ }
+
+ public void addComponentJavaScriptGenerator(ComponentJavaScriptGenerator componentScriptGenerator) {
+ if (componentScriptGenerator.getQName() != null) {
+ generatorsByQName.put(componentScriptGenerator.getQName(), componentScriptGenerator);
+ }
+
+ generators.add(componentScriptGenerator);
+ }
+
+ public void removeComponentJavaScriptGenerator(ComponentJavaScriptGenerator componentScriptGenerator) {
+ if (componentScriptGenerator.getQName() != null) {
+ generatorsByQName.remove(componentScriptGenerator.getQName());
+ }
+
+ generators.remove(componentScriptGenerator);
+ }
+
+
+ public ComponentJavaScriptGenerator getComponentJavaScriptGenerator(QName bindingName) {
+ loadFactories();
+ return generatorsByQName.get(bindingName);
+ }
+
+ public List<ComponentJavaScriptGenerator> getComponentJavaScriptGenerators() {
+ loadFactories();
+ return this.generators;
+ }
+
+ /**
+ * Private Utility methods
+ */
+
+
+ /**
+ * Lazily load artifact processors registered in the extension point.
+ */
+ @SuppressWarnings("unchecked")
+ private synchronized void loadFactories() {
+ if (loaded) {
+ return;
+ }
+
+ // Get the proxy factories declarations
+ Collection<ServiceDeclaration> factoryDeclarations = null;
+ try {
+ factoryDeclarations = extensionPoints.getServiceDiscovery().getServiceDeclarations(ComponentJavaScriptGenerator.class);
+ } catch (IOException e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ error("IllegalStateException", factoryDeclarations, ie);
+ throw ie;
+ }
+
+ for (ServiceDeclaration processorDeclaration : factoryDeclarations) {
+ // Create a factory, and register it
+ ComponentJavaScriptGenerator generator = null;
+ try {
+ Class generatorClass = processorDeclaration.loadClass();
+
+ Constructor<ComponentJavaScriptGenerator> constructor = generatorClass.getConstructor(ExtensionPointRegistry.class);
+ generator = constructor.newInstance(extensionPoints);
+
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ error("IllegalStateException", generator, ie);
+ throw ie;
+ }
+
+ addComponentJavaScriptGenerator(generator);
+ }
+
+ loaded = true;
+ }
+
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/DefaultJavascriptProxyFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/DefaultJavascriptProxyFactoryExtensionPoint.java
new file mode 100644
index 0000000000..402eb53bb0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/DefaultJavascriptProxyFactoryExtensionPoint.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.web.javascript;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+
+/**
+ * Default extension point for javascript proxy factories
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultJavascriptProxyFactoryExtensionPoint implements JavascriptProxyFactoryExtensionPoint {
+ private final Map<QName, JavascriptProxyFactory> factoriesByQName = new HashMap<QName, JavascriptProxyFactory>();
+ private final Map<Class<?>, JavascriptProxyFactory> factoriesByType = new HashMap<Class<?>, JavascriptProxyFactory>();
+
+ private Monitor monitor = null;
+ private ExtensionPointRegistry registry;
+ private boolean loaded = false;
+
+ public DefaultJavascriptProxyFactoryExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ this.registry = extensionPoints;
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ if (monitorFactory != null) {
+ this.monitor = monitorFactory.createMonitor();
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Exception ex) {
+ /*
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.RESOURCE_BUNDLE,
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ */
+ }
+
+ public void addProxyFactory(JavascriptProxyFactory javascriptProxyfactory) {
+ if (javascriptProxyfactory.getModelType() != null) {
+ factoriesByType.put(javascriptProxyfactory.getModelType(), javascriptProxyfactory);
+ }
+ if (javascriptProxyfactory.getQName() != null) {
+ factoriesByQName.put(javascriptProxyfactory.getQName(), javascriptProxyfactory);
+ }
+ }
+
+ public void removeProxyFactory(JavascriptProxyFactory javascriptProxyfactory) {
+ if (javascriptProxyfactory.getModelType() != null) {
+ factoriesByType.remove(javascriptProxyfactory.getModelType());
+ }
+ if (javascriptProxyfactory.getQName() != null) {
+ factoriesByQName.remove(javascriptProxyfactory.getQName());
+ }
+ }
+
+ public JavascriptProxyFactory getProxyFactory(QName bindingName) {
+ loadFactories();
+ return factoriesByQName.get(bindingName);
+ }
+
+ public JavascriptProxyFactory getProxyFactory(Class<?> bindingType) {
+ loadFactories();
+ Class<?>[] classes = bindingType.getInterfaces();
+ for (Class<?> c : classes) {
+ JavascriptProxyFactory proxyFactory = factoriesByType.get(c);
+ if (proxyFactory != null) {
+ return proxyFactory;
+ }
+ }
+
+ //here we didn't find the proxy factory for the biding
+ JavascriptProxyFactory factory = null;
+ if (bindingType.isInterface()) {
+ // Dynamically load a factory class declared under META-INF/services
+ try {
+ Class<?> factoryClass = registry.getServiceDiscovery().getServiceDeclaration(bindingType).getClass();
+ if (factoryClass != null) {
+
+ try {
+ // Default empty constructor
+ Constructor<?> constructor = factoryClass.getConstructor();
+ factory = (JavascriptProxyFactory) constructor.newInstance();
+ } catch (NoSuchMethodException e) {
+
+ // Constructor taking the model factory extension point
+ Constructor<?> constructor = factoryClass.getConstructor(FactoryExtensionPoint.class);
+ factory = (JavascriptProxyFactory) constructor.newInstance(this);
+ }
+
+ // Cache the loaded factory
+ addProxyFactory(factory);
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+
+ // Call the newInstance static method on the factory abstract class
+ try {
+ factory = (JavascriptProxyFactory) ServiceDiscovery.getInstance().getServiceDeclaration(bindingType);
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ // Cache the factory
+ addProxyFactory(factory);
+ }
+
+ return factory;
+ }
+
+ /**
+ * Private Utility methods
+ */
+
+ /**
+ * Returns a QName object from a QName expressed as {ns}name
+ * or ns#name.
+ *
+ * @param qname
+ * @return
+ */
+ private static QName getQName(String qname) {
+ if (qname == null) {
+ return null;
+ }
+ qname = qname.trim();
+ if (qname.startsWith("{")) {
+ int h = qname.indexOf('}');
+ if (h != -1) {
+ return new QName(qname.substring(1, h), qname.substring(h + 1));
+ }
+ } else {
+ int h = qname.indexOf('#');
+ if (h != -1) {
+ return new QName(qname.substring(0, h), qname.substring(h + 1));
+ }
+ }
+ throw new IllegalArgumentException("Invalid qname: "+qname);
+ }
+
+ /**
+ * Lazily load artifact processors registered in the extension point.
+ */
+ private synchronized void loadFactories() {
+ if (loaded) {
+ return;
+ }
+
+ // Get the proxy factories declarations
+ Collection<ServiceDeclaration> factoryDeclarations = null;
+ try {
+ factoryDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(JavascriptProxyFactory.class);
+ } catch (IOException e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ error("IllegalStateException", factoryDeclarations, ie);
+ throw ie;
+ }
+
+ for (ServiceDeclaration processorDeclaration : factoryDeclarations) {
+ Map<String, String> attributes = processorDeclaration.getAttributes();
+
+ // Load a StAX artifact processor
+
+ // Get the model QName
+ QName artifactType = getQName(attributes.get("qname"));
+
+ // Get the model class name
+ String modelTypeName = attributes.get("model");
+
+ // Create a factory, and register it
+ JavascriptProxyFactory proxyFactory = null;
+ try {
+ proxyFactory = (JavascriptProxyFactory) processorDeclaration.loadClass().newInstance();
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ error("IllegalStateException", proxyFactory, ie);
+ throw ie;
+ }
+
+ addProxyFactory(proxyFactory);
+ }
+
+ loaded = true;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/JavascriptProxyFactory.java b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/JavascriptProxyFactory.java
new file mode 100644
index 0000000000..fda093d9aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/JavascriptProxyFactory.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.web.javascript;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+
+/**
+ * Javascript Proxy Factory used to allow Web related bindings to generate
+ * client js proxyies
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface JavascriptProxyFactory {
+
+ /**
+ * The binding model type associated with this factory
+ * @return the binding model type
+ */
+ Class<?> getModelType();
+
+ /**
+ * The binding qname associated with this factory
+ * @return the binding qname
+ */
+ QName getQName();
+
+ /**
+ * Get the Javascript proxy client file name
+ * @return the javascript file name
+ */
+ String getJavascriptProxyFile();
+
+ /**
+ * Get the Javascript proxy client contents as a stream
+ * @return
+ */
+ InputStream getJavascriptProxyFileAsStream() throws IOException;
+
+ /**
+ * Create any necessary JavaScript imports/headers necessary for the extension to work
+ * This is useful in case of Dojo that need to generate the requires statements to load the dependencies
+ *
+ * @param componentReference
+ * @return
+ * @throws IOException
+ */
+ String createJavascriptHeader(ComponentReference componentReference) throws IOException;
+
+ /**
+ * Create a JavaScript Proxy for a given reference
+ * @param componentReference The reference
+ * @return the javascript proxy code
+ * @throws IOException
+ */
+ String createJavascriptReference(ComponentReference componentReference) throws IOException;
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/JavascriptProxyFactoryExtensionPoint.java b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/JavascriptProxyFactoryExtensionPoint.java
new file mode 100644
index 0000000000..5856c15a9b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/java/org/apache/tuscany/sca/web/javascript/JavascriptProxyFactoryExtensionPoint.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.web.javascript;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ * @tuscany.spi.extension.asclient
+ *
+ */
+public interface JavascriptProxyFactoryExtensionPoint {
+ /**
+ * Add Javascript proxy factory
+ *
+ * @param javascriptProxyfactory The Javascript proxy factory
+ */
+ void addProxyFactory(JavascriptProxyFactory javascriptProxyfactory);
+
+ /**
+ * Remove Javascript proxy factory
+ *
+ * @param javascriptProxyfactory The Javascript proxy fatory
+ */
+ void removeProxyFactory(JavascriptProxyFactory javascriptProxyfactory);
+
+ /**
+ * Returns the Javascript proxy factory associated with the given QName
+ * @param bindingName
+ * @return
+ */
+ JavascriptProxyFactory getProxyFactory(QName bindingName);
+
+ /**
+ * Returns the Javascript proxy factory associated with the given Type
+ * @param bindingType
+ * @return
+ */
+ JavascriptProxyFactory getProxyFactory(Class<?> bindingType);
+}
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGeneratorExtensionPoint b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGeneratorExtensionPoint
new file mode 100644
index 0000000000..6a28e3481d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGeneratorExtensionPoint
@@ -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.web.javascript.DefaultComponentJavaScriptGeneratorExtensionPoint
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactoryExtensionPoint b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactoryExtensionPoint
new file mode 100644
index 0000000000..95a7cecd2b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/META-INF/services/org.apache.tuscany.sca.web.javascript.JavascriptProxyFactoryExtensionPoint
@@ -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.web.javascript.DefaultJavascriptProxyFactoryExtensionPoint
diff --git a/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/web-javascript-validation-messages.properties b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/web-javascript-validation-messages.properties
new file mode 100644
index 0000000000..dbc7317653
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/web-javascript/src/main/resources/web-javascript-validation-messages.properties
@@ -0,0 +1,21 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+IllegalArgumentException = Invalid qname: {0}
diff --git a/sandbox/sebastien/java/embed/modules/wink/LICENSE b/sandbox/sebastien/java/embed/modules/wink/LICENSE
new file mode 100644
index 0000000000..c77d3fe856
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/wink/LICENSE
@@ -0,0 +1,241 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+The module host-webapp includes files under the following license:
+
+Permission to copy, display and distribute the Service Component Architecture Specification and/or
+portions thereof, without modification, in any medium without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the Service Component Architecture Specification, or
+portions thereof, that you make:
+
+1. A link or URL to the Service Component Architecture Specification at this location:
+· http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of the copyright notice as shown in the Service Component Architecture Specification.
+
+BEA, Cape Clear, IBM, Interface21, IONA, Oracle, Primeton, Progress Software, Red Hat, Rogue Wave,
+SAP, Siemens, Software AG., Sun, Sybase, TIBCO (collectively, the "Authors") agree to grant you a
+royalty-free license, under reasonable, non-discriminatory terms and conditions to patents that they deem
+necessary to implement the Service Component Architecture Specification.
+THE Service Component Architecture SPECIFICATION IS PROVIDED "AS IS," AND THE
+AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+REGARDING THIS SPECIFICATION AND THE IMPLEMENTATION OF ITS CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR
+DISTRIBUTION OF THE Service Components Architecture SPECIFICATION.
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+
diff --git a/sandbox/sebastien/java/embed/modules/wink/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/wink/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..3e6c92d183
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/wink/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Wink
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Wink
+Import-Package: javax.servlet,
+ org.apache.wink.common,
+ org.apache.wink.common.internal.registry,
+ org.apache.wink.server.internal,
+ org.apache.wink.server.internal.registry,
+ org.apache.tuscany.sca.implementation.web.runtime.utils;version="2.0",
+ org.oasisopen.sca.annotation;version="2.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.wink
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/wink/NOTICE b/sandbox/sebastien/java/embed/modules/wink/NOTICE
new file mode 100644
index 0000000000..dfde08644b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/wink/NOTICE
@@ -0,0 +1,12 @@
+${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 also includes software under the Service Component Architecture specification license
+(see the LICENSE file contained in this distribution) with the following copyright
+
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
diff --git a/sandbox/sebastien/java/embed/modules/wink/pom.xml b/sandbox/sebastien/java/embed/modules/wink/pom.xml
new file mode 100644
index 0000000000..3aae6ac017
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/wink/pom.xml
@@ -0,0 +1,69 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-wink</artifactId>
+ <name>Apache Tuscany SCA Apache Wink JAX-RS Integration</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-server</artifactId>
+ <version>1.1.1-incubating</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-common</artifactId>
+ <version>1.1.1-incubating</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java b/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java
new file mode 100644
index 0000000000..dd21302cfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/PropertyInjectable.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wink;
+
+import java.beans.Introspector;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
+import org.apache.wink.common.RuntimeContext;
+import org.apache.wink.common.internal.registry.Injectable;
+import org.oasisopen.sca.annotation.Property;
+
+public class PropertyInjectable extends Injectable {
+
+ private String name;
+
+ public PropertyInjectable(Property propertyAnnotation,
+ ParamType paramType,
+ Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ Member member) {
+ super(paramType, type, genericType, annotations, member);
+ this.name = getPropertyName(propertyAnnotation.name(), member);
+ }
+
+ @Override
+ public Object getValue(RuntimeContext runtimeContext) throws IOException {
+ return ContextHelper.getProperty(name, runtimeContext.getAttribute(ServletContext.class));
+ }
+
+ private String getPropertyName(String annotationName, Member member) {
+ String name;
+ if (annotationName != null && !annotationName.equals("")) {
+ name = annotationName;
+ } else {
+ name = getMember().getName();
+ if (name.startsWith("set")) {
+ name = Introspector.decapitalize(name.substring(3));
+ }
+ }
+ return name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java b/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java
new file mode 100644
index 0000000000..7a58e97fb9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/ReferenceInjectable.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.wink;
+
+import java.beans.Introspector;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
+import org.apache.wink.common.RuntimeContext;
+import org.apache.wink.common.internal.registry.Injectable;
+import org.oasisopen.sca.annotation.Reference;
+
+public class ReferenceInjectable extends Injectable {
+
+ private String referenceName;
+
+ public ReferenceInjectable(Reference referenceAnnotation,
+ ParamType paramType,
+ Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ Member member) {
+ super(paramType, type, genericType, annotations, member);
+ this.referenceName = getReferenceName(referenceAnnotation.name(), member);
+ }
+
+ @Override
+ public Object getValue(RuntimeContext runtimeContext) throws IOException {
+ return ContextHelper.getReference(referenceName, (Class<?>)getGenericType(), runtimeContext.getAttribute(ServletContext.class));
+ }
+
+ private String getReferenceName(String annotationName, Member member) {
+ String name;
+ if (annotationName != null && !annotationName.equals("")) {
+ name = annotationName;
+ } else {
+ name = getMember().getName();
+ if (name.startsWith("set")) {
+ name = Introspector.decapitalize(name.substring(3));
+ }
+ }
+ return name;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.java b/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.java
new file mode 100644
index 0000000000..dc7ef3fc2c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyDeploymentConfiguration.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 org.apache.tuscany.sca.wink;
+
+import org.apache.wink.common.internal.registry.InjectableFactory;
+import org.apache.wink.server.internal.DeploymentConfiguration;
+
+/**
+ * Subclass the default Wink DeploymentConfiguration and override
+ * the initRegistries method so the InjectableFactory instance can
+ * be set to the Tuscany one.
+ */
+public class TuscanyDeploymentConfiguration extends DeploymentConfiguration {
+
+ @Override
+ protected void initRegistries() {
+ super.initRegistries();
+ InjectableFactory.setInstance(new TuscanyInjectableFactory());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.java b/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.java
new file mode 100644
index 0000000000..ca71856a3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/wink/src/main/java/org/apache/tuscany/sca/wink/TuscanyInjectableFactory.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.wink;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+
+import org.apache.wink.common.internal.registry.Injectable;
+import org.apache.wink.server.internal.registry.ServerInjectableFactory;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * Subclass the Wink default ServerInjectableFactory to look
+ * for SCA @Reference or @Property annotations.
+ */
+public class TuscanyInjectableFactory extends ServerInjectableFactory {
+
+ @Override
+ public Injectable create(Type genericType,
+ Annotation[] annotations,
+ Member member,
+ boolean encoded,
+ String defaultValue) {
+ for (Annotation a : annotations) {
+ if (a instanceof Reference) {
+ return new ReferenceInjectable((Reference)a, null, null, genericType, annotations, member);
+ } else if (a instanceof Property) {
+ return new PropertyInjectable((Property)a, null, null, genericType, annotations, member);
+ }
+ }
+ return super.create(genericType, annotations, member, encoded, defaultValue);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/LICENSE b/sandbox/sebastien/java/embed/modules/xsd/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/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/sebastien/java/embed/modules/xsd/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/modules/xsd/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cd39e046c6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/META-INF/MANIFEST.MF
@@ -0,0 +1,46 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.xsd;version="2.0.0";
+ uses:="org.apache.ws.commons.schema,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.xsd.impl,
+ org.w3c.dom,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.xsd.xml;version="2.0.0";
+ uses:="org.apache.ws.commons.schema.resolver,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.contribution,
+ org.apache.tuscany.sca.xsd,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor,
+ org.xml.sax,
+ javax.xml.namespace"
+Private-Package: org.apache.tuscany.sca.xsd.impl;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA XSD Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA XSD Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xsd;version="2.0.0",
+ org.apache.tuscany.sca.common.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.tuscany.sca.xsd.xml;version="2.0.0",
+ org.apache.ws.commons.schema,
+ org.apache.ws.commons.schema.resolver,
+ org.w3c.dom,
+ org.xml.sax
+Bundle-SymbolicName: org.apache.tuscany.sca.xsd
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/modules/xsd/NOTICE b/sandbox/sebastien/java/embed/modules/xsd/NOTICE
new file mode 100644
index 0000000000..ad2ba40961
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/modules/xsd/pom.xml b/sandbox/sebastien/java/embed/modules/xsd/pom.xml
new file mode 100644
index 0000000000..e9f6b78c2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/pom.xml
@@ -0,0 +1,65 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-xsd</artifactId>
+ <name>Apache Tuscany SCA XSD Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.4.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <!-- Apache repository for Web Services artifacts -->
+ <repository>
+ <id>apache.ws.zone</id>
+ <name>Apache WS Zone Repository</name>
+ <url>http://ws.zones.apache.org/repository2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/DefaultXSDFactory.java b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/DefaultXSDFactory.java
new file mode 100644
index 0000000000..92dce98fa1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/DefaultXSDFactory.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.xsd;
+
+import org.apache.tuscany.sca.xsd.impl.XSDFactoryImpl;
+
+/**
+ * A factory for XSD definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultXSDFactory extends XSDFactoryImpl implements XSDFactory {
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.java b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.java
new file mode 100644
index 0000000000..d57d462843
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.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 org.apache.tuscany.sca.xsd;
+
+/**
+ * Factory for XSD definitions
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface XSDFactory {
+
+ /**
+ * Creates a new XML Schema definition.
+ *
+ * @return a new XML Schema definition
+ */
+ XSDefinition createXSDefinition();
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.java b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.java
new file mode 100644
index 0000000000..f7ddd25611
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.xsd;
+
+import java.net.URI;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.w3c.dom.Document;
+
+/**
+ * Represents an XML Schema definition.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface XSDefinition extends Base {
+ XmlSchemaCollection getSchemaCollection();
+
+ void setSchemaCollection(XmlSchemaCollection schemaCollection);
+
+ /**
+ * Returns the XmlSchema definition model
+ * @return the XmlSchema definition model
+ */
+ XmlSchema getSchema();
+
+ /**
+ * Sets the XmlSchema definition model
+ * @param definition the XmlSchema definition model
+ */
+ void setSchema(XmlSchema definition);
+
+ /**
+ * Returns the namespace of this XmlSchema definition.
+ * @return the namespace of this XmlSchema definition
+ */
+ String getNamespace();
+
+ /**
+ * Sets the namespace of this XmlSchema definition.
+ * @param namespace the namespace of this XmlSchema definition
+ */
+ void setNamespace(String namespace);
+
+ /**
+ * Get the location of the XSD
+ * @return
+ */
+ URI getLocation();
+
+ /**
+ * Set the location of the XSD
+ * @param uri
+ */
+ void setLocation(URI uri);
+
+ /**
+ * Get the DOM representation of the XSD
+ * @return
+ */
+ Document getDocument();
+
+ /**
+ * Set the DOM representation of the XSD
+ * @param document
+ */
+ void setDocument(Document document);
+
+ /**
+ * Get an XSD element by QName
+ * @param name The element name
+ * @return The XSD element
+ */
+ XmlSchemaElement getXmlSchemaElement(QName name);
+
+ /**
+ * Get an XSD type by QName
+ * @param name The type name
+ * @return The XSD type
+ */
+ XmlSchemaType getXmlSchemaType(QName name);
+
+ /**
+ * Get the aggregated definitions for a facade XSDefinition
+ * @return The aggregated definitions, or null if not a facade
+ */
+ List<XSDefinition> getAggregatedDefinitions();
+
+ /**
+ * Set the aggregated definitions for a facade XSDefinition
+ * @param name The aggregated definitions
+ */
+ void setAggregatedDefinitions(List<XSDefinition> definitions);
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDFactoryImpl.java b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDFactoryImpl.java
new file mode 100644
index 0000000000..60ff6b6fd9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDFactoryImpl.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 org.apache.tuscany.sca.xsd.impl;
+
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+
+/**
+ * A factory for XSD definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class XSDFactoryImpl implements XSDFactory {
+
+ public XSDefinition createXSDefinition() {
+ return new XSDefinitionImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDefinitionImpl.java b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDefinitionImpl.java
new file mode 100644
index 0000000000..af8cbf12ab
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDefinitionImpl.java
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.xsd.impl;
+
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.w3c.dom.Document;
+
+/**
+ * Represents a XML schema definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XSDefinitionImpl implements XSDefinition {
+ private XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
+ private XmlSchema schema;
+ private String namespace;
+ private URI location;
+ private Document document;
+ private boolean unresolved;
+ private List<XSDefinition> definitions;
+
+ public XSDefinitionImpl() {
+ }
+
+ public XmlSchema getSchema() {
+ return schema;
+ }
+
+ public void setSchema(XmlSchema definition) {
+ this.schema = definition;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ public String getNamespace() {
+ if (isUnresolved()) {
+ return namespace;
+ } else if (schema != null) {
+ return schema.getTargetNamespace();
+ } else {
+ return namespace;
+ }
+ }
+
+ public void setNamespace(String namespace) {
+ if (!isUnresolved()) {
+ throw new IllegalStateException();
+ } else {
+ this.namespace = namespace;
+ }
+ }
+
+ /**
+ * @return the location
+ */
+ public URI getLocation() {
+ return location;
+ }
+
+ /**
+ * @param location the location to set
+ */
+ public void setLocation(URI location) {
+ this.location = location;
+ }
+
+ /**
+ * @return the document
+ */
+ public Document getDocument() {
+ return document;
+ }
+
+ /**
+ * @param document the document to set
+ */
+ public void setDocument(Document document) {
+ this.document = document;
+ }
+
+ /**
+ * @return the schemaCollection
+ */
+ public XmlSchemaCollection getSchemaCollection() {
+ return schemaCollection;
+ }
+
+ /**
+ * @param schemaCollection the schemaCollection to set
+ */
+ public void setSchemaCollection(XmlSchemaCollection schemaCollection) {
+ this.schemaCollection = schemaCollection;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof XSDefinitionImpl))
+ return false;
+ final XSDefinitionImpl other = (XSDefinitionImpl)obj;
+ if (location == null) {
+ if (other.location != null)
+ return false;
+ } else if (!location.equals(other.location))
+ return false;
+ if (namespace == null) {
+ if (other.namespace != null)
+ return false;
+ } else if (!namespace.equals(other.namespace))
+ return false;
+ return true;
+ }
+
+ private static <T extends XmlSchemaObject> T getXmlSchemaObject(XmlSchema schema, QName name, Class<T> type) {
+ if (schema != null) {
+ XmlSchemaObject object = null;
+ if (type == XmlSchemaElement.class) {
+ object = schema.getElementByName(name);
+ } else if (type == XmlSchemaType.class) {
+ object = schema.getTypeByName(name);
+ }
+ if (object != null) {
+ return type.cast(object);
+ }
+ for (Iterator<?> i = schema.getIncludes().getIterator(); i.hasNext();) {
+ XmlSchemaObject obj = (XmlSchemaObject)i.next();
+ XmlSchema ext = null;
+ if (obj instanceof XmlSchemaInclude) {
+ ext = ((XmlSchemaInclude)obj).getSchema();
+ }
+ if (obj instanceof XmlSchemaImport) {
+ ext = ((XmlSchemaImport)obj).getSchema();
+ }
+ object = getXmlSchemaObject(ext, name, type);
+ if (object != null) {
+ return type.cast(object);
+ }
+ }
+ }
+ return null;
+ }
+
+ public XmlSchemaElement getXmlSchemaElement(QName name) {
+ if (schema != null) {
+ XmlSchemaElement element = getXmlSchemaObject(schema, name, XmlSchemaElement.class);
+ if (element != null) {
+ return element;
+ }
+ }
+
+ if (schemaCollection != null) {
+ return schemaCollection.getElementByQName(name);
+ }
+ return null;
+ }
+
+ public XmlSchemaType getXmlSchemaType(QName name) {
+ if (schema != null) {
+ XmlSchemaType type = getXmlSchemaObject(schema, name, XmlSchemaType.class);
+ if (type != null) {
+ return type;
+ }
+ }
+ if (schemaCollection != null) {
+ return schemaCollection.getTypeByQName(name);
+ }
+ return null;
+ }
+
+ public List<XSDefinition> getAggregatedDefinitions() {
+ return definitions;
+ }
+
+ public void setAggregatedDefinitions(List<XSDefinition> definitions) {
+ this.definitions = definitions;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessor.java b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessor.java
new file mode 100644
index 0000000000..1166567bcc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessor.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.xsd.xml;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+
+/**
+ * An ArtifactProcessor for XSD documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XSDDocumentProcessor implements URLArtifactProcessor<XSDefinition> {
+ private StAXHelper helper;
+ private XSDFactory factory;
+ private XMLInputFactory inputFactory;
+
+
+ public XSDDocumentProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.factory = modelFactories.getFactory(XSDFactory.class);
+ this.inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ this.helper = StAXHelper.getInstance(registry);
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = monitor.createProblem(this.getClass().getName(), "xsd-xml-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public XSDefinition read(URL contributionURL, URI artifactURI, URL artifactURL, ProcessorContext context) throws ContributionReadException {
+ try {
+ return indexRead(artifactURL);
+ } catch (Exception e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(context.getMonitor(), "ContributionReadException", artifactURL, ce);
+ throw ce;
+ }
+ }
+
+ public void resolve(XSDefinition model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+
+ public String getArtifactType() {
+ return ".xsd";
+ }
+
+ public Class<XSDefinition> getModelType() {
+ return XSDefinition.class;
+ }
+
+ public static final QName XSD = new QName("http://www.w3.org/2001/XMLSchema", "schema");
+
+ protected XSDefinition indexRead(URL doc) throws Exception {
+ XSDefinition xsd = factory.createXSDefinition();
+ xsd.setUnresolved(true);
+ xsd.setNamespace(helper.readAttribute(doc, XSD, "targetNamespace"));
+ xsd.setLocation(doc.toURI());
+ xsd.setUnresolved(false);
+ return xsd;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
new file mode 100644
index 0000000000..d87f1a3ef1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
@@ -0,0 +1,391 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.xsd.xml;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.xsd.Constants;
+import org.apache.tuscany.sca.common.xml.XMLDocumentHelper;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DefaultImport;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.processor.ContributionRuntimeException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.xsd.DefaultXSDFactory;
+import org.apache.tuscany.sca.xsd.XSDFactory;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.tuscany.sca.xsd.impl.XSDefinitionImpl;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.resolver.URIResolver;
+import org.xml.sax.InputSource;
+
+/**
+ * A Model Resolver for XSD models.
+ *
+ * @version $Rev$ $Date$
+ */
+public class XSDModelResolver implements ModelResolver {
+ private static final String AGGREGATED_XSD = "http://tuscany.apache.org/aggregated.xsd";
+ private XSDFactory factory;
+ private Contribution contribution;
+ private Map<String, List<XSDefinition>> map = new HashMap<String, List<XSDefinition>>();
+ private XmlSchemaCollection schemaCollection;
+
+ public XSDModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ this.schemaCollection = new XmlSchemaCollection();
+ this.factory = new DefaultXSDFactory();
+ }
+
+ public void addModel(Object resolved, ProcessorContext context) {
+ XSDefinition definition = (XSDefinition)resolved;
+ List<XSDefinition> list = map.get(definition.getNamespace());
+ if (list == null) {
+ list = new ArrayList<XSDefinition>();
+ map.put(definition.getNamespace(), list);
+ }
+ list.add(definition);
+ }
+
+ public Object removeModel(Object resolved, ProcessorContext context) {
+ XSDefinition definition = (XSDefinition)resolved;
+ List<XSDefinition> list = map.get(definition.getNamespace());
+ if (list == null) {
+ return null;
+ } else {
+ return list.remove(definition);
+ }
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
+ schemaCollection.setSchemaResolver(new URIResolverImpl(contribution, context));
+ XSDefinition definition = (XSDefinition)unresolved;
+ String namespace = definition.getNamespace();
+ XSDefinition resolved = null;
+
+ // Lookup a definition for the given namespace, within the contribution
+ List<XSDefinition> list = map.get(namespace);
+
+ if (list == null ||
+ (list != null && list.size() == 0)){
+ // if no schema is found locally delegate to other
+ // contributions via the imports
+ resolved = resolutionDelegation(namespace, context);
+ return modelClass.cast(resolved);
+ }
+
+ XSDefinition modelXSD = null;
+ if (list != null && definition.getDocument() != null) {
+ // Set the document for the inline schema
+ int index = list.indexOf(definition);
+ if (index != -1) { // a matching (not identical) document was found
+ modelXSD = list.get(index);
+ modelXSD.setDocument(definition.getDocument());
+ }
+ }
+ if (list == null && definition.getDocument() != null) {
+ // Hit for the 1st time
+ list = new ArrayList<XSDefinition>();
+ list.add(definition);
+ map.put(namespace, list);
+ }
+ try {
+ resolved = aggregate(list);
+ } catch (IOException e) {
+ throw new ContributionRuntimeException(e);
+ }
+ if (resolved != null && !resolved.isUnresolved()) {
+ if (definition.isUnresolved() && definition.getSchema() == null && modelXSD != null) {
+ // Update the unresolved model with schema information and mark it
+ // resolved. This information in the unresolved model is needed when
+ // this method is called by WSDLModelResolver.readInlineSchemas().
+ definition.setSchema(modelXSD.getSchema());
+ definition.setSchemaCollection(modelXSD.getSchemaCollection());
+ definition.setUnresolved(false);
+ }
+ return modelClass.cast(resolved);
+ }
+
+ return modelClass.cast(unresolved);
+ }
+
+ private void loadOnDemand(XSDefinition definition) throws IOException {
+ if (definition.getSchema() != null) {
+ return;
+ }
+ if (definition.getDocument() != null) {
+ String uri = null;
+ if (definition.getLocation() != null) {
+ uri = definition.getLocation().toString();
+ }
+ XmlSchema schema = null;
+ try {
+ schema = schemaCollection.read(definition.getDocument(), uri, null);
+ } catch (RuntimeException e) {
+ // find original cause of the problem
+ Throwable cause = e;
+ while (cause.getCause() != null && cause != cause.getCause()) {
+ cause = cause.getCause();
+ }
+ throw new ContributionRuntimeException(cause);
+ }
+ definition.setSchemaCollection(schemaCollection);
+ definition.setSchema(schema);
+ definition.setUnresolved(false);
+ } else if (definition.getLocation() != null) {
+ if (definition.getLocation().getFragment() != null) {
+ // It's an inline schema
+ return;
+ }
+ // Read an XSD document
+ XmlSchema schema = null;
+ for (XmlSchema d : schemaCollection.getXmlSchemas()) {
+ if (isSameNamespace(d.getTargetNamespace(), definition.getNamespace())) {
+ if (d.getSourceURI().equals(definition.getLocation().toString())) {
+ schema = d;
+ break;
+ }
+ }
+ }
+ if (schema == null) {
+ InputSource xsd = null;
+ try {
+ xsd = XMLDocumentHelper.getInputSource(definition.getLocation().toURL());
+ } catch (IOException e) {
+ throw new ContributionRuntimeException(e);
+ }
+
+ try {
+ schema = schemaCollection.read(xsd, null);
+ } catch (RuntimeException e) {
+ // find original cause of the problem
+ Throwable cause = e;
+ while (cause.getCause() != null && cause != cause.getCause()) {
+ cause = cause.getCause();
+ }
+ throw new ContributionRuntimeException(cause);
+ }
+ }
+ definition.setSchemaCollection(schemaCollection);
+ definition.setSchema(schema);
+ }
+ }
+
+ private boolean isSameNamespace(String ns1, String ns2) {
+ if (ns1 == null) {
+ return ns2 == null;
+ } else {
+ return ns1.equals(ns2);
+ }
+ }
+ /**
+ * Create a facade XmlSchema which includes all the definitions
+ *
+ * @param definitions A list of the XmlSchema under the same target
+ * namespace
+ * @return The aggregated XmlSchema
+ */
+ private XSDefinition aggregate(List<XSDefinition> definitions) throws IOException {
+ if (definitions == null || definitions.size() == 0) {
+ return null;
+ }
+ if (definitions.size() == 1) {
+ XSDefinition d = definitions.get(0);
+ loadOnDemand(d);
+ return d;
+ }
+ XSDefinition aggregated = factory.createXSDefinition();
+ for (XSDefinition d : definitions) {
+ loadOnDemand(d);
+ }
+ String ns = definitions.get(0).getNamespace();
+
+ XmlSchema facade = null;
+ // Check if the facade XSD is already in the collection
+ for (XmlSchema s : schemaCollection.getXmlSchema(AGGREGATED_XSD)) {
+ if (ns.equals(s.getTargetNamespace())) {
+ facade = s;
+ break;
+ }
+ }
+ if (facade == null) {
+ // This will add the facade into the collection
+ facade = new XmlSchema(ns, AGGREGATED_XSD, schemaCollection);
+ }
+
+ for (XmlSchema d : schemaCollection.getXmlSchemas()) {
+ if (ns.equals(d.getTargetNamespace())) {
+ if (d == facade) {
+ continue;
+ }
+ XmlSchemaInclude include = new XmlSchemaInclude();
+ include.setSchema(d);
+ include.setSourceURI(d.getSourceURI());
+ include.setSchemaLocation(d.getSourceURI());
+ facade.getIncludes().add(include);
+ facade.getItems().add(include);
+ }
+ }
+ aggregated.setUnresolved(true);
+ aggregated.setSchema(facade);
+ aggregated.setNamespace(ns);
+ aggregated.setAggregatedDefinitions(definitions);
+ aggregated.setUnresolved(false);
+
+ // FIXME: [rfeng] This is hacky
+ //definitions.clear();
+ //definitions.add(aggregated);
+ return aggregated;
+ }
+
+ private XSDefinition resolutionDelegation(String namespace, ProcessorContext context){
+ // Delegate the resolution to namespace imports
+ XSDefinition resolved = null;
+ XSDefinition unresolved = new XSDefinitionImpl();
+ unresolved.setUnresolved(true);
+ unresolved.setNamespace(namespace);
+
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof NamespaceImport) {
+ NamespaceImport namespaceImport = (NamespaceImport)import_;
+ if (namespaceImport.getNamespace().equals(namespace)) {
+ // Delegate the resolution to the namespace import resolver
+ resolved =
+ namespaceImport.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return resolved;
+ }
+ }
+ } else if (import_ instanceof DefaultImport) {
+ // Delegate the resolution to the default import resolver
+ resolved =
+ import_.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return resolved;
+ }
+ }
+ }
+
+ return resolved;
+ }
+
+ /**
+ * URI resolver implementation for XML schema
+ */
+ public static class URIResolverImpl implements URIResolver {
+ private Contribution contribution;
+ private ProcessorContext context;
+
+ public URIResolverImpl(Contribution contribution, ProcessorContext context) {
+ this.contribution = contribution;
+ this.context = context;
+ }
+
+ public org.xml.sax.InputSource resolveEntity(java.lang.String targetNamespace,
+ java.lang.String schemaLocation,
+ java.lang.String baseUri) {
+ try {
+ if (schemaLocation == null) {
+ return null;
+ }
+ URL url = null;
+
+ // Delegate the resolution to namespace imports
+ XSDefinition resolved = null;
+ XSDefinition unresolved = new XSDefinitionImpl();
+ unresolved.setUnresolved(true);
+ unresolved.setLocation(new URI(schemaLocation));
+ unresolved.setNamespace(targetNamespace);
+
+ for (Import import_ : this.contribution.getImports()) {
+ if (import_ instanceof NamespaceImport) {
+ NamespaceImport namespaceImport = (NamespaceImport)import_;
+ if (namespaceImport.getNamespace().equals(targetNamespace)) {
+ // Delegate the resolution to the namespace import resolver
+ resolved =
+ namespaceImport.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return XMLDocumentHelper.getInputSource(resolved.getLocation().toURL());
+ }
+ }
+ } else if (import_ instanceof DefaultImport) {
+ // Delegate the resolution to the default import resolver
+ resolved =
+ import_.getModelResolver().resolveModel(XSDefinition.class, (XSDefinition)unresolved, context);
+ if (!resolved.isUnresolved()) {
+ return XMLDocumentHelper.getInputSource(resolved.getLocation().toURL());
+ }
+ }
+ }
+
+ // Not found, lookup a definition for the given namespace
+ // within the current contribution.
+ if (schemaLocation.startsWith("/")) {
+ // The URI is relative to the contribution
+ String uri = schemaLocation.substring(1);
+ for (Artifact a : contribution.getArtifacts()) {
+ if (a.getURI().equals(uri)) {
+ url = new URL(a.getLocation());
+ break;
+ }
+ }
+ if (url == null) {
+ // URI not found in the contribution; return a default InputSource
+ // so that the XmlSchema code will produce a useful diagnostic
+ return new InputSource(schemaLocation);
+ }
+ } else {
+ // look to see whether Tuscany has a local version of the
+ // required schema. It can load the local version rather
+ // than going out to the network in order to improve performance
+ url = Constants.CACHED_XSDS.get(targetNamespace);
+
+ if (url == null) {
+ url = new URL(new URL(baseUri), schemaLocation);
+ }
+ }
+ return XMLDocumentHelper.getInputSource(url);
+ } catch (IOException e) {
+ // Invalid URI; return a default InputSource so that the
+ // XmlSchema code will produce a useful diagnostic
+ return new InputSource(schemaLocation);
+ } catch (URISyntaxException e) {
+ // Invalid URI; return a default InputSource so that the
+ // XmlSchema code will produce a useful diagnostic
+ return new InputSource(schemaLocation);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..8431cdcb75
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -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 artifact processor extension
+org.apache.tuscany.sca.xsd.xml.XSDDocumentProcessor;type=.xsd,model=org.apache.tuscany.sca.xsd.XSDefinition
+
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..acae484065
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -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.
+
+org.apache.tuscany.sca.xsd.xml.XSDModelResolver;model=org.apache.tuscany.sca.xsd.XSDefinition
+
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.xsd.XSDFactory b/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.xsd.XSDFactory
new file mode 100644
index 0000000000..d51b2445a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.xsd.XSDFactory
@@ -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.xsd.DefaultXSDFactory
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/xsd-xml-validation-messages.properties b/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/xsd-xml-validation-messages.properties
new file mode 100644
index 0000000000..ab50456510
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/main/resources/xsd-xml-validation-messages.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+ContributionReadException = ContributionReadException occured due to : {0}
+
+
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/test/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessorTestCase.java b/sandbox/sebastien/java/embed/modules/xsd/src/test/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessorTestCase.java
new file mode 100644
index 0000000000..e139625986
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/test/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessorTestCase.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.xsd.xml;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class XSDDocumentProcessorTestCase {
+ private URLArtifactProcessor<Object> documentProcessor;
+ private ContributionFactory contributionFactory;
+ private ModelResolver resolver;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ Contribution contribution = contributionFactory.createContribution();
+ resolver = new XSDModelResolver(contribution, modelFactories);
+ }
+
+ @Test
+ public void testXSD() throws Exception {
+ ProcessorContext context = new ProcessorContext();
+ URL url = getClass().getResource("/xsd/greeting.xsd");
+ XSDefinition definition = (XSDefinition)documentProcessor.read(null, URI.create("xsd/greeting.xsd"), url, context);
+ Assert.assertNull(definition.getSchema());
+ Assert.assertEquals("http://greeting", definition.getNamespace());
+ URL url1 = getClass().getResource("/xsd/name.xsd");
+ XSDefinition definition1 = (XSDefinition)documentProcessor.read(null, URI.create("xsd/name.xsd"), url1, context);
+ Assert.assertNull(definition1.getSchema());
+ Assert.assertEquals("http://greeting", definition1.getNamespace());
+ resolver.addModel(definition, context);
+ XSDefinition resolved = resolver.resolveModel(XSDefinition.class, definition, context);
+ XmlSchemaObjectCollection collection = resolved.getSchema().getIncludes();
+ Assert.assertTrue(collection.getCount() == 1);
+ XmlSchemaType type =
+ ((XmlSchemaInclude)collection.getItem(0)).getSchema().getTypeByName(new QName("http://greeting", "Name"));
+ Assert.assertNotNull(type);
+ resolver.addModel(definition1, context);
+ resolved = resolver.resolveModel(XSDefinition.class, definition, context);
+ collection = resolved.getSchema().getIncludes();
+ Assert.assertTrue(collection.getCount() == 2);
+ XmlSchemaType type1 =
+ ((XmlSchemaInclude)collection.getItem(0)).getSchema().getTypeByName(new QName("http://greeting", "Name"));
+ XmlSchemaType type2 =
+ ((XmlSchemaInclude)collection.getItem(1)).getSchema().getTypeByName(new QName("http://greeting", "Name"));
+ Assert.assertTrue(type1 != null || type2 != null);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/test/resources/xsd/greeting.xsd b/sandbox/sebastien/java/embed/modules/xsd/src/test/resources/xsd/greeting.xsd
new file mode 100644
index 0000000000..635ca25bfc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/test/resources/xsd/greeting.xsd
@@ -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.
+-->
+<schema targetNamespace="http://greeting" xmlns="http://www.w3.org/2001/XMLSchema">
+ <include schemaLocation="name.xsd" />
+ <complexType name="Greeting">
+ <sequence>
+ <element name="message" type="string" />
+ <element name="name" type="Name" />
+ </sequence>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/modules/xsd/src/test/resources/xsd/name.xsd b/sandbox/sebastien/java/embed/modules/xsd/src/test/resources/xsd/name.xsd
new file mode 100644
index 0000000000..300de931ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/modules/xsd/src/test/resources/xsd/name.xsd
@@ -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.
+-->
+<schema targetNamespace="http://greeting" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <complexType name="Name">
+ <sequence>
+ <element name="firstName" type="string" />
+ <element name="lastName" type="string" />
+ </sequence>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/pom.xml b/sandbox/sebastien/java/embed/pom.xml
new file mode 100644
index 0000000000..12891338c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/pom.xml
@@ -0,0 +1,1039 @@
+<?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</groupId>
+ <artifactId>apache</artifactId>
+ <version>7</version>
+ </parent>
+
+ <!-- ====================================================================== -->
+ <!-- Project description and basic configuration -->
+ <!-- ====================================================================== -->
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Implementation Project (2.x)</name>
+ <url>http://tuscany.apache.org</url>
+ <version>2.0-SNAPSHOT</version>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk</developerConnection>
+ <url>http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk</url>
+ </scm>
+
+ <prerequisites>
+ <maven>2.0.6</maven>
+ </prerequisites>
+
+ <properties>
+ <notice.dir>.</notice.dir>
+ <tools.jar>${java.home}/../lib/tools.jar</tools.jar>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>http://issues.apache.org/jira/browse/TUSCANY</url>
+ </issueManagement>
+
+ <!-- ====================================================================== -->
+ <!-- Maven Repositories -->
+ <!-- ====================================================================== -->
+ <repositories>
+ <repository>
+ <id>maven.central</id>
+ <url>http://repo2.maven.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <!-- Apache SNAPSHOT repository for unreleased artifacts -->
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache SNAPSHOT Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <!-- Tuscany repository to hold artifacts that are not published in the public maven repos -->
+ <repository>
+ <id>tuscany.repo</id>
+ <name>Tuscany Maven 2.x Repository</name>
+ <url>http://svn.apache.org/repos/asf/tuscany/maven</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.ws.zone</id>
+ <name>Apache WS Zone Repository</name>
+ <url>http://ws.zones.apache.org/repository2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>indiana</id>
+ <url>http://ftp.ussg.iu.edu/eclipse/modeling/emf/emf/maven2/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>osuosl.org</id>
+ <url>http://ftp.osuosl.org/pub/eclipse/tools/emf/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+
+ <!-- for Saxon 9.x -->
+ <repository>
+ <id>intalio.org</id>
+ <url>http://www.intalio.org/public/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+
+ <!-- for java.net -->
+ <repository>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+
+ <repository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <!-- ====================================================================== -->
+ <!-- Maven Plugin-Repositories -->
+ <!-- ====================================================================== -->
+ <pluginRepositories>
+ <!-- Apache repository for artifacts released by Apache TLP projects -->
+ <pluginRepository>
+ <id>apache</id>
+ <name>Apache Repository</name>
+ <url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+
+ <!-- Apache Incubator repository for artifacts released by Incubator projects -->
+ <pluginRepository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+
+ <!-- Apache SNAPSHOT repository for unreleased artifacts -->
+ <pluginRepository>
+ <id>apache.snapshots</id>
+ <name>Apache SNAPSHOT Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+
+ <!-- Codehaus SNAPSHOT repository -->
+ <pluginRepository>
+ <id>codehaus-snapshot</id>
+ <name>Codehaus Snapshot Repository</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+
+ <!-- Maven central repository -->
+ <pluginRepository>
+ <id>maven.central</id>
+ <name>Maven Central Repository</name>
+ <url>http://repo2.maven.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+
+ <pluginRepository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <!-- ====================================================================== -->
+ <!-- Distribution Management configuration -->
+ <!-- ====================================================================== -->
+ <distributionManagement>
+ <repository>
+ <id>apache.releases.https</id>
+ <name>Apache Release Distribution Repository</name>
+ <url>https://repository.apache.org/service/local/staging/deploy/maven2</url>
+ </repository>
+ <snapshotRepository>
+ <id>apache.snapshots.https</id>
+ <name>Apache Development Snapshot Repository</name>
+ <url>https://repository.apache.org/content/repositories/snapshots</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <profiles>
+ <!-- ====================================================================== -->
+ <!-- Default profile -->
+ <!-- ====================================================================== -->
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>maven/maven-tuscany-plugin</module>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>features</module>
+ <module>shades</module>
+ <module>distribution</module>
+ <module>archetypes</module>
+ <module>compliance-tests</module>
+ </modules>
+ </profile>
+ <!-- ====================================================================== -->
+ <!-- Default profile to be used in Mac OS environment -->
+ <!-- Note that this set tools.jar property based on the JDK used in Mac -->
+ <!-- ====================================================================== -->
+ <profile>
+ <id>default-mac</id>
+ <activation>
+ <os>
+ <family>mac</family>
+ </os>
+ </activation>
+ <properties>
+ <tools.jar>${java.home}/../Classes/classes.jar</tools.jar>
+ </properties>
+ <modules>
+ <module>maven/maven-tuscany-plugin</module>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>features</module>
+ <module>shades</module>
+ <module>distribution</module>
+ <module>archetypes</module>
+ <module>compliance-tests</module>
+ </modules>
+ </profile>
+
+ <!-- ====================================================================== -->
+ <!-- Profile used to generate OSGi based Eclipse IDE project artifacts -->
+ <!-- ====================================================================== -->
+ <profile>
+ <id>eclipse</id>
+ <modules>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>features</module>
+ <module>distribution</module>
+ </modules>
+ <build>
+ <defaultGoal>org.apache.tuscany.maven.plugins:maven-bundle-plugin:eclipse</defaultGoal>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.5</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+
+ <!-- ====================================================================== -->
+ <!-- Profile used to generate OSGi based Eclipse IDE project artifacts -->
+ <!-- Note that this set tools.jar property based on the JDK used in Mac -->
+ <!-- ====================================================================== -->
+ <profile>
+ <id>eclipse-mac</id>
+ <properties>
+ <tools.jar>${java.home}/../Classes/classes.jar</tools.jar>
+ </properties>
+ <modules>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>features</module>
+ <module>distribution</module>
+ </modules>
+ <build>
+ <defaultGoal>org.apache.tuscany.maven.plugins:maven-bundle-plugin:eclipse</defaultGoal>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.5</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+
+ <!-- ====================================================================== -->
+ <!-- Profile to build release distribution -->
+ <!-- ====================================================================== -->
+ <profile>
+ <id>distribution</id>
+ <modules>
+ <module>maven/maven-tuscany-plugin</module>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>features</module>
+ <module>shades</module>
+ <module>distribution</module>
+ <module>archetypes</module>
+ <module>compliance-tests</module>
+ </modules>
+ <build>
+ <plugins>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>compliance</id>
+ <modules>
+ <module>compliance-tests</module>
+ </modules>
+ </profile>
+
+<!-- START - WHAT ARE THE FOLLOWING PROFILES FOR? -->
+ <!-- ====================================================================== -->
+ <!-- Profile to generate source jars for modules -->
+ <!-- ====================================================================== -->
+
+ <profile>
+ <id>source</id>
+ <modules>
+ <module>modules</module>
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>osgi</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <modules>
+ <module>samples</module>
+ </modules>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-maven-osgi-junit</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>osgi-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>dependencies</id>
+ <modules>
+ <module>modules</module>
+ <!--module>samples</module>
+ <module>tutorials</module>
+ <module>demos</module-->
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-maven-dependency-lister</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>security</id>
+ <modules>
+ <module>itest</module>
+ </modules>
+ <activation>
+ <property>
+ <name>tuscany.policy.file</name>
+ </property>
+ </activation>
+ <properties>
+ <tuscany.policy.file>file:///${java.home}/lib/security/tuscany.policy</tuscany.policy.file>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <reportFormat>brief</reportFormat>
+ <useFile>false</useFile>
+ <forkMode>once</forkMode>
+ <!-- Place tuscany.policy in your Java home security directory. Alternatively, hardcode the file location here. -->
+ <argLine>-Djava.security.manager -Djava.security.policy=${tuscany.policy.file} -Dpolicy.allowSystemProperty=true -Djava.security.debug=policy</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- profile for verifying source code correctness -->
+ <profile>
+ <id>sourcecheck</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <showDeprecation>true</showDeprecation>
+ <compilerArgument>-Xlint:unchecked,deprecation,fallthrough,finally</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!--
+ to test this profile you may like to run mvn with arguments ...
+ -DaltDeploymentRepository=id::default::file:target/deploy -Prelease -Dgpg.skip
+ then look in the target/deploy directory for a locally deployed repository of artifacts
+ -->
+ <profile>
+ <id>release</id>
+ <properties>
+ <skipTests>true</skipTests>
+ <buildZips>true</buildZips>
+ </properties>
+ <modules>
+ <module>maven/maven-tuscany-plugin</module>
+ <module>modules</module>
+ <module>shades</module>
+ <module>features</module>
+ <module>distribution</module>
+ <module>archetypes</module>
+ </modules>
+ <build>
+ <defaultGoal>deploy</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <updateReleaseInfo>true</updateReleaseInfo>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>deploy</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1</version>
+ <configuration>
+ <maxmemory>1024m</maxmemory>
+ <tags>
+ <tag>
+ <name>tuscany.spi.extension.inheritfrom</name>
+ <!-- extension spi by inheritance tag for placing in classes /interfaces -->
+ <placement>t</placement>
+ <head>Provides part of the Tuscany SPI for Extension Developers by specialization of this class/interface
+ </head>
+ </tag>
+ <tag>
+ <name>tuscany.spi.extension.asclient</name>
+ <!-- extension spi by client access tag for placing in classes / interfaces. The term client here is used
+ in the OO design sense of any class that calls the methods of another is a client of the latter -->
+ <placement>t</placement>
+ <head>Provides part of the Tuscany SPI for Extension Developers by calling methods on this interface/class.</head>
+ </tag>
+ <tag>
+ <name>tuscany.spi.extension</name>
+ <!-- extension spi indicator for overviews, packages -->
+ <placement>a</placement>
+ <head>Elements of the Tuscany SPI for Extension developers are provided.</head>
+ </tag>
+ </tags>
+
+
+
+ <groups>
+ <!-- beware: this group stanza results in a grouping of pages that contains a superset of the spi, until we complete identification and then refactor out non spi code from listed packages-->
+ <group>
+ <title>Extension Developer's SPIs (Work in Progress)</title>
+ <packages>
+org.apache.tuscany.sca.assembly:org.apache.tuscany.sca.assembly.builder:org.apache.tuscany.sca.assembly.impl:org.apache.tuscany.sca.assembly.xml:org.apache.tuscany.sca.common.http:org.apache.tuscany.sca.common.xml:org.apache.tuscany.sca.common.xml.dom:org.apache.tuscany.sca.common.xml.stax:org.apache.tuscany.sca.context:org.apache.tuscany.sca.contribution:org.apache.tuscany.sca.contribution.namespace:org.apache.tuscany.sca.contribution.processor:org.apache.tuscany.sca.contribution.resolver:org.apache.tuscany.sca.core:org.apache.tuscany.sca.core.assembly:org.apache.tuscany.sca.core.factory:org.apache.tuscany.sca.core.invocation:org.apache.tuscany.sca.core.scope:org.apache.tuscany.sca.data.collection:org.apache.tuscany.sca.databinding:org.apache.tuscany.sca.databinding.impl:org.apache.tuscany.sca.databinding.javabeans:org.apache.tuscany.sca.databinding.xml:org.apache.tuscany.sca.extensibility:org.apache.tuscany.sca.host.http:org.apache.tuscany.sca.interfacedef:org.apache.tuscany.sca.interfacedef.impl:org.apache.tuscany.sca.interfacedef.util:org.apache.tuscany.sca.interfacedef.wsdl:org.apache.tuscany.sca.invocation:org.apache.tuscany.sca.monitor:org.apache.tuscany.sca.policy:org.apache.tuscany.sca.policy.authentication.token:org.apache.tuscany.sca.policy.security:org.apache.tuscany.sca.policy.util:org.apache.tuscany.sca.provider:org.apache.tuscany.sca.runtime:org.apache.tuscany.sca.web.javascript:org.apache.tuscany.sca.work:org.apache.tuscany.sca.xsd</packages>
+ </group>
+ </groups> <!-- -->
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>base</id>
+ <modules>
+ <module>modules/assembly</module>
+ <module>modules/assembly-xml</module>
+ <module>modules/assembly-xsd</module>
+ <module>modules/binding-hazelcast-runtime</module>
+ <module>modules/binding-sca-runtime</module>
+ <module>modules/binding-ws</module>
+ <module>modules/binding-ws-wsdlgen</module>
+ <module>modules/binding-ws-runtime-jaxws</module>
+ <module>modules/binding-ws-runtime-jaxws-ri</module>
+ <module>modules/binding-jms</module>
+ <module>modules/binding-jms-runtime</module>
+ <module>modules/builder</module>
+ <module>modules/common-java</module>
+ <module>modules/common-xml</module>
+ <module>modules/contribution</module>
+ <module>modules/core</module>
+ <module>modules/core-databinding</module>
+ <module>modules/core-spi</module>
+ <module>modules/databinding</module>
+ <module>modules/databinding-jaxb</module>
+ <module>modules/deployment</module>
+ <module>modules/domain-node</module>
+ <module>modules/endpoint-hazelcast</module>
+ <module>modules/endpoint-hazelcast-client</module>
+ <module>modules/extensibility</module>
+ <module>modules/host-http</module>
+ <module>modules/host-jetty</module>
+ <module>modules/host-webapp</module>
+ <module>modules/implementation-java</module>
+ <module>modules/implementation-java-runtime</module>
+ <module>modules/implementation-web</module>
+ <module>modules/implementation-web-runtime</module>
+ <module>modules/interface-java</module>
+ <module>modules/interface-java-jaxws</module>
+ <module>modules/interface-wsdl</module>
+ <module>modules/launcher</module>
+ <module>modules/monitor</module>
+ <module>modules/interface-wsdl</module>
+ <module>modules/node-api</module>
+ <module>modules/node-impl</module>
+ <module>modules/policy-security</module>
+ <module>modules/sca-api</module>
+ <module>modules/sca-client-impl</module>
+ <module>modules/wink</module>
+ <module>modules/xsd</module>
+ <module>shades/base</module>
+ <module>shades/base-nodep</module>
+ <module>compliance-tests</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>jms</id>
+ <modules>
+ <module>modules/binding-jms</module>
+ <module>modules/binding-jms-runtime</module>
+ <module>samples/webapps/helloworld-jms</module>
+ <module>itest/jms</module>
+ </modules>
+ </profile>
+
+<!-- END - WHAT ARE THE FOLLOWING PROFILES FOR? -->
+
+ <profile>
+ <id>fast</id>
+ <modules>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>features</module>
+ <module>shades</module>
+ <module>distribution</module>
+ <module>archetypes</module>
+ <!-- module>compliance-tests</module -->
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <reportFormat>brief</reportFormat>
+ <useFile>false</useFile>
+ <forkMode>once</forkMode>
+ <argLine>-ea -Xmx256m</argLine>
+ <parallel>classes</parallel>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+<!--
+ <resource>
+ <directory>${notice.dir}</directory>
+ <targetPath>META-INF</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>LICENSE</include>
+ <include>NOTICE</include>
+ <include>README</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${basedir}/META-INF</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>MANIFEST.MF</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${basedir}/OSGI-INF</directory>
+ <targetPath>OSGI-INF</targetPath>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+-->
+ <resource>
+ <directory>${basedir}</directory>
+ <includes>
+ <include>LICENSE</include>
+ <include>NOTICE</include>
+ <include>README</include>
+ <include>META-INF/**/*</include>
+ <include>OSGI-INF/**/*</include>
+ </includes>
+ </resource>
+
+
+
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ <executions>
+ <execution>
+ <id>enforce-plugin-versions</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requirePluginVersions>
+ <unCheckedPluginList>org.apache.tuscany.maven.plugins:maven-tuscany-plugin</unCheckedPluginList>
+ <message>Best Practice is to always define released plugin versions!</message>
+ <banLatest>true</banLatest>
+ <banRelease>true</banRelease>
+ <banSnapshots>true</banSnapshots>
+ <phases>clean,deploy,site</phases>
+ <additionalPlugins>
+ </additionalPlugins>
+ </requirePluginVersions>
+ </rules>
+ <fail>false</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>2.3</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.4.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1-beta-1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.8</version>
+ </plugin>
+
+ <!-- compiler plugin configuration -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <fork>true</fork>
+ <meminitial>512m</meminitial>
+ <maxmem>1024m</maxmem>
+ </configuration>
+ </plugin>
+
+ <!-- surefire plugin configuration -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <reportFormat>brief</reportFormat>
+<!--
+ <useFile>false</useFile>
+ <forkMode>once</forkMode>
+ <argLine>-ea -Xmx756m -Xms756m -XX:MaxPermSize=512m</argLine>
+-->
+ </configuration>
+ </plugin>
+
+ <!-- jar plugin configuration -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Extension-Name>${project.artifactId}</Extension-Name>
+ <Specification-Title>${name}</Specification-Title>
+ <Specification-Vendor>The Apache Software Foundation</Specification-Vendor>
+ <Specification-Version>${version}</Specification-Version>
+ <Implementation-Title>${name}</Implementation-Title>
+ <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
+ <Implementation-Vendor>The Apache Software Foundation</Implementation-Vendor>
+ <Implementation-Version>${version}</Implementation-Version>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <!-- code coverage check plugin configuration -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clover-plugin</artifactId>
+ <configuration>
+ <jdk>1.6</jdk>
+ </configuration>
+ </plugin>
+
+ <!-- ant plugin global configuration -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-trax</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ <!-- this JDk dependency is a workaround for Maven bug - http://jira.codehaus.org/browse/MNG-1323 -->
+ <dependency>
+ <groupId>sun.jdk</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.6</version>
+ <scope>system</scope>
+ <systemPath>${tools.jar}</systemPath>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-8</version>
+ <configuration>
+ <tagBase>https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/tags</tagBase>
+ <useReleaseProfile>false</useReleaseProfile>
+ <preparationGoals>clean install</preparationGoals>
+ <goals>deploy</goals>
+ <arguments>-Prelease,deploy</arguments>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1</version>
+ <configuration>
+ <maxmemory>1024m</maxmemory>
+ <tags>
+ <tag>
+ <name>tuscany.spi.extension.inheritfrom</name>
+ <!-- extension spi by inheritance tag for placing in classes /interfaces -->
+ <placement>t</placement>
+ <head>Provides part of the Tuscany SPI for Extension Developers by specialization of this class/interface
+ </head>
+ </tag>
+ <tag>
+ <name>tuscany.spi.extension.asclient</name>
+ <!-- extension spi by client access tag for placing in classes / interfaces. The term client here is used
+ in the OO design sense of any class that calls the methods of another is a client of the latter -->
+ <placement>t</placement>
+ <head>Provides part of the Tuscany SPI for Extension Developers by calling methods on this interface/class.</head>
+ </tag>
+ <tag>
+ <name>tuscany.spi.extension</name>
+ <!-- extension spi indicator for overviews, packages -->
+ <placement>a</placement>
+ <head>Elements of the Tuscany SPI for Extension developers are provided.</head>
+ </tag>
+ </tags>
+
+
+ <groups>
+ <!-- beware: this group stanza results in a grouping of pages that contains a superset of the spi, until we complete identification and then refactor out non spi code from listed packages-->
+ <group>
+ <title>Extension Developer's SPIs (Work in Progress)</title>
+ <packages>
+org.apache.tuscany.sca.assembly:org.apache.tuscany.sca.assembly.builder:org.apache.tuscany.sca.assembly.impl:org.apache.tuscany.sca.assembly.xml:org.apache.tuscany.sca.common.http:org.apache.tuscany.sca.common.xml:org.apache.tuscany.sca.common.xml.dom:org.apache.tuscany.sca.common.xml.stax:org.apache.tuscany.sca.context:org.apache.tuscany.sca.contribution:org.apache.tuscany.sca.contribution.namespace:org.apache.tuscany.sca.contribution.processor:org.apache.tuscany.sca.contribution.resolver:org.apache.tuscany.sca.core:org.apache.tuscany.sca.core.assembly:org.apache.tuscany.sca.core.factory:org.apache.tuscany.sca.core.invocation:org.apache.tuscany.sca.core.scope:org.apache.tuscany.sca.data.collection:org.apache.tuscany.sca.databinding:org.apache.tuscany.sca.databinding.impl:org.apache.tuscany.sca.databinding.javabeans:org.apache.tuscany.sca.databinding.xml:org.apache.tuscany.sca.extensibility:org.apache.tuscany.sca.host.http:org.apache.tuscany.sca.interfacedef:org.apache.tuscany.sca.interfacedef.impl:org.apache.tuscany.sca.interfacedef.util:org.apache.tuscany.sca.interfacedef.wsdl:org.apache.tuscany.sca.invocation:org.apache.tuscany.sca.monitor:org.apache.tuscany.sca.policy:org.apache.tuscany.sca.policy.authentication.token:org.apache.tuscany.sca.policy.security:org.apache.tuscany.sca.policy.util:org.apache.tuscany.sca.provider:org.apache.tuscany.sca.runtime:org.apache.tuscany.sca.web.javascript:org.apache.tuscany.sca.work:org.apache.tuscany.sca.xsd</packages>
+ </group>
+ </groups> <!-- -->
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/README b/sandbox/sebastien/java/embed/samples/README
new file mode 100644
index 0000000000..43b7cb3056
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/README
@@ -0,0 +1,269 @@
+The Apache Tuscany SCA Samples
+==============================
+
+New Samples Structure
+---------------------
+
+For the Milestone 5 release of Tuscany SCA Java 2.x we are beginning
+the process of moving to a new structure for samples. Milestone 5 is
+delivered in a state of partial change over to this new emphasis, and hence
+this README reflects that hybrid state.
+
+There are primarily 3 types of sample; those which focus on pure SCA
+concepts, those which demonstrate features of Tuscany and the last group
+is of samples which give a flavour of more complete, realistic applications.
+
+The new structure primarily focusses separating contributions from the way that
+contributions are launched. The samples demonstrate the way in which contributions are used by
+launchers to execute tuscany SCA applications.
+
+In this way you can explore the samples by chosing which launcher you wish
+to invoke which contribution. In the old style of sample this distinction was not clear;
+any given sample contained both launcher and contribution, and the set of samples provided
+represented a small subset of the combinations possible by the new approach.
+
+Within the SCA category of samples, most of the calculator samples, have been
+migrated to this new structure as follows.
+
+SCA Samples
+ binding-rmi-calculator
+ contribution-calculator-reference
+ contribution-calculator-service
+ binding-sca
+ contribution-calculator
+ contribution-binding-ws-calculator
+ contribution-implementation-java-calculator
+ calculator-sca-client
+ launcher-command-line
+ launcher-embedded-jse
+ launcher-embedded-osgi
+ launcher-mvn
+
+Please visit the 2.x documentation in our website [1] to get a better understanding of SCA
+and Tuscany 2.x
+
+Running the New Style samples
+-----------------------------
+
+To run a new style sample there are 3 basic steps
+
+1) build the contribution: using either the command "mvn", "ant run" or your usual steps to build a
+ module in your IDE
+2) unit test the contribution: if you used mvn or ant in step 1 then you will already have done this;
+ if you used an IDE follow your usual steps to run the unit test in the contribution's module
+3) launch the contribution: go to one of the launcher* subdirectories of the samples root directory
+ and follow the instructions there to use a launcher to launch your chosen contribution
+
+I the case where you want to exercise the sample contribution with a separate client program, such as
+an application using the SCA client API then there is a 4th step of starting that client application
+
+[1] http://tuscany.apache.org/documentation-2x/
+
+Running the Old Style Samples
+------------------------------
+The Apache Tuscany SCA samples are built as part of the main Maven build and
+run, using the provided JUnit test cases, as tests in the Maven build.
+
+In the binary distribution of Apache Tuscany most samples can also
+be run using the provided Ant build.xml files. These show the samples running
+from a simple main() method without the need for a JUnit test case.
+
+In these notes text that appears in angled brackets like this <example> means
+that you need to make a choice and provide your own text at that point.
+
+These simple samples have been created with the intention of illustrating the
+usage of the SCA API and annotations and certainly not to levels of SCA component
+abstraction. In real life situations you should use SCA to assemble real and
+usually bigger components, and when you do that you'll get all the benefits of
+SCA, bindings, policies, integration in an SOA environment etc..
+
+Sample Layout
+-------------
+Generally sample directories are organized in the same way based on the default
+project template provided by Maven. For example, take a look at the calculator
+sample;
+
+calculator/
+ src/ - Holds all of the source files for the sample
+ main/ - Groups together the files that implement the sample
+ java/ - Java source files
+ resources/ - Non java resource files such as composte files
+ test/ - Groups together files that provide sample tests
+ java - Java test sources files. Usually JUnit test cases
+ target/ - Holds the files generated when the sample is built
+ classes/ - For example, Java class files
+ test-classes/ - classes from src/test and other test files
+
+Getting Ready To Build
+----------------------
+You will need to install the following software before you start.
+
+J2SE Development Kit (JDK) 5.0
+Apache Ant 1.7.1 - if you are going to use Ant
+Apache Maven 2.0.9 - if you are going to use Maven
+
+Java and Ant and/or Maven binary directories must be present in your PATH so
+that their executable programs are available in your environment. You may
+find it useful to use a script to set up your environment, for example;
+
+For UNIX:
+ JAVA_HOME=/<installation_directory>
+ ANT_HOME=/<installation_directory>/apache-ant-1.7.0
+ MAVEN_HOME=/<installation_directory>/maven-2.0.6
+ export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$MAVEN_HOME/bin:$PATH
+
+For Windows:
+ set JAVA_HOME=C:\<installation_directory>
+ set ANT_HOME=C:\<installation_directory>\apache-ant-1.7.0
+ set MAVEN_HOME=C:\<installation_directory>\maven-2.0.6
+ set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%MAVEN_HOME%\bin;%PATH%
+
+
+Building And Running The SCA Samples Using Ant
+----------------------------------------------
+The build.xml files provided with the Apache Tuscany SCA samples are designed
+to work with the binary distribution. They rely on the tuscany-sca-manifest.jar
+to describe the class path and this jar is only provided as part of the
+binary distribution.
+
+The binary distribution of SCA also includes precompiled versions of each sample.
+If you look in the target directory of each sample you will see this jar file. To
+run a sample based on all of the precompiled artifacts all you have to do is:
+
+cd <sampledir>
+ant run
+
+Check each <sampledir>/README file as some samples require that two progams are
+run to get the desired result, for example, the two samples that show how
+to build extensions are run from their associated application samples.
+
+If you want to rebuild a sample, for example, if you have changed it, do the
+following:
+
+cd <sampledir>
+ant compile
+
+Once the sample is built you have the option of running the sample in whatever
+way best suits you. Two alternatives are provided in the ant build files.
+
+The compile target builds the class files and then builds the jar so you can use
+the same command as before:
+
+ant run
+
+This will use the generated jar to run the samples. The command line version of
+this is:
+
+on Windows
+
+java -cp ..\..\features\tuscany-sca-manifest.jar;target\<sample jar file> <sample runnable class>
+
+for example : java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator.jar calculator.CalculatorClient
+
+on *nix
+
+java -cp ../../features/tuscany-sca-manifest.jar:target/<sample jar file> <sample runnable class>
+
+for example : java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator.jar calculator.CalculatorClient
+
+
+You can use the compiled classes directly using
+
+ant run-classes
+
+The command line version of this is:
+
+on Windows
+
+java -cp ..\..\features\tuscany-sca-manifest.jar;target\classes <sample runnable class>
+
+for example : java -cp ..\..\features\tuscany-sca-manifest.jar;target\classes calculator.CalculatorClient
+
+on *nix
+
+java -cp ../../features/tuscany-sca-manifest.jar:target/classes <sample runnable class>
+
+for example : java -cp ../../features/tuscany-sca-manifest.jar:target/classes calculator.CalculatorClient
+
+The class specified on the command of course depends on which sample you want to
+run. In the examples we have used we are running the CalculatorClient from the calculator sample.
+
+
+Building And Running The SCA Samples Using Maven
+------------------------------------------------
+
+The Maven build process will work from both source and binary distributions.
+To build and test all of the Apache Tuscany SCA sources, including the samples,
+do the following.
+
+cd sca
+mvn
+
+This will take a little while to complete. Experience with Maven tells us that
+sometimes there are problems downloading the dependencies that Apache Tuscany
+SCA requires. If Maven reports that it cannot download required dependencies
+try running the Maven build again.
+
+Once you have all of the source built you can build and run each sample
+independently if required.
+
+cd <sampledir>
+mvn
+
+When using Maven the samples are run within JUnit test cases and so you will
+sometimes not see any test output. You will always see an indication of test
+success or failure.
+
+Using The Samples In An IDE
+---------------------------------------------
+The easiest way to use the samples in an IDE is to use Maven to generate all
+of the IDE project files for you automatically. This works best if you
+generate IDE projects for all of the Apache Tuscany modules. You can then
+include the ones you are interested in working with in you IDE.
+
+To build IDE project files for all of the modules in Apache Tuscany SCA;
+
+cd sca
+
+If you are an Eclipse user do the following
+
+mvn -Peclipse
+
+If you are an IDEA user do the following
+
+mvn idea:idea
+
+These commands generate project files for each module in Apache Tuscany SCA.
+The modules you are interested in can now be included in your IDE, for example,
+in Eclipse, if you create a new Java project and use the option to "create a
+new project from existing source" you can specify an SCA module directory,
+which includes the generated project files, and Eclipse will treat it like any
+other Java project.
+
+Using The Samples In An IDE Without Maven
+-----------------------------------------
+We don't provide any IDE project files with our distributions so you will have to
+import the sample files into your IDE manually. Here's an example of how it can be
+done using Eclipse.
+
+In a new or existing workspace
+ Create a new java project to represent the sample you want to work on, e.g.
+ launcher-embedded-jse
+ Import all of the sample code and resources into this project, e.g.
+ File, Import and then select tuscany-sca-1.0-incubating\samples\launcher-embedded-jse from the filesystem
+ Configure the source path to include
+ src/main/java
+ src/main/resources
+ Configure the output folder to be
+ target
+ Configure the build path to include the manifest jar tuscany-sca-manifiest.jar provided in
+ features
+ For here you have run;
+ the unit test (loads a sequence of contributions and runs them)
+ SampleJSELauncher (you'll need to add the name of the contribution to run as a parameter)
+ build.xml (you'll need to set tuscany.home to point to distribution\all\target\apache-tuscany-sca-all-2.0-SNAPSHOT.dir\tuscany-sca-2.0-SNAPSHOT)
+
+The details of how to do this for other development environments will
+vary but the process will be similar.
+
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/README b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/README
new file mode 100644
index 0000000000..18ba62d494
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/README
@@ -0,0 +1 @@
+Please look at the README files in the subdirectories of this directory for descriptions of the sample contributions.
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/build-dojo.xml b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/build-dojo.xml
new file mode 100644
index 0000000000..36714c67fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/build-dojo.xml
@@ -0,0 +1,64 @@
+<?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 name="DojoZipInstaller">
+
+
+ <property name="dojo.version" value="1.3.0"/>
+ <property name="dojo.zip" value="${localRepository}/org/dojotoolkit/dojo/${dojo.version}/dojo-${dojo.version}.zip"/>
+ <property name="unpack.location" value="${basedir}/src/main/webapp/dojo"/>
+
+
+ <target name="check-dojo-installed">
+ <condition property="already.installed" >
+ <available file="${localRepository}/org/dojotoolkit/dojo/${dojo.version}/dojo-${dojo.version}.zip"/>
+ </condition>
+ </target>
+
+ <target name="check-dojo-unpacked">
+ <condition property="already.unpacked" >
+ <available file="${unpack.location}"/>
+ </condition>
+ </target>
+
+ <target name="unpack-dojo-files" depends="check-dojo-installed, check-dojo-unpacked" unless="already.unpacked">
+ <fail message="dojo zip file not installed in local repository: ${localRepository}" unless="already.installed"/>
+ <mkdir dir="${basedir}/target/dojo-unpack-temp/"/>
+ <unzip src="${localRepository}/org/dojotoolkit/dojo/${dojo.version}/dojo-${dojo.version}.zip"
+ dest="${basedir}/target/dojo-unpack-temp/"
+ overwrite="false"
+ encoding="native-encoding">
+ <patternset>
+ <include name="dojo-${dojo.version}/dojo/**"/>
+ <exclude name="dojo-${dojo.version}/dojo/tests/**"/>
+ <exclude name="dojo-${dojo.version}/dijit/**"/>
+ <exclude name="dojo-${dojo.version}/dojox/**"/>
+ <exclude name="dojo-${dojo.version}/util/**"/>
+ </patternset>
+ </unzip>
+ <move file="${basedir}/target/dojo-unpack-temp/dojo-${dojo.version}"
+ tofile="${unpack.location}"
+ verbose="true"/>
+ <delete dir="${basedir}/target/dojo-unpack-temp/"/>
+ </target>
+
+ <target name="clean-dojo-files">
+ <delete dir="${unpack.location}"/>
+ </target>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/pom.xml b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/pom.xml
new file mode 100644
index 0000000000..586937b5e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/pom.xml
@@ -0,0 +1,126 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-binding-jsonrpc-calculator-webapp</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution binding-jsonrpc Calculator WebApp</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webapp</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.dojotoolkit</groupId>
+ <artifactId>dojo</artifactId>
+ <version>1.3.0</version>
+ <type>zip</type>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dojo-files</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant antfile="./build-dojo.xml" target="unpack-dojo-files">
+ <property name="localRepository" value="${settings.localRepository}"/>
+ <property name="artifactId" value="${artifactId}"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ <execution>
+ <id>clean-dojo-files</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant antfile="./build-dojo.xml" target="clean-dojo-files">
+ <property name="localRepository" value="${settings.localRepository}"/>
+ <property name="artifactId" value="${artifactId}"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddBean.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddBean.java
new file mode 100644
index 0000000000..71724ee7ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddBean.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 calculator;
+
+public class AddBean {
+ private static final String DEFAULT_S = "default string";
+ private static final Boolean DEFAULT_B = false;
+
+ protected double n1;
+ protected double n2;
+ protected double n3;
+
+ protected Boolean b;
+ protected String s;
+ protected int x;
+ protected Integer y;
+
+ public double getN1() {
+ return n1;
+ }
+
+ public void setN1(double n1) {
+ this.n1 = n1;
+ }
+
+ public double getN2() {
+ return n2;
+ }
+
+ public void setN2(double n2) {
+ this.n2 = n2;
+ }
+
+ public double getN3() {
+ return n3;
+ }
+
+ public void setN3(double n3) {
+ this.n3 = n3;
+ }
+
+ public Boolean getB() {
+ return b;
+ }
+
+ public void setB(Boolean b) {
+ this.b = b;
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public Integer getY() {
+ return y;
+ }
+
+ public void setY(Integer y) {
+ this.y = y;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..03e844d09c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Add service interface
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+ AddBean addComplexParam(AddBean aBean);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..e16b352021
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/AddServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Add service
+ */
+@Service(AddService.class)
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+ public AddBean addComplexParam(AddBean aBean) {
+ aBean.setN3(aBean.getN1() + aBean.getN2());
+ System.out.println("Adding " + aBean.getN1() + " to " + aBean.getN1() + " gives " + aBean.getN3());
+ return aBean;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..78eea39c71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..d32cc73815
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Service(CalculatorService.class)
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ AddBean aBean = new AddBean();
+ // So data to test different types
+ aBean.setB(true);
+ aBean.setS("Fred");
+ aBean.setX(27);
+ aBean.setY(58);
+
+ // the numbers to be added
+ aBean.setN1(n1);
+ aBean.setN2(n2);
+
+ aBean = addService.addComplexParam(aBean);
+
+ return aBean.getN3();
+ //return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..ef6a8b375b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..ddd7b9cc6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Service(DivideService.class)
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..db568cc762
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..cc0de498d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Multiply service.
+ */
+@Service(MultiplyService.class)
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..56ee372fc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..22e95f7f54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the subtract service.
+ */
+@Service(SubtractService.class)
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..dc0df8756c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,53 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ <service name="AddService">
+ <tuscany:binding.jsonrpc />
+ </service>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..b7e216baf7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+<web-app 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>Apache Tuscany Contribution binding-jsonrpc Calculator WebApp Sample</display-name>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>calculate.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/calculate.html b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/calculate.html
new file mode 100644
index 0000000000..6d22806e8f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/main/webapp/calculate.html
@@ -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.
+-->
+<html>
+
+<head>
+ <title>Apache Tuscany binding-jsonrpc Calculator WebApp with DOJO Sample</title>
+
+ <script type="text/javascript" src="dojo/dojo/dojo.js"></script>
+
+ <script language="JavaScript">
+ dojo.require("dojo.rpc.JsonService");
+
+ var addService = new dojo.rpc.JsonService("AddServiceComponent/AddService?smd");
+
+ function calculate() {
+ var addRequest = new Object();
+ addRequest.n1 = 1;
+ addRequest.n2 = 1;
+ addRequest.n3 = 0;
+ addRequest.b = true;
+ addRequest.s = "fred";
+ addRequest.x = 2;
+ addRequest.y = 3;
+
+ addService.addComplexParam(addRequest).addCallback(calculateResponse);
+ }
+
+ function calculateResponse(reply) {
+ document.getElementById('result').innerHTML=reply.n3;
+ }
+
+ </script>
+
+</head>
+
+<body>
+
+<h2>Apache Tuscany binding-jsonrpc Calculator WebApp with DOJO Sample</h2>
+
+ 1 + 1 =
+ <button name="submit" onclick="calculate()">Calculate</button>
+
+ <div id='result'/>
+
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/test/java/calculator/CalculatorTestCase.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..1952eb4a6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator-webapp/src/test/java/calculator/CalculatorTestCase.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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * A unit test of the basic Java implementation classes in this contribution
+ * without using SCA
+ */
+public class CalculatorTestCase {
+
+ @Test
+ public void testCalculator() throws Exception {
+ AddService add = new AddServiceImpl();
+ SubtractService subtract = new SubtractServiceImpl();
+ MultiplyService multiply = new MultiplyServiceImpl();
+ DivideService divide = new DivideServiceImpl();
+
+ CalculatorServiceImpl calculator = new CalculatorServiceImpl();
+
+ calculator.setAddService(add);
+ calculator.setSubtractService(subtract);
+ calculator.setMultiplyService(multiply);
+ calculator.setDivideService(divide);
+
+ assertEquals(calculator.add(3, 2), 5.0, 0);
+ assertEquals(calculator.subtract(3, 2), 1.0, 0);
+ assertEquals(calculator.multiply(3, 2), 6.0, 0);
+ assertEquals(calculator.divide(3, 2), 1.5, 0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/README b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/README
new file mode 100644
index 0000000000..1e5bc9c584
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/README
@@ -0,0 +1,26 @@
+Calculator Sample Contribution
+==============================
+
+This sample contribution implements a simple calculator using SCA components.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive) Take a look there for instructions on how to launch
+this sample contribution.
+
+Sample Overview
+---------------
+The sample provides a single calculator service with a default SCA (java)
+binding. The CalculatorClient exercises this interface by calling add,
+subtract, multiply and divide operations. This results in messages passing to
+the appropriate components in the composite across the local wires.
+
+Amongst the other output created by the launcher/contribution combination, you should see the following output ...
+
+run:
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/build.xml b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/build.xml
new file mode 100644
index 0000000000..7d0ce122dd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/build.xml
@@ -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.
+-->
+
+<project name="calculator" default="compile">
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="sample-contribution-binding-sca-calculator.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+</project>
+
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/pom.xml b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/pom.xml
new file mode 100644
index 0000000000..7e08ce52be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/pom.xml
@@ -0,0 +1,58 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-binding-jsonrpc-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution binding-jsonrpc Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddBean.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddBean.java
new file mode 100644
index 0000000000..bb39e961b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddBean.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 calculator;
+
+public class AddBean {
+
+ protected double n1;
+ protected double n2;
+ protected double n3;
+
+ protected Boolean b;
+ protected String s;
+ protected int x;
+ protected Integer y;
+
+ public double getN1() {
+ return n1;
+ }
+
+ public void setN1(double n1) {
+ this.n1 = n1;
+ }
+
+ public double getN2() {
+ return n2;
+ }
+
+ public void setN2(double n2) {
+ this.n2 = n2;
+ }
+
+ public double getN3() {
+ return n3;
+ }
+
+ public void setN3(double n3) {
+ this.n3 = n3;
+ }
+
+ public Boolean getB() {
+ return b;
+ }
+
+ public void setB(Boolean b) {
+ this.b = b;
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public Integer getY() {
+ return y;
+ }
+
+ public void setY(Integer y) {
+ this.y = y;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..03e844d09c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Add service interface
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+ AddBean addComplexParam(AddBean aBean);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..8eabfa6773
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/AddServiceImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Add service
+ */
+@Service(AddService.class)
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+ public AddBean addComplexParam(AddBean aBean) {
+ aBean.setN3(aBean.getN1() + aBean.getN2());
+ return aBean;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..1df1f31c48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorClient.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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class CalculatorClient {
+
+ private CalculatorService calculatorService;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ @Init
+ public void calculate() {
+ // Calculate
+ System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader());
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..78eea39c71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..d32cc73815
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Service(CalculatorService.class)
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ AddBean aBean = new AddBean();
+ // So data to test different types
+ aBean.setB(true);
+ aBean.setS("Fred");
+ aBean.setX(27);
+ aBean.setY(58);
+
+ // the numbers to be added
+ aBean.setN1(n1);
+ aBean.setN2(n2);
+
+ aBean = addService.addComplexParam(aBean);
+
+ return aBean.getN3();
+ //return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..ef6a8b375b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..ddd7b9cc6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Service(DivideService.class)
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..db568cc762
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..cc0de498d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Multiply service.
+ */
+@Service(MultiplyService.class)
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..56ee372fc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..22e95f7f54
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the subtract service.
+ */
+@Service(SubtractService.class)
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/Calculator.composite b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..5f1add2431
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/Calculator.composite
@@ -0,0 +1,53 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ <service name="AddService">
+ <tuscany:binding.jsonrpc uri="http://localhost:8085/AddServiceComponent/AddService"/>
+ </service>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/CalculatorClient.composite b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/CalculatorClient.composite
new file mode 100644
index 0000000000..dfd32761be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/CalculatorClient.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="CalculatorClient">
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..70aab0e051
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+ <deployable composite="sample:CalculatorClient"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..1952eb4a6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/contribution-calculator/src/test/java/calculator/CalculatorTestCase.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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * A unit test of the basic Java implementation classes in this contribution
+ * without using SCA
+ */
+public class CalculatorTestCase {
+
+ @Test
+ public void testCalculator() throws Exception {
+ AddService add = new AddServiceImpl();
+ SubtractService subtract = new SubtractServiceImpl();
+ MultiplyService multiply = new MultiplyServiceImpl();
+ DivideService divide = new DivideServiceImpl();
+
+ CalculatorServiceImpl calculator = new CalculatorServiceImpl();
+
+ calculator.setAddService(add);
+ calculator.setSubtractService(subtract);
+ calculator.setMultiplyService(multiply);
+ calculator.setDivideService(divide);
+
+ assertEquals(calculator.add(3, 2), 5.0, 0);
+ assertEquals(calculator.subtract(3, 2), 1.0, 0);
+ assertEquals(calculator.multiply(3, 2), 6.0, 0);
+ assertEquals(calculator.divide(3, 2), 1.5, 0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-jsonrpc/pom.xml b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/pom.xml
new file mode 100644
index 0000000000..52d05e075b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-jsonrpc/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-binding-jsonrpc</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample binding.jsonrpc</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/README b/sandbox/sebastien/java/embed/samples/binding-rmi/README
new file mode 100644
index 0000000000..18ba62d494
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/README
@@ -0,0 +1 @@
+Please look at the README files in the subdirectories of this directory for descriptions of the sample contributions.
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/README b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/README
new file mode 100644
index 0000000000..2f169419ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/README
@@ -0,0 +1,34 @@
+Calculator RMI Reference Sample Contribution
+============================================
+
+This sample illustrates the use of Tuscany RMI Binding to call reference
+services that are hosted as Java RMI services.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive) Take a look there for instructions on how to launch
+this sample contribution.
+
+Sample Overview
+---------------
+This sample extends the calculator sample by replacing the local wired
+connections with RMI bindings. Instead of local add, subtract, multiply and
+divide components, an RMI service implementation now provides the
+add, subtract, multiply and divide interfaces and is hosted as an RMI server.
+References specified in the .composite file include an RMI binding which targets
+this RMI server.
+Note. As this test creates and uses local network connections you may need to
+configure your firewall, if you are running one, to allow the test to run
+successfully.
+
+Amongst the other output created by the launcher/contribution combination, you should see the following output ...
+
+
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
+
+
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/build.xml b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/build.xml
new file mode 100644
index 0000000000..fe28a46b7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/build.xml
@@ -0,0 +1,59 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 name="contribution-binding-rmi-calculator-reference" default="compile">
+
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="contribution-calculator-reference.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+</project>
+
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/pom.xml b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/pom.xml
new file mode 100644
index 0000000000..c10d764ff1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-binding-rmi-calculator-reference</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution binding-rmi Calculator Reference</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..a235e648c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/AddService.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 calculator;
+
+/**
+ * The interface for the add service
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..0f7dec116f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/CalculatorService.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 calculator;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService extends Remote {
+
+ double add(double n1, double n2) throws RemoteException;
+
+ double subtract(double n1, double n2) throws RemoteException;
+
+ double multiply(double n1, double n2) throws RemoteException;
+
+ double divide(double n1, double n2) throws RemoteException;
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..bcfd8871b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..497dafd4fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The interface for the divide service
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..376b3e5bb9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the subtract service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/resources/CalculatorRMIReference.composite b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/resources/CalculatorRMIReference.composite
new file mode 100644
index 0000000000..7455dc7d38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/main/resources/CalculatorRMIReference.composite
@@ -0,0 +1,42 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService">
+ <tuscany:binding.rmi uri="rmi://localhost:8099/CalculatorRMIService"/>
+ </reference>
+ <reference name="subtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8099/CalculatorRMIService"/>
+ </reference>
+ <reference name="multiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8099/CalculatorRMIService"/>
+ </reference>
+ <reference name="divideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8099/CalculatorRMIService"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java
new file mode 100644
index 0000000000..39d4b2fd28
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorRMIReferenceTestCase {
+
+ private static Node node;
+ private static CalculatorService calculatorService;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ CalculatorRMIServiceImpl rmiCalculatorImpl = new CalculatorRMIServiceImpl();
+ Registry rmiRegistry = LocateRegistry.createRegistry(8099);
+ rmiRegistry.bind("CalculatorRMIService", rmiCalculatorImpl);
+
+ String uri = ContributionLocationHelper.getContributionLocation(CalculatorService.class);
+ Contribution contribution = new Contribution("c1", uri);
+ node = NodeFactory.newInstance().createNode("CalculatorRMIReference.composite", contribution);
+ node.start();
+ calculatorService = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ LocateRegistry.getRegistry(8099).unbind("CalculatorRMIService");
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0, 0.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0, 0.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0, 0.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5, 0.0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java
new file mode 100644
index 0000000000..d8ded42cb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-reference/src/test/java/calculator/CalculatorRMIServiceImpl.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 calculator;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorRMIServiceImpl extends UnicastRemoteObject implements CalculatorService {
+
+ private static final long serialVersionUID = -1543948944662001428L;
+
+ public CalculatorRMIServiceImpl() throws RemoteException {
+ super();
+ }
+
+ public double add(double n1, double n2) throws RemoteException {
+ return n1 + n2;
+ }
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/README b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/README
new file mode 100644
index 0000000000..cb25027f14
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/README
@@ -0,0 +1,28 @@
+Calculator RMI Service Sample Contribution
+==========================================
+
+This sample illustrates the use of Tuscany RMI Binding to expose component
+services as Java RMI Services. It also demonstrates how a simple Java RMI
+Client application invokes the SCA Application's services exposed as RMI
+Services.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive) Take a look there for instructions on how to launch
+this sample contribution.
+
+
+Sample Overview
+---------------
+This sample extends the calculator sample by replacing the local service
+binding with an RMI binding. SO a java client can call the service exposed
+by the SCA application using an RMI client.
+
+Amongst the other output created by the launcher/contribution combination, you should see the following output ...
+
+
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/build.xml b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/build.xml
new file mode 100644
index 0000000000..888a1c88b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/build.xml
@@ -0,0 +1,59 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 name="contribution-binding-rmi-calculator-service" default="compile">
+
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="contribution-calculator-service.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+</project>
+
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/pom.xml b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/pom.xml
new file mode 100644
index 0000000000..5cd39e96bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-binding-rmi-calculator-service</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution binding-rmi Calculator Service</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..a235e648c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/AddService.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 calculator;
+
+/**
+ * The interface for the add service
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..8b6fe066a6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/AddServiceImpl.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 calculator;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..2b99485b68
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorClient.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 calculator;
+
+import java.rmi.Naming;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+ CalculatorService calculatorService = (CalculatorService)Naming.lookup("//localhost:8099/CalculatorRMIService");
+
+ // Calculate
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..3c0375924f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..bcfd8871b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..497dafd4fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The interface for the divide service
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..f7ac0b7287
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..b7dca792b2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..376b3e5bb9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the subtract service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..77b128ab8d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/resources/CalculatorRMIServer.composite b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/resources/CalculatorRMIServer.composite
new file mode 100644
index 0000000000..8b37d407f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/resources/CalculatorRMIServer.composite
@@ -0,0 +1,53 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService"/>
+ <tuscany:binding.rmi uri="rmi://localhost:8099/CalculatorRMIService"/>
+ </service>
+ <reference name="addService" target="AddServiceComponent"></reference>
+ <reference name="subtractService" target="SubtractServiceComponent"></reference>
+ <reference name="multiplyService" target="MultiplyServiceComponent"></reference>
+ <reference name="divideService" target="DivideServiceComponent"></reference>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8d6012e5c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/test/java/calculator/CalculatorRMIServerTestCase.java b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/test/java/calculator/CalculatorRMIServerTestCase.java
new file mode 100644
index 0000000000..0e352db9bb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/contribution-calculator-service/src/test/java/calculator/CalculatorRMIServerTestCase.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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import java.rmi.Naming;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorRMIServerTestCase {
+
+ private static Node node;
+ private static CalculatorService calculatorService;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ String uri = ContributionLocationHelper.getContributionLocation(CalculatorService.class);
+ Contribution contribution = new Contribution("c1", uri);
+ node = NodeFactory.newInstance().createNode("CalculatorRMIServer.composite", contribution);
+ node.start();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ // Calculate
+ calculatorService = (CalculatorService)Naming.lookup("//localhost:8099/CalculatorRMIService");
+ assertEquals(calculatorService.add(3, 2), 5.0, 0.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0, 0.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0, 0.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5, 0.0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-rmi/pom.xml b/sandbox/sebastien/java/embed/samples/binding-rmi/pom.xml
new file mode 100644
index 0000000000..073687983d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-rmi/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-binding-rmi</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample binding.rmi</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator-reference</module>
+ <module>contribution-calculator-service</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/README b/sandbox/sebastien/java/embed/samples/binding-sca/README
new file mode 100644
index 0000000000..18ba62d494
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/README
@@ -0,0 +1 @@
+Please look at the README files in the subdirectories of this directory for descriptions of the sample contributions.
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/README b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/README
new file mode 100644
index 0000000000..4777c5ad88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/README
@@ -0,0 +1,26 @@
+Calculator Sample Contribution
+==============================
+
+This sample contribution implements a simple calculator using SCA components.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive) Take a look there for instructions on how to launch
+this sample contribution.
+
+Sample Overview
+---------------
+The sample provides a single calculator service with a default SCA (java)
+binding. The CalculatorClient exercises this interface by calling add,
+subtract, multiply and divide operations. This results in messages passing to
+the appropriate components in the composite across the local wires.
+
+Amongst the other output created by the launcher/contribution combination, you should see the following output ...
+
+run:
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/build.xml b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/build.xml
new file mode 100644
index 0000000000..c109d89c75
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/build.xml
@@ -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.
+-->
+
+<project name="calculator" default="compile">
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="sample-contribution-binding-sca-calculator.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+</project>
+
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/pom.xml b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/pom.xml
new file mode 100644
index 0000000000..c877155853
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/pom.xml
@@ -0,0 +1,58 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-binding-sca-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution binding-sca Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/AddService.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 calculator;
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..bb75bb2337
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/AddServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Add service
+ */
+@Service(AddService.class)
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..afd5ea48fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorClient.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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class CalculatorClient {
+
+ private CalculatorService calculatorService;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ @Init
+ public void calculate() {
+ // Calculate
+ System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader());
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..ce1cdaae5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..fc53393d23
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Service(CalculatorService.class)
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..b1250ed9f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Service(DivideService.class)
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..11f68c66e3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the Multiply service.
+ */
+@Service(MultiplyService.class)
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..30e59bf668
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * An implementation of the subtract service.
+ */
+@Service(SubtractService.class)
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/Calculator.composite b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..05bea57944
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/Calculator.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/CalculatorClient.composite b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/CalculatorClient.composite
new file mode 100644
index 0000000000..dfd32761be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/CalculatorClient.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="CalculatorClient">
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3e64787ce4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+ <deployable composite="sample:CalculatorClient"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..9d3024f451
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/contribution-calculator/src/test/java/calculator/CalculatorTestCase.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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * A unit test of the basic Java implementation classes in this contribution
+ * without using SCA
+ */
+public class CalculatorTestCase {
+
+ @Test
+ public void testCalculator() throws Exception {
+ AddService add = new AddServiceImpl();
+ SubtractService subtract = new SubtractServiceImpl();
+ MultiplyService multiply = new MultiplyServiceImpl();
+ DivideService divide = new DivideServiceImpl();
+
+ CalculatorServiceImpl calculator = new CalculatorServiceImpl();
+
+ calculator.setAddService(add);
+ calculator.setSubtractService(subtract);
+ calculator.setMultiplyService(multiply);
+ calculator.setDivideService(divide);
+
+ assertEquals(calculator.add(3, 2), 5.0, 0);
+ assertEquals(calculator.subtract(3, 2), 1.0, 0);
+ assertEquals(calculator.multiply(3, 2), 6.0, 0);
+ assertEquals(calculator.divide(3, 2), 1.5, 0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-sca/pom.xml b/sandbox/sebastien/java/embed/samples/binding-sca/pom.xml
new file mode 100644
index 0000000000..e3cc9d6e43
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-sca/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-binding-sca</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample binding.sca</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/README b/sandbox/sebastien/java/embed/samples/binding-ws/README
new file mode 100644
index 0000000000..18ba62d494
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/README
@@ -0,0 +1 @@
+Please look at the README files in the subdirectories of this directory for descriptions of the sample contributions.
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/README b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/README
new file mode 100644
index 0000000000..a1f34e0e8a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/README
@@ -0,0 +1,25 @@
+Calculator Contribution Sample
+==============================
+
+This directory contains code which implements a simple calculator SCA contribution.
+
+The contribution can be run as a tuscany application using one of the tuscany launchers
+as described in the README in the root directory of the samples.
+
+Sample Overview
+---------------
+The sample provides a single calculator service with a default SCA (java)
+binding. The launcher exercises this interface by calling add,
+subtract, multiply and divide operations. This results in messages passing to
+the appropriate components in the composite across the local wires.
+
+You should see the following output (depending on the launcher you use, this output
+may be surrounded by other output).
+
+run:
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
+
+
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/build.xml b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/build.xml
new file mode 100644
index 0000000000..69661f7b5e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/build.xml
@@ -0,0 +1,55 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="binding-ws-calculator" default="compile">
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="contribution-binding-ws-calculator.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/calculator.odg b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/calculator.odg
new file mode 100644
index 0000000000..c2646f7d5e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/calculator.odg
Binary files differ
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/calculator.png b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/calculator.png
new file mode 100644
index 0000000000..476306e5f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/calculator.png
Binary files differ
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/pom.xml b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/pom.xml
new file mode 100644
index 0000000000..a177a043d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/pom.xml
@@ -0,0 +1,54 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-binding-ws-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution binding-ws Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..138213b5fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/AddService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Add service interface
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..caf4d358df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/AddServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..ad87375529
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/CalculatorService.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 calculator;
+
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..d3fa7a8f41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..ef6a8b375b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..cd91935f08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..db568cc762
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..c85357fcd8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..56ee372fc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..1b669084d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/resources/Calculator.composite b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..3688ebcb85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/resources/Calculator.composite
@@ -0,0 +1,54 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" >
+ <binding.ws uri="http://localhost:8085/AddServiceComponent"/>
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ <service name="AddService">
+ <binding.ws uri="http://localhost:8085/AddServiceComponent"/>
+ </service>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3a7548cd47
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..1952eb4a6e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/contribution-calculator/src/test/java/calculator/CalculatorTestCase.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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * A unit test of the basic Java implementation classes in this contribution
+ * without using SCA
+ */
+public class CalculatorTestCase {
+
+ @Test
+ public void testCalculator() throws Exception {
+ AddService add = new AddServiceImpl();
+ SubtractService subtract = new SubtractServiceImpl();
+ MultiplyService multiply = new MultiplyServiceImpl();
+ DivideService divide = new DivideServiceImpl();
+
+ CalculatorServiceImpl calculator = new CalculatorServiceImpl();
+
+ calculator.setAddService(add);
+ calculator.setSubtractService(subtract);
+ calculator.setMultiplyService(multiply);
+ calculator.setDivideService(divide);
+
+ assertEquals(calculator.add(3, 2), 5.0, 0);
+ assertEquals(calculator.subtract(3, 2), 1.0, 0);
+ assertEquals(calculator.multiply(3, 2), 6.0, 0);
+ assertEquals(calculator.divide(3, 2), 1.5, 0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/binding-ws/pom.xml b/sandbox/sebastien/java/embed/samples/binding-ws/pom.xml
new file mode 100644
index 0000000000..bfac74c8c0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/binding-ws/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-binding-ws</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample binding.ws</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/samples/calculator-osgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1ebd35b30a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Private-Package: calculator;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Calculator OSGi Sample
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: false
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1223949424781
+Bundle-Activator: calculator.CalculatorActivator
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Calculator OSGi Sample
+Import-Package: org.apache.tuscany.sca.node;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.osgi.framework;version="1.4"
+Bundle-SymbolicName: sample-calculator-osgi
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/README b/sandbox/sebastien/java/embed/samples/calculator-osgi/README
new file mode 100644
index 0000000000..c416ad96a0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/README
@@ -0,0 +1,99 @@
+Calculator Sample
+=================
+This sample implements a simple calculator using SCA components and run it in a OSGi environment.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+If you just want to run it to see what happens open a command prompt, navigate
+to this sample directory and do:
+
+ant run
+
+OR if you don't have ant, on Windows do
+
+java -jar ..\..\features\tuscany-sca-equinox-manifest.jar -composite Calculator.composite -config ..\..\features\configuration\ -ttl 0 target\sample-calculator-osgi.jar
+
+and on *nix do
+
+java -jar ../../features/tuscany-sca-equinox-manifest.jar -composite Calculator.composite -config ../../features/configuration/ -ttl 0 target/sample-calculator-osgi.jar
+
+Sample Overview
+---------------
+The sample provides a single calculator service with a default SCA (java)
+binding. The CalculatorClient exercises this interface by calling add,
+subtract, multiply and divide operations. This results in messages passing to
+the appropriate components in the composite across the local wires.
+
+calculator/
+ src/
+ main/
+ java/
+ calculator/
+ CalculatorService.java - the first component, calls +-/* as
+ appropriate
+ CalculatorServiceImpl.java
+ AddService.java - adds two numbers
+ AddServiceImpl.java
+ SubtractService.java - subtracts one number from another
+ SubtractServiceImpl.java
+ MultiplyService.java - multiplies two numbers
+ MultiplyServiceImpl.java
+ DivideService.java - divides one number by another
+ DivideServiceImpl.java
+ CalculatorClient.java - starts the SCA Runtime and
+ deploys the Calculator.composite.
+ It then calls the deployed Calculator
+ Components services
+ resources/
+ Calculator.composite - the SCA assembly for this sample
+ test/
+ java/
+ calculator/
+ CalculatorTestCase.java - JUnit test case
+ calculator.png - a pictorial representation of the sample
+ .composite file
+ build.xml - the Ant build file
+ pom.xml - the Maven build file
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+With the binary distribution the sample can be built and run using Ant as
+follows
+
+cd calculator
+ant compile
+ant run
+
+You should see the following output from the run target.
+
+run:
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
+
+Building And Running The Sample Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built and run
+using Maven as follows.
+
+cd calculator
+mvn
+
+You should see the following output from the test phase.
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running calculator.CalculatorTestCase
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.272 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+This shows that the Junit test cases have run successfully.
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/build.xml b/sandbox/sebastien/java/embed/samples/calculator-osgi/build.xml
new file mode 100644
index 0000000000..46522211f9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/build.xml
@@ -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.
+-->
+<project name="calculator-osgi" default="run">
+ <property name="sample.name" value="${ant.project.name}"/>
+ <property name="sample.jar" value="./target/sample-${sample.name}.jar" />
+
+ <target name="init">
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5">
+ <classpath>
+ <fileset dir="../../features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="${sample.jar}" basedir="target/classes">
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <java jar="../../features/tuscany-sca-manifest.jar" fork="true">
+ <jvmarg value="-Djava.util.logging.config.file=../logging.properties"/>
+ <!-- optional to set the deployable composite -->
+ <arg value="-composite"/>
+ <arg value="Calculator.composite"/>
+ <!-- stop the node after the application runs -->
+ <arg value="-ttl"/>
+ <arg value="0"/>
+ <arg value="${sample.jar}"/>
+ </java>
+ </target>
+
+ <target name="run-equinox" depends="compile">
+ <java jar="../../features/tuscany-sca-equinox-manifest.jar" fork="true">
+ <jvmarg value="-Djava.util.logging.config.file=../logging.properties"/>
+ <arg value="-composite"/>
+ <arg value="Calculator.composite"/>
+ <arg value="-config"/>
+ <arg value="../../features/configuration"/>
+ <arg value="-ttl"/>
+ <arg value="0"/>
+ <arg value="${sample.jar}"/>
+ </java>
+ </target>
+
+ <target name="clean">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+</project>
+
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/pom.xml b/sandbox/sebastien/java/embed/samples/calculator-osgi/pom.xml
new file mode 100644
index 0000000000..6580790162
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/pom.xml
@@ -0,0 +1,116 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-calculator-osgi</artifactId>
+ <name>Apache Tuscany SCA Sample Calculator OSGi</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <buildcommands>
+ <buildcommand>org.eclipse.pde.ManifestBuilder</buildcommand>
+ <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+ </buildcommands>
+ <projectnatures>
+ <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+ <projectnature>org.eclipse.pde.PluginNature</projectnature>
+ </projectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+ </classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-osgi-junit-plugin</artifactId>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>osgi-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>osgi.configuration.area</name>
+ <value>${project.build.directory}/equinox</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/AddService.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 calculator;
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..7ca8fb04b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java
new file mode 100644
index 0000000000..4408568629
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.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 calculator;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Bundle Activator for Calculator
+ *
+ */
+public class CalculatorActivator implements BundleActivator {
+ private Node node;
+
+ public void start(BundleContext context) throws Exception {
+ try {
+ NodeFactory factory = NodeFactory.newInstance();
+ String url = ContributionLocationHelper.getContributionLocation(getClass());
+ Contribution contrib = new Contribution("c1", url);
+ node = factory.createNode("Calculator.composite", contrib);
+ node.start();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ if (node != null) {
+ node.stop();
+ node = null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..afd5ea48fc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class CalculatorClient {
+
+ private CalculatorService calculatorService;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ @Init
+ public void calculate() {
+ // Calculate
+ System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader());
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..c89043276e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorService.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 calculator;
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..39f55ca31f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..1323edf55a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..91b803bc9e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..58cc4a3547
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/resources/Calculator.composite b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..c5e636f769
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/main/resources/Calculator.composite
@@ -0,0 +1,54 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..d6a3ccb24e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.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 calculator;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator composition.
+ */
+public class CalculatorTestCase {
+
+ private static Node node;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation(CalculatorClient.class);
+ node = NodeFactory.newInstance().createNode("Calculator.composite", new Contribution("test", location));
+ System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader());
+ node.start();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testDummy() throws Exception {
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-scaclient/README b/sandbox/sebastien/java/embed/samples/calculator-scaclient/README
new file mode 100644
index 0000000000..97058ca4c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-scaclient/README
@@ -0,0 +1,13 @@
+To run an application that uses the SCA client API to send messages to the
+Calculator service running in the domain do the following
+
+First start one of the Calculator based contributions. For example,
+
+cd samples/binding-sca/contribution-calculator
+follow the instructions in the README there
+
+Then run the the SCA client by doing the following:
+
+cd samples/calculator-scaclient
+mvn exec:java
+
diff --git a/sandbox/sebastien/java/embed/samples/calculator-scaclient/pom.xml b/sandbox/sebastien/java/embed/samples/calculator-scaclient/pom.xml
new file mode 100644
index 0000000000..6ec8480192
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-scaclient/pom.xml
@@ -0,0 +1,69 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-calculator-scaclient</artifactId>
+ <name>Apache Tuscany SCA Sample Calcualtor SCAClient</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>sample.CalculatorSCAClient</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/calculator-scaclient/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/calculator-scaclient/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-scaclient/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/calculator-scaclient/src/main/java/sample/CalculatorSCAClient.java b/sandbox/sebastien/java/embed/samples/calculator-scaclient/src/main/java/sample/CalculatorSCAClient.java
new file mode 100644
index 0000000000..edbf528517
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/calculator-scaclient/src/main/java/sample/CalculatorSCAClient.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 sample;
+
+import java.net.URI;
+
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+import calculator.CalculatorService;
+
+public class CalculatorSCAClient {
+
+ public static void main(String[] args) throws NoSuchDomainException, NoSuchServiceException {
+
+ String domainURI = "default";
+ String name = "world";
+
+ if (args.length == 2) {
+ domainURI= args[0];
+ name = args[1];
+ } else if (args.length == 1) {
+ domainURI= args[0];
+ }
+
+ System.out.println("using domain uri: " + domainURI);
+ System.out.println("using name: " + name);
+
+ SCAClientFactory factory = SCAClientFactory.newInstance(URI.create(domainURI));
+ CalculatorService calculator = factory.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ System.out.println("Calling CalculatorService.add(2, 3)");
+ System.out.println(calculator.add(3, 2));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/LICENSE b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/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/sebastien/java/embed/samples/dosgi-calculator-operations/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..82a803e3a6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Export-Package: calculator.dosgi.operations;version="1.0.0"
+Bundle-Version: 1.0.0
+Bundle-Name: calculator.dosgi.operations
+Bundle-Activator: calculator.dosgi.operations.impl.OperationsActivator
+Bundle-ManifestVersion: 2
+Import-Package: calculator.dosgi.operations;version="[1.0.0,1.0.0]",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.osgi.framework,
+ org.osgi.service.component;resolution:=optional,
+ org.osgi.service.packageadmin
+Bundle-SymbolicName: calculator.dosgi.operations
+Bundle-Vendor: The Apache Software Foundation
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Service-Component-Disabled: OSGI-INF/add-component.xml,
+ OSGI-INF/subtract-component.xml,
+ OSGI-INF/multiply-component.xml,
+ OSGI-INF/divide-component.xml
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/NOTICE b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/add-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/add-component.xml
new file mode 100644
index 0000000000..99845257ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/add-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="AddComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.AddServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.AddService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/blueprint/operations-module.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/blueprint/operations-module.xml
new file mode 100644
index 0000000000..f6b5f4690e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/blueprint/operations-module.xml
@@ -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.
+-->
+<!-- A sample module-context.xml for OSGI RFC 124 (BluePrint Service) -->
+<components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <component id="AddComponent" class="calculator.dosgi.operations.impl.AddServiceImpl">
+ </component>
+ <component id="SubtractComponent" class="calculator.dosgi.operations.impl.SubtractServiceImpl">
+ </component>
+ <component id="MultiplyComponent" class="calculator.dosgi.operations.impl.MultiplyServiceImpl">
+ </component>
+ <component id="DivideComponent" class="calculator.dosgi.operations.impl.DivideServiceImpl">
+ </component>
+
+ <!-- We can derive the SCA services for the implementation.osgi -->
+ <service id="AddService" ref="AddComponent" interface="calculator.dosgi.operations.AddService">
+ </service>
+ <service id="SubtractService" ref="SubtractComponent" interface="calculator.dosgi.operations.SubtractService">
+ </service>
+ <service id="MultiplyService" ref="MultiplyComponent" interface="calculator.dosgi.operations.MultiplyService">
+ </service>
+ <service id="DivideService" ref="DivideComponent" interface="calculator.dosgi.operations.DivideService">
+ </service>
+</components> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/divide-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/divide-component.xml
new file mode 100644
index 0000000000..322d4daf2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/divide-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="DivideComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.DivideServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.DivideService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/multiply-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/multiply-component.xml
new file mode 100644
index 0000000000..b9ca777bd8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/multiply-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="MultiplyComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.MultiplyServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.MultiplyService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType
new file mode 100644
index 0000000000..fced5b7840
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType
@@ -0,0 +1,54 @@
+<?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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
+
+
+ <!-- The service elment defines an SCA proxy to a remote OSGi service -->
+ <service name="AddService">
+ <interface.java interface="calculator.dosgi.operations.AddService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+ <service name="SubtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+ <service name="MultiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+ <service name="DivideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+</componentType>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.composite b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.composite
new file mode 100644
index 0000000000..c7250912b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.composite
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://calculator.dosgi"
+ name="OperationsComposite">
+
+ <component name="OperationsComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi.operations" bundleVersion="1.0.0" />
+ <service name="AddService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
+ </service>
+ <service name="SubtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
+ </service>
+ <service name="MultiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
+ </service>
+ <service name="DivideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
+ </service>
+
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/subtract-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/subtract-component.xml
new file mode 100644
index 0000000000..1472f5a976
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/OSGI-INF/subtract-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="SubtractComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.SubtractServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.SubtractService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/README b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/README
new file mode 100644
index 0000000000..57126842a4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/README
@@ -0,0 +1,185 @@
+Distributed OSGi Calculator Sample
+==================================
+This sample implements a distributed calculator using Distributed OSGi (RFC 119) over SCA.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.5.0-v20090520.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.5.0-v20090520.jar -configuration ../../features/configuration -clean -console
+
+You should see the osgi console:
+
+osgi>
+
+osgi> Jun 22, 2009 1:32:27 PM org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoveryActivator start
+INFO: Equinox-based service discoverer is now configured.
+
+You can run "ss" command under the osgi> to see the status of the bundles.
+osgi> ss
+
+Then you can install and start the calculator.dosgi bundle:
+
+osgi> install file:./target/sample-dosgi-calculator-operations.jar
+Bundle id is 198
+
+osgi> start 198
+Nov 4, 2009 9:51:56 AM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Starting calculator.dosgi.operations_1.0.0 [198]
+Nov 4, 2009 9:51:56 AM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Registering calculator.dosgi.operations.AddService
+Nov 4, 2009 9:51:56 AM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Registering calculator.dosgi.operations.SubtractService
+Nov 4, 2009 9:51:56 AM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Registering calculator.dosgi.operations.MultiplyService
+Nov 4, 2009 9:51:56 AM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Registering calculator.dosgi.operations.DivideService
+Nov 4, 2009 9:51:56 AM calculator.dosgi.operations.impl.OperationsActivator getB
+undle
+INFO: calculator.dosgi.operations.AddService is loaded by bundle: calculator.dos
+gi.operations
+Nov 4, 2009 9:51:56 AM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: calculator.dosgi.operations domain: tuscany.apache.org
+Nov 4, 2009 9:51:56 AM org.apache.tuscany.sca.node.impl.NodeFactoryImpl loadCont
+ributions
+INFO: Loading contribution: bundleentry://198.fwk8152936/
+Nov 4, 2009 9:52:00 AM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerSe
+rvice
+INFO: RMI service registered: rmi://localhost:8085/AddService
+Nov 4, 2009 9:52:00 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@27845948)Endpoint: URI = OperationsComponent#service-bin
+ding(AddService/AddService)
+Nov 4, 2009 9:52:00 AM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerSe
+rvice
+INFO: RMI service registered: rmi://localhost:8085/SubtractService
+Nov 4, 2009 9:52:00 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@10576215)Endpoint: URI = OperationsComponent#service-bin
+ding(SubtractService/SubtractService)
+Nov 4, 2009 9:52:00 AM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerSe
+rvice
+INFO: RMI service registered: rmi://localhost:8085/MultiplyService
+Nov 4, 2009 9:52:00 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@31713234)Endpoint: URI = OperationsComponent#service-bin
+ding(MultiplyService/MultiplyService)
+Nov 4, 2009 9:52:00 AM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerSe
+rvice
+INFO: RMI service registered: rmi://localhost:8085/DivideService
+Nov 4, 2009 9:52:00 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@10202447)Endpoint: URI = OperationsComponent#service-bin
+ding(DivideService/DivideService)
+
+osgi>
+
+To stop the bundle:
+
+osgi> stop 198
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: calculator.dosgi.operations
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@27845948)Endpoint: URI = OperationsComponent#service-
+binding(AddService/AddService)
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregister
+Service
+INFO: RMI service unregistered: rmi://localhost:8085/AddService
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@10576215)Endpoint: URI = OperationsComponent#service-
+binding(SubtractService/SubtractService)
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregister
+Service
+INFO: RMI service unregistered: rmi://localhost:8085/SubtractService
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@31713234)Endpoint: URI = OperationsComponent#service-
+binding(MultiplyService/MultiplyService)
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregister
+Service
+INFO: RMI service unregistered: rmi://localhost:8085/MultiplyService
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@10202447)Endpoint: URI = OperationsComponent#service-
+binding(DivideService/DivideService)
+Nov 4, 2009 9:53:19 AM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregister
+Service
+INFO: RMI service unregistered: rmi://localhost:8085/DivideService
+Nov 4, 2009 9:53:19 AM calculator.dosgi.operations.impl.OperationsActivator stop
+
+INFO: Stopping calculator.dosgi.operations_1.0.0 [198]
+
+osgi>
+
+To exit the console, run:
+osgi> exit
+
+Sample Overview
+---------------
+The application consists of two OSGi bundles:
+ * The calculator bundle: It provides the calculator service. The service is implemented by a java class that
+ consumes other services to perform the “add”, “subtract”, “multiply” and “divide” operations.
+ * The operations bundle: It provides the add/subtract/multiply/divide services.
+ (See ../samples/dosgi-calculator-operations)
+
+
+dosgi-calculator-operations/
+ src/
+ main/
+ java/
+ calculator/
+ dosgi/
+ operations/
+ AddService.java - Interface for Add
+ SubtractService.java - Interface for Subtract
+ MultiplyService.java - Interface for Multiply
+ DivideService.java - Interface for Divide
+ impl/
+ OperationsActivator.java - OSGi bundle activator
+ AddServiceImpl.java - Implementation for Add
+ SubtractServiceImpl.java - Implementation for Subtract
+ MultiplyServiceImpl.java - Implementation for Multiply
+ DivideServiceImpl.java - Implementation for Divide
+ resources/
+ META-INF/
+ sca-contribution.xml
+ OSGI-INF/
+ sca/
+ bundle.componentType - The component type for implementation.osgi of this bundle
+ bundle.composite - The composite file
+ test/
+ java/
+ src/
+ calculator/
+ dosgi/
+ operations/
+ test/
+ OperationsOSGiNodeTestCase.java - The JUNIT test case that tests this bundle using a RMI client
+
+ META-INF/
+ MANIFEST.MF - The OSGi manifest for this bundle
+ pom.xml - the Maven build file
+
+
+
+Building And Running The Test Case Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built and run
+using Maven as follows.
+
+cd dosgi-calculator-operations
+mvn
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/pom.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/pom.xml
new file mode 100644
index 0000000000..cf7faab1e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/pom.xml
@@ -0,0 +1,148 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-dosgi-calculator-operations</artifactId>
+ <name>Apache Tuscany SCA OSGi Remote Services Caculator Operations Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Equinox Declarative Services -->
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>ds</artifactId>
+ <version>1.1.0-v20090601</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>util</artifactId>
+ <version>1.0.100-v20090520-1800</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <buildcommands>
+ <buildcommand>org.eclipse.pde.ManifestBuilder</buildcommand>
+ <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+ </buildcommands>
+ <projectnatures>
+ <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+ <projectnature>org.eclipse.pde.PluginNature</projectnature>
+ </projectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+ </classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-osgi-junit-plugin</artifactId>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>osgi-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>osgi.configuration.area</name>
+ <value>${project.build.directory}/equinox</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the add service
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the divide service
+ */
+@Remotable
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the multiply service
+ */
+@Remotable
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the subtract service
+ */
+@Remotable
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java
new file mode 100644
index 0000000000..66b2977241
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.AddService;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java
new file mode 100644
index 0000000000..a3c21b2b96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.DivideService;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..7922d2d392
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.MultiplyService;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java
new file mode 100644
index 0000000000..da2ce9063a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.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 calculator.dosgi.operations.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ *
+ */
+public class OperationsActivator implements BundleActivator {
+ private Logger logger = Logger.getLogger(OperationsActivator.class.getName());
+
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting " + context.getBundle());
+
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+
+ logger.info("Registering " + AddService.class.getName());
+ props.put("sca.service", "AddComponent#service-name(Add)");
+ context.registerService(AddService.class.getName(), new AddServiceImpl(), props);
+
+ logger.info("Registering " + SubtractService.class.getName());
+ props.put("sca.service", "SubtractComponent#service-name(Subtract)");
+ context.registerService(SubtractService.class.getName(), new SubtractServiceImpl(), props);
+
+ logger.info("Registering " + MultiplyService.class.getName());
+ props.put("sca.service", "MultiplyComponent#service-name(Multiply)");
+ context.registerService(MultiplyService.class.getName(), new MultiplyServiceImpl(), props);
+
+ logger.info("Registering " + DivideService.class.getName());
+ props.put("sca.service", "DivideComponent#service-name(Divide)");
+ context.registerService(DivideService.class.getName(), new DivideServiceImpl(), props);
+
+ getBundle(context, AddService.class);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping " + context.getBundle());
+ // Registered services will be automatically unregistered
+ }
+
+ private Bundle getBundle(BundleContext bundleContext, Class<?> cls) {
+ PackageAdmin packageAdmin = null;
+ // PackageAdmin is used to resolve bundles
+ ServiceReference ref = bundleContext.getServiceReference("org.osgi.service.packageadmin.PackageAdmin");
+ if (ref != null) {
+ packageAdmin = (PackageAdmin)bundleContext.getService(ref);
+ Bundle bundle = packageAdmin.getBundle(cls);
+ if (bundle != null) {
+ logger.info(cls.getName() + " is loaded by bundle: " + bundle.getSymbolicName());
+ }
+ bundleContext.ungetService(ref);
+ return bundle;
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java
new file mode 100644
index 0000000000..4bbe83b14f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..d24999ab3e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:OperationsComposite" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..cd92989da1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.operations.test;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * Utility class to create OSGi bundles
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiTestUtils {
+ private static class InvocationHandlerImpl implements InvocationHandler {
+ private Object instance;
+
+ public InvocationHandlerImpl(Object instance) {
+ super();
+ this.instance = instance;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ Method m = instance.getClass().getMethod(method.getName(), method.getParameterTypes());
+ return m.invoke(instance, args);
+ }
+
+ }
+
+ /**
+ * Returns a string representation of the given bundle.
+ *
+ * @param b
+ * @param verbose
+ * @return
+ */
+ public static String bundleStatus(Bundle bundle, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(bundle.getBundleId()).append(" ").append(bundle.getSymbolicName());
+ int s = bundle.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ if (verbose) {
+ sb.append(" ").append(bundle.getLocation());
+ sb.append(" ").append(bundle.getHeaders());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * A utility to cast the object to the given interface. If the class for the object
+ * is loaded by a different classloader, a proxy will be created.
+ *
+ * @param <T>
+ * @param obj
+ * @param cls
+ * @return
+ */
+ public static <T> T cast(Object obj, Class<T> cls) {
+ if (cls.isInstance(obj)) {
+ return cls.cast(obj);
+ } else {
+ return cls.cast(Proxy.newProxyInstance(cls.getClassLoader(),
+ new Class<?>[] {cls},
+ new InvocationHandlerImpl(obj)));
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java
new file mode 100644
index 0000000000..02007c385c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package calculator.dosgi.operations.test;
+
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+/**
+ *
+ */
+public class OperationsNode {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ if (args.length == 0) {
+ args = new String[] {"-bundles"};
+ }
+ try {
+ NodeLauncher.main(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java
new file mode 100644
index 0000000000..49c5aab041
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.operations.test;
+
+import static calculator.dosgi.operations.test.OSGiTestUtils.bundleStatus;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+import calculator.dosgi.operations.AddService;
+
+/**
+ *
+ */
+public class OperationsOSGiNodeTestCase {
+ private static EquinoxHost host;
+ private static BundleContext context;
+ private static Bundle operationsBundle;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ try {
+ host = new EquinoxHost();
+ context = host.start();
+
+ for (Bundle b : context.getBundles()) {
+ if (b.getSymbolicName().equals("org.eclipse.equinox.ds") || b.getSymbolicName()
+ .startsWith("org.apache.tuscany.sca.")) {
+ try {
+ if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) {
+ // Start the non-fragment bundle
+ b.start();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println(bundleStatus(b, false));
+ }
+ if ("calculator.dosgi.operations".equals(b.getSymbolicName())) {
+ operationsBundle = b;
+ }
+ }
+
+ if (operationsBundle != null) {
+ operationsBundle.start();
+ System.out.println(bundleStatus(operationsBundle, false));
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
+ public void testOSGi() throws Exception {
+ Registry registry = LocateRegistry.getRegistry(8085);
+ Object add = registry.lookup("AddService");
+ AddService addService = OSGiTestUtils.cast(add, AddService.class);
+ double sum = addService.add(1.0, 2.0);
+ Assert.assertEquals(3.0, sum, 0.0);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (host != null) {
+ host.stop();
+ context = null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/LICENSE b/sandbox/sebastien/java/embed/samples/dosgi-calculator/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/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/sebastien/java/embed/samples/dosgi-calculator/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/samples/dosgi-calculator/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..542b53b085
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Export-Package: calculator.dosgi;version="1.0.0",
+ calculator.dosgi.operations;version="1.0.0"
+Bundle-Version: 1.0.0
+Bundle-Name: calculator.dosgi
+Bundle-Activator: calculator.dosgi.impl.CalculatorActivator
+Bundle-ManifestVersion: 2
+Import-Package: org.oasisopen.sca.annotation;version="2.0.0",
+ org.osgi.framework,
+ org.osgi.service.component;resolution:=optional,
+ org.osgi.service.packageadmin,
+ org.osgi.util.tracker
+Bundle-SymbolicName: calculator.dosgi
+Bundle-Vendor: The Apache Software Foundation
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Service-Component-Disabled: OSGI-INF/calculator-component.xml
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/NOTICE b/sandbox/sebastien/java/embed/samples/dosgi-calculator/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/blueprint/calculator-module.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/blueprint/calculator-module.xml
new file mode 100644
index 0000000000..fd834e12ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/blueprint/calculator-module.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.
+-->
+<!-- A sample module-context.xml for OSGI RFC 124 (BluePrint Service) -->
+<components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <component id="CalculatorComponent" class="calculator.dosgi.impl.CalculatorServiceImpl">
+ <property name="addService" ref="AddService" />
+ <property name="subtractService" ref="SubtractService" />
+ <property name="multiplyService" ref="MultiplyService" />
+ <property name="divideService" ref="DivideService" />
+ </component>
+
+ <!-- We can derive the SCA services for the implementation.osgi -->
+ <service id="CalculatorService" ref="CalculatorComponent" interface="calculator.dosgi.CalculatorService">
+ </service>
+
+ <!-- We can derive the SCA references for the implementation.osgi -->
+ <reference id="AddService" interface="calculator.dosgi.operations.AddService">
+ </reference>
+ <reference id="SubtractService" interface="calculator.dosgi.operations.SubtractService">
+ </reference>
+ <reference id="MultiplyService" interface="calculator.dosgi.operations.MultiplyService">
+ </reference>
+ <reference id="DivideService" interface="calculator.dosgi.operations.DivideService">
+ </reference>
+
+</components> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/calculator-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/calculator-component.xml
new file mode 100644
index 0000000000..5daaa59aae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/calculator-component.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<scr:component name="CalculatorComponent"
+ xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.impl.CalculatorServiceDSImpl" />
+ <service>
+ <provide interface="calculator.dosgi.CalculatorService" />
+ </service>
+
+ <reference name="addService" interface="calculator.dosgi.operations.AddService" bind="setAddService" unbind="unsetAddService"
+ policy="dynamic" />
+ <reference name="subtractService" interface="calculator.dosgi.operations.SubtractService" bind="setSubtractService"
+ unbind="unsetSubtractService" policy="dynamic" />
+ <reference name="multiplyService" interface="calculator.dosgi.operations.MultiplyService" bind="setMultiplyService"
+ unbind="unsetMultiplyService" policy="dynamic" />
+ <reference name="divideService" interface="calculator.dosgi.operations.DivideService" bind="setDivideService"
+ unbind="unsetDivideService" policy="dynamic" />
+
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/sca/bundle.componentType b/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/sca/bundle.componentType
new file mode 100644
index 0000000000..1dff21ab6b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/sca/bundle.componentType
@@ -0,0 +1,64 @@
+<?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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
+ <!-- The service elment defines an SCA view of the OSGi service -->
+ <service name="CalculatorService">
+ <!-- The interface will be mapped into the OSGi service class -->
+ <interface.java interface="calculator.dosgi.CalculatorService"/>
+ <!-- The list of OSGi properties -->
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </service>
+
+ <!-- The reference elment defines an SCA proxy to a remote OSGi service -->
+ <reference name="addService">
+ <interface.java interface="calculator.dosgi.operations.AddService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="subtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="multiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+ <reference name="divideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
+ </reference>
+
+</componentType>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/sca/bundle.composite b/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/sca/bundle.composite
new file mode 100644
index 0000000000..c64e999fc6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/OSGI-INF/sca/bundle.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://calculator.dosgi"
+ name="CalculatorComposite">
+
+ <component name="CalculatorComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi" bundleVersion="1.0.0" />
+ <service name="CalculatorService">
+ <binding.ws uri="http://localhost:8086/CalculatorService"/>
+ </service>
+ <reference name="addService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
+ </reference>
+ <reference name="subtractService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/SubtractService"/>
+ </reference>
+ <reference name="multiplyService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/MultiplyService"/>
+ </reference>
+ <reference name="divideService">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/README b/sandbox/sebastien/java/embed/samples/dosgi-calculator/README
new file mode 100644
index 0000000000..e2cf7cd522
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/README
@@ -0,0 +1,143 @@
+Distributed OSGi Calculator Sample
+==================================
+This sample implements a distributed calculator using Distributed OSGi (RFC 119) over SCA.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.5.0-v20090520.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.5.0-v20090520.jar -configuration ../../features/configuration -clean -console
+
+You should see the osgi console:
+
+osgi>
+
+You can run "ss" command under the osgi> to see the status of the bundles.
+osgi> ss
+
+Then you can install and start the calculator.dosgi bundle:
+
+osgi> install file:./target/sample-dosgi-calculator.jar
+Bundle id is 198
+
+osgi> start 198
+Nov 4, 2009 9:40:00 AM calculator.dosgi.impl.CalculatorActivator start
+INFO: Starting calculator.dosgi_1.0.0 [198]
+Nov 4, 2009 9:40:01 AM calculator.dosgi.impl.CalculatorActivator start
+INFO: Registering calculator.dosgi.CalculatorService
+Nov 4, 2009 9:40:01 AM calculator.dosgi.impl.CalculatorActivator getBundle
+INFO: calculator.dosgi.operations.AddService is loaded by bundle: calculator.dos
+gi
+Nov 4, 2009 9:40:01 AM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: calculator.dosgi domain: tuscany.apache.org
+Nov 4, 2009 9:40:01 AM org.apache.tuscany.sca.node.impl.NodeFactoryImpl loadCont
+ributions
+INFO: Loading contribution: bundleentry://198.fwk15020296/
+log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX
+Utils).
+log4j:WARN Please initialize the log4j system properly.
+Nov 4, 2009 9:40:47 AM org.mortbay.log.Slf4jLog info
+INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via org.mort
+bay.log.Slf4jLog
+Nov 4, 2009 9:40:48 AM org.apache.tuscany.sca.http.jetty.JettyLogger info
+INFO: jetty-6.1.x
+Nov 4, 2009 9:40:48 AM org.apache.tuscany.sca.http.jetty.JettyLogger info
+INFO: Started SelectChannelConnector@0.0.0.0:8086
+Nov 4, 2009 9:40:48 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletM
+apping
+INFO: Added Servlet mapping: http://rfengt61p:8086/CalculatorService
+Nov 4, 2009 9:40:48 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@1277930)Endpoint: URI = CalculatorComponent#service-bind
+ing(CalculatorService/CalculatorService)
+osgi>
+
+You can point your browser to http://localhost:8086/CalculatorService?wsdl to see
+the WSDL.
+
+You can also use the WebService Explorer from Eclipse WTP to test the Web Service.
+
+To stop the bundle:
+
+osgi> stop 198
+Nov 4, 2009 9:41:22 AM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: calculator.dosgi
+Nov 4, 2009 9:41:22 AM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@1277930)Endpoint: URI = CalculatorComponent#service-b
+inding(CalculatorService/CalculatorService)
+Nov 4, 2009 9:41:22 AM org.apache.tuscany.sca.http.jetty.JettyServer removeServl
+etMapping
+INFO: Removed Servlet mapping: /CalculatorService
+Nov 4, 2009 9:41:22 AM calculator.dosgi.impl.CalculatorActivator stop
+INFO: Stopping calculator.dosgi_1.0.0 [198]
+
+To exit the console, run:
+osgi> exit
+
+Sample Overview
+---------------
+The application consists of two OSGi bundles:
+ * The calculator bundle: It provides the calculator service. The service is implemented by a java class that
+ consumes other services to perform the “add”, “subtract”, “multiply” and “divide” operations.
+ * The operations bundle: It provides the add/subtract/multiply/divide services.
+ (See ../samples/dosgi-calculator-operations)
+
+
+dosgi-calculator/
+ src/
+ main/
+ java/
+ calculator/
+ dosgi/
+ CalculatorService.java - The interface for Calculator service
+ impl/
+ CalculatorActivator.java - OSGi bundle activator for Calculator bundle
+ CalculatorServiceDSImpl.java - OSGi declarative service based implementation
+ CalculatorServiceImpl.java - Basic OSGi implementation
+ operations/
+ AddService.java - Interface for Add
+ SubtractService.java - Interface for Subtract
+ MultiplyService.java - Interface for Multiply
+ DivideService.java - Interface for Divide
+ rmi/
+ OperationsRemote.java - RMI remote interface for operations
+ OperationsRMIServer_Stub.java - RMI stub
+ OperationsRMIServer.java - RMI server implementation of the operations
+ resources/
+ META-INF/
+ sca-contribution.xml
+ OSGI-INF/
+ sca/
+ bundle.componentType - The component type for implementation.osgi of this bundle
+ bundle.composite - The composite file
+ test/
+ java/
+ src/
+ calculator/
+ dosgi/
+ test/
+ CalculatorOSGiNodeTestCase.java - The JUNIT test case that tests this bundle against a RMI service
+
+ META-INF/
+ MANIFEST.MF - The OSGi manifest for this bundle
+ dosig-calculator.png - a pictorial representation of the sample
+ pom.xml - the Maven build file
+
+
+
+Building And Running The Test Case Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built and run
+using Maven as follows.
+
+cd dosgi-calculator
+mvn
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/dosgi-calculator.png b/sandbox/sebastien/java/embed/samples/dosgi-calculator/dosgi-calculator.png
new file mode 100644
index 0000000000..805baa54d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/dosgi-calculator.png
Binary files differ
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/pom.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator/pom.xml
new file mode 100644
index 0000000000..2e06ff7e05
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/pom.xml
@@ -0,0 +1,153 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-dosgi-calculator</artifactId>
+ <name>Apache Tuscany SCA OSGi Remote Services Calculator Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Equinox Declarative Services -->
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>ds</artifactId>
+ <version>1.1.0-v20090601</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>util</artifactId>
+ <version>1.0.100-v20090520-1800</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <buildcommands>
+ <buildcommand>org.eclipse.pde.ManifestBuilder</buildcommand>
+ <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+ </buildcommands>
+ <projectnatures>
+ <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+ <projectnature>org.eclipse.pde.PluginNature</projectnature>
+ </projectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+ </classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-osgi-junit-plugin</artifactId>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>osgi-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>osgi.configuration.area</name>
+ <value>${project.build.directory}/equinox</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/CalculatorService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/CalculatorService.java
new file mode 100644
index 0000000000..cc562b7c2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/CalculatorService.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 calculator.dosgi;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java
new file mode 100644
index 0000000000..6b42645f69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.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 calculator.dosgi.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+
+/**
+ *
+ */
+public class CalculatorActivator implements BundleActivator {
+ private Logger logger = Logger.getLogger(CalculatorActivator.class.getName());
+
+ private Bundle getBundle(BundleContext bundleContext, Class<?> cls) {
+ PackageAdmin packageAdmin = null;
+ // PackageAdmin is used to resolve bundles
+ ServiceReference ref = bundleContext.getServiceReference("org.osgi.service.packageadmin.PackageAdmin");
+ if (ref != null) {
+ packageAdmin = (PackageAdmin)bundleContext.getService(ref);
+ Bundle bundle = packageAdmin.getBundle(cls);
+ if (bundle != null) {
+ logger.info(cls.getName() + " is loaded by bundle: " + bundle.getSymbolicName());
+ }
+ bundleContext.ungetService(ref);
+ return bundle;
+ }
+ return null;
+ }
+
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting " + context.getBundle());
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put("sca.service", "CalculatorComponent#service-name(Calculator)");
+ props.put("calculator", "Calculator");
+
+ logger.info("Registering " + CalculatorService.class.getName());
+ CalculatorService calculator = new CalculatorServiceImpl(context);
+ context.registerService(CalculatorService.class.getName(), calculator, props);
+
+ getBundle(context, AddService.class);
+
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping " + context.getBundle());
+ // Registered services will be automatically unregistered
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
new file mode 100644
index 0000000000..5f9db16ca9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.impl;
+
+import org.osgi.service.component.ComponentContext;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceDSImpl implements CalculatorService {
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ public CalculatorServiceDSImpl() {
+ super();
+ System.out.println("CalculatorServiceDSImpl()");
+ }
+
+ protected void activate(ComponentContext context) {
+ System.out.println("Activating " + context);
+ }
+
+ protected void deactivate(ComponentContext context) {
+ System.out.println("Deactivating " + context);
+ }
+
+ /*
+ * The following setters can be used for DS injection
+ */
+ public void setAddService(AddService addService) {
+ System.out.println("setAddService()");
+ this.addService = addService;
+ }
+
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ /*
+ * The following setters can be used for DS injection
+ */
+ public void unsetAddService(AddService addService) {
+ System.out.println("unsetAddService()");
+ this.addService = null;
+ }
+
+ public void unsetSubtractService(SubtractService subtractService) {
+ this.subtractService = null;
+ }
+
+ public void unsetDivideService(DivideService divideService) {
+ this.divideService = null;
+ }
+
+ public void unsetMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = null;
+ }
+ private <T> T getService(Class<T> cls) {
+ for (Object s : new Object[] {addService, subtractService, multiplyService, divideService}) {
+ if (cls.isInstance(s)) {
+ return cls.cast(s);
+ }
+ }
+ throw new IllegalStateException(cls.getSimpleName() + " is not available");
+ }
+
+ public double add(double n1, double n2) {
+ return getService(AddService.class).add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return getService(SubtractService.class).subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return getService(MultiplyService.class).multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return getService(DivideService.class).divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..a9ea37585a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.impl;
+
+import static org.osgi.framework.Constants.OBJECTCLASS;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.util.tracker.ServiceTracker;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+ private ServiceTracker remoteServices;
+ private ServiceTracker localServices;
+
+ public CalculatorServiceImpl() {
+ super();
+ }
+
+ public CalculatorServiceImpl(BundleContext context) {
+ super();
+ Filter remoteFilter = null, localFilter = null;
+ try {
+ remoteFilter =
+ context.createFilter("(&(" + OBJECTCLASS + "=calculator.dosgi.operations.*) (service.imported=*))");
+ localFilter =
+ context.createFilter("(&(" + OBJECTCLASS + "=calculator.dosgi.operations.*) (!(service.imported=*)))");
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ this.remoteServices = new ServiceTracker(context, remoteFilter, null);
+ remoteServices.open();
+ this.localServices = new ServiceTracker(context, localFilter, null);
+ localServices.open();
+ }
+
+ private <T> T getService(Class<T> cls) {
+ try {
+ // Wait for 10 seconds until the remote services are imported
+ remoteServices.waitForService(10000);
+ } catch (InterruptedException e) {
+ throw new IllegalStateException(cls.getSimpleName() + " is not available");
+ }
+ Object[] remoteObjects = remoteServices.getServices();
+ if (remoteObjects != null) {
+ for (Object s : remoteObjects) {
+ if (cls.isInstance(s)) {
+ System.out.println("Remote service: " + s);
+ return cls.cast(s);
+ }
+ }
+ }
+ Object[] localObjects = localServices.getServices();
+ if (localObjects != null) {
+ for (Object s : localObjects) {
+ if (cls.isInstance(s)) {
+ System.out.println("Local service: " + s);
+ return cls.cast(s);
+ }
+ }
+ }
+ throw new IllegalStateException(cls.getSimpleName() + " is not available");
+ }
+
+ public double add(double n1, double n2) {
+ return getService(AddService.class).add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return getService(SubtractService.class).subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return getService(MultiplyService.class).multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return getService(DivideService.class).divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/AddService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/AddService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the add service
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/DivideService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/DivideService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the divide service
+ */
+@Remotable
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the multiply service
+ */
+@Remotable
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/SubtractService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the subtract service
+ */
+@Remotable
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java
new file mode 100644
index 0000000000..a4fc52694e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.rmi;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ *
+ */
+public class OperationsRMIServer implements OperationsRemote, Serializable {
+
+ private static final long serialVersionUID = 6081008315263103012L;
+ private transient Registry registry;
+
+ public OperationsRMIServer() throws RemoteException {
+ super();
+ }
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+ public void start() throws RemoteException {
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ System.out.println("Starting the RMI server for calculator operations...");
+ Remote stub = UnicastRemoteObject.exportObject(OperationsRMIServer.this);
+ registry = LocateRegistry.createRegistry(8085);
+ registry.bind("AddService", stub);
+ registry.bind("SubtractService", stub);
+ registry.bind("MultiplyService", stub);
+ registry.bind("DivideService", stub);
+ System.out.println("RMI server for calculator operations is now started.");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+ thread.start();
+ }
+
+ public void stop() {
+ if (registry != null) {
+ try {
+ registry.unbind("AddService");
+ registry.unbind("SubtractService");
+ registry.unbind("MultiplyService");
+ registry.unbind("DivideService");
+ UnicastRemoteObject.unexportObject(this, false);
+ UnicastRemoteObject.unexportObject(registry, false);
+ registry = null;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java
new file mode 100644
index 0000000000..a813dfb6f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.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.
+ */
+
+// Stub class generated by rmic, do not edit.
+// Contents subject to change without notice.
+package calculator.rmi;
+
+public final class OperationsRMIServer_Stub extends java.rmi.server.RemoteStub implements calculator.rmi.OperationsRemote {
+ private static final long serialVersionUID = 2;
+
+ private static java.lang.reflect.Method $method_add_0;
+ private static java.lang.reflect.Method $method_divide_1;
+ private static java.lang.reflect.Method $method_multiply_2;
+ private static java.lang.reflect.Method $method_subtract_3;
+
+ static {
+ try {
+ $method_add_0 =
+ calculator.rmi.OperationsRemote.class.getMethod("add", new java.lang.Class[] {double.class, double.class});
+ $method_divide_1 =
+ calculator.rmi.OperationsRemote.class.getMethod("divide",
+ new java.lang.Class[] {double.class, double.class});
+ $method_multiply_2 =
+ calculator.rmi.OperationsRemote.class.getMethod("multiply", new java.lang.Class[] {double.class,
+ double.class});
+ $method_subtract_3 =
+ calculator.rmi.OperationsRemote.class.getMethod("subtract", new java.lang.Class[] {double.class,
+ double.class});
+ } catch (java.lang.NoSuchMethodException e) {
+ throw new java.lang.NoSuchMethodError("stub class initialization failed");
+ }
+ }
+
+ // constructors
+ public OperationsRMIServer_Stub(java.rmi.server.RemoteRef ref) {
+ super(ref);
+ }
+
+ // methods from remote interfaces
+
+ // implementation of add(double, double)
+ public double add(double $param_double_1, double $param_double_2) throws java.rmi.RemoteException {
+ try {
+ Object $result =
+ ref.invoke(this,
+ $method_add_0,
+ new java.lang.Object[] {new java.lang.Double($param_double_1),
+ new java.lang.Double($param_double_2)},
+ 864055858262779977L);
+ return ((java.lang.Double)$result).doubleValue();
+ } catch (java.lang.RuntimeException e) {
+ throw e;
+ } catch (java.rmi.RemoteException e) {
+ throw e;
+ } catch (java.lang.Exception e) {
+ throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+ }
+ }
+
+ // implementation of divide(double, double)
+ public double divide(double $param_double_1, double $param_double_2) throws java.rmi.RemoteException {
+ try {
+ Object $result =
+ ref.invoke(this,
+ $method_divide_1,
+ new java.lang.Object[] {new java.lang.Double($param_double_1),
+ new java.lang.Double($param_double_2)},
+ 8097593626497421928L);
+ return ((java.lang.Double)$result).doubleValue();
+ } catch (java.lang.RuntimeException e) {
+ throw e;
+ } catch (java.rmi.RemoteException e) {
+ throw e;
+ } catch (java.lang.Exception e) {
+ throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+ }
+ }
+
+ // implementation of multiply(double, double)
+ public double multiply(double $param_double_1, double $param_double_2) throws java.rmi.RemoteException {
+ try {
+ Object $result =
+ ref.invoke(this,
+ $method_multiply_2,
+ new java.lang.Object[] {new java.lang.Double($param_double_1),
+ new java.lang.Double($param_double_2)},
+ -346155016949350695L);
+ return ((java.lang.Double)$result).doubleValue();
+ } catch (java.lang.RuntimeException e) {
+ throw e;
+ } catch (java.rmi.RemoteException e) {
+ throw e;
+ } catch (java.lang.Exception e) {
+ throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+ }
+ }
+
+ // implementation of subtract(double, double)
+ public double subtract(double $param_double_1, double $param_double_2) throws java.rmi.RemoteException {
+ try {
+ Object $result =
+ ref.invoke(this,
+ $method_subtract_3,
+ new java.lang.Object[] {new java.lang.Double($param_double_1),
+ new java.lang.Double($param_double_2)},
+ -610707357620578750L);
+ return ((java.lang.Double)$result).doubleValue();
+ } catch (java.lang.RuntimeException e) {
+ throw e;
+ } catch (java.rmi.RemoteException e) {
+ throw e;
+ } catch (java.lang.Exception e) {
+ throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRemote.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRemote.java
new file mode 100644
index 0000000000..955e386ad8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRemote.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 calculator.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * RMI Remote interface
+ */
+public interface OperationsRemote extends Remote {
+ double add(double n1, double n2) throws RemoteException;
+
+ double subtract(double n1, double n2) throws RemoteException;
+
+ double multiply(double n1, double n2) throws RemoteException;
+
+ double divide(double n1, double n2) throws RemoteException;
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b48c048000
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:CalculatorComposite" />
+</contribution>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java
new file mode 100644
index 0000000000..565a314d85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package calculator.dosgi.test;
+
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+/**
+ *
+ */
+public class CalculatorNode {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ if (args.length == 0) {
+ args = new String[] {"-bundles"};
+ }
+ try {
+ NodeLauncher.main(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
new file mode 100644
index 0000000000..2f37da0707
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.test;
+
+import static calculator.dosgi.test.OSGiTestUtils.bundleStatus;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+
+import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+import calculator.dosgi.CalculatorService;
+import calculator.rmi.OperationsRMIServer;
+
+/**
+ *
+ */
+public class CalculatorOSGiNodeTestCase {
+ private static EquinoxHost host;
+ private static BundleContext context;
+ private static Bundle calculatorBundle;
+ private static OperationsRMIServer rmiServer;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ try {
+ rmiServer = new OperationsRMIServer();
+ rmiServer.start();
+
+ host = new EquinoxHost();
+ context = host.start();
+
+ for (Bundle b : context.getBundles()) {
+ System.out.println(b);
+ // debug to print out exported packages
+ // handy if you want to find aplit packages
+ //Object exports = b.getHeaders().get(Constants.EXPORT_PACKAGE);
+ //if (exports != null){
+ // System.out.println(exports.toString());
+ //}
+ if (b.getSymbolicName().equals("org.eclipse.equinox.ds") || b.getSymbolicName()
+ .startsWith("org.apache.tuscany.sca.")) {
+ try {
+ if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) {
+ // Start the non-fragment bundle
+ b.start();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println(bundleStatus(b, false));
+ } else {
+ System.out.println(bundleStatus(b, false));
+ }
+ if ("calculator.dosgi".equals(b.getSymbolicName())) {
+ calculatorBundle = b;
+ }
+ }
+
+ if (calculatorBundle != null) {
+ calculatorBundle.start();
+ System.out.println(bundleStatus(calculatorBundle, false));
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
+ public void testOSGi() {
+ ServiceReference ref =
+ calculatorBundle.getBundleContext().getServiceReference(CalculatorService.class.getName());
+ Assert.assertNotNull(ref);
+ Object service = context.getService(ref);
+ Assert.assertNotNull(service);
+ CalculatorService calculator = OSGiTestUtils.cast(service, CalculatorService.class);
+ System.out.println("2.0 + 1.0 = " + calculator.add(2.0, 1.0));
+ System.out.println("2.0 - 1.0 = " + calculator.subtract(2.0, 1.0));
+ System.out.println("2.0 * 1.0 = " + calculator.multiply(2.0, 1.0));
+ System.out.println("2.0 / 1.0 = " + calculator.divide(2.0, 1.0));
+ }
+
+ @Test
+ /**
+ * Test the Web service exposed by the Calculator
+ */
+ public void testWS() throws Exception {
+ URL url = new URL("http://localhost:8086/CalculatorService?wsdl");
+ InputStream is = url.openStream();
+ Reader reader = new InputStreamReader(is);
+ char[] content = new char[10240]; // 10k
+ int len = 0;
+ while (true) {
+ int size = reader.read(content, len, content.length - len);
+ if (size < 0) {
+ break;
+ }
+ len += size;
+ }
+ Assert.assertTrue(len > 0);
+ String str = new String(content, 0, len);
+ System.out.println(str);
+ Assert.assertTrue(str.indexOf("<wsdl:definitions") != -1);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (host != null) {
+ host.stop();
+ rmiServer.stop();
+ host = null;
+ rmiServer = null;
+ context = null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..99e0da9f97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.test;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * Utility class to create OSGi bundles
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiTestUtils {
+ private static class InvocationHandlerImpl implements InvocationHandler {
+ private Object instance;
+
+ public InvocationHandlerImpl(Object instance) {
+ super();
+ this.instance = instance;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ Method m = instance.getClass().getMethod(method.getName(), method.getParameterTypes());
+ return m.invoke(instance, args);
+ }
+
+ }
+
+ /**
+ * Returns a string representation of the given bundle.
+ *
+ * @param b
+ * @param verbose
+ * @return
+ */
+ public static String bundleStatus(Bundle bundle, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(bundle.getBundleId()).append(" ").append(bundle.getSymbolicName());
+ int s = bundle.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ if (verbose) {
+ sb.append(" ").append(bundle.getLocation());
+ sb.append(" ").append(bundle.getHeaders());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * A utility to cast the object to the given interface. If the class for the object
+ * is loaded by a different classloader, a proxy will be created.
+ *
+ * @param <T>
+ * @param obj
+ * @param cls
+ * @return
+ */
+ public static <T> T cast(Object obj, Class<T> cls) {
+ if (cls.isInstance(obj)) {
+ return cls.cast(obj);
+ } else {
+ return cls.cast(Proxy.newProxyInstance(cls.getClassLoader(),
+ new Class<?>[] {cls},
+ new InvocationHandlerImpl(obj)));
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/LICENSE b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/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/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cea4e2ff79
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Export-Package: calculator.dosgi.operations;version="1.0.1"
+Bundle-Version: 1.0.0
+Bundle-Name: calculator.dosgi.dynamic.operations
+Bundle-Activator: calculator.dosgi.operations.impl.OperationsActivator
+Bundle-ManifestVersion: 2
+Import-Package: calculator.dosgi.operations;version="[1.0.1,1.0.1]",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.osgi.framework,
+ org.osgi.service.component;resolution:=optional,
+ org.osgi.service.packageadmin
+Bundle-SymbolicName: calculator.dosgi.dynamic.operations
+Bundle-Vendor: The Apache Software Foundation
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Service-Component-Disabled: OSGI-INF/add-component.xml,
+ OSGI-INF/subtract-component.xml,
+ OSGI-INF/multiply-component.xml,
+ OSGI-INF/divide-component.xml
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+SCA-Configuration: OSGI-INF/sca-config/*.xml
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/NOTICE b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/add-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/add-component.xml
new file mode 100644
index 0000000000..99845257ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/add-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="AddComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.AddServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.AddService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/blueprint/operations-module.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/blueprint/operations-module.xml
new file mode 100644
index 0000000000..f6b5f4690e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/blueprint/operations-module.xml
@@ -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.
+-->
+<!-- A sample module-context.xml for OSGI RFC 124 (BluePrint Service) -->
+<components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <component id="AddComponent" class="calculator.dosgi.operations.impl.AddServiceImpl">
+ </component>
+ <component id="SubtractComponent" class="calculator.dosgi.operations.impl.SubtractServiceImpl">
+ </component>
+ <component id="MultiplyComponent" class="calculator.dosgi.operations.impl.MultiplyServiceImpl">
+ </component>
+ <component id="DivideComponent" class="calculator.dosgi.operations.impl.DivideServiceImpl">
+ </component>
+
+ <!-- We can derive the SCA services for the implementation.osgi -->
+ <service id="AddService" ref="AddComponent" interface="calculator.dosgi.operations.AddService">
+ </service>
+ <service id="SubtractService" ref="SubtractComponent" interface="calculator.dosgi.operations.SubtractService">
+ </service>
+ <service id="MultiplyService" ref="MultiplyComponent" interface="calculator.dosgi.operations.MultiplyService">
+ </service>
+ <service id="DivideService" ref="DivideComponent" interface="calculator.dosgi.operations.DivideService">
+ </service>
+</components> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/divide-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/divide-component.xml
new file mode 100644
index 0000000000..322d4daf2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/divide-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="DivideComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.DivideServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.DivideService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/multiply-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/multiply-component.xml
new file mode 100644
index 0000000000..b9ca777bd8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/multiply-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="MultiplyComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.MultiplyServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.MultiplyService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/sca-config/operations-config.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/sca-config/operations-config.xml
new file mode 100644
index 0000000000..1965b571a9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/sca-config/operations-config.xml
@@ -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.
+-->
+<scact:sca-config targetNamespace="http://sample"
+ xmlns:scact="http://www.osgi.org/xmlns/scact/v1.0.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+ <tuscany:binding.rmi name="Add" uri="rmi://localhost:8085/AddService"/>
+ <tuscany:binding.rmi name="Divide" uri="rmi://localhost:8085/DivideService"/>
+ <tuscany:binding.rmi name="Subtract" uri="rmi://localhost:8085/SubtractService"/>
+ <tuscany:binding.rmi name="Multiply" uri="rmi://localhost:8085/MultiplyService"/>
+</scact:sca-config>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/subtract-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/subtract-component.xml
new file mode 100644
index 0000000000..1472f5a976
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/OSGI-INF/subtract-component.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<scr:component name="SubtractComponent" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.operations.impl.SubtractServiceImpl" />
+ <service>
+ <provide interface="calculator.dosgi.operations.SubtractService" />
+ </service>
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/README b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/README
new file mode 100644
index 0000000000..77a4cbae9e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/README
@@ -0,0 +1,196 @@
+Distributed OSGi Calculator Sample
+==================================
+This sample implements a distributed calculator using Distributed OSGi (RFC 119) over SCA.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.5.0-v20090520.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.5.0-v20090520.jar -configuration ../../features/configuration -clean -console
+
+You should see the osgi console:
+
+osgi>
+
+You can run "ss" command under the osgi> to see the status of the bundles.
+osgi> ss
+
+Then you can install and start the calculator.dosgi bundle:
+
+osgi> install file:./target/sample-dosgi-dynamic-calculator-operations.jar
+Bundle id is 198
+
+osgi> start 198
+Nov 4, 2009 5:16:51 PM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Starting calculator.dosgi.dynamic.operations_1.0.0 [198]
+Nov 4, 2009 5:16:51 PM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Registering calculator.dosgi.operations.AddService
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: urn:osgi.service.d3cadb93-e9b9-4486-87eb-07ece11888f6 domai
+n: tuscany.apache.org
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerSe
+rvice
+INFO: RMI service registered: rmi://localhost:8085/AddService
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@8144744)Endpoint: URI = osgi.service.d3cadb93-e9b9-4486-
+87eb-07ece11888f6#service-binding(AddService/Add)
+Nov 4, 2009 5:16:51 PM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Registering calculator.dosgi.operations.SubtractService
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: urn:osgi.service.b6259ccc-6ae4-41f0-b61b-c5a8c7f42b35 domai
+n: tuscany.apache.org
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerSe
+rvice
+INFO: RMI service registered: rmi://localhost:8085/SubtractService
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@30229114)Endpoint: URI = osgi.service.b6259ccc-6ae4-41f0
+-b61b-c5a8c7f42b35#service-binding(SubtractService/Subtract)
+Nov 4, 2009 5:16:51 PM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Registering calculator.dosgi.operations.MultiplyService
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: urn:osgi.service.8469c64c-9a28-47b3-bc4a-c5fa8d471057 domai
+n: tuscany.apache.org
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerSe
+rvice
+INFO: RMI service registered: rmi://localhost:8085/MultiplyService
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@3312704)Endpoint: URI = osgi.service.8469c64c-9a28-47b3-
+bc4a-c5fa8d471057#service-binding(MultiplyService/Multiply)
+Nov 4, 2009 5:16:51 PM calculator.dosgi.operations.impl.OperationsActivator star
+t
+INFO: Registering calculator.dosgi.operations.DivideService
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: urn:osgi.service.b43555f0-9509-444e-b22a-06d347ab7e98 domai
+n: tuscany.apache.org
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerSe
+rvice
+INFO: RMI service registered: rmi://localhost:8085/DivideService
+Nov 4, 2009 5:16:51 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@8010288)Endpoint: URI = osgi.service.b43555f0-9509-444e-
+b22a-06d347ab7e98#service-binding(DivideService/Divide)
+Nov 4, 2009 5:16:51 PM calculator.dosgi.operations.impl.OperationsActivator getB
+undle
+INFO: calculator.dosgi.operations.AddService is loaded by bundle: calculator.dos
+gi.dynamic.operations
+
+osgi>
+
+To stop the bundle:
+
+osgi> stop 198
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: urn:osgi.service.b43555f0-9509-444e-b22a-06d347ab7e98
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@8010288)Endpoint: URI = osgi.service.b43555f0-9509-44
+4e-b22a-06d347ab7e98#service-binding(DivideService/Divide)
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregister
+Service
+INFO: RMI service unregistered: rmi://localhost:8085/DivideService
+Nov 4, 2009 5:18:43 PM calculator.dosgi.operations.impl.OperationsActivator stop
+
+INFO: Stopping calculator.dosgi.dynamic.operations_1.0.0 [198]
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: urn:osgi.service.d3cadb93-e9b9-4486-87eb-07ece11888f6
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@8144744)Endpoint: URI = osgi.service.d3cadb93-e9b9-44
+86-87eb-07ece11888f6#service-binding(AddService/Add)
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregister
+Service
+INFO: RMI service unregistered: rmi://localhost:8085/AddService
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: urn:osgi.service.b6259ccc-6ae4-41f0-b61b-c5a8c7f42b35
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@30229114)Endpoint: URI = osgi.service.b6259ccc-6ae4-4
+1f0-b61b-c5a8c7f42b35#service-binding(SubtractService/Subtract)
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregister
+Service
+INFO: RMI service unregistered: rmi://localhost:8085/SubtractService
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: urn:osgi.service.8469c64c-9a28-47b3-bc4a-c5fa8d471057
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@3312704)Endpoint: URI = osgi.service.8469c64c-9a28-47
+b3-bc4a-c5fa8d471057#service-binding(MultiplyService/Multiply)
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregister
+Service
+INFO: RMI service unregistered: rmi://localhost:8085/MultiplyService
+Nov 4, 2009 5:18:43 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: urn:osgi.service.b43555f0-9509-444e-b22a-06d347ab7e98
+
+osgi>
+
+To exit the console, run:
+osgi> exit
+
+Sample Overview
+---------------
+The application consists of two OSGi bundles:
+ * The calculator bundle: It provides the calculator service. The service is implemented by a java class that
+ consumes other services to perform the “add”, “subtract”, “multiply” and “divide” operations.
+ * The operations bundle: It provides the add/subtract/multiply/divide services.
+ (See ../samples/dosgi-dynamic-calculator-operations)
+
+
+dosgi-dynamic-calculator-operations/
+ src/
+ main/
+ java/
+ calculator/
+ dosgi/
+ operations/
+ AddService.java - Interface for Add
+ SubtractService.java - Interface for Subtract
+ MultiplyService.java - Interface for Multiply
+ DivideService.java - Interface for Divide
+ impl/
+ OperationsActivator.java - OSGi bundle activator
+ AddServiceImpl.java - Implementation for Add
+ SubtractServiceImpl.java - Implementation for Subtract
+ MultiplyServiceImpl.java - Implementation for Multiply
+ DivideServiceImpl.java - Implementation for Divide
+ resources/
+ META-INF/
+ sca-contribution.xml
+ OSGI-INF/
+ sca-config/
+ operations-config.xml - The SCA configuration file for OSGi remote services
+ test/
+ java/
+ src/
+ calculator/
+ dosgi/
+ operations/
+ test/
+ OperationsOSGiNodeTestCase.java - The JUNIT test case that tests this bundle using a RMI client
+
+ META-INF/
+ MANIFEST.MF - The OSGi manifest for this bundle
+ pom.xml - the Maven build file
+
+
+
+Building And Running The Test Case Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built and run
+using Maven as follows.
+
+cd dosgi-dynamic-calculator-operations
+mvn
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/pom.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/pom.xml
new file mode 100644
index 0000000000..926208b388
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/pom.xml
@@ -0,0 +1,148 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-dosgi-dynamic-calculator-operations</artifactId>
+ <name>Apache Tuscany SCA OSGi Remote Services Dynamic Caculator Operations Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Equinox Declarative Services -->
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>ds</artifactId>
+ <version>1.1.0-v20090601</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>util</artifactId>
+ <version>1.0.100-v20090520-1800</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <buildcommands>
+ <buildcommand>org.eclipse.pde.ManifestBuilder</buildcommand>
+ <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+ </buildcommands>
+ <projectnatures>
+ <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+ <projectnature>org.eclipse.pde.PluginNature</projectnature>
+ </projectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+ </classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-osgi-junit-plugin</artifactId>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>osgi-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>osgi.configuration.area</name>
+ <value>${project.build.directory}/equinox</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the add service
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the divide service
+ */
+@Remotable
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the multiply service
+ */
+@Remotable
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the subtract service
+ */
+@Remotable
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java
new file mode 100644
index 0000000000..66b2977241
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.AddService;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java
new file mode 100644
index 0000000000..a3c21b2b96
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.DivideService;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..7922d2d392
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.MultiplyService;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java
new file mode 100644
index 0000000000..f75cc6444e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.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 calculator.dosgi.operations.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ *
+ */
+public class OperationsActivator implements BundleActivator {
+ private Logger logger = Logger.getLogger(OperationsActivator.class.getName());
+
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting " + context.getBundle());
+
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put("service.exported.configs", new String[] {"org.osgi.sca"});
+ props.put("service.exported.interfaces", new String[] {"*"});
+
+ logger.info("Registering " + AddService.class.getName());
+ props.put("sca.service", "AddComponent#service-name(Add)");
+ props.put("org.osgi.sca.bindings", new String[] {"{http://sample}Add"});
+ context.registerService(AddService.class.getName(), new AddServiceImpl(), props);
+
+ logger.info("Registering " + SubtractService.class.getName());
+ props.put("sca.service", "SubtractComponent#service-name(Subtract)");
+ props.put("org.osgi.sca.bindings", new String[] {"{http://sample}Subtract"});
+ context.registerService(SubtractService.class.getName(), new SubtractServiceImpl(), props);
+
+ logger.info("Registering " + MultiplyService.class.getName());
+ props.put("sca.service", "MultiplyComponent#service-name(Multiply)");
+ props.put("org.osgi.sca.bindings", new String[] {"{http://sample}Multiply"});
+ context.registerService(MultiplyService.class.getName(), new MultiplyServiceImpl(), props);
+
+ logger.info("Registering " + DivideService.class.getName());
+ props.put("sca.service", "DivideComponent#service-name(Divide)");
+ props.put("org.osgi.sca.bindings", new String[] {"{http://sample}Divide"});
+ context.registerService(DivideService.class.getName(), new DivideServiceImpl(), props);
+
+ getBundle(context, AddService.class);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping " + context.getBundle());
+ // Registered services will be automatically unregistered
+ }
+
+ private Bundle getBundle(BundleContext bundleContext, Class<?> cls) {
+ PackageAdmin packageAdmin = null;
+ // PackageAdmin is used to resolve bundles
+ ServiceReference ref = bundleContext.getServiceReference("org.osgi.service.packageadmin.PackageAdmin");
+ if (ref != null) {
+ packageAdmin = (PackageAdmin)bundleContext.getService(ref);
+ Bundle bundle = packageAdmin.getBundle(cls);
+ if (bundle != null) {
+ logger.info(cls.getName() + " is loaded by bundle: " + bundle.getSymbolicName());
+ }
+ bundleContext.ungetService(ref);
+ return bundle;
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java
new file mode 100644
index 0000000000..4bbe83b14f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.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 calculator.dosgi.operations.impl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.INFO, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..cd92989da1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.operations.test;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * Utility class to create OSGi bundles
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiTestUtils {
+ private static class InvocationHandlerImpl implements InvocationHandler {
+ private Object instance;
+
+ public InvocationHandlerImpl(Object instance) {
+ super();
+ this.instance = instance;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ Method m = instance.getClass().getMethod(method.getName(), method.getParameterTypes());
+ return m.invoke(instance, args);
+ }
+
+ }
+
+ /**
+ * Returns a string representation of the given bundle.
+ *
+ * @param b
+ * @param verbose
+ * @return
+ */
+ public static String bundleStatus(Bundle bundle, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(bundle.getBundleId()).append(" ").append(bundle.getSymbolicName());
+ int s = bundle.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ if (verbose) {
+ sb.append(" ").append(bundle.getLocation());
+ sb.append(" ").append(bundle.getHeaders());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * A utility to cast the object to the given interface. If the class for the object
+ * is loaded by a different classloader, a proxy will be created.
+ *
+ * @param <T>
+ * @param obj
+ * @param cls
+ * @return
+ */
+ public static <T> T cast(Object obj, Class<T> cls) {
+ if (cls.isInstance(obj)) {
+ return cls.cast(obj);
+ } else {
+ return cls.cast(Proxy.newProxyInstance(cls.getClassLoader(),
+ new Class<?>[] {cls},
+ new InvocationHandlerImpl(obj)));
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java
new file mode 100644
index 0000000000..02007c385c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package calculator.dosgi.operations.test;
+
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+/**
+ *
+ */
+public class OperationsNode {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ if (args.length == 0) {
+ args = new String[] {"-bundles"};
+ }
+ try {
+ NodeLauncher.main(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java
new file mode 100644
index 0000000000..eee64bf86f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.operations.test;
+
+import static calculator.dosgi.operations.test.OSGiTestUtils.bundleStatus;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+import calculator.dosgi.operations.AddService;
+
+/**
+ *
+ */
+public class OperationsOSGiNodeTestCase {
+ private static EquinoxHost host;
+ private static BundleContext context;
+ private static Bundle operationsBundle;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ try {
+ host = new EquinoxHost();
+ context = host.start();
+
+ for (Bundle b : context.getBundles()) {
+ if (b.getSymbolicName().equals("org.eclipse.equinox.ds") || b.getSymbolicName()
+ .startsWith("org.apache.tuscany.sca.")) {
+ try {
+ if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) {
+ // Start the non-fragment bundle
+ b.start();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println(bundleStatus(b, false));
+ }
+ if ("calculator.dosgi.dynamic.operations".equals(b.getSymbolicName())) {
+ operationsBundle = b;
+ }
+ }
+
+ if (operationsBundle != null) {
+ operationsBundle.start();
+ System.out.println(bundleStatus(operationsBundle, false));
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
+ public void testOSGi() throws Exception {
+ Registry registry = LocateRegistry.getRegistry(8085);
+ Object add = registry.lookup("AddService");
+ AddService addService = OSGiTestUtils.cast(add, AddService.class);
+ double sum = addService.add(1.0, 2.0);
+ Assert.assertEquals(3.0, sum, 0.0);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (host != null) {
+ host.stop();
+ context = null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/LICENSE b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/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/sebastien/java/embed/samples/dosgi-dynamic-calculator/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..6ce24a4a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Export-Package: calculator.dosgi;version="1.0.1",
+ calculator.dosgi.operations;version="1.0.1"
+Bundle-Version: 1.0.0
+Bundle-Name: calculator.dosgi.dynamic
+Bundle-Activator: calculator.dosgi.impl.CalculatorActivator
+Bundle-ManifestVersion: 2
+Import-Package: org.oasisopen.sca.annotation;version="2.0.0",
+ org.osgi.framework,
+ org.osgi.service.component;resolution:=optional,
+ org.osgi.service.packageadmin,
+ org.osgi.util.tracker
+Bundle-SymbolicName: calculator.dosgi.dynamic
+Bundle-Vendor: The Apache Software Foundation
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-DocURL: http://www.apache.org/
+Service-Component-Disabled: OSGI-INF/calculator-component.xml
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+SCA-Configuration: OSGI-INF/sca-config/calculator-config.xml
+Remote-Service: OSGI-INF/remote-service/*.xml
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/NOTICE b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/NOTICE
new file mode 100644
index 0000000000..9ddba06a32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/blueprint/calculator-module.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/blueprint/calculator-module.xml
new file mode 100644
index 0000000000..fd834e12ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/blueprint/calculator-module.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.
+-->
+<!-- A sample module-context.xml for OSGI RFC 124 (BluePrint Service) -->
+<components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <component id="CalculatorComponent" class="calculator.dosgi.impl.CalculatorServiceImpl">
+ <property name="addService" ref="AddService" />
+ <property name="subtractService" ref="SubtractService" />
+ <property name="multiplyService" ref="MultiplyService" />
+ <property name="divideService" ref="DivideService" />
+ </component>
+
+ <!-- We can derive the SCA services for the implementation.osgi -->
+ <service id="CalculatorService" ref="CalculatorComponent" interface="calculator.dosgi.CalculatorService">
+ </service>
+
+ <!-- We can derive the SCA references for the implementation.osgi -->
+ <reference id="AddService" interface="calculator.dosgi.operations.AddService">
+ </reference>
+ <reference id="SubtractService" interface="calculator.dosgi.operations.SubtractService">
+ </reference>
+ <reference id="MultiplyService" interface="calculator.dosgi.operations.MultiplyService">
+ </reference>
+ <reference id="DivideService" interface="calculator.dosgi.operations.DivideService">
+ </reference>
+
+</components> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/calculator-component.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/calculator-component.xml
new file mode 100644
index 0000000000..5daaa59aae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/calculator-component.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<scr:component name="CalculatorComponent"
+ xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+ <implementation class="calculator.dosgi.impl.CalculatorServiceDSImpl" />
+ <service>
+ <provide interface="calculator.dosgi.CalculatorService" />
+ </service>
+
+ <reference name="addService" interface="calculator.dosgi.operations.AddService" bind="setAddService" unbind="unsetAddService"
+ policy="dynamic" />
+ <reference name="subtractService" interface="calculator.dosgi.operations.SubtractService" bind="setSubtractService"
+ unbind="unsetSubtractService" policy="dynamic" />
+ <reference name="multiplyService" interface="calculator.dosgi.operations.MultiplyService" bind="setMultiplyService"
+ unbind="unsetMultiplyService" policy="dynamic" />
+ <reference name="divideService" interface="calculator.dosgi.operations.DivideService" bind="setDivideService"
+ unbind="unsetDivideService" policy="dynamic" />
+
+</scr:component>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml
new file mode 100644
index 0000000000..ded82797b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml
@@ -0,0 +1,61 @@
+<?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.
+-->
+<!-- A consumer-side service description file for RFC 119 -->
+<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+ <!-- Describe a remote OSGi service -->
+ <endpoint-description>
+ <property name="objectClass" value="calculator.dosgi.operations.AddService" />
+ <property name="remote.configs.supported" value="org.osgi.sca"/>
+ <property name="service.imported.configs" value="org.osgi.sca"/>
+ <property name="sca.reference" value="addService"/>
+ <property name="org.osgi.sca.bindings">
+ <list>
+ <value>{http://sample}Add</value>
+ </list>
+ </property>
+ </endpoint-description>
+ <endpoint-description>
+ <property name="objectClass" value="calculator.dosgi.operations.SubtractService" />
+ <property name="service.imported.configs" value="org.osgi.sca"/>
+ <property name="remote.configs.supported" value="org.osgi.sca"/>
+ <property name="sca.reference" value="subtractService"/>
+ <property name="org.osgi.sca.bindings">
+ <list>
+ <value>{http://sample}Subtract</value>
+ </list>
+ </property>
+ </endpoint-description>
+ <endpoint-description>
+ <property name="objectClass" value="calculator.dosgi.operations.MultiplyService" />
+ <property name="service.imported.configs" value="org.osgi.sca"/>
+ <property name="remote.configs.supported" value="org.osgi.sca"/>
+ <property name="sca.reference" value="multiplyService"/>
+ <property name="org.osgi.sca.bindings" value="{http://sample}Multiply"/>
+ </endpoint-description>
+ <endpoint-description>
+ <property name="objectClass" value="calculator.dosgi.operations.DivideService" />
+ <property name="service.imported.configs" value="org.osgi.sca"/>
+ <property name="remote.configs.supported" value="org.osgi.sca"/>
+ <property name="sca.reference" value="divideService"/>
+ <property name="org.osgi.sca.bindings" value="{http://sample}Divide"/>
+ </endpoint-description>
+</endpoint-descriptions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/sca-config/calculator-config.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/sca-config/calculator-config.xml
new file mode 100644
index 0000000000..f10b577e87
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/OSGI-INF/sca-config/calculator-config.xml
@@ -0,0 +1,32 @@
+<?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.
+-->
+<scact:sca-config targetNamespace="http://sample"
+ xmlns:scact="http://www.osgi.org/xmlns/scact/v1.0.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+ <sca:binding.ws name="Calculator" uri="http://localhost:8086/CalculatorService"/>
+
+ <!-- bindings for the remote services -->
+ <tuscany:binding.rmi name="Add" uri="rmi://localhost:8085/AddService"/>
+ <tuscany:binding.rmi name="Divide" uri="rmi://localhost:8085/DivideService"/>
+ <tuscany:binding.rmi name="Subtract" uri="rmi://localhost:8085/SubtractService"/>
+ <tuscany:binding.rmi name="Multiply" uri="rmi://localhost:8085/MultiplyService"/>
+</scact:sca-config>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/README b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/README
new file mode 100644
index 0000000000..e8d311298e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/README
@@ -0,0 +1,145 @@
+Distributed OSGi Calculator Sample
+==================================
+This sample implements a distributed calculator using Distributed OSGi (RFC 119) over SCA.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.5.0-v20090520.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.5.0-v20090520.jar -configuration ../../features/configuration -clean -console
+
+You should see the osgi console:
+
+osgi>
+
+osgi> Jun 22, 2009 1:32:27 PM org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoveryActivator start
+INFO: Equinox-based service discoverer is now configured.
+
+You can run "ss" command under the osgi> to see the status of the bundles.
+osgi> ss
+
+Then you can install and start the calculator.dosgi bundle:
+
+osgi> install file:./target/sample-dosgi-dynamic-calculator.jar
+Bundle id is 198
+
+osgi> start 198
+Nov 4, 2009 5:20:21 PM calculator.dosgi.impl.CalculatorActivator start
+INFO: Starting calculator.dosgi.dynamic_1.0.0 [198]
+Nov 4, 2009 5:20:21 PM calculator.dosgi.impl.CalculatorActivator start
+INFO: Registering calculator.dosgi.CalculatorService
+Nov 4, 2009 5:20:21 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: urn:osgi.service.d5a06834-ae15-42b3-9287-71fe6537c869 domai
+n: tuscany.apache.org
+log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX
+Utils).
+log4j:WARN Please initialize the log4j system properly.
+Nov 4, 2009 5:20:24 PM org.mortbay.log.Slf4jLog info
+INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via org.mort
+bay.log.Slf4jLog
+Nov 4, 2009 5:20:25 PM org.apache.tuscany.sca.http.jetty.JettyLogger info
+INFO: jetty-6.1.x
+Nov 4, 2009 5:20:25 PM org.apache.tuscany.sca.http.jetty.JettyLogger info
+INFO: Started SelectChannelConnector@0.0.0.0:8086
+Nov 4, 2009 5:20:25 PM org.apache.tuscany.sca.http.jetty.JettyServer addServletM
+apping
+INFO: Added Servlet mapping: http://rfengt61p:8086/CalculatorService
+Nov 4, 2009 5:20:25 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl addEndpoint
+INFO: Add endpoint - (@23394516)Endpoint: URI = osgi.service.d5a06834-ae15-42b3
+-9287-71fe6537c869#service-binding(CalculatorService/Calculator)
+Nov 4, 2009 5:20:25 PM calculator.dosgi.impl.CalculatorActivator getBundle
+INFO: calculator.dosgi.operations.AddService is loaded by bundle: calculator.dos
+gi.dynamic
+
+You can point your browser to http://localhost:8086/CalculatorService?wsdl to see
+the WSDL.
+
+You can also use the WebService Explorer from Eclipse WTP to test the Web Service.
+
+To stop the bundle:
+
+osgi> stop 198
+Nov 4, 2009 5:21:16 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: urn:osgi.service.d5a06834-ae15-42b3-9287-71fe6537c869
+Nov 4, 2009 5:21:16 PM org.apache.tuscany.sca.core.assembly.impl.EndpointRegistr
+yImpl endpointRemoved
+INFO: Remove endpoint - (@23394516)Endpoint: URI = osgi.service.d5a06834-ae15-4
+2b3-9287-71fe6537c869#service-binding(CalculatorService/Calculator)
+Nov 4, 2009 5:21:16 PM org.apache.tuscany.sca.http.jetty.JettyServer removeServl
+etMapping
+INFO: Removed Servlet mapping: /CalculatorService
+Nov 4, 2009 5:21:16 PM calculator.dosgi.impl.CalculatorActivator stop
+INFO: Stopping calculator.dosgi.dynamic_1.0.0 [198]
+Nov 4, 2009 5:21:16 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: urn:osgi.service.d5a06834-ae15-42b3-9287-71fe6537c869
+
+To exit the console, run:
+osgi> exit
+
+Sample Overview
+---------------
+The application consists of two OSGi bundles:
+ * The calculator bundle: It provides the calculator service. The service is implemented by a java class that
+ consumes other services to perform the “add”, “subtract”, “multiply” and “divide” operations.
+ * The operations bundle: It provides the add/subtract/multiply/divide services.
+ (See ../samples/dosgi-dynamic-calculator-operations)
+
+
+dosgi-dynamic-calculator/
+ src/
+ main/
+ java/
+ calculator/
+ dosgi/
+ CalculatorService.java - The interface for Calculator service
+ impl/
+ CalculatorActivator.java - OSGi bundle activator for Calculator bundle
+ CalculatorServiceDSImpl.java - OSGi declarative service based implementation
+ CalculatorServiceImpl.java - Basic OSGi implementation
+ operations/
+ AddService.java - Interface for Add
+ SubtractService.java - Interface for Subtract
+ MultiplyService.java - Interface for Multiply
+ DivideService.java - Interface for Divide
+ rmi/
+ OperationsRemote.java - RMI remote interface for operations
+ OperationsRMIServer_Stub.java - RMI stub
+ OperationsRMIServer.java - RMI server implementation of the operations
+ resources/
+ META-INF/
+ sca-contribution.xml
+ OSGI-INF/
+ sca-config/
+ calculator-config.xml - The SCA configuration file for OSGi remote services
+ remote-service/
+ calculator-service-descriptions.xml - The OSGi remote service endpoint descriptions
+ test/
+ java/
+ src/
+ calculator/
+ dosgi/
+ test/
+ CalculatorOSGiNodeTestCase.java - The JUNIT test case that tests this bundle against a RMI service
+
+ META-INF/
+ MANIFEST.MF - The OSGi manifest for this bundle
+ dosig-calculator.png - a pictorial representation of the sample
+ pom.xml - the Maven build file
+
+
+
+Building And Running The Test Case Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built and run
+using Maven as follows.
+
+cd dosgi-calculator
+mvn
+
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/dosgi-calculator.png b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/dosgi-calculator.png
new file mode 100644
index 0000000000..805baa54d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/dosgi-calculator.png
Binary files differ
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/pom.xml b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/pom.xml
new file mode 100644
index 0000000000..0394373342
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/pom.xml
@@ -0,0 +1,153 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-dosgi-dynamic-calculator</artifactId>
+ <name>Apache Tuscany SCA OSGi Remote Services Dynamic Caculator Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Equinox Declarative Services -->
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>ds</artifactId>
+ <version>1.1.0-v20090601</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>util</artifactId>
+ <version>1.0.100-v20090520-1800</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <buildcommands>
+ <buildcommand>org.eclipse.pde.ManifestBuilder</buildcommand>
+ <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+ </buildcommands>
+ <projectnatures>
+ <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+ <projectnature>org.eclipse.pde.PluginNature</projectnature>
+ </projectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+ </classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-osgi-junit-plugin</artifactId>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>osgi-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>osgi.configuration.area</name>
+ <value>${project.build.directory}/equinox</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/CalculatorService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/CalculatorService.java
new file mode 100644
index 0000000000..cc562b7c2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/CalculatorService.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 calculator.dosgi;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java
new file mode 100644
index 0000000000..6228afcd53
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.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 calculator.dosgi.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+
+/**
+ *
+ */
+public class CalculatorActivator implements BundleActivator {
+ private Logger logger = Logger.getLogger(CalculatorActivator.class.getName());
+
+ private Bundle getBundle(BundleContext bundleContext, Class<?> cls) {
+ PackageAdmin packageAdmin = null;
+ // PackageAdmin is used to resolve bundles
+ ServiceReference ref = bundleContext.getServiceReference("org.osgi.service.packageadmin.PackageAdmin");
+ if (ref != null) {
+ packageAdmin = (PackageAdmin)bundleContext.getService(ref);
+ Bundle bundle = packageAdmin.getBundle(cls);
+ if (bundle != null) {
+ logger.info(cls.getName() + " is loaded by bundle: " + bundle.getSymbolicName());
+ }
+ bundleContext.ungetService(ref);
+ return bundle;
+ }
+ return null;
+ }
+
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting " + context.getBundle());
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put("sca.service", "CalculatorComponent#service-name(Calculator)");
+ props.put("calculator", "Calculator");
+ props.put("service.exported.configs", new String[] {"org.osgi.sca"});
+ props.put("org.osgi.sca.bindings", new String[] {"{http://sample}Calculator"});
+ props.put("service.exported.interfaces", new String[] {"*"});
+ logger.info("Registering " + CalculatorService.class.getName());
+ CalculatorService calculator = new CalculatorServiceImpl(context);
+ context.registerService(CalculatorService.class.getName(), calculator, props);
+
+ getBundle(context, AddService.class);
+
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping " + context.getBundle());
+ // Registered services will be automatically unregistered
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
new file mode 100644
index 0000000000..5f9db16ca9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.impl;
+
+import org.osgi.service.component.ComponentContext;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceDSImpl implements CalculatorService {
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ public CalculatorServiceDSImpl() {
+ super();
+ System.out.println("CalculatorServiceDSImpl()");
+ }
+
+ protected void activate(ComponentContext context) {
+ System.out.println("Activating " + context);
+ }
+
+ protected void deactivate(ComponentContext context) {
+ System.out.println("Deactivating " + context);
+ }
+
+ /*
+ * The following setters can be used for DS injection
+ */
+ public void setAddService(AddService addService) {
+ System.out.println("setAddService()");
+ this.addService = addService;
+ }
+
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ /*
+ * The following setters can be used for DS injection
+ */
+ public void unsetAddService(AddService addService) {
+ System.out.println("unsetAddService()");
+ this.addService = null;
+ }
+
+ public void unsetSubtractService(SubtractService subtractService) {
+ this.subtractService = null;
+ }
+
+ public void unsetDivideService(DivideService divideService) {
+ this.divideService = null;
+ }
+
+ public void unsetMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = null;
+ }
+ private <T> T getService(Class<T> cls) {
+ for (Object s : new Object[] {addService, subtractService, multiplyService, divideService}) {
+ if (cls.isInstance(s)) {
+ return cls.cast(s);
+ }
+ }
+ throw new IllegalStateException(cls.getSimpleName() + " is not available");
+ }
+
+ public double add(double n1, double n2) {
+ return getService(AddService.class).add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return getService(SubtractService.class).subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return getService(MultiplyService.class).multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return getService(DivideService.class).divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..aa09b27139
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.impl;
+
+import static org.osgi.framework.Constants.OBJECTCLASS;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.util.tracker.ServiceTracker;
+
+import calculator.dosgi.CalculatorService;
+import calculator.dosgi.operations.AddService;
+import calculator.dosgi.operations.DivideService;
+import calculator.dosgi.operations.MultiplyService;
+import calculator.dosgi.operations.SubtractService;
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+ private Map<Class<?>, ServiceTracker> remoteServices = new HashMap<Class<?>, ServiceTracker>();
+
+ public CalculatorServiceImpl() {
+ super();
+ }
+
+ public CalculatorServiceImpl(BundleContext context) {
+ super();
+ for (Class<?> cls : new Class<?>[] {AddService.class, SubtractService.class, MultiplyService.class,
+ DivideService.class}) {
+ Filter remoteFilter = null;
+ try {
+ remoteFilter =
+ context.createFilter("(&(" + OBJECTCLASS + "=" + cls.getName() + ") (service.imported=*))");
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ ServiceTracker tracker = new ServiceTracker(context, remoteFilter, null);
+ this.remoteServices.put(cls, tracker);
+ tracker.open();
+ }
+ }
+
+ private <T> T getService(Class<T> cls) {
+ ServiceTracker tracker = remoteServices.get(cls);
+ try {
+ // Wait for 10 seconds until the remote services are imported
+ tracker.waitForService(10000);
+ } catch (InterruptedException e) {
+ throw new IllegalStateException(cls.getSimpleName() + " is not available");
+ }
+ Object[] remoteObjects = tracker.getServices();
+ if (remoteObjects != null) {
+ for (Object s : remoteObjects) {
+ if (cls.isInstance(s)) {
+ System.out.println("Remote service: " + s);
+ return cls.cast(s);
+ }
+ }
+ }
+ throw new IllegalStateException(cls.getSimpleName() + " is not available");
+ }
+
+ public double add(double n1, double n2) {
+ return getService(AddService.class).add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return getService(SubtractService.class).subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return getService(MultiplyService.class).multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return getService(DivideService.class).divide(n1, n2);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/AddService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/AddService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the add service
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/DivideService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/DivideService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the divide service
+ */
+@Remotable
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the multiply service
+ */
+@Remotable
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/SubtractService.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 calculator.dosgi.operations;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the subtract service
+ */
+@Remotable
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java
new file mode 100644
index 0000000000..a4fc52694e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.rmi;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ *
+ */
+public class OperationsRMIServer implements OperationsRemote, Serializable {
+
+ private static final long serialVersionUID = 6081008315263103012L;
+ private transient Registry registry;
+
+ public OperationsRMIServer() throws RemoteException {
+ super();
+ }
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+ public void start() throws RemoteException {
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ System.out.println("Starting the RMI server for calculator operations...");
+ Remote stub = UnicastRemoteObject.exportObject(OperationsRMIServer.this);
+ registry = LocateRegistry.createRegistry(8085);
+ registry.bind("AddService", stub);
+ registry.bind("SubtractService", stub);
+ registry.bind("MultiplyService", stub);
+ registry.bind("DivideService", stub);
+ System.out.println("RMI server for calculator operations is now started.");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+ thread.start();
+ }
+
+ public void stop() {
+ if (registry != null) {
+ try {
+ registry.unbind("AddService");
+ registry.unbind("SubtractService");
+ registry.unbind("MultiplyService");
+ registry.unbind("DivideService");
+ UnicastRemoteObject.unexportObject(this, false);
+ UnicastRemoteObject.unexportObject(registry, false);
+ registry = null;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java
new file mode 100644
index 0000000000..a813dfb6f3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.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.
+ */
+
+// Stub class generated by rmic, do not edit.
+// Contents subject to change without notice.
+package calculator.rmi;
+
+public final class OperationsRMIServer_Stub extends java.rmi.server.RemoteStub implements calculator.rmi.OperationsRemote {
+ private static final long serialVersionUID = 2;
+
+ private static java.lang.reflect.Method $method_add_0;
+ private static java.lang.reflect.Method $method_divide_1;
+ private static java.lang.reflect.Method $method_multiply_2;
+ private static java.lang.reflect.Method $method_subtract_3;
+
+ static {
+ try {
+ $method_add_0 =
+ calculator.rmi.OperationsRemote.class.getMethod("add", new java.lang.Class[] {double.class, double.class});
+ $method_divide_1 =
+ calculator.rmi.OperationsRemote.class.getMethod("divide",
+ new java.lang.Class[] {double.class, double.class});
+ $method_multiply_2 =
+ calculator.rmi.OperationsRemote.class.getMethod("multiply", new java.lang.Class[] {double.class,
+ double.class});
+ $method_subtract_3 =
+ calculator.rmi.OperationsRemote.class.getMethod("subtract", new java.lang.Class[] {double.class,
+ double.class});
+ } catch (java.lang.NoSuchMethodException e) {
+ throw new java.lang.NoSuchMethodError("stub class initialization failed");
+ }
+ }
+
+ // constructors
+ public OperationsRMIServer_Stub(java.rmi.server.RemoteRef ref) {
+ super(ref);
+ }
+
+ // methods from remote interfaces
+
+ // implementation of add(double, double)
+ public double add(double $param_double_1, double $param_double_2) throws java.rmi.RemoteException {
+ try {
+ Object $result =
+ ref.invoke(this,
+ $method_add_0,
+ new java.lang.Object[] {new java.lang.Double($param_double_1),
+ new java.lang.Double($param_double_2)},
+ 864055858262779977L);
+ return ((java.lang.Double)$result).doubleValue();
+ } catch (java.lang.RuntimeException e) {
+ throw e;
+ } catch (java.rmi.RemoteException e) {
+ throw e;
+ } catch (java.lang.Exception e) {
+ throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+ }
+ }
+
+ // implementation of divide(double, double)
+ public double divide(double $param_double_1, double $param_double_2) throws java.rmi.RemoteException {
+ try {
+ Object $result =
+ ref.invoke(this,
+ $method_divide_1,
+ new java.lang.Object[] {new java.lang.Double($param_double_1),
+ new java.lang.Double($param_double_2)},
+ 8097593626497421928L);
+ return ((java.lang.Double)$result).doubleValue();
+ } catch (java.lang.RuntimeException e) {
+ throw e;
+ } catch (java.rmi.RemoteException e) {
+ throw e;
+ } catch (java.lang.Exception e) {
+ throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+ }
+ }
+
+ // implementation of multiply(double, double)
+ public double multiply(double $param_double_1, double $param_double_2) throws java.rmi.RemoteException {
+ try {
+ Object $result =
+ ref.invoke(this,
+ $method_multiply_2,
+ new java.lang.Object[] {new java.lang.Double($param_double_1),
+ new java.lang.Double($param_double_2)},
+ -346155016949350695L);
+ return ((java.lang.Double)$result).doubleValue();
+ } catch (java.lang.RuntimeException e) {
+ throw e;
+ } catch (java.rmi.RemoteException e) {
+ throw e;
+ } catch (java.lang.Exception e) {
+ throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+ }
+ }
+
+ // implementation of subtract(double, double)
+ public double subtract(double $param_double_1, double $param_double_2) throws java.rmi.RemoteException {
+ try {
+ Object $result =
+ ref.invoke(this,
+ $method_subtract_3,
+ new java.lang.Object[] {new java.lang.Double($param_double_1),
+ new java.lang.Double($param_double_2)},
+ -610707357620578750L);
+ return ((java.lang.Double)$result).doubleValue();
+ } catch (java.lang.RuntimeException e) {
+ throw e;
+ } catch (java.rmi.RemoteException e) {
+ throw e;
+ } catch (java.lang.Exception e) {
+ throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRemote.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRemote.java
new file mode 100644
index 0000000000..955e386ad8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRemote.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 calculator.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * RMI Remote interface
+ */
+public interface OperationsRemote extends Remote {
+ double add(double n1, double n2) throws RemoteException;
+
+ double subtract(double n1, double n2) throws RemoteException;
+
+ double multiply(double n1, double n2) throws RemoteException;
+
+ double divide(double n1, double n2) throws RemoteException;
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java
new file mode 100644
index 0000000000..565a314d85
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package calculator.dosgi.test;
+
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+/**
+ *
+ */
+public class CalculatorNode {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ if (args.length == 0) {
+ args = new String[] {"-bundles"};
+ }
+ try {
+ NodeLauncher.main(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
new file mode 100644
index 0000000000..4015c7bbc2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.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 calculator.dosgi.test;
+
+import static calculator.dosgi.test.OSGiTestUtils.bundleStatus;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+
+import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+import calculator.dosgi.CalculatorService;
+import calculator.rmi.OperationsRMIServer;
+
+/**
+ *
+ */
+public class CalculatorOSGiNodeTestCase {
+ private static EquinoxHost host;
+ private static BundleContext context;
+ private static Bundle calculatorBundle;
+ private static OperationsRMIServer rmiServer;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ try {
+ rmiServer = new OperationsRMIServer();
+ rmiServer.start();
+
+ host = new EquinoxHost();
+ context = host.start();
+
+ for (Bundle b : context.getBundles()) {
+ System.out.println(b);
+ if (b.getSymbolicName().equals("org.eclipse.equinox.ds") || b.getSymbolicName()
+ .startsWith("org.apache.tuscany.sca.")) {
+ try {
+ if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) {
+ // Start the non-fragment bundle
+ b.start();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println(bundleStatus(b, false));
+ }
+ if ("calculator.dosgi.dynamic".equals(b.getSymbolicName())) {
+ calculatorBundle = b;
+ }
+ }
+
+ if (calculatorBundle != null) {
+ calculatorBundle.start();
+ System.out.println(bundleStatus(calculatorBundle, false));
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
+ public void testOSGi() {
+ ServiceReference ref =
+ calculatorBundle.getBundleContext().getServiceReference(CalculatorService.class.getName());
+ Assert.assertNotNull(ref);
+ Object service = context.getService(ref);
+ Assert.assertNotNull(service);
+ CalculatorService calculator = OSGiTestUtils.cast(service, CalculatorService.class);
+ System.out.println("2.0 + 1.0 = " + calculator.add(2.0, 1.0));
+ System.out.println("2.0 - 1.0 = " + calculator.subtract(2.0, 1.0));
+ System.out.println("2.0 * 1.0 = " + calculator.multiply(2.0, 1.0));
+ System.out.println("2.0 / 1.0 = " + calculator.divide(2.0, 1.0));
+ }
+
+ @Test
+ /**
+ * Test the Web service exposed by the Calculator
+ */
+ public void testWS() throws Exception {
+ URL url = new URL("http://localhost:8086/CalculatorService?wsdl");
+ InputStream is = url.openStream();
+ Reader reader = new InputStreamReader(is);
+ char[] content = new char[10240]; // 10k
+ int len = 0;
+ while (true) {
+ int size = reader.read(content, len, content.length - len);
+ if (size < 0) {
+ break;
+ }
+ len += size;
+ }
+ Assert.assertTrue(len > 0);
+ String str = new String(content, 0, len);
+ System.out.println(str);
+ Assert.assertTrue(str.indexOf("<wsdl:definitions") != -1);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (host != null) {
+ host.stop();
+ rmiServer.stop();
+ host = null;
+ rmiServer = null;
+ context = null;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..99e0da9f97
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator.dosgi.test;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * Utility class to create OSGi bundles
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiTestUtils {
+ private static class InvocationHandlerImpl implements InvocationHandler {
+ private Object instance;
+
+ public InvocationHandlerImpl(Object instance) {
+ super();
+ this.instance = instance;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ Method m = instance.getClass().getMethod(method.getName(), method.getParameterTypes());
+ return m.invoke(instance, args);
+ }
+
+ }
+
+ /**
+ * Returns a string representation of the given bundle.
+ *
+ * @param b
+ * @param verbose
+ * @return
+ */
+ public static String bundleStatus(Bundle bundle, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(bundle.getBundleId()).append(" ").append(bundle.getSymbolicName());
+ int s = bundle.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ if (verbose) {
+ sb.append(" ").append(bundle.getLocation());
+ sb.append(" ").append(bundle.getHeaders());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * A utility to cast the object to the given interface. If the class for the object
+ * is loaded by a different classloader, a proxy will be created.
+ *
+ * @param <T>
+ * @param obj
+ * @param cls
+ * @return
+ */
+ public static <T> T cast(Object obj, Class<T> cls) {
+ if (cls.isInstance(obj)) {
+ return cls.cast(obj);
+ } else {
+ return cls.cast(Proxy.newProxyInstance(cls.getClassLoader(),
+ new Class<?>[] {cls},
+ new InvocationHandlerImpl(obj)));
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/README b/sandbox/sebastien/java/embed/samples/helloworld-bpel/README
new file mode 100644
index 0000000000..533743ebf6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/README
@@ -0,0 +1,153 @@
+Hello World BPEL Sample
+======================================
+This sample demonstrates an SCA service implemented by a BPEL process.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+If you just want to run it to see what happens open a command prompt, navigate
+to this sample directory, and do
+
+ant compile run
+
+OR if you don't have ant, on Windows do
+
+mkdir target\classes
+mkdir target\wsdl2java-source
+java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl
+java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl
+unzip ..\..\lib\ode-dao-jpa-ojpa-derby-1.1.zip -d target\database
+javac -d target\classes -cp target\classes;..\..\lib\tuscany-sca-manifest.jar -sourcepath src\main\java;target\wsdl2java-source -target 1.5 -g -source 1.5 src\main\java\helloworld\BPELClient.java
+copy src\main\resources\* target\classes
+java -cp ..\..\lib\tuscany-sca-manifest.jar;target\classes;target\database helloworld.BPELClient
+
+and on *nix do
+
+mkdir target/classes
+mkdir target/wsdl2java-source
+java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl
+java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl
+unzip ../../lib/ode-dao-jpa-ojpa-derby-1.1.zip -d target/database
+javac -d target/classes -cp target/classes;../../lib/tuscany-sca-manifest.jar -sourcepath src/main/java;target/wsdl2java-source -target 1.5 -g -source 1.5 src/main/java/helloworld/BPELClient.java
+cp src/main/resources/* target/classes
+java -cp ../../lib/tuscany-sca-manifest.jar:target/classes:target/database helloworld.BPELClient
+
+The sample will start an embedded BPEL engine, deploy a process and invoke it.
+
+Sample Overview
+---------------
+The sample provides a single component that is wired to a service with a
+web service binding.
+
+helloworld-bpel/
+ src/
+ main/
+ java/
+ helloworld/
+ BPELClient.java - client application for
+ BEPELHelloWorldComponent
+
+ resources/
+ deploy.xml - ODE deployment descriptor
+ helloworld.bpel - helloworld bpel process
+ helloworld.componentType - helloworld bpel service description
+ helloworld.composite - the SCA assembly for this sample
+ helloworld.wsdl - the service description that describes
+ the bpel process
+ log4j.properties - logging configuration
+
+ test/
+ java/
+ helloworld/
+ BPELHelloWorldTestCase.java - JUnit test case
+ helloworld-bpel.png - a pictorial representation of the
+ sample .composite file
+ build.xml - the Ant build file
+ pom.xml - the Maven build file
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+
+With the binary distribution the sample can be built and run using Ant as
+follows
+
+cd helloworld-bpel
+ant compile
+ant run
+
+
+You should see the following output from the run target.
+
+run:
+ [java] Starting BPELHelloWorldComponent
+ [java] >>> Deploying : D:\temp\SCA1.1-RC1\tuscany-sca-1.1-incubating\samples\helloworld-bpel\target\classes
+ [java] ::arg:::::: <?xml version="1.0" encoding="UTF-8"?>
+ [java] <hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"><message xmlns="http://tuscany.apache.org/implementation/bpel/exampl
+e/helloworld.wsdl">Hello</message></hello>
+ [java] ::message:: <?xml version="1.0" encoding="UTF-8"?>
+ [java] <message><TestPart><hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"><message xmlns="http://tuscany.apache.org/impleme
+ntation/bpel/example/helloworld.wsdl">Hello</message></hello></TestPart></message>
+ [java] Status: RESPONSE
+ [java] Response: <?xml version="1.0" encoding="UTF-8"?>
+ [java] <message><TestPart><hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl">Hello World</hello></TestPart></message>
+ [java] Hello World
+ [java] Stopping BPELHelloWorldComponent
+ [java] Stopped !!!
+
+BUILD SUCCESSFUL
+Total time: 36 seconds
+
+Building And Running The Sample Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built and run
+using Maven as follows. When using Maven, a simple test is present that exercise
+the same logic as the client to invoke the BPEl process.
+
+cd helloworld-bpel
+mvn
+
+You should see the following output from the test phase.
+
+-
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running helloworld.BPELHelloWorldTestCase
+Starting BPELHelloWorldComponent
+>>> Deploying : D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\classes
+::arg:::::: <?xml version="1.0" encoding="UTF-8"?>
+<hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"><message xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld
+.wsdl">Hello</message></hello>
+::message:: <?xml version="1.0" encoding="UTF-8"?>
+<message><TestPart><hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"><message xmlns="http://tuscany.apache.org/implementation/bpel
+/example/helloworld.wsdl">Hello</message></hello></TestPart></message>
+Status: RESPONSE
+Response: <?xml version="1.0" encoding="UTF-8"?>
+<message><TestPart><hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl">Hello World</hello></TestPart></message>
+Stopping BPELHelloWorldComponent
+Stopped !!!
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 18.656 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+[INFO] [jar:jar]
+[INFO] Building jar: D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar
+[INFO] [install:install]
+[INFO] Installing D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar to C:\Documents and Settings\lresend
+e\.m2\repository\org\apache\tuscany\sca\sample-helloworld-bpel\1.1-incubating-SNAPSHOT\sample-helloworld-bpel-1.1-incubating-SNAPSHOT.jar
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESSFUL
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 53 seconds
+[INFO] Finished at: Sun Jan 13 09:54:39 PST 2008
+[INFO] Final Memory: 24M/43M
+[INFO] ------------------------------------------------------------------------
+
+
+This shows that the Junit test cases have run successfully.
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/build.xml b/sandbox/sebastien/java/embed/samples/helloworld-bpel/build.xml
new file mode 100644
index 0000000000..008953e63b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/build.xml
@@ -0,0 +1,95 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="sample-helloworld-bpel" default="compile">
+ <property name="test.class" value="helloworld.BPELClient" />
+ <property name="test.jar" value="sample-helloworld-bpel.jar" />
+ <property name="manifest.jar" value="../../lib/tuscany-sca-manifest.jar" />
+
+ <target name="init">
+ <mkdir dir="target/classes"/>
+ <mkdir dir="target/wsdl2java-source"/>
+ </target>
+
+ <target name="generate-wsdl" depends="init">
+ <java classname="org.apache.tuscany.sdo.generate.XSD2JavaGenerator" fork="true">
+ <arg value="-targetDirectory"/>
+ <arg value="target/wsdl2java-source"/>
+ <arg value="-prefix"/>
+ <arg value="HelloWorld"/>
+ <arg value="-noContainment"/>
+ <arg value="-noUnsettable"/>
+ <arg value="src/main/resources/helloworld.wsdl"/>
+
+ <classpath>
+ <pathelement location="${manifest.jar}"/>
+ </classpath>
+ </java>
+
+ <java classname="org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator" fork="true">
+ <arg value="-targetDirectory"/>
+ <arg value="target/wsdl2java-source"/>
+ <arg value="src/main/resources/helloworld.wsdl"/>
+
+ <classpath>
+ <pathelement location="${manifest.jar}"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="unzip-ode-db" depends="init">
+ <unzip src="../../lib/ode-dao-jpa-ojpa-derby-1.3.2.zip" dest="target/database"/>
+ </target>
+
+ <target name="compile" depends="init,generate-wsdl,unzip-ode-db">
+ <javac destdir="target/classes" debug="on" source="1.5" target="1.5">
+ <src path="src/main/java"/>
+ <src path="target/wsdl2java-source"/>
+ <classpath>
+ <pathelement location="${manifest.jar}"/>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${test.jar}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${test.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run">
+ <java classname="${test.class}" fork="true">
+ <!-- jvmarg value="-Xdebug"/ -->
+ <!-- jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"/ -->
+ <classpath>
+ <pathelement location="target/classes"/>
+ <pathelement location="target/database"/>
+ <pathelement location="${manifest.jar}"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="clean">
+ <delete includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/helloworld-bpel.png b/sandbox/sebastien/java/embed/samples/helloworld-bpel/helloworld-bpel.png
new file mode 100644
index 0000000000..5f53a3c5d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/helloworld-bpel.png
Binary files differ
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/helloworld-bpel.svg b/sandbox/sebastien/java/embed/samples/helloworld-bpel/helloworld-bpel.svg
new file mode 100644
index 0000000000..5a98f1a07c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/helloworld-bpel.svg
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="1052.3622"
+ height="744.09448"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.45.1"
+ sodipodi:docbase="C:\simon\tuscany\java-panic\sca\samples\helloworld-bpel"
+ sodipodi:docname="helloworld-bpel.svg"
+ version="1.0"
+ inkscape:export-filename="C:\simon\tuscany\java-panic\sca\samples\helloworld-bpel\helloworld-bpel.png"
+ inkscape:export-xdpi="52.84"
+ inkscape:export-ydpi="52.84"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.4"
+ inkscape:cx="519.38407"
+ inkscape:cy="414.63224"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:window-width="1141"
+ inkscape:window-height="676"
+ inkscape:window-x="360"
+ inkscape:window-y="147" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <g
+ id="g2997"
+ transform="matrix(0.991389,0,0,1,2.215655,0)">
+ <rect
+ rx="13.79423"
+ ry="12.692303"
+ y="192.00233"
+ x="258.3114"
+ height="299.99988"
+ width="446.72086"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:2.00866628;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <flowRoot
+ id="flowRoot2954"
+ xml:space="preserve"><flowRegion
+ id="flowRegion2956"><rect
+ y="212.66591"
+ x="281.42856"
+ height="61.42857"
+ width="170"
+ id="rect2958" /></flowRegion><flowPara
+ id="flowPara2960">helloworldws</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.77353811;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="137.03178"
+ height="139.37514"
+ x="433.16025"
+ y="308.26868"
+ rx="8.2887468"
+ ry="11.562291" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(183.89697,109.51481)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">HelloWorld</flowPara><flowPara
+ id="flowPara1883">Service</flowPara><flowPara
+ id="flowPara1885">Component</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 414.90867,339.0146 L 448.24371,339.0146 L 454.30462,352.14658 L 447.23356,364.26842 L 414.90867,364.26842 L 422.48482,352.14658 L 414.90867,339.0146 z "
+ id="path3017" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 226.73064,320.75315 L 293.91185,320.75315 L 306.1266,352.82797 L 291.87606,382.43553 L 226.73064,382.43553 L 241.99911,352.82797 L 226.73064,320.75315 z "
+ id="path1892" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1894"
+ transform="translate(-37.47944,122.8324)"
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1896"><rect
+ id="rect1898"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1900">HelloWorld</flowPara><flowPara
+ id="flowPara1906">Web</flowPara><flowPara
+ id="flowPara1904">Service</flowPara></flowRoot> <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 305.71429,353.3802 L 422.85714,351.95163"
+ id="path1910"
+ inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\helloworld-ws-service\helloworld-ws-service.png"
+ inkscape:export-xdpi="52.84"
+ inkscape:export-ydpi="52.84" />
+ <rect
+ style="opacity:1;fill:#e4a637;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.03563392;stroke-miterlimit:4;stroke-dasharray:6.21380369, 1.03563395;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2179"
+ width="107.35972"
+ height="30.216856"
+ x="454.17728"
+ y="404.70035"
+ rx="1.1482089"
+ ry="1.0659764" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot3152"
+ transform="matrix(0.8110318,0,0,0.9349147,74.607827,34.581873)"><flowRegion
+ id="flowRegion3154"><rect
+ id="rect3156"
+ width="114.28571"
+ height="12.857142"
+ x="450.71429"
+ y="376.23734" /></flowRegion><flowPara
+ id="flowPara3158">implementation.bpel</flowPara></flowRoot> <text
+ xml:space="preserve"
+ style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="466.42856"
+ y="423.38019"
+ id="text3160"><tspan
+ sodipodi:role="line"
+ id="tspan3162"
+ x="466.42856"
+ y="423.38019">helloworld.bpel</tspan></text>
+ </g>
+</svg>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/pom.xml b/sandbox/sebastien/java/embed/samples/helloworld-bpel/pom.xml
new file mode 100644
index 0000000000..3f4be82f71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <packaging>zip</packaging>
+ <artifactId>sample-helloworld-bpel</artifactId>
+ <name>Apache Tuscany SCA Sample HelloWorld BPEL</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <!-- plugin to support zip packaging for SCA contributions -->
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-zip-plugin</artifactId>
+ <version>alpha2</version>
+ <extensions>true</extensions>
+ </plugin>
+
+ <!-- plugin to support using mvn tuscany:run to run this contribution -->
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-bpel</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/java/helloworld/Hello.java b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/java/helloworld/Hello.java
new file mode 100644
index 0000000000..dbd3854d7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/java/helloworld/Hello.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Hello {
+
+ String hello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..4a56523adb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://bpel">
+ <deployable composite="sample:bpel"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.bpel b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.bpel
new file mode 100644
index 0000000000..d58768adfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.bpel
@@ -0,0 +1,80 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://testing/"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0" xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+
+ <import location="helloworld.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://testing/"/>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink" partnerLinkType="test:HelloPartnerLinkType" myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="helloMessage" messageType="test:HelloMessage"/>
+ <variable name="helloMessageResponse" messageType="test:HelloMessageResponse"/>
+ <variable name="tmpVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessage"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <!-- from>concat($helloMessage.TestPart/test:message/text(), ' World')</from -->
+ <from>concat($helloMessage.TestPart/test:arg0/text(), ' World')</from>
+ <!-- from>concat('Hello ', 'world')</from -->
+ <to variable="tmpVar"/>
+ </copy>
+ <!-- Initialize the response -->
+ <copy>
+ <from>
+ <literal>
+ <test:helloResponse>
+ <test:messageResponse>Dummy</test:messageResponse>
+ </test:helloResponse>
+ </literal>
+ </from>
+ <to variable="helloMessageResponse" part="TestResponse"/>
+ </copy>
+ <copy>
+ <from variable="tmpVar"/>
+ <to>$helloMessageResponse.TestResponse/test:messageResponse</to>
+ </copy>
+ </assign>
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="helloMessageResponse"/>
+ </sequence>
+</process>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..08350e8417
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://bpel"
+ xmlns:hns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ name="bpel">
+
+ <component name="HelloworldComponent">
+ <implementation.bpel process="hns:HelloWorld"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.wsdl b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..cf966264ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/helloworld.wsdl
@@ -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.
+ -->
+
+<wsdl:definitions name="helloworld"
+ targetNamespace="http://testing/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://testing/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://testing/"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="message" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="helloResponse">
+ <complexType>
+ <sequence>
+ <element name="messageResponse" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part element="tns:hello" name="TestPart"/>
+ </wsdl:message>
+
+ <wsdl:message name="HelloMessageResponse">
+ <wsdl:part element="tns:helloResponse" name="TestResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessageResponse" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="TestIn">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="TestOut">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8085/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/log4j.properties b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/log4j.properties
new file mode 100644
index 0000000000..8649a71550
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-bpel/src/main/resources/log4j.properties
@@ -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.
+#
+
+# Set root logger level to WARN and its only appender to CONSOLE
+log4j.rootLogger=OFF, CONSOLE
+
+# log4j properties to work with commandline tools.
+log4j.category.org.mortbay=OFF
+log4j.category.org.hibernate.type=OFF
+log4j.category.org.objectweb=OFF
+log4j.category.org.apache.ode.sql=OFF
+log4j.category.org.apache.ode.axis2=OFF
+log4j.category.org.apache.ode.bpel.engine=OFF
+log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF
+log4j.category.org.apache.ode.bpel.epr=OFF
+log4j.category.org.apache.openjpa.kernel=OFF
+
+# Console appender
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%p - %C{1}.%M(%L) | %m%n \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-scaclient/pom.xml b/sandbox/sebastien/java/embed/samples/helloworld-scaclient/pom.xml
new file mode 100644
index 0000000000..4e7f057ca9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-scaclient/pom.xml
@@ -0,0 +1,69 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-scaclient</artifactId>
+ <name>Apache Tuscany SCA Sample Helloworld SCAClient</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>sample.HelloworldSCAClient</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/main/java/sample/Helloworld.java b/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/main/java/sample/Helloworld.java
new file mode 100644
index 0000000000..f4e8c50448
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/main/java/sample/Helloworld.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/main/java/sample/HelloworldSCAClient.java b/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/main/java/sample/HelloworldSCAClient.java
new file mode 100644
index 0000000000..c2c9c4e44e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/main/java/sample/HelloworldSCAClient.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.URI;
+
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+public class HelloworldSCAClient {
+
+ public static void main(String[] args) throws NoSuchDomainException, NoSuchServiceException {
+
+ String domainURI = "default";
+ String name = "world";
+
+ if (args.length == 2) {
+ domainURI= args[0];
+ name = args[1];
+ } else if (args.length == 1) {
+ domainURI= args[0];
+ }
+
+ System.out.println("using domain uri: " + domainURI);
+ System.out.println("using name: " + name);
+
+ SCAClientFactory factory = SCAClientFactory.newInstance(URI.create(domainURI));
+ Helloworld service = factory.getService(Helloworld.class, "HelloworldComponent");
+
+ System.out.println("Calling HelloworldComponent.sayHello(\"" + name + "\")");
+ System.out.println(service.sayHello(name));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/test/java/sample/HelloworldTestCase.java b/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/test/java/sample/HelloworldTestCase.java
new file mode 100644
index 0000000000..13e08de692
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-scaclient/src/test/java/sample/HelloworldTestCase.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 sample;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class HelloworldTestCase {
+
+ @Test
+ public void testSayHello() {
+ HelloworldSCAClient helloworld = new HelloworldSCAClient();
+// assertEquals("Hello Petra", helloworld.sayHello("Petra"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/pom.xml b/sandbox/sebastien/java/embed/samples/helloworld-spring/pom.xml
new file mode 100644
index 0000000000..b8cb765c38
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-spring</artifactId>
+ <name>Apache Tuscany SCA Sample HelloWorld using Spring</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <!-- plugin to support using mvn tuscany:run to run this contribution -->
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/DateService.java b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/DateService.java
new file mode 100644
index 0000000000..7c50d66a9c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/DateService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.util.Date;
+
+/**
+ *
+ */
+public interface DateService {
+ Date getDate();
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/DateServiceImpl.java b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/DateServiceImpl.java
new file mode 100644
index 0000000000..64bdd86f7c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/DateServiceImpl.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 sample;
+
+import java.util.Date;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(DateService.class)
+public class DateServiceImpl implements DateService {
+
+ public Date getDate() {
+ System.out.println("DateServiceImpl.getDate()");
+ return new Date();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/Helloworld.java b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/Helloworld.java
new file mode 100644
index 0000000000..f4e8c50448
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/Helloworld.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/HelloworldClientImpl.java b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/HelloworldClientImpl.java
new file mode 100644
index 0000000000..a01aad9d88
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/HelloworldClientImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloworldClientImpl implements Helloworld {
+ private Helloworld helloworld;
+
+ // SCA reference
+ @Reference(required = false)
+ private DateService dateService;
+
+ public HelloworldClientImpl() {
+ System.out.println("HelloworldClientImpl()");
+ }
+
+ public String sayHello(String name) {
+ System.out.println("HelloworldClientImpl.sayHello(" + name + ")");
+ if (dateService == null) {
+ return "Hello " + name;
+ }
+ return "[" + dateService.getDate() + "] " + helloworld.sayHello(name);
+ }
+
+ // Setter for spring injection
+ public void setHelloworld(Helloworld helloworld) {
+ System.out.println("Injected with " + helloworld);
+ this.helloworld = helloworld;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.java b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.java
new file mode 100644
index 0000000000..125c333ddc
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.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 sample;
+
+
+public class HelloworldImpl implements Helloworld {
+
+ public HelloworldImpl() {
+ super();
+ System.out.println("HelloworldImpl()");
+ }
+
+ public String sayHello(String name) {
+ System.out.println("HelloworldImpl.sayHello(" + name + ")");
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..552d100638
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld-client-context.xml b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld-client-context.xml
new file mode 100644
index 0000000000..0e30cfa582
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld-client-context.xml
@@ -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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="HelloworldClientBean" class="sample.HelloworldClientImpl">
+ <property name="helloworld">
+ <ref bean="HelloworldBean"/>
+ </property>
+ </bean>
+
+ <!--
+ <sca:reference name="dateService" type="sample.DateService"/>
+ -->
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld-context.xml b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld-context.xml
new file mode 100644
index 0000000000..9ecd09974e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld-context.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="HelloworldBean" class="sample.HelloworldImpl">
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..6d356758ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/main/resources/helloworld.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="helloworld">
+
+ <component name="HelloworldClientComponent">
+ <implementation.spring location="helloworld-client-context.xml"/>
+ <service name="HelloworldClientBean">
+ <tuscany:binding.jsonrpc/>
+ </service>
+ <reference name="dateService" target="DateServiceComponent"/>
+ </component>
+
+ <component name="DateServiceComponent">
+ <implementation.java class="sample.DateServiceImpl"/>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-spring/src/test/java/sample/HelloworldTestCase.java b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/test/java/sample/HelloworldTestCase.java
new file mode 100644
index 0000000000..7e679ec0e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-spring/src/test/java/sample/HelloworldTestCase.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 sample;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class HelloworldTestCase {
+
+ @Test
+ public void testSayHello() {
+ HelloworldImpl helloworld = new HelloworldImpl();
+ assertEquals("Hello Petra", helloworld.sayHello("Petra"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/README b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/README
new file mode 100644
index 0000000000..be947b1923
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/README
@@ -0,0 +1,214 @@
+Hello World Web Service References using SDO Sample
+===================================================
+This sample demonstrates an SCA reference that uses a web service binding which works with SDO.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+To run this sample
+------------------
+This sample is dependent on helloworld-ws-service. Open a command prompt to start
+the service. If you are running ant do the following:
+
+cd helloworld-ws-service
+ant run
+
+if you don't have ant, issue one of the following commands for windows or *nix:
+
+java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-service.jar helloworld.HelloWorldServer
+
+and on *nix do
+
+java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service.jar helloworld.HelloWorldServer
+
+You should see the following output:
+
+Buildfile: build.xml
+
+run-server:
+ [java] log4j:WARN No appenders could be found for logger (org.apache.axiom.
+om.util.StAXUtils).
+ [java] log4j:WARN Please initialize the log4j system properly.
+ [java] Aug 24, 2007 11:17:33 AM org.apache.catalina.core.StandardEngine sta
+rt
+ [java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.10
+ [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.ContextConfig d
+efaultWebConfig
+ [java] INFO: No default web.xml
+ [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
+ register
+ [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.
+xsd
+ [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
+ register
+ [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
+aglibrary_1_1.dtd
+ [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
+ register
+ [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
+aglibrary_1_2.dtd
+ [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
+ register
+ [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
+aglibrary_2_0.xsd
+ [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
+ register
+ [java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_ser
+vices_1_1.xsd
+ [java] Aug 24, 2007 11:17:34 AM org.apache.coyote.http11.Http11Protocol ini
+t
+ [java] INFO: Initializing Coyote HTTP/1.1 on http-8085
+ [java] Aug 24, 2007 11:17:34 AM org.apache.coyote.http11.Http11Protocol sta
+rt
+ [java] INFO: Starting Coyote HTTP/1.1 on http-8085
+ [java] Aug 24, 2007 11:17:34 AM org.apache.tuscany.sca.http.tomcat.TomcatSe
+rver addServletMapping
+ [java] INFO: Added Servlet mapping: http://localhost:8085/HelloWorldService
+
+ [java] HelloWorld server started (press enter to shutdown)
+
+The server is now ready.
+
+
+Now, open another command window to run the client.
+
+cd helloworld-ws-sdo
+ant run
+
+OR if you don't have ant, on Windows do
+
+java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-sdo.jar helloworld.HelloWorldClient
+
+and on *nix do
+
+java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-sdo.jar helloworl.HelloWorldClient
+
+You should be able to see the following result:
+
+Buildfile: build.xml
+
+run:
+ [java] log4j:WARN No appenders could be found for logger (org.apache.axiom.
+om.util.StAXUtils).
+ [java] log4j:WARN Please initialize the log4j system properly.
+ [java] Injected helloWorldService
+ [java] Called getGreetings
+ [java] Hello David Haney
+
+BUILD SUCCESSFUL
+Total time: 9 seconds
+
+
+Sample Overview
+---------------
+The sample provides a single component that is wired to a reference with a
+web service binding. The binding refers to WSDL that identifies the service
+exposed by the helloworld-ws-service sample.
+
+helloworld-ws-sdo/
+ src/
+ main/
+ java/
+ helloworld/
+ HelloWorldService.java - interface description for
+ HelloWorldServiceComponent
+ HelloWorldServiceComponent.java - component implementation
+ HelloWorldClient.java - starts the SCA Runtime and
+ deploys the helloworldwsclient
+ .composite. It then calls the
+ HelloWorldServiceComponent
+ resources/
+ wsdl
+ helloworld.wsdl - the service description that the
+ SCA reference uses to bind to service.
+
+ test/
+ java/
+ helloworld/
+ HelloWorldClientTestCase.java - JUnit test case
+ helloworld-ws-sdo.png - a pictorial representation of the
+ sample .composite file
+ build.xml - the Ant build file
+ pom.xml - the Maven build file
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+You can build and run the sample with the binary distribution using Ant.
+Make sure that you have started helloworld-ws-service which this sample is dependent on
+in a separate command window. You can either follow the instruction at the begining of this
+sample file or if you want to build and run the service, follow the README under helloworld-ws-service.
+
+Now, let's build and run helloworld-ws-sdo sample:
+
+cd helloworld-ws-sdo
+ant
+ant run
+
+You should see the following output from the run target.
+
+run:
+ [java] log4j:WARN No appenders could be found for logger (org.apache.axiom.
+om.util.StAXUtils).
+ [java] log4j:WARN Please initialize the log4j system properly.
+ [java] Injected helloWorldService
+ [java] Called getGreetings
+ [java] Hello World
+
+Building And Running The Sample Using Maven
+-------------------------------------------
+You can build and run the sample with either the binary or source distributions using Maven. Please note that you do not need to start helloworld-ws-service in this case since Maven does this for you.
+
+cd helloworld-ws-sdo
+mvn
+
+You should see the following output from the test phase.
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running helloworld.HelloWorldClientTestCase
+log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX
+Utils).
+log4j:WARN Please initialize the log4j system properly.
+log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX
+Utils).
+log4j:WARN Please initialize the log4j system properly.
+Aug 23, 2007 2:27:32 PM org.apache.catalina.core.StandardEngine start
+INFO: Starting Servlet Engine: Apache Tomcat/6.0.10
+Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.ContextConfig defaultWebConf
+ig
+INFO: No default web.xml
+Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
+WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd
+Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
+WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_
+1.dtd
+Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
+WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_
+2.dtd
+Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
+WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_
+0.xsd
+Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
+WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs
+d
+Aug 23, 2007 2:27:32 PM org.apache.coyote.http11.Http11Protocol init
+INFO: Initializing Coyote HTTP/1.1 on http-8085
+Aug 23, 2007 2:27:32 PM org.apache.coyote.http11.Http11Protocol start
+INFO: Starting Coyote HTTP/1.1 on http-8085
+Aug 23, 2007 2:27:32 PM org.apache.tuscany.sca.http.tomcat.TomcatServer addServl
+etMapping
+INFO: Added Servlet mapping: http://localhost:8085/HelloWorldService
+Injected helloWorldService
+Called getGreetings
+Aug 23, 2007 2:27:34 PM org.apache.coyote.http11.Http11Protocol destroy
+INFO: Stopping Coyote HTTP/1.1 on http-8085
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.502 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+
+This shows that the Junit test cases have run successfully.
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/build.xml b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/build.xml
new file mode 100644
index 0000000000..401315d424
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/build.xml
@@ -0,0 +1,101 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="helloworld-ws-sdo" default="compile" basedir=".">
+ <property file="${user.home}/tuscany/build.properties" />
+ <property file="${user.home}/build.properties" />
+
+ <property name="server.class" value="helloworld.HelloWorldServer" />
+ <property name="client.class" value="helloworld.HelloWorldClient" />
+ <property name="test.jar" value="sample-helloworld-ws-sdo.jar" />
+
+ <property name="tuscany.sca.manifest.location" value="../../lib/tuscany-sca-manifest.jar"/>
+
+ <target name="init">
+ <mkdir dir="target/classes"/>
+ <mkdir dir="target/sdo-source"/>
+ </target>
+
+ <path id="project.classpath">
+ <pathelement path="target/classes"/>
+ <pathelement path="target/sdo-source"/>
+ <pathelement location="${tuscany.sca.manifest.location}"/>
+ </path>
+
+ <target name="generate-sdo" depends="init">
+ <java classname="org.apache.tuscany.sdo.generate.XSD2JavaGenerator" fork="true">
+ <arg value="-targetDirectory"/>
+ <arg value="target/sdo-source"/>
+ <arg value="-javaPackage"/>
+ <arg value="helloworld"/>
+ <arg value="-prefix"/>
+ <arg value="Helloworld"/>
+ <arg value="-noNotification"/>
+ <arg value="-noContainment"/>
+ <arg value="-noUnsettable"/>
+ <arg value="src/main/resources/wsdl/helloworld.wsdl"/>
+
+ <classpath refid="project.classpath"/>
+ </java>
+ </target>
+
+ <target name="compile" depends="init, generate-sdo">
+ <javac destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5">
+ <src location="src/main/java"/>
+ <src location="target/sdo-source"/>
+ <classpath refid="project.classpath"/>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ <fileset dir="target/sdo-source"/>
+ </copy>
+ <jar destfile="target/${test.jar}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${test.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run-classes">
+ <java classname="${client.class}" fork="true">
+ <classpath refid="project.classpath"/> </java>
+ </target>
+
+ <target name="run-server">
+ <java classname="${server.class}" fork="true">
+ <classpath path="target/${test.jar}"/>
+ <classpath refid="project.classpath"/>
+ </java>
+ </target>
+
+ <target name="run">
+ <java classname="${client.class}" fork="true">
+ <classpath path="target/${test.jar}"/>
+ <classpath refid="project.classpath"/>
+ </java>
+ </target>
+
+ <target name="clean">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/helloworld-ws-sdo.png b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/helloworld-ws-sdo.png
new file mode 100644
index 0000000000..bd2bba41db
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/helloworld-ws-sdo.png
Binary files differ
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/maven-eclipse.xml b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/maven-eclipse.xml
new file mode 100644
index 0000000000..3adfca89f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/maven-eclipse.xml
@@ -0,0 +1,8 @@
+<project default="copy-resources">
+ <target name="init"/>
+ <target name="copy-resources" depends="init">
+ <copy todir="target/classes/META-INF" filtering="true">
+ <fileset dir="." includes="LICENSE|NOTICE" excludes="**/*.java"/>
+ </copy>
+ </target>
+</project> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/pom.xml b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/pom.xml
new file mode 100644
index 0000000000..c5bf5ff186
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/pom.xml
@@ -0,0 +1,180 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-helloworld-ws-sdo</artifactId>
+ <name>Apache Tuscany SCA Sample HelloWorld Web Service SDO</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-lib</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/sdo-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <id>generate-helloworld-sdo</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/main/resources/wsdl/helloworld.wsdl</schemaFile>
+ <javaPackage>helloworld</javaPackage>
+ <prefix>Helloworld</prefix>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-helloworld-sdo1</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/main/resources/test.xsd</schemaFile>
+ <javaPackage>model.sdo</javaPackage>
+ <prefix>Entity</prefix>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..ebc270811f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * This client program shows how to create an SCA runtime, start it, locate the
+ * HelloWorld service and invoke it.
+ */
+public class HelloWorldClient {
+
+ public final static void main(String[] args) throws Exception {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution = ContributionLocationHelper.getContributionLocation(HelloWorldClient.class);
+ Node node =
+ factory.createNode("helloworldwsclient.composite", new Contribution("helloworld", contribution)).start();
+
+ HelloWorldService helloWorldService = node.getService(HelloWorldService.class, "HelloWorldServiceComponent");
+
+ Name name = HelloworldFactory.INSTANCE.createName();
+
+ name.setFirst("David");
+ name.setLast("Haney");
+
+ String value = helloWorldService.getGreetings(name);
+ System.out.println(value);
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..c42a4d59c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/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.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String getGreetings(Name name) {
+ return "Hello " + name.getFirst() + " " + name.getLast();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java
new file mode 100644
index 0000000000..ff5cb4ceda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.IOException;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * This server program shows how to create an SCA runtime, and start it which
+ * activates the helloworld Web service endpoint.
+ */
+public class HelloWorldServer {
+
+ public static void main(String[] args) {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution = ContributionLocationHelper.getContributionLocation(HelloWorldServer.class);
+ Node node = factory.createNode("helloworldws.composite", new Contribution("helloworld", contribution)).start();
+
+ try {
+ System.out.println("HelloWorld server started (press enter to shutdown)");
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ node.stop();
+ System.out.println("HelloWorld server stopped");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..fa257a0605
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.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 helloworld;
+
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the helloworld service
+ */
+@Remotable
+public interface HelloWorldService {
+ @RequestWrapper(className="helloworld.getGreetings")
+ @ResponseWrapper(className="helloworld.getGreetingsResponse")
+ public String getGreetings(Name name);
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java
new file mode 100644
index 0000000000..711eef63b5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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;
+
+/**
+ * The HelloWorld service implementation
+ */
+public class HelloWorldServiceComponent implements HelloWorldService {
+
+ HelloWorldService helloWorldService;
+
+ public String getGreetings(Name name) {
+ System.out.println("Called getGreetings");
+ return helloWorldService.getGreetings(name);
+ }
+
+ public HelloWorldService getHelloWorldService() {
+ System.out.println("Got Injected helloWorldService");
+ return helloWorldService;
+ }
+
+ public void setHelloWorldService(HelloWorldService helloWorldService) {
+ System.out.println("Injected helloWorldService");
+ this.helloWorldService = helloWorldService;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BioTestCase.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BioTestCase.java
new file mode 100644
index 0000000000..d222d77b3b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BioTestCase.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services.bcircle;
+
+import model.sdo.EntityFactory;
+import model.sdo.Laboratory;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class BioTestCase {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ BiochemicalCircle biochemicalCircl = new BiochemicalCircleImpl();
+ Laboratory lab2 = biochemicalCircl.getLaboratory("Lab2"); //This invocation without use SCA works ok.
+
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution = ContributionLocationHelper.getContributionLocation(BioTestCase.class);
+ Node node =
+ factory.createNode("resources/clinicalLaboratory.composite", new Contribution("clinical", contribution))
+ .start();
+
+ BiochemicalCircle biochemicalCircle = node.getService(BiochemicalCircle.class, "BiochemicalCircleComponent");
+
+ Laboratory lab = EntityFactory.INSTANCE.createLaboratory();
+ lab.setName("lab2");
+ biochemicalCircle.setLaboratory(lab); // this invocation works ok too
+
+ lab = biochemicalCircle.getLaboratory("Lab2"); // here I have an exception posted below.
+
+ //here I wait a moment before close scaDomain
+ System.out.println(lab.getName());
+
+ node.stop();
+
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircle.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircle.java
new file mode 100644
index 0000000000..a988a4156c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircle.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services.bcircle;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface BiochemicalCircle {
+ void setLaboratory(model.sdo.Laboratory lab);
+
+ model.sdo.Laboratory getLaboratory(String name);
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircleImpl.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircleImpl.java
new file mode 100644
index 0000000000..b609f58373
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircleImpl.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 services.bcircle;
+import model.sdo.EntityFactory;
+import model.sdo.Laboratory;
+
+import org.oasisopen.sca.annotation.Service;
+
+
+@Service(BiochemicalCircle.class)
+public class BiochemicalCircleImpl implements BiochemicalCircle{
+ public Laboratory getLaboratory(String name) {
+
+ Laboratory lab = EntityFactory.INSTANCE.createLaboratory();
+ lab.setName("Main Laboratory");
+ return lab;
+ }
+
+ public void setLaboratory(Laboratory lab) {
+ //sad method
+ System.out.println(lab.getName());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..f8b2a60f6a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/META-INF/sca-contribution.xml
@@ -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.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:hw="http://helloworld"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <deployable composite="hw:helloworldws"/>
+
+ <tuscany:sdo.types namespace="http://helloworld" location="wsdl/helloworld.wsdl"/>
+
+</contribution>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite
new file mode 100644
index 0000000000..46c819d08c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/helloworldws.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://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://helloworld"
+ xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:hw="http://helloworld"
+ name="helloworldws">
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl" />
+ <service name="HelloWorldService">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService" />
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite
new file mode 100644
index 0000000000..65b0e294a8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://helloworld"
+ xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/1.1" xmlns:hw="http://helloworld"
+ name="helloworldwsclient">
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldServiceComponent" />
+ <reference name="helloWorldService">
+ <interface.java interface="helloworld.HelloWorldService" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </reference>
+ </component>
+
+
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/logging.properties b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/logging.properties
new file mode 100644
index 0000000000..3dca310cdb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/logging.properties
@@ -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.
+#
+# $Rev$ $Date$
+#
+
+# Custom logging configuration for Tuscany samples
+# By default, only INFO level logging is enabled and ALL messages get sent to the console
+# For more messages from the runtime, uncomment specific settings at the end of this file
+handlers = java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level = ALL
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+.level=INFO
+
+# Uncomment the next setting to get all Tuscany messages (this will be a lot)
+#org.apache.tuscany.level=FINEST
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/resources/clinicalLaboratory.composite b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/resources/clinicalLaboratory.composite
new file mode 100644
index 0000000000..0451cee24c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/resources/clinicalLaboratory.composite
@@ -0,0 +1,34 @@
+<?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.
+-->
+<sca:composite xmlns:federation="http://eclipse.org/SCAExample1/src/resources/federation"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="clinicalLaboratory"
+ targetNamespace="http://eclipse.org/SCAExample1/src/resources/clinicalLaboratory">
+
+ <sca:component name="BiochemicalCircleComponent">
+ <sca:implementation.java class="services.bcircle.BiochemicalCircleImpl" />
+ <sca:service name="BiochemicalCircle">
+ <sca:interface.java interface="services.bcircle.BiochemicalCircle" />
+ <sca:binding.ws uri="http://localhost:8080/SCA1/MyServiceComponent" />
+ </sca:service>
+ </sca:component>
+ <!--
+ <sca:service name="BiochemicalCircle" promote="BiochemicalCircleComponent/BiochemicalCircle" />
+ -->
+</sca:composite>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/test.xsd b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/test.xsd
new file mode 100644
index 0000000000..7fd9aa0013
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/test.xsd
@@ -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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://eclipse.org/SCAExample1/src/resources/clinicalLaboratory"
+ xmlns:tns="http://eclipse.org/SCAExample1/src/resources/clinicalLaboratory"
+ elementFormDefault="qualified">
+ <complexType name="Practice">
+ <sequence>
+ <element name="name" type="string" />
+ </sequence>
+ </complexType>
+ <complexType name="Laboratory">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="practices" type="tns:Practice" maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+</schema>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl
new file mode 100644
index 0000000000..882819110f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl
@@ -0,0 +1,88 @@
+<?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="tns:Name" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <complexType name="Name">
+ <sequence>
+ <element name="first" type="xsd:string" />
+ <element name="last" type="xsd:string" />
+ </sequence>
+ </complexType>
+
+ </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:8085/HelloWorldService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java
new file mode 100644
index 0000000000..3918f9a4a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.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 helloworld;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test case for helloworld web service client
+ */
+public class HelloWorldClientTestCase {
+
+ private HelloWorldService helloWorldService;
+ private static Node node;
+
+ private TestCaseRunner server;
+
+ @Before
+ public void startClient() throws Exception {
+ try {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution = ContributionLocationHelper.getContributionLocation(HelloWorldClient.class);
+ node =
+ factory.createNode("helloworldwsclient.composite", new Contribution("helloworld", contribution))
+ .start();
+
+ helloWorldService = node.getService(HelloWorldService.class, "HelloWorldServiceComponent");
+
+ server = new TestCaseRunner(HelloWorldTestServer.class);
+ server.before();
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testWSClient() throws Exception {
+ Name name = HelloworldFactory.INSTANCE.createName();
+ name.setFirst("John");
+ name.setLast("Smith");
+ String msg = helloWorldService.getGreetings(name);
+ Assert.assertEquals("Hello John Smith", msg);
+ }
+
+ @After
+ public void stopClient() throws Exception {
+ server.after();
+ node.stop();
+ }
+
+ public static void main(String[] args) throws Exception {
+ HelloWorldClientTestCase test = new HelloWorldClientTestCase();
+ test.startClient();
+ test.testWSClient();
+
+ System.in.read();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java
new file mode 100644
index 0000000000..98487ad88b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Starts up the SCA runtime which starts listening for service requests
+ */
+public class HelloWorldTestServer {
+
+ private Node node;
+
+ @Before
+ public void startServer() throws Exception {
+ try {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution = ContributionLocationHelper.getContributionLocation(HelloWorldService.class);
+ node = factory.createNode("helloworldws.composite", new Contribution("helloworld", contribution)).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testPing() throws IOException {
+ new Socket("127.0.0.1", 8085);
+ }
+
+ @After
+ public void stopServer() throws Exception {
+ node.stop();
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ HelloWorldTestServer test = new HelloWorldTestServer();
+ test.startServer();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/TestCaseRunner.java b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/TestCaseRunner.java
new file mode 100644
index 0000000000..b6b4ed2254
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld-ws-sdo/src/test/java/helloworld/TestCaseRunner.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A helper class that can be used to run an SCA JUnit test case. The test case will run in an isolated class loader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestCaseRunner {
+
+ private ClassLoader classLoader;
+ private Class<?> testSuiteClass;
+ private Object testSuite;
+ private Class<?> testResultClass;
+ private Class<?> testCaseClass;
+ private Object testCase;
+
+ private Class<?> beforeAnnotation;
+ private Class<?> beforeClassAnnotation;
+ private Class<?> afterAnnotation;
+ private Class<?> afterClassAnnotation;
+ private Class<?> junit4AdapterClass;
+ private Class<?> junit3TestCaseClass;
+
+ /**
+ * Constructs a new TestCase runner.
+ *
+ * @param testClass
+ */
+ public TestCaseRunner(Class<?> testClass, String... isolatedClasses) {
+ try {
+ ClassLoader tccl = setupClassLoader(testClass, isolatedClasses);
+
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ testCaseClass = Class.forName(testClass.getName(), true, classLoader);
+ testCase = testCaseClass.newInstance();
+ ClassLoader testClassLoader = testCaseClass.getClassLoader();
+
+ junit3TestCaseClass = Class.forName("junit.framework.TestCase", true, testClassLoader);
+
+ testSuiteClass = Class.forName("junit.framework.TestSuite", true, testClassLoader);
+ Constructor<?> testSuiteConstructor = testSuiteClass.getConstructor(Class.class);
+ testSuite = testSuiteConstructor.newInstance(testCaseClass);
+
+ testResultClass = Class.forName("junit.framework.TestResult", true, testClassLoader);
+
+ try {
+ beforeAnnotation = Class.forName("org.junit.Before", true, testClassLoader);
+ afterAnnotation = Class.forName("org.junit.After", true, testClassLoader);
+ beforeClassAnnotation = Class.forName("org.junit.BeforeClass", true, testClassLoader);
+ afterClassAnnotation = Class.forName("org.junit.AfterClass", true, testClassLoader);
+ junit4AdapterClass = Class.forName("junit.framework.JUnit4TestAdapter", true, testClassLoader);
+ } catch (Exception e) {
+ // Unexpected
+ throw new AssertionError(e);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ClassLoader setupClassLoader(Class<?> testClass, String... isolatedClasses) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ classLoader = testClass.getClassLoader();
+ if (classLoader instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader)classLoader).getURLs();
+ classLoader = new ClassLoaderImpl(urls, classLoader, isolatedClasses);
+ } else if (classLoader == tccl || classLoader.getParent() == tccl) {
+ classLoader = new URLClassLoader(new URL[0], classLoader);
+ } else {
+ classLoader = tccl;
+ }
+ return tccl;
+ }
+
+ /**
+ * Run the test case
+ */
+ public void run() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ if (junit3TestCaseClass.isAssignableFrom(testCaseClass)) {
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = testSuiteClass.getMethod("run", testResultClass);
+ runMethod.invoke(testSuite, testResult);
+ } else {
+ Object junit4Adapter = junit4AdapterClass.getConstructor(Class.class).newInstance(testCaseClass);
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = junit4AdapterClass.getMethod("run", testResultClass);
+ runMethod.invoke(junit4Adapter, testResult);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Invoke the setUp method
+ */
+ public void setUp() {
+ execute("setUp");
+ }
+
+ /**
+ * Invoke the before methods
+ */
+ public void before() {
+ execute(beforeAnnotation);
+ }
+
+ /**
+ * Invoke the beforeClass methods
+ */
+ public void beforeClass() {
+ execute(beforeClassAnnotation);
+ }
+
+ /**
+ * Invoke the tearDown method
+ */
+ public void tearDown() {
+ execute("tearDown");
+ }
+
+ /**
+ * Invoke the after methods
+ */
+ public void after() {
+ execute(afterAnnotation);
+ }
+
+ /**
+ * Invoke the afterClass methods
+ */
+ public void afterClass() {
+ execute(afterClassAnnotation);
+ }
+
+ /**
+ * Invoke the specified test method.
+ */
+ public void run(String methodName) {
+ execute(methodName);
+ }
+
+ /**
+ * Invoke the methods annotated with the specified annotation.
+ */
+ private void execute(Class<?> annotationClass) {
+ if (annotationClass == null) {
+ throw new RuntimeException(new NoSuchMethodException());
+ }
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+
+ for (Method method : testCaseClass.getDeclaredMethods()) {
+ for (Annotation annotation : method.getAnnotations()) {
+ if (annotation.annotationType() == annotationClass) {
+ method.invoke(testCase);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Invoke the specified method
+ */
+ private void execute(String methodName) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(classLoader);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finalClassLoader = classLoader;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finalClassLoader);
+ return null;
+ }
+ });
+ Method setUpMethod = testCaseClass.getDeclaredMethod(methodName);
+ setUpMethod.setAccessible(true);
+ setUpMethod.invoke(testCase);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ // Thread.currentThread().setContextClassLoader(tccl);
+ // Allow privileged access to set class loader. Requires RuntimePermission
+ // setContextClassLoader in security policy.
+ final ClassLoader finaltccl = tccl;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(finaltccl);
+ return null;
+ }
+ });
+ }
+ }
+
+ public static class ClassLoaderImpl extends URLClassLoader {
+ private Set<String> isolatedClasses = new HashSet<String>();
+
+ /**
+ * @param urls
+ * @param parent
+ */
+ public ClassLoaderImpl(URL[] urls, ClassLoader parent, String... sharedClasses) {
+ super(urls, parent);
+ this.isolatedClasses.addAll(Arrays.asList(sharedClasses));
+ }
+
+ @Override
+ protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ if (!isolatedClasses.contains(name)) {
+ return super.loadClass(name, resolve);
+ } else {
+ Class<?> cls = findLoadedClass(name);
+ if (cls == null) {
+ cls = findClass(name);
+ }
+ if (resolve) {
+ resolveClass(cls);
+ }
+ return cls;
+ }
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld/README b/sandbox/sebastien/java/embed/samples/helloworld/README
new file mode 100644
index 0000000000..ed0f1d0ce4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld/README
@@ -0,0 +1,7 @@
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish this \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/helloworld/pom.xml b/sandbox/sebastien/java/embed/samples/helloworld/pom.xml
new file mode 100644
index 0000000000..e510599a58
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld/pom.xml
@@ -0,0 +1,58 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <packaging>jar</packaging>
+ <artifactId>sample-helloworld</artifactId>
+ <name>Apache Tuscany SCA Sample Helloworld</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld/src/main/java/sample/Helloworld.java b/sandbox/sebastien/java/embed/samples/helloworld/src/main/java/sample/Helloworld.java
new file mode 100644
index 0000000000..f4e8c50448
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld/src/main/java/sample/Helloworld.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld/src/main/java/sample/HelloworldImpl.java b/sandbox/sebastien/java/embed/samples/helloworld/src/main/java/sample/HelloworldImpl.java
new file mode 100644
index 0000000000..5bf6a94505
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld/src/main/java/sample/HelloworldImpl.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;
+
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ System.out.println("HelloworldImpl.sayHello " + name);
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/helloworld/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/helloworld/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..91b0c8fa6f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:helloworld"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld/src/main/resources/helloworld.composite b/sandbox/sebastien/java/embed/samples/helloworld/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..324395c246
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld/src/main/resources/helloworld.composite
@@ -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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/helloworld/src/test/java/sample/HelloworldTestCase.java b/sandbox/sebastien/java/embed/samples/helloworld/src/test/java/sample/HelloworldTestCase.java
new file mode 100644
index 0000000000..7e679ec0e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/helloworld/src/test/java/sample/HelloworldTestCase.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 sample;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class HelloworldTestCase {
+
+ @Test
+ public void testSayHello() {
+ HelloworldImpl helloworld = new HelloworldImpl();
+ assertEquals("Hello Petra", helloworld.sayHello("Petra"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/README b/sandbox/sebastien/java/embed/samples/implementation-extension/README
new file mode 100644
index 0000000000..3c3ef5e3d5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/README
@@ -0,0 +1,8 @@
+Sample Implementation Extension
+===============================
+This sample demonstrates how to develop a new component implementation type
+for Apache Tuscany SCA.
+
+The README in the samples directory (the directory above this) provides
+instructions about building and running the samples. Take a look there.
+
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/build.xml b/sandbox/sebastien/java/embed/samples/implementation-extension/build.xml
new file mode 100644
index 0000000000..78bae79859
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/build.xml
@@ -0,0 +1,51 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 name="implementation-pojo-extension" default="compile">
+ <property name="test.jar" value="sample-implementation-pojo-extension.jar" />
+
+ <target name="init">
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5">
+ <classpath>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${test.jar}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${test.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="clean">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/pom.xml b/sandbox/sebastien/java/embed/samples/implementation-extension/pom.xml
new file mode 100644
index 0000000000..47aff7e941
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-implementation-extension</artifactId>
+ <name>Apache Tuscany SCA Sample Implementation Extension</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/Java.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/Java.java
new file mode 100644
index 0000000000..6c9240005f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/Java.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 sample.api;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target( {TYPE, FIELD})
+@Retention(RUNTIME)
+public @interface Java {
+
+ Class<?> value();
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/WSDL.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/WSDL.java
new file mode 100644
index 0000000000..655770ec32
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/WSDL.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 sample.api;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target( {TYPE, FIELD})
+@Retention(RUNTIME)
+public @interface WSDL {
+
+ String value();
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/WSDLReference.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/WSDLReference.java
new file mode 100644
index 0000000000..cad8478a2a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/api/WSDLReference.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.api;
+
+import org.w3c.dom.Element;
+
+public interface WSDLReference {
+
+ Element call(String op, Element e);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleImplementation.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleImplementation.java
new file mode 100644
index 0000000000..41ce71a732
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleImplementation.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 sample.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+
+/**
+ * Model representing a Sample implementation in an SCA assembly.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SampleImplementation extends ImplementationImpl {
+ static final QName QN = new QName(SCA11_TUSCANY_NS, "implementation.sample");
+
+ final String name;
+ Class<?> clazz;
+
+ SampleImplementation(final String name) {
+ super(QN);
+ this.name = name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleImplementationProcessor.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleImplementationProcessor.java
new file mode 100644
index 0000000000..95f4655131
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleImplementationProcessor.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.impl;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static sample.impl.SampleImplementation.QN;
+import static sample.impl.SampleUtil.clazz;
+import static sample.impl.SampleUtil.definition;
+import static sample.impl.SampleUtil.implementation;
+import static sample.impl.SampleUtil.interfaze;
+import static sample.impl.SampleUtil.qname;
+import static sample.impl.SampleUtil.reference;
+import static sample.impl.SampleUtil.service;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+import javax.wsdl.PortType;
+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.AssemblyFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+
+import sample.api.Java;
+import sample.api.WSDL;
+
+/**
+ * StAX artifact processor for Sample implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SampleImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SampleImplementation> {
+ final AssemblyFactory af;
+ final JavaInterfaceFactory jif;
+ final WSDLFactory wf;
+
+ public SampleImplementationProcessor(final ExtensionPointRegistry ep) {
+ final FactoryExtensionPoint fep = ep.getExtensionPoint(FactoryExtensionPoint.class);
+ this.af = fep.getFactory(AssemblyFactory.class);
+ this.jif = fep.getFactory(JavaInterfaceFactory.class);
+ this.wf = fep.getFactory(WSDLFactory.class);
+ }
+
+ public QName getArtifactType() {
+ return QN;
+ }
+
+ public Class<SampleImplementation> getModelType() {
+ return SampleImplementation.class;
+ }
+
+ public SampleImplementation read(final XMLStreamReader r, final ProcessorContext ctx) throws ContributionReadException, XMLStreamException {
+ // Read the component implementation element
+ final SampleImplementation impl = implementation(r.getAttributeValue(null, "class"));
+ while(r.hasNext() && !(r.next() == END_ELEMENT && QN.equals(r.getName())))
+ ;
+ return impl;
+ }
+
+ public void resolve(final SampleImplementation impl, final ModelResolver res, final ProcessorContext ctx) throws ContributionResolveException {
+ try {
+ // Resolve and introspect the implementation class
+ impl.clazz = resolve(impl.name, res, ctx);
+
+ for(final Annotation a: impl.clazz.getAnnotations()) {
+ if(a instanceof Java)
+ impl.getServices().add(service(clazz(a), jif, af));
+ else if(a instanceof WSDL)
+ impl.getServices().add(service(resolve(qname(a), res, ctx, wf), wf, af));
+ }
+
+ for(Field f: impl.clazz.getDeclaredFields()) {
+ for(final Annotation a: f.getAnnotations()) {
+ if(a instanceof Java)
+ impl.getReferences().add(reference(f.getName(), clazz(a), jif, af));
+ else if(a instanceof WSDL)
+ impl.getReferences().add(reference(f.getName(), resolve(qname(a), res, ctx, wf), wf, af));
+ }
+ }
+
+ impl.setUnresolved(false);
+ } catch(InvalidInterfaceException e) {
+ throw new ContributionResolveException(e);
+ }
+ }
+
+ public void write(final SampleImplementation impl, final XMLStreamWriter w, final ProcessorContext ctx) throws ContributionWriteException, XMLStreamException {
+ writeStart(w, QN.getNamespaceURI(), QN.getLocalPart(), new XAttr("class", impl.name));
+ writeEnd(w);
+ }
+
+ /**
+ * Resolve a Java class.
+ */
+ static Class<?> resolve(final String name, final ModelResolver res, final ProcessorContext ctx) throws ContributionResolveException {
+ final ClassReference cr = res.resolveModel(ClassReference.class, new ClassReference(name), ctx);
+ if(cr.getJavaClass() != null)
+ return cr.getJavaClass();
+ throw new ContributionResolveException(new ClassNotFoundException(name));
+ }
+
+ /**
+ * Resolve a WSDL interface.
+ */
+ static WSDLInterface resolve(final QName name, final ModelResolver res, final ProcessorContext ctx, final WSDLFactory wif) throws ContributionResolveException {
+ final WSDLInterface wi = res.resolveModel(WSDLInterface.class, interfaze(name, wif), ctx);
+ if(!wi.isUnresolved())
+ return wi;
+
+ final WSDLDefinition wd = res.resolveModel(WSDLDefinition.class, definition(wi.getName(), wif), ctx);
+ if(wd.isUnresolved())
+ throw new ContributionResolveException("Couldn't find " + name.getNamespaceURI());
+
+ WSDLObject<PortType> pt = wd.getWSDLObject(PortType.class, name);
+ if(pt == null)
+ throw new ContributionResolveException("Couldn't find " + name);
+ try {
+ final WSDLInterface nwi = wif.createWSDLInterface(pt.getElement(), wd, res, ctx.getMonitor());
+ nwi.setWsdlDefinition(wd);
+ nwi.resetDataBinding(DOMDataBinding.NAME);
+ res.addModel(nwi, ctx);
+ return nwi;
+ } catch(InvalidInterfaceException e) {
+ throw new ContributionResolveException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleJavaInvoker.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleJavaInvoker.java
new file mode 100644
index 0000000000..244251c4c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleJavaInvoker.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 sample.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Invoker for Sample components that implement a Java interface.
+ *
+ * @version $Rev$ $Date$
+ */
+class SampleJavaInvoker implements Invoker {
+ final Object instance;
+ final Method method;
+
+ SampleJavaInvoker(final JavaOperation op, final Class<?> clazz, final Object instance) throws SecurityException, NoSuchMethodException {
+ this.instance = instance;
+ this.method = clazz.getMethod(op.getJavaMethod().getName(), op.getJavaMethod().getParameterTypes());
+ }
+
+ public Message invoke(final Message msg) {
+ try {
+ // Call the method that implements the operation
+ msg.setBody(method.invoke(instance, (Object[])msg.getBody()));
+ } catch(Exception e) {
+ e.printStackTrace();
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleProvider.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleProvider.java
new file mode 100644
index 0000000000..5d946b037b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleProvider.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 sample.impl;
+
+import java.lang.reflect.Field;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Implementation provider for Sample component implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+class SampleProvider implements ImplementationProvider {
+ final RuntimeComponent comp;
+ final SampleImplementation impl;
+ final ProxyFactory pxf;
+ Object instance;
+
+ SampleProvider(final RuntimeComponent comp, final SampleImplementation impl, ProxyFactory pf) {
+ this.comp = comp;
+ this.impl = impl;
+ this.pxf = pf;
+ }
+
+ public void start() {
+ // Construct implementation instance and inject reference proxies
+ try {
+ instance = impl.clazz.newInstance();
+
+ for(ComponentReference r: comp.getReferences()) {
+ final Field f = impl.clazz.getDeclaredField(r.getName());
+ f.setAccessible(true);
+ // Inject a Java or WSDLReference proxy
+ final Interface i = r.getInterfaceContract().getInterface();
+ if(i instanceof JavaInterface)
+ f.set(instance, pxf.createProxy(comp.getComponentContext().getServiceReference(f.getType(), r.getName())));
+ else
+ f.set(instance, new SampleWSDLProxy(r.getEndpointReferences().get(0), i));
+ }
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stop() {
+ instance = null;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public Invoker createInvoker(final RuntimeComponentService s, final Operation op) {
+ try {
+ // Creating an invoker for a Java or WSDL-typed implementation
+ if(op instanceof JavaOperation)
+ return new SampleJavaInvoker((JavaOperation)op, impl.clazz, instance);
+ return new SampleWSDLInvoker((WSDLOperation)op, impl.clazz, instance);
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleProviderFactory.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleProviderFactory.java
new file mode 100644
index 0000000000..4ad24d33ff
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleProviderFactory.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample.impl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Factory for Sample implementation providers.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SampleProviderFactory implements ImplementationProviderFactory<SampleImplementation> {
+ final ProxyFactory pxf;
+
+ public SampleProviderFactory(final ExtensionPointRegistry ep) {
+ pxf = ExtensibleProxyFactory.getInstance(ep);
+ }
+
+ public ImplementationProvider createImplementationProvider(final RuntimeComponent comp, final SampleImplementation impl) {
+ return new SampleProvider(comp, impl, pxf);
+ }
+
+ public Class<SampleImplementation> getModelType() {
+ return SampleImplementation.class;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleUtil.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleUtil.java
new file mode 100644
index 0000000000..5425431a99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleUtil.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.impl;
+
+import java.lang.annotation.Annotation;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+
+import sample.api.Java;
+import sample.api.WSDL;
+
+/**
+ * Utility functions.
+ */
+class SampleUtil {
+
+ /**
+ * Return a Sample implementation with the given name.
+ */
+ static SampleImplementation implementation(String name) {
+ final SampleImplementation impl = new SampleImplementation(name);
+ impl.setUnresolved(true);
+ return impl;
+ }
+
+ /**
+ * Return the Java class configured on an annotation.
+ */
+ static Class<?> clazz(final Annotation a) {
+ return ((Java)a).value();
+ }
+
+ /**
+ * Return the WSDL QName configured on an annotation.
+ */
+ static QName qname(final Annotation a) {
+ final String uri = ((WSDL)a).value();
+ final int h = uri.indexOf('#');
+ return new QName(uri.substring(0, h), uri.substring(h + 1));
+ }
+
+ /**
+ * Convert a Java class to an interface contract.
+ */
+ static JavaInterfaceContract contract(final Class<?> c, final JavaInterfaceFactory jif) throws InvalidInterfaceException {
+ final JavaInterfaceContract ic = jif.createJavaInterfaceContract();
+ ic.setInterface(jif.createJavaInterface(c));
+ return ic;
+ }
+
+ /**
+ * Convert a WSDL interface to an interface contract.
+ */
+ static WSDLInterfaceContract contract(final WSDLInterface wi, final WSDLFactory wf) {
+ final WSDLInterfaceContract ic = wf.createWSDLInterfaceContract();
+ ic.setInterface(wi);
+ return ic;
+ }
+
+ /**
+ * Convert a Java class to a service.
+ */
+ static Service service(final Class<?> c, final JavaInterfaceFactory jif, final AssemblyFactory af) throws InvalidInterfaceException {
+ Service s = af.createService();
+ s.setName(c.getSimpleName());
+ s.setInterfaceContract(contract(c, jif));
+ return s;
+ }
+
+ /**
+ * Convert a WSDL interface to a service.
+ */
+ static Service service(final WSDLInterface wi, final WSDLFactory wf, final AssemblyFactory af) {
+ Service s = af.createService();
+ s.setName(wi.getName().getLocalPart());
+ s.setInterfaceContract(contract(wi, wf));
+ return s;
+ }
+
+ /**
+ * Convert a name and Java class to a reference.
+ */
+ static Reference reference(final String name, final Class<?> c, final JavaInterfaceFactory jif, final AssemblyFactory af) throws InvalidInterfaceException {
+ final Reference r = af.createReference();
+ r.setName(name);
+ r.setInterfaceContract(contract(c, jif));
+ return r;
+ }
+
+ /**
+ * Convert a name and WSDL interface to a reference.
+ */
+ static Reference reference(final String name, final WSDLInterface wi, final WSDLFactory wf, final AssemblyFactory af) {
+ final Reference r = af.createReference();
+ r.setName(name);
+ r.setInterfaceContract(contract(wi, wf));
+ return r;
+ }
+
+ /**
+ * Convert a WSDL qname to a WSDL interface.
+ */
+ static WSDLInterface interfaze(final QName name, final WSDLFactory wif) {
+ final WSDLInterface wir = wif.createWSDLInterface();
+ wir.setUnresolved(true);
+ wir.setName(name);
+ return wir;
+ }
+
+ /**
+ * Convert a WSDL qname to a WSDL definition.
+ */
+ static WSDLDefinition definition(final QName name, final WSDLFactory wif) {
+ final WSDLDefinition wdr = wif.createWSDLDefinition();
+ wdr.setUnresolved(true);
+ wdr.setNamespace(name.getNamespaceURI());
+ wdr.setNameOfPortTypeToResolve(name);
+ return wdr;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleWSDLInvoker.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleWSDLInvoker.java
new file mode 100644
index 0000000000..6c5317274f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleWSDLInvoker.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 sample.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.w3c.dom.Element;
+
+/**
+ * Invoker for Sample components that implement a WSDL interface using a generic
+ * call method.
+ *
+ * @version $Rev$ $Date$
+ */
+class SampleWSDLInvoker implements Invoker {
+ final String name;
+ final Object instance;
+ final Method method;
+
+ SampleWSDLInvoker(final WSDLOperation op, final Class<?> clazz, final Object instance) throws SecurityException, NoSuchMethodException {
+ this.name = op.getName();
+ this.instance = instance;
+ this.method = clazz.getMethod("call", String.class, Element.class);
+ }
+
+ public Message invoke(final Message msg) {
+ try {
+ // Invoke the generic call method
+ msg.setBody(method.invoke(instance, name, ((Object[])msg.getBody())[0]));
+ } catch(Exception e) {
+ e.printStackTrace();
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleWSDLProxy.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleWSDLProxy.java
new file mode 100644
index 0000000000..a6882a0103
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/java/sample/impl/SampleWSDLProxy.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 sample.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.w3c.dom.Element;
+
+import sample.api.WSDLReference;
+
+/**
+ * Proxy used to call operations on WSDL references.
+ */
+class SampleWSDLProxy implements WSDLReference {
+ final RuntimeEndpointReference repr;
+ final Map<String, Operation> ops;
+
+ SampleWSDLProxy(EndpointReference epr, Interface wi) {
+ repr = (RuntimeEndpointReference)epr;
+ ops = new HashMap<String, Operation>();
+ for(Operation o: wi.getOperations())
+ ops.put(o.getName(), o);
+ }
+
+ @Override
+ public Element call(String op, Element e) {
+ try {
+ // Invoke the named operation on the endpoint reference
+ return (Element)repr.invoke(ops.get(op), new Object[] {e});
+ } catch(InvocationTargetException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..908ac95a2e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 artifact processor extension
+sample.impl.SampleImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.sample,model=sample.impl.SampleImplementation
+
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..85aff44074
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -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.
+#
+sample/impl/sample.xsd
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..32a7efcaf9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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 provider for Sample components
+sample.impl.SampleProviderFactory;model=sample.impl.SampleImplementation
+
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/sample/impl/sample.xsd b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/sample/impl/sample.xsd
new file mode 100644
index 0000000000..c057aef1c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/main/resources/sample/impl/sample.xsd
@@ -0,0 +1,38 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"/>
+
+ <element name="implementation.sample" type="t:SampleImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="SampleImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <attribute name="class" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Client.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Client.java
new file mode 100644
index 0000000000..4c473c987f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Client.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 sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Client {
+
+ String jello(String s);
+
+ String wello(String s);
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/ClientTest.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/ClientTest.java
new file mode 100644
index 0000000000..6b5c3983d1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/ClientTest.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 sample;
+
+import static java.lang.System.out;
+import static sample.Xutil.elem;
+import static sample.Xutil.elems;
+import static sample.Xutil.print;
+import static sample.Xutil.select;
+import static sample.Xutil.text;
+import static sample.Xutil.xdom;
+import static sample.Xutil.xfilter;
+import static sample.Xutil.xreduce;
+
+import org.w3c.dom.Element;
+
+import sample.api.Java;
+import sample.api.WSDL;
+import sample.api.WSDLReference;
+
+/**
+ * Sample component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+@Java(Client.class)
+public class ClientTest {
+
+ @Java(Hello.class)
+ Hello jello;
+
+ @WSDL("http://sample#Hello")
+ WSDLReference wello;
+
+ public String jello(String s) {
+ out.println("ClientTest.jello(" + s + ")");
+ return jello.hello(s);
+ }
+
+ public String wello(String s) {
+ out.println("ClientTest.wello(" + s + ")");
+ final Element hreq = xdom("http://sample", "hello", elem("name", text(s)));
+
+ final Element hres = wello.call("hello", hreq);
+
+ return xreduce(print, "", xfilter(select("result"), elems(hres)));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Hello.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Hello.java
new file mode 100644
index 0000000000..f6e02591e5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Hello.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Hello {
+
+ String hello(String s);
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/JelloTest.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/JelloTest.java
new file mode 100644
index 0000000000..53ed006132
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/JelloTest.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 static java.lang.System.out;
+import sample.api.Java;
+
+/**
+ * Sample component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+@Java(Hello.class)
+public class JelloTest {
+
+ @Java(Upper.class)
+ Upper upper;
+
+ public String hello(String s) {
+ out.println("JelloTest.hello(" + s + ")");
+ return upper.upper("Hello " + s);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Upper.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Upper.java
new file mode 100644
index 0000000000..04e929ade7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Upper.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Upper {
+
+ String upper(String s);
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/UpperTest.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/UpperTest.java
new file mode 100644
index 0000000000..fe90097efa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/UpperTest.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 sample;
+
+import static java.lang.System.out;
+import sample.api.Java;
+
+/**
+ * Sample component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+@Java(Upper.class)
+public class UpperTest {
+
+ public String upper(String s) {
+ out.println("UpperTest.upper(" + s + ")");
+ return s.toUpperCase();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/WelloTest.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/WelloTest.java
new file mode 100644
index 0000000000..9da5083dda
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/WelloTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 static java.lang.System.out;
+import static sample.Xutil.elem;
+import static sample.Xutil.elems;
+import static sample.Xutil.print;
+import static sample.Xutil.select;
+import static sample.Xutil.text;
+import static sample.Xutil.xdom;
+import static sample.Xutil.xfilter;
+import static sample.Xutil.xml;
+import static sample.Xutil.xreduce;
+
+import org.w3c.dom.Element;
+
+import sample.api.WSDL;
+import sample.api.WSDLReference;
+
+/**
+ * Sample component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+@WSDL("http://sample#Hello")
+public class WelloTest {
+
+ @WSDL("http://sample#Upper")
+ WSDLReference upper;
+
+ public Element call(String op, Element e) {
+ out.println("WelloTest." + op + "(" + xml(e) + ")");
+ final String name = xreduce(print, "", xfilter(select("name"), elems(e)));
+
+ final Element ureq = xdom("http://sample", "upper", elem("s", text("Hello " + name)));
+ final Element ures = upper.call("upper", ureq);
+
+ final String s = xreduce(print, "", xfilter(select("result"), elems(ures)));
+ return xdom("http://sample", "helloResponse", elem("result", text(s)));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Xutil.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Xutil.java
new file mode 100644
index 0000000000..bdad745b6f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/Xutil.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Just for fun, a little bit of magic code and utility functions to help work with XML DOM.
+ */
+class Xutil {
+ static class NodeBuilder {
+ String ns;
+ String name;
+ NodeBuilder[] children;
+ String text;
+ }
+
+ /**
+ * Convert a name and a list of children to a document element.
+ */
+ static Element xdom(String ns, String name, final NodeBuilder... nodes) {
+ return (Element)node(elem(ns, name, nodes), db.newDocument());
+ }
+
+ /**
+ * Convert a name and children to an element.
+ */
+ static NodeBuilder elem(final String uri, final String n, final NodeBuilder... nodes) {
+ return new NodeBuilder() {
+ {
+ this.ns = uri;
+ this.name = n;
+ this.children = nodes;
+ }
+ };
+ }
+
+ static NodeBuilder elem(final String n, final NodeBuilder... nodes) {
+ return new NodeBuilder() {
+ {
+ this.name = n;
+ this.children = nodes;
+ }
+ };
+ }
+
+ /**
+ * Convert a string to a text element.
+ */
+ static NodeBuilder text(final String t) {
+ return new NodeBuilder() {
+ {
+ this.text = t;
+ }
+ };
+ }
+
+ private final static DocumentBuilder db = db();
+
+ private static DocumentBuilder db() {
+ try {
+ return DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ } catch(ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Element link(final Element e, final Document doc, final NodeBuilder... nodes) {
+ for(final NodeBuilder c: nodes)
+ e.appendChild(node(c, doc));
+ return e;
+ }
+
+ private static Node node(NodeBuilder node, Document doc) {
+ if(node.text != null)
+ return doc.createTextNode(node.text);
+ return link(doc.createElementNS(node.ns, node.name), doc, node.children);
+ }
+
+ /**
+ * Convert an element to XML.
+ */
+ static TransformerFactory trf = TransformerFactory.newInstance();
+
+ static String xml(final Node node) {
+ try {
+ final StreamResult r = new StreamResult(new StringWriter());
+ trf.newTransformer().transform(new DOMSource(node), r);
+ return r.getWriter().toString();
+ } catch(TransformerException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Evaluate an xpath expression.
+ */
+ private static XPathFactory xpf = XPathFactory.newInstance();
+
+ static String xpath(final String expr, final Node node) {
+ final XPath xp = xpf.newXPath();
+ try {
+ return (String)xp.evaluate(expr, node, XPathConstants.STRING);
+ } catch(XPathExpressionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * A pure Java FP-style alternative to xpath.
+ */
+ interface Mapper<T> {
+ T map(final Element e);
+ }
+
+ static Mapper<Element> identity = new Mapper<Element>() {
+ public Element map(Element e) {
+ return e;
+ };
+ };
+
+ interface Reducer<T> {
+ T reduce(final T accum, final Element e);
+ }
+
+ static Reducer<String> print = new Reducer<String>() {
+ public String reduce(String accum, Element e) {
+ return accum + e.getTextContent();
+ }
+ };
+
+ /**
+ * Apply a mapper to a list of elements.
+ */
+ static <T> List<T> xmap(final Mapper<T> f, final Iterable<Element> l) {
+ final List<T> v = new ArrayList<T>();
+ for(Element e: l)
+ v.add(f.map(e));
+ return v;
+ }
+
+ /**
+ * Apply a filter to a list of elements.
+ */
+ static List<Element> xfilter(final Mapper<Boolean> f, final Iterable<Element> l) {
+ final List<Element> v = new ArrayList<Element>();
+ for(Element e: l)
+ if(f.map(e))
+ v.add(e);
+ return v;
+ }
+
+ /**
+ * Perform a reduction over a list of elements.
+ */
+ static <T> T xreduce(final Reducer<T> f, final T initial, final Iterable<Element> l) {
+ T accum = initial;
+ for(Element e: l)
+ accum = f.reduce(accum, e);
+ return accum;
+ }
+
+ /**
+ * Return a filter that selects elements by name.
+ */
+ static Mapper<Boolean> select(final String name) {
+ return new Mapper<Boolean>() {
+ public Boolean map(Element e) {
+ return name.equals(e.getLocalName());
+ }
+ };
+ }
+
+ /**
+ * Return the child elements of a node.
+ */
+ static Iterable<Element> elems(final Node parent) {
+ final List<Element> l = new ArrayList<Element>();
+ for (Node n: children(parent))
+ if (n instanceof Element)
+ l.add((Element)n);
+ return l;
+ }
+
+ /**
+ * An iterable over the children of a node.
+ */
+ private static Iterable<Node> children(Node parent) {
+ final NodeList l = parent.getChildNodes();
+ final int n = l.getLength();
+ return new Iterable<Node>() {
+ public Iterator<Node> iterator() {
+ return new Iterator<Node>() {
+ int i = 0;
+ public boolean hasNext() {
+ return i < n;
+ }
+ public Node next() {
+ return l.item(i++);
+ }
+ public void remove() {
+ }
+ };
+ }
+ };
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/ReadWriteTestCase.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/ReadWriteTestCase.java
new file mode 100644
index 0000000000..8d01c82edf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/ReadWriteTestCase.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 sample.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DefaultContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading/writing Sample implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteTestCase {
+ static XMLInputFactory xif;
+ static XMLOutputFactory xof;
+ static StAXArtifactProcessor<Object> xproc;
+ static ProcessorContext ctx;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final DefaultExtensionPointRegistry ep = new DefaultExtensionPointRegistry();
+ final Contribution contrib = new DefaultContributionFactory().createContribution();
+ contrib.setLocation(ReadWriteTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString());
+ ctx = new ProcessorContext(contrib, null);
+ xif = XMLInputFactory.newInstance();
+ xof = XMLOutputFactory.newInstance();
+ final StAXArtifactProcessorExtensionPoint xpep = new DefaultStAXArtifactProcessorExtensionPoint(ep);
+ xproc = new ExtensibleStAXArtifactProcessor(xpep, xif, xof);
+ }
+
+ @Test
+ public void testRead() throws Exception {
+ final InputStream is = getClass().getClassLoader().getResourceAsStream("test.composite");
+ final Composite c = (Composite)xproc.read(xif.createXMLStreamReader(is), ctx);
+ assertNotNull(c);
+ assertEquals("sample.ClientTest", ((SampleImplementation)c.getComponents().get(0).getImplementation()).name);
+ }
+
+ @Test
+ public void testReadWrite() throws Exception {
+ final InputStream is = getClass().getClassLoader().getResourceAsStream("test.composite");
+ final Composite c = (Composite)xproc.read(xif.createXMLStreamReader(is), ctx);
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ xproc.write(c, xof.createXMLStreamWriter(bos), ctx);
+ assertTrue(bos.toString().contains("class=\"sample.WelloTest\""));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/RunTestCase.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/RunTestCase.java
new file mode 100644
index 0000000000..26cbd5d3e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/RunTestCase.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 sample.impl;
+
+import static java.lang.System.out;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import sample.Client;
+
+/**
+ * Test run.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RunTestCase {
+ static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final NodeFactory nf = NodeFactory.newInstance();
+ final String here = RunTestCase.class.getProtectionDomain().getCodeSource().getLocation().toString();
+ node = nf.createNode(new Contribution("test", here));
+ node.start();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ Client client() {
+ return node.getService(Client.class, "client-test/Client");
+ }
+
+ @Test
+ public void jello() {
+ out.println("RunTestCase.jello");
+ out.println(client().jello("Java"));
+ }
+
+ @Test
+ public void wello() {
+ out.println("RunTestCase.wello");
+ out.println(client().wello("WSDL"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/Hello.wsdl b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/Hello.wsdl
new file mode 100644
index 0000000000..561e560e7a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/Hello.wsdl
@@ -0,0 +1,62 @@
+<?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://sample" xmlns:tns="http://sample"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="Hello">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://sample"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="helloResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="helloRequest">
+ <wsdl:part element="tns:hello" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="helloResponse">
+ <wsdl:part element="tns:helloResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Hello">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:helloRequest" name="helloRequest" />
+ <wsdl:output message="tns:helloResponse" name="helloResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/Upper.wsdl b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/Upper.wsdl
new file mode 100644
index 0000000000..60eaec9f27
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/Upper.wsdl
@@ -0,0 +1,62 @@
+<?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://sample" xmlns:tns="http://sample"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="Upper">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://sample"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="upper">
+ <complexType>
+ <sequence>
+ <element name="s" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="upperResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="upperRequest">
+ <wsdl:part element="tns:upper" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="upperResponse">
+ <wsdl:part element="tns:upperResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Upper">
+ <wsdl:operation name="upper">
+ <wsdl:input message="tns:upperRequest" name="upperRequest" />
+ <wsdl:output message="tns:upperResponse" name="upperResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/test.composite b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/test.composite
new file mode 100644
index 0000000000..535488b74e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/resources/test.composite
@@ -0,0 +1,45 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://test"
+ name="test">
+
+ <component name="client-test">
+ <t:implementation.sample class="sample.ClientTest"/>
+ <reference name="wello" target="wello-test"/>
+ <reference name="jello" target="jello-test"/>
+ </component>
+
+ <component name="wello-test">
+ <t:implementation.sample class="sample.WelloTest"/>
+ <reference name="upper" target="upper-test"/>
+ </component>
+
+ <component name="jello-test">
+ <t:implementation.sample class="sample.JelloTest"/>
+ <reference name="upper" target="upper-test"/>
+ </component>
+
+ <component name="upper-test">
+ <t:implementation.sample class="sample.UpperTest"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/README b/sandbox/sebastien/java/embed/samples/implementation-java/README
new file mode 100644
index 0000000000..18ba62d494
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/README
@@ -0,0 +1 @@
+Please look at the README files in the subdirectories of this directory for descriptions of the sample contributions.
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/README b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/README
new file mode 100644
index 0000000000..9e1ff828ee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/README
@@ -0,0 +1,25 @@
+Calculator Sample Contribution
+==============================
+
+This sample implements a simple calculator using SCA components.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive) Take a look there for instructions on how to launch
+this sample contribution.
+
+Sample Overview
+---------------
+The sample provides a single calculator service with a default SCA (java)
+binding. The CalculatorClient exercises this interface by calling add,
+subtract, multiply and divide operations. This results in messages passing to
+the appropriate components in the composite across the local wires.
+
+You should see the following output from the run target.
+
+run:
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/build.xml b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/build.xml
new file mode 100644
index 0000000000..8ec250d009
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/build.xml
@@ -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.
+-->
+
+<project name="implementation-java-calculator" default="compile">
+
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="contribution-implementation-java-calculator.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/pom.xml b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/pom.xml
new file mode 100644
index 0000000000..c3e4ba4208
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/pom.xml
@@ -0,0 +1,58 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-implementation-java-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution Implementation Java Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..5a1e7a638a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/AddService.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 calculator;
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/AddServiceImpl.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..caf4d358df
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/AddServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..2b791a8e1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorClient.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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE") @EagerInit
+public class CalculatorClient {
+
+ private CalculatorService calculatorService;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ @Init
+ public void calculate() {
+
+ // Calculate
+ System.out.println("SCA API ClassLoader: " + print(Reference.class.getClassLoader()));
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+ }
+
+ private static String print(ClassLoader cl) {
+ StringBuffer buf = new StringBuffer();
+ for (; cl != null;) {
+ buf.append(cl.toString());
+ buf.append(' ');
+ cl = cl.getParent();
+ }
+ return buf.toString();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..78eea39c71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..d3fa7a8f41
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..ef6a8b375b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..cd91935f08
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/DivideServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..db568cc762
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..c85357fcd8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..56ee372fc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..1b669084d9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/Calculator.composite b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..370e1cf315
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/Calculator.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/CalculatorClient.composite b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/CalculatorClient.composite
new file mode 100644
index 0000000000..dfd32761be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/CalculatorClient.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="CalculatorClient">
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..70aab0e051
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+ <deployable composite="sample:CalculatorClient"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..c1cd131f40
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-java/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator composition.
+ */
+public class CalculatorTestCase {
+
+ @Test
+ public void testCalculator() throws Exception {
+ AddService add = new AddServiceImpl();
+ SubtractService subtract = new SubtractServiceImpl();
+ MultiplyService multiply = new MultiplyServiceImpl();
+ DivideService divide = new DivideServiceImpl();
+
+ CalculatorServiceImpl calculator = new CalculatorServiceImpl();
+
+ calculator.setAddService(add);
+ calculator.setSubtractService(subtract);
+ calculator.setMultiplyService(multiply);
+ calculator.setDivideService(divide);
+
+ assertEquals(calculator.add(3, 2), 5.0, 0);
+ assertEquals(calculator.subtract(3, 2), 1.0, 0);
+ assertEquals(calculator.multiply(3, 2), 6.0, 0);
+ assertEquals(calculator.divide(3, 2), 1.5, 0);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-java/pom.xml b/sandbox/sebastien/java/embed/samples/implementation-java/pom.xml
new file mode 100644
index 0000000000..96fece7481
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-implementation-java</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample implementation.java</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/README b/sandbox/sebastien/java/embed/samples/implementation-script/README
new file mode 100644
index 0000000000..18ba62d494
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/README
@@ -0,0 +1 @@
+Please look at the README files in the subdirectories of this directory for descriptions of the sample contributions.
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/README b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/README
new file mode 100644
index 0000000000..1e5bc9c584
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/README
@@ -0,0 +1,26 @@
+Calculator Sample Contribution
+==============================
+
+This sample contribution implements a simple calculator using SCA components.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive) Take a look there for instructions on how to launch
+this sample contribution.
+
+Sample Overview
+---------------
+The sample provides a single calculator service with a default SCA (java)
+binding. The CalculatorClient exercises this interface by calling add,
+subtract, multiply and divide operations. This results in messages passing to
+the appropriate components in the composite across the local wires.
+
+Amongst the other output created by the launcher/contribution combination, you should see the following output ...
+
+run:
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
+
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/build.xml b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/build.xml
new file mode 100644
index 0000000000..91285fdbca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/build.xml
@@ -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.
+-->
+
+<project name="calculator" default="compile">
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="sample-contribution-implementation-script-calculator.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+</project>
+
+
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/pom.xml b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/pom.xml
new file mode 100644
index 0000000000..61c864a4f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/pom.xml
@@ -0,0 +1,58 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-implementation-script-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution implementation-script Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/AddService.java b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..5a1e7a638a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/AddService.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 calculator;
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorClient.java b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..1df1f31c48
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorClient.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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class CalculatorClient {
+
+ private CalculatorService calculatorService;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ @Init
+ public void calculate() {
+ // Calculate
+ System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader());
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..78eea39c71
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..8e4b082d14
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Service(CalculatorService.class)
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/DivideService.java b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..ef6a8b375b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/DivideService.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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/MultiplyService.java b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..db568cc762
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/MultiplyService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/SubtractService.java b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..56ee372fc4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/java/calculator/SubtractService.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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/Calculator.composite b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..d441aa0aea
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/Calculator.composite
@@ -0,0 +1,50 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <tuscany:implementation.script script="calculator/AddServiceImpl.js"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <tuscany:implementation.script script="calculator/SubtractServiceImpl.rb"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <tuscany:implementation.script script="calculator/MultiplyServiceImpl.py"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <tuscany:implementation.script script="calculator/DivideServiceImpl.groovy"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/CalculatorClient.composite b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/CalculatorClient.composite
new file mode 100644
index 0000000000..dfd32761be
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/CalculatorClient.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="CalculatorClient">
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..70aab0e051
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+ <deployable composite="sample:CalculatorClient"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.componentType b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.componentType
new file mode 100644
index 0000000000..5f6d88454c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.componentType
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="AddService">
+ <interface.java interface="calculator.AddService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.js b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.js
new file mode 100644
index 0000000000..6f11106ddd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.js
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function add(n1, n2) {
+ return n1 + n2;
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.componentType b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.componentType
new file mode 100644
index 0000000000..f4bb4e3471
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.componentType
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="DivideService">
+ <interface.java interface="calculator.DivideService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.groovy b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.groovy
new file mode 100644
index 0000000000..c31c1e8fd6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.groovy
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def divide(n1, n2) {
+ return n1 / n2
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.componentType b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.componentType
new file mode 100644
index 0000000000..35dc5721b2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.componentType
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="MultiplyService">
+ <interface.java interface="calculator.MultiplyService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.py b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.py
new file mode 100644
index 0000000000..cce0b5b3ec
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.py
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+def multiply(n1, n2):
+ return n1 * n2 \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.componentType b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.componentType
new file mode 100644
index 0000000000..ee768f73f2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.componentType
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="SubtractService">
+ <interface.java interface="calculator.SubtractService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.rb b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.rb
new file mode 100644
index 0000000000..132a1d13b0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.rb
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+def subtract(n1, n2)
+ return n1 - n2
+end \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/implementation-script/pom.xml b/sandbox/sebastien/java/embed/samples/implementation-script/pom.xml
new file mode 100644
index 0000000000..cf719a7918
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/implementation-script/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-implementation-script</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample implementation.script</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-command-line/README b/sandbox/sebastien/java/embed/samples/launcher-command-line/README
new file mode 100644
index 0000000000..bf963ea98e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-command-line/README
@@ -0,0 +1,13 @@
+To execute a sample contribution from the command line
+
+on Windows, from a command prompt in the samples directory, run the command ...
+
+..\bin\tuscany.bat "contribution-name"
+
+for example
+
+..\bin\tuscany.bat contribution-binding-sca-calculator
+
+or on *nix platforms, from a shell prompt in the samples directory, run the command ...
+
+../bin/tuscany.sh contribution-binding-sca-calculator
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/README b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/README
new file mode 100644
index 0000000000..7108333efa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/README
@@ -0,0 +1,20 @@
+JSE Sample Launcher
+===================
+
+This directory contains a sample java launcher for the
+tuscany sample contributions.
+
+The README file in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running sample contributions using the
+tuscany sample launchers ( where distribution-unpack-dir is the directory in which you
+unpacked the tuscany binary distribution archive)
+
+To use this sample JSE launcher with ant excute the command
+
+ant run-<contributionname>
+
+where run-<contributionname> is one of the targets in the build.xml file
+
+To use this sample launcher to run all of the contributions as junit test cases,
+execute the command "mvn" in the launcher directory.
+
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/build.xml b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/build.xml
new file mode 100644
index 0000000000..05c7ab3c49
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/build.xml
@@ -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.
+-->
+<project name="launcher-embedded-jse" default="run">
+ <property name="tuscany.home" value="../.."/>
+ <property name="jar.name" value="sample-launcher-embedded-jse.jar" />
+ <property name="wait.before.stopping" value="dontWaitBeforeStopping" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-base-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <echo>Please use 'ant run-name-of-sample-contribution-to-run' for example, try one of</echo>
+ <echo> 'ant run-contribution-binding-sca-calculator' </echo>
+ <echo> 'ant run-contribution-binding-ws-calculator' </echo>
+ <echo> 'ant run-contribution-binding-rmi-calculator' </echo>
+ <echo> 'ant run-contribution-implementation-java-calculator' </echo>
+ </target>
+
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
+ <java classname="launcher.JSELauncherBindingSCACalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="launcher.JSELauncherBindingWSCalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-contribution-binding-rmi-calculator" depends="compile">
+ <java classname="launcher.JSELauncherBindingRMICalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-contribution-implementation-java-calculator" depends="compile">
+ <java classname="launcher.JSELauncherImplementationJavaCalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/pom.xml b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/pom.xml
new file mode 100644
index 0000000000..a30d55d2e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-embedded-jse</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Embedded JSE</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java
new file mode 100644
index 0000000000..3d6af9f561
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingJSONRPCCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingJSONRPCCalculator launcher = new JSELauncherBindingJSONRPCCalculator();
+ launcher.launchBindingSCACalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchBindingSCACalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-jsonrpc/contribution-calculator/target/sample-contribution-binding-jsonrpc-calculator.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java
new file mode 100644
index 0000000000..18fb2f4fb7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingRMICalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingRMICalculator launcher = new JSELauncherBindingRMICalculator();
+ launcher.launchBindingRMICalculator();
+ }
+
+
+ public void launchBindingRMICalculator(){
+
+ Node node1 = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-rmi/contribution-calculator-service/target/classes"));
+ Node node2 = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-rmi/contribution-calculator-reference/target/classes"));
+
+ node1.start();
+ node2.start();
+
+ CalculatorService calculator = node2.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+
+ node1.stop();
+ node2.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java
new file mode 100644
index 0000000000..4355bcfbd8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingSCACalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingSCACalculator launcher = new JSELauncherBindingSCACalculator();
+ launcher.launchBindingSCACalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchBindingSCACalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-sca/contribution-calculator/target/sample-contribution-binding-sca-calculator.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java
new file mode 100644
index 0000000000..f23257769e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingWSCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingWSCalculator launcher = new JSELauncherBindingWSCalculator();
+ launcher.launchBindingWSCalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchBindingWSCalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-ws/contribution-calculator/target/sample-contribution-binding-ws-calculator.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java
new file mode 100644
index 0000000000..4aebda1bcf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherImplementationJavaCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherImplementationJavaCalculator launcher = new JSELauncherImplementationJavaCalculator();
+ launcher.launchImplementationJavaCalculator();
+ }
+
+ public void launchImplementationJavaCalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../implementation-java/contribution-calculator/target/classes"));
+ node.start();
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java
new file mode 100644
index 0000000000..ca652718d7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherImplementationScriptCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherImplementationScriptCalculator launcher = new JSELauncherImplementationScriptCalculator();
+ launcher.launchImplementationScriptCalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchImplementationScriptCalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../implementation-script/contribution-calculator/target/sample-contribution-implementation-script-calculator.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..fdff16c12c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+
+/**
+ * Base JSE launcher function
+ */
+public class RuntimeIntegration {
+
+
+ public Node startNode(Contribution... contributions){
+ Node node = NodeFactory.newInstance().createNode(contributions);
+ node.start();
+ return node;
+ }
+
+ public void stopNode(Node node){
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..f2ed3d421d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..6bbbe32a7f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package launcher;
+
+import org.junit.Test;
+
+/**
+ * Test sample contributions.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionBindingSCACalculator() throws Exception {
+ JSELauncherBindingSCACalculator.main(null);
+ }
+
+
+ @Test
+ public void testContributionBindingWSCalculator() throws Exception {
+ JSELauncherBindingWSCalculator.main(null);
+ }
+
+ @Test
+ public void testContributionBindingRMICalculator() throws Exception {
+ JSELauncherBindingRMICalculator.main(null);
+ }
+
+ @Test
+ public void testContributionImplementationJavaCalculator() throws Exception {
+ JSELauncherImplementationJavaCalculator.main(null);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/README b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/README
new file mode 100644
index 0000000000..362d6032d2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/README
@@ -0,0 +1,24 @@
+OSGI Sample Launcher
+===================
+
+This directory contains a sample launcher for the running the
+tuscany sample contributions in an OSGI environment.
+
+The difference between this sample and the sample with the name without the
+-base suffix is that this one uses the Tuscany aggregated jar to minimize the
+jars a user needs to use.
+
+The README file in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running sample contributions using the
+tuscany sample launchers. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive)
+
+To use this sample OSGI launcher with ant excute the command
+
+ant run-<contributionname>
+
+where run-<contributionname> is one of the targets in the build.xml file
+
+To use this sample launcher to run all of the contributions as junit test cases,
+execute the command "mvn" in the launcher directory.
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/build.xml b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/build.xml
new file mode 100644
index 0000000000..139ff054f7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/build.xml
@@ -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.
+-->
+<project name="launcher-embedded-osgi" default="run">
+ <property name="tuscany.home" value="../.."/>
+ <property name="jar.name" value="sample-launcher-embedded-osgi.jar" />
+ <property name="main.class" value="launcher.SampleJSELauncher" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-base-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <echo>Please use 'ant run-name-of-sample-contribution-to-run' for example, try one of</echo>
+ <echo> 'ant run-contribution-binding-sca-calculator' </echo>
+ </target>
+
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/modules">
+ <include name="tuscany-node-api-*.jar" />
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-launcher-equinox-*.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-sca-calculator"/>
+ </java>
+ <echo> and ant run </echo>
+ </target>
+
+ <!-- TODO - this runs from mvn but not from ant so there is some issue with the
+ way the environment gets set up
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/modules">
+ <include name="tuscany-node-api-*.jar" />
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-launcher-equinox-*.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-ws-calculator"/>
+ </java>
+ </target>
+ -->
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/pom.xml b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/pom.xml
new file mode 100644
index 0000000000..aa0876b338
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/pom.xml
@@ -0,0 +1,71 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-embedded-osgi-base</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Embedded OSGi using base jar</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base-nodep</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..a59a7c3b16
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..2c1cdf187a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.LauncherException;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+
+/**
+ * OSGi launcher function
+ */
+public class RuntimeIntegration {
+
+ public Node startNode(Contribution... contributions){
+ NodeLauncher launcher = NodeLauncher.newInstance();
+
+ // TODO - why do we have 3 different versions of the Contribution class?
+ org.apache.tuscany.sca.node.equinox.launcher.Contribution equinoxContributions[] =
+ new org.apache.tuscany.sca.node.equinox.launcher.Contribution[contributions.length];
+ int i = 0;
+ for (Contribution inContrib : contributions) {
+ org.apache.tuscany.sca.node.equinox.launcher.Contribution outContrib =
+ new org.apache.tuscany.sca.node.equinox.launcher.Contribution(inContrib.getURI(), inContrib.getLocation());
+ equinoxContributions[i] = outContrib;
+ i++;
+ }
+ Node node = null;
+
+ try {
+ node = launcher.createNode(null, equinoxContributions);
+ } catch (LauncherException ex) {
+ throw new SampleLauncherException(ex.getMessage());
+ }
+ node.start();
+ return node;
+ }
+
+ public void stopNode(Node node){
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java
new file mode 100644
index 0000000000..b3a0b1ce7e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.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 launcher;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+import calculator.CalculatorService;
+
+
+/**
+ * This client program shows how to create an embedded SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class SampleJSELauncher extends RuntimeIntegration {
+
+ public static void main(String[] args) throws Exception {
+ SampleJSELauncher launcher = new SampleJSELauncher();
+
+ String contribution = null;
+
+ if (args == null || args.length != 1){
+ System.out.println("Please provide the name of the sample contribution to run as a parameter");
+ System.out.println("Running binding-sca-calculator by default");
+ contribution = "contribution-binding-sca-calculator";
+ } else {
+ contribution = args[0];
+ }
+
+ if (contribution.equals("contribution-binding-sca-calculator")){
+ launcher.launchBindingSCACalculator();
+ } else if (contribution.equals("contribution-binding-ws-calculator")){
+ launcher.launchBindingWSCalculator();
+ } else {
+ System.out.println("Sample contribution " + contribution + "not found");
+ }
+
+ }
+
+ /**
+ * The contribution-binding-sca-calculator contribution includes a client component
+ * that calls the CalculatorServiceComponent from an operation marked by @Init.
+ */
+ public void launchBindingSCACalculator(){
+ Node node = startNode(new Contribution("c1", "../binding-sca/contribution-calculator/target/sample-contribution-binding-sca-calculator.jar"));
+
+ stopNode(node);
+ }
+
+ /*
+ * Using a Tuscany specific mechanism for getting at local service proxies
+ */
+ public void launchBindingWSCalculator() throws NoSuchDomainException, NoSuchServiceException{
+ Node node = startNode(new Contribution("c1", "../binding-ws/contribution-calculator/target/sample-contribution-binding-ws-calculator.jar"));
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ stopNode(node);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..1eacb94b19
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..9228d33018
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.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 launcher;
+
+import org.junit.Test;
+
+
+
+/**
+ * Test the Calculator composition.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionBindingSCACalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-sca-calculator"});
+ }
+
+ @Test
+ public void testContributionBindingWSCalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-ws-calculator"});
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/README b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/README
new file mode 100644
index 0000000000..01d277ae09
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/README
@@ -0,0 +1,20 @@
+OSGI Sample Launcher
+===================
+
+This directory contains a sample launcher for the running the
+tuscany sample contributions in an OSGI environment.
+
+The README file in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running sample contributions using the
+tuscany sample launchers. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive)
+
+To use this sample OSGI launcher with ant excute the command
+
+ant run-<contributionname>
+
+where run-<contributionname> is one of the targets in the build.xml file
+
+To use this sample launcher to run all of the contributions as junit test cases,
+execute the command "mvn" in the launcher directory.
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/build.xml b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/build.xml
new file mode 100644
index 0000000000..f08d19e472
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/build.xml
@@ -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.
+-->
+<project name="launcher-embedded-osgi" default="run">
+ <property name="tuscany.home" value="../.."/>
+ <property name="jar.name" value="sample-launcher-embedded-osgi.jar" />
+ <property name="main.class" value="launcher.SampleJSELauncher" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-base-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <echo>Please use 'ant run-name-of-sample-contribution-to-run' for example, try one of</echo>
+ <echo> 'ant run-contribution-binding-sca-calculator' </echo>
+ </target>
+
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/modules">
+ <include name="tuscany-node-api-*.jar" />
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-launcher-equinox-*.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-sca-calculator"/>
+ </java>
+ <echo> and ant run </echo>
+ </target>
+
+ <!-- TODO - this runs from mvn but not from ant so there is some issue with the
+ way the environment gets set up
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/modules">
+ <include name="tuscany-node-api-*.jar" />
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-launcher-equinox-*.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-ws-calculator"/>
+ </java>
+ </target>
+ -->
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/pom.xml b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/pom.xml
new file mode 100644
index 0000000000..c3cf7e6577
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-embedded-osgi</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Embedded OSGi</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..f4a2f0780c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.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 launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.LauncherException;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+
+/**
+ * OSGi launcher function
+ */
+public class RuntimeIntegration {
+
+ public Node startNode(Contribution... contributions){
+ NodeLauncher launcher = NodeLauncher.newInstance();
+
+ // TODO - why do we have 3 different versions of the Contribution class?
+ org.apache.tuscany.sca.node.equinox.launcher.Contribution equinoxContributions[] =
+ new org.apache.tuscany.sca.node.equinox.launcher.Contribution[contributions.length];
+ int i = 0;
+ for (Contribution inContrib : contributions) {
+ org.apache.tuscany.sca.node.equinox.launcher.Contribution outContrib =
+ new org.apache.tuscany.sca.node.equinox.launcher.Contribution(inContrib.getURI(), inContrib.getLocation());
+ equinoxContributions[i] = outContrib;
+ i++;
+ }
+ Node node = null;
+
+ try {
+ node = launcher.createNode(null, equinoxContributions);
+ } catch (LauncherException ex) {
+ throw new SampleLauncherException(ex.getMessage());
+ }
+ node.start();
+ return node;
+ }
+
+ public void stopNode(Node node){
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java
new file mode 100644
index 0000000000..bfc4681836
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.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 launcher;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+import calculator.CalculatorService;
+
+
+/**
+ * This client program shows how to create an embedded SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class SampleJSELauncher extends RuntimeIntegration {
+
+ public static void main(String[] args) throws Exception {
+ SampleJSELauncher launcher = new SampleJSELauncher();
+
+ String contribution = null;
+
+ if (args == null || args.length != 1){
+ System.out.println("Please provide the name of the sample contribution to run as a parameter");
+ System.out.println("Running binding-sca-calculator by default");
+ contribution = "contribution-binding-sca-calculator";
+ } else {
+ contribution = args[0];
+ }
+
+ if (contribution.equals("contribution-binding-sca-calculator")){
+ launcher.launchBindingSCACalculator();
+ } else if (contribution.equals("contribution-binding-ws-calculator")){
+ launcher.launchBindingWSCalculator();
+ } else {
+ System.out.println("Sample contribution " + contribution + "not found");
+ }
+
+ }
+
+ /**
+ * The contribution-binding-sca-calculator contribution includes a client component
+ * that calls the CalculatorServiceComponent from an operation marked by @Init.
+ */
+ public void launchBindingSCACalculator(){
+ Node node = startNode(new Contribution("c1", "../binding-sca/contribution-calculator/target/sample-contribution-binding-sca-calculator.jar"));
+
+ stopNode(node);
+ }
+
+ /*
+ * Using a Tuscany specific mechanism for getting at local service proxies
+ */
+ public void launchBindingWSCalculator() throws NoSuchDomainException, NoSuchServiceException{
+ Node node = startNode(new Contribution("c1", "../binding-ws/contribution-calculator/target/sample-contribution-binding-ws-calculator.jar"));
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ stopNode(node);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..f2ed3d421d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..7b72ec7aee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.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 launcher;
+
+import org.junit.Test;
+
+
+
+/**
+ * Test the Calculator composition.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionBindingSCACalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-sca-calculator"});
+ }
+
+ @Test
+ public void testContributionBindingWSCalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-ws-calculator"});
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-maven/README b/sandbox/sebastien/java/embed/samples/launcher-maven/README
new file mode 100644
index 0000000000..ff976c3515
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-maven/README
@@ -0,0 +1,18 @@
+To execute a sample contribution from Maven
+
+look for contributions that have the following configuration in their pom.xml file:
+
+<plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+</plugin>
+
+For contributions that have this, for example, binding-sca/contribution-calculator, do the following
+
+cd samples/binding-sca/contribution-calculator
+mvn tuscany:run
+
+This will launch the contribution in the Tuscany runtime and then wait. At this point you can use
+other clients to send messages to services that the running SCA applcation exposes,
+for example, try calculator-scaclient.
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/README b/sandbox/sebastien/java/embed/samples/launcher-shell/README
new file mode 100644
index 0000000000..abdf824621
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/README
@@ -0,0 +1,34 @@
+Sample Tuscany Shell
+====================
+
+This directory contains a sample shell program supporting simple commands to
+start and stop SCA composites.
+
+To build the sample shell do this:
+mvn install
+
+To run it:
+./sca
+
+at the prompt:
+start myNode mySampleContrib ../contribution-implementation-java-calculator/target/classes
+
+or:
+start myNode mySampleContrib http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+
+also try:
+status
+stop myNode
+bye
+
+Starting and stopping composites is pretty fast. To see that, try the following
+two scripts, which start/stop a sample composite 10 times.
+
+./sca <scripts/test.txt
+or
+./sca <scripts/test-remote.txt
+
+The shell can also run as a Webapp. To try it install target/scashell.war in
+a Web container, point your Web browser to http://localhost:8080/scashell
+and try the links on that page.
+
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/pom.xml b/sandbox/sebastien/java/embed/samples/launcher-shell/pom.xml
new file mode 100644
index 0000000000..cde0e15f62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-shell</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Shell</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>scashell</finalName>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/sca b/sandbox/sebastien/java/embed/samples/launcher-shell/sca
new file mode 100755
index 0000000000..8f6cf268b3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/sca
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+java -classpath target/classes:`ls target/scashell/WEB-INF/lib/*.jar | awk '{ printf "%s:", $1}'` sample.Shell
+
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-remote.txt b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-remote.txt
new file mode 100644
index 0000000000..fd7bd5766a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-remote.txt
@@ -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
+
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-start.txt b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-start.txt
new file mode 100644
index 0000000000..71f7f3f4aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-start.txt
@@ -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
+
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+status
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-status.txt b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-status.txt
new file mode 100644
index 0000000000..4df56e85e8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-status.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+status
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-stop.txt b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-stop.txt
new file mode 100644
index 0000000000..c942a3087b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test-stop.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+stop foo
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test.txt b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test.txt
new file mode 100644
index 0000000000..66c760b937
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/scripts/test.txt
@@ -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
+
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/java/sample/Shell.java b/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/java/sample/Shell.java
new file mode 100644
index 0000000000..f2790409e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/java/sample/Shell.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 static java.lang.System.in;
+import static java.lang.System.out;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.singletonList;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * A little SCA command shell.
+ */
+public class Shell {
+ final NodeFactory nodeFactory;
+
+ public static class NodeInfo {
+ final String name;
+ final String curi;
+ final String cloc;
+ final Node node;
+
+ NodeInfo(final String name, final String curi, final String cloc, final Node node) {
+ this.name = name;
+ this.curi = curi;
+ this.cloc = cloc;
+ this.node = node;
+ }
+
+ public String toString() {
+ return name + " " + curi + " " + cloc;
+ }
+ }
+
+ final Map<String, NodeInfo> nodes = new HashMap<String, NodeInfo>();
+ final List<String> history = new ArrayList<String>();
+
+ public Shell(NodeFactory nf) {
+ this.nodeFactory = nf;
+ }
+
+ List<?> start(final String name, final String curi, final String cloc) {
+ if(nodes.containsKey(name))
+ return emptyList();
+ final Node node = nodeFactory.createNode(new Contribution(curi, cloc));
+ nodes.put(name, new NodeInfo(name, curi, cloc, node));
+ node.start();
+ return emptyList();
+ }
+
+ List<?> stop(final String name) {
+ final NodeInfo ninfo = nodes.get(name);
+ if(ninfo == null)
+ return emptyList();
+ ninfo.node.stop();
+ nodes.remove(name);
+ return emptyList();
+ }
+
+ List<?> stop() {
+ for(NodeInfo ninfo: nodes.values())
+ ninfo.node.stop();
+ nodes.clear();
+ return emptyList();
+ }
+
+ List<?> restart(final String name, final String curi, final String cloc) {
+ stop(name);
+ return start(name, curi, cloc);
+ }
+
+ List<?> status() {
+ return new ArrayList<Object>(nodes.values());
+ }
+
+ List<?> history() {
+ return history;
+ }
+
+ List<?> bye() {
+ return null;
+ }
+
+ List<String> read(final BufferedReader r) throws IOException {
+ final String l = r.readLine();
+ history.add(l);
+ return l != null ? Arrays.asList(l.split(" ")) : singletonList("bye");
+ }
+
+ Callable<List<?>> eval(final List<String> toks) {
+ final String op = toks.get(0);
+ if(op.equals("start"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return start(toks.get(1), toks.get(2), toks.get(3));
+ }
+ };
+ if(op.equals("stop"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ if(toks.size() == 1)
+ return stop();
+ return stop(toks.get(1));
+ }
+ };
+ if(op.equals("restart"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return restart(toks.get(1), toks.get(2), toks.get(3));
+ }
+ };
+ if(op.equals("status"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return status();
+ }
+ };
+ if(op.equals("history"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return history();
+ }
+ };
+ if(op.equals("bye"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return bye();
+ }
+ };
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return emptyList();
+ }
+ };
+ }
+
+ List<?> apply(final Callable<List<?>> func) {
+ try {
+ return func.call();
+ } catch(Exception e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ return singletonList(sw);
+ }
+ }
+
+ boolean print(final List<?> l, PrintWriter w) {
+ if(l == null)
+ return false;
+ for(Object o: l)
+ w.println(o);
+ return true;
+ }
+
+ public Map<String, NodeInfo> run(final BufferedReader r, final PrintWriter w) throws IOException {
+ while(print(apply(eval(read(r))), w))
+ ;
+ r.close();
+ return nodes;
+ }
+
+ public static void main(final String[] args) throws Exception {
+ new Shell(NodeFactory.newInstance()).run(new BufferedReader(new InputStreamReader(in)), new PrintWriter(out, true));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/java/sample/ShellServlet.java b/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/java/sample/ShellServlet.java
new file mode 100644
index 0000000000..55aadbd09b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/java/sample/ShellServlet.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.host.webapp.WebAppHelper;
+
+public class ShellServlet extends HttpServlet {
+ static final long serialVersionUID = 1L;
+
+ Shell shell;
+
+ public void init() {
+ shell = new Shell(WebAppHelper.getNodeFactory());
+ }
+
+ public void destroy() {
+ shell.stop();
+ }
+
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
+ shell.run(new BufferedReader(new InputStreamReader(new URL(req.getParameter("conf")).openStream())), resp.getWriter());
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..ac1ad1cc8e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,48 @@
+<?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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+ <display-name>scashell</display-name>
+
+ <listener><listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class></listener>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <servlet>
+ <servlet-name>ShellServlet</servlet-name>
+ <servlet-class>sample.ShellServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ShellServlet</servlet-name>
+ <url-pattern>/run</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/webapp/index.html b/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/webapp/index.html
new file mode 100644
index 0000000000..d2ae91e0e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-shell/src/main/webapp/index.html
@@ -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.
+-->
+<html>
+<head>
+<title>Sample Runtime Shell</title>
+</head>
+<body>
+<h1>It works</h1>
+
+<p>This Web app runs a sample Tuscany runtime shell similar to samples/launcher-shell.<br/>
+To see how it works and what configuration commands are supported, just read the Shell program's <a href="http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/src/main/java/sample/Shell.java">source code</a>.</p>
+
+<p>Configuration commands can be provided through a text document served from a Web location, for example:<br/>
+<a href="http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/test-start.txt">http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/test-start.txt</a></p>
+
+<p>To run that particular configuration script just point your Web browser to:<br/>
+<a href="http://localhost:8080/scashell/run?conf=http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/test-start.txt">http://localhost:8080/scashell/run?conf=http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/test-start.txt</a><br/>
+To run the script again and refresh the runtime shell, just refresh that page in your Web browser.
+</p>
+
+<p>Sample configuration script samples are available in the Tuscany Subversion repository <a href="http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/">there</a>.
+
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/launcher-webapp/README b/sandbox/sebastien/java/embed/samples/launcher-webapp/README
new file mode 100644
index 0000000000..4031b9c0bd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/launcher-webapp/README
@@ -0,0 +1,29 @@
+To execute sample webapp based contributions (contributions that have webapp at the end of their name) you
+can build the contribution using maven and then copy the resulting war file to your container of choice
+
+For example, for binding-jsonrpc/contribution-calculator-webapp, do the following
+
+cd samples/binding-jsonrpc/contribution-calculator-webapp
+mvn
+cp target/sample-contribution-binding-jsonrpc-calculator-webapp.war your_container_deployment-dir
+
+
+As an alternative sample webapp based contributions can be run within Jetty directly from Maven, look for
+webapp contributions that have the following configuration in their pom.xml file:
+
+<plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+</plugin>
+
+For contributions that have this, for example, binding-jsonrpc/contribution-calculator-webapp, do the following
+
+cd samples/binding-sca/contribution-calculator
+mvn jetty:run
+
+This will launch the contribution in the Jetty runtime and then wait. At this point you can use
+HTTP clients to send messages to services that the running SCA applcation exposes. For this
+example try pointing your browser at:
+
+http://localhost:8080/sample-contribution-binding-jsonrpc-calculator-webapp/
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/README b/sandbox/sebastien/java/embed/samples/logging-scribe/README
new file mode 100644
index 0000000000..92f339ead5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/README
@@ -0,0 +1,51 @@
+This Tuscany sample shows how to implement and use a simple Logger component
+that logs string messages to a Scribe logging server.
+
+Scribe is an Open Source server for aggregating streaming log data. It is
+designed to scale to a very large number of nodes and be robust to network
+and node failures.
+
+See the Scribe Wiki [1] for more information on Scribe.
+
+Getting the required Apache Thrift library
+==========================================
+This sample uses Apache Thrift's libthrift.jar to communicate with Scribe
+servers. Libthrift is not yet available in a Maven repository, so before
+building the sample with Maven, you need to download libthrift [2] and
+install it in your local Maven repository like this:
+
+mvn install:install-file -DgroupId=org.apache.thrift -DartifactId=libthrift \
+-Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=libthrift-r917130.jar
+
+Starting a Scribe server
+========================
+Before running the LoggingTest sample test program, you need to start a Scribe
+server for the sample program to connect to.
+
+Steps to start a Scribe server are described in the Scribe examples README [3].
+A simple Scribe server configuration can be found in the Scribe examples [4].
+
+LoggingTest will try to connect to a Scribe server at localhost:1463. To use
+a Scribe server at a different host or port, configure the host and port
+properties in scribe.composite to match your server.
+
+Running the LoggingTest sample test program
+===========================================
+
+To run the LoggingTest sample test program, do this:
+mvn -Dtest=LoggingTest test
+
+Checking the Scribe log output
+==============================
+After running LoggingTest, you should find the logged string "Hello There" in
+file sample/sample_current under your Scribe log store directory.
+
+If you've used the example1.conf Scribe configuration from the Scribe examples
+[4], you should find your log message in /tmp/scribetest/sample/sample_current.
+
+
+[1] http://wiki.github.com/facebook/scribe/
+[2] http://svn.apache.org/repos/asf/cassandra/trunk/lib/libthrift-r917130.jar
+[3] http://github.com/facebook/scribe/blob/master/examples/README
+[4] http://github.com/facebook/scribe/blob/master/examples/example1.conf
+
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/pom.xml b/sandbox/sebastien/java/embed/samples/logging-scribe/pom.xml
new file mode 100644
index 0000000000..a21897ca5b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/pom.xml
@@ -0,0 +1,96 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <packaging>jar</packaging>
+ <artifactId>sample-logging-scribe</artifactId>
+ <name>Apache Tuscany SCA Scribe Logging Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.thrift</groupId>
+ <artifactId>libthrift</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.5.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/com/facebook/fb303/FacebookService.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/com/facebook/fb303/FacebookService.java
new file mode 100644
index 0000000000..1708066955
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/com/facebook/fb303/FacebookService.java
@@ -0,0 +1,6823 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package generated.com.facebook.fb303;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+import org.apache.thrift.protocol.*;
+
+public class FacebookService {
+
+ /**
+ * Standard base service
+ */
+ public interface Iface {
+
+ /**
+ * Returns a descriptive name of the service
+ */
+ public String getName() throws TException;
+
+ /**
+ * Returns the version of the service
+ */
+ public String getVersion() throws TException;
+
+ /**
+ * Gets the status of this service
+ */
+ public fb_status getStatus() throws TException;
+
+ /**
+ * User friendly description of status, such as why the service is in
+ * the dead or warning state, or what is being started or stopped.
+ */
+ public String getStatusDetails() throws TException;
+
+ /**
+ * Gets the counters for this service
+ */
+ public Map<String,Long> getCounters() throws TException;
+
+ /**
+ * Gets the value of a single counter
+ *
+ * @param key
+ */
+ public long getCounter(String key) throws TException;
+
+ /**
+ * Sets an option
+ *
+ * @param key
+ * @param value
+ */
+ public void setOption(String key, String value) throws TException;
+
+ /**
+ * Gets an option
+ *
+ * @param key
+ */
+ public String getOption(String key) throws TException;
+
+ /**
+ * Gets all options
+ */
+ public Map<String,String> getOptions() throws TException;
+
+ /**
+ * Returns a CPU profile over the given time interval (client and server
+ * must agree on the profile format).
+ *
+ * @param profileDurationInSec
+ */
+ public String getCpuProfile(int profileDurationInSec) throws TException;
+
+ /**
+ * Returns the unix time that the server has been running since
+ */
+ public long aliveSince() throws TException;
+
+ /**
+ * Tell the server to reload its configuration, reopen log files, etc
+ */
+ public void reinitialize() throws TException;
+
+ /**
+ * Suggest a shutdown to the server
+ */
+ public void shutdown() throws TException;
+
+ }
+
+ public static class Client implements Iface {
+ public Client(TProtocol prot)
+ {
+ this(prot, prot);
+ }
+
+ public Client(TProtocol iprot, TProtocol oprot)
+ {
+ iprot_ = iprot;
+ oprot_ = oprot;
+ }
+
+ protected TProtocol iprot_;
+ protected TProtocol oprot_;
+
+ protected int seqid_;
+
+ public TProtocol getInputProtocol()
+ {
+ return this.iprot_;
+ }
+
+ public TProtocol getOutputProtocol()
+ {
+ return this.oprot_;
+ }
+
+ public String getName() throws TException
+ {
+ send_getName();
+ return recv_getName();
+ }
+
+ public void send_getName() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getName", TMessageType.CALL, seqid_));
+ getName_args args = new getName_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public String recv_getName() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getName_result result = new getName_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getName failed: unknown result");
+ }
+
+ public String getVersion() throws TException
+ {
+ send_getVersion();
+ return recv_getVersion();
+ }
+
+ public void send_getVersion() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getVersion", TMessageType.CALL, seqid_));
+ getVersion_args args = new getVersion_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public String recv_getVersion() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getVersion_result result = new getVersion_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getVersion failed: unknown result");
+ }
+
+ public fb_status getStatus() throws TException
+ {
+ send_getStatus();
+ return recv_getStatus();
+ }
+
+ public void send_getStatus() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getStatus", TMessageType.CALL, seqid_));
+ getStatus_args args = new getStatus_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public fb_status recv_getStatus() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getStatus_result result = new getStatus_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getStatus failed: unknown result");
+ }
+
+ public String getStatusDetails() throws TException
+ {
+ send_getStatusDetails();
+ return recv_getStatusDetails();
+ }
+
+ public void send_getStatusDetails() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getStatusDetails", TMessageType.CALL, seqid_));
+ getStatusDetails_args args = new getStatusDetails_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public String recv_getStatusDetails() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getStatusDetails_result result = new getStatusDetails_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getStatusDetails failed: unknown result");
+ }
+
+ public Map<String,Long> getCounters() throws TException
+ {
+ send_getCounters();
+ return recv_getCounters();
+ }
+
+ public void send_getCounters() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getCounters", TMessageType.CALL, seqid_));
+ getCounters_args args = new getCounters_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public Map<String,Long> recv_getCounters() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getCounters_result result = new getCounters_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getCounters failed: unknown result");
+ }
+
+ public long getCounter(String key) throws TException
+ {
+ send_getCounter(key);
+ return recv_getCounter();
+ }
+
+ public void send_getCounter(String key) throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getCounter", TMessageType.CALL, seqid_));
+ getCounter_args args = new getCounter_args();
+ args.key = key;
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public long recv_getCounter() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getCounter_result result = new getCounter_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getCounter failed: unknown result");
+ }
+
+ public void setOption(String key, String value) throws TException
+ {
+ send_setOption(key, value);
+ recv_setOption();
+ }
+
+ public void send_setOption(String key, String value) throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("setOption", TMessageType.CALL, seqid_));
+ setOption_args args = new setOption_args();
+ args.key = key;
+ args.value = value;
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public void recv_setOption() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ setOption_result result = new setOption_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ return;
+ }
+
+ public String getOption(String key) throws TException
+ {
+ send_getOption(key);
+ return recv_getOption();
+ }
+
+ public void send_getOption(String key) throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getOption", TMessageType.CALL, seqid_));
+ getOption_args args = new getOption_args();
+ args.key = key;
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public String recv_getOption() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getOption_result result = new getOption_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getOption failed: unknown result");
+ }
+
+ public Map<String,String> getOptions() throws TException
+ {
+ send_getOptions();
+ return recv_getOptions();
+ }
+
+ public void send_getOptions() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getOptions", TMessageType.CALL, seqid_));
+ getOptions_args args = new getOptions_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public Map<String,String> recv_getOptions() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getOptions_result result = new getOptions_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getOptions failed: unknown result");
+ }
+
+ public String getCpuProfile(int profileDurationInSec) throws TException
+ {
+ send_getCpuProfile(profileDurationInSec);
+ return recv_getCpuProfile();
+ }
+
+ public void send_getCpuProfile(int profileDurationInSec) throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("getCpuProfile", TMessageType.CALL, seqid_));
+ getCpuProfile_args args = new getCpuProfile_args();
+ args.profileDurationInSec = profileDurationInSec;
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public String recv_getCpuProfile() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ getCpuProfile_result result = new getCpuProfile_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "getCpuProfile failed: unknown result");
+ }
+
+ public long aliveSince() throws TException
+ {
+ send_aliveSince();
+ return recv_aliveSince();
+ }
+
+ public void send_aliveSince() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("aliveSince", TMessageType.CALL, seqid_));
+ aliveSince_args args = new aliveSince_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public long recv_aliveSince() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ aliveSince_result result = new aliveSince_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "aliveSince failed: unknown result");
+ }
+
+ public void reinitialize() throws TException
+ {
+ send_reinitialize();
+ }
+
+ public void send_reinitialize() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("reinitialize", TMessageType.CALL, seqid_));
+ reinitialize_args args = new reinitialize_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public void shutdown() throws TException
+ {
+ send_shutdown();
+ }
+
+ public void send_shutdown() throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("shutdown", TMessageType.CALL, seqid_));
+ shutdown_args args = new shutdown_args();
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ }
+ public static class Processor implements TProcessor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
+ public Processor(Iface iface)
+ {
+ iface_ = iface;
+ processMap_.put("getName", new getName());
+ processMap_.put("getVersion", new getVersion());
+ processMap_.put("getStatus", new getStatus());
+ processMap_.put("getStatusDetails", new getStatusDetails());
+ processMap_.put("getCounters", new getCounters());
+ processMap_.put("getCounter", new getCounter());
+ processMap_.put("setOption", new setOption());
+ processMap_.put("getOption", new getOption());
+ processMap_.put("getOptions", new getOptions());
+ processMap_.put("getCpuProfile", new getCpuProfile());
+ processMap_.put("aliveSince", new aliveSince());
+ processMap_.put("reinitialize", new reinitialize());
+ processMap_.put("shutdown", new shutdown());
+ }
+
+ protected static interface ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;
+ }
+
+ private Iface iface_;
+ protected final HashMap<String,ProcessFunction> processMap_ = new HashMap<String,ProcessFunction>();
+
+ public boolean process(TProtocol iprot, TProtocol oprot) throws TException
+ {
+ TMessage msg = iprot.readMessageBegin();
+ ProcessFunction fn = processMap_.get(msg.name);
+ if (fn == null) {
+ TProtocolUtil.skip(iprot, TType.STRUCT);
+ iprot.readMessageEnd();
+ TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
+ oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
+ x.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ return true;
+ }
+ fn.process(msg.seqid, iprot, oprot);
+ return true;
+ }
+
+ private class getName implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getName_args args = new getName_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getName_result result = new getName_result();
+ result.success = iface_.getName();
+ oprot.writeMessageBegin(new TMessage("getName", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class getVersion implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getVersion_args args = new getVersion_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getVersion_result result = new getVersion_result();
+ result.success = iface_.getVersion();
+ oprot.writeMessageBegin(new TMessage("getVersion", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class getStatus implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getStatus_args args = new getStatus_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getStatus_result result = new getStatus_result();
+ result.success = iface_.getStatus();
+ oprot.writeMessageBegin(new TMessage("getStatus", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class getStatusDetails implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getStatusDetails_args args = new getStatusDetails_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getStatusDetails_result result = new getStatusDetails_result();
+ result.success = iface_.getStatusDetails();
+ oprot.writeMessageBegin(new TMessage("getStatusDetails", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class getCounters implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getCounters_args args = new getCounters_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getCounters_result result = new getCounters_result();
+ result.success = iface_.getCounters();
+ oprot.writeMessageBegin(new TMessage("getCounters", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class getCounter implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getCounter_args args = new getCounter_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getCounter_result result = new getCounter_result();
+ result.success = iface_.getCounter(args.key);
+ result.setSuccessIsSet(true);
+ oprot.writeMessageBegin(new TMessage("getCounter", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class setOption implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ setOption_args args = new setOption_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ setOption_result result = new setOption_result();
+ iface_.setOption(args.key, args.value);
+ oprot.writeMessageBegin(new TMessage("setOption", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class getOption implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getOption_args args = new getOption_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getOption_result result = new getOption_result();
+ result.success = iface_.getOption(args.key);
+ oprot.writeMessageBegin(new TMessage("getOption", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class getOptions implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getOptions_args args = new getOptions_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getOptions_result result = new getOptions_result();
+ result.success = iface_.getOptions();
+ oprot.writeMessageBegin(new TMessage("getOptions", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class getCpuProfile implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ getCpuProfile_args args = new getCpuProfile_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ getCpuProfile_result result = new getCpuProfile_result();
+ result.success = iface_.getCpuProfile(args.profileDurationInSec);
+ oprot.writeMessageBegin(new TMessage("getCpuProfile", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class aliveSince implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ aliveSince_args args = new aliveSince_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ aliveSince_result result = new aliveSince_result();
+ result.success = iface_.aliveSince();
+ result.setSuccessIsSet(true);
+ oprot.writeMessageBegin(new TMessage("aliveSince", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ private class reinitialize implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ reinitialize_args args = new reinitialize_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ iface_.reinitialize();
+ return;
+ }
+ }
+
+ private class shutdown implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ shutdown_args args = new shutdown_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ iface_.shutdown();
+ return;
+ }
+ }
+
+ }
+
+ public static class getName_args implements TBase<getName_args._Fields>, java.io.Serializable, Cloneable, Comparable<getName_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getName_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getName_args.class, metaDataMap);
+ }
+
+ public getName_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getName_args(getName_args other) {
+ }
+
+ public getName_args deepCopy() {
+ return new getName_args(this);
+ }
+
+ @Deprecated
+ public getName_args clone() {
+ return new getName_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getName_args)
+ return this.equals((getName_args)that);
+ return false;
+ }
+
+ public boolean equals(getName_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getName_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getName_args typedOther = (getName_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getName_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getName_result implements TBase<getName_result._Fields>, java.io.Serializable, Cloneable, Comparable<getName_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("getName_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRING, (short)0);
+
+ public String success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getName_result.class, metaDataMap);
+ }
+
+ public getName_result() {
+ }
+
+ public getName_result(
+ String success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getName_result(getName_result other) {
+ if (other.isSetSuccess()) {
+ this.success = other.success;
+ }
+ }
+
+ public getName_result deepCopy() {
+ return new getName_result(this);
+ }
+
+ @Deprecated
+ public getName_result clone() {
+ return new getName_result(this);
+ }
+
+ public String getSuccess() {
+ return this.success;
+ }
+
+ public getName_result setSuccess(String success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getName_result)
+ return this.equals((getName_result)that);
+ return false;
+ }
+
+ public boolean equals(getName_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getName_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getName_result typedOther = (getName_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.STRING) {
+ this.success = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeString(this.success);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getName_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getVersion_args implements TBase<getVersion_args._Fields>, java.io.Serializable, Cloneable, Comparable<getVersion_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getVersion_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getVersion_args.class, metaDataMap);
+ }
+
+ public getVersion_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getVersion_args(getVersion_args other) {
+ }
+
+ public getVersion_args deepCopy() {
+ return new getVersion_args(this);
+ }
+
+ @Deprecated
+ public getVersion_args clone() {
+ return new getVersion_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getVersion_args)
+ return this.equals((getVersion_args)that);
+ return false;
+ }
+
+ public boolean equals(getVersion_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getVersion_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getVersion_args typedOther = (getVersion_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getVersion_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getVersion_result implements TBase<getVersion_result._Fields>, java.io.Serializable, Cloneable, Comparable<getVersion_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("getVersion_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRING, (short)0);
+
+ public String success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getVersion_result.class, metaDataMap);
+ }
+
+ public getVersion_result() {
+ }
+
+ public getVersion_result(
+ String success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getVersion_result(getVersion_result other) {
+ if (other.isSetSuccess()) {
+ this.success = other.success;
+ }
+ }
+
+ public getVersion_result deepCopy() {
+ return new getVersion_result(this);
+ }
+
+ @Deprecated
+ public getVersion_result clone() {
+ return new getVersion_result(this);
+ }
+
+ public String getSuccess() {
+ return this.success;
+ }
+
+ public getVersion_result setSuccess(String success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getVersion_result)
+ return this.equals((getVersion_result)that);
+ return false;
+ }
+
+ public boolean equals(getVersion_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getVersion_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getVersion_result typedOther = (getVersion_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.STRING) {
+ this.success = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeString(this.success);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getVersion_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getStatus_args implements TBase<getStatus_args._Fields>, java.io.Serializable, Cloneable, Comparable<getStatus_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getStatus_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getStatus_args.class, metaDataMap);
+ }
+
+ public getStatus_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getStatus_args(getStatus_args other) {
+ }
+
+ public getStatus_args deepCopy() {
+ return new getStatus_args(this);
+ }
+
+ @Deprecated
+ public getStatus_args clone() {
+ return new getStatus_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getStatus_args)
+ return this.equals((getStatus_args)that);
+ return false;
+ }
+
+ public boolean equals(getStatus_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getStatus_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getStatus_args typedOther = (getStatus_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getStatus_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getStatus_result implements TBase<getStatus_result._Fields>, java.io.Serializable, Cloneable, Comparable<getStatus_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("getStatus_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I32, (short)0);
+
+ /**
+ *
+ * @see fb_status
+ */
+ public fb_status success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ /**
+ *
+ * @see fb_status
+ */
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new EnumMetaData(TType.ENUM, fb_status.class)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getStatus_result.class, metaDataMap);
+ }
+
+ public getStatus_result() {
+ }
+
+ public getStatus_result(
+ fb_status success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getStatus_result(getStatus_result other) {
+ if (other.isSetSuccess()) {
+ this.success = other.success;
+ }
+ }
+
+ public getStatus_result deepCopy() {
+ return new getStatus_result(this);
+ }
+
+ @Deprecated
+ public getStatus_result clone() {
+ return new getStatus_result(this);
+ }
+
+ /**
+ *
+ * @see fb_status
+ */
+ public fb_status getSuccess() {
+ return this.success;
+ }
+
+ /**
+ *
+ * @see fb_status
+ */
+ public getStatus_result setSuccess(fb_status success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((fb_status)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getStatus_result)
+ return this.equals((getStatus_result)that);
+ return false;
+ }
+
+ public boolean equals(getStatus_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getStatus_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getStatus_result typedOther = (getStatus_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.I32) {
+ this.success = fb_status.findByValue(iprot.readI32());
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeI32(this.success.getValue());
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getStatus_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ String success_name = success.name();
+ if (success_name != null) {
+ sb.append(success_name);
+ sb.append(" (");
+ }
+ sb.append(this.success);
+ if (success_name != null) {
+ sb.append(")");
+ }
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getStatusDetails_args implements TBase<getStatusDetails_args._Fields>, java.io.Serializable, Cloneable, Comparable<getStatusDetails_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getStatusDetails_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getStatusDetails_args.class, metaDataMap);
+ }
+
+ public getStatusDetails_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getStatusDetails_args(getStatusDetails_args other) {
+ }
+
+ public getStatusDetails_args deepCopy() {
+ return new getStatusDetails_args(this);
+ }
+
+ @Deprecated
+ public getStatusDetails_args clone() {
+ return new getStatusDetails_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getStatusDetails_args)
+ return this.equals((getStatusDetails_args)that);
+ return false;
+ }
+
+ public boolean equals(getStatusDetails_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getStatusDetails_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getStatusDetails_args typedOther = (getStatusDetails_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getStatusDetails_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getStatusDetails_result implements TBase<getStatusDetails_result._Fields>, java.io.Serializable, Cloneable, Comparable<getStatusDetails_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("getStatusDetails_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRING, (short)0);
+
+ public String success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getStatusDetails_result.class, metaDataMap);
+ }
+
+ public getStatusDetails_result() {
+ }
+
+ public getStatusDetails_result(
+ String success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getStatusDetails_result(getStatusDetails_result other) {
+ if (other.isSetSuccess()) {
+ this.success = other.success;
+ }
+ }
+
+ public getStatusDetails_result deepCopy() {
+ return new getStatusDetails_result(this);
+ }
+
+ @Deprecated
+ public getStatusDetails_result clone() {
+ return new getStatusDetails_result(this);
+ }
+
+ public String getSuccess() {
+ return this.success;
+ }
+
+ public getStatusDetails_result setSuccess(String success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getStatusDetails_result)
+ return this.equals((getStatusDetails_result)that);
+ return false;
+ }
+
+ public boolean equals(getStatusDetails_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getStatusDetails_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getStatusDetails_result typedOther = (getStatusDetails_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.STRING) {
+ this.success = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeString(this.success);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getStatusDetails_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getCounters_args implements TBase<getCounters_args._Fields>, java.io.Serializable, Cloneable, Comparable<getCounters_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getCounters_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getCounters_args.class, metaDataMap);
+ }
+
+ public getCounters_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getCounters_args(getCounters_args other) {
+ }
+
+ public getCounters_args deepCopy() {
+ return new getCounters_args(this);
+ }
+
+ @Deprecated
+ public getCounters_args clone() {
+ return new getCounters_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getCounters_args)
+ return this.equals((getCounters_args)that);
+ return false;
+ }
+
+ public boolean equals(getCounters_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getCounters_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getCounters_args typedOther = (getCounters_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getCounters_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getCounters_result implements TBase<getCounters_result._Fields>, java.io.Serializable, Cloneable {
+ private static final TStruct STRUCT_DESC = new TStruct("getCounters_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.MAP, (short)0);
+
+ public Map<String,Long> success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new MapMetaData(TType.MAP,
+ new FieldValueMetaData(TType.STRING),
+ new FieldValueMetaData(TType.I64))));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getCounters_result.class, metaDataMap);
+ }
+
+ public getCounters_result() {
+ }
+
+ public getCounters_result(
+ Map<String,Long> success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getCounters_result(getCounters_result other) {
+ if (other.isSetSuccess()) {
+ Map<String,Long> __this__success = new HashMap<String,Long>();
+ for (Map.Entry<String, Long> other_element : other.success.entrySet()) {
+
+ String other_element_key = other_element.getKey();
+ Long other_element_value = other_element.getValue();
+
+ String __this__success_copy_key = other_element_key;
+
+ Long __this__success_copy_value = other_element_value;
+
+ __this__success.put(__this__success_copy_key, __this__success_copy_value);
+ }
+ this.success = __this__success;
+ }
+ }
+
+ public getCounters_result deepCopy() {
+ return new getCounters_result(this);
+ }
+
+ @Deprecated
+ public getCounters_result clone() {
+ return new getCounters_result(this);
+ }
+
+ public int getSuccessSize() {
+ return (this.success == null) ? 0 : this.success.size();
+ }
+
+ public void putToSuccess(String key, long val) {
+ if (this.success == null) {
+ this.success = new HashMap<String,Long>();
+ }
+ this.success.put(key, val);
+ }
+
+ public Map<String,Long> getSuccess() {
+ return this.success;
+ }
+
+ public getCounters_result setSuccess(Map<String,Long> success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((Map<String,Long>)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getCounters_result)
+ return this.equals((getCounters_result)that);
+ return false;
+ }
+
+ public boolean equals(getCounters_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.MAP) {
+ {
+ TMap _map0 = iprot.readMapBegin();
+ this.success = new HashMap<String,Long>(2*_map0.size);
+ for (int _i1 = 0; _i1 < _map0.size; ++_i1)
+ {
+ String _key2;
+ long _val3;
+ _key2 = iprot.readString();
+ _val3 = iprot.readI64();
+ this.success.put(_key2, _val3);
+ }
+ iprot.readMapEnd();
+ }
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ {
+ oprot.writeMapBegin(new TMap(TType.STRING, TType.I64, this.success.size()));
+ for (Map.Entry<String, Long> _iter4 : this.success.entrySet())
+ {
+ oprot.writeString(_iter4.getKey());
+ oprot.writeI64(_iter4.getValue());
+ }
+ oprot.writeMapEnd();
+ }
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getCounters_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getCounter_args implements TBase<getCounter_args._Fields>, java.io.Serializable, Cloneable, Comparable<getCounter_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getCounter_args");
+
+ private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)1);
+
+ public String key;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ KEY((short)1, "key");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getCounter_args.class, metaDataMap);
+ }
+
+ public getCounter_args() {
+ }
+
+ public getCounter_args(
+ String key)
+ {
+ this();
+ this.key = key;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getCounter_args(getCounter_args other) {
+ if (other.isSetKey()) {
+ this.key = other.key;
+ }
+ }
+
+ public getCounter_args deepCopy() {
+ return new getCounter_args(this);
+ }
+
+ @Deprecated
+ public getCounter_args clone() {
+ return new getCounter_args(this);
+ }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public getCounter_args setKey(String key) {
+ this.key = key;
+ return this;
+ }
+
+ public void unsetKey() {
+ this.key = null;
+ }
+
+ /** Returns true if field key is set (has been asigned a value) and false otherwise */
+ public boolean isSetKey() {
+ return this.key != null;
+ }
+
+ public void setKeyIsSet(boolean value) {
+ if (!value) {
+ this.key = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case KEY:
+ if (value == null) {
+ unsetKey();
+ } else {
+ setKey((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case KEY:
+ return getKey();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case KEY:
+ return isSetKey();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getCounter_args)
+ return this.equals((getCounter_args)that);
+ return false;
+ }
+
+ public boolean equals(getCounter_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_key = true && this.isSetKey();
+ boolean that_present_key = true && that.isSetKey();
+ if (this_present_key || that_present_key) {
+ if (!(this_present_key && that_present_key))
+ return false;
+ if (!this.key.equals(that.key))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getCounter_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getCounter_args typedOther = (getCounter_args)other;
+
+ lastComparison = Boolean.valueOf(isSetKey()).compareTo(isSetKey());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(key, typedOther.key);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case KEY:
+ if (field.type == TType.STRING) {
+ this.key = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (this.key != null) {
+ oprot.writeFieldBegin(KEY_FIELD_DESC);
+ oprot.writeString(this.key);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getCounter_args(");
+ boolean first = true;
+
+ sb.append("key:");
+ if (this.key == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.key);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getCounter_result implements TBase<getCounter_result._Fields>, java.io.Serializable, Cloneable, Comparable<getCounter_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("getCounter_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I64, (short)0);
+
+ public long success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ private static final int __SUCCESS_ISSET_ID = 0;
+ private BitSet __isset_bit_vector = new BitSet(1);
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.I64)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getCounter_result.class, metaDataMap);
+ }
+
+ public getCounter_result() {
+ }
+
+ public getCounter_result(
+ long success)
+ {
+ this();
+ this.success = success;
+ setSuccessIsSet(true);
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getCounter_result(getCounter_result other) {
+ __isset_bit_vector.clear();
+ __isset_bit_vector.or(other.__isset_bit_vector);
+ this.success = other.success;
+ }
+
+ public getCounter_result deepCopy() {
+ return new getCounter_result(this);
+ }
+
+ @Deprecated
+ public getCounter_result clone() {
+ return new getCounter_result(this);
+ }
+
+ public long getSuccess() {
+ return this.success;
+ }
+
+ public getCounter_result setSuccess(long success) {
+ this.success = success;
+ setSuccessIsSet(true);
+ return this;
+ }
+
+ public void unsetSuccess() {
+ __isset_bit_vector.clear(__SUCCESS_ISSET_ID);
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return __isset_bit_vector.get(__SUCCESS_ISSET_ID);
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ __isset_bit_vector.set(__SUCCESS_ISSET_ID, value);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((Long)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return new Long(getSuccess());
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getCounter_result)
+ return this.equals((getCounter_result)that);
+ return false;
+ }
+
+ public boolean equals(getCounter_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true;
+ boolean that_present_success = true;
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (this.success != that.success)
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getCounter_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getCounter_result typedOther = (getCounter_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.I64) {
+ this.success = iprot.readI64();
+ setSuccessIsSet(true);
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeI64(this.success);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getCounter_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ sb.append(this.success);
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class setOption_args implements TBase<setOption_args._Fields>, java.io.Serializable, Cloneable, Comparable<setOption_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("setOption_args");
+
+ private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)1);
+ private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)2);
+
+ public String key;
+ public String value;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ KEY((short)1, "key"),
+ VALUE((short)2, "value");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ put(_Fields.VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(setOption_args.class, metaDataMap);
+ }
+
+ public setOption_args() {
+ }
+
+ public setOption_args(
+ String key,
+ String value)
+ {
+ this();
+ this.key = key;
+ this.value = value;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public setOption_args(setOption_args other) {
+ if (other.isSetKey()) {
+ this.key = other.key;
+ }
+ if (other.isSetValue()) {
+ this.value = other.value;
+ }
+ }
+
+ public setOption_args deepCopy() {
+ return new setOption_args(this);
+ }
+
+ @Deprecated
+ public setOption_args clone() {
+ return new setOption_args(this);
+ }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public setOption_args setKey(String key) {
+ this.key = key;
+ return this;
+ }
+
+ public void unsetKey() {
+ this.key = null;
+ }
+
+ /** Returns true if field key is set (has been asigned a value) and false otherwise */
+ public boolean isSetKey() {
+ return this.key != null;
+ }
+
+ public void setKeyIsSet(boolean value) {
+ if (!value) {
+ this.key = null;
+ }
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public setOption_args setValue(String value) {
+ this.value = value;
+ return this;
+ }
+
+ public void unsetValue() {
+ this.value = null;
+ }
+
+ /** Returns true if field value is set (has been asigned a value) and false otherwise */
+ public boolean isSetValue() {
+ return this.value != null;
+ }
+
+ public void setValueIsSet(boolean value) {
+ if (!value) {
+ this.value = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case KEY:
+ if (value == null) {
+ unsetKey();
+ } else {
+ setKey((String)value);
+ }
+ break;
+
+ case VALUE:
+ if (value == null) {
+ unsetValue();
+ } else {
+ setValue((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case KEY:
+ return getKey();
+
+ case VALUE:
+ return getValue();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case KEY:
+ return isSetKey();
+ case VALUE:
+ return isSetValue();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof setOption_args)
+ return this.equals((setOption_args)that);
+ return false;
+ }
+
+ public boolean equals(setOption_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_key = true && this.isSetKey();
+ boolean that_present_key = true && that.isSetKey();
+ if (this_present_key || that_present_key) {
+ if (!(this_present_key && that_present_key))
+ return false;
+ if (!this.key.equals(that.key))
+ return false;
+ }
+
+ boolean this_present_value = true && this.isSetValue();
+ boolean that_present_value = true && that.isSetValue();
+ if (this_present_value || that_present_value) {
+ if (!(this_present_value && that_present_value))
+ return false;
+ if (!this.value.equals(that.value))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(setOption_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ setOption_args typedOther = (setOption_args)other;
+
+ lastComparison = Boolean.valueOf(isSetKey()).compareTo(isSetKey());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(key, typedOther.key);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = Boolean.valueOf(isSetValue()).compareTo(isSetValue());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(value, typedOther.value);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case KEY:
+ if (field.type == TType.STRING) {
+ this.key = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ case VALUE:
+ if (field.type == TType.STRING) {
+ this.value = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (this.key != null) {
+ oprot.writeFieldBegin(KEY_FIELD_DESC);
+ oprot.writeString(this.key);
+ oprot.writeFieldEnd();
+ }
+ if (this.value != null) {
+ oprot.writeFieldBegin(VALUE_FIELD_DESC);
+ oprot.writeString(this.value);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("setOption_args(");
+ boolean first = true;
+
+ sb.append("key:");
+ if (this.key == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.key);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("value:");
+ if (this.value == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.value);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class setOption_result implements TBase<setOption_result._Fields>, java.io.Serializable, Cloneable, Comparable<setOption_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("setOption_result");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(setOption_result.class, metaDataMap);
+ }
+
+ public setOption_result() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public setOption_result(setOption_result other) {
+ }
+
+ public setOption_result deepCopy() {
+ return new setOption_result(this);
+ }
+
+ @Deprecated
+ public setOption_result clone() {
+ return new setOption_result(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof setOption_result)
+ return this.equals((setOption_result)that);
+ return false;
+ }
+
+ public boolean equals(setOption_result that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(setOption_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ setOption_result typedOther = (setOption_result)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("setOption_result(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getOption_args implements TBase<getOption_args._Fields>, java.io.Serializable, Cloneable, Comparable<getOption_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getOption_args");
+
+ private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)1);
+
+ public String key;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ KEY((short)1, "key");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getOption_args.class, metaDataMap);
+ }
+
+ public getOption_args() {
+ }
+
+ public getOption_args(
+ String key)
+ {
+ this();
+ this.key = key;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getOption_args(getOption_args other) {
+ if (other.isSetKey()) {
+ this.key = other.key;
+ }
+ }
+
+ public getOption_args deepCopy() {
+ return new getOption_args(this);
+ }
+
+ @Deprecated
+ public getOption_args clone() {
+ return new getOption_args(this);
+ }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public getOption_args setKey(String key) {
+ this.key = key;
+ return this;
+ }
+
+ public void unsetKey() {
+ this.key = null;
+ }
+
+ /** Returns true if field key is set (has been asigned a value) and false otherwise */
+ public boolean isSetKey() {
+ return this.key != null;
+ }
+
+ public void setKeyIsSet(boolean value) {
+ if (!value) {
+ this.key = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case KEY:
+ if (value == null) {
+ unsetKey();
+ } else {
+ setKey((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case KEY:
+ return getKey();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case KEY:
+ return isSetKey();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getOption_args)
+ return this.equals((getOption_args)that);
+ return false;
+ }
+
+ public boolean equals(getOption_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_key = true && this.isSetKey();
+ boolean that_present_key = true && that.isSetKey();
+ if (this_present_key || that_present_key) {
+ if (!(this_present_key && that_present_key))
+ return false;
+ if (!this.key.equals(that.key))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getOption_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getOption_args typedOther = (getOption_args)other;
+
+ lastComparison = Boolean.valueOf(isSetKey()).compareTo(isSetKey());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(key, typedOther.key);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case KEY:
+ if (field.type == TType.STRING) {
+ this.key = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (this.key != null) {
+ oprot.writeFieldBegin(KEY_FIELD_DESC);
+ oprot.writeString(this.key);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getOption_args(");
+ boolean first = true;
+
+ sb.append("key:");
+ if (this.key == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.key);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getOption_result implements TBase<getOption_result._Fields>, java.io.Serializable, Cloneable, Comparable<getOption_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("getOption_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRING, (short)0);
+
+ public String success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getOption_result.class, metaDataMap);
+ }
+
+ public getOption_result() {
+ }
+
+ public getOption_result(
+ String success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getOption_result(getOption_result other) {
+ if (other.isSetSuccess()) {
+ this.success = other.success;
+ }
+ }
+
+ public getOption_result deepCopy() {
+ return new getOption_result(this);
+ }
+
+ @Deprecated
+ public getOption_result clone() {
+ return new getOption_result(this);
+ }
+
+ public String getSuccess() {
+ return this.success;
+ }
+
+ public getOption_result setSuccess(String success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getOption_result)
+ return this.equals((getOption_result)that);
+ return false;
+ }
+
+ public boolean equals(getOption_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getOption_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getOption_result typedOther = (getOption_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.STRING) {
+ this.success = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeString(this.success);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getOption_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getOptions_args implements TBase<getOptions_args._Fields>, java.io.Serializable, Cloneable, Comparable<getOptions_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getOptions_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getOptions_args.class, metaDataMap);
+ }
+
+ public getOptions_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getOptions_args(getOptions_args other) {
+ }
+
+ public getOptions_args deepCopy() {
+ return new getOptions_args(this);
+ }
+
+ @Deprecated
+ public getOptions_args clone() {
+ return new getOptions_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getOptions_args)
+ return this.equals((getOptions_args)that);
+ return false;
+ }
+
+ public boolean equals(getOptions_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getOptions_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getOptions_args typedOther = (getOptions_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getOptions_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getOptions_result implements TBase<getOptions_result._Fields>, java.io.Serializable, Cloneable {
+ private static final TStruct STRUCT_DESC = new TStruct("getOptions_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.MAP, (short)0);
+
+ public Map<String,String> success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new MapMetaData(TType.MAP,
+ new FieldValueMetaData(TType.STRING),
+ new FieldValueMetaData(TType.STRING))));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getOptions_result.class, metaDataMap);
+ }
+
+ public getOptions_result() {
+ }
+
+ public getOptions_result(
+ Map<String,String> success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getOptions_result(getOptions_result other) {
+ if (other.isSetSuccess()) {
+ Map<String,String> __this__success = new HashMap<String,String>();
+ for (Map.Entry<String, String> other_element : other.success.entrySet()) {
+
+ String other_element_key = other_element.getKey();
+ String other_element_value = other_element.getValue();
+
+ String __this__success_copy_key = other_element_key;
+
+ String __this__success_copy_value = other_element_value;
+
+ __this__success.put(__this__success_copy_key, __this__success_copy_value);
+ }
+ this.success = __this__success;
+ }
+ }
+
+ public getOptions_result deepCopy() {
+ return new getOptions_result(this);
+ }
+
+ @Deprecated
+ public getOptions_result clone() {
+ return new getOptions_result(this);
+ }
+
+ public int getSuccessSize() {
+ return (this.success == null) ? 0 : this.success.size();
+ }
+
+ public void putToSuccess(String key, String val) {
+ if (this.success == null) {
+ this.success = new HashMap<String,String>();
+ }
+ this.success.put(key, val);
+ }
+
+ public Map<String,String> getSuccess() {
+ return this.success;
+ }
+
+ public getOptions_result setSuccess(Map<String,String> success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((Map<String,String>)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getOptions_result)
+ return this.equals((getOptions_result)that);
+ return false;
+ }
+
+ public boolean equals(getOptions_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.MAP) {
+ {
+ TMap _map5 = iprot.readMapBegin();
+ this.success = new HashMap<String,String>(2*_map5.size);
+ for (int _i6 = 0; _i6 < _map5.size; ++_i6)
+ {
+ String _key7;
+ String _val8;
+ _key7 = iprot.readString();
+ _val8 = iprot.readString();
+ this.success.put(_key7, _val8);
+ }
+ iprot.readMapEnd();
+ }
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ {
+ oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, this.success.size()));
+ for (Map.Entry<String, String> _iter9 : this.success.entrySet())
+ {
+ oprot.writeString(_iter9.getKey());
+ oprot.writeString(_iter9.getValue());
+ }
+ oprot.writeMapEnd();
+ }
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getOptions_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getCpuProfile_args implements TBase<getCpuProfile_args._Fields>, java.io.Serializable, Cloneable, Comparable<getCpuProfile_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("getCpuProfile_args");
+
+ private static final TField PROFILE_DURATION_IN_SEC_FIELD_DESC = new TField("profileDurationInSec", TType.I32, (short)1);
+
+ public int profileDurationInSec;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ PROFILE_DURATION_IN_SEC((short)1, "profileDurationInSec");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ private static final int __PROFILEDURATIONINSEC_ISSET_ID = 0;
+ private BitSet __isset_bit_vector = new BitSet(1);
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.PROFILE_DURATION_IN_SEC, new FieldMetaData("profileDurationInSec", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.I32)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getCpuProfile_args.class, metaDataMap);
+ }
+
+ public getCpuProfile_args() {
+ }
+
+ public getCpuProfile_args(
+ int profileDurationInSec)
+ {
+ this();
+ this.profileDurationInSec = profileDurationInSec;
+ setProfileDurationInSecIsSet(true);
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getCpuProfile_args(getCpuProfile_args other) {
+ __isset_bit_vector.clear();
+ __isset_bit_vector.or(other.__isset_bit_vector);
+ this.profileDurationInSec = other.profileDurationInSec;
+ }
+
+ public getCpuProfile_args deepCopy() {
+ return new getCpuProfile_args(this);
+ }
+
+ @Deprecated
+ public getCpuProfile_args clone() {
+ return new getCpuProfile_args(this);
+ }
+
+ public int getProfileDurationInSec() {
+ return this.profileDurationInSec;
+ }
+
+ public getCpuProfile_args setProfileDurationInSec(int profileDurationInSec) {
+ this.profileDurationInSec = profileDurationInSec;
+ setProfileDurationInSecIsSet(true);
+ return this;
+ }
+
+ public void unsetProfileDurationInSec() {
+ __isset_bit_vector.clear(__PROFILEDURATIONINSEC_ISSET_ID);
+ }
+
+ /** Returns true if field profileDurationInSec is set (has been asigned a value) and false otherwise */
+ public boolean isSetProfileDurationInSec() {
+ return __isset_bit_vector.get(__PROFILEDURATIONINSEC_ISSET_ID);
+ }
+
+ public void setProfileDurationInSecIsSet(boolean value) {
+ __isset_bit_vector.set(__PROFILEDURATIONINSEC_ISSET_ID, value);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case PROFILE_DURATION_IN_SEC:
+ if (value == null) {
+ unsetProfileDurationInSec();
+ } else {
+ setProfileDurationInSec((Integer)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case PROFILE_DURATION_IN_SEC:
+ return new Integer(getProfileDurationInSec());
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case PROFILE_DURATION_IN_SEC:
+ return isSetProfileDurationInSec();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getCpuProfile_args)
+ return this.equals((getCpuProfile_args)that);
+ return false;
+ }
+
+ public boolean equals(getCpuProfile_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_profileDurationInSec = true;
+ boolean that_present_profileDurationInSec = true;
+ if (this_present_profileDurationInSec || that_present_profileDurationInSec) {
+ if (!(this_present_profileDurationInSec && that_present_profileDurationInSec))
+ return false;
+ if (this.profileDurationInSec != that.profileDurationInSec)
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getCpuProfile_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getCpuProfile_args typedOther = (getCpuProfile_args)other;
+
+ lastComparison = Boolean.valueOf(isSetProfileDurationInSec()).compareTo(isSetProfileDurationInSec());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(profileDurationInSec, typedOther.profileDurationInSec);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case PROFILE_DURATION_IN_SEC:
+ if (field.type == TType.I32) {
+ this.profileDurationInSec = iprot.readI32();
+ setProfileDurationInSecIsSet(true);
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldBegin(PROFILE_DURATION_IN_SEC_FIELD_DESC);
+ oprot.writeI32(this.profileDurationInSec);
+ oprot.writeFieldEnd();
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getCpuProfile_args(");
+ boolean first = true;
+
+ sb.append("profileDurationInSec:");
+ sb.append(this.profileDurationInSec);
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class getCpuProfile_result implements TBase<getCpuProfile_result._Fields>, java.io.Serializable, Cloneable, Comparable<getCpuProfile_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("getCpuProfile_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRING, (short)0);
+
+ public String success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(getCpuProfile_result.class, metaDataMap);
+ }
+
+ public getCpuProfile_result() {
+ }
+
+ public getCpuProfile_result(
+ String success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public getCpuProfile_result(getCpuProfile_result other) {
+ if (other.isSetSuccess()) {
+ this.success = other.success;
+ }
+ }
+
+ public getCpuProfile_result deepCopy() {
+ return new getCpuProfile_result(this);
+ }
+
+ @Deprecated
+ public getCpuProfile_result clone() {
+ return new getCpuProfile_result(this);
+ }
+
+ public String getSuccess() {
+ return this.success;
+ }
+
+ public getCpuProfile_result setSuccess(String success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof getCpuProfile_result)
+ return this.equals((getCpuProfile_result)that);
+ return false;
+ }
+
+ public boolean equals(getCpuProfile_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(getCpuProfile_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ getCpuProfile_result typedOther = (getCpuProfile_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.STRING) {
+ this.success = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeString(this.success);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("getCpuProfile_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class aliveSince_args implements TBase<aliveSince_args._Fields>, java.io.Serializable, Cloneable, Comparable<aliveSince_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("aliveSince_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(aliveSince_args.class, metaDataMap);
+ }
+
+ public aliveSince_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public aliveSince_args(aliveSince_args other) {
+ }
+
+ public aliveSince_args deepCopy() {
+ return new aliveSince_args(this);
+ }
+
+ @Deprecated
+ public aliveSince_args clone() {
+ return new aliveSince_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof aliveSince_args)
+ return this.equals((aliveSince_args)that);
+ return false;
+ }
+
+ public boolean equals(aliveSince_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(aliveSince_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ aliveSince_args typedOther = (aliveSince_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("aliveSince_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class aliveSince_result implements TBase<aliveSince_result._Fields>, java.io.Serializable, Cloneable, Comparable<aliveSince_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("aliveSince_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I64, (short)0);
+
+ public long success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ private static final int __SUCCESS_ISSET_ID = 0;
+ private BitSet __isset_bit_vector = new BitSet(1);
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.I64)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(aliveSince_result.class, metaDataMap);
+ }
+
+ public aliveSince_result() {
+ }
+
+ public aliveSince_result(
+ long success)
+ {
+ this();
+ this.success = success;
+ setSuccessIsSet(true);
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public aliveSince_result(aliveSince_result other) {
+ __isset_bit_vector.clear();
+ __isset_bit_vector.or(other.__isset_bit_vector);
+ this.success = other.success;
+ }
+
+ public aliveSince_result deepCopy() {
+ return new aliveSince_result(this);
+ }
+
+ @Deprecated
+ public aliveSince_result clone() {
+ return new aliveSince_result(this);
+ }
+
+ public long getSuccess() {
+ return this.success;
+ }
+
+ public aliveSince_result setSuccess(long success) {
+ this.success = success;
+ setSuccessIsSet(true);
+ return this;
+ }
+
+ public void unsetSuccess() {
+ __isset_bit_vector.clear(__SUCCESS_ISSET_ID);
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return __isset_bit_vector.get(__SUCCESS_ISSET_ID);
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ __isset_bit_vector.set(__SUCCESS_ISSET_ID, value);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((Long)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return new Long(getSuccess());
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof aliveSince_result)
+ return this.equals((aliveSince_result)that);
+ return false;
+ }
+
+ public boolean equals(aliveSince_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true;
+ boolean that_present_success = true;
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (this.success != that.success)
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(aliveSince_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ aliveSince_result typedOther = (aliveSince_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.I64) {
+ this.success = iprot.readI64();
+ setSuccessIsSet(true);
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeI64(this.success);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("aliveSince_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ sb.append(this.success);
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class reinitialize_args implements TBase<reinitialize_args._Fields>, java.io.Serializable, Cloneable, Comparable<reinitialize_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("reinitialize_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(reinitialize_args.class, metaDataMap);
+ }
+
+ public reinitialize_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public reinitialize_args(reinitialize_args other) {
+ }
+
+ public reinitialize_args deepCopy() {
+ return new reinitialize_args(this);
+ }
+
+ @Deprecated
+ public reinitialize_args clone() {
+ return new reinitialize_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof reinitialize_args)
+ return this.equals((reinitialize_args)that);
+ return false;
+ }
+
+ public boolean equals(reinitialize_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(reinitialize_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ reinitialize_args typedOther = (reinitialize_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("reinitialize_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class shutdown_args implements TBase<shutdown_args._Fields>, java.io.Serializable, Cloneable, Comparable<shutdown_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("shutdown_args");
+
+
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+;
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(shutdown_args.class, metaDataMap);
+ }
+
+ public shutdown_args() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public shutdown_args(shutdown_args other) {
+ }
+
+ public shutdown_args deepCopy() {
+ return new shutdown_args(this);
+ }
+
+ @Deprecated
+ public shutdown_args clone() {
+ return new shutdown_args(this);
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof shutdown_args)
+ return this.equals((shutdown_args)that);
+ return false;
+ }
+
+ public boolean equals(shutdown_args that) {
+ if (that == null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(shutdown_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ shutdown_args typedOther = (shutdown_args)other;
+
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("shutdown_args(");
+ boolean first = true;
+
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/com/facebook/fb303/fb_status.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/com/facebook/fb303/fb_status.java
new file mode 100644
index 0000000000..bb7b132477
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/com/facebook/fb303/fb_status.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package generated.com.facebook.fb303;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift.TEnum;
+/**
+ * Common status reporting mechanism across all services
+ */
+public enum fb_status implements TEnum{
+ DEAD(0),
+ STARTING(1),
+ ALIVE(2),
+ STOPPING(3),
+ STOPPED(4),
+ WARNING(5);
+
+ private static final Map<Integer, fb_status> BY_VALUE = new HashMap<Integer,fb_status>() {{
+ for(fb_status val : fb_status.values()) {
+ put(val.getValue(), val);
+ }
+ }};
+
+ private final int value;
+
+ private fb_status(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Get the integer value of this enum value, as defined in the Thrift IDL.
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Find a the enum type by its integer value, as defined in the Thrift IDL.
+ * @return null if the value is not found.
+ */
+ public static fb_status findByValue(int value) {
+ return BY_VALUE.get(value);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/LogEntry.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/LogEntry.java
new file mode 100644
index 0000000000..c06570d9ef
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/LogEntry.java
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package generated.scribe.thrift;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+import org.apache.thrift.protocol.*;
+
+public class LogEntry implements TBase<LogEntry._Fields>, java.io.Serializable, Cloneable, Comparable<LogEntry> {
+ private static final TStruct STRUCT_DESC = new TStruct("LogEntry");
+
+ private static final TField CATEGORY_FIELD_DESC = new TField("category", TType.STRING, (short)1);
+ private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)2);
+
+ public String category;
+ public String message;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ CATEGORY((short)1, "category"),
+ MESSAGE((short)2, "message");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.CATEGORY, new FieldMetaData("category", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT,
+ new FieldValueMetaData(TType.STRING)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(LogEntry.class, metaDataMap);
+ }
+
+ public LogEntry() {
+ }
+
+ public LogEntry(
+ String category,
+ String message)
+ {
+ this();
+ this.category = category;
+ this.message = message;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public LogEntry(LogEntry other) {
+ if (other.isSetCategory()) {
+ this.category = other.category;
+ }
+ if (other.isSetMessage()) {
+ this.message = other.message;
+ }
+ }
+
+ public LogEntry deepCopy() {
+ return new LogEntry(this);
+ }
+
+ @Deprecated
+ public LogEntry clone() {
+ return new LogEntry(this);
+ }
+
+ public String getCategory() {
+ return this.category;
+ }
+
+ public LogEntry setCategory(String category) {
+ this.category = category;
+ return this;
+ }
+
+ public void unsetCategory() {
+ this.category = null;
+ }
+
+ /** Returns true if field category is set (has been asigned a value) and false otherwise */
+ public boolean isSetCategory() {
+ return this.category != null;
+ }
+
+ public void setCategoryIsSet(boolean value) {
+ if (!value) {
+ this.category = null;
+ }
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ public LogEntry setMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+ public void unsetMessage() {
+ this.message = null;
+ }
+
+ /** Returns true if field message is set (has been asigned a value) and false otherwise */
+ public boolean isSetMessage() {
+ return this.message != null;
+ }
+
+ public void setMessageIsSet(boolean value) {
+ if (!value) {
+ this.message = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case CATEGORY:
+ if (value == null) {
+ unsetCategory();
+ } else {
+ setCategory((String)value);
+ }
+ break;
+
+ case MESSAGE:
+ if (value == null) {
+ unsetMessage();
+ } else {
+ setMessage((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case CATEGORY:
+ return getCategory();
+
+ case MESSAGE:
+ return getMessage();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case CATEGORY:
+ return isSetCategory();
+ case MESSAGE:
+ return isSetMessage();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof LogEntry)
+ return this.equals((LogEntry)that);
+ return false;
+ }
+
+ public boolean equals(LogEntry that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_category = true && this.isSetCategory();
+ boolean that_present_category = true && that.isSetCategory();
+ if (this_present_category || that_present_category) {
+ if (!(this_present_category && that_present_category))
+ return false;
+ if (!this.category.equals(that.category))
+ return false;
+ }
+
+ boolean this_present_message = true && this.isSetMessage();
+ boolean that_present_message = true && that.isSetMessage();
+ if (this_present_message || that_present_message) {
+ if (!(this_present_message && that_present_message))
+ return false;
+ if (!this.message.equals(that.message))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(LogEntry other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ LogEntry typedOther = (LogEntry)other;
+
+ lastComparison = Boolean.valueOf(isSetCategory()).compareTo(isSetCategory());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(category, typedOther.category);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = Boolean.valueOf(isSetMessage()).compareTo(isSetMessage());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(message, typedOther.message);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case CATEGORY:
+ if (field.type == TType.STRING) {
+ this.category = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ case MESSAGE:
+ if (field.type == TType.STRING) {
+ this.message = iprot.readString();
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (this.category != null) {
+ oprot.writeFieldBegin(CATEGORY_FIELD_DESC);
+ oprot.writeString(this.category);
+ oprot.writeFieldEnd();
+ }
+ if (this.message != null) {
+ oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+ oprot.writeString(this.message);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("LogEntry(");
+ boolean first = true;
+
+ sb.append("category:");
+ if (this.category == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.category);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("message:");
+ if (this.message == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.message);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+}
+
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/ResultCode.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/ResultCode.java
new file mode 100644
index 0000000000..2bf826d06a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/ResultCode.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.
+ */
+
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package generated.scribe.thrift;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift.TEnum;
+public enum ResultCode implements TEnum{
+ OK(0),
+ TRY_LATER(1);
+
+ private static final Map<Integer, ResultCode> BY_VALUE = new HashMap<Integer,ResultCode>() {{
+ for(ResultCode val : ResultCode.values()) {
+ put(val.getValue(), val);
+ }
+ }};
+
+ private final int value;
+
+ private ResultCode(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Get the integer value of this enum value, as defined in the Thrift IDL.
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Find a the enum type by its integer value, as defined in the Thrift IDL.
+ * @return null if the value is not found.
+ */
+ public static ResultCode findByValue(int value) {
+ return BY_VALUE.get(value);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/scribe.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/scribe.java
new file mode 100644
index 0000000000..40b4ca774b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/generated/scribe/thrift/scribe.java
@@ -0,0 +1,772 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package generated.scribe.thrift;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+import org.apache.thrift.protocol.*;
+
+public class scribe {
+
+ public interface Iface extends generated.com.facebook.fb303.FacebookService.Iface {
+
+ public ResultCode Log(List<LogEntry> messages) throws TException;
+
+ }
+
+ public static class Client extends generated.com.facebook.fb303.FacebookService.Client implements Iface {
+ public Client(TProtocol prot)
+ {
+ this(prot, prot);
+ }
+
+ public Client(TProtocol iprot, TProtocol oprot)
+ {
+ super(iprot, oprot);
+ }
+
+ public ResultCode Log(List<LogEntry> messages) throws TException
+ {
+ send_Log(messages);
+ return recv_Log();
+ }
+
+ public void send_Log(List<LogEntry> messages) throws TException
+ {
+ oprot_.writeMessageBegin(new TMessage("Log", TMessageType.CALL, seqid_));
+ Log_args args = new Log_args();
+ args.messages = messages;
+ args.write(oprot_);
+ oprot_.writeMessageEnd();
+ oprot_.getTransport().flush();
+ }
+
+ public ResultCode recv_Log() throws TException
+ {
+ TMessage msg = iprot_.readMessageBegin();
+ if (msg.type == TMessageType.EXCEPTION) {
+ TApplicationException x = TApplicationException.read(iprot_);
+ iprot_.readMessageEnd();
+ throw x;
+ }
+ Log_result result = new Log_result();
+ result.read(iprot_);
+ iprot_.readMessageEnd();
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ throw new TApplicationException(TApplicationException.MISSING_RESULT, "Log failed: unknown result");
+ }
+
+ }
+ public static class Processor extends generated.com.facebook.fb303.FacebookService.Processor implements TProcessor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
+ public Processor(Iface iface)
+ {
+ super(iface);
+ iface_ = iface;
+ processMap_.put("Log", new Log());
+ }
+
+ private Iface iface_;
+
+ public boolean process(TProtocol iprot, TProtocol oprot) throws TException
+ {
+ TMessage msg = iprot.readMessageBegin();
+ ProcessFunction fn = processMap_.get(msg.name);
+ if (fn == null) {
+ TProtocolUtil.skip(iprot, TType.STRUCT);
+ iprot.readMessageEnd();
+ TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
+ oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
+ x.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ return true;
+ }
+ fn.process(msg.seqid, iprot, oprot);
+ return true;
+ }
+
+ private class Log implements ProcessFunction {
+ public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+ {
+ Log_args args = new Log_args();
+ args.read(iprot);
+ iprot.readMessageEnd();
+ Log_result result = new Log_result();
+ result.success = iface_.Log(args.messages);
+ oprot.writeMessageBegin(new TMessage("Log", TMessageType.REPLY, seqid));
+ result.write(oprot);
+ oprot.writeMessageEnd();
+ oprot.getTransport().flush();
+ }
+
+ }
+
+ }
+
+ public static class Log_args implements TBase<Log_args._Fields>, java.io.Serializable, Cloneable, Comparable<Log_args> {
+ private static final TStruct STRUCT_DESC = new TStruct("Log_args");
+
+ private static final TField MESSAGES_FIELD_DESC = new TField("messages", TType.LIST, (short)1);
+
+ public List<LogEntry> messages;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ MESSAGES((short)1, "messages");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.MESSAGES, new FieldMetaData("messages", TFieldRequirementType.DEFAULT,
+ new ListMetaData(TType.LIST,
+ new StructMetaData(TType.STRUCT, LogEntry.class))));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(Log_args.class, metaDataMap);
+ }
+
+ public Log_args() {
+ }
+
+ public Log_args(
+ List<LogEntry> messages)
+ {
+ this();
+ this.messages = messages;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public Log_args(Log_args other) {
+ if (other.isSetMessages()) {
+ List<LogEntry> __this__messages = new ArrayList<LogEntry>();
+ for (LogEntry other_element : other.messages) {
+ __this__messages.add(new LogEntry(other_element));
+ }
+ this.messages = __this__messages;
+ }
+ }
+
+ public Log_args deepCopy() {
+ return new Log_args(this);
+ }
+
+ @Deprecated
+ public Log_args clone() {
+ return new Log_args(this);
+ }
+
+ public int getMessagesSize() {
+ return (this.messages == null) ? 0 : this.messages.size();
+ }
+
+ public java.util.Iterator<LogEntry> getMessagesIterator() {
+ return (this.messages == null) ? null : this.messages.iterator();
+ }
+
+ public void addToMessages(LogEntry elem) {
+ if (this.messages == null) {
+ this.messages = new ArrayList<LogEntry>();
+ }
+ this.messages.add(elem);
+ }
+
+ public List<LogEntry> getMessages() {
+ return this.messages;
+ }
+
+ public Log_args setMessages(List<LogEntry> messages) {
+ this.messages = messages;
+ return this;
+ }
+
+ public void unsetMessages() {
+ this.messages = null;
+ }
+
+ /** Returns true if field messages is set (has been asigned a value) and false otherwise */
+ public boolean isSetMessages() {
+ return this.messages != null;
+ }
+
+ public void setMessagesIsSet(boolean value) {
+ if (!value) {
+ this.messages = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case MESSAGES:
+ if (value == null) {
+ unsetMessages();
+ } else {
+ setMessages((List<LogEntry>)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case MESSAGES:
+ return getMessages();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case MESSAGES:
+ return isSetMessages();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof Log_args)
+ return this.equals((Log_args)that);
+ return false;
+ }
+
+ public boolean equals(Log_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_messages = true && this.isSetMessages();
+ boolean that_present_messages = true && that.isSetMessages();
+ if (this_present_messages || that_present_messages) {
+ if (!(this_present_messages && that_present_messages))
+ return false;
+ if (!this.messages.equals(that.messages))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(Log_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ Log_args typedOther = (Log_args)other;
+
+ lastComparison = Boolean.valueOf(isSetMessages()).compareTo(isSetMessages());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(messages, typedOther.messages);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case MESSAGES:
+ if (field.type == TType.LIST) {
+ {
+ TList _list0 = iprot.readListBegin();
+ this.messages = new ArrayList<LogEntry>(_list0.size);
+ for (int _i1 = 0; _i1 < _list0.size; ++_i1)
+ {
+ LogEntry _elem2;
+ _elem2 = new LogEntry();
+ _elem2.read(iprot);
+ this.messages.add(_elem2);
+ }
+ iprot.readListEnd();
+ }
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (this.messages != null) {
+ oprot.writeFieldBegin(MESSAGES_FIELD_DESC);
+ {
+ oprot.writeListBegin(new TList(TType.STRUCT, this.messages.size()));
+ for (LogEntry _iter3 : this.messages)
+ {
+ _iter3.write(oprot);
+ }
+ oprot.writeListEnd();
+ }
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("Log_args(");
+ boolean first = true;
+
+ sb.append("messages:");
+ if (this.messages == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.messages);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+ public static class Log_result implements TBase<Log_result._Fields>, java.io.Serializable, Cloneable, Comparable<Log_result> {
+ private static final TStruct STRUCT_DESC = new TStruct("Log_result");
+
+ private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I32, (short)0);
+
+ /**
+ *
+ * @see ResultCode
+ */
+ public ResultCode success;
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements TFieldIdEnum {
+ /**
+ *
+ * @see ResultCode
+ */
+ SUCCESS((short)0, "success");
+
+ private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byId.put((int)field._thriftId, field);
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ return byId.get(fieldId);
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+ put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
+ new EnumMetaData(TType.ENUM, ResultCode.class)));
+ }});
+
+ static {
+ FieldMetaData.addStructMetaDataMap(Log_result.class, metaDataMap);
+ }
+
+ public Log_result() {
+ }
+
+ public Log_result(
+ ResultCode success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public Log_result(Log_result other) {
+ if (other.isSetSuccess()) {
+ this.success = other.success;
+ }
+ }
+
+ public Log_result deepCopy() {
+ return new Log_result(this);
+ }
+
+ @Deprecated
+ public Log_result clone() {
+ return new Log_result(this);
+ }
+
+ /**
+ *
+ * @see ResultCode
+ */
+ public ResultCode getSuccess() {
+ return this.success;
+ }
+
+ /**
+ *
+ * @see ResultCode
+ */
+ public Log_result setSuccess(ResultCode success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been asigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((ResultCode)value);
+ }
+ break;
+
+ }
+ }
+
+ public void setFieldValue(int fieldID, Object value) {
+ setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ public Object getFieldValue(int fieldId) {
+ return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isSet(int fieldID) {
+ return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof Log_result)
+ return this.equals((Log_result)that);
+ return false;
+ }
+
+ public boolean equals(Log_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(Log_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ Log_result typedOther = (Log_result)other;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ return 0;
+ }
+
+ public void read(TProtocol iprot) throws TException {
+ TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == TType.STOP) {
+ break;
+ }
+ _Fields fieldId = _Fields.findByThriftId(field.id);
+ if (fieldId == null) {
+ TProtocolUtil.skip(iprot, field.type);
+ } else {
+ switch (fieldId) {
+ case SUCCESS:
+ if (field.type == TType.I32) {
+ this.success = ResultCode.findByValue(iprot.readI32());
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ }
+ iprot.readFieldEnd();
+ }
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ validate();
+ }
+
+ public void write(TProtocol oprot) throws TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.isSetSuccess()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeI32(this.success.getValue());
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("Log_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ String success_name = success.name();
+ if (success_name != null) {
+ sb.append(success_name);
+ sb.append(" (");
+ }
+ sb.append(this.success);
+ if (success_name != null) {
+ sb.append(")");
+ }
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws TException {
+ // check for required fields
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/HelloWorld.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/HelloWorld.java
new file mode 100644
index 0000000000..7fb20fe5f4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/HelloWorld.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/HelloWorldImpl.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/HelloWorldImpl.java
new file mode 100644
index 0000000000..d90af4c792
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/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 sample;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldImpl implements HelloWorld {
+
+ @Reference
+ public Logger logger;
+
+ public String sayHello(String name) {
+ logger.log("sample", "HelloWorldImpl.sayHello " + name);
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/Logger.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/Logger.java
new file mode 100644
index 0000000000..aab9ec27c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/Logger.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Logger {
+
+ int log(String category, String message);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/ScribeLoggerImpl.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/ScribeLoggerImpl.java
new file mode 100644
index 0000000000..10c2e079fd
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/java/sample/ScribeLoggerImpl.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 sample;
+
+import generated.scribe.thrift.scribe;
+import generated.scribe.thrift.LogEntry;
+import java.util.Collections;
+import org.apache.thrift.TException;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TFramedTransport;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Destroy;
+
+@Scope("COMPOSITE")
+public class ScribeLoggerImpl implements Logger {
+
+ @Property
+ public String host;
+
+ @Property
+ public int port;
+
+ scribe.Client scribe;
+ TTransport transport;
+
+ @Init
+ public void init() {
+ try {
+ final TSocket socket = new TSocket(host, port);
+ socket.setTimeout(1000);
+ transport = new TFramedTransport(socket);
+ final TProtocol protocol = new TBinaryProtocol(transport);
+ scribe = new scribe.Client(protocol);
+ transport.open();
+ } catch (TException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Destroy
+ public void destroy() {
+ transport.close();
+ }
+
+ public int log(String category, String message) {
+ try {
+ scribe.Log(Collections.singletonList(new LogEntry(category, message)));
+ return 1;
+ } catch (TException e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..fe284f2c10
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:scribe"/>
+</contribution>
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/fb303.thrift b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/fb303.thrift
new file mode 100644
index 0000000000..4926b7a736
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/fb303.thrift
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * fb303.thrift
+ */
+
+namespace java generated.com.facebook.fb303
+namespace cpp facebook.fb303
+namespace perl Facebook.FB303
+
+/**
+ * Common status reporting mechanism across all services
+ */
+enum fb_status {
+ DEAD = 0,
+ STARTING = 1,
+ ALIVE = 2,
+ STOPPING = 3,
+ STOPPED = 4,
+ WARNING = 5,
+}
+
+/**
+ * Standard base service
+ */
+service FacebookService {
+
+ /**
+ * Returns a descriptive name of the service
+ */
+ string getName(),
+
+ /**
+ * Returns the version of the service
+ */
+ string getVersion(),
+
+ /**
+ * Gets the status of this service
+ */
+ fb_status getStatus(),
+
+ /**
+ * User friendly description of status, such as why the service is in
+ * the dead or warning state, or what is being started or stopped.
+ */
+ string getStatusDetails(),
+
+ /**
+ * Gets the counters for this service
+ */
+ map<string, i64> getCounters(),
+
+ /**
+ * Gets the value of a single counter
+ */
+ i64 getCounter(1: string key),
+
+ /**
+ * Sets an option
+ */
+ void setOption(1: string key, 2: string value),
+
+ /**
+ * Gets an option
+ */
+ string getOption(1: string key),
+
+ /**
+ * Gets all options
+ */
+ map<string, string> getOptions(),
+
+ /**
+ * Returns a CPU profile over the given time interval (client and server
+ * must agree on the profile format).
+ */
+ string getCpuProfile(1: i32 profileDurationInSec),
+
+ /**
+ * Returns the unix time that the server has been running since
+ */
+ i64 aliveSince(),
+
+ /**
+ * Tell the server to reload its configuration, reopen log files, etc
+ */
+ oneway void reinitialize(),
+
+ /**
+ * Suggest a shutdown to the server
+ */
+ oneway void shutdown(),
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/scribe.composite b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/scribe.composite
new file mode 100644
index 0000000000..b075a13843
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/scribe.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="scribe">
+
+ <component name="HelloWorld">
+ <implementation.java class="sample.HelloWorldImpl"/>
+ <reference name="logger" target="ScribeLogger"/>
+ </component>
+
+ <component name="ScribeLogger">
+ <implementation.java class="sample.ScribeLoggerImpl"/>
+ <property name="host">localhost</property>
+ <property name="port">1463</property>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/scribe.thrift b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/scribe.thrift
new file mode 100644
index 0000000000..468412f38e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/main/resources/scribe.thrift
@@ -0,0 +1,38 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## 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.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+include "fb303.thrift"
+
+namespace cpp scribe.thrift
+namespace java generated.scribe.thrift
+
+enum ResultCode
+{
+ OK,
+ TRY_LATER
+}
+
+struct LogEntry
+{
+ 1: string category,
+ 2: string message
+}
+
+service scribe extends fb303.FacebookService
+{
+ ResultCode Log(1: list<LogEntry> messages);
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging-scribe/src/test/java/sample/LoggingTest.java b/sandbox/sebastien/java/embed/samples/logging-scribe/src/test/java/sample/LoggingTest.java
new file mode 100644
index 0000000000..4232365f81
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging-scribe/src/test/java/sample/LoggingTest.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 sample;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import sample.HelloWorld;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class LoggingTest {
+
+ @Test
+ public void testSayHello() {
+ NodeFactory nf = NodeFactory.newInstance();
+ Node node = nf.createNode((String)null, new String[] {"target/classes"}).start();
+ HelloWorld hw = node.getService(HelloWorld.class, "HelloWorld");
+ assertEquals("Hello There", hw.sayHello("There"));
+ node.stop();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/logging.properties b/sandbox/sebastien/java/embed/samples/logging.properties
new file mode 100644
index 0000000000..cf452e7812
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/logging.properties
@@ -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.
+#
+
+handlers= java.util.logging.ConsoleHandler
+
+.level = INFO
+
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+org.apache.tuscany.sca.level = INFO
diff --git a/sandbox/sebastien/java/embed/samples/pom.xml b/sandbox/sebastien/java/embed/samples/pom.xml
new file mode 100644
index 0000000000..bf80b4a037
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/pom.xml
@@ -0,0 +1,107 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-samples</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Samples</name>
+
+ <modules>
+ <module>calculator-osgi</module>
+ <module>dosgi-calculator</module>
+ <module>dosgi-calculator-operations</module>
+ <module>dosgi-dynamic-calculator</module>
+ <module>dosgi-dynamic-calculator-operations</module>
+ <module>calculator-scaclient</module>
+ <module>helloworld</module>
+ <module>helloworld-scaclient</module>
+<!-- *********
+ IF YOU ADD ANY SAMPLES THEN ALSO ADD THEM TO
+ distribution\all\src\main\components\bin-samples.xml
+ OR THEY WONT GET IN RELEASES
+ ********* -->
+<!-- *********
+ ALSO SAMPLES SHOULD HAVE A TEST IN itest/distribution TO
+ ENSURE THAT THEY WORK PROPERLY OUT OF A DISTRIBUTION
+ ********* -->
+
+ <module>helloworld-bpel</module>
+ <module>helloworld-spring</module>
+ <module>webapps/helloworld</module>
+ <module>webapps/helloworld-bpel</module>
+ <module>webapps/helloworld-jaxrs</module>
+ <module>webapps/helloworld-jms</module>
+ <module>webapps/helloworld-js-client</module>
+ <module>webapps/helloworld-jsp</module>
+ <module>webapps/helloworld-stripes</module>
+ <module>webapps/helloworld-servlet</module>
+ <module>webapps/helloworld-spring</module>
+
+ <!-- contributions - SCA samples -->
+
+ <module>binding-rmi</module>
+ <module>binding-sca</module>
+ <module>binding-ws</module>
+ <module>binding-jsonrpc</module>
+ <module>implementation-java</module>
+ <module>implementation-script</module>
+
+ <!-- contributions - Tuscany samples -->
+
+ <!-- TODO -->
+
+ <!-- contribution launchers -->
+
+ <!-- don't need to process these as they just contain README files
+ <module>launcher-command-line</module>
+ <module>launcher-maven</module>
+ <module>launcher-webapp</module>
+ -->
+ <module>launcher-embedded-jse</module>
+ <module>launcher-embedded-osgi</module>
+ <module>launcher-embedded-osgi-base</module>
+
+ <!-- Application samples -->
+
+ <module>store</module>
+ <module>store-webapp</module>
+
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/README b/sandbox/sebastien/java/embed/samples/store-webapp/README
new file mode 100644
index 0000000000..46e71bf51e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/README
@@ -0,0 +1,28 @@
+Store Sample
+======================================
+
+This is a sample store scenario that is used as a getting started guide
+for Tuscany SCA. For detailed information, please see:
+
+http://tuscany.apache.org/getting-started-with-tuscany.html
+
+or
+
+http://tuscany.apache.org/getting-started-with-tuscany-using-tuscany-eclipse-plugin.html
+
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+With the binary distribution the sample can be built using Ant as follows:
+
+cd store
+ant compile
+
+and then, to run:
+
+ant run
+
+Once the store application is running use your browser to visit the following
+URL:
+
+http://localhost:8080/store/
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/pom.xml b/sandbox/sebastien/java/embed/samples/store-webapp/pom.xml
new file mode 100644
index 0000000000..16dce9f922
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/pom.xml
@@ -0,0 +1,84 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-store-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Getting Started Online Store as WebApp</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ <configuration>
+ <!-- Key used for configuring access to server in settings.xml-->
+
+ <server>tomcat</server>
+ <!-- context for the webapp, as finalName is not being honored -->
+ <path>/${artifactId}</path>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Cart.java b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Cart.java
new file mode 100644
index 0000000000..3fb5439bc3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Cart.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 services;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Cart extends Collection<String, Item> {
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Catalog.java b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Catalog.java
new file mode 100644
index 0000000000..b5e504fe11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Catalog.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Catalog {
+ Item[] get();
+}
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/CurrencyConverter.java b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/CurrencyConverter.java
new file mode 100644
index 0000000000..a064f3dd69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/CurrencyConverter.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CurrencyConverter {
+ public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount);
+
+ public String getCurrencySymbol(String currencyCode);
+}
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/CurrencyConverterImpl.java b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/CurrencyConverterImpl.java
new file mode 100644
index 0000000000..c354aed447
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/CurrencyConverterImpl.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 services;
+
+public class CurrencyConverterImpl implements CurrencyConverter {
+ public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) {
+ if (toCurrencyCode.equals("USD"))
+ return amount;
+ else if (toCurrencyCode.equals("EUR"))
+ return ((double)Math.round(amount * 0.7256 * 100)) /100;
+ return 0;
+ }
+
+ public String getCurrencySymbol(String currencyCode) {
+ if (currencyCode.equals("USD"))
+ return "$";
+ else if (currencyCode.equals("EUR"))
+ return "E"; //"€";
+ return "?";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/FruitsCatalogImpl.java b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/FruitsCatalogImpl.java
new file mode 100644
index 0000000000..d132a24b00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/FruitsCatalogImpl.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 services;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+public class FruitsCatalogImpl implements Catalog {
+
+ @Property
+ public String currencyCode = "USD";
+
+ @Reference
+ public CurrencyConverter currencyConverter;
+
+ private List<Item> catalog = new ArrayList<Item>();
+
+ @Init
+ public void init() {
+ String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
+ catalog.add(new Item("Apple", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99)));
+ catalog.add(new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55)));
+ catalog.add(new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55)));
+ }
+
+ public Item[] get() {
+ Item[] catalogArray = new Item[catalog.size()];
+ catalog.toArray(catalogArray);
+ return catalogArray;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Item.java b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Item.java
new file mode 100644
index 0000000000..27abd4f016
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Item.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services;
+
+
+public class Item {
+ private String name;
+ private String price;
+
+ public Item() {
+ }
+
+ public Item(String name, String price) {
+ this.name = name;
+ this.price = price;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPrice() {
+ return price;
+ }
+
+ public void setPrice(String price) {
+ this.price = price;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/ShoppingCartImpl.java b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/ShoppingCartImpl.java
new file mode 100644
index 0000000000..698614212d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/ShoppingCartImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class ShoppingCartImpl implements Cart, Total {
+
+ private Map<String, Item> cart;
+
+ @Init
+ public void init() {
+ cart = new HashMap<String, Item>();
+ }
+
+ public Entry<String, Item>[] getAll() {
+ Entry<String, Item>[] entries = new Entry[cart.size()];
+ int i = 0;
+ for (Map.Entry<String, Item> e: cart.entrySet()) {
+ entries[i++] = new Entry<String, Item>(e.getKey(), e.getValue());
+ }
+ return entries;
+ }
+
+ public Item get(String key) throws NotFoundException {
+ Item item = cart.get(key);
+ if (item == null) {
+ throw new NotFoundException(key);
+ } else {
+ return item;
+ }
+ }
+
+ public String post(String key, Item item) {
+ if (key == null) {
+ key ="cart-" + UUID.randomUUID().toString();
+ }
+ cart.put(key, item);
+ return key;
+ }
+
+ public void put(String key, Item item) throws NotFoundException {
+ if (!cart.containsKey(key)) {
+ throw new NotFoundException(key);
+ }
+ cart.put(key, item);
+ }
+
+ public void delete(String key) throws NotFoundException {
+ if (key == null || key.equals("")) {
+ cart.clear();
+ } else {
+ Item item = cart.remove(key);
+ if (item == null)
+ throw new NotFoundException(key);
+ }
+ }
+
+ public Entry<String, Item>[] query(String queryString) {
+ List<Entry<String, Item>> entries = new ArrayList<Entry<String,Item>>();
+ if (queryString.startsWith("name=")) {
+ String name = queryString.substring(5);
+ for (Map.Entry<String, Item> e: cart.entrySet()) {
+ Item item = e.getValue();
+ if (item.getName().equals(name)) {
+ entries.add(new Entry<String, Item>(e.getKey(), e.getValue()));
+ }
+ }
+ }
+ return entries.toArray(new Entry[entries.size()]);
+ }
+
+ public String getTotal() {
+ double total = 0;
+ String currencySymbol = "";
+ if (!cart.isEmpty()) {
+ Item item = cart.values().iterator().next();
+ currencySymbol = item.getPrice().substring(0, 1);
+ }
+ for (Item item : cart.values()) {
+ total += Double.valueOf(item.getPrice().substring(1));
+ }
+ return currencySymbol + String.valueOf(total);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Total.java b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Total.java
new file mode 100644
index 0000000000..b77cc1c7ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/java/services/Total.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Total {
+
+ String getTotal();
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/resources/store.composite b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/resources/store.composite
new file mode 100644
index 0000000000..7a07b89903
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/resources/store.composite
@@ -0,0 +1,55 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://store"
+ name="store">
+
+ <component name="Store">
+ <tuscany:implementation.widget location="store.html"/>
+ <reference name="catalog" target="Catalog"/>
+ <reference name="shoppingCart" target="ShoppingCart/Cart"/>
+ <reference name="shoppingTotal" target="ShoppingCart/Total"/>
+ </component>
+
+ <component name="Catalog">
+ <implementation.java class="services.FruitsCatalogImpl"/>
+ <property name="currencyCode">USD</property>
+ <service name="Catalog">
+ <tuscany:binding.jsonrpc uri="http://localhost:8080/sample-store-webapp/Catalog"/>
+ </service>
+ <reference name="currencyConverter" target="CurrencyConverter"/>
+ </component>
+
+ <component name="ShoppingCart">
+ <implementation.java class="services.ShoppingCartImpl"/>
+ <service name="Cart">
+ <tuscany:binding.atom uri="http://localhost:8080/sample-store-webapp/ShoppingCart/Cart"/>
+ </service>
+ <service name="Total">
+ <tuscany:binding.jsonrpc uri="http://localhost:8080/sample-store-webapp/ShoppingCart/Total"/>
+ </service>
+ </component>
+
+ <component name="CurrencyConverter">
+ <implementation.java class="services.CurrencyConverterImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..cdda6bbcad
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:store="http://store">
+ <deployable composite="store:store"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
new file mode 100644
index 0000000000..b353a6e759
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
@@ -0,0 +1,50 @@
+<?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.
+-->
+<web:web-app
+ xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0"
+ xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"
+ xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"
+ xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"
+ xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-2.0"
+ xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
+ xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2"
+ xmlns:pers="http://java.sun.com/xml/ns/persistence"
+ xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1"
+ xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"
+ xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
+ <dep:environment>
+ <dep:moduleId>
+ <dep:groupId>org.apache.tuscany</dep:groupId>
+ <dep:artifactId>sample-store-webapp</dep:artifactId>
+ <dep:version>1.0</dep:version>
+ <dep:type>car</dep:type>
+ </dep:moduleId>
+
+ <!-- TUSCANY-2622 -->
+ <dep:hidden-classes>
+ <dep:filter>org.apache.axiom</dep:filter>
+ <dep:filter>org.apache.axis2</dep:filter>
+ <dep:filter>org.apache.commons</dep:filter>
+ <dep:filter>org.jdom</dep:filter>
+ </dep:hidden-classes>
+
+ </dep:environment>
+ <web:context-root>/sample-store-secure-webapp</web:context-root>
+</web:web-app>
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..bf3fe972ca
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+ <display-name>sample-store-webapp</display-name>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>store.html</welcome-file>
+ </welcome-file-list>
+</web-app> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/store.html b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/store.html
new file mode 100644
index 0000000000..7fa2e07d5a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/src/main/webapp/store.html
@@ -0,0 +1,163 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+<title>Store</title>
+
+<script type="text/javascript" src="dojo/dojo.js"></script>
+<script type="text/javascript" src="store.js"></script>
+
+<script language="JavaScript">
+
+ //@Reference
+ var catalog = new tuscany.sca.Reference("catalog");
+
+ //@Reference
+ var shoppingCart = new tuscany.sca.Reference("shoppingCart");
+
+ //@Reference
+ var shoppingTotal = new tuscany.sca.Reference("shoppingTotal");
+
+ var catalogItems;
+
+ function catalog_getResponse(items,exception) {
+ if(exception){
+ alert(exception.message);
+ return;
+ }
+ var catalog = "";
+
+ for (var i=0; i<items.length; i++) {
+ var item = items[i].name + ' - ' + items[i].price;
+ catalog += '<input name="items" type="checkbox" value="' +
+ item + '">' + item + ' <br>';
+ }
+ document.getElementById('catalog').innerHTML=catalog;
+ catalogItems = items;
+ }
+
+ function shoppingCart_getResponse(feed) {
+ if (feed != null) {
+ var entries = feed.getElementsByTagName("entry");
+ var list = "";
+ for (var i=0; i<entries.length; i++) {
+ var content = entries[i].getElementsByTagName("content")[0];
+ var name = content.getElementsByTagName("name")[0].firstChild.nodeValue;
+ var price = content.getElementsByTagName("price")[0].firstChild.nodeValue;
+ list += name + ' - ' + price + ' <br>';
+ }
+ document.getElementById("shoppingCart").innerHTML = list;
+
+ if (entries.length != 0) {
+ try {
+ shoppingTotal.getTotal().addCallback(shoppingTotal_getTotalResponse);
+ }
+ catch(e){
+ alert(e);
+ }
+ }
+ }
+ }
+
+ function shoppingTotal_getTotalResponse(total,exception) {
+ if(exception) {
+ alert(exception.message);
+ return;
+ }
+ document.getElementById('total').innerHTML = total;
+ }
+
+ function shoppingCart_postResponse(entry) {
+ shoppingCart.get("").addCallback(shoppingCart_getResponse);
+ }
+
+ function addToCart() {
+ var items = document.catalogForm.items;
+ var j = 0;
+ for (var i=0; i<items.length; i++)
+ if (items[i].checked) {
+
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title>item</title><content type="text/xml">' +
+ '<Item xmlns="http://services/">' +
+ '<name xmlns="">' + catalogItems[i].name + '</name>' + '<price xmlns="">' + catalogItems[i].price + '</price>' +
+ '</Item>' + '</content></entry>';
+ shoppingCart.post(entry).addCallback(shoppingCart_postResponse);
+ items[i].checked = false;
+ }
+ }
+ function checkoutCart() {
+ document.getElementById('store').innerHTML='<h2>' +
+ 'Thanks for Shopping With Us!</h2>'+
+ '<h2>Your Order</h2>'+
+ '<form name="orderForm">'+
+ document.getElementById('shoppingCart').innerHTML+
+ '<br>'+
+ document.getElementById('total').innerHTML+
+ '<br>'+
+ '<br>'+
+ '<input type="submit" value="Continue Shopping">'+
+ '</form>';
+ shoppingCart.del("", null);
+ }
+ function deleteCart() {
+ shoppingCart.del("");
+ document.getElementById('shoppingCart').innerHTML = "";
+ document.getElementById('total').innerHTML = "";
+ }
+
+ function init() {
+
+ try {
+ catalog.get().addCallback(catalog_getResponse);
+ shoppingCart.get("").addCallback(shoppingCart_getResponse);
+ }
+ catch(e){
+ alert(e);
+ }
+ }
+
+</script>
+
+</head>
+
+<body onload="init()">
+<h1>Store</h1>
+ <div id="store">
+ <h2>Catalog</h2>
+ <form name="catalogForm">
+ <div id="catalog" ></div>
+ <br>
+ <input type="button" onClick="addToCart()" value="Add to Cart">
+ </form>
+
+ <br>
+
+ <h2>Your Shopping Cart</h2>
+ <form name="shoppingCartForm">
+ <div id="shoppingCart"></div>
+ <br>
+ <div id="total"></div>
+ <br>
+ <input type="button" onClick="checkoutCart()" value="Checkout">
+ <input type="button" onClick="deleteCart()" value="Empty">
+ <a href="../ShoppingCart/Cart/">(feed)</a>
+ </form>
+ </div>
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/store.png b/sandbox/sebastien/java/embed/samples/store-webapp/store.png
new file mode 100644
index 0000000000..da413edeee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/store.png
Binary files differ
diff --git a/sandbox/sebastien/java/embed/samples/store-webapp/store.svg b/sandbox/sebastien/java/embed/samples/store-webapp/store.svg
new file mode 100644
index 0000000000..74f8ecd36d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store-webapp/store.svg
@@ -0,0 +1,304 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="1052.3622"
+ height="744.09448"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.45.1"
+ sodipodi:docbase="C:\simon\tuscany\java-head\sca\samples\store"
+ sodipodi:docname="store.svg"
+ version="1.0"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="C:\simon\tuscany\java-head\sca\samples\store\store.png"
+ inkscape:export-xdpi="52.84"
+ inkscape:export-ydpi="52.84">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.4"
+ inkscape:cx="538.06165"
+ inkscape:cy="341.69129"
+ inkscape:document-units="px"
+ inkscape:current-layer="g2997"
+ inkscape:window-width="1466"
+ inkscape:window-height="831"
+ inkscape:window-x="117"
+ inkscape:window-y="80" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <g
+ id="g2997">
+ <rect
+ rx="14.335117"
+ ry="17.743465"
+ y="197.1973"
+ x="447.35422"
+ height="419.39099"
+ width="464.23727"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:2.28840661;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <flowRoot
+ id="flowRoot2954"
+ xml:space="preserve"
+ transform="translate(189.90868,1.0101522)"><flowRegion
+ id="flowRegion2956"><rect
+ y="212.66591"
+ x="281.42856"
+ height="61.42857"
+ width="170"
+ id="rect2958" /></flowRegion><flowPara
+ id="flowPara2171">store</flowPara></flowRoot> <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.30182266;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2175"
+ width="118.21779"
+ height="111.27543"
+ x="491.60019"
+ y="247.75989"
+ rx="7.1507306"
+ ry="9.2311935" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2177"
+ transform="translate(223.8585,41.670449)"><flowRegion
+ id="flowRegion2179"><rect
+ id="rect2181"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2183">ufs</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 474.29877,279.45598 L 507.63381,279.45598 L 513.69472,292.58796 L 506.62366,304.7098 L 474.29877,304.7098 L 481.87492,292.58796 L 474.29877,279.45598 z "
+ id="path2187" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2191"
+ width="115.66247"
+ height="85.862968"
+ x="493.07068"
+ y="503.27759"
+ rx="6.9961648"
+ ry="7.1230249" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2193"
+ transform="translate(225.47992,297.33908)"><flowRegion
+ id="flowRegion2195"><rect
+ id="rect2197"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2199">ShoppingCart</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 475.92019,535.12461 L 509.25523,535.12461 L 515.31614,548.25659 L 508.24508,560.37843 L 475.92019,560.37843 L 483.49634,548.25659 L 475.92019,535.12461 z "
+ id="path2203" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2207"
+ width="115.66247"
+ height="85.862968"
+ x="761.44415"
+ y="391.31604"
+ rx="6.9961648"
+ ry="7.1230249" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2209"
+ transform="translate(487.8534,185.37751)"><flowRegion
+ id="flowRegion2211"><rect
+ id="rect2213"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2215">CurrencyConverter</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 744.29367,423.16304 L 777.62871,423.16304 L 783.68962,436.29502 L 776.61856,448.41686 L 744.29367,448.41686 L 751.86982,436.29502 L 744.29367,423.16304 z "
+ id="path2219" />
+ <rect
+ style="opacity:1;fill:#0064ff;fill-opacity:1;stroke:#000000;stroke-width:0.9612025;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2223"
+ width="104.08451"
+ height="113.17588"
+ x="138.37151"
+ y="350.1156"
+ rx="0"
+ ry="0.048917599" />
+ <path
+ style="fill:#1a73fe;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
+ d="M 138.21429,462.66591 L 115.35714,479.80877 L 267.85714,479.80877 L 241.78571,463.02305 L 138.21429,462.66591 z "
+ id="path3197" />
+ <rect
+ style="opacity:1;fill:#f1f4f8;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect3199"
+ width="92.5"
+ height="97.14286"
+ x="143.57143"
+ y="358.38019"
+ ry="3.6203461"
+ rx="3.9285715" />
+ <image
+ y="366.6889"
+ x="156.24066"
+ id="image3323"
+ height="78.571434"
+ width="58.57143"
+ sodipodi:absref="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png"
+ xlink:href="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png" />
+ <image
+ y="270.52304"
+ x="526.42859"
+ id="image3342"
+ height="78.571434"
+ width="58.57143"
+ sodipodi:absref="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png"
+ xlink:href="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 242.85714,374.80877 C 245.71429,374.80877 345.71429,374.80877 345.71429,374.80877 L 345.71429,291.95162 L 481.42858,291.95162"
+ id="path3348"
+ sodipodi:nodetypes="cccc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 210.71429,406.95163 L 345,406.95163 L 345,437.66591 L 481.42857,437.66591"
+ id="path3350"
+ sodipodi:nodetypes="cccc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 210.71429,439.09448 L 325.71429,439.09448 L 325.71429,548.3802 L 482.85714,548.3802"
+ id="path3352"
+ sodipodi:nodetypes="cccc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 626.42857,436.23734 C 750,437.66591 752.14286,436.23734 752.14286,436.23734"
+ id="path3354"
+ sodipodi:nodetypes="cc" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot3356"
+ transform="translate(-94.285714,25)"><flowRegion
+ id="flowRegion3358"><rect
+ id="rect3360"
+ width="142.14285"
+ height="21.428572"
+ x="655"
+ y="349.80878" /></flowRegion><flowPara
+ id="flowPara3362">CurrenyCode</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot3364"
+ transform="translate(-250.76562,-76.210859)"><flowRegion
+ id="flowRegion3366"><rect
+ id="rect3368"
+ width="142.14285"
+ height="21.428572"
+ x="655"
+ y="349.80878" /></flowRegion><flowPara
+ id="flowPara3370">HTTP</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot3372"
+ transform="translate(-273.62277,70.931998)"><flowRegion
+ id="flowRegion3374"><rect
+ id="rect3376"
+ width="142.14285"
+ height="21.428572"
+ x="655"
+ y="349.80878" /></flowRegion><flowPara
+ id="flowPara3378">JSONRPC</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot3380"
+ transform="translate(-243.62277,183.07485)"><flowRegion
+ id="flowRegion3382"><rect
+ id="rect3384"
+ width="142.14285"
+ height="21.428572"
+ x="655"
+ y="349.80878" /></flowRegion><flowPara
+ id="flowPara3386">Atom</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="85.862968"
+ x="491.56897"
+ y="392.70135"
+ rx="6.9961648"
+ ry="7.1230249" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(223.97819,186.76283)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">Catalog</flowPara></flowRoot> <rect
+ style="opacity:1;fill:#fff62c;fill-opacity:1;stroke:#060000;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect3006"
+ width="21.718224"
+ height="20.708065"
+ x="537.53094"
+ y="377.04398"
+ rx="10.859112"
+ ry="0" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 474.41846,424.54836 L 507.7535,424.54836 L 513.81441,437.68034 L 506.74335,449.80218 L 474.41846,449.80218 L 481.99461,437.68034 L 474.41846,424.54836 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 587.6709,422.71008 L 621.00594,422.71008 L 627.06685,435.84206 L 619.99579,447.9639 L 587.6709,447.9639 L 595.24705,435.84206 L 587.6709,422.71008 z "
+ id="path3019" />
+ </g>
+</svg>
diff --git a/sandbox/sebastien/java/embed/samples/store/README b/sandbox/sebastien/java/embed/samples/store/README
new file mode 100644
index 0000000000..d31e4c59b7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/README
@@ -0,0 +1,28 @@
+Store Sample
+======================================
+
+This is a sample store scenario that is used as a getting started guide
+for Tuscany SCA. For detailed information, please see:
+
+http://tuscany.apache.org/getting-started-with-tuscany.html
+
+or
+
+http://tuscany.apache.org/getting-started-with-tuscany-using-tuscany-eclipse-plugin.html
+
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+With the binary distribution the sample can be built using Ant as follows:
+
+cd store
+ant compile
+
+and then, to run:
+
+ant run
+
+Once the store application is running use your browser to visit the following
+URL:
+
+http://localhost:8080/store
diff --git a/sandbox/sebastien/java/embed/samples/store/build.xml b/sandbox/sebastien/java/embed/samples/store/build.xml
new file mode 100644
index 0000000000..bd36a0d398
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/build.xml
@@ -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.
+-->
+<project name="store" default="compile">
+ <property name="test.class" value="launch.Launch" />
+ <property name="test.jar" value="sample-store.jar" />
+
+ <target name="init">
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5">
+ <classpath>
+ <pathelement location="../../features/tuscany-sca-manifest.jar"/>
+ <fileset refid="3rdparty.jars"/>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${test.jar}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${test.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run-classes">
+ <java classname="${test.class}"
+ fork="true">
+ <classpath>
+ <pathelement path="target/classes"/>
+ <pathelement location="../../features/tuscany-sca-manifest.jar"/>
+ <fileset refid="3rdparty.jars"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run">
+ <java classname="${test.class}"
+ fork="true">
+ <classpath>
+ <pathelement path="target/${test.jar}"/>
+ <pathelement location="../../features/tuscany-sca-manifest.jar"/>
+ <fileset refid="3rdparty.jars"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="clean">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+
+ <fileset id="3rdparty.jars" dir="../../lib">
+ <include name="saxon-8.7.jar"/>
+ </fileset>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/store/pom.xml b/sandbox/sebastien/java/embed/samples/store/pom.xml
new file mode 100644
index 0000000000..6386a58525
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-store</artifactId>
+ <name>Apache Tuscany SCA Sample Getting Started Online Store</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/launch/Launch.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/launch/Launch.java
new file mode 100644
index 0000000000..8e4b5839e4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/launch/Launch.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 launch;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class Launch {
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ...");
+ String contribution = ContributionLocationHelper.getContributionLocation(Launch.class);
+ Node node = NodeFactory.newInstance().createNode("store.composite", new Contribution("test", contribution));
+ node.start();
+ System.out.println("store.composite ready for big business !!!");
+ System.in.read();
+ System.out.println("Stopping ...");
+ node.stop();
+ System.out.println();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Cart.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Cart.java
new file mode 100644
index 0000000000..3fb5439bc3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Cart.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 services;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Cart extends Collection<String, Item> {
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Catalog.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Catalog.java
new file mode 100644
index 0000000000..b5e504fe11
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Catalog.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Catalog {
+ Item[] get();
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/services/CurrencyConverter.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/CurrencyConverter.java
new file mode 100644
index 0000000000..a064f3dd69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/CurrencyConverter.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CurrencyConverter {
+ public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount);
+
+ public String getCurrencySymbol(String currencyCode);
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/services/CurrencyConverterImpl.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/CurrencyConverterImpl.java
new file mode 100644
index 0000000000..c354aed447
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/CurrencyConverterImpl.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 services;
+
+public class CurrencyConverterImpl implements CurrencyConverter {
+ public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) {
+ if (toCurrencyCode.equals("USD"))
+ return amount;
+ else if (toCurrencyCode.equals("EUR"))
+ return ((double)Math.round(amount * 0.7256 * 100)) /100;
+ return 0;
+ }
+
+ public String getCurrencySymbol(String currencyCode) {
+ if (currencyCode.equals("USD"))
+ return "$";
+ else if (currencyCode.equals("EUR"))
+ return "E"; //"€";
+ return "?";
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/services/FruitsCatalogImpl.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/FruitsCatalogImpl.java
new file mode 100644
index 0000000000..d132a24b00
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/FruitsCatalogImpl.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 services;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+public class FruitsCatalogImpl implements Catalog {
+
+ @Property
+ public String currencyCode = "USD";
+
+ @Reference
+ public CurrencyConverter currencyConverter;
+
+ private List<Item> catalog = new ArrayList<Item>();
+
+ @Init
+ public void init() {
+ String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
+ catalog.add(new Item("Apple", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99)));
+ catalog.add(new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55)));
+ catalog.add(new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55)));
+ }
+
+ public Item[] get() {
+ Item[] catalogArray = new Item[catalog.size()];
+ catalog.toArray(catalogArray);
+ return catalogArray;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Item.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Item.java
new file mode 100644
index 0000000000..fe32cfc828
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Item.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 services;
+
+public class Item {
+ private String name;
+ private String price;
+
+ public Item() {
+ }
+
+ public Item(String name, String price) {
+ this.name = name;
+ this.price = price;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPrice() {
+ return price;
+ }
+
+ public void setPrice(String price) {
+ this.price = price;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/services/ShoppingCartImpl.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/ShoppingCartImpl.java
new file mode 100644
index 0000000000..698614212d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/ShoppingCartImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class ShoppingCartImpl implements Cart, Total {
+
+ private Map<String, Item> cart;
+
+ @Init
+ public void init() {
+ cart = new HashMap<String, Item>();
+ }
+
+ public Entry<String, Item>[] getAll() {
+ Entry<String, Item>[] entries = new Entry[cart.size()];
+ int i = 0;
+ for (Map.Entry<String, Item> e: cart.entrySet()) {
+ entries[i++] = new Entry<String, Item>(e.getKey(), e.getValue());
+ }
+ return entries;
+ }
+
+ public Item get(String key) throws NotFoundException {
+ Item item = cart.get(key);
+ if (item == null) {
+ throw new NotFoundException(key);
+ } else {
+ return item;
+ }
+ }
+
+ public String post(String key, Item item) {
+ if (key == null) {
+ key ="cart-" + UUID.randomUUID().toString();
+ }
+ cart.put(key, item);
+ return key;
+ }
+
+ public void put(String key, Item item) throws NotFoundException {
+ if (!cart.containsKey(key)) {
+ throw new NotFoundException(key);
+ }
+ cart.put(key, item);
+ }
+
+ public void delete(String key) throws NotFoundException {
+ if (key == null || key.equals("")) {
+ cart.clear();
+ } else {
+ Item item = cart.remove(key);
+ if (item == null)
+ throw new NotFoundException(key);
+ }
+ }
+
+ public Entry<String, Item>[] query(String queryString) {
+ List<Entry<String, Item>> entries = new ArrayList<Entry<String,Item>>();
+ if (queryString.startsWith("name=")) {
+ String name = queryString.substring(5);
+ for (Map.Entry<String, Item> e: cart.entrySet()) {
+ Item item = e.getValue();
+ if (item.getName().equals(name)) {
+ entries.add(new Entry<String, Item>(e.getKey(), e.getValue()));
+ }
+ }
+ }
+ return entries.toArray(new Entry[entries.size()]);
+ }
+
+ public String getTotal() {
+ double total = 0;
+ String currencySymbol = "";
+ if (!cart.isEmpty()) {
+ Item item = cart.values().iterator().next();
+ currencySymbol = item.getPrice().substring(0, 1);
+ }
+ for (Item item : cart.values()) {
+ total += Double.valueOf(item.getPrice().substring(1));
+ }
+ return currencySymbol + String.valueOf(total);
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Total.java b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Total.java
new file mode 100644
index 0000000000..b77cc1c7ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/java/services/Total.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Total {
+
+ String getTotal();
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/resources/store.composite b/sandbox/sebastien/java/embed/samples/store/src/main/resources/store.composite
new file mode 100644
index 0000000000..9c3b79c508
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/resources/store.composite
@@ -0,0 +1,58 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://store"
+ name="store">
+
+ <component name="Store">
+ <tuscany:implementation.widget location="uiservices/store.html"/>
+ <service name="Widget">
+ <tuscany:binding.http uri="/store"/>
+ </service>
+ <reference name="catalog" target="Catalog"/>
+ <reference name="shoppingCart" target="ShoppingCart/Cart"/>
+ <reference name="shoppingTotal" target="ShoppingCart/Total"/>
+ </component>
+
+ <component name="Catalog">
+ <implementation.java class="services.FruitsCatalogImpl"/>
+ <property name="currencyCode">USD</property>
+ <service name="Catalog">
+ <tuscany:binding.jsonrpc uri="/Catalog"/>
+ </service>
+ <reference name="currencyConverter" target="CurrencyConverter"/>
+ </component>
+
+ <component name="ShoppingCart">
+ <implementation.java class="services.ShoppingCartImpl"/>
+ <service name="Cart">
+ <tuscany:binding.atom uri="/ShoppingCart/Cart"/>
+ </service>
+ <service name="Total">
+ <tuscany:binding.jsonrpc uri="/ShoppingCart/Total"/>
+ </service>
+ </component>
+
+ <component name="CurrencyConverter">
+ <implementation.java class="services.CurrencyConverterImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/store/src/main/resources/uiservices/store.html b/sandbox/sebastien/java/embed/samples/store/src/main/resources/uiservices/store.html
new file mode 100644
index 0000000000..000f1f891f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/main/resources/uiservices/store.html
@@ -0,0 +1,162 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+<title>Store</title>
+
+<script type="text/javascript" src="/dojo/dojo.js"></script>
+<script type="text/javascript" src="store.js"></script>
+
+<script language="JavaScript">
+
+ //@Reference
+ var catalog = new tuscany.sca.Reference("catalog");
+
+ //@Reference
+ var shoppingCart = new tuscany.sca.Reference("shoppingCart");
+
+ //@Reference
+ var shoppingTotal = new tuscany.sca.Reference("shoppingTotal");
+
+ var catalogItems;
+
+ function catalog_getResponse(items,exception) {
+ if(exception){
+ alert(exception.message);
+ return;
+ }
+ var catalog = "";
+
+ for (var i=0; i<items.length; i++) {
+ var item = items[i].name + ' - ' + items[i].price;
+ catalog += '<input name="items" type="checkbox" value="' +
+ item + '">' + item + ' <br>';
+ }
+ document.getElementById('catalog').innerHTML=catalog;
+ catalogItems = items;
+ }
+
+ function shoppingCart_getResponse(feed) {
+ if (feed != null) {
+ var entries = feed.getElementsByTagName("entry");
+ var list = "";
+ for (var i=0; i<entries.length; i++) {
+ var content = entries[i].getElementsByTagName("content")[0];
+ var name = content.getElementsByTagName("name")[0].firstChild.nodeValue;
+ var price = content.getElementsByTagName("price")[0].firstChild.nodeValue;
+ list += name + ' - ' + price + ' <br>';
+ }
+ document.getElementById("shoppingCart").innerHTML = list;
+
+ if (entries.length != 0) {
+ try {
+ shoppingTotal.getTotal().addCallback(shoppingTotal_getTotalResponse);
+ }
+ catch(e){
+ alert(e);
+ }
+ }
+ }
+ }
+
+ function shoppingTotal_getTotalResponse(total,exception) {
+ if(exception) {
+ alert(exception.message);
+ return;
+ }
+ document.getElementById('total').innerHTML = total;
+ }
+
+ function shoppingCart_postResponse(entry) {
+ shoppingCart.get("").addCallback(shoppingCart_getResponse);
+ }
+
+ function addToCart() {
+ var items = document.catalogForm.items;
+ var j = 0;
+ for (var i=0; i<items.length; i++) {
+ if (items[i].checked) {
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title>item</title><content type="text/xml">' +
+ '<Item xmlns="http://services/">' +
+ '<name xmlns="">' + catalogItems[i].name + '</name>' + '<price xmlns="">' + catalogItems[i].price + '</price>' +
+ '</Item>' + '</content></entry>';
+ shoppingCart.post(entry).addCallback(shoppingCart_postResponse);
+ items[i].checked = false;
+ }
+ }
+ }
+ function checkoutCart() {
+ document.getElementById('store').innerHTML='<h2>' +
+ 'Thanks for Shopping With Us!</h2>'+
+ '<h2>Your Order</h2>'+
+ '<form name="orderForm">'+
+ document.getElementById('shoppingCart').innerHTML+
+ '<br>'+
+ document.getElementById('total').innerHTML+
+ '<br>'+
+ '<br>'+
+ '<input type="submit" value="Continue Shopping">'+
+ '</form>';
+ shoppingCart.del("");
+ }
+ function deleteCart() {
+ shoppingCart.del("");
+ document.getElementById('shoppingCart').innerHTML = "";
+ document.getElementById('total').innerHTML = "";
+ }
+
+ function init() {
+ try {
+ catalog.get().addCallback(catalog_getResponse);
+ shoppingCart.get("").addCallback(shoppingCart_getResponse);
+ }
+ catch(e){
+ alert(e);
+ }
+ }
+
+</script>
+
+</head>
+
+<body onload="init()">
+<h1>Store</h1>
+ <div id="store">
+ <h2>Catalog</h2>
+ <form name="catalogForm">
+ <div id="catalog" ></div>
+ <br>
+ <input type="button" onClick="addToCart()" value="Add to Cart">
+ </form>
+
+ <br>
+
+ <h2>Your Shopping Cart</h2>
+ <form name="shoppingCartForm">
+ <div id="shoppingCart"></div>
+ <br>
+ <div id="total"></div>
+ <br>
+ <input type="button" onClick="checkoutCart()" value="Checkout">
+ <input type="button" onClick="deleteCart()" value="Empty">
+ <a href="../ShoppingCart/Cart/">(feed)</a>
+ </form>
+ </div>
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/store/src/test/java/client/Shopper.java b/sandbox/sebastien/java/embed/samples/store/src/test/java/client/Shopper.java
new file mode 100644
index 0000000000..4e2fa63493
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/test/java/client/Shopper.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 client;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Shopper {
+
+ String shop(String itemName, int quantity);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/test/java/client/ShopperImpl.java b/sandbox/sebastien/java/embed/samples/store/src/test/java/client/ShopperImpl.java
new file mode 100644
index 0000000000..05b1800d4f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/test/java/client/ShopperImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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 client;
+
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Reference;
+
+import services.Cart;
+import services.Catalog;
+import services.Item;
+import services.Total;
+
+public class ShopperImpl implements Shopper {
+
+ @Reference
+ public Catalog catalog;
+
+ @Reference
+ public Cart shoppingCart;
+
+ @Reference
+ public Total shoppingTotal;
+
+ public String shop(String itemName, int quantity) {
+
+ Item[] items = catalog.get();
+ for (Item item: items) {
+ if (item.getName().startsWith(itemName)) {
+
+ try {
+ shoppingCart.delete("");
+ } catch (NotFoundException e) {
+ // ignore
+ }
+
+ for (int i = 0; i < quantity; i++) {
+ shoppingCart.post("item" + i, item);
+ }
+
+ return shoppingTotal.getTotal();
+ }
+ }
+
+ return "";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/test/java/store/StoreTestCase.java b/sandbox/sebastien/java/embed/samples/store/src/test/java/store/StoreTestCase.java
new file mode 100644
index 0000000000..883aaa76f6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/test/java/store/StoreTestCase.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 store;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import client.Shopper;
+
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+
+/**
+ * Test the store-merger.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StoreTestCase {
+ private static Node nodeStore;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ String storeLocation = ContributionLocationHelper.getContributionLocation("store.composite");
+ String storeClientLocation = ContributionLocationHelper.getContributionLocation("store-client.composite");
+
+ nodeStore = NodeFactory.newInstance().createNode(new Contribution("store", storeLocation), new Contribution("storeClient", storeClientLocation));
+ nodeStore.start();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ nodeStore.stop();
+ }
+
+ @Test
+ @Ignore
+ public void testWaitForInput() {
+ try {
+ System.out.println("press enter to continue)");
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testShop() {
+ Shopper shopper = nodeStore.getService(Shopper.class, "StoreClient");
+
+ String total = shopper.shop("Orange", 5);
+ System.out.println("Total: " + total);
+
+ Assert.assertEquals("$17.75", total);
+
+ }
+
+ @Test
+ public void testStoreWidget() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
+ WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3);
+ webClient.setRedirectEnabled(true);
+ webClient.setThrowExceptionOnScriptError(false);
+ //webClient.waitForBackgroundJavaScript(100000);
+ //webClient.waitForBackgroundJavaScriptStartingBefore(100000);
+ webClient.setAjaxController(new NicelyResynchronizingAjaxController());
+
+ HtmlPage page = (HtmlPage) webClient.getPage("http://localhost:8080/store/store.html");
+
+ HtmlForm form = (HtmlForm) page.getFormByName("catalogForm");
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+
+ HtmlCheckBoxInput catalogItems = (HtmlCheckBoxInput) form.getInputByName("items");
+
+ System.out.println(">>>" + catalogItems.getAttribute("value"));
+ Assert.assertEquals("Apple - $2.99", catalogItems.getAttribute("value"));
+
+ webClient.closeAllWindows();
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/store/src/test/resources/store-client.composite b/sandbox/sebastien/java/embed/samples/store/src/test/resources/store-client.composite
new file mode 100644
index 0000000000..c9abe8e996
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/src/test/resources/store-client.composite
@@ -0,0 +1,38 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://store"
+ name="store-client">
+
+ <component name="StoreClient">
+ <implementation.java class="client.ShopperImpl"/>
+ <reference name="catalog">
+ <tuscany:binding.jsonrpc uri="http://localhost:8080/Catalog"/>
+ </reference>
+ <reference name="shoppingCart">
+ <tuscany:binding.atom uri="http://localhost:8080/ShoppingCart/Cart"/>
+ </reference>
+ <reference name="shoppingTotal">
+ <tuscany:binding.jsonrpc uri="http://localhost:8080/ShoppingCart/Total"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/store/store.png b/sandbox/sebastien/java/embed/samples/store/store.png
new file mode 100644
index 0000000000..da413edeee
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/store.png
Binary files differ
diff --git a/sandbox/sebastien/java/embed/samples/store/store.svg b/sandbox/sebastien/java/embed/samples/store/store.svg
new file mode 100644
index 0000000000..74f8ecd36d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/store/store.svg
@@ -0,0 +1,304 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="1052.3622"
+ height="744.09448"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.45.1"
+ sodipodi:docbase="C:\simon\tuscany\java-head\sca\samples\store"
+ sodipodi:docname="store.svg"
+ version="1.0"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="C:\simon\tuscany\java-head\sca\samples\store\store.png"
+ inkscape:export-xdpi="52.84"
+ inkscape:export-ydpi="52.84">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.4"
+ inkscape:cx="538.06165"
+ inkscape:cy="341.69129"
+ inkscape:document-units="px"
+ inkscape:current-layer="g2997"
+ inkscape:window-width="1466"
+ inkscape:window-height="831"
+ inkscape:window-x="117"
+ inkscape:window-y="80" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <g
+ id="g2997">
+ <rect
+ rx="14.335117"
+ ry="17.743465"
+ y="197.1973"
+ x="447.35422"
+ height="419.39099"
+ width="464.23727"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:2.28840661;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <flowRoot
+ id="flowRoot2954"
+ xml:space="preserve"
+ transform="translate(189.90868,1.0101522)"><flowRegion
+ id="flowRegion2956"><rect
+ y="212.66591"
+ x="281.42856"
+ height="61.42857"
+ width="170"
+ id="rect2958" /></flowRegion><flowPara
+ id="flowPara2171">store</flowPara></flowRoot> <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.30182266;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2175"
+ width="118.21779"
+ height="111.27543"
+ x="491.60019"
+ y="247.75989"
+ rx="7.1507306"
+ ry="9.2311935" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2177"
+ transform="translate(223.8585,41.670449)"><flowRegion
+ id="flowRegion2179"><rect
+ id="rect2181"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2183">ufs</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 474.29877,279.45598 L 507.63381,279.45598 L 513.69472,292.58796 L 506.62366,304.7098 L 474.29877,304.7098 L 481.87492,292.58796 L 474.29877,279.45598 z "
+ id="path2187" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2191"
+ width="115.66247"
+ height="85.862968"
+ x="493.07068"
+ y="503.27759"
+ rx="6.9961648"
+ ry="7.1230249" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2193"
+ transform="translate(225.47992,297.33908)"><flowRegion
+ id="flowRegion2195"><rect
+ id="rect2197"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2199">ShoppingCart</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 475.92019,535.12461 L 509.25523,535.12461 L 515.31614,548.25659 L 508.24508,560.37843 L 475.92019,560.37843 L 483.49634,548.25659 L 475.92019,535.12461 z "
+ id="path2203" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2207"
+ width="115.66247"
+ height="85.862968"
+ x="761.44415"
+ y="391.31604"
+ rx="6.9961648"
+ ry="7.1230249" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2209"
+ transform="translate(487.8534,185.37751)"><flowRegion
+ id="flowRegion2211"><rect
+ id="rect2213"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2215">CurrencyConverter</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 744.29367,423.16304 L 777.62871,423.16304 L 783.68962,436.29502 L 776.61856,448.41686 L 744.29367,448.41686 L 751.86982,436.29502 L 744.29367,423.16304 z "
+ id="path2219" />
+ <rect
+ style="opacity:1;fill:#0064ff;fill-opacity:1;stroke:#000000;stroke-width:0.9612025;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2223"
+ width="104.08451"
+ height="113.17588"
+ x="138.37151"
+ y="350.1156"
+ rx="0"
+ ry="0.048917599" />
+ <path
+ style="fill:#1a73fe;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
+ d="M 138.21429,462.66591 L 115.35714,479.80877 L 267.85714,479.80877 L 241.78571,463.02305 L 138.21429,462.66591 z "
+ id="path3197" />
+ <rect
+ style="opacity:1;fill:#f1f4f8;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect3199"
+ width="92.5"
+ height="97.14286"
+ x="143.57143"
+ y="358.38019"
+ ry="3.6203461"
+ rx="3.9285715" />
+ <image
+ y="366.6889"
+ x="156.24066"
+ id="image3323"
+ height="78.571434"
+ width="58.57143"
+ sodipodi:absref="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png"
+ xlink:href="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png" />
+ <image
+ y="270.52304"
+ x="526.42859"
+ id="image3342"
+ height="78.571434"
+ width="58.57143"
+ sodipodi:absref="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png"
+ xlink:href="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 242.85714,374.80877 C 245.71429,374.80877 345.71429,374.80877 345.71429,374.80877 L 345.71429,291.95162 L 481.42858,291.95162"
+ id="path3348"
+ sodipodi:nodetypes="cccc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 210.71429,406.95163 L 345,406.95163 L 345,437.66591 L 481.42857,437.66591"
+ id="path3350"
+ sodipodi:nodetypes="cccc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 210.71429,439.09448 L 325.71429,439.09448 L 325.71429,548.3802 L 482.85714,548.3802"
+ id="path3352"
+ sodipodi:nodetypes="cccc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 626.42857,436.23734 C 750,437.66591 752.14286,436.23734 752.14286,436.23734"
+ id="path3354"
+ sodipodi:nodetypes="cc" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot3356"
+ transform="translate(-94.285714,25)"><flowRegion
+ id="flowRegion3358"><rect
+ id="rect3360"
+ width="142.14285"
+ height="21.428572"
+ x="655"
+ y="349.80878" /></flowRegion><flowPara
+ id="flowPara3362">CurrenyCode</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot3364"
+ transform="translate(-250.76562,-76.210859)"><flowRegion
+ id="flowRegion3366"><rect
+ id="rect3368"
+ width="142.14285"
+ height="21.428572"
+ x="655"
+ y="349.80878" /></flowRegion><flowPara
+ id="flowPara3370">HTTP</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot3372"
+ transform="translate(-273.62277,70.931998)"><flowRegion
+ id="flowRegion3374"><rect
+ id="rect3376"
+ width="142.14285"
+ height="21.428572"
+ x="655"
+ y="349.80878" /></flowRegion><flowPara
+ id="flowPara3378">JSONRPC</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot3380"
+ transform="translate(-243.62277,183.07485)"><flowRegion
+ id="flowRegion3382"><rect
+ id="rect3384"
+ width="142.14285"
+ height="21.428572"
+ x="655"
+ y="349.80878" /></flowRegion><flowPara
+ id="flowPara3386">Atom</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="85.862968"
+ x="491.56897"
+ y="392.70135"
+ rx="6.9961648"
+ ry="7.1230249" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(223.97819,186.76283)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">Catalog</flowPara></flowRoot> <rect
+ style="opacity:1;fill:#fff62c;fill-opacity:1;stroke:#060000;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect3006"
+ width="21.718224"
+ height="20.708065"
+ x="537.53094"
+ y="377.04398"
+ rx="10.859112"
+ ry="0" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 474.41846,424.54836 L 507.7535,424.54836 L 513.81441,437.68034 L 506.74335,449.80218 L 474.41846,449.80218 L 481.99461,437.68034 L 474.41846,424.54836 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 587.6709,422.71008 L 621.00594,422.71008 L 627.06685,435.84206 L 619.99579,447.9639 L 587.6709,447.9639 L 595.24705,435.84206 L 587.6709,422.71008 z "
+ id="path3019" />
+ </g>
+</svg>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/README b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/README
new file mode 100644
index 0000000000..828aadb0f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/README
@@ -0,0 +1,7 @@
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/pom.xml
new file mode 100644
index 0000000000..1ca3770b74
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/pom.xml
@@ -0,0 +1,160 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-bpel-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld BPEL</name>
+
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ <jetty.version>6.1.18</jetty.version>
+ </properties>
+
+ <dependencies>
+ <!-- TUSCANY DEPENDENCIES -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- JUNIT DEPENDENCY FOR TESTING -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- JETTY DEPENDENCIES FOR TESTING -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-management</artifactId>
+ <version>${jetty.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-bpel</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby</artifactId>
+ <version>1.1.1</version>
+ <type>zip</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}/classes</outputDirectory>
+ <includes>**/*</includes>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld-bpel</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/java/sample/HelloworldService.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..c1a50d9be5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/java/sample/HelloworldService.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloworldService {
+
+ String hello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/resources/helloworld.bpel b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/resources/helloworld.bpel
new file mode 100644
index 0000000000..f1e8895f76
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/resources/helloworld.bpel
@@ -0,0 +1,66 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<process name="HelloWorld"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+ expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+ <import location="helloworld.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"
+ namespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"/>
+
+ <partnerLinks>
+ <partnerLink name="helloPartnerLink" partnerLinkType="test:HelloPartnerLinkType" myRole="me" />
+ </partnerLinks>
+
+ <variables>
+ <variable name="myVar" messageType="test:HelloMessage"/>
+ <variable name="tmpVar" type="xsd:string"/>
+ </variables>
+
+ <sequence>
+ <receive
+ name="start"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="myVar"
+ createInstance="yes"/>
+
+ <assign name="assign1">
+ <copy>
+ <from>concat('Hello ', $myVar.TestPart/test:message/text())</from>
+ <to variable="tmpVar"/>
+ </copy>
+ <copy>
+ <from>$tmpVar</from>
+ <to>$myVar.TestPart/test:message</to>
+ </copy>
+ </assign>
+ <reply name="end"
+ partnerLink="helloPartnerLink"
+ portType="test:HelloPortType"
+ operation="hello"
+ variable="myVar"/>
+ </sequence>
+</process>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/resources/helloworld.wsdl b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..46cf381577
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/resources/helloworld.wsdl
@@ -0,0 +1,82 @@
+<?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://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="message" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="HelloMessage">
+ <wsdl:part element="tns:hello" name="TestPart"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloPortType">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+ <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="hello">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="TestIn">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="TestOut">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8085/ode/processes/helloWorld"/>
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..3d36adadeb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:hns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ targetNamespace="http://sample"
+ name="helloworld-bpel">
+
+ <component name="WebComponent">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent">
+ <interface.java interface="sample.HelloworldService"/>
+ </reference>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.bpel process="hns:HelloWorld"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..bf01a7b759
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+<web-app 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>helloworld-bpel</display-name>
+
+ <filter>
+ <filter-name>tuscany.helloworld-bpel</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany.helloworld-bpel</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/hello.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..c52d7b1cb2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-bpel/src/main/webapp/hello.jsp
@@ -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.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="sample.HelloworldService" />
+
+<html>
+ <body >
+
+ <h2>helloworld-bpel</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.hello("world") %>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/README b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/README
new file mode 100644
index 0000000000..828aadb0f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/README
@@ -0,0 +1,7 @@
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/pom.xml
new file mode 100644
index 0000000000..f414d87837
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/pom.xml
@@ -0,0 +1,116 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-jaxrs-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld JAX-RS</name>
+
+ <dependencies>
+
+ <!-- Tuscany dependency -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base-nodep</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Wink dependency for JAX-RS support -->
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-common</artifactId>
+ <version>1.1.1-incubating</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-server</artifactId>
+ <version>1.1.1-incubating</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-jaxrs</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld-jaxrs</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java
new file mode 100644
index 0000000000..42625b8a78
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.util.Date;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * Simple example - Hello World!
+ * <p/>
+ * The SDK dispatches HTTP requests for URI
+ * <code>http://[host]:[port]/helloworld-jaxrs/rest/world</code>, where
+ * <code>helloworld-jaxrs</code> is the context root, to this class. A simple
+ * plain text entry is returned in HTTP response.
+ * <p/>
+ * The service document is available at URI
+ * <code>http://[host]:[port]/helloworld-jaxrs/rest</code> but it is empty because
+ * this simple demo doesn't contain any collection of resources.
+ * <p/>
+ * This resource must be registered within a JAX-RS application, this example
+ * uses the default usage of application /WEB-INF/application
+ */
+@Path("/world")
+public class HelloWorldResource {
+
+ @Reference
+ protected HelloworldService service;
+
+
+ /**
+ * This method is called by the SDK for HTTP GET method requests where the
+ * Accept header allows the Atom media type application/atom+xml. A
+ * SyndEntry is created with basic information. Serialization of the
+ * SyndEntry to Atom entry is performed by the SDK automatically. The
+ * default status code of 200 (OK) is returned in the response.
+ *
+ * @return SyndEntry of the requested resource
+ */
+ @GET
+ @Produces("text/plain")
+ public String getClichedMessage() {
+ return service == null ? "SCA reference not injected" : service.sayHello("World");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloworldService.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..123774b936
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/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 sample;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..66cef71a25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloworldServiceImpl.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;
+
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/application b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/application
new file mode 100644
index 0000000000..8ce781d6c8
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/application
@@ -0,0 +1,14 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version
+# 2.0 (the "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+# applicable law or agreed to in writing, software distributed under the
+# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+# CONDITIONS OF ANY KIND, either express or implied. See the License for
+# the specific language governing permissions and limitations under the
+# License.
+sample.HelloWorldResource \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..7ff71519e9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="HelloworldJAXRSComponent">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..3c5726a818
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,49 @@
+<?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.
+-->
+<web-app 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>Apache Tuscany Helloworld JAX-RS Sample</display-name>
+
+ <!-- Listener to start the Tuscany webapp embedded runtime -->
+ <listener><listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class></listener>
+
+ <!-- Apache Wink JAX-RS Servlet -->
+ <servlet>
+ <servlet-name>restSdkService</servlet-name>
+ <servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
+ <init-param>
+ <param-name>applicationConfigLocation</param-name>
+ <param-value>/WEB-INF/application</param-value>
+ </init-param>
+ <init-param>
+ <!-- Custom init param to tell Wink to use Tuscany -->
+ <param-name>deploymentConfiguration</param-name>
+ <param-value>org.apache.tuscany.sca.wink.TuscanyDeploymentConfiguration</param-value>
+ </init-param>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>restSdkService</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..50197cdfcb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.TextPage;
+import com.gargoylesoftware.htmlunit.WebClient;
+
+/**
+ */
+public class HelloworldTestCase {
+
+ @Test
+ public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
+ TextPage page = (TextPage)new WebClient().getPage("http://localhost:8085/helloworld-jaxrs/rest/world");
+ assertEquals("Hello World", page.getContent());
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/README b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/README
new file mode 100644
index 0000000000..88bbe9adcb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/README
@@ -0,0 +1,131 @@
+JMS HelloWorld Sample
+=====================
+This sample demonstrates a simple webapp containing a hello world style client
+and service using the JMS binding for request-response style messaging.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+As this sample provides a web app there is a manual step where the WAR file
+that contains the sample is copied to your web app container. If you just want
+to give this sample a go deploy the WAR file (target/helloworld-jms.war )
+to you web application server. Alternatevly, the sample pom.xml is configured
+with the Jetty plugin so you can run the it with Jetty by simply doing "mvn jetty:run".
+
+Once the web app is deployed use your browser to visit the following URL;
+
+http://localhost:8080/helloworld-jms
+
+The port and hostname will of course vary depending on your local installation.
+
+Configuring the JMS resources
+-----------------------------
+
+The sample requires JMS resources be manually configured in the server environment, these are:
+
+- a JMS connection factory named "ConnectionFactory"
+- a JMS queue named "HelloWorldService"
+
+See the following for how to define these resources depending on the application server being used:
+
+Tuscany with embedded ActiveMQ broker
+-------------------------------------
+
+
+Apache Tomcat
+-------------
+
+No configuration is necessary for Tomcat as the sample WAR includes everything pre-configured to run
+an ActiveMQ embedded JMS broker and to configure the JMS resources in JNDI.
+
+The JNDI resources are configured in the META-INF/comtext.xml file, for more information on running
+ActiveMQ in Tomcat see: http://activemq.apache.org/tomcat.html
+
+
+Apache Geronimo
+---------------
+
+For Apache Geronimo 2.0.1 (2.0.2 fails to define JMS resources for me)
+
+Logon to the Geronimo Server Console (http://localhost:8080/console, uid system, pswd manager)
+
+In the Console Navigation on the left under Services click JMS Resources
+
+At the bottom of the JMS Resources panel click under Create a new JMS Resource Group click For ActiveMQ
+
+In Resource Group Name enter "MyRGN" and click next
+
+At JMS Resource Group click Add Connection Factory
+
+For JMS Factory Type choose javax.jms.ConnectionFactory and click Next
+
+In Connection Factory Name enter "ConnectionFactory" and click Next
+
+Click Add destination
+
+For JMS Destination Type choose javax.jms.Queue and click Next
+
+Enter "HelloWorldService" for both Message Destination Name and PhysicalName and click Next
+
+Click Deploy Now
+
+Thats it, you're done.
+
+
+WebSphere
+---------
+
+To define the JMS resources in a new WebSphere Application Server 6.1 installation:
+
+1) First define a Service integration bus:
+
+Logon to the WebSphere Integrated Solutions Console (http://localhost:9060/ibm/console)
+
+On the Left hand menu expand Service integration, and click on Buses.
+
+In the Buses panel click on New
+
+Enter a name for the bus, eg MyBus, and click Next, and then click Finish and Save the changes.
+
+In the Buses panel click on MyBus
+
+Find the Topology secion and click on Bus members
+
+Click on Add, leave the defaults and click Next, Next, Next, Finish, and Save the changes.
+
+Restart WebSphere and when back up logon back on to the Integrated Solutions Console
+
+2) Now define the JMS rescources
+
+On the Left hand menu expand Resources, and JMS and click on Connection Facotories.
+
+In the Connection factories panel click New.
+
+Leave the Default messaging provider and click OK
+
+Enter "ConnectionFactory" in the Name and JNDI name and in the Bus name in the Connection pane choose MyBus and click OK
+
+On the Left hand menu in JMS click on Queues
+
+In the Queues panel click New, accept the defaults and click OK
+
+Enter "HelloWorldService" for the Name and JNDI name and in the Bus name in the Connection pane choose MyBus,
+and then in the Queue name drop down list choose "Create SIB destination"
+
+In the Set queue attributes panel enter "HelloWorldService" for the Identifier and click Next, Next, and Finish
+
+That should take you back to the Queues panel where you can click OK to create the new JMS queue.
+
+Save the changes
+
+Restart WebSphere and you're done.
+
+
+
+Others...
+---------
+
+
+
+ \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/pom.xml
new file mode 100644
index 0000000000..326422ed7b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/pom.xml
@@ -0,0 +1,96 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-jms-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample JMS HelloWorld in a WebApp</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-jms</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.3.0</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-jms</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld-jms</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldClient.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldClient.java
new file mode 100644
index 0000000000..f209f11605
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldClient.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 sample;
+
+/**
+ * The HelloWorld client implementation
+ */
+public class HelloWorldClient implements HelloWorldService {
+
+ HelloWorldService helloWorldRef;
+
+ public String sayHello(String name) {
+ System.out.println("HelloWorldClient.sayHello " + name);
+ return helloWorldRef.sayHello(name);
+ }
+
+ public void setHelloWorldRef(HelloWorldService helloWorldRef) {
+ System.out.println("HelloWorldClient.setHelloWorldService " + helloWorldRef);
+ this.helloWorldRef = helloWorldRef;
+ }
+} \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldService.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldService.java
new file mode 100644
index 0000000000..df2a852161
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The interface for the helloworld service
+ */
+@Remotable
+public interface HelloWorldService {
+ public String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldServiceImpl.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..c09af51e23
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldServiceImpl.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 sample;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ System.out.println("HelloWorldServiceImpl.sayHello " + name);
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/META-INF/context.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/META-INF/context.xml
new file mode 100644
index 0000000000..7575edfc29
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/META-INF/context.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+
+<!--
+This file configures the ActiveMQ JMS resources and is only required when
+using Apache ActiveMQ as the JMS broker in Apache Tomcat.
+-->
+
+<Context>
+
+ <Resource name="ConnectionFactory" auth="Container" type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory"
+ factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="vm://localhost?broker.persistent=false" brokerName="LocalActiveMQBroker"/>
+
+ <Resource name="HelloWorldService" auth="Container" type="org.apache.activemq.command.ActiveMQQueue" description="my Queue"
+ factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="RequestQueue"/>
+
+</Context> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/jetty-env.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/jetty-env.xml
new file mode 100644
index 0000000000..a8cd27f6c6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/jetty-env.xml
@@ -0,0 +1,48 @@
+<?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.
+-->
+
+<!--
+This file configures the ActiveMQ JMS resources and is only required when
+using Apache ActiveMQ as the JMS broker in Jetty.
+-->
+
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
+
+<Configure class="org.mortbay.jetty.webapp.WebAppContext">
+
+ <New id="cf" class="org.mortbay.jetty.plus.naming.Resource">
+ <Arg>ConnectionFactory</Arg>
+ <Arg>
+ <New class="org.apache.activemq.ActiveMQConnectionFactory">
+ <Arg>vm://localhost?broker.persistent=false</Arg>
+ </New>
+ </Arg>
+ </New>
+
+ <New id="myQueue" class="org.mortbay.jetty.plus.naming.Resource">
+ <Arg>HelloWorldService</Arg>
+ <Arg>
+ <New class="org.apache.activemq.command.ActiveMQQueue">
+ <Arg>DEMO</Arg>
+ </New>
+ </Arg>
+ </New>
+
+</Configure>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..c51985bc30
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="foo">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloWorldClientComponent"/>
+ </component>
+
+ <component name="HelloWorldClientComponent">
+ <implementation.java class="sample.HelloWorldClient"/>
+ <reference name="helloWorldRef">
+ <binding.jms uri="jms:HelloWorldService"/>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="sample.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <binding.jms />
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..86710435ae
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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>Apache Tuscany JMS Web Service Sample</display-name>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.jsp</welcome-file>
+ </welcome-file-list>
+
+ <!-- Uncomment this to use an appserver thread pool
+ <resource-ref>
+ <res-ref-name>wm/TuscanyWorkManager</res-ref-name>
+ <res-type>commonj.work.WorkManager</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+ -->
+
+ <!-- Uncomment these to use local jndi name aliases
+ <resource-ref>
+ <res-ref-name>ConnectionFactory</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+
+ <resource-ref>
+ <res-ref-name>HelloWorldService</res-ref-name>
+ <res-type>javax.jms.Queue</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+ -->
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/hello.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..9ae037f2c2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jms/src/main/webapp/hello.jsp
@@ -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.
+--%>
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="sample.HelloWorldService" />
+
+<html>
+<head><title>HelloWorld JMS sample</title></head>
+
+<body>
+
+If this sample is working correctly you should see "Hello World" on the next line...
+<p>
+<%= service.sayHello("world") %>
+<p>
+If you do not see "Hello World" on the line above then there has been a problem.
+<p>
+The sample requires JMS resources be manually configured in the server environment, these are:
+a JMS connection factory named "ConnectionFactory", and a destination queues named "HelloWorldService".
+See the sample README file for more information.
+
+</body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/README b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/README
new file mode 100644
index 0000000000..828aadb0f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/README
@@ -0,0 +1,7 @@
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/pom.xml
new file mode 100644
index 0000000000..388df0913e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/pom.xml
@@ -0,0 +1,104 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-js-client-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld Javascript Client</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-json-nodep</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-js-client</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld-js-client</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldService.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..123774b936
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/java/sample/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 sample;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..66cef71a25
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldServiceImpl.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;
+
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..d41a8535e2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,36 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="foo">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent">
+ <interface.java interface="sample.HelloworldService" />
+ </reference>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..babeb7b203
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+<web-app 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>Apache Tuscany Helloworld JSP Sample</display-name>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/hello.html b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/hello.html
new file mode 100644
index 0000000000..12024cc4d3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/main/webapp/hello.html
@@ -0,0 +1,51 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+
+<head>
+ <title>Apache Tuscany Helloworld Javascript Client Sample</title>
+
+ <script type="text/javascript" src="org.oasisopen.sca.componentContext.js"></script>
+
+ <script language="JavaScript">
+
+ function callSayHello() {
+ componentContext.getService("service").sayHello(document.getElementById('name').value, sayHelloResponse);
+ }
+
+ function sayHelloResponse(reply) {
+ document.getElementById('result').innerHTML=reply;
+ }
+
+ </script>
+
+</head>
+
+<body>
+
+<h2>Apache Tuscany Helloworld Javascript Client Sample</h2>
+
+ <input type="text" id="name" width="10">
+
+ <button name="submit" onclick="callSayHello()">Say hello</button>
+
+ <div id='result'></div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/test/java/itest/HelloworldTestCase.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..099b442050
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-js-client/src/test/java/itest/HelloworldTestCase.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 itest;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+
+import org.junit.Test;
+
+/**
+ * Verfiy the serverside code is working, not sure how to easily itest the browser javascript code
+ */
+public class HelloworldTestCase {
+
+ @Test
+ public void testA() throws MalformedURLException, IOException {
+
+ URL url = new URL("http://localhost:8085/helloworld-js-client/org.oasisopen.sca.componentContext.js/foo/call/plaincall/service.sayHello.dwr");
+ URLConnection conn = url.openConnection();
+ conn.setDoOutput(true);
+ OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
+
+ // to find this run the sample through TCPMON to capture the messages
+
+ String data = URLEncoder.encode("callCount", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8");
+ data += "&" + URLEncoder.encode("page", "UTF-8") + "=" + URLEncoder.encode("/helloworld-js-client/", "UTF-8");
+ data += "&" + URLEncoder.encode("httpSessionId", "UTF-8") + "=" + URLEncoder.encode("", "UTF-8");
+ data += "&" + URLEncoder.encode("scriptSessionId", "UTF-8") + "=" + URLEncoder.encode("A023DA664E56F075491BE1B87B37B02671", "UTF-8");
+ data += "&" + URLEncoder.encode("c0-scriptName", "UTF-8") + "=" + URLEncoder.encode("service", "UTF-8");
+ data += "&" + URLEncoder.encode("c0-methodName", "UTF-8") + "=" + URLEncoder.encode("sayHello", "UTF-8");
+ data += "&" + URLEncoder.encode("c0-id", "UTF-8") + "=" + URLEncoder.encode("0", "UTF-8");
+ data += "&" + URLEncoder.encode("c0-param0", "UTF-8") + "=" + URLEncoder.encode("string:petra", "UTF-8");
+ data += "&" + URLEncoder.encode("batchId", "UTF-8") + "=" + URLEncoder.encode("0", "UTF-8");
+
+ wr.write(data);
+ wr.flush();
+
+ BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+ rd.readLine(); // throw 'allowScriptTagRemoting is false.';
+ rd.readLine(); //#DWR-INSERT
+ rd.readLine(); //#DWR-REPLY
+ String line = rd.readLine(); // dwr.engine._remoteHandleCallback('0','0',"Hello petra");
+ wr.close();
+ rd.close();
+
+ assertTrue(line.endsWith("\"Hello petra\");"));
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/pom.xml
new file mode 100644
index 0000000000..6f2b820e4c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/pom.xml
@@ -0,0 +1,99 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-jsf-webapp</artifactId>
+ <name>Apache Tuscany SCA Sample Helloworld JSF</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-myfaces</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-jsf</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld-jsf</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java
new file mode 100644
index 0000000000..9c9f541997
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.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 sample;
+
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ *
+ */
+public class HelloWorldController {
+
+ @Reference
+ protected HelloworldService service;
+
+ private String name;
+
+ public HelloWorldController() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Method that is backed to a submit button of a form.
+ */
+ public String send() {
+ if (service == null) {
+ name = "reference not injected!";
+ } else {
+ name = service.sayHello(name);
+ }
+ return "success";
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..53ff7a5ca1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/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 sample;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..23925d6c69
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000000..99cee9faeb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,51 @@
+<?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.
+-->
+<faces-config version="1.2"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+
+ <!-- managed beans of the simple hello world app -->
+ <managed-bean>
+ <managed-bean-name>helloWorld</managed-bean-name>
+ <managed-bean-class>sample.HelloWorldController</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <!-- navigation rules for helloWorld.jsp -->
+ <navigation-rule>
+ <from-view-id>/helloWorld.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/page2.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <!-- navigation rules for page2.jsp -->
+ <navigation-rule>
+ <from-view-id>/page2.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/helloWorld.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+</faces-config>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..8976adde3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="foo">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..fecbd7c79b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,191 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<web-app 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"
+ version="2.4">
+
+ <description>MyProject web.xml</description>
+
+ <!-- The only web.xml change to the MyFaces Helloworld sample is to add
+ the Tuscany listener and annotation processor context parameter -->
+ <listener>
+ <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>
+ </listener>
+ <context-param>
+ <param-name>org.apache.myfaces.config.annotation.LifecycleProvider</param-name>
+ <param-value>org.apache.tuscany.sca.myfaces.TuscanyAnnotationLifecycleProvider</param-value>
+ </context-param>
+
+ <!--optional: context-param>
+ <description>Comma separated list of URIs of (additional) faces config files.
+ (e.g. /WEB-INF/my-config.xml)
+ See JSF 1.0 PRD2, 10.3.2
+ Attention: You do not need to put /WEB-INF/faces-config.xml in here.
+ </description>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/examples-config.xml</param-value>
+ </context-param-->
+ <context-param>
+ <description>State saving method: "client" or "server" (= default)
+ See JSF Specification 2.5.3</description>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>client</param-value>
+ </context-param>
+ <context-param>
+ <description>Only applicable if state saving method is "server" (= default).
+ Defines the amount (default = 20) of the latest views are stored in session.</description>
+ <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
+ <param-value>20</param-value>
+ </context-param>
+ <context-param>
+ <description>Only applicable if state saving method is "server" (= default).
+ If true (default) the state will be serialized to a byte stream before it
+ is written to the session.
+ If false the state will not be serialized to a byte stream.</description>
+ <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Only applicable if state saving method is "server" (= default) and if
+ org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default)
+ If true (default) the serialized state will be compressed before it
+ is written to the session. If false the state will not be compressed.</description>
+ <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>This parameter tells MyFaces if javascript code should be allowed in the
+ rendered HTML output.
+ If javascript is allowed, command_link anchors will have javascript code
+ that submits the corresponding form.
+ If javascript is not allowed, the state saving info and nested parameters
+ will be added as url parameters.
+ Default: "true"</description>
+ <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <description>If true, rendered HTML code will be formatted, so that it is "human readable".
+ i.e. additional line separators and whitespace will be written, that do not
+ influence the HTML code.
+ Default: "true"</description>
+ <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>If true, a javascript function will be rendered that is able to restore the
+ former vertical scroll on every request. Convenient feature if you have pages
+ with long lists and you do not want the browser page to always jump to the top
+ if you trigger a link or button action that stays on the same page.
+ Default: "false"</description>
+ <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <description>Used for encrypting view state. Only relevant for client side
+ state saving. See MyFaces wiki/web site documentation for instructions
+ on how to configure an application for diffenent encryption strengths.
+ </description>
+ <param-name>org.apache.myfaces.SECRET</param-name>
+ <param-value>NzY1NDMyMTA=</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Validate managed beans, navigation rules and ensure that forms are not nested.
+ </description>
+ <param-name>org.apache.myfaces.VALIDATE</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Treat readonly same as if disabled attribute was set for select elements.
+ </description>
+ <param-name>org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Use the defined class as the class which will be called when a resource is added to the
+ ExtensionFilter handling. Using StreamingAddResource here helps with performance. If you want to add
+ custom components and want to use the ExtensionFilter, you need to provide your custom implementation here.
+ </description>
+ <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
+ <param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Virtual path in the URL which triggers loading of resources for the MyFaces extended components
+ in the ExtensionFilter.
+ </description>
+ <param-name>org.apache.myfaces.RESOURCE_VIRTUAL_PATH</param-name>
+ <param-value>/faces/myFacesExtensionResource</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Check if the extensions-filter has been properly configured.
+ </description>
+ <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <description>
+ Define partial state saving as true/false.
+ </description>
+ <param-name>javax.faces.PARTIAL_STATE_SAVING_METHOD</param-name>
+ <param-value>false</param-value>
+ </context-param>
+
+ <!-- Listener, to allow Jetty serving MyFaces apps -->
+ <listener>
+ <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
+ </listener>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp
new file mode 100644
index 0000000000..189c142c99
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp
@@ -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.
+-->
+
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+
+<html>
+ <head>
+ <title>Apache Tuscany Helloworld JSF sample</title>
+ </head>
+ <body>
+ <h2>Apache Tuscany Helloworld JSF sample</h2>
+ <f:view>
+ <h:form id="mainForm">
+ <h:panelGrid columns="2">
+ <h:outputLabel for="name" value="Please enter your name" />
+ <h:inputText id="name" value="#{helloWorld.name}" required="true"/>
+ <h:commandButton value="Press me" action="#{helloWorld.send}"/>
+ <h:messages showDetail="true" showSummary="false"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp
new file mode 100644
index 0000000000..5ca296e115
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp
@@ -0,0 +1,23 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<%@ page session="false"%>
+<%
+response.sendRedirect("helloWorld.jsf");
+%>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp
new file mode 100644
index 0000000000..89259021c7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp
@@ -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.
+-->
+
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<html>
+ <head>
+ <title>Apache Tuscany Helloworld JSF sample</title>
+ </head>
+ <body>
+ <h2>Apache Tuscany Helloworld JSF sample</h2>
+ <f:view>
+ <h:form id="mainForm">
+ <h:inputTextarea readonly="true" rows="20" cols="80" value="#{helloWorld.name}"/>
+ <br>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+ </f:view>
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/README b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/README
new file mode 100644
index 0000000000..828aadb0f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/README
@@ -0,0 +1,7 @@
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/pom.xml
new file mode 100644
index 0000000000..05a3e23895
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/pom.xml
@@ -0,0 +1,98 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-jsp-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld JSP</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-jsp</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld-jsp</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..53ff7a5ca1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/java/sample/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 sample;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..a22c095f29
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.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;
+
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..8976adde3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="foo">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..fa1f7ad7b9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+<web-app 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>Apache Tuscany Helloworld JSP Sample</display-name>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..ffd01cca73
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp
@@ -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.
+-->
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="sample.HelloworldService" />
+
+<html>
+ <body >
+
+ <h2>Apache Tuscany Helloworld JSP Sample</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.sayHello("world") %>
+
+ </body>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/test/java/itest/HelloworldTestCase.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..665957b0eb
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-jsp/src/test/java/itest/HelloworldTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlParagraph;
+
+/**
+ */
+public class HelloworldTestCase {
+
+ @Test
+ public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
+ HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-jsp");
+ Iterator<?> ss = page.getAllHtmlChildElements().iterator();
+ while(ss.hasNext()) {
+ HtmlElement htmlElement = (HtmlElement) ss.next();
+ if( htmlElement instanceof HtmlParagraph) {
+ assertEquals("Hello world", htmlElement.asText());
+ break;
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/README b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/README
new file mode 100644
index 0000000000..828aadb0f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/README
@@ -0,0 +1,7 @@
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/pom.xml
new file mode 100644
index 0000000000..45725aaf72
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/pom.xml
@@ -0,0 +1,105 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-servlet-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld Servlet</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base-nodep</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-servlet</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld-servlet</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldService.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..2e43e09897
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/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 sample;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..9e79276704
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java
new file mode 100644
index 0000000000..bb72c50f6a
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.io.IOException;
+import java.io.Writer;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ */
+public class HelloworldServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Reference
+ protected HelloworldService service;
+
+ @Override
+ public void init(ServletConfig servletConfig) throws ServletException {
+ if (service == null) {
+ System.out.println("HelloworldServlet reference injection failed, using ComponentContext");
+ ComponentContext cc = (ComponentContext)servletConfig.getServletContext().getAttribute("org.oasisopen.sca.ComponentContext");
+ service = cc.getService(HelloworldService.class, "service");
+ }
+ }
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ String name = request.getParameter("name");
+ String greeting = service.sayHello(name);
+
+ Writer out = response.getWriter();
+ out.write("<html><head><title>Apache Tuscany Helloworld Servlet Sample</title></head><body>");
+ out.write("<h2>Apache Tuscany Helloworld Servlet Sample</h2>");
+ out.write("<br><strong>Result: </strong>" + greeting);
+ out.write("</body></html>");
+ out.flush();
+ out.close();
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..8976adde3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="foo">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..a91b3fc96b
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml
@@ -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.
+-->
+<web-app 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>Apache Tuscany Helloworld Servlet Sample</display-name>
+
+ <listener><listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class></listener>
+
+ <servlet>
+ <servlet-name>HelloworldServlet</servlet-name>
+ <servlet-class>sample.HelloworldServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>HelloworldServlet</servlet-name>
+ <url-pattern>/HelloworldServlet</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>hello.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
+
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/hello.html b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/hello.html
new file mode 100644
index 0000000000..c4484916aa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/main/webapp/hello.html
@@ -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.
+-->
+<html>
+
+<head>
+<title>Apache Tuscany Helloworld Servlet Sample</title>
+</head>
+
+<body>
+
+<h2>Apache Tuscany Helloworld Servlet Sample</h2>
+
+<form action="HelloworldServlet" method="post">
+ <table>
+ <tr>
+ <td>Enter your name:</td>
+ <td>
+ <input type="text" name="name" width="10">
+ </td>
+ </tr>
+ <tr>
+ <td align="left" colspan="2">
+ <button name="submit" type="submit">Say hello</button>
+ </td>
+ </tr>
+ </table>
+</form>
+
+</body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/test/java/itest/HelloworldTestCase.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..61d722da1f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-servlet/src/test/java/itest/HelloworldTestCase.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlButton;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ */
+public class HelloworldTestCase {
+
+ @Test
+ public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
+ HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-servlet");
+
+ HtmlForm form = (HtmlForm) page.getForms().get(0);
+
+ HtmlInput textField = form.getInputByName("name");
+ textField.setValueAttribute("petra");
+
+ HtmlButton button = (HtmlButton) form.getButtonsByName("submit").get(0);
+
+ HtmlPage pageResponse = (HtmlPage) button.click();
+
+ assertTrue(pageResponse.getWebResponse().getContentAsString().endsWith("</strong>Hello petra</body></html>"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/pom.xml
new file mode 100644
index 0000000000..59f3a25696
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/pom.xml
@@ -0,0 +1,186 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-spring-webapp</artifactId>
+ <name>Apache Tuscany SCA Sample Spring Helloworld</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sample-helloworld-spring</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>httpunit</groupId>
+ <artifactId>httpunit</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-spring</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Skip the normal tests, we'll run them in the integration-test phase -->
+ <skip>true</skip>
+ </configuration>
+
+ <executions>
+ <execution>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <!-- Ingore the test failures so that the build will proceed to stop the tomcat server -->
+ <testFailureIgnore>true</testFailureIgnore>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <overlays>
+ <overlay>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sample-helloworld-spring</artifactId>
+ <type>jar</type>
+ <targetPath>WEB-INF/classes</targetPath>
+ <excludes>
+ <exclude>META-INF/**/*</exclude>
+ </excludes>
+ </overlay>
+
+ <overlay>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sample-helloworld-spring</artifactId>
+ <type>jar</type>
+ <includes>
+ <include>META-INF/**/*</include>
+ </includes>
+ </overlay>
+
+ <overlay>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-webapp</artifactId>
+ <type>jar</type>
+ <targetPath>WEB-INF/classes</targetPath>
+ <includes>
+ <include>org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml</include>
+ </includes>
+ </overlay>
+ </overlays>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <overrideWebXml>src/test/resources/test-web.xml</overrideWebXml>
+ <webAppSourceDirectory>${project.build.directory}/${project.build.finalName}</webAppSourceDirectory>
+ <webXml>${project.build.directory}/${project.build.finalName}/WEB-INF/web.xml</webXml>
+ <classesDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</classesDirectory>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..49590e00a2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,51 @@
+<?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.
+-->
+<web-app 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>Apache Tuscany Helloworld Spring Sample</display-name>
+
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>
+ /WEB-INF/classes/helloworld-context.xml
+ /WEB-INF/classes/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml
+ </param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <listener>
+ <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/test/java/sample/HelloworldClientTestCase.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/test/java/sample/HelloworldClientTestCase.java
new file mode 100644
index 0000000000..fa77f08ee2
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/test/java/sample/HelloworldClientTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.io.ByteArrayInputStream;
+
+import junit.framework.Assert;
+
+import org.json.JSONObject;
+import org.junit.Test;
+
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+
+/**
+ *
+ */
+public class HelloworldClientTestCase {
+ private static final String SERVICE_URL =
+ "http://localhost:8085/helloworld/HelloworldClientComponent/HelloworldClientBean";
+
+ @Test
+ public void testJSONRPCBinding() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"sayHello\", \"params\": [\"Ray\"], \"id\": 1}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request =
+ new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),
+ "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+ String text = jsonResp.getString("result");
+ Assert.assertTrue(text.endsWith("Hello Ray"));
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/test/resources/test-web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/test/resources/test-web.xml
new file mode 100644
index 0000000000..0ad2ed49c1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-spring/src/test/resources/test-web.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<web-app 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" >
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/pom.xml
new file mode 100644
index 0000000000..16259aba62
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/pom.xml
@@ -0,0 +1,112 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-stripes-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld using Stripes</name>
+
+ <dependencies>
+
+ <!-- Tuscany dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Stripes Framework dependencies -->
+ <dependency>
+ <groupId>net.sourceforge.stripes</groupId>
+ <artifactId>stripes</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>helloworld-stripes</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld-stripes</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java
new file mode 100644
index 0000000000..0ab02682ac
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.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 mystripes.action;
+
+import net.sourceforge.stripes.action.ActionBean;
+import net.sourceforge.stripes.action.ActionBeanContext;
+
+public class BaseActionBean implements ActionBean {
+ private ActionBeanContext context;
+
+ public ActionBeanContext getContext() {
+ return context;
+ }
+ public void setContext(ActionBeanContext context) {
+ this.context = context;
+ }
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java
new file mode 100644
index 0000000000..0385c92369
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package mystripes.action;
+
+import net.sourceforge.stripes.action.DefaultHandler;
+import net.sourceforge.stripes.action.ForwardResolution;
+import net.sourceforge.stripes.action.Resolution;
+import net.sourceforge.stripes.action.UrlBinding;
+
+import org.oasisopen.sca.annotation.Reference;
+
+import sample.HelloworldService;
+
+@UrlBinding("/Home.htm")
+public class HomeActionBean extends BaseActionBean {
+
+ @Reference
+ HelloworldService service;
+
+ @DefaultHandler
+ public Resolution view() {
+ return new ForwardResolution("/WEB-INF/jsp/home.jsp");
+ }
+
+ public String getHello() {
+ return service.sayHello("world");
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..53ff7a5ca1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/sample/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 sample;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..a22c095f29
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.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;
+
+
+public class HelloworldServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties
new file mode 100644
index 0000000000..902842a19e
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties
@@ -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.
+#
+
+# Resource strings used by the <stripes:errors> tag when there are no nested tags
+stripes.errors.header=<div style="color:#b72222; font-weight: bold">Please fix the following errors:</div><ol>
+stripes.errors.beforeError=<li style="color: #b72222;">
+stripes.errors.afterError=</li>
+stripes.errors.footer=</ol>
+
+# Resource strings used by the <stripes:errors> tag when displaying errors for a
+# specific field (e.g. <stripes:errors field="password"/>). If not supplied the
+# values above will be used instead.
+stripes.fieldErrors.header=
+stripes.fieldErrors.beforeError=<span style="color: #b72222;">
+stripes.fieldErrors.afterError=</span><br />
+stripes.fieldErrors.footer=
+
+# Resource strings used by the stripes:messages tag
+stripes.messages.header=<ul class="messages">
+stripes.messages.beforeMessage=<li>
+stripes.messages.afterMessage=</li>
+stripes.messages.footer=</ul>
+
+# Validation error messages produced by Stripes' built-in converter classes. These
+# are default error messages and can be overridden on per-field and per-form levels.
+# Using the 'invalidNumber' error for a field 'age' of a form posting to
+# '/user/Profile.action', the keys looked for (in order) would be:
+# 1: /user/Profile.action.age.invalidNumber
+# 2: /user/Profile.action.age.errorMessage
+# 3: age.errorMessage
+# 4: /user/Profile.action.invalidNumber
+# 5: converter.number.invalidNumber
+converter.number.invalidNumber=The value ({1}) entered in field {0} must be a valid number
+converter.byte.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.short.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.integer.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.float.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.enum.notAnEnumeratedValue=The value "{1}" is not a valid value for field {0}
+converter.date.invalidDate=The value ({1}) entered in field {0} must be a valid date
+converter.email.invalidEmail=The value ({1}) entered is not a valid email address
+converter.creditCard.invalidCreditCard=The value ({1}) entered is not a valid credit card number
+
+# Validation error messages produced by Stripes' annotation based validations. These
+# are default error messages and can be overridden on per-field and per-form levels.
+# Using the 'valueNotPresent' required field error for a field 'username' of a form
+# posting to '/user/Register.action', the keys looked for (in order) would be:
+# 1: /user/Register.action.username.valueNotPresent
+# 2: /user/Register.action.username.errorMessage
+# 3: username.errorMessage
+# 4: /user/Register.action.valueNotPresent
+# 5: validation.required.valueNotPresent
+validation.required.valueNotPresent={0} is a required field
+validation.minlength.valueTooShort={0} must be at least {2} characters long
+validation.maxlength.valueTooLong={0} must be no more than {2} characters long
+validation.minvalue.valueBelowMinimum=The minimum allowed value for {0} is {2}
+validation.maxvalue.valueAboveMaximum=The maximum allowed value for {0} is {2}
+validation.mask.valueDoesNotMatch=<em>{1}</em> is not a valid {0}
+validation.expression.valueFailedExpression=The value supplied ({1}) for field {0} is invalid
+validation.file.postBodyTooBig=Total upload size of {3} KB exceeds the maximum size of {2} KB
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties
new file mode 100644
index 0000000000..2741999098
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties
@@ -0,0 +1,48 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# log4j.properties
+
+# Set up a logger to the console
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p %c %x - %m%n
+
+# Use this to only see log messages beyond a certain threshold in the console
+#log4j.appender.stdout.Threshold=WARN
+
+# Set up a logger to a log file
+log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
+log4j.appender.logfile.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p %c %x - %m%n
+log4j.appender.logfile.File=${user.home}/stripesquick.log
+log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
+
+# Use this to only see log messages beyond a certain threshold in the log file
+#log4j.appender.logfile.Threshold=WARN
+
+# Logger settings
+log4j.rootLogger=INFO, stdout, logfile
+
+# Valid levels are TRACE, DEBUG, INFO, WARN, ERROR, FATAL
+# Change to TRACE or DEBUG to see more log messages
+log4j.logger.net.sourceforge.stripes=WARN
+log4j.logger.org.stripesbook.quickstart=INFO
+log4j.logger.org.mortbay.log=INFO
+log4j.logger.org=WARN
+log4j.logger.com=WARN
+log4j.logger.net=WARN
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp
new file mode 100644
index 0000000000..0681c1f2bf
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp
@@ -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.
+-->
+<%@ include file="/WEB-INF/jsp/taglibs.jsp" %>
+
+<s:layout-render name="/WEB-INF/jsp/layout.jsp" title="Welcome">
+ <s:layout-component name="body">
+ <p>sayHello returns: ${actionBean.hello}</p>
+ <p>Congratulations, you've set up a Stripes SCA project!</p>
+ </s:layout-component>
+</s:layout-render>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp
new file mode 100644
index 0000000000..d0fb716b80
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp
@@ -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.
+-->
+<%@ include file="/WEB-INF/jsp/taglibs.jsp" %>
+
+<s:layout-definition>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+ <title>${title}</title>
+ <link rel="stylesheet" type="text/css" href="${contextPath}/css/style.css">
+ <s:layout-component name="head">
+ </s:layout-component>
+ </head>
+ <body>
+ <div id="main">
+ <s:layout-component name="body">
+ </s:layout-component>
+ </div>
+ </body>
+</html>
+
+</s:layout-definition> \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp
new file mode 100644
index 0000000000..f85602fcfa
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp
@@ -0,0 +1,29 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<%-- Stripes TLD --%>
+<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
+<%@ taglib prefix="sdyn" uri="http://stripes.sourceforge.net/stripes-dynattr.tld" %>
+
+<%-- JSTL TLDs --%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
+
+<%-- This is so that you can conveniently refer to the context path with ${contextPath} --%>
+<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..8976adde3c
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="foo">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..f01584cc2f
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,61 @@
+<?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.
+ -->
+<web-app 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>Apache Tuscany Helloworld Stripes Sample</display-name>
+
+ <listener>
+ <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <filter>
+ <filter-name>StripesFilter</filter-name>
+ <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
+ <init-param>
+ <param-name>ActionResolver.Packages</param-name>
+ <param-value>mystripes.action</param-value>
+ </init-param>
+ <init-param>
+ <param-name>Extension.Packages</param-name>
+ <param-value>org.apache.tuscany.sca.stripes</param-value>
+ </init-param>
+ </filter>
+
+ <servlet>
+ <servlet-name>DispatcherServlet</servlet-name>
+ <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <filter-mapping>
+ <filter-name>StripesFilter</filter-name>
+ <servlet-name>DispatcherServlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ </filter-mapping>
+
+ <servlet-mapping>
+ <servlet-name>DispatcherServlet</servlet-name>
+ <url-pattern>*.htm</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/index.html b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/index.html
new file mode 100644
index 0000000000..c79d29e6a5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/main/webapp/index.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+ <head>
+ <meta http-equiv="refresh" content="0;url=Home.htm">
+ </head>
+</html>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/test/java/README b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/test/java/README
new file mode 100644
index 0000000000..828aadb0f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/test/java/README
@@ -0,0 +1,7 @@
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/test/java/itest/HelloworldTestCase.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..7f4359fa43
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld-stripes/src/test/java/itest/HelloworldTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlParagraph;
+
+/**
+ */
+public class HelloworldTestCase {
+
+ @Test
+ public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
+ HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-stripes");
+ Iterator<?> ss = page.getAllHtmlChildElements().iterator();
+ while(ss.hasNext()) {
+ HtmlElement htmlElement = (HtmlElement) ss.next();
+ if( htmlElement instanceof HtmlParagraph) {
+ assertEquals("sayHello returns: Hello world", htmlElement.asText());
+ break;
+ }
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld/README b/sandbox/sebastien/java/embed/samples/webapps/helloworld/README
new file mode 100644
index 0000000000..828aadb0f1
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld/README
@@ -0,0 +1,7 @@
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish \ No newline at end of file
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld/pom.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld/pom.xml
new file mode 100644
index 0000000000..8d70ec23a7
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld/pom.xml
@@ -0,0 +1,118 @@
+<?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-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-helloworld-webapp</artifactId>
+ <name>Apache Tuscany SCA Sample Helloworld</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base-nodep</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>helloworld</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sample-helloworld</artifactId>
+ <version>${pom.version}</version>
+ <!-- should really go in the target folder but i can't get jetty:run to work using that -->
+ <outputDirectory>src/main/webapp/WEB-INF/sca-contributions</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ <configuration>
+ <contextPath>helloworld</contextPath>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <overrideWebXml>src/test/resources/test-web.xml</overrideWebXml>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8085</port>
+ </connector>
+ </connectors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..85aed34b26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,47 @@
+<?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.
+-->
+<web-app 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>Apache Tuscany Helloworld Sample</display-name>
+
+ <context-param>
+ <param-name>contributions</param-name>
+ <param-value>/WEB-INF/sca-contributions</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>org.apache.tuscany.sca.config</param-name>
+ <param-value>uri:default</param-value>
+ </context-param>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/java/itest/Helloworld.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/java/itest/Helloworld.java
new file mode 100644
index 0000000000..f1ccf0b1ba
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/java/itest/Helloworld.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+ String sayHello(String name);
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/java/itest/HelloworldTestCaseFIXME.java b/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/java/itest/HelloworldTestCaseFIXME.java
new file mode 100644
index 0000000000..c1c2c6aae0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/java/itest/HelloworldTestCaseFIXME.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 itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ */
+public class HelloworldTestCaseFIXME {
+
+ @Test
+ public void testHelloworld() throws NoSuchDomainException, NoSuchServiceException {
+// TODO: need to fix the config URI so it works properly
+// SCAClientFactory factory = SCAClientFactory.newInstance(URI.create("uri:default?remote=127.0.0.1:54321"));
+ SCAClientFactory factory = SCAClientFactory.newInstance(URI.create("tuscany:default?remotes=192.168.1.64"));
+ Helloworld helloworld = factory.getService(Helloworld.class, "HelloworldComponent");
+ assertEquals("Hello World", helloworld.sayHello("World"));
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/resources/test-web.xml b/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/resources/test-web.xml
new file mode 100644
index 0000000000..a68aa28698
--- /dev/null
+++ b/sandbox/sebastien/java/embed/samples/webapps/helloworld/src/test/resources/test-web.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+<web-app 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" >
+
+ <context-param>
+ <param-name>org.apache.tuscany.sca.config</param-name>
+ <param-value>uri:default?bind=127.0.0.1:54321</param-value>
+ </context-param>
+
+</web-app>
diff --git a/sandbox/sebastien/java/embed/shades/base-nodep/pom.xml b/sandbox/sebastien/java/embed/shades/base-nodep/pom.xml
new file mode 100644
index 0000000000..60c1aaccb0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base-nodep/pom.xml
@@ -0,0 +1,121 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base-nodep</artifactId>
+ <name>Apache Tuscany SCA Base Jar including dependencies</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>0.9.94</version>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Tuscany uses java.util.logging but extensions and dependencies may use
+ log4j, commons-logging, slf4j, or java.util.logging. So inlcude slf4j
+ modules for all of those that delegate to java.util.logging. This should
+ mean there's no need for any other logging jars and no conflicts on
+ logging verisons as those are handled transparently by slf4j, and,
+ everything uses and can be configured just with java.util.logging.
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ -->
+
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createSourcesJar>true</createSourcesJar>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/base-nodep/src/main/java/org/apache/tuscany/sca/base/AggregatedBundleActivator.java b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/java/org/apache/tuscany/sca/base/AggregatedBundleActivator.java
new file mode 100644
index 0000000000..cb35fed680
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/java/org/apache/tuscany/sca/base/AggregatedBundleActivator.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 org.apache.tuscany.sca.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A bundle activator that delegates to others
+ */
+public class AggregatedBundleActivator implements BundleActivator {
+ public static final String BUNDLE_ACTIVATOR_LIST = "Tuscany-Bundle-Activator-List";
+ private List<BundleActivator> activators = new ArrayList<BundleActivator>();
+
+ public void start(BundleContext context) throws Exception {
+ String list = (String)context.getBundle().getHeaders().get(BUNDLE_ACTIVATOR_LIST);
+ if (list == null) {
+ return;
+ }
+ for (String cls : list.split(",")) {
+ Object i = context.getBundle().loadClass(cls).newInstance();
+ if (i instanceof BundleActivator) {
+ ((BundleActivator)i).start(context);
+ activators.add((BundleActivator)i);
+ }
+ }
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ for (BundleActivator a : activators) {
+ a.stop(context);
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/LICENSE b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/LICENSE
new file mode 100644
index 0000000000..69a1a5eee6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/LICENSE
@@ -0,0 +1,234 @@
+
+ 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.
+
+===============================================================================
+
+This shaded jar also includes files uisng the following licenses:
+
+===============================================================================
+
+Permission to copy, display and distribute the Service Component Architecture Specification and/or
+portions thereof, without modification, in any medium without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the Service Component Architecture Specification, or
+portions thereof, that you make:
+
+1. A link or URL to the Service Component Architecture Specification at this location:
+· http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of the copyright notice as shown in the Service Component Architecture Specification.
+
+BEA, Cape Clear, IBM, Interface21, IONA, Oracle, Primeton, Progress Software, Red Hat, Rogue Wave,
+SAP, Siemens, Software AG., Sun, Sybase, TIBCO (collectively, the "Authors") agree to grant you a
+royalty-free license, under reasonable, non-discriminatory terms and conditions to patents that they deem
+necessary to implement the Service Component Architecture Specification.
+THE Service Component Architecture SPECIFICATION IS PROVIDED "AS IS," AND THE
+AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+REGARDING THIS SPECIFICATION AND THE IMPLEMENTATION OF ITS CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR
+DISTRIBUTION OF THE Service Components Architecture SPECIFICATION.
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+
diff --git a/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/META-INF/MANIFEST.MF b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..728346b3c5
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,479 @@
+Manifest-Version: 1.0
+Main-Class: org.apache.tuscany.sca.shell.Shell
+Bundle-Activator: org.apache.tuscany.sca.base.AggregatedBundleActivator
+Tuscany-Bundle-Activator-List: org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleActivator,org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoveryActivator,org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementationActivator,org.apache.tuscany.sca.node.osgi.impl.NodeActivator,org.apache.tuscany.sca.node.equinox.launcher.FrameworkLauncher
+Export-Package: org.apache.tuscany.sca.launcher;version="2.0",org.apac
+ he.tuscany.sca.assembly.xml;version="2.0.0";uses:="org.apache.tuscany
+ .sca.assembly, javax.xml.parsers, org.apache.tuscany.sca.core, org
+ .apache.tuscany.sca.contribution, org.apache.tuscany.sca.monitor, o
+ rg.apache.tuscany.sca.policy, org.apache.tuscany.sca.interfacedef,
+ org.w3c.dom, javax.xml.namespace, javax.xml.stream, org.apache.tus
+ cany.sca.contribution.resolver, org.apache.tuscany.sca.contribution.
+ processor",org.apache.tuscany.sca.definitions.xml;version="2.0.0";use
+ s:="javax.xml.stream, org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.definitions, org.apache.tuscany.sca.contribu
+ tion.processor, org.apache.tuscany.sca.core, org.apache.tuscany.sca
+ .monitor, javax.xml.namespace",org.apache.tuscany.sca.policy.xml;ver
+ sion="2.0.0";uses:="javax.xml.xpath, javax.xml.stream, org.apache.t
+ uscany.sca.contribution.resolver, org.apache.tuscany.sca.contributio
+ n.processor, org.apache.tuscany.sca.core, org.apache.tuscany.sca.po
+ licy, org.apache.tuscany.sca.monitor, javax.xml.namespace",org.apac
+ he.tuscany.sca.common.xml;version="2.0.0";uses:="org.xml.sax",org.apa
+ che.tuscany.sca.common.xml.dom;version="2.0.0";uses:="org.xml.sax.ext
+ , javax.xml.transform, javax.xml.parsers, org.apache.tuscany.sca.c
+ ore, org.w3c.dom, javax.xml.namespace, org.xml.sax",org.apache.tus
+ cany.sca.common.xml.sax;version="2.0.0";uses:="javax.xml.parsers,org.
+ apache.tuscany.sca.core,org.xml.sax",org.apache.tuscany.sca.common.xm
+ l.stax;version="2.0.0";uses:="org.apache.tuscany.sca.common.xml.dom,
+ javax.xml.stream, javax.xml.transform, org.apache.tuscany.sca.core
+ , org.w3c.dom, javax.xml.namespace, org.xml.sax",org.apache.tuscan
+ y.sca.common.xml.stax.reader;version="2.0.0";uses:="javax.xml.stream,
+ javax.xml.stream.util, org.w3c.dom, javax.xml.namespace",org.apac
+ he.tuscany.sca.common.xml.xpath;version="2.0.0";uses:="javax.xml.xpat
+ h,org.apache.tuscany.sca.core,javax.xml.namespace",org.apache.tuscany
+ .sca.interfacedef.wsdl;version="2.0.0";uses:="org.apache.ws.commons.s
+ chema,org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.contribu
+ tion.resolver,javax.wsdl.extensions,org.apache.tuscany.sca.core,org.a
+ pache.tuscany.sca.interfacedef,javax.wsdl,javax.xml.namespace",org.ap
+ ache.tuscany.sca.databinding.jaxb;version="2.0.0";uses:="org.apache.t
+ uscany.sca.databinding,org.apache.tuscany.sca.interfacedef.util,javax
+ .xml.transform.dom,org.xml.sax,javax.xml.namespace,javax.imageio,java
+ x.xml.stream,org.apache.tuscany.sca.contribution.resolver,org.apache.
+ tuscany.sca.databinding.util,org.oasisopen.sca,org.apache.tuscany.sca
+ .databinding.xml,org.apache.tuscany.sca.databinding.impl,org.apache.w
+ s.commons.schema.resolver,org.apache.tuscany.sca.interfacedef,org.w3c
+ .dom,javax.xml.datatype,javax.activation,javax.xml.bind.attachment,ja
+ vax.xml.transform,javax.xml.bind.annotation,javax.xml.transform.strea
+ m,org.apache.tuscany.sca.interfacedef.impl,org.apache.tuscany.sca.xsd
+ ,javax.xml.bind",org.apache.tuscany.sca.implementation.web;version="2
+ .0.0";uses:="org.apache.tuscany.sca.assembly",org.apache.tuscany.sca.
+ context;version="2.0.0";uses:="org.apache.tuscany.sca.runtime, org.a
+ pache.tuscany.sca.assembly, org.apache.tuscany.sca.core, org.oasiso
+ pen.sca, org.apache.tuscany.sca.extensibility",org.apache.tuscany.sc
+ a.invocation;version="2.0.0";uses:="org.apache.tuscany.sca.runtime,or
+ g.apache.tuscany.sca.interfacedef",org.apache.tuscany.sca.management;
+ version="2.0.0";uses:="org.apache.tuscany.sca.runtime",org.apache.tus
+ cany.sca.provider;version="2.0.0";uses:="org.apache.tuscany.sca.invoc
+ ation, org.apache.tuscany.sca.runtime, org.apache.tuscany.sca.assem
+ bly, org.apache.tuscany.sca.definitions, org.apache.tuscany.sca.cor
+ e, org.apache.tuscany.sca.interfacedef, org.apache.tuscany.sca.exte
+ nsibility",org.apache.tuscany.sca.runtime;version="2.0.0";uses:="org.
+ apache.tuscany.sca.invocation, org.apache.tuscany.sca.assembly, org
+ .apache.tuscany.sca.endpointresolver, org.apache.tuscany.sca.provide
+ r, org.oasisopen.sca, org.apache.tuscany.sca.interfacedef",org.apac
+ he.tuscany.sca.work;version="2.0.0",org.apache.tuscany.sca.interfaced
+ ef.java.jaxws;version="2.0.0";uses:="org.apache.tuscany.sca.databindi
+ ng,org.apache.tuscany.sca.interfacedef.util,org.objectweb.asm,javax.j
+ ws,javax.xml.namespace,javax.jws.soap,org.apache.tuscany.sca.interfac
+ edef.java.impl,org.apache.tuscany.sca.databinding.annotation,org.oasi
+ sopen.sca,javax.xml.bind.annotation.adapters,org.apache.tuscany.sca.i
+ nterfacedef.java,org.apache.tuscany.sca.interfacedef,org.apache.tusca
+ ny.sca.interfacedef.java.introspect,javax.xml.bind.annotation,org.apa
+ che.tuscany.sca.databinding.jaxb,org.apache.tuscany.sca.interfacedef.
+ impl,javax.xml.ws",org.apache.tuscany.sca.host.webapp;version="2.0.0"
+ ;uses:="javax.servlet,org.apache.tuscany.sca.host.http,org.apache.tus
+ cany.sca.core",org.apache.tuscany.sca.endpoint.hazelcast.client;versi
+ on="2.0.0";uses:="org.apache.tuscany.sca.runtime,org.apache.tuscany.s
+ ca.assembly,org.apache.tuscany.sca.core,org.apache.tuscany.sca.endpoi
+ nt.hazelcast",org.apache.tuscany.sca.binding.ws;version="2.0.0";uses:
+ ="org.apache.tuscany.sca.assembly, org.apache.tuscany.sca.interfaced
+ ef.wsdl, org.apache.tuscany.sca.assembly.builder, org.apache.tuscan
+ y.sca.interfacedef, org.w3c.dom, javax.wsdl, javax.xml.namespace",
+ org.apache.tuscany.sca.binding.ws.addressing;version="2.0.0";uses:="j
+ avax.xml.namespace",org.apache.ws.commons.schema,org.apache.ws.common
+ s.schema.resolver,org.apache.ws.commons.schema.utils,org.apache.ws.co
+ mmons.schema.constants,org.apache.ws.commons.schema.extensions,org.oa
+ sisopen.sca;version="2.0.0";uses:="javax.security.auth",org.oasisopen
+ .sca.annotation;version="2.0.0",org.oasisopen.sca.client;version="2.0
+ .0",org.objectweb.asm;version="3.1.0",org.objectweb.asm.signature;ver
+ sion="3.1.0",org.apache.tuscany.sca.monitor;version="2.0.0",org.apach
+ e.tuscany.sca.host.http;version="2.0.0";uses:="javax.servlet,javax.se
+ rvlet.http",javax.wsdl.extensions.schema;version="1.6.2",javax.wsdl.e
+ xtensions;version="1.6.2",com.ibm.wsdl.xml;version="1.6.2",javax.wsdl
+ .xml;version="1.6.2",com.ibm.wsdl.util;version="1.6.2",com.ibm.wsdl.e
+ xtensions.mime;version="1.6.2",com.ibm.wsdl.extensions.soap;version="
+ 1.6.2",javax.wsdl.extensions.soap12;version="1.6.2",javax.wsdl.extens
+ ions.mime;version="1.6.2",javax.wsdl;version="1.6.2",com.ibm.wsdl.uti
+ l.xml;version="1.6.2",com.ibm.wsdl.extensions.http;version="1.6.2",co
+ m.ibm.wsdl.extensions.soap12;version="1.6.2",javax.wsdl.extensions.ht
+ tp;version="1.6.2",com.ibm.wsdl;version="1.6.2",com.ibm.wsdl.extensio
+ ns;version="1.6.2",com.ibm.wsdl.extensions.schema;version="1.6.2",jav
+ ax.wsdl.factory;version="1.6.2",javax.wsdl.extensions.soap;version="1
+ .6.2",com.ibm.wsdl.factory;version="1.6.2",org.apache.tuscany.sca.dat
+ abinding;version="2.0.0";uses:="org.apache.tuscany.sca.interfacedef.u
+ til,org.apache.tuscany.sca.databinding.impl,org.apache.tuscany.sca.in
+ terfacedef,org.apache.tuscany.sca.extensibility,javax.xml.namespace,o
+ rg.apache.tuscany.sca.contribution.resolver,org.apache.tuscany.sca.in
+ terfacedef.impl,org.apache.tuscany.sca.xsd",org.apache.tuscany.sca.da
+ tabinding.xml;version="2.0.0";uses:="org.apache.tuscany.sca.databindi
+ ng,org.apache.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.da
+ tabinding.impl,javax.xml.parsers,javax.xml.transform.dom,org.w3c.dom,
+ org.apache.tuscany.sca.interfacedef,org.xml.sax,javax.xml.namespace,j
+ avax.xml.stream,javax.xml.stream.util,org.xml.sax.ext,javax.xml.trans
+ form,javax.xml.transform.stream,org.apache.tuscany.sca.interfacedef.i
+ mpl,javax.xml.transform.sax,org.apache.tuscany.sca.databinding.javabe
+ ans,org.xml.sax.helpers",org.apache.tuscany.sca.databinding.impl;vers
+ ion="2.0.0";uses:="org.apache.tuscany.sca.databinding,org.apache.tusc
+ any.sca.interfacedef.util,javax.xml.parsers,org.apache.tuscany.sca.in
+ terfacedef,org.w3c.dom,javax.xml.datatype,javax.xml.namespace,javax.x
+ ml.transform,org.apache.tuscany.sca.interfacedef.impl",org.apache.tus
+ cany.sca.databinding.util;version="2.0.0";uses:="org.apache.tuscany.s
+ ca.interfacedef.util,org.apache.tuscany.sca.interfacedef",org.apache.
+ tuscany.sca.databinding.annotation;version="2.0.0",org.apache.tuscany
+ .sca.databinding.javabeans;version="2.0.0";uses:="org.apache.tuscany.
+ sca.databinding,org.apache.tuscany.sca.databinding.xml,org.apache.tus
+ cany.sca.interfacedef.util,org.apache.tuscany.sca.databinding.impl,ja
+ vax.xml.parsers,org.w3c.dom,org.apache.tuscany.sca.interfacedef,javax
+ .xml.datatype,javax.xml.namespace,javax.xml.stream",org.apache.tuscan
+ y.sca.binding.sca.provider;version="2.0.0";uses:="org.apache.tuscany.
+ sca.databinding, org.apache.tuscany.sca.runtime, org.apache.tuscany
+ .sca.assembly, org.apache.tuscany.sca.provider, org.apache.tuscany.
+ sca.core, org.apache.tuscany.sca.interfacedef, javax.xml.namespace,
+ org.apache.tuscany.sca.invocation, org.apache.tuscany.sca.contribu
+ tion.processor, org.apache.tuscany.sca.assembly.builder",org.apache.
+ tuscany.sca.implementation.java;version="2.0.0";uses:="org.apache.tus
+ cany.sca.assembly, org.apache.tuscany.sca.implementation.java.intros
+ pect, org.apache.tuscany.sca.core, org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef.java",org.apache.tuscany.sca.impl
+ ementation.java.introspect;version="2.0.0";uses:="org.apache.tuscany.
+ sca.assembly,org.apache.tuscany.sca.implementation.java,org.oasisopen
+ .sca",org.apache.tuscany.sca.implementation.java.introspect.impl;vers
+ ion="2.0.0",org.apache.tuscany.sca.implementation.web.runtime.utils;v
+ ersion="2.0",org.apache.tuscany.sca.implementation.web.runtime;versio
+ n="2.0",org.apache.tuscany.sca.deployment;version="2.0.0";uses:="java
+ x.xml.stream, org.apache.tuscany.sca.assembly, org.apache.tuscany.s
+ ca.contribution.processor, org.apache.tuscany.sca.core, org.apache.
+ tuscany.sca.contribution, org.apache.tuscany.sca.monitor, org.apach
+ e.tuscany.sca.assembly.builder",org.apache.tuscany.sca.deployment.imp
+ l;version="2.0.0";uses:="org.apache.tuscany.sca.assembly, org.apache
+ .tuscany.sca.definitions, org.apache.tuscany.sca.common.xml.stax, o
+ rg.apache.tuscany.sca.contribution, org.apache.tuscany.sca.core, or
+ g.apache.tuscany.sca.deployment, org.apache.tuscany.sca.monitor, ja
+ vax.xml.stream, org.apache.tuscany.sca.contribution.resolver, org.a
+ pache.tuscany.sca.contribution.processor, org.apache.tuscany.sca.ass
+ embly.builder",org.apache.tuscany.sca.contribution.scanner;version="2
+ .0.0";uses:="org.apache.tuscany.sca.contribution.processor,org.apache
+ .tuscany.sca.extensibility",org.apache.tuscany.sca.contribution.resol
+ ver;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,org.apache
+ .tuscany.sca.core,org.apache.tuscany.sca.contribution,org.apache.tusc
+ any.sca.extensibility",org.apache.tuscany.sca.contribution.processor;
+ version="2.0.0";uses:="org.apache.tuscany.sca.assembly,org.apache.tus
+ cany.sca.core,org.apache.tuscany.sca.policy,org.apache.tuscany.sca.mo
+ nitor,org.apache.tuscany.sca.extensibility,org.xml.sax,javax.xml.name
+ space,javax.xml.stream,javax.xml.stream.util,javax.xml.transform,org.
+ apache.tuscany.sca.contribution.resolver,javax.xml.transform.stream,j
+ avax.xml.validation,org.xml.sax.helpers",org.apache.tuscany.sca.contr
+ ibution;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,org.ap
+ ache.tuscany.sca.contribution.resolver",org.apache.tuscany.sca.contri
+ bution.namespace;version="2.0.0";uses:="org.apache.tuscany.sca.contri
+ bution",org.apache.tuscany.sca.contribution.java;version="2.0.0";uses
+ :="org.apache.tuscany.sca.contribution",org.apache.tuscany.sca.core.a
+ ssembly;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,org.ap
+ ache.tuscany.sca.core",org.apache.tuscany.sca.core.context;version="2
+ .0.0";uses:="javax.xml.stream, org.apache.tuscany.sca.runtime, org.
+ apache.tuscany.sca.assembly, org.apache.tuscany.sca.context, org.oa
+ sisopen.sca, org.apache.tuscany.sca.core",org.apache.tuscany.sca.cor
+ e.factory;version="2.0.0",org.apache.tuscany.sca.core.invocation;vers
+ ion="2.0.0";uses:="org.apache.tuscany.sca.invocation, org.apache.tus
+ cany.sca.runtime, org.apache.tuscany.sca.assembly, org.oasisopen.sc
+ a, org.apache.tuscany.sca.work, org.apache.tuscany.sca.core.factory
+ , org.apache.tuscany.sca.core.context.impl, org.apache.tuscany.sca.
+ core, org.apache.tuscany.sca.interfacedef",org.apache.tuscany.sca.co
+ re.scope;version="2.0.0";uses:="org.apache.tuscany.sca.runtime, org.
+ apache.tuscany.sca.provider, org.apache.tuscany.sca.core.scope.impl,
+ org.apache.tuscany.sca.core.factory",org.apache.tuscany.sca.node.im
+ pl;version="2.0.0",org.apache.tuscany.sca.xsd;version="2.0.0";uses:="
+ org.apache.ws.commons.schema, org.apache.tuscany.sca.assembly, org.
+ apache.tuscany.sca.xsd.impl, org.w3c.dom, javax.xml.namespace",org.
+ apache.tuscany.sca.xsd.xml;version="2.0.0";uses:="org.apache.ws.commo
+ ns.schema.resolver, org.apache.tuscany.sca.contribution.resolver, o
+ rg.apache.tuscany.sca.contribution.processor, org.apache.tuscany.sca
+ .contribution, org.apache.tuscany.sca.xsd, org.apache.tuscany.sca.c
+ ore, org.apache.tuscany.sca.monitor, org.xml.sax, javax.xml.namesp
+ ace",org.apache.tuscany.sca.binding.ws.jaxws;version="2.0.0",org.apac
+ he.tuscany.sca.core;version="2.0.0";uses:="org.apache.tuscany.sca.ext
+ ensibility",org.apache.tuscany.sca.extensibility;version="2.0.0",org.
+ apache.tuscany.sca.endpoint.hazelcast;version="2.0.0";uses:="org.apac
+ he.tuscany.sca.runtime,org.apache.tuscany.sca.assembly,org.apache.tus
+ cany.sca.core",org.apache.tuscany.sca.implementation.java.context;ver
+ sion="2.0.0";uses:="org.apache.tuscany.sca.core.context,org.apache.tu
+ scany.sca.core.factory,org.apache.tuscany.sca.implementation.java,org
+ .apache.tuscany.sca.core.scope,org.apache.tuscany.sca.implementation.
+ java.injection",org.apache.tuscany.sca.implementation.java.injection;
+ version="2.0.0";uses:="org.apache.tuscany.sca.databinding,org.apache.
+ tuscany.sca.databinding.xml,org.apache.tuscany.sca.runtime,org.apache
+ .tuscany.sca.interfacedef.util,org.apache.tuscany.sca.assembly,org.ap
+ ache.tuscany.sca.context,org.apache.tuscany.sca.databinding.impl,org.
+ apache.tuscany.sca.core.context,org.apache.tuscany.sca.implementation
+ .java.introspect,org.apache.tuscany.sca.implementation.java,org.apach
+ e.tuscany.sca.interfacedef,org.w3c.dom,javax.xml.namespace,org.apache
+ .tuscany.sca.invocation,org.apache.tuscany.sca.core.factory,org.apach
+ e.tuscany.sca.interfacedef.impl,org.oasisopen.sca,org.apache.tuscany.
+ sca.core.invocation",com.hazelcast.cluster;uses:="com.hazelcast.impl.
+ base, com.hazelcast.nio, com.hazelcast.core, com.hazelcast.impl, com.
+ hazelcast.util",com.hazelcast.config;uses:="com.hazelcast.nio,org.w3c
+ .dom",com.hazelcast.core;uses:="com.hazelcast.monitor, com.hazelcast.
+ nio, com.hazelcast.query, com.hazelcast.impl, com.hazelcast.logging,
+ com.hazelcast.config, com.hazelcast.partition",com.hazelcast.examples
+ ;uses:="com.hazelcast.core",com.hazelcast.jmx;uses:="com.hazelcast.co
+ nfig, com.hazelcast.core, javax.management, com.hazelcast.impl",com.h
+ azelcast.logging,com.hazelcast.monitor;uses:="com.hazelcast.core,com.
+ hazelcast.impl",com.hazelcast.nio;uses:="javax.crypto, com.hazelcast.
+ impl, com.hazelcast.logging, com.hazelcast.cluster",com.hazelcast.par
+ tition;uses:="com.hazelcast.core",com.hazelcast.query;uses:="com.haze
+ lcast.nio,com.hazelcast.core,com.hazelcast.impl",com.hazelcast.util,o
+ rg.apache.tuscany.sca.binding.ws.wsdlgen;version="2.0.0";uses:="org.a
+ pache.tuscany.sca.databinding,org.apache.tuscany.sca.interfacedef.uti
+ l,org.apache.tuscany.sca.core,org.apache.tuscany.sca.policy,javax.wsd
+ l.extensions.schema,javax.xml.namespace,javax.wsdl.xml,javax.wsdl.ext
+ ensions,org.apache.tuscany.sca.contribution.resolver,org.oasisopen.sc
+ a,org.apache.ws.commons.schema,javax.wsdl.factory,org.apache.tuscany.
+ sca.assembly,javax.wsdl.extensions.soap,javax.xml.parsers,org.apache.
+ tuscany.sca.monitor,org.apache.tuscany.sca.interfacedef.java,org.apac
+ he.tuscany.sca.interfacedef,org.w3c.dom,javax.wsdl,org.apache.tuscany
+ .sca.binding.ws,javax.wsdl.extensions.soap12,org.apache.tuscany.sca.d
+ atabinding.jaxb,org.apache.tuscany.sca.interfacedef.wsdl,org.apache.w
+ s.commons.schema.utils,org.apache.tuscany.sca.xsd",org.apache.tuscany
+ .sca.node;version="2.0.0";uses:="org.oasisopen.sca",org.apache.tuscan
+ y.sca.node.configuration;version="2.0.0",org.apache.tuscany.sca.core.
+ databinding.processor;version="2.0.0";uses:="org.w3c.dom",org.apache.
+ tuscany.sca.assembly;version="2.0.0";uses:="javax.xml.xpath, org.apa
+ che.tuscany.sca.assembly.impl, org.apache.tuscany.sca.core, org.apa
+ che.tuscany.sca.policy, org.apache.tuscany.sca.interfacedef, javax.
+ xml.namespace",org.apache.tuscany.sca.assembly.builder;version="2.0.0
+ ";uses:="org.apache.tuscany.sca.assembly, org.apache.tuscany.sca.def
+ initions, org.apache.tuscany.sca.core, org.apache.tuscany.sca.monit
+ or",org.apache.tuscany.sca.assembly.impl;version="2.0.0";uses:="javax
+ .xml.xpath, org.apache.tuscany.sca.assembly, org.apache.tuscany.sca
+ .core, org.apache.tuscany.sca.policy, org.apache.tuscany.sca.interf
+ acedef, javax.xml.namespace",org.apache.tuscany.sca.definitions;vers
+ ion="2.0.0",org.apache.tuscany.sca.definitions.util;version="2.0.0";u
+ ses:="org.apache.tuscany.sca.definitions,org.apache.tuscany.sca.monit
+ or",org.apache.tuscany.sca.interfacedef;version="2.0.0";uses:="org.ap
+ ache.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.policy",org
+ .apache.tuscany.sca.interfacedef.impl;version="2.0.0";uses:="org.apac
+ he.tuscany.sca.interfacedef.util,org.apache.tuscany.sca.policy,org.ap
+ ache.tuscany.sca.interfacedef",org.apache.tuscany.sca.interfacedef.ut
+ il;version="2.0.0";uses:="org.apache.tuscany.sca.interfacedef,javax.x
+ ml.namespace",org.apache.tuscany.sca.policy;version="2.0.0";uses:="ja
+ vax.xml.xpath,org.apache.tuscany.sca.policy.impl,javax.xml.namespace"
+ ,org.apache.tuscany.sca.policy.impl;version="2.0.0";uses:="javax.xml.
+ xpath,org.apache.tuscany.sca.policy,javax.xml.namespace",org.apache.t
+ uscany.sca.policy.util;version="2.0.0";uses:="javax.xml.parsers,org.a
+ pache.tuscany.sca.policy",org.apache.tuscany.sca.assembly.xsd;version
+ ="2.0.0",org.apache.tuscany.sca.common.java.classloader;version="2.0.
+ 0",org.apache.tuscany.sca.common.java.collection;version="2.0.0",org.
+ apache.tuscany.sca.common.java.io;version="2.0.0",org.apache.tuscany.
+ sca.common.java.reflection;version="2.0.0";uses:="org.apache.tuscany.
+ sca.core",com.hazelcast.client.examples;version="1.8.3",com.hazelcast
+ .client.impl;version="1.8.3",com.hazelcast.client;version="1.8.3",com
+ .hazelcast.client.cluster;version="1.8.3",net.sf.cglib.proxy;version=
+ "2.2.0",net.sf.cglib.transform;version="2.2.0",net.sf.cglib.reflect;v
+ ersion="2.2.0",net.sf.cglib.util;version="2.2.0",net.sf.cglib.beans;v
+ ersion="2.2.0",net.sf.cglib.transform.impl;version="2.2.0",net.sf.cgl
+ ib.core;version="2.2.0",org.apache.tuscany.sca.interfacedef.java.impl
+ ;version="2.0.0";uses:="org.osoa.sca.annotations,org.apache.tuscany.s
+ ca.interfacedef.util,org.apache.tuscany.sca.policy,org.apache.tuscany
+ .sca.interfacedef.java,org.apache.tuscany.sca.interfacedef,javax.xml.
+ namespace,org.apache.tuscany.sca.interfacedef.java.introspect,org.apa
+ che.tuscany.sca.interfacedef.impl",org.apache.tuscany.sca.interfacede
+ f.java.introspect;version="2.0.0";uses:="org.apache.tuscany.sca.inter
+ facedef.java,org.apache.tuscany.sca.interfacedef",org.apache.tuscany.
+ sca.interfacedef.java;version="2.0.0";uses:="org.apache.tuscany.sca.a
+ ssembly,org.apache.tuscany.sca.interfacedef.java.impl,org.apache.tusc
+ any.sca.interfacedef.java.introspect,org.apache.tuscany.sca.core,org.
+ apache.tuscany.sca.policy,org.apache.tuscany.sca.interfacedef,org.apa
+ che.tuscany.sca.extensibility,javax.xml.namespace"
+Private-Package: org.apache.tuscany.sca.interfacedef.wsdl.impl;version
+ ="2.0.0",org.apache.tuscany.sca.implementation.web.impl;version="2.0.
+ 0",org.apache.tuscany.sca.binding.ws.impl;version="2.0.0",org.apache.
+ tuscany.sca.databinding.externalizable;version="2.0.0",org.apache.tus
+ cany.sca.binding.sca.provider;version="2.0.0",org.apache.tuscany.sca.
+ implementation.java.impl;version="2.0.0",org.apache.tuscany.sca.imple
+ mentation.java.introspect.impl;version="2.0.0",org.apache.tuscany.sca
+ .contribution.impl;version="1.4",org.apache.tuscany.sca.xsd.impl;vers
+ ion="2.0.0",org.apache.tuscany.sca.implementation.java.invocation;ver
+ sion="2.0.0",org.apache.tuscany.sca.implementation.java.module;versio
+ n="2.0.0",org.apache.tuscany.sca.core.databinding.module;version="2.0
+ .0",org.apache.tuscany.sca.core.databinding.processor;version="2.0.0"
+ ,org.apache.tuscany.sca.core.databinding.transformers;version="2.0.0"
+ ,org.apache.tuscany.sca.core.databinding.wire;version="2.0.0",org.apa
+ che.tuscany.sca.assembly.builder.impl;version="2.0.0",org.apache.tusc
+ any.sca.http.jetty;version="2.0.0"
+Bundle-ClassPath: .
+Bundle-Name: Apache Tuscany Base with No Dependencies
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+DynamicImport-Package: javax.transaction;version="1.1",javax.transacti
+ on.xa;version="1.1",*,org.apache.tuscany.sca.*;version="2.0.0",org.ap
+ ache.tuscany.sca.extensibility.equinox,org.apache.tuscany.sca.node.im
+ pl,org.apache.tuscany.sca.extensibility
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Launcher,Apache Tuscany SCA XML Ass
+ embly Model,Apache Tuscany SCA Common XML,Apache Tuscany SCA WSDL Int
+ erface Model,Apache Tuscany SCA Data Binding for JAXB,Apache Tuscany
+ SCA Implementation Web Model,Apache Tuscany SCA Domain Node,Apache Tu
+ scany SCA Core SPI,Apache Tuscany Java Interface for JAXWS,Apache Tus
+ cany SCA Webapp Host,Apache Tuscany Hazelcast Client Endpoint Regsitr
+ y,Apache Tuscany SCA WS Binding Model,Apache Tuscany SCA Assembly Mod
+ el,API classes for the Service Component Architecture,Apache Tuscany
+ SCA Client Impl,Apache Tuscany SCA Monitor,Apache Tuscany SCA HTTP Se
+ rvlet Host Extension Point,Apache Tuscany SCA Wink,Apache Tuscany SCA
+ Stripes,Apache Tuscany SCA DataBinding Framework,Apache Tuscany SCA
+ Default Binding Model,Apache Tuscany SCA Java Implementation Model,Ap
+ ache Tuscany SCA Implementation Web Runtime,Apache Tuscany SCA Node I
+ mplementation,Apache Tuscany SCA Contribution Model,Apache Tuscany SC
+ A Core Runtime,Apache Tuscany SCA XSD Model,Apache Tuscany Hazelcast
+ Binding,Apache Tuscany SCA JAXWS-based WS Binding Extension,Apache Tu
+ scany SCA Extensibility,Apache Tuscany Hazelcast Endpoint Regsitry,Ap
+ ache Tuscany SCA Web Service binding WSDL Generator,Apache Tuscany SC
+ A Node API,Apache Tuscany SCA Core/DataBinding Integration,Apache Tus
+ cany SCA Assembly Model XML Schemas,Apache Tuscany SCA Jetty Servlet
+ Host Extension,Apache Tuscany SCA Common Java,Apache Tuscany SCA Java
+ Interface Model
+Bundle-DocURL: http://www.apache.org/
+Bundle-SymbolicName: org.apache.tuscany.sca.base-nodep
+Import-Package: com.hazelcast.client,
+ com.hazelcast.config,
+ com.hazelcast.core,
+ com.hazelcast.nio,
+ javax.activation,
+ javax.imageio,
+ javax.jws,
+ javax.jws.soap,
+ javax.management;resolution:=optional,
+ javax.naming,
+ javax.net.ssl;resolution:=optional,
+ javax.security.auth,
+ javax.security.auth.callback;resolution:=optional,
+ javax.servlet;resolution:=optional,
+ javax.servlet.http;resolution:=optional,
+ javax.servlet.jsp;resolution:=optional,
+ javax.servlet.jsp.tagext;resolution:=optional,
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.extensions.schema,
+ javax.wsdl.extensions.soap,
+ javax.wsdl.extensions.soap12,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.bind,
+ javax.xml.bind.annotation,
+ javax.xml.bind.annotation.adapters,
+ javax.xml.bind.attachment,
+ javax.xml.datatype,
+ javax.xml.namespace,
+ javax.xml.parsers,
+ javax.xml.soap,
+ javax.xml.stream,
+ javax.xml.stream.events,
+ javax.xml.stream.util,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.sax,
+ javax.xml.transform.stream,
+ javax.xml.validation;resolution:=optional,
+ javax.xml.ws,
+ javax.xml.xpath,
+ net.sf.cglib.proxy;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xsd;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.addressing;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.wsdlgen;version="2.0.0",
+ org.apache.tuscany.sca.common.java.classloader;version="2.0.0",
+ org.apache.tuscany.sca.common.java.collection;version="2.0.0",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.java.reflection;version="2.0.0",
+ org.apache.tuscany.sca.common.xml;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.sax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax.reader;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.xpath;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.java;version="2.0.0",
+ org.apache.tuscany.sca.contribution.namespace;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.contribution.scanner;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core.context;version="2.0.0",
+ org.apache.tuscany.sca.core.factory;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
+ org.apache.tuscany.sca.core.scope;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.annotation;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.databinding.jaxb;version="2.0.0",
+ org.apache.tuscany.sca.databinding.util;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0",
+ org.apache.tuscany.sca.deployment;version="2.0.0",
+ org.apache.tuscany.sca.endpoint.hazelcast;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.host.webapp;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.context;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.injection;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.implementation.java.invocation;resolution:=optional,
+ org.apache.tuscany.sca.implementation.web;version="2.0.0",
+ org.apache.tuscany.sca.implementation.web.runtime.utils;version="2.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.introspect;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java.jaxws;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.launcher;version="2.0",
+ org.apache.tuscany.sca.management;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.apache.tuscany.sca.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.impl;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0",
+ org.apache.tuscany.sca.xsd;version="2.0.0",
+ org.apache.tuscany.sca.xsd.xml;version="2.0.0",
+ org.apache.ws.commons.schema,
+ org.apache.ws.commons.schema.resolver,
+ org.apache.ws.commons.schema.utils,
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
+ org.oasisopen.sca.client;version="2.0.0",
+ org.objectweb.asm;version="3.1",
+ org.objectweb.asm.util;version="3.1";resolution:=optional,
+ org.osgi.framework;version="1.4.0";resolution:=optional,
+ org.osgi.framework.hooks.service;version="1.0.0";resolution:=optional,
+ org.osgi.service.cm;version="1.2.1";resolution:=optional,
+ org.osgi.service.component;version="1.1.0";resolution:=optional,
+ org.osgi.service.event;version="1.2.0";resolution:=optional,
+ org.osgi.service.packageadmin;version="1.2.0";resolution:=optional,
+ org.osgi.service.remoteserviceadmin;version="1.0.0";resolution:=optional,
+ org.osgi.util.tracker;version="1.3.0";resolution:=optional,
+ org.w3c.dom,
+ org.w3c.dom.ls,
+ org.xml.sax;resolution:=optional,
+ org.xml.sax.ext,
+ org.xml.sax.helpers
+
diff --git a/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/NOTICE b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/NOTICE
new file mode 100644
index 0000000000..1bfb4e16c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/NOTICE
@@ -0,0 +1,12 @@
+Apache Tuscany Base Jar
+Copyright (c) 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the Service Component Architecture specification license
+(see the LICENSE file contained in this distribution) with the following copyright
+
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
diff --git a/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/README.txt b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/README.txt
new file mode 100644
index 0000000000..3de5be9155
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base-nodep/src/main/resources/README.txt
@@ -0,0 +1,33 @@
+Apache Tuscany Base Jar including all dependencies
+-----------------------
+
+This jar is an agregation of the minimal set of Tuscany module jars that are required to use a Tuscany runtime.
+Included in this jar are the modules to support using the Tuscany standalone, embedded, and webapp runtimes,
+distributed domain support, SCA assembly support for contributions, composites, implementation.java, and binding.rmi.
+
+Support for the JMS binding is also included but requires that the runtime environment supports JMS and JNDI, for example
+when running within a Java EE container or by including a JMS provider (eg Apache ActiveMQ) in the runtime classpath.
+
+This jar also includes the following dependencies:
+
+- asm:asm:jar:3.1
+- cglib:cglib:jar:2.2
+- org.apache.ws.commons.schema:XmlSchema:jar:1.4.2
+- com.hazelcast:hazelcast:jar:1.8.3
+- com.hazelcast:hazelcast-client:jar:1.8.3
+- wsdl4j:wsld4j:jar:1.6.2
+
+When running with less than Java 1.6 the following dependencies are required:
+
+- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1
+- org.codehaus.woodstox:wstx-asl:jar:3.2.4
+- javax.xml.bind:jaxb-api:jar:2.1
+- javax.activation:activation:jar:1.1
+- com.sun.xml.bind:jaxb-impl:jar:2.1.12
+- javax.xml.ws:jaxws-api:jar:2.1
+- javax.annotation:jsr250-api:jar:1.0
+- javax.jws:jsr181-api:jar:1.0-MR1
+- javax.xml.stream:stax-api:jar:1.0-2
+
+
+
diff --git a/sandbox/sebastien/java/embed/shades/base/pom.xml b/sandbox/sebastien/java/embed/shades/base/pom.xml
new file mode 100644
index 0000000000..bdf561d7b4
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base/pom.xml
@@ -0,0 +1,330 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <name>Apache Tuscany SCA Base Jar</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-launcher</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-hazelcast-client</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <!-- dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-javascript</artifactId>
+ <version>${pom.version}</version>
+ </dependency -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-hazelcast-runtime</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-shell</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-stripes</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>net.sourceforge.stripes</groupId>
+ <artifactId>stripes</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-wink</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-jaxws-ri</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+<!-- these remaining dependencies are not required when using JDK6, so use a scope of provided -->
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.12</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createSourcesJar>true</createSourcesJar>
+ <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:*</include>
+ <include>org.apache.tuscany.sca.shades:*</include>
+ </includes>
+ </artifactSet>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <manifestEntries>
+ <Main-Class>org.apache.tuscany.sca.launcher.LauncherMain</Main-Class>
+ </manifestEntries>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/base/src/main/resources/LICENSE b/sandbox/sebastien/java/embed/shades/base/src/main/resources/LICENSE
new file mode 100644
index 0000000000..69a1a5eee6
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base/src/main/resources/LICENSE
@@ -0,0 +1,234 @@
+
+ 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.
+
+===============================================================================
+
+This shaded jar also includes files uisng the following licenses:
+
+===============================================================================
+
+Permission to copy, display and distribute the Service Component Architecture Specification and/or
+portions thereof, without modification, in any medium without fee or royalty is hereby granted, provided
+that you include the following on ALL copies of the Service Component Architecture Specification, or
+portions thereof, that you make:
+
+1. A link or URL to the Service Component Architecture Specification at this location:
+· http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+
+2. The full text of the copyright notice as shown in the Service Component Architecture Specification.
+
+BEA, Cape Clear, IBM, Interface21, IONA, Oracle, Primeton, Progress Software, Red Hat, Rogue Wave,
+SAP, Siemens, Software AG., Sun, Sybase, TIBCO (collectively, the "Authors") agree to grant you a
+royalty-free license, under reasonable, non-discriminatory terms and conditions to patents that they deem
+necessary to implement the Service Component Architecture Specification.
+THE Service Component Architecture SPECIFICATION IS PROVIDED "AS IS," AND THE
+AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+REGARDING THIS SPECIFICATION AND THE IMPLEMENTATION OF ITS CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE.
+THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR
+DISTRIBUTION OF THE Service Components Architecture SPECIFICATION.
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+
diff --git a/sandbox/sebastien/java/embed/shades/base/src/main/resources/NOTICE b/sandbox/sebastien/java/embed/shades/base/src/main/resources/NOTICE
new file mode 100644
index 0000000000..1bfb4e16c3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base/src/main/resources/NOTICE
@@ -0,0 +1,12 @@
+Apache Tuscany Base Jar
+Copyright (c) 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product also includes software under the Service Component Architecture specification license
+(see the LICENSE file contained in this distribution) with the following copyright
+
+(c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA
+Technologies, Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens
+AG., Software AG., Sun Microsystems, Inc., Sybase Inc., TIBCO Software Inc., 2005, 2008. All rights reserved.
diff --git a/sandbox/sebastien/java/embed/shades/base/src/main/resources/README.txt b/sandbox/sebastien/java/embed/shades/base/src/main/resources/README.txt
new file mode 100644
index 0000000000..d8be6ae636
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/base/src/main/resources/README.txt
@@ -0,0 +1,31 @@
+Apache Tuscany Base Jar
+-----------------------
+
+This jar is an agregation of the minimal set of Tuscany module jars that are required to use a Tuscany runtime.
+Included in this jar are the modules to support using the Tuscany standalone, embedded, and webapp runtimes,
+distributed domain support, SCA assembly support for contributions, composites, implementation.java, and binding.rmi.
+
+Support for the JMS binding is also included but requires that the runtime environment supports JMS and JNDI, for example
+when running within a Java EE container or by including a JMS provider (eg Apache ActiveMQ) in the runtime classpath.
+
+This jar has the following dependencies:
+
+- asm:asm:jar:3.1
+- cglib:cglib:jar:2.2
+- org.apache.ws.commons.schema:XmlSchema:jar:1.4.2
+- com.hazelcast:hazelcast:jar:1.8 (optional, for distributed domain support)
+
+When running with less than Java 1.6 the following are also required:
+
+- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1
+- org.codehaus.woodstox:wstx-asl:jar:3.2.4
+- javax.xml.bind:jaxb-api:jar:2.1
+- javax.activation:activation:jar:1.1
+- com.sun.xml.bind:jaxb-impl:jar:2.1.12
+- javax.xml.ws:jaxws-api:jar:2.1
+- javax.annotation:jsr250-api:jar:1.0
+- javax.jws:jsr181-api:jar:1.0-MR1
+- javax.xml.stream:stax-api:jar:1.0-2
+
+
+
diff --git a/sandbox/sebastien/java/embed/shades/bpel-nodep/pom.xml b/sandbox/sebastien/java/embed/shades/bpel-nodep/pom.xml
new file mode 100644
index 0000000000..307adcf483
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/bpel-nodep/pom.xml
@@ -0,0 +1,75 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-bpel-nodep</artifactId>
+ <name>Apache Tuscany SCA BPEL Jar including dependencies</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-bpel</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-webservices</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/bpel/pom.xml b/sandbox/sebastien/java/embed/shades/bpel/pom.xml
new file mode 100644
index 0000000000..baa096015d
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/bpel/pom.xml
@@ -0,0 +1,132 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-bpel</artifactId>
+ <name>Apache Tuscany SCA BPEL Jar</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ </exclusion>
+ <!-- exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion -->
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:*</include>
+ </includes>
+ </artifactSet>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/jms-nodep/pom.xml b/sandbox/sebastien/java/embed/shades/jms-nodep/pom.xml
new file mode 100644
index 0000000000..f55209fe26
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/jms-nodep/pom.xml
@@ -0,0 +1,107 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-jms-nodep</artifactId>
+ <name>Apache Tuscany SCA JMS Support Jar including dependencies</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-jms</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>kahadb</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.activemq.protobuf</groupId>
+ <artifactId>activemq-protobuf</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/jms/pom.xml b/sandbox/sebastien/java/embed/shades/jms/pom.xml
new file mode 100644
index 0000000000..786be02392
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/jms/pom.xml
@@ -0,0 +1,124 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-jms</artifactId>
+ <name>Apache Tuscany SCA JMS Support Jar</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:*</include>
+ </includes>
+ </artifactSet>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/json-nodep/pom.xml b/sandbox/sebastien/java/embed/shades/json-nodep/pom.xml
new file mode 100644
index 0000000000..bcc4fe95e3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/json-nodep/pom.xml
@@ -0,0 +1,73 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-json-nodep</artifactId>
+ <name>Apache Tuscany SCA JSONP Support Jar including dependencies</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-json</artifactId>
+ <version>${pom.version}</version>
+
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/json/pom.xml b/sandbox/sebastien/java/embed/shades/json/pom.xml
new file mode 100644
index 0000000000..6457dbc082
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/json/pom.xml
@@ -0,0 +1,167 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-json</artifactId>
+ <name>Apache Tuscany SCA JSON Support Jar</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ </exclusion>
+ <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>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-client</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:*</include>
+ </includes>
+ </artifactSet>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/pom.xml b/sandbox/sebastien/java/embed/shades/pom.xml
new file mode 100644
index 0000000000..712af5b2f0
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/pom.xml
@@ -0,0 +1,45 @@
+<?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>
+ <relativePath>../pom.xml</relativePath>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>tuscany-shades</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Shaded Jars</name>
+
+ <modules>
+ <module>base</module>
+ <module>base-nodep</module>
+ <module>jms</module>
+ <module>json</module>
+ <module>json-nodep</module>
+ <module>spring</module>
+ <module>spring-nodep</module>
+ <module>webservices</module>
+ <module>webservices-nodep</module>
+ </modules>
+
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/spring-nodep/pom.xml b/sandbox/sebastien/java/embed/shades/spring-nodep/pom.xml
new file mode 100644
index 0000000000..02e3dd43c9
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/spring-nodep/pom.xml
@@ -0,0 +1,72 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-spring-nodep</artifactId>
+ <name>Apache Tuscany SCA Spring Support Jar including dependencies</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-spring</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/spring/pom.xml b/sandbox/sebastien/java/embed/shades/spring/pom.xml
new file mode 100644
index 0000000000..1697669788
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/spring/pom.xml
@@ -0,0 +1,111 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-spring</artifactId>
+ <name>Apache Tuscany SCA Spring Support Jar</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:*</include>
+ </includes>
+ </artifactSet>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/webservices-nodep/pom.xml b/sandbox/sebastien/java/embed/shades/webservices-nodep/pom.xml
new file mode 100644
index 0000000000..21e2e23aa3
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/webservices-nodep/pom.xml
@@ -0,0 +1,69 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-webservices-nodep</artifactId>
+ <name>Apache Tuscany SCA Web Services Jar including dependencies</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-webservices</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/sebastien/java/embed/shades/webservices/pom.xml b/sandbox/sebastien/java/embed/shades/webservices/pom.xml
new file mode 100644
index 0000000000..b93086d222
--- /dev/null
+++ b/sandbox/sebastien/java/embed/shades/webservices/pom.xml
@@ -0,0 +1,208 @@
+<?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-shades</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-webservices</artifactId>
+ <name>Apache Tuscany SCA Web Services Jar</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.rampart</groupId>
+ <artifactId>rampart-trust</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>opensaml</groupId>
+ <artifactId>opensaml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:*</include>
+ </includes>
+ </artifactSet>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>